@netless/appliance-plugin 1.0.4 → 1.0.7

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.
Files changed (53) hide show
  1. package/cdn/cdn.js +1 -1
  2. package/cdn/fullWorker-CF7R0e.js +438 -0
  3. package/cdn/subWorker-BbF9q2.js +438 -0
  4. package/dist/appliance-plugin.js +1 -1
  5. package/dist/appliance-plugin.mjs +7 -7
  6. package/dist/collector/utils/color.d.ts +1 -1
  7. package/dist/core/enum.d.ts +22 -16
  8. package/dist/core/mainEngine.d.ts +10 -3
  9. package/dist/core/mainThread/snapshotThread.d.ts +1 -1
  10. package/dist/core/mainThread/subLocalThread.d.ts +2 -1
  11. package/dist/core/mainThread/subTopThread.d.ts +3 -3
  12. package/dist/core/mainThread/workerMainThread.d.ts +99 -0
  13. package/dist/core/tools/eraser.d.ts +1 -20
  14. package/dist/core/tools/pencilEraser.d.ts +76 -0
  15. package/dist/core/tools/utils.d.ts +6 -5
  16. package/dist/core/types.d.ts +1 -0
  17. package/dist/core/utils/math.d.ts +3 -0
  18. package/dist/core/utils/spriteNode.d.ts +1 -1
  19. package/dist/core/vNodeManager.d.ts +1 -0
  20. package/dist/core/worker/base.d.ts +5 -2
  21. package/dist/core/worker/fullWorkerLocal.d.ts +2 -0
  22. package/dist/core/worker/subWorkerLocal.d.ts +3 -2
  23. package/dist/core/worker/subWorkerTopLayer.d.ts +3 -3
  24. package/dist/core/worker/workerManager.d.ts +1 -0
  25. package/dist/displayer/floatBar/index.d.ts +2 -2
  26. package/dist/displayer/floatBar/resizable/index.d.ts +1 -1
  27. package/dist/displayer/types.d.ts +0 -1
  28. package/dist/fullWorker.js +126 -125
  29. package/dist/index-2kLI3OsH.js +1 -0
  30. package/dist/index-C7xQ-iwn.mjs +2304 -0
  31. package/dist/index-DWP99OFK.mjs +13721 -0
  32. package/dist/index-OwNIkbKl.js +1 -0
  33. package/dist/plugin/baseApplianceManager.d.ts +5 -4
  34. package/dist/plugin/baseViewContainerManager.d.ts +4 -3
  35. package/dist/plugin/const.d.ts +3 -0
  36. package/dist/plugin/displayerView.d.ts +2 -1
  37. package/dist/plugin/multi/containerManager.d.ts +2 -0
  38. package/dist/plugin/multi/displayer/appViewDisplayerManager.d.ts +1 -0
  39. package/dist/plugin/multi/displayer/mainViewDisplayerManager.d.ts +1 -0
  40. package/dist/plugin/single/applianceSingleManager.d.ts +0 -1
  41. package/dist/plugin/single/containerManager.d.ts +2 -0
  42. package/dist/plugin/single/displayer/mainViewDisplayerManager.d.ts +1 -0
  43. package/dist/plugin/types.d.ts +11 -0
  44. package/dist/style.css +1 -1
  45. package/dist/subWorker.js +126 -125
  46. package/dist/undo/index.d.ts +0 -1
  47. package/package.json +6 -7
  48. package/cdn/fullWorker-DRJe2Z.js +0 -437
  49. package/cdn/subWorker-BCicGG.js +0 -437
  50. package/dist/index-BJWcnp2n.mjs +0 -5683
  51. package/dist/index-Bj242vt1.mjs +0 -9769
  52. package/dist/index-C_jpLx3X.js +0 -1
  53. package/dist/index-D6FsYoIf.js +0 -1
@@ -0,0 +1 @@
1
+ "use strict";var zs=Object.defineProperty;var xs=(r,o,t)=>o in r?zs(r,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[o]=t;var M=(r,o,t)=>xs(r,typeof o!="symbol"?o+"":o,t);const it=require("white-web-sdk"),ht=require("spritejs"),ki=require("lz-string"),zi=require("lineclip"),xi=require("eventemitter2"),E=require("lodash"),ko=require("react-dom"),g=require("react"),ge=require("react-draggable"),Ls=require("re-resizable"),bs="/fullWorker.js",js="/subWorker.js";var st=(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))(st||{}),_=(r=>(r.Normal="Normal",r.Stroke="Stroke",r.Dotted="Dotted",r.LongDotted="LongDotted",r))(_||{}),Pt=(r=>(r.Triangle="triangle",r.Rhombus="rhombus",r.Pentagram="pentagram",r.SpeechBalloon="speechBalloon",r.Star="star",r.Polygon="polygon",r))(Pt||{}),O=(r=>(r.None="None",r.ShowFloatBar="ShowFloatBar",r.ZIndexFloatBar="ZIndexFloatBar",r.DeleteNode="DeleteNode",r.CopyNode="CopyNode",r.ZIndexActive="ZIndexActive",r.ZIndexNode="ZIndexNode",r.RotateNode="RotateNode",r.SetColorNode="SetColorNode",r.TranslateNode="TranslateNode",r.ScaleNode="ScaleNode",r.OriginalEvent="OriginalEvent",r.CreateScene="CreateScene",r.ActiveCursor="ActiveCursor",r.MoveCursor="MoveCursor",r.CommandEditor="CommandEditor",r.SetEditorData="SetEditorData",r.SetFontStyle="SetFontStyle",r.SetPoint="SetPoint",r.SetLock="SetLock",r.SetShapeOpt="SetShapeOpt",r.CameraChange="CameraChange",r.ActiveMethod="ActiveMethod",r))(O||{}),Z=(r=>(r.DisplayState="DisplayState",r.MainEngine="MainEngine",r.Cursor="Cursor",r.BindMainView="BindMainView",r))(Z||{}),Li=(r=>(r[r.MainView=0]="MainView",r[r.Plugin=1]="Plugin",r[r.Both=2]="Both",r))(Li||{}),S=(r=>(r[r.Pencil=1]="Pencil",r[r.Eraser=2]="Eraser",r[r.PencilEraser=3]="PencilEraser",r[r.Selector=4]="Selector",r[r.Clicker=5]="Clicker",r[r.Arrow=6]="Arrow",r[r.Hand=7]="Hand",r[r.LaserPen=8]="LaserPen",r[r.Text=9]="Text",r[r.Straight=10]="Straight",r[r.Rectangle=11]="Rectangle",r[r.Ellipse=12]="Ellipse",r[r.Star=13]="Star",r[r.Triangle=14]="Triangle",r[r.Rhombus=15]="Rhombus",r[r.Polygon=16]="Polygon",r[r.SpeechBalloon=17]="SpeechBalloon",r[r.Image=18]="Image",r))(S||{}),U=(r=>(r[r.Local=1]="Local",r[r.Service=2]="Service",r[r.Worker=3]="Worker",r))(U||{}),b=(r=>(r[r.Pending=0]="Pending",r[r.Start=1]="Start",r[r.Doing=2]="Doing",r[r.Done=3]="Done",r[r.Unwritable=4]="Unwritable",r))(b||{}),x=(r=>(r[r.None=0]="None",r[r.Init=1]="Init",r[r.UpdateCamera=2]="UpdateCamera",r[r.UpdateTools=3]="UpdateTools",r[r.CreateWork=4]="CreateWork",r[r.DrawWork=5]="DrawWork",r[r.FullWork=6]="FullWork",r[r.UpdateNode=7]="UpdateNode",r[r.RemoveNode=8]="RemoveNode",r[r.Clear=9]="Clear",r[r.Select=10]="Select",r[r.Destroy=11]="Destroy",r[r.Snapshot=12]="Snapshot",r[r.BoundingBox=13]="BoundingBox",r[r.Cursor=14]="Cursor",r[r.TextUpdate=15]="TextUpdate",r[r.GetTextActive=16]="GetTextActive",r[r.TasksQueue=17]="TasksQueue",r[r.CursorHover=18]="CursorHover",r[r.CursorBlur=19]="CursorBlur",r[r.Console=20]="Console",r[r.PriorityWorker=21]="PriorityWorker",r[r.PriorityMainThreadWorker=22]="PriorityMainThreadWorker",r))(x||{}),Xe=(r=>(r.Webgl2="webgl2",r.Webgl="webgl",r.Canvas2d="2d",r))(Xe||{}),Yt=(r=>(r[r.None=0]="None",r[r.Bg=1]="Bg",r[r.ServiceFloat=2]="ServiceFloat",r[r.Float=3]="Float",r[r.TopFloat=4]="TopFloat",r))(Yt||{}),Ce=(r=>(r[r.Cursor=1]="Cursor",r[r.TextCreate=2]="TextCreate",r))(Ce||{}),ee=(r=>(r[r.Top=1]="Top",r[r.Bottom=2]="Bottom",r))(ee||{}),at=(r=>(r[r.none=1]="none",r[r.all=2]="all",r[r.both=3]="both",r[r.proportional=4]="proportional",r))(at||{}),bi=(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))(bi||{}),ke=(r=>(r[r.inside=0]="inside",r[r.outside=1]="outside",r[r.intersect=2]="intersect",r))(ke||{});const Ds={linear:r=>r,easeInQuad:r=>r*r,easeOutQuad:r=>r*(2-r),easeInOutQuad:r=>r<.5?2*r*r:-1+(4-2*r)*r,easeInCubic:r=>r*r*r,easeOutCubic:r=>--r*r*r+1,easeInOutCubic:r=>r<.5?4*r*r*r:(r-1)*(2*r-2)*(2*r-2)+1,easeInQuart:r=>r*r*r*r,easeOutQuart:r=>1- --r*r*r*r,easeInOutQuart:r=>r<.5?8*r*r*r*r:1-8*--r*r*r*r,easeInQuint:r=>r*r*r*r*r,easeOutQuint:r=>1+--r*r*r*r*r,easeInOutQuint:r=>r<.5?16*r*r*r*r*r:1+16*--r*r*r*r*r,easeInSine:r=>1-Math.cos(r*Math.PI/2),easeOutSine:r=>Math.sin(r*Math.PI/2),easeInOutSine:r=>-(Math.cos(Math.PI*r)-1)/2,easeInExpo:r=>r<=0?0:Math.pow(2,10*r-10),easeOutExpo:r=>r>=1?1:1-Math.pow(2,-10*r),easeInOutExpo:r=>r<=0?0:r>=1?1:r<.5?Math.pow(2,20*r-10)/2:(2-Math.pow(2,-20*r+10))/2};class k{constructor(o=0,t=0,e=1){this.x=o,this.y=t,this.z=e}get XY(){return[this.x,this.y]}setz(o){return this.z=o,this}setXY(o=this.x,t=this.y){return this.x=o,this.y=t,this}set(o=this.x,t=this.y,e=this.z){return this.x=o,this.y=t,this.z=e,this}setTo({x:o=0,y:t=0,z:e=1}){return this.x=o,this.y=t,this.z=e,this}rot(o){if(o===0)return this;const{x:t,y:e}=this,i=Math.sin(o),n=Math.cos(o);return this.x=t*n-e*i,this.y=t*i+e*n,this}rotWith(o,t){if(t===0)return this;const e=this.x-o.x,i=this.y-o.y,n=Math.sin(t),s=Math.cos(t);return this.x=o.x+(e*s-i*n),this.y=o.y+(e*n+i*s),this}clone(){const{x:o,y:t,z:e}=this;return new k(o,t,e)}sub(o){return this.x-=o.x,this.y-=o.y,this}subXY(o,t){return this.x-=o,this.y-=t,this}subScalar(o){return this.x-=o,this.y-=o,this}add(o){return this.x+=o.x,this.y+=o.y,this}addXY(o,t){return this.x+=o,this.y+=t,this}addScalar(o){return this.x+=o,this.y+=o,this}clamp(o,t){return this.x=Math.max(this.x,o),this.y=Math.max(this.y,o),t!==void 0&&(this.x=Math.min(this.x,t),this.y=Math.min(this.y,t)),this}div(o){return this.x/=o,this.y/=o,this}divV(o){return this.x/=o.x,this.y/=o.y,this}mul(o){return this.x*=o,this.y*=o,this}mulV(o){return this.x*=o.x,this.y*=o.y,this}abs(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),this}nudge(o,t){const e=k.Tan(o,this);return this.add(e.mul(t))}neg(){return this.x*=-1,this.y*=-1,this}cross(o){return this.x=this.y*o.z-this.z*o.y,this.y=this.z*o.x-this.x*o.z,this}dpr(o){return k.Dpr(this,o)}cpr(o){return k.Cpr(this,o)}len2(){return k.Len2(this)}len(){return k.Len(this)}pry(o){return k.Pry(this,o)}per(){const{x:o,y:t}=this;return this.x=t,this.y=-o,this}uni(){return k.Uni(this)}tan(o){return k.Tan(this,o)}dist(o){return k.Dist(this,o)}distanceToLineSegment(o,t){return k.DistanceToLineSegment(o,t,this)}slope(o){return k.Slope(this,o)}snapToGrid(o){return this.x=Math.round(this.x/o)*o,this.y=Math.round(this.y/o)*o,this}angle(o){return k.Angle(this,o)}toAngle(){return k.ToAngle(this)}lrp(o,t){return this.x=this.x+(o.x-this.x)*t,this.y=this.y+(o.y-this.y)*t,this}equals(o,t){return k.Equals(this,o,t)}equalsXY(o,t){return k.EqualsXY(this,o,t)}norm(){const o=this.len();return this.x=o===0?0:this.x/o,this.y=o===0?0:this.y/o,this}toFixed(){return k.ToFixed(this)}toString(){return k.ToString(k.ToFixed(this))}toJson(){return k.ToJson(this)}toArray(){return k.ToArray(this)}static Add(o,t){return new k(o.x+t.x,o.y+t.y)}static AddXY(o,t,e){return new k(o.x+t,o.y+e)}static Sub(o,t){return new k(o.x-t.x,o.y-t.y)}static SubXY(o,t,e){return new k(o.x-t,o.y-e)}static AddScalar(o,t){return new k(o.x+t,o.y+t)}static SubScalar(o,t){return new k(o.x-t,o.y-t)}static Div(o,t){return new k(o.x/t,o.y/t)}static Mul(o,t){return new k(o.x*t,o.y*t)}static DivV(o,t){return new k(o.x/t.x,o.y/t.y)}static MulV(o,t){return new k(o.x*t.x,o.y*t.y)}static Neg(o){return new k(-o.x,-o.y)}static Per(o){return new k(o.y,-o.x)}static Dist2(o,t){return k.Sub(o,t).len2()}static Abs(o){return new k(Math.abs(o.x),Math.abs(o.y))}static Dist(o,t){return Math.hypot(o.y-t.y,o.x-t.x)}static Dpr(o,t){return o.x*t.x+o.y*t.y}static Cross(o,t){return new k(o.y*t.z-o.z*t.y,o.z*t.x-o.x*t.z)}static Cpr(o,t){return o.x*t.y-t.x*o.y}static Len2(o){return o.x*o.x+o.y*o.y}static Len(o){return Math.hypot(o.x,o.y)}static Pry(o,t){return k.Dpr(o,t)/k.Len(t)}static Uni(o){return k.Div(o,k.Len(o))}static Tan(o,t){return k.Uni(k.Sub(o,t))}static Min(o,t){return new k(Math.min(o.x,t.x),Math.min(o.y,t.y))}static Max(o,t){return new k(Math.max(o.x,t.x),Math.max(o.y,t.y))}static From(o){return new k().add(o)}static FromArray(o){return new k(o[0],o[1])}static Rot(o,t=0){const e=Math.sin(t),i=Math.cos(t);return new k(o.x*i-o.y*e,o.x*e+o.y*i)}static RotWith(o,t,e){const i=o.x-t.x,n=o.y-t.y,s=Math.sin(e),a=Math.cos(e);return new k(t.x+(i*a-n*s),t.y+(i*s+n*a))}static NearestPointOnLineThroughPoint(o,t,e){return k.Mul(t,k.Sub(e,o).pry(t)).add(o)}static NearestPointOnLineSegment(o,t,e,i=!0){const n=k.Tan(t,o),s=k.Add(o,k.Mul(n,k.Sub(e,o).pry(n)));if(i){if(s.x<Math.min(o.x,t.x))return k.Cast(o.x<t.x?o:t);if(s.x>Math.max(o.x,t.x))return k.Cast(o.x>t.x?o:t);if(s.y<Math.min(o.y,t.y))return k.Cast(o.y<t.y?o:t);if(s.y>Math.max(o.y,t.y))return k.Cast(o.y>t.y?o:t)}return s}static DistanceToLineThroughPoint(o,t,e){return k.Dist(e,k.NearestPointOnLineThroughPoint(o,t,e))}static DistanceToLineSegment(o,t,e,i=!0){return k.Dist(e,k.NearestPointOnLineSegment(o,t,e,i))}static Snap(o,t=1){return new k(Math.round(o.x/t)*t,Math.round(o.y/t)*t)}static Cast(o){return o instanceof k?o:k.From(o)}static Slope(o,t){return o.x===t.y?NaN:(o.y-t.y)/(o.x-t.x)}static Angle(o,t){return Math.atan2(t.y-o.y,t.x-o.x)}static Lrp(o,t,e){return k.Sub(t,o).mul(e).add(o)}static Med(o,t){return new k((o.x+t.x)/2,(o.y+t.y)/2)}static Equals(o,t,e=1e-4){return Math.abs(o.x-t.x)<e&&Math.abs(o.y-t.y)<e}static EqualsXY(o,t,e){return o.x===t&&o.y===e}static EqualsXYZ(o,t,e=1e-4){return k.Equals(o,t,e)&&Math.abs((o.z||0)-(t.z||0))<e}static Clockwise(o,t,e){return(e.x-o.x)*(t.y-o.y)-(t.x-o.x)*(e.y-o.y)<0}static Rescale(o,t){const e=k.Len(o);return new k(t*o.x/e,t*o.y/e)}static ScaleWithOrigin(o,t,e){return k.Sub(o,e).mul(t).add(e)}static ScaleWOrigin(o,t,e){return k.Sub(o,e).mulV(t).add(e)}static ToFixed(o,t=2){return new k(+o.x.toFixed(t),+o.y.toFixed(t),+o.z.toFixed(t))}static Nudge(o,t,e){return k.Add(o,k.Tan(t,o).mul(e))}static ToString(o){return`${o.x}, ${o.y}`}static ToAngle(o){let t=Math.atan2(o.y,o.x);return t<0&&(t+=Math.PI*2),t}static FromAngle(o,t=1){return new k(Math.cos(o)*t,Math.sin(o)*t)}static ToArray(o){return[o.x,o.y,o.z]}static ToJson(o){const{x:t,y:e,z:i}=o;return{x:t,y:e,z:i}}static Average(o){const t=o.length,e=new k(0,0);for(let i=0;i<t;i++)e.add(o[i]);return e.div(t)}static Clamp(o,t,e){return e===void 0?new k(Math.min(Math.max(o.x,t)),Math.min(Math.max(o.y,t))):new k(Math.min(Math.max(o.x,t),e),Math.min(Math.max(o.y,t),e))}static PointsBetween(o,t,e=6){const i=[];for(let n=0;n<e;n++){const s=Ds.easeInQuad(n/(e-1)),a=k.Lrp(o,t,s);a.z=Math.min(1,.5+Math.abs(.5-Ps(s))*.65),i.push(a)}return i}static SnapToGrid(o,t=8){return new k(Math.round(o.x/t)*t,Math.round(o.y/t)*t)}}const Ps=r=>r<.5?2*r*r:-1+(4-2*r)*r;var Pe=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function je(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Es=typeof Pe=="object"&&Pe&&Pe.Object===Object&&Pe,ji=Es,As=ji,Os=typeof self=="object"&&self&&self.Object===Object&&self,Rs=As||Os||Function("return this")(),Rt=Rs,Ys=Rt,Ws=Ys.Symbol,Ke=Ws,Wo=Ke,Di=Object.prototype,Us=Di.hasOwnProperty,Bs=Di.toString,Te=Wo?Wo.toStringTag:void 0;function $s(r){var o=Us.call(r,Te),t=r[Te];try{r[Te]=void 0;var e=!0}catch{}var i=Bs.call(r);return e&&(o?r[Te]=t:delete r[Te]),i}var Fs=$s,Hs=Object.prototype,Qs=Hs.toString;function Vs(r){return Qs.call(r)}var Zs=Vs,Uo=Ke,Gs=Fs,Js=Zs,qs="[object Null]",Xs="[object Undefined]",Bo=Uo?Uo.toStringTag:void 0;function Ks(r){return r==null?r===void 0?Xs:qs:Bo&&Bo in Object(r)?Gs(r):Js(r)}var ie=Ks;function _s(r){return r!=null&&typeof r=="object"}var Ht=_s,tn=ie,en=Ht,on="[object Number]";function sn(r){return typeof r=="number"||en(r)&&tn(r)==on}var nn=sn;const Wt=je(nn);function rn(){this.__data__=[],this.size=0}var an=rn;function cn(r,o){return r===o||r!==r&&o!==o}var zo=cn,ln=zo;function hn(r,o){for(var t=r.length;t--;)if(ln(r[t][0],o))return t;return-1}var _e=hn,un=_e,dn=Array.prototype,pn=dn.splice;function fn(r){var o=this.__data__,t=un(o,r);if(t<0)return!1;var e=o.length-1;return t==e?o.pop():pn.call(o,t,1),--this.size,!0}var gn=fn,Mn=_e;function yn(r){var o=this.__data__,t=Mn(o,r);return t<0?void 0:o[t][1]}var wn=yn,mn=_e;function In(r){return mn(this.__data__,r)>-1}var vn=In,Nn=_e;function Tn(r,o){var t=this.__data__,e=Nn(t,r);return e<0?(++this.size,t.push([r,o])):t[e][1]=o,this}var Sn=Tn,Cn=an,kn=gn,zn=wn,xn=vn,Ln=Sn;function Me(r){var o=-1,t=r==null?0:r.length;for(this.clear();++o<t;){var e=r[o];this.set(e[0],e[1])}}Me.prototype.clear=Cn;Me.prototype.delete=kn;Me.prototype.get=zn;Me.prototype.has=xn;Me.prototype.set=Ln;var to=Me,bn=to;function jn(){this.__data__=new bn,this.size=0}var Dn=jn;function Pn(r){var o=this.__data__,t=o.delete(r);return this.size=o.size,t}var En=Pn;function An(r){return this.__data__.get(r)}var On=An;function Rn(r){return this.__data__.has(r)}var Yn=Rn;function Wn(r){var o=typeof r;return r!=null&&(o=="object"||o=="function")}var qt=Wn,Un=ie,Bn=qt,$n="[object AsyncFunction]",Fn="[object Function]",Hn="[object GeneratorFunction]",Qn="[object Proxy]";function Vn(r){if(!Bn(r))return!1;var o=Un(r);return o==Fn||o==Hn||o==$n||o==Qn}var Pi=Vn,Zn=Rt,Gn=Zn["__core-js_shared__"],Jn=Gn,ho=Jn,$o=function(){var r=/[^.]+$/.exec(ho&&ho.keys&&ho.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}();function qn(r){return!!$o&&$o in r}var Xn=qn,Kn=Function.prototype,_n=Kn.toString;function tr(r){if(r!=null){try{return _n.call(r)}catch{}try{return r+""}catch{}}return""}var Ei=tr,er=Pi,or=Xn,ir=qt,sr=Ei,nr=/[\\^$.*+?()[\]{}|]/g,rr=/^\[object .+?Constructor\]$/,ar=Function.prototype,cr=Object.prototype,lr=ar.toString,hr=cr.hasOwnProperty,ur=RegExp("^"+lr.call(hr).replace(nr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function dr(r){if(!ir(r)||or(r))return!1;var o=er(r)?ur:rr;return o.test(sr(r))}var pr=dr;function fr(r,o){return r==null?void 0:r[o]}var gr=fr,Mr=pr,yr=gr;function wr(r,o){var t=yr(r,o);return Mr(t)?t:void 0}var se=wr,mr=se,Ir=Rt,vr=mr(Ir,"Map"),xo=vr,Nr=se,Tr=Nr(Object,"create"),eo=Tr,Fo=eo;function Sr(){this.__data__=Fo?Fo(null):{},this.size=0}var Cr=Sr;function kr(r){var o=this.has(r)&&delete this.__data__[r];return this.size-=o?1:0,o}var zr=kr,xr=eo,Lr="__lodash_hash_undefined__",br=Object.prototype,jr=br.hasOwnProperty;function Dr(r){var o=this.__data__;if(xr){var t=o[r];return t===Lr?void 0:t}return jr.call(o,r)?o[r]:void 0}var Pr=Dr,Er=eo,Ar=Object.prototype,Or=Ar.hasOwnProperty;function Rr(r){var o=this.__data__;return Er?o[r]!==void 0:Or.call(o,r)}var Yr=Rr,Wr=eo,Ur="__lodash_hash_undefined__";function Br(r,o){var t=this.__data__;return this.size+=this.has(r)?0:1,t[r]=Wr&&o===void 0?Ur:o,this}var $r=Br,Fr=Cr,Hr=zr,Qr=Pr,Vr=Yr,Zr=$r;function ye(r){var o=-1,t=r==null?0:r.length;for(this.clear();++o<t;){var e=r[o];this.set(e[0],e[1])}}ye.prototype.clear=Fr;ye.prototype.delete=Hr;ye.prototype.get=Qr;ye.prototype.has=Vr;ye.prototype.set=Zr;var Gr=ye,Ho=Gr,Jr=to,qr=xo;function Xr(){this.size=0,this.__data__={hash:new Ho,map:new(qr||Jr),string:new Ho}}var Kr=Xr;function _r(r){var o=typeof r;return o=="string"||o=="number"||o=="symbol"||o=="boolean"?r!=="__proto__":r===null}var ta=_r,ea=ta;function oa(r,o){var t=r.__data__;return ea(o)?t[typeof o=="string"?"string":"hash"]:t.map}var oo=oa,ia=oo;function sa(r){var o=ia(this,r).delete(r);return this.size-=o?1:0,o}var na=sa,ra=oo;function aa(r){return ra(this,r).get(r)}var ca=aa,la=oo;function ha(r){return la(this,r).has(r)}var ua=ha,da=oo;function pa(r,o){var t=da(this,r),e=t.size;return t.set(r,o),this.size+=t.size==e?0:1,this}var fa=pa,ga=Kr,Ma=na,ya=ca,wa=ua,ma=fa;function we(r){var o=-1,t=r==null?0:r.length;for(this.clear();++o<t;){var e=r[o];this.set(e[0],e[1])}}we.prototype.clear=ga;we.prototype.delete=Ma;we.prototype.get=ya;we.prototype.has=wa;we.prototype.set=ma;var Ai=we,Ia=to,va=xo,Na=Ai,Ta=200;function Sa(r,o){var t=this.__data__;if(t instanceof Ia){var e=t.__data__;if(!va||e.length<Ta-1)return e.push([r,o]),this.size=++t.size,this;t=this.__data__=new Na(e)}return t.set(r,o),this.size=t.size,this}var Ca=Sa,ka=to,za=Dn,xa=En,La=On,ba=Yn,ja=Ca;function me(r){var o=this.__data__=new ka(r);this.size=o.size}me.prototype.clear=za;me.prototype.delete=xa;me.prototype.get=La;me.prototype.has=ba;me.prototype.set=ja;var Oi=me;function Da(r,o){for(var t=-1,e=r==null?0:r.length;++t<e&&o(r[t],t,r)!==!1;);return r}var Pa=Da,Ea=se,Aa=function(){try{var r=Ea(Object,"defineProperty");return r({},"",{}),r}catch{}}(),Oa=Aa,Qo=Oa;function Ra(r,o,t){o=="__proto__"&&Qo?Qo(r,o,{configurable:!0,enumerable:!0,value:t,writable:!0}):r[o]=t}var Ri=Ra,Ya=Ri,Wa=zo,Ua=Object.prototype,Ba=Ua.hasOwnProperty;function $a(r,o,t){var e=r[o];(!(Ba.call(r,o)&&Wa(e,t))||t===void 0&&!(o in r))&&Ya(r,o,t)}var Yi=$a,Fa=Yi,Ha=Ri;function Qa(r,o,t,e){var i=!t;t||(t={});for(var n=-1,s=o.length;++n<s;){var a=o[n],c=e?e(t[a],r[a],a,t,r):void 0;c===void 0&&(c=r[a]),i?Ha(t,a,c):Fa(t,a,c)}return t}var io=Qa;function Va(r,o){for(var t=-1,e=Array(r);++t<r;)e[t]=o(t);return e}var Za=Va,Ga=ie,Ja=Ht,qa="[object Arguments]";function Xa(r){return Ja(r)&&Ga(r)==qa}var Ka=Xa,Vo=Ka,_a=Ht,Wi=Object.prototype,tc=Wi.hasOwnProperty,ec=Wi.propertyIsEnumerable,oc=Vo(function(){return arguments}())?Vo:function(r){return _a(r)&&tc.call(r,"callee")&&!ec.call(r,"callee")},ic=oc,sc=Array.isArray,so=sc,Ue={exports:{}};function nc(){return!1}var rc=nc;Ue.exports;(function(r,o){var t=Rt,e=rc,i=o&&!o.nodeType&&o,n=i&&!0&&r&&!r.nodeType&&r,s=n&&n.exports===i,a=s?t.Buffer:void 0,c=a?a.isBuffer:void 0,l=c||e;r.exports=l})(Ue,Ue.exports);var Lo=Ue.exports,ac=9007199254740991,cc=/^(?:0|[1-9]\d*)$/;function lc(r,o){var t=typeof r;return o=o??ac,!!o&&(t=="number"||t!="symbol"&&cc.test(r))&&r>-1&&r%1==0&&r<o}var hc=lc,uc=9007199254740991;function dc(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=uc}var Ui=dc,pc=ie,fc=Ui,gc=Ht,Mc="[object Arguments]",yc="[object Array]",wc="[object Boolean]",mc="[object Date]",Ic="[object Error]",vc="[object Function]",Nc="[object Map]",Tc="[object Number]",Sc="[object Object]",Cc="[object RegExp]",kc="[object Set]",zc="[object String]",xc="[object WeakMap]",Lc="[object ArrayBuffer]",bc="[object DataView]",jc="[object Float32Array]",Dc="[object Float64Array]",Pc="[object Int8Array]",Ec="[object Int16Array]",Ac="[object Int32Array]",Oc="[object Uint8Array]",Rc="[object Uint8ClampedArray]",Yc="[object Uint16Array]",Wc="[object Uint32Array]",pt={};pt[jc]=pt[Dc]=pt[Pc]=pt[Ec]=pt[Ac]=pt[Oc]=pt[Rc]=pt[Yc]=pt[Wc]=!0;pt[Mc]=pt[yc]=pt[Lc]=pt[wc]=pt[bc]=pt[mc]=pt[Ic]=pt[vc]=pt[Nc]=pt[Tc]=pt[Sc]=pt[Cc]=pt[kc]=pt[zc]=pt[xc]=!1;function Uc(r){return gc(r)&&fc(r.length)&&!!pt[pc(r)]}var Bc=Uc;function $c(r){return function(o){return r(o)}}var bo=$c,Be={exports:{}};Be.exports;(function(r,o){var t=ji,e=o&&!o.nodeType&&o,i=e&&!0&&r&&!r.nodeType&&r,n=i&&i.exports===e,s=n&&t.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})(Be,Be.exports);var jo=Be.exports,Fc=Bc,Hc=bo,Zo=jo,Go=Zo&&Zo.isTypedArray,Qc=Go?Hc(Go):Fc,Bi=Qc,Vc=Za,Zc=ic,Gc=so,Jc=Lo,qc=hc,Xc=Bi,Kc=Object.prototype,_c=Kc.hasOwnProperty;function tl(r,o){var t=Gc(r),e=!t&&Zc(r),i=!t&&!e&&Jc(r),n=!t&&!e&&!i&&Xc(r),s=t||e||i||n,a=s?Vc(r.length,String):[],c=a.length;for(var l in r)(o||_c.call(r,l))&&!(s&&(l=="length"||i&&(l=="offset"||l=="parent")||n&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||qc(l,c)))&&a.push(l);return a}var $i=tl,el=Object.prototype;function ol(r){var o=r&&r.constructor,t=typeof o=="function"&&o.prototype||el;return r===t}var Do=ol;function il(r,o){return function(t){return r(o(t))}}var Fi=il,sl=Fi,nl=sl(Object.keys,Object),rl=nl,al=Do,cl=rl,ll=Object.prototype,hl=ll.hasOwnProperty;function ul(r){if(!al(r))return cl(r);var o=[];for(var t in Object(r))hl.call(r,t)&&t!="constructor"&&o.push(t);return o}var dl=ul,pl=Pi,fl=Ui;function gl(r){return r!=null&&fl(r.length)&&!pl(r)}var Hi=gl,Ml=$i,yl=dl,wl=Hi;function ml(r){return wl(r)?Ml(r):yl(r)}var Po=ml,Il=io,vl=Po;function Nl(r,o){return r&&Il(o,vl(o),r)}var Tl=Nl;function Sl(r){var o=[];if(r!=null)for(var t in Object(r))o.push(t);return o}var Cl=Sl,kl=qt,zl=Do,xl=Cl,Ll=Object.prototype,bl=Ll.hasOwnProperty;function jl(r){if(!kl(r))return xl(r);var o=zl(r),t=[];for(var e in r)e=="constructor"&&(o||!bl.call(r,e))||t.push(e);return t}var Dl=jl,Pl=$i,El=Dl,Al=Hi;function Ol(r){return Al(r)?Pl(r,!0):El(r)}var Eo=Ol,Rl=io,Yl=Eo;function Wl(r,o){return r&&Rl(o,Yl(o),r)}var Ul=Wl,$e={exports:{}};$e.exports;(function(r,o){var t=Rt,e=o&&!o.nodeType&&o,i=e&&!0&&r&&!r.nodeType&&r,n=i&&i.exports===e,s=n?t.Buffer:void 0,a=s?s.allocUnsafe:void 0;function c(l,h){if(h)return l.slice();var u=l.length,d=a?a(u):new l.constructor(u);return l.copy(d),d}r.exports=c})($e,$e.exports);var Bl=$e.exports;function $l(r,o){var t=-1,e=r.length;for(o||(o=Array(e));++t<e;)o[t]=r[t];return o}var Fl=$l;function Hl(r,o){for(var t=-1,e=r==null?0:r.length,i=0,n=[];++t<e;){var s=r[t];o(s,t,r)&&(n[i++]=s)}return n}var Ql=Hl;function Vl(){return[]}var Qi=Vl,Zl=Ql,Gl=Qi,Jl=Object.prototype,ql=Jl.propertyIsEnumerable,Jo=Object.getOwnPropertySymbols,Xl=Jo?function(r){return r==null?[]:(r=Object(r),Zl(Jo(r),function(o){return ql.call(r,o)}))}:Gl,Ao=Xl,Kl=io,_l=Ao;function th(r,o){return Kl(r,_l(r),o)}var eh=th;function oh(r,o){for(var t=-1,e=o.length,i=r.length;++t<e;)r[i+t]=o[t];return r}var Vi=oh,ih=Fi,sh=ih(Object.getPrototypeOf,Object),Zi=sh,nh=Vi,rh=Zi,ah=Ao,ch=Qi,lh=Object.getOwnPropertySymbols,hh=lh?function(r){for(var o=[];r;)nh(o,ah(r)),r=rh(r);return o}:ch,Gi=hh,uh=io,dh=Gi;function ph(r,o){return uh(r,dh(r),o)}var fh=ph,gh=Vi,Mh=so;function yh(r,o,t){var e=o(r);return Mh(r)?e:gh(e,t(r))}var Ji=yh,wh=Ji,mh=Ao,Ih=Po;function vh(r){return wh(r,Ih,mh)}var qi=vh,Nh=Ji,Th=Gi,Sh=Eo;function Ch(r){return Nh(r,Sh,Th)}var kh=Ch,zh=se,xh=Rt,Lh=zh(xh,"DataView"),bh=Lh,jh=se,Dh=Rt,Ph=jh(Dh,"Promise"),Eh=Ph,Ah=se,Oh=Rt,Rh=Ah(Oh,"Set"),Yh=Rh,Wh=se,Uh=Rt,Bh=Wh(Uh,"WeakMap"),$h=Bh,Mo=bh,yo=xo,wo=Eh,mo=Yh,Io=$h,Xi=ie,Ie=Ei,qo="[object Map]",Fh="[object Object]",Xo="[object Promise]",Ko="[object Set]",_o="[object WeakMap]",ti="[object DataView]",Hh=Ie(Mo),Qh=Ie(yo),Vh=Ie(wo),Zh=Ie(mo),Gh=Ie(Io),Kt=Xi;(Mo&&Kt(new Mo(new ArrayBuffer(1)))!=ti||yo&&Kt(new yo)!=qo||wo&&Kt(wo.resolve())!=Xo||mo&&Kt(new mo)!=Ko||Io&&Kt(new Io)!=_o)&&(Kt=function(r){var o=Xi(r),t=o==Fh?r.constructor:void 0,e=t?Ie(t):"";if(e)switch(e){case Hh:return ti;case Qh:return qo;case Vh:return Xo;case Zh:return Ko;case Gh:return _o}return o});var no=Kt,Jh=Object.prototype,qh=Jh.hasOwnProperty;function Xh(r){var o=r.length,t=new r.constructor(o);return o&&typeof r[0]=="string"&&qh.call(r,"index")&&(t.index=r.index,t.input=r.input),t}var Kh=Xh,_h=Rt,tu=_h.Uint8Array,Ki=tu,ei=Ki;function eu(r){var o=new r.constructor(r.byteLength);return new ei(o).set(new ei(r)),o}var Oo=eu,ou=Oo;function iu(r,o){var t=o?ou(r.buffer):r.buffer;return new r.constructor(t,r.byteOffset,r.byteLength)}var su=iu,nu=/\w*$/;function ru(r){var o=new r.constructor(r.source,nu.exec(r));return o.lastIndex=r.lastIndex,o}var au=ru,oi=Ke,ii=oi?oi.prototype:void 0,si=ii?ii.valueOf:void 0;function cu(r){return si?Object(si.call(r)):{}}var lu=cu,hu=Oo;function uu(r,o){var t=o?hu(r.buffer):r.buffer;return new r.constructor(t,r.byteOffset,r.length)}var du=uu,pu=Oo,fu=su,gu=au,Mu=lu,yu=du,wu="[object Boolean]",mu="[object Date]",Iu="[object Map]",vu="[object Number]",Nu="[object RegExp]",Tu="[object Set]",Su="[object String]",Cu="[object Symbol]",ku="[object ArrayBuffer]",zu="[object DataView]",xu="[object Float32Array]",Lu="[object Float64Array]",bu="[object Int8Array]",ju="[object Int16Array]",Du="[object Int32Array]",Pu="[object Uint8Array]",Eu="[object Uint8ClampedArray]",Au="[object Uint16Array]",Ou="[object Uint32Array]";function Ru(r,o,t){var e=r.constructor;switch(o){case ku:return pu(r);case wu:case mu:return new e(+r);case zu:return fu(r,t);case xu:case Lu:case bu:case ju:case Du:case Pu:case Eu:case Au:case Ou:return yu(r,t);case Iu:return new e;case vu:case Su:return new e(r);case Nu:return gu(r);case Tu:return new e;case Cu:return Mu(r)}}var Yu=Ru,Wu=qt,ni=Object.create,Uu=function(){function r(){}return function(o){if(!Wu(o))return{};if(ni)return ni(o);r.prototype=o;var t=new r;return r.prototype=void 0,t}}(),Bu=Uu,$u=Bu,Fu=Zi,Hu=Do;function Qu(r){return typeof r.constructor=="function"&&!Hu(r)?$u(Fu(r)):{}}var Vu=Qu,Zu=no,Gu=Ht,Ju="[object Map]";function qu(r){return Gu(r)&&Zu(r)==Ju}var Xu=qu,Ku=Xu,_u=bo,ri=jo,ai=ri&&ri.isMap,td=ai?_u(ai):Ku,ed=td,od=no,id=Ht,sd="[object Set]";function nd(r){return id(r)&&od(r)==sd}var rd=nd,ad=rd,cd=bo,ci=jo,li=ci&&ci.isSet,ld=li?cd(li):ad,hd=ld,ud=Oi,dd=Pa,pd=Yi,fd=Tl,gd=Ul,Md=Bl,yd=Fl,wd=eh,md=fh,Id=qi,vd=kh,Nd=no,Td=Kh,Sd=Yu,Cd=Vu,kd=so,zd=Lo,xd=ed,Ld=qt,bd=hd,jd=Po,Dd=Eo,Pd=1,Ed=2,Ad=4,_i="[object Arguments]",Od="[object Array]",Rd="[object Boolean]",Yd="[object Date]",Wd="[object Error]",ts="[object Function]",Ud="[object GeneratorFunction]",Bd="[object Map]",$d="[object Number]",es="[object Object]",Fd="[object RegExp]",Hd="[object Set]",Qd="[object String]",Vd="[object Symbol]",Zd="[object WeakMap]",Gd="[object ArrayBuffer]",Jd="[object DataView]",qd="[object Float32Array]",Xd="[object Float64Array]",Kd="[object Int8Array]",_d="[object Int16Array]",tp="[object Int32Array]",ep="[object Uint8Array]",op="[object Uint8ClampedArray]",ip="[object Uint16Array]",sp="[object Uint32Array]",dt={};dt[_i]=dt[Od]=dt[Gd]=dt[Jd]=dt[Rd]=dt[Yd]=dt[qd]=dt[Xd]=dt[Kd]=dt[_d]=dt[tp]=dt[Bd]=dt[$d]=dt[es]=dt[Fd]=dt[Hd]=dt[Qd]=dt[Vd]=dt[ep]=dt[op]=dt[ip]=dt[sp]=!0;dt[Wd]=dt[ts]=dt[Zd]=!1;function Ye(r,o,t,e,i,n){var s,a=o&Pd,c=o&Ed,l=o&Ad;if(t&&(s=i?t(r,e,i,n):t(r)),s!==void 0)return s;if(!Ld(r))return r;var h=kd(r);if(h){if(s=Td(r),!a)return yd(r,s)}else{var u=Nd(r),d=u==ts||u==Ud;if(zd(r))return Md(r,a);if(u==es||u==_i||d&&!i){if(s=c||d?{}:Cd(r),!a)return c?md(r,gd(s,r)):wd(r,fd(s,r))}else{if(!dt[u])return i?r:{};s=Sd(r,u,a)}}n||(n=new ud);var p=n.get(r);if(p)return p;n.set(r,s),bd(r)?r.forEach(function(y){s.add(Ye(y,o,t,y,r,n))}):xd(r)&&r.forEach(function(y,v){s.set(v,Ye(y,o,t,v,r,n))});var f=l?c?vd:Id:c?Dd:jd,I=h?void 0:f(r);return dd(I||r,function(y,v){I&&(v=y,y=r[v]),pd(s,v,Ye(y,o,t,v,r,n))}),s}var np=Ye,rp=np,ap=1,cp=4;function lp(r){return rp(r,ap|cp)}var hp=lp;const Qt=je(hp),os="1.0.7",up="@netless/appliance-plugin",is=typeof OffscreenCanvas=="function"?"worker":"mainThread";if(typeof window<"u"){let r=window.__netlessUA||"";r+=` ${up}@${os}_${is}`,window.__netlessUA=r}const xt={syncOpt:{interval:500},canvasOpt:{contextType:Xe.Canvas2d},cdn:{subWorkerUrl:"https://cdn.jsdelivr.net/npm/@netless/appliance-plugin@latest/dist/subWorker.js",fullWorkerUrl:"https://cdn.jsdelivr.net/npm/@netless/appliance-plugin@latest/dist/fullWorker.js"},cursor:{expirationTime:5e3},bufferSize:{full:2e4,sub:1e3},bezier:{combineUnitTime:100}},kt=class kt{constructor(o){M(this,"syncUnitTime",xt.syncOpt.interval);M(this,"vNodes");M(this,"drawLayer");M(this,"fullLayer");M(this,"workId");const{vNodes:t,fullLayer:e,drawLayer:i,workId:n,toolsOpt:s}=o;this.vNodes=t,this.fullLayer=e,this.drawLayer=i,this.workId=n,this.syncUnitTime=s.syncUnitTime||this.syncUnitTime}get baseConsumeResult(){return{workId:this.workId,toolsType:this.toolsType,opt:this.workOptions}}filterSamePoints(o,t=.01){return o.reduce((e,i)=>{const n=e[e.length-1];return(i&&!n||i&&n&&!i.isNear(n,t))&&e.push(i),e},[])}setWorkId(o){this.workId=o}getWorkId(){return this.workId}getWorkOptions(){return this.workOptions}setWorkOptions(o){var i,n,s;this.workOptions=o,this.syncUnitTime=o.syncUnitTime||this.syncUnitTime;const t=(i=this.workId)==null?void 0:i.toString(),e=t&&((n=this.vNodes)==null?void 0:n.get(t))||void 0;t&&e&&(e.opt=o,(s=this.vNodes)==null||s.setInfo(t,e))}updataOptService(o){var i,n;let t;const e=(i=this.workId)==null?void 0:i.toString();if(e&&o){const s=this.fullLayer.getElementsByName(e)||this.drawLayer&&this.drawLayer.getElementsByName(e)||[];if(s.length!==1)return;const a=s[0],{pos:c,zIndex:l,scale:h,angle:u,translate:d}=o,p={};Wt(l)&&(p.zIndex=l),c&&(p.pos=[c[0],c[1]]),h&&(p.scale=h),u&&(p.rotate=u),d&&(p.translate=d),a.attr(p);const f=a==null?void 0:a.getBoundingClientRect();return f&&(t=ut(t,{x:Math.floor(f.x-kt.SafeBorderPadding),y:Math.floor(f.y-kt.SafeBorderPadding),w:Math.floor(f.width+kt.SafeBorderPadding*2),h:Math.floor(f.height+kt.SafeBorderPadding*2)})),(n=this.vNodes)==null||n.setInfo(e,{rect:t,centerPos:c}),t}}replace(o,t,e){var a;const i=o.getElementsByName(t),n=i.length;if(n){if(n>1)for(let c=1;c<i.length;c++)o.removeChild(i[c]),i[c].disconnect();e?o.replaceChild(e,i[0]):o.removeChild(i[0]),i[0].disconnect()}else e&&o.append(e);this.fullLayer===o?(a=this.drawLayer)==null||a.getElementsByName(t).forEach(c=>{var l;(l=this.drawLayer)==null||l.removeChild(c),c.disconnect()}):this.fullLayer.getElementsByName(t).forEach(c=>{this.fullLayer.removeChild(c),c.disconnect()})}static updateNodeOpt(o){var w;const{node:t,opt:e,vNodes:i,willSerializeData:n,targetNode:s}=o,{zIndex:a,translate:c,angle:l,originPoint:h,scenePoint:u,scale:d,pointMap:p,thickness:f}=e;let I;const y=s&&Qt(s)||i.get(t.name);if(!y)return;Wt(a)&&(t.setAttribute("zIndex",a),y.opt.zIndex=a);const v=t.parent;if(v){if(h&&d&&s){const m=[y.op[0],y.op[1]];Ro(y.op,u,d,c);const T=[y.op[0],y.op[1]],N=[T[0]-m[0],T[1]-m[1]];y.centerPos=[y.centerPos[0]+N[0],y.centerPos[1]+N[1]],y.opt.translate=void 0,y.opt.scale=void 0}else if(c)if(t.setAttribute("translate",c),y.opt.translate=c,s){const m=[c[0]*v.worldScaling[0],c[1]*v.worldScaling[1]];I=Sf(y.rect,m),y.rect=I}else{const m=kt.getRectFromLayer(v,t.name);y.rect=m||y.rect}else if(Wt(l))if(t.setAttribute("rotate",l),y.opt.rotate=l,s)I=ms(y.rect,l),y.rect=I;else{const m=kt.getRectFromLayer(v,t.name);y.rect=m||y.rect}if(p){const m=p.get(t.name);if(m)for(let T=0,N=0;T<y.op.length;T+=3,N++)y.op[T]=m[N][0],y.op[T+1]=m[N][1]}if(f&&((w=y==null?void 0:y.opt)!=null&&w.thickness)&&(y.opt.thickness=f),n&&!(h&&d&&s)){if(c){const m=y.op.map((T,N)=>{const C=N%3;return C===0?T+c[0]:C===1?T+c[1]:T});y.op=m,y.centerPos=[y.centerPos[0]+c[0],y.centerPos[1]+c[1]],y!=null&&y.opt&&(y.opt.translate=void 0)}else if(Wt(l)){const m=y.op;kf(m,y.centerPos,l),y.op=m,y!=null&&y.opt&&(y.opt.rotate=void 0)}}y&&i.setInfo(t.name,y)}}static getCenterPos(o,t){const{worldPosition:e,worldScaling:i}=t;return[(o.x+o.w/2-e[0])/i[0],(o.y+o.h/2-e[1])/i[1]]}static getRectFromLayer(o,t){const e=o.getElementsByName(t)[0];if(e){const i=e.getBoundingClientRect();return{x:Math.floor(i.x-kt.SafeBorderPadding),y:Math.floor(i.y-kt.SafeBorderPadding),w:Math.floor(i.width+kt.SafeBorderPadding*2),h:Math.floor(i.height+kt.SafeBorderPadding*2)}}}};M(kt,"SafeBorderPadding",10);let Y=kt;class F extends k{constructor(o=0,t=0,e=0,i={x:0,y:0},n=0,s=0){super(o,t,e),this.x=o,this.y=t,this.z=e,this.v=i,this.t=n,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(o){this.a=o}setT(o){this.t=o}setv(o){return this.v={x:o.x,y:o.y},this}set(o=this.x,t=this.y,e=this.z,i=this.v,n=this.t,s=this.a){return this.x=o,this.y=t,this.z=e,this.v=i,this.t=n,this.a=s,this}clone(){const{x:o,y:t,z:e,v:i,t:n,a:s}=this,a={x:i.x,y:i.y};return new F(o,t,e,a,n,s)}distance(o){return F.GetDistance(this,o)}isNear(o,t){return F.IsNear(this,o,t)}getAngleByPoints(o,t){return F.GetAngleByPoints(o,this,t)}static Sub(o,t){return new F(o.x-t.x,o.y-t.y)}static Add(o,t){return new F(o.x+t.x,o.y+t.y)}static GetDistance(o,t){return F.Len(o.clone().sub(t))}static GetAngleByPoints(o,t,e){const i=t.x-o.x,n=e.x-t.x,s=t.y-o.y,a=e.y-t.y;let c=0;const l=Math.sqrt(i*i+s*s),h=Math.sqrt(n*n+a*a);if(l&&h){const u=i*n+s*a;c=Math.acos(u/(l*h)),c=c/Math.PI*180;let d=i*a-s*n;d=d>0?1:-1,c=180+d*c}return c}static IsNear(o,t,e){return F.Len(o.clone().sub(t))<e}static RotWith(o,t,e,i=2){const n=o.x-t.x,s=o.y-t.y,a=Math.sin(e),c=Math.cos(e),l=Math.pow(10,i),h=Math.floor((t.x+(n*c-s*a))*l)/l,u=Math.floor((t.y+(n*a+s*c))*l)/l;return new F(h,u)}static GetDotStroke(o,t,e=16){const i=new k(1,1),n=Math.PI+.001,s=F.Add(o,F.Sub(o,i).uni().per().mul(-t)),a=[];for(let c=1/e,l=c;l<=1;l+=c)a.push(F.RotWith(s,o,n*2*l));return a}static GetSemicircleStroke(o,t,e=-1,i=8){const n=e*(Math.PI+.001),s=[];for(let a=1/i,c=a;c<=1;c+=a)s.push(F.RotWith(t,o,n*c));return s}}function oe(r,o=!0){const t=r.length;if(t<2)return"";let e=r[0],i=r[1];if(t===2)return`M${ne(e)}L${ne(i)}`;let n="";for(let s=2,a=t-1;s<a;s++)e=r[s],i=r[s+1],n+=re(e,i);return o?`M${re(r[0],r[1])}Q${ne(r[1])}${re(r[1],r[2])}T${n}${re(r[t-1],r[0])}${re(r[0],r[1])}Z`:`M${ne(r[0])}Q${ne(r[1])}${re(r[1],r[2])}${r.length>3?"T":""}${n}L${ne(r[t-1])}`}function ve(r){return JSON.parse(ki.decompress(r))}function Lt(r){return ki.compress(JSON.stringify(r))}const Ct=Object.keys;class ss extends Y{constructor(t){super(t);M(this,"canRotate",!0);M(this,"scaleType",at.all);M(this,"toolsType",S.Pencil);M(this,"syncTimestamp");M(this,"syncIndex",0);M(this,"tmpPoints",[]);M(this,"MAX_REPEAR",10);M(this,"uniThickness");M(this,"workOptions");M(this,"centerPos",[0,0]);this.workOptions=t.toolsOpt,this.uniThickness=this.MAX_REPEAR/this.workOptions.thickness/10,this.syncTimestamp=0}combineConsume(){var a;const t=(a=this.workId)==null?void 0:a.toString();if(this.tmpPoints.length<2)return{type:x.None};const e=this.transformDataAll(!0),i={name:t};let n;const s=this.drawLayer||this.fullLayer;return e.length&&(n=this.draw({attrs:i,tasks:e,replaceId:t,layer:s})),{rect:n,type:x.DrawWork,dataType:U.Local}}setWorkOptions(t){super.setWorkOptions(t),this.syncTimestamp=Date.now()}consume(t){const{data:e,isFullWork:i,isSubWorker:n,isMainThread:s,drawCount:a,replaceId:c}=t,{workId:l}=e,{tasks:h,effects:u,consumeIndex:d}=this.transformData(e,!1);this.syncIndex=Math.min(this.syncIndex,d,Math.max(0,this.tmpPoints.length-2));const p={name:l,id:a==null?void 0:a.toString()};let f,I=!1;const y=this.syncIndex;if(this.syncTimestamp===0&&(this.syncTimestamp=Date.now()),h.length&&(h[0].taskId-this.syncTimestamp>this.syncUnitTime&&(I=!0,this.syncTimestamp=h[0].taskId,this.syncIndex=this.tmpPoints.length),n||s)){const w=i?this.fullLayer:this.drawLayer||this.fullLayer;f=this.draw({attrs:p,tasks:h,effects:u,layer:w,replaceId:c})}if(n)return d>10&&this.tmpPoints.splice(0,d-10),{rect:f,type:x.DrawWork,dataType:U.Local};const v=[];return this.tmpPoints.slice(y).forEach(w=>{v.push(w.x,w.y,this.computRadius(w.z,this.workOptions.thickness))}),{...this.baseConsumeResult,type:x.DrawWork,dataType:U.Local,rect:f,op:I?v:void 0,index:I?y*3:void 0,updateNodeOpt:{useAnimation:!0}}}consumeAll(t){var h;const e=this.workId;if(t.data){const{op:u,workState:d}=t.data;u!=null&&u.length&&d===b.Done&&this.workOptions.strokeType===_.Stroke&&this.updateTempPointsWithPressureWhenDone(u)}const i=this.transformDataAll(!0),n={name:e};let s;const a=this.fullLayer;if(i.length&&(s=this.draw({attrs:n,tasks:i,replaceId:e,layer:a})),this.tmpPoints.length<2)return this.replace(a,e),{type:x.RemoveNode,removeIds:[e],rect:s};const c=[];this.tmpPoints.map(u=>{c.push(u.x,u.y,u.z)}),this.syncTimestamp=0,delete this.workOptions.syncUnitTime;const l=Lt(c);return(h=this.vNodes)==null||h.setInfo(e,{rect:s,op:c,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:s&&Y.getCenterPos(s,a)}),{...this.baseConsumeResult,rect:s,type:x.FullWork,dataType:U.Local,ops:l,updateNodeOpt:{pos:this.centerPos,useAnimation:!0}}}clearTmpPoints(){this.tmpPoints.length=0,this.syncTimestamp=0,this.syncIndex=0}consumeService(t){var h,u;const{op:e,isFullWork:i,replaceId:n}=t;this.tmpPoints.length=0;for(let d=0;d<e.length;d+=3){const p=new F(e[d],e[d+1],e[d+2]);if(this.tmpPoints.length>0){const f=this.tmpPoints[this.tmpPoints.length-1],I=k.Sub(p,f).uni();p.setv(I)}this.tmpPoints.push(p)}if(this.tmpPoints.length<2)return;const s=this.transformDataAll(!0),a=(h=this.workId)==null?void 0:h.toString(),c={name:a};let l;if(a&&s.length){const d=i?this.fullLayer:this.drawLayer||this.fullLayer;l=this.draw({attrs:c,tasks:s,replaceId:n,layer:d}),(u=this.vNodes)==null||u.setInfo(a,{rect:l,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:l&&Y.getCenterPos(l,d)})}return l}transformDataAll(t=!0){const e=this.filterSamePoints(this.tmpPoints,this.workOptions.thickness);return this.getTaskPoints(e,t&&this.workOptions.thickness||void 0)}draw(t){const{attrs:e,tasks:i,replaceId:n,effects:s,layer:a}=t,{strokeColor:c,strokeType:l,thickness:h,zIndex:u,scale:d,rotate:p,translate:f}=this.workOptions;s!=null&&s.size&&(s.forEach(T=>{var N;(N=a.getElementById(T+""))==null||N.remove()}),s.clear());let I;const y=[],v=a.worldPosition,w=a.worldScaling;for(let T=0;T<i.length;T++){const{pos:N,points:C}=i[T],{ps:z,rect:L}=this.computDrawPoints(C);let j;const A=C.length===1;l===_.Stroke||A?j=oe(z,!0):j=oe(z,!1);const P={pos:N,d:j,fillColor:l===_.Stroke||A?c:void 0,lineDash:l===_.Dotted&&!A?[1,h*2]:l===_.LongDotted&&!A?[h,h*2]:void 0,strokeColor:c,lineCap:l===_.Stroke||A?void 0:"round",lineWidth:l===_.Stroke||A?0:h};I=ut(I,{x:Math.floor((L.x+N[0])*w[0]+v[0]-Y.SafeBorderPadding),y:Math.floor((L.y+N[1])*w[1]+v[1]-Y.SafeBorderPadding),w:Math.floor(L.w*w[0]+2*Y.SafeBorderPadding),h:Math.floor(L.h*w[1]+2*Y.SafeBorderPadding)}),y.push(P)}d&&(e.scale=d),p&&(e.rotate=p),f&&(e.translate=f);const m=new ht.Group;if(I){this.centerPos=Y.getCenterPos(I,a),m.attr({...e,normalize:!0,anchor:[.5,.5],bgcolor:l===_.Stroke?c:void 0,pos:this.centerPos,size:[(I.w-2*Y.SafeBorderPadding)/w[0],(I.h-2*Y.SafeBorderPadding)/w[1]],zIndex:u});const T=y.map(N=>(N.pos=[N.pos[0]-this.centerPos[0],N.pos[1]-this.centerPos[1]],new ht.Path(N)));m.append(...T),l===_.Stroke&&m.seal(),this.replace(a,n||e.workId,m)}if(d||p||f){const T=m==null?void 0:m.getBoundingClientRect();if(T)return{x:Math.floor(T.x-Y.SafeBorderPadding),y:Math.floor(T.y-Y.SafeBorderPadding),w:Math.floor(T.width+Y.SafeBorderPadding*2),h:Math.floor(T.height+Y.SafeBorderPadding*2)}}return I}computDrawPoints(t){return this.workOptions.strokeType===_.Stroke||t.length===1?this.computStroke(t):this.computNomal(t)}computNomal(t){let e=this.workOptions.thickness;const i=t.map(n=>(e=Math.max(e,n.radius),n.point));return{ps:i,rect:ft(i,e)}}computStroke(t){return t.length===1?this.computDotStroke(t[0]):this.computLineStroke(t)}computLineStroke(t){const e=[],i=[];for(let l=0;l<t.length;l++){const{point:h,radius:u}=t[l];let d=h.v;l===0&&t.length>1&&(d=t[l+1].point.v);const p=k.Per(d).mul(u);e.push(F.Sub(h,p)),i.push(F.Add(h,p))}const n=t[t.length-1],s=F.GetSemicircleStroke(n.point,e[e.length-1],-1,8),a=F.GetSemicircleStroke(t[0].point,i[0],-1,8),c=e.concat(s,i.reverse(),a);return{ps:c,rect:ft(c)}}computDotStroke(t){const{point:e,radius:i}=t,n={x:e.x-i,y:e.y-i,w:i*2,h:i*2};return{ps:F.GetDotStroke(e,i,8),rect:n}}transformData(t,e){const{op:i,workState:n}=t;let s=this.tmpPoints.length-1,a=[];if(i!=null&&i.length&&n){const{strokeType:c,thickness:l}=this.workOptions,h=new Set;s=c===_.Stroke?this.updateTempPointsWithPressure(i,l,h):this.updateTempPoints(i,l,h);const u=e?this.tmpPoints:this.tmpPoints.slice(s);return a=this.getTaskPoints(u,l),{tasks:a,effects:h,consumeIndex:s}}return{tasks:a,consumeIndex:s}}computRadius(t,e){return t*.03*e+e*.5}getMinZ(t,e){return((e||Math.max(1,Math.floor(t*.3)))-t*.5)*100/t/3}getTaskPoints(t,e){var u;const i=[];if(t.length===0)return[];let n=0,s=t[0].x,a=t[0].y,c=[s,a],l=[],h=t[0].t;for(;n<t.length;){const d=t[n],p=d.x-s,f=d.y-a,I=d.z,y=e?this.computRadius(I,e):I;if(l.push({point:new F(p,f,I,t[n].v),radius:y}),n>0&&n<t.length-1){const v=t[n].getAngleByPoints(t[n-1],t[n+1]);if(v<90||v>270){const w=(u=l.pop())==null?void 0:u.point.clone();w&&i.push({taskId:h,pos:c,points:[...l,{point:w,radius:y}]}),s=t[n].x,a=t[n].y,c=[s,a];const m=d.x-s,T=d.y-a;l=[{point:new F(m,T,I),radius:y}],h=Date.now()}}n++}return i.push({taskId:h,pos:c,points:l}),i}updateTempPointsWithPressure(t,e,i){const n=Date.now(),s=this.tmpPoints.length;let a=s;for(let l=0;l<t.length;l+=2){a=Math.min(a,s);const h=this.tmpPoints.length,u=new F(t[l],t[l+1]);if(h===0){this.tmpPoints.push(u);continue}const d=h-1,p=this.tmpPoints[d],f=k.Sub(u,p).uni();if(u.isNear(p,e)){if(p.z<this.MAX_REPEAR){if(p.setz(Math.min(p.z+1,this.MAX_REPEAR)),a=Math.min(a,d),h>1){let v=h-1;for(;v>0;){const w=this.tmpPoints[v].distance(this.tmpPoints[v-1]),m=Math.max(this.tmpPoints[v].z-this.uniThickness*w,0);if(this.tmpPoints[v-1].z>=m)break;this.tmpPoints[v-1].setz(m),a=Math.min(a,v-1),v--}}}else a=1/0;continue}u.setv(f);const I=u.distance(p),y=Math.max(p.z-this.uniThickness*I,0);h>1&&k.Equals(f,p.v,.02)&&(y>0||p.z<=0)&&(i&&p.t&&i.add(p.t),this.tmpPoints.pop(),a=Math.min(d,a)),u.setz(y),this.tmpPoints.push(u)}if(a===1/0)return this.tmpPoints.length;let c=s;if(a===s){c=Math.max(c-1,0);const l=this.tmpPoints[c].t;l&&(i==null||i.add(l))}else{let l=s-1;for(c=a;l>=0;){const h=this.tmpPoints[l].t;if(h&&(i==null||i.add(h),l<=a)){c=l,l=-1;break}l--}}return this.tmpPoints[c].setT(n),c}updateTempPoints(t,e,i){var l;const n=Date.now(),s=this.tmpPoints.length;let a=s;for(let h=0;h<t.length;h+=2){const u=this.tmpPoints.length,d=new F(t[h],t[h+1]);if(u===0){this.tmpPoints.push(d);continue}const p=u-1,f=this.tmpPoints[p],I=k.Sub(d,f).uni();if(d.isNear(f,e/2)){a=Math.min(p,a);continue}k.Equals(I,f.v,.02)&&(i&&f.t&&i.add(f.t),this.tmpPoints.pop(),a=Math.min(p,a)),d.setv(I),this.tmpPoints.push(d)}let c=s;if(a===s){c=Math.max(c-1,0);const h=this.tmpPoints[c].t;h&&(i==null||i.add(h))}else{let h=Math.min(s-1,a);for(c=a;h>=0;){const u=(l=this.tmpPoints[h])==null?void 0:l.t;if(u&&(i==null||i.add(u),h<=a)){c=h,h=-1;break}h--}}return this.tmpPoints[c].setT(n),c}updateTempPointsWithPressureWhenDone(t){const{thickness:e}=this.workOptions,i=t.length,n=this.getMinZ(e);for(let s=0;s<i;s+=2){const a=this.tmpPoints.length,c=new F(t[s],t[s+1]);if(a===0){this.tmpPoints.push(c);continue}const l=a-1,h=this.tmpPoints[l],u=k.Sub(c,h).uni(),d=c.distance(h);if(a>1&&h.z===n)break;if(c.isNear(h,e/2)){if(i<3&&h.z<this.MAX_REPEAR&&(h.setz(Math.min(h.z+1,this.MAX_REPEAR)),a>1)){let f=a-1;for(;f>0;){const I=this.tmpPoints[f].distance(this.tmpPoints[f-1]),y=Math.max(this.tmpPoints[f].z-this.uniThickness*I,-e/4);if(this.tmpPoints[f-1].z>=y)break;this.tmpPoints[f-1].setz(y),f--}}continue}c.setv(u);const p=Math.max(h.z-this.uniThickness*d,n);a>1&&k.Equals(u,h.v,.02)&&h.z<=0&&this.tmpPoints.pop(),c.setz(p),this.tmpPoints.push(c)}}static updateNodeOpt(t){var l,h;const{node:e,opt:i,vNodes:n}=t,{strokeColor:s,strokeType:a}=i,c=n.get(e.name);return s&&(e.tagName==="GROUP"?xf(e)?e.setAttribute("bgcolor",s):e.children.forEach(u=>{u.setAttribute("strokeColor",s),u.getAttribute("fillColor")&&u.setAttribute("fillColor",s)}):(e.setAttribute("strokeColor",s),e.setAttribute("fillColor",s)),(l=c==null?void 0:c.opt)!=null&&l.strokeColor&&(c.opt.strokeColor=s)),a&&(c!=null&&c.opt)&&((h=c.opt)!=null&&h.strokeType)&&(c.opt.strokeType=a),c&&n.setInfo(e.name,c),Y.updateNodeOpt(t)}}class ns extends Y{constructor(t){super(t);M(this,"toolsType",S.LaserPen);M(this,"canRotate",!1);M(this,"scaleType",at.none);M(this,"syncTimestamp");M(this,"syncIndex",0);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"consumeIndex",0);this.workOptions=t.toolsOpt,this.syncTimestamp=0}combineConsume(){}setWorkOptions(t){super.setWorkOptions(t),this.syncTimestamp=Date.now()}consume(t){const{data:e,isSubWorker:i}=t,{workId:n,op:s}=e;if((s==null?void 0:s.length)===0)return{type:x.None};if(this.updateTempPoints(s||[]),this.consumeIndex>this.tmpPoints.length-4)return{type:x.None};const{strokeColor:a,thickness:c,strokeType:l}=this.workOptions,h=ft(this.tmpPoints,c);let u=!1;const d=this.syncIndex,p=this.tmpPoints.slice(this.consumeIndex);this.consumeIndex=this.tmpPoints.length-1,this.syncTimestamp===0&&(this.syncTimestamp=Date.now());const f={name:n==null?void 0:n.toString(),opacity:1,lineDash:l===_.Dotted?[1,c*2]:l===_.LongDotted?[c,c*2]:void 0,strokeColor:a,lineCap:"round",lineWidth:c,anchor:[.5,.5]},I=this.getTaskPoints(p);if(I.length){const v=Date.now();v-this.syncTimestamp>this.syncUnitTime&&(u=!0,this.syncTimestamp=v,this.syncIndex=this.tmpPoints.length),i&&this.draw({attrs:f,tasks:I,isDot:!1,layer:this.drawLayer||this.fullLayer})}const y=[];return this.tmpPoints.slice(d).forEach(v=>{y.push(v.x,v.y)}),{rect:{x:h.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:h.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:h.w*this.fullLayer.worldScaling[0],h:h.h*this.fullLayer.worldScaling[1]},type:x.DrawWork,dataType:U.Local,op:u?y:void 0,index:u?d*2:void 0,...this.baseConsumeResult}}consumeAll(){var s;const t=(s=this.workId)==null?void 0:s.toString();let e;if(this.tmpPoints.length-1>this.consumeIndex){let a=this.tmpPoints.slice(this.consumeIndex);const c=a.length===1,{strokeColor:l,thickness:h,strokeType:u}=this.workOptions;if(c){const f=this.computDotStroke({point:a[0],radius:h/2});a=f.ps,e=f.rect}else e=ft(this.tmpPoints,h);const d={name:t==null?void 0:t.toString(),fillColor:c?l:void 0,opacity:1,lineDash:u===_.Dotted&&!c?[1,h*2]:u===_.LongDotted&&!c?[h,h*2]:void 0,strokeColor:l,lineCap:c?void 0:"round",lineWidth:c?0:h,anchor:[.5,.5]},p=this.getTaskPoints(a);p.length&&this.draw({attrs:d,tasks:p,isDot:c,layer:this.drawLayer||this.fullLayer})}const i=[];this.tmpPoints.forEach(a=>{i.push(a.x,a.y)});const n=Lt(i);return{rect:e&&{x:e.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:e.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:e.w*this.fullLayer.worldScaling[0],h:e.h*this.fullLayer.worldScaling[1]},type:x.FullWork,dataType:U.Local,ops:n,index:this.syncIndex*2,...this.baseConsumeResult}}clearTmpPoints(){this.tmpPoints.length=0,this.syncTimestamp=0,this.syncIndex=0}consumeService(t){var I;const{op:e,replaceId:i,isFullWork:n}=t,{strokeColor:s,thickness:a,strokeType:c}=this.workOptions;if(!e.length){const y=ft(this.tmpPoints,a);return{x:y.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:y.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:y.w*this.fullLayer.worldScaling[0],h:y.h*this.fullLayer.worldScaling[1]}}const l=Math.max(0,this.tmpPoints.length-1);this.updateTempPoints(e||[]);let h,u=this.tmpPoints.slice(l);const d=u.length===1;if(d){const y=this.computDotStroke({point:u[0],radius:a/2});u=y.ps,h=y.rect}else h=ft(this.tmpPoints,a);const p={name:(I=this.workId)==null?void 0:I.toString(),fillColor:d?s:void 0,opacity:1,lineDash:c===_.Dotted&&!d?[1,a*2]:c===_.LongDotted&&!d?[a,a*2]:void 0,strokeColor:s,lineCap:d?void 0:"round",lineWidth:d?0:a,anchor:[.5,.5]},f=this.getTaskPoints(u);if(f.length){const y=n?this.fullLayer:this.drawLayer||this.fullLayer;this.draw({attrs:p,tasks:f,isDot:d,replaceId:i,layer:y})}return{x:h.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:h.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:h.w*this.fullLayer.worldScaling[0],h:h.h*this.fullLayer.worldScaling[1]}}computDotStroke(t){const{point:e,radius:i}=t,n={x:e.x-i,y:e.y-i,w:i*2,h:i*2};return{ps:F.GetDotStroke(e,i,8),rect:n}}updateTempPoints(t){const e=this.tmpPoints.length;for(let i=0;i<t.length;i+=2){if(e){const n=this.tmpPoints.slice(-1)[0];n&&n.x===t[i]&&n.y===t[i+1]&&this.tmpPoints.pop()}this.tmpPoints.push(new F(t[i],t[i+1]))}}async draw(t){const{attrs:e,tasks:i,isDot:n,layer:s}=t,{duration:a}=this.workOptions;for(const c of i){const l=new ht.Path,{pos:h,points:u}=c;let d;n?d=oe(u,!0):d=oe(u,!1),l.attr({...e,pos:h,d});const{vertex:p,fragment:f}=this.workOptions;if(p&&f){const I=s.renderer.createProgram({vertex:p,fragment:f}),{width:y,height:v}=s.getResolution();l.setUniforms({u_time:0,u_resolution:[y,v]}),l.setProgram(I)}s.appendChild(l),l.transition(a).attr({scale:n?[.1,.1]:[1,1],lineWidth:n?0:1}).then(()=>{l.remove()})}}getTaskPoints(t){var l;const e=[];if(t.length===0)return[];let i=0,n=t[0].x,s=t[0].y,a=[n,s],c=[];for(;i<t.length;){const h=t[i],u=h.x-n,d=h.y-s;if(c.push(new F(u,d)),i>0&&i<t.length-1){const p=t[i].getAngleByPoints(t[i-1],t[i+1]);if(p<90||p>270){const f=(l=c.pop())==null?void 0:l.clone();f&&e.push({pos:a,points:[...c,f]}),n=t[i].x,s=t[i].y,a=[n,s];const I=h.x-n,y=h.y-s;c=[new F(I,y)]}}i++}return e.push({pos:a,points:c}),e}removeLocal(){}removeService(t){let e;const i=[];return this.fullLayer.getElementsByName(t).forEach(n=>{if(n.name===t){const s=n.getBoundingClientRect();e=ut(e,{x:s.x,y:s.y,w:s.width,h:s.height}),i.push(n)}}),i.length&&i.forEach(n=>n.remove()),e}}const le=class le extends Y{constructor(t,e){super(t);M(this,"canRotate",!1);M(this,"scaleType",at.none);M(this,"toolsType",S.Eraser);M(this,"serviceWork");M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"worldPosition");M(this,"worldScaling");M(this,"eraserRect");M(this,"eraserPolyline");this.serviceWork=e,this.workOptions=t.toolsOpt,this.worldPosition=this.fullLayer.worldPosition,this.worldScaling=this.fullLayer.worldScaling}combineConsume(){}consumeService(){}setWorkOptions(t){super.setWorkOptions(t)}createEraserRect(t){const e=t[0]*this.worldScaling[0]+this.worldPosition[0],i=t[1]*this.worldScaling[1]+this.worldPosition[1],{width:n,height:s}=le.eraserSizes[this.workOptions.thickness];this.eraserRect={x:e-n*.5,y:i-s*.5,w:n,h:s},this.eraserPolyline=[this.eraserRect.x,this.eraserRect.y,this.eraserRect.x+this.eraserRect.w,this.eraserRect.y+this.eraserRect.h]}computRectCenterPoints(){const t=this.tmpPoints.slice(-2);if(this.tmpPoints.length===4){const e=new k(this.tmpPoints[0],this.tmpPoints[1]),i=new k(this.tmpPoints[2],this.tmpPoints[3]),n=k.Sub(i,e).uni(),s=k.Dist(e,i),{width:a,height:c}=le.eraserSizes[this.workOptions.thickness],l=Math.min(a,c),h=Math.round(s/l);if(h>1){const u=[];for(let d=0;d<h;d++){const p=k.Mul(n,d*l);u.push(this.tmpPoints[0]+p.x,this.tmpPoints[1]+p.y)}return u.concat(t)}}return t}isNear(t,e){const i=new k(t[0],t[1]),n=new k(e[0],e[1]),{width:s,height:a}=le.eraserSizes[this.workOptions.thickness];return k.Dist(i,n)<Math.hypot(s,a)*.5}remove(t){const{curNodeMap:e,removeIds:i}=t;let n;for(const s of e.values())if(s.rect&&this.eraserRect&&this.eraserPolyline&&Le(this.eraserRect,s.rect)){const{op:a}=s,c=[],l=[];for(let u=0;u<a.length;u+=3){const d=new k(a[u]*this.worldScaling[0]+this.worldPosition[0],a[u+1]*this.worldScaling[1]+this.worldPosition[1],a[u+2]);l.push(d),c.push(new F(d.x,d.y))}const h=c.length&&ft(c)||s.rect;Le(h,this.eraserRect)&&(l.length>1?zi.polyline(l.map(d=>d.XY),this.eraserPolyline).length&&i.add(s.name):i.add(s.name),n=ut(n,h))}return i.forEach(s=>{var c;const a=this.fullLayer.getElementsByName(s);this.fullLayer.removeChild(a[0]),(c=this.vNodes)==null||c.delete(s)}),n&&(n.x-=Y.SafeBorderPadding,n.y-=Y.SafeBorderPadding,n.w+=Y.SafeBorderPadding*2,n.h+=Y.SafeBorderPadding*2),n}consume(t){const{op:e}=t.data;if(!e||e.length===0)return{type:x.None,...this.baseConsumeResult};const i=this.tmpPoints.length;if(i>1&&this.isNear([e[0],e[1]],[this.tmpPoints[i-2],this.tmpPoints[i-1]]))return{type:x.None,...this.baseConsumeResult};i<3?this.tmpPoints.push(e[0],e[1]):this.tmpPoints.splice(2,2,e[0],e[1]);const n=this.computRectCenterPoints();let s;const a=new Set;if(!this.vNodes)return{type:x.None,...this.baseConsumeResult};const c=this.getUnLockNodeMap(this.vNodes.getUnLockNodes());for(let l=0;l<n.length-1;l+=2){this.createEraserRect(n.slice(l,l+2));const h=this.remove({curNodeMap:c,removeIds:a});s=ut(s,h)}return s&&a.size?{type:x.RemoveNode,rect:s,removeIds:[...a]}:{type:x.None,...this.baseConsumeResult}}consumeAll(t){return this.consume(t)}clearTmpPoints(){this.tmpPoints.length=0}getUnLockNodeMap(t){var e;if(this.serviceWork){const i=new Map(t),n=this.serviceWork.selectorWorkShapes,s=this.serviceWork.workShapes;for(const a of n.values())if((e=a.selectIds)!=null&&e.length)for(const c of a.selectIds)i.delete(c);for(const a of s.keys())i.delete(a);return i}return t}};M(le,"eraserSizes",Object.freeze([Object.freeze({width:18,height:26}),Object.freeze({width:26,height:34}),Object.freeze({width:34,height:50})]));let Fe=le;const Ot="++",B="selector",We="all";var dp="__lodash_hash_undefined__";function pp(r){return this.__data__.set(r,dp),this}var fp=pp;function gp(r){return this.__data__.has(r)}var Mp=gp,yp=Ai,wp=fp,mp=Mp;function He(r){var o=-1,t=r==null?0:r.length;for(this.__data__=new yp;++o<t;)this.add(r[o])}He.prototype.add=He.prototype.push=wp;He.prototype.has=mp;var Ip=He;function vp(r,o){for(var t=-1,e=r==null?0:r.length;++t<e;)if(o(r[t],t,r))return!0;return!1}var Np=vp;function Tp(r,o){return r.has(o)}var Sp=Tp,Cp=Ip,kp=Np,zp=Sp,xp=1,Lp=2;function bp(r,o,t,e,i,n){var s=t&xp,a=r.length,c=o.length;if(a!=c&&!(s&&c>a))return!1;var l=n.get(r),h=n.get(o);if(l&&h)return l==o&&h==r;var u=-1,d=!0,p=t&Lp?new Cp:void 0;for(n.set(r,o),n.set(o,r);++u<a;){var f=r[u],I=o[u];if(e)var y=s?e(I,f,u,o,r,n):e(f,I,u,r,o,n);if(y!==void 0){if(y)continue;d=!1;break}if(p){if(!kp(o,function(v,w){if(!zp(p,w)&&(f===v||i(f,v,t,e,n)))return p.push(w)})){d=!1;break}}else if(!(f===I||i(f,I,t,e,n))){d=!1;break}}return n.delete(r),n.delete(o),d}var rs=bp;function jp(r){var o=-1,t=Array(r.size);return r.forEach(function(e,i){t[++o]=[i,e]}),t}var Dp=jp;function Pp(r){var o=-1,t=Array(r.size);return r.forEach(function(e){t[++o]=e}),t}var Ep=Pp,hi=Ke,ui=Ki,Ap=zo,Op=rs,Rp=Dp,Yp=Ep,Wp=1,Up=2,Bp="[object Boolean]",$p="[object Date]",Fp="[object Error]",Hp="[object Map]",Qp="[object Number]",Vp="[object RegExp]",Zp="[object Set]",Gp="[object String]",Jp="[object Symbol]",qp="[object ArrayBuffer]",Xp="[object DataView]",di=hi?hi.prototype:void 0,uo=di?di.valueOf:void 0;function Kp(r,o,t,e,i,n,s){switch(t){case Xp:if(r.byteLength!=o.byteLength||r.byteOffset!=o.byteOffset)return!1;r=r.buffer,o=o.buffer;case qp:return!(r.byteLength!=o.byteLength||!n(new ui(r),new ui(o)));case Bp:case $p:case Qp:return Ap(+r,+o);case Fp:return r.name==o.name&&r.message==o.message;case Vp:case Gp:return r==o+"";case Hp:var a=Rp;case Zp:var c=e&Wp;if(a||(a=Yp),r.size!=o.size&&!c)return!1;var l=s.get(r);if(l)return l==o;e|=Up,s.set(r,o);var h=Op(a(r),a(o),e,i,n,s);return s.delete(r),h;case Jp:if(uo)return uo.call(r)==uo.call(o)}return!1}var _p=Kp,pi=qi,tf=1,ef=Object.prototype,of=ef.hasOwnProperty;function sf(r,o,t,e,i,n){var s=t&tf,a=pi(r),c=a.length,l=pi(o),h=l.length;if(c!=h&&!s)return!1;for(var u=c;u--;){var d=a[u];if(!(s?d in o:of.call(o,d)))return!1}var p=n.get(r),f=n.get(o);if(p&&f)return p==o&&f==r;var I=!0;n.set(r,o),n.set(o,r);for(var y=s;++u<c;){d=a[u];var v=r[d],w=o[d];if(e)var m=s?e(w,v,d,o,r,n):e(v,w,d,r,o,n);if(!(m===void 0?v===w||i(v,w,t,e,n):m)){I=!1;break}y||(y=d=="constructor")}if(I&&!y){var T=r.constructor,N=o.constructor;T!=N&&"constructor"in r&&"constructor"in o&&!(typeof T=="function"&&T instanceof T&&typeof N=="function"&&N instanceof N)&&(I=!1)}return n.delete(r),n.delete(o),I}var nf=sf,po=Oi,rf=rs,af=_p,cf=nf,fi=no,gi=so,Mi=Lo,lf=Bi,hf=1,yi="[object Arguments]",wi="[object Array]",Ee="[object Object]",uf=Object.prototype,mi=uf.hasOwnProperty;function df(r,o,t,e,i,n){var s=gi(r),a=gi(o),c=s?wi:fi(r),l=a?wi:fi(o);c=c==yi?Ee:c,l=l==yi?Ee:l;var h=c==Ee,u=l==Ee,d=c==l;if(d&&Mi(r)){if(!Mi(o))return!1;s=!0,h=!1}if(d&&!h)return n||(n=new po),s||lf(r)?rf(r,o,t,e,i,n):af(r,o,c,t,e,i,n);if(!(t&hf)){var p=h&&mi.call(r,"__wrapped__"),f=u&&mi.call(o,"__wrapped__");if(p||f){var I=p?r.value():r,y=f?o.value():o;return n||(n=new po),i(I,y,t,e,n)}}return d?(n||(n=new po),cf(r,o,t,e,i,n)):!1}var pf=df,ff=pf,Ii=Ht;function as(r,o,t,e,i){return r===o?!0:r==null||o==null||!Ii(r)&&!Ii(o)?r!==r&&o!==o:ff(r,o,t,e,as,i)}var gf=as,Mf=gf;function yf(r,o){return Mf(r,o)}var wf=yf;const Se=je(wf),qe=class qe extends Y{constructor(t){super(t);M(this,"toolsType",S.Selector);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"vNodes");M(this,"selectIds");M(this,"selectorColor");M(this,"strokeColor");M(this,"fillColor");M(this,"oldSelectRect");M(this,"canRotate",!1);M(this,"canTextEdit",!1);M(this,"canLock",!1);M(this,"scaleType",at.all);M(this,"toolsTypes");M(this,"shapeOpt");M(this,"textOpt");M(this,"isLocked");M(this,"thickness");M(this,"strokeType");M(this,"useStroke");this.workOptions=t.toolsOpt,this.vNodes=t.vNodes}computSelector(t=!0){const e=ft(this.tmpPoints);if(e.w===0||e.h===0)return{selectIds:[],intersectRect:void 0,subNodeMap:new Map};const{rectRange:i,nodeRange:n}=this.vNodes.getRectIntersectRange(e,t);return{selectIds:[...n.keys()],intersectRect:i,subNodeMap:n}}updateTempPoints(t){const e=this.tmpPoints.length,i=t.length;if(i>1){const n=new F(t[i-2]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],t[i-1]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[1]);e===2?this.tmpPoints.splice(1,1,n):this.tmpPoints.push(n)}}drawSelector(t){const{drawRect:e,subNodeMap:i,selectorId:n,layer:s,isService:a}=t,c=new ht.Group({pos:[e.x,e.y],anchor:[0,0],size:[e.w,e.h],id:n,name:n,zIndex:9999}),l=[];if(a){const h=new ht.Rect({normalize:!0,pos:[e.w/2,e.h/2],lineWidth:1,strokeColor:this.selectorColor||this.workOptions.strokeColor,width:e.w,height:e.h,name:qe.selectorBorderId});l.push(h)}i.forEach((h,u)=>{const d=[h.rect.x+h.rect.w/2-e.x,h.rect.y+h.rect.h/2-e.y],p=new ht.Rect({normalize:!0,pos:d,lineWidth:1,strokeColor:i.size>1?this.selectorColor||this.workOptions.strokeColor:void 0,width:h.rect.w,height:h.rect.h,id:`selector-${u}`,name:`selector-${u}`});l.push(p)}),l&&c.append(...l),(s==null?void 0:s.parent).appendChild(c)}draw(t,e,i,n=!1){var c,l;const{intersectRect:s,subNodeMap:a}=i;(l=(c=e.parent)==null?void 0:c.getElementById(t))==null||l.remove(),s&&this.drawSelector({drawRect:s,subNodeMap:a,selectorId:t,layer:e,isService:n})}getSelecteorInfo(t){this.scaleType=at.all,this.canRotate=!1,this.textOpt=void 0,this.strokeColor=void 0,this.fillColor=void 0,this.canTextEdit=!1,this.canLock=!1,this.isLocked=!1,this.toolsTypes=void 0,this.shapeOpt=void 0,this.thickness=void 0,this.strokeType=void 0,this.useStroke=!1;const e=new Set;let i,n=!0;for(const s of t.values()){const{opt:a,canRotate:c,scaleType:l,toolsType:h}=s;this.selectorColor=this.workOptions.strokeColor,a.strokeColor&&(this.strokeColor=a.strokeColor),a.fillColor&&(this.fillColor=a.fillColor),a.textOpt&&(this.textOpt=a.textOpt),a.thickness&&(this.thickness=a.thickness),h!==S.Pencil&&(n=!1),a.strokeType&&(this.strokeType=a.strokeType),h===S.SpeechBalloon&&(e.add(h),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.placement=a.placement),h===S.Polygon&&(e.add(h),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.vertices=a.vertices),h===S.Star&&(e.add(h),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.vertices=a.vertices,this.shapeOpt.innerRatio=a.innerRatio,this.shapeOpt.innerVerticeStep=a.innerVerticeStep),h===S.Text&&(this.textOpt=a),t.size===1&&(this.textOpt&&(this.canTextEdit=!0),this.canRotate=c,this.scaleType=l),l===at.none&&(this.scaleType=l),h===S.Image&&(i=s)}n&&(this.useStroke=!0),e.size&&(this.toolsTypes=[...e]),i&&(t.size===1?(this.canLock=!0,i.opt.locked&&(this.isLocked=!0,this.scaleType=at.none,this.canRotate=!1,this.textOpt=void 0,this.fillColor=void 0,this.selectorColor="rgb(177,177,177)",this.strokeColor=void 0,this.canTextEdit=!1,this.thickness=void 0,this.strokeType=void 0,this.useStroke=void 0)):t.size>1&&!i.opt.locked&&(this.canLock=!1,this.canRotate=!1))}getChildrenPoints(){var t,e;if(this.scaleType===at.both&&((t=this.selectIds)==null?void 0:t.length)===1){const i=this.selectIds[0],n=(e=this.vNodes.get(i))==null?void 0:e.op;if(n){const s=[];for(let a=0;a<n.length;a+=3)s.push([n[a],n[a+1]]);return s}}}consume(t){const{op:e,workState:i}=t.data;let n=this.oldSelectRect;if(i===b.Start&&(n=this.unSelectedAllIds()),!(e!=null&&e.length)||!this.vNodes.curNodeMap.size)return{type:x.None};this.updateTempPoints(e);const s=this.computSelector();if(this.selectIds&&Se(this.selectIds,s.selectIds))return{type:x.None};this.selectIds=s.selectIds;const a=s.intersectRect;this.getSelecteorInfo(s.subNodeMap),this.draw(B,this.fullLayer,s),this.oldSelectRect=a;const c=this.getChildrenPoints();return{type:x.Select,dataType:U.Local,rect:ut(a,n),selectIds:s.selectIds,selectRect:a,selectorColor:this.selectorColor,strokeColor:this.strokeColor,fillColor:this.fillColor,textOpt:this.textOpt,canTextEdit:this.canTextEdit,canRotate:this.canRotate,canLock:this.canLock,scaleType:this.scaleType,willSyncService:!0,points:c,isLocked:this.isLocked,toolsTypes:this.toolsTypes,shapeOpt:this.shapeOpt,thickness:this.thickness,useStroke:this.useStroke,strokeType:this.strokeType,...this.baseConsumeResult}}consumeAll(){var e,i;let t=this.oldSelectRect;if(!((e=this.selectIds)!=null&&e.length)&&this.tmpPoints[0]&&this.selectSingleTool(this.tmpPoints[0].XY,B,!1),(i=this.selectIds)!=null&&i.length&&(t=this.selectedByIds(this.selectIds)),t){const n=this.getChildrenPoints();return{type:x.Select,dataType:U.Local,rect:this.oldSelectRect,selectIds:this.selectIds,selectorColor:this.selectorColor,selectRect:this.oldSelectRect,strokeColor:this.strokeColor,fillColor:this.fillColor,textOpt:this.textOpt,canTextEdit:this.canTextEdit,canRotate:this.canRotate,canLock:this.canLock,scaleType:this.scaleType,willSyncService:!0,points:n,isLocked:this.isLocked,toolsTypes:this.toolsTypes,shapeOpt:this.shapeOpt,thickness:this.thickness,useStroke:this.useStroke,strokeType:this.strokeType,...this.baseConsumeResult}}return{type:x.None}}consumeService(){}clearTmpPoints(){this.tmpPoints.length=0}clearSelectData(){this.selectIds=void 0,this.oldSelectRect=void 0}selectSingleTool(t,e=B,i=!1){if(t.length===2){const n=t[0],s=t[1];let a;const{nodeRange:c}=this.vNodes.getRectIntersectRange({x:n,y:s,w:0,h:0},!1),l=[...c.values()].sort((h,u)=>(u.opt.zIndex||0)-(h.opt.zIndex||0));for(const h of l){const u=this.fullLayer.getElementsByName(h.name);if(ys(u).find(p=>p.isPointCollision(n,s))){a=h;break}}if(a){const h=a.name;if(!Se(this.oldSelectRect,a.rect)){const u=new Map([[h,a]]);this.getSelecteorInfo(u),this.draw(e,this.fullLayer,{intersectRect:a.rect,subNodeMap:u,selectIds:this.selectIds||[]},i)}this.selectIds=[h],this.oldSelectRect=a.rect}}}unSelectedAllIds(){let t;for(const[e,i]of this.vNodes.curNodeMap.entries())i.isSelected&&(t=ut(t,i.rect),this.vNodes.unSelected(e));return t}unSelectedByIds(t){let e;for(const i of t){const n=this.vNodes.get(i);n&&n.isSelected&&(e=ut(e,n.rect),this.vNodes.unSelected(i))}return e}selectedByIds(t){let e;for(const i of t){const n=this.vNodes.get(i);n&&(e=ut(e,n.rect),this.vNodes.selected(i))}return e}getSelectorRect(t,e){var a;let i;const n=(a=t.parent)==null?void 0:a.getElementById(e),s=n==null?void 0:n.getBoundingClientRect();return s&&(i=ut(i,{x:Math.floor(s.x),y:Math.floor(s.y),w:Math.floor(s.width+1),h:Math.floor(s.height+1)})),i}isCanFillColor(t){return t===S.Ellipse||t===S.Triangle||t===S.Rectangle||t===S.Polygon||t===S.Star||t===S.SpeechBalloon}async updateSelector(t){var z;const{updateSelectorOpt:e,selectIds:i,vNodes:n,willSerializeData:s,worker:a,scene:c,isMainThread:l,offset:h}=t,u=this.fullLayer;if(!u)return;let d;const p=new Map,{originPoint:f,workState:I,angle:y,translate:v,dir:w,scale:m}=e;h&&(v?e.translate=[v[0]+h[0],v[1]+h[1]]:e.translate=h);let T;if(f||v||Wt(y)){if(I===b.Start&&i)return n.setTargetAssignKeys(i),{type:x.Select,dataType:U.Local,selectRect:this.oldSelectRect,rect:this.oldSelectRect};T=n.getLastTarget()}if(i)for(const L of i){const j=n.get(L);if(j){const{toolsType:A}=j,P=(u==null?void 0:u.getElementsByName(L))[0];if(P){let R=!1,D=!1;const G={...e};let ct;if(A){G.thickness&&j.opt.thickness&&(R=j.opt.thickness!==G.thickness),G.strokeType&&((z=j.opt)!=null&&z.strokeType)&&(D=j.opt.strokeType!==G.strokeType),ct=T==null?void 0:T.get(L);const et=gs(A);if(et==null||et.updateNodeOpt({node:P,opt:G,vNodes:n,willSerializeData:s,targetNode:ct}),j&&a&&(s&&(G.angle||G.translate)||G.originPoint&&G.scenePoint&&G.scale||G.pointMap&&G.pointMap.has(L)||A===S.Text&&(G.fontSize||G.translate||G.textInfos&&G.textInfos.get(L))||A===S.Image&&(G.angle||G.translate||G.scale)||A===G.toolsType&&G.willRefresh||R||D)){const H=a.createWorkShapeNode({workId:L,toolsType:A,toolsOpt:j.opt});H==null||H.setWorkId(L);let J;if(A===S.Image&&c)J=await H.consumeServiceAsync({isFullWork:!0,replaceId:L,scene:c,isMainThread:l});else if(A===S.Text)J=await H.consumeServiceAsync({isFullWork:!0,replaceId:L});else try{J=H==null?void 0:H.consumeService({op:j.op,isFullWork:!0,replaceId:L})}catch{continue}J&&(j.rect=J)}j&&(p.set(L,j),d=ut(d,j.rect))}}}}T&&I===b.Done&&(n.deleteLastTarget(),T=void 0);const N=d;if(f&&v&&m&&w&&N&&!h){const L=[[N.x,N.y],[N.x+N.w,N.y],[N.x+N.w,N.y+N.h],[N.x,N.y+N.h]];let j;switch(w){case"top":case"topLeft":case"left":v[0]>0&&v[1]>0?j=L[0]:v[0]>0?j=L[3]:v[1]>0?j=L[1]:j=L[2];break;case"topRight":v[0]<0&&v[1]>0?j=L[1]:v[0]<0?j=L[2]:v[1]>0?j=L[0]:j=L[3];break;case"right":case"bottomRight":case"bottom":v[0]<0&&v[1]<0?j=L[2]:v[0]<0?j=L[1]:v[1]<0?j=L[3]:j=L[0];break;case"bottomLeft":v[0]>0&&v[1]<0?j=L[3]:v[0]>0?j=L[0]:v[1]<0?j=L[2]:j=L[1];break}const A=j&&[f[0]-j[0],f[1]-j[1]]||[0,0];if(!Se(A,[0,0]))return await this.updateSelector({...t,updateSelectorOpt:{},offset:A})}this.getSelecteorInfo(p),this.draw(B,u,{selectIds:i||[],subNodeMap:p,intersectRect:N});const C=ut(this.oldSelectRect,N);return this.oldSelectRect=N,{type:x.Select,dataType:U.Local,selectRect:N,renderRect:d,rect:ut(C,N),selectIds:i}}blurSelector(){const t=this.unSelectedAllIds();return{type:x.Select,dataType:U.Local,rect:t,selectIds:[],willSyncService:!0}}getRightServiceId(t){return t.replace(Ot,"-")}selectServiceNode(t,e,i){const{selectIds:n}=e,s=this.getRightServiceId(t),a=this.getSelectorRect(this.fullLayer,s);let c;const l=new Map;return n==null||n.forEach(h=>{const u=this.vNodes.get(h);u&&(c=ut(c,u.rect),l.set(h,u))}),this.getSelecteorInfo(l),this.draw(s,this.fullLayer,{intersectRect:c,selectIds:n||[],subNodeMap:l},i),ut(c,a)}reRenderSelector(){var i;let t;const e=new Map;return(i=this.selectIds)==null||i.forEach(n=>{const s=this.vNodes.get(n);s&&(t=ut(t,s.rect),e.set(n,s))},this),this.getSelecteorInfo(e),this.draw(B,this.fullLayer,{intersectRect:t,subNodeMap:e,selectIds:this.selectIds||[]}),this.oldSelectRect=t,t}updateSelectIds(t){var s;let e;const i=(s=this.selectIds)==null?void 0:s.filter(a=>!t.includes(a));if(i!=null&&i.length&&(e=this.unSelectedByIds(i)),t.length){const a=this.selectedByIds(t);e=ut(e,a)}this.selectIds=t;const n=this.reRenderSelector();return{bgRect:e,selectRect:n}}cursorHover(t){var s,a;const e=this.oldSelectRect;this.selectIds=[];const i=(s=this.workId)==null?void 0:s.toString(),n=[t[0]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],t[1]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[1]];if(this.selectSingleTool(n,i,!0),this.oldSelectRect&&!Se(e,this.oldSelectRect))return{type:x.CursorHover,dataType:U.Local,rect:ut(e,this.oldSelectRect),selectorColor:this.selectorColor,willSyncService:!1};if((a=this.selectIds)!=null&&a.length||(this.oldSelectRect=void 0),e&&!this.oldSelectRect)return this.cursorBlur(),{type:x.CursorHover,dataType:U.Local,rect:e,selectorColor:this.selectorColor,willSyncService:!1}}cursorBlur(){var e,i;this.selectIds=[];const t=(e=this.workId)==null?void 0:e.toString();((i=this.fullLayer)==null?void 0:i.parent).children.forEach(n=>{n.name===t&&n.remove()})}};M(qe,"selectorBorderId","selector-border");let Qe=qe;class cs extends Y{constructor(t){super(t);M(this,"canRotate",!1);M(this,"scaleType",at.both);M(this,"toolsType",S.Arrow);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");M(this,"arrowTipWidth");M(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.arrowTipWidth=this.workOptions.thickness*4,this.syncTimestamp=0,this.syncUnitTime=50}consume(t){const{data:e,isFullWork:i,isSubWorker:n,isMainThread:s}=t,a=this.workId,{op:c}=e,l=c==null?void 0:c.length;if(!l||l<2)return{type:x.None};let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new F(c[0],c[1])],h=!1):h=this.updateTempPoints(c),!h)return{type:x.None};let u;if(n||s){const p=i?this.fullLayer:this.drawLayer||this.fullLayer;u=this.draw({workId:a,layer:p})}if(!n){const p=Date.now();return p-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=p,{...this.baseConsumeResult,type:x.DrawWork,dataType:U.Local,op:this.tmpPoints.map(f=>[...f.XY,0]).flat(1),isSync:!0,index:0}):{type:x.None}}const d=ut(u,this.oldRect);return this.oldRect=u,{rect:d,...this.baseConsumeResult,type:x.DrawWork,dataType:U.Local}}consumeAll(){var a;const t=this.workId;if(this.tmpPoints.length<2)return{type:x.RemoveNode,removeIds:[t]};const e=this.fullLayer,i=this.draw({workId:t,layer:e});this.oldRect=i;const n=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),s=Lt(n);return(a=this.vNodes)==null||a.setInfo(t,{rect:i,op:n,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:Y.getCenterPos(i,e)}),{rect:i,...this.baseConsumeResult,type:x.FullWork,dataType:U.Local,ops:s,isSync:!0}}draw(t){const{workId:e,layer:i}=t,{strokeColor:n,thickness:s,zIndex:a,scale:c,rotate:l,translate:h,strokeType:u}=this.workOptions,d=i.worldPosition,p=i.worldScaling,{points:f,pos:I,rect:y,isTriangle:v,trianglePoints:w,trianglePos:m}=this.computDrawPoints(s),T=[y.x+y.w/2,y.y+y.h/2],N={pos:T,name:e,id:e,zIndex:a,anchor:[.5,.5],size:[y.w,y.h]};c&&(N.scale=c),l&&(N.rotate=l),h&&(N.translate=h);const C=new ht.Group(N),z={points:w,pos:[m[0]-T[0],m[1]-T[1]],fillColor:n,strokeColor:n,lineWidth:0,normalize:!1},L=new ht.Polyline(z);if(C.append(L),!v&&f&&I){const j={points:f,pos:[I[0]-T[0],I[1]-T[1]],fillColor:n,strokeColor:n,lineDash:u===_.Dotted&&!v?[1,s*2]:u===_.LongDotted&&!v?[s,s*2]:void 0,lineCap:u===_.Normal?void 0:"round",lineWidth:s,normalize:!1},A=new ht.Polyline(j);C.append(A)}if(this.replace(i,e,C),c||l||h){const j=C.getBoundingClientRect();return{x:Math.floor(j.x-Y.SafeBorderPadding),y:Math.floor(j.y-Y.SafeBorderPadding),w:Math.floor(j.width+Y.SafeBorderPadding*2),h:Math.floor(j.height+Y.SafeBorderPadding*2)}}return{x:Math.floor(y.x*p[0]+d[0]-Y.SafeBorderPadding),y:Math.floor(y.y*p[1]+d[1]-Y.SafeBorderPadding),w:Math.floor(y.w*p[0]+2*Y.SafeBorderPadding),h:Math.floor(y.h*p[1]+2*Y.SafeBorderPadding)}}computDrawPoints(t){return this.tmpPoints[1].distance(this.tmpPoints[0])>this.arrowTipWidth?this.computFullArrowPoints(t):this.computTrianglePoints()}computFullArrowPoints(t){const e=k.Sub(this.tmpPoints[1],this.tmpPoints[0]).uni(),i=k.Per(e).mul(t/2),n=F.Sub(this.tmpPoints[0],i),s=F.Add(this.tmpPoints[0],i),a=k.Mul(e,this.arrowTipWidth),c=k.Sub(this.tmpPoints[1],a),l=F.Sub(c,i),h=F.Add(c,i),u=k.Per(e).mul(t*1.5),d=F.Sub(c,u),p=F.Add(c,u),f=[this.tmpPoints[0],c],I=[d,this.tmpPoints[1],p],y=[n,s,...I,l,h];return{trianglePoints:I.map(v=>F.Sub(v,this.tmpPoints[1]).XY).flat(1),trianglePos:this.tmpPoints[1].XY,points:f.map(v=>F.Sub(v,this.tmpPoints[0]).XY).flat(1),rect:ft(y),isTriangle:!1,pos:this.tmpPoints[0].XY}}computTrianglePoints(){const t=k.Sub(this.tmpPoints[1],this.tmpPoints[0]).uni(),e=this.tmpPoints[1].distance(this.tmpPoints[0]),i=k.Per(t).mul(Math.floor(e*3/8)),n=F.Sub(this.tmpPoints[0],i),s=F.Add(this.tmpPoints[0],i),a=[n,this.tmpPoints[1],s];return{trianglePoints:a.map(c=>F.Sub(c,this.tmpPoints[1]).XY).flat(1),trianglePos:this.tmpPoints[1].XY,rect:ft(a),isTriangle:!0}}updateTempPoints(t){const e=t.slice(-2),i=new F(e[0],e[1]),n=this.tmpPoints[0],{thickness:s}=this.workOptions;if(n.isNear(i,s))return!1;if(this.tmpPoints.length===2){if(i.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=i}else this.tmpPoints.push(i);return!0}consumeService(t){var c,l;const{op:e,isFullWork:i}=t,n=(c=this.workId)==null?void 0:c.toString();if(!n)return;this.tmpPoints.length=0;for(let h=0;h<e.length;h+=3)this.tmpPoints.push(new F(e[h],e[h+1],e[h+2]));const s=i?this.fullLayer:this.drawLayer||this.fullLayer,a=this.draw({workId:n,layer:s});return this.oldRect=a,(l=this.vNodes)==null||l.setInfo(n,{rect:a,op:e,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:Y.getCenterPos(a,s)}),a}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){var l,h;const{node:e,opt:i,vNodes:n}=t,{strokeColor:s,strokeType:a}=i,c=n.get(e.name);return s&&(e.setAttribute("strokeColor",s),e.setAttribute("fillColor",s),(l=c==null?void 0:c.opt)!=null&&l.strokeColor&&(c.opt.strokeColor=s),c&&n.setInfo(e.name,c)),a&&(c!=null&&c.opt)&&((h=c.opt)!=null&&h.strokeType)&&(c.opt.strokeType=a),Y.updateNodeOpt(t)}}class ls extends Y{constructor(t){super(t);M(this,"canRotate",!1);M(this,"scaleType",at.all);M(this,"toolsType",S.Ellipse);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");M(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}consume(t){const{data:e,isFullWork:i,isSubWorker:n,isMainThread:s}=t,a=this.workId,{op:c}=e,l=c==null?void 0:c.length;if(!l||l<2)return{type:x.None};let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new F(c[0],c[1])],h=!1):h=this.updateTempPoints(c),!h)return{type:x.None};let u;if(n||s){const p=i?this.fullLayer:this.drawLayer||this.fullLayer;u=this.draw({workId:a,layer:p,isDrawing:!0})}if(!n){const p=Date.now();return p-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=p,{type:x.DrawWork,dataType:U.Local,...this.baseConsumeResult,op:this.tmpPoints.map(f=>[...f.XY,0]).flat(1),isSync:!0,index:0}):{type:x.None}}const d=ut(u,this.oldRect);return this.oldRect=u,{rect:d,type:x.DrawWork,dataType:U.Local,...this.baseConsumeResult}}consumeAll(){var a;const t=this.workId;if(this.tmpPoints.length<2)return{type:x.RemoveNode,removeIds:[t]};const e=this.fullLayer,i=this.draw({workId:t,layer:e,isDrawing:!1});this.oldRect=i;const n=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),s=Lt(n);return(a=this.vNodes)==null||a.setInfo(t,{rect:i,op:n,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:i&&Y.getCenterPos(i,e)}),{rect:i,type:x.FullWork,dataType:U.Local,...this.baseConsumeResult,ops:s,isSync:!0}}draw(t){const{workId:e,layer:i,isDrawing:n}=t,{strokeColor:s,fillColor:a,thickness:c,zIndex:l,scale:h,rotate:u,translate:d,strokeType:p}=this.workOptions,f=i.worldScaling,{radius:I,rect:y,pos:v}=this.computDrawPoints(c),w={pos:v,name:e,id:e,radius:I,lineWidth:c,fillColor:a!=="transparent"&&a||void 0,strokeColor:s,normalize:!0,lineJoin:"round",lineCap:"round",lineDash:p===_.Dotted?[1,c*2]:p===_.LongDotted?[c,c*2]:void 0},m={name:e,id:e,zIndex:l,pos:v,anchor:[.5,.5],size:[y.w,y.h]};h&&(m.scale=h),u&&(m.rotate=u),d&&(m.translate=d);const T=new ht.Group(m);if(n){const z=new ht.Path({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:s,lineWidth:1,scale:[1/f[0],1/f[1]]});T.append(z)}const N=new ht.Ellipse({...w,pos:[0,0]});T.append(N),this.replace(i,e,T);const C=T.getBoundingClientRect();return{x:Math.floor(C.x-Y.SafeBorderPadding),y:Math.floor(C.y-Y.SafeBorderPadding),w:Math.floor(C.width+Y.SafeBorderPadding*2),h:Math.floor(C.height+Y.SafeBorderPadding*2)}}computDrawPoints(t){const e=ft(this.tmpPoints),i=ft(this.tmpPoints,t),n=[Math.floor(e.x+e.w/2),Math.floor(e.y+e.h/2)];return{rect:i,pos:n,radius:[Math.floor(e.w/2),Math.floor(e.h/2)]}}updateTempPoints(t){const e=t.slice(-2),i=new F(e[0],e[1]),n=this.tmpPoints[0],{thickness:s}=this.workOptions;if(n.isNear(i,s))return!1;if(this.tmpPoints.length===2){if(i.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=i}else this.tmpPoints.push(i);return!0}consumeService(t){var c,l;const{op:e,isFullWork:i}=t,n=(c=this.workId)==null?void 0:c.toString();if(!n)return;this.tmpPoints.length=0;for(let h=0;h<e.length;h+=3)this.tmpPoints.push(new F(e[h],e[h+1],e[h+2]));const s=i?this.fullLayer:this.drawLayer||this.fullLayer,a=this.draw({workId:n,layer:s,isDrawing:!1});return this.oldRect=a,(l=this.vNodes)==null||l.setInfo(n,{rect:a,op:e,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:Y.getCenterPos(a,s)}),a}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){var u,d,p;const{node:e,opt:i,vNodes:n}=t,{strokeColor:s,fillColor:a,strokeType:c}=i,l=n.get(e.name);let h=e;return e.tagName==="GROUP"&&(h=e.children[0]),s&&(h.setAttribute("strokeColor",s),(u=l==null?void 0:l.opt)!=null&&u.strokeColor&&(l.opt.strokeColor=s)),a&&(a==="transparent"?h.setAttribute("fillColor","rgba(0,0,0,0)"):h.setAttribute("fillColor",a),(d=l==null?void 0:l.opt)!=null&&d.fillColor&&(l.opt.fillColor=a)),c&&(l!=null&&l.opt)&&((p=l.opt)!=null&&p.strokeType)&&(l.opt.strokeType=c),l&&n.setInfo(e.name,l),Y.updateNodeOpt(t)}}var mf=ie,If=Ht,vf="[object Boolean]";function Nf(r){return r===!0||r===!1||If(r)&&mf(r)==vf}var Tf=Nf;const Gt=je(Tf);class hs extends Y{constructor(t){super(t);M(this,"canRotate",!0);M(this,"scaleType",at.all);M(this,"toolsType",S.Rectangle);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");M(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}transformData(){const t=ft(this.tmpPoints);return[[t.x,t.y,0],[t.x+t.w,t.y,0],[t.x+t.w,t.y+t.h,0],[t.x,t.y+t.h,0]]}computDrawPoints(t){const{thickness:e}=this.workOptions,i=[];for(const a of t)i.push(new k(...a));const n=ft(i,e),s=[n.x+n.w/2,n.y+n.h/2];return{rect:n,pos:s,points:i.map(a=>a.XY).flat(1)}}consume(t){const{data:e,isFullWork:i,isSubWorker:n,isMainThread:s}=t,a=this.workId,{op:c}=e,l=c==null?void 0:c.length;if(!l||l<2)return{type:x.None};let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new F(c[0],c[1])],h=!1):h=this.updateTempPoints(c),!h)return{type:x.None};const u=this.transformData();let d;if(n||s){const f=i?this.fullLayer:this.drawLayer||this.fullLayer;d=this.draw({ps:u,workId:a,layer:f,isDrawing:!0})}if(!n){const f=Date.now();return f-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=f,{type:x.DrawWork,dataType:U.Local,op:u.flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:x.None}}const p=ut(d,this.oldRect);return this.oldRect=d,{rect:p,type:x.DrawWork,dataType:U.Local,...this.baseConsumeResult}}consumeAll(){var c;const t=this.workId;if(this.tmpPoints.length<2)return{type:x.RemoveNode,removeIds:[t]};const e=this.transformData(),i=this.fullLayer,n=this.draw({ps:e,workId:t,layer:i,isDrawing:!1});this.oldRect=n;const s=e.flat(1),a=Lt(s);return(c=this.vNodes)==null||c.setInfo(t,{rect:n,op:s,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:n&&Y.getCenterPos(n,i)}),{rect:n,type:x.FullWork,dataType:U.Local,ops:a,isSync:!0,...this.baseConsumeResult}}draw(t){const{workId:e,layer:i,isDrawing:n,ps:s,replaceId:a}=t,{strokeColor:c,fillColor:l,thickness:h,zIndex:u,scale:d,rotate:p,translate:f,strokeType:I}=this.workOptions,y=i.worldPosition,v=i.worldScaling,{points:w,rect:m,pos:T}=this.computDrawPoints(s),N={close:!0,normalize:!0,points:w,lineWidth:h,fillColor:l!=="transparent"&&l||void 0,strokeColor:c,lineJoin:"round",lineCap:"round",lineDash:I===_.Dotted?[1,h*2]:I===_.LongDotted?[h,h*2]:void 0},C={x:Math.floor(m.x*v[0]+y[0]-Y.SafeBorderPadding),y:Math.floor(m.y*v[1]+y[1]-Y.SafeBorderPadding),w:Math.floor(m.w*v[0]+2*Y.SafeBorderPadding),h:Math.floor(m.h*v[0]+2*Y.SafeBorderPadding)},z=new ht.Group({name:e,id:e,zIndex:u,pos:T,anchor:[.5,.5],size:[m.w,m.h],scale:d,rotate:p,translate:f}),L=new ht.Polyline({...N,pos:[0,0]});if(z.appendChild(L),n){const j=new ht.Path({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:c,lineWidth:1,scale:[1/v[0],1/v[1]]});z.appendChild(j)}if(this.replace(i,a||e,z),d||p||f){const j=z.getBoundingClientRect();return{x:Math.floor(j.x-Y.SafeBorderPadding),y:Math.floor(j.y-Y.SafeBorderPadding),w:Math.floor(j.width+2*Y.SafeBorderPadding),h:Math.floor(j.height+2*Y.SafeBorderPadding)}}return C}updateTempPoints(t){const e=t.slice(-2),i=new F(e[0],e[1]),n=this.tmpPoints[0],{thickness:s}=this.workOptions;if(n.isNear(i,s))return!1;if(this.tmpPoints.length===2){if(i.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=i}else this.tmpPoints.push(i);return!0}consumeService(t){var h,u;const{op:e,isFullWork:i,replaceId:n}=t,s=(h=this.workId)==null?void 0:h.toString();if(!s)return;const a=[];for(let d=0;d<e.length;d+=3)a.push([e[d],e[d+1],e[d+2]]);const c=i?this.fullLayer:this.drawLayer||this.fullLayer,l=this.draw({ps:a,workId:s,layer:c,isDrawing:!1,replaceId:n});return this.oldRect=l,(u=this.vNodes)==null||u.setInfo(s,{rect:l,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:l&&Y.getCenterPos(l,c)}),l}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){var w,m,T;const{node:e,opt:i,vNodes:n}=t,{strokeColor:s,fillColor:a,fontColor:c,fontBgColor:l,bold:h,italic:u,lineThrough:d,underline:p,fontSize:f,strokeType:I}=i,y=n.get(e.name);let v=e;if(e.tagName==="GROUP"&&(v=e.children[0]),s&&(v.setAttribute("strokeColor",s),(w=y==null?void 0:y.opt)!=null&&w.strokeColor&&(y.opt.strokeColor=s)),a&&(a==="transparent"?v.setAttribute("fillColor","rgba(0,0,0,0)"):v.setAttribute("fillColor",a),(m=y==null?void 0:y.opt)!=null&&m.fillColor&&(y.opt.fillColor=a)),y!=null&&y.opt.textOpt){const N=y.opt.textOpt;c&&N.fontColor&&(N.fontColor=c),l&&N.fontBgColor&&(N.fontBgColor=l),h&&(N.bold=h),u&&(N.italic=u),Gt(d)&&(N.lineThrough=d),Gt(p)&&(N.underline=p),f&&(N.fontSize=f)}return I&&(y!=null&&y.opt)&&((T=y.opt)!=null&&T.strokeType)&&(y.opt.strokeType=I),y&&n.setInfo(e.name,y),Y.updateNodeOpt(t)}}class us extends Y{constructor(t){super(t);M(this,"canRotate",!1);M(this,"scaleType",at.all);M(this,"toolsType",S.Star);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");M(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}consume(t){const{data:e,isFullWork:i,isSubWorker:n,isMainThread:s}=t,a=this.workId,{op:c}=e,l=c==null?void 0:c.length;if(!l||l<2)return{type:x.None};let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new F(c[0],c[1])],h=!1):h=this.updateTempPoints(c),!h)return{type:x.None};let u;if(n||s){const p=i?this.fullLayer:this.drawLayer||this.fullLayer;u=this.draw({workId:a,layer:p,isDrawing:!0})}if(!n){const p=Date.now();return p-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=p,{type:x.DrawWork,dataType:U.Local,op:this.tmpPoints.map(f=>[...f.XY,0]).flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:x.None}}const d=ut(u,this.oldRect);return this.oldRect=u,{rect:d,type:x.DrawWork,dataType:U.Local,...this.baseConsumeResult}}consumeAll(){var a;const t=this.workId;if(this.tmpPoints.length<2)return{type:x.RemoveNode,removeIds:[t]};const e=this.fullLayer,i=this.draw({workId:t,layer:e,isDrawing:!1});this.oldRect=i;const n=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),s=Lt(n);return(a=this.vNodes)==null||a.setInfo(t,{rect:i,op:n,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:i&&Y.getCenterPos(i,e)}),{rect:i,type:x.FullWork,dataType:U.Local,ops:s,isSync:!0,...this.baseConsumeResult}}draw(t){const{workId:e,layer:i,isDrawing:n}=t,{strokeColor:s,fillColor:a,thickness:c,zIndex:l,vertices:h,innerVerticeStep:u,innerRatio:d,scale:p,rotate:f,translate:I,strokeType:y}=this.workOptions,v=i.worldScaling,{rect:w,pos:m,points:T}=this.computDrawPoints(c,h,u,d),N={close:!0,points:T,lineWidth:c,fillColor:a!=="transparent"&&a||void 0,strokeColor:s,normalize:!0,lineJoin:"round",lineCap:"round",lineDash:y===_.Dotted?[1,c*2]:y===_.LongDotted?[c,c*2]:void 0},C={name:e,id:e,zIndex:l,pos:m,anchor:[.5,.5],size:[w.w,w.h]};p&&(C.scale=p),f&&(C.rotate=f),I&&(C.translate=I);const z=new ht.Group(C);if(n){const A=new ht.Path({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:s,lineWidth:1,scale:[1/v[0],1/v[1]]});z.append(A)}const L=new ht.Polyline({...N,pos:[0,0]});z.append(L),this.replace(i,e,z);const j=z.getBoundingClientRect();return{x:Math.floor(j.x-Y.SafeBorderPadding),y:Math.floor(j.y-Y.SafeBorderPadding),w:Math.floor(j.width+Y.SafeBorderPadding*2),h:Math.floor(j.height+Y.SafeBorderPadding*2)}}computDrawPoints(t,e,i,n){const s=ft(this.tmpPoints),a=[Math.floor(s.x+s.w/2),Math.floor(s.y+s.h/2)],c=vs(s.w,s.h),l=Math.floor(Math.min(s.w,s.h)/2),h=n*l,u=[],d=2*Math.PI/e;for(let f=0;f<e;f++){const I=f*d-.5*Math.PI;let y,v;f%i===1?(y=h*c[0]*Math.cos(I),v=h*c[1]*Math.sin(I)):(y=l*c[0]*Math.cos(I),v=l*c[1]*Math.sin(I),u.push(y,v)),u.push(y,v)}return{rect:ft(this.tmpPoints,t),pos:a,points:u}}updateTempPoints(t){const e=t.slice(-2),i=new F(e[0],e[1]),n=this.tmpPoints[0],{thickness:s}=this.workOptions;if(n.isNear(i,s)||F.Sub(n,i).XY.includes(0))return!1;if(this.tmpPoints.length===2){if(i.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=i}else this.tmpPoints.push(i);return!0}consumeService(t){var c,l;const{op:e,isFullWork:i}=t,n=(c=this.workId)==null?void 0:c.toString();if(!n)return;this.tmpPoints.length=0;for(let h=0;h<e.length;h+=3)this.tmpPoints.push(new F(e[h],e[h+1],e[h+2]));const s=i?this.fullLayer:this.drawLayer||this.fullLayer,a=this.draw({workId:n,layer:s,isDrawing:!1});return this.oldRect=a,(l=this.vNodes)==null||l.setInfo(n,{rect:a,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:a&&Y.getCenterPos(a,s)}),a}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){var y;const{node:e,opt:i,vNodes:n}=t,{strokeColor:s,fillColor:a,toolsType:c,vertices:l,innerVerticeStep:h,innerRatio:u,strokeType:d}=i,p=n.get(e.name),f=p==null?void 0:p.opt;let I=e;return e.tagName==="GROUP"&&(I=e.children[0]),s&&(I.setAttribute("strokeColor",s),f!=null&&f.strokeColor&&(f.strokeColor=s)),a&&(a==="transparent"?I.setAttribute("fillColor","rgba(0,0,0,0)"):I.setAttribute("fillColor",a),f!=null&&f.fillColor&&(f.fillColor=a)),c===S.Star&&(l&&(f.vertices=l),h&&(f.innerVerticeStep=h),u&&(f.innerRatio=u)),d&&(p!=null&&p.opt)&&((y=p.opt)!=null&&y.strokeType)&&(p.opt.strokeType=d),p&&n.setInfo(e.name,{...p,opt:f}),Y.updateNodeOpt(t)}}class ds extends Y{constructor(t){super(t);M(this,"canRotate",!1);M(this,"scaleType",at.all);M(this,"toolsType",S.Polygon);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");M(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}consume(t){const{data:e,isFullWork:i,isSubWorker:n,isMainThread:s}=t,{op:a}=e,c=this.workId,l=a==null?void 0:a.length;if(!l||l<2)return{type:x.None};let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new F(a[0],a[1])],h=!1):h=this.updateTempPoints(a),!h)return{type:x.None};let u;if(n||s){const p=i?this.fullLayer:this.drawLayer||this.fullLayer;u=this.draw({workId:c,layer:p,isDrawing:!0})}if(!n){const p=Date.now();return p-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=p,{type:x.DrawWork,dataType:U.Local,op:this.tmpPoints.map(f=>[...f.XY,0]).flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:x.None}}const d=ut(u,this.oldRect);return this.oldRect=u,{rect:d,type:x.DrawWork,dataType:U.Local,...this.baseConsumeResult}}consumeAll(){var a;const t=this.workId;if(this.tmpPoints.length<2)return{type:x.RemoveNode,removeIds:[t]};const e=this.fullLayer,i=this.draw({workId:t,layer:e,isDrawing:!1});this.oldRect=i;const n=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),s=Lt(n);return(a=this.vNodes)==null||a.setInfo(t,{rect:i,op:n,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:i&&Y.getCenterPos(i,e)}),{rect:i,type:x.FullWork,dataType:U.Local,ops:s,isSync:!0,...this.baseConsumeResult}}draw(t){const{workId:e,layer:i,isDrawing:n}=t,{strokeColor:s,fillColor:a,thickness:c,zIndex:l,vertices:h,scale:u,rotate:d,translate:p,strokeType:f}=this.workOptions,I=i.worldScaling,{rect:y,pos:v,points:w}=this.computDrawPoints(c,h),m={close:!0,points:w,lineWidth:c,fillColor:a!=="transparent"&&a||void 0,strokeColor:s,normalize:!0,lineJoin:"round",lineCap:"round",lineDash:f===_.Dotted?[1,c*2]:f===_.LongDotted?[c,c*2]:void 0},T={name:e,id:e,zIndex:l,pos:v,anchor:[.5,.5],size:[y.w,y.h]};u&&(T.scale=u),d&&(T.rotate=d),p&&(T.translate=p);const N=new ht.Group(T);if(n){const L=new ht.Path({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:s,lineWidth:1,scale:[1/I[0],1/I[1]]});N.append(L)}const C=new ht.Polyline({...m,pos:[0,0]});N.append(C),this.replace(i,e,N);const z=N.getBoundingClientRect();return{x:Math.floor(z.x-Y.SafeBorderPadding),y:Math.floor(z.y-Y.SafeBorderPadding),w:Math.floor(z.width+Y.SafeBorderPadding*2),h:Math.floor(z.height+Y.SafeBorderPadding*2)}}computDrawPoints(t,e){const i=ft(this.tmpPoints),n=[Math.floor(i.x+i.w/2),Math.floor(i.y+i.h/2)],s=vs(i.w,i.h),a=Math.floor(Math.min(i.w,i.h)/2),c=[],l=2*Math.PI/e;for(let u=0;u<e;u++){const d=u*l-.5*Math.PI,p=a*s[0]*Math.cos(d),f=a*s[1]*Math.sin(d);c.push(p,f)}return{rect:ft(this.tmpPoints,t),pos:n,points:c}}updateTempPoints(t){const e=t.slice(-2),i=new F(e[0],e[1]),n=this.tmpPoints[0],{thickness:s}=this.workOptions;if(n.isNear(i,s)||F.Sub(n,i).XY.includes(0))return!1;if(this.tmpPoints.length===2){if(i.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=i}else this.tmpPoints.push(i);return!0}consumeService(t){var c,l;const{op:e,isFullWork:i}=t,n=(c=this.workId)==null?void 0:c.toString();if(!n)return;this.tmpPoints.length=0;for(let h=0;h<e.length;h+=3)this.tmpPoints.push(new F(e[h],e[h+1],e[h+2]));const s=i?this.fullLayer:this.drawLayer||this.fullLayer,a=this.draw({workId:n,layer:s,isDrawing:!1});return this.oldRect=a,(l=this.vNodes)==null||l.setInfo(n,{rect:a,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:a&&Y.getCenterPos(a,s)}),a}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){var f;const{node:e,opt:i,vNodes:n}=t,{strokeColor:s,fillColor:a,toolsType:c,vertices:l,strokeType:h}=i,u=n.get(e.name),d=u==null?void 0:u.opt;let p=e;return e.tagName==="GROUP"&&(p=e.children[0]),s&&(p.setAttribute("strokeColor",s),d!=null&&d.strokeColor&&(d.strokeColor=s)),a&&(a==="transparent"?p.setAttribute("fillColor","rgba(0,0,0,0)"):p.setAttribute("fillColor",a),d!=null&&d.fillColor&&(d.fillColor=a)),c===S.Polygon&&l&&(d.vertices=l),h&&(u!=null&&u.opt)&&((f=u.opt)!=null&&f.strokeType)&&(u.opt.strokeType=h),u&&n.setInfo(e.name,{...u,opt:d}),Y.updateNodeOpt(t)}}class At{static bezier(o,t){const e=[];for(let i=0;i<t.length;i+=4){const n=t[i],s=t[i+1],a=t[i+2],c=t[i+3];n&&s&&a&&c?e.push(...At.getBezierPoints(o,n,s,a,c)):n&&s&&a?e.push(...At.getBezierPoints(o,n,s,a)):n&&s?e.push(...At.getBezierPoints(o,n,s)):n&&e.push(n)}return e}static getBezierPoints(o=10,t,e,i,n){let s=null;const a=[];!i&&!n?s=At.oneBezier:i&&!n?s=At.twoBezier:i&&n&&(s=At.threeBezier);for(let c=0;c<o;c++)s&&a.push(s(c/o,t,e,i,n));return n?a.push(n):i&&a.push(i),a}static oneBezier(o,t,e){const i=t.x+(e.x-t.x)*o,n=t.y+(e.y-t.y)*o;return new k(i,n)}static twoBezier(o,t,e,i){const n=(1-o)*(1-o)*t.x+2*o*(1-o)*e.x+o*o*i.x,s=(1-o)*(1-o)*t.y+2*o*(1-o)*e.y+o*o*i.y;return new k(n,s)}static threeBezier(o,t,e,i,n){const s=t.x*(1-o)*(1-o)*(1-o)+3*e.x*o*(1-o)*(1-o)+3*i.x*o*o*(1-o)+n.x*o*o*o,a=t.y*(1-o)*(1-o)*(1-o)+3*e.y*o*(1-o)*(1-o)+3*i.y*o*o*(1-o)+n.y*o*o*o;return new k(s,a)}}class ps extends Y{constructor(t){super(t);M(this,"canRotate",!1);M(this,"scaleType",at.all);M(this,"toolsType",S.SpeechBalloon);M(this,"ratio",.8);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");M(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}consume(t){var p;const{data:e,isFullWork:i,isSubWorker:n,isMainThread:s}=t,a=(p=e==null?void 0:e.workId)==null?void 0:p.toString();if(!a)return{type:x.None};const{op:c}=e,l=c==null?void 0:c.length;if(!l||l<2)return{type:x.None};let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new F(c[0],c[1])],h=!1):h=this.updateTempPoints(c),!h)return{type:x.None};let u;if(n||s){const f=i?this.fullLayer:this.drawLayer||this.fullLayer;u=this.draw({workId:a,layer:f,isDrawing:!0})}if(!n){const f=Date.now();return f-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=f,{type:x.DrawWork,dataType:U.Local,op:this.tmpPoints.map(I=>[...I.XY,0]).flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:x.None}}const d=ut(u,this.oldRect);return this.oldRect=u,{rect:d,type:x.DrawWork,dataType:U.Local,...this.baseConsumeResult}}consumeAll(){var a;const t=this.workId;if(this.tmpPoints.length<2)return{type:x.RemoveNode,removeIds:[t]};const e=this.fullLayer,i=this.draw({workId:t,layer:e,isDrawing:!1});this.oldRect=i;const n=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),s=Lt(n);return(a=this.vNodes)==null||a.setInfo(t,{rect:i,op:n,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:i&&Y.getCenterPos(i,e)}),{rect:i,type:x.FullWork,dataType:U.Local,ops:s,isSync:!0,...this.baseConsumeResult}}draw(t){const{workId:e,layer:i}=t,{strokeColor:n,fillColor:s,thickness:a,zIndex:c,placement:l,scale:h,rotate:u,translate:d,strokeType:p}=this.workOptions,{rect:f,pos:I,points:y}=this.computDrawPoints(a,l),v={points:y.map(C=>C.XY),lineWidth:a,fillColor:s!=="transparent"&&s||void 0,strokeColor:n,normalize:!0,className:`${I[0]},${I[1]}`,close:!0,lineJoin:"round",lineCap:"round",lineDash:p===_.Dotted?[1,a*2]:p===_.LongDotted?[a,a*2]:void 0},w={name:e,id:e,zIndex:c,pos:I,anchor:[.5,.5],size:[f.w,f.h]};h&&(w.scale=h),u&&(w.rotate=u),d&&(w.translate=d);const m=new ht.Group(w),T=new ht.Polyline({...v,pos:[0,0]});m.append(T),this.replace(i,e,m);const N=m.getBoundingClientRect();return{x:Math.floor(N.x-Y.SafeBorderPadding),y:Math.floor(N.y-Y.SafeBorderPadding),w:Math.floor(N.width+Y.SafeBorderPadding*2),h:Math.floor(N.height+Y.SafeBorderPadding*2)}}transformControlPoints(t){const e=ft(this.tmpPoints);switch(t){case"bottom":case"bottomLeft":case"bottomRight":{const i=e.y+e.h*this.ratio;return[new k(e.x,e.y,0),new k(e.x+e.w,e.y,0),new k(e.x+e.w,i,0),new k(e.x,i,0)]}case"top":case"topLeft":case"topRight":{const i=e.y+e.h*(1-this.ratio);return[new k(e.x,i,0),new k(e.x+e.w,i,0),new k(e.x+e.w,e.y+e.h,0),new k(e.x,e.y+e.h,0)]}case"left":case"leftBottom":case"leftTop":{const i=e.x+e.w*(1-this.ratio);return[new k(i,e.y,0),new k(e.x+e.w,e.y,0),new k(e.x+e.w,e.y+e.h,0),new k(i,e.y+e.h,0)]}case"right":case"rightBottom":case"rightTop":{const i=e.x+e.w*this.ratio;return[new k(e.x,e.y,0),new k(i,e.y,0),new k(i,e.y+e.h,0),new k(e.x,e.y+e.h,0)]}}}computDrawPoints(t,e){const i=ft(this.tmpPoints),n=this.transformControlPoints(e),s=Math.floor(i.w*.1),a=Math.floor(i.h*.1),c=[],l=k.Add(n[0],new k(0,a,0)),h=k.Add(n[0],new k(s,0,0)),u=At.getBezierPoints(10,l,n[0],h),d=k.Sub(n[1],new k(s,0,0)),p=k.Add(n[1],new k(0,a,0)),f=At.getBezierPoints(10,d,n[1],p),I=k.Sub(n[2],new k(0,a,0)),y=k.Sub(n[2],new k(s,0,0)),v=At.getBezierPoints(10,I,n[2],y),w=k.Add(n[3],new k(s,0,0)),m=k.Sub(n[3],new k(0,a,0)),T=At.getBezierPoints(10,w,n[3],m),N=s*(1-this.ratio)*10,C=a*(1-this.ratio)*10;switch(e){case"bottom":{const j=k.Sub(n[2],new k(s*5-N/2,0,0)),A=k.Sub(n[2],new k(s*5,-C,0)),P=k.Sub(n[2],new k(s*5+N/2,0,0));c.push(A,P,...T,...u,...f,...v,j);break}case"bottomRight":{const j=k.Sub(n[2],new k(s*1.1,0,0)),A=k.Sub(n[2],new k(s*1.1+N/2,-C,0)),P=k.Sub(n[2],new k(s*1.1+N,0,0));c.push(A,P,...T,...u,...f,...v,j);break}case"bottomLeft":{const j=k.Add(n[3],new k(s*1.1+N,0,0)),A=k.Add(n[3],new k(s*1.1+N/2,C,0)),P=k.Add(n[3],new k(s*1.1,0,0));c.push(A,P,...T,...u,...f,...v,j);break}case"top":{const j=k.Sub(n[1],new k(s*5-N/2,0,0)),A=k.Sub(n[1],new k(s*5,C,0)),P=k.Sub(n[1],new k(s*5+N/2,0,0));c.push(A,j,...f,...v,...T,...u,P);break}case"topRight":{const j=k.Sub(n[1],new k(s*1.1,0,0)),A=k.Sub(n[1],new k(s*1.1+N/2,C,0)),P=k.Sub(n[1],new k(s*1.1+N,0,0));c.push(A,j,...f,...v,...T,...u,P);break}case"topLeft":{const j=k.Add(n[0],new k(s*1.1+N,0,0)),A=k.Add(n[0],new k(s*1.1+N/2,-C,0)),P=k.Add(n[0],new k(s*1.1,0,0));c.push(A,j,...f,...v,...T,...u,P);break}case"left":{const j=k.Add(n[0],new k(0,a*5-C/2,0)),A=k.Add(n[0],new k(-N,a*5,0)),P=k.Add(n[0],new k(0,a*5+C/2,0));c.push(A,j,...u,...f,...v,...T,P);break}case"leftTop":{const j=k.Add(n[0],new k(0,a*1.1,0)),A=k.Add(n[0],new k(-N,a*1.1+C/2,0)),P=k.Add(n[0],new k(0,a*1.1+C,0));c.push(A,j,...u,...f,...v,...T,P);break}case"leftBottom":{const j=k.Sub(n[3],new k(0,a*1.1+C,0)),A=k.Sub(n[3],new k(N,a*1.1+C/2,0)),P=k.Sub(n[3],new k(0,a*1.1,0));c.push(A,j,...u,...f,...v,...T,P);break}case"right":{const j=k.Add(n[1],new k(0,a*5-C/2,0)),A=k.Add(n[1],new k(N,a*5,0)),P=k.Add(n[1],new k(0,a*5+C/2,0));c.push(A,P,...v,...T,...u,...f,j);break}case"rightTop":{const j=k.Add(n[1],new k(0,a*1.1,0)),A=k.Add(n[1],new k(N,a*1.1+C/2,0)),P=k.Add(n[1],new k(0,a*1.1+C,0));c.push(A,P,...v,...T,...u,...f,j);break}case"rightBottom":{const j=k.Sub(n[2],new k(0,a*1.1+C,0)),A=k.Sub(n[2],new k(-N,a*1.1+C/2,0)),P=k.Sub(n[2],new k(0,a*1.1,0));c.push(A,P,...v,...T,...u,...f,j);break}}const z=ft(this.tmpPoints,t),L=[Math.floor(z.x+z.w/2),Math.floor(z.y+z.h/2)];return{rect:z,pos:L,points:c}}updateTempPoints(t){const e=t.slice(-2),i=new F(e[0],e[1]),n=this.tmpPoints[0],{thickness:s}=this.workOptions;if(n.isNear(i,s)||F.Sub(n,i).XY.includes(0))return!1;if(this.tmpPoints.length===2){if(i.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=i}else this.tmpPoints.push(i);return!0}consumeService(t){var c,l;const{op:e,isFullWork:i}=t,n=(c=this.workId)==null?void 0:c.toString();if(!n)return;this.tmpPoints.length=0;for(let h=0;h<e.length;h+=3)this.tmpPoints.push(new F(e[h],e[h+1],e[h+2]));const s=i?this.fullLayer:this.drawLayer||this.fullLayer,a=this.draw({workId:n,layer:s,isDrawing:!1});return this.oldRect=a,(l=this.vNodes)==null||l.setInfo(n,{rect:a,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:a&&Y.getCenterPos(a,s)}),a}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){var f;const{node:e,opt:i,vNodes:n}=t,{strokeColor:s,fillColor:a,toolsType:c,placement:l,strokeType:h}=i,u=n.get(e.name),d=u==null?void 0:u.opt;let p=e;return e.tagName==="GROUP"&&(p=e.children[0]),s&&(p.setAttribute("strokeColor",s),d!=null&&d.strokeColor&&(d.strokeColor=s)),a&&(a==="transparent"?p.setAttribute("fillColor","rgba(0,0,0,0)"):p.setAttribute("fillColor",a),d!=null&&d.fillColor&&(d.fillColor=a)),c===S.SpeechBalloon&&l&&(d.placement=l),h&&(u!=null&&u.opt)&&((f=u.opt)!=null&&f.strokeType)&&(u.opt.strokeType=h),u&&n.setInfo(e.name,{...u,opt:d}),Y.updateNodeOpt(t)}}class xe extends Y{constructor(t){super(t);M(this,"canRotate",!0);M(this,"scaleType",at.all);M(this,"toolsType",S.Image);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");this.workOptions=t.toolsOpt,this.scaleType=xe.getScaleType(this.workOptions)}consume(){return{type:x.None}}consumeAll(){return{type:x.None}}draw(t){const{layer:e,workId:i,replaceId:n,imageBitmap:s,isMainThread:a}=t,{centerX:c,centerY:l,width:h,height:u,rotate:d,zIndex:p}=this.workOptions,f=!!e.parent.gl,I={anchor:[.5,.5],pos:[c,l],name:i,size:[h,u],zIndex:p,rotate:!a&&!f&&180+(d||0)||d,texture:s},y=new ht.Sprite(I);this.replace(e,n||i,y);const v=y.getBoundingClientRect();if(v)return{x:Math.floor(v.x-Y.SafeBorderPadding),y:Math.floor(v.y-Y.SafeBorderPadding),w:Math.floor(v.width+Y.SafeBorderPadding*2),h:Math.floor(v.height+Y.SafeBorderPadding*2)}}consumeService(){}async consumeServiceAsync(t){var u,d,p,f;const{isFullWork:e,replaceId:i,scene:n,isMainThread:s}=t,{src:a,uuid:c}=this.workOptions,l=((u=this.workId)==null?void 0:u.toString())||c,h=e?this.fullLayer:this.drawLayer||this.fullLayer;if(a){const I=await n.preload({id:c,src:this.workOptions.src}),y=this.draw({workId:l,layer:h,replaceId:i,imageBitmap:I[0],isMainThread:s});return this.oldRect=l&&((p=(d=this.vNodes)==null?void 0:d.get(l))==null?void 0:p.rect)||void 0,(f=this.vNodes)==null||f.setInfo(l,{rect:y,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:y&&Y.getCenterPos(y,h)}),y}}clearTmpPoints(){this.tmpPoints.length=0}static getScaleType(t){const{uniformScale:e,rotate:i}=t;return e!==!1||i&&Math.abs(i)%90>0?at.proportional:at.all}static updateNodeOpt(t){const{node:e,opt:i,vNodes:n,targetNode:s}=t,{translate:a,originPoint:c,scenePoint:l,scale:h,angle:u,isLocked:d,zIndex:p}=i,f=s&&Qt(s)||n.get(e.name);if(!f)return;const I=e.parent;if(I){if(Wt(p)&&(e.setAttribute("zIndex",p),f.opt.zIndex=p),Gt(d)&&(f.opt.locked=d),c&&l&&h){const{centerX:y,centerY:v,width:w,height:m,uniformScale:T}=f.opt,N=T!==!1?[h[0],h[0]]:h,C=[y,v],z=[y,v];Ro(z,l,N,a);const L=[z[0]-C[0],z[1]-C[1]];f.centerPos=[f.centerPos[0]+L[0],f.centerPos[1]+L[1]],f.opt.width=Math.round(w*N[0]),f.opt.height=Math.round(m*N[1]),f.opt.centerX=z[0],f.opt.centerY=z[1]}else if(a)f.opt.centerX=f.opt.centerX+a[0],f.opt.centerY=f.opt.centerY+a[1],f.centerPos=[f.centerPos[0]+a[0],f.centerPos[1]+a[1]];else if(Wt(u))if(f.opt.rotate=u,f.scaleType=xe.getScaleType(f.opt),s){const y=ms(f.rect,u);f.rect=y}else{const y=Y.getRectFromLayer(I,e.name);f.rect=y||f.rect}return f&&n.setInfo(e.name,f),f==null?void 0:f.rect}}}class fs extends Y{constructor(t){super(t);M(this,"canRotate",!1);M(this,"scaleType",at.both);M(this,"toolsType",S.Straight);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");M(this,"straightTipWidth");M(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.straightTipWidth=this.workOptions.thickness/2,this.syncTimestamp=0,this.syncUnitTime=50}consume(t){const{data:e,isFullWork:i,isSubWorker:n,isMainThread:s}=t,a=this.workId,{op:c}=e,l=c==null?void 0:c.length;if(!l||l<2)return{type:x.None};let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new F(c[0],c[1])],h=!1):h=this.updateTempPoints(c),!h)return{type:x.None};let u;if(n||s){const p=i?this.fullLayer:this.drawLayer||this.fullLayer;u=this.draw({workId:a,layer:p})}if(!n){const p=Date.now();return p-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=p,{type:x.DrawWork,dataType:U.Local,op:this.tmpPoints.map(f=>[...f.XY,0]).flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:x.None}}const d=ut(u,this.oldRect);return this.oldRect=u,{rect:d,type:x.DrawWork,dataType:U.Local,...this.baseConsumeResult}}consumeAll(){var a;const t=this.workId;if(this.tmpPoints.length<2)return{type:x.RemoveNode,removeIds:[t]};const e=this.fullLayer,i=this.draw({workId:t,layer:e});this.oldRect=i;const n=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),s=Lt(n);return(a=this.vNodes)==null||a.setInfo(t,{rect:i,op:n,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:i&&Y.getCenterPos(i,e)}),{rect:i,type:x.FullWork,dataType:U.Local,ops:s,isSync:!0,...this.baseConsumeResult}}draw(t){const{workId:e,layer:i}=t,{strokeColor:n,thickness:s,zIndex:a,scale:c,rotate:l,translate:h,strokeType:u}=this.workOptions,d=i.worldPosition,p=i.worldScaling,{d:f,rect:I,isDot:y}=this.computDrawPoints(s,u),v=[I.x+I.w/2,I.y+I.h/2],w={pos:v,name:e,id:e,d:f,fillColor:n,strokeColor:n,lineDash:u===_.Dotted&&!y?[1,s*2]:u===_.LongDotted&&!y?[s,s*2]:void 0,lineCap:u===_.Normal||y?void 0:"round",lineWidth:u===_.Normal||y?0:s,className:`${v[0]},${v[1]}`,normalize:!0,zIndex:a};c&&(w.scale=c),l&&(w.rotate=l),h&&(w.translate=h);const m=new ht.Path(w);if(this.replace(i,e,m),l||c||h){const N=m.getBoundingClientRect();return{x:Math.floor(N.x-Y.SafeBorderPadding),y:Math.floor(N.y-Y.SafeBorderPadding),w:Math.floor(N.width+Y.SafeBorderPadding*2),h:Math.floor(N.height+Y.SafeBorderPadding*2)}}return{x:Math.floor(I.x*p[0]+d[0]-Y.SafeBorderPadding),y:Math.floor(I.y*p[1]+d[1]-Y.SafeBorderPadding),w:Math.floor(I.w*p[0]+2*Y.SafeBorderPadding),h:Math.floor(I.h*p[1]+2*Y.SafeBorderPadding)}}computDrawPoints(t,e){return this.tmpPoints[1].distance(this.tmpPoints[0])>this.straightTipWidth?this.computFullPoints(t,e):this.computDotPoints(t)}computFullPoints(t,e){const i=k.Sub(this.tmpPoints[1],this.tmpPoints[0]).uni(),n=k.Per(i).mul(t/2),s=F.Sub(this.tmpPoints[0],n),a=F.Add(this.tmpPoints[0],n),c=F.Sub(this.tmpPoints[1],n),l=F.Add(this.tmpPoints[1],n),h=F.GetSemicircleStroke(this.tmpPoints[1],c,-1,8),u=F.GetSemicircleStroke(this.tmpPoints[0],a,-1,8),d=[s,c,...h,l,a,...u];let p;return e!==_.Normal?p=oe(this.tmpPoints,!1):p=oe(d,!0),{d:p,rect:ft(d),isDot:!1,pos:this.tmpPoints[0].XY}}computDotPoints(t){const e=F.GetDotStroke(this.tmpPoints[0],t/2,8);return{d:oe(e,!0),rect:ft(e),isDot:!0,pos:this.tmpPoints[0].XY}}updateTempPoints(t){const e=t.slice(-2),i=new F(e[0],e[1]),n=this.tmpPoints[0],{thickness:s}=this.workOptions;if(n.isNear(i,s))return!1;if(this.tmpPoints.length===2){if(i.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=i}else this.tmpPoints.push(i);return!0}consumeService(t){var c,l;const{op:e,isFullWork:i}=t,n=(c=this.workId)==null?void 0:c.toString();if(!n)return;this.tmpPoints.length=0;for(let h=0;h<e.length;h+=3)this.tmpPoints.push(new F(e[h],e[h+1],e[h+2]));const s=i?this.fullLayer:this.drawLayer||this.fullLayer,a=this.draw({workId:n,layer:s});return this.oldRect=a,(l=this.vNodes)==null||l.setInfo(n,{rect:a,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:a&&Y.getCenterPos(a,s)}),a}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){var l,h;const{node:e,opt:i,vNodes:n}=t,{strokeColor:s,strokeType:a}=i,c=n.get(e.name);return s&&(e.setAttribute("strokeColor",s),e.setAttribute("fillColor",s),(l=c==null?void 0:c.opt)!=null&&l.strokeColor&&(c.opt.strokeColor=s)),a&&(c!=null&&c.opt)&&((h=c.opt)!=null&&h.strokeType)&&(c.opt.strokeType=a),c&&n.setInfo(e.name,c),Y.updateNodeOpt(t)}}const Zt=class Zt extends Y{constructor(t){super(t);M(this,"canRotate",!1);M(this,"scaleType",at.proportional);M(this,"toolsType",S.Text);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");this.workOptions=t.toolsOpt}consume(){return{type:x.None}}consumeAll(){return{type:x.None}}consumeService(){}async draw(t){const{workId:e,layer:i,isDrawLabel:n}=t,{boxSize:s,boxPoint:a,zIndex:c}=this.workOptions,l=i.worldPosition,h=i.worldScaling;if(!a||!s)return;const u={name:e,id:e,pos:[a[0],a[1]],anchor:[0,0],size:s,zIndex:c},d=new ht.Group(u),p={x:a[0],y:a[1],w:s[0],h:s[1]},f={x:Math.floor(p.x*h[0]+l[0]),y:Math.floor(p.y*h[1]+l[1]),w:Math.floor(p.w*h[0])+2,h:Math.floor(p.h*h[1])+2};if(this.replace(i,e,d),n&&i&&this.workOptions.text){const I=await Zt.createLabels(this.workOptions,i,f),{labels:y,maxWidth:v}=I;d.append(...y),f.w=Math.ceil(Math.max(v*i.worldScaling[0],f.w))}return f}async consumeServiceAsync(t){var l,h,u,d;const e=(l=this.workId)==null?void 0:l.toString();if(!e)return;const{isFullWork:i,replaceId:n,isDrawLabel:s}=t;this.oldRect=n&&((u=(h=this.vNodes)==null?void 0:h.get(n))==null?void 0:u.rect)||void 0;const a=i?this.fullLayer:this.drawLayer||this.fullLayer,c=await this.draw({workId:e,layer:a,isDrawLabel:typeof s>"u"&&this.workOptions.workState===b.Done||s});return(d=this.vNodes)==null||d.setInfo(e,{rect:c,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:c&&Y.getCenterPos(c,a)}),c}updataOptService(){}async updataOptServiceAsync(t,e){var f,I;if(!this.workId)return;const i=this.workId.toString(),{fontColor:n,fontBgColor:s,bold:a,italic:c,lineThrough:l,underline:h,zIndex:u}=t,d=(f=this.vNodes)==null?void 0:f.get(i);if(!d)return;n&&(d.opt.fontColor=n),s&&(d.opt.fontBgColor=s),a&&(d.opt.bold=a),c&&(d.opt.italic=c),Gt(l)&&(d.opt.lineThrough=l),Gt(h)&&(d.opt.underline=h),Wt(u)&&(d.opt.zIndex=u),this.oldRect=d.rect;const p=await this.draw({workId:i,layer:this.fullLayer,isDrawLabel:typeof e>"u"&&this.workOptions.workState===b.Done||e});return(I=this.vNodes)==null||I.setInfo(i,{rect:p,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:p&&Y.getCenterPos(p,this.fullLayer)}),p}clearTmpPoints(){this.tmpPoints.length=0}static getSafetySnippetRatio(t){const e=(t==null?void 0:t.parent).displayRatio||1,i=Math.ceil(t.worldScaling[0]*10)/10;let n=i;return i>=.2&&i<1?n=i*e:i<=2&&i>=1?n=i*e*1.6:i>2&&i<=3?n=i*e*1.4:i>3&&i<=4?n=i*e*.8:i>4&&(n=i*e*.6),Math.floor(n*1e3)/1e3}static getSafetySnippetFontLength(t){return Math.floor(Zt.textImageSnippetSize*3/4/t)||1}static async createLabels(t,e,i){var P;const n=[],{x:s,y:a}=i,{width:c,height:l}=(P=e.parent)==null?void 0:P.parent,h=ve(t.text),u=h.length,{fontSize:d,lineHeight:p,bold:f,textAlign:I,italic:y,fontFamily:v,verticalAlign:w,fontColor:m,fontBgColor:T,underline:N,lineThrough:C}=t,z=Zt.getSafetySnippetRatio(e)||1,L=Math.floor(d*z),j=Zt.getSafetySnippetFontLength(L);let A=0;for(let R=0;R<u;R++){const D=h[R],G=p||L*1.5;if(D){const ct=jf(D),et=[0,0],H=[0,d*1.2];w==="middle"&&(et[1]=R*d*1.2+5);const J=[0,-d*.15];et[0]=5;const Q=Math.sin(Math.PI/180*20);let V=0;const K=[];let nt=0;for(;nt<ct;){I==="left"&&(J[0]=V),nt===0&&y==="italic"&&(J[0]=J[0]-Q/2*d);const ot=D.slice(nt,nt+j),rt={anchor:[0,0],pos:J,text:ot,fontFamily:v,fontSize:L,lineHeight:G,strokeColor:m,fontWeight:f,fillColor:m,textAlign:I,fontStyle:y,scale:[1/z,1/z]},tt=new ht.Label(rt),lt=await tt.textImageReady;let gt=!0;if(lt){const Tt=lt.rect&&lt.rect[2],Xt=lt.rect&&lt.rect[3];if(Tt&&Xt){const Bt=Tt/z,jt=Xt/z;V=Bt+V,y==="italic"&&(f==="bold"?V=V-Q*d*1.2:V=V-Q*d),((J[0]+et[0]+Bt)*e.worldScaling[0]+s<=0||(J[0]+et[0])*e.worldScaling[0]+s>=c||(J[1]+et[1]+jt)*e.worldScaling[1]+a<=0||(J[1]+et[1])*e.worldScaling[1]+a>=l)&&(tt.disconnect(),gt=!1),gt&&K.push(tt)}}nt+=j}H[0]=V,y==="italic"&&(H[0]=H[0]+Q*d),A=Math.max(A,H[0]);let q=!0;if(((et[0]+H[0])*e.worldScaling[0]+s<=0||et[0]*e.worldScaling[0]+s>=c||(et[1]+H[1])*e.worldScaling[0]+a<=0||et[1]*e.worldScaling[1]+a>=l)&&(q=!1),q){if(N){const tt=Math.floor(d/10),lt={normalize:!1,pos:[0,d*1.1+tt/2],lineWidth:tt,points:[0,0,Math.ceil(H[0]),0],strokeColor:m,className:"underline"},gt=new ht.Polyline(lt);K.push(gt)}if(C){const tt={normalize:!1,pos:[0,d*1.2/2],lineWidth:Math.floor(d/10),points:[0,0,Math.ceil(H[0]),0],strokeColor:m,className:"lineThrough"},lt=new ht.Polyline(tt);K.push(lt)}const ot={pos:et,anchor:[0,0],size:H,bgcolor:T},rt=new ht.Group(ot);rt.append(...K),n.push(rt)}}}return{labels:n,maxWidth:A}}static updateNodeOpt(t){const{node:e,opt:i,vNodes:n,targetNode:s}=t,{fontBgColor:a,fontColor:c,translate:l,originPoint:h,scenePoint:u,scale:d,bold:p,italic:f,lineThrough:I,underline:y,fontSize:v,textInfos:w,zIndex:m}=i,T=s&&Qt(s)||n.get(e.name);if(!T||!e.parent)return;const C=T.opt;if(Wt(m)&&(e.setAttribute("zIndex",m),T.opt.zIndex=m),c&&C.fontColor&&(C.fontColor=c,e.children.forEach(z=>{z.tagName==="GROUP"&&z.children.forEach(L=>{L.tagName==="LABEL"?(L.setAttribute("fillColor",c),L.setAttribute("strokeColor",c)):L.tagName==="POLYLINE"&&L.setAttribute("strokeColor",c)})})),a&&C.fontBgColor&&(C.fontBgColor=a,e.children.forEach(z=>{z.tagName==="GROUP"&&z.setAttribute("bgcolor",a)})),p&&(C.bold=p),f&&(C.italic=f),Gt(I)&&(C.lineThrough=I),Gt(y)&&(C.underline=y),v&&(C.fontSize=v),h&&u&&d&&s&&C.boxPoint){const z=w==null?void 0:w.get(e.name);if(z){const{fontSize:P,boxSize:R}=z;C.boxSize=R||C.boxSize,C.fontSize=P||C.fontSize}const L=[C.boxPoint[0],C.boxPoint[1]];Ro(C.boxPoint,u,d,l);const j=[T.op[0],T.op[1]],A=[j[0]-L[0],j[1]-L[1]];T.centerPos=[T.centerPos[0]+A[0],T.centerPos[1]+A[1]]}else l&&C.boxPoint&&(C.boxPoint=[C.boxPoint[0]+l[0],C.boxPoint[1]+l[1]],T.centerPos=[T.centerPos[0]+l[0],T.centerPos[1]+l[1]]);return T&&n.setInfo(e.name,T),T==null?void 0:T.rect}static getRectFromLayer(t,e){const i=t.getElementsByName(e)[0];if(i){const n=i.getBoundingClientRect();let s={x:Math.floor(n.x),y:Math.floor(n.y),w:Math.floor(n.width+2),h:Math.floor(n.height+2)};return i.children.forEach(a=>{if(a.tagName==="GROUP"){const c=i.getBoundingClientRect();s=ut(s,{x:Math.floor(c.x),y:Math.floor(c.y),w:Math.floor(c.width+2),h:Math.floor(c.height+2)})}}),s}}};M(Zt,"textImageSnippetSize",1024*4),M(Zt,"SafeBorderPadding",30);let Ve=Zt;const he=class he extends Y{constructor(t,e){super(t);M(this,"canRotate",!1);M(this,"scaleType",at.none);M(this,"toolsType",S.PencilEraser);M(this,"serviceWork");M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"worldPosition");M(this,"worldScaling");M(this,"eraserRect");M(this,"eraserPolyline");this.serviceWork=e,this.workOptions=t.toolsOpt,this.worldPosition=this.fullLayer.worldPosition,this.worldScaling=this.fullLayer.worldScaling}combineConsume(){}consumeService(){}setWorkOptions(t){super.setWorkOptions(t)}createEraserRect(t){const e=t[0]*this.worldScaling[0]+this.worldPosition[0],i=t[1]*this.worldScaling[1]+this.worldPosition[1],{width:n,height:s}=he.eraserSizes[this.workOptions.thickness];this.eraserRect={x:e-n*.5,y:i-s*.5,w:n,h:s},this.eraserPolyline=[this.eraserRect.x,this.eraserRect.y,this.eraserRect.x+this.eraserRect.w,this.eraserRect.y+this.eraserRect.h]}computRectCenterPoints(){const t=this.tmpPoints.slice(-2);if(this.tmpPoints.length===4){const e=new k(this.tmpPoints[0],this.tmpPoints[1]),i=new k(this.tmpPoints[2],this.tmpPoints[3]),n=k.Sub(i,e).uni(),s=k.Dist(e,i),{width:a,height:c}=he.eraserSizes[this.workOptions.thickness],l=Math.min(a,c),h=Math.round(s/l);if(h>1){const u=[];for(let d=0;d<h;d++){const p=k.Mul(n,d*l);u.push(this.tmpPoints[0]+p.x,this.tmpPoints[1]+p.y)}return u.concat(t)}}return t}isNear(t,e){const i=new k(t[0],t[1]),n=new k(e[0],e[1]),{width:s,height:a}=he.eraserSizes[this.workOptions.thickness];return k.Dist(i,n)<Math.hypot(s,a)*.5}cutPolyline(t,e){let i=[e],n=0;for(;n<t.length;){const c=t[n];if(c.length<2)break;i=s(i,c),n++}return i;function s(c,l){const h=c;for(let u=0;u<c.length;u++){const d=c[u],p=d.findIndex((f,I)=>I<d.length-1?a([f,d[I+1]],[l[0],l[1]]):!1);if(p!==-1&&p>-1){const f=[],I=d.slice(0,p+1);if(k.Equals(d[p],l[0])||I.push(l[0].clone().setz(d[p].z)),I.length>1&&f.push(I),p+l.length-1<d.length-1){const y=p+l.length-1,v=d.slice(y),w=l[l.length-1];k.Equals(d[y],w)||v.unshift(w.clone().setz(d[y].z)),v.length>1&&f.push(v)}return h.splice(u,1,...f),h}}return h}function a(c,l){const h=k.Sub(c[1],c[0]),u=k.Sub(l[1],l[0]),d=k.Sub(l[0],c[0]);return Math.abs(k.Cpr(h,u))<.1&&Math.abs(k.Cpr(h,d))<.1}}isSamePoint(t,e){return t[0]===e[0]&&t[1]===e[1]}translateIntersect(t){const e=[];for(let i=0;i<t.length;i++){const n=t[i].filter((c,l,h)=>!(l>0&&this.isSamePoint(c,h[l-1]))),s=[];let a=0;for(;a<n.length;){const c=n[a],l=new k(c[0],c[1]);s.push(l),a++}e.push(s)}return e}isLineEraser(t,e){return!(t===S.Pencil&&!e)}remove(t){const{curNodeMap:e,removeIds:i,newWorkDatas:n}=t;let s;for(const[a,c]of e.entries())if(c.rect&&this.eraserRect&&this.eraserPolyline&&Le(this.eraserRect,c.rect)){const{op:l,toolsType:h}=c,u=this.isLineEraser(h,!1),d=[],p=[];for(let I=0;I<l.length;I+=3){const y=new k(l[I]*this.worldScaling[0]+this.worldPosition[0],l[I+1]*this.worldScaling[1]+this.worldPosition[1],l[I+2]);p.push(y),d.push(new F(y.x,y.y))}const f=d.length&&ft(d)||c.rect;if(Le(f,this.eraserRect)){if(p.length>1){const I=zi.polyline(p.map(y=>y.XY),this.eraserPolyline);if(I.length&&(i.add(c.name),!u)){const y=this.translateIntersect(I),v=this.cutPolyline(y,p);for(let w=0;w<v.length;w++){const m=`${a}_s_${w}`,T=[];v[w].forEach(N=>{T.push((N.x-this.worldPosition[0])/this.worldScaling[0],(N.y-this.worldPosition[1])/this.worldScaling[1],N.z)}),c.opt&&c.toolsType&&this.vNodes&&(this.vNodes.setInfo(m,{rect:f,op:T,opt:c.opt,canRotate:c.canRotate,scaleType:c.scaleType,toolsType:c.toolsType}),n.set(m,{workId:m,op:T,opt:c.opt,toolsType:c.toolsType}))}}}else i.add(c.name);s=ut(s,f)}}return i.forEach(a=>{var c;return(c=this.vNodes)==null?void 0:c.delete(a)}),s&&(s.x-=Y.SafeBorderPadding,s.y-=Y.SafeBorderPadding,s.w+=Y.SafeBorderPadding*2,s.h+=Y.SafeBorderPadding*2),s}consume(t){const{op:e}=t.data;if(!e||e.length===0)return{type:x.None,...this.baseConsumeResult};const i=this.tmpPoints.length;if(i>1&&this.isNear([e[0],e[1]],[this.tmpPoints[i-2],this.tmpPoints[i-1]]))return{type:x.None,...this.baseConsumeResult};i===4&&(this.tmpPoints.shift(),this.tmpPoints.shift()),this.tmpPoints.push(e[0],e[1]);const n=this.computRectCenterPoints();let s;const a=new Set,c=new Map;if(!this.vNodes)return{type:x.None,...this.baseConsumeResult};this.vNodes.setTarget();const l=this.getUnLockNodeMap(this.vNodes.getLastTarget());for(let h=0;h<n.length-1;h+=2){this.createEraserRect(n.slice(h,h+2));const u=this.remove({curNodeMap:l,removeIds:a,newWorkDatas:c});s=ut(s,u)}if(this.vNodes.deleteLastTarget(),s&&a.size){for(const h of c.keys())a.has(h)&&c.delete(h);return{type:x.RemoveNode,rect:s,removeIds:[...a],newWorkDatas:c}}return{type:x.None,...this.baseConsumeResult}}consumeAll(t){return this.consume(t)}clearTmpPoints(){this.tmpPoints.length=0}getUnLockNodeMap(t){var e;if(this.serviceWork){const i=Qt(t),n=this.serviceWork.selectorWorkShapes,s=this.serviceWork.workShapes;for(const a of n.values())if((e=a.selectIds)!=null&&e.length)for(const c of a.selectIds)i.delete(c);for(const a of s.keys())i.delete(a);return i}return t}};M(he,"eraserSizes",Object.freeze([Object.freeze({width:18,height:26}),Object.freeze({width:26,height:34}),Object.freeze({width:34,height:50})]));let Ze=he;function gs(r){switch(r){case S.Arrow:return cs;case S.Pencil:return ss;case S.Straight:return fs;case S.Ellipse:return ls;case S.Polygon:case S.Triangle:return ds;case S.Star:case S.Rhombus:return us;case S.Rectangle:return hs;case S.SpeechBalloon:return ps;case S.Text:return Ve;case S.LaserPen:return ns;case S.Eraser:return Fe;case S.PencilEraser:return Ze;case S.Selector:return Qe;case S.Image:return xe}}function Ms(r,o){const{toolsType:t,...e}=r;switch(t){case S.Arrow:return new cs(e);case S.Pencil:return new ss(e);case S.Straight:return new fs(e);case S.Ellipse:return new ls(e);case S.Polygon:case S.Triangle:return new ds(e);case S.Star:case S.Rhombus:return new us(e);case S.Rectangle:return new hs(e);case S.SpeechBalloon:return new ps(e);case S.Text:return new Ve(e);case S.LaserPen:return new ns(e);case S.Eraser:return new Fe(e,o);case S.PencilEraser:return new Ze(e,o);case S.Selector:return e.vNodes?new Qe({...e,vNodes:e.vNodes,drawLayer:e.fullLayer}):void 0;case S.Image:return new xe(e);default:return}}function ys(r){const o=[],t=["PATH","SPRITE","POLYLINE","RECT","ELLIPSE","LABEL"];for(const e of r){if(e.tagName==="GROUP"&&e.children.length)return ys(e.children);e.tagName&&t.includes(e.tagName)&&o.push(e)}return o}function ut(r,o){if(r&&o){const t=Math.min(r.x,o.x),e=Math.min(r.y,o.y),i=Math.max(r.x+r.w,o.x+o.w),n=Math.max(r.y+r.h,o.y+o.h),s=i-t,a=n-e;return{x:t,y:e,w:s,h:a}}return o||r}function ws(r,o){if(r&&o){const t=Math.min(r.originX,o.originX),e=Math.min(r.originY,o.originY),i=Math.max(r.originX+r.width,o.originX+o.width),n=Math.max(r.originY+r.height,o.originY+o.height),s=i-t,a=n-e;return{originX:t,originY:e,width:s,height:a}}return o||r}function ft(r,o=0){const t={x:0,y:0,w:0,h:0};let e=1/0,i=1/0,n=-1/0,s=-1/0;return r.forEach(a=>{const[c,l]=a.XY;e=Math.min(e,c-o),i=Math.min(i,l-o),n=Math.max(n,c+o),s=Math.max(s,l+o)}),t.x=e,t.y=i,t.w=n-e,t.h=s-i,t}function Le(r,o){return!(r.x+r.w<o.x||r.x>o.x+o.w||r.y+r.h<o.y||r.y>o.y+o.h)}function Sf(r,o){return{x:r.x+o[0],y:r.y+o[1],w:r.w,h:r.h}}function Cf(r,o){const t=new k(r.x,r.y),e=new k(r.x+r.w,r.y),i=new k(r.x+r.w,r.y+r.h),n=new k(r.x,r.y+r.h),s=new k(r.x+r.w/2,r.y+r.h/2),a=Math.PI*o/180,c=k.RotWith(t,s,a),l=k.RotWith(e,s,a),h=k.RotWith(i,s,a),u=k.RotWith(n,s,a);return[c,l,h,u]}function ms(r,o){const t=Cf(r,o);return ft(t)}function kf(r,o,t){const e=new k(o[0],o[1]);for(let i=0;i<r.length;i+=3){const n=new k(r[i],r[i+1]),s=Math.PI*t/180,a=k.RotWith(n,e,s);r[i]=a.x,r[i+1]=a.y}}function Ro(r,o,t,e=[0,0]){const i=new k(o[0],o[1]);for(let n=0;n<r.length;n+=3){const s=new k(r[n],r[n+1]),a=new k(t[0],t[1]),c=k.ScaleWOrigin(s,a,i);r[n]=c.x+e[0],r[n+1]=c.y+e[1]}}function Is(r,o){return r[0]>=o.x&&r[0]<=o.x+o.w&&r[1]>=o.y&&r[1]<=o.y+o.h}function vs(r,o){const t=r<=o?1:r/o,e=o<=r?1:o/r;return[t,e]}function zf(r){for(const o of r)if(isNaN(o)||o===1/0||o===-1/0)return!1;return!0}const xf=r=>{if(r.tagName==="GROUP"){const o=Object.getOwnPropertySymbols(r).find(t=>t.toString()==="Symbol(sealed)");if(o&&r[o])return!0}return!1},Lf=r=>!r.isHid;function ne(r){return`${Ge(r.x)},${Ge(r.y)} `}function re(r,o){return`${Ge((r.x+o.x)/2)},${Ge((r.y+o.y)/2)} `}function Ge(r){return+r.toFixed(4)}const fe=(r,o)=>new Promise(function(t){window.requestIdleCallback?requestIdleCallback(()=>{t(1)},{timeout:o}):setTimeout(()=>{t(2)},o)}).then(function(){r()},()=>{r()}),Jt=r=>{const o=(r==null?void 0:r.webkitBackingStorePixelRatio)||(r==null?void 0:r.mozBackingStorePixelRatio)||(r==null?void 0:r.msBackingStorePixelRatio)||(r==null?void 0:r.oBackingStorePixelRatio)||(r==null?void 0:r.backingStorePixelRatio)||1;return Math.max(1,(window.devicePixelRatio||1)/o)},bf=(r,o)=>r.x+r.w<o.x||r.x>o.x+o.w||r.y+r.h<o.y||r.y>o.y+o.h?ke.outside:r.x>=o.x&&r.y>=o.y&&r.x+r.w<=o.x+o.w&&r.y+r.h<=o.y+o.h?ke.inside:ke.intersect;function jf(r){let o=0;for(let t=0;t<r.length;t++){const e=r.charCodeAt(t);e>=1&&e<=126||65376<=e&&e<=65439?o++:o+=2}return o}class Df{constructor(o,t){M(this,"plugin");M(this,"uid");M(this,"control");this.control=o,this.plugin=t,this.uid=t.displayer.uid}getNamespaceData(){var o;return it.toJS((o=this.plugin)==null?void 0:o.attributes[this.namespace])||{}}getUidFromKey(o){return o.split(Ot).length===2&&o.split(Ot)[0]||this.uid}isLocalId(o){return o.split(Ot).length===1}getLocalId(o){return o.split(Ot)[1]}isSelector(o){return this.getLocalId(o)===B}}const $t=class $t extends Df{constructor(t,e,i){super(t,e);M(this,"namespace");M(this,"serviceStorage",{});M(this,"storage",{});M(this,"stateDisposer");M(this,"asyncClockState",!1);$t.syncInterval=(i||$t.syncInterval)*.5,this.namespace=$t.namespace,this.serviceStorage=this.getNamespaceData(),this.storage=E.cloneDeep(this.serviceStorage)}getViewIdBySecenPath(t){const e=this.getNamespaceData();for(const[i,n]of Object.entries(e))if(n){for(const s of Object.keys(n))if(s===t)return i}}getScenePathData(t){const e=this.getNamespaceData();for(const i of Object.values(e))if(i){for(const n of Object.keys(i))if(n===t)return E.cloneDeep(i[n])}}getStorageData(t,e){const i=this.getNamespaceData();return i&&i[t]&&E.cloneDeep(i[t][e])||void 0}hasSelector(t,e){const i=this.storage&&this.storage[t]&&this.storage[t][e];return!!(i&&Object.keys(i).find(n=>this.isOwn(n)&&this.getLocalId(n)===B))}addStorageStateListener(t){this.stateDisposer=it.autorun(async()=>{var c;const e=this.getNamespaceData(),{diffView:i,diffScenePath:n,diffData:s}=this.diffFunByView(this.serviceStorage,e);this.serviceStorage=e;const a={};if(Object.keys(i).length>0){a.diffView=i;for(const[l,h]of Object.entries(i)){if(h&&h.newValue===void 0&&this.storage[l]){delete this.storage[l];continue}if(h&&h.newValue){this.storage[l]=E.cloneDeep(h.newValue);continue}}}if(Object.keys(n).length>0){a.diffScenePath=n;for(const[l,h]of Object.entries(n))if(h){const{viewId:u,newValue:d}=h;let p=this.storage[u];if(p&&p[l]&&d===void 0){delete p[l];continue}if(d&&u){p===void 0&&(this.storage[u]={},p=this.storage[u]),p[l]=E.cloneDeep(d);continue}}}if(Object.keys(s).length>0){a.diffData=s;for(const[l,h]of Object.entries(s))if(h){const{viewId:u,scenePath:d,newValue:p}=h;if(u&&d){let f=this.storage[u],I=(c=this.storage[u])==null?void 0:c[d];if(f||(this.storage[u]={},f=this.storage[u],f[d]={},I=f[d]),I){if(I[l]&&p===void 0){delete I[l];continue}if(p&&u){I[l]=E.cloneDeep(p);continue}}}}}Object.keys(a).length>0&&t(a)})}removeStorageStateListener(){this.stateDisposer&&this.stateDisposer()}diffFunByView(t,e){const i=Ct(t),n=Ct(e),s={},a={},c={};for(const l of n)if(!i.includes(l)||t[l]===void 0){s[l]={newValue:e[l],oldValue:void 0};continue}for(const l of i){if(E.isEqual(t[l],e[l]))continue;if(!n.includes(l)||e[l]===void 0){s[l]={newValue:void 0,oldValue:t[l]};continue}const h=this.diffFunByScenePath(t[l],e[l],l);Object.assign(a,h.diffScenePath),Object.assign(c,h.diffData)}return{diffData:c,diffScenePath:a,diffView:s}}diffFunByScenePath(t,e,i){const n=Ct(t),s=Ct(e),a={},c={};for(const l of s)if(!n.includes(l)||t[l]===void 0){a[l]={newValue:e[l],oldValue:void 0,viewId:i};continue}for(const l of n){if(E.isEqual(t[l],e[l]))continue;if(!s.includes(l)||e[l]===void 0){a[l]={newValue:void 0,oldValue:t[l],viewId:i};continue}const h=this.diffFunByKeys(t[l],e[l],l,i);Object.assign(c,h)}return{diffScenePath:a,diffData:c}}diffFunByKeys(t,e,i,n){const s=Ct(t),a=Ct(e),c={};for(const l of a)(!s.includes(l)||t[l]===void 0)&&(c[l]={oldValue:void 0,newValue:e[l],viewId:n,scenePath:i});for(const l of s)if(!E.isEqual(t[l],e[l])){if(!a.includes(l)||e[l]===void 0){c[l]={newValue:void 0,oldValue:t[l],viewId:n,scenePath:i};continue}a.includes(l)&&(c[l]={oldValue:t[l],newValue:e[l],viewId:n,scenePath:i})}return c}transformKey(t){return this.uid+Ot+t}isOwn(t){return t.split(Ot)[0]===this.uid}dispatch(t){const{type:e,workId:i,ops:n,index:s,opt:a,toolsType:c,removeIds:l,updateNodeOpt:h,op:u,selectIds:d,isSync:p,scenePath:f,viewId:I}=t;if(I)switch(e){case x.Clear:const y={};f&&this.storage[I]&&this.storage[I][f]?(delete this.storage[I][f],this.setState(y,{isSync:p,viewId:I,scenePath:f})):this.storage[I]&&(delete this.storage[I],this.setState(y,{isSync:p,viewId:I,scenePath:""}));break;case x.CreateWork:if(f&&i&&c&&a){const N=this.isLocalId(i.toString())?this.transformKey(i):i;this.updateValue(N.toString(),{type:x.CreateWork,workId:i,toolsType:c,opt:a},{isSync:p,viewId:I,scenePath:f})}break;case x.DrawWork:if(f&&i&&typeof s=="number"&&(u!=null&&u.length)){const N=this.isLocalId(i.toString())?this.transformKey(i):i,C=this.storage[I]&&this.storage[I][f]&&this.storage[I][f][N]||void 0;if(C!=null&&C.ops||(C==null?void 0:C.type)===x.FullWork)return;const z=s?((C==null?void 0:C.op)||[]).slice(0,s).concat(u):u||(C==null?void 0:C.op),L=c||(C==null?void 0:C.toolsType),j=a||(C==null?void 0:C.opt),A=h||(C==null?void 0:C.updateNodeOpt);i&&L&&j&&z&&this.updateValue(N.toString(),{...C,type:x.DrawWork,workId:i,updateNodeOpt:A,toolsType:L,opt:j,op:z,index:s},{isSync:p,viewId:I,scenePath:f})}break;case x.FullWork:if(f&&i){const N=this.isLocalId(i.toString())?this.transformKey(i):i,C=this.storage[I]&&this.storage[I][f]&&this.storage[I][f][N]||void 0,z=h||(C==null?void 0:C.updateNodeOpt),L=c||(C==null?void 0:C.toolsType),j=a||(C==null?void 0:C.opt),A=n||(C==null?void 0:C.ops);L&&j&&this.updateValue(N.toString(),{type:x.FullWork,updateNodeOpt:z,workId:N,toolsType:L,opt:j,ops:A},{isSync:p,viewId:I,scenePath:f})}break;case x.RemoveNode:if(f&&(l!=null&&l.length)){const N=l.map(C=>this.isLocalId(C+"")?this.transformKey(C):C);this.storage[I]&&this.storage[I][f]&&Object.keys(this.storage[I][f]).map(C=>{N!=null&&N.includes(C)&&this.updateValue(C,void 0,{isSync:p,viewId:I,scenePath:f})})}break;case x.UpdateNode:if(f&&i&&(h||n||a)){const N=this.isLocalId(i.toString())?this.transformKey(i):i,C=this.storage[I]&&this.storage[I][f]&&this.storage[I][f][N]||void 0;C&&(C.updateNodeOpt=h,(n||u)&&(C.ops=n,C.op=u),a&&(C.opt=a),C.type=x.FullWork,this.updateValue(N.toString(),C,{isSync:p,viewId:I,scenePath:f}))}break;case x.Select:if(!f)return;let v;d!=null&&d.length&&(v=d.map(N=>this.isLocalId(N+"")?this.transformKey(N):N));const w=this.transformKey(B),m=this.storage[I]&&this.storage[I][f]&&this.storage[I][f][w]||void 0,T=a||(m==null?void 0:m.opt);v&&this.checkOtherSelector(w,v,{isSync:p,viewId:I,scenePath:f}),this.updateValue(w,v&&{type:x.Select,toolsType:S.Selector,opt:T,selectIds:v},{isSync:p,viewId:I,scenePath:f});break}}checkOtherSelector(t,e,i){const{viewId:n,scenePath:s}=i;for(const a of Object.keys(this.storage[n][s]))if(a!==t&&this.getLocalId(a)===B){const c=this.storage[n][s][a];if(c&&c.selectIds){const l=c.selectIds.filter(h=>!e.includes(h));l.length>0&&(c.selectIds=l),this.updateValue(a,l.length&&c||void 0,i)}}}setState(t,e){const{viewId:i,scenePath:n}=e,s=Ct(t);for(let a=0;a<s.length;a++){const c=s[a],l=t[c];typeof l<"u"?(this.storage[i]||(this.storage[i]={}),this.storage[i][n]||(this.storage[i][n]={}),this.storage[i][n][c]=l):delete this.storage[i][n][c]}this.runSyncService(e)}updateValue(t,e,i){const{viewId:n,scenePath:s}=i;e===void 0?delete this.storage[n][s][t]:(this.storage[n]||(this.storage[n]={}),this.storage[n][s]||(this.storage[n][s]={}),this.storage[n][s][t]=e),this.runSyncService(i)}runSyncService(t){this.asyncClockState||(this.asyncClockState=!0,setTimeout(()=>{t.isSync?(this.asyncClockState=!1,this.syncSerivice(t.isAfterUpdate)):fe(()=>{this.asyncClockState=!1,this.syncSerivice(t.isAfterUpdate)},$t.syncInterval)},t!=null&&t.isSync?0:$t.syncInterval))}syncSerivice(t=!1){const e=Ct(this.serviceStorage),i=Ct(this.storage),n=new Map;for(const s of e){if(!i.includes(s)){n.set(s,void 0);continue}E.isEqual(this.serviceStorage[s],this.storage[s])||this.syncViewData(s,t)}for(const s of i)e.includes(s)||n.set(s,this.storage[s]);if(n.size>5)this.syncStorageView(this.storage,t);else for(const[s,a]of n.entries())this.syncUpdataView(s,a,t)}syncViewData(t,e=!1){const i=Ct(this.serviceStorage[t]),n=Ct(this.storage[t]),s=new Map;for(const a of i){if(!n.includes(a)){s.set(a,void 0);continue}E.isEqual(this.serviceStorage[t][a],this.storage[t][a])||this.syncScenePathData(t,a,e)}for(const a of n)i.includes(a)||s.set(a,this.storage[t][a]);if(s.size>5)this.syncStorageScenePath(t,this.storage[t],e);else for(const[a,c]of s.entries())this.syncUpdataScenePath(t,a,c,e)}syncScenePathData(t,e,i=!1){const n=Ct(this.serviceStorage[t][e]),s=Ct(this.storage[t][e]),a=new Map;for(const c of n){if(!s.includes(c)){a.set(c,void 0);continue}E.isEqual(this.serviceStorage[t][e][c],this.storage[t][e][c])||a.set(c,this.storage[t][e][c])}for(const c of s)n.includes(c)||a.set(c,this.storage[t][e][c]);if(a.size>5)this.syncStorageKey(t,e,this.storage[t][e],i);else for(const[c,l]of a.entries())this.syncUpdataKey(t,e,c,l,i)}syncUpdataView(t,e,i=!1){var s;Object.keys(this.serviceStorage).length?(i||(e===void 0?delete this.serviceStorage[t]:this.serviceStorage[t]=E.cloneDeep(e)),(s=this.plugin)==null||s.updateAttributes([this.namespace,t],e)):this.syncStorageView(this.storage,i)}syncStorageView(t,e=!1){var i;e||t&&(this.serviceStorage=E.cloneDeep(t)),(i=this.plugin)==null||i.updateAttributes([this.namespace],t)}syncUpdataScenePath(t,e,i,n=!1){var a;Object.keys(this.serviceStorage[t]).length?(n||(i===void 0?delete this.serviceStorage[t][e]:this.serviceStorage[t][e]=i),(a=this.plugin)==null||a.updateAttributes([this.namespace,t,e],i)):this.syncStorageScenePath(t,this.storage[t],n)}syncStorageScenePath(t,e,i=!1){var n;i||e&&(this.serviceStorage[t]=e),(n=this.plugin)==null||n.updateAttributes([this.namespace,t],e)}syncUpdataKey(t,e,i,n,s=!1){var c;Object.keys(this.serviceStorage[t][e]).length?(s||(n===void 0?delete this.serviceStorage[t][e][i]:this.serviceStorage[t][e][i]=n),(c=this.plugin)==null||c.updateAttributes([this.namespace,t,e,i],n)):this.syncStorageKey(t,e,this.storage[t][e],s)}syncStorageKey(t,e,i,n=!1){var s;n||(this.serviceStorage[t][e]=i),(s=this.plugin)==null||s.updateAttributes([this.namespace,t,e],i)}keyTransformWorkId(t){const e=t.split(Ot);return e.length===2?e[1]:t}destroy(){this.removeStorageStateListener(),this.serviceStorage={},this.storage={}}};M($t,"namespace","PluginState"),M($t,"syncInterval",500);let vo=$t;class Pf{constructor(){M(this,"roomMembers",[]);M(this,"onChangeHooks",new Set)}setRoomMembers(o){this.executChangeUidHook(this.roomMembers,o),this.roomMembers=o}executChangeUidHook(o,t){const e={online:t.map(i=>{var n;return((n=i.payload)==null?void 0:n.uid)||i.session}),offline:o.map(i=>{var n;return((n=i.payload)==null?void 0:n.uid)||i.session})};this.onChangeHooks.forEach(i=>i(e))}getRoomMember(o){return this.roomMembers.find(t=>{var e;return((e=t.payload)==null?void 0:e.uid)===o})}isOnLine(o){return!this.getRoomMember(o)}onUidChangeHook(o){this.onChangeHooks.add(o)}destroy(){this.onChangeHooks.clear()}}var Ut=(r=>(r[r.Text=1]="Text",r[r.Shape=2]="Shape",r))(Ut||{});const Ef="cursorhover",Af=20,wt="mainView",St=class St{createProxy(o){const t=new Proxy(o,{get(e,i,n){const s=St.interceptors.hasOwnProperty(i)?St.interceptors:e;return Reflect.get(s,i,n)}});return St.proxyToRaw.set(t,o),t}};M(St,"proxyToRaw",new WeakMap),M(St,"interceptors",{entries(...o){return St.proxyToRaw.get(this).entries(...o)},forEach(...o){return St.proxyToRaw.get(this).forEach(...o)},size(){return St.proxyToRaw.get(this).size},get(o){return St.proxyToRaw.get(this).get(o)},set(o,t){return St.proxyToRaw.get(this).set(o,t)},delete(o,t){return St.proxyToRaw.get(this).delete(o)},clear(){return St.proxyToRaw.get(this).clear()}});let _t=St;class Of{constructor(o){M(this,"internalMsgEmitter");M(this,"control");M(this,"editors");M(this,"activeId");M(this,"proxyMap");M(this,"taskqueue",new Map);const{control:t,internalMsgEmitter:e}=o;this.control=t,this.internalMsgEmitter=e;const i=new Map;this.proxyMap=new _t;const n=this,s=_t.interceptors.set;_t.interceptors.set=function(c,l){return n.interceptors.set(c,l),s.call(this,c,l)};const a=_t.interceptors.delete;_t.interceptors.delete=function(c,l){return n.interceptors.delete(c,l),a.call(this,c)},this.editors=this.proxyMap.createProxy(i)}get collector(){return this.control.collector}filterEditor(o){const t=new Map;return this.editors.forEach((e,i)=>{e.viewId===o&&t.set(i,e)}),t}get interceptors(){return{set:(o,t)=>{var p,f,I,y,v,w,m,T;if(!this.collector)return!0;const{viewId:e,scenePath:i,canSync:n,canWorker:s,type:a,opt:c,dataType:l}=t;if(!s&&!n)return!0;const u=((p=this.collector)==null?void 0:p.isLocalId(o))?(f=this.collector)==null?void 0:f.transformKey(o):o,d=((I=this.collector)==null?void 0:I.storage[e])&&this.collector.storage[e][i]&&this.collector.storage[e][i][u]||void 0;d?d.toolsType===S.Text&&(s&&(this.control.worker.queryTaskBatchData({workId:o,msgType:x.UpdateNode}).forEach(N=>{var C;(C=this.control.worker)==null||C.taskBatchData.delete(N)}),(m=this.control.worker)==null||m.taskBatchData.add({workId:o,msgType:x.UpdateNode,dataType:l||U.Local,toolsType:S.Text,opt:c,viewId:e,scenePath:i,willRefresh:!0}),(T=this.control.worker)==null||T.runAnimation()),n&&fe(()=>{var N;(N=this.collector)==null||N.dispatch({type:x.UpdateNode,workId:o,toolsType:S.Text,opt:c,viewId:e,scenePath:i})},this.control.worker.maxLastSyncTime)):a===Ut.Text&&(n&&((y=this.collector)==null||y.dispatch({type:c.text&&x.FullWork||x.CreateWork,workId:o,toolsType:S.Text,opt:c,isSync:!0,viewId:e,scenePath:i})),s&&((v=this.control.worker)==null||v.taskBatchData.add({workId:o,msgType:c.text&&x.FullWork||x.CreateWork,dataType:l||U.Local,toolsType:S.Text,opt:c,viewId:e,scenePath:i,willRefresh:!0}),(w=this.control.worker)==null||w.runAnimation()))},delete:o=>{var a,c;if(!this.collector)return!0;const t=this.editors.get(o);if(!t)return!0;const{viewId:e,scenePath:i,canSync:n,canWorker:s}=t;if(!s&&!n)return!0;s&&((a=this.control.worker)==null||a.taskBatchData.add({workId:o,toolsType:S.Text,msgType:x.RemoveNode,dataType:U.Local,viewId:e,scenePath:i,willRefresh:!0}),(c=this.control.worker)==null||c.runAnimation()),n&&fe(()=>{var l;(l=this.collector)==null||l.dispatch({type:x.RemoveNode,removeIds:[o],toolsType:S.Text,viewId:e,scenePath:i})},this.control.worker.maxLastSyncTime)},clear(){return!0}}}computeTextActive(o,t){var n,s,a,c;const e=(n=this.control.viewContainerManager)==null?void 0:n.transformToScenePoint(o,t),i=(s=this.control.viewContainerManager)==null?void 0:s.getCurScenePath(t);t&&i&&((a=this.control.worker)==null||a.taskBatchData.add({msgType:x.GetTextActive,dataType:U.Local,op:e,viewId:t,scenePath:i}),(c=this.control.worker)==null||c.runAnimation())}checkEmptyTextBlur(){var t;let o=this.activeId;for(const[e,i]of this.editors.entries())if(i.opt.uid&&i.opt.uid===((t=this.collector)==null?void 0:t.uid)){o=e;break}if(o){const e=this.editors.get(o);(e==null?void 0:e.opt.text)&&(e==null?void 0:e.opt.text.replace(/\s*,/g,""))?this.unActive(o):this.delete(o,!0,!0)}}onCameraChange(o,t){var e,i;for(const[n,s]of this.editors.entries())if(s.viewId===t){const{boxPoint:a,boxSize:c}=s.opt,l=a&&((e=this.control.viewContainerManager)==null?void 0:e.transformToOriginPoint(a,s.viewId)),h=(i=this.control.viewContainerManager)==null?void 0:i.getCurScenePath(t);if(h&&t){const u={x:l&&l[0]||0,y:l&&l[1]||0,w:c&&c[0]||0,h:c&&c[1]||0,opt:s.opt,scale:o.scale,type:Ut.Text,viewId:t,scenePath:h,canWorker:!1,canSync:!1};this.editors.set(n,u),this.control.viewContainerManager.setActiveTextEditor(t,this.activeId)}}}onServiceDerive(o){var f,I;const{workId:t,opt:e,msgType:i,viewId:n,scenePath:s,dataType:a}=o;if(!t||!n||!s)return;const c=t.toString();if(i===x.RemoveNode){this.delete(c,!0,!0);return}const{boxPoint:l,boxSize:h}=e,u=l&&((f=this.control.viewContainerManager)==null?void 0:f.transformToOriginPoint(l,n)),d=this.control.viewContainerManager.getView(n),p={x:u&&u[0]||0,y:u&&u[1]||0,w:h&&h[0]||0,h:h&&h[1]||0,opt:e,type:Ut.Text,canWorker:!0,canSync:!1,dataType:a,scale:((I=d==null?void 0:d.cameraOpt)==null?void 0:I.scale)||1,viewId:n,scenePath:s};this.editors.set(c,p),a===U.Service&&e.workState===b.Done&&this.activeId===c&&(this.activeId=void 0),this.control.viewContainerManager.setActiveTextEditor(n,this.activeId)}updateForViewEdited(o,t){var i;this.editors.set(o,t);const e=(i=this.taskqueue.get(o))==null?void 0:i.resolve;e&&e(t)}active(o){var e;const t=this.editors.get(o);t&&t.viewId&&(t.opt.workState=b.Start,t.opt.uid=(e=this.collector)==null?void 0:e.uid,this.activeId=o,t.canWorker=!0,t.canSync=!0,this.editors.set(o,t),this.control.viewContainerManager.setActiveTextEditor(t.viewId,this.activeId))}unActive(o){const t=this.editors.get(o);t&&t.viewId&&(t.opt.workState=b.Done,t.opt.uid=void 0,t.canWorker=!0,t.canSync=!0,this.editors.set(o,t),this.activeId=void 0,this.control.viewContainerManager.setActiveTextEditor(t.viewId,this.activeId))}createTextForMasterController(o,t){var s;const{workId:e,isActive:i,...n}=o;t&&this.internalMsgEmitter.emit("addUndoTicker",t,n.viewId),n.opt.uid=(s=this.collector)==null?void 0:s.uid,i&&(this.activeId=e),n.dataType=U.Local,n.canWorker=!0,n.canSync=!0,this.editors.set(e,n),this.control.viewContainerManager.setActiveTextEditor(n.viewId,this.activeId)}updateTextForMasterController(o,t){var s;const{workId:e,...i}=o;t&&this.internalMsgEmitter.emit("addUndoTicker",t,i.viewId);const n=this.editors.get(e)||{};i.opt&&(i.opt.uid=(s=this.collector)==null?void 0:s.uid),i.dataType=U.Local,this.editors.set(e,{...n,...i}),this.control.viewContainerManager.setActiveTextEditor(i.viewId,this.activeId)}async updateTextControllerWithEffectAsync(o,t){var h;const{workId:e,...i}=o;t&&this.internalMsgEmitter.emit("addUndoTicker",t,i.viewId);const n=this.editors.get(e)||{};i.opt&&(i.opt.uid=(h=this.collector)==null?void 0:h.uid),i.dataType=U.Local;const s={...n,...i};if(this.editors.set(e,s),this.control.viewContainerManager.setActiveTextEditor(i.viewId,this.activeId),this.taskqueue.has(e)){const u=this.taskqueue.get(e);return u&&(u.clocker&&clearTimeout(u.clocker),this.taskqueue.delete(e)),await this.updateTextControllerWithEffectAsync(o)}const a=setTimeout(()=>{var d;const u=(d=this.taskqueue.get(e))==null?void 0:d.resolve;u&&u(s)},50),c=await new Promise(u=>{this.taskqueue.set(e,{resolve:u,clocker:a})}),l=this.taskqueue.get(e);return l&&(l.clocker&&clearTimeout(l.clocker),this.taskqueue.delete(e)),c}updateTextForWorker(o,t){const{workId:e,isActive:i,...n}=o,a={...this.editors.get(e)||{},...n};if(i){a.canWorker=!1,a.canSync=!1,this.editors.set(e,a),this.active(e);return}this.editors.set(e,a),this.control.viewContainerManager.setActiveTextEditor(n.viewId,this.activeId),t&&this.internalMsgEmitter.emit("addUndoTicker",t,n.viewId)}get(o){return this.editors.get(o)}delete(o,t,e){const i=this.editors.get(o);if(i){const n=i.viewId;i.canSync=t,i.canWorker=e,this.editors.delete(o),this.activeId===o&&(this.activeId=void 0),this.control.viewContainerManager.setActiveTextEditor(n,this.activeId)}}deleteBatch(o,t,e){const i=new Set;for(const n of o){const s=this.editors.get(n);if(s){const a=s.viewId;s.canSync=t,s.canWorker=e,this.editors.delete(n),this.activeId===n&&(this.activeId=void 0),i.add(a)}}for(const n of i)this.control.viewContainerManager.setActiveTextEditor(n,this.activeId)}clear(o,t){this.editors.forEach((e,i)=>{e.viewId===o&&(t&&(e.canSync=!1),e.canWorker=!1,this.editors.delete(i))}),this.activeId=void 0,this.control.viewContainerManager.setActiveTextEditor(o,this.activeId)}destory(){this.editors.clear(),this.activeId=void 0}}class Rf{constructor(o){M(this,"expirationTime",xt.cursor.expirationTime);M(this,"internalMsgEmitter");M(this,"control");M(this,"eventName","applianc-cursor");M(this,"displayer");M(this,"roomMember");M(this,"animationId");M(this,"maxLastSyncTime",xt.syncOpt.interval);M(this,"willSendEventWorkers",[]);M(this,"willConsumeEventWorkers",new Map);M(this,"sendEventTimerId");M(this,"animationDrawWorkers",new Map);M(this,"animationEventWorkers",new Map);M(this,"cursorInfoMap",new Map);M(this,"doneRenderCursorInfoMap",new Map);M(this,"eventCollector");var i,n;const{control:t,internalMsgEmitter:e}=o;this.internalMsgEmitter=e,this.control=t,this.roomMember=t.roomMember,this.maxLastSyncTime=((n=(i=this.control.pluginOptions)==null?void 0:i.syncOpt)==null?void 0:n.interval)||this.maxLastSyncTime}activeCollector(){this.control.plugin&&(this.displayer=this.control.room||this.control.play,this.displayer.addMagixEventListener(this.eventName,this.mainMagixEventListener.bind(this)))}mainMagixEventListener(o){var a;const{event:t,payload:e}=o;if(t!==this.eventName)return;const{uid:i,op:n,type:s}=e;if(((a=this.control.collector)==null?void 0:a.uid)!==i&&s===Ce.Cursor&&(n!=null&&n.length)){const c=this.willConsumeEventWorkers.get(i)||[];for(const l of n){const{viewId:h}=l;E.isNumber(l.consumPoint[0])&&E.isNumber(l.consumPoint[1])&&(l.consumPoint=this.control.viewContainerManager.transformToOriginPoint(l.consumPoint,h)),c.unshift({...l,timestamp:Date.now()})}this.willConsumeEventWorkers.set(i,c),this.runAnimation()}}onFocusViewChange(){this.checkDrawWorks(),this.runAnimation()}updateRoomMembers(o){const{offline:t}=o;for(const e of this.cursorInfoMap.keys())e&&t.includes(e)&&this.cursorInfoMap.delete(e)}getKey(o,t){return`${o}${Ot}${t}`}getUidAndviewId(o){const[t,e]=o.split(Ot);return{uid:t,viewId:e}}runAnimation(){this.animationId||(this.animationId=requestAnimationFrame(this.animationCursor.bind(this)))}checkDrawWorks(){var t;const o=this.control.viewContainerManager.focuedViewId;for(const[e,i]of this.animationDrawWorkers.entries()){const{viewId:n,uid:s}=this.getUidAndviewId(e);s!==((t=this.control.collector)==null?void 0:t.uid)&&n!==o&&i.workState===b.Done&&(i.consumPoint=[void 0,void 0])}}animationCursor(){this.animationId=void 0;const o=Date.now();for(const[e,i]of this.animationDrawWorkers.entries()){const{uid:n,viewId:s}=this.getUidAndviewId(e),a=this.roomMember.getRoomMember(n);if(!a){this.animationDrawWorkers.delete(e);continue}const{consumPoint:c,timestamp:l,workState:h}=i,u=this.cursorInfoMap.get(s)||new Map;c&&E.isNumber(c[0])&&E.isNumber(c[1])&&l+this.expirationTime>o?u.set(a.memberId,{x:c[0],y:c[1],roomMember:a,timestamp:l,type:1,workState:h}):u.delete(a.memberId),u.size?this.cursorInfoMap.set(s,u):this.cursorInfoMap.delete(s),this.animationDrawWorkers.delete(e)}const t=new Set;for(const[e,i]of this.cursorInfoMap.entries())if(i)for(const[n,s]of i.entries())s.type===1&&s.workState!==b.Done&&t.add(n);else this.cursorInfoMap.delete(e);for(const[e,i]of this.willConsumeEventWorkers.entries()){const n=this.roomMember.getRoomMember(e);if(n!=null&&n.memberId&&!t.has(n.memberId)){const s=i.pop();s?this.animationEventWorkers.set(e,s):this.willConsumeEventWorkers.delete(e)}}for(const[e,i]of this.animationEventWorkers.entries()){const n=this.roomMember.getRoomMember(e);if(!n){this.animationEventWorkers.delete(e);continue}const{viewId:s,consumPoint:a,timestamp:c}=i,l=this.cursorInfoMap.get(s)||new Map;a&&E.isNumber(a[0])&&E.isNumber(a[1])&&c+this.expirationTime>o?l.set(n.memberId,{x:a[0],y:a[1],roomMember:n,timestamp:c,type:0}):l.delete(n.memberId),l.size?this.cursorInfoMap.set(s,l):this.cursorInfoMap.delete(s),this.animationEventWorkers.delete(e)}for(const e of this.doneRenderCursorInfoMap.keys())this.cursorInfoMap.has(e)||(this.doneRenderCursorInfoMap.delete(e),this.internalMsgEmitter.emit([Z.Cursor,e],[]));for(const[e,i]of this.cursorInfoMap.entries())if(i!=null&&i.size){const n=[];for(const[a,c]of i.entries()){const{timestamp:l,...h}=c;l+this.expirationTime>o?n.push(h):(i.delete(a),i.size===0&&(this.cursorInfoMap.delete(e),this.doneRenderCursorInfoMap.delete(e),this.internalMsgEmitter.emit([Z.Cursor,e],[])))}const s=this.doneRenderCursorInfoMap.get(e);E.isEqual(s,n)||(this.doneRenderCursorInfoMap.set(e,n),this.internalMsgEmitter.emit([Z.Cursor,e],n))}else this.cursorInfoMap.delete(e),this.doneRenderCursorInfoMap.delete(e),this.internalMsgEmitter.emit([Z.Cursor,e],[]);(this.willConsumeEventWorkers.size||this.cursorInfoMap.size)&&this.runAnimation()}sendEvent(o,t){if(this.displayer&&it.isRoom(this.displayer)){const e=E.isNumber(o[0])&&E.isNumber(o[1])&&this.control.viewContainerManager.transformToScenePoint(o,t)||[void 0,void 0];this.willSendEventWorkers.push({consumPoint:e,viewId:t}),this.sendEventTimerId||(this.sendEventTimerId=setTimeout(()=>{this.dispatchMagixEvent()},this.maxLastSyncTime))}}dispatchMagixEvent(){var o;this.displayer.dispatchMagixEvent(this.eventName,{type:Ce.Cursor,op:E.cloneDeep(this.willSendEventWorkers),uid:(o=this.control.collector)==null?void 0:o.uid}),this.willSendEventWorkers.length=0,this.sendEventTimerId&&(clearTimeout(this.sendEventTimerId),this.sendEventTimerId=void 0)}collectServiceCursor(o){var s;const{op:t,uid:e,workState:i,viewId:n}=o;if(e&&t&&i&&n){const a=this.roomMember.getRoomMember(e);if(!a||e===((s=this.control.collector)==null?void 0:s.uid))return;const c=this.getKey(e,n);let l=[void 0,void 0];if(E.isNumber(t[0])&&E.isNumber(t[1])){const[u,d]=this.control.viewContainerManager.transformToOriginPoint(t,n);l=[u,d]}if(i===b.Start){for(const u of this.cursorInfoMap.values())if(u!=null&&u.size)for(const d of u.keys())d===a.memberId&&u.delete(d)}const h={consumPoint:l,workState:i,viewId:n,timestamp:Date.now()};if(i===b.Start||i===b.Done){const u=this.willConsumeEventWorkers.get(e);i===b.Start&&u&&this.willConsumeEventWorkers.delete(e),u&&i===b.Done&&(h.timestamp=h.timestamp-this.expirationTime)}this.animationDrawWorkers.set(c,h),this.runAnimation()}}unabled(){var o;this.displayer&&it.isRoom(this.displayer)&&(this.willSendEventWorkers.length=0,this.displayer.dispatchMagixEvent(this.eventName,{type:Ce.Cursor,op:[{viewId:this.control.viewContainerManager.focuedViewId,consumPoint:[void 0,void 0]}],uid:(o=this.control.collector)==null?void 0:o.uid}),this.sendEventTimerId&&(clearTimeout(this.sendEventTimerId),this.sendEventTimerId=void 0))}clearViewCursor(o){var t,e,i;for(const[n]of this.animationDrawWorkers.entries()){const{uid:s}=this.getUidAndviewId(n);s===((t=this.control.collector)==null?void 0:t.uid)&&o===o&&this.animationDrawWorkers.delete(n)}for(const[n]of this.willConsumeEventWorkers.entries())n===((e=this.control.collector)==null?void 0:e.uid)&&this.willConsumeEventWorkers.delete(n);for(const[n]of this.animationEventWorkers.entries())n===((i=this.control.collector)==null?void 0:i.uid)&&this.animationEventWorkers.delete(n);for(const[n]of this.cursorInfoMap.entries())n===n&&(this.cursorInfoMap.delete(n),this.doneRenderCursorInfoMap.delete(n),this.internalMsgEmitter.emit([Z.Cursor,n],[]))}stopAnimation(){this.animationDrawWorkers.clear(),this.willConsumeEventWorkers.clear(),this.cursorInfoMap.clear()}destroy(){var o;(o=this.displayer)==null||o.removeMagixEventListener(this.eventName),this.stopAnimation()}}class bt{constructor(){M(this,"useEmtMsg");M(this,"emtType");M(this,"control");M(this,"mainEngine")}static dispatch(o,t,e){var i;(i=mt.InternalMsgEmitter)==null||i.emit([o,t],e)}get serviceColloctor(){return this.control.collector}registerForMainEngine(o,t){return this.emtType=o,this.control=t,this.mainEngine=t.worker,this.mainEngine.internalMsgEmitter.on([this.emtType,this.emitEventType],this.collect.bind(this)),this}destroy(){this.emtType&&this.mainEngine&&this.mainEngine.internalMsgEmitter.off([this.emtType,this.emitEventType],this.collect.bind(this))}collectForLocalWorker(o,t){var e,i,n;for(const[s,a]of o)(e=this.mainEngine)==null||e.queryTaskBatchData(a).forEach(c=>{var l;(l=this.mainEngine)==null||l.taskBatchData.delete(c)}),(i=this.mainEngine)==null||i.taskBatchData.add(s);if(t){this.mainEngine.consume();return}(n=this.mainEngine)==null||n.runAnimation()}collectForServiceWorker(o){fe(()=>{o.forEach(t=>{var e;(e=this.serviceColloctor)==null||e.dispatch(t)})},this.mainEngine.maxLastSyncTime)}pause(){var o;if(this.lastEmtData){this.useEmtMsg=!0;const t={...this.lastEmtData,workState:b.Done};this.collect(t,!0),(o=mt.InternalMsgEmitter)==null||o.emit(O.ActiveMethod,!1)}}recover(){var o;this.useEmtMsg&&mt.InternalMsgEmitter.hasListeners(O.ActiveMethod)&&((o=mt.InternalMsgEmitter)==null||o.emit(O.ActiveMethod,!0))}}class Yf extends bt{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",O.CopyNode)}collect(t){var c;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:e,viewId:i}=t,n=this.control.viewContainerManager.getView(i);if(!(n!=null&&n.displayer))return;const s=n.focusScenePath,a=Date.now();this.mainEngine.internalMsgEmitter.emit("addUndoTicker",a,i);for(const l of e){const h=l.toString(),d=this.serviceColloctor.isLocalId(h)?this.serviceColloctor.transformKey(l):h,p=(c=this.serviceColloctor.getStorageData(i,s))==null?void 0:c[d];if(p){if(l===B){const f=p&&this.copySelector({viewId:i,store:p});f&&this.pasteSelector({...f,viewId:i,scenePath:s,undoTickerId:a});break}if(p.toolsType===S.Text&&p.opt&&p.opt.workState&&p.opt.workState!==b.Done){const f=p&&this.copyText({viewId:i,store:p});f&&this.pasteText({...f,viewId:i,scenePath:s,key:d,store:p,undoTickerId:a});break}}}}copyText(t){const{viewId:e,store:i}=t,n=this.control.viewContainerManager.getView(e);if(!this.serviceColloctor||!n)return;const s=n==null?void 0:n.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(t){var y,v;const{bgCenter:e,textCenter:i,store:n,key:s,viewId:a,scenePath:c,undoTickerId:l}=t,h=this.control.viewContainerManager.getView(a);if(!this.serviceColloctor||!h)return;const u=Math.floor(Math.random()*30+1),d=((y=h.cameraOpt)==null?void 0:y.scale)||1,p=e&&i&&[e[0]-i[0]+u,e[1]-i[1]+u]||[u/d,u/d],I=(this.serviceColloctor.isLocalId(s)?s:this.serviceColloctor.getLocalId(s.toString()))+"-"+l;if(n.toolsType===S.Text&&n.opt){const w=n.opt;if(w&&w.boxPoint&&w.text){w.workState=b.Done;const m=w.boxPoint;w.boxPoint=[m[0]+p[0],m[1]+p[1]],w.workState=b.Done;const T=this.control.viewContainerManager.transformToOriginPoint(w.boxPoint,a);this.control.textEditorManager.createTextForMasterController({workId:I,x:T[0],y:T[1],opt:w,scale:((v=h.cameraOpt)==null?void 0:v.scale)||1,type:Ut.Text,isActive:!1,viewId:a,scenePath:c}),this.collectForServiceWorker([{...n,opt:w,type:x.FullWork,workId:I,viewId:a,scenePath:c}])}}}copySelector(t){var I,y,v,w,m,T,N,C,z;const{viewId:e,store:i}=t,n=this.control.viewContainerManager.getView(e),s=i.selectIds;if(!this.serviceColloctor||!(s!=null&&s.length)||!n)return;const a=new Map,c={offset:{x:0,y:0},cameraOpt:{centerX:((I=n.cameraOpt)==null?void 0:I.centerX)||0,centerY:((y=n.cameraOpt)==null?void 0:y.centerY)||0,scale:((v=n.cameraOpt)==null?void 0:v.scale)||1}},l=this.control.hasOffscreenCanvas()&&((w=n.displayer.canvasBgRef.current)==null?void 0:w.getBoundingClientRect())||((m=n.displayer.canvasContainerRef.current)==null?void 0:m.getBoundingClientRect()),h=(N=(T=n.displayer)==null?void 0:T.floatBarRef.current)==null?void 0:N.getBoundingClientRect(),u=l&&[l.x+l.width/2,l.y+l.height/2],d=h&&[h.x+h.width/2,h.y+h.height/2],p=u&&n.viewData&&n.viewData.convertToPointInWorld({x:u[0],y:u[1]}),f=d&&n.viewData&&n.viewData.convertToPointInWorld({x:d[0],y:d[1]});p&&f&&(c.offset={x:p.x-f.x,y:p.y-f.y});for(const L of s){const j=(z=(C=this.serviceColloctor)==null?void 0:C.getStorageData(n.id,n.focusScenePath))==null?void 0:z[L];j&&a.set(L,j)}return{copyStores:a,copyCoordInfo:c}}pasteSelector(t){var I;const{copyStores:e,copyCoordInfo:i,viewId:n,scenePath:s,undoTickerId:a}=t,c=this.control.viewContainerManager.getView(n);if(!e.size||!this.serviceColloctor||!c)return;const{offset:l,cameraOpt:h}=i,u=Math.floor(Math.random()*30+1),d=[l.x+u,l.y+u],p=[],f=[];for(const[y,v]of e.entries()){const m=(this.serviceColloctor.isLocalId(y)?y:this.serviceColloctor.getLocalId(y.toString()))+"-"+a,T={useAnimation:!1};if(v.toolsType===S.Text&&v.opt){const N=v.opt;if(N&&N.boxPoint&&N.text){N.workState=b.Done;const C=N.boxPoint;N.boxPoint=[C[0]+d[0],C[1]+d[1]],N.workState=b.Done;const z=this.control.viewContainerManager.transformToOriginPoint(N.boxPoint,n);this.control.textEditorManager.createTextForMasterController({workId:m,x:z[0],y:z[1],opt:N,scale:((I=c.cameraOpt)==null?void 0:I.scale)||1,type:Ut.Text,isActive:!1,viewId:n,scenePath:s})}f.push({...v,opt:N,type:x.FullWork,workId:m,viewId:n,scenePath:s});continue}if(v.toolsType===S.Image&&(v.opt.uuid=m,v.opt.centerX=v.opt.centerX+d[0],v.opt.centerY=v.opt.centerY+d[1]),v.ops){const N=ve(v.ops).map((z,L)=>{const j=L%3;return j===0?z+d[0]:j===1?z+d[1]:z}),C=Lt(N);v.ops=C}f.push({...v,updateNodeOpt:T,type:x.FullWork,workId:m,viewId:n,scenePath:s}),p.push([{...v,updateNodeOpt:T,workId:m,msgType:x.FullWork,dataType:U.Local,emitEventType:O.CopyNode,willSyncService:!1,willRefresh:!0,viewId:n},{workId:m,msgType:x.FullWork,emitEventType:O.CopyNode}])}p.length&&this.collectForLocalWorker(p),f.length&&this.collectForServiceWorker(f)}}function De(r,o,t){return"#"+((r<<16)+(o<<8)+t).toString(16).padStart(6,"0")}function Mt(r,o=1){return"rgba("+parseInt("0x"+r.slice(1,3))+","+parseInt("0x"+r.slice(3,5))+","+parseInt("0x"+r.slice(5,7))+","+o+")"}function Ae(r,o,t,e=1){return`rgba(${r},${o},${t},${e})`}function ro(r){const o=r.split(","),t=parseInt(o[0].split("(")[1]),e=parseInt(o[1]),i=parseInt(o[2]),n=Number(o[3].split(")")[0]);return[De(t,e,i),n]}function Oe(r){const o=r.split(","),t=parseInt(o[0].split("(")[1]),e=parseInt(o[1]),i=parseInt(o[2]),n=Number(o[3].split(")")[0]);return[t,e,i,n]}function Re(r){return r==="transparent"}class Wf extends bt{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",O.SetColorNode);M(this,"undoTickerId")}setTextColor(t,e,i,n){const{fontColor:s,fontBgColor:a}=i;e.opt&&(s&&(e.opt.fontColor=s),a&&(e.opt.fontBgColor=a),this.control.textEditorManager.updateTextForMasterController({workId:t,opt:e.opt,viewId:n,canSync:!0,canWorker:!0}))}collect(t){if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:e,strokeColor:i,fillColor:n,fontColor:s,fontBgColor:a,viewId:c,workState:l,thickness:h,strokeType:u}=t,d=this.control.viewContainerManager.getView(c);if(!(d!=null&&d.displayer))return;const p=d.focusScenePath,f=[...e],I=this.serviceColloctor.storage,y=[],v={};for((l===b.Start||!this.undoTickerId&&l===b.Done)&&(this.undoTickerId=Date.now(),this.mainEngine.internalMsgEmitter.emit("addUndoTicker",this.undoTickerId,c));f.length;){const w=f.pop();if(!w)continue;const m=w.toString(),T=this.serviceColloctor.isLocalId(m),N=T?this.serviceColloctor.transformKey(w):m;let C=m;!T&&this.serviceColloctor.isOwn(C)&&(C=this.serviceColloctor.getLocalId(C));const z=I[c][p][N]||void 0;if(z){const L=z.updateNodeOpt||{};if(s||a){if(s){L.fontColor=s;const[A,P,R,D]=Oe(s);v.textColor=[A,P,R],v.textOpacity=D}if(a)if(L.fontBgColor=Re(a)?"transparent":a,Re(a))v.textBgColor=void 0,v.textBgOpacity=void 0;else{const[A,P,R,D]=Oe(a);v.textBgColor=[A,P,R],v.textBgOpacity=D}if(z.toolsType===S.Text&&z.opt&&l!==b.Start){this.setTextColor(C,Qt(z),L,c),l===b.Done&&(this.undoTickerId=void 0);continue}}if(i){L.strokeColor=i;const[A,P,R,D]=Oe(i);v.strokeColor=[A,P,R],v.strokeOpacity=D}if(n)if(L.fillColor=Re(n)?"transparent":n,Re(n))v.fillColor=void 0,v.fillOpacity=void 0;else{const[A,P,R,D]=Oe(n);v.fillColor=[A,P,R],v.fillOpacity=D}h&&(L.thickness=h,v.strokeWidth=h),u&&(L.strokeType=u,v.strokeType=u);const j={workId:C,msgType:x.UpdateNode,dataType:U.Local,updateNodeOpt:L,emitEventType:this.emitEventType,willRefresh:!0,willRefreshSelector:!0,willSyncService:!0,textUpdateForWoker:!0,viewId:c};y.push([j,{workId:C,msgType:x.UpdateNode,emitEventType:this.emitEventType}])}}y.length&&(l===b.Done&&(this.undoTickerId=void 0),this.collectForLocalWorker(y)),Object.keys(v).length&&setTimeout(()=>{var w;(w=this.control.room)==null||w.setMemberState(v)},0)}}class Uf extends bt{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",O.ZIndexNode);M(this,"zIndexMap",new Map)}clearZIndex(t){this.zIndexMap.delete(t)}getMinZIndex(t){var e;return((e=this.zIndexMap.get(t))==null?void 0:e.min)||0}getMaxZIndex(t){var e;return((e=this.zIndexMap.get(t))==null?void 0:e.max)||0}setMaxZIndex(t,e){const i=this.getMinZIndex(e);this.zIndexMap.set(e,{min:i,max:t})}setMinZIndex(t,e){const i=this.getMaxZIndex(e);this.zIndexMap.set(e,{min:t,max:i})}addMaxLayer(t){const e=this.getMaxZIndex(t)+1;this.setMaxZIndex(e,t)}addMinLayer(t){const e=this.getMinZIndex(t)-1;this.setMinZIndex(e,t)}correct(t){const e=t.sort((i,n)=>i[1]-n[1]);for(let i=1;i<e.length;i++){const n=e[i][1],s=e[i-1][1];n<=s&&(e[i][1]=s+1)}return e}collect(t){if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:e,layer:i,viewId:n}=t,s=this.control.viewContainerManager.getView(n);if(!(s!=null&&s.displayer))return;const a=s.focusScenePath,c=[...e],l=this.serviceColloctor.storage,h=[],u=[];for(;c.length;){const p=c.pop();if(!p)continue;const f=p.toString(),I=this.serviceColloctor.isLocalId(f),y=I?this.serviceColloctor.transformKey(p):f;let v=f;!I&&this.serviceColloctor.isOwn(v)&&(v=this.serviceColloctor.getLocalId(v));const w=Qt(l[n][a][y]);let m;if(w&&v===B){if(w.selectIds){u.push(...w.selectIds),u.sort((z,L)=>{var P,R,D,G;const j=((R=(P=l[d(z,this.serviceColloctor)])==null?void 0:P.opt)==null?void 0:R.zIndex)||0,A=((G=(D=l[d(z,this.serviceColloctor)])==null?void 0:D.opt)==null?void 0:G.zIndex)||0;return j>A?1:z<L?-1:0});const T=w.updateNodeOpt||{};T.zIndexLayer=i;const N={workId:p,msgType:x.UpdateNode,dataType:U.Local,updateNodeOpt:T,emitEventType:this.emitEventType,willRefreshSelector:!0,willSyncService:!0,viewId:n},C=new Map;i===ee.Top?(this.addMaxLayer(n),m=this.getMaxZIndex(n)):(this.addMinLayer(n),m=this.getMinZIndex(n)),u.forEach(z=>{var P,R,D;const L=(P=this.serviceColloctor)==null?void 0:P.isLocalId(z);let j=L&&((R=this.serviceColloctor)==null?void 0:R.transformKey(z))||z;const A=l[n][a][j];!L&&((D=this.serviceColloctor)!=null&&D.isOwn(j))&&(j=this.serviceColloctor.getLocalId(j)),T.zIndex=m,A!=null&&A.opt&&(A.opt.zIndex=m),A!=null&&A.opt&&C.set(j,{updateNodeOpt:A.updateNodeOpt,opt:A.opt})}),N.selectStore=C,N.willSerializeData=!0,h.push([N,{workId:p,msgType:x.UpdateNode,emitEventType:this.emitEventType}])}continue}}h.length&&this.collectForLocalWorker(h);function d(p,f){return f.isLocalId(p)&&f.transformKey(p)||p}}}class Bf extends bt{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",O.TranslateNode);M(this,"cachePosition")}collect(t,e){var f;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:i,position:n,workState:s,viewId:a}=t;this.lastEmtData=t;const c=this.control.viewContainerManager.getView(a);if(!(c!=null&&c.displayer))return;const l=c.focusScenePath,h=[...i],u=(f=this.serviceColloctor)==null?void 0:f.storage,d=[],p=s===b.Start&&Date.now()||void 0;for(p&&this.mainEngine.internalMsgEmitter.emit("addUndoTicker",p,a);h.length;){const I=h.pop();if(!I)continue;const y=I.toString(),v=this.serviceColloctor.isLocalId(y),w=v&&this.serviceColloctor.transformKey(I)||y;let m=y;!v&&this.serviceColloctor.isOwn(m)&&(m=this.serviceColloctor.getLocalId(m));const T=u[a][l][w];if(T&&m===B){if(T.selectIds){const N=this.control.viewContainerManager.transformToScenePoint([n.x,n.y],a);if(s===b.Start&&(this.cachePosition=N),this.cachePosition){const C=T.updateNodeOpt||{};C.translate=[N[0]-this.cachePosition[0],N[1]-this.cachePosition[1]],C.workState=s;const z={workId:I,msgType:x.UpdateNode,dataType:U.Local,updateNodeOpt:C,emitEventType:this.emitEventType,willSyncService:!0,textUpdateForWoker:!0,viewId:a};s===b.Done&&(z.textUpdateForWoker=!0,z.willSerializeData=!0,this.cachePosition=void 0),d.push([z,{workId:I,msgType:x.UpdateNode,emitEventType:this.emitEventType}])}}continue}}s===b.Start?this.mainEngine.unWritable():s===b.Done&&(this.mainEngine.abled(),this.lastEmtData=void 0),d.length&&this.collectForLocalWorker(d,e)}}class $f extends bt{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",O.DeleteNode)}collect(t){if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:e,viewId:i}=t,n=this.control.viewContainerManager.getView(i);if(!(n!=null&&n.displayer))return;const s=n.focusScenePath,a=this.serviceColloctor.storage,c=[...e],l=[],h=[],u=Date.now();for(;c.length;){const d=c.pop();if(!d)continue;const p=d.toString(),f=this.serviceColloctor.isLocalId(p),I=f?this.serviceColloctor.transformKey(d):p,y=a[i][s][I];if(y){let v=p;if(!f&&this.serviceColloctor.isOwn(v)&&(v=this.serviceColloctor.getLocalId(v)),y.toolsType===S.Text){this.control.textEditorManager.delete(v,!0,!0);continue}h.push(v)}}h.length&&(l.push([{msgType:x.RemoveNode,emitEventType:O.DeleteNode,removeIds:h,dataType:U.Local,willSyncService:!0,willRefresh:!0,viewId:i},void 0]),this.mainEngine.internalMsgEmitter.emit("addUndoTicker",u,i),this.collectForLocalWorker(l))}}class Ff extends bt{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",O.ScaleNode);M(this,"targetText",new Map);M(this,"cacheTextInfo",new Map)}async setTextStyle(t,e,i){const n=await this.control.textEditorManager.updateTextControllerWithEffectAsync({workId:t,opt:e,viewId:i,canSync:!1,canWorker:!1});return{key:t,textInfo:n}}async collect(t,e){var w,m,T,N,C;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:i,workState:n,viewId:s,originPoint:a,scenePoint:c,dir:l,scale:h,translate:u}=t;this.lastEmtData=t;const d=this.control.viewContainerManager.getView(s);if(!(d!=null&&d.displayer))return;const p=d.focusScenePath,f=[...i],I=(w=this.serviceColloctor)==null?void 0:w.storage,y=[],v=n===b.Start&&Date.now()||void 0;for(v&&this.mainEngine.internalMsgEmitter.emit("addUndoTicker",v,s);f.length;){const z=f.pop();if(!z)continue;const L=z.toString(),j=this.serviceColloctor.isLocalId(L),A=j&&this.serviceColloctor.transformKey(z)||L;let P=L;!j&&this.serviceColloctor.isOwn(P)&&(P=this.serviceColloctor.getLocalId(P));const R=I[s][p][A];if(R&&P===B&&R.selectIds){const D=R.updateNodeOpt||{};if(D.dir=l,D.originPoint=a,D.scenePoint=c,D.workState=n,D.scale=h,D.translate=u,n===b.Start){this.cacheTextInfo.clear();for(const ct of R.selectIds){const et=(m=this.serviceColloctor)==null?void 0:m.isLocalId(ct),H=et&&((T=this.serviceColloctor)==null?void 0:T.transformKey(ct))||ct;let J=H;!et&&((N=this.serviceColloctor)!=null&&N.isOwn(H))&&(J=this.serviceColloctor.getLocalId(H));const Q=this.control.textEditorManager.get(J);Q&&n===b.Start&&this.targetText.set(J,Qt(Q))}}if(this.targetText.size&&n!==b.Start&&h){const ct=[];for(const[H,J]of this.targetText.entries()){const{opt:Q}=J,V=Math.floor(Q.fontSize*h[0]),K=this.cacheTextInfo.get(H),nt=!K&&Q.fontSize!==V||K&&K.fontSize!==V||!1,q=(C=this.control.textEditorManager.get(H))==null?void 0:C.opt;if(nt&&q&&Q.boxSize&&Q.boxPoint){const ot=this.setTextStyle(H,{...q,fontSize:V},s);ct.push(ot)}}const et=await Promise.all(ct);for(const H of et)if(H){const{key:J,textInfo:Q}=H;this.cacheTextInfo.set(J,{fontSize:Q.opt.fontSize,boxSize:Q.opt.boxSize,boxPoint:Q.opt.boxPoint})}D.textInfos=this.cacheTextInfo}const G={workId:z,msgType:x.UpdateNode,dataType:U.Local,updateNodeOpt:D,emitEventType:this.emitEventType,willRefreshSelector:!0,willSyncService:!0,viewId:s};n===b.Done&&(G.willSerializeData=!0,this.targetText.clear()),y.push([G,{workId:z,msgType:x.UpdateNode,emitEventType:this.emitEventType}]);continue}}n===b.Start?this.mainEngine.unWritable():n===b.Done&&(this.mainEngine.abled(),this.lastEmtData=void 0),y.length&&this.collectForLocalWorker(y,e)}}class Hf extends bt{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",O.RotateNode);M(this,"cacheOriginRotate",0)}collect(t,e){var f,I,y,v,w;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:i,angle:n,workState:s,viewId:a}=t;this.lastEmtData=t;const c=this.control.viewContainerManager.getView(a);if(!(c!=null&&c.displayer))return;const l=c.focusScenePath,h=[...i],u=(f=this.serviceColloctor)==null?void 0:f.storage,d=[],p=s===b.Start&&Date.now()||void 0;for(p&&this.mainEngine.internalMsgEmitter.emit("addUndoTicker",p,a);h.length;){const m=h.pop();if(!m)continue;const T=m.toString(),N=this.serviceColloctor.isLocalId(T),C=N&&this.serviceColloctor.transformKey(m)||T;let z=T;!N&&this.serviceColloctor.isOwn(z)&&(z=this.serviceColloctor.getLocalId(z));const L=u[a][l][C];if(L&&z===B){if(((I=L.selectIds)==null?void 0:I.length)===1){const j=L.selectIds[0];if(s===b.Start){const D=((y=this.serviceColloctor)==null?void 0:y.isLocalId(j))&&((v=this.serviceColloctor)==null?void 0:v.transformKey(j))||j,G=u[a][l][D];this.cacheOriginRotate=((w=G==null?void 0:G.opt)==null?void 0:w.rotate)||0}const A=L.updateNodeOpt||{};A.angle=(n+this.cacheOriginRotate)%360,A.workState=s;const P={workId:m,msgType:x.UpdateNode,dataType:U.Local,updateNodeOpt:A,emitEventType:this.emitEventType,willRefreshSelector:!1,willSyncService:!0,viewId:a};s===b.Done&&(P.willRefreshSelector=!0,P.willSerializeData=!0,this.cacheOriginRotate=0),d.push([P,{workId:m,msgType:x.UpdateNode,emitEventType:this.emitEventType}])}continue}}s===b.Start?this.mainEngine.unWritable():s===b.Done&&(this.mainEngine.abled(),this.lastEmtData=void 0),d.length&&this.collectForLocalWorker(d,e)}}function Qf(r){switch(r){case S.Text:return Ut.Text;case S.SpeechBalloon:case S.Star:case S.Ellipse:case S.Rectangle:case S.Triangle:case S.Rhombus:case S.Polygon:return Ut.Shape}}class Vf extends bt{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",O.SetFontStyle);M(this,"timerId")}async setTextStyle(t,e,i,n){const{bold:s,underline:a,lineThrough:c,italic:l,fontSize:h}=i;if(e.toolsType&&Qf(e.toolsType)===Ut.Text){e.opt&&(s&&(e.opt.bold=s),E.isBoolean(a)&&(e.opt.underline=a),E.isBoolean(c)&&(e.opt.lineThrough=c),l&&(e.opt.italic=l),h&&(e.opt.fontSize=h));const d=await this.control.textEditorManager.updateTextControllerWithEffectAsync({workId:t,opt:e.opt,viewId:n,canSync:!1,canWorker:!1});return{key:t,textInfo:d}}}async collect(t){var w,m,T,N;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:e,bold:i,italic:n,lineThrough:s,underline:a,viewId:c,fontSize:l}=t,h=this.control.viewContainerManager.getView(c);if(!(h!=null&&h.displayer))return;const u=h.focusScenePath,d=[...e],p=this.serviceColloctor.storage,f={},I=Date.now();this.mainEngine.internalMsgEmitter.emit("addUndoTicker",I,c);const y=[];for(;d.length;){const C=d.pop();if(!C)continue;const z=C.toString(),L=this.serviceColloctor.isLocalId(z),j=L?this.serviceColloctor.transformKey(C):z;let A=z;!L&&this.serviceColloctor.isOwn(A)&&(A=this.serviceColloctor.getLocalId(A));const P=p[c][u][j]||void 0;if(P){const R=P.updateNodeOpt||{};if(i&&(R.bold=i,f.bold=i==="bold"),n&&(R.italic=n,f.italic=n==="italic"),E.isBoolean(s)&&(R.lineThrough=s,f.lineThrough=s),E.isBoolean(a)&&(R.underline=a,f.underline=a),l&&(R.fontSize=l,f.textSize=l),P.toolsType===S.Text&&P.opt){const D=this.setTextStyle(A,E.cloneDeep(P),R,c);y.push(D);continue}if(P&&A===B&&((w=P.selectIds)!=null&&w.length))for(const D of P.selectIds){const G=(m=this.serviceColloctor)==null?void 0:m.isLocalId(D);let ct=G&&((T=this.serviceColloctor)==null?void 0:T.transformKey(D))||D;const et=p[c][u][ct]||void 0;if(!G&&((N=this.serviceColloctor)!=null&&N.isOwn(ct))&&(ct=this.serviceColloctor.getLocalId(ct)),et&&et.toolsType===S.Text&&P.opt){const H=this.setTextStyle(ct,E.cloneDeep(et),R,c);y.push(H);continue}}}}const v=await Promise.all(y);for(const C of v)if(C){const{key:z,textInfo:L}=C;L&&(L.canSync=!0,L.canWorker=!0,this.control.textEditorManager.updateForViewEdited(z,L))}Object.keys(f).length&&(this.timerId&&(clearTimeout(this.timerId),this.timerId=void 0),this.timerId=setTimeout(()=>{var C;this.timerId=void 0,(C=this.control.room)==null||C.setMemberState(f)},0))}}class Zf extends bt{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",O.SetPoint);M(this,"undoTickerId")}collect(t){var w;if(!this.serviceColloctor||!this.mainEngine)return;const{workId:e,pointMap:i,workState:n,viewId:s}=t,a=this.control.viewContainerManager.getView(s);if(!(a!=null&&a.displayer))return;const c=a.focusScenePath,l=(w=this.serviceColloctor)==null?void 0:w.storage,h=[],u=n===b.Start&&Date.now()||void 0;u&&(this.undoTickerId=u,this.mainEngine.internalMsgEmitter.emit("addUndoTicker",u,s));const d=e;if(!d)return;const p=d.toString(),f=this.serviceColloctor.isLocalId(p),I=f&&this.serviceColloctor.transformKey(d)||p;let y=p;!f&&this.serviceColloctor.isOwn(y)&&(y=this.serviceColloctor.getLocalId(y));const v=l[s][c][I];if(v&&y===B&&v.selectIds){const m=v.updateNodeOpt||{};m.pointMap=i,m.workState=n;const T={workId:d,msgType:x.UpdateNode,dataType:U.Local,updateNodeOpt:m,emitEventType:this.emitEventType,willRefreshSelector:!0,willSyncService:!0,viewId:s};n===b.Done&&(T.undoTickerId=this.undoTickerId),h.push([T,{workId:d,msgType:x.UpdateNode,emitEventType:this.emitEventType}])}n===b.Start?this.mainEngine.unWritable():n===b.Done&&this.mainEngine.abled(),h.length&&this.collectForLocalWorker(h)}}class Gf extends bt{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",O.SetLock)}collect(t){if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:e,isLocked:i,viewId:n}=t,s=this.control.viewContainerManager.getView(n);if(!(s!=null&&s.displayer))return;const a=s.focusScenePath,c=[...e],l=this.serviceColloctor.storage,h=[],u=Date.now();for(;c.length;){const d=c.pop();if(!d)continue;const p=d.toString(),f=this.serviceColloctor.isLocalId(p),I=f?this.serviceColloctor.transformKey(d):p;let y=p;!f&&this.serviceColloctor.isOwn(y)&&(y=this.serviceColloctor.getLocalId(y));const v=l[n][a][I]||void 0;if(v){const w=v.updateNodeOpt||{};w.isLocked=i;const m={workId:y,msgType:x.UpdateNode,dataType:U.Local,updateNodeOpt:w,emitEventType:this.emitEventType,willRefresh:!0,willRefreshSelector:!0,willSyncService:!0,viewId:n};h.push([m,{workId:y,msgType:x.UpdateNode,emitEventType:this.emitEventType}])}}this.mainEngine.internalMsgEmitter.emit("addUndoTicker",u,n),h.length&&this.collectForLocalWorker(h)}}class Jf extends bt{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",O.SetShapeOpt)}collect(t){if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:e,viewId:i,...n}=t,s=this.control.viewContainerManager.getView(i);if(!(s!=null&&s.displayer))return;const a=s.focusScenePath,c=[...e],l=this.serviceColloctor.storage,h=[],u=Date.now();for(;c.length;){const d=c.pop();if(!d)continue;const p=d.toString(),f=this.serviceColloctor.isLocalId(p),I=f?this.serviceColloctor.transformKey(d):p;let y=p;!f&&this.serviceColloctor.isOwn(y)&&(y=this.serviceColloctor.getLocalId(y));const v=l[i][a][I]||void 0;if(v){const w={...v.updateNodeOpt,...n,willRefresh:!0};if(v&&y===B){const m={workId:y,msgType:x.UpdateNode,dataType:U.Local,updateNodeOpt:w,emitEventType:this.emitEventType,willRefresh:!0,willRefreshSelector:!0,willSyncService:!0,viewId:i};h.push([m,{workId:y,msgType:x.UpdateNode,emitEventType:this.emitEventType}])}}}h.length&&(this.mainEngine.internalMsgEmitter.emit("addUndoTicker",u,i),this.collectForLocalWorker(h))}}class X{constructor(o){M(this,"builders",new Map);this.builders=new Map(o.map(t=>[t,this.build(t)]))}build(o){switch(o){case O.TranslateNode:return new Bf;case O.ZIndexNode:return new Uf;case O.CopyNode:return new Yf;case O.SetColorNode:return new Wf;case O.DeleteNode:return new $f;case O.ScaleNode:return new Ff;case O.RotateNode:return new Hf;case O.SetFontStyle:return new Vf;case O.SetPoint:return new Zf;case O.SetLock:return new Gf;case O.SetShapeOpt:return new Jf}}getBuilder(o){return this.builders.get(o)}registerForMainEngine(o,t){return this.builders.forEach(e=>{e&&e.registerForMainEngine(o,t)}),this}destroy(){this.builders.forEach(o=>{o&&o.destroy()}),this.builders.clear()}pause(){return this.builders.forEach(o=>{o&&o.pause()}),this}recover(){return this.builders.forEach(o=>{o&&o.recover()}),this}static emitMethod(o,t,e){bt.dispatch(o,t,e)}static activeListener(o){mt.InternalMsgEmitter.on(O.ActiveMethod,o)}static unmountActiveListener(o){mt.InternalMsgEmitter.off(O.ActiveMethod,o)}}class qf{constructor(o){M(this,"master");M(this,"mainThreadWorkerMap",new Map);this.master=o}updateCamera(){for(const[o,t]of this.mainThreadWorkerMap.entries()){const e=this.master.control.viewContainerManager.getView(o);if(e){const{cameraOpt:i}=e;t.updateCamera({cameraOpt:i,viewId:e.viewId,msgType:x.UpdateCamera,dataType:U.Local})}}}notifyDrawCount(o){const t=this.master.getWorkDrawCount(),e=this.mainThreadWorkerMap.get(o);e&&e.clearDrawLayer(t)}clearDrawCount(o){const t=this.mainThreadWorkerMap.get(o);t&&t.clearDrawLayer(1/0)}createMainThreadWorker(o,t){return new Xf(o,t,this)}consume(o){var t;for(const e of o.values()){const{msgType:i,viewId:n,layerOpt:s,offscreenCanvasOpt:a,cameraOpt:c}=e;if(i===x.Console){console.log(this);continue}if(i===x.Init){const h=(t=this.master.control.viewContainerManager.getView(n))==null?void 0:t.displayer,u=h==null?void 0:h.subLocalCanvasContainerRef.current;if(h&&u&&s&&a){const d=this.createMainThreadWorker(n,{displayer:h,container:u,layerOpt:s,master:this.master,canvasOpt:a,post:this.post.bind(this)});this.mainThreadWorkerMap.set(n,d),d&&c&&d.setCameraOpt(c)}continue}if(i===x.TasksQueue)continue;const l=this.mainThreadWorkerMap.get(n);l&&(l.on(e),i===x.Destroy&&(l.destroy(),this.mainThreadWorkerMap.delete(n)))}}post(o){const{sp:t}=o;t&&this.master.collectorSyncData(t)}destroy(){for(const o of this.mainThreadWorkerMap.values())o.destroy();this.mainThreadWorkerMap.clear()}active(){}}class Xf{constructor(o,t,e){M(this,"viewId");M(this,"opt");M(this,"manager");M(this,"subLocalLayer");M(this,"subLocalWork");M(this,"scene");M(this,"cameraOpt");this.viewId=o,this.opt=t,this.manager=e,this.scene=this.createScene({...t.canvasOpt,container:t.container});const i=xt.bufferSize.full,n=xt.bufferSize.sub;this.subLocalLayer=this.createLayer("subLocalLayer",this.scene,{...t.layerOpt,bufferSize:this.viewId===wt?i:n});const s={thread:this};this.subLocalWork=new Kf(s)}createScene(o){return new ht.Scene({displayRatio:this.opt.displayer.dpr,depth:!1,desynchronized:!0,...o,autoRender:!0,id:this.viewId})}createLayer(o,t,e){const{width:i,height:n}=e,s=`canvas-${o}`,a=t.layer(s,{...e,offscreen:!1}),c=new ht.Group({anchor:[.5,.5],pos:[i*.5,n*.5],size:[i,n],name:"viewport",id:o});return a.append(c),c}updateScene(o){this.scene.attr({...o});const{width:t,height:e}=o;this.scene.width=t,this.scene.height=e,this.updateLayer({width:t,height:e})}updateLayer(o){const{width:t,height:e}=o;this.subLocalLayer.parent.setAttribute("width",t),this.subLocalLayer.parent.setAttribute("height",e),this.subLocalLayer.setAttribute("size",[t,e]),this.subLocalLayer.setAttribute("pos",[t*.5,e*.5])}on(o){const{msgType:t,toolsType:e,opt:i,dataType:n,workId:s,workState:a}=o,c=s==null?void 0:s.toString();switch(t){case x.Destroy:this.destroy();break;case x.Clear:this.clearAll();break;case x.UpdateCamera:this.updateCamera(o);break;case x.UpdateTools:if(e&&this.subLocalWork.canUseSubWorkerLayer(e)&&i){const l={toolsType:e,toolsOpt:i};this.subLocalWork.setToolsOpt(l)}break;case x.CreateWork:c&&i&&e&&this.subLocalWork.canUseSubWorkerLayer(e)&&(this.subLocalWork.getToolsOpt()||this.subLocalWork.setToolsOpt({toolsType:e,toolsOpt:i}),this.subLocalWork.setWorkOptions(c,i));break;case x.DrawWork:e&&this.subLocalWork.canUseSubWorkerLayer(e)&&(a===b.Done&&n===U.Local?this.subLocalWork.consumeDrawAll(o):this.subLocalWork.consumeDraw(o));break;case x.RemoveNode:this.subLocalWork.removeNode(o);return}}setCameraOpt(o){this.cameraOpt=o;const{scale:t,centerX:e,centerY:i,width:n,height:s}=o;(n!==this.scene.width||s!==this.scene.height)&&this.updateScene({width:n,height:s}),this.subLocalLayer&&(this.subLocalLayer.setAttribute("scale",[t,t]),this.subLocalLayer.setAttribute("translate",[-e,-i]))}updateCamera(o){const{cameraOpt:t}=o;t&&!E.isEqual(this.cameraOpt,t)&&(this.subLocalWork.workShapes.size&&this.clearAll(),this.setCameraOpt(t))}clearAll(){this.subLocalLayer.children.length&&(this.subLocalLayer.parent.children.forEach(o=>{o.name!=="viewport"&&o.remove()}),this.subLocalLayer.removeAllChildren()),this.subLocalWork.clearAll()}destroy(){this.subLocalLayer.remove(),this.scene.remove(),this.subLocalWork.destroy()}clearDrawLayer(o){if(o===1/0){this.clearAll();return}const t=this.subLocalLayer.children.filter(e=>e.id&&E.isNumber(parseInt(e.id))&&parseInt(e.id)<o);for(const e of t)e.remove(),e.disconnect()}}class Kf{constructor(o){M(this,"thread");M(this,"workShapes",new Map);M(this,"tmpOpt");M(this,"syncUnitTime",xt.syncOpt.interval);M(this,"drawCount",0);this.thread=o.thread}getToolsOpt(){return this.tmpOpt}consumeDrawAll(o){const{workId:t}=o,e=t==null?void 0:t.toString();e&&this.workShapes.get(e)&&(this.drawCount=0,this.thread.subLocalLayer.removeAllChildren(),this.clearWorkShapeNodeCache(e))}consumeDraw(o){const{workId:t,toolsType:e}=o;t&&e&&this.canUseSubWorkerLayer(e)&&(this.getWorkShape(t.toString())||this.createLocalWork(o));const i=t==null?void 0:t.toString(),n=i&&this.workShapes.get(i);if(!n)return;n.consume({data:o,drawCount:this.drawCount,isFullWork:!1,isSubWorker:!0}),this.drawCount++;const s=this.thread.manager.master;s.setSubWorkerDrawCount(this.drawCount);const a=Math.max(s.getMaxDrawCount(),this.drawCount);s.setMaxDrawCount(a)}removeNode(o){const{workId:t}=o,e=t==null?void 0:t.toString();e&&this.workShapes.has(e)&&(this.thread.subLocalLayer.getElementsByName(e).forEach(n=>{n.remove()}),this.clearWorkShapeNodeCache(e))}createLocalWork(o){const{workId:t,toolsType:e,opt:i}=o,n=t==null?void 0:t.toString();e&&this.canUseSubWorkerLayer(e)&&n&&i&&(this.getToolsOpt()||this.setToolsOpt({toolsType:e,toolsOpt:i}),this.setWorkOptions(n,i))}setWorkOptions(o,t){let e=this.workShapes.get(o);if(!e&&this.tmpOpt){const{toolsType:i}=this.tmpOpt;this.tmpOpt.toolsOpt=t,e=this.createWorkShapeNode({workId:o,toolsType:i,toolsOpt:t}),e&&this.workShapes.set(o,e),this.setToolsOpt(this.tmpOpt)}t!=null&&t.syncUnitTime||(t.syncUnitTime=this.syncUnitTime),e&&e.setWorkOptions(t)}destroy(){this.clearAll()}clearAll(){this.thread.subLocalLayer.removeAllChildren(),this.workShapes.clear()}canUseSubWorkerLayer(o){return o===S.Pencil}setToolsOpt(o){var t;this.tmpOpt=o,(t=o.toolsOpt)!=null&&t.syncUnitTime&&(this.syncUnitTime=o.toolsOpt.syncUnitTime)}createWorkShapeNode(o){return Ms({...o,fullLayer:this.thread.subLocalLayer,drawLayer:this.thread.subLocalLayer})}clearWorkShapeNodeCache(o){this.workShapes.delete(o)}getWorkShape(o){return this.workShapes.get(o)}}class _f{constructor(){M(this,"maxLastSyncTime",xt.syncOpt.interval)}setCurrentToolsData(o){this.currentToolsData=o}getCurrentToolsData(){return this.currentToolsData}setCurrentLocalWorkData(o){this.currentLocalWorkData=o}getWorkId(){return this.currentLocalWorkData.workId}getWorkState(){return this.currentLocalWorkData.workState}}class tg extends _f{constructor(t){var n,s;super();M(this,"isActive",!1);M(this,"currentToolsData");M(this,"currentLocalWorkData");M(this,"control");M(this,"internalMsgEmitter");M(this,"taskBatchData",new Set);M(this,"fullWorker");M(this,"subWorker");M(this,"fullWorkerUrl");M(this,"subWorkerUrl");M(this,"methodBuilder");M(this,"zIndexNodeMethod");M(this,"subWorkerDrawCount",0);M(this,"wokerDrawCount",0);M(this,"maxDrawCount",0);M(this,"reRenders",new Map);M(this,"localWorkViewId");M(this,"localPointsBatchData",new Map);M(this,"tasksqueue",new Map);M(this,"useTasksqueue",!1);M(this,"useTasksClockId");M(this,"mainTasksqueueCount");M(this,"workerTasksqueueCount");M(this,"snapshotMap",new Map);M(this,"boundingRectMap",new Map);M(this,"clearAllResolveMap",new Map);M(this,"delayWorkStateToDoneResolve");M(this,"animationId");M(this,"tmpImageConfigMap",new Map);M(this,"mainThread");M(this,"willSelectorWorkId");M(this,"isLockSentEventCursor",!1);M(this,"subMainThreadWorker");const{control:e,internalMsgEmitter:i}=t;this.control=e,this.maxLastSyncTime=((s=(n=this.control.pluginOptions)==null?void 0:n.syncOpt)==null?void 0:s.interval)||this.maxLastSyncTime,this.fullWorkerUrl=this.control.pluginOptions.cdn.fullWorkerUrl,this.subWorkerUrl=this.control.pluginOptions.cdn.subWorkerUrl,this.internalMsgEmitter=i,this.currentLocalWorkData={workState:b.Pending}}destroy(){var t;(t=this.methodBuilder)==null||t.destroy(),this.unWritable(),this.taskBatchData.clear(),this.tasksqueue.clear(),this.tmpImageConfigMap.clear(),this.localPointsBatchData.clear(),this.fullWorker.terminate(),this.subWorker.terminate(),this.isActive=!1,this.clearAllResolveMap.clear(),this.snapshotMap.clear(),this.boundingRectMap.clear(),this.fullWorker.terminate(),this.subWorker.terminate()}get viewContainerManager(){return this.control.viewContainerManager}get collector(){return this.control.collector}get isRunSubWork(){var e;const t=(e=this.currentToolsData)==null?void 0:e.toolsType;return t===S.Pencil||t===S.LaserPen||t===S.Arrow||t===S.Straight||t===S.Ellipse||t===S.Rectangle||t===S.Star||t===S.Polygon||t===S.SpeechBalloon}get isCanDrawWork(){var e;const t=(e=this.currentToolsData)==null?void 0:e.toolsType;return t===S.Pencil||t===S.LaserPen||t===S.Arrow||t===S.Straight||t===S.Ellipse||t===S.Rectangle||t===S.Star||t===S.Polygon||t===S.SpeechBalloon||t===S.Triangle||t===S.Rhombus}get isUseZIndex(){var e;const t=(e=this.currentToolsData)==null?void 0:e.toolsType;return t===S.Pencil||t===S.Arrow||t===S.Straight||t===S.Ellipse||t===S.Rectangle||t===S.Star||t===S.Polygon||t===S.SpeechBalloon||t===S.Text||t===S.Image}get isCanRecordUndoRedo(){var e;const t=(e=this.currentToolsData)==null?void 0:e.toolsType;return t===S.Pencil||t===S.Eraser||t===S.PencilEraser||t===S.Arrow||t===S.Straight||t===S.Ellipse||t===S.Rectangle||t===S.Star||t===S.Polygon||t===S.SpeechBalloon||t===S.Text||t===S.Image}get isCanSentCursor(){var e;const t=(e=this.currentToolsData)==null?void 0:e.toolsType;return t===S.Pencil||t===S.Text||t===S.LaserPen||t===S.Arrow||t===S.Straight||t===S.Ellipse||t===S.Rectangle||t===S.Star||t===S.Polygon||t===S.SpeechBalloon||t===S.Triangle||t===S.Rhombus}get isCanStartEventConsum(){var e;const t=(e=this.currentToolsData)==null?void 0:e.toolsType;return t===S.Selector||t===S.Eraser||t===S.PencilEraser}async init(){await this.on(),this.internalMsgEmitterListener(),this.isActive=!0}async on(){if(!this.control.hasOffscreenCanvas()){console.info("no OffscreenCanvas");const{MainThreadManagerImpl:t}=await Promise.resolve().then(()=>require("./index-2kLI3OsH.js"));this.mainThread=new t(this);return}if(!this.fullWorkerUrl||!this.subWorkerUrl){console.error("no worker url config");return}this.fullWorker=new Worker(this.fullWorkerUrl,{type:"classic"}),this.subWorker=new Worker(this.subWorkerUrl,{type:"classic"}),this.subMainThreadWorker=new qf(this),this.fullWorker.onmessage=t=>{var e,i;if(t.data){const{render:n,sp:s,drawCount:a,workerTasksqueueCount:c,viewId:l}=t.data;this.isBusy&&c&&this.setWorkerTasksqueueCount(c),s!=null&&s.length&&this.collectorSyncData(s);const h=(n==null?void 0:n.length)&&n||[];if(a&&l){if(this.setWorkDrawCount(a),this.wokerDrawCount<1/0){const u=Math.max(this.maxDrawCount,this.wokerDrawCount);this.setMaxDrawCount(u),this.control.priority==="ui"?(e=this.subMainThreadWorker)==null||e.notifyDrawCount(l):this.clearReRenders(this.wokerDrawCount)}else this.setMaxDrawCount(0),this.control.priority==="ui"?(i=this.subMainThreadWorker)==null||i.clearDrawCount(l):this.clearReRenders(1/0);if(this.reRenders.size)for(const u of this.reRenders.values())h.push(...u)}h.length&&this.viewContainerManager.render(h)}},this.subWorker.onmessage=t=>{if(t.data){const{render:e,sp:i,drawCount:n}=t.data;i!=null&&i.length&&this.collectorSyncData(i);const s=(e==null?void 0:e.length)&&e||[];if(this.control.priority==="cpu"&&E.isNumber(n)){if(this.setSubWorkerDrawCount(n),this.wokerDrawCount<1/0){const a=Math.max(this.maxDrawCount,this.subWorkerDrawCount);this.setMaxDrawCount(a)}if(e!=null&&e.length)if(this.subWorkerDrawCount>this.wokerDrawCount){const a=[];for(const c of e)c.imageBitmap&&(c.isUnClose=!0,a.push(c));this.reRenders.set(this.subWorkerDrawCount,a)}else this.reRenders.size&&this.clearReRenders(this.subWorkerDrawCount)}s.length&&this.viewContainerManager.render(s)}}}clearReRenders(t=1/0){for(const e of this.reRenders.keys())if(E.isNumber(Number(e))&&Number(e)<=t){const i=this.reRenders.get(Number(e));i==null||i.forEach(n=>{var s;(s=n.imageBitmap)==null||s.close()}),this.reRenders.delete(e)}}get isBusy(){return this.getTasksqueueState()===b.Doing}getLockSentEventCursor(){return this.isLockSentEventCursor}setLockSentEventCursor(t){this.isLockSentEventCursor=t}getTasksqueueState(){return this.useTasksqueue&&b.Doing||b.Done}setMaxDrawCount(t){this.maxDrawCount=t}getWorkDrawCount(){return this.wokerDrawCount}getSubWorkerDrawCount(){return this.subWorkerDrawCount}getMaxDrawCount(){return this.maxDrawCount}setWorkDrawCount(t){this.wokerDrawCount=t}setSubWorkerDrawCount(t){this.subWorkerDrawCount=t}setWorkerTasksqueueCount(t){const e=Math.max(this.workerTasksqueueCount||0,t);this.workerTasksqueueCount=e}collectorSyncData(t){var i,n,s;let e=!1;for(const a of t){const{type:c,selectIds:l,opt:h,selectRect:u,strokeColor:d,fillColor:p,willSyncService:f,isSync:I,imageBitmap:y,canvasHeight:v,canvasWidth:w,rect:m,op:T,canTextEdit:N,points:C,selectorColor:z,canRotate:L,scaleType:j,textOpt:A,toolsType:P,workId:R,viewId:D,dataType:G,canLock:ct,isLocked:et,shapeOpt:H,toolsTypes:J,thickness:Q,strokeType:V,useStroke:K}=a;if(!D)return;const nt=a.scenePath||this.viewContainerManager.getCurScenePath(D);switch(c){case x.Select:{const q=l!=null&&l.length?{...u,selectIds:l,canvasHeight:v,canvasWidth:w,points:C}:void 0;q&&(h!=null&&h.strokeColor)&&(q.selectorColor=h.strokeColor),q&&z&&(q.selectorColor=z),q&&d&&(q.strokeColor=d),q&&(h!=null&&h.fillColor)&&(q.fillColor=h.fillColor),q&&p&&(q.fillColor=p),q&&E.isBoolean(L)&&(q.canRotate=L),q&&j&&(q.scaleType=j),q&&N&&(q.canTextEdit=N),q&&A&&(q.textOpt=A),q&&E.isBoolean(ct)&&(q.canLock=ct),q&&E.isBoolean(et)&&(q.isLocked=et),q&&H&&(q.shapeOpt=H),q&&J&&(q.toolsTypes=J),q&&Q&&(q.thickness=Q),q&&V&&(q.strokeType=V),q&&E.isBoolean(K)&&(q.useStroke=K),D&&this.viewContainerManager.showFloatBar(D,!!q,q),f&&((i=this.collector)==null||i.dispatch({type:c,selectIds:l,opt:h,isSync:I,viewId:D,scenePath:nt}));break}case x.Snapshot:if(y&&nt){const q=this.snapshotMap.get(nt);q&&q(y)}break;case x.BoundingBox:if(m&&nt){const q=this.boundingRectMap.get(nt);q&&q(m)}break;case x.Cursor:T&&this.control.cursor.collectServiceCursor({...a});break;case x.Clear:if(D){this.viewContainerManager.showFloatBar(D,!1);const q=(n=this.clearAllResolveMap.get(D))==null?void 0:n.resolve;q&&q(D)}break;case x.TextUpdate:if(P===S.Text&&R&&D){const q=this.viewContainerManager.transformToOriginPoint((h==null?void 0:h.boxPoint)||[0,0],D),ot=(h==null?void 0:h.boxSize)||[0,0],rt=(s=this.viewContainerManager.getView(D))==null?void 0:s.cameraOpt;h?this.control.textEditorManager.updateTextForWorker({x:q[0],y:q[1],w:ot[0],h:ot[1],scale:(rt==null?void 0:rt.scale)||1,workId:R,opt:h,dataType:G,viewId:D,canSync:f||!1,canWorker:!1}):this.control.textEditorManager.delete(R,f||!1,!1)}break;case x.GetTextActive:P===S.Text&&R&&D&&this.control.textEditorManager.updateTextForWorker({workId:R,isActive:!0,viewId:D,dataType:U.Local,canWorker:!1,canSync:!0},Date.now());break;default:e=!0;break}}e&&fe(()=>{this.collectorAsyncData(t)},this.maxLastSyncTime)}collectorAsyncData(t){var e,i,n,s;for(const a of t){const{type:c,op:l,workId:h,index:u,removeIds:d,ops:p,opt:f,updateNodeOpt:I,toolsType:y,isSync:v,viewId:w,isLockSentEventCursor:m}=a;if(!w){console.error("collectorAsyncData",a);return}const T=a.scenePath||this.viewContainerManager.getCurScenePath(w);switch(c){case x.DrawWork:{(e=this.collector)==null||e.dispatch({type:c,op:l,opt:f,toolsType:y,workId:h,index:u,isSync:v,viewId:w,scenePath:T,updateNodeOpt:I});break}case x.FullWork:{(i=this.collector)==null||i.dispatch({type:c,ops:p,workId:h,updateNodeOpt:I,opt:f,toolsType:y,isSync:v,viewId:w,scenePath:T}),this.willSelectorWorkId&&h&&h.toString()===this.willSelectorWorkId&&this.control.runEffectWork(()=>{this.setShapeSelectorByWorkId(this.willSelectorWorkId,w),this.willSelectorWorkId=void 0}),m&&fe(()=>{this.setLockSentEventCursor(!1)},this.maxLastSyncTime);break}case x.UpdateNode:{(n=this.collector)==null||n.dispatch({type:c,updateNodeOpt:I,workId:h,opt:f,ops:p,op:l,isSync:v,viewId:w,scenePath:T});break}case x.RemoveNode:{d&&this.control.textEditorManager.deleteBatch(d,!1,!1),(s=this.collector)==null||s.dispatch({type:c,removeIds:d,isSync:v,viewId:w,scenePath:T}),this.willSelectorWorkId&&(d!=null&&d.includes(this.willSelectorWorkId))&&(this.willSelectorWorkId=void 0);break}}}}async onLocalEventEnd(t,e){var l;const i=this.viewContainerManager.getView(e);if(!i)return;const{focusScenePath:n,cameraOpt:s}=i,a=this.viewContainerManager.transformToScenePoint(t,e),c=[];for(const h of this.localPointsBatchData.keys())if(((l=this.currentToolsData)==null?void 0:l.toolsType)===S.Text){const u=this.getLocalPointInfo(h),d=u==null?void 0:u.state;if(d&&d===b.Start){const p=this.currentLocalWorkData.toolsOpt;p.workState=b.Doing,p.boxPoint=a,p.boxSize=[p.fontSize,p.fontSize],this.control.textEditorManager.checkEmptyTextBlur(),this.control.textEditorManager.createTextForMasterController({workId:Date.now().toString(),x:t[0],y:t[1],scale:(s==null?void 0:s.scale)||1,opt:p,type:Ut.Text,isActive:!0,viewId:e,scenePath:n},Date.now())}this.deleteLocalPoint(h);continue}else this.pushLocalPoint(h,a,b.Done,e),c.push(h);if(c.length){try{if(await new Promise(u=>{setTimeout(async()=>{c.forEach(d=>{this.setLocalPointIsFullWork(d)}),this.delayWorkStateToDoneResolve=u,this.consume()},0)})&&c[0]){const u=c[0];c.forEach(d=>{this.deleteLocalPoint(d)}),this.willSelectorWorkId=u.toString()}}catch(h){console.log("error",h)}this.delayWorkStateToDoneResolve=void 0,c.length=0}}onLocalEventDoing(t,e){var n;if(((n=this.currentToolsData)==null?void 0:n.toolsType)===S.Text)return;this.currentLocalWorkData.workState===b.Start&&this.setCurrentLocalWorkData({...this.currentLocalWorkData,workState:b.Doing});let i=!1;for(const[s,{state:a}]of this.localPointsBatchData.entries())if(this.isAbled()&&a!==b.Pending){const c=this.viewContainerManager.transformToScenePoint(t,e);this.pushLocalPoint(s,c,a===b.Start?b.Doing:a,e),i=!0}if(i){this.runAnimation();return}this.useTasksqueue||this.hoverCursor(t,e)}onLocalEventStart(t,e){var a,c,l,h,u,d;this.viewContainerManager.focuedViewId!==e&&this.viewContainerManager.setFocuedViewId(e),this.isCanDrawWork&&this.control.room&&!this.control.room.disableDeviceInputs&&(this.control.room.disableDeviceInputs=!0);const i=((a=this.currentToolsData)==null?void 0:a.toolsType)===S.Selector?B:Date.now(),n=this.setZIndex(e);this.setCurrentLocalWorkData({workState:b.Start,toolsOpt:n,viewId:e});const s=this.viewContainerManager.transformToScenePoint(t,e);if(this.pushLocalPoint(i,s,b.Start,e,n),((c=this.currentToolsData)==null?void 0:c.toolsType)!==S.Text){if(this.control.textEditorManager.checkEmptyTextBlur(),this.isCanRecordUndoRedo&&this.internalMsgEmitter.emit("addUndoTicker",i,e),i&&n&&((l=this.currentToolsData)!=null&&l.toolsType)&&this.isCanStartEventConsum&&this.prepareOnceWork({workId:i,toolsOpt:n,viewId:e},(h=this.currentToolsData)==null?void 0:h.toolsType),this.maxDrawCount=0,this.wokerDrawCount=0,this.subWorkerDrawCount=0,this.clearReRenders(1/0),(u=this.subMainThreadWorker)==null||u.clearDrawCount(e),this.isCanDrawWork){const p=this.viewContainerManager.getCurScenePath(e);p&&((d=this.collector)!=null&&d.hasSelector(e,p))&&this.blurSelector(e,p)}this.consume()}}setLocalPointIsFullWork(t){const e=this.getLocalPointInfo(t);e&&(e.isFullWork=!0,this.localPointsBatchData.set(t,e))}pushLocalPoint(t,e,i,n,s){let a=this.getLocalPointInfo(t);i===b.Start?a={state:b.Start,points:e,opt:s||this.currentLocalWorkData.toolsOpt,isFullWork:!1,viewId:n}:a&&(a.state=i,a.points.push(e[0],e[1])),a&&this.localPointsBatchData.set(t,a)}deleteLocalPoint(t){this.localPointsBatchData.delete(t)}getLocalPointInfo(t){return this.localPointsBatchData.get(t)}getLocalPointsInfo(){return this.localPointsBatchData}correctStorage(t,e,i){var c;const n=new Map,s=[];Object.keys(t).forEach(l=>{var u,d;const h=(d=(u=t[l])==null?void 0:u.opt)==null?void 0:d.zIndex;E.isNumber(h)&&s.push([l,h])});const a=s.length&&((c=this.zIndexNodeMethod)==null?void 0:c.correct(s))||[];this.zIndexNodeMethod&&a.length&&(this.zIndexNodeMethod.setMinZIndex(a[0][1]||0,e),this.zIndexNodeMethod.setMaxZIndex(a[a.length-1][1]||0,e));for(const[l,h]of a){if(!t[l])continue;const u=t[l];u.opt&&E.isNumber(u.opt.zIndex)&&u.opt.zIndex!==h&&(u.opt.zIndex=h,n.set(l,u))}return n.size&&n.forEach((l,h)=>{var u;(u=this.collector)==null||u.updateValue(h,l,{viewId:e,scenePath:i,isSync:!0}),t[h]=l}),t}async originalEventLintener(t,e,i){if(this.isAbled())switch(t){case b.Start:this.setLocalWorkViewId(i),i&&this.onLocalEventStart(e,i);break;case b.Doing:i&&i===this.getLocalWorkViewId()&&this.onLocalEventDoing(e,i);break;case b.Done:i&&i===this.getLocalWorkViewId()&&await this.onLocalEventEnd(e,i);break}}getLocalWorkViewId(){return this.localWorkViewId}setLocalWorkViewId(t){this.localWorkViewId=t}setCurrentToolsData(t){var n,s,a;const e=t.toolsType,i=((n=this.currentToolsData)==null?void 0:n.toolsType)!==t.toolsType;if(super.setCurrentToolsData(t),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:x.UpdateTools,dataType:U.Local,toolsType:e,opt:{...t.toolsOpt,syncUnitTime:this.maxLastSyncTime},isRunSubWork:this.isRunSubWork,viewId:We}),this.runAnimation()}}prepareOnceWork(t,e){const{workId:i,toolsOpt:n,viewId:s}=t;this.queryTaskBatchData({msgType:x.CreateWork,dataType:U.Local,viewId:s,toolsType:e}).forEach(a=>{this.taskBatchData.delete(a)}),this.taskBatchData.add({msgType:x.CreateWork,workId:i,toolsType:e,opt:{...n,syncUnitTime:this.maxLastSyncTime},dataType:U.Local,isRunSubWork:this.isRunSubWork,viewId:s}),this.runAnimation()}createViewWorker(t,e){const{offscreenCanvasOpt:i,layerOpt:n,dpr:s,cameraOpt:a}=e;this.taskBatchData.add({msgType:x.Init,dataType:U.Local,viewId:t,offscreenCanvasOpt:i,layerOpt:n,dpr:s,cameraOpt:a,isRunSubWork:!0,isSafari:navigator.userAgent.indexOf("Safari")!==-1&&navigator.userAgent.indexOf("Chrome")===-1}),this.isBusy&&this.destroyTaskQueue(),this.consume()}destroyViewWorker(t,e=!1){var i;this.getLocalWorkViewId()===t&&this.setLocalWorkViewId(void 0),this.zIndexNodeMethod&&this.zIndexNodeMethod.clearZIndex(t),this.taskBatchData.add({msgType:x.Destroy,dataType:U.Local,viewId:t,isRunSubWork:!0}),this.consume(),e||(i=this.collector)==null||i.dispatch({type:x.Clear,viewId:t})}onServiceDerive(t,e){var p,f,I,y,v;const{newValue:i,oldValue:n,viewId:s,scenePath:a}=e,c=E.cloneDeep(i)||{},l=t;let h=c.type;if(!i&&n){if(l&&((p=this.collector)==null?void 0:p.getLocalId(l))===B){this.collector.isOwn(l)?this.blurSelector(s,a):this.blurSelector(s,a,l);return}if(h=x.RemoveNode,n.toolsType===S.LaserPen)return}const u=(f=this.viewContainerManager.getView(s))==null?void 0:f.focusScenePath;if(u&&u!==a)return;if(h&&l){const w=c;if(w.workId=(I=this.collector)!=null&&I.isOwn(l)?(y=this.collector)==null?void 0:y.getLocalId(l):l,w.msgType=h,w.toolsType===S.LaserPen&&(w.isRunSubWork=!0),w.dataType=U.Service,w.viewId=s,w.scenePath=a,w.selectIds&&(w.selectIds=w.selectIds.map(m=>{var T,N;return(T=this.collector)!=null&&T.isOwn(m)?(N=this.collector)==null?void 0:N.getLocalId(m):m})),w&&w.toolsType===S.Text||(n==null?void 0:n.toolsType)===S.Text){this.control.textEditorManager.onServiceDerive(w);return}this.taskBatchData.add(w)}this.runAnimation();const d=e.newValue&&((v=e.newValue.opt)==null?void 0:v.zIndex);if(this.zIndexNodeMethod&&E.isNumber(d)){const w=this.zIndexNodeMethod.getMinZIndex(s);this.zIndexNodeMethod.getMaxZIndex(s)<d&&this.zIndexNodeMethod.setMaxZIndex(d,s),w>d&&this.zIndexNodeMethod.setMinZIndex(d,s)}}pullServiceData(t,e,i={isAsync:!1,useAnimation:!1}){var c,l,h,u;let n=(c=this.collector)==null?void 0:c.getStorageData(t,e);const{isAsync:s,useAnimation:a}=i;if(n){n=this.correctStorage(n,t,e);const d=Object.keys(n);for(const p of d){const f=(l=n[p])==null?void 0:l.type;if(f&&p){const I=n[p];if(I.workId=(h=this.collector)!=null&&h.isOwn(p)?(u=this.collector)==null?void 0:u.getLocalId(p):p,I.msgType=f,I.dataType=U.Service,I.viewId=t,I.scenePath=e,I.useAnimation=!!a,I.selectIds&&(I.selectIds=I.selectIds.map(y=>{var v,w;return(v=this.collector)!=null&&v.isOwn(y)?(w=this.collector)==null?void 0:w.getLocalId(y):y})),I.toolsType===S.Text){this.control.textEditorManager.onServiceDerive(I);continue}this.taskBatchData.add(I)}this.internalMsgEmitter.emit("excludeIds",d,t)}s?this.consume():this.runAnimation()}}runAnimation(){!this.animationId&&!this.isBusy&&(this.animationId=requestAnimationFrame(this.consume.bind(this)))}consume(){var e;this.animationId=void 0;const{viewId:t}=this.currentLocalWorkData;if(this.tasksqueue.size){const i=this.consumeQueue(),n=!!i.size;if(this.taskBatchData.size)for(const s of this.taskBatchData.values())s.dataType===U.Service&&(i.add(s),this.taskBatchData.delete(s));i.size?(this.post(i),n&&this.tasksqueue.clear()):this.tasksqueue.size&&(this.animationId=requestAnimationFrame(this.consume.bind(this)));return}if(this.isAbled()&&this.localPointsBatchData.size&&t)for(const[i,{state:n,isFullWork:s,points:a,opt:c}]of this.localPointsBatchData.entries()){if(n===b.Done&&!s||n===b.Start&&!this.isCanStartEventConsum)continue;const l=a.map(h=>h);l.length&&(this.delayWorkStateToDoneResolve&&n===b.Done&&(this.delayWorkStateToDoneResolve(!0),this.setLockSentEventCursor(!0)),this.taskBatchData.add({op:l,workState:n,workId:i,dataType:U.Local,msgType:x.DrawWork,isRunSubWork:this.isRunSubWork,toolsType:(e=this.currentToolsData)==null?void 0:e.toolsType,viewId:t,scenePath:t&&this.viewContainerManager.getCurScenePath(t),opt:c,isLockSentEventCursor:this.getLockSentEventCursor(),syncUnitTime:this.maxLastSyncTime}),a.length=0)}this.taskBatchData.size&&(this.post(this.taskBatchData),this.taskBatchData.clear()),this.taskBatchData.size&&(this.animationId=requestAnimationFrame(this.consume.bind(this)))}unWritable(){this.setCurrentLocalWorkData({workState:b.Unwritable,workId:void 0})}abled(){this.setCurrentLocalWorkData({workState:b.Pending,workId:void 0})}isAbled(){return this.currentLocalWorkData.workState!==b.Unwritable}post(t){var i;if(!this.control.hasOffscreenCanvas()){if(!this.mainThread){let n=[];n=E.cloneDeep([...t]),setTimeout(()=>{for(const s of n)this.taskBatchData.add(s)},0);return}this.mainThread.consume(t);return}this.fullWorker.postMessage(t);const e=new Set;for(const n of t.values()){const s=n.msgType;(s===x.Init||s===x.Clear||s===x.Destroy||s===x.UpdateCamera||n.isRunSubWork)&&e.add(n)}e.size&&(this.subWorker.postMessage(e),this.control.priority==="ui"&&((i=this.subMainThreadWorker)==null||i.consume(e)))}updateNode(t,e,i,n){this.taskBatchData.add({msgType:x.UpdateNode,workId:t,updateNodeOpt:e,viewId:i,scenePath:n,dataType:U.Local}),this.runAnimation()}destroyTaskQueue(){this.useTasksqueue=!1,this.useTasksClockId&&(clearTimeout(this.useTasksClockId),this.useTasksClockId=void 0),this.mainTasksqueueCount=void 0,this.workerTasksqueueCount=void 0}updateCamera(t,e){var i;this.useTasksqueue||((i=this.methodBuilder)==null||i.pause(),this.blurCursor(t),this.checkDrawingWork(t),this.useTasksqueue=!0,this.mainTasksqueueCount=1,this.workerTasksqueueCount=1),this.useTasksqueue&&(this.tasksqueue.set(t,{msgType:x.UpdateCamera,dataType:U.Local,cameraOpt:{...e,width:e.width,height:e.height},scenePath:this.viewContainerManager.getCurScenePath(t),isRunSubWork:!0,viewId:t}),this.consume(),this.useTasksClockId&&clearTimeout(this.useTasksClockId),this.updateCameraDone())}updateCameraDone(){this.useTasksClockId=setTimeout(()=>{var t,e;this.useTasksClockId=void 0,this.mainTasksqueueCount===this.workerTasksqueueCount?(this.tasksqueue.size&&this.consume(),this.useTasksqueue=!1,this.mainTasksqueueCount=void 0,this.workerTasksqueueCount=void 0,this.control.priority==="ui"&&((t=this.subMainThreadWorker)==null||t.updateCamera()),(e=this.methodBuilder)==null||e.recover(),this.runAnimation()):this.updateCameraDone()},this.maxLastSyncTime)}consumeQueue(){const t=new Set;let e=!this.isBusy;if(this.isBusy&&this.mainTasksqueueCount&&this.workerTasksqueueCount&&this.mainTasksqueueCount<=this.workerTasksqueueCount&&(e=!0),e){this.mainTasksqueueCount&&this.workerTasksqueueCount&&this.mainTasksqueueCount++,t.add({msgType:x.TasksQueue,dataType:U.Local,isRunSubWork:!0,mainTasksqueueCount:this.mainTasksqueueCount,tasksqueue:this.tasksqueue,viewId:""});for(const[i,n]of this.tasksqueue.entries())n.cameraOpt&&this.control.textEditorManager.onCameraChange(n.cameraOpt,i)}return t}async clearViewScenePath(t,e){var i;if(this.control.textEditorManager.clear(t,e),this.queryTaskBatchData({msgType:x.Clear,dataType:U.Local,viewId:t}).forEach(n=>{this.taskBatchData.delete(n)}),this.taskBatchData.add({dataType:U.Local,msgType:x.Clear,viewId:t}),this.runAnimation(),!e){const n=this.viewContainerManager.getCurScenePath(t);(i=this.collector)==null||i.dispatch({type:x.Clear,viewId:t,scenePath:n})}this.zIndexNodeMethod&&this.zIndexNodeMethod.clearZIndex(t),this.localPointsBatchData.clear(),await new Promise(n=>{const s=this.clearAllResolveMap.get(t)||{resolve:void 0,timer:void 0};s.timer&&clearTimeout(s.timer),s.resolve=n,s.timer=setTimeout(()=>{const a=this.clearAllResolveMap.get(t);a!=null&&a.resolve&&a.resolve(t)},this.maxLastSyncTime),this.clearAllResolveMap.set(t,s)}).then(n=>{this.clearAllResolveMap.delete(n)})}internalMsgEmitterListener(){var t;this.methodBuilder=new X([O.CopyNode,O.SetColorNode,O.DeleteNode,O.RotateNode,O.ScaleNode,O.TranslateNode,O.ZIndexNode,O.RotateNode,O.SetFontStyle,O.SetPoint,O.SetLock,O.SetShapeOpt]).registerForMainEngine(Z.MainEngine,this.control),this.zIndexNodeMethod=(t=this.methodBuilder)==null?void 0:t.getBuilder(O.ZIndexNode)}setZIndex(t){const e=this.currentToolsData&&E.cloneDeep(this.currentToolsData.toolsOpt);return e&&this.zIndexNodeMethod&&this.isUseZIndex&&(this.zIndexNodeMethod.addMaxLayer(t),e.zIndex=this.zIndexNodeMethod.getMaxZIndex(t)),e}checkDrawingWork(t){var n,s,a;let e=!1;const i=[];for(const[c,{state:l,viewId:h,points:u,opt:d}]of this.localPointsBatchData.entries())if(t===h&&l===b.Start||l===b.Doing){if(l===b.Doing&&this.isCanDrawWork){Number(c)&&Number(c)+60>Date.now()&&(i.push(c.toString()),this.taskBatchData.add({msgType:x.RemoveNode,workId:c,viewId:h,dataType:U.Local,isRunSubWork:!0}));const p=u.map(f=>f);this.taskBatchData.add({op:p,workState:b.Done,workId:c,dataType:U.Local,msgType:x.DrawWork,isRunSubWork:this.isRunSubWork,toolsType:(n=this.currentToolsData)==null?void 0:n.toolsType,viewId:h,opt:d,scenePath:h&&this.viewContainerManager.getCurScenePath(h)}),e=!0}this.deleteLocalPoint(c)}if((e||i.length)&&(this.consume(),i.length)){const c=(s=this.viewContainerManager.getView(t))==null?void 0:s.focusScenePath;(a=this.collector)==null||a.dispatch({type:x.RemoveNode,removeIds:i,viewId:t,scenePath:c})}}removeDrawingWork(t){var i,n;const e=[];for(const[s,{state:a,viewId:c}]of this.localPointsBatchData.entries())(t===c&&a===b.Start||a===b.Doing)&&(this.deleteLocalPoint(s),a===b.Doing&&this.isCanDrawWork&&(e.push(s.toString()),this.taskBatchData.add({msgType:x.RemoveNode,workId:s,viewId:c,dataType:U.Local,isRunSubWork:!0})));if(e.length){this.consume();const s=(i=this.viewContainerManager.getView(t))==null?void 0:i.focusScenePath;(n=this.collector)==null||n.dispatch({type:x.RemoveNode,removeIds:e,viewId:t,scenePath:s})}}hoverCursor(t,e){var i;if(((i=this.currentToolsData)==null?void 0:i.toolsType)===S.Selector){const n=this.viewContainerManager.getView(e);if(n&&n.displayer&&n.displayer.vDom){const c=n.displayer.vDom.state.floatBarData;if(c){const{x:l,y:h,w:u,h:d}=c;if(Is(t,{x:l,y:h,w:u,h:d}))return}}const s=this.viewContainerManager.transformToScenePoint(t,e),a={msgType:x.CursorHover,dataType:U.Local,point:s,toolsType:this.currentToolsData.toolsType,opt:this.currentToolsData.toolsOpt,isRunSubWork:!1,viewId:e};this.queryTaskBatchData({msgType:x.CursorHover,dataType:U.Local,toolsType:this.currentToolsData.toolsType,viewId:e}).forEach(c=>{this.taskBatchData.delete(c)}),this.taskBatchData.add(a),this.runAnimation()}}blurCursor(t){var i;if(((i=this.currentToolsData)==null?void 0:i.toolsType)!==S.Selector)return;const e={msgType:x.CursorBlur,dataType:U.Local,isRunSubWork:!1,viewId:t};this.queryTaskBatchData({msgType:x.CursorHover,dataType:U.Local,viewId:t}).forEach(n=>{this.taskBatchData.delete(n)}),this.taskBatchData.add(e),this.consume()}sendCursorEvent(t,e){if(!this.currentLocalWorkData||this.currentLocalWorkData.workState===b.Unwritable||!this.currentToolsData||!this.isCanSentCursor)return;let i=[void 0,void 0];this.currentToolsData&&(this.isCanDrawWork||this.currentToolsData.toolsType===S.Text)&&!this.localPointsBatchData.size&&!this.getLockSentEventCursor()&&(i=t,this.control.cursor.sendEvent(i,e))}getBoundingRect(t){var i,n;if(!((i=this.boundingRectMap)==null?void 0:i.get(t))){const s=(n=this.collector)==null?void 0:n.getScenePathData(t);if(!s)return;if(Object.keys(s).forEach(a=>{var c;((c=this.collector)==null?void 0:c.getLocalId(a))===B&&delete s[a]}),Object.keys(s).length&&this.viewContainerManager.mainView&&this.viewContainerManager.mainView.cameraOpt){const a={msgType:x.BoundingBox,dataType:U.Local,scenePath:t,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(t,c)}).then(c=>(this.boundingRectMap.delete(t),c))}}}getSnapshot(t,e,i,n){var a,c,l,h,u;if(!((a=this.snapshotMap)==null?void 0:a.get(t))){const d=(c=this.collector)==null?void 0:c.getViewIdBySecenPath(t);if(!d)return;const p=(l=this.collector)==null?void 0:l.getStorageData(d,t);if(!p)return;if(Object.keys(p).forEach(f=>{var I;((I=this.collector)==null?void 0:I.getLocalId(f))===B&&delete p[f]}),Object.keys(p).length){const f=this.viewContainerManager.mainView;if(!f)return;const I=e||((h=f.cameraOpt)==null?void 0:h.width),y=i||((u=f.cameraOpt)==null?void 0:u.height),v={msgType:x.Snapshot,dataType:U.Local,scenePath:t,scenes:p,w:I,h:y,cameraOpt:n&&{...n,width:I,height:y}||f.cameraOpt,isRunSubWork:!0,viewId:f.id};return this.taskBatchData.add(v),this.runAnimation(),new Promise(w=>{this.snapshotMap.set(t,w)}).then(w=>(this.snapshotMap.delete(t),w))}}}queryTaskBatchData(t){const e=[];if(t)for(const i of this.taskBatchData.values()){let n=!0;for(const[s,a]of Object.entries(t))if(i[s]!==a){n=!1;break}n&&e.push(i)}return e}insertImage(t){const e=this.viewContainerManager.mainView,i=e==null?void 0:e.id,n=e==null?void 0:e.focusScenePath;if(i&&n){const{src:s,uuid:a}=t;if(a&&!s){this.tmpImageConfigMap.set(a,t);return}const c=Date.now();mt.InternalMsgEmitter.emit("addUndoTicker",c,i);const l={...t};this.zIndexNodeMethod&&(this.zIndexNodeMethod.addMaxLayer(i),l.zIndex=this.zIndexNodeMethod.getMaxZIndex(i)),this.taskBatchData.add({msgType:x.FullWork,dataType:U.Local,toolsType:S.Image,workId:t.uuid,opt:l,viewId:i,willRefresh:!0,willSyncService:!0}),this.runAnimation()}}lockImage(t,e){var a,c;const i=this.viewContainerManager.mainView,n=i==null?void 0:i.id,s=i==null?void 0:i.focusScenePath;if(n&&s&&this.collector){const l=this.collector.getStorageData(n,s);if(!l)return;for(const[h,u]of Object.entries(l))if(u&&u.toolsType===S.Image&&u.opt.uuid===t){const d=Date.now();mt.InternalMsgEmitter.emit("addUndoTicker",d,n);const p=(a=this.collector)!=null&&a.isOwn(h)?(c=this.collector)==null?void 0:c.getLocalId(h):h,f={...u.opt,locked:e};this.taskBatchData.add({msgType:x.FullWork,dataType:U.Local,toolsType:S.Image,workId:p,opt:f,viewId:n,willRefresh:!0,willSyncService:!0}),this.runAnimation();return}}}completeImageUpload(t,e){const i=this.viewContainerManager.mainView,n=i==null?void 0:i.id,s=i==null?void 0:i.focusScenePath;if(n&&s){const a=this.tmpImageConfigMap.get(t);a&&(a.src=e,this.insertImage(a),this.tmpImageConfigMap.delete(t));return}}getImagesInformation(t){const e=[];if(this.collector){const i=this.collector.getScenePathData(t);if(!i)return e;for(const n of Object.values(i))if(n&&n.toolsType===S.Image){const s=n.opt;e.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 e}setShapeSelectorByWorkId(t,e){this.taskBatchData.add({workId:B,selectIds:[t],msgType:x.Select,dataType:U.Local,viewId:e,willSyncService:!0}),this.runAnimation()}blurSelector(t,e,i){this.taskBatchData.add({workId:i||B,selectIds:[],msgType:x.Select,dataType:U.Service,viewId:t,scenePath:e}),this.runAnimation()}consoleWorkerInfo(){this.taskBatchData.add({msgType:x.Console,dataType:U.Local,isRunSubWork:!0,viewId:""}),this.consume()}setPriority(t){var n,s;const e=new Set,i=new Set;if(t==="cpu"&&((n=this.subMainThreadWorker)==null||n.destroy(),e.add({msgType:x.PriorityWorker,viewId:We,dataType:U.Local,isRunSubWork:!0})),t==="ui"){e.add({msgType:x.PriorityMainThreadWorker,viewId:We,dataType:U.Local,isRunSubWork:!0});const a=this.viewContainerManager.mainView;if(a){const l=this.viewContainerManager.getViewInitData(a.id);if(l){const{offscreenCanvasOpt:h,layerOpt:u,dpr:d,cameraOpt:p}=l;i.add({msgType:x.Init,dataType:U.Local,viewId:a.id,offscreenCanvasOpt:h,layerOpt:u,dpr:d,cameraOpt:p,isRunSubWork:!0,isSafari:navigator.userAgent.indexOf("Safari")!==-1&&navigator.userAgent.indexOf("Chrome")===-1})}}const c=this.viewContainerManager.appViews;for(const l of c.keys()){const h=this.viewContainerManager.getViewInitData(l);if(h){const{offscreenCanvasOpt:u,layerOpt:d,dpr:p,cameraOpt:f}=h;i.add({msgType:x.Init,dataType:U.Local,viewId:l,offscreenCanvasOpt:u,layerOpt:d,dpr:p,cameraOpt:f,isRunSubWork:!0,isSafari:navigator.userAgent.indexOf("Safari")!==-1&&navigator.userAgent.indexOf("Chrome")===-1})}}}e.size&&this.subWorker.postMessage(e),i.size&&((s=this.subMainThreadWorker)==null||s.consume(i))}}var eg=Rt,og=function(){return eg.Date.now()},ig=og,sg=/\s/;function ng(r){for(var o=r.length;o--&&sg.test(r.charAt(o)););return o}var rg=ng,ag=rg,cg=/^\s+/;function lg(r){return r&&r.slice(0,ag(r)+1).replace(cg,"")}var hg=lg,ug=ie,dg=Ht,pg="[object Symbol]";function fg(r){return typeof r=="symbol"||dg(r)&&ug(r)==pg}var gg=fg,Mg=hg,vi=qt,yg=gg,Ni=NaN,wg=/^[-+]0x[0-9a-f]+$/i,mg=/^0b[01]+$/i,Ig=/^0o[0-7]+$/i,vg=parseInt;function Ng(r){if(typeof r=="number")return r;if(yg(r))return Ni;if(vi(r)){var o=typeof r.valueOf=="function"?r.valueOf():r;r=vi(o)?o+"":o}if(typeof r!="string")return r===0?r:+r;r=Mg(r);var t=mg.test(r);return t||Ig.test(r)?vg(r.slice(2),t?2:8):wg.test(r)?Ni:+r}var Tg=Ng,Sg=qt,fo=ig,Ti=Tg,Cg="Expected a function",kg=Math.max,zg=Math.min;function xg(r,o,t){var e,i,n,s,a,c,l=0,h=!1,u=!1,d=!0;if(typeof r!="function")throw new TypeError(Cg);o=Ti(o)||0,Sg(t)&&(h=!!t.leading,u="maxWait"in t,n=u?kg(Ti(t.maxWait)||0,o):n,d="trailing"in t?!!t.trailing:d);function p(C){var z=e,L=i;return e=i=void 0,l=C,s=r.apply(L,z),s}function f(C){return l=C,a=setTimeout(v,o),h?p(C):s}function I(C){var z=C-c,L=C-l,j=o-z;return u?zg(j,n-L):j}function y(C){var z=C-c,L=C-l;return c===void 0||z>=o||z<0||u&&L>=n}function v(){var C=fo();if(y(C))return w(C);a=setTimeout(v,I(C))}function w(C){return a=void 0,d&&e?p(C):(e=i=void 0,s)}function m(){a!==void 0&&clearTimeout(a),l=0,e=c=i=a=void 0}function T(){return a===void 0?s:w(fo())}function N(){var C=fo(),z=y(C);if(e=arguments,i=this,c=C,z){if(a===void 0)return f(c);if(u)return clearTimeout(a),a=setTimeout(v,o),p(c)}return a===void 0&&(a=setTimeout(v,o)),s}return N.cancel=m,N.flush=T,N}var Lg=xg,bg=Lg,jg=qt,Dg="Expected a function";function Pg(r,o,t){var e=!0,i=!0;if(typeof r!="function")throw new TypeError(Dg);return jg(t)&&(e="leading"in t?!!t.leading:e,i="trailing"in t?!!t.trailing:i),bg(r,o,{leading:e,maxWait:o,trailing:i})}var Eg=Pg;const be=je(Eg);class Ag{constructor(o){M(this,"internalMsgEmitter");M(this,"control");M(this,"roomHotkeyCheckers");M(this,"tmpCopyStore",new Map);M(this,"tmpCopyCoordInfo");var i;const{control:t,internalMsgEmitter:e}=o;this.control=t,this.internalMsgEmitter=e,this.roomHotkeyCheckers=((i=this.control.room)==null?void 0:i.viewsParams.hotKeys.nodes)||[]}get isUseSelf(){var o;return((o=this.control.room)==null?void 0:o.disableDeviceInputs)||!1}get isSelector(){var o;return((o=this.control.worker.currentToolsData)==null?void 0:o.toolsType)===S.Selector}get collector(){return this.control.collector}get mainEngine(){return this.control.worker}get keyboardKind(){return/^Mac/i.test(navigator.platform)?"mac":"windows"}getEventKey(o){switch(o.type){case"keydown":return"KeyDown"}return"KeyUp"}onActiveHotkey(o){var i,n,s;const t=this.control.viewContainerManager.focuedViewId,e=(i=this.control.viewContainerManager.focuedView)==null?void 0:i.focusScenePath;if(t&&e)switch(o){case"delete":this.isSelector&&((n=this.collector)!=null&&n.hasSelector(t,e))&&X.emitMethod(Z.MainEngine,O.DeleteNode,{workIds:[B],viewId:t});break;case"copy":this.isSelector&&((s=this.collector)!=null&&s.hasSelector(t,e))&&this.copySelectorToTemp(t,e);break;case"paste":this.tmpCopyStore.size&&this.pasteTempToFocusView(t,e);break}(o==="changeToPencil"||o==="redo"||o==="undo")&&this.onSelfActiveHotkey(o)}colloctHotkey(o){if(this.isUseSelf){const t=this.checkHotkey(o);t&&this.onSelfActiveHotkey(t)}}onSelfActiveHotkey(o){switch(o){case"changeToPencil":this.setMemberState({currentApplianceName:st.pencil,useNewPencil:!0});break;case"changeToArrow":this.setMemberState({currentApplianceName:st.arrow});break;case"changeToClick":this.setMemberState({currentApplianceName:st.clicker});break;case"changeToEllipse":this.setMemberState({currentApplianceName:st.ellipse});break;case"changeToEraser":this.setMemberState({currentApplianceName:st.eraser,isLine:!0});break;case"changeToHand":this.setMemberState({currentApplianceName:st.hand});break;case"changeToLaserPointer":this.setMemberState({currentApplianceName:st.laserPointer});break;case"changeToSelector":this.setMemberState({currentApplianceName:st.selector});break;case"changeToRectangle":this.setMemberState({currentApplianceName:st.rectangle});break;case"changeToStraight":this.setMemberState({currentApplianceName:st.straight});break;case"redo":this.control.room&&!this.control.room.disableSerialization&&this.control.viewContainerManager.redo();break;case"undo":this.control.room&&!this.control.room.disableSerialization&&this.control.viewContainerManager.undo();break;case"changeToText":this.setMemberState({currentApplianceName:st.text});break}}checkHotkey(o){for(const t of this.roomHotkeyCheckers){const{kind:e,checker:i}=t;if(i({nativeEvent:o,kind:this.getEventKey(o),key:o.key,altKey:o.altKey,ctrlKey:o.ctrlKey,shiftKey:o.shiftKey},this.keyboardKind))return e}}copySelectorToTemp(o,t){var l,h;const e=this.control.viewContainerManager.getView(o),i=(h=(l=this.mainEngine)==null?void 0:l.methodBuilder)==null?void 0:h.getBuilder(O.CopyNode);if(!e||!this.collector||!i)return;const n=this.collector.transformKey(B),s=this.collector.getStorageData(o,t);if(!s)return;const a=s[n],c=a&&i.copySelector({viewId:o,store:a});c&&(this.tmpCopyCoordInfo=c==null?void 0:c.copyCoordInfo,this.tmpCopyStore=c==null?void 0:c.copyStores)}pasteTempToFocusView(o,t){var n,s;const e=this.control.viewContainerManager.getView(o),i=(s=(n=this.mainEngine)==null?void 0:n.methodBuilder)==null?void 0:s.getBuilder(O.CopyNode);if(!(!e||!this.tmpCopyCoordInfo||!this.tmpCopyStore.size||!this.collector||!i)&&e.viewData&&this.tmpCopyCoordInfo){const a=E.cloneDeep(this.tmpCopyCoordInfo.offset),c=this.tmpCopyCoordInfo.cameraOpt,l=e.viewData.camera;a.x=a.x+l.centerX-c.centerX,a.y=a.y+l.centerY-c.centerY;const h=Date.now();this.control.worker.internalMsgEmitter.emit("addUndoTicker",h,o),i.pasteSelector({viewId:o,scenePath:t,copyStores:E.cloneDeep(this.tmpCopyStore),copyCoordInfo:{offset:a,cameraOpt:l},undoTickerId:h})}}setMemberState(o){var t;(t=this.control.room)==null||t.setMemberState(o)}}const ze=class ze{constructor(o){M(this,"version",os);M(this,"plugin");M(this,"room");M(this,"play");M(this,"collector");M(this,"hasSwitchToSelectorEffect");M(this,"snapshootStateMap");M(this,"priority","cpu");M(this,"effectResolve");M(this,"hotkeyManager");M(this,"pluginOptions");M(this,"roomMember");M(this,"cursor");M(this,"textEditorManager");M(this,"worker");M(this,"onSceneChange",async(o,t)=>{var s;const e=this.viewContainerManager.getView(t);e!=null&&e.focusScenePath&&(s=this.collector)!=null&&s.hasSelector(t,e.focusScenePath)&&this.worker.blurSelector(t,e.focusScenePath),this.textEditorManager.checkEmptyTextBlur();const i=e==null?void 0:e.displayer;i&&(i.setActive(!1),await i.stopEventHandler());const n=o;n&&this.viewContainerManager.setViewScenePath(t,n),i==null||i.setActive(!0)});M(this,"onRoomMembersChange",o=>{this.roomMember.setRoomMembers(it.toJS(o))});M(this,"onMemberChange",be(o=>{if(!this.room||!this.worker||!o)return;const t=this.getToolsKey(o),e=this.getToolsOpt(t,o);this.worker.setCurrentToolsData(e),this.effectViewContainer(t),this.effectResolve&&this.effectResolve(!0)},100,{leading:!1}));M(this,"internalSceneChange",(o,t)=>{var e;(e=this.worker)==null||e.clearViewScenePath(o,!0).then(()=>{var i;(i=this.worker)==null||i.pullServiceData(o,t,{isAsync:!0,useAnimation:!1})})});M(this,"internalCameraChange",(o,t)=>{var e;(e=this.worker)==null||e.updateCamera(o,t)});const{displayer:t,plugin:e,options:i}=o;this.plugin=e,this.room=it.isRoom(t)?t:void 0,this.play=it.isPlayer(t)?t:void 0,this.pluginOptions=i,this.roomMember=new Pf;const n={control:this,internalMsgEmitter:ze.InternalMsgEmitter};this.cursor=new Rf(n),this.textEditorManager=new Of(n),this.worker=new tg(n),this.hotkeyManager=new Ag(n)}setPriority(o){var t;this.priority=o,this.hasOffscreenCanvas()&&((t=this.worker)==null||t.setPriority(o))}hasOffscreenCanvas(){return is==="worker"}bindPlugin(o){var t,e;this.plugin=o,this.collector&&this.collector.removeStorageStateListener(),this.collector=new vo(this,o,(e=(t=this.pluginOptions)==null?void 0:t.syncOpt)==null?void 0:e.interval),this.activePlugin()}destroy(){var o,t,e,i,n;this.roomMember.destroy(),(o=this.collector)==null||o.destroy(),(t=this.worker)==null||t.destroy(),(e=this.viewContainerManager)==null||e.destroy(),(i=this.cursor)==null||i.destroy(),(n=this.textEditorManager)==null||n.destory()}cleanCurrentScene(){const o=Date.now(),t=this.worker.getLocalWorkViewId()||this.viewContainerManager.focuedViewId;t&&(ze.InternalMsgEmitter.emit("addUndoTicker",o,t),this.worker.clearViewScenePath(t))}onWritableChange(o){var t,e;o?(e=this.worker)==null||e.abled():(t=this.worker)==null||t.unWritable()}getToolsKey(o){const t=o.currentApplianceName;switch(this.hasSwitchToSelectorEffect=!1,t){case st.text:return o.textCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),S.Text;case st.pencil:return o.useLaserPen?S.LaserPen:S.Pencil;case st.eraser:return S.Eraser;case st.pencilEraser:return S.PencilEraser;case st.selector:return S.Selector;case st.arrow:return o.arrowCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),S.Arrow;case st.straight:return o.straightCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),S.Straight;case st.ellipse:return o.ellipseCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),S.Ellipse;case st.rectangle:return o.rectangleCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),S.Rectangle;case st.shape:if(o.shapeCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),o.shapeType===Pt.Pentagram||o.shapeType===Pt.Star)return S.Star;if(o.shapeType===Pt.Polygon||o.shapeType===Pt.Triangle||o.shapeType===Pt.Rhombus)return S.Polygon;if(o.shapeType===Pt.SpeechBalloon)return S.SpeechBalloon;break}return S.Clicker}getToolsOpt(o,t){if(o===S.Clicker)return{toolsType:o,toolsOpt:{}};const e={strokeColor:Ae(t.strokeColor[0],t.strokeColor[1],t.strokeColor[2],t.strokeOpacity||1),thickness:t.strokeWidth,isOpacity:(t==null?void 0:t.strokeOpacity)&&t.strokeOpacity<1||(t==null?void 0:t.fillOpacity)&&t.fillOpacity<1||(t==null?void 0:t.textOpacity)&&t.textOpacity<1||(t==null?void 0:t.textBgOpacity)&&t.textBgOpacity<1||!1};switch(o){case S.Text:e.fontFamily=window.getComputedStyle(document.documentElement).getPropertyValue("font-family"),e.fontSize=(t==null?void 0:t.textSizeOverride)||(t==null?void 0:t.textSize)||Number(window.getComputedStyle(document.body).fontSize),e.textAlign=(t==null?void 0:t.textAlign)||"left",e.verticalAlign=(t==null?void 0:t.verticalAlign)||"middle",e.fontColor=(t==null?void 0:t.textColor)&&Ae(t.textColor[0],t.textColor[1],t.textColor[2],t.textOpacity||1)||e.strokeColor||"rgba(0,0,0,1)",e.fontBgColor=Array.isArray(t==null?void 0:t.textBgColor)&&Ae(t.textBgColor[0],t.textBgColor[1],t.textBgColor[2],t.textBgOpacity||1)||"transparent",e.bold=(t==null?void 0:t.bold)&&"bold"||void 0,e.italic=(t==null?void 0:t.italic)&&"italic"||void 0,e.underline=(t==null?void 0:t.underline)||void 0,e.lineThrough=(t==null?void 0:t.lineThrough)||void 0,e.text="",e.strokeColor=void 0;break;case S.Pencil:e.strokeType=(t==null?void 0:t.strokeType)||_.Normal;break;case S.PencilEraser:e.thickness=Math.min(3,Math.max(1,Math.floor(t.pencilEraserSize||1)))-1;break;case S.Eraser:e.thickness=Math.min(3,Math.max(1,Math.floor(t.pencilEraserSize||1)))-1;break;case S.LaserPen:e.duration=(t==null?void 0:t.duration)||1,t!=null&&t.strokeType&&(t==null?void 0:t.strokeType)===_.Stroke?e.strokeType=_.Normal:e.strokeType=(t==null?void 0:t.strokeType)||_.Normal;break;case S.Arrow:case S.Straight:t!=null&&t.strokeType&&(t==null?void 0:t.strokeType)===_.Stroke?e.strokeType=_.Normal:e.strokeType=(t==null?void 0:t.strokeType)||_.Normal;break;case S.Ellipse:case S.Rectangle:case S.Star:case S.Polygon:case S.SpeechBalloon:t!=null&&t.strokeType&&(t==null?void 0:t.strokeType)===_.Stroke?e.strokeType=_.Normal:e.strokeType=(t==null?void 0:t.strokeType)||_.Normal,o===S.Star&&(t.shapeType===Pt.Pentagram?(e.vertices=10,e.innerVerticeStep=2,e.innerRatio=.4):t!=null&&t.vertices&&(t!=null&&t.innerVerticeStep)&&(t!=null&&t.innerRatio)&&(e.vertices=t.vertices,e.innerVerticeStep=t.innerVerticeStep,e.innerRatio=t.innerRatio)),o===S.Polygon&&(t.shapeType===Pt.Triangle?e.vertices=3:t.shapeType===Pt.Rhombus?e.vertices=4:t.vertices&&(e.vertices=t.vertices)),e.fillColor=(t==null?void 0:t.fillColor)&&Ae(t.fillColor[0],t.fillColor[1],t.fillColor[2],t==null?void 0:t.fillOpacity)||"transparent",o===S.SpeechBalloon&&(e.placement=t.placement||"bottomLeft");break}return{toolsType:o,toolsOpt:e}}effectViewContainer(o){var t,e,i,n,s;switch(o){case S.Text:case S.Pencil:case S.LaserPen:case S.Arrow:case S.Straight:case S.Rectangle:case S.Ellipse:case S.Star:case S.Polygon:case S.SpeechBalloon:case S.Triangle:case S.Rhombus:this.room.disableDeviceInputs=!0,(t=this.worker)==null||t.abled();break;case S.PencilEraser:case S.Eraser:case S.Selector:this.room.disableDeviceInputs=!1,(e=this.cursor)==null||e.unabled(),(i=this.worker)==null||i.abled();break;default:this.room.disableDeviceInputs=!1,(n=this.worker)==null||n.unWritable(),(s=this.cursor)==null||s.unabled();break}setTimeout(()=>{this.viewContainerManager.getAllViews().forEach(c=>{c!=null&&c.displayer&&c.displayer.bindToolsClass()})},0)}async getBoundingRect(o){var e,i,n,s,a;const t=await((e=this.worker)==null?void 0:e.getBoundingRect(o));if(t){const c=((n=(i=this.viewContainerManager.mainView)==null?void 0:i.viewData)==null?void 0:n.convertToPointInWorld({x:t.x,y:t.y}))||{x:t.x,y:t.y},l=((a=(s=this.viewContainerManager.mainView)==null?void 0:s.viewData)==null?void 0:a.camera.scale)||1;return{width:Math.floor(t.w/l)+1,height:Math.floor(t.h/l)+1,originX:c.x,originY:c.y}}}async screenshotToCanvas(o,t,e,i,n,s,a){const c=await this.worker.getSnapshot(t,e,i,n);c&&(o.drawImage(c,s||0,a||0),c.close())}async scenePreview(o,t){var s,a,c,l;const e=(s=this.collector)==null?void 0:s.getViewIdBySecenPath(o);if(!e)return;const i=this.viewContainerManager.getView(e);if(!i||!((a=i.cameraOpt)!=null&&a.width)||!((c=i.cameraOpt)!=null&&c.height))return;const n=await((l=this.worker)==null?void 0:l.getSnapshot(o));if(n&&this.worker){const h=document.createElement("canvas"),u=h.getContext("2d"),{width:d,height:p}=i.cameraOpt;h.width=d,h.height=p,u&&(u.drawImage(n,0,0),t.src=h.toDataURL(),t.onload=()=>{h.remove()},t.onerror=()=>{h.remove(),t.remove()}),n.close()}}switchToText(){var o;(o=this.room)==null||o.setMemberState({currentApplianceName:st.text})}switchToSelector(){var o;(o=this.room)==null||o.setMemberState({currentApplianceName:st.selector})}async runEffectWork(o){if(this.hasSwitchToSelectorEffect){const t=await new Promise(e=>{this.switchToSelector(),this.effectResolve=e});this.effectResolve=void 0,t&&o&&o()}}setSnapshootData(){var o;this.room&&(this.snapshootStateMap=new Map,this.snapshootStateMap.set("memberState",(o=this.room)==null?void 0:o.state.memberState))}getSnapshootData(o){var t;return(t=this.snapshootStateMap)==null?void 0:t.get(o)}clearSnapshootData(){var o;(o=this.snapshootStateMap)==null||o.clear(),this.snapshootStateMap=void 0}consoleWorkerInfo(){var o;(o=this.worker)==null||o.consoleWorkerInfo()}};M(ze,"InternalMsgEmitter",new xi);let mt=ze;const te=class te{constructor(o){M(this,"emitter",new xi);M(this,"undoStack");M(this,"redoStack");M(this,"worker");M(this,"control");M(this,"room");M(this,"isTicking");M(this,"undoTickerId");M(this,"viewId");M(this,"scenePath");M(this,"tickStartStorerCache");M(this,"excludeIds",new Set);M(this,"onChangeScene",E.debounce(()=>{const o=this.control.viewContainerManager.getCurScenePath(this.viewId);if(o){let t=this.undoStack.filter(i=>i.scenePath===o).length;const e=this.redoStack.filter(i=>i.scenePath===o).length;t===0&&e===0&&this.tickStartStorerCache&&this.scenePath===o&&(t=1),this.emitter.emit("onCanUndoStepsUpdate",t),this.emitter.emit("onCanRedoStepsUpdate",e)}},te.waitTime));const{control:t,internalMsgEmitter:e,viewId:i}=o;this.control=t,this.emitter=e,this.undoStack=[],this.redoStack=[],this.room=t.room,this.worker=t.worker,this.isTicking=!1,this.viewId=i}get collector(){return this.control.collector}addExcludeIds(o){if(this.isTicking)for(const t of o)this.excludeIds.add(t)}undoTickerStart(o,t){if(this.collector&&(this.undoTickerId!==o||this.scenePath!==t)){!this.undoTickerId&&!this.tickStartStorerCache&&!this.scenePath&&this.emitter.emit("onCanUndoStepsUpdate",1),this.undoTickerId&&this.viewId&&this.scenePath&&this.undoTickerEndSync(this.undoTickerId,this.viewId,this.scenePath),this.isTicking=!0;const e=this.collector.transformKey(B);this.excludeIds.add(e),this.undoTickerId=o,this.scenePath=t;const i=this.collector.getStorageData(this.viewId,t)||{};this.tickStartStorerCache=new Map(Object.entries(E.cloneDeep(i)))}}undoTickerEndSync(o,t,e){var i,n;if(o===this.undoTickerId&&e===this.scenePath&&t===this.viewId&&this.tickStartStorerCache){const s=((i=this.collector)==null?void 0:i.storage[t])&&((n=this.collector)==null?void 0:n.storage[t][e])||{},a=this.diffFun(this.tickStartStorerCache,new Map(Object.entries(s)));a.size&&(this.undoStack.push({id:o,type:2,data:E.cloneDeep(a),scenePath:e}),this.undoStack.length>te.MaxStackLength&&this.undoStack.shift(),this.emitter.emit("onCanUndoStepsUpdate",this.undoStack.length)),this.redoStack.length&&(this.redoStack.length=0,this.emitter.emit("onCanRedoStepsUpdate",this.redoStack.length)),this.isTicking=!1,this.scenePath=void 0,this.tickStartStorerCache=void 0,this.undoTickerId=void 0,this.excludeIds.clear()}}undo(o){this.undoTickerId&&this.tickStartStorerCache&&this.scenePath&&this.undoTickerEndSync(this.undoTickerId,this.viewId,this.scenePath);let t=this.undoStack.length-1;for(;t>=0;){if(this.undoStack[t].scenePath===o){const s=this.undoStack[t];s&&(this.redoStack.push(s),s.type===2&&s.data&&this.refreshPlugin(s)),this.undoStack.splice(t,1);break}t--}const e=this.undoStack.filter(n=>n.scenePath===o).length,i=this.redoStack.filter(n=>n.scenePath===o).length;return this.emitter.emit("onCanUndoStepsUpdate",e),this.emitter.emit("onCanRedoStepsUpdate",i),e}redo(o){let t=this.redoStack.length-1;for(;t>=0;){if(this.redoStack[t].scenePath===o){const s=this.redoStack[t];s&&(!this.undoTickerId&&s.tickStartStorerCache?(this.undoTickerId=s.id,this.tickStartStorerCache=s.tickStartStorerCache,this.scenePath=s.scenePath):this.undoStack.push(s),s.type===2&&s.data&&this.refreshPlugin(s,!0)),this.redoStack.splice(t,1);break}t--}const e=this.undoStack.filter(n=>n.scenePath===o).length,i=this.redoStack.filter(n=>n.scenePath===o).length;return this.emitter.emit("onCanUndoStepsUpdate",e),this.emitter.emit("onCanRedoStepsUpdate",i),i}clear(){this.clearUndo(),this.clearRedo()}clearUndo(){this.undoStack.length=0,this.emitter.emit("onCanUndoStepsUpdate",this.undoStack.length)}clearRedo(){this.redoStack.length=0,this.emitter.emit("onCanRedoStepsUpdate",this.redoStack.length)}canUndo(){return!!this.undoStack.length}canRedo(){return!!this.redoStack.length}onFocusView(){const o=this.control.viewContainerManager.getCurScenePath(this.viewId);if(o){let t=this.undoStack.filter(i=>i.scenePath===o).length;const e=this.redoStack.filter(i=>i.scenePath===o).length;t===0&&e===0&&this.tickStartStorerCache&&this.scenePath===o&&(t=1),this.emitter.emit("onCanUndoStepsUpdate",t),this.emitter.emit("onCanRedoStepsUpdate",e)}}diffFun(o,t){const e=new Set,i=o.keys(),n=t.keys();for(const s of i){if(this.excludeIds.has(s))continue;const a=o.get(s),c=t.get(s);if(a&&c){if(E.isEqual(c,a))continue;e.add({dataType:3,key:s,data:[a,c]});continue}a&&e.add({dataType:2,key:s,data:a})}for(const s of n){if(this.excludeIds.has(s))continue;const a=t.get(s);a&&!o.has(s)&&e.add({dataType:1,key:s,data:a})}return e}isDrawEffectiveScene(o,t){const{key:e}=o;return!t.includes(e)}isDeleteEffectiveScene(o,t,e){var s;const{key:i}=o;if(!t.includes(i))return!1;const n=t.filter(a=>{var c,l;return((c=this.collector)==null?void 0:c.getLocalId(a))===B&&!((l=this.collector)!=null&&l.isOwn(a))}).map(a=>{var c;return(c=this.collector)==null?void 0:c.storage[this.viewId][e][a]});for(const a of n)if((s=a==null?void 0:a.selectIds)!=null&&s.includes(i))return!1;return!0}isOldEffectiveScene(o,t,e){var s;const{key:i}=o;if(!t.includes(i))return!1;const n=t.filter(a=>{var c,l;return((c=this.collector)==null?void 0:c.getLocalId(a))===B&&!((l=this.collector)!=null&&l.isOwn(a))}).map(a=>{var c;return(c=this.collector)==null?void 0:c.storage[this.viewId][e][a]});for(const a of n)if((s=a==null?void 0:a.selectIds)!=null&&s.includes(i))return!1;return!0}isNewEffectiveScene(o,t){const{key:e}=o;return!!t.includes(e)}refreshPlugin(o,t=!1){var s,a,c,l,h,u,d,p,f,I,y,v,w,m,T,N,C,z,L,j,A;let e;const{scenePath:i}=o,n=o.data;if(!(!n||!this.collector))for(const P of n.values()){const{dataType:R,data:D,key:G}=P,ct=this.collector.getStorageData(this.viewId,i),et=ct&&Object.keys(ct)||[];switch(R){case 1:if(e=t?this.isDrawEffectiveScene(P,et):this.isDeleteEffectiveScene(P,et,i),e)if(t&&!Array.isArray(D)){if((s=D.updateNodeOpt)!=null&&s.useAnimation&&(D.updateNodeOpt.useAnimation=!1),((a=this.collector)==null?void 0:a.getLocalId(G))===B&&((c=this.collector)!=null&&c.isOwn(P.key))){const H=D.selectIds;if(H){const J=et.filter(V=>{var K,nt;return((K=this.collector)==null?void 0:K.getLocalId(V))===B&&!((nt=this.collector)!=null&&nt.isOwn(V))}).map(V=>{var K;return(K=this.collector)==null?void 0:K.storage[this.viewId][i][V]});let Q=!1;for(const V of J)for(let K=0;K<H.length;K++)(l=V==null?void 0:V.selectIds)!=null&&l.includes(H[K])&&(delete H[K],Q=!0);Q&&(D.selectIds=H.filter(V=>!!V))}}(h=this.collector)==null||h.updateValue(P.key,D,{isAfterUpdate:!0,viewId:this.viewId,scenePath:i,isSync:!0})}else!t&&!Array.isArray(P.data)&&((u=this.collector)==null||u.updateValue(P.key,void 0,{isAfterUpdate:!0,viewId:this.viewId,scenePath:i,isSync:!0}));break;case 2:if(e=t?this.isDeleteEffectiveScene(P,et,i):this.isDrawEffectiveScene(P,et),e){if(t&&!Array.isArray(D))(d=this.collector)==null||d.updateValue(G,void 0,{isAfterUpdate:!0,viewId:this.viewId,scenePath:i,isSync:!0});else if(!t&&!Array.isArray(D)){if((p=D.updateNodeOpt)!=null&&p.useAnimation&&(D.updateNodeOpt.useAnimation=!1),((f=this.collector)==null?void 0:f.getLocalId(P.key))===B&&((I=this.collector)!=null&&I.isOwn(P.key))){const H=D.selectIds;if(H){const J=et.filter(V=>{var K,nt;return((K=this.collector)==null?void 0:K.getLocalId(V))===B&&!((nt=this.collector)!=null&&nt.isOwn(V))}).map(V=>{var K;return(K=this.collector)==null?void 0:K.storage[this.viewId][i][V]});let Q=!1;for(const V of J)for(let K=0;K<H.length;K++)(y=V==null?void 0:V.selectIds)!=null&&y.includes(H[K])&&(delete H[K],Q=!0);Q&&(D.selectIds=H.filter(V=>!!V))}}(v=this.collector)==null||v.updateValue(P.key,P.data,{isAfterUpdate:!0,viewId:this.viewId,scenePath:i,isSync:!0})}}break;case 3:if(e=t?this.isNewEffectiveScene(P,et):this.isOldEffectiveScene(P,et,i),e){if(t&&Array.isArray(D)&&D.length===2){const H=D[1];if((w=H.updateNodeOpt)!=null&&w.useAnimation&&(H.updateNodeOpt.useAnimation=!1),((m=this.collector)==null?void 0:m.getLocalId(P.key))===B&&((T=this.collector)!=null&&T.isOwn(P.key))){const J=H.selectIds;if(J){const Q=et.filter(K=>{var nt,q;return((nt=this.collector)==null?void 0:nt.getLocalId(K))===B&&!((q=this.collector)!=null&&q.isOwn(K))}).map(K=>{var nt;return(nt=this.collector)==null?void 0:nt.storage[this.viewId][i][K]});let V=!1;for(const K of Q)for(let nt=0;nt<J.length;nt++)K!=null&&K.selectIds&&((N=K.selectIds)!=null&&N.includes(J[nt]))&&(delete J[nt],V=!0);V&&(H.selectIds=J.filter(K=>!!K))}}(C=this.collector)==null||C.updateValue(G,H,{isAfterUpdate:!0,viewId:this.viewId,scenePath:i,isSync:!0})}else if(!t&&Array.isArray(D)&&D.length===2){const H=D[0];if((z=H.updateNodeOpt)!=null&&z.useAnimation&&(H.updateNodeOpt.useAnimation=!1),((L=this.collector)==null?void 0:L.getLocalId(P.key))===B&&((j=this.collector)!=null&&j.isOwn(P.key))){const J=H.selectIds;if(J){const Q=et.filter(K=>{var nt,q;return((nt=this.collector)==null?void 0:nt.getLocalId(K))===B&&!((q=this.collector)!=null&&q.isOwn(K))}).map(K=>{var nt;return(nt=this.collector)==null?void 0:nt.storage[this.viewId][i][K]});let V=!1;for(const K of Q)for(let nt=0;nt<J.length;nt++)K!=null&&K.selectIds&&K.selectIds.includes(J[nt])&&(delete J[nt],V=!0);V&&(H.selectIds=J.filter(K=>!!K))}}(A=this.collector)==null||A.updateValue(P.key,H,{isAfterUpdate:!0,viewId:this.viewId,scenePath:i,isSync:!0})}}break}}}};M(te,"sdkCallBack"),M(te,"MaxStackLength",20),M(te,"waitTime",100);let Je=te;function Og(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 de(r){return Og(r)&&(r.touches&&r.touches.length===1||r.changedTouches&&r.changedTouches.length===1)}function Ns(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 pe{constructor(o){M(this,"internalMsgEmitter");M(this,"control");M(this,"mainView");M(this,"appViews",new Map);const{control:t,internalMsgEmitter:e}=o;this.control=t,this.internalMsgEmitter=e,this.internalMsgEmitter.on("addUndoTicker",this.undoTickerStart.bind(this)),this.internalMsgEmitter.on("excludeIds",this.addExcludeIds.bind(this))}undoTickerStart(o,t){const e=this.getView(t);e&&e.displayer&&e.focusScenePath&&e.displayer.commiter.undoTickerStart(o,e.focusScenePath)}addExcludeIds(o,t){const e=this.getView(t);e&&e.displayer&&e.focusScenePath&&e.displayer.commiter.addExcludeIds(o)}undo(){const o=this.focuedView;let t=0;if(o){const e=o.focusScenePath;t=o.displayer.commiter.undo(e)||0}return t}redo(){const o=this.focuedView;let t=0;if(o){const e=o.focusScenePath;t=o.displayer.commiter.redo(e)||0}return t}validator(o,t,e){var s;const i=E.clone(o[t]),n=E.clone(e);t==="focusScenePath"&&e&&!E.isEqual(i,n)&&(this.control.internalSceneChange(o.id,n),(s=this.focuedView)==null||s.displayer.commiter.onChangeScene()),t==="cameraOpt"&&!E.isEqual(i,n)&&this.control.internalCameraChange(o.id,n)}destroyAppView(o,t=!1){const e=this.appViews.get(o);e&&(this.control.textEditorManager.clear(o,t),e.displayer.destroy(),this.appViews.delete(o))}createMianView(o){this.mainView=new Proxy(o,{set:(t,e,i)=>(this.control.worker.isActive&&this.validator(t,e,i),t[e]=i,!0)})}createAppView(o){const t=o.id,e=new Proxy(o,{set:(i,n,s)=>(this.control.worker.isActive&&this.validator(i,n,s),i[n]=s,!0)});this.appViews.set(t,e)}isAppView(o){return o!==wt&&this.appViews.has(o)}getView(o){var t;return o===wt?this.mainView:(t=this.appViews)==null?void 0:t.get(o)}getCurScenePath(o){const t=this.getView(o);if(t)return t.focusScenePath}getAllViews(){return[this.mainView,...this.appViews.values()]}setViewScenePath(o,t){var e;if(o===wt&&this.mainView)this.mainView.focusScenePath=t;else{const i=o&&((e=this.appViews)==null?void 0:e.get(o))||void 0;i&&(i.focusScenePath=t)}}setViewData(o,t){var e;if(o===wt&&this.mainView)this.mainView.viewData=t;else{const i=o&&((e=this.appViews)==null?void 0:e.get(o))||void 0;i&&(i.viewData=t)}}setFocuedViewId(o){var t;this.focuedViewId=o,o===wt?this.focuedView=this.mainView:this.focuedView=o&&((t=this.appViews)==null?void 0:t.get(o))||void 0,this.control.cursor.onFocusViewChange(),this.focuedView&&this.focuedView.displayer.commiter.onFocusView()}setViewFocusScenePath(o,t){var i;let e;o===wt?e=this.mainView:e=(i=this.appViews)==null?void 0:i.get(o),e&&(e.focusScenePath=t)}destroy(){var o;this.internalMsgEmitter.removeAllListeners("addUndoTicker"),this.internalMsgEmitter.removeAllListeners("excludeIds"),(o=this.mainView)==null||o.displayer.destroy(),this.appViews.forEach(t=>{this.destroyAppView(t.id,!0),this.control.worker.destroyViewWorker(t.id)})}setFocuedViewCameraOpt(o){if(this.focuedView){const t=this.focuedView.cameraOpt;E.isEqual(t,o)||(this.focuedView.cameraOpt=o)}}transformToOriginPoint(o,t){const e=this.getView(t);if(e!=null&&e.viewData){const i=e.viewData.convertToPointOnScreen(o[0],o[1]);return[i.x,i.y]}return o}transformToScenePoint(o,t){const e=this.getView(t);if(e!=null&&e.viewData){const i=e.viewData.convertToPointInWorld({x:o[0],y:o[1]});return[i.x,i.y]}return o}render(o){var t,e,i,n,s,a,c,l,h,u,d,p,f,I,y,v,w;for(const m of o){const{rect:T,imageBitmap:N,isClear:C,isUnClose:z,drawCanvas:L,clearCanvas:j,viewId:A}=m,P=(t=this.getView(A))==null?void 0:t.displayer;if(P&&T){const{dpr:R,canvasBgRef:D,canvasFloatRef:G,canvasServiceFloatRef:ct,canvasTopRef:et}=P,H=Math.floor(T.w*R),J=Math.floor(T.h*R),Q=T.x*R,V=T.y*R;if(C){switch(j){case Yt.TopFloat:(i=(e=et.current)==null?void 0:e.getContext("2d"))==null||i.clearRect(Q,V,H,J);break;case Yt.Float:(s=(n=G.current)==null?void 0:n.getContext("2d"))==null||s.clearRect(Q,V,H,J);break;case Yt.ServiceFloat:(c=(a=ct.current)==null?void 0:a.getContext("2d"))==null||c.clearRect(Q,V,H,J);break;case Yt.Bg:(h=(l=D.current)==null?void 0:l.getContext("2d"))==null||h.clearRect(Q,V,H,J);break}continue}if(L&&N)switch(L){case Yt.TopFloat:(d=(u=et.current)==null?void 0:u.getContext("2d"))==null||d.drawImage(N,0,0,H,J,Q,V,H,J);break;case Yt.Float:{(f=(p=G.current)==null?void 0:p.getContext("2d"))==null||f.drawImage(N,0,0,H,J,Q,V,H,J);break}case Yt.ServiceFloat:{(y=(I=ct.current)==null?void 0:I.getContext("2d"))==null||y.drawImage(N,0,0,H,J,Q,V,H,J);break}case Yt.Bg:{(w=(v=D.current)==null?void 0:v.getContext("2d"))==null||w.drawImage(N,0,0,H,J,Q,V,H,J);break}}if(z)continue;N==null||N.close()}}}showFloatBar(o,t,e){const i=this.getView(o),n=i==null?void 0:i.displayer.vDom;n&&n.showFloatBar(t,e)}setActiveTextEditor(o,t){const e=this.getView(o),i=e==null?void 0:e.displayer.vDom;i&&i.setActiveTextEditor(t)}}M(pe,"defaultCameraOpt",{centerX:0,centerY:0,scale:1}),M(pe,"defaultScreenCanvasOpt",{autoRender:!1,contextType:Xe.Canvas2d}),M(pe,"defaultLayerOpt",{offscreen:!0,handleEvent:!1,depth:!1});class Rg{constructor(o,t,e){M(this,"viewId");M(this,"control");M(this,"internalMsgEmitter");M(this,"commiter");M(this,"cachePoint");M(this,"cacheCursorPoint");M(this,"active",!0);M(this,"mousedown",o=>{if(this.active&&o.button===0&&this.viewId){this.control.worker.checkDrawingWork(this.viewId),this.reflashContainerOffset();const t=this.getPoint(o);this.cachePoint=t,t&&this.control.worker.originalEventLintener(b.Start,t,this.viewId)}});M(this,"mousemove",o=>{if(this.active&&this.viewId){const t=this.getPoint(o);this.cachePoint=t,t&&this.control.worker.originalEventLintener(b.Doing,t,this.viewId)}});M(this,"mouseup",o=>{if(this.active&&o.button===0&&this.viewId){const t=this.getPoint(o)||this.cachePoint;t&&this.control.worker.originalEventLintener(b.Done,t,this.viewId),this.cachePoint=void 0}});M(this,"touchstart",o=>{var t;if(this.active){if(!de(o)){this.control.worker.unWritable(),this.viewId&&this.control.worker.removeDrawingWork(this.viewId);return}if(this.viewId){if(!this.control.worker.isAbled()){const i=(t=this.control.worker.getCurrentToolsData())==null?void 0:t.toolsType;i&&this.control.effectViewContainer(i)}this.control.worker.checkDrawingWork(this.viewId),this.reflashContainerOffset();const e=this.getPoint(o);this.cachePoint=e,e&&this.control.worker.originalEventLintener(b.Start,e,this.viewId)}}});M(this,"touchmove",o=>{if(this.active){if(!de(o)){this.control.worker.unWritable(),this.control.worker.removeDrawingWork(this.viewId);return}if(this.viewId){const t=this.getPoint(o);this.cachePoint=t,t&&this.control.worker.originalEventLintener(b.Doing,t,this.viewId)}}});M(this,"touchend",o=>{if(this.active){if(!de(o)||!this.control.worker.isAbled()){this.control.worker.unWritable(),this.control.worker.removeDrawingWork(this.viewId);return}if(this.viewId){const t=this.getPoint(o)||this.cachePoint;t&&this.control.worker.originalEventLintener(b.Done,t,this.viewId),this.cachePoint=void 0}}});M(this,"cursorMouseMove",E.throttle(o=>{const t=this.getPoint(o);this.cacheCursorPoint&&E.isEqual(t,this.cacheCursorPoint)||!this.viewId||(this.cacheCursorPoint=t,t&&this.control.worker.sendCursorEvent(t,this.viewId))},30,{leading:!1}));M(this,"cursorMouseLeave",E.throttle(()=>{this.viewId&&(this.cacheCursorPoint=[void 0,void 0],this.control.worker.sendCursorEvent(this.cacheCursorPoint,this.viewId))},30,{leading:!1}));M(this,"keydown",o=>{this.control.hotkeyManager.colloctHotkey(o)});this.viewId=o,this.control=t,this.internalMsgEmitter=e;const i={control:this.control,internalMsgEmitter:this.internalMsgEmitter,viewId:this.viewId};this.commiter=new Je(i)}bindToolsClass(){var t,e;const o=(e=(t=this.control.worker)==null?void 0:t.currentToolsData)==null?void 0:e.toolsType;switch(o){case S.Text:case S.Pencil:case S.LaserPen:case S.Arrow:case S.Straight:case S.Rectangle:case S.Ellipse:case S.Star:case S.Polygon:case S.SpeechBalloon:this.eventTragetElement&&(this.eventTragetElement.className=`netless-whiteboard ${o===S.Text?"cursor-text":o===S.Pencil||o===S.LaserPen?"cursor-pencil":"cursor-arrow"}`);break}}mountView(){this.setCanvassStyle(),this.control.viewContainerManager.mountView(this.viewId)}reflashContainerOffset(){this.eventTragetElement&&(this.containerOffset=this.getContainerOffset(this.eventTragetElement,{x:0,y:0}))}updateSize(){this.setCanvassStyle(),this.reflashContainerOffset()}setViewId(o){this.viewId=o}destroy(){this.eventTragetElement&&this.removeDisplayerEvent(this.eventTragetElement),this.vDom=void 0,this.control.cursor.clearViewCursor(this.viewId),this.internalMsgEmitter.removeAllListeners([Z.Cursor,this.viewId])}getPoint(o){const t=Ns(o);if(t&&E.isNumber(t.x)&&E.isNumber(t.y))return[t.x-this.containerOffset.x,t.y-this.containerOffset.y]}setActive(o){this.active=o}async stopEventHandler(){this.cachePoint&&(await this.control.worker.originalEventLintener(b.Done,this.cachePoint,this.viewId),this.cachePoint=void 0)}getTranslate(o){const e=(o.style.WebkitTransform||getComputedStyle(o,"").getPropertyValue("-webkit-transform")||o.style.transform||getComputedStyle(o,"").getPropertyValue("transform")).match(/-?[0-9]+\.?[0-9]*/g),i=e&&parseInt(e[0])||0,n=e&&parseInt(e[1])||0;return[i,n]}getContainerOffset(o,t){var n;const e=this.getTranslate(o);let i={x:t.x+o.offsetLeft+e[0],y:t.y+o.offsetTop+e[1]};return(n=o.offsetParent)!=null&&n.nodeName&&o.offsetParent.nodeName!=="BODY"&&(i=this.getContainerOffset(o.offsetParent,i)),i}bindDisplayerEvent(o){o.addEventListener("mousedown",this.mousedown,!1),o.addEventListener("touchstart",this.touchstart,{capture:!0,passive:!1}),window.addEventListener("mouseleave",this.mouseup,!1),window.addEventListener("mousemove",this.mousemove,{capture:!0,passive:!1}),window.addEventListener("mouseup",this.mouseup,!1),window.addEventListener("touchmove",this.touchmove,{capture:!0,passive:!1}),window.addEventListener("touchend",this.touchend,{capture:!0,passive:!1}),o.addEventListener("mousemove",this.cursorMouseMove,!1),o.addEventListener("mouseleave",this.cursorMouseLeave,!1),o.addEventListener("keydown",this.keydown,!0)}removeDisplayerEvent(o){o.removeEventListener("mousedown",this.mousedown),o.removeEventListener("touchstart",this.touchstart),window.removeEventListener("mouseleave",this.mouseup),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup),window.removeEventListener("touchmove",this.touchmove),window.removeEventListener("touchend",this.touchend),o.removeEventListener("mousemove",this.cursorMouseMove),o.removeEventListener("mouseleave",this.cursorMouseLeave),o.removeEventListener("keydown",this.keydown)}}class Ts{constructor(o,t){M(this,"viewId",wt);M(this,"control");M(this,"internalMsgEmitter");M(this,"commiter");M(this,"cachePoint");M(this,"cacheCursorPoint");M(this,"active",!0);M(this,"mousedown",o=>{if(this.active&&o.button===0){this.control.worker.checkDrawingWork(this.viewId),this.reflashContainerOffset();const t=this.getPoint(o);this.cachePoint=t,t&&this.control.worker.originalEventLintener(b.Start,t,this.viewId)}});M(this,"mousemove",o=>{if(!this.active)return;const t=this.getPoint(o);this.cachePoint=t,t&&this.control.worker.originalEventLintener(b.Doing,t,this.viewId)});M(this,"mouseup",o=>{if(this.active&&o.button===0){const t=this.getPoint(o)||this.cachePoint;t&&this.control.worker.originalEventLintener(b.Done,t,this.viewId),this.cachePoint=void 0}});M(this,"touchstart",o=>{var e;if(!this.active)return;if(!de(o)){this.control.worker.unWritable(),this.viewId&&this.control.worker.removeDrawingWork(this.viewId);return}if(!this.control.worker.isAbled()){const i=(e=this.control.worker.getCurrentToolsData())==null?void 0:e.toolsType;i&&this.control.effectViewContainer(i)}this.control.worker.checkDrawingWork(this.viewId),this.reflashContainerOffset();const t=this.getPoint(o);this.cachePoint=t,t&&this.control.worker.originalEventLintener(b.Start,t,this.viewId)});M(this,"touchmove",o=>{if(!this.active)return;if(!de(o)){this.control.worker.unWritable(),this.viewId&&this.control.worker.removeDrawingWork(this.viewId);return}const t=this.getPoint(o);this.cachePoint=t,t&&this.control.worker.originalEventLintener(b.Doing,t,this.viewId)});M(this,"touchend",o=>{if(!this.active)return;if(!de(o)||!this.control.worker.isAbled()){this.control.worker.removeDrawingWork(this.viewId);return}const t=this.getPoint(o)||this.cachePoint;t&&this.control.worker.originalEventLintener(b.Done,t,this.viewId),this.cachePoint=void 0});M(this,"cursorMouseMove",E.throttle(o=>{const t=this.getPoint(o);this.cacheCursorPoint&&E.isEqual(t,this.cacheCursorPoint)||(this.cacheCursorPoint=t,t&&this.control.worker.sendCursorEvent(t,this.viewId))},30,{leading:!1}));M(this,"cursorMouseLeave",E.throttle(()=>{this.cacheCursorPoint=[void 0,void 0],this.control.worker.sendCursorEvent(this.cacheCursorPoint,this.viewId)},30,{leading:!1}));M(this,"keydown",o=>{this.control.hotkeyManager.colloctHotkey(o)});this.control=o,this.internalMsgEmitter=t;const e={control:this.control,internalMsgEmitter:this.internalMsgEmitter,viewId:this.viewId};this.commiter=new Je(e)}bindToolsClass(){var t,e;const o=(e=(t=this.control.worker)==null?void 0:t.currentToolsData)==null?void 0:e.toolsType;switch(o){case S.Text:case S.Pencil:case S.LaserPen:case S.Arrow:case S.Straight:case S.Rectangle:case S.Ellipse:case S.Star:case S.Polygon:case S.SpeechBalloon:this.eventTragetElement&&(this.eventTragetElement.className=`netless-whiteboard ${o===S.Text?"cursor-text":o===S.Pencil||o===S.LaserPen?"cursor-pencil":"cursor-arrow"}`);break}}mountView(){this.setCanvassStyle(),this.control.viewContainerManager.mountView(this.viewId)}updateSize(){this.setCanvassStyle()}reflashContainerOffset(){this.eventTragetElement&&(this.containerOffset=this.getContainerOffset(this.eventTragetElement,{x:0,y:0}))}destroy(){this.eventTragetElement&&this.removeDisplayerEvent(this.eventTragetElement),this.vDom=void 0,this.control.cursor.destroy(),this.internalMsgEmitter.removeAllListeners([Z.Cursor,this.viewId])}getPoint(o){const t=Ns(o);if(t&&E.isNumber(t.x)&&E.isNumber(t.y))return[t.x-this.containerOffset.x,t.y-this.containerOffset.y]}setActive(o){this.active=o}async stopEventHandler(){this.cachePoint&&(await this.control.worker.originalEventLintener(b.Done,this.cachePoint,this.viewId),this.cachePoint=void 0)}getTranslate(o){const e=(o.style.WebkitTransform||getComputedStyle(o,"").getPropertyValue("-webkit-transform")||o.style.transform||getComputedStyle(o,"").getPropertyValue("transform")).match(/-?[0-9]+\.?[0-9]*/g),i=e&&parseInt(e[0])||0,n=e&&parseInt(e[1])||0;return[i,n]}getContainerOffset(o,t){var n;const e=this.getTranslate(o);let i={x:t.x+o.offsetLeft+e[0],y:t.y+o.offsetTop+e[1]};return(n=o.offsetParent)!=null&&n.nodeName&&o.offsetParent.nodeName!=="BODY"&&(i=this.getContainerOffset(o.offsetParent,i)),i}bindDisplayerEvent(o){o.addEventListener("mousedown",this.mousedown,!1),window.addEventListener("mouseleave",this.mouseup,!1),window.addEventListener("mousemove",this.mousemove,{capture:!1,passive:!1}),window.addEventListener("mouseup",this.mouseup,!1),o.addEventListener("touchstart",this.touchstart,{capture:!0,passive:!1}),window.addEventListener("touchmove",this.touchmove,{capture:!0,passive:!1}),window.addEventListener("touchend",this.touchend,{capture:!0,passive:!1}),o.addEventListener("mousemove",this.cursorMouseMove,!0),o.addEventListener("mouseleave",this.cursorMouseLeave,!0),o.addEventListener("keydown",this.keydown,!0)}removeDisplayerEvent(o){o.removeEventListener("mousedown",this.mousedown),o.removeEventListener("touchstart",this.touchstart),window.removeEventListener("mouseleave",this.mouseup),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup),window.removeEventListener("touchmove",this.touchmove),window.removeEventListener("touchend",this.touchend),o.removeEventListener("mousemove",this.cursorMouseMove),o.removeEventListener("mouseleave",this.cursorMouseLeave),o.removeEventListener("keydown",this.keydown)}}const Yg="index-module__Container__nLsM3",Wg="index-module__CanvasBox__j2Xe-",Ug="index-module__FloatCanvas__d1YR7",Bg="index-module__TopFloatCanvas__7IaCw",$g="index-module__CanvasBoxSub__hcMeK",Fg="index-module__SnapshotBox__--eeE",Hg="index-module__FloatBar__cm-EL",Qg="index-module__RotateBtn__HSSkf",Vg="index-module__ResizeBtn__yjvda",Zg="index-module__CursorBox__2UHvI",Gg="index-module__TextEditorContainer__Qm8KC",Jg="index-module__ResizeTowBox__HOllX",qg="index-module__FloatBarBtn__FJrOG",Nt={Container:Yg,CanvasBox:Wg,FloatCanvas:Ug,TopFloatCanvas:Bg,CanvasBoxSub:$g,SnapshotBox:Fg,FloatBar:Hg,RotateBtn:Qg,ResizeBtn:Vg,CursorBox:Zg,TextEditorContainer:Gg,ResizeTowBox:Jg,FloatBarBtn:qg},Xg={delete:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDZ2NmEyIDIgMCAwIDEtMiAySDZhMiAyIDAgMCAxLTIt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lBOC44NDYgOC44NDYgMCAwIDEgMy4xMjUgMTJjMC0yLjI3MS44NjYtNC41NDMgMi42LTYuMjc2eiIgc3Ryb2tlPSIjRkZGIiBzdHJva2Utd2lkdGg9Ii41IiBmaWxsPSIjMDAwIiBmaWxsLXJ1bGU9Im5vbnplcm8iLz48L2c+PC9zdmc+","font-colors-active":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0ibTQgMTEgNC05IDQgOU02IDdoNCIgc3Ryb2tlPSIjMzM4MUZGIiBmaWxsPSJub25lIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=","font-colors":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0ibTQgMTEgNC05IDQgOU02IDdoNCIgc3Ryb2tlPSIjNDQ0RTYwIiBmaWxsPSJub25lIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=","to-bottom":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDEwdjhtMCAwLTItMm0yIDIgMi0ybS00IDZoMTJtLTYtNGg2bS02LTRoNm0tNi00aDYiIHN0cm9rZT0iIzQ0NEU2MCIgZmlsbD0ibm9uZSIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+PC9zdmc+","to-top":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDIydi04bTAgMC0yIDJtMi0yIDIgMm0tNC02aDEybS02IDRoNm0tNiA0aDZtLTYgNGg2IiBzdHJva2U9IiM0NDRFNjAiIGZpbGw9Im5vbmUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjwvc3ZnPg==","bold-active":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTQuNSAySDhhMi41IDIuNSAwIDAgMSAwIDVINS41aDBtLTEgMGg0YTMgMyAwIDAgMSAwIDZoLTQgMG0wIDFWMiIgc3Ryb2tlPSIjMzM4MUZGIiBmaWxsPSJub25lIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=",bold:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTQuNSAySDhhMi41IDIuNSAwIDAgMSAwIDVINS41aDBtLTEgMGg0YTMgMyAwIDAgMSAwIDZoLTQgMG0wIDFWMiIgc3Ryb2tlPSIjNDQ0RTYwIiBmaWxsPSJub25lIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=","underline-active":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDJ2NWE0IDQgMCAxIDEtOCAwVjJoME0zIDE0aDEwIiBzdHJva2U9IiMzMzgxRkYiIGZpbGw9Im5vbmUiIHN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F0aD48L3N2Zz4="};function It(r){return Xg[r]}const Kg=r=>{const{workIds:o,mananger:t}=r;return g.createElement("div",{className:"button normal-button",style:{touchAction:"none"},onClick:e=>{e.cancelable&&e.preventDefault(),e.stopPropagation(),X.emitMethod(Z.MainEngine,O.DeleteNode,{workIds:o||[B],viewId:t.viewId})},onTouchEnd:e=>{e.cancelable&&e.preventDefault(),e.stopPropagation(),X.emitMethod(Z.MainEngine,O.DeleteNode,{workIds:o||[B],viewId:t.viewId})}},g.createElement("img",{alt:"icon",src:It("delete")}))},_g=r=>{const{workIds:o,viewId:t}=r;return g.createElement("div",{className:"button normal-button",onClick:e=>{e.cancelable&&e.preventDefault(),e.stopPropagation(),X.emitMethod(Z.MainEngine,O.CopyNode,{workIds:o||[B],viewId:t})},onTouchEnd:e=>{e.stopPropagation(),X.emitMethod(Z.MainEngine,O.CopyNode,{workIds:o||[B],viewId:t})}},g.createElement("img",{alt:"icon",src:It("duplicate")}))},Si=r=>{const{icon:o,onClickHandler:t,onTouchEndHandler:e}=r;return g.createElement("div",{className:"button normal-button",onClick:t,onTouchEnd:e},g.createElement("img",{src:It(o)}))},tM=r=>{const{open:o,setOpen:t,floatBarRef:e}=r,{floatBarData:i,mananger:n}=g.useContext(yt),[s,a]=g.useState([]),c=g.useMemo(()=>{if(e!=null&&e.current&&E.isNumber(i==null?void 0:i.y)&&(n!=null&&n.height)){if(e.current.offsetTop&&e.current.offsetTop+i.y>180){const d={};return d.top="inherit",d.bottom=50,d}else if(!e.current.offsetTop&&(n==null?void 0:n.height)-e.current.offsetTop-i.y<120){const d={};return d.top="inherit",d.bottom=50,d}}},[e==null?void 0:e.current,i,n]),l=g.useMemo(()=>o?g.createElement("div",{className:"image-layer-menu",style:c},g.createElement(Si,{icon:"to-top",onClickHandler:d=>{d.cancelable&&d.preventDefault(),d.stopPropagation(),X.emitMethod(Z.MainEngine,O.ZIndexNode,{workIds:[B],layer:ee.Top,viewId:n==null?void 0:n.viewId})},onTouchEndHandler:d=>{d.stopPropagation(),X.emitMethod(Z.MainEngine,O.ZIndexNode,{workIds:[B],layer:ee.Top,viewId:n==null?void 0:n.viewId})}}),g.createElement(Si,{icon:"to-bottom",onClickHandler:d=>{d.cancelable&&d.preventDefault(),d.stopPropagation(),X.emitMethod(Z.MainEngine,O.ZIndexNode,{workIds:[B],layer:ee.Bottom,viewId:n==null?void 0:n.viewId})},onTouchEndHandler:d=>{d.stopPropagation(),X.emitMethod(Z.MainEngine,O.ZIndexNode,{workIds:[B],layer:ee.Bottom,viewId:n==null?void 0:n.viewId})}})):null,[o,c]),h=d=>{d.cancelable&&d.preventDefault(),d.stopPropagation(),d.nativeEvent.stopImmediatePropagation(),t(!o)},u=d=>{d.stopPropagation(),d.nativeEvent.stopImmediatePropagation(),t(!o)};return g.useEffect(()=>{E.isEqual(i==null?void 0:i.selectIds,s)||i!=null&&i.selectIds&&!E.isEqual(i==null?void 0:i.selectIds,s)&&(a(i==null?void 0:i.selectIds),t(!1))},[o,i,s,t]),g.createElement("div",{className:`button normal-button ${o&&"active"}`,onClick:h,onTouchEnd:u},l,g.createElement("img",{alt:"icon",src:It(o?"layer-pressed":"layer")}))},eM=()=>g.createElement("svg",{style:{marginLeft:"2px"},viewBox:"0 0 1025 1024",width:"14",height:"14"},g.createElement("path",{d:"M1016.5248 493.8752c-9.984-9.984-26.2144-9.984-36.1984 0l-183.6032 183.6032c-29.952 29.952-78.6944 29.952-108.5952 0l-239.2064-239.2064c-14.4384-14.4384-22.3744-33.6896-22.3744-54.3232s7.936-39.8848 22.3744-54.3232l183.6032-183.6032c9.984-9.984 9.984-26.2144 0-36.1984s-26.2144-9.984-36.1984 0l-183.6032 183.6032c-24.1152 24.1152-37.376 56.2176-37.376 90.5216 0 14.592 2.4576 28.8256 7.0656 42.1888l-374.8864 374.8864c-4.8128 4.8128-7.4752 11.3152-7.4752 18.1248l0 76.8c0 14.1312 11.4688 25.6 25.6 25.6l486.4 0c6.8096 0 13.312-2.7136 18.1248-7.4752l170.0864-170.0864c13.3632 4.6592 27.5968 7.0656 42.1888 7.0656 34.2528 0 66.4064-13.2608 90.5216-37.376l183.6032-183.6032c9.984-9.984 9.984-26.2144 0-36.1984zM501.4016 870.4l-450.2016 0 0-40.6016 358.5024-358.5024c1.024 1.0752 1.9968 2.1504 3.0208 3.1744l239.2064 239.2064c1.024 1.024 2.0992 2.048 3.1744 3.0208l-153.7024 153.7024z",fill:"#000000"})),Ss=r=>{const{activeColor:o,onClickHandler:t,onTouchEndHandler:e}=r;return g.createElement("div",{className:`font-color-button ${o==="transparent"?"active":""}`,onClick:t,onTouchEnd:e},g.createElement("div",{className:"circle none"}))},ao=r=>{const{color:o,activeColor:t,onClickHandler:e,onTouchEndHandler:i}=r;return g.createElement("div",{className:`font-color-button ${o===t?"active":""}`,onClick:e,onTouchEnd:i},g.createElement("div",{className:"circle",style:{backgroundColor:Mt(o,1)}}))},co=r=>{const{opacity:o,activeColor:t,setCurOpacity:e}=r,[i,n]=g.useState({x:108,y:0});if(g.useEffect(()=>{n({x:o*100+8,y:0})},[]),!t)return null;const s=E.throttle((l,h)=>{l.cancelable&&l.preventDefault(),l.stopPropagation(),h.x!==(i==null?void 0:i.x)&&n({x:h.x,y:0});const u=Math.min(Math.max(h.x-8,0),100)/100;o!==u&&e(u,t,b.Doing)},100,{leading:!1}),a=l=>{l.cancelable&&l.preventDefault(),l.stopPropagation(),e(o,t,b.Start)},c=E.throttle((l,h)=>{l.cancelable&&l.preventDefault(),l.stopPropagation(),h.x!==(i==null?void 0:i.x)&&n({x:h.x,y:0});const u=Math.min(Math.max(h.x-8,0),100)/100;e(u,t,b.Done)},100,{leading:!1});return g.createElement("div",{className:"font-color-opacity",style:{marginLeft:"10px"},onClick:l=>{const h=l.nativeEvent.offsetX,u=Math.min(Math.max(h-12,0),100)/100;n({x:u*100+8,y:0}),e(u,t,b.Done)}},g.createElement("div",{className:"range-color",style:{background:`linear-gradient(to right, ${Mt(t,0)}, ${Mt(t,1)})`}}),g.createElement("div",{className:"range-opacity"},g.createElement(ge,{bounds:"parent",axis:"x",position:i,onDrag:s,onStart:a,onStop:c},g.createElement("div",{className:"circle",style:{backgroundColor:Mt(t,o)},onClick:l=>{l.cancelable&&l.preventDefault(),l.stopPropagation()}}))))},oM=r=>{const{min:o,max:t,activeNumber:e,setActiveNumber:i,color:n}=r,[s,a]=g.useState({x:108,y:0});if(g.useEffect(()=>{const u=Math.ceil((e-o)/(t-o)*100)+8;a({x:u,y:0})},[]),!e)return null;const c=E.throttle((u,d)=>{u.cancelable&&u.preventDefault(),u.stopPropagation(),d.x!==(s==null?void 0:s.x)&&a({x:d.x,y:0});const p=Math.ceil(Math.max(d.x-8,0)/100*(t-o)+o);e!==p&&i(p,b.Doing)},100,{leading:!1}),l=u=>{u.cancelable&&u.preventDefault(),u.stopPropagation(),i(e,b.Start)},h=E.throttle((u,d)=>{u.cancelable&&u.preventDefault(),u.stopPropagation(),d.x!==(s==null?void 0:s.x)&&a({x:d.x,y:0});const p=Math.ceil(Math.max(d.x-8,0)/100*(t-o)+o);i(p,b.Done)},100,{leading:!1});return g.createElement("div",{className:"font-color-opacity",style:{marginLeft:"10px"},onClick:u=>{const d=u.nativeEvent.offsetX,p=Math.ceil(Math.max(d-12,0)/100*(t-o)+o),f=Math.ceil((p-o)/(t-o)*100)+8;a({x:f,y:0}),i(p,b.Done)}},g.createElement("div",{className:"range-color",style:{backgroundColor:n}}),g.createElement("div",{className:"range-opacity"},g.createElement(ge,{bounds:"parent",axis:"x",position:s,onDrag:c,onStart:l,onStop:h},g.createElement("div",{className:"circle",style:{backgroundColor:n},onClick:u=>{u.cancelable&&u.preventDefault(),u.stopPropagation()}},g.createElement("div",{className:"range-opacity-data-icon"},e)))))},iM=r=>{const{useStroke:o,color:t,activeStrokeType:e,setStrokeType:i}=r;return g.createElement("div",{className:"stroke-type-box"},!!o&&g.createElement("div",{className:`stroke-type-box-item Stroke ${e===_.Stroke&&"active"}`,style:{backgroundColor:t},onClick:()=>{i(_.Stroke)},onTouchEnd:()=>{i(_.Stroke)}}),g.createElement("div",{className:`stroke-type-box-item Normal ${e===_.Normal&&"active"}`,style:{borderColor:t},onClick:()=>{i(_.Normal)},onTouchEnd:()=>{i(_.Normal)}}),g.createElement("div",{className:`stroke-type-box-item Dotted ${e===_.Dotted&&"active"}`,style:{borderColor:t},onClick:()=>{i(_.Dotted)},onTouchEnd:()=>{i(_.Dotted)}}),g.createElement("div",{className:`stroke-type-box-item LongDotted ${e===_.LongDotted&&"active"}`,style:{borderColor:t},onClick:()=>{i(_.LongDotted)},onTouchEnd:()=>{i(_.LongDotted)}}))},sM=r=>{const{open:o,setOpen:t,floatBarRef:e}=r,{floatBarData:i,floatBarColors:n,mananger:s,setFloatBarData:a}=g.useContext(yt),[c,l]=g.useState(),[h,u]=g.useState(1);g.useEffect(()=>{if(i!=null&&i.strokeColor){const[w,m]=ro(i.strokeColor);l(w),u(m)}},[i]);const d=g.useMemo(()=>{if(e!=null&&e.current&&E.isNumber(i==null?void 0:i.y)&&(s!=null&&s.height)){if(e.current.offsetTop&&e.current.offsetTop+i.y>180){const w={};return w.top="inherit",w.bottom=50,w}else if(!e.current.offsetTop&&(s==null?void 0:s.height)-e.current.offsetTop-i.y<120){const w={};return w.top="inherit",w.bottom=50,w}}},[(e==null?void 0:e.current)&&i,s==null?void 0:s.height]),p=g.useMemo(()=>g.createElement(co,{key:"strokeColors",opacity:h,activeColor:c,setCurOpacity:(w,m,T)=>{T===b.Start&&(s!=null&&s.control.room)&&(s.control.room.disableDeviceInputs=!0),T===b.Done&&(s!=null&&s.control.room)&&(s.control.room.disableDeviceInputs=!1),u(w);const N=Mt(m,w);i!=null&&i.strokeColor&&a({strokeColor:N}),X.emitMethod(Z.MainEngine,O.SetColorNode,{workIds:[B],strokeColor:N,workState:T,viewId:s==null?void 0:s.viewId})}}),[h,c,s==null?void 0:s.control.room,s==null?void 0:s.viewId,i]),f=g.useMemo(()=>c&&(i!=null&&i.thickness)?g.createElement(oM,{key:"strokeThickness",min:1,max:10,activeNumber:i.thickness,setActiveNumber:(w,m)=>{m===b.Start&&(s!=null&&s.control.room)&&(s.control.room.disableDeviceInputs=!0),m===b.Done&&(s!=null&&s.control.room)&&(s.control.room.disableDeviceInputs=!1),i!=null&&i.thickness&&a({thickness:w}),X.emitMethod(Z.MainEngine,O.SetColorNode,{workIds:[B],thickness:w,workState:m,viewId:s==null?void 0:s.viewId})},color:c}):null,[c,i==null?void 0:i.thickness,s==null?void 0:s.control.room,s==null?void 0:s.viewId]),I=g.useMemo(()=>c&&(i!=null&&i.strokeType)?g.createElement(iM,{key:"strokeType",useStroke:i==null?void 0:i.useStroke,activeStrokeType:i.strokeType,setStrokeType:w=>{i.strokeType&&a({strokeType:w}),X.emitMethod(Z.MainEngine,O.SetColorNode,{workIds:[B],strokeType:w,workState:b.Done,viewId:s==null?void 0:s.viewId})},color:c}):null,[c,i==null?void 0:i.strokeType,s==null?void 0:s.control.room,s==null?void 0:s.viewId,i==null?void 0:i.useStroke]),y=g.useMemo(()=>o?g.createElement("div",{className:"font-colors-menu",style:d,onTouchEnd:w=>{w.stopPropagation(),w.nativeEvent.stopImmediatePropagation()},onClick:w=>{w.cancelable&&w.preventDefault(),w.stopPropagation(),w.nativeEvent.stopImmediatePropagation()}},I,f,g.createElement("div",{className:"font-colors-line"}),n.concat().map((w,m)=>{const T=De(...w);return g.createElement(ao,{key:m,color:T,activeColor:c,onTouchEndHandler:N=>{N.stopPropagation(),l(T);const C=Mt(T,h);i!=null&&i.strokeColor&&(i.strokeColor=C,a({strokeColor:C})),X.emitMethod(Z.MainEngine,O.SetColorNode,{workIds:[B],workState:b.Done,strokeColor:C,viewId:s==null?void 0:s.viewId})},onClickHandler:N=>{N.cancelable&&N.preventDefault(),N.stopPropagation(),l(T);const C=Mt(T,h);i!=null&&i.strokeColor&&(i.strokeColor=C,a({strokeColor:C})),X.emitMethod(Z.MainEngine,O.SetColorNode,{workIds:[B],workState:b.Done,strokeColor:C,viewId:s==null?void 0:s.viewId})}})}),p):null,[o,n,p,c,h,i,s==null?void 0:s.viewId,d]),v=g.useMemo(()=>c?g.createElement("div",{className:"color-bar-ring",style:{backgroundColor:Mt(c,h)}},g.createElement("div",{className:"circle"})):null,[c,h]);return g.createElement("div",{className:`button normal-button font-colors-icon ${o&&"active"}`,onTouchEnd:w=>{w.stopPropagation(),w.nativeEvent.stopImmediatePropagation(),t(!o)},onClick:w=>{w.cancelable&&w.preventDefault(),w.stopPropagation(),w.nativeEvent.stopImmediatePropagation(),t(!o)}},v,y)},nM=r=>{const{open:o,setOpen:t,floatBarRef:e}=r,{floatBarData:i,floatBarColors:n,mananger:s,setFloatBarData:a}=g.useContext(yt),[c,l]=g.useState(),[h,u]=g.useState(1);g.useEffect(()=>{if(i!=null&&i.fillColor){const[y,v]=(i==null?void 0:i.fillColor)==="transparent"&&["transparent",1]||ro(i.fillColor);l(y),u(v)}},[i]);const d=g.useMemo(()=>{if(e!=null&&e.current&&E.isNumber(i==null?void 0:i.y)&&(s!=null&&s.height)){if(e.current.offsetTop&&e.current.offsetTop+i.y>200){const y={};return y.top="inherit",y.bottom=50,y}else if(!e.current.offsetTop&&(s==null?void 0:s.height)-e.current.offsetTop-i.y<140){const y={};return y.top="inherit",y.bottom=50,y}}},[e==null?void 0:e.current,i,s==null?void 0:s.height]),p=g.useMemo(()=>c&&c!=="transparent"?g.createElement(co,{key:"fillColors",opacity:h||0,activeColor:c,setCurOpacity:(y,v,w)=>{w===b.Start&&(s!=null&&s.control.room)&&(s.control.room.disableDeviceInputs=!0),w===b.Done&&(s!=null&&s.control.room)&&(s.control.room.disableDeviceInputs=!1),u(y);const m=Mt(v,y);i!=null&&i.fillColor&&(i.fillColor=m,a({fillColor:m})),X.emitMethod(Z.MainEngine,O.SetColorNode,{workIds:[B],fillColor:c&&Mt(v,y),workState:w,viewId:s==null?void 0:s.viewId})}}):null,[c,h,s==null?void 0:s.control.room,s==null?void 0:s.viewId,i]),f=g.useMemo(()=>o?g.createElement("div",{className:"font-colors-menu",style:d,onTouchEnd:y=>{y.stopPropagation(),y.nativeEvent.stopImmediatePropagation()},onClick:y=>{y.cancelable&&y.preventDefault(),y.stopPropagation(),y.nativeEvent.stopImmediatePropagation()}},g.createElement(Ss,{activeColor:c,onTouchEndHandler:y=>{y.stopPropagation(),l("transparent");const v="transparent";i!=null&&i.fillColor&&(i.fillColor=v,a({fillColor:v})),X.emitMethod(Z.MainEngine,O.SetColorNode,{workIds:[B],workState:b.Done,fillColor:v,viewId:s==null?void 0:s.viewId})},onClickHandler:y=>{y.cancelable&&y.preventDefault(),y.stopPropagation(),l("transparent");const v="transparent";i!=null&&i.fillColor&&(i.fillColor=v,a({fillColor:v})),X.emitMethod(Z.MainEngine,O.SetColorNode,{workIds:[B],workState:b.Done,fillColor:v,viewId:s==null?void 0:s.viewId})}}),n.map((y,v)=>{const w=De(...y);return g.createElement(ao,{key:v,color:w,activeColor:c,onTouchEndHandler:m=>{m.cancelable&&m.preventDefault(),m.stopPropagation(),l(w);const T=Mt(w,h);i!=null&&i.fillColor&&(i.fillColor=T,a({fillColor:T})),X.emitMethod(Z.MainEngine,O.SetColorNode,{workIds:[B],workState:b.Done,fillColor:T,viewId:s==null?void 0:s.viewId})},onClickHandler:m=>{m.cancelable&&m.preventDefault(),m.stopPropagation(),l(w);const T=Mt(w,h);i!=null&&i.fillColor&&(i.fillColor=T,a({fillColor:T})),X.emitMethod(Z.MainEngine,O.SetColorNode,{workIds:[B],workState:b.Done,fillColor:T,viewId:s==null?void 0:s.viewId})}})}),p):null,[o,c,n,p,i,s==null?void 0:s.viewId,h,d]),I=g.useMemo(()=>{const y=c&&c!=="transparent"&&Mt(c,h)||"transparent";return g.createElement("div",{className:"color-bar-fill"},g.createElement("div",{className:"circle",style:{backgroundColor:y}}))},[c,h]);return g.createElement("div",{className:`button normal-button font-colors-icon ${o&&"active"}`,onTouchEnd:y=>{y.stopPropagation(),y.nativeEvent.stopImmediatePropagation(),t(!o)},onClick:y=>{y.cancelable&&y.preventDefault(),y.stopPropagation(),y.nativeEvent.stopImmediatePropagation(),t(!o)}},I,f)},rM=r=>{const{open:o,setOpen:t,textOpt:e,workIds:i,floatBarRef:n}=r,{floatBarColors:s,mananger:a,setFloatBarData:c,floatBarData:l}=g.useContext(yt),[h,u]=g.useState(),[d,p]=g.useState(1);g.useEffect(()=>{if(e!=null&&e.fontColor){const[w,m]=(e==null?void 0:e.fontColor)==="transparent"&&["transparent",0]||ro(e.fontColor);u(w),p(m)}},[e==null?void 0:e.fontColor]);const f=g.useMemo(()=>{if(n!=null&&n.current&&E.isNumber(l==null?void 0:l.y)&&(a!=null&&a.height)){if(n.current.offsetTop&&n.current.offsetTop+l.y>180){const w={};return w.top="inherit",w.bottom=50,w}else if(!n.current.offsetTop&&(a==null?void 0:a.height)-n.current.offsetTop-l.y<120){const w={};return w.top="inherit",w.bottom=50,w}}},[n==null?void 0:n.current,l,a]),I=g.useMemo(()=>h&&h!=="transparent"?g.createElement(co,{key:"fontColors",opacity:d,activeColor:h,setCurOpacity:(w,m,T)=>{T===b.Start&&(a!=null&&a.control.room)&&(a.control.room.disableDeviceInputs=!0),T===b.Done&&(a!=null&&a.control.room)&&(a.control.room.disableDeviceInputs=!1),p(w);const N=Mt(m,w);l!=null&&l.textOpt&&(l.textOpt.fontColor=N,c({textOpt:l.textOpt})),X.emitMethod(Z.MainEngine,O.SetColorNode,{workIds:i||[B],fontColor:h&&N,workState:T,viewId:a==null?void 0:a.viewId})}}):null,[h,d,a==null?void 0:a.control.room,a==null?void 0:a.viewId,l==null?void 0:l.textOpt,i]),y=g.useMemo(()=>o?g.createElement("div",{className:"font-colors-menu",style:f,onTouchEnd:w=>{w.stopPropagation(),w.nativeEvent.stopImmediatePropagation()},onClick:w=>{w.cancelable&&w.preventDefault(),w.stopPropagation(),w.nativeEvent.stopImmediatePropagation()}},s.map((w,m)=>{const T=De(...w);return g.createElement(ao,{key:m,color:T,activeColor:h,onTouchEndHandler:N=>{N.stopPropagation(),u(T);const C=Mt(T,d);l!=null&&l.textOpt&&(l.textOpt.fontColor=C,c({textOpt:l.textOpt})),X.emitMethod(Z.MainEngine,O.SetColorNode,{workIds:i||[B],workState:b.Done,fontColor:C,viewId:a==null?void 0:a.viewId})},onClickHandler:N=>{N.cancelable&&N.preventDefault(),N.stopPropagation(),u(T);const C=Mt(T,d);l!=null&&l.textOpt&&(l.textOpt.fontColor=C,c({textOpt:l.textOpt})),X.emitMethod(Z.MainEngine,O.SetColorNode,{workIds:i||[B],workState:b.Done,fontColor:C,viewId:a==null?void 0:a.viewId})}})}),I):null,[o,s,I,h,d,l==null?void 0:l.textOpt,i,a==null?void 0:a.viewId,f]),v=g.useMemo(()=>{const w=h&&h!=="transparent"&&Mt(h,d)||"transparent";return g.createElement("div",{className:"color-bar"},g.createElement("div",{className:"color-bar-color",style:{backgroundColor:w}}))},[h,d]);return g.createElement("div",{className:`button normal-button font-colors-icon ${o&&"active"}`,onTouchEnd:w=>{w.stopPropagation(),w.nativeEvent.stopImmediatePropagation(),t(!o)},onClick:w=>{w.cancelable&&w.preventDefault(),w.stopPropagation(),w.nativeEvent.stopImmediatePropagation(),t(!o)}},g.createElement("img",{alt:"icon",src:It("font-colors")}),v,y)},aM=r=>{const{open:o,setOpen:t,textOpt:e,workIds:i,floatBarRef:n}=r,{floatBarColors:s,mananger:a,setFloatBarData:c,floatBarData:l}=g.useContext(yt),[h,u]=g.useState(),[d,p]=g.useState(1);g.useEffect(()=>{if(e!=null&&e.fontBgColor){const[w,m]=(e==null?void 0:e.fontBgColor)==="transparent"&&["transparent",1]||ro(e.fontBgColor);u(w),p(m)}},[e==null?void 0:e.fontBgColor]);const f=g.useMemo(()=>{if(n!=null&&n.current&&E.isNumber(l==null?void 0:l.y)&&(a!=null&&a.height)){if(n.current.offsetTop&&n.current.offsetTop+l.y>180){const w={};return w.top="inherit",w.bottom=50,w}else if(!n.current.offsetTop&&(a==null?void 0:a.height)-n.current.offsetTop-l.y<120){const w={};return w.top="inherit",w.bottom=50,w}}},[n==null?void 0:n.current,l,a]),I=g.useMemo(()=>h&&h!=="transparent"?g.createElement(co,{key:"fontBgColor",opacity:d||0,activeColor:h,setCurOpacity:(w,m,T)=>{T===b.Start&&(a!=null&&a.control.room)&&(a.control.room.disableDeviceInputs=!0),T===b.Done&&(a!=null&&a.control.room)&&(a.control.room.disableDeviceInputs=!1),p(w);const N=Mt(m,w);l!=null&&l.textOpt&&(l.textOpt.fontBgColor=N,c({textOpt:l.textOpt})),X.emitMethod(Z.MainEngine,O.SetColorNode,{workIds:i||[B],fontBgColor:h&&Mt(m,w),workState:T,viewId:a==null?void 0:a.viewId})}}):null,[h,d,a==null?void 0:a.control.room,a==null?void 0:a.viewId,l==null?void 0:l.textOpt,i]),y=g.useMemo(()=>o?g.createElement("div",{className:"font-colors-menu",style:f,onTouchEnd:w=>{w.stopPropagation(),w.nativeEvent.stopImmediatePropagation()},onClick:w=>{w.cancelable&&w.preventDefault(),w.stopPropagation(),w.nativeEvent.stopImmediatePropagation()}},g.createElement(Ss,{activeColor:h,onTouchEndHandler:w=>{w.stopPropagation();const m="transparent";u(m),l!=null&&l.textOpt&&(l.textOpt.fontBgColor=m,c({textOpt:l.textOpt})),X.emitMethod(Z.MainEngine,O.SetColorNode,{workIds:i||[B],workState:b.Done,fontBgColor:m,viewId:a==null?void 0:a.viewId})},onClickHandler:w=>{w.cancelable&&w.preventDefault(),w.stopPropagation();const m="transparent";u(m),l!=null&&l.textOpt&&(l.textOpt.fontBgColor=m,c({textOpt:l.textOpt})),X.emitMethod(Z.MainEngine,O.SetColorNode,{workIds:i||[B],workState:b.Done,fontBgColor:m,viewId:a==null?void 0:a.viewId})}}),s.map((w,m)=>{const T=De(...w);return g.createElement(ao,{key:m,color:T,activeColor:h,onTouchEndHandler:N=>{N.stopPropagation(),u(T);const C=Mt(T,d);l!=null&&l.textOpt&&(l.textOpt.fontBgColor=C,c({textOpt:l.textOpt})),X.emitMethod(Z.MainEngine,O.SetColorNode,{workIds:i||[B],workState:b.Done,fontBgColor:Mt(T,d),viewId:a==null?void 0:a.viewId})},onClickHandler:N=>{N.cancelable&&N.preventDefault(),N.stopPropagation(),u(T);const C=Mt(T,d);l!=null&&l.textOpt&&(l.textOpt.fontBgColor=C,c({textOpt:l.textOpt})),X.emitMethod(Z.MainEngine,O.SetColorNode,{workIds:i||[B],workState:b.Done,fontBgColor:Mt(T,d),viewId:a==null?void 0:a.viewId})}})}),I):null,[o,s,I,d,h,l==null?void 0:l.textOpt,i,a==null?void 0:a.viewId,f]),v=g.useMemo(()=>{const w=h&&h!=="transparent"&&Mt(h,d)||"transparent";return g.createElement("div",{className:"color-bar",style:{marginTop:0}},g.createElement("div",{className:"color-bar-color",style:{backgroundColor:w}}))},[h,d]);return g.createElement("div",{className:`button normal-button font-colors-icon ${o&&"active"}`,onTouchEnd:w=>{w.stopPropagation(),w.nativeEvent.stopImmediatePropagation(),t(!o)},onClick:w=>{w.cancelable&&w.preventDefault(),w.stopPropagation(),w.nativeEvent.stopImmediatePropagation(),t(!o)}},g.createElement(eM,null),v,y)},cM=r=>{const{bold:o,setBold:t,workIds:e,viewId:i}=r,n=s=>{const a=o==="bold"?"normal":"bold";s.cancelable&&s.preventDefault(),s==null||s.stopPropagation(),t(a),X.emitMethod(Z.MainEngine,O.SetFontStyle,{workIds:e,viewId:i,bold:a})};return g.createElement("div",{className:"font-style-button",onClick:n,onTouchEnd:n},g.createElement("img",{alt:"icon",src:It(o==="bold"?"bold-active":"bold")}))},lM=r=>{const{underline:o,setUnderline:t,workIds:e,viewId:i}=r,n=s=>{const a=!o;s.cancelable&&s.preventDefault(),s==null||s.stopPropagation(),t(a),X.emitMethod(Z.MainEngine,O.SetFontStyle,{workIds:e,viewId:i,underline:a})};return g.createElement("div",{className:"font-style-button",onClick:n,onTouchEnd:n},g.createElement("img",{alt:"icon",src:It(o?"underline-active":"underline")}))},hM=r=>{const{lineThrough:o,setLineThrough:t,workIds:e,viewId:i}=r,n=s=>{const a=!o;s.cancelable&&s.preventDefault(),s==null||s.stopPropagation(),t(a),X.emitMethod(Z.MainEngine,O.SetFontStyle,{workIds:e,viewId:i,lineThrough:a})};return g.createElement("div",{className:"font-style-button",onClick:n,onTouchEnd:n},g.createElement("img",{alt:"icon",src:It(o?"line-through-active":"line-through")}))},uM=r=>{const{italic:o,setItalic:t,workIds:e,viewId:i}=r,n=s=>{const a=o==="italic"?"normal":"italic";s.cancelable&&s.preventDefault(),s==null||s.stopPropagation(),t(a),X.emitMethod(Z.MainEngine,O.SetFontStyle,{workIds:e,viewId:i,italic:a})};return g.createElement("div",{className:"font-style-button",onClick:n,onTouchEnd:n},g.createElement("img",{alt:"icon",src:It(o==="italic"?"italic-active":"italic")}))},dM=r=>{const{open:o,setOpen:t,textOpt:e,workIds:i,style:n,floatBarRef:s}=r,{mananger:a,floatBarData:c}=g.useContext(yt),[l,h]=g.useState("normal"),[u,d]=g.useState("normal"),[p,f]=g.useState(!1),[I,y]=g.useState(!1);g.useEffect(()=>{e!=null&&e.bold&&h(e.bold),E.isBoolean(e==null?void 0:e.underline)&&f(e.underline||!1),E.isBoolean(e==null?void 0:e.lineThrough)&&y(e.lineThrough||!1),e!=null&&e.italic&&d(e.italic)},[e]);const v=g.useMemo(()=>{if(n&&(s!=null&&s.current)&&E.isNumber(c==null?void 0:c.y)&&(a!=null&&a.height)){if(s.current.offsetTop&&s.current.offsetTop+c.y>180){const m={};return m.top="inherit",m.bottom=50,m}else if(!s.current.offsetTop&&(a==null?void 0:a.height)-s.current.offsetTop-c.y<120){const m={};return m.top="inherit",m.bottom=50,m}}},[n,s==null?void 0:s.current,c,a]),w=g.useMemo(()=>o?g.createElement("div",{className:"font-style-menu",style:v,onTouchEnd:m=>{m.stopPropagation(),m.nativeEvent.stopImmediatePropagation()},onClick:m=>{m.cancelable&&m.preventDefault(),m.stopPropagation(),m.nativeEvent.stopImmediatePropagation()}},g.createElement(cM,{workIds:i||[B],bold:l,setBold:h,viewId:a==null?void 0:a.viewId}),g.createElement(lM,{workIds:i||[B],underline:p,setUnderline:f,viewId:a==null?void 0:a.viewId}),g.createElement(hM,{workIds:i||[B],lineThrough:I,setLineThrough:y,viewId:a==null?void 0:a.viewId}),g.createElement(uM,{workIds:i||[B],italic:u,setItalic:d,viewId:a==null?void 0:a.viewId})):null,[o,i,l,a==null?void 0:a.viewId,p,I,u,v]);return g.createElement("div",{className:`button normal-button ${o&&"active"}`,onTouchEnd:m=>{m.stopPropagation(),m.nativeEvent.stopImmediatePropagation(),t(!o)},onClick:m=>{m.cancelable&&m.preventDefault(),m.stopPropagation(),m.nativeEvent.stopImmediatePropagation(),t(!o)}},g.createElement("img",{alt:"icon",src:It(o?"font-style-active":"font-style")}),w)},zt=Object.freeze([12,14,18,24,36,48,64,80,144,288]),ae=["top","topLeft","topRight","bottom","bottomLeft","bottomRight","left","leftTop","leftBottom","right","rightTop","rightBottom"],pM=r=>{const{style:o,onClickHandler:t}=r;return g.createElement("div",{className:"font-size-menu",style:o,onTouchEnd:e=>{e.stopPropagation(),e.nativeEvent.stopImmediatePropagation()},onClick:e=>{e.cancelable&&e.preventDefault(),e.stopPropagation(),e.nativeEvent.stopImmediatePropagation()}},zt.map(e=>g.createElement("div",{className:"font-size-btn",key:e,onClick:()=>{t(e)},onTouchEnd:()=>{t(e)}},e)))},fM=r=>{const o=g.useRef(null),{open:t,setOpen:e,textOpt:i,workIds:n,floatBarRef:s}=r,{mananger:a,floatBarData:c}=g.useContext(yt),[l,h]=g.useState(0),[u,d]=g.useState(),p=zt.length-1;g.useEffect(()=>{i!=null&&i.fontSize&&(h(i.fontSize),o.current&&(o.current.value=i.fontSize.toString()))},[i==null?void 0:i.fontSize]);const f=g.useMemo(()=>{if(s!=null&&s.current&&E.isNumber(c==null?void 0:c.y)&&(a!=null&&a.height)){if(s.current.offsetTop&&s.current.offsetTop+c.y>180){const m={};return m.top="inherit",m.bottom=35,m}else if(!s.current.offsetTop&&(a==null?void 0:a.height)-s.current.offsetTop-c.y<120){const m={};return m.top="inherit",m.bottom=35,m}}},[s==null?void 0:s.current,c,a]);function I(m){h(m),m&&m>=zt[0]&&m<=zt[p]&&X.emitMethod(Z.MainEngine,O.SetFontStyle,{workIds:n||[B],fontSize:m,viewId:a==null?void 0:a.viewId})}const y=m=>{var T;(T=o.current)==null||T.blur(),e(!1),w(m)},v=g.useMemo(()=>t?g.createElement(pM,{onClickHandler:y,style:f}):null,[t,y,f]),w=m=>{m>zt[p]&&(m=zt[p]),m<zt[0]&&(m=zt[0]),I(m)};return g.useEffect(()=>()=>{a!=null&&a.control.room&&E.isBoolean(u)&&(a.control.room.disableDeviceInputs=u)},[a,u]),g.createElement("div",{className:"button normal-button font-size-barBtn",style:{width:50},onTouchEnd:m=>{m.stopPropagation(),m.nativeEvent.stopImmediatePropagation()},onClick:m=>{m.cancelable&&m.preventDefault(),m.stopPropagation(),m.nativeEvent.stopImmediatePropagation()}},g.createElement("input",{className:"font-size-input",ref:o,onTouchEnd:()=>{o.current&&o.current.focus()},onClick:()=>{e(!t),o.current&&o.current.focus()},onKeyDown:m=>{if(m.key==="Backspace"){const T=window.getSelection(),N=T==null?void 0:T.getRangeAt(0);if(N!=null&&N.collapsed)return m.cancelable&&m.preventDefault(),document.execCommand("delete",!1),!1}return!1},onKeyUp:m=>{var T;if(o.current){const N=o.current.value,C=parseInt(N);isNaN(C)?o.current.value="0":o.current.value=C.toString(),C&&m.key==="Enter"&&(w(C),(T=o.current)==null||T.blur(),e(!1))}},onFocus:()=>{a!=null&&a.control.room&&!a.control.room.disableDeviceInputs&&(d(a.control.room.disableDeviceInputs),a.control.room.disableDeviceInputs=!0)},onBlur:()=>{a!=null&&a.control.room&&E.isBoolean(u)&&(a.control.room.disableDeviceInputs=u)}}),g.createElement("div",{className:"font-size-btns"},g.createElement("div",{className:"font-size-add",onClick:()=>{w(l+zt[0])},onTouchEnd:()=>{w(l+zt[0])}}),g.createElement("div",{className:"font-size-cut",onClick:()=>{w(l-zt[0])},onTouchEnd:()=>{w(l-zt[0])}})),v)},gM=r=>{const{workIds:o,mananger:t,islocked:e}=r;return g.createElement("div",{className:"button normal-button",onClick:i=>{i.cancelable&&i.preventDefault(),i.stopPropagation(),X.emitMethod(Z.MainEngine,O.SetLock,{workIds:o||[B],isLocked:!e,viewId:t==null?void 0:t.viewId})},onTouchEnd:i=>{i.stopPropagation(),X.emitMethod(Z.MainEngine,O.SetLock,{workIds:o||[B],isLocked:!e,viewId:t==null?void 0:t.viewId})}},g.createElement("img",{alt:"icon",src:It(e?"unlock-new":"lock-new")}))},No=r=>{const{icon:o,min:t,max:e,step:i,value:n,onInputHandler:s}=r,[a,c]=g.useState(0),l=g.useRef(null),h=u=>{u>e&&(u=e),u<t&&(u=t),c(u),s(u),l.current&&(l.current.value=u.toString())};return g.useEffect(()=>{n&&(c(n),l.current&&(l.current.value=n.toString()))},[n]),g.createElement("div",{className:"button input-button",onTouchEnd:u=>{u.stopPropagation(),u.nativeEvent.stopImmediatePropagation()},onClick:u=>{u.cancelable&&u.preventDefault(),u.stopPropagation(),u.nativeEvent.stopImmediatePropagation()}},g.createElement("img",{src:It(o)}),g.createElement("input",{className:"input-number",type:"text",ref:l,onTouchEnd:()=>{l.current&&l.current.focus()},onClick:()=>{l.current&&l.current.focus()},onKeyDown:u=>{if(u.key==="Backspace"){const d=window.getSelection(),p=d==null?void 0:d.getRangeAt(0);if(p!=null&&p.collapsed)return u.cancelable&&u.preventDefault(),document.execCommand("delete",!1),!1}},onKeyUp:()=>{if(l.current){const u=l.current.value,d=parseInt(u);isNaN(d)?l.current.value="0":l.current.value=d.toString()}},onChange:u=>{const d=u.target.value,p=parseInt(d);p&&p&&p>=t&&p<=e&&h(p)}}),g.createElement("div",{className:"input-number-btns"},g.createElement("div",{className:"input-number-add",onClick:()=>{h(a+i)},onTouchEnd:()=>{h(a+i)}}),g.createElement("div",{className:"input-number-cut",onClick:()=>{h(a-i)},onTouchEnd:()=>{h(a-i)}})))},MM=r=>{const{icon:o,min:t,max:e,step:i,value:n,onInputHandler:s}=r;return g.createElement("div",{className:"button input-button"},g.createElement("img",{src:It(o)}),g.createElement(yM,{min:t,max:e,step:i,value:n,onInputHandler:s}))},yM=r=>{const{value:o,min:t,max:e,onInputHandler:i}=r,[n,s]=g.useState({x:0,y:0});g.useEffect(()=>{s({x:o*100,y:0})},[]);const a=E.throttle((h,u)=>{h.cancelable&&h.preventDefault(),h.stopPropagation();let d=Math.floor(Math.max(u.x,t*100));d=Math.floor(Math.min(d,e*100)),u.x!==(n==null?void 0:n.x)&&s({x:d,y:0});const p=d/100;o!==p&&i(p)},100,{leading:!1}),c=h=>{h.cancelable&&h.preventDefault(),h.stopPropagation()},l=E.throttle((h,u)=>{h.cancelable&&h.preventDefault(),h.stopPropagation();let d=Math.floor(Math.max(u.x,t*100));d=Math.floor(Math.min(d,e*100)),u.x!==(n==null?void 0:n.x)&&s({x:d,y:0});const p=d/100;o!==p&&i(p)},100,{leading:!1});return g.createElement("div",{className:"range-number-container",onClick:h=>{const u=h.nativeEvent.offsetX-6;let d=Math.floor(Math.max(u,t*100));d=Math.floor(Math.min(d,e*100)),s({x:d,y:0});const p=d/100;o!==p&&i(p)}},g.createElement("div",{className:"range-number-color"}),g.createElement("div",{className:"range-number"},g.createElement(ge,{bounds:"parent",axis:"x",position:n,onDrag:a,onStart:c,onStop:l},g.createElement("div",{className:"circle",onClick:c}))))},wM=r=>{const{icon:o,value:t,onChangeHandler:e,style:i}=r,[n,s]=g.useState(0),[a,c]=g.useState(),l=g.useRef(null),h=g.useCallback(p=>{p>=ae.length&&(p=0),p<0&&(p=ae.length-1),s(p),e(ae[p]),c(!1),l.current&&(l.current.value=ae[p])},[e]),u=g.useMemo(()=>{if(i&&i.bottom){const p={};return p.top="inherit",p.bottom=50,p}},[i]);g.useEffect(()=>{t&&(s(ae.indexOf(t)),l.current&&(l.current.value=t))},[t]);const d=g.useMemo(()=>a?g.createElement(mM,{options:ae,onClickHandler:h,style:u}):null,[a,h,u]);return g.createElement("div",{className:"button input-button"},g.createElement("img",{src:It(o)}),g.createElement("input",{readOnly:!0,className:"input-number",type:"text",ref:l,onTouchEnd:p=>{p.cancelable&&p.preventDefault(),p.stopPropagation(),l.current&&l.current.focus()},onClick:p=>{p.cancelable&&p.preventDefault(),p.stopPropagation(),l.current&&(l.current.focus(),c(!a))}}),g.createElement("div",{className:"input-number-btns"},g.createElement("div",{className:"input-number-add",onClick:p=>{p.cancelable&&p.preventDefault(),p.stopPropagation(),h(n+1)},onTouchEnd:p=>{p.cancelable&&p.preventDefault(),p.stopPropagation(),h(n+1)}}),g.createElement("div",{className:"input-number-cut",onClick:p=>{p.cancelable&&p.preventDefault(),p.stopPropagation(),h(n-1)},onTouchEnd:p=>{p.cancelable&&p.preventDefault(),p.stopPropagation(),h(n-1)}})),d)},mM=r=>{const{options:o,style:t,onClickHandler:e}=r;return g.createElement("div",{className:"select-option-menu",style:t,onTouchEnd:i=>{i.cancelable&&i.preventDefault(),i.stopPropagation(),i.nativeEvent.stopImmediatePropagation()},onClick:i=>{i.cancelable&&i.preventDefault(),i.stopPropagation(),i.nativeEvent.stopImmediatePropagation()}},o.map((i,n)=>g.createElement("div",{className:"select-option-btn",key:i,onClick:s=>{s.cancelable&&s.preventDefault(),s.stopPropagation(),e(n)},onTouchEnd:s=>{s.cancelable&&s.preventDefault(),s.stopPropagation(),e(n)}},i)))},IM=r=>{const{mananger:o,innerRatio:t,innerVerticeStep:e,vertices:i}=r,n=c=>{X.emitMethod(Z.MainEngine,O.SetShapeOpt,{workIds:[B],toolsType:S.Star,viewId:o.viewId,vertices:c})},s=c=>{X.emitMethod(Z.MainEngine,O.SetShapeOpt,{workIds:[B],toolsType:S.Star,viewId:o.viewId,innerVerticeStep:c})},a=c=>{X.emitMethod(Z.MainEngine,O.SetShapeOpt,{workIds:[B],toolsType:S.Star,viewId:o.viewId,innerRatio:c})};return g.createElement(g.Fragment,null,g.createElement(No,{value:i,icon:"polygon-vertex",min:3,max:100,step:1,onInputHandler:n}),g.createElement(No,{value:e,icon:"star-innerVertex",min:1,max:100,step:1,onInputHandler:s}),g.createElement(MM,{value:t,icon:"star-innerRatio",min:.1,max:1,step:.1,onInputHandler:a}))},vM=r=>{const{mananger:o,vertices:t}=r,e=i=>{X.emitMethod(Z.MainEngine,O.SetShapeOpt,{workIds:[B],toolsType:S.Polygon,viewId:o.viewId,vertices:i})};return g.createElement(No,{value:t,icon:"polygon-vertex",min:3,max:100,step:1,onInputHandler:e})},NM=r=>{const{mananger:o,placement:t}=r,e=i=>{X.emitMethod(Z.MainEngine,O.SetShapeOpt,{workIds:[B],toolsType:S.SpeechBalloon,viewId:o.viewId,placement:i})};return g.createElement(wM,{value:t,icon:"speechBallon-placement",onChangeHandler:e})},go=r=>{const{icon:o,isActive:t,onClickHandler:e,onTouchEndHandler:i}=r;return g.createElement("div",{className:`button tab-button ${t?"active":""}`,onClick:e,onTouchEnd:i},g.createElement("img",{src:It(o)}))},TM=r=>{const{toolsTypes:o,style:t,mananger:e,shapeOpt:i}=r,[n,s]=g.useState();g.useEffect(()=>{o.includes(S.Polygon)?s(S.Polygon):o.includes(S.Star)?s(S.Star):s(S.SpeechBalloon)},[o]);const a=(u,d)=>{d.cancelable&&d.preventDefault(),d==null||d.stopPropagation(),s(u)},c=g.useMemo(()=>n===S.Polygon&&e&&i.vertices?g.createElement(vM,{vertices:i.vertices,mananger:e}):null,[e,n,i]),l=g.useMemo(()=>n===S.Star&&e&&i.vertices&&i.innerVerticeStep&&i.innerRatio?g.createElement(IM,{mananger:e,vertices:i.vertices,innerVerticeStep:i.innerVerticeStep,innerRatio:i.innerRatio}):null,[e,n,i]),h=g.useMemo(()=>n===S.SpeechBalloon&&e&&i.placement?g.createElement(NM,{mananger:e,placement:i.placement}):null,[e,n,i]);return g.createElement("div",{className:"shapeOpt-sub-menu",style:t,onClick:u=>{u.stopPropagation(),u.nativeEvent.stopImmediatePropagation(),u.cancelable&&u.preventDefault()}},g.createElement("div",{className:"shapeOpt-sub-menu-tabs"},o.includes(S.Polygon)&&g.createElement(go,{isActive:n===S.Polygon,icon:n===S.Polygon?"polygon-active":"polygon",onClickHandler:a.bind(void 0,S.Polygon),onTouchEndHandler:a.bind(void 0,S.Polygon)})||null,o.includes(S.Star)&&g.createElement(go,{isActive:n===S.Star,icon:n===S.Star?"star-active":"star",onClickHandler:a.bind(void 0,S.Star),onTouchEndHandler:a.bind(void 0,S.Star)})||null,o.includes(S.SpeechBalloon)&&g.createElement(go,{isActive:n===S.SpeechBalloon,icon:n===S.SpeechBalloon?"speechBallon-active":"speechBallon",onClickHandler:a.bind(void 0,S.SpeechBalloon),onTouchEndHandler:a.bind(void 0,S.SpeechBalloon)})||null),g.createElement("div",{className:"shapeOpt-sub-menu-content"},c,l,h))},SM=r=>{const{open:o,setOpen:t,floatBarRef:e,toolsTypes:i,shapeOpt:n}=r,{floatBarData:s,mananger:a}=g.useContext(yt),[c,l]=g.useState([]),[h,u]=g.useState(),d=g.useMemo(()=>{if(e!=null&&e.current&&E.isNumber(s==null?void 0:s.x)&&E.isNumber(s==null?void 0:s.y)&&(a!=null&&a.height)){if(e.current.offsetTop&&e.current.offsetTop+s.y>200){const y={};return y.top="inherit",y.bottom=50,y}else if(!e.current.offsetTop&&(a==null?void 0:a.height)-e.current.offsetTop-(s==null?void 0:s.y)<140){const y={};return y.top="inherit",y.bottom=50,y}}},[e,s==null?void 0:s.x,s==null?void 0:s.y,a==null?void 0:a.height]),p=g.useMemo(()=>o&&i&&a&&n?(a.control.room&&!a.control.room.disableDeviceInputs&&(u(a.control.room.disableDeviceInputs),a.control.room.disableDeviceInputs=!0),g.createElement(TM,{shapeOpt:n,style:d,toolsTypes:i,mananger:a})):(a!=null&&a.control.room&&E.isBoolean(h)&&(a.control.room.disableDeviceInputs=h),null),[o,d,i,a,n]),f=y=>{y.cancelable&&y.preventDefault(),y.stopPropagation(),y.nativeEvent.stopImmediatePropagation(),t(!o)},I=y=>{y.stopPropagation(),y.nativeEvent.stopImmediatePropagation(),t(!o)};return g.useEffect(()=>{E.isEqual(s==null?void 0:s.selectIds,c)||s!=null&&s.selectIds&&!E.isEqual(s==null?void 0:s.selectIds,c)&&(l(s==null?void 0:s.selectIds),t(!1))},[o,s,c,t]),g.useEffect(()=>()=>{o&&a!=null&&a.control.room&&E.isBoolean(h)&&(a.control.room.disableDeviceInputs=h)},[o,a,h]),g.createElement("div",{className:`button normal-button ${o&&"active"}`,onClick:f,onTouchEnd:I},p,g.createElement("img",{alt:"icon",src:It(o?"shapes-active":"shapes")}))},Cs=g.memo(r=>{const{textOpt:o,workIds:t,noLayer:e,position:i}=r,{floatBarData:n,mananger:s}=g.useContext(yt),[a,c]=g.useState(0),[l,h]=g.useState(),u=g.useRef(null);g.useEffect(()=>{var L,j,A,P;const N={},C=(n==null?void 0:n.w)||((L=o==null?void 0:o.boxSize)==null?void 0:L[0])||0,z=(n==null?void 0:n.h)||((j=o==null?void 0:o.boxSize)==null?void 0:j[1])||0;if(i&&C&&z&&(s!=null&&s.width)&&(s!=null&&s.height)){if(i.y<60?i.y+z<s.height-60?N.bottom=-120:i.y+z<s.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+(((A=u.current)==null?void 0:A.offsetWidth)||C)>s.width){const R=s.width-(((P=u.current)==null?void 0:P.offsetWidth)||C)-i.x;N.left=R}h(N);return}h(void 0)},[u,i,n==null?void 0:n.w,n==null?void 0:n.h,s==null?void 0:s.width,s==null?void 0:s.height,o==null?void 0:o.boxSize]);const d=g.useMemo(()=>n!=null&&n.fillColor?g.createElement(nM,{floatBarRef:u,open:a===3,setOpen:N=>{c(N===!0?3:0)}}):null,[n==null?void 0:n.fillColor,a,u]),p=g.useMemo(()=>n!=null&&n.strokeColor?g.createElement(sM,{floatBarRef:u,open:a===2,setOpen:N=>{c(N===!0?2:0)}}):null,[n==null?void 0:n.strokeColor,a,u]),f=g.useMemo(()=>o!=null&&o.fontColor&&(s!=null&&s.viewId)?g.createElement(rM,{floatBarRef:u,open:a===4,setOpen:N=>{c(N===!0?4:0)},textOpt:o,workIds:t}):null,[o,a,t,s,u]),I=g.useMemo(()=>o!=null&&o.fontBgColor&&(s!=null&&s.viewId)?g.createElement(aM,{floatBarRef:u,open:a===5,setOpen:N=>{c(N===!0?5:0)},textOpt:o,workIds:t}):null,[o,a,t,s,u]),y=g.useMemo(()=>o&&(s!=null&&s.viewId)?g.createElement(dM,{floatBarRef:u,open:a===6,setOpen:N=>{c(N===!0?6:0)},textOpt:o,workIds:t,style:l}):null,[o,a,t,s,l,u]),v=g.useMemo(()=>o&&(s!=null&&s.viewId)?g.createElement(fM,{open:a===7,setOpen:N=>{c(N===!0?7:0)},textOpt:o,workIds:t,floatBarRef:u}):null,[o,a,t,s,u]),w=g.useMemo(()=>e?null:g.createElement(tM,{open:a===1,setOpen:N=>{c(N===!0?1:0)},floatBarRef:u}),[e,a,u]),m=g.useMemo(()=>n!=null&&n.canLock&&s?g.createElement(gM,{workIds:t,mananger:s,islocked:n.isLocked}):null,[n,s,t]),T=g.useMemo(()=>s&&(s!=null&&s.viewId)&&l&&(n!=null&&n.shapeOpt)&&(n!=null&&n.toolsTypes)?g.createElement(SM,{open:a===8,setOpen:N=>{c(N===!0?8:0)},floatBarRef:u,workIds:t,toolsTypes:n.toolsTypes,shapeOpt:n.shapeOpt}):null,[n,s,a,l,t,u]);return g.createElement("div",{className:"appliance-plugin-floatbtns",style:l,ref:u,onMouseOver:N=>(N.stopPropagation(),N.cancelable&&N.preventDefault(),s==null||s.control.worker.blurCursor(s.viewId),!1),onMouseMove:N=>(N.stopPropagation(),N.cancelable&&N.preventDefault(),!1)},s&&g.createElement(Kg,{workIds:t,mananger:s}),w,m,!!(s!=null&&s.viewId)&&g.createElement(_g,{workIds:t,viewId:s.viewId}),T,v,y,f,I,p,d)}),CM=r=>{const{data:o,isActive:t,manager:e,workId:i}=r,{opt:n,scale:s,translate:a,x:c,y:l}=o,h=`scale(${s||1}) ${a&&"translate("+a[0]+"px,"+a[1]+"px)"||""}`,{fontSize:u,fontFamily:d,underline:p,fontColor:f,lineThrough:I,textAlign:y,strokeColor:v,lineHeight:w,bold:m,italic:T,uid:N,workState:C}=n,z=u,L=w||z*1.2,j={fontSize:`${z}px`,lineHeight:`${L}px`,color:f,borderColor:v,minHeight:`${L}px`,paddingRight:`${T==="italic"?Math.round(z*.3):5}px`};d&&(j.fontFamily=`${d}`),(I||p)&&(j.textDecoration=`${I&&"line-through"||""}${p&&" underline"||""}`),m&&(j.fontWeight=`${m}`),T&&(j.fontStyle=`${T}`),y&&(j.textAlign=`${y}`);function A(){var R;t&&(N&&N===((R=e.control.collector)==null?void 0:R.uid)||!N)&&e.control.textEditorManager.active(i)}const P=g.useMemo(()=>{const R=[];if(n.text){const D=ve(n.text);for(let G=0;G<D.length;G++){const ct=D[G];ct===""?R.push(g.createElement("div",{style:{backgroundColor:n.fontBgColor},key:G},g.createElement("br",null))):R.push(g.createElement("div",{style:{backgroundColor:n.fontBgColor},key:G},ct))}}return R.length?R:null},[n.fontBgColor,n.text]);return g.createElement("div",{className:"editor-box",style:{left:`${c}px`,top:`${l}px`,transform:h,transformOrigin:"left top",pointerEvents:"none",opacity:C===b.Done?0:1}},g.createElement("div",{className:`editor ${t?"":"readOnly"}`,style:j,onClick:A},P))},kM=g.memo(r=>{const{data:o,left:t,top:e,workId:i,updateOptInfo:n}=r,{opt:s,scale:a,translate:c}=o,l=g.useRef(null);g.useEffect(()=>{var j,A;if((j=l.current)!=null&&j.offsetWidth&&((A=l.current)!=null&&A.offsetHeight)){const P=s.boxSize;if((P==null?void 0:P[0])!==l.current.offsetWidth||P[1]!==l.current.offsetHeight||!P){const R=[l.current.offsetWidth,l.current.offsetHeight];n({activeTextId:i,update:{boxSize:R,workState:b.Done}})}}},[s.fontSize,s.italic,s.bold,s.boxSize,i]);const h=`scale(${a||1}) ${c&&"translate("+c[0]+"px,"+c[1]+"px)"||""}`,{fontSize:u,fontFamily:d,underline:p,fontColor:f,lineThrough:I,textAlign:y,strokeColor:v,lineHeight:w,bold:m,italic:T}=s,N=u,C=w||N*1.2,z={fontSize:`${N}px`,lineHeight:`${C}px`,color:f,borderColor:v,minHeight:`${C}px`,pointerEvents:"none",paddingRight:`${T==="italic"?Math.round(N*.3):5}px`};d&&(z.fontFamily=`${d}`),(I||p)&&(z.textDecoration=`${I&&"line-through"||""}${p&&" underline"||""}`),y&&(z.textAlign=`${y}`),m&&(z.fontWeight=`${m}`),T&&(z.fontStyle=`${T}`);const L=g.useMemo(()=>{const j=[];if(s.text){const A=ve(s.text);for(let P=0;P<A.length;P++){const R=A[P];R===""?j.push(g.createElement("div",{key:P},g.createElement("br",null))):j.push(g.createElement("div",{key:P},R))}}return j.length?j:null},[s.text]);return g.createElement("div",{className:"editor-box",style:{left:`${t}`,top:`${e}`,transform:h,transformOrigin:"left top",zIndex:1,pointerEvents:"none",opacity:0}},g.createElement("div",{className:"editor readOnly",ref:l,style:z},L))},(r,o)=>!(r.workId!==o.workId||r.left!==o.left||r.top!==o.top||!E.isEqual(r.data,o.data))),zM=r=>{const{data:o,workId:t,isSelect:e,showFloatBtns:i,handleKeyUp:n,handleFocus:s,updateOptInfo:a,manager:c,runAnimation:l}=r,[h,u]=g.useState(),{opt:d,scale:p,translate:f,x:I,y}=o,{fontSize:v,fontFamily:w,underline:m,fontColor:T,lineThrough:N,textAlign:C,strokeColor:z,lineHeight:L,bold:j,italic:A,boxSize:P}=d,R=g.useRef(null),D=g.useMemo(()=>{const ot=v,rt=L||ot*1.2,tt={fontSize:`${ot}px`,lineHeight:`${rt}px`,color:T,borderColor:z,minHeight:`${rt}px`,paddingRight:`${A==="italic"?Math.round(ot*.3):5}px`,borderWidth:`${Math.max(Math.round(1/(p||1)),1)}px`};return w&&(tt.fontFamily=`${w}`),(N||m)&&(tt.textDecoration=`${N&&"line-through"||""} ${m&&" underline"||""}`),C&&(tt.textAlign=`${C}`),j&&(tt.fontWeight=`${j}`),A&&(tt.fontStyle=`${A}`),tt},[j,T,w,v,A,L,N,p,z,C,m]),G=g.useMemo(()=>{const ot=`scale(${p||1}) ${f&&"translate("+f[0]+"px,"+f[1]+"px)"||""}`;return{left:`${I}px`,top:`${y}px`,zIndex:2,pointerEvents:"none",transform:ot,transformOrigin:"left top"}},[p,f,I,y]),ct=g.useMemo(()=>{var ot,rt;return!e&&p&&i&&E.isNumber(I)&&E.isNumber(y)&&d.boxSize&&E.isNumber((ot=d.boxSize)==null?void 0:ot[0])&&E.isNumber((rt=d.boxSize)==null?void 0:rt[1])?g.createElement("div",{className:Nt.FloatBarBtn,style:{left:I,top:y,width:d.boxSize[0]*p,height:d.boxSize[1]*p}},g.createElement(Cs,{position:{x:I,y},textOpt:d,workIds:[t],noLayer:!0})):null},[e,d,i,t,I,y,p]),et=g.useMemo(()=>{let ot="";if(d.text){const rt=ve(d.text);for(let tt=0;tt<rt.length;tt++){const lt=rt[tt];lt===""?ot=ot+"<div><br/></div>":ot=ot+`<div style="background-color:${d.fontBgColor}">${lt}</div>`}}else ot=`<div style="background-color:${d.fontBgColor}"></div>`;return ot},[d.fontBgColor,d.text]),H=g.useMemo(()=>typeof et=="string"?g.createElement("div",{id:t,suppressContentEditableWarning:!0,contentEditable:!0,className:"editor",ref:R,style:D,onKeyDown:Q,onKeyUp:n,onClick:J,onTouchEnd:J,onFocus:s,onPaste:nt,onInput:q,dangerouslySetInnerHTML:{__html:et}}):null,[et,D,t]);g.useEffect(()=>{H&&R.current&&(R.current.click(),setTimeout(()=>{var ot;if(R.current){const rt=window==null?void 0:window.getSelection(),tt=R.current.lastChild;if(rt&&tt){const lt=document.createRange(),gt=((ot=tt.textContent)==null?void 0:ot.length)||0;(tt==null?void 0:tt.nodeName)==="#text"?lt.setStart(tt,gt):lt.setStart(tt,gt&&1||0),lt.collapse(!0),rt.removeAllRanges(),rt.addRange(lt)}}},20))},[H,R.current]),g.useEffect(()=>{var ot,rt,tt,lt;if(H&&((ot=R.current)!=null&&ot.offsetWidth||(rt=R.current)!=null&&rt.offsetHeight||(tt=R.current)!=null&&tt.offsetLeft||(lt=R.current)!=null&&lt.offsetTop)){const gt=[R.current.offsetWidth,R.current.offsetHeight];(P&&P[0]!==gt[0]&&P[1]!==gt[1]||!P)&&a({activeTextId:t,update:{boxSize:gt,workState:b.Doing}})}},[P,H,D,t]);function J(){R.current&&R.current.focus(),l()}function Q(ot){if(ot.key==="Backspace"){const rt=window.getSelection(),tt=rt==null?void 0:rt.getRangeAt(0);if(tt!=null&&tt.collapsed)return ot.cancelable&&ot.preventDefault(),document.execCommand("delete",!1),!1}return l(),!1}function V(ot,rt){const tt=window==null?void 0:window.getSelection();if(tt!=null&&tt.rangeCount&&ot&&tt&&tt.anchorNode){const lt=tt.anchorOffset,gt=tt.anchorNode.textContent||"",Tt=gt.slice(0,lt)||"",Xt=gt.slice(lt)||"",Bt=Tt.concat(ot)||"";K(Bt,Xt,rt)}}function K(ot,rt,tt){const lt=window==null?void 0:window.getSelection();if(!(lt!=null&&lt.rangeCount)||!lt.anchorNode)return;const gt=ot.split(/\n/);let Tt=lt.anchorNode.parentNode;Tt===tt&&(Tt=lt.anchorNode);const Xt=[...tt.childNodes],Bt=[];let jt,lo=lt.anchorOffset;for(;Xt.length;){const vt=Xt.pop();if(vt){if(vt===Tt){let Dt=gt[0];gt.length===1&&(lo=gt[0].length,Dt=gt[0].concat(rt)),Tt.nodeName==="#text"?(Tt.textContent=Dt,jt=Tt):Tt.nodeName==="DIV"&&(Tt.innerText=Dt,jt=Tt.childNodes[0]);break}Bt.push(vt),tt.removeChild(vt)}}if(gt.length>1)for(let vt=1;vt<gt.length;vt++){let Dt=gt[vt];const Ne=document.createElement("div");d.fontBgColor&&(Ne.style.backgroundColor=d.fontBgColor),vt===gt.length-1&&(lo=Dt.length,Dt=Dt.concat(rt)),Dt===""?Ne.innerHTML="<br/>":Ne.innerText=Dt,tt.appendChild(Ne),vt===gt.length-1&&(jt=Ne.childNodes[0])}if(Bt.length){Bt.reverse();for(const vt of Bt)tt.appendChild(vt)}if(jt&&jt.nodeName==="#text"){lt.deleteFromDocument();const vt=document.createRange(),Dt=Math.min(lo,(jt==null?void 0:jt.length)||0);vt.setStart(jt,Dt),vt.collapse(!0),lt.removeAllRanges(),lt.addRange(vt)}}function nt(ot){if(ot.cancelable&&ot.preventDefault(),ot.stopPropagation(),R.current){const rt=(ot.clipboardData||window.clipboardData).getData("text"),tt=window==null?void 0:window.getSelection();if(!(tt!=null&&tt.rangeCount))return;rt&&tt&&tt.anchorNode&&V(rt,R.current),l()}}function q(ot){n(ot),l()}return g.createElement(g.Fragment,null,ct,g.createElement("div",{className:"editor-box",style:G,onFocus:()=>{c.control.room&&!c.control.room.disableDeviceInputs&&(u(c.control.room.disableDeviceInputs),c.control.room.disableDeviceInputs=!0)},onBlur:()=>{c!=null&&c.control.room&&E.isBoolean(h)&&(c.control.room.disableDeviceInputs=h)}},H))};class ks extends g.Component{constructor(o){super(o)}getInnerText(o){const t=[];for(let e=0;e<o.childNodes.length;e++){const i=o.childNodes[e];if(i.nodeName==="#text"&&e===0){const n=i.textContent.split(/\n/),s=n.pop();t.push(...n),s&&t.push(s)}else if(i.nodeName==="DIV"){const n=i.innerText.split(/\n/);if(n.length===2&&n[0]===""&&n[1]==="")t.push("");else{const s=n.shift();s&&t.push(s);const a=n.pop();t.push(...n),a&&t.push(a)}}}return t}updateOptInfo(o){var s,a;const{activeTextId:t,update:e,syncData:i}=o,n=t&&E.cloneDeep(((s=this.props.manager.control.textEditorManager)==null?void 0:s.get(t))||((a=this.props.editors)==null?void 0:a.get(t)));n&&n.opt&&(n.opt={...n.opt,...e},i&&(n.canSync=Object.keys(i).includes("canSync")&&i.canSync||n.canSync,n.canWorker=Object.keys(i).includes("canWorker")&&i.canWorker||n.canWorker),this.props.manager.control.textEditorManager.updateForViewEdited(t,n))}get editorUI(){var o;if((o=this.props.editors)!=null&&o.size){const t=[];return this.props.editors.forEach((e,i)=>{if(this.props.selectIds.includes(i)&&!(this.props.activeTextId==i)&&this.props.box){const{x:s,y:a}=this.props.box,{x:c,y:l}=e,h=`${c-s}px`,u=`${l-a}px`,d=g.createElement(kM,{left:h,top:u,key:i,data:e,workId:i,isSelect:!0,updateOptInfo:this.updateOptInfo.bind(this),manager:this.props.manager});t.push(d)}}),t}return null}render(){return g.createElement(g.Fragment,null,this.editorUI)}}class xM extends ks{constructor(t){super(t);M(this,"ref");M(this,"isRunAnimation");this.ref=g.createRef(),this.isRunAnimation=void 0}runAnimation(){this.isRunAnimation||(this.isRunAnimation=requestAnimationFrame(()=>{var t,e;(t=this.ref)!=null&&t.current&&((e=this.ref)==null||e.current.scrollTo({left:0,behavior:"instant"})),this.isRunAnimation=void 0}))}handleKeyUp(t){const e=this.getInnerText(t.nativeEvent.target),i=this.props.activeTextId;if(i){const n=this.props.manager.control.textEditorManager.get(i),s=Lt(e),a=b.Doing,c=[t.nativeEvent.target.offsetWidth,t.nativeEvent.target.offsetHeight];(!n||n&&(n.opt.text!==s||!E.isEqual(n.opt.boxSize,c)||!E.isEqual(n.opt.workState,a)))&&this.updateOptInfo({activeTextId:i,update:{text:s,boxSize:c,workState:a},syncData:{canSync:!0,canWorker:!0}})}}handleFocus(t){const e=this.props.activeTextId;if(e){const i=this.props.manager.control.textEditorManager.get(e),n=b.Doing,s=[t.nativeEvent.target.offsetWidth,t.nativeEvent.target.offsetHeight];(!i||i&&(!E.isEqual(i.opt.boxSize,s)||!E.isEqual(i.opt.workState,n)))&&this.updateOptInfo({activeTextId:e,update:{boxSize:s,workState:n},syncData:{canSync:!0,canWorker:!0}})}}get editorUI(){var t;if((t=this.props.editors)!=null&&t.size){const e=[];return this.props.editors.forEach((i,n)=>{if(!(this.props.selectIds.includes(n)&&this.props.activeTextId!==n)){const c=this.props.activeTextId==n?g.createElement(zM,{key:n,data:i,workId:n,showFloatBtns:this.props.showFloatBtns||!1,handleFocus:this.handleFocus.bind(this),handleKeyUp:this.handleKeyUp.bind(this),updateOptInfo:this.updateOptInfo.bind(this),manager:this.props.manager,runAnimation:this.runAnimation.bind(this)}):g.createElement(CM,{manager:this.props.manager,isActive:i.opt.workState===b.Doing||i.opt.workState===b.Start||!1,key:n,data:i,workId:n});e.push(c)}}),e}return null}render(){return g.createElement("div",{className:`${this.props.className}`,ref:this.ref},this.editorUI)}}const LM=()=>{const{floatBarData:r}=g.useContext(yt);return g.createElement("div",{className:"appliance-plugin-hightlight-box",style:{borderColor:r==null?void 0:r.selectorColor}},g.createElement("div",{className:"point LT nwse-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),g.createElement("div",{className:"point LC ew-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),g.createElement("div",{className:"point LB nesw-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),g.createElement("div",{className:"point TC ns-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),g.createElement("div",{className:"point RT nesw-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),g.createElement("div",{className:"point RC ew-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),g.createElement("div",{className:"point RB nwse-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),g.createElement("div",{className:"point BC ns-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}))},bM=()=>{const{floatBarData:r,mananger:o}=g.useContext(yt),[t,e]=g.useState(),[i,n]=g.useState();g.useEffect(()=>{const c=[];if(o&&E.isNumber(r==null?void 0:r.x)&&E.isNumber(r==null?void 0:r.y)&&(r!=null&&r.points)){const l=o.viewId;if(o.control.viewContainerManager.getView(l))for(const u of r.points){const d=o.control.viewContainerManager.transformToOriginPoint(u,l);c.push(d)}c[0]&&e({x:c[0][0]-((r==null?void 0:r.x)||0),y:c[0][1]-((r==null?void 0:r.y)||0)}),c[1]&&n({x:c[1][0]-((r==null?void 0:r.x)||0),y:c[1][1]-((r==null?void 0:r.y)||0)})}},[o,r==null?void 0:r.points,r==null?void 0:r.x,r==null?void 0:r.y]);const s=g.useMemo(()=>t?g.createElement("div",{className:"point point-dot",style:{borderColor:r==null?void 0:r.selectorColor,left:t.x,top:t.y}}):null,[r==null?void 0:r.selectorColor,t]),a=g.useMemo(()=>i?g.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 g.createElement("div",{className:"appliance-plugin-hightlight-box",style:{borderColor:r==null?void 0:r.selectorColor}},s,a)},jM=()=>{const{floatBarData:r}=g.useContext(yt);return g.createElement("div",{className:"appliance-plugin-hightlight-box",style:{borderColor:r==null?void 0:r.selectorColor}},g.createElement("div",{className:"point LT nwse-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),g.createElement("div",{className:"point LB nesw-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),g.createElement("div",{className:"point RT nesw-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),g.createElement("div",{className:"point RB nwse-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}))},DM=()=>{const{floatBarData:r}=g.useContext(yt);return g.createElement("div",{className:"appliance-plugin-hightlight-box",style:{borderColor:r==null?void 0:r.selectorColor}},g.createElement("img",{className:"lock",alt:"lock",src:"https://sdk.netless.link/resource/icons/lock.svg"}))},PM=r=>{const{className:o}=r,{floatBarData:t,angle:e,setAngle:i,setOperationType:n,mananger:s}=g.useContext(yt),[a,c]=g.useState(!1),[l,h]=g.useState(new F),[u,d]=g.useState(new F),[p,f]=g.useState(!1);g.useEffect(()=>(X.activeListener(I),()=>{X.unmountActiveListener(I)}),[]);const I=m=>{var T;if(!m){f(!0),c(!1),n(O.None);return}f(!1),(T=s==null?void 0:s.control.room)!=null&&T.disableDeviceInputs&&(s.control.room.disableDeviceInputs=!1)};g.useEffect(()=>{if(t){const m=Math.floor(t.w/2),T=Math.floor(-t.h/2);d(new F(m,T)),h(new F)}},[t]);const y=(m,T)=>{if(m.cancelable&&m.preventDefault(),m.stopPropagation(),s!=null&&s.control.worker.isBusy){f(!0);return}c(!0);const N=Math.round(F.GetAngleByPoints(l,u,new F(T.x,T.y)))||0;i(N),n(O.RotateNode),s!=null&&s.control.room&&(s.control.room.disableDeviceInputs=!0),X.emitMethod(Z.MainEngine,O.RotateNode,{workIds:[B],angle:N,workState:b.Start,viewId:s==null?void 0:s.viewId})},v=be((m,T)=>{if(m.cancelable&&m.preventDefault(),m.stopPropagation(),s!=null&&s.control.worker.isBusy){f(!0);return}c(!1);const N=Math.round(F.GetAngleByPoints(l,u,new F(T.x,T.y)))||0;i(N),n(O.None),s!=null&&s.control.room&&(s.control.room.disableDeviceInputs=!1),X.emitMethod(Z.MainEngine,O.RotateNode,{workIds:[B],angle:N,workState:b.Done,viewId:s==null?void 0:s.viewId})},100,{leading:!1}),w=be((m,T)=>{if(m.cancelable&&m.preventDefault(),m.stopPropagation(),s!=null&&s.control.worker.isBusy){f(!0);return}c(!0);const N=Math.round(F.GetAngleByPoints(l,u,new F(T.x,T.y)))||0;i(N),n(O.RotateNode),X.emitMethod(Z.MainEngine,O.RotateNode,{workIds:[B],angle:N,workState:b.Doing,viewId:s==null?void 0:s.viewId})},100,{leading:!1});return g.createElement(ge,{disabled:p,handle:".appliance-plugin-rotate-mouse-pointer",onStart:y,onDrag:w,onStop:v},g.createElement("div",{className:`${o}`,style:t?{left:t.x-30,top:t.y+t.h+20,touchAction:"none"}:void 0},!a&&g.createElement("div",{className:"appliance-plugin-rotate-btn",style:{backgroundColor:t==null?void 0:t.selectorColor}},g.createElement("img",{alt:"icon",src:It("rotation-button")})),g.createElement("div",{className:`appliance-plugin-rotate-mouse-pointer ${a?"active":""}`},g.createElement("img",{alt:"icon",src:It("rotation")}),g.createElement("div",{className:"angle-icon"},e,"°"))))},EM=r=>{const{floatBarData:o,setOperationType:t,mananger:e}=g.useContext(yt),{onClickHandle:i}=r,[n,s]=g.useState(b.Pending),[a,c]=g.useState(),[l,h]=g.useState(),[u,d]=g.useState(!1);g.useEffect(()=>(X.activeListener(p),()=>{X.unmountActiveListener(p)}),[]);const p=m=>{var T;if(!m||o!=null&&o.isLocked){d(!0),s(b.Pending),t(O.None);return}d(!1),(T=e==null?void 0:e.control.room)!=null&&T.disableDeviceInputs&&(e.control.room.disableDeviceInputs=!1)};g.useEffect(()=>{if(o!=null&&o.isLocked||e!=null&&e.control.worker.isBusy){d(!0),s(b.Pending);return}d(!1)},[o==null?void 0:o.isLocked]),g.useEffect(()=>{E.isNumber(o==null?void 0:o.x)&&E.isNumber(o==null?void 0:o.y)&&(n===b.Pending||n===b.Done)&&h({x:o==null?void 0:o.x,y:o==null?void 0:o.y})},[n,o==null?void 0:o.x,o==null?void 0:o.y]);const f=m=>{if(m.cancelable&&m.preventDefault(),m.stopPropagation(),e!=null&&e.control.worker.isBusy){d(!0),s(b.Pending);return}E.isNumber(o==null?void 0:o.x)&&E.isNumber(o==null?void 0:o.y)&&(t(O.TranslateNode),s(b.Start),c({x:o==null?void 0:o.x,y:o==null?void 0:o.y}),e!=null&&e.control.room&&(e.control.room.disableDeviceInputs=!0),X.emitMethod(Z.MainEngine,O.TranslateNode,{workIds:[B],position:{x:o==null?void 0:o.x,y:o==null?void 0:o.y},workState:b.Start,viewId:e==null?void 0:e.viewId}))},I=E.throttle((m,T)=>{if(m.cancelable&&m.preventDefault(),e!=null&&e.control.worker.isBusy){d(!0),s(b.Pending);return}m.stopPropagation();const N={x:T.x,y:T.y};t(O.None),s(b.Done),e!=null&&e.control.room&&(e.control.room.disableDeviceInputs=!1),X.emitMethod(Z.MainEngine,O.TranslateNode,{workIds:[B],position:N,workState:b.Done,viewId:e==null?void 0:e.viewId})},100,{leading:!1}),y=E.throttle((m,T)=>{if(m.cancelable&&m.preventDefault(),m.stopPropagation(),e!=null&&e.control.worker.isBusy){d(!0),s(b.Pending);return}const N={x:T.x,y:T.y};(T.x!==(o==null?void 0:o.x)||T.y!==(o==null?void 0:o.y))&&(s(b.Doing),X.emitMethod(Z.MainEngine,O.TranslateNode,{workIds:[B],position:N,workState:b.Doing,viewId:e==null?void 0:e.viewId}))},100,{leading:!1}),v=g.useMemo(()=>!!((o==null?void 0:o.scaleType)===at.none&&(o!=null&&o.canLock)),[o]),w=E.throttle(m=>(m.stopPropagation(),m.cancelable&&m.preventDefault(),(a==null?void 0:a.x)===(o==null?void 0:o.x)&&(a==null?void 0:a.y)===(o==null?void 0:o.y)&&i(m),!1),100,{leading:!1});return g.createElement(ge,{disabled:u,position:l,onStart:f,onDrag:y,onStop:I},g.createElement("div",{style:o?{position:"absolute",left:0,top:0,width:o.w,height:o.h,zIndex:2,pointerEvents:v?"none":"auto",touchAction:"none"}:void 0,onClick:m=>{m.persist(),w(m)},onTouchEnd:m=>{m.persist(),w(m)}}))},AM=r=>{const{className:o}=r,[t,e]=g.useState({x:0,y:0,h:0,w:0}),[i,n]=g.useState(),[s,a]=g.useState(),[c,l]=g.useState(),{floatBarData:h,mananger:u}=g.useContext(yt),[d,p]=g.useState(),[f,I]=g.useState(!1);g.useEffect(()=>{if(h&&u){const z={x:h.x,y:h.y,w:h.w,h:h.h};e(z)}return X.activeListener(y),()=>{X.unmountActiveListener(y)}},[]);const y=z=>{var L;if(!z){I(!0);return}I(!1),(L=u==null?void 0:u.control.room)!=null&&L.disableDeviceInputs&&(u.control.room.disableDeviceInputs=!1)},v=z=>[[z.x,z.y],[z.x+z.w,z.y],[z.x+z.w,z.y+z.h],[z.x,z.y+z.h]],w=(z,L)=>{switch(L){case"top":case"topLeft":case"left":return z[2];case"topRight":return z[3];case"right":case"bottomRight":case"bottom":return z[0];case"bottomLeft":return z[1]}},m=(z,L,j,A)=>{let P=!1,R=!1;const D={x:t.x,y:t.y,w:t.w,h:t.h},G=[1,1],ct=[0,0];switch(z){case"top":{const Q=L.height+t.h;Q<0?(R=!0,D.y=t.y+t.h,D.h=Math.abs(Q)):(D.y=t.y-L.height,D.h=t.h+L.height);break}case"topLeft":{const Q=L.width+t.w;Q<0?(P=!0,D.x=t.x+t.w,D.w=Math.abs(Q)):(D.x=t.x-L.width,D.w=t.w+L.width);const V=L.height+t.h;V<0?(R=!0,D.y=t.y+t.h,D.h=Math.abs(V)):(D.y=t.y-L.height,D.h=t.h+L.height);break}case"topRight":{const Q=L.width+t.w;Q<0?(P=!0,D.x=t.x+Q,D.w=Math.abs(Q)):D.w=t.w+L.width;const V=L.height+t.h;V<0?(R=!0,D.y=t.y+t.h,D.h=Math.abs(V)):(D.y=t.y-L.height,D.h=t.h+L.height);break}case"bottom":{const Q=L.height+t.h;Q<0?(R=!0,D.y=t.y+Q,D.h=Math.abs(Q)):D.h=t.h+L.height;break}case"bottomLeft":{const Q=L.width+t.w;Q<0?(P=!0,D.x=t.x+t.w,D.w=Math.abs(Q)):(D.x=t.x-L.width,D.w=t.w+L.width);const V=L.height+t.h;V<0?(R=!0,D.y=t.y+V,D.h=Math.abs(V)):D.h=t.h+L.height;break}case"left":{const Q=L.width+t.w;Q<0?(P=!0,D.x=t.x+t.w,D.w=Math.abs(Q)):(D.x=t.x-L.width,D.w=t.w+L.width);break}case"bottomRight":{const Q=L.width+t.w;Q<0?(P=!0,D.x=t.x+Q,D.w=Math.abs(Q)):D.w=t.w+L.width;const V=L.height+t.h;V<0?(R=!0,D.y=t.y+V,D.h=Math.abs(V)):D.h=t.h+L.height;break}case"right":{const Q=L.width+t.w;Q<0?(P=!0,D.x=t.x+Q,D.w=Math.abs(Q)):D.w=t.w+L.width;break}}G[0]=D.w/t.w,G[1]=D.h/t.h;const H=v(D).map(Q=>j.control.viewContainerManager.transformToScenePoint(Q,j.viewId)),J=w(H,z);return R&&(ct[1]=J[1]-A[1]),P&&(ct[0]=J[0]-A[0]),{scale:G,translate:ct}},T=(z,L)=>{if(z.cancelable&&z.preventDefault(),z.stopPropagation(),u!=null&&u.control.worker.isBusy){I(!0);return}if(h!=null&&h.w&&(h!=null&&h.h)&&u){const j={x:h.x,y:h.y,w:h.w,h:h.h},A=v(j),P=A.map(G=>u.control.viewContainerManager.transformToScenePoint(G,u.viewId)),R=w(A,L),D=w(P,L);e(j),n(R),a(D),l(L),u!=null&&u.control.room&&(u.control.room.disableDeviceInputs=!0),X.emitMethod(Z.MainEngine,O.ScaleNode,{workIds:[B],originPoint:R,scenePoint:D,workState:b.Start,viewId:u.viewId})}},N=E.throttle((z,L,j,A)=>{if(z.cancelable&&z.preventDefault(),z.stopPropagation(),!u||!i||!s)return;if(u!=null&&u.control.worker.isBusy){I(!0);return}const{scale:P,translate:R}=m(L,A,u,s);(!E.isEqual(P,d==null?void 0:d.scale)||!E.isEqual(R,d==null?void 0:d.translate))&&(p({scale:P,translate:R}),X.emitMethod(Z.MainEngine,O.ScaleNode,{workIds:[B],scale:P,dir:L,translate:R,originPoint:i,scenePoint:s,workState:b.Doing,viewId:u.viewId}))},100,{leading:!1}),C=E.throttle(z=>{if(z.cancelable&&z.preventDefault(),z.stopPropagation(),!(!u||!i||!s)){if(u!=null&&u.control.worker.isBusy){I(!0);return}if(u!=null&&u.control.room&&(u.control.room.disableDeviceInputs=!1),d){const{scale:L,translate:j}=d;X.emitMethod(Z.MainEngine,O.ScaleNode,{workIds:[B],scale:L,dir:c,translate:j,originPoint:i,scenePoint:s,workState:b.Done,viewId:u.viewId})}}},100,{leading:!1});return g.createElement(Ls.Resizable,{className:`${o}`,boundsByDirection:!0,minWidth:-(((h==null?void 0:h.x)||0)+((h==null?void 0:h.w)||0)),minHeight:-(((h==null?void 0:h.y)||0)+((h==null?void 0:h.h)||0)),size:{width:(h==null?void 0:h.w)||0,height:(h==null?void 0:h.h)||0},style:{position:"absolute",pointerEvents:"auto",left:h==null?void 0:h.x,top:h==null?void 0:h.y},enable:f?!1:{top:(h==null?void 0:h.scaleType)===at.all&&!0||!1,right:(h==null?void 0:h.scaleType)===at.all&&!0||!1,bottom:(h==null?void 0:h.scaleType)===at.all&&!0||!1,left:(h==null?void 0:h.scaleType)===at.all&&!0||!1,topRight:!0,bottomRight:!0,bottomLeft:!0,topLeft:!0},lockAspectRatio:(h==null?void 0:h.scaleType)===at.proportional,onResizeStart:T,onResize:N,onResizeStop:C})},Ci=r=>{const{id:o,pos:t,pointMap:e,type:i}=r,{setOperationType:n,mananger:s,floatBarData:a}=g.useContext(yt),[c,l]=g.useState({x:0,y:0}),[h,u]=g.useState(b.Pending),[d,p]=g.useState(!1);g.useEffect(()=>(X.activeListener(f),()=>{X.unmountActiveListener(f)}),[]);const f=w=>{var m;if(!w||a!=null&&a.isLocked){p(!0),u(b.Pending),n(O.None);return}p(!1),(m=s==null?void 0:s.control.room)!=null&&m.disableDeviceInputs&&(s.control.room.disableDeviceInputs=!1)};g.useEffect(()=>{E.isNumber(t.x)&&E.isNumber(t.y)&&(h===b.Pending||h===b.Done)&&l({x:t.x,y:t.y})},[t,h]);const I=w=>{if(w.cancelable&&w.preventDefault(),w.stopPropagation(),s!=null&&s.control.worker.isBusy){p(!0),u(b.Pending);return}E.isNumber(t.x)&&E.isNumber(t.y)&&(n(O.SetPoint),u(b.Start),s!=null&&s.control.room&&(s.control.room.disableDeviceInputs=!0),X.emitMethod(Z.MainEngine,O.SetPoint,{workId:B,pointMap:e,workState:b.Start,viewId:s==null?void 0:s.viewId}))},y=E.throttle((w,m)=>{if(w.cancelable&&w.preventDefault(),w.stopPropagation(),s!=null&&s.control.worker.isBusy){p(!0),u(b.Pending);return}const T={x:m.x,y:m.y};if((T.x!==(t==null?void 0:t.x)||T.y!==(t==null?void 0:t.y))&&(s!=null&&s.control.viewContainerManager)){const N=s.control.viewContainerManager.transformToScenePoint([T.x,T.y],s.viewId),C=e.get(o);C&&i==="start"?C[0]=N:C&&i==="end"&&(C[1]=N),u(b.Doing),X.emitMethod(Z.MainEngine,O.SetPoint,{workId:B,pointMap:e,workState:b.Doing,viewId:s==null?void 0:s.viewId})}},100,{leading:!1}),v=E.throttle((w,m)=>{if(w.cancelable&&w.preventDefault(),s!=null&&s.control.worker.isBusy){p(!0),u(b.Pending);return}w.stopPropagation(),n(O.None),u(b.Done);const T={x:m.x,y:m.y};if(s!=null&&s.control.viewContainerManager){const N=s.control.viewContainerManager.transformToScenePoint([T.x,T.y],s.viewId),C=e.get(o);C&&i==="start"?C[0]=N:C&&i==="end"&&(C[1]=N),s!=null&&s.control.room&&(s.control.room.disableDeviceInputs=!1),X.emitMethod(Z.MainEngine,O.SetPoint,{workId:B,pointMap:e,workState:b.Done,viewId:s==null?void 0:s.viewId})}},100,{leading:!1});return g.createElement(ge,{disabled:d,position:c,onStart:I,onDrag:y,onStop:v},g.createElement("div",{className:"appliance-plugin-point-draggable-btn",style:a?{left:0,top:0}:void 0}))},OM=r=>{const{className:o}=r,{floatBarData:t,mananger:e}=g.useContext(yt),[i,n]=g.useState(),[s,a]=g.useState(),[c,l]=g.useState(new Map);g.useEffect(()=>{const d=[];if(e&&(t!=null&&t.points)){const p=e.viewId;if(e.control.viewContainerManager.getView(p))for(const I of t.points){const y=e.control.viewContainerManager.transformToOriginPoint(I,p);d.push(y)}t!=null&&t.selectIds&&t.selectIds.length===1&&(c.set(t.selectIds[0],t.points),l(c))}d[0]&&n({x:d[0][0],y:d[0][1]}),d[1]&&a({x:d[1][0],y:d[1][1]})},[e,t==null?void 0:t.points,t==null?void 0:t.selectIds,c]);const h=g.useMemo(()=>i&&(t!=null&&t.selectIds)?g.createElement(Ci,{pos:i,type:"start",id:t.selectIds[0],pointMap:c}):null,[i,t==null?void 0:t.selectIds,c]),u=g.useMemo(()=>s&&(t!=null&&t.selectIds)?g.createElement(Ci,{pos:s,type:"end",id:t.selectIds[0],pointMap:c}):null,[s,t==null?void 0:t.selectIds,c]);return g.createElement("div",{className:`${o}`},h,u)},RM=g.forwardRef((r,o)=>{const{floatBarData:t,operationType:e}=g.useContext(yt),i=g.useMemo(()=>(t==null?void 0:t.scaleType)!==at.all||e===O.RotateNode?null:g.createElement(LM,null),[t,e]),n=g.useMemo(()=>(t==null?void 0:t.scaleType)!==at.both||e===O.RotateNode?null:g.createElement(bM,null),[t,e]),s=g.useMemo(()=>(t==null?void 0:t.scaleType)!==at.proportional||e===O.RotateNode?null:g.createElement(jM,null),[t,e]),a=g.useMemo(()=>(t==null?void 0:t.scaleType)===at.none&&(t!=null&&t.canLock)?g.createElement(DM,null):null,[t]);return g.createElement("div",{ref:o,style:t?{transform:`translate(${t.x}px,${t.y}px)`,width:t.w,height:t.h,pointerEvents:"none"}:void 0},a,i,n,s,r.children)}),YM=g.forwardRef((r,o)=>{var d;const{floatBarData:t,operationType:e,mananger:i}=g.useContext(yt),{editors:n,activeTextId:s}=r,a=g.useMemo(()=>{var p;return t!=null&&t.canRotate&&((p=t==null?void 0:t.selectIds)==null?void 0:p.length)===1&&(e===O.None||e===O.RotateNode)?g.createElement(PM,{className:Nt.RotateBtn}):null},[t==null?void 0:t.canRotate,(d=t==null?void 0:t.selectIds)==null?void 0:d.length,e]),c=g.useMemo(()=>((t==null?void 0:t.scaleType)===at.all||(t==null?void 0:t.scaleType)===at.proportional)&&(e===O.None||e===O.ScaleNode)&&E.isNumber(t==null?void 0:t.x)&&E.isNumber(t==null?void 0:t.y)?g.createElement(AM,{className:Nt.ResizeBtn}):null,[t==null?void 0:t.scaleType,e,t==null?void 0:t.x,t==null?void 0:t.y]),l=g.useMemo(()=>(t==null?void 0:t.scaleType)===at.both&&(e===O.None||e===O.SetPoint)?g.createElement(OM,{className:Nt.ResizeTowBox}):null,[t==null?void 0:t.scaleType,e]),h=g.useMemo(()=>{const p=(t==null?void 0:t.selectIds)||[];return n&&i&&p&&E.isNumber(t==null?void 0:t.x)&&E.isNumber(t==null?void 0:t.y)&&E.isNumber(t==null?void 0:t.w)&&E.isNumber(t==null?void 0:t.h)?g.createElement(ks,{box:{x:t==null?void 0:t.x,y:t==null?void 0:t.y,w:t==null?void 0:t.w,h:t==null?void 0:t.h},manager:i,selectIds:p,activeTextId:s,editors:n}):null},[t==null?void 0:t.selectIds,t==null?void 0:t.x,t==null?void 0:t.y,t==null?void 0:t.w,t==null?void 0:t.h,n,i,s]),u=g.useMemo(()=>e===O.None&&E.isNumber(t==null?void 0:t.x)&&E.isNumber(t==null?void 0:t.y)&&E.isNumber(t==null?void 0:t.w)&&E.isNumber(t==null?void 0:t.h)?g.createElement("div",{className:Nt.FloatBarBtn,style:{left:t==null?void 0:t.x,top:t==null?void 0:t.y,width:t.w,height:t.h}},g.createElement(Cs,{position:{x:t.x,y:t.y},textOpt:t==null?void 0:t.textOpt,noLayer:t==null?void 0:t.isLocked})):null,[t==null?void 0:t.x,t==null?void 0:t.y,t==null?void 0:t.w,t==null?void 0:t.h,t==null?void 0:t.textOpt,t==null?void 0:t.isLocked,e]);return g.createElement("div",{className:Nt.FloatBar,onMouseOver:()=>{i==null||i.control.worker.blurCursor(i.viewId)}},g.createElement(RM,{ref:o},g.createElement(g.Fragment,null,h)),g.createElement(EM,{onClickHandle:p=>{if(i&&(n!=null&&n.size)){const f=i.getPoint(p.nativeEvent);f&&i.control.textEditorManager.computeTextActive(f,i.viewId)}}}),a,c,l,u)}),WM=g.memo(YM,(r,o)=>!!E.isEqual(r,o)),UM="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAAA0CAYAAADFeBvrAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAYISURBVHgB7ZpNSCtXFIBPEuvz+dMGpYUKD/sWFX+Qti6kK7Hqpm6e9q0rIoIUFUShPLV10VZx4+JZqa9v20LBhdq9fyBUCtKNPH8qYl2IOw3G38Rkek4y15y5uTOZJDOWggcOSSYzN/ebc+45554JwIM8iBCPyTEP+86T4vyMfsRN4b+nQTKIJp0vzuGvlpID7os8EQNEIBD4oKio6Bm9DwaDv/v9/n/076JgbtWUYPchwrW8qD7UnOvr6wFNkpubm+/wu7f0c7y6mrnlvQufxB0Iau7V1dX3BDA/P6/V1dVpzc3N2uLiIofK1c8VYHys/wRKBUN3/hGHqaysNOjc3FwMis6hc0FtLTHuvYLxCCZgci8uLn4wg5Gh6Fy8Jk+/NkcCAlAAuUkoW4g0B+d5tLS05O/r67O8eGxsDNra2uDy8nKsoKCAwCIQDxQa0yTxgrvCYXyTk5Ml+Orf2dlJeeHIyAigFSE/P38ELfUNqNdSkjgF5FF89jL1TU1NlQwOD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NPsMBO6KAEeE4BMaCU67RsoYhSbXgaT//ht709vZCaWmp6YkEbLFmVJWzas04+iBL7EKpm0J7duqu0B7+CTUpNJuyvb1NCfMj1CqI9wLKUOlOUMeG+gGFkHii4HizUF4z/KFUrPsJ8WbEIyx7nnZ0dDynME6BAuce09iFHo+GrnmGltltb2//E4wVAN82y7vOjKOZXSBhJdHNiT3TYWD8OY2PTUJkdd7MkJMnT5wZVQF2RFX6yBMUdzPMvvfqxz3sXHF+GNT9ANXit/10O1sgHkZvdQAOKvs9B5L7ARELGAAXLSTvM8QExTE+YbHe+HURhZp1aRyF4CJXClbbWwGketgkW9VsY+YaiBCVhfgE+XvxRwgZSM4jUVCDZFQ9pytmXR8hUTB2gnidx4XffVWydN0yQjwmx/jkAZJBrIBI5J7ZvQGZWUgVSuU/EqmOAzicKNMVu816DdRWUV1/7xAP8n+SfwF3Du3NF2sYhwAAAABJRU5ErkJggg==",BM="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20width='40px'%20height='40px'%20viewBox='0%200%2040%2040'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3c!--%20Generator:%20Sketch%2060.1%20(88133)%20-%20https://sketch.com%20--%3e%3ctitle%3eshape-cursor%3c/title%3e%3cdesc%3eCreated%20with%20Sketch.%3c/desc%3e%3cdefs%3e%3cpath%20d='M20,21.5%20C20.2454599,21.5%2020.4496084,21.6768752%2020.4919443,21.9101244%20L20.5,22%20L20.5,27%20C20.5,27.2761424%2020.2761424,27.5%2020,27.5%20C19.7545401,27.5%2019.5503916,27.3231248%2019.5080557,27.0898756%20L19.5,27%20L19.5,22%20C19.5,21.7238576%2019.7238576,21.5%2020,21.5%20Z%20M27,19.5%20C27.2761424,19.5%2027.5,19.7238576%2027.5,20%20C27.5,20.2454599%2027.3231248,20.4496084%2027.0898756,20.4919443%20L27,20.5%20L22,20.5%20C21.7238576,20.5%2021.5,20.2761424%2021.5,20%20C21.5,19.7545401%2021.6768752,19.5503916%2021.9101244,19.5080557%20L22,19.5%20L27,19.5%20Z%20M18,19.5%20C18.2761424,19.5%2018.5,19.7238576%2018.5,20%20C18.5,20.2454599%2018.3231248,20.4496084%2018.0898756,20.4919443%20L18,20.5%20L13,20.5%20C12.7238576,20.5%2012.5,20.2761424%2012.5,20%20C12.5,19.7545401%2012.6768752,19.5503916%2012.9101244,19.5080557%20L13,19.5%20L18,19.5%20Z%20M20,12.5%20C20.2454599,12.5%2020.4496084,12.6768752%2020.4919443,12.9101244%20L20.5,13%20L20.5,18%20C20.5,18.2761424%2020.2761424,18.5%2020,18.5%20C19.7545401,18.5%2019.5503916,18.3231248%2019.5080557,18.0898756%20L19.5,18%20L19.5,13%20C19.5,12.7238576%2019.7238576,12.5%2020,12.5%20Z'%20id='path-1'%3e%3c/path%3e%3cfilter%20x='-64.6%25'%20y='-59.5%25'%20width='229.3%25'%20height='246.1%25'%20filterUnits='objectBoundingBox'%20id='filter-2'%3e%3cfeMorphology%20radius='1'%20operator='dilate'%20in='SourceAlpha'%20result='shadowSpreadOuter1'%3e%3c/feMorphology%3e%3cfeOffset%20dx='0'%20dy='2'%20in='shadowSpreadOuter1'%20result='shadowOffsetOuter1'%3e%3c/feOffset%3e%3cfeGaussianBlur%20stdDeviation='3'%20in='shadowOffsetOuter1'%20result='shadowBlurOuter1'%3e%3c/feGaussianBlur%3e%3cfeComposite%20in='shadowBlurOuter1'%20in2='SourceAlpha'%20operator='out'%20result='shadowBlurOuter1'%3e%3c/feComposite%3e%3cfeColorMatrix%20values='0%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200.16%200'%20type='matrix'%20in='shadowBlurOuter1'%3e%3c/feColorMatrix%3e%3c/filter%3e%3c/defs%3e%3cg%20id='页面-4'%20stroke='none'%20stroke-width='1'%20fill='none'%20fill-rule='evenodd'%3e%3cg%20id='Whiteboard-Guidelines'%20transform='translate(-344.000000,%20-751.000000)'%3e%3cg%20id='shape-cursor'%20transform='translate(344.000000,%20751.000000)'%3e%3crect%20id='矩形备份-44'%20fill='%23FFFFFF'%20opacity='0.01'%20x='0'%20y='0'%20width='40'%20height='40'%20rx='2'%3e%3c/rect%3e%3cg%20id='形状结合'%20fill-rule='nonzero'%3e%3cuse%20fill='black'%20fill-opacity='1'%20filter='url(%23filter-2)'%20xlink:href='%23path-1'%3e%3c/use%3e%3cpath%20stroke='%23FFFFFF'%20stroke-width='1'%20d='M20,21%20C20.4854103,21%2020.898085,21.3479993%2020.9899479,21.8654877%20L21,22%20L21,27%20C21,27.5522847%2020.5522847,28%2020,28%20C19.5145897,28%2019.101915,27.6520007%2019.0100521,27.1345123%20L19,27%20L19,22%20C19,21.4477153%2019.4477153,21%2020,21%20Z%20M27,19%20C27.5522847,19%2028,19.4477153%2028,20%20C28,20.4854103%2027.6520007,20.898085%2027.1345123,20.9899479%20L27,21%20L22,21%20C21.4477153,21%2021,20.5522847%2021,20%20C21,19.5145897%2021.3479993,19.101915%2021.8654877,19.0100521%20L22,19%20L27,19%20Z%20M18,19%20C18.5522847,19%2019,19.4477153%2019,20%20C19,20.4854103%2018.6520007,20.898085%2018.1345123,20.9899479%20L18,21%20L13,21%20C12.4477153,21%2012,20.5522847%2012,20%20C12,19.5145897%2012.3479993,19.101915%2012.8654877,19.0100521%20L13,19%20L18,19%20Z%20M20,12%20C20.4854103,12%2020.898085,12.3479993%2020.9899479,12.8654877%20L21,13%20L21,18%20C21,18.5522847%2020.5522847,19%2020,19%20C19.5145897,19%2019.101915,18.6520007%2019.0100521,18.1345123%20L19,18%20L19,13%20C19,12.4477153%2019.4477153,12%2020,12%20Z'%20fill='%23212324'%20fill-rule='evenodd'%3e%3c/path%3e%3c/g%3e%3crect%20id='矩形'%20fill='%23FFFFFF'%20x='18.5'%20y='17'%20width='3'%20height='6'%3e%3c/rect%3e%3crect%20id='矩形'%20fill='%23FFFFFF'%20x='17'%20y='18.5'%20width='6'%20height='3'%3e%3c/rect%3e%3cpath%20d='M20,21.5%20C20.2454599,21.5%2020.4496084,21.6768752%2020.4919443,21.9101244%20L20.5,22%20L20.5,27%20C20.5,27.2761424%2020.2761424,27.5%2020,27.5%20C19.7545401,27.5%2019.5503916,27.3231248%2019.5080557,27.0898756%20L19.5,27%20L19.5,22%20C19.5,21.7238576%2019.7238576,21.5%2020,21.5%20Z%20M27,19.5%20C27.2761424,19.5%2027.5,19.7238576%2027.5,20%20C27.5,20.2454599%2027.3231248,20.4496084%2027.0898756,20.4919443%20L27,20.5%20L22,20.5%20C21.7238576,20.5%2021.5,20.2761424%2021.5,20%20C21.5,19.7545401%2021.6768752,19.5503916%2021.9101244,19.5080557%20L22,19.5%20L27,19.5%20Z%20M18,19.5%20C18.2761424,19.5%2018.5,19.7238576%2018.5,20%20C18.5,20.2454599%2018.3231248,20.4496084%2018.0898756,20.4919443%20L18,20.5%20L13,20.5%20C12.7238576,20.5%2012.5,20.2761424%2012.5,20%20C12.5,19.7545401%2012.6768752,19.5503916%2012.9101244,19.5080557%20L13,19.5%20L18,19.5%20Z%20M20,12.5%20C20.2454599,12.5%2020.4496084,12.6768752%2020.4919443,12.9101244%20L20.5,13%20L20.5,18%20C20.5,18.2761424%2020.2761424,18.5%2020,18.5%20C19.7545401,18.5%2019.5503916,18.3231248%2019.5080557,18.0898756%20L19.5,18%20L19.5,13%20C19.5,12.7238576%2019.7238576,12.5%2020,12.5%20Z'%20id='形状结合'%20fill='%23212324'%20fill-rule='nonzero'%3e%3c/path%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e",$M="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20width='47px'%20height='40px'%20viewBox='0%200%2047%2040'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3c!--%20Generator:%20Sketch%2060.1%20(88133)%20-%20https://sketch.com%20--%3e%3ctitle%3etext-cursor%3c/title%3e%3cdesc%3eCreated%20with%20Sketch.%3c/desc%3e%3cdefs%3e%3cpath%20d='M16,26.5%20C15.7238576,26.5%2015.5,26.2761424%2015.5,26%20C15.5,25.7545401%2015.6768752,25.5503916%2015.9101244,25.5080557%20L16,25.5%20L19.5,25.5%20L19.5,14.5%20L16,14.5%20C15.7238576,14.5%2015.5,14.2761424%2015.5,14%20C15.5,13.7545401%2015.6768752,13.5503916%2015.9101244,13.5080557%20L16,13.5%20L24,13.5%20C24.2761424,13.5%2024.5,13.7238576%2024.5,14%20C24.5,14.2454599%2024.3231248,14.4496084%2024.0898756,14.4919443%20L24,14.5%20L20.5,14.5%20L20.5,25.5%20L24,25.5%20C24.2761424,25.5%2024.5,25.7238576%2024.5,26%20C24.5,26.2454599%2024.3231248,26.4496084%2024.0898756,26.4919443%20L24,26.5%20L16,26.5%20Z'%20id='path-1'%3e%3c/path%3e%3cfilter%20x='-284.0%25'%20y='-81.5%25'%20width='668.1%25'%20height='293.9%25'%20filterUnits='objectBoundingBox'%20id='filter-2'%3e%3cfeMorphology%20radius='1'%20operator='dilate'%20in='SourceAlpha'%20result='shadowSpreadOuter1'%3e%3c/feMorphology%3e%3cfeOffset%20dx='0'%20dy='2'%20in='shadowSpreadOuter1'%20result='shadowOffsetOuter1'%3e%3c/feOffset%3e%3cfeGaussianBlur%20stdDeviation='3'%20in='shadowOffsetOuter1'%20result='shadowBlurOuter1'%3e%3c/feGaussianBlur%3e%3cfeComposite%20in='shadowBlurOuter1'%20in2='SourceAlpha'%20operator='out'%20result='shadowBlurOuter1'%3e%3c/feComposite%3e%3cfeColorMatrix%20values='0%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200.16%200'%20type='matrix'%20in='shadowBlurOuter1'%3e%3c/feColorMatrix%3e%3c/filter%3e%3c/defs%3e%3cg%20id='页面-4'%20stroke='none'%20stroke-width='1'%20fill='none'%20fill-rule='evenodd'%3e%3cg%20id='Whiteboard-Guidelines'%20transform='translate(-388.000000,%20-672.000000)'%3e%3cg%20id='text-cursor'%20transform='translate(392.000000,%20672.000000)'%3e%3crect%20id='矩形备份-40'%20fill='%23FFFFFF'%20opacity='0.01'%20x='0'%20y='0'%20width='40'%20height='40'%20rx='2'%3e%3c/rect%3e%3cg%20id='形状结合'%20fill-rule='nonzero'%3e%3cuse%20fill='black'%20fill-opacity='1'%20filter='url(%23filter-2)'%20xlink:href='%23path-1'%3e%3c/use%3e%3cpath%20stroke='%23FFFFFF'%20stroke-width='1'%20d='M19,25%20L19,15%20L16,15%20C15.4477153,15%2015,14.5522847%2015,14%20C15,13.5145897%2015.3479993,13.101915%2015.8654877,13.0100521%20L16,13%20L24,13%20C24.5522847,13%2025,13.4477153%2025,14%20C25,14.4854103%2024.6520007,14.898085%2024.1345123,14.9899479%20L24,15%20L21,15%20L21,25%20L24,25%20C24.5522847,25%2025,25.4477153%2025,26%20C25,26.4854103%2024.6520007,26.898085%2024.1345123,26.9899479%20L24,27%20L16,27%20C15.4477153,27%2015,26.5522847%2015,26%20C15,25.5145897%2015.3479993,25.101915%2015.8654877,25.0100521%20L16,25%20L19,25%20Z'%20fill='%23212324'%20fill-rule='evenodd'%3e%3c/path%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e";class FM extends g.Component{constructor(t){super(t);M(this,"renderAvatar",t=>{var i;const e=`rgb(${t.memberState.strokeColor[0]}, ${t.memberState.strokeColor[1]}, ${t.memberState.strokeColor[2]})`;if(this.detectAvatar(t)){const n=this.detectCursorName(t);return g.createElement("img",{className:"cursor-selector-avatar",style:{width:n?19:28,height:n?19:28,position:n?"initial":"absolute",borderColor:n?"white":e,marginRight:n?4:0},src:(i=t.payload)==null?void 0:i.avatar,alt:"avatar"})}else return null});M(this,"getOpacity",t=>{const e=this.getCursorName(t),i=this.detectAvatar(t);return e===void 0&&i===void 0?0:1});M(this,"getCursorName",t=>{if(t.payload&&t.payload.cursorName)return t.payload.cursorName});M(this,"getThemeClass",t=>t.payload&&t.payload.theme?"cursor-inner-mellow":"cursor-inner");M(this,"getCursorBackgroundColor",t=>{const e=this.detectCursorName(t);return t.payload&&t.payload.cursorBackgroundColor?t.payload.cursorBackgroundColor:e?`rgb(${t.memberState.strokeColor[0]}, ${t.memberState.strokeColor[1]}, ${t.memberState.strokeColor[2]})`:void 0});M(this,"getCursorTextColor",t=>t.payload&&t.payload.cursorTextColor?t.payload.cursorTextColor:"#FFFFFF");M(this,"getCursorTagBackgroundColor",t=>t.payload&&t.payload.cursorTagBackgroundColor?t.payload.cursorTagBackgroundColor:this.getCursorBackgroundColor(t));M(this,"detectCursorName",t=>!!(t.payload&&t.payload.cursorName));M(this,"detectAvatar",t=>!!(t.payload&&t.payload.avatar));M(this,"renderTag",t=>{if(t.payload&&t.payload.cursorTagName)return g.createElement("span",{className:"cursor-tag-name",style:{backgroundColor:this.getCursorTagBackgroundColor(t)}},t.payload.cursorTagName)})}render(){const{roomMember:t}=this.props,e=this.getCursorName(t);switch(t.memberState.currentApplianceName){case st.pencil:return g.createElement("div",{className:"cursor-box"},g.createElement("div",{className:"cursor-mid cursor-pencil-offset",style:{transform:"translate(-50%, -90%)",marginLeft:"10px"}},g.createElement("div",{className:"cursor-name"},g.createElement("div",{style:{opacity:this.getOpacity(t),backgroundColor:this.getCursorBackgroundColor(t),color:this.getCursorTextColor(t)},className:this.getThemeClass(t)},this.renderAvatar(t),e,this.renderTag(t))),g.createElement("div",null,g.createElement("img",{className:"cursor-pencil-image",src:UM,alt:"pencilCursor"}))));case st.text:return g.createElement("div",{className:"cursor-box"},g.createElement("div",{className:"cursor-mid cursor-pencil-offset",style:{transform:"translate(-50%, -65%)",marginLeft:"0px"}},g.createElement("div",{className:"cursor-name"},g.createElement("div",{style:{opacity:this.getOpacity(t),backgroundColor:this.getCursorBackgroundColor(t),color:this.getCursorTextColor(t)},className:this.getThemeClass(t)},this.renderAvatar(t),e,this.renderTag(t))),g.createElement("div",null,g.createElement("img",{className:"cursor-arrow-image",src:$M,alt:"textCursor"}))));case st.rectangle:case st.arrow:case st.straight:case st.shape:case st.ellipse:return g.createElement("div",{className:"cursor-box"},g.createElement("div",{className:"cursor-mid cursor-pencil-offset",style:{transform:"translate(-50%, -65%)",marginLeft:"0px"}},g.createElement("div",{className:"cursor-name"},g.createElement("div",{style:{opacity:this.getOpacity(t),backgroundColor:this.getCursorBackgroundColor(t),color:this.getCursorTextColor(t)},className:this.getThemeClass(t)},this.renderAvatar(t),e,this.renderTag(t))),g.createElement("div",null,g.createElement("img",{className:"cursor-arrow-image",src:BM,alt:"shapeCursor"}))));default:return null}}}const HM=r=>{const{className:o,info:t}=r,{roomMember:e,...i}=t||{};return g.createElement("div",{className:`${o}`,style:i?{transform:`translate(${i.x}px, ${i.y}px)`}:{display:"none"}},e&&g.createElement(FM,{roomMember:e}))},QM=r=>{const{className:o,manager:t}=r,[e,i]=g.useState();g.useEffect(()=>(t.internalMsgEmitter.on([Z.Cursor,t.viewId],n),()=>{t.internalMsgEmitter.off([Z.Cursor,t.viewId],n)}),[t]);function n(a){i(a)}return g.useMemo(()=>{if(e!=null&&e.length){const a=e.map(c=>{var l;return c.roomMember?g.createElement(HM,{key:(l=c.roomMember)==null?void 0:l.memberId,className:o,info:c}):null});return g.createElement(g.Fragment,null,a)}return null},[e])},yt=g.createContext({mananger:void 0,floatBarColors:[],floatBarData:void 0,dpr:1,angle:0,operationType:O.None,scale:[1,1],setAngle:()=>{},setOperationType:()=>{},setFloatBarData:()=>{}});class Yo extends g.Component{constructor(t){var e;super(t);M(this,"setAngle",t=>{this.setState({angle:t})});M(this,"setOperationType",t=>{this.setState({operationType:t})});this.state={floatBarData:void 0,showFloatBar:!1,dpr:1,angle:0,operationType:O.None,scale:[1,1],editors:this.editors,activeTextId:(e=this.props.mananger.control.textEditorManager)==null?void 0:e.activeId}}get editors(){return Qt(this.props.mananger.control.textEditorManager.filterEditor(this.props.mananger.viewId))}componentDidMount(){this.props.mananger.vDom=this,this.props.mananger.mountView(),this.setState({dpr:this.props.mananger.dpr})}componentWillUnmount(){}showFloatBar(t,e){const i=t&&e&&{...this.state.floatBarData,...e}||void 0;this.setState({showFloatBar:t,floatBarData:i,angle:0})}setActiveTextEditor(t){this.setState({activeTextId:t,editors:this.editors})}setFloatBarData(t){this.state.floatBarData&&this.setState({floatBarData:{...this.state.floatBarData,...t}})}render(){var e,i,n,s,a,c,l;const t=!!((i=(e=this.props.mananger.control)==null?void 0:e.room)!=null&&i.floatBarOptions);return g.createElement("div",{className:Nt.Container},!this.props.mananger.control.hasOffscreenCanvas()&&g.createElement("div",{className:Nt.CanvasBox,ref:this.props.refs.canvasContainerRef})||g.createElement("div",{className:Nt.CanvasBox,onMouseDown:h=>{h.cancelable&&h.preventDefault(),h.stopPropagation()},onTouchStart:h=>{h.stopPropagation()},onMouseMove:h=>{this.props.mananger.cursorMouseMove(h)}},g.createElement("canvas",{id:"bgCanvas",ref:this.props.refs.canvasBgRef,style:{width:"100%",height:"100%"}}),g.createElement("canvas",{id:"serviceCanvas",className:Nt.FloatCanvas,ref:this.props.refs.canvasServiceFloatRef,style:{width:"100%",height:"100%"}}),g.createElement("canvas",{id:"localCanvas",className:Nt.FloatCanvas,ref:this.props.refs.canvasFloatRef,style:{width:"100%",height:"100%"}}),g.createElement("div",{id:"subLocalCanvas",className:Nt.CanvasBoxSub,ref:this.props.refs.subLocalCanvasContainerRef}),g.createElement("canvas",{id:"topCanvas",className:Nt.TopFloatCanvas,ref:this.props.refs.canvasTopRef,style:{width:"100%",height:"100%"}})),!this.props.mananger.control.hasOffscreenCanvas()&&this.props.refs.snapshotContainerRef&&g.createElement("div",{className:Nt.SnapshotBox,ref:this.props.refs.snapshotContainerRef})||null,g.createElement(yt.Provider,{value:{mananger:this.props.mananger,floatBarColors:t&&((a=(s=(n=this.props.mananger.control)==null?void 0:n.room)==null?void 0:s.floatBarOptions)==null?void 0:a.colors)||[],floatBarData:this.state.floatBarData,dpr:this.state.dpr,angle:this.state.angle,operationType:this.state.operationType,scale:this.state.scale,setAngle:this.setAngle.bind(this),setOperationType:this.setOperationType.bind(this),setFloatBarData:this.setFloatBarData.bind(this)}},this.state.showFloatBar&&g.createElement(WM,{ref:this.props.refs.floatBarRef,editors:this.state.editors,activeTextId:this.state.activeTextId})||null,((c=this.state.editors)==null?void 0:c.size)&&g.createElement(xM,{className:Nt.TextEditorContainer,showFloatBtns:t,manager:this.props.mananger,selectIds:((l=this.state.floatBarData)==null?void 0:l.selectIds)||[],editors:this.state.editors,activeTextId:this.state.activeTextId})||null),g.createElement(QM,{className:Nt.CursorBox,manager:this.props.mananger}))}}class VM extends Ts{constructor(t,e){super(t,e);M(this,"width",1e3);M(this,"height",1e3);M(this,"dpr",1);M(this,"vDom");M(this,"eventTragetElement");M(this,"snapshotContainerRef");M(this,"canvasContainerRef",g.createRef());M(this,"subLocalCanvasContainerRef",g.createRef());M(this,"canvasTopRef",g.createRef());M(this,"canvasServiceFloatRef",g.createRef());M(this,"canvasFloatRef",g.createRef());M(this,"canvasBgRef",g.createRef());M(this,"floatBarRef",g.createRef());M(this,"containerOffset",{x:0,y:0});this.control.hasOffscreenCanvas()||(this.snapshotContainerRef=g.createRef())}setCanvassStyle(){if(this.eventTragetElement){const t=this.eventTragetElement.offsetWidth||this.width,e=this.eventTragetElement.offsetHeight||this.height;t&&e&&this.canvasContainerRef.current&&(t!==this.width||e!==this.height)&&(this.dpr=Jt(),this.width=t,this.height=e,this.canvasContainerRef.current.style.width=`${t}px`,this.canvasContainerRef.current.style.height=`${e}px`),t&&e&&this.snapshotContainerRef&&this.snapshotContainerRef.current&&(t!==this.width||e!==this.height)&&(this.dpr=Jt(),this.width=t,this.height=e),t&&e&&this.canvasBgRef.current&&(t!==this.width||e!==this.height)&&(this.dpr=Jt(this.canvasBgRef.current.getContext("2d")),this.width=t,this.height=e,this.canvasBgRef.current.width=t*this.dpr,this.canvasBgRef.current.height=e*this.dpr,this.canvasFloatRef.current&&(this.canvasFloatRef.current.width=t*this.dpr,this.canvasFloatRef.current.height=e*this.dpr),this.canvasServiceFloatRef.current&&(this.canvasServiceFloatRef.current.width=t*this.dpr,this.canvasServiceFloatRef.current.height=e*this.dpr),this.canvasTopRef.current&&(this.canvasTopRef.current.width=t*this.dpr,this.canvasTopRef.current.height=e*this.dpr))}}destroy(){if(super.destroy(),this.eventTragetElement){const t=this.eventTragetElement.parentElement;if(t){const e=t.querySelectorAll(".appliance-plugin-main-view-displayer");for(const i of e)i.remove()}}}createMainViewDisplayer(t){const e=document.createElement("div");return e.className="appliance-plugin-main-view-displayer",t.appendChild(e),this.eventTragetElement=t.children[0],this.containerOffset=this.getContainerOffset(this.eventTragetElement,this.containerOffset),this.bindToolsClass(),ko.render(g.createElement(Yo,{viewId:this.viewId,mananger:this,refs:{canvasServiceFloatRef:this.canvasServiceFloatRef,canvasFloatRef:this.canvasFloatRef,canvasBgRef:this.canvasBgRef,floatBarRef:this.floatBarRef,canvasTopRef:this.canvasTopRef,canvasContainerRef:this.canvasContainerRef,snapshotContainerRef:this.snapshotContainerRef,subLocalCanvasContainerRef:this.subLocalCanvasContainerRef}}),e),this.control.room&&this.bindDisplayerEvent(this.eventTragetElement),this}}class ZM extends Rg{constructor(t,e,i){super(t,e,i);M(this,"dpr",1);M(this,"width",1e3);M(this,"height",1e3);M(this,"vDom");M(this,"eventTragetElement");M(this,"canvasContainerRef",g.createRef());M(this,"subLocalCanvasContainerRef",g.createRef());M(this,"canvasTopRef",g.createRef());M(this,"canvasServiceFloatRef",g.createRef());M(this,"canvasFloatRef",g.createRef());M(this,"canvasBgRef",g.createRef());M(this,"floatBarRef",g.createRef());M(this,"containerOffset",{x:0,y:0})}setCanvassStyle(){if(this.eventTragetElement){if(this.canvasContainerRef.current){const t=this.eventTragetElement.offsetWidth||this.width,e=this.eventTragetElement.offsetHeight||this.height;t&&e&&(t!==this.width||e!==this.height)&&(this.width=t,this.height=e,this.dpr=Jt(),this.canvasContainerRef.current.style.width=`${t}px`,this.canvasContainerRef.current.style.height=`${e}px`)}if(this.canvasBgRef.current){this.dpr=Jt(this.canvasBgRef.current.getContext("2d"));const t=this.eventTragetElement.offsetWidth||this.width,e=this.eventTragetElement.offsetHeight||this.height;t&&e&&(t!==this.width||e!==this.height)&&(this.width=t,this.height=e,this.canvasBgRef.current.width=t*this.dpr,this.canvasBgRef.current.height=e*this.dpr,this.canvasFloatRef.current&&(this.canvasFloatRef.current.width=t*this.dpr,this.canvasFloatRef.current.height=e*this.dpr),this.canvasServiceFloatRef.current&&(this.canvasServiceFloatRef.current.width=t*this.dpr,this.canvasServiceFloatRef.current.height=e*this.dpr),this.canvasTopRef.current&&(this.canvasTopRef.current.width=t*this.dpr,this.canvasTopRef.current.height=e*this.dpr))}}}createAppViewDisplayer(t,e){const i=document.createElement("div");return i.className="appliance-plugin-app-view-displayer",e.appendChild(i),this.eventTragetElement=e.children[0],this.containerOffset=this.getContainerOffset(this.eventTragetElement,this.containerOffset),this.bindToolsClass(),ko.render(g.createElement(Yo,{viewId:t,mananger:this,refs:{canvasServiceFloatRef:this.canvasServiceFloatRef,canvasFloatRef:this.canvasFloatRef,canvasBgRef:this.canvasBgRef,floatBarRef:this.floatBarRef,canvasTopRef:this.canvasTopRef,canvasContainerRef:this.canvasContainerRef,subLocalCanvasContainerRef:this.subLocalCanvasContainerRef}}),i),this.control.room&&this.bindDisplayerEvent(this.eventTragetElement),this}}class Et extends pe{constructor(t){super(t);M(this,"focuedViewId");M(this,"focuedView");M(this,"control");M(this,"tmpFocusedViewId");M(this,"checkScaleTimer");M(this,"onMainViewRelease",async t=>{this.control.textEditorManager.clear(wt,!0),this.mainViewDestroy(t),await new Promise(i=>{setTimeout(()=>{i(!0)},0)}),this.onMainViewMounted(t);const e=this.control.getSnapshootData("memberState");this.control.room&&this.control.onMemberChange(e),this.control.clearSnapshootData()});M(this,"mainViewDestroy",t=>{var e;if(this.mainView&&this.mainView.displayer){this.mainView.displayer.destroy();const i=t.divElement;if(i){const n=i.getElementsByClassName("appliance-plugin-main-view-displayer");for(const s of n)s.remove()}if(this.mainView.container&&i!==this.mainView.container){const n=this.mainView.container.getElementsByClassName("appliance-plugin-main-view-displayer");for(const s of n)s.remove()}(e=this.control.worker)==null||e.destroyViewWorker(this.mainView.id,!0),this.mainView.displayer.destroy(),this.mainView=void 0}});M(this,"onMainViewMounted",t=>{const e=t.divElement;if(!e||!t.focusScenePath||!(t.focusScenePath||t.scenePath))return;const n=new VM(this.control,mt.InternalMsgEmitter),s=t.size.width||n.width,a=t.size.height||n.height,l={dpr:n.dpr,originalPoint:[s/2,a/2],offscreenCanvasOpt:{...Et.defaultScreenCanvasOpt,width:s,height:a},layerOpt:{...Et.defaultLayerOpt,width:s,height:a},cameraOpt:{...Et.defaultCameraOpt,width:s,height:a}},{scale:h,...u}=t.camera;l.cameraOpt={...l.cameraOpt,...u,scale:h===1/0?1:h},this.focuedViewId=wt,this.createMianView({id:wt,container:e,displayer:n,focusScenePath:t.focusScenePath,cameraOpt:l.cameraOpt,viewData:t}),this.focuedView=this.mainView,n.createMainViewDisplayer(e),t.callbacks.on("onSizeUpdated",this.onMainViewSizeUpdated),t.callbacks.on("onCameraUpdated",this.onMainViewCameraUpdated),t.callbacks.on("onActiveHotkey",this.onActiveHotkeyChange.bind(this))});M(this,"onMainViewSizeUpdated",async()=>{await new Promise(t=>{setTimeout(()=>{t(!0)},0)}),this.mainView&&this.mainView.viewData&&this.updateMainViewCamera()});M(this,"onMainViewCameraUpdated",async()=>{await new Promise(t=>{setTimeout(()=>{t(!0)},0)}),this.updateMainViewCamera()});M(this,"updateMainViewCamera",()=>{if(this.mainView&&this.mainView.viewData){const t=this.mainView.viewData.camera,e=this.mainView.cameraOpt;if(e){const i=e.width,n=e.height,{width:s,height:a}=this.mainView.viewData.size;(s!==i||a!==n)&&this.mainView.displayer.updateSize();const c=t.scale===1/0?1:t.scale,l=t.centerX||0,h=t.centerY||0,u={...e,scale:c,centerX:l,centerY:h,width:s,height:a};E.isEqual(e,u)||(this.mainView.cameraOpt=u),this.checkScaleTimer&&t.scale==1/0&&(clearTimeout(this.checkScaleTimer),this.checkScaleTimer=void 0),!this.checkScaleTimer&&t.scale===1/0&&this.mainView.viewData&&this.mainView.viewData.camera.scale===1/0&&(this.checkScaleTimer=setTimeout(()=>{var d,p;(p=(d=this.mainView)==null?void 0:d.viewData)==null||p.moveCamera({scale:c,centerX:l,centerY:h,animationMode:"immediately"}),this.checkScaleTimer=void 0},500))}}});M(this,"onAppViewMounted",async t=>{var d;const{appId:e,view:i}=t,n=i.divElement;if(!n||!i.focusScenePath)return;const s=this.appViews.get(e);if(s&&s.displayer){let p=n.getElementsByClassName("appliance-plugin-app-view-displayer");for(const f of p)f.remove();if(s.container&&s.container!==n){p=s.container.getElementsByClassName("appliance-plugin-app-view-displayer");for(const f of p)f.remove()}this.destroyAppView(t.appId,!0),(d=this.control.worker)==null||d.destroyViewWorker(e,!0),await new Promise(f=>{setTimeout(()=>{f(!0)},0)})}const a=new ZM(e,this.control,mt.InternalMsgEmitter),c=i.size.width||a.width,l=i.size.height||a.height,u={dpr:a.dpr,originalPoint:[c/2,l/2],offscreenCanvasOpt:{...Et.defaultScreenCanvasOpt,width:c,height:l},layerOpt:{...Et.defaultLayerOpt,width:c,height:l},cameraOpt:{...Et.defaultCameraOpt,...i.camera,width:c,height:l}};if(this.createAppView({id:e,container:n,displayer:a,cameraOpt:u.cameraOpt,focusScenePath:i.focusScenePath,viewData:i}),a.createAppViewDisplayer(e,n),i.callbacks.on("onSizeUpdated",this.onAppViewSizeUpdated.bind(this,e)),i.callbacks.on("onCameraUpdated",this.onAppViewCameraUpdated.bind(this,e)),i.callbacks.on("onActiveHotkey",this.onActiveHotkeyChange.bind(this)),this.tmpFocusedViewId===e){const p=this.control.worker.getLocalWorkViewId();p&&p!==e?this.setFocuedViewId(p):this.setFocuedViewId(e),this.tmpFocusedViewId=void 0}setTimeout(()=>{this.onAppViewCameraUpdated(e)},0)});M(this,"onAppViewSizeUpdated",async t=>{await new Promise(i=>{setTimeout(()=>{i(!0)},0)});const e=this.appViews.get(t);e&&e.viewData&&this.updateAppCamera(t)});M(this,"onAppViewCameraUpdated",async t=>{await new Promise(e=>{setTimeout(()=>{e(!0)},0)}),this.updateAppCamera(t)});M(this,"updateAppCamera",t=>{const e=this.appViews.get(t);if(e&&e.viewData){const i=e.viewData.camera,n=e.cameraOpt;if(n){const{width:s,height:a}=e.viewData.size,c=n.width,l=n.height;(s!==c||a!==l)&&e.displayer.updateSize();const h=i.scale===1/0?1:i.scale,u=i.centerX||0,d=i.centerY||0,p={...n,scale:h,centerX:u,centerY:d,width:s,height:a};E.isEqual(p,n)||(e.cameraOpt=p)}}});this.control=t.control}getViewInitData(t){const e=this.getView(t);if(e){const{width:i,height:n,dpr:s}=e.displayer,a={dpr:s,originalPoint:[i/2,n/2],offscreenCanvasOpt:{...Et.defaultScreenCanvasOpt,width:i,height:n},layerOpt:{...Et.defaultLayerOpt,width:i,height:n},cameraOpt:{...Et.defaultCameraOpt,width:i,height:n}};if(e.viewData){const{scale:c,...l}=e.viewData.camera;a.cameraOpt={...a.cameraOpt,...l,scale:c===1/0?1:c}}return a}}async mountView(t){var i,n;const e=this.getView(t);if(e){t===((i=this.mainView)==null?void 0:i.id)&&(this.control.cursor.activeCollector(),await this.control.activeWorker());const s=this.getViewInitData(t);s&&((n=this.control.worker)==null||n.createViewWorker(t,s)),e.focusScenePath&&this.control.collector&&this.control.worker.pullServiceData(t,e.focusScenePath,{isAsync:!0,useAnimation:!1})}}listenerWindowManager(t){t.emitter.on("focusedChange",e=>{const i=e||wt;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}),t.emitter.on("mainViewScenePathChange",e=>{this.control.onSceneChange(e,wt)}),t.emitter.on("onMainViewMounted",this.onMainViewMounted),t.emitter.on("onAppViewMounted",this.onAppViewMounted),t.emitter.on("onMainViewRebind",this.onMainViewRelease),t.emitter.on("onBoxClose",e=>{this.appViews.get(e.appId)&&(this.destroyAppView(e.appId),this.control.worker.destroyViewWorker(e.appId))}),t.emitter.on("onAppScenePathChange",e=>{const{appId:i,view:n}=e;this.control.onSceneChange(n.focusScenePath,i)}),t.emitter.on("appsChange",e=>{for(const i of this.appViews.keys())e.includes(i)||(this.destroyAppView(i),this.control.worker.destroyViewWorker(i,!0))})}onActiveHotkeyChange(t){this.control.hotkeyManager.onActiveHotkey(t)}}class ce extends mt{constructor(t){super(t);M(this,"windowManager");M(this,"viewContainerManager");const e={control:this,internalMsgEmitter:mt.InternalMsgEmitter};this.viewContainerManager=new Et(e)}init(){}destroy(){var t,e,i,n;this.roomMember.destroy(),(t=this.collector)==null||t.destroy(),(e=this.worker)==null||e.destroy(),(i=this.viewContainerManager)==null||i.destroy(),(n=this.cursor)==null||n.destroy()}activePlugin(){this.collector&&(this.collector.addStorageStateListener(t=>{var a,c;if((a=this.collector)!=null&&a.storage&&Object.keys(this.collector.storage).length===0){(c=this.worker)==null||c.clearViewScenePath(wt,!0);return}const{diffView:e,diffScenePath:i,diffData:n}=t,s=new Map;if(e){let l;Object.keys(e).forEach(h=>{var d;const u=e[h];if(u&&!u.newValue)(d=this.worker)==null||d.clearViewScenePath(h,!0),u.oldValue&&(l=u.oldValue);else if(u&&u.newValue){for(const p of Object.keys(u.newValue))this.worker.pullServiceData(h,p,{isAsync:!1,useAnimation:!0});l=u.newValue}if(l)for(const p of Object.values(l)){const f=new Set;for(const I of Object.keys(p))I&&f.add(I);s.set(h,f)}})}if(i){let l;Object.keys(i).forEach(h=>{var d;const u=i[h];if(u&&u.viewId&&!u.newValue?((d=this.worker)==null||d.clearViewScenePath(u.viewId,!0),u.oldValue&&(l=u.oldValue)):u&&u.viewId&&u.newValue&&(this.worker.pullServiceData(u.viewId,h,{isAsync:!1,useAnimation:!0}),l=u.newValue),u!=null&&u.viewId&&l){const p=new Set;for(const f of Object.keys(l))f&&p.add(f),s.set(u.viewId,p)}})}n&&Object.keys(n).forEach(l=>{var u;const h=n[l];if(h){const{viewId:d}=h,p=s.get(d)||new Set;p.add(l),s.set(d,p),(u=this.worker)==null||u.onServiceDerive(l,h)}});for(const[l,h]of s.entries())mt.InternalMsgEmitter.emit("excludeIds",[...h],l)}),this.room&&this.roomMember.onUidChangeHook(t=>{var e,i;if((e=this.collector)!=null&&e.serviceStorage){const n=[];this.viewContainerManager.getAllViews().forEach(s=>{var a;if(s&&s.focusScenePath&&((a=this.collector)!=null&&a.serviceStorage[s.id])&&this.collector.serviceStorage[s.id][s.focusScenePath]){const c=Object.keys(this.collector.serviceStorage[s.id][s.focusScenePath]).filter(l=>{var h;return(h=this.collector)==null?void 0:h.isSelector(l)}).map(l=>({viewId:s.id,scenePath:s.focusScenePath,key:l}));c.length&&n.push(...c)}}),n.forEach(({key:s,viewId:a,scenePath:c})=>{var h,u;const l=(h=this.collector)==null?void 0:h.getUidFromKey(s);l&&!t.online.includes(l)&&((u=this.collector)==null||u.updateValue(s,void 0,{isAfterUpdate:!0,viewId:a,scenePath:c}))})}(i=this.cursor)==null||i.updateRoomMembers(t)}),this.worker.isActive&&this.viewContainerManager.getAllViews().forEach(t=>{t&&t.focusScenePath&&this.worker.pullServiceData(t.id,t.focusScenePath,{isAsync:!0,useAnimation:!1})}))}async activeWorker(){await this.worker.init()}setWindowManager(t){var e,i,n,s,a;this.windowManager=t,(i=(e=this.windowManager)==null?void 0:e.mainView)!=null&&i.divElement&&this.viewContainerManager.onMainViewMounted(this.windowManager.mainView),(a=(s=(n=this.windowManager.appManager)==null?void 0:n.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 $=class $ extends it.InvisiblePlugin{constructor(){super(...arguments);M(this,"onPhaseChanged",t=>{var e;t===it.RoomPhase.Reconnecting&&((e=$.currentManager)==null||e.setSnapshootData())});M(this,"updateRoomWritable",()=>{var t;(t=$.currentManager)==null||t.onWritableChange(this.displayer.isWritable)});M(this,"roomStateChangeListener",async t=>{var e,i;it.isRoom(this.displayer)&&!this.displayer.isWritable||(t.memberState&&((e=$.currentManager)==null||e.onMemberChange(t.memberState)),t!=null&&t.roomMembers&&((i=$.currentManager)==null||i.onRoomMembersChange(t.roomMembers)))})}static async getInstance(t,e){!e.options.cdn.fullWorkerUrl&&!e.options.cdn.subWorkerUrl&&$.logger.error("[ApplianceMultiPlugin] you must adaptor options cdn fullWorkerUrl and subWorkerUrl");const i=t.displayer,n=i.callbacks.on,s=i.callbacks.off,a=i.callbacks.once,c=t.cleanCurrentScene,l=t.mainView.setMemberState;e!=null&&e.logger&&($.logger=e.logger),e.options&&($.options={...xt,...e.options});let h=i.getInvisiblePlugin($.kind);i&&h&&$.createCurrentManager(t,$.options,h),!h&&it.isRoom(i)&&(h=await $.createApplianceMultiPlugin(i,$.kind)),h&&$.currentManager&&($.currentManager.bindPlugin(h),h.init(i));const u={displayer:i,windowManager:t,currentManager:$.currentManager,maxScreenshotWidth:10*1024,maxScreenshotHeight:10*1024,getBoundingRectAsync:async function(p){var y;$.logger.info("[ApplianceMultiPlugin] getBoundingRectAsync");const f=(t.mainView||i).getBoundingRect(p),I=await((y=$.currentManager)==null?void 0:y.getBoundingRect(p));return!f.width||!f.height?I:ws(f,I)},screenshotToCanvasAsync:async function(p,f,I,y,v,w){var L;$.logger.info("[ApplianceMultiPlugin] screenshotToCanvasAsync");let m=I,T=y,N=v.scale;m>this.maxScreenshotWidth&&(N=this.maxScreenshotWidth/m*N,m=this.maxScreenshotWidth),T>this.maxScreenshotHeight&&(N=Math.min(this.maxScreenshotHeight/T*N,N),T=this.maxScreenshotHeight),v.scale=N;const C=document.createElement("canvas"),z=C.getContext("2d");C.width=m*(w||1),C.height=T*(w||1),z&&((t.mainView||i).screenshotToCanvas(z,f,m,T,v,w),p.drawImage(C,Math.floor((I-m)/2),Math.floor((y-T)/2),m*(w||1),T*(w||1),0,0,m,T),C.remove()),$.currentManager&&await((L=$.currentManager)==null?void 0:L.screenshotToCanvas(p,f,m,T,v,Math.floor((I-m)/2),Math.floor((y-T)/2)))},scenePreviewAsync:async function(p,f,I,y,v){$.logger.info("[ApplianceMultiPlugin] scenePreviewAsync"),(t.mainView||i).scenePreview(p,f,I,y,v);const w=document.createElement("img");w.className="appliance-plugin-fill-scene-snapshot-img",f.append(w),getComputedStyle(f).position||(f.style.position="relative"),$.currentManager&&await $.currentManager.scenePreview(p,w)},fillSceneSnapshotAsync:async function(p,f,I,y,v){$.logger.info("[ApplianceMultiPlugin] fillSceneSnapshotAsync"),f.innerHTML="",(t.mainView||i).fillSceneSnapshot(p,f,I,y,v);const w=I||t.mainView.size.width,m=y||t.mainView.size.height;let T=await this.getBoundingRectAsync(p);T||(T={originX:0,originY:0,width:w,height:m});let N=Math.max(T==null?void 0:T.width,w),C=Math.max(T==null?void 0:T.height,m),z=1;const L=N>w&&Math.min(w/N,z)||z,j=C>m&&Math.min(m/C,z)||z;L<=j?(N=L<1&&w||N,C=Math.floor(C*L)+1,z=L):L>j&&(C=j<1&&m||C,N=Math.floor(N*j)+1,z=j);const A={scale:z,centerX:T.originX+T.width/2,centerY:T.originY+T.height/2},P=document.createElement("canvas"),R=P.getContext("2d");P.width=N,P.height=C,R&&await this.screenshotToCanvasAsync(R,p,N,C,A,devicePixelRatio);const D=document.createElement("img");D.className="appliance-plugin-fill-scene-snapshot-img",D.src=P.toDataURL(),D.onload=()=>{P.remove()},D.onerror=()=>{P.remove(),D.remove()},f.append(D),getComputedStyle(f).position||(f.style.position="relative")},_callbacksOn:function(p,f){$.logger.info(`[ApplianceMultiPlugin] callbacks ${p}`),(p==="onCanUndoStepsUpdate"||p==="onCanRedoStepsUpdate")&&it.isRoom(i)&&i.isWritable?ce.InternalMsgEmitter.on(p,f):n.call(i.callbacks,p,f)},_callbacksOnce:function(p,f){$.logger.info(`[ApplianceMultiPlugin] callbacks ${p}`),(p==="onCanUndoStepsUpdate"||p==="onCanRedoStepsUpdate")&&it.isRoom(i)&&i.isWritable?ce.InternalMsgEmitter.on(p,f):a.call(i.callbacks,p,f)},_callbacksOff:function(p,f){$.logger.info(`[ApplianceMultiPlugin] callbacks ${p}`),(p==="onCanUndoStepsUpdate"||p==="onCanRedoStepsUpdate")&&it.isRoom(i)&&i.isWritable?ce.InternalMsgEmitter.off(p,f):s.call(i.callbacks,p,f)},canRedoSteps(){if($.logger.info("[ApplianceMultiPlugin] canRedoSteps"),$.currentManager&&it.isRoom(i)&&!i.disableSerialization){const p=$.currentManager.viewContainerManager.focuedView,f=p==null?void 0:p.focusScenePath;if(p&&f)return p.displayer.commiter.redoStack.filter(I=>I.scenePath===f).length}return 0},canUndoSteps(){if($.logger.info("[ApplianceMultiPlugin] canUndoSteps"),$.currentManager&&it.isRoom(i)&&!i.disableSerialization){const p=$.currentManager.viewContainerManager.focuedView,f=p==null?void 0:p.focusScenePath;if(p&&f)return p.displayer.commiter.undoStack.filter(I=>I.scenePath===f).length}return 0},undo:function(){return $.logger.info("[ApplianceMultiPlugin] undo"),$.currentManager&&it.isRoom(i)&&!i.disableSerialization?$.currentManager.viewContainerManager.undo():0},redo:function(){return $.logger.info("[ApplianceMultiPlugin] redo"),$.currentManager&&it.isRoom(i)&&!i.disableSerialization?$.currentManager.viewContainerManager.redo():0},cleanCurrentScene:function(){$.logger.info("[ApplianceMultiPlugin] cleanCurrentScene"),$.currentManager&&it.isRoom(i)&&i.isWritable&&($.currentManager.cleanCurrentScene(),c.call(t))},insertImage:function(p){$.logger.info("[ApplianceMultiPlugin] insertImage"),$.currentManager&&it.isRoom(i)&&i.isWritable&&$.currentManager.worker.insertImage(p)},lockImage:function(p,f){$.logger.info("[ApplianceMultiPlugin] lockImage"),$.currentManager&&it.isRoom(i)&&i.isWritable&&$.currentManager.worker.lockImage(p,f)},completeImageUpload:function(p,f){$.logger.info("[ApplianceMultiPlugin] completeImageUpload"),$.currentManager&&it.isRoom(i)&&i.isWritable&&$.currentManager.worker.completeImageUpload(p,f)},getImagesInformation:function(p){return $.logger.info("[ApplianceMultiPlugin] completeImageUpload"),$.currentManager&&it.isRoom(i)&&i.isWritable?$.currentManager.worker.getImagesInformation(p):[]},callbacks:()=>($.logger.info("[ApplianceMultiPlugin] callbacks bind"),{...i.callbacks,on:u._callbacksOn.bind(u),once:u._callbacksOnce.bind(u),off:u._callbacksOff.bind(u)}),destroy(){$.currentManager&&($.logger.info("[ApplianceMultiPlugin] destroy"),$.currentManager.destroy(),$.currentManager=void 0)},setMemberState(p){$.logger.info("[ApplianceMultiPlugin] setMemberState");const f=Object.keys(p);if(it.isRoom(i)&&i.isWritable){f.includes("currentApplianceName")&&(p.currentApplianceName&&p.currentApplianceName===st.laserPen?(p.currentApplianceName=st.pencil,p.useLaserPen=!0):p.currentApplianceName&&p.currentApplianceName===st.pencil&&(p.useLaserPen=!1)),l.call(t.mainView,p);return}throw new Error("setMemberState must be called in writable room")},setPerformancePriority(p){$.logger.info("[ApplianceMultiPlugin] setPriority"),$.currentManager&&$.currentManager.setPriority(p)}},d=(p,f)=>{if($.logger.info(`[ApplianceMultiPlugin] injectMethodToObject ${f}`),typeof p[f]=="function"||typeof p[f]>"u"){p[f]=u[f];return}f==="callbacks"&&(p.callbacks.on=u._callbacksOn.bind(u),p.callbacks.off=u._callbacksOff.bind(u),p.callbacks.once=u._callbacksOnce.bind(u))};return d(t,"undo"),d(t,"redo"),d(t,"cleanCurrentScene"),d(t,"insertImage"),d(t,"completeImageUpload"),d(t,"lockImage"),d(i,"getImagesInformation"),d(i,"callbacks"),d(i,"screenshotToCanvasAsync"),d(i,"getBoundingRectAsync"),d(i,"scenePreviewAsync"),d(i,"fillSceneSnapshotAsync"),d(t.mainView,"setMemberState"),Object.defineProperty(t,"canUndoSteps",{get(){return u.canUndoSteps()}}),Object.defineProperty(t,"canRedoSteps",{get(){return u.canRedoSteps()}}),ce.InternalMsgEmitter.on("onCanUndoStepsUpdate",p=>{t.emitter.emit("canUndoStepsChange",p)}),ce.InternalMsgEmitter.on("onCanRedoStepsUpdate",p=>{t.emitter.emit("canRedoStepsChange",p)}),{...u,callbacks:u.callbacks()}}static onCreate(t){t&&$.currentManager&&($.currentManager.bindPlugin(t),t.init(t.displayer))}static async createApplianceMultiPlugin(t,e){await t.createInvisiblePlugin($,{});let i=t.getInvisiblePlugin(e);return i||(i=await $.createApplianceMultiPlugin(t,e)),i}get isReplay(){return it.isPlayer(this.displayer)}get callbackName(){return this.isReplay?"onPlayerStateChanged":"onRoomStateChanged"}init(t){var e,i;if(it.isRoom(t)){const n=t.state;(e=$.currentManager)==null||e.onMemberChange(n.memberState),(i=$.currentManager)==null||i.onRoomMembersChange(n.roomMembers)}this.displayer.callbacks.on(this.callbackName,this.roomStateChangeListener),this.displayer.callbacks.on("onEnableWriteNowChanged",this.updateRoomWritable),this.displayer.callbacks.on("onPhaseChanged",this.onPhaseChanged)}destroy(){var t;$.logger.info("[ApplianceMultiPlugin] passive destroy"),(t=$.currentManager)==null||t.destroy(),$.currentManager=void 0}};M($,"kind","appliance-multi-plugin"),M($,"currentManager"),M($,"logger",{info:console.log,warn:console.warn,error:console.error}),M($,"options",xt),M($,"createCurrentManager",(t,e,i)=>{if($.currentManager&&$.currentManager.destroy(),e&&t){const n={plugin:i,displayer:t.displayer,options:e},s=new ce(n);$.logger.info("[ApplianceMultiPlugin] refresh ApplianceMultiManager object"),s.setWindowManager(t),$.currentManager=s}});let To=$;class GM extends Ts{constructor(t,e){super(t,e);M(this,"width",1e3);M(this,"height",1e3);M(this,"dpr",1);M(this,"vDom");M(this,"viewId",wt);M(this,"eventTragetElement");M(this,"snapshotContainerRef");M(this,"canvasContainerRef",g.createRef());M(this,"subLocalCanvasContainerRef",g.createRef());M(this,"canvasTopRef",g.createRef());M(this,"canvasServiceFloatRef",g.createRef());M(this,"canvasFloatRef",g.createRef());M(this,"canvasBgRef",g.createRef());M(this,"floatBarRef",g.createRef());M(this,"containerOffset",{x:0,y:0});this.control.hasOffscreenCanvas()||(this.snapshotContainerRef=g.createRef())}setCanvassStyle(){if(this.eventTragetElement){const t=this.eventTragetElement.offsetWidth,e=this.eventTragetElement.offsetHeight;t&&e&&this.canvasContainerRef.current&&(t!==this.width||e!==this.height)&&(this.dpr=Jt()),t&&e&&this.canvasContainerRef.current&&(t!==this.width||e!==this.height)&&(this.dpr=Jt(),this.width=t,this.height=e),t&&e&&this.canvasBgRef.current&&(t!==this.width||e!==this.height)&&(this.dpr=Jt(this.canvasBgRef.current.getContext("2d")),this.width=t,this.height=e,this.canvasBgRef.current.width=t*this.dpr,this.canvasBgRef.current.height=e*this.dpr,this.canvasFloatRef.current&&(this.canvasFloatRef.current.width=t*this.dpr,this.canvasFloatRef.current.height=e*this.dpr),this.canvasServiceFloatRef.current&&(this.canvasServiceFloatRef.current.width=t*this.dpr,this.canvasServiceFloatRef.current.height=e*this.dpr),this.canvasTopRef.current&&(this.canvasTopRef.current.width=t*this.dpr,this.canvasTopRef.current.height=e*this.dpr))}}createMainViewDisplayer(t){return this.vDom||(this.containerOffset=this.getContainerOffset(t,this.containerOffset),this.eventTragetElement=t.parentElement.children[0],t.innerHTML="",ko.render(g.createElement(Yo,{viewId:this.viewId,mananger:this,refs:{canvasServiceFloatRef:this.canvasServiceFloatRef,canvasFloatRef:this.canvasFloatRef,canvasBgRef:this.canvasBgRef,floatBarRef:this.floatBarRef,canvasTopRef:this.canvasTopRef,canvasContainerRef:this.canvasContainerRef,snapshotContainerRef:this.snapshotContainerRef,subLocalCanvasContainerRef:this.subLocalCanvasContainerRef}}),t),this.control.room&&this.bindDisplayerEvent(this.eventTragetElement)),this}}class Vt extends pe{constructor(t){super(t);M(this,"focuedViewId");M(this,"control");M(this,"focuedView");this.control=t.control}bindMainView(){if(!this.control.divMainView)return;const t=new GM(this.control,mt.InternalMsgEmitter);this.focuedViewId=wt;const{width:e,height:i,dpr:n}=t,s={dpr:n,originalPoint:[e/2,i/2],offscreenCanvasOpt:{...Vt.defaultScreenCanvasOpt,width:e,height:i},layerOpt:{...Vt.defaultLayerOpt,width:e,height:i},cameraOpt:{...Vt.defaultCameraOpt,width:e,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:wt,displayer:t,focusScenePath:a.focusScenePath||a.scenePath,cameraOpt:s.cameraOpt,viewData:a}),this.focuedView=this.mainView,t.createMainViewDisplayer(this.control.divMainView)}}getViewInitData(t){const e=this.getView(t);if(e){const{width:i,height:n,dpr:s}=e.displayer,a={dpr:s,originalPoint:[i/2,n/2],offscreenCanvasOpt:{...Vt.defaultScreenCanvasOpt,width:i,height:n},layerOpt:{...Vt.defaultLayerOpt,width:i,height:n},cameraOpt:{...Vt.defaultCameraOpt,width:i,height:n}};if(e.viewData){const{scale:c,...l}=e.viewData.camera;a.cameraOpt={...a.cameraOpt,...l,scale:c===1/0?1:c}}return a}}async mountView(t){var i;const e=this.getView(t);if(e){this.control.worker.isActive||(this.control.cursor.activeCollector(),await this.control.activeWorker());const n=this.getViewInitData(t);n&&((i=this.control.worker)==null||i.createViewWorker(t,n)),e.focusScenePath&&this.control.collector&&this.control.worker.pullServiceData(t,e.focusScenePath,{isAsync:!0,useAnimation:!1})}}}class Ft extends mt{constructor(t){super(t);M(this,"viewContainerManager");M(this,"divMainView");M(this,"onCameraChange",be(t=>{var i;const e=this.viewContainerManager.mainView;e&&e.cameraOpt&&(e.cameraOpt.width!==t.width||e.cameraOpt.height!==t.height)&&((i=this.viewContainerManager.mainView)==null||i.displayer.updateSize()),this.viewContainerManager.setFocuedViewCameraOpt(t)},20,{leading:!1}));const e={control:this,internalMsgEmitter:Ft.InternalMsgEmitter};this.viewContainerManager=new Vt(e)}init(){Ft.InternalMsgEmitter.on(Z.BindMainView,t=>{this.divMainView=t,this.plugin&&!this.viewContainerManager.mainView&&this.viewContainerManager.bindMainView()})}activePlugin(){this.plugin&&this.divMainView&&!this.viewContainerManager.mainView&&this.viewContainerManager.bindMainView(),this.collector&&(this.collector.addStorageStateListener(t=>{var a,c;if((a=this.collector)!=null&&a.storage&&Object.keys(this.collector.storage).length===0){(c=this.worker)==null||c.clearViewScenePath(wt,!0);return}const{diffView:e,diffScenePath:i,diffData:n}=t,s=new Map;if(e){let l;Object.keys(e).forEach(h=>{var d;const u=e[h];if(u&&!u.newValue)(d=this.worker)==null||d.clearViewScenePath(h,!0),u.oldValue&&(l=u.oldValue);else if(u&&u.newValue){for(const p of Object.keys(u.newValue))this.worker.pullServiceData(h,p,{isAsync:!1,useAnimation:!0});l=u.newValue}if(l)for(const p of Object.values(l)){const f=new Set;for(const I of Object.keys(p))I&&f.add(I);s.set(h,f)}})}if(i){let l;Object.keys(i).forEach(h=>{var d;const u=i[h];if(u&&u.viewId&&!u.newValue?((d=this.worker)==null||d.clearViewScenePath(u.viewId,!0),u.oldValue&&(l=u.oldValue)):u&&u.viewId&&u.newValue&&(this.worker.pullServiceData(u.viewId,h,{isAsync:!1,useAnimation:!0}),l=u.newValue),u!=null&&u.viewId&&l){const p=new Set;for(const f of Object.keys(l))f&&p.add(f),s.set(u.viewId,p)}})}n&&Object.keys(n).forEach(l=>{var u;const h=n[l];if(h){const{viewId:d}=h,p=s.get(d)||new Set;p.add(l),s.set(d,p),(u=this.worker)==null||u.onServiceDerive(l,h)}});for(const[l,h]of s.entries())mt.InternalMsgEmitter.emit("excludeIds",[...h],l)}),this.room&&(this.roomMember.onUidChangeHook(t=>{var e,i,n,s;if((e=this.collector)!=null&&e.serviceStorage){const a=[];this.viewContainerManager.getAllViews().forEach(c=>{var l,h,u;if(c&&c.focusScenePath&&((l=this.collector)!=null&&l.serviceStorage[c.id])&&((h=this.collector)!=null&&h.serviceStorage[c.id][c.focusScenePath])){const d=Object.keys((u=this.collector)==null?void 0:u.serviceStorage[c.id][c.focusScenePath]).filter(p=>{var f;return(f=this.collector)==null?void 0:f.isSelector(p)}).map(p=>({viewId:c.id,scenePath:c.focusScenePath,key:p}));d.length&&a.push(...d)}}),a.forEach(({key:c,viewId:l,scenePath:h})=>{var d,p;const u=(d=this.collector)==null?void 0:d.getUidFromKey(c);u&&!t.online.includes(u)&&((p=this.collector)==null||p.updateValue(c,void 0,{isAfterUpdate:!0,viewId:l,scenePath:h}))})}(n=(i=this.cursor)==null?void 0:i.eventCollector)!=null&&n.serviceStorage&&Object.keys((s=this.cursor)==null?void 0:s.eventCollector.serviceStorage).forEach(c=>{var l,h;t.online.includes(c)||(h=(l=this.cursor)==null?void 0:l.eventCollector)==null||h.clearValue(c)})}),this.worker.isActive&&this.viewContainerManager.getAllViews().forEach(t=>{t&&t.focusScenePath&&this.worker.pullServiceData(t.id,t.focusScenePath,{isAsync:!0,useAnimation:!1})})))}async activeWorker(){await this.worker.init()}}const W=class W extends it.InvisiblePlugin{constructor(){super(...arguments);M(this,"onPhaseChanged",t=>{var e;t===it.RoomPhase.Reconnecting&&((e=W.currentManager)==null||e.setSnapshootData())});M(this,"updateRoomWritable",()=>{var t;(t=W.currentManager)==null||t.onWritableChange(this.displayer.isWritable)});M(this,"roomStateChangeListener",async t=>{var e,i;W.currentManager instanceof Ft&&(t.cameraState&&W.currentManager.onCameraChange(t.cameraState),t.sceneState&&W.currentManager.onSceneChange(t.sceneState.scenePath,wt)),!(it.isRoom(this.displayer)&&!this.displayer.isWritable)&&(t.memberState&&((e=W.currentManager)==null||e.onMemberChange(t.memberState)),t!=null&&t.roomMembers&&((i=W.currentManager)==null||i.onRoomMembersChange(t.roomMembers)))})}static async getInstance(t,e){const i=t.callbacks.on,n=t.callbacks.off,s=t.callbacks.once,a=t.cleanCurrentScene.bind(t),c=t.setMemberState.bind(t);e!=null&&e.logger&&(W.logger=e.logger),e.options&&(W.options={...xt,...e.options});let l=t.getInvisiblePlugin(W.kind);t&&l&&W.createCurrentManager(t,W.options,l),!l&&it.isRoom(t)&&(l=await W.createAppliancePlugin(t,W.kind)),l&&W.currentManager&&(W.currentManager.bindPlugin(l),l.init(t)),e!=null&&e.cursorAdapter&&(W.cursorAdapter=e.cursorAdapter),W.effectInstance();const h={displayer:t,currentManager:W.currentManager,maxScreenshotWidth:10*1024,maxScreenshotHeight:10*1024,_injectTargetObject:void 0,getBoundingRectAsync:async function(d){var I;W.logger.info("[ApplianceSinglePlugin] getBoundingRectAsync");const p=t.getBoundingRect(d),f=await((I=W.currentManager)==null?void 0:I.getBoundingRect(d));return!p.width||!p.height?f:ws(p,f)},screenshotToCanvasAsync:async function(d,p,f,I,y,v){var z;W.logger.info("[ApplianceSinglePlugin] screenshotToCanvasAsync");let w=f,m=I,T=y.scale;w>this.maxScreenshotWidth&&(T=this.maxScreenshotWidth/w*T,w=this.maxScreenshotWidth),m>this.maxScreenshotHeight&&(T=Math.min(this.maxScreenshotHeight/m*T,T),m=this.maxScreenshotHeight),y.scale=T;const N=document.createElement("canvas"),C=N.getContext("2d");N.width=w*(v||1),N.height=m*(v||1),C&&(t.screenshotToCanvas(C,p,w,m,y,v),d.drawImage(N,Math.floor((f-w)/2),Math.floor((I-m)/2),w*(v||1),m*(v||1),0,0,w,m),N.remove()),W.currentManager&&await((z=W.currentManager)==null?void 0:z.screenshotToCanvas(d,p,w,m,y,Math.floor((f-w)/2),Math.floor((I-m)/2)))},scenePreviewAsync:async function(d,p,f,I,y){W.logger.info("[ApplianceSinglePlugin] scenePreviewAsync"),t.scenePreview(d,p,f,I,y);const v=document.createElement("img");v.className="appliance-plugin-fill-scene-snapshot-img",p.append(v),getComputedStyle(p).position||(p.style.position="relative"),W.currentManager&&await W.currentManager.scenePreview(d,v)},fillSceneSnapshotAsync:async function(d,p,f,I,y){var D,G;W.logger.info("[ApplianceSinglePlugin] fillSceneSnapshotAsync"),p.innerHTML="",t.fillSceneSnapshot(d,p,f,I,y);const v=f||((D=t.state.cameraState)==null?void 0:D.width)||0,w=I||((G=t.state.cameraState)==null?void 0:G.height)||0;let m=await this.getBoundingRectAsync(d);m||(m={originX:0,originY:0,width:v,height:w});let T=Math.max(m==null?void 0:m.width,v),N=Math.max(m==null?void 0:m.height,w),C=1;const z=T>v&&Math.min(v/T,C)||C,L=N>w&&Math.min(w/N,C)||C;z<=L?(T=z<1&&v||T,N=Math.floor(N*z)+1,C=z):z>L&&(N=L<1&&w||N,T=Math.floor(T*L)+1,C=L);const j={scale:C,centerX:m.originX+m.width/2,centerY:m.originY+m.height/2},A=document.createElement("canvas"),P=A.getContext("2d");A.width=T,A.height=N,P&&await this.screenshotToCanvasAsync(P,d,T,N,j,devicePixelRatio);const R=document.createElement("img");R.className="appliance-plugin-fill-scene-snapshot-img",R.src=A.toDataURL(),R.onload=()=>{A.remove()},R.onerror=()=>{A.remove(),R.remove()},p.append(R),getComputedStyle(p).position||(p.style.position="relative")},_callbacksOn:function(d,p){W.logger.info(`[ApplianceSinglePlugin] callbacks ${d}`),(d==="onCanUndoStepsUpdate"||d==="onCanRedoStepsUpdate")&&it.isRoom(t)&&t.isWritable?Ft.InternalMsgEmitter.on(d,p):i.call(t.callbacks,d,p)},_callbacksOnce:function(d,p){W.logger.info(`[ApplianceSinglePlugin] callbacks ${d}`),(d==="onCanUndoStepsUpdate"||d==="onCanRedoStepsUpdate")&&it.isRoom(t)&&t.isWritable?Ft.InternalMsgEmitter.on(d,p):s.call(t.callbacks,d,p)},_callbacksOff:function(d,p){W.logger.info(`[ApplianceSinglePlugin] callbacks ${d}`),(d==="onCanUndoStepsUpdate"||d==="onCanRedoStepsUpdate")&&it.isRoom(t)&&t.isWritable?Ft.InternalMsgEmitter.off(d,p):n.call(t.callbacks,d,p)},canRedoSteps(){if(W.logger.info("[ApplianceSinglePlugin] canRedoSteps"),W.currentManager&&it.isRoom(t)&&!t.disableSerialization){const d=W.currentManager.viewContainerManager.focuedView,p=d==null?void 0:d.focusScenePath;if(d&&p)return d.displayer.commiter.redoStack.filter(f=>f.scenePath===p).length}return 0},canUndoSteps(){if(W.logger.info("[ApplianceSinglePlugin] canUndoSteps"),W.currentManager&&it.isRoom(t)&&!t.disableSerialization){const d=W.currentManager.viewContainerManager.focuedView,p=d==null?void 0:d.focusScenePath;if(d&&p)return d.displayer.commiter.undoStack.filter(f=>f.scenePath===p).length}return 0},undo:function(){return W.logger.info("[ApplianceSinglePlugin] undo"),W.currentManager&&it.isRoom(t)&&!t.disableSerialization?W.currentManager.viewContainerManager.undo():0},redo:function(){return W.logger.info("[ApplianceSinglePlugin] redo"),W.currentManager&&it.isRoom(t)&&!t.disableSerialization?W.currentManager.viewContainerManager.redo():0},cleanCurrentScene:function(d){W.logger.info("[ApplianceSinglePlugin] cleanCurrentScene"),W.currentManager&&it.isRoom(t)&&t.isWritable&&(W.currentManager.cleanCurrentScene(),a.call(t,d))},insertImage:function(d){W.logger.info("[ApplianceSinglePlugin] insertImage"),W.currentManager&&it.isRoom(t)&&t.isWritable&&W.currentManager.worker.insertImage(d)},lockImage:function(d,p){W.logger.info("[ApplianceSinglePlugin] lockImage"),W.currentManager&&it.isRoom(t)&&t.isWritable&&W.currentManager.worker.lockImage(d,p)},completeImageUpload:function(d,p){W.logger.info("[ApplianceSinglePlugin] completeImageUpload"),W.currentManager&&it.isRoom(t)&&t.isWritable&&W.currentManager.worker.completeImageUpload(d,p)},getImagesInformation:function(d){return W.logger.info("[ApplianceSinglePlugin] completeImageUpload"),W.currentManager&&it.isRoom(t)&&t.isWritable?W.currentManager.worker.getImagesInformation(d):[]},callbacks:()=>({...t.callbacks,on:h._callbacksOn.bind(h),once:h._callbacksOnce.bind(h),off:h._callbacksOff.bind(h)}),destroy(){W.currentManager&&(W.logger.info("[ApplianceSinglePlugin] destroy"),W.currentManager.destroy(),W.currentManager=void 0,W.cursorAdapter=void 0)},setMemberState(d){W.logger.info("[ApplianceSinglePlugin] setMemberState");const p=Object.keys(d);if(it.isRoom(t)&&t.isWritable){p.includes("currentApplianceName")&&(d.currentApplianceName&&d.currentApplianceName===st.laserPen?(d.currentApplianceName=st.pencil,d.useLaserPen=!0):d.currentApplianceName&&d.currentApplianceName===st.pencil&&(d.useLaserPen=!1)),c(d);return}throw new Error("setMemberState must be called in writable room")},setPerformancePriority(d){W.logger.info("[ApplianceSinglePlugin] setPriority"),W.currentManager&&W.currentManager.setPriority(d)}},u=(d,p)=>{if(W.logger.info(`[ApplianceSinglePlugin] injectMethodToObject ${p}`),typeof d[p]=="function"||typeof d[p]>"u"){d[p]=h[p];return}p==="callbacks"&&(d.callbacks.on=h._callbacksOn.bind(h),d.callbacks.off=h._callbacksOff.bind(h),d.callbacks.once=h._callbacksOnce.bind(h))};return u(t,"undo"),u(t,"redo"),u(t,"cleanCurrentScene"),u(t,"insertImage"),u(t,"completeImageUpload"),u(t,"lockImage"),u(t,"getImagesInformation"),u(t,"callbacks"),u(t,"screenshotToCanvasAsync"),u(t,"getBoundingRectAsync"),u(t,"scenePreviewAsync"),u(t,"fillSceneSnapshotAsync"),u(t,"setMemberState"),Object.defineProperty(t,"canUndoSteps",{get(){return h.canUndoSteps()}}),Object.defineProperty(t,"canRedoSteps",{get(){return h.canRedoSteps()}}),{...h,callbacks:h.callbacks()}}static onCreate(t){t&&W.currentManager&&(W.currentManager.bindPlugin(t),t.init(t.displayer))}static async createAppliancePlugin(t,e){await t.createInvisiblePlugin(W,{});let i=t.getInvisiblePlugin(e);return i||(i=await W.createAppliancePlugin(t,e)),i}static effectInstance(){if(W.cursorAdapter){const t=W.cursorAdapter.onAddedCursor;W.cursorAdapter.onAddedCursor=function(e){e.onCursorMemberChanged=i=>{try{i.appliance===st.pencil||i.appliance===st.shape||i.appliance===st.text||i.appliance===st.arrow||i.appliance===st.straight||i.appliance===st.rectangle||i.appliance===st.ellipse?e!=null&&e.divElement&&(e.divElement.style.display="none"):e!=null&&e.divElement&&(e.divElement.style.display="block")}catch{}},t.call(W.cursorAdapter,e)}}}get isReplay(){return it.isPlayer(this.displayer)}get callbackName(){return this.isReplay?"onPlayerStateChanged":"onRoomStateChanged"}init(t){var e,i;if(it.isRoom(t)){const n=t.state;n!=null&&n.memberState&&((e=W.currentManager)==null||e.onMemberChange(n.memberState),(i=W.currentManager)==null||i.onRoomMembersChange(n.roomMembers))}this.displayer.callbacks.on(this.callbackName,this.roomStateChangeListener),this.displayer.callbacks.on("onEnableWriteNowChanged",this.updateRoomWritable),this.displayer.callbacks.on("onPhaseChanged",this.onPhaseChanged)}destroy(){var t;W.logger.info("[ApplianceSinglePlugin] passive destroy"),(t=W.currentManager)==null||t.destroy(),W.currentManager=void 0,W.cursorAdapter=void 0}};M(W,"kind","appliance-aids-single-plugin"),M(W,"cursorAdapter"),M(W,"currentManager"),M(W,"logger",{info:console.log,warn:console.warn,error:console.error}),M(W,"options",xt),M(W,"createCurrentManager",(t,e,i)=>{W.currentManager&&W.currentManager.destroy();const n={plugin:i,displayer:t,options:e},s=new Ft(n);s.init(),W.logger.info("[ApplianceSinglePlugin] refresh ApplianceSingleManager object"),W.currentManager=s});let So=W;const ue=class ue extends g.Component{constructor(){super(...arguments);M(this,"mainViewRef",null)}componentDidMount(){ue.emiter||(ue.emiter=Ft.InternalMsgEmitter),ue.emiter.emit(Z.BindMainView,this.mainViewRef)}render(){return g.createElement(g.Fragment,null,this.props.children,g.createElement("div",{className:"appliance-plugin-main-view-displayer",ref:t=>this.mainViewRef=t}))}};M(ue,"emiter");let Co=ue;exports.ActiveContainerType=Li;exports.ApplianceMultiPlugin=To;exports.ApplianceNames=st;exports.ApplianceSigleWrapper=Co;exports.ApplianceSinglePlugin=So;exports.Cursor_Hover_Id=Ef;exports.DefaultAppliancePluginOptions=xt;exports.ECanvasContextType=Xe;exports.ECanvasShowType=Yt;exports.EDataType=U;exports.EMatrixrRelationType=ke;exports.EPostMessageType=x;exports.EScaleType=at;exports.EStrokeType=_;exports.EToolsKey=S;exports.ElayerType=ee;exports.EmitEventType=O;exports.EventMessageType=Ce;exports.EvevtWorkState=b;exports.EvevtWorkType=bi;exports.InternalMsgEmitterType=Z;exports.Main_View_Id=wt;exports.ShapeType=Pt;exports.Storage_Selector_key=B;exports.Storage_Splitter=Ot;exports.Storage_ViewId_ALL=We;exports.Task_Time_Interval=Af;exports.ViewContainerManager=pe;exports.checkOp=zf;exports.cloneDeep=Qt;exports.computRect=ut;exports.fullWorker=bs;exports.getRectMatrixrRelation=bf;exports.getShapeInstance=Ms;exports.getShapeTools=gs;exports.isBoolean=Gt;exports.isEqual=Se;exports.isIntersect=Le;exports.isIntersectForPoint=Is;exports.isNumber=Wt;exports.isRenderNode=Lf;exports.subWorker=js;exports.throttle=be;exports.transformToNormalData=ve;exports.transformToSerializableData=Lt;