oolong-engine 0.0.2-t.3 → 0.0.2-t.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/action/render/RenderManager.d.ts +2 -0
- package/dist/app/OolongApp.d.ts +5 -0
- package/dist/app/docState/DocState.d.ts +1 -0
- package/dist/application/nodeManager/NodeManager.d.ts +1 -0
- package/dist/asyncRender/AsyncRenderNodeManager.d.ts +3 -0
- package/dist/auxiliary/AuxiliaryManager.d.ts +1 -0
- package/dist/engine.js +1244 -1189
- package/dist/engine.umd.cjs +14 -14
- package/dist/resource-manager/ResourceManager.d.ts +1 -0
- package/dist/select/SelectManager.d.ts +1 -0
- package/dist/slide/SlideCoverManager.d.ts +2 -0
- package/dist/slide/SlideManager.d.ts +1 -0
- package/dist/slot/SlotManager.d.ts +3 -0
- package/dist/utils/IdGenerator.d.ts +1 -0
- package/package.json +1 -1
package/dist/engine.umd.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function(T,st){typeof exports=="object"&&typeof module<"u"?st(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],st):(T=typeof globalThis<"u"?globalThis:T||self,st(T.engine={},T.React))})(this,function(T,st){"use strict";var Ux=Object.defineProperty;var _x=(T,st,bn)=>st in T?Ux(T,st,{enumerable:!0,configurable:!0,writable:!0,value:bn}):T[st]=bn;var p=(T,st,bn)=>_x(T,typeof st!="symbol"?st+"":st,bn);var bn=document.createElement("style");bn.textContent=`.canvas-container .auxiliary-canvas{position:absolute;left:0;top:0;width:100%;height:100%;z-index:2;pointer-events:none}.canvas-container .content-canvas{position:absolute;left:0;top:0;width:100%;height:100%;z-index:1}.canvas-container .page-canvas{position:absolute;left:0;top:0;width:100%;height:100%;z-index:0}.normal-container,.normal-container .normal-canvas{width:100%;height:100%}.canvas-input{position:absolute;border:none;outline:none;-webkit-user-select:none;user-select:none;width:1px;z-index:3;opacity:0;pointer-events:none}@keyframes van-cursor-flicker{0%{opacity:1}50%{opacity:0}to{opacity:1}}.render-input{position:absolute;background-color:#000;width:1px;height:12px;z-index:4;pointer-events:none;animation:.6s van-cursor-flicker infinite}
|
|
2
|
-
/*$vite$:1*/`,document.head.appendChild(bn);class zl{constructor(t){p(this,"ctx");this.ctx=t,t.actionManager.addNetworkPlugin(this)}onEnable(t){return!0}}class hn{exec(t,e){const n=t.data;t.reverseLog=this.reverseLog(n,e),this.execData(n,e)}}var Xe=(l=>(l[l.Start=0]="Start",l[l.End=1]="End",l[l.AddNode=2]="AddNode",l[l.RemoveNode=3]="RemoveNode",l[l.UpdateNode=4]="UpdateNode",l[l.SelectNode=5]="SelectNode",l[l.TextFocus=6]="TextFocus",l))(Xe||{});class m{constructor(t=0,e=0){p(this,"x");p(this,"y");this.x=t,this.y=e}clone(){return new m(this.x,this.y)}}var Or=(l=>(l.LEFT="LEFT",l.TOP="TOP",l.RIGHT="RIGHT",l.BOTTOM="BOTTOM",l))(Or||{});class Wl extends m{constructor(e,n,o,s){super(e.x,e.y);p(this,"xPos");p(this,"yPos");p(this,"nodeSide");this.xPos=n,this.yPos=o,this.nodeSide=s}}class Fl extends m{constructor(){super(...arguments);p(this,"isHorizon",!0)}}const Sn="ROOT",Xr="ROOT";var v=(l=>(l[l.Shape=0]="Shape",l[l.Line=1]="Line",l[l.SVG=2]="SVG",l[l.IMG=3]="IMG",l[l.Section=4]="Section",l[l.Group=5]="Group",l[l.Checkbox=6]="Checkbox",l[l.CheckboxText=7]="CheckboxText",l[l.SlideContainer=8]="SlideContainer",l[l.ROOT=99]="ROOT",l))(v||{}),et=(l=>(l[l.None=0]="None",l[l.Solid=1]="Solid",l[l.Dash1=2]="Dash1",l[l.Dash2=3]="Dash2",l))(et||{}),it=(l=>(l[l.None=0]="None",l[l.Arrow=1]="Arrow",l[l.Triangle=2]="Triangle",l[l.EmptyTriangle=3]="EmptyTriangle",l[l.Diamond=4]="Diamond",l[l.EmptyDiamond=5]="EmptyDiamond",l[l.Circle=6]="Circle",l[l.EmptyCircle=7]="EmptyCircle",l))(it||{}),at=(l=>(l[l.Top=0]="Top",l[l.Middle=1]="Middle",l[l.Bottom=2]="Bottom",l))(at||{}),We=(l=>(l[l.fix=0]="fix",l[l.autoHeight=1]="autoHeight",l[l.autoWidth=2]="autoWidth",l))(We||{}),I=(l=>(l[l.Base=0]="Base",l[l.Color=1]="Color",l[l.Border=2]="Border",l[l.Text=3]="Text",l[l.Shape=4]="Shape",l[l.Line=5]="Line",l[l.Arrow=6]="Arrow",l[l.Connect=7]="Connect",l[l.LineTextRect=8]="LineTextRect",l[l.Svg=9]="Svg",l[l.Image=10]="Image",l[l.Crop=11]="Crop",l[l.CheckStatus=12]="CheckStatus",l[l.CheckSize=13]="CheckSize",l[l.TextParagraph=14]="TextParagraph",l[l.TextParagraphQuote=15]="TextParagraphQuote",l[l.Slide=16]="Slide",l))(I||{});class ct{}class ro extends ct{constructor(){super(...arguments);p(this,"type",I.Image);p(this,"url","")}static from(e){const n=new ro;return n.url=e.url,n}clone(){const e=new ro;return e.url=this.url,e}update(e){const{url:n}=e;n!==void 0&&(this.url=n)}}class ie extends ct{constructor(){super(...arguments);p(this,"type",I.Base);p(this,"x",0);p(this,"y",0);p(this,"width",100);p(this,"height",100);p(this,"angle",0)}static create(e){const n=new ie;return n.update(e),n}static from(e){const n=new ie;return n.x=e.x,n.y=e.y,n.width=e.width,n.height=e.height,n.angle=e.angle,n}update(e){const{x:n,y:o,height:s,width:r,angle:i}=e;n!==void 0&&(this.x=n),o!==void 0&&(this.y=o),s!==void 0&&(this.height=s),r!==void 0&&(this.width=r),i!==void 0&&(this.angle=i)}clone(){const e=new ie;return e.x=this.x,e.y=this.y,e.width=this.width,e.height=this.height,e.angle=this.angle,e}}class Ae extends ct{constructor(){super(...arguments);p(this,"type",I.Border);p(this,"color","#000000");p(this,"alpha",1);p(this,"width",2);p(this,"dashType",et.Solid)}static create(e){const n=new Ae;return n.update(e),n}static from(e){const n=new Ae;return n.color=e.color,n.alpha=e.alpha,n.width=e.width,n.dashType=e.dashType,n}update(e){const{color:n,alpha:o,width:s,dashType:r}=e;n!==void 0&&(this.color=n),o!==void 0&&(this.alpha=o),s!==void 0&&(this.width=s),r!==void 0&&(this.dashType=r)}clone(){const e=new Ae;return e.color=this.color,e.alpha=this.alpha,e.width=this.width,e.dashType=this.dashType,e}}class re{constructor(){p(this,"a",1);p(this,"b",0);p(this,"c",0);p(this,"d",1);p(this,"e",0);p(this,"f",0)}static generateMatrix(){return new re}setTransform(t,e,n,o,s,r){this.a=t,this.b=e,this.c=n,this.d=o,this.e=s,this.f=r}rotate(t){const e=t/180*Math.PI;return this.rotate2(e),this}rotate2(t){return this.a=Math.cos(t),this.c=-Math.sin(t),this.b=Math.sin(t),this.d=Math.cos(t),this}scale(t,e){return this.a=t,this.d=e,this}translate(t,e){return this.e=t,this.f=e,this}crossProduct(t){const e=new re;return e.a=this.a*t.a+this.c*t.b,e.b=this.b*t.a+this.d*t.b,e.c=this.a*t.c+this.c*t.d,e.d=this.b*t.c+this.d*t.d,e.e=this.a*t.e+this.c*t.f+this.e,e.f=this.b*t.e+this.d*t.f+this.f,e}crossPoint(t){return new m(this.a*t.x+this.c*t.y+this.e,this.b*t.x+this.d*t.y+this.f)}inverseMatrix(){const{a:t,b:e,c:n,d:o,e:s,f:r}=this,i=t*o-e*n;if(Math.abs(i)<1e-4)throw new Error("该仿射变换不可逆");const a=o/i,c=-e/i,h=-n/i,d=t/i,u=(n*r-o*s)/i,f=(e*s-t*r)/i,g=re.generateMatrix();return g.a=a,g.b=c,g.c=h,g.d=d,g.e=u,g.f=f,g}clone(){const t=new re;return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.e=this.e,t.f=this.f,t}}class Yl{constructor(t,e,n){p(this,"p0");p(this,"p1");p(this,"p2");this.p0=t,this.p1=e,this.p2=n}xStationaryPoint(){return(this.p0.x-this.p1.x)/(this.p0.x-2*this.p1.x+this.p2.x)}dxdt(t){return 2*t*(this.p0.x-2*this.p1.x+this.p2.x)-2*(this.p0.x-this.p1.x)}xValue(t){const e=1-t;return e*e*this.p0.x+2*t*e*this.p1.x+t*t*this.p2.x}yValue(t){const e=1-t;return e*e*this.p0.y+2*t*e*this.p1.y+t*t*this.p2.y}newtonSolveX(t,e,n){let s=.5*(e+n),r=0;for(;;){r++;const i=this.xValue(s)-t,a=this.dxdt(s),c=s-i/a;if(Math.abs(c-s)<.01)return c;if(r>20)return null;s=c}return null}solve(t,e=6){const n=this.xStationaryPoint();if(n<0||n>1)return this.monotonicSolve(t,0,1,e);let o=this.monotonicSolve(t,0,n,e);return o?!0:(o=this.monotonicSolve(t,n,1,e),o)}monotonicSolve(t,e,n,o){const s=this.xValue(e),r=this.xValue(n),i=t.x,a=t.y;if((i-s)*(i-r)>0)return!1;const c=this.newtonSolveX(i,e,n);return c===null?(console.warn("newton 迭代求解贝塞尔曲线出错."),!1):Math.abs(a-this.yValue(c))<o}}class Bo{constructor(t){p(this,"prev",null);p(this,"next",null);p(this,"data",null);this.data=t}breakOff(){this.prev=null,this.next=null}toString(){return this.data?this.data.toString():""}add(t){const e=this.next;this.next=t,t.prev=this,t.next=e,e&&(e.prev=t)}pushAdd(t){this.next=t,t.prev=this}removeSelf(){const t=this.next,e=this.prev;this.next=null,this.prev=null,t.prev=e,e.next=t}getIndex(){let t=this.prev,e=0;for(;t&&t.data;)e++,t=t.prev;return e}static generateLink(){const t=new Bo(null),e=new Bo(null);return t.add(e),t}}class D{constructor(t=0,e=0,n=100,o=100){p(this,"x");p(this,"y");p(this,"width");p(this,"height");this.x=t,this.y=e,this.width=n,this.height=o}clone(){return new D(this.x,this.y,this.width,this.height)}static baseProps2Rect(t){const{x:e,y:n,width:o,height:s}=t;return new D(e,n,o,s)}static rectNode2Rect(t){const{minY:e,minX:n,maxY:o,maxX:s}=t;return new D(n,e,s-n,o-e)}static toRectNode(t){const{x:e,y:n,width:o,height:s}=t;return{minX:e,minY:n,maxX:e+o,maxY:n+s}}}var zn=(l=>(l[l.Image=0]="Image",l[l.SVG=1]="SVG",l))(zn||{});class Ke{constructor(){p(this,"result",null)}detect(t,e){return this.result?!0:this.onDetect(t,e)}reset(){this.result=null}}var F=(l=>(l[l.Node=0]="Node",l[l.Stretch=1]="Stretch",l[l.HoverNode=2]="HoverNode",l[l.ParagraphHead=3]="ParagraphHead",l[l.PolyControlPoint=4]="PolyControlPoint",l[l.CurveControlPoint=5]="CurveControlPoint",l[l.LineEndPoint=6]="LineEndPoint",l[l.ConnectorPoint=7]="ConnectorPoint",l[l.Rotate=8]="Rotate",l[l.SingleStretch=9]="SingleStretch",l[l.ExpandShape=10]="ExpandShape",l[l.NodeEdge=11]="NodeEdge",l[l.BufferNode=12]="BufferNode",l[l.BufferHoverNode=13]="BufferHoverNode",l[l.HoverNodeAnchor=14]="HoverNodeAnchor",l[l.HoverConnectAnchor=15]="HoverConnectAnchor",l[l.HoverOnContainer=16]="HoverOnContainer",l[l.Image=17]="Image",l[l.ImageOriginBounds=18]="ImageOriginBounds",l[l.CurveEndPoint=19]="CurveEndPoint",l[l.DragLineText=20]="DragLineText",l[l.SlideGap=21]="SlideGap",l[l.EmptySlideContainer=22]="EmptySlideContainer",l))(F||{}),be=(l=>(l.pointerDown="pointerdown",l.pointermove="pointermove",l.pointermoveOutside="pointermoveOutside",l.pointerup="pointerup",l.unknown="unknown",l))(be||{}),V=(l=>(l[l.TOP=0]="TOP",l[l.LEFT=1]="LEFT",l[l.BOTTOM=2]="BOTTOM",l[l.RIGHT=3]="RIGHT",l[l.TOP_LEFT=4]="TOP_LEFT",l[l.TOP_RIGHT=5]="TOP_RIGHT",l[l.BOTTOM_LEFT=6]="BOTTOM_LEFT",l[l.BOTTOM_RIGHT=7]="BOTTOM_RIGHT",l))(V||{});class tt extends ct{constructor(){super(...arguments);p(this,"type",I.Color);p(this,"color","#ffccff");p(this,"alpha",1)}static create(e){const n=new tt;return n.update(e),n}static from(e){const n=new tt;return n.color=e.color,n.alpha=e.alpha,n}update(e){const{color:n,alpha:o}=e;n!==void 0&&(this.color=n),o!==void 0&&(this.alpha=o)}clone(){const e=new tt;return e.color=this.color,e.alpha=this.alpha,e}}class Ge extends ct{constructor(){super(...arguments);p(this,"type",I.Text);p(this,"text","");p(this,"richText","");p(this,"fontSize",14);p(this,"fontFamily","Noto Sans");p(this,"fontColor","#000000");p(this,"fontBgColor","");p(this,"bold",!1);p(this,"italic",!1);p(this,"underline",!1);p(this,"strikethrough",!1);p(this,"verticalAlign",at.Middle);p(this,"horizonAlign",at.Middle);p(this,"sizeMode",We.fix)}static create(e){const n=new Ge;return n.update(e),n}static from(e){const n=new Ge;return n.text=e.text,n.fontSize=e.fontSize,n.fontFamily=e.fontFamily,n.fontColor=e.fontColor,n.fontBgColor=e.fontBgColor,n.bold=e.bold,n.italic=e.italic,n.underline=e.underline,n.strikethrough=e.strikethrough,n.verticalAlign=e.verticalAlign,n.horizonAlign=e.horizonAlign,n.sizeMode=e.sizeMode,n.richText=e.richText,!e.richText&&e.text&&(n.richText=this.dealTextToRichText(e.text)),n}update(e){const{sizeMode:n,verticalAlign:o,horizonAlign:s,fontFamily:r,fontSize:i,text:a,bold:c,italic:h,fontColor:d,fontBgColor:u,underline:f,strikethrough:g,richText:y}=e;a!==void 0&&(this.text=a),r!==void 0&&(this.fontFamily=r),i!==void 0&&(this.fontSize=i),d!==void 0&&(this.fontColor=d),u!==void 0&&(this.fontBgColor=u.trim()),c!==void 0&&(this.bold=c),h!==void 0&&(this.italic=h),f!==void 0&&(this.underline=f),g!==void 0&&(this.strikethrough=g),o!==void 0&&(this.verticalAlign=o),s!==void 0&&(this.horizonAlign=s),n!==void 0&&(this.sizeMode=n),y!==void 0&&(this.richText=y)}clone(){const e=new Ge;return e.text=this.text,e.fontFamily=this.fontFamily,e.fontSize=this.fontSize,e.fontColor=this.fontColor,e.fontBgColor=this.fontBgColor,e.bold=this.bold,e.italic=this.italic,e.underline=this.underline,e.strikethrough=this.strikethrough,e.horizonAlign=this.horizonAlign,e.verticalAlign=this.verticalAlign,e.sizeMode=this.sizeMode,e.richText=this.richText,e}static dealTextToRichText(e){const n=e.split(`
|
|
3
|
-
`);let o="<root>";for(const s of n)o=o+"<p>"+s+"</p>";return o+="</root>",o}}class Oe extends ct{constructor(e=1){super();p(this,"type",I.Shape);p(this,"shapeCode",1);this.shapeCode=e}static from(e){const n=new Oe;return n.shapeCode=e.shapeCode,n}update(e){const{shapeCode:n}=e;n!==void 0&&(this.shapeCode=n)}clone(){const e=new Oe;return e.shapeCode=this.shapeCode,e}}class je extends ct{constructor(){super(...arguments);p(this,"type",I.Line);p(this,"points",[]);p(this,"auto",!0)}static create(e,n=!0){const o=new je;return o.auto=n,o.points=e,o}static from(e){const n=new je;return n.points=e.points,n.auto=e.auto,n}clone(){const e=new je,n=[];for(const o of this.points)n.push(S.cloneIPoint(o));return e.points=n,e.auto=this.auto,e}update(e){const{points:n,auto:o}=e;n!==void 0&&(this.points=n),o!==void 0&&(this.auto=o)}}class Rt extends ct{constructor(){super(...arguments);p(this,"type",I.Connect);p(this,"start",null);p(this,"end",null)}static from(e){const n=new Rt;return n.start=e.start,n.end=e.end,n}clone(){const e=new Rt;return e.start=this.start,e.end=this.end,e}update(e){const{start:n,end:o}=e;n!==void 0&&(this.start=n),o!==void 0&&(this.end=o)}}class lt extends ct{constructor(){super(...arguments);p(this,"type",I.Arrow);p(this,"lArrow",it.None);p(this,"rArrow",it.None)}static create(e){const n=new lt;return n.update(e),n}static from(e){const n=new lt;return n.lArrow=e.lArrow,n.rArrow=e.rArrow,n}clone(){const e=new lt;return e.rArrow=this.rArrow,e.lArrow=this.lArrow,e}update(e){const{lArrow:n,rArrow:o}=e;n!==void 0&&(this.lArrow=n),o!==void 0&&(this.rArrow=o)}}var de=(l=>(l[l.Top=0]="Top",l[l.Right=1]="Right",l[l.Bottom=2]="Bottom",l[l.Left=3]="Left",l))(de||{});class Et extends ct{constructor(){super(...arguments);p(this,"type",I.LineTextRect);p(this,"width",20);p(this,"height",20);p(this,"x",0);p(this,"y",0);p(this,"point",{x:0,y:0})}static from(e){const n=new Et;return n.width=e.width,n.height=e.height,n.x=e.x,n.y=e.y,n.point=e.point,n}update(e){const{x:n,y:o,point:s,height:r,width:i}=e;n!==void 0&&(this.x=n),o!==void 0&&(this.y=o),r!==void 0&&(this.height=r),i!==void 0&&(this.width=i),s!==void 0&&(this.point=s)}clone(){const e=new Et;return e.width=this.width,e.height=this.height,e.x=this.x,e.y=this.y,e.point=this.point,e}}var k=(l=>(l[l.HoverBounds=0]="HoverBounds",l[l.HoverLine=1]="HoverLine",l[l.SelectLine=2]="SelectLine",l[l.MultiSelectBound=3]="MultiSelectBound",l[l.TextSelection=4]="TextSelection",l[l.SelectGroup=5]="SelectGroup",l[l.SelectRect=6]="SelectRect",l[l.HighLightLine=7]="HighLightLine",l[l.AlignLine=8]="AlignLine",l[l.AlignStretchLine=9]="AlignStretchLine",l[l.SingleSelectBound=10]="SingleSelectBound",l[l.RotateLine=11]="RotateLine",l[l.HighlightRects=12]="HighlightRects",l[l.CreateRectBound=13]="CreateRectBound",l[l.ExpandShape=14]="ExpandShape",l[l.SelectLineEnd=15]="SelectLineEnd",l[l.HoverConnectPoint=16]="HoverConnectPoint",l[l.HoverConnectAnchorPoint=17]="HoverConnectAnchorPoint",l[l.HoverAnchorPoint=18]="HoverAnchorPoint",l[l.SelectPolyLineControlPoint=19]="SelectPolyLineControlPoint",l[l.SelectLineTextRect=20]="SelectLineTextRect",l[l.PlaceHolder=21]="PlaceHolder",l[l.SelectConnectAnchor=22]="SelectConnectAnchor",l[l.HoverConnectAnchor=23]="HoverConnectAnchor",l[l.PreviewGraphics=24]="PreviewGraphics",l[l.HoverContainer=25]="HoverContainer",l[l.CropBounds=26]="CropBounds",l[l.CropOriginImg=27]="CropOriginImg",l[l.StretchRect=28]="StretchRect",l[l.HoverSize=29]="HoverSize",l[l.SelectCurveControlPoint=30]="SelectCurveControlPoint",l[l.SelectCurveEnd=31]="SelectCurveEnd",l[l.SelectParentGroupBound=32]="SelectParentGroupBound",l[l.SelectSlideGapInsertPoint=33]="SelectSlideGapInsertPoint",l[l.HoverSlidePlaceHolder=34]="HoverSlidePlaceHolder",l[l.HoverInsertSlide=35]="HoverInsertSlide",l[l.HoverInsertHorizonSlide=36]="HoverInsertHorizonSlide",l[l.HoverSlideGapInsertPoint=37]="HoverSlideGapInsertPoint",l[l.HoverFocusCopy=38]="HoverFocusCopy",l))(k||{});class Me{constructor(){p(this,"prop")}update(t){this.prop=t}}const Ht="#FFFFFF",bs="#000000",Gt="#647ee5",Qe="#545DE7",Ss="#32a8f2",zr="#3370FF",Wr=8,Fr=18,Yr=5,Ms=11,Gr="#CCCCCC",Ur="#B7BEF5",_r="#DADEFA";class $r extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.HoverBounds)}draw(e,n){const{node:o,transform:s}=this.prop;e.save(),e.strokeStyle=Gt,e.lineWidth=2/n,e.globalAlpha=1;const{x:r,y:i,width:a,height:c}=o.baseProps,{a:h,b:d,c:u,d:f,e:g,f:y}=s;e.transform(h,d,u,f,g,y),e.beginPath(),e.strokeRect(0,0,a,c),e.restore()}}class jr extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.SingleSelectBound)}draw(e,n){const{x:o,y:s,width:r,height:i,transform:a}=this.prop;e.save(),e.strokeStyle=Qe,e.lineWidth=1/n,e.globalAlpha=1;const{a:c,b:h,c:d,d:u,e:f,f:g}=a;e.transform(c,h,d,u,f,g),e.beginPath(),e.strokeRect(o,s,r,i),e.restore()}}class Vr extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.MultiSelectBound)}draw(e,n){const{rect:o}=this.prop;e.save(),e.strokeStyle=Qe,e.lineWidth=1/n,e.globalAlpha=1;const{x:s,y:r,width:i,height:a}=o;e.beginPath(),e.strokeRect(s,r,i,a),e.restore()}}class Kr extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.HighlightRects)}draw(e,n){const{rects:o}=this.prop;for(const s of o){e.save(),e.strokeStyle=Qe,e.lineWidth=1/n,e.globalAlpha=1;const{x:r,y:i,width:a,height:c}=s;e.beginPath(),e.strokeRect(r,i,a,c),e.restore()}}}class Qr extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.SelectGroup)}draw(e,n){const{rect:o,isPrecise:s}=this.prop;e.save(),e.beginPath(),e.strokeStyle=Ss,e.fillStyle=Ss,s&&e.setLineDash([2,2]),e.rect(o.x,o.y,o.width,o.height),e.lineWidth=1/n,e.stroke(),e.globalAlpha=.2,e.fill(),e.restore()}}class Zr extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.TextSelection)}draw(e){const{selectionList:n,node:o}=this.prop;if(n.length===0)return;e.save(),e.fillStyle=zr,e.globalAlpha=.5;const{a:s,b:r,c:i,d:a,e:c,f:h}=o.globalTransform();e.transform(s,r,i,a,c,h);for(const d of n)e.fillRect(d.x,d.y,d.width,d.height);e.restore()}}class qr{static computeStretchRects(t,e){const n=Wr/e,o=.5*n;return[new D(t.x-o,t.y-o,n,n),new D(t.x+t.width-o,t.y-o,n,n),new D(t.x+t.width-o,t.y+t.height-o,n,n),new D(t.x-o,t.y+t.height-o,n,n)]}}class Jr extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.StretchRect)}draw(e,n){const{rect:o,transform:s}=this.prop,r=qr.computeStretchRects(o,n);e.save();const{a:i,b:a,c,d:h,e:d,f:u}=s;e.transform(i,a,c,h,d,u),e.strokeStyle=Qe,e.fillStyle=Ht,e.lineWidth=1/n,e.globalAlpha=1,e.beginPath();for(const f of r)e.roundRect(f.x,f.y,f.width,f.height,1/n),e.fill(),e.stroke();e.restore()}}class ei extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.CreateRectBound)}draw(e,n){const{rect:o,transform:s}=this.prop;e.save();const{a:r,b:i,c:a,d:c,e:h,f:d}=s;e.transform(r,i,a,c,h,d),e.strokeStyle=Qe,e.lineWidth=1/n,e.globalAlpha=1;const{width:u,height:f}=o;e.beginPath(),e.strokeRect(0,0,u,f),e.restore()}}class ti extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.ExpandShape)}draw(e,n){const{rect:o,transform:s}=this.prop,{width:r,height:i}=o,a=1.5/n,c=re.generateMatrix().scale(a,a),h=re.generateMatrix().translate(.5*r-.5*a*14,i-.5*a*8),d=s.crossProduct(h.crossProduct(c));e.save(),e.beginPath();const{a:u,b:f,c:g,d:y,e:P,f:b}=d;e.transform(u,f,g,y,P,b),e.fillStyle=Qe,e.roundRect(0,0,14,7.58333,2),e.fill(),e.beginPath(),e.fillStyle=Ht,e.rect(1.75,2.91666,2.33333,2.33333),e.rect(5.83333,2.91666,2.33333,2.33333),e.rect(9.91667,2.91666,2.33333,2.33333),e.fill(),e.restore()}}class ni extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.AlignLine)}draw(e,n){const{lines:o}=this.prop;e.save(),e.beginPath(),e.strokeStyle=Qe,e.lineWidth=1/n,e.globalAlpha=1,e.setLineDash([4,2]);for(const s of o){const{start:r,end:i}=s;e.moveTo(r.x,r.y),e.lineTo(i.x,i.y)}e.stroke(),e.restore()}}class oi extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.AlignStretchLine)}draw(e,n){const o=10/n,{alignInfo:s}=this.prop,{width:r,height:i}=s;e.save(),e.beginPath(),e.strokeStyle=Qe,e.lineWidth=1/n,e.globalAlpha=1,r&&this.drawWidth(e,r,o),i&&this.drawHeight(e,i,o),e.restore()}drawWidth(e,n,o){const{lines:s}=n;for(const r of s){const{line:i,transform:a}=r,{start:c,end:h}=i;e.save();const{a:d,b:u,c:f,d:g,e:y,f:P}=a;e.transform(d,u,f,g,y,P);const b={x:c.x,y:c.y},w={x:c.x,y:c.y+2*o};e.moveTo(b.x,b.y),e.lineTo(w.x,w.y);const L={x:h.x,y:h.y},B={x:h.x,y:h.y+2*o};e.moveTo(L.x,L.y),e.lineTo(B.x,B.y),e.moveTo(c.x,c.y+o),e.lineTo(h.x,h.y+o),e.stroke(),e.restore()}}drawHeight(e,n,o){const{lines:s}=n;for(const r of s){const{line:i,transform:a}=r,{start:c,end:h}=i;e.save();const{a:d,b:u,c:f,d:g,e:y,f:P}=a;e.transform(d,u,f,g,y,P);const b={x:c.x,y:c.y},w={x:c.x+2*o,y:c.y};e.moveTo(b.x,b.y),e.lineTo(w.x,w.y);const L={x:h.x,y:h.y},B={x:h.x+2*o,y:h.y};e.moveTo(L.x,L.y),e.lineTo(B.x,B.y),e.moveTo(c.x+o,c.y),e.lineTo(h.x+o,h.y),e.stroke(),e.restore()}}}class Gl extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.SingleSelectBound)}draw(e,n){const{start:o,end:s,transform:r}=this.prop,i=5/n;e.save();const{a,b:c,c:h,d,e:u,f}=r;e.transform(a,c,h,d,u,f),e.strokeStyle=Qe,e.fillStyle=Ht,e.lineWidth=2/n,e.globalAlpha=1,e.beginPath(),e.arc(o.x,o.y,i,0,2*Math.PI),e.fill(),e.stroke(),e.beginPath(),e.arc(s.x,s.y,i,0,2*Math.PI),e.fill(),e.stroke(),e.restore()}}class Ul extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.HoverLine)}draw(e,n){const{node:o,transform:s}=this.prop;e.save();const{a:r,b:i,c:a,d:c,e:h,f:d}=s;e.transform(r,i,a,c,h,d),e.strokeStyle=Gt,e.lineWidth=2/n,e.globalAlpha=1,e.beginPath(),o.drawer.draw(o,e),e.restore()}}class _l extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.SelectLine)}draw(e,n){const{node:o}=this.prop;e.save();const{a:s,b:r,c:i,d:a,e:c,f:h}=o.globalTransform();e.transform(s,r,i,a,c,h),e.strokeStyle=Qe,e.lineWidth=2/n,e.globalAlpha=1,e.beginPath(),o.drawer.draw(o,e),e.restore()}}class $l extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.HoverConnectPoint)}draw(e,n){const{point:o}=this.prop,s=4/n;e.save(),e.fillStyle=Gt,e.strokeStyle=Gt,e.lineWidth=2/n,e.globalAlpha=1,e.beginPath(),e.arc(o.x,o.y,s,0,2*Math.PI),e.fill(),e.restore()}}class jl extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.HoverConnectAnchorPoint)}draw(e,n){const{node:o}=this.prop;if(!o.canQuickCreate())return;const s=5/n,{width:r,height:i}=o.baseProps,{a,b:c,c:h,d,e:u,f}=o.globalTransform(),g=o.getConnectAnchor(),y=[];for(const P of g)y.push(new m(P.x*r,P.y*i));e.save(),e.transform(a,c,h,d,u,f),e.fillStyle=Ht,e.strokeStyle=Qe;for(const P of y)e.beginPath(),e.arc(P.x,P.y,s,0,2*Math.PI),e.fill(),e.stroke();e.restore()}}class Vl extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.HoverConnectAnchorPoint)}draw(e,n){const{node:o,localPoint:s}=this.prop;if(!o.canBeConnected())return;const r=6/n,{a:i,b:a,c,d:h,e:d,f:u}=o.globalTransform();e.save(),e.transform(i,a,c,h,d,u),e.fillStyle=Gt,e.beginPath(),e.arc(s.x,s.y,r,0,2*Math.PI),e.fill(),e.stroke(),e.restore()}}const A=22;class Kl extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.SelectPolyLineControlPoint)}draw(e,n){const{points:o,transform:s}=this.prop;e.save(),e.fillStyle=Qe,e.strokeStyle=Ht,e.lineWidth=2/n,e.globalAlpha=1;const{a:r,b:i,c:a,d:c,e:h,f:d}=s;e.transform(r,i,a,c,h,d);for(let u=0;u<o.length-1;u++){const f=o[u],g=o[u+1];if(S.distance(f,g)<(A+6)/n)continue;const P=S.judgeHorizon(f,g),b=.5*(f.x+g.x),w=.5*(f.y+g.y);if(e.beginPath(),P){const L=new m(b-6/n,w);e.roundRect(L.x,L.y-2/n,12/n,4/n,2/n)}else{const L=new m(b,w-6/n);e.roundRect(L.x-2/n,L.y,4/n,12/n,2/n)}e.stroke(),e.fill()}e.restore()}}class Ql extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.SelectLineTextRect)}draw(e,n){const{node:s,transform:r}=this.prop,i=s.getTextContentRect();e.save();const{a,b:c,c:h,d,e:u,f}=r;e.transform(a,c,h,d,u,f),e.strokeStyle=Qe,e.lineWidth=2/n,e.globalAlpha=1,e.beginPath(),e.strokeRect(i.x-2,i.y-2,i.width+2*2,i.height+2*2),e.restore()}}const si="输入文本";class Zl extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.PlaceHolder)}draw(e,n){const{node:o}=this.prop,s=o.shapeType!==K.PureText,r=o.renderText,i=r.paragraphs[0],a=i.lines[0],c=r.x+i.x+a.x,h=r.y+i.y+a.y,{fontSize:d,fontFamily:u,bold:f,italic:g}=r.textProps;e.save();const{a:y,b:P,c:b,d:w,e:L,f:B}=o.globalTransform();e.transform(y,P,b,w,L,B),e.textAlign="left",e.textBaseline="alphabetic",e.fillStyle="#000000",e.globalAlpha=.5,e.font=S.calcFont(d,u,f,g);const H=e.measureText(si),E=H.fontBoundingBoxAscent,X=H.width,$=s?c-.5*X:c;e.fillText(si,$,h+E),e.restore()}}class ql extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.SelectConnectAnchor)}draw(e,n){const{node:o}=this.prop,s=Yr/n,r=S.computeNodeConnectAnchor(o,n);e.save(),e.fillStyle=Ur,e.globalAlpha=1;const{a:i,b:a,c,d:h,e:d,f:u}=o.globalTransform();e.transform(i,a,c,h,d,u);for(const f of r)e.beginPath(),e.arc(f.x,f.y,s,0,2*Math.PI),e.fill();e.restore()}}class Jl extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.HoverConnectAnchor)}draw(e,n){const{point:o}=this.prop,s=Ms/n;e.save(),e.strokeStyle=Qe,e.fillStyle=_r,e.globalAlpha=1,e.lineWidth=2/n,e.beginPath(),e.arc(o.x,o.y,s,0,2*Math.PI),e.fill(),e.stroke(),e.restore()}}class eh extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.PreviewGraphics)}draw(e,n){const{previewNodes:o}=this.prop;for(const s of o)s.drawOnGLCtx(e)}}class th extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.HoverContainer)}draw(e,n){const{node:o}=this.prop;e.save(),e.strokeStyle=Gt,e.lineWidth=2/n,e.globalAlpha=1;const{width:s,height:r}=o.baseProps,{a:i,b:a,c,d:h,e:d,f:u}=o.globalTransform();e.transform(i,a,c,h,d,u),e.beginPath(),e.strokeRect(0,0,s,r),e.restore()}}class nh extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.CropBounds)}draw(e,n){const{node:o,transform:s}=this.prop,r=12/n;e.save(),e.strokeStyle=bs,e.lineWidth=2/n,e.globalAlpha=1;const{width:i,height:a}=o.baseProps,{a:c,b:h,c:d,d:u,e:f,f:g}=s;e.transform(c,h,d,u,f,g),e.beginPath(),e.moveTo(0,r),e.lineTo(0,0),e.lineTo(r,0),e.moveTo(i-r,0),e.lineTo(i,0),e.lineTo(i,r),e.moveTo(i-r,a),e.lineTo(i,a),e.lineTo(i,a-r),e.moveTo(0,a-r),e.lineTo(0,a),e.lineTo(r,a),e.moveTo(.5*i-.5*r,0),e.lineTo(.5*i+.5*r,0),e.moveTo(.5*i-.5*r,a),e.lineTo(.5*i+.5*r,a),e.moveTo(0,.5*a-.5*r),e.lineTo(0,.5*a+.5*r),e.moveTo(i,.5*a-.5*r),e.lineTo(i,.5*a+.5*r),e.stroke(),e.beginPath(),e.setLineDash([2,2]),e.lineWidth=1/n,e.strokeRect(0,0,i,a),e.restore()}}class oh extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.CropOriginImg)}draw(e,n){const{imgBitmap:o,transform:s,x:r,y:i,width:a,height:c}=this.prop;e.save();const{a:h,b:d,c:u,d:f,e:g,f:y}=s;e.transform(h,d,u,f,g,y),e.globalAlpha=.4,e.drawImage(o,r,i,a,c),e.restore()}}class sh extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.HoverSize)}draw(e,n){const{rect:o,transform:s}=this.prop,{width:r,height:i}=o,a=Math.round(r),c=Math.round(i),h=`${a}x${c}`,d=12/n,u="Noto Sans",f=S.measureTextByFont(e,h,d,"Noto Sans",!1,!1);e.save();const g=re.generateMatrix().translate(r-f.width,i),{a:y,b:P,c:b,d:w,e:L,f:B}=s.crossProduct(g);e.transform(y,P,b,w,L,B),e.fillStyle=Qe,e.globalAlpha=1,e.fillRect(0,0,f.width,f.height),e.fillStyle=Ht,e.font=S.calcFont(d,u),e.textAlign="left",e.textBaseline="top",e.fillText(h,0,2/n),e.restore()}}class rh extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.SingleSelectBound)}draw(e,n){const{points:o,transform:s}=this.prop,r=5/n;e.save();const{a:i,b:a,c,d:h,e:d,f:u}=s;e.transform(i,a,c,h,d,u),e.strokeStyle=Qe,e.fillStyle=Qe,e.lineWidth=2/n,e.globalAlpha=1;for(const f of o)e.beginPath(),e.arc(f.x,f.y,r,0,2*Math.PI),e.fill(),e.stroke();e.restore()}}class ih extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.SelectCurveEnd)}draw(e,n){const{points:o,transform:s}=this.prop,r=5/n;e.save();const{a:i,b:a,c,d:h,e:d,f:u}=s;e.transform(i,a,c,h,d,u),e.strokeStyle=Qe,e.fillStyle=Ht,e.lineWidth=2/n,e.globalAlpha=1;for(const f of o)e.beginPath(),e.arc(f.x,f.y,r,0,2*Math.PI),e.fill(),e.stroke();e.restore()}}class ah extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.SelectParentGroupBound)}draw(e,n){const{node:o}=this.prop;e.save(),e.strokeStyle=Gt,e.lineWidth=1/n,e.globalAlpha=1;const{width:s,height:r}=o.baseProps,{a:i,b:a,c,d:h,e:d,f:u}=o.nameGlobalTransform();e.transform(i,a,c,h,d,u),e.beginPath(),e.strokeRect(0,0,s,r),e.restore()}}class ch extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.HoverSlidePlaceHolder)}draw(e,n){const{baseProps:o}=this.prop;e.save(),e.fillStyle=Gr,e.lineWidth=2/n,e.globalAlpha=.5;const{x:s,y:r,width:i,height:a}=o;e.beginPath(),e.roundRect(s,r,i,a,10),e.fill(),e.restore()}}class lh extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.HoverFocusCopy)}draw(e,n){const{nodes:o}=this.prop;e.save();for(const s of o)s.drawOnGLCtx(e);e.restore()}}class hh extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.HoverInsertSlide)}draw(e,n){const{x:o,y1:s,y0:r}=this.prop;e.save(),e.strokeStyle=Gt,e.lineWidth=2/n,e.globalAlpha=1,e.moveTo(o,r),e.lineTo(o,s),e.stroke(),e.restore()}}class dh extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.HoverInsertHorizonSlide)}draw(e,n){const{x0:o,x1:s,y:r}=this.prop;e.save(),e.strokeStyle=Gt,e.lineWidth=2/n,e.globalAlpha=1,e.moveTo(o,r),e.lineTo(s,r),e.stroke(),e.restore()}}class uh extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.HoverSlideGapInsertPoint)}draw(e,n){const{point:o}=this.prop,s=10/n;e.save(),e.fillStyle=Qe,e.globalAlpha=1,e.beginPath(),e.arc(o.x,o.y,s,0,2*Math.PI),e.fill();const r=6/n;e.strokeStyle=Ht,e.lineWidth=2.5/n,e.lineCap="square",e.beginPath(),e.moveTo(o.x-r,o.y),e.lineTo(o.x+r,o.y),e.moveTo(o.x,o.y-r),e.lineTo(o.x,o.y+r),e.stroke(),e.restore()}}class ph extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.SelectSlideGapInsertPoint)}draw(e,n){const{points:o}=this.prop,s=6/n;e.save(),e.fillStyle=Qe,e.globalAlpha=.9,e.beginPath();for(const r of o){e.beginPath(),e.arc(r.x,r.y,s,0,2*Math.PI),e.fill();const i=3.6/n;e.strokeStyle=Ht,e.lineWidth=1.5/n,e.lineCap="square",e.beginPath(),e.moveTo(r.x-i,r.y),e.lineTo(r.x+i,r.y),e.moveTo(r.x,r.y-i),e.lineTo(r.x,r.y+i),e.stroke()}e.restore()}}class vs{static create(t){const e=this.constructorMap[t];return e?new e:(console.error("缺少对应构造函数"),null)}}p(vs,"constructorMap",{[k.HoverBounds]:$r,[k.SingleSelectBound]:jr,[k.MultiSelectBound]:Vr,[k.HighlightRects]:Kr,[k.SelectGroup]:Qr,[k.TextSelection]:Zr,[k.StretchRect]:Jr,[k.CreateRectBound]:ei,[k.ExpandShape]:ti,[k.AlignLine]:ni,[k.AlignStretchLine]:oi,[k.SelectLineEnd]:Gl,[k.HoverLine]:Ul,[k.SelectLine]:_l,[k.HoverConnectPoint]:$l,[k.HoverConnectAnchorPoint]:jl,[k.HoverAnchorPoint]:Vl,[k.SelectPolyLineControlPoint]:Kl,[k.SelectLineTextRect]:Ql,[k.PlaceHolder]:Zl,[k.SelectConnectAnchor]:ql,[k.HoverConnectAnchor]:Jl,[k.PreviewGraphics]:eh,[k.HoverContainer]:th,[k.CropBounds]:nh,[k.CropOriginImg]:oh,[k.HoverSize]:sh,[k.SelectCurveControlPoint]:rh,[k.SelectCurveEnd]:ih,[k.SelectParentGroupBound]:ah,[k.HoverSlidePlaceHolder]:ch,[k.HoverFocusCopy]:lh,[k.HoverInsertSlide]:hh,[k.HoverInsertHorizonSlide]:dh,[k.HoverSlideGapInsertPoint]:uh,[k.SelectSlideGapInsertPoint]:ph});class ri{constructor(){p(this,"isWorking",!1);p(this,"idList",[]);p(this,"originX",0);p(this,"originY",0)}startWorking(t,e,n){this.idList=t,this.originX=e,this.originY=n,this.isWorking=!0}selectChange(t){if(!this.isWorking)return;t.size!==this.idList.length&&this.stopWork();const e=new Set(this.idList);for(const n of t)e.has(n.id)||this.stopWork(),e.delete(n.id);e.size!==0&&this.stopWork()}stopWork(){this.idList=[],this.isWorking=!1}}class bt{}const fh=new Set([v.Shape,v.SVG,v.IMG,v.Group,v.Section,v.Checkbox,v.CheckboxText]);class ii extends bt{enable(t){return t.length===1&&fh.has(t[0].type)}handle(t,e){const n=t[0],o=n.globalTransform().clone(),{width:s,height:r}=n.baseProps;e.addOrUpdate(k.SingleSelectBound,{x:0,y:0,width:s,height:r,transform:o}),n.parent&&n.parent.type===v.Group&&e.addOrUpdate(k.SelectParentGroupBound,{node:n.parent});const i=D.baseProps2Rect(n.baseProps);if(t.filter(c=>S.judgeNodeCanBeStretch(c)).length>0&&e.addOrUpdate(k.StretchRect,{transform:o,rect:new D(0,0,i.width,i.height)}),n.canQuickCreate()&&e.addOrUpdate(k.SelectConnectAnchor,{node:n}),n instanceof vt&&n.shapeType!==K.PureText){const h=n.drawer.fullTextNodeHeight(n);n.baseProps.height<h&&e.addOrUpdate(k.ExpandShape,{transform:o,rect:i})}}}class ai extends bt{enable(t){return t.length>1}handle(t,e){const n=[],o=[];t.forEach(i=>{const a=i.getBounds();n.push(a),o.push(D.rectNode2Rect(a))});const s=S.getBounds(n),r=D.rectNode2Rect(s);e.addOrUpdate(k.MultiSelectBound,{rect:r}),e.addOrUpdate(k.HighlightRects,{rects:o}),e.addOrUpdate(k.StretchRect,{rect:new D(0,0,r.width,r.height),transform:re.generateMatrix().translate(r.x,r.y)})}}var ze=(l=>(l[l.Scale=0]="Scale",l[l.Focus=1]="Focus",l[l.FocusPropsChange=2]="FocusPropsChange",l[l.ToolChange=3]="ToolChange",l[l.QuickCreate=4]="QuickCreate",l[l.ClickImg=5]="ClickImg",l[l.ImgUrls=6]="ImgUrls",l[l.ContextMenu=7]="ContextMenu",l[l.ExitCrop=8]="ExitCrop",l[l.DocMode=9]="DocMode",l[l.SlideCovers=10]="SlideCovers",l[l.SlideIndex=11]="SlideIndex",l))(ze||{});class ci{constructor(){p(this,"slotMap",new Map);p(this,"slotCallBack",new Map);p(this,"tickerRun",()=>{for(const[t,e]of this.slotMap){const n=this.slotCallBack.get(t);n&&n(e)}this.slotMap.clear(),requestAnimationFrame(this.tickerRun)})}start(){this.tickerRun()}addSlotState(t,e){this.slotMap.set(t,e)}registerSlotCallback(t,e){this.slotCallBack.set(t,e)}}class gh extends bt{enable(t){return t.length===1&&t[0].type===v.Line}handle(t,e){const n=t[0],o=n.points,s=n.globalTransform();e.addOrUpdate(k.SelectLineEnd,{start:o[0],end:o[o.length-1],transform:s})}}class yh extends bt{enable(t){if(t.length!==1)return!1;const e=t[0];return e.type!==v.Line?!1:!!e.isPolyLine()}handle(t,e){const n=t[0],o=n.points,s=n.globalTransform();e.addOrUpdate(k.SelectLineEnd,{start:o[0],end:o[o.length-1],transform:s}),e.addOrUpdate(k.SelectPolyLineControlPoint,{points:n.points,transform:s})}}class xh extends bt{enable(t,e){if(t.length!==1)return!1;const n=t[0];if(n.type!==v.Line)return!1;const o=e.inputManager.editTextInfo;if(!o)return!1;const s=n;return o.node.id===s.id}handle(t,e){const n=t[0];e.addOrUpdate(k.SelectLineTextRect,{node:n,transform:n.globalTransform()})}}class wh extends bt{enable(t){return t.length===1&&t[0].type===v.Group}handle(t,e){const n=t[0],o=n.nameGlobalTransform().clone(),{width:s,height:r}=n.baseProps;e.addOrUpdate(k.SingleSelectBound,{x:0,y:0,width:s,height:r,transform:o}),n.parent&&n.parent.type===v.Group&&e.addOrUpdate(k.SelectParentGroupBound,{node:n.parent});const i=D.baseProps2Rect(n.baseProps);e.addOrUpdate(k.StretchRect,{transform:o,rect:new D(0,0,i.width,i.height)})}}const mh=new Set([v.SVG,v.IMG]);class Ph extends bt{enable(t,e){if(t.length!==1)return!1;const n=t[0];return!(!mh.has(n.type)||!e.cropManager.duringCrop||!n.imgBitmap)}handle(t,e){const n=t[0],o=n.globalTransform().clone();e.addOrUpdate(k.CropBounds,{node:n,transform:o});const{cropType:s,cropInfo:r}=n.cropProps,{x:i,y:a,width:c,height:h}=n.baseProps;if(s===0||!r){e.addOrUpdate(k.SingleSelectBound,{x:0,y:0,width:c,height:h,transform:o});const d=new D(0,0,c,h);e.addOrUpdate(k.StretchRect,{transform:o,rect:d})}else{const d=n.getOriginImageRect();e.addOrUpdate(k.SingleSelectBound,{x:d.x,y:d.y,width:d.width,height:d.height,transform:o}),e.addOrUpdate(k.StretchRect,{transform:o,rect:d}),e.addOrUpdate(k.CropOriginImg,{x:d.x,y:d.y,width:d.width,height:d.height,transform:o,imgBitmap:n.imgBitmap})}}}class bh extends bt{enable(t){return t.length===1&&t[0].type===v.Line&&t[0].shapeType===he.Curve}handle(t,e){const n=t[0],o=n.globalTransform();e.addOrUpdate(k.SelectCurveEnd,{points:S.computeCurveEndPoints(n),transform:o}),e.addOrUpdate(k.SelectCurveControlPoint,{points:S.computeCurveControlPoints(n),transform:o})}}const Sh=new Set([v.Shape,v.SVG,v.IMG,v.Group,v.Section,v.Checkbox,v.CheckboxText]);class Mh extends bt{enable(t,e){return!e.docState.userPermission.canEdit&&t.length===1}handle(t,e){const n=t[0];if(n.type===v.Group){this.handleGroup(n,e);return}if(n instanceof Ct){this.handleLine(n,e);return}if(Sh.has(n.type)){this.handleNormalNode(n,e);return}}handleNormalNode(t,e){const n=t.globalTransform().clone(),{width:o,height:s}=t.baseProps;e.addOrUpdate(k.SingleSelectBound,{x:0,y:0,width:o,height:s,transform:n}),t.parent&&t.parent.type===v.Group&&e.addOrUpdate(k.SelectParentGroupBound,{node:t.parent})}handleLine(t,e){e.addOrUpdate(k.SelectLine,{node:t})}handleGroup(t,e){const n=t.nameGlobalTransform().clone(),{width:o,height:s}=t.baseProps;e.addOrUpdate(k.SingleSelectBound,{x:0,y:0,width:o,height:s,transform:n}),t.parent&&t.parent.type===v.Group&&e.addOrUpdate(k.SelectParentGroupBound,{node:t.parent})}}class vh extends bt{enable(t,e){return!e.docState.userPermission.canEdit&&t.length>1}handle(t,e){const n=[],o=[];t.forEach(i=>{const a=i.getBounds();n.push(a),o.push(D.rectNode2Rect(a))});const s=S.getBounds(n),r=D.rectNode2Rect(s);e.addOrUpdate(k.MultiSelectBound,{rect:r}),e.addOrUpdate(k.HighlightRects,{rects:o})}}class Ih extends bt{enable(t){return t.length===1&&t[0].type===v.SlideContainer}handle(t,e){const n=t[0],o=n.globalTransform().clone(),{width:s,height:r}=n.baseProps;e.addOrUpdate(k.SingleSelectBound,{x:0,y:0,width:s,height:r,transform:o}),n.parent&&n.parent.type===v.Group&&e.addOrUpdate(k.SelectParentGroupBound,{node:n.parent})}}const Th=5,nt=50,xt=40;class Lh extends bt{enable(t){var e;return t.length===1&&((e=t[0].parent)==null?void 0:e.type)===v.SlideContainer}handle(t,e){const n=t[0],o=n.globalTransform().clone(),{x:s,y:r,height:i,width:a}=n.globalBaseProps;e.addOrUpdate(k.SingleSelectBound,{x:0,y:0,width:a,height:i,transform:o});const c=[{x:s-nt/2,y:r+i/2},{x:s+a+nt/2,y:r+i/2}];e.addOrUpdate(k.SelectSlideGapInsertPoint,{points:c})}}var ue=(l=>(l[l.BOARD=0]="BOARD",l[l.SLIDE_EDIT=1]="SLIDE_EDIT",l[l.SLIDE_PLAY=2]="SLIDE_PLAY",l))(ue||{});class Ch extends bt{enable(t,e){var n;return t.length===1&&((n=t[0].parent)==null?void 0:n.type)===v.SlideContainer&&e.docState.docMode===ue.SLIDE_EDIT}handle(t,e){const n=t[0],o=n.globalTransform().clone(),{x:s,y:r,height:i,width:a}=n.globalBaseProps;e.addOrUpdate(k.SingleSelectBound,{x:0,y:0,width:a,height:i,transform:o})}}class li{constructor(t,e,n,o){p(this,"selectNodes",new Set);p(this,"optionHelper");p(this,"auxiliaryManager");p(this,"inputManager");p(this,"cropManager");p(this,"docState");p(this,"statusHandlers",[new Mh,new vh,new Ih,new wh,new xh,new yh,new bh,new gh,new Ph,new Ch,new Lh,new ii,new ai]);this.auxiliaryManager=e,this.optionHelper=new ri,this.cropManager=n,this.docState=o}register(t){this.inputManager=t}refreshSelectStatus(){this.auxiliaryManager.removeSelectGraphics();const t=[...this.selectNodes],e=this.selectStatusContext();for(const n of this.statusHandlers)if(n.enable(t,e)){n.handle(t,this.auxiliaryManager);return}}selectStatusContext(){return{inputManager:this.inputManager,cropManager:this.cropManager,docState:this.docState}}getSelectNodes(){return[...this.selectNodes]}getSelectBounds(){const t=[];for(const e of this.selectNodes)t.push(e.getBounds());return S.getBounds(t,"selectBounds")}set(t){this.selectNodes=t,this.optionHelper.selectChange(t),this.auxiliaryManager.slotManager.addSlotState(ze.Focus,[...t]),this.auxiliaryManager.slotManager.addSlotState(ze.FocusPropsChange,!0),this.refreshSelectStatus()}startOptWorking(t,e,n){this.optionHelper.startWorking(t,e,n)}include(t){return this.selectNodes.has(t)}}class hi{constructor(t,e,n,o){p(this,"gmlRender");p(this,"selectManager");p(this,"graphicMap");p(this,"slotManager");this.gmlRender=t,this.slotManager=e,this.selectManager=new li(t,this,n,o),this.graphicMap=new Map}start(){}addOrUpdate(t,e){const n=this.graphicMap.get(t);if(n){n.update(e);return}const o=vs.create(t);o&&(this.graphicMap.set(t,o),o.update(e))}remove(t){this.graphicMap.delete(t)}redraw(){const t=this.gmlRender.getViewPortBounds();this.gmlRender.glCtx.clearRect(t.minX,t.minY,t.maxX-t.minX,t.maxY-t.minY);const e=this.gmlRender.getScale(),n=[...this.graphicMap.values()];n.sort((o,s)=>o.auxiliaryType-s.auxiliaryType);for(const o of n)o.draw(this.gmlRender.glCtx,e)}removeHoverGraphics(){this.remove(k.HoverBounds),this.remove(k.HoverLine),this.remove(k.HoverConnectPoint),this.remove(k.HoverConnectAnchorPoint),this.remove(k.HoverAnchorPoint),this.remove(k.HoverConnectAnchor),this.remove(k.PreviewGraphics),this.remove(k.HoverContainer),this.remove(k.HoverSize),this.remove(k.HoverSlidePlaceHolder),this.remove(k.HoverFocusCopy),this.remove(k.HoverInsertSlide),this.remove(k.HoverInsertHorizonSlide),this.remove(k.HoverSlideGapInsertPoint),this.removeAlignGraphics()}removeSelectGraphics(){this.remove(k.SingleSelectBound),this.remove(k.MultiSelectBound),this.remove(k.HighlightRects),this.remove(k.TextSelection),this.remove(k.StretchRect),this.remove(k.ExpandShape),this.remove(k.SelectLineEnd),this.remove(k.SelectLine),this.remove(k.SelectPolyLineControlPoint),this.remove(k.SelectCurveControlPoint),this.remove(k.SelectCurveEnd),this.remove(k.SelectLineTextRect),this.remove(k.SelectConnectAnchor),this.remove(k.CropBounds),this.remove(k.CropOriginImg),this.remove(k.SelectParentGroupBound),this.remove(k.SelectSlideGapInsertPoint)}removeAlignGraphics(){this.remove(k.AlignLine),this.remove(k.AlignStretchLine)}}class Ah{}class Wn extends ct{constructor(){super(...arguments);p(this,"type",I.Svg);p(this,"useCode",!1);p(this,"url","");p(this,"code","")}static from(e){const n=new Wn;return n.url=e.url,n.code=e.code,n.useCode=e.useCode,n}clone(){const e=new Wn;return e.url=this.url,e.code=this.code,e.useCode=this.useCode,e}update(e){const{url:n,code:o,useCode:s}=e;n!==void 0&&(this.url=n),o!==void 0&&(this.code=o),s!==void 0&&(this.useCode=s)}}var wt=(l=>(l[l.None=0]="None",l[l.Rect=1]="Rect",l[l.RoundRect=2]="RoundRect",l[l.Circle=3]="Circle",l))(wt||{});class Mn extends ct{constructor(){super(...arguments);p(this,"type",I.Crop);p(this,"cropType",wt.None);p(this,"cropInfo")}static from(e){const n=new Mn;return n.cropType=e.cropType||wt.None,n.cropInfo=e.cropInfo,n}clone(){const e=new Mn;return e.cropType=this.cropType,this.cropInfo&&(e.cropInfo={imgX:this.cropInfo.imgX,imgY:this.cropInfo.imgY,imgWidth:this.cropInfo.imgWidth,imgHeight:this.cropInfo.imgHeight}),e}update(e){const{cropInfo:n,cropType:o}=e;n!==void 0&&(this.cropInfo=n),o!==void 0&&(this.cropType=o)}}class Qt extends ct{constructor(){super(...arguments);p(this,"type",I.CheckStatus);p(this,"checkStatus",!1)}static create(e){const n=new Qt;return n.update(e),n}static from(e){const n=new Qt;return n.checkStatus=e.checkStatus,n}clone(){const e=new Qt;return e.checkStatus=this.checkStatus,e}update(e){const{checkStatus:n}=e;n!==void 0&&(this.checkStatus=n)}}class vn extends ct{constructor(){super(...arguments);p(this,"type",I.CheckSize);p(this,"size",16)}static create(e){const n=new vn;return n.update(e),n}static from(e){const n=new vn;return n.size=e.size,n}clone(){const e=new vn;return e.size=this.size,e}update(e){const{size:n}=e;n!==void 0&&(this.size=n)}}var me=(l=>(l[l.Decision=0]="Decision",l[l.Step=1]="Step",l[l.Data=2]="Data",l[l.Status=3]="Status",l[l.Operation=4]="Operation",l[l.Others=5]="Others",l[l.Section=6]="Section",l[l.Resource=7]="Resource",l[l.Line=8]="Line",l[l.Check=9]="Check",l))(me||{}),K=(l=>(l[l.PureText=0]="PureText",l[l.Rect=1]="Rect",l[l.Ellipse=2]="Ellipse",l[l.Octagon=3]="Octagon",l[l.DoubleArrow=4]="DoubleArrow",l[l.LeftArrow=5]="LeftArrow",l[l.LeftKuohao=6]="LeftKuohao",l[l.Diamond=7]="Diamond",l[l.Hexagon=8]="Hexagon",l[l.LiuCheng=9]="LiuCheng",l[l.LiuCheng2=10]="LiuCheng2",l[l.Parallelogram=11]="Parallelogram",l[l.Qipao=12]="Qipao",l[l.Qipao2=13]="Qipao2",l[l.RightArrow=14]="RightArrow",l[l.RightKuohao=15]="RightKuohao",l[l.RoundRect=16]="RoundRect",l[l.RoundRect2=17]="RoundRect2",l[l.Cross=18]="Cross",l[l.Trapezoid=19]="Trapezoid",l[l.Triangle=20]="Triangle",l[l.Triangle2=21]="Triangle2",l[l.Pentagon=22]="Pentagon",l[l.Star=23]="Star",l[l.YuanZhu=24]="YuanZhu",l[l.Cloud=25]="Cloud",l))(K||{});const Is={[K.PureText]:me.Operation,[K.Rect]:me.Operation,[K.RoundRect]:me.Step,[K.Triangle]:me.Operation,[K.Diamond]:me.Decision,[K.Ellipse]:me.Status,[K.Parallelogram]:me.Operation,[K.Trapezoid]:me.Step,[K.Cross]:me.Operation,[K.Pentagon]:me.Operation,[K.Hexagon]:me.Decision,[K.Octagon]:me.Operation,[K.Star]:me.Decision};var Zt=(l=>(l[l.TOP_RIGHT=0]="TOP_RIGHT",l[l.TOP_LEFT=1]="TOP_LEFT",l[l.BOTTOM_RIGHT=2]="BOTTOM_RIGHT",l[l.BOTTOM_LEFT=3]="BOTTOM_LEFT",l))(Zt||{});class qt extends ct{constructor(){super(...arguments);p(this,"type",I.TextParagraph);p(this,"paragraphStyles",[])}static create(e){const n=new qt;return n.update(e),n}static from(e){const n=new qt;return n.paragraphStyles=e.paragraphStyles,n}clone(){const e=new qt;return e.paragraphStyles=JSON.parse(JSON.stringify(this.paragraphStyles)),e}update(e){const{paragraphStyles:n}=e;n!==void 0&&(this.paragraphStyles=n)}}class Dt extends ct{constructor(){super(...arguments);p(this,"paraQuoteStyles",[]);p(this,"type",I.TextParagraphQuote)}static create(e){const n=new Dt;return n.update(e),n}static from(e){const n=new Dt;return n.paraQuoteStyles=e.paraQuoteStyles,n}clone(){const e=new Dt;return e.paraQuoteStyles=JSON.parse(JSON.stringify(this.paraQuoteStyles)),e}update(e){const{paraQuoteStyles:n}=e;n!==void 0&&(this.paraQuoteStyles=n)}}var he=(l=>(l[l.Line=0]="Line",l[l.PolyLine=1]="PolyLine",l[l.RoundPolyLine=2]="RoundPolyLine",l[l.Curve=3]="Curve",l))(he||{});class di{constructor(t,e,n,o){p(this,"p0");p(this,"p1");p(this,"p2");p(this,"p3");this.p0=t,this.p1=e,this.p2=n,this.p3=o}getPos(t){if(t<0||t>1)throw new Error(`非法的t值:${t}`);const e=1-t,n=e*e*e*this.p0.x+3*t*e*e*this.p1.x+3*t*t*e*this.p2.x+t*t*t*this.p3.x,o=e*e*e*this.p0.y+3*t*e*e*this.p1.y+3*t*t*e*this.p2.y+t*t*t*this.p3.y;return new m(n,o)}getHalfTPos(){return this.getPos(.5)}getDerivative(t){const e=1-t,n=3*e*e*(this.p1.x-this.p0.x)+6*e*t*(this.p2.x-this.p1.x)+3*t*t*(this.p3.x-this.p2.x),o=3*e*e*(this.p1.y-this.p0.y)+6*e*t*(this.p2.y-this.p1.y)+3*t*t*(this.p3.y-this.p2.y);return new m(n,o)}getDistanceSquared(t,e){const n=this.getPos(e),o=n.x-t.x,s=n.y-t.y;return o*o+s*s}getTValueByPoint(t,e=1,n=50){let o=0,s=1/0;const r=20;for(let a=0;a<=r;a++){const c=a/r,h=this.getDistanceSquared(t,c);h<s&&(s=h,o=c)}if(Math.sqrt(s)<e)return o;let i=o;for(let a=0;a<n;a++){const c=this.getPos(i),h=this.getDerivative(i),d=c.x-t.x,u=c.y-t.y,f=d*h.x+u*h.y;if(Math.abs(f)<e)return Math.max(0,Math.min(1,i));const g=1-i,y=6*g*(this.p2.x-2*this.p1.x+this.p0.x)+6*i*(this.p3.x-2*this.p2.x+this.p1.x),P=6*g*(this.p2.y-2*this.p1.y+this.p0.y)+6*i*(this.p3.y-2*this.p2.y+this.p1.y),b=h.x*h.x+h.y*h.y+d*y+u*P;if(Math.abs(b)<1e-10)break;const w=i-f/b;if(i=Math.max(0,Math.min(1,w)),Math.abs(w-i)<e&&i===w)break}return i}getApproximateLength(t=10){let e=0,n=this.getPos(0);for(let o=1;o<=t;o++){const s=o/t,r=this.getPos(s),i=r.x-n.x,a=r.y-n.y;e+=Math.sqrt(i*i+a*a),n=r}return e}getTValueByDistance(t,e=20){if(t<=0)return 0;let n=0,o=this.getPos(0);for(let s=1;s<=e;s++){const r=s/e,i=this.getPos(r),a=i.x-o.x,c=i.y-o.y,h=Math.sqrt(a*a+c*c);if(n+h>=t){const u=(t-n)/h,f=(s-1)/e;return f+u*(r-f)}n+=h,o=i}return 1}}var Jt=(l=>(l.Windows="Windows",l.MacOS="MacOS",l.Linux="Linux",l.Android="Android",l.IOS="ios",l.Unknown="unknown",l))(Jt||{});class ui{static getOS(){const t=navigator.userAgent;return t.includes("Win")?Jt.Windows:t.includes("Mac")?Jt.MacOS:t.includes("Linux")?Jt.Linux:/Android/.test(t)?Jt.Android:/iPhone|iPad|iPod/.test(t)?Jt.IOS:Jt.Unknown}}class St extends ct{constructor(){super(...arguments);p(this,"type",I.Slide);p(this,"children",[])}static create(e){const n=new St;return n.update(e),n}static from(e){const n=new St;return n.children=e.children,n}clone(){const e=new St;return e.children=this.children,e}update(e){const{children:n}=e;n!==void 0&&(this.children=n)}}class S{static computeShapeCategory(t,e=0){return t===v.Shape?Is[e]??me.Others:t===v.CheckboxText||t===v.Checkbox?me.Check:t===v.Line?me.Line:t===v.Section?me.Section:t===v.SVG?me.Resource:me.Others}static makeSortGraphic(t){const e=[t];let n=t.parent;for(;n&&n.id!==Sn;)e.unshift(n),n=n.parent;return{graphics:e}}static sortGraphics(t){const e=t.map(this.makeSortGraphic);return e.sort((n,o)=>{const s=Math.min(n.graphics.length,o.graphics.length);for(let r=0;r<s;r++){const i=n.graphics[r],a=o.graphics[r];if(i!==a)return i.zIndex>a.zIndex?1:-1}return n.graphics.length-o.graphics.length}),e.map(n=>n.graphics[n.graphics.length-1])}static setDashLine(t,e){t.dashType===et.Dash1?e.setLineDash([4,2]):t.dashType===et.Dash2&&e.setLineDash([2,2])}static convertPropsToCapInfo(t){const e={},n=t.get(I.Base);n&&(e.baseProps=n);const o=t.get(I.Color);o&&(e.colorProps=o);const s=t.get(I.Border);s&&(e.borderProps=s);const r=t.get(I.Text);r&&(e.textProps=r);const i=t.get(I.Shape);i&&(e.shapeProps=i);const a=t.get(I.Line);a&&(e.lineProps=a);const c=t.get(I.Connect);c&&(e.connectProps=c);const h=t.get(I.Arrow);h&&(e.arrowProps=h);const d=t.get(I.LineTextRect);d&&(e.lineTextRectProps=d);const u=t.get(I.Svg);u&&(e.svgProps=u);const f=t.get(I.Image);f&&(e.imageProps=f);const g=t.get(I.Crop);g&&(e.cropProps=g);const y=t.get(I.CheckStatus);y&&(e.checkStatusProps=y);const P=t.get(I.CheckSize);y&&(e.checkSizeProps=P);const b=t.get(I.TextParagraph);b&&(e.textParagraphProps=b);const w=t.get(I.TextParagraphQuote);w&&(e.textParagraphQuoteProps=w);const L=t.get(I.Slide);return L&&(e.slideProps=L),e}static convertCapInfoToProps(t){const e=[],{baseProps:n,borderProps:o,shapeProps:s,colorProps:r,textProps:i,lineProps:a,connectProps:c,arrowProps:h,lineTextRectProps:d,svgProps:u,imageProps:f,cropProps:g,checkStatusProps:y,checkSizeProps:P,textParagraphProps:b,textParagraphQuoteProps:w,slideProps:L}=t;return o&&e.push(Ae.from(o)),r&&e.push(tt.from(r)),i&&e.push(Ge.from(i)),n&&e.push(ie.from(n)),s&&e.push(Oe.from(s)),a&&e.push(je.from(a)),c&&e.push(Rt.from(c)),h&&e.push(lt.from(h)),d&&e.push(Et.from(d)),u&&e.push(Wn.from(u)),f&&e.push(ro.from(f)),g&&e.push(Mn.from(g)),y&&e.push(Qt.from(y)),P&&e.push(vn.from(P)),b&&e.push(qt.from(b)),w&&e.push(Dt.from(w)),L&&e.push(St.from(L)),e}static centerPoint(t){const e=t.baseProps;return new m(e.x+.5*e.width,e.y+.5*e.height)}static topPoint(t){const e=t.baseProps;return new m(e.x+.5*e.width,e.y)}static rightPoint(t){const e=t.baseProps;return new m(e.x+e.width,e.y+.5*e.height)}static bottomPoint(t){const e=t.baseProps;return new m(e.x+.5*e.width,e.y+e.height)}static leftPoint(t){const e=t.baseProps;return new m(e.x,e.y+.5*e.height)}static topLeft(t){const e=t.baseProps;return new m(e.x,e.y)}static topRight(t){const e=t.baseProps;return new m(e.x+e.width,e.x+e.width)}static bottomLeft(t){const e=t.baseProps;return new m(e.x,e.y+e.height)}static bottomRight(t){const e=t.baseProps;return new m(e.x+e.width,e.y+e.height)}static middleInsertPoint(t,e,n){const o=new m(t.x,e.y);n.push(t,o,e)}static doubleMiddleInsertPoint(t,e,n){const o=new m(.5*(t.x+e.x),t.y),s=new m(.5*(t.x+e.x),e.y);n.push(t,o,s,e)}static rectContains(t,e){return t.x>e.x&&t.x<e.x+e.width&&t.y>e.y&&t.y<e.y+e.height}static rectContains2(t,e){return t.x>=e.minX&&t.x<=e.maxX&&t.y>=e.minY&&t.y<=e.maxY}static circleContains(t,e,n=2){return(t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y)<n*n}static overlapRect(t,e){return!(t.maxX<e.minX||t.minX>e.maxX||t.maxY<e.minY||t.minY>e.maxY)}static containRect(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&t.maxX>=e.maxX&&t.maxY>=e.maxY}static distance(t,e){return Math.sqrt((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y))}static lineAngle(t,e){if(Math.abs(t.x-e.x)<.001)return e.y>t.y?Math.PI*.5:-Math.PI*.5;const n=(e.y-t.y)/(e.x-t.x);let o=Math.atan(n);return e.x<t.x&&(o+=Math.PI),o}static basicGetArrowPoint(t,e,n,o){const s=S.lineAngle(t,e),r=re.generateMatrix().translate(t.x,t.y).rotate2(s),i=r.crossPoint(n),a=r.crossPoint(o);return{a:i,b:a}}static getLArrowPoint(t,e,n=5){const o=new m(Math.sqrt(3)*.5*n,.5*n),s=new m(Math.sqrt(3)*.5*n,-.5*n);return S.basicGetArrowPoint(t,e,o,s)}static getRArrowPoint(t,e,n=5){const o=S.distance(t,e),s=new m(o-Math.sqrt(3)*.5*n,.5*n),r=new m(o-Math.sqrt(3)*.5*n,-.5*n);return S.basicGetArrowPoint(t,e,s,r)}static getNodeBounds(t){const e=[];t.forEach(o=>e.push(o.getBounds()));const n=this.getBounds(e);return D.rectNode2Rect(n)}static cloneIRectNode(t){return{minX:t.minX,maxX:t.maxX,minY:t.minY,maxY:t.maxY}}static cloneIPoint(t){return{x:t.x,y:t.y}}static getBoundsByBaseProps(t){const{x:e,y:n,width:o,height:s,angle:r}=t,i=re.generateMatrix().rotate(r),a=re.generateMatrix().translate(e,n),c=[new m(0,0),new m(0,s),new m(o,0),new m(o,s)],h=a.crossProduct(i),d=c.map(u=>h.crossPoint(u));return this.getBoundsByPoints(d)}static getBoundsByBasePropsList(t){const e=[];for(const n of t){const{x:o,y:s,width:r,height:i}=n,a=n.angle??0,c=re.generateMatrix().rotate(a),d=re.generateMatrix().translate(o,s).crossProduct(c),f=[new m(0,0),new m(0,i),new m(r,0),new m(r,i)].map(g=>d.crossPoint(g));e.push(...f)}return this.getBoundsByPoints(e)}static getBounds(t,e="getBounds"){const n=[],o=[];for(const s of t)n.push(s.maxX,s.minX),o.push(s.maxY,s.minY);return{id:e,minX:Math.min(...n),maxX:Math.max(...n),minY:Math.min(...o),maxY:Math.max(...o)}}static getBoundsByPoints(t){const e=[],n=[];for(const o of t)e.push(o.x),n.push(o.y);return{id:"getBounds",minX:Math.min(...e),maxX:Math.max(...e),minY:Math.min(...n),maxY:Math.max(...n)}}static calcFont(t,e,n=!1,o=!1){let s=`${t.toString()}px ${e}`;return n?s=`700 ${s}`:s=`400 ${s}`,o&&(s=`italic ${s}`),s}static calcFontByTextProps(t){const{fontSize:e,fontFamily:n,bold:o,italic:s}=t;return this.calcFont(e,n,o,s)}static measureText(t,e){const n=t.measureText(e),o=n.width,s=n.fontBoundingBoxDescent+n.fontBoundingBoxAscent,r=n.fontBoundingBoxAscent;return{width:o,height:s,boxAscent:r}}static measureTextByFont(t,e,n,o,s,r){t.save(),t.font=this.calcFont(n,o,s,r);const i=t.measureText(e);t.restore();const a=i.width,c=i.fontBoundingBoxDescent+i.fontBoundingBoxAscent,h=i.fontBoundingBoxAscent;return{width:a,height:c,boxAscent:h}}static judgeHorizon(t,e,n=.01){return Math.abs(t.y-e.y)<n}static judgeVertical(t,e,n=.01){return Math.abs(t.x-e.x)<n}static computePolyLinePoints(t,e){const n=[],o=new m(e.x-t.x,e.y-t.y);if(Math.abs(o.x)<.001||Math.abs(o.y)<.001)n.push(t,e);else if(Math.abs(o.x)>Math.abs(o.y)){const s=new m(t.x+.5*o.x,t.y),r=new m(e.x-.5*o.x,e.y);n.push(t,s,r,e)}else{const s=new m(t.x,t.y+.5*o.y),r=new m(e.x,e.y-.5*o.y);n.push(t,s,r,e)}return n}static normalizeAngle(t){let e=t%360;return e<0&&(e+=360),e}static computeOriginNodeConnectEnd(t){const{x:e,y:n}=t,o=Math.atan2(n-.5,e-.5)/Math.PI*180,s=this.normalizeAngle(o);if(s<45||s>315)return de.Right;if(Math.abs(s-90)<45)return de.Bottom;if(Math.abs(s-180)<45)return de.Left;if(Math.abs(s-270)<45)return de.Top;throw new Error("没有正确的end type")}static computeNodeConnectEnd(t,e){const{x:n,y:o}=t,s=Math.atan2(o-.5,n-.5)/Math.PI*180+e,r=this.normalizeAngle(s);if(r<45||r>315)return de.Right;if(Math.abs(r-90)<45)return de.Bottom;if(Math.abs(r-180)<45)return de.Left;if(Math.abs(r-270)<45)return de.Top;throw new Error("没有正确的end type")}static inDistance(t,e,n){return Math.abs(t-e-.5*n)<.5*n}static dealWithEndPolyPointsInUp(t,e,n){if(t.length<4)return t;const o=t.length;if(n){const a=t[o-1],c=t[o-2],h=t[o-3];return S.distance(c,h)<3/e&&(S.judgeHorizon(a,c)?a.y=h.y:a.x=h.x,t.splice(o-3,2)),t}const s=t[0],r=t[1],i=t[2];return S.distance(i,r)<3/e&&(S.judgeHorizon(s,r)?s.y=i.y:s.x=i.x,t.splice(1,2)),t}static dealWithEndPolyPoints(t,e,n){if(t.length<4)return t;const o=t.length;if(n){const a=t[o-1],c=t[o-2],h=t[o-3];return S.distance(c,h)<3/e&&(S.judgeHorizon(a,c)?(c.y=h.y,a.y=h.y):(c.x=h.x,a.x=h.x)),t}const s=t[0],r=t[1],i=t[2];return S.distance(i,r)<3/e&&(S.judgeHorizon(s,r)?(r.y=i.y,s.y=i.y):(r.x=i.x,s.x=i.x)),t}static dealWithPolyPoints(t,e){if(t.length===0)return[];const n=[t[0]];for(let o=1;o<t.length-1;o++){const s=t[o],r=t[o+1];if(S.distance(s,r)<3/e){const i=t[o+2],a=t[o-1];S.judgeHorizon(a,s)?a.y=i.y:a.x=i.x,o=o+1}else n.push(s)}return n.push(t[t.length-1]),n}static computePointByT(t,e){const n=t.points;if(t.isPolyLine()){let a=0;for(let h=0;h<n.length-1;h++){const d=n[h],u=n[h+1],f=S.distance(d,u);a+=f}const c=e*a;a=0;for(let h=0;h<n.length-1;h++){const d=n[h],u=n[h+1],f=S.distance(d,u);if(c>a&&c<=a+f)if(S.judgeHorizon(d,u)){const y=u.x>d.x?1:-1;return new m(d.x+(c-a)*y,d.y)}else{const y=u.y>d.y?1:-1;return new m(d.x,d.y+(c-a)*y)}a+=f}}else if(t.shapeType===he.Curve){const a=S.computeBezierCurves(t);let c=0;const h=[];for(const u of a){const f=u.getApproximateLength();c+=f,h.push(f)}c=e*c;for(let u=0;u<a.length;u++){const f=a[u],g=h[u];if(c>g){c-=g;continue}const y=f.getTValueByDistance(c);return f.getPos(y)}}const o=n[0],s=n[n.length-1],r=o.x+(s.x-o.x)*e,i=o.y+(s.y-o.y)*e;return new m(r,i)}static computeNodeConnectAnchor(t,e){const{width:n,height:o}=t.baseProps,s=Fr/e;return[{x:.5*n,y:-s},{x:n+s,y:.5*o},{x:.5*n,y:o+s},{x:-s,y:.5*o}]}static computeSelectNode(t,e){const n=new Set(t.getSelectNodes());let o=e.parent;for(;o;)n.has(o)&&n.delete(o),o=o.parent;return this.filterChildInSet(n,e),n.add(e),n}static filterChildInSet(t,e){const n=e.children;if(n.size!==0)for(const o of n)t.has(o)&&t.delete(o),this.filterChildInSet(t,o)}static computeSelectNodes(t){const e=new Set(t);for(const n of t)this.filterChildInSet(e,n);return[...e]}static filterToGroupNodes(t){const e=[];for(const n of t)if(n.type!==v.Section){if(n.type===v.Line){const o=n,{start:s,end:r}=o.connectProps;if(s&&r){const i=t.find(c=>c.id===s.objectId),a=t.find(c=>c.id===r.objectId);i&&a&&e.push(n);continue}if(s&&!r){t.find(a=>a.id===s.objectId)&&e.push(n);continue}if(r&&!s){t.find(a=>a.id===r.objectId)&&e.push(n);continue}e.push(n);continue}e.push(n)}return e}static detectRectBounds(t,e,n){const{x:o,y:s,width:r,height:i}=t;return S.circleContains(new m(o,s),e,n)?{type:V.TOP_LEFT}:S.circleContains(new m(o+r,s),e,n)?{type:V.TOP_RIGHT}:S.circleContains(new m(o+r,s+i),e,n)?{type:V.BOTTOM_RIGHT}:S.circleContains(new m(o,s+i),e,n)?{type:V.BOTTOM_LEFT}:S.rectContains(e,new D(o,s-.5*n,r,n))?{type:V.TOP}:S.rectContains(e,new D(o+r-.5*n,s,n,i))?{type:V.RIGHT}:S.rectContains(e,new D(o,s+i-.5*n,r,n))?{type:V.BOTTOM}:S.rectContains(e,new D(o-.5*n,s,n,i))?{type:V.LEFT}:null}static computeShiftPoint(t,e){if(S.distance(t,e)<.1)return new m(e.x,t.y);let n=Math.atan2(e.y-t.y,e.x-t.x)*180/Math.PI;return n=(n+360)%360,n<45||n>=315?new m(e.x,t.y):n>45&&n<=135?new m(t.x,e.y):n>135&&n<225?new m(e.x,t.y):new m(t.x,e.y)}static dealWithShiftLineInteractEvent(t,e,n=!0){if(!t.originEvent.shiftKey)return t;const o=e.globalLinePoints,s=n?o[0]:o[o.length-1],r=S.computeShiftPoint(s,t.globalPoint);return{clientPoint:t.clientPoint,globalPoint:r,type:t.type,originEvent:t.originEvent}}static getMockEventModifierInit(t){return{shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey,ctrlKey:t.ctrlKey}}static judgeParentInset(t,e){let n=t;for(;n;){if(e.has(n))return!0;n=n.parent}return!1}static judgeSlideSectionChildren(t,e){let n=t;for(;n!=null&&n.parent;){if(n.parent.id===e.id)return n;n=n.parent}return null}static filterContainerFromNodes(t){const e=t.filter(o=>o.type===v.Section);return new Set(e)}static judgeEndNode(t,e,n,o,s){if(!n)return;const r=o.nodeManager.getNode(n.objectId);r&&!S.judgeParentInset(r,s)&&e.add(t)}static getViewportBoundCenter(t){const e=t.renderManager.gmlRender.getViewPortBounds();return new m(.5*(e.minX+e.maxX),.5*(e.minY+e.maxY))}static computeRotateAngle(t,e){let n=0;return t.length===1&&(n=n+t[0].baseProps.angle),n=n+e,Math.round(n)}static computeRotateDeltaAngle(t){let e=0;switch(t){case Zt.BOTTOM_LEFT:e=90;break;case Zt.BOTTOM_RIGHT:e=0;break;case Zt.TOP_LEFT:e=180;break;case Zt.TOP_RIGHT:e=-90;break}return e}static computeRelationChangeUpdateNodeInfo(t,e,n,o){if(t.type===v.Line){const i=t.globalLinePoints.map(c=>e.toLocal(c)),a=D.rectNode2Rect(S.getBoundsByPoints(i));return{id:t.id,props:[{type:I.Line,points:i},ie.create({x:a.x,y:a.y,width:a.width,height:a.height})],zIndex:n,parentId:o}}const s=e.toLocal(t.globalPos);return{id:t.id,zIndex:n,parentId:o,props:[{type:I.Base,x:s.x,y:s.y}]}}static computeStretchAngle(t,e){let n=0;return t.length===1&&(n=n+t[0].baseProps.angle),e===V.TOP_RIGHT||e===V.BOTTOM_LEFT?n=n-45:e===V.TOP_LEFT||e===V.BOTTOM_RIGHT?n=n+45:(e===V.TOP||e===V.BOTTOM)&&(n=n+90),Math.round(n)}static correctZIndex(t){if(t.length===0)return t;const e=new Map;if(t.forEach((s,r)=>{const i=s.zIndex;e.has(i)||e.set(i,[]),e.get(i).push(r)}),!Array.from(e.values()).some(s=>s.length>1))return t;const o=t.map(s=>({...s}));return e.forEach((s,r)=>{if(s.length>1){const i=s[0];let a=.1,c=0;i===0?(c=r-1,a=(r-c)/(s.length+1)):(c=o[i-1].zIndex<r?o[i-1].zIndex:r-1,a=(r-c)/(s.length+1)),s.forEach((h,d)=>{o[h].zIndex=(d+1)*a+c})}}),o}static judgeLineBreak(t,e,n,o){let s=-1;for(const r of t){const i=e.characters.slice(0,r);let a=0;if(i.forEach(c=>{a+=c.width}),n.width+a<o)s=r;else return s>0?s:-1}return s>-1?s:-1}static getParaStyle(t,e){const n=t.paragraphStyles;for(const o of n)if(o.paraIndex===e)return o;return null}static computeNotUnOrderParas(t){const n=t.paragraphProps.paragraphStyles,o=new Set;for(let s=0;s<t.paragraphs.length;s++)o.add(s);for(const s of n)s.orderIndex===-1&&o.delete(s.paraIndex);return o}static computeNotOrderParas(t){const n=t.paragraphProps.paragraphStyles,o=new Set;for(let s=0;s<t.paragraphs.length;s++)o.add(s);for(const s of n)s.orderIndex>-1&&o.delete(s.paraIndex);return o}static computeNotNormalParas(t){const n=t.paragraphProps.paragraphStyles,o=new Set;for(const s of n)o.add(s.paraIndex);return o}static computeNotQuoteParas(t){const n=t.paragraphQuoteProps.paraQuoteStyles,o=new Set;for(let s=0;s<t.paragraphs.length;s++)o.add(s);for(const s of n)s.quote&&o.delete(s.paraIndex);return o}static drawControlPoints(t,e){t.save(),t.beginPath(),t.strokeStyle="#cc2626",t.lineWidth=1;const n=e.globalLinePoints;t.moveTo(n[0].x,n[0].y);for(let o=1;o<n.length;o++){const s=n[o];t.lineTo(s.x,s.y)}t.stroke(),t.fillStyle="#000000";for(let o=1;o<n.length-2;o=o+3){const s=n[o],r=n[o+1];t.beginPath(),t.arc(s.x,s.y,5,0,2*Math.PI),t.fill(),t.stroke(),t.beginPath(),t.arc(r.x,r.y,5,0,2*Math.PI),t.fill(),t.stroke()}t.restore()}static computeBezierCurves(t){if(t.shapeType!==he.Curve)return[];const e=t.points,n=[];for(let o=1;o<e.length-2;o=o+3){const s=e[o-1],r=e[o],i=e[o+1],a=e[o+2],c=new di(s,r,i,a);n.push(c)}return n}static computeBezierCurvesByPoints(t){const e=[];for(let n=1;n<t.length-2;n=n+3){const o=t[n-1],s=t[n],r=t[n+1],i=t[n+2],a=new di(o,s,r,i);e.push(a)}return e}static computeCurveControlPoints(t){const e=this.computeBezierCurves(t),n=[];for(const o of e)n.push(o.getHalfTPos());return n}static computeCurveEndPoints(t){if(t.shapeType!==he.Curve)return[];const e=t.points,n=[];for(let o=1;o<e.length-2;o=o+3){const s=e[o-1],r=e[o+2];n.push(s),n.push(r)}return n}static pressMeta(t){return ui.getOS()===Jt.MacOS?t.originEvent.metaKey:t.originEvent.ctrlKey}static getAllChildren(t,e){const n=t.children;for(const o of n)e.add(o),this.getAllChildren(o,e)}static judgeNodeCanBeStretch(t){var e;return!(t.type===v.SlideContainer||t.type===v.Section&&((e=t.parent)==null?void 0:e.type)===v.SlideContainer)}static getSlideContainerChildNode(t,e,n){const o=t.getChildIdByIndex(e);if(!o)return null;const s=n.nodeManager.getNode(o);return s||null}static filterSlideContainerNodes(t,e){const n=t.docState.docMode,o=t.docState.slideStatus,s=o.slideContainer;if(n===ue.SLIDE_EDIT&&s){const r=this.getSlideContainerChildNode(s,o.currentIndex,t);if(!r)return e;const i=new Set;S.getAllChildren(r,i);const a=[];for(const c of e)i.has(c)&&a.push(c);return a}return e}static getSlideInfo(t,{renderManager:e,nodeManager:n}){return new Promise((o,s)=>{const r=t.getBounds(),i=r.maxX-r.minX,a=r.maxY-r.minY,c=new Set([t]);S.getAllChildren(t,c),e.exportWorker.exportToOfflineCanvasByFilterNodes(r,n,1,"",c).toBlob(d=>{if(d){const u=URL.createObjectURL(d),f={id:t.id,blobUrl:u,width:i,height:a};o(f)}else console.error("导出图片错误"),s("导出图片错误")})})}}class en{constructor(t,e){p(this,"type",v.Shape);p(this,"id");p(this,"parent",null);p(this,"children",new Set);p(this,"zIndex",0);p(this,"graphicContext");p(this,"props",new Map);p(this,"transform",re.generateMatrix());this.id=t,this.graphicContext=e}get baseProps(){return this.props.get(I.Base)}get globalBaseProps(){const t=this.baseProps.clone(),e=this.globalPos;return t.x=e.x,t.y=e.y,t}get pos(){const t=this.baseProps;return new m(t.x,t.y)}get globalPos(){return this.globalTransform().crossPoint(new m)}setParent(t){this.parent=t,t.children.add(this)}updateProps(t){for(const e of t){if(e.type===void 0)continue;const n=this.props.get(e.type);n&&n.update(e)}}getProp(t){const e=this.props.get(t);return e||null}updateTransformMatrix(){const t=this.baseProps,e=re.generateMatrix().rotate(t.angle),n=re.generateMatrix().translate(t.x,t.y);this.transform=n.crossProduct(e)}contains(t,e=1){const{width:n,height:o}=this.baseProps,s=this.toLocal(t);return S.rectContains(s,new D(0,0,n,o))}canQuickCreate(){return!!this.canBeConnected()}canBeConnected(){return!0}getConnectAnchor(){return[]}borderContains(t,e){return null}draw(){return this.drawOnGLCtx(this.graphicContext)}globalTransform(){const t=[this];let e=this.parent;for(;e;)t.push(e),e=e.parent;let n=re.generateMatrix();for(const o of t.reverse())n=n.crossProduct(o.transform);return n}getRectNode(){const{width:t,height:e}=this.baseProps,n=this.getProp(I.Border),o=n?n.width:0,s=[new m(-o,-o),new m(t+o,-o),new m(t+o,e+o),new m(-o,e+o)],r=[];for(const a of s)r.push(this.toGlobal(a));const i=S.getBoundsByPoints(r);return i.id=this.id,i}getBounds(){const t=this.baseProps,e={id:this.id,minX:0,minY:0,maxX:t.width,maxY:t.height},n=[new m(e.minX,e.minY),new m(e.maxX,e.minY),new m(e.maxX,e.maxY),new m(e.minX,e.maxY)],o=[];for(const r of n)o.push(this.toGlobal(r));const s=S.getBoundsByPoints(o);return s.id=this.id,s}getStretchMinSize(){return{x:10,y:10}}overlapRect(t){return S.overlapRect(t,this.getBounds())}isEmptyText(){return!0}toLocal(t){return this.globalTransform().inverseMatrix().crossPoint(t)}toGlobal(t){return this.globalTransform().crossPoint(t)}modifyPosInEditing(t){return!1}resetFromEditing(){}serializeTo(){const t=S.convertPropsToCapInfo(this.props),e=JSON.parse(JSON.stringify(t));return{type:this.type,zIndex:this.zIndex,id:this.id,parentId:"",capInfo:e,children:[]}}}class Nh{fallbackDraw(t,e){const{width:n,height:o}=t.baseProps;e.save();const{a:s,b:r,c:i,d:a,e:c,f:h}=t.globalTransform();e.transform(s,r,i,a,c,h),e.beginPath();let d=!1;const u=n/3,f=o/3;for(let g=0;g<3;g++)for(let y=0;y<3;y++){const P=d?Ht:bs,b=u*g,w=f*y;e.fillStyle=P,e.fillRect(b,w,u,f),d=!d}e.restore()}}class ge{constructor(t=0,e=0){this.x=t,this.y=e}clone(){return new this.constructor(this.x,this.y)}add(t){return new this.constructor(this.x+t.x,this.y+t.y)}subtract(t){return new this.constructor(this.x-t.x,this.y-t.y)}multiply(t){return new this.constructor(this.x*t,this.y*t)}divide(t){return new this.constructor(this.x/t,this.y/t)}equals(t){return this.x===t.x&&this.y===t.y}precisionEquals(t,e){return Math.abs(this.x-t.x)<e&&Math.abs(this.y-t.y)<e}lerp(t,e){const n=1-e;return new this.constructor(this.x*n+t.x*e,this.y*n+t.y*e)}distanceFrom(t){const e=this.x-t.x,n=this.y-t.y;return Math.sqrt(e*e+n*n)}min(t){return new this.constructor(Math.min(this.x,t.x),Math.min(this.y,t.y))}max(t){return new this.constructor(Math.max(this.x,t.x),Math.max(this.y,t.y))}transform(t){return new this.constructor(t.a*this.x+t.c*this.y+t.e,t.b*this.x+t.d*this.y+t.f)}toString(){return`point(${this.x},${this.y})`}}class rt{constructor(t=0,e=0){this.x=t,this.y=e}static fromPoints(t,e){return new rt(e.x-t.x,e.y-t.y)}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}magnitude(){return this.x*this.x+this.y*this.y}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}determinant(t){return this.x*t.y-this.y*t.x}unit(){return this.divide(this.length())}add(t){return new this.constructor(this.x+t.x,this.y+t.y)}subtract(t){return new this.constructor(this.x-t.x,this.y-t.y)}multiply(t){return new this.constructor(this.x*t,this.y*t)}divide(t){return new this.constructor(this.x/t,this.y/t)}angleBetween(t){let e=this.dot(t)/(this.length()*t.length());e=Math.max(-1,Math.min(e,1));const n=Math.acos(e);return this.cross(t)<0?-n:n}perp(){return new this.constructor(-this.y,this.x)}perpendicular(t){return this.subtract(this.project(t))}project(t){const e=this.dot(t)/t.dot(t);return t.multiply(e)}transform(t){return new this.constructor(t.a*this.x+t.c*this.y,t.b*this.x+t.d*this.y)}equals(t){return this.x===t.x&&this.y===t.y}precisionEquals(t,e){return Math.abs(this.x-t.x)<e&&Math.abs(this.y-t.y)<e}toString(){return`vector(${this.x},${this.y})`}}class pt{constructor(t=1,e=0,n=0,o=1,s=0,r=0){this.a=t,this.b=e,this.c=n,this.d=o,this.e=s,this.f=r}static translation(t,e){return new pt(1,0,0,1,t,e)}static scaling(t){return new pt(t,0,0,t,0,0)}static scalingAt(t,e){return new pt(t,0,0,t,e.x-e.x*t,e.y-e.y*t)}static nonUniformScaling(t,e){return new pt(t,0,0,e,0,0)}static nonUniformScalingAt(t,e,n){return new pt(t,0,0,e,n.x-n.x*t,n.y-n.y*e)}static rotation(t){const e=Math.cos(t),n=Math.sin(t);return new pt(e,n,-n,e,0,0)}static rotationAt(t,e){const n=Math.cos(t),o=Math.sin(t);return new pt(n,o,-o,n,e.x-e.x*n+e.y*o,e.y-e.y*n-e.x*o)}static rotationFromVector(t){const e=t.unit(),n=e.x,o=e.y;return new pt(n,o,-o,n,0,0)}static xFlip(){return new pt(-1,0,0,1,0,0)}static yFlip(){return new pt(1,0,0,-1,0,0)}static xSkew(t){const e=Math.tan(t);return new pt(1,0,e,1,0,0)}static ySkew(t){const e=Math.tan(t);return new pt(1,e,0,1,0,0)}multiply(t){return this.isIdentity()?t:t.isIdentity()?this:new this.constructor(this.a*t.a+this.c*t.b,this.b*t.a+this.d*t.b,this.a*t.c+this.c*t.d,this.b*t.c+this.d*t.d,this.a*t.e+this.c*t.f+this.e,this.b*t.e+this.d*t.f+this.f)}inverse(){if(this.isIdentity())return this;const t=this.a*this.d-this.b*this.c;if(t===0)throw new Error("Matrix is not invertible");const e=1/t,n=this.f*this.c-this.e*this.d,o=this.e*this.b-this.f*this.a;return new this.constructor(this.d*e,-this.b*e,-this.c*e,this.a*e,n*e,o*e)}translate(t,e){return new this.constructor(this.a,this.b,this.c,this.d,this.a*t+this.c*e+this.e,this.b*t+this.d*e+this.f)}scale(t){return new this.constructor(this.a*t,this.b*t,this.c*t,this.d*t,this.e,this.f)}scaleAt(t,e){const n=e.x-t*e.x,o=e.y-t*e.y;return new this.constructor(this.a*t,this.b*t,this.c*t,this.d*t,this.a*n+this.c*o+this.e,this.b*n+this.d*o+this.f)}scaleNonUniform(t,e){return new this.constructor(this.a*t,this.b*t,this.c*e,this.d*e,this.e,this.f)}scaleNonUniformAt(t,e,n){const o=n.x-t*n.x,s=n.y-e*n.y;return new this.constructor(this.a*t,this.b*t,this.c*e,this.d*e,this.a*o+this.c*s+this.e,this.b*o+this.d*s+this.f)}rotate(t){const e=Math.cos(t),n=Math.sin(t);return new this.constructor(this.a*e+this.c*n,this.b*e+this.d*n,this.a*-n+this.c*e,this.b*-n+this.d*e,this.e,this.f)}rotateAt(t,e){const n=Math.cos(t),o=Math.sin(t),s=e.x,r=e.y,i=this.a*n+this.c*o,a=this.b*n+this.d*o,c=this.c*n-this.a*o,h=this.d*n-this.b*o;return new this.constructor(i,a,c,h,(this.a-i)*s+(this.c-c)*r+this.e,(this.b-a)*s+(this.d-h)*r+this.f)}rotateFromVector(t){const e=t.unit(),n=e.x,o=e.y;return new this.constructor(this.a*n+this.c*o,this.b*n+this.d*o,this.a*-o+this.c*n,this.b*-o+this.d*n,this.e,this.f)}flipX(){return new this.constructor(-this.a,-this.b,this.c,this.d,this.e,this.f)}flipY(){return new this.constructor(this.a,this.b,-this.c,-this.d,this.e,this.f)}skewX(t){const e=Math.tan(t);return new this.constructor(this.a,this.b,this.c+this.a*e,this.d+this.b*e,this.e,this.f)}skewY(t){const e=Math.tan(t);return new this.constructor(this.a+this.c*e,this.b+this.d*e,this.c,this.d,this.e,this.f)}isIdentity(){return this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.e===0&&this.f===0}isInvertible(){return this.a*this.d-this.b*this.c!==0}getScale(){return{scaleX:Math.sqrt(this.a*this.a+this.c*this.c),scaleY:Math.sqrt(this.b*this.b+this.d*this.d)}}getDecomposition(){const t=(this.a+this.d)*.5,e=(this.a-this.d)*.5,n=(this.b+this.c)*.5,o=(this.b-this.c)*.5,s=Math.sqrt(t*t+o*o),r=Math.sqrt(e*e+n*n),i=s+r,a=s-r,c=Math.atan2(n,e),h=Math.atan2(o,t),d=(h-c)*.5,u=(h+c)*.5;return{translation:this.constructor.translation(this.e,this.f),rotation:this.constructor.rotation(u),scale:this.constructor.nonUniformScaling(i,a),rotation0:this.constructor.rotation(d)}}equals(t){return this.a===t.a&&this.b===t.b&&this.c===t.c&&this.d===t.d&&this.e===t.e&&this.f===t.f}precisionEquals(t,e){return Math.abs(this.a-t.a)<e&&Math.abs(this.b-t.b)<e&&Math.abs(this.c-t.c)<e&&Math.abs(this.d-t.d)<e&&Math.abs(this.e-t.e)<e&&Math.abs(this.f-t.f)<e}toString(){return`matrix(${this.a},${this.b},${this.c},${this.d},${this.e},${this.f})`}}pt.IDENTITY=new pt,pt.IDENTITY.isIdentity=()=>!0;function Mt(l){return typeof l=="number"?l?l<0?-1:1:l===l?l:NaN:NaN}class Ue{constructor(...t){this.coefs=[];for(let e=t.length-1;e>=0;e--)this.coefs.push(t[e]);this._variable="t",this._s=0}static interpolate(t,e,n,o,s){if(t.constructor!==Array||e.constructor!==Array)throw new TypeError("xs and ys must be arrays");if(isNaN(n)||isNaN(o)||isNaN(s))throw new TypeError("n, offset, and x must be numbers");let r,i,a=0;const c=new Array(n),h=new Array(n);let d=0,u=Math.abs(s-t[o]);for(r=0;r<n;r++){const f=Math.abs(s-t[o+r]);f<u&&(d=r,u=f),c[r]=h[r]=e[o+r]}i=e[o+d],d--;for(let f=1;f<n;f++){for(r=0;r<n-f;r++){const g=t[o+r]-s,y=t[o+r+f]-s,P=c[r+1]-h[r];let b=g-y;if(b===0)throw new RangeError("Unable to interpolate polynomial. Two numbers in n were identical (to within roundoff)");b=P/b,h[r]=y*b,c[r]=g*b}a=2*(d+1)<n-f?c[d+1]:h[d--],i+=a}return{y:i,dy:a}}static newtonSecantBisection(t,e,n,o,s,r){let i,a=0,c,h=0,d,u,f,g,y;i=t;const P=Math.pow(10,-14),b=typeof s=="number"&&typeof r=="number";if(b){if(s>r)throw new RangeError("Min must be greater than max");if(g=e(s),y=e(r),Mt(g)===Mt(y))throw new RangeError("Y values of bounds must be of opposite sign")}const w=function(){return Math.abs(d)<=P*Math.abs(i)||h===i-d-i};for(let L=0;L<o;L++){if(c=n(i),c===0){if(a===0)throw new RangeError("df(x) is zero");c=a}if(a=c,f=e(i),d=f/c,u=i-d,w())break;if(b){if(Mt(f)===Mt(y))r=i,y=f;else if(Mt(f)===Mt(g))s=i,g=f;else{i=u;break}if(u<s||u>r){if(Mt(g)===Mt(y))break;const B=50,H=.25,E=y-g,X=r-s;if(E===0?d=i-(s+X*.5):Math.abs(E/Math.min(g,y))>B?d=i-(s+X*(.5+(Math.abs(g)<Math.abs(y)?-H:H))):d=i-(s-g/E*X),u=i-d,w())break}}h=i-u,i=u}return i}clone(){const t=new Ue;return t.coefs=this.coefs.slice(),t}eval(t){if(isNaN(t))throw new TypeError(`Parameter must be a number. Found '${t}'`);let e=0;for(let n=this.coefs.length-1;n>=0;n--)e=e*t+this.coefs[n];return e}add(t){const e=new Ue,n=this.getDegree(),o=t.getDegree(),s=Math.max(n,o);for(let r=0;r<=s;r++){const i=r<=n?this.coefs[r]:0,a=r<=o?t.coefs[r]:0;e.coefs[r]=i+a}return e}multiply(t){const e=new Ue;for(let n=0;n<=this.getDegree()+t.getDegree();n++)e.coefs.push(0);for(let n=0;n<=this.getDegree();n++)for(let o=0;o<=t.getDegree();o++)e.coefs[n+o]+=this.coefs[n]*t.coefs[o];return e}divideEqualsScalar(t){for(let e=0;e<this.coefs.length;e++)this.coefs[e]/=t}simplifyEquals(t=1e-12){for(let e=this.getDegree();e>=0&&Math.abs(this.coefs[e])<=t;e--)this.coefs.pop()}removeZerosEquals(t=1e-15){const e=this.coefs,n=10*t*Math.abs(e.reduce((o,s)=>Math.abs(s)>Math.abs(o)?s:o));for(let o=0;o<e.length-1;o++)Math.abs(e[o])<n&&(e[o]=0);return this}monicEquals(){const t=this.coefs;return t[t.length-1]!==1&&this.divideEqualsScalar(t[t.length-1]),this}toString(){const t=[],e=[];for(let o=this.coefs.length-1;o>=0;o--){let s=Math.round(this.coefs[o]*1e3)/1e3;if(s!==0){const r=s<0?" - ":" + ";s=Math.abs(s),o>0&&(s===1?s=this._variable:s+=this._variable),o>1&&(s+="^"+o),e.push(r),t.push(s)}}e[0]=e[0]===" + "?"":"-";let n="";for(let o=0;o<t.length;o++)n+=e[o]+t[o];return n}bisection(t,e,n=1e-6,o=15){let s=this.eval(t),r=this.eval(e),i;if(Math.abs(s)<=n)i=t;else if(Math.abs(r)<=n)i=e;else if(s*r<=0){const a=Math.log(e-t),c=Math.LN10*o,h=Math.ceil((a+c)/Math.LN2);for(let d=0;d<h;d++){i=.5*(t+e);const u=this.eval(i);if(Math.abs(u)<=n)break;u*s<0?(e=i,r=u):(t=i,s=u)}}return i}trapezoid(t,e,n){if(isNaN(t)||isNaN(e)||isNaN(n))throw new TypeError("Parameters must be numbers");const o=e-t;if(n===1){const s=this.eval(t),r=this.eval(e);this._s=.5*o*(s+r)}else{const s=1<<n-2,r=o/s;let i=t+.5*r,a=0;for(let c=0;c<s;c++)a+=this.eval(i),i+=r;this._s=.5*(this._s+o*a/s)}if(isNaN(this._s))throw new TypeError("this._s is NaN");return this._s}simpson(t,e){if(isNaN(t)||isNaN(e))throw new TypeError("Parameters must be numbers");const n=e-t;let o=.5*n*(this.eval(t)+this.eval(e)),s=o,r=4*o/3,i=r,a=o;const c=1e-7;let h=1;for(let d=2;d<=20;d++){const u=n/h;let f=t+.5*u,g=0;for(let y=1;y<=h;y++)g+=this.eval(f),f+=u;if(s=.5*(s+n*g/h),o=s,r=(4*o-a)/3,Math.abs(r-i)<c*Math.abs(i))break;i=r,a=o,h<<=1}return r}romberg(t,e){if(isNaN(t)||isNaN(e))throw new TypeError("Parameters must be numbers");const n=20,o=3,s=1e-6,r=new Array(n+1),i=new Array(n+1);let a={y:0,dy:0};i[0]=1;for(let c=1;c<=n&&(r[c-1]=this.trapezoid(t,e,c),!(c>=o&&(a=Ue.interpolate(i,r,o,c-o,0),Math.abs(a.dy)<=s*a.y)));c++)r[c]=r[c-1],i[c]=.25*i[c-1];return a.y}zeroErrorEstimate(t){const e=this,n=1e-15;if(typeof t>"u"){const r=e.bounds();t=Math.max(Math.abs(r.minX),Math.abs(r.maxX))}if(t<.001)return 2*Math.abs(e.eval(n));const o=e.coefs.length-1,s=e.coefs[o];return 10*n*e.coefs.reduce((r,i,a)=>{const c=i/s*Math.pow(t,a);return c>r?c:r},0)}boundsUpperRealFujiwara(){let t=this.coefs;const e=t.length-1,n=t[e];n!==1&&(t=this.coefs.map(c=>c/n));const o=t.map((c,h)=>h<e?Math.pow(Math.abs(h===0?c/2:c),1/(e-h)):c);let s;const r=function(c,h,d){return s(d)&&(c.max<h?(c.nearmax=c.max,c.max=h):c.nearmax<h&&(c.nearmax=h)),c};s=function(c){return c<e&&t[c]<0};const i=o.reduce(r,{max:0,nearmax:0});return s=function(c){return c<e&&(e%2===c%2?t[c]<0:t[c]>0)},{negX:-2*o.reduce(r,{max:0,nearmax:0}).max,posX:2*i.max}}boundsLowerRealFujiwara(){const t=new Ue;t.coefs=this.coefs.slice().reverse();const e=t.boundsUpperRealFujiwara();return e.negX=1/e.negX,e.posX=1/e.posX,e}bounds(){const t=this.boundsUpperRealFujiwara(),e={minX:t.negX,maxX:t.posX};return t.negX===0&&t.posX===0||(t.negX===0?e.minX=this.boundsLowerRealFujiwara().posX:t.posX===0&&(e.maxX=this.boundsLowerRealFujiwara().negX),e.minX>e.maxX&&(e.minX=e.maxX=0)),e}boundUpperAbsRouche(){const t=this.coefs,e=t.length-1;return 1+t.reduce((o,s,r)=>r!==e?(s=Math.abs(s),o<s?s:o):o,0)/Math.abs(t[e])}boundLowerAbsRouche(){const t=this.coefs,e=t.reduce((n,o,s)=>s!==0?(o=Math.abs(o),n<o?o:n):n,0);return Math.abs(t[0])/(Math.abs(t[0])+e)}boundsRealLaguerre(){const t=this.coefs,e=t.length-1,n=-t[e-1]/(e*t[e]),o=t[e-1]*t[e-1]-2*e/(e-1)*t[e]*t[e-2];let s=(e-1)/(e*t[e])*Math.sqrt(o);return s<0&&(s=-s),{minX:n-s,maxX:n+s}}countRootsDescartes(){const t=this.coefs,e=t.length-1,n=t.reduce((o,s,r)=>(o.prev_a!==0&&s!==0&&(o.prev_a<0==s>0&&o.pos++,r%2===0!=o.prev_a<0==(r%2===1!=s>0)&&o.neg++),o.prev_a=s,o),{pos:0,neg:0,prev_a:0});return{maxRealPos:n.pos,maxRealNeg:n.neg,minComplex:e-(n.pos+n.neg)}}getDegree(){return this.coefs.length-1}getDerivative(){const t=new Ue;for(let e=1;e<this.coefs.length;e++)t.coefs.push(e*this.coefs[e]);return t}getRoots(){let t;switch(this.simplifyEquals(),this.getDegree()){case 0:t=[];break;case 1:t=this.getLinearRoot();break;case 2:t=this.getQuadraticRoots();break;case 3:t=this.getCubicRoots();break;case 4:t=this.getQuarticRoots();break;default:t=[]}return t}getRootsInInterval(t,e){const n=[];function o(s){typeof s=="number"&&n.push(s)}if(this.getDegree()===0)throw new RangeError("Unexpected empty polynomial");if(this.getDegree()===1)o(this.bisection(t,e));else{const r=this.getDerivative().getRootsInInterval(t,e);if(r.length>0){o(this.bisection(t,r[0]));for(let i=0;i<=r.length-2;i++)o(this.bisection(r[i],r[i+1]));o(this.bisection(r[r.length-1],e))}else o(this.bisection(t,e))}return n}getLinearRoot(){const t=[],e=this.coefs[1];return e!==0&&t.push(-this.coefs[0]/e),t}getQuadraticRoots(){const t=[];if(this.getDegree()===2){const e=this.coefs[2],n=this.coefs[1]/e,o=this.coefs[0]/e,s=n*n-4*o;if(s>0){const r=Math.sqrt(s);t.push(.5*(-n+r)),t.push(.5*(-n-r))}else s===0&&t.push(.5*-n)}return t}getCubicRoots(){const t=[];if(this.getDegree()===3){const e=this.coefs[3],n=this.coefs[2]/e,o=this.coefs[1]/e,s=this.coefs[0]/e,r=(3*o-n*n)/3,i=(2*n*n*n-9*o*n+27*s)/27,a=n/3;let c=i*i/4+r*r*r/27;const h=i/2,d=this.zeroErrorEstimate();if(Math.abs(c)<=d&&(c=0),c>0){const u=Math.sqrt(c);let f,g=-h+u;g>=0?f=Math.pow(g,1/3):f=-Math.pow(-g,1/3),g=-h-u,g>=0?f+=Math.pow(g,1/3):f-=Math.pow(-g,1/3),t.push(f-a)}else if(c<0){const u=Math.sqrt(-r/3),f=Math.atan2(Math.sqrt(-c),-h)/3,g=Math.cos(f),y=Math.sin(f),P=Math.sqrt(3);t.push(2*u*g-a),t.push(-u*(g+P*y)-a),t.push(-u*(g-P*y)-a)}else{let u;h>=0?u=-Math.pow(h,1/3):u=Math.pow(-h,1/3),t.push(2*u-a),t.push(-u-a)}}return t}getQuarticRoots(){let t=[];const e=this.getDegree();if(e===4){const n=new Ue;n.coefs=this.coefs.slice(),n.divideEqualsScalar(n.coefs[e]);const o=1e-15;Math.abs(n.coefs[0])<10*o*Math.abs(n.coefs[3])&&(n.coefs[0]=0);const s=n.getDerivative(),r=s.getRoots().sort((w,L)=>w-L),i=[],a=r.length-1,c=this.bounds(),h=Math.max(Math.abs(c.minX),Math.abs(c.maxX)),d=this.zeroErrorEstimate(h);for(let w=0;w<=a;w++)i.push(n.eval(r[w]));for(let w=0;w<=a;w++)Math.abs(i[w])<d&&(i[w]=0);let u=0;const f=Math.max(.1*(c.maxX-c.minX)/e,o),g=[],y=[];if(a>-1){for(i[0]!==0?Mt(i[0])!==Mt(n.eval(r[0]-f)-i[0])&&(g.push(r[0]-f),y.push([c.minX,r[0]])):(t.push(r[0],r[0]),u++);u<a;u++)i[u+1]===0?(t.push(r[u+1],r[u+1]),u++):Mt(i[u])!==Mt(i[u+1])&&(g.push((r[u]+r[u+1])/2),y.push([r[u],r[u+1]]));i[a]!==0&&Mt(i[a])!==Mt(n.eval(r[a]+f)-i[a])&&(g.push(r[a]+f),y.push([r[a],c.maxX]))}const P=function(w){return n.eval(w)},b=function(w){return s.eval(w)};if(g.length>0)for(u=0;u<g.length;u++)g[u]=Ue.newtonSecantBisection(g[u],P,b,32,y[u][0],y[u][1]);t=t.concat(g)}return t}}class ft{constructor(t,e){this.type=t,this.text=e}typeis(t){return this.type===t}}ft.UNDEFINED=0,ft.COMMAND=1,ft.NUMBER=2,ft.EOD=3;class kh{constructor(t){t==null&&(t=""),this.setPathData(t)}setPathData(t){if(typeof t!="string")throw new TypeError("The first parameter must be a string");this._pathData=t}getNextToken(){let t=null,e=this._pathData;for(;t===null;)if(e===null||e==="")t=new ft(ft.EOD,"");else if(e.match(/^([ \t\r\n,]+)/))e=e.substr(RegExp.$1.length);else if(e.match(/^([AaCcHhLlMmQqSsTtVvZz])/))t=new ft(ft.COMMAND,RegExp.$1),e=e.substr(RegExp.$1.length);else if(e.match(/^(([-+]?\d+(\.\d*)?|[-+]?\.\d+)([eE][-+]?\d+)?)/))t=new ft(ft.NUMBER,RegExp.$1),e=e.substr(RegExp.$1.length);else throw new SyntaxError(`Unrecognized path data: ${e}`);return this._pathData=e,t}}const Ts="BOP";class In{constructor(){this._lexer=new kh,this._handler=null}parseData(t){if(typeof t!="string")throw new TypeError(`The first parameter must be a string: ${t}`);this._handler!==null&&typeof this._handler.beginParse=="function"&&this._handler.beginParse();const e=this._lexer;e.setPathData(t);let n=Ts,o=null,s=e.getNextToken();for(;s.typeis(ft.EOD)===!1;){let r;const i=[];switch(s.type){case ft.COMMAND:if(n===Ts&&s.text!=="M"&&s.text!=="m")throw new SyntaxError(`New paths must begin with a moveto command. Found '${s.text}'`);n=s.text,r=In.PARAMCOUNT[s.text.toUpperCase()],s=e.getNextToken();break;case ft.NUMBER:if(n===Ts)throw new SyntaxError(`New paths must begin with a moveto command. Found '${s.text}'`);r=In.PARAMCOUNT[n.toUpperCase()];break;default:throw new SyntaxError(`Unrecognized command type: ${s.type}`)}for(let a=0;a<r;a++){switch(s.type){case ft.COMMAND:throw new SyntaxError(`Parameter must be a number. Found '${s.text}'`);case ft.NUMBER:i[a]=parseFloat(s.text);break;case ft.EOD:throw new SyntaxError("Unexpected end of string");default:throw new SyntaxError(`Unrecognized parameter type. Found type '${s.type}'`)}s=e.getNextToken()}if(this._handler!==null){const a=this._handler,c=In.METHODNAME[n];(n==="a"||n==="A")&&(i[3]=i[3]!==0,i[4]=i[4]!==0),a!==null&&typeof a[c]=="function"&&a[c](...i)}switch(n){case"M":n="L";break;case"m":n="l";break;case"Z":case"z":n="BOP";break}if(s===o)throw new SyntaxError(`Parser stalled on '${s.text}'`);o=s}this._handler!==null&&typeof this._handler.endParse=="function"&&this._handler.endParse()}setHandler(t){this._handler=t}}In.PARAMCOUNT={A:7,C:6,H:1,L:2,M:2,Q:4,S:4,T:2,V:1,Z:0},In.METHODNAME={A:"arcAbs",a:"arcRel",C:"curvetoCubicAbs",c:"curvetoCubicRel",H:"linetoHorizontalAbs",h:"linetoHorizontalRel",L:"linetoAbs",l:"linetoRel",M:"movetoAbs",m:"movetoRel",Q:"curvetoQuadraticAbs",q:"curvetoQuadraticRel",S:"curvetoCubicSmoothAbs",s:"curvetoCubicSmoothRel",T:"curvetoQuadraticSmoothAbs",t:"curvetoQuadraticSmoothRel",V:"linetoVerticalAbs",v:"linetoVerticalRel",Z:"closePath",z:"closePath"};const Bh=2*Math.PI;function pi(l,t,e,n,o,s,r){o=o*Math.PI/180;const i=Math.cos(o),a=Math.sin(o),c=1e-6,h=l.subtract(t).multiply(.5),d=h.x*i+h.y*a,u=h.x*-a+h.y*i;e=Math.abs(e),n=Math.abs(n);const f=d*d,g=u*u,y=f/(e*e)+g/(n*n);if(y>1){const pe=Math.sqrt(y);e*=pe,n*=pe}const P=e*e,b=n*n,w=P*g,L=b*f;let B=(P*b-w-L)/(w+L);Math.abs(B)<c&&(B=0);let H=Math.sqrt(B);s===r&&(H=-H);const E=l.add(t).multiply(.5),X=H*e*u/n,$=H*-n*d/e,Z=(d-X)/e,se=(d+X)/e,ne=(u-$)/n,ae=(u+$)/n,te=new rt(1,0).angleBetween(new rt(Z,ne));let ce=new rt(Z,ne).angleBetween(new rt(-se,-ae));return r===!1&&(ce-=Bh),[X*i-$*a+E.x,X*a+$*i+E.y,e,n,te,te+ce]}class Rh{constructor(t){this.shapeCreator=t,this.shapes=[],this.firstX=null,this.firstY=null,this.lastX=null,this.lastY=null,this.lastCommand=null}beginParse(){this.shapes=[],this.firstX=null,this.firstY=null,this.lastX=null,this.lastY=null,this.lastCommand=null}addShape(t){this.shapes.push(t)}arcAbs(t,e,n,o,s,r,i){if(t===0||e===0)this.addShape(this.shapeCreator.line(this.lastX,this.lastY,r,i));else{const a=pi(new ge(this.lastX,this.lastY),new ge(r,i),t,e,n,o,s);this.addShape(this.shapeCreator.arc(...a))}this.lastCommand="A",this.lastX=r,this.lastY=i}arcRel(t,e,n,o,s,r,i){if(t===0||e===0)this.addShape(this.shapeCreator.line(this.lastX,this.lastY,this.lastX+r,this.lastY+i));else{const a=pi(new ge(this.lastX,this.lastY),new ge(this.lastX+r,this.lastY+i),t,e,n,o,s);this.addShape(this.shapeCreator.arc(...a))}this.lastCommand="a",this.lastX+=r,this.lastY+=i}curvetoCubicAbs(t,e,n,o,s,r){this.addShape(this.shapeCreator.cubicBezier(this.lastX,this.lastY,t,e,n,o,s,r)),this.lastX=s,this.lastY=r,this.lastCommand="C"}curvetoCubicRel(t,e,n,o,s,r){this.addShape(this.shapeCreator.cubicBezier(this.lastX,this.lastY,this.lastX+t,this.lastY+e,this.lastX+n,this.lastY+o,this.lastX+s,this.lastY+r)),this.lastX+=s,this.lastY+=r,this.lastCommand="c"}linetoHorizontalAbs(t){this.addShape(this.shapeCreator.line(this.lastX,this.lastY,t,this.lastY)),this.lastX=t,this.lastCommand="H"}linetoHorizontalRel(t){this.addShape(this.shapeCreator.line(this.lastX,this.lastY,this.lastX+t,this.lastY)),this.lastX+=t,this.lastCommand="h"}linetoAbs(t,e){this.addShape(this.shapeCreator.line(this.lastX,this.lastY,t,e)),this.lastX=t,this.lastY=e,this.lastCommand="L"}linetoRel(t,e){this.addShape(this.shapeCreator.line(this.lastX,this.lastY,this.lastX+t,this.lastY+e)),this.lastX+=t,this.lastY+=e,this.lastCommand="l"}movetoAbs(t,e){this.firstX=t,this.firstY=e,this.lastX=t,this.lastY=e,this.lastCommand="M"}movetoRel(t,e){this.firstX+=t,this.firstY+=e,this.lastX+=t,this.lastY+=e,this.lastCommand="m"}curvetoQuadraticAbs(t,e,n,o){this.addShape(this.shapeCreator.quadraticBezier(this.lastX,this.lastY,t,e,n,o)),this.lastX=n,this.lastY=o,this.lastCommand="Q"}curvetoQuadraticRel(t,e,n,o){this.addShape(this.shapeCreator.quadraticBezier(this.lastX,this.lastY,this.lastX+t,this.lastY+e,this.lastX+n,this.lastY+o)),this.lastX+=n,this.lastY+=o,this.lastCommand="q"}curvetoCubicSmoothAbs(t,e,n,o){let s,r;if(this.lastCommand.match(/^[SsCc]$/)){const i=this.shapes[this.shapes.length-1].args[2];s=2*this.lastX-i.x,r=2*this.lastY-i.y}else s=this.lastX,r=this.lastY;this.addShape(this.shapeCreator.cubicBezier(this.lastX,this.lastY,s,r,t,e,n,o)),this.lastX=n,this.lastY=o,this.lastCommand="S"}curvetoCubicSmoothRel(t,e,n,o){let s,r;if(this.lastCommand.match(/^[SsCc]$/)){const i=this.shapes[this.shapes.length-1].args[2];s=2*this.lastX-i.x,r=2*this.lastY-i.y}else s=this.lastX,r=this.lastY;this.addShape(this.shapeCreator.cubicBezier(this.lastX,this.lastY,s,r,this.lastX+t,this.lastY+e,this.lastX+n,this.lastY+o)),this.lastX+=n,this.lastY+=o,this.lastCommand="s"}curvetoQuadraticSmoothAbs(t,e){let n,o;if(this.lastCommand.match(/^[QqTt]$/)){const s=this.shapes[this.shapes.length-1].args[1];n=2*this.lastX-s.x,o=2*this.lastY-s.y}else n=this.lastX,o=this.lastY;this.addShape(this.shapeCreator.quadraticBezier(this.lastX,this.lastY,n,o,t,e)),this.lastX=t,this.lastY=e,this.lastCommand="T"}curvetoQuadraticSmoothRel(t,e){let n,o;if(this.lastCommand.match(/^[QqTt]$/)){const s=this.shapes[this.shapes.length-1].args[1];n=2*this.lastX-s.x,o=2*this.lastY-s.y}else n=this.lastX,o=this.lastY;this.addShape(this.shapeCreator.quadraticBezier(this.lastX,this.lastY,n,o,this.lastX+t,this.lastY+e)),this.lastX+=t,this.lastY+=e,this.lastCommand="t"}linetoVerticalAbs(t){this.addShape(this.shapeCreator.line(this.lastX,this.lastY,this.lastX,t)),this.lastY=t,this.lastCommand="V"}linetoVerticalRel(t){this.addShape(this.shapeCreator.line(this.lastX,this.lastY,this.lastX,this.lastY+t)),this.lastY+=t,this.lastCommand="v"}closePath(){this.addShape(this.shapeCreator.line(this.lastX,this.lastY,this.firstX,this.firstY)),this.lastX=this.firstX,this.lastY=this.firstY,this.lastCommand="z"}}const Tn=Math.PI*.5,fi=new In;function tn(l,t){const e=[];for(const[n,o]of l){let s=null;if(o==="Point2D")s=Ls(n,t);else if(o==="Number")s=gi(n,t);else if(o==="Array<Point2D>"||o==="Point2D[]"){const r=[];for(;t.length>0;)r.push(Ls(n,t));r.length>0&&(s=r)}else if(o==="Optional<Number>"||o==="Number?")s=gi(n,t),s===null&&(s=void 0);else throw new TypeError(`Unrecognized value type: ${o}`);if(s!==null)e.push(s);else throw new TypeError(`Unable to extract value for ${n}`)}return e}function gi(l,t){let e=null;if(t.length>0){const n=t[0],o=typeof n;if(o==="number")return t.shift();if(o==="object"){for(const s of l)if(s in n&&typeof n[s]=="number"){e=n[s];break}}}return e}function Ls(l,t){let e=null;if(t.length>0){const n=t[0],o=typeof n;if(o==="number"){if(t.length>1){const s=t.shift(),r=t.shift();e=new ge(s,r)}}else if(Array.isArray(n)&&n.length>1)if(n.length===2){const[s,r]=t.shift();e=new ge(s,r)}else throw new TypeError(`Unhandled array of length ${n.length}`);else if(o==="object"){if("x"in n&&"y"in n)e=new ge(n.x,n.y),t.shift();else for(const s of l)if(Array.isArray(s)){if(s.every(r=>r in n)){e=new ge(n[s[0]],n[s[1]]);break}}else if(s in n){e=Ls([],[n[s]]);break}}}return e}class q{constructor(t,e){this.name=t,this.args=e}static arc(...t){const n=tn([[["center",["centerX","centerY"],["cx","cy"]],"Point2D"],[["radiusX","rx"],"Number"],[["radiusY","ry"],"Number"],[["startRadians"],"Number"],[["endRadians"],"Number"]],t);return new q(q.ARC,n)}static quadraticBezier(...t){const n=tn([[["p1",["p1x","p1y"]],"Point2D"],[["p2",["p2x","p2y"]],"Point2D"],[["p3",["p3x","p3y"]],"Point2D"]],t);return new q(q.QUADRATIC_BEZIER,n)}static cubicBezier(...t){const n=tn([[["p1",["p1x","p1y"]],"Point2D"],[["p2",["p2x","p2y"]],"Point2D"],[["p3",["p3x","p3y"]],"Point2D"],[["p4",["p4x","p4y"]],"Point2D"]],t);return new q(q.CUBIC_BEZIER,n)}static circle(...t){const n=tn([[["center",["centerX","centerY"],["cx","cy"]],"Point2D"],[["radius","r"],"Number"]],t);return new q(q.CIRCLE,n)}static ellipse(...t){const n=tn([[["center",["centerX","centerY"],["cx","cy"]],"Point2D"],[["radiusX","rx"],"Number"],[["radiusY","ry"],"Number"]],t);return new q(q.ELLIPSE,n)}static line(...t){const n=tn([[["p1",["p1x","p1y"],["x1","y1"]],"Point2D"],[["p2",["p2x","p2y"],["x2","y2"]],"Point2D"]],t);return new q(q.LINE,n)}static path(...t){return fi.parseData(t[0]),new q(q.PATH,yi.shapes)}static polygon(...t){const n=tn([[[],"Array<Point2D>"]],t.length===1&&Array.isArray(t[0])?t[0]:t);return new q(q.POLYGON,n)}static polyline(...t){const n=tn([[[],"Array<Point2D>"]],t.length===1&&Array.isArray(t[0])?t[0]:t);return new q(q.POLYLINE,n)}static rectangle(...t){const n=tn([[["topLeft",["x","y"],["left","top"]],"Point2D"],[["size",["width","height"],["w","h"]],"Point2D"],[["radiusX","rx"],"Optional<Number>"],[["radiusY","ry"],"Optional<Number>"]],t),o=n[0],s=n[1];n[1]=new ge(o.x+s.x,o.y+s.y);const r=new q(q.RECTANGLE,n);let i=r.args.pop(),a=r.args.pop();if(a=a===void 0?0:a,i=i===void 0?0:i,a===0&&i===0)return r;const{x:c,y:h}=r.args[0],{x:d,y:u}=r.args[1],f=d-c,g=u-h;a===0&&(a=i),i===0&&(i=a),a>f*.5&&(a=f*.5),i>g*.5&&(i=g*.5);const y=c,P=h,b=c+a,w=h+i,L=d-a,B=u-i,H=d,E=u,X=[q.arc(b,w,a,i,2*Tn,3*Tn),q.line(b,P,L,P),q.arc(L,w,a,i,3*Tn,4*Tn),q.line(H,w,H,B),q.arc(L,B,a,i,0,Tn),q.line(L,E,b,E),q.arc(b,B,a,i,Tn,2*Tn),q.line(y,B,y,w)];return new q(q.PATH,X)}}q.ARC="Arc",q.QUADRATIC_BEZIER="Bezier2",q.CUBIC_BEZIER="Bezier3",q.CIRCLE="Circle",q.ELLIPSE="Ellipse",q.LINE="Line",q.PATH="Path",q.POLYGON="Polygon",q.POLYLINE="Polyline",q.RECTANGLE="Rectangle";const yi=new Rh(q);fi.setHandler(yi);const io=2*Math.PI,Eh=new rt(1,0);function xi(l){return l==null}function Hh(l,t){const e=l[0]*t[1]-t[0]*l[1],n=l[0]*t[2]-t[0]*l[2],o=l[0]*t[3]-t[0]*l[3],s=l[0]*t[4]-t[0]*l[4],r=l[0]*t[5]-t[0]*l[5],i=l[1]*t[2]-t[1]*l[2],a=l[1]*t[4]-t[1]*l[4],c=l[1]*t[5]-t[1]*l[5],h=l[2]*t[3]-t[2]*l[3],d=l[3]*t[4]-t[3]*l[4],u=l[3]*t[5]-t[3]*l[5],f=c+d,g=a-h;return new Ue(e*i-n*n,e*g+o*i-2*n*s,e*f+o*g-s*s-2*n*r,e*u+o*f-2*s*r,o*u-r*r)}function Dh(l){const t=l%io;return t<0?t+io:t}function Oh(l,t,e,n,o,s){if(l.points.length===0)return l;const r=new Y("No Intersection");s<o&&([o,s]=[s,o]),(o<0||s<0)&&(o+=io,s+=io);for(const i of l.points){let a=Dh(Eh.angleBetween(rt.fromPoints(t,i)));a<o&&(a+=io),o<=a&&a<=s&&r.appendPoint(i)}return r.points.length>0&&(r.status="Intersection"),r}function nn(l){const t=l.slice();return t.push(l[0]),t}class Y{constructor(t){this.init(t)}init(t){this.status=t,this.points=[]}static intersect(t,e){let n;if(!xi(t)&&!xi(e))if(t.name==="Path")n=Y.intersectPathShape(t,e);else if(e.name==="Path")n=Y.intersectPathShape(e,t);else if(t.name==="Arc")n=Y.intersectArcShape(t,e);else if(e.name==="Arc")n=Y.intersectArcShape(e,t);else{let o,s;if(t.name<e.name?(o="intersect"+t.name+e.name,s=t.args.concat(e.args)):(o="intersect"+e.name+t.name,s=e.args.concat(t.args)),!(o in Y))throw new TypeError("Intersection not available: "+o);n=Y[o].apply(null,s)}else n=new Y("No Intersection");return n}static intersectPathShape(t,e){const n=new Y("No Intersection");for(const o of t.args){const s=Y.intersect(o,e);n.appendPoints(s.points)}return n.points.length>0&&(n.status="Intersection"),n}static intersectArcShape(t,e){const[n,o,s,r,i]=t.args,a=new q(q.ELLIPSE,[n,o,s]),c=Y.intersect(a,e);return Oh(c,n,o,s,r,i)}static intersectBezier2Bezier2(t,e,n,o,s,r){let i,a;const c=new Y("No Intersection");i=e.multiply(-2);const h=t.add(i.add(n));i=t.multiply(-2),a=e.multiply(2);const d=i.add(a),u=new ge(t.x,t.y);i=s.multiply(-2);const f=o.add(i.add(r));i=o.multiply(-2),a=s.multiply(2);const g=i.add(a),y=new ge(o.x,o.y);i=h.x*d.y-d.x*h.y,a=f.x*d.y-d.x*f.y;const P=g.x*d.y-d.x*g.y,b=d.x*(u.y-y.y)+d.y*(-u.x+y.x),w=f.x*h.y-h.x*f.y,L=g.x*h.y-h.x*g.y,B=h.x*(u.y-y.y)+h.y*(-u.x+y.x),E=new Ue(-w*w,-2*w*L,i*a-L*L-2*w*B,i*P-2*L*B,i*b-B*B).getRoots();for(const X of E)if(0<=X&&X<=1){const $=new Ue(h.x,d.x,u.x-y.x-X*g.x-X*X*f.x);$.simplifyEquals();const Z=$.getRoots(),se=new Ue(h.y,d.y,u.y-y.y-X*g.y-X*X*f.y);se.simplifyEquals();const ne=se.getRoots();if(Z.length>0&&ne.length>0){e:for(const te of Z)if(0<=te&&te<=1){for(let ce=0;ce<ne.length;ce++)if(Math.abs(te-ne[ce])<1e-4){c.points.push(f.multiply(X*X).add(g.multiply(X).add(y)));break e}}}}return c.points.length>0&&(c.status="Intersection"),c}static intersectBezier2Bezier3(t,e,n,o,s,r,i){let a,c,h,d;const u=new Y("No Intersection");a=e.multiply(-2);const f=t.add(a.add(n));a=t.multiply(-2),c=e.multiply(2);const g=a.add(c),y=new ge(t.x,t.y);a=o.multiply(-1),c=s.multiply(3),h=r.multiply(-3),d=a.add(c.add(h.add(i)));const P=new ge(d.x,d.y);a=o.multiply(3),c=s.multiply(-6),h=r.multiply(3),d=a.add(c.add(h));const b=new ge(d.x,d.y);a=o.multiply(-3),c=s.multiply(3),h=a.add(c);const w=new ge(h.x,h.y),L=new ge(o.x,o.y),B=y.x*y.x,H=y.y*y.y,E=g.x*g.x,X=g.y*g.y,$=f.x*f.x,Z=f.y*f.y,se=L.x*L.x,ne=L.y*L.y,ae=w.x*w.x,te=w.y*w.y,ce=b.x*b.x,pe=b.y*b.y,Be=P.x*P.x,Re=P.y*P.y,Te=new Ue(-2*f.x*f.y*P.x*P.y+$*Re+Z*Be,-2*f.x*f.y*b.x*P.y-2*f.x*f.y*b.y*P.x+2*Z*b.x*P.x+2*$*b.y*P.y,-2*f.x*w.x*f.y*P.y-2*f.x*f.y*w.y*P.x-2*f.x*f.y*b.x*b.y+2*w.x*Z*P.x+Z*ce+$*(2*w.y*P.y+pe),2*y.x*f.x*f.y*P.y+2*y.y*f.x*f.y*P.x+g.x*g.y*f.x*P.y+g.x*g.y*f.y*P.x-2*L.x*f.x*f.y*P.y-2*f.x*L.y*f.y*P.x-2*f.x*w.x*f.y*b.y-2*f.x*f.y*w.y*b.x-2*y.x*Z*P.x-2*y.y*$*P.y+2*L.x*Z*P.x+2*w.x*Z*b.x-X*f.x*P.x-E*f.y*P.y+$*(2*L.y*P.y+2*w.y*b.y),2*y.x*f.x*f.y*b.y+2*y.y*f.x*f.y*b.x+g.x*g.y*f.x*b.y+g.x*g.y*f.y*b.x-2*L.x*f.x*f.y*b.y-2*f.x*L.y*f.y*b.x-2*f.x*w.x*f.y*w.y-2*y.x*Z*b.x-2*y.y*$*b.y+2*L.x*Z*b.x-X*f.x*b.x-E*f.y*b.y+ae*Z+$*(2*L.y*b.y+te),2*y.x*f.x*f.y*w.y+2*y.y*f.x*w.x*f.y+g.x*g.y*f.x*w.y+g.x*g.y*w.x*f.y-2*L.x*f.x*f.y*w.y-2*f.x*L.y*w.x*f.y-2*y.x*w.x*Z-2*y.y*$*w.y+2*L.x*w.x*Z-X*f.x*w.x-E*f.y*w.y+2*$*L.y*w.y,-2*y.x*y.y*f.x*f.y-y.x*g.x*g.y*f.y-y.y*g.x*g.y*f.x+2*y.x*f.x*L.y*f.y+2*y.y*L.x*f.x*f.y+g.x*L.x*g.y*f.y+g.x*g.y*f.x*L.y-2*L.x*f.x*L.y*f.y-2*y.x*L.x*Z+y.x*X*f.x+y.y*E*f.y-2*y.y*$*L.y-L.x*X*f.x-E*L.y*f.y+B*Z+H*$+se*Z+$*ne).getRootsInInterval(0,1);for(const fe of Te){const O=new Ue(f.x,g.x,y.x-L.x-fe*w.x-fe*fe*b.x-fe*fe*fe*P.x).getRoots(),G=new Ue(f.y,g.y,y.y-L.y-fe*w.y-fe*fe*b.y-fe*fe*fe*P.y).getRoots();if(O.length>0&&G.length>0){e:for(const _ of O)if(0<=_&&_<=1){for(let Ve=0;Ve<G.length;Ve++)if(Math.abs(_-G[Ve])<1e-4){u.points.push(P.multiply(fe*fe*fe).add(b.multiply(fe*fe).add(w.multiply(fe).add(L))));break e}}}}return u.points.length>0&&(u.status="Intersection"),u}static intersectBezier2Circle(t,e,n,o,s){return Y.intersectBezier2Ellipse(t,e,n,o,s,s)}static intersectBezier2Ellipse(t,e,n,o,s,r){let i;const a=new Y("No Intersection");i=e.multiply(-2);const c=t.add(i.add(n));i=t.multiply(-2);const h=e.multiply(2),d=i.add(h),u=new ge(t.x,t.y),f=s*s,g=r*r,y=new Ue(g*c.x*c.x+f*c.y*c.y,2*(g*c.x*d.x+f*c.y*d.y),g*(2*c.x*u.x+d.x*d.x)+f*(2*c.y*u.y+d.y*d.y)-2*(g*o.x*c.x+f*o.y*c.y),2*(g*d.x*(u.x-o.x)+f*d.y*(u.y-o.y)),g*(u.x*u.x+o.x*o.x)+f*(u.y*u.y+o.y*o.y)-2*(g*o.x*u.x+f*o.y*u.y)-f*g).getRoots();for(const P of y)0<=P&&P<=1&&a.points.push(c.multiply(P*P).add(d.multiply(P).add(u)));return a.points.length>0&&(a.status="Intersection"),a}static intersectBezier2Line(t,e,n,o,s){let r;const i=o.min(s),a=o.max(s),c=new Y("No Intersection");r=e.multiply(-2);const h=t.add(r.add(n));r=t.multiply(-2);const d=e.multiply(2),u=r.add(d),f=new ge(t.x,t.y),g=new rt(o.y-s.y,s.x-o.x),y=o.x*s.y-s.x*o.y,P=new Ue(g.dot(h),g.dot(u),g.dot(f)+y).getRoots();for(const b of P)if(0<=b&&b<=1){const w=t.lerp(e,b),L=e.lerp(n,b),B=w.lerp(L,b);o.x===s.x?i.y<=B.y&&B.y<=a.y&&(c.status="Intersection",c.appendPoint(B)):o.y===s.y?i.x<=B.x&&B.x<=a.x&&(c.status="Intersection",c.appendPoint(B)):i.x<=B.x&&B.x<=a.x&&i.y<=B.y&&B.y<=a.y&&(c.status="Intersection",c.appendPoint(B))}return c}static intersectBezier2Polygon(t,e,n,o){return Y.intersectBezier2Polyline(t,e,n,nn(o))}static intersectBezier2Polyline(t,e,n,o){const s=new Y("No Intersection"),{length:r}=o;for(let i=0;i<r-1;i++){const a=o[i],c=o[i+1],h=Y.intersectBezier2Line(t,e,n,a,c);s.appendPoints(h.points)}return s.points.length>0&&(s.status="Intersection"),s}static intersectBezier2Rectangle(t,e,n,o,s){const r=o.min(s),i=o.max(s),a=new ge(i.x,r.y),c=new ge(r.x,i.y),h=Y.intersectBezier2Line(t,e,n,r,a),d=Y.intersectBezier2Line(t,e,n,a,i),u=Y.intersectBezier2Line(t,e,n,i,c),f=Y.intersectBezier2Line(t,e,n,c,r),g=new Y("No Intersection");return g.appendPoints(h.points),g.appendPoints(d.points),g.appendPoints(u.points),g.appendPoints(f.points),g.points.length>0&&(g.status="Intersection"),g}static intersectBezier3Bezier3(t,e,n,o,s,r,i,a){let c,h,d,u;const f=new Y("No Intersection");c=t.multiply(-1),h=e.multiply(3),d=n.multiply(-3),u=c.add(h.add(d.add(o)));const g=new ge(u.x,u.y);c=t.multiply(3),h=e.multiply(-6),d=n.multiply(3),u=c.add(h.add(d));const y=new ge(u.x,u.y);c=t.multiply(-3),h=e.multiply(3),d=c.add(h);const P=new ge(d.x,d.y),b=new ge(t.x,t.y);c=s.multiply(-1),h=r.multiply(3),d=i.multiply(-3),u=c.add(h.add(d.add(a)));const w=new ge(u.x,u.y);c=s.multiply(3),h=r.multiply(-6),d=i.multiply(3),u=c.add(h.add(d));const L=new ge(u.x,u.y);c=s.multiply(-3),h=r.multiply(3),d=c.add(h);const B=new ge(d.x,d.y),H=new ge(s.x,s.y);c=g.x*y.y-y.x*g.y,h=g.x*P.y-P.x*g.y;const E=g.x*b.y-b.x*g.y+H.x*g.y-g.x*H.y,X=B.x*g.y-g.x*B.y,$=L.x*g.y-g.x*L.y,Z=w.x*g.y-g.x*w.y;u=g.x*P.y-P.x*g.y;const se=g.x*b.y+y.x*P.y-P.x*y.y-b.x*g.y+H.x*g.y-g.x*H.y,ne=B.x*g.y-g.x*B.y,ae=L.x*g.y-g.x*L.y,te=w.x*g.y-g.x*w.y,ce=y.x*b.y-b.x*y.y+H.x*y.y-y.x*H.y,pe=B.x*y.y-y.x*B.y,Be=L.x*y.y-y.x*L.y,Re=w.x*y.y-y.x*w.y,Se=g.x*b.y-b.x*g.y+H.x*g.y-g.x*H.y,Te=B.x*g.y-g.x*B.y,fe=L.x*g.y-g.x*L.y,O=w.x*g.y-g.x*w.y,G=y.x*b.y-b.x*y.y+H.x*y.y-y.x*H.y,j=B.x*y.y-y.x*B.y,_=L.x*y.y-y.x*L.y,Ve=w.x*y.y-y.x*w.y,ut=P.x*b.y-b.x*P.y+H.x*P.y-P.x*H.y,yt=B.x*P.y-P.x*B.y,kt=L.x*P.y-P.x*L.y,Ft=w.x*P.y-P.x*w.y,ln=new Ue(-Z*te*O,-Z*te*fe-Z*ae*O-$*te*O,-Z*te*Te-Z*ae*fe-$*te*fe-Z*ne*O-$*ae*O-X*te*O,-Z*te*Se-Z*ae*Te-$*te*Te-Z*ne*fe-$*ae*fe-X*te*fe-Z*se*O-$*ne*O-X*ae*O-E*te*O+h*Re*O+Z*u*Ve-c*Re*Ve+c*te*Ft,-Z*ae*Se-$*te*Se-Z*ne*Te-$*ae*Te-X*te*Te-Z*se*fe-$*ne*fe-X*ae*fe-E*te*fe+h*Re*fe-$*se*O-X*ne*O-E*ae*O+h*Be*O+Z*u*_-c*Re*_+$*u*Ve-c*Be*Ve+c*te*kt+c*ae*Ft,-Z*ne*Se-$*ae*Se-X*te*Se-Z*se*Te-$*ne*Te-X*ae*Te-E*te*Te+h*Re*Te-$*se*fe-X*ne*fe-E*ae*fe+h*Be*fe-X*se*O-E*ne*O+h*pe*O+Z*u*j-c*Re*j+$*u*_-c*Be*_+X*u*Ve-c*pe*Ve+c*te*yt+c*ae*kt+c*ne*Ft,-Z*se*Se-$*ne*Se-X*ae*Se-E*te*Se+h*Re*Se-$*se*Te-X*ne*Te-E*ae*Te+h*Be*Te-X*se*fe-E*ne*fe+h*pe*fe-E*se*O+h*ce*O+Z*u*G-c*Re*G+$*u*j-c*Be*j+X*u*_-c*pe*_+E*u*Ve-c*ce*Ve+c*te*ut+c*ae*yt+c*ne*kt-h*u*Ft+c*se*Ft,-$*se*Se-X*ne*Se-E*ae*Se+h*Be*Se-X*se*Te-E*ne*Te+h*pe*Te-E*se*fe+h*ce*fe+$*u*G-c*Be*G+X*u*j-c*pe*j+E*u*_-c*ce*_+c*ae*ut+c*ne*yt-h*u*kt+c*se*kt,-X*se*Se-E*ne*Se+h*pe*Se-E*se*Te+h*ce*Te+X*u*G-c*pe*G+E*u*j-c*ce*j+c*ne*ut-h*u*yt+c*se*yt,-E*se*Se+h*ce*Se+E*u*G-c*ce*G-h*u*ut+c*se*ut);ln.simplifyEquals();const On=ln.getRootsInInterval(0,1);for(const $e of On){const eo=new Ue(g.x,y.x,P.x,b.x-H.x-$e*B.x-$e*$e*L.x-$e*$e*$e*w.x);eo.simplifyEquals();const to=eo.getRoots(),mn=new Ue(g.y,y.y,P.y,b.y-H.y-$e*B.y-$e*$e*L.y-$e*$e*$e*w.y);mn.simplifyEquals();const Yt=mn.getRoots();if(to.length>0&&Yt.length>0){e:for(const no of to)if(0<=no&&no<=1){for(let Pn=0;Pn<Yt.length;Pn++)if(Math.abs(no-Yt[Pn])<1e-4){f.points.push(w.multiply($e*$e*$e).add(L.multiply($e*$e).add(B.multiply($e).add(H))));break e}}}}return f.points.length>0&&(f.status="Intersection"),f}static intersectBezier3Circle(t,e,n,o,s,r){return Y.intersectBezier3Ellipse(t,e,n,o,s,r,r)}static intersectBezier3Ellipse(t,e,n,o,s,r,i){let a,c,h,d;const u=new Y("No Intersection");a=t.multiply(-1),c=e.multiply(3),h=n.multiply(-3),d=a.add(c.add(h.add(o)));const f=new ge(d.x,d.y);a=t.multiply(3),c=e.multiply(-6),h=n.multiply(3),d=a.add(c.add(h));const g=new ge(d.x,d.y);a=t.multiply(-3),c=e.multiply(3),h=a.add(c);const y=new ge(h.x,h.y),P=new ge(t.x,t.y),b=r*r,w=i*i,B=new Ue(f.x*f.x*w+f.y*f.y*b,2*(f.x*g.x*w+f.y*g.y*b),2*(f.x*y.x*w+f.y*y.y*b)+g.x*g.x*w+g.y*g.y*b,2*f.x*w*(P.x-s.x)+2*f.y*b*(P.y-s.y)+2*(g.x*y.x*w+g.y*y.y*b),2*g.x*w*(P.x-s.x)+2*g.y*b*(P.y-s.y)+y.x*y.x*w+y.y*y.y*b,2*y.x*w*(P.x-s.x)+2*y.y*b*(P.y-s.y),P.x*P.x*w-2*P.y*s.y*b-2*P.x*s.x*w+P.y*P.y*b+s.x*s.x*w+s.y*s.y*b-b*w).getRootsInInterval(0,1);for(const H of B)u.points.push(f.multiply(H*H*H).add(g.multiply(H*H).add(y.multiply(H).add(P))));return u.points.length>0&&(u.status="Intersection"),u}static intersectBezier3Line(t,e,n,o,s,r){let i,a,c,h;const d=s.min(r),u=s.max(r),f=new Y("No Intersection");i=t.multiply(-1),a=e.multiply(3),c=n.multiply(-3),h=i.add(a.add(c.add(o)));const g=new rt(h.x,h.y);i=t.multiply(3),a=e.multiply(-6),c=n.multiply(3),h=i.add(a.add(c));const y=new rt(h.x,h.y);i=t.multiply(-3),a=e.multiply(3),c=i.add(a);const P=new rt(c.x,c.y),b=new rt(t.x,t.y),w=new rt(s.y-r.y,r.x-s.x),L=s.x*r.y-r.x*s.y,B=new Ue(w.dot(g),w.dot(y),w.dot(P),w.dot(b)+L).getRoots();for(const H of B)if(0<=H&&H<=1){const E=t.lerp(e,H),X=e.lerp(n,H),$=n.lerp(o,H),Z=E.lerp(X,H),se=X.lerp($,H),ne=Z.lerp(se,H);s.x===r.x?d.y<=ne.y&&ne.y<=u.y&&(f.status="Intersection",f.appendPoint(ne)):s.y===r.y?d.x<=ne.x&&ne.x<=u.x&&(f.status="Intersection",f.appendPoint(ne)):d.x<=ne.x&&ne.x<=u.x&&d.y<=ne.y&&ne.y<=u.y&&(f.status="Intersection",f.appendPoint(ne))}return f}static intersectBezier3Polygon(t,e,n,o,s){return Y.intersectBezier3Polyline(t,e,n,o,nn(s))}static intersectBezier3Polyline(t,e,n,o,s){const r=new Y("No Intersection"),{length:i}=s;for(let a=0;a<i-1;a++){const c=s[a],h=s[a+1],d=Y.intersectBezier3Line(t,e,n,o,c,h);r.appendPoints(d.points)}return r.points.length>0&&(r.status="Intersection"),r}static intersectBezier3Rectangle(t,e,n,o,s,r){const i=s.min(r),a=s.max(r),c=new ge(a.x,i.y),h=new ge(i.x,a.y),d=Y.intersectBezier3Line(t,e,n,o,i,c),u=Y.intersectBezier3Line(t,e,n,o,c,a),f=Y.intersectBezier3Line(t,e,n,o,a,h),g=Y.intersectBezier3Line(t,e,n,o,h,i),y=new Y("No Intersection");return y.appendPoints(d.points),y.appendPoints(u.points),y.appendPoints(f.points),y.appendPoints(g.points),y.points.length>0&&(y.status="Intersection"),y}static intersectCircleCircle(t,e,n,o){let s;const r=e+o,i=Math.abs(e-o),a=t.distanceFrom(n);if(a>r)s=new Y("Outside");else if(a<i)s=new Y("Inside");else{s=new Y("Intersection");const c=(e*e-o*o+a*a)/(2*a),h=Math.sqrt(e*e-c*c),d=t.lerp(n,c/a),u=h/a;s.points.push(new ge(d.x-u*(n.y-t.y),d.y+u*(n.x-t.x))),s.points.push(new ge(d.x+u*(n.y-t.y),d.y-u*(n.x-t.x)))}return s}static intersectCircleEllipse(t,e,n,o,s){return Y.intersectEllipseEllipse(t,e,e,n,o,s)}static intersectCircleLine(t,e,n,o){let s;const r=(o.x-n.x)*(o.x-n.x)+(o.y-n.y)*(o.y-n.y),i=2*((o.x-n.x)*(n.x-t.x)+(o.y-n.y)*(n.y-t.y)),a=t.x*t.x+t.y*t.y+n.x*n.x+n.y*n.y-2*(t.x*n.x+t.y*n.y)-e*e,c=i*i-4*r*a;if(c<0)s=new Y("Outside");else if(c===0)s=new Y("Tangent");else{const h=Math.sqrt(c),d=(-i+h)/(2*r),u=(-i-h)/(2*r);(d<0||d>1)&&(u<0||u>1)?d<0&&u<0||d>1&&u>1?s=new Y("Outside"):s=new Y("Inside"):(s=new Y("Intersection"),0<=d&&d<=1&&s.points.push(n.lerp(o,d)),0<=u&&u<=1&&s.points.push(n.lerp(o,u)))}return s}static intersectCirclePolygon(t,e,n){return Y.intersectCirclePolyline(t,e,nn(n))}static intersectCirclePolyline(t,e,n){const o=new Y("No Intersection"),{length:s}=n;let r;for(let i=0;i<s-1;i++){const a=n[i],c=n[i+1];r=Y.intersectCircleLine(t,e,a,c),o.appendPoints(r.points)}return o.points.length>0?o.status="Intersection":o.status=r.status,o}static intersectCircleRectangle(t,e,n,o){const s=n.min(o),r=n.max(o),i=new ge(r.x,s.y),a=new ge(s.x,r.y),c=Y.intersectCircleLine(t,e,s,i),h=Y.intersectCircleLine(t,e,i,r),d=Y.intersectCircleLine(t,e,r,a),u=Y.intersectCircleLine(t,e,a,s),f=new Y("No Intersection");return f.appendPoints(c.points),f.appendPoints(h.points),f.appendPoints(d.points),f.appendPoints(u.points),f.points.length>0?f.status="Intersection":f.status=c.status,f}static intersectEllipseEllipse(t,e,n,o,s,r){const i=[n*n,0,e*e,-2*n*n*t.x,-2*e*e*t.y,n*n*t.x*t.x+e*e*t.y*t.y-e*e*n*n],a=[r*r,0,s*s,-2*r*r*o.x,-2*s*s*o.y,r*r*o.x*o.x+s*s*o.y*o.y-s*s*r*r],h=Hh(i,a).getRoots(),d=.001,u=(i[0]*i[0]+2*i[1]*i[1]+i[2]*i[2])*d,f=(a[0]*a[0]+2*a[1]*a[1]+a[2]*a[2])*d,g=new Y("No Intersection");for(let y=0;y<h.length;y++){const b=new Ue(i[0],i[3]+h[y]*i[1],i[5]+h[y]*(i[4]+h[y]*i[2])).getRoots();for(let w=0;w<b.length;w++){let L=(i[0]*b[w]+i[1]*h[y]+i[3])*b[w]+(i[2]*h[y]+i[4])*h[y]+i[5];Math.abs(L)<u&&(L=(a[0]*b[w]+a[1]*h[y]+a[3])*b[w]+(a[2]*h[y]+a[4])*h[y]+a[5],Math.abs(L)<f&&g.appendPoint(new ge(b[w],h[y])))}}return g.points.length>0&&(g.status="Intersection"),g}static intersectEllipseLine(t,e,n,o,s){let r;const i=new rt(o.x,o.y),a=rt.fromPoints(o,s),c=new rt(t.x,t.y),h=i.subtract(c),d=new rt(a.x/(e*e),a.y/(n*n)),u=new rt(h.x/(e*e),h.y/(n*n)),f=a.dot(d),g=a.dot(u);t=h.dot(u)-1;const y=g*g-f*t;if(y<0)r=new Y("Outside");else if(y>0){const P=Math.sqrt(y),b=(-g-P)/f,w=(-g+P)/f;(b<0||1<b)&&(w<0||1<w)?b<0&&w<0||b>1&&w>1?r=new Y("Outside"):r=new Y("Inside"):(r=new Y("Intersection"),0<=b&&b<=1&&r.appendPoint(o.lerp(s,b)),0<=w&&w<=1&&r.appendPoint(o.lerp(s,w)))}else{const P=-g/f;0<=P&&P<=1?(r=new Y("Intersection"),r.appendPoint(o.lerp(s,P))):r=new Y("Outside")}return r}static intersectEllipsePolygon(t,e,n,o){return Y.intersectEllipsePolyline(t,e,n,nn(o))}static intersectEllipsePolyline(t,e,n,o){const s=new Y("No Intersection"),{length:r}=o;for(let i=0;i<r-1;i++){const a=o[i],c=o[i+1],h=Y.intersectEllipseLine(t,e,n,a,c);s.appendPoints(h.points)}return s.points.length>0&&(s.status="Intersection"),s}static intersectEllipseRectangle(t,e,n,o,s){const r=o.min(s),i=o.max(s),a=new ge(i.x,r.y),c=new ge(r.x,i.y),h=Y.intersectEllipseLine(t,e,n,r,a),d=Y.intersectEllipseLine(t,e,n,a,i),u=Y.intersectEllipseLine(t,e,n,i,c),f=Y.intersectEllipseLine(t,e,n,c,r),g=new Y("No Intersection");return g.appendPoints(h.points),g.appendPoints(d.points),g.appendPoints(u.points),g.appendPoints(f.points),g.points.length>0&&(g.status="Intersection"),g}static intersectLineLine(t,e,n,o){let s;const r=(o.x-n.x)*(t.y-n.y)-(o.y-n.y)*(t.x-n.x),i=(e.x-t.x)*(t.y-n.y)-(e.y-t.y)*(t.x-n.x),a=(o.y-n.y)*(e.x-t.x)-(o.x-n.x)*(e.y-t.y);if(a!==0){const c=r/a,h=i/a;0<=c&&c<=1&&0<=h&&h<=1?(s=new Y("Intersection"),s.points.push(new ge(t.x+c*(e.x-t.x),t.y+c*(e.y-t.y)))):s=new Y("No Intersection")}else r===0||i===0?s=new Y("Coincident"):s=new Y("Parallel");return s}static intersectLinePolygon(t,e,n){return Y.intersectLinePolyline(t,e,nn(n))}static intersectLinePolyline(t,e,n){const o=new Y("No Intersection"),{length:s}=n;for(let r=0;r<s-1;r++){const i=n[r],a=n[r+1],c=Y.intersectLineLine(t,e,i,a);o.appendPoints(c.points)}return o.points.length>0&&(o.status="Intersection"),o}static intersectLineRectangle(t,e,n,o){const s=n.min(o),r=n.max(o),i=new ge(r.x,s.y),a=new ge(s.x,r.y),c=Y.intersectLineLine(s,i,t,e),h=Y.intersectLineLine(i,r,t,e),d=Y.intersectLineLine(r,a,t,e),u=Y.intersectLineLine(a,s,t,e),f=new Y("No Intersection");return f.appendPoints(c.points),f.appendPoints(h.points),f.appendPoints(d.points),f.appendPoints(u.points),f.points.length>0&&(f.status="Intersection"),f}static intersectPolygonPolygon(t,e){return Y.intersectPolylinePolyline(nn(t),nn(e))}static intersectPolygonPolyline(t,e){return Y.intersectPolylinePolyline(nn(t),e)}static intersectPolygonRectangle(t,e,n){return Y.intersectPolylineRectangle(nn(t),e,n)}static intersectPolylinePolyline(t,e){const n=new Y("No Intersection"),{length:o}=t;for(let s=0;s<o-1;s++){const r=t[s],i=t[s+1],a=Y.intersectLinePolyline(r,i,e);n.appendPoints(a.points)}return n.points.length>0&&(n.status="Intersection"),n}static intersectPolylineRectangle(t,e,n){const o=e.min(n),s=e.max(n),r=new ge(s.x,o.y),i=new ge(o.x,s.y),a=Y.intersectLinePolyline(o,r,t),c=Y.intersectLinePolyline(r,s,t),h=Y.intersectLinePolyline(s,i,t),d=Y.intersectLinePolyline(i,o,t),u=new Y("No Intersection");return u.appendPoints(a.points),u.appendPoints(c.points),u.appendPoints(h.points),u.appendPoints(d.points),u.points.length>0&&(u.status="Intersection"),u}static intersectRectangleRectangle(t,e,n,o){const s=t.min(e),r=t.max(e),i=new ge(r.x,s.y),a=new ge(s.x,r.y),c=Y.intersectLineRectangle(s,i,n,o),h=Y.intersectLineRectangle(i,r,n,o),d=Y.intersectLineRectangle(r,a,n,o),u=Y.intersectLineRectangle(a,s,n,o),f=new Y("No Intersection");return f.appendPoints(c.points),f.appendPoints(h.points),f.appendPoints(d.points),f.appendPoints(u.points),f.points.length>0&&(f.status="Intersection"),f}static intersectRayRay(t,e,n,o){let s;const r=(o.x-n.x)*(t.y-n.y)-(o.y-n.y)*(t.x-n.x),i=(e.x-t.x)*(t.y-n.y)-(e.y-t.y)*(t.x-n.x),a=(o.y-n.y)*(e.x-t.x)-(o.x-n.x)*(e.y-t.y);if(a!==0){const c=r/a;s=new Y("Intersection"),s.points.push(new ge(t.x+c*(e.x-t.x),t.y+c*(e.y-t.y)))}else r===0||i===0?s=new Y("Coincident"):s=new Y("Parallel");return s}appendPoint(t){this.points.push(t)}appendPoints(t){this.points=this.points.concat(t)}}class Fn extends en{constructor(){super(...arguments);p(this,"imgBitmap",null);p(this,"fallbackDrawer",new Nh);p(this,"broken",!1)}setBroken(e=!0){this.broken=e}setImageBitmap(e){this.imgBitmap=e}get borderProps(){return this.props.get(I.Border)}get cropProps(){return this.props.get(I.Crop)}updateProps(e){super.updateProps(e),e.find(o=>o.type===I.Base)&&this.updateTransformMatrix()}drawOnGLCtx(e){if(!this.imgBitmap){this.broken&&this.fallbackDrawer.fallbackDraw(this,e);return}e.save();const{a:n,b:o,c:s,d:r,e:i,f:a}=this.globalTransform();e.transform(n,o,s,r,i,a),this.clipDrawImage(e,this.imgBitmap),this.clipDrawBorder(e),e.restore()}clipDrawBorder(e){const n=this.borderProps,o=this.cropProps,s=this.baseProps;if(n.color!==""&&n.dashType!==et.None){if(S.setDashLine(n,e),e.strokeStyle=n.color,e.lineWidth=n.width,e.globalAlpha=n.alpha,o.cropType===wt.Circle){const r=.5*Math.min(s.width,s.height);e.beginPath(),e.arc(.5*s.width,.5*s.height,r,0,2*Math.PI),e.stroke();return}if(o.cropType===wt.RoundRect){e.beginPath(),e.roundRect(0,0,s.width,s.height,10),e.stroke();return}e.strokeRect(0,0,s.width,s.height)}}clipDrawImage(e,n){const o=this.cropProps,s=this.baseProps;if(o.cropType===wt.None)e.drawImage(n,0,0,s.width,s.height);else{if(e.save(),o.cropType===wt.RoundRect&&(e.beginPath(),e.roundRect(0,0,s.width,s.height,10),e.clip()),o.cropType===wt.Circle){const b=.5*Math.min(s.width,s.height);e.beginPath(),e.arc(.5*s.width,.5*s.height,b,0,2*Math.PI),e.clip()}const{imgX:r,imgY:i,imgWidth:a,imgHeight:c}=o.cropInfo,h=this.getImgSize(),d=a/h.imgWidth,u=c/h.imgHeight,f=-r/d,g=-i/u,y=s.width/d,P=s.height/u;e.drawImage(n,f,g,y,P,0,0,s.width,s.height),e.restore()}}getImgSize(){if(!this.imgBitmap){console.warn("img bitmap不存在,已经降级处理");const{width:o,height:s}=this.baseProps;return{imgWidth:o,imgHeight:s}}const e=this.imgBitmap.width,n=this.imgBitmap.height;return{imgWidth:e,imgHeight:n}}getOriginImageRect(){const{cropType:e,cropInfo:n}=this.cropProps;if(e===wt.None||!n){const a=this.baseProps;return new D(0,0,a.width,a.height)}const{imgX:o,imgY:s,imgWidth:r,imgHeight:i}=n;return new D(o,s,r,i)}getTextContentRect(){return this.baseProps}getConnectAnchor(){return[new m(.5,0),new m(1,.5),new m(.5,1),new m(0,.5)]}borderContains(e,n){const o=this.toLocal(e),{width:s,height:r}=this.baseProps,i=q.rectangle({top:0,left:0,width:s,height:r}),a=q.line({x:o.x-n,y:o.y},{x:o.x+n,y:o.y}),c=q.line({x:o.x,y:o.y-n},{x:o.x,y:o.y+n});for(const h of[a,c]){const d=Y.intersect(i,h);if(d.points.length>0)return d.points[0]}return null}}class Yn extends Fn{constructor(e,n){super(e,n);p(this,"type",v.IMG);this.props.set(I.Base,new ie),this.props.set(I.Border,new Ae),this.props.set(I.Image,new ro),this.props.set(I.Crop,new Mn)}get imgSrc(){return this.getProp(I.Image).url}static load(e,n,o,s,r,i){const a=new Yn(e,i);return a.type=n,a.zIndex=o,a.setParent(r),a.updateProps(s),a}}class Xh{draw(t,e){const n=t.getDrawPoints();if(n.length<2){console.error("line has no point!");return}const o=n[0],s=n.length>1?n[n.length-1]:{...o};e.beginPath(),e.moveTo(o.x,o.y),e.lineTo(s.x,s.y),e.stroke()}textContentBounds(t){const e=t.baseProps;return{x:e.x,y:e.y,width:e.width,height:e.height}}borderContains(t,e,n){return null}getConnectAnchor(){return[]}}class wi{static lineContainsPoint(t,e,n){const o=t.shapeType,s=[...t.points];return o===he.Line?this.simpleLineContains(s,e,n):t.isPolyLine()?this.polyLineContains(s,e,n):o===he.Curve?this.curveLineContains(s,e,n):!1}static overlapRectNode(t,e){const n=t.shapeType,o=[...t.points],s=q.rectangle({top:e.minY,left:e.minX,width:e.maxX-e.minX,height:e.maxY-e.minY});if(n===he.Line){const r=q.line(o[0],o[o.length-1]);if(Y.intersect(s,r).points.length>0)return!0}if(t.isPolyLine()){const r=q.polyline(o);if(Y.intersect(s,r).points.length>0)return!0}if(n===he.Curve)for(let r=0;r<o.length-2;r=r+3){const i=o[r],a=o[r+1],c=o[r+2],h=o[r+3],d=q.cubicBezier(i,a,c,h);if(Y.intersect(s,d).points.length>0)return!0}return!1}static curveLineContains(t,e,n){for(let o=0;o<t.length-2;o=o+3){const s=t[o],r=t[o+1],i=t[o+2],a=t[o+3],c=q.cubicBezier(s,r,i,a),h=q.circle(e,n);if(Y.intersect(h,c).points.length>0)return!0}return!1}static polyLineContains(t,e,n){const o=q.polyline(t),s=q.circle(e,n);return Y.intersect(s,o).points.length>0}static simpleLineContains(t,e,n){const o=q.line(t[0],t[t.length-1]),s=q.circle(e,n);return Y.intersect(s,o).points.length>0}}class zh{constructor(){p(this,"radius",8)}draw(t,e){const n=t.getDrawPoints();if(n.length<2)return;e.save(),e.beginPath();const o=n[0];e.moveTo(o.x,o.y);for(const s of n)e.lineTo(s.x,s.y);e.stroke(),e.restore()}textContentBounds(t){const e=t.baseProps;return new D(e.x,e.y,e.width,e.height)}borderContains(t,e,n){return null}getConnectAnchor(){return[]}}class Wh{draw(t,e){const n=t.getDrawPoints();if(!(n.length<3)){e.save(),e.beginPath();for(let o=1;o<n.length-2;o=o+3){const s=n[o-1],r=n[o],i=n[o+1],a=n[o+2];e.moveTo(s.x,s.y),e.bezierCurveTo(r.x,r.y,i.x,i.y,a.x,a.y)}e.stroke(),e.restore()}}textContentBounds(t){const e=t.baseProps;return{x:e.x,y:e.y,width:e.width,height:e.height}}borderContains(t,e,n){return null}getConnectAnchor(){return[]}}class Fh{constructor(){p(this,"radius",8)}draw(t,e){const n=t.getDrawPoints();n.length<2||(e.save(),e.beginPath(),t.points.length===2?(e.moveTo(n[0].x,n[0].y),e.lineTo(n[1].x,n[1].y),e.stroke()):this.acrPolyDraw(e,n),e.restore())}textContentBounds(t){const e=t.baseProps;return new D(e.x,e.y,e.width,e.height)}acrPolyDraw(t,e){const n=e[e.length-1],o=this.dealArcPoly(e);for(const s of o)t.moveTo(s.p0.x,s.p0.y),t.lineTo(s.p1.x,s.p1.y),t.arcTo(s.arcDraw.a.x,s.arcDraw.a.y,s.arcDraw.b.x,s.arcDraw.b.y,s.arcDraw.r);t.lineTo(n.x,n.y),t.stroke()}dealArcPoly(t){const e=[];let n=t[0];for(let o=0;o<t.length-2;o=o+1){const s=n,r=t[o+1],i=t[o+2];if(S.judgeHorizon(s,r)){const c=.5*Math.abs(s.x-r.x),h=.5*Math.abs(r.y-i.y),d=c>h?h:c,u=this.radius<d?this.radius:d,f=u,g=r.x>s.x?1:-1,y=i.y>r.y?1:-1;n=new m(r.x,r.y+y*f);const P={p0:s,p1:new m(r.x-g*f,r.y),arcDraw:{a:r,b:n,r:u}};e.push(P)}else{const c=.5*Math.abs(s.y-r.y),h=.5*Math.abs(r.x-i.x),d=c>h?h:c,u=this.radius<d?this.radius:d,f=u,g=r.y>s.y?1:-1,y=i.x>r.x?1:-1;n=new m(r.x+y*f,r.y);const P={p0:s,p1:new m(r.x,r.y-g*f),arcDraw:{a:r,b:n,r:u}};e.push(P)}}return e}borderContains(t,e,n){return null}getConnectAnchor(){return[]}}class Fe{constructor(t,e,n){p(this,"paragraphIndex");p(this,"lineIndex");p(this,"charIndex");this.paragraphIndex=t,this.lineIndex=e,this.charIndex=n}static head(){return new Fe(0,0,-1)}clone(){return new Fe(this.paragraphIndex,this.lineIndex,this.charIndex)}equal(t){return this.paragraphIndex===t.paragraphIndex&&this.lineIndex===t.lineIndex&&this.charIndex===t.charIndex}greaterThan(t){return this.paragraphIndex>t.paragraphIndex?!0:this.paragraphIndex<t.paragraphIndex?!1:this.lineIndex>t.lineIndex?!0:this.lineIndex<t.lineIndex?!1:this.charIndex>t.charIndex?!0:!(this.charIndex<t.charIndex)}}class Cs{constructor(){p(this,"lines",[]);p(this,"index",0);p(this,"x",0);p(this,"y",0);p(this,"width",0);p(this,"height",0);p(this,"paragraphStyle",null)}addLine(t){t.y=this.height,t.index=this.lines.length,this.lines.push(t),this.width=Math.max(t.width,this.width),this.height=this.height+t.height}contains(t){return S.rectContains2(t,{minX:this.x,maxX:this.x+this.width,minY:this.y,maxY:this.y+this.height})}headCursorPosition(){return new Fe(this.index,0,-1)}tailCursorPosition(){if(this.lines.length===0)return new Fe(this.index,-1,-1);const t=this.lines.length-1,n=this.lines[t].getCharLength();return n===0?new Fe(this.index,t,-1):new Fe(this.index,t,n-1)}detect(t){const{x:e,y:n}=t;if(n<0||n>this.height||this.lines.length===0)return null;for(let o=0;o<this.lines.length;o++){const s=this.lines[o];if(n>=s.y&&n<s.y+s.height){const r=new m(t.x-s.x,t.y-s.y),i=s.detect(r);return{lineIndex:s.index,charIndex:i}}}return null}getLine(t){return t<0||this.lines.length===0?null:t>this.lines.length-1?(console.warn("index 超出该段最大数目,fall back处理"),this.lines[this.lines.length-1]):this.lines[t]}draw(t,e){for(const n of this.lines){const o=new m(e.x+this.x,e.y+this.y);n.draw(t,o)}}alignHorizon(t,e){for(const n of this.lines)t===at.Bottom&&(n.x=e-n.width),t===at.Middle&&(n.x=.5*e-.5*n.width)}toString(){let t="";for(const e of this.lines)t+=e.toString();return t+`
|
|
4
|
-
`}toRichTextXML(t){let e="<p>";for(const n of this.lines)e+=n.toRichTextXML(t);return e+"</p>"}prevToRichTextXML(t,e){let n="";for(let o=0;o<t;o++){const s=this.lines[o];n+=s.toRichTextXML(e)}return n}nextToRichTextXML(t,e){let n="";for(let o=t+1;o<this.lines.length;o++){const s=this.lines[o];n+=s.toRichTextXML(e)}return n}}class Gn{constructor(){p(this,"textBlocks",[]);p(this,"index",0);p(this,"x",0);p(this,"y",0);p(this,"width",0);p(this,"height",0);p(this,"boxAscent",0)}contains(t){return S.rectContains2(t,{minX:this.x,maxX:this.x+this.width,minY:this.y,maxY:this.y+this.height})}getCharLength(){let t=0;return this.textBlocks.forEach(e=>t+=e.characters.length),t}detect(t){const{x:e,y:n}=t;if(n<0||e<0)return-1;const o=this.getCharLength();if(n>this.height||e>this.width)return o-1;if(o===0)return-1;let s=0;for(let r=0;r<this.textBlocks.length;r++){const i=this.textBlocks[r];for(let a=0;a<i.characters.length;a++){const c=i.characters[a],h=i.x+c.x+.5*c.width;if(e<h)return s-1;s++}}return o-1}addTextBlock(t){if(this.textBlocks.length>0){const e=this.textBlocks[this.textBlocks.length-1];if(e.fontSize===t.fontSize&&e.fontFamily===t.fontFamily&&e.fontColor===t.fontColor&&e.fontBgColor===t.fontBgColor&&e.bold===t.bold&&e.italic===t.italic&&e.underline===t.underline&&e.strikethrough===t.strikethrough){for(const n of t.characters)e.addCharacter(n);e.text+=t.text,this.width=this.width+t.width,this.height=Math.max(this.height,e.height),this.boxAscent=Math.max(e.height,this.boxAscent);return}}t.x=this.width,t.y=0,this.textBlocks.push(t),this.width=this.width+t.width,this.height=Math.max(this.height,t.height),this.boxAscent=Math.max(t.height,this.boxAscent)}getBlockIndex(t){const e=this.getCharLength();if(t<0||e===0)return this.textBlocks.length>0?{textBlock:this.textBlocks[0],charIndex:-1,blockIndex:0}:null;if(t>e-1){console.warn("index 超出该行最大字符数目,fall back处理");const o=this.textBlocks[this.textBlocks.length-1];return{textBlock:o,charIndex:o.characters.length-1,blockIndex:this.textBlocks.length-1}}let n=0;for(let o=0;o<this.textBlocks.length;o++){const s=this.textBlocks[o];if(t-n<s.characters.length)return{textBlock:s,charIndex:t-n,blockIndex:o};n+=s.characters.length}return null}getCharacter(t){const e=this.getCharLength();if(t<0||e===0)return null;if(t>e-1){console.warn("index 超出该行最大字符数目,fall back处理");const o=this.textBlocks[this.textBlocks.length-1];return{character:o.characters[o.characters.length-1],textBlock:o,charIndex:o.characters.length-1,blockIndex:this.textBlocks.length-1}}let n=0;for(let o=0;o<this.textBlocks.length;o++){const s=this.textBlocks[o];if(t-n<s.characters.length)return{character:s.characters[t-n],textBlock:s,charIndex:t-n,blockIndex:o};n+=s.characters.length}return null}draw(t,e){const n=e.x+this.x,o=e.y+this.y,s=new m(n,o);for(const r of this.textBlocks)r.draw(t,s,this.height)}toString(){let t="";for(const e of this.textBlocks)t+=e.toString();return t}toRichTextXML(t){let e="";for(const n of this.textBlocks)e+=n.toRichTextXML(t);return e}prevToRichTextXML(t,e){let n="";for(let o=0;o<t;o++){const s=this.textBlocks[o];n+=s.toRichTextXML(e)}return n}nextToRichTextXML(t,e){let n="";for(let o=t+1;o<this.textBlocks.length;o++){const s=this.textBlocks[o];n+=s.toRichTextXML(e)}return n}}class mi{constructor(){p(this,"parser",new DOMParser)}parseBooleanAttribute(t){if(t!=null){if(typeof t=="boolean")return t;if(typeof t=="string"){const e=t.toLowerCase().trim();if(e==="true")return!0;if(e==="false")return!1}}}parse(t,e){const n=[],o=this.parseRichText(t);for(const s of o){const r=this.computeTextBlocks(s,e);n.push({textBlocks:r})}return n}escapeXmlText(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}preprocessXmlString(t){return t.replace(/>([^<>]+)</g,(e,n)=>{if(/[&<>"']/.test(n)){const o=[];let s=n.replace(/&(?:amp|lt|gt|quot|apos);/g,r=>(o.push(r),`__ENTITY_${o.length-1}__`));return s=this.escapeXmlText(s),s=s.replace(/__ENTITY_(\d+)__/g,(r,i)=>o[parseInt(i)]),`>${s}<`}return e})}parseRichText(t){if(!t)return[{textBlocks:[]}];const e=this.preprocessXmlString(t),n=this.parser.parseFromString(e,"text/xml"),o=n.querySelector("parsererror");if(o)return console.error("解析富文本样式失败:",o,t),[{textBlocks:[t]}];const s=[],r=n.documentElement;for(const i of r.childNodes){const a=this.flattenNodes(i);s.push({textBlocks:a})}return s}flattenNodes(t){const e=[];for(const n of t.childNodes)if(n.nodeType===Node.TEXT_NODE){const o=n.textContent;o&&e.push(o)}else if(n.nodeType===Node.ELEMENT_NODE){const o=n;if(o.tagName.toLowerCase()==="style"){const r=o.textContent||"",i={text:""};o.childNodes.length>0?i.text=this.flattenNodes(o):i.text=r;const a=o.getAttribute("color");a&&(i.fontColor=a);const c=o.getAttribute("bg-color");c&&(i.fontBgColor=c);const h=o.getAttribute("bold"),d=this.parseBooleanAttribute(h);d!==void 0&&(i.bold=d);const u=o.getAttribute("italic"),f=this.parseBooleanAttribute(u);f!==void 0&&(i.italic=f);const g=o.getAttribute("font-size");g&&(i.fontSize=parseFloat(g));const y=o.getAttribute("underline"),P=this.parseBooleanAttribute(y);P!==void 0&&(i.underline=P);const b=o.getAttribute("strikethrough"),w=this.parseBooleanAttribute(b);w!==void 0&&(i.strikethrough=w),e.push(i)}}return e}computeTextBlocks(t,e){const n=[];for(const o of t.textBlocks)this.makeupTextBlock(o,e,n);return n}makeupTextBlock(t,e,n){if(typeof t=="string"){n.push(this.makeupTextBlockOfText(t,e));return}const o=t.text;if(typeof o=="string"){n.push(this.makeupTextBlockOfCacheTextBlock(t,e));return}if(!(o instanceof Array))return;const s={...e,...this.computeTextProps(t,e)};for(const r of o)this.makeupTextBlock(r,s,n)}makeupTextBlockOfText(t,e){return{text:t,fontSize:e.fontSize,fontFamily:e.fontFamily,fontColor:e.fontColor,fontBgColor:e.fontBgColor,bold:e.bold,italic:e.italic,underline:e.underline,strikethrough:e.strikethrough}}makeupTextBlockOfCacheTextBlock(t,e){return{...this.computeTextProps(t,e),text:t.text}}computeTextProps(t,e){return{text:"",fontSize:t.fontSize!==void 0?t.fontSize:e.fontSize,fontFamily:t.fontFamily!==void 0?t.fontFamily:e.fontFamily,fontColor:t.fontColor!==void 0?t.fontColor:e.fontColor,fontBgColor:t.fontBgColor!==void 0?t.fontBgColor:e.fontBgColor,bold:t.bold!==void 0?t.bold:e.bold,italic:t.italic!==void 0?t.italic:e.italic,underline:t.underline!==void 0?t.underline:e.underline,strikethrough:t.strikethrough!==void 0?t.strikethrough:e.strikethrough}}}class As{constructor(t,e,n,o,s,r){p(this,"charText");p(this,"index",0);p(this,"x");p(this,"y");p(this,"width");p(this,"height");p(this,"boxAscent");this.charText=t,this.x=e,this.y=n,this.width=o,this.height=s,this.boxAscent=r}contains(t){return S.rectContains2(t,{minX:this.x,maxX:this.x+this.width,minY:this.y,maxY:this.y+this.height})}toString(){return this.charText}}class Ro{constructor(){p(this,"segmentWorker",new Intl.Segmenter("en",{granularity:"grapheme"}))}split(t){return Array.from(this.segmentWorker.segment(t)).map(n=>n.segment)}}const Eo=new Ro;class Yh{measureParagraphs(t,e){for(const n of e)this.measure(t,n)}measure(t,e){for(const n of e.textBlocks){const{fontSize:o,fontFamily:s,italic:r,bold:i,text:a}=n;t.font=S.calcFont(o,s,i,r);const c=Eo.split(a),h=[];for(const d of c){const{width:u,height:f,boxAscent:g}=S.measureText(t,d),y=new As(d,0,0,u,f,g);h.push(y)}n.characters=h}}}var ao=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ns(l){return l&&l.__esModule&&Object.prototype.hasOwnProperty.call(l,"default")?l.default:l}function Gh(l){if(l.__esModule)return l;var t=l.default;if(typeof t=="function"){var e=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(l).forEach(function(n){var o=Object.getOwnPropertyDescriptor(l,n);Object.defineProperty(e,n,o.get?o:{enumerable:!0,get:function(){return l[n]}})}),e}var ks=0,Pi=-3;function co(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function Uh(l,t){this.source=l,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=t,this.destLen=0,this.ltree=new co,this.dtree=new co}var bi=new co,Si=new co,Bs=new Uint8Array(30),Rs=new Uint16Array(30),Mi=new Uint8Array(30),vi=new Uint16Array(30),_h=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ii=new co,Ut=new Uint8Array(320);function Ti(l,t,e,n){var o,s;for(o=0;o<e;++o)l[o]=0;for(o=0;o<30-e;++o)l[o+e]=o/e|0;for(s=n,o=0;o<30;++o)t[o]=s,s+=1<<l[o]}function $h(l,t){var e;for(e=0;e<7;++e)l.table[e]=0;for(l.table[7]=24,l.table[8]=152,l.table[9]=112,e=0;e<24;++e)l.trans[e]=256+e;for(e=0;e<144;++e)l.trans[24+e]=e;for(e=0;e<8;++e)l.trans[168+e]=280+e;for(e=0;e<112;++e)l.trans[176+e]=144+e;for(e=0;e<5;++e)t.table[e]=0;for(t.table[5]=32,e=0;e<32;++e)t.trans[e]=e}var Li=new Uint16Array(16);function Es(l,t,e,n){var o,s;for(o=0;o<16;++o)l.table[o]=0;for(o=0;o<n;++o)l.table[t[e+o]]++;for(l.table[0]=0,s=0,o=0;o<16;++o)Li[o]=s,s+=l.table[o];for(o=0;o<n;++o)t[e+o]&&(l.trans[Li[t[e+o]]++]=o)}function jh(l){l.bitcount--||(l.tag=l.source[l.sourceIndex++],l.bitcount=7);var t=l.tag&1;return l.tag>>>=1,t}function _t(l,t,e){if(!t)return e;for(;l.bitcount<24;)l.tag|=l.source[l.sourceIndex++]<<l.bitcount,l.bitcount+=8;var n=l.tag&65535>>>16-t;return l.tag>>>=t,l.bitcount-=t,n+e}function Hs(l,t){for(;l.bitcount<24;)l.tag|=l.source[l.sourceIndex++]<<l.bitcount,l.bitcount+=8;var e=0,n=0,o=0,s=l.tag;do n=2*n+(s&1),s>>>=1,++o,e+=t.table[o],n-=t.table[o];while(n>=0);return l.tag=s,l.bitcount-=o,t.trans[e+n]}function Vh(l,t,e){var n,o,s,r,i,a;for(n=_t(l,5,257),o=_t(l,5,1),s=_t(l,4,4),r=0;r<19;++r)Ut[r]=0;for(r=0;r<s;++r){var c=_t(l,3,0);Ut[_h[r]]=c}for(Es(Ii,Ut,0,19),i=0;i<n+o;){var h=Hs(l,Ii);switch(h){case 16:var d=Ut[i-1];for(a=_t(l,2,3);a;--a)Ut[i++]=d;break;case 17:for(a=_t(l,3,3);a;--a)Ut[i++]=0;break;case 18:for(a=_t(l,7,11);a;--a)Ut[i++]=0;break;default:Ut[i++]=h;break}}Es(t,Ut,0,n),Es(e,Ut,n,o)}function Ci(l,t,e){for(;;){var n=Hs(l,t);if(n===256)return ks;if(n<256)l.dest[l.destLen++]=n;else{var o,s,r,i;for(n-=257,o=_t(l,Bs[n],Rs[n]),s=Hs(l,e),r=l.destLen-_t(l,Mi[s],vi[s]),i=r;i<r+o;++i)l.dest[l.destLen++]=l.dest[i]}}}function Kh(l){for(var t,e,n;l.bitcount>8;)l.sourceIndex--,l.bitcount-=8;if(t=l.source[l.sourceIndex+1],t=256*t+l.source[l.sourceIndex],e=l.source[l.sourceIndex+3],e=256*e+l.source[l.sourceIndex+2],t!==(~e&65535))return Pi;for(l.sourceIndex+=4,n=t;n;--n)l.dest[l.destLen++]=l.source[l.sourceIndex++];return l.bitcount=0,ks}function Qh(l,t){var e=new Uh(l,t),n,o,s;do{switch(n=jh(e),o=_t(e,2,0),o){case 0:s=Kh(e);break;case 1:s=Ci(e,bi,Si);break;case 2:Vh(e,e.ltree,e.dtree),s=Ci(e,e.ltree,e.dtree);break;default:s=Pi}if(s!==ks)throw new Error("Data error")}while(!n);return e.destLen<e.dest.length?typeof e.dest.slice=="function"?e.dest.slice(0,e.destLen):e.dest.subarray(0,e.destLen):e.dest}$h(bi,Si),Ti(Bs,Rs,4,3),Ti(Mi,vi,2,1),Bs[28]=0,Rs[28]=258;var Zh=Qh;const qh=new Uint8Array(new Uint32Array([305419896]).buffer)[0]===18,Ai=(l,t,e)=>{let n=l[t];l[t]=l[e],l[e]=n},Jh=l=>{const t=l.length;for(let e=0;e<t;e+=4)Ai(l,e,e+3),Ai(l,e+1,e+2)};var ed={swap32LE:l=>{qh&&Jh(l)}};const Ni=Zh,{swap32LE:td}=ed,Ds=11,Ln=5,nd=Ds-Ln,od=65536>>Ds,sd=(1<<nd)-1,Ho=2,Os=(1<<Ln)-1,ki=65536>>Ln,rd=1024>>Ln,id=ki+rd+32,ad=1<<Ho;class cd{constructor(t){const e=typeof t.readUInt32BE=="function"&&typeof t.slice=="function";if(e||t instanceof Uint8Array){let n;if(e)this.highStart=t.readUInt32LE(0),this.errorValue=t.readUInt32LE(4),n=t.readUInt32LE(8),t=t.slice(12);else{const o=new DataView(t.buffer);this.highStart=o.getUint32(0,!0),this.errorValue=o.getUint32(4,!0),n=o.getUint32(8,!0),t=t.subarray(12)}t=Ni(t,new Uint8Array(n)),t=Ni(t,new Uint8Array(n)),td(t),this.data=new Uint32Array(t.buffer)}else({data:this.data,highStart:this.highStart,errorValue:this.errorValue}=t)}get(t){let e;return t<0||t>1114111?this.errorValue:t<55296||t>56319&&t<=65535?(e=(this.data[t>>Ln]<<Ho)+(t&Os),this.data[e]):t<=65535?(e=(this.data[ki+(t-55296>>Ln)]<<Ho)+(t&Os),this.data[e]):t<this.highStart?(e=this.data[id-od+(t>>Ds)],e=this.data[e+(t>>Ln&sd)],e=(e<<Ho)+(t&Os),this.data[e]):this.data[this.data.length-ad]}}var ld=cd;const hd=Ns(ld);var Bi={};(function(l){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";(function(e){var n=typeof Uint8Array<"u"?Uint8Array:Array,o=43,s=47,r=48,i=97,a=65,c=45,h=95;function d(g){var y=g.charCodeAt(0);if(y===o||y===c)return 62;if(y===s||y===h)return 63;if(y<r)return-1;if(y<r+10)return y-r+26+26;if(y<a+26)return y-a;if(y<i+26)return y-i+26}function u(g){var y,P,b,w,L,B;if(g.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var H=g.length;L=g.charAt(H-2)==="="?2:g.charAt(H-1)==="="?1:0,B=new n(g.length*3/4-L),b=L>0?g.length-4:g.length;var E=0;function X($){B[E++]=$}for(y=0,P=0;y<b;y+=4,P+=3)w=d(g.charAt(y))<<18|d(g.charAt(y+1))<<12|d(g.charAt(y+2))<<6|d(g.charAt(y+3)),X((w&16711680)>>16),X((w&65280)>>8),X(w&255);return L===2?(w=d(g.charAt(y))<<2|d(g.charAt(y+1))>>4,X(w&255)):L===1&&(w=d(g.charAt(y))<<10|d(g.charAt(y+1))<<4|d(g.charAt(y+2))>>2,X(w>>8&255),X(w&255)),B}function f(g){var y,P=g.length%3,b="",w,L;function B(E){return t.charAt(E)}function H(E){return B(E>>18&63)+B(E>>12&63)+B(E>>6&63)+B(E&63)}for(y=0,L=g.length-P;y<L;y+=3)w=(g[y]<<16)+(g[y+1]<<8)+g[y+2],b+=H(w);switch(P){case 1:w=g[g.length-1],b+=B(w>>2),b+=B(w<<4&63),b+="==";break;case 2:w=(g[g.length-2]<<8)+g[g.length-1],b+=B(w>>10),b+=B(w>>4&63),b+=B(w<<2&63),b+="=";break}return b}e.toByteArray=u,e.fromByteArray=f})(l)})(Bi);const dd=Ns(Bi);var Ri={};const ud=5,Ei=12,pd=13,fd=16,gd=17,yd=22,Hi=28,Di=31,xd=33,Do=34,wd=35,Xs=36,zs=37,Oi=38,md=39,Pd=40,lo=41,bd=42,x=0,M=1,Ee=2,Xi=3,C=4,Sd=[[C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,Xi,C,C,C,C,C,C,C,C,C,C,C],[x,C,C,M,M,C,C,C,C,M,M,x,x,x,x,M,M,M,x,x,C,Ee,C,x,x,x,x,x,x,x,x,M,x],[x,C,C,M,M,C,C,C,C,M,M,M,M,M,x,M,M,M,x,x,C,Ee,C,x,x,x,x,x,x,x,x,M,x],[C,C,C,M,M,M,C,C,C,M,M,M,M,M,M,M,M,M,M,M,C,Ee,C,M,M,M,M,M,M,M,M,M,M],[M,C,C,M,M,M,C,C,C,M,M,M,M,M,M,M,M,M,M,M,C,Ee,C,M,M,M,M,M,M,M,M,M,M],[x,C,C,M,M,M,C,C,C,x,x,x,x,x,x,M,M,M,x,x,C,Ee,C,x,x,x,x,x,x,x,x,M,x],[x,C,C,M,M,M,C,C,C,x,x,x,x,x,x,M,M,M,x,x,C,Ee,C,x,x,x,x,x,x,x,x,M,x],[x,C,C,M,M,M,C,C,C,x,x,M,x,M,x,M,M,M,x,x,C,Ee,C,x,x,x,x,x,x,x,x,M,x],[x,C,C,M,M,M,C,C,C,x,x,M,M,M,x,M,M,M,x,x,C,Ee,C,x,x,x,x,x,x,x,x,M,x],[M,C,C,M,M,M,C,C,C,x,x,M,M,M,M,M,M,M,x,x,C,Ee,C,M,M,M,M,M,x,M,M,M,x],[M,C,C,M,M,M,C,C,C,x,x,M,M,M,x,M,M,M,x,x,C,Ee,C,x,x,x,x,x,x,x,x,M,x],[M,C,C,M,M,M,C,C,C,M,M,M,M,M,x,M,M,M,x,x,C,Ee,C,x,x,x,x,x,x,x,x,M,x],[M,C,C,M,M,M,C,C,C,M,M,M,M,M,x,M,M,M,x,x,C,Ee,C,x,x,x,x,x,x,x,x,M,x],[M,C,C,M,M,M,C,C,C,M,M,M,M,M,x,M,M,M,x,x,C,Ee,C,x,x,x,x,x,x,x,x,M,x],[x,C,C,M,M,M,C,C,C,x,M,x,x,x,x,M,M,M,x,x,C,Ee,C,x,x,x,x,x,x,x,x,M,x],[x,C,C,M,M,M,C,C,C,x,x,x,x,x,x,M,M,M,x,x,C,Ee,C,x,x,x,x,x,x,x,x,M,x],[x,C,C,M,x,M,C,C,C,x,x,M,x,x,x,M,M,M,x,x,C,Ee,C,x,x,x,x,x,x,x,x,M,x],[x,C,C,M,x,M,C,C,C,x,x,x,x,x,x,M,M,M,x,x,C,Ee,C,x,x,x,x,x,x,x,x,M,x],[M,C,C,M,M,M,C,C,C,M,M,M,M,M,M,M,M,M,M,M,C,Ee,C,M,M,M,M,M,M,M,M,M,x],[x,C,C,M,M,M,C,C,C,x,x,x,x,x,x,M,M,M,x,C,C,Ee,C,x,x,x,x,x,x,x,x,M,x],[x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,C,x,x,x,x,x,x,x,x,x,x,x,x],[M,C,C,M,M,M,C,C,C,M,M,M,M,M,x,M,M,M,x,x,C,Ee,C,x,x,x,x,x,x,x,x,M,x],[M,C,C,M,M,M,C,C,C,M,M,M,M,M,M,M,M,M,M,M,C,Ee,C,M,M,M,M,M,M,M,M,M,M],[x,C,C,M,M,M,C,C,C,x,M,x,x,x,x,M,M,M,x,x,C,Ee,C,x,x,x,M,M,x,x,x,M,x],[x,C,C,M,M,M,C,C,C,x,M,x,x,x,x,M,M,M,x,x,C,Ee,C,x,x,x,x,M,x,x,x,M,x],[x,C,C,M,M,M,C,C,C,x,M,x,x,x,x,M,M,M,x,x,C,Ee,C,M,M,M,M,x,x,x,x,M,x],[x,C,C,M,M,M,C,C,C,x,M,x,x,x,x,M,M,M,x,x,C,Ee,C,x,x,x,M,M,x,x,x,M,x],[x,C,C,M,M,M,C,C,C,x,M,x,x,x,x,M,M,M,x,x,C,Ee,C,x,x,x,x,M,x,x,x,M,x],[x,C,C,M,M,M,C,C,C,x,x,x,x,x,x,M,M,M,x,x,C,Ee,C,x,x,x,x,x,M,x,x,M,x],[x,C,C,M,M,M,C,C,C,x,M,x,x,x,x,M,M,M,x,x,C,Ee,C,x,x,x,x,x,x,x,M,M,x],[x,C,C,M,M,M,C,C,C,x,M,x,x,x,x,M,M,M,x,x,C,Ee,C,x,x,x,x,x,x,x,x,M,x],[M,C,C,M,M,M,C,C,C,M,M,M,M,M,x,M,M,M,x,x,C,Ee,C,x,x,x,x,x,x,x,x,M,x],[x,C,C,M,M,x,C,C,C,x,x,x,x,x,x,x,x,x,x,x,C,Ee,C,x,x,x,x,x,x,x,x,M,x]],Md=dd.toByteArray("AAgOAAAAAAAQ4QAAAQ0P8vDtnQuMXUUZx+eyu7d7797d9m5bHoWltKVUlsjLWE0VJNigQoMVqkStEoNQQUl5GIo1KKmogEgqkKbBRki72lYabZMGKoGAjQRtJJDaCCIRiiigREBQS3z+xzOTnZ3O+3HOhd5NfpkzZx7fN9988zivu2M9hGwB28F94DnwEngd/Asc1EtIs9c/bIPDwCxwLDgezHcodyo4w5C+CCwBS8FnwSXgCnA1uFbI93XwbXAbWAfWgx+CzWAb+An4KfgFeAzsYWWfYuFz4CXwGvgb+Dfo6yNkEEwGh4CZYB44FpwI3g1OY+kfBItZOo2fB84Hy8DF4HJwNbiWpV8PVoO1LH4n2NRXyN+KcAd4kNVP9XsY4aPgcfAbsBfs6SniL4K/sPjfEf6HlanXCRkCw2BGvUh/keWfXS/CY+pFXs7x9XHmM94LTmWIeU2cgbxnS/k/B3kf86jDhU8L9V2E40vAFWAlWFUfb++NOL4F3C7JX4/4GiE+hvgWsF0oS7mXldspnN+F493gyXrh9xTav0cg3EvzgVfBG6wsmVSEkxBOBgdPGpd7JI6PnqRvJ68/xlbHof53gPeA94OzwLngk+ACsAwsByvASrAK3MB0Ws3CtQjvBJvAVrADPMDSHkb4CNijaccTwvnf4fiPEs8Lxy+D18A/QU8/xjgYBjPAbDAKTgYLwOngTHAO+EQ/8wuEF4EvsPiVCFf2+9tsFStzA8LVHuXXBsi6QyqzUYiPMR/7Mc7dAx7oL8bzw/3u/Bw8Bp4Az4AXwCtgHzsmDXP5fiF9iiVvly5d0sHngar16NKlS5cuXbp06fLmYlqHXrcd3ph4P0THUY3iXh49novju4S0tzfs5d+JPKewfAsRntZb3K9ZhOMlrO6lCC8An28U9+OuovcPcPxlVu5rCL/VmHh/iHIrzn3fIPu7SN8Axmg+8AOwEWwCm7tp3bRuWjetm5Y8bSu4B9zbKO6ZVsnORrVU3f4uXTqZ2H3sLoyx3eDXjfDndE9qyj6L838CfwVvgFpzYnof4oNgOhgBc8Fos9DrZIQLmtXPP1MmF6wGj4H+KXoWguvADkXaPil+YpuQy8Am8Ey7ODdtmJDF4HowBp4De6HDTNjhfHAHeBr0DBBy0kDxfPbcgSIusgrcWhtnJ8vL+TPix7UIOQtcBq4C28Cr4KRBnANbwSuDE+s50JgyNNFuXbp06XIgsXjIvPafjvXozKY+fVFz/z0LT1uCtKVSWbrOLWPnztG8e0Xfy7ol8XtZJi7WtG+5od2UFXQ/A12vUeS7jp27yVKHjdsU9lXB869TyNvAzt0lpP2oWbwLdjiO78bx/Sz+EMJHwK9Y/LcIfw+eZ3F67/Hl5vh9xX80J+rwX8SvRDhpgL17iPAQMHNArfPrqHPewLheI+AERV6efwV418B4nOZ/H+IfYHV8GOF5LJ3eAz0fx8sM9S0fUNud39O9CulfGZhY5huI3wzWgNvBelbHZoTbNPVpfYjKQpkHwUNgl0LWblbnk0LbbDxr0OMFpL3iqWdu9nWYPlVAWkXY39LnGdCkDbeqv1YNbfcMQ3t9oe8lzm6NH9N1ZB6Ln4BwfkJZJk7RyFnYKt6b/JDQXx9p5X+eFdqOjzM9P9MB/lUlFzr20aXIdzlY4dmn9F3YqtvoO76/2hp/D/xA5Zue88nNyL8GbFbs075X0tyUig3Qd2MCnf//HjnzpbsR3g9+1kHzzVjdnE71/qVBX9rGPUh/ysNWe1neFzvIDi5zAufV1sT0N0poR22wkFUfTOPfA4N2mbZ5fSrqOHSw+IbkSBbOGSzSRgf91/GTUWYBOB2cIZQ/G8cfBZ8CFwrnL8XxF8FKcA24jqXdiPA7Qr61OF7H4mMItwzuv2/YLth1ISt3Hzu3k4W7EH5JqPdRHD/O4k+z8A8IX5Lq3y7Z4nXE9xn6kX6vQ4bKfy+ok+hH+xf3hq9dnTTHhjKd2GmDuWA242iHMq4cC7A8kJ7i8o1+skSa7Jieo38HCWnoNjKFhdSFBxzpZ7QE6lI8N4S14aASZcryaV/WWHw66f6NHuCoxuQxmvM56GX9QMd8Q4D65ywGP+ZzRJuM+zQvx/MOS2VFeqQ4IXnH26zM9Xe6/E6D+4foAzzuajPZp8Qyw5ayZVDWuH0z0BtYRkeIDqH9KO9VbH1btd/lhNqCzvl8zeLnG0S/hnU6baHfpiuO6yy0rd+DHURo/zYF5H26j03rQsip2ndzz82u1z9N4VjWKWeb68Tedpt95HRVXp7H1R6p+/Wt4FPy/PpWwscOLRJ+PVWF/+W0iVyGzs18TIvXkOJ1Wxm66vSXz+vylenrZcj1ub439W+K8RNCGTJi2p/TJ1K23VaXr35tRpnzmjxequgfcfyk6B/TGBVlyedsNgpdd/h+W1U3P99QyFPNo1X3TwpM/WLTIWYfoBqXrv6iskHZ/RFr79R6hIyHBrH3f1nrUVnjP8SnZZ+rYtzr9Exld5MNbPNErusAPg+77u/eDOPftU9yj39TH7rezxd1LvsZQJlzkWlOirG/79zjMj/mtHUKu7vKy+3/LnXr9okyKedjX5/0He9iP/j63LwOQdarEVlfy8OO/Lqw023j6xcqmwxLiOd6heM2i9cV9LJy8jMJ23yQ+rpbfu7EQ/pXE8KYvUSqvVnb4XzZa6LrHMXHR+zcLvqWbm/Bn0/HzIs6fWPHoat8XfnDKmZGxRxeMbn2UqZ5Q94nmcZRbqqUXbZ8+lcjE+cPX11t814orvvAXNcG8vqj2vvk1MGn3anlj0bIT72v47bvE+Lc98T9b6r7AKn6j+8Duf7D0nnZx/j7Zjn0j9nbpSTndaLr9WNLivP+iN23xF7L+fqv6ZouFyb78jxVXvv5jJ9YUs9/sddO8h7KNg5jrhfaJGztT6G7KF+1d6yCmD5Kdb2fan60rSc552fZr3zeQ9DpnPp+Si5cx5Ktv2QfSzF/mMbWdOm46rFI4XstnU9xeqX4NKb7TKEdcr6pZOK3ID1k/LvFHkVczEuZLEDr499YqvqBym1aEHWgcvoYOtv0M91qQl5TfpO/in6rWx8OVpT1Wedkv3f5xom3T/xeR/6Gx6V86PWAOB4bBpqWdN+yTcVxjIyGRz/FrDGu6w/3d7kPm8StX8RyPu+uuvpNju/vTLJV37GpvoM0oZPnW87VLnL/5pDno1NoW1R6yedU6TyUv3u19a3KFnIbTLYz+ZCLP4T0tU1uivFgso0pnsJ/UtXvarNY28Xq5cvkBDrQP/E5ZaiuQwwfmTlsOiQRU1fMuqrDd/3ISSuwjOwXOfTyGUMpZIXq4GpLn3pUcdfzch2x7XO1u2uZHOPb1G6b3Xg9PH1IIWeEpJlPQtqos2EKW8b0u8rnuP1UeVLoXJb9be0uG9nnbchjU+XTszT5VeNBThPHnc5OKj1U9aj0GTHIVaGy1YhEWT4ixns00DT+XEzWn/7VAsIc63Cov3OdyhwjrnaqQqZvWKXdypRdlq+k8msZ031U+Rm4fA+3TtyeR9hwfW9G9yxDN0fZMN33F+9TE6md4hwoxumfaUzI9fN3PFT3xVV2msrQ3UsnChm6Nulk8TndpS28D3zX9tTIPsF/z7Am5OkTjm1tI1JZW74+4VgsZ0N3L1yXV3WeP5uR7TGHHdvC3JQlxybfpd22tDlk/2eofRK8TzrN/qnar/K/OUTth6I/+jAnEptNbPvFHP2gs40N3+dfMWtwqvVct7/wfd8gtQ7imifial9ZJ9/3IHLYU6eDj3+4PhsNhX+vwvcWLnu6kGfEMe8DuciPfUfGZB8X/7HJy/Gefe5n+VRGFd/wyP2ta7/LO4yh/sbLV/k9lev6kfO9Dt/5U67b1/6u/epqB1U9Me23jfHY9sscAg4tkbLl+e4/U36rJ9ddxfd6sg5vq5ice42Wpk/pb9FOJ36/W9tpv4kbC79nUbZceX8Zu6/qJ+P3WvhvA8v3reh7Jbn2d6rrNC7XNZTLma4Ba0JI9efX2uLzF5scG/w9UNU1ZxW+ymUfzELeTllXlQ1rUuhzjS5fp9c964iFBOqeSz63bU065nZKdU+mDEz3qHIjjifquw0pnb/raRtvrnsYcb46ihT3taoYz6brdNW9l6rWRnE/navdPn1XlR1km7hcz1WlH/elKuSOSvLLuE8U6m8uzwRdfcGl73VyTHuyMvzJ1Sa2cWDTP/Z63Kc94n2B1PYr24dz1JlyHLlcP+S4B6vD1c9EW4q2LWstCvUjeVy63k/LMYdUNd5D1xQfvVTzX1VjkMsUv88N8VH5fReVn/Fjn++/h6X6Q8a6b1/q3g/i/ewi0/Scs8zxXeV6mWIOUPlPzBgdFerW+bZrm2P18dnjuK6HunEp+rHvPMXbr+sHVb/lnL+pTP57jPw9Cvk3PW178JD9qChfzuvTf7Htl38L1QUf/VKu9SFjwWbTWPvFEvu7Uq76y7+31g6QlYPc669pbsm9Xur2LWI9Pu8ypfDXqm3A2z8s1FWGn4ntL9NfQu2oSlftX9uetvTtv7J8Ql4zxfXGZ3zk8PeQ9w59x2uMfqI8/q5eKh/l9cb2rwsu9rSNl06ZP2Pmxtz+rNMx93yno0n2/82rVH7rQ+y9P15H6FyRun9ViH81ATmffI7nJ5r8uXXW6enbP6b/B8/l5OifVHYLnb9S39s2zcc+Ph+rh8+eQgVPS72elzGWY/tUtbbabBpDiI7yN1q6/4th2y+ErAc5+9BVvu/7KamJbWNZeuqI/R4tRf+YyD1HmOZM1bMV3/14Sn10c0Xu+Sj1nOXb5jL73ncdy02uvlXZNde65dOHYl7Vs4KYuS6FzWLn2zJlpZqPXPVPOa5yzKOyn1VhT9lmMfdbfH7D11Wf2PXN5h9y+dD287+qxgSnaYmnIrRtIb8pJe6/Uv9OVer6Whn0zfGO/BEloZI9ojmfAlUflClDd178bTmVHVTpZXOkAlk/lb42UujmI89HH5V+cl7XtowY6vTxLVWok6UrGzoGTHN+bB+6ri05687VNpvfuvRfaP2uMlNQth1D5JjGelm/8yn+9p3p/7qk9gnfeddXZmq/Sm333PJT659Kv1zjNbZ9uv2Oi//67CV8/N1nj1DmviyXDNVeJkaeaX8UsyesYg8cu2+NvdaPfb+lLDu5tvt/"),vd=new hd(Md),zi=function(l){switch(l){case xd:return Ei;case md:case Pd:case bd:return Ei;case wd:return ud;default:return l}},Wi=function(l){switch(l){case zs:case Oi:return Do;case lo:return yd;default:return l}};class Ws{constructor(t,e=!1){this.position=t,this.required=e}}class Id{nextCodePoint(){const t=this.string.charCodeAt(this.pos++),e=this.string.charCodeAt(this.pos);return 55296<=t&&t<=56319&&56320<=e&&e<=57343?(this.pos++,(t-55296)*1024+(e-56320)+65536):t}nextCharClass(){return zi(vd.get(this.nextCodePoint()))}getSimpleBreak(){switch(this.nextClass){case lo:return!1;case Do:case zs:case Oi:return this.curClass=Do,!1;case Xs:return this.curClass=Xs,!1}return null}getPairTableBreak(t){let e=!1;switch(Sd[this.curClass][this.nextClass]){case x:e=!0;break;case M:e=t===lo;break;case Ee:if(e=t===lo,!e)return e=!1,e;break;case Xi:if(t!==lo)return e;break}return this.LB8a&&(e=!1),this.LB21a&&(this.curClass===fd||this.curClass===gd)?(e=!1,this.LB21a=!1):this.LB21a=this.curClass===pd,this.curClass===Hi?(this.LB30a++,this.LB30a==2&&this.nextClass===Hi&&(e=!0,this.LB30a=0)):this.LB30a=0,this.curClass=this.nextClass,e}nextBreak(){if(this.curClass==null){let t=this.nextCharClass();this.curClass=Wi(t),this.nextClass=t,this.LB8a=t===Di,this.LB30a=0}for(;this.pos<this.string.length;){this.lastPos=this.pos;const t=this.nextClass;if(this.nextClass=this.nextCharClass(),this.curClass===Do||this.curClass===Xs&&this.nextClass!==zs)return this.curClass=Wi(zi(this.nextClass)),new Ws(this.lastPos,!0);let e=this.getSimpleBreak();if(e===null&&(e=this.getPairTableBreak(t)),this.LB8a=this.nextClass===Di,e)return new Ws(this.lastPos)}return this.lastPos<this.string.length?(this.lastPos=this.string.length,new Ws(this.string.length)):null}constructor(t){this.string=t,this.pos=0,this.lastPos=0,this.curClass=null,this.nextClass=null,this.LB8a=!1,this.LB21a=!1,this.LB30a=0}}Ri=Id;class Td{split(t){const e=new Ri(t);let n=0,o;const s=[];for(;o=e.nextBreak();){const r=t.slice(n,o.position);s.push(r),o.required,n=o.position}return s}}const Fi=new Td;class dn{constructor(){p(this,"text");p(this,"characters",[]);p(this,"fontSize");p(this,"fontFamily");p(this,"fontColor");p(this,"fontBgColor");p(this,"bold");p(this,"italic");p(this,"underline");p(this,"strikethrough");p(this,"x",0);p(this,"y",0);p(this,"width",0);p(this,"height",0);this.text="",this.characters=[],this.fontSize=14,this.fontFamily="Noto Sans",this.fontColor="#000000",this.fontBgColor="",this.bold=!1,this.italic=!1,this.underline=!1,this.strikethrough=!1}static create(t){const e=new dn;e.fontSize=t.fontSize,e.fontFamily=t.fontFamily,e.fontColor=t.fontColor,e.fontBgColor=t.fontBgColor,e.bold=t.bold,e.italic=t.italic,e.underline=t.underline,e.strikethrough=t.strikethrough;const n=t.characters||[];let o="";for(const s of n)e.addCharacter(s),o+=s.charText;return e.text=o,e}static createByStyleAndCharacter(t,e=[]){const n=new dn;n.fontSize=t.fontSize,n.fontFamily=t.fontFamily,n.fontColor=t.fontColor,n.fontBgColor=t.fontBgColor,n.bold=t.bold,n.italic=t.italic,n.underline=t.underline,n.strikethrough=t.strikethrough;let o="";for(const s of e)n.addCharacter(s),o+=s.charText;return n.text=o,n}addCharacter(t){t.x=this.width,t.index=this.characters.length,this.characters.push(t),this.width=this.width+t.width,this.height=Math.max(this.height,t.height)}draw(t,e,n){const{fontBgColor:o,underline:s,strikethrough:r,fontColor:i,fontSize:a,fontFamily:c,bold:h,italic:d}=this,u=e.x+this.x,f=e.y+this.y;if(o&&(t.save(),t.fillStyle=o,t.fillRect(u,f,this.width,n),t.restore()),t.save(),t.fillStyle=i,t.font=S.calcFont(a,c,h,d),t.textAlign="left",t.textBaseline="bottom",t.fillText(this.text,u,f+n),t.restore(),s){const g=.08333333333333333*a;t.strokeStyle=i,t.lineWidth=g,t.beginPath(),t.moveTo(u,f+n-g),t.lineTo(u+this.width,f+n-g),t.stroke()}r&&(t.strokeStyle=i,t.lineWidth=1/12*a,t.beginPath(),t.moveTo(u,f+n-.4*this.height),t.lineTo(u+this.width,f+n-.4*this.height),t.stroke())}computeLineBreakPoint(t){const e=Fi.split(this.text);let n=0;const o=[];for(let s=0;s<e.length-1;s++){const r=e[s],i=Eo.split(r);n+=i.length,o.push(n)}if(!t)o.push(this.characters.length);else{const s=Fi.split(this.text+t.text);let r=0;for(const i of s){const a=Eo.split(i);if(r+=a.length,r===this.characters.length)return o.push(this.characters.length),o;if(r>this.characters.length)return o}}return o}toString(){let t="";for(const e of this.characters)t+=e.toString();return t}toRichTextXML(t){return`<style ${this.computeStyle(t)}>${this.text}</style>`}computeStyle(t){let e="";return this.fontColor!==t.fontColor&&(e+=`color='${this.fontColor}' `),this.fontBgColor!==t.fontBgColor&&(e+=`bg-color='${this.fontBgColor}' `),this.fontSize!==t.fontSize&&(e+=`font-size='${this.fontSize}' `),this.bold!==t.bold&&(e+=`bold=${this.bold?"'true'":"'false'"} `),this.italic!==t.italic&&(e+=`italic=${this.italic?"'true'":"'false'"} `),this.underline!==t.underline&&(e+=`underline=${this.underline?"'true'":"'false'"} `),this.strikethrough!==t.strikethrough&&(e+=`strikethrough=${this.strikethrough?"'true'":"'false'"} `),e}getPrevText(t){let e="";for(let n=0;n<t+1;n++)e+=this.characters[n].charText;return e}getNextText(t){let e="";const n=Math.max(t+1,0);for(let o=n;o<this.characters.length;o++)e+=this.characters[o].charText;return e}insertTextToRichTextXML(t,e,n){const o=this.getPrevText(e)+t+this.getNextText(e);return`<style ${this.computeStyle(n)}>${o}</style>`}}class Ld{work(t,e,n){let o=[],s=n.line.width;for(const r of t.characters)if(s+r.width<e)o.push(r),s+=r.width;else{if(o.length>0){const i=dn.createByStyleAndCharacter(t,o);n.line.addTextBlock(i)}n.paragraph.addLine(n.line),o=[],n.line=new Gn,o.push(r),s=r.width}if(o.length>0){const r=dn.createByStyleAndCharacter(t,o);n.line.addTextBlock(r)}}}const Cd=new Ld;class ho{checkValid(t,e){const{paragraphIndex:n,lineIndex:o,charIndex:s}=e;if(n<0||o<0||s<-1||n>t.paragraphs.length-1)return console.warn("警告,光标位置异常,",e),null;const r=t.paragraphs[n];if(o>r.lines.length-1)return console.warn("警告,光标位置异常,",e),null;const i=r.lines[o],a=i.getCharLength();return s>a-1?(console.warn("警告,光标位置异常,",e),null):{paragraph:r,line:i}}moveRight(t,e){const{paragraphIndex:n,lineIndex:o,charIndex:s}=e,r=this.checkValid(t,e);if(!r)return e;const{paragraph:i,line:a}=r;if(e.equal(t.tailTextCursorPosition()))return e;const c=a.getCharLength();return o===i.lines.length-1&&s===c-1?new Fe(n+1,0,-1):s===c-1?new Fe(n,o+1,-1):new Fe(n,o,s+1)}moveLeft(t,e){const{paragraphIndex:n,lineIndex:o,charIndex:s}=e,r=this.checkValid(t,e);if(!r)return e;const{paragraph:i,line:a}=r;if(e.equal(t.headTextCursorPosition()))return e;if(o===0&&s===-1)return t.paragraphs[n-1].tailCursorPosition();if(s===-1){const h=i.lines[o-1].getCharLength();return h>0?new Fe(n,o-1,h-2):new Fe(n,o-1,-1)}return new Fe(n,o,s-1)}moveUp(t,e){const{paragraphIndex:n,lineIndex:o,charIndex:s}=e,r=this.checkValid(t,e);if(!r)return e;const{paragraph:i,line:a}=r;if(n===0&&o===0)return e;const{relativePos:c,height:h}=t.getPosByCursorPosition(e),d=new m(c.x,c.y-1);return t.detect(d)}moveDown(t,e){const{paragraphIndex:n,lineIndex:o,charIndex:s}=e,r=this.checkValid(t,e);if(!r)return e;const{paragraph:i}=r;if(n===t.paragraphs.length-1&&o===i.lines.length-1)return e;const{relativePos:a,height:c}=t.getPosByCursorPosition(e),h=new m(a.x,a.y+c+1);return t.detect(h)}}const Ad="pingfang",le=5,Nd=2,kd=5,Bd=50,Rd="main_text_id",Ed=14,Hd=10,Yi=8,Oo=2,Gi=.4;class Dd{computeStyle(t,e,n,o,s){if(!s){t.paragraphStyle=null;return}const r=this.firstLineHeight(t),i=this.computePrefixToken(s.orderIndex,s.level),a={level:s.level,orderIndex:s.orderIndex,paraIndex:s.paraIndex,width:n,lineHeight:r,prefixToken:i,color:o};t.paragraphStyle=a}computePrefixToken(t,e){switch(e%3){case 0:return t.toString();case 1:return this.numberToLetter(t);case 2:return this.numberToRoman(t);default:return t.toString()}}numberToLetter(t){if(t<1)return"a";const e=(t-1)%26+97;return String.fromCharCode(e)}numberToRoman(t){if(t<1)return"I";const e=[[1e3,"M"],[900,"CM"],[500,"D"],[400,"CD"],[100,"C"],[90,"XC"],[50,"L"],[40,"XL"],[10,"X"],[9,"IX"],[5,"V"],[4,"IV"],[1,"I"]];let n="",o=t;for(const[s,r]of e)for(;o>=s;)n+=r,o-=s;return n}computeParagraphX(t,e,n){let o=0;if(n&&(o+=Yi),!e)return o;const{level:s}=e;return o+(s+1)*t}computePrefixWidth(t,e){const{fontSize:n,fontFamily:o,bold:s,italic:r}=e;t.font=S.calcFont(n,o,s,r);const{width:i,height:a}=S.measureText(t,"aaa"),c=S.measureText(t,"aa");return{width:i,height:a,prefixWidth:c.width}}draw(t,e,n){if(!e.paragraphStyle)return;const o=e.paragraphStyle.width,s=e.paragraphStyle.lineHeight,r=this.firstLineX(e),i=n.x+e.x+r-o,a=n.y+e.y+s;if(e.paragraphStyle.orderIndex>=0){t.fillText(e.paragraphStyle.prefixToken+".",i,a);return}const c=e.paragraphStyle.color||"#000000";t.strokeStyle=c,t.lineWidth=1,t.beginPath();const h=e.paragraphStyle.level%3,d=.1*o;switch(h){case 1:t.arc(i+.5*o,a-.5*s+d,d,0,Math.PI*2),t.stroke();return;case 2:t.rect(i+.5*o,a-.5*s,2*d,2*d),t.fill(),t.stroke();return;case 0:default:t.arc(i+.5*o,a-.5*s+d,d,0,Math.PI*2),t.fill(),t.stroke();return}}firstLineHeight(t){if(t.lines.length===0)return 20;const e=t.lines[0];return e.height<.1?20:e.height}firstLineX(t){if(t.lines.length===0)return 0;const e=t.lines[0];return e.height<.1?0:e.x}}class Od{constructor(){p(this,"textQuoteInfo",null);p(this,"paraStyleMap",new Map)}reset(){this.textQuoteInfo=null,this.paraStyleMap.clear()}getQuoteStyle(t){return this.paraStyleMap.get(t)}work(t,e){t.paraQuoteStyles.forEach(s=>this.paraStyleMap.set(s.paraIndex,s));let n=null;const o=[];for(let s=0;s<e.paragraphs.length;s++){const r=e.paragraphs[s],i=this.paraStyleMap.get(s);i&&i.quote?n?n.y1=r.y+r.height:n={x:0,y0:r.y,y1:r.y+r.height}:n&&(o.push(n),n=null)}n&&o.push(n),o.length>0&&(this.textQuoteInfo={quoteLines:o})}draw(t,e){if(this.textQuoteInfo){t.lineWidth=Oo,t.strokeStyle="#8F959E",t.lineCap="round",t.globalAlpha=1,t.beginPath();for(const n of this.textQuoteInfo.quoteLines){const{x:o,y1:s,y0:r}=n;t.moveTo(e.x+o+Oo,e.y+r),t.lineTo(e.x+o+Oo,e.y+s)}t.stroke()}}}class uo{constructor(){p(this,"paragraphs",[]);p(this,"x",0);p(this,"y",0);p(this,"width",0);p(this,"height",0);p(this,"textProps",new Ge);p(this,"paragraphProps",new qt);p(this,"paragraphQuoteProps",new Dt);p(this,"rect",new D);p(this,"prefixDrawer",new Dd);p(this,"textBlockMeasureWorker",new Yh);p(this,"richTextHelper",new mi);p(this,"cursorMoveWorker",new ho);p(this,"textQuoteLineWorker",new Od)}draw(t,e,n=1){t.save();for(let d=0;d<this.paragraphs.length;d++){const u=this.paragraphs[d],f=new m(e.x+this.x,e.y+this.y),g=this.textQuoteLineWorker.getQuoteStyle(d);g&&g.quote?t.globalAlpha=Gi*n:t.globalAlpha=n,u.draw(t,f)}const{fontSize:o,fontColor:s,fontFamily:r,bold:i,italic:a}=this.textProps,c=e.x+this.x,h=e.y+this.y;t.globalAlpha=n,t.textBaseline="bottom",t.textAlign="left",t.fillStyle=s,t.font=S.calcFont(o,r,i,a);for(const d of this.paragraphs)this.prefixDrawer.draw(t,d,{x:c,y:h});this.textQuoteLineWorker.draw(t,{x:c,y:h}),t.restore()}contains(t){return S.rectContains2(t,{minX:this.rect.x,maxX:this.rect.x+this.rect.width,minY:this.rect.y,maxY:this.rect.y+this.rect.height})}detect(t){let{x:e,y:n}=t;if(this.paragraphs.length===0)return new Fe(-1,-1,-1);if(n<this.y)return this.headTextCursorPosition();if(e<this.x)return this.headTextCursorPosition();if(n>this.y+this.height)return this.tailTextCursorPosition();if(e>this.x+this.rect.width)return this.tailTextCursorPosition();e=e-this.x,n=n-this.y;for(const o of this.paragraphs){const s=new m(e-o.x,n-o.y),r=o.detect(s);if(r)return new Fe(o.index,r.lineIndex,r.charIndex)}return this.tailTextCursorPosition()}headTextCursorPosition(){return Fe.head()}tailTextCursorPosition(){const t=this.paragraphs[this.paragraphs.length-1],e=t.lines[t.lines.length-1],n=e.getCharLength(),o=n===0?-1:n-1;return new Fe(t.index,e.index,o)}addParagraph(t){t.y=this.height,t.index=this.paragraphs.length,this.paragraphs.push(t),this.width=Math.max(t.x+t.width,this.width),this.height=this.height+t.height}getParagraph(t){return t<0||this.paragraphs.length===0?null:t>this.paragraphs.length-1?(console.warn("index 超出该文本最大段落数目,fall back处理"),this.paragraphs[this.paragraphs.length-1]):this.paragraphs[t]}getPosByCursorPosition(t){const e=this.textProps,n=new m(this.x,this.y),{charIndex:o,lineIndex:s,paragraphIndex:r}=t,i=this.getParagraph(r);if(i===null)return{relativePos:n,height:e.fontSize};n.x+=i.x,n.y+=i.y;const a=i.getLine(s);if(a===null)return{relativePos:n,height:e.fontSize};n.x+=a.x,n.y+=a.y;const c=a.getCharacter(o);if(c===null)return{relativePos:n,height:a.height};const{character:h,textBlock:d}=c;return n.x+=d.x+h.x+h.width,n.y+=h.y,{relativePos:n,height:a.height}}reset(){this.paragraphs=[],this.x=0,this.y=0,this.width=0,this.height=0,this.textQuoteLineWorker.reset()}computeParagraphMap(){const t=new Map;for(const e of this.paragraphProps.paragraphStyles)t.set(e.paraIndex,e);return t}computeParagraphQuoteMap(){const t=new Map;for(const e of this.paragraphQuoteProps.paraQuoteStyles)t.set(e.paraIndex,e);return t}typesetting(t,e=this.textProps,n,o=this.paragraphProps,s=this.paragraphQuoteProps){this.reset(),this.rect=n,this.x=0,this.y=0,this.textProps=e,this.paragraphProps=o,this.paragraphQuoteProps=s;const r=this.computeParagraphMap(),i=this.computeParagraphQuoteMap(),{sizeMode:a}=e,c=a===We.autoWidth,h=this.richTextHelper.parse(e.richText,e);this.textBlockMeasureWorker.measureParagraphs(t,h);const{width:d,prefixWidth:u}=this.prefixDrawer.computePrefixWidth(t,this.textProps);for(let f=0;f<h.length;f++){const g=h[f],y=r.get(f),P=i.get(f),b=this.prefixDrawer.computeParagraphX(d,y,P),w=this.typesettingParagraph(t,g,n.width-b,c);w.x=b,this.prefixDrawer.computeStyle(w,b,u,e.fontColor,y),this.addParagraph(w)}this.alignVertical(n),this.alignHorizon(n),this.textQuoteLineWorker.work(this.paragraphQuoteProps,this)}typesettingParagraph(t,e,n,o){if(e.textBlocks.length===0){const c=new Cs,h=new Gn,{fontSize:d,fontFamily:u,bold:f,italic:g}=this.textProps,{height:y}=S.measureTextByFont(t,"1",d,u,f,g);return h.height=y,c.addLine(h),c}const s=new Cs,r=new Gn,i={paragraph:s,line:r};for(let c=0;c<e.textBlocks.length;c++){const h=e.textBlocks[c],d=c===e.textBlocks.length-1?null:e.textBlocks[c+1],u=dn.create(h);if(u.characters.length===0){const{fontSize:f,fontFamily:g,bold:y,italic:P}=u,{height:b}=S.measureTextByFont(t,"1",f,g,y,P);u.height=b}this.lineAddTextBlock(u,d,n,o,i)}const a=i.paragraph.lines;return(a.length===0||i.line!==a[a.length-1])&&i.paragraph.addLine(i.line),s}lineAddTextBlock(t,e,n,o,s){if(o)s.line.addTextBlock(t);else if(s.line.width+t.width<n)s.line.addTextBlock(t);else{const r=t.computeLineBreakPoint(e),i=S.judgeLineBreak(r,t,s.line,n);if(r.length===0||i<0)s.line.textBlocks.length>0&&(s.paragraph.addLine(s.line),s.line=new Gn),Cd.work(t,n,s);else{const a=t.characters.slice(0,i),c=dn.createByStyleAndCharacter(t,a);s.line.addTextBlock(c),s.paragraph.addLine(s.line),s.line=new Gn;const h=t.characters.slice(i,t.characters.length),d=dn.createByStyleAndCharacter(t,h);this.lineAddTextBlock(d,e,n,o,s);return}}}alignVertical(t){const e=this.textProps.verticalAlign;if(e===at.Top){this.y=t.y;return}if(e===at.Bottom){this.y=t.y+t.height-this.height;return}if(e===at.Middle){this.y=t.y+.5*t.height-.5*this.height;return}}alignHorizon(t){this.x=this.rect.x;let e=this.textProps.horizonAlign;this.textProps.sizeMode===We.autoWidth&&(e=at.Top);for(const n of this.paragraphs)n.alignHorizon(e,t.width-n.x)}modifyPosInEditing(t,e){const n=new m;let o=!1;const{relativePos:s,height:r}=this.getPosByCursorPosition(e);return s.x<t.x&&(n.x=t.x-s.x,o=!0),s.x>t.x+t.width&&(n.x=-(s.x-(t.x+t.width)),o=!0),s.y<t.y&&(n.y=t.y-s.y,o=!0),s.y+r>t.y+t.height&&(n.y=-(s.y+r-(t.y+t.height)),o=!0),o&&(this.x+=n.x,this.y+=n.y),o}resetFromEditing(t){this.alignVertical(t),this.x=t.x}isEmptyText(){if(this.paragraphs.length!==1)return!1;const t=this.paragraphs[0];return t.lines.length===0||t.lines.length===1&&t.lines[0].toString()===""}toRichTextXML(){let t="<root>";for(const e of this.paragraphs)t+=e.toRichTextXML(this.textProps);return t+"</root>"}toString(){let t="";for(const e of this.paragraphs)t+=e.toString();return t}prevParagraphToXML(t){let e="";for(let n=0;n<t;n++)e+=this.paragraphs[n].toRichTextXML(this.textProps);return e}nextParagraphToXML(t){let e="";for(let n=t+1;n<this.paragraphs.length;n++)e+=this.paragraphs[n].toRichTextXML(this.textProps);return e}nextCursorPos(t,e){let n=t;for(let o=0;o<e;o++)n=this.cursorMoveWorker.moveRight(this,n);return n}prevCursorPos(t,e){let n=t;for(let o=0;o<e;o++)n=this.cursorMoveWorker.moveLeft(this,n);return n}getTextCursorPosByIndex(t){let e=-1;for(let n=0;n<this.paragraphs.length;n++){const o=this.paragraphs[n];for(let s=0;s<o.lines.length;s++){const i=o.lines[s].getCharLength();if(e===t)return new Fe(n,s,-1);for(let a=0;a<i;a++)if(e++,e===t)return new Fe(n,s,a)}n<this.paragraphs.length-1&&e++}return this.tailTextCursorPosition()}getIndexByTextCursorPos(t){const{paragraphIndex:e,lineIndex:n,charIndex:o}=t;if(e<0||e>=this.paragraphs.length)return-1;let s=0;for(let c=0;c<e;c++){const h=this.paragraphs[c];for(let d=0;d<h.lines.length;d++){const u=h.lines[d];s+=u.getCharLength()}s++}const r=this.paragraphs[e];if(n<0||n>=r.lines.length)return s-1;for(let c=0;c<n;c++){const h=r.lines[c];s+=h.getCharLength()}const i=r.lines[n];if(o===-1)return s-1;const a=i.getCharLength();return o>=a?s+a-1:s+o}}class Ui{constructor(){p(this,"characters",[]);p(this,"width",0)}addCharacter(t){this.characters.push(t),this.width=this.width+t.width}}class Fs{handle(t,e){const n=this.layoutToPoints(t,e);return this.getUpdateNodeData(t.id,n)}getNodePos(t,{x:e,y:n}){const o=new m,{width:s,height:r}=t.baseProps;return o.x=e*s,o.y=n*r,t.toGlobal(o)}getUpdateNodeData(t,e){return{infos:[{id:t,props:[{type:I.Line,points:e}]}]}}}class Xo extends Fs{enable(t){return t.shapeType===he.Line}layoutToPoints(t,e){const{start:n,end:o}=t.connectProps,s=t.globalLinePoints;let r=s[0],i=s[s.length-1];if(n){const d=e.nodeManager.getNode(n.objectId);d&&(r=this.getNodePos(d,n))}if(o){const d=e.nodeManager.getNode(o.objectId);d&&(i=this.getNodePos(d,o))}const a=[r,i],c=t.globalTransform().inverseMatrix();return a.map(d=>c.crossPoint(d))}layoutToPointsPro(t,e){return[t.point,e.point]}}function Xd(l,t,e){return(t.x-l.x)*(e.y-l.y)-(t.y-l.y)*(e.x-l.x)}function zd(l){if(l.length!==4)return!1;const t=[];for(let e=0;e<4;e++){const n=l[e],o=l[(e+1)%4],s=l[(e+2)%4],r=Xd(n,o,s);if(r===0)return!1;t.push(Math.sign(r))}return t.every(e=>e===t[0])}class zo{splitCurve(t){const e=t.getHalfTPos();return this.computeCurveControlPoint(t.p0,e,t.p3)}computeCurvePointsForLine(t,e,n=t.points){const{start:o,end:s}=t.connectProps,r=this.computeConnectEndInfo(o,e),i=this.computeConnectEndInfo(s,e);return this.computeCurvePoints(n,r,i)}computeConnectEndInfo(t,e){let n;if(t){const o=this.computeEndType(t,e);o&&(n=this.computeEndDirection(o.endType,o.nodeAngle))}return n}computeEndDirection(t,e){let n=0;switch(t){case de.Top:n=-.5*Math.PI;break;case de.Left:n=Math.PI;break;case de.Bottom:n=.5*Math.PI;break;default:case de.Right:n=0;break}const o=e/180*Math.PI;n+=o;const s=Math.cos(n),r=Math.sin(n);return{direction:{x:s,y:r}}}computeEndType(t,e){if(t){const n=e.getNode(t.objectId);if(n)return{endType:S.computeNodeConnectEnd(t,0),nodeAngle:n.baseProps.angle}}return null}computeCurvePoints(t,e,n){const o=S.computeBezierCurvesByPoints(t),s=o[0],r=s.p0;let i=new m(r.x,r.y);if(e){const f=.4*S.distance(r,s.p3),g=Math.sqrt(e.direction.x*e.direction.x+e.direction.y*e.direction.y);i=new m(r.x+f*(e.direction.x/g),r.y+f*(e.direction.y/g))}const a=[r,i];for(let u=1;u<o.length;u++){const f=o[u],g=f.p0,y=f.p3,{lP:P,midPoint:b,rP:w}=this.computeCurveControlPoint(i,g,y);a.push(P,b,w),i=w}const c=o[o.length-1],h=c.p3;let d=new m(h.x,h.y);if(n){const f=.4*S.distance(h,c.p0),g=Math.sqrt(n.direction.x*n.direction.x+n.direction.y*n.direction.y);d=new m(h.x+f*(n.direction.x/g),h.y+f*(n.direction.y/g))}return a.push(d,h),a}computeCurveControlPoint(t,e,n){const o=S.distance(t,e),s=S.distance(e,n),r=S.lineAngle(e,t),i=S.lineAngle(e,n),a=r-i,c=i+.5*a,h=c+.5*Math.PI,d=c-.5*Math.PI,u=e.x+.4*o*Math.cos(h),f=e.y+.4*o*Math.sin(h),g=e.x+.4*s*Math.cos(d),y=e.y+.4*s*Math.sin(d),P=new m(u,f),b=new m(g,y);return zd([n,t,P,b])?{lP:P,midPoint:e,rP:b}:{lP:b,midPoint:e,rP:P}}}class po extends Fs{constructor(){super(...arguments);p(this,"bezierWorker",new zo)}enable(e){return e.shapeType===he.Curve}handle(e,n){const{start:o,end:s}=e.connectProps,r=[...e.globalLinePoints];let i=r[0],a=r[r.length-1];if(o){const u=n.nodeManager.getNode(o.objectId);u&&(i=this.getNodePos(u,o),r.splice(0,1,i))}if(s){const u=n.nodeManager.getNode(s.objectId);u&&(a=this.getNodePos(u,s),r.splice(r.length-1,1,a))}const c=this.bezierWorker.computeCurvePointsForLine(e,n.nodeManager,r),h=e.globalTransform().inverseMatrix(),d=c.map(u=>h.crossPoint(u));return this.getUpdateNodeData(e.id,d)}computeLinePoints(e,n){const o=[],s=new m(n.x-e.x,n.y-e.y);if(Math.abs(s.x)>Math.abs(s.y)){const r=new m(e.x+.5*s.x,e.y),i=new m(n.x-.5*s.x,n.y);o.push(e,r,i,n)}else{const r=new m(e.x,e.y+.5*s.y),i=new m(n.x,n.y-.5*s.y);o.push(e,r,i,n)}return o}layoutToPoints(e,n){const{start:o,end:s}=e.connectProps,r=e.points,i=r[0],a=r[r.length-1];return this.computeLinePoints(i,a)}layoutToPointsPro(e,n){return this.computeLinePoints(e.point,n.point)}}class fo{constructor(t){p(this,"startPoint");this.startPoint=t}}class R{static computeZLinePoints(t,e,n){if(n){const r=new m(t.x,.5*(t.y+e.y)),i=new m(e.x,.5*(t.y+e.y));return[t,r,i,e]}const o=new m(.5*(t.x+e.x),t.y),s=new m(.5*(t.x+e.x),e.y);return[t,o,s,e]}static computeLLinePoints(t,e,n){if(n){const s=new m(t.x,e.y);return[t,s,e]}const o=new m(e.x,t.y);return[t,o,e]}}class Wd extends fo{constructor(e,n){super(e);p(this,"rect");this.rect=n}bottom(e,n){const o=this.startPoint;if(e.y<o.y)return Math.abs(o.x-e.x)<.01?[o,e]:R.computeZLinePoints(o,e,!0);const s=new m(.5*(o.x+e.x),o.y-A);if(Math.abs(s.x-this.rect.x-.5*this.rect.width)<.5*this.rect.width||Math.abs(s.x-n.x-.5*n.width)<.5*n.width)if(o.x>e.x){const c=new m(Math.min(this.rect.x-A,n.x-A),Math.min(n.y-A,this.rect.y-A)),h=new m(e.x,Math.max(this.rect.y+this.rect.height+A,n.y+n.height+A)),d=R.computeLLinePoints(o,c,!0),u=R.computeLLinePoints(c,h,!0);return u.shift(),[...d,...u,e]}else{const c=new m(n.x+n.width+A,Math.min(n.y-A,this.rect.y-A)),h=new m(e.x,Math.max(this.rect.y+this.rect.height+A,n.y+n.height+A)),d=R.computeLLinePoints(o,c,!0),u=R.computeLLinePoints(c,h,!0);return u.shift(),[...d,...u,e]}const r=new m(e.x,e.y+A),i=R.computeLLinePoints(o,s,!0),a=R.computeLLinePoints(s,r,!0);return a.shift(),[...i,...a,e]}left(e,n){const o=this.startPoint;if(e.y<o.y&&e.x>o.x)return R.computeLLinePoints(o,e,!0);if(e.y<o.y){const a=new m(Math.min(this.rect.x-A,n.x-A),.5*(o.y+e.y));if(Math.abs(a.y-this.rect.y-.5*this.rect.height)<.5*this.rect.height||Math.abs(a.y-n.y-.5*n.height)<.5*n.height){const d=new m(Math.min(this.rect.x-A,n.x-A),Math.min(this.rect.y-A,n.y-A)),u=R.computeLLinePoints(o,d,!0),f=R.computeLLinePoints(d,e,!0);return f.shift(),[...u,...f]}const c=R.computeLLinePoints(o,a,!0),h=R.computeLLinePoints(a,e,!0);return h.shift(),[...c,...h]}if(e.x>this.rect.x+this.rect.width+A){const a=new m(.5*(this.rect.x+this.rect.width+n.x),this.rect.y-A),c=R.computeLLinePoints(o,a,!0),h=R.computeLLinePoints(a,e,!0);return h.shift(),[...c,...h]}const s=new m(Math.min(this.rect.x-A,n.x-A),this.rect.y-A),r=R.computeLLinePoints(o,s,!0),i=R.computeLLinePoints(s,e,!0);return i.shift(),[...r,...i]}right(e,n){const o=this.startPoint;if(e.y<o.y&&e.x<o.x)return R.computeLLinePoints(o,e,!0);if(e.y<o.y){const a=new m(Math.max(this.rect.x+this.rect.width+A,n.x+n.width+A),.5*(o.y+e.y));if(Math.abs(a.y-this.rect.y-.5*this.rect.height)<.5*this.rect.height||Math.abs(a.y-n.y-.5*n.height)<.5*n.height){const d=new m(Math.min(this.rect.x+this.rect.width+A,n.x+n.width+A),Math.min(this.rect.y-A,n.y-A)),u=R.computeLLinePoints(o,d,!0),f=R.computeLLinePoints(d,e,!0);return f.shift(),[...u,...f]}const c=R.computeLLinePoints(o,a,!0),h=R.computeLLinePoints(a,e,!0);return h.shift(),[...c,...h]}if(e.x<this.rect.x-A){const a=new m(.5*(this.rect.x+n.x),this.rect.y-A),c=R.computeLLinePoints(o,a,!0),h=R.computeLLinePoints(a,e,!0);return h.shift(),[...c,...h]}const s=new m(Math.min(this.rect.x+this.rect.width+A,n.x+n.width+A),this.rect.y-A),r=R.computeLLinePoints(o,s,!0),i=R.computeLLinePoints(s,e,!0);return i.shift(),[...r,...i]}top(e,n){const o=this.startPoint;if(e.y>this.rect.y+this.rect.height+A&&Math.abs(e.x-this.rect.x-.5*this.rect.width)<.5*this.rect.width){if(e.x>o.x){const d=new m(this.rect.x+this.rect.width+A,this.rect.y-A),u=new m(e.x,n.y-A),f=R.computeLLinePoints(o,d,!0),g=R.computeLLinePoints(d,u,!0);return g.shift(),[...f,...g,e]}const i=new m(this.rect.x-A,this.rect.y-A),a=new m(e.x,n.y-A),c=R.computeLLinePoints(o,i,!0),h=R.computeLLinePoints(i,a,!0);return h.shift(),[...c,...h,e]}if(n.y+n.height<this.rect.y){if(e.x>o.x){const d=new m(n.x-A,this.rect.y-A),u=new m(e.x,n.y-A),f=R.computeLLinePoints(o,d,!0),g=R.computeLLinePoints(d,u,!0);return g.shift(),[...f,...g,e]}const i=new m(n.x+n.width+A,this.rect.y-A),a=new m(e.x,n.y-A),c=R.computeLLinePoints(o,i,!0),h=R.computeLLinePoints(i,a,!0);return h.shift(),[...c,...h,e]}const s=new m(e.x,Math.min(this.rect.y-A,n.y-A));return[...R.computeLLinePoints(o,s,!0),e]}toPoint(e){if(S.rectContains(e,new D(this.rect.x-A,this.rect.y,2*A,this.rect.height))){const r=new m(this.rect.x-A,this.rect.y-A),i=R.computeLLinePoints(this.startPoint,r,!0),a=R.computeLLinePoints(r,e,!0);return a.shift(),[...i,...a]}if(S.rectContains(e,new D(this.rect.x+this.rect.width-A,this.rect.y,2*A,this.rect.height))){const r=new m(this.rect.x+this.rect.width+A,this.rect.y-A),i=R.computeLLinePoints(this.startPoint,r,!0),a=R.computeLLinePoints(r,e,!0);return a.shift(),[...i,...a]}if(S.rectContains(e,new D(this.rect.x,this.rect.y+this.rect.height-A,this.rect.width,2*A))){const r=new m(this.rect.x-A,this.rect.y-A),i=new m(e.x,this.rect.y+this.rect.height+A),a=R.computeLLinePoints(this.startPoint,r,!0),c=R.computeLLinePoints(r,i,!0);return c.shift(),[...a,...c,e]}if(S.rectContains(e,new D(this.rect.x,this.rect.y-A,this.rect.width,2*A))){const r=new m(e.x,this.rect.y-A);return[...R.computeLLinePoints(this.startPoint,r,!0),e]}if(e.y<this.startPoint.y)return R.computeZLinePoints(this.startPoint,e,!0);if(e.x<this.rect.x||e.x>this.rect.x+this.rect.width)return[...R.computeLLinePoints(this.startPoint,new m(e.x,this.rect.y-A),!0),e];if(e.x<this.rect.x+.5*this.rect.width){const r=new m(this.rect.x-A,this.rect.y-A),i=R.computeLLinePoints(this.startPoint,r,!0),a=R.computeLLinePoints(r,e,!0);return a.shift(),[...i,...a]}const n=new m(this.rect.x+this.rect.width+A,this.rect.y-A),o=R.computeLLinePoints(this.startPoint,n,!0),s=R.computeLLinePoints(n,e,!0);return s.shift(),[...o,...s]}}class _i extends fo{bottom(t,e){const n=this.startPoint;if(t.y<n.y)return R.computeZLinePoints(n,t,!0);if(S.inDistance(n.x,e.x,e.width))if(n.x<e.x+.5*e.width){const r=new m(e.x-A,e.y+e.height+A),i=R.computeLLinePoints(n,r,!1),a=R.computeLLinePoints(r,t,!1);return a.shift(),[...i,...a]}else{const r=new m(e.x+e.width+A,e.y+e.height+A),i=R.computeLLinePoints(n,r,!1),a=R.computeLLinePoints(r,t,!1);return a.shift(),[...i,...a]}const o=new m(t.x,e.y+e.height+A);return[...R.computeLLinePoints(n,o,!0),t]}left(t,e){const n=this.startPoint;if(t.x>n.x)return R.computeZLinePoints(n,t,!1);if(S.inDistance(n.y,e.y,e.height))if(n.y<e.y+.5*e.height){const r=new m(e.x-A,e.y-A),i=R.computeLLinePoints(n,r,!0),a=R.computeLLinePoints(r,t,!0);return a.shift(),[...i,...a]}else{const r=new m(e.x-A,e.y+e.height+A),i=R.computeLLinePoints(n,r,!0),a=R.computeLLinePoints(r,t,!0);return a.shift(),[...i,...a]}const o=new m(e.x-A,t.y);return[...R.computeLLinePoints(n,o,!1),t]}right(t,e){const n=this.startPoint;if(t.x<n.x)return R.computeZLinePoints(n,t,!1);if(S.inDistance(n.y,e.y,e.height))if(n.y<e.y+.5*e.height){const r=new m(e.x+e.width+A,e.y-A),i=R.computeLLinePoints(n,r,!0),a=R.computeLLinePoints(r,t,!0);return a.shift(),[...i,...a]}else{const r=new m(e.x+e.width+A,e.y+e.height+A),i=R.computeLLinePoints(n,r,!0),a=R.computeLLinePoints(r,t,!0);return a.shift(),[...i,...a]}const o=new m(e.x+e.width+A,t.y);return[...R.computeLLinePoints(n,o,!1),t]}toPoint(t){return S.computePolyLinePoints(this.startPoint,t)}top(t,e){const n=this.startPoint;if(t.y>n.y)return R.computeZLinePoints(n,t,!0);if(S.inDistance(n.x,e.x,e.width))if(n.x<e.x+.5*e.width){const r=new m(e.x-A,e.y-A),i=R.computeLLinePoints(n,r,!1),a=R.computeLLinePoints(r,t,!1);return a.shift(),[...i,...a]}else{const r=new m(e.x+e.width+A,e.y-A),i=R.computeLLinePoints(n,r,!1),a=R.computeLLinePoints(r,t,!1);return a.shift(),[...i,...a]}const o=new m(t.x,e.y-A);return[...R.computeLLinePoints(n,o,!0),t]}}class Fd extends fo{constructor(e,n){super(e);p(this,"rect");this.rect=n}bottom(e,n){const o=this.startPoint;if(e.y+A<this.rect.y&&S.inDistance(e.x,this.rect.x,this.rect.width))if(e.x>this.rect.x+.5*this.rect.width){const i=new m(this.rect.x+this.rect.width+A,this.rect.y+this.rect.height+A),a=new m(e.x,n.y+n.height+A),c=R.computeLLinePoints(o,i,!0),h=R.computeLLinePoints(i,a,!0);return h.shift(),[...c,...h,e]}else{const i=new m(this.rect.x-A,this.rect.y+this.rect.height+A),a=new m(e.x,n.y+n.height+A),c=R.computeLLinePoints(o,i,!0),h=R.computeLLinePoints(i,a,!0);return h.shift(),[...c,...h,e]}if(o.y+A<n.y&&S.inDistance(o.x,n.x,n.width)){if(o.x<n.x+.5*n.width){const d=new m(n.x-A,this.rect.y+this.rect.height+A),u=new m(e.x,n.y+n.height+A),f=R.computeLLinePoints(o,d,!0),g=R.computeLLinePoints(d,u,!0);return g.shift(),[...f,...g,e]}const i=new m(n.x+n.width+A,this.rect.y+this.rect.height+A),a=new m(e.x,n.y+n.height+A),c=R.computeLLinePoints(o,i,!0),h=R.computeLLinePoints(i,a,!0);return h.shift(),[...c,...h,e]}const s=new m(e.x,Math.max(n.y+n.height+A,this.rect.y+this.rect.height+A));return[...R.computeLLinePoints(o,s,!0),e]}left(e,n){const o=this.startPoint;if(e.x>o.x&&e.y>o.y)return R.computeLLinePoints(o,e,!0);if(e.x>this.rect.x+this.rect.width+A&&e.y<o.y){const a=new m(this.rect.x+this.rect.width+A,this.rect.y+this.rect.height+A),c=R.computeLLinePoints(o,a,!0),h=R.computeLLinePoints(a,e,!0);return h.shift(),[...c,...h]}if(e.x<this.rect.x+this.rect.width+A){const a=new m(Math.min(n.x-A,this.rect.x-A),Math.max(n.y+n.height+A,this.rect.y+this.rect.height+A)),c=R.computeLLinePoints(o,a,!0),h=R.computeLLinePoints(a,e,!0);return h.shift(),[...c,...h]}const s=new m(n.x-A,n.y-A),r=R.computeLLinePoints(o,s,!0),i=R.computeLLinePoints(s,e,!0);return i.shift(),[...r,...i]}right(e,n){const o=this.startPoint;if(e.x<o.x&&e.y>o.y)return R.computeLLinePoints(o,e,!0);if(n.x+n.width>this.rect.x-A){if(n.y<this.rect.y+this.rect.height+A){const a=new m(Math.max(n.x+n.width+A,this.rect.x+this.rect.width+A),Math.max(this.rect.y+this.rect.height+A,n.y+n.height+A)),c=R.computeLLinePoints(o,a,!0),h=R.computeLLinePoints(a,e,!0);return h.shift(),[...c,...h]}const s=new m(n.x+n.width+A,this.rect.y+this.rect.height+A),r=R.computeLLinePoints(o,s,!0),i=R.computeLLinePoints(s,e,!0);return i.shift(),[...r,...i]}if(e.y<this.rect.y+this.rect.height+A){const s=new m(this.rect.x-A,this.rect.y+this.rect.height+A),r=R.computeLLinePoints(o,s,!0),i=R.computeLLinePoints(s,e,!0);return i.shift(),[...r,...i]}return R.computeLLinePoints(o,e,!0)}toPoint(e){const n=this.startPoint;if(e.y>n.y)return R.computeZLinePoints(n,e,!0);if(S.inDistance(e.x,this.rect.x,this.rect.width))if(e.x<this.rect.x+.5*this.rect.width){const r=new m(this.rect.x-A,this.rect.y+this.rect.height+A),i=R.computeLLinePoints(n,r,!0),a=R.computeLLinePoints(r,e,!0);return a.shift(),[...i,...a]}else{const r=new m(this.rect.x+this.rect.width+A,this.rect.y+this.rect.height+A),i=R.computeLLinePoints(n,r,!0),a=R.computeLLinePoints(r,e,!0);return a.shift(),[...i,...a]}const o=new m(n.x,this.rect.y+this.rect.height+A),s=R.computeLLinePoints(o,e,!1);return[n,...s]}top(e,n){const o=this.startPoint;if(e.y>o.y)return R.computeZLinePoints(o,e,!0);if(n.x+n.width+A<this.rect.x){const c=new m(n.x+n.width+A,this.rect.y+this.rect.height+A),h=new m(e.x,n.y-A),d=R.computeLLinePoints(o,c,!0),u=R.computeLLinePoints(c,h,!0);return u.shift(),[...d,...u,e]}if(n.x+n.width<o.x){const c=new m(n.x+-A,this.rect.y+this.rect.height+A),h=new m(e.x,n.y-A),d=R.computeLLinePoints(o,c,!0),u=R.computeLLinePoints(c,h,!0);return u.shift(),[...d,...u,e]}if(n.x>this.rect.x+this.rect.width+A){const c=new m(n.x-A,this.rect.y+this.rect.height+A),h=new m(e.x,n.y-A),d=R.computeLLinePoints(o,c,!0),u=R.computeLLinePoints(c,h,!0);return u.shift(),[...d,...u,e]}const s=new m(Math.max(n.x+n.width+A,this.rect.x+this.rect.width+A),this.rect.y+this.rect.height+A),r=new m(e.x,n.y-A),i=R.computeLLinePoints(o,s,!0),a=R.computeLLinePoints(s,r,!0);return a.shift(),[...i,...a,e]}}class Yd extends fo{constructor(e,n){super(e);p(this,"rect");this.rect=n}bottom(e,n){const o=this.startPoint;if(e.y<o.y){if(e.x<o.x)return R.computeLLinePoints(o,e,!1);const a=new m(this.rect.x-A,n.y+n.height+A),c=R.computeLLinePoints(o,a,!1),h=R.computeLLinePoints(a,e,!1);return h.shift(),[...c,...h]}if(e.y>o.y&&e.x<o.x){const a=new m(this.rect.x-A,e.y+A),c=R.computeLLinePoints(o,a,!1),h=R.computeLLinePoints(a,e,!1);return h.shift(),[...c,...h]}const s=new m(this.rect.x-A,e.y+A),r=R.computeLLinePoints(o,s,!1),i=R.computeLLinePoints(s,e,!1);return i.shift(),[...r,...i]}left(e,n){const o=this.startPoint;if(e.y<this.rect.y){const i=new m(Math.min(this.rect.x-A,n.x-A),e.y);return[...R.computeLLinePoints(o,i,!1),e]}if(e.y>this.rect.y+this.rect.height){const i=new m(Math.min(this.rect.x-A,n.x-A),e.y);return[...R.computeLLinePoints(o,i,!1),e]}if(e.y<this.rect.y+this.rect.height&&e.x>this.rect.x+this.rect.width){const i=new m(this.rect.x-A,this.rect.y-A),a=new m(n.x-A,e.y),c=R.computeLLinePoints(o,i,!1),h=R.computeLLinePoints(i,a,!1);return h.shift(),[...c,...h,e]}const s=new m(Math.min(this.rect.x-A,n.x-A),e.y);return[...R.computeLLinePoints(o,s,!1),e]}right(e,n){const o=this.startPoint;if(e.x<o.x)return R.computeZLinePoints(o,e,!1);if(e.y<o.y){const c=new m(this.rect.x-A,n.y+n.height+A),h=new m(n.x+n.width+A,e.y),d=R.computeLLinePoints(o,c,!1),u=R.computeLLinePoints(c,h,!1);return u.shift(),[...d,...u,e]}const s=new m(this.rect.x-A,n.y-A),r=new m(n.x+n.width+A,e.y),i=R.computeLLinePoints(o,s,!1),a=R.computeLLinePoints(s,r,!1);return a.shift(),[...i,...a,e]}toPoint(e){const n=this.startPoint;if(e.x>n.x&&e.y<this.rect.y){const r=new m(this.rect.x-A,e.y);return[...R.computeLLinePoints(n,r,!1),e]}if(e.x>n.x&&e.y>this.rect.y&&e.y<n.y){const r=new m(this.rect.x-A,this.rect.y-A),i=R.computeLLinePoints(n,r,!1),a=R.computeLLinePoints(r,e,!1);return a.shift(),[...i,...a]}if(e.x>n.x&&e.y>n.y&&e.y<this.rect.y+this.rect.height){const r=new m(this.rect.x-A,this.rect.y+this.rect.height+A),i=R.computeLLinePoints(n,r,!1),a=R.computeLLinePoints(r,e,!1);return a.shift(),[...i,...a]}if(e.x<n.x)return R.computeZLinePoints(n,e,!1);const o=new m(this.rect.x-A,e.y);return[...R.computeLLinePoints(n,o,!1),e]}top(e,n){const o=this.startPoint;if(e.x>o.x&&e.y<this.rect.y+this.rect.height+A){const s=new m(this.rect.x-A,Math.min(this.rect.y-A,n.y-A)),r=R.computeLLinePoints(o,s,!1),i=R.computeLLinePoints(s,e,!1);return i.shift(),[...r,...i]}if(e.y<o.y+2&&e.x<o.x){const s=new m(this.rect.x-A,n.y-A),r=R.computeLLinePoints(o,s,!1),i=R.computeLLinePoints(s,e,!1);return i.shift(),[...r,...i]}if(e.x>o.x&&e.y>this.rect.y+this.rect.height+A){const s=new m(this.rect.x-A,this.rect.y+this.rect.height+A),r=R.computeLLinePoints(o,s,!1),i=R.computeLLinePoints(s,e,!1);return i.shift(),[...r,...i]}return R.computeLLinePoints(o,e,!1)}}class Gd extends fo{constructor(e,n){super(e);p(this,"rect");this.rect=n}bottom(e,n){const o=this.startPoint;if(e.x>o.x){if(e.y<o.y)return R.computeLLinePoints(o,e,!1);const a=new m(this.rect.x+this.rect.width+A,n.y+n.height+A),c=R.computeLLinePoints(o,a,!1),h=R.computeLLinePoints(a,e,!1);return h.shift(),[...c,...h]}if(e.y<this.rect.y){const a=new m(this.rect.x+this.rect.width+A,n.y+n.height+A),c=R.computeLLinePoints(o,a,!1),h=R.computeLLinePoints(a,e,!1);return h.shift(),[...c,...h]}const s=new m(this.rect.x+this.rect.width+A,Math.max(n.y+n.height+A,this.rect.y+this.rect.height+A)),r=R.computeLLinePoints(o,s,!1),i=R.computeLLinePoints(s,e,!1);return i.shift(),[...r,...i]}left(e,n){const o=this.startPoint;if(e.x>o.x)return R.computeZLinePoints(o,e,!1);if(e.y<this.rect.y){const c=new m(this.rect.x+this.rect.width+A,n.y+n.height+A),h=new m(n.x-A,e.y),d=R.computeLLinePoints(o,c,!1),u=R.computeLLinePoints(c,h,!1);return u.shift(),[...d,...u,e]}if(e.y>this.rect.y+this.rect.height){const c=new m(this.rect.x+this.rect.width+A,n.y-A),h=new m(n.x-A,e.y),d=R.computeLLinePoints(o,c,!1),u=R.computeLLinePoints(c,h,!1);return u.shift(),[...d,...u,e]}if(e.y<this.rect.y+.5*this.rect.height){const c=new m(this.rect.x+this.rect.width+A,Math.min(n.y-A,this.rect.y-A)),h=new m(n.x-A,e.y),d=R.computeLLinePoints(o,c,!1),u=R.computeLLinePoints(c,h,!1);return u.shift(),[...d,...u,e]}const s=new m(this.rect.x+this.rect.width+A,Math.max(n.y+n.height+A,this.rect.y+this.rect.height+A)),r=new m(n.x-A,e.y),i=R.computeLLinePoints(o,s,!1),a=R.computeLLinePoints(s,r,!1);return a.shift(),[...i,...a,e]}right(e,n){const o=this.startPoint;if(e.y<this.rect.y||e.y>this.rect.y+this.rect.height){const c=new m(Math.max(n.x+n.width+A,this.rect.x+this.rect.width+A),e.y);return[...R.computeLLinePoints(o,c,!1),e]}if(e.y<this.rect.y+.5*this.rect.height){const c=new m(this.rect.x+this.rect.width+A,this.rect.y-A),h=new m(n.x+n.width+A,e.y),d=R.computeLLinePoints(o,c,!1),u=R.computeLLinePoints(c,h,!1);return u.shift(),[...d,...u,e]}const s=new m(this.rect.x+this.rect.width+A,this.rect.y+this.rect.height+A),r=new m(n.x+n.width+A,e.y),i=R.computeLLinePoints(o,s,!1),a=R.computeLLinePoints(s,r,!1);return a.shift(),[...i,...a,e]}toPoint(e){const n=this.startPoint;if(e.x>n.x)return R.computeZLinePoints(n,e,!1);if(e.y<this.rect.y||e.y>this.rect.y+this.rect.height){const i=new m(this.rect.x+this.rect.width+A,e.y);return[...R.computeLLinePoints(n,i,!1),e]}if(e.y<this.rect.y+.5*this.rect.height){const i=new m(this.rect.x+this.rect.width+A,this.rect.y-A),a=R.computeLLinePoints(n,i,!1),c=R.computeLLinePoints(i,e,!1);return c.shift(),[...a,...c]}const o=new m(this.rect.x+this.rect.width+A,this.rect.y+this.rect.height+A),s=R.computeLLinePoints(n,o,!1),r=R.computeLLinePoints(o,e,!1);return r.shift(),[...s,...r]}top(e,n){const o=this.startPoint;if(e.y>o.y&&e.x>o.x)return R.computeLLinePoints(o,e,!1);if(e.y>this.rect.y+this.rect.height){const a=new m(this.rect.x+this.rect.width+A,this.rect.y+this.rect.height+A),c=R.computeLLinePoints(o,a,!1),h=R.computeLLinePoints(a,e,!1);return h.shift(),[...c,...h]}if(n.x<this.rect.x+this.rect.width+A){const a=new m(Math.max(this.rect.x+this.rect.width+A,n.x+n.width+A),Math.min(n.y-A,this.rect.y-A)),c=R.computeLLinePoints(o,a,!1),h=R.computeLLinePoints(a,e,!1);return h.shift(),[...c,...h]}const s=new m(this.rect.x+this.rect.width+A,n.y-A),r=R.computeLLinePoints(o,s,!1),i=R.computeLLinePoints(s,e,!1);return i.shift(),[...r,...i]}}class Ze{static mockPointermoveEvent(t,e){return{pointerId:1,width:1,height:1,pressure:.5,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,type:"pointermove",pointerType:"mouse",isPrimary:!0,bubbles:!0,cancelable:!0,composed:!0,clientX:t.x,clientY:t.y,...e}}static getNodePos(t,{x:e,y:n}){const o=new m,{width:s,height:r}=t.baseProps;return o.x=e*s,o.y=n*r,t.toGlobal(o)}static computeConnectInfo(t,e,n,o=!1){const s=t.globalLinePoints,r={point:o?s[s.length-1]:s[0]};if(e){const i=n.nodeManager.getNode(e.objectId);i&&(r.nodeConnect={rect:D.rectNode2Rect(i.getBounds()),endType:S.computeNodeConnectEnd(e,i.baseProps.angle)},r.point=this.getNodePos(i,e))}return r}static computeLinePoints(t,e,n,o,s){const r=o.detect(F.NodeEdge,n),i=!S.pressMeta(n),c={point:s.alignLineEndAndDrawAlignLines(n,o,o.getSelectNodes(),i)};return r&&(c.point=new m(r.point.x,r.point.y),c.nodeConnect={rect:D.rectNode2Rect(r.node.getBounds()),endType:S.computeNodeConnectEnd(r.relativePos,r.node.baseProps.angle)}),e.layoutToPointsPro(t,c)}static trimAngle(t){const e=Math.floor(t/360);return t-e*360}static calculateAngle(t,e){return Math.abs(t.x-e.x)<.01?e.y>t.y?90:-90:Math.atan2(e.y-t.y,e.x-t.x)/Math.PI*180}static calculateAngle2(t,e){return Math.abs(t.x-e.x)<.01?e.y>t.y?.5*Math.PI:-.5*Math.PI:Math.atan2(e.y-t.y,e.x-t.x)}static trimPoint(t){return new m(Math.floor(t.x),Math.floor(t.y))}static overlapHorizonVertical(t,e,n){if(Ze.judgeHorizon(t,e)){if(t.y<n.minY||t.y>n.maxY)return!1;const s=t.x>e.x?e.x:t.x,r=t.x<e.x?e.x:t.x;if(s>n.maxX||r<n.minX)return!1}else{if(t.x<n.minX||t.x>n.maxX)return!1;const s=t.y>e.y?e.y:t.y,r=t.y<e.y?e.y:t.y;if(s>n.maxY||r<n.minY)return!1}return!0}static overlapHorizon(t,e,n,o,s){const r=o.y>s.y?s.y:o.y,i=o.y<s.y?s.y:o.y;if(r>n||i<n)return!1;const a=o.x>s.x?s.x:o.x,c=o.x<s.x?s.x:o.x;return!(a>e||c<t)}static overlapVertical(t,e,n,o,s){const r=o.x>s.x?s.x:o.x,i=o.x<s.x?s.x:o.x;if(r>n||i<n)return!1;const a=o.y>s.y?s.y:o.y,c=o.y<s.y?s.y:o.y;return!(a>e||c<t)}static overlapSimpleLine(t,e,n){if(this.overlapHorizon(n.minX,n.maxX,n.minY,t,e)||this.overlapHorizon(n.minX,n.maxX,n.maxY,t,e)||this.overlapVertical(n.minY,n.maxY,n.maxX,t,e)||this.overlapVertical(n.minY,n.maxY,n.minX,t,e))return!0;const o=t.x>e.x?e.x:t.x,s=t.x<e.x?e.x:t.x,r=t.y>e.y?e.y:t.y,i=t.y<e.y?e.y:t.y;return s<=n.maxX&&o>=n.minX&&i<=n.maxY&&r>=n.minY}static overlapPolyLine(t,e){for(let n=0;n<t.length-1;n++){const o=t[n],s=t[n+1];if(this.overlapHorizonVertical(o,s,e))return!0}return!1}static interactRect(t,e){return{minX:Math.max(t.minX,e.minX),maxX:Math.min(t.maxX,e.maxX),minY:Math.max(t.minY,e.minY),maxY:Math.min(t.maxY,e.maxY)}}static needDrawByDelete(t,e,n,o,s){const r=t.nodeManager.tree.search(e),i=new Set;for(const c of r){const h=t.nodeManager.nodeMap.get(c.id);h&&i.add(h)}s||i.add(o);const a=[...i];return a.sort((c,h)=>c.zIndex-h.zIndex),a}static layout(t,e){const n=[];return S.doubleMiddleInsertPoint(t,e,n),n}static judgeHorizon(t,e,n=.01){return Math.abs(t.y-e.y)<n}static judgeVertical(t,e,n=.01){return Math.abs(t.x-e.x)<n}static getOfflineCanvas(t,e,n){const o=D.rectNode2Rect(t),s=document.createElement("canvas");s.width=n*o.width,s.height=n*o.height;const r=s.getContext("2d");r.scale(n,n),r.translate(-o.x,-o.y);const i=e.searchNodesByRectNode(t);for(const a of i)a.drawOnGLCtx(r);return s}}class $i{constructor(t){p(this,"modes",[]);p(this,"currentMode");this.modes=t.modes,this.currentMode=t.modes[t.modes.length-1]}onEvent(t,e){this.reset(t,e);const n=this.convertInteractiveEvent(t,e);this.detect(n,e),this.currentMode.work(n,e),this.afterOnEvent(n,e)}refreshEvent(t,e){const n=t.lastInteractiveEvent.originEvent,o=new m(n.clientX,n.clientY),s=Ze.mockPointermoveEvent(o,e);s.target=t.gmlRender.canvas,this.onEvent(s,t)}detect(t,e){if(this.currentMode.canBeExit(t,e)){for(const n of this.modes)if(n.canBeEnable(t,e)){this.currentMode=n;return}}}reset(t,e){var n;e.reset();for(const[o,s]of e.detectors)s.reset();t.type!==((n=e.lastInteractiveEvent)==null?void 0:n.type)&&(e.lastDiffTypeEvent=e.lastInteractiveEvent)}afterOnEvent(t,e){this.record(t,e)}record(t,e){e.lastInteractiveEvent=t}convertInteractiveEvent(t,e){const n=e.gmlRender.canvas.getBoundingClientRect(),o=new m(t.clientX-n.x,t.clientY-n.y),s=e.gmlRender.transformToGlobal(o);return{clientPoint:new m(t.clientX,t.clientY),globalPoint:s,type:this.convertEventType(t,e),originEvent:t}}convertEventType(t,e){const n=t.type;return n==="pointerdown"?be.pointerDown:n==="pointermove"?t.target!=e.gmlRender.canvas?be.pointermoveOutside:be.pointermove:n==="pointerup"?be.pointerup:be.unknown}}class Ud{constructor(){p(this,"isWorking",!1);p(this,"initialTouchInfo",null);p(this,"lastTouchInfo",null);p(this,"SCALE_THRESHOLD",10);p(this,"MOVE_THRESHOLD",5)}enable(t){return t.touches.length===2}start(t,e){this.enable(t)&&(this.isWorking=!0,this.initialTouchInfo=this.getTouchInfo(t),this.lastTouchInfo=this.initialTouchInfo)}move(t,e){if(!this.isWorking||!this.lastTouchInfo)return;const n=this.getTouchInfo(t),o=e.renderManager.gmlRender.transformToGlobal(this.lastTouchInfo.centerPoint),s=n.distance/this.lastTouchInfo.distance;this.handleZoom(s,o,e);const r=n.centerPoint.x-this.lastTouchInfo.centerPoint.x,i=n.centerPoint.y-this.lastTouchInfo.centerPoint.y;this.handleScroll(r,i,e),this.lastTouchInfo=n}stop(t,e){this.isWorking=!1,this.initialTouchInfo=null,this.lastTouchInfo=null}getTouchInfo(t){const e=new m(t.touches[0].clientX,t.touches[0].clientY),n=new m(t.touches[1].clientX,t.touches[1].clientY),o=new m((e.x+n.x)/2,(e.y+n.y)/2),s=n.x-e.x,r=n.y-e.y,i=Math.sqrt(s*s+r*r);return{centerPoint:o,distance:i,touch1:e,touch2:n}}handleZoom(t,e,n){n.renderManager.zoomScale(t,e)}handleScroll(t,e,n){n.renderManager.scroll(-t,-e)}}class Wo{constructor(t,e){p(this,"eventCtx");p(this,"interactiveManager");p(this,"touchScrollZoomWorker");p(this,"onContextMenu",t=>{t.preventDefault()});p(this,"onTouchStart",t=>{if(this.touchScrollZoomWorker.enable(t)){t.preventDefault(),t.stopPropagation(),this.touchScrollZoomWorker.start(t,this.eventCtx);return}});p(this,"onTouchMove",t=>{if(this.touchScrollZoomWorker.isWorking){t.preventDefault(),t.stopPropagation(),this.touchScrollZoomWorker.move(t,this.eventCtx);return}t.preventDefault()});p(this,"onTouchEnd",t=>{if(this.touchScrollZoomWorker.isWorking){t.preventDefault(),t.stopPropagation(),this.touchScrollZoomWorker.stop(t,this.eventCtx);return}});p(this,"onPointerDown",t=>{this.touchScrollZoomWorker.isWorking||this.triggerEvent(t)});p(this,"onPointerMove",t=>{this.touchScrollZoomWorker.isWorking||this.triggerEvent(t)});p(this,"onPointerUp",t=>{this.touchScrollZoomWorker.isWorking||this.triggerEvent(t)});this.eventCtx=t,this.interactiveManager=new $i(e),this.touchScrollZoomWorker=new Ud}start(){document.addEventListener("pointerdown",this.onPointerDown),document.addEventListener("pointermove",this.onPointerMove),document.addEventListener("pointerup",this.onPointerUp),document.addEventListener("contextmenu",this.onContextMenu);const t=this.eventCtx.renderManager.gmlRender.canvas;t&&(t.addEventListener("touchstart",this.onTouchStart),t.addEventListener("touchmove",this.onTouchMove),t.addEventListener("touchend",this.onTouchEnd))}stop(){document.removeEventListener("pointerdown",this.onPointerDown),document.removeEventListener("pointermove",this.onPointerMove),document.removeEventListener("pointerup",this.onPointerUp),document.removeEventListener("contextmenu",this.onContextMenu);const t=this.eventCtx.renderManager.gmlRender.canvas;t&&(t.removeEventListener("touchstart",this.onTouchStart),t.removeEventListener("touchmove",this.onTouchMove),t.removeEventListener("touchend",this.onTouchEnd))}triggerEvent(t){this.onEnable(t)&&(this.interactiveManager.onEvent(t,this.eventCtx),this.afterEvent())}onEnable(t){return t.type!=="pointermove"&&t.target!==this.eventCtx.gmlRender.canvas?(this.eventCtx.inputManager.blur(),!1):!0}afterEvent(){}}const Ys=8,Gs=8,Us=500;var _e=(l=>(l[l.width=0]="width",l[l.height=1]="height",l[l.both=2]="both",l))(_e||{});const Cn=new Set([v.Line,v.Group]);class An{}class ji extends An{align(t,e,n,o,s,r){const i={minX:o.minX,maxX:o.maxX,minY:n.minY-r,maxY:n.minY+r},a=t.nodeManager.searchNodesByRectNode(i),c=S.filterSlideContainerNodes(t,a),h=[];for(const g of c){if(e.has(g)||Cn.has(g.type))continue;const y=g.getBounds();if(Math.abs(n.minY-y.minY)<r){const P=Math.min(n.minX,y.minX),b=Math.max(n.maxX,y.maxX),w={start:new m(P,y.minY),end:new m(b,y.minY)};h.push({line:w,dx:0,dy:y.minY-n.minY})}if(Math.abs(n.minY-y.maxY)<r){const P=Math.min(n.minX,y.minX),b=Math.max(n.maxX,y.maxX),w={start:new m(P,y.maxY),end:new m(b,y.maxY)};h.push({line:w,dx:0,dy:y.maxY-n.minY})}}if(h.length===0)return;const d=h.map(g=>g.dy),u=Math.min(...d),f={dx:0,dy:u,lines:[]};for(const g of h)Math.abs(g.dy-u)<.01&&f.lines.push(g.line);s.top=f}}class Vi extends An{align(t,e,n,o,s,r=2){const i={minX:o.minX,maxX:o.maxX,minY:n.maxY-r,maxY:n.maxY+r},a=t.nodeManager.searchNodesByRectNode(i),c=S.filterSlideContainerNodes(t,a),h=[];for(const g of c){if(e.has(g)||Cn.has(g.type))continue;const y=g.getBounds();if(Math.abs(n.maxY-y.minY)<r){const P=Math.min(n.minX,y.minX),b=Math.max(n.maxX,y.maxX),w={start:new m(P,y.minY),end:new m(b,y.minY)};h.push({line:w,dx:0,dy:y.minY-n.maxY})}if(Math.abs(n.maxY-y.maxY)<r){const P=Math.min(n.minX,y.minX),b=Math.max(n.maxX,y.maxX),w={start:new m(P,y.maxY),end:new m(b,y.maxY)};h.push({line:w,dx:0,dy:y.maxY-n.maxY})}}if(h.length===0)return;const d=h.map(g=>g.dy),u=Math.min(...d),f={dx:0,dy:u,lines:[]};for(const g of h)Math.abs(g.dy-u)<.01&&f.lines.push(g.line);s.bottom=f}}class Ki extends An{align(t,e,n,o,s,r){const i={minX:n.minX-r,maxX:n.minX+r,minY:o.minY,maxY:o.maxY},a=t.nodeManager.searchNodesByRectNode(i),c=S.filterSlideContainerNodes(t,a),h=[];for(const g of c){if(e.has(g)||Cn.has(g.type))continue;const y=g.getBounds();if(Math.abs(n.minX-y.minX)<r){const P=Math.min(n.minY,y.minY),b=Math.max(n.maxY,y.maxY),w={start:new m(y.minX,P),end:new m(y.minX,b)};h.push({line:w,dy:0,dx:y.minX-n.minX})}if(Math.abs(n.minX-y.maxX)<r){const P=Math.min(n.minY,y.minY),b=Math.max(n.maxY,y.maxY),w={start:new m(y.maxX,P),end:new m(y.maxX,b)};h.push({line:w,dy:0,dx:y.maxX-n.minX})}}if(h.length===0)return;const d=h.map(g=>g.dx),u=Math.min(...d),f={dy:0,dx:u,lines:[]};for(const g of h)Math.abs(g.dx-u)<.01&&f.lines.push(g.line);s.left=f}}class Qi extends An{align(t,e,n,o,s,r){const i={minX:n.maxX-r,maxX:n.maxX+r,minY:o.minY,maxY:o.maxY},a=t.nodeManager.searchNodesByRectNode(i),c=S.filterSlideContainerNodes(t,a),h=[];for(const g of c){if(e.has(g)||Cn.has(g.type))continue;const y=g.getBounds();if(Math.abs(n.maxX-y.minX)<r){const P=Math.min(n.minY,y.minY),b=Math.max(n.maxY,y.maxY),w={start:new m(y.minX,P),end:new m(y.minX,b)};h.push({line:w,dy:0,dx:y.minX-n.maxX})}if(Math.abs(n.maxX-y.maxX)<r){const P=Math.min(n.minY,y.minY),b=Math.max(n.maxY,y.maxY),w={start:new m(y.maxX,P),end:new m(y.maxX,b)};h.push({line:w,dy:0,dx:y.maxX-n.maxX})}}if(h.length===0)return;const d=h.map(g=>g.dx),u=Math.min(...d),f={dy:0,dx:u,lines:[]};for(const g of h)Math.abs(g.dx-u)<.01&&f.lines.push(g.line);s.right=f}}class _d extends An{align(t,e,n,o,s,r){const i=.5*(n.minY+n.maxY),a={minX:o.minX,maxX:o.maxX,minY:i-r,maxY:i+r},c=t.nodeManager.searchNodesByRectNode(a),h=S.filterSlideContainerNodes(t,c),d=[];for(const y of h){if(e.has(y)||Cn.has(y.type))continue;const P=y.getBounds(),b=.5*(P.minY+P.maxY);if(Math.abs(i-b)<r){const w=Math.min(n.minX,n.maxX,P.maxX,P.minX),L=Math.max(n.minX,n.maxX,P.maxX,P.minX),B={start:new m(w,b),end:new m(L,b)};d.push({line:B,dx:0,dy:b-i})}}if(d.length===0)return;const u=d.map(y=>y.dy),f=Math.min(...u),g={dx:0,dy:f,lines:[]};for(const y of d)Math.abs(y.dy-f)<.01&&g.lines.push(y.line);s.horizonMid=g}}class $d extends An{align(t,e,n,o,s,r){const i=.5*(n.minX+n.maxX),a={minX:i-r,maxX:i+r,minY:o.minY,maxY:o.maxY},c=t.nodeManager.searchNodesByRectNode(a),h=S.filterSlideContainerNodes(t,c),d=[];for(const y of h){if(e.has(y)||Cn.has(y.type))continue;const P=y.getBounds(),b=.5*(P.minX+P.maxX);if(Math.abs(i-b)<r){const w=Math.min(n.minY,n.maxY,P.maxY,P.minY),L=Math.max(n.minY,n.maxY,P.maxY,P.minY),B={start:new m(b,w),end:new m(b,L)};d.push({line:B,dx:b-i,dy:0})}}if(d.length===0)return;const u=d.map(y=>y.dx),f=Math.min(...u),g={dx:f,dy:0,lines:[]};for(const y of d)Math.abs(y.dx-f)<.01&&g.lines.push(y.line);s.verticalMid=g}}class Zi{constructor(){p(this,"handlers",[new ji,new _d,new Vi,new Ki,new $d,new Qi])}align(t,e,n){const o=n.gmlRender.getViewPortBounds(),s=Ys/n.gmlRender.getScale(),r=new Set;for(const a of e)this.computeFilterSet(a,r);const i={};for(const a of this.handlers)a.align(n,r,t,o,i,s);return this.dealAlignTopBottom(i),this.dealAlignLeftRight(i),i}computeFilterSet(t,e){e.add(t);const n=t.children;for(const o of n)this.computeFilterSet(o,e)}dealAlignTopBottom(t){const{top:e,bottom:n,horizonMid:o}=t,s=[e,o,n].map(i=>i==null?void 0:i.dy).filter(i=>i!==void 0);if(s.length===0)return;const r=Math.min(...s);for(const i of["top","bottom","horizonMid"]){const a=t[i];a&&Math.abs(r-a.dy)>.01&&(t[i]=void 0)}}dealAlignLeftRight(t){const{left:e,right:n,verticalMid:o}=t,s=[e,n,o].map(i=>i==null?void 0:i.dx).filter(i=>i!==void 0);if(s.length===0)return;const r=Math.min(...s);for(const i of["left","right","verticalMid"]){const a=t[i];a&&Math.abs(r-a.dx)>.01&&(t[i]=void 0)}if(e&&n){if(Math.abs(e.dx-n.dx)<.01)return;e.dx<n.dx?t.right=void 0:t.left=void 0}}}const _s=new Set([v.Group,v.Line]);class $s{}class qi extends $s{enable(t){return t===_e.both||t===_e.width}align(t,e,n,o,s,r,i,a){const c=n.maxX-n.minX,h=this.searchNodes(t,c,s,n,o,r,i,a);if(h.length===0)return;const d=h.map(y=>y.dt),u=Math.min(...d),f=[];for(const y of h)Math.abs(y.dt-u)<.01&&f.push(y.info);const g={dt:u,sideSize:c,lines:f};e.width=g}searchNodes(t,e,n,o,s,r,i,a){let c=200;const h={minX:o.minX-c,maxX:o.maxX+c,minY:o.minY-c,maxY:o.maxY+c},d=[];for(;d.length===0&&!(c>i||S.containRect(h,r));){const u=this.searchNodesForOffset(t,e,n,h,s,r,c,a);d.push(...u),c=2*c}return d}searchNodesForOffset(t,e,n,o,s,r,i,a){const c=t.nodeManager.searchNodesByRectNode(r),h=S.filterSlideContainerNodes(t,c),d=[];for(const u of h){if(s.has(u)||_s.has(u.type))continue;const{width:f,height:g,angle:y}=u.baseProps,P=y%360;if(!(Math.abs(P)>30)&&Math.abs(f-e)<a){const b={x:0,y:g},w={x:f,y:g};d.push({dt:f-e,sideSize:f,info:{line:{start:b,end:w},transform:u.globalTransform().clone()}})}}return d}}class Ji extends $s{enable(t){return t===_e.both||t===_e.height}align(t,e,n,o,s,r,i,a){const c=n.maxY-n.minY,h=this.searchNodes(t,c,s,n,o,r,i,a);if(h.length===0)return;const d=h.map(y=>y.dt),u=Math.min(...d),f=[];for(const y of h)Math.abs(y.dt-u)<.01&&f.push(y.info);const g={dt:u,sideSize:c,lines:f};e.height=g}searchNodes(t,e,n,o,s,r,i,a){let c=200;const h={minX:o.minX-c,maxX:o.maxX+c,minY:o.minY-c,maxY:o.maxY+c},d=[];for(;d.length===0&&!(c>i||S.containRect(h,r));){const u=this.searchNodesForOffset(t,e,n,h,s,r,c,a);d.push(...u),c=2*c}return d}searchNodesForOffset(t,e,n,o,s,r,i,a){const c=t.nodeManager.searchNodesByRectNode(r),h=S.filterSlideContainerNodes(t,c),d=[];for(const u of h){if(s.has(u)||_s.has(u.type))continue;const{width:f,height:g,angle:y}=u.baseProps,P=y%360;if(!(Math.abs(P)>30)&&Math.abs(g-e)<a){const b={x:f,y:0},w={x:f,y:g};d.push({dt:g-e,sideSize:g,info:{line:{start:b,end:w},transform:u.transform.clone()}})}}return d}}class ea{constructor(){p(this,"handlers",[new qi,new Ji])}align(t,e,n,o,s,r,i){const a={};for(const c of this.handlers)c.enable(o)&&c.align(t,a,e,n,o,s,r,i);return a}}class ta{}class jd extends ta{align(t,e,n,o,s,r){const i={minX:o.minX,maxX:o.maxX,minY:n.y-r,maxY:n.y+r},a=t.nodeManager.searchNodesByRectNode(i),c=S.filterSlideContainerNodes(t,a),h=[];for(const g of c){if(this.skipNodeAlign(e,g))continue;const y=g.getBounds(),P=[y.minY,y.maxY];for(const b of P)if(Math.abs(n.y-b)<r){const w=Math.min(n.x,y.minX,y.maxX),L=Math.max(n.x,y.minX,y.maxX),B={start:new m(w,b),end:new m(L,b)};h.push({line:B,dx:0,dy:b-n.y})}}if(h.length===0)return;const d=h.map(g=>g.dy),u=Math.min(...d),f={dx:0,dy:u,lines:[]};for(const g of h)Math.abs(g.dy-u)<.01&&f.lines.push(g.line);s.horizon=f}skipNodeAlign(t,e){if(t.has(e))return!0;if(e.type===v.Line){const n=e;if(n.shapeType!==he.Line)return!0;const o=n.points;return!S.judgeHorizon(o[0],o[o.length-1])}return e.type===v.Group}}class Vd extends ta{align(t,e,n,o,s,r){const i={minY:o.minY,maxY:o.maxY,minX:n.x-r,maxX:n.x+r},a=t.nodeManager.searchNodesByRectNode(i),c=S.filterSlideContainerNodes(t,a),h=[];for(const g of c){if(this.skipNodeAlign(e,g))continue;const y=g.getBounds(),P=[y.minX,y.maxX];for(const b of P)if(Math.abs(n.x-b)<r){const w=Math.min(n.y,y.minY,y.maxY),L=Math.max(n.y,y.minY,y.maxY),B={start:new m(b,w),end:new m(b,L)};h.push({line:B,dx:b-n.x,dy:0})}}if(h.length===0)return;const d=h.map(g=>g.dx),u=Math.min(...d),f={dx:u,dy:0,lines:[]};for(const g of h)Math.abs(g.dx-u)<.01&&f.lines.push(g.line);s.vertical=f}skipNodeAlign(t,e){if(t.has(e))return!0;if(e.type===v.Line){const n=e;if(n.shapeType!==he.Line)return!0;const o=n.points;return!S.judgeVertical(o[0],o[o.length-1])}return e.type===v.Group}}class Kd{constructor(){p(this,"handlers",[new jd,new Vd])}align(t,e,n){const o=n.gmlRender.getViewPortBounds(),s=Ys/n.gmlRender.getScale(),r={};for(const i of this.handlers)i.align(n,e,t,o,r,s);return r}}class $t{static addAllParentToSet(t,e){let n=t.parent;for(;n&&n.type===v.Group;)e.add(n),n=n.parent}static findHoverNode(t,e){if(t.parent.type!==v.Group)return t;const n=new Set;for(const s of e)n.add(s.parent);let o=t.parent;if(n.has(o))return t;for(;o;){const s=o.parent;if(n.has(s))return o;if(s.type!==v.Group)break;o=s}return o}static flattenNodes(t){const e=new Set;for(const n of t)this.flattenGroupNodes(n,e);return[...e]}static flattenGroupNodes(t,e){if(t.type!==v.Group){e.add(t);return}const o=t.children;for(const s of o)this.flattenGroupNodes(s,e)}}class un{constructor(){p(this,"alignMoveWorker",new Zi);p(this,"alignStretchWorker",new ea);p(this,"alignLineEndWorker",new Kd)}alignLineEnd(t,e,n,o){return o?this.alignLineEndWorker.align(t,e,n):{}}alignMove(t,e,n,o){if(!o)return{};const s=new Set;for(const r of e)this.addChildrenToFilterSet(r,s);return this.alignMoveWorker.align(t,s,n)}alignStretch(t,e,n,o,s,r,i){const a=D.toRectNode(e),c=new Set(n);for(const d of[...n])$t.addAllParentToSet(d,c);return this.alignStretchWorker.align(t,a,c,o,s,r,i)}alignLineEndAndDrawAlignLines(t,e,n=e.getSelectNodes(),o=!0){const s=t.globalPoint.clone(),r=this.alignLineEnd(s,n,e,o),i=[];return r.horizon&&(i.push(...r.horizon.lines),s.y+=r.horizon.dy),r.vertical&&(i.push(...r.vertical.lines),s.x+=r.vertical.dx),e.addOrUpdate(k.AlignLine,{lines:i}),s}drawAlignLines(t,e){const{top:n,bottom:o,horizonMid:s,right:r,left:i,verticalMid:a}=t,c=[],h=new m;return n&&(h.y=n.dy,c.push(...n.lines)),s&&(h.y=s.dy,c.push(...s.lines)),o&&(h.y=o.dy,c.push(...o.lines)),i&&(h.x=i.dx,c.push(...i.lines)),a&&(h.x=a.dx,c.push(...a.lines)),r&&(h.x=r.dx,c.push(...r.lines)),e.addOrUpdate(k.AlignLine,{lines:c}),h}addChildrenToFilterSet(t,e){e.add(t);const n=t.children;for(const o of n)this.addChildrenToFilterSet(o,e)}}class qe{}class Ot{constructor(t){p(this,"processors",[]);this.processors=t}work(t,e){for(const n of this.processors)n.allowEventTypeSet.has(t.type)&&n.process(t,e)}stop(t,e){for(const n of this.processors)n.stop&&n.stop(t,e)}isStreaming(){return!1}}class pn extends Ot{constructor(e){super(e);p(this,"deltaDistance",1);p(this,"locked",!1)}clickEnable(e,n){return!0}canBeEnable(e,n){if(e.type!==be.pointerDown)return!1;const o=this.clickEnable(e,n);return o&&(this.locked=!0),o}work(e,n){e.type===be.pointerup&&(this.locked=!1),e.type!==be.pointerDown&&n.lastDiffTypeEvent&&S.distance(n.lastDiffTypeEvent.globalPoint,e.globalPoint)>this.deltaDistance/n.gmlRender.getScale()&&(this.locked=!1),super.work(e,n)}canBeExit(e,n){const o=!this.locked;return o&&this.stop(e,n),o}}class jt{constructor(){p(this,"downHandlers",[]);p(this,"upHandlers",[]);p(this,"hasWorking",!1);p(this,"allowEventTypeSet",new Set([be.pointerDown,be.pointerup]))}registerDownHandler(t){this.downHandlers.push(t)}registerUpHandler(t){this.upHandlers.push(t)}process(t,e){this.downProcess(t,e),this.upProcess(t,e)}stop(t,e){this.hasWorking=!1}downProcess(t,e){if(t.type===be.pointerDown){for(const n of this.downHandlers)if(n.enable(t,e)){this.hasWorking=!0,n.handle(t,e);return}}}upProcess(t,e){if(t.type===be.pointerup){if(this.hasWorking){this.hasWorking=!1;return}for(const n of this.upHandlers)if(n.enable(t,e)){n.handle(t,e);return}}}}class js extends Ot{constructor(e){super(e);p(this,"deltaDistance",1);p(this,"locked",!1);p(this,"firstPointerDown",!1)}canBeEnable(e,n){return e.type===be.pointerDown?this.firstPointerDown?(this.locked=!0,!0):(this.firstPointerDown=!0,setTimeout(()=>{this.firstPointerDown=!1},300),!1):!1}work(e,n){this.firstPointerDown&&e.type===be.pointerup&&(this.locked=!1),e.type===be.pointermove&&S.distance(n.lastInteractiveEvent.globalPoint,e.globalPoint)>this.deltaDistance/n.gmlRender.getScale()&&(this.locked=!1),this.firstPointerDown||(this.locked=!1),super.work(e,n)}canBeExit(e,n){const o=!this.locked;return o&&this.stop(e,n),o}}class dt extends Ot{constructor(e,n=[]){super(n);p(this,"streamProcessor");p(this,"deltaDistance",1);p(this,"locked",!1);this.streamProcessor=e}onDown(e,n){}canBeEnable(e,n){var i;if(e.type===be.pointerDown&&this.onDown(e,n),!(((i=n.lastDiffTypeEvent)==null?void 0:i.type)===be.pointerDown&&e.type===be.pointermove))return!1;const s=n.lastDiffTypeEvent.globalPoint;if(S.distance(s,e.globalPoint)<this.deltaDistance/n.gmlRender.getScale())return!1;const r=this.streamEnable(n.lastDiffTypeEvent,n);if(r){this.locked=!0;for(const a of this.streamProcessor)a.onStart(n.lastDiffTypeEvent,n)}return r}work(e,n){if(e.type===be.pointermove)for(const o of this.streamProcessor)o.onMove(e,n);if(e.type===be.pointerup){for(const o of this.streamProcessor)o.onUp(e,n);this.locked=!1}super.work(e,n)}canBeExit(e,n){const o=!this.locked;return o&&this.stop(e,n),o}isStreaming(){return this.locked}}class fn{constructor(t){p(this,"currentSubMode");p(this,"subModes",[]);this.subModes=t,this.currentSubMode=t[t.length-1]}canBeExit(t,e){return this.currentSubMode.canBeExit(t,e)}work(t,e){this.detect(t,e),this.currentSubMode.work(t,e)}detect(t,e){if(this.currentSubMode.canBeExit(t,e)){for(const n of this.subModes)if(n.canBeEnable(t,e)){this.currentSubMode=n;return}}}}class Nn extends Ot{constructor(e,n=[]){super(n);p(this,"streamProcessor");p(this,"locked",!1);this.streamProcessor=e}canBeEnable(e,n){if(e.type!==be.pointerDown)return!1;const o=this.streamEnable(e,n);return o&&(this.locked=!0),o}work(e,n){if(e.type===be.pointerDown)for(const o of this.streamProcessor)o.onStart(e,n);if(e.type===be.pointermove)for(const o of this.streamProcessor)o.onMove(e,n);if(e.type===be.pointerup){for(const o of this.streamProcessor)o.onUp(e,n);this.locked=!1}super.work(e,n)}canBeExit(e,n){const o=!this.locked;return o&&this.stop(e,n),o}isStreaming(){return this.locked}}class ht{constructor(){p(this,"allowEventTypeSet",new Set([be.pointerDown,be.pointermove,be.pointerup]))}process(t,e){}}class na{}class oa extends Ke{onDetect(t,e){if(e.detect(F.Stretch,t)||e.detect(F.Rotate,t)||e.detect(F.LineEndPoint,t))return!1;const r=t.globalPoint;let i=e.nodeManager.searchNodes(r.x,r.y);i=S.filterSlideContainerNodes(e,i);let a=[];for(const c of i)c.type!==v.Group&&c.contains(t.globalPoint,e.gmlRender.getScale())&&a.push(c);return a.length===0?(this.result=null,!1):(a=S.sortGraphics(a),a.reverse(),this.result=a,!0)}}class sa extends Ke{onDetect(t,e){const n=e.detect(F.Node,t);if(!n)return!1;const o=n[0];if(n.length===1&&e.auxiliaryManager.selectManager.include(o))return!1;if(t.originEvent.metaKey)return this.result=o,!0;const s=e.getSelectNodes(),r=$t.findHoverNode(o,s);return r?(this.result=r,!0):(this.result=o,!0)}}const ys=class ys extends Ke{computeLocalPoint(t,e,n){if(t.length===1){const i=t[0],a=i.baseProps,c=i.toLocal(e.globalPoint),h=D.baseProps2Rect(a);return{localPoint:c,rect:h}}const o=n.auxiliaryManager.selectManager.getSelectBounds(),s=D.rectNode2Rect(o);return{localPoint:new m(e.globalPoint.x-s.x,e.globalPoint.y-s.y),rect:s}}onDetect(t,e){const n=e.auxiliaryManager.selectManager.selectNodes;if(n.size===0||e.detect(F.ExpandShape,t))return!1;const s=$t.flattenNodes([...n]),r=e.gmlRender.getScale(),i=ys.HOT_DISTANCE/r,{rect:a,localPoint:c}=this.computeLocalPoint(s,t,e),h=new D(0,0,a.width,a.height),d=S.detectRectBounds(h,c,i);return d?(this.result={nodes:s,type:d.type,angle:S.computeStretchAngle(s,d.type)},!0):!1}};p(ys,"HOT_DISTANCE",8);let Fo=ys;class ra extends ht{constructor(){super(...arguments);p(this,"start",null)}onStart(e,n){const{renderText:o,node:s}=n.inputManager.editTextInfo,r=s.toLocal(e.globalPoint),i=o.detect(r);n.setCursor("text"),this.start=i,n.execAction(new W)}onMove(e,n){const{renderText:o,node:s}=n.inputManager.editTextInfo,r=s.toLocal(e.globalPoint),i=o.detect(r);this.start.equal(i)?n.execAction(ee.focus(s.id,this.start)):n.execAction(ee.selection(s.id,this.start,i))}onUp(e,n){const{renderText:o,node:s}=n.inputManager.editTextInfo,r=s.toLocal(e.globalPoint),i=o.detect(r);this.start.equal(i)?n.execAction(ee.focus(s.id,this.start)):n.execAction(ee.selection(s.id,this.start,i)),n.execAction(new z)}}class ia extends dt{constructor(){super([new ra])}streamEnable(t,e){const n=e.inputManager.editTextInfo;if(!n)return!1;const{node:o,renderText:s}=n,r=o.getTextContentRect(),i=o.toLocal(t.globalPoint);return!!S.rectContains(i,r)}}class on{constructor(){p(this,"parentGroupSet",new Set)}start(t){this.parentGroupSet.clear();for(const e of t)$t.addAllParentToSet(e,this.parentGroupSet)}work(t,e){if(this.parentGroupSet.size===0)return;const n=S.sortGraphics([...this.parentGroupSet]).reverse();for(const o of n){const s=o.computeBasePropsByChildren();t.execAction(new U({infos:[{id:o.id,props:[s]}]},{streaming:e}))}}}class gn{}class Qd extends gn{enable(t){return!(!(t instanceof Fn)||t.cropProps.cropType===wt.None||!t.cropProps.cropInfo)}handle(t,e,n,o,s){const r=this.handleCropProp(t,e,n,o,s);return[{id:t.id,props:[r]}]}handleCropProp(t,e,n,o,s){const r=e.crop,i=e.crop.globalImgPos,a=r.originCropProps,c=a.cropType,h=s.crossPoint(new m(i.x,i.y)),d=t.toLocal(h);return{type:I.Crop,cropInfo:{imgX:d.x,imgY:d.y,imgWidth:a.cropInfo.imgWidth*n,imgHeight:a.cropInfo.imgHeight*o},cropType:c}}}class Zd extends en{updateProps(t){super.updateProps(t),t.find(n=>n.type===I.Base)&&this.updateTransformMatrix()}getTextContentRect(){return this.baseProps}getConnectAnchor(){return[new m(.5,0),new m(1,.5),new m(.5,1),new m(0,.5)]}borderContains(t,e){const n=this.toLocal(t),{width:o,height:s}=this.baseProps,r=q.rectangle({top:0,left:0,width:o,height:s}),i=q.line({x:n.x-e,y:n.y},{x:n.x+e,y:n.y}),a=q.line({x:n.x,y:n.y-e},{x:n.x,y:n.y+e});for(const c of[i,a]){const h=Y.intersect(r,c);if(h.points.length>0)return h.points[0]}return null}}class Yo extends Zd{get checkStatus(){return this.getProp(I.CheckStatus).checkStatus}constructor(t,e){super(t,e),this.props.set(I.Base,new ie),this.props.set(I.Border,new Ae),this.props.set(I.CheckStatus,new Qt),this.props.set(I.Color,new tt),this.props.set(I.Shape,new Oe)}drawOnGLCtx(t){this.drawCheckboxBorder(t),this.drawCheckboxIcon(t)}drawCheckboxBorder(t){const e=this.getProp(I.Border),n=this.baseProps;if(e.color!==""&&e.alpha!==0&&e.dashType!==et.None){const{a:o,b:s,c:r,d:i,e:a,f:c}=this.globalTransform();t.save(),t.transform(o,s,r,i,a,c),t.beginPath(),t.roundRect(0,0,n.width,n.height,4),t.lineWidth=e.width,t.strokeStyle=e.color,t.globalAlpha=e.alpha,S.setDashLine(e,t),t.stroke(),t.restore()}}drawCheckboxIcon(t){if(!this.checkStatus)return;const e=this.getProp(I.Color),n=this.baseProps;if(e.color!==""&&e.alpha!==0){t.save();const o=re.generateMatrix().scale(n.width/16,n.height/16),{a:s,b:r,c:i,d:a,e:c,f:h}=this.globalTransform().crossProduct(o);t.transform(s,r,i,a,c,h),t.fillStyle=e.color,t.globalAlpha=e.alpha,t.scale(1,1),t.beginPath();const d=new Path2D("M10.97 4.97a.75.75 0 0 1 1.07 1.05l-3.99 4.99a.75.75 0 0 1-1.08.02L4.324 8.384a.75.75 0 1 1 1.06-1.06l2.094 2.093 3.473-4.425a.267.267 0 0 1 .02-.022z");t.fill(d),t.restore()}}checkboxContain(t){return this.contains(t)}canQuickCreate(){return!1}canBeConnected(){return!0}static load(t,e,n,o,s,r){const i=new Yo(t,r);return i.type=e,i.zIndex=n,i.setParent(s),i.updateProps(o),i}}const aa=1;class Un extends Yo{constructor(e,n){super(e,n);p(this,"renderText");p(this,"checkboxTopPadding",aa);this.props.set(I.Text,new Ge),this.props.set(I.CheckSize,new vn),this.renderText=new uo}get textProps(){return this.props.get(I.Text)}get chickSize(){return this.props.get(I.CheckSize).size}updateProps(e){super.updateProps(e);const n=e.find(r=>r.type===I.Text),o=e.find(r=>r.type===I.Base),s=e.find(r=>r.type===I.CheckSize);if(n||o||s){const r=this.getTextContentRect();if(this.renderText.typesetting(this.graphicContext,this.textProps,r),this.baseProps.height=this.renderText.height+2*le,this.renderText.rect.height=this.renderText.height+2*le,this.renderText.paragraphs.length>0){const i=this.renderText.paragraphs[0];if(i.lines.length>0){const a=i.lines[0];this.checkboxTopPadding=.5*(a.height-this.chickSize)}}}}drawOnGLCtx(e){super.drawOnGLCtx(e),this.drawText(e)}drawCheckboxBorder(e){const n=this.getProp(I.Border);if(n.color!==""&&n.alpha!==0&&n.dashType!==et.None){const o=this.chickSize,{a:s,b:r,c:i,d:a,e:c,f:h}=this.globalTransform();e.save(),e.transform(s,r,i,a,c,h),e.beginPath(),e.roundRect(0,le+this.checkboxTopPadding,o,o,4),e.lineWidth=n.width,e.strokeStyle=n.color,e.globalAlpha=n.alpha,S.setDashLine(n,e),e.stroke(),e.restore()}}drawCheckboxIcon(e){if(!this.checkStatus)return;const n=this.getProp(I.Color);if(n.color!==""&&n.alpha!==0){e.save();const o=this.chickSize,s=re.generateMatrix().scale(o/16,o/16),r=re.generateMatrix().translate(0,this.checkboxTopPadding+le),{a:i,b:a,c,d:h,e:d,f:u}=this.globalTransform().crossProduct(r).crossProduct(s);e.transform(i,a,c,h,d,u),e.fillStyle=n.color,e.globalAlpha=n.alpha,e.scale(1,1),e.beginPath();const f=new Path2D("M10.97 4.97a.75.75 0 0 1 1.07 1.05l-3.99 4.99a.75.75 0 0 1-1.08.02L4.324 8.384a.75.75 0 1 1 1.06-1.06l2.094 2.093 3.473-4.425a.267.267 0 0 1 .02-.022z");e.fill(f),e.restore()}}drawText(e){const{alpha:n}=this.getProp(I.Color);e.save(),e.beginPath();const o=this.globalPos;this.renderText.draw(e,new m(o.x,o.y),n),e.restore()}checkboxContain(e){const{height:n}=this.baseProps,o=this.toLocal(e);return S.rectContains(o,new D(0,0,n,n))}getTextContentRect(){const{width:e,height:n}=this.baseProps,o=this.chickSize;return{x:o+le,y:le,width:e-2*le-o-aa,height:n-2*le}}static load(e,n,o,s,r,i){const a=new Un(e,i);return a.type=n,a.zIndex=o,a.setParent(r),a.updateProps(s),a}}class Go extends ht{constructor(){super(...arguments);p(this,"minStretchSize",new m(0,0));p(this,"originPos",new m(0,0));p(this,"originStretchRect");p(this,"propsMap",new Map);p(this,"originTransform",re.generateMatrix());p(this,"viewBounds");p(this,"target",null);p(this,"alignWorker",new un);p(this,"alignType",_e.width);p(this,"originWidthHeightRatio",1);p(this,"isUniform",!1);p(this,"relatedLines",new Set);p(this,"layoutWorker",new Rn);p(this,"cropStretchHandler",new Qd);p(this,"groupBaseWorker",new on)}recordNodePropInfo(e){const{x:n,y:o,width:s,height:r}=e.globalBaseProps,i=this.originTransform.crossPoint({x:n,y:o}),a={x:i.x,y:i.y,width:s,height:r};if(e instanceof Fn){const c=e.cropProps,h=e.getOriginImageRect().clone(),d=e.toGlobal({x:h.x,y:h.y}),u={originCropProps:c.clone(),originImgRect:h,originTransform:e.globalTransform().inverseMatrix().clone(),globalImgPos:this.originTransform.crossPoint(d)};a.crop=u}return e instanceof vt&&e.shapeType===K.PureText&&(a.fontSize=e.textProps.fontSize),e instanceof Un&&(a.fontSize=e.textProps.fontSize,a.checkSize=e.chickSize),a}computeAnchorPoint(e,n){const{width:o,height:s}=n;switch(e.type){case V.TOP:return this.alignType=_e.height,{x:.5*o,y:s};case V.RIGHT:return this.alignType=_e.width,{x:0,y:.5*s};case V.BOTTOM:return this.alignType=_e.height,{x:.5*o,y:0};case V.LEFT:return this.alignType=_e.width,{x:o,y:.5*s};case V.TOP_LEFT:return this.alignType=_e.both,{x:o,y:s};case V.TOP_RIGHT:return this.alignType=_e.both,{x:0,y:s};case V.BOTTOM_RIGHT:return this.alignType=_e.both,{x:0,y:0};case V.BOTTOM_LEFT:default:return this.alignType=_e.both,{x:o,y:0}}}judgeUniform(e){this.isUniform=!1;const n=this.target.nodes;for(const o of n){if(Math.abs(o.baseProps.angle)>.1){this.isUniform=!0;return}if(o.type===v.SVG||o.type===v.IMG||o.type===v.Checkbox){this.isUniform=!0;return}if(o.type===v.Shape&&o.shapeType===K.PureText&&(this.target.type===V.TOP||this.target.type===V.TOP_LEFT||this.target.type===V.BOTTOM_LEFT||this.target.type===V.BOTTOM||this.target.type===V.BOTTOM_RIGHT||this.target.type===V.TOP_RIGHT)){this.isUniform=!0;return}if(o.type===v.CheckboxText&&(this.target.type===V.TOP||this.target.type===V.TOP_LEFT||this.target.type===V.BOTTOM_LEFT||this.target.type===V.BOTTOM||this.target.type===V.BOTTOM_RIGHT||this.target.type===V.TOP_RIGHT)){this.isUniform=!0;return}}}computeStretchRect(e,n){switch(this.target.type){case V.BOTTOM:e.height+=n.y;break;case V.LEFT:e.x+=n.x,e.width-=n.x;break;case V.RIGHT:e.width+=n.x;break;case V.TOP:e.y+=n.y,e.height-=n.y;break;case V.BOTTOM_LEFT:e.height+=n.y,e.x+=n.x,e.width-=n.x;break;case V.BOTTOM_RIGHT:e.height+=n.y,e.width+=n.x;break;case V.TOP_LEFT:e.y+=n.y,e.height-=n.y,e.x+=n.x,e.width-=n.x;break;case V.TOP_RIGHT:e.y+=n.y,e.height-=n.y,e.width+=n.x;break}e.width<this.minStretchSize.x&&(e.width=this.minStretchSize.x),e.height<this.minStretchSize.y&&(e.height=this.minStretchSize.y)}computeTarget(e,n){this.target=n.detect(F.Stretch,e)}onStart(e,n){this.computeTarget(e,n),this.originStretchRect=this.getStretchRect(n),this.originWidthHeightRatio=this.originStretchRect.width/this.originStretchRect.height,this.computeOriginTransform(n),this.minStretchSize=this.getMiniSize(n),this.judgeUniform(n),this.originPos=this.originTransform.crossPoint(e.globalPoint),this.recordPropsMap(n),this.relatedLines.clear(),this.batchCollectNodeLinks(this.target.nodes,n,this.relatedLines),this.groupBaseWorker.start(this.target.nodes),this.viewBounds=n.gmlRender.getViewPortBounds(),n.actionManager.execAction(new W);const o=[];for(const s of this.target.nodes)(s.type===v.CheckboxText||s instanceof vt&&s.shapeType===K.PureText)&&(this.target.type===V.RIGHT||this.target.type===V.LEFT)&&o.push({id:s.id,props:[{type:I.Text,sizeMode:We.autoHeight}]}),s instanceof vt&&this.target.type!==V.RIGHT&&this.target.type!==V.LEFT&&o.push({id:s.id,props:[{type:I.Text,sizeMode:We.fix}]});n.actionManager.execAction(new U({infos:o})),n.inputManager.editTextInfo&&n.execAction(ee.blur(n.inputManager.editTextInfo.node.id))}onMove(e,n){n.auxiliaryManager.removeAlignGraphics(),this.stretchNode(e,n,!0)}onUp(e,n){this.stretchNode(e,n,!1),n.actionManager.execAction(new z),n.auxiliaryManager.removeAlignGraphics()}alignStretchGlobalPoint(e,n){const o=new Set(this.target.nodes),s=!S.pressMeta(e);return this.alignWorker.alignLineEndAndDrawAlignLines(e,n,o,s)}stretchNode(e,n,o){const s=this.alignStretchGlobalPoint(e,n),r=this.originTransform.crossPoint(s),i=new m(r.x-this.originPos.x,r.y-this.originPos.y),a=this.originStretchRect.clone();this.computeStretchRect(a,i);const c=n.gmlRender.getScale(),h=new Set(this.target.nodes),d=this.alignWorker.alignStretch(n,a,h,this.alignType,this.viewBounds,Us/c,Gs/c);this.drawAlignLine(a,d,n);const{sx:u,sy:f}=this.computeScale(a),g=re.generateMatrix().scale(u,f),y=this.originTransform.inverseMatrix().crossProduct(g),P=[],b=[],w=[];for(const[L,B]of this.propsMap){for(const H of this.handlers)if(H.enable(L)){const E=H.handle(L,B,u,f,y,n,this.isUniform);P.push(...E);break}L.type===v.SVG&&b.push(L),this.cropStretchHandler.enable(L)&&w.push(L)}n.execAction(new U({infos:P},{streaming:o})),this.afterStretchNode(n,u,f,y,o,w,b),this.layoutWorker.work([...this.relatedLines],n,o),this.groupBaseWorker.work(n,o)}afterStretchNode(e,n,o,s,r,i,a){if(i.length>0){const c=[];i.forEach(h=>{c.push(...this.cropStretchHandler.handle(h,this.propsMap.get(h),n,o,s))}),e.execAction(new U({infos:c},{streaming:r}))}if(r||e.asyncRenderNodeManager.batchAddRenderNode(a),this.target.type===V.BOTTOM_RIGHT){const c=[...this.target.nodes],h=c[0];if(c.length===1)e.addOrUpdate(k.HoverSize,{rect:D.baseProps2Rect(h.baseProps),transform:h.globalTransform().clone()});else{const d=e.auxiliaryManager.selectManager.getSelectBounds();e.addOrUpdate(k.HoverSize,{rect:D.rectNode2Rect(d),transform:re.generateMatrix().translate(d.minX,d.minY)})}}}computeScale(e){let n=e.width/this.originStretchRect.width,o=e.height/this.originStretchRect.height;if(!this.isUniform)return{sx:n,sy:o};const s=this.target.type;if(s===V.BOTTOM||s===V.TOP)return n=o,{sx:n,sy:o};if(s===V.LEFT||s===V.RIGHT)return o=n,{sx:n,sy:o};const r=e.width/e.height;return r>this.originWidthHeightRatio?o=n:r<this.originWidthHeightRatio&&(n=o),{sx:n,sy:o}}batchCollectNodeLinks(e,n,o){const s=n.getSelectNodes();for(const r of e)this.collectNodeLinks(r,n,s,o)}collectNodeLinks(e,n,o,s){const r=n.nodeManager.getNodeLinks(e);for(const i of r)o.has(i)||s.add(i);for(const i of e.children)i.type===v.Line&&this.collectNodeLinks(i,n,o,s)}}class qd extends gn{enable(t){return t.type===v.Section}handle(t,e,n,o,s,r){const i=s.crossPoint({x:e.x,y:e.y}),a=t.baseProps,c=t.parent.toLocal(i),h=new m(c.x-a.x,c.y-a.y),d=[{id:t.id,props:[{type:I.Base,x:c.x,y:c.y,width:e.width*n,height:e.height*o}]}];if(t.type===v.Section&&t.children.size>0){const u=t,f=this.computeSectionChildren(u,r);for(const g of f){const y=g.baseProps;if(g.type===v.Line){const P=g.points.map(w=>new m(w.x,w.y));for(const w of P)w.x-=h.x,w.y-=h.y;const b=D.rectNode2Rect(S.getBoundsByPoints(P));d.push({id:g.id,props:[{type:I.Line,points:P},{type:I.Base,x:b.x,y:b.y,width:b.width,height:b.height}]})}else d.push({id:g.id,props:[{type:I.Base,x:y.x-h.x,y:y.y-h.y}]})}}return d}computeSectionChildren(t,e){const n=t.children,o=new Set;for(const s of n)s.type===v.Group?$t.flattenGroupNodes(s,o):o.add(s);return o}}class ca extends gn{enable(t){return!0}handle(t,e,n,o,s){const r=s.crossPoint({x:e.x,y:e.y}),i=t.parent.toLocal(r);return[{id:t.id,props:[{type:I.Base,x:i.x,y:i.y,width:e.width*n,height:e.height*o}]}]}}class la extends gn{enable(t){return t.type!==v.Shape?!1:t.shapeType===K.PureText}handle(t,e,n,o,s,r,i){const a=s.crossPoint({x:e.x,y:e.y}),c=t.parent.toLocal(a),d=[{type:I.Base,x:c.x,y:c.y,width:e.width*n,height:e.height*o}],u=t.getProp(I.Text);if(i&&u){const f=e.fontSize*o,g={type:I.Text,fontSize:f};d.push(g)}return[{id:t.id,props:d}]}}class ha extends gn{enable(t){return t.type===v.CheckboxText}handle(t,e,n,o,s,r,i){const a=s.crossPoint({x:e.x,y:e.y}),c=t.parent.toLocal(a),d=[{type:I.Base,x:c.x,y:c.y,width:e.width*n,height:e.height*o}],u=t.getProp(I.Text);if(i&&u){const f=e.fontSize*o,g={type:I.Text,fontSize:f};d.push(g);const y=e.checkSize*n;d.push({type:I.CheckSize,size:y})}return[{id:t.id,props:d}]}}class da extends Go{constructor(){super(...arguments);p(this,"handlers",[new qd,new la,new ha,new ca])}getStretchRect(e){const n=[...e.getSelectNodes()];return D.baseProps2Rect(n[0].baseProps)}getMiniSize(e){return[...e.getSelectNodes()][0].getStretchMinSize()}recordPropsMap(e){this.propsMap.clear();const n=this.target.nodes;for(const o of n){const s=this.recordNodePropInfo(o);this.propsMap.set(o,s)}}computeOriginTransform(e){const n=this.target,o=[...e.getSelectNodes()][0],{x:s,y:r,width:i,height:a,angle:c}=o.globalBaseProps,h=re.generateMatrix().rotate(-c),d=re.generateMatrix().translate(-s,-r),u=this.computeAnchorPoint(n,new D(0,0,i,a)),g=re.generateMatrix().translate(-u.x,-u.y).crossProduct(h.crossProduct(d));this.originTransform=g}drawAlignLine(e,n,o){const s=this.target.nodes[0],r=s.baseProps,{width:i,height:a}=n,c=s.globalTransform().clone();if(i){e.width+=i.dt;const h={transform:c,line:{start:new m(0,r.height),end:new m(r.width,r.height)}};i.lines.push(h)}if(a){e.height+=a.dt;const h={transform:c,line:{start:new m(r.width,0),end:new m(r.width,r.height)}};a.lines.push(h)}o.addOrUpdate(k.AlignStretchLine,{alignInfo:n})}}class ua extends Nn{constructor(){super([new da])}streamEnable(t,e){if(e.getSelectNodes().size===0)return!1;const n=e.detect(F.Stretch,t);return n?n.nodes.filter(s=>S.judgeNodeCanBeStretch(s)).length===1:!1}}class Vs{handleChangeRelation(t,e,n){if(t.parent===e)return[];if(t.parent.type===v.Group)return[];const o=t.globalPos,s=e.toLocal(o);return[{id:t.id,props:[{type:I.Base,x:s.x,y:s.y}],parentId:e.id,zIndex:n}]}}class pa extends Vs{enable(t){return t.type===v.Line}handle(t,e){const n=t.baseProps.clone();n.x+=e.x,n.y+=e.y;const o=t.getProp(I.Line).clone();for(const s of o.points)s.x+=e.x,s.y+=e.y;return[{id:t.id,props:[n,o]}]}handleChangeRelation(t,e,n){if(t.parent===e)return[];const o=t.globalLinePoints,s=e.globalTransform().inverseMatrix(),r=o.map(a=>s.crossPoint(a)),i=S.getBoundsByPoints(r);return[{id:t.id,props:[{type:I.Base,x:i.minX,y:i.minY},{type:I.Line,points:r}],parentId:e.id,zIndex:n}]}}class fa extends Vs{enable(t){return!0}handle(t,e){const n=t.baseProps.clone();return n.x+=e.x,n.y+=e.y,[{id:t.id,props:[n]}]}}var go=(l=>(l[l.Resource=0]="Resource",l[l.Template=1]="Template",l))(go||{});class Ks{work(t){const e=t.getSelectNodes();return e.size===0?null:this.copyByIds([...e].map(n=>n.id),t)}copyByIds(t,e){const n=[];if(t.forEach(i=>{const a=e.nodeManager.getNode(i);a&&n.push(a)}),n.length===0)return null;const o=D.rectNode2Rect(e.auxiliaryManager.selectManager.getSelectBounds()),s=[],r=[];for(const i of n){const a=this.makeupPasteDO(i,!0,r);s.push(a)}return s.sort((i,a)=>i.zIndex-a.zIndex),{meta:{docId:e.docState.docId,resourceType:go.Resource},nodes:s,bounds:o,resources:r}}makeupPasteDO(t,e=!1,n){const{id:o,zIndex:s,capInfo:r,type:i}=t.serializeTo(),a={id:o,type:i,zIndex:s,capInfo:r,children:[]};if(this.collectResourceInfo(t,n),e){const u=t.globalPos;a.capInfo.baseProps.x=u.x,a.capInfo.baseProps.y=u.y,t instanceof Ct&&(a.capInfo.lineProps.points=[...t.globalLinePoints])}const c=t.children;if(c.size===0)return a;const h=[],d=e&&t.type===v.Group;for(const u of c)h.push(this.makeupPasteDO(u,d,n));return h.sort((u,f)=>u.zIndex-f.zIndex),a.children=h,a}collectResourceInfo(t,e){if(t.type===v.IMG){const n=t;e.push({type:zn.Image,fileKey:n.imgSrc})}if(t.type===v.SVG){const n=t;n.svgProps.useCode||e.push({type:zn.SVG,fileKey:n.svgUrl})}}}let yo=class{};class ga extends yo{handle(t,e){const n=t.find(o=>o.type===I.Base);n&&(n.x+=e.x,n.y+=e.y)}}let ya=class extends yo{handle(t,e,n){const o=t.find(i=>i.type===I.Connect);if(!o)return;const{start:s,end:r}=o;if(s){const i=n.get(s.objectId);i?s.objectId=i:o.start=null}if(r){const i=n.get(r.objectId);i?r.objectId=i:o.end=null}}};class xa extends yo{handle(t,e){const n=t.find(o=>o.type===I.Line);if(n)for(const o of n.points)o.x+=e.x,o.y+=e.y}}var wa={exports:{}};function Jd(l){throw new Error('Could not dynamically require "'+l+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Qs={exports:{}};const eu=Gh(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var ma;function tu(){return ma||(ma=1,function(l,t){(function(e,n){l.exports=n()})(ao,function(){var e=e||function(n,o){var s;if(typeof window<"u"&&window.crypto&&(s=window.crypto),typeof self<"u"&&self.crypto&&(s=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(s=globalThis.crypto),!s&&typeof window<"u"&&window.msCrypto&&(s=window.msCrypto),!s&&typeof ao<"u"&&ao.crypto&&(s=ao.crypto),!s&&typeof Jd=="function")try{s=eu}catch{}var r=function(){if(s){if(typeof s.getRandomValues=="function")try{return s.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof s.randomBytes=="function")try{return s.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},i=Object.create||function(){function w(){}return function(L){var B;return w.prototype=L,B=new w,w.prototype=null,B}}(),a={},c=a.lib={},h=c.Base=function(){return{extend:function(w){var L=i(this);return w&&L.mixIn(w),(!L.hasOwnProperty("init")||this.init===L.init)&&(L.init=function(){L.$super.init.apply(this,arguments)}),L.init.prototype=L,L.$super=this,L},create:function(){var w=this.extend();return w.init.apply(w,arguments),w},init:function(){},mixIn:function(w){for(var L in w)w.hasOwnProperty(L)&&(this[L]=w[L]);w.hasOwnProperty("toString")&&(this.toString=w.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),d=c.WordArray=h.extend({init:function(w,L){w=this.words=w||[],L!=o?this.sigBytes=L:this.sigBytes=w.length*4},toString:function(w){return(w||f).stringify(this)},concat:function(w){var L=this.words,B=w.words,H=this.sigBytes,E=w.sigBytes;if(this.clamp(),H%4)for(var X=0;X<E;X++){var $=B[X>>>2]>>>24-X%4*8&255;L[H+X>>>2]|=$<<24-(H+X)%4*8}else for(var Z=0;Z<E;Z+=4)L[H+Z>>>2]=B[Z>>>2];return this.sigBytes+=E,this},clamp:function(){var w=this.words,L=this.sigBytes;w[L>>>2]&=4294967295<<32-L%4*8,w.length=n.ceil(L/4)},clone:function(){var w=h.clone.call(this);return w.words=this.words.slice(0),w},random:function(w){for(var L=[],B=0;B<w;B+=4)L.push(r());return new d.init(L,w)}}),u=a.enc={},f=u.Hex={stringify:function(w){for(var L=w.words,B=w.sigBytes,H=[],E=0;E<B;E++){var X=L[E>>>2]>>>24-E%4*8&255;H.push((X>>>4).toString(16)),H.push((X&15).toString(16))}return H.join("")},parse:function(w){for(var L=w.length,B=[],H=0;H<L;H+=2)B[H>>>3]|=parseInt(w.substr(H,2),16)<<24-H%8*4;return new d.init(B,L/2)}},g=u.Latin1={stringify:function(w){for(var L=w.words,B=w.sigBytes,H=[],E=0;E<B;E++){var X=L[E>>>2]>>>24-E%4*8&255;H.push(String.fromCharCode(X))}return H.join("")},parse:function(w){for(var L=w.length,B=[],H=0;H<L;H++)B[H>>>2]|=(w.charCodeAt(H)&255)<<24-H%4*8;return new d.init(B,L)}},y=u.Utf8={stringify:function(w){try{return decodeURIComponent(escape(g.stringify(w)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(w){return g.parse(unescape(encodeURIComponent(w)))}},P=c.BufferedBlockAlgorithm=h.extend({reset:function(){this._data=new d.init,this._nDataBytes=0},_append:function(w){typeof w=="string"&&(w=y.parse(w)),this._data.concat(w),this._nDataBytes+=w.sigBytes},_process:function(w){var L,B=this._data,H=B.words,E=B.sigBytes,X=this.blockSize,$=X*4,Z=E/$;w?Z=n.ceil(Z):Z=n.max((Z|0)-this._minBufferSize,0);var se=Z*X,ne=n.min(se*4,E);if(se){for(var ae=0;ae<se;ae+=X)this._doProcessBlock(H,ae);L=H.splice(0,se),B.sigBytes-=ne}return new d.init(L,ne)},clone:function(){var w=h.clone.call(this);return w._data=this._data.clone(),w},_minBufferSize:0});c.Hasher=P.extend({cfg:h.extend(),init:function(w){this.cfg=this.cfg.extend(w),this.reset()},reset:function(){P.reset.call(this),this._doReset()},update:function(w){return this._append(w),this._process(),this},finalize:function(w){w&&this._append(w);var L=this._doFinalize();return L},blockSize:16,_createHelper:function(w){return function(L,B){return new w.init(B).finalize(L)}},_createHmacHelper:function(w){return function(L,B){return new b.HMAC.init(w,B).finalize(L)}}});var b=a.algo={};return a}(Math);return e})}(Qs)),Qs.exports}(function(l,t){(function(e,n){l.exports=n(tu())})(ao,function(e){return function(n){var o=e,s=o.lib,r=s.WordArray,i=s.Hasher,a=o.algo,c=[];(function(){for(var y=0;y<64;y++)c[y]=n.abs(n.sin(y+1))*4294967296|0})();var h=a.MD5=i.extend({_doReset:function(){this._hash=new r.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(y,P){for(var b=0;b<16;b++){var w=P+b,L=y[w];y[w]=(L<<8|L>>>24)&16711935|(L<<24|L>>>8)&4278255360}var B=this._hash.words,H=y[P+0],E=y[P+1],X=y[P+2],$=y[P+3],Z=y[P+4],se=y[P+5],ne=y[P+6],ae=y[P+7],te=y[P+8],ce=y[P+9],pe=y[P+10],Be=y[P+11],Re=y[P+12],Se=y[P+13],Te=y[P+14],fe=y[P+15],O=B[0],G=B[1],j=B[2],_=B[3];O=d(O,G,j,_,H,7,c[0]),_=d(_,O,G,j,E,12,c[1]),j=d(j,_,O,G,X,17,c[2]),G=d(G,j,_,O,$,22,c[3]),O=d(O,G,j,_,Z,7,c[4]),_=d(_,O,G,j,se,12,c[5]),j=d(j,_,O,G,ne,17,c[6]),G=d(G,j,_,O,ae,22,c[7]),O=d(O,G,j,_,te,7,c[8]),_=d(_,O,G,j,ce,12,c[9]),j=d(j,_,O,G,pe,17,c[10]),G=d(G,j,_,O,Be,22,c[11]),O=d(O,G,j,_,Re,7,c[12]),_=d(_,O,G,j,Se,12,c[13]),j=d(j,_,O,G,Te,17,c[14]),G=d(G,j,_,O,fe,22,c[15]),O=u(O,G,j,_,E,5,c[16]),_=u(_,O,G,j,ne,9,c[17]),j=u(j,_,O,G,Be,14,c[18]),G=u(G,j,_,O,H,20,c[19]),O=u(O,G,j,_,se,5,c[20]),_=u(_,O,G,j,pe,9,c[21]),j=u(j,_,O,G,fe,14,c[22]),G=u(G,j,_,O,Z,20,c[23]),O=u(O,G,j,_,ce,5,c[24]),_=u(_,O,G,j,Te,9,c[25]),j=u(j,_,O,G,$,14,c[26]),G=u(G,j,_,O,te,20,c[27]),O=u(O,G,j,_,Se,5,c[28]),_=u(_,O,G,j,X,9,c[29]),j=u(j,_,O,G,ae,14,c[30]),G=u(G,j,_,O,Re,20,c[31]),O=f(O,G,j,_,se,4,c[32]),_=f(_,O,G,j,te,11,c[33]),j=f(j,_,O,G,Be,16,c[34]),G=f(G,j,_,O,Te,23,c[35]),O=f(O,G,j,_,E,4,c[36]),_=f(_,O,G,j,Z,11,c[37]),j=f(j,_,O,G,ae,16,c[38]),G=f(G,j,_,O,pe,23,c[39]),O=f(O,G,j,_,Se,4,c[40]),_=f(_,O,G,j,H,11,c[41]),j=f(j,_,O,G,$,16,c[42]),G=f(G,j,_,O,ne,23,c[43]),O=f(O,G,j,_,ce,4,c[44]),_=f(_,O,G,j,Re,11,c[45]),j=f(j,_,O,G,fe,16,c[46]),G=f(G,j,_,O,X,23,c[47]),O=g(O,G,j,_,H,6,c[48]),_=g(_,O,G,j,ae,10,c[49]),j=g(j,_,O,G,Te,15,c[50]),G=g(G,j,_,O,se,21,c[51]),O=g(O,G,j,_,Re,6,c[52]),_=g(_,O,G,j,$,10,c[53]),j=g(j,_,O,G,pe,15,c[54]),G=g(G,j,_,O,E,21,c[55]),O=g(O,G,j,_,te,6,c[56]),_=g(_,O,G,j,fe,10,c[57]),j=g(j,_,O,G,ne,15,c[58]),G=g(G,j,_,O,Se,21,c[59]),O=g(O,G,j,_,Z,6,c[60]),_=g(_,O,G,j,Be,10,c[61]),j=g(j,_,O,G,X,15,c[62]),G=g(G,j,_,O,ce,21,c[63]),B[0]=B[0]+O|0,B[1]=B[1]+G|0,B[2]=B[2]+j|0,B[3]=B[3]+_|0},_doFinalize:function(){var y=this._data,P=y.words,b=this._nDataBytes*8,w=y.sigBytes*8;P[w>>>5]|=128<<24-w%32;var L=n.floor(b/4294967296),B=b;P[(w+64>>>9<<4)+15]=(L<<8|L>>>24)&16711935|(L<<24|L>>>8)&4278255360,P[(w+64>>>9<<4)+14]=(B<<8|B>>>24)&16711935|(B<<24|B>>>8)&4278255360,y.sigBytes=(P.length+1)*4,this._process();for(var H=this._hash,E=H.words,X=0;X<4;X++){var $=E[X];E[X]=($<<8|$>>>24)&16711935|($<<24|$>>>8)&4278255360}return H},clone:function(){var y=i.clone.call(this);return y._hash=this._hash.clone(),y}});function d(y,P,b,w,L,B,H){var E=y+(P&b|~P&w)+L+H;return(E<<B|E>>>32-B)+P}function u(y,P,b,w,L,B,H){var E=y+(P&w|b&~w)+L+H;return(E<<B|E>>>32-B)+P}function f(y,P,b,w,L,B,H){var E=y+(P^b^w)+L+H;return(E<<B|E>>>32-B)+P}function g(y,P,b,w,L,B,H){var E=y+(b^(P|~w))+L+H;return(E<<B|E>>>32-B)+P}o.MD5=i._createHelper(h),o.HmacMD5=i._createHmacHelper(h)}(Math),e.MD5})})(wa);var nu=wa.exports;const ou=Ns(nu);class ve{constructor(){p(this,"prefix","001");p(this,"map",new Map);p(this,"zIndex",0)}setPrefix(t){this.prefix=t}genId(t){const e=(this.map.get(t)||0)+1;return this.map.set(t,e),ve.type2NodePrefix(t)+this.prefix+":"+e}static genImgFileName(t,e){const n="img:"+t+"|"+e;return ou(n).toString()}loadNode(t){this.loadNodeId(t.id)}loadNodeId(t){const e=ve.nodePrefix2Type(t[0]),n=t.split(":");try{const o=parseInt(n[1]),s=this.map.get(e);s!==void 0?s<o&&this.map.set(e,o):this.map.set(e,o)}catch(o){console.error("id错误",o)}}static genZIndex(t){return t.children.size===0?1:[...t.children].sort((n,o)=>o.zIndex-n.zIndex)[0].zIndex+1}static type2NodePrefix(t){switch(t){case v.Shape:return"a";case v.Line:return"c";case v.SVG:return"d";case v.IMG:return"e";case v.Section:return"f";case v.Group:return"g";case v.Checkbox:return"i";case v.CheckboxText:return"j";case v.SlideContainer:return"k";default:return"x"}}static nodePrefix2Type(t){return t==="a"?v.Shape:t==="c"?v.Line:t==="d"?v.SVG:t==="e"?v.IMG:t==="f"?v.Section:t==="g"?v.Group:t==="i"?v.Checkbox:t==="j"?v.CheckboxText:t==="k"?v.SlideContainer:v.Shape}}class Pa{work(t,e,n,o){const s=new Map;this.recordIdMap(e,t,s);const r=[],i=[];let a=ve.genZIndex(t.nodeManager.root);for(const h of e){const d=this.convertToAddNodeInfo(t,h,s,n,r,Sn,a,o);a++,i.push(d)}return{addNodeData:{nodes:r},nextFocusIds:i}}convertToAddNodeInfo(t,e,n,o,s,r,i,a){const c=n.get(e.id),h=this.convertToProps(e.capInfo,o,n,a),d={id:c,type:e.type,zIndex:i,parentId:r,props:h};s.push(d);const u=new m;e.type===v.Group&&(u.x=o.x,u.y=o.y);for(const f of e.children)this.convertToAddNodeInfo(t,f,n,u,s,c,f.zIndex,a);return c}convertToProps(t,e,n,o){const s=S.convertCapInfoToProps(t);for(const r of this.propsHandler)r.handle(s,e,n,o);return s}recordIdMap(t,e,n){for(const o of t){const s=e.idGenerator.genId(o.type);n.set(o.id,s);const r=o.children;this.recordIdMap(r,e,n)}}}class ba extends Pa{constructor(){super(...arguments);p(this,"propsHandler",[new ga,new ya,new xa])}}class Zs{constructor(){p(this,"copyWorker",new Ks);p(this,"pasteWorker",new ba)}work(t,e){var d;const n=this.copyWorker.work(t);if(!n)return;let o;e?o=e:o=new m(20,20);const s=n.nodes,r=JSON.parse(JSON.stringify(s)),{addNodeData:i,nextFocusIds:a}=this.pasteWorker.work(t,r,o),c=[...t.getSelectNodes()];c.length===1&&((d=c[0].parent)==null?void 0:d.type)===v.SlideContainer?(i.nodes[0].parentId=c[0].parent.id,i.nodes[0].zIndex=ve.genZIndex(c[0].parent),t.execAction(new Le(i)),this.handleSlideContainerDuplicate(t,c[0],a[0])):t.execAction(new Le(i)),t.execAction(xe.create(a))}duplicateByIds(t,e,n){var u;const o=this.copyWorker.copyByIds(t,e);if(!o)return;let s;n?s=n:s=new m(20,20);const r=o.nodes,i=JSON.parse(JSON.stringify(r)),{addNodeData:a,nextFocusIds:c}=this.pasteWorker.work(e,i,s),h=[];t.forEach(f=>{const g=e.nodeManager.getNode(f);g&&h.push(g)}),h.length===1&&((u=h[0].parent)==null?void 0:u.type)===v.SlideContainer?(a.nodes[0].parentId=h[0].parent.id,a.nodes[0].zIndex=ve.genZIndex(h[0].parent),e.execAction(new Le(a)),this.handleSlideContainerDuplicate(e,h[0],c[0])):e.execAction(new Le(a)),e.execAction(xe.create(c))}handleSlideContainerDuplicate(t,e,n){const o=e.parent,s=o.slideProps.children,r=this.getNodePosition(o,e.id);if(!r)return;const{rowIndex:i,colIndex:a}=r,c=s.map((g,y)=>{if(y===i){const P=[...g.ids];return P.splice(a+1,0,n),{ids:P}}return{ids:[...g.ids]}}),h=[{id:o.id,props:[St.create({children:c})]}],d=c[i],u=t.nodeManager.getNode(e.id);if(u){let g=u.baseProps.x+u.baseProps.width+nt;const y=u.baseProps.y;for(let P=a+1;P<d.ids.length;P++){const b=d.ids[P],w=t.nodeManager.getNode(b);w&&(h.push({id:b,props:[ie.create({x:g,y,width:w.baseProps.width,height:w.baseProps.height})]}),g+=w.baseProps.width+nt)}}t.execAction(new U({infos:h}));const f=[];for(const g of c)for(const y of g.ids){const P=t.nodeManager.getNode(y);P&&f.push(P.baseProps)}if(f.length>0){const g=S.getBoundsByBasePropsList(f),y=g.maxX-g.minX+2*nt,P=g.maxY-g.minY+2*xt;t.execAction(U.create(o.id,[{type:I.Base,width:y,height:P}]))}}getNodePosition(t,e){const n=t.slideProps.children;for(let o=0;o<n.length;o++){const s=n[o];for(let r=0;r<s.ids.length;r++)if(s.ids[r]===e)return{rowIndex:o,colIndex:r}}return null}}class Sa extends Vs{enable(t){return t.type===v.Group}handle(t,e,n){const o=[],s=t.baseProps.clone();s.x+=e.x,s.y+=e.y,o.push({id:t.id,props:[s]});for(const r of t.children)o.push(...n.handle(r,e));return o}handleChangeRelation(t,e,n){if(t.parent===e)return[];if(t.parent.type===v.Group)return[];const o=t.globalPos,s=e.toLocal(o),r=[];r.push({id:t.id,props:[{type:I.Base,x:s.x,y:s.y}],parentId:e.id,zIndex:n});for(const i of t.children)this.handlePosChange(i,e,r);return r}handlePosChange(t,e,n){if(t.type===v.Line){const s=t.globalLinePoints.map(a=>e.toLocal(a)),r=D.rectNode2Rect(S.getBoundsByPoints(s)),i={id:t.id,props:[{type:I.Line,points:s},{type:I.Base,x:r.x,y:r.y,width:r.width,height:r.height}]};n.push(i)}else{const o=t.globalPos,s=e.toLocal(o),r={id:t.id,props:[{type:I.Base,x:s.x,y:s.y}]};n.push(r)}if(t.type===v.Group)for(const o of t.children)this.handlePosChange(o,e,n)}}class Ma{constructor(t){p(this,"handlers");this.handlers=t}handle(t,e){for(const n of this.handlers)if(n.enable(t))return n.handle(t,e,this);return[]}handleRelation(t,e,n){for(const o of this.handlers)if(o.enable(t))return o.handleChangeRelation(t,e,n);return[]}}class va extends ht{constructor(){super(...arguments);p(this,"moveRect",null);p(this,"lastPos",new m(0,0));p(this,"lastMoveRectPos",new m);p(this,"targetNodes",[]);p(this,"alignWorker",new un);p(this,"layoutWorker",new Rn);p(this,"duplicateWorker",new Zs);p(this,"groupBaseWorker",new on);p(this,"handlerCtx",new Ma([new pa,new Sa,new fa]))}computeMoveNodes(e,n){e.originEvent.altKey&&this.duplicateWorker.work(n,new m);const o=n.getSelectNodes(),s=this.recordNodeMap(o),r=[];for(const i of o)if(i.type===v.Line){const a=i,{start:c,end:h}=a.connectProps;if(c&&h&&s.has(c.objectId)&&s.has(h.objectId)){r.push(i);continue}if(!c&&h&&s.has(h.objectId)){r.push(i);continue}if(!h&&c&&s.has(c.objectId)){r.push(i);continue}!h&&!c&&r.push(i)}else r.push(i);return r}recordNodeMap(e){const n=new Map;for(const o of e)n.set(o.id,o);return n}onStart(e,n){n.actionManager.execAction(new W),this.targetNodes=this.computeMoveNodes(e,n),this.targetNodes.length!==0&&(this.lastPos=e.globalPoint.clone(),this.moveRect=n.auxiliaryManager.selectManager.getSelectBounds(),this.lastMoveRectPos=new m(this.moveRect.minX,this.moveRect.minY),n.inputManager.editTextInfo&&n.execAction(ee.blur(n.inputManager.editTextInfo.node.id)),this.groupBaseWorker.start(this.targetNodes))}onMove(e,n){if(n.auxiliaryManager.removeAlignGraphics(),this.targetNodes.length===0)return;this.moveNode(e,n,!0);const o=this.hoverOnContainer(e,n);o&&n.addOrUpdate(k.HoverContainer,{node:o})}judgeLinkLineRelation(e,n,o){const{start:s,end:r}=e.connectProps;let i=null,a=null;return s&&(i=n.nodeManager.getNode(s.objectId)),r&&(a=n.nodeManager.getNode(r.objectId)),i?!!(!a||o.has(a)):a?!!o.has(a):!1}onUp(e,n){this.targetNodes.length!==0&&(this.moveNode(e,n,!1),this.changeNodesRelation(e,n),n.actionManager.execAction(new z),n.auxiliaryManager.removeAlignGraphics())}changeNodesRelation(e,n){const o=this.hoverOnContainer(e,n)||n.nodeManager.root,s=n.getSelectNodes(),r=new Set;for(const u of s)u.type!==v.SlideContainer&&r.add(u);const i=new Set;for(const u of s)n.nodeManager.getNodeLinks(u).forEach(g=>i.add(g));for(const u of i)this.judgeLinkLineRelation(u,n,s)&&r.add(u);const a=[],c=o.children.size===0?0:Math.max(...[...o.children].map(u=>u.zIndex));let h=1;const d=S.sortGraphics([...r]);for(const u of d){if(u.parent===o)continue;const f=this.handlerCtx.handleRelation(u,o,c+h);a.push(...f),h++}a.length>0&&n.execAction(new U({infos:a}))}moveNode(e,n,o){const s=e.globalPoint,r=!S.pressMeta(e),i=new m(s.x-this.lastPos.x,s.y-this.lastPos.y);this.moveRectChange(this.moveRect,i);const a=this.alignWorker.alignMove(this.moveRect,n.getSelectNodes(),n,r),c=this.alignWorker.drawAlignLines(a,n),h=this.checkAlign(a),d=S.cloneIRectNode(this.moveRect),u={x:0,y:0};if(h){const y=d.minX+c.x,P=d.minY+c.y;u.x=y-this.lastMoveRectPos.x,u.y=P-this.lastMoveRectPos.y,this.lastMoveRectPos.x=y,this.lastMoveRectPos.y=P}else u.x=i.x,u.y=i.y,this.lastMoveRectPos.x+=i.x,this.lastMoveRectPos.y+=i.y;const f=[];for(const y of this.targetNodes){const P=this.handlerCtx.handle(y,u);f.push(...P)}const g=new Set;this.batchCollectNodeLinks(this.targetNodes,n,g),n.execAction(new U({infos:f},{streaming:o})),this.groupBaseWorker.work(n,o),this.layoutWorker.work([...g],n,o),this.lastPos=s}hoverOnContainer(e,n){const o=n.detect(F.HoverOnContainer,e);return o||null}moveRectChange(e,n){e.minX+=n.x,e.maxX+=n.x,e.minY+=n.y,e.maxY+=n.y}checkAlign(e){const{top:n,bottom:o,right:s,left:r,horizonMid:i,verticalMid:a}=e;return n!==void 0||o!==void 0||s!==void 0||r!==void 0||i!==void 0||a!==void 0}batchCollectNodeLinks(e,n,o){const s=n.getSelectNodes();for(const r of e)this.collectNodeLinks(r,n,s,o)}collectNodeLinks(e,n,o,s){const r=n.nodeManager.getNodeLinks(e);for(const i of r)o.has(i)||s.add(i);for(const i of e.children)i.type!==v.Line&&this.collectNodeLinks(i,n,o,s)}}class Ia extends dt{constructor(){super([new va])}streamEnable(t,e){if(e.auxiliaryManager.selectManager.selectNodes.size===0)return!1;const o=e.auxiliaryManager.selectManager.getSelectBounds(),s=D.rectNode2Rect(o);if(s.width<.1||s.height<.1){const i=q.line({x:s.x,y:s.y},{x:o.maxX,y:o.maxY}),a=q.circle(t.globalPoint,4/e.gmlRender.getScale());return Y.intersect(i,a).points.length>0}return S.rectContains2(t.globalPoint,o)}}class Ta{}class su extends Ta{enable(t){return t.originEvent.metaKey}handle(t,e,n){for(const o of e)S.containRect(t,o.getBounds())&&n.add(o)}drawGroupRect(t,e){t.addOrUpdate(k.SelectGroup,{rect:e,isPrecise:!0})}}class ru extends Ta{enable(t){return!0}handle(t,e,n){for(const o of e){if(o.type===v.Section||o.type===v.SlideContainer){S.containRect(t,o.getBounds())&&n.add(o);continue}o.overlapRect(t)&&n.add(o)}}drawGroupRect(t,e){t.addOrUpdate(k.SelectGroup,{rect:e})}}class La extends ht{constructor(){super(...arguments);p(this,"startPoint",null);p(this,"handlers",[new su,new ru])}onStart(e,n){this.startPoint=e.globalPoint,n.actionManager.execAction(new W),n.inputManager.editTextInfo&&n.execAction(ee.blur(n.inputManager.editTextInfo.node.id)),n.actionManager.execAction(xe.create([]))}onMove(e,n){if(!this.startPoint)return;const o=Math.min(e.globalPoint.x,this.startPoint.x),s=Math.max(e.globalPoint.x,this.startPoint.x),r=Math.min(e.globalPoint.y,this.startPoint.y),i=Math.max(e.globalPoint.y,this.startPoint.y),a={id:"group-rect",minX:o,maxX:s,minY:r,maxY:i},c=D.rectNode2Rect(a),h=n.nodeManager.searchNodes(o,r,s,i),d=new Set;for(const y of this.handlers)if(y.enable(e)){y.handle(a,h,d),y.drawGroupRect(n,c);break}const u=S.computeSelectNodes(d),g=S.filterSlideContainerNodes(n,u).map(y=>y.id);n.actionManager.execAction(xe.create(g))}onUp(e,n){n.actionManager.execAction(new z),n.removeAuxGraphic(k.SelectGroup),this.startPoint=null}}class qs extends dt{constructor(){super([new La])}streamEnable(t,e){if(t.originEvent.metaKey)return!0;const n=e.detect(F.Node,t);if(n&&n.length>0&&e.auxiliaryManager.selectManager.include(n[0])&&n[0].contains(t.globalPoint))return!1;const o=e.auxiliaryManager.selectManager.getSelectBounds();return!S.rectContains2(t.globalPoint,o)}}class xo{moveForward(t){const e=t.getSelectNodes();if(e.size===0)return;t.execAction(new W);const n=S.sortGraphics([...e]).reverse();for(const o of n){const s=this.moveNodeForward(o);s&&t.execAction(s)}t.execAction(new z)}moveBackward(t){const e=t.getSelectNodes();if(e.size===0)return;t.execAction(new W);const n=S.sortGraphics([...e]);for(const o of n){const s=this.moveNodeBackward(o);s&&t.execAction(s)}t.execAction(new z)}moveToUp(t){const e=t.getSelectNodes();if(e.size===0)return;const n=new Map;for(const o of e){const s=o.parent,r=n.get(s);r?r.push(o):n.set(s,[o])}t.execAction(new W);for(const[o,s]of n){const r=this.moveNodesToUp(s,o);r&&t.execAction(r)}t.execAction(new z)}moveToBack(t){const e=t.getSelectNodes();if(e.size===0)return;const n=new Map;for(const o of e){const s=o.parent,r=n.get(s);r?r.push(o):n.set(s,[o])}t.execAction(new W);for(const[o,s]of n){const r=this.moveNodesToBack(s,o);r&&t.execAction(r)}t.execAction(new z)}moveNodesToUp(t,e){if(t.length===0)return null;const n=S.sortGraphics(t),o=new Set(t),s=e.children,r=[];for(const d of s)o.has(d)||r.push(d);const i=S.sortGraphics(r),a=i[i.length-1].zIndex,c=[];let h=1;for(const d of n)c.push({id:d.id,zIndex:a+h,props:[]}),h++;return new U({infos:c})}moveNodesToBack(t,e){if(t.length===0)return null;const n=S.sortGraphics(t).reverse(),o=new Set(t),s=e.children,r=[];for(const d of s)o.has(d)||r.push(d);const a=S.sortGraphics(r)[0].zIndex,c=[];let h=1;for(const d of n)c.push({id:d.id,zIndex:a-h,props:[]}),h++;return new U({infos:c})}moveNodeForward(t){const e=t.parent;if(!e)return null;let n=[...e.children];n=S.sortGraphics(n);const o=n.indexOf(t);if(o<0&&console.error("排序时发生错误",o,t.id),o===n.length-1)return null;if(o===n.length-2){const a=n[o+1],c=[{id:t.id,zIndex:a.zIndex+1,props:[]}];return new U({infos:c})}const s=n[o+1],r=n[o+2],i=[{id:t.id,zIndex:.5*(s.zIndex+r.zIndex),props:[]}];return new U({infos:i})}moveNodeBackward(t){const e=t.parent;if(!e)return null;let n=[...e.children];n=S.sortGraphics(n);const o=n.indexOf(t);if(o<0&&console.error("排序时发生错误",o,t.id),o===0)return null;if(o===1){const a=n[o-1],c=[{id:t.id,zIndex:a.zIndex-1,props:[]}];return new U({infos:c})}const s=n[o-1],r=n[o-2],i=[{id:t.id,zIndex:.5*(s.zIndex+r.zIndex),props:[]}];return new U({infos:i})}}const xs=class xs{constructor(){p(this,"offlineCanvas");p(this,"ctx");this.offlineCanvas=document.createElement("canvas"),this.ctx=this.offlineCanvas.getContext("2d")}static getInstance(){return this.instance||(this.instance=new xs),this.instance}getCanvasCtx(){return this.ctx}};p(xs,"instance",null);let Js=xs;class sn{static dealWithAIDocumentInfo(t){if(t.nodes)for(const e of t.nodes)this.dealNodeInfo(e)}static dealNodeInfo(t){sn.dealNodeSizeForFullText(t);const e=t.children;for(const n of e)this.dealNodeInfo(n)}static dealNodeSizeForFullText(t){var e,n;try{if(t.type!==v.Shape||!((e=t.capInfo)!=null&&e.shapeProps)||!t.capInfo.textProps)return;const o=t.capInfo.shapeProps.shapeCode;if(o!==K.Rect&&o!==K.RoundRect){t.capInfo.textProps.sizeMode=We.fix;return}if(!t.capInfo.textProps.text){t.capInfo.textProps.sizeMode=We.fix;return}if(!t.capInfo.baseProps)return;const s=Js.getInstance().getCanvasCtx(),r=new uo,i=new Ge;i.update(((n=t.capInfo)==null?void 0:n.textProps)||{});const a={x:le,y:le,width:t.capInfo.baseProps.width-2*le,height:t.capInfo.baseProps.height-2*le};r.typesetting(s,i,a);const c=r.height+2*le,h=r.width+2*le;t.capInfo.baseProps.height=c,h>t.capInfo.baseProps.width&&(t.capInfo.baseProps.width=h),t.capInfo.textProps.sizeMode=We.fix}catch{console.error("处理失败,忽略node",t)}}static blurText(t){const e=t.inputManager.editTextInfo;e&&t.execAction(ee.blur(e.node.id))}}class er extends qe{constructor(){super(...arguments);p(this,"node",null)}enable(e,n){const o=n.auxiliaryManager.selectManager.getSelectBounds();if(S.rectContains2(e.globalPoint,o)||!e.originEvent.shiftKey)return!1;if(e.originEvent.metaKey){const r=n.detect(F.Node,e);if(r&&r.length>0)return this.node=r[0],!0}const s=n.detect(F.HoverNode,e);return s?(this.node=s,!0):!1}handle(e,n){if(!this.node)return;const s=[...S.computeSelectNode(n,this.node)].map(r=>r.id);n.actionManager.execAction(new W),sn.blurText(n),n.actionManager.execAction(xe.create([...s])),n.actionManager.execAction(new z)}}class Ca extends qe{constructor(){super(...arguments);p(this,"node",null)}enable(e,n){const o=n.auxiliaryManager.selectManager.getSelectBounds();if(n.getSelectNodes().size>1&&S.rectContains2(e.globalPoint,o))return!1;const s=n.detect(F.HoverNode,e);return s?n.auxiliaryManager.selectManager.include(s)||!this.canEnable(s)?!1:(this.node=s,!0):!1}handle(e,n){this.node&&(n.actionManager.execAction(new W),sn.blurText(n),n.actionManager.execAction(xe.create([this.node.id])),n.actionManager.execAction(new z),this.node.type===v.IMG&&n.setCursor("zoom-in"))}}class tr extends Ca{constructor(){super(...arguments);p(this,"node",null)}canEnable(e){return e.type!==v.Section}}class Aa extends qe{constructor(){super(...arguments);p(this,"res",null)}enable(e,n){if(n.getSelectNodes().size!==1)return!1;const o=n.detect(F.Node,e);if(o){const s=o[0];if(n.auxiliaryManager.selectManager.include(s)){const r=s.toLocal(e.globalPoint);if(s instanceof vt&&s.renderText.contains(r))return this.res={node:s,relativePos:r},!0;if(s instanceof Ct)return this.res={node:s,relativePos:r},!0;if(s instanceof Un&&s.renderText.contains(r))return this.res={node:s,relativePos:r},!0}}return!1}handle(e,n){if(!this.res)return;const{node:o,relativePos:s}=this.res,r=o.renderText.detect(s);this.shiftTextClick(e,n,r)||(n.execAction(new W),n.execAction(ee.focus(o.id,r)),n.execAction(new z))}shiftTextClick(e,n,o){if(!e.originEvent.shiftKey)return!1;const s=n.inputManager.editTextInfo,{node:r}=this.res;return s&&!n.inputManager.selectionManager.selectionInfo&&!s.textCursorPosition.equal(o)?(n.execAction(new W),n.execAction(ee.selection(r.id,o,s.textCursorPosition)),n.execAction(new z),!0):!1}}class nr extends qe{constructor(){super(...arguments);p(this,"node",null)}enable(e,n){if(!e.originEvent.shiftKey)return!1;const o=n.detect(F.Node,e);if(o){const s=o[0];if(n.auxiliaryManager.selectManager.include(s))return this.node=s,!0}return!1}handle(e,n){if(!this.node)return;const o=n.getSelectNodes(),s=new Set;o.forEach(r=>s.add(r.id)),s.delete(this.node.id),n.actionManager.execAction(new W),sn.blurText(n),n.actionManager.execAction(xe.create([...s])),n.actionManager.execAction(new z)}}class or extends qe{enable(t,e){return!e.detect(F.Node,t)}handle(t,e){if(e.getSelectNodes().size===0){e.slotManager.addSlotState(ze.QuickCreate,{show:!1});return}if(e.execAction(new W),e.inputManager.editTextInfo){const n=e.inputManager.editTextInfo.node;if(e.execAction(ee.blur(e.inputManager.editTextInfo.node.id)),n.type===v.Shape&&n.shapeType===K.PureText&&n.getProp(I.Text)&&n.isEmptyText()){e.execAction(xe.create([])),e.execAction(At.create([n.id])),e.execAction(new z);return}}e.execAction(xe.create([])),e.execAction(new z)}}class Na extends qe{constructor(){super(...arguments);p(this,"res",null);p(this,"layoutWorker",new Rn)}enable(e,n){const o=n.detect(F.ExpandShape,e);return o?(this.res=o,!0):!1}handle(e,n){const{node:o,realHeight:s}=this.res,r={infos:[{id:o.id,props:[{height:s,type:I.Base},{type:I.Text,sizeMode:We.autoHeight}]}]};n.execAction(new W),sn.blurText(n),n.execAction(new U(r));const i=[...n.nodeManager.getNodeLinks(o)];this.layoutWorker.work(i,n,!1),n.execAction(new z)}}class ka extends Ca{constructor(){super(...arguments);p(this,"node",null)}canEnable(e){return e.type===v.Section}}class iu extends qe{constructor(){super(...arguments);p(this,"node")}enable(e,n){const o=n.detect(F.Image,e);return o?(this.node=o,!0):!1}handle(e,n){const o=this.getFileKey(this.node),s={nodeId:this.node.id,fileKey:o,blobUrl:n.resourceManager.getBlobUrl(o)};n.slotManager.addSlotState(ze.ClickImg,s)}getFileKey(e){return e.type===v.SVG?e.svgUrl:e.type===v.IMG?e.imgSrc:""}}class Ba{checkbox(t,e,n){const o=t.checkStatus;n.execAction(new W),sn.blurText(n),n.execAction(U.create(t.id,[{type:I.CheckStatus,checkStatus:!o}])),t.type===v.CheckboxText&&n.execAction(U.create(t.id,[{type:I.Text,strikethrough:!o}])),n.execAction(new z)}}const au=new Set([v.Checkbox,v.CheckboxText]);class cu extends qe{constructor(){super(...arguments);p(this,"node",null);p(this,"checkboxWorker",new Ba)}enable(e,n){const o=[...n.getSelectNodes()];if(o.length!==1)return!1;const s=o[0];return au.has(s.type)&&s.checkboxContain(e.globalPoint)?(this.node=s,!0):!1}handle(e,n){this.node&&this.checkboxWorker.checkbox(this.node,e,n)}}class lu extends qe{enable(t,e){return!!e.detect(F.SlideGap,t)}handle(t,e){const n=e.detect(F.SlideGap,t);if(!n)return;const{slideContainer:o,i:s,j:r}=n,i=o.slideProps.children,a=i[s];if(!a||!a.ids||a.ids.length===0)return;const c=this.getGlobalIndex(i,s,r>0?r-1:0),h=r>0;e.execAction(new W);const d=e.slideManager.insertSlide(o,c,h,e);d&&e.execAction(xe.create([d.id])),e.execAction(new z)}getGlobalIndex(t,e,n){let o=0;for(let s=0;s<e;s++)o+=t[s].ids.length;return o+n}}var kn=(l=>(l[l.A4=0]="A4",l[l.S16_9=1]="S16_9",l[l.S4_3=2]="S4_3",l[l.S1_1=3]="S1_1",l))(kn||{});const Uo={[kn.A4]:{width:595,height:842},[kn.S16_9]:{width:860,height:540},[kn.S4_3]:{width:860,height:720},[kn.S1_1]:{width:600,height:600}};class hu extends qe{enable(t,e){return!!e.detect(F.EmptySlideContainer,t)}handle(t,e){const n=e.detect(F.EmptySlideContainer,t);if(!n)return;const{slideContainer:o,rect:s}=n;e.execAction(new W);const r=Uo[kn.S16_9],i=r.width,a=r.height,d=[ie.create({x:nt,y:xt,width:i,height:a}),tt.create({color:"#F4F2F3"}),Ae.create({color:"#C0A9BD"})],u=e.idGenerator.genId(v.Section),f={id:u,type:v.Section,zIndex:ve.genZIndex(o),parentId:o.id,props:d};e.execAction(Le.create(f));const g=[{ids:[u]}],y=[{id:o.id,props:[St.create({children:g})]}],P=i+2*nt,b=a+2*xt;y.push({id:o.id,props:[{type:I.Base,width:P,height:b}]}),e.execAction(new U({infos:y})),e.execAction(xe.create([u])),e.execAction(new z)}}class Ra extends jt{constructor(){super(),this.registerDownHandler(new hu),this.registerDownHandler(new lu),this.registerDownHandler(new Na),this.registerDownHandler(new er),this.registerDownHandler(new tr),this.registerUpHandler(new nr),this.registerUpHandler(new ka),this.registerUpHandler(new Aa),this.registerUpHandler(new cu),this.registerUpHandler(new iu),this.registerUpHandler(new or)}}class Ea extends pn{constructor(){super([new Ra])}}class du{}class Ha extends du{enable(t){return t.type===v.Line}handle(t,e){e.addOrUpdate(k.HoverLine,{node:t,transform:t.globalTransform()})}}class Da{enable(t){return!0}handle(t,e){e.addOrUpdate(k.HoverBounds,{node:t,transform:t.globalTransform()})}}class Oa{enable(t){return t.type===v.Group}handle(t,e){const n=t;if(e.auxiliaryManager.selectManager.include(t))return;const o=n.nameGlobalTransform();e.addOrUpdate(k.HoverBounds,{node:t,transform:o})}}class Xa{enable(t){return t.type===v.Section}handle(t,e){}}class za{constructor(){p(this,"allowEventTypeSet",new Set([be.pointermove]));p(this,"handlers",[new Ha,new Oa,new Xa,new Da])}process(t,e){const n=e.detect(F.EmptySlideContainer,t);if(n){const i=n.slideContainer,a=n.rect;e.addOrUpdate(k.HoverSlideGapInsertPoint,{point:{x:i.globalBaseProps.x+i.globalBaseProps.width/2,y:i.globalBaseProps.y+i.globalBaseProps.height/2}});const c=ie.create({x:a.x,y:a.y,width:a.width,height:a.height});e.addOrUpdate(k.HoverSlidePlaceHolder,{baseProps:c});return}const o=e.detect(F.SlideGap,t);if(o){e.addOrUpdate(k.HoverSlideGapInsertPoint,{point:o.point});return}const s=e.detect(F.HoverConnectAnchor,t);if(s){s.node.type===v.Shape&&e.previewManager.quickCreateManager.enterQuickPreview(s.node,s.relative,e),e.addOrUpdate(k.HoverConnectAnchor,{point:s.globalPoint});return}e.previewManager.quickCreateManager.exitQuickPreview(e),this.hoverSizer(t,e);const r=e.detect(F.HoverNode,t);if(r){for(const i of this.handlers)if(i.enable(r)){i.handle(r,e);return}}}hoverSizer(t,e){const n=e.detect(F.Stretch,t);if(!n)return;const o=n.nodes,s=o[0];if(n.type===V.BOTTOM_RIGHT)if(o.length===1)e.addOrUpdate(k.HoverSize,{rect:D.baseProps2Rect(s.baseProps),transform:s.globalTransform().clone()});else{const r=e.auxiliaryManager.selectManager.getSelectBounds();e.addOrUpdate(k.HoverSize,{rect:D.rectNode2Rect(r),transform:re.generateMatrix().translate(r.minX,r.minY)})}}}var ye=(l=>(l[l.DEFAULT=0]="DEFAULT",l[l.TEXT=1]="TEXT",l[l.SHAPE=2]="SHAPE",l[l.LINE=3]="LINE",l[l.SECTION=4]="SECTION",l[l.STICKY=5]="STICKY",l[l.HandTool=6]="HandTool",l[l.Resource=7]="Resource",l[l.Widget=8]="Widget",l[l.SlideContainer=9]="SlideContainer",l))(ye||{});class Wa{constructor(t,e,n,o){p(this,"nodeManager");p(this,"inputManager");p(this,"slotManager");p(this,"cursorManager");p(this,"currentTool",ye.DEFAULT);p(this,"shapeType",0);p(this,"grab",!1);p(this,"creatingLine",null);this.nodeManager=t,this.inputManager=e,this.slotManager=n,this.cursorManager=o}setCurrentTool(t,e=0,n=!1){this.currentTool=t,this.shapeType=e,this.grab=n,this.slotManager.addSlotState(ze.ToolChange,{tool:t,shapeType:e}),t===ye.DEFAULT&&this.cursorManager.setCursor("default")}resetTool(){this.creatingLine||this.setCurrentTool(ye.DEFAULT)}setInCreatingLine(t){this.creatingLine=t}}var _n=(l=>(l[l.Checkbox=0]="Checkbox",l[l.CheckboxText=1]="CheckboxText",l))(_n||{});class gt{}class Fa extends gt{constructor(){super(...arguments);p(this,"cursorMap",new Map([[ye.SHAPE,"crosshair"],[ye.SECTION,"crosshair"],[ye.TEXT,"text"],[ye.LINE,"crosshair"]]))}enable(e,n){return this.cursorMap.has(n.toolManager.currentTool)}handle(e,n){if(n.toolManager.grab){n.setCursor("grabbing");return}const o=this.cursorMap.get(n.toolManager.currentTool);n.setCursor(o)}}class uu extends gt{enable(t,e){return!!e.detect(F.ExpandShape,t)}handle(t,e){e.setCursor("pointer")}}class pu extends gt{enable(t,e){const n=e.inputManager.editTextInfo;if(!n)return!1;const{node:o}=n,s=o.getTextContentRect(),r=o.toLocal(t.globalPoint);return!!S.rectContains(r,s)}handle(t,e){e.setCursor("text")}}class Ya extends gt{enable(t,e){const n=e.detect(F.Stretch,t);return n?n.nodes.filter(s=>S.judgeNodeCanBeStretch(s)).length>0:!1}handle(t,e){const n=e.detect(F.Stretch,t);e.setCursor("stretch",n.angle)}}class fu extends gt{enable(t,e){return!!e.detect(F.HoverNode,t)}handle(t,e){e.setCursor("default")}}class sr extends gt{enable(t,e){return!0}handle(t,e){e.setCursor("default")}}class _o{constructor(){p(this,"allowEventTypeSet",new Set([be.pointermove]))}process(t,e){for(const n of this.handlers)if(n.enable(t,e)){n.handle(t,e);return}}}class gu extends gt{enable(t,e){return!!e.detect(F.LineEndPoint,t)}handle(t,e){e.setCursor("move")}}class yu extends gt{constructor(){super(...arguments);p(this,"res",null)}enable(e,n){const o=n.detect(F.PolyControlPoint,e);return o?(this.res=o,!0):!1}handle(e,n){if(!this.res)return;const{isHorizon:o}=this.res;o?n.setCursor("ns-resize"):n.setCursor("ew-resize")}}class xu extends gt{enable(t,e){return!!e.detect(F.Rotate,t)}handle(t,e){const n=e.detect(F.Rotate,t);e.setCursor("rotate",n.cursorAngle)}}class wu extends gt{enable(t,e){return!!e.detect(F.Image,t)}handle(t,e){e.setCursor("zoom-in")}}class mu extends gt{constructor(){super(...arguments);p(this,"res",null)}enable(e,n){const o=n.detect(F.CurveControlPoint,e);return o?(this.res=o,!0):!1}handle(e,n){this.res&&n.setCursor("move")}}class Pu extends gt{constructor(){super(...arguments);p(this,"res",null)}enable(e,n){const o=n.detect(F.CurveEndPoint,e);return o?(this.res=o,!0):!1}handle(e,n){this.res&&n.setCursor("move")}}class bu extends gt{constructor(){super(...arguments);p(this,"res",null)}enable(e,n){const o=n.detect(F.DragLineText,e);return o?(this.res=o,!0):!1}handle(e,n){this.res&&n.setCursor("move")}}class Su extends gt{enable(t,e){var o;const n=e.detect(F.HoverNode,t);return n?!!(((o=n.parent)==null?void 0:o.type)===v.SlideContainer&&e.auxiliaryManager.selectManager.include(n)):!1}handle(t,e){e.setCursor("move")}}class Mu extends gt{enable(t,e){return!!e.detect(F.SlideGap,t)}handle(t,e){e.setCursor("pointer")}}class Ga extends _o{constructor(){super(...arguments);p(this,"handlers",[new Fa,new yu,new Pu,new mu,new bu,new uu,new gu,new pu,new Ya,new xu,new Mu,new Su,new fu,new wu,new sr])}}class Ua extends Ot{constructor(){super([new za,new Ga])}canBeEnable(t,e){return!0}canBeExit(t,e){return!0}}class vu extends gn{enable(t){return t.type===v.Line}handle(t,e,n,o,s){const i=t.parent.globalTransform().inverseMatrix().crossProduct(s),a=[];for(const h of e.points){const d=i.crossPoint(h);a.push(d)}const c=D.rectNode2Rect(S.getBoundsByPoints(a));return[{id:t.id,props:[{type:I.Line,points:a},{type:I.Base,x:c.x,y:c.y,width:c.width,height:c.height}]}]}}class Iu extends gn{enable(t){return t.type===v.SlideContainer}handle(t,e,n,o,s){return[]}}class _a extends Go{constructor(){super(...arguments);p(this,"handlers",[new vu,new la,new ha,new Iu,new ca])}computeOriginTransform(e){const n=this.target,{x:o,y:s}=this.originStretchRect,r=re.generateMatrix().translate(-o,-s),i=this.computeAnchorPoint(n,this.originStretchRect),c=re.generateMatrix().translate(-i.x,-i.y).crossProduct(r);this.originTransform=c}recordPropsMap(e){this.propsMap.clear();for(const n of this.target.nodes){const o=this.recordNodePropInfo(n);if(n.type===v.Line){const r=n.globalLinePoints.map(i=>this.originTransform.crossPoint(i));o.points=r}this.propsMap.set(n,o)}}drawAlignLine(e,n,o){const s=o.auxiliaryManager.selectManager.getSelectBounds(),r=D.rectNode2Rect(s),i=re.generateMatrix().translate(s.minX,s.minY),{width:a,height:c}=n;if(a){e.width+=a.dt;const h={transform:i,line:{start:new m(0,r.height),end:new m(r.width,r.height)}};a.lines.push(h)}if(c){e.height+=c.dt;const h={transform:i,line:{start:new m(r.width,0),end:new m(r.width,r.height)}};c.lines.push(h)}o.addOrUpdate(k.AlignStretchLine,{alignInfo:n})}getMiniSize(e){const n=[],o=[],{width:s,height:r}=this.originStretchRect,i=this.target.nodes;if([...i].filter(d=>d.type===v.Line).length===i.length)return{x:10,y:10};for(const d of i){if(d.type===v.Line)continue;const u=d.getStretchMinSize();n.push(u.x/s),o.push(u.y/r)}const c=Math.max(...n),h=Math.max(...o);return{x:c*s,y:h*r}}getStretchRect(e){const n=e.auxiliaryManager.selectManager.getSelectBounds();return D.rectNode2Rect(n)}}class $a extends Nn{constructor(){super([new _a])}streamEnable(t,e){if(e.getSelectNodes().size===0)return!1;const n=e.detect(F.Stretch,t);if(!n)return!1;const o=n.nodes,s=o.filter(r=>S.judgeNodeCanBeStretch(r));return o.length>1&&s.length>0}}class rr{}class Tu extends rr{constructor(){super(...arguments);p(this,"polylineHandler",new Vt)}enable(e){return e.isPolyLine()}handleMove(e,n,o){const{line:s}=n,r=this.handle(e,n,o),i=S.dealWithEndPolyPoints(r,o.gmlRender.getScale(),!n.isStart),a=s.globalTransform().inverseMatrix(),c=i.map(u=>a.crossPoint(u)),h=D.rectNode2Rect(S.getBoundsByPoints(c));return{id:s.id,props:[{type:I.Line,points:c},ie.create({x:h.x,y:h.y,width:h.width,height:h.height})]}}handleUp(e,n,o,s){const{line:r}=n,i=this.handle(e,n,o),a=S.dealWithEndPolyPointsInUp(i,o.gmlRender.getScale(),!n.isStart),c=r.globalTransform().inverseMatrix(),h=a.map(f=>c.crossPoint(f)),d=D.rectNode2Rect(S.getBoundsByPoints(h));return{id:r.id,props:[{type:I.Line,points:h},ie.create({x:d.x,y:d.y,width:d.width,height:d.height}),s]}}handle(e,n,o){const{line:s}=n,r=s.lineProps;let i=[];return r.auto?i=this.autoLayoutLine(e,n,o):i=this.editLine(e,n,o),i}autoLayoutLine(e,n,o){const{line:s,isStart:r}=n,i=s.connectProps;if(r){const a=e,c=Ze.computeConnectInfo(s,i.end,o,!0);return this.polylineHandler.layoutToPointsPro(a,c)}else{const a=e,c=Ze.computeConnectInfo(s,i.start,o,!1);return this.polylineHandler.layoutToPointsPro(c,a)}}editLine(e,n,o){const{line:s,isStart:r}=n,i=[...s.globalLinePoints];if(i.length===2)return this.autoLayoutLine(e,n,o);const a=e.point;if(r){const c=i[0],h=i[1],d=S.judgeHorizon(c,h);if(i.length>3){const u=i[2];S.distance(h,u)<3&&(d?Math.abs(a.y-u.y)<6:Math.abs(a.x-u.x)<6)&&(d?a.y=u.y:a.x=u.x)}c.x=a.x,c.y=a.y,d?h.y=c.y:h.x=c.x}else{const c=i[i.length-2],h=i[i.length-1],d=S.judgeHorizon(c,h);if(i.length>3){const u=i[i.length-3];S.distance(c,u)<3&&(d?Math.abs(a.y-u.y)<6:Math.abs(a.x-u.x)<6)&&(d?a.y=u.y:a.x=u.x)}h.x=a.x,h.y=a.y,d?c.y=h.y:c.x=h.x}return i}}class Lu extends rr{enable(t){return t.shapeType===he.Line}handle(t,e,n){const{line:o,isStart:s}=e,r=[...o.globalLinePoints];return s?(r.shift(),r.unshift(t.point)):(r.pop(),r.push(t.point)),r}handleMove(t,e,n){const{line:o}=e,s=this.handle(t,e,n),r=o.globalTransform().inverseMatrix(),i=s.map(c=>r.crossPoint(c)),a=D.rectNode2Rect(S.getBoundsByPoints(i));return{id:o.id,props:[{type:I.Line,points:i},ie.create({x:a.x,y:a.y,width:a.width,height:a.height})]}}handleUp(t,e,n,o){const{line:s}=e,r=this.handle(t,e,n),i=s.globalTransform().inverseMatrix(),a=r.map(h=>i.crossPoint(h)),c=D.rectNode2Rect(S.getBoundsByPoints(a));return{id:s.id,props:[{type:I.Line,points:a},ie.create({x:c.x,y:c.y,width:c.width,height:c.height}),o]}}}class Cu extends rr{constructor(){super(...arguments);p(this,"bezierWorker",new zo)}enable(e){return e.shapeType===he.Curve}handle(e,n,o){const{line:s,isStart:r}=n,i=[...s.globalLinePoints],{start:a,end:c}=s.connectProps;if(r){i.shift(),i.unshift(e.point);let h;e.endTypeInfo&&(h=this.bezierWorker.computeConnectEndInfo(e.endTypeInfo,o.nodeManager));const d=this.bezierWorker.computeConnectEndInfo(c,o.nodeManager);return this.bezierWorker.computeCurvePoints(i,h,d)}else{i.pop(),i.push(e.point);let h;e.endTypeInfo&&(h=this.bezierWorker.computeConnectEndInfo(e.endTypeInfo,o.nodeManager));const d=this.bezierWorker.computeConnectEndInfo(a,o.nodeManager);return this.bezierWorker.computeCurvePoints(i,d,h)}}handleMove(e,n,o){const{line:s}=n,r=this.handle(e,n,o),i=s.globalTransform().inverseMatrix(),a=r.map(h=>i.crossPoint(h)),c=D.rectNode2Rect(S.getBoundsByPoints(a));return{id:s.id,props:[{type:I.Line,points:a},ie.create({x:c.x,y:c.y,width:c.width,height:c.height})]}}handleUp(e,n,o,s){const{line:r}=n,i=this.handle(e,n,o),a=r.globalTransform().inverseMatrix(),c=i.map(d=>a.crossPoint(d)),h=D.rectNode2Rect(S.getBoundsByPoints(c));return{id:r.id,props:[{type:I.Line,points:c},ie.create({x:h.x,y:h.y,width:h.width,height:h.height}),s]}}}class $n{constructor(){p(this,"t",.5)}init(t){if(t.renderText.isEmptyText())return;const e=t.getLineLength(),n=t.points,{point:o}=t.lineTextRect,s=t.baseProps,r=new m(o.x+s.x,o.y+s.y);if(t.shapeType===he.Line){const i=S.distance(n[0],r);this.t=i/e;return}if(t.isPolyLine()){let i=0;for(let a=0;a<n.length;a++){const c=n[a],h=n[a+1],d=q.circle(r,1),u=q.line(c,h);if(Y.intersect(d,u).points.length>0){const g=S.distance(r,c);this.t=(g+i)/e;return}i+=S.distance(c,h)}return}if(t.shapeType===he.Curve){const i=S.computeBezierCurves(t);let a=0;for(let c=0;c<i.length;c++){const h=i[c],d=q.circle(r,1),{p0:u,p1:f,p2:g,p3:y}=h,P=q.cubicBezier(u,f,g,y),b=Y.intersect(d,P),w=h.getApproximateLength();if(b.points.length>0){const L=h.getTValueByPoint(r);this.t=(L*w+a)/e;return}a+=w}}}work(t,e,n){if(t.renderText.isEmptyText())return;const{width:o,height:s}=t.lineTextRect,r=S.computePointByT(t,this.t),i=t.baseProps,a=new m(r.x-i.x,r.y-i.y);e.execAction(U.create(t.id,[{type:I.LineTextRect,point:a,x:a.x-.5*o,y:a.y-.5*s}],{streaming:n}))}}class ja extends ht{constructor(){super(...arguments);p(this,"res",null);p(this,"connectEndProp");p(this,"alignWorker",new un);p(this,"groupBaseWorker",new on);p(this,"lineTextWorker",new $n);p(this,"handlers",[new Tu,new Cu,new Lu]);p(this,"currentHandler",null)}selectHandler(){const{line:e,isStart:n}=this.res;for(const o of this.handlers)o.enable(e)&&(this.currentHandler=o)}computeConnectProp(e,n){const o=n.detect(F.LineEndPoint,e);if(!o)return;this.res=o;const s=o.line.connectProps;if(o.isStart){const r=Ze.computeConnectInfo(o.line,s.end,n,!0);this.connectEndProp={isStart:!1,connectInfo:r}}}onStart(e,n){this.computeConnectProp(e,n),this.selectHandler(),n.execAction(new W),this.removeConnectInfoAndSendMsg(e,n),this.groupBaseWorker.start([this.res.line]),this.lineTextWorker.init(this.res.line)}onMove(e,n){if(!this.res)return;const o=this.getConnectInfo(e,n),s=this.currentHandler.handleMove(o,this.res,n);n.execAction(new U({infos:[s]},{streaming:!0})),this.lineTextWorker.work(this.res.line,n,!0),this.groupBaseWorker.work(n,!0)}onUp(e,n){if(!this.res)return;const o=this.addConnectInfoAndSendMsg(e,n),s=this.getConnectInfo(e,n),r=this.currentHandler.handleUp(s,this.res,n,o);n.execAction(new U({infos:[r]},{streaming:!1})),this.lineTextWorker.work(this.res.line,n,!1),this.groupBaseWorker.work(n,!1),n.execAction(new z)}getConnectInfo(e,n){const o=this.res.line,s=this.res.isStart,r=S.dealWithShiftLineInteractEvent(e,o,!s),i=!S.pressMeta(e),c={point:this.alignWorker.alignLineEndAndDrawAlignLines(r,n,n.getSelectNodes(),i)},h=n.detect(F.NodeEdge,r);return h&&(c.point=new m(h.point.x,h.point.y),c.nodeConnect={rect:D.rectNode2Rect(h.node.getBounds()),endType:S.computeNodeConnectEnd(h.relativePos,h.node.baseProps.angle)},c.endTypeInfo=this.computeEndType(e,n)||void 0),c}computeEndType(e,n){const o=n.detect(F.NodeEdge,e);return o?{objectId:o.node.id,x:o.relativePos.x,y:o.relativePos.y}:null}addConnectInfoAndSendMsg(e,n){const{line:o,isStart:s}=this.res,r=o.connectProps.clone(),i=s?"start":"end",a=this.computeEndType(e,n);return a?r[i]=a:r[i]=null,r}removeConnectInfoAndSendMsg(e,n){const{line:o,isStart:s}=this.res,r=o.connectProps.clone(),i=s?"start":"end";r[i]=null;const a={id:o.id,props:[r]};n.execAction(new U({infos:[a]}))}}class $o{constructor(){p(this,"allowEventTypeSet",new Set([be.pointermove]))}process(t,e){const n=e.detect(F.BufferNode,t);if(!n)return;const o=n.filter(s=>s.canBeConnected());o.length!==0&&(e.auxiliaryManager.selectManager.include(o[0])||o[0].canBeConnected()&&e.addOrUpdate(k.HoverConnectAnchorPoint,{node:o[0]}))}}class jo{constructor(){p(this,"allowEventTypeSet",new Set([be.pointermove]))}process(t,e){const n=e.detect(F.HoverConnectAnchor,t);if(n){e.addOrUpdate(k.HoverConnectAnchor,{point:n.globalPoint});return}const o=e.detect(F.HoverNodeAnchor,t);o&&e.addOrUpdate(k.HoverAnchorPoint,{node:o.node,localPoint:o.localPoint})}}class Vo{constructor(){p(this,"allowEventTypeSet",new Set([be.pointermove]))}process(t,e){if(e.toolManager.currentTool!==ye.LINE)return;const o=e.detect(F.NodeEdge,t);o&&e.addOrUpdate(k.HoverConnectPoint,{point:o.point})}}class Au extends dt{constructor(){super([new ja],[new $o,new jo,new Vo])}streamEnable(t,e){return!!e.detect(F.LineEndPoint,t)}}class Ko{setPointValue(t,e,n,o){t?(e.y=o.y,n.y=o.y):(e.x=o.x,n.x=o.x)}}class Nu extends Ko{enable(t){const{rIndex:e,lIndex:n,line:o}=t,s=[...o.points];return n>0&&e<s.length-1}handle(t,e,n){const{rIndex:o,lIndex:s,line:r,isHorizon:i}=t,a=[...r.points],c=r.toLocal(e.globalPoint),h=a[s],d=a[o],u=a[o+1],f=a[s-1],g=n.gmlRender.getScale();return S.distance(f,h)<3/g&&(i?Math.abs(c.y-f.y)<6/g:Math.abs(c.x-f.x)<6/g)?i?c.y=f.y:c.x=f.x:S.distance(d,u)<3/g&&(i?Math.abs(c.y-u.y)<6/g:Math.abs(c.x-u.x)<6/g)&&(i?c.y=u.y:c.x=u.x),this.setPointValue(i,h,d,c),a}setPointValue(t,e,n,o){t?(e.y=o.y,n.y=o.y):(e.x=o.x,n.x=o.x)}}class ku extends Ko{enable(t){const{rIndex:e,lIndex:n,line:o}=t,s=[...o.points];return n===0&&e===1&&s.length===2}handle(t,e){const{rIndex:n,lIndex:o,line:s,isHorizon:r}=t,i=[...s.points],{start:a,end:c}=s.connectProps,h=i[o],d=i[n],u=s.toLocal(e.globalPoint);if(!a&&!c)return this.setPointValue(r,h,d,u),i;if(c&&!a){if(r){const P=d.x>h.x?1:-1,b=new m(d.x-P*A,d.y),w=new m(d.x-P*A,u.y);return i.splice(o+1,0,b,w),t.lIndex=o+2,t.rIndex=n+2,i}const f=d.y>h.y?1:-1,g=new m(d.x,d.y-f*A),y=new m(u.x,d.y-f*A);return i.splice(o+1,0,g,y),t.lIndex=o+2,t.rIndex=n+2,i}if(a&&!c){if(r){const P=d.x>h.x?1:-1,b=new m(h.x+P*A,h.y),w=new m(h.x+P*A,u.y);return i.splice(o+1,0,b,w),t.lIndex=o+2,t.rIndex=n+2,i}const f=d.y>h.y?1:-1,g=new m(h.x,h.y-f*A),y=new m(u.x,h.y-f*A);return i.splice(o+1,0,g,y),t.lIndex=o+2,t.rIndex=n+2,i}if(a&&c){if(r){const w=d.x>h.x?1:-1,L=new m(h.x+w*A,h.y),B=new m(h.x+w*A,u.y),H=new m(d.x-w*A,d.y),E=new m(d.x-w*A,u.y);return i.splice(o+1,0,L,B,H,E),t.lIndex=o+4,t.rIndex=n+4,i}const f=d.y>h.y?1:-1,g=new m(h.x,h.y-f*A),y=new m(u.x,h.y-f*A),P=new m(d.x,d.y-f*A),b=new m(u.x,d.y-f*A);return i.splice(o+1,0,g,y,P,b),t.lIndex=o+4,t.rIndex=n+4,i}return[]}}class Bu extends Ko{enable(t){const{lIndex:e}=t;return e===0}handle(t,e){const{rIndex:n,lIndex:o,line:s,isHorizon:r}=t,i=[...s.points],{start:a,end:c}=s.connectProps,h=i[o],d=i[n],u=s.toLocal(e.globalPoint);if(!a)return this.setPointValue(r,h,d,u),i;if(r){const P=d.x>h.x?1:-1,b=new m(h.x+P*A,h.y),w=new m(h.x+P*A,u.y);return i.splice(o+1,0,b,w),t.lIndex=o+2,t.rIndex=n+2,i}const f=d.y<h.y?1:-1,g=new m(h.x,h.y-f*A),y=new m(u.x,h.y-f*A);return i.splice(o+1,0,g,y),t.lIndex=o+2,t.rIndex=n+2,i}}class Ru extends Ko{enable(t){const{rIndex:e,line:n}=t;return e===n.points.length-1}handle(t,e){const{rIndex:n,lIndex:o,line:s,isHorizon:r}=t,i=[...s.points],{end:a}=s.connectProps,c=i[o],h=i[n],d=s.toLocal(e.globalPoint);if(!a)return this.setPointValue(r,c,h,d),i;if(r){const y=h.x<c.x?1:-1,P=new m(h.x+y*A,h.y),b=new m(h.x+y*A,d.y);return i.splice(o+1,0,b,P),c.y=d.y,i}const u=h.y>c.y?1:-1,f=new m(h.x,h.y-u*A),g=new m(d.x,h.y-u*A);return i.splice(o+1,0,g,f),c.x=d.x,i}}class Eu extends ht{constructor(){super(...arguments);p(this,"res");p(this,"handlers",[new Nu,new ku,new Bu,new Ru]);p(this,"lineTextWorker",new $n)}onStart(e,n){this.res=n.detect(F.PolyControlPoint,e),n.execAction(new W),this.lineTextWorker.init(this.res.line)}onMove(e,n){const{line:o}=this.res,s=this.computeLinePoints(e,n),r=D.rectNode2Rect(S.getBoundsByPoints(s)),i={infos:[{id:o.id,props:[{type:I.Line,points:s,auto:!1},ie.create({x:r.x,y:r.y,width:r.width,height:r.height})]}]};n.execAction(new U(i,{streaming:!0})),this.lineTextWorker.work(this.res.line,n,!0)}onUp(e,n){const{line:o}=this.res,s=n.gmlRender.getScale(),r=this.computeLinePoints(e,n),i=S.dealWithPolyPoints(r,s),a=D.rectNode2Rect(S.getBoundsByPoints(i)),c={infos:[{id:o.id,props:[{type:I.Line,points:i,auto:!1},ie.create({x:a.x,y:a.y,width:a.width,height:a.height})]}]};n.execAction(new U(c,{streaming:!1})),this.lineTextWorker.work(this.res.line,n,!1),n.execAction(new z)}computeLinePoints(e,n){for(const o of this.handlers)if(o.enable(this.res))return o.handle(this.res,e,n);return[]}}class Hu extends dt{constructor(){super([new Eu],[])}streamEnable(t,e){return!!e.detect(F.PolyControlPoint,t)}}class Du extends ht{constructor(){super(...arguments);p(this,"startConnectInfo",{point:new m});p(this,"target",null);p(this,"layoutHandler",new Vt);p(this,"alignWorker",new un)}onStart(e,n){this.startConnectInfo.point=e.globalPoint;const s=[new Oe(he.RoundPolyLine)],{node:r,relative:i}=n.detect(F.HoverConnectAnchor,e),a={type:I.Connect,start:{objectId:r.id,x:i.x,y:i.y}};s.push(a);const c=Ze.getNodePos(r,i);this.startConnectInfo={point:new m(c.x,c.y),nodeConnect:{rect:D.rectNode2Rect(r.getBounds()),endType:S.computeNodeConnectEnd(i,r.baseProps.angle)}};const h={point:e.globalPoint.clone()},d=this.layoutHandler.layoutToPointsPro(this.startConnectInfo,h),u=je.create(d),f=D.rectNode2Rect(S.getBoundsByPoints(d)),g=ie.create({x:f.x,y:f.y,width:f.width,height:f.height});s.push(u,g,new Ae,lt.create({rArrow:it.Arrow}),Ge.create({sizeMode:We.autoWidth}),new Et);const y=n.idGenerator.genId(v.Line),P={id:y,type:v.Line,zIndex:ve.genZIndex(n.nodeManager.root),parentId:"",props:s};n.actionManager.execAction(new W);const b=Le.create(P);n.actionManager.execAction(b),this.target=n.nodeManager.nodeMap.get(y),n.actionManager.execAction(xe.create([this.target.id])),n.setCursor("crosshair")}onMove(e,n){const o=S.dealWithShiftLineInteractEvent(e,this.target),s=Ze.computeLinePoints(this.startConnectInfo,this.layoutHandler,o,n,this.alignWorker),r=S.dealWithEndPolyPoints(s,n.gmlRender.getScale(),!0),i=D.rectNode2Rect(S.getBoundsByPoints(r)),a=[je.create(r),ie.create({x:i.x,y:i.y,width:i.width,height:i.height})],c={infos:[{id:this.target.id,props:a}]};n.actionManager.execAction(new U(c,{streaming:!0}))}onUp(e,n){const o=S.dealWithShiftLineInteractEvent(e,this.target),s=[],r=n.detect(F.NodeEdge,o);if(r){const d=this.target.connectProps.clone();d.end={objectId:r.node.id,x:r.relativePos.x,y:r.relativePos.y},s.push(d)}const i=Ze.computeLinePoints(this.startConnectInfo,this.layoutHandler,o,n,this.alignWorker),a=S.dealWithEndPolyPointsInUp(i,n.gmlRender.getScale(),!0),c=D.rectNode2Rect(S.getBoundsByPoints(a));s.push(je.create(a),ie.create({x:c.x,y:c.y,width:c.width,height:c.height}));const h={infos:[{id:this.target.id,props:s}]};if(n.actionManager.execAction(new U(h,{streaming:!1})),!r){n.execAction(xe.create([]));const d={clientPoint:o.clientPoint,show:!0,lineId:this.target.id};n.slotManager.addSlotState(ze.QuickCreate,d)}n.execAction(new z),n.setCursor("default")}}class Ou extends dt{constructor(){super([new Du],[new $o,new jo,new Vo])}streamEnable(t,e){return!!e.detect(F.HoverConnectAnchor,t)}}class ir{}const Xu=new Set([v.Shape,v.SVG,v.IMG]);class zu extends ir{enable(t){return Xu.has(t.type)}handle(t,e,n,o){const s=t.baseProps,r=new m(0,0),i=t.toGlobal(r),a=e.crossPoint(i),h=t.parent.globalTransform().inverseMatrix().crossPoint(a);o.push({id:t.id,props:[{type:I.Base,x:h.x,y:h.y,angle:s.angle+n}]})}}class Wu extends ir{enable(t){return t.type===v.Line}handle(t,e,n,o){const{start:s,end:r}=t.connectProps;if(s||r)return;const i=t.lineProps,a=[],c=[];for(const u of i.points){const f=e.crossPoint(u);a.push(f)}c.push({type:I.Line,points:a});const h=S.getBoundsByPoints(a),d={type:I.Base,x:h.minX,y:h.minY,width:h.maxX-h.minX,height:h.maxY-h.minY};c.push(d),o.push({id:t.id,props:c})}}class Fu extends ir{constructor(){super(...arguments);p(this,"layoutHandler",new Vt)}enable(e){return e.type!==v.Line?!1:e.isPolyLine()}handle(e,n,o,s){const{start:r,end:i}=e.connectProps;if(r||i)return;const a=e.lineProps,c=[],h=a.points[0],d=a.points[a.points.length-1],u=n.crossPoint(h),f=n.crossPoint(d),g=this.layoutHandler.layoutToPointsPro({point:u},{point:f});c.push({type:I.Line,points:g});const y=S.getBoundsByPoints(g),P={type:I.Base,x:y.minX,y:y.minY,width:y.maxX-y.minX,height:y.maxY-y.minY};c.push(P),s.push({id:e.id,props:c})}}class Va extends ht{constructor(){super(...arguments);p(this,"rotateInfo",null);p(this,"lastAngle",0);p(this,"originAngle",0);p(this,"originNodeAngle",0);p(this,"matrix",re.generateMatrix());p(this,"reverseMatrix",re.generateMatrix());p(this,"layoutWorker",new Rn);p(this,"groupBaseWorker",new on);p(this,"handlers",[new zu,new Fu,new Wu])}onStart(e,n){this.rotateInfo=n.detect(F.Rotate,e);const o=Ze.trimPoint(e.globalPoint),s=this.rotateInfo.rotateCenter,r=this.rotateInfo.nodes;r.length===1?this.originNodeAngle=r[0].baseProps.angle:this.originNodeAngle=0,this.lastAngle=Ze.calculateAngle(s,o),this.originAngle=this.lastAngle;const i=re.generateMatrix().translate(-s.x,-s.y);this.matrix=i,this.reverseMatrix=i.inverseMatrix(),n.actionManager.execAction(new W),n.inputManager.editTextInfo&&n.execAction(ee.blur(n.inputManager.editTextInfo.node.id)),this.groupBaseWorker.start(this.rotateInfo.nodes)}onMove(e,n){this.rotateNode(e,n,!0),this.removeAuxiliaryGraphics(n)}onUp(e,n){this.rotateNode(e,n,!1),n.auxiliaryManager.selectManager.refreshSelectStatus(),n.setCursor("default"),n.actionManager.execAction(new z),this.rotateInfo=null}removeAuxiliaryGraphics(e){e.removeAuxGraphic(k.HighlightRects),e.removeAuxGraphic(k.MultiSelectBound),e.removeAuxGraphic(k.SingleSelectBound),e.removeAuxGraphic(k.StretchRect),e.removeAuxGraphic(k.ExpandShape),e.removeAuxGraphic(k.SelectConnectAnchor)}rotateNode(e,n,o){const s=Ze.trimPoint(e.globalPoint),r=this.rotateInfo.rotateCenter;let i=Ze.calculateAngle(r,s);i=this.computeDeltaAngle(e,i);const a=i-this.lastAngle,c=re.generateMatrix().rotate(a),h=this.reverseMatrix.crossProduct(c).crossProduct(this.matrix),d=[],u=new Set;for(const f of this.rotateInfo.nodes){for(const g of this.handlers)if(g.enable(f)){g.handle(f,h,a,d);break}this.layoutWorker.collectNodeLinks(f,n,u)}if(n.execAction(new U({infos:d},{streaming:o})),this.lastAngle=i,this.rotateInfo.nodes.length===1){const f=S.computeRotateDeltaAngle(this.rotateInfo.rotateType),g=S.computeRotateAngle(this.rotateInfo.nodes,f);n.setCursor("rotate",g)}this.layoutWorker.work([...u],n,o),this.groupBaseWorker.work(n,o)}computeDeltaAngle(e,n){if(e.originEvent.ctrlKey)return n;let o=n-this.originAngle+this.originNodeAngle;const s=Ze.trimAngle(o),r=7.5;return Math.abs(s)<r?(o+=0-s,o+this.originAngle-this.originNodeAngle):Math.abs(s-90)<r?(o+=90-s,o+this.originAngle-this.originNodeAngle):Math.abs(s-180)<r?(o+=180-s,o+this.originAngle-this.originNodeAngle):Math.abs(s-270)<r?(o+=270-s,o+this.originAngle-this.originNodeAngle):Math.abs(s-360)<r?(o+=360-s,o+this.originAngle-this.originNodeAngle):n}}class Ka extends Nn{constructor(){super([new Va])}streamEnable(t,e){return e.getSelectNodes().size===0?!1:!!e.detect(F.Rotate,t)}}const Xt=100,rn=50;class Qa{computeEndNodeRelative(t,e){const n=t.drawer.getConnectAnchor(),o=S.computeOriginNodeConnectEnd(e);let s;return o===de.Top?s=n[de.Bottom]:o===de.Bottom?s=n[de.Top]:o===de.Left?s=n[de.Right]:s=n[de.Left],s}judgeQuickCreateMode(t,e,n){const o=S.computeNodeConnectEnd(e,t.baseProps.angle),s=t.globalBaseProps,r=s.clone();o===de.Top?r.y=s.y-s.height-Xt:o===de.Bottom?r.y=s.y+s.height+Xt:o===de.Left?r.x=s.x-s.width-Xt:r.x=s.x+s.width+Xt;const i=S.getBoundsByBaseProps(r),a=n.nodeManager.searchNodesByRectNode(i).filter(h=>h.type!==v.Line&&h.type!==v.Section),c=S.sortGraphics(a);return c.length===0?null:c[c.length-1]}computePreviewNodePos(t,e,n){const o=S.computeNodeConnectEnd(e,t.baseProps.angle);return o===de.Top?this.findTopPlace(t,o,n):o===de.Bottom?this.findBottomPlace(t,o,n):o===de.Left?this.findLeftPlace(t,o,n):this.findRightPlace(t,o,n)}findTopPlace(t,e,n){const o=t.globalBaseProps;for(let s=0;s<20;s++){const r=o.clone();r.y=o.y-o.height-Xt;const i=s%2,a=Math.ceil(s/2);i?r.x-=a*(o.width+rn):r.x+=a*(o.width+rn);const c=S.getBoundsByBaseProps(r);if(n.nodeManager.searchNodesByRectNode(c).filter(d=>d.type!==v.Line&&d.type!==v.Section).length===0)return{x:r.x,y:r.y}}return{x:o.x,y:o.y-o.height-rn}}findBottomPlace(t,e,n){const o=t.globalBaseProps;for(let s=0;s<20;s++){const r=o.clone();r.y=o.y+o.height+Xt;const i=s%2,a=Math.ceil(s/2);i?r.x-=a*(o.width+rn):r.x+=a*(o.width+rn);const c=S.getBoundsByBaseProps(r);if(n.nodeManager.searchNodesByRectNode(c).filter(d=>d.type!==v.Line&&d.type!==v.Section).length===0)return{x:r.x,y:r.y}}return{x:o.x,y:o.y+o.height+Xt}}findRightPlace(t,e,n){const o=t.globalBaseProps;for(let s=0;s<20;s++){const r=o.clone();r.x=o.x+o.width+Xt;const i=s%2,a=Math.ceil(s/2);i?r.y-=a*(o.width+rn):r.y+=a*(o.width+rn);const c=S.getBoundsByBaseProps(r);if(n.nodeManager.searchNodesByRectNode(c).filter(d=>d.type!==v.Line&&d.type!==v.Section).length===0)return{x:r.x,y:r.y}}return{x:o.x+o.width+Xt,y:o.y}}findLeftPlace(t,e,n){const o=t.globalBaseProps;for(let s=0;s<20;s++){const r=o.clone();r.x=o.x-o.width-Xt;const i=s%2,a=Math.ceil(s/2);i?r.y-=a*(o.width+rn):r.y+=a*(o.width+rn);const c=S.getBoundsByBaseProps(r);if(n.nodeManager.searchNodesByRectNode(c).filter(d=>d.type!==v.Line&&d.type!==v.Section).length===0)return{x:r.x,y:r.y}}return{x:o.x-o.width-Xt,y:o.y}}}class Yu extends qe{constructor(){super(...arguments);p(this,"createWorker",new Qa);p(this,"layoutHandler",new Vt)}enable(e,n){const o=n.detect(F.HoverConnectAnchor,e);return o?o.node.type===v.Shape:!1}isParentRoot(e,n,o){const s=e.parent;if(s===o.nodeManager.root)return!0;const r=e.getBounds(),i=e.globalPos,a=n.x-i.x,c=n.y-i.y,h={minX:r.minX+a,minY:r.minY+c,maxX:r.maxX+a,maxY:r.maxY+c},d=s.getBounds();return!(S.containRect(d,h)||S.overlapRect(d,h))}handle(e,n){const o=n.detect(F.HoverConnectAnchor,e),s=o.node,r=o.relative,i=this.createWorker.judgeQuickCreateMode(s,r,n);if(i){this.handleCreateLineAndLink(i,e,n);return}this.handleCreateNode(e,n)}handleCreateLine(e,n,o,s){const r=o.globalPos,i=this.createWorker.computeEndNodeRelative(e,n),a=e.baseProps,c=e.toGlobal({x:n.x*a.width,y:n.y*a.height}),h=this.isParentRoot(e,r,s),d=o.id,u=o.baseProps,f=o.toGlobal({x:i.x*u.width,y:i.y*u.height}),g={point:c,nodeConnect:{rect:D.rectNode2Rect(e.getBounds()),endType:S.computeNodeConnectEnd(n,e.baseProps.angle)}},y={point:f,nodeConnect:{rect:D.rectNode2Rect(o.getBounds()),endType:S.computeNodeConnectEnd(i,o.baseProps.angle)}},P=this.makeupLineProps(g,y,e.parent,h);P.push({type:I.Connect,start:{objectId:e.id,x:n.x,y:n.y},end:{objectId:d,x:i.x,y:i.y}});const b=s.idGenerator.genId(v.Line);return s.execAction(Le.create({id:b,zIndex:ve.genZIndex(s.nodeManager.root),type:v.Line,props:P,parentId:h?"":e.parent.id})),b}handleCreateLineAndLink(e,n,o){const s=o.detect(F.HoverConnectAnchor,n),r=s.node,i=s.relative;o.execAction(new W);const a=this.handleCreateLine(r,i,e,o);o.execAction(xe.create([a])),sn.blurText(o),o.execAction(new z)}handleCreateNode(e,n){const o=n.detect(F.HoverConnectAnchor,e),s=o.node,r=o.relative,i=this.createWorker.computePreviewNodePos(s,r,n),a=this.isParentRoot(s,i,n),c=this.makeupNodeProps(s,i,a),h=n.idGenerator.genId(v.Shape);n.execAction(new W),n.execAction(Le.create({id:h,zIndex:ve.genZIndex(n.nodeManager.root),type:v.Shape,props:c,parentId:a?"":s.parent.id}));const d=n.nodeManager.getNode(h);if(this.handleCreateLine(s,r,d,n),n.execAction(xe.create([h])),d.type===v.Shape&&d.shapeType===K.PureText){const u=d.renderText;n.execAction(ee.selection(h,u.headTextCursorPosition(),u.tailTextCursorPosition()))}else n.execAction(ee.focus(h));n.execAction(new z)}makeupNodeProps(e,n,o){const s=e.baseProps,r=e.shapeType;let i=n;o||(i=e.parent.globalTransform().inverseMatrix().crossPoint(i));const a=i.x,c=i.y,h=e.colorProps,d=e.borderProps,u=[{type:I.Base,x:a,y:c,width:s.width,height:s.height,angle:s.angle},tt.create({...h}),Ae.create({...d}),new Oe(r)];if(e.type===v.Shape&&e.shapeType===K.PureText){const f=e.textProps;u.push(f.clone());const g=e.paragraphProps;u.push(g.clone())}return u}makeupLineProps(e,n,o,s){let r=this.layoutHandler.layoutToPointsPro(e,n);if(!s){const c=o.globalTransform().inverseMatrix();r=r.map(h=>c.crossPoint(h))}const i=D.rectNode2Rect(S.getBoundsByPoints(r));return[je.create(r),ie.create({x:i.x,y:i.y,width:i.width,height:i.height}),lt.create({rArrow:it.Arrow}),new Oe(he.RoundPolyLine)]}}class Gu extends jt{constructor(){super(),this.registerUpHandler(new Yu)}}class Uu extends pn{constructor(){super([new Gu])}clickEnable(t,e){return!!e.detect(F.HoverConnectAnchor,t)}}class Za extends qe{constructor(){super(...arguments);p(this,"group",null)}enable(e,n){const o=[...n.getSelectNodes()];if(o.length!==1)return!1;const s=o[0];if(s.type!==v.Group)return!1;const r=s;return r.contains(e.globalPoint)?(this.group=r,!0):!1}handle(e,n){if(this.group){for(const o of this.group.children)if(o.contains(e.globalPoint)){n.execAction(new W),n.execAction(xe.create([o.id])),n.execAction(new z);return}}}}class _u extends qe{constructor(){super(...arguments);p(this,"res",null)}enable(e,n){const o=n.detect(F.Node,e);if(o){const s=o[0];if(n.auxiliaryManager.selectManager.include(s)){const r=s.toLocal(e.globalPoint);if(s instanceof vt&&s.renderText.contains(r))return this.res={node:s,relativePos:r},!0;if(s instanceof Ct)return this.res={node:s,relativePos:r},!0;if(s instanceof Un&&s.renderText.contains(r))return this.res={node:s,relativePos:r},!0}}return!1}handle(e,n){if(!this.res)return;const{node:o,relativePos:s}=this.res;if(o.isEmptyText()){const r=o.renderText.detect(s);if(n.execAction(new W),o instanceof Ct&&o.renderText.isEmptyText()){const{height:a}=o.renderText,c=o.baseProps,h=S.computePointByT(o,.5),d=h.x-.5*20,u=h.y-.5*a,f=new D(d,u,20,a);n.execAction(U.create(o.id,[{type:I.LineTextRect,x:f.x-c.x,y:f.y-c.y,width:f.width,height:f.height,point:{x:h.x-c.x,y:h.y-c.y}}]))}n.execAction(ee.focus(o.id,r)),n.execAction(new z);return}n.execAction(new W),n.execAction(ee.selection(o.id,Fe.head(),o.renderText.tailTextCursorPosition())),n.execAction(new z)}}const $u=new Set([v.Checkbox,v.CheckboxText]);class ju extends qe{constructor(){super(...arguments);p(this,"node",null);p(this,"checkboxWorker",new Ba)}enable(e,n){const o=n.detect(F.Node,e);if(!o)return!1;const s=o[0];return $u.has(s.type)&&s.checkboxContain(e.globalPoint)?(this.node=s,!0):!1}handle(e,n){this.node&&this.checkboxWorker.checkbox(this.node,e,n)}}class Vu extends jt{constructor(){super(),this.registerDownHandler(new Za),this.registerDownHandler(new _u),this.registerDownHandler(new ju)}}class Ku extends js{constructor(){super([new Vu])}}class Qu extends qe{constructor(){super(...arguments);p(this,"node",null)}enable(e,n){return!0}handle(e,n){if(n.getSelectNodes().size>0){const r=n.auxiliaryManager.selectManager.getSelectBounds();if(S.rectContains2(e.globalPoint,r)){const i={clientPoint:e.clientPoint,show:!0,hasFocus:n.getSelectNodes().size>0};n.slotManager.addSlotState(ze.ContextMenu,i);return}}const o=n.detect(F.Node,e);if(o&&o.length>0){const r=o[0];n.auxiliaryManager.selectManager.include(r)||(n.execAction(new W),n.execAction(xe.create([r.id])),n.execAction(new z))}else n.execAction(new W),n.execAction(xe.create([])),n.execAction(new z);const s={clientPoint:e.clientPoint,show:!0,hasFocus:n.getSelectNodes().size>0};n.slotManager.addSlotState(ze.ContextMenu,s)}}class Zu extends jt{constructor(){super(),this.registerUpHandler(new Qu)}}class qu extends pn{constructor(){super([new Zu])}canBeEnable(t,e){return t.originEvent.button===2}}class qa extends ht{constructor(){super(...arguments);p(this,"lastPoint",null)}onStart(e,n){this.lastPoint=e.clientPoint,n.setCursor("grabbing")}onMove(e,n){if(!this.lastPoint)return;n.setCursor("grabbing");const o=e.clientPoint,s=o.x-this.lastPoint.x,r=o.y-this.lastPoint.y;n.renderManager.scroll(-s,-r),this.lastPoint=o}onUp(e,n){n.setCursor("grab")}}class Ju extends dt{constructor(){super([new qa])}streamEnable(t,e){return t.originEvent.button===2}}class ep extends ht{constructor(){super(...arguments);p(this,"line");p(this,"bezierWorker",new zo);p(this,"startPoint");p(this,"endPoint");p(this,"leftPoints",[]);p(this,"rightPoints",[]);p(this,"lineTextWorker",new $n)}onStart(e,n){const{line:o,lPoint:s,rPoint:r,curve:i,index:a}=n.detect(F.CurveControlPoint,e);this.line=o,this.startPoint=s,this.endPoint=r;const{lP:c,rP:h,midPoint:d}=this.bezierWorker.splitCurve(i),u=JSON.parse(JSON.stringify(o.points));this.leftPoints=u.slice(0,a),this.rightPoints=u.slice(a+4);const g=.4*S.distance(this.startPoint,e.globalPoint),y=new m(this.startPoint.x+g,this.startPoint.y),P=i.p3,w=.4*S.distance(P,d),L=new m(P.x-w,P.y),B=[...this.leftPoints,s,y,c,d,h,L,r,...this.rightPoints];this.lineTextWorker.init(o),n.execAction(new W);const H=this.bezierWorker.computeCurvePointsForLine(o,n.nodeManager,B);n.execAction(U.create(this.line.id,[{type:I.Line,points:H}]))}onMove(e,n){this.onWork(e,n,!0)}onUp(e,n){this.onWork(e,n,!1),n.execAction(new z)}onWork(e,n,o){const s=e.globalPoint,i=.4*S.distance(this.startPoint,s),a=new m(this.startPoint.x+i,this.startPoint.y),c=this.endPoint,d=.4*S.distance(c,e.globalPoint),u=new m(c.x-d,c.y),{lP:f,rP:g,midPoint:y}=this.bezierWorker.computeCurveControlPoint(a,s,u),P=this.startPoint,b=this.endPoint,w=[...this.leftPoints,P,a,f,y,g,u,b,...this.rightPoints],L=this.bezierWorker.computeCurvePointsForLine(this.line,n.nodeManager,w);n.execAction(U.create(this.line.id,[{type:I.Line,points:L}],{streaming:o})),this.lineTextWorker.work(this.line,n,o)}}class tp extends dt{constructor(){super([new ep],[])}streamEnable(t,e){return!!e.detect(F.CurveControlPoint,t)}}class np extends ht{constructor(){super(...arguments);p(this,"line");p(this,"dragIndex");p(this,"bezierWorker",new zo);p(this,"lineTextWorker",new $n)}onStart(e,n){const{line:o,index:s}=n.detect(F.CurveEndPoint,e);this.line=o,this.dragIndex=s,n.execAction(new W),this.lineTextWorker.init(o)}onMove(e,n){this.onWork(e,n,!0)}onUp(e,n){this.onWork(e,n,!1),n.execAction(new z)}onWork(e,n,o){const s=this.line,r=[...s.points];r.splice(this.dragIndex,1,e.globalPoint);const i=this.bezierWorker.computeCurvePointsForLine(s,n.nodeManager,r);n.execAction(U.create(this.line.id,[{type:I.Line,points:i}],{streaming:o})),this.lineTextWorker.work(s,n,o)}}class op extends dt{constructor(){super([new np],[])}streamEnable(t,e){return!!e.detect(F.CurveEndPoint,t)}}class ar{init(t){}dealWithPoint(t,e){t.x<e.minX&&(t.x=e.minX),t.y<e.minY&&(t.y=e.minY),t.x>e.maxX&&(t.x=e.maxX),t.y>e.maxY&&(t.y=e.maxY)}}class sp extends ar{constructor(){super(...arguments);p(this,"lineShapes",[])}init(e){const n=[],o=e.globalLinePoints;for(let s=0;s<o.length-1;s++){const r=o[s],i=o[s+1],a=q.line(r,i),c=S.judgeHorizon(r,i);n.push({isHorizon:c,shapeInfo:a})}this.lineShapes=n}enable(e){return e.isPolyLine()}handle(e,n){const o=e.getBounds(),{minX:s,minY:r,maxX:i,maxY:a}=o,c=this.lineShapes,h={x:n.x,y:n.y};this.dealWithPoint(h,o);const d=10,u=q.line({x:s-d,y:h.y},{x:i+d,y:h.y}),f=q.line({x:h.x,y:r-d},{x:h.x,y:a+d}),g=[];for(const b of c)if(b.isHorizon){const w=Y.intersect(b.shapeInfo,f);if(w.points.length>0){const L=w.points[0],B=S.distance(L,h);g.push({point:L,distance:B})}}else{const w=Y.intersect(b.shapeInfo,u);if(w.points.length>0){const L=w.points[0],B=S.distance(L,h);g.push({point:L,distance:B})}}if(g.length===0)return console.warn("探测结果出现问题,兜底容错"),null;const y=Math.min(...g.map(b=>b.distance));return g.find(b=>b.distance-y<.1)??null}dealWithPoint(e,n){e.x<n.minX&&(e.x=n.minX),e.y<n.minY&&(e.y=n.minY),e.x>n.maxX&&(e.x=n.maxX),e.y>n.maxY&&(e.y=n.maxY)}}class rp extends ar{constructor(){super(...arguments);p(this,"lineShape")}init(e){const n=e.globalLinePoints,o=n[0],s=n[n.length-1],r=q.line({x:o.x,y:o.y},{x:s.x,y:s.y});this.lineShape=r}enable(e){return e.shapeType===he.Line}handle(e,n){const o=e.getBounds(),{minX:s,minY:r,maxX:i,maxY:a}=o,c={x:n.x,y:n.y};this.dealWithPoint(c,o);const h=10,d=q.line({x:s-h,y:c.y},{x:i+h,y:c.y}),u=q.line({x:c.x,y:r-h},{x:c.x,y:a+h}),f=[];if(this.intersectLine(d,c,f),this.intersectLine(u,c,f),f.length===0)return console.warn("探测结果出现问题,兜底容错"),null;const g=Math.min(...f.map(P=>P.distance));return f.find(P=>P.distance-g<.1)??null}intersectLine(e,n,o){const s=Y.intersect(this.lineShape,e);if(s.points.length>0){const r=s.points[0],i=S.distance(r,n);o.push({point:r,distance:i})}}}class ip extends ar{constructor(){super(...arguments);p(this,"lineShapes",[])}init(e){const n=S.computeBezierCurves(e),o=[];for(const s of n){const r=q.cubicBezier(s.p0,s.p1,s.p2,s.p3);o.push(r)}this.lineShapes=o}enable(e){return e.shapeType===he.Curve}handle(e,n){const o=e.getBounds(),{minX:s,minY:r,maxX:i,maxY:a}=o,c={x:n.x,y:n.y};this.dealWithPoint(c,o);const h=10,d=q.line({x:s-h,y:c.y},{x:i+h,y:c.y}),u=q.line({x:c.x,y:r-h},{x:c.x,y:a+h}),f=[];for(const P of this.lineShapes)this.intersectLine(P,d,c,f),this.intersectLine(P,u,c,f);if(f.length===0)return console.warn("探测结果出现问题,兜底容错"),null;const g=Math.min(...f.map(P=>P.distance));return f.find(P=>P.distance-g<.1)??null}intersectLine(e,n,o,s){const r=Y.intersect(e,n);if(r.points.length>0){const i=r.points[0],a=S.distance(i,o);s.push({point:i,distance:a})}}}class ap extends ht{constructor(){super(...arguments);p(this,"line");p(this,"intersectHandlers",[new sp,new ip,new rp]);p(this,"currentHandler",null)}onStart(e,n){const{line:o}=n.detect(F.DragLineText,e);this.line=o,this.selectHandler(o),n.execAction(new W)}onMove(e,n){this.onWork(e,n,!0)}onUp(e,n){this.onWork(e,n,!1),n.execAction(new z)}onWork(e,n,o){if(!this.currentHandler)return;const s=e.globalPoint,r=this.currentHandler.handle(this.line,s);if(!r)return;const{width:i,height:a}=this.line.lineTextRect,c=this.line.baseProps,h=r.point,d=h.x-.5*i-c.x,u=h.y-.5*a-c.y;n.execAction(U.create(this.line.id,[{type:I.LineTextRect,x:d,y:u,point:{x:h.x-c.x,y:h.y-c.y}}],{streaming:o}))}selectHandler(e){for(const n of this.intersectHandlers)if(n.enable(e)){n.init(e),this.currentHandler=n;return}}}class cp extends dt{constructor(){super([new ap])}streamEnable(t,e){return!!e.detect(F.DragLineText,t)}}class lp extends ht{constructor(){super(...arguments);p(this,"originPos");p(this,"originNodePos");p(this,"dragNode");p(this,"originDragNodes",[]);p(this,"originBaseProps");p(this,"rowNodes",[]);p(this,"rowIds",[]);p(this,"rowIndex",0);p(this,"targetRowIndex",0);p(this,"isInsertNewRow",!1);p(this,"originIndex",0);p(this,"insertIndex",0)}computeRowNodes(e){const o=this.dragNode.parent.slideProps.children;this.rowNodes=[],this.rowIds=[];let s=-1,r=-1;for(let i=0;i<o.length;i++){const a=o[i],c=[];for(const h of a.ids){const d=e.nodeManager.getNode(h);d&&(c.push(d),d.id===this.dragNode.id&&(s=i,r=c.length-1))}this.rowNodes.push(c.map(h=>h.baseProps.clone())),this.rowIds.push(c.map(h=>h.id))}if(s===-1){this.rowIndex=0,this.originIndex=0;return}this.rowIndex=s,this.originIndex=r}onStart(e,n){const s=[...n.getSelectNodes()][0],r=s.pos;this.dragNode=s,this.originNodePos=new m(r.x,r.y),this.originPos=e.globalPoint,this.originBaseProps=s.globalBaseProps.clone();const i=new Set;S.getAllChildren(s,i);const a=S.sortGraphics([s,...i]);this.originDragNodes=a,this.computeRowNodes(n),n.execAction(new W)}onMove(e,n){const o=e.globalPoint,s=this.originPos,r=o.x-s.x,i=o.y-s.y;n.addOrUpdate(k.HoverSlidePlaceHolder,{baseProps:this.originBaseProps}),n.addOrUpdate(k.HoverFocusCopy,{nodes:this.originDragNodes});const a=this.originNodePos.x+r,c=this.originNodePos.y+i,h=this.dragNode.parent.globalPos,d=o.x-h.x,u=o.y-h.y;this.determineTargetRow(u),this.showInsertIndicator(d,h,n),n.execAction(U.create(this.dragNode.id,[{type:I.Base,x:a,y:c}],{streaming:!0}))}relayoutRow(e,n,o,s,r){let i=n;for(const a of e){const c=s.nodeManager.getNode(a);c&&(r.push({id:a,props:[{type:I.Base,x:i,y:o}]}),i+=c.baseProps.width+nt)}}handleInsertNewRow(e,n){const o=[],s=[...this.rowIds[this.rowIndex]];s.splice(this.originIndex,1);const r=this.targetRowIndex,i=r===0,a=r===this.rowNodes.length;s.length===0?(e.splice(this.rowIndex,1),this.rowIndex<this.targetRowIndex&&this.targetRowIndex--):e[this.rowIndex].ids=s,e.splice(this.targetRowIndex,0,{ids:[this.dragNode.id]});const c=this.dragNode.baseProps;let h,d;if(i){h=this.rowNodes[0][0].x,d=this.rowNodes[0][0].y;const u=c.height+xt;for(let f=0;f<this.rowNodes.length;f++){const g=this.rowIds[f].filter(P=>P!==this.dragNode.id),y=this.rowNodes[f][0].y+u;this.relayoutRow(g,this.rowNodes[f][0].x,y,n,o)}}else if(a){const u=this.rowNodes.length-1,f=this.rowNodes[u];h=f[0].x,d=f[0].y+f[0].height+xt,s.length>0&&this.relayoutRow(s,this.rowNodes[this.rowIndex][0].x,this.rowNodes[this.rowIndex][0].y,n,o)}else{const u=this.rowNodes[r-1];this.rowNodes[r],h=u[0].x,d=u[0].y+u[0].height+xt;const f=c.height+xt;for(let g=0;g<this.rowNodes.length;g++){const y=this.rowIds[g].filter(b=>b!==this.dragNode.id);if(y.length===0)continue;let P;g<r?P=this.rowNodes[g][0].y:P=this.rowNodes[g][0].y+f,this.relayoutRow(y,this.rowNodes[g][0].x,P,n,o)}}return o.push({id:this.dragNode.id,props:[{type:I.Base,x:h,y:d}]}),o}determineTargetRow(e){var a,c,h;if(this.isInsertNewRow=!1,this.rowNodes.length===0){this.targetRowIndex=0;return}const n=((a=this.rowNodes[0][0])==null?void 0:a.y)??0;if(e<n){this.isInsertNewRow=!0,this.targetRowIndex=0,this.insertIndex=0;return}const o=this.rowNodes.length-1,s=this.rowNodes[o],r=((c=s[0])==null?void 0:c.y)??0,i=((h=s[0])==null?void 0:h.height)??0;if(e>r+i){this.isInsertNewRow=!0,this.targetRowIndex=this.rowNodes.length,this.insertIndex=0;return}for(let d=0;d<this.rowNodes.length;d++){const u=this.rowNodes[d];if(u.length===0)continue;const f=u[0].y,g=u[0].height;if(e>=f&&e<=f+g){this.targetRowIndex=d;return}if(d<this.rowNodes.length-1){const y=this.rowNodes[d+1];if(y.length===0)continue;const P=y[0].y,b=f+g,w=P;if(e>b&&e<w){this.isInsertNewRow=!0,this.targetRowIndex=d+1,this.insertIndex=0;return}}}this.targetRowIndex=this.rowIndex}showInsertIndicator(e,n,o){this.isInsertNewRow?this.showNewRowIndicator(n,o):this.showExistingRowIndicator(e,n,o)}showNewRowIndicator(e,n){const o=this.targetRowIndex===0,s=this.targetRowIndex===this.rowNodes.length;let r,i;if(o)r=this.rowNodes[0],i=r[0].y+e.y-.5*xt;else if(s)r=this.rowNodes[this.rowNodes.length-1],i=r[0].y+r[0].height+e.y+.5*xt;else{const u=this.rowNodes[this.targetRowIndex-1],f=this.rowNodes[this.targetRowIndex],g=u[u.length-1].x+u[u.length-1].width-u[0].x,y=f[f.length-1].x+f[f.length-1].width-f[0].x;r=g>=y?u:f;const P=u[0].y+u[0].height,b=f[0].y;i=(P+b)/2+e.y}const a=r[0],c=r[r.length-1],h=a.x+e.x,d=c.x+c.width+e.x;n.addOrUpdate(k.HoverInsertHorizonSlide,{x0:h,x1:d,y:i})}showExistingRowIndicator(e,n,o){const s=this.rowNodes[this.targetRowIndex]||[];for(let r=0;r<s.length;r++){const i=s[r],a=i.x+.5*i.width;if(e<a){this.insertIndex=r,o.addOrUpdate(k.HoverInsertSlide,{x:i.x-.5*nt+n.x,y0:i.y+n.y,y1:i.y+i.height+n.y});return}if(r===s.length-1){this.insertIndex=s.length,o.addOrUpdate(k.HoverInsertSlide,{x:i.x+i.width+.5*nt+n.x,y0:i.y+n.y,y1:i.y+i.height+n.y});return}}}handleSameRowDrag(e,n){const o=[],s=[...this.rowIds[this.rowIndex]];return this.insertIndex<this.originIndex?(s.splice(this.originIndex,1),s.splice(this.insertIndex,0,this.dragNode.id)):(s.splice(this.insertIndex,0,this.dragNode.id),s.splice(this.originIndex,1)),e[this.rowIndex].ids=s,this.relayoutRow(s,this.rowNodes[this.rowIndex][0].x,this.rowNodes[this.rowIndex][0].y,n,o),o}handleCrossRowDrag(e,n){const o=[],s=[...this.rowIds[this.rowIndex]],r=[...this.rowIds[this.targetRowIndex]];if(s.splice(this.originIndex,1),e[this.rowIndex].ids=s,r.splice(this.insertIndex,0,this.dragNode.id),e[this.targetRowIndex].ids=r,s.length===0){const a=this.rowNodes[this.rowIndex][0].height+xt;for(let c=0;c<this.rowNodes.length;c++){if(c===this.rowIndex)continue;const h=c===this.targetRowIndex?r:this.rowIds[c],d=c>this.rowIndex?this.rowNodes[c][0].y-a:this.rowNodes[c][0].y;this.relayoutRow(h,this.rowNodes[c][0].x,d,n,o)}}else this.relayoutRow(s,this.rowNodes[this.rowIndex][0].x,this.rowNodes[this.rowIndex][0].y,n,o),this.relayoutRow(r,this.rowNodes[this.targetRowIndex][0].x,this.rowNodes[this.targetRowIndex][0].y,n,o);return o}onUp(e,n){const o=!this.isInsertNewRow&&this.targetRowIndex===this.rowIndex,s=o&&(this.insertIndex===this.originIndex||this.insertIndex===this.originIndex+1),r=this.rowIds[this.rowIndex].length===1,i=this.isInsertNewRow&&r&&(this.targetRowIndex===this.rowIndex||this.targetRowIndex===this.rowIndex+1);if(s||i){n.execAction(U.create(this.dragNode.id,[{type:I.Base,x:this.originNodePos.x,y:this.originNodePos.y}],{streaming:!1})),n.execAction(new z);return}const c=this.dragNode.parent.slideProps.children.map(g=>({ids:[...g.ids]}));let h;this.isInsertNewRow?h=this.handleInsertNewRow(c,n):o?h=this.handleSameRowDrag(c,n):h=this.handleCrossRowDrag(c,n);const d=c.filter(g=>g.ids.length>0);h.unshift({id:this.dragNode.parent.id,props:[{type:I.Slide,children:d}]}),n.execAction(new U({infos:h}));const u=this.dragNode.parent,f=[];for(const g of d)for(const y of g.ids){const P=n.nodeManager.getNode(y);P&&f.push(P.baseProps)}if(f.length>0){const g=S.getBoundsByBasePropsList(f),y=g.maxX-g.minX,P=g.maxY-g.minY;n.execAction(U.create(u.id,[{type:I.Base,width:y+2*nt,height:P+2*xt}]))}n.execAction(new z)}}class hp extends dt{constructor(){super([new lp])}streamEnable(t,e){var i;const o=[...e.auxiliaryManager.selectManager.getSelectNodes()];if(o.length!==1)return!1;const s=o[0];return((i=s.parent)==null?void 0:i.type)!==v.SlideContainer?!1:S.rectContains2(t.globalPoint,s.getRectNode())}}class Ja extends fn{constructor(){super([new Ju,new Uu,new Ou,new Hu,new tp,new Au,new op,new cp,new ia,new qs,new ua,new $a,new Ka,new hp,new Ia,new Ku,new qu,new Ea,new Ua])}canBeEnable(t,e){return!0}}class ec extends Ke{onDetect(t,e){const n=e.getSelectNodes();if(n.size!==1)return!1;const o=[...n][0];if(o.type!==v.Shape)return!1;const s=o;if(s.isEmptyText())return!1;const r=s.getTextContentRect();if(s.renderText.height<r.height)return!1;const i=e.gmlRender.getScale(),a=s.toLocal(t.globalPoint),{width:c,height:h}=s.baseProps,d=new D(.5*c-.5*21/i,h-.5*12/i,21/i,12/i);return S.rectContains(a,d)?(this.result={node:s,realHeight:s.drawer.fullTextNodeHeight(s)},!0):!1}}class tc extends Ke{onDetect(t,e){const n=e.auxiliaryManager.selectManager.selectNodes;if(n.size!==1)return!1;const o=[...n][0];if(o.type!==v.Line)return!1;const s=o,i=8/e.gmlRender.getScale(),a=s.points,c=a[0],h=a[a.length-1],d=s.toLocal(t.globalPoint);let u=S.circleContains(d,c,i);return u?(this.result={detectPoint:c,isStart:!0,line:s},!0):(u=S.circleContains(d,h,i),u?(this.result={detectPoint:h,isStart:!1,line:s},!0):!1)}}const dp=12;class up extends Ke{onDetect(t,e){const n=e.detect(F.HoverConnectAnchor,t);if(n){const u=Ze.getNodePos(n.node,n.relative);return this.result={node:n.node,point:u,relativePos:n.relative},!0}const o=e.detect(F.HoverNodeAnchor,t);if(o){const u=Ze.getNodePos(o.node,o.ratio);return this.result={node:o.node,point:u,relativePos:o.ratio},!0}const s=e.detect(F.BufferNode,t);if(!s)return!1;const r=s.filter(u=>u.canBeConnected());if(r.length===0)return!1;const i=r[0];if(!i.canBeConnected())return!1;const a=e.renderManager.getScale(),{width:c,height:h}=i.baseProps,d=i.borderContains(t.globalPoint,dp/a);return d?(this.result={node:i,point:i.toGlobal(d),relativePos:new m(d.x/c,d.y/h)},!0):!1}}class Qo extends ht{constructor(){super(...arguments);p(this,"startPos",new m);p(this,"target",null);p(this,"viewBounds");p(this,"alignWorker",new un)}nodeType(){return v.Shape}autoFocus(){return!0}onStart(e,n){n.previewManager.resetPreviewNode(n),n.alignPoint?(this.startPos=n.alignPoint,n.alignPoint=null):this.startPos=e.globalPoint;const o=n.detect(F.HoverOnContainer,e);let s=n.nodeManager.root,r=new m(this.startPos.x,this.startPos.y);o&&(r=o.toLocal(this.startPos),s=o);const i=this.nodeType(),a=n.idGenerator.genId(i),c=this.makeupDefaultProps(n,r);console.log("njx debug,props:",c);const h={id:a,type:i,zIndex:ve.genZIndex(s),parentId:s.id,props:c};n.actionManager.execAction(new W);const d=Le.create(h);n.actionManager.execAction(d),this.target=n.nodeManager.nodeMap.get(a);const u=D.baseProps2Rect(this.target.baseProps);n.addOrUpdate(k.CreateRectBound,{rect:u,transform:this.target.globalTransform()}),n.auxiliaryManager.removeAlignGraphics(),this.viewBounds=n.gmlRender.getViewPortBounds()}onMove(e,n){if(!this.target)return;n.auxiliaryManager.removeAlignGraphics();const o=this.target.baseProps.clone(),s=new Set([this.target]),r=!S.pressMeta(e),i=this.alignWorker.alignLineEndAndDrawAlignLines(e,n,s,r);this.computeRectBounds(i,o);const a=n.gmlRender.getScale(),c=D.baseProps2Rect(o),h=new Set(n.getSelectNodes());h.add(this.target);const d=this.alignWorker.alignStretch(n,c,h,_e.both,this.viewBounds,Us/a,Gs/a);this.drawAlignLine(c,d,n);const u=new m(c.x,c.y),f=this.target.parent.toLocal(u),g={type:I.Base,x:f.x,y:f.y,width:c.width,height:c.height},y=U.create(this.target.id,[g],{streaming:!0});n.actionManager.execAction(y);const P=D.baseProps2Rect(this.target.baseProps);n.addOrUpdate(k.CreateRectBound,{rect:P,transform:this.target.globalTransform()})}onUp(e,n){if(!this.target)return;const o=n.renderManager.getScale(),s=this.target.baseProps,r={type:I.Base,x:s.x,y:s.y,width:s.width,height:s.height},{width:i,height:a}=this.computeMiniSize(),c=this.computeDefaultSize(n);let h=!1;S.distance(this.startPos,e.globalPoint)<Math.max(9,9/o)?(r.width=c.width,r.height=c.height,h=!0):(r.width<i||r.height<a)&&(r.width=c.width,r.height=c.height);const d=[r];this.dealWithUpUpdateProps(h,d);const u=U.create(this.target.id,d);n.actionManager.execAction(u),n.actionManager.execAction(xe.create([this.target.id])),this.autoFocus()&&n.actionManager.execAction(ee.focus(this.target.id)),n.actionManager.execAction(new z),this.target=null,n.toolManager.resetTool(),n.removeAuxGraphic(k.CreateRectBound),n.auxiliaryManager.removeAlignGraphics(),n.setCursor("default")}dealWithUpUpdateProps(e,n){}computeRectBounds(e,n,o=10,s=10){if(!this.target)return;const r=Math.max(Math.abs(e.x-this.startPos.x),o),i=Math.max(Math.abs(e.y-this.startPos.y),s);n.width=r,n.height=i,e.x>=this.startPos.x&&e.y>=this.startPos.y?(n.x=this.startPos.x,n.y=this.startPos.y):e.x>this.startPos.x&&e.y<this.startPos.y?(n.x=this.startPos.x,n.y=this.startPos.y-i):e.x<this.startPos.x&&e.y>this.startPos.y?(n.x=this.startPos.x-r,n.y=this.startPos.y):e.x<=this.startPos.x&&e.y<=this.startPos.y?(n.x=this.startPos.x-r,n.y=this.startPos.y-i):(n.x=this.startPos.x-r,n.y=this.startPos.y-i)}drawAlignLine(e,n,o){const s=this.target,r=s.baseProps,{width:i,height:a}=n;if(i){e.width+=i.dt;const c={transform:s.transform.clone(),line:{start:new m(0,r.height),end:new m(r.width,r.height)}};i.lines.push(c)}if(a){e.height+=a.dt;const c={transform:s.transform.clone(),line:{start:new m(r.width,0),end:new m(r.width,r.height)}};a.lines.push(c)}o.addOrUpdate(k.AlignStretchLine,{alignInfo:n})}}class nc extends Qo{constructor(){super(...arguments);p(this,"startPos",new m);p(this,"target",null)}computeDefaultSize(){return{width:100,height:100}}computeMiniSize(){return{height:5,width:5}}makeupDefaultProps(e,n){return e.createWorker.makeupDefaultProps(v.Shape,e,e.toolManager.shapeType,n)}dealWithUpUpdateProps(e,n){e||n.push({type:I.Text,sizeMode:We.fix})}}class oc extends Nn{constructor(){super([new nc])}streamEnable(t,e){return e.toolManager.currentTool==ye.SHAPE}}class sc extends Qo{computeDefaultSize(){return{height:0,width:0}}computeMiniSize(){return{height:0,width:0}}makeupDefaultProps(t,e){return[ie.create({x:e.x,y:e.y}),Ge.create({type:I.Text,fontSize:16,richText:"<root><p></p></root>",horizonAlign:at.Top,verticalAlign:at.Top}),new Oe(K.PureText)]}}class rc extends dt{constructor(){super([new sc])}streamEnable(t,e){return e.toolManager.currentTool==ye.TEXT}}class ic extends Ot{constructor(t){super(t)}canBeEnable(t,e){return!0}canBeExit(t,e){return!0}}class pp extends qe{constructor(){super(...arguments);p(this,"res",null)}enable(e,n){return n.toolManager.currentTool===ye.TEXT}handle(e,n){const o=n.idGenerator.genId(v.Shape),s=n.detect(F.HoverOnContainer,e);let r=n.nodeManager.root,i=e.globalPoint.clone();s&&(i=s.toLocal(i),r=s);const a=this.makeupDefaultProps(i),c={id:o,type:v.Shape,zIndex:ve.genZIndex(n.nodeManager.root),parentId:r.id,props:a};n.actionManager.execAction(new W);const h=Le.create(c);n.actionManager.execAction(h),n.actionManager.execAction(xe.create([o])),n.actionManager.execAction(ee.focus(o)),n.actionManager.execAction(new z),n.toolManager.resetTool()}makeupDefaultProps(e){return[ie.create({x:e.x,y:e.y,height:22,width:64}),Ge.create({type:I.Text,fontSize:16,richText:"<root><p></p></root>",horizonAlign:at.Top,verticalAlign:at.Top,sizeMode:We.autoWidth}),new Oe(K.PureText)]}}class fp extends qe{constructor(){super(...arguments);p(this,"res",null)}enable(e,n){const o=n.detect(F.Node,e);if(o){const s=o[0],r=s.toLocal(e.globalPoint);if(s instanceof vt&&s.renderText.contains(r))return this.res={node:s,relativePos:r},!0;if(s instanceof Ct)return this.res={node:s,relativePos:r},!0}return!1}handle(e,n){if(!this.res)return;n.toolManager.resetTool();const{node:o,relativePos:s}=this.res,r=o.renderText.detect(s);n.execAction(new W),n.execAction(xe.create([o.id])),n.execAction(ee.focus(o.id,r)),n.execAction(new z)}}class gp extends jt{constructor(){super(),this.registerUpHandler(new pp),this.registerUpHandler(new fp)}}class yp extends pn{constructor(){super([new gp])}clickEnable(t,e){return e.toolManager.currentTool===ye.TEXT}}class xp extends Qo{constructor(){super(...arguments);p(this,"startPos",new m);p(this,"target",null)}computeDefaultSize(e){const n=e.toolManager.shapeType,o=Uo[n];return{width:o.width,height:o.height}}computeMiniSize(){return{height:5,width:5}}nodeType(){return v.Section}autoFocus(){return!1}makeupDefaultProps(e,n){return e.createWorker.makeupDefaultProps(v.Section,e,e.toolManager.shapeType,n)}}class wp extends Nn{constructor(){super([new xp])}streamEnable(t,e){return e.toolManager.currentTool==ye.SECTION}}class ac extends _o{constructor(){super(...arguments);p(this,"handlers",[new Fa])}}class cc{constructor(){p(this,"allowEventTypeSet",new Set([be.pointermove]));p(this,"alignWorker",new un)}process(t,e){const n=e.previewManager.createManager;if(!n.previewGraphics)return;const o=e.toolManager.grab;e.auxiliaryManager.removeAlignGraphics();const{rectNode:s,delta:r}=this.computeMoveRect(n.previewGraphics,t.globalPoint,o),i=this.alignWorker.alignMove(s,e.getSelectNodes(),e,!0),a=this.alignWorker.drawAlignLines(i,e),c=new m(s.minX+a.x,s.minY+a.y);e.alignPoint=c,e.previewManager.updatePos(c),e.addOrUpdate(k.PreviewGraphics,{previewNodes:[n.previewGraphics]})}computeMoveRect(t,e,n){const o=t.getBounds(),s=D.rectNode2Rect(o),r=n?s.x+.5*s.width:s.x,i=n?s.y+.5*s.height:s.y,a=new m(e.x-r,e.y-i);return o.minX+=a.x,o.maxX+=a.x,o.minY+=a.y,o.maxY+=a.y,{rectNode:o,delta:a}}}class Bn{handle(t,e,n){this.makeupAddNodeInfo(t,e,n).then(o=>{const s=o.id;t.actionManager.execAction(new W);const r=Le.create(o);t.actionManager.execAction(r),t.actionManager.execAction(xe.create([s])),this.autoFocus()&&t.actionManager.execAction(ee.focus(s)),t.actionManager.execAction(new z),t.toolManager.resetTool(),t.previewManager.resetPreviewNode(t),t.auxiliaryManager.removeAlignGraphics()})}detectParentContainer(t,e){const n=t.detect(F.HoverOnContainer,e);let o=t.nodeManager.root;return n&&(o=n),o}}class mp extends Bn{enable(t){return t===ye.SHAPE}async makeupAddNodeInfo(t,e,n){const o=t.toolManager.shapeType,s=this.detectParentContainer(t,n),r=t.createWorker.makeupDefaultProps(v.Shape,t,o,e,s);return{id:t.idGenerator.genId(v.Shape),type:v.Shape,zIndex:ve.genZIndex(s),parentId:s.id,props:r}}autoFocus(){return!0}}class Pp extends Bn{enable(t){return t===ye.SECTION}async makeupAddNodeInfo(t,e,n){const o=this.detectParentContainer(t,n),s=t.toolManager.shapeType,r=t.createWorker.makeupDefaultProps(v.Section,t,s,e,o);return{id:t.idGenerator.genId(v.Section),type:v.Section,zIndex:ve.genZIndex(o),parentId:o.id,props:r}}autoFocus(){return!1}}const bp="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Zo=(l=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(l|=0));for(;l--;)t+=bp[e[l]&63];return t};class cr{async addSvgNodeBySvgCode(t,e,n,o=n.nodeManager.root){const s=n.docState.docId,r=Zo(10),i=`${s}/${r}`,a=await n.resourceManager.uploadSvgString(i,t),c=this.computeAddSvgNode(t,a,e,n,o);return{url:a,addNodeInfo:c}}computeAddSvgNode(t,e,n,o,s=o.nodeManager.root){const r=an.trimSvgCode(t),i=[{type:I.Base,x:n.x,y:n.y,width:r.width,height:r.height},{type:I.Svg,url:e},{type:I.Border,dashType:et.None}];return{id:o.idGenerator.genId(v.SVG),type:v.SVG,zIndex:ve.genZIndex(s),parentId:s.id,props:i}}}class Sp extends Bn{constructor(){super(...arguments);p(this,"svgWorker",new cr)}autoFocus(){return!1}enable(e){return e===ye.Resource}async makeupAddNodeInfo(e,n,o){const s=this.detectParentContainer(e,o),r=s.toLocal(n),i=e.previewManager.previewResourceManager.previewSvgCode;i===""&&console.error("出现错误,svg code为空");const{addNodeInfo:a}=await this.svgWorker.addSvgNodeBySvgCode(i,r,e,s);return a}}class Mp extends Bn{autoFocus(){return!1}enable(t,e){return t===ye.Widget&&e===_n.Checkbox}async makeupAddNodeInfo(t,e,n){const o=this.detectParentContainer(t,n),s=t.createWorker.makeupDefaultProps(v.Checkbox,t,0,e,o);return{id:t.idGenerator.genId(v.Checkbox),type:v.Checkbox,zIndex:ve.genZIndex(o),parentId:o.id,props:s}}}class vp extends Bn{autoFocus(){return!1}enable(t,e){return t===ye.Widget&&e===_n.CheckboxText}async makeupAddNodeInfo(t,e,n){const o=this.detectParentContainer(t,n),s=t.createWorker.makeupDefaultProps(v.CheckboxText,t,0,e,o);return{id:t.idGenerator.genId(v.CheckboxText),type:v.CheckboxText,zIndex:ve.genZIndex(o),parentId:o.id,props:s}}}class Ip extends Bn{enable(t){return t===ye.LINE}async makeupAddNodeInfo(t,e,n){const o=t.toolManager.shapeType,s=this.detectParentContainer(t,n),r=t.createWorker.makeupDefaultProps(v.Line,t,o,e,s);return{id:t.idGenerator.genId(v.Line),type:v.Line,zIndex:ve.genZIndex(s),parentId:s.id,props:r}}autoFocus(){return!1}}class Tp extends Bn{autoFocus(){return!1}enable(t,e){return t===ye.SlideContainer}async makeupAddNodeInfo(t,e,n){const o=this.detectParentContainer(t,n),s=t.createWorker.makeupDefaultProps(v.SlideContainer,t,0,e,o);return{id:t.idGenerator.genId(v.SlideContainer),type:v.SlideContainer,zIndex:ve.genZIndex(o),parentId:o.id,props:s}}}class lc{constructor(){p(this,"allowEventTypeSet",new Set([be.pointerup]));p(this,"startPos",new m);p(this,"handlers",[new Sp,new mp,new Pp,new Ip,new Mp,new vp,new Tp])}process(t,e){e.toolManager.grab&&(e.alignPoint?(this.startPos=e.alignPoint,e.alignPoint=null):this.startPos=t.globalPoint,this.handleCreateUp(this.startPos,e,t))}handleCreateUp(t,e,n){for(const o of this.handlers)if(o.enable(e.toolManager.currentTool,e.toolManager.shapeType)){o.handle(e,t,n);return}}}const Lp=new Set([ye.SHAPE,ye.TEXT,ye.SECTION,ye.Resource,ye.Widget,ye.SlideContainer]);class Cp extends fn{constructor(){super([new yp,new wp,new oc,new rc,new ic([new ac,new cc,new lc])])}canBeEnable(t,e){return Lp.has(e.toolManager.currentTool)}}const qo=12;class Ap extends Ke{onDetect(t,e){const n=t.globalPoint,o=e.nodeManager.searchNodes(n.x-qo,n.y-qo,n.x+qo,n.y+qo);if(o.length===0)return this.result=null,!1;const s=S.sortGraphics(o);return s.reverse(),this.result=s,!0}}class Np extends Ke{onDetect(t,e){const n=e.detect(F.BufferNode,t);if(!n)return!1;const o=n[0];return e.auxiliaryManager.selectManager.include(o)?!1:(this.result=o,!0)}}const kp=12;class Bp extends Ke{onDetect(t,e){const n=e.detect(F.BufferNode,t);if(!n)return!1;const o=n.filter(u=>u.canBeConnected());if(o.length===0)return!1;const s=o[0];if(!s.canBeConnected()||e.auxiliaryManager.selectManager.include(s))return!1;const r=e.renderManager.getScale(),i=kp/r,{width:a,height:c}=s.baseProps,h=s.toLocal(t.globalPoint),d=s.getConnectAnchor();for(const u of d){const f=new m(u.x*a,u.y*c);if(S.circleContains(h,f,i))return this.result={node:s,ratio:u,localPoint:f},!0}return!1}}class hc extends Ke{onDetect(t,e){const n=e.auxiliaryManager.selectManager.selectNodes;if(n.size!==1)return!1;const o=[...n][0];if(o.type!==v.Line)return!1;const s=o;if(!s.isPolyLine())return!1;const r=e.gmlRender.getScale(),i=s.points;for(let a=0;a<i.length-1;a++){const c=i[a],h=i[a+1];if(S.distance(c,h)<(A+6)/r)continue;const u=S.judgeHorizon(c,h),f=.5*(c.x+h.x),g=.5*(c.y+h.y);let y;if(u){const w=new m(f-8/r,g);y=new D(w.x,w.y-4/r,16/r,8/r)}else{const w=new m(f,g-8/r);y=new D(w.x-4/r,w.y,8/r,16/r)}const P=s.toLocal(t.globalPoint);if(S.rectContains(P,y))return this.result={isHorizon:u,line:s,point:new m(f,g),lIndex:a,rIndex:a+1},!0}return!1}}const Rp=[new m(.5,0),new m(1,.5),new m(.5,1),new m(0,.5)];class Ep extends Ke{onDetect(t,e){const n=e.getSelectNodes();if(n.size!==1)return!1;const o=[...n][0];if(!o.canQuickCreate())return!1;const s=e.renderManager.getScale(),r=S.computeNodeConnectAnchor(o,s),i=Ms/s;for(let a=0;a<r.length;a++){const c=r[a],h=o.toLocal(t.globalPoint);let d=Rp[a];if(S.circleContains(h,c,i))return o.type===v.Shape&&(d=o.drawer.getConnectAnchor()[a]),this.result={node:o,localPoint:c,globalPoint:o.toGlobal(c),relative:d},!0}return!1}}const Hp=new Set([v.Checkbox,v.Group,v.CheckboxText,v.Section,v.Line]),ws=class ws extends Ke{onDetect(t,e){const n=$t.flattenNodes([...e.getSelectNodes()]);if(n.length===0)return!1;const o=e.auxiliaryManager.selectManager.getSelectBounds();if(S.rectContains2(t.globalPoint,o)||e.detect(F.Stretch,t))return!1;const s=e.gmlRender.getScale(),r=ws.HOT_DISTANCE/s;let i=re.generateMatrix(),a,c,h;if(n.length===1){const d=n[0];if(Hp.has(d.type))return!1;const u=d.baseProps;i=d.globalTransform().clone();const f=new m(.5*u.width,.5*u.height);a=i.crossPoint(f),c=new D(0,0,u.width,u.height),h=i.inverseMatrix().crossPoint(t.globalPoint)}else{const d=e.auxiliaryManager.selectManager.getSelectBounds();c=D.rectNode2Rect(d),a=new m(.5*(d.minX+d.maxX),.5*(d.minY+d.maxY)),h=new m(t.globalPoint.x-c.x,t.globalPoint.y-c.y)}return S.circleContains({x:0,y:0},h,r)?(this.result={rotateCenter:a,nodes:n,cursorAngle:S.computeRotateAngle(n,180),rotateType:Zt.TOP_LEFT},!0):S.circleContains({x:c.width,y:0},h,r)?(this.result={rotateCenter:a,nodes:n,cursorAngle:S.computeRotateAngle(n,-90),rotateType:Zt.TOP_RIGHT},!0):S.circleContains({x:c.width,y:c.height},h,r)?(this.result={rotateCenter:a,nodes:n,cursorAngle:S.computeRotateAngle(n,0),rotateType:Zt.BOTTOM_RIGHT},!0):S.circleContains({x:0,y:c.height},h,r)?(this.result={rotateCenter:a,nodes:n,cursorAngle:S.computeRotateAngle(n,90),rotateType:Zt.BOTTOM_LEFT},!0):!1}};p(ws,"HOT_DISTANCE",16);let Jo=ws;class Dp extends Ke{onDetect(t,e){const n=e.detect(F.Node,t),o=e.docState.docMode===ue.SLIDE_EDIT;if(!n){if(o){const r=S.getSlideContainerChildNode(e.docState.slideStatus.slideContainer,e.docState.slideStatus.currentIndex,e);return this.result=r,!0}return!1}const s=e.getSelectNodes();for(const r of n)if(!s.has(r)&&r.type===v.Section)return this.result=r,!0;if(o){const r=S.getSlideContainerChildNode(e.docState.slideStatus.slideContainer,e.docState.slideStatus.currentIndex,e);return this.result=r,!0}return!1}}class Op extends jt{constructor(){super(),this.registerDownHandler(new er),this.registerDownHandler(new tr),this.registerUpHandler(new nr),this.registerUpHandler(new ka),this.registerUpHandler(new or)}}class Xp extends pn{constructor(){super([new Op])}}class zp extends jt{constructor(){super(),this.registerDownHandler(new Za)}}class Wp extends js{constructor(){super([new zp])}}class Fp extends _o{constructor(){super(...arguments);p(this,"handlers",[new sr])}}class Yp{constructor(){p(this,"allowEventTypeSet",new Set([be.pointermove]));p(this,"handlers",[new Ha,new Oa,new Xa,new Da])}process(t,e){const n=e.detect(F.HoverNode,t);if(n){for(const o of this.handlers)if(o.enable(n)){o.handle(n,e);return}}}}class Gp extends Ot{constructor(){super([new Yp,new Fp])}canBeEnable(t,e){return!0}canBeExit(t,e){return!0}}class Up extends fn{constructor(){super([new qs,new Wp,new Xp,new Gp])}canBeEnable(t,e){return!e.docState.canEdit()}}class _p extends Ke{onDetect(t,e){const n=[...e.getSelectNodes()];if(n.length!==1)return!1;const o=n[0];if(o.type!==v.IMG)return!1;const s=e.detect(F.Node,t);return s&&e.auxiliaryManager.selectManager.include(s[0])?(this.result=o,!0):!1}}class $p extends Nn{constructor(){super([new qa])}streamEnable(t,e){return!0}}class jp{constructor(){p(this,"allowEventTypeSet",new Set([be.pointermove]))}process(t,e){e.setCursor("grab")}}class Vp extends Ot{constructor(){super([new jp])}canBeEnable(t,e){return!0}canBeExit(t,e){return!0}}class Kp extends fn{constructor(){super([new $p,new Vp])}canBeEnable(t,e){return e.toolManager.currentTool===ye.HandTool}}class Qp extends gt{enable(t,e){return!!e.detect(F.ImageOriginBounds,t)}handle(t,e){const n=e.detect(F.ImageOriginBounds,t);n.type===V.BOTTOM||n.type===V.TOP?e.setCursor("ns-resize"):n.type===V.RIGHT||n.type===V.LEFT?e.setCursor("ew-resize"):n.type===V.TOP_LEFT||n.type===V.BOTTOM_RIGHT?e.setCursor("nwse-resize"):(n.type===V.TOP_RIGHT||n.type===V.BOTTOM_LEFT)&&e.setCursor("nesw-resize")}}class Zp extends _o{constructor(){super(...arguments);p(this,"handlers",[new Ya,new Qp,new sr])}}class qp extends Ot{constructor(){super([new Zp])}canBeEnable(t,e){return!0}canBeExit(t,e){return!0}}class Jp extends ht{constructor(){super(...arguments);p(this,"limitBounds");p(this,"imgNode");p(this,"lastPoint");p(this,"stretchRect");p(this,"transform");p(this,"stretchType")}onStart(e,n){const o=n.detect(F.Stretch,e);this.stretchType=o.type;const s=[...n.getSelectNodes()][0];this.imgNode=s;const r=s.getOriginImageRect().clone(),i=s.toGlobal({x:r.x,y:r.y}),a=this.imgNode.globalBaseProps;this.limitBounds=new D(i.x,i.y,r.width,r.height);const c=re.generateMatrix().rotate(a.angle),d=re.generateMatrix().translate(i.x,i.y).crossProduct(c);this.transform=d.inverseMatrix(),this.lastPoint=this.transform.crossPoint(e.globalPoint);const u=new m(a.x,a.y),f=this.transform.crossPoint(u);this.stretchRect=new D(f.x,f.y,a.width,a.height),n.execAction(new W)}onCropNode(e,n,o){const s=this.transform.crossPoint(e.globalPoint),r=new m(s.x-this.lastPoint.x,s.y-this.lastPoint.y);this.lastPoint=s;const i=this.stretchRect;switch(this.stretchType){case V.TOP:i.y=i.y+r.y,i.height=i.height-r.y;break;case V.BOTTOM:i.height=i.height+r.y;break;case V.LEFT:i.x=i.x+r.x,i.width=i.width-r.x;break;case V.RIGHT:i.width=i.width+r.x;break;case V.TOP_LEFT:i.y=i.y+r.y,i.height=i.height-r.y,i.x=i.x+r.x,i.width=i.width-r.x;break;case V.TOP_RIGHT:i.y=i.y+r.y,i.height=i.height-r.y,i.width=i.width+r.x;break;case V.BOTTOM_LEFT:i.x=i.x+r.x,i.width=i.width-r.x,i.height=i.height+r.y;break;case V.BOTTOM_RIGHT:i.width=i.width+r.x,i.height=i.height+r.y;break}const a=this.modifyStretchRect(i),c=new m(a.x,a.y),h=this.transform.inverseMatrix().crossPoint(c),d=this.imgNode.parent.toLocal(h),u=[{type:I.Base,x:d.x,y:d.y,width:a.width,height:a.height}];n.execAction(U.create(this.imgNode.id,u,{streaming:o}));const f=this.imgNode.toLocal(new m(this.limitBounds.x,this.limitBounds.y));n.execAction(U.create(this.imgNode.id,[{type:I.Crop,cropInfo:{imgX:f.x,imgY:f.y,imgWidth:this.limitBounds.width,imgHeight:this.limitBounds.height}}],{streaming:o}))}onMove(e,n){this.onCropNode(e,n,!0)}modifyStretchRect(e){const n=new D(e.x,e.y,e.width,e.height);return n.width<10&&(n.width=10),n.height<10&&(n.height=10),e.x<0?(n.x=0,n.width=e.x+e.width):e.x+e.width>this.limitBounds.width&&(n.width=this.limitBounds.width-e.x),e.y<0?(n.y=0,n.height=e.y+e.height):e.y+e.height>this.limitBounds.height&&(n.height=this.limitBounds.height-e.y),n}onUp(e,n){this.onCropNode(e,n,!1),n.execAction(new z)}}class ef extends dt{constructor(){super([new Jp])}streamEnable(t,e){return!!e.detect(F.Stretch,t)}}class tf extends gn{enable(t){return t.type===v.IMG}handle(t,e,n,o,s){const r=e.crop,i=e.crop.globalImgPos,a=r.originCropProps,c=a.cropType,h=r.originTransform,d=s.crossPoint(i),u=h.crossPoint(d);return[{id:t.id,props:[{type:I.Crop,cropInfo:{imgX:u.x,imgY:u.y,imgWidth:a.cropInfo.imgWidth*n,imgHeight:a.cropInfo.imgHeight*o},cropType:c}]}]}}class nf extends Go{constructor(){super(...arguments);p(this,"handlers",[new tf])}computeAnchorPoint(e,n){const o=this.target.nodes[0],{x:s,y:r,width:i,height:a}=o.getOriginImageRect();switch(e.type){case V.TOP:return this.alignType=_e.height,{x:s,y:r+a};case V.RIGHT:return this.alignType=_e.width,{x:s,y:r};case V.BOTTOM:return this.alignType=_e.height,{x:s,y:r};case V.LEFT:return this.alignType=_e.width,{x:s+i,y:r};case V.TOP_LEFT:return this.alignType=_e.both,{x:s+i,y:r+a};case V.TOP_RIGHT:return this.alignType=_e.both,{x:s,y:r+a};case V.BOTTOM_RIGHT:return this.alignType=_e.both,{x:s,y:r};case V.BOTTOM_LEFT:default:return this.alignType=_e.both,{x:s+i,y:r}}}judgeUniform(e){this.isUniform=!0}computeTarget(e,n){const o=n.detect(F.ImageOriginBounds,e),s=[...n.getSelectNodes()];this.target={type:o.type,nodes:s,angle:S.computeStretchAngle(s,o.type)}}alignStretchGlobalPoint(e,n){const o=[...n.getSelectNodes()][0],s=o.toLocal(e.globalPoint),r=o.baseProps,i=e.globalPoint.clone(),a=this.target.type;return s.x>0&&(a===V.LEFT||a===V.BOTTOM_LEFT||a===V.TOP_LEFT)&&(i.x=o.toGlobal({x:0,y:0}).x),s.x<r.width&&(a===V.RIGHT||a===V.BOTTOM_RIGHT||a===V.TOP_RIGHT)&&(i.x=o.toGlobal({x:r.width,y:0}).x),s.y>0&&(a===V.TOP||a===V.TOP_RIGHT||a===V.TOP_LEFT)&&(i.y=o.toGlobal({x:0,y:0}).y),s.y<r.height&&(a===V.BOTTOM||a===V.BOTTOM_RIGHT||a===V.BOTTOM_LEFT)&&(i.y=o.toGlobal({x:0,y:r.height}).y),i}computeOriginTransform(e){const n=this.target,o=[...e.getSelectNodes()][0],{x:s,y:r,angle:i}=o.globalBaseProps,a=re.generateMatrix().rotate(-i),c=re.generateMatrix().translate(-s,-r),h=this.computeAnchorPoint(n,D.baseProps2Rect(o.baseProps)),u=re.generateMatrix().translate(-h.x,-h.y).crossProduct(a.crossProduct(c));this.originTransform=u}drawAlignLine(e,n,o){const s=this.target.nodes[0],r=s.baseProps,{width:i,height:a}=n,c=s.globalTransform().clone();if(i){e.width+=i.dt;const h={transform:c,line:{start:new m(0,r.height),end:new m(r.width,r.height)}};i.lines.push(h)}if(a){e.height+=a.dt;const h={transform:c,line:{start:new m(r.width,0),end:new m(r.width,r.height)}};a.lines.push(h)}o.addOrUpdate(k.AlignStretchLine,{alignInfo:n})}getMiniSize(e){const n=this.target.type,o=this.target.nodes[0],s=o.baseProps,{x:r,y:i,width:a,height:c}=o.getOriginImageRect(),h=a/c;switch(n){case V.BOTTOM:case V.RIGHT:case V.BOTTOM_RIGHT:{const d=s.width-r,u=s.height-i,f=u*h;return d>f?new m(d,d/h):new m(f,u)}case V.LEFT:case V.BOTTOM_LEFT:{const d=a+r,u=s.height-i,f=u*h;return d>f?new m(d,d/h):new m(f,u)}case V.TOP_LEFT:{const d=a+r,u=c+i,f=u*h;return d>f?new m(d,d/h):new m(f,u)}case V.TOP:case V.TOP_RIGHT:{const d=s.width-r,u=c+i,f=u*h;return d>f?new m(d,d/h):new m(f,u)}default:return new m(s.width,s.height)}}getStretchRect(e){const n=[...e.getSelectNodes()][0],o=D.baseProps2Rect(n.baseProps),s=n.getOriginImageRect();return o.width=s.width,o.height=s.height,o.x=o.x-s.x,o.y=o.y-s.y,o}recordPropsMap(e){this.propsMap.clear();const n=this.target.nodes;for(const o of n){const s=this.recordNodePropInfo(o);this.propsMap.set(o,s)}}afterStretchNode(e,n,o,s,r,i,a){e.asyncRenderNodeManager.batchAddRenderNode(a)}}class of extends dt{constructor(){super([new nf])}streamEnable(t,e){return!!e.detect(F.ImageOriginBounds,t)}}class sf extends ht{constructor(){super(...arguments);p(this,"lastPoint");p(this,"originImgRect");p(this,"imgNode");p(this,"limitBounds");p(this,"transform");p(this,"dragRect")}onStart(e,n){this.imgNode=[...n.getSelectNodes()][0],this.originImgRect=this.imgNode.getOriginImageRect().clone();const o=this.imgNode.globalBaseProps,s=this.imgNode.toGlobal({x:this.originImgRect.x,y:this.originImgRect.y});this.limitBounds=new D(s.x,s.y,this.originImgRect.width,this.originImgRect.height);const r=re.generateMatrix().rotate(o.angle),a=re.generateMatrix().translate(s.x,s.y).crossProduct(r);this.transform=a.inverseMatrix();const c=this.transform.crossPoint({x:o.x,y:o.y});this.dragRect=new D(c.x,c.y,o.width,o.height),this.lastPoint=this.transform.crossPoint(e.globalPoint),n.execAction(new W)}onMove(e,n){this.dragCrop(e,n,!0)}onUp(e,n){this.dragCrop(e,n,!1),n.execAction(new z)}dragCrop(e,n,o){const s=this.imgNode.cropProps.cropInfo,r=this.modifyCropBasePos(e,n),i=this.imgNode.parent.toLocal(r),a=[{type:I.Base,x:i.x,y:i.y}];n.execAction(new U({infos:[{id:this.imgNode.id,props:a}]},{streaming:o}));const c=this.imgNode.toLocal(this.limitBounds),h={imgX:c.x,imgY:c.y,imgWidth:s.imgWidth,imgHeight:s.imgHeight},d=[{type:I.Crop,cropInfo:h}];n.execAction(new U({infos:[{id:this.imgNode.id,props:d}]},{streaming:o}))}modifyCropBasePos(e,n){const o=e.globalPoint,s=this.transform.crossPoint(o),r=s.x-this.lastPoint.x,i=s.y-this.lastPoint.y,a=this.dragRect;a.x+=r,a.y+=i;const c=this.imgNode.baseProps,h=new m(a.x,a.y);a.x+a.width>this.limitBounds.width?h.x=this.limitBounds.width-c.width:a.x<0&&(h.x=0),a.y<0?h.y=0:a.y+a.height>this.limitBounds.height&&(h.y=this.limitBounds.height-c.height);const d=this.transform.inverseMatrix().crossPoint(h);return this.lastPoint=s,d}}class rf extends dt{constructor(){super([new sf])}streamEnable(t,e){const n=[...e.getSelectNodes()];return n.length!==1||!e.cropManager.duringCrop?!1:!!n[0].contains(t.globalPoint)}}class wo{intoCrop(t){const e=t.getSelectNodes();if(e.size!==1)return;const n=[...e][0];if(!(n instanceof Fn)||t.cropManager.duringCrop)return;t.cropManager.intoCrop(),t.auxiliaryManager.selectManager.refreshSelectStatus(),t.renderManager.addAuxiliaryDrawTask();const s=n.cropProps;if(!s.cropInfo||s.cropType===wt.None){const{width:r,height:i}=n.baseProps;t.execAction(new W),t.execAction(U.create(n.id,[{cropType:wt.Rect,cropInfo:{imgX:0,imgY:0,imgWidth:r,imgHeight:i},type:I.Crop}])),t.execAction(new z)}}exitCrop(t){if(t.cropManager.duringCrop){t.cropManager.exitCrop(),t.auxiliaryManager.selectManager.refreshSelectStatus(),t.renderManager.addAuxiliaryDrawTask();return}}resetCrop(t){const e=t.getSelectNodes();if(e.size!==1)return;const n=[...e][0];if(!(n instanceof Fn)||!t.cropManager.duringCrop)return;const s=n.cropProps;if(!s.cropInfo||s.cropType===wt.None)return;const r=n.getOriginImageRect(),i=new m(r.x,r.y),a=n.toGlobal(i),c=n.parent.toLocal(a);t.execAction(new W),t.execAction(U.create(n.id,[{cropType:wt.None,type:I.Crop},{type:I.Base,x:c.x,y:c.y,width:r.width,height:r.height}])),t.execAction(new z),t.cropManager.exitCrop(),t.auxiliaryManager.selectManager.refreshSelectStatus()}}class af extends qe{constructor(){super(...arguments);p(this,"worker",new wo)}enable(e,n){const o=[...n.getSelectNodes()];if(o.length!==1)return!1;const s=o[0],r=s.toLocal(e.globalPoint),i=s.getOriginImageRect();return n.detect(F.ImageOriginBounds,e)?!1:!S.rectContains(r,i)}handle(e,n){this.worker.exitCrop(n),n.auxiliaryManager.slotManager.addSlotState(ze.ExitCrop,!0)}}class cf extends jt{constructor(){super(),this.registerDownHandler(new af)}}class lf extends pn{constructor(){super([new cf])}}class hf extends fn{constructor(){super([new ef,new of,new rf,new lf,new qp])}canBeEnable(t,e){return e.cropManager.duringCrop}}class df extends Ke{onDetect(t,e){const n=e.getSelectNodes();if(n.size!==1)return!1;const o=[...n][0];if(o.type!==v.IMG||!e.cropManager.duringCrop)return!1;const s=o,{cropType:r,cropInfo:i}=s.cropProps;if(r===wt.None||!i)return!1;const a=8/e.renderManager.getScale(),c=s.getOriginImageRect(),h=o.toLocal(t.globalPoint),d=S.detectRectBounds(c,h,a);return d?(this.result={type:d.type},!0):!1}}class lr{constructor(){p(this,"alignWorker",new un)}computeLinePoints(t,e,n){return Ze.computeLinePoints(t,this.layoutHandler,e,n,this.alignWorker)}alignLinePointsInMove(t,e){return t}alignLinePointsInUp(t,e){return t}computeDownProps(t,e,n,o){const r=[new Oe(e.toolManager.shapeType)],i=e.detect(F.NodeEdge,e.lastDiffTypeEvent);if(i){const y={type:I.Connect,start:{objectId:i.node.id,x:i.relativePos.x,y:i.relativePos.y}};t.point=new m(i.point.x,i.point.y),t.nodeConnect={rect:D.rectNode2Rect(i.node.getBounds()),endType:S.computeNodeConnectEnd(i.relativePos,i.node.baseProps.angle)},r.push(y)}else r.push(new Rt);const a={point:new m(t.point.x+1,t.point.y+1)},c=this.layoutHandler.layoutToPointsPro(t,a),h=o.globalTransform().inverseMatrix(),d=c.map(y=>h.crossPoint(y)),u=je.create(d),f=D.rectNode2Rect(S.getBoundsByPoints(d)),g=ie.create({x:f.x,y:f.y,width:f.width,height:f.height});return r.push(u,g,new Ae,lt.create({rArrow:it.Arrow}),Ge.create({sizeMode:We.autoWidth}),new Et),r}computeMoveProps(t,e,n,o){const s=S.dealWithShiftLineInteractEvent(e,o),r=this.computeLinePoints(t,s,n),i=this.alignLinePointsInMove(r,n),a=o.parent.globalTransform().inverseMatrix(),c=i.map(f=>a.crossPoint(f)),h=D.rectNode2Rect(S.getBoundsByPoints(c)),d=[je.create(c),ie.create({x:h.x,y:h.y,width:h.width,height:h.height})],u={infos:[{id:o.id,props:d}]};n.actionManager.execAction(new U(u,{streaming:!0}))}computeUpProps(t,e,n,o){const s=S.dealWithShiftLineInteractEvent(e,o),r=[],i=n.detect(F.NodeEdge,s);if(i){const g=o.connectProps.clone();g.end={objectId:i.node.id,x:i.relativePos.x,y:i.relativePos.y},r.push(g)}const a=this.computeLinePoints(t,s,n),c=this.alignLinePointsInUp(a,n),h=o.parent.globalTransform().inverseMatrix(),d=c.map(g=>h.crossPoint(g)),u=D.rectNode2Rect(S.getBoundsByPoints(d));r.push(je.create(d),ie.create({x:u.x,y:u.y,width:u.width,height:u.height}));const f={infos:[{id:o.id,props:r}]};n.actionManager.execAction(new U(f,{streaming:!1}))}}let es=class extends lr{constructor(){super(...arguments);p(this,"layoutHandler",new Xo)}enable(e){return e===he.Line}};class ts extends lr{constructor(){super(...arguments);p(this,"layoutHandler",new po)}enable(e){return e===he.Curve}}class ns extends lr{constructor(){super(...arguments);p(this,"layoutHandler",new Vt)}enable(e){return e===he.RoundPolyLine||e===he.PolyLine}alignLinePointsInMove(e,n){return S.dealWithEndPolyPoints(e,n.gmlRender.getScale(),!0)}alignLinePointsInUp(e,n){return S.dealWithEndPolyPointsInUp(e,n.gmlRender.getScale(),!0)}}class dc extends ht{constructor(){super(...arguments);p(this,"startConnectInfo",{point:new m});p(this,"target",null);p(this,"shapeType",he.Line);p(this,"currentHandler",null);p(this,"handlers",[new es,new ts,new ns])}selectHandler(){for(const e of this.handlers)if(e.enable(this.shapeType)){this.currentHandler=e;return}throw new Error("类型错误:没有合适的handler处理")}onStart(e,n){this.startConnectInfo.point=e.globalPoint,this.shapeType=n.toolManager.shapeType,this.selectHandler();const o=n.detect(F.HoverOnContainer,e);let s=n.nodeManager.root;o&&(s=o);const r=this.currentHandler.computeDownProps(this.startConnectInfo,n,e,s),i=n.idGenerator.genId(v.Line),a={id:i,type:v.Line,zIndex:ve.genZIndex(n.nodeManager.root),parentId:s.id,props:r};n.actionManager.execAction(new W);const c=Le.create(a);n.actionManager.execAction(c),this.target=n.nodeManager.nodeMap.get(i),n.actionManager.execAction(xe.create([this.target.id]))}onMove(e,n){this.currentHandler.computeMoveProps(this.startConnectInfo,e,n,this.target)}onUp(e,n){this.currentHandler.computeUpProps(this.startConnectInfo,e,n,this.target),n.execAction(new z),n.setCursor("default"),n.toolManager.resetTool()}}class uc extends dt{constructor(){super([new dc],[new $o,new jo,new Vo])}streamEnable(t,e){return e.toolManager.currentTool==ye.LINE}}class uf extends qe{constructor(){super(...arguments);p(this,"handlers",[new es,new ts,new ns])}enable(e,n){return!n.toolManager.creatingLine}handle(e,n){const o=n.idGenerator.genId(v.Line),s=this.makeupLineProps(e,n);if(!s)return;const r={id:o,type:v.Line,zIndex:ve.genZIndex(n.nodeManager.root),parentId:"",props:s};n.actionManager.execAction(new W);const i=Le.create(r);n.actionManager.execAction(i);const a=n.nodeManager.getNode(o);n.toolManager.setInCreatingLine(a)}makeupLineProps(e,n){const o={point:e.globalPoint},r=n.detect(F.HoverOnContainer,e)??n.nodeManager.root;for(const i of this.handlers)if(i.enable(n.toolManager.shapeType))return i.computeDownProps(o,n,e,r);return null}}class pf extends qe{constructor(){super(...arguments);p(this,"handlers",[new es,new ts,new ns])}enable(e,n){return n.previewManager.resetPreviewNode(n),n.auxiliaryManager.removeAlignGraphics(),!!n.toolManager.creatingLine}handle(e,n){const o=n.toolManager.creatingLine,s=this.getStartConnectInfo(o,n);for(const r of this.handlers)r.enable(o.shapeType)&&r.computeUpProps(s,e,n,o);n.execAction(new z),n.toolManager.setInCreatingLine(null),n.toolManager.resetTool(),n.setCursor("default")}getStartConnectInfo(e,n){const o=e.points,{start:s}=e.connectProps,r={point:o[0]};if(s){const i=n.nodeManager.getNode(s.objectId);i&&(r.nodeConnect={endType:S.computeNodeConnectEnd(s,i.baseProps.angle),rect:D.rectNode2Rect(i.getBounds())})}return r}}class ff extends jt{constructor(){super(),this.registerDownHandler(new pf),this.registerUpHandler(new uf)}}class gf extends pn{constructor(){super([new ff])}clickEnable(t,e){return e.toolManager.currentTool===ye.LINE}}class yf{constructor(){p(this,"allowEventTypeSet",new Set([be.pointermove]));p(this,"handlers",[new es,new ts,new ns])}process(t,e){const n=e.toolManager.creatingLine;if(!n)return;const o=this.getStartConnectInfo(n,e);for(const s of this.handlers)s.enable(n.shapeType)&&s.computeMoveProps(o,t,e,n)}getStartConnectInfo(t,e){const n=t.points,{start:o}=t.connectProps,s={point:n[0]};if(o){const r=e.nodeManager.getNode(o.objectId);r&&(s.nodeConnect={endType:S.computeNodeConnectEnd(o,r.baseProps.angle),rect:D.rectNode2Rect(r.getBounds())})}return s}}const xf=new Set([ye.LINE]);class wf extends fn{constructor(){super([new gf,new uc,new ic([new ac,new $o,new jo,new Vo,new yf,new cc,new lc])])}canBeEnable(t,e){return xf.has(e.toolManager.currentTool)}}class mf extends Ke{onDetect(t,e){const n=e.auxiliaryManager.selectManager.selectNodes;if(n.size!==1)return!1;const o=[...n][0];if(o.type!==v.Line)return!1;const s=o;if(s.shapeType!==he.Curve)return!1;const r=e.gmlRender.getScale(),i=S.computeBezierCurves(s);let a=0;for(const c of i){const h=c.getHalfTPos();if(S.circleContains(h,t.globalPoint,8/r))return this.result={line:s,midPoint:new m(h.x,h.y),lPoint:c.p0,rPoint:c.p3,curve:c,index:a},!0;a=a+3}return!1}}class Pf extends Ke{onDetect(t,e){const n=e.auxiliaryManager.selectManager.selectNodes;if(n.size!==1)return!1;const o=[...n][0];if(o.type!==v.Line)return!1;const s=o;if(s.shapeType!==he.Curve)return!1;const r=e.gmlRender.getScale(),i=S.computeBezierCurves(s);let a=0;for(const c of i){const h=[c.p0,c.p3];let d=0;for(const u of h){if(S.circleContains(u,t.globalPoint,8/r))return this.result={line:s,index:a+d},!0;d=d+3}a+=3}return!1}}class bf extends Ke{onDetect(t,e){if(e.inputManager.editTextInfo)return!1;const n=e.auxiliaryManager.selectManager.selectNodes;if(n.size!==1)return!1;const o=[...n][0];if(o.type!==v.Line)return!1;const s=o;if(s.renderText.isEmptyText())return!1;const r=s.toLocal(t.globalPoint),i=s.getTextContentRect();return S.rectContains(r,i)?(this.result={line:s},!0):!1}}class Sf extends Ot{constructor(){super([])}canBeEnable(t,e){return!0}canBeExit(t,e){return!0}}class Mf extends fn{constructor(){super([new Sf])}canBeEnable(t,e){return e.docState.docMode===ue.SLIDE_PLAY}}class vf extends Ke{onDetect(t,e){var u;const n=[...e.getSelectNodes()];if(n.length!==1)return!1;const o=n[0];if(((u=o.parent)==null?void 0:u.type)!==v.SlideContainer||e.docState.docMode===ue.SLIDE_EDIT)return!1;const r=o.parent,i=this.getRowColIndex(r,o.id);if(!i)return!1;const{x:a,y:c,height:h,width:d}=o.globalBaseProps;return S.rectContains(t.globalPoint,new D(a-nt,c,nt,h))?(this.result={slideContainer:r,i:i.i,j:i.j,point:{x:a-nt/2,y:c+h/2}},!0):S.rectContains(t.globalPoint,new D(a+d,c,nt,h))?(this.result={slideContainer:r,i:i.i,j:i.j+1,point:{x:a+d+nt/2,y:c+h/2}},!0):!1}getRowColIndex(t,e){const n=t.slideProps.children;let o=0,s=0;for(const r of n){s=0;for(const i of r.ids){if(e===i)return{i:o,j:s};s++}o++}return null}}class If extends Ke{onDetect(t,e){const n=e.detect(F.Node,t);if(!n)return!1;const o=n[0];if(o.type!==v.SlideContainer||!e.auxiliaryManager.selectManager.include(o))return!1;const s=o;if(s.slideProps.children.length!==0)return!1;const{x:i,y:a,height:c,width:h}=o.globalBaseProps,d=new D(i+nt,a+xt,h-2*nt,c-2*xt);return S.rectContains(t.globalPoint,d)?(this.result={slideContainer:s,rect:d},!0):!1}getRowColIndex(t,e){const n=t.slideProps.children;let o=0,s=0;for(const r of n){s=0;for(const i of r.ids){if(e===i)return{i:o,j:s};s++}o++}return null}}class hr extends na{constructor(){super(...arguments);p(this,"detectors",new Map([[F.Node,new oa],[F.HoverNode,new sa],[F.PolyControlPoint,new hc],[F.CurveControlPoint,new mf],[F.Rotate,new Jo],[F.Stretch,new Fo],[F.ExpandShape,new ec],[F.LineEndPoint,new tc],[F.NodeEdge,new up],[F.BufferNode,new Ap],[F.BufferHoverNode,new Np],[F.HoverNodeAnchor,new Bp],[F.HoverConnectAnchor,new Ep],[F.HoverOnContainer,new Dp],[F.Image,new _p],[F.ImageOriginBounds,new df],[F.CurveEndPoint,new Pf],[F.DragLineText,new bf],[F.SlideGap,new vf],[F.EmptySlideContainer,new If]]));p(this,"modes",[new Mf,new Kp,new Up,new hf,new wf,new Cp,new Ja])}}const Tf={[K.Ellipse]:"#F2F3F5",[K.Hexagon]:"#F2F3F5",[K.Cloud]:"#F2F3F5",[K.YuanZhu]:"#F0FBEF",[K.Parallelogram]:"#F0FBEF",[K.Trapezoid]:"#E1EAFF",[K.Triangle]:"#E1EAFF",[K.Triangle2]:"#E1EAFF",[K.RightArrow]:"#E1EAFF",[K.DoubleArrow]:"#E1EAFF",[K.LeftArrow]:"#E1EAFF",[K.RoundRect]:"#E0E2FA",[K.RoundRect2]:"#E0E2FA",[K.Rect]:"#E0E2FA",[K.LiuCheng]:"#E0E2FA",[K.LiuCheng2]:"#E0E2FA",[K.Diamond]:"#FEEAD2",[K.Star]:"#FEEAD2",[K.Qipao]:"#FEF1F1",[K.Qipao2]:"#FEF1F1",[K.RightKuohao]:"#FEF1F1",[K.LeftKuohao]:"#FEF1F1"},Lf={[K.Ellipse]:"#DEE0E3",[K.Hexagon]:"#DEE0E3",[K.Cloud]:"#DEE0E3",[K.YuanZhu]:"#8EE085",[K.Parallelogram]:"#8EE085",[K.Trapezoid]:"#82A7FC",[K.Triangle]:"#82A7FC",[K.Triangle2]:"#82A7FC",[K.RightArrow]:"#82A7FC",[K.DoubleArrow]:"#82A7FC",[K.LeftArrow]:"#82A7FC",[K.RoundRect]:"#7B83EA",[K.RoundRect2]:"#7B83EA",[K.Rect]:"#7B83EA",[K.LiuCheng]:"#7B83EA",[K.LiuCheng2]:"#7B83EA",[K.Diamond]:"#FFBA6B",[K.Star]:"#FFBA6B",[K.Qipao]:"#F98E8B",[K.Qipao2]:"#F98E8B",[K.RightKuohao]:"#F98E8B",[K.LeftKuohao]:"#F98E8B"},Cf=(l,{x:t,y:e,width:n,height:o})=>l.x>=t&&l.x<=t+n&&l.y>=e&&l.y<=e+o;class Vt extends Fs{enable(t){return t.isPolyLine()}layoutToPoints(t,e){const n=t.lineProps,{start:o,end:s}=t.connectProps,r=[...t.globalLinePoints];if(!n.auto&&r.length>2){if(o){const c=r[0],h=r[1],d=S.judgeHorizon(c,h),u=e.nodeManager.getNode(o.objectId);if(u){const f=this.getNodePos(u,o);c.x=f.x,c.y=f.y}d?h.y=c.y:h.x=c.x}if(s){const c=r[r.length-2],h=r[r.length-1],d=S.judgeHorizon(c,h),u=e.nodeManager.getNode(s.objectId);if(u){const f=this.getNodePos(u,s);h.x=f.x,h.y=f.y}d?c.y=h.y:c.x=h.x}const i=t.globalTransform().inverseMatrix();return r.map(c=>i.crossPoint(c))}else{const i=this.getLayoutHandler(t,o,e),a=this.computeLayout(i,t,s,e),c=t.globalTransform().inverseMatrix();return a.map(d=>c.crossPoint(d))}}layoutToPointsPro(t,e){const n=this.getLayoutHandlerV2(t);return this.computePointsV2(n,e)}getLayoutHandlerV2({point:t,nodeConnect:e}){if(!e)return new _i(t);const{rect:n,endType:o}=e;switch(o){case de.Top:return new Wd(t,n);case de.Bottom:return new Fd(t,n);case de.Left:return new Yd(t,n);case de.Right:return new Gd(t,n);default:return new _i(t)}}computePointsV2(t,{point:e,nodeConnect:n}){if(!n)return t.toPoint(e);const{rect:o,endType:s}=n;switch(s){case de.Right:return t.right(e,o);case de.Left:return t.left(e,o);case de.Bottom:return t.bottom(e,o);case de.Top:return t.top(e,o);default:return t.toPoint(e)}}getLayoutHandler(t,e,n){const o={point:t.globalLinePoints[0]};if(e){const s=n.nodeManager.getNode(e.objectId);s&&(o.nodeConnect={rect:D.rectNode2Rect(s.getBounds()),endType:S.computeNodeConnectEnd(e,s.baseProps.angle)},o.point=this.getNodePos(s,e))}return this.getLayoutHandlerV2(o)}computeLayout(t,e,n,o){const s=Ze.computeConnectInfo(e,n,o,!0);return this.computePointsV2(t,s)}}class Af{constructor(){p(this,"workerMap",new Map)}init(t){this.workerMap.clear();for(const e of t){const n=new $n;n.init(e),this.workerMap.set(e,n)}}work(t,e,n){for(const o of t){const s=this.workerMap.get(o);s&&s.work(o,e,n)}}}class Rn{constructor(){p(this,"handlers",[new Xo,new po,new Vt]);p(this,"batchLineTextWorker",new Af)}work(t,e,n){this.batchLineTextWorker.init(t);for(const o of t)this.handleAndMsg(o,e,n);this.batchLineTextWorker.work(t,e,n)}layoutToPoints(t,e){for(const n of this.handlers)if(n.enable(t))return n.layoutToPoints(t,e);return[]}handleAndMsg(t,e,n){for(const o of this.handlers)if(o.enable(t)){const s=o.handle(t,e);e.execAction(new U(s,{streaming:n}));return}}batchCollectNodeLinks(t,e,n){const o=new Set(t);for(const s of t)this.collectNodeLinks(s,e,n,o)}collectNodeLinks(t,e,n,o=new Set){const s=e.nodeManager.getNodeLinks(t);for(const r of s){const{start:i,end:a}=r.connectProps;S.judgeEndNode(r,n,i,e,o),S.judgeEndNode(r,n,a,e,o)}for(const r of t.children){if(r.type===v.Line){const i=r,{start:a,end:c}=i.connectProps;S.judgeEndNode(i,n,a,e,o),S.judgeEndNode(i,n,c,e,o)}this.collectNodeLinks(r,e,n,o)}}judgeEndNode(t,e,n,o,s){if(!n)return;const r=o.nodeManager.getNode(n.objectId);r&&!S.judgeParentInset(r,s)&&e.add(t)}}class Nf{constructor(){p(this,"layoutWorker",new Rn);p(this,"groupBaseWorker",new on)}work(t,e,n){let o=!1;if(this.groupBaseWorker.start([e]),t.textProps.sizeMode===We.autoWidth){const s=e.getTextContentRect(),{width:r,height:i}=e.baseProps,a=r-s.width,c=t.height+(i-s.height)+.2;n.execAction(U.create(e.id,[{type:I.Base,width:t.width+a,height:c}])),o=!0}else if(t.textProps.sizeMode===We.autoHeight&&e instanceof vt){let s=e.drawer.fullTextNodeHeight(e);s<100&&(s=100),n.execAction(U.create(e.id,[{type:I.Base,height:s}])),o=!0}if(o){const s=new Set;this.groupBaseWorker.work(n,!1),this.layoutWorker.collectNodeLinks(e,n,s),this.layoutWorker.work([...s],n,!1)}}}class kf{work(t,e,n){const o=e.lineTextRect,s=new m(o.point.x,o.point.y),r=t.width,i=t.height;n.execAction(U.create(e.id,[{type:I.LineTextRect,x:s.x-.5*r,y:s.y-.5*i,width:r,height:i}]))}}class mo{constructor(){p(this,"prevStringBuilder",{text:""});p(this,"nextStringBuilder",{text:""});p(this,"currentbuilder",this.prevStringBuilder);p(this,"layoutWorker",new Rn);p(this,"groupBaseWorker",new on);p(this,"nodeModifyBaseWorker",new Nf);p(this,"lineModifyWorker",new kf)}switchCurrentBuilder(t,e){return this.currentbuilder===this.nextStringBuilder?!1:t.equal(e)?(this.currentbuilder=this.nextStringBuilder,!0):!1}splitText(t,e){this.prevStringBuilder={text:""},this.nextStringBuilder={text:""},this.currentbuilder=this.prevStringBuilder;let n=-1,o=0;for(let s=0;s<t.paragraphs.length;s++){const r=t.paragraphs[s];for(let i=0;i<r.lines.length;i++){const a=r.lines[i];this.switchCurrentBuilder(e,new Fe(s,i,-1))&&(o=n);const h=a.getCharLength();for(let d=0;d<h;d++){const{character:u}=a.getCharacter(d);this.currentbuilder.text+=u.charText,n++,this.switchCurrentBuilder(e,new Fe(s,i,d))&&(o=n)}}s<t.paragraphs.length-1&&(this.currentbuilder.text+=`
|
|
5
|
-
`,n++)}return{prev:this.prevStringBuilder.text,next:this.nextStringBuilder.text,index:o}}editText(t,e,n){const{paragraphIndex:o,lineIndex:s,charIndex:r}=e,i=t.prevParagraphToXML(o),a=t.nextParagraphToXML(o),c=t.getParagraph(o),h=c.prevToRichTextXML(s,t.textProps),d=c.nextToRichTextXML(s,t.textProps),u=c.getLine(s),f=u.getBlockIndex(r);if(f){const{textBlock:g,blockIndex:y,charIndex:P}=f,b=u.prevToRichTextXML(y,t.textProps),w=u.nextToRichTextXML(y,t.textProps),L=g.insertTextToRichTextXML(n,P,t.textProps);return`<root>${i}<p>${h}${b}${L}${w}${d}</p>${a}</root>`}return`<root>${i}<p>${h}${n}${d}</p>${a}</root>`}modifyBaseProps(t,e,n){e.type===v.Shape?this.nodeModifyBaseWorker.work(t,e,n):e.type===v.Line&&this.lineModifyWorker.work(t,e,n)}}class Bf{measure(t,e,n){const o=[];t.font=S.calcFontByTextProps(n);for(const s of e){const r=new Ui;for(const i of[...s]){const{width:a,height:c,boxAscent:h}=S.measureText(t,i),d=new As(i,0,0,a,c,h);r.addCharacter(d)}o.push(r)}return o}}class pc{constructor(){p(this,"streaming",!1)}}class yn{constructor(t,e){p(this,"meta",new pc);p(this,"data");p(this,"reverseLog",null);this.data=t,e&&(this.meta=e)}reverse(){if(this.reverseLog===null)throw new Error("缺少对应逆消息");return this.reverseLog}}var Lt=(l=>(l[l.Focus=0]="Focus",l[l.Selection=1]="Selection",l[l.Blur=2]="Blur",l[l.Empty=3]="Empty",l))(Lt||{});class ee extends yn{constructor(){super(...arguments);p(this,"type",Xe.TextFocus)}static focus(e,n=Fe.head()){return new ee({focusType:Lt.Focus,focus:{id:e,textCursorPosition:n}})}static selection(e,n,o){return new ee({focusType:Lt.Selection,selection:{id:e,start:n,end:o}})}static blur(e){return new ee({blur:{id:e},focusType:Lt.Blur})}static empty(){return new ee({focusType:Lt.Empty})}clone(){const e=JSON.parse(JSON.stringify(this.data));return new ee(e,this.meta)}}class fc{constructor(){p(this,"cursorMoveWorker",new ho)}work(t,e,n=1){const{node:o,renderText:s,textCursorPosition:r}=t,{updateTextProps:i}=this.computeUpdateTextProps(t,n);let a=r;for(let c=0;c<n;c++)a=this.cursorMoveWorker.moveLeft(s,a);e.execAction(new W),e.execAction(U.create(o.id,[i])),e.execAction(ee.focus(o.id,a)),e.execAction(new z)}computeUpdateTextProps(t,e){const{renderText:n,textCursorPosition:o}=t,s=this.deleteText(n,o,e);return{updateTextProps:{type:I.Text,richText:s}}}deleteText(t,e,n){if(n<=0)return t.toRichTextXML();const o=t.prevCursorPos(e,n),s=e;return this.deleteTextByCursorPos(t,o,s)}deleteTextByCursorPos(t,e,n){return e.equal(n)?t.toRichTextXML():this.generateDeletedXML(t,e,n)}generateDeletedXML(t,e,n){const{paragraphIndex:o,lineIndex:s,charIndex:r}=e,{paragraphIndex:i,lineIndex:a,charIndex:c}=n;return o===i?this.deleteSameParagraph(t,o,s,r,a,c):this.deleteCrossParagraph(t,o,s,r,i,a,c)}deleteSameParagraph(t,e,n,o,s,r){const i=t.prevParagraphToXML(e),a=t.nextParagraphToXML(e),c=t.getParagraph(e);if(n===s){const se=c.prevToRichTextXML(n,t.textProps),ne=c.nextToRichTextXML(s,t.textProps),ae=c.getLine(n),te=ae.getBlockIndex(o),ce=ae.getBlockIndex(r);if(!te||!ce)return`<root>${i}<p>${se}${ne}</p>${a}</root>`;const{blockIndex:pe,charIndex:Be}=te,{blockIndex:Re,charIndex:Se}=ce;if(pe===Re){const Ft=ae.prevToRichTextXML(pe,t.textProps),ln=ae.nextToRichTextXML(Re,t.textProps),On=te.textBlock,$e=On.getPrevText(Be),eo=On.getNextText(Se),to=$e+eo,Yt=`<style ${On.computeStyle(t.textProps)}>${to}</style>`;return`<root>${i}<p>${se}${Ft}${Yt}${ln}${ne}</p>${a}</root>`}const Te=ae.prevToRichTextXML(pe,t.textProps),fe=ae.nextToRichTextXML(Re,t.textProps),O=te.textBlock,G=ce.textBlock,j=O.getPrevText(Be),_=O.computeStyle(t.textProps),Ve=j?`<style ${_}>${j}</style>`:"",ut=G.getNextText(Se),yt=G.computeStyle(t.textProps),kt=ut?`<style ${yt}>${ut}</style>`:"";return`<root>${i}<p>${se}${Te}${Ve}${kt}${fe}${ne}</p>${a}</root>`}const h=c.prevToRichTextXML(n,t.textProps),d=c.nextToRichTextXML(s,t.textProps),u=c.getLine(n),f=c.getLine(s),g=u.getBlockIndex(o),y=f.getBlockIndex(r);if(!g||!y)return`<root>${i}<p>${h}${d}</p>${a}</root>`;const P=u.prevToRichTextXML(g.blockIndex,t.textProps),b=g.textBlock,w=b.getPrevText(g.charIndex),L=b.computeStyle(t.textProps),B=w?`<style ${L}>${w}</style>`:"",H=f.nextToRichTextXML(y.blockIndex,t.textProps),E=y.textBlock,X=E.getNextText(y.charIndex),$=E.computeStyle(t.textProps),Z=X?`<style ${$}>${X}</style>`:"";return`<root>${i}<p>${h}${P}${B}${Z}${H}${d}</p>${a}</root>`}deleteCrossParagraph(t,e,n,o,s,r,i){const a=t.prevParagraphToXML(e),c=t.nextParagraphToXML(s),h=t.getParagraph(e),d=t.getParagraph(s),u=h.prevToRichTextXML(n,t.textProps),f=h.getLine(n),g=f.getBlockIndex(o);let y="";if(g){const B=f.prevToRichTextXML(g.blockIndex,t.textProps),H=g.textBlock,E=H.getPrevText(g.charIndex),X=H.computeStyle(t.textProps),$=E?`<style ${X}>${E}</style>`:"";y=`${B}${$}`}const P=d.nextToRichTextXML(r,t.textProps),b=d.getLine(r),w=b.getBlockIndex(i);let L="";if(w){const B=b.nextToRichTextXML(w.blockIndex,t.textProps),H=w.textBlock,E=H.getNextText(w.charIndex),X=H.computeStyle(t.textProps);L=`${E?`<style ${X}>${E}</style>`:""}${B}`}return`<root>${a}<p>${u}${y}${L}${P}</p>${c}</root>`}}class os{constructor(){p(this,"deleteInputWorker",new fc)}work(t,e,n){n.execAction(ee.selection(t.node.id,e.start,e.end));const{node:o,renderText:s}=t,r=e.start;n.execAction(ee.focus(o.id,r));const i=this.deleteInputWorker.deleteTextByCursorPos(s,e.start,e.end),a={type:I.Text,richText:i};n.execAction(U.create(o.id,[a])),n.execAction(ee.focus(o.id,r))}}class ss{}class dr extends ss{enable(t,e){return t.paragraphIndex===e.paragraphIndex&&t.lineIndex===e.lineIndex}handle(t,e,n){const o=t.paragraphs[e.paragraphIndex],s=o.lines[e.lineIndex],r=s.getCharacter(n.charIndex);let i=0,a=0;if(e.charIndex>-1){const h=s.getCharacter(e.charIndex);i=h.textBlock.x+h.character.x+h.character.width,a=h.character.y}const c=new D(i,a,r.textBlock.x+r.character.x+r.character.width-i,s.height);return c.x+=s.x+o.x+t.x,c.y+=s.y+o.y+t.y,[c]}}class ur extends ss{enable(t,e){return t.paragraphIndex===e.paragraphIndex&&t.lineIndex!==e.lineIndex}handle(t,e,n){const o=[],s=t.paragraphs[e.paragraphIndex],r=s.lines[e.lineIndex],i=s.lines[n.lineIndex];let a=0,c=0;const h=r.getCharacter(e.charIndex);a=h===null?0:h.textBlock.x+h.character.x+h.character.width,c=h===null?0:h.character.y;const d=r.width-a;if(a+=r.x+s.x+t.x,c+=r.y+s.y+t.y,o.push(new D(a,c,d,r.height)),e.lineIndex+1===n.lineIndex&&n.charIndex===-1)return o;for(let f=e.lineIndex+1;f<n.lineIndex;f++){const g=s.lines[f];a=g.x+s.x+t.x,c=g.y+s.y+t.y,o.push(new D(a,c,g.width,g.height))}const u=i.getCharacter(n.charIndex);return u&&(a=i.x+s.x+t.x,c=i.y+s.y+t.y,o.push(new D(a,c,u.textBlock.x+u.character.x+u.character.width,i.height))),o}}class gc extends ss{constructor(){super(...arguments);p(this,"handlers",[new dr,new ur])}enable(e,n){return e.paragraphIndex!==n.paragraphIndex}handleSamePara(e,n,o){for(const s of this.handlers)if(s.enable(n,o))return s.handle(e,n,o);return[]}handle(e,n,o){const s=[],r=e.paragraphs[n.paragraphIndex],i=e.paragraphs[o.paragraphIndex],a=this.handleSamePara(e,n,r.tailCursorPosition());s.push(...a);for(let h=n.paragraphIndex+1;h<o.paragraphIndex;h++){const d=e.paragraphs[h];for(const u of d.lines)s.push(new D(e.x+d.x+u.x,e.y+d.y+u.y,u.width,u.height))}const c=this.handleSamePara(e,i.headCursorPosition(),o);return s.push(...c),s}}class yc{constructor(){p(this,"handlers",[new dr,new ur,new gc])}handleTextSelection(t,e,n){for(const o of this.handlers)if(o.enable(e,n))return o.handle(t,e,n);return[]}computeTextSelection(t,e,n){return e.equal(n)?[]:this.handleTextSelection(t,e,n)}}class xc{constructor(){p(this,"segmentWorker",new Intl.Segmenter("en",{granularity:"word"}))}split(t){return Array.from(this.segmentWorker.segment(t)).map(n=>n.segment)}}const Rf=new xc,He=16,Ne=16,wc=[{x:0,y:0},{x:He,y:0},{x:He,y:Ne},{x:0,y:Ne}];class En{}class Ef extends En{drawOnGLCtx(t,e){const n=e.borderProps;t.strokeStyle=n.color,t.lineWidth=n.width,t.globalAlpha=n.alpha,t.moveTo(0,.5*Ne),t.lineTo(He,.5*Ne),t.moveTo(.5*He,0),t.lineTo(He,.5*Ne),t.lineTo(.5*He,Ne),t.stroke()}}class Hf extends En{drawOnGLCtx(t,e){const n=e.borderProps;t.fillStyle=n.color,t.strokeStyle=n.color,t.lineWidth=n.width,t.globalAlpha=n.alpha,t.moveTo(0,.5*Ne),t.lineTo(.5*He,.5*Ne),t.stroke(),t.beginPath(),t.moveTo(.5*He,0),t.lineTo(He,.5*Ne),t.lineTo(.5*He,Ne),t.closePath(),t.fill(),t.stroke()}}class Df extends En{drawOnGLCtx(t,e){const n=e.borderProps;t.strokeStyle=n.color,t.lineWidth=2,t.globalAlpha=n.alpha,t.moveTo(0,.5*Ne),t.lineTo(.5*He,.5*Ne),t.stroke(),t.beginPath(),t.moveTo(.5*He,0),t.lineTo(He,.5*Ne),t.lineTo(.5*He,Ne),t.closePath(),t.stroke()}}class Of extends En{drawOnGLCtx(t,e){const n=e.borderProps;t.fillStyle=n.color,t.lineWidth=n.width,t.globalAlpha=n.alpha,t.moveTo(0,.5*Ne),t.lineTo(.5*He,.3*Ne),t.lineTo(He,.5*Ne),t.lineTo(.5*He,.7*Ne),t.closePath(),t.fill()}}class Xf extends En{drawOnGLCtx(t,e){const n=e.borderProps;t.strokeStyle=n.color,t.lineWidth=2,t.globalAlpha=n.alpha,t.moveTo(0,.5*Ne),t.lineTo(.5*He,.3*Ne),t.lineTo(He,.5*Ne),t.lineTo(.5*He,.7*Ne),t.closePath(),t.stroke()}}class zf extends En{drawOnGLCtx(t,e){const n=e.borderProps;t.fillStyle=n.color,t.strokeStyle=n.color,t.lineWidth=n.width,t.globalAlpha=n.alpha;const o=Math.min(He,Ne)*.3;t.moveTo(0,.5*Ne),t.lineTo(He-o,.5*Ne),t.stroke(),t.beginPath();const s=He,r=.5*Ne;t.arc(s,r,o,0,2*Math.PI),t.fill(),t.stroke()}}class Wf extends En{drawOnGLCtx(t,e){const n=e.borderProps;t.strokeStyle=n.color,t.lineWidth=2,t.globalAlpha=n.alpha;const o=Math.min(He,Ne)*.3;t.moveTo(0,.5*Ne),t.lineTo(He-o,.5*Ne),t.stroke(),t.beginPath();const s=He,r=.5*Ne;t.arc(s,r,o,0,2*Math.PI),t.stroke()}}const wn=class wn extends en{constructor(e,n){super(e,n);p(this,"type",v.Line);p(this,"renderText");p(this,"inEditing",!1);p(this,"rArrowMatrix",re.generateMatrix());p(this,"lArrowMatrix",re.generateMatrix());this.props.set(I.Base,new ie),this.props.set(I.Border,new Ae),this.props.set(I.Shape,new Oe),this.props.set(I.Line,new je),this.props.set(I.Arrow,new lt),this.props.set(I.Connect,new Rt),this.props.set(I.Text,Ge.create({sizeMode:We.autoWidth})),this.props.set(I.LineTextRect,new Et),this.props.set(I.TextParagraph,new qt),this.props.set(I.TextParagraphQuote,new Dt),this.renderText=new uo}get globalPos(){const e=this.pos;return this.globalTransform().crossPoint(e)}get borderProps(){return this.props.get(I.Border)}get textProps(){return this.props.get(I.Text)}get paragraphProps(){return this.props.get(I.TextParagraph)}get paragraphQuoteProps(){return this.props.get(I.TextParagraphQuote)}get arrowProps(){return this.props.get(I.Arrow)}get shapeType(){return this.props.get(I.Shape).shapeCode}get lineProps(){return this.props.get(I.Line)}get globalLinePoints(){const e=this.lineProps.points,n=this.globalTransform();return e.map(s=>n.crossPoint(s))}get connectProps(){return this.props.get(I.Connect)}get points(){return this.lineProps.points}get lineTextRect(){return this.props.get(I.LineTextRect)}get drawer(){const e=this.shapeType;let n=wn.drawerMap.get(e);return n||(console.error("取不到drawer,使用line兜底!"),n=wn.drawerMap.get(he.Line)),n}canBeConnected(){return!1}getStretchMinSize(){return new m(10,10)}drawWithTextClip(e){const o=this.getTextContentRect();o.x-=2,o.y-=2,o.width+=2*2,o.height+=2*2;const s=D.rectNode2Rect(this.getRectNode());let r=new m(s.x,s.y);r=this.toLocal(r),e.save(),e.beginPath(),e.rect(r.x,r.y,s.width,s.height),e.rect(o.x,o.y,o.width,o.height),e.clip("evenodd"),this.drawCore(e),e.restore()}drawCore(e){const n=this.borderProps;S.setDashLine(n,e),e.save(),e.strokeStyle=n.color,e.globalAlpha=n.alpha,e.lineWidth=n.width,this.drawer.draw(this,e),e.restore(),e.beginPath(),this.drawArrow(e)}drawOnGLCtx(e){const n=!this.isEmptyText()||this.inEditing;e.save();const{a:o,b:s,c:r,d:i,e:a,f:c}=this.globalTransform();e.transform(o,s,r,i,a,c),n?this.drawWithTextClip(e):this.drawCore(e),this.drawText(e),e.restore()}drawText(e){const{alpha:n}=this.borderProps;e.save(),e.beginPath();const o=new m;this.renderText.draw(e,o,n),e.restore()}isEmptyText(){return this.renderText.isEmptyText()}updateProps(e){super.updateProps(e),this.updateLArrowMatrix(),this.updateRArrowMatrix();const n=e.find(c=>c.type===I.Text),o=e.find(c=>c.type===I.Base),s=e.find(c=>c.type===I.Line),r=e.find(c=>c.type===I.LineTextRect),i=e.find(c=>c.type===I.TextParagraph),a=e.find(c=>c.type===I.TextParagraphQuote);if(n||o||s||r||i||a){const c=this.getTextContentRect();this.renderText.typesetting(this.graphicContext,this.textProps,c,this.paragraphProps,this.paragraphQuoteProps)}}getArrowDrawer(e){const n=wn.arrowDrawerMap.get(e);return n||null}draw(){this.drawOnGLCtx(this.graphicContext)}getBounds(){const e=[...this.points],n=this.globalTransform(),o=e.map(r=>n.crossPoint(r));return S.getBoundsByPoints(o)}getRectNode(){const e=[...this.points],{lArrow:n,rArrow:o}=this.arrowProps;if(n)for(const c of wc)e.push(this.lArrowMatrix.crossPoint(c));if(o)for(const c of wc)e.push(this.rArrowMatrix.crossPoint(c));const s=this.globalTransform(),r=e.map(c=>s.crossPoint(c)),i=S.getBoundsByPoints(r),a=this.borderProps;return i.minX=i.minX-a.width,i.minY=i.minY-a.width,i.maxX=i.maxX+2*a.width,i.maxY=i.maxY+2*a.width,i.id=this.id,i}updateRArrowMatrix(){const{rArrow:e}=this.arrowProps;if(!e)return;const n=this.points,o=n[n.length-1],s=new m(He,.5*Ne);let r=0;if(this.isPolyLine()){const u=n[n.length-2],f=o;S.judgeHorizon(u,f)?r=f.x>u.x?0:180:r=f.y>u.y?90:-90}else if(this.shapeType===he.Curve){const u=n[n.length-1],f=n[n.length-2],g=n[n.length-3];S.distance(u,f)>.1?r=S.lineAngle(f,u)/Math.PI*180:r=S.lineAngle(g,u)/Math.PI*180}else{const u=n[n.length-2];r=S.lineAngle(u,o)/Math.PI*180}const i=re.generateMatrix().translate(-.5*He,-.5*He),a=re.generateMatrix().rotate(r),c=i.crossProduct(a),h=c.crossPoint(s),d=re.generateMatrix().translate(o.x-h.x,o.y-h.y);this.rArrowMatrix=d.crossProduct(c)}updateLArrowMatrix(){const{lArrow:e}=this.arrowProps;if(!e)return;const n=this.points,o=n[0],s=new m(He,.5*Ne);let r=0;if(this.isPolyLine()){const u=o,f=n[1];S.judgeHorizon(u,f)?r=f.x>u.x?180:0:r=f.y>u.y?-90:90}else if(this.shapeType===he.Curve){const u=n[0],f=n[1],g=n[2];S.distance(u,f)>.1?r=S.lineAngle(f,u)/Math.PI*180:r=S.lineAngle(g,u)/Math.PI*180}else{const u=n[1];r=S.lineAngle(u,o)/Math.PI*180}const i=re.generateMatrix().translate(-.5*He,-.5*He),a=re.generateMatrix().rotate(r),c=i.crossProduct(a),h=c.crossPoint(s),d=re.generateMatrix().translate(o.x-h.x,o.y-h.y);this.lArrowMatrix=d.crossProduct(c)}drawArrow(e){if(this.points.length===0){console.error("line has no point!");return}const o=this.arrowProps;if(o.rArrow){const s=this.getArrowDrawer(o.rArrow);if(s){e.save();const{a:r,b:i,c:a,d:c,e:h,f:d}=this.rArrowMatrix;e.transform(r,i,a,c,h,d),s.drawOnGLCtx(e,this),e.restore()}}if(o.lArrow){const s=this.getArrowDrawer(o.lArrow);if(s){e.save();const{a:r,b:i,c:a,d:c,e:h,f:d}=this.lArrowMatrix;e.transform(r,i,a,c,h,d),s.drawOnGLCtx(e,this),e.restore()}}}getRArrowPoint(e,n,o=5){const s=S.distance(e,n),r=new m(s-Math.sqrt(3)*.5*o,.5*o),i=new m(s-Math.sqrt(3)*.5*o,-.5*o);return this.basicGetArrowPoint(e,n,r,i)}basicGetArrowPoint(e,n,o,s){const r=S.lineAngle(e,n),i=re.generateMatrix().translate(e.x,e.y).rotate2(r),a=i.crossPoint(o),c=i.crossPoint(s);return{a,b:c}}static load(e,n,o,s,r,i){const a=new wn(e,i);return a.type=n,a.zIndex=o,a.setParent(r),a.updateProps(s),a}contains(e,n=1){const o=this.toLocal(e),s=this.getTextContentRect();if(S.rectContains(o,s))return!0;const r=8/n;return wi.lineContainsPoint(this,o,r)}overlapRect(e){const n=this.getBounds();return S.containRect(e,n)?!0:wi.overlapRectNode(this,e)}getTextContentRect(){const e=this.baseProps,{x:n,y:o,width:s,height:r}=this.lineTextRect;return new D(n+e.x,o+e.y,s,r)}isPolyLine(){const e=this.shapeType;return e===he.PolyLine||e===he.RoundPolyLine}modifyPosInEditing(){return this.inEditing=!0,!0}resetFromEditing(){this.inEditing=!1}getDrawPoints(){const{lArrow:e,rArrow:n}=this.arrowProps,o=[...this.points];if(e){const s=new m(0,.5*Ne),r=this.lArrowMatrix.crossPoint(s);o.shift(),o.unshift(r)}if(n){const s=new m(0,.5*Ne),r=this.rArrowMatrix.crossPoint(s);o.pop(),o.push(r)}return o}getLineLength(){const e=this.points;if(this.isPolyLine()){let s=0;for(let r=0;r<e.length-1;r++){const i=e[r],a=e[r+1],c=S.distance(i,a);s+=c}return s}if(this.shapeType===he.Curve){const s=S.computeBezierCurves(this);let r=0;for(const i of s){const a=i.getApproximateLength();r+=a}return r}const n=e[0],o=e[e.length-1];return S.distance(n,o)}};p(wn,"arrowDrawerMap",new Map([[it.Arrow,new Ef],[it.Triangle,new Hf],[it.EmptyTriangle,new Df],[it.Diamond,new Of],[it.EmptyDiamond,new Xf],[it.Circle,new zf],[it.EmptyCircle,new Wf]])),p(wn,"drawerMap",new Map([[he.Curve,new Wh],[he.RoundPolyLine,new Fh],[he.PolyLine,new zh],[he.Line,new Xh]]));let Ct=wn;class mt{buildPath(t,e){}draw(t,e){const n=t.colorProps,o=t.borderProps;e.lineJoin="round",e.lineCap="round",this.buildPath(t,e),n.color!==""&&(e.fillStyle=n.color,e.globalAlpha=n.alpha,e.fill()),o.color!==""&&o.dashType!==et.None&&(S.setDashLine(o,e),e.strokeStyle=o.color,e.lineWidth=o.width,e.globalAlpha=o.alpha,e.stroke())}getTextPadding(t){const e=t.textProps.fontSize;return e>10?le:e<4?0:1}fullTextNodeHeight(t){const e=this.getTextPadding(t);return t.renderText.height+2*e}textContentBounds(t){const e=t.baseProps,n=this.getTextPadding(t);return{x:n,y:n,width:e.width-2*n+2,height:e.height-2*n}}nodeShapeInfo(t){const{width:e,height:n}=t.baseProps;return q.rectangle({top:0,left:0,width:e,height:n})}borderContains(t,e,n){const o=this.nodeShapeInfo(t),s=q.line({x:e.x-n,y:e.y},{x:e.x+n,y:e.y}),r=q.line({x:e.x,y:e.y-n},{x:e.x,y:e.y+n});for(const i of[s,r]){const a=Y.intersect(o,i);if(a.points.length>0)return a.points[0]}return null}getConnectAnchor(){return[new m(.5,0),new m(1,.5),new m(.5,1),new m(0,.5)]}}class Ff extends mt{draw(t,e){}textContentBounds(t){const e=t.baseProps,n=this.getTextPadding(t);return{x:n,y:n,width:e.width-2*n,height:e.height-2*n}}fullTextNodeHeight(t){const e=this.getTextPadding(t);return t.renderText.height+2*e}getTextPadding(t){const e=t.textProps.fontSize;return e>10?2:e<4?0:1}}class Yf extends mt{draw(t,e){const n=t.colorProps,o=t.baseProps,s=t.borderProps;n.color!==""&&(e.fillStyle=n.color,e.globalAlpha=n.alpha,e.fillRect(0,0,o.width,o.height)),s.color!==""&&s.dashType!==et.None&&(S.setDashLine(s,e),e.strokeStyle=s.color,e.lineWidth=s.width,e.globalAlpha=s.alpha,e.strokeRect(0,0,o.width,o.height))}}class Gf extends mt{textContentBounds(t){const e=t.baseProps,n=e.width/4,o=-e.height/(e.width/2),s=e.height,r=o*n+s,i={x:n,y:r,width:e.width/2,height:e.height-r};return{x:i.x+le,y:i.y+le,width:i.width-le*2,height:i.height-le*2}}fullTextNodeHeight(t){return(t.renderText.height+le)*2}draw(t,e){const n=t.colorProps,{width:o,height:s}=t.baseProps,r=t.borderProps;e.fillStyle=n.color,e.globalAlpha=n.alpha,e.lineWidth=r.width,e.lineJoin="round",e.lineCap="round",e.beginPath(),e.moveTo(0,s),e.lineTo(.5*o,0),e.lineTo(o,s),e.closePath(),n.color!==""&&e.fill(),r.color!==""&&r.dashType!==et.None&&Math.abs(r.alpha)>.001&&(S.setDashLine(r,e),e.globalAlpha=r.alpha,e.strokeStyle=r.color,e.stroke())}nodeShapeInfo(t){const{width:e,height:n}=t.baseProps;return q.polygon([{x:0,y:n},{x:.5*e,y:0},{x:e,y:n}])}getConnectAnchor(){return[new m(.5,0),new m(.75,.5),new m(.5,1),new m(.25,.5)]}}class Uf extends mt{draw(t,e){const n=t.colorProps,{width:o,height:s}=t.baseProps,r=t.borderProps;e.fillStyle=n.color,e.globalAlpha=n.alpha,e.lineWidth=r.width,e.lineJoin="round",e.lineCap="round",e.beginPath(),e.moveTo(0,.5*s),e.lineTo(.5*o,0),e.lineTo(o,.5*s),e.lineTo(.5*o,s),e.closePath(),n.color!==""&&e.fill(),r.color!==""&&r.dashType!==et.None&&Math.abs(r.alpha)>.001&&(e.strokeStyle=r.color,e.globalAlpha=r.alpha,S.setDashLine(r,e),e.stroke())}fullTextNodeHeight(t){return(t.renderText.height+le)*2}textContentBounds(t){const e=t.baseProps,n={x:0,y:e.height/2},o={x:e.width/2,y:0},s=(n.y-o.y)/(n.x-o.x),r=n.y,i=.25*e.width,a=s*i+r,c={x:i,y:a,with:e.width-i*2,height:e.height-a*2};return{x:c.x+le,y:c.y+le,width:c.with-le*2,height:c.height-le*2}}nodeShapeInfo(t){const{width:e,height:n}=t.baseProps;return q.polygon([{x:0,y:.5*n},{x:.5*e,y:0},{x:e,y:.5*n},{x:.5*e,y:n}])}}class _f extends mt{draw(t,e){const n=t.baseProps,o=t.colorProps,s=t.borderProps;e.beginPath(),e.fillStyle=o.color,e.roundRect(0,0,n.width,n.height,10),o.color!==""&&(e.globalAlpha=o.alpha,e.fill()),s.color!==""&&s.dashType!==et.None&&Math.abs(s.alpha)>.001&&(e.strokeStyle=s.color,e.lineWidth=s.width,e.globalAlpha=s.alpha,S.setDashLine(s,e),e.stroke())}nodeShapeInfo(t){const{width:e,height:n}=t.baseProps;return q.rectangle({top:0,left:0,width:e,height:n})}}class $f extends mt{draw(t,e){const n=t.colorProps,{width:o,height:s}=t.baseProps,r=t.borderProps;e.fillStyle=n.color,e.globalAlpha=n.alpha,e.lineWidth=r.width,e.lineJoin="round",e.lineCap="round",e.beginPath(),e.ellipse(.5*o,.5*s,.5*o,.5*s,0,0,2*Math.PI,!1),n.color!==""&&e.fill(),r.color!==""&&r.dashType!==et.None&&Math.abs(r.alpha)>.001&&(e.strokeStyle=r.color,e.globalAlpha=r.alpha,S.setDashLine(r,e),e.stroke())}textContentBounds(t){const e=t.baseProps,n=e.width*Math.sqrt(2)/2,o=(e.width-n)/2,s=Math.max(e.width,e.height)/2,r=Math.min(e.width,e.height)/2,i=(1-(n/2)**2/s**2)*r**2,a={x:o,y:e.height/2-Math.sqrt(i),width:n,height:2*Math.sqrt(i)},c=this.getTextPadding(t);return{x:a.x+c,y:a.y+c,width:a.width-c*2,height:a.height-c*2}}fullTextNodeHeight(t){const e=this.getTextPadding(t);return(t.renderText.height+e)*2}nodeShapeInfo(t){const{width:e,height:n}=t.baseProps;return q.ellipse({centerX:.5*e,centerY:.5*n,radiusX:.5*e,radiusY:.5*n})}}class jf extends mt{textContentBounds(t){const e=t.baseProps;return{x:.16*e.width+le,y:le,width:(1-.16*2)*e.width-2*le,height:e.height-2*le}}buildPath(t,e){const n=t.baseProps;e.beginPath(),e.moveTo(.16*n.width,0),e.lineTo(n.width,0),e.lineTo(.84*n.width,n.height),e.lineTo(0,n.height),e.closePath()}nodeShapeInfo(t){const{width:e,height:n}=t.baseProps;return q.polygon([{x:.16*e,y:0},{x:e,y:0},{x:.84*e,y:n},{x:0,y:n}])}getConnectAnchor(){return[new m(.5,0),new m(.92,.5),new m(.5,1),new m(.08,.5)]}}class Vf extends mt{textContentBounds(t){const e=t.baseProps;return{x:.2*e.width,y:le,width:.6*e.width,height:e.height-2*le}}draw(t,e){const n=t.colorProps,{width:o,height:s}=t.baseProps,r=t.borderProps;e.lineJoin="round",e.lineCap="round",e.beginPath(),e.moveTo(.2*o,0),e.lineTo(.8*o,0),e.lineTo(o,s),e.lineTo(0,s),e.closePath(),n.color!==""&&(e.fillStyle=n.color,e.globalAlpha=n.alpha,e.fill()),r.color!==""&&r.dashType!==et.None&&(S.setDashLine(r,e),e.strokeStyle=r.color,e.lineWidth=r.width,e.globalAlpha=r.alpha,e.stroke())}nodeShapeInfo(t){const{width:e,height:n}=t.baseProps;return q.polygon([{x:.2*e,y:0},{x:.8*e,y:0},{x:e,y:n},{x:0,y:n}])}getConnectAnchor(){return[new m(.5,0),new m(.9,.5),new m(.5,1),new m(.1,.5)]}}class Kf extends mt{buildPath(t,e){const{width:n,height:o}=t.baseProps;e.beginPath(),e.moveTo(.5*n,0),e.lineTo(n,.38196601125010515*o),e.lineTo(.8090169943749473*n,o),e.lineTo(.1909830056250526*n,o),e.lineTo(0,.381966011250105*o),e.closePath()}nodeShapeInfo(t){const{width:e,height:n}=t.baseProps;return q.polygon([{x:.5*e,y:0},{x:e,y:.38196601125010515*n},{x:.8090169943749473*e,y:n},{x:.1909830056250526*e,y:n},{x:0,y:.381966011250105*n}])}textContentBounds(t){const e=t.baseProps,n={x:0,y:e.height*.38196601125010515},o={x:e.width/2,y:0},s=(n.y-o.y)/(n.x-o.x),r=n.y,i=.1909830056250526*e.width,a=s*i+r,c={x:i,y:a,with:e.width-i*2,height:e.height-a};return{x:c.x+le,y:c.y+le,width:c.with-le*2,height:c.height-le*2}}fullTextNodeHeight(t){const e=t.renderText.height,n=t.baseProps,o={x:0,y:n.height*.38196601125010515},s={x:n.width/2,y:0},r=(o.y-s.y)/(o.x-s.x),i=o.y,a=.1909830056250526*n.width,c=r*a+i;return e+2*le+c}getConnectAnchor(){return super.getConnectAnchor()}}class Qf extends mt{buildPath(t,e){const{width:n,height:o}=t.baseProps;e.beginPath(),e.moveTo(n,.5*o),e.lineTo(.75*n,o),e.lineTo(.25*n,o),e.lineTo(0,.5*o),e.lineTo(.25*n,0),e.lineTo(.75*n,0),e.closePath()}nodeShapeInfo(t){const{width:e,height:n}=t.baseProps;return q.polygon([{x:e,y:.5*n},{x:.75*e,y:n},{x:.25*e,y:n},{x:0,y:.5*n},{x:.25*e,y:0},{x:.75*e,y:0}])}textContentBounds(t){const e=t.baseProps;return{x:.25*e.width+le,y:le,width:.5*e.width-2*le,height:e.height-2*le}}getConnectAnchor(){return super.getConnectAnchor()}}class Zf extends mt{buildPath(t,e){const{width:n,height:o}=t.baseProps;e.beginPath(),e.moveTo(.7071067811865476*n,0),e.lineTo(n,.2928932188134524*o),e.lineTo(n,.7071067811865476*o),e.lineTo(.7071067811865476*n,o),e.lineTo(.2928932188134525*n,o),e.lineTo(0,.7071067811865476*o),e.lineTo(0,.29289321881345254*o),e.lineTo(.29289321881345215*n,0),e.closePath()}nodeShapeInfo(t){const{width:e,height:n}=t.baseProps;return q.polygon([{x:.7071067811865476*e,y:0},{x:e,y:.2928932188134524*n},{x:e,y:.7071067811865476*n},{x:.7071067811865476*e,y:n},{x:.2928932188134525*e,y:n},{x:0,y:.7071067811865476*n},{x:0,y:.29289321881345254*n},{x:.29289321881345215*e,y:0}])}textContentBounds(t){const e=t.baseProps,n={x:.064625*e.width,y:.064625*e.height,width:e.width*(1-.064625*2),height:e.height*(1-.064625*2)};return{x:n.x+le,y:n.y+le,width:n.width-le*2,height:n.height-le*2}}fullTextNodeHeight(t){return(t.renderText.height+2*le)/(1-.064625*2)}getConnectAnchor(){return super.getConnectAnchor()}}const qf="M19.1498 8.12942L18.9895 8.95084L19.7971 9.17031C21.3773 9.59972 22.4731 10.9487 22.4731 12.4833C22.4731 13.901 21.5408 15.1571 20.1512 15.6818L19.5155 15.9218L19.5722 16.5988C19.5788 16.6767 19.5821 16.7556 19.5821 16.8356C19.5821 18.3711 18.3424 19.6106 16.8195 19.6106C16.2161 19.6106 15.66 19.4173 15.206 19.0884L14.4417 18.5348L13.925 19.3244C13.4292 20.082 12.5786 20.5777 11.6143 20.5777C10.5661 20.5777 9.65135 19.9913 9.18244 19.1206L8.73358 18.2873L7.92388 18.7776C7.45803 19.0596 6.90757 19.2236 6.31413 19.2236C4.61055 19.2236 3.26243 17.8766 3.26243 16.2551C3.26243 15.774 3.37941 15.3216 3.58718 14.9209L4.05462 14.0194L3.1035 13.6636C2.19708 13.3246 1.52704 12.4149 1.52704 11.323C1.52704 9.96428 2.55686 8.90054 3.79171 8.84083L4.78871 8.79263L4.63791 7.80592C4.62047 7.69176 4.61134 7.57433 4.61134 7.45418C4.61134 6.18576 5.63529 5.16272 6.89198 5.16272C7.18142 5.16272 7.45628 5.21645 7.70869 5.31377L8.44216 5.59655L8.82102 4.90778C9.30983 4.01913 10.2497 3.42222 11.3256 3.42222C12.5174 3.42222 13.5428 4.15533 13.9715 5.20352L14.3964 6.24229L15.3181 5.60191C15.717 5.32477 16.1997 5.16272 16.7227 5.16272C18.0858 5.16272 19.1961 6.27235 19.1961 7.6476C19.1961 7.81325 19.1801 7.97425 19.1498 8.12942Z";class Jf extends mt{constructor(){super(...arguments);p(this,"path2D",new Path2D(qf))}textContentBounds(e){const n=e.baseProps;return{x:.2*n.width,y:.2*n.height,width:.6*n.width,height:.6*n.height}}draw(e,n){const o=e.colorProps,s=e.borderProps,{width:r,height:i}=e.baseProps,a=new Path2D;a.addPath(this.path2D,new DOMMatrix().scale(r/24,i/24)),n.lineJoin="round",n.lineCap="round",o.color!==""&&(n.fillStyle=o.color,n.globalAlpha=o.alpha,n.fill(a)),s.color!==""&&s.dashType!==et.None&&(S.setDashLine(s,n),n.strokeStyle=s.color,n.lineWidth=s.width,n.globalAlpha=s.alpha,n.stroke(a))}borderContains(e,n,o){const{width:s,height:r}=e.baseProps,i=e.borderProps,a=new Path2D;a.addPath(this.path2D,new DOMMatrix().scale(s/24,r/24));const c=e.graphicContext;return c.lineWidth=i.width,c.isPointInStroke(a,n.x,n.y)?n:null}}const Ie=.3;class eg extends mt{buildPath(t,e){const{width:n,height:o}=t.baseProps;e.beginPath(),e.moveTo(0,Ie*o),e.lineTo(Ie*n,Ie*o),e.lineTo(Ie*n,0),e.lineTo((1-Ie)*n,0),e.lineTo((1-Ie)*n,Ie*o),e.lineTo(n,Ie*o),e.lineTo(n,(1-Ie)*o),e.lineTo((1-Ie)*n,(1-Ie)*o),e.lineTo((1-Ie)*n,o),e.lineTo(Ie*n,o),e.lineTo(Ie*n,(1-Ie)*o),e.lineTo(0,(1-Ie)*o),e.closePath()}nodeShapeInfo(t){const{width:e,height:n}=t.baseProps;return q.polygon([{x:0,y:Ie*n},{x:Ie*e,y:Ie*n},{x:Ie*e,y:0},{x:(1-Ie)*e,y:0},{x:(1-Ie)*e,y:Ie*n},{x:e,y:Ie*n},{x:e,y:(1-Ie)*n},{x:(1-Ie)*e,y:(1-Ie)*n},{x:(1-Ie)*e,y:n},{x:Ie*e,y:n},{x:Ie*e,y:(1-Ie)*n},{x:0,y:(1-Ie)*n}])}textContentBounds(t){const e=t.baseProps;return{x:e.width*Ie+le,y:e.height*Ie+le,width:e.width*(1-Ie*2)-le*2,height:e.height*(1-Ie*2)-le*2}}fullTextNodeHeight(t){return(t.renderText.height+2*le)/(1-Ie*2)}getConnectAnchor(){return super.getConnectAnchor()}}class tg extends mt{buildPath(t,e){const{width:n,height:o}=t.baseProps;e.beginPath(),e.moveTo(.45331701407562014*n,.04068531978415023*o),e.lineTo(.47241283626581937*n,0),e.lineTo(.5275866431283414*n,0),e.lineTo(.5466824653185405*n,.04068531978415023*o),e.lineTo(.6561866975837122*n,.2739844955129827*o),e.lineTo(.6637719246641702*n,.29014093296241683*o),e.lineTo(.6784321851024475*n,.3013390437841371*o),e.lineTo(.6953883172925998*n,.3039298761896317*o),e.lineTo(.9402500678089105*n,.3413412114782689*o),e.lineTo(.9829501587587509*n,.3478650949789417*o),e.lineTo(n,.40304112159559813*o),e.lineTo(.9691020434299804*n,.4347080674349939*o),e.lineTo(.7919190520392391*n,.616307190723145*o),e.lineTo(.779648372403934*n,.6288863854576189*o),e.lineTo(.7740466535716944*n,.647005242973332*o),e.lineTo(.7769464280973055*n,.6647628181337468*o),e.lineTo(.8187719012369075*n,.9211802328191082*o),e.lineTo(.8260655890472862*n,.9658971352498816*o),e.lineTo(.7814288443747758*n,o),e.lineTo(.7432371999943775*n,.9788868781153761*o),e.lineTo(.5242235294056399*n,.8578189712649151*o),e.lineTo(.509058281303118*n,.849438315417013*o),e.lineTo(.49094119809104253*n,.849438315417013*o),e.lineTo(.4757759499885207*n,.8578189712649151*o),e.lineTo(.2567643618231409*n,.9788868781153761*o),e.lineTo(.21857115562522422*n,o),e.lineTo(.1739323285293562*n,.9658971352498816*o),e.lineTo(.18122705755141377*n,.9211802328191082*o),e.lineTo(.22305409250853406*n,.6647628181337468*o),e.lineTo(.22595074339910845*n,.647005242973332*o),e.lineTo(.2203516275960661*n,.6288863854576189*o),e.lineTo(.20808146856660034*n,.616307190723145*o),e.lineTo(.030898997781698512*n,.4347080674349939*o),e.lineTo(0,.40304112159559813*o),e.lineTo(.017050361847088705*n,.3478650949789417*o),e.lineTo(.059751494008607714*n,.3413412114782689*o),e.lineTo(.3046116827074003*n,.3039298761896317*o),e.lineTo(.3215683355033921*n,.3013390437841371*o),e.lineTo(.33622703412415095*n,.29014093296241683*o),e.lineTo(.34381017878125136*n,.2739844955129827*o),e.lineTo(.45331701407562014*n,.04068531978415023*o),e.closePath()}nodeShapeInfo(t){const{width:e,height:n}=t.baseProps;return q.polygon([{x:.45331701407562014*e,y:.04068531978415023*n},{x:.47241283626581937*e,y:0},{x:.5275866431283414*e,y:0},{x:.5466824653185405*e,y:.04068531978415023*n},{x:.6561866975837122*e,y:.2739844955129827*n},{x:.6637719246641702*e,y:.29014093296241683*n},{x:.6784321851024475*e,y:.3013390437841371*n},{x:.6953883172925998*e,y:.3039298761896317*n},{x:.9402500678089105*e,y:.3413412114782689*n},{x:.9829501587587509*e,y:.3478650949789417*n},{x:e,y:.40304112159559813*n},{x:.9691020434299804*e,y:.4347080674349939*n},{x:.7919190520392391*e,y:.616307190723145*n},{x:.779648372403934*e,y:.6288863854576189*n},{x:.7740466535716944*e,y:.647005242973332*n},{x:.7769464280973055*e,y:.6647628181337468*n},{x:.8187719012369075*e,y:.9211802328191082*n},{x:.8260655890472862*e,y:.9658971352498816*n},{x:.7814288443747758*e,y:n},{x:.7432371999943775*e,y:.9788868781153761*n},{x:.5242235294056399*e,y:.8578189712649151*n},{x:.509058281303118*e,y:.849438315417013*n},{x:.49094119809104253*e,y:.849438315417013*n},{x:.4757759499885207*e,y:.8578189712649151*n},{x:.2567643618231409*e,y:.9788868781153761*n},{x:.21857115562522422*e,y:n},{x:.1739323285293562*e,y:.9658971352498816*n},{x:.18122705755141377*e,y:.9211802328191082*n},{x:.22305409250853406*e,y:.6647628181337468*n},{x:.22595074339910845*e,y:.647005242973332*n},{x:.2203516275960661*e,y:.6288863854576189*n},{x:.20808146856660034*e,y:.616307190723145*n},{x:.030898997781698512*e,y:.4347080674349939*n},{x:0,y:.40304112159559813*n},{x:.017050361847088705*e,y:.3478650949789417*n},{x:.059751494008607714*e,y:.3413412114782689*n},{x:.3046116827074003*e,y:.3039298761896317*n},{x:.3215683355033921*e,y:.3013390437841371*n},{x:.33622703412415095*e,y:.29014093296241683*n},{x:.34381017878125136*e,y:.2739844955129827*n},{x:.45331701407562014*e,y:.04068531978415023*n}])}textContentBounds(t){const e=t.baseProps,n={x:e.width*.059751494008607714,y:e.height*.3413412114782689},o={x:e.width*.3046116827074003,y:e.height*.3039298761896317},s=(n.y-o.y)/(n.x-o.x),r=n.y,i=.22595074339910845*e.width,a=s*i+r,c={x:i,y:a,with:e.width-i*2,height:e.height*.849438315417013-a};return{x:c.x+le,y:c.y+le,width:c.with-le*2,height:c.height-le*2}}fullTextNodeHeight(t){const e=t.baseProps;return e.width*.059751494008607714,e.height*.3413412114782689,e.width*.3046116827074003,e.height*.3039298761896317,(t.renderText.height+2*le)/.849438315417013}getConnectAnchor(){return super.getConnectAnchor()}}const Wt=class Wt extends en{constructor(e,n){super(e,n);p(this,"type",v.Shape);p(this,"transform",re.generateMatrix());p(this,"renderText");this.props.set(I.Base,new ie),this.props.set(I.Shape,new Oe),this.props.set(I.Color,new tt),this.props.set(I.Border,new Ae),this.props.set(I.Text,new Ge),this.props.set(I.TextParagraph,new qt),this.props.set(I.TextParagraphQuote,new Dt),this.renderText=new uo}validShapeCode(e){return!!Wt.drawerMap.get(e)}get borderProps(){return this.props.get(I.Border)}get colorProps(){return this.props.get(I.Color)}get textProps(){return this.props.get(I.Text)}get paragraphProps(){return this.props.get(I.TextParagraph)}get paragraphQuoteProps(){return this.props.get(I.TextParagraphQuote)}get shapeType(){return this.props.get(I.Shape).shapeCode}get drawer(){const e=Wt.drawerMap.get(this.shapeType);return e||Wt.drawerMap.get(K.RoundRect)}borderContains(e,n){const o=this.toLocal(e);return this.drawer.borderContains(this,o,n)}updateProps(e){super.updateProps(e);const n=e.find(i=>i.type===I.Text),o=e.find(i=>i.type===I.TextParagraph),s=e.find(i=>i.type===I.TextParagraphQuote),r=e.find(i=>i.type===I.Base);if(r&&this.updateTransformMatrix(),n||r||o||s){const i=this.drawer.textContentBounds(this);this.shapeType===K.PureText&&this.textProps.sizeMode!==We.fix&&this.textProps.verticalAlign!==at.Top&&(this.textProps.verticalAlign=at.Top),this.renderText.typesetting(this.graphicContext,this.textProps,i,this.paragraphProps,this.paragraphQuoteProps),this.shapeType===K.PureText&&this.textProps.sizeMode!==We.fix&&(this.baseProps.height=this.renderText.y+this.renderText.height,this.renderText.rect.height=this.renderText.height+4,this.textProps.sizeMode===We.autoWidth&&(this.baseProps.width=this.renderText.width+4))}}modifyPosInEditing(e){if(this.shapeType===K.PureText)return!1;const n=this.drawer.textContentBounds(this);return this.renderText.modifyPosInEditing(n,e)}resetFromEditing(){const e=this.drawer.textContentBounds(this);return this.renderText.resetFromEditing(e)}contains(e){const{width:n,height:o}=this.baseProps,s=this.toLocal(e);return S.rectContains(s,new D(0,0,n,o))}drawOnGLCtx(e){const n=this.shapeType;let o=Wt.drawerMap.get(n);o||(console.error("取不到drawer,使用rect兜底!"),o=Wt.drawerMap.get(K.Rect)),e.save(),e.beginPath();const{a:s,b:r,c:i,d:a,e:c,f:h}=this.globalTransform();e.transform(s,r,i,a,c,h),o.draw(this,e),this.drawText(e),e.restore()}drawText(e){if(this.shapeType===K.PureText){const a=new m;this.renderText.draw(e,a,1);return}const{x:n,y:o,width:s,height:r}=this.getTextContentRect();e.save(),e.beginPath(),e.rect(n,o,s,r),e.clip();const i=new m;this.renderText.draw(e,i,1),e.restore()}getStretchMinSize(){return new m(20,20)}draw(){this.drawOnGLCtx(this.graphicContext)}getTextContentRect(){const e=this.shapeType;let n=Wt.drawerMap.get(e);return n||(console.error("取不到drawer,使用rect兜底!"),n=Wt.drawerMap.get(K.Rect)),n.textContentBounds(this)}isEmptyText(){return this.renderText.isEmptyText()}getConnectAnchor(){return this.drawer.getConnectAnchor()}static load(e,n,o,s,r,i){const a=new Wt(e,i);return a.type=n,a.zIndex=o,a.setParent(r),a.updateProps(s),a}};p(Wt,"drawerMap",new Map([[K.PureText,new Ff],[K.Ellipse,new $f],[K.Rect,new Yf],[K.RoundRect,new _f],[K.Triangle,new Gf],[K.Diamond,new Uf],[K.Parallelogram,new jf],[K.Octagon,new Zf],[K.Hexagon,new Qf],[K.Trapezoid,new Vf],[K.Pentagon,new Kf],[K.Star,new tg],[K.Cloud,new Jf],[K.Cross,new eg]]));let vt=Wt;class jn extends Fn{constructor(e,n){super(e,n);p(this,"type",v.SVG);p(this,"imgBitmap",null);p(this,"svgCode","");this.props.set(I.Base,new ie),this.props.set(I.Border,new Ae),this.props.set(I.Svg,new Wn),this.props.set(I.Crop,new Mn)}get svgUrl(){return this.props.get(I.Svg).url}get svgProps(){return this.props.get(I.Svg)}setSvgCode(e){this.svgCode=e}static load(e,n,o,s,r,i){const a=new jn(e,i);return a.type=n,a.zIndex=o,a.setParent(r),a.updateProps(s),a}}class an{static getNumFromString(t){try{const e=t.match(/(\d+)/);return e&&e[1]?parseInt(e[1],10):100}catch{return console.error("从字符串中获取num出错:",t),100}}static trimSvgCode(t){const n=new DOMParser().parseFromString(t,"image/svg+xml").documentElement,o=n.getAttribute("width"),s=n.getAttribute("height");n.removeAttribute("width"),n.removeAttribute("height");const r=n.style.width,i=n.style.height;n.style.removeProperty("width"),n.style.removeProperty("height");let a=100,c=100;return o!==null?a=this.getNumFromString(o):r!==""&&(a=this.getNumFromString(r)),s!==null?c=this.getNumFromString(s):i!==""&&(c=this.getNumFromString(i)),n.getAttribute("viewBox")||n.setAttribute("viewBox",`0 0 ${a} ${c}`),{svgCode:n.outerHTML,width:a,height:c}}}class Po extends en{constructor(e,n){super(e,n);p(this,"type",v.Group);this.props.set(I.Base,new ie)}get globalPos(){return this.nameGlobalTransform().crossPoint(new m)}computeBasePropsByChildren(){const e=[];for(const s of this.children)e.push(s.baseProps);const n=S.getBoundsByBasePropsList(e),o=D.rectNode2Rect(n);return ie.create({x:o.x,y:o.y,width:o.width,height:o.height})}drawOnGLCtx(e){}getTextContentRect(){return this.baseProps}canBeConnected(){return!1}transToLocalPoint(e){return this.nameGlobalTransform().inverseMatrix().crossPoint(e)}contains(e,n=1){const{width:o,height:s}=this.baseProps,r=this.transToLocalPoint(e);return S.rectContains(r,new D(0,0,o,s))}toGlobal(e){return this.nameGlobalTransform().crossPoint(e)}nameGlobalTransform(){const e=this.selfTransform();return this.globalTransform().crossProduct(e)}selfTransform(){const{x:e,y:n}=this.baseProps;return re.generateMatrix().translate(e,n)}updateTransformMatrix(){}static load(e,n,o,s,r,i){const a=new Po(e,i);return a.type=n,a.zIndex=o,a.setParent(r),a.updateProps(s),a}}class rs extends en{constructor(e,n){super(e,n);p(this,"type",v.Section);this.props.set(I.Base,new ie),this.props.set(I.Border,new Ae),this.props.set(I.Color,new tt),this.props.set(I.Slide,new St)}get borderProps(){return this.props.get(I.Border)}get colorProps(){return this.props.get(I.Color)}updateProps(e){super.updateProps(e),e.find(o=>o.type===I.Base)&&this.updateTransformMatrix()}drawOnGLCtx(e){e.save();const n=this.baseProps,{a:o,b:s,c:r,d:i,e:a,f:c}=this.globalTransform();e.transform(o,s,r,i,a,c);const h=this.colorProps,d=this.borderProps;e.beginPath(),e.roundRect(0,0,n.width,n.height,6),h.color!==""&&(e.fillStyle=h.color,e.globalAlpha=h.alpha,e.fill()),d.color!==""&&d.dashType!==et.None&&(S.setDashLine(d,e),e.strokeStyle=d.color,e.lineWidth=d.width,e.globalAlpha=d.alpha,e.stroke()),e.restore()}static load(e,n,o,s,r,i){const a=new rs(e,i);return a.type=n,a.zIndex=o,a.setParent(r),a.updateProps(s),a}canQuickCreate(){return!1}getTextContentRect(){return this.baseProps}}class bo extends en{constructor(e,n){super(e,n);p(this,"type",v.SlideContainer);this.props.set(I.Base,new ie),this.props.set(I.Slide,new St)}get slideProps(){return this.props.get(I.Slide)}updateProps(e){super.updateProps(e),e.find(o=>o.type===I.Base)&&this.updateTransformMatrix()}drawOnGLCtx(e){const{width:n,height:o}=this.baseProps,{a:s,b:r,c:i,d:a,e:c,f:h}=this.globalTransform();e.save(),e.transform(s,r,i,a,c,h),e.shadowColor="rgba(0, 0, 0, 0.1)",e.shadowBlur=15,e.shadowOffsetX=0,e.shadowOffsetY=6,e.fillStyle="rgba(255, 255, 255, 0.6)",e.beginPath(),e.roundRect(0,0,n,o,8),e.fill(),e.shadowColor="transparent",e.fillStyle="rgba(240, 242, 245, 0.5)",e.fill(),e.strokeStyle="rgba(0, 0, 0, 0.1)",e.lineWidth=1,e.stroke(),e.restore()}canQuickCreate(){return!1}getTextContentRect(){return this.baseProps}static load(e,n,o,s,r,i){const a=new bo(e,i);return a.type=n,a.zIndex=o,a.setParent(r),a.updateProps(s),a}getChildIdByIndex(e){const n=this.slideProps.children;let o=0;for(let s=0;s<n.length;s++){if(e<o+n[s].ids.length){const r=e-o;return n[s].ids[r]}o+=n[s].ids.length}return null}getTotalCount(){return this.slideProps.children.reduce((n,o)=>n+o.ids.length,0)}}const ms=class ms{static getInstance(){return this.instance||(this.instance=new ms),this.instance}create(t,e,n,o,s,r){switch(e){case v.Line:return Ct.load(t,e,n,o,s,r);case v.SVG:return jn.load(t,e,n,o,s,r);case v.IMG:return Yn.load(t,e,n,o,s,r);case v.Section:return rs.load(t,e,n,o,s,r);case v.Group:return Po.load(t,e,n,o,s,r);case v.Checkbox:return Yo.load(t,e,n,o,s,r);case v.CheckboxText:return Un.load(t,e,n,o,s,r);case v.SlideContainer:return bo.load(t,e,n,o,s,r);case v.Shape:default:return vt.load(t,e,n,o,s,r)}}createByNodeInfo(t,e,n){const o=S.convertCapInfoToProps(t.capInfo);return this.create(t.id,t.type,t.zIndex,o,e,n)}};p(ms,"instance",null);let It=ms;class pr extends en{constructor(e){const o=document.createElement("canvas").getContext("2d");super(e,o);p(this,"type",v.ROOT);p(this,"transform",re.generateMatrix())}updateProps(e){}drawOnGLCtx(e){}getTextContentRect(){return new D}toGlobal(e){return e}toLocal(e){return e}}const is=800;class mc{static async getImageSize(t){return new Promise((e,n)=>{const o=URL.createObjectURL(t),s=new Image;s.crossOrigin="anonymous",s.onload=()=>{let r=s.naturalWidth*.5,i=s.naturalHeight*.5;URL.revokeObjectURL(o);const a=r/i;r>i&&r>is?(r=is,i=r/a):i>r&&i>is&&(i=is,r=i*a),e({width:r,height:i})},s.onerror=()=>{URL.revokeObjectURL(o),n(new Error("无法加载图片"))},s.src=o})}}class At extends yn{constructor(){super(...arguments);p(this,"type",Xe.RemoveNode)}static create(e){return new At({idList:e})}clone(){const e=JSON.parse(JSON.stringify(this.data));return new At(e,this.meta)}}class fr{}class Pc extends fr{handle(t,e,n){const o=e.find(i=>i.type===I.Connect);if(!o)return;const{start:s,end:r}=o;if(s!==void 0)if(s!==null){const i=n.nodeManager.getNode(s.objectId)||null;n.nodeManager.addLink(t,i,!0)}else n.nodeManager.addLink(t,null,!0);if(r!==void 0)if(r!==null){const i=n.nodeManager.getNode(r.objectId)||null;n.nodeManager.addLink(t,i,!1)}else n.nodeManager.addLink(t,null,!1)}}class ng extends fr{handle(t,e,n){if(!e.find(r=>r.type===I.Image)||t.type!==v.IMG)return;const s=t;n.asyncRenderNodeManager.addRenderNode(s)}}let og=class extends fr{handle(t,e,n){const o=e.find(r=>r.type===I.Svg);if(!o||t.type!==v.SVG)return;const s=t;if(s.svgProps.useCode){const r=an.trimSvgCode(s.svgProps.code);s.setSvgCode(r.svgCode),n.asyncRenderNodeManager.addRenderNode(s);return}n.resourceManager.loadSvgUrl(o.url).then(r=>{const i=an.trimSvgCode(r);s.setSvgCode(i.svgCode),n.asyncRenderNodeManager.addRenderNode(s)}).catch(r=>{console.error("加载图片出现问题",r),s.setBroken(),n.renderManager.dirtyDraw(t.getBounds())})}};class bc extends hn{constructor(){super(...arguments);p(this,"type",Xe.AddNode);p(this,"handlers",[new Pc,new ng,new og])}execData(e,n){const o=e.nodes;for(const s of o)this.execNodeInfo(s,n);n.renderManager.addContentRenderTask()}execNodeInfo(e,n){const o=n.gmlRender.glCtx,s=n.nodeManager.getParentNode(e.parentId),r=It.getInstance().create(e.id,e.type,e.zIndex,e.props,s,o);n.nodeManager.addNode(r);for(const i of this.handlers)i.handle(r,e.props,n)}reverseLog(e,n){const o=e.nodes.map(s=>s.id);return new At({idList:o})}}class Le extends yn{constructor(){super(...arguments);p(this,"type",Xe.AddNode)}static create(e){return new Le({nodes:[e]})}clone(){const e=JSON.parse(JSON.stringify(this.data));return new Le(e,this.meta)}}class Sc extends hn{constructor(){super(...arguments);p(this,"type",Xe.RemoveNode)}execData(e,n){for(const o of e.idList)n.nodeManager.getNode(o)&&n.nodeManager.removeNode(o);n.renderManager.addContentRenderTask(),n.renderManager.addAuxiliaryDrawTask()}reverseLog(e,n){var s;const o=[];for(const r of e.idList){const i=n.nodeManager.getNode(r);if(!i){console.error("错误,生成逆消息时节点不存在:",r);continue}const a=[...i.props.values()];o.push({id:i.id,type:i.type,zIndex:i.zIndex,parentId:((s=i.parent)==null?void 0:s.id)||Sn,props:a})}return new Le({nodes:o})}}class U extends yn{constructor(){super(...arguments);p(this,"type",Xe.UpdateNode)}static create(e,n,o){const s={id:e,props:n};return new U({infos:[s]},o)}clone(){const e=JSON.parse(JSON.stringify(this.data));return new U(e,this.meta)}}class Mc extends hn{constructor(){super(...arguments);p(this,"type",Xe.UpdateNode);p(this,"handlers",[new Pc])}execData(e,n){for(const o of e.infos)this.execNodeInfo(o,n);n.renderManager.addContentRenderTask()}execNodeInfo(e,n){const{id:o,zIndex:s,props:r,parentId:i}=e,a=n.nodeManager.getNode(o);if(!a){console.error("错误:节点不存在:",o);return}if(this.removeIndexNode(a,n),s!==void 0&&(a.zIndex=s),this.changeParent(a,n,i),r.length>0){a.updateProps(r);for(const c of this.handlers)c.handle(a,r,n)}this.addIndexNode(a,n),n.auxiliaryManager.selectManager.include(a)&&(n.auxiliaryManager.selectManager.refreshSelectStatus(),n.renderManager.addAuxiliaryDrawTask(),n.auxiliaryManager.slotManager.addSlotState(ze.FocusPropsChange,!0))}changeParent(e,n,o){if(o===void 0||o===e.parent.id)return;const s=n.nodeManager.getNode(o);s&&(e.parent.children.delete(e),s.children.add(e),e.parent=s)}removeIndexNode(e,n){n.nodeManager.removeIndexNode(e.getRectNode());for(const o of e.children)this.removeIndexNode(o,n)}addIndexNode(e,n){n.nodeManager.addIndexNode(e.getRectNode());for(const o of e.children)this.addIndexNode(o,n)}reverseLog(e,n){const o=[];for(const s of e.infos){const r=n.nodeManager.getNode(s.id);if(!r)continue;const i=r.parent?r.parent.id:n.nodeManager.root.id,a=r.serializeTo(),c=S.convertCapInfoToProps(a.capInfo);o.push({id:r.id,zIndex:r.zIndex,props:c,parentId:i})}return new U({infos:o})}}class xe extends yn{constructor(){super(...arguments);p(this,"type",Xe.SelectNode)}static create(e){return new xe({idList:e})}clone(){const e=JSON.parse(JSON.stringify(this.data));return new xe(e,this.meta)}}class vc extends hn{constructor(){super(...arguments);p(this,"type",Xe.SelectNode)}execData(e,n){const o=e.idList,s=new Set;o.forEach(r=>{const i=n.nodeManager.getNode(r);i&&s.add(i)}),n.auxiliaryManager.selectManager.set(s),n.renderManager.addAuxiliaryDrawTask(),n.auxiliaryManager.slotManager.addSlotState(ze.FocusPropsChange,!0)}reverseLog(e,n){const s=n.auxiliaryManager.selectManager.getSelectNodes().map(r=>r.id);return new xe({idList:s})}}class z extends yn{constructor(){super(null);p(this,"type",Xe.End)}clone(){return new z}}class Ic extends hn{constructor(){super(...arguments);p(this,"type",Xe.Start)}execData(e,n){}reverseLog(e,n){return new z}}class W extends yn{constructor(){super(null);p(this,"type",Xe.Start)}clone(){return new W}}class Tc extends hn{constructor(){super(...arguments);p(this,"type",Xe.End)}execData(e,n){}reverseLog(e,n){return new W}}class Lc extends hn{constructor(){super(...arguments);p(this,"type",Xe.TextFocus)}checkValidNode(e,n){const o=n.nodeManager.getNode(e);if(!o)throw new Error("错误:节点不存在:"+e);const s=o.renderText;return{node:o,renderText:s}}execData(e,n){var a;const{focusType:o,blur:s,selection:r,focus:i}=e;if(o===Lt.Empty){n.auxiliaryManager.remove(k.TextSelection);return}if(n.renderManager.addAuxiliaryDrawTask(),o===Lt.Focus){n.auxiliaryManager.remove(k.TextSelection);const{id:c,textCursorPosition:h}=i,{node:d,renderText:u}=this.checkValidNode(c,n);d.modifyPosInEditing(h)&&n.renderManager.addContentRenderTask(),n.inputManager.focus({node:d,renderText:u,textCursorPosition:h}),u.isEmptyText()?d.type===v.Shape&&n.auxiliaryManager.addOrUpdate(k.PlaceHolder,{node:d}):n.auxiliaryManager.remove(k.PlaceHolder),n.auxiliaryManager.selectManager.refreshSelectStatus();return}if(o===Lt.Selection){const{id:c,start:h,end:d}=r,{node:u,renderText:f}=this.checkValidNode(c,n);n.inputManager.selection(u,f,h,d);const g=(a=n.inputManager.selectionManager.selectionInfo)==null?void 0:a.selectionList;g&&(n.auxiliaryManager.addOrUpdate(k.TextSelection,{selectionList:g,node:u}),n.renderManager.addAuxiliaryDrawTask()),n.auxiliaryManager.remove(k.PlaceHolder),n.auxiliaryManager.slotManager.addSlotState(ze.FocusPropsChange,!0);return}if(o===Lt.Blur){n.inputManager.blur(),n.auxiliaryManager.remove(k.PlaceHolder);return}}reverseLog(e,n){const{focusType:o}=e,s=n.inputManager.editTextInfo,r=n.inputManager.selectionManager.selectionInfo;if(o===Lt.Focus){const i=e.focus.id;return s?r?ee.selection(s.node.id,r.start,r.end):ee.focus(s.node.id,s.textCursorPosition):ee.blur(i)}if(o===Lt.Blur)return s?r?ee.selection(s.node.id,r.start,r.end):ee.focus(s.node.id,s.textCursorPosition):(console.warn("选中消息不符合预期,已容错处理"),ee.empty());if(o===Lt.Selection){const i=e.selection.id;return s?r?ee.selection(s.node.id,r.start,r.end):ee.focus(s.node.id,s.textCursorPosition):ee.blur(i)}return ee.empty()}}const Cc=[new bc,new Sc,new Mc,new vc,new Lc,new Ic,new Tc];class Ac{}class sg extends Ac{constructor(){super(...arguments);p(this,"slideContainer",null)}enable(e,n){if(e.meta.streaming||n.docState.docMode!==ue.SLIDE_EDIT)return!1;const o=n.docState.slideStatus.slideContainer;return o?(this.slideContainer=o,!0):!1}handle(e,n){this.slideContainer&&(this.handleUpdateLog(e,n,this.slideContainer),this.handleAddLog(e,n,this.slideContainer),this.handleRemoveLog(e,n,this.slideContainer))}handleUpdateLog(e,n,o){var s;if(e.type===Xe.UpdateNode){const r=e.data;for(const i of r.infos){const a=n.nodeManager.getNode(i.id);if(!a)continue;if(((s=a.parent)==null?void 0:s.id)===o.id&&this.judgeOnlyPosChange(i.props,a)){this.judgeSlideEditCurrent(a,n)&&(console.log("协同端正在更新此幻灯片位置,触发器重置视图"),setTimeout(()=>{n.slideManager.refocusSlide(n,50)},10));continue}if(a.id===o.id){const h=n.renderManager.getScale(),d=this.judgeOnlyPosChange(i.props,a);if(d){n.renderManager.scroll(d.x*h,d.y*h);continue}}const c=S.judgeSlideSectionChildren(a,o);c&&n.slideManager.slideCoverManager.updateSlideCover(c)}}}judgeSlideEditCurrent(e,n){const o=n.docState.slideStatus;return o.slideContainer?o.slideContainer.getChildIdByIndex(o.currentIndex)===e.id:!1}judgeOnlyPosChange(e,n){if(e.length!==1)return null;const o=e[0];if(o.type!==I.Base)return null;const s=n.baseProps,r=o.width===void 0||Math.abs(o.width-s.width)<.1;if(!(o.height===void 0||Math.abs(o.height-s.height)<.1)||!r)return null;if(o.x!==void 0||o.y!==void 0){const a=new m;return o.x!==void 0&&(a.x=o.x-s.x),o.y!==void 0&&(a.y=o.y-s.y),a}return null}handleAddLog(e,n,o){if(e.type===Xe.AddNode){const s=e.data;for(const r of s.nodes){const i=n.nodeManager.getNode(r.parentId);if(!i)continue;const a=S.judgeSlideSectionChildren(i,o);a&&n.slideManager.slideCoverManager.updateSlideCover(a)}}}handleRemoveLog(e,n,o){if(e.type===Xe.RemoveNode){const s=e.data;for(const r of s.idList){const i=n.nodeManager.getNode(r);if(!i)continue;const a=S.judgeSlideSectionChildren(i,o);a&&n.slideManager.slideCoverManager.updateSlideCover(a)}}}}class rg extends Ac{constructor(){super(...arguments);p(this,"slideContainer",null)}enable(e,n){if(e.meta.streaming||n.docState.docMode!==ue.SLIDE_EDIT)return!1;const o=n.docState.slideStatus.slideContainer;return o?(this.slideContainer=o,!0):!1}handle(e,n){this.slideContainer&&this.handleUpdateLog(e,n,this.slideContainer)}handleUpdateLog(e,n,o){if(e.type===Xe.UpdateNode){const s=e.data;for(const r of s.infos){const i=n.nodeManager.getNode(r.id);!i||i.id!==o.id||!r.props.find(c=>c.type===I.Slide)||n.slideManager.slideCoverManager.updateSlideContainerCover(o)}}}}class Nc{constructor(t){p(this,"executors",new Map);p(this,"ctx");p(this,"beforeInterceptors",[new sg,new rg]);p(this,"afterInterceptors",[]);for(const e of t)this.executors.set(e.type,e)}init(t){this.ctx=t}exec(t,e){const n=this.executors.get(t.type);if(!n){console.error("缺乏对应的消息处理器,已忽略该消息");return}for(const o of this.beforeInterceptors)o.enable(t,this.ctx)&&o.handle(t,this.ctx);n.exec(t,e);for(const o of this.afterInterceptors)o.enable(t,this.ctx)&&o.handle(t,this.ctx)}}class kc{constructor(){p(this,"undoStack",[]);p(this,"redoStack",[])}add(t){const e=t.reverse();this.undoStack.push(e),this.redoStack=[]}undo(t,e){const n=this.undoStack.pop()||null;if(!n)return null;for(const o of n.actionLogs)t.exec(o,e);return this.redoStack.push(n.reverse()),n}redo(t,e){const n=this.redoStack.pop()||null;if(!n)return null;for(const o of n.actionLogs)t.exec(o,e);return this.undoStack.push(n.reverse()),n}}class as{constructor(t=[]){p(this,"actionLogs",[]);this.actionLogs=t}reverse(){const t=new as;for(let e=this.actionLogs.length-1;e>-1;e--){const n=this.actionLogs[e];t.actionLogs.push(n.reverse())}return t}}class Bc{constructor(){p(this,"cacheLogs",[]);p(this,"duringGroup",!1)}add(t){t.type===Xe.Start&&(this.duringGroup=!0),this.cacheLogs.push(t),t.type===Xe.End&&(this.duringGroup=!1)}getActionGroup(){if(this.duringGroup)return null;const t=new as(this.cacheLogs);return this.cacheLogs=[],t}}const Rc=new Set([Xe.Start,Xe.End,Xe.SelectNode,Xe.TextFocus]);class Ec{constructor(t,e,n,o,s,r,i,a,c,h,d,u){p(this,"execCtx");p(this,"executor");p(this,"undoManager");p(this,"networkPlugin",null);p(this,"actionCache");p(this,"renderManager");p(this,"docState");this.executor=new Nc(Cc),this.undoManager=new kc,this.renderManager=r,this.execCtx={inputManager:e,nodeManager:t,gmlRender:n,auxiliaryManager:o,toolManager:s,renderManager:this.renderManager,resourceManager:i,idGenerator:c,slotManager:h,asyncRenderNodeManager:d,docState:a,slideManager:u},this.actionCache=new Bc,this.docState=a}addNetworkPlugin(t){this.networkPlugin=t}execAction(t){var n;this.dealDocSeq(t),this.executor.exec(t,this.execCtx),Rc.has(t.type)||(n=this.networkPlugin)==null||n.addMessage(t),this.actionCache.add(t);const e=this.actionCache.getActionGroup();e&&this.undoManager.add(e)}dealDocSeq(t){Rc.has(t.type)||this.docState.seq++}undo(){var e;const t=this.undoManager.undo(this.executor,this.execCtx);t&&((e=this.networkPlugin)==null||e.addActionGroup(t))}redo(){var e;const t=this.undoManager.redo(this.executor,this.execCtx);t&&((e=this.networkPlugin)==null||e.addActionGroup(t))}}function ig(l){return l.type===Xe.AddNode?{addNodeData:{data:l.data.nodes.map(n=>{const o=n.props,s=new Map;o.forEach(a=>s.set(a.type,a));const r=S.convertPropsToCapInfo(s);return{id:n.id,type:n.type,zIndex:n.zIndex,parentId:n.parentId,capInfo:r}})}}:l.type===Xe.UpdateNode?{updateNodeData:{data:l.data.infos.map(n=>{const o=n.props,s=new Map;o.forEach(a=>s.set(a.type,a));const r=S.convertPropsToCapInfo(s);return{id:n.id,zIndex:n.zIndex,parentId:n.parentId,capInfo:r}})}}:l instanceof At?{removeNodeData:{data:l.data.idList}}:null}function ag(l){const{updateNodeData:t,addNodeData:e,removeNodeData:n}=l;if(e){const o=[];for(const s of e.data)o.push({id:s.id,parentId:s.parentId,zIndex:s.zIndex,type:s.type,props:S.convertCapInfoToProps(s.capInfo)});return new Le({nodes:o})}if(t){const o=[];for(const s of t.data)o.push({id:s.id,zIndex:s.zIndex,parentId:s.parentId,props:S.convertCapInfoToProps(s.capInfo)});return new U({infos:o})}if(n)return At.create(n.data);throw new Error("类型转换错误!")}const gr=.04,yr=4;class Hc{static isMobile(){const t=navigator.userAgent||navigator.vendor||window.opera;if(/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini|mobile/i.test(t.toLowerCase()))return!0;const n="ontouchstart"in window||navigator.maxTouchPoints>0,o=window.innerWidth<768;return n&&o}}const cg=70,lg=10;class hg{zoomScale(t,e,n){const o=n.getScale();let s=t;o*t>yr&&(s=yr/o),o*t<gr&&(s=gr/o),this.zoomToScale(s,e,n.gmlRender),this.zoomToScale(s,e,n.auxiliaryManager.gmlRender);const r=n.getScale();n.slotManager.addSlotState(ze.Scale,r),n.addContentRenderTask(),n.addAuxiliaryDrawTask()}zoomToSelect(t){if(t.auxiliaryManager.selectManager.getSelectNodes().length===0)return;const n=t.auxiliaryManager.selectManager.getSelectBounds();this.zoomToBounds(n,t)}zoomToFit(t){if(t.nodeManager.nodeMap.size===0)return;const n=t.nodeManager.getNodeBounds();this.zoomToBounds(n,t)}zoomTo100(t){if(t.nodeManager.nodeMap.size===0)return;const n=t.nodeManager.getNodeBounds(),o=t.gmlRender.canvas.getBoundingClientRect(),s=window.devicePixelRatio,r=1*s,i=new m(.5*s*o.width,.5*s*o.height),a=new m(.5*(n.minX+n.maxX),.5*(n.minY+n.maxY)),c=new m(-a.x*r+i.x,-a.y*r+i.y);this.zoomToMatrix(r,c.x,c.y,t.gmlRender),this.zoomToMatrix(r,c.x,c.y,t.auxiliaryManager.gmlRender);const h=t.getScale();t.slotManager.addSlotState(ze.Scale,h),t.addContentRenderTask(),t.addAuxiliaryDrawTask()}zoomToBounds(t,e,n){const o=Hc.isMobile()?lg:cg,s=n!==void 0?n:o,r=D.rectNode2Rect(t),i=e.gmlRender.canvas.getBoundingClientRect(),a=window.devicePixelRatio,c=i.width-s*2*a,h=i.height-s*2*a,d=c/r.width,u=h/r.height,f=Math.min(d,u)*a,g=new m(.5*a*i.width,.5*a*i.height),y=new m(.5*(t.minX+t.maxX),.5*(t.minY+t.maxY)),P=new m(-y.x*f+g.x,-y.y*f+g.y);this.zoomToMatrix(f,P.x,P.y,e.gmlRender),this.zoomToMatrix(f,P.x,P.y,e.auxiliaryManager.gmlRender);const b=e.getScale();e.slotManager.addSlotState(ze.Scale,b),e.addContentRenderTask(),e.addAuxiliaryDrawTask()}zoomToScale(t,e,n){n.scale(t,t,e);const o=n.glCtx,{a:s,b:r,c:i,d:a,e:c,f:h}=n.globalTransform;o.setTransform(s,r,i,a,c,h)}zoomToMatrix(t,e,n,o){const s=t,r=t,i=e,a=n;o.setTransform(s,0,0,r,i,a)}}class dg{exportToOfflineCanvas(t,e,n,o){const s=D.rectNode2Rect(t),r=document.createElement("canvas");r.width=n*s.width,r.height=n*s.height;const i=r.getContext("2d");i.scale(n,n),i.translate(-s.x,-s.y);let a=e.searchNodesByRectNode(t);a=S.sortGraphics(a),i.save(),o&&(i.fillStyle=o,i.fillRect(s.x,s.y,s.width,s.height)),i.restore();for(const c of a)c.drawOnGLCtx(i);return r}exportToOfflineCanvasByFilterNodes(t,e,n,o,s){const r=D.rectNode2Rect(t),i=document.createElement("canvas");i.width=n*r.width,i.height=n*r.height;const a=i.getContext("2d");a.scale(n,n),a.translate(-r.x,-r.y);let c=e.searchNodesByRectNode(t);c=S.sortGraphics(c),a.save(),o&&(a.fillStyle=o,a.fillRect(r.x,r.y,r.width,r.height)),a.restore();for(const h of c)s.has(h)&&h.drawOnGLCtx(a);return i}}class Dc{constructor(t,e,n,o){p(this,"gmlRender");p(this,"nodeManager");p(this,"auxiliaryManager");p(this,"slotManager");p(this,"zoomWorker",new hg);p(this,"exportWorker",new dg);p(this,"contentDraw",!1);p(this,"auxiliaryDraw",!1);p(this,"focusId");p(this,"tickerRun",()=>{if(this.contentDraw){const t=this.judgeFocusNode();t?this.auxiliaryManager.selectManager.docState.docMode===ue.SLIDE_PLAY?this.drawInPlayingMode(t):this.drawInFocusMode(t):this.drawInNormalMode()}this.auxiliaryDraw&&(this.auxiliaryManager.redraw(),this.auxiliaryDraw=!1),requestAnimationFrame(this.tickerRun)});p(this,"drawInNormalMode",()=>{const t=this.gmlRender.getViewPortBounds(),e=this.nodeManager.tree.search(t),n=new Set;for(const s of e){const r=this.nodeManager.nodeMap.get(s.id);r&&n.add(r)}let o=[...n];o=S.sortGraphics(o),this.gmlRender.dirtyDraw(t,o),this.contentDraw=!1});p(this,"drawInFocusMode",t=>{const e=this.gmlRender.getViewPortBounds(),n=new Set;S.getAllChildren(t,n);const o=S.sortGraphics([t,...n]);this.gmlRender.dirtyDraw(e,o),this.contentDraw=!1});p(this,"drawInPlayingMode",t=>{this.gmlRender.getViewPortBounds();const e=t.getBounds(),n=new Set;S.getAllChildren(t,n);const o=S.sortGraphics([t,...n]);this.gmlRender.dirtyDraw(e,o),this.contentDraw=!1});this.gmlRender=t,this.nodeManager=e,this.auxiliaryManager=n,this.slotManager=o}getScale(){return this.gmlRender.getScale()}zoomScale(t,e){this.zoomWorker.zoomScale(t,e,this)}zoomToFit(){this.zoomWorker.zoomToFit(this)}zoomToSelect(){this.zoomWorker.zoomToSelect(this)}zoomTo100(){this.zoomWorker.zoomTo100(this)}exportOfflineCanvas(t,e,n){return this.exportWorker.exportToOfflineCanvas(t,this.nodeManager,e,n)}scroll(t,e){this.scrollTo(t,e,this.gmlRender),this.scrollTo(t,e,this.auxiliaryManager.gmlRender),this.addContentRenderTask(),this.addAuxiliaryDrawTask()}start(){this.tickerRun()}addAuxiliaryDrawTask(){this.auxiliaryDraw=!0}addContentRenderTask(){this.contentDraw=!0}dirtyDraw(t){const e=this.nodeManager.tree.search(t),n=new Set;for(const r of e){const i=this.nodeManager.nodeMap.get(r.id);i&&n.add(i)}let o=[...n];o=S.sortGraphics(o);const s=this.judgeFocusNode();if(s){const r=new Set([s]);S.getAllChildren(s,r),o=o.filter(i=>r.has(i))}console.log("njx debug:====>",o.map(r=>r.id)),this.gmlRender.dirtyDraw(t,o)}judgeFocusNode(){if(this.focusId){const t=this.nodeManager.nodeMap.get(this.focusId);if(t)return t}return null}scrollTo(t,e,n){const o=n.getScale();n.translation(-t/o,-e/o);const s=n.glCtx,{a:r,b:i,c:a,d:c,e:h,f:d}=n.globalTransform;s.setTransform(r,i,a,c,h,d)}}const ug={default:"default"};class Oc{constructor(){p(this,"currentCursor","default");p(this,"currentAngle")}resetCursor(){this.currentCursor=null}setCursor(t,e){if(this.currentCursor!==null){const o=e!==void 0?`${t}-${e}`:t;if((this.currentAngle!==void 0?`${this.currentCursor}-${this.currentAngle}`:this.currentCursor)===o)return}if(t==="stretch"&&e!==void 0){const o=this.generateRotatedStretchCursorSvg(e),r=`url("data:image/svg+xml,${encodeURIComponent(o)}") 16 16, auto`;document.body.style.cursor=r,this.currentCursor=t,this.currentAngle=e;return}if(t==="rotate"&&e!==void 0){const o=this.generateRotatedRotateCursorSvg(e),r=`url("data:image/svg+xml,${encodeURIComponent(o)}") 16 16, auto`;document.body.style.cursor=r,this.currentCursor=t,this.currentAngle=e;return}const n=ug[t];n?document.body.style.cursor=n:document.body.style.cursor=t,this.currentCursor=t,this.currentAngle=void 0}generateRotatedStretchCursorSvg(t){return`<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32" fill="none">
|
|
2
|
+
/*$vite$:1*/`,document.head.appendChild(bn);class zl{constructor(t){p(this,"ctx");this.ctx=t,t.actionManager.addNetworkPlugin(this)}onEnable(t){return!0}}class hn{exec(t,e){const n=t.data;t.reverseLog=this.reverseLog(n,e),this.execData(n,e)}}var Xe=(l=>(l[l.Start=0]="Start",l[l.End=1]="End",l[l.AddNode=2]="AddNode",l[l.RemoveNode=3]="RemoveNode",l[l.UpdateNode=4]="UpdateNode",l[l.SelectNode=5]="SelectNode",l[l.TextFocus=6]="TextFocus",l))(Xe||{});class m{constructor(t=0,e=0){p(this,"x");p(this,"y");this.x=t,this.y=e}clone(){return new m(this.x,this.y)}}var Xr=(l=>(l.LEFT="LEFT",l.TOP="TOP",l.RIGHT="RIGHT",l.BOTTOM="BOTTOM",l))(Xr||{});class Wl extends m{constructor(e,n,o,s){super(e.x,e.y);p(this,"xPos");p(this,"yPos");p(this,"nodeSide");this.xPos=n,this.yPos=o,this.nodeSide=s}}class Fl extends m{constructor(){super(...arguments);p(this,"isHorizon",!0)}}const Mn="ROOT",zr="ROOT";var v=(l=>(l[l.Shape=0]="Shape",l[l.Line=1]="Line",l[l.SVG=2]="SVG",l[l.IMG=3]="IMG",l[l.Section=4]="Section",l[l.Group=5]="Group",l[l.Checkbox=6]="Checkbox",l[l.CheckboxText=7]="CheckboxText",l[l.SlideContainer=8]="SlideContainer",l[l.ROOT=99]="ROOT",l))(v||{}),et=(l=>(l[l.None=0]="None",l[l.Solid=1]="Solid",l[l.Dash1=2]="Dash1",l[l.Dash2=3]="Dash2",l))(et||{}),it=(l=>(l[l.None=0]="None",l[l.Arrow=1]="Arrow",l[l.Triangle=2]="Triangle",l[l.EmptyTriangle=3]="EmptyTriangle",l[l.Diamond=4]="Diamond",l[l.EmptyDiamond=5]="EmptyDiamond",l[l.Circle=6]="Circle",l[l.EmptyCircle=7]="EmptyCircle",l))(it||{}),at=(l=>(l[l.Top=0]="Top",l[l.Middle=1]="Middle",l[l.Bottom=2]="Bottom",l))(at||{}),We=(l=>(l[l.fix=0]="fix",l[l.autoHeight=1]="autoHeight",l[l.autoWidth=2]="autoWidth",l))(We||{}),I=(l=>(l[l.Base=0]="Base",l[l.Color=1]="Color",l[l.Border=2]="Border",l[l.Text=3]="Text",l[l.Shape=4]="Shape",l[l.Line=5]="Line",l[l.Arrow=6]="Arrow",l[l.Connect=7]="Connect",l[l.LineTextRect=8]="LineTextRect",l[l.Svg=9]="Svg",l[l.Image=10]="Image",l[l.Crop=11]="Crop",l[l.CheckStatus=12]="CheckStatus",l[l.CheckSize=13]="CheckSize",l[l.TextParagraph=14]="TextParagraph",l[l.TextParagraphQuote=15]="TextParagraphQuote",l[l.Slide=16]="Slide",l))(I||{});class ct{}class ro extends ct{constructor(){super(...arguments);p(this,"type",I.Image);p(this,"url","")}static from(e){const n=new ro;return n.url=e.url,n}clone(){const e=new ro;return e.url=this.url,e}update(e){const{url:n}=e;n!==void 0&&(this.url=n)}}class ie extends ct{constructor(){super(...arguments);p(this,"type",I.Base);p(this,"x",0);p(this,"y",0);p(this,"width",100);p(this,"height",100);p(this,"angle",0)}static create(e){const n=new ie;return n.update(e),n}static from(e){const n=new ie;return n.x=e.x,n.y=e.y,n.width=e.width,n.height=e.height,n.angle=e.angle,n}update(e){const{x:n,y:o,height:s,width:r,angle:i}=e;n!==void 0&&(this.x=n),o!==void 0&&(this.y=o),s!==void 0&&(this.height=s),r!==void 0&&(this.width=r),i!==void 0&&(this.angle=i)}clone(){const e=new ie;return e.x=this.x,e.y=this.y,e.width=this.width,e.height=this.height,e.angle=this.angle,e}}class Ae extends ct{constructor(){super(...arguments);p(this,"type",I.Border);p(this,"color","#000000");p(this,"alpha",1);p(this,"width",2);p(this,"dashType",et.Solid)}static create(e){const n=new Ae;return n.update(e),n}static from(e){const n=new Ae;return n.color=e.color,n.alpha=e.alpha,n.width=e.width,n.dashType=e.dashType,n}update(e){const{color:n,alpha:o,width:s,dashType:r}=e;n!==void 0&&(this.color=n),o!==void 0&&(this.alpha=o),s!==void 0&&(this.width=s),r!==void 0&&(this.dashType=r)}clone(){const e=new Ae;return e.color=this.color,e.alpha=this.alpha,e.width=this.width,e.dashType=this.dashType,e}}class re{constructor(){p(this,"a",1);p(this,"b",0);p(this,"c",0);p(this,"d",1);p(this,"e",0);p(this,"f",0)}static generateMatrix(){return new re}setTransform(t,e,n,o,s,r){this.a=t,this.b=e,this.c=n,this.d=o,this.e=s,this.f=r}rotate(t){const e=t/180*Math.PI;return this.rotate2(e),this}rotate2(t){return this.a=Math.cos(t),this.c=-Math.sin(t),this.b=Math.sin(t),this.d=Math.cos(t),this}scale(t,e){return this.a=t,this.d=e,this}translate(t,e){return this.e=t,this.f=e,this}crossProduct(t){const e=new re;return e.a=this.a*t.a+this.c*t.b,e.b=this.b*t.a+this.d*t.b,e.c=this.a*t.c+this.c*t.d,e.d=this.b*t.c+this.d*t.d,e.e=this.a*t.e+this.c*t.f+this.e,e.f=this.b*t.e+this.d*t.f+this.f,e}crossPoint(t){return new m(this.a*t.x+this.c*t.y+this.e,this.b*t.x+this.d*t.y+this.f)}inverseMatrix(){const{a:t,b:e,c:n,d:o,e:s,f:r}=this,i=t*o-e*n;if(Math.abs(i)<1e-4)throw new Error("该仿射变换不可逆");const a=o/i,c=-e/i,h=-n/i,d=t/i,u=(n*r-o*s)/i,g=(e*s-t*r)/i,f=re.generateMatrix();return f.a=a,f.b=c,f.c=h,f.d=d,f.e=u,f.f=g,f}clone(){const t=new re;return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.e=this.e,t.f=this.f,t}}class Yl{constructor(t,e,n){p(this,"p0");p(this,"p1");p(this,"p2");this.p0=t,this.p1=e,this.p2=n}xStationaryPoint(){return(this.p0.x-this.p1.x)/(this.p0.x-2*this.p1.x+this.p2.x)}dxdt(t){return 2*t*(this.p0.x-2*this.p1.x+this.p2.x)-2*(this.p0.x-this.p1.x)}xValue(t){const e=1-t;return e*e*this.p0.x+2*t*e*this.p1.x+t*t*this.p2.x}yValue(t){const e=1-t;return e*e*this.p0.y+2*t*e*this.p1.y+t*t*this.p2.y}newtonSolveX(t,e,n){let s=.5*(e+n),r=0;for(;;){r++;const i=this.xValue(s)-t,a=this.dxdt(s),c=s-i/a;if(Math.abs(c-s)<.01)return c;if(r>20)return null;s=c}return null}solve(t,e=6){const n=this.xStationaryPoint();if(n<0||n>1)return this.monotonicSolve(t,0,1,e);let o=this.monotonicSolve(t,0,n,e);return o?!0:(o=this.monotonicSolve(t,n,1,e),o)}monotonicSolve(t,e,n,o){const s=this.xValue(e),r=this.xValue(n),i=t.x,a=t.y;if((i-s)*(i-r)>0)return!1;const c=this.newtonSolveX(i,e,n);return c===null?(console.warn("newton 迭代求解贝塞尔曲线出错."),!1):Math.abs(a-this.yValue(c))<o}}class Bo{constructor(t){p(this,"prev",null);p(this,"next",null);p(this,"data",null);this.data=t}breakOff(){this.prev=null,this.next=null}toString(){return this.data?this.data.toString():""}add(t){const e=this.next;this.next=t,t.prev=this,t.next=e,e&&(e.prev=t)}pushAdd(t){this.next=t,t.prev=this}removeSelf(){const t=this.next,e=this.prev;this.next=null,this.prev=null,t.prev=e,e.next=t}getIndex(){let t=this.prev,e=0;for(;t&&t.data;)e++,t=t.prev;return e}static generateLink(){const t=new Bo(null),e=new Bo(null);return t.add(e),t}}class D{constructor(t=0,e=0,n=100,o=100){p(this,"x");p(this,"y");p(this,"width");p(this,"height");this.x=t,this.y=e,this.width=n,this.height=o}clone(){return new D(this.x,this.y,this.width,this.height)}static baseProps2Rect(t){const{x:e,y:n,width:o,height:s}=t;return new D(e,n,o,s)}static rectNode2Rect(t){const{minY:e,minX:n,maxY:o,maxX:s}=t;return new D(n,e,s-n,o-e)}static toRectNode(t){const{x:e,y:n,width:o,height:s}=t;return{minX:e,minY:n,maxX:e+o,maxY:n+s}}}var zn=(l=>(l[l.Image=0]="Image",l[l.SVG=1]="SVG",l))(zn||{});class Ke{constructor(){p(this,"result",null)}detect(t,e){return this.result?!0:this.onDetect(t,e)}reset(){this.result=null}}var F=(l=>(l[l.Node=0]="Node",l[l.Stretch=1]="Stretch",l[l.HoverNode=2]="HoverNode",l[l.ParagraphHead=3]="ParagraphHead",l[l.PolyControlPoint=4]="PolyControlPoint",l[l.CurveControlPoint=5]="CurveControlPoint",l[l.LineEndPoint=6]="LineEndPoint",l[l.ConnectorPoint=7]="ConnectorPoint",l[l.Rotate=8]="Rotate",l[l.SingleStretch=9]="SingleStretch",l[l.ExpandShape=10]="ExpandShape",l[l.NodeEdge=11]="NodeEdge",l[l.BufferNode=12]="BufferNode",l[l.BufferHoverNode=13]="BufferHoverNode",l[l.HoverNodeAnchor=14]="HoverNodeAnchor",l[l.HoverConnectAnchor=15]="HoverConnectAnchor",l[l.HoverOnContainer=16]="HoverOnContainer",l[l.Image=17]="Image",l[l.ImageOriginBounds=18]="ImageOriginBounds",l[l.CurveEndPoint=19]="CurveEndPoint",l[l.DragLineText=20]="DragLineText",l[l.SlideGap=21]="SlideGap",l[l.EmptySlideContainer=22]="EmptySlideContainer",l))(F||{}),be=(l=>(l.pointerDown="pointerdown",l.pointermove="pointermove",l.pointermoveOutside="pointermoveOutside",l.pointerup="pointerup",l.unknown="unknown",l))(be||{}),V=(l=>(l[l.TOP=0]="TOP",l[l.LEFT=1]="LEFT",l[l.BOTTOM=2]="BOTTOM",l[l.RIGHT=3]="RIGHT",l[l.TOP_LEFT=4]="TOP_LEFT",l[l.TOP_RIGHT=5]="TOP_RIGHT",l[l.BOTTOM_LEFT=6]="BOTTOM_LEFT",l[l.BOTTOM_RIGHT=7]="BOTTOM_RIGHT",l))(V||{});class tt extends ct{constructor(){super(...arguments);p(this,"type",I.Color);p(this,"color","#ffccff");p(this,"alpha",1)}static create(e){const n=new tt;return n.update(e),n}static from(e){const n=new tt;return n.color=e.color,n.alpha=e.alpha,n}update(e){const{color:n,alpha:o}=e;n!==void 0&&(this.color=n),o!==void 0&&(this.alpha=o)}clone(){const e=new tt;return e.color=this.color,e.alpha=this.alpha,e}}class Ge extends ct{constructor(){super(...arguments);p(this,"type",I.Text);p(this,"text","");p(this,"richText","");p(this,"fontSize",14);p(this,"fontFamily","Noto Sans");p(this,"fontColor","#000000");p(this,"fontBgColor","");p(this,"bold",!1);p(this,"italic",!1);p(this,"underline",!1);p(this,"strikethrough",!1);p(this,"verticalAlign",at.Middle);p(this,"horizonAlign",at.Middle);p(this,"sizeMode",We.fix)}static create(e){const n=new Ge;return n.update(e),n}static from(e){const n=new Ge;return n.text=e.text,n.fontSize=e.fontSize,n.fontFamily=e.fontFamily,n.fontColor=e.fontColor,n.fontBgColor=e.fontBgColor,n.bold=e.bold,n.italic=e.italic,n.underline=e.underline,n.strikethrough=e.strikethrough,n.verticalAlign=e.verticalAlign,n.horizonAlign=e.horizonAlign,n.sizeMode=e.sizeMode,n.richText=e.richText,!e.richText&&e.text&&(n.richText=this.dealTextToRichText(e.text)),n}update(e){const{sizeMode:n,verticalAlign:o,horizonAlign:s,fontFamily:r,fontSize:i,text:a,bold:c,italic:h,fontColor:d,fontBgColor:u,underline:g,strikethrough:f,richText:y}=e;a!==void 0&&(this.text=a),r!==void 0&&(this.fontFamily=r),i!==void 0&&(this.fontSize=i),d!==void 0&&(this.fontColor=d),u!==void 0&&(this.fontBgColor=u.trim()),c!==void 0&&(this.bold=c),h!==void 0&&(this.italic=h),g!==void 0&&(this.underline=g),f!==void 0&&(this.strikethrough=f),o!==void 0&&(this.verticalAlign=o),s!==void 0&&(this.horizonAlign=s),n!==void 0&&(this.sizeMode=n),y!==void 0&&(this.richText=y)}clone(){const e=new Ge;return e.text=this.text,e.fontFamily=this.fontFamily,e.fontSize=this.fontSize,e.fontColor=this.fontColor,e.fontBgColor=this.fontBgColor,e.bold=this.bold,e.italic=this.italic,e.underline=this.underline,e.strikethrough=this.strikethrough,e.horizonAlign=this.horizonAlign,e.verticalAlign=this.verticalAlign,e.sizeMode=this.sizeMode,e.richText=this.richText,e}static dealTextToRichText(e){const n=e.split(`
|
|
3
|
+
`);let o="<root>";for(const s of n)o=o+"<p>"+s+"</p>";return o+="</root>",o}}class Oe extends ct{constructor(e=1){super();p(this,"type",I.Shape);p(this,"shapeCode",1);this.shapeCode=e}static from(e){const n=new Oe;return n.shapeCode=e.shapeCode,n}update(e){const{shapeCode:n}=e;n!==void 0&&(this.shapeCode=n)}clone(){const e=new Oe;return e.shapeCode=this.shapeCode,e}}class je extends ct{constructor(){super(...arguments);p(this,"type",I.Line);p(this,"points",[]);p(this,"auto",!0)}static create(e,n=!0){const o=new je;return o.auto=n,o.points=e,o}static from(e){const n=new je;return n.points=e.points,n.auto=e.auto,n}clone(){const e=new je,n=[];for(const o of this.points)n.push(M.cloneIPoint(o));return e.points=n,e.auto=this.auto,e}update(e){const{points:n,auto:o}=e;n!==void 0&&(this.points=n),o!==void 0&&(this.auto=o)}}class Rt extends ct{constructor(){super(...arguments);p(this,"type",I.Connect);p(this,"start",null);p(this,"end",null)}static from(e){const n=new Rt;return n.start=e.start,n.end=e.end,n}clone(){const e=new Rt;return e.start=this.start,e.end=this.end,e}update(e){const{start:n,end:o}=e;n!==void 0&&(this.start=n),o!==void 0&&(this.end=o)}}class lt extends ct{constructor(){super(...arguments);p(this,"type",I.Arrow);p(this,"lArrow",it.None);p(this,"rArrow",it.None)}static create(e){const n=new lt;return n.update(e),n}static from(e){const n=new lt;return n.lArrow=e.lArrow,n.rArrow=e.rArrow,n}clone(){const e=new lt;return e.rArrow=this.rArrow,e.lArrow=this.lArrow,e}update(e){const{lArrow:n,rArrow:o}=e;n!==void 0&&(this.lArrow=n),o!==void 0&&(this.rArrow=o)}}var ue=(l=>(l[l.Top=0]="Top",l[l.Right=1]="Right",l[l.Bottom=2]="Bottom",l[l.Left=3]="Left",l))(ue||{});class Et extends ct{constructor(){super(...arguments);p(this,"type",I.LineTextRect);p(this,"width",20);p(this,"height",20);p(this,"x",0);p(this,"y",0);p(this,"point",{x:0,y:0})}static from(e){const n=new Et;return n.width=e.width,n.height=e.height,n.x=e.x,n.y=e.y,n.point=e.point,n}update(e){const{x:n,y:o,point:s,height:r,width:i}=e;n!==void 0&&(this.x=n),o!==void 0&&(this.y=o),r!==void 0&&(this.height=r),i!==void 0&&(this.width=i),s!==void 0&&(this.point=s)}clone(){const e=new Et;return e.width=this.width,e.height=this.height,e.x=this.x,e.y=this.y,e.point=this.point,e}}var N=(l=>(l[l.HoverBounds=0]="HoverBounds",l[l.HoverLine=1]="HoverLine",l[l.SelectLine=2]="SelectLine",l[l.MultiSelectBound=3]="MultiSelectBound",l[l.TextSelection=4]="TextSelection",l[l.SelectGroup=5]="SelectGroup",l[l.SelectRect=6]="SelectRect",l[l.HighLightLine=7]="HighLightLine",l[l.AlignLine=8]="AlignLine",l[l.AlignStretchLine=9]="AlignStretchLine",l[l.SingleSelectBound=10]="SingleSelectBound",l[l.RotateLine=11]="RotateLine",l[l.HighlightRects=12]="HighlightRects",l[l.CreateRectBound=13]="CreateRectBound",l[l.ExpandShape=14]="ExpandShape",l[l.SelectLineEnd=15]="SelectLineEnd",l[l.HoverConnectPoint=16]="HoverConnectPoint",l[l.HoverConnectAnchorPoint=17]="HoverConnectAnchorPoint",l[l.HoverAnchorPoint=18]="HoverAnchorPoint",l[l.SelectPolyLineControlPoint=19]="SelectPolyLineControlPoint",l[l.SelectLineTextRect=20]="SelectLineTextRect",l[l.PlaceHolder=21]="PlaceHolder",l[l.SelectConnectAnchor=22]="SelectConnectAnchor",l[l.HoverConnectAnchor=23]="HoverConnectAnchor",l[l.PreviewGraphics=24]="PreviewGraphics",l[l.HoverContainer=25]="HoverContainer",l[l.CropBounds=26]="CropBounds",l[l.CropOriginImg=27]="CropOriginImg",l[l.StretchRect=28]="StretchRect",l[l.HoverSize=29]="HoverSize",l[l.SelectCurveControlPoint=30]="SelectCurveControlPoint",l[l.SelectCurveEnd=31]="SelectCurveEnd",l[l.SelectParentGroupBound=32]="SelectParentGroupBound",l[l.SelectSlideGapInsertPoint=33]="SelectSlideGapInsertPoint",l[l.HoverSlidePlaceHolder=34]="HoverSlidePlaceHolder",l[l.HoverInsertSlide=35]="HoverInsertSlide",l[l.HoverInsertHorizonSlide=36]="HoverInsertHorizonSlide",l[l.HoverSlideGapInsertPoint=37]="HoverSlideGapInsertPoint",l[l.HoverFocusCopy=38]="HoverFocusCopy",l))(N||{});class Se{constructor(){p(this,"prop")}update(t){this.prop=t}}const Ht="#FFFFFF",bs="#000000",Gt="#647ee5",Qe="#545DE7",Ms="#32a8f2",Wr="#3370FF",Fr=8,Yr=18,Gr=5,Ss=11,Ur="#CCCCCC",_r="#B7BEF5",$r="#DADEFA";class jr extends Se{constructor(){super(...arguments);p(this,"auxiliaryType",N.HoverBounds)}draw(e,n){const{node:o,transform:s}=this.prop;e.save(),e.strokeStyle=Gt,e.lineWidth=2/n,e.globalAlpha=1;const{x:r,y:i,width:a,height:c}=o.baseProps,{a:h,b:d,c:u,d:g,e:f,f:y}=s;e.transform(h,d,u,g,f,y),e.beginPath(),e.strokeRect(0,0,a,c),e.restore()}}class Vr extends Se{constructor(){super(...arguments);p(this,"auxiliaryType",N.SingleSelectBound)}draw(e,n){const{x:o,y:s,width:r,height:i,transform:a}=this.prop;e.save(),e.strokeStyle=Qe,e.lineWidth=1/n,e.globalAlpha=1;const{a:c,b:h,c:d,d:u,e:g,f}=a;e.transform(c,h,d,u,g,f),e.beginPath(),e.strokeRect(o,s,r,i),e.restore()}}class Kr extends Se{constructor(){super(...arguments);p(this,"auxiliaryType",N.MultiSelectBound)}draw(e,n){const{rect:o}=this.prop;e.save(),e.strokeStyle=Qe,e.lineWidth=1/n,e.globalAlpha=1;const{x:s,y:r,width:i,height:a}=o;e.beginPath(),e.strokeRect(s,r,i,a),e.restore()}}class Qr extends Se{constructor(){super(...arguments);p(this,"auxiliaryType",N.HighlightRects)}draw(e,n){const{rects:o}=this.prop;for(const s of o){e.save(),e.strokeStyle=Qe,e.lineWidth=1/n,e.globalAlpha=1;const{x:r,y:i,width:a,height:c}=s;e.beginPath(),e.strokeRect(r,i,a,c),e.restore()}}}class Zr extends Se{constructor(){super(...arguments);p(this,"auxiliaryType",N.SelectGroup)}draw(e,n){const{rect:o,isPrecise:s}=this.prop;e.save(),e.beginPath(),e.strokeStyle=Ms,e.fillStyle=Ms,s&&e.setLineDash([2,2]),e.rect(o.x,o.y,o.width,o.height),e.lineWidth=1/n,e.stroke(),e.globalAlpha=.2,e.fill(),e.restore()}}class qr extends Se{constructor(){super(...arguments);p(this,"auxiliaryType",N.TextSelection)}draw(e){const{selectionList:n,node:o}=this.prop;if(n.length===0)return;e.save(),e.fillStyle=Wr,e.globalAlpha=.5;const{a:s,b:r,c:i,d:a,e:c,f:h}=o.globalTransform();e.transform(s,r,i,a,c,h);for(const d of n)e.fillRect(d.x,d.y,d.width,d.height);e.restore()}}class Jr{static computeStretchRects(t,e){const n=Fr/e,o=.5*n;return[new D(t.x-o,t.y-o,n,n),new D(t.x+t.width-o,t.y-o,n,n),new D(t.x+t.width-o,t.y+t.height-o,n,n),new D(t.x-o,t.y+t.height-o,n,n)]}}class ei extends Se{constructor(){super(...arguments);p(this,"auxiliaryType",N.StretchRect)}draw(e,n){const{rect:o,transform:s}=this.prop,r=Jr.computeStretchRects(o,n);e.save();const{a:i,b:a,c,d:h,e:d,f:u}=s;e.transform(i,a,c,h,d,u),e.strokeStyle=Qe,e.fillStyle=Ht,e.lineWidth=1/n,e.globalAlpha=1,e.beginPath();for(const g of r)e.roundRect(g.x,g.y,g.width,g.height,1/n),e.fill(),e.stroke();e.restore()}}class ti extends Se{constructor(){super(...arguments);p(this,"auxiliaryType",N.CreateRectBound)}draw(e,n){const{rect:o,transform:s}=this.prop;e.save();const{a:r,b:i,c:a,d:c,e:h,f:d}=s;e.transform(r,i,a,c,h,d),e.strokeStyle=Qe,e.lineWidth=1/n,e.globalAlpha=1;const{width:u,height:g}=o;e.beginPath(),e.strokeRect(0,0,u,g),e.restore()}}class ni extends Se{constructor(){super(...arguments);p(this,"auxiliaryType",N.ExpandShape)}draw(e,n){const{rect:o,transform:s}=this.prop,{width:r,height:i}=o,a=1.5/n,c=re.generateMatrix().scale(a,a),h=re.generateMatrix().translate(.5*r-.5*a*14,i-.5*a*8),d=s.crossProduct(h.crossProduct(c));e.save(),e.beginPath();const{a:u,b:g,c:f,d:y,e:P,f:b}=d;e.transform(u,g,f,y,P,b),e.fillStyle=Qe,e.roundRect(0,0,14,7.58333,2),e.fill(),e.beginPath(),e.fillStyle=Ht,e.rect(1.75,2.91666,2.33333,2.33333),e.rect(5.83333,2.91666,2.33333,2.33333),e.rect(9.91667,2.91666,2.33333,2.33333),e.fill(),e.restore()}}class oi extends Se{constructor(){super(...arguments);p(this,"auxiliaryType",N.AlignLine)}draw(e,n){const{lines:o}=this.prop;e.save(),e.beginPath(),e.strokeStyle=Qe,e.lineWidth=1/n,e.globalAlpha=1,e.setLineDash([4,2]);for(const s of o){const{start:r,end:i}=s;e.moveTo(r.x,r.y),e.lineTo(i.x,i.y)}e.stroke(),e.restore()}}class si extends Se{constructor(){super(...arguments);p(this,"auxiliaryType",N.AlignStretchLine)}draw(e,n){const o=10/n,{alignInfo:s}=this.prop,{width:r,height:i}=s;e.save(),e.beginPath(),e.strokeStyle=Qe,e.lineWidth=1/n,e.globalAlpha=1,r&&this.drawWidth(e,r,o),i&&this.drawHeight(e,i,o),e.restore()}drawWidth(e,n,o){const{lines:s}=n;for(const r of s){const{line:i,transform:a}=r,{start:c,end:h}=i;e.save();const{a:d,b:u,c:g,d:f,e:y,f:P}=a;e.transform(d,u,g,f,y,P);const b={x:c.x,y:c.y},w={x:c.x,y:c.y+2*o};e.moveTo(b.x,b.y),e.lineTo(w.x,w.y);const L={x:h.x,y:h.y},B={x:h.x,y:h.y+2*o};e.moveTo(L.x,L.y),e.lineTo(B.x,B.y),e.moveTo(c.x,c.y+o),e.lineTo(h.x,h.y+o),e.stroke(),e.restore()}}drawHeight(e,n,o){const{lines:s}=n;for(const r of s){const{line:i,transform:a}=r,{start:c,end:h}=i;e.save();const{a:d,b:u,c:g,d:f,e:y,f:P}=a;e.transform(d,u,g,f,y,P);const b={x:c.x,y:c.y},w={x:c.x+2*o,y:c.y};e.moveTo(b.x,b.y),e.lineTo(w.x,w.y);const L={x:h.x,y:h.y},B={x:h.x+2*o,y:h.y};e.moveTo(L.x,L.y),e.lineTo(B.x,B.y),e.moveTo(c.x+o,c.y),e.lineTo(h.x+o,h.y),e.stroke(),e.restore()}}}class Gl extends Se{constructor(){super(...arguments);p(this,"auxiliaryType",N.SingleSelectBound)}draw(e,n){const{start:o,end:s,transform:r}=this.prop,i=5/n;e.save();const{a,b:c,c:h,d,e:u,f:g}=r;e.transform(a,c,h,d,u,g),e.strokeStyle=Qe,e.fillStyle=Ht,e.lineWidth=2/n,e.globalAlpha=1,e.beginPath(),e.arc(o.x,o.y,i,0,2*Math.PI),e.fill(),e.stroke(),e.beginPath(),e.arc(s.x,s.y,i,0,2*Math.PI),e.fill(),e.stroke(),e.restore()}}class Ul extends Se{constructor(){super(...arguments);p(this,"auxiliaryType",N.HoverLine)}draw(e,n){const{node:o,transform:s}=this.prop;e.save();const{a:r,b:i,c:a,d:c,e:h,f:d}=s;e.transform(r,i,a,c,h,d),e.strokeStyle=Gt,e.lineWidth=2/n,e.globalAlpha=1,e.beginPath(),o.drawer.draw(o,e),e.restore()}}class _l extends Se{constructor(){super(...arguments);p(this,"auxiliaryType",N.SelectLine)}draw(e,n){const{node:o}=this.prop;e.save();const{a:s,b:r,c:i,d:a,e:c,f:h}=o.globalTransform();e.transform(s,r,i,a,c,h),e.strokeStyle=Qe,e.lineWidth=2/n,e.globalAlpha=1,e.beginPath(),o.drawer.draw(o,e),e.restore()}}class $l extends Se{constructor(){super(...arguments);p(this,"auxiliaryType",N.HoverConnectPoint)}draw(e,n){const{point:o}=this.prop,s=4/n;e.save(),e.fillStyle=Gt,e.strokeStyle=Gt,e.lineWidth=2/n,e.globalAlpha=1,e.beginPath(),e.arc(o.x,o.y,s,0,2*Math.PI),e.fill(),e.restore()}}class jl extends Se{constructor(){super(...arguments);p(this,"auxiliaryType",N.HoverConnectAnchorPoint)}draw(e,n){const{node:o}=this.prop;if(!o.canQuickCreate())return;const s=5/n,{width:r,height:i}=o.baseProps,{a,b:c,c:h,d,e:u,f:g}=o.globalTransform(),f=o.getConnectAnchor(),y=[];for(const P of f)y.push(new m(P.x*r,P.y*i));e.save(),e.transform(a,c,h,d,u,g),e.fillStyle=Ht,e.strokeStyle=Qe;for(const P of y)e.beginPath(),e.arc(P.x,P.y,s,0,2*Math.PI),e.fill(),e.stroke();e.restore()}}class Vl extends Se{constructor(){super(...arguments);p(this,"auxiliaryType",N.HoverConnectAnchorPoint)}draw(e,n){const{node:o,localPoint:s}=this.prop;if(!o.canBeConnected())return;const r=6/n,{a:i,b:a,c,d:h,e:d,f:u}=o.globalTransform();e.save(),e.transform(i,a,c,h,d,u),e.fillStyle=Gt,e.beginPath(),e.arc(s.x,s.y,r,0,2*Math.PI),e.fill(),e.stroke(),e.restore()}}const A=22;class Kl extends Se{constructor(){super(...arguments);p(this,"auxiliaryType",N.SelectPolyLineControlPoint)}draw(e,n){const{points:o,transform:s}=this.prop;e.save(),e.fillStyle=Qe,e.strokeStyle=Ht,e.lineWidth=2/n,e.globalAlpha=1;const{a:r,b:i,c:a,d:c,e:h,f:d}=s;e.transform(r,i,a,c,h,d);for(let u=0;u<o.length-1;u++){const g=o[u],f=o[u+1];if(M.distance(g,f)<(A+6)/n)continue;const P=M.judgeHorizon(g,f),b=.5*(g.x+f.x),w=.5*(g.y+f.y);if(e.beginPath(),P){const L=new m(b-6/n,w);e.roundRect(L.x,L.y-2/n,12/n,4/n,2/n)}else{const L=new m(b,w-6/n);e.roundRect(L.x-2/n,L.y,4/n,12/n,2/n)}e.stroke(),e.fill()}e.restore()}}class Ql extends Se{constructor(){super(...arguments);p(this,"auxiliaryType",N.SelectLineTextRect)}draw(e,n){const{node:s,transform:r}=this.prop,i=s.getTextContentRect();e.save();const{a,b:c,c:h,d,e:u,f:g}=r;e.transform(a,c,h,d,u,g),e.strokeStyle=Qe,e.lineWidth=2/n,e.globalAlpha=1,e.beginPath(),e.strokeRect(i.x-2,i.y-2,i.width+2*2,i.height+2*2),e.restore()}}const ri="输入文本";class Zl extends Se{constructor(){super(...arguments);p(this,"auxiliaryType",N.PlaceHolder)}draw(e,n){const{node:o}=this.prop,s=o.shapeType!==K.PureText,r=o.renderText,i=r.paragraphs[0],a=i.lines[0],c=r.x+i.x+a.x,h=r.y+i.y+a.y,{fontSize:d,fontFamily:u,bold:g,italic:f}=r.textProps;e.save();const{a:y,b:P,c:b,d:w,e:L,f:B}=o.globalTransform();e.transform(y,P,b,w,L,B),e.textAlign="left",e.textBaseline="alphabetic",e.fillStyle="#000000",e.globalAlpha=.5,e.font=M.calcFont(d,u,g,f);const H=e.measureText(ri),E=H.fontBoundingBoxAscent,X=H.width,$=s?c-.5*X:c;e.fillText(ri,$,h+E),e.restore()}}class ql extends Se{constructor(){super(...arguments);p(this,"auxiliaryType",N.SelectConnectAnchor)}draw(e,n){const{node:o}=this.prop,s=Gr/n,r=M.computeNodeConnectAnchor(o,n);e.save(),e.fillStyle=_r,e.globalAlpha=1;const{a:i,b:a,c,d:h,e:d,f:u}=o.globalTransform();e.transform(i,a,c,h,d,u);for(const g of r)e.beginPath(),e.arc(g.x,g.y,s,0,2*Math.PI),e.fill();e.restore()}}class Jl extends Se{constructor(){super(...arguments);p(this,"auxiliaryType",N.HoverConnectAnchor)}draw(e,n){const{point:o}=this.prop,s=Ss/n;e.save(),e.strokeStyle=Qe,e.fillStyle=$r,e.globalAlpha=1,e.lineWidth=2/n,e.beginPath(),e.arc(o.x,o.y,s,0,2*Math.PI),e.fill(),e.stroke(),e.restore()}}class eh extends Se{constructor(){super(...arguments);p(this,"auxiliaryType",N.PreviewGraphics)}draw(e,n){const{previewNodes:o}=this.prop;for(const s of o)s.drawOnGLCtx(e)}}class th extends Se{constructor(){super(...arguments);p(this,"auxiliaryType",N.HoverContainer)}draw(e,n){const{node:o}=this.prop;e.save(),e.strokeStyle=Gt,e.lineWidth=2/n,e.globalAlpha=1;const{width:s,height:r}=o.baseProps,{a:i,b:a,c,d:h,e:d,f:u}=o.globalTransform();e.transform(i,a,c,h,d,u),e.beginPath(),e.strokeRect(0,0,s,r),e.restore()}}class nh extends Se{constructor(){super(...arguments);p(this,"auxiliaryType",N.CropBounds)}draw(e,n){const{node:o,transform:s}=this.prop,r=12/n;e.save(),e.strokeStyle=bs,e.lineWidth=2/n,e.globalAlpha=1;const{width:i,height:a}=o.baseProps,{a:c,b:h,c:d,d:u,e:g,f}=s;e.transform(c,h,d,u,g,f),e.beginPath(),e.moveTo(0,r),e.lineTo(0,0),e.lineTo(r,0),e.moveTo(i-r,0),e.lineTo(i,0),e.lineTo(i,r),e.moveTo(i-r,a),e.lineTo(i,a),e.lineTo(i,a-r),e.moveTo(0,a-r),e.lineTo(0,a),e.lineTo(r,a),e.moveTo(.5*i-.5*r,0),e.lineTo(.5*i+.5*r,0),e.moveTo(.5*i-.5*r,a),e.lineTo(.5*i+.5*r,a),e.moveTo(0,.5*a-.5*r),e.lineTo(0,.5*a+.5*r),e.moveTo(i,.5*a-.5*r),e.lineTo(i,.5*a+.5*r),e.stroke(),e.beginPath(),e.setLineDash([2,2]),e.lineWidth=1/n,e.strokeRect(0,0,i,a),e.restore()}}class oh extends Se{constructor(){super(...arguments);p(this,"auxiliaryType",N.CropOriginImg)}draw(e,n){const{imgBitmap:o,transform:s,x:r,y:i,width:a,height:c}=this.prop;e.save();const{a:h,b:d,c:u,d:g,e:f,f:y}=s;e.transform(h,d,u,g,f,y),e.globalAlpha=.4,e.drawImage(o,r,i,a,c),e.restore()}}class sh extends Se{constructor(){super(...arguments);p(this,"auxiliaryType",N.HoverSize)}draw(e,n){const{rect:o,transform:s}=this.prop,{width:r,height:i}=o,a=Math.round(r),c=Math.round(i),h=`${a}x${c}`,d=12/n,u="Noto Sans",g=M.measureTextByFont(e,h,d,"Noto Sans",!1,!1);e.save();const f=re.generateMatrix().translate(r-g.width,i),{a:y,b:P,c:b,d:w,e:L,f:B}=s.crossProduct(f);e.transform(y,P,b,w,L,B),e.fillStyle=Qe,e.globalAlpha=1,e.fillRect(0,0,g.width,g.height),e.fillStyle=Ht,e.font=M.calcFont(d,u),e.textAlign="left",e.textBaseline="top",e.fillText(h,0,2/n),e.restore()}}class rh extends Se{constructor(){super(...arguments);p(this,"auxiliaryType",N.SingleSelectBound)}draw(e,n){const{points:o,transform:s}=this.prop,r=5/n;e.save();const{a:i,b:a,c,d:h,e:d,f:u}=s;e.transform(i,a,c,h,d,u),e.strokeStyle=Qe,e.fillStyle=Qe,e.lineWidth=2/n,e.globalAlpha=1;for(const g of o)e.beginPath(),e.arc(g.x,g.y,r,0,2*Math.PI),e.fill(),e.stroke();e.restore()}}class ih extends Se{constructor(){super(...arguments);p(this,"auxiliaryType",N.SelectCurveEnd)}draw(e,n){const{points:o,transform:s}=this.prop,r=5/n;e.save();const{a:i,b:a,c,d:h,e:d,f:u}=s;e.transform(i,a,c,h,d,u),e.strokeStyle=Qe,e.fillStyle=Ht,e.lineWidth=2/n,e.globalAlpha=1;for(const g of o)e.beginPath(),e.arc(g.x,g.y,r,0,2*Math.PI),e.fill(),e.stroke();e.restore()}}class ah extends Se{constructor(){super(...arguments);p(this,"auxiliaryType",N.SelectParentGroupBound)}draw(e,n){const{node:o}=this.prop;e.save(),e.strokeStyle=Gt,e.lineWidth=1/n,e.globalAlpha=1;const{width:s,height:r}=o.baseProps,{a:i,b:a,c,d:h,e:d,f:u}=o.nameGlobalTransform();e.transform(i,a,c,h,d,u),e.beginPath(),e.strokeRect(0,0,s,r),e.restore()}}class ch extends Se{constructor(){super(...arguments);p(this,"auxiliaryType",N.HoverSlidePlaceHolder)}draw(e,n){const{baseProps:o}=this.prop;e.save(),e.fillStyle=Ur,e.lineWidth=2/n,e.globalAlpha=.5;const{x:s,y:r,width:i,height:a}=o;e.beginPath(),e.roundRect(s,r,i,a,10),e.fill(),e.restore()}}class lh extends Se{constructor(){super(...arguments);p(this,"auxiliaryType",N.HoverFocusCopy)}draw(e,n){const{nodes:o}=this.prop;e.save();for(const s of o)s.drawOnGLCtx(e);e.restore()}}class hh extends Se{constructor(){super(...arguments);p(this,"auxiliaryType",N.HoverInsertSlide)}draw(e,n){const{x:o,y1:s,y0:r}=this.prop;e.save(),e.strokeStyle=Gt,e.lineWidth=2/n,e.globalAlpha=1,e.moveTo(o,r),e.lineTo(o,s),e.stroke(),e.restore()}}class dh extends Se{constructor(){super(...arguments);p(this,"auxiliaryType",N.HoverInsertHorizonSlide)}draw(e,n){const{x0:o,x1:s,y:r}=this.prop;e.save(),e.strokeStyle=Gt,e.lineWidth=2/n,e.globalAlpha=1,e.moveTo(o,r),e.lineTo(s,r),e.stroke(),e.restore()}}class uh extends Se{constructor(){super(...arguments);p(this,"auxiliaryType",N.HoverSlideGapInsertPoint)}draw(e,n){const{point:o}=this.prop,s=10/n;e.save(),e.fillStyle=Qe,e.globalAlpha=1,e.beginPath(),e.arc(o.x,o.y,s,0,2*Math.PI),e.fill();const r=6/n;e.strokeStyle=Ht,e.lineWidth=2.5/n,e.lineCap="square",e.beginPath(),e.moveTo(o.x-r,o.y),e.lineTo(o.x+r,o.y),e.moveTo(o.x,o.y-r),e.lineTo(o.x,o.y+r),e.stroke(),e.restore()}}class ph extends Se{constructor(){super(...arguments);p(this,"auxiliaryType",N.SelectSlideGapInsertPoint)}draw(e,n){const{points:o}=this.prop,s=6/n;e.save(),e.fillStyle=Qe,e.globalAlpha=.9,e.beginPath();for(const r of o){e.beginPath(),e.arc(r.x,r.y,s,0,2*Math.PI),e.fill();const i=3.6/n;e.strokeStyle=Ht,e.lineWidth=1.5/n,e.lineCap="square",e.beginPath(),e.moveTo(r.x-i,r.y),e.lineTo(r.x+i,r.y),e.moveTo(r.x,r.y-i),e.lineTo(r.x,r.y+i),e.stroke()}e.restore()}}class vs{static create(t){const e=this.constructorMap[t];return e?new e:(console.error("缺少对应构造函数"),null)}}p(vs,"constructorMap",{[N.HoverBounds]:jr,[N.SingleSelectBound]:Vr,[N.MultiSelectBound]:Kr,[N.HighlightRects]:Qr,[N.SelectGroup]:Zr,[N.TextSelection]:qr,[N.StretchRect]:ei,[N.CreateRectBound]:ti,[N.ExpandShape]:ni,[N.AlignLine]:oi,[N.AlignStretchLine]:si,[N.SelectLineEnd]:Gl,[N.HoverLine]:Ul,[N.SelectLine]:_l,[N.HoverConnectPoint]:$l,[N.HoverConnectAnchorPoint]:jl,[N.HoverAnchorPoint]:Vl,[N.SelectPolyLineControlPoint]:Kl,[N.SelectLineTextRect]:Ql,[N.PlaceHolder]:Zl,[N.SelectConnectAnchor]:ql,[N.HoverConnectAnchor]:Jl,[N.PreviewGraphics]:eh,[N.HoverContainer]:th,[N.CropBounds]:nh,[N.CropOriginImg]:oh,[N.HoverSize]:sh,[N.SelectCurveControlPoint]:rh,[N.SelectCurveEnd]:ih,[N.SelectParentGroupBound]:ah,[N.HoverSlidePlaceHolder]:ch,[N.HoverFocusCopy]:lh,[N.HoverInsertSlide]:hh,[N.HoverInsertHorizonSlide]:dh,[N.HoverSlideGapInsertPoint]:uh,[N.SelectSlideGapInsertPoint]:ph});class ii{constructor(){p(this,"isWorking",!1);p(this,"idList",[]);p(this,"originX",0);p(this,"originY",0)}startWorking(t,e,n){this.idList=t,this.originX=e,this.originY=n,this.isWorking=!0}selectChange(t){if(!this.isWorking)return;t.size!==this.idList.length&&this.stopWork();const e=new Set(this.idList);for(const n of t)e.has(n.id)||this.stopWork(),e.delete(n.id);e.size!==0&&this.stopWork()}stopWork(){this.idList=[],this.isWorking=!1}}class bt{}const gh=new Set([v.Shape,v.SVG,v.IMG,v.Group,v.Section,v.Checkbox,v.CheckboxText]);class ai extends bt{enable(t){return t.length===1&&gh.has(t[0].type)}handle(t,e){const n=t[0],o=n.globalTransform().clone(),{width:s,height:r}=n.baseProps;e.addOrUpdate(N.SingleSelectBound,{x:0,y:0,width:s,height:r,transform:o}),n.parent&&n.parent.type===v.Group&&e.addOrUpdate(N.SelectParentGroupBound,{node:n.parent});const i=D.baseProps2Rect(n.baseProps);if(t.filter(c=>M.judgeNodeCanBeStretch(c)).length>0&&e.addOrUpdate(N.StretchRect,{transform:o,rect:new D(0,0,i.width,i.height)}),n.canQuickCreate()&&e.addOrUpdate(N.SelectConnectAnchor,{node:n}),n instanceof vt&&n.shapeType!==K.PureText){const h=n.drawer.fullTextNodeHeight(n);n.baseProps.height<h&&e.addOrUpdate(N.ExpandShape,{transform:o,rect:i})}}}class ci extends bt{enable(t){return t.length>1}handle(t,e){const n=[],o=[];t.forEach(i=>{const a=i.getBounds();n.push(a),o.push(D.rectNode2Rect(a))});const s=M.getBounds(n),r=D.rectNode2Rect(s);e.addOrUpdate(N.MultiSelectBound,{rect:r}),e.addOrUpdate(N.HighlightRects,{rects:o}),e.addOrUpdate(N.StretchRect,{rect:new D(0,0,r.width,r.height),transform:re.generateMatrix().translate(r.x,r.y)})}}var ze=(l=>(l[l.Scale=0]="Scale",l[l.Focus=1]="Focus",l[l.FocusPropsChange=2]="FocusPropsChange",l[l.ToolChange=3]="ToolChange",l[l.QuickCreate=4]="QuickCreate",l[l.ClickImg=5]="ClickImg",l[l.ImgUrls=6]="ImgUrls",l[l.ContextMenu=7]="ContextMenu",l[l.ExitCrop=8]="ExitCrop",l[l.DocMode=9]="DocMode",l[l.SlideCovers=10]="SlideCovers",l[l.SlideIndex=11]="SlideIndex",l))(ze||{});class li{constructor(){p(this,"slotMap",new Map);p(this,"slotCallBack",new Map);p(this,"working",!1);p(this,"tickerRun",()=>{for(const[t,e]of this.slotMap){const n=this.slotCallBack.get(t);n&&n(e)}this.slotMap.clear(),this.working&&requestAnimationFrame(this.tickerRun)})}start(){this.working=!0,this.tickerRun()}stop(){this.working=!1}reset(){this.slotMap.clear()}addSlotState(t,e){this.slotMap.set(t,e)}registerSlotCallback(t,e){this.slotCallBack.set(t,e)}}class fh extends bt{enable(t){return t.length===1&&t[0].type===v.Line}handle(t,e){const n=t[0],o=n.points,s=n.globalTransform();e.addOrUpdate(N.SelectLineEnd,{start:o[0],end:o[o.length-1],transform:s})}}class yh extends bt{enable(t){if(t.length!==1)return!1;const e=t[0];return e.type!==v.Line?!1:!!e.isPolyLine()}handle(t,e){const n=t[0],o=n.points,s=n.globalTransform();e.addOrUpdate(N.SelectLineEnd,{start:o[0],end:o[o.length-1],transform:s}),e.addOrUpdate(N.SelectPolyLineControlPoint,{points:n.points,transform:s})}}class xh extends bt{enable(t,e){if(t.length!==1)return!1;const n=t[0];if(n.type!==v.Line)return!1;const o=e.inputManager.editTextInfo;if(!o)return!1;const s=n;return o.node.id===s.id}handle(t,e){const n=t[0];e.addOrUpdate(N.SelectLineTextRect,{node:n,transform:n.globalTransform()})}}class wh extends bt{enable(t){return t.length===1&&t[0].type===v.Group}handle(t,e){const n=t[0],o=n.nameGlobalTransform().clone(),{width:s,height:r}=n.baseProps;e.addOrUpdate(N.SingleSelectBound,{x:0,y:0,width:s,height:r,transform:o}),n.parent&&n.parent.type===v.Group&&e.addOrUpdate(N.SelectParentGroupBound,{node:n.parent});const i=D.baseProps2Rect(n.baseProps);e.addOrUpdate(N.StretchRect,{transform:o,rect:new D(0,0,i.width,i.height)})}}const mh=new Set([v.SVG,v.IMG]);class Ph extends bt{enable(t,e){if(t.length!==1)return!1;const n=t[0];return!(!mh.has(n.type)||!e.cropManager.duringCrop||!n.imgBitmap)}handle(t,e){const n=t[0],o=n.globalTransform().clone();e.addOrUpdate(N.CropBounds,{node:n,transform:o});const{cropType:s,cropInfo:r}=n.cropProps,{x:i,y:a,width:c,height:h}=n.baseProps;if(s===0||!r){e.addOrUpdate(N.SingleSelectBound,{x:0,y:0,width:c,height:h,transform:o});const d=new D(0,0,c,h);e.addOrUpdate(N.StretchRect,{transform:o,rect:d})}else{const d=n.getOriginImageRect();e.addOrUpdate(N.SingleSelectBound,{x:d.x,y:d.y,width:d.width,height:d.height,transform:o}),e.addOrUpdate(N.StretchRect,{transform:o,rect:d}),e.addOrUpdate(N.CropOriginImg,{x:d.x,y:d.y,width:d.width,height:d.height,transform:o,imgBitmap:n.imgBitmap})}}}class bh extends bt{enable(t){return t.length===1&&t[0].type===v.Line&&t[0].shapeType===de.Curve}handle(t,e){const n=t[0],o=n.globalTransform();e.addOrUpdate(N.SelectCurveEnd,{points:M.computeCurveEndPoints(n),transform:o}),e.addOrUpdate(N.SelectCurveControlPoint,{points:M.computeCurveControlPoints(n),transform:o})}}const Mh=new Set([v.Shape,v.SVG,v.IMG,v.Group,v.Section,v.Checkbox,v.CheckboxText]);class Sh extends bt{enable(t,e){return!e.docState.userPermission.canEdit&&t.length===1}handle(t,e){const n=t[0];if(n.type===v.Group){this.handleGroup(n,e);return}if(n instanceof Ct){this.handleLine(n,e);return}if(Mh.has(n.type)){this.handleNormalNode(n,e);return}}handleNormalNode(t,e){const n=t.globalTransform().clone(),{width:o,height:s}=t.baseProps;e.addOrUpdate(N.SingleSelectBound,{x:0,y:0,width:o,height:s,transform:n}),t.parent&&t.parent.type===v.Group&&e.addOrUpdate(N.SelectParentGroupBound,{node:t.parent})}handleLine(t,e){e.addOrUpdate(N.SelectLine,{node:t})}handleGroup(t,e){const n=t.nameGlobalTransform().clone(),{width:o,height:s}=t.baseProps;e.addOrUpdate(N.SingleSelectBound,{x:0,y:0,width:o,height:s,transform:n}),t.parent&&t.parent.type===v.Group&&e.addOrUpdate(N.SelectParentGroupBound,{node:t.parent})}}class vh extends bt{enable(t,e){return!e.docState.userPermission.canEdit&&t.length>1}handle(t,e){const n=[],o=[];t.forEach(i=>{const a=i.getBounds();n.push(a),o.push(D.rectNode2Rect(a))});const s=M.getBounds(n),r=D.rectNode2Rect(s);e.addOrUpdate(N.MultiSelectBound,{rect:r}),e.addOrUpdate(N.HighlightRects,{rects:o})}}class Ih extends bt{enable(t){return t.length===1&&t[0].type===v.SlideContainer}handle(t,e){const n=t[0],o=n.globalTransform().clone(),{width:s,height:r}=n.baseProps;e.addOrUpdate(N.SingleSelectBound,{x:0,y:0,width:s,height:r,transform:o}),n.parent&&n.parent.type===v.Group&&e.addOrUpdate(N.SelectParentGroupBound,{node:n.parent})}}const Th=5,nt=50,xt=40;class Lh extends bt{enable(t){var e;return t.length===1&&((e=t[0].parent)==null?void 0:e.type)===v.SlideContainer}handle(t,e){const n=t[0],o=n.globalTransform().clone(),{x:s,y:r,height:i,width:a}=n.globalBaseProps;e.addOrUpdate(N.SingleSelectBound,{x:0,y:0,width:a,height:i,transform:o});const c=[{x:s-nt/2,y:r+i/2},{x:s+a+nt/2,y:r+i/2}];e.addOrUpdate(N.SelectSlideGapInsertPoint,{points:c})}}var he=(l=>(l[l.BOARD=0]="BOARD",l[l.SLIDE_EDIT=1]="SLIDE_EDIT",l[l.SLIDE_PLAY=2]="SLIDE_PLAY",l))(he||{});class Ch extends bt{enable(t,e){var n;return t.length===1&&((n=t[0].parent)==null?void 0:n.type)===v.SlideContainer&&e.docState.docMode===he.SLIDE_EDIT}handle(t,e){const n=t[0],o=n.globalTransform().clone(),{x:s,y:r,height:i,width:a}=n.globalBaseProps;e.addOrUpdate(N.SingleSelectBound,{x:0,y:0,width:a,height:i,transform:o})}}class hi{constructor(t,e,n,o){p(this,"selectNodes",new Set);p(this,"optionHelper");p(this,"auxiliaryManager");p(this,"inputManager");p(this,"cropManager");p(this,"docState");p(this,"statusHandlers",[new Sh,new vh,new Ih,new wh,new xh,new yh,new bh,new fh,new Ph,new Ch,new Lh,new ai,new ci]);this.auxiliaryManager=e,this.optionHelper=new ii,this.cropManager=n,this.docState=o}register(t){this.inputManager=t}reset(){this.selectNodes.clear()}refreshSelectStatus(){this.auxiliaryManager.removeSelectGraphics();const t=[...this.selectNodes],e=this.selectStatusContext();for(const n of this.statusHandlers)if(n.enable(t,e)){n.handle(t,this.auxiliaryManager);return}}selectStatusContext(){return{inputManager:this.inputManager,cropManager:this.cropManager,docState:this.docState}}getSelectNodes(){return[...this.selectNodes]}getSelectBounds(){const t=[];for(const e of this.selectNodes)t.push(e.getBounds());return M.getBounds(t,"selectBounds")}set(t){this.selectNodes=t,this.optionHelper.selectChange(t),this.auxiliaryManager.slotManager.addSlotState(ze.Focus,[...t]),this.auxiliaryManager.slotManager.addSlotState(ze.FocusPropsChange,!0),this.refreshSelectStatus()}startOptWorking(t,e,n){this.optionHelper.startWorking(t,e,n)}include(t){return this.selectNodes.has(t)}}class di{constructor(t,e,n,o){p(this,"gmlRender");p(this,"selectManager");p(this,"graphicMap");p(this,"slotManager");this.gmlRender=t,this.slotManager=e,this.selectManager=new hi(t,this,n,o),this.graphicMap=new Map}start(){}reset(){this.graphicMap.clear(),this.selectManager.reset()}addOrUpdate(t,e){const n=this.graphicMap.get(t);if(n){n.update(e);return}const o=vs.create(t);o&&(this.graphicMap.set(t,o),o.update(e))}remove(t){this.graphicMap.delete(t)}redraw(){const t=this.gmlRender.getViewPortBounds();this.gmlRender.glCtx.clearRect(t.minX,t.minY,t.maxX-t.minX,t.maxY-t.minY);const e=this.gmlRender.getScale(),n=[...this.graphicMap.values()];n.sort((o,s)=>o.auxiliaryType-s.auxiliaryType);for(const o of n)o.draw(this.gmlRender.glCtx,e)}removeHoverGraphics(){this.remove(N.HoverBounds),this.remove(N.HoverLine),this.remove(N.HoverConnectPoint),this.remove(N.HoverConnectAnchorPoint),this.remove(N.HoverAnchorPoint),this.remove(N.HoverConnectAnchor),this.remove(N.PreviewGraphics),this.remove(N.HoverContainer),this.remove(N.HoverSize),this.remove(N.HoverSlidePlaceHolder),this.remove(N.HoverFocusCopy),this.remove(N.HoverInsertSlide),this.remove(N.HoverInsertHorizonSlide),this.remove(N.HoverSlideGapInsertPoint),this.removeAlignGraphics()}removeSelectGraphics(){this.remove(N.SingleSelectBound),this.remove(N.MultiSelectBound),this.remove(N.HighlightRects),this.remove(N.TextSelection),this.remove(N.StretchRect),this.remove(N.ExpandShape),this.remove(N.SelectLineEnd),this.remove(N.SelectLine),this.remove(N.SelectPolyLineControlPoint),this.remove(N.SelectCurveControlPoint),this.remove(N.SelectCurveEnd),this.remove(N.SelectLineTextRect),this.remove(N.SelectConnectAnchor),this.remove(N.CropBounds),this.remove(N.CropOriginImg),this.remove(N.SelectParentGroupBound),this.remove(N.SelectSlideGapInsertPoint)}removeAlignGraphics(){this.remove(N.AlignLine),this.remove(N.AlignStretchLine)}}class Ah{}class Wn extends ct{constructor(){super(...arguments);p(this,"type",I.Svg);p(this,"useCode",!1);p(this,"url","");p(this,"code","")}static from(e){const n=new Wn;return n.url=e.url,n.code=e.code,n.useCode=e.useCode,n}clone(){const e=new Wn;return e.url=this.url,e.code=this.code,e.useCode=this.useCode,e}update(e){const{url:n,code:o,useCode:s}=e;n!==void 0&&(this.url=n),o!==void 0&&(this.code=o),s!==void 0&&(this.useCode=s)}}var wt=(l=>(l[l.None=0]="None",l[l.Rect=1]="Rect",l[l.RoundRect=2]="RoundRect",l[l.Circle=3]="Circle",l))(wt||{});class Sn extends ct{constructor(){super(...arguments);p(this,"type",I.Crop);p(this,"cropType",wt.None);p(this,"cropInfo")}static from(e){const n=new Sn;return n.cropType=e.cropType||wt.None,n.cropInfo=e.cropInfo,n}clone(){const e=new Sn;return e.cropType=this.cropType,this.cropInfo&&(e.cropInfo={imgX:this.cropInfo.imgX,imgY:this.cropInfo.imgY,imgWidth:this.cropInfo.imgWidth,imgHeight:this.cropInfo.imgHeight}),e}update(e){const{cropInfo:n,cropType:o}=e;n!==void 0&&(this.cropInfo=n),o!==void 0&&(this.cropType=o)}}class Qt extends ct{constructor(){super(...arguments);p(this,"type",I.CheckStatus);p(this,"checkStatus",!1)}static create(e){const n=new Qt;return n.update(e),n}static from(e){const n=new Qt;return n.checkStatus=e.checkStatus,n}clone(){const e=new Qt;return e.checkStatus=this.checkStatus,e}update(e){const{checkStatus:n}=e;n!==void 0&&(this.checkStatus=n)}}class vn extends ct{constructor(){super(...arguments);p(this,"type",I.CheckSize);p(this,"size",16)}static create(e){const n=new vn;return n.update(e),n}static from(e){const n=new vn;return n.size=e.size,n}clone(){const e=new vn;return e.size=this.size,e}update(e){const{size:n}=e;n!==void 0&&(this.size=n)}}var me=(l=>(l[l.Decision=0]="Decision",l[l.Step=1]="Step",l[l.Data=2]="Data",l[l.Status=3]="Status",l[l.Operation=4]="Operation",l[l.Others=5]="Others",l[l.Section=6]="Section",l[l.Resource=7]="Resource",l[l.Line=8]="Line",l[l.Check=9]="Check",l))(me||{}),K=(l=>(l[l.PureText=0]="PureText",l[l.Rect=1]="Rect",l[l.Ellipse=2]="Ellipse",l[l.Octagon=3]="Octagon",l[l.DoubleArrow=4]="DoubleArrow",l[l.LeftArrow=5]="LeftArrow",l[l.LeftKuohao=6]="LeftKuohao",l[l.Diamond=7]="Diamond",l[l.Hexagon=8]="Hexagon",l[l.LiuCheng=9]="LiuCheng",l[l.LiuCheng2=10]="LiuCheng2",l[l.Parallelogram=11]="Parallelogram",l[l.Qipao=12]="Qipao",l[l.Qipao2=13]="Qipao2",l[l.RightArrow=14]="RightArrow",l[l.RightKuohao=15]="RightKuohao",l[l.RoundRect=16]="RoundRect",l[l.RoundRect2=17]="RoundRect2",l[l.Cross=18]="Cross",l[l.Trapezoid=19]="Trapezoid",l[l.Triangle=20]="Triangle",l[l.Triangle2=21]="Triangle2",l[l.Pentagon=22]="Pentagon",l[l.Star=23]="Star",l[l.YuanZhu=24]="YuanZhu",l[l.Cloud=25]="Cloud",l))(K||{});const Is={[K.PureText]:me.Operation,[K.Rect]:me.Operation,[K.RoundRect]:me.Step,[K.Triangle]:me.Operation,[K.Diamond]:me.Decision,[K.Ellipse]:me.Status,[K.Parallelogram]:me.Operation,[K.Trapezoid]:me.Step,[K.Cross]:me.Operation,[K.Pentagon]:me.Operation,[K.Hexagon]:me.Decision,[K.Octagon]:me.Operation,[K.Star]:me.Decision};var Zt=(l=>(l[l.TOP_RIGHT=0]="TOP_RIGHT",l[l.TOP_LEFT=1]="TOP_LEFT",l[l.BOTTOM_RIGHT=2]="BOTTOM_RIGHT",l[l.BOTTOM_LEFT=3]="BOTTOM_LEFT",l))(Zt||{});class qt extends ct{constructor(){super(...arguments);p(this,"type",I.TextParagraph);p(this,"paragraphStyles",[])}static create(e){const n=new qt;return n.update(e),n}static from(e){const n=new qt;return n.paragraphStyles=e.paragraphStyles,n}clone(){const e=new qt;return e.paragraphStyles=JSON.parse(JSON.stringify(this.paragraphStyles)),e}update(e){const{paragraphStyles:n}=e;n!==void 0&&(this.paragraphStyles=n)}}class Dt extends ct{constructor(){super(...arguments);p(this,"paraQuoteStyles",[]);p(this,"type",I.TextParagraphQuote)}static create(e){const n=new Dt;return n.update(e),n}static from(e){const n=new Dt;return n.paraQuoteStyles=e.paraQuoteStyles,n}clone(){const e=new Dt;return e.paraQuoteStyles=JSON.parse(JSON.stringify(this.paraQuoteStyles)),e}update(e){const{paraQuoteStyles:n}=e;n!==void 0&&(this.paraQuoteStyles=n)}}var de=(l=>(l[l.Line=0]="Line",l[l.PolyLine=1]="PolyLine",l[l.RoundPolyLine=2]="RoundPolyLine",l[l.Curve=3]="Curve",l))(de||{});class ui{constructor(t,e,n,o){p(this,"p0");p(this,"p1");p(this,"p2");p(this,"p3");this.p0=t,this.p1=e,this.p2=n,this.p3=o}getPos(t){if(t<0||t>1)throw new Error(`非法的t值:${t}`);const e=1-t,n=e*e*e*this.p0.x+3*t*e*e*this.p1.x+3*t*t*e*this.p2.x+t*t*t*this.p3.x,o=e*e*e*this.p0.y+3*t*e*e*this.p1.y+3*t*t*e*this.p2.y+t*t*t*this.p3.y;return new m(n,o)}getHalfTPos(){return this.getPos(.5)}getDerivative(t){const e=1-t,n=3*e*e*(this.p1.x-this.p0.x)+6*e*t*(this.p2.x-this.p1.x)+3*t*t*(this.p3.x-this.p2.x),o=3*e*e*(this.p1.y-this.p0.y)+6*e*t*(this.p2.y-this.p1.y)+3*t*t*(this.p3.y-this.p2.y);return new m(n,o)}getDistanceSquared(t,e){const n=this.getPos(e),o=n.x-t.x,s=n.y-t.y;return o*o+s*s}getTValueByPoint(t,e=1,n=50){let o=0,s=1/0;const r=20;for(let a=0;a<=r;a++){const c=a/r,h=this.getDistanceSquared(t,c);h<s&&(s=h,o=c)}if(Math.sqrt(s)<e)return o;let i=o;for(let a=0;a<n;a++){const c=this.getPos(i),h=this.getDerivative(i),d=c.x-t.x,u=c.y-t.y,g=d*h.x+u*h.y;if(Math.abs(g)<e)return Math.max(0,Math.min(1,i));const f=1-i,y=6*f*(this.p2.x-2*this.p1.x+this.p0.x)+6*i*(this.p3.x-2*this.p2.x+this.p1.x),P=6*f*(this.p2.y-2*this.p1.y+this.p0.y)+6*i*(this.p3.y-2*this.p2.y+this.p1.y),b=h.x*h.x+h.y*h.y+d*y+u*P;if(Math.abs(b)<1e-10)break;const w=i-g/b;if(i=Math.max(0,Math.min(1,w)),Math.abs(w-i)<e&&i===w)break}return i}getApproximateLength(t=10){let e=0,n=this.getPos(0);for(let o=1;o<=t;o++){const s=o/t,r=this.getPos(s),i=r.x-n.x,a=r.y-n.y;e+=Math.sqrt(i*i+a*a),n=r}return e}getTValueByDistance(t,e=20){if(t<=0)return 0;let n=0,o=this.getPos(0);for(let s=1;s<=e;s++){const r=s/e,i=this.getPos(r),a=i.x-o.x,c=i.y-o.y,h=Math.sqrt(a*a+c*c);if(n+h>=t){const u=(t-n)/h,g=(s-1)/e;return g+u*(r-g)}n+=h,o=i}return 1}}var Jt=(l=>(l.Windows="Windows",l.MacOS="MacOS",l.Linux="Linux",l.Android="Android",l.IOS="ios",l.Unknown="unknown",l))(Jt||{});class pi{static getOS(){const t=navigator.userAgent;return t.includes("Win")?Jt.Windows:t.includes("Mac")?Jt.MacOS:t.includes("Linux")?Jt.Linux:/Android/.test(t)?Jt.Android:/iPhone|iPad|iPod/.test(t)?Jt.IOS:Jt.Unknown}}class Mt extends ct{constructor(){super(...arguments);p(this,"type",I.Slide);p(this,"children",[])}static create(e){const n=new Mt;return n.update(e),n}static from(e){const n=new Mt;return n.children=e.children,n}clone(){const e=new Mt;return e.children=this.children,e}update(e){const{children:n}=e;n!==void 0&&(this.children=n)}}class M{static computeShapeCategory(t,e=0){return t===v.Shape?Is[e]??me.Others:t===v.CheckboxText||t===v.Checkbox?me.Check:t===v.Line?me.Line:t===v.Section?me.Section:t===v.SVG?me.Resource:me.Others}static makeSortGraphic(t){const e=[t];let n=t.parent;for(;n&&n.id!==Mn;)e.unshift(n),n=n.parent;return{graphics:e}}static sortGraphics(t){const e=t.map(this.makeSortGraphic);return e.sort((n,o)=>{const s=Math.min(n.graphics.length,o.graphics.length);for(let r=0;r<s;r++){const i=n.graphics[r],a=o.graphics[r];if(i!==a)return i.zIndex>a.zIndex?1:-1}return n.graphics.length-o.graphics.length}),e.map(n=>n.graphics[n.graphics.length-1])}static setDashLine(t,e){t.dashType===et.Dash1?e.setLineDash([4,2]):t.dashType===et.Dash2&&e.setLineDash([2,2])}static convertPropsToCapInfo(t){const e={},n=t.get(I.Base);n&&(e.baseProps=n);const o=t.get(I.Color);o&&(e.colorProps=o);const s=t.get(I.Border);s&&(e.borderProps=s);const r=t.get(I.Text);r&&(e.textProps=r);const i=t.get(I.Shape);i&&(e.shapeProps=i);const a=t.get(I.Line);a&&(e.lineProps=a);const c=t.get(I.Connect);c&&(e.connectProps=c);const h=t.get(I.Arrow);h&&(e.arrowProps=h);const d=t.get(I.LineTextRect);d&&(e.lineTextRectProps=d);const u=t.get(I.Svg);u&&(e.svgProps=u);const g=t.get(I.Image);g&&(e.imageProps=g);const f=t.get(I.Crop);f&&(e.cropProps=f);const y=t.get(I.CheckStatus);y&&(e.checkStatusProps=y);const P=t.get(I.CheckSize);y&&(e.checkSizeProps=P);const b=t.get(I.TextParagraph);b&&(e.textParagraphProps=b);const w=t.get(I.TextParagraphQuote);w&&(e.textParagraphQuoteProps=w);const L=t.get(I.Slide);return L&&(e.slideProps=L),e}static convertCapInfoToProps(t){const e=[],{baseProps:n,borderProps:o,shapeProps:s,colorProps:r,textProps:i,lineProps:a,connectProps:c,arrowProps:h,lineTextRectProps:d,svgProps:u,imageProps:g,cropProps:f,checkStatusProps:y,checkSizeProps:P,textParagraphProps:b,textParagraphQuoteProps:w,slideProps:L}=t;return o&&e.push(Ae.from(o)),r&&e.push(tt.from(r)),i&&e.push(Ge.from(i)),n&&e.push(ie.from(n)),s&&e.push(Oe.from(s)),a&&e.push(je.from(a)),c&&e.push(Rt.from(c)),h&&e.push(lt.from(h)),d&&e.push(Et.from(d)),u&&e.push(Wn.from(u)),g&&e.push(ro.from(g)),f&&e.push(Sn.from(f)),y&&e.push(Qt.from(y)),P&&e.push(vn.from(P)),b&&e.push(qt.from(b)),w&&e.push(Dt.from(w)),L&&e.push(Mt.from(L)),e}static centerPoint(t){const e=t.baseProps;return new m(e.x+.5*e.width,e.y+.5*e.height)}static topPoint(t){const e=t.baseProps;return new m(e.x+.5*e.width,e.y)}static rightPoint(t){const e=t.baseProps;return new m(e.x+e.width,e.y+.5*e.height)}static bottomPoint(t){const e=t.baseProps;return new m(e.x+.5*e.width,e.y+e.height)}static leftPoint(t){const e=t.baseProps;return new m(e.x,e.y+.5*e.height)}static topLeft(t){const e=t.baseProps;return new m(e.x,e.y)}static topRight(t){const e=t.baseProps;return new m(e.x+e.width,e.x+e.width)}static bottomLeft(t){const e=t.baseProps;return new m(e.x,e.y+e.height)}static bottomRight(t){const e=t.baseProps;return new m(e.x+e.width,e.y+e.height)}static middleInsertPoint(t,e,n){const o=new m(t.x,e.y);n.push(t,o,e)}static doubleMiddleInsertPoint(t,e,n){const o=new m(.5*(t.x+e.x),t.y),s=new m(.5*(t.x+e.x),e.y);n.push(t,o,s,e)}static rectContains(t,e){return t.x>e.x&&t.x<e.x+e.width&&t.y>e.y&&t.y<e.y+e.height}static rectContains2(t,e){return t.x>=e.minX&&t.x<=e.maxX&&t.y>=e.minY&&t.y<=e.maxY}static circleContains(t,e,n=2){return(t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y)<n*n}static overlapRect(t,e){return!(t.maxX<e.minX||t.minX>e.maxX||t.maxY<e.minY||t.minY>e.maxY)}static containRect(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&t.maxX>=e.maxX&&t.maxY>=e.maxY}static distance(t,e){return Math.sqrt((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y))}static lineAngle(t,e){if(Math.abs(t.x-e.x)<.001)return e.y>t.y?Math.PI*.5:-Math.PI*.5;const n=(e.y-t.y)/(e.x-t.x);let o=Math.atan(n);return e.x<t.x&&(o+=Math.PI),o}static basicGetArrowPoint(t,e,n,o){const s=M.lineAngle(t,e),r=re.generateMatrix().translate(t.x,t.y).rotate2(s),i=r.crossPoint(n),a=r.crossPoint(o);return{a:i,b:a}}static getLArrowPoint(t,e,n=5){const o=new m(Math.sqrt(3)*.5*n,.5*n),s=new m(Math.sqrt(3)*.5*n,-.5*n);return M.basicGetArrowPoint(t,e,o,s)}static getRArrowPoint(t,e,n=5){const o=M.distance(t,e),s=new m(o-Math.sqrt(3)*.5*n,.5*n),r=new m(o-Math.sqrt(3)*.5*n,-.5*n);return M.basicGetArrowPoint(t,e,s,r)}static getNodeBounds(t){const e=[];t.forEach(o=>e.push(o.getBounds()));const n=this.getBounds(e);return D.rectNode2Rect(n)}static cloneIRectNode(t){return{minX:t.minX,maxX:t.maxX,minY:t.minY,maxY:t.maxY}}static cloneIPoint(t){return{x:t.x,y:t.y}}static getBoundsByBaseProps(t){const{x:e,y:n,width:o,height:s,angle:r}=t,i=re.generateMatrix().rotate(r),a=re.generateMatrix().translate(e,n),c=[new m(0,0),new m(0,s),new m(o,0),new m(o,s)],h=a.crossProduct(i),d=c.map(u=>h.crossPoint(u));return this.getBoundsByPoints(d)}static getBoundsByBasePropsList(t){const e=[];for(const n of t){const{x:o,y:s,width:r,height:i}=n,a=n.angle??0,c=re.generateMatrix().rotate(a),d=re.generateMatrix().translate(o,s).crossProduct(c),g=[new m(0,0),new m(0,i),new m(r,0),new m(r,i)].map(f=>d.crossPoint(f));e.push(...g)}return this.getBoundsByPoints(e)}static getBounds(t,e="getBounds"){const n=[],o=[];for(const s of t)n.push(s.maxX,s.minX),o.push(s.maxY,s.minY);return{id:e,minX:Math.min(...n),maxX:Math.max(...n),minY:Math.min(...o),maxY:Math.max(...o)}}static getBoundsByPoints(t){const e=[],n=[];for(const o of t)e.push(o.x),n.push(o.y);return{id:"getBounds",minX:Math.min(...e),maxX:Math.max(...e),minY:Math.min(...n),maxY:Math.max(...n)}}static calcFont(t,e,n=!1,o=!1){let s=`${t.toString()}px ${e}`;return n?s=`700 ${s}`:s=`400 ${s}`,o&&(s=`italic ${s}`),s}static calcFontByTextProps(t){const{fontSize:e,fontFamily:n,bold:o,italic:s}=t;return this.calcFont(e,n,o,s)}static measureText(t,e){const n=t.measureText(e),o=n.width,s=n.fontBoundingBoxDescent+n.fontBoundingBoxAscent,r=n.fontBoundingBoxAscent;return{width:o,height:s,boxAscent:r}}static measureTextByFont(t,e,n,o,s,r){t.save(),t.font=this.calcFont(n,o,s,r);const i=t.measureText(e);t.restore();const a=i.width,c=i.fontBoundingBoxDescent+i.fontBoundingBoxAscent,h=i.fontBoundingBoxAscent;return{width:a,height:c,boxAscent:h}}static judgeHorizon(t,e,n=.01){return Math.abs(t.y-e.y)<n}static judgeVertical(t,e,n=.01){return Math.abs(t.x-e.x)<n}static computePolyLinePoints(t,e){const n=[],o=new m(e.x-t.x,e.y-t.y);if(Math.abs(o.x)<.001||Math.abs(o.y)<.001)n.push(t,e);else if(Math.abs(o.x)>Math.abs(o.y)){const s=new m(t.x+.5*o.x,t.y),r=new m(e.x-.5*o.x,e.y);n.push(t,s,r,e)}else{const s=new m(t.x,t.y+.5*o.y),r=new m(e.x,e.y-.5*o.y);n.push(t,s,r,e)}return n}static normalizeAngle(t){let e=t%360;return e<0&&(e+=360),e}static computeOriginNodeConnectEnd(t){const{x:e,y:n}=t,o=Math.atan2(n-.5,e-.5)/Math.PI*180,s=this.normalizeAngle(o);if(s<45||s>315)return ue.Right;if(Math.abs(s-90)<45)return ue.Bottom;if(Math.abs(s-180)<45)return ue.Left;if(Math.abs(s-270)<45)return ue.Top;throw new Error("没有正确的end type")}static computeNodeConnectEnd(t,e){const{x:n,y:o}=t,s=Math.atan2(o-.5,n-.5)/Math.PI*180+e,r=this.normalizeAngle(s);if(r<45||r>315)return ue.Right;if(Math.abs(r-90)<45)return ue.Bottom;if(Math.abs(r-180)<45)return ue.Left;if(Math.abs(r-270)<45)return ue.Top;throw new Error("没有正确的end type")}static inDistance(t,e,n){return Math.abs(t-e-.5*n)<.5*n}static dealWithEndPolyPointsInUp(t,e,n){if(t.length<4)return t;const o=t.length;if(n){const a=t[o-1],c=t[o-2],h=t[o-3];return M.distance(c,h)<3/e&&(M.judgeHorizon(a,c)?a.y=h.y:a.x=h.x,t.splice(o-3,2)),t}const s=t[0],r=t[1],i=t[2];return M.distance(i,r)<3/e&&(M.judgeHorizon(s,r)?s.y=i.y:s.x=i.x,t.splice(1,2)),t}static dealWithEndPolyPoints(t,e,n){if(t.length<4)return t;const o=t.length;if(n){const a=t[o-1],c=t[o-2],h=t[o-3];return M.distance(c,h)<3/e&&(M.judgeHorizon(a,c)?(c.y=h.y,a.y=h.y):(c.x=h.x,a.x=h.x)),t}const s=t[0],r=t[1],i=t[2];return M.distance(i,r)<3/e&&(M.judgeHorizon(s,r)?(r.y=i.y,s.y=i.y):(r.x=i.x,s.x=i.x)),t}static dealWithPolyPoints(t,e){if(t.length===0)return[];const n=[t[0]];for(let o=1;o<t.length-1;o++){const s=t[o],r=t[o+1];if(M.distance(s,r)<3/e){const i=t[o+2],a=t[o-1];M.judgeHorizon(a,s)?a.y=i.y:a.x=i.x,o=o+1}else n.push(s)}return n.push(t[t.length-1]),n}static computePointByT(t,e){const n=t.points;if(t.isPolyLine()){let a=0;for(let h=0;h<n.length-1;h++){const d=n[h],u=n[h+1],g=M.distance(d,u);a+=g}const c=e*a;a=0;for(let h=0;h<n.length-1;h++){const d=n[h],u=n[h+1],g=M.distance(d,u);if(c>a&&c<=a+g)if(M.judgeHorizon(d,u)){const y=u.x>d.x?1:-1;return new m(d.x+(c-a)*y,d.y)}else{const y=u.y>d.y?1:-1;return new m(d.x,d.y+(c-a)*y)}a+=g}}else if(t.shapeType===de.Curve){const a=M.computeBezierCurves(t);let c=0;const h=[];for(const u of a){const g=u.getApproximateLength();c+=g,h.push(g)}c=e*c;for(let u=0;u<a.length;u++){const g=a[u],f=h[u];if(c>f){c-=f;continue}const y=g.getTValueByDistance(c);return g.getPos(y)}}const o=n[0],s=n[n.length-1],r=o.x+(s.x-o.x)*e,i=o.y+(s.y-o.y)*e;return new m(r,i)}static computeNodeConnectAnchor(t,e){const{width:n,height:o}=t.baseProps,s=Yr/e;return[{x:.5*n,y:-s},{x:n+s,y:.5*o},{x:.5*n,y:o+s},{x:-s,y:.5*o}]}static computeSelectNode(t,e){const n=new Set(t.getSelectNodes());let o=e.parent;for(;o;)n.has(o)&&n.delete(o),o=o.parent;return this.filterChildInSet(n,e),n.add(e),n}static filterChildInSet(t,e){const n=e.children;if(n.size!==0)for(const o of n)t.has(o)&&t.delete(o),this.filterChildInSet(t,o)}static computeSelectNodes(t){const e=new Set(t);for(const n of t)this.filterChildInSet(e,n);return[...e]}static filterToGroupNodes(t){const e=[];for(const n of t)if(n.type!==v.Section){if(n.type===v.Line){const o=n,{start:s,end:r}=o.connectProps;if(s&&r){const i=t.find(c=>c.id===s.objectId),a=t.find(c=>c.id===r.objectId);i&&a&&e.push(n);continue}if(s&&!r){t.find(a=>a.id===s.objectId)&&e.push(n);continue}if(r&&!s){t.find(a=>a.id===r.objectId)&&e.push(n);continue}e.push(n);continue}e.push(n)}return e}static detectRectBounds(t,e,n){const{x:o,y:s,width:r,height:i}=t;return M.circleContains(new m(o,s),e,n)?{type:V.TOP_LEFT}:M.circleContains(new m(o+r,s),e,n)?{type:V.TOP_RIGHT}:M.circleContains(new m(o+r,s+i),e,n)?{type:V.BOTTOM_RIGHT}:M.circleContains(new m(o,s+i),e,n)?{type:V.BOTTOM_LEFT}:M.rectContains(e,new D(o,s-.5*n,r,n))?{type:V.TOP}:M.rectContains(e,new D(o+r-.5*n,s,n,i))?{type:V.RIGHT}:M.rectContains(e,new D(o,s+i-.5*n,r,n))?{type:V.BOTTOM}:M.rectContains(e,new D(o-.5*n,s,n,i))?{type:V.LEFT}:null}static computeShiftPoint(t,e){if(M.distance(t,e)<.1)return new m(e.x,t.y);let n=Math.atan2(e.y-t.y,e.x-t.x)*180/Math.PI;return n=(n+360)%360,n<45||n>=315?new m(e.x,t.y):n>45&&n<=135?new m(t.x,e.y):n>135&&n<225?new m(e.x,t.y):new m(t.x,e.y)}static dealWithShiftLineInteractEvent(t,e,n=!0){if(!t.originEvent.shiftKey)return t;const o=e.globalLinePoints,s=n?o[0]:o[o.length-1],r=M.computeShiftPoint(s,t.globalPoint);return{clientPoint:t.clientPoint,globalPoint:r,type:t.type,originEvent:t.originEvent}}static getMockEventModifierInit(t){return{shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey,ctrlKey:t.ctrlKey}}static judgeParentInset(t,e){let n=t;for(;n;){if(e.has(n))return!0;n=n.parent}return!1}static judgeSlideSectionChildren(t,e){let n=t;for(;n!=null&&n.parent;){if(n.parent.id===e.id)return n;n=n.parent}return null}static filterContainerFromNodes(t){const e=t.filter(o=>o.type===v.Section);return new Set(e)}static judgeEndNode(t,e,n,o,s){if(!n)return;const r=o.nodeManager.getNode(n.objectId);r&&!M.judgeParentInset(r,s)&&e.add(t)}static getViewportBoundCenter(t){const e=t.renderManager.gmlRender.getViewPortBounds();return new m(.5*(e.minX+e.maxX),.5*(e.minY+e.maxY))}static computeRotateAngle(t,e){let n=0;return t.length===1&&(n=n+t[0].baseProps.angle),n=n+e,Math.round(n)}static computeRotateDeltaAngle(t){let e=0;switch(t){case Zt.BOTTOM_LEFT:e=90;break;case Zt.BOTTOM_RIGHT:e=0;break;case Zt.TOP_LEFT:e=180;break;case Zt.TOP_RIGHT:e=-90;break}return e}static computeRelationChangeUpdateNodeInfo(t,e,n,o){if(t.type===v.Line){const i=t.globalLinePoints.map(c=>e.toLocal(c)),a=D.rectNode2Rect(M.getBoundsByPoints(i));return{id:t.id,props:[{type:I.Line,points:i},ie.create({x:a.x,y:a.y,width:a.width,height:a.height})],zIndex:n,parentId:o}}const s=e.toLocal(t.globalPos);return{id:t.id,zIndex:n,parentId:o,props:[{type:I.Base,x:s.x,y:s.y}]}}static computeStretchAngle(t,e){let n=0;return t.length===1&&(n=n+t[0].baseProps.angle),e===V.TOP_RIGHT||e===V.BOTTOM_LEFT?n=n-45:e===V.TOP_LEFT||e===V.BOTTOM_RIGHT?n=n+45:(e===V.TOP||e===V.BOTTOM)&&(n=n+90),Math.round(n)}static correctZIndex(t){if(t.length===0)return t;const e=new Map;if(t.forEach((s,r)=>{const i=s.zIndex;e.has(i)||e.set(i,[]),e.get(i).push(r)}),!Array.from(e.values()).some(s=>s.length>1))return t;const o=t.map(s=>({...s}));return e.forEach((s,r)=>{if(s.length>1){const i=s[0];let a=.1,c=0;i===0?(c=r-1,a=(r-c)/(s.length+1)):(c=o[i-1].zIndex<r?o[i-1].zIndex:r-1,a=(r-c)/(s.length+1)),s.forEach((h,d)=>{o[h].zIndex=(d+1)*a+c})}}),o}static judgeLineBreak(t,e,n,o){let s=-1;for(const r of t){const i=e.characters.slice(0,r);let a=0;if(i.forEach(c=>{a+=c.width}),n.width+a<o)s=r;else return s>0?s:-1}return s>-1?s:-1}static getParaStyle(t,e){const n=t.paragraphStyles;for(const o of n)if(o.paraIndex===e)return o;return null}static computeNotUnOrderParas(t){const n=t.paragraphProps.paragraphStyles,o=new Set;for(let s=0;s<t.paragraphs.length;s++)o.add(s);for(const s of n)s.orderIndex===-1&&o.delete(s.paraIndex);return o}static computeNotOrderParas(t){const n=t.paragraphProps.paragraphStyles,o=new Set;for(let s=0;s<t.paragraphs.length;s++)o.add(s);for(const s of n)s.orderIndex>-1&&o.delete(s.paraIndex);return o}static computeNotNormalParas(t){const n=t.paragraphProps.paragraphStyles,o=new Set;for(const s of n)o.add(s.paraIndex);return o}static computeNotQuoteParas(t){const n=t.paragraphQuoteProps.paraQuoteStyles,o=new Set;for(let s=0;s<t.paragraphs.length;s++)o.add(s);for(const s of n)s.quote&&o.delete(s.paraIndex);return o}static drawControlPoints(t,e){t.save(),t.beginPath(),t.strokeStyle="#cc2626",t.lineWidth=1;const n=e.globalLinePoints;t.moveTo(n[0].x,n[0].y);for(let o=1;o<n.length;o++){const s=n[o];t.lineTo(s.x,s.y)}t.stroke(),t.fillStyle="#000000";for(let o=1;o<n.length-2;o=o+3){const s=n[o],r=n[o+1];t.beginPath(),t.arc(s.x,s.y,5,0,2*Math.PI),t.fill(),t.stroke(),t.beginPath(),t.arc(r.x,r.y,5,0,2*Math.PI),t.fill(),t.stroke()}t.restore()}static computeBezierCurves(t){if(t.shapeType!==de.Curve)return[];const e=t.points,n=[];for(let o=1;o<e.length-2;o=o+3){const s=e[o-1],r=e[o],i=e[o+1],a=e[o+2],c=new ui(s,r,i,a);n.push(c)}return n}static computeBezierCurvesByPoints(t){const e=[];for(let n=1;n<t.length-2;n=n+3){const o=t[n-1],s=t[n],r=t[n+1],i=t[n+2],a=new ui(o,s,r,i);e.push(a)}return e}static computeCurveControlPoints(t){const e=this.computeBezierCurves(t),n=[];for(const o of e)n.push(o.getHalfTPos());return n}static computeCurveEndPoints(t){if(t.shapeType!==de.Curve)return[];const e=t.points,n=[];for(let o=1;o<e.length-2;o=o+3){const s=e[o-1],r=e[o+2];n.push(s),n.push(r)}return n}static pressMeta(t){return pi.getOS()===Jt.MacOS?t.originEvent.metaKey:t.originEvent.ctrlKey}static getAllChildren(t,e){const n=t.children;for(const o of n)e.add(o),this.getAllChildren(o,e)}static judgeNodeCanBeStretch(t){var e;return!(t.type===v.SlideContainer||t.type===v.Section&&((e=t.parent)==null?void 0:e.type)===v.SlideContainer)}static getSlideContainerChildNode(t,e,n){const o=t.getChildIdByIndex(e);if(!o)return null;const s=n.nodeManager.getNode(o);return s||null}static filterSlideContainerNodes(t,e){const n=t.docState.docMode,o=t.docState.slideStatus,s=o.slideContainer;if(n===he.SLIDE_EDIT&&s){const r=this.getSlideContainerChildNode(s,o.currentIndex,t);if(!r)return e;const i=new Set;M.getAllChildren(r,i);const a=[];for(const c of e)i.has(c)&&a.push(c);return a}return e}static getSlideInfo(t,{renderManager:e,nodeManager:n}){return new Promise((o,s)=>{const r=t.getBounds(),i=r.maxX-r.minX,a=r.maxY-r.minY,c=new Set([t]);M.getAllChildren(t,c),e.exportWorker.exportToOfflineCanvasByFilterNodes(r,n,1,"",c).toBlob(d=>{if(d){const u=URL.createObjectURL(d),g={id:t.id,blobUrl:u,width:i,height:a};o(g)}else console.error("导出图片错误"),s("导出图片错误")})})}}class en{constructor(t,e){p(this,"type",v.Shape);p(this,"id");p(this,"parent",null);p(this,"children",new Set);p(this,"zIndex",0);p(this,"graphicContext");p(this,"props",new Map);p(this,"transform",re.generateMatrix());this.id=t,this.graphicContext=e}get baseProps(){return this.props.get(I.Base)}get globalBaseProps(){const t=this.baseProps.clone(),e=this.globalPos;return t.x=e.x,t.y=e.y,t}get pos(){const t=this.baseProps;return new m(t.x,t.y)}get globalPos(){return this.globalTransform().crossPoint(new m)}setParent(t){this.parent=t,t.children.add(this)}updateProps(t){for(const e of t){if(e.type===void 0)continue;const n=this.props.get(e.type);n&&n.update(e)}}getProp(t){const e=this.props.get(t);return e||null}updateTransformMatrix(){const t=this.baseProps,e=re.generateMatrix().rotate(t.angle),n=re.generateMatrix().translate(t.x,t.y);this.transform=n.crossProduct(e)}contains(t,e=1){const{width:n,height:o}=this.baseProps,s=this.toLocal(t);return M.rectContains(s,new D(0,0,n,o))}canQuickCreate(){return!!this.canBeConnected()}canBeConnected(){return!0}getConnectAnchor(){return[]}borderContains(t,e){return null}draw(){return this.drawOnGLCtx(this.graphicContext)}globalTransform(){const t=[this];let e=this.parent;for(;e;)t.push(e),e=e.parent;let n=re.generateMatrix();for(const o of t.reverse())n=n.crossProduct(o.transform);return n}getRectNode(){const{width:t,height:e}=this.baseProps,n=this.getProp(I.Border),o=n?n.width:0,s=[new m(-o,-o),new m(t+o,-o),new m(t+o,e+o),new m(-o,e+o)],r=[];for(const a of s)r.push(this.toGlobal(a));const i=M.getBoundsByPoints(r);return i.id=this.id,i}getBounds(){const t=this.baseProps,e={id:this.id,minX:0,minY:0,maxX:t.width,maxY:t.height},n=[new m(e.minX,e.minY),new m(e.maxX,e.minY),new m(e.maxX,e.maxY),new m(e.minX,e.maxY)],o=[];for(const r of n)o.push(this.toGlobal(r));const s=M.getBoundsByPoints(o);return s.id=this.id,s}getStretchMinSize(){return{x:10,y:10}}overlapRect(t){return M.overlapRect(t,this.getBounds())}isEmptyText(){return!0}toLocal(t){return this.globalTransform().inverseMatrix().crossPoint(t)}toGlobal(t){return this.globalTransform().crossPoint(t)}modifyPosInEditing(t){return!1}resetFromEditing(){}serializeTo(){const t=M.convertPropsToCapInfo(this.props),e=JSON.parse(JSON.stringify(t));return{type:this.type,zIndex:this.zIndex,id:this.id,parentId:"",capInfo:e,children:[]}}}class kh{fallbackDraw(t,e){const{width:n,height:o}=t.baseProps;e.save();const{a:s,b:r,c:i,d:a,e:c,f:h}=t.globalTransform();e.transform(s,r,i,a,c,h),e.beginPath();let d=!1;const u=n/3,g=o/3;for(let f=0;f<3;f++)for(let y=0;y<3;y++){const P=d?Ht:bs,b=u*f,w=g*y;e.fillStyle=P,e.fillRect(b,w,u,g),d=!d}e.restore()}}class fe{constructor(t=0,e=0){this.x=t,this.y=e}clone(){return new this.constructor(this.x,this.y)}add(t){return new this.constructor(this.x+t.x,this.y+t.y)}subtract(t){return new this.constructor(this.x-t.x,this.y-t.y)}multiply(t){return new this.constructor(this.x*t,this.y*t)}divide(t){return new this.constructor(this.x/t,this.y/t)}equals(t){return this.x===t.x&&this.y===t.y}precisionEquals(t,e){return Math.abs(this.x-t.x)<e&&Math.abs(this.y-t.y)<e}lerp(t,e){const n=1-e;return new this.constructor(this.x*n+t.x*e,this.y*n+t.y*e)}distanceFrom(t){const e=this.x-t.x,n=this.y-t.y;return Math.sqrt(e*e+n*n)}min(t){return new this.constructor(Math.min(this.x,t.x),Math.min(this.y,t.y))}max(t){return new this.constructor(Math.max(this.x,t.x),Math.max(this.y,t.y))}transform(t){return new this.constructor(t.a*this.x+t.c*this.y+t.e,t.b*this.x+t.d*this.y+t.f)}toString(){return`point(${this.x},${this.y})`}}class rt{constructor(t=0,e=0){this.x=t,this.y=e}static fromPoints(t,e){return new rt(e.x-t.x,e.y-t.y)}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}magnitude(){return this.x*this.x+this.y*this.y}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}determinant(t){return this.x*t.y-this.y*t.x}unit(){return this.divide(this.length())}add(t){return new this.constructor(this.x+t.x,this.y+t.y)}subtract(t){return new this.constructor(this.x-t.x,this.y-t.y)}multiply(t){return new this.constructor(this.x*t,this.y*t)}divide(t){return new this.constructor(this.x/t,this.y/t)}angleBetween(t){let e=this.dot(t)/(this.length()*t.length());e=Math.max(-1,Math.min(e,1));const n=Math.acos(e);return this.cross(t)<0?-n:n}perp(){return new this.constructor(-this.y,this.x)}perpendicular(t){return this.subtract(this.project(t))}project(t){const e=this.dot(t)/t.dot(t);return t.multiply(e)}transform(t){return new this.constructor(t.a*this.x+t.c*this.y,t.b*this.x+t.d*this.y)}equals(t){return this.x===t.x&&this.y===t.y}precisionEquals(t,e){return Math.abs(this.x-t.x)<e&&Math.abs(this.y-t.y)<e}toString(){return`vector(${this.x},${this.y})`}}class pt{constructor(t=1,e=0,n=0,o=1,s=0,r=0){this.a=t,this.b=e,this.c=n,this.d=o,this.e=s,this.f=r}static translation(t,e){return new pt(1,0,0,1,t,e)}static scaling(t){return new pt(t,0,0,t,0,0)}static scalingAt(t,e){return new pt(t,0,0,t,e.x-e.x*t,e.y-e.y*t)}static nonUniformScaling(t,e){return new pt(t,0,0,e,0,0)}static nonUniformScalingAt(t,e,n){return new pt(t,0,0,e,n.x-n.x*t,n.y-n.y*e)}static rotation(t){const e=Math.cos(t),n=Math.sin(t);return new pt(e,n,-n,e,0,0)}static rotationAt(t,e){const n=Math.cos(t),o=Math.sin(t);return new pt(n,o,-o,n,e.x-e.x*n+e.y*o,e.y-e.y*n-e.x*o)}static rotationFromVector(t){const e=t.unit(),n=e.x,o=e.y;return new pt(n,o,-o,n,0,0)}static xFlip(){return new pt(-1,0,0,1,0,0)}static yFlip(){return new pt(1,0,0,-1,0,0)}static xSkew(t){const e=Math.tan(t);return new pt(1,0,e,1,0,0)}static ySkew(t){const e=Math.tan(t);return new pt(1,e,0,1,0,0)}multiply(t){return this.isIdentity()?t:t.isIdentity()?this:new this.constructor(this.a*t.a+this.c*t.b,this.b*t.a+this.d*t.b,this.a*t.c+this.c*t.d,this.b*t.c+this.d*t.d,this.a*t.e+this.c*t.f+this.e,this.b*t.e+this.d*t.f+this.f)}inverse(){if(this.isIdentity())return this;const t=this.a*this.d-this.b*this.c;if(t===0)throw new Error("Matrix is not invertible");const e=1/t,n=this.f*this.c-this.e*this.d,o=this.e*this.b-this.f*this.a;return new this.constructor(this.d*e,-this.b*e,-this.c*e,this.a*e,n*e,o*e)}translate(t,e){return new this.constructor(this.a,this.b,this.c,this.d,this.a*t+this.c*e+this.e,this.b*t+this.d*e+this.f)}scale(t){return new this.constructor(this.a*t,this.b*t,this.c*t,this.d*t,this.e,this.f)}scaleAt(t,e){const n=e.x-t*e.x,o=e.y-t*e.y;return new this.constructor(this.a*t,this.b*t,this.c*t,this.d*t,this.a*n+this.c*o+this.e,this.b*n+this.d*o+this.f)}scaleNonUniform(t,e){return new this.constructor(this.a*t,this.b*t,this.c*e,this.d*e,this.e,this.f)}scaleNonUniformAt(t,e,n){const o=n.x-t*n.x,s=n.y-e*n.y;return new this.constructor(this.a*t,this.b*t,this.c*e,this.d*e,this.a*o+this.c*s+this.e,this.b*o+this.d*s+this.f)}rotate(t){const e=Math.cos(t),n=Math.sin(t);return new this.constructor(this.a*e+this.c*n,this.b*e+this.d*n,this.a*-n+this.c*e,this.b*-n+this.d*e,this.e,this.f)}rotateAt(t,e){const n=Math.cos(t),o=Math.sin(t),s=e.x,r=e.y,i=this.a*n+this.c*o,a=this.b*n+this.d*o,c=this.c*n-this.a*o,h=this.d*n-this.b*o;return new this.constructor(i,a,c,h,(this.a-i)*s+(this.c-c)*r+this.e,(this.b-a)*s+(this.d-h)*r+this.f)}rotateFromVector(t){const e=t.unit(),n=e.x,o=e.y;return new this.constructor(this.a*n+this.c*o,this.b*n+this.d*o,this.a*-o+this.c*n,this.b*-o+this.d*n,this.e,this.f)}flipX(){return new this.constructor(-this.a,-this.b,this.c,this.d,this.e,this.f)}flipY(){return new this.constructor(this.a,this.b,-this.c,-this.d,this.e,this.f)}skewX(t){const e=Math.tan(t);return new this.constructor(this.a,this.b,this.c+this.a*e,this.d+this.b*e,this.e,this.f)}skewY(t){const e=Math.tan(t);return new this.constructor(this.a+this.c*e,this.b+this.d*e,this.c,this.d,this.e,this.f)}isIdentity(){return this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.e===0&&this.f===0}isInvertible(){return this.a*this.d-this.b*this.c!==0}getScale(){return{scaleX:Math.sqrt(this.a*this.a+this.c*this.c),scaleY:Math.sqrt(this.b*this.b+this.d*this.d)}}getDecomposition(){const t=(this.a+this.d)*.5,e=(this.a-this.d)*.5,n=(this.b+this.c)*.5,o=(this.b-this.c)*.5,s=Math.sqrt(t*t+o*o),r=Math.sqrt(e*e+n*n),i=s+r,a=s-r,c=Math.atan2(n,e),h=Math.atan2(o,t),d=(h-c)*.5,u=(h+c)*.5;return{translation:this.constructor.translation(this.e,this.f),rotation:this.constructor.rotation(u),scale:this.constructor.nonUniformScaling(i,a),rotation0:this.constructor.rotation(d)}}equals(t){return this.a===t.a&&this.b===t.b&&this.c===t.c&&this.d===t.d&&this.e===t.e&&this.f===t.f}precisionEquals(t,e){return Math.abs(this.a-t.a)<e&&Math.abs(this.b-t.b)<e&&Math.abs(this.c-t.c)<e&&Math.abs(this.d-t.d)<e&&Math.abs(this.e-t.e)<e&&Math.abs(this.f-t.f)<e}toString(){return`matrix(${this.a},${this.b},${this.c},${this.d},${this.e},${this.f})`}}pt.IDENTITY=new pt,pt.IDENTITY.isIdentity=()=>!0;function St(l){return typeof l=="number"?l?l<0?-1:1:l===l?l:NaN:NaN}class Ue{constructor(...t){this.coefs=[];for(let e=t.length-1;e>=0;e--)this.coefs.push(t[e]);this._variable="t",this._s=0}static interpolate(t,e,n,o,s){if(t.constructor!==Array||e.constructor!==Array)throw new TypeError("xs and ys must be arrays");if(isNaN(n)||isNaN(o)||isNaN(s))throw new TypeError("n, offset, and x must be numbers");let r,i,a=0;const c=new Array(n),h=new Array(n);let d=0,u=Math.abs(s-t[o]);for(r=0;r<n;r++){const g=Math.abs(s-t[o+r]);g<u&&(d=r,u=g),c[r]=h[r]=e[o+r]}i=e[o+d],d--;for(let g=1;g<n;g++){for(r=0;r<n-g;r++){const f=t[o+r]-s,y=t[o+r+g]-s,P=c[r+1]-h[r];let b=f-y;if(b===0)throw new RangeError("Unable to interpolate polynomial. Two numbers in n were identical (to within roundoff)");b=P/b,h[r]=y*b,c[r]=f*b}a=2*(d+1)<n-g?c[d+1]:h[d--],i+=a}return{y:i,dy:a}}static newtonSecantBisection(t,e,n,o,s,r){let i,a=0,c,h=0,d,u,g,f,y;i=t;const P=Math.pow(10,-14),b=typeof s=="number"&&typeof r=="number";if(b){if(s>r)throw new RangeError("Min must be greater than max");if(f=e(s),y=e(r),St(f)===St(y))throw new RangeError("Y values of bounds must be of opposite sign")}const w=function(){return Math.abs(d)<=P*Math.abs(i)||h===i-d-i};for(let L=0;L<o;L++){if(c=n(i),c===0){if(a===0)throw new RangeError("df(x) is zero");c=a}if(a=c,g=e(i),d=g/c,u=i-d,w())break;if(b){if(St(g)===St(y))r=i,y=g;else if(St(g)===St(f))s=i,f=g;else{i=u;break}if(u<s||u>r){if(St(f)===St(y))break;const B=50,H=.25,E=y-f,X=r-s;if(E===0?d=i-(s+X*.5):Math.abs(E/Math.min(f,y))>B?d=i-(s+X*(.5+(Math.abs(f)<Math.abs(y)?-H:H))):d=i-(s-f/E*X),u=i-d,w())break}}h=i-u,i=u}return i}clone(){const t=new Ue;return t.coefs=this.coefs.slice(),t}eval(t){if(isNaN(t))throw new TypeError(`Parameter must be a number. Found '${t}'`);let e=0;for(let n=this.coefs.length-1;n>=0;n--)e=e*t+this.coefs[n];return e}add(t){const e=new Ue,n=this.getDegree(),o=t.getDegree(),s=Math.max(n,o);for(let r=0;r<=s;r++){const i=r<=n?this.coefs[r]:0,a=r<=o?t.coefs[r]:0;e.coefs[r]=i+a}return e}multiply(t){const e=new Ue;for(let n=0;n<=this.getDegree()+t.getDegree();n++)e.coefs.push(0);for(let n=0;n<=this.getDegree();n++)for(let o=0;o<=t.getDegree();o++)e.coefs[n+o]+=this.coefs[n]*t.coefs[o];return e}divideEqualsScalar(t){for(let e=0;e<this.coefs.length;e++)this.coefs[e]/=t}simplifyEquals(t=1e-12){for(let e=this.getDegree();e>=0&&Math.abs(this.coefs[e])<=t;e--)this.coefs.pop()}removeZerosEquals(t=1e-15){const e=this.coefs,n=10*t*Math.abs(e.reduce((o,s)=>Math.abs(s)>Math.abs(o)?s:o));for(let o=0;o<e.length-1;o++)Math.abs(e[o])<n&&(e[o]=0);return this}monicEquals(){const t=this.coefs;return t[t.length-1]!==1&&this.divideEqualsScalar(t[t.length-1]),this}toString(){const t=[],e=[];for(let o=this.coefs.length-1;o>=0;o--){let s=Math.round(this.coefs[o]*1e3)/1e3;if(s!==0){const r=s<0?" - ":" + ";s=Math.abs(s),o>0&&(s===1?s=this._variable:s+=this._variable),o>1&&(s+="^"+o),e.push(r),t.push(s)}}e[0]=e[0]===" + "?"":"-";let n="";for(let o=0;o<t.length;o++)n+=e[o]+t[o];return n}bisection(t,e,n=1e-6,o=15){let s=this.eval(t),r=this.eval(e),i;if(Math.abs(s)<=n)i=t;else if(Math.abs(r)<=n)i=e;else if(s*r<=0){const a=Math.log(e-t),c=Math.LN10*o,h=Math.ceil((a+c)/Math.LN2);for(let d=0;d<h;d++){i=.5*(t+e);const u=this.eval(i);if(Math.abs(u)<=n)break;u*s<0?(e=i,r=u):(t=i,s=u)}}return i}trapezoid(t,e,n){if(isNaN(t)||isNaN(e)||isNaN(n))throw new TypeError("Parameters must be numbers");const o=e-t;if(n===1){const s=this.eval(t),r=this.eval(e);this._s=.5*o*(s+r)}else{const s=1<<n-2,r=o/s;let i=t+.5*r,a=0;for(let c=0;c<s;c++)a+=this.eval(i),i+=r;this._s=.5*(this._s+o*a/s)}if(isNaN(this._s))throw new TypeError("this._s is NaN");return this._s}simpson(t,e){if(isNaN(t)||isNaN(e))throw new TypeError("Parameters must be numbers");const n=e-t;let o=.5*n*(this.eval(t)+this.eval(e)),s=o,r=4*o/3,i=r,a=o;const c=1e-7;let h=1;for(let d=2;d<=20;d++){const u=n/h;let g=t+.5*u,f=0;for(let y=1;y<=h;y++)f+=this.eval(g),g+=u;if(s=.5*(s+n*f/h),o=s,r=(4*o-a)/3,Math.abs(r-i)<c*Math.abs(i))break;i=r,a=o,h<<=1}return r}romberg(t,e){if(isNaN(t)||isNaN(e))throw new TypeError("Parameters must be numbers");const n=20,o=3,s=1e-6,r=new Array(n+1),i=new Array(n+1);let a={y:0,dy:0};i[0]=1;for(let c=1;c<=n&&(r[c-1]=this.trapezoid(t,e,c),!(c>=o&&(a=Ue.interpolate(i,r,o,c-o,0),Math.abs(a.dy)<=s*a.y)));c++)r[c]=r[c-1],i[c]=.25*i[c-1];return a.y}zeroErrorEstimate(t){const e=this,n=1e-15;if(typeof t>"u"){const r=e.bounds();t=Math.max(Math.abs(r.minX),Math.abs(r.maxX))}if(t<.001)return 2*Math.abs(e.eval(n));const o=e.coefs.length-1,s=e.coefs[o];return 10*n*e.coefs.reduce((r,i,a)=>{const c=i/s*Math.pow(t,a);return c>r?c:r},0)}boundsUpperRealFujiwara(){let t=this.coefs;const e=t.length-1,n=t[e];n!==1&&(t=this.coefs.map(c=>c/n));const o=t.map((c,h)=>h<e?Math.pow(Math.abs(h===0?c/2:c),1/(e-h)):c);let s;const r=function(c,h,d){return s(d)&&(c.max<h?(c.nearmax=c.max,c.max=h):c.nearmax<h&&(c.nearmax=h)),c};s=function(c){return c<e&&t[c]<0};const i=o.reduce(r,{max:0,nearmax:0});return s=function(c){return c<e&&(e%2===c%2?t[c]<0:t[c]>0)},{negX:-2*o.reduce(r,{max:0,nearmax:0}).max,posX:2*i.max}}boundsLowerRealFujiwara(){const t=new Ue;t.coefs=this.coefs.slice().reverse();const e=t.boundsUpperRealFujiwara();return e.negX=1/e.negX,e.posX=1/e.posX,e}bounds(){const t=this.boundsUpperRealFujiwara(),e={minX:t.negX,maxX:t.posX};return t.negX===0&&t.posX===0||(t.negX===0?e.minX=this.boundsLowerRealFujiwara().posX:t.posX===0&&(e.maxX=this.boundsLowerRealFujiwara().negX),e.minX>e.maxX&&(e.minX=e.maxX=0)),e}boundUpperAbsRouche(){const t=this.coefs,e=t.length-1;return 1+t.reduce((o,s,r)=>r!==e?(s=Math.abs(s),o<s?s:o):o,0)/Math.abs(t[e])}boundLowerAbsRouche(){const t=this.coefs,e=t.reduce((n,o,s)=>s!==0?(o=Math.abs(o),n<o?o:n):n,0);return Math.abs(t[0])/(Math.abs(t[0])+e)}boundsRealLaguerre(){const t=this.coefs,e=t.length-1,n=-t[e-1]/(e*t[e]),o=t[e-1]*t[e-1]-2*e/(e-1)*t[e]*t[e-2];let s=(e-1)/(e*t[e])*Math.sqrt(o);return s<0&&(s=-s),{minX:n-s,maxX:n+s}}countRootsDescartes(){const t=this.coefs,e=t.length-1,n=t.reduce((o,s,r)=>(o.prev_a!==0&&s!==0&&(o.prev_a<0==s>0&&o.pos++,r%2===0!=o.prev_a<0==(r%2===1!=s>0)&&o.neg++),o.prev_a=s,o),{pos:0,neg:0,prev_a:0});return{maxRealPos:n.pos,maxRealNeg:n.neg,minComplex:e-(n.pos+n.neg)}}getDegree(){return this.coefs.length-1}getDerivative(){const t=new Ue;for(let e=1;e<this.coefs.length;e++)t.coefs.push(e*this.coefs[e]);return t}getRoots(){let t;switch(this.simplifyEquals(),this.getDegree()){case 0:t=[];break;case 1:t=this.getLinearRoot();break;case 2:t=this.getQuadraticRoots();break;case 3:t=this.getCubicRoots();break;case 4:t=this.getQuarticRoots();break;default:t=[]}return t}getRootsInInterval(t,e){const n=[];function o(s){typeof s=="number"&&n.push(s)}if(this.getDegree()===0)throw new RangeError("Unexpected empty polynomial");if(this.getDegree()===1)o(this.bisection(t,e));else{const r=this.getDerivative().getRootsInInterval(t,e);if(r.length>0){o(this.bisection(t,r[0]));for(let i=0;i<=r.length-2;i++)o(this.bisection(r[i],r[i+1]));o(this.bisection(r[r.length-1],e))}else o(this.bisection(t,e))}return n}getLinearRoot(){const t=[],e=this.coefs[1];return e!==0&&t.push(-this.coefs[0]/e),t}getQuadraticRoots(){const t=[];if(this.getDegree()===2){const e=this.coefs[2],n=this.coefs[1]/e,o=this.coefs[0]/e,s=n*n-4*o;if(s>0){const r=Math.sqrt(s);t.push(.5*(-n+r)),t.push(.5*(-n-r))}else s===0&&t.push(.5*-n)}return t}getCubicRoots(){const t=[];if(this.getDegree()===3){const e=this.coefs[3],n=this.coefs[2]/e,o=this.coefs[1]/e,s=this.coefs[0]/e,r=(3*o-n*n)/3,i=(2*n*n*n-9*o*n+27*s)/27,a=n/3;let c=i*i/4+r*r*r/27;const h=i/2,d=this.zeroErrorEstimate();if(Math.abs(c)<=d&&(c=0),c>0){const u=Math.sqrt(c);let g,f=-h+u;f>=0?g=Math.pow(f,1/3):g=-Math.pow(-f,1/3),f=-h-u,f>=0?g+=Math.pow(f,1/3):g-=Math.pow(-f,1/3),t.push(g-a)}else if(c<0){const u=Math.sqrt(-r/3),g=Math.atan2(Math.sqrt(-c),-h)/3,f=Math.cos(g),y=Math.sin(g),P=Math.sqrt(3);t.push(2*u*f-a),t.push(-u*(f+P*y)-a),t.push(-u*(f-P*y)-a)}else{let u;h>=0?u=-Math.pow(h,1/3):u=Math.pow(-h,1/3),t.push(2*u-a),t.push(-u-a)}}return t}getQuarticRoots(){let t=[];const e=this.getDegree();if(e===4){const n=new Ue;n.coefs=this.coefs.slice(),n.divideEqualsScalar(n.coefs[e]);const o=1e-15;Math.abs(n.coefs[0])<10*o*Math.abs(n.coefs[3])&&(n.coefs[0]=0);const s=n.getDerivative(),r=s.getRoots().sort((w,L)=>w-L),i=[],a=r.length-1,c=this.bounds(),h=Math.max(Math.abs(c.minX),Math.abs(c.maxX)),d=this.zeroErrorEstimate(h);for(let w=0;w<=a;w++)i.push(n.eval(r[w]));for(let w=0;w<=a;w++)Math.abs(i[w])<d&&(i[w]=0);let u=0;const g=Math.max(.1*(c.maxX-c.minX)/e,o),f=[],y=[];if(a>-1){for(i[0]!==0?St(i[0])!==St(n.eval(r[0]-g)-i[0])&&(f.push(r[0]-g),y.push([c.minX,r[0]])):(t.push(r[0],r[0]),u++);u<a;u++)i[u+1]===0?(t.push(r[u+1],r[u+1]),u++):St(i[u])!==St(i[u+1])&&(f.push((r[u]+r[u+1])/2),y.push([r[u],r[u+1]]));i[a]!==0&&St(i[a])!==St(n.eval(r[a]+g)-i[a])&&(f.push(r[a]+g),y.push([r[a],c.maxX]))}const P=function(w){return n.eval(w)},b=function(w){return s.eval(w)};if(f.length>0)for(u=0;u<f.length;u++)f[u]=Ue.newtonSecantBisection(f[u],P,b,32,y[u][0],y[u][1]);t=t.concat(f)}return t}}class gt{constructor(t,e){this.type=t,this.text=e}typeis(t){return this.type===t}}gt.UNDEFINED=0,gt.COMMAND=1,gt.NUMBER=2,gt.EOD=3;class Nh{constructor(t){t==null&&(t=""),this.setPathData(t)}setPathData(t){if(typeof t!="string")throw new TypeError("The first parameter must be a string");this._pathData=t}getNextToken(){let t=null,e=this._pathData;for(;t===null;)if(e===null||e==="")t=new gt(gt.EOD,"");else if(e.match(/^([ \t\r\n,]+)/))e=e.substr(RegExp.$1.length);else if(e.match(/^([AaCcHhLlMmQqSsTtVvZz])/))t=new gt(gt.COMMAND,RegExp.$1),e=e.substr(RegExp.$1.length);else if(e.match(/^(([-+]?\d+(\.\d*)?|[-+]?\.\d+)([eE][-+]?\d+)?)/))t=new gt(gt.NUMBER,RegExp.$1),e=e.substr(RegExp.$1.length);else throw new SyntaxError(`Unrecognized path data: ${e}`);return this._pathData=e,t}}const Ts="BOP";class In{constructor(){this._lexer=new Nh,this._handler=null}parseData(t){if(typeof t!="string")throw new TypeError(`The first parameter must be a string: ${t}`);this._handler!==null&&typeof this._handler.beginParse=="function"&&this._handler.beginParse();const e=this._lexer;e.setPathData(t);let n=Ts,o=null,s=e.getNextToken();for(;s.typeis(gt.EOD)===!1;){let r;const i=[];switch(s.type){case gt.COMMAND:if(n===Ts&&s.text!=="M"&&s.text!=="m")throw new SyntaxError(`New paths must begin with a moveto command. Found '${s.text}'`);n=s.text,r=In.PARAMCOUNT[s.text.toUpperCase()],s=e.getNextToken();break;case gt.NUMBER:if(n===Ts)throw new SyntaxError(`New paths must begin with a moveto command. Found '${s.text}'`);r=In.PARAMCOUNT[n.toUpperCase()];break;default:throw new SyntaxError(`Unrecognized command type: ${s.type}`)}for(let a=0;a<r;a++){switch(s.type){case gt.COMMAND:throw new SyntaxError(`Parameter must be a number. Found '${s.text}'`);case gt.NUMBER:i[a]=parseFloat(s.text);break;case gt.EOD:throw new SyntaxError("Unexpected end of string");default:throw new SyntaxError(`Unrecognized parameter type. Found type '${s.type}'`)}s=e.getNextToken()}if(this._handler!==null){const a=this._handler,c=In.METHODNAME[n];(n==="a"||n==="A")&&(i[3]=i[3]!==0,i[4]=i[4]!==0),a!==null&&typeof a[c]=="function"&&a[c](...i)}switch(n){case"M":n="L";break;case"m":n="l";break;case"Z":case"z":n="BOP";break}if(s===o)throw new SyntaxError(`Parser stalled on '${s.text}'`);o=s}this._handler!==null&&typeof this._handler.endParse=="function"&&this._handler.endParse()}setHandler(t){this._handler=t}}In.PARAMCOUNT={A:7,C:6,H:1,L:2,M:2,Q:4,S:4,T:2,V:1,Z:0},In.METHODNAME={A:"arcAbs",a:"arcRel",C:"curvetoCubicAbs",c:"curvetoCubicRel",H:"linetoHorizontalAbs",h:"linetoHorizontalRel",L:"linetoAbs",l:"linetoRel",M:"movetoAbs",m:"movetoRel",Q:"curvetoQuadraticAbs",q:"curvetoQuadraticRel",S:"curvetoCubicSmoothAbs",s:"curvetoCubicSmoothRel",T:"curvetoQuadraticSmoothAbs",t:"curvetoQuadraticSmoothRel",V:"linetoVerticalAbs",v:"linetoVerticalRel",Z:"closePath",z:"closePath"};const Bh=2*Math.PI;function gi(l,t,e,n,o,s,r){o=o*Math.PI/180;const i=Math.cos(o),a=Math.sin(o),c=1e-6,h=l.subtract(t).multiply(.5),d=h.x*i+h.y*a,u=h.x*-a+h.y*i;e=Math.abs(e),n=Math.abs(n);const g=d*d,f=u*u,y=g/(e*e)+f/(n*n);if(y>1){const pe=Math.sqrt(y);e*=pe,n*=pe}const P=e*e,b=n*n,w=P*f,L=b*g;let B=(P*b-w-L)/(w+L);Math.abs(B)<c&&(B=0);let H=Math.sqrt(B);s===r&&(H=-H);const E=l.add(t).multiply(.5),X=H*e*u/n,$=H*-n*d/e,Z=(d-X)/e,se=(d+X)/e,ne=(u-$)/n,ae=(u+$)/n,te=new rt(1,0).angleBetween(new rt(Z,ne));let ce=new rt(Z,ne).angleBetween(new rt(-se,-ae));return r===!1&&(ce-=Bh),[X*i-$*a+E.x,X*a+$*i+E.y,e,n,te,te+ce]}class Rh{constructor(t){this.shapeCreator=t,this.shapes=[],this.firstX=null,this.firstY=null,this.lastX=null,this.lastY=null,this.lastCommand=null}beginParse(){this.shapes=[],this.firstX=null,this.firstY=null,this.lastX=null,this.lastY=null,this.lastCommand=null}addShape(t){this.shapes.push(t)}arcAbs(t,e,n,o,s,r,i){if(t===0||e===0)this.addShape(this.shapeCreator.line(this.lastX,this.lastY,r,i));else{const a=gi(new fe(this.lastX,this.lastY),new fe(r,i),t,e,n,o,s);this.addShape(this.shapeCreator.arc(...a))}this.lastCommand="A",this.lastX=r,this.lastY=i}arcRel(t,e,n,o,s,r,i){if(t===0||e===0)this.addShape(this.shapeCreator.line(this.lastX,this.lastY,this.lastX+r,this.lastY+i));else{const a=gi(new fe(this.lastX,this.lastY),new fe(this.lastX+r,this.lastY+i),t,e,n,o,s);this.addShape(this.shapeCreator.arc(...a))}this.lastCommand="a",this.lastX+=r,this.lastY+=i}curvetoCubicAbs(t,e,n,o,s,r){this.addShape(this.shapeCreator.cubicBezier(this.lastX,this.lastY,t,e,n,o,s,r)),this.lastX=s,this.lastY=r,this.lastCommand="C"}curvetoCubicRel(t,e,n,o,s,r){this.addShape(this.shapeCreator.cubicBezier(this.lastX,this.lastY,this.lastX+t,this.lastY+e,this.lastX+n,this.lastY+o,this.lastX+s,this.lastY+r)),this.lastX+=s,this.lastY+=r,this.lastCommand="c"}linetoHorizontalAbs(t){this.addShape(this.shapeCreator.line(this.lastX,this.lastY,t,this.lastY)),this.lastX=t,this.lastCommand="H"}linetoHorizontalRel(t){this.addShape(this.shapeCreator.line(this.lastX,this.lastY,this.lastX+t,this.lastY)),this.lastX+=t,this.lastCommand="h"}linetoAbs(t,e){this.addShape(this.shapeCreator.line(this.lastX,this.lastY,t,e)),this.lastX=t,this.lastY=e,this.lastCommand="L"}linetoRel(t,e){this.addShape(this.shapeCreator.line(this.lastX,this.lastY,this.lastX+t,this.lastY+e)),this.lastX+=t,this.lastY+=e,this.lastCommand="l"}movetoAbs(t,e){this.firstX=t,this.firstY=e,this.lastX=t,this.lastY=e,this.lastCommand="M"}movetoRel(t,e){this.firstX+=t,this.firstY+=e,this.lastX+=t,this.lastY+=e,this.lastCommand="m"}curvetoQuadraticAbs(t,e,n,o){this.addShape(this.shapeCreator.quadraticBezier(this.lastX,this.lastY,t,e,n,o)),this.lastX=n,this.lastY=o,this.lastCommand="Q"}curvetoQuadraticRel(t,e,n,o){this.addShape(this.shapeCreator.quadraticBezier(this.lastX,this.lastY,this.lastX+t,this.lastY+e,this.lastX+n,this.lastY+o)),this.lastX+=n,this.lastY+=o,this.lastCommand="q"}curvetoCubicSmoothAbs(t,e,n,o){let s,r;if(this.lastCommand.match(/^[SsCc]$/)){const i=this.shapes[this.shapes.length-1].args[2];s=2*this.lastX-i.x,r=2*this.lastY-i.y}else s=this.lastX,r=this.lastY;this.addShape(this.shapeCreator.cubicBezier(this.lastX,this.lastY,s,r,t,e,n,o)),this.lastX=n,this.lastY=o,this.lastCommand="S"}curvetoCubicSmoothRel(t,e,n,o){let s,r;if(this.lastCommand.match(/^[SsCc]$/)){const i=this.shapes[this.shapes.length-1].args[2];s=2*this.lastX-i.x,r=2*this.lastY-i.y}else s=this.lastX,r=this.lastY;this.addShape(this.shapeCreator.cubicBezier(this.lastX,this.lastY,s,r,this.lastX+t,this.lastY+e,this.lastX+n,this.lastY+o)),this.lastX+=n,this.lastY+=o,this.lastCommand="s"}curvetoQuadraticSmoothAbs(t,e){let n,o;if(this.lastCommand.match(/^[QqTt]$/)){const s=this.shapes[this.shapes.length-1].args[1];n=2*this.lastX-s.x,o=2*this.lastY-s.y}else n=this.lastX,o=this.lastY;this.addShape(this.shapeCreator.quadraticBezier(this.lastX,this.lastY,n,o,t,e)),this.lastX=t,this.lastY=e,this.lastCommand="T"}curvetoQuadraticSmoothRel(t,e){let n,o;if(this.lastCommand.match(/^[QqTt]$/)){const s=this.shapes[this.shapes.length-1].args[1];n=2*this.lastX-s.x,o=2*this.lastY-s.y}else n=this.lastX,o=this.lastY;this.addShape(this.shapeCreator.quadraticBezier(this.lastX,this.lastY,n,o,this.lastX+t,this.lastY+e)),this.lastX+=t,this.lastY+=e,this.lastCommand="t"}linetoVerticalAbs(t){this.addShape(this.shapeCreator.line(this.lastX,this.lastY,this.lastX,t)),this.lastY=t,this.lastCommand="V"}linetoVerticalRel(t){this.addShape(this.shapeCreator.line(this.lastX,this.lastY,this.lastX,this.lastY+t)),this.lastY+=t,this.lastCommand="v"}closePath(){this.addShape(this.shapeCreator.line(this.lastX,this.lastY,this.firstX,this.firstY)),this.lastX=this.firstX,this.lastY=this.firstY,this.lastCommand="z"}}const Tn=Math.PI*.5,fi=new In;function tn(l,t){const e=[];for(const[n,o]of l){let s=null;if(o==="Point2D")s=Ls(n,t);else if(o==="Number")s=yi(n,t);else if(o==="Array<Point2D>"||o==="Point2D[]"){const r=[];for(;t.length>0;)r.push(Ls(n,t));r.length>0&&(s=r)}else if(o==="Optional<Number>"||o==="Number?")s=yi(n,t),s===null&&(s=void 0);else throw new TypeError(`Unrecognized value type: ${o}`);if(s!==null)e.push(s);else throw new TypeError(`Unable to extract value for ${n}`)}return e}function yi(l,t){let e=null;if(t.length>0){const n=t[0],o=typeof n;if(o==="number")return t.shift();if(o==="object"){for(const s of l)if(s in n&&typeof n[s]=="number"){e=n[s];break}}}return e}function Ls(l,t){let e=null;if(t.length>0){const n=t[0],o=typeof n;if(o==="number"){if(t.length>1){const s=t.shift(),r=t.shift();e=new fe(s,r)}}else if(Array.isArray(n)&&n.length>1)if(n.length===2){const[s,r]=t.shift();e=new fe(s,r)}else throw new TypeError(`Unhandled array of length ${n.length}`);else if(o==="object"){if("x"in n&&"y"in n)e=new fe(n.x,n.y),t.shift();else for(const s of l)if(Array.isArray(s)){if(s.every(r=>r in n)){e=new fe(n[s[0]],n[s[1]]);break}}else if(s in n){e=Ls([],[n[s]]);break}}}return e}class q{constructor(t,e){this.name=t,this.args=e}static arc(...t){const n=tn([[["center",["centerX","centerY"],["cx","cy"]],"Point2D"],[["radiusX","rx"],"Number"],[["radiusY","ry"],"Number"],[["startRadians"],"Number"],[["endRadians"],"Number"]],t);return new q(q.ARC,n)}static quadraticBezier(...t){const n=tn([[["p1",["p1x","p1y"]],"Point2D"],[["p2",["p2x","p2y"]],"Point2D"],[["p3",["p3x","p3y"]],"Point2D"]],t);return new q(q.QUADRATIC_BEZIER,n)}static cubicBezier(...t){const n=tn([[["p1",["p1x","p1y"]],"Point2D"],[["p2",["p2x","p2y"]],"Point2D"],[["p3",["p3x","p3y"]],"Point2D"],[["p4",["p4x","p4y"]],"Point2D"]],t);return new q(q.CUBIC_BEZIER,n)}static circle(...t){const n=tn([[["center",["centerX","centerY"],["cx","cy"]],"Point2D"],[["radius","r"],"Number"]],t);return new q(q.CIRCLE,n)}static ellipse(...t){const n=tn([[["center",["centerX","centerY"],["cx","cy"]],"Point2D"],[["radiusX","rx"],"Number"],[["radiusY","ry"],"Number"]],t);return new q(q.ELLIPSE,n)}static line(...t){const n=tn([[["p1",["p1x","p1y"],["x1","y1"]],"Point2D"],[["p2",["p2x","p2y"],["x2","y2"]],"Point2D"]],t);return new q(q.LINE,n)}static path(...t){return fi.parseData(t[0]),new q(q.PATH,xi.shapes)}static polygon(...t){const n=tn([[[],"Array<Point2D>"]],t.length===1&&Array.isArray(t[0])?t[0]:t);return new q(q.POLYGON,n)}static polyline(...t){const n=tn([[[],"Array<Point2D>"]],t.length===1&&Array.isArray(t[0])?t[0]:t);return new q(q.POLYLINE,n)}static rectangle(...t){const n=tn([[["topLeft",["x","y"],["left","top"]],"Point2D"],[["size",["width","height"],["w","h"]],"Point2D"],[["radiusX","rx"],"Optional<Number>"],[["radiusY","ry"],"Optional<Number>"]],t),o=n[0],s=n[1];n[1]=new fe(o.x+s.x,o.y+s.y);const r=new q(q.RECTANGLE,n);let i=r.args.pop(),a=r.args.pop();if(a=a===void 0?0:a,i=i===void 0?0:i,a===0&&i===0)return r;const{x:c,y:h}=r.args[0],{x:d,y:u}=r.args[1],g=d-c,f=u-h;a===0&&(a=i),i===0&&(i=a),a>g*.5&&(a=g*.5),i>f*.5&&(i=f*.5);const y=c,P=h,b=c+a,w=h+i,L=d-a,B=u-i,H=d,E=u,X=[q.arc(b,w,a,i,2*Tn,3*Tn),q.line(b,P,L,P),q.arc(L,w,a,i,3*Tn,4*Tn),q.line(H,w,H,B),q.arc(L,B,a,i,0,Tn),q.line(L,E,b,E),q.arc(b,B,a,i,Tn,2*Tn),q.line(y,B,y,w)];return new q(q.PATH,X)}}q.ARC="Arc",q.QUADRATIC_BEZIER="Bezier2",q.CUBIC_BEZIER="Bezier3",q.CIRCLE="Circle",q.ELLIPSE="Ellipse",q.LINE="Line",q.PATH="Path",q.POLYGON="Polygon",q.POLYLINE="Polyline",q.RECTANGLE="Rectangle";const xi=new Rh(q);fi.setHandler(xi);const io=2*Math.PI,Eh=new rt(1,0);function wi(l){return l==null}function Hh(l,t){const e=l[0]*t[1]-t[0]*l[1],n=l[0]*t[2]-t[0]*l[2],o=l[0]*t[3]-t[0]*l[3],s=l[0]*t[4]-t[0]*l[4],r=l[0]*t[5]-t[0]*l[5],i=l[1]*t[2]-t[1]*l[2],a=l[1]*t[4]-t[1]*l[4],c=l[1]*t[5]-t[1]*l[5],h=l[2]*t[3]-t[2]*l[3],d=l[3]*t[4]-t[3]*l[4],u=l[3]*t[5]-t[3]*l[5],g=c+d,f=a-h;return new Ue(e*i-n*n,e*f+o*i-2*n*s,e*g+o*f-s*s-2*n*r,e*u+o*g-2*s*r,o*u-r*r)}function Dh(l){const t=l%io;return t<0?t+io:t}function Oh(l,t,e,n,o,s){if(l.points.length===0)return l;const r=new Y("No Intersection");s<o&&([o,s]=[s,o]),(o<0||s<0)&&(o+=io,s+=io);for(const i of l.points){let a=Dh(Eh.angleBetween(rt.fromPoints(t,i)));a<o&&(a+=io),o<=a&&a<=s&&r.appendPoint(i)}return r.points.length>0&&(r.status="Intersection"),r}function nn(l){const t=l.slice();return t.push(l[0]),t}class Y{constructor(t){this.init(t)}init(t){this.status=t,this.points=[]}static intersect(t,e){let n;if(!wi(t)&&!wi(e))if(t.name==="Path")n=Y.intersectPathShape(t,e);else if(e.name==="Path")n=Y.intersectPathShape(e,t);else if(t.name==="Arc")n=Y.intersectArcShape(t,e);else if(e.name==="Arc")n=Y.intersectArcShape(e,t);else{let o,s;if(t.name<e.name?(o="intersect"+t.name+e.name,s=t.args.concat(e.args)):(o="intersect"+e.name+t.name,s=e.args.concat(t.args)),!(o in Y))throw new TypeError("Intersection not available: "+o);n=Y[o].apply(null,s)}else n=new Y("No Intersection");return n}static intersectPathShape(t,e){const n=new Y("No Intersection");for(const o of t.args){const s=Y.intersect(o,e);n.appendPoints(s.points)}return n.points.length>0&&(n.status="Intersection"),n}static intersectArcShape(t,e){const[n,o,s,r,i]=t.args,a=new q(q.ELLIPSE,[n,o,s]),c=Y.intersect(a,e);return Oh(c,n,o,s,r,i)}static intersectBezier2Bezier2(t,e,n,o,s,r){let i,a;const c=new Y("No Intersection");i=e.multiply(-2);const h=t.add(i.add(n));i=t.multiply(-2),a=e.multiply(2);const d=i.add(a),u=new fe(t.x,t.y);i=s.multiply(-2);const g=o.add(i.add(r));i=o.multiply(-2),a=s.multiply(2);const f=i.add(a),y=new fe(o.x,o.y);i=h.x*d.y-d.x*h.y,a=g.x*d.y-d.x*g.y;const P=f.x*d.y-d.x*f.y,b=d.x*(u.y-y.y)+d.y*(-u.x+y.x),w=g.x*h.y-h.x*g.y,L=f.x*h.y-h.x*f.y,B=h.x*(u.y-y.y)+h.y*(-u.x+y.x),E=new Ue(-w*w,-2*w*L,i*a-L*L-2*w*B,i*P-2*L*B,i*b-B*B).getRoots();for(const X of E)if(0<=X&&X<=1){const $=new Ue(h.x,d.x,u.x-y.x-X*f.x-X*X*g.x);$.simplifyEquals();const Z=$.getRoots(),se=new Ue(h.y,d.y,u.y-y.y-X*f.y-X*X*g.y);se.simplifyEquals();const ne=se.getRoots();if(Z.length>0&&ne.length>0){e:for(const te of Z)if(0<=te&&te<=1){for(let ce=0;ce<ne.length;ce++)if(Math.abs(te-ne[ce])<1e-4){c.points.push(g.multiply(X*X).add(f.multiply(X).add(y)));break e}}}}return c.points.length>0&&(c.status="Intersection"),c}static intersectBezier2Bezier3(t,e,n,o,s,r,i){let a,c,h,d;const u=new Y("No Intersection");a=e.multiply(-2);const g=t.add(a.add(n));a=t.multiply(-2),c=e.multiply(2);const f=a.add(c),y=new fe(t.x,t.y);a=o.multiply(-1),c=s.multiply(3),h=r.multiply(-3),d=a.add(c.add(h.add(i)));const P=new fe(d.x,d.y);a=o.multiply(3),c=s.multiply(-6),h=r.multiply(3),d=a.add(c.add(h));const b=new fe(d.x,d.y);a=o.multiply(-3),c=s.multiply(3),h=a.add(c);const w=new fe(h.x,h.y),L=new fe(o.x,o.y),B=y.x*y.x,H=y.y*y.y,E=f.x*f.x,X=f.y*f.y,$=g.x*g.x,Z=g.y*g.y,se=L.x*L.x,ne=L.y*L.y,ae=w.x*w.x,te=w.y*w.y,ce=b.x*b.x,pe=b.y*b.y,Be=P.x*P.x,Re=P.y*P.y,Te=new Ue(-2*g.x*g.y*P.x*P.y+$*Re+Z*Be,-2*g.x*g.y*b.x*P.y-2*g.x*g.y*b.y*P.x+2*Z*b.x*P.x+2*$*b.y*P.y,-2*g.x*w.x*g.y*P.y-2*g.x*g.y*w.y*P.x-2*g.x*g.y*b.x*b.y+2*w.x*Z*P.x+Z*ce+$*(2*w.y*P.y+pe),2*y.x*g.x*g.y*P.y+2*y.y*g.x*g.y*P.x+f.x*f.y*g.x*P.y+f.x*f.y*g.y*P.x-2*L.x*g.x*g.y*P.y-2*g.x*L.y*g.y*P.x-2*g.x*w.x*g.y*b.y-2*g.x*g.y*w.y*b.x-2*y.x*Z*P.x-2*y.y*$*P.y+2*L.x*Z*P.x+2*w.x*Z*b.x-X*g.x*P.x-E*g.y*P.y+$*(2*L.y*P.y+2*w.y*b.y),2*y.x*g.x*g.y*b.y+2*y.y*g.x*g.y*b.x+f.x*f.y*g.x*b.y+f.x*f.y*g.y*b.x-2*L.x*g.x*g.y*b.y-2*g.x*L.y*g.y*b.x-2*g.x*w.x*g.y*w.y-2*y.x*Z*b.x-2*y.y*$*b.y+2*L.x*Z*b.x-X*g.x*b.x-E*g.y*b.y+ae*Z+$*(2*L.y*b.y+te),2*y.x*g.x*g.y*w.y+2*y.y*g.x*w.x*g.y+f.x*f.y*g.x*w.y+f.x*f.y*w.x*g.y-2*L.x*g.x*g.y*w.y-2*g.x*L.y*w.x*g.y-2*y.x*w.x*Z-2*y.y*$*w.y+2*L.x*w.x*Z-X*g.x*w.x-E*g.y*w.y+2*$*L.y*w.y,-2*y.x*y.y*g.x*g.y-y.x*f.x*f.y*g.y-y.y*f.x*f.y*g.x+2*y.x*g.x*L.y*g.y+2*y.y*L.x*g.x*g.y+f.x*L.x*f.y*g.y+f.x*f.y*g.x*L.y-2*L.x*g.x*L.y*g.y-2*y.x*L.x*Z+y.x*X*g.x+y.y*E*g.y-2*y.y*$*L.y-L.x*X*g.x-E*L.y*g.y+B*Z+H*$+se*Z+$*ne).getRootsInInterval(0,1);for(const ge of Te){const O=new Ue(g.x,f.x,y.x-L.x-ge*w.x-ge*ge*b.x-ge*ge*ge*P.x).getRoots(),G=new Ue(g.y,f.y,y.y-L.y-ge*w.y-ge*ge*b.y-ge*ge*ge*P.y).getRoots();if(O.length>0&&G.length>0){e:for(const _ of O)if(0<=_&&_<=1){for(let Ve=0;Ve<G.length;Ve++)if(Math.abs(_-G[Ve])<1e-4){u.points.push(P.multiply(ge*ge*ge).add(b.multiply(ge*ge).add(w.multiply(ge).add(L))));break e}}}}return u.points.length>0&&(u.status="Intersection"),u}static intersectBezier2Circle(t,e,n,o,s){return Y.intersectBezier2Ellipse(t,e,n,o,s,s)}static intersectBezier2Ellipse(t,e,n,o,s,r){let i;const a=new Y("No Intersection");i=e.multiply(-2);const c=t.add(i.add(n));i=t.multiply(-2);const h=e.multiply(2),d=i.add(h),u=new fe(t.x,t.y),g=s*s,f=r*r,y=new Ue(f*c.x*c.x+g*c.y*c.y,2*(f*c.x*d.x+g*c.y*d.y),f*(2*c.x*u.x+d.x*d.x)+g*(2*c.y*u.y+d.y*d.y)-2*(f*o.x*c.x+g*o.y*c.y),2*(f*d.x*(u.x-o.x)+g*d.y*(u.y-o.y)),f*(u.x*u.x+o.x*o.x)+g*(u.y*u.y+o.y*o.y)-2*(f*o.x*u.x+g*o.y*u.y)-g*f).getRoots();for(const P of y)0<=P&&P<=1&&a.points.push(c.multiply(P*P).add(d.multiply(P).add(u)));return a.points.length>0&&(a.status="Intersection"),a}static intersectBezier2Line(t,e,n,o,s){let r;const i=o.min(s),a=o.max(s),c=new Y("No Intersection");r=e.multiply(-2);const h=t.add(r.add(n));r=t.multiply(-2);const d=e.multiply(2),u=r.add(d),g=new fe(t.x,t.y),f=new rt(o.y-s.y,s.x-o.x),y=o.x*s.y-s.x*o.y,P=new Ue(f.dot(h),f.dot(u),f.dot(g)+y).getRoots();for(const b of P)if(0<=b&&b<=1){const w=t.lerp(e,b),L=e.lerp(n,b),B=w.lerp(L,b);o.x===s.x?i.y<=B.y&&B.y<=a.y&&(c.status="Intersection",c.appendPoint(B)):o.y===s.y?i.x<=B.x&&B.x<=a.x&&(c.status="Intersection",c.appendPoint(B)):i.x<=B.x&&B.x<=a.x&&i.y<=B.y&&B.y<=a.y&&(c.status="Intersection",c.appendPoint(B))}return c}static intersectBezier2Polygon(t,e,n,o){return Y.intersectBezier2Polyline(t,e,n,nn(o))}static intersectBezier2Polyline(t,e,n,o){const s=new Y("No Intersection"),{length:r}=o;for(let i=0;i<r-1;i++){const a=o[i],c=o[i+1],h=Y.intersectBezier2Line(t,e,n,a,c);s.appendPoints(h.points)}return s.points.length>0&&(s.status="Intersection"),s}static intersectBezier2Rectangle(t,e,n,o,s){const r=o.min(s),i=o.max(s),a=new fe(i.x,r.y),c=new fe(r.x,i.y),h=Y.intersectBezier2Line(t,e,n,r,a),d=Y.intersectBezier2Line(t,e,n,a,i),u=Y.intersectBezier2Line(t,e,n,i,c),g=Y.intersectBezier2Line(t,e,n,c,r),f=new Y("No Intersection");return f.appendPoints(h.points),f.appendPoints(d.points),f.appendPoints(u.points),f.appendPoints(g.points),f.points.length>0&&(f.status="Intersection"),f}static intersectBezier3Bezier3(t,e,n,o,s,r,i,a){let c,h,d,u;const g=new Y("No Intersection");c=t.multiply(-1),h=e.multiply(3),d=n.multiply(-3),u=c.add(h.add(d.add(o)));const f=new fe(u.x,u.y);c=t.multiply(3),h=e.multiply(-6),d=n.multiply(3),u=c.add(h.add(d));const y=new fe(u.x,u.y);c=t.multiply(-3),h=e.multiply(3),d=c.add(h);const P=new fe(d.x,d.y),b=new fe(t.x,t.y);c=s.multiply(-1),h=r.multiply(3),d=i.multiply(-3),u=c.add(h.add(d.add(a)));const w=new fe(u.x,u.y);c=s.multiply(3),h=r.multiply(-6),d=i.multiply(3),u=c.add(h.add(d));const L=new fe(u.x,u.y);c=s.multiply(-3),h=r.multiply(3),d=c.add(h);const B=new fe(d.x,d.y),H=new fe(s.x,s.y);c=f.x*y.y-y.x*f.y,h=f.x*P.y-P.x*f.y;const E=f.x*b.y-b.x*f.y+H.x*f.y-f.x*H.y,X=B.x*f.y-f.x*B.y,$=L.x*f.y-f.x*L.y,Z=w.x*f.y-f.x*w.y;u=f.x*P.y-P.x*f.y;const se=f.x*b.y+y.x*P.y-P.x*y.y-b.x*f.y+H.x*f.y-f.x*H.y,ne=B.x*f.y-f.x*B.y,ae=L.x*f.y-f.x*L.y,te=w.x*f.y-f.x*w.y,ce=y.x*b.y-b.x*y.y+H.x*y.y-y.x*H.y,pe=B.x*y.y-y.x*B.y,Be=L.x*y.y-y.x*L.y,Re=w.x*y.y-y.x*w.y,Me=f.x*b.y-b.x*f.y+H.x*f.y-f.x*H.y,Te=B.x*f.y-f.x*B.y,ge=L.x*f.y-f.x*L.y,O=w.x*f.y-f.x*w.y,G=y.x*b.y-b.x*y.y+H.x*y.y-y.x*H.y,j=B.x*y.y-y.x*B.y,_=L.x*y.y-y.x*L.y,Ve=w.x*y.y-y.x*w.y,ut=P.x*b.y-b.x*P.y+H.x*P.y-P.x*H.y,yt=B.x*P.y-P.x*B.y,Nt=L.x*P.y-P.x*L.y,Ft=w.x*P.y-P.x*w.y,ln=new Ue(-Z*te*O,-Z*te*ge-Z*ae*O-$*te*O,-Z*te*Te-Z*ae*ge-$*te*ge-Z*ne*O-$*ae*O-X*te*O,-Z*te*Me-Z*ae*Te-$*te*Te-Z*ne*ge-$*ae*ge-X*te*ge-Z*se*O-$*ne*O-X*ae*O-E*te*O+h*Re*O+Z*u*Ve-c*Re*Ve+c*te*Ft,-Z*ae*Me-$*te*Me-Z*ne*Te-$*ae*Te-X*te*Te-Z*se*ge-$*ne*ge-X*ae*ge-E*te*ge+h*Re*ge-$*se*O-X*ne*O-E*ae*O+h*Be*O+Z*u*_-c*Re*_+$*u*Ve-c*Be*Ve+c*te*Nt+c*ae*Ft,-Z*ne*Me-$*ae*Me-X*te*Me-Z*se*Te-$*ne*Te-X*ae*Te-E*te*Te+h*Re*Te-$*se*ge-X*ne*ge-E*ae*ge+h*Be*ge-X*se*O-E*ne*O+h*pe*O+Z*u*j-c*Re*j+$*u*_-c*Be*_+X*u*Ve-c*pe*Ve+c*te*yt+c*ae*Nt+c*ne*Ft,-Z*se*Me-$*ne*Me-X*ae*Me-E*te*Me+h*Re*Me-$*se*Te-X*ne*Te-E*ae*Te+h*Be*Te-X*se*ge-E*ne*ge+h*pe*ge-E*se*O+h*ce*O+Z*u*G-c*Re*G+$*u*j-c*Be*j+X*u*_-c*pe*_+E*u*Ve-c*ce*Ve+c*te*ut+c*ae*yt+c*ne*Nt-h*u*Ft+c*se*Ft,-$*se*Me-X*ne*Me-E*ae*Me+h*Be*Me-X*se*Te-E*ne*Te+h*pe*Te-E*se*ge+h*ce*ge+$*u*G-c*Be*G+X*u*j-c*pe*j+E*u*_-c*ce*_+c*ae*ut+c*ne*yt-h*u*Nt+c*se*Nt,-X*se*Me-E*ne*Me+h*pe*Me-E*se*Te+h*ce*Te+X*u*G-c*pe*G+E*u*j-c*ce*j+c*ne*ut-h*u*yt+c*se*yt,-E*se*Me+h*ce*Me+E*u*G-c*ce*G-h*u*ut+c*se*ut);ln.simplifyEquals();const On=ln.getRootsInInterval(0,1);for(const $e of On){const eo=new Ue(f.x,y.x,P.x,b.x-H.x-$e*B.x-$e*$e*L.x-$e*$e*$e*w.x);eo.simplifyEquals();const to=eo.getRoots(),mn=new Ue(f.y,y.y,P.y,b.y-H.y-$e*B.y-$e*$e*L.y-$e*$e*$e*w.y);mn.simplifyEquals();const Yt=mn.getRoots();if(to.length>0&&Yt.length>0){e:for(const no of to)if(0<=no&&no<=1){for(let Pn=0;Pn<Yt.length;Pn++)if(Math.abs(no-Yt[Pn])<1e-4){g.points.push(w.multiply($e*$e*$e).add(L.multiply($e*$e).add(B.multiply($e).add(H))));break e}}}}return g.points.length>0&&(g.status="Intersection"),g}static intersectBezier3Circle(t,e,n,o,s,r){return Y.intersectBezier3Ellipse(t,e,n,o,s,r,r)}static intersectBezier3Ellipse(t,e,n,o,s,r,i){let a,c,h,d;const u=new Y("No Intersection");a=t.multiply(-1),c=e.multiply(3),h=n.multiply(-3),d=a.add(c.add(h.add(o)));const g=new fe(d.x,d.y);a=t.multiply(3),c=e.multiply(-6),h=n.multiply(3),d=a.add(c.add(h));const f=new fe(d.x,d.y);a=t.multiply(-3),c=e.multiply(3),h=a.add(c);const y=new fe(h.x,h.y),P=new fe(t.x,t.y),b=r*r,w=i*i,B=new Ue(g.x*g.x*w+g.y*g.y*b,2*(g.x*f.x*w+g.y*f.y*b),2*(g.x*y.x*w+g.y*y.y*b)+f.x*f.x*w+f.y*f.y*b,2*g.x*w*(P.x-s.x)+2*g.y*b*(P.y-s.y)+2*(f.x*y.x*w+f.y*y.y*b),2*f.x*w*(P.x-s.x)+2*f.y*b*(P.y-s.y)+y.x*y.x*w+y.y*y.y*b,2*y.x*w*(P.x-s.x)+2*y.y*b*(P.y-s.y),P.x*P.x*w-2*P.y*s.y*b-2*P.x*s.x*w+P.y*P.y*b+s.x*s.x*w+s.y*s.y*b-b*w).getRootsInInterval(0,1);for(const H of B)u.points.push(g.multiply(H*H*H).add(f.multiply(H*H).add(y.multiply(H).add(P))));return u.points.length>0&&(u.status="Intersection"),u}static intersectBezier3Line(t,e,n,o,s,r){let i,a,c,h;const d=s.min(r),u=s.max(r),g=new Y("No Intersection");i=t.multiply(-1),a=e.multiply(3),c=n.multiply(-3),h=i.add(a.add(c.add(o)));const f=new rt(h.x,h.y);i=t.multiply(3),a=e.multiply(-6),c=n.multiply(3),h=i.add(a.add(c));const y=new rt(h.x,h.y);i=t.multiply(-3),a=e.multiply(3),c=i.add(a);const P=new rt(c.x,c.y),b=new rt(t.x,t.y),w=new rt(s.y-r.y,r.x-s.x),L=s.x*r.y-r.x*s.y,B=new Ue(w.dot(f),w.dot(y),w.dot(P),w.dot(b)+L).getRoots();for(const H of B)if(0<=H&&H<=1){const E=t.lerp(e,H),X=e.lerp(n,H),$=n.lerp(o,H),Z=E.lerp(X,H),se=X.lerp($,H),ne=Z.lerp(se,H);s.x===r.x?d.y<=ne.y&&ne.y<=u.y&&(g.status="Intersection",g.appendPoint(ne)):s.y===r.y?d.x<=ne.x&&ne.x<=u.x&&(g.status="Intersection",g.appendPoint(ne)):d.x<=ne.x&&ne.x<=u.x&&d.y<=ne.y&&ne.y<=u.y&&(g.status="Intersection",g.appendPoint(ne))}return g}static intersectBezier3Polygon(t,e,n,o,s){return Y.intersectBezier3Polyline(t,e,n,o,nn(s))}static intersectBezier3Polyline(t,e,n,o,s){const r=new Y("No Intersection"),{length:i}=s;for(let a=0;a<i-1;a++){const c=s[a],h=s[a+1],d=Y.intersectBezier3Line(t,e,n,o,c,h);r.appendPoints(d.points)}return r.points.length>0&&(r.status="Intersection"),r}static intersectBezier3Rectangle(t,e,n,o,s,r){const i=s.min(r),a=s.max(r),c=new fe(a.x,i.y),h=new fe(i.x,a.y),d=Y.intersectBezier3Line(t,e,n,o,i,c),u=Y.intersectBezier3Line(t,e,n,o,c,a),g=Y.intersectBezier3Line(t,e,n,o,a,h),f=Y.intersectBezier3Line(t,e,n,o,h,i),y=new Y("No Intersection");return y.appendPoints(d.points),y.appendPoints(u.points),y.appendPoints(g.points),y.appendPoints(f.points),y.points.length>0&&(y.status="Intersection"),y}static intersectCircleCircle(t,e,n,o){let s;const r=e+o,i=Math.abs(e-o),a=t.distanceFrom(n);if(a>r)s=new Y("Outside");else if(a<i)s=new Y("Inside");else{s=new Y("Intersection");const c=(e*e-o*o+a*a)/(2*a),h=Math.sqrt(e*e-c*c),d=t.lerp(n,c/a),u=h/a;s.points.push(new fe(d.x-u*(n.y-t.y),d.y+u*(n.x-t.x))),s.points.push(new fe(d.x+u*(n.y-t.y),d.y-u*(n.x-t.x)))}return s}static intersectCircleEllipse(t,e,n,o,s){return Y.intersectEllipseEllipse(t,e,e,n,o,s)}static intersectCircleLine(t,e,n,o){let s;const r=(o.x-n.x)*(o.x-n.x)+(o.y-n.y)*(o.y-n.y),i=2*((o.x-n.x)*(n.x-t.x)+(o.y-n.y)*(n.y-t.y)),a=t.x*t.x+t.y*t.y+n.x*n.x+n.y*n.y-2*(t.x*n.x+t.y*n.y)-e*e,c=i*i-4*r*a;if(c<0)s=new Y("Outside");else if(c===0)s=new Y("Tangent");else{const h=Math.sqrt(c),d=(-i+h)/(2*r),u=(-i-h)/(2*r);(d<0||d>1)&&(u<0||u>1)?d<0&&u<0||d>1&&u>1?s=new Y("Outside"):s=new Y("Inside"):(s=new Y("Intersection"),0<=d&&d<=1&&s.points.push(n.lerp(o,d)),0<=u&&u<=1&&s.points.push(n.lerp(o,u)))}return s}static intersectCirclePolygon(t,e,n){return Y.intersectCirclePolyline(t,e,nn(n))}static intersectCirclePolyline(t,e,n){const o=new Y("No Intersection"),{length:s}=n;let r;for(let i=0;i<s-1;i++){const a=n[i],c=n[i+1];r=Y.intersectCircleLine(t,e,a,c),o.appendPoints(r.points)}return o.points.length>0?o.status="Intersection":o.status=r.status,o}static intersectCircleRectangle(t,e,n,o){const s=n.min(o),r=n.max(o),i=new fe(r.x,s.y),a=new fe(s.x,r.y),c=Y.intersectCircleLine(t,e,s,i),h=Y.intersectCircleLine(t,e,i,r),d=Y.intersectCircleLine(t,e,r,a),u=Y.intersectCircleLine(t,e,a,s),g=new Y("No Intersection");return g.appendPoints(c.points),g.appendPoints(h.points),g.appendPoints(d.points),g.appendPoints(u.points),g.points.length>0?g.status="Intersection":g.status=c.status,g}static intersectEllipseEllipse(t,e,n,o,s,r){const i=[n*n,0,e*e,-2*n*n*t.x,-2*e*e*t.y,n*n*t.x*t.x+e*e*t.y*t.y-e*e*n*n],a=[r*r,0,s*s,-2*r*r*o.x,-2*s*s*o.y,r*r*o.x*o.x+s*s*o.y*o.y-s*s*r*r],h=Hh(i,a).getRoots(),d=.001,u=(i[0]*i[0]+2*i[1]*i[1]+i[2]*i[2])*d,g=(a[0]*a[0]+2*a[1]*a[1]+a[2]*a[2])*d,f=new Y("No Intersection");for(let y=0;y<h.length;y++){const b=new Ue(i[0],i[3]+h[y]*i[1],i[5]+h[y]*(i[4]+h[y]*i[2])).getRoots();for(let w=0;w<b.length;w++){let L=(i[0]*b[w]+i[1]*h[y]+i[3])*b[w]+(i[2]*h[y]+i[4])*h[y]+i[5];Math.abs(L)<u&&(L=(a[0]*b[w]+a[1]*h[y]+a[3])*b[w]+(a[2]*h[y]+a[4])*h[y]+a[5],Math.abs(L)<g&&f.appendPoint(new fe(b[w],h[y])))}}return f.points.length>0&&(f.status="Intersection"),f}static intersectEllipseLine(t,e,n,o,s){let r;const i=new rt(o.x,o.y),a=rt.fromPoints(o,s),c=new rt(t.x,t.y),h=i.subtract(c),d=new rt(a.x/(e*e),a.y/(n*n)),u=new rt(h.x/(e*e),h.y/(n*n)),g=a.dot(d),f=a.dot(u);t=h.dot(u)-1;const y=f*f-g*t;if(y<0)r=new Y("Outside");else if(y>0){const P=Math.sqrt(y),b=(-f-P)/g,w=(-f+P)/g;(b<0||1<b)&&(w<0||1<w)?b<0&&w<0||b>1&&w>1?r=new Y("Outside"):r=new Y("Inside"):(r=new Y("Intersection"),0<=b&&b<=1&&r.appendPoint(o.lerp(s,b)),0<=w&&w<=1&&r.appendPoint(o.lerp(s,w)))}else{const P=-f/g;0<=P&&P<=1?(r=new Y("Intersection"),r.appendPoint(o.lerp(s,P))):r=new Y("Outside")}return r}static intersectEllipsePolygon(t,e,n,o){return Y.intersectEllipsePolyline(t,e,n,nn(o))}static intersectEllipsePolyline(t,e,n,o){const s=new Y("No Intersection"),{length:r}=o;for(let i=0;i<r-1;i++){const a=o[i],c=o[i+1],h=Y.intersectEllipseLine(t,e,n,a,c);s.appendPoints(h.points)}return s.points.length>0&&(s.status="Intersection"),s}static intersectEllipseRectangle(t,e,n,o,s){const r=o.min(s),i=o.max(s),a=new fe(i.x,r.y),c=new fe(r.x,i.y),h=Y.intersectEllipseLine(t,e,n,r,a),d=Y.intersectEllipseLine(t,e,n,a,i),u=Y.intersectEllipseLine(t,e,n,i,c),g=Y.intersectEllipseLine(t,e,n,c,r),f=new Y("No Intersection");return f.appendPoints(h.points),f.appendPoints(d.points),f.appendPoints(u.points),f.appendPoints(g.points),f.points.length>0&&(f.status="Intersection"),f}static intersectLineLine(t,e,n,o){let s;const r=(o.x-n.x)*(t.y-n.y)-(o.y-n.y)*(t.x-n.x),i=(e.x-t.x)*(t.y-n.y)-(e.y-t.y)*(t.x-n.x),a=(o.y-n.y)*(e.x-t.x)-(o.x-n.x)*(e.y-t.y);if(a!==0){const c=r/a,h=i/a;0<=c&&c<=1&&0<=h&&h<=1?(s=new Y("Intersection"),s.points.push(new fe(t.x+c*(e.x-t.x),t.y+c*(e.y-t.y)))):s=new Y("No Intersection")}else r===0||i===0?s=new Y("Coincident"):s=new Y("Parallel");return s}static intersectLinePolygon(t,e,n){return Y.intersectLinePolyline(t,e,nn(n))}static intersectLinePolyline(t,e,n){const o=new Y("No Intersection"),{length:s}=n;for(let r=0;r<s-1;r++){const i=n[r],a=n[r+1],c=Y.intersectLineLine(t,e,i,a);o.appendPoints(c.points)}return o.points.length>0&&(o.status="Intersection"),o}static intersectLineRectangle(t,e,n,o){const s=n.min(o),r=n.max(o),i=new fe(r.x,s.y),a=new fe(s.x,r.y),c=Y.intersectLineLine(s,i,t,e),h=Y.intersectLineLine(i,r,t,e),d=Y.intersectLineLine(r,a,t,e),u=Y.intersectLineLine(a,s,t,e),g=new Y("No Intersection");return g.appendPoints(c.points),g.appendPoints(h.points),g.appendPoints(d.points),g.appendPoints(u.points),g.points.length>0&&(g.status="Intersection"),g}static intersectPolygonPolygon(t,e){return Y.intersectPolylinePolyline(nn(t),nn(e))}static intersectPolygonPolyline(t,e){return Y.intersectPolylinePolyline(nn(t),e)}static intersectPolygonRectangle(t,e,n){return Y.intersectPolylineRectangle(nn(t),e,n)}static intersectPolylinePolyline(t,e){const n=new Y("No Intersection"),{length:o}=t;for(let s=0;s<o-1;s++){const r=t[s],i=t[s+1],a=Y.intersectLinePolyline(r,i,e);n.appendPoints(a.points)}return n.points.length>0&&(n.status="Intersection"),n}static intersectPolylineRectangle(t,e,n){const o=e.min(n),s=e.max(n),r=new fe(s.x,o.y),i=new fe(o.x,s.y),a=Y.intersectLinePolyline(o,r,t),c=Y.intersectLinePolyline(r,s,t),h=Y.intersectLinePolyline(s,i,t),d=Y.intersectLinePolyline(i,o,t),u=new Y("No Intersection");return u.appendPoints(a.points),u.appendPoints(c.points),u.appendPoints(h.points),u.appendPoints(d.points),u.points.length>0&&(u.status="Intersection"),u}static intersectRectangleRectangle(t,e,n,o){const s=t.min(e),r=t.max(e),i=new fe(r.x,s.y),a=new fe(s.x,r.y),c=Y.intersectLineRectangle(s,i,n,o),h=Y.intersectLineRectangle(i,r,n,o),d=Y.intersectLineRectangle(r,a,n,o),u=Y.intersectLineRectangle(a,s,n,o),g=new Y("No Intersection");return g.appendPoints(c.points),g.appendPoints(h.points),g.appendPoints(d.points),g.appendPoints(u.points),g.points.length>0&&(g.status="Intersection"),g}static intersectRayRay(t,e,n,o){let s;const r=(o.x-n.x)*(t.y-n.y)-(o.y-n.y)*(t.x-n.x),i=(e.x-t.x)*(t.y-n.y)-(e.y-t.y)*(t.x-n.x),a=(o.y-n.y)*(e.x-t.x)-(o.x-n.x)*(e.y-t.y);if(a!==0){const c=r/a;s=new Y("Intersection"),s.points.push(new fe(t.x+c*(e.x-t.x),t.y+c*(e.y-t.y)))}else r===0||i===0?s=new Y("Coincident"):s=new Y("Parallel");return s}appendPoint(t){this.points.push(t)}appendPoints(t){this.points=this.points.concat(t)}}class Fn extends en{constructor(){super(...arguments);p(this,"imgBitmap",null);p(this,"fallbackDrawer",new kh);p(this,"broken",!1)}setBroken(e=!0){this.broken=e}setImageBitmap(e){this.imgBitmap=e}get borderProps(){return this.props.get(I.Border)}get cropProps(){return this.props.get(I.Crop)}updateProps(e){super.updateProps(e),e.find(o=>o.type===I.Base)&&this.updateTransformMatrix()}drawOnGLCtx(e){if(!this.imgBitmap){this.broken&&this.fallbackDrawer.fallbackDraw(this,e);return}e.save();const{a:n,b:o,c:s,d:r,e:i,f:a}=this.globalTransform();e.transform(n,o,s,r,i,a),this.clipDrawImage(e,this.imgBitmap),this.clipDrawBorder(e),e.restore()}clipDrawBorder(e){const n=this.borderProps,o=this.cropProps,s=this.baseProps;if(n.color!==""&&n.dashType!==et.None){if(M.setDashLine(n,e),e.strokeStyle=n.color,e.lineWidth=n.width,e.globalAlpha=n.alpha,o.cropType===wt.Circle){const r=.5*Math.min(s.width,s.height);e.beginPath(),e.arc(.5*s.width,.5*s.height,r,0,2*Math.PI),e.stroke();return}if(o.cropType===wt.RoundRect){e.beginPath(),e.roundRect(0,0,s.width,s.height,10),e.stroke();return}e.strokeRect(0,0,s.width,s.height)}}clipDrawImage(e,n){const o=this.cropProps,s=this.baseProps;if(o.cropType===wt.None)e.drawImage(n,0,0,s.width,s.height);else{if(e.save(),o.cropType===wt.RoundRect&&(e.beginPath(),e.roundRect(0,0,s.width,s.height,10),e.clip()),o.cropType===wt.Circle){const b=.5*Math.min(s.width,s.height);e.beginPath(),e.arc(.5*s.width,.5*s.height,b,0,2*Math.PI),e.clip()}const{imgX:r,imgY:i,imgWidth:a,imgHeight:c}=o.cropInfo,h=this.getImgSize(),d=a/h.imgWidth,u=c/h.imgHeight,g=-r/d,f=-i/u,y=s.width/d,P=s.height/u;e.drawImage(n,g,f,y,P,0,0,s.width,s.height),e.restore()}}getImgSize(){if(!this.imgBitmap){console.warn("img bitmap不存在,已经降级处理");const{width:o,height:s}=this.baseProps;return{imgWidth:o,imgHeight:s}}const e=this.imgBitmap.width,n=this.imgBitmap.height;return{imgWidth:e,imgHeight:n}}getOriginImageRect(){const{cropType:e,cropInfo:n}=this.cropProps;if(e===wt.None||!n){const a=this.baseProps;return new D(0,0,a.width,a.height)}const{imgX:o,imgY:s,imgWidth:r,imgHeight:i}=n;return new D(o,s,r,i)}getTextContentRect(){return this.baseProps}getConnectAnchor(){return[new m(.5,0),new m(1,.5),new m(.5,1),new m(0,.5)]}borderContains(e,n){const o=this.toLocal(e),{width:s,height:r}=this.baseProps,i=q.rectangle({top:0,left:0,width:s,height:r}),a=q.line({x:o.x-n,y:o.y},{x:o.x+n,y:o.y}),c=q.line({x:o.x,y:o.y-n},{x:o.x,y:o.y+n});for(const h of[a,c]){const d=Y.intersect(i,h);if(d.points.length>0)return d.points[0]}return null}}class Yn extends Fn{constructor(e,n){super(e,n);p(this,"type",v.IMG);this.props.set(I.Base,new ie),this.props.set(I.Border,new Ae),this.props.set(I.Image,new ro),this.props.set(I.Crop,new Sn)}get imgSrc(){return this.getProp(I.Image).url}static load(e,n,o,s,r,i){const a=new Yn(e,i);return a.type=n,a.zIndex=o,a.setParent(r),a.updateProps(s),a}}class Xh{draw(t,e){const n=t.getDrawPoints();if(n.length<2){console.error("line has no point!");return}const o=n[0],s=n.length>1?n[n.length-1]:{...o};e.beginPath(),e.moveTo(o.x,o.y),e.lineTo(s.x,s.y),e.stroke()}textContentBounds(t){const e=t.baseProps;return{x:e.x,y:e.y,width:e.width,height:e.height}}borderContains(t,e,n){return null}getConnectAnchor(){return[]}}class mi{static lineContainsPoint(t,e,n){const o=t.shapeType,s=[...t.points];return o===de.Line?this.simpleLineContains(s,e,n):t.isPolyLine()?this.polyLineContains(s,e,n):o===de.Curve?this.curveLineContains(s,e,n):!1}static overlapRectNode(t,e){const n=t.shapeType,o=[...t.points],s=q.rectangle({top:e.minY,left:e.minX,width:e.maxX-e.minX,height:e.maxY-e.minY});if(n===de.Line){const r=q.line(o[0],o[o.length-1]);if(Y.intersect(s,r).points.length>0)return!0}if(t.isPolyLine()){const r=q.polyline(o);if(Y.intersect(s,r).points.length>0)return!0}if(n===de.Curve)for(let r=0;r<o.length-2;r=r+3){const i=o[r],a=o[r+1],c=o[r+2],h=o[r+3],d=q.cubicBezier(i,a,c,h);if(Y.intersect(s,d).points.length>0)return!0}return!1}static curveLineContains(t,e,n){for(let o=0;o<t.length-2;o=o+3){const s=t[o],r=t[o+1],i=t[o+2],a=t[o+3],c=q.cubicBezier(s,r,i,a),h=q.circle(e,n);if(Y.intersect(h,c).points.length>0)return!0}return!1}static polyLineContains(t,e,n){const o=q.polyline(t),s=q.circle(e,n);return Y.intersect(s,o).points.length>0}static simpleLineContains(t,e,n){const o=q.line(t[0],t[t.length-1]),s=q.circle(e,n);return Y.intersect(s,o).points.length>0}}class zh{constructor(){p(this,"radius",8)}draw(t,e){const n=t.getDrawPoints();if(n.length<2)return;e.save(),e.beginPath();const o=n[0];e.moveTo(o.x,o.y);for(const s of n)e.lineTo(s.x,s.y);e.stroke(),e.restore()}textContentBounds(t){const e=t.baseProps;return new D(e.x,e.y,e.width,e.height)}borderContains(t,e,n){return null}getConnectAnchor(){return[]}}class Wh{draw(t,e){const n=t.getDrawPoints();if(!(n.length<3)){e.save(),e.beginPath();for(let o=1;o<n.length-2;o=o+3){const s=n[o-1],r=n[o],i=n[o+1],a=n[o+2];e.moveTo(s.x,s.y),e.bezierCurveTo(r.x,r.y,i.x,i.y,a.x,a.y)}e.stroke(),e.restore()}}textContentBounds(t){const e=t.baseProps;return{x:e.x,y:e.y,width:e.width,height:e.height}}borderContains(t,e,n){return null}getConnectAnchor(){return[]}}class Fh{constructor(){p(this,"radius",8)}draw(t,e){const n=t.getDrawPoints();n.length<2||(e.save(),e.beginPath(),t.points.length===2?(e.moveTo(n[0].x,n[0].y),e.lineTo(n[1].x,n[1].y),e.stroke()):this.acrPolyDraw(e,n),e.restore())}textContentBounds(t){const e=t.baseProps;return new D(e.x,e.y,e.width,e.height)}acrPolyDraw(t,e){const n=e[e.length-1],o=this.dealArcPoly(e);for(const s of o)t.moveTo(s.p0.x,s.p0.y),t.lineTo(s.p1.x,s.p1.y),t.arcTo(s.arcDraw.a.x,s.arcDraw.a.y,s.arcDraw.b.x,s.arcDraw.b.y,s.arcDraw.r);t.lineTo(n.x,n.y),t.stroke()}dealArcPoly(t){const e=[];let n=t[0];for(let o=0;o<t.length-2;o=o+1){const s=n,r=t[o+1],i=t[o+2];if(M.judgeHorizon(s,r)){const c=.5*Math.abs(s.x-r.x),h=.5*Math.abs(r.y-i.y),d=c>h?h:c,u=this.radius<d?this.radius:d,g=u,f=r.x>s.x?1:-1,y=i.y>r.y?1:-1;n=new m(r.x,r.y+y*g);const P={p0:s,p1:new m(r.x-f*g,r.y),arcDraw:{a:r,b:n,r:u}};e.push(P)}else{const c=.5*Math.abs(s.y-r.y),h=.5*Math.abs(r.x-i.x),d=c>h?h:c,u=this.radius<d?this.radius:d,g=u,f=r.y>s.y?1:-1,y=i.x>r.x?1:-1;n=new m(r.x+y*g,r.y);const P={p0:s,p1:new m(r.x,r.y-f*g),arcDraw:{a:r,b:n,r:u}};e.push(P)}}return e}borderContains(t,e,n){return null}getConnectAnchor(){return[]}}class Fe{constructor(t,e,n){p(this,"paragraphIndex");p(this,"lineIndex");p(this,"charIndex");this.paragraphIndex=t,this.lineIndex=e,this.charIndex=n}static head(){return new Fe(0,0,-1)}clone(){return new Fe(this.paragraphIndex,this.lineIndex,this.charIndex)}equal(t){return this.paragraphIndex===t.paragraphIndex&&this.lineIndex===t.lineIndex&&this.charIndex===t.charIndex}greaterThan(t){return this.paragraphIndex>t.paragraphIndex?!0:this.paragraphIndex<t.paragraphIndex?!1:this.lineIndex>t.lineIndex?!0:this.lineIndex<t.lineIndex?!1:this.charIndex>t.charIndex?!0:!(this.charIndex<t.charIndex)}}class Cs{constructor(){p(this,"lines",[]);p(this,"index",0);p(this,"x",0);p(this,"y",0);p(this,"width",0);p(this,"height",0);p(this,"paragraphStyle",null)}addLine(t){t.y=this.height,t.index=this.lines.length,this.lines.push(t),this.width=Math.max(t.width,this.width),this.height=this.height+t.height}contains(t){return M.rectContains2(t,{minX:this.x,maxX:this.x+this.width,minY:this.y,maxY:this.y+this.height})}headCursorPosition(){return new Fe(this.index,0,-1)}tailCursorPosition(){if(this.lines.length===0)return new Fe(this.index,-1,-1);const t=this.lines.length-1,n=this.lines[t].getCharLength();return n===0?new Fe(this.index,t,-1):new Fe(this.index,t,n-1)}detect(t){const{x:e,y:n}=t;if(n<0||n>this.height||this.lines.length===0)return null;for(let o=0;o<this.lines.length;o++){const s=this.lines[o];if(n>=s.y&&n<s.y+s.height){const r=new m(t.x-s.x,t.y-s.y),i=s.detect(r);return{lineIndex:s.index,charIndex:i}}}return null}getLine(t){return t<0||this.lines.length===0?null:t>this.lines.length-1?(console.warn("index 超出该段最大数目,fall back处理"),this.lines[this.lines.length-1]):this.lines[t]}draw(t,e){for(const n of this.lines){const o=new m(e.x+this.x,e.y+this.y);n.draw(t,o)}}alignHorizon(t,e){for(const n of this.lines)t===at.Bottom&&(n.x=e-n.width),t===at.Middle&&(n.x=.5*e-.5*n.width)}toString(){let t="";for(const e of this.lines)t+=e.toString();return t+`
|
|
4
|
+
`}toRichTextXML(t){let e="<p>";for(const n of this.lines)e+=n.toRichTextXML(t);return e+"</p>"}prevToRichTextXML(t,e){let n="";for(let o=0;o<t;o++){const s=this.lines[o];n+=s.toRichTextXML(e)}return n}nextToRichTextXML(t,e){let n="";for(let o=t+1;o<this.lines.length;o++){const s=this.lines[o];n+=s.toRichTextXML(e)}return n}}class Gn{constructor(){p(this,"textBlocks",[]);p(this,"index",0);p(this,"x",0);p(this,"y",0);p(this,"width",0);p(this,"height",0);p(this,"boxAscent",0)}contains(t){return M.rectContains2(t,{minX:this.x,maxX:this.x+this.width,minY:this.y,maxY:this.y+this.height})}getCharLength(){let t=0;return this.textBlocks.forEach(e=>t+=e.characters.length),t}detect(t){const{x:e,y:n}=t;if(n<0||e<0)return-1;const o=this.getCharLength();if(n>this.height||e>this.width)return o-1;if(o===0)return-1;let s=0;for(let r=0;r<this.textBlocks.length;r++){const i=this.textBlocks[r];for(let a=0;a<i.characters.length;a++){const c=i.characters[a],h=i.x+c.x+.5*c.width;if(e<h)return s-1;s++}}return o-1}addTextBlock(t){if(this.textBlocks.length>0){const e=this.textBlocks[this.textBlocks.length-1];if(e.fontSize===t.fontSize&&e.fontFamily===t.fontFamily&&e.fontColor===t.fontColor&&e.fontBgColor===t.fontBgColor&&e.bold===t.bold&&e.italic===t.italic&&e.underline===t.underline&&e.strikethrough===t.strikethrough){for(const n of t.characters)e.addCharacter(n);e.text+=t.text,this.width=this.width+t.width,this.height=Math.max(this.height,e.height),this.boxAscent=Math.max(e.height,this.boxAscent);return}}t.x=this.width,t.y=0,this.textBlocks.push(t),this.width=this.width+t.width,this.height=Math.max(this.height,t.height),this.boxAscent=Math.max(t.height,this.boxAscent)}getBlockIndex(t){const e=this.getCharLength();if(t<0||e===0)return this.textBlocks.length>0?{textBlock:this.textBlocks[0],charIndex:-1,blockIndex:0}:null;if(t>e-1){console.warn("index 超出该行最大字符数目,fall back处理");const o=this.textBlocks[this.textBlocks.length-1];return{textBlock:o,charIndex:o.characters.length-1,blockIndex:this.textBlocks.length-1}}let n=0;for(let o=0;o<this.textBlocks.length;o++){const s=this.textBlocks[o];if(t-n<s.characters.length)return{textBlock:s,charIndex:t-n,blockIndex:o};n+=s.characters.length}return null}getCharacter(t){const e=this.getCharLength();if(t<0||e===0)return null;if(t>e-1){console.warn("index 超出该行最大字符数目,fall back处理");const o=this.textBlocks[this.textBlocks.length-1];return{character:o.characters[o.characters.length-1],textBlock:o,charIndex:o.characters.length-1,blockIndex:this.textBlocks.length-1}}let n=0;for(let o=0;o<this.textBlocks.length;o++){const s=this.textBlocks[o];if(t-n<s.characters.length)return{character:s.characters[t-n],textBlock:s,charIndex:t-n,blockIndex:o};n+=s.characters.length}return null}draw(t,e){const n=e.x+this.x,o=e.y+this.y,s=new m(n,o);for(const r of this.textBlocks)r.draw(t,s,this.height)}toString(){let t="";for(const e of this.textBlocks)t+=e.toString();return t}toRichTextXML(t){let e="";for(const n of this.textBlocks)e+=n.toRichTextXML(t);return e}prevToRichTextXML(t,e){let n="";for(let o=0;o<t;o++){const s=this.textBlocks[o];n+=s.toRichTextXML(e)}return n}nextToRichTextXML(t,e){let n="";for(let o=t+1;o<this.textBlocks.length;o++){const s=this.textBlocks[o];n+=s.toRichTextXML(e)}return n}}class Pi{constructor(){p(this,"parser",new DOMParser)}parseBooleanAttribute(t){if(t!=null){if(typeof t=="boolean")return t;if(typeof t=="string"){const e=t.toLowerCase().trim();if(e==="true")return!0;if(e==="false")return!1}}}parse(t,e){const n=[],o=this.parseRichText(t);for(const s of o){const r=this.computeTextBlocks(s,e);n.push({textBlocks:r})}return n}escapeXmlText(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}preprocessXmlString(t){return t.replace(/>([^<>]+)</g,(e,n)=>{if(/[&<>"']/.test(n)){const o=[];let s=n.replace(/&(?:amp|lt|gt|quot|apos);/g,r=>(o.push(r),`__ENTITY_${o.length-1}__`));return s=this.escapeXmlText(s),s=s.replace(/__ENTITY_(\d+)__/g,(r,i)=>o[parseInt(i)]),`>${s}<`}return e})}parseRichText(t){if(!t)return[{textBlocks:[]}];const e=this.preprocessXmlString(t),n=this.parser.parseFromString(e,"text/xml"),o=n.querySelector("parsererror");if(o)return console.error("解析富文本样式失败:",o,t),[{textBlocks:[t]}];const s=[],r=n.documentElement;for(const i of r.childNodes){const a=this.flattenNodes(i);s.push({textBlocks:a})}return s}flattenNodes(t){const e=[];for(const n of t.childNodes)if(n.nodeType===Node.TEXT_NODE){const o=n.textContent;o&&e.push(o)}else if(n.nodeType===Node.ELEMENT_NODE){const o=n;if(o.tagName.toLowerCase()==="style"){const r=o.textContent||"",i={text:""};o.childNodes.length>0?i.text=this.flattenNodes(o):i.text=r;const a=o.getAttribute("color");a&&(i.fontColor=a);const c=o.getAttribute("bg-color");c&&(i.fontBgColor=c);const h=o.getAttribute("bold"),d=this.parseBooleanAttribute(h);d!==void 0&&(i.bold=d);const u=o.getAttribute("italic"),g=this.parseBooleanAttribute(u);g!==void 0&&(i.italic=g);const f=o.getAttribute("font-size");f&&(i.fontSize=parseFloat(f));const y=o.getAttribute("underline"),P=this.parseBooleanAttribute(y);P!==void 0&&(i.underline=P);const b=o.getAttribute("strikethrough"),w=this.parseBooleanAttribute(b);w!==void 0&&(i.strikethrough=w),e.push(i)}}return e}computeTextBlocks(t,e){const n=[];for(const o of t.textBlocks)this.makeupTextBlock(o,e,n);return n}makeupTextBlock(t,e,n){if(typeof t=="string"){n.push(this.makeupTextBlockOfText(t,e));return}const o=t.text;if(typeof o=="string"){n.push(this.makeupTextBlockOfCacheTextBlock(t,e));return}if(!(o instanceof Array))return;const s={...e,...this.computeTextProps(t,e)};for(const r of o)this.makeupTextBlock(r,s,n)}makeupTextBlockOfText(t,e){return{text:t,fontSize:e.fontSize,fontFamily:e.fontFamily,fontColor:e.fontColor,fontBgColor:e.fontBgColor,bold:e.bold,italic:e.italic,underline:e.underline,strikethrough:e.strikethrough}}makeupTextBlockOfCacheTextBlock(t,e){return{...this.computeTextProps(t,e),text:t.text}}computeTextProps(t,e){return{text:"",fontSize:t.fontSize!==void 0?t.fontSize:e.fontSize,fontFamily:t.fontFamily!==void 0?t.fontFamily:e.fontFamily,fontColor:t.fontColor!==void 0?t.fontColor:e.fontColor,fontBgColor:t.fontBgColor!==void 0?t.fontBgColor:e.fontBgColor,bold:t.bold!==void 0?t.bold:e.bold,italic:t.italic!==void 0?t.italic:e.italic,underline:t.underline!==void 0?t.underline:e.underline,strikethrough:t.strikethrough!==void 0?t.strikethrough:e.strikethrough}}}class As{constructor(t,e,n,o,s,r){p(this,"charText");p(this,"index",0);p(this,"x");p(this,"y");p(this,"width");p(this,"height");p(this,"boxAscent");this.charText=t,this.x=e,this.y=n,this.width=o,this.height=s,this.boxAscent=r}contains(t){return M.rectContains2(t,{minX:this.x,maxX:this.x+this.width,minY:this.y,maxY:this.y+this.height})}toString(){return this.charText}}class Ro{constructor(){p(this,"segmentWorker",new Intl.Segmenter("en",{granularity:"grapheme"}))}split(t){return Array.from(this.segmentWorker.segment(t)).map(n=>n.segment)}}const Eo=new Ro;class Yh{measureParagraphs(t,e){for(const n of e)this.measure(t,n)}measure(t,e){for(const n of e.textBlocks){const{fontSize:o,fontFamily:s,italic:r,bold:i,text:a}=n;t.font=M.calcFont(o,s,i,r);const c=Eo.split(a),h=[];for(const d of c){const{width:u,height:g,boxAscent:f}=M.measureText(t,d),y=new As(d,0,0,u,g,f);h.push(y)}n.characters=h}}}var ao=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ks(l){return l&&l.__esModule&&Object.prototype.hasOwnProperty.call(l,"default")?l.default:l}function Gh(l){if(l.__esModule)return l;var t=l.default;if(typeof t=="function"){var e=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(l).forEach(function(n){var o=Object.getOwnPropertyDescriptor(l,n);Object.defineProperty(e,n,o.get?o:{enumerable:!0,get:function(){return l[n]}})}),e}var Ns=0,bi=-3;function co(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function Uh(l,t){this.source=l,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=t,this.destLen=0,this.ltree=new co,this.dtree=new co}var Mi=new co,Si=new co,Bs=new Uint8Array(30),Rs=new Uint16Array(30),vi=new Uint8Array(30),Ii=new Uint16Array(30),_h=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ti=new co,Ut=new Uint8Array(320);function Li(l,t,e,n){var o,s;for(o=0;o<e;++o)l[o]=0;for(o=0;o<30-e;++o)l[o+e]=o/e|0;for(s=n,o=0;o<30;++o)t[o]=s,s+=1<<l[o]}function $h(l,t){var e;for(e=0;e<7;++e)l.table[e]=0;for(l.table[7]=24,l.table[8]=152,l.table[9]=112,e=0;e<24;++e)l.trans[e]=256+e;for(e=0;e<144;++e)l.trans[24+e]=e;for(e=0;e<8;++e)l.trans[168+e]=280+e;for(e=0;e<112;++e)l.trans[176+e]=144+e;for(e=0;e<5;++e)t.table[e]=0;for(t.table[5]=32,e=0;e<32;++e)t.trans[e]=e}var Ci=new Uint16Array(16);function Es(l,t,e,n){var o,s;for(o=0;o<16;++o)l.table[o]=0;for(o=0;o<n;++o)l.table[t[e+o]]++;for(l.table[0]=0,s=0,o=0;o<16;++o)Ci[o]=s,s+=l.table[o];for(o=0;o<n;++o)t[e+o]&&(l.trans[Ci[t[e+o]]++]=o)}function jh(l){l.bitcount--||(l.tag=l.source[l.sourceIndex++],l.bitcount=7);var t=l.tag&1;return l.tag>>>=1,t}function _t(l,t,e){if(!t)return e;for(;l.bitcount<24;)l.tag|=l.source[l.sourceIndex++]<<l.bitcount,l.bitcount+=8;var n=l.tag&65535>>>16-t;return l.tag>>>=t,l.bitcount-=t,n+e}function Hs(l,t){for(;l.bitcount<24;)l.tag|=l.source[l.sourceIndex++]<<l.bitcount,l.bitcount+=8;var e=0,n=0,o=0,s=l.tag;do n=2*n+(s&1),s>>>=1,++o,e+=t.table[o],n-=t.table[o];while(n>=0);return l.tag=s,l.bitcount-=o,t.trans[e+n]}function Vh(l,t,e){var n,o,s,r,i,a;for(n=_t(l,5,257),o=_t(l,5,1),s=_t(l,4,4),r=0;r<19;++r)Ut[r]=0;for(r=0;r<s;++r){var c=_t(l,3,0);Ut[_h[r]]=c}for(Es(Ti,Ut,0,19),i=0;i<n+o;){var h=Hs(l,Ti);switch(h){case 16:var d=Ut[i-1];for(a=_t(l,2,3);a;--a)Ut[i++]=d;break;case 17:for(a=_t(l,3,3);a;--a)Ut[i++]=0;break;case 18:for(a=_t(l,7,11);a;--a)Ut[i++]=0;break;default:Ut[i++]=h;break}}Es(t,Ut,0,n),Es(e,Ut,n,o)}function Ai(l,t,e){for(;;){var n=Hs(l,t);if(n===256)return Ns;if(n<256)l.dest[l.destLen++]=n;else{var o,s,r,i;for(n-=257,o=_t(l,Bs[n],Rs[n]),s=Hs(l,e),r=l.destLen-_t(l,vi[s],Ii[s]),i=r;i<r+o;++i)l.dest[l.destLen++]=l.dest[i]}}}function Kh(l){for(var t,e,n;l.bitcount>8;)l.sourceIndex--,l.bitcount-=8;if(t=l.source[l.sourceIndex+1],t=256*t+l.source[l.sourceIndex],e=l.source[l.sourceIndex+3],e=256*e+l.source[l.sourceIndex+2],t!==(~e&65535))return bi;for(l.sourceIndex+=4,n=t;n;--n)l.dest[l.destLen++]=l.source[l.sourceIndex++];return l.bitcount=0,Ns}function Qh(l,t){var e=new Uh(l,t),n,o,s;do{switch(n=jh(e),o=_t(e,2,0),o){case 0:s=Kh(e);break;case 1:s=Ai(e,Mi,Si);break;case 2:Vh(e,e.ltree,e.dtree),s=Ai(e,e.ltree,e.dtree);break;default:s=bi}if(s!==Ns)throw new Error("Data error")}while(!n);return e.destLen<e.dest.length?typeof e.dest.slice=="function"?e.dest.slice(0,e.destLen):e.dest.subarray(0,e.destLen):e.dest}$h(Mi,Si),Li(Bs,Rs,4,3),Li(vi,Ii,2,1),Bs[28]=0,Rs[28]=258;var Zh=Qh;const qh=new Uint8Array(new Uint32Array([305419896]).buffer)[0]===18,ki=(l,t,e)=>{let n=l[t];l[t]=l[e],l[e]=n},Jh=l=>{const t=l.length;for(let e=0;e<t;e+=4)ki(l,e,e+3),ki(l,e+1,e+2)};var ed={swap32LE:l=>{qh&&Jh(l)}};const Ni=Zh,{swap32LE:td}=ed,Ds=11,Ln=5,nd=Ds-Ln,od=65536>>Ds,sd=(1<<nd)-1,Ho=2,Os=(1<<Ln)-1,Bi=65536>>Ln,rd=1024>>Ln,id=Bi+rd+32,ad=1<<Ho;class cd{constructor(t){const e=typeof t.readUInt32BE=="function"&&typeof t.slice=="function";if(e||t instanceof Uint8Array){let n;if(e)this.highStart=t.readUInt32LE(0),this.errorValue=t.readUInt32LE(4),n=t.readUInt32LE(8),t=t.slice(12);else{const o=new DataView(t.buffer);this.highStart=o.getUint32(0,!0),this.errorValue=o.getUint32(4,!0),n=o.getUint32(8,!0),t=t.subarray(12)}t=Ni(t,new Uint8Array(n)),t=Ni(t,new Uint8Array(n)),td(t),this.data=new Uint32Array(t.buffer)}else({data:this.data,highStart:this.highStart,errorValue:this.errorValue}=t)}get(t){let e;return t<0||t>1114111?this.errorValue:t<55296||t>56319&&t<=65535?(e=(this.data[t>>Ln]<<Ho)+(t&Os),this.data[e]):t<=65535?(e=(this.data[Bi+(t-55296>>Ln)]<<Ho)+(t&Os),this.data[e]):t<this.highStart?(e=this.data[id-od+(t>>Ds)],e=this.data[e+(t>>Ln&sd)],e=(e<<Ho)+(t&Os),this.data[e]):this.data[this.data.length-ad]}}var ld=cd;const hd=ks(ld);var Ri={};(function(l){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";(function(e){var n=typeof Uint8Array<"u"?Uint8Array:Array,o=43,s=47,r=48,i=97,a=65,c=45,h=95;function d(f){var y=f.charCodeAt(0);if(y===o||y===c)return 62;if(y===s||y===h)return 63;if(y<r)return-1;if(y<r+10)return y-r+26+26;if(y<a+26)return y-a;if(y<i+26)return y-i+26}function u(f){var y,P,b,w,L,B;if(f.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var H=f.length;L=f.charAt(H-2)==="="?2:f.charAt(H-1)==="="?1:0,B=new n(f.length*3/4-L),b=L>0?f.length-4:f.length;var E=0;function X($){B[E++]=$}for(y=0,P=0;y<b;y+=4,P+=3)w=d(f.charAt(y))<<18|d(f.charAt(y+1))<<12|d(f.charAt(y+2))<<6|d(f.charAt(y+3)),X((w&16711680)>>16),X((w&65280)>>8),X(w&255);return L===2?(w=d(f.charAt(y))<<2|d(f.charAt(y+1))>>4,X(w&255)):L===1&&(w=d(f.charAt(y))<<10|d(f.charAt(y+1))<<4|d(f.charAt(y+2))>>2,X(w>>8&255),X(w&255)),B}function g(f){var y,P=f.length%3,b="",w,L;function B(E){return t.charAt(E)}function H(E){return B(E>>18&63)+B(E>>12&63)+B(E>>6&63)+B(E&63)}for(y=0,L=f.length-P;y<L;y+=3)w=(f[y]<<16)+(f[y+1]<<8)+f[y+2],b+=H(w);switch(P){case 1:w=f[f.length-1],b+=B(w>>2),b+=B(w<<4&63),b+="==";break;case 2:w=(f[f.length-2]<<8)+f[f.length-1],b+=B(w>>10),b+=B(w>>4&63),b+=B(w<<2&63),b+="=";break}return b}e.toByteArray=u,e.fromByteArray=g})(l)})(Ri);const dd=ks(Ri);var Ei={};const ud=5,Hi=12,pd=13,gd=16,fd=17,yd=22,Di=28,Oi=31,xd=33,Do=34,wd=35,Xs=36,zs=37,Xi=38,md=39,Pd=40,lo=41,bd=42,x=0,S=1,Ee=2,zi=3,C=4,Md=[[C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,zi,C,C,C,C,C,C,C,C,C,C,C],[x,C,C,S,S,C,C,C,C,S,S,x,x,x,x,S,S,S,x,x,C,Ee,C,x,x,x,x,x,x,x,x,S,x],[x,C,C,S,S,C,C,C,C,S,S,S,S,S,x,S,S,S,x,x,C,Ee,C,x,x,x,x,x,x,x,x,S,x],[C,C,C,S,S,S,C,C,C,S,S,S,S,S,S,S,S,S,S,S,C,Ee,C,S,S,S,S,S,S,S,S,S,S],[S,C,C,S,S,S,C,C,C,S,S,S,S,S,S,S,S,S,S,S,C,Ee,C,S,S,S,S,S,S,S,S,S,S],[x,C,C,S,S,S,C,C,C,x,x,x,x,x,x,S,S,S,x,x,C,Ee,C,x,x,x,x,x,x,x,x,S,x],[x,C,C,S,S,S,C,C,C,x,x,x,x,x,x,S,S,S,x,x,C,Ee,C,x,x,x,x,x,x,x,x,S,x],[x,C,C,S,S,S,C,C,C,x,x,S,x,S,x,S,S,S,x,x,C,Ee,C,x,x,x,x,x,x,x,x,S,x],[x,C,C,S,S,S,C,C,C,x,x,S,S,S,x,S,S,S,x,x,C,Ee,C,x,x,x,x,x,x,x,x,S,x],[S,C,C,S,S,S,C,C,C,x,x,S,S,S,S,S,S,S,x,x,C,Ee,C,S,S,S,S,S,x,S,S,S,x],[S,C,C,S,S,S,C,C,C,x,x,S,S,S,x,S,S,S,x,x,C,Ee,C,x,x,x,x,x,x,x,x,S,x],[S,C,C,S,S,S,C,C,C,S,S,S,S,S,x,S,S,S,x,x,C,Ee,C,x,x,x,x,x,x,x,x,S,x],[S,C,C,S,S,S,C,C,C,S,S,S,S,S,x,S,S,S,x,x,C,Ee,C,x,x,x,x,x,x,x,x,S,x],[S,C,C,S,S,S,C,C,C,S,S,S,S,S,x,S,S,S,x,x,C,Ee,C,x,x,x,x,x,x,x,x,S,x],[x,C,C,S,S,S,C,C,C,x,S,x,x,x,x,S,S,S,x,x,C,Ee,C,x,x,x,x,x,x,x,x,S,x],[x,C,C,S,S,S,C,C,C,x,x,x,x,x,x,S,S,S,x,x,C,Ee,C,x,x,x,x,x,x,x,x,S,x],[x,C,C,S,x,S,C,C,C,x,x,S,x,x,x,S,S,S,x,x,C,Ee,C,x,x,x,x,x,x,x,x,S,x],[x,C,C,S,x,S,C,C,C,x,x,x,x,x,x,S,S,S,x,x,C,Ee,C,x,x,x,x,x,x,x,x,S,x],[S,C,C,S,S,S,C,C,C,S,S,S,S,S,S,S,S,S,S,S,C,Ee,C,S,S,S,S,S,S,S,S,S,x],[x,C,C,S,S,S,C,C,C,x,x,x,x,x,x,S,S,S,x,C,C,Ee,C,x,x,x,x,x,x,x,x,S,x],[x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,C,x,x,x,x,x,x,x,x,x,x,x,x],[S,C,C,S,S,S,C,C,C,S,S,S,S,S,x,S,S,S,x,x,C,Ee,C,x,x,x,x,x,x,x,x,S,x],[S,C,C,S,S,S,C,C,C,S,S,S,S,S,S,S,S,S,S,S,C,Ee,C,S,S,S,S,S,S,S,S,S,S],[x,C,C,S,S,S,C,C,C,x,S,x,x,x,x,S,S,S,x,x,C,Ee,C,x,x,x,S,S,x,x,x,S,x],[x,C,C,S,S,S,C,C,C,x,S,x,x,x,x,S,S,S,x,x,C,Ee,C,x,x,x,x,S,x,x,x,S,x],[x,C,C,S,S,S,C,C,C,x,S,x,x,x,x,S,S,S,x,x,C,Ee,C,S,S,S,S,x,x,x,x,S,x],[x,C,C,S,S,S,C,C,C,x,S,x,x,x,x,S,S,S,x,x,C,Ee,C,x,x,x,S,S,x,x,x,S,x],[x,C,C,S,S,S,C,C,C,x,S,x,x,x,x,S,S,S,x,x,C,Ee,C,x,x,x,x,S,x,x,x,S,x],[x,C,C,S,S,S,C,C,C,x,x,x,x,x,x,S,S,S,x,x,C,Ee,C,x,x,x,x,x,S,x,x,S,x],[x,C,C,S,S,S,C,C,C,x,S,x,x,x,x,S,S,S,x,x,C,Ee,C,x,x,x,x,x,x,x,S,S,x],[x,C,C,S,S,S,C,C,C,x,S,x,x,x,x,S,S,S,x,x,C,Ee,C,x,x,x,x,x,x,x,x,S,x],[S,C,C,S,S,S,C,C,C,S,S,S,S,S,x,S,S,S,x,x,C,Ee,C,x,x,x,x,x,x,x,x,S,x],[x,C,C,S,S,x,C,C,C,x,x,x,x,x,x,x,x,x,x,x,C,Ee,C,x,x,x,x,x,x,x,x,S,x]],Sd=dd.toByteArray("AAgOAAAAAAAQ4QAAAQ0P8vDtnQuMXUUZx+eyu7d7797d9m5bHoWltKVUlsjLWE0VJNigQoMVqkStEoNQQUl5GIo1KKmogEgqkKbBRki72lYabZMGKoGAjQRtJJDaCCIRiiigREBQS3z+xzOTnZ3O+3HOhd5NfpkzZx7fN9988zivu2M9hGwB28F94DnwEngd/Asc1EtIs9c/bIPDwCxwLDgezHcodyo4w5C+CCwBS8FnwSXgCnA1uFbI93XwbXAbWAfWgx+CzWAb+An4KfgFeAzsYWWfYuFz4CXwGvgb+Dfo6yNkEEwGh4CZYB44FpwI3g1OY+kfBItZOo2fB84Hy8DF4HJwNbiWpV8PVoO1LH4n2NRXyN+KcAd4kNVP9XsY4aPgcfAbsBfs6SniL4K/sPjfEf6HlanXCRkCw2BGvUh/keWfXS/CY+pFXs7x9XHmM94LTmWIeU2cgbxnS/k/B3kf86jDhU8L9V2E40vAFWAlWFUfb++NOL4F3C7JX4/4GiE+hvgWsF0oS7mXldspnN+F493gyXrh9xTav0cg3EvzgVfBG6wsmVSEkxBOBgdPGpd7JI6PnqRvJ68/xlbHof53gPeA94OzwLngk+ACsAwsByvASrAK3MB0Ws3CtQjvBJvAVrADPMDSHkb4CNijaccTwvnf4fiPEs8Lxy+D18A/QU8/xjgYBjPAbDAKTgYLwOngTHAO+EQ/8wuEF4EvsPiVCFf2+9tsFStzA8LVHuXXBsi6QyqzUYiPMR/7Mc7dAx7oL8bzw/3u/Bw8Bp4Az4AXwCtgHzsmDXP5fiF9iiVvly5d0sHngar16NKlS5cuXbp06fLmYlqHXrcd3ph4P0THUY3iXh49novju4S0tzfs5d+JPKewfAsRntZb3K9ZhOMlrO6lCC8An28U9+OuovcPcPxlVu5rCL/VmHh/iHIrzn3fIPu7SN8Axmg+8AOwEWwCm7tp3bRuWjetm5Y8bSu4B9zbKO6ZVsnORrVU3f4uXTqZ2H3sLoyx3eDXjfDndE9qyj6L838CfwVvgFpzYnof4oNgOhgBc8Fos9DrZIQLmtXPP1MmF6wGj4H+KXoWguvADkXaPil+YpuQy8Am8Ey7ODdtmJDF4HowBp4De6HDTNjhfHAHeBr0DBBy0kDxfPbcgSIusgrcWhtnJ8vL+TPix7UIOQtcBq4C28Cr4KRBnANbwSuDE+s50JgyNNFuXbp06XIgsXjIvPafjvXozKY+fVFz/z0LT1uCtKVSWbrOLWPnztG8e0Xfy7ol8XtZJi7WtG+5od2UFXQ/A12vUeS7jp27yVKHjdsU9lXB869TyNvAzt0lpP2oWbwLdjiO78bx/Sz+EMJHwK9Y/LcIfw+eZ3F67/Hl5vh9xX80J+rwX8SvRDhpgL17iPAQMHNArfPrqHPewLheI+AERV6efwV418B4nOZ/H+IfYHV8GOF5LJ3eAz0fx8sM9S0fUNud39O9CulfGZhY5huI3wzWgNvBelbHZoTbNPVpfYjKQpkHwUNgl0LWblbnk0LbbDxr0OMFpL3iqWdu9nWYPlVAWkXY39LnGdCkDbeqv1YNbfcMQ3t9oe8lzm6NH9N1ZB6Ln4BwfkJZJk7RyFnYKt6b/JDQXx9p5X+eFdqOjzM9P9MB/lUlFzr20aXIdzlY4dmn9F3YqtvoO76/2hp/D/xA5Zue88nNyL8GbFbs075X0tyUig3Qd2MCnf//HjnzpbsR3g9+1kHzzVjdnE71/qVBX9rGPUh/ysNWe1neFzvIDi5zAufV1sT0N0poR22wkFUfTOPfA4N2mbZ5fSrqOHSw+IbkSBbOGSzSRgf91/GTUWYBOB2cIZQ/G8cfBZ8CFwrnL8XxF8FKcA24jqXdiPA7Qr61OF7H4mMItwzuv2/YLth1ISt3Hzu3k4W7EH5JqPdRHD/O4k+z8A8IX5Lq3y7Z4nXE9xn6kX6vQ4bKfy+ok+hH+xf3hq9dnTTHhjKd2GmDuWA242iHMq4cC7A8kJ7i8o1+skSa7Jieo38HCWnoNjKFhdSFBxzpZ7QE6lI8N4S14aASZcryaV/WWHw66f6NHuCoxuQxmvM56GX9QMd8Q4D65ywGP+ZzRJuM+zQvx/MOS2VFeqQ4IXnH26zM9Xe6/E6D+4foAzzuajPZp8Qyw5ayZVDWuH0z0BtYRkeIDqH9KO9VbH1btd/lhNqCzvl8zeLnG0S/hnU6baHfpiuO6yy0rd+DHURo/zYF5H26j03rQsip2ndzz82u1z9N4VjWKWeb68Tedpt95HRVXp7H1R6p+/Wt4FPy/PpWwscOLRJ+PVWF/+W0iVyGzs18TIvXkOJ1Wxm66vSXz+vylenrZcj1ub439W+K8RNCGTJi2p/TJ1K23VaXr35tRpnzmjxequgfcfyk6B/TGBVlyedsNgpdd/h+W1U3P99QyFPNo1X3TwpM/WLTIWYfoBqXrv6iskHZ/RFr79R6hIyHBrH3f1nrUVnjP8SnZZ+rYtzr9Exld5MNbPNErusAPg+77u/eDOPftU9yj39TH7rezxd1LvsZQJlzkWlOirG/79zjMj/mtHUKu7vKy+3/LnXr9okyKedjX5/0He9iP/j63LwOQdarEVlfy8OO/Lqw023j6xcqmwxLiOd6heM2i9cV9LJy8jMJ23yQ+rpbfu7EQ/pXE8KYvUSqvVnb4XzZa6LrHMXHR+zcLvqWbm/Bn0/HzIs6fWPHoat8XfnDKmZGxRxeMbn2UqZ5Q94nmcZRbqqUXbZ8+lcjE+cPX11t814orvvAXNcG8vqj2vvk1MGn3anlj0bIT72v47bvE+Lc98T9b6r7AKn6j+8Duf7D0nnZx/j7Zjn0j9nbpSTndaLr9WNLivP+iN23xF7L+fqv6ZouFyb78jxVXvv5jJ9YUs9/sddO8h7KNg5jrhfaJGztT6G7KF+1d6yCmD5Kdb2fan60rSc552fZr3zeQ9DpnPp+Si5cx5Ktv2QfSzF/mMbWdOm46rFI4XstnU9xeqX4NKb7TKEdcr6pZOK3ID1k/LvFHkVczEuZLEDr499YqvqBym1aEHWgcvoYOtv0M91qQl5TfpO/in6rWx8OVpT1Wedkv3f5xom3T/xeR/6Gx6V86PWAOB4bBpqWdN+yTcVxjIyGRz/FrDGu6w/3d7kPm8StX8RyPu+uuvpNju/vTLJV37GpvoM0oZPnW87VLnL/5pDno1NoW1R6yedU6TyUv3u19a3KFnIbTLYz+ZCLP4T0tU1uivFgso0pnsJ/UtXvarNY28Xq5cvkBDrQP/E5ZaiuQwwfmTlsOiQRU1fMuqrDd/3ISSuwjOwXOfTyGUMpZIXq4GpLn3pUcdfzch2x7XO1u2uZHOPb1G6b3Xg9PH1IIWeEpJlPQtqos2EKW8b0u8rnuP1UeVLoXJb9be0uG9nnbchjU+XTszT5VeNBThPHnc5OKj1U9aj0GTHIVaGy1YhEWT4ixns00DT+XEzWn/7VAsIc63Cov3OdyhwjrnaqQqZvWKXdypRdlq+k8msZ031U+Rm4fA+3TtyeR9hwfW9G9yxDN0fZMN33F+9TE6md4hwoxumfaUzI9fN3PFT3xVV2msrQ3UsnChm6Nulk8TndpS28D3zX9tTIPsF/z7Am5OkTjm1tI1JZW74+4VgsZ0N3L1yXV3WeP5uR7TGHHdvC3JQlxybfpd22tDlk/2eofRK8TzrN/qnar/K/OUTth6I/+jAnEptNbPvFHP2gs40N3+dfMWtwqvVct7/wfd8gtQ7imifial9ZJ9/3IHLYU6eDj3+4PhsNhX+vwvcWLnu6kGfEMe8DuciPfUfGZB8X/7HJy/Gefe5n+VRGFd/wyP2ta7/LO4yh/sbLV/k9lev6kfO9Dt/5U67b1/6u/epqB1U9Me23jfHY9sscAg4tkbLl+e4/U36rJ9ddxfd6sg5vq5ice42Wpk/pb9FOJ36/W9tpv4kbC79nUbZceX8Zu6/qJ+P3WvhvA8v3reh7Jbn2d6rrNC7XNZTLma4Ba0JI9efX2uLzF5scG/w9UNU1ZxW+ymUfzELeTllXlQ1rUuhzjS5fp9c964iFBOqeSz63bU065nZKdU+mDEz3qHIjjifquw0pnb/raRtvrnsYcb46ihT3taoYz6brdNW9l6rWRnE/navdPn1XlR1km7hcz1WlH/elKuSOSvLLuE8U6m8uzwRdfcGl73VyTHuyMvzJ1Sa2cWDTP/Z63Kc94n2B1PYr24dz1JlyHLlcP+S4B6vD1c9EW4q2LWstCvUjeVy63k/LMYdUNd5D1xQfvVTzX1VjkMsUv88N8VH5fReVn/Fjn++/h6X6Q8a6b1/q3g/i/ewi0/Scs8zxXeV6mWIOUPlPzBgdFerW+bZrm2P18dnjuK6HunEp+rHvPMXbr+sHVb/lnL+pTP57jPw9Cvk3PW178JD9qChfzuvTf7Htl38L1QUf/VKu9SFjwWbTWPvFEvu7Uq76y7+31g6QlYPc669pbsm9Xur2LWI9Pu8ypfDXqm3A2z8s1FWGn4ntL9NfQu2oSlftX9uetvTtv7J8Ql4zxfXGZ3zk8PeQ9w59x2uMfqI8/q5eKh/l9cb2rwsu9rSNl06ZP2Pmxtz+rNMx93yno0n2/82rVH7rQ+y9P15H6FyRun9ViH81ATmffI7nJ5r8uXXW6enbP6b/B8/l5OifVHYLnb9S39s2zcc+Ph+rh8+eQgVPS72elzGWY/tUtbbabBpDiI7yN1q6/4th2y+ErAc5+9BVvu/7KamJbWNZeuqI/R4tRf+YyD1HmOZM1bMV3/14Sn10c0Xu+Sj1nOXb5jL73ncdy02uvlXZNde65dOHYl7Vs4KYuS6FzWLn2zJlpZqPXPVPOa5yzKOyn1VhT9lmMfdbfH7D11Wf2PXN5h9y+dD287+qxgSnaYmnIrRtIb8pJe6/Uv9OVer6Whn0zfGO/BEloZI9ojmfAlUflClDd178bTmVHVTpZXOkAlk/lb42UujmI89HH5V+cl7XtowY6vTxLVWok6UrGzoGTHN+bB+6ri05687VNpvfuvRfaP2uMlNQth1D5JjGelm/8yn+9p3p/7qk9gnfeddXZmq/Sm333PJT659Kv1zjNbZ9uv2Oi//67CV8/N1nj1DmviyXDNVeJkaeaX8UsyesYg8cu2+NvdaPfb+lLDu5tvt/"),vd=new hd(Sd),Wi=function(l){switch(l){case xd:return Hi;case md:case Pd:case bd:return Hi;case wd:return ud;default:return l}},Fi=function(l){switch(l){case zs:case Xi:return Do;case lo:return yd;default:return l}};class Ws{constructor(t,e=!1){this.position=t,this.required=e}}class Id{nextCodePoint(){const t=this.string.charCodeAt(this.pos++),e=this.string.charCodeAt(this.pos);return 55296<=t&&t<=56319&&56320<=e&&e<=57343?(this.pos++,(t-55296)*1024+(e-56320)+65536):t}nextCharClass(){return Wi(vd.get(this.nextCodePoint()))}getSimpleBreak(){switch(this.nextClass){case lo:return!1;case Do:case zs:case Xi:return this.curClass=Do,!1;case Xs:return this.curClass=Xs,!1}return null}getPairTableBreak(t){let e=!1;switch(Md[this.curClass][this.nextClass]){case x:e=!0;break;case S:e=t===lo;break;case Ee:if(e=t===lo,!e)return e=!1,e;break;case zi:if(t!==lo)return e;break}return this.LB8a&&(e=!1),this.LB21a&&(this.curClass===gd||this.curClass===fd)?(e=!1,this.LB21a=!1):this.LB21a=this.curClass===pd,this.curClass===Di?(this.LB30a++,this.LB30a==2&&this.nextClass===Di&&(e=!0,this.LB30a=0)):this.LB30a=0,this.curClass=this.nextClass,e}nextBreak(){if(this.curClass==null){let t=this.nextCharClass();this.curClass=Fi(t),this.nextClass=t,this.LB8a=t===Oi,this.LB30a=0}for(;this.pos<this.string.length;){this.lastPos=this.pos;const t=this.nextClass;if(this.nextClass=this.nextCharClass(),this.curClass===Do||this.curClass===Xs&&this.nextClass!==zs)return this.curClass=Fi(Wi(this.nextClass)),new Ws(this.lastPos,!0);let e=this.getSimpleBreak();if(e===null&&(e=this.getPairTableBreak(t)),this.LB8a=this.nextClass===Oi,e)return new Ws(this.lastPos)}return this.lastPos<this.string.length?(this.lastPos=this.string.length,new Ws(this.string.length)):null}constructor(t){this.string=t,this.pos=0,this.lastPos=0,this.curClass=null,this.nextClass=null,this.LB8a=!1,this.LB21a=!1,this.LB30a=0}}Ei=Id;class Td{split(t){const e=new Ei(t);let n=0,o;const s=[];for(;o=e.nextBreak();){const r=t.slice(n,o.position);s.push(r),o.required,n=o.position}return s}}const Yi=new Td;class dn{constructor(){p(this,"text");p(this,"characters",[]);p(this,"fontSize");p(this,"fontFamily");p(this,"fontColor");p(this,"fontBgColor");p(this,"bold");p(this,"italic");p(this,"underline");p(this,"strikethrough");p(this,"x",0);p(this,"y",0);p(this,"width",0);p(this,"height",0);this.text="",this.characters=[],this.fontSize=14,this.fontFamily="Noto Sans",this.fontColor="#000000",this.fontBgColor="",this.bold=!1,this.italic=!1,this.underline=!1,this.strikethrough=!1}static create(t){const e=new dn;e.fontSize=t.fontSize,e.fontFamily=t.fontFamily,e.fontColor=t.fontColor,e.fontBgColor=t.fontBgColor,e.bold=t.bold,e.italic=t.italic,e.underline=t.underline,e.strikethrough=t.strikethrough;const n=t.characters||[];let o="";for(const s of n)e.addCharacter(s),o+=s.charText;return e.text=o,e}static createByStyleAndCharacter(t,e=[]){const n=new dn;n.fontSize=t.fontSize,n.fontFamily=t.fontFamily,n.fontColor=t.fontColor,n.fontBgColor=t.fontBgColor,n.bold=t.bold,n.italic=t.italic,n.underline=t.underline,n.strikethrough=t.strikethrough;let o="";for(const s of e)n.addCharacter(s),o+=s.charText;return n.text=o,n}addCharacter(t){t.x=this.width,t.index=this.characters.length,this.characters.push(t),this.width=this.width+t.width,this.height=Math.max(this.height,t.height)}draw(t,e,n){const{fontBgColor:o,underline:s,strikethrough:r,fontColor:i,fontSize:a,fontFamily:c,bold:h,italic:d}=this,u=e.x+this.x,g=e.y+this.y;if(o&&(t.save(),t.fillStyle=o,t.fillRect(u,g,this.width,n),t.restore()),t.save(),t.fillStyle=i,t.font=M.calcFont(a,c,h,d),t.textAlign="left",t.textBaseline="bottom",t.fillText(this.text,u,g+n),t.restore(),s){const f=.08333333333333333*a;t.strokeStyle=i,t.lineWidth=f,t.beginPath(),t.moveTo(u,g+n-f),t.lineTo(u+this.width,g+n-f),t.stroke()}r&&(t.strokeStyle=i,t.lineWidth=1/12*a,t.beginPath(),t.moveTo(u,g+n-.4*this.height),t.lineTo(u+this.width,g+n-.4*this.height),t.stroke())}computeLineBreakPoint(t){const e=Yi.split(this.text);let n=0;const o=[];for(let s=0;s<e.length-1;s++){const r=e[s],i=Eo.split(r);n+=i.length,o.push(n)}if(!t)o.push(this.characters.length);else{const s=Yi.split(this.text+t.text);let r=0;for(const i of s){const a=Eo.split(i);if(r+=a.length,r===this.characters.length)return o.push(this.characters.length),o;if(r>this.characters.length)return o}}return o}toString(){let t="";for(const e of this.characters)t+=e.toString();return t}toRichTextXML(t){return`<style ${this.computeStyle(t)}>${this.text}</style>`}computeStyle(t){let e="";return this.fontColor!==t.fontColor&&(e+=`color='${this.fontColor}' `),this.fontBgColor!==t.fontBgColor&&(e+=`bg-color='${this.fontBgColor}' `),this.fontSize!==t.fontSize&&(e+=`font-size='${this.fontSize}' `),this.bold!==t.bold&&(e+=`bold=${this.bold?"'true'":"'false'"} `),this.italic!==t.italic&&(e+=`italic=${this.italic?"'true'":"'false'"} `),this.underline!==t.underline&&(e+=`underline=${this.underline?"'true'":"'false'"} `),this.strikethrough!==t.strikethrough&&(e+=`strikethrough=${this.strikethrough?"'true'":"'false'"} `),e}getPrevText(t){let e="";for(let n=0;n<t+1;n++)e+=this.characters[n].charText;return e}getNextText(t){let e="";const n=Math.max(t+1,0);for(let o=n;o<this.characters.length;o++)e+=this.characters[o].charText;return e}insertTextToRichTextXML(t,e,n){const o=this.getPrevText(e)+t+this.getNextText(e);return`<style ${this.computeStyle(n)}>${o}</style>`}}class Ld{work(t,e,n){let o=[],s=n.line.width;for(const r of t.characters)if(s+r.width<e)o.push(r),s+=r.width;else{if(o.length>0){const i=dn.createByStyleAndCharacter(t,o);n.line.addTextBlock(i)}n.paragraph.addLine(n.line),o=[],n.line=new Gn,o.push(r),s=r.width}if(o.length>0){const r=dn.createByStyleAndCharacter(t,o);n.line.addTextBlock(r)}}}const Cd=new Ld;class ho{checkValid(t,e){const{paragraphIndex:n,lineIndex:o,charIndex:s}=e;if(n<0||o<0||s<-1||n>t.paragraphs.length-1)return console.warn("警告,光标位置异常,",e),null;const r=t.paragraphs[n];if(o>r.lines.length-1)return console.warn("警告,光标位置异常,",e),null;const i=r.lines[o],a=i.getCharLength();return s>a-1?(console.warn("警告,光标位置异常,",e),null):{paragraph:r,line:i}}moveRight(t,e){const{paragraphIndex:n,lineIndex:o,charIndex:s}=e,r=this.checkValid(t,e);if(!r)return e;const{paragraph:i,line:a}=r;if(e.equal(t.tailTextCursorPosition()))return e;const c=a.getCharLength();return o===i.lines.length-1&&s===c-1?new Fe(n+1,0,-1):s===c-1?new Fe(n,o+1,-1):new Fe(n,o,s+1)}moveLeft(t,e){const{paragraphIndex:n,lineIndex:o,charIndex:s}=e,r=this.checkValid(t,e);if(!r)return e;const{paragraph:i,line:a}=r;if(e.equal(t.headTextCursorPosition()))return e;if(o===0&&s===-1)return t.paragraphs[n-1].tailCursorPosition();if(s===-1){const h=i.lines[o-1].getCharLength();return h>0?new Fe(n,o-1,h-2):new Fe(n,o-1,-1)}return new Fe(n,o,s-1)}moveUp(t,e){const{paragraphIndex:n,lineIndex:o,charIndex:s}=e,r=this.checkValid(t,e);if(!r)return e;const{paragraph:i,line:a}=r;if(n===0&&o===0)return e;const{relativePos:c,height:h}=t.getPosByCursorPosition(e),d=new m(c.x,c.y-1);return t.detect(d)}moveDown(t,e){const{paragraphIndex:n,lineIndex:o,charIndex:s}=e,r=this.checkValid(t,e);if(!r)return e;const{paragraph:i}=r;if(n===t.paragraphs.length-1&&o===i.lines.length-1)return e;const{relativePos:a,height:c}=t.getPosByCursorPosition(e),h=new m(a.x,a.y+c+1);return t.detect(h)}}const Ad="pingfang",le=5,kd=2,Nd=5,Bd=50,Rd="main_text_id",Ed=14,Hd=10,Gi=8,Oo=2,Ui=.4;class Dd{computeStyle(t,e,n,o,s){if(!s){t.paragraphStyle=null;return}const r=this.firstLineHeight(t),i=this.computePrefixToken(s.orderIndex,s.level),a={level:s.level,orderIndex:s.orderIndex,paraIndex:s.paraIndex,width:n,lineHeight:r,prefixToken:i,color:o};t.paragraphStyle=a}computePrefixToken(t,e){switch(e%3){case 0:return t.toString();case 1:return this.numberToLetter(t);case 2:return this.numberToRoman(t);default:return t.toString()}}numberToLetter(t){if(t<1)return"a";const e=(t-1)%26+97;return String.fromCharCode(e)}numberToRoman(t){if(t<1)return"I";const e=[[1e3,"M"],[900,"CM"],[500,"D"],[400,"CD"],[100,"C"],[90,"XC"],[50,"L"],[40,"XL"],[10,"X"],[9,"IX"],[5,"V"],[4,"IV"],[1,"I"]];let n="",o=t;for(const[s,r]of e)for(;o>=s;)n+=r,o-=s;return n}computeParagraphX(t,e,n){let o=0;if(n&&(o+=Gi),!e)return o;const{level:s}=e;return o+(s+1)*t}computePrefixWidth(t,e){const{fontSize:n,fontFamily:o,bold:s,italic:r}=e;t.font=M.calcFont(n,o,s,r);const{width:i,height:a}=M.measureText(t,"aaa"),c=M.measureText(t,"aa");return{width:i,height:a,prefixWidth:c.width}}draw(t,e,n){if(!e.paragraphStyle)return;const o=e.paragraphStyle.width,s=e.paragraphStyle.lineHeight,r=this.firstLineX(e),i=n.x+e.x+r-o,a=n.y+e.y+s;if(e.paragraphStyle.orderIndex>=0){t.fillText(e.paragraphStyle.prefixToken+".",i,a);return}const c=e.paragraphStyle.color||"#000000";t.strokeStyle=c,t.lineWidth=1,t.beginPath();const h=e.paragraphStyle.level%3,d=.1*o;switch(h){case 1:t.arc(i+.5*o,a-.5*s+d,d,0,Math.PI*2),t.stroke();return;case 2:t.rect(i+.5*o,a-.5*s,2*d,2*d),t.fill(),t.stroke();return;case 0:default:t.arc(i+.5*o,a-.5*s+d,d,0,Math.PI*2),t.fill(),t.stroke();return}}firstLineHeight(t){if(t.lines.length===0)return 20;const e=t.lines[0];return e.height<.1?20:e.height}firstLineX(t){if(t.lines.length===0)return 0;const e=t.lines[0];return e.height<.1?0:e.x}}class Od{constructor(){p(this,"textQuoteInfo",null);p(this,"paraStyleMap",new Map)}reset(){this.textQuoteInfo=null,this.paraStyleMap.clear()}getQuoteStyle(t){return this.paraStyleMap.get(t)}work(t,e){t.paraQuoteStyles.forEach(s=>this.paraStyleMap.set(s.paraIndex,s));let n=null;const o=[];for(let s=0;s<e.paragraphs.length;s++){const r=e.paragraphs[s],i=this.paraStyleMap.get(s);i&&i.quote?n?n.y1=r.y+r.height:n={x:0,y0:r.y,y1:r.y+r.height}:n&&(o.push(n),n=null)}n&&o.push(n),o.length>0&&(this.textQuoteInfo={quoteLines:o})}draw(t,e){if(this.textQuoteInfo){t.lineWidth=Oo,t.strokeStyle="#8F959E",t.lineCap="round",t.globalAlpha=1,t.beginPath();for(const n of this.textQuoteInfo.quoteLines){const{x:o,y1:s,y0:r}=n;t.moveTo(e.x+o+Oo,e.y+r),t.lineTo(e.x+o+Oo,e.y+s)}t.stroke()}}}class uo{constructor(){p(this,"paragraphs",[]);p(this,"x",0);p(this,"y",0);p(this,"width",0);p(this,"height",0);p(this,"textProps",new Ge);p(this,"paragraphProps",new qt);p(this,"paragraphQuoteProps",new Dt);p(this,"rect",new D);p(this,"prefixDrawer",new Dd);p(this,"textBlockMeasureWorker",new Yh);p(this,"richTextHelper",new Pi);p(this,"cursorMoveWorker",new ho);p(this,"textQuoteLineWorker",new Od)}draw(t,e,n=1){t.save();for(let d=0;d<this.paragraphs.length;d++){const u=this.paragraphs[d],g=new m(e.x+this.x,e.y+this.y),f=this.textQuoteLineWorker.getQuoteStyle(d);f&&f.quote?t.globalAlpha=Ui*n:t.globalAlpha=n,u.draw(t,g)}const{fontSize:o,fontColor:s,fontFamily:r,bold:i,italic:a}=this.textProps,c=e.x+this.x,h=e.y+this.y;t.globalAlpha=n,t.textBaseline="bottom",t.textAlign="left",t.fillStyle=s,t.font=M.calcFont(o,r,i,a);for(const d of this.paragraphs)this.prefixDrawer.draw(t,d,{x:c,y:h});this.textQuoteLineWorker.draw(t,{x:c,y:h}),t.restore()}contains(t){return M.rectContains2(t,{minX:this.rect.x,maxX:this.rect.x+this.rect.width,minY:this.rect.y,maxY:this.rect.y+this.rect.height})}detect(t){let{x:e,y:n}=t;if(this.paragraphs.length===0)return new Fe(-1,-1,-1);if(n<this.y)return this.headTextCursorPosition();if(e<this.x)return this.headTextCursorPosition();if(n>this.y+this.height)return this.tailTextCursorPosition();if(e>this.x+this.rect.width)return this.tailTextCursorPosition();e=e-this.x,n=n-this.y;for(const o of this.paragraphs){const s=new m(e-o.x,n-o.y),r=o.detect(s);if(r)return new Fe(o.index,r.lineIndex,r.charIndex)}return this.tailTextCursorPosition()}headTextCursorPosition(){return Fe.head()}tailTextCursorPosition(){const t=this.paragraphs[this.paragraphs.length-1],e=t.lines[t.lines.length-1],n=e.getCharLength(),o=n===0?-1:n-1;return new Fe(t.index,e.index,o)}addParagraph(t){t.y=this.height,t.index=this.paragraphs.length,this.paragraphs.push(t),this.width=Math.max(t.x+t.width,this.width),this.height=this.height+t.height}getParagraph(t){return t<0||this.paragraphs.length===0?null:t>this.paragraphs.length-1?(console.warn("index 超出该文本最大段落数目,fall back处理"),this.paragraphs[this.paragraphs.length-1]):this.paragraphs[t]}getPosByCursorPosition(t){const e=this.textProps,n=new m(this.x,this.y),{charIndex:o,lineIndex:s,paragraphIndex:r}=t,i=this.getParagraph(r);if(i===null)return{relativePos:n,height:e.fontSize};n.x+=i.x,n.y+=i.y;const a=i.getLine(s);if(a===null)return{relativePos:n,height:e.fontSize};n.x+=a.x,n.y+=a.y;const c=a.getCharacter(o);if(c===null)return{relativePos:n,height:a.height};const{character:h,textBlock:d}=c;return n.x+=d.x+h.x+h.width,n.y+=h.y,{relativePos:n,height:a.height}}reset(){this.paragraphs=[],this.x=0,this.y=0,this.width=0,this.height=0,this.textQuoteLineWorker.reset()}computeParagraphMap(){const t=new Map;for(const e of this.paragraphProps.paragraphStyles)t.set(e.paraIndex,e);return t}computeParagraphQuoteMap(){const t=new Map;for(const e of this.paragraphQuoteProps.paraQuoteStyles)t.set(e.paraIndex,e);return t}typesetting(t,e=this.textProps,n,o=this.paragraphProps,s=this.paragraphQuoteProps){this.reset(),this.rect=n,this.x=0,this.y=0,this.textProps=e,this.paragraphProps=o,this.paragraphQuoteProps=s;const r=this.computeParagraphMap(),i=this.computeParagraphQuoteMap(),{sizeMode:a}=e,c=a===We.autoWidth,h=this.richTextHelper.parse(e.richText,e);this.textBlockMeasureWorker.measureParagraphs(t,h);const{width:d,prefixWidth:u}=this.prefixDrawer.computePrefixWidth(t,this.textProps);for(let g=0;g<h.length;g++){const f=h[g],y=r.get(g),P=i.get(g),b=this.prefixDrawer.computeParagraphX(d,y,P),w=this.typesettingParagraph(t,f,n.width-b,c);w.x=b,this.prefixDrawer.computeStyle(w,b,u,e.fontColor,y),this.addParagraph(w)}this.alignVertical(n),this.alignHorizon(n),this.textQuoteLineWorker.work(this.paragraphQuoteProps,this)}typesettingParagraph(t,e,n,o){if(e.textBlocks.length===0){const c=new Cs,h=new Gn,{fontSize:d,fontFamily:u,bold:g,italic:f}=this.textProps,{height:y}=M.measureTextByFont(t,"1",d,u,g,f);return h.height=y,c.addLine(h),c}const s=new Cs,r=new Gn,i={paragraph:s,line:r};for(let c=0;c<e.textBlocks.length;c++){const h=e.textBlocks[c],d=c===e.textBlocks.length-1?null:e.textBlocks[c+1],u=dn.create(h);if(u.characters.length===0){const{fontSize:g,fontFamily:f,bold:y,italic:P}=u,{height:b}=M.measureTextByFont(t,"1",g,f,y,P);u.height=b}this.lineAddTextBlock(u,d,n,o,i)}const a=i.paragraph.lines;return(a.length===0||i.line!==a[a.length-1])&&i.paragraph.addLine(i.line),s}lineAddTextBlock(t,e,n,o,s){if(o)s.line.addTextBlock(t);else if(s.line.width+t.width<n)s.line.addTextBlock(t);else{const r=t.computeLineBreakPoint(e),i=M.judgeLineBreak(r,t,s.line,n);if(r.length===0||i<0)s.line.textBlocks.length>0&&(s.paragraph.addLine(s.line),s.line=new Gn),Cd.work(t,n,s);else{const a=t.characters.slice(0,i),c=dn.createByStyleAndCharacter(t,a);s.line.addTextBlock(c),s.paragraph.addLine(s.line),s.line=new Gn;const h=t.characters.slice(i,t.characters.length),d=dn.createByStyleAndCharacter(t,h);this.lineAddTextBlock(d,e,n,o,s);return}}}alignVertical(t){const e=this.textProps.verticalAlign;if(e===at.Top){this.y=t.y;return}if(e===at.Bottom){this.y=t.y+t.height-this.height;return}if(e===at.Middle){this.y=t.y+.5*t.height-.5*this.height;return}}alignHorizon(t){this.x=this.rect.x;let e=this.textProps.horizonAlign;this.textProps.sizeMode===We.autoWidth&&(e=at.Top);for(const n of this.paragraphs)n.alignHorizon(e,t.width-n.x)}modifyPosInEditing(t,e){const n=new m;let o=!1;const{relativePos:s,height:r}=this.getPosByCursorPosition(e);return s.x<t.x&&(n.x=t.x-s.x,o=!0),s.x>t.x+t.width&&(n.x=-(s.x-(t.x+t.width)),o=!0),s.y<t.y&&(n.y=t.y-s.y,o=!0),s.y+r>t.y+t.height&&(n.y=-(s.y+r-(t.y+t.height)),o=!0),o&&(this.x+=n.x,this.y+=n.y),o}resetFromEditing(t){this.alignVertical(t),this.x=t.x}isEmptyText(){if(this.paragraphs.length!==1)return!1;const t=this.paragraphs[0];return t.lines.length===0||t.lines.length===1&&t.lines[0].toString()===""}toRichTextXML(){let t="<root>";for(const e of this.paragraphs)t+=e.toRichTextXML(this.textProps);return t+"</root>"}toString(){let t="";for(const e of this.paragraphs)t+=e.toString();return t}prevParagraphToXML(t){let e="";for(let n=0;n<t;n++)e+=this.paragraphs[n].toRichTextXML(this.textProps);return e}nextParagraphToXML(t){let e="";for(let n=t+1;n<this.paragraphs.length;n++)e+=this.paragraphs[n].toRichTextXML(this.textProps);return e}nextCursorPos(t,e){let n=t;for(let o=0;o<e;o++)n=this.cursorMoveWorker.moveRight(this,n);return n}prevCursorPos(t,e){let n=t;for(let o=0;o<e;o++)n=this.cursorMoveWorker.moveLeft(this,n);return n}getTextCursorPosByIndex(t){let e=-1;for(let n=0;n<this.paragraphs.length;n++){const o=this.paragraphs[n];for(let s=0;s<o.lines.length;s++){const i=o.lines[s].getCharLength();if(e===t)return new Fe(n,s,-1);for(let a=0;a<i;a++)if(e++,e===t)return new Fe(n,s,a)}n<this.paragraphs.length-1&&e++}return this.tailTextCursorPosition()}getIndexByTextCursorPos(t){const{paragraphIndex:e,lineIndex:n,charIndex:o}=t;if(e<0||e>=this.paragraphs.length)return-1;let s=0;for(let c=0;c<e;c++){const h=this.paragraphs[c];for(let d=0;d<h.lines.length;d++){const u=h.lines[d];s+=u.getCharLength()}s++}const r=this.paragraphs[e];if(n<0||n>=r.lines.length)return s-1;for(let c=0;c<n;c++){const h=r.lines[c];s+=h.getCharLength()}const i=r.lines[n];if(o===-1)return s-1;const a=i.getCharLength();return o>=a?s+a-1:s+o}}class _i{constructor(){p(this,"characters",[]);p(this,"width",0)}addCharacter(t){this.characters.push(t),this.width=this.width+t.width}}class Fs{handle(t,e){const n=this.layoutToPoints(t,e);return this.getUpdateNodeData(t.id,n)}getNodePos(t,{x:e,y:n}){const o=new m,{width:s,height:r}=t.baseProps;return o.x=e*s,o.y=n*r,t.toGlobal(o)}getUpdateNodeData(t,e){return{infos:[{id:t,props:[{type:I.Line,points:e}]}]}}}class Xo extends Fs{enable(t){return t.shapeType===de.Line}layoutToPoints(t,e){const{start:n,end:o}=t.connectProps,s=t.globalLinePoints;let r=s[0],i=s[s.length-1];if(n){const d=e.nodeManager.getNode(n.objectId);d&&(r=this.getNodePos(d,n))}if(o){const d=e.nodeManager.getNode(o.objectId);d&&(i=this.getNodePos(d,o))}const a=[r,i],c=t.globalTransform().inverseMatrix();return a.map(d=>c.crossPoint(d))}layoutToPointsPro(t,e){return[t.point,e.point]}}function Xd(l,t,e){return(t.x-l.x)*(e.y-l.y)-(t.y-l.y)*(e.x-l.x)}function zd(l){if(l.length!==4)return!1;const t=[];for(let e=0;e<4;e++){const n=l[e],o=l[(e+1)%4],s=l[(e+2)%4],r=Xd(n,o,s);if(r===0)return!1;t.push(Math.sign(r))}return t.every(e=>e===t[0])}class zo{splitCurve(t){const e=t.getHalfTPos();return this.computeCurveControlPoint(t.p0,e,t.p3)}computeCurvePointsForLine(t,e,n=t.points){const{start:o,end:s}=t.connectProps,r=this.computeConnectEndInfo(o,e),i=this.computeConnectEndInfo(s,e);return this.computeCurvePoints(n,r,i)}computeConnectEndInfo(t,e){let n;if(t){const o=this.computeEndType(t,e);o&&(n=this.computeEndDirection(o.endType,o.nodeAngle))}return n}computeEndDirection(t,e){let n=0;switch(t){case ue.Top:n=-.5*Math.PI;break;case ue.Left:n=Math.PI;break;case ue.Bottom:n=.5*Math.PI;break;default:case ue.Right:n=0;break}const o=e/180*Math.PI;n+=o;const s=Math.cos(n),r=Math.sin(n);return{direction:{x:s,y:r}}}computeEndType(t,e){if(t){const n=e.getNode(t.objectId);if(n)return{endType:M.computeNodeConnectEnd(t,0),nodeAngle:n.baseProps.angle}}return null}computeCurvePoints(t,e,n){const o=M.computeBezierCurvesByPoints(t),s=o[0],r=s.p0;let i=new m(r.x,r.y);if(e){const g=.4*M.distance(r,s.p3),f=Math.sqrt(e.direction.x*e.direction.x+e.direction.y*e.direction.y);i=new m(r.x+g*(e.direction.x/f),r.y+g*(e.direction.y/f))}const a=[r,i];for(let u=1;u<o.length;u++){const g=o[u],f=g.p0,y=g.p3,{lP:P,midPoint:b,rP:w}=this.computeCurveControlPoint(i,f,y);a.push(P,b,w),i=w}const c=o[o.length-1],h=c.p3;let d=new m(h.x,h.y);if(n){const g=.4*M.distance(h,c.p0),f=Math.sqrt(n.direction.x*n.direction.x+n.direction.y*n.direction.y);d=new m(h.x+g*(n.direction.x/f),h.y+g*(n.direction.y/f))}return a.push(d,h),a}computeCurveControlPoint(t,e,n){const o=M.distance(t,e),s=M.distance(e,n),r=M.lineAngle(e,t),i=M.lineAngle(e,n),a=r-i,c=i+.5*a,h=c+.5*Math.PI,d=c-.5*Math.PI,u=e.x+.4*o*Math.cos(h),g=e.y+.4*o*Math.sin(h),f=e.x+.4*s*Math.cos(d),y=e.y+.4*s*Math.sin(d),P=new m(u,g),b=new m(f,y);return zd([n,t,P,b])?{lP:P,midPoint:e,rP:b}:{lP:b,midPoint:e,rP:P}}}class po extends Fs{constructor(){super(...arguments);p(this,"bezierWorker",new zo)}enable(e){return e.shapeType===de.Curve}handle(e,n){const{start:o,end:s}=e.connectProps,r=[...e.globalLinePoints];let i=r[0],a=r[r.length-1];if(o){const u=n.nodeManager.getNode(o.objectId);u&&(i=this.getNodePos(u,o),r.splice(0,1,i))}if(s){const u=n.nodeManager.getNode(s.objectId);u&&(a=this.getNodePos(u,s),r.splice(r.length-1,1,a))}const c=this.bezierWorker.computeCurvePointsForLine(e,n.nodeManager,r),h=e.globalTransform().inverseMatrix(),d=c.map(u=>h.crossPoint(u));return this.getUpdateNodeData(e.id,d)}computeLinePoints(e,n){const o=[],s=new m(n.x-e.x,n.y-e.y);if(Math.abs(s.x)>Math.abs(s.y)){const r=new m(e.x+.5*s.x,e.y),i=new m(n.x-.5*s.x,n.y);o.push(e,r,i,n)}else{const r=new m(e.x,e.y+.5*s.y),i=new m(n.x,n.y-.5*s.y);o.push(e,r,i,n)}return o}layoutToPoints(e,n){const{start:o,end:s}=e.connectProps,r=e.points,i=r[0],a=r[r.length-1];return this.computeLinePoints(i,a)}layoutToPointsPro(e,n){return this.computeLinePoints(e.point,n.point)}}class go{constructor(t){p(this,"startPoint");this.startPoint=t}}class R{static computeZLinePoints(t,e,n){if(n){const r=new m(t.x,.5*(t.y+e.y)),i=new m(e.x,.5*(t.y+e.y));return[t,r,i,e]}const o=new m(.5*(t.x+e.x),t.y),s=new m(.5*(t.x+e.x),e.y);return[t,o,s,e]}static computeLLinePoints(t,e,n){if(n){const s=new m(t.x,e.y);return[t,s,e]}const o=new m(e.x,t.y);return[t,o,e]}}class Wd extends go{constructor(e,n){super(e);p(this,"rect");this.rect=n}bottom(e,n){const o=this.startPoint;if(e.y<o.y)return Math.abs(o.x-e.x)<.01?[o,e]:R.computeZLinePoints(o,e,!0);const s=new m(.5*(o.x+e.x),o.y-A);if(Math.abs(s.x-this.rect.x-.5*this.rect.width)<.5*this.rect.width||Math.abs(s.x-n.x-.5*n.width)<.5*n.width)if(o.x>e.x){const c=new m(Math.min(this.rect.x-A,n.x-A),Math.min(n.y-A,this.rect.y-A)),h=new m(e.x,Math.max(this.rect.y+this.rect.height+A,n.y+n.height+A)),d=R.computeLLinePoints(o,c,!0),u=R.computeLLinePoints(c,h,!0);return u.shift(),[...d,...u,e]}else{const c=new m(n.x+n.width+A,Math.min(n.y-A,this.rect.y-A)),h=new m(e.x,Math.max(this.rect.y+this.rect.height+A,n.y+n.height+A)),d=R.computeLLinePoints(o,c,!0),u=R.computeLLinePoints(c,h,!0);return u.shift(),[...d,...u,e]}const r=new m(e.x,e.y+A),i=R.computeLLinePoints(o,s,!0),a=R.computeLLinePoints(s,r,!0);return a.shift(),[...i,...a,e]}left(e,n){const o=this.startPoint;if(e.y<o.y&&e.x>o.x)return R.computeLLinePoints(o,e,!0);if(e.y<o.y){const a=new m(Math.min(this.rect.x-A,n.x-A),.5*(o.y+e.y));if(Math.abs(a.y-this.rect.y-.5*this.rect.height)<.5*this.rect.height||Math.abs(a.y-n.y-.5*n.height)<.5*n.height){const d=new m(Math.min(this.rect.x-A,n.x-A),Math.min(this.rect.y-A,n.y-A)),u=R.computeLLinePoints(o,d,!0),g=R.computeLLinePoints(d,e,!0);return g.shift(),[...u,...g]}const c=R.computeLLinePoints(o,a,!0),h=R.computeLLinePoints(a,e,!0);return h.shift(),[...c,...h]}if(e.x>this.rect.x+this.rect.width+A){const a=new m(.5*(this.rect.x+this.rect.width+n.x),this.rect.y-A),c=R.computeLLinePoints(o,a,!0),h=R.computeLLinePoints(a,e,!0);return h.shift(),[...c,...h]}const s=new m(Math.min(this.rect.x-A,n.x-A),this.rect.y-A),r=R.computeLLinePoints(o,s,!0),i=R.computeLLinePoints(s,e,!0);return i.shift(),[...r,...i]}right(e,n){const o=this.startPoint;if(e.y<o.y&&e.x<o.x)return R.computeLLinePoints(o,e,!0);if(e.y<o.y){const a=new m(Math.max(this.rect.x+this.rect.width+A,n.x+n.width+A),.5*(o.y+e.y));if(Math.abs(a.y-this.rect.y-.5*this.rect.height)<.5*this.rect.height||Math.abs(a.y-n.y-.5*n.height)<.5*n.height){const d=new m(Math.min(this.rect.x+this.rect.width+A,n.x+n.width+A),Math.min(this.rect.y-A,n.y-A)),u=R.computeLLinePoints(o,d,!0),g=R.computeLLinePoints(d,e,!0);return g.shift(),[...u,...g]}const c=R.computeLLinePoints(o,a,!0),h=R.computeLLinePoints(a,e,!0);return h.shift(),[...c,...h]}if(e.x<this.rect.x-A){const a=new m(.5*(this.rect.x+n.x),this.rect.y-A),c=R.computeLLinePoints(o,a,!0),h=R.computeLLinePoints(a,e,!0);return h.shift(),[...c,...h]}const s=new m(Math.min(this.rect.x+this.rect.width+A,n.x+n.width+A),this.rect.y-A),r=R.computeLLinePoints(o,s,!0),i=R.computeLLinePoints(s,e,!0);return i.shift(),[...r,...i]}top(e,n){const o=this.startPoint;if(e.y>this.rect.y+this.rect.height+A&&Math.abs(e.x-this.rect.x-.5*this.rect.width)<.5*this.rect.width){if(e.x>o.x){const d=new m(this.rect.x+this.rect.width+A,this.rect.y-A),u=new m(e.x,n.y-A),g=R.computeLLinePoints(o,d,!0),f=R.computeLLinePoints(d,u,!0);return f.shift(),[...g,...f,e]}const i=new m(this.rect.x-A,this.rect.y-A),a=new m(e.x,n.y-A),c=R.computeLLinePoints(o,i,!0),h=R.computeLLinePoints(i,a,!0);return h.shift(),[...c,...h,e]}if(n.y+n.height<this.rect.y){if(e.x>o.x){const d=new m(n.x-A,this.rect.y-A),u=new m(e.x,n.y-A),g=R.computeLLinePoints(o,d,!0),f=R.computeLLinePoints(d,u,!0);return f.shift(),[...g,...f,e]}const i=new m(n.x+n.width+A,this.rect.y-A),a=new m(e.x,n.y-A),c=R.computeLLinePoints(o,i,!0),h=R.computeLLinePoints(i,a,!0);return h.shift(),[...c,...h,e]}const s=new m(e.x,Math.min(this.rect.y-A,n.y-A));return[...R.computeLLinePoints(o,s,!0),e]}toPoint(e){if(M.rectContains(e,new D(this.rect.x-A,this.rect.y,2*A,this.rect.height))){const r=new m(this.rect.x-A,this.rect.y-A),i=R.computeLLinePoints(this.startPoint,r,!0),a=R.computeLLinePoints(r,e,!0);return a.shift(),[...i,...a]}if(M.rectContains(e,new D(this.rect.x+this.rect.width-A,this.rect.y,2*A,this.rect.height))){const r=new m(this.rect.x+this.rect.width+A,this.rect.y-A),i=R.computeLLinePoints(this.startPoint,r,!0),a=R.computeLLinePoints(r,e,!0);return a.shift(),[...i,...a]}if(M.rectContains(e,new D(this.rect.x,this.rect.y+this.rect.height-A,this.rect.width,2*A))){const r=new m(this.rect.x-A,this.rect.y-A),i=new m(e.x,this.rect.y+this.rect.height+A),a=R.computeLLinePoints(this.startPoint,r,!0),c=R.computeLLinePoints(r,i,!0);return c.shift(),[...a,...c,e]}if(M.rectContains(e,new D(this.rect.x,this.rect.y-A,this.rect.width,2*A))){const r=new m(e.x,this.rect.y-A);return[...R.computeLLinePoints(this.startPoint,r,!0),e]}if(e.y<this.startPoint.y)return R.computeZLinePoints(this.startPoint,e,!0);if(e.x<this.rect.x||e.x>this.rect.x+this.rect.width)return[...R.computeLLinePoints(this.startPoint,new m(e.x,this.rect.y-A),!0),e];if(e.x<this.rect.x+.5*this.rect.width){const r=new m(this.rect.x-A,this.rect.y-A),i=R.computeLLinePoints(this.startPoint,r,!0),a=R.computeLLinePoints(r,e,!0);return a.shift(),[...i,...a]}const n=new m(this.rect.x+this.rect.width+A,this.rect.y-A),o=R.computeLLinePoints(this.startPoint,n,!0),s=R.computeLLinePoints(n,e,!0);return s.shift(),[...o,...s]}}class $i extends go{bottom(t,e){const n=this.startPoint;if(t.y<n.y)return R.computeZLinePoints(n,t,!0);if(M.inDistance(n.x,e.x,e.width))if(n.x<e.x+.5*e.width){const r=new m(e.x-A,e.y+e.height+A),i=R.computeLLinePoints(n,r,!1),a=R.computeLLinePoints(r,t,!1);return a.shift(),[...i,...a]}else{const r=new m(e.x+e.width+A,e.y+e.height+A),i=R.computeLLinePoints(n,r,!1),a=R.computeLLinePoints(r,t,!1);return a.shift(),[...i,...a]}const o=new m(t.x,e.y+e.height+A);return[...R.computeLLinePoints(n,o,!0),t]}left(t,e){const n=this.startPoint;if(t.x>n.x)return R.computeZLinePoints(n,t,!1);if(M.inDistance(n.y,e.y,e.height))if(n.y<e.y+.5*e.height){const r=new m(e.x-A,e.y-A),i=R.computeLLinePoints(n,r,!0),a=R.computeLLinePoints(r,t,!0);return a.shift(),[...i,...a]}else{const r=new m(e.x-A,e.y+e.height+A),i=R.computeLLinePoints(n,r,!0),a=R.computeLLinePoints(r,t,!0);return a.shift(),[...i,...a]}const o=new m(e.x-A,t.y);return[...R.computeLLinePoints(n,o,!1),t]}right(t,e){const n=this.startPoint;if(t.x<n.x)return R.computeZLinePoints(n,t,!1);if(M.inDistance(n.y,e.y,e.height))if(n.y<e.y+.5*e.height){const r=new m(e.x+e.width+A,e.y-A),i=R.computeLLinePoints(n,r,!0),a=R.computeLLinePoints(r,t,!0);return a.shift(),[...i,...a]}else{const r=new m(e.x+e.width+A,e.y+e.height+A),i=R.computeLLinePoints(n,r,!0),a=R.computeLLinePoints(r,t,!0);return a.shift(),[...i,...a]}const o=new m(e.x+e.width+A,t.y);return[...R.computeLLinePoints(n,o,!1),t]}toPoint(t){return M.computePolyLinePoints(this.startPoint,t)}top(t,e){const n=this.startPoint;if(t.y>n.y)return R.computeZLinePoints(n,t,!0);if(M.inDistance(n.x,e.x,e.width))if(n.x<e.x+.5*e.width){const r=new m(e.x-A,e.y-A),i=R.computeLLinePoints(n,r,!1),a=R.computeLLinePoints(r,t,!1);return a.shift(),[...i,...a]}else{const r=new m(e.x+e.width+A,e.y-A),i=R.computeLLinePoints(n,r,!1),a=R.computeLLinePoints(r,t,!1);return a.shift(),[...i,...a]}const o=new m(t.x,e.y-A);return[...R.computeLLinePoints(n,o,!0),t]}}class Fd extends go{constructor(e,n){super(e);p(this,"rect");this.rect=n}bottom(e,n){const o=this.startPoint;if(e.y+A<this.rect.y&&M.inDistance(e.x,this.rect.x,this.rect.width))if(e.x>this.rect.x+.5*this.rect.width){const i=new m(this.rect.x+this.rect.width+A,this.rect.y+this.rect.height+A),a=new m(e.x,n.y+n.height+A),c=R.computeLLinePoints(o,i,!0),h=R.computeLLinePoints(i,a,!0);return h.shift(),[...c,...h,e]}else{const i=new m(this.rect.x-A,this.rect.y+this.rect.height+A),a=new m(e.x,n.y+n.height+A),c=R.computeLLinePoints(o,i,!0),h=R.computeLLinePoints(i,a,!0);return h.shift(),[...c,...h,e]}if(o.y+A<n.y&&M.inDistance(o.x,n.x,n.width)){if(o.x<n.x+.5*n.width){const d=new m(n.x-A,this.rect.y+this.rect.height+A),u=new m(e.x,n.y+n.height+A),g=R.computeLLinePoints(o,d,!0),f=R.computeLLinePoints(d,u,!0);return f.shift(),[...g,...f,e]}const i=new m(n.x+n.width+A,this.rect.y+this.rect.height+A),a=new m(e.x,n.y+n.height+A),c=R.computeLLinePoints(o,i,!0),h=R.computeLLinePoints(i,a,!0);return h.shift(),[...c,...h,e]}const s=new m(e.x,Math.max(n.y+n.height+A,this.rect.y+this.rect.height+A));return[...R.computeLLinePoints(o,s,!0),e]}left(e,n){const o=this.startPoint;if(e.x>o.x&&e.y>o.y)return R.computeLLinePoints(o,e,!0);if(e.x>this.rect.x+this.rect.width+A&&e.y<o.y){const a=new m(this.rect.x+this.rect.width+A,this.rect.y+this.rect.height+A),c=R.computeLLinePoints(o,a,!0),h=R.computeLLinePoints(a,e,!0);return h.shift(),[...c,...h]}if(e.x<this.rect.x+this.rect.width+A){const a=new m(Math.min(n.x-A,this.rect.x-A),Math.max(n.y+n.height+A,this.rect.y+this.rect.height+A)),c=R.computeLLinePoints(o,a,!0),h=R.computeLLinePoints(a,e,!0);return h.shift(),[...c,...h]}const s=new m(n.x-A,n.y-A),r=R.computeLLinePoints(o,s,!0),i=R.computeLLinePoints(s,e,!0);return i.shift(),[...r,...i]}right(e,n){const o=this.startPoint;if(e.x<o.x&&e.y>o.y)return R.computeLLinePoints(o,e,!0);if(n.x+n.width>this.rect.x-A){if(n.y<this.rect.y+this.rect.height+A){const a=new m(Math.max(n.x+n.width+A,this.rect.x+this.rect.width+A),Math.max(this.rect.y+this.rect.height+A,n.y+n.height+A)),c=R.computeLLinePoints(o,a,!0),h=R.computeLLinePoints(a,e,!0);return h.shift(),[...c,...h]}const s=new m(n.x+n.width+A,this.rect.y+this.rect.height+A),r=R.computeLLinePoints(o,s,!0),i=R.computeLLinePoints(s,e,!0);return i.shift(),[...r,...i]}if(e.y<this.rect.y+this.rect.height+A){const s=new m(this.rect.x-A,this.rect.y+this.rect.height+A),r=R.computeLLinePoints(o,s,!0),i=R.computeLLinePoints(s,e,!0);return i.shift(),[...r,...i]}return R.computeLLinePoints(o,e,!0)}toPoint(e){const n=this.startPoint;if(e.y>n.y)return R.computeZLinePoints(n,e,!0);if(M.inDistance(e.x,this.rect.x,this.rect.width))if(e.x<this.rect.x+.5*this.rect.width){const r=new m(this.rect.x-A,this.rect.y+this.rect.height+A),i=R.computeLLinePoints(n,r,!0),a=R.computeLLinePoints(r,e,!0);return a.shift(),[...i,...a]}else{const r=new m(this.rect.x+this.rect.width+A,this.rect.y+this.rect.height+A),i=R.computeLLinePoints(n,r,!0),a=R.computeLLinePoints(r,e,!0);return a.shift(),[...i,...a]}const o=new m(n.x,this.rect.y+this.rect.height+A),s=R.computeLLinePoints(o,e,!1);return[n,...s]}top(e,n){const o=this.startPoint;if(e.y>o.y)return R.computeZLinePoints(o,e,!0);if(n.x+n.width+A<this.rect.x){const c=new m(n.x+n.width+A,this.rect.y+this.rect.height+A),h=new m(e.x,n.y-A),d=R.computeLLinePoints(o,c,!0),u=R.computeLLinePoints(c,h,!0);return u.shift(),[...d,...u,e]}if(n.x+n.width<o.x){const c=new m(n.x+-A,this.rect.y+this.rect.height+A),h=new m(e.x,n.y-A),d=R.computeLLinePoints(o,c,!0),u=R.computeLLinePoints(c,h,!0);return u.shift(),[...d,...u,e]}if(n.x>this.rect.x+this.rect.width+A){const c=new m(n.x-A,this.rect.y+this.rect.height+A),h=new m(e.x,n.y-A),d=R.computeLLinePoints(o,c,!0),u=R.computeLLinePoints(c,h,!0);return u.shift(),[...d,...u,e]}const s=new m(Math.max(n.x+n.width+A,this.rect.x+this.rect.width+A),this.rect.y+this.rect.height+A),r=new m(e.x,n.y-A),i=R.computeLLinePoints(o,s,!0),a=R.computeLLinePoints(s,r,!0);return a.shift(),[...i,...a,e]}}class Yd extends go{constructor(e,n){super(e);p(this,"rect");this.rect=n}bottom(e,n){const o=this.startPoint;if(e.y<o.y){if(e.x<o.x)return R.computeLLinePoints(o,e,!1);const a=new m(this.rect.x-A,n.y+n.height+A),c=R.computeLLinePoints(o,a,!1),h=R.computeLLinePoints(a,e,!1);return h.shift(),[...c,...h]}if(e.y>o.y&&e.x<o.x){const a=new m(this.rect.x-A,e.y+A),c=R.computeLLinePoints(o,a,!1),h=R.computeLLinePoints(a,e,!1);return h.shift(),[...c,...h]}const s=new m(this.rect.x-A,e.y+A),r=R.computeLLinePoints(o,s,!1),i=R.computeLLinePoints(s,e,!1);return i.shift(),[...r,...i]}left(e,n){const o=this.startPoint;if(e.y<this.rect.y){const i=new m(Math.min(this.rect.x-A,n.x-A),e.y);return[...R.computeLLinePoints(o,i,!1),e]}if(e.y>this.rect.y+this.rect.height){const i=new m(Math.min(this.rect.x-A,n.x-A),e.y);return[...R.computeLLinePoints(o,i,!1),e]}if(e.y<this.rect.y+this.rect.height&&e.x>this.rect.x+this.rect.width){const i=new m(this.rect.x-A,this.rect.y-A),a=new m(n.x-A,e.y),c=R.computeLLinePoints(o,i,!1),h=R.computeLLinePoints(i,a,!1);return h.shift(),[...c,...h,e]}const s=new m(Math.min(this.rect.x-A,n.x-A),e.y);return[...R.computeLLinePoints(o,s,!1),e]}right(e,n){const o=this.startPoint;if(e.x<o.x)return R.computeZLinePoints(o,e,!1);if(e.y<o.y){const c=new m(this.rect.x-A,n.y+n.height+A),h=new m(n.x+n.width+A,e.y),d=R.computeLLinePoints(o,c,!1),u=R.computeLLinePoints(c,h,!1);return u.shift(),[...d,...u,e]}const s=new m(this.rect.x-A,n.y-A),r=new m(n.x+n.width+A,e.y),i=R.computeLLinePoints(o,s,!1),a=R.computeLLinePoints(s,r,!1);return a.shift(),[...i,...a,e]}toPoint(e){const n=this.startPoint;if(e.x>n.x&&e.y<this.rect.y){const r=new m(this.rect.x-A,e.y);return[...R.computeLLinePoints(n,r,!1),e]}if(e.x>n.x&&e.y>this.rect.y&&e.y<n.y){const r=new m(this.rect.x-A,this.rect.y-A),i=R.computeLLinePoints(n,r,!1),a=R.computeLLinePoints(r,e,!1);return a.shift(),[...i,...a]}if(e.x>n.x&&e.y>n.y&&e.y<this.rect.y+this.rect.height){const r=new m(this.rect.x-A,this.rect.y+this.rect.height+A),i=R.computeLLinePoints(n,r,!1),a=R.computeLLinePoints(r,e,!1);return a.shift(),[...i,...a]}if(e.x<n.x)return R.computeZLinePoints(n,e,!1);const o=new m(this.rect.x-A,e.y);return[...R.computeLLinePoints(n,o,!1),e]}top(e,n){const o=this.startPoint;if(e.x>o.x&&e.y<this.rect.y+this.rect.height+A){const s=new m(this.rect.x-A,Math.min(this.rect.y-A,n.y-A)),r=R.computeLLinePoints(o,s,!1),i=R.computeLLinePoints(s,e,!1);return i.shift(),[...r,...i]}if(e.y<o.y+2&&e.x<o.x){const s=new m(this.rect.x-A,n.y-A),r=R.computeLLinePoints(o,s,!1),i=R.computeLLinePoints(s,e,!1);return i.shift(),[...r,...i]}if(e.x>o.x&&e.y>this.rect.y+this.rect.height+A){const s=new m(this.rect.x-A,this.rect.y+this.rect.height+A),r=R.computeLLinePoints(o,s,!1),i=R.computeLLinePoints(s,e,!1);return i.shift(),[...r,...i]}return R.computeLLinePoints(o,e,!1)}}class Gd extends go{constructor(e,n){super(e);p(this,"rect");this.rect=n}bottom(e,n){const o=this.startPoint;if(e.x>o.x){if(e.y<o.y)return R.computeLLinePoints(o,e,!1);const a=new m(this.rect.x+this.rect.width+A,n.y+n.height+A),c=R.computeLLinePoints(o,a,!1),h=R.computeLLinePoints(a,e,!1);return h.shift(),[...c,...h]}if(e.y<this.rect.y){const a=new m(this.rect.x+this.rect.width+A,n.y+n.height+A),c=R.computeLLinePoints(o,a,!1),h=R.computeLLinePoints(a,e,!1);return h.shift(),[...c,...h]}const s=new m(this.rect.x+this.rect.width+A,Math.max(n.y+n.height+A,this.rect.y+this.rect.height+A)),r=R.computeLLinePoints(o,s,!1),i=R.computeLLinePoints(s,e,!1);return i.shift(),[...r,...i]}left(e,n){const o=this.startPoint;if(e.x>o.x)return R.computeZLinePoints(o,e,!1);if(e.y<this.rect.y){const c=new m(this.rect.x+this.rect.width+A,n.y+n.height+A),h=new m(n.x-A,e.y),d=R.computeLLinePoints(o,c,!1),u=R.computeLLinePoints(c,h,!1);return u.shift(),[...d,...u,e]}if(e.y>this.rect.y+this.rect.height){const c=new m(this.rect.x+this.rect.width+A,n.y-A),h=new m(n.x-A,e.y),d=R.computeLLinePoints(o,c,!1),u=R.computeLLinePoints(c,h,!1);return u.shift(),[...d,...u,e]}if(e.y<this.rect.y+.5*this.rect.height){const c=new m(this.rect.x+this.rect.width+A,Math.min(n.y-A,this.rect.y-A)),h=new m(n.x-A,e.y),d=R.computeLLinePoints(o,c,!1),u=R.computeLLinePoints(c,h,!1);return u.shift(),[...d,...u,e]}const s=new m(this.rect.x+this.rect.width+A,Math.max(n.y+n.height+A,this.rect.y+this.rect.height+A)),r=new m(n.x-A,e.y),i=R.computeLLinePoints(o,s,!1),a=R.computeLLinePoints(s,r,!1);return a.shift(),[...i,...a,e]}right(e,n){const o=this.startPoint;if(e.y<this.rect.y||e.y>this.rect.y+this.rect.height){const c=new m(Math.max(n.x+n.width+A,this.rect.x+this.rect.width+A),e.y);return[...R.computeLLinePoints(o,c,!1),e]}if(e.y<this.rect.y+.5*this.rect.height){const c=new m(this.rect.x+this.rect.width+A,this.rect.y-A),h=new m(n.x+n.width+A,e.y),d=R.computeLLinePoints(o,c,!1),u=R.computeLLinePoints(c,h,!1);return u.shift(),[...d,...u,e]}const s=new m(this.rect.x+this.rect.width+A,this.rect.y+this.rect.height+A),r=new m(n.x+n.width+A,e.y),i=R.computeLLinePoints(o,s,!1),a=R.computeLLinePoints(s,r,!1);return a.shift(),[...i,...a,e]}toPoint(e){const n=this.startPoint;if(e.x>n.x)return R.computeZLinePoints(n,e,!1);if(e.y<this.rect.y||e.y>this.rect.y+this.rect.height){const i=new m(this.rect.x+this.rect.width+A,e.y);return[...R.computeLLinePoints(n,i,!1),e]}if(e.y<this.rect.y+.5*this.rect.height){const i=new m(this.rect.x+this.rect.width+A,this.rect.y-A),a=R.computeLLinePoints(n,i,!1),c=R.computeLLinePoints(i,e,!1);return c.shift(),[...a,...c]}const o=new m(this.rect.x+this.rect.width+A,this.rect.y+this.rect.height+A),s=R.computeLLinePoints(n,o,!1),r=R.computeLLinePoints(o,e,!1);return r.shift(),[...s,...r]}top(e,n){const o=this.startPoint;if(e.y>o.y&&e.x>o.x)return R.computeLLinePoints(o,e,!1);if(e.y>this.rect.y+this.rect.height){const a=new m(this.rect.x+this.rect.width+A,this.rect.y+this.rect.height+A),c=R.computeLLinePoints(o,a,!1),h=R.computeLLinePoints(a,e,!1);return h.shift(),[...c,...h]}if(n.x<this.rect.x+this.rect.width+A){const a=new m(Math.max(this.rect.x+this.rect.width+A,n.x+n.width+A),Math.min(n.y-A,this.rect.y-A)),c=R.computeLLinePoints(o,a,!1),h=R.computeLLinePoints(a,e,!1);return h.shift(),[...c,...h]}const s=new m(this.rect.x+this.rect.width+A,n.y-A),r=R.computeLLinePoints(o,s,!1),i=R.computeLLinePoints(s,e,!1);return i.shift(),[...r,...i]}}class Ze{static mockPointermoveEvent(t,e){return{pointerId:1,width:1,height:1,pressure:.5,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,type:"pointermove",pointerType:"mouse",isPrimary:!0,bubbles:!0,cancelable:!0,composed:!0,clientX:t.x,clientY:t.y,...e}}static getNodePos(t,{x:e,y:n}){const o=new m,{width:s,height:r}=t.baseProps;return o.x=e*s,o.y=n*r,t.toGlobal(o)}static computeConnectInfo(t,e,n,o=!1){const s=t.globalLinePoints,r={point:o?s[s.length-1]:s[0]};if(e){const i=n.nodeManager.getNode(e.objectId);i&&(r.nodeConnect={rect:D.rectNode2Rect(i.getBounds()),endType:M.computeNodeConnectEnd(e,i.baseProps.angle)},r.point=this.getNodePos(i,e))}return r}static computeLinePoints(t,e,n,o,s){const r=o.detect(F.NodeEdge,n),i=!M.pressMeta(n),c={point:s.alignLineEndAndDrawAlignLines(n,o,o.getSelectNodes(),i)};return r&&(c.point=new m(r.point.x,r.point.y),c.nodeConnect={rect:D.rectNode2Rect(r.node.getBounds()),endType:M.computeNodeConnectEnd(r.relativePos,r.node.baseProps.angle)}),e.layoutToPointsPro(t,c)}static trimAngle(t){const e=Math.floor(t/360);return t-e*360}static calculateAngle(t,e){return Math.abs(t.x-e.x)<.01?e.y>t.y?90:-90:Math.atan2(e.y-t.y,e.x-t.x)/Math.PI*180}static calculateAngle2(t,e){return Math.abs(t.x-e.x)<.01?e.y>t.y?.5*Math.PI:-.5*Math.PI:Math.atan2(e.y-t.y,e.x-t.x)}static trimPoint(t){return new m(Math.floor(t.x),Math.floor(t.y))}static overlapHorizonVertical(t,e,n){if(Ze.judgeHorizon(t,e)){if(t.y<n.minY||t.y>n.maxY)return!1;const s=t.x>e.x?e.x:t.x,r=t.x<e.x?e.x:t.x;if(s>n.maxX||r<n.minX)return!1}else{if(t.x<n.minX||t.x>n.maxX)return!1;const s=t.y>e.y?e.y:t.y,r=t.y<e.y?e.y:t.y;if(s>n.maxY||r<n.minY)return!1}return!0}static overlapHorizon(t,e,n,o,s){const r=o.y>s.y?s.y:o.y,i=o.y<s.y?s.y:o.y;if(r>n||i<n)return!1;const a=o.x>s.x?s.x:o.x,c=o.x<s.x?s.x:o.x;return!(a>e||c<t)}static overlapVertical(t,e,n,o,s){const r=o.x>s.x?s.x:o.x,i=o.x<s.x?s.x:o.x;if(r>n||i<n)return!1;const a=o.y>s.y?s.y:o.y,c=o.y<s.y?s.y:o.y;return!(a>e||c<t)}static overlapSimpleLine(t,e,n){if(this.overlapHorizon(n.minX,n.maxX,n.minY,t,e)||this.overlapHorizon(n.minX,n.maxX,n.maxY,t,e)||this.overlapVertical(n.minY,n.maxY,n.maxX,t,e)||this.overlapVertical(n.minY,n.maxY,n.minX,t,e))return!0;const o=t.x>e.x?e.x:t.x,s=t.x<e.x?e.x:t.x,r=t.y>e.y?e.y:t.y,i=t.y<e.y?e.y:t.y;return s<=n.maxX&&o>=n.minX&&i<=n.maxY&&r>=n.minY}static overlapPolyLine(t,e){for(let n=0;n<t.length-1;n++){const o=t[n],s=t[n+1];if(this.overlapHorizonVertical(o,s,e))return!0}return!1}static interactRect(t,e){return{minX:Math.max(t.minX,e.minX),maxX:Math.min(t.maxX,e.maxX),minY:Math.max(t.minY,e.minY),maxY:Math.min(t.maxY,e.maxY)}}static needDrawByDelete(t,e,n,o,s){const r=t.nodeManager.tree.search(e),i=new Set;for(const c of r){const h=t.nodeManager.nodeMap.get(c.id);h&&i.add(h)}s||i.add(o);const a=[...i];return a.sort((c,h)=>c.zIndex-h.zIndex),a}static layout(t,e){const n=[];return M.doubleMiddleInsertPoint(t,e,n),n}static judgeHorizon(t,e,n=.01){return Math.abs(t.y-e.y)<n}static judgeVertical(t,e,n=.01){return Math.abs(t.x-e.x)<n}static getOfflineCanvas(t,e,n){const o=D.rectNode2Rect(t),s=document.createElement("canvas");s.width=n*o.width,s.height=n*o.height;const r=s.getContext("2d");r.scale(n,n),r.translate(-o.x,-o.y);const i=e.searchNodesByRectNode(t);for(const a of i)a.drawOnGLCtx(r);return s}}class ji{constructor(t){p(this,"modes",[]);p(this,"currentMode");this.modes=t.modes,this.currentMode=t.modes[t.modes.length-1]}onEvent(t,e){this.reset(t,e);const n=this.convertInteractiveEvent(t,e);this.detect(n,e),this.currentMode.work(n,e),this.afterOnEvent(n,e)}refreshEvent(t,e){const n=t.lastInteractiveEvent.originEvent,o=new m(n.clientX,n.clientY),s=Ze.mockPointermoveEvent(o,e);s.target=t.gmlRender.canvas,this.onEvent(s,t)}detect(t,e){if(this.currentMode.canBeExit(t,e)){for(const n of this.modes)if(n.canBeEnable(t,e)){this.currentMode=n;return}}}reset(t,e){var n;e.reset();for(const[o,s]of e.detectors)s.reset();t.type!==((n=e.lastInteractiveEvent)==null?void 0:n.type)&&(e.lastDiffTypeEvent=e.lastInteractiveEvent)}afterOnEvent(t,e){this.record(t,e)}record(t,e){e.lastInteractiveEvent=t}convertInteractiveEvent(t,e){const n=e.gmlRender.canvas.getBoundingClientRect(),o=new m(t.clientX-n.x,t.clientY-n.y),s=e.gmlRender.transformToGlobal(o);return{clientPoint:new m(t.clientX,t.clientY),globalPoint:s,type:this.convertEventType(t,e),originEvent:t}}convertEventType(t,e){const n=t.type;return n==="pointerdown"?be.pointerDown:n==="pointermove"?t.target!=e.gmlRender.canvas?be.pointermoveOutside:be.pointermove:n==="pointerup"?be.pointerup:be.unknown}}class Ud{constructor(){p(this,"isWorking",!1);p(this,"initialTouchInfo",null);p(this,"lastTouchInfo",null);p(this,"SCALE_THRESHOLD",10);p(this,"MOVE_THRESHOLD",5)}enable(t){return t.touches.length===2}start(t,e){this.enable(t)&&(this.isWorking=!0,this.initialTouchInfo=this.getTouchInfo(t),this.lastTouchInfo=this.initialTouchInfo)}move(t,e){if(!this.isWorking||!this.lastTouchInfo)return;const n=this.getTouchInfo(t),o=e.renderManager.gmlRender.transformToGlobal(this.lastTouchInfo.centerPoint),s=n.distance/this.lastTouchInfo.distance;this.handleZoom(s,o,e);const r=n.centerPoint.x-this.lastTouchInfo.centerPoint.x,i=n.centerPoint.y-this.lastTouchInfo.centerPoint.y;this.handleScroll(r,i,e),this.lastTouchInfo=n}stop(t,e){this.isWorking=!1,this.initialTouchInfo=null,this.lastTouchInfo=null}getTouchInfo(t){const e=new m(t.touches[0].clientX,t.touches[0].clientY),n=new m(t.touches[1].clientX,t.touches[1].clientY),o=new m((e.x+n.x)/2,(e.y+n.y)/2),s=n.x-e.x,r=n.y-e.y,i=Math.sqrt(s*s+r*r);return{centerPoint:o,distance:i,touch1:e,touch2:n}}handleZoom(t,e,n){n.renderManager.zoomScale(t,e)}handleScroll(t,e,n){n.renderManager.scroll(-t,-e)}}class Wo{constructor(t,e){p(this,"eventCtx");p(this,"interactiveManager");p(this,"touchScrollZoomWorker");p(this,"onContextMenu",t=>{t.preventDefault()});p(this,"onTouchStart",t=>{if(this.touchScrollZoomWorker.enable(t)){t.preventDefault(),t.stopPropagation(),this.touchScrollZoomWorker.start(t,this.eventCtx);return}});p(this,"onTouchMove",t=>{if(this.touchScrollZoomWorker.isWorking){t.preventDefault(),t.stopPropagation(),this.touchScrollZoomWorker.move(t,this.eventCtx);return}t.preventDefault()});p(this,"onTouchEnd",t=>{if(this.touchScrollZoomWorker.isWorking){t.preventDefault(),t.stopPropagation(),this.touchScrollZoomWorker.stop(t,this.eventCtx);return}});p(this,"onPointerDown",t=>{this.touchScrollZoomWorker.isWorking||this.triggerEvent(t)});p(this,"onPointerMove",t=>{this.touchScrollZoomWorker.isWorking||this.triggerEvent(t)});p(this,"onPointerUp",t=>{this.touchScrollZoomWorker.isWorking||this.triggerEvent(t)});this.eventCtx=t,this.interactiveManager=new ji(e),this.touchScrollZoomWorker=new Ud}start(){document.addEventListener("pointerdown",this.onPointerDown),document.addEventListener("pointermove",this.onPointerMove),document.addEventListener("pointerup",this.onPointerUp),document.addEventListener("contextmenu",this.onContextMenu);const t=this.eventCtx.renderManager.gmlRender.canvas;t&&(t.addEventListener("touchstart",this.onTouchStart),t.addEventListener("touchmove",this.onTouchMove),t.addEventListener("touchend",this.onTouchEnd))}stop(){document.removeEventListener("pointerdown",this.onPointerDown),document.removeEventListener("pointermove",this.onPointerMove),document.removeEventListener("pointerup",this.onPointerUp),document.removeEventListener("contextmenu",this.onContextMenu);const t=this.eventCtx.renderManager.gmlRender.canvas;t&&(t.removeEventListener("touchstart",this.onTouchStart),t.removeEventListener("touchmove",this.onTouchMove),t.removeEventListener("touchend",this.onTouchEnd))}triggerEvent(t){this.onEnable(t)&&(this.interactiveManager.onEvent(t,this.eventCtx),this.afterEvent())}onEnable(t){return t.type!=="pointermove"&&t.target!==this.eventCtx.gmlRender.canvas?(this.eventCtx.inputManager.blur(),!1):!0}afterEvent(){}}const Ys=8,Gs=8,Us=500;var _e=(l=>(l[l.width=0]="width",l[l.height=1]="height",l[l.both=2]="both",l))(_e||{});const Cn=new Set([v.Line,v.Group]);class An{}class Vi extends An{align(t,e,n,o,s,r){const i={minX:o.minX,maxX:o.maxX,minY:n.minY-r,maxY:n.minY+r},a=t.nodeManager.searchNodesByRectNode(i),c=M.filterSlideContainerNodes(t,a),h=[];for(const f of c){if(e.has(f)||Cn.has(f.type))continue;const y=f.getBounds();if(Math.abs(n.minY-y.minY)<r){const P=Math.min(n.minX,y.minX),b=Math.max(n.maxX,y.maxX),w={start:new m(P,y.minY),end:new m(b,y.minY)};h.push({line:w,dx:0,dy:y.minY-n.minY})}if(Math.abs(n.minY-y.maxY)<r){const P=Math.min(n.minX,y.minX),b=Math.max(n.maxX,y.maxX),w={start:new m(P,y.maxY),end:new m(b,y.maxY)};h.push({line:w,dx:0,dy:y.maxY-n.minY})}}if(h.length===0)return;const d=h.map(f=>f.dy),u=Math.min(...d),g={dx:0,dy:u,lines:[]};for(const f of h)Math.abs(f.dy-u)<.01&&g.lines.push(f.line);s.top=g}}class Ki extends An{align(t,e,n,o,s,r=2){const i={minX:o.minX,maxX:o.maxX,minY:n.maxY-r,maxY:n.maxY+r},a=t.nodeManager.searchNodesByRectNode(i),c=M.filterSlideContainerNodes(t,a),h=[];for(const f of c){if(e.has(f)||Cn.has(f.type))continue;const y=f.getBounds();if(Math.abs(n.maxY-y.minY)<r){const P=Math.min(n.minX,y.minX),b=Math.max(n.maxX,y.maxX),w={start:new m(P,y.minY),end:new m(b,y.minY)};h.push({line:w,dx:0,dy:y.minY-n.maxY})}if(Math.abs(n.maxY-y.maxY)<r){const P=Math.min(n.minX,y.minX),b=Math.max(n.maxX,y.maxX),w={start:new m(P,y.maxY),end:new m(b,y.maxY)};h.push({line:w,dx:0,dy:y.maxY-n.maxY})}}if(h.length===0)return;const d=h.map(f=>f.dy),u=Math.min(...d),g={dx:0,dy:u,lines:[]};for(const f of h)Math.abs(f.dy-u)<.01&&g.lines.push(f.line);s.bottom=g}}class Qi extends An{align(t,e,n,o,s,r){const i={minX:n.minX-r,maxX:n.minX+r,minY:o.minY,maxY:o.maxY},a=t.nodeManager.searchNodesByRectNode(i),c=M.filterSlideContainerNodes(t,a),h=[];for(const f of c){if(e.has(f)||Cn.has(f.type))continue;const y=f.getBounds();if(Math.abs(n.minX-y.minX)<r){const P=Math.min(n.minY,y.minY),b=Math.max(n.maxY,y.maxY),w={start:new m(y.minX,P),end:new m(y.minX,b)};h.push({line:w,dy:0,dx:y.minX-n.minX})}if(Math.abs(n.minX-y.maxX)<r){const P=Math.min(n.minY,y.minY),b=Math.max(n.maxY,y.maxY),w={start:new m(y.maxX,P),end:new m(y.maxX,b)};h.push({line:w,dy:0,dx:y.maxX-n.minX})}}if(h.length===0)return;const d=h.map(f=>f.dx),u=Math.min(...d),g={dy:0,dx:u,lines:[]};for(const f of h)Math.abs(f.dx-u)<.01&&g.lines.push(f.line);s.left=g}}class Zi extends An{align(t,e,n,o,s,r){const i={minX:n.maxX-r,maxX:n.maxX+r,minY:o.minY,maxY:o.maxY},a=t.nodeManager.searchNodesByRectNode(i),c=M.filterSlideContainerNodes(t,a),h=[];for(const f of c){if(e.has(f)||Cn.has(f.type))continue;const y=f.getBounds();if(Math.abs(n.maxX-y.minX)<r){const P=Math.min(n.minY,y.minY),b=Math.max(n.maxY,y.maxY),w={start:new m(y.minX,P),end:new m(y.minX,b)};h.push({line:w,dy:0,dx:y.minX-n.maxX})}if(Math.abs(n.maxX-y.maxX)<r){const P=Math.min(n.minY,y.minY),b=Math.max(n.maxY,y.maxY),w={start:new m(y.maxX,P),end:new m(y.maxX,b)};h.push({line:w,dy:0,dx:y.maxX-n.maxX})}}if(h.length===0)return;const d=h.map(f=>f.dx),u=Math.min(...d),g={dy:0,dx:u,lines:[]};for(const f of h)Math.abs(f.dx-u)<.01&&g.lines.push(f.line);s.right=g}}class _d extends An{align(t,e,n,o,s,r){const i=.5*(n.minY+n.maxY),a={minX:o.minX,maxX:o.maxX,minY:i-r,maxY:i+r},c=t.nodeManager.searchNodesByRectNode(a),h=M.filterSlideContainerNodes(t,c),d=[];for(const y of h){if(e.has(y)||Cn.has(y.type))continue;const P=y.getBounds(),b=.5*(P.minY+P.maxY);if(Math.abs(i-b)<r){const w=Math.min(n.minX,n.maxX,P.maxX,P.minX),L=Math.max(n.minX,n.maxX,P.maxX,P.minX),B={start:new m(w,b),end:new m(L,b)};d.push({line:B,dx:0,dy:b-i})}}if(d.length===0)return;const u=d.map(y=>y.dy),g=Math.min(...u),f={dx:0,dy:g,lines:[]};for(const y of d)Math.abs(y.dy-g)<.01&&f.lines.push(y.line);s.horizonMid=f}}class $d extends An{align(t,e,n,o,s,r){const i=.5*(n.minX+n.maxX),a={minX:i-r,maxX:i+r,minY:o.minY,maxY:o.maxY},c=t.nodeManager.searchNodesByRectNode(a),h=M.filterSlideContainerNodes(t,c),d=[];for(const y of h){if(e.has(y)||Cn.has(y.type))continue;const P=y.getBounds(),b=.5*(P.minX+P.maxX);if(Math.abs(i-b)<r){const w=Math.min(n.minY,n.maxY,P.maxY,P.minY),L=Math.max(n.minY,n.maxY,P.maxY,P.minY),B={start:new m(b,w),end:new m(b,L)};d.push({line:B,dx:b-i,dy:0})}}if(d.length===0)return;const u=d.map(y=>y.dx),g=Math.min(...u),f={dx:g,dy:0,lines:[]};for(const y of d)Math.abs(y.dx-g)<.01&&f.lines.push(y.line);s.verticalMid=f}}class qi{constructor(){p(this,"handlers",[new Vi,new _d,new Ki,new Qi,new $d,new Zi])}align(t,e,n){const o=n.gmlRender.getViewPortBounds(),s=Ys/n.gmlRender.getScale(),r=new Set;for(const a of e)this.computeFilterSet(a,r);const i={};for(const a of this.handlers)a.align(n,r,t,o,i,s);return this.dealAlignTopBottom(i),this.dealAlignLeftRight(i),i}computeFilterSet(t,e){e.add(t);const n=t.children;for(const o of n)this.computeFilterSet(o,e)}dealAlignTopBottom(t){const{top:e,bottom:n,horizonMid:o}=t,s=[e,o,n].map(i=>i==null?void 0:i.dy).filter(i=>i!==void 0);if(s.length===0)return;const r=Math.min(...s);for(const i of["top","bottom","horizonMid"]){const a=t[i];a&&Math.abs(r-a.dy)>.01&&(t[i]=void 0)}}dealAlignLeftRight(t){const{left:e,right:n,verticalMid:o}=t,s=[e,n,o].map(i=>i==null?void 0:i.dx).filter(i=>i!==void 0);if(s.length===0)return;const r=Math.min(...s);for(const i of["left","right","verticalMid"]){const a=t[i];a&&Math.abs(r-a.dx)>.01&&(t[i]=void 0)}if(e&&n){if(Math.abs(e.dx-n.dx)<.01)return;e.dx<n.dx?t.right=void 0:t.left=void 0}}}const _s=new Set([v.Group,v.Line]);class $s{}class Ji extends $s{enable(t){return t===_e.both||t===_e.width}align(t,e,n,o,s,r,i,a){const c=n.maxX-n.minX,h=this.searchNodes(t,c,s,n,o,r,i,a);if(h.length===0)return;const d=h.map(y=>y.dt),u=Math.min(...d),g=[];for(const y of h)Math.abs(y.dt-u)<.01&&g.push(y.info);const f={dt:u,sideSize:c,lines:g};e.width=f}searchNodes(t,e,n,o,s,r,i,a){let c=200;const h={minX:o.minX-c,maxX:o.maxX+c,minY:o.minY-c,maxY:o.maxY+c},d=[];for(;d.length===0&&!(c>i||M.containRect(h,r));){const u=this.searchNodesForOffset(t,e,n,h,s,r,c,a);d.push(...u),c=2*c}return d}searchNodesForOffset(t,e,n,o,s,r,i,a){const c=t.nodeManager.searchNodesByRectNode(r),h=M.filterSlideContainerNodes(t,c),d=[];for(const u of h){if(s.has(u)||_s.has(u.type))continue;const{width:g,height:f,angle:y}=u.baseProps,P=y%360;if(!(Math.abs(P)>30)&&Math.abs(g-e)<a){const b={x:0,y:f},w={x:g,y:f};d.push({dt:g-e,sideSize:g,info:{line:{start:b,end:w},transform:u.globalTransform().clone()}})}}return d}}class ea extends $s{enable(t){return t===_e.both||t===_e.height}align(t,e,n,o,s,r,i,a){const c=n.maxY-n.minY,h=this.searchNodes(t,c,s,n,o,r,i,a);if(h.length===0)return;const d=h.map(y=>y.dt),u=Math.min(...d),g=[];for(const y of h)Math.abs(y.dt-u)<.01&&g.push(y.info);const f={dt:u,sideSize:c,lines:g};e.height=f}searchNodes(t,e,n,o,s,r,i,a){let c=200;const h={minX:o.minX-c,maxX:o.maxX+c,minY:o.minY-c,maxY:o.maxY+c},d=[];for(;d.length===0&&!(c>i||M.containRect(h,r));){const u=this.searchNodesForOffset(t,e,n,h,s,r,c,a);d.push(...u),c=2*c}return d}searchNodesForOffset(t,e,n,o,s,r,i,a){const c=t.nodeManager.searchNodesByRectNode(r),h=M.filterSlideContainerNodes(t,c),d=[];for(const u of h){if(s.has(u)||_s.has(u.type))continue;const{width:g,height:f,angle:y}=u.baseProps,P=y%360;if(!(Math.abs(P)>30)&&Math.abs(f-e)<a){const b={x:g,y:0},w={x:g,y:f};d.push({dt:f-e,sideSize:f,info:{line:{start:b,end:w},transform:u.transform.clone()}})}}return d}}class ta{constructor(){p(this,"handlers",[new Ji,new ea])}align(t,e,n,o,s,r,i){const a={};for(const c of this.handlers)c.enable(o)&&c.align(t,a,e,n,o,s,r,i);return a}}class na{}class jd extends na{align(t,e,n,o,s,r){const i={minX:o.minX,maxX:o.maxX,minY:n.y-r,maxY:n.y+r},a=t.nodeManager.searchNodesByRectNode(i),c=M.filterSlideContainerNodes(t,a),h=[];for(const f of c){if(this.skipNodeAlign(e,f))continue;const y=f.getBounds(),P=[y.minY,y.maxY];for(const b of P)if(Math.abs(n.y-b)<r){const w=Math.min(n.x,y.minX,y.maxX),L=Math.max(n.x,y.minX,y.maxX),B={start:new m(w,b),end:new m(L,b)};h.push({line:B,dx:0,dy:b-n.y})}}if(h.length===0)return;const d=h.map(f=>f.dy),u=Math.min(...d),g={dx:0,dy:u,lines:[]};for(const f of h)Math.abs(f.dy-u)<.01&&g.lines.push(f.line);s.horizon=g}skipNodeAlign(t,e){if(t.has(e))return!0;if(e.type===v.Line){const n=e;if(n.shapeType!==de.Line)return!0;const o=n.points;return!M.judgeHorizon(o[0],o[o.length-1])}return e.type===v.Group}}class Vd extends na{align(t,e,n,o,s,r){const i={minY:o.minY,maxY:o.maxY,minX:n.x-r,maxX:n.x+r},a=t.nodeManager.searchNodesByRectNode(i),c=M.filterSlideContainerNodes(t,a),h=[];for(const f of c){if(this.skipNodeAlign(e,f))continue;const y=f.getBounds(),P=[y.minX,y.maxX];for(const b of P)if(Math.abs(n.x-b)<r){const w=Math.min(n.y,y.minY,y.maxY),L=Math.max(n.y,y.minY,y.maxY),B={start:new m(b,w),end:new m(b,L)};h.push({line:B,dx:b-n.x,dy:0})}}if(h.length===0)return;const d=h.map(f=>f.dx),u=Math.min(...d),g={dx:u,dy:0,lines:[]};for(const f of h)Math.abs(f.dx-u)<.01&&g.lines.push(f.line);s.vertical=g}skipNodeAlign(t,e){if(t.has(e))return!0;if(e.type===v.Line){const n=e;if(n.shapeType!==de.Line)return!0;const o=n.points;return!M.judgeVertical(o[0],o[o.length-1])}return e.type===v.Group}}class Kd{constructor(){p(this,"handlers",[new jd,new Vd])}align(t,e,n){const o=n.gmlRender.getViewPortBounds(),s=Ys/n.gmlRender.getScale(),r={};for(const i of this.handlers)i.align(n,e,t,o,r,s);return r}}class $t{static addAllParentToSet(t,e){let n=t.parent;for(;n&&n.type===v.Group;)e.add(n),n=n.parent}static findHoverNode(t,e){if(t.parent.type!==v.Group)return t;const n=new Set;for(const s of e)n.add(s.parent);let o=t.parent;if(n.has(o))return t;for(;o;){const s=o.parent;if(n.has(s))return o;if(s.type!==v.Group)break;o=s}return o}static flattenNodes(t){const e=new Set;for(const n of t)this.flattenGroupNodes(n,e);return[...e]}static flattenGroupNodes(t,e){if(t.type!==v.Group){e.add(t);return}const o=t.children;for(const s of o)this.flattenGroupNodes(s,e)}}class un{constructor(){p(this,"alignMoveWorker",new qi);p(this,"alignStretchWorker",new ta);p(this,"alignLineEndWorker",new Kd)}alignLineEnd(t,e,n,o){return o?this.alignLineEndWorker.align(t,e,n):{}}alignMove(t,e,n,o){if(!o)return{};const s=new Set;for(const r of e)this.addChildrenToFilterSet(r,s);return this.alignMoveWorker.align(t,s,n)}alignStretch(t,e,n,o,s,r,i){const a=D.toRectNode(e),c=new Set(n);for(const d of[...n])$t.addAllParentToSet(d,c);return this.alignStretchWorker.align(t,a,c,o,s,r,i)}alignLineEndAndDrawAlignLines(t,e,n=e.getSelectNodes(),o=!0){const s=t.globalPoint.clone(),r=this.alignLineEnd(s,n,e,o),i=[];return r.horizon&&(i.push(...r.horizon.lines),s.y+=r.horizon.dy),r.vertical&&(i.push(...r.vertical.lines),s.x+=r.vertical.dx),e.addOrUpdate(N.AlignLine,{lines:i}),s}drawAlignLines(t,e){const{top:n,bottom:o,horizonMid:s,right:r,left:i,verticalMid:a}=t,c=[],h=new m;return n&&(h.y=n.dy,c.push(...n.lines)),s&&(h.y=s.dy,c.push(...s.lines)),o&&(h.y=o.dy,c.push(...o.lines)),i&&(h.x=i.dx,c.push(...i.lines)),a&&(h.x=a.dx,c.push(...a.lines)),r&&(h.x=r.dx,c.push(...r.lines)),e.addOrUpdate(N.AlignLine,{lines:c}),h}addChildrenToFilterSet(t,e){e.add(t);const n=t.children;for(const o of n)this.addChildrenToFilterSet(o,e)}}class qe{}class Ot{constructor(t){p(this,"processors",[]);this.processors=t}work(t,e){for(const n of this.processors)n.allowEventTypeSet.has(t.type)&&n.process(t,e)}stop(t,e){for(const n of this.processors)n.stop&&n.stop(t,e)}isStreaming(){return!1}}class pn extends Ot{constructor(e){super(e);p(this,"deltaDistance",1);p(this,"locked",!1)}clickEnable(e,n){return!0}canBeEnable(e,n){if(e.type!==be.pointerDown)return!1;const o=this.clickEnable(e,n);return o&&(this.locked=!0),o}work(e,n){e.type===be.pointerup&&(this.locked=!1),e.type!==be.pointerDown&&n.lastDiffTypeEvent&&M.distance(n.lastDiffTypeEvent.globalPoint,e.globalPoint)>this.deltaDistance/n.gmlRender.getScale()&&(this.locked=!1),super.work(e,n)}canBeExit(e,n){const o=!this.locked;return o&&this.stop(e,n),o}}class jt{constructor(){p(this,"downHandlers",[]);p(this,"upHandlers",[]);p(this,"hasWorking",!1);p(this,"allowEventTypeSet",new Set([be.pointerDown,be.pointerup]))}registerDownHandler(t){this.downHandlers.push(t)}registerUpHandler(t){this.upHandlers.push(t)}process(t,e){this.downProcess(t,e),this.upProcess(t,e)}stop(t,e){this.hasWorking=!1}downProcess(t,e){if(t.type===be.pointerDown){for(const n of this.downHandlers)if(n.enable(t,e)){this.hasWorking=!0,n.handle(t,e);return}}}upProcess(t,e){if(t.type===be.pointerup){if(this.hasWorking){this.hasWorking=!1;return}for(const n of this.upHandlers)if(n.enable(t,e)){n.handle(t,e);return}}}}class js extends Ot{constructor(e){super(e);p(this,"deltaDistance",1);p(this,"locked",!1);p(this,"firstPointerDown",!1)}canBeEnable(e,n){return e.type===be.pointerDown?this.firstPointerDown?(this.locked=!0,!0):(this.firstPointerDown=!0,setTimeout(()=>{this.firstPointerDown=!1},300),!1):!1}work(e,n){this.firstPointerDown&&e.type===be.pointerup&&(this.locked=!1),e.type===be.pointermove&&M.distance(n.lastInteractiveEvent.globalPoint,e.globalPoint)>this.deltaDistance/n.gmlRender.getScale()&&(this.locked=!1),this.firstPointerDown||(this.locked=!1),super.work(e,n)}canBeExit(e,n){const o=!this.locked;return o&&this.stop(e,n),o}}class dt extends Ot{constructor(e,n=[]){super(n);p(this,"streamProcessor");p(this,"deltaDistance",1);p(this,"locked",!1);this.streamProcessor=e}onDown(e,n){}canBeEnable(e,n){var i;if(e.type===be.pointerDown&&this.onDown(e,n),!(((i=n.lastDiffTypeEvent)==null?void 0:i.type)===be.pointerDown&&e.type===be.pointermove))return!1;const s=n.lastDiffTypeEvent.globalPoint;if(M.distance(s,e.globalPoint)<this.deltaDistance/n.gmlRender.getScale())return!1;const r=this.streamEnable(n.lastDiffTypeEvent,n);if(r){this.locked=!0;for(const a of this.streamProcessor)a.onStart(n.lastDiffTypeEvent,n)}return r}work(e,n){if(e.type===be.pointermove)for(const o of this.streamProcessor)o.onMove(e,n);if(e.type===be.pointerup){for(const o of this.streamProcessor)o.onUp(e,n);this.locked=!1}super.work(e,n)}canBeExit(e,n){const o=!this.locked;return o&&this.stop(e,n),o}isStreaming(){return this.locked}}class gn{constructor(t){p(this,"currentSubMode");p(this,"subModes",[]);this.subModes=t,this.currentSubMode=t[t.length-1]}canBeExit(t,e){return this.currentSubMode.canBeExit(t,e)}work(t,e){this.detect(t,e),this.currentSubMode.work(t,e)}detect(t,e){if(this.currentSubMode.canBeExit(t,e)){for(const n of this.subModes)if(n.canBeEnable(t,e)){this.currentSubMode=n;return}}}}class kn extends Ot{constructor(e,n=[]){super(n);p(this,"streamProcessor");p(this,"locked",!1);this.streamProcessor=e}canBeEnable(e,n){if(e.type!==be.pointerDown)return!1;const o=this.streamEnable(e,n);return o&&(this.locked=!0),o}work(e,n){if(e.type===be.pointerDown)for(const o of this.streamProcessor)o.onStart(e,n);if(e.type===be.pointermove)for(const o of this.streamProcessor)o.onMove(e,n);if(e.type===be.pointerup){for(const o of this.streamProcessor)o.onUp(e,n);this.locked=!1}super.work(e,n)}canBeExit(e,n){const o=!this.locked;return o&&this.stop(e,n),o}isStreaming(){return this.locked}}class ht{constructor(){p(this,"allowEventTypeSet",new Set([be.pointerDown,be.pointermove,be.pointerup]))}process(t,e){}}class oa{}class sa extends Ke{onDetect(t,e){if(e.detect(F.Stretch,t)||e.detect(F.Rotate,t)||e.detect(F.LineEndPoint,t))return!1;const r=t.globalPoint;let i=e.nodeManager.searchNodes(r.x,r.y);i=M.filterSlideContainerNodes(e,i);let a=[];for(const c of i)c.type!==v.Group&&c.contains(t.globalPoint,e.gmlRender.getScale())&&a.push(c);return a.length===0?(this.result=null,!1):(a=M.sortGraphics(a),a.reverse(),this.result=a,!0)}}class ra extends Ke{onDetect(t,e){const n=e.detect(F.Node,t);if(!n)return!1;const o=n[0];if(n.length===1&&e.auxiliaryManager.selectManager.include(o))return!1;if(t.originEvent.metaKey)return this.result=o,!0;const s=e.getSelectNodes(),r=$t.findHoverNode(o,s);return r?(this.result=r,!0):(this.result=o,!0)}}const ys=class ys extends Ke{computeLocalPoint(t,e,n){if(t.length===1){const i=t[0],a=i.baseProps,c=i.toLocal(e.globalPoint),h=D.baseProps2Rect(a);return{localPoint:c,rect:h}}const o=n.auxiliaryManager.selectManager.getSelectBounds(),s=D.rectNode2Rect(o);return{localPoint:new m(e.globalPoint.x-s.x,e.globalPoint.y-s.y),rect:s}}onDetect(t,e){const n=e.auxiliaryManager.selectManager.selectNodes;if(n.size===0||e.detect(F.ExpandShape,t))return!1;const s=$t.flattenNodes([...n]),r=e.gmlRender.getScale(),i=ys.HOT_DISTANCE/r,{rect:a,localPoint:c}=this.computeLocalPoint(s,t,e),h=new D(0,0,a.width,a.height),d=M.detectRectBounds(h,c,i);return d?(this.result={nodes:s,type:d.type,angle:M.computeStretchAngle(s,d.type)},!0):!1}};p(ys,"HOT_DISTANCE",8);let Fo=ys;class ia extends ht{constructor(){super(...arguments);p(this,"start",null)}onStart(e,n){const{renderText:o,node:s}=n.inputManager.editTextInfo,r=s.toLocal(e.globalPoint),i=o.detect(r);n.setCursor("text"),this.start=i,n.execAction(new W)}onMove(e,n){const{renderText:o,node:s}=n.inputManager.editTextInfo,r=s.toLocal(e.globalPoint),i=o.detect(r);this.start.equal(i)?n.execAction(ee.focus(s.id,this.start)):n.execAction(ee.selection(s.id,this.start,i))}onUp(e,n){const{renderText:o,node:s}=n.inputManager.editTextInfo,r=s.toLocal(e.globalPoint),i=o.detect(r);this.start.equal(i)?n.execAction(ee.focus(s.id,this.start)):n.execAction(ee.selection(s.id,this.start,i)),n.execAction(new z)}}class aa extends dt{constructor(){super([new ia])}streamEnable(t,e){const n=e.inputManager.editTextInfo;if(!n)return!1;const{node:o,renderText:s}=n,r=o.getTextContentRect(),i=o.toLocal(t.globalPoint);return!!M.rectContains(i,r)}}class on{constructor(){p(this,"parentGroupSet",new Set)}start(t){this.parentGroupSet.clear();for(const e of t)$t.addAllParentToSet(e,this.parentGroupSet)}work(t,e){if(this.parentGroupSet.size===0)return;const n=M.sortGraphics([...this.parentGroupSet]).reverse();for(const o of n){const s=o.computeBasePropsByChildren();t.execAction(new U({infos:[{id:o.id,props:[s]}]},{streaming:e}))}}}class fn{}class Qd extends fn{enable(t){return!(!(t instanceof Fn)||t.cropProps.cropType===wt.None||!t.cropProps.cropInfo)}handle(t,e,n,o,s){const r=this.handleCropProp(t,e,n,o,s);return[{id:t.id,props:[r]}]}handleCropProp(t,e,n,o,s){const r=e.crop,i=e.crop.globalImgPos,a=r.originCropProps,c=a.cropType,h=s.crossPoint(new m(i.x,i.y)),d=t.toLocal(h);return{type:I.Crop,cropInfo:{imgX:d.x,imgY:d.y,imgWidth:a.cropInfo.imgWidth*n,imgHeight:a.cropInfo.imgHeight*o},cropType:c}}}class Zd extends en{updateProps(t){super.updateProps(t),t.find(n=>n.type===I.Base)&&this.updateTransformMatrix()}getTextContentRect(){return this.baseProps}getConnectAnchor(){return[new m(.5,0),new m(1,.5),new m(.5,1),new m(0,.5)]}borderContains(t,e){const n=this.toLocal(t),{width:o,height:s}=this.baseProps,r=q.rectangle({top:0,left:0,width:o,height:s}),i=q.line({x:n.x-e,y:n.y},{x:n.x+e,y:n.y}),a=q.line({x:n.x,y:n.y-e},{x:n.x,y:n.y+e});for(const c of[i,a]){const h=Y.intersect(r,c);if(h.points.length>0)return h.points[0]}return null}}class Yo extends Zd{get checkStatus(){return this.getProp(I.CheckStatus).checkStatus}constructor(t,e){super(t,e),this.props.set(I.Base,new ie),this.props.set(I.Border,new Ae),this.props.set(I.CheckStatus,new Qt),this.props.set(I.Color,new tt),this.props.set(I.Shape,new Oe)}drawOnGLCtx(t){this.drawCheckboxBorder(t),this.drawCheckboxIcon(t)}drawCheckboxBorder(t){const e=this.getProp(I.Border),n=this.baseProps;if(e.color!==""&&e.alpha!==0&&e.dashType!==et.None){const{a:o,b:s,c:r,d:i,e:a,f:c}=this.globalTransform();t.save(),t.transform(o,s,r,i,a,c),t.beginPath(),t.roundRect(0,0,n.width,n.height,4),t.lineWidth=e.width,t.strokeStyle=e.color,t.globalAlpha=e.alpha,M.setDashLine(e,t),t.stroke(),t.restore()}}drawCheckboxIcon(t){if(!this.checkStatus)return;const e=this.getProp(I.Color),n=this.baseProps;if(e.color!==""&&e.alpha!==0){t.save();const o=re.generateMatrix().scale(n.width/16,n.height/16),{a:s,b:r,c:i,d:a,e:c,f:h}=this.globalTransform().crossProduct(o);t.transform(s,r,i,a,c,h),t.fillStyle=e.color,t.globalAlpha=e.alpha,t.scale(1,1),t.beginPath();const d=new Path2D("M10.97 4.97a.75.75 0 0 1 1.07 1.05l-3.99 4.99a.75.75 0 0 1-1.08.02L4.324 8.384a.75.75 0 1 1 1.06-1.06l2.094 2.093 3.473-4.425a.267.267 0 0 1 .02-.022z");t.fill(d),t.restore()}}checkboxContain(t){return this.contains(t)}canQuickCreate(){return!1}canBeConnected(){return!0}static load(t,e,n,o,s,r){const i=new Yo(t,r);return i.type=e,i.zIndex=n,i.setParent(s),i.updateProps(o),i}}const ca=1;class Un extends Yo{constructor(e,n){super(e,n);p(this,"renderText");p(this,"checkboxTopPadding",ca);this.props.set(I.Text,new Ge),this.props.set(I.CheckSize,new vn),this.renderText=new uo}get textProps(){return this.props.get(I.Text)}get chickSize(){return this.props.get(I.CheckSize).size}updateProps(e){super.updateProps(e);const n=e.find(r=>r.type===I.Text),o=e.find(r=>r.type===I.Base),s=e.find(r=>r.type===I.CheckSize);if(n||o||s){const r=this.getTextContentRect();if(this.renderText.typesetting(this.graphicContext,this.textProps,r),this.baseProps.height=this.renderText.height+2*le,this.renderText.rect.height=this.renderText.height+2*le,this.renderText.paragraphs.length>0){const i=this.renderText.paragraphs[0];if(i.lines.length>0){const a=i.lines[0];this.checkboxTopPadding=.5*(a.height-this.chickSize)}}}}drawOnGLCtx(e){super.drawOnGLCtx(e),this.drawText(e)}drawCheckboxBorder(e){const n=this.getProp(I.Border);if(n.color!==""&&n.alpha!==0&&n.dashType!==et.None){const o=this.chickSize,{a:s,b:r,c:i,d:a,e:c,f:h}=this.globalTransform();e.save(),e.transform(s,r,i,a,c,h),e.beginPath(),e.roundRect(0,le+this.checkboxTopPadding,o,o,4),e.lineWidth=n.width,e.strokeStyle=n.color,e.globalAlpha=n.alpha,M.setDashLine(n,e),e.stroke(),e.restore()}}drawCheckboxIcon(e){if(!this.checkStatus)return;const n=this.getProp(I.Color);if(n.color!==""&&n.alpha!==0){e.save();const o=this.chickSize,s=re.generateMatrix().scale(o/16,o/16),r=re.generateMatrix().translate(0,this.checkboxTopPadding+le),{a:i,b:a,c,d:h,e:d,f:u}=this.globalTransform().crossProduct(r).crossProduct(s);e.transform(i,a,c,h,d,u),e.fillStyle=n.color,e.globalAlpha=n.alpha,e.scale(1,1),e.beginPath();const g=new Path2D("M10.97 4.97a.75.75 0 0 1 1.07 1.05l-3.99 4.99a.75.75 0 0 1-1.08.02L4.324 8.384a.75.75 0 1 1 1.06-1.06l2.094 2.093 3.473-4.425a.267.267 0 0 1 .02-.022z");e.fill(g),e.restore()}}drawText(e){const{alpha:n}=this.getProp(I.Color);e.save(),e.beginPath();const o=this.globalPos;this.renderText.draw(e,new m(o.x,o.y),n),e.restore()}checkboxContain(e){const{height:n}=this.baseProps,o=this.toLocal(e);return M.rectContains(o,new D(0,0,n,n))}getTextContentRect(){const{width:e,height:n}=this.baseProps,o=this.chickSize;return{x:o+le,y:le,width:e-2*le-o-ca,height:n-2*le}}static load(e,n,o,s,r,i){const a=new Un(e,i);return a.type=n,a.zIndex=o,a.setParent(r),a.updateProps(s),a}}class Go extends ht{constructor(){super(...arguments);p(this,"minStretchSize",new m(0,0));p(this,"originPos",new m(0,0));p(this,"originStretchRect");p(this,"propsMap",new Map);p(this,"originTransform",re.generateMatrix());p(this,"viewBounds");p(this,"target",null);p(this,"alignWorker",new un);p(this,"alignType",_e.width);p(this,"originWidthHeightRatio",1);p(this,"isUniform",!1);p(this,"relatedLines",new Set);p(this,"layoutWorker",new Rn);p(this,"cropStretchHandler",new Qd);p(this,"groupBaseWorker",new on)}recordNodePropInfo(e){const{x:n,y:o,width:s,height:r}=e.globalBaseProps,i=this.originTransform.crossPoint({x:n,y:o}),a={x:i.x,y:i.y,width:s,height:r};if(e instanceof Fn){const c=e.cropProps,h=e.getOriginImageRect().clone(),d=e.toGlobal({x:h.x,y:h.y}),u={originCropProps:c.clone(),originImgRect:h,originTransform:e.globalTransform().inverseMatrix().clone(),globalImgPos:this.originTransform.crossPoint(d)};a.crop=u}return e instanceof vt&&e.shapeType===K.PureText&&(a.fontSize=e.textProps.fontSize),e instanceof Un&&(a.fontSize=e.textProps.fontSize,a.checkSize=e.chickSize),a}computeAnchorPoint(e,n){const{width:o,height:s}=n;switch(e.type){case V.TOP:return this.alignType=_e.height,{x:.5*o,y:s};case V.RIGHT:return this.alignType=_e.width,{x:0,y:.5*s};case V.BOTTOM:return this.alignType=_e.height,{x:.5*o,y:0};case V.LEFT:return this.alignType=_e.width,{x:o,y:.5*s};case V.TOP_LEFT:return this.alignType=_e.both,{x:o,y:s};case V.TOP_RIGHT:return this.alignType=_e.both,{x:0,y:s};case V.BOTTOM_RIGHT:return this.alignType=_e.both,{x:0,y:0};case V.BOTTOM_LEFT:default:return this.alignType=_e.both,{x:o,y:0}}}judgeUniform(e){this.isUniform=!1;const n=this.target.nodes;for(const o of n){if(Math.abs(o.baseProps.angle)>.1){this.isUniform=!0;return}if(o.type===v.SVG||o.type===v.IMG||o.type===v.Checkbox){this.isUniform=!0;return}if(o.type===v.Shape&&o.shapeType===K.PureText&&(this.target.type===V.TOP||this.target.type===V.TOP_LEFT||this.target.type===V.BOTTOM_LEFT||this.target.type===V.BOTTOM||this.target.type===V.BOTTOM_RIGHT||this.target.type===V.TOP_RIGHT)){this.isUniform=!0;return}if(o.type===v.CheckboxText&&(this.target.type===V.TOP||this.target.type===V.TOP_LEFT||this.target.type===V.BOTTOM_LEFT||this.target.type===V.BOTTOM||this.target.type===V.BOTTOM_RIGHT||this.target.type===V.TOP_RIGHT)){this.isUniform=!0;return}}}computeStretchRect(e,n){switch(this.target.type){case V.BOTTOM:e.height+=n.y;break;case V.LEFT:e.x+=n.x,e.width-=n.x;break;case V.RIGHT:e.width+=n.x;break;case V.TOP:e.y+=n.y,e.height-=n.y;break;case V.BOTTOM_LEFT:e.height+=n.y,e.x+=n.x,e.width-=n.x;break;case V.BOTTOM_RIGHT:e.height+=n.y,e.width+=n.x;break;case V.TOP_LEFT:e.y+=n.y,e.height-=n.y,e.x+=n.x,e.width-=n.x;break;case V.TOP_RIGHT:e.y+=n.y,e.height-=n.y,e.width+=n.x;break}e.width<this.minStretchSize.x&&(e.width=this.minStretchSize.x),e.height<this.minStretchSize.y&&(e.height=this.minStretchSize.y)}computeTarget(e,n){this.target=n.detect(F.Stretch,e)}onStart(e,n){this.computeTarget(e,n),this.originStretchRect=this.getStretchRect(n),this.originWidthHeightRatio=this.originStretchRect.width/this.originStretchRect.height,this.computeOriginTransform(n),this.minStretchSize=this.getMiniSize(n),this.judgeUniform(n),this.originPos=this.originTransform.crossPoint(e.globalPoint),this.recordPropsMap(n),this.relatedLines.clear(),this.batchCollectNodeLinks(this.target.nodes,n,this.relatedLines),this.groupBaseWorker.start(this.target.nodes),this.viewBounds=n.gmlRender.getViewPortBounds(),n.actionManager.execAction(new W);const o=[];for(const s of this.target.nodes)(s.type===v.CheckboxText||s instanceof vt&&s.shapeType===K.PureText)&&(this.target.type===V.RIGHT||this.target.type===V.LEFT)&&o.push({id:s.id,props:[{type:I.Text,sizeMode:We.autoHeight}]}),s instanceof vt&&this.target.type!==V.RIGHT&&this.target.type!==V.LEFT&&o.push({id:s.id,props:[{type:I.Text,sizeMode:We.fix}]});n.actionManager.execAction(new U({infos:o})),n.inputManager.editTextInfo&&n.execAction(ee.blur(n.inputManager.editTextInfo.node.id))}onMove(e,n){n.auxiliaryManager.removeAlignGraphics(),this.stretchNode(e,n,!0)}onUp(e,n){this.stretchNode(e,n,!1),n.actionManager.execAction(new z),n.auxiliaryManager.removeAlignGraphics()}alignStretchGlobalPoint(e,n){const o=new Set(this.target.nodes),s=!M.pressMeta(e);return this.alignWorker.alignLineEndAndDrawAlignLines(e,n,o,s)}stretchNode(e,n,o){const s=this.alignStretchGlobalPoint(e,n),r=this.originTransform.crossPoint(s),i=new m(r.x-this.originPos.x,r.y-this.originPos.y),a=this.originStretchRect.clone();this.computeStretchRect(a,i);const c=n.gmlRender.getScale(),h=new Set(this.target.nodes),d=this.alignWorker.alignStretch(n,a,h,this.alignType,this.viewBounds,Us/c,Gs/c);this.drawAlignLine(a,d,n);const{sx:u,sy:g}=this.computeScale(a),f=re.generateMatrix().scale(u,g),y=this.originTransform.inverseMatrix().crossProduct(f),P=[],b=[],w=[];for(const[L,B]of this.propsMap){for(const H of this.handlers)if(H.enable(L)){const E=H.handle(L,B,u,g,y,n,this.isUniform);P.push(...E);break}L.type===v.SVG&&b.push(L),this.cropStretchHandler.enable(L)&&w.push(L)}n.execAction(new U({infos:P},{streaming:o})),this.afterStretchNode(n,u,g,y,o,w,b),this.layoutWorker.work([...this.relatedLines],n,o),this.groupBaseWorker.work(n,o)}afterStretchNode(e,n,o,s,r,i,a){if(i.length>0){const c=[];i.forEach(h=>{c.push(...this.cropStretchHandler.handle(h,this.propsMap.get(h),n,o,s))}),e.execAction(new U({infos:c},{streaming:r}))}if(r||e.asyncRenderNodeManager.batchAddRenderNode(a),this.target.type===V.BOTTOM_RIGHT){const c=[...this.target.nodes],h=c[0];if(c.length===1)e.addOrUpdate(N.HoverSize,{rect:D.baseProps2Rect(h.baseProps),transform:h.globalTransform().clone()});else{const d=e.auxiliaryManager.selectManager.getSelectBounds();e.addOrUpdate(N.HoverSize,{rect:D.rectNode2Rect(d),transform:re.generateMatrix().translate(d.minX,d.minY)})}}}computeScale(e){let n=e.width/this.originStretchRect.width,o=e.height/this.originStretchRect.height;if(!this.isUniform)return{sx:n,sy:o};const s=this.target.type;if(s===V.BOTTOM||s===V.TOP)return n=o,{sx:n,sy:o};if(s===V.LEFT||s===V.RIGHT)return o=n,{sx:n,sy:o};const r=e.width/e.height;return r>this.originWidthHeightRatio?o=n:r<this.originWidthHeightRatio&&(n=o),{sx:n,sy:o}}batchCollectNodeLinks(e,n,o){const s=n.getSelectNodes();for(const r of e)this.collectNodeLinks(r,n,s,o)}collectNodeLinks(e,n,o,s){const r=n.nodeManager.getNodeLinks(e);for(const i of r)o.has(i)||s.add(i);for(const i of e.children)i.type===v.Line&&this.collectNodeLinks(i,n,o,s)}}class qd extends fn{enable(t){return t.type===v.Section}handle(t,e,n,o,s,r){const i=s.crossPoint({x:e.x,y:e.y}),a=t.baseProps,c=t.parent.toLocal(i),h=new m(c.x-a.x,c.y-a.y),d=[{id:t.id,props:[{type:I.Base,x:c.x,y:c.y,width:e.width*n,height:e.height*o}]}];if(t.type===v.Section&&t.children.size>0){const u=t,g=this.computeSectionChildren(u,r);for(const f of g){const y=f.baseProps;if(f.type===v.Line){const P=f.points.map(w=>new m(w.x,w.y));for(const w of P)w.x-=h.x,w.y-=h.y;const b=D.rectNode2Rect(M.getBoundsByPoints(P));d.push({id:f.id,props:[{type:I.Line,points:P},{type:I.Base,x:b.x,y:b.y,width:b.width,height:b.height}]})}else d.push({id:f.id,props:[{type:I.Base,x:y.x-h.x,y:y.y-h.y}]})}}return d}computeSectionChildren(t,e){const n=t.children,o=new Set;for(const s of n)s.type===v.Group?$t.flattenGroupNodes(s,o):o.add(s);return o}}class la extends fn{enable(t){return!0}handle(t,e,n,o,s){const r=s.crossPoint({x:e.x,y:e.y}),i=t.parent.toLocal(r);return[{id:t.id,props:[{type:I.Base,x:i.x,y:i.y,width:e.width*n,height:e.height*o}]}]}}class ha extends fn{enable(t){return t.type!==v.Shape?!1:t.shapeType===K.PureText}handle(t,e,n,o,s,r,i){const a=s.crossPoint({x:e.x,y:e.y}),c=t.parent.toLocal(a),d=[{type:I.Base,x:c.x,y:c.y,width:e.width*n,height:e.height*o}],u=t.getProp(I.Text);if(i&&u){const g=e.fontSize*o,f={type:I.Text,fontSize:g};d.push(f)}return[{id:t.id,props:d}]}}class da extends fn{enable(t){return t.type===v.CheckboxText}handle(t,e,n,o,s,r,i){const a=s.crossPoint({x:e.x,y:e.y}),c=t.parent.toLocal(a),d=[{type:I.Base,x:c.x,y:c.y,width:e.width*n,height:e.height*o}],u=t.getProp(I.Text);if(i&&u){const g=e.fontSize*o,f={type:I.Text,fontSize:g};d.push(f);const y=e.checkSize*n;d.push({type:I.CheckSize,size:y})}return[{id:t.id,props:d}]}}class ua extends Go{constructor(){super(...arguments);p(this,"handlers",[new qd,new ha,new da,new la])}getStretchRect(e){const n=[...e.getSelectNodes()];return D.baseProps2Rect(n[0].baseProps)}getMiniSize(e){return[...e.getSelectNodes()][0].getStretchMinSize()}recordPropsMap(e){this.propsMap.clear();const n=this.target.nodes;for(const o of n){const s=this.recordNodePropInfo(o);this.propsMap.set(o,s)}}computeOriginTransform(e){const n=this.target,o=[...e.getSelectNodes()][0],{x:s,y:r,width:i,height:a,angle:c}=o.globalBaseProps,h=re.generateMatrix().rotate(-c),d=re.generateMatrix().translate(-s,-r),u=this.computeAnchorPoint(n,new D(0,0,i,a)),f=re.generateMatrix().translate(-u.x,-u.y).crossProduct(h.crossProduct(d));this.originTransform=f}drawAlignLine(e,n,o){const s=this.target.nodes[0],r=s.baseProps,{width:i,height:a}=n,c=s.globalTransform().clone();if(i){e.width+=i.dt;const h={transform:c,line:{start:new m(0,r.height),end:new m(r.width,r.height)}};i.lines.push(h)}if(a){e.height+=a.dt;const h={transform:c,line:{start:new m(r.width,0),end:new m(r.width,r.height)}};a.lines.push(h)}o.addOrUpdate(N.AlignStretchLine,{alignInfo:n})}}class pa extends kn{constructor(){super([new ua])}streamEnable(t,e){if(e.getSelectNodes().size===0)return!1;const n=e.detect(F.Stretch,t);return n?n.nodes.filter(s=>M.judgeNodeCanBeStretch(s)).length===1:!1}}class Vs{handleChangeRelation(t,e,n){if(t.parent===e)return[];if(t.parent.type===v.Group)return[];const o=t.globalPos,s=e.toLocal(o);return[{id:t.id,props:[{type:I.Base,x:s.x,y:s.y}],parentId:e.id,zIndex:n}]}}class ga extends Vs{enable(t){return t.type===v.Line}handle(t,e){const n=t.baseProps.clone();n.x+=e.x,n.y+=e.y;const o=t.getProp(I.Line).clone();for(const s of o.points)s.x+=e.x,s.y+=e.y;return[{id:t.id,props:[n,o]}]}handleChangeRelation(t,e,n){if(t.parent===e)return[];const o=t.globalLinePoints,s=e.globalTransform().inverseMatrix(),r=o.map(a=>s.crossPoint(a)),i=M.getBoundsByPoints(r);return[{id:t.id,props:[{type:I.Base,x:i.minX,y:i.minY},{type:I.Line,points:r}],parentId:e.id,zIndex:n}]}}class fa extends Vs{enable(t){return!0}handle(t,e){const n=t.baseProps.clone();return n.x+=e.x,n.y+=e.y,[{id:t.id,props:[n]}]}}var fo=(l=>(l[l.Resource=0]="Resource",l[l.Template=1]="Template",l))(fo||{});class Ks{work(t){const e=t.getSelectNodes();return e.size===0?null:this.copyByIds([...e].map(n=>n.id),t)}copyByIds(t,e){const n=[];if(t.forEach(i=>{const a=e.nodeManager.getNode(i);a&&n.push(a)}),n.length===0)return null;const o=D.rectNode2Rect(e.auxiliaryManager.selectManager.getSelectBounds()),s=[],r=[];for(const i of n){const a=this.makeupPasteDO(i,!0,r);s.push(a)}return s.sort((i,a)=>i.zIndex-a.zIndex),{meta:{docId:e.docState.docId,resourceType:fo.Resource},nodes:s,bounds:o,resources:r}}makeupPasteDO(t,e=!1,n){const{id:o,zIndex:s,capInfo:r,type:i}=t.serializeTo(),a={id:o,type:i,zIndex:s,capInfo:r,children:[]};if(this.collectResourceInfo(t,n),e){const u=t.globalPos;a.capInfo.baseProps.x=u.x,a.capInfo.baseProps.y=u.y,t instanceof Ct&&(a.capInfo.lineProps.points=[...t.globalLinePoints])}const c=t.children;if(c.size===0)return a;const h=[],d=e&&t.type===v.Group;for(const u of c)h.push(this.makeupPasteDO(u,d,n));return h.sort((u,g)=>u.zIndex-g.zIndex),a.children=h,a}collectResourceInfo(t,e){if(t.type===v.IMG){const n=t;e.push({type:zn.Image,fileKey:n.imgSrc})}if(t.type===v.SVG){const n=t;n.svgProps.useCode||e.push({type:zn.SVG,fileKey:n.svgUrl})}}}let yo=class{};class ya extends yo{handle(t,e){const n=t.find(o=>o.type===I.Base);n&&(n.x+=e.x,n.y+=e.y)}}let xa=class extends yo{handle(t,e,n){const o=t.find(i=>i.type===I.Connect);if(!o)return;const{start:s,end:r}=o;if(s){const i=n.get(s.objectId);i?s.objectId=i:o.start=null}if(r){const i=n.get(r.objectId);i?r.objectId=i:o.end=null}}};class wa extends yo{handle(t,e){const n=t.find(o=>o.type===I.Line);if(n)for(const o of n.points)o.x+=e.x,o.y+=e.y}}var ma={exports:{}};function Jd(l){throw new Error('Could not dynamically require "'+l+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Qs={exports:{}};const eu=Gh(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var Pa;function tu(){return Pa||(Pa=1,function(l,t){(function(e,n){l.exports=n()})(ao,function(){var e=e||function(n,o){var s;if(typeof window<"u"&&window.crypto&&(s=window.crypto),typeof self<"u"&&self.crypto&&(s=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(s=globalThis.crypto),!s&&typeof window<"u"&&window.msCrypto&&(s=window.msCrypto),!s&&typeof ao<"u"&&ao.crypto&&(s=ao.crypto),!s&&typeof Jd=="function")try{s=eu}catch{}var r=function(){if(s){if(typeof s.getRandomValues=="function")try{return s.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof s.randomBytes=="function")try{return s.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},i=Object.create||function(){function w(){}return function(L){var B;return w.prototype=L,B=new w,w.prototype=null,B}}(),a={},c=a.lib={},h=c.Base=function(){return{extend:function(w){var L=i(this);return w&&L.mixIn(w),(!L.hasOwnProperty("init")||this.init===L.init)&&(L.init=function(){L.$super.init.apply(this,arguments)}),L.init.prototype=L,L.$super=this,L},create:function(){var w=this.extend();return w.init.apply(w,arguments),w},init:function(){},mixIn:function(w){for(var L in w)w.hasOwnProperty(L)&&(this[L]=w[L]);w.hasOwnProperty("toString")&&(this.toString=w.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),d=c.WordArray=h.extend({init:function(w,L){w=this.words=w||[],L!=o?this.sigBytes=L:this.sigBytes=w.length*4},toString:function(w){return(w||g).stringify(this)},concat:function(w){var L=this.words,B=w.words,H=this.sigBytes,E=w.sigBytes;if(this.clamp(),H%4)for(var X=0;X<E;X++){var $=B[X>>>2]>>>24-X%4*8&255;L[H+X>>>2]|=$<<24-(H+X)%4*8}else for(var Z=0;Z<E;Z+=4)L[H+Z>>>2]=B[Z>>>2];return this.sigBytes+=E,this},clamp:function(){var w=this.words,L=this.sigBytes;w[L>>>2]&=4294967295<<32-L%4*8,w.length=n.ceil(L/4)},clone:function(){var w=h.clone.call(this);return w.words=this.words.slice(0),w},random:function(w){for(var L=[],B=0;B<w;B+=4)L.push(r());return new d.init(L,w)}}),u=a.enc={},g=u.Hex={stringify:function(w){for(var L=w.words,B=w.sigBytes,H=[],E=0;E<B;E++){var X=L[E>>>2]>>>24-E%4*8&255;H.push((X>>>4).toString(16)),H.push((X&15).toString(16))}return H.join("")},parse:function(w){for(var L=w.length,B=[],H=0;H<L;H+=2)B[H>>>3]|=parseInt(w.substr(H,2),16)<<24-H%8*4;return new d.init(B,L/2)}},f=u.Latin1={stringify:function(w){for(var L=w.words,B=w.sigBytes,H=[],E=0;E<B;E++){var X=L[E>>>2]>>>24-E%4*8&255;H.push(String.fromCharCode(X))}return H.join("")},parse:function(w){for(var L=w.length,B=[],H=0;H<L;H++)B[H>>>2]|=(w.charCodeAt(H)&255)<<24-H%4*8;return new d.init(B,L)}},y=u.Utf8={stringify:function(w){try{return decodeURIComponent(escape(f.stringify(w)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(w){return f.parse(unescape(encodeURIComponent(w)))}},P=c.BufferedBlockAlgorithm=h.extend({reset:function(){this._data=new d.init,this._nDataBytes=0},_append:function(w){typeof w=="string"&&(w=y.parse(w)),this._data.concat(w),this._nDataBytes+=w.sigBytes},_process:function(w){var L,B=this._data,H=B.words,E=B.sigBytes,X=this.blockSize,$=X*4,Z=E/$;w?Z=n.ceil(Z):Z=n.max((Z|0)-this._minBufferSize,0);var se=Z*X,ne=n.min(se*4,E);if(se){for(var ae=0;ae<se;ae+=X)this._doProcessBlock(H,ae);L=H.splice(0,se),B.sigBytes-=ne}return new d.init(L,ne)},clone:function(){var w=h.clone.call(this);return w._data=this._data.clone(),w},_minBufferSize:0});c.Hasher=P.extend({cfg:h.extend(),init:function(w){this.cfg=this.cfg.extend(w),this.reset()},reset:function(){P.reset.call(this),this._doReset()},update:function(w){return this._append(w),this._process(),this},finalize:function(w){w&&this._append(w);var L=this._doFinalize();return L},blockSize:16,_createHelper:function(w){return function(L,B){return new w.init(B).finalize(L)}},_createHmacHelper:function(w){return function(L,B){return new b.HMAC.init(w,B).finalize(L)}}});var b=a.algo={};return a}(Math);return e})}(Qs)),Qs.exports}(function(l,t){(function(e,n){l.exports=n(tu())})(ao,function(e){return function(n){var o=e,s=o.lib,r=s.WordArray,i=s.Hasher,a=o.algo,c=[];(function(){for(var y=0;y<64;y++)c[y]=n.abs(n.sin(y+1))*4294967296|0})();var h=a.MD5=i.extend({_doReset:function(){this._hash=new r.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(y,P){for(var b=0;b<16;b++){var w=P+b,L=y[w];y[w]=(L<<8|L>>>24)&16711935|(L<<24|L>>>8)&4278255360}var B=this._hash.words,H=y[P+0],E=y[P+1],X=y[P+2],$=y[P+3],Z=y[P+4],se=y[P+5],ne=y[P+6],ae=y[P+7],te=y[P+8],ce=y[P+9],pe=y[P+10],Be=y[P+11],Re=y[P+12],Me=y[P+13],Te=y[P+14],ge=y[P+15],O=B[0],G=B[1],j=B[2],_=B[3];O=d(O,G,j,_,H,7,c[0]),_=d(_,O,G,j,E,12,c[1]),j=d(j,_,O,G,X,17,c[2]),G=d(G,j,_,O,$,22,c[3]),O=d(O,G,j,_,Z,7,c[4]),_=d(_,O,G,j,se,12,c[5]),j=d(j,_,O,G,ne,17,c[6]),G=d(G,j,_,O,ae,22,c[7]),O=d(O,G,j,_,te,7,c[8]),_=d(_,O,G,j,ce,12,c[9]),j=d(j,_,O,G,pe,17,c[10]),G=d(G,j,_,O,Be,22,c[11]),O=d(O,G,j,_,Re,7,c[12]),_=d(_,O,G,j,Me,12,c[13]),j=d(j,_,O,G,Te,17,c[14]),G=d(G,j,_,O,ge,22,c[15]),O=u(O,G,j,_,E,5,c[16]),_=u(_,O,G,j,ne,9,c[17]),j=u(j,_,O,G,Be,14,c[18]),G=u(G,j,_,O,H,20,c[19]),O=u(O,G,j,_,se,5,c[20]),_=u(_,O,G,j,pe,9,c[21]),j=u(j,_,O,G,ge,14,c[22]),G=u(G,j,_,O,Z,20,c[23]),O=u(O,G,j,_,ce,5,c[24]),_=u(_,O,G,j,Te,9,c[25]),j=u(j,_,O,G,$,14,c[26]),G=u(G,j,_,O,te,20,c[27]),O=u(O,G,j,_,Me,5,c[28]),_=u(_,O,G,j,X,9,c[29]),j=u(j,_,O,G,ae,14,c[30]),G=u(G,j,_,O,Re,20,c[31]),O=g(O,G,j,_,se,4,c[32]),_=g(_,O,G,j,te,11,c[33]),j=g(j,_,O,G,Be,16,c[34]),G=g(G,j,_,O,Te,23,c[35]),O=g(O,G,j,_,E,4,c[36]),_=g(_,O,G,j,Z,11,c[37]),j=g(j,_,O,G,ae,16,c[38]),G=g(G,j,_,O,pe,23,c[39]),O=g(O,G,j,_,Me,4,c[40]),_=g(_,O,G,j,H,11,c[41]),j=g(j,_,O,G,$,16,c[42]),G=g(G,j,_,O,ne,23,c[43]),O=g(O,G,j,_,ce,4,c[44]),_=g(_,O,G,j,Re,11,c[45]),j=g(j,_,O,G,ge,16,c[46]),G=g(G,j,_,O,X,23,c[47]),O=f(O,G,j,_,H,6,c[48]),_=f(_,O,G,j,ae,10,c[49]),j=f(j,_,O,G,Te,15,c[50]),G=f(G,j,_,O,se,21,c[51]),O=f(O,G,j,_,Re,6,c[52]),_=f(_,O,G,j,$,10,c[53]),j=f(j,_,O,G,pe,15,c[54]),G=f(G,j,_,O,E,21,c[55]),O=f(O,G,j,_,te,6,c[56]),_=f(_,O,G,j,ge,10,c[57]),j=f(j,_,O,G,ne,15,c[58]),G=f(G,j,_,O,Me,21,c[59]),O=f(O,G,j,_,Z,6,c[60]),_=f(_,O,G,j,Be,10,c[61]),j=f(j,_,O,G,X,15,c[62]),G=f(G,j,_,O,ce,21,c[63]),B[0]=B[0]+O|0,B[1]=B[1]+G|0,B[2]=B[2]+j|0,B[3]=B[3]+_|0},_doFinalize:function(){var y=this._data,P=y.words,b=this._nDataBytes*8,w=y.sigBytes*8;P[w>>>5]|=128<<24-w%32;var L=n.floor(b/4294967296),B=b;P[(w+64>>>9<<4)+15]=(L<<8|L>>>24)&16711935|(L<<24|L>>>8)&4278255360,P[(w+64>>>9<<4)+14]=(B<<8|B>>>24)&16711935|(B<<24|B>>>8)&4278255360,y.sigBytes=(P.length+1)*4,this._process();for(var H=this._hash,E=H.words,X=0;X<4;X++){var $=E[X];E[X]=($<<8|$>>>24)&16711935|($<<24|$>>>8)&4278255360}return H},clone:function(){var y=i.clone.call(this);return y._hash=this._hash.clone(),y}});function d(y,P,b,w,L,B,H){var E=y+(P&b|~P&w)+L+H;return(E<<B|E>>>32-B)+P}function u(y,P,b,w,L,B,H){var E=y+(P&w|b&~w)+L+H;return(E<<B|E>>>32-B)+P}function g(y,P,b,w,L,B,H){var E=y+(P^b^w)+L+H;return(E<<B|E>>>32-B)+P}function f(y,P,b,w,L,B,H){var E=y+(b^(P|~w))+L+H;return(E<<B|E>>>32-B)+P}o.MD5=i._createHelper(h),o.HmacMD5=i._createHmacHelper(h)}(Math),e.MD5})})(ma);var nu=ma.exports;const ou=ks(nu);class ve{constructor(){p(this,"prefix","001");p(this,"map",new Map);p(this,"zIndex",0)}setPrefix(t){this.prefix=t}reset(){this.map.clear(),this.zIndex=0}genId(t){const e=(this.map.get(t)||0)+1;return this.map.set(t,e),ve.type2NodePrefix(t)+this.prefix+":"+e}static genImgFileName(t,e){const n="img:"+t+"|"+e;return ou(n).toString()}loadNode(t){this.loadNodeId(t.id)}loadNodeId(t){const e=ve.nodePrefix2Type(t[0]),n=t.split(":");try{const o=parseInt(n[1]),s=this.map.get(e);s!==void 0?s<o&&this.map.set(e,o):this.map.set(e,o)}catch(o){console.error("id错误",o)}}static genZIndex(t){return t.children.size===0?1:[...t.children].sort((n,o)=>o.zIndex-n.zIndex)[0].zIndex+1}static type2NodePrefix(t){switch(t){case v.Shape:return"a";case v.Line:return"c";case v.SVG:return"d";case v.IMG:return"e";case v.Section:return"f";case v.Group:return"g";case v.Checkbox:return"i";case v.CheckboxText:return"j";case v.SlideContainer:return"k";default:return"x"}}static nodePrefix2Type(t){return t==="a"?v.Shape:t==="c"?v.Line:t==="d"?v.SVG:t==="e"?v.IMG:t==="f"?v.Section:t==="g"?v.Group:t==="i"?v.Checkbox:t==="j"?v.CheckboxText:t==="k"?v.SlideContainer:v.Shape}}class ba{work(t,e,n,o){const s=new Map;this.recordIdMap(e,t,s);const r=[],i=[];let a=ve.genZIndex(t.nodeManager.root);for(const h of e){const d=this.convertToAddNodeInfo(t,h,s,n,r,Mn,a,o);a++,i.push(d)}return{addNodeData:{nodes:r},nextFocusIds:i}}convertToAddNodeInfo(t,e,n,o,s,r,i,a){const c=n.get(e.id),h=this.convertToProps(e.capInfo,o,n,a),d={id:c,type:e.type,zIndex:i,parentId:r,props:h};s.push(d);const u=new m;e.type===v.Group&&(u.x=o.x,u.y=o.y);for(const g of e.children)this.convertToAddNodeInfo(t,g,n,u,s,c,g.zIndex,a);return c}convertToProps(t,e,n,o){const s=M.convertCapInfoToProps(t);for(const r of this.propsHandler)r.handle(s,e,n,o);return s}recordIdMap(t,e,n){for(const o of t){const s=e.idGenerator.genId(o.type);n.set(o.id,s);const r=o.children;this.recordIdMap(r,e,n)}}}class Ma extends ba{constructor(){super(...arguments);p(this,"propsHandler",[new ya,new xa,new wa])}}class Zs{constructor(){p(this,"copyWorker",new Ks);p(this,"pasteWorker",new Ma)}work(t,e){var d;const n=this.copyWorker.work(t);if(!n)return;let o;e?o=e:o=new m(20,20);const s=n.nodes,r=JSON.parse(JSON.stringify(s)),{addNodeData:i,nextFocusIds:a}=this.pasteWorker.work(t,r,o),c=[...t.getSelectNodes()];c.length===1&&((d=c[0].parent)==null?void 0:d.type)===v.SlideContainer?(i.nodes[0].parentId=c[0].parent.id,i.nodes[0].zIndex=ve.genZIndex(c[0].parent),t.execAction(new Le(i)),this.handleSlideContainerDuplicate(t,c[0],a[0])):t.execAction(new Le(i)),t.execAction(xe.create(a))}duplicateByIds(t,e,n){var u;const o=this.copyWorker.copyByIds(t,e);if(!o)return;let s;n?s=n:s=new m(20,20);const r=o.nodes,i=JSON.parse(JSON.stringify(r)),{addNodeData:a,nextFocusIds:c}=this.pasteWorker.work(e,i,s),h=[];t.forEach(g=>{const f=e.nodeManager.getNode(g);f&&h.push(f)}),h.length===1&&((u=h[0].parent)==null?void 0:u.type)===v.SlideContainer?(a.nodes[0].parentId=h[0].parent.id,a.nodes[0].zIndex=ve.genZIndex(h[0].parent),e.execAction(new Le(a)),this.handleSlideContainerDuplicate(e,h[0],c[0])):e.execAction(new Le(a)),e.execAction(xe.create(c))}handleSlideContainerDuplicate(t,e,n){const o=e.parent,s=o.slideProps.children,r=this.getNodePosition(o,e.id);if(!r)return;const{rowIndex:i,colIndex:a}=r,c=s.map((f,y)=>{if(y===i){const P=[...f.ids];return P.splice(a+1,0,n),{ids:P}}return{ids:[...f.ids]}}),h=[{id:o.id,props:[Mt.create({children:c})]}],d=c[i],u=t.nodeManager.getNode(e.id);if(u){let f=u.baseProps.x+u.baseProps.width+nt;const y=u.baseProps.y;for(let P=a+1;P<d.ids.length;P++){const b=d.ids[P],w=t.nodeManager.getNode(b);w&&(h.push({id:b,props:[ie.create({x:f,y,width:w.baseProps.width,height:w.baseProps.height})]}),f+=w.baseProps.width+nt)}}t.execAction(new U({infos:h}));const g=[];for(const f of c)for(const y of f.ids){const P=t.nodeManager.getNode(y);P&&g.push(P.baseProps)}if(g.length>0){const f=M.getBoundsByBasePropsList(g),y=f.maxX-f.minX+2*nt,P=f.maxY-f.minY+2*xt;t.execAction(U.create(o.id,[{type:I.Base,width:y,height:P}]))}}getNodePosition(t,e){const n=t.slideProps.children;for(let o=0;o<n.length;o++){const s=n[o];for(let r=0;r<s.ids.length;r++)if(s.ids[r]===e)return{rowIndex:o,colIndex:r}}return null}}class Sa extends Vs{enable(t){return t.type===v.Group}handle(t,e,n){const o=[],s=t.baseProps.clone();s.x+=e.x,s.y+=e.y,o.push({id:t.id,props:[s]});for(const r of t.children)o.push(...n.handle(r,e));return o}handleChangeRelation(t,e,n){if(t.parent===e)return[];if(t.parent.type===v.Group)return[];const o=t.globalPos,s=e.toLocal(o),r=[];r.push({id:t.id,props:[{type:I.Base,x:s.x,y:s.y}],parentId:e.id,zIndex:n});for(const i of t.children)this.handlePosChange(i,e,r);return r}handlePosChange(t,e,n){if(t.type===v.Line){const s=t.globalLinePoints.map(a=>e.toLocal(a)),r=D.rectNode2Rect(M.getBoundsByPoints(s)),i={id:t.id,props:[{type:I.Line,points:s},{type:I.Base,x:r.x,y:r.y,width:r.width,height:r.height}]};n.push(i)}else{const o=t.globalPos,s=e.toLocal(o),r={id:t.id,props:[{type:I.Base,x:s.x,y:s.y}]};n.push(r)}if(t.type===v.Group)for(const o of t.children)this.handlePosChange(o,e,n)}}class va{constructor(t){p(this,"handlers");this.handlers=t}handle(t,e){for(const n of this.handlers)if(n.enable(t))return n.handle(t,e,this);return[]}handleRelation(t,e,n){for(const o of this.handlers)if(o.enable(t))return o.handleChangeRelation(t,e,n);return[]}}class Ia extends ht{constructor(){super(...arguments);p(this,"moveRect",null);p(this,"lastPos",new m(0,0));p(this,"lastMoveRectPos",new m);p(this,"targetNodes",[]);p(this,"alignWorker",new un);p(this,"layoutWorker",new Rn);p(this,"duplicateWorker",new Zs);p(this,"groupBaseWorker",new on);p(this,"handlerCtx",new va([new ga,new Sa,new fa]))}computeMoveNodes(e,n){e.originEvent.altKey&&this.duplicateWorker.work(n,new m);const o=n.getSelectNodes(),s=this.recordNodeMap(o),r=[];for(const i of o)if(i.type===v.Line){const a=i,{start:c,end:h}=a.connectProps;if(c&&h&&s.has(c.objectId)&&s.has(h.objectId)){r.push(i);continue}if(!c&&h&&s.has(h.objectId)){r.push(i);continue}if(!h&&c&&s.has(c.objectId)){r.push(i);continue}!h&&!c&&r.push(i)}else r.push(i);return r}recordNodeMap(e){const n=new Map;for(const o of e)n.set(o.id,o);return n}onStart(e,n){n.actionManager.execAction(new W),this.targetNodes=this.computeMoveNodes(e,n),this.targetNodes.length!==0&&(this.lastPos=e.globalPoint.clone(),this.moveRect=n.auxiliaryManager.selectManager.getSelectBounds(),this.lastMoveRectPos=new m(this.moveRect.minX,this.moveRect.minY),n.inputManager.editTextInfo&&n.execAction(ee.blur(n.inputManager.editTextInfo.node.id)),this.groupBaseWorker.start(this.targetNodes))}onMove(e,n){if(n.auxiliaryManager.removeAlignGraphics(),this.targetNodes.length===0)return;this.moveNode(e,n,!0);const o=this.hoverOnContainer(e,n);o&&n.addOrUpdate(N.HoverContainer,{node:o})}judgeLinkLineRelation(e,n,o){const{start:s,end:r}=e.connectProps;let i=null,a=null;return s&&(i=n.nodeManager.getNode(s.objectId)),r&&(a=n.nodeManager.getNode(r.objectId)),i?!!(!a||o.has(a)):a?!!o.has(a):!1}onUp(e,n){this.targetNodes.length!==0&&(this.moveNode(e,n,!1),this.changeNodesRelation(e,n),n.actionManager.execAction(new z),n.auxiliaryManager.removeAlignGraphics())}changeNodesRelation(e,n){const o=this.hoverOnContainer(e,n)||n.nodeManager.root,s=n.getSelectNodes(),r=new Set;for(const u of s)u.type!==v.SlideContainer&&r.add(u);const i=new Set;for(const u of s)n.nodeManager.getNodeLinks(u).forEach(f=>i.add(f));for(const u of i)this.judgeLinkLineRelation(u,n,s)&&r.add(u);const a=[],c=o.children.size===0?0:Math.max(...[...o.children].map(u=>u.zIndex));let h=1;const d=M.sortGraphics([...r]);for(const u of d){if(u.parent===o)continue;const g=this.handlerCtx.handleRelation(u,o,c+h);a.push(...g),h++}a.length>0&&n.execAction(new U({infos:a}))}moveNode(e,n,o){const s=e.globalPoint,r=!M.pressMeta(e),i=new m(s.x-this.lastPos.x,s.y-this.lastPos.y);this.moveRectChange(this.moveRect,i);const a=this.alignWorker.alignMove(this.moveRect,n.getSelectNodes(),n,r),c=this.alignWorker.drawAlignLines(a,n),h=this.checkAlign(a),d=M.cloneIRectNode(this.moveRect),u={x:0,y:0};if(h){const y=d.minX+c.x,P=d.minY+c.y;u.x=y-this.lastMoveRectPos.x,u.y=P-this.lastMoveRectPos.y,this.lastMoveRectPos.x=y,this.lastMoveRectPos.y=P}else u.x=i.x,u.y=i.y,this.lastMoveRectPos.x+=i.x,this.lastMoveRectPos.y+=i.y;const g=[];for(const y of this.targetNodes){const P=this.handlerCtx.handle(y,u);g.push(...P)}const f=new Set;this.batchCollectNodeLinks(this.targetNodes,n,f),n.execAction(new U({infos:g},{streaming:o})),this.groupBaseWorker.work(n,o),this.layoutWorker.work([...f],n,o),this.lastPos=s}hoverOnContainer(e,n){const o=n.detect(F.HoverOnContainer,e);return o||null}moveRectChange(e,n){e.minX+=n.x,e.maxX+=n.x,e.minY+=n.y,e.maxY+=n.y}checkAlign(e){const{top:n,bottom:o,right:s,left:r,horizonMid:i,verticalMid:a}=e;return n!==void 0||o!==void 0||s!==void 0||r!==void 0||i!==void 0||a!==void 0}batchCollectNodeLinks(e,n,o){const s=n.getSelectNodes();for(const r of e)this.collectNodeLinks(r,n,s,o)}collectNodeLinks(e,n,o,s){const r=n.nodeManager.getNodeLinks(e);for(const i of r)o.has(i)||s.add(i);for(const i of e.children)i.type!==v.Line&&this.collectNodeLinks(i,n,o,s)}}class Ta extends dt{constructor(){super([new Ia])}streamEnable(t,e){if(e.auxiliaryManager.selectManager.selectNodes.size===0)return!1;const o=e.auxiliaryManager.selectManager.getSelectBounds(),s=D.rectNode2Rect(o);if(s.width<.1||s.height<.1){const i=q.line({x:s.x,y:s.y},{x:o.maxX,y:o.maxY}),a=q.circle(t.globalPoint,4/e.gmlRender.getScale());return Y.intersect(i,a).points.length>0}return M.rectContains2(t.globalPoint,o)}}class La{}class su extends La{enable(t){return t.originEvent.metaKey}handle(t,e,n){for(const o of e)M.containRect(t,o.getBounds())&&n.add(o)}drawGroupRect(t,e){t.addOrUpdate(N.SelectGroup,{rect:e,isPrecise:!0})}}class ru extends La{enable(t){return!0}handle(t,e,n){for(const o of e){if(o.type===v.Section||o.type===v.SlideContainer){M.containRect(t,o.getBounds())&&n.add(o);continue}o.overlapRect(t)&&n.add(o)}}drawGroupRect(t,e){t.addOrUpdate(N.SelectGroup,{rect:e})}}class Ca extends ht{constructor(){super(...arguments);p(this,"startPoint",null);p(this,"handlers",[new su,new ru])}onStart(e,n){this.startPoint=e.globalPoint,n.actionManager.execAction(new W),n.inputManager.editTextInfo&&n.execAction(ee.blur(n.inputManager.editTextInfo.node.id)),n.actionManager.execAction(xe.create([]))}onMove(e,n){if(!this.startPoint)return;const o=Math.min(e.globalPoint.x,this.startPoint.x),s=Math.max(e.globalPoint.x,this.startPoint.x),r=Math.min(e.globalPoint.y,this.startPoint.y),i=Math.max(e.globalPoint.y,this.startPoint.y),a={id:"group-rect",minX:o,maxX:s,minY:r,maxY:i},c=D.rectNode2Rect(a),h=n.nodeManager.searchNodes(o,r,s,i),d=new Set;for(const y of this.handlers)if(y.enable(e)){y.handle(a,h,d),y.drawGroupRect(n,c);break}const u=M.computeSelectNodes(d),f=M.filterSlideContainerNodes(n,u).map(y=>y.id);n.actionManager.execAction(xe.create(f))}onUp(e,n){n.actionManager.execAction(new z),n.removeAuxGraphic(N.SelectGroup),this.startPoint=null}}class qs extends dt{constructor(){super([new Ca])}streamEnable(t,e){if(t.originEvent.metaKey)return!0;const n=e.detect(F.Node,t);if(n&&n.length>0&&e.auxiliaryManager.selectManager.include(n[0])&&n[0].contains(t.globalPoint))return!1;const o=e.auxiliaryManager.selectManager.getSelectBounds();return!M.rectContains2(t.globalPoint,o)}}class xo{moveForward(t){const e=t.getSelectNodes();if(e.size===0)return;t.execAction(new W);const n=M.sortGraphics([...e]).reverse();for(const o of n){const s=this.moveNodeForward(o);s&&t.execAction(s)}t.execAction(new z)}moveBackward(t){const e=t.getSelectNodes();if(e.size===0)return;t.execAction(new W);const n=M.sortGraphics([...e]);for(const o of n){const s=this.moveNodeBackward(o);s&&t.execAction(s)}t.execAction(new z)}moveToUp(t){const e=t.getSelectNodes();if(e.size===0)return;const n=new Map;for(const o of e){const s=o.parent,r=n.get(s);r?r.push(o):n.set(s,[o])}t.execAction(new W);for(const[o,s]of n){const r=this.moveNodesToUp(s,o);r&&t.execAction(r)}t.execAction(new z)}moveToBack(t){const e=t.getSelectNodes();if(e.size===0)return;const n=new Map;for(const o of e){const s=o.parent,r=n.get(s);r?r.push(o):n.set(s,[o])}t.execAction(new W);for(const[o,s]of n){const r=this.moveNodesToBack(s,o);r&&t.execAction(r)}t.execAction(new z)}moveNodesToUp(t,e){if(t.length===0)return null;const n=M.sortGraphics(t),o=new Set(t),s=e.children,r=[];for(const d of s)o.has(d)||r.push(d);const i=M.sortGraphics(r),a=i[i.length-1].zIndex,c=[];let h=1;for(const d of n)c.push({id:d.id,zIndex:a+h,props:[]}),h++;return new U({infos:c})}moveNodesToBack(t,e){if(t.length===0)return null;const n=M.sortGraphics(t).reverse(),o=new Set(t),s=e.children,r=[];for(const d of s)o.has(d)||r.push(d);const a=M.sortGraphics(r)[0].zIndex,c=[];let h=1;for(const d of n)c.push({id:d.id,zIndex:a-h,props:[]}),h++;return new U({infos:c})}moveNodeForward(t){const e=t.parent;if(!e)return null;let n=[...e.children];n=M.sortGraphics(n);const o=n.indexOf(t);if(o<0&&console.error("排序时发生错误",o,t.id),o===n.length-1)return null;if(o===n.length-2){const a=n[o+1],c=[{id:t.id,zIndex:a.zIndex+1,props:[]}];return new U({infos:c})}const s=n[o+1],r=n[o+2],i=[{id:t.id,zIndex:.5*(s.zIndex+r.zIndex),props:[]}];return new U({infos:i})}moveNodeBackward(t){const e=t.parent;if(!e)return null;let n=[...e.children];n=M.sortGraphics(n);const o=n.indexOf(t);if(o<0&&console.error("排序时发生错误",o,t.id),o===0)return null;if(o===1){const a=n[o-1],c=[{id:t.id,zIndex:a.zIndex-1,props:[]}];return new U({infos:c})}const s=n[o-1],r=n[o-2],i=[{id:t.id,zIndex:.5*(s.zIndex+r.zIndex),props:[]}];return new U({infos:i})}}const xs=class xs{constructor(){p(this,"offlineCanvas");p(this,"ctx");this.offlineCanvas=document.createElement("canvas"),this.ctx=this.offlineCanvas.getContext("2d")}static getInstance(){return this.instance||(this.instance=new xs),this.instance}getCanvasCtx(){return this.ctx}};p(xs,"instance",null);let Js=xs;class sn{static dealWithAIDocumentInfo(t){if(t.nodes)for(const e of t.nodes)this.dealNodeInfo(e)}static dealNodeInfo(t){sn.dealNodeSizeForFullText(t);const e=t.children;for(const n of e)this.dealNodeInfo(n)}static dealNodeSizeForFullText(t){var e,n;try{if(t.type!==v.Shape||!((e=t.capInfo)!=null&&e.shapeProps)||!t.capInfo.textProps)return;const o=t.capInfo.shapeProps.shapeCode;if(o!==K.Rect&&o!==K.RoundRect){t.capInfo.textProps.sizeMode=We.fix;return}if(!t.capInfo.textProps.text){t.capInfo.textProps.sizeMode=We.fix;return}if(!t.capInfo.baseProps)return;const s=Js.getInstance().getCanvasCtx(),r=new uo,i=new Ge;i.update(((n=t.capInfo)==null?void 0:n.textProps)||{});const a={x:le,y:le,width:t.capInfo.baseProps.width-2*le,height:t.capInfo.baseProps.height-2*le};r.typesetting(s,i,a);const c=r.height+2*le,h=r.width+2*le;t.capInfo.baseProps.height=c,h>t.capInfo.baseProps.width&&(t.capInfo.baseProps.width=h),t.capInfo.textProps.sizeMode=We.fix}catch{console.error("处理失败,忽略node",t)}}static blurText(t){const e=t.inputManager.editTextInfo;e&&t.execAction(ee.blur(e.node.id))}}class er extends qe{constructor(){super(...arguments);p(this,"node",null)}enable(e,n){const o=n.auxiliaryManager.selectManager.getSelectBounds();if(M.rectContains2(e.globalPoint,o)||!e.originEvent.shiftKey)return!1;if(e.originEvent.metaKey){const r=n.detect(F.Node,e);if(r&&r.length>0)return this.node=r[0],!0}const s=n.detect(F.HoverNode,e);return s?(this.node=s,!0):!1}handle(e,n){if(!this.node)return;const s=[...M.computeSelectNode(n,this.node)].map(r=>r.id);n.actionManager.execAction(new W),sn.blurText(n),n.actionManager.execAction(xe.create([...s])),n.actionManager.execAction(new z)}}class Aa extends qe{constructor(){super(...arguments);p(this,"node",null)}enable(e,n){const o=n.auxiliaryManager.selectManager.getSelectBounds();if(n.getSelectNodes().size>1&&M.rectContains2(e.globalPoint,o))return!1;const s=n.detect(F.HoverNode,e);return s?n.auxiliaryManager.selectManager.include(s)||!this.canEnable(s)?!1:(this.node=s,!0):!1}handle(e,n){this.node&&(n.actionManager.execAction(new W),sn.blurText(n),n.actionManager.execAction(xe.create([this.node.id])),n.actionManager.execAction(new z),this.node.type===v.IMG&&n.setCursor("zoom-in"))}}class tr extends Aa{constructor(){super(...arguments);p(this,"node",null)}canEnable(e){return e.type!==v.Section}}class ka extends qe{constructor(){super(...arguments);p(this,"res",null)}enable(e,n){if(n.getSelectNodes().size!==1)return!1;const o=n.detect(F.Node,e);if(o){const s=o[0];if(n.auxiliaryManager.selectManager.include(s)){const r=s.toLocal(e.globalPoint);if(s instanceof vt&&s.renderText.contains(r))return this.res={node:s,relativePos:r},!0;if(s instanceof Ct)return this.res={node:s,relativePos:r},!0;if(s instanceof Un&&s.renderText.contains(r))return this.res={node:s,relativePos:r},!0}}return!1}handle(e,n){if(!this.res)return;const{node:o,relativePos:s}=this.res,r=o.renderText.detect(s);this.shiftTextClick(e,n,r)||(n.execAction(new W),n.execAction(ee.focus(o.id,r)),n.execAction(new z))}shiftTextClick(e,n,o){if(!e.originEvent.shiftKey)return!1;const s=n.inputManager.editTextInfo,{node:r}=this.res;return s&&!n.inputManager.selectionManager.selectionInfo&&!s.textCursorPosition.equal(o)?(n.execAction(new W),n.execAction(ee.selection(r.id,o,s.textCursorPosition)),n.execAction(new z),!0):!1}}class nr extends qe{constructor(){super(...arguments);p(this,"node",null)}enable(e,n){if(!e.originEvent.shiftKey)return!1;const o=n.detect(F.Node,e);if(o){const s=o[0];if(n.auxiliaryManager.selectManager.include(s))return this.node=s,!0}return!1}handle(e,n){if(!this.node)return;const o=n.getSelectNodes(),s=new Set;o.forEach(r=>s.add(r.id)),s.delete(this.node.id),n.actionManager.execAction(new W),sn.blurText(n),n.actionManager.execAction(xe.create([...s])),n.actionManager.execAction(new z)}}class or extends qe{enable(t,e){return!e.detect(F.Node,t)}handle(t,e){if(e.getSelectNodes().size===0){e.slotManager.addSlotState(ze.QuickCreate,{show:!1});return}if(e.execAction(new W),e.inputManager.editTextInfo){const n=e.inputManager.editTextInfo.node;if(e.execAction(ee.blur(e.inputManager.editTextInfo.node.id)),n.type===v.Shape&&n.shapeType===K.PureText&&n.getProp(I.Text)&&n.isEmptyText()){e.execAction(xe.create([])),e.execAction(At.create([n.id])),e.execAction(new z);return}}e.execAction(xe.create([])),e.execAction(new z)}}class Na extends qe{constructor(){super(...arguments);p(this,"res",null);p(this,"layoutWorker",new Rn)}enable(e,n){const o=n.detect(F.ExpandShape,e);return o?(this.res=o,!0):!1}handle(e,n){const{node:o,realHeight:s}=this.res,r={infos:[{id:o.id,props:[{height:s,type:I.Base},{type:I.Text,sizeMode:We.autoHeight}]}]};n.execAction(new W),sn.blurText(n),n.execAction(new U(r));const i=[...n.nodeManager.getNodeLinks(o)];this.layoutWorker.work(i,n,!1),n.execAction(new z)}}class Ba extends Aa{constructor(){super(...arguments);p(this,"node",null)}canEnable(e){return e.type===v.Section}}class iu extends qe{constructor(){super(...arguments);p(this,"node")}enable(e,n){const o=n.detect(F.Image,e);return o?(this.node=o,!0):!1}handle(e,n){const o=this.getFileKey(this.node),s={nodeId:this.node.id,fileKey:o,blobUrl:n.resourceManager.getBlobUrl(o)};n.slotManager.addSlotState(ze.ClickImg,s)}getFileKey(e){return e.type===v.SVG?e.svgUrl:e.type===v.IMG?e.imgSrc:""}}class Ra{checkbox(t,e,n){const o=t.checkStatus;n.execAction(new W),sn.blurText(n),n.execAction(U.create(t.id,[{type:I.CheckStatus,checkStatus:!o}])),t.type===v.CheckboxText&&n.execAction(U.create(t.id,[{type:I.Text,strikethrough:!o}])),n.execAction(new z)}}const au=new Set([v.Checkbox,v.CheckboxText]);class cu extends qe{constructor(){super(...arguments);p(this,"node",null);p(this,"checkboxWorker",new Ra)}enable(e,n){const o=[...n.getSelectNodes()];if(o.length!==1)return!1;const s=o[0];return au.has(s.type)&&s.checkboxContain(e.globalPoint)?(this.node=s,!0):!1}handle(e,n){this.node&&this.checkboxWorker.checkbox(this.node,e,n)}}class lu extends qe{enable(t,e){return!!e.detect(F.SlideGap,t)}handle(t,e){const n=e.detect(F.SlideGap,t);if(!n)return;const{slideContainer:o,i:s,j:r}=n,i=o.slideProps.children,a=i[s];if(!a||!a.ids||a.ids.length===0)return;const c=this.getGlobalIndex(i,s,r>0?r-1:0),h=r>0;e.execAction(new W);const d=e.slideManager.insertSlide(o,c,h,e);d&&e.execAction(xe.create([d.id])),e.execAction(new z)}getGlobalIndex(t,e,n){let o=0;for(let s=0;s<e;s++)o+=t[s].ids.length;return o+n}}var Nn=(l=>(l[l.A4=0]="A4",l[l.S16_9=1]="S16_9",l[l.S4_3=2]="S4_3",l[l.S1_1=3]="S1_1",l))(Nn||{});const Uo={[Nn.A4]:{width:595,height:842},[Nn.S16_9]:{width:860,height:540},[Nn.S4_3]:{width:860,height:720},[Nn.S1_1]:{width:600,height:600}};class hu extends qe{enable(t,e){return!!e.detect(F.EmptySlideContainer,t)}handle(t,e){const n=e.detect(F.EmptySlideContainer,t);if(!n)return;const{slideContainer:o,rect:s}=n;e.execAction(new W);const r=Uo[Nn.S16_9],i=r.width,a=r.height,d=[ie.create({x:nt,y:xt,width:i,height:a}),tt.create({color:"#F4F2F3"}),Ae.create({color:"#C0A9BD"})],u=e.idGenerator.genId(v.Section),g={id:u,type:v.Section,zIndex:ve.genZIndex(o),parentId:o.id,props:d};e.execAction(Le.create(g));const f=[{ids:[u]}],y=[{id:o.id,props:[Mt.create({children:f})]}],P=i+2*nt,b=a+2*xt;y.push({id:o.id,props:[{type:I.Base,width:P,height:b}]}),e.execAction(new U({infos:y})),e.execAction(xe.create([u])),e.execAction(new z)}}class Ea extends jt{constructor(){super(),this.registerDownHandler(new hu),this.registerDownHandler(new lu),this.registerDownHandler(new Na),this.registerDownHandler(new er),this.registerDownHandler(new tr),this.registerUpHandler(new nr),this.registerUpHandler(new Ba),this.registerUpHandler(new ka),this.registerUpHandler(new cu),this.registerUpHandler(new iu),this.registerUpHandler(new or)}}class Ha extends pn{constructor(){super([new Ea])}}class du{}class Da extends du{enable(t){return t.type===v.Line}handle(t,e){e.addOrUpdate(N.HoverLine,{node:t,transform:t.globalTransform()})}}class Oa{enable(t){return!0}handle(t,e){e.addOrUpdate(N.HoverBounds,{node:t,transform:t.globalTransform()})}}class Xa{enable(t){return t.type===v.Group}handle(t,e){const n=t;if(e.auxiliaryManager.selectManager.include(t))return;const o=n.nameGlobalTransform();e.addOrUpdate(N.HoverBounds,{node:t,transform:o})}}class za{enable(t){return t.type===v.Section}handle(t,e){}}class Wa{constructor(){p(this,"allowEventTypeSet",new Set([be.pointermove]));p(this,"handlers",[new Da,new Xa,new za,new Oa])}process(t,e){const n=e.detect(F.EmptySlideContainer,t);if(n){const i=n.slideContainer,a=n.rect;e.addOrUpdate(N.HoverSlideGapInsertPoint,{point:{x:i.globalBaseProps.x+i.globalBaseProps.width/2,y:i.globalBaseProps.y+i.globalBaseProps.height/2}});const c=ie.create({x:a.x,y:a.y,width:a.width,height:a.height});e.addOrUpdate(N.HoverSlidePlaceHolder,{baseProps:c});return}const o=e.detect(F.SlideGap,t);if(o){e.addOrUpdate(N.HoverSlideGapInsertPoint,{point:o.point});return}const s=e.detect(F.HoverConnectAnchor,t);if(s){s.node.type===v.Shape&&e.previewManager.quickCreateManager.enterQuickPreview(s.node,s.relative,e),e.addOrUpdate(N.HoverConnectAnchor,{point:s.globalPoint});return}e.previewManager.quickCreateManager.exitQuickPreview(e),this.hoverSizer(t,e);const r=e.detect(F.HoverNode,t);if(r){for(const i of this.handlers)if(i.enable(r)){i.handle(r,e);return}}}hoverSizer(t,e){const n=e.detect(F.Stretch,t);if(!n)return;const o=n.nodes,s=o[0];if(n.type===V.BOTTOM_RIGHT)if(o.length===1)e.addOrUpdate(N.HoverSize,{rect:D.baseProps2Rect(s.baseProps),transform:s.globalTransform().clone()});else{const r=e.auxiliaryManager.selectManager.getSelectBounds();e.addOrUpdate(N.HoverSize,{rect:D.rectNode2Rect(r),transform:re.generateMatrix().translate(r.minX,r.minY)})}}}var ye=(l=>(l[l.DEFAULT=0]="DEFAULT",l[l.TEXT=1]="TEXT",l[l.SHAPE=2]="SHAPE",l[l.LINE=3]="LINE",l[l.SECTION=4]="SECTION",l[l.STICKY=5]="STICKY",l[l.HandTool=6]="HandTool",l[l.Resource=7]="Resource",l[l.Widget=8]="Widget",l[l.SlideContainer=9]="SlideContainer",l))(ye||{});class Fa{constructor(t,e,n,o){p(this,"nodeManager");p(this,"inputManager");p(this,"slotManager");p(this,"cursorManager");p(this,"currentTool",ye.DEFAULT);p(this,"shapeType",0);p(this,"grab",!1);p(this,"creatingLine",null);this.nodeManager=t,this.inputManager=e,this.slotManager=n,this.cursorManager=o}setCurrentTool(t,e=0,n=!1){this.currentTool=t,this.shapeType=e,this.grab=n,this.slotManager.addSlotState(ze.ToolChange,{tool:t,shapeType:e}),t===ye.DEFAULT&&this.cursorManager.setCursor("default")}resetTool(){this.creatingLine||this.setCurrentTool(ye.DEFAULT)}setInCreatingLine(t){this.creatingLine=t}}var _n=(l=>(l[l.Checkbox=0]="Checkbox",l[l.CheckboxText=1]="CheckboxText",l))(_n||{});class ft{}class Ya extends ft{constructor(){super(...arguments);p(this,"cursorMap",new Map([[ye.SHAPE,"crosshair"],[ye.SECTION,"crosshair"],[ye.TEXT,"text"],[ye.LINE,"crosshair"]]))}enable(e,n){return this.cursorMap.has(n.toolManager.currentTool)}handle(e,n){if(n.toolManager.grab){n.setCursor("grabbing");return}const o=this.cursorMap.get(n.toolManager.currentTool);n.setCursor(o)}}class uu extends ft{enable(t,e){return!!e.detect(F.ExpandShape,t)}handle(t,e){e.setCursor("pointer")}}class pu extends ft{enable(t,e){const n=e.inputManager.editTextInfo;if(!n)return!1;const{node:o}=n,s=o.getTextContentRect(),r=o.toLocal(t.globalPoint);return!!M.rectContains(r,s)}handle(t,e){e.setCursor("text")}}class Ga extends ft{enable(t,e){const n=e.detect(F.Stretch,t);return n?n.nodes.filter(s=>M.judgeNodeCanBeStretch(s)).length>0:!1}handle(t,e){const n=e.detect(F.Stretch,t);e.setCursor("stretch",n.angle)}}class gu extends ft{enable(t,e){return!!e.detect(F.HoverNode,t)}handle(t,e){e.setCursor("default")}}class sr extends ft{enable(t,e){return!0}handle(t,e){e.setCursor("default")}}class _o{constructor(){p(this,"allowEventTypeSet",new Set([be.pointermove]))}process(t,e){for(const n of this.handlers)if(n.enable(t,e)){n.handle(t,e);return}}}class fu extends ft{enable(t,e){return!!e.detect(F.LineEndPoint,t)}handle(t,e){e.setCursor("move")}}class yu extends ft{constructor(){super(...arguments);p(this,"res",null)}enable(e,n){const o=n.detect(F.PolyControlPoint,e);return o?(this.res=o,!0):!1}handle(e,n){if(!this.res)return;const{isHorizon:o}=this.res;o?n.setCursor("ns-resize"):n.setCursor("ew-resize")}}class xu extends ft{enable(t,e){return!!e.detect(F.Rotate,t)}handle(t,e){const n=e.detect(F.Rotate,t);e.setCursor("rotate",n.cursorAngle)}}class wu extends ft{enable(t,e){return!!e.detect(F.Image,t)}handle(t,e){e.setCursor("zoom-in")}}class mu extends ft{constructor(){super(...arguments);p(this,"res",null)}enable(e,n){const o=n.detect(F.CurveControlPoint,e);return o?(this.res=o,!0):!1}handle(e,n){this.res&&n.setCursor("move")}}class Pu extends ft{constructor(){super(...arguments);p(this,"res",null)}enable(e,n){const o=n.detect(F.CurveEndPoint,e);return o?(this.res=o,!0):!1}handle(e,n){this.res&&n.setCursor("move")}}class bu extends ft{constructor(){super(...arguments);p(this,"res",null)}enable(e,n){const o=n.detect(F.DragLineText,e);return o?(this.res=o,!0):!1}handle(e,n){this.res&&n.setCursor("move")}}class Mu extends ft{enable(t,e){var o;const n=e.detect(F.HoverNode,t);return n?!!(((o=n.parent)==null?void 0:o.type)===v.SlideContainer&&e.auxiliaryManager.selectManager.include(n)):!1}handle(t,e){e.setCursor("move")}}class Su extends ft{enable(t,e){return!!e.detect(F.SlideGap,t)}handle(t,e){e.setCursor("pointer")}}class Ua extends _o{constructor(){super(...arguments);p(this,"handlers",[new Ya,new yu,new Pu,new mu,new bu,new uu,new fu,new pu,new Ga,new xu,new Su,new Mu,new gu,new wu,new sr])}}class _a extends Ot{constructor(){super([new Wa,new Ua])}canBeEnable(t,e){return!0}canBeExit(t,e){return!0}}class vu extends fn{enable(t){return t.type===v.Line}handle(t,e,n,o,s){const i=t.parent.globalTransform().inverseMatrix().crossProduct(s),a=[];for(const h of e.points){const d=i.crossPoint(h);a.push(d)}const c=D.rectNode2Rect(M.getBoundsByPoints(a));return[{id:t.id,props:[{type:I.Line,points:a},{type:I.Base,x:c.x,y:c.y,width:c.width,height:c.height}]}]}}class Iu extends fn{enable(t){return t.type===v.SlideContainer}handle(t,e,n,o,s){return[]}}class $a extends Go{constructor(){super(...arguments);p(this,"handlers",[new vu,new ha,new da,new Iu,new la])}computeOriginTransform(e){const n=this.target,{x:o,y:s}=this.originStretchRect,r=re.generateMatrix().translate(-o,-s),i=this.computeAnchorPoint(n,this.originStretchRect),c=re.generateMatrix().translate(-i.x,-i.y).crossProduct(r);this.originTransform=c}recordPropsMap(e){this.propsMap.clear();for(const n of this.target.nodes){const o=this.recordNodePropInfo(n);if(n.type===v.Line){const r=n.globalLinePoints.map(i=>this.originTransform.crossPoint(i));o.points=r}this.propsMap.set(n,o)}}drawAlignLine(e,n,o){const s=o.auxiliaryManager.selectManager.getSelectBounds(),r=D.rectNode2Rect(s),i=re.generateMatrix().translate(s.minX,s.minY),{width:a,height:c}=n;if(a){e.width+=a.dt;const h={transform:i,line:{start:new m(0,r.height),end:new m(r.width,r.height)}};a.lines.push(h)}if(c){e.height+=c.dt;const h={transform:i,line:{start:new m(r.width,0),end:new m(r.width,r.height)}};c.lines.push(h)}o.addOrUpdate(N.AlignStretchLine,{alignInfo:n})}getMiniSize(e){const n=[],o=[],{width:s,height:r}=this.originStretchRect,i=this.target.nodes;if([...i].filter(d=>d.type===v.Line).length===i.length)return{x:10,y:10};for(const d of i){if(d.type===v.Line)continue;const u=d.getStretchMinSize();n.push(u.x/s),o.push(u.y/r)}const c=Math.max(...n),h=Math.max(...o);return{x:c*s,y:h*r}}getStretchRect(e){const n=e.auxiliaryManager.selectManager.getSelectBounds();return D.rectNode2Rect(n)}}class ja extends kn{constructor(){super([new $a])}streamEnable(t,e){if(e.getSelectNodes().size===0)return!1;const n=e.detect(F.Stretch,t);if(!n)return!1;const o=n.nodes,s=o.filter(r=>M.judgeNodeCanBeStretch(r));return o.length>1&&s.length>0}}class rr{}class Tu extends rr{constructor(){super(...arguments);p(this,"polylineHandler",new Vt)}enable(e){return e.isPolyLine()}handleMove(e,n,o){const{line:s}=n,r=this.handle(e,n,o),i=M.dealWithEndPolyPoints(r,o.gmlRender.getScale(),!n.isStart),a=s.globalTransform().inverseMatrix(),c=i.map(u=>a.crossPoint(u)),h=D.rectNode2Rect(M.getBoundsByPoints(c));return{id:s.id,props:[{type:I.Line,points:c},ie.create({x:h.x,y:h.y,width:h.width,height:h.height})]}}handleUp(e,n,o,s){const{line:r}=n,i=this.handle(e,n,o),a=M.dealWithEndPolyPointsInUp(i,o.gmlRender.getScale(),!n.isStart),c=r.globalTransform().inverseMatrix(),h=a.map(g=>c.crossPoint(g)),d=D.rectNode2Rect(M.getBoundsByPoints(h));return{id:r.id,props:[{type:I.Line,points:h},ie.create({x:d.x,y:d.y,width:d.width,height:d.height}),s]}}handle(e,n,o){const{line:s}=n,r=s.lineProps;let i=[];return r.auto?i=this.autoLayoutLine(e,n,o):i=this.editLine(e,n,o),i}autoLayoutLine(e,n,o){const{line:s,isStart:r}=n,i=s.connectProps;if(r){const a=e,c=Ze.computeConnectInfo(s,i.end,o,!0);return this.polylineHandler.layoutToPointsPro(a,c)}else{const a=e,c=Ze.computeConnectInfo(s,i.start,o,!1);return this.polylineHandler.layoutToPointsPro(c,a)}}editLine(e,n,o){const{line:s,isStart:r}=n,i=[...s.globalLinePoints];if(i.length===2)return this.autoLayoutLine(e,n,o);const a=e.point;if(r){const c=i[0],h=i[1],d=M.judgeHorizon(c,h);if(i.length>3){const u=i[2];M.distance(h,u)<3&&(d?Math.abs(a.y-u.y)<6:Math.abs(a.x-u.x)<6)&&(d?a.y=u.y:a.x=u.x)}c.x=a.x,c.y=a.y,d?h.y=c.y:h.x=c.x}else{const c=i[i.length-2],h=i[i.length-1],d=M.judgeHorizon(c,h);if(i.length>3){const u=i[i.length-3];M.distance(c,u)<3&&(d?Math.abs(a.y-u.y)<6:Math.abs(a.x-u.x)<6)&&(d?a.y=u.y:a.x=u.x)}h.x=a.x,h.y=a.y,d?c.y=h.y:c.x=h.x}return i}}class Lu extends rr{enable(t){return t.shapeType===de.Line}handle(t,e,n){const{line:o,isStart:s}=e,r=[...o.globalLinePoints];return s?(r.shift(),r.unshift(t.point)):(r.pop(),r.push(t.point)),r}handleMove(t,e,n){const{line:o}=e,s=this.handle(t,e,n),r=o.globalTransform().inverseMatrix(),i=s.map(c=>r.crossPoint(c)),a=D.rectNode2Rect(M.getBoundsByPoints(i));return{id:o.id,props:[{type:I.Line,points:i},ie.create({x:a.x,y:a.y,width:a.width,height:a.height})]}}handleUp(t,e,n,o){const{line:s}=e,r=this.handle(t,e,n),i=s.globalTransform().inverseMatrix(),a=r.map(h=>i.crossPoint(h)),c=D.rectNode2Rect(M.getBoundsByPoints(a));return{id:s.id,props:[{type:I.Line,points:a},ie.create({x:c.x,y:c.y,width:c.width,height:c.height}),o]}}}class Cu extends rr{constructor(){super(...arguments);p(this,"bezierWorker",new zo)}enable(e){return e.shapeType===de.Curve}handle(e,n,o){const{line:s,isStart:r}=n,i=[...s.globalLinePoints],{start:a,end:c}=s.connectProps;if(r){i.shift(),i.unshift(e.point);let h;e.endTypeInfo&&(h=this.bezierWorker.computeConnectEndInfo(e.endTypeInfo,o.nodeManager));const d=this.bezierWorker.computeConnectEndInfo(c,o.nodeManager);return this.bezierWorker.computeCurvePoints(i,h,d)}else{i.pop(),i.push(e.point);let h;e.endTypeInfo&&(h=this.bezierWorker.computeConnectEndInfo(e.endTypeInfo,o.nodeManager));const d=this.bezierWorker.computeConnectEndInfo(a,o.nodeManager);return this.bezierWorker.computeCurvePoints(i,d,h)}}handleMove(e,n,o){const{line:s}=n,r=this.handle(e,n,o),i=s.globalTransform().inverseMatrix(),a=r.map(h=>i.crossPoint(h)),c=D.rectNode2Rect(M.getBoundsByPoints(a));return{id:s.id,props:[{type:I.Line,points:a},ie.create({x:c.x,y:c.y,width:c.width,height:c.height})]}}handleUp(e,n,o,s){const{line:r}=n,i=this.handle(e,n,o),a=r.globalTransform().inverseMatrix(),c=i.map(d=>a.crossPoint(d)),h=D.rectNode2Rect(M.getBoundsByPoints(c));return{id:r.id,props:[{type:I.Line,points:c},ie.create({x:h.x,y:h.y,width:h.width,height:h.height}),s]}}}class $n{constructor(){p(this,"t",.5)}init(t){if(t.renderText.isEmptyText())return;const e=t.getLineLength(),n=t.points,{point:o}=t.lineTextRect,s=t.baseProps,r=new m(o.x+s.x,o.y+s.y);if(t.shapeType===de.Line){const i=M.distance(n[0],r);this.t=i/e;return}if(t.isPolyLine()){let i=0;for(let a=0;a<n.length;a++){const c=n[a],h=n[a+1],d=q.circle(r,1),u=q.line(c,h);if(Y.intersect(d,u).points.length>0){const f=M.distance(r,c);this.t=(f+i)/e;return}i+=M.distance(c,h)}return}if(t.shapeType===de.Curve){const i=M.computeBezierCurves(t);let a=0;for(let c=0;c<i.length;c++){const h=i[c],d=q.circle(r,1),{p0:u,p1:g,p2:f,p3:y}=h,P=q.cubicBezier(u,g,f,y),b=Y.intersect(d,P),w=h.getApproximateLength();if(b.points.length>0){const L=h.getTValueByPoint(r);this.t=(L*w+a)/e;return}a+=w}}}work(t,e,n){if(t.renderText.isEmptyText())return;const{width:o,height:s}=t.lineTextRect,r=M.computePointByT(t,this.t),i=t.baseProps,a=new m(r.x-i.x,r.y-i.y);e.execAction(U.create(t.id,[{type:I.LineTextRect,point:a,x:a.x-.5*o,y:a.y-.5*s}],{streaming:n}))}}class Va extends ht{constructor(){super(...arguments);p(this,"res",null);p(this,"connectEndProp");p(this,"alignWorker",new un);p(this,"groupBaseWorker",new on);p(this,"lineTextWorker",new $n);p(this,"handlers",[new Tu,new Cu,new Lu]);p(this,"currentHandler",null)}selectHandler(){const{line:e,isStart:n}=this.res;for(const o of this.handlers)o.enable(e)&&(this.currentHandler=o)}computeConnectProp(e,n){const o=n.detect(F.LineEndPoint,e);if(!o)return;this.res=o;const s=o.line.connectProps;if(o.isStart){const r=Ze.computeConnectInfo(o.line,s.end,n,!0);this.connectEndProp={isStart:!1,connectInfo:r}}}onStart(e,n){this.computeConnectProp(e,n),this.selectHandler(),n.execAction(new W),this.removeConnectInfoAndSendMsg(e,n),this.groupBaseWorker.start([this.res.line]),this.lineTextWorker.init(this.res.line)}onMove(e,n){if(!this.res)return;const o=this.getConnectInfo(e,n),s=this.currentHandler.handleMove(o,this.res,n);n.execAction(new U({infos:[s]},{streaming:!0})),this.lineTextWorker.work(this.res.line,n,!0),this.groupBaseWorker.work(n,!0)}onUp(e,n){if(!this.res)return;const o=this.addConnectInfoAndSendMsg(e,n),s=this.getConnectInfo(e,n),r=this.currentHandler.handleUp(s,this.res,n,o);n.execAction(new U({infos:[r]},{streaming:!1})),this.lineTextWorker.work(this.res.line,n,!1),this.groupBaseWorker.work(n,!1),n.execAction(new z)}getConnectInfo(e,n){const o=this.res.line,s=this.res.isStart,r=M.dealWithShiftLineInteractEvent(e,o,!s),i=!M.pressMeta(e),c={point:this.alignWorker.alignLineEndAndDrawAlignLines(r,n,n.getSelectNodes(),i)},h=n.detect(F.NodeEdge,r);return h&&(c.point=new m(h.point.x,h.point.y),c.nodeConnect={rect:D.rectNode2Rect(h.node.getBounds()),endType:M.computeNodeConnectEnd(h.relativePos,h.node.baseProps.angle)},c.endTypeInfo=this.computeEndType(e,n)||void 0),c}computeEndType(e,n){const o=n.detect(F.NodeEdge,e);return o?{objectId:o.node.id,x:o.relativePos.x,y:o.relativePos.y}:null}addConnectInfoAndSendMsg(e,n){const{line:o,isStart:s}=this.res,r=o.connectProps.clone(),i=s?"start":"end",a=this.computeEndType(e,n);return a?r[i]=a:r[i]=null,r}removeConnectInfoAndSendMsg(e,n){const{line:o,isStart:s}=this.res,r=o.connectProps.clone(),i=s?"start":"end";r[i]=null;const a={id:o.id,props:[r]};n.execAction(new U({infos:[a]}))}}class $o{constructor(){p(this,"allowEventTypeSet",new Set([be.pointermove]))}process(t,e){const n=e.detect(F.BufferNode,t);if(!n)return;const o=n.filter(s=>s.canBeConnected());o.length!==0&&(e.auxiliaryManager.selectManager.include(o[0])||o[0].canBeConnected()&&e.addOrUpdate(N.HoverConnectAnchorPoint,{node:o[0]}))}}class jo{constructor(){p(this,"allowEventTypeSet",new Set([be.pointermove]))}process(t,e){const n=e.detect(F.HoverConnectAnchor,t);if(n){e.addOrUpdate(N.HoverConnectAnchor,{point:n.globalPoint});return}const o=e.detect(F.HoverNodeAnchor,t);o&&e.addOrUpdate(N.HoverAnchorPoint,{node:o.node,localPoint:o.localPoint})}}class Vo{constructor(){p(this,"allowEventTypeSet",new Set([be.pointermove]))}process(t,e){if(e.toolManager.currentTool!==ye.LINE)return;const o=e.detect(F.NodeEdge,t);o&&e.addOrUpdate(N.HoverConnectPoint,{point:o.point})}}class Au extends dt{constructor(){super([new Va],[new $o,new jo,new Vo])}streamEnable(t,e){return!!e.detect(F.LineEndPoint,t)}}class Ko{setPointValue(t,e,n,o){t?(e.y=o.y,n.y=o.y):(e.x=o.x,n.x=o.x)}}class ku extends Ko{enable(t){const{rIndex:e,lIndex:n,line:o}=t,s=[...o.points];return n>0&&e<s.length-1}handle(t,e,n){const{rIndex:o,lIndex:s,line:r,isHorizon:i}=t,a=[...r.points],c=r.toLocal(e.globalPoint),h=a[s],d=a[o],u=a[o+1],g=a[s-1],f=n.gmlRender.getScale();return M.distance(g,h)<3/f&&(i?Math.abs(c.y-g.y)<6/f:Math.abs(c.x-g.x)<6/f)?i?c.y=g.y:c.x=g.x:M.distance(d,u)<3/f&&(i?Math.abs(c.y-u.y)<6/f:Math.abs(c.x-u.x)<6/f)&&(i?c.y=u.y:c.x=u.x),this.setPointValue(i,h,d,c),a}setPointValue(t,e,n,o){t?(e.y=o.y,n.y=o.y):(e.x=o.x,n.x=o.x)}}class Nu extends Ko{enable(t){const{rIndex:e,lIndex:n,line:o}=t,s=[...o.points];return n===0&&e===1&&s.length===2}handle(t,e){const{rIndex:n,lIndex:o,line:s,isHorizon:r}=t,i=[...s.points],{start:a,end:c}=s.connectProps,h=i[o],d=i[n],u=s.toLocal(e.globalPoint);if(!a&&!c)return this.setPointValue(r,h,d,u),i;if(c&&!a){if(r){const P=d.x>h.x?1:-1,b=new m(d.x-P*A,d.y),w=new m(d.x-P*A,u.y);return i.splice(o+1,0,b,w),t.lIndex=o+2,t.rIndex=n+2,i}const g=d.y>h.y?1:-1,f=new m(d.x,d.y-g*A),y=new m(u.x,d.y-g*A);return i.splice(o+1,0,f,y),t.lIndex=o+2,t.rIndex=n+2,i}if(a&&!c){if(r){const P=d.x>h.x?1:-1,b=new m(h.x+P*A,h.y),w=new m(h.x+P*A,u.y);return i.splice(o+1,0,b,w),t.lIndex=o+2,t.rIndex=n+2,i}const g=d.y>h.y?1:-1,f=new m(h.x,h.y-g*A),y=new m(u.x,h.y-g*A);return i.splice(o+1,0,f,y),t.lIndex=o+2,t.rIndex=n+2,i}if(a&&c){if(r){const w=d.x>h.x?1:-1,L=new m(h.x+w*A,h.y),B=new m(h.x+w*A,u.y),H=new m(d.x-w*A,d.y),E=new m(d.x-w*A,u.y);return i.splice(o+1,0,L,B,H,E),t.lIndex=o+4,t.rIndex=n+4,i}const g=d.y>h.y?1:-1,f=new m(h.x,h.y-g*A),y=new m(u.x,h.y-g*A),P=new m(d.x,d.y-g*A),b=new m(u.x,d.y-g*A);return i.splice(o+1,0,f,y,P,b),t.lIndex=o+4,t.rIndex=n+4,i}return[]}}class Bu extends Ko{enable(t){const{lIndex:e}=t;return e===0}handle(t,e){const{rIndex:n,lIndex:o,line:s,isHorizon:r}=t,i=[...s.points],{start:a,end:c}=s.connectProps,h=i[o],d=i[n],u=s.toLocal(e.globalPoint);if(!a)return this.setPointValue(r,h,d,u),i;if(r){const P=d.x>h.x?1:-1,b=new m(h.x+P*A,h.y),w=new m(h.x+P*A,u.y);return i.splice(o+1,0,b,w),t.lIndex=o+2,t.rIndex=n+2,i}const g=d.y<h.y?1:-1,f=new m(h.x,h.y-g*A),y=new m(u.x,h.y-g*A);return i.splice(o+1,0,f,y),t.lIndex=o+2,t.rIndex=n+2,i}}class Ru extends Ko{enable(t){const{rIndex:e,line:n}=t;return e===n.points.length-1}handle(t,e){const{rIndex:n,lIndex:o,line:s,isHorizon:r}=t,i=[...s.points],{end:a}=s.connectProps,c=i[o],h=i[n],d=s.toLocal(e.globalPoint);if(!a)return this.setPointValue(r,c,h,d),i;if(r){const y=h.x<c.x?1:-1,P=new m(h.x+y*A,h.y),b=new m(h.x+y*A,d.y);return i.splice(o+1,0,b,P),c.y=d.y,i}const u=h.y>c.y?1:-1,g=new m(h.x,h.y-u*A),f=new m(d.x,h.y-u*A);return i.splice(o+1,0,f,g),c.x=d.x,i}}class Eu extends ht{constructor(){super(...arguments);p(this,"res");p(this,"handlers",[new ku,new Nu,new Bu,new Ru]);p(this,"lineTextWorker",new $n)}onStart(e,n){this.res=n.detect(F.PolyControlPoint,e),n.execAction(new W),this.lineTextWorker.init(this.res.line)}onMove(e,n){const{line:o}=this.res,s=this.computeLinePoints(e,n),r=D.rectNode2Rect(M.getBoundsByPoints(s)),i={infos:[{id:o.id,props:[{type:I.Line,points:s,auto:!1},ie.create({x:r.x,y:r.y,width:r.width,height:r.height})]}]};n.execAction(new U(i,{streaming:!0})),this.lineTextWorker.work(this.res.line,n,!0)}onUp(e,n){const{line:o}=this.res,s=n.gmlRender.getScale(),r=this.computeLinePoints(e,n),i=M.dealWithPolyPoints(r,s),a=D.rectNode2Rect(M.getBoundsByPoints(i)),c={infos:[{id:o.id,props:[{type:I.Line,points:i,auto:!1},ie.create({x:a.x,y:a.y,width:a.width,height:a.height})]}]};n.execAction(new U(c,{streaming:!1})),this.lineTextWorker.work(this.res.line,n,!1),n.execAction(new z)}computeLinePoints(e,n){for(const o of this.handlers)if(o.enable(this.res))return o.handle(this.res,e,n);return[]}}class Hu extends dt{constructor(){super([new Eu],[])}streamEnable(t,e){return!!e.detect(F.PolyControlPoint,t)}}class Du extends ht{constructor(){super(...arguments);p(this,"startConnectInfo",{point:new m});p(this,"target",null);p(this,"layoutHandler",new Vt);p(this,"alignWorker",new un)}onStart(e,n){this.startConnectInfo.point=e.globalPoint;const s=[new Oe(de.RoundPolyLine)],{node:r,relative:i}=n.detect(F.HoverConnectAnchor,e),a={type:I.Connect,start:{objectId:r.id,x:i.x,y:i.y}};s.push(a);const c=Ze.getNodePos(r,i);this.startConnectInfo={point:new m(c.x,c.y),nodeConnect:{rect:D.rectNode2Rect(r.getBounds()),endType:M.computeNodeConnectEnd(i,r.baseProps.angle)}};const h={point:e.globalPoint.clone()},d=this.layoutHandler.layoutToPointsPro(this.startConnectInfo,h),u=je.create(d),g=D.rectNode2Rect(M.getBoundsByPoints(d)),f=ie.create({x:g.x,y:g.y,width:g.width,height:g.height});s.push(u,f,new Ae,lt.create({rArrow:it.Arrow}),Ge.create({sizeMode:We.autoWidth}),new Et);const y=n.idGenerator.genId(v.Line),P={id:y,type:v.Line,zIndex:ve.genZIndex(n.nodeManager.root),parentId:"",props:s};n.actionManager.execAction(new W);const b=Le.create(P);n.actionManager.execAction(b),this.target=n.nodeManager.nodeMap.get(y),n.actionManager.execAction(xe.create([this.target.id])),n.setCursor("crosshair")}onMove(e,n){const o=M.dealWithShiftLineInteractEvent(e,this.target),s=Ze.computeLinePoints(this.startConnectInfo,this.layoutHandler,o,n,this.alignWorker),r=M.dealWithEndPolyPoints(s,n.gmlRender.getScale(),!0),i=D.rectNode2Rect(M.getBoundsByPoints(r)),a=[je.create(r),ie.create({x:i.x,y:i.y,width:i.width,height:i.height})],c={infos:[{id:this.target.id,props:a}]};n.actionManager.execAction(new U(c,{streaming:!0}))}onUp(e,n){const o=M.dealWithShiftLineInteractEvent(e,this.target),s=[],r=n.detect(F.NodeEdge,o);if(r){const d=this.target.connectProps.clone();d.end={objectId:r.node.id,x:r.relativePos.x,y:r.relativePos.y},s.push(d)}const i=Ze.computeLinePoints(this.startConnectInfo,this.layoutHandler,o,n,this.alignWorker),a=M.dealWithEndPolyPointsInUp(i,n.gmlRender.getScale(),!0),c=D.rectNode2Rect(M.getBoundsByPoints(a));s.push(je.create(a),ie.create({x:c.x,y:c.y,width:c.width,height:c.height}));const h={infos:[{id:this.target.id,props:s}]};if(n.actionManager.execAction(new U(h,{streaming:!1})),!r){n.execAction(xe.create([]));const d={clientPoint:o.clientPoint,show:!0,lineId:this.target.id};n.slotManager.addSlotState(ze.QuickCreate,d)}n.execAction(new z),n.setCursor("default")}}class Ou extends dt{constructor(){super([new Du],[new $o,new jo,new Vo])}streamEnable(t,e){return!!e.detect(F.HoverConnectAnchor,t)}}class ir{}const Xu=new Set([v.Shape,v.SVG,v.IMG]);class zu extends ir{enable(t){return Xu.has(t.type)}handle(t,e,n,o){const s=t.baseProps,r=new m(0,0),i=t.toGlobal(r),a=e.crossPoint(i),h=t.parent.globalTransform().inverseMatrix().crossPoint(a);o.push({id:t.id,props:[{type:I.Base,x:h.x,y:h.y,angle:s.angle+n}]})}}class Wu extends ir{enable(t){return t.type===v.Line}handle(t,e,n,o){const{start:s,end:r}=t.connectProps;if(s||r)return;const i=t.lineProps,a=[],c=[];for(const u of i.points){const g=e.crossPoint(u);a.push(g)}c.push({type:I.Line,points:a});const h=M.getBoundsByPoints(a),d={type:I.Base,x:h.minX,y:h.minY,width:h.maxX-h.minX,height:h.maxY-h.minY};c.push(d),o.push({id:t.id,props:c})}}class Fu extends ir{constructor(){super(...arguments);p(this,"layoutHandler",new Vt)}enable(e){return e.type!==v.Line?!1:e.isPolyLine()}handle(e,n,o,s){const{start:r,end:i}=e.connectProps;if(r||i)return;const a=e.lineProps,c=[],h=a.points[0],d=a.points[a.points.length-1],u=n.crossPoint(h),g=n.crossPoint(d),f=this.layoutHandler.layoutToPointsPro({point:u},{point:g});c.push({type:I.Line,points:f});const y=M.getBoundsByPoints(f),P={type:I.Base,x:y.minX,y:y.minY,width:y.maxX-y.minX,height:y.maxY-y.minY};c.push(P),s.push({id:e.id,props:c})}}class Ka extends ht{constructor(){super(...arguments);p(this,"rotateInfo",null);p(this,"lastAngle",0);p(this,"originAngle",0);p(this,"originNodeAngle",0);p(this,"matrix",re.generateMatrix());p(this,"reverseMatrix",re.generateMatrix());p(this,"layoutWorker",new Rn);p(this,"groupBaseWorker",new on);p(this,"handlers",[new zu,new Fu,new Wu])}onStart(e,n){this.rotateInfo=n.detect(F.Rotate,e);const o=Ze.trimPoint(e.globalPoint),s=this.rotateInfo.rotateCenter,r=this.rotateInfo.nodes;r.length===1?this.originNodeAngle=r[0].baseProps.angle:this.originNodeAngle=0,this.lastAngle=Ze.calculateAngle(s,o),this.originAngle=this.lastAngle;const i=re.generateMatrix().translate(-s.x,-s.y);this.matrix=i,this.reverseMatrix=i.inverseMatrix(),n.actionManager.execAction(new W),n.inputManager.editTextInfo&&n.execAction(ee.blur(n.inputManager.editTextInfo.node.id)),this.groupBaseWorker.start(this.rotateInfo.nodes)}onMove(e,n){this.rotateNode(e,n,!0),this.removeAuxiliaryGraphics(n)}onUp(e,n){this.rotateNode(e,n,!1),n.auxiliaryManager.selectManager.refreshSelectStatus(),n.setCursor("default"),n.actionManager.execAction(new z),this.rotateInfo=null}removeAuxiliaryGraphics(e){e.removeAuxGraphic(N.HighlightRects),e.removeAuxGraphic(N.MultiSelectBound),e.removeAuxGraphic(N.SingleSelectBound),e.removeAuxGraphic(N.StretchRect),e.removeAuxGraphic(N.ExpandShape),e.removeAuxGraphic(N.SelectConnectAnchor)}rotateNode(e,n,o){const s=Ze.trimPoint(e.globalPoint),r=this.rotateInfo.rotateCenter;let i=Ze.calculateAngle(r,s);i=this.computeDeltaAngle(e,i);const a=i-this.lastAngle,c=re.generateMatrix().rotate(a),h=this.reverseMatrix.crossProduct(c).crossProduct(this.matrix),d=[],u=new Set;for(const g of this.rotateInfo.nodes){for(const f of this.handlers)if(f.enable(g)){f.handle(g,h,a,d);break}this.layoutWorker.collectNodeLinks(g,n,u)}if(n.execAction(new U({infos:d},{streaming:o})),this.lastAngle=i,this.rotateInfo.nodes.length===1){const g=M.computeRotateDeltaAngle(this.rotateInfo.rotateType),f=M.computeRotateAngle(this.rotateInfo.nodes,g);n.setCursor("rotate",f)}this.layoutWorker.work([...u],n,o),this.groupBaseWorker.work(n,o)}computeDeltaAngle(e,n){if(e.originEvent.ctrlKey)return n;let o=n-this.originAngle+this.originNodeAngle;const s=Ze.trimAngle(o),r=7.5;return Math.abs(s)<r?(o+=0-s,o+this.originAngle-this.originNodeAngle):Math.abs(s-90)<r?(o+=90-s,o+this.originAngle-this.originNodeAngle):Math.abs(s-180)<r?(o+=180-s,o+this.originAngle-this.originNodeAngle):Math.abs(s-270)<r?(o+=270-s,o+this.originAngle-this.originNodeAngle):Math.abs(s-360)<r?(o+=360-s,o+this.originAngle-this.originNodeAngle):n}}class Qa extends kn{constructor(){super([new Ka])}streamEnable(t,e){return e.getSelectNodes().size===0?!1:!!e.detect(F.Rotate,t)}}const Xt=100,rn=50;class Za{computeEndNodeRelative(t,e){const n=t.drawer.getConnectAnchor(),o=M.computeOriginNodeConnectEnd(e);let s;return o===ue.Top?s=n[ue.Bottom]:o===ue.Bottom?s=n[ue.Top]:o===ue.Left?s=n[ue.Right]:s=n[ue.Left],s}judgeQuickCreateMode(t,e,n){const o=M.computeNodeConnectEnd(e,t.baseProps.angle),s=t.globalBaseProps,r=s.clone();o===ue.Top?r.y=s.y-s.height-Xt:o===ue.Bottom?r.y=s.y+s.height+Xt:o===ue.Left?r.x=s.x-s.width-Xt:r.x=s.x+s.width+Xt;const i=M.getBoundsByBaseProps(r),a=n.nodeManager.searchNodesByRectNode(i).filter(h=>h.type!==v.Line&&h.type!==v.Section),c=M.sortGraphics(a);return c.length===0?null:c[c.length-1]}computePreviewNodePos(t,e,n){const o=M.computeNodeConnectEnd(e,t.baseProps.angle);return o===ue.Top?this.findTopPlace(t,o,n):o===ue.Bottom?this.findBottomPlace(t,o,n):o===ue.Left?this.findLeftPlace(t,o,n):this.findRightPlace(t,o,n)}findTopPlace(t,e,n){const o=t.globalBaseProps;for(let s=0;s<20;s++){const r=o.clone();r.y=o.y-o.height-Xt;const i=s%2,a=Math.ceil(s/2);i?r.x-=a*(o.width+rn):r.x+=a*(o.width+rn);const c=M.getBoundsByBaseProps(r);if(n.nodeManager.searchNodesByRectNode(c).filter(d=>d.type!==v.Line&&d.type!==v.Section).length===0)return{x:r.x,y:r.y}}return{x:o.x,y:o.y-o.height-rn}}findBottomPlace(t,e,n){const o=t.globalBaseProps;for(let s=0;s<20;s++){const r=o.clone();r.y=o.y+o.height+Xt;const i=s%2,a=Math.ceil(s/2);i?r.x-=a*(o.width+rn):r.x+=a*(o.width+rn);const c=M.getBoundsByBaseProps(r);if(n.nodeManager.searchNodesByRectNode(c).filter(d=>d.type!==v.Line&&d.type!==v.Section).length===0)return{x:r.x,y:r.y}}return{x:o.x,y:o.y+o.height+Xt}}findRightPlace(t,e,n){const o=t.globalBaseProps;for(let s=0;s<20;s++){const r=o.clone();r.x=o.x+o.width+Xt;const i=s%2,a=Math.ceil(s/2);i?r.y-=a*(o.width+rn):r.y+=a*(o.width+rn);const c=M.getBoundsByBaseProps(r);if(n.nodeManager.searchNodesByRectNode(c).filter(d=>d.type!==v.Line&&d.type!==v.Section).length===0)return{x:r.x,y:r.y}}return{x:o.x+o.width+Xt,y:o.y}}findLeftPlace(t,e,n){const o=t.globalBaseProps;for(let s=0;s<20;s++){const r=o.clone();r.x=o.x-o.width-Xt;const i=s%2,a=Math.ceil(s/2);i?r.y-=a*(o.width+rn):r.y+=a*(o.width+rn);const c=M.getBoundsByBaseProps(r);if(n.nodeManager.searchNodesByRectNode(c).filter(d=>d.type!==v.Line&&d.type!==v.Section).length===0)return{x:r.x,y:r.y}}return{x:o.x-o.width-Xt,y:o.y}}}class Yu extends qe{constructor(){super(...arguments);p(this,"createWorker",new Za);p(this,"layoutHandler",new Vt)}enable(e,n){const o=n.detect(F.HoverConnectAnchor,e);return o?o.node.type===v.Shape:!1}isParentRoot(e,n,o){const s=e.parent;if(s===o.nodeManager.root)return!0;const r=e.getBounds(),i=e.globalPos,a=n.x-i.x,c=n.y-i.y,h={minX:r.minX+a,minY:r.minY+c,maxX:r.maxX+a,maxY:r.maxY+c},d=s.getBounds();return!(M.containRect(d,h)||M.overlapRect(d,h))}handle(e,n){const o=n.detect(F.HoverConnectAnchor,e),s=o.node,r=o.relative,i=this.createWorker.judgeQuickCreateMode(s,r,n);if(i){this.handleCreateLineAndLink(i,e,n);return}this.handleCreateNode(e,n)}handleCreateLine(e,n,o,s){const r=o.globalPos,i=this.createWorker.computeEndNodeRelative(e,n),a=e.baseProps,c=e.toGlobal({x:n.x*a.width,y:n.y*a.height}),h=this.isParentRoot(e,r,s),d=o.id,u=o.baseProps,g=o.toGlobal({x:i.x*u.width,y:i.y*u.height}),f={point:c,nodeConnect:{rect:D.rectNode2Rect(e.getBounds()),endType:M.computeNodeConnectEnd(n,e.baseProps.angle)}},y={point:g,nodeConnect:{rect:D.rectNode2Rect(o.getBounds()),endType:M.computeNodeConnectEnd(i,o.baseProps.angle)}},P=this.makeupLineProps(f,y,e.parent,h);P.push({type:I.Connect,start:{objectId:e.id,x:n.x,y:n.y},end:{objectId:d,x:i.x,y:i.y}});const b=s.idGenerator.genId(v.Line);return s.execAction(Le.create({id:b,zIndex:ve.genZIndex(s.nodeManager.root),type:v.Line,props:P,parentId:h?"":e.parent.id})),b}handleCreateLineAndLink(e,n,o){const s=o.detect(F.HoverConnectAnchor,n),r=s.node,i=s.relative;o.execAction(new W);const a=this.handleCreateLine(r,i,e,o);o.execAction(xe.create([a])),sn.blurText(o),o.execAction(new z)}handleCreateNode(e,n){const o=n.detect(F.HoverConnectAnchor,e),s=o.node,r=o.relative,i=this.createWorker.computePreviewNodePos(s,r,n),a=this.isParentRoot(s,i,n),c=this.makeupNodeProps(s,i,a),h=n.idGenerator.genId(v.Shape);n.execAction(new W),n.execAction(Le.create({id:h,zIndex:ve.genZIndex(n.nodeManager.root),type:v.Shape,props:c,parentId:a?"":s.parent.id}));const d=n.nodeManager.getNode(h);if(this.handleCreateLine(s,r,d,n),n.execAction(xe.create([h])),d.type===v.Shape&&d.shapeType===K.PureText){const u=d.renderText;n.execAction(ee.selection(h,u.headTextCursorPosition(),u.tailTextCursorPosition()))}else n.execAction(ee.focus(h));n.execAction(new z)}makeupNodeProps(e,n,o){const s=e.baseProps,r=e.shapeType;let i=n;o||(i=e.parent.globalTransform().inverseMatrix().crossPoint(i));const a=i.x,c=i.y,h=e.colorProps,d=e.borderProps,u=[{type:I.Base,x:a,y:c,width:s.width,height:s.height,angle:s.angle},tt.create({...h}),Ae.create({...d}),new Oe(r)];if(e.type===v.Shape&&e.shapeType===K.PureText){const g=e.textProps;u.push(g.clone());const f=e.paragraphProps;u.push(f.clone())}return u}makeupLineProps(e,n,o,s){let r=this.layoutHandler.layoutToPointsPro(e,n);if(!s){const c=o.globalTransform().inverseMatrix();r=r.map(h=>c.crossPoint(h))}const i=D.rectNode2Rect(M.getBoundsByPoints(r));return[je.create(r),ie.create({x:i.x,y:i.y,width:i.width,height:i.height}),lt.create({rArrow:it.Arrow}),new Oe(de.RoundPolyLine)]}}class Gu extends jt{constructor(){super(),this.registerUpHandler(new Yu)}}class Uu extends pn{constructor(){super([new Gu])}clickEnable(t,e){return!!e.detect(F.HoverConnectAnchor,t)}}class qa extends qe{constructor(){super(...arguments);p(this,"group",null)}enable(e,n){const o=[...n.getSelectNodes()];if(o.length!==1)return!1;const s=o[0];if(s.type!==v.Group)return!1;const r=s;return r.contains(e.globalPoint)?(this.group=r,!0):!1}handle(e,n){if(this.group){for(const o of this.group.children)if(o.contains(e.globalPoint)){n.execAction(new W),n.execAction(xe.create([o.id])),n.execAction(new z);return}}}}class _u extends qe{constructor(){super(...arguments);p(this,"res",null)}enable(e,n){const o=n.detect(F.Node,e);if(o){const s=o[0];if(n.auxiliaryManager.selectManager.include(s)){const r=s.toLocal(e.globalPoint);if(s instanceof vt&&s.renderText.contains(r))return this.res={node:s,relativePos:r},!0;if(s instanceof Ct)return this.res={node:s,relativePos:r},!0;if(s instanceof Un&&s.renderText.contains(r))return this.res={node:s,relativePos:r},!0}}return!1}handle(e,n){if(!this.res)return;const{node:o,relativePos:s}=this.res;if(o.isEmptyText()){const r=o.renderText.detect(s);if(n.execAction(new W),o instanceof Ct&&o.renderText.isEmptyText()){const{height:a}=o.renderText,c=o.baseProps,h=M.computePointByT(o,.5),d=h.x-.5*20,u=h.y-.5*a,g=new D(d,u,20,a);n.execAction(U.create(o.id,[{type:I.LineTextRect,x:g.x-c.x,y:g.y-c.y,width:g.width,height:g.height,point:{x:h.x-c.x,y:h.y-c.y}}]))}n.execAction(ee.focus(o.id,r)),n.execAction(new z);return}n.execAction(new W),n.execAction(ee.selection(o.id,Fe.head(),o.renderText.tailTextCursorPosition())),n.execAction(new z)}}const $u=new Set([v.Checkbox,v.CheckboxText]);class ju extends qe{constructor(){super(...arguments);p(this,"node",null);p(this,"checkboxWorker",new Ra)}enable(e,n){const o=n.detect(F.Node,e);if(!o)return!1;const s=o[0];return $u.has(s.type)&&s.checkboxContain(e.globalPoint)?(this.node=s,!0):!1}handle(e,n){this.node&&this.checkboxWorker.checkbox(this.node,e,n)}}class Vu extends jt{constructor(){super(),this.registerDownHandler(new qa),this.registerDownHandler(new _u),this.registerDownHandler(new ju)}}class Ku extends js{constructor(){super([new Vu])}}class Qu extends qe{constructor(){super(...arguments);p(this,"node",null)}enable(e,n){return!0}handle(e,n){if(n.getSelectNodes().size>0){const r=n.auxiliaryManager.selectManager.getSelectBounds();if(M.rectContains2(e.globalPoint,r)){const i={clientPoint:e.clientPoint,show:!0,hasFocus:n.getSelectNodes().size>0};n.slotManager.addSlotState(ze.ContextMenu,i);return}}const o=n.detect(F.Node,e);if(o&&o.length>0){const r=o[0];n.auxiliaryManager.selectManager.include(r)||(n.execAction(new W),n.execAction(xe.create([r.id])),n.execAction(new z))}else n.execAction(new W),n.execAction(xe.create([])),n.execAction(new z);const s={clientPoint:e.clientPoint,show:!0,hasFocus:n.getSelectNodes().size>0};n.slotManager.addSlotState(ze.ContextMenu,s)}}class Zu extends jt{constructor(){super(),this.registerUpHandler(new Qu)}}class qu extends pn{constructor(){super([new Zu])}canBeEnable(t,e){return t.originEvent.button===2}}class Ja extends ht{constructor(){super(...arguments);p(this,"lastPoint",null)}onStart(e,n){this.lastPoint=e.clientPoint,n.setCursor("grabbing")}onMove(e,n){if(!this.lastPoint)return;n.setCursor("grabbing");const o=e.clientPoint,s=o.x-this.lastPoint.x,r=o.y-this.lastPoint.y;n.renderManager.scroll(-s,-r),this.lastPoint=o}onUp(e,n){n.setCursor("grab")}}class Ju extends dt{constructor(){super([new Ja])}streamEnable(t,e){return t.originEvent.button===2}}class ep extends ht{constructor(){super(...arguments);p(this,"line");p(this,"bezierWorker",new zo);p(this,"startPoint");p(this,"endPoint");p(this,"leftPoints",[]);p(this,"rightPoints",[]);p(this,"lineTextWorker",new $n)}onStart(e,n){const{line:o,lPoint:s,rPoint:r,curve:i,index:a}=n.detect(F.CurveControlPoint,e);this.line=o,this.startPoint=s,this.endPoint=r;const{lP:c,rP:h,midPoint:d}=this.bezierWorker.splitCurve(i),u=JSON.parse(JSON.stringify(o.points));this.leftPoints=u.slice(0,a),this.rightPoints=u.slice(a+4);const f=.4*M.distance(this.startPoint,e.globalPoint),y=new m(this.startPoint.x+f,this.startPoint.y),P=i.p3,w=.4*M.distance(P,d),L=new m(P.x-w,P.y),B=[...this.leftPoints,s,y,c,d,h,L,r,...this.rightPoints];this.lineTextWorker.init(o),n.execAction(new W);const H=this.bezierWorker.computeCurvePointsForLine(o,n.nodeManager,B);n.execAction(U.create(this.line.id,[{type:I.Line,points:H}]))}onMove(e,n){this.onWork(e,n,!0)}onUp(e,n){this.onWork(e,n,!1),n.execAction(new z)}onWork(e,n,o){const s=e.globalPoint,i=.4*M.distance(this.startPoint,s),a=new m(this.startPoint.x+i,this.startPoint.y),c=this.endPoint,d=.4*M.distance(c,e.globalPoint),u=new m(c.x-d,c.y),{lP:g,rP:f,midPoint:y}=this.bezierWorker.computeCurveControlPoint(a,s,u),P=this.startPoint,b=this.endPoint,w=[...this.leftPoints,P,a,g,y,f,u,b,...this.rightPoints],L=this.bezierWorker.computeCurvePointsForLine(this.line,n.nodeManager,w);n.execAction(U.create(this.line.id,[{type:I.Line,points:L}],{streaming:o})),this.lineTextWorker.work(this.line,n,o)}}class tp extends dt{constructor(){super([new ep],[])}streamEnable(t,e){return!!e.detect(F.CurveControlPoint,t)}}class np extends ht{constructor(){super(...arguments);p(this,"line");p(this,"dragIndex");p(this,"bezierWorker",new zo);p(this,"lineTextWorker",new $n)}onStart(e,n){const{line:o,index:s}=n.detect(F.CurveEndPoint,e);this.line=o,this.dragIndex=s,n.execAction(new W),this.lineTextWorker.init(o)}onMove(e,n){this.onWork(e,n,!0)}onUp(e,n){this.onWork(e,n,!1),n.execAction(new z)}onWork(e,n,o){const s=this.line,r=[...s.points];r.splice(this.dragIndex,1,e.globalPoint);const i=this.bezierWorker.computeCurvePointsForLine(s,n.nodeManager,r);n.execAction(U.create(this.line.id,[{type:I.Line,points:i}],{streaming:o})),this.lineTextWorker.work(s,n,o)}}class op extends dt{constructor(){super([new np],[])}streamEnable(t,e){return!!e.detect(F.CurveEndPoint,t)}}class ar{init(t){}dealWithPoint(t,e){t.x<e.minX&&(t.x=e.minX),t.y<e.minY&&(t.y=e.minY),t.x>e.maxX&&(t.x=e.maxX),t.y>e.maxY&&(t.y=e.maxY)}}class sp extends ar{constructor(){super(...arguments);p(this,"lineShapes",[])}init(e){const n=[],o=e.globalLinePoints;for(let s=0;s<o.length-1;s++){const r=o[s],i=o[s+1],a=q.line(r,i),c=M.judgeHorizon(r,i);n.push({isHorizon:c,shapeInfo:a})}this.lineShapes=n}enable(e){return e.isPolyLine()}handle(e,n){const o=e.getBounds(),{minX:s,minY:r,maxX:i,maxY:a}=o,c=this.lineShapes,h={x:n.x,y:n.y};this.dealWithPoint(h,o);const d=10,u=q.line({x:s-d,y:h.y},{x:i+d,y:h.y}),g=q.line({x:h.x,y:r-d},{x:h.x,y:a+d}),f=[];for(const b of c)if(b.isHorizon){const w=Y.intersect(b.shapeInfo,g);if(w.points.length>0){const L=w.points[0],B=M.distance(L,h);f.push({point:L,distance:B})}}else{const w=Y.intersect(b.shapeInfo,u);if(w.points.length>0){const L=w.points[0],B=M.distance(L,h);f.push({point:L,distance:B})}}if(f.length===0)return console.warn("探测结果出现问题,兜底容错"),null;const y=Math.min(...f.map(b=>b.distance));return f.find(b=>b.distance-y<.1)??null}dealWithPoint(e,n){e.x<n.minX&&(e.x=n.minX),e.y<n.minY&&(e.y=n.minY),e.x>n.maxX&&(e.x=n.maxX),e.y>n.maxY&&(e.y=n.maxY)}}class rp extends ar{constructor(){super(...arguments);p(this,"lineShape")}init(e){const n=e.globalLinePoints,o=n[0],s=n[n.length-1],r=q.line({x:o.x,y:o.y},{x:s.x,y:s.y});this.lineShape=r}enable(e){return e.shapeType===de.Line}handle(e,n){const o=e.getBounds(),{minX:s,minY:r,maxX:i,maxY:a}=o,c={x:n.x,y:n.y};this.dealWithPoint(c,o);const h=10,d=q.line({x:s-h,y:c.y},{x:i+h,y:c.y}),u=q.line({x:c.x,y:r-h},{x:c.x,y:a+h}),g=[];if(this.intersectLine(d,c,g),this.intersectLine(u,c,g),g.length===0)return console.warn("探测结果出现问题,兜底容错"),null;const f=Math.min(...g.map(P=>P.distance));return g.find(P=>P.distance-f<.1)??null}intersectLine(e,n,o){const s=Y.intersect(this.lineShape,e);if(s.points.length>0){const r=s.points[0],i=M.distance(r,n);o.push({point:r,distance:i})}}}class ip extends ar{constructor(){super(...arguments);p(this,"lineShapes",[])}init(e){const n=M.computeBezierCurves(e),o=[];for(const s of n){const r=q.cubicBezier(s.p0,s.p1,s.p2,s.p3);o.push(r)}this.lineShapes=o}enable(e){return e.shapeType===de.Curve}handle(e,n){const o=e.getBounds(),{minX:s,minY:r,maxX:i,maxY:a}=o,c={x:n.x,y:n.y};this.dealWithPoint(c,o);const h=10,d=q.line({x:s-h,y:c.y},{x:i+h,y:c.y}),u=q.line({x:c.x,y:r-h},{x:c.x,y:a+h}),g=[];for(const P of this.lineShapes)this.intersectLine(P,d,c,g),this.intersectLine(P,u,c,g);if(g.length===0)return console.warn("探测结果出现问题,兜底容错"),null;const f=Math.min(...g.map(P=>P.distance));return g.find(P=>P.distance-f<.1)??null}intersectLine(e,n,o,s){const r=Y.intersect(e,n);if(r.points.length>0){const i=r.points[0],a=M.distance(i,o);s.push({point:i,distance:a})}}}class ap extends ht{constructor(){super(...arguments);p(this,"line");p(this,"intersectHandlers",[new sp,new ip,new rp]);p(this,"currentHandler",null)}onStart(e,n){const{line:o}=n.detect(F.DragLineText,e);this.line=o,this.selectHandler(o),n.execAction(new W)}onMove(e,n){this.onWork(e,n,!0)}onUp(e,n){this.onWork(e,n,!1),n.execAction(new z)}onWork(e,n,o){if(!this.currentHandler)return;const s=e.globalPoint,r=this.currentHandler.handle(this.line,s);if(!r)return;const{width:i,height:a}=this.line.lineTextRect,c=this.line.baseProps,h=r.point,d=h.x-.5*i-c.x,u=h.y-.5*a-c.y;n.execAction(U.create(this.line.id,[{type:I.LineTextRect,x:d,y:u,point:{x:h.x-c.x,y:h.y-c.y}}],{streaming:o}))}selectHandler(e){for(const n of this.intersectHandlers)if(n.enable(e)){n.init(e),this.currentHandler=n;return}}}class cp extends dt{constructor(){super([new ap])}streamEnable(t,e){return!!e.detect(F.DragLineText,t)}}class lp extends ht{constructor(){super(...arguments);p(this,"originPos");p(this,"originNodePos");p(this,"dragNode");p(this,"originDragNodes",[]);p(this,"originBaseProps");p(this,"rowNodes",[]);p(this,"rowIds",[]);p(this,"rowIndex",0);p(this,"targetRowIndex",0);p(this,"isInsertNewRow",!1);p(this,"originIndex",0);p(this,"insertIndex",0)}computeRowNodes(e){const o=this.dragNode.parent.slideProps.children;this.rowNodes=[],this.rowIds=[];let s=-1,r=-1;for(let i=0;i<o.length;i++){const a=o[i],c=[];for(const h of a.ids){const d=e.nodeManager.getNode(h);d&&(c.push(d),d.id===this.dragNode.id&&(s=i,r=c.length-1))}this.rowNodes.push(c.map(h=>h.baseProps.clone())),this.rowIds.push(c.map(h=>h.id))}if(s===-1){this.rowIndex=0,this.originIndex=0;return}this.rowIndex=s,this.originIndex=r}onStart(e,n){const s=[...n.getSelectNodes()][0],r=s.pos;this.dragNode=s,this.originNodePos=new m(r.x,r.y),this.originPos=e.globalPoint,this.originBaseProps=s.globalBaseProps.clone();const i=new Set;M.getAllChildren(s,i);const a=M.sortGraphics([s,...i]);this.originDragNodes=a,this.computeRowNodes(n),n.execAction(new W)}onMove(e,n){const o=e.globalPoint,s=this.originPos,r=o.x-s.x,i=o.y-s.y;n.addOrUpdate(N.HoverSlidePlaceHolder,{baseProps:this.originBaseProps}),n.addOrUpdate(N.HoverFocusCopy,{nodes:this.originDragNodes});const a=this.originNodePos.x+r,c=this.originNodePos.y+i,h=this.dragNode.parent.globalPos,d=o.x-h.x,u=o.y-h.y;this.determineTargetRow(u),this.showInsertIndicator(d,h,n),n.execAction(U.create(this.dragNode.id,[{type:I.Base,x:a,y:c}],{streaming:!0}))}relayoutRow(e,n,o,s,r){let i=n;for(const a of e){const c=s.nodeManager.getNode(a);c&&(r.push({id:a,props:[{type:I.Base,x:i,y:o}]}),i+=c.baseProps.width+nt)}}handleInsertNewRow(e,n){const o=[],s=[...this.rowIds[this.rowIndex]];s.splice(this.originIndex,1);const r=this.targetRowIndex,i=r===0,a=r===this.rowNodes.length;s.length===0?(e.splice(this.rowIndex,1),this.rowIndex<this.targetRowIndex&&this.targetRowIndex--):e[this.rowIndex].ids=s,e.splice(this.targetRowIndex,0,{ids:[this.dragNode.id]});const c=this.dragNode.baseProps;let h,d;if(i){h=this.rowNodes[0][0].x,d=this.rowNodes[0][0].y;const u=c.height+xt;for(let g=0;g<this.rowNodes.length;g++){const f=this.rowIds[g].filter(P=>P!==this.dragNode.id),y=this.rowNodes[g][0].y+u;this.relayoutRow(f,this.rowNodes[g][0].x,y,n,o)}}else if(a){const u=this.rowNodes.length-1,g=this.rowNodes[u];h=g[0].x,d=g[0].y+g[0].height+xt,s.length>0&&this.relayoutRow(s,this.rowNodes[this.rowIndex][0].x,this.rowNodes[this.rowIndex][0].y,n,o)}else{const u=this.rowNodes[r-1];this.rowNodes[r],h=u[0].x,d=u[0].y+u[0].height+xt;const g=c.height+xt;for(let f=0;f<this.rowNodes.length;f++){const y=this.rowIds[f].filter(b=>b!==this.dragNode.id);if(y.length===0)continue;let P;f<r?P=this.rowNodes[f][0].y:P=this.rowNodes[f][0].y+g,this.relayoutRow(y,this.rowNodes[f][0].x,P,n,o)}}return o.push({id:this.dragNode.id,props:[{type:I.Base,x:h,y:d}]}),o}determineTargetRow(e){var a,c,h;if(this.isInsertNewRow=!1,this.rowNodes.length===0){this.targetRowIndex=0;return}const n=((a=this.rowNodes[0][0])==null?void 0:a.y)??0;if(e<n){this.isInsertNewRow=!0,this.targetRowIndex=0,this.insertIndex=0;return}const o=this.rowNodes.length-1,s=this.rowNodes[o],r=((c=s[0])==null?void 0:c.y)??0,i=((h=s[0])==null?void 0:h.height)??0;if(e>r+i){this.isInsertNewRow=!0,this.targetRowIndex=this.rowNodes.length,this.insertIndex=0;return}for(let d=0;d<this.rowNodes.length;d++){const u=this.rowNodes[d];if(u.length===0)continue;const g=u[0].y,f=u[0].height;if(e>=g&&e<=g+f){this.targetRowIndex=d;return}if(d<this.rowNodes.length-1){const y=this.rowNodes[d+1];if(y.length===0)continue;const P=y[0].y,b=g+f,w=P;if(e>b&&e<w){this.isInsertNewRow=!0,this.targetRowIndex=d+1,this.insertIndex=0;return}}}this.targetRowIndex=this.rowIndex}showInsertIndicator(e,n,o){this.isInsertNewRow?this.showNewRowIndicator(n,o):this.showExistingRowIndicator(e,n,o)}showNewRowIndicator(e,n){const o=this.targetRowIndex===0,s=this.targetRowIndex===this.rowNodes.length;let r,i;if(o)r=this.rowNodes[0],i=r[0].y+e.y-.5*xt;else if(s)r=this.rowNodes[this.rowNodes.length-1],i=r[0].y+r[0].height+e.y+.5*xt;else{const u=this.rowNodes[this.targetRowIndex-1],g=this.rowNodes[this.targetRowIndex],f=u[u.length-1].x+u[u.length-1].width-u[0].x,y=g[g.length-1].x+g[g.length-1].width-g[0].x;r=f>=y?u:g;const P=u[0].y+u[0].height,b=g[0].y;i=(P+b)/2+e.y}const a=r[0],c=r[r.length-1],h=a.x+e.x,d=c.x+c.width+e.x;n.addOrUpdate(N.HoverInsertHorizonSlide,{x0:h,x1:d,y:i})}showExistingRowIndicator(e,n,o){const s=this.rowNodes[this.targetRowIndex]||[];for(let r=0;r<s.length;r++){const i=s[r],a=i.x+.5*i.width;if(e<a){this.insertIndex=r,o.addOrUpdate(N.HoverInsertSlide,{x:i.x-.5*nt+n.x,y0:i.y+n.y,y1:i.y+i.height+n.y});return}if(r===s.length-1){this.insertIndex=s.length,o.addOrUpdate(N.HoverInsertSlide,{x:i.x+i.width+.5*nt+n.x,y0:i.y+n.y,y1:i.y+i.height+n.y});return}}}handleSameRowDrag(e,n){const o=[],s=[...this.rowIds[this.rowIndex]];return this.insertIndex<this.originIndex?(s.splice(this.originIndex,1),s.splice(this.insertIndex,0,this.dragNode.id)):(s.splice(this.insertIndex,0,this.dragNode.id),s.splice(this.originIndex,1)),e[this.rowIndex].ids=s,this.relayoutRow(s,this.rowNodes[this.rowIndex][0].x,this.rowNodes[this.rowIndex][0].y,n,o),o}handleCrossRowDrag(e,n){const o=[],s=[...this.rowIds[this.rowIndex]],r=[...this.rowIds[this.targetRowIndex]];if(s.splice(this.originIndex,1),e[this.rowIndex].ids=s,r.splice(this.insertIndex,0,this.dragNode.id),e[this.targetRowIndex].ids=r,s.length===0){const a=this.rowNodes[this.rowIndex][0].height+xt;for(let c=0;c<this.rowNodes.length;c++){if(c===this.rowIndex)continue;const h=c===this.targetRowIndex?r:this.rowIds[c],d=c>this.rowIndex?this.rowNodes[c][0].y-a:this.rowNodes[c][0].y;this.relayoutRow(h,this.rowNodes[c][0].x,d,n,o)}}else this.relayoutRow(s,this.rowNodes[this.rowIndex][0].x,this.rowNodes[this.rowIndex][0].y,n,o),this.relayoutRow(r,this.rowNodes[this.targetRowIndex][0].x,this.rowNodes[this.targetRowIndex][0].y,n,o);return o}onUp(e,n){const o=!this.isInsertNewRow&&this.targetRowIndex===this.rowIndex,s=o&&(this.insertIndex===this.originIndex||this.insertIndex===this.originIndex+1),r=this.rowIds[this.rowIndex].length===1,i=this.isInsertNewRow&&r&&(this.targetRowIndex===this.rowIndex||this.targetRowIndex===this.rowIndex+1);if(s||i){n.execAction(U.create(this.dragNode.id,[{type:I.Base,x:this.originNodePos.x,y:this.originNodePos.y}],{streaming:!1})),n.execAction(new z);return}const c=this.dragNode.parent.slideProps.children.map(f=>({ids:[...f.ids]}));let h;this.isInsertNewRow?h=this.handleInsertNewRow(c,n):o?h=this.handleSameRowDrag(c,n):h=this.handleCrossRowDrag(c,n);const d=c.filter(f=>f.ids.length>0);h.unshift({id:this.dragNode.parent.id,props:[{type:I.Slide,children:d}]}),n.execAction(new U({infos:h}));const u=this.dragNode.parent,g=[];for(const f of d)for(const y of f.ids){const P=n.nodeManager.getNode(y);P&&g.push(P.baseProps)}if(g.length>0){const f=M.getBoundsByBasePropsList(g),y=f.maxX-f.minX,P=f.maxY-f.minY;n.execAction(U.create(u.id,[{type:I.Base,width:y+2*nt,height:P+2*xt}]))}n.execAction(new z)}}class hp extends dt{constructor(){super([new lp])}streamEnable(t,e){var i;const o=[...e.auxiliaryManager.selectManager.getSelectNodes()];if(o.length!==1)return!1;const s=o[0];return((i=s.parent)==null?void 0:i.type)!==v.SlideContainer?!1:M.rectContains2(t.globalPoint,s.getRectNode())}}class ec extends gn{constructor(){super([new Ju,new Uu,new Ou,new Hu,new tp,new Au,new op,new cp,new aa,new qs,new pa,new ja,new Qa,new hp,new Ta,new Ku,new qu,new Ha,new _a])}canBeEnable(t,e){return!0}}class tc extends Ke{onDetect(t,e){const n=e.getSelectNodes();if(n.size!==1)return!1;const o=[...n][0];if(o.type!==v.Shape)return!1;const s=o;if(s.isEmptyText())return!1;const r=s.getTextContentRect();if(s.renderText.height<r.height)return!1;const i=e.gmlRender.getScale(),a=s.toLocal(t.globalPoint),{width:c,height:h}=s.baseProps,d=new D(.5*c-.5*21/i,h-.5*12/i,21/i,12/i);return M.rectContains(a,d)?(this.result={node:s,realHeight:s.drawer.fullTextNodeHeight(s)},!0):!1}}class nc extends Ke{onDetect(t,e){const n=e.auxiliaryManager.selectManager.selectNodes;if(n.size!==1)return!1;const o=[...n][0];if(o.type!==v.Line)return!1;const s=o,i=8/e.gmlRender.getScale(),a=s.points,c=a[0],h=a[a.length-1],d=s.toLocal(t.globalPoint);let u=M.circleContains(d,c,i);return u?(this.result={detectPoint:c,isStart:!0,line:s},!0):(u=M.circleContains(d,h,i),u?(this.result={detectPoint:h,isStart:!1,line:s},!0):!1)}}const dp=12;class up extends Ke{onDetect(t,e){const n=e.detect(F.HoverConnectAnchor,t);if(n){const u=Ze.getNodePos(n.node,n.relative);return this.result={node:n.node,point:u,relativePos:n.relative},!0}const o=e.detect(F.HoverNodeAnchor,t);if(o){const u=Ze.getNodePos(o.node,o.ratio);return this.result={node:o.node,point:u,relativePos:o.ratio},!0}const s=e.detect(F.BufferNode,t);if(!s)return!1;const r=s.filter(u=>u.canBeConnected());if(r.length===0)return!1;const i=r[0];if(!i.canBeConnected())return!1;const a=e.renderManager.getScale(),{width:c,height:h}=i.baseProps,d=i.borderContains(t.globalPoint,dp/a);return d?(this.result={node:i,point:i.toGlobal(d),relativePos:new m(d.x/c,d.y/h)},!0):!1}}class Qo extends ht{constructor(){super(...arguments);p(this,"startPos",new m);p(this,"target",null);p(this,"viewBounds");p(this,"alignWorker",new un)}nodeType(){return v.Shape}autoFocus(){return!0}onStart(e,n){n.previewManager.resetPreviewNode(n),n.alignPoint?(this.startPos=n.alignPoint,n.alignPoint=null):this.startPos=e.globalPoint;const o=n.detect(F.HoverOnContainer,e);let s=n.nodeManager.root,r=new m(this.startPos.x,this.startPos.y);o&&(r=o.toLocal(this.startPos),s=o);const i=this.nodeType(),a=n.idGenerator.genId(i),c=this.makeupDefaultProps(n,r);console.log("njx debug,props:",c);const h={id:a,type:i,zIndex:ve.genZIndex(s),parentId:s.id,props:c};n.actionManager.execAction(new W);const d=Le.create(h);n.actionManager.execAction(d),this.target=n.nodeManager.nodeMap.get(a);const u=D.baseProps2Rect(this.target.baseProps);n.addOrUpdate(N.CreateRectBound,{rect:u,transform:this.target.globalTransform()}),n.auxiliaryManager.removeAlignGraphics(),this.viewBounds=n.gmlRender.getViewPortBounds()}onMove(e,n){if(!this.target)return;n.auxiliaryManager.removeAlignGraphics();const o=this.target.baseProps.clone(),s=new Set([this.target]),r=!M.pressMeta(e),i=this.alignWorker.alignLineEndAndDrawAlignLines(e,n,s,r);this.computeRectBounds(i,o);const a=n.gmlRender.getScale(),c=D.baseProps2Rect(o),h=new Set(n.getSelectNodes());h.add(this.target);const d=this.alignWorker.alignStretch(n,c,h,_e.both,this.viewBounds,Us/a,Gs/a);this.drawAlignLine(c,d,n);const u=new m(c.x,c.y),g=this.target.parent.toLocal(u),f={type:I.Base,x:g.x,y:g.y,width:c.width,height:c.height},y=U.create(this.target.id,[f],{streaming:!0});n.actionManager.execAction(y);const P=D.baseProps2Rect(this.target.baseProps);n.addOrUpdate(N.CreateRectBound,{rect:P,transform:this.target.globalTransform()})}onUp(e,n){if(!this.target)return;const o=n.renderManager.getScale(),s=this.target.baseProps,r={type:I.Base,x:s.x,y:s.y,width:s.width,height:s.height},{width:i,height:a}=this.computeMiniSize(),c=this.computeDefaultSize(n);let h=!1;M.distance(this.startPos,e.globalPoint)<Math.max(9,9/o)?(r.width=c.width,r.height=c.height,h=!0):(r.width<i||r.height<a)&&(r.width=c.width,r.height=c.height);const d=[r];this.dealWithUpUpdateProps(h,d);const u=U.create(this.target.id,d);n.actionManager.execAction(u),n.actionManager.execAction(xe.create([this.target.id])),this.autoFocus()&&n.actionManager.execAction(ee.focus(this.target.id)),n.actionManager.execAction(new z),this.target=null,n.toolManager.resetTool(),n.removeAuxGraphic(N.CreateRectBound),n.auxiliaryManager.removeAlignGraphics(),n.setCursor("default")}dealWithUpUpdateProps(e,n){}computeRectBounds(e,n,o=10,s=10){if(!this.target)return;const r=Math.max(Math.abs(e.x-this.startPos.x),o),i=Math.max(Math.abs(e.y-this.startPos.y),s);n.width=r,n.height=i,e.x>=this.startPos.x&&e.y>=this.startPos.y?(n.x=this.startPos.x,n.y=this.startPos.y):e.x>this.startPos.x&&e.y<this.startPos.y?(n.x=this.startPos.x,n.y=this.startPos.y-i):e.x<this.startPos.x&&e.y>this.startPos.y?(n.x=this.startPos.x-r,n.y=this.startPos.y):e.x<=this.startPos.x&&e.y<=this.startPos.y?(n.x=this.startPos.x-r,n.y=this.startPos.y-i):(n.x=this.startPos.x-r,n.y=this.startPos.y-i)}drawAlignLine(e,n,o){const s=this.target,r=s.baseProps,{width:i,height:a}=n;if(i){e.width+=i.dt;const c={transform:s.transform.clone(),line:{start:new m(0,r.height),end:new m(r.width,r.height)}};i.lines.push(c)}if(a){e.height+=a.dt;const c={transform:s.transform.clone(),line:{start:new m(r.width,0),end:new m(r.width,r.height)}};a.lines.push(c)}o.addOrUpdate(N.AlignStretchLine,{alignInfo:n})}}class oc extends Qo{constructor(){super(...arguments);p(this,"startPos",new m);p(this,"target",null)}computeDefaultSize(){return{width:100,height:100}}computeMiniSize(){return{height:5,width:5}}makeupDefaultProps(e,n){return e.createWorker.makeupDefaultProps(v.Shape,e,e.toolManager.shapeType,n)}dealWithUpUpdateProps(e,n){e||n.push({type:I.Text,sizeMode:We.fix})}}class sc extends kn{constructor(){super([new oc])}streamEnable(t,e){return e.toolManager.currentTool==ye.SHAPE}}class rc extends Qo{computeDefaultSize(){return{height:0,width:0}}computeMiniSize(){return{height:0,width:0}}makeupDefaultProps(t,e){return[ie.create({x:e.x,y:e.y}),Ge.create({type:I.Text,fontSize:16,richText:"<root><p></p></root>",horizonAlign:at.Top,verticalAlign:at.Top}),new Oe(K.PureText)]}}class ic extends dt{constructor(){super([new rc])}streamEnable(t,e){return e.toolManager.currentTool==ye.TEXT}}class ac extends Ot{constructor(t){super(t)}canBeEnable(t,e){return!0}canBeExit(t,e){return!0}}class pp extends qe{constructor(){super(...arguments);p(this,"res",null)}enable(e,n){return n.toolManager.currentTool===ye.TEXT}handle(e,n){const o=n.idGenerator.genId(v.Shape),s=n.detect(F.HoverOnContainer,e);let r=n.nodeManager.root,i=e.globalPoint.clone();s&&(i=s.toLocal(i),r=s);const a=this.makeupDefaultProps(i),c={id:o,type:v.Shape,zIndex:ve.genZIndex(n.nodeManager.root),parentId:r.id,props:a};n.actionManager.execAction(new W);const h=Le.create(c);n.actionManager.execAction(h),n.actionManager.execAction(xe.create([o])),n.actionManager.execAction(ee.focus(o)),n.actionManager.execAction(new z),n.toolManager.resetTool()}makeupDefaultProps(e){return[ie.create({x:e.x,y:e.y,height:22,width:64}),Ge.create({type:I.Text,fontSize:16,richText:"<root><p></p></root>",horizonAlign:at.Top,verticalAlign:at.Top,sizeMode:We.autoWidth}),new Oe(K.PureText)]}}class gp extends qe{constructor(){super(...arguments);p(this,"res",null)}enable(e,n){const o=n.detect(F.Node,e);if(o){const s=o[0],r=s.toLocal(e.globalPoint);if(s instanceof vt&&s.renderText.contains(r))return this.res={node:s,relativePos:r},!0;if(s instanceof Ct)return this.res={node:s,relativePos:r},!0}return!1}handle(e,n){if(!this.res)return;n.toolManager.resetTool();const{node:o,relativePos:s}=this.res,r=o.renderText.detect(s);n.execAction(new W),n.execAction(xe.create([o.id])),n.execAction(ee.focus(o.id,r)),n.execAction(new z)}}class fp extends jt{constructor(){super(),this.registerUpHandler(new pp),this.registerUpHandler(new gp)}}class yp extends pn{constructor(){super([new fp])}clickEnable(t,e){return e.toolManager.currentTool===ye.TEXT}}class xp extends Qo{constructor(){super(...arguments);p(this,"startPos",new m);p(this,"target",null)}computeDefaultSize(e){const n=e.toolManager.shapeType,o=Uo[n];return{width:o.width,height:o.height}}computeMiniSize(){return{height:5,width:5}}nodeType(){return v.Section}autoFocus(){return!1}makeupDefaultProps(e,n){return e.createWorker.makeupDefaultProps(v.Section,e,e.toolManager.shapeType,n)}}class wp extends kn{constructor(){super([new xp])}streamEnable(t,e){return e.toolManager.currentTool==ye.SECTION}}class cc extends _o{constructor(){super(...arguments);p(this,"handlers",[new Ya])}}class lc{constructor(){p(this,"allowEventTypeSet",new Set([be.pointermove]));p(this,"alignWorker",new un)}process(t,e){const n=e.previewManager.createManager;if(!n.previewGraphics)return;const o=e.toolManager.grab;e.auxiliaryManager.removeAlignGraphics();const{rectNode:s,delta:r}=this.computeMoveRect(n.previewGraphics,t.globalPoint,o),i=this.alignWorker.alignMove(s,e.getSelectNodes(),e,!0),a=this.alignWorker.drawAlignLines(i,e),c=new m(s.minX+a.x,s.minY+a.y);e.alignPoint=c,e.previewManager.updatePos(c),e.addOrUpdate(N.PreviewGraphics,{previewNodes:[n.previewGraphics]})}computeMoveRect(t,e,n){const o=t.getBounds(),s=D.rectNode2Rect(o),r=n?s.x+.5*s.width:s.x,i=n?s.y+.5*s.height:s.y,a=new m(e.x-r,e.y-i);return o.minX+=a.x,o.maxX+=a.x,o.minY+=a.y,o.maxY+=a.y,{rectNode:o,delta:a}}}class Bn{handle(t,e,n){this.makeupAddNodeInfo(t,e,n).then(o=>{const s=o.id;t.actionManager.execAction(new W);const r=Le.create(o);t.actionManager.execAction(r),t.actionManager.execAction(xe.create([s])),this.autoFocus()&&t.actionManager.execAction(ee.focus(s)),t.actionManager.execAction(new z),t.toolManager.resetTool(),t.previewManager.resetPreviewNode(t),t.auxiliaryManager.removeAlignGraphics()})}detectParentContainer(t,e){const n=t.detect(F.HoverOnContainer,e);let o=t.nodeManager.root;return n&&(o=n),o}}class mp extends Bn{enable(t){return t===ye.SHAPE}async makeupAddNodeInfo(t,e,n){const o=t.toolManager.shapeType,s=this.detectParentContainer(t,n),r=t.createWorker.makeupDefaultProps(v.Shape,t,o,e,s);return{id:t.idGenerator.genId(v.Shape),type:v.Shape,zIndex:ve.genZIndex(s),parentId:s.id,props:r}}autoFocus(){return!0}}class Pp extends Bn{enable(t){return t===ye.SECTION}async makeupAddNodeInfo(t,e,n){const o=this.detectParentContainer(t,n),s=t.toolManager.shapeType,r=t.createWorker.makeupDefaultProps(v.Section,t,s,e,o);return{id:t.idGenerator.genId(v.Section),type:v.Section,zIndex:ve.genZIndex(o),parentId:o.id,props:r}}autoFocus(){return!1}}const bp="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Zo=(l=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(l|=0));for(;l--;)t+=bp[e[l]&63];return t};class cr{async addSvgNodeBySvgCode(t,e,n,o=n.nodeManager.root){const s=n.docState.docId,r=Zo(10),i=`${s}/${r}`,a=await n.resourceManager.uploadSvgString(i,t),c=this.computeAddSvgNode(t,a,e,n,o);return{url:a,addNodeInfo:c}}computeAddSvgNode(t,e,n,o,s=o.nodeManager.root){const r=an.trimSvgCode(t),i=[{type:I.Base,x:n.x,y:n.y,width:r.width,height:r.height},{type:I.Svg,url:e},{type:I.Border,dashType:et.None}];return{id:o.idGenerator.genId(v.SVG),type:v.SVG,zIndex:ve.genZIndex(s),parentId:s.id,props:i}}}class Mp extends Bn{constructor(){super(...arguments);p(this,"svgWorker",new cr)}autoFocus(){return!1}enable(e){return e===ye.Resource}async makeupAddNodeInfo(e,n,o){const s=this.detectParentContainer(e,o),r=s.toLocal(n),i=e.previewManager.previewResourceManager.previewSvgCode;i===""&&console.error("出现错误,svg code为空");const{addNodeInfo:a}=await this.svgWorker.addSvgNodeBySvgCode(i,r,e,s);return a}}class Sp extends Bn{autoFocus(){return!1}enable(t,e){return t===ye.Widget&&e===_n.Checkbox}async makeupAddNodeInfo(t,e,n){const o=this.detectParentContainer(t,n),s=t.createWorker.makeupDefaultProps(v.Checkbox,t,0,e,o);return{id:t.idGenerator.genId(v.Checkbox),type:v.Checkbox,zIndex:ve.genZIndex(o),parentId:o.id,props:s}}}class vp extends Bn{autoFocus(){return!1}enable(t,e){return t===ye.Widget&&e===_n.CheckboxText}async makeupAddNodeInfo(t,e,n){const o=this.detectParentContainer(t,n),s=t.createWorker.makeupDefaultProps(v.CheckboxText,t,0,e,o);return{id:t.idGenerator.genId(v.CheckboxText),type:v.CheckboxText,zIndex:ve.genZIndex(o),parentId:o.id,props:s}}}class Ip extends Bn{enable(t){return t===ye.LINE}async makeupAddNodeInfo(t,e,n){const o=t.toolManager.shapeType,s=this.detectParentContainer(t,n),r=t.createWorker.makeupDefaultProps(v.Line,t,o,e,s);return{id:t.idGenerator.genId(v.Line),type:v.Line,zIndex:ve.genZIndex(s),parentId:s.id,props:r}}autoFocus(){return!1}}class Tp extends Bn{autoFocus(){return!1}enable(t,e){return t===ye.SlideContainer}async makeupAddNodeInfo(t,e,n){const o=this.detectParentContainer(t,n),s=t.createWorker.makeupDefaultProps(v.SlideContainer,t,0,e,o);return{id:t.idGenerator.genId(v.SlideContainer),type:v.SlideContainer,zIndex:ve.genZIndex(o),parentId:o.id,props:s}}}class hc{constructor(){p(this,"allowEventTypeSet",new Set([be.pointerup]));p(this,"startPos",new m);p(this,"handlers",[new Mp,new mp,new Pp,new Ip,new Sp,new vp,new Tp])}process(t,e){e.toolManager.grab&&(e.alignPoint?(this.startPos=e.alignPoint,e.alignPoint=null):this.startPos=t.globalPoint,this.handleCreateUp(this.startPos,e,t))}handleCreateUp(t,e,n){for(const o of this.handlers)if(o.enable(e.toolManager.currentTool,e.toolManager.shapeType)){o.handle(e,t,n);return}}}const Lp=new Set([ye.SHAPE,ye.TEXT,ye.SECTION,ye.Resource,ye.Widget,ye.SlideContainer]);class Cp extends gn{constructor(){super([new yp,new wp,new sc,new ic,new ac([new cc,new lc,new hc])])}canBeEnable(t,e){return Lp.has(e.toolManager.currentTool)}}const qo=12;class Ap extends Ke{onDetect(t,e){const n=t.globalPoint,o=e.nodeManager.searchNodes(n.x-qo,n.y-qo,n.x+qo,n.y+qo);if(o.length===0)return this.result=null,!1;const s=M.sortGraphics(o);return s.reverse(),this.result=s,!0}}class kp extends Ke{onDetect(t,e){const n=e.detect(F.BufferNode,t);if(!n)return!1;const o=n[0];return e.auxiliaryManager.selectManager.include(o)?!1:(this.result=o,!0)}}const Np=12;class Bp extends Ke{onDetect(t,e){const n=e.detect(F.BufferNode,t);if(!n)return!1;const o=n.filter(u=>u.canBeConnected());if(o.length===0)return!1;const s=o[0];if(!s.canBeConnected()||e.auxiliaryManager.selectManager.include(s))return!1;const r=e.renderManager.getScale(),i=Np/r,{width:a,height:c}=s.baseProps,h=s.toLocal(t.globalPoint),d=s.getConnectAnchor();for(const u of d){const g=new m(u.x*a,u.y*c);if(M.circleContains(h,g,i))return this.result={node:s,ratio:u,localPoint:g},!0}return!1}}class dc extends Ke{onDetect(t,e){const n=e.auxiliaryManager.selectManager.selectNodes;if(n.size!==1)return!1;const o=[...n][0];if(o.type!==v.Line)return!1;const s=o;if(!s.isPolyLine())return!1;const r=e.gmlRender.getScale(),i=s.points;for(let a=0;a<i.length-1;a++){const c=i[a],h=i[a+1];if(M.distance(c,h)<(A+6)/r)continue;const u=M.judgeHorizon(c,h),g=.5*(c.x+h.x),f=.5*(c.y+h.y);let y;if(u){const w=new m(g-8/r,f);y=new D(w.x,w.y-4/r,16/r,8/r)}else{const w=new m(g,f-8/r);y=new D(w.x-4/r,w.y,8/r,16/r)}const P=s.toLocal(t.globalPoint);if(M.rectContains(P,y))return this.result={isHorizon:u,line:s,point:new m(g,f),lIndex:a,rIndex:a+1},!0}return!1}}const Rp=[new m(.5,0),new m(1,.5),new m(.5,1),new m(0,.5)];class Ep extends Ke{onDetect(t,e){const n=e.getSelectNodes();if(n.size!==1)return!1;const o=[...n][0];if(!o.canQuickCreate())return!1;const s=e.renderManager.getScale(),r=M.computeNodeConnectAnchor(o,s),i=Ss/s;for(let a=0;a<r.length;a++){const c=r[a],h=o.toLocal(t.globalPoint);let d=Rp[a];if(M.circleContains(h,c,i))return o.type===v.Shape&&(d=o.drawer.getConnectAnchor()[a]),this.result={node:o,localPoint:c,globalPoint:o.toGlobal(c),relative:d},!0}return!1}}const Hp=new Set([v.Checkbox,v.Group,v.CheckboxText,v.Section,v.Line]),ws=class ws extends Ke{onDetect(t,e){const n=$t.flattenNodes([...e.getSelectNodes()]);if(n.length===0)return!1;const o=e.auxiliaryManager.selectManager.getSelectBounds();if(M.rectContains2(t.globalPoint,o)||e.detect(F.Stretch,t))return!1;const s=e.gmlRender.getScale(),r=ws.HOT_DISTANCE/s;let i=re.generateMatrix(),a,c,h;if(n.length===1){const d=n[0];if(Hp.has(d.type))return!1;const u=d.baseProps;i=d.globalTransform().clone();const g=new m(.5*u.width,.5*u.height);a=i.crossPoint(g),c=new D(0,0,u.width,u.height),h=i.inverseMatrix().crossPoint(t.globalPoint)}else{const d=e.auxiliaryManager.selectManager.getSelectBounds();c=D.rectNode2Rect(d),a=new m(.5*(d.minX+d.maxX),.5*(d.minY+d.maxY)),h=new m(t.globalPoint.x-c.x,t.globalPoint.y-c.y)}return M.circleContains({x:0,y:0},h,r)?(this.result={rotateCenter:a,nodes:n,cursorAngle:M.computeRotateAngle(n,180),rotateType:Zt.TOP_LEFT},!0):M.circleContains({x:c.width,y:0},h,r)?(this.result={rotateCenter:a,nodes:n,cursorAngle:M.computeRotateAngle(n,-90),rotateType:Zt.TOP_RIGHT},!0):M.circleContains({x:c.width,y:c.height},h,r)?(this.result={rotateCenter:a,nodes:n,cursorAngle:M.computeRotateAngle(n,0),rotateType:Zt.BOTTOM_RIGHT},!0):M.circleContains({x:0,y:c.height},h,r)?(this.result={rotateCenter:a,nodes:n,cursorAngle:M.computeRotateAngle(n,90),rotateType:Zt.BOTTOM_LEFT},!0):!1}};p(ws,"HOT_DISTANCE",16);let Jo=ws;class Dp extends Ke{onDetect(t,e){const n=e.detect(F.Node,t),o=e.docState.docMode===he.SLIDE_EDIT;if(!n){if(o){const r=M.getSlideContainerChildNode(e.docState.slideStatus.slideContainer,e.docState.slideStatus.currentIndex,e);return this.result=r,!0}return!1}const s=e.getSelectNodes();for(const r of n)if(!s.has(r)&&r.type===v.Section)return this.result=r,!0;if(o){const r=M.getSlideContainerChildNode(e.docState.slideStatus.slideContainer,e.docState.slideStatus.currentIndex,e);return this.result=r,!0}return!1}}class Op extends jt{constructor(){super(),this.registerDownHandler(new er),this.registerDownHandler(new tr),this.registerUpHandler(new nr),this.registerUpHandler(new Ba),this.registerUpHandler(new or)}}class Xp extends pn{constructor(){super([new Op])}}class zp extends jt{constructor(){super(),this.registerDownHandler(new qa)}}class Wp extends js{constructor(){super([new zp])}}class Fp extends _o{constructor(){super(...arguments);p(this,"handlers",[new sr])}}class Yp{constructor(){p(this,"allowEventTypeSet",new Set([be.pointermove]));p(this,"handlers",[new Da,new Xa,new za,new Oa])}process(t,e){const n=e.detect(F.HoverNode,t);if(n){for(const o of this.handlers)if(o.enable(n)){o.handle(n,e);return}}}}class Gp extends Ot{constructor(){super([new Yp,new Fp])}canBeEnable(t,e){return!0}canBeExit(t,e){return!0}}class Up extends gn{constructor(){super([new qs,new Wp,new Xp,new Gp])}canBeEnable(t,e){return!e.docState.canEdit()}}class _p extends Ke{onDetect(t,e){const n=[...e.getSelectNodes()];if(n.length!==1)return!1;const o=n[0];if(o.type!==v.IMG)return!1;const s=e.detect(F.Node,t);return s&&e.auxiliaryManager.selectManager.include(s[0])?(this.result=o,!0):!1}}class $p extends kn{constructor(){super([new Ja])}streamEnable(t,e){return!0}}class jp{constructor(){p(this,"allowEventTypeSet",new Set([be.pointermove]))}process(t,e){e.setCursor("grab")}}class Vp extends Ot{constructor(){super([new jp])}canBeEnable(t,e){return!0}canBeExit(t,e){return!0}}class Kp extends gn{constructor(){super([new $p,new Vp])}canBeEnable(t,e){return e.toolManager.currentTool===ye.HandTool}}class Qp extends ft{enable(t,e){return!!e.detect(F.ImageOriginBounds,t)}handle(t,e){const n=e.detect(F.ImageOriginBounds,t);n.type===V.BOTTOM||n.type===V.TOP?e.setCursor("ns-resize"):n.type===V.RIGHT||n.type===V.LEFT?e.setCursor("ew-resize"):n.type===V.TOP_LEFT||n.type===V.BOTTOM_RIGHT?e.setCursor("nwse-resize"):(n.type===V.TOP_RIGHT||n.type===V.BOTTOM_LEFT)&&e.setCursor("nesw-resize")}}class Zp extends _o{constructor(){super(...arguments);p(this,"handlers",[new Ga,new Qp,new sr])}}class qp extends Ot{constructor(){super([new Zp])}canBeEnable(t,e){return!0}canBeExit(t,e){return!0}}class Jp extends ht{constructor(){super(...arguments);p(this,"limitBounds");p(this,"imgNode");p(this,"lastPoint");p(this,"stretchRect");p(this,"transform");p(this,"stretchType")}onStart(e,n){const o=n.detect(F.Stretch,e);this.stretchType=o.type;const s=[...n.getSelectNodes()][0];this.imgNode=s;const r=s.getOriginImageRect().clone(),i=s.toGlobal({x:r.x,y:r.y}),a=this.imgNode.globalBaseProps;this.limitBounds=new D(i.x,i.y,r.width,r.height);const c=re.generateMatrix().rotate(a.angle),d=re.generateMatrix().translate(i.x,i.y).crossProduct(c);this.transform=d.inverseMatrix(),this.lastPoint=this.transform.crossPoint(e.globalPoint);const u=new m(a.x,a.y),g=this.transform.crossPoint(u);this.stretchRect=new D(g.x,g.y,a.width,a.height),n.execAction(new W)}onCropNode(e,n,o){const s=this.transform.crossPoint(e.globalPoint),r=new m(s.x-this.lastPoint.x,s.y-this.lastPoint.y);this.lastPoint=s;const i=this.stretchRect;switch(this.stretchType){case V.TOP:i.y=i.y+r.y,i.height=i.height-r.y;break;case V.BOTTOM:i.height=i.height+r.y;break;case V.LEFT:i.x=i.x+r.x,i.width=i.width-r.x;break;case V.RIGHT:i.width=i.width+r.x;break;case V.TOP_LEFT:i.y=i.y+r.y,i.height=i.height-r.y,i.x=i.x+r.x,i.width=i.width-r.x;break;case V.TOP_RIGHT:i.y=i.y+r.y,i.height=i.height-r.y,i.width=i.width+r.x;break;case V.BOTTOM_LEFT:i.x=i.x+r.x,i.width=i.width-r.x,i.height=i.height+r.y;break;case V.BOTTOM_RIGHT:i.width=i.width+r.x,i.height=i.height+r.y;break}const a=this.modifyStretchRect(i),c=new m(a.x,a.y),h=this.transform.inverseMatrix().crossPoint(c),d=this.imgNode.parent.toLocal(h),u=[{type:I.Base,x:d.x,y:d.y,width:a.width,height:a.height}];n.execAction(U.create(this.imgNode.id,u,{streaming:o}));const g=this.imgNode.toLocal(new m(this.limitBounds.x,this.limitBounds.y));n.execAction(U.create(this.imgNode.id,[{type:I.Crop,cropInfo:{imgX:g.x,imgY:g.y,imgWidth:this.limitBounds.width,imgHeight:this.limitBounds.height}}],{streaming:o}))}onMove(e,n){this.onCropNode(e,n,!0)}modifyStretchRect(e){const n=new D(e.x,e.y,e.width,e.height);return n.width<10&&(n.width=10),n.height<10&&(n.height=10),e.x<0?(n.x=0,n.width=e.x+e.width):e.x+e.width>this.limitBounds.width&&(n.width=this.limitBounds.width-e.x),e.y<0?(n.y=0,n.height=e.y+e.height):e.y+e.height>this.limitBounds.height&&(n.height=this.limitBounds.height-e.y),n}onUp(e,n){this.onCropNode(e,n,!1),n.execAction(new z)}}class eg extends dt{constructor(){super([new Jp])}streamEnable(t,e){return!!e.detect(F.Stretch,t)}}class tg extends fn{enable(t){return t.type===v.IMG}handle(t,e,n,o,s){const r=e.crop,i=e.crop.globalImgPos,a=r.originCropProps,c=a.cropType,h=r.originTransform,d=s.crossPoint(i),u=h.crossPoint(d);return[{id:t.id,props:[{type:I.Crop,cropInfo:{imgX:u.x,imgY:u.y,imgWidth:a.cropInfo.imgWidth*n,imgHeight:a.cropInfo.imgHeight*o},cropType:c}]}]}}class ng extends Go{constructor(){super(...arguments);p(this,"handlers",[new tg])}computeAnchorPoint(e,n){const o=this.target.nodes[0],{x:s,y:r,width:i,height:a}=o.getOriginImageRect();switch(e.type){case V.TOP:return this.alignType=_e.height,{x:s,y:r+a};case V.RIGHT:return this.alignType=_e.width,{x:s,y:r};case V.BOTTOM:return this.alignType=_e.height,{x:s,y:r};case V.LEFT:return this.alignType=_e.width,{x:s+i,y:r};case V.TOP_LEFT:return this.alignType=_e.both,{x:s+i,y:r+a};case V.TOP_RIGHT:return this.alignType=_e.both,{x:s,y:r+a};case V.BOTTOM_RIGHT:return this.alignType=_e.both,{x:s,y:r};case V.BOTTOM_LEFT:default:return this.alignType=_e.both,{x:s+i,y:r}}}judgeUniform(e){this.isUniform=!0}computeTarget(e,n){const o=n.detect(F.ImageOriginBounds,e),s=[...n.getSelectNodes()];this.target={type:o.type,nodes:s,angle:M.computeStretchAngle(s,o.type)}}alignStretchGlobalPoint(e,n){const o=[...n.getSelectNodes()][0],s=o.toLocal(e.globalPoint),r=o.baseProps,i=e.globalPoint.clone(),a=this.target.type;return s.x>0&&(a===V.LEFT||a===V.BOTTOM_LEFT||a===V.TOP_LEFT)&&(i.x=o.toGlobal({x:0,y:0}).x),s.x<r.width&&(a===V.RIGHT||a===V.BOTTOM_RIGHT||a===V.TOP_RIGHT)&&(i.x=o.toGlobal({x:r.width,y:0}).x),s.y>0&&(a===V.TOP||a===V.TOP_RIGHT||a===V.TOP_LEFT)&&(i.y=o.toGlobal({x:0,y:0}).y),s.y<r.height&&(a===V.BOTTOM||a===V.BOTTOM_RIGHT||a===V.BOTTOM_LEFT)&&(i.y=o.toGlobal({x:0,y:r.height}).y),i}computeOriginTransform(e){const n=this.target,o=[...e.getSelectNodes()][0],{x:s,y:r,angle:i}=o.globalBaseProps,a=re.generateMatrix().rotate(-i),c=re.generateMatrix().translate(-s,-r),h=this.computeAnchorPoint(n,D.baseProps2Rect(o.baseProps)),u=re.generateMatrix().translate(-h.x,-h.y).crossProduct(a.crossProduct(c));this.originTransform=u}drawAlignLine(e,n,o){const s=this.target.nodes[0],r=s.baseProps,{width:i,height:a}=n,c=s.globalTransform().clone();if(i){e.width+=i.dt;const h={transform:c,line:{start:new m(0,r.height),end:new m(r.width,r.height)}};i.lines.push(h)}if(a){e.height+=a.dt;const h={transform:c,line:{start:new m(r.width,0),end:new m(r.width,r.height)}};a.lines.push(h)}o.addOrUpdate(N.AlignStretchLine,{alignInfo:n})}getMiniSize(e){const n=this.target.type,o=this.target.nodes[0],s=o.baseProps,{x:r,y:i,width:a,height:c}=o.getOriginImageRect(),h=a/c;switch(n){case V.BOTTOM:case V.RIGHT:case V.BOTTOM_RIGHT:{const d=s.width-r,u=s.height-i,g=u*h;return d>g?new m(d,d/h):new m(g,u)}case V.LEFT:case V.BOTTOM_LEFT:{const d=a+r,u=s.height-i,g=u*h;return d>g?new m(d,d/h):new m(g,u)}case V.TOP_LEFT:{const d=a+r,u=c+i,g=u*h;return d>g?new m(d,d/h):new m(g,u)}case V.TOP:case V.TOP_RIGHT:{const d=s.width-r,u=c+i,g=u*h;return d>g?new m(d,d/h):new m(g,u)}default:return new m(s.width,s.height)}}getStretchRect(e){const n=[...e.getSelectNodes()][0],o=D.baseProps2Rect(n.baseProps),s=n.getOriginImageRect();return o.width=s.width,o.height=s.height,o.x=o.x-s.x,o.y=o.y-s.y,o}recordPropsMap(e){this.propsMap.clear();const n=this.target.nodes;for(const o of n){const s=this.recordNodePropInfo(o);this.propsMap.set(o,s)}}afterStretchNode(e,n,o,s,r,i,a){e.asyncRenderNodeManager.batchAddRenderNode(a)}}class og extends dt{constructor(){super([new ng])}streamEnable(t,e){return!!e.detect(F.ImageOriginBounds,t)}}class sg extends ht{constructor(){super(...arguments);p(this,"lastPoint");p(this,"originImgRect");p(this,"imgNode");p(this,"limitBounds");p(this,"transform");p(this,"dragRect")}onStart(e,n){this.imgNode=[...n.getSelectNodes()][0],this.originImgRect=this.imgNode.getOriginImageRect().clone();const o=this.imgNode.globalBaseProps,s=this.imgNode.toGlobal({x:this.originImgRect.x,y:this.originImgRect.y});this.limitBounds=new D(s.x,s.y,this.originImgRect.width,this.originImgRect.height);const r=re.generateMatrix().rotate(o.angle),a=re.generateMatrix().translate(s.x,s.y).crossProduct(r);this.transform=a.inverseMatrix();const c=this.transform.crossPoint({x:o.x,y:o.y});this.dragRect=new D(c.x,c.y,o.width,o.height),this.lastPoint=this.transform.crossPoint(e.globalPoint),n.execAction(new W)}onMove(e,n){this.dragCrop(e,n,!0)}onUp(e,n){this.dragCrop(e,n,!1),n.execAction(new z)}dragCrop(e,n,o){const s=this.imgNode.cropProps.cropInfo,r=this.modifyCropBasePos(e,n),i=this.imgNode.parent.toLocal(r),a=[{type:I.Base,x:i.x,y:i.y}];n.execAction(new U({infos:[{id:this.imgNode.id,props:a}]},{streaming:o}));const c=this.imgNode.toLocal(this.limitBounds),h={imgX:c.x,imgY:c.y,imgWidth:s.imgWidth,imgHeight:s.imgHeight},d=[{type:I.Crop,cropInfo:h}];n.execAction(new U({infos:[{id:this.imgNode.id,props:d}]},{streaming:o}))}modifyCropBasePos(e,n){const o=e.globalPoint,s=this.transform.crossPoint(o),r=s.x-this.lastPoint.x,i=s.y-this.lastPoint.y,a=this.dragRect;a.x+=r,a.y+=i;const c=this.imgNode.baseProps,h=new m(a.x,a.y);a.x+a.width>this.limitBounds.width?h.x=this.limitBounds.width-c.width:a.x<0&&(h.x=0),a.y<0?h.y=0:a.y+a.height>this.limitBounds.height&&(h.y=this.limitBounds.height-c.height);const d=this.transform.inverseMatrix().crossPoint(h);return this.lastPoint=s,d}}class rg extends dt{constructor(){super([new sg])}streamEnable(t,e){const n=[...e.getSelectNodes()];return n.length!==1||!e.cropManager.duringCrop?!1:!!n[0].contains(t.globalPoint)}}class wo{intoCrop(t){const e=t.getSelectNodes();if(e.size!==1)return;const n=[...e][0];if(!(n instanceof Fn)||t.cropManager.duringCrop)return;t.cropManager.intoCrop(),t.auxiliaryManager.selectManager.refreshSelectStatus(),t.renderManager.addAuxiliaryDrawTask();const s=n.cropProps;if(!s.cropInfo||s.cropType===wt.None){const{width:r,height:i}=n.baseProps;t.execAction(new W),t.execAction(U.create(n.id,[{cropType:wt.Rect,cropInfo:{imgX:0,imgY:0,imgWidth:r,imgHeight:i},type:I.Crop}])),t.execAction(new z)}}exitCrop(t){if(t.cropManager.duringCrop){t.cropManager.exitCrop(),t.auxiliaryManager.selectManager.refreshSelectStatus(),t.renderManager.addAuxiliaryDrawTask();return}}resetCrop(t){const e=t.getSelectNodes();if(e.size!==1)return;const n=[...e][0];if(!(n instanceof Fn)||!t.cropManager.duringCrop)return;const s=n.cropProps;if(!s.cropInfo||s.cropType===wt.None)return;const r=n.getOriginImageRect(),i=new m(r.x,r.y),a=n.toGlobal(i),c=n.parent.toLocal(a);t.execAction(new W),t.execAction(U.create(n.id,[{cropType:wt.None,type:I.Crop},{type:I.Base,x:c.x,y:c.y,width:r.width,height:r.height}])),t.execAction(new z),t.cropManager.exitCrop(),t.auxiliaryManager.selectManager.refreshSelectStatus()}}class ig extends qe{constructor(){super(...arguments);p(this,"worker",new wo)}enable(e,n){const o=[...n.getSelectNodes()];if(o.length!==1)return!1;const s=o[0],r=s.toLocal(e.globalPoint),i=s.getOriginImageRect();return n.detect(F.ImageOriginBounds,e)?!1:!M.rectContains(r,i)}handle(e,n){this.worker.exitCrop(n),n.auxiliaryManager.slotManager.addSlotState(ze.ExitCrop,!0)}}class ag extends jt{constructor(){super(),this.registerDownHandler(new ig)}}class cg extends pn{constructor(){super([new ag])}}class lg extends gn{constructor(){super([new eg,new og,new rg,new cg,new qp])}canBeEnable(t,e){return e.cropManager.duringCrop}}class hg extends Ke{onDetect(t,e){const n=e.getSelectNodes();if(n.size!==1)return!1;const o=[...n][0];if(o.type!==v.IMG||!e.cropManager.duringCrop)return!1;const s=o,{cropType:r,cropInfo:i}=s.cropProps;if(r===wt.None||!i)return!1;const a=8/e.renderManager.getScale(),c=s.getOriginImageRect(),h=o.toLocal(t.globalPoint),d=M.detectRectBounds(c,h,a);return d?(this.result={type:d.type},!0):!1}}class lr{constructor(){p(this,"alignWorker",new un)}computeLinePoints(t,e,n){return Ze.computeLinePoints(t,this.layoutHandler,e,n,this.alignWorker)}alignLinePointsInMove(t,e){return t}alignLinePointsInUp(t,e){return t}computeDownProps(t,e,n,o){const r=[new Oe(e.toolManager.shapeType)],i=e.detect(F.NodeEdge,e.lastDiffTypeEvent);if(i){const y={type:I.Connect,start:{objectId:i.node.id,x:i.relativePos.x,y:i.relativePos.y}};t.point=new m(i.point.x,i.point.y),t.nodeConnect={rect:D.rectNode2Rect(i.node.getBounds()),endType:M.computeNodeConnectEnd(i.relativePos,i.node.baseProps.angle)},r.push(y)}else r.push(new Rt);const a={point:new m(t.point.x+1,t.point.y+1)},c=this.layoutHandler.layoutToPointsPro(t,a),h=o.globalTransform().inverseMatrix(),d=c.map(y=>h.crossPoint(y)),u=je.create(d),g=D.rectNode2Rect(M.getBoundsByPoints(d)),f=ie.create({x:g.x,y:g.y,width:g.width,height:g.height});return r.push(u,f,new Ae,lt.create({rArrow:it.Arrow}),Ge.create({sizeMode:We.autoWidth}),new Et),r}computeMoveProps(t,e,n,o){const s=M.dealWithShiftLineInteractEvent(e,o),r=this.computeLinePoints(t,s,n),i=this.alignLinePointsInMove(r,n),a=o.parent.globalTransform().inverseMatrix(),c=i.map(g=>a.crossPoint(g)),h=D.rectNode2Rect(M.getBoundsByPoints(c)),d=[je.create(c),ie.create({x:h.x,y:h.y,width:h.width,height:h.height})],u={infos:[{id:o.id,props:d}]};n.actionManager.execAction(new U(u,{streaming:!0}))}computeUpProps(t,e,n,o){const s=M.dealWithShiftLineInteractEvent(e,o),r=[],i=n.detect(F.NodeEdge,s);if(i){const f=o.connectProps.clone();f.end={objectId:i.node.id,x:i.relativePos.x,y:i.relativePos.y},r.push(f)}const a=this.computeLinePoints(t,s,n),c=this.alignLinePointsInUp(a,n),h=o.parent.globalTransform().inverseMatrix(),d=c.map(f=>h.crossPoint(f)),u=D.rectNode2Rect(M.getBoundsByPoints(d));r.push(je.create(d),ie.create({x:u.x,y:u.y,width:u.width,height:u.height}));const g={infos:[{id:o.id,props:r}]};n.actionManager.execAction(new U(g,{streaming:!1}))}}let es=class extends lr{constructor(){super(...arguments);p(this,"layoutHandler",new Xo)}enable(e){return e===de.Line}};class ts extends lr{constructor(){super(...arguments);p(this,"layoutHandler",new po)}enable(e){return e===de.Curve}}class ns extends lr{constructor(){super(...arguments);p(this,"layoutHandler",new Vt)}enable(e){return e===de.RoundPolyLine||e===de.PolyLine}alignLinePointsInMove(e,n){return M.dealWithEndPolyPoints(e,n.gmlRender.getScale(),!0)}alignLinePointsInUp(e,n){return M.dealWithEndPolyPointsInUp(e,n.gmlRender.getScale(),!0)}}class uc extends ht{constructor(){super(...arguments);p(this,"startConnectInfo",{point:new m});p(this,"target",null);p(this,"shapeType",de.Line);p(this,"currentHandler",null);p(this,"handlers",[new es,new ts,new ns])}selectHandler(){for(const e of this.handlers)if(e.enable(this.shapeType)){this.currentHandler=e;return}throw new Error("类型错误:没有合适的handler处理")}onStart(e,n){this.startConnectInfo.point=e.globalPoint,this.shapeType=n.toolManager.shapeType,this.selectHandler();const o=n.detect(F.HoverOnContainer,e);let s=n.nodeManager.root;o&&(s=o);const r=this.currentHandler.computeDownProps(this.startConnectInfo,n,e,s),i=n.idGenerator.genId(v.Line),a={id:i,type:v.Line,zIndex:ve.genZIndex(n.nodeManager.root),parentId:s.id,props:r};n.actionManager.execAction(new W);const c=Le.create(a);n.actionManager.execAction(c),this.target=n.nodeManager.nodeMap.get(i),n.actionManager.execAction(xe.create([this.target.id]))}onMove(e,n){this.currentHandler.computeMoveProps(this.startConnectInfo,e,n,this.target)}onUp(e,n){this.currentHandler.computeUpProps(this.startConnectInfo,e,n,this.target),n.execAction(new z),n.setCursor("default"),n.toolManager.resetTool()}}class pc extends dt{constructor(){super([new uc],[new $o,new jo,new Vo])}streamEnable(t,e){return e.toolManager.currentTool==ye.LINE}}class dg extends qe{constructor(){super(...arguments);p(this,"handlers",[new es,new ts,new ns])}enable(e,n){return!n.toolManager.creatingLine}handle(e,n){const o=n.idGenerator.genId(v.Line),s=this.makeupLineProps(e,n);if(!s)return;const r={id:o,type:v.Line,zIndex:ve.genZIndex(n.nodeManager.root),parentId:"",props:s};n.actionManager.execAction(new W);const i=Le.create(r);n.actionManager.execAction(i);const a=n.nodeManager.getNode(o);n.toolManager.setInCreatingLine(a)}makeupLineProps(e,n){const o={point:e.globalPoint},r=n.detect(F.HoverOnContainer,e)??n.nodeManager.root;for(const i of this.handlers)if(i.enable(n.toolManager.shapeType))return i.computeDownProps(o,n,e,r);return null}}class ug extends qe{constructor(){super(...arguments);p(this,"handlers",[new es,new ts,new ns])}enable(e,n){return n.previewManager.resetPreviewNode(n),n.auxiliaryManager.removeAlignGraphics(),!!n.toolManager.creatingLine}handle(e,n){const o=n.toolManager.creatingLine,s=this.getStartConnectInfo(o,n);for(const r of this.handlers)r.enable(o.shapeType)&&r.computeUpProps(s,e,n,o);n.execAction(new z),n.toolManager.setInCreatingLine(null),n.toolManager.resetTool(),n.setCursor("default")}getStartConnectInfo(e,n){const o=e.points,{start:s}=e.connectProps,r={point:o[0]};if(s){const i=n.nodeManager.getNode(s.objectId);i&&(r.nodeConnect={endType:M.computeNodeConnectEnd(s,i.baseProps.angle),rect:D.rectNode2Rect(i.getBounds())})}return r}}class pg extends jt{constructor(){super(),this.registerDownHandler(new ug),this.registerUpHandler(new dg)}}class gg extends pn{constructor(){super([new pg])}clickEnable(t,e){return e.toolManager.currentTool===ye.LINE}}class fg{constructor(){p(this,"allowEventTypeSet",new Set([be.pointermove]));p(this,"handlers",[new es,new ts,new ns])}process(t,e){const n=e.toolManager.creatingLine;if(!n)return;const o=this.getStartConnectInfo(n,e);for(const s of this.handlers)s.enable(n.shapeType)&&s.computeMoveProps(o,t,e,n)}getStartConnectInfo(t,e){const n=t.points,{start:o}=t.connectProps,s={point:n[0]};if(o){const r=e.nodeManager.getNode(o.objectId);r&&(s.nodeConnect={endType:M.computeNodeConnectEnd(o,r.baseProps.angle),rect:D.rectNode2Rect(r.getBounds())})}return s}}const yg=new Set([ye.LINE]);class xg extends gn{constructor(){super([new gg,new pc,new ac([new cc,new $o,new jo,new Vo,new fg,new lc,new hc])])}canBeEnable(t,e){return yg.has(e.toolManager.currentTool)}}class wg extends Ke{onDetect(t,e){const n=e.auxiliaryManager.selectManager.selectNodes;if(n.size!==1)return!1;const o=[...n][0];if(o.type!==v.Line)return!1;const s=o;if(s.shapeType!==de.Curve)return!1;const r=e.gmlRender.getScale(),i=M.computeBezierCurves(s);let a=0;for(const c of i){const h=c.getHalfTPos();if(M.circleContains(h,t.globalPoint,8/r))return this.result={line:s,midPoint:new m(h.x,h.y),lPoint:c.p0,rPoint:c.p3,curve:c,index:a},!0;a=a+3}return!1}}class mg extends Ke{onDetect(t,e){const n=e.auxiliaryManager.selectManager.selectNodes;if(n.size!==1)return!1;const o=[...n][0];if(o.type!==v.Line)return!1;const s=o;if(s.shapeType!==de.Curve)return!1;const r=e.gmlRender.getScale(),i=M.computeBezierCurves(s);let a=0;for(const c of i){const h=[c.p0,c.p3];let d=0;for(const u of h){if(M.circleContains(u,t.globalPoint,8/r))return this.result={line:s,index:a+d},!0;d=d+3}a+=3}return!1}}class Pg extends Ke{onDetect(t,e){if(e.inputManager.editTextInfo)return!1;const n=e.auxiliaryManager.selectManager.selectNodes;if(n.size!==1)return!1;const o=[...n][0];if(o.type!==v.Line)return!1;const s=o;if(s.renderText.isEmptyText())return!1;const r=s.toLocal(t.globalPoint),i=s.getTextContentRect();return M.rectContains(r,i)?(this.result={line:s},!0):!1}}class bg extends Ot{constructor(){super([])}canBeEnable(t,e){return!0}canBeExit(t,e){return!0}}class Mg extends gn{constructor(){super([new bg])}canBeEnable(t,e){return e.docState.docMode===he.SLIDE_PLAY}}class Sg extends Ke{onDetect(t,e){var u;const n=[...e.getSelectNodes()];if(n.length!==1)return!1;const o=n[0];if(((u=o.parent)==null?void 0:u.type)!==v.SlideContainer||e.docState.docMode===he.SLIDE_EDIT)return!1;const r=o.parent,i=this.getRowColIndex(r,o.id);if(!i)return!1;const{x:a,y:c,height:h,width:d}=o.globalBaseProps;return M.rectContains(t.globalPoint,new D(a-nt,c,nt,h))?(this.result={slideContainer:r,i:i.i,j:i.j,point:{x:a-nt/2,y:c+h/2}},!0):M.rectContains(t.globalPoint,new D(a+d,c,nt,h))?(this.result={slideContainer:r,i:i.i,j:i.j+1,point:{x:a+d+nt/2,y:c+h/2}},!0):!1}getRowColIndex(t,e){const n=t.slideProps.children;let o=0,s=0;for(const r of n){s=0;for(const i of r.ids){if(e===i)return{i:o,j:s};s++}o++}return null}}class vg extends Ke{onDetect(t,e){const n=e.detect(F.Node,t);if(!n)return!1;const o=n[0];if(o.type!==v.SlideContainer||!e.auxiliaryManager.selectManager.include(o))return!1;const s=o;if(s.slideProps.children.length!==0)return!1;const{x:i,y:a,height:c,width:h}=o.globalBaseProps,d=new D(i+nt,a+xt,h-2*nt,c-2*xt);return M.rectContains(t.globalPoint,d)?(this.result={slideContainer:s,rect:d},!0):!1}getRowColIndex(t,e){const n=t.slideProps.children;let o=0,s=0;for(const r of n){s=0;for(const i of r.ids){if(e===i)return{i:o,j:s};s++}o++}return null}}class hr extends oa{constructor(){super(...arguments);p(this,"detectors",new Map([[F.Node,new sa],[F.HoverNode,new ra],[F.PolyControlPoint,new dc],[F.CurveControlPoint,new wg],[F.Rotate,new Jo],[F.Stretch,new Fo],[F.ExpandShape,new tc],[F.LineEndPoint,new nc],[F.NodeEdge,new up],[F.BufferNode,new Ap],[F.BufferHoverNode,new kp],[F.HoverNodeAnchor,new Bp],[F.HoverConnectAnchor,new Ep],[F.HoverOnContainer,new Dp],[F.Image,new _p],[F.ImageOriginBounds,new hg],[F.CurveEndPoint,new mg],[F.DragLineText,new Pg],[F.SlideGap,new Sg],[F.EmptySlideContainer,new vg]]));p(this,"modes",[new Mg,new Kp,new Up,new lg,new xg,new Cp,new ec])}}const Ig={[K.Ellipse]:"#F2F3F5",[K.Hexagon]:"#F2F3F5",[K.Cloud]:"#F2F3F5",[K.YuanZhu]:"#F0FBEF",[K.Parallelogram]:"#F0FBEF",[K.Trapezoid]:"#E1EAFF",[K.Triangle]:"#E1EAFF",[K.Triangle2]:"#E1EAFF",[K.RightArrow]:"#E1EAFF",[K.DoubleArrow]:"#E1EAFF",[K.LeftArrow]:"#E1EAFF",[K.RoundRect]:"#E0E2FA",[K.RoundRect2]:"#E0E2FA",[K.Rect]:"#E0E2FA",[K.LiuCheng]:"#E0E2FA",[K.LiuCheng2]:"#E0E2FA",[K.Diamond]:"#FEEAD2",[K.Star]:"#FEEAD2",[K.Qipao]:"#FEF1F1",[K.Qipao2]:"#FEF1F1",[K.RightKuohao]:"#FEF1F1",[K.LeftKuohao]:"#FEF1F1"},Tg={[K.Ellipse]:"#DEE0E3",[K.Hexagon]:"#DEE0E3",[K.Cloud]:"#DEE0E3",[K.YuanZhu]:"#8EE085",[K.Parallelogram]:"#8EE085",[K.Trapezoid]:"#82A7FC",[K.Triangle]:"#82A7FC",[K.Triangle2]:"#82A7FC",[K.RightArrow]:"#82A7FC",[K.DoubleArrow]:"#82A7FC",[K.LeftArrow]:"#82A7FC",[K.RoundRect]:"#7B83EA",[K.RoundRect2]:"#7B83EA",[K.Rect]:"#7B83EA",[K.LiuCheng]:"#7B83EA",[K.LiuCheng2]:"#7B83EA",[K.Diamond]:"#FFBA6B",[K.Star]:"#FFBA6B",[K.Qipao]:"#F98E8B",[K.Qipao2]:"#F98E8B",[K.RightKuohao]:"#F98E8B",[K.LeftKuohao]:"#F98E8B"},Lg=(l,{x:t,y:e,width:n,height:o})=>l.x>=t&&l.x<=t+n&&l.y>=e&&l.y<=e+o;class Vt extends Fs{enable(t){return t.isPolyLine()}layoutToPoints(t,e){const n=t.lineProps,{start:o,end:s}=t.connectProps,r=[...t.globalLinePoints];if(!n.auto&&r.length>2){if(o){const c=r[0],h=r[1],d=M.judgeHorizon(c,h),u=e.nodeManager.getNode(o.objectId);if(u){const g=this.getNodePos(u,o);c.x=g.x,c.y=g.y}d?h.y=c.y:h.x=c.x}if(s){const c=r[r.length-2],h=r[r.length-1],d=M.judgeHorizon(c,h),u=e.nodeManager.getNode(s.objectId);if(u){const g=this.getNodePos(u,s);h.x=g.x,h.y=g.y}d?c.y=h.y:c.x=h.x}const i=t.globalTransform().inverseMatrix();return r.map(c=>i.crossPoint(c))}else{const i=this.getLayoutHandler(t,o,e),a=this.computeLayout(i,t,s,e),c=t.globalTransform().inverseMatrix();return a.map(d=>c.crossPoint(d))}}layoutToPointsPro(t,e){const n=this.getLayoutHandlerV2(t);return this.computePointsV2(n,e)}getLayoutHandlerV2({point:t,nodeConnect:e}){if(!e)return new $i(t);const{rect:n,endType:o}=e;switch(o){case ue.Top:return new Wd(t,n);case ue.Bottom:return new Fd(t,n);case ue.Left:return new Yd(t,n);case ue.Right:return new Gd(t,n);default:return new $i(t)}}computePointsV2(t,{point:e,nodeConnect:n}){if(!n)return t.toPoint(e);const{rect:o,endType:s}=n;switch(s){case ue.Right:return t.right(e,o);case ue.Left:return t.left(e,o);case ue.Bottom:return t.bottom(e,o);case ue.Top:return t.top(e,o);default:return t.toPoint(e)}}getLayoutHandler(t,e,n){const o={point:t.globalLinePoints[0]};if(e){const s=n.nodeManager.getNode(e.objectId);s&&(o.nodeConnect={rect:D.rectNode2Rect(s.getBounds()),endType:M.computeNodeConnectEnd(e,s.baseProps.angle)},o.point=this.getNodePos(s,e))}return this.getLayoutHandlerV2(o)}computeLayout(t,e,n,o){const s=Ze.computeConnectInfo(e,n,o,!0);return this.computePointsV2(t,s)}}class Cg{constructor(){p(this,"workerMap",new Map)}init(t){this.workerMap.clear();for(const e of t){const n=new $n;n.init(e),this.workerMap.set(e,n)}}work(t,e,n){for(const o of t){const s=this.workerMap.get(o);s&&s.work(o,e,n)}}}class Rn{constructor(){p(this,"handlers",[new Xo,new po,new Vt]);p(this,"batchLineTextWorker",new Cg)}work(t,e,n){this.batchLineTextWorker.init(t);for(const o of t)this.handleAndMsg(o,e,n);this.batchLineTextWorker.work(t,e,n)}layoutToPoints(t,e){for(const n of this.handlers)if(n.enable(t))return n.layoutToPoints(t,e);return[]}handleAndMsg(t,e,n){for(const o of this.handlers)if(o.enable(t)){const s=o.handle(t,e);e.execAction(new U(s,{streaming:n}));return}}batchCollectNodeLinks(t,e,n){const o=new Set(t);for(const s of t)this.collectNodeLinks(s,e,n,o)}collectNodeLinks(t,e,n,o=new Set){const s=e.nodeManager.getNodeLinks(t);for(const r of s){const{start:i,end:a}=r.connectProps;M.judgeEndNode(r,n,i,e,o),M.judgeEndNode(r,n,a,e,o)}for(const r of t.children){if(r.type===v.Line){const i=r,{start:a,end:c}=i.connectProps;M.judgeEndNode(i,n,a,e,o),M.judgeEndNode(i,n,c,e,o)}this.collectNodeLinks(r,e,n,o)}}judgeEndNode(t,e,n,o,s){if(!n)return;const r=o.nodeManager.getNode(n.objectId);r&&!M.judgeParentInset(r,s)&&e.add(t)}}class Ag{constructor(){p(this,"layoutWorker",new Rn);p(this,"groupBaseWorker",new on)}work(t,e,n){let o=!1;if(this.groupBaseWorker.start([e]),t.textProps.sizeMode===We.autoWidth){const s=e.getTextContentRect(),{width:r,height:i}=e.baseProps,a=r-s.width,c=t.height+(i-s.height)+.2;n.execAction(U.create(e.id,[{type:I.Base,width:t.width+a,height:c}])),o=!0}else if(t.textProps.sizeMode===We.autoHeight&&e instanceof vt){let s=e.drawer.fullTextNodeHeight(e);s<100&&(s=100),n.execAction(U.create(e.id,[{type:I.Base,height:s}])),o=!0}if(o){const s=new Set;this.groupBaseWorker.work(n,!1),this.layoutWorker.collectNodeLinks(e,n,s),this.layoutWorker.work([...s],n,!1)}}}class kg{work(t,e,n){const o=e.lineTextRect,s=new m(o.point.x,o.point.y),r=t.width,i=t.height;n.execAction(U.create(e.id,[{type:I.LineTextRect,x:s.x-.5*r,y:s.y-.5*i,width:r,height:i}]))}}class mo{constructor(){p(this,"prevStringBuilder",{text:""});p(this,"nextStringBuilder",{text:""});p(this,"currentbuilder",this.prevStringBuilder);p(this,"layoutWorker",new Rn);p(this,"groupBaseWorker",new on);p(this,"nodeModifyBaseWorker",new Ag);p(this,"lineModifyWorker",new kg)}switchCurrentBuilder(t,e){return this.currentbuilder===this.nextStringBuilder?!1:t.equal(e)?(this.currentbuilder=this.nextStringBuilder,!0):!1}splitText(t,e){this.prevStringBuilder={text:""},this.nextStringBuilder={text:""},this.currentbuilder=this.prevStringBuilder;let n=-1,o=0;for(let s=0;s<t.paragraphs.length;s++){const r=t.paragraphs[s];for(let i=0;i<r.lines.length;i++){const a=r.lines[i];this.switchCurrentBuilder(e,new Fe(s,i,-1))&&(o=n);const h=a.getCharLength();for(let d=0;d<h;d++){const{character:u}=a.getCharacter(d);this.currentbuilder.text+=u.charText,n++,this.switchCurrentBuilder(e,new Fe(s,i,d))&&(o=n)}}s<t.paragraphs.length-1&&(this.currentbuilder.text+=`
|
|
5
|
+
`,n++)}return{prev:this.prevStringBuilder.text,next:this.nextStringBuilder.text,index:o}}editText(t,e,n){const{paragraphIndex:o,lineIndex:s,charIndex:r}=e,i=t.prevParagraphToXML(o),a=t.nextParagraphToXML(o),c=t.getParagraph(o),h=c.prevToRichTextXML(s,t.textProps),d=c.nextToRichTextXML(s,t.textProps),u=c.getLine(s),g=u.getBlockIndex(r);if(g){const{textBlock:f,blockIndex:y,charIndex:P}=g,b=u.prevToRichTextXML(y,t.textProps),w=u.nextToRichTextXML(y,t.textProps),L=f.insertTextToRichTextXML(n,P,t.textProps);return`<root>${i}<p>${h}${b}${L}${w}${d}</p>${a}</root>`}return`<root>${i}<p>${h}${n}${d}</p>${a}</root>`}modifyBaseProps(t,e,n){e.type===v.Shape?this.nodeModifyBaseWorker.work(t,e,n):e.type===v.Line&&this.lineModifyWorker.work(t,e,n)}}class Ng{measure(t,e,n){const o=[];t.font=M.calcFontByTextProps(n);for(const s of e){const r=new _i;for(const i of[...s]){const{width:a,height:c,boxAscent:h}=M.measureText(t,i),d=new As(i,0,0,a,c,h);r.addCharacter(d)}o.push(r)}return o}}class gc{constructor(){p(this,"streaming",!1)}}class yn{constructor(t,e){p(this,"meta",new gc);p(this,"data");p(this,"reverseLog",null);this.data=t,e&&(this.meta=e)}reverse(){if(this.reverseLog===null)throw new Error("缺少对应逆消息");return this.reverseLog}}var Lt=(l=>(l[l.Focus=0]="Focus",l[l.Selection=1]="Selection",l[l.Blur=2]="Blur",l[l.Empty=3]="Empty",l))(Lt||{});class ee extends yn{constructor(){super(...arguments);p(this,"type",Xe.TextFocus)}static focus(e,n=Fe.head()){return new ee({focusType:Lt.Focus,focus:{id:e,textCursorPosition:n}})}static selection(e,n,o){return new ee({focusType:Lt.Selection,selection:{id:e,start:n,end:o}})}static blur(e){return new ee({blur:{id:e},focusType:Lt.Blur})}static empty(){return new ee({focusType:Lt.Empty})}clone(){const e=JSON.parse(JSON.stringify(this.data));return new ee(e,this.meta)}}class fc{constructor(){p(this,"cursorMoveWorker",new ho)}work(t,e,n=1){const{node:o,renderText:s,textCursorPosition:r}=t,{updateTextProps:i}=this.computeUpdateTextProps(t,n);let a=r;for(let c=0;c<n;c++)a=this.cursorMoveWorker.moveLeft(s,a);e.execAction(new W),e.execAction(U.create(o.id,[i])),e.execAction(ee.focus(o.id,a)),e.execAction(new z)}computeUpdateTextProps(t,e){const{renderText:n,textCursorPosition:o}=t,s=this.deleteText(n,o,e);return{updateTextProps:{type:I.Text,richText:s}}}deleteText(t,e,n){if(n<=0)return t.toRichTextXML();const o=t.prevCursorPos(e,n),s=e;return this.deleteTextByCursorPos(t,o,s)}deleteTextByCursorPos(t,e,n){return e.equal(n)?t.toRichTextXML():this.generateDeletedXML(t,e,n)}generateDeletedXML(t,e,n){const{paragraphIndex:o,lineIndex:s,charIndex:r}=e,{paragraphIndex:i,lineIndex:a,charIndex:c}=n;return o===i?this.deleteSameParagraph(t,o,s,r,a,c):this.deleteCrossParagraph(t,o,s,r,i,a,c)}deleteSameParagraph(t,e,n,o,s,r){const i=t.prevParagraphToXML(e),a=t.nextParagraphToXML(e),c=t.getParagraph(e);if(n===s){const se=c.prevToRichTextXML(n,t.textProps),ne=c.nextToRichTextXML(s,t.textProps),ae=c.getLine(n),te=ae.getBlockIndex(o),ce=ae.getBlockIndex(r);if(!te||!ce)return`<root>${i}<p>${se}${ne}</p>${a}</root>`;const{blockIndex:pe,charIndex:Be}=te,{blockIndex:Re,charIndex:Me}=ce;if(pe===Re){const Ft=ae.prevToRichTextXML(pe,t.textProps),ln=ae.nextToRichTextXML(Re,t.textProps),On=te.textBlock,$e=On.getPrevText(Be),eo=On.getNextText(Me),to=$e+eo,Yt=`<style ${On.computeStyle(t.textProps)}>${to}</style>`;return`<root>${i}<p>${se}${Ft}${Yt}${ln}${ne}</p>${a}</root>`}const Te=ae.prevToRichTextXML(pe,t.textProps),ge=ae.nextToRichTextXML(Re,t.textProps),O=te.textBlock,G=ce.textBlock,j=O.getPrevText(Be),_=O.computeStyle(t.textProps),Ve=j?`<style ${_}>${j}</style>`:"",ut=G.getNextText(Me),yt=G.computeStyle(t.textProps),Nt=ut?`<style ${yt}>${ut}</style>`:"";return`<root>${i}<p>${se}${Te}${Ve}${Nt}${ge}${ne}</p>${a}</root>`}const h=c.prevToRichTextXML(n,t.textProps),d=c.nextToRichTextXML(s,t.textProps),u=c.getLine(n),g=c.getLine(s),f=u.getBlockIndex(o),y=g.getBlockIndex(r);if(!f||!y)return`<root>${i}<p>${h}${d}</p>${a}</root>`;const P=u.prevToRichTextXML(f.blockIndex,t.textProps),b=f.textBlock,w=b.getPrevText(f.charIndex),L=b.computeStyle(t.textProps),B=w?`<style ${L}>${w}</style>`:"",H=g.nextToRichTextXML(y.blockIndex,t.textProps),E=y.textBlock,X=E.getNextText(y.charIndex),$=E.computeStyle(t.textProps),Z=X?`<style ${$}>${X}</style>`:"";return`<root>${i}<p>${h}${P}${B}${Z}${H}${d}</p>${a}</root>`}deleteCrossParagraph(t,e,n,o,s,r,i){const a=t.prevParagraphToXML(e),c=t.nextParagraphToXML(s),h=t.getParagraph(e),d=t.getParagraph(s),u=h.prevToRichTextXML(n,t.textProps),g=h.getLine(n),f=g.getBlockIndex(o);let y="";if(f){const B=g.prevToRichTextXML(f.blockIndex,t.textProps),H=f.textBlock,E=H.getPrevText(f.charIndex),X=H.computeStyle(t.textProps),$=E?`<style ${X}>${E}</style>`:"";y=`${B}${$}`}const P=d.nextToRichTextXML(r,t.textProps),b=d.getLine(r),w=b.getBlockIndex(i);let L="";if(w){const B=b.nextToRichTextXML(w.blockIndex,t.textProps),H=w.textBlock,E=H.getNextText(w.charIndex),X=H.computeStyle(t.textProps);L=`${E?`<style ${X}>${E}</style>`:""}${B}`}return`<root>${a}<p>${u}${y}${L}${P}</p>${c}</root>`}}class os{constructor(){p(this,"deleteInputWorker",new fc)}work(t,e,n){n.execAction(ee.selection(t.node.id,e.start,e.end));const{node:o,renderText:s}=t,r=e.start;n.execAction(ee.focus(o.id,r));const i=this.deleteInputWorker.deleteTextByCursorPos(s,e.start,e.end),a={type:I.Text,richText:i};n.execAction(U.create(o.id,[a])),n.execAction(ee.focus(o.id,r))}}class ss{}class dr extends ss{enable(t,e){return t.paragraphIndex===e.paragraphIndex&&t.lineIndex===e.lineIndex}handle(t,e,n){const o=t.paragraphs[e.paragraphIndex],s=o.lines[e.lineIndex],r=s.getCharacter(n.charIndex);let i=0,a=0;if(e.charIndex>-1){const h=s.getCharacter(e.charIndex);i=h.textBlock.x+h.character.x+h.character.width,a=h.character.y}const c=new D(i,a,r.textBlock.x+r.character.x+r.character.width-i,s.height);return c.x+=s.x+o.x+t.x,c.y+=s.y+o.y+t.y,[c]}}class ur extends ss{enable(t,e){return t.paragraphIndex===e.paragraphIndex&&t.lineIndex!==e.lineIndex}handle(t,e,n){const o=[],s=t.paragraphs[e.paragraphIndex],r=s.lines[e.lineIndex],i=s.lines[n.lineIndex];let a=0,c=0;const h=r.getCharacter(e.charIndex);a=h===null?0:h.textBlock.x+h.character.x+h.character.width,c=h===null?0:h.character.y;const d=r.width-a;if(a+=r.x+s.x+t.x,c+=r.y+s.y+t.y,o.push(new D(a,c,d,r.height)),e.lineIndex+1===n.lineIndex&&n.charIndex===-1)return o;for(let g=e.lineIndex+1;g<n.lineIndex;g++){const f=s.lines[g];a=f.x+s.x+t.x,c=f.y+s.y+t.y,o.push(new D(a,c,f.width,f.height))}const u=i.getCharacter(n.charIndex);return u&&(a=i.x+s.x+t.x,c=i.y+s.y+t.y,o.push(new D(a,c,u.textBlock.x+u.character.x+u.character.width,i.height))),o}}class yc extends ss{constructor(){super(...arguments);p(this,"handlers",[new dr,new ur])}enable(e,n){return e.paragraphIndex!==n.paragraphIndex}handleSamePara(e,n,o){for(const s of this.handlers)if(s.enable(n,o))return s.handle(e,n,o);return[]}handle(e,n,o){const s=[],r=e.paragraphs[n.paragraphIndex],i=e.paragraphs[o.paragraphIndex],a=this.handleSamePara(e,n,r.tailCursorPosition());s.push(...a);for(let h=n.paragraphIndex+1;h<o.paragraphIndex;h++){const d=e.paragraphs[h];for(const u of d.lines)s.push(new D(e.x+d.x+u.x,e.y+d.y+u.y,u.width,u.height))}const c=this.handleSamePara(e,i.headCursorPosition(),o);return s.push(...c),s}}class xc{constructor(){p(this,"handlers",[new dr,new ur,new yc])}handleTextSelection(t,e,n){for(const o of this.handlers)if(o.enable(e,n))return o.handle(t,e,n);return[]}computeTextSelection(t,e,n){return e.equal(n)?[]:this.handleTextSelection(t,e,n)}}class wc{constructor(){p(this,"segmentWorker",new Intl.Segmenter("en",{granularity:"word"}))}split(t){return Array.from(this.segmentWorker.segment(t)).map(n=>n.segment)}}const Bg=new wc,He=16,ke=16,mc=[{x:0,y:0},{x:He,y:0},{x:He,y:ke},{x:0,y:ke}];class En{}class Rg extends En{drawOnGLCtx(t,e){const n=e.borderProps;t.strokeStyle=n.color,t.lineWidth=n.width,t.globalAlpha=n.alpha,t.moveTo(0,.5*ke),t.lineTo(He,.5*ke),t.moveTo(.5*He,0),t.lineTo(He,.5*ke),t.lineTo(.5*He,ke),t.stroke()}}class Eg extends En{drawOnGLCtx(t,e){const n=e.borderProps;t.fillStyle=n.color,t.strokeStyle=n.color,t.lineWidth=n.width,t.globalAlpha=n.alpha,t.moveTo(0,.5*ke),t.lineTo(.5*He,.5*ke),t.stroke(),t.beginPath(),t.moveTo(.5*He,0),t.lineTo(He,.5*ke),t.lineTo(.5*He,ke),t.closePath(),t.fill(),t.stroke()}}class Hg extends En{drawOnGLCtx(t,e){const n=e.borderProps;t.strokeStyle=n.color,t.lineWidth=2,t.globalAlpha=n.alpha,t.moveTo(0,.5*ke),t.lineTo(.5*He,.5*ke),t.stroke(),t.beginPath(),t.moveTo(.5*He,0),t.lineTo(He,.5*ke),t.lineTo(.5*He,ke),t.closePath(),t.stroke()}}class Dg extends En{drawOnGLCtx(t,e){const n=e.borderProps;t.fillStyle=n.color,t.lineWidth=n.width,t.globalAlpha=n.alpha,t.moveTo(0,.5*ke),t.lineTo(.5*He,.3*ke),t.lineTo(He,.5*ke),t.lineTo(.5*He,.7*ke),t.closePath(),t.fill()}}class Og extends En{drawOnGLCtx(t,e){const n=e.borderProps;t.strokeStyle=n.color,t.lineWidth=2,t.globalAlpha=n.alpha,t.moveTo(0,.5*ke),t.lineTo(.5*He,.3*ke),t.lineTo(He,.5*ke),t.lineTo(.5*He,.7*ke),t.closePath(),t.stroke()}}class Xg extends En{drawOnGLCtx(t,e){const n=e.borderProps;t.fillStyle=n.color,t.strokeStyle=n.color,t.lineWidth=n.width,t.globalAlpha=n.alpha;const o=Math.min(He,ke)*.3;t.moveTo(0,.5*ke),t.lineTo(He-o,.5*ke),t.stroke(),t.beginPath();const s=He,r=.5*ke;t.arc(s,r,o,0,2*Math.PI),t.fill(),t.stroke()}}class zg extends En{drawOnGLCtx(t,e){const n=e.borderProps;t.strokeStyle=n.color,t.lineWidth=2,t.globalAlpha=n.alpha;const o=Math.min(He,ke)*.3;t.moveTo(0,.5*ke),t.lineTo(He-o,.5*ke),t.stroke(),t.beginPath();const s=He,r=.5*ke;t.arc(s,r,o,0,2*Math.PI),t.stroke()}}const wn=class wn extends en{constructor(e,n){super(e,n);p(this,"type",v.Line);p(this,"renderText");p(this,"inEditing",!1);p(this,"rArrowMatrix",re.generateMatrix());p(this,"lArrowMatrix",re.generateMatrix());this.props.set(I.Base,new ie),this.props.set(I.Border,new Ae),this.props.set(I.Shape,new Oe),this.props.set(I.Line,new je),this.props.set(I.Arrow,new lt),this.props.set(I.Connect,new Rt),this.props.set(I.Text,Ge.create({sizeMode:We.autoWidth})),this.props.set(I.LineTextRect,new Et),this.props.set(I.TextParagraph,new qt),this.props.set(I.TextParagraphQuote,new Dt),this.renderText=new uo}get globalPos(){const e=this.pos;return this.globalTransform().crossPoint(e)}get borderProps(){return this.props.get(I.Border)}get textProps(){return this.props.get(I.Text)}get paragraphProps(){return this.props.get(I.TextParagraph)}get paragraphQuoteProps(){return this.props.get(I.TextParagraphQuote)}get arrowProps(){return this.props.get(I.Arrow)}get shapeType(){return this.props.get(I.Shape).shapeCode}get lineProps(){return this.props.get(I.Line)}get globalLinePoints(){const e=this.lineProps.points,n=this.globalTransform();return e.map(s=>n.crossPoint(s))}get connectProps(){return this.props.get(I.Connect)}get points(){return this.lineProps.points}get lineTextRect(){return this.props.get(I.LineTextRect)}get drawer(){const e=this.shapeType;let n=wn.drawerMap.get(e);return n||(console.error("取不到drawer,使用line兜底!"),n=wn.drawerMap.get(de.Line)),n}canBeConnected(){return!1}getStretchMinSize(){return new m(10,10)}drawWithTextClip(e){const o=this.getTextContentRect();o.x-=2,o.y-=2,o.width+=2*2,o.height+=2*2;const s=D.rectNode2Rect(this.getRectNode());let r=new m(s.x,s.y);r=this.toLocal(r),e.save(),e.beginPath(),e.rect(r.x,r.y,s.width,s.height),e.rect(o.x,o.y,o.width,o.height),e.clip("evenodd"),this.drawCore(e),e.restore()}drawCore(e){const n=this.borderProps;M.setDashLine(n,e),e.save(),e.strokeStyle=n.color,e.globalAlpha=n.alpha,e.lineWidth=n.width,this.drawer.draw(this,e),e.restore(),e.beginPath(),this.drawArrow(e)}drawOnGLCtx(e){const n=!this.isEmptyText()||this.inEditing;e.save();const{a:o,b:s,c:r,d:i,e:a,f:c}=this.globalTransform();e.transform(o,s,r,i,a,c),n?this.drawWithTextClip(e):this.drawCore(e),this.drawText(e),e.restore()}drawText(e){const{alpha:n}=this.borderProps;e.save(),e.beginPath();const o=new m;this.renderText.draw(e,o,n),e.restore()}isEmptyText(){return this.renderText.isEmptyText()}updateProps(e){super.updateProps(e),this.updateLArrowMatrix(),this.updateRArrowMatrix();const n=e.find(c=>c.type===I.Text),o=e.find(c=>c.type===I.Base),s=e.find(c=>c.type===I.Line),r=e.find(c=>c.type===I.LineTextRect),i=e.find(c=>c.type===I.TextParagraph),a=e.find(c=>c.type===I.TextParagraphQuote);if(n||o||s||r||i||a){const c=this.getTextContentRect();this.renderText.typesetting(this.graphicContext,this.textProps,c,this.paragraphProps,this.paragraphQuoteProps)}}getArrowDrawer(e){const n=wn.arrowDrawerMap.get(e);return n||null}draw(){this.drawOnGLCtx(this.graphicContext)}getBounds(){const e=[...this.points],n=this.globalTransform(),o=e.map(r=>n.crossPoint(r));return M.getBoundsByPoints(o)}getRectNode(){const e=[...this.points],{lArrow:n,rArrow:o}=this.arrowProps;if(n)for(const c of mc)e.push(this.lArrowMatrix.crossPoint(c));if(o)for(const c of mc)e.push(this.rArrowMatrix.crossPoint(c));const s=this.globalTransform(),r=e.map(c=>s.crossPoint(c)),i=M.getBoundsByPoints(r),a=this.borderProps;return i.minX=i.minX-a.width,i.minY=i.minY-a.width,i.maxX=i.maxX+2*a.width,i.maxY=i.maxY+2*a.width,i.id=this.id,i}updateRArrowMatrix(){const{rArrow:e}=this.arrowProps;if(!e)return;const n=this.points,o=n[n.length-1],s=new m(He,.5*ke);let r=0;if(this.isPolyLine()){const u=n[n.length-2],g=o;M.judgeHorizon(u,g)?r=g.x>u.x?0:180:r=g.y>u.y?90:-90}else if(this.shapeType===de.Curve){const u=n[n.length-1],g=n[n.length-2],f=n[n.length-3];M.distance(u,g)>.1?r=M.lineAngle(g,u)/Math.PI*180:r=M.lineAngle(f,u)/Math.PI*180}else{const u=n[n.length-2];r=M.lineAngle(u,o)/Math.PI*180}const i=re.generateMatrix().translate(-.5*He,-.5*He),a=re.generateMatrix().rotate(r),c=i.crossProduct(a),h=c.crossPoint(s),d=re.generateMatrix().translate(o.x-h.x,o.y-h.y);this.rArrowMatrix=d.crossProduct(c)}updateLArrowMatrix(){const{lArrow:e}=this.arrowProps;if(!e)return;const n=this.points,o=n[0],s=new m(He,.5*ke);let r=0;if(this.isPolyLine()){const u=o,g=n[1];M.judgeHorizon(u,g)?r=g.x>u.x?180:0:r=g.y>u.y?-90:90}else if(this.shapeType===de.Curve){const u=n[0],g=n[1],f=n[2];M.distance(u,g)>.1?r=M.lineAngle(g,u)/Math.PI*180:r=M.lineAngle(f,u)/Math.PI*180}else{const u=n[1];r=M.lineAngle(u,o)/Math.PI*180}const i=re.generateMatrix().translate(-.5*He,-.5*He),a=re.generateMatrix().rotate(r),c=i.crossProduct(a),h=c.crossPoint(s),d=re.generateMatrix().translate(o.x-h.x,o.y-h.y);this.lArrowMatrix=d.crossProduct(c)}drawArrow(e){if(this.points.length===0){console.error("line has no point!");return}const o=this.arrowProps;if(o.rArrow){const s=this.getArrowDrawer(o.rArrow);if(s){e.save();const{a:r,b:i,c:a,d:c,e:h,f:d}=this.rArrowMatrix;e.transform(r,i,a,c,h,d),s.drawOnGLCtx(e,this),e.restore()}}if(o.lArrow){const s=this.getArrowDrawer(o.lArrow);if(s){e.save();const{a:r,b:i,c:a,d:c,e:h,f:d}=this.lArrowMatrix;e.transform(r,i,a,c,h,d),s.drawOnGLCtx(e,this),e.restore()}}}getRArrowPoint(e,n,o=5){const s=M.distance(e,n),r=new m(s-Math.sqrt(3)*.5*o,.5*o),i=new m(s-Math.sqrt(3)*.5*o,-.5*o);return this.basicGetArrowPoint(e,n,r,i)}basicGetArrowPoint(e,n,o,s){const r=M.lineAngle(e,n),i=re.generateMatrix().translate(e.x,e.y).rotate2(r),a=i.crossPoint(o),c=i.crossPoint(s);return{a,b:c}}static load(e,n,o,s,r,i){const a=new wn(e,i);return a.type=n,a.zIndex=o,a.setParent(r),a.updateProps(s),a}contains(e,n=1){const o=this.toLocal(e),s=this.getTextContentRect();if(M.rectContains(o,s))return!0;const r=8/n;return mi.lineContainsPoint(this,o,r)}overlapRect(e){const n=this.getBounds();return M.containRect(e,n)?!0:mi.overlapRectNode(this,e)}getTextContentRect(){const e=this.baseProps,{x:n,y:o,width:s,height:r}=this.lineTextRect;return new D(n+e.x,o+e.y,s,r)}isPolyLine(){const e=this.shapeType;return e===de.PolyLine||e===de.RoundPolyLine}modifyPosInEditing(){return this.inEditing=!0,!0}resetFromEditing(){this.inEditing=!1}getDrawPoints(){const{lArrow:e,rArrow:n}=this.arrowProps,o=[...this.points];if(e){const s=new m(0,.5*ke),r=this.lArrowMatrix.crossPoint(s);o.shift(),o.unshift(r)}if(n){const s=new m(0,.5*ke),r=this.rArrowMatrix.crossPoint(s);o.pop(),o.push(r)}return o}getLineLength(){const e=this.points;if(this.isPolyLine()){let s=0;for(let r=0;r<e.length-1;r++){const i=e[r],a=e[r+1],c=M.distance(i,a);s+=c}return s}if(this.shapeType===de.Curve){const s=M.computeBezierCurves(this);let r=0;for(const i of s){const a=i.getApproximateLength();r+=a}return r}const n=e[0],o=e[e.length-1];return M.distance(n,o)}};p(wn,"arrowDrawerMap",new Map([[it.Arrow,new Rg],[it.Triangle,new Eg],[it.EmptyTriangle,new Hg],[it.Diamond,new Dg],[it.EmptyDiamond,new Og],[it.Circle,new Xg],[it.EmptyCircle,new zg]])),p(wn,"drawerMap",new Map([[de.Curve,new Wh],[de.RoundPolyLine,new Fh],[de.PolyLine,new zh],[de.Line,new Xh]]));let Ct=wn;class mt{buildPath(t,e){}draw(t,e){const n=t.colorProps,o=t.borderProps;e.lineJoin="round",e.lineCap="round",this.buildPath(t,e),n.color!==""&&(e.fillStyle=n.color,e.globalAlpha=n.alpha,e.fill()),o.color!==""&&o.dashType!==et.None&&(M.setDashLine(o,e),e.strokeStyle=o.color,e.lineWidth=o.width,e.globalAlpha=o.alpha,e.stroke())}getTextPadding(t){const e=t.textProps.fontSize;return e>10?le:e<4?0:1}fullTextNodeHeight(t){const e=this.getTextPadding(t);return t.renderText.height+2*e}textContentBounds(t){const e=t.baseProps,n=this.getTextPadding(t);return{x:n,y:n,width:e.width-2*n+2,height:e.height-2*n}}nodeShapeInfo(t){const{width:e,height:n}=t.baseProps;return q.rectangle({top:0,left:0,width:e,height:n})}borderContains(t,e,n){const o=this.nodeShapeInfo(t),s=q.line({x:e.x-n,y:e.y},{x:e.x+n,y:e.y}),r=q.line({x:e.x,y:e.y-n},{x:e.x,y:e.y+n});for(const i of[s,r]){const a=Y.intersect(o,i);if(a.points.length>0)return a.points[0]}return null}getConnectAnchor(){return[new m(.5,0),new m(1,.5),new m(.5,1),new m(0,.5)]}}class Wg extends mt{draw(t,e){}textContentBounds(t){const e=t.baseProps,n=this.getTextPadding(t);return{x:n,y:n,width:e.width-2*n,height:e.height-2*n}}fullTextNodeHeight(t){const e=this.getTextPadding(t);return t.renderText.height+2*e}getTextPadding(t){const e=t.textProps.fontSize;return e>10?2:e<4?0:1}}class Fg extends mt{draw(t,e){const n=t.colorProps,o=t.baseProps,s=t.borderProps;n.color!==""&&(e.fillStyle=n.color,e.globalAlpha=n.alpha,e.fillRect(0,0,o.width,o.height)),s.color!==""&&s.dashType!==et.None&&(M.setDashLine(s,e),e.strokeStyle=s.color,e.lineWidth=s.width,e.globalAlpha=s.alpha,e.strokeRect(0,0,o.width,o.height))}}class Yg extends mt{textContentBounds(t){const e=t.baseProps,n=e.width/4,o=-e.height/(e.width/2),s=e.height,r=o*n+s,i={x:n,y:r,width:e.width/2,height:e.height-r};return{x:i.x+le,y:i.y+le,width:i.width-le*2,height:i.height-le*2}}fullTextNodeHeight(t){return(t.renderText.height+le)*2}draw(t,e){const n=t.colorProps,{width:o,height:s}=t.baseProps,r=t.borderProps;e.fillStyle=n.color,e.globalAlpha=n.alpha,e.lineWidth=r.width,e.lineJoin="round",e.lineCap="round",e.beginPath(),e.moveTo(0,s),e.lineTo(.5*o,0),e.lineTo(o,s),e.closePath(),n.color!==""&&e.fill(),r.color!==""&&r.dashType!==et.None&&Math.abs(r.alpha)>.001&&(M.setDashLine(r,e),e.globalAlpha=r.alpha,e.strokeStyle=r.color,e.stroke())}nodeShapeInfo(t){const{width:e,height:n}=t.baseProps;return q.polygon([{x:0,y:n},{x:.5*e,y:0},{x:e,y:n}])}getConnectAnchor(){return[new m(.5,0),new m(.75,.5),new m(.5,1),new m(.25,.5)]}}class Gg extends mt{draw(t,e){const n=t.colorProps,{width:o,height:s}=t.baseProps,r=t.borderProps;e.fillStyle=n.color,e.globalAlpha=n.alpha,e.lineWidth=r.width,e.lineJoin="round",e.lineCap="round",e.beginPath(),e.moveTo(0,.5*s),e.lineTo(.5*o,0),e.lineTo(o,.5*s),e.lineTo(.5*o,s),e.closePath(),n.color!==""&&e.fill(),r.color!==""&&r.dashType!==et.None&&Math.abs(r.alpha)>.001&&(e.strokeStyle=r.color,e.globalAlpha=r.alpha,M.setDashLine(r,e),e.stroke())}fullTextNodeHeight(t){return(t.renderText.height+le)*2}textContentBounds(t){const e=t.baseProps,n={x:0,y:e.height/2},o={x:e.width/2,y:0},s=(n.y-o.y)/(n.x-o.x),r=n.y,i=.25*e.width,a=s*i+r,c={x:i,y:a,with:e.width-i*2,height:e.height-a*2};return{x:c.x+le,y:c.y+le,width:c.with-le*2,height:c.height-le*2}}nodeShapeInfo(t){const{width:e,height:n}=t.baseProps;return q.polygon([{x:0,y:.5*n},{x:.5*e,y:0},{x:e,y:.5*n},{x:.5*e,y:n}])}}class Ug extends mt{draw(t,e){const n=t.baseProps,o=t.colorProps,s=t.borderProps;e.beginPath(),e.fillStyle=o.color,e.roundRect(0,0,n.width,n.height,10),o.color!==""&&(e.globalAlpha=o.alpha,e.fill()),s.color!==""&&s.dashType!==et.None&&Math.abs(s.alpha)>.001&&(e.strokeStyle=s.color,e.lineWidth=s.width,e.globalAlpha=s.alpha,M.setDashLine(s,e),e.stroke())}nodeShapeInfo(t){const{width:e,height:n}=t.baseProps;return q.rectangle({top:0,left:0,width:e,height:n})}}class _g extends mt{draw(t,e){const n=t.colorProps,{width:o,height:s}=t.baseProps,r=t.borderProps;e.fillStyle=n.color,e.globalAlpha=n.alpha,e.lineWidth=r.width,e.lineJoin="round",e.lineCap="round",e.beginPath(),e.ellipse(.5*o,.5*s,.5*o,.5*s,0,0,2*Math.PI,!1),n.color!==""&&e.fill(),r.color!==""&&r.dashType!==et.None&&Math.abs(r.alpha)>.001&&(e.strokeStyle=r.color,e.globalAlpha=r.alpha,M.setDashLine(r,e),e.stroke())}textContentBounds(t){const e=t.baseProps,n=e.width*Math.sqrt(2)/2,o=(e.width-n)/2,s=Math.max(e.width,e.height)/2,r=Math.min(e.width,e.height)/2,i=(1-(n/2)**2/s**2)*r**2,a={x:o,y:e.height/2-Math.sqrt(i),width:n,height:2*Math.sqrt(i)},c=this.getTextPadding(t);return{x:a.x+c,y:a.y+c,width:a.width-c*2,height:a.height-c*2}}fullTextNodeHeight(t){const e=this.getTextPadding(t);return(t.renderText.height+e)*2}nodeShapeInfo(t){const{width:e,height:n}=t.baseProps;return q.ellipse({centerX:.5*e,centerY:.5*n,radiusX:.5*e,radiusY:.5*n})}}class $g extends mt{textContentBounds(t){const e=t.baseProps;return{x:.16*e.width+le,y:le,width:(1-.16*2)*e.width-2*le,height:e.height-2*le}}buildPath(t,e){const n=t.baseProps;e.beginPath(),e.moveTo(.16*n.width,0),e.lineTo(n.width,0),e.lineTo(.84*n.width,n.height),e.lineTo(0,n.height),e.closePath()}nodeShapeInfo(t){const{width:e,height:n}=t.baseProps;return q.polygon([{x:.16*e,y:0},{x:e,y:0},{x:.84*e,y:n},{x:0,y:n}])}getConnectAnchor(){return[new m(.5,0),new m(.92,.5),new m(.5,1),new m(.08,.5)]}}class jg extends mt{textContentBounds(t){const e=t.baseProps;return{x:.2*e.width,y:le,width:.6*e.width,height:e.height-2*le}}draw(t,e){const n=t.colorProps,{width:o,height:s}=t.baseProps,r=t.borderProps;e.lineJoin="round",e.lineCap="round",e.beginPath(),e.moveTo(.2*o,0),e.lineTo(.8*o,0),e.lineTo(o,s),e.lineTo(0,s),e.closePath(),n.color!==""&&(e.fillStyle=n.color,e.globalAlpha=n.alpha,e.fill()),r.color!==""&&r.dashType!==et.None&&(M.setDashLine(r,e),e.strokeStyle=r.color,e.lineWidth=r.width,e.globalAlpha=r.alpha,e.stroke())}nodeShapeInfo(t){const{width:e,height:n}=t.baseProps;return q.polygon([{x:.2*e,y:0},{x:.8*e,y:0},{x:e,y:n},{x:0,y:n}])}getConnectAnchor(){return[new m(.5,0),new m(.9,.5),new m(.5,1),new m(.1,.5)]}}class Vg extends mt{buildPath(t,e){const{width:n,height:o}=t.baseProps;e.beginPath(),e.moveTo(.5*n,0),e.lineTo(n,.38196601125010515*o),e.lineTo(.8090169943749473*n,o),e.lineTo(.1909830056250526*n,o),e.lineTo(0,.381966011250105*o),e.closePath()}nodeShapeInfo(t){const{width:e,height:n}=t.baseProps;return q.polygon([{x:.5*e,y:0},{x:e,y:.38196601125010515*n},{x:.8090169943749473*e,y:n},{x:.1909830056250526*e,y:n},{x:0,y:.381966011250105*n}])}textContentBounds(t){const e=t.baseProps,n={x:0,y:e.height*.38196601125010515},o={x:e.width/2,y:0},s=(n.y-o.y)/(n.x-o.x),r=n.y,i=.1909830056250526*e.width,a=s*i+r,c={x:i,y:a,with:e.width-i*2,height:e.height-a};return{x:c.x+le,y:c.y+le,width:c.with-le*2,height:c.height-le*2}}fullTextNodeHeight(t){const e=t.renderText.height,n=t.baseProps,o={x:0,y:n.height*.38196601125010515},s={x:n.width/2,y:0},r=(o.y-s.y)/(o.x-s.x),i=o.y,a=.1909830056250526*n.width,c=r*a+i;return e+2*le+c}getConnectAnchor(){return super.getConnectAnchor()}}class Kg extends mt{buildPath(t,e){const{width:n,height:o}=t.baseProps;e.beginPath(),e.moveTo(n,.5*o),e.lineTo(.75*n,o),e.lineTo(.25*n,o),e.lineTo(0,.5*o),e.lineTo(.25*n,0),e.lineTo(.75*n,0),e.closePath()}nodeShapeInfo(t){const{width:e,height:n}=t.baseProps;return q.polygon([{x:e,y:.5*n},{x:.75*e,y:n},{x:.25*e,y:n},{x:0,y:.5*n},{x:.25*e,y:0},{x:.75*e,y:0}])}textContentBounds(t){const e=t.baseProps;return{x:.25*e.width+le,y:le,width:.5*e.width-2*le,height:e.height-2*le}}getConnectAnchor(){return super.getConnectAnchor()}}class Qg extends mt{buildPath(t,e){const{width:n,height:o}=t.baseProps;e.beginPath(),e.moveTo(.7071067811865476*n,0),e.lineTo(n,.2928932188134524*o),e.lineTo(n,.7071067811865476*o),e.lineTo(.7071067811865476*n,o),e.lineTo(.2928932188134525*n,o),e.lineTo(0,.7071067811865476*o),e.lineTo(0,.29289321881345254*o),e.lineTo(.29289321881345215*n,0),e.closePath()}nodeShapeInfo(t){const{width:e,height:n}=t.baseProps;return q.polygon([{x:.7071067811865476*e,y:0},{x:e,y:.2928932188134524*n},{x:e,y:.7071067811865476*n},{x:.7071067811865476*e,y:n},{x:.2928932188134525*e,y:n},{x:0,y:.7071067811865476*n},{x:0,y:.29289321881345254*n},{x:.29289321881345215*e,y:0}])}textContentBounds(t){const e=t.baseProps,n={x:.064625*e.width,y:.064625*e.height,width:e.width*(1-.064625*2),height:e.height*(1-.064625*2)};return{x:n.x+le,y:n.y+le,width:n.width-le*2,height:n.height-le*2}}fullTextNodeHeight(t){return(t.renderText.height+2*le)/(1-.064625*2)}getConnectAnchor(){return super.getConnectAnchor()}}const Zg="M19.1498 8.12942L18.9895 8.95084L19.7971 9.17031C21.3773 9.59972 22.4731 10.9487 22.4731 12.4833C22.4731 13.901 21.5408 15.1571 20.1512 15.6818L19.5155 15.9218L19.5722 16.5988C19.5788 16.6767 19.5821 16.7556 19.5821 16.8356C19.5821 18.3711 18.3424 19.6106 16.8195 19.6106C16.2161 19.6106 15.66 19.4173 15.206 19.0884L14.4417 18.5348L13.925 19.3244C13.4292 20.082 12.5786 20.5777 11.6143 20.5777C10.5661 20.5777 9.65135 19.9913 9.18244 19.1206L8.73358 18.2873L7.92388 18.7776C7.45803 19.0596 6.90757 19.2236 6.31413 19.2236C4.61055 19.2236 3.26243 17.8766 3.26243 16.2551C3.26243 15.774 3.37941 15.3216 3.58718 14.9209L4.05462 14.0194L3.1035 13.6636C2.19708 13.3246 1.52704 12.4149 1.52704 11.323C1.52704 9.96428 2.55686 8.90054 3.79171 8.84083L4.78871 8.79263L4.63791 7.80592C4.62047 7.69176 4.61134 7.57433 4.61134 7.45418C4.61134 6.18576 5.63529 5.16272 6.89198 5.16272C7.18142 5.16272 7.45628 5.21645 7.70869 5.31377L8.44216 5.59655L8.82102 4.90778C9.30983 4.01913 10.2497 3.42222 11.3256 3.42222C12.5174 3.42222 13.5428 4.15533 13.9715 5.20352L14.3964 6.24229L15.3181 5.60191C15.717 5.32477 16.1997 5.16272 16.7227 5.16272C18.0858 5.16272 19.1961 6.27235 19.1961 7.6476C19.1961 7.81325 19.1801 7.97425 19.1498 8.12942Z";class qg extends mt{constructor(){super(...arguments);p(this,"path2D",new Path2D(Zg))}textContentBounds(e){const n=e.baseProps;return{x:.2*n.width,y:.2*n.height,width:.6*n.width,height:.6*n.height}}draw(e,n){const o=e.colorProps,s=e.borderProps,{width:r,height:i}=e.baseProps,a=new Path2D;a.addPath(this.path2D,new DOMMatrix().scale(r/24,i/24)),n.lineJoin="round",n.lineCap="round",o.color!==""&&(n.fillStyle=o.color,n.globalAlpha=o.alpha,n.fill(a)),s.color!==""&&s.dashType!==et.None&&(M.setDashLine(s,n),n.strokeStyle=s.color,n.lineWidth=s.width,n.globalAlpha=s.alpha,n.stroke(a))}borderContains(e,n,o){const{width:s,height:r}=e.baseProps,i=e.borderProps,a=new Path2D;a.addPath(this.path2D,new DOMMatrix().scale(s/24,r/24));const c=e.graphicContext;return c.lineWidth=i.width,c.isPointInStroke(a,n.x,n.y)?n:null}}const Ie=.3;class Jg extends mt{buildPath(t,e){const{width:n,height:o}=t.baseProps;e.beginPath(),e.moveTo(0,Ie*o),e.lineTo(Ie*n,Ie*o),e.lineTo(Ie*n,0),e.lineTo((1-Ie)*n,0),e.lineTo((1-Ie)*n,Ie*o),e.lineTo(n,Ie*o),e.lineTo(n,(1-Ie)*o),e.lineTo((1-Ie)*n,(1-Ie)*o),e.lineTo((1-Ie)*n,o),e.lineTo(Ie*n,o),e.lineTo(Ie*n,(1-Ie)*o),e.lineTo(0,(1-Ie)*o),e.closePath()}nodeShapeInfo(t){const{width:e,height:n}=t.baseProps;return q.polygon([{x:0,y:Ie*n},{x:Ie*e,y:Ie*n},{x:Ie*e,y:0},{x:(1-Ie)*e,y:0},{x:(1-Ie)*e,y:Ie*n},{x:e,y:Ie*n},{x:e,y:(1-Ie)*n},{x:(1-Ie)*e,y:(1-Ie)*n},{x:(1-Ie)*e,y:n},{x:Ie*e,y:n},{x:Ie*e,y:(1-Ie)*n},{x:0,y:(1-Ie)*n}])}textContentBounds(t){const e=t.baseProps;return{x:e.width*Ie+le,y:e.height*Ie+le,width:e.width*(1-Ie*2)-le*2,height:e.height*(1-Ie*2)-le*2}}fullTextNodeHeight(t){return(t.renderText.height+2*le)/(1-Ie*2)}getConnectAnchor(){return super.getConnectAnchor()}}class ef extends mt{buildPath(t,e){const{width:n,height:o}=t.baseProps;e.beginPath(),e.moveTo(.45331701407562014*n,.04068531978415023*o),e.lineTo(.47241283626581937*n,0),e.lineTo(.5275866431283414*n,0),e.lineTo(.5466824653185405*n,.04068531978415023*o),e.lineTo(.6561866975837122*n,.2739844955129827*o),e.lineTo(.6637719246641702*n,.29014093296241683*o),e.lineTo(.6784321851024475*n,.3013390437841371*o),e.lineTo(.6953883172925998*n,.3039298761896317*o),e.lineTo(.9402500678089105*n,.3413412114782689*o),e.lineTo(.9829501587587509*n,.3478650949789417*o),e.lineTo(n,.40304112159559813*o),e.lineTo(.9691020434299804*n,.4347080674349939*o),e.lineTo(.7919190520392391*n,.616307190723145*o),e.lineTo(.779648372403934*n,.6288863854576189*o),e.lineTo(.7740466535716944*n,.647005242973332*o),e.lineTo(.7769464280973055*n,.6647628181337468*o),e.lineTo(.8187719012369075*n,.9211802328191082*o),e.lineTo(.8260655890472862*n,.9658971352498816*o),e.lineTo(.7814288443747758*n,o),e.lineTo(.7432371999943775*n,.9788868781153761*o),e.lineTo(.5242235294056399*n,.8578189712649151*o),e.lineTo(.509058281303118*n,.849438315417013*o),e.lineTo(.49094119809104253*n,.849438315417013*o),e.lineTo(.4757759499885207*n,.8578189712649151*o),e.lineTo(.2567643618231409*n,.9788868781153761*o),e.lineTo(.21857115562522422*n,o),e.lineTo(.1739323285293562*n,.9658971352498816*o),e.lineTo(.18122705755141377*n,.9211802328191082*o),e.lineTo(.22305409250853406*n,.6647628181337468*o),e.lineTo(.22595074339910845*n,.647005242973332*o),e.lineTo(.2203516275960661*n,.6288863854576189*o),e.lineTo(.20808146856660034*n,.616307190723145*o),e.lineTo(.030898997781698512*n,.4347080674349939*o),e.lineTo(0,.40304112159559813*o),e.lineTo(.017050361847088705*n,.3478650949789417*o),e.lineTo(.059751494008607714*n,.3413412114782689*o),e.lineTo(.3046116827074003*n,.3039298761896317*o),e.lineTo(.3215683355033921*n,.3013390437841371*o),e.lineTo(.33622703412415095*n,.29014093296241683*o),e.lineTo(.34381017878125136*n,.2739844955129827*o),e.lineTo(.45331701407562014*n,.04068531978415023*o),e.closePath()}nodeShapeInfo(t){const{width:e,height:n}=t.baseProps;return q.polygon([{x:.45331701407562014*e,y:.04068531978415023*n},{x:.47241283626581937*e,y:0},{x:.5275866431283414*e,y:0},{x:.5466824653185405*e,y:.04068531978415023*n},{x:.6561866975837122*e,y:.2739844955129827*n},{x:.6637719246641702*e,y:.29014093296241683*n},{x:.6784321851024475*e,y:.3013390437841371*n},{x:.6953883172925998*e,y:.3039298761896317*n},{x:.9402500678089105*e,y:.3413412114782689*n},{x:.9829501587587509*e,y:.3478650949789417*n},{x:e,y:.40304112159559813*n},{x:.9691020434299804*e,y:.4347080674349939*n},{x:.7919190520392391*e,y:.616307190723145*n},{x:.779648372403934*e,y:.6288863854576189*n},{x:.7740466535716944*e,y:.647005242973332*n},{x:.7769464280973055*e,y:.6647628181337468*n},{x:.8187719012369075*e,y:.9211802328191082*n},{x:.8260655890472862*e,y:.9658971352498816*n},{x:.7814288443747758*e,y:n},{x:.7432371999943775*e,y:.9788868781153761*n},{x:.5242235294056399*e,y:.8578189712649151*n},{x:.509058281303118*e,y:.849438315417013*n},{x:.49094119809104253*e,y:.849438315417013*n},{x:.4757759499885207*e,y:.8578189712649151*n},{x:.2567643618231409*e,y:.9788868781153761*n},{x:.21857115562522422*e,y:n},{x:.1739323285293562*e,y:.9658971352498816*n},{x:.18122705755141377*e,y:.9211802328191082*n},{x:.22305409250853406*e,y:.6647628181337468*n},{x:.22595074339910845*e,y:.647005242973332*n},{x:.2203516275960661*e,y:.6288863854576189*n},{x:.20808146856660034*e,y:.616307190723145*n},{x:.030898997781698512*e,y:.4347080674349939*n},{x:0,y:.40304112159559813*n},{x:.017050361847088705*e,y:.3478650949789417*n},{x:.059751494008607714*e,y:.3413412114782689*n},{x:.3046116827074003*e,y:.3039298761896317*n},{x:.3215683355033921*e,y:.3013390437841371*n},{x:.33622703412415095*e,y:.29014093296241683*n},{x:.34381017878125136*e,y:.2739844955129827*n},{x:.45331701407562014*e,y:.04068531978415023*n}])}textContentBounds(t){const e=t.baseProps,n={x:e.width*.059751494008607714,y:e.height*.3413412114782689},o={x:e.width*.3046116827074003,y:e.height*.3039298761896317},s=(n.y-o.y)/(n.x-o.x),r=n.y,i=.22595074339910845*e.width,a=s*i+r,c={x:i,y:a,with:e.width-i*2,height:e.height*.849438315417013-a};return{x:c.x+le,y:c.y+le,width:c.with-le*2,height:c.height-le*2}}fullTextNodeHeight(t){const e=t.baseProps;return e.width*.059751494008607714,e.height*.3413412114782689,e.width*.3046116827074003,e.height*.3039298761896317,(t.renderText.height+2*le)/.849438315417013}getConnectAnchor(){return super.getConnectAnchor()}}const Wt=class Wt extends en{constructor(e,n){super(e,n);p(this,"type",v.Shape);p(this,"transform",re.generateMatrix());p(this,"renderText");this.props.set(I.Base,new ie),this.props.set(I.Shape,new Oe),this.props.set(I.Color,new tt),this.props.set(I.Border,new Ae),this.props.set(I.Text,new Ge),this.props.set(I.TextParagraph,new qt),this.props.set(I.TextParagraphQuote,new Dt),this.renderText=new uo}validShapeCode(e){return!!Wt.drawerMap.get(e)}get borderProps(){return this.props.get(I.Border)}get colorProps(){return this.props.get(I.Color)}get textProps(){return this.props.get(I.Text)}get paragraphProps(){return this.props.get(I.TextParagraph)}get paragraphQuoteProps(){return this.props.get(I.TextParagraphQuote)}get shapeType(){return this.props.get(I.Shape).shapeCode}get drawer(){const e=Wt.drawerMap.get(this.shapeType);return e||Wt.drawerMap.get(K.RoundRect)}borderContains(e,n){const o=this.toLocal(e);return this.drawer.borderContains(this,o,n)}updateProps(e){super.updateProps(e);const n=e.find(i=>i.type===I.Text),o=e.find(i=>i.type===I.TextParagraph),s=e.find(i=>i.type===I.TextParagraphQuote),r=e.find(i=>i.type===I.Base);if(r&&this.updateTransformMatrix(),n||r||o||s){const i=this.drawer.textContentBounds(this);this.shapeType===K.PureText&&this.textProps.sizeMode!==We.fix&&this.textProps.verticalAlign!==at.Top&&(this.textProps.verticalAlign=at.Top),this.renderText.typesetting(this.graphicContext,this.textProps,i,this.paragraphProps,this.paragraphQuoteProps),this.shapeType===K.PureText&&this.textProps.sizeMode!==We.fix&&(this.baseProps.height=this.renderText.y+this.renderText.height,this.renderText.rect.height=this.renderText.height+4,this.textProps.sizeMode===We.autoWidth&&(this.baseProps.width=this.renderText.width+4))}}modifyPosInEditing(e){if(this.shapeType===K.PureText)return!1;const n=this.drawer.textContentBounds(this);return this.renderText.modifyPosInEditing(n,e)}resetFromEditing(){const e=this.drawer.textContentBounds(this);return this.renderText.resetFromEditing(e)}contains(e){const{width:n,height:o}=this.baseProps,s=this.toLocal(e);return M.rectContains(s,new D(0,0,n,o))}drawOnGLCtx(e){const n=this.shapeType;let o=Wt.drawerMap.get(n);o||(console.error("取不到drawer,使用rect兜底!"),o=Wt.drawerMap.get(K.Rect)),e.save(),e.beginPath();const{a:s,b:r,c:i,d:a,e:c,f:h}=this.globalTransform();e.transform(s,r,i,a,c,h),o.draw(this,e),this.drawText(e),e.restore()}drawText(e){if(this.shapeType===K.PureText){const a=new m;this.renderText.draw(e,a,1);return}const{x:n,y:o,width:s,height:r}=this.getTextContentRect();e.save(),e.beginPath(),e.rect(n,o,s,r),e.clip();const i=new m;this.renderText.draw(e,i,1),e.restore()}getStretchMinSize(){return new m(20,20)}draw(){this.drawOnGLCtx(this.graphicContext)}getTextContentRect(){const e=this.shapeType;let n=Wt.drawerMap.get(e);return n||(console.error("取不到drawer,使用rect兜底!"),n=Wt.drawerMap.get(K.Rect)),n.textContentBounds(this)}isEmptyText(){return this.renderText.isEmptyText()}getConnectAnchor(){return this.drawer.getConnectAnchor()}static load(e,n,o,s,r,i){const a=new Wt(e,i);return a.type=n,a.zIndex=o,a.setParent(r),a.updateProps(s),a}};p(Wt,"drawerMap",new Map([[K.PureText,new Wg],[K.Ellipse,new _g],[K.Rect,new Fg],[K.RoundRect,new Ug],[K.Triangle,new Yg],[K.Diamond,new Gg],[K.Parallelogram,new $g],[K.Octagon,new Qg],[K.Hexagon,new Kg],[K.Trapezoid,new jg],[K.Pentagon,new Vg],[K.Star,new ef],[K.Cloud,new qg],[K.Cross,new Jg]]));let vt=Wt;class jn extends Fn{constructor(e,n){super(e,n);p(this,"type",v.SVG);p(this,"imgBitmap",null);p(this,"svgCode","");this.props.set(I.Base,new ie),this.props.set(I.Border,new Ae),this.props.set(I.Svg,new Wn),this.props.set(I.Crop,new Sn)}get svgUrl(){return this.props.get(I.Svg).url}get svgProps(){return this.props.get(I.Svg)}setSvgCode(e){this.svgCode=e}static load(e,n,o,s,r,i){const a=new jn(e,i);return a.type=n,a.zIndex=o,a.setParent(r),a.updateProps(s),a}}class an{static getNumFromString(t){try{const e=t.match(/(\d+)/);return e&&e[1]?parseInt(e[1],10):100}catch{return console.error("从字符串中获取num出错:",t),100}}static trimSvgCode(t){const n=new DOMParser().parseFromString(t,"image/svg+xml").documentElement,o=n.getAttribute("width"),s=n.getAttribute("height");n.removeAttribute("width"),n.removeAttribute("height");const r=n.style.width,i=n.style.height;n.style.removeProperty("width"),n.style.removeProperty("height");let a=100,c=100;return o!==null?a=this.getNumFromString(o):r!==""&&(a=this.getNumFromString(r)),s!==null?c=this.getNumFromString(s):i!==""&&(c=this.getNumFromString(i)),n.getAttribute("viewBox")||n.setAttribute("viewBox",`0 0 ${a} ${c}`),{svgCode:n.outerHTML,width:a,height:c}}}class Po extends en{constructor(e,n){super(e,n);p(this,"type",v.Group);this.props.set(I.Base,new ie)}get globalPos(){return this.nameGlobalTransform().crossPoint(new m)}computeBasePropsByChildren(){const e=[];for(const s of this.children)e.push(s.baseProps);const n=M.getBoundsByBasePropsList(e),o=D.rectNode2Rect(n);return ie.create({x:o.x,y:o.y,width:o.width,height:o.height})}drawOnGLCtx(e){}getTextContentRect(){return this.baseProps}canBeConnected(){return!1}transToLocalPoint(e){return this.nameGlobalTransform().inverseMatrix().crossPoint(e)}contains(e,n=1){const{width:o,height:s}=this.baseProps,r=this.transToLocalPoint(e);return M.rectContains(r,new D(0,0,o,s))}toGlobal(e){return this.nameGlobalTransform().crossPoint(e)}nameGlobalTransform(){const e=this.selfTransform();return this.globalTransform().crossProduct(e)}selfTransform(){const{x:e,y:n}=this.baseProps;return re.generateMatrix().translate(e,n)}updateTransformMatrix(){}static load(e,n,o,s,r,i){const a=new Po(e,i);return a.type=n,a.zIndex=o,a.setParent(r),a.updateProps(s),a}}class rs extends en{constructor(e,n){super(e,n);p(this,"type",v.Section);this.props.set(I.Base,new ie),this.props.set(I.Border,new Ae),this.props.set(I.Color,new tt),this.props.set(I.Slide,new Mt)}get borderProps(){return this.props.get(I.Border)}get colorProps(){return this.props.get(I.Color)}updateProps(e){super.updateProps(e),e.find(o=>o.type===I.Base)&&this.updateTransformMatrix()}drawOnGLCtx(e){e.save();const n=this.baseProps,{a:o,b:s,c:r,d:i,e:a,f:c}=this.globalTransform();e.transform(o,s,r,i,a,c);const h=this.colorProps,d=this.borderProps;e.beginPath(),e.roundRect(0,0,n.width,n.height,6),h.color!==""&&(e.fillStyle=h.color,e.globalAlpha=h.alpha,e.fill()),d.color!==""&&d.dashType!==et.None&&(M.setDashLine(d,e),e.strokeStyle=d.color,e.lineWidth=d.width,e.globalAlpha=d.alpha,e.stroke()),e.restore()}static load(e,n,o,s,r,i){const a=new rs(e,i);return a.type=n,a.zIndex=o,a.setParent(r),a.updateProps(s),a}canQuickCreate(){return!1}getTextContentRect(){return this.baseProps}}class bo extends en{constructor(e,n){super(e,n);p(this,"type",v.SlideContainer);this.props.set(I.Base,new ie),this.props.set(I.Slide,new Mt)}get slideProps(){return this.props.get(I.Slide)}updateProps(e){super.updateProps(e),e.find(o=>o.type===I.Base)&&this.updateTransformMatrix()}drawOnGLCtx(e){const{width:n,height:o}=this.baseProps,{a:s,b:r,c:i,d:a,e:c,f:h}=this.globalTransform();e.save(),e.transform(s,r,i,a,c,h),e.shadowColor="rgba(0, 0, 0, 0.1)",e.shadowBlur=15,e.shadowOffsetX=0,e.shadowOffsetY=6,e.fillStyle="rgba(255, 255, 255, 0.6)",e.beginPath(),e.roundRect(0,0,n,o,8),e.fill(),e.shadowColor="transparent",e.fillStyle="rgba(240, 242, 245, 0.5)",e.fill(),e.strokeStyle="rgba(0, 0, 0, 0.1)",e.lineWidth=1,e.stroke(),e.restore()}canQuickCreate(){return!1}getTextContentRect(){return this.baseProps}static load(e,n,o,s,r,i){const a=new bo(e,i);return a.type=n,a.zIndex=o,a.setParent(r),a.updateProps(s),a}getChildIdByIndex(e){const n=this.slideProps.children;let o=0;for(let s=0;s<n.length;s++){if(e<o+n[s].ids.length){const r=e-o;return n[s].ids[r]}o+=n[s].ids.length}return null}getTotalCount(){return this.slideProps.children.reduce((n,o)=>n+o.ids.length,0)}}const ms=class ms{static getInstance(){return this.instance||(this.instance=new ms),this.instance}create(t,e,n,o,s,r){switch(e){case v.Line:return Ct.load(t,e,n,o,s,r);case v.SVG:return jn.load(t,e,n,o,s,r);case v.IMG:return Yn.load(t,e,n,o,s,r);case v.Section:return rs.load(t,e,n,o,s,r);case v.Group:return Po.load(t,e,n,o,s,r);case v.Checkbox:return Yo.load(t,e,n,o,s,r);case v.CheckboxText:return Un.load(t,e,n,o,s,r);case v.SlideContainer:return bo.load(t,e,n,o,s,r);case v.Shape:default:return vt.load(t,e,n,o,s,r)}}createByNodeInfo(t,e,n){const o=M.convertCapInfoToProps(t.capInfo);return this.create(t.id,t.type,t.zIndex,o,e,n)}};p(ms,"instance",null);let It=ms;class pr extends en{constructor(e){const o=document.createElement("canvas").getContext("2d");super(e,o);p(this,"type",v.ROOT);p(this,"transform",re.generateMatrix())}updateProps(e){}drawOnGLCtx(e){}getTextContentRect(){return new D}toGlobal(e){return e}toLocal(e){return e}}const is=800;class Pc{static async getImageSize(t){return new Promise((e,n)=>{const o=URL.createObjectURL(t),s=new Image;s.crossOrigin="anonymous",s.onload=()=>{let r=s.naturalWidth*.5,i=s.naturalHeight*.5;URL.revokeObjectURL(o);const a=r/i;r>i&&r>is?(r=is,i=r/a):i>r&&i>is&&(i=is,r=i*a),e({width:r,height:i})},s.onerror=()=>{URL.revokeObjectURL(o),n(new Error("无法加载图片"))},s.src=o})}}class At extends yn{constructor(){super(...arguments);p(this,"type",Xe.RemoveNode)}static create(e){return new At({idList:e})}clone(){const e=JSON.parse(JSON.stringify(this.data));return new At(e,this.meta)}}class gr{}class bc extends gr{handle(t,e,n){const o=e.find(i=>i.type===I.Connect);if(!o)return;const{start:s,end:r}=o;if(s!==void 0)if(s!==null){const i=n.nodeManager.getNode(s.objectId)||null;n.nodeManager.addLink(t,i,!0)}else n.nodeManager.addLink(t,null,!0);if(r!==void 0)if(r!==null){const i=n.nodeManager.getNode(r.objectId)||null;n.nodeManager.addLink(t,i,!1)}else n.nodeManager.addLink(t,null,!1)}}class tf extends gr{handle(t,e,n){if(!e.find(r=>r.type===I.Image)||t.type!==v.IMG)return;const s=t;n.asyncRenderNodeManager.addRenderNode(s)}}let nf=class extends gr{handle(t,e,n){const o=e.find(r=>r.type===I.Svg);if(!o||t.type!==v.SVG)return;const s=t;if(s.svgProps.useCode){const r=an.trimSvgCode(s.svgProps.code);s.setSvgCode(r.svgCode),n.asyncRenderNodeManager.addRenderNode(s);return}n.resourceManager.loadSvgUrl(o.url).then(r=>{const i=an.trimSvgCode(r);s.setSvgCode(i.svgCode),n.asyncRenderNodeManager.addRenderNode(s)}).catch(r=>{console.error("加载图片出现问题",r),s.setBroken(),n.renderManager.dirtyDraw(t.getBounds())})}};class Mc extends hn{constructor(){super(...arguments);p(this,"type",Xe.AddNode);p(this,"handlers",[new bc,new tf,new nf])}execData(e,n){const o=e.nodes;for(const s of o)this.execNodeInfo(s,n);n.renderManager.addContentRenderTask()}execNodeInfo(e,n){const o=n.gmlRender.glCtx,s=n.nodeManager.getParentNode(e.parentId),r=It.getInstance().create(e.id,e.type,e.zIndex,e.props,s,o);n.nodeManager.addNode(r);for(const i of this.handlers)i.handle(r,e.props,n)}reverseLog(e,n){const o=e.nodes.map(s=>s.id);return new At({idList:o})}}class Le extends yn{constructor(){super(...arguments);p(this,"type",Xe.AddNode)}static create(e){return new Le({nodes:[e]})}clone(){const e=JSON.parse(JSON.stringify(this.data));return new Le(e,this.meta)}}class Sc extends hn{constructor(){super(...arguments);p(this,"type",Xe.RemoveNode)}execData(e,n){for(const o of e.idList)n.nodeManager.getNode(o)&&n.nodeManager.removeNode(o);n.renderManager.addContentRenderTask(),n.renderManager.addAuxiliaryDrawTask()}reverseLog(e,n){var s;const o=[];for(const r of e.idList){const i=n.nodeManager.getNode(r);if(!i){console.error("错误,生成逆消息时节点不存在:",r);continue}const a=[...i.props.values()];o.push({id:i.id,type:i.type,zIndex:i.zIndex,parentId:((s=i.parent)==null?void 0:s.id)||Mn,props:a})}return new Le({nodes:o})}}class U extends yn{constructor(){super(...arguments);p(this,"type",Xe.UpdateNode)}static create(e,n,o){const s={id:e,props:n};return new U({infos:[s]},o)}clone(){const e=JSON.parse(JSON.stringify(this.data));return new U(e,this.meta)}}class vc extends hn{constructor(){super(...arguments);p(this,"type",Xe.UpdateNode);p(this,"handlers",[new bc])}execData(e,n){for(const o of e.infos)this.execNodeInfo(o,n);n.renderManager.addContentRenderTask()}execNodeInfo(e,n){const{id:o,zIndex:s,props:r,parentId:i}=e,a=n.nodeManager.getNode(o);if(!a){console.error("错误:节点不存在:",o);return}if(this.removeIndexNode(a,n),s!==void 0&&(a.zIndex=s),this.changeParent(a,n,i),r.length>0){a.updateProps(r);for(const c of this.handlers)c.handle(a,r,n)}this.addIndexNode(a,n),n.auxiliaryManager.selectManager.include(a)&&(n.auxiliaryManager.selectManager.refreshSelectStatus(),n.renderManager.addAuxiliaryDrawTask(),n.auxiliaryManager.slotManager.addSlotState(ze.FocusPropsChange,!0))}changeParent(e,n,o){if(o===void 0||o===e.parent.id)return;const s=n.nodeManager.getNode(o);s&&(e.parent.children.delete(e),s.children.add(e),e.parent=s)}removeIndexNode(e,n){n.nodeManager.removeIndexNode(e.getRectNode());for(const o of e.children)this.removeIndexNode(o,n)}addIndexNode(e,n){n.nodeManager.addIndexNode(e.getRectNode());for(const o of e.children)this.addIndexNode(o,n)}reverseLog(e,n){const o=[];for(const s of e.infos){const r=n.nodeManager.getNode(s.id);if(!r)continue;const i=r.parent?r.parent.id:n.nodeManager.root.id,a=r.serializeTo(),c=M.convertCapInfoToProps(a.capInfo);o.push({id:r.id,zIndex:r.zIndex,props:c,parentId:i})}return new U({infos:o})}}class xe extends yn{constructor(){super(...arguments);p(this,"type",Xe.SelectNode)}static create(e){return new xe({idList:e})}clone(){const e=JSON.parse(JSON.stringify(this.data));return new xe(e,this.meta)}}class Ic extends hn{constructor(){super(...arguments);p(this,"type",Xe.SelectNode)}execData(e,n){const o=e.idList,s=new Set;o.forEach(r=>{const i=n.nodeManager.getNode(r);i&&s.add(i)}),n.auxiliaryManager.selectManager.set(s),n.renderManager.addAuxiliaryDrawTask(),n.auxiliaryManager.slotManager.addSlotState(ze.FocusPropsChange,!0)}reverseLog(e,n){const s=n.auxiliaryManager.selectManager.getSelectNodes().map(r=>r.id);return new xe({idList:s})}}class z extends yn{constructor(){super(null);p(this,"type",Xe.End)}clone(){return new z}}class Tc extends hn{constructor(){super(...arguments);p(this,"type",Xe.Start)}execData(e,n){}reverseLog(e,n){return new z}}class W extends yn{constructor(){super(null);p(this,"type",Xe.Start)}clone(){return new W}}class Lc extends hn{constructor(){super(...arguments);p(this,"type",Xe.End)}execData(e,n){}reverseLog(e,n){return new W}}class Cc extends hn{constructor(){super(...arguments);p(this,"type",Xe.TextFocus)}checkValidNode(e,n){const o=n.nodeManager.getNode(e);if(!o)throw new Error("错误:节点不存在:"+e);const s=o.renderText;return{node:o,renderText:s}}execData(e,n){var a;const{focusType:o,blur:s,selection:r,focus:i}=e;if(o===Lt.Empty){n.auxiliaryManager.remove(N.TextSelection);return}if(n.renderManager.addAuxiliaryDrawTask(),o===Lt.Focus){n.auxiliaryManager.remove(N.TextSelection);const{id:c,textCursorPosition:h}=i,{node:d,renderText:u}=this.checkValidNode(c,n);d.modifyPosInEditing(h)&&n.renderManager.addContentRenderTask(),n.inputManager.focus({node:d,renderText:u,textCursorPosition:h}),u.isEmptyText()?d.type===v.Shape&&n.auxiliaryManager.addOrUpdate(N.PlaceHolder,{node:d}):n.auxiliaryManager.remove(N.PlaceHolder),n.auxiliaryManager.selectManager.refreshSelectStatus();return}if(o===Lt.Selection){const{id:c,start:h,end:d}=r,{node:u,renderText:g}=this.checkValidNode(c,n);n.inputManager.selection(u,g,h,d);const f=(a=n.inputManager.selectionManager.selectionInfo)==null?void 0:a.selectionList;f&&(n.auxiliaryManager.addOrUpdate(N.TextSelection,{selectionList:f,node:u}),n.renderManager.addAuxiliaryDrawTask()),n.auxiliaryManager.remove(N.PlaceHolder),n.auxiliaryManager.slotManager.addSlotState(ze.FocusPropsChange,!0);return}if(o===Lt.Blur){n.inputManager.blur(),n.auxiliaryManager.remove(N.PlaceHolder);return}}reverseLog(e,n){const{focusType:o}=e,s=n.inputManager.editTextInfo,r=n.inputManager.selectionManager.selectionInfo;if(o===Lt.Focus){const i=e.focus.id;return s?r?ee.selection(s.node.id,r.start,r.end):ee.focus(s.node.id,s.textCursorPosition):ee.blur(i)}if(o===Lt.Blur)return s?r?ee.selection(s.node.id,r.start,r.end):ee.focus(s.node.id,s.textCursorPosition):(console.warn("选中消息不符合预期,已容错处理"),ee.empty());if(o===Lt.Selection){const i=e.selection.id;return s?r?ee.selection(s.node.id,r.start,r.end):ee.focus(s.node.id,s.textCursorPosition):ee.blur(i)}return ee.empty()}}const Ac=[new Mc,new Sc,new vc,new Ic,new Cc,new Tc,new Lc];class kc{}class of extends kc{constructor(){super(...arguments);p(this,"slideContainer",null)}enable(e,n){if(e.meta.streaming||n.docState.docMode!==he.SLIDE_EDIT)return!1;const o=n.docState.slideStatus.slideContainer;return o?(this.slideContainer=o,!0):!1}handle(e,n){this.slideContainer&&(this.handleUpdateLog(e,n,this.slideContainer),this.handleAddLog(e,n,this.slideContainer),this.handleRemoveLog(e,n,this.slideContainer))}handleUpdateLog(e,n,o){var s;if(e.type===Xe.UpdateNode){const r=e.data;for(const i of r.infos){const a=n.nodeManager.getNode(i.id);if(!a)continue;if(((s=a.parent)==null?void 0:s.id)===o.id&&this.judgeOnlyPosChange(i.props,a)){this.judgeSlideEditCurrent(a,n)&&(console.log("协同端正在更新此幻灯片位置,触发器重置视图"),setTimeout(()=>{n.slideManager.refocusSlide(n,50)},10));continue}if(a.id===o.id){const h=n.renderManager.getScale(),d=this.judgeOnlyPosChange(i.props,a);if(d){n.renderManager.scroll(d.x*h,d.y*h);continue}}const c=M.judgeSlideSectionChildren(a,o);c&&n.slideManager.slideCoverManager.updateSlideCover(c)}}}judgeSlideEditCurrent(e,n){const o=n.docState.slideStatus;return o.slideContainer?o.slideContainer.getChildIdByIndex(o.currentIndex)===e.id:!1}judgeOnlyPosChange(e,n){if(e.length!==1)return null;const o=e[0];if(o.type!==I.Base)return null;const s=n.baseProps,r=o.width===void 0||Math.abs(o.width-s.width)<.1;if(!(o.height===void 0||Math.abs(o.height-s.height)<.1)||!r)return null;if(o.x!==void 0||o.y!==void 0){const a=new m;return o.x!==void 0&&(a.x=o.x-s.x),o.y!==void 0&&(a.y=o.y-s.y),a}return null}handleAddLog(e,n,o){if(e.type===Xe.AddNode){const s=e.data;for(const r of s.nodes){const i=n.nodeManager.getNode(r.parentId);if(!i)continue;const a=M.judgeSlideSectionChildren(i,o);a&&n.slideManager.slideCoverManager.updateSlideCover(a)}}}handleRemoveLog(e,n,o){if(e.type===Xe.RemoveNode){const s=e.data;for(const r of s.idList){const i=n.nodeManager.getNode(r);if(!i)continue;const a=M.judgeSlideSectionChildren(i,o);a&&n.slideManager.slideCoverManager.updateSlideCover(a)}}}}class sf extends kc{constructor(){super(...arguments);p(this,"slideContainer",null)}enable(e,n){if(e.meta.streaming||n.docState.docMode!==he.SLIDE_EDIT)return!1;const o=n.docState.slideStatus.slideContainer;return o?(this.slideContainer=o,!0):!1}handle(e,n){this.slideContainer&&this.handleUpdateLog(e,n,this.slideContainer)}handleUpdateLog(e,n,o){if(e.type===Xe.UpdateNode){const s=e.data;for(const r of s.infos){const i=n.nodeManager.getNode(r.id);!i||i.id!==o.id||!r.props.find(c=>c.type===I.Slide)||n.slideManager.slideCoverManager.updateSlideContainerCover(o)}}}}class Nc{constructor(t){p(this,"executors",new Map);p(this,"ctx");p(this,"beforeInterceptors",[new of,new sf]);p(this,"afterInterceptors",[]);for(const e of t)this.executors.set(e.type,e)}init(t){this.ctx=t}exec(t,e){const n=this.executors.get(t.type);if(!n){console.error("缺乏对应的消息处理器,已忽略该消息");return}for(const o of this.beforeInterceptors)o.enable(t,this.ctx)&&o.handle(t,this.ctx);n.exec(t,e);for(const o of this.afterInterceptors)o.enable(t,this.ctx)&&o.handle(t,this.ctx)}}class Bc{constructor(){p(this,"undoStack",[]);p(this,"redoStack",[])}add(t){const e=t.reverse();this.undoStack.push(e),this.redoStack=[]}undo(t,e){const n=this.undoStack.pop()||null;if(!n)return null;for(const o of n.actionLogs)t.exec(o,e);return this.redoStack.push(n.reverse()),n}redo(t,e){const n=this.redoStack.pop()||null;if(!n)return null;for(const o of n.actionLogs)t.exec(o,e);return this.undoStack.push(n.reverse()),n}}class as{constructor(t=[]){p(this,"actionLogs",[]);this.actionLogs=t}reverse(){const t=new as;for(let e=this.actionLogs.length-1;e>-1;e--){const n=this.actionLogs[e];t.actionLogs.push(n.reverse())}return t}}class Rc{constructor(){p(this,"cacheLogs",[]);p(this,"duringGroup",!1)}add(t){t.type===Xe.Start&&(this.duringGroup=!0),this.cacheLogs.push(t),t.type===Xe.End&&(this.duringGroup=!1)}getActionGroup(){if(this.duringGroup)return null;const t=new as(this.cacheLogs);return this.cacheLogs=[],t}}const Ec=new Set([Xe.Start,Xe.End,Xe.SelectNode,Xe.TextFocus]);class Hc{constructor(t,e,n,o,s,r,i,a,c,h,d,u){p(this,"execCtx");p(this,"executor");p(this,"undoManager");p(this,"networkPlugin",null);p(this,"actionCache");p(this,"renderManager");p(this,"docState");this.executor=new Nc(Ac),this.undoManager=new Bc,this.renderManager=r,this.execCtx={inputManager:e,nodeManager:t,gmlRender:n,auxiliaryManager:o,toolManager:s,renderManager:this.renderManager,resourceManager:i,idGenerator:c,slotManager:h,asyncRenderNodeManager:d,docState:a,slideManager:u},this.actionCache=new Rc,this.docState=a}addNetworkPlugin(t){this.networkPlugin=t}execAction(t){var n;this.dealDocSeq(t),this.executor.exec(t,this.execCtx),Ec.has(t.type)||(n=this.networkPlugin)==null||n.addMessage(t),this.actionCache.add(t);const e=this.actionCache.getActionGroup();e&&this.undoManager.add(e)}dealDocSeq(t){Ec.has(t.type)||this.docState.seq++}undo(){var e;const t=this.undoManager.undo(this.executor,this.execCtx);t&&((e=this.networkPlugin)==null||e.addActionGroup(t))}redo(){var e;const t=this.undoManager.redo(this.executor,this.execCtx);t&&((e=this.networkPlugin)==null||e.addActionGroup(t))}}function rf(l){return l.type===Xe.AddNode?{addNodeData:{data:l.data.nodes.map(n=>{const o=n.props,s=new Map;o.forEach(a=>s.set(a.type,a));const r=M.convertPropsToCapInfo(s);return{id:n.id,type:n.type,zIndex:n.zIndex,parentId:n.parentId,capInfo:r}})}}:l.type===Xe.UpdateNode?{updateNodeData:{data:l.data.infos.map(n=>{const o=n.props,s=new Map;o.forEach(a=>s.set(a.type,a));const r=M.convertPropsToCapInfo(s);return{id:n.id,zIndex:n.zIndex,parentId:n.parentId,capInfo:r}})}}:l instanceof At?{removeNodeData:{data:l.data.idList}}:null}function af(l){const{updateNodeData:t,addNodeData:e,removeNodeData:n}=l;if(e){const o=[];for(const s of e.data)o.push({id:s.id,parentId:s.parentId,zIndex:s.zIndex,type:s.type,props:M.convertCapInfoToProps(s.capInfo)});return new Le({nodes:o})}if(t){const o=[];for(const s of t.data)o.push({id:s.id,zIndex:s.zIndex,parentId:s.parentId,props:M.convertCapInfoToProps(s.capInfo)});return new U({infos:o})}if(n)return At.create(n.data);throw new Error("类型转换错误!")}const fr=.04,yr=4;class Dc{static isMobile(){const t=navigator.userAgent||navigator.vendor||window.opera;if(/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini|mobile/i.test(t.toLowerCase()))return!0;const n="ontouchstart"in window||navigator.maxTouchPoints>0,o=window.innerWidth<768;return n&&o}}const cf=70,lf=10;class hf{zoomScale(t,e,n){const o=n.getScale();let s=t;o*t>yr&&(s=yr/o),o*t<fr&&(s=fr/o),this.zoomToScale(s,e,n.gmlRender),this.zoomToScale(s,e,n.auxiliaryManager.gmlRender);const r=n.getScale();n.slotManager.addSlotState(ze.Scale,r),n.addContentRenderTask(),n.addAuxiliaryDrawTask()}zoomToSelect(t){if(t.auxiliaryManager.selectManager.getSelectNodes().length===0)return;const n=t.auxiliaryManager.selectManager.getSelectBounds();this.zoomToBounds(n,t)}zoomToFit(t){if(t.nodeManager.nodeMap.size===0)return;const n=t.nodeManager.getNodeBounds();this.zoomToBounds(n,t)}zoomTo100(t){if(t.nodeManager.nodeMap.size===0)return;const n=t.nodeManager.getNodeBounds(),o=t.gmlRender.canvas.getBoundingClientRect(),s=window.devicePixelRatio,r=1*s,i=new m(.5*s*o.width,.5*s*o.height),a=new m(.5*(n.minX+n.maxX),.5*(n.minY+n.maxY)),c=new m(-a.x*r+i.x,-a.y*r+i.y);this.zoomToMatrix(r,c.x,c.y,t.gmlRender),this.zoomToMatrix(r,c.x,c.y,t.auxiliaryManager.gmlRender);const h=t.getScale();t.slotManager.addSlotState(ze.Scale,h),t.addContentRenderTask(),t.addAuxiliaryDrawTask()}zoomToBounds(t,e,n){const o=Dc.isMobile()?lf:cf,s=n!==void 0?n:o,r=D.rectNode2Rect(t),i=e.gmlRender.canvas.getBoundingClientRect(),a=window.devicePixelRatio,c=i.width-s*2*a,h=i.height-s*2*a,d=c/r.width,u=h/r.height,g=Math.min(d,u)*a,f=new m(.5*a*i.width,.5*a*i.height),y=new m(.5*(t.minX+t.maxX),.5*(t.minY+t.maxY)),P=new m(-y.x*g+f.x,-y.y*g+f.y);this.zoomToMatrix(g,P.x,P.y,e.gmlRender),this.zoomToMatrix(g,P.x,P.y,e.auxiliaryManager.gmlRender);const b=e.getScale();e.slotManager.addSlotState(ze.Scale,b),e.addContentRenderTask(),e.addAuxiliaryDrawTask()}zoomToScale(t,e,n){n.scale(t,t,e);const o=n.glCtx,{a:s,b:r,c:i,d:a,e:c,f:h}=n.globalTransform;o.setTransform(s,r,i,a,c,h)}zoomToMatrix(t,e,n,o){const s=t,r=t,i=e,a=n;o.setTransform(s,0,0,r,i,a)}}class df{exportToOfflineCanvas(t,e,n,o){const s=D.rectNode2Rect(t),r=document.createElement("canvas");r.width=n*s.width,r.height=n*s.height;const i=r.getContext("2d");i.scale(n,n),i.translate(-s.x,-s.y);let a=e.searchNodesByRectNode(t);a=M.sortGraphics(a),i.save(),o&&(i.fillStyle=o,i.fillRect(s.x,s.y,s.width,s.height)),i.restore();for(const c of a)c.drawOnGLCtx(i);return r}exportToOfflineCanvasByFilterNodes(t,e,n,o,s){const r=D.rectNode2Rect(t),i=document.createElement("canvas");i.width=n*r.width,i.height=n*r.height;const a=i.getContext("2d");a.scale(n,n),a.translate(-r.x,-r.y);let c=e.searchNodesByRectNode(t);c=M.sortGraphics(c),a.save(),o&&(a.fillStyle=o,a.fillRect(r.x,r.y,r.width,r.height)),a.restore();for(const h of c)s.has(h)&&h.drawOnGLCtx(a);return i}}class Oc{constructor(t,e,n,o){p(this,"gmlRender");p(this,"nodeManager");p(this,"auxiliaryManager");p(this,"slotManager");p(this,"zoomWorker",new hf);p(this,"exportWorker",new df);p(this,"working",!1);p(this,"contentDraw",!1);p(this,"auxiliaryDraw",!1);p(this,"focusId");p(this,"tickerRun",()=>{if(this.contentDraw){const t=this.judgeFocusNode();t?this.auxiliaryManager.selectManager.docState.docMode===he.SLIDE_PLAY?this.drawInPlayingMode(t):this.drawInFocusMode(t):this.drawInNormalMode()}this.auxiliaryDraw&&(this.auxiliaryManager.redraw(),this.auxiliaryDraw=!1),this.working&&requestAnimationFrame(this.tickerRun)});p(this,"drawInNormalMode",()=>{const t=this.gmlRender.getViewPortBounds(),e=this.nodeManager.tree.search(t),n=new Set;for(const s of e){const r=this.nodeManager.nodeMap.get(s.id);r&&n.add(r)}let o=[...n];o=M.sortGraphics(o),this.gmlRender.dirtyDraw(t,o),this.contentDraw=!1});p(this,"drawInFocusMode",t=>{const e=this.gmlRender.getViewPortBounds(),n=new Set;M.getAllChildren(t,n);const o=M.sortGraphics([t,...n]);this.gmlRender.dirtyDraw(e,o),this.contentDraw=!1});p(this,"drawInPlayingMode",t=>{this.gmlRender.getViewPortBounds();const e=t.getBounds(),n=new Set;M.getAllChildren(t,n);const o=M.sortGraphics([t,...n]);this.gmlRender.dirtyDraw(e,o),this.contentDraw=!1});this.gmlRender=t,this.nodeManager=e,this.auxiliaryManager=n,this.slotManager=o}getScale(){return this.gmlRender.getScale()}zoomScale(t,e){this.zoomWorker.zoomScale(t,e,this)}zoomToFit(){this.zoomWorker.zoomToFit(this)}zoomToSelect(){this.zoomWorker.zoomToSelect(this)}zoomTo100(){this.zoomWorker.zoomTo100(this)}exportOfflineCanvas(t,e,n){return this.exportWorker.exportToOfflineCanvas(t,this.nodeManager,e,n)}scroll(t,e){this.scrollTo(t,e,this.gmlRender),this.scrollTo(t,e,this.auxiliaryManager.gmlRender),this.addContentRenderTask(),this.addAuxiliaryDrawTask()}start(){this.working=!0,this.tickerRun()}stop(){this.working=!1}addAuxiliaryDrawTask(){this.auxiliaryDraw=!0}addContentRenderTask(){this.contentDraw=!0}dirtyDraw(t){const e=this.nodeManager.tree.search(t),n=new Set;for(const r of e){const i=this.nodeManager.nodeMap.get(r.id);i&&n.add(i)}let o=[...n];o=M.sortGraphics(o);const s=this.judgeFocusNode();if(s){const r=new Set([s]);M.getAllChildren(s,r),o=o.filter(i=>r.has(i))}console.log("njx debug:====>",o.map(r=>r.id)),this.gmlRender.dirtyDraw(t,o)}judgeFocusNode(){if(this.focusId){const t=this.nodeManager.nodeMap.get(this.focusId);if(t)return t}return null}scrollTo(t,e,n){const o=n.getScale();n.translation(-t/o,-e/o);const s=n.glCtx,{a:r,b:i,c:a,d:c,e:h,f:d}=n.globalTransform;s.setTransform(r,i,a,c,h,d)}}const uf={default:"default"};class Xc{constructor(){p(this,"currentCursor","default");p(this,"currentAngle")}resetCursor(){this.currentCursor=null}setCursor(t,e){if(this.currentCursor!==null){const o=e!==void 0?`${t}-${e}`:t;if((this.currentAngle!==void 0?`${this.currentCursor}-${this.currentAngle}`:this.currentCursor)===o)return}if(t==="stretch"&&e!==void 0){const o=this.generateRotatedStretchCursorSvg(e),r=`url("data:image/svg+xml,${encodeURIComponent(o)}") 16 16, auto`;document.body.style.cursor=r,this.currentCursor=t,this.currentAngle=e;return}if(t==="rotate"&&e!==void 0){const o=this.generateRotatedRotateCursorSvg(e),r=`url("data:image/svg+xml,${encodeURIComponent(o)}") 16 16, auto`;document.body.style.cursor=r,this.currentCursor=t,this.currentAngle=e;return}const n=uf[t];n?document.body.style.cursor=n:document.body.style.cursor=t,this.currentCursor=t,this.currentAngle=void 0}generateRotatedStretchCursorSvg(t){return`<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32" fill="none">
|
|
6
6
|
<g transform="rotate(${t} 16 16)">
|
|
7
7
|
<mask id="path-1-outside-1_0_11070" maskUnits="userSpaceOnUse" x="5" y="10" width="22" height="12" fill="black">
|
|
8
8
|
<rect fill="white" x="5" y="10" width="22" height="12"/>
|
|
@@ -18,14 +18,14 @@
|
|
|
18
18
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M18.9997 6.58594L24.4139 12.0002L20.4477 12.0002C19.9824 16.4482 16.4477 19.9828 11.9997 20.4481L11.9997 24.4144L6.58545 19.0002L11.9996 13.586L11.9997 17.4237C14.7888 16.993 16.9926 14.7893 17.4233 12.0002H13.5855L18.9997 6.58594ZM18.4336 12.0002C18.4107 12.1726 18.3818 12.3431 18.3473 12.5117C17.7134 15.6096 15.1695 18.0117 11.9997 18.4341C11.6727 18.4776 11.339 18.5001 11.0001 18.5002L10.9997 16.0002L7.99966 19.0002L10.9997 22.0002L10.9997 19.5002C11.2931 19.5002 11.5831 19.4853 11.8688 19.4563C15.1163 19.1265 17.8234 16.9685 18.9447 14.0277C19.3033 13.0872 19.4997 12.0666 19.4997 11.0002L21.9997 11.0002L18.9997 8.00015L15.9997 11.0002H18.4997C18.4997 11.3392 18.4772 11.673 18.4336 12.0002Z" fill="white"/>
|
|
19
19
|
</g>
|
|
20
20
|
</g>
|
|
21
|
-
</svg>`}}class Vn{makeupDefaultProps(t,e,n,o){return this.makeupProps(t,e,n,1,o)}makePreviewProps(t,e,n){return this.makeupProps(t,e,n,.5)}}const
|
|
21
|
+
</svg>`}}class Vn{makeupDefaultProps(t,e,n,o){return this.makeupProps(t,e,n,1,o)}makePreviewProps(t,e,n){return this.makeupProps(t,e,n,.5)}}const Mo={[me.Status]:"#F2F3F5",[me.Data]:"#F0FBEF",[me.Operation]:"#E1EAFF",[me.Step]:"#E0E2FA",[me.Decision]:"#FEEAD2",[me.Others]:"#FEF1F1",[me.Section]:"#F4F2F3",[me.Line]:"",[me.Check]:"#B4B9F3",[me.Resource]:""},cn={[me.Status]:"#DEE0E3",[me.Data]:"#8EE085",[me.Operation]:"#82A7FC",[me.Step]:"#7B83EA",[me.Decision]:"#FFBA6B",[me.Others]:"#F98E8B",[me.Section]:"#C0A9BD",[me.Resource]:"",[me.Line]:"#000000",[me.Check]:"#7B83EA"};class pf extends Vn{makeupProps(t,e,n,o,s){const r=Is[e],i=Mo[r],a=cn[r],c=s?s.toLocal(n):n,{width:h,height:d}=this.computeDefaultSize();return[ie.create({x:c.x,y:c.y,width:h,height:d}),Ge.create({type:I.Text,fontSize:16,richText:"",sizeMode:We.autoHeight}),tt.create({color:i,alpha:o}),Ae.create({color:a,alpha:o}),new Oe(e)]}computeDefaultSize(){return{height:100,width:100}}}class gf extends Vn{makeupProps(t,e,n,o,s){const r=Uo[e],i=me.Section,a=Mo[i],c=cn[i],h=s?s.toLocal(n):n;return[ie.create({x:h.x,y:h.y,width:r.width,height:r.height}),tt.create({color:a,alpha:o}),Ae.create({color:c,alpha:o})]}}class ff extends Vn{makeupProps(t,e,n,o,s){const r=M.computeShapeCategory(v.Line,e),i=cn[r],a=s?s.toLocal(n):n,c=this.makeupLinePoints(a,e),h=D.rectNode2Rect(M.getBoundsByPoints(c));return[ie.create({x:h.x,y:h.y,width:h.width,height:h.height}),new Oe(e),je.create(c),Ae.create({color:i,alpha:o}),lt.create({rArrow:it.Arrow})]}makeupLinePoints(t,e){return e===de.PolyLine||e===de.RoundPolyLine||e===de.Curve?[{x:t.x,y:t.y+100},{x:t.x+.5*100,y:t.y+100},{x:t.x+.5*100,y:t.y},{x:t.x+100,y:t.y}]:[{x:t.x,y:t.y+100},{x:t.x+100,y:t.y}]}}class yf extends Vn{makeupProps(t,e,n,o,s){const a=s?s.toLocal(n):n,c=M.computeShapeCategory(v.CheckboxText),h=cn[c],d=Mo[c];return[ie.create({x:a.x,y:a.y,width:16,height:16}),tt.create({color:d,alpha:o}),Ae.create({color:h,alpha:o}),Qt.create({checkStatus:!0})]}}class xf extends Vn{makeupProps(t,e,n,o,s){const a=s?s.toLocal(n):n,c=M.computeShapeCategory(v.CheckboxText),h=cn[c],d=Mo[c];return[ie.create({x:a.x,y:a.y,width:102,height:32}),tt.create({color:d,alpha:o}),Ae.create({color:h,alpha:o}),Ge.create({type:I.Text,fontSize:16,richText:"<root><p>Checkbox</p></root>",sizeMode:We.autoWidth,horizonAlign:at.Top,verticalAlign:at.Top}),new Qt]}}class wf extends Vn{makeupProps(t,e,n,o,s){me.Section;const r=s?s.toLocal(n):n;return[ie.create({x:r.x,y:r.y,width:200,height:180})]}}class mf{constructor(){p(this,"creatorMap",new Map([[v.Shape,new pf],[v.Section,new gf],[v.Line,new ff],[v.Checkbox,new yf],[v.CheckboxText,new xf],[v.SlideContainer,new wf]]))}getCreateHandler(t){return this.creatorMap.get(t)}makeupDefaultProps(t,e,n,o,s){const r=this.getCreateHandler(t);if(!r)throw new Error(`No create handler found for shape type: ${t}`);return r.makeupDefaultProps(e,n,o,s)}makeupPreviewProps(t,e,n,o){const s=this.getCreateHandler(t);if(!s)throw new Error(`No create handler found for shape type: ${t}`);return s.makePreviewProps(e,n,o)}}class Pf{constructor(){p(this,"prevDevicePixelRatio",window.devicePixelRatio)}resize(t){const e=window.devicePixelRatio;this.resizeCanvas(t.gmlRender,e),this.resizeCanvas(t.auxiliaryManager.gmlRender,e),t.renderManager.addAuxiliaryDrawTask(),t.renderManager.addContentRenderTask(),this.prevDevicePixelRatio=e}resizeCanvas(t,e){t.canvas.width=e*t.canvas.clientWidth,t.canvas.height=e*t.canvas.clientHeight;const n=t.glCtx;if(Math.abs(this.prevDevicePixelRatio-e)>.001){const h=t.transformToGlobal(new m);t.scale(e/this.prevDevicePixelRatio,e/this.prevDevicePixelRatio,h)}const{a:o,b:s,c:r,d:i,e:a,f:c}=t.globalTransform;n.setTransform(o,s,r,i,a,c)}}class Kn{}class bf extends Kn{handle(t,e){t.docState.resetSlideCovers();const n=t.docState;n.docMode=he.SLIDE_EDIT,n.slideStatus.slideContainer=e,n.slideStatus.currentIndex=0,t.slotManager.addSlotState(ze.DocMode,{docMode:he.SLIDE_EDIT});const s=n.slideStatus.slideContainer.slideProps.children[0].ids[0];t.focus(s,0,50),this.generateSlideCover(n.slideStatus,t)}async generateSlideCover(t,e){const n=t.slideContainer;if(!n)return;const o=n.slideProps.children;for(const s of o)for(const r of s.ids){const i=e.nodeManager.getNode(r);if(!i)continue;const a=await M.getSlideInfo(i,e);e.docState.slideStatus.slideCoverList.push(a),e.slotManager.addSlotState(ze.SlideCovers,{covers:e.docState.slideStatus.slideCoverList})}}}class Mf extends Kn{handle(t,e){const n=t.docState;n.docMode=he.SLIDE_PLAY,n.slideStatus.slideContainer=e,n.slideStatus.currentIndex=0,t.docState.changePermission({canEdit:!1}),t.slotManager.addSlotState(ze.DocMode,{docMode:he.SLIDE_PLAY});const s=n.slideStatus.slideContainer.slideProps.children[0].ids[0];t.focus(s)}}class Sf extends Kn{handle(t){t.docState.resetSlideCovers();const e=t.docState;e.docMode=he.SLIDE_EDIT,t.docState.changePermission({canEdit:!0}),t.slotManager.addSlotState(ze.DocMode,{docMode:he.SLIDE_EDIT});const n=e.slideStatus.slideContainer;if(!n)return"";const o=e.slideStatus.currentIndex,s=n.getChildIdByIndex(o)||"";setTimeout(()=>{t.focus(s,0,50)},100)}}class vf extends Kn{handle(t,e){const n=t.docState;n.docMode=he.BOARD,n.slideStatus.slideContainer=null,n.slideStatus.currentIndex=0,t.docState.changePermission({canEdit:!0}),t.slotManager.addSlotState(ze.DocMode,{docMode:he.BOARD}),t.focus()}}class If extends Kn{handle(t){const e=t.docState;e.docMode=he.SLIDE_PLAY,e.slideStatus.currentIndex=0,t.slotManager.addSlotState(ze.DocMode,{docMode:he.SLIDE_PLAY}),t.docState.changePermission({canEdit:!1});const n=e.slideStatus.slideContainer;if(!n)return"";const o=n.getChildIdByIndex(0)||"";t.focus(o),t.docState.resetSlideCovers()}}class Tf extends Kn{handle(t,e){const n=t.docState;n.docMode=he.BOARD,n.slideStatus.slideContainer=null,n.slideStatus.currentIndex=0,t.slotManager.addSlotState(ze.DocMode,{docMode:he.BOARD}),t.focus(),t.docState.resetSlideCovers()}}class Lf{constructor(){p(this,"currentMode",he.BOARD);p(this,"prevMode",he.BOARD);p(this,"switchHandlerMap",new Map);const t=new Map([[he.SLIDE_EDIT,new bf],[he.SLIDE_PLAY,new Mf]]),e=new Map([[he.SLIDE_EDIT,new Sf],[he.BOARD,new vf]]),n=new Map([[he.SLIDE_PLAY,new If],[he.BOARD,new Tf]]);this.switchHandlerMap.set(he.BOARD,t),this.switchHandlerMap.set(he.SLIDE_PLAY,e),this.switchHandlerMap.set(he.SLIDE_EDIT,n)}switchMode(t,e,n){if(this.prevMode=this.currentMode,this.currentMode=t,this.prevMode===this.currentMode)return;const o=this.switchHandlerMap.get(this.prevMode),s=o==null?void 0:o.get(this.currentMode);s&&n.slideContainer&&s.handle(e,n.slideContainer)}backToPrevMode(t,e){const n=this.prevMode;n!==this.currentMode&&this.switchMode(n,t,e)}}class zc{constructor(t,e,n,o,s,r,i,a,c,h,d,u,g,f,y,P,b){p(this,"nodeManager");p(this,"gmlRender");p(this,"detectors");p(this,"toolManager");p(this,"inputManager");p(this,"actionManager");p(this,"renderManager");p(this,"auxiliaryManager");p(this,"lastInteractiveEvent",null);p(this,"lastDiffTypeEvent",null);p(this,"docState");p(this,"idGenerator");p(this,"cursorManager");p(this,"previewManager");p(this,"resourceManager");p(this,"slotManager");p(this,"asyncRenderNodeManager");p(this,"cropManager");p(this,"slideManager");p(this,"docModeManager");p(this,"alignPoint",null);p(this,"createWorker",new mf);p(this,"resizeWorker",new Pf);this.nodeManager=t,this.gmlRender=e,this.detectors=n,this.toolManager=o,this.inputManager=s,this.actionManager=r,this.renderManager=i,this.auxiliaryManager=a,this.cursorManager=new Xc,this.docState=c,this.idGenerator=h,this.cursorManager=d,this.previewManager=u,this.resourceManager=g,this.slotManager=f,this.asyncRenderNodeManager=y,this.cropManager=P,this.slideManager=b,this.docModeManager=new Lf}detect(t,e){const n=this.detectors.get(t);return!n||!n.detect(e,this)?null:n.result}resize(){this.resizeWorker.resize(this)}addOrUpdate(t,e){this.auxiliaryManager.addOrUpdate(t,e),this.renderManager.addAuxiliaryDrawTask()}removeAuxGraphic(t){this.auxiliaryManager.remove(t),this.renderManager.addAuxiliaryDrawTask()}setCursor(t,e){this.cursorManager.setCursor(t,e)}getSelectNodes(){return this.auxiliaryManager.selectManager.selectNodes}execAction(t){this.actionManager.execAction(t)}reset(){this.auxiliaryManager.removeHoverGraphics(),this.auxiliaryManager.removeAlignGraphics(),this.renderManager.addAuxiliaryDrawTask()}inSelect(t){if(this.auxiliaryManager.selectManager.selectNodes.size===0)return!1;const e=this.auxiliaryManager.selectManager.getSelectBounds();return M.rectContains2(t,e)}refreshEvent(t){}refreshAllSvgNode(){for(const[t,e]of this.nodeManager.nodeMap)e.type===v.SVG&&this.asyncRenderNodeManager.addRenderNode(e)}zoomScale(t,e){this.renderManager.zoomScale(t,e)}focus(t,e=0,n=0){if(t){this.renderManager.focusId=t;const o=this.nodeManager.getNode(t);if(o&&o.id!==Mn){const s=new Set;M.getAllChildren(o,s);const r=o.getBounds();r.maxY+=e,r.maxX+=e,r.minX-=e,r.minX-=e,this.renderManager.zoomWorker.zoomToBounds(r,this.renderManager,n)}}else{const o=this.docState.slideStatus.slideContainer;o?(this.execAction(new W),this.execAction(xe.create([o.id])),this.execAction(new z),this.renderManager.zoomToSelect()):this.renderManager.zoomToFit(),this.renderManager.focusId=void 0}this.renderManager.addContentRenderTask(),this.renderManager.addAuxiliaryDrawTask()}}class Wc{addImageNode(t,e,n,o,s){const r=[{type:I.Base,x:o.x,y:o.y,width:e,height:n},{type:I.Image,url:t},{type:I.Border,dashType:et.None}],i=s.idGenerator.genId(v.IMG),a={id:i,type:v.IMG,zIndex:ve.genZIndex(s.nodeManager.root),parentId:"",props:r};s.execAction(new W);const c=Le.create(a);s.execAction(c),s.execAction(xe.create([i])),s.execAction(new z)}}const qn=class qn{static encode(t){const e=encodeURI(t),n=btoa(e);return`<html>
|
|
22
22
|
<head><meta charset="utf-8"></head>
|
|
23
23
|
<body>
|
|
24
24
|
<div style="white-space: pre-wrap" data-info=${qn.oolongLeft}${n}${qn.oolongRight}/>
|
|
25
25
|
</body>
|
|
26
|
-
</html>`}static decode(t){const e=t.indexOf(this.oolongLeft),n=t.indexOf(this.oolongRight);if(e<0||n<0||e===n)return null;const o=t.slice(e+this.oolongLeft.length,n),s=atob(o);return decodeURI(s)}static convertDocumentInfoToPasteData(t,e){const n={docId:t.documentId,resourceType:e},o=[],s=[],r=new Map,i=
|
|
26
|
+
</html>`}static decode(t){const e=t.indexOf(this.oolongLeft),n=t.indexOf(this.oolongRight);if(e<0||n<0||e===n)return null;const o=t.slice(e+this.oolongLeft.length,n),s=atob(o);return decodeURI(s)}static convertDocumentInfoToPasteData(t,e){const n={docId:t.documentId,resourceType:e},o=[],s=[],r=new Map,i=M.correctZIndex(t.nodes);for(const h of i){const d=this.convertToPasteDO(h,r);o.push(d),h.capInfo.baseProps&&s.push(h.capInfo.baseProps)}const a=M.getBoundsByBasePropsList(s),c=D.rectNode2Rect(a);return{meta:n,bounds:c,nodes:o,resources:[...r.values()]}}static convertToPasteDO(t,e){var r,i;const n={id:t.id,type:t.type,zIndex:t.zIndex,capInfo:t.capInfo,children:[]};(r=t.capInfo.imageProps)!=null&&r.url&&e.set(t.capInfo.imageProps.url,{type:zn.Image,fileKey:t.capInfo.imageProps.url}),(i=t.capInfo.svgProps)!=null&&i.url&&e.set(t.capInfo.svgProps.url,{type:zn.SVG,fileKey:t.capInfo.svgProps.url});const o=t.children||[],s=M.correctZIndex(o);for(const a of s){const c=this.convertToPasteDO(a,e);n.children.push(c)}return n}};p(qn,"oolongLeft","start--oolong--"),p(qn,"oolongRight","--oolong--end");let xn=qn;class Cf{constructor(){p(this,"copyWorker",new Ks)}copy(t,e){if(!t.clipboardData)return!1;const n=this.copyWorker.work(e);if(!n)return!1;t.preventDefault();const o=JSON.stringify(n),s=xn.encode(o);return t.clipboardData.setData("text/html",s),!0}}class Af{copy(t,e){if(!t.clipboardData)return!1;const n=e.inputManager.selectionManager.selectionInfo;if(!n)return!1;const o=e.inputManager.editTextInfo;if(!o)return!1;const{renderText:s}=o,{start:r,end:i}=n,a=this.extractPlainText(s,r,i);return a?(t.preventDefault(),t.clipboardData.setData("text/plain",a),!0):!1}extractPlainText(t,e,n){let o="";if(e.paragraphIndex===n.paragraphIndex){const s=t.paragraphs[e.paragraphIndex];o=this.extractTextFromParagraph(s,e,n)}else{const s=t.paragraphs[e.paragraphIndex],r=this.extractTextFromParagraph(s,e,s.tailCursorPosition());o+=r,r.endsWith(`
|
|
27
27
|
`)||(o+=`
|
|
28
|
-
`);for(let c=e.paragraphIndex+1;c<n.paragraphIndex;c++){const h=t.paragraphs[c];o+=h.toString()}const i=t.paragraphs[n.paragraphIndex],a=this.extractTextFromParagraph(i,new Fe(n.paragraphIndex,0,-1),n);o+=a}return o}extractTextFromParagraph(t,e,n){let o="";if(e.lineIndex===n.lineIndex){const s=t.lines[e.lineIndex];o=this.extractTextFromLine(s,e.charIndex,n.charIndex)}else{const s=t.lines[e.lineIndex],r=s.getCharLength();o+=this.extractTextFromLine(s,e.charIndex,r-1);for(let a=e.lineIndex+1;a<n.lineIndex;a++){const c=t.lines[a];o+=c.toString()}const i=t.lines[n.lineIndex];o+=this.extractTextFromLine(i,-1,n.charIndex)}return o}extractTextFromLine(t,e,n){let o="",s=0;const r=e+1,i=n;for(const a of t.textBlocks){const c=a.characters.length;if(s+c-1<r){s+=c;continue}if(s>i)break;const d=Math.max(0,r-s),u=Math.min(c-1,i-s);for(let f=d;f<=u&&f<a.characters.length;f++)o+=a.characters[f].charText;s+=c}return o}}class Ng extends yo{handle(t,e,n,o){const s=t.find(a=>a.type===I.Image);if(!s)return;const r=s.url,i=o.get(r);i?s.url=i:(console.error("复制图片时该图片资源失效!",i),s.url="")}}class kg extends yo{handle(t,e,n,o){const s=t.find(a=>a.type===I.Svg);if(!s||s.useCode)return;const r=s.url,i=o.get(r);i?s.url=i:(console.error("复制svg时该svg资源失效!",i),s.url="")}}class Bg extends Pa{constructor(){super(...arguments);p(this,"propsHandler",[new ga,new ya,new xa,new Ng,new kg])}}class xr{}var Kt=(l=>(l[l.Normal=0]="Normal",l[l.EmptyPlace=1]="EmptyPlace",l))(Kt||{});class Wc extends xr{constructor(){super(...arguments);p(this,"posPasteType",Kt.Normal)}handlePos(e,n){return n.lastInteractiveEvent.globalPoint}}class Fc extends xr{constructor(){super(...arguments);p(this,"posPasteType",Kt.EmptyPlace)}handlePos(e,n){const o=e.bounds,s=20,r=n.renderManager.gmlRender.getViewPortBounds(),i=n.nodeManager.searchNodesByRectNode(r);if(i.length===0){const y=.5*(r.minX+r.maxX)-.5*o.width,P=.5*(r.minY+r.maxY)-.5*o.height;return new m(y,P)}const a=i.map(y=>y.globalPos),c=Math.min(...a.map(y=>y.x)),h=Math.min(...a.map(y=>y.y));let d=c;const u=h,f=o.width+2*s,g=o.height+2*s;for(let y=0;y<10;y++){if(n.nodeManager.searchNodes(d,u,d+f,u+g).length===0)return{x:d+s,y:u+s};d+=f}return new m(c,h)}}class cs{constructor(){p(this,"pasteWorker",new ba);p(this,"crossPagePasteWorker",new Bg);p(this,"pastePosHandlerMap",new Map([[Kt.Normal,new Wc],[Kt.EmptyPlace,new Fc]]))}handle(t,e,n=Kt.Normal){const o=e.docState.docId;return t.meta.docId!==o?this.handleCrossPaste(t,e,n):this.handlePaste(t,e,n)}handlePaste(t,e,n){return!t.nodes||t.nodes.length===0?!1:(this.normalPaste(t,e,this.pasteWorker,n),!0)}handleCrossPaste(t,e,n){return!t.nodes||t.nodes.length===0?!1:(this.asyncHandleCrossPaste(t,e,n),!0)}async asyncHandleCrossPaste(t,e,n){if(!t.nodes||t.nodes.length===0)return!1;const o=await this.pasteResourceInfo(t.resources,e,t.meta.resourceType);return o||console.error("复制图片资源时出现错误!"),this.normalPaste(t,e,this.crossPagePasteWorker,n,o==null?void 0:o.resourceMap),!0}normalPaste(t,e,n,o,s){const r=t.nodes,i=t.bounds,a=this.computePastePos(o,t,e),c=new m(a.x-i.x,a.y-i.y);e.execAction(new W);const{addNodeData:h,nextFocusIds:d}=n.work(e,r,c,s);e.execAction(new Le(h)),e.execAction(xe.create(d)),e.execAction(new z)}computePastePos(t,e,n){const o=this.pastePosHandlerMap.get(t);return o?o.handlePos(e,n):this.pastePosHandlerMap.get(Kt.Normal).handlePos(e,n)}async pasteResourceInfo(t,e,n){return t.length===0?{failedList:[],resourceMap:new Map}:await e.resourceManager.copyImage(t,e.docState.docId,n)}}class Rg{constructor(){p(this,"handlers",[new cs])}paste(t,e){const n=t.clipboardData,o=n==null?void 0:n.getData("text/html");if(!o)return!1;const s=xn.decode(o);if(s===null)return!1;const r=JSON.parse(s);for(const i of this.handlers)if(i.handle(r,e,Kt.Normal))return!0;return!1}}class Eg{paste(t,e){const n=t.clipboardData,o=n==null?void 0:n.getData("text/plain");if(!o)return!1;const s=this.getSvgCode(o);if(s===null)return!1;const r=e.docState.docId,i=Zo(10),a=`${r}/${i}`,c=an.trimSvgCode(s);return e.resourceManager.uploadSvgString(a,c.svgCode).then(h=>{this.addSvgNode(e,c,h)}),!0}addSvgNode(t,e,n){var c;const o=((c=t.lastInteractiveEvent)==null?void 0:c.globalPoint)||new m,s=[{type:I.Base,x:o.x,y:o.y,width:e.width,height:e.height},{type:I.Svg,url:n},{type:I.Border,dashType:et.None}],r=t.idGenerator.genId(v.SVG),i={id:r,type:v.SVG,zIndex:ve.genZIndex(t.nodeManager.root),parentId:"",props:s};t.execAction(new W);const a=Le.create(i);t.execAction(a),t.execAction(xe.create([r])),t.execAction(new z)}getSvgCode(t){const e=t.indexOf("<svg"),n=t.indexOf("svg>");return e<0||n<0||e===n?null:t.slice(e,n+4)}}class Hg{constructor(){p(this,"worker",new zc)}paste(t,e){if(!t.clipboardData)return!1;const n=t.clipboardData.items;for(let o=0;o<n.length;o++){const s=n[o];if(s.type.startsWith("image/")){const r=s.getAsFile();return r?(this.pasteImg(r,e),!0):!1}}return!1}async pasteImg(t,e){const n=Zo(10),o=`${e.docState.docId}/${n}`,s=await e.resourceManager.uploadFileBlob(o,t),{width:r,height:i}=await mc.getImageSize(t),a=e.lastInteractiveEvent.globalPoint;this.worker.addImageNode(s,r,i,a,e)}}class Yc{constructor(t){p(this,"eventCtx");p(this,"pasteHandlers");p(this,"copyHandlers");this.eventCtx=t,this.pasteHandlers=[new Hg,new Rg,new Eg],this.copyHandlers=[new Ag,new Cg]}paste(t){for(const e of this.pasteHandlers)if(e.paste(t,this.eventCtx))return}copy(t){for(const e of this.copyHandlers)if(e.copy(t,this.eventCtx))return}cut(t){console.log(t)}}class Gc{constructor(t){p(this,"eventCtx");p(this,"copyPasteManager");p(this,"onCopy",t=>{this.onEnable()&&this.copyPasteManager.copy(t)});p(this,"onPaste",t=>{this.onEnable()&&this.eventCtx.docState.canEdit()&&this.copyPasteManager.paste(t)});p(this,"onCut",t=>{this.onEnable()&&this.eventCtx.docState.canEdit()&&this.copyPasteManager.cut(t)});this.eventCtx=t,this.copyPasteManager=new Yc(t)}start(){document.addEventListener("copy",this.onCopy),document.addEventListener("paste",this.onPaste),document.addEventListener("cut",this.onCut)}stop(){document.removeEventListener("copy",this.onCopy),document.removeEventListener("paste",this.onPaste),document.removeEventListener("cut",this.onCut)}onEnable(){return this.eventCtx.docState.canEdit()}}const Dg=new Set([v.Shape]);class Og{constructor(t){p(this,"app");this.app=t}addTemplateNodes(t){const e=xn.convertDocumentInfoToPasteData(t,go.Template),n=new cs,o=this.app.appContext;n.asyncHandleCrossPaste(e,o,Kt.EmptyPlace).then(s=>{if(s)o.renderManager.zoomToSelect();else throw console.error("应用模版时出现错误"),new Error("应用模版时出现错误")})}addNode(t,e){const n=this.app.appContext,o=S.getViewportBoundCenter(n),s=100,r=100,i=new m(o.x-s/2,o.y-r/2),a=n.createWorker.makeupDefaultProps(t,n,e,i),c=n.idGenerator.genId(t);n.execAction(new W),n.execAction(Le.create({id:c,props:a,parentId:"",type:t,zIndex:ve.genZIndex(n.nodeManager.root)})),n.execAction(xe.create([c])),Dg.has(t)&&n.execAction(ee.focus(c)),n.execAction(new z)}addSvgNodeBySvgCode(t){const e=this.app.docState.docId,n=Zo(10),o=`${e}/${n}`;this.app.resourceManager.uploadSvgString(o,t).then(s=>{this.addSvgNode(t,s)})}addSvgNode(t,e){const n=this.app.appContext,o=n.renderManager.gmlRender.getViewPortBounds(),s=new m(.5*(o.minX+o.maxX),.5*(o.minY+o.maxY)),i=new cr().computeAddSvgNode(t,e,s,this.app.appContext),a=i.id;n.execAction(new W);const c=Le.create(i);n.execAction(c),n.execAction(xe.create([a])),n.execAction(new z)}addImageNode(t,e,n){const o=new zc,s=this.app.appContext,r=s.renderManager.gmlRender.getViewPortBounds(),i=new m(.5*(r.minX+r.maxX),.5*(r.minY+r.maxY));o.addImageNode(t,e,n,i,s)}quickCreateNode(t,e){const n=this.app.nodeManager.getNode(e);if(!n||n.type!==v.Line)return;const o=n,{start:s}=o.connectProps;if(!s)return;const r=this.app.nodeManager.getNode(s.objectId);if(!r)return;const i=r.baseProps,c=o.lineProps.points,h=c[c.length-1],d=c[c.length-2],u=vt.drawerMap.get(t).getConnectAnchor(),f=S.judgeHorizon(d,h);let g;f?h.x>d.x?g=u[de.Left]:g=u[de.Right]:h.y>d.y?g=u[de.Top]:g=u[de.Bottom];const y=i.width*g.x,P=i.height*g.y,b=h.x-y,w=h.y-P,L=this.app.appContext,B=Is[t],H=So[B],E=cn[B],X=[{type:I.Base,x:b,y:w,width:i.width,height:i.height},tt.create({color:H}),Ae.create({color:E}),new Oe(t)],$=L.idGenerator.genId(v.Shape),Z={id:$,type:v.Shape,zIndex:ve.genZIndex(this.app.nodeManager.root),parentId:"",props:X};L.execAction(new W);const se=Le.create(Z);L.execAction(se);const ne=o.connectProps.clone();ne.end={objectId:$,x:g.x,y:g.y},L.execAction(U.create(e,[ne])),L.execAction(xe.create([$])),L.execAction(ee.focus($)),L.execAction(new z)}makeupToSlidesBySelective(){this.makeupToSlides([...this.app.appContext.getSelectNodes()])}makeupToSlides(t){const e=t.filter($=>!(!($ instanceof rs)||$.parent&&$.parent.type===v.SlideContainer)),n=this.app.appContext;n.execAction(new W),n.execAction(xe.create([]));const o=nt,s=xt,r=this.sortSectionsByPosition(e),i=e.length,a=Math.ceil(Math.sqrt(i)),c=[];for(let $=0;$<r.length;$+=a){const Z=r.slice($,$+a);c.push({ids:Z})}const h=n.idGenerator.genId(v.SlideContainer),d=[ie.create({x:0,y:0,width:100,height:100}),St.create({children:c})],u={id:h,type:v.SlideContainer,zIndex:ve.genZIndex(this.app.nodeManager.root),parentId:"",props:d};n.execAction(Le.create(u));const f=[];let g=0,y=0,P=1/0,b=1/0,w=-1/0,L=-1/0;c.flatMap($=>$.ids).forEach(($,Z)=>{const se=e.find(Re=>Re.id===$);if(!se)return;Z===0&&(g=se.baseProps.x-o,y=se.baseProps.y-s);const ne=Math.floor(Z/a),ae=Z%a,te=se.baseProps,ce=ae*(te.width+o)+o,pe=ne*(te.height+s)+s;P=Math.min(P,ce),b=Math.min(b,pe),w=Math.max(w,ce+te.width),L=Math.max(L,pe+te.height);const Be=ie.create({x:ce,y:pe,width:te.width,height:te.height,angle:te.angle});f.push({id:$,parentId:h,props:[Be]})}),f.length>0&&n.execAction(new U({infos:f}));const H=w-P+2*o,E=L-b+2*s,X=ie.create({x:g,y,width:H,height:E});n.execAction(U.create(h,[X])),n.execAction(xe.create([h])),n.execAction(new z)}sortSectionsByPosition(t){if(t.length===0)return[];const e=t.map(s=>({id:s.id,x:s.baseProps.x,y:s.baseProps.y,yMin:s.baseProps.y,yMax:s.baseProps.y+s.baseProps.height}));e.sort((s,r)=>s.y!==r.y?s.y-r.y:s.x-r.x);const n=[],o=[...e];for(;o.length>0;){const s=o.shift(),r=[s];let i=0;for(;i<o.length;){const a=o[i];a.y>=s.yMin&&a.y<=s.yMax?(r.push(a),o.splice(i,1)):i++}r.sort((a,c)=>a.x-c.x),n.push(...r.map(a=>a.id))}return n}}class ls{constructor(){p(this,"groupBaseWorker",new on)}group(t,e){const n=S.filterToGroupNodes(t);if(n.length<2)return;e.execAction(new W);const o=e.idGenerator.genId(v.Group),s=[],r=S.sortGraphics(n),i=r[r.length-1].parent;for(const b of r)s.push(b.getBounds());const a=S.getBounds(s),c=D.rectNode2Rect(a),h=new m(c.x,c.y),d=i.toLocal(h),u={id:o,parentId:i.id,type:v.Group,zIndex:ve.genZIndex(i),props:[ie.create({x:d.x,y:d.y,width:c.width,height:c.height})]};e.execAction(new Le({nodes:[u]}));const f=e.nodeManager.getNode(o),g=[];let y=1;const P=$t.flattenNodes(r);this.groupBaseWorker.start(P);for(const b of r){if(b.type===v.Group){const w=$t.flattenNodes([b]);for(const L of w)g.push(S.computeRelationChangeUpdateNodeInfo(L,f))}g.push(S.computeRelationChangeUpdateNodeInfo(b,f,y,o)),y++}e.execAction(new U({infos:g})),this.groupBaseWorker.work(e,!1),e.execAction(xe.create([f.id])),e.execAction(new z)}unGroup(t,e){e.execAction(new W);const n=t.parent,o=[...t.children];o.sort((c,h)=>c.zIndex-h.zIndex);const s=[];let r=1;const i=Math.max(...[...n.children].map(c=>c.zIndex)),a=[];for(const c of o){if(c.type===v.Group){const h=$t.flattenNodes([c]);for(const d of h)s.push(S.computeRelationChangeUpdateNodeInfo(d,t))}s.push(S.computeRelationChangeUpdateNodeInfo(c,t,i+r,n.id)),r++,a.push(c.id)}e.execAction(new U({infos:s})),e.execAction(At.create([t.id])),e.execAction(xe.create(a)),e.execAction(new z)}}class Xg{constructor(t){p(this,"app");this.app=t}rotateImageAngle(t,e){const n=this.getNodeIdByBlobUrl(t);n&&this.rotateImage(n,e)}rotateImage(t,e){const n=this.app.appContext,o=n.nodeManager.getNode(t);if(!o)return;const{angle:s}=o.baseProps,r=o.globalPos,i=D.rectNode2Rect(o.getBounds()),a=new m(i.x+.5*i.width,i.y+.5*i.height),c=re.generateMatrix().translate(a.x,a.y),h=re.generateMatrix().rotate(e),u=c.crossProduct(h).crossProduct(c.inverseMatrix()).crossPoint(r);let f;o.parent.type===v.Group?f=o.parent.globalTransform().inverseMatrix().crossPoint(u):f=o.parent.toLocal(u),n.execAction(new W),n.execAction(U.create(t,[{type:I.Base,x:f.x,y:f.y,angle:s+e}])),n.execAction(new z)}getNodeIdByBlobUrl(t){const e=this.app.appContext;for(const[n,o]of e.resourceManager.nodeResourceMap)if(o.blobUrl===t)return n;return""}}class zg{constructor(t){p(this,"app");this.app=t}async copySelectNodes(){const e=new Ks().work(this.app.appContext);if(!e)return!1;const n=JSON.stringify(e),o=xn.encode(n),s=new Blob([o],{type:"text/html"}),r=new ClipboardItem({"text/html":s});await navigator.clipboard.write([r])}copySelectNodesAsPng(t=2,e=""){const o=this.app.appContext.auxiliaryManager.selectManager.getSelectBounds(),s=this.app.renderManager.exportOfflineCanvas(o,t,e);return new Promise(r=>{s.toBlob(async i=>{if(!i){console.error("转化为图片时候出现错误.");return}const a=new ClipboardItem({[i.type]:i});await navigator.clipboard.write([a]),r()})})}async pasteNodes(){try{const t=this.app.appContext,e=await navigator.clipboard.read();for(const n of e)if(n.types.includes("text/html")){const s=await(await n.getType("text/html")).text();if(!s)return;const r=xn.decode(s);if(r===null)return;const i=JSON.parse(r);new cs().handle(i,t);return}console.log("剪贴板中没有可用的文本数据")}catch(t){console.error("读取剪贴板失败:",t),alert("粘贴失败,请检查权限或使用 Ctrl+V")}}}class Mo{work(t){const e=[...t.getSelectNodes()];e.length!==0&&this.deleteByIds(t,e.map(n=>n.id))}deleteByIds(t,e){var r;if(e.length===0)return;const n=[];e.forEach(i=>{const a=t.nodeManager.getNode(i);a&&n.push(a)});const o=new Set,s=new Set;for(const i of n)o.add(i.id),t.nodeManager.getNodeLinks(i).forEach(c=>o.add(c.id)),this.addAllChildren(i,o),((r=i.parent)==null?void 0:r.type)===v.SlideContainer&&s.add(i.parent);t.actionManager.execAction(new W),t.actionManager.execAction(xe.create([])),t.actionManager.execAction(At.create([...o])),s.size>0&&t.slideManager.updateSlideContainers(s,o,t),t.actionManager.execAction(new z)}addAllChildren(t,e){e.add(t.id);for(const n of t.children)this.addAllChildren(n,e)}}class Wg{constructor(t){p(this,"app");this.app=t}intoCrop(){new wo().intoCrop(this.app.appContext)}exitCrop(){new wo().exitCrop(this.app.appContext)}resetCrop(){new wo().resetCrop(this.app.appContext)}}class Fg{constructor(t){p(this,"app");p(this,"lineTextWorker",new $n);this.app=t}switchShape(t){const e=this.app.appContext,n=[...e.getSelectNodes()];if(new Set(n.map(s=>s.type)).size===1&&n[0].type===v.Shape&&n[0].validShapeCode(t)){const r=[];for(const i of n)t!==i.shapeType&&r.push({id:i.id,props:[{type:I.Shape,shapeCode:t}]});r.length>0&&(e.execAction(new W),e.execAction(new U({infos:r})),e.execAction(new z))}}switchLineShape(t){const e=this.app.appContext,n=[...e.getSelectNodes()];if(new Set(n.map(s=>s.type)).size===1&&n[0].type===v.Line){const s=[];for(const r of n){const i=r;if(this.lineTextWorker.init(i),t===i.shapeType)continue;const a=[{type:I.Shape,shapeCode:t}],c=i.points;if(t===he.Line)a.push({type:I.Line,points:[c[0],c[c.length-1]]});else if(t===he.Curve){const h=new po;this.modifyLinePoints(i,e,h,a)}else if(t===he.PolyLine||t===he.RoundPolyLine){const h=new Vt;this.modifyLinePoints(i,e,h,a)}else continue;s.push({id:i.id,props:a})}s.length>0&&(e.execAction(new W),s.forEach(r=>{e.execAction(new U({infos:[r]})),this.lineTextWorker.work(this.app.nodeManager.getNode(r.id),e,!1)}),e.execAction(new z))}}modifyLinePoints(t,e,n,o){const{start:s,end:r}=t.connectProps,i=Ze.computeConnectInfo(t,s,e,!1),a=Ze.computeConnectInfo(t,r,e,!0),c=n.layoutToPointsPro(i,a);o.push({type:I.Line,points:c});const h=D.rectNode2Rect(S.getBoundsByPoints(c)),d=ie.create({x:h.x,y:h.y,width:h.width,height:h.height});o.push(d)}}class Yg{constructor(t){p(this,"app");this.app=t}}class Gg{constructor(t){p(this,"app");p(this,"groupBaseWorker",new on);this.app=t}alignLeft(){const t=this.app.appContext,e=this.getAlignNodes();if(e.length<2)return;const n=Math.min(...e.map(s=>s.globalBaseProps.x)),o=[];for(const s of e){const r=s.globalPos,i=s.parent.toLocal({x:n,y:r.y}),a=s.baseProps,c=i.x-a.x;this.dealNodePos(s,o,c,0)}t.execAction(new W),t.execAction(new U({infos:o})),t.execAction(new z)}alignRight(){const t=this.app.appContext,e=this.getAlignNodes();if(e.length<2)return;const n=Math.max(...e.map(s=>{const r=s.globalBaseProps;return r.x+r.width})),o=[];for(const s of e){const r=s.globalPos,i=s.parent.toLocal({x:n-s.baseProps.width,y:r.y}),a=s.baseProps,c=i.x-a.x;this.dealNodePos(s,o,c,0)}t.execAction(new W),t.execAction(new U({infos:o})),t.execAction(new z)}alignHorizontalCenter(){const t=this.app.appContext,e=this.getAlignNodes();if(e.length<2)return;const n=Math.min(...e.map(i=>i.globalPos.x)),o=Math.max(...e.map(i=>i.globalBaseProps.x+i.baseProps.width)),s=(n+o)/2,r=[];for(const i of e){const a=i.globalPos,c=i.parent.toLocal({x:s-i.baseProps.width/2,y:a.y}),h=i.baseProps,d=c.x-h.x;this.dealNodePos(i,r,d,0)}t.execAction(new W),t.execAction(new U({infos:r})),t.execAction(new z)}dealNodePos(t,e,n,o){const s=t.baseProps,r=s.x+n,i=s.y+o;if(t instanceof Ct){const a=t.points,c=[];for(const h of a)c.push({x:h.x+n,y:h.y+o});e.push({id:t.id,props:[{type:I.Base,x:r,y:i},{type:I.Line,points:c}]})}else e.push({id:t.id,props:[{type:I.Base,x:r,y:i}]});if(t.type===v.Group){const a={x:n,y:o};this.computeGroupChildrenAction(t,a,e)}}alignTop(){const t=this.app.appContext,e=this.getAlignNodes();if(e.length<2)return;const n=Math.min(...e.map(s=>s.globalBaseProps.y)),o=[];for(const s of e){const r=s.globalPos,i=s.parent.toLocal({x:r.x,y:n}),a=s.baseProps,c=i.y-a.y;this.dealNodePos(s,o,0,c)}t.execAction(new W),t.execAction(new U({infos:o})),t.execAction(new z)}alignBottom(){const t=this.app.appContext,e=this.getAlignNodes();if(e.length<2)return;const n=Math.max(...e.map(s=>s.globalBaseProps.y+s.baseProps.height)),o=[];for(const s of e){const r=s.globalPos,i=s.parent.toLocal({x:r.x,y:n-s.baseProps.height}),a=s.baseProps,c=i.y-a.y;this.dealNodePos(s,o,0,c)}t.execAction(new W),t.execAction(new U({infos:o})),t.execAction(new z)}alignVerticalCenter(){const t=this.app.appContext,e=this.getAlignNodes();if(e.length<2)return;const n=Math.min(...e.map(i=>i.globalPos.y)),o=Math.max(...e.map(i=>i.globalPos.y+i.baseProps.height)),s=(n+o)/2,r=[];for(const i of e){const a=i.globalPos,c=i.parent.toLocal({x:a.x,y:s-i.baseProps.height/2}),h=i.baseProps,d=c.y-h.y;this.dealNodePos(i,r,0,d)}t.execAction(new W),t.execAction(new U({infos:r})),t.execAction(new z)}distributeHorizontal(){const t=this.app.appContext,e=this.getAlignNodes();if(e.length<3)return;const n=[...e].sort((f,g)=>f.globalPos.x-g.globalPos.x),o=n[0],s=n[n.length-1],r=o.globalPos.x,i=s.globalPos.x+s.baseProps.width,a=n.reduce((f,g)=>f+g.baseProps.width,0),h=(i-r-a)/(e.length-1),d=[];let u=r;for(let f=0;f<n.length;f++){const g=n[f],y=g.globalPos,P=g.parent.toLocal({x:u,y:y.y}),b=g.baseProps,w=P.x-b.x;this.dealNodePos(g,d,w,0),u+=g.baseProps.width+h}t.execAction(new W),t.execAction(new U({infos:d})),t.execAction(new z)}distributeVertical(){const t=this.app.appContext,e=this.getAlignNodes();if(e.length<3)return;const n=[...e].sort((f,g)=>f.globalPos.y-g.globalPos.y),o=n[0],s=n[n.length-1],r=o.globalPos.y,i=s.globalPos.y+s.baseProps.height,a=n.reduce((f,g)=>f+g.baseProps.height,0),h=(i-r-a)/(e.length-1),d=[];let u=r;for(let f=0;f<n.length;f++){const g=n[f],y=g.globalPos,P=g.parent.toLocal({x:y.x,y:u}),b=g.baseProps,w=P.y-b.y;this.dealNodePos(g,d,0,w),u+=g.baseProps.height+h}t.execAction(new W),t.execAction(new U({infos:d})),t.execAction(new z)}getAlignNodes(){return[...this.app.appContext.getSelectNodes()].filter(o=>{if(o.type!==v.Line)return!0;const s=o,{start:r,end:i}=s.connectProps;return!r&&!i})}getLayoutNodes(t){return t instanceof Po?$t.flattenNodes([t]):[t]}computeGroupChildrenAction(t,e,n){if(t.type===v.Group)for(const o of t.children){if(o.type===v.Line){const s=o.points,r=[];for(const c of s)r.push({x:c.x+e.x,y:c.y+e.y});const{x:i,y:a}=o.baseProps;n.push({id:o.id,props:[{type:I.Base,x:i+e.x,y:a+e.y},{type:I.Line,points:r}]})}else{const{x:s,y:r}=o.baseProps;n.push({id:o.id,props:[{type:I.Base,x:s+e.x,y:r+e.y}]})}this.computeGroupChildrenAction(o,e,n)}}}class Ug{batchNodesToUnOrderByNotEditing(t){const n=[...t.getSelectNodes()].filter(s=>s.type===v.Shape||s.type===v.Line),o=[];for(const s of n)o.push(this.toUnOrderByNotEditing(s));o.length>0&&(t.execAction(new W),t.execAction(new U({infos:o})),t.execAction(new z))}toUnOrderBySelection(t,e,n){const{start:o,end:s}=e,r=t.getProp(I.TextParagraph).clone(),i=o.paragraphIndex,a=s.paragraphIndex;for(let d=i;d<=a;d++)this.toUnOrderWithPara(d,r);const h=[{id:t.id,props:[{type:I.TextParagraph,paragraphStyles:r.paragraphStyles}]}];h.length>0&&(n.execAction(new W),n.execAction(ee.selection(t.id,o,s)),n.execAction(new U({infos:h})),n.execAction(ee.selection(t.id,o,s)),n.execAction(new z))}toUnOrderByEditing(t,e,n){const{textCursorPosition:o}=e,s=t.getProp(I.TextParagraph).clone(),r=o.paragraphIndex;this.toUnOrderWithPara(r,s);const a=[{id:t.id,props:[{type:I.TextParagraph,paragraphStyles:s.paragraphStyles}]}];a.length>0&&(n.execAction(new W),n.execAction(ee.focus(t.id,o)),n.execAction(new U({infos:a})),n.execAction(ee.focus(t.id,o)),n.execAction(new z))}toUnOrderWithPara(t,e){const n=e.paragraphStyles.findIndex(s=>s.paraIndex===t),o=S.getParaStyle(e,t-1);if(n<0)e.paragraphStyles.push({paraIndex:t,level:o?o.level:0,orderIndex:-1});else{const s=e.paragraphStyles[n];s.orderIndex!==-1?s.orderIndex=-1:e.paragraphStyles.splice(n,1)}}toUnOrderByNotEditing(t){const e=t.getProp(I.TextParagraph).clone(),n=t.renderText,o=e.paragraphStyles,s=S.computeNotUnOrderParas(n);if(s.size===0)return{id:t.id,props:[{type:I.TextParagraph,paragraphStyles:[]}]};for(const r of s){const i=S.getParaStyle(e,r);if(i)i.orderIndex=-1;else{const a={level:0,orderIndex:-1,paraIndex:r};o.push(a)}}return{id:t.id,props:[{type:I.TextParagraph,paragraphStyles:o}]}}}class _g{batchNodesToOrderByNotEditing(t){const n=[...t.getSelectNodes()].filter(s=>s.type===v.Shape||s.type===v.Line),o=[];for(const s of n)o.push(this.toOrderByNotEditing(s));o.length>0&&(t.execAction(new W),t.execAction(new U({infos:o})),t.execAction(new z))}toOrderBySelection(t,e,n){const{start:o,end:s}=e,r=t.getProp(I.TextParagraph).clone(),i=o.paragraphIndex,a=s.paragraphIndex;for(let d=i;d<=a;d++)this.toOrderWithPara(d,r);const h=[{id:t.id,props:[{type:I.TextParagraph,paragraphStyles:r.paragraphStyles}]}];h.length>0&&(n.execAction(new W),n.execAction(ee.selection(t.id,o,s)),n.execAction(new U({infos:h})),n.execAction(ee.selection(t.id,o,s)),n.execAction(new z))}toOrderByEditing(t,e,n){const{textCursorPosition:o}=e,s=t.getProp(I.TextParagraph).clone(),r=o.paragraphIndex;this.toOrderWithPara(r,s);const a=[{id:t.id,props:[{type:I.TextParagraph,paragraphStyles:s.paragraphStyles}]}];a.length>0&&(n.execAction(new W),n.execAction(ee.focus(t.id,o)),n.execAction(new U({infos:a})),n.execAction(ee.focus(t.id,o)),n.execAction(new z))}toOrderWithPara(t,e){const n=e.paragraphStyles.findIndex(s=>s.paraIndex===t),o=S.getParaStyle(e,t-1);if(n<0){const s=o&&o.orderIndex>0?o.orderIndex+1:1,r=o?o.level:0;e.paragraphStyles.push({paraIndex:t,level:r,orderIndex:s})}else{const s=e.paragraphStyles[n];if(s.orderIndex>0)e.paragraphStyles.splice(n,1);else{const r=o&&o.orderIndex>0?o.orderIndex+1:1;s.orderIndex=r}}}toOrderByNotEditing(t){const e=t.getProp(I.TextParagraph).clone(),n=t.renderText,o=e.paragraphStyles,s=S.computeNotOrderParas(n);if(s.size===0)return{id:t.id,props:[{type:I.TextParagraph,paragraphStyles:[]}]};const r=[...s].sort((i,a)=>i-a);for(const i of r){const a=o.findIndex(h=>h.paraIndex===i),c=o.findIndex(h=>h.paraIndex===i-1);if(a>-1){const h=o[a];if(c>-1){const d=o[c];h.orderIndex=d.orderIndex+1,h.level=d.level}else h.orderIndex=1,h.level=0}else if(c>-1){const h=o[c],d={level:h.level,orderIndex:h.orderIndex+1,paraIndex:i};o.push(d)}else{const h={level:0,orderIndex:1,paraIndex:i};o.push(h)}}return{id:t.id,props:[{type:I.TextParagraph,paragraphStyles:o}]}}}class $g{batchNodesToQuoteByNotEditing(t){const n=[...t.getSelectNodes()].filter(s=>s.type===v.Shape||s.type===v.Line),o=[];for(const s of n)o.push(this.toQuoteByNotEditing(s));o.length>0&&(t.execAction(new W),t.execAction(new U({infos:o})),t.execAction(new z))}toQuoteBySelection(t,e,n){var u;const{start:o,end:s}=e,r=((u=t.getProp(I.TextParagraphQuote))==null?void 0:u.clone())||new Dt,i=o.paragraphIndex,a=s.paragraphIndex;let c=!1;for(let f=i;f<=a;f++)if(r.paraQuoteStyles.findIndex(y=>y.paraIndex===f)<0){c=!0;break}if(c)for(let f=i;f<=a;f++)r.paraQuoteStyles.findIndex(y=>y.paraIndex===f)<0&&r.paraQuoteStyles.push({paraIndex:f,quote:!0});else for(let f=i;f<=a;f++){const g=r.paraQuoteStyles.findIndex(y=>y.paraIndex===f);g>=0&&r.paraQuoteStyles.splice(g,1)}const d=[{id:t.id,props:[{type:I.TextParagraphQuote,paraQuoteStyles:r.paraQuoteStyles}]}];d.length>0&&(n.execAction(new W),n.execAction(ee.selection(t.id,o,s)),n.execAction(new U({infos:d})),n.execAction(ee.selection(t.id,o,s)),n.execAction(new z))}toQuoteByEditing(t,e,n){var c;const{textCursorPosition:o}=e,s=((c=t.getProp(I.TextParagraphQuote))==null?void 0:c.clone())||new Dt,r=o.paragraphIndex;this.toQuoteWithPara(r,s);const a=[{id:t.id,props:[{type:I.TextParagraphQuote,paraQuoteStyles:s.paraQuoteStyles}]}];a.length>0&&(n.execAction(new W),n.execAction(ee.focus(t.id,o)),n.execAction(new U({infos:a})),n.execAction(ee.focus(t.id,o)),n.execAction(new z))}toQuoteWithPara(t,e){const n=e.paraQuoteStyles.findIndex(o=>o.paraIndex===t);if(n<0)e.paraQuoteStyles.push({paraIndex:t,quote:!0});else{const o=e.paraQuoteStyles[n];o.quote?e.paraQuoteStyles.splice(n,1):o.quote=!0}}toQuoteByNotEditing(t){const e=t.renderText;if(S.computeNotQuoteParas(e).size===0)return{id:t.id,props:[{type:I.TextParagraphQuote,paraQuoteStyles:[]}]};const o=[];for(let s=0;s<e.paragraphs.length;s++)o.push({paraIndex:s,quote:!0});return{id:t.id,props:[{type:I.TextParagraphQuote,paraQuoteStyles:o}]}}}class jg{batchNodesToNormalByNotEditing(t){const n=[...t.getSelectNodes()].filter(s=>s.type===v.Shape||s.type===v.Line),o=[];for(const s of n){const r=this.toNormalByNotEditing(s);r&&o.push(r)}o.length>0&&(t.execAction(new W),t.execAction(new U({infos:o})),t.execAction(new z))}toNormalBySelection(t,e,n){var d;const{start:o,end:s}=e,r=(d=t.getProp(I.TextParagraph))==null?void 0:d.clone(),i=o.paragraphIndex,a=s.paragraphIndex,c=[],h=[];if(r){for(let u=i;u<=a;u++){const f=r.paragraphStyles.findIndex(g=>g.paraIndex===u);f>=0&&r.paragraphStyles.splice(f,1)}h.push({type:I.TextParagraph,paragraphStyles:r.paragraphStyles})}if(h.length>0){const u={id:t.id,props:h};c.push(u)}c.length>0&&(n.execAction(new W),n.execAction(ee.selection(t.id,o,s)),n.execAction(new U({infos:c})),n.execAction(ee.selection(t.id,o,s)),n.execAction(new z))}toNormalByEditing(t,e,n){var c;const{textCursorPosition:o}=e,s=(c=t.getProp(I.TextParagraph))==null?void 0:c.clone(),r=o.paragraphIndex,i=[],a=[];if(s){const h=s.paragraphStyles.findIndex(d=>d.paraIndex===r);h>=0&&s.paragraphStyles.splice(h,1),a.push({type:I.TextParagraph,paragraphStyles:s.paragraphStyles})}if(a.length>0){const h={id:t.id,props:a};i.push(h)}i.length>0&&(n.execAction(new W),n.execAction(ee.focus(t.id,o)),n.execAction(new U({infos:i})),n.execAction(ee.focus(t.id,o)),n.execAction(new z))}toNormalByNotEditing(t){const e=t.renderText;return S.computeNotNormalParas(e).size===0?null:{id:t.id,props:[{type:I.TextParagraph,paragraphStyles:[]}]}}}class wr{work(t,e,n){const{node:o,renderText:s,textCursorPosition:r}=t,{updateTextProps:i}=this.computeUpdateTextProps(t,n);e.execAction(new W),e.execAction(U.create(o.id,[i]));const a=s.nextCursorPos(r,n.length);e.execAction(ee.focus(o.id,a)),e.execAction(new z)}computeUpdateTextProps(t,e){const{renderText:n,textCursorPosition:o}=t,s=this.editText(n,o,e);return{updateTextProps:{type:I.Text,richText:s}}}editText(t,e,n){const{paragraphIndex:o,lineIndex:s,charIndex:r}=e,i=t.prevParagraphToXML(o),a=t.nextParagraphToXML(o),c=t.getParagraph(o),h=c.prevToRichTextXML(s,t.textProps),d=c.nextToRichTextXML(s,t.textProps),u=c.getLine(s),f=u.getBlockIndex(r);if(f){const{textBlock:g,blockIndex:y,charIndex:P}=f,b=u.prevToRichTextXML(y,t.textProps),w=u.nextToRichTextXML(y,t.textProps),L=g.insertTextToRichTextXML(n,P,t.textProps);return`<root>${i}<p>${h}${b}${L}${w}${d}</p>${a}</root>`}return`<root>${i}<p>${h}${n}${d}</p>${a}</root>`}getEditTextPrevNext(t,e){const{paragraphIndex:n,lineIndex:o,charIndex:s}=e,r=t.prevParagraphToXML(n),i=t.nextParagraphToXML(n),a=t.getParagraph(n),c=a.prevToRichTextXML(o,t.textProps),h=a.nextToRichTextXML(o,t.textProps),d=a.getLine(o),u=d.getBlockIndex(s);if(u){const{textBlock:y,blockIndex:P,charIndex:b}=u,w=d.prevToRichTextXML(P,t.textProps),L=d.nextToRichTextXML(P,t.textProps),B=y.getPrevText(b),H=y.getNextText(b),E=y.computeStyle(t.textProps),X=`<root>${r}<p>${c}${w}<style ${E}>${B}`,$=`${H}</style>${L}${h}</p>${i}</root>`;return{prev:X,next:$}}const f=`<root>${r}<p>${c}`,g=`${h}</p>${i}</root>`;return{prev:f,next:g}}applyStyleToSelection(t,e,n,o){const{start:s,end:r}=this.normalizeSelection(e,n);return s.paragraphIndex===r.paragraphIndex&&s.lineIndex===r.lineIndex?this.applyStyleSameLine(t,s,r,o):s.paragraphIndex===r.paragraphIndex?this.applyStyleSameParagraph(t,s,r,o):this.applyStyleDifferentParagraphs(t,s,r,o)}normalizeSelection(t,e){const n=this.getCursorPosition(t),o=this.getCursorPosition(e);return n<=o?{start:t,end:e}:{start:e,end:t}}getCursorPosition(t){return t.paragraphIndex*1e6+t.lineIndex*1e3+(t.charIndex+1)}generateStyleString(t){return Object.entries(t).map(([e,n])=>`${e}='${n}'`).join(" ")}mergeStyles(t,e){const n={};if(t.trim()){const s=/(\S+)=['"]([^'"]*)['"]/g;let r;for(;(r=s.exec(t))!==null;)n[r[1]]=r[2]}const o={...n,...e};return Object.entries(o).map(([s,r])=>`${s}='${r}'`).join(" ")}applyStyleSameLine(t,e,n,o){const{paragraphIndex:s,lineIndex:r}=e,i=e.charIndex+1,a=n.charIndex,c=t.prevParagraphToXML(s),h=t.nextParagraphToXML(s),d=t.getParagraph(s),u=d.prevToRichTextXML(r,t.textProps),f=d.nextToRichTextXML(r,t.textProps),g=d.getLine(r),y=this.buildSelectionXMLInLine(g,i,a,o,t.textProps);return`<root>${c}<p>${u}${y}${f}</p>${h}</root>`}buildSelectionXMLInLine(t,e,n,o,s){let r="",i=0;const a=e===-1?0:e,c=n===-1?0:n;for(let h=0;h<t.textBlocks.length;h++){const d=t.textBlocks[h],u=d.characters.length;if(i+u-1<a){r+=d.toRichTextXML(s),i+=u;continue}if(i>c){r+=d.toRichTextXML(s),i+=u;continue}const g=Math.max(0,a-i),y=Math.min(u-1,c-i);if(g>0){const L=d.getPrevText(g-1),B=d.computeStyle(s);r+=`<style ${B}>${L}</style>`}const P=this.getTextRange(d,g,y),b=d.computeStyle(s),w=this.mergeStyles(b,o);if(r+=`<style ${w}>${P}</style>`,y<u-1){const L=d.getNextText(y),B=d.computeStyle(s);r+=`<style ${B}>${L}</style>`}i+=u}return r}getTextRange(t,e,n){let o="";for(let s=e;s<=n;s++)o+=t.characters[s].charText;return o}applyStyleSameParagraph(t,e,n,o){const{paragraphIndex:s}=e,r=t.prevParagraphToXML(s),i=t.nextParagraphToXML(s),a=t.getParagraph(s);let c="";c+=a.prevToRichTextXML(e.lineIndex,t.textProps);const h=a.getLine(e.lineIndex);c+=this.buildSelectionXMLInLine(h,e.charIndex+1,h.getCharLength()-1,o,t.textProps);for(let u=e.lineIndex+1;u<n.lineIndex;u++){const f=a.getLine(u);c+=this.buildSelectionXMLInLine(f,-1,f.getCharLength()-1,o,t.textProps)}const d=a.getLine(n.lineIndex);return c+=this.buildSelectionXMLInLine(d,-1,n.charIndex,o,t.textProps),c+=a.nextToRichTextXML(n.lineIndex,t.textProps),`<root>${r}<p>${c}</p>${i}</root>`}applyStyleDifferentParagraphs(t,e,n,o){let s="<root>";s+=t.prevParagraphToXML(e.paragraphIndex);const r=t.getParagraph(e.paragraphIndex);let i="";i+=r.prevToRichTextXML(e.lineIndex,t.textProps);const a=r.getLine(e.lineIndex);i+=this.buildSelectionXMLInLine(a,e.charIndex+1,a.getCharLength()-1,o,t.textProps);for(let u=e.lineIndex+1;u<r.lines.length;u++){const f=r.getLine(u);i+=this.buildSelectionXMLInLine(f,-1,f.getCharLength()-1,o,t.textProps)}s+=`<p>${i}</p>`;for(let u=e.paragraphIndex+1;u<n.paragraphIndex;u++){const f=t.getParagraph(u);let g="";for(const y of f.lines)g+=this.buildSelectionXMLInLine(y,-1,y.getCharLength()-1,o,t.textProps);s+=`<p>${g}</p>`}const c=t.getParagraph(n.paragraphIndex);let h="";for(let u=0;u<n.lineIndex;u++){const f=c.getLine(u);h+=this.buildSelectionXMLInLine(f,-1,f.getCharLength()-1,o,t.textProps)}const d=c.getLine(n.lineIndex);return h+=this.buildSelectionXMLInLine(d,-1,n.charIndex,o,t.textProps),h+=c.nextToRichTextXML(n.lineIndex,t.textProps),s+=`<p>${h}</p>`,s+=t.nextParagraphToXML(n.paragraphIndex),s+="</root>",s}}class Hn{constructor(){p(this,"inputWorker",new wr)}changeFontProp(t,e){if(e.getSelectNodes().size===0)return;const o=e.inputManager.selectionManager.selectionInfo,s=e.inputManager.editTextInfo;if(s&&o){this.changeFontPropBySelection(t,s,o,e);return}this.changeFontPropForWhole(t,e)}changeFontPropForWhole(t,e){const o=[...e.getSelectNodes()].filter(r=>r.getProp(I.Text)!==null),s=[];for(const r of o)s.push({id:r.id,props:[this.textProp(t)]});s.length>0&&(e.execAction(new W),e.execAction(new U({infos:s})),e.execAction(new z))}changeFontPropBySelection(t,e,n,o){const{renderText:s,node:r}=e,{start:i,end:a}=n,c=this.inputWorker.applyStyleToSelection(s,i,a,this.richStyle(t));o.execAction(new W),o.execAction(ee.selection(r.id,i,a)),o.execAction(U.create(r.id,[{type:I.Text,richText:c}])),o.execAction(ee.selection(r.id,i,a)),o.execAction(new z)}}class Vg extends Hn{richStyle(t){return{color:t}}textProp(t){return{type:I.Text,fontColor:t}}}class Kg extends Hn{richStyle(t){return{"bg-color":t}}textProp(t){return{type:I.Text,fontBgColor:t}}}class Qg extends Hn{richStyle(t){return{bold:t}}textProp(t){return{type:I.Text,bold:t}}}class Zg extends Hn{richStyle(t){return{italic:t}}textProp(t){let e=t;return typeof t=="string"&&(e=t.trim().toLowerCase()==="true"),{type:I.Text,italic:e}}}class qg extends Hn{richStyle(t){return{underline:t}}textProp(t){return{type:I.Text,underline:t}}}class Jg extends Hn{richStyle(t){return{strikethrough:t}}textProp(t){return{type:I.Text,strikethrough:t}}}class Uc{}class ey extends Uc{enable(t){return t.type===v.CheckboxText}handle(t,e){return{id:t.id,props:[{type:I.Text,fontSize:e},{type:I.CheckSize,size:e}]}}}class ty extends Uc{enable(t){return!0}handle(t,e){return{id:t.id,props:[{type:I.Text,fontSize:e}]}}}v.Line,v.Shape,v.CheckboxText;class ny extends Hn{constructor(){super(...arguments);p(this,"editTextWorker",new mo);p(this,"fontSizeHandlers",[new ey,new ty])}richStyle(e){return{"font-size":e}}textProp(e){return{type:I.Text,fontSize:e}}changeFontPropBySelection(e,n,o,s){const{renderText:r,node:i}=n,{start:a,end:c}=o,h=this.inputWorker.applyStyleToSelection(r,a,c,this.richStyle(e));s.execAction(new W),s.execAction(ee.selection(i.id,a,c)),s.execAction(U.create(i.id,[{type:I.Text,richText:h}])),r&&(r.textProps.sizeMode===We.autoWidth||r.textProps.sizeMode===We.autoHeight)&&this.editTextWorker.modifyBaseProps(i.renderText,i,s),s.execAction(ee.selection(i.id,a,c)),s.execAction(new z)}changeFontPropForWhole(e,n){const s=[...n.getSelectNodes()].filter(a=>a.getProp(I.Text)!==null),r=[],i=new Set;for(const a of s){const c=a.renderText;c&&(c.textProps.sizeMode===We.autoWidth||c.textProps.sizeMode===We.autoHeight)&&i.add(a);for(const h of this.fontSizeHandlers)if(h.enable(a)){r.push(h.handle(a,e));break}}if(r.length!==0){n.execAction(new W),n.execAction(new U({infos:r}));for(const a of i)this.editTextWorker.modifyBaseProps(a.renderText,a,n);n.execAction(new z)}}}class oy{constructor(t){p(this,"app");p(this,"textUnOrderWorker",new Ug);p(this,"textOrderWorker",new _g);p(this,"textQuoteWorker",new $g);p(this,"textNormalWorker",new jg);p(this,"textFontColorWorker",new Vg);p(this,"textFontBgColorWorker",new Kg);p(this,"textFontBoldWorker",new Qg);p(this,"textFontItalicWorker",new Zg);p(this,"textUnderLineWorker",new qg);p(this,"textFontStrikethroughWorker",new Jg);p(this,"textFontSizeWorker",new ny);this.app=t}addUnOrderList(){const t=this.app.appContext,e=t.inputManager.editTextInfo;if(e===null)return this.textUnOrderWorker.batchNodesToUnOrderByNotEditing(t);const{node:n}=e,o=t.inputManager.selectionManager.selectionInfo;if(o===null){this.textUnOrderWorker.toUnOrderByEditing(n,e,t);return}this.textUnOrderWorker.toUnOrderBySelection(n,o,t)}addOrderList(){const t=this.app.appContext,e=t.inputManager.editTextInfo;if(e===null)return this.textOrderWorker.batchNodesToOrderByNotEditing(t);const{node:n}=e,o=t.inputManager.selectionManager.selectionInfo;if(o===null){this.textOrderWorker.toOrderByEditing(n,e,t);return}this.textOrderWorker.toOrderBySelection(n,o,t)}addQuote(){const t=this.app.appContext,e=t.inputManager.editTextInfo;if(e===null)return this.textQuoteWorker.batchNodesToQuoteByNotEditing(t);const{node:n}=e,o=t.inputManager.selectionManager.selectionInfo;if(o===null){this.textQuoteWorker.toQuoteByEditing(n,e,t);return}this.textQuoteWorker.toQuoteBySelection(n,o,t)}toNormal(){const t=this.app.appContext,e=t.inputManager.editTextInfo;if(e===null)return this.textNormalWorker.batchNodesToNormalByNotEditing(t);const{node:n}=e,o=t.inputManager.selectionManager.selectionInfo;if(o===null){this.textNormalWorker.toNormalByEditing(n,e,t);return}this.textNormalWorker.toNormalBySelection(n,o,t)}changeTextColor(t){const e=this.app.appContext;this.textFontColorWorker.changeFontProp(t,e)}changeTextBgColor(t){const e=this.app.appContext;this.textFontBgColorWorker.changeFontProp(t,e)}changeTextBold(t){const e=this.app.appContext;this.textFontBoldWorker.changeFontProp(t,e)}changeTextItalic(t){const e=this.app.appContext;this.textFontItalicWorker.changeFontProp(t,e)}changeTextUnderLine(t){const e=this.app.appContext;this.textUnderLineWorker.changeFontProp(t,e)}changeTextStrikethrough(t){const e=this.app.appContext;this.textFontStrikethroughWorker.changeFontProp(t,e)}changeTextFontSize(t){const e=this.app.appContext;this.textFontSizeWorker.changeFontProp(t,e)}}class _c{getTotalCount(t){return t.reduce((e,n)=>e+n.ids.length,0)}playToNext(t){if(t.docMode!==ue.SLIDE_PLAY||!t.slideStatus.slideContainer)return null;const e=t.slideStatus.slideContainer.slideProps.children,n=t.slideStatus.currentIndex+1,o=this.getTotalCount(e);return n<o?(t.slideStatus.currentIndex=n,t.slideStatus.slideContainer.getChildIdByIndex(n)):null}playToPrev(t){if(t.docMode!==ue.SLIDE_PLAY||!t.slideStatus.slideContainer)return null;const e=t.slideStatus.currentIndex-1;return e>=0?(t.slideStatus.currentIndex=e,t.slideStatus.slideContainer.getChildIdByIndex(e)):null}}class sy{constructor(t){p(this,"app");p(this,"slidePlayWorker");p(this,"duplicateWorker",new Zs);this.app=t,this.slidePlayWorker=new _c}createEmptySlideContainer(){const t=this.app.appContext,e=S.getViewportBoundCenter(t),n=800,o=600,s=t.idGenerator.genId(v.SlideContainer),r=[ie.create({x:e.x-n/2,y:e.y-o/2,width:n,height:o}),St.create({children:[]})],i={id:s,type:v.SlideContainer,zIndex:ve.genZIndex(this.app.nodeManager.root),parentId:"",props:r};t.execAction(new W),t.execAction(Le.create(i)),t.execAction(xe.create([s])),t.execAction(new z)}refocusSlide(t=0){const e=this.app.appContext;e.slideManager.refocusSlide(e,t)}enterEditing(){const t=this.app.appContext;t.slideManager.enterEditing(t)}exitEditing(){const t=this.app.appContext;t.slideManager.exitEditing(t)}jumpToWhenEditing(t){const e=this.app.appContext;e.slideManager.jumpToWhenEditing(t,e)}enterPlayFromEdit(){const t=this.app.appContext;t.slideManager.enterPlayBySlideContainer(t,t.docState.slideStatus.slideContainer)}enterPlay(){const t=this.app.appContext;t.slideManager.enterPlay(t)}playToNext(){const t=this.app.appContext;t.slideManager.playToNext(t)}playToPrev(){const t=this.app.appContext;t.slideManager.playToPrev(t)}exitPlay(){const t=this.app.appContext;t.slideManager.exitPlay(t)}unGroupSlideContainerBySelective(){const t=this.app.appContext;t.slideManager.unGroupSlideContainerBySelective(t)}unGroupSlideContainer(t){const e=this.app.appContext;e.slideManager.unGroupSlideContainer(t,e)}async insertSlideByEditingMode(t){const e=this.app.appContext;if(e.docState.docMode!==ue.SLIDE_EDIT)return;const o=e.docState.slideStatus.slideContainer;o&&(e.execAction(new W),t===0?e.slideManager.insertSlide(o,0,!1,e):e.slideManager.insertSlide(o,t-1,!0,e),e.execAction(xe.create([])),e.slideManager.jumpToWhenEditing(t,e),e.execAction(new z))}deleteSlideByEditingMode(t){const e=this.app.appContext;if(e.docState.docMode!==ue.SLIDE_EDIT)return;const n=e.docState.slideStatus.slideContainer;if(!n)return;const o=n.getChildIdByIndex(t);if(!o)return;new Mo().deleteByIds(this.app.appContext,[o]);const r=n.getTotalCount();t===r-1?e.slideManager.jumpToWhenEditing(t-1,e):e.slideManager.jumpToWhenEditing(t+1,e)}duplicateSlideByEditingMode(t){const e=this.app.appContext;if(e.docState.docMode!==ue.SLIDE_EDIT)return;const n=e.docState.slideStatus.slideContainer;if(!n)return;const o=n.getChildIdByIndex(t);o&&(this.duplicateWorker.duplicateByIds([o],e),e.slideManager.jumpToWhenEditing(t+1,e))}}class $c{constructor(t){p(this,"app");p(this,"create");p(this,"image");p(this,"copyPaste");p(this,"crop");p(this,"switch");p(this,"propChangeAPI");p(this,"align");p(this,"text");p(this,"slide");this.app=t,this.create=new Og(t),this.image=new Xg(t),this.copyPaste=new zg(t),this.crop=new Wg(t),this.switch=new Fg(t),this.propChangeAPI=new Yg(t),this.align=new Gg(t),this.text=new oy(t),this.slide=new sy(t)}resizeCanvas(){this.app.appContext.resize()}focus(t,e=0,n=0){this.app.appContext.focus(t,e,n)}resetCursor(){this.app.cursorManager.resetCursor()}zoomScale(t,e){this.app.renderManager.zoomScale(t,e),this.app.appContext.refreshAllSvgNode()}zoomToFit(){this.app.renderManager.zoomToFit(),this.app.appContext.refreshAllSvgNode()}zoomToSelect(){this.app.renderManager.zoomToSelect(),this.app.appContext.refreshAllSvgNode()}zoomTo100(){this.app.renderManager.zoomTo100(),this.app.appContext.refreshAllSvgNode()}exportCoverCanvas(t,e=""){const n=this.app.nodeManager.getNodeBounds(),o=n.maxX-n.minX,s=n.maxY-n.minY,r=1280;let i=n;const a=1.5;if(o>r||s>r){const c=(n.minX+n.maxX)/2,h=(n.minY+n.maxY)/2,d=o>r?r:o,u=d/a;i={id:"cover-export-bounds",minX:c-d/2,minY:h-u/2,maxX:c+d/2,maxY:h+u/2}}return this.app.renderManager.exportOfflineCanvas(i,t,e)}exportOfflineCanvas(t,e,n=""){return this.app.renderManager.exportOfflineCanvas(t,e,n)}exportAllNodesImg(t,e=""){const n=this.app.nodeManager.getNodeBounds();if(this.app.nodeManager.nodeMap.size===0){const o={minX:0,minY:0,maxX:600,maxY:600};return this.app.renderManager.exportOfflineCanvas(o,t,e)}return this.app.renderManager.exportOfflineCanvas(n,t,e)}scroll(t,e){this.app.renderManager.scroll(t,e)}registerCallback(t,e){this.app.slotManager.registerSlotCallback(t,e)}changePermission({canEdit:t}){this.app.docState.userPermission.canEdit=t}getBounds(){const t=this.app.renderManager.gmlRender.getViewPortBounds();return D.rectNode2Rect(t)}getScale(){return this.app.renderManager.getScale()}transformToClientPos(t){return this.app.gmlRender.transformToLocal(t)}getFocusList(){return this.app.auxiliaryManager.selectManager.getSelectNodes()}setPrefix(t){this.app.idGenerator.setPrefix(t)}clearFocus(){if(this.app.auxiliaryManager.selectManager.getSelectNodes().length===0)return;const t=this.app.appContext;if(t.execAction(new W),t.inputManager.editTextInfo){const{node:e}=t.inputManager.editTextInfo;t.execAction(ee.blur(e.id))}t.execAction(xe.create([])),t.execAction(new z)}makeGroup(){const t=[...this.app.appContext.getSelectNodes()];new ls().group(t,this.app.appContext)}makeUnGroup(){const t=[...this.app.appContext.getSelectNodes()];if(t.length!==1)return;const e=t[0];if(e.type!==v.Group)return;const n=e;new ls().unGroup(n,this.app.appContext)}getImageBlobUrl(t){return this.app.resourceManager.getBlobUrl(t)}deleteSelectNodes(){new Mo().work(this.app.appContext)}deleteByIds(t){new Mo().deleteByIds(this.app.appContext,t)}}class ry{constructor(t){p(this,"app");p(this,"textHelper",new mi);this.app=t}getCtx(){return this.app.appContext}computeRichText(t){if(!t)return Ge.dealTextToRichText("");const e=t.trim();if(e.startsWith("<root>")||e.startsWith("<root "))return t;const n=this.textHelper.escapeXmlText(t);return Ge.dealTextToRichText(n)}addNode(t){try{const e=this.getCtx();if(t.x===void 0||t.y===void 0||t.width===void 0||t.height===void 0)return{code:400,msg:"缺少必需参数: x, y, width, height"};const n=e.idGenerator.genId(v.Shape),o=e.nodeManager.root,s=Ge.create({richText:this.computeRichText(t.text??""),fontSize:t.fontSize,fontColor:t.fontColor,bold:t.bold,italic:t.italic,underline:t.underline,strikethrough:t.strikethrough,verticalAlign:t.verticalAlign,horizonAlign:t.horizonAlign}),r=[ie.create({x:t.x,y:t.y,width:t.width,height:t.height,angle:t.angle??0}),tt.create({color:t.color??"#FFFFFF",alpha:t.alpha??1}),Ae.create({color:t.borderColor??"#000000",alpha:1,width:2,dashType:t.dashType??1}),s,new Oe(t.shapeCode??1)],i={id:n,parentId:o.id,type:v.Shape,zIndex:t.zIndex??ve.genZIndex(o),props:r};return e.execAction(new W),e.execAction(new Le({nodes:[i]})),e.execAction(new z),{code:200,id:n}}catch(e){return console.error("[AINodeAPI] addNode 失败:",e),{code:500,msg:`添加节点失败: ${e instanceof Error?e.message:String(e)}`}}}deleteNode(t){try{const e=this.getCtx();if(!t.ids||!Array.isArray(t.ids)||t.ids.length===0)return{code:400,msg:"缺少必需参数: ids (非空数组)"};const n=[],o=[];for(const s of t.ids)e.nodeManager.nodeMap.has(s)?n.push(s):o.push(s);return n.length===0?{code:404,msg:`所有节点都不存在: ${o.join(", ")}`}:(e.execAction(new W),e.execAction(At.create(n)),e.execAction(new z),o.length>0?{code:200,msg:`部分节点删除成功,以下节点不存在: ${o.join(", ")}`}:{code:200})}catch(e){return console.error("[AINodeAPI] deleteNode 失败:",e),{code:500,msg:`删除节点失败: ${e instanceof Error?e.message:String(e)}`}}}updateNode(t){try{const e=this.getCtx();if(!t.id)return{code:400,msg:"缺少必需参数: id"};if(!e.nodeManager.nodeMap.has(t.id))return{code:404,msg:`节点不存在: ${t.id}`};const n=[],o={};t.x!==void 0&&(o.x=t.x),t.y!==void 0&&(o.y=t.y),t.width!==void 0&&(o.width=t.width),t.height!==void 0&&(o.height=t.height),t.angle!==void 0&&(o.angle=t.angle),Object.keys(o).length>0&&(o.type=I.Base,n.push(o)),t.zIndex!==void 0&&(o.type=I.Base);const s={};t.color!==void 0&&(s.color=t.color),t.alpha!==void 0&&(s.alpha=t.alpha),Object.keys(s).length>0&&(s.type=I.Color,n.push(s));const r={};if(t.borderColor!==void 0&&(r.color=t.borderColor),t.borderWidth!==void 0&&(r.width=t.borderWidth),t.borderAlpha!==void 0&&(r.alpha=t.borderAlpha),t.dashType!==void 0&&(r.dashType=t.dashType),Object.keys(r).length>0&&(r.type=I.Border,n.push(r)),(t.text!==void 0||t.fontSize!==void 0||t.fontColor!==void 0)&&n.push({type:I.Text,richText:t.text!==void 0?this.computeRichText(t.text??""):void 0,fontSize:t.fontSize,fontColor:t.fontColor}),t.shapeCode!==void 0&&n.push(new Oe(t.shapeCode)),n.length===0)return{code:400,msg:"没有提供任何更新属性"};if(e.execAction(new W),t.zIndex!==void 0){const i=e.nodeManager.getNode(t.id);i&&(i.zIndex=t.zIndex)}return e.execAction(U.create(t.id,n)),e.execAction(new z),{code:200}}catch(e){return console.error("[AINodeAPI] updateNode 失败:",e),{code:500,msg:`更新节点失败: ${e instanceof Error?e.message:String(e)}`}}}batchUpdateNode(t){try{const e=this.getCtx();if(!t.nodes||!Array.isArray(t.nodes))return{code:400,msg:"缺少必需参数: nodes (数组)"};if(t.nodes.length===0)return{code:400,msg:"nodes 数组不能为空"};const n=[];let o=0;e.execAction(new W);for(let s=0;s<t.nodes.length;s++){const r=t.nodes[s];try{if(!r.id){n.push({index:s,id:r.id,error:"缺少必需参数: id"});continue}if(!e.nodeManager.nodeMap.has(r.id)){n.push({index:s,id:r.id,error:`节点不存在: ${r.id}`});continue}const i=[],a={};r.x!==void 0&&(a.x=r.x),r.y!==void 0&&(a.y=r.y),r.width!==void 0&&(a.width=r.width),r.height!==void 0&&(a.height=r.height),r.angle!==void 0&&(a.angle=r.angle),Object.keys(a).length>0&&(a.type=I.Base,i.push(a));const c={};r.color!==void 0&&(c.color=r.color),r.alpha!==void 0&&(c.alpha=r.alpha),Object.keys(c).length>0&&(c.type=I.Color,i.push(c));const h={};r.borderColor!==void 0&&(h.color=r.borderColor),r.borderWidth!==void 0&&(h.width=r.borderWidth),r.borderAlpha!==void 0&&(h.alpha=r.borderAlpha),r.dashType!==void 0&&(h.dashType=r.dashType),Object.keys(h).length>0&&(h.type=I.Border,i.push(h));const d={};let u=!1;if(r.text!==void 0&&(d.richText=this.computeRichText(r.text),u=!0),r.fontSize!==void 0&&(d.fontSize=r.fontSize,u=!0),r.fontColor!==void 0&&(d.fontColor=r.fontColor,u=!0),r.bold!==void 0&&(d.bold=r.bold,u=!0),r.italic!==void 0&&(d.italic=r.italic,u=!0),r.underline!==void 0&&(d.underline=r.underline,u=!0),r.strikethrough!==void 0&&(d.strikethrough=r.strikethrough,u=!0),r.verticalAlign!==void 0&&(d.verticalAlign=r.verticalAlign,u=!0),r.horizonAlign!==void 0&&(d.horizonAlign=r.horizonAlign,u=!0),u&&(d.type=I.Text,i.push(d)),r.shapeCode!==void 0&&i.push(new Oe(r.shapeCode)),i.length===0){n.push({index:s,id:r.id,error:"没有提供任何更新属性"});continue}if(r.zIndex!==void 0){const f=e.nodeManager.getNode(r.id);f&&(f.zIndex=r.zIndex)}e.execAction(U.create(r.id,i)),o++}catch(i){n.push({index:s,id:r.id,error:i instanceof Error?i.message:String(i)})}}return e.execAction(new z),n.length===0?{code:200,successCount:o}:o===0?{code:500,msg:"所有节点更新失败",errorCount:n.length,errors:n}:{code:206,successCount:o,errorCount:n.length,errors:n}}catch(e){return console.error("[AINodeAPI] batchUpdateNode 失败:",e),{code:500,msg:`批量更新节点失败: ${e instanceof Error?e.message:String(e)}`}}}selectNode(t){try{const e=this.getCtx();if(t.x===void 0||t.y===void 0||t.width===void 0||t.height===void 0)return{code:400,msg:"缺少必需参数: x, y, width, height"};const n=t.x,o=t.y,s=t.x+t.width,r=t.y+t.height,i=e.nodeManager.searchNodes(n,o,s,r),a=[];for(const c of i){if(c===e.nodeManager.root)continue;const h=c.getBounds(),d=c.getProp(I.Base);let u="";(c.type===v.Shape||c.type===v.Line||c.type===v.CheckboxText)&&(u=c.renderText.toString()),a.push({id:c.id,text:u,x:(d==null?void 0:d.x)??h.minX,y:(d==null?void 0:d.y)??h.minY,width:(d==null?void 0:d.width)??h.maxX-h.minX,height:(d==null?void 0:d.height)??h.maxY-h.minY})}return{code:200,nodes:a,count:a.length}}catch(e){return console.error("[AINodeAPI] selectNode 失败:",e),{code:500,msg:`查询节点失败: ${e instanceof Error?e.message:String(e)}`}}}selectNodeDetail(t){try{const e=this.getCtx();if(!t.ids||!Array.isArray(t.ids)||t.ids.length===0)return{code:400,msg:"缺少必需参数: ids (非空数组)"};if(!t.ids.every(s=>typeof s=="string"))return{code:400,msg:"参数 ids 数组中的所有元素必须是字符串"};const n=[],o=[];for(const s of t.ids){const r=e.nodeManager.nodeMap.get(s);if(!r||r===e.nodeManager.root){o.push(s);continue}const i=r.getBounds(),a=r.getProp(I.Base),c=r.getProp(I.Color),h=r.getProp(I.Border),d=r.getProp(I.Text),u=r.getProp(I.Shape);let f="";(r.type===v.Shape||r.type===v.Line||r.type===v.CheckboxText)&&(f=r.renderText.toString()),n.push({id:r.id,type:r.type,x:(a==null?void 0:a.x)??i.minX,y:(a==null?void 0:a.y)??i.minY,width:(a==null?void 0:a.width)??i.maxX-i.minX,height:(a==null?void 0:a.height)??i.maxY-i.minY,angle:(a==null?void 0:a.angle)??0,zIndex:r.zIndex,color:(c==null?void 0:c.color)??"#FFFFFF",alpha:(c==null?void 0:c.alpha)??1,borderColor:(h==null?void 0:h.color)??"#000000",dashType:(h==null?void 0:h.dashType)??1,text:f,fontSize:d==null?void 0:d.fontSize,fontColor:d==null?void 0:d.fontColor,shapeCode:(u==null?void 0:u.shapeCode)??1})}return o.length>0?{code:200,nodes:n,count:n.length,msg:`部分节点查询成功,以下节点不存在: ${o.join(", ")}`}:{code:200,nodes:n,count:n.length}}catch(e){return console.error("[AINodeAPI] selectNodeDetail 失败:",e),{code:500,msg:`查询节点详细信息失败: ${e instanceof Error?e.message:String(e)}`}}}computeTextNodeSize(t){try{const e=this.getCtx();if(!t.ids||!Array.isArray(t.ids)||t.ids.length===0)return{code:400,msg:"缺少必需参数: ids (非空数组)"};if(!t.ids.every(i=>typeof i=="string"))return{code:400,msg:"参数 ids 数组中的所有元素必须是字符串"};const n=[],o=[],s=[];for(const i of t.ids){const a=e.nodeManager.getNode(i);if(!a||a===e.nodeManager.root){o.push(i);continue}if(!(a instanceof vt)){s.push(i);continue}const c=a.drawer.fullTextNodeHeight(a),h=a.renderText.width+2*le;n.push({id:i,width:h,height:c})}const r=[];return o.length>0&&r.push(`以下节点不存在: ${o.join(", ")}`),s.length>0&&r.push(`以下节点不是文字节点: ${s.join(", ")}`),n.length===0?{code:404,msg:r.join("; ")}:{code:200,nodes:n,count:n.length,msg:r.length>0?r.join("; "):void 0}}catch(e){return console.error("[AINodeAPI] computeTextNodeSize 失败:",e),{code:500,msg:`计算文字节点尺寸失败: ${e instanceof Error?e.message:String(e)}`}}}addLine(t){try{const e=this.getCtx();if(!t.points||!Array.isArray(t.points))return{code:400,msg:"缺少必需参数: points"};if(t.points.length<2)return{code:400,msg:"points 数组至少需要2个点(起点和终点)"};for(let u=0;u<t.points.length;u++){const f=t.points[u];if(typeof f.x!="number"||typeof f.y!="number"||isNaN(f.x)||isNaN(f.y))return{code:400,msg:`points[${u}] 必须包含有效的 x 和 y 坐标`}}const n=e.idGenerator.genId(v.Line),o=e.nodeManager.root;let s=t.points[0].x,r=t.points[0].y,i=t.points[0].x,a=t.points[0].y;for(const u of t.points)s=Math.min(s,u.x),r=Math.min(r,u.y),i=Math.max(i,u.x),a=Math.max(a,u.y);const c=[ie.create({x:s,y:r,width:i-s,height:a-r,angle:0}),Ae.create({color:t.borderColor??"#000000",alpha:1,width:t.borderWidth??2,dashType:t.dashType??1}),Ge.create({richText:this.computeRichText(t.text??""),fontSize:t.fontSize??14,fontColor:t.fontColor??"#000000"}),new Oe(t.shapeCode??0),je.create(t.points,!0),new Rt,lt.create({lArrow:t.lArrow??0,rArrow:t.rArrow??0})],h=new Et;h.width=20,h.height=20,h.point={x:t.points[Math.floor(t.points.length/2)].x,y:t.points[Math.floor(t.points.length/2)].y},c.push(h);const d={id:n,parentId:o.id,type:v.Line,zIndex:t.zIndex??ve.genZIndex(o),props:c};return e.execAction(new W),e.execAction(new Le({nodes:[d]})),e.execAction(new z),{code:200,id:n}}catch(e){return console.error("[AINodeAPI] addLine 失败:",e),{code:500,msg:`添加连线失败: ${e instanceof Error?e.message:String(e)}`}}}addSvg(t){try{const e=this.getCtx();if(t.x===void 0||t.y===void 0||t.width===void 0||t.height===void 0)return{code:400,msg:"缺少必需参数: x, y, width, height"};if(!t.svgCode||typeof t.svgCode!="string")return{code:400,msg:"缺少必需参数: svgCode"};if(!t.svgCode.includes('xmlns="http://www.w3.org/2000/svg"')&&!t.svgCode.includes("xmlns='http://www.w3.org/2000/svg'"))return{code:400,msg:'SVG 代码必须包含 xmlns="http://www.w3.org/2000/svg" 属性'};const n=e.idGenerator.genId(v.SVG),o=e.nodeManager.root,s=new Wn;s.url="",s.useCode=!0,s.code=t.svgCode;const r=[ie.create({x:t.x,y:t.y,width:t.width,height:t.height,angle:t.angle??0}),Ae.create({color:t.borderColor??"",alpha:1,width:t.borderWidth??2,dashType:t.dashType??0}),s],i={id:n,parentId:o.id,type:v.SVG,zIndex:ve.genZIndex(o),props:r};return e.execAction(new W),e.execAction(new Le({nodes:[i]})),e.execAction(new z),{code:200,id:n}}catch(e){return console.error("[AINodeAPI] addSvg 失败:",e),{code:500,msg:`添加SVG节点失败: ${e instanceof Error?e.message:String(e)}`}}}batchAddNodes(t){try{const e=this.getCtx();if(!t.nodes||!Array.isArray(t.nodes))return{code:400,msg:"缺少必需参数: nodes"};if(t.nodes.length===0)return{code:400,msg:"nodes 数组不能为空"};for(let r=0;r<t.nodes.length;r++){const i=t.nodes[r];if(i.x===void 0||i.y===void 0||i.width===void 0||i.height===void 0)return{code:400,msg:`nodes[${r}] 缺少必需参数: x, y, width, height`}}const n=e.nodeManager.root,o=[],s=[];for(const r of t.nodes){const i=e.idGenerator.genId(v.Shape);s.push(i);const a=Ge.create({richText:this.computeRichText(r.text??""),fontSize:r.fontSize,fontColor:r.fontColor,bold:r.bold,italic:r.italic,underline:r.underline,strikethrough:r.strikethrough,verticalAlign:r.verticalAlign,horizonAlign:r.horizonAlign}),c=[ie.create({x:r.x,y:r.y,width:r.width,height:r.height,angle:r.angle??0}),tt.create({color:r.color??"#FFFFFF",alpha:r.alpha??1}),Ae.create({color:r.borderColor??"#000000",alpha:1,width:2,dashType:r.dashType??1}),a,new Oe(r.shapeCode??1)],h={id:i,parentId:n.id,type:v.Shape,zIndex:r.zIndex??ve.genZIndex(n),props:c};o.push(h)}return e.execAction(new W),e.execAction(new Le({nodes:o})),e.execAction(new z),{code:200,ids:s,count:s.length}}catch(e){return console.error("[AINodeAPI] batchAddNodes 失败:",e),{code:500,msg:`批量添加节点失败: ${e instanceof Error?e.message:String(e)}`}}}batchAddLines(t){try{const e=this.getCtx();if(!t.lines||!Array.isArray(t.lines))return{code:400,msg:"缺少必需参数: lines"};if(t.lines.length===0)return{code:400,msg:"lines 数组不能为空"};for(let r=0;r<t.lines.length;r++){const i=t.lines[r];if(!i.points||!Array.isArray(i.points))return{code:400,msg:`lines[${r}] 缺少必需参数: points`};if(i.points.length<2)return{code:400,msg:`lines[${r}].points 数组至少需要2个点(起点和终点)`};for(let a=0;a<i.points.length;a++){const c=i.points[a];if(typeof c.x!="number"||typeof c.y!="number"||isNaN(c.x)||isNaN(c.y))return{code:400,msg:`lines[${r}].points[${a}] 必须包含有效的 x 和 y 坐标`}}}const n=e.nodeManager.root,o=[],s=[];for(const r of t.lines){const i=e.idGenerator.genId(v.Line);s.push(i);let a=r.points[0].x,c=r.points[0].y,h=r.points[0].x,d=r.points[0].y;for(const y of r.points)a=Math.min(a,y.x),c=Math.min(c,y.y),h=Math.max(h,y.x),d=Math.max(d,y.y);const u=[ie.create({x:a,y:c,width:h-a,height:d-c,angle:0}),Ae.create({color:r.borderColor??"#000000",alpha:1,width:r.borderWidth??2,dashType:r.dashType??1}),Ge.create({richText:this.computeRichText(r.text??""),fontSize:r.fontSize??14,fontColor:r.fontColor??"#000000"}),new Oe(r.shapeCode??0),je.create(r.points,!0),new Rt,lt.create({lArrow:r.lArrow??0,rArrow:r.rArrow??0})],f=new Et;f.width=20,f.height=20,f.point={x:r.points[Math.floor(r.points.length/2)].x,y:r.points[Math.floor(r.points.length/2)].y},u.push(f);const g={id:i,parentId:n.id,type:v.Line,zIndex:r.zIndex??ve.genZIndex(n),props:u};o.push(g)}return e.execAction(new W),e.execAction(new Le({nodes:o})),e.execAction(new z),{code:200,ids:s,count:s.length}}catch(e){return console.error("[AINodeAPI] batchAddLines 失败:",e),{code:500,msg:`批量添加连线失败: ${e instanceof Error?e.message:String(e)}`}}}connectLine(t){try{const e=this.getCtx();if(!t.startInfo&&!t.startPoint)return{code:400,msg:"必须提供 startInfo 或 startPoint 中的一个"};if(!t.endInfo&&!t.endPoint)return{code:400,msg:"必须提供 endInfo 或 endPoint 中的一个"};let n=null;if(t.startInfo){if(n=e.nodeManager.getNode(t.startInfo.id),!n)return{code:404,msg:`起始节点不存在: ${t.startInfo.id}`};if(![0,1,2,3].includes(t.startInfo.endType))return{code:400,msg:"startInfo.endType 必须是 0, 1, 2 或 3"}}let o=null;if(t.endInfo){if(o=e.nodeManager.getNode(t.endInfo.id),!o)return{code:404,msg:`终止节点不存在: ${t.endInfo.id}`};if(![0,1,2,3].includes(t.endInfo.endType))return{code:400,msg:"endInfo.endType 必须是 0, 1, 2 或 3"}}if(t.startPoint&&(typeof t.startPoint.x!="number"||typeof t.startPoint.y!="number"||isNaN(t.startPoint.x)||isNaN(t.startPoint.y)))return{code:400,msg:"startPoint 必须包含有效的 x 和 y 坐标"};if(t.endPoint&&(typeof t.endPoint.x!="number"||typeof t.endPoint.y!="number"||isNaN(t.endPoint.x)||isNaN(t.endPoint.y)))return{code:400,msg:"endPoint 必须包含有效的 x 和 y 坐标"};const s=(E,X)=>{const $=E.props.get(I.Base);if(!$)throw new Error("节点缺少 BaseProps");const{x:Z,y:se,width:ne,height:ae}=$;switch(X){case 0:return{x:Z+ne/2,y:se};case 1:return{x:Z+ne,y:se+ae/2};case 2:return{x:Z+ne/2,y:se+ae};case 3:return{x:Z,y:se+ae/2};default:return{x:Z+ne/2,y:se+ae/2}}};let r,i;if(t.startInfo&&n){const E=s(n,t.startInfo.endType);r=E.x,i=E.y}else if(t.startPoint)r=t.startPoint.x,i=t.startPoint.y;else return{code:400,msg:"无法计算起点坐标"};let a,c;if(t.endInfo&&o){const E=s(o,t.endInfo.endType);a=E.x,c=E.y}else if(t.endPoint)a=t.endPoint.x,c=t.endPoint.y;else return{code:400,msg:"无法计算终点坐标"};const h=t.shapeCode??0;let d;const u={point:{x:r,y:i}};if(t.startInfo&&n){const E=D.rectNode2Rect(n.getBounds()),X=[de.Top,de.Right,de.Bottom,de.Left];u.nodeConnect={rect:E,endType:X[t.startInfo.endType]}}const f={point:{x:a,y:c}};if(t.endInfo&&o){const E=D.rectNode2Rect(o.getBounds()),X=[de.Top,de.Right,de.Bottom,de.Left];f.nodeConnect={rect:E,endType:X[t.endInfo.endType]}}h===0?d=new Xo().layoutToPointsPro(u,f):h===3?d=new po().layoutToPointsPro(u,f):d=new Vt().layoutToPointsPro(u,f);const g=e.idGenerator.genId(v.Line),y=e.nodeManager.root,P=S.getBoundsByPoints(d),w=[{type:I.Base,x:P.minX,y:P.minY,width:P.maxX-P.minX,height:P.maxY-P.minY},Ae.create({color:t.borderColor??"#000000",alpha:1,width:t.borderWidth??2,dashType:t.dashType??1}),Ge.create({richText:this.computeRichText(t.text??""),fontSize:t.fontSize??14,fontColor:t.fontColor??"#000000"}),new Oe(t.shapeCode??0),je.create(d,!0),lt.create({lArrow:t.lArrow??0,rArrow:t.rArrow??0})],L=new Rt;if(t.startInfo&&n){const X=n.drawer.getConnectAnchor()[t.startInfo.endType];L.start={objectId:t.startInfo.id,x:X.x,y:X.y}}else L.start=null;if(t.endInfo&&o){const X=o.drawer.getConnectAnchor()[t.endInfo.endType];L.end={objectId:t.endInfo.id,x:X.x,y:X.y}}else L.end=null;w.push(L);const B=new Et;B.width=20,B.height=20,B.point={x:(r+a)/2,y:(i+c)/2},w.push(B);const H={id:g,parentId:y.id,type:v.Line,zIndex:t.zIndex??ve.genZIndex(y),props:w};return e.execAction(new W),e.execAction(new Le({nodes:[H]})),e.execAction(new z),{code:200,id:g}}catch(e){return console.error("[AINodeAPI] connectLine 失败:",e),console.error("[AINodeAPI] connectLine 失败:",e),{code:500,msg:`创建连接线失败: ${e instanceof Error?e.message:String(e)}`}}}batchConnectLine(t){var e,n,o,s,r,i,a,c,h;try{const d=this.getCtx();if(!t.connections||!Array.isArray(t.connections))return{code:400,msg:"connections 参数必须是一个数组"};if(t.connections.length===0)return{code:400,msg:"connections 数组不能为空"};const u=[];let f=0,g=0;d.execAction(new W);for(let y=0;y<t.connections.length;y++){const P=t.connections[y],b={startInfo:P.startInfo,endInfo:P.endInfo,startPoint:P.startPoint,endPoint:P.endPoint,zIndex:P.zIndex??((e=t.defaultStyle)==null?void 0:e.zIndex),shapeCode:P.shapeCode??((n=t.defaultStyle)==null?void 0:n.shapeCode)??0,borderColor:P.borderColor??((o=t.defaultStyle)==null?void 0:o.borderColor)??"#000000",borderWidth:P.borderWidth??((s=t.defaultStyle)==null?void 0:s.borderWidth)??2,dashType:P.dashType??((r=t.defaultStyle)==null?void 0:r.dashType)??1,lArrow:P.lArrow??((i=t.defaultStyle)==null?void 0:i.lArrow)??0,rArrow:P.rArrow??((a=t.defaultStyle)==null?void 0:a.rArrow)??0,text:P.text??"",fontSize:P.fontSize??((c=t.defaultStyle)==null?void 0:c.fontSize)??14,fontColor:P.fontColor??((h=t.defaultStyle)==null?void 0:h.fontColor)??"#000000",textPosition:P.textPosition??.5};try{if(!b.startInfo&&!b.startPoint)throw new Error(`连接 ${y}: 必须提供 startInfo 或 startPoint 中的一个`);if(!b.endInfo&&!b.endPoint)throw new Error(`连接 ${y}: 必须提供 endInfo 或 endPoint 中的一个`);let w=null;if(b.startInfo){if(w=d.nodeManager.getNode(b.startInfo.id),!w)throw new Error(`连接 ${y}: 起始节点不存在: ${b.startInfo.id}`);if(![0,1,2,3].includes(b.startInfo.endType))throw new Error(`连接 ${y}: startInfo.endType 必须是 0, 1, 2 或 3`)}let L=null;if(b.endInfo){if(L=d.nodeManager.getNode(b.endInfo.id),!L)throw new Error(`连接 ${y}: 终止节点不存在: ${b.endInfo.id}`);if(![0,1,2,3].includes(b.endInfo.endType))throw new Error(`连接 ${y}: endInfo.endType 必须是 0, 1, 2 或 3`)}if(b.startPoint&&(typeof b.startPoint.x!="number"||typeof b.startPoint.y!="number"||isNaN(b.startPoint.x)||isNaN(b.startPoint.y)))throw new Error(`连接 ${y}: startPoint 必须包含有效的 x 和 y 坐标`);if(b.endPoint&&(typeof b.endPoint.x!="number"||typeof b.endPoint.y!="number"||isNaN(b.endPoint.x)||isNaN(b.endPoint.y)))throw new Error(`连接 ${y}: endPoint 必须包含有效的 x 和 y 坐标`);const B=(O,G)=>{const j=O.props.get(I.Base);if(!j)throw new Error("节点缺少 BaseProps");const{x:_,y:Ve,width:ut,height:yt}=j;switch(G){case 0:return{x:_+ut/2,y:Ve};case 1:return{x:_+ut,y:Ve+yt/2};case 2:return{x:_+ut/2,y:Ve+yt};case 3:return{x:_,y:Ve+yt/2};default:return{x:_+ut/2,y:Ve+yt/2}}};let H,E;if(b.startInfo&&w){const O=B(w,b.startInfo.endType);H=O.x,E=O.y}else if(b.startPoint)H=b.startPoint.x,E=b.startPoint.y;else throw new Error(`连接 ${y}: 无法计算起点坐标`);let X,$;if(b.endInfo&&L){const O=B(L,b.endInfo.endType);X=O.x,$=O.y}else if(b.endPoint)X=b.endPoint.x,$=b.endPoint.y;else throw new Error(`连接 ${y}: 无法计算终点坐标`);const Z=b.shapeCode;let se;const ne={point:{x:H,y:E}};if(b.startInfo&&w){const O=D.rectNode2Rect(w.getBounds()),G=[de.Top,de.Right,de.Bottom,de.Left];ne.nodeConnect={rect:O,endType:G[b.startInfo.endType]}}const ae={point:{x:X,y:$}};if(b.endInfo&&L){const O=D.rectNode2Rect(L.getBounds()),G=[de.Top,de.Right,de.Bottom,de.Left];ae.nodeConnect={rect:O,endType:G[b.endInfo.endType]}}Z===0?se=new Xo().layoutToPointsPro(ne,ae):Z===3?se=new po().layoutToPointsPro(ne,ae):se=new Vt().layoutToPointsPro(ne,ae);const te=d.idGenerator.genId(v.Line),ce=d.nodeManager.root,pe=S.getBoundsByPoints(se),Re=[{type:I.Base,x:pe.minX,y:pe.minY,width:pe.maxX-pe.minX,height:pe.maxY-pe.minY},Ae.create({color:b.borderColor,alpha:1,width:b.borderWidth,dashType:b.dashType}),Ge.create({richText:this.computeRichText(b.text),fontSize:b.fontSize,fontColor:b.fontColor}),new Oe(b.shapeCode),je.create(se,!0),lt.create({lArrow:b.lArrow,rArrow:b.rArrow})],Se=new Rt;if(b.startInfo&&w){const G=w.drawer.getConnectAnchor()[b.startInfo.endType];Se.start={objectId:b.startInfo.id,x:G.x,y:G.y}}else Se.start=null;if(b.endInfo&&L){const G=L.drawer.getConnectAnchor()[b.endInfo.endType];Se.end={objectId:b.endInfo.id,x:G.x,y:G.y}}else Se.end=null;Re.push(Se);const Te=new Et;Te.width=20,Te.height=20,Te.point={x:(H+X)/2,y:(E+$)/2},Re.push(Te);const fe={id:te,parentId:ce.id,type:v.Line,zIndex:b.zIndex??ve.genZIndex(ce),props:Re};d.execAction(new Le({nodes:[fe]})),u.push({index:y,success:!0,id:te}),f++}catch(w){const L=w instanceof Error?w.message:String(w);console.error(`[AINodeAPI] 批量连接线 - 连接 ${y} 失败:`,w),u.push({index:y,success:!1,error:L}),g++}}return d.execAction(new z),{code:200,successCount:f,failedCount:g,results:u}}catch(d){return console.error("[AINodeAPI] batchConnectLine 失败:",d),{code:500,msg:`批量创建连接线失败: ${d instanceof Error?d.message:String(d)}`}}}}class iy{constructor(t){p(this,"app");this.app=t}getCtx(){return this.app.appContext}getViewportBounds(){try{const e=this.getCtx().gmlRender.getViewPortBounds();return{code:200,bounds:{minX:e.minX,minY:e.minY,maxX:e.maxX,maxY:e.maxY,width:e.maxX-e.minX,height:e.maxY-e.minY}}}catch(t){return console.error("[AIViewportAPI] getViewportBounds 失败:",t),{code:500,msg:`获取视口边界失败: ${t instanceof Error?t.message:String(t)}`}}}zoomToBounds(t,e,n,o){try{const s=this.getCtx();if(t>=n||e>=o)return{code:400,msg:"无效的边界参数:minX 必须小于 maxX,minY 必须小于 maxY"};const r={minX:t,minY:e,maxX:n,maxY:o,id:"temp-zoom-bounds"};return s.renderManager.zoomWorker.zoomToBounds(r,s.renderManager),{code:200}}catch(s){return console.error("[AIViewportAPI] zoomToBounds 失败:",s),{code:500,msg:`缩放到指定边界失败: ${s instanceof Error?s.message:String(s)}`}}}zoomToFit(){try{const t=this.getCtx();return t.renderManager.nodeManager.nodeMap.size===0?{code:400,msg:"画布中没有节点,无法执行适配缩放"}:(t.renderManager.zoomWorker.zoomToFit(t.renderManager),{code:200})}catch(t){return console.error("[AIViewportAPI] zoomToFit 失败:",t),{code:500,msg:`缩放适配所有节点失败: ${t instanceof Error?t.message:String(t)}`}}}zoomToSelect(){try{const t=this.getCtx();return t.renderManager.auxiliaryManager.selectManager.getSelectNodes().length===0?{code:400,msg:"当前没有选中任何节点,无法执行缩放"}:(t.renderManager.zoomWorker.zoomToSelect(t.renderManager),{code:200})}catch(t){return console.error("[AIViewportAPI] zoomToSelect 失败:",t),{code:500,msg:`缩放到选中节点失败: ${t instanceof Error?t.message:String(t)}`}}}}class ay{constructor(t){p(this,"app");this.app=t}getCtx(){return this.app.appContext}getSelectedNodes(){try{const t=this.getCtx(),e=t.getSelectNodes();if(!e||e.size===0)return{code:200,nodes:[],count:0};const n=[];for(const o of e){if(o===t.nodeManager.root)continue;const s=o.getBounds(),r=o.getProp(I.Base);let i="";(o.type===v.Shape||o.type===v.Line||o.type===v.CheckboxText)&&(i=o.renderText.toString()),n.push({id:o.id,text:i,x:(r==null?void 0:r.x)??s.minX,y:(r==null?void 0:r.y)??s.minY,width:(r==null?void 0:r.width)??s.maxX-s.minX,height:(r==null?void 0:r.height)??s.maxY-s.minY})}return{code:200,nodes:n,count:n.length}}catch(t){return console.error("[SelectAPI] getSelectedNodes 失败:",t),{code:500,msg:`获取选中节点信息失败: ${t instanceof Error?t.message:String(t)}`}}}selectAllNodes(){try{const t=this.getCtx(),e=[];for(const[n,o]of t.nodeManager.nodeMap){if(o===t.nodeManager.root)continue;const s=o.getBounds(),r=o.getProp(I.Base);let i="";(o.type===v.Shape||o.type===v.Line||o.type===v.CheckboxText)&&(i=o.renderText.toString()),e.push({id:o.id,text:i,x:(r==null?void 0:r.x)??s.minX,y:(r==null?void 0:r.y)??s.minY,width:(r==null?void 0:r.width)??s.maxX-s.minX,height:(r==null?void 0:r.height)??s.maxY-s.minY})}return{code:200,nodes:e,count:e.length}}catch(t){return console.error("[SelectAPI] selectAllNodes 失败:",t),{code:500,msg:`获取所有节点信息失败: ${t instanceof Error?t.message:String(t)}`}}}}class jc{constructor(t){p(this,"app");p(this,"node");p(this,"viewport");p(this,"select");this.app=t,this.node=new ry(t),this.viewport=new iy(t),this.select=new ay(t)}}class cy{constructor(t){p(this,"renderDom",null);p(this,"inputDom",null);p(this,"isFocusing",!1);p(this,"cursorManager");this.cursorManager=t}init(t,e){this.inputDom=t,this.renderDom=e}focus(){setTimeout(()=>{this.inputDom.focus(),console.log("njx debug ======>i am focus")},100),this.isFocusing=!0,this.cursorManager.setCursor("text")}blur(){this.isFocusing=!1,this.inputDom.blur(),this.renderDom.style.display="none"}hideRenderDom(){this.renderDom.style.display="none"}updateCursor(t,e,n,o){const s=e.globalTransform.crossPoint(t),r=e.canvas.getBoundingClientRect(),i=window.devicePixelRatio;let a=s.x/i+r.x,c=s.y/i+r.y;a>r.width&&(a=0),c>r.height&&(c=0),this.renderDom.style.left=a+"px",this.renderDom.style.top=c+"px",this.inputDom.style.left=a+"px",this.inputDom.style.top=c+"px",this.renderDom.style.transform=`rotate(${o}deg)`,this.renderDom.style.transformOrigin="top left",this.renderDom.style.display="unset",this.renderDom.style.height=n*e.getScale()+"px"}}class ly{constructor(){p(this,"selectionInfo",null);p(this,"selectionWorker",new yc)}clear(){this.selectionInfo=null}generateSelect(t,e,n){const o=this.selectionWorker.computeTextSelection(t,e,n);return o.length===0?[]:(this.selectionInfo={start:e,end:n,selectionList:o},o)}}class hy{constructor(t,e){p(this,"renderInput");p(this,"editTextInfo",null);p(this,"selectionManager",new ly);p(this,"renderManager");this.renderInput=new cy(e),this.renderManager=t}init(t,e){var n;(n=this.renderInput)==null||n.init(t,e),this.renderInput.hideRenderDom()}isEdit(){return this.editTextInfo!==null}hasSelection(){return this.selectionManager.selectionInfo!==null}checkNeedReFocusInputDom(t){return!this.editTextInfo||this.editTextInfo.node.id!==t.node.id||!this.editTextInfo.textCursorPosition.equal(t.textCursorPosition)}focus(t){this.checkNeedReFocusInputDom(t),this.editTextInfo=t;const{node:e,renderText:n,textCursorPosition:o}=t,{relativePos:s,height:r}=n.getPosByCursorPosition(o),i=e.toGlobal(s);this.renderInput.focus(),console.log("njx debug:===>focus"),this.renderInput.updateCursor(i,this.renderManager.gmlRender,r,e.baseProps.angle),this.selectionManager.clear()}selection(t,e,n,o){let s=n,r=o;o.greaterThan(n)||(s=o,r=n),this.editTextInfo={node:t,renderText:e,textCursorPosition:s};const i=this.selectionManager.generateSelect(e,s,r);return this.renderInput.focus(),this.renderInput.hideRenderDom(),i}refreshCursor(){if(!this.editTextInfo)return;const{node:t,renderText:e,textCursorPosition:n}=this.editTextInfo,{relativePos:o,height:s}=e.getPosByCursorPosition(n),r=t.toGlobal(o);this.renderInput.updateCursor(r,this.renderManager.gmlRender,s,t.baseProps.angle)}updateCursorPos(t){this.editTextInfo&&(this.editTextInfo.textCursorPosition=t,this.refreshCursor())}blur(){var t;console.log("====>blur"),this.selectionManager.selectionInfo&&this.selectionManager.clear(),this.editTextInfo&&(this.editTextInfo.node.resetFromEditing(),this.renderManager.addContentRenderTask(),(t=this.renderInput)==null||t.blur(),this.editTextInfo=null)}}class dy{constructor(t,e){p(this,"docState");p(this,"nodeManager");this.docState=e,this.nodeManager=t}serializeTo(){const t=[],e=this.nodeManager;for(const[o,s]of e.nodeMap)t.push(s.serializeTo());return{documentId:"",nodes:t}}deSerialize(t){return JSON.parse(t)}}class Vc{constructor(){p(this,"canEdit",!0)}}class Kc{constructor(){p(this,"seq",0);p(this,"savedSeq",-1);p(this,"backgroundColor","#EEEEEE");p(this,"userid","");p(this,"sessionId","");p(this,"docId","");p(this,"userPermission",new Vc);p(this,"docMode",ue.BOARD);p(this,"slideStatus",{slideContainer:null,currentIndex:0,slideCoverList:[]})}load(t){this.backgroundColor=t.backgroundColor,this.seq=t.seq,this.savedSeq=t.savedSeq}canEdit(){return this.userPermission.canEdit}changePermission({canEdit:t}){this.userPermission.canEdit=t}resetSlideCovers(){if(this.slideStatus.slideCoverList.length!==0){for(const t of this.slideStatus.slideCoverList)URL.revokeObjectURL(t.blobUrl);this.slideStatus.slideCoverList=[]}}}function Qc(){return{backgroundColor:"#EEEEEE",seq:0,savedSeq:0}}class Zc{}class mr{constructor(){p(this,"globalTransform",re.generateMatrix());p(this,"canvas",null);p(this,"glCtx",null);this.globalTransform.a=window.devicePixelRatio,this.globalTransform.d=window.devicePixelRatio}init(t){this.canvas=t;const e=this.canvas.getContext("2d");this.glCtx=e;const{a:n,b:o,c:s,d:r,e:i,f:a}=this.globalTransform;e.transform(n,o,s,r,i,a)}setTransform(t,e,n,o,s,r){this.globalTransform.setTransform(t,e,n,o,s,r),this.glCtx.setTransform(t,e,n,o,s,r)}reset(){if(!this.canvas){console.error("Error! The canvas is null!");return}const t=this.canvas.getContext("2d"),{a:e,b:n,c:o,d:s,e:r,f:i}=this.globalTransform;t.setTransform(e,n,o,s,r,i)}scale(t,e,n){if(!n){this.globalTransform.a*=t,this.globalTransform.d*=e;return}const o=re.generateMatrix().translate(-n.x,-n.y),s=re.generateMatrix().scale(t,t),i=re.generateMatrix().translate(n.x,n.y).crossProduct(s).crossProduct(o);this.globalTransform=this.globalTransform.crossProduct(i)}translation(t,e){const n=re.generateMatrix().translate(t,e);this.globalTransform=this.globalTransform.crossProduct(n)}resetTransform(){this.globalTransform=re.generateMatrix(),this.globalTransform.a=window.devicePixelRatio,this.globalTransform.d=window.devicePixelRatio}transformToLocal(t){const{a:e,b:n,c:o,d:s,e:r,f:i}=this.globalTransform;return t.x=e*t.x+o*t.y+r,t.y=n*t.x+s*t.y+i,t.x=t.x/window.devicePixelRatio,t.y=t.y/window.devicePixelRatio,t}transformToGlobal(t){const e=new m(t.x,t.y);e.x=e.x*window.devicePixelRatio,e.y=e.y*window.devicePixelRatio;const{a:n,d:o,e:s,f:r}=this.globalTransform;return e.x=e.x/n-s/n,e.y=e.y/o-r/o,e}dirtyDraw(t,e){const n=this.canvas.getContext("2d");n.clearRect(t.minX,t.minY,t.maxX-t.minX,t.maxY-t.minY),n.save(),n.beginPath(),n.rect(t.minX,t.minY,t.maxX-t.minX,t.maxY-t.minY),n.clip();for(const o of e)o.draw();n.restore()}getViewPortBounds(){const t=this.canvas.getBoundingClientRect(),e=new m(t.width,t.height),n=this.transformToGlobal(new m(0,0)),o=this.transformToGlobal(e);return{id:"rect",minX:n.x,minY:n.y,maxX:o.x,maxY:o.y}}getGlobalPoint(t){const e=this.canvas.getBoundingClientRect(),n=new m(t.clientX-e.x,t.clientY-e.y);return this.transformToGlobal(n)}getScale(){const t=window.devicePixelRatio;return this.globalTransform.a/t}scaleToCenter(t){const e=this.getScale(),n=t/e,o=this.getViewPortBounds(),s=new m(.5*(o.minX+o.maxX),.5*(o.minY+o.maxY));this.scale(n,n,s)}}function uy(l,t,e,n,o){qc(l,t,e||0,n||l.length-1,o||py)}function qc(l,t,e,n,o){for(;n>e;){if(n-e>600){var s=n-e+1,r=t-e+1,i=Math.log(s),a=.5*Math.exp(2*i/3),c=.5*Math.sqrt(i*a*(s-a)/s)*(r-s/2<0?-1:1),h=Math.max(e,Math.floor(t-r*a/s+c)),d=Math.min(n,Math.floor(t+(s-r)*a/s+c));qc(l,t,h,d,o)}var u=l[t],f=e,g=n;for(vo(l,e,t),o(l[n],u)>0&&vo(l,e,n);f<g;){for(vo(l,f,g),f++,g--;o(l[f],u)<0;)f++;for(;o(l[g],u)>0;)g--}o(l[e],u)===0?vo(l,e,g):(g++,vo(l,g,n)),g<=t&&(e=g+1),t<=g&&(n=g-1)}}function vo(l,t,e){var n=l[t];l[t]=l[e],l[e]=n}function py(l,t){return l<t?-1:l>t?1:0}class fy{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(t){let e=this.data;const n=[];if(!ds(t,e))return n;const o=this.toBBox,s=[];for(;e;){for(let r=0;r<e.children.length;r++){const i=e.children[r],a=e.leaf?o(i):i;ds(t,a)&&(e.leaf?n.push(i):br(t,a)?this._all(i,n):s.push(i))}e=s.pop()}return n}collides(t){let e=this.data;if(!ds(t,e))return!1;const n=[];for(;e;){for(let o=0;o<e.children.length;o++){const s=e.children[o],r=e.leaf?this.toBBox(s):s;if(ds(t,r)){if(e.leaf||br(t,r))return!0;n.push(s)}}e=n.pop()}return!1}load(t){if(!(t&&t.length))return this;if(t.length<this._minEntries){for(let n=0;n<t.length;n++)this.insert(t[n]);return this}let e=this._build(t.slice(),0,t.length-1,0);if(!this.data.children.length)this.data=e;else if(this.data.height===e.height)this._splitRoot(this.data,e);else{if(this.data.height<e.height){const n=this.data;this.data=e,e=n}this._insert(e,this.data.height-e.height-1,!0)}return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=Zn([]),this}remove(t,e){if(!t)return this;let n=this.data;const o=this.toBBox(t),s=[],r=[];let i,a,c;for(;n||s.length;){if(n||(n=s.pop(),a=s[s.length-1],i=r.pop(),c=!0),n.leaf){const h=gy(t,n.children,e);if(h!==-1)return n.children.splice(h,1),s.push(n),this._condense(s),this}!c&&!n.leaf&&br(n,o)?(s.push(n),r.push(i),i=0,a=n,n=n.children[0]):a?(i++,n=a.children[i],c=!1):n=null}return this}toBBox(t){return t}compareMinX(t,e){return t.minX-e.minX}compareMinY(t,e){return t.minY-e.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,e){const n=[];for(;t;)t.leaf?e.push(...t.children):n.push(...t.children),t=n.pop();return e}_build(t,e,n,o){const s=n-e+1;let r=this._maxEntries,i;if(s<=r)return i=Zn(t.slice(e,n+1)),Qn(i,this.toBBox),i;o||(o=Math.ceil(Math.log(s)/Math.log(r)),r=Math.ceil(s/Math.pow(r,o-1))),i=Zn([]),i.leaf=!1,i.height=o;const a=Math.ceil(s/r),c=a*Math.ceil(Math.sqrt(r));Jc(t,e,n,c,this.compareMinX);for(let h=e;h<=n;h+=c){const d=Math.min(h+c-1,n);Jc(t,h,d,a,this.compareMinY);for(let u=h;u<=d;u+=a){const f=Math.min(u+a-1,d);i.children.push(this._build(t,u,f,o-1))}}return Qn(i,this.toBBox),i}_chooseSubtree(t,e,n,o){for(;o.push(e),!(e.leaf||o.length-1===n);){let s=1/0,r=1/0,i;for(let a=0;a<e.children.length;a++){const c=e.children[a],h=Pr(c),d=wy(t,c)-h;d<r?(r=d,s=h<s?h:s,i=c):d===r&&h<s&&(s=h,i=c)}e=i||e.children[0]}return e}_insert(t,e,n){const o=n?t:this.toBBox(t),s=[],r=this._chooseSubtree(o,this.data,e,s);for(r.children.push(t),To(r,o);e>=0&&s[e].children.length>this._maxEntries;)this._split(s,e),e--;this._adjustParentBBoxes(o,s,e)}_split(t,e){const n=t[e],o=n.children.length,s=this._minEntries;this._chooseSplitAxis(n,s,o);const r=this._chooseSplitIndex(n,s,o),i=Zn(n.children.splice(r,n.children.length-r));i.height=n.height,i.leaf=n.leaf,Qn(n,this.toBBox),Qn(i,this.toBBox),e?t[e-1].children.push(i):this._splitRoot(n,i)}_splitRoot(t,e){this.data=Zn([t,e]),this.data.height=t.height+1,this.data.leaf=!1,Qn(this.data,this.toBBox)}_chooseSplitIndex(t,e,n){let o,s=1/0,r=1/0;for(let i=e;i<=n-e;i++){const a=Io(t,0,i,this.toBBox),c=Io(t,i,n,this.toBBox),h=my(a,c),d=Pr(a)+Pr(c);h<s?(s=h,o=i,r=d<r?d:r):h===s&&d<r&&(r=d,o=i)}return o||n-e}_chooseSplitAxis(t,e,n){const o=t.leaf?this.compareMinX:yy,s=t.leaf?this.compareMinY:xy,r=this._allDistMargin(t,e,n,o),i=this._allDistMargin(t,e,n,s);r<i&&t.children.sort(o)}_allDistMargin(t,e,n,o){t.children.sort(o);const s=this.toBBox,r=Io(t,0,e,s),i=Io(t,n-e,n,s);let a=hs(r)+hs(i);for(let c=e;c<n-e;c++){const h=t.children[c];To(r,t.leaf?s(h):h),a+=hs(r)}for(let c=n-e-1;c>=e;c--){const h=t.children[c];To(i,t.leaf?s(h):h),a+=hs(i)}return a}_adjustParentBBoxes(t,e,n){for(let o=n;o>=0;o--)To(e[o],t)}_condense(t){for(let e=t.length-1,n;e>=0;e--)t[e].children.length===0?e>0?(n=t[e-1].children,n.splice(n.indexOf(t[e]),1)):this.clear():Qn(t[e],this.toBBox)}}function gy(l,t,e){if(!e)return t.indexOf(l);for(let n=0;n<t.length;n++)if(e(l,t[n]))return n;return-1}function Qn(l,t){Io(l,0,l.children.length,t,l)}function Io(l,t,e,n,o){o||(o=Zn(null)),o.minX=1/0,o.minY=1/0,o.maxX=-1/0,o.maxY=-1/0;for(let s=t;s<e;s++){const r=l.children[s];To(o,l.leaf?n(r):r)}return o}function To(l,t){return l.minX=Math.min(l.minX,t.minX),l.minY=Math.min(l.minY,t.minY),l.maxX=Math.max(l.maxX,t.maxX),l.maxY=Math.max(l.maxY,t.maxY),l}function yy(l,t){return l.minX-t.minX}function xy(l,t){return l.minY-t.minY}function Pr(l){return(l.maxX-l.minX)*(l.maxY-l.minY)}function hs(l){return l.maxX-l.minX+(l.maxY-l.minY)}function wy(l,t){return(Math.max(t.maxX,l.maxX)-Math.min(t.minX,l.minX))*(Math.max(t.maxY,l.maxY)-Math.min(t.minY,l.minY))}function my(l,t){const e=Math.max(l.minX,t.minX),n=Math.max(l.minY,t.minY),o=Math.min(l.maxX,t.maxX),s=Math.min(l.maxY,t.maxY);return Math.max(0,o-e)*Math.max(0,s-n)}function br(l,t){return l.minX<=t.minX&&l.minY<=t.minY&&t.maxX<=l.maxX&&t.maxY<=l.maxY}function ds(l,t){return t.minX<=l.maxX&&t.minY<=l.maxY&&t.maxX>=l.minX&&t.maxY>=l.minY}function Zn(l){return{children:l,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Jc(l,t,e,n,o){const s=[t,e];for(;s.length;){if(e=s.pop(),t=s.pop(),e-t<=n)continue;const r=t+Math.ceil((e-t)/n/2)*n;uy(l,r,t,e,o),s.push(t,r,r,e)}}class el extends Zc{constructor(){super();p(this,"root");p(this,"previewRoot");p(this,"nodeMap");p(this,"tree");p(this,"linkMap");this.nodeMap=new Map,this.tree=new fy,this.root=new pr(Sn),this.previewRoot=new pr(Xr),this.linkMap=new Map}clear(){this.tree.clear(),this.nodeMap.clear()}searchNodesByRectNode(e){const{minY:n,minX:o,maxY:s,maxX:r}=e;return this.searchNodes(o,n,r,s)}searchNodes(e,n,o=e,s=n){const r={id:"pointer",minX:e,minY:n,maxX:o,maxY:s},i=this.tree.search(r),a=[];for(const c of i){const h=this.nodeMap.get(c.id);h&&a.push(h)}return a}getParentNode(e){const n=this.nodeMap.get(e);return n||this.root}getNode(e){if(e===Sn||e==="")return this.root;const n=this.nodeMap.get(e);return n||null}addNode(e){this.nodeMap.set(e.id,e),this.addIndexNode(e.getRectNode())}removeNode(e){const n=this.getNode(e);if(!n){console.warn("警告:删除节点不存在:",e);return}this.nodeMap.delete(e),this.removeIndexNode(n.getRectNode()),n.type===v.Line&&this.linkMap.delete(n),this.deleteNodeFromParent(n)}deleteNodeFromParent(e){var o;const n=(o=e.parent)==null?void 0:o.id;if(n)if(n===this.root.id)this.root.children.delete(e);else{const s=this.nodeMap.get(n);s&&s.children.delete(e)}}removeIndexNode(e){this.tree.remove(e,(n,o)=>n.id===o.id)}addIndexNode(e){this.tree.insert(e)}getNodeBounds(){const e=[];for(const[n,o]of this.nodeMap)e.push(o.getRectNode());return S.getBounds(e,"all-node-bounds")}addLink(e,n,o=!0){const s=this.linkMap.get(e);if(s){o?s.startNode=n:s.endNode=n,this.checkLinkLine(e);return}const r={startNode:null,endNode:null};o?r.startNode=n:r.endNode=n,this.linkMap.set(e,r),this.checkLinkLine(e)}checkLinkLine(e){const n=this.linkMap.get(e);n&&n.endNode===null&&n.startNode===null&&this.linkMap.delete(e)}getNodeLinks(e){const n=new Set;if(e.type===v.Line)return n;for(const[o,s]of this.linkMap){if(!o.getProp(I.Connect))continue;const{startNode:i,endNode:a}=s;i===e&&n.add(o),a===e&&n.add(o)}return n}}const Jn=class Jn{constructor(){p(this,"previewGraphics",[]);p(this,"createWorker",new Qa);p(this,"layoutHandler",new Vt);p(this,"inQuickPreview",!1)}enterQuickPreview(t,e,n){if(this.inQuickPreview){this.previewGraphics.length>0&&n.addOrUpdate(k.PreviewGraphics,{previewNodes:this.previewGraphics});return}this.inQuickPreview=!0,this.resetPreviewNode(n);const o=this.createWorker.judgeQuickCreateMode(t,e,n);if(o){this.computeDrawLine(o,t,e,n);return}this.computeDrawLineAndNode(t,e,n)}computeDrawLine(t,e,n,o){const s=e.baseProps,r=e.toGlobal({x:n.x*s.width,y:n.y*s.height}),i=this.createWorker.computeEndNodeRelative(e,n),a=t.baseProps,c=t.toGlobal({x:i.x*a.width,y:i.y*a.height}),h={point:r,nodeConnect:{rect:D.rectNode2Rect(e.getBounds()),endType:S.computeNodeConnectEnd(n,e.baseProps.angle)}},d={point:c,nodeConnect:{rect:D.rectNode2Rect(t.getBounds()),endType:S.computeNodeConnectEnd(i,t.baseProps.angle)}},u=this.makeupLineProps(h,d),f=It.getInstance().create(Jn.PREVIEW_LINE_ID,v.Line,0,u,o.nodeManager.previewRoot,o.gmlRender.glCtx);this.previewGraphics.push(f)}computeDrawLineAndNode(t,e,n){const o=this.createWorker.computePreviewNodePos(t,e,n),s=this.makeupNodeProps(t,o),r=It.getInstance().create(Jn.PREVIEW_ID,v.Shape,0,s,n.nodeManager.previewRoot,n.gmlRender.glCtx);this.previewGraphics.push(r),this.computeDrawLine(r,t,e,n),n.addOrUpdate(k.PreviewGraphics,{previewNodes:this.previewGraphics})}exitQuickPreview(t){this.resetPreviewNode(t),this.inQuickPreview=!1}resetPreviewNode(t){this.previewGraphics=[],t.nodeManager.previewRoot.children.clear()}makeupNodeProps(t,e){const n=t.baseProps,o=t.shapeType,s=e.x,r=e.y,i=t.colorProps,a=t.borderProps,c=[{type:I.Base,x:s,y:r,width:n.width,height:n.height,angle:n.angle},tt.create({...i,alpha:.5}),Ae.create({...a,alpha:.5}),new Oe(o)];if(t.type===v.Shape&&t.shapeType===K.PureText){const h=t.textProps;c.push(h.clone());const d=t.paragraphProps;c.push(d.clone())}return c}makeupLineProps(t,e){const n=this.layoutHandler.layoutToPointsPro(t,e),o=D.rectNode2Rect(S.getBoundsByPoints(n));return[je.create(n),ie.create({x:o.x,y:o.y,width:o.width,height:o.height}),lt.create({rArrow:it.Arrow}),new Oe(he.RoundPolyLine),Ae.create({alpha:.5})]}};p(Jn,"PREVIEW_ID","quick_preview"),p(Jn,"PREVIEW_LINE_ID","quick_preview_line");let us=Jn;class Dn{computePreviewPos(t,e,n){var a;t.toolManager.shapeType;const o=t.toolManager.grab,s=((a=t.lastInteractiveEvent)==null?void 0:a.globalPoint)||new m,r=o?s.x-.5*e:s.x,i=o?s.y-.5*n:s.y;return new m(r,i)}}class Py extends Dn{enable(t){return t===ye.SHAPE}async handle(t,e){const n=e.toolManager.shapeType,o=this.computePreviewPos(e,100,100),s=e.createWorker.makeupPreviewProps(v.Shape,e,n,o);return It.getInstance().create(t,v.Shape,0,s,e.nodeManager.previewRoot,e.gmlRender.glCtx)}}class by extends Dn{enable(t){return t===ye.SECTION}async handle(t,e){const n=e.toolManager.shapeType,o=Uo[n],s=this.computePreviewPos(e,o.width,o.height),r=e.createWorker.makeupPreviewProps(v.Section,e,n,s);return It.getInstance().create(t,v.Section,0,r,e.nodeManager.previewRoot,e.gmlRender.glCtx)}}class tl{async work(t,e,n,o){const s=n.getScale();try{const r=t.baseProps,i=s*r.width,a=s*r.height;let c;const h=o.getSVGBlobUrl(e,i,a);if(h)c=h.imageBitmap;else{const d=new Blob([e],{type:"image/svg+xml"}),u=URL.createObjectURL(d),f=new Image;f.width=2*i,f.height=2*a,await new Promise((b,w)=>{f.onload=b,f.onerror=w,f.src=u});const g=new OffscreenCanvas(2*i,2*a);g.getContext("2d").drawImage(f,0,0,2*i,2*a);const P=g.transferToImageBitmap();c=P,o.setSvgInfo(e,{imageBitmap:P},i,a),URL.revokeObjectURL(u)}t.setImageBitmap(c)}catch(r){console.error("加载svg图片出现问题",r),t.setBroken()}n.dirtyDraw(t.getBounds())}}class Sy extends Dn{constructor(){super(...arguments);p(this,"svgWorker",new cr)}enable(e){return e===ye.Resource}async handle(e,n){const o=new m(0,0),s=n.previewManager.previewResourceManager.previewSvgCode;s===""&&console.error("出现错误,svg code为空");const{addNodeInfo:r}=await this.svgWorker.addSvgNodeBySvgCode(s,o,n),i=It.getInstance().create(us.PREVIEW_ID,v.SVG,0,r.props,n.nodeManager.previewRoot,n.gmlRender.glCtx),a=an.trimSvgCode(s);return i.setSvgCode(a.svgCode),await new tl().work(i,a.svgCode,n.renderManager,n.resourceManager),i}makeupShapeDefaultProps(e,n,o){const s=me.Resource,r=cn[s],i=100,a=100,c=o?n.x-.5*i:n.x,h=o?n.y-.5*a:n.y;return[ie.create({x:c,y:h,width:i,height:a}),Ae.create({color:r,alpha:.5})]}}class My extends Dn{enable(t,e){return t===ye.Widget&&e===_n.Checkbox}async handle(t,e){const n=e.toolManager.shapeType,o=this.computePreviewPos(e,16,16),s=e.createWorker.makeupPreviewProps(v.Checkbox,e,n,o);return It.getInstance().create(t,v.Checkbox,0,s,e.nodeManager.previewRoot,e.gmlRender.glCtx)}}class vy extends Dn{enable(t,e){return t===ye.Widget&&e===_n.CheckboxText}async handle(t,e){const n=e.toolManager.shapeType,o=this.computePreviewPos(e,102,32),s=e.createWorker.makeupPreviewProps(v.CheckboxText,e,n,o);return It.getInstance().create(t,v.CheckboxText,0,s,e.nodeManager.previewRoot,e.gmlRender.glCtx)}}class ps{makeupLineDefaultProps(t,e){const s=e.x,r=e.y,i=S.computeShapeCategory(v.Line,t),a=cn[i],c=this.makeupLinePoints(s,r,100,-100),h=D.rectNode2Rect(S.getBoundsByPoints(c));return[ie.create({x:h.x,y:h.y,width:h.width,height:h.height}),new Oe(t),je.create(c),Ae.create({color:a,alpha:.5}),lt.create({rArrow:it.Arrow})]}}class Iy extends ps{makeupLineDefaultProps(t,e){const s=e.x,r=e.y,i=S.computeShapeCategory(v.Line,t),a=cn[i],c=[{x:s,y:r},{x:s+100,y:r+-100}],h=D.rectNode2Rect(S.getBoundsByPoints(c));return[ie.create({x:h.x,y:h.y,width:h.width,height:h.height}),new Oe(t),je.create(c),Ae.create({color:a,alpha:.5}),lt.create({rArrow:it.Arrow})]}makeupLinePoints(t,e,n,o){return[{x:t,y:e},{x:t+n,y:e+o}]}}class Ty extends ps{makeupLinePoints(t,e,n,o){return[{x:t,y:e},{x:t+.5*n,y:e},{x:t+.5*n,y:e+o},{x:t+n,y:e+o}]}}class Ly extends ps{makeupLinePoints(t,e,n,o){return[{x:t,y:e},{x:t+.5*n,y:e},{x:t+.5*n,y:e+o},{x:t+n,y:e+o}]}}class Cy extends ps{makeupLinePoints(t,e,n,o){return[{x:t,y:e},{x:t+.5*n,y:e},{x:t+.5*n,y:e+o},{x:t+n,y:e+o}]}}class Ay extends Dn{constructor(){super(...arguments);p(this,"helpers",new Map([[he.Line,new Iy],[he.Curve,new Ty],[he.PolyLine,new Ly],[he.RoundPolyLine,new Cy]]))}enable(e){return e===ye.LINE}async handle(e,n){var a;const o=n.toolManager.shapeType,s=((a=n.lastInteractiveEvent)==null?void 0:a.globalPoint)||new m,r=this.makeupLineDefaultProps(o,s);return It.getInstance().create(e,v.Line,0,r,n.nodeManager.previewRoot,n.gmlRender.glCtx)}makeupLineDefaultProps(e,n){const o=this.helpers.get(e);return o?o.makeupLineDefaultProps(e,n):this.helpers.get(he.Line).makeupLineDefaultProps(e,n)}}class Ny extends Dn{enable(t,e){return t===ye.SlideContainer}async handle(t,e){const n=e.toolManager.shapeType,o=this.computePreviewPos(e,200,180),s=e.createWorker.makeupPreviewProps(v.SlideContainer,e,n,o);return It.getInstance().create(t,v.SlideContainer,0,s,e.nodeManager.previewRoot,e.gmlRender.glCtx)}}const Ps=class Ps{constructor(){p(this,"previewGraphics",null);p(this,"handlers",[new Py,new by,new Sy,new Ay,new My,new vy,new Ny])}addPreviewNode(t){const e=t.toolManager.currentTool,n=t.toolManager.shapeType;for(const o of this.handlers)if(o.enable(e,n)){o.handle(Ps.PREVIEW_ID,t).then(s=>{this.previewGraphics=s});return}}updatePos(t){if(!this.previewGraphics)return;if(this.previewGraphics.type===v.Line){const n=this.previewGraphics.pos,o={x:t.x-n.x,y:t.y-n.y},s=this.previewGraphics.points;for(const a of s)a.x+=o.x,a.y+=o.y;const r={type:I.Line,points:s},i={type:I.Base,x:t.x,y:t.y};this.previewGraphics.updateProps([i,r]);return}const e={type:I.Base,x:t.x,y:t.y};this.previewGraphics.updateProps([e])}resetPreviewNode(t){this.previewGraphics=null,t.nodeManager.previewRoot.children.clear()}};p(Ps,"PREVIEW_ID","create_preview");let Sr=Ps;class ky{constructor(){p(this,"previewSvgCode","");p(this,"previewSvgResourceUrl","")}setPreviewSvgCode(t){this.previewSvgCode=t}setPreviewResourceUrl(t){this.previewSvgResourceUrl=t}}class By{constructor(){p(this,"createManager",new Sr);p(this,"quickCreateManager",new us);p(this,"previewResourceManager",new ky)}addPreviewNode(t){this.createManager.addPreviewNode(t)}updatePos(t){this.createManager.updatePos(t)}resetPreviewNode(t){this.createManager.resetPreviewNode(t)}}class nl{}class ol extends nl{async downloadAsImageBitmap(t){const n=await(await fetch(t)).blob();return{imageBitmap:await createImageBitmap(n),blobUrl:t}}async uploadBlobImg(t,e){return Promise.resolve("")}async downloadSvgCode(t){return Promise.resolve("")}async uploadSvgFile(t,e){return Promise.resolve(void 0)}async deleteMultipleImages(t){return Promise.resolve(void 0)}async uploadSvgString(t,e){return Promise.resolve("")}async copyImage(t,e,n){throw new Error("该方法没有被实现")}}class sl{constructor(){p(this,"resourceMap",new Map);p(this,"nodeResourceMap",new Map);p(this,"svgMap",new Map);p(this,"svgBlobMap",new Map);p(this,"instance",new ol)}loadResourceInstance(t){this.instance=t}makeSvgBlobUrlKey(t,e,n){const o=Math.round(e/10),s=Math.round(n/10);return o+"-"+s+"-"+t}setSvgInfo(t,e,n,o){this.svgBlobMap.set(this.makeSvgBlobUrlKey(t,n,o),e)}getSVGBlobUrl(t,e,n){return this.svgBlobMap.get(this.makeSvgBlobUrlKey(t,e,n))}getBlobUrl(t){var e;return((e=this.resourceMap.get(t))==null?void 0:e.blobUrl)||""}getImgUrls(){return[...this.nodeResourceMap.values()].map(t=>t.blobUrl)}addNodeResourceInfo(t,e){this.nodeResourceMap.set(t,e)}async loadImgUrl(t){if(this.resourceMap.has(t))return this.resourceMap.get(t);const e=await this.instance.downloadAsImageBitmap(t);return this.resourceMap.set(t,e),e}async uploadFileBlob(t,e){return await this.instance.uploadBlobImg(t,e)}async loadSvgUrl(t){return await this.instance.downloadSvgCode(t)}async uploadSvgFile(t,e){return await this.instance.uploadSvgFile(t,e)}async uploadSvgString(t,e){const n=this.svgMap.get(e);if(n)return n;const o=await this.instance.uploadSvgString(t,e);return this.svgMap.set(e,o),o}async deleteMultipleImages(t){if(t.length!==0)return await this.instance.deleteMultipleImages(t)}async copyImage(t,e,n=go.Resource){return await this.instance.copyImage(t,e,n)}}var Lo=(l=>(l[l.Img=0]="Img",l[l.Svg=1]="Svg",l))(Lo||{});class Ry{constructor(t,e,n){p(this,"tasks",[]);p(this,"resourceManager");p(this,"nodeManager");p(this,"renderManager");p(this,"tickerRun",async()=>{this.tasks.length>0&&await this.onTicker(),requestAnimationFrame(this.tickerRun)});p(this,"onTicker",async()=>{const t=this.tasks.pop();t&&(t.type===Lo.Svg&&await this.genSvgTexture(t),t.type===Lo.Img&&(await this.genImgTexture(t),this.renderManager.slotManager.addSlotState(ze.ImgUrls,this.resourceManager.getImgUrls())))});this.resourceManager=t,this.nodeManager=e,this.renderManager=n}batchAddRenderNode(t){t.forEach(e=>this.addRenderNode(e))}addRenderNode(t){if(t.type===v.IMG){const e=t;this.tasks.push({type:Lo.Img,nodeId:t.id,url:e.imgSrc})}if(t.type===v.SVG){const e=t;e.svgCode!==""&&this.tasks.push({type:Lo.Svg,nodeId:t.id,svgCode:e.svgCode})}}start(){this.tickerRun()}async genImgTexture(t){const{nodeId:e,url:n}=t,o=this.nodeManager.getNode(e);if(!o||o.type!==v.IMG)return;const s=o;try{const r=await this.resourceManager.loadImgUrl(n);s.setImageBitmap(r.imageBitmap),this.resourceManager.addNodeResourceInfo(s.id,r)}catch(r){console.error("加载图片出现问题",r),s.setBroken()}this.renderManager.dirtyDraw(o.getBounds())}async genSvgTexture(t){const{svgCode:e,nodeId:n}=t,o=this.nodeManager.getNode(n);if(!o||o.type!==v.SVG)return;const s=o;await new tl().work(s,e,this.renderManager,this.resourceManager)}}class Ey{constructor(){p(this,"duringCrop",!1)}intoCrop(){this.duringCrop=!0}exitCrop(){this.duringCrop=!1}}class Hy{constructor(){p(this,"slideSet",new Set);p(this,"slideContainerSet",new Set);p(this,"appCtx");p(this,"tickerRun",()=>{for(const t of this.slideContainerSet)this.appCtx.slideManager.updateSlideContainerCover(this.appCtx);this.slideContainerSet.clear();for(const t of this.slideSet)this.appCtx.slideManager.updateSlideCover(t,this.appCtx);this.slideSet.clear(),requestAnimationFrame(this.tickerRun)})}init(t){this.appCtx=t}start(){this.tickerRun()}updateSlideCover(t){this.slideSet.add(t)}updateSlideContainerCover(t){this.slideContainerSet.add(t)}}const Nt=50,Co=40;class Dy{constructor(){p(this,"slidePlayWorker");p(this,"slideCoverManager");this.slidePlayWorker=new _c,this.slideCoverManager=new Hy}init(t){this.slideCoverManager.init(t)}start(){this.slideCoverManager.start()}enterEditing(t){const e=[...t.getSelectNodes()];if(e.length!==1)return;const n=e[0];n instanceof bo&&(t.execAction(new W),t.execAction(xe.create([])),t.execAction(new z),t.docModeManager.switchMode(ue.SLIDE_EDIT,t,{slideContainer:n}))}exitEditing(t){t.docState.docMode!==ue.BOARD&&t.docModeManager.switchMode(ue.BOARD,t,{slideContainer:t.docState.slideStatus.slideContainer||void 0})}jumpTo(t,e){if(t.docMode!==ue.SLIDE_EDIT||!t.slideStatus.slideContainer)return null;const n=t.slideStatus.slideContainer.slideProps.children,o=t.slideStatus.slideContainer.getTotalCount();return e<o&&e>-1?(t.slideStatus.currentIndex=e,this.getChildIdByIndex(n,e)):null}jumpToWhenEditing(t,e){const n=this.jumpTo(e.docState,t);n&&(e.focus(n,0,50),e.slotManager.addSlotState(ze.SlideIndex,{index:t}))}enterPlayBySlideContainer(t,e){t.execAction(new W),t.execAction(xe.create([])),t.execAction(new z),t.docState.changePermission({canEdit:!1}),t.docModeManager.switchMode(ue.SLIDE_PLAY,t,{slideContainer:e})}enterPlay(t){const e=[...t.getSelectNodes()];if(e.length!==1)return;const n=e[0];n instanceof bo&&this.enterPlayBySlideContainer(t,n)}playToNext(t){const e=this.slidePlayWorker.playToNext(t.docState);e&&t.focus(e)}playToPrev(t){const e=this.slidePlayWorker.playToPrev(t.docState);e&&t.focus(e)}insertSlide(t,e,n,o){var ne,ae;const s=t.slideProps.children,r=t.getTotalCount();if(e<0||e>=r)return null;const{rowIndex:i,colIndex:a}=this.getRowColByIndex(s,e);if(i===-1)return null;const c=s[i];if(!c||!c.ids||c.ids.length===0)return null;const h=n?a+1:a,d=c.ids[a],u=o.nodeManager.getNode(d);if(!u)return null;const f=u.baseProps,g=(ne=u.getProp(I.Color))==null?void 0:ne.color,y=(ae=u.getProp(I.Border))==null?void 0:ae.color,P=f.width,b=f.height;let w;if(h===0)w=Nt;else{const te=c.ids[h-1],ce=o.nodeManager.getNode(te);ce?w=ce.baseProps.x+ce.baseProps.width+Nt:w=u.baseProps.x+u.baseProps.width+Nt}const L=u.baseProps.y,B=[ie.create({x:w,y:L,width:P,height:b})];g!==void 0&&B.push(tt.create({color:g})),y!==void 0&&B.push(Ae.create({color:y}));const H=o.idGenerator.genId(v.Section),E={id:H,type:v.Section,zIndex:ve.genZIndex(t),parentId:t.id,props:B};o.execAction(Le.create(E));const X=s.map((te,ce)=>{if(ce===i){const pe=[...te.ids];return pe.splice(h,0,H),{ids:pe}}return{ids:[...te.ids]}}),$=[{id:t.id,props:[St.create({children:X})]}];if(h===0){let te=Nt;const ce=X[i];for(let pe=0;pe<ce.ids.length;pe++){const Be=ce.ids[pe],Re=o.nodeManager.getNode(Be);Re&&($.push({id:Be,props:[ie.create({x:te,y:L,width:Re.baseProps.width,height:Re.baseProps.height})]}),te+=Re.baseProps.width+Nt)}}else if(h<c.ids.length+1){let te=w+P+Nt;for(let ce=h;ce<c.ids.length;ce++){const pe=c.ids[ce],Be=o.nodeManager.getNode(pe);Be&&($.push({id:pe,props:[ie.create({x:te,y:Be.baseProps.y,width:Be.baseProps.width,height:Be.baseProps.height})]}),te+=Be.baseProps.width+Nt)}}o.execAction(new U({infos:$}));const Z=[];for(const te of X)for(const ce of te.ids){const pe=o.nodeManager.getNode(ce);pe&&Z.push(pe.baseProps)}if(Z.length>0){const te=S.getBoundsByBasePropsList(Z),ce=te.maxX-te.minX+2*Nt,pe=te.maxY-te.minY+2*Co;o.execAction(U.create(t.id,[{type:I.Base,width:ce,height:pe}]))}return o.nodeManager.getNode(H)}exitPlay(t){t.docState.docMode===ue.SLIDE_PLAY&&t.docModeManager.backToPrevMode(t,{slideContainer:t.docState.slideStatus.slideContainer||void 0})}refocusSlide(t,e=0){if(t.docState.docMode===ue.BOARD)return;const{currentIndex:o,slideContainer:s}=t.docState.slideStatus;if(!s)return;const r=s.getChildIdByIndex(o);r&&t.focus(r,0,e)}unGroupSlideContainerBySelective(t){const n=[...t.getSelectNodes()].filter(o=>o.type===v.SlideContainer);for(const o of n)this.unGroupSlideContainer(o,t)}unGroupSlideContainer(t,e){const n=t.globalBaseProps,o=n.x,s=n.y,r=Array.from(t.children);if(r.length===0)return;e.execAction(new W);const i=r.map(c=>{const h=c.baseProps,d=o+h.x,u=s+h.y;return{id:c.id,parentId:"",props:[ie.create({x:d,y:u,width:h.width,height:h.height,angle:h.angle})]}});i.length>0&&e.execAction(new U({infos:i})),e.execAction(At.create([t.id]));const a=r.map(c=>c.id);e.execAction(xe.create(a)),e.execAction(new z)}getChildIdByIndex(t,e){let n=0;for(let o=0;o<t.length;o++){if(e<n+t[o].ids.length){const s=e-n;return t[o].ids[s]}n+=t[o].ids.length}return null}getRowColByIndex(t,e){let n=0;for(let o=0;o<t.length;o++){if(e<n+t[o].ids.length){const s=e-n;return{rowIndex:o,colIndex:s}}n+=t[o].ids.length}return{rowIndex:-1,colIndex:-1}}updateSlideCover(t,e){S.getSlideInfo(t,e).then(n=>{const o=e.docState.slideStatus.slideCoverList.findIndex(s=>s.id===t.id);if(o>-1){const s=e.docState.slideStatus.slideCoverList[o];URL.revokeObjectURL(s.blobUrl),e.docState.slideStatus.slideCoverList.splice(o,1,n),e.slotManager.addSlotState(ze.SlideCovers,{covers:e.docState.slideStatus.slideCoverList})}else URL.revokeObjectURL(n.blobUrl)})}async updateSlideContainerCover(t){const e=t.docState.slideStatus.slideContainer;if(!e)return;const n=t.docState.slideStatus.slideCoverList,o=new Map;n.forEach(i=>o.set(i.id,i));const s=e.slideProps.children,r=[];for(const i of s)for(const a of i.ids){const c=o.get(a);if(c)r.push(c),o.delete(a);else{const h=t.nodeManager.getNode(a);if(h){const d=await S.getSlideInfo(h,t);r.push(d)}}}for(const i of o.values())URL.revokeObjectURL(i.blobUrl);t.docState.slideStatus.slideCoverList=r,t.slotManager.addSlotState(ze.SlideCovers,{covers:t.docState.slideStatus.slideCoverList})}updateSlideContainers(t,e,n){for(const o of t){const s=o.slideProps.children,r=[];for(const h of s){const d=h.ids.filter(u=>!e.has(u));d.length>0&&r.push({ids:d})}if(r.length===0){n.actionManager.execAction(U.create(o.id,[St.create({children:[]}),{type:I.Base,width:100+2*Nt,height:100+2*Co}]));continue}const i=[];let a=Co;for(let h=0;h<r.length;h++){const d=r[h];let u=Nt,f=0;for(const g of d.ids){const y=n.nodeManager.getNode(g);y&&(i.push({id:g,props:[ie.create({x:u,y:a,width:y.baseProps.width,height:y.baseProps.height})]}),u+=y.baseProps.width+Nt,f=Math.max(f,y.baseProps.height))}a+=f+Co}i.unshift({id:o.id,props:[St.create({children:r})]}),n.actionManager.execAction(new U({infos:i}));const c=[];for(const h of r)for(const d of h.ids){const u=n.nodeManager.getNode(d);u&&c.push(u.baseProps)}if(c.length>0){const h=S.getBoundsByBasePropsList(c),d=h.maxX-h.minX+2*Nt,u=h.maxY-h.minY+2*Co;n.actionManager.execAction(U.create(o.id,[{type:I.Base,width:d,height:u}]))}}}}class Mr{constructor(t){p(this,"inputManager");p(this,"cursorManager");p(this,"toolManager");p(this,"gmlRender");p(this,"auxGMLRender");p(this,"nodeManager");p(this,"serializeManager");p(this,"actionManager");p(this,"renderManager");p(this,"auxiliaryManager");p(this,"previewManager");p(this,"asyncRenderNodeManager");p(this,"docState");p(this,"idGenerator");p(this,"slotManager");p(this,"resourceManager");p(this,"cropManager");p(this,"slideManager");p(this,"appContext");p(this,"plugins",[]);p(this,"api");p(this,"aiAPI");this.docState=new Kc,this.idGenerator=new ve,this.gmlRender=new mr,this.auxGMLRender=new mr,this.cursorManager=new Oc,this.nodeManager=new el,this.slotManager=new ci,this.resourceManager=new sl,this.cropManager=new Ey,this.slideManager=new Dy,this.auxiliaryManager=new hi(this.auxGMLRender,this.slotManager,this.cropManager,this.docState),this.renderManager=new Dc(this.gmlRender,this.nodeManager,this.auxiliaryManager,this.slotManager),this.inputManager=new hy(this.renderManager,this.cursorManager),this.previewManager=new By,this.toolManager=new Wa(this.nodeManager,this.inputManager,this.slotManager,this.cursorManager),this.asyncRenderNodeManager=new Ry(this.resourceManager,this.nodeManager,this.renderManager),this.actionManager=new Ec(this.nodeManager,this.inputManager,this.gmlRender,this.auxiliaryManager,this.toolManager,this.renderManager,this.resourceManager,this.docState,this.idGenerator,this.slotManager,this.asyncRenderNodeManager,this.slideManager),this.serializeManager=new dy(this.nodeManager,this.docState),this.appContext=new Xc(this.nodeManager,this.gmlRender,t.detectors,this.toolManager,this.inputManager,this.actionManager,this.renderManager,this.auxiliaryManager,this.docState,this.idGenerator,this.cursorManager,this.previewManager,this.resourceManager,this.slotManager,this.asyncRenderNodeManager,this.cropManager,this.slideManager),this.api=new $c(this),this.aiAPI=new jc(this),this.slideManager.init(this.appContext),this.actionManager.executor.init(this.appContext),this.auxiliaryManager.selectManager.register(this.inputManager),this.appContext.refreshEvent=e=>{const n=this.getPlugin(Wo);n&&n.interactiveManager.refreshEvent(this.appContext,e)}}registerPlugin(t){this.plugins.push(t)}getPlugin(t){for(const e of this.plugins)if(e instanceof t)return e;return null}start(){this.slotManager.start(),this.auxiliaryManager.start(),this.renderManager.start(),this.asyncRenderNodeManager.start(),this.slideManager.start();for(const t of this.plugins)t.start()}stop(){for(const t of this.plugins)t.stop()}load(t){return this.loadDocumentInfo(t)}asyncLoad(t,e){return this.asyncLoadDocumentInfo(t,e)}asyncLoadDocumentInfo(t,e){const n=Qc();this.docState.load(n);try{const o=this.initData(t);this.asyncAfterInit(o,e),this.renderManager.zoomToFit(),this.renderManager.addContentRenderTask()}catch(o){console.error("初始化过程中出现错误;",o)}return this.docState.seq}loadDocumentInfo(t){const e=Qc();this.docState.load(e);try{const n=this.initData(t);this.afterInit(n),this.renderManager.zoomToFit(),this.renderManager.addContentRenderTask()}catch(n){console.error("初始化过程中出现错误;",n)}return this.docState.seq}initData(t){this.nodeManager.clear(),this.gmlRender.reset();const e=this.gmlRender.canvas.getContext("2d");let n=[];const o=S.correctZIndex(t.nodes);for(const s of o){const r=this.nodeManager.root;this.initNode(s,r,e,n)}return n=S.sortGraphics(n),n}initNode(t,e,n,o){this.idGenerator.loadNode(t);const s=It.getInstance().createByNodeInfo(t,e,n);this.nodeManager.addNode(s),o.push(s);const r=t.children??[],i=S.correctZIndex(r);for(const a of i)this.initNode(a,s,n,o);return s}async afterInit(t){for(const e of t){if(e instanceof Ct){const{start:n,end:o}=e.connectProps;if(n){const s=this.nodeManager.getNode(n.objectId)||null;this.nodeManager.addLink(e,s,!0)}if(o){const s=this.nodeManager.getNode(o.objectId)||null;this.nodeManager.addLink(e,s,!1)}}if(e instanceof Yn&&this.asyncRenderNodeManager.addRenderNode(e),e instanceof jn)try{let n="";if(e.svgProps.useCode)n=an.trimSvgCode(e.svgProps.code).svgCode;else{const s=e.svgUrl;n=await this.resourceManager.loadSvgUrl(s)}const o=an.trimSvgCode(n);e.setSvgCode(o.svgCode),this.asyncRenderNodeManager.addRenderNode(e)}catch(n){console.error("加载svg图片出现问题",n),e.setBroken()}}}asyncAfterInit(t,e){for(const n of t){if(n instanceof Ct){const{start:o,end:s}=n.connectProps;if(o){const r=this.nodeManager.getNode(o.objectId)||null;this.nodeManager.addLink(n,r,!0)}if(s){const r=this.nodeManager.getNode(s.objectId)||null;this.nodeManager.addLink(n,r,!1)}}if(n instanceof Yn){const o=n,s=o.imgSrc;if(e&&e.has(s))try{const r=e.get(s);o.setImageBitmap(r)}catch(r){console.error("从 resourceMap 加载图片出现问题",r),o.setBroken()}else{console.warn("图片资源未在 resourceMap 中找到:",s),n.setBroken();continue}}if(n instanceof jn)try{if(n.svgProps.useCode){const s=an.trimSvgCode(n.svgProps.code).svgCode;if(n.setSvgCode(s),e&&e.has(s)){const r=e.get(s);n.setImageBitmap(r)}else{console.warn("SVG useCode 资源未在 resourceMap 中找到"),n.setBroken();continue}}else{const o=n.svgUrl;if(e&&e.has(o)){const s=e.get(o);n.setImageBitmap(s)}else{console.warn("SVG 资源未在 resourceMap 中找到:",o),n.setBroken();continue}}}catch(o){console.error("加载svg图片出现问题",o),n.setBroken()}}}}const Oy={width:595,height:942};var vr={exports:{}},Ao={};/**
|
|
28
|
+
`);for(let c=e.paragraphIndex+1;c<n.paragraphIndex;c++){const h=t.paragraphs[c];o+=h.toString()}const i=t.paragraphs[n.paragraphIndex],a=this.extractTextFromParagraph(i,new Fe(n.paragraphIndex,0,-1),n);o+=a}return o}extractTextFromParagraph(t,e,n){let o="";if(e.lineIndex===n.lineIndex){const s=t.lines[e.lineIndex];o=this.extractTextFromLine(s,e.charIndex,n.charIndex)}else{const s=t.lines[e.lineIndex],r=s.getCharLength();o+=this.extractTextFromLine(s,e.charIndex,r-1);for(let a=e.lineIndex+1;a<n.lineIndex;a++){const c=t.lines[a];o+=c.toString()}const i=t.lines[n.lineIndex];o+=this.extractTextFromLine(i,-1,n.charIndex)}return o}extractTextFromLine(t,e,n){let o="",s=0;const r=e+1,i=n;for(const a of t.textBlocks){const c=a.characters.length;if(s+c-1<r){s+=c;continue}if(s>i)break;const d=Math.max(0,r-s),u=Math.min(c-1,i-s);for(let g=d;g<=u&&g<a.characters.length;g++)o+=a.characters[g].charText;s+=c}return o}}class kf extends yo{handle(t,e,n,o){const s=t.find(a=>a.type===I.Image);if(!s)return;const r=s.url,i=o.get(r);i?s.url=i:(console.error("复制图片时该图片资源失效!",i),s.url="")}}class Nf extends yo{handle(t,e,n,o){const s=t.find(a=>a.type===I.Svg);if(!s||s.useCode)return;const r=s.url,i=o.get(r);i?s.url=i:(console.error("复制svg时该svg资源失效!",i),s.url="")}}class Bf extends ba{constructor(){super(...arguments);p(this,"propsHandler",[new ya,new xa,new wa,new kf,new Nf])}}class xr{}var Kt=(l=>(l[l.Normal=0]="Normal",l[l.EmptyPlace=1]="EmptyPlace",l))(Kt||{});class Fc extends xr{constructor(){super(...arguments);p(this,"posPasteType",Kt.Normal)}handlePos(e,n){return n.lastInteractiveEvent.globalPoint}}class Yc extends xr{constructor(){super(...arguments);p(this,"posPasteType",Kt.EmptyPlace)}handlePos(e,n){const o=e.bounds,s=20,r=n.renderManager.gmlRender.getViewPortBounds(),i=n.nodeManager.searchNodesByRectNode(r);if(i.length===0){const y=.5*(r.minX+r.maxX)-.5*o.width,P=.5*(r.minY+r.maxY)-.5*o.height;return new m(y,P)}const a=i.map(y=>y.globalPos),c=Math.min(...a.map(y=>y.x)),h=Math.min(...a.map(y=>y.y));let d=c;const u=h,g=o.width+2*s,f=o.height+2*s;for(let y=0;y<10;y++){if(n.nodeManager.searchNodes(d,u,d+g,u+f).length===0)return{x:d+s,y:u+s};d+=g}return new m(c,h)}}class cs{constructor(){p(this,"pasteWorker",new Ma);p(this,"crossPagePasteWorker",new Bf);p(this,"pastePosHandlerMap",new Map([[Kt.Normal,new Fc],[Kt.EmptyPlace,new Yc]]))}handle(t,e,n=Kt.Normal){const o=e.docState.docId;return t.meta.docId!==o?this.handleCrossPaste(t,e,n):this.handlePaste(t,e,n)}handlePaste(t,e,n){return!t.nodes||t.nodes.length===0?!1:(this.normalPaste(t,e,this.pasteWorker,n),!0)}handleCrossPaste(t,e,n){return!t.nodes||t.nodes.length===0?!1:(this.asyncHandleCrossPaste(t,e,n),!0)}async asyncHandleCrossPaste(t,e,n){if(!t.nodes||t.nodes.length===0)return!1;const o=await this.pasteResourceInfo(t.resources,e,t.meta.resourceType);return o||console.error("复制图片资源时出现错误!"),this.normalPaste(t,e,this.crossPagePasteWorker,n,o==null?void 0:o.resourceMap),!0}normalPaste(t,e,n,o,s){const r=t.nodes,i=t.bounds,a=this.computePastePos(o,t,e),c=new m(a.x-i.x,a.y-i.y);e.execAction(new W);const{addNodeData:h,nextFocusIds:d}=n.work(e,r,c,s);e.execAction(new Le(h)),e.execAction(xe.create(d)),e.execAction(new z)}computePastePos(t,e,n){const o=this.pastePosHandlerMap.get(t);return o?o.handlePos(e,n):this.pastePosHandlerMap.get(Kt.Normal).handlePos(e,n)}async pasteResourceInfo(t,e,n){return t.length===0?{failedList:[],resourceMap:new Map}:await e.resourceManager.copyImage(t,e.docState.docId,n)}}class Rf{constructor(){p(this,"handlers",[new cs])}paste(t,e){const n=t.clipboardData,o=n==null?void 0:n.getData("text/html");if(!o)return!1;const s=xn.decode(o);if(s===null)return!1;const r=JSON.parse(s);for(const i of this.handlers)if(i.handle(r,e,Kt.Normal))return!0;return!1}}class Ef{paste(t,e){const n=t.clipboardData,o=n==null?void 0:n.getData("text/plain");if(!o)return!1;const s=this.getSvgCode(o);if(s===null)return!1;const r=e.docState.docId,i=Zo(10),a=`${r}/${i}`,c=an.trimSvgCode(s);return e.resourceManager.uploadSvgString(a,c.svgCode).then(h=>{this.addSvgNode(e,c,h)}),!0}addSvgNode(t,e,n){var c;const o=((c=t.lastInteractiveEvent)==null?void 0:c.globalPoint)||new m,s=[{type:I.Base,x:o.x,y:o.y,width:e.width,height:e.height},{type:I.Svg,url:n},{type:I.Border,dashType:et.None}],r=t.idGenerator.genId(v.SVG),i={id:r,type:v.SVG,zIndex:ve.genZIndex(t.nodeManager.root),parentId:"",props:s};t.execAction(new W);const a=Le.create(i);t.execAction(a),t.execAction(xe.create([r])),t.execAction(new z)}getSvgCode(t){const e=t.indexOf("<svg"),n=t.indexOf("svg>");return e<0||n<0||e===n?null:t.slice(e,n+4)}}class Hf{constructor(){p(this,"worker",new Wc)}paste(t,e){if(!t.clipboardData)return!1;const n=t.clipboardData.items;for(let o=0;o<n.length;o++){const s=n[o];if(s.type.startsWith("image/")){const r=s.getAsFile();return r?(this.pasteImg(r,e),!0):!1}}return!1}async pasteImg(t,e){const n=Zo(10),o=`${e.docState.docId}/${n}`,s=await e.resourceManager.uploadFileBlob(o,t),{width:r,height:i}=await Pc.getImageSize(t),a=e.lastInteractiveEvent.globalPoint;this.worker.addImageNode(s,r,i,a,e)}}class Gc{constructor(t){p(this,"eventCtx");p(this,"pasteHandlers");p(this,"copyHandlers");this.eventCtx=t,this.pasteHandlers=[new Hf,new Rf,new Ef],this.copyHandlers=[new Af,new Cf]}paste(t){for(const e of this.pasteHandlers)if(e.paste(t,this.eventCtx))return}copy(t){for(const e of this.copyHandlers)if(e.copy(t,this.eventCtx))return}cut(t){console.log(t)}}class Uc{constructor(t){p(this,"eventCtx");p(this,"copyPasteManager");p(this,"onCopy",t=>{this.onEnable()&&this.copyPasteManager.copy(t)});p(this,"onPaste",t=>{this.onEnable()&&this.eventCtx.docState.canEdit()&&this.copyPasteManager.paste(t)});p(this,"onCut",t=>{this.onEnable()&&this.eventCtx.docState.canEdit()&&this.copyPasteManager.cut(t)});this.eventCtx=t,this.copyPasteManager=new Gc(t)}start(){document.addEventListener("copy",this.onCopy),document.addEventListener("paste",this.onPaste),document.addEventListener("cut",this.onCut)}stop(){document.removeEventListener("copy",this.onCopy),document.removeEventListener("paste",this.onPaste),document.removeEventListener("cut",this.onCut)}onEnable(){return this.eventCtx.docState.canEdit()}}const Df=new Set([v.Shape]);class Of{constructor(t){p(this,"app");this.app=t}addTemplateNodes(t){const e=xn.convertDocumentInfoToPasteData(t,fo.Template),n=new cs,o=this.app.appContext;n.asyncHandleCrossPaste(e,o,Kt.EmptyPlace).then(s=>{if(s)o.renderManager.zoomToSelect();else throw console.error("应用模版时出现错误"),new Error("应用模版时出现错误")})}addNode(t,e){const n=this.app.appContext,o=M.getViewportBoundCenter(n),s=100,r=100,i=new m(o.x-s/2,o.y-r/2),a=n.createWorker.makeupDefaultProps(t,n,e,i),c=n.idGenerator.genId(t);n.execAction(new W),n.execAction(Le.create({id:c,props:a,parentId:"",type:t,zIndex:ve.genZIndex(n.nodeManager.root)})),n.execAction(xe.create([c])),Df.has(t)&&n.execAction(ee.focus(c)),n.execAction(new z)}addSvgNodeBySvgCode(t){const e=this.app.docState.docId,n=Zo(10),o=`${e}/${n}`;this.app.resourceManager.uploadSvgString(o,t).then(s=>{this.addSvgNode(t,s)})}addSvgNode(t,e){const n=this.app.appContext,o=n.renderManager.gmlRender.getViewPortBounds(),s=new m(.5*(o.minX+o.maxX),.5*(o.minY+o.maxY)),i=new cr().computeAddSvgNode(t,e,s,this.app.appContext),a=i.id;n.execAction(new W);const c=Le.create(i);n.execAction(c),n.execAction(xe.create([a])),n.execAction(new z)}addImageNode(t,e,n){const o=new Wc,s=this.app.appContext,r=s.renderManager.gmlRender.getViewPortBounds(),i=new m(.5*(r.minX+r.maxX),.5*(r.minY+r.maxY));o.addImageNode(t,e,n,i,s)}quickCreateNode(t,e){const n=this.app.nodeManager.getNode(e);if(!n||n.type!==v.Line)return;const o=n,{start:s}=o.connectProps;if(!s)return;const r=this.app.nodeManager.getNode(s.objectId);if(!r)return;const i=r.baseProps,c=o.lineProps.points,h=c[c.length-1],d=c[c.length-2],u=vt.drawerMap.get(t).getConnectAnchor(),g=M.judgeHorizon(d,h);let f;g?h.x>d.x?f=u[ue.Left]:f=u[ue.Right]:h.y>d.y?f=u[ue.Top]:f=u[ue.Bottom];const y=i.width*f.x,P=i.height*f.y,b=h.x-y,w=h.y-P,L=this.app.appContext,B=Is[t],H=Mo[B],E=cn[B],X=[{type:I.Base,x:b,y:w,width:i.width,height:i.height},tt.create({color:H}),Ae.create({color:E}),new Oe(t)],$=L.idGenerator.genId(v.Shape),Z={id:$,type:v.Shape,zIndex:ve.genZIndex(this.app.nodeManager.root),parentId:"",props:X};L.execAction(new W);const se=Le.create(Z);L.execAction(se);const ne=o.connectProps.clone();ne.end={objectId:$,x:f.x,y:f.y},L.execAction(U.create(e,[ne])),L.execAction(xe.create([$])),L.execAction(ee.focus($)),L.execAction(new z)}makeupToSlidesBySelective(){this.makeupToSlides([...this.app.appContext.getSelectNodes()])}makeupToSlides(t){const e=t.filter($=>!(!($ instanceof rs)||$.parent&&$.parent.type===v.SlideContainer)),n=this.app.appContext;n.execAction(new W),n.execAction(xe.create([]));const o=nt,s=xt,r=this.sortSectionsByPosition(e),i=e.length,a=Math.ceil(Math.sqrt(i)),c=[];for(let $=0;$<r.length;$+=a){const Z=r.slice($,$+a);c.push({ids:Z})}const h=n.idGenerator.genId(v.SlideContainer),d=[ie.create({x:0,y:0,width:100,height:100}),Mt.create({children:c})],u={id:h,type:v.SlideContainer,zIndex:ve.genZIndex(this.app.nodeManager.root),parentId:"",props:d};n.execAction(Le.create(u));const g=[];let f=0,y=0,P=1/0,b=1/0,w=-1/0,L=-1/0;c.flatMap($=>$.ids).forEach(($,Z)=>{const se=e.find(Re=>Re.id===$);if(!se)return;Z===0&&(f=se.baseProps.x-o,y=se.baseProps.y-s);const ne=Math.floor(Z/a),ae=Z%a,te=se.baseProps,ce=ae*(te.width+o)+o,pe=ne*(te.height+s)+s;P=Math.min(P,ce),b=Math.min(b,pe),w=Math.max(w,ce+te.width),L=Math.max(L,pe+te.height);const Be=ie.create({x:ce,y:pe,width:te.width,height:te.height,angle:te.angle});g.push({id:$,parentId:h,props:[Be]})}),g.length>0&&n.execAction(new U({infos:g}));const H=w-P+2*o,E=L-b+2*s,X=ie.create({x:f,y,width:H,height:E});n.execAction(U.create(h,[X])),n.execAction(xe.create([h])),n.execAction(new z)}sortSectionsByPosition(t){if(t.length===0)return[];const e=t.map(s=>({id:s.id,x:s.baseProps.x,y:s.baseProps.y,yMin:s.baseProps.y,yMax:s.baseProps.y+s.baseProps.height}));e.sort((s,r)=>s.y!==r.y?s.y-r.y:s.x-r.x);const n=[],o=[...e];for(;o.length>0;){const s=o.shift(),r=[s];let i=0;for(;i<o.length;){const a=o[i];a.y>=s.yMin&&a.y<=s.yMax?(r.push(a),o.splice(i,1)):i++}r.sort((a,c)=>a.x-c.x),n.push(...r.map(a=>a.id))}return n}}class ls{constructor(){p(this,"groupBaseWorker",new on)}group(t,e){const n=M.filterToGroupNodes(t);if(n.length<2)return;e.execAction(new W);const o=e.idGenerator.genId(v.Group),s=[],r=M.sortGraphics(n),i=r[r.length-1].parent;for(const b of r)s.push(b.getBounds());const a=M.getBounds(s),c=D.rectNode2Rect(a),h=new m(c.x,c.y),d=i.toLocal(h),u={id:o,parentId:i.id,type:v.Group,zIndex:ve.genZIndex(i),props:[ie.create({x:d.x,y:d.y,width:c.width,height:c.height})]};e.execAction(new Le({nodes:[u]}));const g=e.nodeManager.getNode(o),f=[];let y=1;const P=$t.flattenNodes(r);this.groupBaseWorker.start(P);for(const b of r){if(b.type===v.Group){const w=$t.flattenNodes([b]);for(const L of w)f.push(M.computeRelationChangeUpdateNodeInfo(L,g))}f.push(M.computeRelationChangeUpdateNodeInfo(b,g,y,o)),y++}e.execAction(new U({infos:f})),this.groupBaseWorker.work(e,!1),e.execAction(xe.create([g.id])),e.execAction(new z)}unGroup(t,e){e.execAction(new W);const n=t.parent,o=[...t.children];o.sort((c,h)=>c.zIndex-h.zIndex);const s=[];let r=1;const i=Math.max(...[...n.children].map(c=>c.zIndex)),a=[];for(const c of o){if(c.type===v.Group){const h=$t.flattenNodes([c]);for(const d of h)s.push(M.computeRelationChangeUpdateNodeInfo(d,t))}s.push(M.computeRelationChangeUpdateNodeInfo(c,t,i+r,n.id)),r++,a.push(c.id)}e.execAction(new U({infos:s})),e.execAction(At.create([t.id])),e.execAction(xe.create(a)),e.execAction(new z)}}class Xf{constructor(t){p(this,"app");this.app=t}rotateImageAngle(t,e){const n=this.getNodeIdByBlobUrl(t);n&&this.rotateImage(n,e)}rotateImage(t,e){const n=this.app.appContext,o=n.nodeManager.getNode(t);if(!o)return;const{angle:s}=o.baseProps,r=o.globalPos,i=D.rectNode2Rect(o.getBounds()),a=new m(i.x+.5*i.width,i.y+.5*i.height),c=re.generateMatrix().translate(a.x,a.y),h=re.generateMatrix().rotate(e),u=c.crossProduct(h).crossProduct(c.inverseMatrix()).crossPoint(r);let g;o.parent.type===v.Group?g=o.parent.globalTransform().inverseMatrix().crossPoint(u):g=o.parent.toLocal(u),n.execAction(new W),n.execAction(U.create(t,[{type:I.Base,x:g.x,y:g.y,angle:s+e}])),n.execAction(new z)}getNodeIdByBlobUrl(t){const e=this.app.appContext;for(const[n,o]of e.resourceManager.nodeResourceMap)if(o.blobUrl===t)return n;return""}}class zf{constructor(t){p(this,"app");this.app=t}async copySelectNodes(){const e=new Ks().work(this.app.appContext);if(!e)return!1;const n=JSON.stringify(e),o=xn.encode(n),s=new Blob([o],{type:"text/html"}),r=new ClipboardItem({"text/html":s});await navigator.clipboard.write([r])}copySelectNodesAsPng(t=2,e=""){const o=this.app.appContext.auxiliaryManager.selectManager.getSelectBounds(),s=this.app.renderManager.exportOfflineCanvas(o,t,e);return new Promise(r=>{s.toBlob(async i=>{if(!i){console.error("转化为图片时候出现错误.");return}const a=new ClipboardItem({[i.type]:i});await navigator.clipboard.write([a]),r()})})}async pasteNodes(){try{const t=this.app.appContext,e=await navigator.clipboard.read();for(const n of e)if(n.types.includes("text/html")){const s=await(await n.getType("text/html")).text();if(!s)return;const r=xn.decode(s);if(r===null)return;const i=JSON.parse(r);new cs().handle(i,t);return}console.log("剪贴板中没有可用的文本数据")}catch(t){console.error("读取剪贴板失败:",t),alert("粘贴失败,请检查权限或使用 Ctrl+V")}}}class So{work(t){const e=[...t.getSelectNodes()];e.length!==0&&this.deleteByIds(t,e.map(n=>n.id))}deleteByIds(t,e){var r;if(e.length===0)return;const n=[];e.forEach(i=>{const a=t.nodeManager.getNode(i);a&&n.push(a)});const o=new Set,s=new Set;for(const i of n)o.add(i.id),t.nodeManager.getNodeLinks(i).forEach(c=>o.add(c.id)),this.addAllChildren(i,o),((r=i.parent)==null?void 0:r.type)===v.SlideContainer&&s.add(i.parent);t.actionManager.execAction(new W),t.actionManager.execAction(xe.create([])),t.actionManager.execAction(At.create([...o])),s.size>0&&t.slideManager.updateSlideContainers(s,o,t),t.actionManager.execAction(new z)}addAllChildren(t,e){e.add(t.id);for(const n of t.children)this.addAllChildren(n,e)}}class Wf{constructor(t){p(this,"app");this.app=t}intoCrop(){new wo().intoCrop(this.app.appContext)}exitCrop(){new wo().exitCrop(this.app.appContext)}resetCrop(){new wo().resetCrop(this.app.appContext)}}class Ff{constructor(t){p(this,"app");p(this,"lineTextWorker",new $n);this.app=t}switchShape(t){const e=this.app.appContext,n=[...e.getSelectNodes()];if(new Set(n.map(s=>s.type)).size===1&&n[0].type===v.Shape&&n[0].validShapeCode(t)){const r=[];for(const i of n)t!==i.shapeType&&r.push({id:i.id,props:[{type:I.Shape,shapeCode:t}]});r.length>0&&(e.execAction(new W),e.execAction(new U({infos:r})),e.execAction(new z))}}switchLineShape(t){const e=this.app.appContext,n=[...e.getSelectNodes()];if(new Set(n.map(s=>s.type)).size===1&&n[0].type===v.Line){const s=[];for(const r of n){const i=r;if(this.lineTextWorker.init(i),t===i.shapeType)continue;const a=[{type:I.Shape,shapeCode:t}],c=i.points;if(t===de.Line)a.push({type:I.Line,points:[c[0],c[c.length-1]]});else if(t===de.Curve){const h=new po;this.modifyLinePoints(i,e,h,a)}else if(t===de.PolyLine||t===de.RoundPolyLine){const h=new Vt;this.modifyLinePoints(i,e,h,a)}else continue;s.push({id:i.id,props:a})}s.length>0&&(e.execAction(new W),s.forEach(r=>{e.execAction(new U({infos:[r]})),this.lineTextWorker.work(this.app.nodeManager.getNode(r.id),e,!1)}),e.execAction(new z))}}modifyLinePoints(t,e,n,o){const{start:s,end:r}=t.connectProps,i=Ze.computeConnectInfo(t,s,e,!1),a=Ze.computeConnectInfo(t,r,e,!0),c=n.layoutToPointsPro(i,a);o.push({type:I.Line,points:c});const h=D.rectNode2Rect(M.getBoundsByPoints(c)),d=ie.create({x:h.x,y:h.y,width:h.width,height:h.height});o.push(d)}}class Yf{constructor(t){p(this,"app");this.app=t}}class Gf{constructor(t){p(this,"app");p(this,"groupBaseWorker",new on);this.app=t}alignLeft(){const t=this.app.appContext,e=this.getAlignNodes();if(e.length<2)return;const n=Math.min(...e.map(s=>s.globalBaseProps.x)),o=[];for(const s of e){const r=s.globalPos,i=s.parent.toLocal({x:n,y:r.y}),a=s.baseProps,c=i.x-a.x;this.dealNodePos(s,o,c,0)}t.execAction(new W),t.execAction(new U({infos:o})),t.execAction(new z)}alignRight(){const t=this.app.appContext,e=this.getAlignNodes();if(e.length<2)return;const n=Math.max(...e.map(s=>{const r=s.globalBaseProps;return r.x+r.width})),o=[];for(const s of e){const r=s.globalPos,i=s.parent.toLocal({x:n-s.baseProps.width,y:r.y}),a=s.baseProps,c=i.x-a.x;this.dealNodePos(s,o,c,0)}t.execAction(new W),t.execAction(new U({infos:o})),t.execAction(new z)}alignHorizontalCenter(){const t=this.app.appContext,e=this.getAlignNodes();if(e.length<2)return;const n=Math.min(...e.map(i=>i.globalPos.x)),o=Math.max(...e.map(i=>i.globalBaseProps.x+i.baseProps.width)),s=(n+o)/2,r=[];for(const i of e){const a=i.globalPos,c=i.parent.toLocal({x:s-i.baseProps.width/2,y:a.y}),h=i.baseProps,d=c.x-h.x;this.dealNodePos(i,r,d,0)}t.execAction(new W),t.execAction(new U({infos:r})),t.execAction(new z)}dealNodePos(t,e,n,o){const s=t.baseProps,r=s.x+n,i=s.y+o;if(t instanceof Ct){const a=t.points,c=[];for(const h of a)c.push({x:h.x+n,y:h.y+o});e.push({id:t.id,props:[{type:I.Base,x:r,y:i},{type:I.Line,points:c}]})}else e.push({id:t.id,props:[{type:I.Base,x:r,y:i}]});if(t.type===v.Group){const a={x:n,y:o};this.computeGroupChildrenAction(t,a,e)}}alignTop(){const t=this.app.appContext,e=this.getAlignNodes();if(e.length<2)return;const n=Math.min(...e.map(s=>s.globalBaseProps.y)),o=[];for(const s of e){const r=s.globalPos,i=s.parent.toLocal({x:r.x,y:n}),a=s.baseProps,c=i.y-a.y;this.dealNodePos(s,o,0,c)}t.execAction(new W),t.execAction(new U({infos:o})),t.execAction(new z)}alignBottom(){const t=this.app.appContext,e=this.getAlignNodes();if(e.length<2)return;const n=Math.max(...e.map(s=>s.globalBaseProps.y+s.baseProps.height)),o=[];for(const s of e){const r=s.globalPos,i=s.parent.toLocal({x:r.x,y:n-s.baseProps.height}),a=s.baseProps,c=i.y-a.y;this.dealNodePos(s,o,0,c)}t.execAction(new W),t.execAction(new U({infos:o})),t.execAction(new z)}alignVerticalCenter(){const t=this.app.appContext,e=this.getAlignNodes();if(e.length<2)return;const n=Math.min(...e.map(i=>i.globalPos.y)),o=Math.max(...e.map(i=>i.globalPos.y+i.baseProps.height)),s=(n+o)/2,r=[];for(const i of e){const a=i.globalPos,c=i.parent.toLocal({x:a.x,y:s-i.baseProps.height/2}),h=i.baseProps,d=c.y-h.y;this.dealNodePos(i,r,0,d)}t.execAction(new W),t.execAction(new U({infos:r})),t.execAction(new z)}distributeHorizontal(){const t=this.app.appContext,e=this.getAlignNodes();if(e.length<3)return;const n=[...e].sort((g,f)=>g.globalPos.x-f.globalPos.x),o=n[0],s=n[n.length-1],r=o.globalPos.x,i=s.globalPos.x+s.baseProps.width,a=n.reduce((g,f)=>g+f.baseProps.width,0),h=(i-r-a)/(e.length-1),d=[];let u=r;for(let g=0;g<n.length;g++){const f=n[g],y=f.globalPos,P=f.parent.toLocal({x:u,y:y.y}),b=f.baseProps,w=P.x-b.x;this.dealNodePos(f,d,w,0),u+=f.baseProps.width+h}t.execAction(new W),t.execAction(new U({infos:d})),t.execAction(new z)}distributeVertical(){const t=this.app.appContext,e=this.getAlignNodes();if(e.length<3)return;const n=[...e].sort((g,f)=>g.globalPos.y-f.globalPos.y),o=n[0],s=n[n.length-1],r=o.globalPos.y,i=s.globalPos.y+s.baseProps.height,a=n.reduce((g,f)=>g+f.baseProps.height,0),h=(i-r-a)/(e.length-1),d=[];let u=r;for(let g=0;g<n.length;g++){const f=n[g],y=f.globalPos,P=f.parent.toLocal({x:y.x,y:u}),b=f.baseProps,w=P.y-b.y;this.dealNodePos(f,d,0,w),u+=f.baseProps.height+h}t.execAction(new W),t.execAction(new U({infos:d})),t.execAction(new z)}getAlignNodes(){return[...this.app.appContext.getSelectNodes()].filter(o=>{if(o.type!==v.Line)return!0;const s=o,{start:r,end:i}=s.connectProps;return!r&&!i})}getLayoutNodes(t){return t instanceof Po?$t.flattenNodes([t]):[t]}computeGroupChildrenAction(t,e,n){if(t.type===v.Group)for(const o of t.children){if(o.type===v.Line){const s=o.points,r=[];for(const c of s)r.push({x:c.x+e.x,y:c.y+e.y});const{x:i,y:a}=o.baseProps;n.push({id:o.id,props:[{type:I.Base,x:i+e.x,y:a+e.y},{type:I.Line,points:r}]})}else{const{x:s,y:r}=o.baseProps;n.push({id:o.id,props:[{type:I.Base,x:s+e.x,y:r+e.y}]})}this.computeGroupChildrenAction(o,e,n)}}}class Uf{batchNodesToUnOrderByNotEditing(t){const n=[...t.getSelectNodes()].filter(s=>s.type===v.Shape||s.type===v.Line),o=[];for(const s of n)o.push(this.toUnOrderByNotEditing(s));o.length>0&&(t.execAction(new W),t.execAction(new U({infos:o})),t.execAction(new z))}toUnOrderBySelection(t,e,n){const{start:o,end:s}=e,r=t.getProp(I.TextParagraph).clone(),i=o.paragraphIndex,a=s.paragraphIndex;for(let d=i;d<=a;d++)this.toUnOrderWithPara(d,r);const h=[{id:t.id,props:[{type:I.TextParagraph,paragraphStyles:r.paragraphStyles}]}];h.length>0&&(n.execAction(new W),n.execAction(ee.selection(t.id,o,s)),n.execAction(new U({infos:h})),n.execAction(ee.selection(t.id,o,s)),n.execAction(new z))}toUnOrderByEditing(t,e,n){const{textCursorPosition:o}=e,s=t.getProp(I.TextParagraph).clone(),r=o.paragraphIndex;this.toUnOrderWithPara(r,s);const a=[{id:t.id,props:[{type:I.TextParagraph,paragraphStyles:s.paragraphStyles}]}];a.length>0&&(n.execAction(new W),n.execAction(ee.focus(t.id,o)),n.execAction(new U({infos:a})),n.execAction(ee.focus(t.id,o)),n.execAction(new z))}toUnOrderWithPara(t,e){const n=e.paragraphStyles.findIndex(s=>s.paraIndex===t),o=M.getParaStyle(e,t-1);if(n<0)e.paragraphStyles.push({paraIndex:t,level:o?o.level:0,orderIndex:-1});else{const s=e.paragraphStyles[n];s.orderIndex!==-1?s.orderIndex=-1:e.paragraphStyles.splice(n,1)}}toUnOrderByNotEditing(t){const e=t.getProp(I.TextParagraph).clone(),n=t.renderText,o=e.paragraphStyles,s=M.computeNotUnOrderParas(n);if(s.size===0)return{id:t.id,props:[{type:I.TextParagraph,paragraphStyles:[]}]};for(const r of s){const i=M.getParaStyle(e,r);if(i)i.orderIndex=-1;else{const a={level:0,orderIndex:-1,paraIndex:r};o.push(a)}}return{id:t.id,props:[{type:I.TextParagraph,paragraphStyles:o}]}}}class _f{batchNodesToOrderByNotEditing(t){const n=[...t.getSelectNodes()].filter(s=>s.type===v.Shape||s.type===v.Line),o=[];for(const s of n)o.push(this.toOrderByNotEditing(s));o.length>0&&(t.execAction(new W),t.execAction(new U({infos:o})),t.execAction(new z))}toOrderBySelection(t,e,n){const{start:o,end:s}=e,r=t.getProp(I.TextParagraph).clone(),i=o.paragraphIndex,a=s.paragraphIndex;for(let d=i;d<=a;d++)this.toOrderWithPara(d,r);const h=[{id:t.id,props:[{type:I.TextParagraph,paragraphStyles:r.paragraphStyles}]}];h.length>0&&(n.execAction(new W),n.execAction(ee.selection(t.id,o,s)),n.execAction(new U({infos:h})),n.execAction(ee.selection(t.id,o,s)),n.execAction(new z))}toOrderByEditing(t,e,n){const{textCursorPosition:o}=e,s=t.getProp(I.TextParagraph).clone(),r=o.paragraphIndex;this.toOrderWithPara(r,s);const a=[{id:t.id,props:[{type:I.TextParagraph,paragraphStyles:s.paragraphStyles}]}];a.length>0&&(n.execAction(new W),n.execAction(ee.focus(t.id,o)),n.execAction(new U({infos:a})),n.execAction(ee.focus(t.id,o)),n.execAction(new z))}toOrderWithPara(t,e){const n=e.paragraphStyles.findIndex(s=>s.paraIndex===t),o=M.getParaStyle(e,t-1);if(n<0){const s=o&&o.orderIndex>0?o.orderIndex+1:1,r=o?o.level:0;e.paragraphStyles.push({paraIndex:t,level:r,orderIndex:s})}else{const s=e.paragraphStyles[n];if(s.orderIndex>0)e.paragraphStyles.splice(n,1);else{const r=o&&o.orderIndex>0?o.orderIndex+1:1;s.orderIndex=r}}}toOrderByNotEditing(t){const e=t.getProp(I.TextParagraph).clone(),n=t.renderText,o=e.paragraphStyles,s=M.computeNotOrderParas(n);if(s.size===0)return{id:t.id,props:[{type:I.TextParagraph,paragraphStyles:[]}]};const r=[...s].sort((i,a)=>i-a);for(const i of r){const a=o.findIndex(h=>h.paraIndex===i),c=o.findIndex(h=>h.paraIndex===i-1);if(a>-1){const h=o[a];if(c>-1){const d=o[c];h.orderIndex=d.orderIndex+1,h.level=d.level}else h.orderIndex=1,h.level=0}else if(c>-1){const h=o[c],d={level:h.level,orderIndex:h.orderIndex+1,paraIndex:i};o.push(d)}else{const h={level:0,orderIndex:1,paraIndex:i};o.push(h)}}return{id:t.id,props:[{type:I.TextParagraph,paragraphStyles:o}]}}}class $f{batchNodesToQuoteByNotEditing(t){const n=[...t.getSelectNodes()].filter(s=>s.type===v.Shape||s.type===v.Line),o=[];for(const s of n)o.push(this.toQuoteByNotEditing(s));o.length>0&&(t.execAction(new W),t.execAction(new U({infos:o})),t.execAction(new z))}toQuoteBySelection(t,e,n){var u;const{start:o,end:s}=e,r=((u=t.getProp(I.TextParagraphQuote))==null?void 0:u.clone())||new Dt,i=o.paragraphIndex,a=s.paragraphIndex;let c=!1;for(let g=i;g<=a;g++)if(r.paraQuoteStyles.findIndex(y=>y.paraIndex===g)<0){c=!0;break}if(c)for(let g=i;g<=a;g++)r.paraQuoteStyles.findIndex(y=>y.paraIndex===g)<0&&r.paraQuoteStyles.push({paraIndex:g,quote:!0});else for(let g=i;g<=a;g++){const f=r.paraQuoteStyles.findIndex(y=>y.paraIndex===g);f>=0&&r.paraQuoteStyles.splice(f,1)}const d=[{id:t.id,props:[{type:I.TextParagraphQuote,paraQuoteStyles:r.paraQuoteStyles}]}];d.length>0&&(n.execAction(new W),n.execAction(ee.selection(t.id,o,s)),n.execAction(new U({infos:d})),n.execAction(ee.selection(t.id,o,s)),n.execAction(new z))}toQuoteByEditing(t,e,n){var c;const{textCursorPosition:o}=e,s=((c=t.getProp(I.TextParagraphQuote))==null?void 0:c.clone())||new Dt,r=o.paragraphIndex;this.toQuoteWithPara(r,s);const a=[{id:t.id,props:[{type:I.TextParagraphQuote,paraQuoteStyles:s.paraQuoteStyles}]}];a.length>0&&(n.execAction(new W),n.execAction(ee.focus(t.id,o)),n.execAction(new U({infos:a})),n.execAction(ee.focus(t.id,o)),n.execAction(new z))}toQuoteWithPara(t,e){const n=e.paraQuoteStyles.findIndex(o=>o.paraIndex===t);if(n<0)e.paraQuoteStyles.push({paraIndex:t,quote:!0});else{const o=e.paraQuoteStyles[n];o.quote?e.paraQuoteStyles.splice(n,1):o.quote=!0}}toQuoteByNotEditing(t){const e=t.renderText;if(M.computeNotQuoteParas(e).size===0)return{id:t.id,props:[{type:I.TextParagraphQuote,paraQuoteStyles:[]}]};const o=[];for(let s=0;s<e.paragraphs.length;s++)o.push({paraIndex:s,quote:!0});return{id:t.id,props:[{type:I.TextParagraphQuote,paraQuoteStyles:o}]}}}class jf{batchNodesToNormalByNotEditing(t){const n=[...t.getSelectNodes()].filter(s=>s.type===v.Shape||s.type===v.Line),o=[];for(const s of n){const r=this.toNormalByNotEditing(s);r&&o.push(r)}o.length>0&&(t.execAction(new W),t.execAction(new U({infos:o})),t.execAction(new z))}toNormalBySelection(t,e,n){var d;const{start:o,end:s}=e,r=(d=t.getProp(I.TextParagraph))==null?void 0:d.clone(),i=o.paragraphIndex,a=s.paragraphIndex,c=[],h=[];if(r){for(let u=i;u<=a;u++){const g=r.paragraphStyles.findIndex(f=>f.paraIndex===u);g>=0&&r.paragraphStyles.splice(g,1)}h.push({type:I.TextParagraph,paragraphStyles:r.paragraphStyles})}if(h.length>0){const u={id:t.id,props:h};c.push(u)}c.length>0&&(n.execAction(new W),n.execAction(ee.selection(t.id,o,s)),n.execAction(new U({infos:c})),n.execAction(ee.selection(t.id,o,s)),n.execAction(new z))}toNormalByEditing(t,e,n){var c;const{textCursorPosition:o}=e,s=(c=t.getProp(I.TextParagraph))==null?void 0:c.clone(),r=o.paragraphIndex,i=[],a=[];if(s){const h=s.paragraphStyles.findIndex(d=>d.paraIndex===r);h>=0&&s.paragraphStyles.splice(h,1),a.push({type:I.TextParagraph,paragraphStyles:s.paragraphStyles})}if(a.length>0){const h={id:t.id,props:a};i.push(h)}i.length>0&&(n.execAction(new W),n.execAction(ee.focus(t.id,o)),n.execAction(new U({infos:i})),n.execAction(ee.focus(t.id,o)),n.execAction(new z))}toNormalByNotEditing(t){const e=t.renderText;return M.computeNotNormalParas(e).size===0?null:{id:t.id,props:[{type:I.TextParagraph,paragraphStyles:[]}]}}}class wr{work(t,e,n){const{node:o,renderText:s,textCursorPosition:r}=t,{updateTextProps:i}=this.computeUpdateTextProps(t,n);e.execAction(new W),e.execAction(U.create(o.id,[i]));const a=s.nextCursorPos(r,n.length);e.execAction(ee.focus(o.id,a)),e.execAction(new z)}computeUpdateTextProps(t,e){const{renderText:n,textCursorPosition:o}=t,s=this.editText(n,o,e);return{updateTextProps:{type:I.Text,richText:s}}}editText(t,e,n){const{paragraphIndex:o,lineIndex:s,charIndex:r}=e,i=t.prevParagraphToXML(o),a=t.nextParagraphToXML(o),c=t.getParagraph(o),h=c.prevToRichTextXML(s,t.textProps),d=c.nextToRichTextXML(s,t.textProps),u=c.getLine(s),g=u.getBlockIndex(r);if(g){const{textBlock:f,blockIndex:y,charIndex:P}=g,b=u.prevToRichTextXML(y,t.textProps),w=u.nextToRichTextXML(y,t.textProps),L=f.insertTextToRichTextXML(n,P,t.textProps);return`<root>${i}<p>${h}${b}${L}${w}${d}</p>${a}</root>`}return`<root>${i}<p>${h}${n}${d}</p>${a}</root>`}getEditTextPrevNext(t,e){const{paragraphIndex:n,lineIndex:o,charIndex:s}=e,r=t.prevParagraphToXML(n),i=t.nextParagraphToXML(n),a=t.getParagraph(n),c=a.prevToRichTextXML(o,t.textProps),h=a.nextToRichTextXML(o,t.textProps),d=a.getLine(o),u=d.getBlockIndex(s);if(u){const{textBlock:y,blockIndex:P,charIndex:b}=u,w=d.prevToRichTextXML(P,t.textProps),L=d.nextToRichTextXML(P,t.textProps),B=y.getPrevText(b),H=y.getNextText(b),E=y.computeStyle(t.textProps),X=`<root>${r}<p>${c}${w}<style ${E}>${B}`,$=`${H}</style>${L}${h}</p>${i}</root>`;return{prev:X,next:$}}const g=`<root>${r}<p>${c}`,f=`${h}</p>${i}</root>`;return{prev:g,next:f}}applyStyleToSelection(t,e,n,o){const{start:s,end:r}=this.normalizeSelection(e,n);return s.paragraphIndex===r.paragraphIndex&&s.lineIndex===r.lineIndex?this.applyStyleSameLine(t,s,r,o):s.paragraphIndex===r.paragraphIndex?this.applyStyleSameParagraph(t,s,r,o):this.applyStyleDifferentParagraphs(t,s,r,o)}normalizeSelection(t,e){const n=this.getCursorPosition(t),o=this.getCursorPosition(e);return n<=o?{start:t,end:e}:{start:e,end:t}}getCursorPosition(t){return t.paragraphIndex*1e6+t.lineIndex*1e3+(t.charIndex+1)}generateStyleString(t){return Object.entries(t).map(([e,n])=>`${e}='${n}'`).join(" ")}mergeStyles(t,e){const n={};if(t.trim()){const s=/(\S+)=['"]([^'"]*)['"]/g;let r;for(;(r=s.exec(t))!==null;)n[r[1]]=r[2]}const o={...n,...e};return Object.entries(o).map(([s,r])=>`${s}='${r}'`).join(" ")}applyStyleSameLine(t,e,n,o){const{paragraphIndex:s,lineIndex:r}=e,i=e.charIndex+1,a=n.charIndex,c=t.prevParagraphToXML(s),h=t.nextParagraphToXML(s),d=t.getParagraph(s),u=d.prevToRichTextXML(r,t.textProps),g=d.nextToRichTextXML(r,t.textProps),f=d.getLine(r),y=this.buildSelectionXMLInLine(f,i,a,o,t.textProps);return`<root>${c}<p>${u}${y}${g}</p>${h}</root>`}buildSelectionXMLInLine(t,e,n,o,s){let r="",i=0;const a=e===-1?0:e,c=n===-1?0:n;for(let h=0;h<t.textBlocks.length;h++){const d=t.textBlocks[h],u=d.characters.length;if(i+u-1<a){r+=d.toRichTextXML(s),i+=u;continue}if(i>c){r+=d.toRichTextXML(s),i+=u;continue}const f=Math.max(0,a-i),y=Math.min(u-1,c-i);if(f>0){const L=d.getPrevText(f-1),B=d.computeStyle(s);r+=`<style ${B}>${L}</style>`}const P=this.getTextRange(d,f,y),b=d.computeStyle(s),w=this.mergeStyles(b,o);if(r+=`<style ${w}>${P}</style>`,y<u-1){const L=d.getNextText(y),B=d.computeStyle(s);r+=`<style ${B}>${L}</style>`}i+=u}return r}getTextRange(t,e,n){let o="";for(let s=e;s<=n;s++)o+=t.characters[s].charText;return o}applyStyleSameParagraph(t,e,n,o){const{paragraphIndex:s}=e,r=t.prevParagraphToXML(s),i=t.nextParagraphToXML(s),a=t.getParagraph(s);let c="";c+=a.prevToRichTextXML(e.lineIndex,t.textProps);const h=a.getLine(e.lineIndex);c+=this.buildSelectionXMLInLine(h,e.charIndex+1,h.getCharLength()-1,o,t.textProps);for(let u=e.lineIndex+1;u<n.lineIndex;u++){const g=a.getLine(u);c+=this.buildSelectionXMLInLine(g,-1,g.getCharLength()-1,o,t.textProps)}const d=a.getLine(n.lineIndex);return c+=this.buildSelectionXMLInLine(d,-1,n.charIndex,o,t.textProps),c+=a.nextToRichTextXML(n.lineIndex,t.textProps),`<root>${r}<p>${c}</p>${i}</root>`}applyStyleDifferentParagraphs(t,e,n,o){let s="<root>";s+=t.prevParagraphToXML(e.paragraphIndex);const r=t.getParagraph(e.paragraphIndex);let i="";i+=r.prevToRichTextXML(e.lineIndex,t.textProps);const a=r.getLine(e.lineIndex);i+=this.buildSelectionXMLInLine(a,e.charIndex+1,a.getCharLength()-1,o,t.textProps);for(let u=e.lineIndex+1;u<r.lines.length;u++){const g=r.getLine(u);i+=this.buildSelectionXMLInLine(g,-1,g.getCharLength()-1,o,t.textProps)}s+=`<p>${i}</p>`;for(let u=e.paragraphIndex+1;u<n.paragraphIndex;u++){const g=t.getParagraph(u);let f="";for(const y of g.lines)f+=this.buildSelectionXMLInLine(y,-1,y.getCharLength()-1,o,t.textProps);s+=`<p>${f}</p>`}const c=t.getParagraph(n.paragraphIndex);let h="";for(let u=0;u<n.lineIndex;u++){const g=c.getLine(u);h+=this.buildSelectionXMLInLine(g,-1,g.getCharLength()-1,o,t.textProps)}const d=c.getLine(n.lineIndex);return h+=this.buildSelectionXMLInLine(d,-1,n.charIndex,o,t.textProps),h+=c.nextToRichTextXML(n.lineIndex,t.textProps),s+=`<p>${h}</p>`,s+=t.nextParagraphToXML(n.paragraphIndex),s+="</root>",s}}class Hn{constructor(){p(this,"inputWorker",new wr)}changeFontProp(t,e){if(e.getSelectNodes().size===0)return;const o=e.inputManager.selectionManager.selectionInfo,s=e.inputManager.editTextInfo;if(s&&o){this.changeFontPropBySelection(t,s,o,e);return}this.changeFontPropForWhole(t,e)}changeFontPropForWhole(t,e){const o=[...e.getSelectNodes()].filter(r=>r.getProp(I.Text)!==null),s=[];for(const r of o)s.push({id:r.id,props:[this.textProp(t)]});s.length>0&&(e.execAction(new W),e.execAction(new U({infos:s})),e.execAction(new z))}changeFontPropBySelection(t,e,n,o){const{renderText:s,node:r}=e,{start:i,end:a}=n,c=this.inputWorker.applyStyleToSelection(s,i,a,this.richStyle(t));o.execAction(new W),o.execAction(ee.selection(r.id,i,a)),o.execAction(U.create(r.id,[{type:I.Text,richText:c}])),o.execAction(ee.selection(r.id,i,a)),o.execAction(new z)}}class Vf extends Hn{richStyle(t){return{color:t}}textProp(t){return{type:I.Text,fontColor:t}}}class Kf extends Hn{richStyle(t){return{"bg-color":t}}textProp(t){return{type:I.Text,fontBgColor:t}}}class Qf extends Hn{richStyle(t){return{bold:t}}textProp(t){return{type:I.Text,bold:t}}}class Zf extends Hn{richStyle(t){return{italic:t}}textProp(t){let e=t;return typeof t=="string"&&(e=t.trim().toLowerCase()==="true"),{type:I.Text,italic:e}}}class qf extends Hn{richStyle(t){return{underline:t}}textProp(t){return{type:I.Text,underline:t}}}class Jf extends Hn{richStyle(t){return{strikethrough:t}}textProp(t){return{type:I.Text,strikethrough:t}}}class _c{}class ey extends _c{enable(t){return t.type===v.CheckboxText}handle(t,e){return{id:t.id,props:[{type:I.Text,fontSize:e},{type:I.CheckSize,size:e}]}}}class ty extends _c{enable(t){return!0}handle(t,e){return{id:t.id,props:[{type:I.Text,fontSize:e}]}}}v.Line,v.Shape,v.CheckboxText;class ny extends Hn{constructor(){super(...arguments);p(this,"editTextWorker",new mo);p(this,"fontSizeHandlers",[new ey,new ty])}richStyle(e){return{"font-size":e}}textProp(e){return{type:I.Text,fontSize:e}}changeFontPropBySelection(e,n,o,s){const{renderText:r,node:i}=n,{start:a,end:c}=o,h=this.inputWorker.applyStyleToSelection(r,a,c,this.richStyle(e));s.execAction(new W),s.execAction(ee.selection(i.id,a,c)),s.execAction(U.create(i.id,[{type:I.Text,richText:h}])),r&&(r.textProps.sizeMode===We.autoWidth||r.textProps.sizeMode===We.autoHeight)&&this.editTextWorker.modifyBaseProps(i.renderText,i,s),s.execAction(ee.selection(i.id,a,c)),s.execAction(new z)}changeFontPropForWhole(e,n){const s=[...n.getSelectNodes()].filter(a=>a.getProp(I.Text)!==null),r=[],i=new Set;for(const a of s){const c=a.renderText;c&&(c.textProps.sizeMode===We.autoWidth||c.textProps.sizeMode===We.autoHeight)&&i.add(a);for(const h of this.fontSizeHandlers)if(h.enable(a)){r.push(h.handle(a,e));break}}if(r.length!==0){n.execAction(new W),n.execAction(new U({infos:r}));for(const a of i)this.editTextWorker.modifyBaseProps(a.renderText,a,n);n.execAction(new z)}}}class oy{constructor(t){p(this,"app");p(this,"textUnOrderWorker",new Uf);p(this,"textOrderWorker",new _f);p(this,"textQuoteWorker",new $f);p(this,"textNormalWorker",new jf);p(this,"textFontColorWorker",new Vf);p(this,"textFontBgColorWorker",new Kf);p(this,"textFontBoldWorker",new Qf);p(this,"textFontItalicWorker",new Zf);p(this,"textUnderLineWorker",new qf);p(this,"textFontStrikethroughWorker",new Jf);p(this,"textFontSizeWorker",new ny);this.app=t}addUnOrderList(){const t=this.app.appContext,e=t.inputManager.editTextInfo;if(e===null)return this.textUnOrderWorker.batchNodesToUnOrderByNotEditing(t);const{node:n}=e,o=t.inputManager.selectionManager.selectionInfo;if(o===null){this.textUnOrderWorker.toUnOrderByEditing(n,e,t);return}this.textUnOrderWorker.toUnOrderBySelection(n,o,t)}addOrderList(){const t=this.app.appContext,e=t.inputManager.editTextInfo;if(e===null)return this.textOrderWorker.batchNodesToOrderByNotEditing(t);const{node:n}=e,o=t.inputManager.selectionManager.selectionInfo;if(o===null){this.textOrderWorker.toOrderByEditing(n,e,t);return}this.textOrderWorker.toOrderBySelection(n,o,t)}addQuote(){const t=this.app.appContext,e=t.inputManager.editTextInfo;if(e===null)return this.textQuoteWorker.batchNodesToQuoteByNotEditing(t);const{node:n}=e,o=t.inputManager.selectionManager.selectionInfo;if(o===null){this.textQuoteWorker.toQuoteByEditing(n,e,t);return}this.textQuoteWorker.toQuoteBySelection(n,o,t)}toNormal(){const t=this.app.appContext,e=t.inputManager.editTextInfo;if(e===null)return this.textNormalWorker.batchNodesToNormalByNotEditing(t);const{node:n}=e,o=t.inputManager.selectionManager.selectionInfo;if(o===null){this.textNormalWorker.toNormalByEditing(n,e,t);return}this.textNormalWorker.toNormalBySelection(n,o,t)}changeTextColor(t){const e=this.app.appContext;this.textFontColorWorker.changeFontProp(t,e)}changeTextBgColor(t){const e=this.app.appContext;this.textFontBgColorWorker.changeFontProp(t,e)}changeTextBold(t){const e=this.app.appContext;this.textFontBoldWorker.changeFontProp(t,e)}changeTextItalic(t){const e=this.app.appContext;this.textFontItalicWorker.changeFontProp(t,e)}changeTextUnderLine(t){const e=this.app.appContext;this.textUnderLineWorker.changeFontProp(t,e)}changeTextStrikethrough(t){const e=this.app.appContext;this.textFontStrikethroughWorker.changeFontProp(t,e)}changeTextFontSize(t){const e=this.app.appContext;this.textFontSizeWorker.changeFontProp(t,e)}}class $c{getTotalCount(t){return t.reduce((e,n)=>e+n.ids.length,0)}playToNext(t){if(t.docMode!==he.SLIDE_PLAY||!t.slideStatus.slideContainer)return null;const e=t.slideStatus.slideContainer.slideProps.children,n=t.slideStatus.currentIndex+1,o=this.getTotalCount(e);return n<o?(t.slideStatus.currentIndex=n,t.slideStatus.slideContainer.getChildIdByIndex(n)):null}playToPrev(t){if(t.docMode!==he.SLIDE_PLAY||!t.slideStatus.slideContainer)return null;const e=t.slideStatus.currentIndex-1;return e>=0?(t.slideStatus.currentIndex=e,t.slideStatus.slideContainer.getChildIdByIndex(e)):null}}class sy{constructor(t){p(this,"app");p(this,"slidePlayWorker");p(this,"duplicateWorker",new Zs);this.app=t,this.slidePlayWorker=new $c}createEmptySlideContainer(){const t=this.app.appContext,e=M.getViewportBoundCenter(t),n=800,o=600,s=t.idGenerator.genId(v.SlideContainer),r=[ie.create({x:e.x-n/2,y:e.y-o/2,width:n,height:o}),Mt.create({children:[]})],i={id:s,type:v.SlideContainer,zIndex:ve.genZIndex(this.app.nodeManager.root),parentId:"",props:r};t.execAction(new W),t.execAction(Le.create(i)),t.execAction(xe.create([s])),t.execAction(new z)}refocusSlide(t=0){const e=this.app.appContext;e.slideManager.refocusSlide(e,t)}enterEditing(){const t=this.app.appContext;t.slideManager.enterEditing(t)}exitEditing(){const t=this.app.appContext;t.slideManager.exitEditing(t)}jumpToWhenEditing(t){const e=this.app.appContext;e.slideManager.jumpToWhenEditing(t,e)}enterPlayFromEdit(){const t=this.app.appContext;t.slideManager.enterPlayBySlideContainer(t,t.docState.slideStatus.slideContainer)}enterPlay(){const t=this.app.appContext;t.slideManager.enterPlay(t)}playToNext(){const t=this.app.appContext;t.slideManager.playToNext(t)}playToPrev(){const t=this.app.appContext;t.slideManager.playToPrev(t)}exitPlay(){const t=this.app.appContext;t.slideManager.exitPlay(t)}unGroupSlideContainerBySelective(){const t=this.app.appContext;t.slideManager.unGroupSlideContainerBySelective(t)}unGroupSlideContainer(t){const e=this.app.appContext;e.slideManager.unGroupSlideContainer(t,e)}async insertSlideByEditingMode(t){const e=this.app.appContext;if(e.docState.docMode!==he.SLIDE_EDIT)return;const o=e.docState.slideStatus.slideContainer;o&&(e.execAction(new W),t===0?e.slideManager.insertSlide(o,0,!1,e):e.slideManager.insertSlide(o,t-1,!0,e),e.execAction(xe.create([])),e.slideManager.jumpToWhenEditing(t,e),e.execAction(new z))}deleteSlideByEditingMode(t){const e=this.app.appContext;if(e.docState.docMode!==he.SLIDE_EDIT)return;const n=e.docState.slideStatus.slideContainer;if(!n)return;const o=n.getChildIdByIndex(t);if(!o)return;new So().deleteByIds(this.app.appContext,[o]);const r=n.getTotalCount();t===r-1?e.slideManager.jumpToWhenEditing(t-1,e):e.slideManager.jumpToWhenEditing(t+1,e)}duplicateSlideByEditingMode(t){const e=this.app.appContext;if(e.docState.docMode!==he.SLIDE_EDIT)return;const n=e.docState.slideStatus.slideContainer;if(!n)return;const o=n.getChildIdByIndex(t);o&&(this.duplicateWorker.duplicateByIds([o],e),e.slideManager.jumpToWhenEditing(t+1,e))}}class jc{constructor(t){p(this,"app");p(this,"create");p(this,"image");p(this,"copyPaste");p(this,"crop");p(this,"switch");p(this,"propChangeAPI");p(this,"align");p(this,"text");p(this,"slide");this.app=t,this.create=new Of(t),this.image=new Xf(t),this.copyPaste=new zf(t),this.crop=new Wf(t),this.switch=new Ff(t),this.propChangeAPI=new Yf(t),this.align=new Gf(t),this.text=new oy(t),this.slide=new sy(t)}resizeCanvas(){this.app.appContext.resize()}focus(t,e=0,n=0){this.app.appContext.focus(t,e,n)}resetCursor(){this.app.cursorManager.resetCursor()}zoomScale(t,e){this.app.renderManager.zoomScale(t,e),this.app.appContext.refreshAllSvgNode()}zoomToFit(){this.app.renderManager.zoomToFit(),this.app.appContext.refreshAllSvgNode()}zoomToSelect(){this.app.renderManager.zoomToSelect(),this.app.appContext.refreshAllSvgNode()}zoomTo100(){this.app.renderManager.zoomTo100(),this.app.appContext.refreshAllSvgNode()}exportCoverCanvas(t,e=""){const n=this.app.nodeManager.getNodeBounds(),o=n.maxX-n.minX,s=n.maxY-n.minY,r=1280;let i=n;const a=1.5;if(o>r||s>r){const c=(n.minX+n.maxX)/2,h=(n.minY+n.maxY)/2,d=o>r?r:o,u=d/a;i={id:"cover-export-bounds",minX:c-d/2,minY:h-u/2,maxX:c+d/2,maxY:h+u/2}}return this.app.renderManager.exportOfflineCanvas(i,t,e)}exportOfflineCanvas(t,e,n=""){return this.app.renderManager.exportOfflineCanvas(t,e,n)}exportAllNodesImg(t,e=""){const n=this.app.nodeManager.getNodeBounds();if(this.app.nodeManager.nodeMap.size===0){const o={minX:0,minY:0,maxX:600,maxY:600};return this.app.renderManager.exportOfflineCanvas(o,t,e)}return this.app.renderManager.exportOfflineCanvas(n,t,e)}scroll(t,e){this.app.renderManager.scroll(t,e)}registerCallback(t,e){this.app.slotManager.registerSlotCallback(t,e)}changePermission({canEdit:t}){this.app.docState.userPermission.canEdit=t}getBounds(){const t=this.app.renderManager.gmlRender.getViewPortBounds();return D.rectNode2Rect(t)}getScale(){return this.app.renderManager.getScale()}transformToClientPos(t){return this.app.gmlRender.transformToLocal(t)}getFocusList(){return this.app.auxiliaryManager.selectManager.getSelectNodes()}setPrefix(t){this.app.idGenerator.setPrefix(t)}clearFocus(){if(this.app.auxiliaryManager.selectManager.getSelectNodes().length===0)return;const t=this.app.appContext;if(t.execAction(new W),t.inputManager.editTextInfo){const{node:e}=t.inputManager.editTextInfo;t.execAction(ee.blur(e.id))}t.execAction(xe.create([])),t.execAction(new z)}makeGroup(){const t=[...this.app.appContext.getSelectNodes()];new ls().group(t,this.app.appContext)}makeUnGroup(){const t=[...this.app.appContext.getSelectNodes()];if(t.length!==1)return;const e=t[0];if(e.type!==v.Group)return;const n=e;new ls().unGroup(n,this.app.appContext)}getImageBlobUrl(t){return this.app.resourceManager.getBlobUrl(t)}deleteSelectNodes(){new So().work(this.app.appContext)}deleteByIds(t){new So().deleteByIds(this.app.appContext,t)}}class ry{constructor(t){p(this,"app");p(this,"textHelper",new Pi);this.app=t}getCtx(){return this.app.appContext}computeRichText(t){if(!t)return Ge.dealTextToRichText("");const e=t.trim();if(e.startsWith("<root>")||e.startsWith("<root "))return t;const n=this.textHelper.escapeXmlText(t);return Ge.dealTextToRichText(n)}addNode(t){try{const e=this.getCtx();if(t.x===void 0||t.y===void 0||t.width===void 0||t.height===void 0)return{code:400,msg:"缺少必需参数: x, y, width, height"};const n=e.idGenerator.genId(v.Shape),o=e.nodeManager.root,s=Ge.create({richText:this.computeRichText(t.text??""),fontSize:t.fontSize,fontColor:t.fontColor,bold:t.bold,italic:t.italic,underline:t.underline,strikethrough:t.strikethrough,verticalAlign:t.verticalAlign,horizonAlign:t.horizonAlign}),r=[ie.create({x:t.x,y:t.y,width:t.width,height:t.height,angle:t.angle??0}),tt.create({color:t.color??"#FFFFFF",alpha:t.alpha??1}),Ae.create({color:t.borderColor??"#000000",alpha:1,width:2,dashType:t.dashType??1}),s,new Oe(t.shapeCode??1)],i={id:n,parentId:o.id,type:v.Shape,zIndex:t.zIndex??ve.genZIndex(o),props:r};return e.execAction(new W),e.execAction(new Le({nodes:[i]})),e.execAction(new z),{code:200,id:n}}catch(e){return console.error("[AINodeAPI] addNode 失败:",e),{code:500,msg:`添加节点失败: ${e instanceof Error?e.message:String(e)}`}}}deleteNode(t){try{const e=this.getCtx();if(!t.ids||!Array.isArray(t.ids)||t.ids.length===0)return{code:400,msg:"缺少必需参数: ids (非空数组)"};const n=[],o=[];for(const s of t.ids)e.nodeManager.nodeMap.has(s)?n.push(s):o.push(s);return n.length===0?{code:404,msg:`所有节点都不存在: ${o.join(", ")}`}:(e.execAction(new W),e.execAction(At.create(n)),e.execAction(new z),o.length>0?{code:200,msg:`部分节点删除成功,以下节点不存在: ${o.join(", ")}`}:{code:200})}catch(e){return console.error("[AINodeAPI] deleteNode 失败:",e),{code:500,msg:`删除节点失败: ${e instanceof Error?e.message:String(e)}`}}}updateNode(t){try{const e=this.getCtx();if(!t.id)return{code:400,msg:"缺少必需参数: id"};if(!e.nodeManager.nodeMap.has(t.id))return{code:404,msg:`节点不存在: ${t.id}`};const n=[],o={};t.x!==void 0&&(o.x=t.x),t.y!==void 0&&(o.y=t.y),t.width!==void 0&&(o.width=t.width),t.height!==void 0&&(o.height=t.height),t.angle!==void 0&&(o.angle=t.angle),Object.keys(o).length>0&&(o.type=I.Base,n.push(o)),t.zIndex!==void 0&&(o.type=I.Base);const s={};t.color!==void 0&&(s.color=t.color),t.alpha!==void 0&&(s.alpha=t.alpha),Object.keys(s).length>0&&(s.type=I.Color,n.push(s));const r={};if(t.borderColor!==void 0&&(r.color=t.borderColor),t.borderWidth!==void 0&&(r.width=t.borderWidth),t.borderAlpha!==void 0&&(r.alpha=t.borderAlpha),t.dashType!==void 0&&(r.dashType=t.dashType),Object.keys(r).length>0&&(r.type=I.Border,n.push(r)),(t.text!==void 0||t.fontSize!==void 0||t.fontColor!==void 0)&&n.push({type:I.Text,richText:t.text!==void 0?this.computeRichText(t.text??""):void 0,fontSize:t.fontSize,fontColor:t.fontColor}),t.shapeCode!==void 0&&n.push(new Oe(t.shapeCode)),n.length===0)return{code:400,msg:"没有提供任何更新属性"};if(e.execAction(new W),t.zIndex!==void 0){const i=e.nodeManager.getNode(t.id);i&&(i.zIndex=t.zIndex)}return e.execAction(U.create(t.id,n)),e.execAction(new z),{code:200}}catch(e){return console.error("[AINodeAPI] updateNode 失败:",e),{code:500,msg:`更新节点失败: ${e instanceof Error?e.message:String(e)}`}}}batchUpdateNode(t){try{const e=this.getCtx();if(!t.nodes||!Array.isArray(t.nodes))return{code:400,msg:"缺少必需参数: nodes (数组)"};if(t.nodes.length===0)return{code:400,msg:"nodes 数组不能为空"};const n=[];let o=0;e.execAction(new W);for(let s=0;s<t.nodes.length;s++){const r=t.nodes[s];try{if(!r.id){n.push({index:s,id:r.id,error:"缺少必需参数: id"});continue}if(!e.nodeManager.nodeMap.has(r.id)){n.push({index:s,id:r.id,error:`节点不存在: ${r.id}`});continue}const i=[],a={};r.x!==void 0&&(a.x=r.x),r.y!==void 0&&(a.y=r.y),r.width!==void 0&&(a.width=r.width),r.height!==void 0&&(a.height=r.height),r.angle!==void 0&&(a.angle=r.angle),Object.keys(a).length>0&&(a.type=I.Base,i.push(a));const c={};r.color!==void 0&&(c.color=r.color),r.alpha!==void 0&&(c.alpha=r.alpha),Object.keys(c).length>0&&(c.type=I.Color,i.push(c));const h={};r.borderColor!==void 0&&(h.color=r.borderColor),r.borderWidth!==void 0&&(h.width=r.borderWidth),r.borderAlpha!==void 0&&(h.alpha=r.borderAlpha),r.dashType!==void 0&&(h.dashType=r.dashType),Object.keys(h).length>0&&(h.type=I.Border,i.push(h));const d={};let u=!1;if(r.text!==void 0&&(d.richText=this.computeRichText(r.text),u=!0),r.fontSize!==void 0&&(d.fontSize=r.fontSize,u=!0),r.fontColor!==void 0&&(d.fontColor=r.fontColor,u=!0),r.bold!==void 0&&(d.bold=r.bold,u=!0),r.italic!==void 0&&(d.italic=r.italic,u=!0),r.underline!==void 0&&(d.underline=r.underline,u=!0),r.strikethrough!==void 0&&(d.strikethrough=r.strikethrough,u=!0),r.verticalAlign!==void 0&&(d.verticalAlign=r.verticalAlign,u=!0),r.horizonAlign!==void 0&&(d.horizonAlign=r.horizonAlign,u=!0),u&&(d.type=I.Text,i.push(d)),r.shapeCode!==void 0&&i.push(new Oe(r.shapeCode)),i.length===0){n.push({index:s,id:r.id,error:"没有提供任何更新属性"});continue}if(r.zIndex!==void 0){const g=e.nodeManager.getNode(r.id);g&&(g.zIndex=r.zIndex)}e.execAction(U.create(r.id,i)),o++}catch(i){n.push({index:s,id:r.id,error:i instanceof Error?i.message:String(i)})}}return e.execAction(new z),n.length===0?{code:200,successCount:o}:o===0?{code:500,msg:"所有节点更新失败",errorCount:n.length,errors:n}:{code:206,successCount:o,errorCount:n.length,errors:n}}catch(e){return console.error("[AINodeAPI] batchUpdateNode 失败:",e),{code:500,msg:`批量更新节点失败: ${e instanceof Error?e.message:String(e)}`}}}selectNode(t){try{const e=this.getCtx();if(t.x===void 0||t.y===void 0||t.width===void 0||t.height===void 0)return{code:400,msg:"缺少必需参数: x, y, width, height"};const n=t.x,o=t.y,s=t.x+t.width,r=t.y+t.height,i=e.nodeManager.searchNodes(n,o,s,r),a=[];for(const c of i){if(c===e.nodeManager.root)continue;const h=c.getBounds(),d=c.getProp(I.Base);let u="";(c.type===v.Shape||c.type===v.Line||c.type===v.CheckboxText)&&(u=c.renderText.toString()),a.push({id:c.id,text:u,x:(d==null?void 0:d.x)??h.minX,y:(d==null?void 0:d.y)??h.minY,width:(d==null?void 0:d.width)??h.maxX-h.minX,height:(d==null?void 0:d.height)??h.maxY-h.minY})}return{code:200,nodes:a,count:a.length}}catch(e){return console.error("[AINodeAPI] selectNode 失败:",e),{code:500,msg:`查询节点失败: ${e instanceof Error?e.message:String(e)}`}}}selectNodeDetail(t){try{const e=this.getCtx();if(!t.ids||!Array.isArray(t.ids)||t.ids.length===0)return{code:400,msg:"缺少必需参数: ids (非空数组)"};if(!t.ids.every(s=>typeof s=="string"))return{code:400,msg:"参数 ids 数组中的所有元素必须是字符串"};const n=[],o=[];for(const s of t.ids){const r=e.nodeManager.nodeMap.get(s);if(!r||r===e.nodeManager.root){o.push(s);continue}const i=r.getBounds(),a=r.getProp(I.Base),c=r.getProp(I.Color),h=r.getProp(I.Border),d=r.getProp(I.Text),u=r.getProp(I.Shape);let g="";(r.type===v.Shape||r.type===v.Line||r.type===v.CheckboxText)&&(g=r.renderText.toString()),n.push({id:r.id,type:r.type,x:(a==null?void 0:a.x)??i.minX,y:(a==null?void 0:a.y)??i.minY,width:(a==null?void 0:a.width)??i.maxX-i.minX,height:(a==null?void 0:a.height)??i.maxY-i.minY,angle:(a==null?void 0:a.angle)??0,zIndex:r.zIndex,color:(c==null?void 0:c.color)??"#FFFFFF",alpha:(c==null?void 0:c.alpha)??1,borderColor:(h==null?void 0:h.color)??"#000000",dashType:(h==null?void 0:h.dashType)??1,text:g,fontSize:d==null?void 0:d.fontSize,fontColor:d==null?void 0:d.fontColor,shapeCode:(u==null?void 0:u.shapeCode)??1})}return o.length>0?{code:200,nodes:n,count:n.length,msg:`部分节点查询成功,以下节点不存在: ${o.join(", ")}`}:{code:200,nodes:n,count:n.length}}catch(e){return console.error("[AINodeAPI] selectNodeDetail 失败:",e),{code:500,msg:`查询节点详细信息失败: ${e instanceof Error?e.message:String(e)}`}}}computeTextNodeSize(t){try{const e=this.getCtx();if(!t.ids||!Array.isArray(t.ids)||t.ids.length===0)return{code:400,msg:"缺少必需参数: ids (非空数组)"};if(!t.ids.every(i=>typeof i=="string"))return{code:400,msg:"参数 ids 数组中的所有元素必须是字符串"};const n=[],o=[],s=[];for(const i of t.ids){const a=e.nodeManager.getNode(i);if(!a||a===e.nodeManager.root){o.push(i);continue}if(!(a instanceof vt)){s.push(i);continue}const c=a.drawer.fullTextNodeHeight(a),h=a.renderText.width+2*le;n.push({id:i,width:h,height:c})}const r=[];return o.length>0&&r.push(`以下节点不存在: ${o.join(", ")}`),s.length>0&&r.push(`以下节点不是文字节点: ${s.join(", ")}`),n.length===0?{code:404,msg:r.join("; ")}:{code:200,nodes:n,count:n.length,msg:r.length>0?r.join("; "):void 0}}catch(e){return console.error("[AINodeAPI] computeTextNodeSize 失败:",e),{code:500,msg:`计算文字节点尺寸失败: ${e instanceof Error?e.message:String(e)}`}}}addLine(t){try{const e=this.getCtx();if(!t.points||!Array.isArray(t.points))return{code:400,msg:"缺少必需参数: points"};if(t.points.length<2)return{code:400,msg:"points 数组至少需要2个点(起点和终点)"};for(let u=0;u<t.points.length;u++){const g=t.points[u];if(typeof g.x!="number"||typeof g.y!="number"||isNaN(g.x)||isNaN(g.y))return{code:400,msg:`points[${u}] 必须包含有效的 x 和 y 坐标`}}const n=e.idGenerator.genId(v.Line),o=e.nodeManager.root;let s=t.points[0].x,r=t.points[0].y,i=t.points[0].x,a=t.points[0].y;for(const u of t.points)s=Math.min(s,u.x),r=Math.min(r,u.y),i=Math.max(i,u.x),a=Math.max(a,u.y);const c=[ie.create({x:s,y:r,width:i-s,height:a-r,angle:0}),Ae.create({color:t.borderColor??"#000000",alpha:1,width:t.borderWidth??2,dashType:t.dashType??1}),Ge.create({richText:this.computeRichText(t.text??""),fontSize:t.fontSize??14,fontColor:t.fontColor??"#000000"}),new Oe(t.shapeCode??0),je.create(t.points,!0),new Rt,lt.create({lArrow:t.lArrow??0,rArrow:t.rArrow??0})],h=new Et;h.width=20,h.height=20,h.point={x:t.points[Math.floor(t.points.length/2)].x,y:t.points[Math.floor(t.points.length/2)].y},c.push(h);const d={id:n,parentId:o.id,type:v.Line,zIndex:t.zIndex??ve.genZIndex(o),props:c};return e.execAction(new W),e.execAction(new Le({nodes:[d]})),e.execAction(new z),{code:200,id:n}}catch(e){return console.error("[AINodeAPI] addLine 失败:",e),{code:500,msg:`添加连线失败: ${e instanceof Error?e.message:String(e)}`}}}addSvg(t){try{const e=this.getCtx();if(t.x===void 0||t.y===void 0||t.width===void 0||t.height===void 0)return{code:400,msg:"缺少必需参数: x, y, width, height"};if(!t.svgCode||typeof t.svgCode!="string")return{code:400,msg:"缺少必需参数: svgCode"};if(!t.svgCode.includes('xmlns="http://www.w3.org/2000/svg"')&&!t.svgCode.includes("xmlns='http://www.w3.org/2000/svg'"))return{code:400,msg:'SVG 代码必须包含 xmlns="http://www.w3.org/2000/svg" 属性'};const n=e.idGenerator.genId(v.SVG),o=e.nodeManager.root,s=new Wn;s.url="",s.useCode=!0,s.code=t.svgCode;const r=[ie.create({x:t.x,y:t.y,width:t.width,height:t.height,angle:t.angle??0}),Ae.create({color:t.borderColor??"",alpha:1,width:t.borderWidth??2,dashType:t.dashType??0}),s],i={id:n,parentId:o.id,type:v.SVG,zIndex:ve.genZIndex(o),props:r};return e.execAction(new W),e.execAction(new Le({nodes:[i]})),e.execAction(new z),{code:200,id:n}}catch(e){return console.error("[AINodeAPI] addSvg 失败:",e),{code:500,msg:`添加SVG节点失败: ${e instanceof Error?e.message:String(e)}`}}}batchAddNodes(t){try{const e=this.getCtx();if(!t.nodes||!Array.isArray(t.nodes))return{code:400,msg:"缺少必需参数: nodes"};if(t.nodes.length===0)return{code:400,msg:"nodes 数组不能为空"};for(let r=0;r<t.nodes.length;r++){const i=t.nodes[r];if(i.x===void 0||i.y===void 0||i.width===void 0||i.height===void 0)return{code:400,msg:`nodes[${r}] 缺少必需参数: x, y, width, height`}}const n=e.nodeManager.root,o=[],s=[];for(const r of t.nodes){const i=e.idGenerator.genId(v.Shape);s.push(i);const a=Ge.create({richText:this.computeRichText(r.text??""),fontSize:r.fontSize,fontColor:r.fontColor,bold:r.bold,italic:r.italic,underline:r.underline,strikethrough:r.strikethrough,verticalAlign:r.verticalAlign,horizonAlign:r.horizonAlign}),c=[ie.create({x:r.x,y:r.y,width:r.width,height:r.height,angle:r.angle??0}),tt.create({color:r.color??"#FFFFFF",alpha:r.alpha??1}),Ae.create({color:r.borderColor??"#000000",alpha:1,width:2,dashType:r.dashType??1}),a,new Oe(r.shapeCode??1)],h={id:i,parentId:n.id,type:v.Shape,zIndex:r.zIndex??ve.genZIndex(n),props:c};o.push(h)}return e.execAction(new W),e.execAction(new Le({nodes:o})),e.execAction(new z),{code:200,ids:s,count:s.length}}catch(e){return console.error("[AINodeAPI] batchAddNodes 失败:",e),{code:500,msg:`批量添加节点失败: ${e instanceof Error?e.message:String(e)}`}}}batchAddLines(t){try{const e=this.getCtx();if(!t.lines||!Array.isArray(t.lines))return{code:400,msg:"缺少必需参数: lines"};if(t.lines.length===0)return{code:400,msg:"lines 数组不能为空"};for(let r=0;r<t.lines.length;r++){const i=t.lines[r];if(!i.points||!Array.isArray(i.points))return{code:400,msg:`lines[${r}] 缺少必需参数: points`};if(i.points.length<2)return{code:400,msg:`lines[${r}].points 数组至少需要2个点(起点和终点)`};for(let a=0;a<i.points.length;a++){const c=i.points[a];if(typeof c.x!="number"||typeof c.y!="number"||isNaN(c.x)||isNaN(c.y))return{code:400,msg:`lines[${r}].points[${a}] 必须包含有效的 x 和 y 坐标`}}}const n=e.nodeManager.root,o=[],s=[];for(const r of t.lines){const i=e.idGenerator.genId(v.Line);s.push(i);let a=r.points[0].x,c=r.points[0].y,h=r.points[0].x,d=r.points[0].y;for(const y of r.points)a=Math.min(a,y.x),c=Math.min(c,y.y),h=Math.max(h,y.x),d=Math.max(d,y.y);const u=[ie.create({x:a,y:c,width:h-a,height:d-c,angle:0}),Ae.create({color:r.borderColor??"#000000",alpha:1,width:r.borderWidth??2,dashType:r.dashType??1}),Ge.create({richText:this.computeRichText(r.text??""),fontSize:r.fontSize??14,fontColor:r.fontColor??"#000000"}),new Oe(r.shapeCode??0),je.create(r.points,!0),new Rt,lt.create({lArrow:r.lArrow??0,rArrow:r.rArrow??0})],g=new Et;g.width=20,g.height=20,g.point={x:r.points[Math.floor(r.points.length/2)].x,y:r.points[Math.floor(r.points.length/2)].y},u.push(g);const f={id:i,parentId:n.id,type:v.Line,zIndex:r.zIndex??ve.genZIndex(n),props:u};o.push(f)}return e.execAction(new W),e.execAction(new Le({nodes:o})),e.execAction(new z),{code:200,ids:s,count:s.length}}catch(e){return console.error("[AINodeAPI] batchAddLines 失败:",e),{code:500,msg:`批量添加连线失败: ${e instanceof Error?e.message:String(e)}`}}}connectLine(t){try{const e=this.getCtx();if(!t.startInfo&&!t.startPoint)return{code:400,msg:"必须提供 startInfo 或 startPoint 中的一个"};if(!t.endInfo&&!t.endPoint)return{code:400,msg:"必须提供 endInfo 或 endPoint 中的一个"};let n=null;if(t.startInfo){if(n=e.nodeManager.getNode(t.startInfo.id),!n)return{code:404,msg:`起始节点不存在: ${t.startInfo.id}`};if(![0,1,2,3].includes(t.startInfo.endType))return{code:400,msg:"startInfo.endType 必须是 0, 1, 2 或 3"}}let o=null;if(t.endInfo){if(o=e.nodeManager.getNode(t.endInfo.id),!o)return{code:404,msg:`终止节点不存在: ${t.endInfo.id}`};if(![0,1,2,3].includes(t.endInfo.endType))return{code:400,msg:"endInfo.endType 必须是 0, 1, 2 或 3"}}if(t.startPoint&&(typeof t.startPoint.x!="number"||typeof t.startPoint.y!="number"||isNaN(t.startPoint.x)||isNaN(t.startPoint.y)))return{code:400,msg:"startPoint 必须包含有效的 x 和 y 坐标"};if(t.endPoint&&(typeof t.endPoint.x!="number"||typeof t.endPoint.y!="number"||isNaN(t.endPoint.x)||isNaN(t.endPoint.y)))return{code:400,msg:"endPoint 必须包含有效的 x 和 y 坐标"};const s=(E,X)=>{const $=E.props.get(I.Base);if(!$)throw new Error("节点缺少 BaseProps");const{x:Z,y:se,width:ne,height:ae}=$;switch(X){case 0:return{x:Z+ne/2,y:se};case 1:return{x:Z+ne,y:se+ae/2};case 2:return{x:Z+ne/2,y:se+ae};case 3:return{x:Z,y:se+ae/2};default:return{x:Z+ne/2,y:se+ae/2}}};let r,i;if(t.startInfo&&n){const E=s(n,t.startInfo.endType);r=E.x,i=E.y}else if(t.startPoint)r=t.startPoint.x,i=t.startPoint.y;else return{code:400,msg:"无法计算起点坐标"};let a,c;if(t.endInfo&&o){const E=s(o,t.endInfo.endType);a=E.x,c=E.y}else if(t.endPoint)a=t.endPoint.x,c=t.endPoint.y;else return{code:400,msg:"无法计算终点坐标"};const h=t.shapeCode??0;let d;const u={point:{x:r,y:i}};if(t.startInfo&&n){const E=D.rectNode2Rect(n.getBounds()),X=[ue.Top,ue.Right,ue.Bottom,ue.Left];u.nodeConnect={rect:E,endType:X[t.startInfo.endType]}}const g={point:{x:a,y:c}};if(t.endInfo&&o){const E=D.rectNode2Rect(o.getBounds()),X=[ue.Top,ue.Right,ue.Bottom,ue.Left];g.nodeConnect={rect:E,endType:X[t.endInfo.endType]}}h===0?d=new Xo().layoutToPointsPro(u,g):h===3?d=new po().layoutToPointsPro(u,g):d=new Vt().layoutToPointsPro(u,g);const f=e.idGenerator.genId(v.Line),y=e.nodeManager.root,P=M.getBoundsByPoints(d),w=[{type:I.Base,x:P.minX,y:P.minY,width:P.maxX-P.minX,height:P.maxY-P.minY},Ae.create({color:t.borderColor??"#000000",alpha:1,width:t.borderWidth??2,dashType:t.dashType??1}),Ge.create({richText:this.computeRichText(t.text??""),fontSize:t.fontSize??14,fontColor:t.fontColor??"#000000"}),new Oe(t.shapeCode??0),je.create(d,!0),lt.create({lArrow:t.lArrow??0,rArrow:t.rArrow??0})],L=new Rt;if(t.startInfo&&n){const X=n.drawer.getConnectAnchor()[t.startInfo.endType];L.start={objectId:t.startInfo.id,x:X.x,y:X.y}}else L.start=null;if(t.endInfo&&o){const X=o.drawer.getConnectAnchor()[t.endInfo.endType];L.end={objectId:t.endInfo.id,x:X.x,y:X.y}}else L.end=null;w.push(L);const B=new Et;B.width=20,B.height=20,B.point={x:(r+a)/2,y:(i+c)/2},w.push(B);const H={id:f,parentId:y.id,type:v.Line,zIndex:t.zIndex??ve.genZIndex(y),props:w};return e.execAction(new W),e.execAction(new Le({nodes:[H]})),e.execAction(new z),{code:200,id:f}}catch(e){return console.error("[AINodeAPI] connectLine 失败:",e),console.error("[AINodeAPI] connectLine 失败:",e),{code:500,msg:`创建连接线失败: ${e instanceof Error?e.message:String(e)}`}}}batchConnectLine(t){var e,n,o,s,r,i,a,c,h;try{const d=this.getCtx();if(!t.connections||!Array.isArray(t.connections))return{code:400,msg:"connections 参数必须是一个数组"};if(t.connections.length===0)return{code:400,msg:"connections 数组不能为空"};const u=[];let g=0,f=0;d.execAction(new W);for(let y=0;y<t.connections.length;y++){const P=t.connections[y],b={startInfo:P.startInfo,endInfo:P.endInfo,startPoint:P.startPoint,endPoint:P.endPoint,zIndex:P.zIndex??((e=t.defaultStyle)==null?void 0:e.zIndex),shapeCode:P.shapeCode??((n=t.defaultStyle)==null?void 0:n.shapeCode)??0,borderColor:P.borderColor??((o=t.defaultStyle)==null?void 0:o.borderColor)??"#000000",borderWidth:P.borderWidth??((s=t.defaultStyle)==null?void 0:s.borderWidth)??2,dashType:P.dashType??((r=t.defaultStyle)==null?void 0:r.dashType)??1,lArrow:P.lArrow??((i=t.defaultStyle)==null?void 0:i.lArrow)??0,rArrow:P.rArrow??((a=t.defaultStyle)==null?void 0:a.rArrow)??0,text:P.text??"",fontSize:P.fontSize??((c=t.defaultStyle)==null?void 0:c.fontSize)??14,fontColor:P.fontColor??((h=t.defaultStyle)==null?void 0:h.fontColor)??"#000000",textPosition:P.textPosition??.5};try{if(!b.startInfo&&!b.startPoint)throw new Error(`连接 ${y}: 必须提供 startInfo 或 startPoint 中的一个`);if(!b.endInfo&&!b.endPoint)throw new Error(`连接 ${y}: 必须提供 endInfo 或 endPoint 中的一个`);let w=null;if(b.startInfo){if(w=d.nodeManager.getNode(b.startInfo.id),!w)throw new Error(`连接 ${y}: 起始节点不存在: ${b.startInfo.id}`);if(![0,1,2,3].includes(b.startInfo.endType))throw new Error(`连接 ${y}: startInfo.endType 必须是 0, 1, 2 或 3`)}let L=null;if(b.endInfo){if(L=d.nodeManager.getNode(b.endInfo.id),!L)throw new Error(`连接 ${y}: 终止节点不存在: ${b.endInfo.id}`);if(![0,1,2,3].includes(b.endInfo.endType))throw new Error(`连接 ${y}: endInfo.endType 必须是 0, 1, 2 或 3`)}if(b.startPoint&&(typeof b.startPoint.x!="number"||typeof b.startPoint.y!="number"||isNaN(b.startPoint.x)||isNaN(b.startPoint.y)))throw new Error(`连接 ${y}: startPoint 必须包含有效的 x 和 y 坐标`);if(b.endPoint&&(typeof b.endPoint.x!="number"||typeof b.endPoint.y!="number"||isNaN(b.endPoint.x)||isNaN(b.endPoint.y)))throw new Error(`连接 ${y}: endPoint 必须包含有效的 x 和 y 坐标`);const B=(O,G)=>{const j=O.props.get(I.Base);if(!j)throw new Error("节点缺少 BaseProps");const{x:_,y:Ve,width:ut,height:yt}=j;switch(G){case 0:return{x:_+ut/2,y:Ve};case 1:return{x:_+ut,y:Ve+yt/2};case 2:return{x:_+ut/2,y:Ve+yt};case 3:return{x:_,y:Ve+yt/2};default:return{x:_+ut/2,y:Ve+yt/2}}};let H,E;if(b.startInfo&&w){const O=B(w,b.startInfo.endType);H=O.x,E=O.y}else if(b.startPoint)H=b.startPoint.x,E=b.startPoint.y;else throw new Error(`连接 ${y}: 无法计算起点坐标`);let X,$;if(b.endInfo&&L){const O=B(L,b.endInfo.endType);X=O.x,$=O.y}else if(b.endPoint)X=b.endPoint.x,$=b.endPoint.y;else throw new Error(`连接 ${y}: 无法计算终点坐标`);const Z=b.shapeCode;let se;const ne={point:{x:H,y:E}};if(b.startInfo&&w){const O=D.rectNode2Rect(w.getBounds()),G=[ue.Top,ue.Right,ue.Bottom,ue.Left];ne.nodeConnect={rect:O,endType:G[b.startInfo.endType]}}const ae={point:{x:X,y:$}};if(b.endInfo&&L){const O=D.rectNode2Rect(L.getBounds()),G=[ue.Top,ue.Right,ue.Bottom,ue.Left];ae.nodeConnect={rect:O,endType:G[b.endInfo.endType]}}Z===0?se=new Xo().layoutToPointsPro(ne,ae):Z===3?se=new po().layoutToPointsPro(ne,ae):se=new Vt().layoutToPointsPro(ne,ae);const te=d.idGenerator.genId(v.Line),ce=d.nodeManager.root,pe=M.getBoundsByPoints(se),Re=[{type:I.Base,x:pe.minX,y:pe.minY,width:pe.maxX-pe.minX,height:pe.maxY-pe.minY},Ae.create({color:b.borderColor,alpha:1,width:b.borderWidth,dashType:b.dashType}),Ge.create({richText:this.computeRichText(b.text),fontSize:b.fontSize,fontColor:b.fontColor}),new Oe(b.shapeCode),je.create(se,!0),lt.create({lArrow:b.lArrow,rArrow:b.rArrow})],Me=new Rt;if(b.startInfo&&w){const G=w.drawer.getConnectAnchor()[b.startInfo.endType];Me.start={objectId:b.startInfo.id,x:G.x,y:G.y}}else Me.start=null;if(b.endInfo&&L){const G=L.drawer.getConnectAnchor()[b.endInfo.endType];Me.end={objectId:b.endInfo.id,x:G.x,y:G.y}}else Me.end=null;Re.push(Me);const Te=new Et;Te.width=20,Te.height=20,Te.point={x:(H+X)/2,y:(E+$)/2},Re.push(Te);const ge={id:te,parentId:ce.id,type:v.Line,zIndex:b.zIndex??ve.genZIndex(ce),props:Re};d.execAction(new Le({nodes:[ge]})),u.push({index:y,success:!0,id:te}),g++}catch(w){const L=w instanceof Error?w.message:String(w);console.error(`[AINodeAPI] 批量连接线 - 连接 ${y} 失败:`,w),u.push({index:y,success:!1,error:L}),f++}}return d.execAction(new z),{code:200,successCount:g,failedCount:f,results:u}}catch(d){return console.error("[AINodeAPI] batchConnectLine 失败:",d),{code:500,msg:`批量创建连接线失败: ${d instanceof Error?d.message:String(d)}`}}}}class iy{constructor(t){p(this,"app");this.app=t}getCtx(){return this.app.appContext}getViewportBounds(){try{const e=this.getCtx().gmlRender.getViewPortBounds();return{code:200,bounds:{minX:e.minX,minY:e.minY,maxX:e.maxX,maxY:e.maxY,width:e.maxX-e.minX,height:e.maxY-e.minY}}}catch(t){return console.error("[AIViewportAPI] getViewportBounds 失败:",t),{code:500,msg:`获取视口边界失败: ${t instanceof Error?t.message:String(t)}`}}}zoomToBounds(t,e,n,o){try{const s=this.getCtx();if(t>=n||e>=o)return{code:400,msg:"无效的边界参数:minX 必须小于 maxX,minY 必须小于 maxY"};const r={minX:t,minY:e,maxX:n,maxY:o,id:"temp-zoom-bounds"};return s.renderManager.zoomWorker.zoomToBounds(r,s.renderManager),{code:200}}catch(s){return console.error("[AIViewportAPI] zoomToBounds 失败:",s),{code:500,msg:`缩放到指定边界失败: ${s instanceof Error?s.message:String(s)}`}}}zoomToFit(){try{const t=this.getCtx();return t.renderManager.nodeManager.nodeMap.size===0?{code:400,msg:"画布中没有节点,无法执行适配缩放"}:(t.renderManager.zoomWorker.zoomToFit(t.renderManager),{code:200})}catch(t){return console.error("[AIViewportAPI] zoomToFit 失败:",t),{code:500,msg:`缩放适配所有节点失败: ${t instanceof Error?t.message:String(t)}`}}}zoomToSelect(){try{const t=this.getCtx();return t.renderManager.auxiliaryManager.selectManager.getSelectNodes().length===0?{code:400,msg:"当前没有选中任何节点,无法执行缩放"}:(t.renderManager.zoomWorker.zoomToSelect(t.renderManager),{code:200})}catch(t){return console.error("[AIViewportAPI] zoomToSelect 失败:",t),{code:500,msg:`缩放到选中节点失败: ${t instanceof Error?t.message:String(t)}`}}}}class ay{constructor(t){p(this,"app");this.app=t}getCtx(){return this.app.appContext}getSelectedNodes(){try{const t=this.getCtx(),e=t.getSelectNodes();if(!e||e.size===0)return{code:200,nodes:[],count:0};const n=[];for(const o of e){if(o===t.nodeManager.root)continue;const s=o.getBounds(),r=o.getProp(I.Base);let i="";(o.type===v.Shape||o.type===v.Line||o.type===v.CheckboxText)&&(i=o.renderText.toString()),n.push({id:o.id,text:i,x:(r==null?void 0:r.x)??s.minX,y:(r==null?void 0:r.y)??s.minY,width:(r==null?void 0:r.width)??s.maxX-s.minX,height:(r==null?void 0:r.height)??s.maxY-s.minY})}return{code:200,nodes:n,count:n.length}}catch(t){return console.error("[SelectAPI] getSelectedNodes 失败:",t),{code:500,msg:`获取选中节点信息失败: ${t instanceof Error?t.message:String(t)}`}}}selectAllNodes(){try{const t=this.getCtx(),e=[];for(const[n,o]of t.nodeManager.nodeMap){if(o===t.nodeManager.root)continue;const s=o.getBounds(),r=o.getProp(I.Base);let i="";(o.type===v.Shape||o.type===v.Line||o.type===v.CheckboxText)&&(i=o.renderText.toString()),e.push({id:o.id,text:i,x:(r==null?void 0:r.x)??s.minX,y:(r==null?void 0:r.y)??s.minY,width:(r==null?void 0:r.width)??s.maxX-s.minX,height:(r==null?void 0:r.height)??s.maxY-s.minY})}return{code:200,nodes:e,count:e.length}}catch(t){return console.error("[SelectAPI] selectAllNodes 失败:",t),{code:500,msg:`获取所有节点信息失败: ${t instanceof Error?t.message:String(t)}`}}}}class Vc{constructor(t){p(this,"app");p(this,"node");p(this,"viewport");p(this,"select");this.app=t,this.node=new ry(t),this.viewport=new iy(t),this.select=new ay(t)}}class cy{constructor(t){p(this,"renderDom",null);p(this,"inputDom",null);p(this,"isFocusing",!1);p(this,"cursorManager");this.cursorManager=t}init(t,e){this.inputDom=t,this.renderDom=e}focus(){setTimeout(()=>{this.inputDom.focus(),console.log("njx debug ======>i am focus")},100),this.isFocusing=!0,this.cursorManager.setCursor("text")}blur(){this.isFocusing=!1,this.inputDom.blur(),this.renderDom.style.display="none"}hideRenderDom(){this.renderDom.style.display="none"}updateCursor(t,e,n,o){const s=e.globalTransform.crossPoint(t),r=e.canvas.getBoundingClientRect(),i=window.devicePixelRatio;let a=s.x/i+r.x,c=s.y/i+r.y;a>r.width&&(a=0),c>r.height&&(c=0),this.renderDom.style.left=a+"px",this.renderDom.style.top=c+"px",this.inputDom.style.left=a+"px",this.inputDom.style.top=c+"px",this.renderDom.style.transform=`rotate(${o}deg)`,this.renderDom.style.transformOrigin="top left",this.renderDom.style.display="unset",this.renderDom.style.height=n*e.getScale()+"px"}}class ly{constructor(){p(this,"selectionInfo",null);p(this,"selectionWorker",new xc)}clear(){this.selectionInfo=null}generateSelect(t,e,n){const o=this.selectionWorker.computeTextSelection(t,e,n);return o.length===0?[]:(this.selectionInfo={start:e,end:n,selectionList:o},o)}}class hy{constructor(t,e){p(this,"renderInput");p(this,"editTextInfo",null);p(this,"selectionManager",new ly);p(this,"renderManager");this.renderInput=new cy(e),this.renderManager=t}init(t,e){var n;(n=this.renderInput)==null||n.init(t,e),this.renderInput.hideRenderDom()}isEdit(){return this.editTextInfo!==null}hasSelection(){return this.selectionManager.selectionInfo!==null}checkNeedReFocusInputDom(t){return!this.editTextInfo||this.editTextInfo.node.id!==t.node.id||!this.editTextInfo.textCursorPosition.equal(t.textCursorPosition)}focus(t){this.checkNeedReFocusInputDom(t),this.editTextInfo=t;const{node:e,renderText:n,textCursorPosition:o}=t,{relativePos:s,height:r}=n.getPosByCursorPosition(o),i=e.toGlobal(s);this.renderInput.focus(),console.log("njx debug:===>focus"),this.renderInput.updateCursor(i,this.renderManager.gmlRender,r,e.baseProps.angle),this.selectionManager.clear()}selection(t,e,n,o){let s=n,r=o;o.greaterThan(n)||(s=o,r=n),this.editTextInfo={node:t,renderText:e,textCursorPosition:s};const i=this.selectionManager.generateSelect(e,s,r);return this.renderInput.focus(),this.renderInput.hideRenderDom(),i}refreshCursor(){if(!this.editTextInfo)return;const{node:t,renderText:e,textCursorPosition:n}=this.editTextInfo,{relativePos:o,height:s}=e.getPosByCursorPosition(n),r=t.toGlobal(o);this.renderInput.updateCursor(r,this.renderManager.gmlRender,s,t.baseProps.angle)}updateCursorPos(t){this.editTextInfo&&(this.editTextInfo.textCursorPosition=t,this.refreshCursor())}blur(){var t;console.log("====>blur"),this.selectionManager.selectionInfo&&this.selectionManager.clear(),this.editTextInfo&&(this.editTextInfo.node.resetFromEditing(),this.renderManager.addContentRenderTask(),(t=this.renderInput)==null||t.blur(),this.editTextInfo=null)}}class dy{constructor(t,e){p(this,"docState");p(this,"nodeManager");this.docState=e,this.nodeManager=t}serializeTo(){const t=[],e=this.nodeManager;for(const[o,s]of e.nodeMap)t.push(s.serializeTo());return{documentId:"",nodes:t}}deSerialize(t){return JSON.parse(t)}}class mr{constructor(){p(this,"canEdit",!0)}}class Kc{constructor(){p(this,"seq",0);p(this,"savedSeq",-1);p(this,"backgroundColor","#EEEEEE");p(this,"userid","");p(this,"sessionId","");p(this,"docId","");p(this,"userPermission",new mr);p(this,"docMode",he.BOARD);p(this,"slideStatus",{slideContainer:null,currentIndex:0,slideCoverList:[]})}load(t){this.backgroundColor=t.backgroundColor,this.seq=t.seq,this.savedSeq=t.savedSeq}canEdit(){return this.userPermission.canEdit}changePermission({canEdit:t}){this.userPermission.canEdit=t}resetSlideCovers(){if(this.slideStatus.slideCoverList.length!==0){for(const t of this.slideStatus.slideCoverList)URL.revokeObjectURL(t.blobUrl);this.slideStatus.slideCoverList=[]}}reset(){this.seq=0,this.savedSeq=-1,this.backgroundColor="#EEEEEE",this.userid="",this.sessionId="",this.docId="",this.userPermission=new mr,this.docMode=he.BOARD,this.resetSlideCovers(),this.slideStatus={slideContainer:null,currentIndex:0,slideCoverList:[]}}}function Qc(){return{backgroundColor:"#EEEEEE",seq:0,savedSeq:0}}class Zc{}class Pr{constructor(){p(this,"globalTransform",re.generateMatrix());p(this,"canvas",null);p(this,"glCtx",null);this.globalTransform.a=window.devicePixelRatio,this.globalTransform.d=window.devicePixelRatio}init(t){this.canvas=t;const e=this.canvas.getContext("2d");this.glCtx=e;const{a:n,b:o,c:s,d:r,e:i,f:a}=this.globalTransform;e.transform(n,o,s,r,i,a)}setTransform(t,e,n,o,s,r){this.globalTransform.setTransform(t,e,n,o,s,r),this.glCtx.setTransform(t,e,n,o,s,r)}reset(){if(!this.canvas){console.error("Error! The canvas is null!");return}const t=this.canvas.getContext("2d"),{a:e,b:n,c:o,d:s,e:r,f:i}=this.globalTransform;t.setTransform(e,n,o,s,r,i)}scale(t,e,n){if(!n){this.globalTransform.a*=t,this.globalTransform.d*=e;return}const o=re.generateMatrix().translate(-n.x,-n.y),s=re.generateMatrix().scale(t,t),i=re.generateMatrix().translate(n.x,n.y).crossProduct(s).crossProduct(o);this.globalTransform=this.globalTransform.crossProduct(i)}translation(t,e){const n=re.generateMatrix().translate(t,e);this.globalTransform=this.globalTransform.crossProduct(n)}resetTransform(){this.globalTransform=re.generateMatrix(),this.globalTransform.a=window.devicePixelRatio,this.globalTransform.d=window.devicePixelRatio}transformToLocal(t){const{a:e,b:n,c:o,d:s,e:r,f:i}=this.globalTransform;return t.x=e*t.x+o*t.y+r,t.y=n*t.x+s*t.y+i,t.x=t.x/window.devicePixelRatio,t.y=t.y/window.devicePixelRatio,t}transformToGlobal(t){const e=new m(t.x,t.y);e.x=e.x*window.devicePixelRatio,e.y=e.y*window.devicePixelRatio;const{a:n,d:o,e:s,f:r}=this.globalTransform;return e.x=e.x/n-s/n,e.y=e.y/o-r/o,e}dirtyDraw(t,e){const n=this.canvas.getContext("2d");n.clearRect(t.minX,t.minY,t.maxX-t.minX,t.maxY-t.minY),n.save(),n.beginPath(),n.rect(t.minX,t.minY,t.maxX-t.minX,t.maxY-t.minY),n.clip();for(const o of e)o.draw();n.restore()}getViewPortBounds(){const t=this.canvas.getBoundingClientRect(),e=new m(t.width,t.height),n=this.transformToGlobal(new m(0,0)),o=this.transformToGlobal(e);return{id:"rect",minX:n.x,minY:n.y,maxX:o.x,maxY:o.y}}getGlobalPoint(t){const e=this.canvas.getBoundingClientRect(),n=new m(t.clientX-e.x,t.clientY-e.y);return this.transformToGlobal(n)}getScale(){const t=window.devicePixelRatio;return this.globalTransform.a/t}scaleToCenter(t){const e=this.getScale(),n=t/e,o=this.getViewPortBounds(),s=new m(.5*(o.minX+o.maxX),.5*(o.minY+o.maxY));this.scale(n,n,s)}}function uy(l,t,e,n,o){qc(l,t,e||0,n||l.length-1,o||py)}function qc(l,t,e,n,o){for(;n>e;){if(n-e>600){var s=n-e+1,r=t-e+1,i=Math.log(s),a=.5*Math.exp(2*i/3),c=.5*Math.sqrt(i*a*(s-a)/s)*(r-s/2<0?-1:1),h=Math.max(e,Math.floor(t-r*a/s+c)),d=Math.min(n,Math.floor(t+(s-r)*a/s+c));qc(l,t,h,d,o)}var u=l[t],g=e,f=n;for(vo(l,e,t),o(l[n],u)>0&&vo(l,e,n);g<f;){for(vo(l,g,f),g++,f--;o(l[g],u)<0;)g++;for(;o(l[f],u)>0;)f--}o(l[e],u)===0?vo(l,e,f):(f++,vo(l,f,n)),f<=t&&(e=f+1),t<=f&&(n=f-1)}}function vo(l,t,e){var n=l[t];l[t]=l[e],l[e]=n}function py(l,t){return l<t?-1:l>t?1:0}class gy{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(t){let e=this.data;const n=[];if(!ds(t,e))return n;const o=this.toBBox,s=[];for(;e;){for(let r=0;r<e.children.length;r++){const i=e.children[r],a=e.leaf?o(i):i;ds(t,a)&&(e.leaf?n.push(i):Mr(t,a)?this._all(i,n):s.push(i))}e=s.pop()}return n}collides(t){let e=this.data;if(!ds(t,e))return!1;const n=[];for(;e;){for(let o=0;o<e.children.length;o++){const s=e.children[o],r=e.leaf?this.toBBox(s):s;if(ds(t,r)){if(e.leaf||Mr(t,r))return!0;n.push(s)}}e=n.pop()}return!1}load(t){if(!(t&&t.length))return this;if(t.length<this._minEntries){for(let n=0;n<t.length;n++)this.insert(t[n]);return this}let e=this._build(t.slice(),0,t.length-1,0);if(!this.data.children.length)this.data=e;else if(this.data.height===e.height)this._splitRoot(this.data,e);else{if(this.data.height<e.height){const n=this.data;this.data=e,e=n}this._insert(e,this.data.height-e.height-1,!0)}return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=Zn([]),this}remove(t,e){if(!t)return this;let n=this.data;const o=this.toBBox(t),s=[],r=[];let i,a,c;for(;n||s.length;){if(n||(n=s.pop(),a=s[s.length-1],i=r.pop(),c=!0),n.leaf){const h=fy(t,n.children,e);if(h!==-1)return n.children.splice(h,1),s.push(n),this._condense(s),this}!c&&!n.leaf&&Mr(n,o)?(s.push(n),r.push(i),i=0,a=n,n=n.children[0]):a?(i++,n=a.children[i],c=!1):n=null}return this}toBBox(t){return t}compareMinX(t,e){return t.minX-e.minX}compareMinY(t,e){return t.minY-e.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,e){const n=[];for(;t;)t.leaf?e.push(...t.children):n.push(...t.children),t=n.pop();return e}_build(t,e,n,o){const s=n-e+1;let r=this._maxEntries,i;if(s<=r)return i=Zn(t.slice(e,n+1)),Qn(i,this.toBBox),i;o||(o=Math.ceil(Math.log(s)/Math.log(r)),r=Math.ceil(s/Math.pow(r,o-1))),i=Zn([]),i.leaf=!1,i.height=o;const a=Math.ceil(s/r),c=a*Math.ceil(Math.sqrt(r));Jc(t,e,n,c,this.compareMinX);for(let h=e;h<=n;h+=c){const d=Math.min(h+c-1,n);Jc(t,h,d,a,this.compareMinY);for(let u=h;u<=d;u+=a){const g=Math.min(u+a-1,d);i.children.push(this._build(t,u,g,o-1))}}return Qn(i,this.toBBox),i}_chooseSubtree(t,e,n,o){for(;o.push(e),!(e.leaf||o.length-1===n);){let s=1/0,r=1/0,i;for(let a=0;a<e.children.length;a++){const c=e.children[a],h=br(c),d=wy(t,c)-h;d<r?(r=d,s=h<s?h:s,i=c):d===r&&h<s&&(s=h,i=c)}e=i||e.children[0]}return e}_insert(t,e,n){const o=n?t:this.toBBox(t),s=[],r=this._chooseSubtree(o,this.data,e,s);for(r.children.push(t),To(r,o);e>=0&&s[e].children.length>this._maxEntries;)this._split(s,e),e--;this._adjustParentBBoxes(o,s,e)}_split(t,e){const n=t[e],o=n.children.length,s=this._minEntries;this._chooseSplitAxis(n,s,o);const r=this._chooseSplitIndex(n,s,o),i=Zn(n.children.splice(r,n.children.length-r));i.height=n.height,i.leaf=n.leaf,Qn(n,this.toBBox),Qn(i,this.toBBox),e?t[e-1].children.push(i):this._splitRoot(n,i)}_splitRoot(t,e){this.data=Zn([t,e]),this.data.height=t.height+1,this.data.leaf=!1,Qn(this.data,this.toBBox)}_chooseSplitIndex(t,e,n){let o,s=1/0,r=1/0;for(let i=e;i<=n-e;i++){const a=Io(t,0,i,this.toBBox),c=Io(t,i,n,this.toBBox),h=my(a,c),d=br(a)+br(c);h<s?(s=h,o=i,r=d<r?d:r):h===s&&d<r&&(r=d,o=i)}return o||n-e}_chooseSplitAxis(t,e,n){const o=t.leaf?this.compareMinX:yy,s=t.leaf?this.compareMinY:xy,r=this._allDistMargin(t,e,n,o),i=this._allDistMargin(t,e,n,s);r<i&&t.children.sort(o)}_allDistMargin(t,e,n,o){t.children.sort(o);const s=this.toBBox,r=Io(t,0,e,s),i=Io(t,n-e,n,s);let a=hs(r)+hs(i);for(let c=e;c<n-e;c++){const h=t.children[c];To(r,t.leaf?s(h):h),a+=hs(r)}for(let c=n-e-1;c>=e;c--){const h=t.children[c];To(i,t.leaf?s(h):h),a+=hs(i)}return a}_adjustParentBBoxes(t,e,n){for(let o=n;o>=0;o--)To(e[o],t)}_condense(t){for(let e=t.length-1,n;e>=0;e--)t[e].children.length===0?e>0?(n=t[e-1].children,n.splice(n.indexOf(t[e]),1)):this.clear():Qn(t[e],this.toBBox)}}function fy(l,t,e){if(!e)return t.indexOf(l);for(let n=0;n<t.length;n++)if(e(l,t[n]))return n;return-1}function Qn(l,t){Io(l,0,l.children.length,t,l)}function Io(l,t,e,n,o){o||(o=Zn(null)),o.minX=1/0,o.minY=1/0,o.maxX=-1/0,o.maxY=-1/0;for(let s=t;s<e;s++){const r=l.children[s];To(o,l.leaf?n(r):r)}return o}function To(l,t){return l.minX=Math.min(l.minX,t.minX),l.minY=Math.min(l.minY,t.minY),l.maxX=Math.max(l.maxX,t.maxX),l.maxY=Math.max(l.maxY,t.maxY),l}function yy(l,t){return l.minX-t.minX}function xy(l,t){return l.minY-t.minY}function br(l){return(l.maxX-l.minX)*(l.maxY-l.minY)}function hs(l){return l.maxX-l.minX+(l.maxY-l.minY)}function wy(l,t){return(Math.max(t.maxX,l.maxX)-Math.min(t.minX,l.minX))*(Math.max(t.maxY,l.maxY)-Math.min(t.minY,l.minY))}function my(l,t){const e=Math.max(l.minX,t.minX),n=Math.max(l.minY,t.minY),o=Math.min(l.maxX,t.maxX),s=Math.min(l.maxY,t.maxY);return Math.max(0,o-e)*Math.max(0,s-n)}function Mr(l,t){return l.minX<=t.minX&&l.minY<=t.minY&&t.maxX<=l.maxX&&t.maxY<=l.maxY}function ds(l,t){return t.minX<=l.maxX&&t.minY<=l.maxY&&t.maxX>=l.minX&&t.maxY>=l.minY}function Zn(l){return{children:l,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Jc(l,t,e,n,o){const s=[t,e];for(;s.length;){if(e=s.pop(),t=s.pop(),e-t<=n)continue;const r=t+Math.ceil((e-t)/n/2)*n;uy(l,r,t,e,o),s.push(t,r,r,e)}}class el extends Zc{constructor(){super();p(this,"root");p(this,"previewRoot");p(this,"nodeMap");p(this,"tree");p(this,"linkMap");this.nodeMap=new Map,this.tree=new gy,this.root=new pr(Mn),this.previewRoot=new pr(zr),this.linkMap=new Map}clear(){this.tree.clear(),this.nodeMap.clear()}reset(){this.clear(),this.linkMap.clear()}searchNodesByRectNode(e){const{minY:n,minX:o,maxY:s,maxX:r}=e;return this.searchNodes(o,n,r,s)}searchNodes(e,n,o=e,s=n){const r={id:"pointer",minX:e,minY:n,maxX:o,maxY:s},i=this.tree.search(r),a=[];for(const c of i){const h=this.nodeMap.get(c.id);h&&a.push(h)}return a}getParentNode(e){const n=this.nodeMap.get(e);return n||this.root}getNode(e){if(e===Mn||e==="")return this.root;const n=this.nodeMap.get(e);return n||null}addNode(e){this.nodeMap.set(e.id,e),this.addIndexNode(e.getRectNode())}removeNode(e){const n=this.getNode(e);if(!n){console.warn("警告:删除节点不存在:",e);return}this.nodeMap.delete(e),this.removeIndexNode(n.getRectNode()),n.type===v.Line&&this.linkMap.delete(n),this.deleteNodeFromParent(n)}deleteNodeFromParent(e){var o;const n=(o=e.parent)==null?void 0:o.id;if(n)if(n===this.root.id)this.root.children.delete(e);else{const s=this.nodeMap.get(n);s&&s.children.delete(e)}}removeIndexNode(e){this.tree.remove(e,(n,o)=>n.id===o.id)}addIndexNode(e){this.tree.insert(e)}getNodeBounds(){const e=[];for(const[n,o]of this.nodeMap)e.push(o.getRectNode());return M.getBounds(e,"all-node-bounds")}addLink(e,n,o=!0){const s=this.linkMap.get(e);if(s){o?s.startNode=n:s.endNode=n,this.checkLinkLine(e);return}const r={startNode:null,endNode:null};o?r.startNode=n:r.endNode=n,this.linkMap.set(e,r),this.checkLinkLine(e)}checkLinkLine(e){const n=this.linkMap.get(e);n&&n.endNode===null&&n.startNode===null&&this.linkMap.delete(e)}getNodeLinks(e){const n=new Set;if(e.type===v.Line)return n;for(const[o,s]of this.linkMap){if(!o.getProp(I.Connect))continue;const{startNode:i,endNode:a}=s;i===e&&n.add(o),a===e&&n.add(o)}return n}}const Jn=class Jn{constructor(){p(this,"previewGraphics",[]);p(this,"createWorker",new Za);p(this,"layoutHandler",new Vt);p(this,"inQuickPreview",!1)}enterQuickPreview(t,e,n){if(this.inQuickPreview){this.previewGraphics.length>0&&n.addOrUpdate(N.PreviewGraphics,{previewNodes:this.previewGraphics});return}this.inQuickPreview=!0,this.resetPreviewNode(n);const o=this.createWorker.judgeQuickCreateMode(t,e,n);if(o){this.computeDrawLine(o,t,e,n);return}this.computeDrawLineAndNode(t,e,n)}computeDrawLine(t,e,n,o){const s=e.baseProps,r=e.toGlobal({x:n.x*s.width,y:n.y*s.height}),i=this.createWorker.computeEndNodeRelative(e,n),a=t.baseProps,c=t.toGlobal({x:i.x*a.width,y:i.y*a.height}),h={point:r,nodeConnect:{rect:D.rectNode2Rect(e.getBounds()),endType:M.computeNodeConnectEnd(n,e.baseProps.angle)}},d={point:c,nodeConnect:{rect:D.rectNode2Rect(t.getBounds()),endType:M.computeNodeConnectEnd(i,t.baseProps.angle)}},u=this.makeupLineProps(h,d),g=It.getInstance().create(Jn.PREVIEW_LINE_ID,v.Line,0,u,o.nodeManager.previewRoot,o.gmlRender.glCtx);this.previewGraphics.push(g)}computeDrawLineAndNode(t,e,n){const o=this.createWorker.computePreviewNodePos(t,e,n),s=this.makeupNodeProps(t,o),r=It.getInstance().create(Jn.PREVIEW_ID,v.Shape,0,s,n.nodeManager.previewRoot,n.gmlRender.glCtx);this.previewGraphics.push(r),this.computeDrawLine(r,t,e,n),n.addOrUpdate(N.PreviewGraphics,{previewNodes:this.previewGraphics})}exitQuickPreview(t){this.resetPreviewNode(t),this.inQuickPreview=!1}resetPreviewNode(t){this.previewGraphics=[],t.nodeManager.previewRoot.children.clear()}makeupNodeProps(t,e){const n=t.baseProps,o=t.shapeType,s=e.x,r=e.y,i=t.colorProps,a=t.borderProps,c=[{type:I.Base,x:s,y:r,width:n.width,height:n.height,angle:n.angle},tt.create({...i,alpha:.5}),Ae.create({...a,alpha:.5}),new Oe(o)];if(t.type===v.Shape&&t.shapeType===K.PureText){const h=t.textProps;c.push(h.clone());const d=t.paragraphProps;c.push(d.clone())}return c}makeupLineProps(t,e){const n=this.layoutHandler.layoutToPointsPro(t,e),o=D.rectNode2Rect(M.getBoundsByPoints(n));return[je.create(n),ie.create({x:o.x,y:o.y,width:o.width,height:o.height}),lt.create({rArrow:it.Arrow}),new Oe(de.RoundPolyLine),Ae.create({alpha:.5})]}};p(Jn,"PREVIEW_ID","quick_preview"),p(Jn,"PREVIEW_LINE_ID","quick_preview_line");let us=Jn;class Dn{computePreviewPos(t,e,n){var a;t.toolManager.shapeType;const o=t.toolManager.grab,s=((a=t.lastInteractiveEvent)==null?void 0:a.globalPoint)||new m,r=o?s.x-.5*e:s.x,i=o?s.y-.5*n:s.y;return new m(r,i)}}class Py extends Dn{enable(t){return t===ye.SHAPE}async handle(t,e){const n=e.toolManager.shapeType,o=this.computePreviewPos(e,100,100),s=e.createWorker.makeupPreviewProps(v.Shape,e,n,o);return It.getInstance().create(t,v.Shape,0,s,e.nodeManager.previewRoot,e.gmlRender.glCtx)}}class by extends Dn{enable(t){return t===ye.SECTION}async handle(t,e){const n=e.toolManager.shapeType,o=Uo[n],s=this.computePreviewPos(e,o.width,o.height),r=e.createWorker.makeupPreviewProps(v.Section,e,n,s);return It.getInstance().create(t,v.Section,0,r,e.nodeManager.previewRoot,e.gmlRender.glCtx)}}class tl{async work(t,e,n,o){const s=n.getScale();try{const r=t.baseProps,i=s*r.width,a=s*r.height;let c;const h=o.getSVGBlobUrl(e,i,a);if(h)c=h.imageBitmap;else{const d=new Blob([e],{type:"image/svg+xml"}),u=URL.createObjectURL(d),g=new Image;g.width=2*i,g.height=2*a,await new Promise((b,w)=>{g.onload=b,g.onerror=w,g.src=u});const f=new OffscreenCanvas(2*i,2*a);f.getContext("2d").drawImage(g,0,0,2*i,2*a);const P=f.transferToImageBitmap();c=P,o.setSvgInfo(e,{imageBitmap:P},i,a),URL.revokeObjectURL(u)}t.setImageBitmap(c)}catch(r){console.error("加载svg图片出现问题",r),t.setBroken()}n.dirtyDraw(t.getBounds())}}class My extends Dn{constructor(){super(...arguments);p(this,"svgWorker",new cr)}enable(e){return e===ye.Resource}async handle(e,n){const o=new m(0,0),s=n.previewManager.previewResourceManager.previewSvgCode;s===""&&console.error("出现错误,svg code为空");const{addNodeInfo:r}=await this.svgWorker.addSvgNodeBySvgCode(s,o,n),i=It.getInstance().create(us.PREVIEW_ID,v.SVG,0,r.props,n.nodeManager.previewRoot,n.gmlRender.glCtx),a=an.trimSvgCode(s);return i.setSvgCode(a.svgCode),await new tl().work(i,a.svgCode,n.renderManager,n.resourceManager),i}makeupShapeDefaultProps(e,n,o){const s=me.Resource,r=cn[s],i=100,a=100,c=o?n.x-.5*i:n.x,h=o?n.y-.5*a:n.y;return[ie.create({x:c,y:h,width:i,height:a}),Ae.create({color:r,alpha:.5})]}}class Sy extends Dn{enable(t,e){return t===ye.Widget&&e===_n.Checkbox}async handle(t,e){const n=e.toolManager.shapeType,o=this.computePreviewPos(e,16,16),s=e.createWorker.makeupPreviewProps(v.Checkbox,e,n,o);return It.getInstance().create(t,v.Checkbox,0,s,e.nodeManager.previewRoot,e.gmlRender.glCtx)}}class vy extends Dn{enable(t,e){return t===ye.Widget&&e===_n.CheckboxText}async handle(t,e){const n=e.toolManager.shapeType,o=this.computePreviewPos(e,102,32),s=e.createWorker.makeupPreviewProps(v.CheckboxText,e,n,o);return It.getInstance().create(t,v.CheckboxText,0,s,e.nodeManager.previewRoot,e.gmlRender.glCtx)}}class ps{makeupLineDefaultProps(t,e){const s=e.x,r=e.y,i=M.computeShapeCategory(v.Line,t),a=cn[i],c=this.makeupLinePoints(s,r,100,-100),h=D.rectNode2Rect(M.getBoundsByPoints(c));return[ie.create({x:h.x,y:h.y,width:h.width,height:h.height}),new Oe(t),je.create(c),Ae.create({color:a,alpha:.5}),lt.create({rArrow:it.Arrow})]}}class Iy extends ps{makeupLineDefaultProps(t,e){const s=e.x,r=e.y,i=M.computeShapeCategory(v.Line,t),a=cn[i],c=[{x:s,y:r},{x:s+100,y:r+-100}],h=D.rectNode2Rect(M.getBoundsByPoints(c));return[ie.create({x:h.x,y:h.y,width:h.width,height:h.height}),new Oe(t),je.create(c),Ae.create({color:a,alpha:.5}),lt.create({rArrow:it.Arrow})]}makeupLinePoints(t,e,n,o){return[{x:t,y:e},{x:t+n,y:e+o}]}}class Ty extends ps{makeupLinePoints(t,e,n,o){return[{x:t,y:e},{x:t+.5*n,y:e},{x:t+.5*n,y:e+o},{x:t+n,y:e+o}]}}class Ly extends ps{makeupLinePoints(t,e,n,o){return[{x:t,y:e},{x:t+.5*n,y:e},{x:t+.5*n,y:e+o},{x:t+n,y:e+o}]}}class Cy extends ps{makeupLinePoints(t,e,n,o){return[{x:t,y:e},{x:t+.5*n,y:e},{x:t+.5*n,y:e+o},{x:t+n,y:e+o}]}}class Ay extends Dn{constructor(){super(...arguments);p(this,"helpers",new Map([[de.Line,new Iy],[de.Curve,new Ty],[de.PolyLine,new Ly],[de.RoundPolyLine,new Cy]]))}enable(e){return e===ye.LINE}async handle(e,n){var a;const o=n.toolManager.shapeType,s=((a=n.lastInteractiveEvent)==null?void 0:a.globalPoint)||new m,r=this.makeupLineDefaultProps(o,s);return It.getInstance().create(e,v.Line,0,r,n.nodeManager.previewRoot,n.gmlRender.glCtx)}makeupLineDefaultProps(e,n){const o=this.helpers.get(e);return o?o.makeupLineDefaultProps(e,n):this.helpers.get(de.Line).makeupLineDefaultProps(e,n)}}class ky extends Dn{enable(t,e){return t===ye.SlideContainer}async handle(t,e){const n=e.toolManager.shapeType,o=this.computePreviewPos(e,200,180),s=e.createWorker.makeupPreviewProps(v.SlideContainer,e,n,o);return It.getInstance().create(t,v.SlideContainer,0,s,e.nodeManager.previewRoot,e.gmlRender.glCtx)}}const Ps=class Ps{constructor(){p(this,"previewGraphics",null);p(this,"handlers",[new Py,new by,new My,new Ay,new Sy,new vy,new ky])}addPreviewNode(t){const e=t.toolManager.currentTool,n=t.toolManager.shapeType;for(const o of this.handlers)if(o.enable(e,n)){o.handle(Ps.PREVIEW_ID,t).then(s=>{this.previewGraphics=s});return}}updatePos(t){if(!this.previewGraphics)return;if(this.previewGraphics.type===v.Line){const n=this.previewGraphics.pos,o={x:t.x-n.x,y:t.y-n.y},s=this.previewGraphics.points;for(const a of s)a.x+=o.x,a.y+=o.y;const r={type:I.Line,points:s},i={type:I.Base,x:t.x,y:t.y};this.previewGraphics.updateProps([i,r]);return}const e={type:I.Base,x:t.x,y:t.y};this.previewGraphics.updateProps([e])}resetPreviewNode(t){this.previewGraphics=null,t.nodeManager.previewRoot.children.clear()}};p(Ps,"PREVIEW_ID","create_preview");let Sr=Ps;class Ny{constructor(){p(this,"previewSvgCode","");p(this,"previewSvgResourceUrl","")}setPreviewSvgCode(t){this.previewSvgCode=t}setPreviewResourceUrl(t){this.previewSvgResourceUrl=t}}class By{constructor(){p(this,"createManager",new Sr);p(this,"quickCreateManager",new us);p(this,"previewResourceManager",new Ny)}addPreviewNode(t){this.createManager.addPreviewNode(t)}updatePos(t){this.createManager.updatePos(t)}resetPreviewNode(t){this.createManager.resetPreviewNode(t)}}class nl{}class ol extends nl{async downloadAsImageBitmap(t){const n=await(await fetch(t)).blob();return{imageBitmap:await createImageBitmap(n),blobUrl:t}}async uploadBlobImg(t,e){return Promise.resolve("")}async downloadSvgCode(t){return Promise.resolve("")}async uploadSvgFile(t,e){return Promise.resolve(void 0)}async deleteMultipleImages(t){return Promise.resolve(void 0)}async uploadSvgString(t,e){return Promise.resolve("")}async copyImage(t,e,n){throw new Error("该方法没有被实现")}}class sl{constructor(){p(this,"resourceMap",new Map);p(this,"nodeResourceMap",new Map);p(this,"svgMap",new Map);p(this,"svgBlobMap",new Map);p(this,"instance",new ol)}reset(){this.resourceMap.clear(),this.nodeResourceMap.clear(),this.svgMap.clear(),this.svgBlobMap.clear()}loadResourceInstance(t){this.instance=t}makeSvgBlobUrlKey(t,e,n){const o=Math.round(e/10),s=Math.round(n/10);return o+"-"+s+"-"+t}setSvgInfo(t,e,n,o){this.svgBlobMap.set(this.makeSvgBlobUrlKey(t,n,o),e)}getSVGBlobUrl(t,e,n){return this.svgBlobMap.get(this.makeSvgBlobUrlKey(t,e,n))}getBlobUrl(t){var e;return((e=this.resourceMap.get(t))==null?void 0:e.blobUrl)||""}getImgUrls(){return[...this.nodeResourceMap.values()].map(t=>t.blobUrl)}addNodeResourceInfo(t,e){this.nodeResourceMap.set(t,e)}async loadImgUrl(t){if(this.resourceMap.has(t))return this.resourceMap.get(t);const e=await this.instance.downloadAsImageBitmap(t);return this.resourceMap.set(t,e),e}async uploadFileBlob(t,e){return await this.instance.uploadBlobImg(t,e)}async loadSvgUrl(t){return await this.instance.downloadSvgCode(t)}async uploadSvgFile(t,e){return await this.instance.uploadSvgFile(t,e)}async uploadSvgString(t,e){const n=this.svgMap.get(e);if(n)return n;const o=await this.instance.uploadSvgString(t,e);return this.svgMap.set(e,o),o}async deleteMultipleImages(t){if(t.length!==0)return await this.instance.deleteMultipleImages(t)}async copyImage(t,e,n=fo.Resource){return await this.instance.copyImage(t,e,n)}}var Lo=(l=>(l[l.Img=0]="Img",l[l.Svg=1]="Svg",l))(Lo||{});class Ry{constructor(t,e,n){p(this,"tasks",[]);p(this,"working",!1);p(this,"resourceManager");p(this,"nodeManager");p(this,"renderManager");p(this,"tickerRun",async()=>{this.tasks.length>0&&await this.onTicker(),this.working&&requestAnimationFrame(this.tickerRun)});p(this,"onTicker",async()=>{const t=this.tasks.pop();t&&(t.type===Lo.Svg&&await this.genSvgTexture(t),t.type===Lo.Img&&(await this.genImgTexture(t),this.renderManager.slotManager.addSlotState(ze.ImgUrls,this.resourceManager.getImgUrls())))});this.resourceManager=t,this.nodeManager=e,this.renderManager=n}batchAddRenderNode(t){t.forEach(e=>this.addRenderNode(e))}addRenderNode(t){if(t.type===v.IMG){const e=t;this.tasks.push({type:Lo.Img,nodeId:t.id,url:e.imgSrc})}if(t.type===v.SVG){const e=t;e.svgCode!==""&&this.tasks.push({type:Lo.Svg,nodeId:t.id,svgCode:e.svgCode})}}start(){this.working=!0,this.tickerRun()}stop(){this.working=!1}reset(){this.tasks=[]}async genImgTexture(t){const{nodeId:e,url:n}=t,o=this.nodeManager.getNode(e);if(!o||o.type!==v.IMG)return;const s=o;try{const r=await this.resourceManager.loadImgUrl(n);s.setImageBitmap(r.imageBitmap),this.resourceManager.addNodeResourceInfo(s.id,r)}catch(r){console.error("加载图片出现问题",r),s.setBroken()}this.renderManager.dirtyDraw(o.getBounds())}async genSvgTexture(t){const{svgCode:e,nodeId:n}=t,o=this.nodeManager.getNode(n);if(!o||o.type!==v.SVG)return;const s=o;await new tl().work(s,e,this.renderManager,this.resourceManager)}}class Ey{constructor(){p(this,"duringCrop",!1)}intoCrop(){this.duringCrop=!0}exitCrop(){this.duringCrop=!1}}class Hy{constructor(){p(this,"slideSet",new Set);p(this,"slideContainerSet",new Set);p(this,"working",!1);p(this,"appCtx");p(this,"tickerRun",()=>{for(const t of this.slideContainerSet)this.appCtx.slideManager.updateSlideContainerCover(this.appCtx);this.slideContainerSet.clear();for(const t of this.slideSet)this.appCtx.slideManager.updateSlideCover(t,this.appCtx);this.slideSet.clear(),this.working&&requestAnimationFrame(this.tickerRun)})}init(t){this.appCtx=t}start(){this.working=!0,this.tickerRun()}stop(){this.working=!1}updateSlideCover(t){this.slideSet.add(t)}updateSlideContainerCover(t){this.slideContainerSet.add(t)}}const kt=50,Co=40;class Dy{constructor(){p(this,"slidePlayWorker");p(this,"slideCoverManager");this.slidePlayWorker=new $c,this.slideCoverManager=new Hy}init(t){this.slideCoverManager.init(t)}start(){this.slideCoverManager.start()}stop(){this.slideCoverManager.stop()}enterEditing(t){const e=[...t.getSelectNodes()];if(e.length!==1)return;const n=e[0];n instanceof bo&&(t.execAction(new W),t.execAction(xe.create([])),t.execAction(new z),t.docModeManager.switchMode(he.SLIDE_EDIT,t,{slideContainer:n}))}exitEditing(t){t.docState.docMode!==he.BOARD&&t.docModeManager.switchMode(he.BOARD,t,{slideContainer:t.docState.slideStatus.slideContainer||void 0})}jumpTo(t,e){if(t.docMode!==he.SLIDE_EDIT||!t.slideStatus.slideContainer)return null;const n=t.slideStatus.slideContainer.slideProps.children,o=t.slideStatus.slideContainer.getTotalCount();return e<o&&e>-1?(t.slideStatus.currentIndex=e,this.getChildIdByIndex(n,e)):null}jumpToWhenEditing(t,e){const n=this.jumpTo(e.docState,t);n&&(e.focus(n,0,50),e.slotManager.addSlotState(ze.SlideIndex,{index:t}))}enterPlayBySlideContainer(t,e){t.execAction(new W),t.execAction(xe.create([])),t.execAction(new z),t.docState.changePermission({canEdit:!1}),t.docModeManager.switchMode(he.SLIDE_PLAY,t,{slideContainer:e})}enterPlay(t){const e=[...t.getSelectNodes()];if(e.length!==1)return;const n=e[0];n instanceof bo&&this.enterPlayBySlideContainer(t,n)}playToNext(t){const e=this.slidePlayWorker.playToNext(t.docState);e&&t.focus(e)}playToPrev(t){const e=this.slidePlayWorker.playToPrev(t.docState);e&&t.focus(e)}insertSlide(t,e,n,o){var ne,ae;const s=t.slideProps.children,r=t.getTotalCount();if(e<0||e>=r)return null;const{rowIndex:i,colIndex:a}=this.getRowColByIndex(s,e);if(i===-1)return null;const c=s[i];if(!c||!c.ids||c.ids.length===0)return null;const h=n?a+1:a,d=c.ids[a],u=o.nodeManager.getNode(d);if(!u)return null;const g=u.baseProps,f=(ne=u.getProp(I.Color))==null?void 0:ne.color,y=(ae=u.getProp(I.Border))==null?void 0:ae.color,P=g.width,b=g.height;let w;if(h===0)w=kt;else{const te=c.ids[h-1],ce=o.nodeManager.getNode(te);ce?w=ce.baseProps.x+ce.baseProps.width+kt:w=u.baseProps.x+u.baseProps.width+kt}const L=u.baseProps.y,B=[ie.create({x:w,y:L,width:P,height:b})];f!==void 0&&B.push(tt.create({color:f})),y!==void 0&&B.push(Ae.create({color:y}));const H=o.idGenerator.genId(v.Section),E={id:H,type:v.Section,zIndex:ve.genZIndex(t),parentId:t.id,props:B};o.execAction(Le.create(E));const X=s.map((te,ce)=>{if(ce===i){const pe=[...te.ids];return pe.splice(h,0,H),{ids:pe}}return{ids:[...te.ids]}}),$=[{id:t.id,props:[Mt.create({children:X})]}];if(h===0){let te=kt;const ce=X[i];for(let pe=0;pe<ce.ids.length;pe++){const Be=ce.ids[pe],Re=o.nodeManager.getNode(Be);Re&&($.push({id:Be,props:[ie.create({x:te,y:L,width:Re.baseProps.width,height:Re.baseProps.height})]}),te+=Re.baseProps.width+kt)}}else if(h<c.ids.length+1){let te=w+P+kt;for(let ce=h;ce<c.ids.length;ce++){const pe=c.ids[ce],Be=o.nodeManager.getNode(pe);Be&&($.push({id:pe,props:[ie.create({x:te,y:Be.baseProps.y,width:Be.baseProps.width,height:Be.baseProps.height})]}),te+=Be.baseProps.width+kt)}}o.execAction(new U({infos:$}));const Z=[];for(const te of X)for(const ce of te.ids){const pe=o.nodeManager.getNode(ce);pe&&Z.push(pe.baseProps)}if(Z.length>0){const te=M.getBoundsByBasePropsList(Z),ce=te.maxX-te.minX+2*kt,pe=te.maxY-te.minY+2*Co;o.execAction(U.create(t.id,[{type:I.Base,width:ce,height:pe}]))}return o.nodeManager.getNode(H)}exitPlay(t){t.docState.docMode===he.SLIDE_PLAY&&t.docModeManager.backToPrevMode(t,{slideContainer:t.docState.slideStatus.slideContainer||void 0})}refocusSlide(t,e=0){if(t.docState.docMode===he.BOARD)return;const{currentIndex:o,slideContainer:s}=t.docState.slideStatus;if(!s)return;const r=s.getChildIdByIndex(o);r&&t.focus(r,0,e)}unGroupSlideContainerBySelective(t){const n=[...t.getSelectNodes()].filter(o=>o.type===v.SlideContainer);for(const o of n)this.unGroupSlideContainer(o,t)}unGroupSlideContainer(t,e){const n=t.globalBaseProps,o=n.x,s=n.y,r=Array.from(t.children);if(r.length===0)return;e.execAction(new W);const i=r.map(c=>{const h=c.baseProps,d=o+h.x,u=s+h.y;return{id:c.id,parentId:"",props:[ie.create({x:d,y:u,width:h.width,height:h.height,angle:h.angle})]}});i.length>0&&e.execAction(new U({infos:i})),e.execAction(At.create([t.id]));const a=r.map(c=>c.id);e.execAction(xe.create(a)),e.execAction(new z)}getChildIdByIndex(t,e){let n=0;for(let o=0;o<t.length;o++){if(e<n+t[o].ids.length){const s=e-n;return t[o].ids[s]}n+=t[o].ids.length}return null}getRowColByIndex(t,e){let n=0;for(let o=0;o<t.length;o++){if(e<n+t[o].ids.length){const s=e-n;return{rowIndex:o,colIndex:s}}n+=t[o].ids.length}return{rowIndex:-1,colIndex:-1}}updateSlideCover(t,e){M.getSlideInfo(t,e).then(n=>{const o=e.docState.slideStatus.slideCoverList.findIndex(s=>s.id===t.id);if(o>-1){const s=e.docState.slideStatus.slideCoverList[o];URL.revokeObjectURL(s.blobUrl),e.docState.slideStatus.slideCoverList.splice(o,1,n),e.slotManager.addSlotState(ze.SlideCovers,{covers:e.docState.slideStatus.slideCoverList})}else URL.revokeObjectURL(n.blobUrl)})}async updateSlideContainerCover(t){const e=t.docState.slideStatus.slideContainer;if(!e)return;const n=t.docState.slideStatus.slideCoverList,o=new Map;n.forEach(i=>o.set(i.id,i));const s=e.slideProps.children,r=[];for(const i of s)for(const a of i.ids){const c=o.get(a);if(c)r.push(c),o.delete(a);else{const h=t.nodeManager.getNode(a);if(h){const d=await M.getSlideInfo(h,t);r.push(d)}}}for(const i of o.values())URL.revokeObjectURL(i.blobUrl);t.docState.slideStatus.slideCoverList=r,t.slotManager.addSlotState(ze.SlideCovers,{covers:t.docState.slideStatus.slideCoverList})}updateSlideContainers(t,e,n){for(const o of t){const s=o.slideProps.children,r=[];for(const h of s){const d=h.ids.filter(u=>!e.has(u));d.length>0&&r.push({ids:d})}if(r.length===0){n.actionManager.execAction(U.create(o.id,[Mt.create({children:[]}),{type:I.Base,width:100+2*kt,height:100+2*Co}]));continue}const i=[];let a=Co;for(let h=0;h<r.length;h++){const d=r[h];let u=kt,g=0;for(const f of d.ids){const y=n.nodeManager.getNode(f);y&&(i.push({id:f,props:[ie.create({x:u,y:a,width:y.baseProps.width,height:y.baseProps.height})]}),u+=y.baseProps.width+kt,g=Math.max(g,y.baseProps.height))}a+=g+Co}i.unshift({id:o.id,props:[Mt.create({children:r})]}),n.actionManager.execAction(new U({infos:i}));const c=[];for(const h of r)for(const d of h.ids){const u=n.nodeManager.getNode(d);u&&c.push(u.baseProps)}if(c.length>0){const h=M.getBoundsByBasePropsList(c),d=h.maxX-h.minX+2*kt,u=h.maxY-h.minY+2*Co;n.actionManager.execAction(U.create(o.id,[{type:I.Base,width:d,height:u}]))}}}}class vr{constructor(t){p(this,"inputManager");p(this,"cursorManager");p(this,"toolManager");p(this,"gmlRender");p(this,"auxGMLRender");p(this,"nodeManager");p(this,"serializeManager");p(this,"actionManager");p(this,"renderManager");p(this,"auxiliaryManager");p(this,"previewManager");p(this,"asyncRenderNodeManager");p(this,"docState");p(this,"idGenerator");p(this,"slotManager");p(this,"resourceManager");p(this,"cropManager");p(this,"slideManager");p(this,"appContext");p(this,"plugins",[]);p(this,"api");p(this,"aiAPI");this.docState=new Kc,this.idGenerator=new ve,this.gmlRender=new Pr,this.auxGMLRender=new Pr,this.cursorManager=new Xc,this.nodeManager=new el,this.slotManager=new li,this.resourceManager=new sl,this.cropManager=new Ey,this.slideManager=new Dy,this.auxiliaryManager=new di(this.auxGMLRender,this.slotManager,this.cropManager,this.docState),this.renderManager=new Oc(this.gmlRender,this.nodeManager,this.auxiliaryManager,this.slotManager),this.inputManager=new hy(this.renderManager,this.cursorManager),this.previewManager=new By,this.toolManager=new Fa(this.nodeManager,this.inputManager,this.slotManager,this.cursorManager),this.asyncRenderNodeManager=new Ry(this.resourceManager,this.nodeManager,this.renderManager),this.actionManager=new Hc(this.nodeManager,this.inputManager,this.gmlRender,this.auxiliaryManager,this.toolManager,this.renderManager,this.resourceManager,this.docState,this.idGenerator,this.slotManager,this.asyncRenderNodeManager,this.slideManager),this.serializeManager=new dy(this.nodeManager,this.docState),this.appContext=new zc(this.nodeManager,this.gmlRender,t.detectors,this.toolManager,this.inputManager,this.actionManager,this.renderManager,this.auxiliaryManager,this.docState,this.idGenerator,this.cursorManager,this.previewManager,this.resourceManager,this.slotManager,this.asyncRenderNodeManager,this.cropManager,this.slideManager),this.api=new jc(this),this.aiAPI=new Vc(this),this.slideManager.init(this.appContext),this.actionManager.executor.init(this.appContext),this.auxiliaryManager.selectManager.register(this.inputManager),this.appContext.refreshEvent=e=>{const n=this.getPlugin(Wo);n&&n.interactiveManager.refreshEvent(this.appContext,e)}}registerPlugin(t){this.plugins.push(t)}getPlugin(t){for(const e of this.plugins)if(e instanceof t)return e;return null}start(){this.slotManager.start(),this.auxiliaryManager.start(),this.renderManager.start(),this.asyncRenderNodeManager.start(),this.slideManager.start();for(const t of this.plugins)t.start()}stop(){this.slotManager.stop(),this.renderManager.stop(),this.asyncRenderNodeManager.stop(),this.slideManager.stop();for(const t of this.plugins)t.stop()}reset(){this.nodeManager.reset(),this.auxiliaryManager.reset(),this.resourceManager.reset(),this.asyncRenderNodeManager.reset(),this.slotManager.reset(),this.idGenerator.reset(),this.docState.reset()}load(t){return this.loadDocumentInfo(t)}asyncLoad(t,e){return this.asyncLoadDocumentInfo(t,e)}asyncLoadDocumentInfo(t,e){const n=Qc();this.docState.load(n);try{const o=this.initData(t);this.asyncAfterInit(o,e),this.renderManager.zoomToFit(),this.renderManager.addContentRenderTask()}catch(o){console.error("初始化过程中出现错误;",o)}return this.docState.seq}loadDocumentInfo(t){const e=Qc();this.docState.load(e);try{const n=this.initData(t);this.afterInit(n),this.renderManager.zoomToFit(),this.renderManager.addContentRenderTask()}catch(n){console.error("初始化过程中出现错误;",n)}return this.docState.seq}initData(t){this.nodeManager.clear(),this.gmlRender.reset();const e=this.gmlRender.canvas.getContext("2d");let n=[];const o=M.correctZIndex(t.nodes);for(const s of o){const r=this.nodeManager.root;this.initNode(s,r,e,n)}return n=M.sortGraphics(n),n}initNode(t,e,n,o){this.idGenerator.loadNode(t);const s=It.getInstance().createByNodeInfo(t,e,n);this.nodeManager.addNode(s),o.push(s);const r=t.children??[],i=M.correctZIndex(r);for(const a of i)this.initNode(a,s,n,o);return s}async afterInit(t){for(const e of t){if(e instanceof Ct){const{start:n,end:o}=e.connectProps;if(n){const s=this.nodeManager.getNode(n.objectId)||null;this.nodeManager.addLink(e,s,!0)}if(o){const s=this.nodeManager.getNode(o.objectId)||null;this.nodeManager.addLink(e,s,!1)}}if(e instanceof Yn&&this.asyncRenderNodeManager.addRenderNode(e),e instanceof jn)try{let n="";if(e.svgProps.useCode)n=an.trimSvgCode(e.svgProps.code).svgCode;else{const s=e.svgUrl;n=await this.resourceManager.loadSvgUrl(s)}const o=an.trimSvgCode(n);e.setSvgCode(o.svgCode),this.asyncRenderNodeManager.addRenderNode(e)}catch(n){console.error("加载svg图片出现问题",n),e.setBroken()}}}asyncAfterInit(t,e){for(const n of t){if(n instanceof Ct){const{start:o,end:s}=n.connectProps;if(o){const r=this.nodeManager.getNode(o.objectId)||null;this.nodeManager.addLink(n,r,!0)}if(s){const r=this.nodeManager.getNode(s.objectId)||null;this.nodeManager.addLink(n,r,!1)}}if(n instanceof Yn){const o=n,s=o.imgSrc;if(e&&e.has(s))try{const r=e.get(s);o.setImageBitmap(r)}catch(r){console.error("从 resourceMap 加载图片出现问题",r),o.setBroken()}else{console.warn("图片资源未在 resourceMap 中找到:",s),n.setBroken();continue}}if(n instanceof jn)try{if(n.svgProps.useCode){const s=an.trimSvgCode(n.svgProps.code).svgCode;if(n.setSvgCode(s),e&&e.has(s)){const r=e.get(s);n.setImageBitmap(r)}else{console.warn("SVG useCode 资源未在 resourceMap 中找到"),n.setBroken();continue}}else{const o=n.svgUrl;if(e&&e.has(o)){const s=e.get(o);n.setImageBitmap(s)}else{console.warn("SVG 资源未在 resourceMap 中找到:",o),n.setBroken();continue}}}catch(o){console.error("加载svg图片出现问题",o),n.setBroken()}}}}const Oy={width:595,height:942};var Ir={exports:{}},Ao={};/**
|
|
29
29
|
* @license React
|
|
30
30
|
* react-jsx-runtime.production.min.js
|
|
31
31
|
*
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
*
|
|
34
34
|
* This source code is licensed under the MIT license found in the
|
|
35
35
|
* LICENSE file in the root directory of this source tree.
|
|
36
|
-
*/var rl;function Xy(){if(rl)return Ao;rl=1;var l=st,t=Symbol.for("react.element"),e=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,o=l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function r(i,a,c){var h,d={},u=null,
|
|
36
|
+
*/var rl;function Xy(){if(rl)return Ao;rl=1;var l=st,t=Symbol.for("react.element"),e=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,o=l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function r(i,a,c){var h,d={},u=null,g=null;c!==void 0&&(u=""+c),a.key!==void 0&&(u=""+a.key),a.ref!==void 0&&(g=a.ref);for(h in a)n.call(a,h)&&!s.hasOwnProperty(h)&&(d[h]=a[h]);if(i&&i.defaultProps)for(h in a=i.defaultProps,a)d[h]===void 0&&(d[h]=a[h]);return{$$typeof:t,type:i,key:u,ref:g,props:d,_owner:o.current}}return Ao.Fragment=e,Ao.jsx=r,Ao.jsxs=r,Ao}var ko={};/**
|
|
37
37
|
* @license React
|
|
38
38
|
* react-jsx-runtime.development.js
|
|
39
39
|
*
|
|
@@ -41,17 +41,17 @@
|
|
|
41
41
|
*
|
|
42
42
|
* This source code is licensed under the MIT license found in the
|
|
43
43
|
* LICENSE file in the root directory of this source tree.
|
|
44
|
-
*/var il;function zy(){return il||(il=1,process.env.NODE_ENV!=="production"&&function(){var l=st,t=Symbol.for("react.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),r=Symbol.for("react.provider"),i=Symbol.for("react.context"),a=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),h=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),u=Symbol.for("react.lazy"),
|
|
45
|
-
`+yt+
|
|
44
|
+
*/var il;function zy(){return il||(il=1,process.env.NODE_ENV!=="production"&&function(){var l=st,t=Symbol.for("react.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),r=Symbol.for("react.provider"),i=Symbol.for("react.context"),a=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),h=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),u=Symbol.for("react.lazy"),g=Symbol.for("react.offscreen"),f=Symbol.iterator,y="@@iterator";function P(k){if(k===null||typeof k!="object")return null;var Q=f&&k[f]||k[y];return typeof Q=="function"?Q:null}var b=l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function w(k){{for(var Q=arguments.length,oe=new Array(Q>1?Q-1:0),we=1;we<Q;we++)oe[we-1]=arguments[we];L("error",k,oe)}}function L(k,Q,oe){{var we=b.ReactDebugCurrentFrame,De=we.getStackAddendum();De!==""&&(Q+="%s",oe=oe.concat([De]));var Ye=oe.map(function(Ne){return String(Ne)});Ye.unshift("Warning: "+Q),Function.prototype.apply.call(console[k],console,Ye)}}var B=!1,H=!1,E=!1,X=!1,$=!1,Z;Z=Symbol.for("react.module.reference");function se(k){return!!(typeof k=="string"||typeof k=="function"||k===n||k===s||$||k===o||k===c||k===h||X||k===g||B||H||E||typeof k=="object"&&k!==null&&(k.$$typeof===u||k.$$typeof===d||k.$$typeof===r||k.$$typeof===i||k.$$typeof===a||k.$$typeof===Z||k.getModuleId!==void 0))}function ne(k,Q,oe){var we=k.displayName;if(we)return we;var De=Q.displayName||Q.name||"";return De!==""?oe+"("+De+")":oe}function ae(k){return k.displayName||"Context"}function te(k){if(k==null)return null;if(typeof k.tag=="number"&&w("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof k=="function")return k.displayName||k.name||null;if(typeof k=="string")return k;switch(k){case n:return"Fragment";case e:return"Portal";case s:return"Profiler";case o:return"StrictMode";case c:return"Suspense";case h:return"SuspenseList"}if(typeof k=="object")switch(k.$$typeof){case i:var Q=k;return ae(Q)+".Consumer";case r:var oe=k;return ae(oe._context)+".Provider";case a:return ne(k,k.render,"ForwardRef");case d:var we=k.displayName||null;return we!==null?we:te(k.type)||"Memo";case u:{var De=k,Ye=De._payload,Ne=De._init;try{return te(Ne(Ye))}catch{return null}}}return null}var ce=Object.assign,pe=0,Be,Re,Me,Te,ge,O,G;function j(){}j.__reactDisabledLog=!0;function _(){{if(pe===0){Be=console.log,Re=console.info,Me=console.warn,Te=console.error,ge=console.group,O=console.groupCollapsed,G=console.groupEnd;var k={configurable:!0,enumerable:!0,value:j,writable:!0};Object.defineProperties(console,{info:k,log:k,warn:k,error:k,group:k,groupCollapsed:k,groupEnd:k})}pe++}}function Ve(){{if(pe--,pe===0){var k={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:ce({},k,{value:Be}),info:ce({},k,{value:Re}),warn:ce({},k,{value:Me}),error:ce({},k,{value:Te}),group:ce({},k,{value:ge}),groupCollapsed:ce({},k,{value:O}),groupEnd:ce({},k,{value:G})})}pe<0&&w("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ut=b.ReactCurrentDispatcher,yt;function Nt(k,Q,oe){{if(yt===void 0)try{throw Error()}catch(De){var we=De.stack.trim().match(/\n( *(at )?)/);yt=we&&we[1]||""}return`
|
|
45
|
+
`+yt+k}}var Ft=!1,ln;{var On=typeof WeakMap=="function"?WeakMap:Map;ln=new On}function $e(k,Q){if(!k||Ft)return"";{var oe=ln.get(k);if(oe!==void 0)return oe}var we;Ft=!0;var De=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Ye;Ye=ut.current,ut.current=null,_();try{if(Q){var Ne=function(){throw Error()};if(Object.defineProperty(Ne.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ne,[])}catch(Tt){we=Tt}Reflect.construct(k,[],Ne)}else{try{Ne.call()}catch(Tt){we=Tt}k.call(Ne.prototype)}}else{try{throw Error()}catch(Tt){we=Tt}k()}}catch(Tt){if(Tt&&we&&typeof Tt.stack=="string"){for(var Ce=Tt.stack.split(`
|
|
46
46
|
`),Pt=we.stack.split(`
|
|
47
47
|
`),Je=Ce.length-1,ot=Pt.length-1;Je>=1&&ot>=0&&Ce[Je]!==Pt[ot];)ot--;for(;Je>=1&&ot>=0;Je--,ot--)if(Ce[Je]!==Pt[ot]){if(Je!==1||ot!==1)do if(Je--,ot--,ot<0||Ce[Je]!==Pt[ot]){var Bt=`
|
|
48
|
-
`+Ce[Je].replace(" at new "," at ");return
|
|
48
|
+
`+Ce[Je].replace(" at new "," at ");return k.displayName&&Bt.includes("<anonymous>")&&(Bt=Bt.replace("<anonymous>",k.displayName)),typeof k=="function"&&ln.set(k,Bt),Bt}while(Je>=1&&ot>=0);break}}}finally{Ft=!1,ut.current=Ye,Ve(),Error.prepareStackTrace=De}var so=k?k.displayName||k.name:"",Xn=so?Nt(so):"";return typeof k=="function"&&ln.set(k,Xn),Xn}function eo(k,Q,oe){return $e(k,!1)}function to(k){var Q=k.prototype;return!!(Q&&Q.isReactComponent)}function mn(k,Q,oe){if(k==null)return"";if(typeof k=="function")return $e(k,to(k));if(typeof k=="string")return Nt(k);switch(k){case c:return Nt("Suspense");case h:return Nt("SuspenseList")}if(typeof k=="object")switch(k.$$typeof){case a:return eo(k.render);case d:return mn(k.type,Q,oe);case u:{var we=k,De=we._payload,Ye=we._init;try{return mn(Ye(De),Q,oe)}catch{}}}return""}var Yt=Object.prototype.hasOwnProperty,Br={},no=b.ReactDebugCurrentFrame;function Pn(k){if(k){var Q=k._owner,oe=mn(k.type,k._source,Q?Q.type:null);no.setExtraStackFrame(oe)}else no.setExtraStackFrame(null)}function Mx(k,Q,oe,we,De){{var Ye=Function.call.bind(Yt);for(var Ne in k)if(Ye(k,Ne)){var Ce=void 0;try{if(typeof k[Ne]!="function"){var Pt=Error((we||"React class")+": "+oe+" type `"+Ne+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof k[Ne]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Pt.name="Invariant Violation",Pt}Ce=k[Ne](Q,Ne,we,oe,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(Je){Ce=Je}Ce&&!(Ce instanceof Error)&&(Pn(De),w("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",we||"React class",oe,Ne,typeof Ce),Pn(null)),Ce instanceof Error&&!(Ce.message in Br)&&(Br[Ce.message]=!0,Pn(De),w("Failed %s type: %s",oe,Ce.message),Pn(null))}}}var Sx=Array.isArray;function Rr(k){return Sx(k)}function vx(k){{var Q=typeof Symbol=="function"&&Symbol.toStringTag,oe=Q&&k[Symbol.toStringTag]||k.constructor.name||"Object";return oe}}function Ix(k){try{return Ll(k),!1}catch{return!0}}function Ll(k){return""+k}function Cl(k){if(Ix(k))return w("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",vx(k)),Ll(k)}var Al=b.ReactCurrentOwner,Tx={key:!0,ref:!0,__self:!0,__source:!0},kl,Nl;function Lx(k){if(Yt.call(k,"ref")){var Q=Object.getOwnPropertyDescriptor(k,"ref").get;if(Q&&Q.isReactWarning)return!1}return k.ref!==void 0}function Cx(k){if(Yt.call(k,"key")){var Q=Object.getOwnPropertyDescriptor(k,"key").get;if(Q&&Q.isReactWarning)return!1}return k.key!==void 0}function Ax(k,Q){typeof k.ref=="string"&&Al.current}function kx(k,Q){{var oe=function(){kl||(kl=!0,w("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",Q))};oe.isReactWarning=!0,Object.defineProperty(k,"key",{get:oe,configurable:!0})}}function Nx(k,Q){{var oe=function(){Nl||(Nl=!0,w("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",Q))};oe.isReactWarning=!0,Object.defineProperty(k,"ref",{get:oe,configurable:!0})}}var Bx=function(k,Q,oe,we,De,Ye,Ne){var Ce={$$typeof:t,type:k,key:Q,ref:oe,props:Ne,_owner:Ye};return Ce._store={},Object.defineProperty(Ce._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Ce,"_self",{configurable:!1,enumerable:!1,writable:!1,value:we}),Object.defineProperty(Ce,"_source",{configurable:!1,enumerable:!1,writable:!1,value:De}),Object.freeze&&(Object.freeze(Ce.props),Object.freeze(Ce)),Ce};function Rx(k,Q,oe,we,De){{var Ye,Ne={},Ce=null,Pt=null;oe!==void 0&&(Cl(oe),Ce=""+oe),Cx(Q)&&(Cl(Q.key),Ce=""+Q.key),Lx(Q)&&(Pt=Q.ref,Ax(Q,De));for(Ye in Q)Yt.call(Q,Ye)&&!Tx.hasOwnProperty(Ye)&&(Ne[Ye]=Q[Ye]);if(k&&k.defaultProps){var Je=k.defaultProps;for(Ye in Je)Ne[Ye]===void 0&&(Ne[Ye]=Je[Ye])}if(Ce||Pt){var ot=typeof k=="function"?k.displayName||k.name||"Unknown":k;Ce&&kx(Ne,ot),Pt&&Nx(Ne,ot)}return Bx(k,Ce,Pt,De,we,Al.current,Ne)}}var Er=b.ReactCurrentOwner,Bl=b.ReactDebugCurrentFrame;function oo(k){if(k){var Q=k._owner,oe=mn(k.type,k._source,Q?Q.type:null);Bl.setExtraStackFrame(oe)}else Bl.setExtraStackFrame(null)}var Hr;Hr=!1;function Dr(k){return typeof k=="object"&&k!==null&&k.$$typeof===t}function Rl(){{if(Er.current){var k=te(Er.current.type);if(k)return`
|
|
49
49
|
|
|
50
|
-
Check the render method of \``+
|
|
50
|
+
Check the render method of \``+k+"`."}return""}}function Ex(k){return""}var El={};function Hx(k){{var Q=Rl();if(!Q){var oe=typeof k=="string"?k:k.displayName||k.name;oe&&(Q=`
|
|
51
51
|
|
|
52
|
-
Check the top-level render call using <`+oe+">.")}return Q}}function Hl(
|
|
52
|
+
Check the top-level render call using <`+oe+">.")}return Q}}function Hl(k,Q){{if(!k._store||k._store.validated||k.key!=null)return;k._store.validated=!0;var oe=Hx(Q);if(El[oe])return;El[oe]=!0;var we="";k&&k._owner&&k._owner!==Er.current&&(we=" It was passed a child from "+te(k._owner.type)+"."),oo(k),w('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',oe,we),oo(null)}}function Dl(k,Q){{if(typeof k!="object")return;if(Rr(k))for(var oe=0;oe<k.length;oe++){var we=k[oe];Dr(we)&&Hl(we,Q)}else if(Dr(k))k._store&&(k._store.validated=!0);else if(k){var De=P(k);if(typeof De=="function"&&De!==k.entries)for(var Ye=De.call(k),Ne;!(Ne=Ye.next()).done;)Dr(Ne.value)&&Hl(Ne.value,Q)}}}function Dx(k){{var Q=k.type;if(Q==null||typeof Q=="string")return;var oe;if(typeof Q=="function")oe=Q.propTypes;else if(typeof Q=="object"&&(Q.$$typeof===a||Q.$$typeof===d))oe=Q.propTypes;else return;if(oe){var we=te(Q);Mx(oe,k.props,"prop",we,k)}else if(Q.PropTypes!==void 0&&!Hr){Hr=!0;var De=te(Q);w("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",De||"Unknown")}typeof Q.getDefaultProps=="function"&&!Q.getDefaultProps.isReactClassApproved&&w("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Ox(k){{for(var Q=Object.keys(k.props),oe=0;oe<Q.length;oe++){var we=Q[oe];if(we!=="children"&&we!=="key"){oo(k),w("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",we),oo(null);break}}k.ref!==null&&(oo(k),w("Invalid attribute `ref` supplied to `React.Fragment`."),oo(null))}}var Ol={};function Xl(k,Q,oe,we,De,Ye){{var Ne=se(k);if(!Ne){var Ce="";(k===void 0||typeof k=="object"&&k!==null&&Object.keys(k).length===0)&&(Ce+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var Pt=Ex();Pt?Ce+=Pt:Ce+=Rl();var Je;k===null?Je="null":Rr(k)?Je="array":k!==void 0&&k.$$typeof===t?(Je="<"+(te(k.type)||"Unknown")+" />",Ce=" Did you accidentally export a JSX literal instead of a component?"):Je=typeof k,w("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",Je,Ce)}var ot=Rx(k,Q,oe,De,Ye);if(ot==null)return ot;if(Ne){var Bt=Q.children;if(Bt!==void 0)if(we)if(Rr(Bt)){for(var so=0;so<Bt.length;so++)Dl(Bt[so],k);Object.freeze&&Object.freeze(Bt)}else w("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Dl(Bt,k)}if(Yt.call(Q,"key")){var Xn=te(k),Tt=Object.keys(Q).filter(function(Gx){return Gx!=="key"}),Or=Tt.length>0?"{key: someKey, "+Tt.join(": ..., ")+": ...}":"{key: someKey}";if(!Ol[Xn+Or]){var Yx=Tt.length>0?"{"+Tt.join(": ..., ")+": ...}":"{}";w(`A props object containing a "key" prop is being spread into JSX:
|
|
53
53
|
let props = %s;
|
|
54
54
|
<%s {...props} />
|
|
55
55
|
React keys must be passed directly to JSX without using spread:
|
|
56
56
|
let props = %s;
|
|
57
|
-
<%s key={someKey} {...props} />`,Dr,Xn,Yx,Xn),Ol[Xn+Dr]=!0}}return N===n?Ox(ot):Dx(ot),ot}}function Xx(N,Q,oe){return Xl(N,Q,oe,!0)}function zx(N,Q,oe){return Xl(N,Q,oe,!1)}var Wx=zx,Fx=Xx;No.Fragment=n,No.jsx=Wx,No.jsxs=Fx}()),No}process.env.NODE_ENV==="production"?vr.exports=Xy():vr.exports=zy();var zt=vr.exports;const Ir=({gmlRender:l})=>{const t=st.useRef(null),e=()=>{const n=window.devicePixelRatio;t.current.width=n*t.current.clientWidth,t.current.height=n*t.current.clientHeight};return st.useEffect(()=>(e(),l.init(t.current),window.addEventListener("resize",e,!1),()=>{window.removeEventListener("resize",e,!1)}),[t]),zt.jsx("div",{className:"normal-container",children:zt.jsx("canvas",{ref:t,className:"normal-canvas"})})},Wy=({gmlRender:l,auxiliaryGmlRender:t})=>zt.jsxs("div",{className:"canvas-container",children:[zt.jsx("div",{className:"auxiliary-canvas",children:zt.jsx(Ir,{gmlRender:t})}),zt.jsx("div",{className:"content-canvas",children:zt.jsx(Ir,{gmlRender:l})})]}),Fy=({inputManager:l})=>{const t=st.useRef(null),e=st.useRef(null);return st.useEffect(()=>{t.current&&l.init(t.current,e.current)},[t]),zt.jsxs(zt.Fragment,{children:[zt.jsx("div",{ref:e,className:"render-input"}),zt.jsx("input",{ref:t,className:"canvas-input"})]})};class fs{constructor(){p(this,"editTextWorker",new mo);p(this,"textInputWorker",new wr);p(this,"selectionDeleteWorker",new os)}computeNextCursorIndex(t,e){return t+e.length}handle(t,e,n,o){const{node:s,renderText:r,textCursorPosition:i}=t;e.execAction(new W);const a=e.inputManager.selectionManager.selectionInfo;if(a){this.selectionDeleteWorker.work(t,a,e);const{renderText:f,textCursorPosition:g}=e.inputManager.editTextInfo,{prev:y,next:P}=this.textInputWorker.getEditTextPrevNext(f,g),b=f.getIndexByTextCursorPos(g);o.prev=y,o.next=P,o.index=b}else e.execAction(ee.focus(s.id,i));const{updateTextProps:c,index:h}=this.computeUpdateTextProps(t,n,o);e.execAction(U.create(s.id,[c])),this.editTextWorker.modifyBaseProps(r,s,e);const d=this.computeNextCursorIndex(h,n),u=r.getTextCursorPosByIndex(d);e.execAction(ee.focus(s.id,u)),e.execAction(new z)}}class al extends fs{computeUpdateTextProps(t,e){const{renderText:n,textCursorPosition:o}=t,s=this.editTextWorker.editText(n,o,e),r=n.getIndexByTextCursorPos(o);return{updateTextProps:{type:I.Text,richText:s},index:r}}}class cl extends fs{computeUpdateTextProps(t,e,n){const{prev:o,next:s,index:r}=n;return{updateTextProps:{type:I.Text,richText:o+e+s},index:r}}}class ll extends fs{constructor(){super(...arguments);p(this,"graphemeSplit",new Ro)}computeUpdateTextProps(e,n,o){const{prev:s,next:r,index:i}=o;return{updateTextProps:{type:I.Text,richText:s+n+r},index:i}}computeNextCursorIndex(e,n){const o=this.graphemeSplit.split(n).length;return e+o}}class hl{constructor(t){p(this,"eventCtx");p(this,"duringComposition",!1);p(this,"compositionRecord",{prev:"",next:"",index:0});p(this,"textInputWorker",new wr);p(this,"normalInputHandler",new al);p(this,"compositionInputHandler",new cl);p(this,"compositionEndHandler",new ll);p(this,"compositionEnd",t=>{if(!this.onEnable()||!this.duringComposition)return;const e=this.eventCtx.inputManager.editTextInfo;if(!e)return;const n=t.data;this.compositionEndHandler.handle(e,this.eventCtx,n,this.compositionRecord),this.duringComposition=!1});p(this,"compositionStart",t=>{if(!this.onEnable())return;const e=this.eventCtx.inputManager.editTextInfo;if(!e)return;this.duringComposition=!0;const{renderText:n,textCursorPosition:o}=e,{prev:s,next:r}=this.textInputWorker.getEditTextPrevNext(n,o),i=n.getIndexByTextCursorPos(o);this.compositionRecord={prev:s,next:r,index:i}});p(this,"onKeyDown",t=>{if(!this.onEnable()||!t.data)return;const e=t.data;if(e==="")return;const n=this.eventCtx.inputManager.editTextInfo;if(n){if(this.duringComposition){this.compositionInputHandler.handle(n,this.eventCtx,e,this.compositionRecord);return}this.normalInputHandler.handle(n,this.eventCtx,e,this.compositionRecord)}});this.eventCtx=t}onEnable(){return this.eventCtx.docState.canEdit()}start(){var e;const t=(e=this.eventCtx.inputManager.renderInput)==null?void 0:e.inputDom;if(!t){console.error("input dom is not exist");return}t.addEventListener("input",this.onKeyDown),t.addEventListener("compositionstart",this.compositionStart),t.addEventListener("compositionend",this.compositionEnd)}stop(){var e;const t=(e=this.eventCtx.inputManager.renderInput)==null?void 0:e.inputDom;if(!t){console.error("input dom is not exist");return}t.removeEventListener("input",this.onKeyDown),t.removeEventListener("compositionstart",this.compositionStart),t.removeEventListener("compositionend",this.compositionEnd)}}class Tr{constructor(t){p(this,"eventCtx");p(this,"svgRedrawTimer",null);p(this,"onWheel",t=>{if(!this.onEnable(t))return;const e=this.eventCtx;if(t.target===e.gmlRender.canvas&&t.preventDefault(),t.ctrlKey){const n=e.gmlRender.canvas.getBoundingClientRect(),o=new m(t.clientX-n.x,t.clientY-n.y),s=e.gmlRender.transformToGlobal(o),r=t.deltaY,i=2*Math.abs(r)/100,a=r>0?1-i:1+i;this.eventCtx.renderManager.zoomScale(a,s),this.scaleRedrawSvg(e)}else this.eventCtx.renderManager.scroll(t.deltaX,t.deltaY);this.eventCtx.inputManager.refreshCursor(),this.eventCtx.refreshEvent()});this.eventCtx=t}start(){if(!this.eventCtx.renderManager.gmlRender.canvas){console.error("canvas 不存在,无法注册画布滚动时间");return}this.eventCtx.renderManager.gmlRender.canvas.addEventListener("wheel",this.onWheel,{passive:!1})}stop(){if(!this.eventCtx.renderManager.gmlRender.canvas){console.error("canvas 不存在,无法注册画布滚动时间");return}this.eventCtx.renderManager.gmlRender.canvas.removeEventListener("wheel",this.onWheel)}onEnable(t){return!0}scaleRedrawSvg(t){this.svgRedrawTimer&&(clearTimeout(this.svgRedrawTimer),this.svgRedrawTimer=null),this.svgRedrawTimer=setTimeout(()=>{for(const[e,n]of t.nodeManager.nodeMap)n.type===v.SVG&&t.asyncRenderNodeManager.addRenderNode(n)},100)}}class Yy{static scroll(t,e,n){const o=n.getScale();n.translation(-t/o,-e/o);const s=n.glCtx,{a:r,b:i,c:a,d:c,e:h,f:d}=n.globalTransform;s.setTransform(r,i,a,c,h,d)}static zoomScale(t,e,n){const o=2*Math.abs(t)/100,s=t>0?1-o:1+o;e.scale(s,s,n);const r=e.glCtx,{a:i,b:a,c,d:h,e:d,f:u}=e.globalTransform;r.setTransform(i,a,c,h,d,u)}static zoomRedraw(t,e,n){const o=t.canvas.getContext("2d"),{a:s,b:r,c:i,d:a,e:c,f:h}=t.globalTransform;o.setTransform(s,r,i,a,c,h),n.addContentRenderTask(),n.addAuxiliaryDrawTask()}static zoomToFit(t,e,n,o){const s=t.canvas.getContext("2d"),{a:r,b:i,c:a,d:c,e:h,f:d}=o;t.globalTransform.a=r,t.globalTransform.b=i,t.globalTransform.c=a,t.globalTransform.d=c,t.globalTransform.e=h,t.globalTransform.f=d,s.setTransform(r,i,a,c,h,d),n.renderManager.addContentRenderTask()}}class Lr{constructor(t){p(this,"eventCtx");p(this,"onResize",()=>{this.eventCtx.resizeWorker.resize(this.eventCtx)});this.eventCtx=t}start(){window.addEventListener("resize",this.onResize)}stop(){window.removeEventListener("resize",this.onResize)}onEnable(t){return!0}}class Cr{constructor(t){p(this,"keyMap",new Map);this.keyMap=t}getKey(t){const e=this.keyMap.get(t.code);if(!e)return null;const o=ui.getOS()===Jt.MacOS;for(const s of e)if(s.enable(t,o))return s;return null}}class Pe{keyDown(t,e){this.work(t,e)}keyUp(t,e){}shouldPreventDefault(){return!0}isPressMetaKey(t,e){return e?t.metaKey:t.ctrlKey}}var J=(l=>(l.Enter="Enter",l.Escape="Escape",l.Backspace="Backspace",l.Delete="Delete",l.Space="Space",l.ArrowLeft="ArrowLeft",l.ArrowRight="ArrowRight",l.ArrowUp="ArrowUp",l.ArrowDown="ArrowDown",l.Digit1="Digit1",l.Digit2="Digit2",l.Digit3="Digit3",l.Digit4="Digit4",l.Digit5="Digit5",l.Digit6="Digit6",l.Digit7="Digit7",l.Digit8="Digit8",l.Digit9="Digit9",l.Digit0="Digit0",l.KeyA="KeyA",l.KeyB="KeyB",l.KeyC="KeyC",l.KeyD="KeyD",l.KeyE="KeyE",l.KeyF="KeyF",l.KeyG="KeyG",l.KeyH="KeyH",l.KeyI="KeyI",l.KeyJ="KeyJ",l.KeyK="KeyK",l.KeyL="KeyL",l.KeyM="KeyM",l.KeyN="KeyN",l.KeyO="KeyO",l.KeyP="KeyP",l.KeyQ="KeyQ",l.KeyR="KeyR",l.KeyS="KeyS",l.KeyT="KeyT",l.KeyU="KeyU",l.KeyV="KeyV",l.KeyW="KeyW",l.KeyX="KeyX",l.KeyY="KeyY",l.KeyZ="KeyZ",l.Tab="Tab",l.ShiftLeft="ShiftLeft",l.ShiftRight="ShiftRight",l.BracketRight="BracketRight",l.BracketLeft="BracketLeft",l))(J||{});class Gy{constructor(){p(this,"cursorMoveWorker",new ho)}work(t,e){const{node:n,renderText:o,textCursorPosition:s}=t,{updateTextProps:r}=this.computeUpdateTextProps(t);e.execAction(new W),e.execAction(U.create(n.id,[r]));const i=this.cursorMoveWorker.moveRight(o,s);e.execAction(ee.focus(n.id,i)),e.execAction(new z)}computeUpdateTextProps(t){const{renderText:e,textCursorPosition:n}=t,o=this.lineBreak(e,n);return{updateTextProps:{type:I.Text,richText:o}}}lineBreak(t,e){const{paragraphIndex:n,lineIndex:o,charIndex:s}=e,r=t.prevParagraphToXML(n),i=t.nextParagraphToXML(n),a=t.getParagraph(n);if(!a)return"<root><p></p><p></p></root>";const c=a.getLine(o);if(!c){const Z=a.toRichTextXML(t.textProps);return`<root>${r}${Z}<p></p>${i}</root>`}const h=a.prevToRichTextXML(o,t.textProps),d=a.nextToRichTextXML(o,t.textProps),u=c.getBlockIndex(s);if(!u){const Z=`<p>${h}</p>`,se=`<p>${d}</p>`;return`<root>${r}${Z}${se}${i}</root>`}const{textBlock:f,blockIndex:g,charIndex:y}=u,P=c.prevToRichTextXML(g,t.textProps),b=c.nextToRichTextXML(g,t.textProps),w=f.getPrevText(y),L=f.getNextText(y),B=f.computeStyle(t.textProps),H=w?`<style ${B}>${w}</style>`:"",E=L?`<style ${B}>${L}</style>`:"",X=`<p>${h}${P}${H}</p>`,$=`<p>${E}${b}${d}</p>`;return`<root>${r}${X}${$}${i}</root>`}}class Uy{addParagraph(t,e,n){const o=t.getProp(I.TextParagraph).clone(),s=o.paragraphStyles;for(const i of s)i.paraIndex>e&&i.paraIndex++;const r=S.getParaStyle(o,e);if(r){const i={level:r.level,orderIndex:r.orderIndex,paraIndex:e+1};s.push(i),n.execAction(U.create(t.id,[{type:I.TextParagraph,paragraphStyles:s}]))}}}let dl=class extends Pe{constructor(){super(...arguments);p(this,"styleWorker",new Uy);p(this,"type",J.Enter);p(this,"editTextWorker",new mo);p(this,"selectionDeleteWorker",new os);p(this,"lineBreakWorker",new Gy)}enable(e){return!0}work(e,n){const o=n.inputManager.editTextInfo;if(!o)return;const{node:s,renderText:r}=o;let i=o.textCursorPosition;const a=n.inputManager.selectionManager.selectionInfo;n.execAction(new W),a?(this.selectionDeleteWorker.work(o,a,n),i=n.inputManager.editTextInfo.textCursorPosition):n.execAction(ee.focus(s.id,i));const c=i.paragraphIndex;this.styleWorker.addParagraph(s,c,n);const h=this.lineBreakWorker.lineBreak(r,i),d=r.getIndexByTextCursorPos(i),u={type:I.Text,richText:h};n.execAction(U.create(s.id,[u])),this.editTextWorker.modifyBaseProps(r,s,n);const f=d+1,g=r.getTextCursorPosByIndex(f);n.execAction(ee.focus(s.id,g)),n.execAction(new z)}};class ul extends Pe{constructor(){super(...arguments);p(this,"type",J.Backspace);p(this,"editTextWorker",new mo);p(this,"graphemeSplit",new Ro);p(this,"selectionDeleteWorker",new os)}enable(e){return!0}work(e,n){const o=n.inputManager.editTextInfo;if(!o)return;const s=n.inputManager.selectionManager.selectionInfo;if(s){n.execAction(new W),this.selectionDeleteWorker.work(o,s,n),n.execAction(new z);return}const{node:r,renderText:i,textCursorPosition:a}=o,c=a.paragraphIndex;if(a.lineIndex===0&&a.charIndex===-1){const P=r.getProp(I.TextParagraph).clone(),b=S.getParaStyle(P,c),w=P.paragraphStyles;if(b){if(b.level>0){b.level--,n.execAction(new W),n.execAction(U.create(r.id,[{type:I.TextParagraph,paragraphStyles:w}])),n.execAction(ee.focus(r.id,a)),n.execAction(new z);return}const L=w.findIndex(B=>B===b);w.splice(L,1),n.execAction(new W),n.execAction(U.create(r.id,[{type:I.TextParagraph,paragraphStyles:w}])),n.execAction(ee.focus(r.id,a)),n.execAction(new z);return}}const d=new fc().deleteText(i,a,1),u={type:I.Text,richText:d},f=i.getIndexByTextCursorPos(a);n.execAction(new W),n.execAction(ee.focus(r.id,a)),n.execAction(U.create(r.id,[u])),this.editTextWorker.modifyBaseProps(i,r,n);const g=f-1,y=i.getTextCursorPosByIndex(g);n.execAction(ee.focus(r.id,y)),n.execAction(new z)}}class ko extends Pe{constructor(){super(...arguments);p(this,"cursorMoveWorker",new ho)}enable(e){return!0}work(e,n){const o=n.inputManager.editTextInfo;if(!o)return;const{renderText:s,textCursorPosition:r,node:i}=o,a=this.moveCursor(s,r,n);n.execAction(new W),n.execAction(ee.focus(i.id,a)),n.execAction(new z)}}let pl=class extends ko{constructor(){super(...arguments);p(this,"type",J.ArrowRight)}moveCursor(e,n,o){const s=o.inputManager.selectionManager.selectionInfo;if(s){const{end:r}=s;return r}return this.cursorMoveWorker.moveRight(e,n)}},fl=class extends ko{constructor(){super(...arguments);p(this,"type",J.ArrowLeft)}moveCursor(e,n){return this.cursorMoveWorker.moveLeft(e,n)}},gl=class extends ko{constructor(){super(...arguments);p(this,"type",J.ArrowRight)}moveCursor(e,n){return this.cursorMoveWorker.moveUp(e,n)}},yl=class extends ko{constructor(){super(...arguments);p(this,"type",J.ArrowDown)}moveCursor(e,n){return this.cursorMoveWorker.moveDown(e,n)}};class Ar extends Pe{constructor(){super(...arguments);p(this,"type",J.KeyZ)}work(e,n){n.actionManager.redo()}enable(e,n){return e.shiftKey&&this.isPressMetaKey(e,n)}}class Nr extends Pe{constructor(){super(...arguments);p(this,"type",J.KeyZ)}work(e,n){n.actionManager.undo()}enable(e,n){return this.isPressMetaKey(e,n)}}let _y=class extends Pe{constructor(){super(...arguments);p(this,"type",J.KeyA)}enable(e,n){return this.isPressMetaKey(e,n)}work(e,n){const o=n.inputManager.editTextInfo;if(!o)return;const{node:s,textCursorPosition:r,renderText:i}=o;n.execAction(new W),n.execAction(ee.selection(s.id,i.headTextCursorPosition(),i.tailTextCursorPosition())),n.execAction(new z)}};class $y extends Pe{constructor(){super(...arguments);p(this,"type",J.Tab)}enable(e,n){return!0}work(e,n){const o=n.inputManager.editTextInfo;if(!o)return;const{node:s,textCursorPosition:r}=o,i=r.paragraphIndex,a=s.getProp(I.TextParagraph).clone(),c=S.getParaStyle(a,i);if(!c)return;c.level++;const h=a.paragraphStyles;n.execAction(new W),n.execAction(ee.focus(s.id,r)),n.execAction(U.create(s.id,[{type:I.TextParagraph,paragraphStyles:h}])),n.execAction(ee.focus(s.id,r)),n.execAction(new z)}}let jy=class extends Pe{constructor(){super(...arguments);p(this,"type",J.Escape)}enable(e){return!0}work(e,n){const{editTextInfo:o}=n.inputManager;o&&(n.execAction(new W),n.execAction(ee.blur(o.node.id)),n.execAction(new z),n.auxiliaryManager.selectManager.refreshSelectStatus())}};const xl=new Map([[J.Enter,[new dl]],[J.Escape,[new jy]],[J.Backspace,[new ul]],[J.ArrowRight,[new pl]],[J.ArrowLeft,[new fl]],[J.ArrowUp,[new gl]],[J.ArrowDown,[new yl]],[J.KeyA,[new _y]],[J.KeyZ,[new Ar,new Nr]],[J.Tab,[new $y]]]);class wl extends Pe{constructor(){super(...arguments);p(this,"type",J.Delete);p(this,"worker",new Mo)}work(e,n){this.worker.work(n)}enable(e){return!0}}class ml extends Pe{constructor(){super(...arguments);p(this,"type",J.KeyR)}work(e,n){n.toolManager.setCurrentTool(ye.SHAPE,K.RoundRect),n.setCursor("crosshair"),n.previewManager.addPreviewNode(n),n.refreshEvent()}enable(e){return!0}}class Pl extends Pe{constructor(){super(...arguments);p(this,"type",J.Escape)}enable(e){return!0}work(e,n){if(n.cropManager.duringCrop){n.cropManager.exitCrop(),n.auxiliaryManager.selectManager.refreshSelectStatus(),n.renderManager.addAuxiliaryDrawTask();return}n.previewManager.resetPreviewNode(n),n.toolManager.setCurrentTool(ye.DEFAULT),n.setCursor("default"),n.refreshEvent()}}class bl extends Pe{constructor(){super(...arguments);p(this,"type",J.KeyT)}work(e,n){n.toolManager.setCurrentTool(ye.TEXT,K.PureText),n.setCursor("text")}enable(e){return!0}}class Sl extends Pe{constructor(){super(...arguments);p(this,"type",J.KeyR)}work(e,n){n.toolManager.setCurrentTool(ye.LINE,he.Line),n.setCursor("crosshair")}enable(e){return!0}}class Vy extends Pe{constructor(){super(...arguments);p(this,"type",J.KeyC)}enable(e){return!0}work(e,n){n.toolManager.setCurrentTool(ye.LINE,he.Curve),n.setCursor("crosshair")}}class Ky extends Pe{constructor(){super(...arguments);p(this,"type",J.KeyA)}enable(e){return!0}work(e,n){n.toolManager.setCurrentTool(ye.LINE,he.RoundPolyLine),n.setCursor("crosshair")}}class Qy extends Pe{constructor(){super(...arguments);p(this,"type",J.KeyS)}work(e,n){n.toolManager.setCurrentTool(ye.SHAPE,K.Rect),n.setCursor("crosshair"),n.previewManager.addPreviewNode(n),n.refreshEvent()}enable(e){return!0}}class Zy extends Pe{constructor(){super(...arguments);p(this,"type",J.KeyC)}enable(e,n){return this.isPressMetaKey(e,n)}work(e,n){}shouldPreventDefault(){return!1}}class qy extends Pe{constructor(){super(...arguments);p(this,"type",J.KeyV)}enable(e,n){return this.isPressMetaKey(e,n)}work(e,n){}shouldPreventDefault(){return!1}}class Jy extends Pe{constructor(){super(...arguments);p(this,"duplicateWorker",new Zs);p(this,"type",J.KeyD)}enable(e,n){return this.isPressMetaKey(e,n)}work(e,n){e.preventDefault(),n.execAction(new W),this.duplicateWorker.work(n),n.execAction(new z)}}class ex extends Pe{constructor(){super(...arguments);p(this,"type",J.KeyA)}enable(e,n){return this.isPressMetaKey(e,n)}work(e,n){const o=[...n.nodeManager.root.children];if(o.length===0)return;const s=o.map(r=>r.id);n.execAction(new W),n.execAction(xe.create(s)),n.execAction(new z)}}class tx extends Pe{constructor(){super(...arguments);p(this,"type",J.BracketLeft);p(this,"moveLayerWorker",new xo)}enable(e,n){return this.isPressMetaKey(e,n)}work(e,n){this.moveLayerWorker.moveBackward(n)}}class nx extends Pe{constructor(){super(...arguments);p(this,"type",J.BracketRight);p(this,"moveLayerWorker",new xo)}enable(e,n){return this.isPressMetaKey(e,n)}work(e,n){this.moveLayerWorker.moveForward(n)}}class ox extends Pe{constructor(){super(...arguments);p(this,"type",J.BracketLeft);p(this,"moveLayerWorker",new xo)}enable(e,n){return e.altKey&&this.isPressMetaKey(e,n)}work(e,n){this.moveLayerWorker.moveToBack(n)}}class sx extends Pe{constructor(){super(...arguments);p(this,"type",J.BracketRight);p(this,"moveLayerWorker",new xo)}enable(e,n){return e.altKey&&this.isPressMetaKey(e,n)}work(e,n){this.moveLayerWorker.moveToUp(n)}}class rx extends Pe{constructor(){super(...arguments);p(this,"type",J.KeyF)}work(e,n){n.toolManager.setCurrentTool(ye.SECTION),n.setCursor("crosshair"),n.previewManager.addPreviewNode(n),n.refreshEvent()}enable(e){return!0}}class ix extends Pe{constructor(){super(...arguments);p(this,"type",J.KeyG);p(this,"worker",new ls)}work(e,n){const o=[...n.getSelectNodes()];this.worker.group(o,n)}enable(e,n){return this.isPressMetaKey(e,n)}}class ax extends Pe{constructor(){super(...arguments);p(this,"type",J.KeyG);p(this,"worker",new ls)}work(e,n){const o=[...n.getSelectNodes()];if(o.length!==1)return;const s=o[0];if(s.type!==v.Group)return;const r=s;this.worker.unGroup(r,n)}enable(e,n){return this.isPressMetaKey(e,n)&&e.shiftKey}}class cx extends Pe{constructor(){super(...arguments);p(this,"type",J.Space)}enable(e){return!0}work(e,n){n.toolManager.setCurrentTool(ye.HandTool),n.refreshEvent()}keyUp(e,n){n.toolManager.resetTool(),n.refreshEvent()}}class lx extends Pe{constructor(){super(...arguments);p(this,"type",J.Backspace);p(this,"worker",new Mo)}work(e,n){this.worker.work(n)}enable(e){return!0}}class hx extends Pe{constructor(){super(...arguments);p(this,"type",J.KeyC);p(this,"worker",new wo)}enable(e,n){return this.isPressMetaKey(e,n)&&e.shiftKey}work(e,n){const o=n.getSelectNodes();o.size!==1||[...o][0].type!==v.IMG||(e.preventDefault(),this.worker.intoCrop(n))}}class dx extends Pe{constructor(){super(...arguments);p(this,"type",J.KeyH)}work(e,n){n.toolManager.setCurrentTool(ye.HandTool),n.setCursor("grab"),n.refreshEvent()}enable(e){return!0}}class ux extends Pe{constructor(){super(...arguments);p(this,"type",J.Digit1)}work(e,n){n.renderManager.zoomToFit(),n.refreshAllSvgNode()}enable(e){return e.shiftKey}}class px extends Pe{constructor(){super(...arguments);p(this,"type",J.Digit2)}work(e,n){n.renderManager.zoomToSelect()}enable(e){return e.shiftKey}}class fx extends Pe{constructor(){super(...arguments);p(this,"type",J.Digit3)}work(e,n){n.renderManager.zoomTo100()}enable(e){return e.shiftKey}}class Ml extends Pe{constructor(){super(...arguments);p(this,"type",J.ShiftLeft)}enable(e,n){return!0}work(e,n){const o=S.getMockEventModifierInit(e);n.refreshEvent(o)}keyUp(e,n){this.work(e,n)}}class gs{constructor(){p(this,"groupBaseWorker",new on);p(this,"layoutWorker",new Rn);p(this,"handlerCtx",new Ma([new pa,new Sa,new fa]))}work(t,e,n){const o=this.computeMoveNodes(t);if(o.length===0)return;this.groupBaseWorker.start(o);const s=new Set;this.batchCollectNodeLinks(o,t,s),t.execAction(new W);const r={x:e,y:n},i=[];for(const a of o){const c=this.handlerCtx.handle(a,r);i.push(...c)}t.execAction(new U({infos:i})),this.groupBaseWorker.work(t,!1),this.layoutWorker.work([...s],t,!1),t.execAction(new z)}batchCollectNodeLinks(t,e,n){const o=e.getSelectNodes();for(const s of t)this.collectNodeLinks(s,e,o,n)}collectNodeLinks(t,e,n,o){const s=e.nodeManager.getNodeLinks(t);for(const r of s)n.has(r)||o.add(r);for(const r of t.children)r.type!==v.Line&&this.collectNodeLinks(r,e,n,o)}computeMoveNodes(t){const e=t.getSelectNodes(),n=new Map;e.forEach(s=>n.set(s.id,s));const o=[];for(const s of e)if(s.type===v.Line){const r=s,{start:i,end:a}=r.connectProps;if(i&&a&&n.has(i.objectId)&&n.has(a.objectId)){o.push(s);continue}if(!i&&a&&n.has(a.objectId)){o.push(s);continue}if(!a&&i&&n.has(i.objectId)){o.push(s);continue}!a&&!i&&o.push(s)}else o.push(s);return o}}class gx extends Pe{constructor(){super(...arguments);p(this,"type",J.ArrowRight);p(this,"worker",new gs)}enable(e,n){return!0}work(e,n){const o=n.docState.docMode;if((o===ue.SLIDE_EDIT||o===ue.SLIDE_PLAY)&&n.getSelectNodes().size===0){const i=n.docState.slideStatus.currentIndex+1;n.slideManager.jumpToWhenEditing(i,n);return}const s=e.shiftKey?15:1;this.worker.work(n,s,0)}}class yx extends Pe{constructor(){super(...arguments);p(this,"type",J.ArrowLeft);p(this,"worker",new gs)}enable(e,n){return!0}work(e,n){const o=n.docState.docMode;if((o===ue.SLIDE_EDIT||o===ue.SLIDE_PLAY)&&n.getSelectNodes().size===0){const i=n.docState.slideStatus.currentIndex-1;n.slideManager.jumpToWhenEditing(i,n);return}const s=e.shiftKey?15:1;this.worker.work(n,-s,0)}}class xx extends Pe{constructor(){super(...arguments);p(this,"type",J.ArrowUp);p(this,"worker",new gs)}enable(e,n){return!0}work(e,n){const o=n.docState.docMode;if((o===ue.SLIDE_EDIT||o===ue.SLIDE_PLAY)&&n.getSelectNodes().size===0){const i=n.docState.slideStatus.currentIndex-1;n.slideManager.jumpToWhenEditing(i,n);return}const s=e.shiftKey?15:1;this.worker.work(n,0,-s)}}class wx extends Pe{constructor(){super(...arguments);p(this,"type",J.ArrowDown);p(this,"worker",new gs)}enable(e,n){return!0}work(e,n){const o=n.docState.docMode;if((o===ue.SLIDE_EDIT||o===ue.SLIDE_PLAY)&&n.getSelectNodes().size===0){const i=n.docState.slideStatus.currentIndex+1;n.slideManager.jumpToWhenEditing(i,n);return}const s=e.shiftKey?15:1;this.worker.work(n,0,s)}}class mx extends Pe{constructor(){super(...arguments);p(this,"type",J.Enter)}enable(e){return!0}work(e,n){const o=[...n.getSelectNodes()];if(o.length!==1)return;const s=o[0];if(s.type===v.SlideContainer||s.type===v.Section){const i=[...s.children].map(a=>a.id);n.execAction(new W),n.execAction(xe.create(i)),n.execAction(new z);return}(s.type===v.Shape||s.type===v.CheckboxText)&&this.focusSelectionText(s,n)}focusSelectionText(e,n){if(e.isEmptyText()){n.execAction(new W);const o=Fe.head();n.execAction(ee.focus(e.id,o)),n.execAction(new z);return}n.execAction(new W),n.execAction(ee.selection(e.id,Fe.head(),e.renderText.tailTextCursorPosition())),n.execAction(new z)}}const vl=new Map([[J.Delete,[new wl]],[J.Backspace,[new lx]],[J.ArrowRight,[new gx]],[J.ArrowLeft,[new yx]],[J.ArrowUp,[new xx]],[J.ArrowDown,[new wx]],[J.Digit1,[new ux]],[J.Digit2,[new px]],[J.Digit3,[new fx]],[J.KeyA,[new ex,new Ky]],[J.KeyC,[new hx,new Zy,new Vy]],[J.KeyD,[new Jy]],[J.KeyF,[new rx]],[J.KeyV,[new qy]],[J.KeyL,[new Sl]],[J.KeyS,[new Qy]],[J.KeyR,[new ml]],[J.KeyT,[new bl]],[J.KeyH,[new dx]],[J.KeyZ,[new Ar,new Nr]],[J.KeyG,[new ax,new ix]],[J.Escape,[new Pl]],[J.Space,[new cx]],[J.ShiftLeft,[new Ml]],[J.ShiftRight,[new Ml]],[J.BracketLeft,[new ox,new tx]],[J.BracketRight,[new sx,new nx]],[J.Enter,[new mx]]]);class Il{constructor(t){p(this,"textConfig");p(this,"normalConfig");p(this,"context");this.context=t,this.textConfig=new Cr(xl),this.normalConfig=new Cr(vl)}keyDown(t,e){const n=this.getHotKey(t);n&&(n.shouldPreventDefault()&&(t.preventDefault(),t.stopPropagation()),n.keyDown(t,e))}keyUp(t,e){const n=this.getHotKey(t);n&&(n.shouldPreventDefault()&&(t.preventDefault(),t.stopPropagation()),n.keyUp(t,e))}getHotKey(t){return this.context.inputManager.isEdit()?this.textConfig.getKey(t):this.normalConfig.getKey(t)}}class Tl{constructor(t){p(this,"eventCtx");p(this,"hotKeyManager");p(this,"onKeyDown",t=>{this.onEnable(t)&&this.hotKeyManager.keyDown(t,this.eventCtx)});p(this,"onKeyUp",t=>{this.onEnable(t)&&this.hotKeyManager.keyUp(t,this.eventCtx)});this.eventCtx=t,this.hotKeyManager=new Il(t)}start(){document.addEventListener("keydown",this.onKeyDown,!0),document.addEventListener("keyup",this.onKeyUp,!0)}stop(){document.removeEventListener("keydown",this.onKeyDown,!0),document.removeEventListener("keyup",this.onKeyUp,!0)}onEnable(t){return this.eventCtx.docState.canEdit()?t.target===this.eventCtx.inputManager.renderInput.inputDom?!0:!(t.target instanceof HTMLInputElement||t.target instanceof HTMLTextAreaElement):!1}}class Px{constructor(t){p(this,"ctx");this.ctx=t,t.actionManager.addNetworkPlugin(this)}addMessage(t){}addActionGroup(t){}initWebsocket(){}start(){}stop(){}onEnable(t){return!0}}class bx{static getOolongApp(){const t=new hr,e=new Mr(t),n=e.appContext,o=new Wo(n,t),s=new Tr(n),r=new hl(n),i=new Tl(n),a=new Lr(n),c=new Gc(n);return e.registerPlugin(o),e.registerPlugin(s),e.registerPlugin(r),e.registerPlugin(i),e.registerPlugin(a),e.registerPlugin(c),e}static getReadOnlyApp(){const t=new hr,e=new Mr(t),n=e.appContext,o=new Wo(n,t),s=new Tr(n),r=new Lr(n);return e.registerPlugin(o),e.registerPlugin(s),e.registerPlugin(r),e}}T.ANCHOR_COLOR=Ur,T.ANCHOR_HOVER_RADIUS=Ms,T.ANCHOR_OFFSET=Fr,T.ANCHOR_RADIUS=Yr,T.AbsActionExecutor=hn,T.AbsActionLog=yn,T.AbsAlignHandler=An,T.AbsAlignSideHandler=$s,T.AbsArrowKey=ko,T.AbsAuxGraphic=Me,T.AbsCreateDragProcessor=Qo,T.AbsDetector=Ke,T.AbsDrawer=mt,T.AbsInputHandler=fs,T.AbsInteractConfig=na,T.AbsMainMode=fn,T.AbsNetworkPlugin=zl,T.AbsNodeManager=Zc,T.AbsPastePosHandler=xr,T.AbsProps=ct,T.AbsResourceInstance=nl,T.AbsStatusHandler=bt,T.AbsStretchProcessor=Go,T.AbsSubMode=Ot,T.AbsTextSelectionHandler=ss,T.ActionCache=Bc,T.ActionLogGroup=as,T.ActionManager=Ec,T.ActionMeta=pc,T.ActionType=Xe,T.AddExecutor=bc,T.AddNodeLog=Le,T.AffineMatrix=re,T.AlignBottomHandler=Vi,T.AlignHeightSideHandler=Ji,T.AlignLeftHandler=Ki,T.AlignLine=ni,T.AlignMoveWorker=Zi,T.AlignRightHandler=Qi,T.AlignStretchLine=oi,T.AlignStretchWorker=ea,T.AlignTopHandler=ji,T.AlignWidthSideHandler=qi,T.AlignWorker=un,T.AppEventContext=Xc,T.AppStage=bx,T.ArrowDownKey=yl,T.ArrowLeftKey=fl,T.ArrowProps=lt,T.ArrowRightKey=pl,T.ArrowUpKey=gl,T.AuxGraphicFactory=vs,T.AuxUtils=qr,T.AuxiliaryManager=hi,T.AuxiliaryType=k,T.BLOCK_COLOR=bs,T.BaseProps=ie,T.BorderProps=Ae,T.CanvasConfig=Oy,T.CanvasContainer=Wy,T.CanvasInput=Fy,T.CanvasRender=mr,T.CheckSizeProps=vn,T.CheckStatusProps=Qt,T.ClearFocusNodeHandler=or,T.ClickExpandShapeHandler=Na,T.ClickHandler=qe,T.ClickMode=pn,T.ClickProcessor=jt,T.ClickTextHandler=Aa,T.CollaborationManager=Ah,T.ColorProps=tt,T.ConnectProps=Rt,T.ConnectorPoint=Wl,T.ControlPoint=Fl,T.CopyPasteManager=Yc,T.CopyPastePlugin=Gc,T.CopyPasteUtils=xn,T.CreateLineMode=uc,T.CreateRectBound=ei,T.CreateRectMode=oc,T.CreateTextMode=rc,T.CropProps=Mn,T.CursorProcessor=Ga,T.DHPCanvas=Ir,T.DbClickMode=js,T.DefaultBorderColorShape=Lf,T.DefaultClickMode=Ea,T.DefaultClickProcessor=Ra,T.DefaultColorShape=Tf,T.DefaultFont=Ad,T.DefaultLineHeight=Ed,T.DefaultMode=Ja,T.DeleteKey=wl,T.DetectorEnum=F,T.DiffParaHandler=gc,T.DocMode=ue,T.DocState=Kc,T.DownAndMoveStreamMode=dt,T.DragLineEndProcessor=ja,T.DragMode=Ia,T.DragProcessor=va,T.DragSelectTextMode=ia,T.DragSelectTextProcessor=ra,T.EditTextWorker=mo,T.EmptyNetworkPlugin=Px,T.EmptyPlacePosHandler=Fc,T.EndExecutor=Tc,T.EndLog=z,T.EnterHotKey=dl,T.EscKey=Pl,T.ExecutorManager=Nc,T.ExpandDetector=ec,T.ExpandShapeButton=ti,T.FocusEnum=Lt,T.FocusNodeHandler=tr,T.GRAY_COLOR=Gr,T.GraphemeSplit=Ro,T.GraphicNode=en,T.GraphicUtils=S,T.GroupMode=qs,T.GroupProcessor=La,T.HOVER_ANCHOR_COLOR=_r,T.HOVER_BOUND_COLOR=Gt,T.HighlightRects=Kr,T.HotKey=Pe,T.HotKeyConfig=Cr,T.HotKeyManager=Il,T.HoverBound=$r,T.HoverNodeDetector=sa,T.HoverProcessor=za,T.ImageUtils=mc,T.InputCompositionEndHandler=ll,T.InputCompositionHandler=cl,T.InputEventPlugin=hl,T.InputNormalHandler=al,T.InteractConfig=hr,T.InteractiveEventType=be,T.InteractiveManager=$i,T.InteractiveUtils=Ze,T.IntlSplit=xc,T.KeyCode=J,T.KeyEventPlugin=Tl,T.LKey=Sl,T.LineArrowType=it,T.LineCreateDragProcessor=dc,T.LineDashType=et,T.LineEndPointDetector=tc,T.LineProps=je,T.LineShapeType=he,T.LineSpacing=Nd,T.LinkNode=Bo,T.MAX_SCALE=yr,T.MIN_SCALE=gr,T.MOVE_ALIGN_BUFFER=Ys,T.MainTextId=Rd,T.MeasureWorker=Bf,T.MobileUtils=Hc,T.MoveLayerWorker=xo,T.MultiSelectBound=Vr,T.MultiSelectHandler=ai,T.NodeDetector=oa,T.NodeFactory=It,T.NodeManager=el,T.NodeSideEnum=Or,T.NodeTextPadding=le,T.NodeType=v,T.NormalMode=Ua,T.NormalPastePosHandler=Wc,T.NormalResourceInstance=ol,T.OolongAIAPI=jc,T.OolongAPI=$c,T.OolongApp=Mr,T.OolongGroup=Po,T.OolongImgNode=Yn,T.OolongLine=Ct,T.OolongNode=vt,T.OolongSVGNode=jn,T.OolongSVGUtils=an,T.OptionHelper=ri,T.PREVIEW_ROOT_ID=Xr,T.ParagraphSpacing=kd,T.PasteNodeHandler=cs,T.Permission=Vc,T.Point=m,T.PointerEventPlugin=Wo,T.PolyLineControlPointDetector=hc,T.PosPasteType=Kt,T.PropType=I,T.QuadBezierCurve=Yl,T.RKey=ml,T.ROOT_ID=Sn,T.Rect=D,T.RectCreateDragProcessor=nc,T.RedoKey=Ar,T.RemoveExecutor=Sc,T.RemoveNodeLog=At,T.RenderManager=Dc,T.RenderText=uo,T.ResourceEnumType=go,T.ResourceManager=sl,T.ResourceType=zn,T.RootNode=pr,T.RotateDetector=Jo,T.RotateMode=Ka,T.RotateProcessor=Va,T.SELECT_BOUND_COLOR=Qe,T.SELECT_GROUP_COLOR=Ss,T.SLIDE_X_GAP=nt,T.SLIDE_Y_GAP=xt,T.STRETCH_ALIGN_BUFFER=Gs,T.STRETCH_ALIGN_OFFSET=Us,T.STRETCH_WIDTH=Wr,T.SameParaDiffLineHandler=ur,T.SameParaSameLineHandler=dr,T.SectionType=kn,T.SelectGroup=Qr,T.SelectManager=li,T.SelectNodeExecutor=vc,T.SelectNodeLog=xe,T.ShapeProps=Oe,T.ShapeType=K,T.ShiftDownNodeHandler=er,T.ShiftUpClickHandler=nr,T.SingleSelectBound=jr,T.SingleStatusHandler=ii,T.SingleStretchMode=ua,T.SingleStretchProcessorV2=da,T.SlotKeyType=ze,T.SlotManager=ci,T.StartExecutor=Ic,T.StartLog=W,T.StreamMode=Nn,T.StreamProcessor=ht,T.StretchAlignType=_e,T.StretchDetector=Fo,T.StretchHotBuffer=Th,T.StretchMode=$a,T.StretchProcessorV2=_a,T.StretchRect=Jr,T.StretchType=V,T.TEXT_QUOTE_ALPHA=Gi,T.TEXT_QUOTE_LINE_WIDTH=Oo,T.TEXT_QUOTE_PADDING=Yi,T.TEXT_SELECTION_COLOR=zr,T.TKey=bl,T.TextAlignType=at,T.TextCharacter=As,T.TextCreateDragProcessor=sc,T.TextCursorMoveWorker=ho,T.TextCursorPosition=Fe,T.TextDeleteKey=ul,T.TextFocusExecutor=Lc,T.TextFocusLog=ee,T.TextLine=Gn,T.TextParagraph=Cs,T.TextParagraphProps=qt,T.TextParagraphQuoteProps=Dt,T.TextProps=Ge,T.TextSelection=Zr,T.TextSelectionDeleteWorker=os,T.TextSelectionWorker=yc,T.TextSizeMode=We,T.TextUtils=sn,T.TextWord=Ui,T.ToolEnum=ye,T.ToolManager=Wa,T.UndoKey=Nr,T.UndoRedoManager=kc,T.UpdateExecutor=Mc,T.UpdateNodeLog=U,T.VisibleBuffer=Hd,T.WHITE_COLOR=Ht,T.WheelEventPlugin=Tr,T.WheelUtils=Yy,T.WidgetEnum=_n,T.WindowResizePlugin=Lr,T.actionExecutors=Cc,T.convertAction2MsgData=ig,T.convertActionData2Log=ag,T.disableAlignNodeType=Cn,T.disableAlignSideSet=_s,T.graphemeSplitter=Eo,T.intlSplitter=Rf,T.isContains=Cf,T.limitLineWidth=Bd,T.normalKeyMap=vl,T.textKeyMap=xl,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})});
|
|
57
|
+
<%s key={someKey} {...props} />`,Or,Xn,Yx,Xn),Ol[Xn+Or]=!0}}return k===n?Ox(ot):Dx(ot),ot}}function Xx(k,Q,oe){return Xl(k,Q,oe,!0)}function zx(k,Q,oe){return Xl(k,Q,oe,!1)}var Wx=zx,Fx=Xx;ko.Fragment=n,ko.jsx=Wx,ko.jsxs=Fx}()),ko}process.env.NODE_ENV==="production"?Ir.exports=Xy():Ir.exports=zy();var zt=Ir.exports;const Tr=({gmlRender:l})=>{const t=st.useRef(null),e=()=>{const n=window.devicePixelRatio;t.current.width=n*t.current.clientWidth,t.current.height=n*t.current.clientHeight};return st.useEffect(()=>(e(),l.init(t.current),window.addEventListener("resize",e,!1),()=>{window.removeEventListener("resize",e,!1)}),[t]),zt.jsx("div",{className:"normal-container",children:zt.jsx("canvas",{ref:t,className:"normal-canvas"})})},Wy=({gmlRender:l,auxiliaryGmlRender:t})=>zt.jsxs("div",{className:"canvas-container",children:[zt.jsx("div",{className:"auxiliary-canvas",children:zt.jsx(Tr,{gmlRender:t})}),zt.jsx("div",{className:"content-canvas",children:zt.jsx(Tr,{gmlRender:l})})]}),Fy=({inputManager:l})=>{const t=st.useRef(null),e=st.useRef(null);return st.useEffect(()=>{t.current&&l.init(t.current,e.current)},[t]),zt.jsxs(zt.Fragment,{children:[zt.jsx("div",{ref:e,className:"render-input"}),zt.jsx("input",{ref:t,className:"canvas-input"})]})};class gs{constructor(){p(this,"editTextWorker",new mo);p(this,"textInputWorker",new wr);p(this,"selectionDeleteWorker",new os)}computeNextCursorIndex(t,e){return t+e.length}handle(t,e,n,o){const{node:s,renderText:r,textCursorPosition:i}=t;e.execAction(new W);const a=e.inputManager.selectionManager.selectionInfo;if(a){this.selectionDeleteWorker.work(t,a,e);const{renderText:g,textCursorPosition:f}=e.inputManager.editTextInfo,{prev:y,next:P}=this.textInputWorker.getEditTextPrevNext(g,f),b=g.getIndexByTextCursorPos(f);o.prev=y,o.next=P,o.index=b}else e.execAction(ee.focus(s.id,i));const{updateTextProps:c,index:h}=this.computeUpdateTextProps(t,n,o);e.execAction(U.create(s.id,[c])),this.editTextWorker.modifyBaseProps(r,s,e);const d=this.computeNextCursorIndex(h,n),u=r.getTextCursorPosByIndex(d);e.execAction(ee.focus(s.id,u)),e.execAction(new z)}}class al extends gs{computeUpdateTextProps(t,e){const{renderText:n,textCursorPosition:o}=t,s=this.editTextWorker.editText(n,o,e),r=n.getIndexByTextCursorPos(o);return{updateTextProps:{type:I.Text,richText:s},index:r}}}class cl extends gs{computeUpdateTextProps(t,e,n){const{prev:o,next:s,index:r}=n;return{updateTextProps:{type:I.Text,richText:o+e+s},index:r}}}class ll extends gs{constructor(){super(...arguments);p(this,"graphemeSplit",new Ro)}computeUpdateTextProps(e,n,o){const{prev:s,next:r,index:i}=o;return{updateTextProps:{type:I.Text,richText:s+n+r},index:i}}computeNextCursorIndex(e,n){const o=this.graphemeSplit.split(n).length;return e+o}}class hl{constructor(t){p(this,"eventCtx");p(this,"duringComposition",!1);p(this,"compositionRecord",{prev:"",next:"",index:0});p(this,"textInputWorker",new wr);p(this,"normalInputHandler",new al);p(this,"compositionInputHandler",new cl);p(this,"compositionEndHandler",new ll);p(this,"compositionEnd",t=>{if(!this.onEnable()||!this.duringComposition)return;const e=this.eventCtx.inputManager.editTextInfo;if(!e)return;const n=t.data;this.compositionEndHandler.handle(e,this.eventCtx,n,this.compositionRecord),this.duringComposition=!1});p(this,"compositionStart",t=>{if(!this.onEnable())return;const e=this.eventCtx.inputManager.editTextInfo;if(!e)return;this.duringComposition=!0;const{renderText:n,textCursorPosition:o}=e,{prev:s,next:r}=this.textInputWorker.getEditTextPrevNext(n,o),i=n.getIndexByTextCursorPos(o);this.compositionRecord={prev:s,next:r,index:i}});p(this,"onKeyDown",t=>{if(!this.onEnable()||!t.data)return;const e=t.data;if(e==="")return;const n=this.eventCtx.inputManager.editTextInfo;if(n){if(this.duringComposition){this.compositionInputHandler.handle(n,this.eventCtx,e,this.compositionRecord);return}this.normalInputHandler.handle(n,this.eventCtx,e,this.compositionRecord)}});this.eventCtx=t}onEnable(){return this.eventCtx.docState.canEdit()}start(){var e;const t=(e=this.eventCtx.inputManager.renderInput)==null?void 0:e.inputDom;if(!t){console.error("input dom is not exist");return}t.addEventListener("input",this.onKeyDown),t.addEventListener("compositionstart",this.compositionStart),t.addEventListener("compositionend",this.compositionEnd)}stop(){var e;const t=(e=this.eventCtx.inputManager.renderInput)==null?void 0:e.inputDom;if(!t){console.error("input dom is not exist");return}t.removeEventListener("input",this.onKeyDown),t.removeEventListener("compositionstart",this.compositionStart),t.removeEventListener("compositionend",this.compositionEnd)}}class Lr{constructor(t){p(this,"eventCtx");p(this,"svgRedrawTimer",null);p(this,"onWheel",t=>{if(!this.onEnable(t))return;const e=this.eventCtx;if(t.target===e.gmlRender.canvas&&t.preventDefault(),t.ctrlKey){const n=e.gmlRender.canvas.getBoundingClientRect(),o=new m(t.clientX-n.x,t.clientY-n.y),s=e.gmlRender.transformToGlobal(o),r=t.deltaY,i=2*Math.abs(r)/100,a=r>0?1-i:1+i;this.eventCtx.renderManager.zoomScale(a,s),this.scaleRedrawSvg(e)}else this.eventCtx.renderManager.scroll(t.deltaX,t.deltaY);this.eventCtx.inputManager.refreshCursor(),this.eventCtx.refreshEvent()});this.eventCtx=t}start(){if(!this.eventCtx.renderManager.gmlRender.canvas){console.error("canvas 不存在,无法注册画布滚动时间");return}this.eventCtx.renderManager.gmlRender.canvas.addEventListener("wheel",this.onWheel,{passive:!1})}stop(){if(!this.eventCtx.renderManager.gmlRender.canvas){console.error("canvas 不存在,无法注册画布滚动时间");return}this.eventCtx.renderManager.gmlRender.canvas.removeEventListener("wheel",this.onWheel)}onEnable(t){return!0}scaleRedrawSvg(t){this.svgRedrawTimer&&(clearTimeout(this.svgRedrawTimer),this.svgRedrawTimer=null),this.svgRedrawTimer=setTimeout(()=>{for(const[e,n]of t.nodeManager.nodeMap)n.type===v.SVG&&t.asyncRenderNodeManager.addRenderNode(n)},100)}}class Yy{static scroll(t,e,n){const o=n.getScale();n.translation(-t/o,-e/o);const s=n.glCtx,{a:r,b:i,c:a,d:c,e:h,f:d}=n.globalTransform;s.setTransform(r,i,a,c,h,d)}static zoomScale(t,e,n){const o=2*Math.abs(t)/100,s=t>0?1-o:1+o;e.scale(s,s,n);const r=e.glCtx,{a:i,b:a,c,d:h,e:d,f:u}=e.globalTransform;r.setTransform(i,a,c,h,d,u)}static zoomRedraw(t,e,n){const o=t.canvas.getContext("2d"),{a:s,b:r,c:i,d:a,e:c,f:h}=t.globalTransform;o.setTransform(s,r,i,a,c,h),n.addContentRenderTask(),n.addAuxiliaryDrawTask()}static zoomToFit(t,e,n,o){const s=t.canvas.getContext("2d"),{a:r,b:i,c:a,d:c,e:h,f:d}=o;t.globalTransform.a=r,t.globalTransform.b=i,t.globalTransform.c=a,t.globalTransform.d=c,t.globalTransform.e=h,t.globalTransform.f=d,s.setTransform(r,i,a,c,h,d),n.renderManager.addContentRenderTask()}}class Cr{constructor(t){p(this,"eventCtx");p(this,"onResize",()=>{this.eventCtx.resizeWorker.resize(this.eventCtx)});this.eventCtx=t}start(){window.addEventListener("resize",this.onResize)}stop(){window.removeEventListener("resize",this.onResize)}onEnable(t){return!0}}class Ar{constructor(t){p(this,"keyMap",new Map);this.keyMap=t}getKey(t){const e=this.keyMap.get(t.code);if(!e)return null;const o=pi.getOS()===Jt.MacOS;for(const s of e)if(s.enable(t,o))return s;return null}}class Pe{keyDown(t,e){this.work(t,e)}keyUp(t,e){}shouldPreventDefault(){return!0}isPressMetaKey(t,e){return e?t.metaKey:t.ctrlKey}}var J=(l=>(l.Enter="Enter",l.Escape="Escape",l.Backspace="Backspace",l.Delete="Delete",l.Space="Space",l.ArrowLeft="ArrowLeft",l.ArrowRight="ArrowRight",l.ArrowUp="ArrowUp",l.ArrowDown="ArrowDown",l.Digit1="Digit1",l.Digit2="Digit2",l.Digit3="Digit3",l.Digit4="Digit4",l.Digit5="Digit5",l.Digit6="Digit6",l.Digit7="Digit7",l.Digit8="Digit8",l.Digit9="Digit9",l.Digit0="Digit0",l.KeyA="KeyA",l.KeyB="KeyB",l.KeyC="KeyC",l.KeyD="KeyD",l.KeyE="KeyE",l.KeyF="KeyF",l.KeyG="KeyG",l.KeyH="KeyH",l.KeyI="KeyI",l.KeyJ="KeyJ",l.KeyK="KeyK",l.KeyL="KeyL",l.KeyM="KeyM",l.KeyN="KeyN",l.KeyO="KeyO",l.KeyP="KeyP",l.KeyQ="KeyQ",l.KeyR="KeyR",l.KeyS="KeyS",l.KeyT="KeyT",l.KeyU="KeyU",l.KeyV="KeyV",l.KeyW="KeyW",l.KeyX="KeyX",l.KeyY="KeyY",l.KeyZ="KeyZ",l.Tab="Tab",l.ShiftLeft="ShiftLeft",l.ShiftRight="ShiftRight",l.BracketRight="BracketRight",l.BracketLeft="BracketLeft",l))(J||{});class Gy{constructor(){p(this,"cursorMoveWorker",new ho)}work(t,e){const{node:n,renderText:o,textCursorPosition:s}=t,{updateTextProps:r}=this.computeUpdateTextProps(t);e.execAction(new W),e.execAction(U.create(n.id,[r]));const i=this.cursorMoveWorker.moveRight(o,s);e.execAction(ee.focus(n.id,i)),e.execAction(new z)}computeUpdateTextProps(t){const{renderText:e,textCursorPosition:n}=t,o=this.lineBreak(e,n);return{updateTextProps:{type:I.Text,richText:o}}}lineBreak(t,e){const{paragraphIndex:n,lineIndex:o,charIndex:s}=e,r=t.prevParagraphToXML(n),i=t.nextParagraphToXML(n),a=t.getParagraph(n);if(!a)return"<root><p></p><p></p></root>";const c=a.getLine(o);if(!c){const Z=a.toRichTextXML(t.textProps);return`<root>${r}${Z}<p></p>${i}</root>`}const h=a.prevToRichTextXML(o,t.textProps),d=a.nextToRichTextXML(o,t.textProps),u=c.getBlockIndex(s);if(!u){const Z=`<p>${h}</p>`,se=`<p>${d}</p>`;return`<root>${r}${Z}${se}${i}</root>`}const{textBlock:g,blockIndex:f,charIndex:y}=u,P=c.prevToRichTextXML(f,t.textProps),b=c.nextToRichTextXML(f,t.textProps),w=g.getPrevText(y),L=g.getNextText(y),B=g.computeStyle(t.textProps),H=w?`<style ${B}>${w}</style>`:"",E=L?`<style ${B}>${L}</style>`:"",X=`<p>${h}${P}${H}</p>`,$=`<p>${E}${b}${d}</p>`;return`<root>${r}${X}${$}${i}</root>`}}class Uy{addParagraph(t,e,n){const o=t.getProp(I.TextParagraph).clone(),s=o.paragraphStyles;for(const i of s)i.paraIndex>e&&i.paraIndex++;const r=M.getParaStyle(o,e);if(r){const i={level:r.level,orderIndex:r.orderIndex,paraIndex:e+1};s.push(i),n.execAction(U.create(t.id,[{type:I.TextParagraph,paragraphStyles:s}]))}}}let dl=class extends Pe{constructor(){super(...arguments);p(this,"styleWorker",new Uy);p(this,"type",J.Enter);p(this,"editTextWorker",new mo);p(this,"selectionDeleteWorker",new os);p(this,"lineBreakWorker",new Gy)}enable(e){return!0}work(e,n){const o=n.inputManager.editTextInfo;if(!o)return;const{node:s,renderText:r}=o;let i=o.textCursorPosition;const a=n.inputManager.selectionManager.selectionInfo;n.execAction(new W),a?(this.selectionDeleteWorker.work(o,a,n),i=n.inputManager.editTextInfo.textCursorPosition):n.execAction(ee.focus(s.id,i));const c=i.paragraphIndex;this.styleWorker.addParagraph(s,c,n);const h=this.lineBreakWorker.lineBreak(r,i),d=r.getIndexByTextCursorPos(i),u={type:I.Text,richText:h};n.execAction(U.create(s.id,[u])),this.editTextWorker.modifyBaseProps(r,s,n);const g=d+1,f=r.getTextCursorPosByIndex(g);n.execAction(ee.focus(s.id,f)),n.execAction(new z)}};class ul extends Pe{constructor(){super(...arguments);p(this,"type",J.Backspace);p(this,"editTextWorker",new mo);p(this,"graphemeSplit",new Ro);p(this,"selectionDeleteWorker",new os)}enable(e){return!0}work(e,n){const o=n.inputManager.editTextInfo;if(!o)return;const s=n.inputManager.selectionManager.selectionInfo;if(s){n.execAction(new W),this.selectionDeleteWorker.work(o,s,n),n.execAction(new z);return}const{node:r,renderText:i,textCursorPosition:a}=o,c=a.paragraphIndex;if(a.lineIndex===0&&a.charIndex===-1){const P=r.getProp(I.TextParagraph).clone(),b=M.getParaStyle(P,c),w=P.paragraphStyles;if(b){if(b.level>0){b.level--,n.execAction(new W),n.execAction(U.create(r.id,[{type:I.TextParagraph,paragraphStyles:w}])),n.execAction(ee.focus(r.id,a)),n.execAction(new z);return}const L=w.findIndex(B=>B===b);w.splice(L,1),n.execAction(new W),n.execAction(U.create(r.id,[{type:I.TextParagraph,paragraphStyles:w}])),n.execAction(ee.focus(r.id,a)),n.execAction(new z);return}}const d=new fc().deleteText(i,a,1),u={type:I.Text,richText:d},g=i.getIndexByTextCursorPos(a);n.execAction(new W),n.execAction(ee.focus(r.id,a)),n.execAction(U.create(r.id,[u])),this.editTextWorker.modifyBaseProps(i,r,n);const f=g-1,y=i.getTextCursorPosByIndex(f);n.execAction(ee.focus(r.id,y)),n.execAction(new z)}}class No extends Pe{constructor(){super(...arguments);p(this,"cursorMoveWorker",new ho)}enable(e){return!0}work(e,n){const o=n.inputManager.editTextInfo;if(!o)return;const{renderText:s,textCursorPosition:r,node:i}=o,a=this.moveCursor(s,r,n);n.execAction(new W),n.execAction(ee.focus(i.id,a)),n.execAction(new z)}}let pl=class extends No{constructor(){super(...arguments);p(this,"type",J.ArrowRight)}moveCursor(e,n,o){const s=o.inputManager.selectionManager.selectionInfo;if(s){const{end:r}=s;return r}return this.cursorMoveWorker.moveRight(e,n)}},gl=class extends No{constructor(){super(...arguments);p(this,"type",J.ArrowLeft)}moveCursor(e,n){return this.cursorMoveWorker.moveLeft(e,n)}},fl=class extends No{constructor(){super(...arguments);p(this,"type",J.ArrowRight)}moveCursor(e,n){return this.cursorMoveWorker.moveUp(e,n)}},yl=class extends No{constructor(){super(...arguments);p(this,"type",J.ArrowDown)}moveCursor(e,n){return this.cursorMoveWorker.moveDown(e,n)}};class kr extends Pe{constructor(){super(...arguments);p(this,"type",J.KeyZ)}work(e,n){n.actionManager.redo()}enable(e,n){return e.shiftKey&&this.isPressMetaKey(e,n)}}class Nr extends Pe{constructor(){super(...arguments);p(this,"type",J.KeyZ)}work(e,n){n.actionManager.undo()}enable(e,n){return this.isPressMetaKey(e,n)}}let _y=class extends Pe{constructor(){super(...arguments);p(this,"type",J.KeyA)}enable(e,n){return this.isPressMetaKey(e,n)}work(e,n){const o=n.inputManager.editTextInfo;if(!o)return;const{node:s,textCursorPosition:r,renderText:i}=o;n.execAction(new W),n.execAction(ee.selection(s.id,i.headTextCursorPosition(),i.tailTextCursorPosition())),n.execAction(new z)}};class $y extends Pe{constructor(){super(...arguments);p(this,"type",J.Tab)}enable(e,n){return!0}work(e,n){const o=n.inputManager.editTextInfo;if(!o)return;const{node:s,textCursorPosition:r}=o,i=r.paragraphIndex,a=s.getProp(I.TextParagraph).clone(),c=M.getParaStyle(a,i);if(!c)return;c.level++;const h=a.paragraphStyles;n.execAction(new W),n.execAction(ee.focus(s.id,r)),n.execAction(U.create(s.id,[{type:I.TextParagraph,paragraphStyles:h}])),n.execAction(ee.focus(s.id,r)),n.execAction(new z)}}let jy=class extends Pe{constructor(){super(...arguments);p(this,"type",J.Escape)}enable(e){return!0}work(e,n){const{editTextInfo:o}=n.inputManager;o&&(n.execAction(new W),n.execAction(ee.blur(o.node.id)),n.execAction(new z),n.auxiliaryManager.selectManager.refreshSelectStatus())}};const xl=new Map([[J.Enter,[new dl]],[J.Escape,[new jy]],[J.Backspace,[new ul]],[J.ArrowRight,[new pl]],[J.ArrowLeft,[new gl]],[J.ArrowUp,[new fl]],[J.ArrowDown,[new yl]],[J.KeyA,[new _y]],[J.KeyZ,[new kr,new Nr]],[J.Tab,[new $y]]]);class wl extends Pe{constructor(){super(...arguments);p(this,"type",J.Delete);p(this,"worker",new So)}work(e,n){this.worker.work(n)}enable(e){return!0}}class ml extends Pe{constructor(){super(...arguments);p(this,"type",J.KeyR)}work(e,n){n.toolManager.setCurrentTool(ye.SHAPE,K.RoundRect),n.setCursor("crosshair"),n.previewManager.addPreviewNode(n),n.refreshEvent()}enable(e){return!0}}class Pl extends Pe{constructor(){super(...arguments);p(this,"type",J.Escape)}enable(e){return!0}work(e,n){if(n.cropManager.duringCrop){n.cropManager.exitCrop(),n.auxiliaryManager.selectManager.refreshSelectStatus(),n.renderManager.addAuxiliaryDrawTask();return}n.previewManager.resetPreviewNode(n),n.toolManager.setCurrentTool(ye.DEFAULT),n.setCursor("default"),n.refreshEvent()}}class bl extends Pe{constructor(){super(...arguments);p(this,"type",J.KeyT)}work(e,n){n.toolManager.setCurrentTool(ye.TEXT,K.PureText),n.setCursor("text")}enable(e){return!0}}class Ml extends Pe{constructor(){super(...arguments);p(this,"type",J.KeyR)}work(e,n){n.toolManager.setCurrentTool(ye.LINE,de.Line),n.setCursor("crosshair")}enable(e){return!0}}class Vy extends Pe{constructor(){super(...arguments);p(this,"type",J.KeyC)}enable(e){return!0}work(e,n){n.toolManager.setCurrentTool(ye.LINE,de.Curve),n.setCursor("crosshair")}}class Ky extends Pe{constructor(){super(...arguments);p(this,"type",J.KeyA)}enable(e){return!0}work(e,n){n.toolManager.setCurrentTool(ye.LINE,de.RoundPolyLine),n.setCursor("crosshair")}}class Qy extends Pe{constructor(){super(...arguments);p(this,"type",J.KeyS)}work(e,n){n.toolManager.setCurrentTool(ye.SHAPE,K.Rect),n.setCursor("crosshair"),n.previewManager.addPreviewNode(n),n.refreshEvent()}enable(e){return!0}}class Zy extends Pe{constructor(){super(...arguments);p(this,"type",J.KeyC)}enable(e,n){return this.isPressMetaKey(e,n)}work(e,n){}shouldPreventDefault(){return!1}}class qy extends Pe{constructor(){super(...arguments);p(this,"type",J.KeyV)}enable(e,n){return this.isPressMetaKey(e,n)}work(e,n){}shouldPreventDefault(){return!1}}class Jy extends Pe{constructor(){super(...arguments);p(this,"duplicateWorker",new Zs);p(this,"type",J.KeyD)}enable(e,n){return this.isPressMetaKey(e,n)}work(e,n){e.preventDefault(),n.execAction(new W),this.duplicateWorker.work(n),n.execAction(new z)}}class ex extends Pe{constructor(){super(...arguments);p(this,"type",J.KeyA)}enable(e,n){return this.isPressMetaKey(e,n)}work(e,n){const o=[...n.nodeManager.root.children];if(o.length===0)return;const s=o.map(r=>r.id);n.execAction(new W),n.execAction(xe.create(s)),n.execAction(new z)}}class tx extends Pe{constructor(){super(...arguments);p(this,"type",J.BracketLeft);p(this,"moveLayerWorker",new xo)}enable(e,n){return this.isPressMetaKey(e,n)}work(e,n){this.moveLayerWorker.moveBackward(n)}}class nx extends Pe{constructor(){super(...arguments);p(this,"type",J.BracketRight);p(this,"moveLayerWorker",new xo)}enable(e,n){return this.isPressMetaKey(e,n)}work(e,n){this.moveLayerWorker.moveForward(n)}}class ox extends Pe{constructor(){super(...arguments);p(this,"type",J.BracketLeft);p(this,"moveLayerWorker",new xo)}enable(e,n){return e.altKey&&this.isPressMetaKey(e,n)}work(e,n){this.moveLayerWorker.moveToBack(n)}}class sx extends Pe{constructor(){super(...arguments);p(this,"type",J.BracketRight);p(this,"moveLayerWorker",new xo)}enable(e,n){return e.altKey&&this.isPressMetaKey(e,n)}work(e,n){this.moveLayerWorker.moveToUp(n)}}class rx extends Pe{constructor(){super(...arguments);p(this,"type",J.KeyF)}work(e,n){n.toolManager.setCurrentTool(ye.SECTION),n.setCursor("crosshair"),n.previewManager.addPreviewNode(n),n.refreshEvent()}enable(e){return!0}}class ix extends Pe{constructor(){super(...arguments);p(this,"type",J.KeyG);p(this,"worker",new ls)}work(e,n){const o=[...n.getSelectNodes()];this.worker.group(o,n)}enable(e,n){return this.isPressMetaKey(e,n)}}class ax extends Pe{constructor(){super(...arguments);p(this,"type",J.KeyG);p(this,"worker",new ls)}work(e,n){const o=[...n.getSelectNodes()];if(o.length!==1)return;const s=o[0];if(s.type!==v.Group)return;const r=s;this.worker.unGroup(r,n)}enable(e,n){return this.isPressMetaKey(e,n)&&e.shiftKey}}class cx extends Pe{constructor(){super(...arguments);p(this,"type",J.Space)}enable(e){return!0}work(e,n){n.toolManager.setCurrentTool(ye.HandTool),n.refreshEvent()}keyUp(e,n){n.toolManager.resetTool(),n.refreshEvent()}}class lx extends Pe{constructor(){super(...arguments);p(this,"type",J.Backspace);p(this,"worker",new So)}work(e,n){this.worker.work(n)}enable(e){return!0}}class hx extends Pe{constructor(){super(...arguments);p(this,"type",J.KeyC);p(this,"worker",new wo)}enable(e,n){return this.isPressMetaKey(e,n)&&e.shiftKey}work(e,n){const o=n.getSelectNodes();o.size!==1||[...o][0].type!==v.IMG||(e.preventDefault(),this.worker.intoCrop(n))}}class dx extends Pe{constructor(){super(...arguments);p(this,"type",J.KeyH)}work(e,n){n.toolManager.setCurrentTool(ye.HandTool),n.setCursor("grab"),n.refreshEvent()}enable(e){return!0}}class ux extends Pe{constructor(){super(...arguments);p(this,"type",J.Digit1)}work(e,n){n.renderManager.zoomToFit(),n.refreshAllSvgNode()}enable(e){return e.shiftKey}}class px extends Pe{constructor(){super(...arguments);p(this,"type",J.Digit2)}work(e,n){n.renderManager.zoomToSelect()}enable(e){return e.shiftKey}}class gx extends Pe{constructor(){super(...arguments);p(this,"type",J.Digit3)}work(e,n){n.renderManager.zoomTo100()}enable(e){return e.shiftKey}}class Sl extends Pe{constructor(){super(...arguments);p(this,"type",J.ShiftLeft)}enable(e,n){return!0}work(e,n){const o=M.getMockEventModifierInit(e);n.refreshEvent(o)}keyUp(e,n){this.work(e,n)}}class fs{constructor(){p(this,"groupBaseWorker",new on);p(this,"layoutWorker",new Rn);p(this,"handlerCtx",new va([new ga,new Sa,new fa]))}work(t,e,n){const o=this.computeMoveNodes(t);if(o.length===0)return;this.groupBaseWorker.start(o);const s=new Set;this.batchCollectNodeLinks(o,t,s),t.execAction(new W);const r={x:e,y:n},i=[];for(const a of o){const c=this.handlerCtx.handle(a,r);i.push(...c)}t.execAction(new U({infos:i})),this.groupBaseWorker.work(t,!1),this.layoutWorker.work([...s],t,!1),t.execAction(new z)}batchCollectNodeLinks(t,e,n){const o=e.getSelectNodes();for(const s of t)this.collectNodeLinks(s,e,o,n)}collectNodeLinks(t,e,n,o){const s=e.nodeManager.getNodeLinks(t);for(const r of s)n.has(r)||o.add(r);for(const r of t.children)r.type!==v.Line&&this.collectNodeLinks(r,e,n,o)}computeMoveNodes(t){const e=t.getSelectNodes(),n=new Map;e.forEach(s=>n.set(s.id,s));const o=[];for(const s of e)if(s.type===v.Line){const r=s,{start:i,end:a}=r.connectProps;if(i&&a&&n.has(i.objectId)&&n.has(a.objectId)){o.push(s);continue}if(!i&&a&&n.has(a.objectId)){o.push(s);continue}if(!a&&i&&n.has(i.objectId)){o.push(s);continue}!a&&!i&&o.push(s)}else o.push(s);return o}}class fx extends Pe{constructor(){super(...arguments);p(this,"type",J.ArrowRight);p(this,"worker",new fs)}enable(e,n){return!0}work(e,n){const o=n.docState.docMode;if((o===he.SLIDE_EDIT||o===he.SLIDE_PLAY)&&n.getSelectNodes().size===0){const i=n.docState.slideStatus.currentIndex+1;n.slideManager.jumpToWhenEditing(i,n);return}const s=e.shiftKey?15:1;this.worker.work(n,s,0)}}class yx extends Pe{constructor(){super(...arguments);p(this,"type",J.ArrowLeft);p(this,"worker",new fs)}enable(e,n){return!0}work(e,n){const o=n.docState.docMode;if((o===he.SLIDE_EDIT||o===he.SLIDE_PLAY)&&n.getSelectNodes().size===0){const i=n.docState.slideStatus.currentIndex-1;n.slideManager.jumpToWhenEditing(i,n);return}const s=e.shiftKey?15:1;this.worker.work(n,-s,0)}}class xx extends Pe{constructor(){super(...arguments);p(this,"type",J.ArrowUp);p(this,"worker",new fs)}enable(e,n){return!0}work(e,n){const o=n.docState.docMode;if((o===he.SLIDE_EDIT||o===he.SLIDE_PLAY)&&n.getSelectNodes().size===0){const i=n.docState.slideStatus.currentIndex-1;n.slideManager.jumpToWhenEditing(i,n);return}const s=e.shiftKey?15:1;this.worker.work(n,0,-s)}}class wx extends Pe{constructor(){super(...arguments);p(this,"type",J.ArrowDown);p(this,"worker",new fs)}enable(e,n){return!0}work(e,n){const o=n.docState.docMode;if((o===he.SLIDE_EDIT||o===he.SLIDE_PLAY)&&n.getSelectNodes().size===0){const i=n.docState.slideStatus.currentIndex+1;n.slideManager.jumpToWhenEditing(i,n);return}const s=e.shiftKey?15:1;this.worker.work(n,0,s)}}class mx extends Pe{constructor(){super(...arguments);p(this,"type",J.Enter)}enable(e){return!0}work(e,n){const o=[...n.getSelectNodes()];if(o.length!==1)return;const s=o[0];if(s.type===v.SlideContainer||s.type===v.Section){const i=[...s.children].map(a=>a.id);n.execAction(new W),n.execAction(xe.create(i)),n.execAction(new z);return}(s.type===v.Shape||s.type===v.CheckboxText)&&this.focusSelectionText(s,n)}focusSelectionText(e,n){if(e.isEmptyText()){n.execAction(new W);const o=Fe.head();n.execAction(ee.focus(e.id,o)),n.execAction(new z);return}n.execAction(new W),n.execAction(ee.selection(e.id,Fe.head(),e.renderText.tailTextCursorPosition())),n.execAction(new z)}}const vl=new Map([[J.Delete,[new wl]],[J.Backspace,[new lx]],[J.ArrowRight,[new fx]],[J.ArrowLeft,[new yx]],[J.ArrowUp,[new xx]],[J.ArrowDown,[new wx]],[J.Digit1,[new ux]],[J.Digit2,[new px]],[J.Digit3,[new gx]],[J.KeyA,[new ex,new Ky]],[J.KeyC,[new hx,new Zy,new Vy]],[J.KeyD,[new Jy]],[J.KeyF,[new rx]],[J.KeyV,[new qy]],[J.KeyL,[new Ml]],[J.KeyS,[new Qy]],[J.KeyR,[new ml]],[J.KeyT,[new bl]],[J.KeyH,[new dx]],[J.KeyZ,[new kr,new Nr]],[J.KeyG,[new ax,new ix]],[J.Escape,[new Pl]],[J.Space,[new cx]],[J.ShiftLeft,[new Sl]],[J.ShiftRight,[new Sl]],[J.BracketLeft,[new ox,new tx]],[J.BracketRight,[new sx,new nx]],[J.Enter,[new mx]]]);class Il{constructor(t){p(this,"textConfig");p(this,"normalConfig");p(this,"context");this.context=t,this.textConfig=new Ar(xl),this.normalConfig=new Ar(vl)}keyDown(t,e){const n=this.getHotKey(t);n&&(n.shouldPreventDefault()&&(t.preventDefault(),t.stopPropagation()),n.keyDown(t,e))}keyUp(t,e){const n=this.getHotKey(t);n&&(n.shouldPreventDefault()&&(t.preventDefault(),t.stopPropagation()),n.keyUp(t,e))}getHotKey(t){return this.context.inputManager.isEdit()?this.textConfig.getKey(t):this.normalConfig.getKey(t)}}class Tl{constructor(t){p(this,"eventCtx");p(this,"hotKeyManager");p(this,"onKeyDown",t=>{this.onEnable(t)&&this.hotKeyManager.keyDown(t,this.eventCtx)});p(this,"onKeyUp",t=>{this.onEnable(t)&&this.hotKeyManager.keyUp(t,this.eventCtx)});this.eventCtx=t,this.hotKeyManager=new Il(t)}start(){document.addEventListener("keydown",this.onKeyDown,!0),document.addEventListener("keyup",this.onKeyUp,!0)}stop(){document.removeEventListener("keydown",this.onKeyDown,!0),document.removeEventListener("keyup",this.onKeyUp,!0)}onEnable(t){return this.eventCtx.docState.canEdit()?t.target===this.eventCtx.inputManager.renderInput.inputDom?!0:!(t.target instanceof HTMLInputElement||t.target instanceof HTMLTextAreaElement):!1}}class Px{constructor(t){p(this,"ctx");this.ctx=t,t.actionManager.addNetworkPlugin(this)}addMessage(t){}addActionGroup(t){}initWebsocket(){}start(){}stop(){}onEnable(t){return!0}}class bx{static getOolongApp(){const t=new hr,e=new vr(t),n=e.appContext,o=new Wo(n,t),s=new Lr(n),r=new hl(n),i=new Tl(n),a=new Cr(n),c=new Uc(n);return e.registerPlugin(o),e.registerPlugin(s),e.registerPlugin(r),e.registerPlugin(i),e.registerPlugin(a),e.registerPlugin(c),e}static getReadOnlyApp(){const t=new hr,e=new vr(t),n=e.appContext,o=new Wo(n,t),s=new Lr(n),r=new Cr(n);return e.registerPlugin(o),e.registerPlugin(s),e.registerPlugin(r),e}}T.ANCHOR_COLOR=_r,T.ANCHOR_HOVER_RADIUS=Ss,T.ANCHOR_OFFSET=Yr,T.ANCHOR_RADIUS=Gr,T.AbsActionExecutor=hn,T.AbsActionLog=yn,T.AbsAlignHandler=An,T.AbsAlignSideHandler=$s,T.AbsArrowKey=No,T.AbsAuxGraphic=Se,T.AbsCreateDragProcessor=Qo,T.AbsDetector=Ke,T.AbsDrawer=mt,T.AbsInputHandler=gs,T.AbsInteractConfig=oa,T.AbsMainMode=gn,T.AbsNetworkPlugin=zl,T.AbsNodeManager=Zc,T.AbsPastePosHandler=xr,T.AbsProps=ct,T.AbsResourceInstance=nl,T.AbsStatusHandler=bt,T.AbsStretchProcessor=Go,T.AbsSubMode=Ot,T.AbsTextSelectionHandler=ss,T.ActionCache=Rc,T.ActionLogGroup=as,T.ActionManager=Hc,T.ActionMeta=gc,T.ActionType=Xe,T.AddExecutor=Mc,T.AddNodeLog=Le,T.AffineMatrix=re,T.AlignBottomHandler=Ki,T.AlignHeightSideHandler=ea,T.AlignLeftHandler=Qi,T.AlignLine=oi,T.AlignMoveWorker=qi,T.AlignRightHandler=Zi,T.AlignStretchLine=si,T.AlignStretchWorker=ta,T.AlignTopHandler=Vi,T.AlignWidthSideHandler=Ji,T.AlignWorker=un,T.AppEventContext=zc,T.AppStage=bx,T.ArrowDownKey=yl,T.ArrowLeftKey=gl,T.ArrowProps=lt,T.ArrowRightKey=pl,T.ArrowUpKey=fl,T.AuxGraphicFactory=vs,T.AuxUtils=Jr,T.AuxiliaryManager=di,T.AuxiliaryType=N,T.BLOCK_COLOR=bs,T.BaseProps=ie,T.BorderProps=Ae,T.CanvasConfig=Oy,T.CanvasContainer=Wy,T.CanvasInput=Fy,T.CanvasRender=Pr,T.CheckSizeProps=vn,T.CheckStatusProps=Qt,T.ClearFocusNodeHandler=or,T.ClickExpandShapeHandler=Na,T.ClickHandler=qe,T.ClickMode=pn,T.ClickProcessor=jt,T.ClickTextHandler=ka,T.CollaborationManager=Ah,T.ColorProps=tt,T.ConnectProps=Rt,T.ConnectorPoint=Wl,T.ControlPoint=Fl,T.CopyPasteManager=Gc,T.CopyPastePlugin=Uc,T.CopyPasteUtils=xn,T.CreateLineMode=pc,T.CreateRectBound=ti,T.CreateRectMode=sc,T.CreateTextMode=ic,T.CropProps=Sn,T.CursorProcessor=Ua,T.DHPCanvas=Tr,T.DbClickMode=js,T.DefaultBorderColorShape=Tg,T.DefaultClickMode=Ha,T.DefaultClickProcessor=Ea,T.DefaultColorShape=Ig,T.DefaultFont=Ad,T.DefaultLineHeight=Ed,T.DefaultMode=ec,T.DeleteKey=wl,T.DetectorEnum=F,T.DiffParaHandler=yc,T.DocMode=he,T.DocState=Kc,T.DownAndMoveStreamMode=dt,T.DragLineEndProcessor=Va,T.DragMode=Ta,T.DragProcessor=Ia,T.DragSelectTextMode=aa,T.DragSelectTextProcessor=ia,T.EditTextWorker=mo,T.EmptyNetworkPlugin=Px,T.EmptyPlacePosHandler=Yc,T.EndExecutor=Lc,T.EndLog=z,T.EnterHotKey=dl,T.EscKey=Pl,T.ExecutorManager=Nc,T.ExpandDetector=tc,T.ExpandShapeButton=ni,T.FocusEnum=Lt,T.FocusNodeHandler=tr,T.GRAY_COLOR=Ur,T.GraphemeSplit=Ro,T.GraphicNode=en,T.GraphicUtils=M,T.GroupMode=qs,T.GroupProcessor=Ca,T.HOVER_ANCHOR_COLOR=$r,T.HOVER_BOUND_COLOR=Gt,T.HighlightRects=Qr,T.HotKey=Pe,T.HotKeyConfig=Ar,T.HotKeyManager=Il,T.HoverBound=jr,T.HoverNodeDetector=ra,T.HoverProcessor=Wa,T.ImageUtils=Pc,T.InputCompositionEndHandler=ll,T.InputCompositionHandler=cl,T.InputEventPlugin=hl,T.InputNormalHandler=al,T.InteractConfig=hr,T.InteractiveEventType=be,T.InteractiveManager=ji,T.InteractiveUtils=Ze,T.IntlSplit=wc,T.KeyCode=J,T.KeyEventPlugin=Tl,T.LKey=Ml,T.LineArrowType=it,T.LineCreateDragProcessor=uc,T.LineDashType=et,T.LineEndPointDetector=nc,T.LineProps=je,T.LineShapeType=de,T.LineSpacing=kd,T.LinkNode=Bo,T.MAX_SCALE=yr,T.MIN_SCALE=fr,T.MOVE_ALIGN_BUFFER=Ys,T.MainTextId=Rd,T.MeasureWorker=Ng,T.MobileUtils=Dc,T.MoveLayerWorker=xo,T.MultiSelectBound=Kr,T.MultiSelectHandler=ci,T.NodeDetector=sa,T.NodeFactory=It,T.NodeManager=el,T.NodeSideEnum=Xr,T.NodeTextPadding=le,T.NodeType=v,T.NormalMode=_a,T.NormalPastePosHandler=Fc,T.NormalResourceInstance=ol,T.OolongAIAPI=Vc,T.OolongAPI=jc,T.OolongApp=vr,T.OolongGroup=Po,T.OolongImgNode=Yn,T.OolongLine=Ct,T.OolongNode=vt,T.OolongSVGNode=jn,T.OolongSVGUtils=an,T.OptionHelper=ii,T.PREVIEW_ROOT_ID=zr,T.ParagraphSpacing=Nd,T.PasteNodeHandler=cs,T.Permission=mr,T.Point=m,T.PointerEventPlugin=Wo,T.PolyLineControlPointDetector=dc,T.PosPasteType=Kt,T.PropType=I,T.QuadBezierCurve=Yl,T.RKey=ml,T.ROOT_ID=Mn,T.Rect=D,T.RectCreateDragProcessor=oc,T.RedoKey=kr,T.RemoveExecutor=Sc,T.RemoveNodeLog=At,T.RenderManager=Oc,T.RenderText=uo,T.ResourceEnumType=fo,T.ResourceManager=sl,T.ResourceType=zn,T.RootNode=pr,T.RotateDetector=Jo,T.RotateMode=Qa,T.RotateProcessor=Ka,T.SELECT_BOUND_COLOR=Qe,T.SELECT_GROUP_COLOR=Ms,T.SLIDE_X_GAP=nt,T.SLIDE_Y_GAP=xt,T.STRETCH_ALIGN_BUFFER=Gs,T.STRETCH_ALIGN_OFFSET=Us,T.STRETCH_WIDTH=Fr,T.SameParaDiffLineHandler=ur,T.SameParaSameLineHandler=dr,T.SectionType=Nn,T.SelectGroup=Zr,T.SelectManager=hi,T.SelectNodeExecutor=Ic,T.SelectNodeLog=xe,T.ShapeProps=Oe,T.ShapeType=K,T.ShiftDownNodeHandler=er,T.ShiftUpClickHandler=nr,T.SingleSelectBound=Vr,T.SingleStatusHandler=ai,T.SingleStretchMode=pa,T.SingleStretchProcessorV2=ua,T.SlotKeyType=ze,T.SlotManager=li,T.StartExecutor=Tc,T.StartLog=W,T.StreamMode=kn,T.StreamProcessor=ht,T.StretchAlignType=_e,T.StretchDetector=Fo,T.StretchHotBuffer=Th,T.StretchMode=ja,T.StretchProcessorV2=$a,T.StretchRect=ei,T.StretchType=V,T.TEXT_QUOTE_ALPHA=Ui,T.TEXT_QUOTE_LINE_WIDTH=Oo,T.TEXT_QUOTE_PADDING=Gi,T.TEXT_SELECTION_COLOR=Wr,T.TKey=bl,T.TextAlignType=at,T.TextCharacter=As,T.TextCreateDragProcessor=rc,T.TextCursorMoveWorker=ho,T.TextCursorPosition=Fe,T.TextDeleteKey=ul,T.TextFocusExecutor=Cc,T.TextFocusLog=ee,T.TextLine=Gn,T.TextParagraph=Cs,T.TextParagraphProps=qt,T.TextParagraphQuoteProps=Dt,T.TextProps=Ge,T.TextSelection=qr,T.TextSelectionDeleteWorker=os,T.TextSelectionWorker=xc,T.TextSizeMode=We,T.TextUtils=sn,T.TextWord=_i,T.ToolEnum=ye,T.ToolManager=Fa,T.UndoKey=Nr,T.UndoRedoManager=Bc,T.UpdateExecutor=vc,T.UpdateNodeLog=U,T.VisibleBuffer=Hd,T.WHITE_COLOR=Ht,T.WheelEventPlugin=Lr,T.WheelUtils=Yy,T.WidgetEnum=_n,T.WindowResizePlugin=Cr,T.actionExecutors=Ac,T.convertAction2MsgData=rf,T.convertActionData2Log=af,T.disableAlignNodeType=Cn,T.disableAlignSideSet=_s,T.graphemeSplitter=Eo,T.intlSplitter=Bg,T.isContains=Lg,T.limitLineWidth=Bd,T.normalKeyMap=vl,T.textKeyMap=xl,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})});
|