@fgbg/mdocs 1.1.0 → 1.1.2
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/agent-skills/changelog/SKILL.md +18 -0
- package/dist/server/routes/assets.routes.js +9 -4
- package/dist/server/routes/assets.routes.js.map +1 -1
- package/dist/server/routes/assets.routes.upload.test.js +1 -0
- package/dist/server/routes/assets.routes.upload.test.js.map +1 -1
- package/dist/web/assets/{AgentChatPanel-C8TMWDuE.js → AgentChatPanel-Bt38gm3b.js} +2 -2
- package/dist/web/assets/{AgentSkillFormCard-yk7PWF0W.js → AgentSkillFormCard-CtfWIf7Y.js} +1 -1
- package/dist/web/assets/AiWriteWorkbench-Boie5E_-.js +7 -0
- package/dist/web/assets/{DiagramEditor-NtNY3sZL-Bw4wHaBD.js → DiagramEditor-NtNY3sZL-CZy-tmEe.js} +1 -1
- package/dist/web/assets/DocumentEditor-1A6lpvV-.js +26 -0
- package/dist/web/assets/{MergeView-royv5YkB.js → MergeView-Dip0aW7s.js} +1 -1
- package/dist/web/assets/PlaygroundPage-C4X6Lj-Q.js +8 -0
- package/dist/web/assets/{SettingsPage-D8HfepZ8.js → SettingsPage-nlnmzNZK.js} +1 -1
- package/dist/web/assets/{Toolbar-BDJ6WABq.js → Toolbar-BHLX-ug4.js} +2 -2
- package/dist/web/assets/{VisitorPickerModal-DPKIoySi.js → VisitorPickerModal-BPyEWlQo.js} +1 -1
- package/dist/web/assets/{copy-UwfRYkpI.js → copy-BE64wQqi.js} +1 -1
- package/dist/web/assets/diagram-CT58wBdU.js +5772 -0
- package/dist/web/assets/{editor-ONzd_YnO.js → editor-CL03se2B.js} +1 -1
- package/dist/web/assets/{index-4TuRcE3b.js → index-BkKvQv2F.js} +24 -24
- package/dist/web/assets/index-DKshvHIN.css +1 -0
- package/dist/web/assets/{meta2d-D3b5RRN8.js → meta2d-1-g23JOU.js} +1 -1
- package/dist/web/assets/{meta2dEngine-BD2XbzaV-D1J2-XNv.js → meta2dEngine-BD2XbzaV-z-eR7E_V.js} +1 -1
- package/dist/web/assets/{motion-DddvD-ez.js → motion-DX3HNq_4.js} +2 -2
- package/dist/web/assets/{plus-CiGwts52.js → plus-ECzYbQfA.js} +1 -1
- package/dist/web/assets/react-GP8hKHRA.js +2122 -0
- package/dist/web/assets/react-vendor-BuABiQkA.js +242 -0
- package/dist/web/assets/ui-BQStT3dY.js +3116 -0
- package/dist/web/index.html +6 -6
- package/package.json +2 -2
- package/dist/web/assets/AiWriteWorkbench-ChCJt24m.js +0 -7
- package/dist/web/assets/DocumentEditor-B3Dsq02C.js +0 -26
- package/dist/web/assets/PlaygroundPage-B-_1l4Ix.js +0 -8
- package/dist/web/assets/diagram--gCCJK__.js +0 -6257
- package/dist/web/assets/index-C4ESYs7f.css +0 -1
- package/dist/web/assets/react-B99eF5mm.js +0 -2377
- package/dist/web/assets/react-vendor-BJFXgntS.js +0 -242
- package/dist/web/assets/ui-BHvBMRFE.js +0 -3126
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var ma=Object.defineProperty;var pa=(e,t,i)=>t in e?ma(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var D=(e,t,i)=>pa(e,typeof t!="symbol"?t+"":t,i);import{d as Ut,g as wa}from"./react-vendor-BJFXgntS.js";function me(e,t){const i=t||new Path2D;if(e.name==="combine"&&!e.draw)return i instanceof Path2D?i:void 0;e.setTheme||(e.setTheme=ba);let s=e.calculative.borderRadius||0,r=s;const{x:a,y:o,width:l,height:n,ex:h,ey:c}=e.calculative.worldRect;s<1&&(s=l*s,r=n*r);let f=s<r?s:r;if(l<2*f&&(f=l/2),n<2*f&&(f=n/2),i.moveTo(a+f,o),i.arcTo(h,o,h,c,f),i.arcTo(h,c,a,c,f),i.arcTo(a,c,a,o,f),i.arcTo(a,o,h,o,f),i.closePath(),i instanceof Path2D)return i}function ba(e,t){if(e.affectByTheme){for(const i in t)if(Object.prototype.hasOwnProperty.call(t,i)){const s=t[i];e.hasOwnProperty(i)&&(e[i]=s),e.calculative.hasOwnProperty(i)&&(e.calculative[i]=s)}e.hoverTextColor=t.textPrimaryColor,e.iconColor=t.buttonBg,e.calculative.iconColor=t.buttonBg,e.hoverBackground=t.formBg,e.activeBackground=t.activeBg,e.color=t.borderColor,e.calculative.color=t.borderColor,e.textColor=t["textColor-9"],e.calculative.textColor=t["textColor-9"]}}const xa=me;function ka(e,t){const i=t||new Path2D,{x:s,y:r,width:a,height:o}=e.calculative.worldRect;if(i.ellipse(s+a/2,r+o/2,a/2,o/2,0,0,Math.PI*2),i instanceof Path2D)return i}var ut;(function(e){e[e.Node=0]="Node",e[e.Line=1]="Line"})(ut||(ut={}));var ct;(function(e){e[e.None=0]="None",e[e.DisableEdit=1]="DisableEdit",e[e.DisableMove=2]="DisableMove",e[e.DisableScale=3]="DisableScale",e[e.DisableMoveScale=4]="DisableMoveScale",e[e.Disable=10]="Disable"})(ct||(ct={}));var ks;(function(e){e[e.Default=0]="Default",e[e.In=1]="In",e[e.Out=2]="Out"})(ks||(ks={}));var ie;(function(e){e[e.None=0]="None",e[e.Linear=1]="Linear",e[e.Radial=2]="Radial"})(ie||(ie={}));var ht;(function(e){e[e.CanvasTemplate=1]="CanvasTemplate",e[e.CanvasImageBottom=2]="CanvasImageBottom",e[e.CanvasMain=3]="CanvasMain",e[e.CanvasImage=4]="CanvasImage"})(ht||(ht={}));const Ra=["text","textWidth","textHeight","textLeft","textTop","fontFamily","fontSize","lineHeight","fontStyle","fontWeight","textAlign","textBaseline","whiteSpace","ellipsis","keepDecimal","letterSpacing"],Ta=["x","y","width","height","flipX","flipY"],Ca=["paddingTop","paddingRight","paddingBottom","paddingLeft","flipX","flipY","visible","showChild"],Aa=["iconLeft","iconTop","iconRotate"],yr=["globalAlpha","flipY","flipX","x","y","width","height","iconWidth","iconHeight","imageRatio","iconLeft","iconTop","iconAlign","rotate","visible"];var pt;(function(e){e[e.Normal=0]="Normal",e[e.Beads=1]="Beads",e[e.Dot=2]="Dot",e[e.Arrow=3]="Arrow",e[e.WaterDrop=4]="WaterDrop",e[e.Custom=5]="Custom"})(pt||(pt={}));var Se;(function(e){e[e.Image=0]="Image",e[e.Icon=1]="Icon",e[e.Pen=2]="Pen",e[e.Element=3]="Element"})(Se||(Se={}));const $i=["gif","iframe","video","echarts","highcharts","lightningCharts","vue"],Di=["radio","checkbox","button","inputDom","slider","echarts"],Fe=new Set(["borderRadius","paddingLeft","paddingRight","paddingTop","paddingBottom","progress","progressColor","verticalProgress","reverseProgress","flipX","flipY","input","lineDash","lineCap","lineJoin","strokeType","lineGradientFromColor","lineGradientToColor","lineGradientAngle","color","hoverColor","activeColor","lineWidth","bkType","gradientFromColor","gradientToColor","gradientAngle","gradientRadius","hoverBackground","activeBackground","globalAlpha","anchorColor","anchorRadius","shadow","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","textHasShadow","fontFamily","fontSize","textColor","hoverTextColor","activeTextColor","textBackground","fontStyle","fontWeight","textAlign","textBaseline","lineHeight","whiteSpace","textWidth","textHeight","textLeft","textTop","ellipsis","hiddenText","keepDecimal","borderWidth","borderColor","animateLineWidth","lineAnimateType","frames","animateColor","animateType","animateReverse","background","gradientColors","lineGradientColors","animateLineWidth","gradientSmooth","lineSmooth","animations","toArrow","fromArrow","dirMarkerLineWidth","lineName","textType","textGradientColors"]),Oi={textType:0,bkType:0,strokeType:0};function Sa(e){e.onAdd=void 0,e.onValue=void 0,e.onBeforeValue=void 0,e.onDestroy=void 0,e.onMove=void 0,e.onResize=void 0,e.onRotate=void 0,e.onClick=void 0,e.onMouseEnter=void 0,e.onMouseLeave=void 0,e.onMouseDown=void 0,e.onMouseMove=void 0,e.onMouseUp=void 0,e.onShowInput=void 0,e.onInput=void 0,e.onChangeId=void 0,e.onBinds=void 0,e.onStartVideo=void 0,e.onPauseVideo=void 0,e.onStopVideo=void 0,e.onRenderPenRaw=void 0,e.onKeyDown=void 0,e.onContextmenu=void 0,e.onScale=void 0,e.onWheel=void 0,e.onConnectLine=void 0}var st;(function(e){e[e.None=0]="None",e[e.LineAnchor=1]="LineAnchor",e[e.NodeAnchor=2]="NodeAnchor",e[e.Line=3]="Line",e[e.Node=4]="Node",e[e.Resize=5]="Resize",e[e.Rotate=6]="Rotate",e[e.LineAnchorPrev=7]="LineAnchorPrev",e[e.LineAnchorNext=8]="LineAnchorNext"})(st||(st={}));var ft;(function(e){e[e.None=0]="None",e[e.Translate=1]="Translate",e[e.Select=2]="Select",e[e.Resize=3]="Resize",e[e.AddAnchor=4]="AddAnchor"})(ft||(ft={}));var Qt;(function(e){e[e.None=0]="None",e[e.Down=1]="Down",e[e.Translate=2]="Translate"})(Qt||(Qt={}));var nt;(function(e){e[e.None=-1]="None",e[e.Up=0]="Up",e[e.Right=1]="Right",e[e.Bottom=2]="Bottom",e[e.Left=3]="Left"})(nt||(nt={}));const Rs=["nw-resize","ne-resize","se-resize","sw-resize"],Ts=["n-resize","e-resize","s-resize","w-resize"],Pa=["curve","polyline","line"],mr=["dash","lineWidth","lineCap","lineJoin","strokeType","color","lineGradientFromColor","lineGradientToColor","lineGradientAngle","globalAlpha","bkType","background","gradientFromColor","gradientToColor","gradientAngle","gradientRadius","fontFamily","fontSize","textColor","hoverTextColor","activeTextColor","textBackground","fontStyle","fontWeight","textAlign","textBaseline","lineHeight","whiteSpace","textLeft","textTop","flipX","flipY","lineDash","visible","iconColor"];var pe;(function(e){e[e.Mirror=0]="Mirror",e[e.Bilateral=1]="Bilateral",e[e.Free=2]="Free"})(pe||(pe={}));var At;(function(e){e[e.Default=0]="Default",e[e.In=1]="In",e[e.Out=2]="Out",e[e.DisableConnected=3]="DisableConnected",e[e.DisableConnectTo=4]="DisableConnectTo",e[e.Disable=10]="Disable"})(At||(At={}));var $t;(function(e){e[e.Default=0]="Default",e[e.Line=1]="Line"})($t||($t={}));function vt(e,t,i){if(!t||t%360===0)return;const s=t*Math.PI/180,r=(e.x-i.x)*Math.cos(s)-(e.y-i.y)*Math.sin(s)+i.x,a=(e.x-i.x)*Math.sin(s)+(e.y-i.y)*Math.cos(s)+i.y;e.x=r,e.y=a,e.prev&&vt(e.prev,t,i),e.next&&vt(e.next,t,i)}function Ce(e,t,i=5,s){if(t.type===$t.Line){let r=s.rotate;s.flipX&&(r*=-1),s.flipY&&(r*=-1);let a=t.rotate+r;return s.flipX&&(a*=-1),s.flipY&&(a*=-1),Jt(e,{x:t.x-t.length*s.calculative.canvas.store.data.scale/2,y:t.y-i,width:t.length*s.calculative.canvas.store.data.scale,height:i*2,rotate:a})}else return e.x>t.x-i&&e.x<t.x+i&&e.y>t.y-i&&e.y<t.y+i}function Pe(e,t,i){e.x=i.x-(i.x-e.x)*t,e.y=i.y-(i.y-e.y)*t}function jt(e,t){if(e.x===t.x)return e.y<=t.y?0:180;if(e.y===t.y)return e.x<t.x?270:90;const i=e.x-t.x,s=e.y-t.y;let r=Math.atan(Math.abs(i/s))/(2*Math.PI)*360;return i>0&&s>0?r=180-r:i<0&&s>0?r+=180:i<0&&s<0&&(r=360-r),r}function Mi(e,t){const i=e.x-t.x,s=e.y-t.y;return Math.sqrt(i*i+s*s)}function Ia(e,t){let i=nt.None;if(!t)return i;const s=e.x-t.x,r=e.y-t.y;return Math.abs(s)>Math.abs(r)?s>0?i=nt.Right:i=nt.Left:r>0?i=nt.Bottom:i=nt.Up,i}function Ye(e,t,i){e&&(e.x+=t,e.y+=i,e.next&&(e.next.x+=t,e.next.y+=i),e.prev&&(e.prev.x+=t,e.prev.y+=i))}function Cs(e,t){return e.anchorId===t.anchorId&&e.connectTo===t.connectTo}function ei(e,t,i){let s=Math.sqrt((e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y))/i.data.scale;t.rotate===0?e.x<t.x?i.pens[t.penId].flipX||(s*=-1):i.pens[t.penId].flipX&&(s*=-1):e.y<t.y?i.pens[t.penId].flipY||(s*=-1):i.pens[t.penId].flipY&&(s*=-1),e.distance=s}const _a="1.1.28",pr={version:_a},it={version:pr.version,path2dDraws:{},canvasDraws:{},anchors:{},lineAnimateDraws:{},htmlElements:{},gridDrawers:{}};function wr(e){Object.assign(it.path2dDraws,e)}function Ea(e){Object.assign(it.canvasDraws,e)}function Ma(e){Object.assign(it.anchors,e)}function La(e,t){it.gridDrawers[e]=t}function Da(e){delete it.gridDrawers[e]}function Oa(e){return{all:e=e||new Map,on:function(t,i){var s=e.get(t);s&&s.push(i)||e.set(t,[i])},off:function(t,i){var s=e.get(t);s&&s.splice(s.indexOf(i)>>>0,1)},emit:function(t,i){(e.get(t)||[]).slice().map(function(s){s(i)}),(e.get("*")||[]).slice().map(function(s){s(t,i)})}}}var ve;(function(e){e[e.None=-1]="None",e[e.Document=0]="Document",e[e.Canvas=1]="Canvas"})(ve||(ve={}));const Ba="#FFFFFF00",Na={fontFamily:'"Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial',fontSize:12,lineHeight:1.5,textAlign:"center",textBaseline:"middle",color:"#222222",activeColor:"#278df8",hoverColor:"rgba(39,141,248,0.50)",anchorColor:"#278DF8",hoverAnchorColor:"#FF4101",anchorRadius:4,anchorBackground:"#fff",dockColor:"rgba(39,141,248,0.50)",dockPenColor:"#1890FF",dragColor:"#1890ff",rotateCursor:"rotate.cur",rightCursor:"right.cur",downCursor:"down.cur",hoverCursor:"pointer",minScale:.1,maxScale:10,keydown:ve.Document,gridSize:20,gridColor:"#e2e2e2",ruleColor:"#888888",drawingLineName:"curve",interval:30,minFPSNumber:10,autoFPS:!0,animateInterval:30,autoPolyline:!0,autoAnchor:!0,autoAlignGrid:!1,animateColor:"#30EEDC",ruleLineColor:"#FF4101",shadowOffsetX:0,shadowOffsetY:0,shadowBlur:64,shadowColor:"#00000014",globalAlpha:1,defaultAnchors:[{x:.5,y:0},{x:1,y:.5},{x:.5,y:1},{x:0,y:.5}],measureTextWidth:!0,moveConnectedLine:!0,mouseRightActive:!0,disableClipboard:!1,drawingLineLength:0,disableTouchPadScale:!1,parentTouch:!0,cdn:"",polylineSpace:10,dirMarkers:!1,domShapes:[],containerShapes:["tablePlus"],textFlip:!0,textRotate:!0,unavailableKeys:[],diagramOptions:{},svgPathStroke:!0,reconnetTimes:10},Fa=["color","hoverColor","activeColor","disabledColor","background","activeBackground","hoverBackground","disabledBackground","anchorColor","hoverAnchorColor","anchorBackground","animateColor","textColor","ruleColor","ruleLineColor","gridColor","lineColor","penBackground","dockPenColor"],za={dark:{color:"#bdc7db",background:"#1e2430",parentBackground:"#080b0f",ruleColor:"#222E47",ruleOptions:{background:"#121924",textColor:"#6E7B91"}},light:{color:"#222222",background:"#FFFFFF",parentBackground:"#F0F1F2",ruleColor:"#C8D0E1",ruleOptions:{background:"#F7F8FA",textColor:"#C8D0E1"}}},Ve={cssRuleSelector:":root",style_prefix:"le5le_",vendor_css_prefix:"--le-",dark:["textColor-9: rgba(255,255,255,0.90)","textColor-6: rgba(255,255,255,0.60)","textColor-1: rgba(255,255,255,1)","textColor-4: rgba(255,255,255,0.40)","textPrimaryColor: #7f838c","textSecondColor: rgba(255,255,255,0.90)","textDisabledColor: rgba(255,255,255,0.40)","textActiveColor: #0052d9","buttonBg: #4583ff","buttonDisabledBg: #0057CC","buttonDisabledColor: #FFFFFF26","buttonGradient: linear-gradient(360deg,#4583ff, #33ccff)","containerBg: rgba(21,24,28,0.95)","tabBg: #303746","tabActiveBg: #4583ff","tabDisabledBg: #282e3b","tabDisabledColor: rgba(255,255,255,0.26)","tabActiveColor: rgba(255,255,255,0.90)","formBg: #2a2f36","datePickerCellActiveRangeBg: #2c4475","componentDisabledBg: #282e3b","dataPickerCellActiveBg: #001b52","activeBg: #25375b","popContentBg: #252b37","disabledBg: #7f838c","disabledBg-2: #282E3B","tableStripeColor: rgba(150,192,255,0.10)","tableMenuBg: #303746","tableMenuDividerBg: rgb(76 81 94)","tableMenuHandleBg: #454f64","tableMenuColor: #bdc7db","tableMenuBorderColor: transparent","tableColRowBg: #303746","tableColRowActiveBg: #4A5263","tableColRowColor: rgba(255,255,255,0.6)","paginationColor: rgba(255,255,255,0.6)","paginationActiveColor: #4583ff","paginationActiveBg: rgba(69,131,255,0.20)","sliderBg: #303746","sliderBtnBg: #000000","notificationBorderColor: transparent","notificationBg: #282e3b","borderColor: #424b61","borderOutsideColor: #4583ff","formBorderColor: #424b61","borderInsideColor: rgba(255,255,255,0.40)","shadow: 0px 1px 10px 0px rgba(0,0,0,0.05), 0px 4px 5px 0px rgba(0,0,0,0.08), 0px 2px 4px -1px rgba(0,0,0,0.12)","radius: 4px"],light:["textColor-9: rgba(0,0,0,0.90)","textColor-6: rgba(0,0,0,0.60)","textColor-1: rgba(0,0,0,1)","textColor-4: rgba(0,0,0,0.40)","textPrimaryColor: #7f838c","textSecondColor: #171B27","textDisabledColor: rgba(0, 0, 0, 0.6)","textActiveColor: #0052d9","buttonBg: #4583ff","buttonDisabledBg: #b5c7ff","buttonDisabledColor: #FFFFFF","buttonGradient: linear-gradient(360deg,#4583ff, #33ccff)","containerBg: #ffffff","tabBg: #f1f2f5","tabActiveBg: #4583ff","tabDisabledBg: #e2e6ea","tabDisabledColor: rgba(0,0,0,0.26)","tabActiveColor: #ffffff","formBg: #EFF1F4","datePickerCellActiveRangeBg: #f2f3ff","componentDisabledBg: #eee","dataPickerCellActiveBg: #edefff","activeBg: #f2f3ff","popContentBg: #ffffff","disabledBg: #7f838c","disabledBg-2: #E2E6EA","tableStripeColor: #f1f2f5","tableMenuBg: #ffffff","tableMenuDividerBg: #e2e6ea","tableMenuHandleBg: #ebedf1","tableMenuColor: rgba(0,0,0,0.60)","tableMenuBorderColor: #e2e6ea","tableColRowBg: #ebedf1","tableColRowActiveBg: #bcc4d0","tableColRowColor: rgba(0,0,0,0.4)","paginationColor: rgba(0,0,0,0.6)","paginationActiveColor: #ffffff","paginationActiveBg: #4583ff","sliderBg: #e2e6ea","sliderBtnBg: #ffffff","notificationBorderColor: transparent","notificationBg: #ffffff","borderColor: #d6dbe3","borderOutsideColor: #d6dbe3","formBorderColor: #d4d6d9","borderInsideColor: #e7e7e7","shadow: 0px 2px 4px 0px rgba(107,113,121,0.25)","radius: 4px"],camelCaseToHyphenated(e){return e.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())},_addVendorCssPrefix(e){return e.map(t=>{const[i,s]=t.split(":");return`${this.vendor_css_prefix}${this.camelCaseToHyphenated(i.trim())}:${s.trim()}`})},createThemeSheet(e,t){const i=document.createElement("style");i.type="text/css",i.id=this.style_prefix+t,document.head.appendChild(i);const s=e||"dark",r=this.getTheme(s),a=`${this.cssRuleSelector} { ${r.join(";")} }`;i.innerHTML=a},destroyThemeSheet(e){const t=this.findStyleSheet(this.style_prefix+e);t&&document.head.removeChild(t.ownerNode)},addTheme(e,t){Object.assign(this,{[e]:t})},getTheme(e){return this._addVendorCssPrefix(this[e]||this.light)},getThemeObj(e="dark"){var s;const t=":";return(s=this[e])==null?void 0:s.reduce((r,a)=>{const[o,l]=a.split(t);return r[o]=l,r},{})},findStyleSheet(e){const t=document.styleSheets;for(let i=0;i<t.length;i++){const s=t[i];if(s.ownerNode&&s.ownerNode.id===e)return s}return null},updateCssRule(e,t){const s=this.getTheme(t),r=this.findStyleSheet(this.style_prefix+e);if(!r)return;let a=!1;for(let o=0;o<r.cssRules.length;o++)if(r.cssRules[o].selectorText===this.cssRuleSelector){a=!0;break}if(a)for(let o=0;o<r.cssRules.length;o++){const l=r.cssRules[o];if(l.selectorText===this.cssRuleSelector)if(r.insertRule){r.deleteRule(o);const n=`${this.cssRuleSelector} { ${s.join(";")} }`;r.insertRule(n,o)}else r.addRule&&(l.style.cssText=s.join(";"))}else if(r.insertRule){const o=`${this.cssRuleSelector} { ${s.join(";")} }`;r.insertRule(o,r.cssRules.length)}else if(r.addRule){const o=r.cssRules.find(l=>l.selectorText===this.cssRuleSelector);if(o){const l=s.join(";");o.style.cssText+=`; ${l}`}else r.addRule(this.cssRuleSelector,s.join(";"))}}};var rt;(function(e){e[e.Add=0]="Add",e[e.Update=1]="Update",e[e.Delete=2]="Delete",e[e.Replace=3]="Replace"})(rt||(rt={}));const ja=()=>({data:{x:0,y:0,scale:1,pens:[],origin:{x:0,y:0},center:{x:0,y:0},paths:{}},histories:[],pens:{},path2dMap:new WeakMap,animateMap:new WeakMap,active:[],animates:new Set,options:{...Na},theme:{...za},emitter:Oa(),bindDatas:{},bind:{},pensNetwork:{},cacheDatas:[],messageEvents:{},templatePens:{},globalTriggers:{}}),Wa=(e="default")=>(it[e]||(it[e]=ja(),it[e].id=e),it[e]),Ha=(e,t)=>{const i=e.data.template===t;if(i)for(const s of e.data.pens)s.canvasLayer,ht.CanvasTemplate;e.lastScale=e.data.scale,e.data={x:0,y:0,scale:1,pens:[],origin:{x:0,y:0},center:{x:0,y:0},paths:{},template:i?t:null,lineAnimateDraws:{}},e.sameTemplate=i,e.pens={},e.histories=[],e.historyIndex=null,e.path2dMap=new WeakMap,e.animateMap=new WeakMap,e.bindDatas={},e.bind={},e.pensNetwork={},e.active=[],e.hover=void 0,e.lastHover=void 0,e.animates.clear()};function qt(e){return typeof e=="number"&&!isNaN(e)}function yi(e){return e==null||typeof e=="string"&&e.trim()===""||!e&&e!==0&&e!=="0"&&e!==!1}function Yt(e){const{paddingTop:t,paddingBottom:i,paddingLeft:s,paddingRight:r,worldRect:a,canvas:o,text:l}=e.calculative;let{textLeft:n,textTop:h,textWidth:c,textHeight:f}=e.calculative,u=s,d=t;const v=a.width-s-r,g=a.height-t-i;c&&c<1&&(c*=a.width),f&&f<1&&(f*=a.height),c<e.calculative.fontSize&&(c=e.calculative.fontSize),u+=(n||0)+a.x,d+=(h||0)+a.y;const y=e.textAlign||o.store.options.textAlign,p=e.textBaseline||o.store.options.textBaseline;switch(y){case"center":u+=(v-(c||v))/2;break;case"right":u+=v-(c||v);break}switch(p){case"middle":d+=(g-(f||g))/2;break;case"bottom":d+=g-(f||g);break}const b={x:u,y:d,width:c||v,height:f||g};bt(b),e.calculative.worldTextRect=b,Ne(e),e.calculative.textDrawRect=void 0}function as(e,t){const i=t.calculative;if(yi(i.text))return;i.textLines||Ne(t);const{worldTextRect:s,textLines:r,fontSize:a,lineHeight:o,canvas:l}=i;if(!r)return;const n=a*o,h=r.length*n;t.calculative.fontsChecked!==!1&&(document.fonts.check(e.font)?t.calculative.fontsChecked=!1:t.calculative.fontsChecked=!0);const c=Va(e,t);let f=s.x+(s.width-c)/2,u=s.y+(s.height-h)/2;const{options:d}=l.store;switch(t.textAlign||d.textAlign){case"left":f=s.x;break;case"right":f=s.x+s.width-c;break}switch(t.textBaseline||d.textBaseline){case"top":u=s.y;break;case"bottom":u=s.ey-h;break}t.calculative.textDrawRect={x:f,y:u,width:c,height:h},bt(t.calculative.textDrawRect)}function Ne(e,t=e.calculative.text){const i=e.calculative;if(yi(t)){i.textLines=void 0;return}let s=typeof t=="string"?t:t.toString();const{whiteSpace:r,ellipsis:a}=e,{keepDecimal:o}=i;if(o!=null&&s.trim()!==""){const u=Number(s);isNaN(u)||(s=u.toFixed(o))}let l=[];const n=i.fontSize*i.lineHeight,h=i.worldTextRect.height,c=Math.floor(h/n),f=c>1?c:1;switch(r){case"nowrap":if(a!==!1){const v=As([...s],e);v[0]&&(l.push(v[0]),v.length>1&&Bi(l))}else l.push(s);break;case"pre-line":l=s.split(/[\n]/g),a!==!1&&l.length>f&&(l=l.slice(0,f),Bi(l));break;case"break-all":default:const u=s.split(/[\n]/g);let d=0;t:for(const v of u){const g=r==="break-all"?v.split(""):br(v);let y=As(g,e);if(y.length===0&&(y=[""]),a!=!1)for(const p of y)if(d++,d>f){Bi(l);break t}else l.push(p);else l.push(...y)}break}return i.textLines=l,l}function br(e=""){const t=[];let i="";for(let s=0;s<e.length;++s){const r=e.charCodeAt(s);r<33||r>126?(i&&(t.push(i),i=""),t.push(e[s])):i+=e[s]}return i&&t.push(i),t}function As(e,t){const i=t.calculative.canvas,s=i.offscreen.getContext("2d"),{fontStyle:r,fontWeight:a,fontSize:o,fontFamily:l,lineHeight:n}=t.calculative;s.save();const h=[];let c=e[0]||"";for(let f=1;f<e.length;++f){const u=e[f]||"",d=c+u;let v=0;if(i.store.options.measureTextWidth)s.font=_t({fontStyle:r,fontWeight:a,fontFamily:l||i.store.options.fontFamily,fontSize:o,lineHeight:n}),v=s.measureText(d).width;else{const y=d.match(/[^\x00-\xff]/g)||"",p=y.length*o,b=d.match(/\s/g)||"",m=b.length*o*.3,k=(d.length-y.length-b.length)*o*.6;v=p+m+k}const g=t.calculative.worldTextRect.width;v<=g+.1?c+=u:(c.length&&h.push(c),c=u)}return c.length&&h.push(c),s.restore(),h}function Va(e,t){let i=0;return t.calculative.textLineWidths=[],t.calculative.textLines&&t.calculative.textLines.forEach(s=>{let r;t.calculative.textType?r=Ua(s,t)+s.length*t.calculative.letterSpacing:r=e.measureText(s).width+s.length*t.calculative.letterSpacing,t.calculative.textLineWidths.push(r),i<r&&(i=r)}),i}function Ua(e,t){const i=t.calculative.fontSize,s=e.match(/[^\x00-\xff]/g)||"",r=s.length*i,a=e.match(/\s/g)||"",o=a.length*i*(t.CSmultiple||.5),l=(e.length-s.length-a.length)*i*(t.CEmultiple||.54);return r+o+l}function Bi(e){e[e.length-1]=e[e.length-1].slice(0,-3)+"..."}function qa(e){let t=e.text.split(`
|
|
1
|
+
var ma=Object.defineProperty;var pa=(e,t,i)=>t in e?ma(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var D=(e,t,i)=>pa(e,typeof t!="symbol"?t+"":t,i);import{C as Ut,B as wa}from"./react-vendor-BuABiQkA.js";function me(e,t){const i=t||new Path2D;if(e.name==="combine"&&!e.draw)return i instanceof Path2D?i:void 0;e.setTheme||(e.setTheme=ba);let s=e.calculative.borderRadius||0,r=s;const{x:a,y:o,width:l,height:n,ex:h,ey:c}=e.calculative.worldRect;s<1&&(s=l*s,r=n*r);let f=s<r?s:r;if(l<2*f&&(f=l/2),n<2*f&&(f=n/2),i.moveTo(a+f,o),i.arcTo(h,o,h,c,f),i.arcTo(h,c,a,c,f),i.arcTo(a,c,a,o,f),i.arcTo(a,o,h,o,f),i.closePath(),i instanceof Path2D)return i}function ba(e,t){if(e.affectByTheme){for(const i in t)if(Object.prototype.hasOwnProperty.call(t,i)){const s=t[i];e.hasOwnProperty(i)&&(e[i]=s),e.calculative.hasOwnProperty(i)&&(e.calculative[i]=s)}e.hoverTextColor=t.textPrimaryColor,e.iconColor=t.buttonBg,e.calculative.iconColor=t.buttonBg,e.hoverBackground=t.formBg,e.activeBackground=t.activeBg,e.color=t.borderColor,e.calculative.color=t.borderColor,e.textColor=t["textColor-9"],e.calculative.textColor=t["textColor-9"]}}const xa=me;function ka(e,t){const i=t||new Path2D,{x:s,y:r,width:a,height:o}=e.calculative.worldRect;if(i.ellipse(s+a/2,r+o/2,a/2,o/2,0,0,Math.PI*2),i instanceof Path2D)return i}var ut;(function(e){e[e.Node=0]="Node",e[e.Line=1]="Line"})(ut||(ut={}));var ct;(function(e){e[e.None=0]="None",e[e.DisableEdit=1]="DisableEdit",e[e.DisableMove=2]="DisableMove",e[e.DisableScale=3]="DisableScale",e[e.DisableMoveScale=4]="DisableMoveScale",e[e.Disable=10]="Disable"})(ct||(ct={}));var ks;(function(e){e[e.Default=0]="Default",e[e.In=1]="In",e[e.Out=2]="Out"})(ks||(ks={}));var ie;(function(e){e[e.None=0]="None",e[e.Linear=1]="Linear",e[e.Radial=2]="Radial"})(ie||(ie={}));var ht;(function(e){e[e.CanvasTemplate=1]="CanvasTemplate",e[e.CanvasImageBottom=2]="CanvasImageBottom",e[e.CanvasMain=3]="CanvasMain",e[e.CanvasImage=4]="CanvasImage"})(ht||(ht={}));const Ra=["text","textWidth","textHeight","textLeft","textTop","fontFamily","fontSize","lineHeight","fontStyle","fontWeight","textAlign","textBaseline","whiteSpace","ellipsis","keepDecimal","letterSpacing"],Ta=["x","y","width","height","flipX","flipY"],Ca=["paddingTop","paddingRight","paddingBottom","paddingLeft","flipX","flipY","visible","showChild"],Aa=["iconLeft","iconTop","iconRotate"],yr=["globalAlpha","flipY","flipX","x","y","width","height","iconWidth","iconHeight","imageRatio","iconLeft","iconTop","iconAlign","rotate","visible"];var pt;(function(e){e[e.Normal=0]="Normal",e[e.Beads=1]="Beads",e[e.Dot=2]="Dot",e[e.Arrow=3]="Arrow",e[e.WaterDrop=4]="WaterDrop",e[e.Custom=5]="Custom"})(pt||(pt={}));var Se;(function(e){e[e.Image=0]="Image",e[e.Icon=1]="Icon",e[e.Pen=2]="Pen",e[e.Element=3]="Element"})(Se||(Se={}));const $i=["gif","iframe","video","echarts","highcharts","lightningCharts","vue"],Di=["radio","checkbox","button","inputDom","slider","echarts"],Fe=new Set(["borderRadius","paddingLeft","paddingRight","paddingTop","paddingBottom","progress","progressColor","verticalProgress","reverseProgress","flipX","flipY","input","lineDash","lineCap","lineJoin","strokeType","lineGradientFromColor","lineGradientToColor","lineGradientAngle","color","hoverColor","activeColor","lineWidth","bkType","gradientFromColor","gradientToColor","gradientAngle","gradientRadius","hoverBackground","activeBackground","globalAlpha","anchorColor","anchorRadius","shadow","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","textHasShadow","fontFamily","fontSize","textColor","hoverTextColor","activeTextColor","textBackground","fontStyle","fontWeight","textAlign","textBaseline","lineHeight","whiteSpace","textWidth","textHeight","textLeft","textTop","ellipsis","hiddenText","keepDecimal","borderWidth","borderColor","animateLineWidth","lineAnimateType","frames","animateColor","animateType","animateReverse","background","gradientColors","lineGradientColors","animateLineWidth","gradientSmooth","lineSmooth","animations","toArrow","fromArrow","dirMarkerLineWidth","lineName","textType","textGradientColors"]),Oi={textType:0,bkType:0,strokeType:0};function Sa(e){e.onAdd=void 0,e.onValue=void 0,e.onBeforeValue=void 0,e.onDestroy=void 0,e.onMove=void 0,e.onResize=void 0,e.onRotate=void 0,e.onClick=void 0,e.onMouseEnter=void 0,e.onMouseLeave=void 0,e.onMouseDown=void 0,e.onMouseMove=void 0,e.onMouseUp=void 0,e.onShowInput=void 0,e.onInput=void 0,e.onChangeId=void 0,e.onBinds=void 0,e.onStartVideo=void 0,e.onPauseVideo=void 0,e.onStopVideo=void 0,e.onRenderPenRaw=void 0,e.onKeyDown=void 0,e.onContextmenu=void 0,e.onScale=void 0,e.onWheel=void 0,e.onConnectLine=void 0}var st;(function(e){e[e.None=0]="None",e[e.LineAnchor=1]="LineAnchor",e[e.NodeAnchor=2]="NodeAnchor",e[e.Line=3]="Line",e[e.Node=4]="Node",e[e.Resize=5]="Resize",e[e.Rotate=6]="Rotate",e[e.LineAnchorPrev=7]="LineAnchorPrev",e[e.LineAnchorNext=8]="LineAnchorNext"})(st||(st={}));var ft;(function(e){e[e.None=0]="None",e[e.Translate=1]="Translate",e[e.Select=2]="Select",e[e.Resize=3]="Resize",e[e.AddAnchor=4]="AddAnchor"})(ft||(ft={}));var Qt;(function(e){e[e.None=0]="None",e[e.Down=1]="Down",e[e.Translate=2]="Translate"})(Qt||(Qt={}));var nt;(function(e){e[e.None=-1]="None",e[e.Up=0]="Up",e[e.Right=1]="Right",e[e.Bottom=2]="Bottom",e[e.Left=3]="Left"})(nt||(nt={}));const Rs=["nw-resize","ne-resize","se-resize","sw-resize"],Ts=["n-resize","e-resize","s-resize","w-resize"],Pa=["curve","polyline","line"],mr=["dash","lineWidth","lineCap","lineJoin","strokeType","color","lineGradientFromColor","lineGradientToColor","lineGradientAngle","globalAlpha","bkType","background","gradientFromColor","gradientToColor","gradientAngle","gradientRadius","fontFamily","fontSize","textColor","hoverTextColor","activeTextColor","textBackground","fontStyle","fontWeight","textAlign","textBaseline","lineHeight","whiteSpace","textLeft","textTop","flipX","flipY","lineDash","visible","iconColor"];var pe;(function(e){e[e.Mirror=0]="Mirror",e[e.Bilateral=1]="Bilateral",e[e.Free=2]="Free"})(pe||(pe={}));var At;(function(e){e[e.Default=0]="Default",e[e.In=1]="In",e[e.Out=2]="Out",e[e.DisableConnected=3]="DisableConnected",e[e.DisableConnectTo=4]="DisableConnectTo",e[e.Disable=10]="Disable"})(At||(At={}));var $t;(function(e){e[e.Default=0]="Default",e[e.Line=1]="Line"})($t||($t={}));function vt(e,t,i){if(!t||t%360===0)return;const s=t*Math.PI/180,r=(e.x-i.x)*Math.cos(s)-(e.y-i.y)*Math.sin(s)+i.x,a=(e.x-i.x)*Math.sin(s)+(e.y-i.y)*Math.cos(s)+i.y;e.x=r,e.y=a,e.prev&&vt(e.prev,t,i),e.next&&vt(e.next,t,i)}function Ce(e,t,i=5,s){if(t.type===$t.Line){let r=s.rotate;s.flipX&&(r*=-1),s.flipY&&(r*=-1);let a=t.rotate+r;return s.flipX&&(a*=-1),s.flipY&&(a*=-1),Jt(e,{x:t.x-t.length*s.calculative.canvas.store.data.scale/2,y:t.y-i,width:t.length*s.calculative.canvas.store.data.scale,height:i*2,rotate:a})}else return e.x>t.x-i&&e.x<t.x+i&&e.y>t.y-i&&e.y<t.y+i}function Pe(e,t,i){e.x=i.x-(i.x-e.x)*t,e.y=i.y-(i.y-e.y)*t}function jt(e,t){if(e.x===t.x)return e.y<=t.y?0:180;if(e.y===t.y)return e.x<t.x?270:90;const i=e.x-t.x,s=e.y-t.y;let r=Math.atan(Math.abs(i/s))/(2*Math.PI)*360;return i>0&&s>0?r=180-r:i<0&&s>0?r+=180:i<0&&s<0&&(r=360-r),r}function Mi(e,t){const i=e.x-t.x,s=e.y-t.y;return Math.sqrt(i*i+s*s)}function Ia(e,t){let i=nt.None;if(!t)return i;const s=e.x-t.x,r=e.y-t.y;return Math.abs(s)>Math.abs(r)?s>0?i=nt.Right:i=nt.Left:r>0?i=nt.Bottom:i=nt.Up,i}function Ye(e,t,i){e&&(e.x+=t,e.y+=i,e.next&&(e.next.x+=t,e.next.y+=i),e.prev&&(e.prev.x+=t,e.prev.y+=i))}function Cs(e,t){return e.anchorId===t.anchorId&&e.connectTo===t.connectTo}function ei(e,t,i){let s=Math.sqrt((e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y))/i.data.scale;t.rotate===0?e.x<t.x?i.pens[t.penId].flipX||(s*=-1):i.pens[t.penId].flipX&&(s*=-1):e.y<t.y?i.pens[t.penId].flipY||(s*=-1):i.pens[t.penId].flipY&&(s*=-1),e.distance=s}const _a="1.1.28",pr={version:_a},it={version:pr.version,path2dDraws:{},canvasDraws:{},anchors:{},lineAnimateDraws:{},htmlElements:{},gridDrawers:{}};function wr(e){Object.assign(it.path2dDraws,e)}function Ea(e){Object.assign(it.canvasDraws,e)}function Ma(e){Object.assign(it.anchors,e)}function La(e,t){it.gridDrawers[e]=t}function Da(e){delete it.gridDrawers[e]}function Oa(e){return{all:e=e||new Map,on:function(t,i){var s=e.get(t);s&&s.push(i)||e.set(t,[i])},off:function(t,i){var s=e.get(t);s&&s.splice(s.indexOf(i)>>>0,1)},emit:function(t,i){(e.get(t)||[]).slice().map(function(s){s(i)}),(e.get("*")||[]).slice().map(function(s){s(t,i)})}}}var ve;(function(e){e[e.None=-1]="None",e[e.Document=0]="Document",e[e.Canvas=1]="Canvas"})(ve||(ve={}));const Ba="#FFFFFF00",Na={fontFamily:'"Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial',fontSize:12,lineHeight:1.5,textAlign:"center",textBaseline:"middle",color:"#222222",activeColor:"#278df8",hoverColor:"rgba(39,141,248,0.50)",anchorColor:"#278DF8",hoverAnchorColor:"#FF4101",anchorRadius:4,anchorBackground:"#fff",dockColor:"rgba(39,141,248,0.50)",dockPenColor:"#1890FF",dragColor:"#1890ff",rotateCursor:"rotate.cur",rightCursor:"right.cur",downCursor:"down.cur",hoverCursor:"pointer",minScale:.1,maxScale:10,keydown:ve.Document,gridSize:20,gridColor:"#e2e2e2",ruleColor:"#888888",drawingLineName:"curve",interval:30,minFPSNumber:10,autoFPS:!0,animateInterval:30,autoPolyline:!0,autoAnchor:!0,autoAlignGrid:!1,animateColor:"#30EEDC",ruleLineColor:"#FF4101",shadowOffsetX:0,shadowOffsetY:0,shadowBlur:64,shadowColor:"#00000014",globalAlpha:1,defaultAnchors:[{x:.5,y:0},{x:1,y:.5},{x:.5,y:1},{x:0,y:.5}],measureTextWidth:!0,moveConnectedLine:!0,mouseRightActive:!0,disableClipboard:!1,drawingLineLength:0,disableTouchPadScale:!1,parentTouch:!0,cdn:"",polylineSpace:10,dirMarkers:!1,domShapes:[],containerShapes:["tablePlus"],textFlip:!0,textRotate:!0,unavailableKeys:[],diagramOptions:{},svgPathStroke:!0,reconnetTimes:10},Fa=["color","hoverColor","activeColor","disabledColor","background","activeBackground","hoverBackground","disabledBackground","anchorColor","hoverAnchorColor","anchorBackground","animateColor","textColor","ruleColor","ruleLineColor","gridColor","lineColor","penBackground","dockPenColor"],za={dark:{color:"#bdc7db",background:"#1e2430",parentBackground:"#080b0f",ruleColor:"#222E47",ruleOptions:{background:"#121924",textColor:"#6E7B91"}},light:{color:"#222222",background:"#FFFFFF",parentBackground:"#F0F1F2",ruleColor:"#C8D0E1",ruleOptions:{background:"#F7F8FA",textColor:"#C8D0E1"}}},Ve={cssRuleSelector:":root",style_prefix:"le5le_",vendor_css_prefix:"--le-",dark:["textColor-9: rgba(255,255,255,0.90)","textColor-6: rgba(255,255,255,0.60)","textColor-1: rgba(255,255,255,1)","textColor-4: rgba(255,255,255,0.40)","textPrimaryColor: #7f838c","textSecondColor: rgba(255,255,255,0.90)","textDisabledColor: rgba(255,255,255,0.40)","textActiveColor: #0052d9","buttonBg: #4583ff","buttonDisabledBg: #0057CC","buttonDisabledColor: #FFFFFF26","buttonGradient: linear-gradient(360deg,#4583ff, #33ccff)","containerBg: rgba(21,24,28,0.95)","tabBg: #303746","tabActiveBg: #4583ff","tabDisabledBg: #282e3b","tabDisabledColor: rgba(255,255,255,0.26)","tabActiveColor: rgba(255,255,255,0.90)","formBg: #2a2f36","datePickerCellActiveRangeBg: #2c4475","componentDisabledBg: #282e3b","dataPickerCellActiveBg: #001b52","activeBg: #25375b","popContentBg: #252b37","disabledBg: #7f838c","disabledBg-2: #282E3B","tableStripeColor: rgba(150,192,255,0.10)","tableMenuBg: #303746","tableMenuDividerBg: rgb(76 81 94)","tableMenuHandleBg: #454f64","tableMenuColor: #bdc7db","tableMenuBorderColor: transparent","tableColRowBg: #303746","tableColRowActiveBg: #4A5263","tableColRowColor: rgba(255,255,255,0.6)","paginationColor: rgba(255,255,255,0.6)","paginationActiveColor: #4583ff","paginationActiveBg: rgba(69,131,255,0.20)","sliderBg: #303746","sliderBtnBg: #000000","notificationBorderColor: transparent","notificationBg: #282e3b","borderColor: #424b61","borderOutsideColor: #4583ff","formBorderColor: #424b61","borderInsideColor: rgba(255,255,255,0.40)","shadow: 0px 1px 10px 0px rgba(0,0,0,0.05), 0px 4px 5px 0px rgba(0,0,0,0.08), 0px 2px 4px -1px rgba(0,0,0,0.12)","radius: 4px"],light:["textColor-9: rgba(0,0,0,0.90)","textColor-6: rgba(0,0,0,0.60)","textColor-1: rgba(0,0,0,1)","textColor-4: rgba(0,0,0,0.40)","textPrimaryColor: #7f838c","textSecondColor: #171B27","textDisabledColor: rgba(0, 0, 0, 0.6)","textActiveColor: #0052d9","buttonBg: #4583ff","buttonDisabledBg: #b5c7ff","buttonDisabledColor: #FFFFFF","buttonGradient: linear-gradient(360deg,#4583ff, #33ccff)","containerBg: #ffffff","tabBg: #f1f2f5","tabActiveBg: #4583ff","tabDisabledBg: #e2e6ea","tabDisabledColor: rgba(0,0,0,0.26)","tabActiveColor: #ffffff","formBg: #EFF1F4","datePickerCellActiveRangeBg: #f2f3ff","componentDisabledBg: #eee","dataPickerCellActiveBg: #edefff","activeBg: #f2f3ff","popContentBg: #ffffff","disabledBg: #7f838c","disabledBg-2: #E2E6EA","tableStripeColor: #f1f2f5","tableMenuBg: #ffffff","tableMenuDividerBg: #e2e6ea","tableMenuHandleBg: #ebedf1","tableMenuColor: rgba(0,0,0,0.60)","tableMenuBorderColor: #e2e6ea","tableColRowBg: #ebedf1","tableColRowActiveBg: #bcc4d0","tableColRowColor: rgba(0,0,0,0.4)","paginationColor: rgba(0,0,0,0.6)","paginationActiveColor: #ffffff","paginationActiveBg: #4583ff","sliderBg: #e2e6ea","sliderBtnBg: #ffffff","notificationBorderColor: transparent","notificationBg: #ffffff","borderColor: #d6dbe3","borderOutsideColor: #d6dbe3","formBorderColor: #d4d6d9","borderInsideColor: #e7e7e7","shadow: 0px 2px 4px 0px rgba(107,113,121,0.25)","radius: 4px"],camelCaseToHyphenated(e){return e.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())},_addVendorCssPrefix(e){return e.map(t=>{const[i,s]=t.split(":");return`${this.vendor_css_prefix}${this.camelCaseToHyphenated(i.trim())}:${s.trim()}`})},createThemeSheet(e,t){const i=document.createElement("style");i.type="text/css",i.id=this.style_prefix+t,document.head.appendChild(i);const s=e||"dark",r=this.getTheme(s),a=`${this.cssRuleSelector} { ${r.join(";")} }`;i.innerHTML=a},destroyThemeSheet(e){const t=this.findStyleSheet(this.style_prefix+e);t&&document.head.removeChild(t.ownerNode)},addTheme(e,t){Object.assign(this,{[e]:t})},getTheme(e){return this._addVendorCssPrefix(this[e]||this.light)},getThemeObj(e="dark"){var s;const t=":";return(s=this[e])==null?void 0:s.reduce((r,a)=>{const[o,l]=a.split(t);return r[o]=l,r},{})},findStyleSheet(e){const t=document.styleSheets;for(let i=0;i<t.length;i++){const s=t[i];if(s.ownerNode&&s.ownerNode.id===e)return s}return null},updateCssRule(e,t){const s=this.getTheme(t),r=this.findStyleSheet(this.style_prefix+e);if(!r)return;let a=!1;for(let o=0;o<r.cssRules.length;o++)if(r.cssRules[o].selectorText===this.cssRuleSelector){a=!0;break}if(a)for(let o=0;o<r.cssRules.length;o++){const l=r.cssRules[o];if(l.selectorText===this.cssRuleSelector)if(r.insertRule){r.deleteRule(o);const n=`${this.cssRuleSelector} { ${s.join(";")} }`;r.insertRule(n,o)}else r.addRule&&(l.style.cssText=s.join(";"))}else if(r.insertRule){const o=`${this.cssRuleSelector} { ${s.join(";")} }`;r.insertRule(o,r.cssRules.length)}else if(r.addRule){const o=r.cssRules.find(l=>l.selectorText===this.cssRuleSelector);if(o){const l=s.join(";");o.style.cssText+=`; ${l}`}else r.addRule(this.cssRuleSelector,s.join(";"))}}};var rt;(function(e){e[e.Add=0]="Add",e[e.Update=1]="Update",e[e.Delete=2]="Delete",e[e.Replace=3]="Replace"})(rt||(rt={}));const ja=()=>({data:{x:0,y:0,scale:1,pens:[],origin:{x:0,y:0},center:{x:0,y:0},paths:{}},histories:[],pens:{},path2dMap:new WeakMap,animateMap:new WeakMap,active:[],animates:new Set,options:{...Na},theme:{...za},emitter:Oa(),bindDatas:{},bind:{},pensNetwork:{},cacheDatas:[],messageEvents:{},templatePens:{},globalTriggers:{}}),Wa=(e="default")=>(it[e]||(it[e]=ja(),it[e].id=e),it[e]),Ha=(e,t)=>{const i=e.data.template===t;if(i)for(const s of e.data.pens)s.canvasLayer,ht.CanvasTemplate;e.lastScale=e.data.scale,e.data={x:0,y:0,scale:1,pens:[],origin:{x:0,y:0},center:{x:0,y:0},paths:{},template:i?t:null,lineAnimateDraws:{}},e.sameTemplate=i,e.pens={},e.histories=[],e.historyIndex=null,e.path2dMap=new WeakMap,e.animateMap=new WeakMap,e.bindDatas={},e.bind={},e.pensNetwork={},e.active=[],e.hover=void 0,e.lastHover=void 0,e.animates.clear()};function qt(e){return typeof e=="number"&&!isNaN(e)}function yi(e){return e==null||typeof e=="string"&&e.trim()===""||!e&&e!==0&&e!=="0"&&e!==!1}function Yt(e){const{paddingTop:t,paddingBottom:i,paddingLeft:s,paddingRight:r,worldRect:a,canvas:o,text:l}=e.calculative;let{textLeft:n,textTop:h,textWidth:c,textHeight:f}=e.calculative,u=s,d=t;const v=a.width-s-r,g=a.height-t-i;c&&c<1&&(c*=a.width),f&&f<1&&(f*=a.height),c<e.calculative.fontSize&&(c=e.calculative.fontSize),u+=(n||0)+a.x,d+=(h||0)+a.y;const y=e.textAlign||o.store.options.textAlign,p=e.textBaseline||o.store.options.textBaseline;switch(y){case"center":u+=(v-(c||v))/2;break;case"right":u+=v-(c||v);break}switch(p){case"middle":d+=(g-(f||g))/2;break;case"bottom":d+=g-(f||g);break}const b={x:u,y:d,width:c||v,height:f||g};bt(b),e.calculative.worldTextRect=b,Ne(e),e.calculative.textDrawRect=void 0}function as(e,t){const i=t.calculative;if(yi(i.text))return;i.textLines||Ne(t);const{worldTextRect:s,textLines:r,fontSize:a,lineHeight:o,canvas:l}=i;if(!r)return;const n=a*o,h=r.length*n;t.calculative.fontsChecked!==!1&&(document.fonts.check(e.font)?t.calculative.fontsChecked=!1:t.calculative.fontsChecked=!0);const c=Va(e,t);let f=s.x+(s.width-c)/2,u=s.y+(s.height-h)/2;const{options:d}=l.store;switch(t.textAlign||d.textAlign){case"left":f=s.x;break;case"right":f=s.x+s.width-c;break}switch(t.textBaseline||d.textBaseline){case"top":u=s.y;break;case"bottom":u=s.ey-h;break}t.calculative.textDrawRect={x:f,y:u,width:c,height:h},bt(t.calculative.textDrawRect)}function Ne(e,t=e.calculative.text){const i=e.calculative;if(yi(t)){i.textLines=void 0;return}let s=typeof t=="string"?t:t.toString();const{whiteSpace:r,ellipsis:a}=e,{keepDecimal:o}=i;if(o!=null&&s.trim()!==""){const u=Number(s);isNaN(u)||(s=u.toFixed(o))}let l=[];const n=i.fontSize*i.lineHeight,h=i.worldTextRect.height,c=Math.floor(h/n),f=c>1?c:1;switch(r){case"nowrap":if(a!==!1){const v=As([...s],e);v[0]&&(l.push(v[0]),v.length>1&&Bi(l))}else l.push(s);break;case"pre-line":l=s.split(/[\n]/g),a!==!1&&l.length>f&&(l=l.slice(0,f),Bi(l));break;case"break-all":default:const u=s.split(/[\n]/g);let d=0;t:for(const v of u){const g=r==="break-all"?v.split(""):br(v);let y=As(g,e);if(y.length===0&&(y=[""]),a!=!1)for(const p of y)if(d++,d>f){Bi(l);break t}else l.push(p);else l.push(...y)}break}return i.textLines=l,l}function br(e=""){const t=[];let i="";for(let s=0;s<e.length;++s){const r=e.charCodeAt(s);r<33||r>126?(i&&(t.push(i),i=""),t.push(e[s])):i+=e[s]}return i&&t.push(i),t}function As(e,t){const i=t.calculative.canvas,s=i.offscreen.getContext("2d"),{fontStyle:r,fontWeight:a,fontSize:o,fontFamily:l,lineHeight:n}=t.calculative;s.save();const h=[];let c=e[0]||"";for(let f=1;f<e.length;++f){const u=e[f]||"",d=c+u;let v=0;if(i.store.options.measureTextWidth)s.font=_t({fontStyle:r,fontWeight:a,fontFamily:l||i.store.options.fontFamily,fontSize:o,lineHeight:n}),v=s.measureText(d).width;else{const y=d.match(/[^\x00-\xff]/g)||"",p=y.length*o,b=d.match(/\s/g)||"",m=b.length*o*.3,k=(d.length-y.length-b.length)*o*.6;v=p+m+k}const g=t.calculative.worldTextRect.width;v<=g+.1?c+=u:(c.length&&h.push(c),c=u)}return c.length&&h.push(c),s.restore(),h}function Va(e,t){let i=0;return t.calculative.textLineWidths=[],t.calculative.textLines&&t.calculative.textLines.forEach(s=>{let r;t.calculative.textType?r=Ua(s,t)+s.length*t.calculative.letterSpacing:r=e.measureText(s).width+s.length*t.calculative.letterSpacing,t.calculative.textLineWidths.push(r),i<r&&(i=r)}),i}function Ua(e,t){const i=t.calculative.fontSize,s=e.match(/[^\x00-\xff]/g)||"",r=s.length*i,a=e.match(/\s/g)||"",o=a.length*i*(t.CSmultiple||.5),l=(e.length-s.length-a.length)*i*(t.CEmultiple||.54);return r+o+l}function Bi(e){e[e.length-1]=e[e.length-1].slice(0,-3)+"..."}function qa(e){let t=e.text.split(`
|
|
2
2
|
`);const i=e.calculative.canvas,s=i.offscreen.getContext("2d"),{fontStyle:r,fontWeight:a,fontSize:o,fontFamily:l,lineHeight:n}=e.calculative;let h=0,c=0;s.save();for(let u=0;u<t.length;u++){if(i.store.options.measureTextWidth)s.font=_t({fontStyle:r,fontWeight:a,fontFamily:l||i.store.options.fontFamily,fontSize:o,lineHeight:n}),c=s.measureText(t[u]).width+t[u].length*e.calculative.letterSpacing;else{const d=t[u].match(/[^\x00-\xff]/g)||"",v=d.length*o,g=t[u].match(/\s/g)||"",y=g.length*o*.3,p=(t[u].length-d.length-g.length)*o*.6;c=v+y+p+t[u].length*e.calculative.letterSpacing}c>h&&(h=c)}s.restore();let f=t.length*o*n;e.textAlign==="left"||(e.textAlign==="right"?e.x=e.x-(h-e.width):e.x=e.x-(h-e.width)/2),e.textBaseline==="top"||(e.textBaseline==="bottom"?e.y=e.y-(f-e.height):e.y=e.y-(f-e.height)/2),e.height=f+5,e.width=h+5,e.calculative.canvas.updatePenRect(e),e.calculative.canvas.calcActiveRect()}function K(e,t=!1){if(Array.isArray(e)){const i=[];return e.forEach(s=>{i.push(K(s,t))}),i}else if(typeof e=="object"){if(e===null)return null;if(e.constructor===RegExp)return e;const i={};for(const s in e)if(!(["canvas","lastFrame","socketFn"].includes(s)||e[s]instanceof HTMLImageElement||e[s]instanceof HTMLCanvasElement||e[s]instanceof HTMLMediaElement)){{if(s==="calculative"&&!t)continue;if(s==="singleton"){t?i[s]={}:i[s]=e[s];continue}}i[s]=K(e[s],t)}return i}return e}function Yi(e,t,i){if(Array.isArray(e)){const s=[];return e.forEach(r=>{s.push(Yi(r,t,i))}),s}else if(typeof e=="object"){if(e===null)return null;for(const s in e)if(t.includes(s))if(Array.isArray(e[s]))e[s].forEach((r,a)=>{Number.isNaN(Number(r))||(e[s][a]=Number(r*i))});else{if(Number.isNaN(Number(e[s])))continue;e[s]=Number(e[s])*i}else e[s]=Yi(e[s],t,i);return e}return e}const Bt={};function xr(e,t,i){if(!Bt[t.fromArrow])return;const s=xt(t),{x:r,y:a}=s,o={x:r,y:a};if(o.step=(t.fromArrowSize||10)*i.data.scale,s.next)o.rotate=jt(s.next,s)+90;else{const n=t.calculative.worldAnchors[1];if(!n)return;n.prev?o.rotate=jt(n.prev,s)+90:o.rotate=jt(n,s)+90}e.save(),e.beginPath(),e.setLineDash([]);const l=t.fromArrowColor||t.calculative.color;l&&(e.strokeStyle=l),Bt[t.fromArrow](e,t,i,o),e.restore()}function kr(e,t,i){if(!Bt[t.toArrow]||t.calculative.worldAnchors.length<2)return;e.save();const s=dt(t),{x:r,y:a}=s,o={x:r,y:a};if(o.step=(t.toArrowSize||10)*i.data.scale,s.prev)o.rotate=jt(s.prev,s)+90;else{const n=t.calculative.worldAnchors[t.calculative.worldAnchors.length-2];n.next?o.rotate=jt(n.next,s)+90:o.rotate=jt(n,s)+90}e.beginPath(),e.setLineDash([]);const l=t.toArrowColor||t.calculative.color;l&&(e.strokeStyle=l),Bt[t.toArrow](e,t,i,o),e.restore()}Bt.triangleSolid=(e,t,i,s)=>{e.save(),e.translate(s.x,s.y),e.rotate(s.rotate*Math.PI/180),e.translate(-s.x,-s.y);const r=s.x-s.step;e.moveTo(r,s.y-s.step/4),e.lineTo(s.x,s.y),e.lineTo(r,s.y+s.step/4),e.closePath(),e.stroke(),e.fillStyle=e.strokeStyle,e.fill(),e.restore()};Bt.reTriangleSolid=(e,t,i,s)=>{e.save(),e.translate(s.x,s.y),e.rotate(s.rotate*Math.PI/180),e.translate(-s.x,-s.y);const r=s.x-s.step/2;e.moveTo(s.x,s.y-s.step/2),e.lineTo(r,s.y),e.lineTo(s.x,s.y+s.step/2),e.closePath(),e.stroke(),e.fillStyle=e.strokeStyle,e.fill(),e.restore()};Bt.triangle=(e,t,i,s)=>{e.save(),e.lineWidth<2&&(e.lineWidth=2),e.translate(s.x,s.y),e.rotate(s.rotate*Math.PI/180),e.translate(-s.x,-s.y);const r=s.x-s.step;e.moveTo(r,s.y-s.step/4),e.lineTo(s.x,s.y),e.lineTo(r,s.y+s.step/4),e.closePath(),e.stroke(),e.fillStyle=i.data.background||"#ffffff",e.fill(),e.restore()};Bt.circleSolid=(e,t,i,s)=>{e.save(),e.translate(s.x,s.y),e.rotate(s.rotate*Math.PI/180),e.translate(-s.x,-s.y);const r=s.step/2;e.arc(s.x-r,s.y,r,0,2*Math.PI),e.stroke(),e.fillStyle=e.strokeStyle,e.fill(),e.restore()};Bt.circle=(e,t,i,s)=>{e.save(),e.translate(s.x,s.y),e.rotate(s.rotate*Math.PI/180),e.translate(-s.x,-s.y);const r=s.step/2;e.arc(s.x-r,s.y,r,0,2*Math.PI),e.stroke(),e.fillStyle=i.data.background||"#ffffff",e.fill(),e.restore()};Bt.diamondSolid=(e,t,i,s)=>{e.save(),e.translate(s.x,s.y),e.rotate(s.rotate*Math.PI/180),e.translate(-s.x,-s.y);const r=s.x-s.step,a=s.step/2;e.moveTo(r,s.y),e.lineTo(r+a,s.y-a/2),e.lineTo(s.x,s.y),e.lineTo(r+a,s.y+a/2),e.closePath(),e.stroke(),e.fillStyle=e.strokeStyle,e.fill(),e.restore()};Bt.diamond=(e,t,i,s)=>{e.save(),e.translate(s.x,s.y),e.rotate(s.rotate*Math.PI/180),e.translate(-s.x,-s.y);const r=s.x-s.step,a=s.step/2;e.moveTo(r,s.y),e.lineTo(r+a,s.y-a/2),e.lineTo(s.x,s.y),e.lineTo(r+a,s.y+a/2),e.closePath(),e.stroke(),e.fillStyle=i.data.background||"#ffffff",e.fill(),e.restore()};Bt.line=(e,t,i,s)=>{e.save(),e.translate(s.x,s.y),e.rotate(s.rotate*Math.PI/180),e.translate(-s.x,-s.y);const r=s.x-s.step;e.moveTo(r,s.y-s.step/3),e.lineTo(s.x,s.y),e.lineTo(r,s.y+s.step/3),e.stroke(),e.restore()};Bt.lineUp=(e,t,i,s)=>{e.save(),e.translate(s.x,s.y),e.rotate(s.rotate*Math.PI/180),e.translate(-s.x,-s.y);const r=s.x-s.step;e.moveTo(r,s.y-s.step/3),e.lineTo(s.x,s.y),e.stroke(),e.restore()};Bt.lineDown=(e,t,i,s)=>{e.save(),e.translate(s.x,s.y),e.rotate(s.rotate*Math.PI/180),e.translate(-s.x,-s.y);const r=s.x-s.step;e.moveTo(r,s.y+s.step/3),e.lineTo(s.x,s.y),e.stroke(),e.restore()};function Xi(e){const t=parseInt,i=Math.round;let s=e.length,r={};if(s>9){const[a,o,l,n]=e=e.split(",");if(s=e.length,s<3||s>4)return null;r.r=t(a[3]=="a"?a.slice(5):a.slice(4)),r.g=t(o),r.b=t(l),r.a=n?parseFloat(n):-1}else{if(s==8||s==6||s<4)return null;s<6&&(e="#"+e[1]+e[1]+e[2]+e[2]+e[3]+e[3]+(s>4?e[4]+e[4]:"")),e=t(e.slice(1),16),s==9||s==5?(r.r=e>>24&255,r.g=e>>16&255,r.b=e>>8&255,r.a=i((e&255)/.255)/1e3):(r.r=e>>16,r.g=e>>8&255,r.b=e&255,r.a=-1)}return r}function St(e,t,i,s){let r,a,o,l,n,h,c,f=Math.round,u=typeof i=="string";return typeof e!="number"||e<-1||e>1||typeof t!="string"||t[0]!="r"&&t[0]!="#"||i&&!u||(c=t.length>9,c=u?i.length>9?!0:i=="c"?!c:!1:c,n=Xi(t),l=e<0,h=i&&i!="c"?Xi(i):l?{r:0,g:0,b:0,a:-1}:{r:255,g:255,b:255,a:-1},e=l?e*-1:e,l=1-e,!n||!h)?null:(s?(r=f(l*n.r+e*h.r),a=f(l*n.g+e*h.g),o=f(l*n.b+e*h.b)):(r=f((l*n.r**2+e*h.r**2)**.5),a=f((l*n.g**2+e*h.g**2)**.5),o=f((l*n.b**2+e*h.b**2)**.5)),u=n.a,h=h.a,n=u>=0||h>=0,u=n?u<0?h:h<0?u:u*l+h*e:0,c?"rgb"+(n?"a(":"(")+r+","+a+","+o+(n?","+f(u*1e3)/1e3:"")+")":"#"+(4294967296+r*16777216+a*65536+o*256+(n?f(u*255):0)).toString(16).slice(1,n?void 0:-2))}globalThis.pSBC=St;function mi(e,t){const i=Xi(e)||{r:0,g:0,b:0};return i.a<0?`rgba(${i.r},${i.g},${i.b},${t})`:`rgba(${i.r},${i.g},${i.b},${t+i.a})`}function Re(e,t){if(isNaN(e)){console.warn("realValue not number");return}if(typeof t!="string"){console.warn("collection must be string");return}const[i,s]=[t[0],t[t.length-1]];if(!["[","("].includes(i)){console.warn('collection must start with "[" or "("');return}if(!["]",")"].includes(s)){console.warn('collection must end with "]" or ")"');return}const r=t.substring(1,t.length-1).split(",");if(r.length!==2){console.warn("collection must have 2 numbers");return}const[a,o]=[+r[0],+r[1]];if(a>=o){console.warn("startNum must less than endNum");return}return e>a||i==="["&&e===a?e<o||s==="]"&&e===o:!1}function Te(e,t){if(typeof t!="string"){console.warn("collection must be string");return}const[i,s]=[t[0],t[t.length-1]];if(i!=="["||s!=="]"){console.warn('collection must start with "[" and end with "]"');return}const r=t.substring(1,t.length-1).split(",");for(const a of r)if(a.includes("..")){const[o,l]=a.split(".."),[n,h]=[+o,+l];if(n>=h){console.warn("startNum must less than endNum");return}if(e>=n&&e<=h)return!0}else if(e==a)return!0;return!1}function Rr(e,t,i){const s=1-e;return 3*s*s*e*t+3*s*e*e*i+e*e*e}function $a(e){const t=e.match(/^-?\d*\.?\d*/);if(e=t?t[0]:"",e.includes("-")&&e.indexOf("-")!==0&&(e=e.replace(/-/g,""),e&&(e="-"+e)),(e.match(/\./g)||[]).length>1){const s=e.split(".");e=s[0]+"."+s.slice(1).join("")}return e}function lt(){return((1+Math.random())*4294967296|0).toString(16).substring(1)}const Zt=e=>{let t=0,i=0,s=0,r=0;return typeof e=="number"?t=i=s=r=e:typeof e=="string"?t=i=s=r=parseInt(e,10):Array.isArray(e)&&(t=e[0],s=Ni(e[1])?e[0]:e[1],r=Ni(e[2])?e[0]:e[2],i=Ni(e[3])?s:e[3]),[t,s,r,i]};function Ni(e){return e==null}async function Ya(e){return new Promise((t,i)=>{const s=new FileReader;s.onload=r=>{t(r.target.result)},s.onerror=r=>{i(r)},s.readAsDataURL(e)})}async function Xa(e,t,i,s){const r=new FormData;if(r.append("file",e),i)for(const o in i)i.hasOwnProperty(o)&&r.append(o,i[o]);return(await(await fetch(t,{method:"POST",headers:s,body:r})).json()).url}function Ka(e,t,i){var s=document.createElement("link");s.href=e,s.rel="stylesheet",t&&(s.onload=t),document.head.appendChild(s)}function Ie(e){let t=e||window.location.search.split("?")[1];const i=new URLSearchParams(t);return Object.fromEntries(i.entries())}function pi(e){let t;const i=new RegExp("(^| )"+e+"=([^;]*)(;|$)");return(t=document.cookie.match(i))?decodeURIComponent(t[2]):""}var wi;(function(e){e[e.None=0]="None",e[e.LocalStorage=1]="LocalStorage",e[e.Cookie=2]="Cookie"})(wi||(wi={}));const Ga=location.host.indexOf("le5le.com")!==-1;function Ue(){let e="";const t=globalThis.le5leTokenName??"token";switch(globalThis.le5leTokenType){case wi.LocalStorage:e=localStorage.getItem(t);break;case wi.Cookie:e=pi(t);break;default:e=Ga?pi(t):localStorage.getItem(t)}return(globalThis.TokenPrefix??"Bearer ")+(globalThis.le5leTokenD?Tr(e):e)}function Tr(e){if(!e)return e;const t=e.split("");for(let i=0;i<Math.min(10,t.length);i++){const s=t[i],r=i+1;if(new RegExp("[0-9]","").test(s)){let o=parseInt(s,10)-r;for(;o<0;)o+=10;t[i]=o.toString()}else if(new RegExp("[A-Z]","").test(s)){let o=s.charCodeAt(0)-65-r;for(;o<0;)o+=26;t[i]=String.fromCharCode(o+65)}else if(new RegExp("[a-z]","").test(s)){let o=s.charCodeAt(0)-97-r;for(;o<0;)o+=26;t[i]=String.fromCharCode(o+97)}}return t.join("")}async function os(e,t){var n,h;if(globalThis.getMeta2dData)return await globalThis.getMeta2dData(t);const i=e.options.navigatorNetWork;let r=`/api/data/${location.href.includes("2d.")||location.href.includes("/2d")?"2d":"v"}/get`,a=((n=Ie())==null?void 0:n.id)||r.includes("${id}");if(!a&&((h=Ie())==null?void 0:h.data)){r=`./projects/${t}`;const f=new URL(window.location);f.searchParams.set("data",t),history.pushState({},"",f)}i!=null&&i.url&&(i.url.includes("${id}")?r=i.url.replace("${id}",t):r=i.url+((i==null?void 0:i.method)==="GET"?`?id=${t}`:""));let o=(i==null?void 0:i.method)||"POST";a||(o="GET");const l=await fetch(r,{headers:{Authorization:Ue()},method:o,body:o==="GET"?void 0:JSON.stringify({id:t})});if(l.ok){let c=await l.text();return c.constructor===Object||c.constructor===Array?c=JSON.parse(JSON.stringify(c)):typeof c=="string"&&(c=JSON.parse(c)),c.data&&(c=c.data),c}else e.emitter.emit("error",{type:"http",error:l})}function Et(e,t){if(t==null)return e;const i=t.split(".");for(;i.length&&(e=e[i.shift()]););return e}function bi(e,t,i){t!=null&&t.split(".").reduce((s,r,a)=>s[r]=t.split(".").length===++a?i:s[r]||{},e)}function Cr(){}function ns(e){return!!(e!=null&&e.allowScript)}function It(e,...t){return ns(e)?new Function(...t):Cr}function ii(e,...t){if(!ns(e))return async()=>{};const i=Object.getPrototypeOf(async function(){}).constructor;return new i(...t)}function Ja(e,t){return ns(e)?It(e,`return (${t})`)():Cr}function xi(e,t,i){const s=["天","一","二","三","四","五","六"];let r=new Date;t&&(r=new Date(t));const a=r.getFullYear(),o=r.getMonth()+1,l=r.getDate(),n=r.getDay(),h=r.getHours(),c=r.getMinutes(),f=r.getSeconds();if(!e)return`${a}:${o}:${l} ${h}:${c}:${f} 星期${s[n]}`;let u=It(i,"year","month","day","week","hours","minutes","seconds",`return ${e}`);const d=u(a,o,l,s[n],h,c,f);return u=null,d}const Fi=new WeakMap;function Qa(e,t,i){let s=Fi.get(e);return s?clearTimeout(s.timer):(s={},Fi.set(e,s)),new Promise((r,a)=>{s.timer=setTimeout(async()=>{r(await e(i)),Fi.delete(e)},t)})}class ls{static debounce(t,i,s=300){const r=Symbol(`${t.constructor.name}.${i}`);this.instances.has(t)||this.instances.set(t,{});const a=this.instances.get(t);return(...o)=>{a[r]&&clearTimeout(a[r]),a[r]=setTimeout(()=>{t[i](...o),delete a[r]},s)}}}D(ls,"instances",new WeakMap);const Ss="line",ki="repeat";function Za(e,t){if(!e||!t)return!1;let i=Mt(e);for(;i;){if(i.id===t.id)return!0;i=Mt(i)}return!1}function Mt(e,t){if(!e||!e.parentId||!e.calculative)return;const s=e.calculative.canvas.store.pens[e.parentId];return t&&Mt(s,t)||s}function Pt(e,t){if(!e||!e.children)return[];const i=[];return e.children.forEach(s=>{const r=t.pens[s];r&&(i.push(r),i.push(...Pt(r,t)))}),i}function cs(e,t){if(!e||!e.followers)return[];const i=[];return e.followers.forEach(s=>{const r=t.pens[s];r&&!r.parentId&&(i.push(r),i.push(...cs(r,t)))}),i}function to(e,t){const{worldRect:i,gradientFromColor:s,gradientToColor:r,gradientAngle:a}=t.calculative;return Sr(e,i,s,r,a)}function eo(e,t){const{worldRect:i,gradientFromColor:s,gradientToColor:r,gradientRadius:a}=t.calculative;if(!s||!r)return;const{width:o,height:l,center:n}=i,{x:h,y:c}=n;let f=o;f<l&&(f=l),f*=.5;const u=e.createRadialGradient(h,c,f*(a||0),h,c,f);return u.addColorStop(0,s),u.addColorStop(1,r),u}function io(e,t,i,s,r){let a=0;a=Math.PI/2-Math.atan2(s-t,i-e);const o=(e+i)/2,l=(t+s)/2,n=o+r*Math.sin(90*Math.PI/180-a),h=l+r*-Math.cos(90*Math.PI/180-a),c=o+r*Math.sin(270*Math.PI/180-a),f=l+r*-Math.cos(270*Math.PI/180-a);return[n,h,c,f]}function so(e,t){const{worldRect:i,gradientColors:s,gradientRadius:r}=t.calculative;if(!s)return;let a=t.calculative.gradientColors;t.calculative.checked&&(a=t.calculative.onGradientColors);const{width:o,height:l,center:n}=i,{x:h,y:c}=n;let f=o;f<l&&(f=l),f*=.5;const{colors:u}=oe(a),d=e.createRadialGradient(h,c,f*(r||0),h,c,f);return u.forEach(v=>{d.addColorStop(v.i,v.color)}),d}function ro(e,t){const{x:i,y:s,ex:r,width:a,height:o,center:l}=t.calculative.worldRect;let n=[{x:r,y:s+o/2},{x:i,y:s+o/2}],h=t.calculative.gradientColors;t.calculative.checked&&(h=t.calculative.onGradientColors);const{angle:c,colors:f}=oe(h);let u=Li(c,a,o);return n.forEach(d=>{vt(d,c,l)}),Qe(e,n,f,u)}function ao(e,t){const{worldRect:i,textGradientColors:s}=t.calculative;if(!s)return;const{width:r,height:a,center:o}=i,{x:l,y:n}=o;let h=r;h<a&&(h=a),h*=.5;const{colors:c}=oe(s),f=e.createRadialGradient(l,n,0,l,n,h);return c.forEach(u=>{f.addColorStop(u.i,u.color)}),f}function oo(e,t){!t.calculative.textDrawRect&&as(e,t),yt(t.calculative.textDrawRect);const{x:i,y:s,ex:r,width:a,height:o,center:l}=t.calculative.textDrawRect;let n=[{x:r,y:s+o/2},{x:i,y:s+o/2}];const{angle:h,colors:c}=oe(t.calculative.textGradientColors);let f=Li(h,a,o);return n.forEach(u=>{vt(u,h,l)}),Qe(e,n,c,f)}function no(e,t){const{worldIconRect:i,iconGradientColors:s}=t.calculative;if(!s||!i)return;const{x:r,y:a,ex:o,width:l,height:n,center:h}=i;let c=[{x:o,y:a+n/2},{x:r,y:a+n/2}];const{angle:f,colors:u}=oe(s);let d=Li(f,l,n);return c.forEach(v=>{vt(v,f,h)}),Qe(e,c,u,d)}function lo(e,t){const{worldIconRect:i,iconGradientColors:s,iconGradientRadius:r}=t.calculative;if(!s||!i)return;const{width:a,height:o,center:l}=i,{x:n,y:h}=l;let c=a;c<o&&(c=o),c*=.5;const{colors:f}=oe(s),u=e.createRadialGradient(n,h,c*(r||0),n,h,c);return f.forEach(d=>{u.addColorStop(d.i,d.color)}),u}function Li(e,t,i){const s=Math.atan(i/t)/Math.PI*180;let r=(e-90)%360,a=0;return r>s&&r<180-s||r>180+s&&r<360-s||r<0?(r>270?r=360-r:r>180?r=r-180:r>90&&(r=180-r),a=Math.abs(i/Math.sin(r/180*Math.PI)/2)):(r>270?r=360-r:r>180?r=r-180:r>90&&(r=180-r),a=Math.abs(t/Math.cos(r/180*Math.PI)/2)),a}function oe(e){if(typeof e!="string"||!e.startsWith("linear-gradient"))return{angle:0,colors:[]};const t=e.indexOf("("),i=e.lastIndexOf(")");if(t===-1||i===-1||i<=t)return{angle:0,colors:[]};const s=e.slice(t+1,i).trim(),r=co(s);if(r.length===0)return{angle:0,colors:[]};let a=0,o=0;const l=r[0].trim();l.endsWith("deg")?(a=parseFloat(l),o=1):l.startsWith("to ")&&(a=uo(l),o=1);const n=[];for(let c=o;c<r.length;c++){const f=ho(r[c].trim());f&&n.push(f)}if(n.length===0)return{angle:a,colors:[]};fo(n);const h=n.map(c=>({color:c.color,i:c.offset/100}));return{angle:a,colors:h}}function co(e){const t=[];let i="",s=0;for(let r=0;r<e.length;r++){const a=e[r];a==="("?(s++,i+=a):a===")"?(s--,i+=a):a===","&&s===0?(t.push(i),i=""):i+=a}return i.trim()&&t.push(i),t}function ho(e){if(!e)return null;const t=e.match(/^(.+?)\s+(\d+(?:\.\d+)?%)\s*$/);return t?{color:Ps(t[1].trim()),offset:parseFloat(t[2])}:{color:Ps(e)}}function Ps(e){return/^rgba?\s*\(/.test(e)?vo(e):e}function uo(e){return{"to top":90,"to right":180,"to bottom":270,"to left":0,"to top right":135,"to right top":135,"to bottom right":225,"to right bottom":225,"to bottom left":315,"to left bottom":315,"to top left":45,"to left top":45}[e]??0}function fo(e){if(e.length===0)return;e[0].offset==null&&(e[0].offset=0),e[e.length-1].offset==null&&(e[e.length-1].offset=100);let t=0;for(;t<e.length;)if(e[t].offset==null){let i=t-1,s=t+1;for(;s<e.length&&e[s].offset==null;)s++;const r=e[i].offset,a=e[s].offset,o=s-i;for(let l=1;l<o;l++)e[i+l].offset=r+(a-r)*(l/o);t=s}else t++}function vo(e){if(/rgba?/.test(e)){let t=e.split(",");if(t.length<3)return"";e="#";for(let i=0,s;s=t[i++];)if(i<4)s=parseInt(s.replace(/[^\d]/gi,""),10).toString(16),e+=s.length==1?"0"+s:s;else{s=s.replace(")","");let a=parseInt(s*255+"").toString(16);a=a.length===2?a:"0"+a,e+=a}e=e.toUpperCase()}return e}function go(e,t){const{x:i,y:s,ex:r,width:a,height:o,center:l}=t.calculative.worldRect;let n=[{x:r,y:s+o/2},{x:i,y:s+o/2}];const{angle:h,colors:c}=oe(t.calculative.lineGradientColors);let f=Li(h,a,o);return n.forEach(u=>{vt(u,h,l)}),Qe(e,n,c,f)}function Qe(e,t,i,s){let r=io(t[0].x,t[0].y,t[1].x,t[1].y,s),a=e.createLinearGradient(r[0],r[1],r[2],r[3]);return i.forEach(o=>{a.addColorStop(o.i,o.color)}),a}function le(e,t,i){let s=[];t.calculative.gradientColorStop?s=t.calculative.gradientColorStop:(s=oe(t.calculative.lineGradientColors).colors,t.calculative.gradientColorStop=s),e.strokeStyle=Qe(e,i,s,t.calculative.lineWidth/2),e.beginPath(),e.moveTo(i[0].x,i[0].y),e.lineTo(i[1].x,i[1].y),e.stroke()}function Ar(e,t){const i=t.calculative.worldAnchors;let s=t.calculative.lineWidth*(t.calculative.gradientSmooth||t.calculative.lineSmooth||0);for(let r=0;r<i.length-1;r++)if((t.lineName==="curve"||t.lineName==="mind")&&i[r].curvePoints){if(r>0){let l=i[r-1].curvePoints;l?si(e,t,s,l[l.length-1],i[r],i[r].curvePoints[0]):si(e,t,s,i[r-1],i[r],i[r].curvePoints[0]);let n=te(s,i[r],i[r].curvePoints[0]);le(e,t,[n,i[r].curvePoints[1]])}else le(e,t,[i[r],i[r].curvePoints[0]]),le(e,t,[i[r].curvePoints[0],i[r].curvePoints[1]]);let a=i[r].curvePoints.length-1;for(let l=1;l<a;l++)le(e,t,[i[r].curvePoints[l],i[r].curvePoints[l+1]]);let o=te(s,i[r+1],i[r].curvePoints[a]);le(e,t,[i[r].curvePoints[a],o])}else{let a=i[r],o=i[r+1];if(r>0&&r<i.length-1){let n=i[r-1].curvePoints;n?si(e,t,s,n[n.length-1],i[r],i[r+1]):si(e,t,s,i[r-1],i[r],i[r+1])}r>0&&r<i.length-1&&(a=te(s,i[r],i[r+1])),r<i.length-2&&(o=te(s,i[r+1],i[r]));let l=!1;if(r===0&&t.fromLineCap&&t.fromLineCap!=="butt"&&(e.save(),l=!0,e.lineCap=t.fromLineCap),r!==0&&r===i.length-2&&t.toLineCap&&t.toLineCap!=="butt"&&(e.save(),l=!0,e.lineCap=t.toLineCap),le(e,t,[a,o]),l&&e.restore(),i.length===2&&r===0){e.save(),l=!0,e.lineCap=t.toLineCap;let n=.1,h=.1;a.x-o.x===0?h=0:n=(a.y-o.y)/(a.x-o.x)*.1,le(e,t,[{x:o.x-h,y:o.y-n},o]),e.restore()}}}function te(e,t,i){let s=Math.sqrt((i.x-t.x)*(i.x-t.x)+(i.y-t.y)*(i.y-t.y));return s===0?{x:t.x,y:t.y}:e<s?{x:t.x+(i.x-t.x)*e/s,y:t.y+(i.y-t.y)*e/s}:{x:t.x+(i.x-t.x)/s/2,y:t.y+(i.y-t.y)/s/2}}function si(e,t,i,s,r,a){let o=te(i,r,s),l=te(i,r,a),n={x:r.x,y:r.y},h=yo(t.calculative.canvas.store.data.smoothNum||20,o,n,l);for(let c=0;c<h.length-1;c++)le(e,t,[{x:h[c].x,y:h[c].y},{x:h[c+1].x,y:h[c+1].y}])}function Is(e,t,i,s){let r=te(t,i,s),a={x:i.x,y:i.y};e.quadraticCurveTo(a.x,a.y,r.x,r.y)}function hs(e){const t=e.calculative.worldAnchors;let i=e.calculative.lineWidth*(e.calculative.gradientSmooth||e.calculative.lineSmooth||0);const s=new Path2D;for(let r=0;r<t.length-1;r++){t[r];let a=t[r+1];if(r==0&&s.moveTo(t[r].x,t[r].y),r>0&&r<t.length-1){let o=t[r-1].curvePoints;Is(s,i,t[r],t[r+1])}r>0&&r<t.length-1&&te(i,t[r],t[r+1]),r<t.length-2&&(a=te(i,t[r+1],t[r])),s.lineTo(a.x,a.y)}return s}function yo(e=100,t,i,s,r){let a=null;const o=[];!s&&!r?a=mo:s&&!r&&(a=po);for(let l=0;l<e;l++)o.push(a(l/e,t,i,s,r));return s&&o.push(s),o}function mo(e,t,i){const{x:s,y:r}=t,{x:a,y:o}=i;let l=s+(a-s)*e,n=r+(o-r)*e;return{x:l,y:n}}function po(e,t,i,s){const{x:r,y:a}=t,{x:o,y:l}=i,{x:n,y:h}=s;let c=(1-e)*(1-e)*r+2*e*(1-e)*o+e*e*n,f=(1-e)*(1-e)*a+2*e*(1-e)*l+e*e*h;return{x:c,y:f}}function wo(e,t){const{worldRect:i,lineGradientFromColor:s,lineGradientToColor:r,lineGradientAngle:a}=t.calculative;return Sr(e,i,s,r,a)}function Sr(e,t,i,s,r){if(!i||!s)return;const{x:a,y:o,center:l,ex:n,ey:h}=t,c={x:a,y:l.y},f={x:n,y:l.y};r%90===0&&r%180?(c.x=l.x,f.x=l.x,r%270?(c.y=o,f.y=h):(c.y=h,f.y=o)):r&&(vt(c,r,t.center),vt(f,r,t.center));const u=e.createLinearGradient(c.x,c.y,f.x,f.y);return u.addColorStop(0,i),u.addColorStop(1,s),u}function bo(e){const{worldIconRect:t,iconWidth:i,iconHeight:s,imgNaturalWidth:r,imgNaturalHeight:a,worldRect:o}=e.calculative;if(!t)return{x:o.x,y:o.y,width:o.width||r||e.calculative.img.naturalWidth,height:o.height||a||e.calculative.img.naturalHeight};let{x:l,y:n,width:h,height:c}=t;if(i&&(h=i),s&&(c=s),r&&a&&e.imageRatio){const f=t.width/r,u=t.height/a,d=Math.min(f,u),v=r/a;i?c=i/v:s?h=s*v:(h=d*r,c=d*a)}switch(l+=(t.width-h)/2,n+=(t.height-c)/2,e.iconAlign){case"top":n=t.y;break;case"bottom":n=t.ey-c;break;case"left":l=t.x;break;case"right":l=t.ex-h;break;case"left-top":l=t.x,n=t.y;break;case"right-top":l=t.ex-h,n=t.y;break;case"left-bottom":l=t.x,n=t.ey-c;break;case"right-bottom":l=t.ex-h,n=t.ey-c;break}return{x:l,y:n,width:h,height:c}}function Me(e,t){const{x:i,y:s,width:r,height:a}=bo(t),{worldIconRect:o,iconRotate:l}=t.calculative;let{img:n}=t.calculative;if(e.getSerializedSvg&&(n!=null&&n.toDataURL)){const h=new Image;h.src=n.toDataURL("image/png"),n=h}if(e.filter=t.filter,l){const{x:h,y:c}=o.center;e.translate(h,c),e.rotate(l*Math.PI/180),e.translate(-h,-c)}if(t.imageRadius){e.save();let h=t.calculative.imageRadius||0,c=h;const{x:f,y:u,width:d,height:v,ex:g,ey:y}=t.calculative.worldRect;h<1&&(h=d*h,c=v*c);let p=h<c?h:c;d<2*p&&(p=d/2),v<2*p&&(p=v/2),e.beginPath(),e.moveTo(f+p,u),e.arcTo(g,u,g,y,p),e.arcTo(g,y,f,y,p),e.arcTo(f,y,f,u,p),e.arcTo(f,u,g,u,p),e.clip(),e.drawImage(n,i,s,r,a),e.restore()}else{let h=s,c=0;if(t.thumbImg){let f=n.naturalWidth,u=n.naturalHeight;c=(a/r*f-u)/2,a-2*c<0&&(c=(a-u/f*r)/2),h=s+c}e.drawImage(n,i,h,r,a-2*c)}}function Gt(e,t){const{textColor:i,color:s}=e.calculative,{styles:r}=t;return i||s||r.textColor||r.color}function Pr(e,t){const{fontStyle:i,fontWeight:s,fontSize:r,fontFamily:a,lineHeight:o,text:l,hiddenText:n,canvas:h,textHasShadow:c,textBackground:f,textType:u}=t.calculative;if(t.input&&yi(t.text)&&t.calculative.canvas.inputDiv.dataset.penId!==t.id&&!t.onShowInput){e.save(),e.font=_t({fontStyle:i,fontWeight:s,fontFamily:a,fontSize:r,lineHeight:o}),e.textBaseline="top",e.fillStyle=t.placeholderColor||"#c0c0c0";const S=e.measureText(t.placeholder||"请输入").width,I=t.calculative.worldTextRect;let E=0;const z=r*o;let U=(I.height-z)/2;t.textAlign==="center"?E=(I.width-S)/2:t.textAlign==="right"&&(E=I.width-S),t.textBaseline==="top"?U=0:t.textBaseline==="bottom"&&(U=I.height-z),e.fillText(t.placeholder||"请输入",I.x+E,I.y+U+_s(e,t.placeholder||"请输入",z)),e.restore()}if(yi(l)||n||t.hiddenText)return;const d=h.store;e.save(),c||(e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0);let v;t.calculative.disabled?v=t.disabledTextColor||t.disabledColor||St(.4,Gt(t,d)):t.calculative.hover?v=t.hoverTextColor||t.hoverColor||d.styles.hoverColor:t.calculative.active&&(v=t.activeTextColor||t.activeColor||d.styles.activeColor);let g;u===ie.Linear?g=oo(e,t):u===ie.Radial&&(g=ao(e,t)),e.fillStyle=v||g||Gt(t,d),e.font=_t({fontStyle:i,fontWeight:s,fontFamily:a||d.options.fontFamily,fontSize:r,lineHeight:o}),(!t.calculative.textDrawRect||t.calculative.fontsChecked)&&as(e,t);const{x:y,y:p,width:b,height:m}=t.calculative.textDrawRect;f&&(e.save(),e.fillStyle=f,e.fillRect(y,p,b,m),e.restore());const k=t.textAlign||d.options.textAlign,A=r*o;t.calculative.textLines&&t.calculative.textLines.forEach((S,I)=>{const E=t.calculative.textLineWidths[I];let z=0;k==="center"?z=(b-E)/2:k==="right"&&(z=b-E);const U=p+I*A+_s(e,S,A);t.letterSpacing?xo(e,S,y+z,U,t.calculative.letterSpacing):e.fillText(S,y+z,U);const{textDecorationColor:T,textDecorationDash:R,textDecoration:C}=t;C&&ko(e,{x:y+z,y:U,width:E},{textDecorationColor:T,textDecorationDash:R,fontSize:r});const{textStrickoutColor:_,textStrickoutDash:B,textStrickout:j}=t;j&&Ro(e,{x:y+z,y:U,width:E},{textStrickoutColor:_,textStrickoutDash:B,fontSize:r})}),e.restore()}function _s(e,t,i){const s=e.measureText(t),{actualBoundingBoxAscent:r,actualBoundingBoxDescent:a}=s;return r||a?i/2+(r-a)/2:i*.55}function xo(e,t,i,s,r=0){if(r===0){e.fillText(t,i,s);return}let a=0;for(let o=0;o<t.length;o++)e.fillText(t[o],i+a,s),a+=e.measureText(t[o]).width+r}function ko(e,t,i){const{textDecorationColor:s,textDecorationDash:r,fontSize:a}=i;let{x:o,y:l,width:n}=t;switch(e.textBaseline){case"top":l+=a;break;case"middle":l+=a/2;break}e.save(),e.beginPath(),e.strokeStyle=s||e.fillStyle,e.lineWidth=1,e.moveTo(o,l),e.setLineDash(r||[]),e.lineTo(o+n,l),e.stroke(),e.restore()}function Ro(e,t,i){const{textStrickoutColor:s,textStrickoutDash:r,fontSize:a}=i;let{x:o,y:l,width:n}=t;switch(e.textBaseline){case"top":l+=a/2;break;case"bottom":l-=a/2;break}e.save(),e.beginPath(),e.strokeStyle=s||e.fillStyle,e.lineWidth=1,e.moveTo(o,l),e.setLineDash(r||[]),e.lineTo(o+n,l),e.stroke(),e.restore()}function Ir(e,t,i){if(i==null)return;const{fontStyle:s,fontWeight:r,fontSize:a,fontFamily:o,lineHeight:l,canvas:n}=t.calculative,h=n.store;e.save();let c;t.calculative.hover?c=t.hoverTextColor||t.hoverColor||h.styles.hoverColor:t.calculative.active&&(c=t.activeTextColor||t.activeColor||h.styles.activeColor),e.fillStyle=c||Gt(t,h),e.font=_t({fontStyle:s,fontWeight:r,fontFamily:o||h.options.fontFamily,fontSize:a,lineHeight:l});const f=e.measureText(i).width;let u,d;for(const v of t.calculative.worldAnchors){if(!d){d=v;continue}const g=Mi(d,v),y=Math.floor(g/f);u="";for(let b=0;b<y;b++)u+=i;const p=jt(d,v)-270;if(e.save(),p%360!==0){const{x:b,y:m}=d;e.translate(b,m);let k=p*Math.PI/180;e.rotate(k),e.translate(-b,-m)}e.fillText(u,d.x,d.y+l/2),e.restore(),d=v}e.restore()}function _r(e,t){const i=t.calculative.canvas.store;e.save(),e.shadowColor="",e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0,e.textAlign="center",e.textBaseline="middle";const s=t.calculative.worldIconRect;let r=s.x+s.width/2,a=s.y+s.height/2;switch(t.iconAlign){case"top":a=s.y,e.textBaseline="top";break;case"bottom":a=s.ey,e.textBaseline="bottom";break;case"left":r=s.x,e.textAlign="left";break;case"right":r=s.ex,e.textAlign="right";break;case"left-top":r=s.x,a=s.y,e.textAlign="left",e.textBaseline="top";break;case"right-top":r=s.ex,a=s.y,e.textAlign="right",e.textBaseline="top";break;case"left-bottom":r=s.x,a=s.ey,e.textAlign="left",e.textBaseline="bottom";break;case"right-bottom":r=s.ex,a=s.ey,e.textAlign="right",e.textBaseline="bottom";break}const o=t.calculative.iconWeight;let l;const n=t.calculative.iconFamily;t.calculative.iconSize>0?l=t.calculative.iconSize:s.width>s.height?l=s.height:l=s.width,e.font=_t({fontSize:l,fontWeight:o,fontFamily:n});let h;t.calculative.iconType===ie.Linear?h=no(e,t):t.calculative.iconType===ie.Radial&&(h=lo(e,t)),e.fillStyle=h||t.calculative.iconColor||Gt(t,i),t.calculative.iconRotate&&(e.translate(s.center.x,s.center.y),e.rotate(t.calculative.iconRotate*Math.PI/180),e.translate(-s.center.x,-s.center.y)),e.beginPath(),e.fillText(t.calculative.icon,r,a),e.restore()}function Er(e,t){if(!t.input)return;const i=t.calculative.canvas.store.data.scale,s=t.calculative.canvas.inputDiv.dataset.penId,{x:r,y:a,width:o,height:l}=t.calculative.worldRect;e.save(),e.beginPath(),t.id===s?(e.moveTo(r+o-20*i,a+l/2+2*i),e.lineTo(r+o-14*i,a+l/2-4*i),e.lineTo(r+o-8*i,a+l/2+2*i)):(e.moveTo(r+o-20*i,a+l/2-4*i),e.lineTo(r+o-14*i,a+l/2+2*i),e.lineTo(r+o-8*i,a+l/2-4*i)),e.stroke(),e.restore()}function _t({fontStyle:e="normal",textDecoration:t="normal",fontWeight:i="normal",fontSize:s=12,fontFamily:r="Arial",lineHeight:a=1}={}){return`${e} ${t} ${i} ${s}px/${a} ${r}`}function we(e,t){const{x:i,ex:s,y:r,ey:a}=t.calculative.worldRect||{};t.calculative.flipX&&(e.translate(i+s,0),e.scale(-1,1)),t.calculative.flipY&&(e.translate(0,r+a),e.scale(1,-1))}function se(e,t,i=!1){if(t.parentId&&t.rotateByRoot){let s=Mt(t,!0);if(s){const{x:r,y:a}=s.calculative.worldRect.pivot||s.calculative.worldRect.center;e.translate(r,a);let o=s.calculative.rotate*Math.PI/180;i||(s.calculative.flipX&&(o*=-1),s.calculative.flipY&&(o*=-1)),e.rotate(o),e.translate(-r,-a)}}else{const{x:s,y:r}=t.calculative.worldRect.pivot||t.calculative.worldRect.center;e.translate(s,r);let a=t.calculative.rotate*Math.PI/180;i||(t.calculative.flipX&&(a*=-1),t.calculative.flipY&&(a*=-1)),e.rotate(a),e.translate(-s,-r)}}function de(e,t,i){var f;e.save(),e.translate(.5,.5),e.beginPath(),$o(e,t);const s=t.calculative.canvas.store,r=t.textFlip||s.options.textFlip,a=t.textRotate||s.options.textRotate;(!r||!a)&&e.save(),we(e,t),(t.rotateByRoot||t.calculative.rotate&&t.name!==Ss)&&se(e,t),(t.calculative.lineWidth>1||i)&&(e.lineWidth=t.calculative.lineWidth),jo(e,s,t);let o,l=!1,n;t.calculative.disabled?(n=t.disabledColor||s.styles.disabledColor||St(.4,t.calculative.color||s.styles.color),o=t.disabledBackground||s.styles.disabledBackground||St(.4,t.calculative.background||s.styles.penBackground)):t.mouseDownValid&&t.calculative.mouseDown?(n=t.mouseDownColor||St(-.4,t.calculative.color||s.styles.color),o=t.mouseDownBackground||St(-.4,t.calculative.background||s.styles.penBackground)):t.switch&&t.calculative.checked?t.calculative.bkType||(o=t.onBackground):t.calculative.hover?(n=t.hoverColor||s.styles.hoverColor,o=t.hoverBackground||s.styles.hoverBackground):t.calculative.active?(n=t.activeColor||s.styles.activeColor,o=t.activeBackground||s.styles.activeBackground):t.calculative.isDock&&(t.type===ut.Line?n=s.styles.dockPenColor:o=mi(s.styles.dockPenColor,.2));const h=t.calculative.strokeImg;if(t.calculative.strokeImage&&h)e.strokeStyle=n||e.createPattern(h,ki);else{let u;t.calculative.strokeType?t.calculative.lineGradientColors?t.name===Ss?l=!0:t.calculative.lineGradient?u=t.calculative.lineGradient:(u=go(e,t),t.calculative.lineGradient=u):u=wo(e,t):u=t.calculative.color||(t.type?s.data.lineColor:"")||s.styles.color,e.strokeStyle=n||u}const c=t.calculative.backgroundImg;if(t.calculative.backgroundImage&&c)e.fillStyle=o||e.createPattern(c,ki),o=!0;else{let u;const d=t.calculative.background||"";typeof d=="string"&&d.startsWith("linear-gradient")&&(t.calculative.gradientColors=d,t.calculative.bkType=ie.Linear),t.calculative.bkType===ie.Linear?t.calculative.gradientColors?t.calculative.gradient?u=t.calculative.gradient:(u=ro(e,t),t.calculative.gradient=u):u=to(e,t):t.calculative.bkType===ie.Radial?t.calculative.gradientColors?t.calculative.radialGradient?u=t.calculative.radialGradient:(u=so(e,t),t.calculative.radialGradient=u):u=eo(e,t):u=t.calculative.background||s.styles.penBackground,e.fillStyle=o||u,o=!!u}if(Mr(e,t),Lr(e,t),be(e,t),t.calculative.lineDash&&e.setLineDash(t.calculative.lineDash.map(u=>u*t.calculative.canvas.store.data.scale)),t.calculative.lineDashOffset&&(e.lineDashOffset=t.calculative.lineDashOffset),t.calculative.shadowColor&&(e.shadowColor=t.calculative.shadowColor,e.shadowOffsetX=t.calculative.shadowOffsetX,e.shadowOffsetY=t.calculative.shadowOffsetY,e.shadowBlur=t.calculative.shadowBlur),l?(Ar(e,t),Or(!0,e,t,s)):(Dr(!0,e,t,s,o),Vr(e,t)),!(t.image&&t.calculative.img)&&t.calculative.icon&&_r(e,t),t.dropdownList&&Er(e,t),(!r||!a)&&e.restore(),r&&!a&&we(e,t),!r&&a&&(t.rotateByRoot||t.calculative.rotate&&t.name!=="line")&&se(e,t,!0),Pr(e,t),t.type===ut.Line&&((f=t.fillTexts)==null?void 0:f.length)>0)for(const u of t.fillTexts)Ir(e,t,u);e.restore()}function Mr(e,t){const i=t.lineCap||(t.type?"round":"square");e.lineCap=i}function Lr(e,t){const i=t.lineJoin;i?e.lineJoin=i:t.type&&(e.lineJoin="round")}function Ri(e,t,i,s){var h,c;e.save(),i&&e.translate(-i.x,-i.y),(h=e.setAttrs)==null||h.call(e,t);let r=!1;const a=t.calculative.canvas.store,o=t.textFlip||a.options.textFlip,l=t.textRotate||a.options.textRotate;e.beginPath(),(!o||!l)&&e.save(),t.calculative.flipX&&(e.translate(t.calculative.worldRect.x+t.calculative.worldRect.ex,0),e.scale(-1,1)),t.calculative.flipY&&(e.translate(0,t.calculative.worldRect.y+t.calculative.worldRect.ey),e.scale(1,-1)),(t.rotateByRoot||t.calculative.rotate&&t.name!=="line")&&se(e,t),(t.calculative.lineWidth>1||s)&&(e.lineWidth=t.calculative.lineWidth);let n;if(t.calculative.hover)e.strokeStyle=t.hoverColor||a.styles.hoverColor,e.fillStyle=t.hoverBackground||a.styles.hoverBackground,n=t.hoverBackground||a.styles.hoverBackground;else if(t.calculative.active)e.strokeStyle=t.activeColor||a.styles.activeColor,e.fillStyle=t.activeBackground||a.styles.activeBackground,n=t.activeBackground||a.styles.activeBackground;else{if(t.strokeImage)t.calculative.strokeImg&&(e.strokeStyle=e.createPattern(t.calculative.strokeImg,ki),n=!0);else{let f;t.calculative.strokeType&&t.calculative.lineGradientColors&&t.name==="line"?r=!0:f=t.calculative.color||a.styles.color,e.strokeStyle=f}t.backgroundImage?t.calculative.backgroundImg&&(e.fillStyle=e.createPattern(t.calculative.backgroundImg,ki),n=!0):(e.fillStyle=t.background,n=!!t.background)}if(Mr(e,t),Lr(e,t),be(e,t),t.calculative.lineDash&&e.setLineDash(t.calculative.lineDash),t.calculative.lineDashOffset&&(e.lineDashOffset=t.calculative.lineDashOffset),t.calculative.shadowColor&&(e.shadowColor=t.calculative.shadowColor,e.shadowOffsetX=t.calculative.shadowOffsetX,e.shadowOffsetY=t.calculative.shadowOffsetY,e.shadowBlur=t.calculative.shadowBlur),r?(Ar(e,t),Or(!0,e,t,a)):(Dr(!1,e,t,a,n),Vr(e,t)),t.calculative.img?(e.save(),e.shadowColor="",e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0,Me(e,t),e.restore()):t.calculative.icon&&_r(e,t),t.dropdownList&&Er(e,t),(!o||!l)&&e.restore(),o&&!l&&(t.calculative.flipX&&(e.translate(t.calculative.worldRect.x+t.calculative.worldRect.ex,0),e.scale(-1,1)),t.calculative.flipY&&(e.translate(0,t.calculative.worldRect.y+t.calculative.worldRect.ey),e.scale(1,-1))),!o&&l&&(t.rotateByRoot||t.calculative.rotate&&t.name!=="line")&&se(e,t,!0),Pr(e,t),t.type===ut.Line&&((c=t.fillTexts)==null?void 0:c.length)>0)for(const f of t.fillTexts)Ir(e,t,f);e.restore()}function Dr(e=!0,t,i,s,r){if(i.name==="drawCommand")return;const a=e?s.path2dMap.get(i):it.path2dDraws[i.name];let o=null,l=null;if(i.type===ut.Line&&(i.fromLineCap&&i.fromLineCap!=="butt"&&(t.lineCap="butt",o=new Path2D,o.moveTo(i.calculative.worldAnchors[0].x,i.calculative.worldAnchors[0].y),o.lineTo(i.calculative.worldAnchors[0].x,i.calculative.worldAnchors[0].y)),i.toLineCap&&i.toLineCap!=="butt"&&(t.lineCap="butt",l=new Path2D,l.moveTo(i.calculative.worldAnchors[i.calculative.worldAnchors.length-1].x,i.calculative.worldAnchors[i.calculative.worldAnchors.length-1].y),l.lineTo(i.calculative.worldAnchors[i.calculative.worldAnchors.length-1].x,i.calculative.worldAnchors[i.calculative.worldAnchors.length-1].y))),a){if(i.type===ut.Line&&i.borderWidth){t.save(),t.beginPath();const h=i.calculative.lineWidth+i.calculative.borderWidth;t.lineWidth=h,t.strokeStyle=i.borderColor,o&&(t.save(),t.lineCap=i.fromLineCap,t.stroke(o),t.restore()),a instanceof Path2D?(r&&t.fill(a),h&&t.stroke(a)):(a(i,t),r&&t.fill(),h&&t.stroke()),l&&(t.save(),t.lineCap=i.toLineCap,t.stroke(l),t.restore()),t.restore()}a instanceof Path2D?i.type?i.close&&r&&t.fill(a):r&&t.fill(a):(t.save(),a(i,t),r&&t.fill(),t.restore());const n=(i.calculative.progress-(i.calculative.min||0))/((i.calculative.max||1)-(i.calculative.min||0));if(n!=null&&!isNaN(n)){t.save();const{ex:h,x:c,y:f,width:u,height:d,ey:v}=i.calculative.worldRect;let g=null;if(i.calculative.verticalProgress?g=i.reverseProgress?t.createLinearGradient(c,f,c,f+d*n):t.createLinearGradient(c,v,c,f+d*(1-n)):g=i.reverseProgress?t.createLinearGradient(h,f,c+u*(1-n),f):t.createLinearGradient(c,f,c+u*n,f),i.calculative.progressGradientColors){const{colors:y}=oe(i.calculative.progressGradientColors);y.forEach(p=>{g.addColorStop(p.i,p.color)})}else{const y=i.calculative.progressColor||i.calculative.color||s.options.activeColor||s.data.color;g.addColorStop(0,y),g.addColorStop(1,y)}g.addColorStop(1,"transparent"),t.fillStyle=g,a instanceof Path2D?t.fill(a):(a(i,t),t.fill()),t.restore()}if(i.calculative.lineWidth&&(a instanceof Path2D?(s.options.svgPathStroke||i.name!=="svgPath")&&(o&&(t.save(),t.lineCap=i.fromLineCap,t.stroke(o),t.restore()),t.stroke(a),l&&(t.save(),t.lineCap=i.toLineCap,t.stroke(l),t.restore())):(a(i,t),t.stroke())),i.type){if(i.calculative.animatePos){if(t.save(),Br(t,i,s),i.lineAnimateType===pt.Arrow||i.lineAnimateType===pt.WaterDrop){let h=Kr(i,t);h instanceof Path2D?(t.stroke(h),t.fill(h)):(t.stroke(),t.fill())}else a instanceof Path2D?(o&&!i.lineAnimateType&&(t.save(),t.lineCap=i.fromLineCap,t.stroke(o),t.restore()),t.lineCap=i.lineCap,t.stroke(a)):(a(i,t),t.stroke());t.restore()}i.fromArrow&&xr(t,i,s),i.toArrow&&kr(t,i,s),Yr(t,i,s),i.calculative.active&&!i.calculative.pencil&&!s.options.disableAnchor&&!s.data.locked&&Nr(t,i)}}}function Or(e=!0,t,i,s){const r=e?s.path2dMap.get(i):it.path2dDraws[i.name];if(r&&i.type){if(i.calculative.animatePos){if(t.save(),Br(t,i,s),t.beginPath(),r instanceof Path2D)if(i.lineAnimateType===pt.Arrow||i.lineAnimateType===pt.WaterDrop){const a=Kr(i);t.stroke(a),t.fill(a)}else i.calculative.gradientSmooth||i.calculative.lineSmooth?(i.calculative.gradientAnimatePath||(i.calculative.gradientAnimatePath=hs(i)),i.calculative.gradientAnimatePath instanceof Path2D&&t.stroke(i.calculative.gradientAnimatePath)):t.stroke(r);else r(i,t),t.stroke();t.restore()}i.fromArrow&&xr(t,i,s),i.toArrow&&kr(t,i,s),Yr(t,i,s),i.calculative.active&&!i.calculative.pencil&&!s.options.disableAnchor&&!s.data.locked&&Nr(t,i)}}function Br(e,t,i){e.strokeStyle=t.lineAnimateType===pt.Custom?t.animateColor||Ba:t.animateColor||i.styles.animateColor,t.animateShadow&&(e.shadowBlur=t.animateShadowBlur||t.animateLineWidth||6,e.shadowColor=t.animateShadowColor||t.animateColor||i.styles.animateColor),t.calculative.animateLineWidth&&(e.lineWidth=t.calculative.animateLineWidth*i.data.scale),Array.isArray(t.lineAnimateType)?t.lineAnimateType.forEach(s=>{Es(t,i,s,e)}):Es(t,i,t.lineAnimateType,e)}function Es(e,t,i,s){let r=0;switch(i){case pt.Beads:e.animateReverse?s.lineDashOffset=e.calculative.animatePos:s.lineDashOffset=e.length-e.calculative.animatePos,r=e.calculative.lineWidth||5,r<5&&(r=5);const a=e.animateLineDash&&e.animateLineDash.map(o=>o*r/5);s.setLineDash(a||[r,r*2]);break;case pt.Dot:e.animateReverse?s.lineDashOffset=e.calculative.animatePos:s.lineDashOffset=e.length-e.calculative.animatePos,r=e.calculative.animateDotSize||e.calculative.lineWidth*2||6,r<6&&(r=6),r>40&&(r=40),s.lineWidth=(e.calculative.animateLineWidth||r)*t.data.scale,s.setLineDash([.1,e.length]);break;case pt.Arrow:s.fillStyle=e.animateColor||t.styles.animateColor,s.lineWidth=1;break;case pt.WaterDrop:s.fillStyle=e.animateColor||t.styles.animateColor,s.lineWidth=1;break;case pt.Custom:switch(e.lineAnimateTargetType){case Se.Image:if(e.lineAnimateImages??(e.lineAnimateImages=[]),e.lineAnimateImages.length>0){const n=e.lineAnimateImages.map((h,c)=>{const f=it.htmlElements[h];if(!f)e.calculative.canvas.__loadImage(h);else return f});ri(s,e,"image",n)}break;case Se.Icon:const o=e.lineAnimateIcon;ri(s,e,"icon",o);break;case Se.Pen:e.lineAnimatePens&&ri(s,e,"pen",e.lineAnimatePens);break;case Se.Element:const l=e.lineAnimateElement;ri(s,e,"element",l)}break;default:e.animateReverse?(s.lineDashOffset=Number.EPSILON,s.setLineDash([0,e.length-e.calculative.animatePos+1,e.calculative.animatePos])):s.setLineDash([e.calculative.animatePos,e.length+.01-e.calculative.animatePos]);break}}function ri(e,t,i,s){let r=null;switch(i){case"image":r=To(s);break;case"icon":r=Ao(s);break;case"pen":let a=t.calculative.canvas.find(s);t.lineAnimateElementCount=a.length,r=Co(a);break;case"element":if(r=it.lineAnimateDraws[s],!r)return;break}So(e,t,r)}function To(e){return function(t,i,s,r){const a=i.calculative.canvas.store.data.scale,o=i.lineAnimateElementWidth||10,l=i.lineAnimateElementHeight||10,n=e[r%e.length];n&&(t.save(),t.translate(s.x,s.y),t.rotate(s.rotate*Math.PI/180),t.scale(a,a),t.drawImage(n,-o/2,-l/2,o,l),t.restore())}}function Co(e){return function(t,i,s,r){const a=e[r%e.length];if(!a)return;const o=i.calculative.canvas.store.data.scale,l=i.calculative.canvas.store.data.origin,n=i.calculative.canvas.parent,h=a.width,c=a.height,f=s.x-h/2,u=s.y-c/2,d=(f-l.x)/o,v=(u-l.y)/o,g=h/o,y=c/o,p={x:d,y:v,width:g,height:y,rotate:s.rotate};n.setValue({id:a.id,...p},{render:!1,doEvent:!1,history:!1})}}function Ao(e){return function(t,i,s,r){const a=i.calculative.canvas.store.data.scale;t.beginPath(),t.translate(s.x,s.y),t.rotate(s.rotate*Math.PI/180),t.scale(a,a);const o=i.calculative.iconWeight;let l;const n=i.calculative.iconFamily;l=i.calculative.iconSize||Math.max(i.lineAnimateElementWidth||0,i.lineAnimateElementHeight||0)||10,t.font=_t({fontSize:l,fontWeight:o,fontFamily:n}),t.fillStyle=i.calculative.iconColor||Gt(i,i.calculative.canvas.parent.store),i.calculative.iconRotate&&t.rotate(i.calculative.iconRotate*Math.PI/180),t.beginPath(),t.fillText(e,0,0)}}function So(e,t,i){var a;const s=t.calculative.canvas.store.data.scale,r=Si(t)/s;if(t.lineAnimateLoopMode)Po(e,t,i,r,s);else{const o=Array.isArray(t.lineAnimateDash)?t.lineAnimateDash:((a=t.lineAnimateDash)==null?void 0:a.split(",").map(n=>Number(n)))||[10,20];Io(r,o,t.lineAnimateDashOffset,t.lineAnimateElementCount).forEach((n,h)=>{const c=Ki(t,n.start);if(c)try{e.save(),i(e,t,c,h),e.restore()}catch(f){e.restore(),console.warn(f)}})}}function Po(e,t,i,s,r){var h;const o=((Array.isArray(t.lineAnimateDash)?t.lineAnimateDash:((h=t.lineAnimateDash)==null?void 0:h.split(",").map(c=>Number(c)))||[10,20])[0]||30)*r,l=t.calculative.animatePos,n=t.calculative.worldAnchors;if(n.length>1){let c,f=0;for(let u=0;u<n.length;u++){let d=n[u];if(c){const v=t.length;let y=(l-f)%o-o,p=0;for(;y<v;){if(y>=0){const b=f+y,m=(l-b)/r;try{e.save();const k=Ki(t,m);k&&i(e,t,k,p),e.restore()}catch(k){e.restore(),console.warn(k)}}y+=o,p++}f+=v}c=d}if(t.close){let u=n[0];if(c){const d=Math.sqrt((u.x-c.x)**2+(u.y-c.y)**2);let g=(l-f)%o-o,y=0;for(;g<d;){if(g>=0){const p=f+g,b=(l-p)/r;try{e.save();const m=Ki(t,b);m&&i(e,t,m,y),e.restore()}catch(m){e.restore(),console.warn(m)}}g+=o,y++}}}}}function Io(e,t,i=0,s,r=0){const a=[];if(!t||t.length===0)return a.push({start:0,end:e,isDash:!0}),a;const o=t.reduce((c,f)=>c+f,0);let l=(-i+r)%o;l<0&&(l+=o);let n=0,h=0;for(s||(s=1/0);h<e&&n<s;)for(let c=0;c<t.length;c++){const f=t[c],u=c%2===0;let d=h,v=h+f-l;if(v>e&&(v=e),u&&v>d){const g=(d+r)%e,y=(v+r)%e;a.push({start:g,end:y,isDash:!0}),n+=1}if(h=v,l=0,h>=e||n>=s)break}return a}function Ki(e,t=0){const i=e.calculative.worldAnchors;if(!i||i.length<2)return null;const s={x:i[0].x,y:i[0].y},r=h=>h&&{...h,x:h.x-s.x,y:h.y-s.y};let a,o=null;if(i.forEach(h=>{if(o){const c=r(o);c.next=r(o.next);const f=r(h);f.prev=r(h.prev),a=$s(a,c,c.next,f.prev,f)}o=h}),e.close){const h=i[0],c=r(o);c.next=r(o.next);const f=r(h);f.prev=r(h.prev),a=$s(a,c,c.next,f.prev,f)}let l=0;e.animateReverse?l=e.length-e.calculative.animatePos-t*e.calculative.canvas.store.data.scale:l=e.calculative.animatePos-t*e.calculative.canvas.store.data.scale;const n=ln(a,l);return n?(n.x+=s.x,n.y+=s.y,n):null}function Nr(e,t){const i=t.calculative.canvas.store;e.save(),e.lineWidth=1,e.fillStyle=t.activeColor||i.styles.activeColor,t.calculative.worldAnchors.forEach(s=>{!s.hidden&&!s.isTemp&&_o(e,s,t)}),e.restore()}function _o(e,t,i){if(!t)return;const s=i.calculative.canvas.store.activeAnchor===i.calculative.activeAnchor&&i.calculative.activeAnchor===t;let r=3;i.calculative.lineWidth>3&&(r=i.calculative.lineWidth),i.anchorRadius&&(r=i.anchorRadius),t.radius&&(r=t.radius),s?(t.prev&&(e.save(),e.strokeStyle="#4dffff",e.beginPath(),e.moveTo(t.prev.x,t.prev.y),e.lineTo(t.x,t.y),e.stroke(),e.restore(),e.save(),e.fillStyle="#ffffff",e.beginPath(),e.arc(t.prev.x,t.prev.y,r,0,Math.PI*2),e.fill(),e.stroke(),e.restore()),t.next&&(e.save(),e.strokeStyle="#4dffff",e.beginPath(),e.moveTo(t.x,t.y),e.lineTo(t.next.x,t.next.y),e.stroke(),e.restore(),e.save(),e.fillStyle="#ffffff",e.beginPath(),e.arc(t.next.x,t.next.y,r,0,Math.PI*2),e.fill(),e.stroke(),e.restore(),e.beginPath(),e.arc(t.x,t.y,r,0,Math.PI*2),e.fill(),e.stroke()),e.beginPath(),e.arc(t.x,t.y,r,0,Math.PI*2),e.fill(),e.stroke()):(e.save(),e.fillStyle="#ffffff",e.beginPath(),e.arc(t.x,t.y,r,0,Math.PI*2),e.fill(),e.stroke(),e.restore())}function Fr(e){const t=e.calculative.canvas.store;let i={x:e.x,y:e.y};if(!e.parentId||e.parentId&&!t.pens[e.parentId])e.parentId=void 0,i.width=e.width,i.height=e.height,i.rotate=e.rotate,bt(i),yt(i),e.pivot&&Qi(i,e.pivot);else{const s=t.pens[e.parentId];let r=s.calculative.worldRect;r||(r=Fr(s)),i.x=r.x+r.width*e.x,i.y=r.y+r.height*e.y,i.width=r.width*e.width,i.height=r.height*e.height,s.flipX&&(i.x=r.width-(i.x-r.x+i.width)+r.x),s.flipY&&(i.y=r.height-(i.y-r.y+i.height)+r.y),bt(i),i.rotate=r.rotate+e.rotate,yt(i),e.pivot&&Qi(i,e.pivot)}return e.calculative.worldRect=i,us(e,i),i}function us(e,t){!e.paddingTop&&(e.calculative.paddingTop=0),!e.paddingBottom&&(e.calculative.paddingBottom=0),!e.paddingLeft&&(e.calculative.paddingLeft=0),!e.paddingRight&&(e.calculative.paddingRight=0),Math.abs(e.calculative.paddingTop)<1&&(e.calculative.paddingTop*=t.height),Math.abs(e.calculative.paddingBottom)<1&&(e.calculative.paddingBottom*=t.height),Math.abs(e.calculative.paddingLeft)<1&&(e.calculative.paddingLeft*=t.width),Math.abs(e.calculative.paddingRight)<1&&(e.calculative.paddingRight*=t.width)}function fi(e){const t=K(e.calculative.worldRect);if(delete t.pivot,!e.parentId){Object.assign(e,t);return}const s=e.calculative.canvas.store.pens[e.parentId].calculative.worldRect;Object.assign(e,ce(t,s))}function Le(e){const t=e.calculative.canvas.store;let i=[];if(e.anchors){let s=K(e.anchors);e.flipX&&e.name!=="line"&&s.forEach(r=>{r.x=.5-(r.x-.5)}),e.flipY&&e.name!=="line"&&s.forEach(r=>{r.y=.5-(r.y-.5)}),s.forEach(r=>{i.push(Eo(e,r))})}if(!i.length&&!e.type&&!e.calculative.canvas.parent.isCombine(e)){const{x:s,y:r,width:a,height:o}=e.calculative.worldRect;for(let l=0;l<t.options.defaultAnchors.length;l++){const n=t.options.defaultAnchors[l];i.push({id:`${l}`,penId:e.id,x:s+a*n.x,y:r+o*n.y})}}e.calculative.rotate&&e.name!=="line"&&i.forEach(s=>{vt(s,e.calculative.rotate,e.calculative.worldRect.pivot||e.calculative.worldRect.center)}),(!e.type||e.anchors)&&(e.calculative.worldAnchors=i),e.calculative.activeAnchor&&i.length&&(e.calculative.activeAnchor=i.find(s=>{s.id,e.calculative.activeAnchor.id})),e.calculative.gradientAnimatePath=void 0}function zr(e){var t;if((t=e.children)!=null&&t.length){let i=e.calculative.worldRect;e.children.forEach(s=>{const r=e.calculative.canvas.store.pens[s];r.calculative.initRect&&r.calculative.initRelativeRect&&(r.calculative.initRect.x=i.x+i.width*r.calculative.initRelativeRect.x,r.calculative.initRect.y=i.y+i.height*r.calculative.initRelativeRect.y,r.calculative.initRect.ex=r.calculative.initRect.x+i.width*r.calculative.initRelativeRect.width,r.calculative.initRect.ey=r.calculative.initRect.y+i.height+r.calculative.initRelativeRect.height,yt(r.calculative.initRect)),zr(r)})}}function Eo(e,t){const i={...t},{x:s,y:r,width:a,height:o}=e.calculative.worldRect;return i.x=s+a*t.x,i.y=r+o*t.y,t.prev&&(i.prev={penId:e.id,connectTo:t.prev.connectTo,x:s+a*t.prev.x,y:r+o*t.prev.y}),t.next&&(i.next={penId:e.id,connectTo:t.next.connectTo,x:s+a*t.next.x,y:r+o*t.next.y}),i}function Ms(e,t){if(!t.image&&!t.icon&&!t.thumbImg)return;const{paddingTop:i,paddingBottom:s,paddingLeft:r,paddingRight:a}=t.calculative;let o=r,l=i,n=t.calculative.worldRect.width-r-a,h=t.calculative.worldRect.height-i-s,c=t.calculative.iconLeft||0,f=t.calculative.iconTop||0;c&&Math.abs(c)<1&&(c=t.calculative.worldRect.width*c),f&&Math.abs(f)<1&&(f=t.calculative.worldRect.height*f),o+=c||0,l+=f||0,n-=c||0,h-=f||0;let u=t.calculative.iconRotate||0;if(t.parentId){const d=e[t.parentId].calculative;d&&(u+=d.rotate,u%=360)}o=t.calculative.worldRect.x+o,l=t.calculative.worldRect.y+l,t.calculative.worldIconRect={x:o,y:l,width:n,height:h,rotate:u},bt(t.calculative.worldIconRect),yt(t.calculative.worldIconRect)}function zt(e,t,i){De(e.calculative.worldRect,t,i,e.pivot),e.calculative.initRect&&De(e.calculative.initRect,t,i,e.pivot),e.calculative.prevFrameRect&&De(e.calculative.prevFrameRect,t,i,e.pivot),jr(e,t,i),e.calculative.x&&Pe(e.calculative,t,i),e.type&&Le(e)}function jr(e,t,i){var s;e&&(s=e.children)!=null&&s.length&&e.children.forEach(r=>{const a=e.calculative.canvas.store.pens[r];a&&(a.calculative.initRect&&De(a.calculative.initRect,t,i),jr(a,t,i))})}function Mo(e,t){e.anchors||(e.anchors=[]),e.calculative.worldAnchors||(e.calculative.worldAnchors=[]);const i={id:t.id,penId:e.id,x:t.x,y:t.y};if(e.calculative.worldAnchors.push(i),e.calculative.worldRect){e.rotate%360&&vt(t,-e.rotate,e.calculative.worldRect.center);const s={id:t.id,penId:e.id,x:(t.x-e.calculative.worldRect.x)/e.calculative.worldRect.width,y:(t.y-e.calculative.worldRect.y)/e.calculative.worldRect.height};e.anchors.push(s)}return i}function Lo(e,t,i){e.anchors||(e.anchors=[]),e.calculative.worldAnchors||(e.calculative.worldAnchors=[]);const s=tn(e,t,i);return e.calculative.worldAnchors.splice(i+1,0,s),e.anchors.splice(i+1,0,Xe(s,e.calculative.worldRect)),e.calculative.activeAnchor=s,s}function Do(e,t){if(!e||!e.calculative.worldAnchors)return;let i=e.calculative.worldAnchors.findIndex(s=>s.id===t.id);i>-1&&e.calculative.worldAnchors.splice(i,1),i=e.anchors.findIndex(s=>s.id===t.id),i>-1&&e.anchors.splice(i,1)}function Oe(e,t){if(!t||!t.calculative||!t.calculative.worldRect.center)return nt.None;if(e.anchorId){let i=t.anchors.filter(s=>s.id===e.anchorId);if(i.length&&i[0].direction>-1)return i[0].direction}return Ia(e,t.calculative.worldRect.center)}function _e(e,t){let i=1/0,s;return e.calculative.worldAnchors.forEach(r=>{const a=Mi(t,r);i>a&&(i=a,s=r)}),s}function Ls(e,t,i){e.x+=t,e.y+=i,e.anchors&&e.anchors.forEach(s=>{Ye(s,t,i)}),e.calculative.worldAnchors&&e.calculative.worldAnchors.forEach(s=>{Ye(s,t,i)})}function ds(e){if(e&&e.calculative&&e.calculative.worldAnchors.length){let t=dt(e);if(!e.anchors||!e.anchors.length)for(;e.calculative.worldAnchors.length&&t!==e.calculative.activeAnchor;)e.calculative.worldAnchors.pop(),t=dt(e);else t===e.calculative.activeAnchor?e.calculative.worldAnchors=[e.calculative.worldAnchors[0]]:e.calculative.worldAnchors[0]===e.calculative.activeAnchor&&(e.calculative.worldAnchors=[e.calculative.worldAnchors[e.calculative.worldAnchors.length-1]])}}function Tt(e,t,i,s){var l,n,h,c,f,u;if(!e||!t||!i||!s||t.twoWay===At.DisableConnected||t.twoWay===At.Disable||s.twoWay===At.DisableConnectTo||s.twoWay===At.Disable)return;if(t.twoWay===At.In){if(i.calculative.worldAnchors.length===1)return;const d=dt(i);if(s.id!==d.id)return}if(t.twoWay===At.Out){const d=xt(i);if(s.id!==d.id)return}if(s.connectTo===e.id&&s.anchorId===t.id)return;if(s.connectTo){const d=e.calculative.canvas.store.pens[s.connectTo];Ee(d,fe(d,s.anchorId),i,s)}e.connectedLines||(e.connectedLines=[]),e.connectedLines.findIndex(d=>d.lineId===i.id&&d.lineAnchor===s.id&&d.anchor===t.id)<0&&e.connectedLines.push({lineId:i.id,lineAnchor:s.id,anchor:t.id}),s.connectTo=e.id,s.anchorId=t.id,e.type&&Tt(i,s,e,t),e.calculative.canvas.store.emitter.emit("connectLine",{line:i,lineAnchor:s,pen:e,anchor:t});let a=((l=i.calculative.worldAnchors)==null?void 0:l.length)>=2?(n=i.calculative.worldAnchors)==null?void 0:n[0].connectTo:void 0,o=((h=i.calculative.worldAnchors)==null?void 0:h.length)>=2?(f=i.calculative.canvas.store.pens[(c=i.calculative.worldAnchors)==null?void 0:c[0].connectTo])==null?void 0:f.anchors.find(d=>{var v;return d.id===((v=i.calculative.worldAnchors)==null?void 0:v[0].anchorId)}):void 0;return(u=e.onConnectLine)==null||u.call(e,e,{line:i,lineAnchor:s,pen:e,anchor:t,fromPen:a,fromAnchor:o}),!0}function Ee(e,t,i,s){if(!(!e||!t||!i||!s)&&!(!e.connectedLines||!e.connectedLines.length))return i.lastConnected||(i.lastConnected={}),i.lastConnected[e.id]||(i.lastConnected[e.id]=K(e.connectedLines)),e.connectedLines.forEach((r,a,o)=>{(r.lineId===i.id||r.lineId===i.id)&&r.lineAnchor===s.id&&r.anchor===t.id&&o.splice(a,1)}),s.connectTo=void 0,s.anchorId=void 0,e.type&&t.connectTo===i.id&&t.anchorId===s.id&&Ee(i,s,e,t),e.calculative.canvas.store.emitter.emit("disconnectLine",{line:i,lineAnchor:s,pen:e,anchor:t}),!0}function fe(e,t){var i;if(!(!e||!t))return(i=e.calculative.worldAnchors)==null?void 0:i.find(s=>s.id===t)}function xt(e){if(!(!e||!e.calculative.worldAnchors))return e.calculative.worldAnchors[0]}function dt(e){if(!(!e||!e.calculative.worldAnchors))return e.calculative.worldAnchors[e.calculative.worldAnchors.length-1]}function Oo(e,t){var r,a;if(e.calculative.start===0||!e.frames||!e.frames.length)return e.calculative.start=void 0,0;if(!e.calculative.duration){e.calculative.duration=0;for(const o of e.frames){e.calculative.duration+=o.duration;for(const l in o)l!=="duration"&&!e[l]&&l==="scale"&&(e[l]=1)}}if(e.animateCycle||(e.animateCycle=1/0),e.calculative.start){let o=0;const l=Math.ceil((t-e.calculative.start)/e.calculative.duration);if(l>e.animateCycle)return e.currentAnimation=void 0,e.calculative.start=void 0,Os(e,1),0;const n=(t-e.calculative.start)%e.calculative.duration||e.calculative.duration;let h=0;for(const u of e.frames)if(h+=u.duration,n>h)e.frames[o].switch||(e.calculative.prevFrameRect=K(e.calculative.worldRect),e.frames[o].switch=!0),++o;else break;if(!e.frames[o])return!0;let c=!1;o!==e.calculative.frameIndex&&(c=!0,e.calculative.frameIndex=o,e.calculative.frameDuration=e.frames[o].duration,o>0&&(e.calculative.frameStart+=e.frames[o-1].duration),e.calculative.frameEnd=e.calculative.frameStart+e.calculative.frameDuration);let f=!1;if(l>e.calculative.cycleIndex&&(e.frames.forEach(u=>{u.switch=!1}),e.calculative.worldRect=K(e.calculative.initRect),e.calculative.prevFrameRect=K(e.calculative.initRect),e.calculative.cycleIndex=l,e.calculative.frameStart=e.calculative.start+e.calculative.duration*(l-1),f=!0),c||f)if(e.calculative.x=e.calculative.initRect.x,e.calculative.y=e.calculative.initRect.y,(a=e.children)!=null&&a.length&&!e.parentId?e.calculative.canvas.rotatePen(e,(e.calculative.initRect.rotate||0)-(e.calculative.rotate||0),e.calculative.initRect):e.calculative.rotate=e.calculative.initRect.rotate||0,o>0){e.prevFrame={};const u=e.frames[o-1];for(const d in u)e.prevFrame[d]=u[d];Object.assign(e.prevFrame,{rotate:u.rotate||0,x:u.x||0,y:u.y||0,scale:u.scale||1})}else Ds(e)}else{if(e.calculative.start=t,e.calculative.frameIndex=0,e.calculative.frameStart=e.calculative.start,e.calculative.frameDuration=e.frames[0].duration,e.calculative.frameEnd=e.calculative.frameStart+e.calculative.frameDuration,e.calculative.cycleIndex=1,e.calculative.x=e.calculative.worldRect.x,e.calculative.y=e.calculative.worldRect.y,e.calculative.initRect=K(e.calculative.worldRect),e.calculative.prevFrameRect=K(e.calculative.worldRect),e.parentId&&(e.calculative.initRelativeRect={x:e.x,y:e.y,width:e.width,height:e.height}),(r=e.children)!=null&&r.length){const o=e.calculative.canvas.store;e.calculative.childrenVisible={},e.children.forEach(l=>{e.calculative.childrenVisible[l]=o.pens[l].visible})}e.calculative.initRect.rotate=e.calculative.rotate||0,Ds(e)}const i=e.frames[e.calculative.frameIndex];let s=0;if(i.curveAnimate){const o=(t-e.calculative.frameStart)/e.calculative.frameDuration%1;let l=[];i.animateTimingFunction?l=Array.isArray(i.animateTimingFunction)?i.animateTimingFunction:i.animateTimingFunction.split(","):l=[.25,.25,.75,.75],s=Rr(o,l[1],l[3])}else s=(t-e.calculative.frameStart)/e.calculative.frameDuration%1;return s>0&&Os(e,s),!0}function Ds(e){e.prevFrame={};for(const t in e)(typeof e[t]!="object"||t==="lineDash")&&(e.prevFrame[t]=e[t]);e.prevFrame.rotate=0,e.prevFrame.x=0,e.prevFrame.y=0,e.prevFrame.scale=1}function Os(e,t){var r,a,o,l,n,h;if(t<0)return;t>1&&(t=1);const i=e.frames[e.calculative.frameIndex],s=e.calculative.canvas.store.data.scale;for(const c in i)if(c!=="duration"){if(c==="scale"){e.calculative.worldRect=K(e.calculative.prevFrameRect),De(e.calculative.worldRect,e.prevFrame.scale,e.calculative.worldRect.center);const f=e.prevFrame.scale+(i[c]-e.prevFrame.scale)*t;De(e.calculative.worldRect,f/e.prevFrame.scale,e.calculative.worldRect.center),e.calculative.patchFlags=!0}else if(c==="x"){const f=ze(e,c,e.calculative.frameIndex)*s;e.calculative.worldRect.x=e.calculative.initRect.x+f,e.calculative.worldRect.ex=e.calculative.initRect.ex+f,e.calculative.worldRect.center.x=e.calculative.initRect.center.x+f,(r=e.calculative.worldRect.pivot)!=null&&r.x&&(e.calculative.worldRect.pivot.x=((a=e.calculative.initRect.pivot)==null?void 0:a.x)+f),ye(e.calculative.worldRect,i[c]*t*s,0),e.calculative.patchFlags=!0}else if(c==="y"){const f=ze(e,c,e.calculative.frameIndex)*s;e.calculative.worldRect.y=e.calculative.initRect.y+f,e.calculative.worldRect.ey=e.calculative.initRect.ey+f,e.calculative.worldRect.center.y=e.calculative.initRect.center.y+f,(o=e.calculative.worldRect.pivot)!=null&&o.x&&(e.calculative.worldRect.pivot.y=((l=e.calculative.initRect.pivot)==null?void 0:l.y)+f),ye(e.calculative.worldRect,0,i[c]*t*s),e.calculative.patchFlags=!0}else if(c==="width"){const f=ze(e,c,e.calculative.frameIndex)*s;e.calculative.worldRect.width=e.calculative.initRect.width+f,e.calculative.worldRect.ex=e.calculative.initRect.ex+f,e.calculative.worldRect.center.x=e.calculative.initRect.center.x+f;let u=i[c]*t*s;e.calculative.worldRect.width+=u,e.calculative.worldRect.ex+=u,e.calculative.worldRect.center.x+=u,e.calculative.patchFlags=!0}else if(c==="height"){const f=ze(e,c,e.calculative.frameIndex)*s;e.calculative.worldRect.height=e.calculative.initRect.height+f,e.calculative.worldRect.ey=e.calculative.initRect.ey+f,e.calculative.worldRect.center.y=e.calculative.initRect.center.y+f;let u=i[c]*t*s;e.calculative.worldRect.height+=u,e.calculative.worldRect.ey+=u,e.calculative.worldRect.center.y+=u,e.calculative.patchFlags=!0}else if(c==="rotate"){e.prevFrame[c]>=360&&(e.prevFrame[c]%=360);const f=ze(e,c,e.calculative.frameIndex),u=(e.calculative.initRect.rotate+f+i[c]*t)%360-(e.calculative.rotate||0);(n=e.children)!=null&&n.length?e.calculative.canvas.rotatePen(e,u,e.calculative.initRect):e.calculative.rotate=(e.calculative.initRect.rotate+f+i[c]*t)%360,e.calculative.patchFlags=!0}else if(c==="image")e.image=i.image,e.calculative.image=void 0,e.calculative.canvas.loadImage(e),e.canvasLayer===ht.CanvasImageBottom?e.calculative.canvas.canvasImageBottom.init():e.canvasLayer===ht.CanvasImage&&e.calculative.canvas.canvasImage.init();else if(Bo(i[c],c,e)){e.prevFrame[c]==null&&(c==="globalAlpha"?e.prevFrame[c]=1:e.prevFrame[c]=0);const f=e.prevFrame[c]+(i[c]-e.prevFrame[c])*t;e.calculative[c]=Math.round(f*100)/100}else{if(c==="visible"&&!e.calculative.image){if((h=e.children)!=null&&h.length){const u=Pt(e,e.calculative.canvas.store);e.calculative.canvas.initImageCanvas(u)}}e.calculative[c]=i[c];const f={};f[c]=i[c],fs(e,f)}c==="text"&&Ne(e)}}function Bo(e,t,i){const s=["strokeType","bkType","showChild"];return typeof e=="number"&&i.linear!==!1&&!s.includes(t)}function No(e,t){if(e.calculative.start===0)return e.calculative.start=void 0,e.calculative.cycleStart=void 0,0;e.animateCycle||(e.animateCycle=1/0),e.animateSpan||(e.animateSpan=1);const i=(t-e.calculative.cycleStart)/1e3;if(e.curveAnimate){let s=[];e.animateTimingFunction?s=Array.isArray(e.animateTimingFunction)?e.animateTimingFunction:e.animateTimingFunction.split(","):s=[.25,.25,.75,.75];const r=e.duration||5,a=i/r,o=Rr(a,s[1],s[3]);e.calculative.animatePos=o*e.length}else e.calculative.animatePos+=e.animateSpan*(e.calculative.canvas.store.data.scale||1);if(e.calculative.cycleStart||(e.calculative.cycleStart=t),!e.calculative.start)e.calculative.start=Date.now(),e.calculative.animatePos=e.animateSpan*(e.calculative.canvas.store.data.scale||1),e.calculative.cycleIndex=1;else if(e.calculative.animatePos>e.length||e.curveAnimate&&i>e.duration){if(++e.calculative.cycleIndex,e.calculative.cycleIndex>e.animateCycle)return e.currentAnimation=void 0,e.calculative.start=void 0,e.calculative.cycleStart=void 0,0;e.calculative.cycleStart=void 0,e.calculative.animatePos=e.animateSpan}return!0}function Ae(e,t=!0){if(!e.children||e.childActive===!1)return;const i=e.calculative.canvas.store;e.children.forEach(s=>{const r=i.pens[s];r&&(r.calculative.active=t,Ae(r,t))})}function qe(e,t=!0){if(!e)return;const i=e.calculative.canvas.store;e.calculative.hover=t,e.childHover!==!1&&e.children&&e.children.forEach(s=>{var r,a;((r=i.pens[s])==null?void 0:r.hoverColor)==null&&((a=i.pens[s])==null?void 0:a.hoverBackground)==null&&qe(i.pens[s],t)})}function Ct(e,t){if(!t)return;const i=e.calculative.canvas.store,s=e.calculative.worldRect;if(t.style.opacity=e.globalAlpha+"",t.style.position="absolute",t.style.outline="none",t.style.left=s.x+i.data.x+"px",t.style.top=s.y+i.data.y+"px",t.style.width=s.width+"px",t.style.height=s.height+"px",e.name==="iframe"?t.style.opacity=e.calculative.inView?"1":"0":t.style.display=e.calculative.inView!=!1?e.calculative.cssDisplay||"inline":"none",!e.calculative.rotate&&(e.calculative.rotate=0),t.style.transform=`rotate(${e.calculative.rotate}deg)`,e.calculative.rotate||(e.calculative.flipX&&(t.style.transform="rotateY(180deg)"),e.calculative.flipY&&(t.style.transform="rotateX(180deg)"),e.calculative.flipX&&e.calculative.flipY&&(t.style.transform="rotateZ(180deg)")),t.style.zIndex=e.calculative.zIndex!==void 0?e.calculative.zIndex+"":"5",e.calculative.zIndex>e.calculative.canvas.maxZindex&&(e.calculative.canvas.maxZindex=e.calculative.zIndex),e.locked===ct.DisableEdit||e.locked===ct.DisableMove||i.data.locked?(t.style.userSelect="initial",t.style.pointerEvents="initial",e.name==="gif"&&(t.style.userSelect="none",t.style.pointerEvents="none")):(t.style.userSelect="none",t.style.pointerEvents="none"),e.className&&(t.className=e.className),e.styles)for(let r in e.styles)t.style[r]=e.styles[r]}async function Fo(e,t){if(t&&globalThis.html2canvas){const i=await globalThis.html2canvas(t);if(i){const s=new Image;s.src=i.toDataURL("image/png",.1),s.src.length>10&&(e.calculative.img=s)}}}function zi(e){return e.every(t=>t.locked)}function Bs(e){return e.every(t=>t.disableRotate)}function Wr(e,t,i){var s;e.rotateByRoot||(e.name==="line"?(e.calculative.worldAnchors.forEach(r=>{vt(r,t,i.center)}),zo(e),fi(e)):(e.calculative.rotate?e.calculative.rotate+=t:e.calculative.rotate=t,vt(e.calculative.worldRect.center,t,i.center),e.parentId&&(e.calculative.worldRect.x=e.calculative.worldRect.center.x-e.calculative.worldRect.width/2,e.calculative.worldRect.y=e.calculative.worldRect.center.y-e.calculative.worldRect.height/2,e.x=(e.calculative.worldRect.x-i.x)/i.width,e.y=(e.calculative.worldRect.y-i.y)/i.height)),(s=e.children)==null||s.forEach(r=>{const a=e.calculative.canvas.store.pens[r];Wr(a,t,i)}))}function zo(e){var r;if(!((r=e.calculative.worldAnchors)!=null&&r.length)||!isFinite(e.x)||!isFinite(e.x)||e.x==null||e.y==null)return;const t=Ji(e);e.parentId||Object.assign(e,t);const{fontSize:i,lineHeight:s}=e.calculative.canvas.store.options;e.fontSize?e.fontSize<0&&(e.fontSize=0,e.calculative.fontSize=0):(e.fontSize=i>=0?i:12,e.calculative.fontSize=e.fontSize*e.calculative.canvas.store.data.scale),e.lineHeight||(e.lineHeight=s,e.calculative.lineHeight=e.lineHeight),yt(t),e.calculative.worldRect=t,us(e,t),Yt(e),e.calculative.worldAnchors&&(e.anchors=e.calculative.worldAnchors.map(a=>Xe(a,e.calculative.worldRect)))}function Ns(e){return e.every(t=>t.disableSize||t.pivot)}function ze(e,t,i){if(!e.frames||!t)return 0;let s=0;for(let r=0;r<i;r++)e.frames[r]&&(s+=e.frames[r][t]||0);return s}function Ti(e,t){var s;let i=e;for(;i&&i.parentId;){const r=i;i=t.pens[i.parentId];const a=(s=i==null?void 0:i.calculative)==null?void 0:s.showChild;if(a!=null&&i.children[a]!==r.id)return!1}return!0}function Xt(e,t=!1){var r,a,o;const{store:i,canvasRect:s}=e.calculative.canvas;if(t&&((r=e.children)==null||r.forEach(l=>{const n=i.pens[l];n&&Xt(n,!0)})),e.calculative.inView=!0,Ti(e,i)?(e.visible==!1||e.calculative.visible==!1)&&(e.calculative.inView=!1,(e.canvasLayer===ht.CanvasImageBottom||e.canvasLayer===ht.CanvasImage)&&((a=e.frames)!=null&&a.length)&&(e.calculative.inView=e.frames.some(l=>l.hasOwnProperty("visible")))):e.calculative.inView=!1,e.calculative.inView){const{x:l,y:n,width:h,height:c,rotate:f}=e.calculative.worldRect,u={x:l+i.data.x,y:n+i.data.y,width:h,height:c,rotate:f};bt(u),ee(u,s)||(e.calculative.inView=!1)}i.data.locked&&e.calculative.inView&&(e.calculative.inView=Hr(e,i.options.roles)),(o=e.calculative.singleton)!=null&&o.div&&Ct(e,e.calculative.singleton.div)}function Hr(e,t){var i;return(i=e.roles)!=null&&i.length?t!=null&&t.length?t==null?void 0:t.some(s=>e.roles.includes(s)):!1:e.parentId?Hr(Mt(e,!1),t):e.calculative.inView}function jo(e,t,i){if(t.fillWorldTextRect){e.save(),e.fillStyle="#c3deb7";const{x:s,y:r,width:a,height:o}=i.calculative.worldTextRect;e.fillRect(s,r,a,o),e.restore()}}function be(e,t){const i=t.calculative.globalAlpha;typeof i=="number"&&i<1&&!isNaN(i)&&(e.globalAlpha=i)}function Vr(e,t){const i=Wo(e,t)||it.canvasDraws[t.name];i&&(e.save(),i(e,t),e.restore())}function Wo(e,t){const i=t.drawCommand;if(!(!i||t.name==="line"))return(s,r)=>{i.forEach(a=>{try{a.steps=a.steps.flat(1/0),a.steps.reduce((o,l)=>{const n=Ho(l,r,o.x,o.y);try{if(n.c){if(n.c.startsWith("_")){const c=n.c.split("_")[1];return typeof n.v.value=="number"&&(n.v.value*=r.calculative.canvas.store.data.scale),(n.p||s)[c]=n.v.value,{x:o.x,y:o.y}}let h=[];for(const c in n.v)h.push(n.v[c]);return(n.p||s)[n.c](...h),{x:n.startX||n.v.x,y:n.startY||n.v.y}}return{x:o.x,y:o.y}}catch{}},{})}catch{}}),s.stroke()}}function Ho(e,t,i,s){var a;const r={visio:qo,dxf:Vo,canvas:Uo};return((a=r[t.parseType])==null?void 0:a.call(r,e,t,i,s))||e}function Vo(e,t,i,s){const{x:r,y:a,width:o,height:l}=t.calculative.worldRect,{originWidth:n,originHeight:h}=t.dxfOrigin;switch(e.c){case"beginPath":return{c:"beginPath",v:{}};case"closePath":return{c:"closePath",v:{}};case"moveTo":return{c:"moveTo",v:{x:e.v.x*(o/n)+r,y:e.v.y*(l/h)+a}};case"lineTo":return{c:"lineTo",v:{x:e.v.x*(o/n)+r,y:e.v.y*(l/h)+a}};case"arc":return{c:"ellipse",v:{x:e.v.x*(o/n)+r,y:e.v.y*(l/h)+a,rx:e.v.xr*(o/n),ry:e.v.yr*(l/h),rotation:e.v.rotation||0,startAngle:e.v.startAngle,endAngle:e.v.endAngle,a:e.v.aclockwise??!0}};case"ellipse":return{c:"ellipse",v:{x:e.v.x*(o/n)+r,y:e.v.y*(l/h)+a,rx:e.v.xr*(o/n),ry:e.v.yr*(l/h),rotation:e.v.rotation||0,startAngle:e.v.startAngle,endAngle:e.v.endAngle,a:e.v.aclockwise??!0}};case"_font":return{c:"_font",v:{value:e.v.fontSize*t.calculative.canvas.store.data.scale+"px "+(e.v.fontFamily||t.calculative.canvas.store.options.fontFamily)}};case"_fillStyle":return{c:"_fillStyle",v:{value:t.color||e.v.value}};default:const c={c:e.c,v:{...e.v}};return c.v.x!==void 0&&(c.v.x=e.v.x*(o/n)+r),c.v.y!==void 0&&(c.v.y=e.v.y*(l/h)+a),c}}function Uo(e,t,i,s){const{x:r,y:a,width:o,height:l}=t.calculative.worldRect,{originWidth:n,originHeight:h}=t.origin;switch(e.c){case"beginPath":return{c:"beginPath",v:{}};case"closePath":return{c:"closePath",v:{}};case"moveTo":return{c:"moveTo",v:{x:e.v.x*(o/n)+r,y:e.v.y*(l/h)+a}};case"lineTo":return{c:"lineTo",v:{x:e.v.x*(o/n)+r,y:e.v.y*(l/h)+a}};case"arc":return{c:"ellipse",v:{x:e.v.x*(o/n)+r,y:e.v.y*(l/h)+a,rx:e.v.xr*(o/n),ry:e.v.yr*(l/h),rotation:e.v.rotation||0,startAngle:e.v.startAngle,endAngle:e.v.endAngle,a:e.v.aclockwise??!0}};case"ellipse":return{c:"ellipse",v:{x:e.v.x*(o/n)+r,y:e.v.y*(l/h)+a,rx:e.v.xr*(o/n),ry:e.v.yr*(l/h),rotation:e.v.rotation||0,startAngle:e.v.startAngle,endAngle:e.v.endAngle,a:e.v.aclockwise??!0}};case"_font":return{c:"_font",v:{value:e.v.fontSize*t.calculative.canvas.store.data.scale+"px "+(e.v.fontFamily||t.calculative.canvas.store.options.fontFamily)}};default:const c={c:e.c,v:{...e.v}};return c.v.x!==void 0&&(c.v.x=e.v.x*(o/n)+r),c.v.y!==void 0&&(c.v.y=e.v.y*(l/h)+a),c}}function qo(e,t,i,s){const{x:r,y:a,width:o,height:l}=t.calculative.worldRect,{width:n,height:h}=t.origin;switch(e.c){case"MoveTo":return{c:"moveTo",v:{x:+e.v.X*100*(o/n)+r,y:+e.v.Y*100*(l/h)+a}};case"RelMoveTo":return{c:"moveTo",v:{x:+e.v.X*n*(o/n)+r,y:+e.v.Y*h*(l/h)+a}};case"LineTo":return{c:"lineTo",v:{x:+e.v.X*100*(o/n)+r,y:+e.v.Y*100*(l/h)+a}};case"RelLineTo":return{c:"lineTo",v:{x:+e.v.X*n*(o/n)+r,y:+e.v.Y*h*(l/h)+a}};case"Ellipse":let c=e.v.X,f=e.v.Y,u=Math.abs(e.v.A-e.v.C),d=Math.abs(e.v.B-e.v.D);return{c:"ellipse",v:{x:c*100*(o/n)+r,y:f*100*(l/h)+a,radiuX:u*100*(o/n),radiuY:d*100*(l/h),rotation:0,startAngle:0,endAngle:Math.PI*2,anticlockwise:!0}};case"EllipticalArcTo":const v=e.v.X*100*(o/n)+r,g=e.v.Y*100*(l/h)+a,y=e.v.A*100*(o/n)+r,p=e.v.B*100*(l/h)+a;e.v.C;const b=e.v.D*(o/l)*(h/n),m=(v-i)*(p-s)-(g-s)*(y-i)>0,k=Fs(i,s,v,g,y,p,b);return!e.orign&&(e.orign={}),!e.orign.startA&&(e.orign.startA=ai(k.x0,k.y0,i,s)),!e.orign.endA&&(e.orign.endA=ai(k.x0,k.y0,v,g)),{c:"ellipse",v:{centerX:k.x0,centerY:k.y0,radiuX:k.a,radiuY:k.b,rotation:0,startAngle:e.orign.startA,endAngle:e.orign.endA,anticlockwise:m},startX:v,startY:g};case"RelEllipticalArcTo":const A=e.v.X*n*(o/n)+r,S=e.v.Y*h*(l/h)+a,I=e.v.A*n*(o/n)+r,E=e.v.B*h*(l/h)+a;e.v.C;const z=e.v.D*(o/l)*(h/n),U=(A-i)*(E-s)-(S-s)*(I-i)>0,T=Fs(i,s,A,S,I,E,z);return!e.orign&&(e.orign={}),!e.orign.startA&&(e.orign.startA=ai(T.x0,T.y0,i,s)),!e.orign.endA&&(e.orign.endA=ai(T.x0,T.y0,A,S)),{c:"ellipse",v:{centerX:T.x0,centerY:T.y0,radiuX:T.a,radiuY:T.b,rotation:0,startAngle:e.orign.startA,endAngle:e.orign.endA,anticlockwise:U},startX:A,startY:S};case"ArcTo":let R=e.v.X*100*o/n+r,C=e.v.Y*100*l/h+a,_=e.v.A*100*t.calculative.canvas.store.data.scale,B=(i+R)/2,j=(s+C)/2,X=Math.sqrt((R-i)**2+(C-s)**2);if(Math.abs(_)<.001||X<.001)return{c:"lineTo",v:{x:R,y:C}};let F=X*X/(8*Math.abs(_))+Math.abs(_)/2,L=-(C-s)/X,N=(R-i)/X,W=F-Math.abs(_),O=B-Math.sign(_)*L*W,q=j-Math.sign(_)*N*W,$=Math.atan2(s-q,i-O),Y=Math.atan2(C-q,R-O),Z=Y-$;for(;Z>Math.PI;)Z-=2*Math.PI;for(;Z<-Math.PI;)Z+=2*Math.PI;let J=_>0;return(J&&Z>0||!J&&Z<0)&&([$,Y]=[Y,$],J=!J),{c:"arc",v:{x:O,y:q,radius:F,startAngle:$,endAngle:Y,anticlockwise:J},startX:R,startY:C};default:const Q=K(e);return Object.entries(Q.v).forEach(([w,x])=>{var P,M;(P=w.endsWith)!=null&&P.call(w,"_x")?typeof x=="number"&&(Q.v[w]=x*(o/n)+r):(M=w.endsWith)!=null&&M.call(w,"_y")?typeof x=="number"&&(Q.v[w]=x*(l/h)+a):typeof x=="number"&&(Q.v[w]=x)}),Q}}function $o(e,t){e.filter=t.filter}function fs(e,t){for(const i in t)mr.includes(i)&&(i=="fontSize"&&t[i]<0&&(t[i]=0),e[i]=t[i],["fontSize","lineWidth"].includes(i)?(e.calculative[i]=t[i]*e.calculative.canvas.store.data.scale,Yt(e)):e.calculative[i]=t[i]),e.image&&e.name!=="gif"&&yr.includes(i)&&(e.calculative.canvas.store.patchFlagsTop=!0,e.calculative.canvas.store.patchFlagsBackground=!0,e.calculative.imageDrawed=!1);if(e.calculative.canvas.parent.isCombine(e)){const i=e.children;i==null||i.forEach(s=>{let r=K(t);e.calculative.childrenVisible&&e.calculative.childrenVisible[s]===!1&&delete r.visible;const a=e.calculative.canvas.store.pens[s];a&&fs(a,r)})}}function Fs(e,t,i,s,r,a,o){let l=(e-i)*(e+i)*(s-a)-(i-r)*(i+r)*(t-s)+o*o*(t-s)*(s-a)*(t-a),n=2*((e-i)*(s-a)-(i-r)*(t-s)),h=l/n,c=(e-i)*(i-r)*(e-r)+o*o*((i-r)*(t-s)*(t+s)-(e-i)*(s-a)*(s+a)),f=2*o*o*((i-r)*(t-s)-(e-i)*(s-a)),u=c/f,d=Math.sqrt(Math.pow(e-h,2)+Math.pow(o*(t-u),2)),v=d/o;return{x0:h,y0:u,a:d,b:v}}function ai(e,t,i,s){let r=i-e,a=s-t,o=Math.atan2(a,r);return o<0&&(o+=2*Math.PI),o}function zs(e,t,i){let s,r,a=1/0,o=1/0;const l=8;for(const n of e.data.pens){if(n.calculative.inView===!1)continue;vs(n).forEach(c=>{if(c===t||c===i)return;let f=(n.calculative.worldRect.center.x-t.x)*(n.calculative.worldRect.center.x-t.x)+(n.calculative.worldRect.center.y-t.y)*(n.calculative.worldRect.center.y-t.y);const u=Math.abs(c.x-t.x);u>0&&u<l&&f<a&&(s={x:Math.round(c.x)+.5,y:Math.round(c.y)+.5,prev:{x:Math.round(t.x)+.5,y:Math.round(t.y)+.5},step:c.x-t.x},a=f);const d=Math.abs(c.y-t.y);d>0&&d<l&&f<o&&(r={x:Math.round(c.x)+.5,y:Math.round(c.y)+.5,prev:{x:Math.round(t.x)+.5,y:Math.round(t.y)+.5},step:c.y-t.y},o=f)})}return{xDock:s,yDock:r}}function Yo(e,t,i,s){let r=[];return i.length===1?(r=K(vs(i[0])),r.forEach(a=>{a.x+=s.x,a.y+=s.y})):(yt(t),r=[t.center,...re(t)]),Ur(e,r,t,!0)}function vs(e){if(e.type){if(e.type===ut.Line)return e.calculative.worldAnchors}else{const t=re(e.calculative.worldRect);return yt(e.calculative.worldRect),[...e.calculative.worldAnchors,...t,e.calculative.worldRect.center]}}function Xo(e,t,i,s){const r=re(t);return Ur(e,r,t)}function Ur(e,t,i,s=!1){let r,a,o=1/0,l=1/0;const n=10,h=vn(i,n);return e.data.pens.forEach(c=>{const{inView:f,worldRect:u,active:d}=c.calculative;if(f===!1||!s&&d||fn(h,u)||c.type&&e.active.some(g=>qr(e,g,c)))return;const v=vs(c);if(v)for(const g of v)for(const y of t){const p=g.x-y.x,b=g.y-y.y,m=Math.abs(p),k=Math.abs(b);i.center||(i.center={x:i.x+i.width/2,y:i.y+i.height/2}),m<n&&m<o&&(r={x:Math.round(g.x)+.5,y:Math.round(g.y)+.5,step:p,prev:{x:Math.round(y.x)+.5,y:Math.round(y.y)+.5},penId:c.id,anchorId:y.id,dockAnchorId:g.id},o=m),k<n&&k<l&&(a={x:Math.round(g.x)+.5,y:Math.round(g.y)+.5,step:b,prev:{x:Math.round(y.x)+.5,y:Math.round(y.y)+.5},penId:c.id,anchorId:y.id,dockAnchorId:g.id},l=k)}}),{xDock:r,yDock:a}}function qr(e,t,i){if(!i.type)return!1;if(Array.isArray(t==null?void 0:t.connectedLines)){for(const s of t==null?void 0:t.connectedLines)if(s.lineId===i.id)return!0}if(Array.isArray(t==null?void 0:t.children))for(const s of t.children){const r=e.pens[s];if(qr(e,r,i))return!0}return!1}function Gi(e,t){return e.toFixed(12)==t}function Ko(e,t=4){let i=e.map(h=>h.calculative.worldRect);const s=i.map(h=>h.x),r=i.map(h=>h.y),a=s.reduce((h,c)=>h+c,0)/s.length,o=r.reduce((h,c)=>h+c,0)/r.length,l=Math.sqrt(s.map(h=>Math.pow(h-a,2)).reduce((h,c)=>h+c,0)/s.length),n=Math.sqrt(r.map(h=>Math.pow(h-o,2)).reduce((h,c)=>h+c,0)/r.length);return e.filter(h=>{let c=h.calculative.worldRect;const f=(c.x-a)/l,u=(c.y-o)/n;return Math.sqrt(f*f+u*u)>t})}function js(e){if(e.id=lt(),Array.isArray(e.anchors))for(const t of e.anchors)e.type&&(t.id=lt()),t.penId=e.id,t.prev&&(e.type&&(t.prev.id=lt()),t.prev.penId=e.id),t.next&&(e.type&&(t.next.id=lt()),t.next.penId=e.id)}function Go(){let e=null,t=new WeakMap;return(i,s,r,a=!1)=>{if(t.has(i)&&t.get(i)?e=t.get(i):t.set(i,e=new Map),typeof r!="function")return()=>{console.warn("[rewritePenLifeCycle] warn: not a function ")};let o=new Set,l=new Map;e.has(s)&&e.get(s)?o=e.get(s):(l.set(s,i[s]),e.set(s,o)),a?o.delete(r):o.add(r);let n=l.get(s),h=(...c)=>{n==null||n(...c),o.forEach(f=>{f(...c)})};i[s]=h}}let Jo=Go();function Qo(e){return!e.name&&!e.install?(console.error("installPenPlugin Error: Validation Failed"),!1):!0}function Zo(e,t,i){if(t.calculative.worldAnchors||(t.calculative.worldAnchors=[]),i)t.calculative.activeAnchor&&(t.calculative.activeAnchor.next={penId:t.id,x:i.x,y:i.y},Mi(t.calculative.activeAnchor.next,t.calculative.activeAnchor)<5?t.calculative.activeAnchor.next=void 0:(t.calculative.activeAnchor.prev={...t.calculative.activeAnchor.next},vt(t.calculative.activeAnchor.prev,180,t.calculative.activeAnchor)));else{const s=t.calculative.worldAnchors[0];if(!s.next){const a=Oe(s,e.pens[s.connectTo]);Ws(s,a,50),s.prev=void 0}const r=t.calculative.worldAnchors[t.calculative.worldAnchors.length-1];if(r&&r!==s&&!r.prev){const a=Oe(r,e.pens[r.connectTo]);Ws(r,a,-50),r.next=void 0}}}function Ws(e,t,i){switch(t){case nt.Up:e.prev={penId:e.penId,x:e.x,y:e.y+i},e.next={penId:e.penId,x:e.x,y:e.y-i};break;case nt.Right:e.prev={penId:e.penId,x:e.x-i,y:e.y},e.next={penId:e.penId,x:e.x+i,y:e.y};break;case nt.Bottom:e.prev={penId:e.penId,x:e.x,y:e.y-i},e.next={penId:e.penId,x:e.x,y:e.y+i};break;case nt.Left:e.prev={penId:e.penId,x:e.x+i,y:e.y},e.next={penId:e.penId,x:e.x-i,y:e.y};break}}function ge(e,t,i,s){const r=1-e,a=r*r*t.x+2*r*e*i.x+e*e*s.x,o=r*r*t.y+2*r*e*i.y+e*e*s.y;return{x:a,y:o,step:e}}function Ci(e,t,i,s,r){const{x:a,y:o}=t,{x:l,y:n}=r,{x:h,y:c}=i,{x:f,y:u}=s,d=1-e,v=a*d*d*d+3*h*e*d*d+3*f*e*e*d+l*e*e*e,g=o*d*d*d+3*c*e*d*d+3*u*e*e*d+n*e*e*e;return{x:v,y:g,step:e}}function ne(e,t,i){return{x:e.x+i*(t.x-e.x),y:e.y+i*(t.y-e.y)}}function tn(e,t,i){let s=e.calculative.worldAnchors[i],r=e.calculative.worldAnchors[i+1];!r&&e.close&&(r=e.calculative.worldAnchors[0]);const a=t.step;let o;if(s.next&&r.prev){const l=s,n=s.next,h=r.prev,c=r,f=ne(l,n,a),u=ne(n,h,a),d=ne(h,c,a),v=ne(f,u,a),g=ne(u,d,a);o=ne(v,g,a),v.penId=e.id,o.prev=v,g.penId=e.id,o.next=g,s.next.x=f.x,s.next.y=f.y,r.prev.x=d.x,r.prev.y=d.y}else if(s.next||r.prev){const l=s,n=s.next||r.prev,h=r,c=ne(l,n,a),f=ne(n,h,a);o=t,c.penId=e.id,f.penId=e.id,o.prev=c,o.next=f,s.next=void 0,r.prev=void 0}else o=t;return o.penId=e.id,o.id=lt(),o.prevNextType=pe.Bilateral,o}function en(e,t,i){if(t.calculative.worldAnchors||(t.calculative.worldAnchors=[]),t.calculative.worldAnchors.length<2)return;let s=t.calculative.activeAnchor,r=i||dt(t);if(!s||!r)return;const a=20,o=e.pens[s.connectTo];let l=Oe(s,o);switch(l===nt.None&&(r.x>s.x?l=nt.Right:l=nt.Left),s.next={id:lt(),penId:t.id,x:s.x,y:s.y,prevNextType:2},r.prev={id:lt(),penId:t.id,x:r.x,y:r.y,prevNextType:2},l){case nt.Up:s.next.y-=a,r.prev.y=s.y;break;case nt.Bottom:s.next.y+=a,r.prev.y=s.y;break;case nt.Left:s.next.x-=a,r.prev.x=s.x;break;default:s.next.x+=a,r.prev.x=s.x;break}}function sn(e,t){const i=t||new Path2D;if((e.lineName==="line"||e.lineName==="polyline")&&e.calculative.lineSmooth){let r=hs(e);if(i instanceof Path2D&&i.addPath(r),i instanceof Path2D)return i}const s=e.calculative.worldAnchors;if(s.length>1){let r;s.forEach(a=>{r?Hs(i,r,a):a.start=!0,r=a}),e.close&&(e.lineName==="curve"?Hs(i,r,s[0]):i.closePath())}if(i instanceof Path2D)return i}function rn(e,t,i){var a;if(t.calculative.worldAnchors||(t.calculative.worldAnchors=[]),t.calculative.worldAnchors.length<2||((a=t.anchors)==null?void 0:a.length)>1)return;const s=xt(t),r=dt(t);!s||!r||!r.id||s===r||(s.next=void 0,ds(t),r.prev=void 0,t.calculative.worldAnchors.push(r))}function Hs(e,t,i){!i||i.isTemp||(t.start&&e.moveTo(t.x,t.y),t.next?i.prev?e.bezierCurveTo(t.next.x,t.next.y,i.prev.x,i.prev.y,i.x,i.y):e.quadraticCurveTo(t.next.x,t.next.y,i.x,i.y):i.prev?e.quadraticCurveTo(i.prev.x,i.prev.y,i.x,i.y):e.lineTo(i.x,i.y))}function Ji(e){return Si(e),Ze(gs(e))}function gs(e){const t=[];let i;return e.calculative.worldAnchors.forEach(s=>{i&&t.push(...Vs(i,s,e)),t.push(s),i=s}),e.close&&e.calculative.worldAnchors.length>1&&t.push(...Vs(i,e.calculative.worldAnchors[0],e)),t}function Ai(e){return e!=null&&e.lineWidth?e.lineWidth/2+4:4}function Vs(e,t,i){const s=[];if(!t)return s;let r=.02;if(e.lineLength&&!i.parentId&&(r=Ai(i)/e.lineLength),e.next)if(t.prev)for(let a=r;a<1;a+=r)s.push(Ci(a,e,e.next,t.prev,t));else for(let a=r;a<1;a+=r)s.push(ge(a,e,e.next,t));else if(t.prev)for(let a=r;a<1;a+=r)s.push(ge(a,e,t.prev,t));else s.push({x:t.x,y:t.y});return s.length>1&&(e.curvePoints=s),s}function an(e,t){const i=Ai(t);let s=0,r,a;for(const o of t.calculative.worldAnchors){if(r){if(a=Us(e,r,o,i),a)return{i:s,point:a};++s}r=o}if(t.close&&t.calculative.worldAnchors.length>1&&(a=Us(e,r,t.calculative.worldAnchors[0],i)))return{i:s,point:a}}function Us(e,t,i,s=4){if(!t.next&&!i.prev){const{x:r,y:a}=t,{x:o,y:l}=i,n=Math.min(r,o),h=Math.max(r,o),c=Math.min(a,l),f=Math.max(a,l);return e.x>=n-s&&e.x<=h+s&&e.y>=c-s&&e.y<=f+s?on(e,t,i,s):void 0}else if(t.curvePoints){for(const r of t.curvePoints)if(Ce(e,r,s))return r}}function on(e,t,i,s=4){if(t.x===i.x){if(Math.abs(e.x-t.x)<=s)return{x:t.x,y:e.y}}else{const r=(t.y-i.y)/(t.x-i.x),a=t.y-r*t.x;if(Math.abs((r*e.x+a-e.y)/Math.sqrt(r*r+1))<=s){const n=(e.x+r*e.y-r*a)/(r*r+1);return{x:n,y:r*n+a}}}}function qs(e,t,i,s){if(!t&&!i)return Math.sqrt(Math.pow(Math.abs(e.x-s.x),2)+Math.pow(Math.abs(e.y-s.y),2))||0;const r=document.createElementNS("http://www.w3.org/2000/svg","path");return t&&i?r.setAttribute("d",`M${e.x} ${e.y} C${t.x} ${t.y} ${i.x} ${i.y} ${s.x} ${s.y}`):t?r.setAttribute("d",`M${e.x} ${e.y} Q${t.x} ${t.y} ${s.x} ${s.y}`):r.setAttribute("d",`M${e.x} ${e.y} Q${i.x} ${i.y} ${s.x} ${s.y}`),r.getTotalLength()||0}function Si(e){if(e.calculative.worldAnchors.length<2)return 0;let t=0,i;if(e.calculative.worldAnchors.forEach(s=>{i&&(i.lineLength=qs(i,i.next,s.prev,s),t+=i.lineLength),i=s}),e.close){const s=xt(e);i.lineLength=qs(i,i.next,s.prev,s),t+=i.lineLength}return e.calculative.animatePos&&(e.calculative.animatePos=t/e.length*e.calculative.animatePos),e.length=t,t}function ji(e,t){const i=e.calculative.worldAnchors;for(let s=0;s<i.length-1;s++){const r=i[s],a=i[s+1];if(!r.next&&!a.prev){if($r(r,a,t))return!0}else if(nn(r,a,t))return!0}return!1}function $r(e,t,i){if(xe(e,i)||xe(t,i))return!0;const s=e.x,r=e.y,a=t.x,o=t.y;let l=i.x,n=i.y,h=i.ex,c=i.ey;const f=r-o,u=a-s,d=s*o-a*r;if(f*l+u*n+d>=0&&f*h+u*c+d<=0||f*l+u*n+d<=0&&f*h+u*c+d>=0||f*l+u*c+d>=0&&f*h+u*n+d<=0||f*l+u*c+d<=0&&f*h+u*n+d>=0){if(l>h){const v=l;l=h,h=v}if(n<c){const v=n;n=c,c=v}return!(s<l&&a<l||s>h&&a>h||r>n&&o>n||r<c&&o<c)}else return!1}function nn(e,t,i){if(!e.next&&!t.prev)return $r(e,t,i);if(e.next&&t.prev)for(let r=.02;r<1;r+=.02){const a=Ci(r,e,e.next,t.prev,t);if(xe(a,i))return!0}else if(e.next||t.prev)for(let r=.02;r<1;r+=.02){const a=ge(r,e,e.next||t.prev,t);if(xe(a,i))return!0}return!1}function $s(e,t,i,s,r){let a="";return e||(a+=`M${t.x} ${t.y} `,e=document.createElementNS("http://www.w3.org/2000/svg","path"),e.setAttribute("d",a)),a=e.getAttribute("d")||"",i&&s?a+=`C${i.x} ${i.y} ${s.x} ${s.y} ${r.x} ${r.y}`:i?a+=`Q${i.x} ${i.y} ${r.x} ${r.y}`:a+=`Q${(s==null?void 0:s.x)||t.x} ${(s==null?void 0:s.y)||t.y} ${r.x} ${r.y}`,e.setAttribute("d",a),e}function ln(e,t){const i=e.getTotalLength();if(t<0||t>i)return null;const s=Math.max(.01,i*1e-4),r=e.getPointAtLength(t),a=e.getPointAtLength(t-s),o=Math.atan2(r.y-a.y,r.x-a.x);return{x:r.x,y:r.y,rotate:o/Math.PI*180,progress:t/i}}function cn(e){const t=e.lineAnimateType;return t==null?!1:(Array.isArray(t)?t:[t]).some(s=>s===pt.Arrow||s===pt.WaterDrop)}function hn(e,t,i){e.beginPath(),e.moveTo(0,0),e.lineTo(-t,-i),e.moveTo(0,0),e.lineTo(-t,i),e.stroke()}function un(e,t,i,s,r,a){e.save(),e.translate(t,i),e.rotate(s),hn(e,r,a),e.restore()}function Ys(e,t,i){let s=0,r=t.length-1;for(;r-s>1;){const d=s+r>>1;t[d]<=i?s=d:r=d}const a=s,o=e[a],l=e[a+1],n=t[a+1]-t[a],h=n>1e-6?(i-t[a])/n:0,c=o.x+h*(l.x-o.x),f=o.y+h*(l.y-o.y),u=Math.atan2(l.y-o.y,l.x-o.x);return{x:c,y:f,ang:u}}function Yr(e,t,i){if(t.type!==ut.Line||!(t.dirMarkers||i.options.dirMarkers)||t.calculative.pencil)return;const r=t.calculative.worldAnchors;if(!r||r.length<2||t.calculative.animatePos&&cn(t))return;const a=i.options.drawDirMarkers;e.save(),e.setLineDash([]),e.shadowBlur=0,e.shadowColor="",e.shadowOffsetX=0,e.shadowOffsetY=0;const o=gs(t);if(o.length<2){e.restore();return}const l=i.data.scale,n=(t.dirMarkerInterval??i.options.dirMarkerInterval??40)*l,h=t.dirMarkerColor??i.options.dirMarkerColor??"#ffffff",c=t.calculative.lineWidth||2,f=(t.dirMarkerLineWidth??i.options.dirMarkerLineWidth)!=null?(t.dirMarkerLineWidth??i.options.dirMarkerLineWidth)*l:Math.min(c*.38,Math.max(.75,c*.14)),u=[0];let d=0;for(let g=0;g<o.length-1;g++){const y=o[g+1].x-o[g].x,p=o[g+1].y-o[g].y;d+=Math.sqrt(y*y+p*p),u.push(d)}if(d<=1e-6){e.restore();return}let v=[];for(let g=n/2;g<d;g+=n)v.push(g);if((v.length===0||v.length===1)&&(v=[d/2]),a){e.strokeStyle=h,e.lineWidth=f,e.lineJoin="round",e.lineCap="round";for(const g of v){const{x:y,y:p,ang:b}=Ys(o,u,g);a(e,y,p,b,h,t)}}else{const y=Math.max(0,c-f)*.38,p=c*.52;e.strokeStyle=h,e.lineWidth=f,e.lineJoin="round",e.lineCap="round";for(const b of v){const{x:m,y:k,ang:A}=Ys(o,u,b);un(e,m,k,A,p,y)}}e.restore()}function Jt(e,t){if(!t)return;if(t.ex==null&&bt(t),!t.rotate||t.rotate%360===0)return e.x>t.x&&e.x<t.ex&&e.y>t.y&&e.y<t.ey;t.center||yt(t);const i=[{x:t.x,y:t.y},{x:t.ex,y:t.y},{x:t.ex,y:t.ey},{x:t.x,y:t.ey}];return i.forEach(s=>{vt(s,t.rotate,t.pivot||t.center)}),dn(e,i)}function xe(e,t,i=0){const{x:s,y:r,ex:a,ey:o}=t;return e.x>=s-i&&e.x<=a+i&&e.y>=r-i&&e.y<=o+i}function yt(e){e.center||(e.center={}),e.center.x=e.x+e.width/2,e.center.y=e.y+e.height/2}function bt(e){e.ex=e.x+e.width,e.ey=e.y+e.height}function Qi(e,t){e.pivot||(e.pivot={}),e.pivot.x=e.x+e.width*t.x,e.pivot.y=e.y+e.height*t.y}function dn(e,t){if(t.length<3)return!1;let i=!1,s=t[t.length-1];for(const r of t)s.y>e.y!=r.y>e.y&&r.x+(e.y-r.y)*(s.x-r.x)/(s.y-r.y)>e.x&&(i=!i),s=r;return i}function Vt(e){const t=[];e.forEach(s=>{if(s.isRuleLine)return;const r=s.calculative.worldRect;if(r){const a=re(r);t.push(...a)}});const i=Ze(t);return yt(i),i}function re(e){const t=[{x:e.x,y:e.y},{x:e.ex,y:e.y},{x:e.ex,y:e.ey},{x:e.x,y:e.ey}];return e.rotate&&(e.center||yt(e),t.forEach(i=>{vt(i,e.rotate,e.pivot||e.center)})),t}function Ze(e){let t=1/0,i=1/0,s=-1/0,r=-1/0;return e==null||e.forEach(a=>{!isFinite(a.x)||!isFinite(a.y)||(t=Math.min(t,a.x),i=Math.min(i,a.y),s=Math.max(s,a.x),r=Math.max(r,a.y))}),{x:t,y:i,ex:s,ey:r,width:s-t,height:r-i}}function ee(e,t,i){return e.rotate&&(e=Ze(re(e))),i?e.x>t.x&&e.ex<t.ex&&e.y>t.y&&e.ey<t.ey:!(e.x>t.ex||e.ex<t.x||e.ey<t.y||e.y>t.ey)}function fn(e,t){return(t.x>e.ex||t.ex<e.x)&&(t.y>e.ey||t.ey<e.y)}function vn(e,t){const i=Zt(t),s={x:e.x-i[3],y:e.y-i[0],width:e.width+i[1]+i[3],height:e.height+i[0]+i[2]};return bt(s),s}function ye(e,t,i){e.x+=t,e.y+=i,e.ex+=t,e.ey+=i,e.center&&(e.center.x+=t,e.center.y+=i),e.pivot&&(e.pivot.x+=t,e.pivot.y+=i)}function gn(e,t){const i=(e.to.y-e.from.y)/(e.to.x-e.from.x),s=(t.to.y-t.from.y)/(t.to.x-t.from.x);return Zi({k:i,point:e.from},{k:s,point:t.from})}function Zi(e,t){if(Gi(e.k,0))return{x:t.point.x,y:e.point.y};if(Gi(t.k,0))return{x:e.point.x,y:t.point.y};const i=e.point.y-e.k*e.point.x,r=(t.point.y-t.k*t.point.x-i)/(e.k-t.k),a=e.k*r+i;return{x:r,y:a}}function yn(e,t){const i=gn({from:e[0],to:e[2]},{from:e[1],to:e[3]});for(const s of e)vt(s,-t,i);return Ze(e)}function Xs(e,t,i,s){let r=e.rotate?e.rotate%360:0;if(r){const a=re(e),o=(a[0].y-a[1].y)/(a[0].x-a[1].x),l=(a[1].y-a[2].y)/(a[1].x-a[2].x);if(s<4){if(a[s].x+=t,e.ratio)if(s===0||s===2){let c=t*Math.tan((90-(360-r)-Math.atan(e.width/e.height)/Math.PI*180)/180*Math.PI);a[s].y+=c}else{let c=t*Math.tan((90-(360-r)+Math.atan(e.width/e.height)/Math.PI*180)/180*Math.PI);a[s].y+=c}else a[s].y+=i;const h=a[(s+2)%4];a[(s+1)%4]=Zi({k:s%2?l:o,point:a[s]},{k:s%2?o:l,point:h}),a[(s+4-1)%4]=Zi({k:s%2?o:l,point:a[s]},{k:s%2?l:o,point:h})}else{const h=[4,6].includes(s)?l:o;Gi(h,0)?(a[s%4].x+=t,a[(s+1)%4].x+=t):(a[s%4].y+=i,a[s%4].x+=i/h,a[(s+1)%4].y+=i,a[(s+1)%4].x+=i/h)}if((a[0].x-a[1].x)**2+(a[0].y-a[1].y)**2<25||(a[1].x-a[2].x)**2+(a[1].y-a[2].y)**2<25)return;const n=yn(a,e.rotate);yt(n),Object.assign(e,n);return}switch(s){case 0:if(e.width-t<5||e.height-i<5)break;e.x+=t,e.y+=i,e.width-=t,e.height-=i;break;case 1:if(e.width+t<5||e.height-i<5)break;e.ex+=t,e.y+=i,e.width+=t,e.height-=i;break;case 2:if(e.width+t<5||e.height+i<5)break;e.ex+=t,e.ey+=i,e.width+=t,e.height+=i;break;case 3:if(e.width-t<5||e.height+i<5)break;e.x+=t,e.ey+=i,e.width-=t,e.height+=i;break;case 4:if(e.height-i<5)break;e.y+=i,e.height-=i;break;case 5:if(e.width+t<5)break;e.ex+=t,e.width+=t;break;case 6:if(e.height+i<5)break;e.ey+=i,e.height+=i;break;case 7:if(e.width-t<5)break;e.x+=t,e.width-=t;break}}function De(e,t,i,s){e&&(e.width*=t,e.height*=t,Pe(e,t,i),bt(e),yt(e),s&&Qi(e,s))}function ce(e,t){const i={x:(e.x-t.x)/t.width,y:(e.y-t.y)/t.height,width:e.width/t.width,height:e.height/t.height};return bt(i),i}function Xe(e,t){const{x:i,y:s,width:r,height:a}=t,{penId:o,connectTo:l}=e,n=Object.assign({},e,{x:r?(e.x-i)/r:0,y:a?(e.y-s)/a:0});return e.prev&&(n.prev={penId:o,connectTo:l,x:r?(e.prev.x-i)/r:0,y:a?(e.prev.y-s)/a:0}),e.next&&(n.next={penId:o,connectTo:l,x:r?(e.next.x-i)/r:0,y:a?(e.next.y-s)/a:0}),n}function mn(e,t){let i=!1;for(let s=0,r=t.length-1;s<t.length;r=s++){let a=t[s].x,o=t[s].y,l=t[r].x,n=t[r].y;o>e.y!=n>e.y&&e.x<(l-a)*(e.y-o)/(n-o)+a&&(i=!i)}return i}const pn=/^[\t\n\f\r ]*([MLHVZCSQTAmlhvzcsqta])[\t\n\f\r ]*/,Ks=/^[01]/,gt=/^[+-]?(([0-9]*\.[0-9]+)|([0-9]+\.)|([0-9]+))([eE][+-]?[0-9]+)?/,wn=/^(([\t\n\f\r ]+,?[\t\n\f\r ]*)|(,[\t\n\f\r ]*))/,bn={M:[gt,gt],L:[gt,gt],H:[gt],V:[gt],Z:[],C:[gt,gt,gt,gt,gt,gt],S:[gt,gt,gt,gt],Q:[gt,gt,gt,gt],T:[gt,gt],A:[gt,gt,gt,Ks,Ks,gt,gt]};function xn(e){let t=0;const i=[];for(;t<e.length;){const s=e.slice(t).match(pn);if(s!==null){const r=s[1];t+=s[0].length;const a=Cn(r,e,t);t=a.cursor,i.push(...a.commands)}else throw new Error("malformed path (first error at "+t+")")}return{commands:i}}function Gs(e){let t=1/0,i=1/0,s=-1/0,r=-1/0;return Sn(e),e.commands.forEach(a=>{a.worldPoints.forEach((o,l)=>{l%2===0?(o<t&&(t=o),o>s&&(s=o)):(o<i&&(i=o),o>r&&(r=o))})}),{x:t,y:i,ex:s,ey:r,width:s-t+1,height:r-i+1}}function kn(e,t,i){i==null&&(i=t),e.commands.forEach((s,r)=>{if(!(s.relative&&r))switch(s.key){case"A":case"a":s.values[5]+=t,s.values[6]+=i;break;case"V":case"v":s.values[0]+=i;break;default:s.values.forEach((a,o)=>{s.values[o]=a+(o%2===0?t:i)});break}})}function Rn(e,t,i){i==null&&(i=t),e.commands.forEach(s=>{switch(s.key){case"A":case"a":const r=s.values[0],a=s.values[1],o=Math.PI*s.values[2]/180,l=Math.cos(o),n=Math.sin(o),h=a*a*i*i*l*l+r*r*i*i*n*n,c=2*t*i*l*n*(a*a-r*r),f=r*r*t*t*l*l+a*a*t*t*n*n,u=-(r*r*a*a*t*t*i*i),d=c*c-4*h*f,v=Math.sqrt((h-f)*(h-f)+c*c);s.values[2]=c!==0?Math.atan((f-h-v)/c)*180/Math.PI:h<f?0:90,s.values[0]=-Math.sqrt(2*d*u*(h+f+v))/d,s.values[1]=-Math.sqrt(2*d*u*(h+f-v))/d,s.values[5]*=t,s.values[6]*=i,s.values[4]=t*i>=0?s.values[4]:1-s.values[4];break;case"V":case"v":s.values[0]*=i;break;default:s.values.forEach((g,y)=>{s.values[y]=g*(y%2===0?t:i)});break}})}function Tn(e){let t="";return e.commands.forEach(i=>{t+=i.key+" ",i.values.forEach(s=>{t+=s+" "})}),t}function Cn(e,t,i){const s=bn[e.toUpperCase()],r=[];for(;i<=t.length;){const a={key:e,values:[]};for(const o of s){const l=t.slice(i).match(o);if(l!==null){a.values.push(+l[0]),i+=l[0].length;const n=t.slice(i).match(wn);n!==null&&(i+=n[0].length)}else{if(a.values.length===0)return{cursor:i,commands:r};throw new Error("malformed path (first error at "+i+")")}}if(a.relative=a.key.toUpperCase()!==a.key,r.push(a),s.length===0)return{cursor:i,commands:r};e==="m"&&(e="l"),e==="M"&&(e="L")}throw new Error("malformed path (first error at "+i+")")}function An(e,t){const i=[];let s=e.relative&&t?{x:t.worldPoints[t.worldPoints.length-2],y:t.worldPoints[t.worldPoints.length-1]}:{x:0,y:0};for(let r=0;r<e.values.length-1;r+=2)i.push(s.x+e.values[r]),i.push(s.y+e.values[r+1]);e.worldPoints=i}function Js(e,t,i,s,r,a,o,l,n){const h=Math.cos(o),c=Math.sin(o),f=(e-i)/2,u=(t-s)/2,d=h*f+c*u,v=-c*f+h*u;let g=r*r,y=a*a;const p=d*d,b=v*v,m=p/g+b/y;if(m>1){const B=Math.sqrt(m);r*=B,a*=B,g=r*r,y=a*a}const k=Math.sqrt(Math.max(0,(g*y-g*b-y*p)/(g*b+y*p))),A=l===n?-k:k,S=A*r*v/a,I=-A*a*d/r,E=h*S-c*I+(e+i)/2,z=c*S+h*I+(t+s)/2;let U=Math.atan2(v-I,d-S),R=Math.atan2(-v-I,-d-S)-U;n===0&&R>0?R-=2*Math.PI:n===1&&R<0&&(R+=2*Math.PI);const C=[e,t,i,s];function _(B){const j=U+R;let X=B;const F=2*Math.PI,L=Math.floor((U-X)/F);X+=L*F;const N=1e-10;let W;if(R>0?(W=X>=U-N&&X<=j+N||X+F>=U-N&&X+F<=j+N,X+F>=U-N&&X+F<=j+N&&(X+=F)):(W=X<=U+N&&X>=j-N||X-F<=U+N&&X-F>=j-N,X-F<=U+N&&X-F>=j-N&&(X-=F)),W){const O=Math.cos(X),q=Math.sin(X);C.push(E+r*O*h-a*q*c),C.push(z+r*O*c+a*q*h)}}if(Math.abs(h)>1e-10){const B=Math.atan(-a*c/(r*h));_(B),_(B+Math.PI)}else _(0),_(Math.PI);if(Math.abs(c)>1e-10){const B=Math.atan(a*h/(r*c));_(B),_(B+Math.PI)}else _(Math.PI/2),_(3*Math.PI/2);return C}function Sn(e){let t,i=0,s=0;e.commands.forEach(r=>{switch(r.key){case"Z":case"z":r.worldPoints=[i,s];break;case"H":r.worldPoints=[r.values[0],t.worldPoints[t.worldPoints.length-1]];break;case"h":r.worldPoints=[r.values[0]+t.worldPoints[t.worldPoints.length-2],t.worldPoints[t.worldPoints.length-1]];break;case"V":r.worldPoints=[t.worldPoints[t.worldPoints.length-2],r.values[0]];break;case"v":r.worldPoints=[t.worldPoints[t.worldPoints.length-2],r.values[0]+t.worldPoints[t.worldPoints.length-1]];break;case"A":r.worldPoints=Js(t.worldPoints[t.worldPoints.length-2],t.worldPoints[t.worldPoints.length-1],r.values[5],r.values[6],r.values[0],r.values[1],r.values[2]*Math.PI/180,r.values[3],r.values[4]);break;case"a":r.worldPoints=Js(t.worldPoints[t.worldPoints.length-2],t.worldPoints[t.worldPoints.length-1],t.worldPoints[t.worldPoints.length-2]+r.values[5],t.worldPoints[t.worldPoints.length-1]+r.values[6],r.values[0],r.values[1],r.values[2]*Math.PI/180,r.values[3],r.values[4]);break;default:An(r,t);break}(r.key==="M"||r.key==="m"||r.key==="Z"||r.key==="z")&&(i=r.worldPoints[r.worldPoints.length-2],s=r.worldPoints[r.worldPoints.length-1]),t=r})}function Pn(e,t){var n;const s=e.calculative.canvas.store.data.paths[e.pathId];if(!s)return new Path2D;const r=xn(s);e.calculative.svgRect=Gs(r),yt(e.calculative.svgRect),(e.calculative.svgRect.width!==e.calculative.worldRect.width||e.calculative.svgRect.height!==e.calculative.worldRect.height)&&Rn(r,e.calculative.worldRect.width/e.calculative.svgRect.width,e.calculative.worldRect.height/e.calculative.svgRect.height);const a=Gs(r);yt(a),kn(r,e.calculative.worldRect.x-a.x,e.calculative.worldRect.y-a.y);const o=Tn(r);if(t){(n=t.svgPath)==null||n.call(t,o);return}return new Path2D(o)}function In(e,t){const i=t||new Path2D,{x:s,y:r,width:a,height:o}=e.calculative.worldRect;if(i.moveTo(s+a/2,r),i.lineTo(s+a,r+o/2),i.lineTo(s+a/2,r+o),i.lineTo(s,r+o/2),i.lineTo(s+a/2,r),i.closePath(),i instanceof Path2D)return i}function _n(e,t){const i=t||new Path2D,{x:s,y:r,width:a,height:o}=e.calculative.worldRect;if(i.moveTo(s+a/2,r),i.lineTo(s+a,r+o),i.lineTo(s,r+o),i.lineTo(s+a/2,r),i.closePath(),i instanceof Path2D)return i}function En(e){const t=[{x:.5,y:0},{x:.75,y:.5},{x:.5,y:1},{x:.25,y:.5}];e.anchors=t.map(({x:i,y:s},r)=>({id:`${r}`,penId:e.id,x:i,y:s}))}function Mn(e,t){const i=t||new Path2D,{x:s,y:r,width:a,height:o}=e.calculative.worldRect;if(i.moveTo(s+a/2,r),i.lineTo(s+a,r+o*2/5),i.lineTo(s+a*4/5,r+o),i.lineTo(s+a/5,r+o),i.lineTo(s,r+o*2/5),i.closePath(),i instanceof Path2D)return i}function Ln(e){const t=[{x:.5,y:0},{x:1,y:.4},{x:.8,y:1},{x:.2,y:1},{x:0,y:.4}];e.anchors=t.map(({x:i,y:s},r)=>({id:`${r}`,penId:e.id,x:i,y:s}))}function Dn(e,t){e.onResize||(e.onResize=On);const i=t||new Path2D,{width:s,height:r,center:a}=e.calculative.worldRect,o=s>r?r:s,l=a.x,n=a.y,h=n-o/2,c=n-o/4,f=-(c-n)*Math.sin(Math.PI/180*324)+l,u=(c-n)*Math.cos(Math.PI/180*324)+n;i.moveTo(f,u);for(let d=0;d<5;++d)i.lineTo(-(h-n)*Math.sin(Math.PI/180*72*d)+l,(h-n)*Math.cos(Math.PI/180*72*d)+n),i.lineTo((f-l)*Math.cos(Math.PI/180*72*(d+1))-(u-n)*Math.sin(Math.PI/180*72*(d+1))+l,(f-l)*Math.sin(Math.PI/180*72*(d+1))+(u-n)*Math.cos(Math.PI/180*72*(d+1))+n);if(i.closePath(),i instanceof Path2D)return i}function Xr(e){const{width:t,height:i}=e,s=t>i?i:t,r=[];for(let a=0;a<5;++a)r.push({flag:1,id:String(a),penId:e.id,x:.5+s/2*Math.sin(Math.PI/180*72*a)/t,y:-s/2*Math.cos(Math.PI/180*72*a)/i+.5});e.anchors=r}function On(e){const t=e.anchors.filter(i=>i.flag!==1);Xr(e),e.anchors=e.anchors.concat(...t)}function Bn(e,t){const i=t||new Path2D,{x:s,y:r,width:a,height:o}=e.calculative.worldRect;if(i.moveTo(s+a/4,r),i.lineTo(s+a*3/4,r),i.lineTo(s+a,r+o/2),i.lineTo(s+a*3/4,r+o),i.lineTo(s+a*1/4,r+o),i.lineTo(s,r+o/2),i.lineTo(s+a/4,r),i.closePath(),i instanceof Path2D)return i}function Nn(e,t){const i=t||new Path2D,{x:s,y:r,width:a,height:o}=e.calculative.worldRect;if(i.moveTo(s,r+o/2),i.lineTo(s+o/2,r),i.lineTo(s+o/2,r+o/3),i.lineTo(s+a,r+o/3),i.lineTo(s+a,r+o*2/3),i.lineTo(s+o/2,r+o*2/3),i.lineTo(s+o/2,r+o*2/3),i.lineTo(s+o/2,r+o),i.closePath(),i instanceof Path2D)return i}function Fn(e,t){const i=t||new Path2D,{x:s,y:r,width:a,height:o}=e.calculative.worldRect;if(i.moveTo(s,r+o/3),i.lineTo(s+(a-o/2),r+o/3),i.lineTo(s+(a-o/2),r),i.lineTo(s+a,r+o/2),i.lineTo(s+(a-o/2),r+o),i.lineTo(s+(a-o/2),r+o*2/3),i.lineTo(s,r+o*2/3),i.closePath(),i instanceof Path2D)return i}function zn(e,t){const i=t||new Path2D,{x:s,y:r,width:a,height:o}=e.calculative.worldRect;if(i.moveTo(s,r+o/2),i.lineTo(s+o/2,r),i.lineTo(s+o/2,r+o/3),i.lineTo(s+(a-o/2),r+o/3),i.lineTo(s+(a-o/2),r),i.lineTo(s+a,r+o/2),i.lineTo(s+(a-o/2),r+o),i.lineTo(s+(a-o/2),r+o*2/3),i.lineTo(s+o/2,r+o*2/3),i.lineTo(s+o/2,r+o),i.closePath(),i instanceof Path2D)return i}function jn(e,t){const i=t||new Path2D,{x:s,y:r,width:a,height:o,ey:l}=e.calculative.worldRect;if(i.moveTo(s,r),i.lineTo(s+a,r),i.lineTo(s+a,r+o*3/4),i.lineTo(s+a*8/16,r+o*3/4),i.lineTo(s+a/4,l),i.lineTo(s+a*5/16,r+o*3/4),i.lineTo(s,r+o*3/4),i.closePath(),i instanceof Path2D)return i}function Wn(e,t){const i=t||new Path2D,{x:s,y:r,width:a,height:o}=e.calculative.worldRect;if(i.moveTo(s+a/5,r+o*13/16),i.bezierCurveTo(s-a/15,r+o*13/16,s-a/15,r+o*7/16,s+a/5,r+o*7/16),i.bezierCurveTo(s+a/5,r,s+a*4/5,r,s+a*4/5,r+o*7/16),i.bezierCurveTo(s+a*16/15,r+o*7/16,s+a*16/15,r+o*13/16,s+a*4/5,r+o*13/16),i.closePath(),i instanceof Path2D)return i}function Hn(e,t){const i=t||new Path2D,{x:s,y:r,width:a,ex:o,ey:l}=e.calculative.worldRect,n=a/6;if(i.moveTo(s,r),i.lineTo(o-n,r),i.lineTo(o,r+n),i.lineTo(o,l),i.lineTo(s,l),i.closePath(),i.moveTo(o-n,r),i.lineTo(o-n,r+n),i.lineTo(o,r+n),i.closePath(),i instanceof Path2D)return i}function Vn(e,t){const{x:i,y:s,width:r,ex:a,ey:o}=t.calculative.worldRect;let l=r*.25;const n=t.z;n>1?l=n*t.calculative.canvas.store.data.scale:n>0&&(l=r*n);const h={x:i,y:s+l},c={x:a-l,y:s+l},f={x:a-l,y:o};Wi(e,[h,c,f,{x:i,y:o}],t.backgroundFront||t.background,t.color),Wi(e,[h,{x:i+l,y:s},{x:a,y:s},c],t.backgroundUp||t.background,t.color),Wi(e,[c,{x:a,y:s},{x:a,y:o-l},f],t.backgroundRight||t.background,t.color)}function Wi(e,t,i="",s=""){e.save(),i&&(e.fillStyle=i),s&&(e.strokeStyle=s),e.beginPath();for(let r=0;r<t.length;++r)r?e.lineTo(t[r].x,t[r].y):e.moveTo(t[r].x,t[r].y);e.closePath(),i&&e.fill(),e.stroke(),e.restore()}function Un(e,t){const i=t||new Path2D,{x:s,y:r,width:a,ex:o,ey:l}=e.calculative.worldRect,n=a/4,h=s+a/2;if(i.arc(h,r+n,n,0,Math.PI*2),i.moveTo(s,r+n*3),i.lineTo(o,r+n*3),i.moveTo(h,r+n*2),i.lineTo(h,r+n*4),i.moveTo(h,r+n*4),i.lineTo(s,l),i.moveTo(h,r+n*4),i.lineTo(o,l),i.closePath(),i instanceof Path2D)return i}let Dt=10;function qn(e,t,i){var g;if(t.calculative.worldAnchors||(t.calculative.worldAnchors=[]),Dt=e.options.polylineSpace||10,t.calculative.worldAnchors.length<2)return;let s=xt(t),r=dt(t);if(!s||!r)return;let a;if((g=t.anchors)!=null&&g.length&&s===t.calculative.activeAnchor?(a=!0,s=r,r=xt(t)):(!t.anchors||!t.anchors.length)&&s!==t.calculative.activeAnchor&&(s=t.calculative.activeAnchor),!s||!r)return;s.next=void 0,r.prev=void 0;const o=r.connectTo;ds(t);const l=[],n=e.pens[s.connectTo],h=e.pens[r.connectTo],c=Oe(s,n),f=Oe(r,h);let u=Qs(s,c,Dt);u&&(s=u,l.push(u)),u=Qs(r,f,Dt);const d=r;let v;if(u&&(r=u,d.connectTo&&(u.y>d.y&&s.y<d.y||u.y<d.y&&s.y>d.y))){v=u;let y=Dt;s.x<u.x&&(y=-y),Math.abs(s.x-u.x)<y&&(y=-y),r={x:u.x+y,y:u.y,id:lt()}}switch(c){case nt.Up:l.push(...$n(s,r,f));break;case nt.Right:l.push(...Yn(s,r,f));break;case nt.Bottom:l.push(...Xn(s,r,f));break;case nt.Left:l.push(...Kn(s,r,f));break;default:l.push(...Gn(t,s,r));break}if(l.forEach(y=>{y.id=lt(),y.penId=t.id,t.calculative.worldAnchors.push(y)}),t.calculative.worldAnchors.push(r),v&&t.calculative.worldAnchors.push(v),u&&t.calculative.worldAnchors.push(d),a&&t.calculative.worldAnchors.reverse(),o){const y=t.calculative.worldAnchors.length-2;t.calculative.worldAnchors[y].isTemp=!1,t.calculative.worldAnchors[1].isTemp=!1}}function Qs(e,t,i){const s={x:e.x,y:e.y,id:lt()};switch(t){case nt.Up:s.y-=i;break;case nt.Right:s.x+=i;break;case nt.Bottom:s.y+=i;break;case nt.Left:s.x-=i;break;default:return}return s}function $n(e,t,i){if(e.x===t.x||e.y===t.y)return[];const s=[];let r,a;switch(i){case nt.Up:e.y<t.y?(r=t.x,a=e.y):(r=e.x,a=t.y),s.push({x:r,y:a});break;case nt.Bottom:if(r=t.x,a=e.y,t.y>e.y)r=e.x+(t.x-e.x)/2,s.push({x:r,y:e.y},{x:r,y:t.y});else{const o=(e.y+t.y)/2;s.push({x:e.x,y:o},{x:t.x,y:o})}break;case nt.Right:r=t.x,a=e.y,t.x<e.x&&t.y<e.y&&(r=e.x,a=t.y),s.push({x:r,y:a});break;case nt.Left:r=t.x,a=e.y,t.x>e.x&&t.y<e.y&&(r=e.x,a=t.y),s.push({x:r,y:a});break;default:if(t.y>e.y-Dt)r=e.x+(t.x-e.x)/2,s.push({x:r,y:e.y},{x:r,y:t.y});else{const o=(e.y+t.y+Dt)/2;s.push({x:e.x,y:o},{x:t.x,y:o})}break}return s}function Yn(e,t,i){if(e.x===t.x||e.y===t.y)return[];const s=[];let r,a;switch(i){case nt.Up:r=e.x,a=t.y,t.x>e.x&&t.y>e.y&&(r=t.x,a=e.y),s.push({x:r,y:a});break;case nt.Bottom:r=e.x,a=t.y,t.x>e.x&&t.y<e.y&&(r=t.x,a=e.y),s.push({x:r,y:a});break;case nt.Left:if(r=t.x,a=e.y,t.x<e.x)a=e.y+(t.y-e.y)/2,s.push({x:e.x,y:a},{x:t.x,y:a});else{const o=(e.x+t.x)/2;s.push({x:o,y:a},{x:o,y:t.y})}break;case nt.Right:t.x<e.x?s.push({x:e.x,y:t.y}):s.push({x:t.x,y:e.y});break;default:if(r=t.x,a=t.y,t.x<e.x+Dt)s.push({x:e.x,y:a});else{const o=(e.x+t.x-Dt)/2;s.push({x:o,y:e.y},{x:o,y:a})}break}return s}function Xn(e,t,i){if(e.x===t.x||e.y===t.y)return[];const s=[];let r,a;switch(i){case nt.Up:if(r=e.x,a=t.y,t.y<e.y)r=e.x+(t.x-e.x)/2,s.push({x:r,y:e.y},{x:r,y:t.y});else{const o=(e.y+t.y)/2;s.push({x:r,y:o},{x:t.x,y:o})}break;case nt.Right:r=t.x,a=e.y,t.x<e.x&&t.y>e.y&&(r=e.x,a=t.y),s.push({x:r,y:a});break;case nt.Bottom:e.y>t.y?(r=t.x,a=e.y):(r=e.x,a=t.y),s.push({x:r,y:a});break;case nt.Left:r=t.x,a=e.y,t.x>e.x&&t.y>e.y&&(r=e.x,a=t.y),s.push({x:r,y:a});break;default:if(r=e.x,t.y<e.y+Dt)r=e.x+(t.x-e.x)/2,s.push({x:r,y:e.y},{x:r,y:t.y});else{const o=(e.y+t.y-Dt)/2;s.push({x:r,y:o},{x:t.x,y:o})}break}return s}function Kn(e,t,i){if(e.x===t.x||e.y===t.y)return[];const s=[];let r,a;switch(i){case nt.Up:r=e.x,a=t.y,t.x<e.x&&t.y>e.y&&(r=t.x,a=e.y),s.push({x:r,y:a});break;case nt.Bottom:r=e.x,a=t.y,t.x<e.x&&t.y<e.y&&(r=t.x,a=e.y),s.push({x:r,y:a});break;case nt.Right:if(r=e.x,a=t.y,t.x>e.x)r=t.x,a=e.y+(t.y-e.y)/2,s.push({x:e.x,y:a},{x:t.x,y:a});else{const o=(e.x+t.x)/2;s.push({x:o,y:e.y},{x:o,y:t.y})}break;case nt.Left:t.x>e.x?s.push({x:e.x,y:t.y}):s.push({x:t.x,y:e.y});break;default:if(r=e.x,a=t.y,t.x<e.x-Dt){const o=(e.x+t.x+Dt)/2;s.push({x:o,y:e.y},{x:o,y:a})}else s.push({x:e.x,y:a});break}return s}function Gn(e,t,i){const s=[];e.calculative.drawlineH==null&&(e.calculative.drawlineH=Math.abs(i.x-t.x)>Math.abs(i.y-t.y));let r=e.calculative.worldAnchors.findIndex(a=>a.id==t.id);if(r>1){let a=e.calculative.worldAnchors[r-1];if(a.x===t.x&&a.y!==t.y)return s.push({x:i.x,y:t.y}),s;if(a.y===t.y&&a.x!==t.x)return s.push({x:t.x,y:i.y}),s}return e.calculative.worldAnchors.length&&(i.isTemp=void 0,e.calculative.drawlineH?(s.push({x:i.x,y:t.y}),Math.abs(i.y-t.y)<Dt&&(i.isTemp=!0)):(s.push({x:t.x,y:i.y}),Math.abs(i.x-t.x)<Dt&&(i.isTemp=!0))),s}function oi(e,t,i=!0){var r,a;let s=e.calculative.worldAnchors;i||(s=[],e.calculative.worldAnchors.forEach(o=>{s.unshift(o)}));for(let o=0;o<s.length&&s[o].id!==t.id;o++)if(s[o].y!==t.y||s[o].x===((r=s[o+1])==null?void 0:r.x)&&s[o].y!==((a=s[o+1])==null?void 0:a.y))return!1;return!0}function ni(e,t,i=!0){var r,a;let s=e.calculative.worldAnchors;i||(s=[],e.calculative.worldAnchors.forEach(o=>{s.unshift(o)}));for(let o=0;o<s.length&&s[o].id!==t.id;o++)if(s[o].x!==t.x||s[o].y===((r=s[o+1])==null?void 0:r.y)&&s[o].x!==((a=s[o+1])==null?void 0:a.x))return!1;return!0}function Jn(e,t,i){if(!e.calculative.worldAnchors)return;const s=e.calculative.worldAnchors.findIndex(n=>n.id===t.id),r=xt(e),a=dt(e);let o=e.calculative.worldAnchors[s-1],l=e.calculative.worldAnchors[s+1];if(e.calculative.h==null&&(r.connectTo&&(oi(e,t,!0)?e.calculative.h=!0:ni(e,t,!0)&&(e.calculative.h=!1)),e.calculative.h==null&&a.connectTo&&(oi(e,t,!1)?e.calculative.h=!0:ni(e,t,!1)&&(e.calculative.h=!1)),e.calculative.h==null&&(o?e.calculative.h=o.y===t.y:l&&(e.calculative.h=l.y===t.y))),e.calculative.h){if(t.x=i.x,r.connectTo&&oi(e,t,!0)){l&&l.y!==t.y&&(l.x=t.x);return}if(a.connectTo&&oi(e,t,!1)){o&&o.y!==t.y&&(o.x=t.x);return}const n=e.anchors[s];let h;for(let c=s-1;c>-1;c--)if(o=e.anchors[c],h==null&&(h=o.y===n.y),h===!0)if(o.y===n.y)e.calculative.worldAnchors[c].y=i.y;else break;else if(o.x===n.x)e.calculative.worldAnchors[c].x=i.x;else break;h=void 0;for(let c=s+1;c<e.calculative.worldAnchors.length&&(l=e.anchors[c],l);c++)if(h==null&&(h=l.y===n.y),h===!0)if(l.y===n.y)e.calculative.worldAnchors[c].y=i.y;else break;else if(l.x===n.x)e.calculative.worldAnchors[c].x=i.x;else break;t.y=i.y}else{if(t.y=i.y,r.connectTo&&ni(e,t,!0)){l&&l.x!==t.x&&(l.y=t.y);return}if(a.connectTo&&ni(e,t,!1)){o&&o.x!==t.x&&(o.y=t.y);return}const n=e.anchors[s];let h;for(let c=s-1;c>-1;c--)if(o=e.anchors[c],h==null&&(h=o.x===n.x),h===!0)if(o.x===n.x)e.calculative.worldAnchors[c].x=i.x;else break;else if(o.y===n.y)e.calculative.worldAnchors[c].y=i.y;else break;h=void 0;for(let c=s+1;c<e.calculative.worldAnchors.length&&(l=e.anchors[c],l);c++)if(h==null&&(h=l.x===n.x),h===!0)if(l.x===n.x)e.calculative.worldAnchors[c].x=i.x;else break;else if(l.y===n.y)e.calculative.worldAnchors[c].y=i.y;else break;t.x=i.x}}function ts(e,t,i,s){const r=[];let a,o,l,n,h,c,f,u,d,v,g,y,p,b;d=e[i],v=e[s],l=d.x,n=d.y,f=v.x-l,u=v.y-n,b=f*f+u*u,a=t;for(let m=i+1;m<s;m++)g=e[m],f!==0||u!==0?(y=((g.x-l)*f+(g.y-n)*u)/b,y>1?(h=g.x-v.x,c=g.y-v.y):y>0?(h=g.x-(l+f*y),c=g.y-(n+u*y)):(h=g.x-l,c=g.y-n)):(h=g.x-l,c=g.y-n),p=h*h+c*c,p>a&&(o=m,a=p);return a>t&&(o-i>1&&r.push(...ts(e,t,i,o)),r.push({id:e[o].id,penId:e[o].penId,x:e[o].x,y:e[o].y}),s-o>1&&r.push(...ts(e,t,o,s))),r}function Qn(e,t=.8,i=!1){if(e.length<3)return e;let s,r,a,o,l,n,h,c,f,u,d,v,g,y,p;const b=(m,k,A,S)=>(o=Math.sqrt(m*m+k*k),o>0?(v=m/o,y=k/o):(v=1,y=0),l=Math.sqrt(A*A+S*S),l>0?(g=A/l,p=S/l):(g=1,p=0),Math.acos(v*g+y*p));u=[],d=e.length,s=e[0],e[d-1],u.push({...e[0]});for(let m=0;m<d-1;m++){if(r=e[m],a=e[m+1],f=Math.abs(b(r.x-s.x,r.y-s.y,a.x-r.x,a.y-r.y)),o)if(f<t*3.14)if(i&&(o=Math.min(o,l),l=o),n=(v+g)/2,h=(y+p)/2,c=Math.sqrt(n*n+h*h),c===0)u.push({...r});else{n/=c,h/=c;const k={...r};k.prevNextType=pe.Bilateral,k.prev={penId:k.penId,x:r.x-n*o*.25,y:r.y-h*o*.25},k.next={penId:k.penId,x:r.x+n*l*.25,y:r.y+h*l*.25},u.push(k)}else u.push({...r});s=r}return u.push({...e[e.length-1]}),u}function Kr(e,t){const i=t||new Path2D;let s=e.calculative.worldAnchors,r=e.calculative.canvas.store.data.scale,a=(e.calculative.animateLineWidth||6)*r,o=(e.animateLineWidth*2||12)*r;e.lineAnimateType===pt.WaterDrop&&(o=(e.animateLineWidth*4||24)*r);let l=(e.animateInterval||100)*r,n=e.calculative.lineWidth*(e.calculative.lineSmooth||0),h=(e.calculative.animateLineWidth/2||3)*r;if(e.animateReverse&&(o=-o,a=-a),s.length>1){let c,f=0;if(e.close&&(s=K(s),s.push(s[0])),["polyline","line"].includes(e.lineName))for(let u=0;u<s.length;u++){let d=s[u];if(c){let v=je(c,d),g={x:c.x+(e.calculative.animatePos-f)%l*Math.cos(v*Math.PI/180),y:c.y-(e.calculative.animatePos-f)%l*Math.sin(v*Math.PI/180)};e.animateReverse&&(g={x:c.x+(e.length-(e.calculative.animatePos+f))%l*Math.cos(v*Math.PI/180),y:c.y-(e.length-(e.calculative.animatePos+f))%l*Math.sin(v*Math.PI/180)});let y=Math.sqrt((g.x-c.x)**2+(g.y-c.y)**2),p=Math.sqrt((d.x-c.x)**2+(d.y-c.y)**2);for(;y<p;)(e.animateReverse&&y-o<p||!e.animateReverse&&y>o)&&y>n+o&&p-y>n&&(e.lineAnimateType===pt.Arrow?We(i,g,a,v,h,o):e.lineAnimateType===pt.WaterDrop&&He(i,g,e.animateReverse,v,h,o)),g.x+=l*Math.cos(v*Math.PI/180),g.y-=l*Math.sin(v*Math.PI/180),y=Math.sqrt((g.x-c.x)**2+(g.y-c.y)**2)}c=d}else{let u,d=e.calculative.animatePos%l/l;d>1&&(d=1),e.animateReverse&&(d=1-d);let v=1/(s[0].lineLength/l),g=d*v,y;s.forEach(p=>{let b=p;if(u)if(v=1/(u.lineLength/l),u.next)if(b.prev)for(y=g;y<1;y+=v){let m=Ci(y,u,u.next,b.prev,b),k=Ci(y+.001,u,u.next,b.prev,b),A=je(m,k);e.lineAnimateType===pt.Arrow?We(i,m,a,A,h,o):e.lineAnimateType===pt.WaterDrop&&He(i,m,e.animateReverse,A,h,o)}else for(y=g;y<1;y+=v){let m=ge(y,u,u.next,b),k=ge(y+.001,u,u.next,b),A=je(m,k);e.lineAnimateType===pt.Arrow?We(i,m,a,A,h,o):e.lineAnimateType===pt.WaterDrop&&He(i,m,e.animateReverse,A,h,o)}else if(b.prev)for(y=g;y<1;y+=v){let m=ge(y,u,b.prev,b),k=ge(y+.001,u,b.prev,b),A=je(m,k);e.lineAnimateType===pt.Arrow?We(i,m,a,A,h,o):e.lineAnimateType===pt.WaterDrop&&He(i,m,e.animateReverse,A,h,o)}else{let m=je(u,b);for(y=g;y<1;y+=v){let k={x:u.x+(b.x-u.x)*y,y:u.y+(b.y-u.y)*y};e.lineAnimateType===pt.Arrow?We(i,k,a,m,h,o):e.lineAnimateType===pt.WaterDrop&&He(i,k,e.animateReverse,m,h,o)}}u=p,y?g=y-1:y=g})}}if(i instanceof Path2D)return i}function je(e,t){let i=t.x-e.x,s=t.y-e.y,r=Math.atan(s/i)*180/Math.PI;return t.x>=e.x?r=-r:r=180-r,r}function he(e,t,i){let s=(180-i)*Math.PI/180;return{x:(e.x-t.x)*Math.cos(s)-(e.y-t.y)*Math.sin(s)+t.x,y:(e.x-t.x)*Math.sin(s)+(e.y-t.y)*Math.cos(s)+t.y}}function We(e,t,i,s,r,a){let o=he({x:t.x+i,y:t.y+.57*i},{x:t.x,y:t.y},s),l=he({x:t.x+i,y:t.y-.57*i},{x:t.x,y:t.y},s),n=he({x:t.x+i,y:t.y+r/2},{x:t.x,y:t.y},s),h=he({x:t.x+a,y:t.y+r/2},{x:t.x,y:t.y},s),c=he({x:t.x+i,y:t.y-r/2},{x:t.x,y:t.y},s),f=he({x:t.x+a,y:t.y-r/2},{x:t.x,y:t.y},s);e.moveTo(o.x,o.y),e.lineTo(t.x,t.y),e.lineTo(l.x,l.y),e.lineTo(c.x,c.y),e.lineTo(f.x,f.y),e.lineTo(h.x,h.y),e.lineTo(n.x,n.y),e.lineTo(o.x,o.y)}function He(e,t,i,s,r,a){let o=r/2;i&&(o=-r/2);let l=he({x:t.x,y:t.y+o},{x:t.x,y:t.y},s),n=he({x:t.x+a,y:t.y},{x:t.x,y:t.y},s),h=Math.PI/2;i&&(h=-Math.PI/2),e.moveTo(t.x,t.y),e.arc(t.x,t.y,r/2,-h-s/180*Math.PI,h-s/180*Math.PI,!1),e.lineTo(n.x,n.y),e.lineTo(l.x,l.y)}const ae={};function Zn(){var e;for(const t in ae)(e=ae[t])==null||e.remove(),delete ae[t]}function tl(e){var t;for(const i in ae)e.some(s=>s.name=="iframe"&&s.iframe==i)||((t=ae[i])==null||t.remove(),delete ae[i])}function el(e){const t=ae[e.iframe];return t?(e.calculative.singleton.div=t,ys(e),!0):!1}function il(e){var i;e.onDestroy||(e.onDestroy=sl,e.onMove=li,e.onResize=li,e.onRotate=li,e.onValue=li,e.onMouseMove=al,e.onBeforeValue=rl,e.onRenderPenRaw=nl),e.calculative.singleton||(e.calculative.singleton={});const t=e.calculative.worldRect;if(!e.calculative.singleton.div){if(el(e))return;const s=document.createElement("div");s.style.position="absolute",s.style.outline="none",s.style.left="-9999px",s.style.top="-9999px",s.style.width=t.width+"px",s.style.height=t.height+"px",(i=e.calculative.canvas.externalElements)==null||i.parentElement.appendChild(s),Ct(e,s),e.calculative.singleton.div=s;const r=document.createElement("iframe");r.style.width="100%",r.style.height="100%",r.scrolling=e.scrolling||"no",r.frameBorder="0",r.style.border="none",r.src=e.iframe,r.allowFullscreen=!0,e.calculative.iframe=e.iframe,s.appendChild(r),ys(e)}return e.calculative.patchFlags&&Ct(e,e.calculative.singleton.div),e.onRenderPenRaw(e),new Path2D}function sl(e){Jr(e),e.calculative.singleton&&e.calculative.singleton.div&&(e.calculative.canvas.store.data.locked?(ae[e.calculative.iframe]=e.calculative.singleton.div,delete e.calculative.singleton.div):(e.calculative.singleton.div.remove(),ae[e.calculative.iframe]=null))}function li(e){e.calculative.singleton.div&&Ct(e,e.calculative.singleton.div)}function rl(e,t){if(t.iframe&&e.calculative.singleton.div&&(e.calculative.singleton.div.children[0].src=t.iframe,e.calculative.iframe=t.iframe),t.operationalRect||t["operationalRect.x"]!==void 0||t["operationalRect.y"]!==void 0||t["operationalRect.width"]!==void 0||t["operationalRect.height"]!==void 0){e.operationalRect||(e.operationalRect={});let i=K(t);i.operationalRect||(i.operationalRect={}),i["operationalRect.x"]!==void 0&&(i.operationalRect.x=i["operationalRect.x"]),i["operationalRect.y"]!==void 0&&(i.operationalRect.y=i["operationalRect.y"]),i["operationalRect.width"]!==void 0&&(i.operationalRect.width=i["operationalRect.width"]),i["operationalRect.height"]!==void 0&&(i.operationalRect.height=i["operationalRect.height"]),Object.assign(e.operationalRect,i.operationalRect),e.calculative.singleton.div&&(e.calculative.singleton.div.children.length===1?ys(e):(e.calculative.singleton.div.children[1].style.height=e.operationalRect.y*100+"%",e.calculative.singleton.div.children[1].style.left=e.operationalRect.x*100+"%",e.calculative.singleton.div.children[1].style.width=e.operationalRect.width*100+"%",e.calculative.singleton.div.children[2].style.width=(1-e.operationalRect.x-e.operationalRect.width)*100+"%",e.calculative.singleton.div.children[3].style.height=(1-e.operationalRect.y-e.operationalRect.height)*100+"%",e.calculative.singleton.div.children[3].style.left=e.operationalRect.x*100+"%",e.calculative.singleton.div.children[3].style.width=e.operationalRect.width*100+"%",e.calculative.singleton.div.children[4].style.width=e.operationalRect.x*100+"%"))}if(t.blur!==void 0)for(let i=1;i<5;i++)e.calculative.singleton.div.children[i]&&(e.calculative.singleton.div.children[i].style["backdrop-filter"]=`blur(${t.blur}px)`);if(t.blurBackground!==void 0)for(let i=1;i<5;i++)e.calculative.singleton.div.children[i]&&(e.calculative.singleton.div.children[i].style.backgroundColor=t.blurBackground);return t}function al(e,t){if(!(!e.calculative.canvas.store.data.locked&&!e.locked)&&Gr(e.operationalRect)&&e.calculative.zIndex<5&&t.x>e.x+e.width*e.operationalRect.x&&t.x<e.x+e.width*(e.operationalRect.x+e.operationalRect.width)&&t.y>e.y+e.height*e.operationalRect.y&&t.y<e.y+e.height*(e.operationalRect.y+e.operationalRect.height)&&e.calculative.singleton.div){let i=e.calculative.singleton.div.parentNode.children;for(let s=0;s<6;s++)i[s].style.pointerEvents="none"}}function Gr(e){return e?!e.width||!e.height?!1:(e.x===void 0&&(e.x=(1-e.width)/2),e.y===void 0&&(e.y=(1-e.height)/2),!0):!1}function ol(e){for(;e.childNodes.length>1;)e.removeChild(e.lastChild)}function ys(e){if(!Gr(e.operationalRect))return;const t=e.calculative.singleton.div;if(!t)return;t.childNodes.length>1&&ol(t);const i=navigator.userAgent.indexOf("Linux")>-1,s=document.createElement("div");s.style.position="absolute",s.style.left=e.operationalRect.x*100+"%",s.style.top="0px",s.style.width=e.operationalRect.width*100+"%",s.style.height=e.operationalRect.y*100+"%",!i&&e.blur&&(s.style["backdrop-filter"]=`blur(${e.blur}px)`),s.style.backgroundColor=e.blurBackground,t.appendChild(s);const r=document.createElement("div");r.style.position="absolute",r.style.right="0px",r.style.top="0px",r.style.width=(1-e.operationalRect.x-e.operationalRect.width)*100+"%",r.style.height="100%",!i&&e.blur&&(r.style["backdrop-filter"]=`blur(${e.blur}px)`),r.style.backgroundColor=e.blurBackground,t.appendChild(r);const a=document.createElement("div");a.style.position="absolute",a.style.left=e.operationalRect.x*100+"%",a.style.bottom="0px",a.style.width=e.operationalRect.width*100+"%",a.style.height=(1-e.operationalRect.y-e.operationalRect.height)*100+"%",!i&&e.blur&&(a.style["backdrop-filter"]=`blur(${e.blur}px)`),a.style.backgroundColor=e.blurBackground,t.appendChild(a);const o=document.createElement("div");o.style.position="absolute",o.style.left="0px",o.style.top="0px",o.style.width=e.operationalRect.x*100+"%",o.style.height="100%",!i&&e.blur&&(o.style["backdrop-filter"]=`blur(${e.blur}px)`),o.style.backgroundColor=e.blurBackground,t.appendChild(o);let l=()=>{Jr(e)};s.onmouseenter=l,a.onmouseenter=l,r.onmouseenter=l,o.onmouseenter=l,t.onmouseleave=l}function Jr(e){if(!(!e.calculative.canvas.store.data.locked&&!e.locked)&&e.calculative.zIndex<5){let t=e.calculative.singleton.div.parentNode.children;for(let i=1;i<6;i++)t[i].style.pointerEvents="initial"}}function nl(e){if(e.thumbImg&&!e.calculative.img){const t=new Image;t.crossOrigin=e.crossOrigin==="undefined"?void 0:e.crossOrigin||e.calculative.canvas.store.options.crossOrigin||"anonymous",e.calculative.canvas.store.options.cdn&&!(e.thumbImg.startsWith("http")||e.thumbImg.startsWith("//")||e.thumbImg.startsWith("data:image"))?t.src=e.calculative.canvas.store.options.cdn+e.thumbImg:t.src=e.thumbImg,t.onerror=i=>{t.remove(),e.calculative.img=void 0},e.calculative.img=t}}const Ot={},vi=['<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M473.088 125.44L256 256H52.224C23.552 256 0 279.552 0 308.224V716.8c0 28.16 23.04 51.2 51.2 51.2h204.8l217.088 130.56c16.896 10.24 38.912-2.048 38.912-22.016V147.456c0-19.968-21.504-32.256-38.912-22.016zM699.904 320.512c-20.992-18.944-53.248-17.408-72.192 3.584-18.944 20.992-17.408 53.248 3.584 72.192 0.512 0.512 58.368 54.784 58.368 121.344 0 37.888-19.456 74.752-58.368 110.08-20.992 18.944-22.528 51.2-3.584 72.192 10.24 11.264 24.064 16.896 37.888 16.896 12.288 0 24.576-4.608 34.304-13.312 61.44-55.296 92.16-117.76 92.16-185.856 0-112.64-88.576-193.536-92.16-197.12z" fill="" p-id="2434"></path><path d="M853.504 166.4c-20.992-18.944-53.248-16.896-72.192 4.096-18.944 20.992-16.896 53.248 4.096 72.192 1.536 1.024 135.68 122.88 135.68 280.576 0 90.624-45.568 177.152-135.68 257.536-20.992 18.944-23.04 51.2-4.096 72.192 10.24 11.264 24.064 16.896 38.4 16.896 12.288 0 24.576-4.096 34.304-12.8 112.64-100.864 169.984-212.992 169.984-333.824-1.024-202.752-163.84-350.208-170.496-356.864z"></path></svg>','<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" ><path d="M256 768H51.2c-28.16 0-51.2-23.04-51.2-51.2V308.224C0 279.552 23.552 256 52.224 256H256v512zM512 147.456v728.576c0 19.968-21.504 32.256-38.912 22.016L256 768V256l217.088-130.56c17.408-10.24 38.912 2.048 38.912 22.016zM623.104 656.896c-19.968-19.968-19.968-52.224 0-72.192l217.088-217.088c19.968-19.968 52.224-19.968 72.192 0 19.968 19.968 19.968 52.224 0 72.192l-217.088 217.088c-19.456 19.968-52.224 19.968-72.192 0z" fill="" p-id="2582"></path><path d="M623.104 367.104c19.968-19.968 52.224-19.968 72.192 0l217.088 217.088c19.968 19.968 19.968 52.224 0 72.192-19.968 19.968-52.224 19.968-72.192 0l-217.088-217.088c-19.968-19.456-19.968-52.224 0-72.192z"></path></svg>'];function ll(e){var t;if(e.onDestroy||(e.onDestroy=cl,e.onMove=Hi,e.onResize=Hi,e.onRotate=Hi,e.onClick=Zs,e.onValue=ul,e.onChangeId=hl),Ot[e.id])e.video&&e.calculative.media&&e.video!==e.calculative.video?(console.warn("video 更改, 此处是否执行?"),e.calculative.media.src=e.video,e.autoPlay&&(e.calculative.media.muted=!0,e.calculative.media.autoplay=!0),e.calculative.media.loop=e.playLoop,e.calculative.video=e.video):e.audio&&e.calculative.media&&e.audio!==e.calculative.audio&&(e.calculative.media.src=e.audio,e.autoPlay&&(e.calculative.media.muted=!0,e.calculative.media.autoplay=!0),e.calculative.media.loop=e.playLoop,e.calculative.audio=e.audio);else{const i=document.createElement("div"),s=document.createElement("div");s.style.position="absolute",s.style.outline="none",s.style.left="0",s.style.bottom="0",s.style.width="0",s.style.height="2px",s.style.background="#52c41a",s.style.zIndex="1",e.hideProgress&&(s.style.display="none");const r=document.createElement("div");r.innerHTML=vi[1],r.style.position="absolute",r.style.right="0",r.style.bottom="0",r.style.width="20px",r.style.height="20px",r.style.fill="hsla(0, 0%, 100%, .8)",r.style.zIndex="1",r.style.display="none",i.appendChild(s),i.appendChild(r),r.onclick=o=>{o.stopPropagation(),e.calculative.media.muted?(r.innerHTML=vi[0],e.calculative.media.muted=!1):(r.innerHTML=vi[1],e.calculative.media.muted=!0)},e.calculative.singleton||(e.calculative.singleton={div:i}),e.calculative.singleton.muted=r,i.onmouseenter=o=>{e.hideMuted||(r.style.display="block")},i.onmouseleave=o=>{r.style.display="none"},i.onclick=o=>{o.stopPropagation(),Zs(e)};let a;e.audio?(a=document.createElement("audio"),a.controls=e.controls,a.src=e.audio):(a=document.createElement("video"),a.src=e.video,a.crossOrigin=e.crossOrigin||"anonymous",e.calculative.img=a),a.loop=e.playLoop,a.ontimeupdate=()=>{Qr(s,a,e.calculative.worldRect.width)},a.onended=()=>{e.calculative.onended&&e.calculative.onended(e)},e.calculative.media=a,a.style.position="absolute",a.style.outline="none",a.style.left="0",a.style.top="0",a.style.width="100%",a.style.height="100%",a.style.objectFit=e.objectFit||"contain",i.appendChild(a),Ot[e.id]=i,(t=e.calculative.canvas.externalElements)==null||t.parentElement.appendChild(i),Ct(e,i),e.autoPlay&&(a.autoplay=!0,a.muted=!0)}return e.calculative.patchFlags&&Ct(e,Ot[e.id]),new Path2D}function cl(e){Ot[e.id].onclick=null,Ot[e.id].remove(),Ot[e.id]=void 0}function Hi(e){Ct(e,Ot[e.id]);const t=Ot[e.id].children[0],i=Ot[e.id].children[1];Qr(t,i,e.calculative.worldRect.width)}function Zs(e){e.calculative.media&&(e.calculative.media.muted=!1,e.calculative.singleton.muted.innerHTML=vi[0],e.calculative.media.paused?e.calculative.media.play():e.calculative.media.pause())}function Qr(e,t,i){e.style.width=t.currentTime/t.duration*i+"px"}function hl(e,t,i){Ot[t]&&(Ot[i]=Ot[t],delete Ot[t])}function ul(e){const t=Ot[e.id];if(!t)return;Ct(e,t),e.calculative.media||(e.calculative.media=t.querySelector("video"));const i=e.calculative.media.getAttribute("src");e.video?i!==e.video&&(e.calculative.media.src=e.video):e.audio&&i!==e.audio&&(e.calculative.media.src=e.audio),e.autoPlay&&(e.calculative.media.muted=!0,e.calculative.media.autoplay=!0),e.calculative.media.loop=e.playLoop}function Kt(){try{const e=new OffscreenCanvas(0,0),t=e.getContext("2d");return t&&t.arc?e:document.createElement("canvas")}catch{return document.createElement("canvas")}}class Ke{constructor(t,i){D(this,"parentElement");D(this,"store");D(this,"box");D(this,"text");D(this,"arrowUp");D(this,"arrowDown");D(this,"x");D(this,"y");D(this,"currentPen");this.parentElement=t,this.store=i,this.box=document.createElement("div"),this.text=document.createElement("div"),this.arrowUp=document.createElement("div"),this.arrowDown=document.createElement("div"),this.box.className="meta2d-tooltip",this.text.className="text",this.arrowUp.className="arrow",this.arrowDown.className="arrow down",this.box.appendChild(this.text),this.box.appendChild(this.arrowUp),this.box.appendChild(this.arrowDown),t.appendChild(this.box),this.box.onmouseleave=()=>{this.hide(),this.store.lastHover=void 0};let s;for(let r=0;r<document.styleSheets.length;r++)document.styleSheets[r].title==="le5le.com/tooltip"&&(s=document.styleSheets[r]);if(!s){let r=document.createElement("style");r.type="text/css",r.title="le5le.com/tooltip",document.head.appendChild(r),r=document.createElement("style"),r.type="text/css",document.head.appendChild(r),s=r.sheet,s.insertRule(".meta2d-tooltip{position:absolute;padding:8px 0;z-index:10;left: -9999px;top: -9999px;}"),s.insertRule(".meta2d-tooltip .text{max-width:320px;min-height:30px;max-height:400px;outline:none;padding:8px 16px;border-radius:4px;background:#777777;color:#ffffff;line-height:1.8;overflow-y:auto;}"),s.insertRule(".meta2d-tooltip .arrow{position:absolute;border:10px solid transparent;background:transparent;top:-5px;left:50%;transform:translateX(-50%)}"),s.insertRule(".meta2d-tooltip .arrow.down{top:initial;bottom: -1px;}")}}static getTitle(t){var i,s,r;if(t.titleFnJs&&!t.titleFn)try{t.titleFn=It((r=(s=(i=t.calculative)==null?void 0:i.canvas)==null?void 0:s.store)==null?void 0:r.options,"pen",t.titleFnJs)}catch(a){console.log("titleFnJs",a)}return t.titleFn?t.titleFn(t):String(t.title)}setText(t){const i=this.box.getBoundingClientRect();let s=globalThis.marked;const r=Ke.getTitle(t);if(s){this.text.innerHTML=s(r);const a=this.text.getElementsByTagName("A");for(let o=0;o<a.length;++o)a[o].setAttribute("target","_blank")}else this.text.innerHTML=r;return i}updateText(t){var r;if(((r=this.currentPen)==null?void 0:r.id)!==t.id||Ke.titleEmpty(t)||t.titleUnUpdate)return;const i=this.setText(t),s=this.box.getBoundingClientRect();this.changePositionByText(i,s)}changePositionByText(t,i){this.x-=(i.width-t.width)/2,this.y-=i.height-t.height,this.box.style.left=this.x+"px",this.box.style.top=this.y+"px"}static titleEmpty(t){return!t.title&&!t.titleFn&&!t.titleFnJs}show(t,i){if(this.currentPen=t,Ke.titleEmpty(t)){let l=Mt(t,!0);l&&this.show(l,i);return}this.setText(t);const s=this.box.getBoundingClientRect(),r=t.calculative.worldRect;let a=t.calculative.canvas.store.data.x+i.x-s.width/2,o=t.calculative.canvas.store.data.y+i.y-s.height;t.type||(a=t.calculative.canvas.store.data.x+r.x-(s.width-r.width)/2,o=t.calculative.canvas.store.data.y+r.ey-s.height-r.height),o>0?(this.arrowUp.style.borderBottomColor="transparent",this.arrowDown.style.borderTopColor="#777777"):(o+=s.height+r.height+5,this.arrowUp.style.borderBottomColor="#777777",this.arrowDown.style.borderTopColor="transparent"),this.x=a,this.y=o,this.box.style.left=this.x+"px",this.box.style.top=this.y+"px"}hide(){this.currentPen=null,this.x=-9999,this.box.style.left="-9999px"}translate(t,i){this.x<-1e3||(this.x+=t,this.y+=i,this.box.style.left=this.x+"px",this.box.style.top=this.y+"px")}destroy(){this.box.onmouseleave=null}}class Zr{constructor(t){D(this,"parent");D(this,"h");D(this,"v");D(this,"isDownH");D(this,"isDownV");D(this,"x");D(this,"y");D(this,"hSize");D(this,"vSize");D(this,"scrollX");D(this,"scrollY");D(this,"lastScrollX");D(this,"lastScrollY");D(this,"rect");D(this,"isShow");D(this,"isV");D(this,"padding");D(this,"pageMode");D(this,"onMouseDownH",t=>{t.preventDefault(),t.stopPropagation(),this.isDownH=t.x,this.x=this.parent.store.data.x||0,this.lastScrollX=this.scrollX});D(this,"onMouseDownV",t=>{t.preventDefault(),t.stopPropagation(),this.isDownV=t.y,this.y=this.parent.store.data.y||0,this.lastScrollY=this.scrollY});D(this,"onMouseMove",t=>{if(this.isDownH){const i=t.x-this.isDownH;this.scrollX=this.lastScrollX+i,this.h.style.left=`${this.scrollX}px`,this.parent.store.data.x=this.x-i*this.rect.width/this.parent.parentElement.clientWidth}if(this.isDownV){const i=t.y-this.isDownV;if(this.pageMode&&this.canMouseMove(i))return;this.scrollY=this.lastScrollY+i,this.v.style.top=`${this.scrollY}px`,this.isV?this.parent.store.data.y=this.y-i*this.isV.h/this.parent.parentElement.clientHeight:this.parent.store.data.y=this.y-i*this.rect.height/this.parent.parentElement.clientHeight}(this.isDownH||this.isDownV)&&(this.parent.onMovePens(),this.parent.canvasTemplate.init(),this.parent.canvasImage.init(),this.parent.canvasImageBottom.init(),this.parent.render())});D(this,"onMouseUp",t=>{!this.isDownH&&!this.isDownV||(this.isDownH=void 0,this.isDownV=void 0,!this.isV&&(this.scrollX<20?(this.scrollX=20,this.h.style.left=`${this.scrollX}px`):this.scrollX>this.parent.parentElement.clientWidth-this.hSize-20&&(this.scrollX=this.parent.parentElement.clientWidth-this.hSize-20,this.h.style.left=`${this.scrollX}px`),this.scrollY<20?(this.scrollY=20,this.v.style.top=`${this.scrollY}px`):this.scrollY>this.parent.parentElement.clientHeight-this.vSize-20&&(this.scrollY=this.parent.parentElement.clientHeight-this.vSize-20,this.v.style.top=`${this.scrollY}px`),this.resize()))});this.parent=t,this.h=document.createElement("div"),this.v=document.createElement("div"),this.parent.externalElements.appendChild(this.h),this.parent.externalElements.appendChild(this.v),this.h.className="meta2d-scroll h",this.h.onmousedown=this.onMouseDownH,this.v.className="meta2d-scroll v",this.v.onmousedown=this.onMouseDownV,document.addEventListener("mousemove",this.onMouseMove),document.addEventListener("mouseup",this.onMouseUp);let i;for(let s=0;s<document.styleSheets.length;s++)document.styleSheets[s].title==="le5le/scroll"&&(i=document.styleSheets[s]);if(!i){let s=document.createElement("style");s.type="text/css",s.title="le5le.com/scroll",document.head.appendChild(s),s=document.createElement("style"),s.type="text/css",document.head.appendChild(s),i=s.sheet,i.insertRule(".meta2d-scroll{position:absolute;width:8px;height:200px;background:#dddddd;border-radius:10px;z-index:20;cursor:default;}"),i.insertRule(".meta2d-scroll:hover{background:#cccccc;cursor:pointer}"),i.insertRule(".meta2d-scroll.v{right:0;top:calc(50% - 100px);}"),i.insertRule(".meta2d-scroll.h{bottom:2px;left:calc(50% - 100px);width:200px;height:8px;}")}this.init()}init(){this.isShow=!0,this.resize(),this.initPos(),this.getV()}getV(){const t=this.parent.store.data.width||this.parent.store.options.width,i=this.parent.store.data.height||this.parent.store.options.height;if(t&&i){const s=this.parent.store.data.scale;this.isV={w:t*s,h:i*s}}}canMouseMove(t){if(this.isV){let s=this.parent.store.data.origin;return t<0&&(Math.abs(s.y+this.parent.store.data.y-this.padding)<1||s.y+this.parent.store.data.y-this.padding>0)?(this.scrollY=0,this.v.style.top="0px",!0):t>0&&(Math.abs(s.y+this.isV.h-this.parent.height+this.parent.store.data.y-this.padding)<1||s.y+this.isV.h-this.parent.height+this.parent.store.data.y-this.padding<=0)?(this.parent.store.data.y=-(s.y+this.isV.h-this.parent.height+this.padding)-1,this.parent.onMovePens(),this.parent.canvasTemplate.init(),this.parent.canvasImage.init(),this.parent.canvasImageBottom.init(),this.parent.render(),!0):!1}const i=this.parent.parent.getRect();return t<0&&i.y+this.parent.store.data.y>=0||t>0&&i.ey-this.parent.height+this.parent.store.data.y<=0}changeMode(t){this.pageMode=!0,this.h.style.display="none";const i=this.parent.parent.getRect();if(i.height<this.parent.height&&(this.v.style.display="none"),this.isV){let s=i.height;this.padding=t||0,this.getV(),s=this.isV.h,this.v.style.top="0px",this.v.style.height=this.parent.parentElement.clientHeight/(s+this.padding||0)*this.parent.parentElement.clientHeight+"px",this.scrollY=0}}initPos(){this.scrollX=(this.parent.parentElement.clientWidth-this.hSize)/2,this.scrollY=(this.parent.parentElement.clientHeight-this.vSize)/2,this.h.style.left=`${this.scrollX}px`,this.v.style.top=`${this.scrollY}px`}resize(){this.rect=this.parent.parent.getRect(),this.rect.width<1400&&(this.rect.width=1400),this.rect.height<900&&(this.rect.height=900),this.parent.store.data.x>0?this.rect.width+=this.parent.store.data.x+(this.rect.x>0?0:this.rect.x):this.rect.width-=this.parent.store.data.x+(this.rect.x>0?0:this.rect.x),this.parent.store.data.y>0?this.rect.height+=this.parent.store.data.y+(this.rect.y>0?0:this.rect.y):this.rect.height-=this.parent.store.data.y+(this.rect.y>0?0:this.rect.y),this.rect.width<1400&&(this.rect.width=1400),this.rect.height<900&&(this.rect.height=900),this.hSize=1e3*this.parent.parentElement.clientWidth/this.rect.width/3,this.vSize=1e3*this.parent.parentElement.clientHeight/this.rect.height/3,this.h.style.width=this.hSize+"px",this.v.style.height=this.vSize+"px"}show(){this.isShow=!0,this.h.style.display="block",this.v.style.display="block",document.addEventListener("mousemove",this.onMouseMove),document.addEventListener("mouseup",this.onMouseUp)}hide(){this.isShow=!1,this.h.style.display="none",this.v.style.display="none",this.destroy()}translate(t,i){t&&(this.scrollX-=t*this.parent.parentElement.clientWidth/this.rect.width,this.h.style.left=`${this.scrollX}px`),i&&(this.scrollY-=i*this.parent.parentElement.clientHeight/this.rect.height,this.v.style.top=`${this.scrollY}px`)}wheel(t){let i=10;typeof t=="boolean"?t&&(i=-10):i=t,!(this.pageMode&&this.canMouseMove(i))&&(this.scrollY+=i,this.v.style.top=`${this.scrollY}px`,this.isV?this.parent.store.data.y-=i*this.isV.h/this.parent.parentElement.clientHeight:this.parent.store.data.y-=i*this.rect.height/this.parent.parentElement.clientHeight,this.parent.onMovePens(),this.parent.canvasTemplate.init(),this.parent.canvasImage.init(),this.parent.canvasImageBottom.init(),this.parent.render())}destroy(){document.removeEventListener("mousemove",this.onMouseMove),document.removeEventListener("mouseup",this.onMouseUp)}}class tr{constructor(t,i,s){D(this,"parentElement");D(this,"store");D(this,"isBottom");D(this,"canvas",document.createElement("canvas"));D(this,"otherOffsreen",Kt());D(this,"offscreen",Kt());D(this,"animateOffsScreen",Kt());D(this,"fitOffscreen",Kt());D(this,"fitFlag",!1);D(this,"currentFit");D(this,"activeFit");this.parentElement=t,this.store=i,this.isBottom=s,t.appendChild(this.canvas),this.canvas.style.backgroundRepeat="no-repeat",this.canvas.style.backgroundSize="100% 100%",this.canvas.style.position="absolute",this.canvas.style.top="0",this.canvas.style.left="0"}resize(t,i){this.canvas.style.width=t+"px",this.canvas.style.height=i+"px",t=t*this.store.dpiRatio|0,i=i*this.store.dpiRatio|0,this.canvas.width=t,this.canvas.height=i,this.otherOffsreen.width=t,this.otherOffsreen.height=i,this.offscreen.width=t,this.offscreen.height=i,this.animateOffsScreen.width=t,this.animateOffsScreen.height=i,this.fitOffscreen.width=t,this.fitOffscreen.height=i,this.otherOffsreen.getContext("2d").scale(this.store.dpiRatio,this.store.dpiRatio),this.otherOffsreen.getContext("2d").textBaseline="middle",this.offscreen.getContext("2d").scale(this.store.dpiRatio,this.store.dpiRatio),this.offscreen.getContext("2d").textBaseline="middle",this.animateOffsScreen.getContext("2d").scale(this.store.dpiRatio,this.store.dpiRatio),this.animateOffsScreen.getContext("2d").textBaseline="middle",this.fitOffscreen.getContext("2d").scale(this.store.dpiRatio,this.store.dpiRatio),this.fitOffscreen.getContext("2d").textBaseline="middle",this.init()}init(){this.offscreen.getContext("2d").clearRect(0,0,this.canvas.width,this.canvas.height),this.animateOffsScreen.getContext("2d").clearRect(0,0,this.canvas.width,this.canvas.height),this.fitOffscreen.getContext("2d").clearRect(0,0,this.canvas.width,this.canvas.height);for(const t of this.store.data.pens)this.hasImage(t)&&(t.calculative.imageDrawed=!1);this.isBottom?this.store.patchFlagsBackground=!0:this.store.patchFlagsTop=!0}clear(){this.otherOffsreen.getContext("2d").clearRect(0,0,this.otherOffsreen.width,this.otherOffsreen.height),this.offscreen.getContext("2d").clearRect(0,0,this.canvas.width,this.canvas.height),this.animateOffsScreen.getContext("2d").clearRect(0,0,this.canvas.width,this.canvas.height),this.fitOffscreen.getContext("2d").clearRect(0,0,this.canvas.width,this.canvas.height),this.canvas.getContext("2d").clearRect(0,0,this.canvas.width,this.canvas.height)}hasImage(t){return t.calculative.hasImage=t.calculative&&t.calculative.inView&&(this.isBottom&&t.canvasLayer===ht.CanvasImageBottom||!this.isBottom&&t.canvasLayer===ht.CanvasImage)&&t.image&&t.calculative.img&&t.name!=="gif",t.calculative.hasImage}render(){var o;let t=!1,i=!1;for(const l of this.store.data.pens)this.hasImage(l)&&(this.store.animates.has(l)?i=!0:l.calculative.imageDrawed||(t=!0),l.parentId&&this.store.animates.has(Mt(l,!0))&&(i=!0));const s=this.store.patchFlagsBackground,r=this.store.patchFlagsTop;if(r&&!this.isBottom){const l=this.otherOffsreen.getContext("2d");l.clearRect(0,0,this.canvas.width,this.canvas.height),this.renderRule(l)}if(this.store.patchFlagsLast&&this.offscreen.getContext("2d").clearRect(0,0,this.canvas.width,this.canvas.height),t){const l=this.offscreen.getContext("2d");l.save(),l.clearRect(0,0,this.canvas.width,this.canvas.height),l.translate(this.store.data.x,this.store.data.y);for(const n of this.store.data.pens)!n.calculative.hasImage||this.store.animates.has(n)||this.store.animates.has(Mt(n,!0))||n.canvasLayer!==ht.CanvasTemplate&&(n.calculative.imageDrawed=!0,l.save(),we(l,n),(n.rotateByRoot||n.calculative.rotate)&&se(l,n),be(l,n),Me(l,n),l.restore());l.restore()}if(i){const l=this.animateOffsScreen.getContext("2d");l.save(),l.clearRect(0,0,this.canvas.width,this.canvas.height),l.translate(this.store.data.x,this.store.data.y);for(const n of this.store.animates)n.calculative.hasImage&&n.canvasLayer!==ht.CanvasTemplate&&(n.visible===!1||n.calculative.visible===!1||(n.calculative.imageDrawed=!0,l.save(),we(l,n),(n.rotateByRoot||n.calculative.rotate)&&se(l,n),be(l,n),Me(l,n),l.restore()));for(const n of this.store.data.pens)!n.calculative.hasImage||!n.parentId||n.canvasLayer!==ht.CanvasTemplate&&(n.visible===!1||n.calculative.visible===!1||this.store.animates.has(Mt(n,!0))&&(n.calculative.imageDrawed=!0,l.save(),we(l,n),(n.rotateByRoot||n.calculative.rotate)&&se(l,n),be(l,n),Me(l,n),l.restore()));l.restore()}if(!this.isBottom&&!this.store.data.locked&&this.fitFlag){const l=(this.store.data.width||this.store.options.width)*this.store.data.scale,n=(this.store.data.height||this.store.options.height)*this.store.data.scale,h=this.store.data.origin.x+this.store.data.x||this.store.options.x||0,c=this.store.data.origin.y+this.store.data.y||this.store.options.y||0,f=this.fitOffscreen.getContext("2d");f.save(),f.clearRect(0,0,this.canvas.width,this.canvas.height),f.fillStyle="#ffffff66",f.strokeStyle=this.store.styles.activeColor,(o=this.store.data.fits)==null||o.forEach((u,d)=>{f.fillRect(h+l*u.x,c+n*u.y,l*u.width,n*u.height),u.active&&f.strokeRect(h+l*u.x,c+n*u.y,l*u.width,n*u.height)}),f.restore()}if(t||i||s&&this.isBottom||r&&!this.isBottom){const l=this.canvas.getContext("2d");l.clearRect(0,0,this.canvas.width,this.canvas.height),this.isBottom&&(this.store.patchFlagsBackground=!1),l.drawImage(this.offscreen,0,0,this.canvas.width,this.canvas.height),l.drawImage(this.animateOffsScreen,0,0,this.canvas.width,this.canvas.height),this.isBottom||(l.drawImage(this.otherOffsreen,0,0,this.canvas.width,this.canvas.height),this.store.patchFlagsTop=!1,!this.store.data.locked&&this.fitFlag&&l.drawImage(this.fitOffscreen,0,0,this.canvas.width,this.canvas.height))}}renderRule(t){var m,k,A,S,I,E,z,U;const{data:i,options:s}=this.store,{rule:r,ruleColor:a,scale:o,origin:l}=i;if(!(r??s.rule))return;const n=o*10;t.save();const h=a||s.ruleColor||"#ccc";t.strokeStyle=mi(h,.7);const c=l.x+i.x,f=l.y+i.y,{width:u,height:d}=this.canvas;let v=((m=s.ruleOptions)==null?void 0:m.height)||20;(k=s.ruleOptions)!=null&&k.background&&(t.beginPath(),t.fillStyle=(A=s.ruleOptions)==null?void 0:A.background,t.rect(0,0,u,v),t.fill(),t.rect(0,0,v,d),t.fill()),(S=s.ruleOptions)!=null&&S.underline&&(t.beginPath(),t.fillStyle=mi(h,.7),t.moveTo(0,v),t.lineTo(u,v),t.stroke(),t.moveTo(v,0),t.lineTo(v,d),t.stroke());let g=v/4;((I=s.ruleOptions)==null?void 0:I.baseline)==="bottom"&&(g=v*3/4),t.beginPath(),t.lineWidth=v/2,t.lineDashOffset=-c%n,t.setLineDash([1,n-1]),t.moveTo(0,g),t.lineTo(u,g),t.stroke(),t.beginPath(),t.lineDashOffset=-f%n,t.moveTo(g,0),t.lineTo(g,d),t.stroke(),t.strokeStyle=h,t.beginPath(),t.lineWidth=v,t.lineDashOffset=-c%(n*10),t.setLineDash([1,n*10-1]),t.moveTo(0,v/2),t.lineTo(u,v/2),t.stroke(),t.beginPath(),t.lineDashOffset=-f%(n*10),t.moveTo(v/2,0),t.lineTo(v/2,d),t.stroke(),t.beginPath(),t.fillStyle=((E=s.ruleOptions)==null?void 0:E.textColor)||t.strokeStyle;let y=0-Math.floor(c/n/10)*100,p=((z=s.ruleOptions)==null?void 0:z.textTop)||16,b=((U=s.ruleOptions)==null?void 0:U.textLeft)||4;c<0&&(y-=100);for(let T=c%(n*10);T<u;T+=10*n,y+=100)n<3&&y%500||t.fillText(y.toString(),T+b,p);y=0-Math.floor(f/n/10)*100,f<0&&(y-=100);for(let T=f%(n*10);T<d;T+=10*n,y+=100)n<3&&y%500||(t.save(),t.beginPath(),t.translate(p,T-b),t.rotate(270*Math.PI/180),t.fillText(y.toString(),0,0),t.restore());t.restore()}}class dl{constructor(t,i,s){D(this,"parentCanvas");D(this,"parentElement");D(this,"store");D(this,"canvas",document.createElement("canvas"));D(this,"magnifierScreen",Kt());D(this,"offscreen",Kt());D(this,"domOffscreen",Kt());D(this,"magnifierSize",300);D(this,"magnifier");this.parentCanvas=t,this.parentElement=i,this.store=s,i.appendChild(this.canvas),this.canvas.style.backgroundRepeat="no-repeat",this.canvas.style.backgroundSize="100% 100%",this.canvas.style.position="absolute",this.canvas.style.top="0",this.canvas.style.left="0",this.canvas.style.pointerEvents="none"}resize(t,i){this.canvas.style.width=t+"px",this.canvas.style.height=i+"px",t=t*this.store.dpiRatio|0,i=i*this.store.dpiRatio|0,this.canvas.width=t,this.canvas.height=i,this.offscreen.width=t,this.offscreen.height=i,this.offscreen.getContext("2d").scale(this.store.dpiRatio,this.store.dpiRatio),this.offscreen.getContext("2d").textBaseline="middle",this.domOffscreen.width=t,this.domOffscreen.height=i,this.domOffscreen.getContext("2d").scale(this.store.dpiRatio,this.store.dpiRatio),this.domOffscreen.getContext("2d").textBaseline="middle",this.magnifierScreen.width=this.magnifierSize+5,this.magnifierScreen.height=this.magnifierSize+5}renderMagnifier(){if(!this.magnifier)return;const t=this.magnifierSize/2,i=this.magnifierSize+5,s=this.magnifierScreen.getContext("2d");s.clearRect(0,0,i,i),s.lineWidth=5,s.save(),s.translate(2.5,2.5),s.save(),s.arc(t,t,t,0,Math.PI*2,!1),s.clip(),s.translate(-t,-t),s.scale(2,2);const r={x:(this.parentCanvas.mousePos.x+this.store.data.x)*this.store.dpiRatio,y:(this.parentCanvas.mousePos.y+this.store.data.y)*this.store.dpiRatio};[this.parentCanvas.canvasTemplate.bgOffscreen,this.parentCanvas.canvasTemplate.offscreen,this.parentCanvas.canvasImageBottom.offscreen,this.parentCanvas.canvasImageBottom.animateOffsScreen,this.parentCanvas.offscreen,this.parentCanvas.canvasImage.offscreen,this.parentCanvas.canvasImage.animateOffsScreen,this.domOffscreen].forEach(n=>{s.drawImage(n,r.x-t,r.y-t,this.magnifierSize,this.magnifierSize,0,0,this.magnifierSize,this.magnifierSize)}),s.restore(),s.beginPath();const o=s.createRadialGradient(t,t,t-5,t,t,t);o.addColorStop(0,"rgba(0,0,0,0.2)"),o.addColorStop(.8,"rgb(200,200,200)"),o.addColorStop(.9,"rgb(200,200,200)"),o.addColorStop(1,"rgba(200,200,200,0.9)"),s.strokeStyle=o,s.arc(t,t,t,0,Math.PI*2,!1),s.stroke(),s.restore(),this.offscreen.getContext("2d").drawImage(this.magnifierScreen,0,0,this.magnifierSize+5,this.magnifierSize+5,(r.x-t-2.5)/this.store.dpiRatio,(r.y-t-2.5)/this.store.dpiRatio,(this.magnifierSize+5)/this.store.dpiRatio,(this.magnifierSize+5)/this.store.dpiRatio)}updateDomOffscreen(){const t=this.domOffscreen.getContext("2d");t.clearRect(0,0,this.domOffscreen.width,this.domOffscreen.height);for(const i of this.store.data.pens)if((i.externElement||i.name==="gif")&&i.calculative.img){t.save(),t.translate(this.store.data.x,this.store.data.y);const{x:s,y:r,width:a,height:o}=i.calculative.worldRect;t.drawImage(i.calculative.img,s,r,a,o),t.restore()}}render(){this.offscreen.getContext("2d").clearRect(0,0,this.canvas.width,this.canvas.height),this.renderMagnifier();const t=this.canvas.getContext("2d");t.clearRect(0,0,this.canvas.width,this.canvas.height),t.drawImage(this.offscreen,0,0,this.canvas.width,this.canvas.height)}}function ta(e){if(e.data.locked)throw new Error("canvas is locked")}class fl{constructor(t,i){D(this,"parentElement");D(this,"box");D(this,"iframe");D(this,"dialog");D(this,"close");D(this,"title");D(this,"body");D(this,"x");D(this,"y");D(this,"url");D(this,"meta2dDiv");D(this,"dialogMeta2d");D(this,"store");D(this,"data");this.parentElement=t,this.store=i,this.box=document.createElement("div"),this.dialog=document.createElement("div");let s=document.createElement("div");this.title=document.createElement("div"),this.close=document.createElement("span"),this.close.innerHTML=`
|
|
3
3
|
<svg fill="none" viewBox="0 0 16 16" width="1em" height="1em">
|
|
4
4
|
<path
|
package/dist/web/assets/{meta2dEngine-BD2XbzaV-D1J2-XNv.js → meta2dEngine-BD2XbzaV-z-eR7E_V.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{T as D,W as _}from"./react-
|
|
1
|
+
import{T as D,W as _}from"./react-GP8hKHRA.js";import{r as p,a as A,b as u,c as z,i as N,M as O,C,f as k,d as q,e as L,g as V,h as j,s as B,j as G,k as H,l as J,m as W,n as K,o as Q}from"./meta2d-1-g23JOU.js";import"./react-vendor-BuABiQkA.js";import"./editor-CL03se2B.js";import"./ui-BQStT3dY.js";import"./motion-DX3HNq_4.js";import"./diagram-CT58wBdU.js";import"./index-BkKvQv2F.js";import"./plus-ECzYbQfA.js";import"./copy-BE64wQqi.js";let E=!1;function U(){E||(p(k()),A(q()),p(L()),u(V()),p(j()),p(B()),u(G()),z(),u(H()),u(J()),p(W()),u(K()),A(Q()),E=!0)}let F=!1;function Z(){F||(U(),F=!0)}function Y(e,r){try{e==null||e.destroy()}catch{}try{r.remove()}catch{}}function X(e){let r=e.font;Object.defineProperty(e,"font",{configurable:!0,get:()=>r,set:t=>{r=typeof t=="string"?t.replace(/(\d+(?:\.\d+)?(?:px|pt|pc|em|ex|%|in|cm|mm))\s*\/\s*(\d+(?:\.\d+)?)(?=\s|$)/,"$1/normal"):t,e.__ctx&&(e.__ctx.font=r)}})}function ee(e){typeof e.ellipse!="function"&&(e.ellipse=(r,t,n,a,s=0,o=0,m=Math.PI*2,i=!1)=>{var M;if(n<0||a<0)throw new Error("IndexSizeError: The radius provided is negative.");((M=e.__currentElement)==null?void 0:M.nodeName)!=="path"&&e.beginPath();const h=Math.PI*2,f=Math.abs(m-o),y=f>=h-1e-4||f===0,w=s*180/Math.PI,v=i?0:1,c=g=>{const l=Math.cos(g),S=Math.sin(g),b=Math.cos(s),x=Math.sin(s);return{x:r+n*l*b-a*S*x,y:t+n*l*x+a*S*b}},d=(g,l)=>{e.__addPathCommand(`A ${n} ${a} ${w} ${g} ${v} ${l.x} ${l.y}`),e.__currentPosition=l},P=c(o);if(e.moveTo(P.x,P.y),y){d(1,c(o+Math.PI)),d(1,P);return}const T=c(m);d(f>Math.PI?1:0,T)})}function $(){return new Promise(e=>{requestAnimationFrame(()=>e())})}async function I(){await $(),await $()}function R(){const e=C.default??C.C2S??C;if(typeof e=="function")return e;const r=window.C2S;return typeof r=="function"?r:null}async function te(e,r=R()){var f,y,w,v;if(!r)return console.error("[meta2d] preview failed: canvas2svg constructor missing"),"";D(e.data()),e.render(!0),await I();const t=e.store,n=(f=t==null?void 0:t.data)==null?void 0:f.pens,a=Array.isArray(n)?n.length:0,s=10,o=e.getRect();if(!o||!Number.isFinite(o.width)||!Number.isFinite(o.height)||o.width<=0||o.height<=0)return a===0?_:(console.error("[meta2d] preview failed: invalid bounds",o),"");const m={...o,x:o.x-s,y:o.y-s},i=new r(Math.ceil(o.width+s*2),Math.ceil(o.height+s*2));if(i.textBaseline="middle",i.strokeStyle=((y=t==null?void 0:t.styles)==null?void 0:y.color)||"#1f1f1f",X(i),ee(i),Array.isArray(n)&&t){for(const c of n)if(!((c==null?void 0:c.visible)===!1||!N(c,t)))try{e.renderPenRaw(i,c,m,!0)}catch(d){console.error("[meta2d] preview failed: render pen",c,d)}}const h=((v=(w=i.getSerializedSvg)==null?void 0:w.call(i))==null?void 0:v.replace(/--le5le--/g,"&#x"))??"";return h.trim()?h:a===0?_:(console.error("[meta2d] preview failed: serialized SVG is empty",{pensCount:a}),"")}async function pe(e){const r=R();if(!r)return console.error("[meta2d] preview failed: canvas2svg constructor missing"),"";Z();const t=document.createElement("div");t.style.cssText="position:fixed;left:-20000px;top:0;width:1200px;height:800px;pointer-events:none;z-index:-1;",document.body.append(t);let n=null;try{let a;try{a=JSON.parse(e)}catch(s){return console.error("[meta2d] preview failed: invalid diagram JSON",s,e),""}return n=new O(t,{background:"#fff",grid:!1,rule:!1}),D(a),n.open(a),n.render(!0),await I(),te(n,r)}catch(a){return console.error("[meta2d] preview failed: unexpected error",a),""}finally{Y(n,t)}}export{Z as ensureMeta2dShapes,pe as generateSvgFromDiagram,te as generateSvgFromMeta2d};
|