From 66eac4361ebc0ee419f2f33fd176f6bd3cbf8add Mon Sep 17 00:00:00 2001 From: plantain-00 Date: Wed, 13 Nov 2024 23:13:31 +0000 Subject: [PATCH] feat: get circle tangent to 2 geometry lines near param b953f6e1675486f45d3369a0d714c7166f90a1d2 --- ...e-tangent-tangent-radius-circle.plugin.tsx | 110 +++++++++++++++++- dev/cad-editor/plugins/variables.ts | 101 ++++++++++++++++ main.bundle.js | 2 +- src/utils/index.ts | 1 + src/utils/tangent-circle.ts | 79 +++++++++++++ 5 files changed, 291 insertions(+), 2 deletions(-) create mode 100644 src/utils/tangent-circle.ts diff --git a/dev/cad-editor/plugins/create-tangent-tangent-radius-circle.plugin.tsx b/dev/cad-editor/plugins/create-tangent-tangent-radius-circle.plugin.tsx index 7bdb7dff..46aa2c4b 100644 --- a/dev/cad-editor/plugins/create-tangent-tangent-radius-circle.plugin.tsx +++ b/dev/cad-editor/plugins/create-tangent-tangent-radius-circle.plugin.tsx @@ -2,7 +2,7 @@ import type { PluginContext } from './types' import type * as core from '../../../src' import type { Command } from '../command' import type * as model from '../model' -import { isLineContent } from './line-polyline.plugin' +import { isLineContent, LineContent } from './line-polyline.plugin' import { CircleContent, isArcContent, isCircleContent } from './circle-arc.plugin' export function getCommand(ctx: PluginContext): Command[] { @@ -38,6 +38,15 @@ export function getCommand(ctx: PluginContext): Command[] { ) const contentSelectable = (c: model.BaseContent) => isCircleContent(c) || isArcContent(c) || isLineContent(c) + const icon2 = ( + + + + + + + + ) const command: Command = { name: 'create tangent tangent radius circle', useCommand({ onEnd, type, selected, scale }) { @@ -213,6 +222,105 @@ export function getCommand(ctx: PluginContext): Command[] { } }, selectCount: 0, + }, + { + name: 'create tangent tangent radius circle at points', + useCommand({ onEnd, type, scale, contents }) { + const [start, setStart] = React.useState<{ point: core.Position, param: number, line: core.GeometryLine }>() + const [cursor, setCursor] = React.useState() + const [radius, setRadius] = React.useState() + const [result, setResult] = React.useState() + const assistentContents: (LineContent | CircleContent)[] = [] + if (start && cursor && type) { + assistentContents.push({ + points: [start.point, cursor], + type: 'line', + dashArray: [4 / scale], + }) + } + if (result) { + assistentContents.push({ ...result, type: 'circle' } as CircleContent) + } + const getTarget = (point: core.Position, id: number, param: number) => { + const content = contents[id] + if (!content) return + const lines = ctx.getContentModel(content)?.getGeometries?.(content, contents)?.lines + if (!lines) return + const index = Math.floor(param) + return { point, line: lines[index], param: param - index } + } + let message = '' + if (type && !radius) { + message = 'input radius' + } + const { input, setInputPosition, setCursorPosition, clearText, resetInput } = ctx.useCursorInput(message, type ? (e, text) => { + if (e.key === 'Enter') { + const r = +text + if (!isNaN(r)) { + setRadius(r) + clearText() + resetInput() + } + } + } : undefined) + const reset = () => { + setStart(undefined) + setResult(undefined) + setCursor(undefined) + setRadius(undefined) + clearText() + resetInput() + } + return { + onStart(p, target) { + if (!type) return + if (!target) return + if (target.param === undefined) return + if (!start) { + setStart(getTarget(p, target.id, target.param)) + } else if (result) { + onEnd({ + updateContents: (contents) => { + contents.push({ ...result, type: 'circle' } as CircleContent) + } + }) + reset() + } + }, + onMove(p, viewportPosition, target) { + if (!type) return + setCursor(p) + setResult(undefined) + setCursorPosition(p) + setInputPosition(viewportPosition || p) + if (!radius) return + if (!target) return + if (target.param === undefined) return + if (!start) return + const end = getTarget(p, target.id, target.param) + if (!end) return + const center = ctx.getTwoGeneralFormLinesIntersectionPoint( + ctx.pointAndDirectionToGeneralFormLine( + start.point, + ctx.getGeometryLineTangentRadianAtParam(start.param, start.line), + ), + ctx.pointAndDirectionToGeneralFormLine( + end.point, + ctx.getGeometryLineTangentRadianAtParam(end.param, end.line), + ), + ) + if (!center) return + const circle = ctx.getCircleTangentTo2GeometryLinesNearParam(start.line, end.line, radius, start.param, end.param, center) + if (!circle) return + setResult({ ...circle, r: radius }) + }, + input, + assistentContents, + reset, + } + }, + selectCount: 0, + icon: icon2, } ] } diff --git a/dev/cad-editor/plugins/variables.ts b/dev/cad-editor/plugins/variables.ts index 193ac84d..fc56bd45 100644 --- a/dev/cad-editor/plugins/variables.ts +++ b/dev/cad-editor/plugins/variables.ts @@ -2733,6 +2733,7 @@ function getCommand(ctx) { const React = ctx.React; const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "10,87 89,87", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "17", cy: "40", r: "16", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "60", cy: "57", r: "30", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" })); const contentSelectable = (c) => isCircleContent(c) || isArcContent(c) || isLineContent(c); + const icon2 = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "10,87 89,87", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "17", cy: "40", r: "16", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "60", cy: "57", r: "30", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "33", cy: "46", r: "8", fillOpacity: "1", strokeOpacity: "1", fill: "currentColor", stroke: "none" }), /* @__PURE__ */ React.createElement("circle", { cx: "60", cy: "87", r: "8", fillOpacity: "1", strokeOpacity: "1", fill: "currentColor", stroke: "none" })); const command = { name: "create tangent tangent radius circle", useCommand({ onEnd, type, selected, scale }) { @@ -2907,6 +2908,106 @@ function getCommand(ctx) { }; }, selectCount: 0 + }, + { + name: "create tangent tangent radius circle at points", + useCommand({ onEnd, type, scale, contents }) { + const [start, setStart] = React.useState(); + const [cursor, setCursor] = React.useState(); + const [radius, setRadius] = React.useState(); + const [result, setResult] = React.useState(); + const assistentContents = []; + if (start && cursor && type) { + assistentContents.push({ + points: [start.point, cursor], + type: "line", + dashArray: [4 / scale] + }); + } + if (result) { + assistentContents.push({ ...result, type: "circle" }); + } + const getTarget = (point, id, param) => { + var _a, _b, _c; + const content = contents[id]; + if (!content) return; + const lines = (_c = (_b = (_a = ctx.getContentModel(content)) == null ? void 0 : _a.getGeometries) == null ? void 0 : _b.call(_a, content, contents)) == null ? void 0 : _c.lines; + if (!lines) return; + const index = Math.floor(param); + return { point, line: lines[index], param: param - index }; + }; + let message = ""; + if (type && !radius) { + message = "input radius"; + } + const { input, setInputPosition, setCursorPosition, clearText, resetInput } = ctx.useCursorInput(message, type ? (e, text) => { + if (e.key === "Enter") { + const r = +text; + if (!isNaN(r)) { + setRadius(r); + clearText(); + resetInput(); + } + } + } : void 0); + const reset = () => { + setStart(void 0); + setResult(void 0); + setCursor(void 0); + setRadius(void 0); + clearText(); + resetInput(); + }; + return { + onStart(p, target) { + if (!type) return; + if (!target) return; + if (target.param === void 0) return; + if (!start) { + setStart(getTarget(p, target.id, target.param)); + } else if (result) { + onEnd({ + updateContents: (contents2) => { + contents2.push({ ...result, type: "circle" }); + } + }); + reset(); + } + }, + onMove(p, viewportPosition, target) { + if (!type) return; + setCursor(p); + setResult(void 0); + setCursorPosition(p); + setInputPosition(viewportPosition || p); + if (!radius) return; + if (!target) return; + if (target.param === void 0) return; + if (!start) return; + const end = getTarget(p, target.id, target.param); + if (!end) return; + const center = ctx.getTwoGeneralFormLinesIntersectionPoint( + ctx.pointAndDirectionToGeneralFormLine( + start.point, + ctx.getGeometryLineTangentRadianAtParam(start.param, start.line) + ), + ctx.pointAndDirectionToGeneralFormLine( + end.point, + ctx.getGeometryLineTangentRadianAtParam(end.param, end.line) + ) + ); + if (!center) return; + const circle = ctx.getCircleTangentTo2GeometryLinesNearParam(start.line, end.line, radius, start.param, end.param, center); + if (!circle) return; + setResult({ ...circle, r: radius }); + }, + input, + assistentContents, + reset + }; + }, + selectCount: 0, + icon: icon2 } ]; } diff --git a/main.bundle.js b/main.bundle.js index d4f7c07e..635dce2e 100644 --- a/main.bundle.js +++ b/main.bundle.js @@ -1,2 +1,2 @@ /*! For license information please see main.bundle.js.LICENSE.txt */ -(()=>{var e={8941:(e,t,n)=>{"use strict";n.d(t,{navigateTo:()=>a,useLocation:()=>c});var r=n(4629),o="positionLastShown",i="positionMax";function a(e,t){var n=t?"replaceState":"pushState",a=Number(sessionStorage.getItem(i))+1;sessionStorage.setItem(i,String(a)),sessionStorage.setItem(o,String(a));var c=(0,r.__assign)((0,r.__assign)({},s()),{state:history.state});history[n](a,"",e),dispatchEvent(new CustomEvent(n,{detail:c}))}function s(){return{path:location.pathname||"/",search:location.search}}function c(e,t){var n=this,i=(0,r.__read)(e.useState((function(){return s()})),2),a=i[0],c=a.path,l=a.search,u=i[1],p=e.useRef(c+l);return e.useEffect((function(){var e,i,a=function(e){return(0,r.__awaiter)(n,void 0,void 0,(function(){var n,o,i,a;return(0,r.__generator)(this,(function(r){switch(r.label){case 0:return n=s(),o=n.path+n.search,p.current===o?[3,3]:(i=!0,(null==t?void 0:t.confirm)?[4,t.confirm("replace")]:[3,2]);case 1:i=r.sent(),r.label=2;case 2:i?(p.current=o,u(n)):(a=e.detail,history.replaceState(a.state,"",a.path+a.search)),r.label=3;case 3:return[2]}}))}))},c=function(){return(0,r.__awaiter)(n,void 0,void 0,(function(){var e,n,o;return(0,r.__generator)(this,(function(r){switch(r.label){case 0:return e=s(),n=e.path+e.search,p.current===n?[3,3]:(o=!0,(null==t?void 0:t.confirm)?[4,t.confirm("push")]:[3,2]);case 1:o=r.sent(),r.label=2;case 2:o?(p.current=n,u(e)):history.back(),r.label=3;case 3:return[2]}}))}))},l=function(){return(0,r.__awaiter)(n,void 0,void 0,(function(){var e,n,i;return(0,r.__generator)(this,(function(r){switch(r.label){case 0:return e=s(),n=e.path+e.search,p.current===n?[3,3]:(i=!0,(null==t?void 0:t.confirm)?[4,t.confirm("pop")]:[3,2]);case 1:i=r.sent(),r.label=2;case 2:i?(sessionStorage.setItem(o,String(history.state)),p.current=n,u(e)):(a=Number(sessionStorage.getItem(o)),history.state>a?history.back():history.state{"use strict";n.d(t,{default:()=>s});var r=n(8645),o=n.n(r),i=n(278),a=n.n(i)()(o());a.push([e.id,"/* PrismJS 1.26.0\nhttps://prismjs.com/download.html#themes=prism-twilight&languages=markup+clike+javascript+jsx+tsx+typescript&plugins=line-numbers+toolbar+copy-to-clipboard */\ncode[class*=language-],pre[class*=language-]{color:#fff;background:0 0;font-family:Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace;font-size:1em;text-align:left;text-shadow:0 -.1em .2em #000;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}:not(pre)>code[class*=language-],pre[class*=language-]{background:#141414}pre[class*=language-]{border-radius:.5em;border:.3em solid #545454;box-shadow:1px 1px .5em #000 inset;margin:.5em 0;overflow:auto;padding:1em}pre[class*=language-]::-moz-selection{background:#27292a}pre[class*=language-]::selection{background:#27292a}code[class*=language-] ::-moz-selection,code[class*=language-]::-moz-selection,pre[class*=language-] ::-moz-selection,pre[class*=language-]::-moz-selection{text-shadow:none;background:hsla(0,0%,93%,.15)}code[class*=language-] ::selection,code[class*=language-]::selection,pre[class*=language-] ::selection,pre[class*=language-]::selection{text-shadow:none;background:hsla(0,0%,93%,.15)}:not(pre)>code[class*=language-]{border-radius:.3em;border:.13em solid #545454;box-shadow:1px 1px .3em -.1em #000 inset;padding:.15em .2em .05em;white-space:normal}.token.cdata,.token.comment,.token.doctype,.token.prolog{color:#777}.token.punctuation{opacity:.7}.token.namespace{opacity:.7}.token.boolean,.token.deleted,.token.number,.token.tag{color:#ce6849}.token.builtin,.token.constant,.token.keyword,.token.property,.token.selector,.token.symbol{color:#f9ed99}.language-css .token.string,.style .token.string,.token.attr-name,.token.attr-value,.token.char,.token.entity,.token.inserted,.token.operator,.token.string,.token.url,.token.variable{color:#909e6a}.token.atrule{color:#7385a5}.token.important,.token.regex{color:#e8c062}.token.bold,.token.important{font-weight:700}.token.italic{font-style:italic}.token.entity{cursor:help}.language-markup .token.attr-name,.language-markup .token.punctuation,.language-markup .token.tag{color:#ac885c}.token{position:relative;z-index:1}.line-highlight.line-highlight{background:hsla(0,0%,33%,.25);background:linear-gradient(to right,hsla(0,0%,33%,.1) 70%,hsla(0,0%,33%,0));border-bottom:1px dashed #545454;border-top:1px dashed #545454;margin-top:.75em;z-index:0}.line-highlight.line-highlight:before,.line-highlight.line-highlight[data-end]:after{background-color:#8693a6;color:#f4f1ef}\npre[class*=language-].line-numbers{position:relative;padding-left:3.8em;counter-reset:linenumber}pre[class*=language-].line-numbers>code{position:relative;white-space:inherit}.line-numbers .line-numbers-rows{position:absolute;pointer-events:none;top:0;font-size:100%;left:-3.8em;width:3em;letter-spacing:-1px;border-right:1px solid #999;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.line-numbers-rows>span{display:block;counter-increment:linenumber}.line-numbers-rows>span:before{content:counter(linenumber);color:#999;display:block;padding-right:.8em;text-align:right}\ndiv.code-toolbar{position:relative}div.code-toolbar>.toolbar{position:absolute;z-index:10;top:.3em;right:.2em;transition:opacity .3s ease-in-out;opacity:0}div.code-toolbar:hover>.toolbar{opacity:1}div.code-toolbar:focus-within>.toolbar{opacity:1}div.code-toolbar>.toolbar>.toolbar-item{display:inline-block}div.code-toolbar>.toolbar>.toolbar-item>a{cursor:pointer}div.code-toolbar>.toolbar>.toolbar-item>button{background:0 0;border:0;color:inherit;font:inherit;line-height:normal;overflow:visible;padding:0;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none}div.code-toolbar>.toolbar>.toolbar-item>a,div.code-toolbar>.toolbar>.toolbar-item>button,div.code-toolbar>.toolbar>.toolbar-item>span{color:#bbb;font-size:.8em;padding:0 .5em;background:#f5f2f0;background:rgba(224,224,224,.2);box-shadow:0 2px 0 0 rgba(0,0,0,.2);border-radius:.5em}div.code-toolbar>.toolbar>.toolbar-item>a:focus,div.code-toolbar>.toolbar>.toolbar-item>a:hover,div.code-toolbar>.toolbar>.toolbar-item>button:focus,div.code-toolbar>.toolbar>.toolbar-item>button:hover,div.code-toolbar>.toolbar>.toolbar-item>span:focus,div.code-toolbar>.toolbar>.toolbar-item>span:hover{color:inherit;text-decoration:none}\n",""]);const s=a},278:e=>{"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var n="",r=void 0!==t[5];return t[4]&&(n+="@supports (".concat(t[4],") {")),t[2]&&(n+="@media ".concat(t[2]," {")),r&&(n+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),n+=e(t),r&&(n+="}"),t[2]&&(n+="}"),t[4]&&(n+="}"),n})).join("")},t.i=function(e,n,r,o,i){"string"==typeof e&&(e=[[null,e,void 0]]);var a={};if(r)for(var s=0;s0?" ".concat(u[5]):""," {").concat(u[1],"}")),u[5]=i),n&&(u[2]?(u[1]="@media ".concat(u[2]," {").concat(u[1],"}"),u[2]=n):u[2]=n),o&&(u[4]?(u[1]="@supports (".concat(u[4],") {").concat(u[1],"}"),u[4]=o):u[4]="".concat(o)),t.push(u))}},t}},8645:e=>{"use strict";e.exports=function(e){return e[1]}},2100:(e,t,n)=>{"use strict";n.d(t,{AstronomicalObjectSimulator:()=>C});var r=n(3696),o=n.n(r),i=n(8662),a=n(9397),s=n(9758),c=n(9018),l=n(972),u=n(9520),p=Object.defineProperty,d=Object.defineProperties,f=Object.getOwnPropertyDescriptors,g=Object.getOwnPropertySymbols,h=Object.prototype.hasOwnProperty,m=Object.prototype.propertyIsEnumerable,y=Math.pow,v=(e,t,n)=>t in e?p(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,x=(e,t)=>{for(var n in t||(t={}))h.call(t,n)&&v(e,n,t[n]);if(g)for(var n of g(t))m.call(t,n)&&v(e,n,t[n]);return e},b=(e,t)=>d(e,f(t));(0,i.enablePatches)();const C=o().forwardRef(((e,t)=>{var n,r;const{width:p,height:d}=(0,s.useWindowSize)(),{state:f,setState:g,undo:h,redo:m,applyPatchFromOtherOperators:v,applyPatchFromSelf:C}=(0,s.usePatchBasedUndoRedo)(e.initialState,e.operator,{onApplyPatchesFromSelf:e.onApplyPatchesFromSelf}),{x:E,y:P,ref:w,setX:k,setY:_}=(0,s.useWheelScroll)(),{scale:S,setScale:R,ref:T}=(0,s.useWheelZoom)({min:.001,onChange(e,t,n){const r=(0,s.scaleByCursorPosition)({width:p,height:d},t/e,n);k(r.setX),_(r.setY)}}),[A,L]=o().useState({x:0,y:0}),{offset:M,onStart:I,mask:O,resetDragMove:D}=(0,s.useDragMove)((()=>{K?L((e=>({x:e.x+M.x,y:e.y+M.y}))):(k((e=>e+M.x)),_((e=>e+M.y)))})),[B,z]=o().useState(),[F,N]=o().useState(),[U,G]=o().useState(!1),[j,V]=o().useState(),W=[],H=[],q=[],$=[],[X,Y]=o().useState(!1),[K,Z]=o().useState(!1);let Q;const J=o().useRef(null),[ee,te,ne]=(0,s.useRefState)(!1),[re,oe,ie]=(0,s.useRefState2)(),ae=null!=re?re:f,{line:se,onClick:ce,reset:le,onMove:ue}=(0,s.useLineClickCreate)(U,(e=>{g((t=>{const n={type:"sphere",x:X?0:e[0].x,y:e[0].y,z:X?e[0].x:0,radius:(0,s.getTwoPointsDistance)(e[0],e[1]),speed:{x:0,y:0,z:0},mass:1,color:16711680};t.push(n)})),de()}),{once:!0});if(se){const e={type:"sphere",x:X?0:se[0].x,y:se[0].y,z:X?se[0].x:0,radius:(0,s.getTwoPointsDistance)(se[0],se[1]),speed:{x:0,y:0,z:0},mass:1,color:16711680};W.push(e)}j&&W.push(j);const pe={x:K?E:E+M.x,y:K?P:P+M.y,scale:S,center:{x:p/2,y:d/2}},de=()=>{G(!1),z(void 0),N(void 0),V(void 0)},{editPoint:fe,updateEditPreview:ge,onEditMove:he,onEditClick:me,resetEdit:ye}=(0,s.useEdit)((()=>C(H,q)),(e=>{if((0,l.isSphereContent)(e)){const t=X?e.z:e.x,n=[{x:t,y:e.y,cursor:"move",update(e,{cursor:t}){(0,l.isSphereContent)(e)&&(X?e.z=t.x:e.x=t.x,e.y=t.y)}}],r=X?e.speed.z:e.speed.x;if(r||e.speed.y){const o={x:t,y:e.y},i={x:r,y:e.speed.y},a=(0,s.getPointByLengthAndRadian)(o,e.radius+(0,s.getTwoPointsDistance)(i),Math.atan2(e.speed.y,r));n.push({x:a.x,y:a.y,cursor:"move",update(n,{cursor:r}){if(!(0,l.isSphereContent)(n))return;if((0,s.getTwoPointsDistance)(r,e)<=e.radius)return;const o=r.x-t,i=r.y-e.y,a=(0,s.getTwoPointsDistance)({x:o,y:i}),c=(a-e.radius)/a;X?n.speed.z=o*c:n.speed.x=o*c,n.speed.y=i*c}})}return{editPoints:n}}}),{scale:pe.scale,readOnly:U}),ve=ge();if(H.push(...null!=(n=null==ve?void 0:ve.patches)?n:[]),q.push(...null!=(r=null==ve?void 0:ve.reversePatches)?r:[]),void 0!==F&&!ee){const e=ae[F];if(e&&(0,l.isSphereContent)(e)){$.push({content:e,path:[F]});const t=e=>{const[,...t]=(0,i.produceWithPatches)(ae,(t=>{const n=t[F];n&&e(n,t)}));C(...t)},n={x:o().createElement(s.NumberEditor,{value:e.x,setValue:e=>t((t=>{(0,l.isSphereContent)(t)&&(t.x=e)}))}),y:o().createElement(s.NumberEditor,{value:e.y,setValue:e=>t((t=>{(0,l.isSphereContent)(t)&&(t.y=e)}))}),z:o().createElement(s.NumberEditor,{value:e.z,setValue:e=>t((t=>{(0,l.isSphereContent)(t)&&(t.z=e)}))}),radius:o().createElement(s.NumberEditor,{value:e.radius,setValue:e=>t((t=>{(0,l.isSphereContent)(t)&&(t.radius=e)}))}),mass:o().createElement(s.NumberEditor,{value:e.mass,setValue:e=>t((t=>{(0,l.isSphereContent)(t)&&(t.mass=e)}))}),color:o().createElement(s.NumberEditor,{type:"color",value:e.color,setValue:e=>t((t=>{(0,l.isSphereContent)(t)&&(t.color=e)}))}),speed:o().createElement(s.ObjectEditor,{inline:!0,properties:{x:o().createElement(s.NumberEditor,{value:e.speed.x,setValue:e=>t((t=>{(0,l.isSphereContent)(t)&&(t.speed.x=e)}))}),y:o().createElement(s.NumberEditor,{value:e.speed.y,setValue:e=>t((t=>{(0,l.isSphereContent)(t)&&(t.speed.y=e)}))}),z:o().createElement(s.NumberEditor,{value:e.speed.z,setValue:e=>t((t=>{(0,l.isSphereContent)(t)&&(t.speed.z=e)}))})}})};e.acceleration&&(n.acceleration=o().createElement(s.ObjectEditor,{inline:!0,properties:{x:o().createElement(s.NumberEditor,{value:e.acceleration.x}),y:o().createElement(s.NumberEditor,{value:e.acceleration.y}),z:o().createElement(s.NumberEditor,{value:e.acceleration.z})}})),Q=o().createElement("div",{style:{position:"absolute",right:"0px",top:"0px",bottom:"0px",width:"300px",overflowY:"auto",background:"white",zIndex:11}},o().createElement("div",null,F),o().createElement(s.ObjectEditor,{readOnly:void 0!==re,properties:n}))}}(0,s.useGlobalKeyDown)((e=>{return t=function*(){if("Escape"===e.key)de(),le(!0),ye(),D();else if("Backspace"===e.code){if(K)return;void 0!==B?(g((e=>{e[B]=void 0})),z(void 0)):void 0!==F&&(g((e=>{e[F]=void 0})),N(void 0))}else if((0,s.metaKeyIfMacElseCtrlKey)(e))if(e.shiftKey)"KeyZ"===e.code&&(yield m(e));else if("KeyZ"===e.code)yield h(e);else if("Digit0"===e.code)R(1),k(0),_(0),L({x:0,y:0}),e.preventDefault();else if("KeyC"===e.code){if(e.preventDefault(),void 0!==F){const e=f[F];e&&(yield navigator.clipboard.writeText(JSON.stringify(e)))}}else if("KeyV"===e.code){try{const e=yield navigator.clipboard.readText(),t=JSON.parse(e);if((0,l.isSphereContent)(t))return void V(t)}catch(e){console.info(e)}e.preventDefault()}},new Promise(((e,n)=>{var r=e=>{try{i(t.next(e))}catch(e){n(e)}},o=e=>{try{i(t.throw(e))}catch(e){n(e)}},i=t=>t.done?e(t.value):Promise.resolve(t.value).then(r,o);i((t=t.apply(undefined,null)).next())}));var t})),o().useImperativeHandle(t,(()=>({handlePatchesEvent(e){try{v(e.patches,e.reversePatches,e.operator)}catch(e){console.error(e)}}})),[v]);const xe=(0,s.useEvent)((e=>{const t={x:e.clientX,y:e.clientY};4===e.buttons?I(t):U||fe||void 0!==B||j||I(t)})),be=(0,s.useEvent)((e=>{const t={x:e.clientX,y:e.clientY},n=(0,s.reverseTransformPosition)(t,pe);U?ce(n):j?g((e=>{e.push(b(x({},j),{x:n.x,y:n.y}))})):fe?me(n):void 0!==B&&(N(B),z(void 0))})),Ce=(0,s.useEvent)((e=>{var t;const n={x:e.clientX,y:e.clientY};if(K)return void z(null==(t=J.current)?void 0:t.getContentByPosition(n));const r=(0,s.reverseTransformPosition)(n,pe);U?ue(r,n):j?V(b(x({},j),{x:r.x,y:r.y})):(he(r,$),z((e=>{for(let t=0;tZ(!K)},K?"3D":"2D"),!K&&o().createElement(s.Button,{style:{color:U?"red":void 0},onClick:()=>{le(),G(!0)}},"create"),o().createElement(s.Button,{onClick:()=>{g((e=>{for(let t=f.length-1;t>=0;t--)f[t]||e.splice(t,1)}))}},"compress"),o().createElement(s.Button,{onClick:()=>{if(ne.current)return void te(!1);let e;te(!0);const t=n=>{var r;if(ne.current){if(void 0!==e){const t=.001*(n-e),o=[],c=null!=(r=ie.current)?r:f;for(const e of c)if(e&&(0,l.isSphereContent)(e)){const n={x:0,y:0,z:0};for(const t of c)if(t&&t!==e&&(0,l.isSphereContent)(t)){const r=a.v3.create(t.x-e.x,t.y-e.y,t.z-e.z),o=a.v3.mulScalar(a.v3.normalize(r),t.mass/a.v3.lengthSq(r));n.x+=o[0],n.y+=o[1],n.z+=o[2]}const r=(0,i.produce)(e,(r=>{r.x+=e.speed.x*t,r.y+=e.speed.y*t,r.z+=e.speed.z*t,r.speed.x+=n.x*t,r.speed.y+=n.y*t,r.speed.z+=n.z*t,r.acceleration=n})),u=o.findIndex((e=>y(e.x-r.x,2)+y(e.y-r.y,2)+y(e.z-r.z,2)<=y(e.radius+r.radius,2)));u>=0?o[u]=(0,i.produce)(o[u],(e=>{const t=e.mass+r.mass,n=e.mass/t,o=r.mass/t,i=(0,s.colorNumberToPixelColor)(e.color),a=(0,s.colorNumberToPixelColor)(r.color);e.color=(0,s.pixelColorToColorNumber)([Math.round(i[0]*n+a[0]*o),Math.round(i[1]*n+a[1]*o),Math.round(i[2]*n+a[2]*o)]),e.x=e.x*n+r.x*o,e.y=e.y*n+r.y*o,e.z=e.z*n+r.z*o,e.speed.x=e.speed.x*n+r.speed.x*o,e.speed.y=e.speed.y*n+r.speed.y*o,e.speed.z=e.speed.z*n+r.speed.z*o,e.mass=t,e.radius=y(y(e.radius,3)+y(r.radius,3),1/3)})):o.push(r)}oe(o)}e=n,requestAnimationFrame(t)}};requestAnimationFrame(t)}},ee?"pause":"run"),void 0!==re&&o().createElement(s.Button,{onClick:()=>{te(!1),oe(void 0)}},"stop"),!K&&o().createElement(s.Button,{onClick:()=>Y(!X)},X?"y-z":"x-y"))),Q,O)}))},6129:(e,t,n)=>{"use strict";n.d(t,{astronomicalObjectData:()=>r});const r=[{type:"sphere",x:231,y:236,z:0,radius:30,speed:{x:-73.70571823105142,y:68.12490364773653,z:0},mass:1e7,color:16711680},{type:"sphere",x:446,y:353,z:0,radius:20,speed:{x:-102.94373709062597,y:168.36353129062343,z:0},mass:1e3,color:65280},{type:"sphere",x:398.9843062850506,y:-117.78508305127633,z:0,radius:20,speed:{x:153.21723012109481,y:57.76555978608411,z:0},mass:1e3,color:255},{type:"sphere",x:41.02054841250941,y:37.316758024428964,z:0,radius:30,speed:{x:65.08066514652798,y:-66.75836078276822,z:0},mass:1e7,color:65535},{type:"sphere",x:3107.5317443426698,y:-18.917171514406107,z:0,radius:37.45047072967306,speed:{x:0,y:0,z:0},mass:1e7,color:54783},{type:"sphere",x:3638.8316388608887,y:-65.11716234207734,z:0,radius:45.06522687618144,speed:{x:-27.342187113971978,y:-33.25473001125231,z:0},mass:1e7,color:16711680},{type:"sphere",x:3497.1057910282866,y:661.0342986264877,z:0,radius:37.45047072967306,speed:{x:0,y:0,z:0},mass:1e7,color:16771584},{type:"sphere",x:635.5477051784671,y:307.619425187331,z:0,radius:20,speed:{x:-19.15755965193336,y:112.03470856588699,z:0},mass:1e3,color:13172480},{type:"sphere",x:839.3864576748671,y:249.379781616931,z:0,radius:20,speed:{x:-6.070839258689052,y:128.36149928851918,z:0},mass:1e3,color:16711829},{type:"sphere",x:813.5021716435781,y:97.30960118310884,z:0,radius:20,speed:{x:-.47910598403916377,y:108.26015976138154,z:0},mass:1e3,color:7536895},{type:"sphere",x:601.5745797624005,y:121.57611933744215,z:0,radius:20,speed:{x:-4.309805634415668,y:95.12035518543071,z:0},mass:1e3,color:15597823},{type:"sphere",x:998.966956569539,y:170.03750534624538,z:0,radius:20,speed:{x:-6.070839258689052,y:128.36149928851918,z:0},mass:1e3,color:49151},{type:"sphere",x:1110.0310760697196,y:39.53716493353312,z:0,radius:20,speed:{x:-6.070839258689052,y:128.36149928851918,z:0},mass:1e3,color:0},{type:"sphere",x:1201.6589746573686,y:-93.73977846668356,z:0,radius:20,speed:{x:-6.070839258689052,y:128.36149928851918,z:0},mass:1e3,color:16756224},{type:"sphere",x:216,y:82,z:0,radius:99.80981915623332,speed:{x:0,y:0,z:0},mass:1,color:16711680}]},972:(e,t,n)=>{"use strict";n.d(t,{getContentModel:()=>a,isSphereContent:()=>o});var r=n(9758);function o(e){return"sphere"===e.type}const i={};function a(e){return i[e.type]}var s;i[(s={type:"sphere",render(e,{target:t,transformRadius:n,yz:o}){const i=n(e.radius),a=o?e.z:e.x,s={x:a,y:e.y},c=[t.renderCircle(a,e.y,i,{fillColor:e.color,strokeWidth:0})],l=o?e.speed.z:e.speed.x;if(l||e.speed.y){const n={x:l,y:e.speed.y},o=(0,r.getPointByLengthAndRadian)(s,e.radius+(0,r.getTwoPointsDistance)(n),Math.atan2(e.speed.y,l)),{arrowPoints:i,endPoint:a}=(0,r.getArrow)(s,o,10,15);c.push(t.renderPolyline([s,a],{strokeColor:e.color}),t.renderPolygon(i,{fillColor:e.color,strokeWidth:0}))}if(e.acceleration){const n=o?e.acceleration.z:e.acceleration.x;if(n||e.acceleration.y){const o={x:n,y:e.acceleration.y},i=(0,r.getPointByLengthAndRadian)(s,e.radius+(0,r.getTwoPointsDistance)(o),Math.atan2(e.acceleration.y,n)),{arrowPoints:a,endPoint:l}=(0,r.getArrow)(s,i,10,15);c.push(t.renderPolyline([s,l],{strokeColor:e.color,dashArray:[5]}),t.renderPolygon(a,{fillColor:e.color,strokeWidth:0}))}}return t.renderGroup(c)}}).type]=s},9520:(e,t,n)=>{"use strict";n.d(t,{Renderer3d:()=>c});var r=n(3696),o=n.n(r),i=n(9397),a=n(9758),s=n(972);const c=o().forwardRef(((e,t)=>{const n=o().useRef(null),r=o().useRef(),c=o().useRef(new a.MapCache),l=o().useRef(new a.WeakmapCache),u=o().useRef(new a.WeakmapCache);return o().useEffect((()=>{n.current&&(r.current=(0,a.createWebgl3DRenderer)(n.current))}),[n.current]),o().useEffect((()=>{if(!r.current)return;const t=[],n=[...(0,a.getAxesGraphics)()],{position:o,up:p}=(0,a.updateCamera)(-e.x,e.y,1e3/e.scale,-.3*e.rotateX,-.3*e.rotateY);e.contents.forEach(((r,o)=>{if(r&&(0,s.isSphereContent)(r)){const s=(0,a.colorNumberToVec)(r.color);e.hovering!==o&&e.selected!==o||(s[3]=.5),t.push({geometry:c.current.get(r.radius,(()=>({type:"sphere",radius:r.radius}))),color:s,position:(0,a.position3DToVec3)(r)});const p=i.v3.create(r.x,r.y,r.z),d=i.v3.create(r.speed.x,r.speed.y,r.speed.z),f=i.v3.add(p,i.v3.mulScalar(i.v3.normalize(d),i.v3.length(d)+r.radius));if(n.push({geometry:l.current.get(r,(()=>({type:"lines",points:[...p,...f]}))),color:s}),r.acceleration){const e=i.v3.create(r.acceleration.x,r.acceleration.y,r.acceleration.z),t=i.v3.add(p,i.v3.mulScalar(i.v3.normalize(e),i.v3.length(e)+r.radius));n.push({geometry:u.current.get(r,(()=>({type:"lines",points:(0,a.getDashedLine)([p[0],p[1],p[2]],[t[0],t[1],t[2]],6).flat()}))),color:s})}}else t.push(void 0)})),t.push(...n),r.current.render(t,{eye:(0,a.position3DToVec3)(o),up:(0,a.position3DToVec3)(p),target:[-e.x,e.y,0],fov:(0,a.angleToRadian)(60),near:.1,far:2e4},{position:[1e3,1e3,1e3],color:[1,1,1,1],specular:[1,1,1,1],shininess:50,specularFactor:1},[1,1,1,1])}),[e.x,e.y,e.scale,e.rotateX,e.rotateY,e.contents,e.hovering,e.selected,e.width,e.height]),o().useImperativeHandle(t,(()=>({getContentByPosition(e){var t,n;return null==(n=null==(t=r.current)?void 0:t.pick)?void 0:n.call(t,e.x,e.y,(e=>"sphere"===e.geometry.type))}})),[]),o().createElement("canvas",{ref:n,width:e.width,height:e.height,onClick:e.onClick,onMouseDown:e.onMouseDown})}))},9018:(e,t,n)=>{"use strict";n.d(t,{Renderer:()=>d});var r=n(8662),o=n(9758),i=n(972),a=Object.defineProperty,s=Object.getOwnPropertySymbols,c=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,u=(e,t,n)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,p=(e,t)=>{for(var n in t||(t={}))c.call(t,n)&&u(e,n,t[n]);if(s)for(var n of s(t))l.call(t,n)&&u(e,n,t[n]);return e};function d(e){var t,n;const a=o.reactSvgRenderTarget,s=[],c=e.previewPatches.length>0?(0,r.applyPatches)(e.contents,e.previewPatches):e.contents;for(let n=0;ne.hovering===n||e.selected===n?t+1:t,yz:e.yz}))}}for(const t of e.assistentContents){if(!t)continue;const r=null==(n=(0,i.getContentModel)(t))?void 0:n.render;r&&s.push(r(t,{target:a,transformRadius:e=>e,yz:e.yz}))}return a.renderResult(s,e.width,e.height,{attributes:{style:p({position:"absolute",boxSizing:"border-box"},e.style),onClick:e.onClick,onMouseDown:e.onMouseDown,onContextMenu:e.onContextMenu},transform:{x:e.x,y:e.y,scale:e.scale}})}},8995:(e,t,n)=>{"use strict";n.d(t,{default:()=>c});var r=n(3696),o=n.n(r),i=n(9758),a=n(7469),s=n(3385);const c=()=>{const e=(0,i.useWindowSize)().width/2-30,[t,n]=o().useState(),r=o().useRef(new i.MapCache4),c=(e,n,o=!1,a=!1)=>{if(t&&e)return r.current.get(o,a,n,e,(()=>{const r=t.getPath(e,0,n,n,{xScale:n/t.unitsPerEm,yScale:n/t.unitsPerEm}),c=t.charToGlyph(e),l=c.getBoundingBox(),u=c.advanceWidth||0,p=l.x2-l.x1,d=(0,s.opentypeCommandsToPathCommands)(r,o?.7*n:void 0);let f=(0,i.geometryLinesToHatches)((0,i.pathCommandsToGeometryLines)(d));return a&&(f=f.map((e=>(0,i.boldHatch)(e,.01*n)))),{commands:f.map((e=>[e.border,...e.holes])).map((e=>e.map((e=>(0,i.geometryLineToPathCommands)(e))).flat())),x1:(u>p?0:l.x1)/t.unitsPerEm*n,y1:(c.unicode&&c.unicode<256?0:l.y1)/t.unitsPerEm*n,width:Math.max(u,p)/t.unitsPerEm*n}}))},[l,u]=o().useState([{insert:"我们出"},{insert:"去吧",attributes:{stackText:"ab"}},{insert:"Aag jioIb BDxVX晒回吧",attributes:{color:16711680}}]),[p,d]=o().useState("left"),[f,g]=o().useState("top"),[h,m]=o().useState(!1),y=e=>{var t,n;return null!=(n=null==(t=null==e?void 0:e.attributes)?void 0:t.color)?n:0},v=e=>{var t,n;return null!=(n=null==(t=null==e?void 0:e.attributes)?void 0:t.opacity)?n:1},x=e=>{var t,n;return null!=(n=null==(t=null==e?void 0:e.attributes)?void 0:t.fontSize)?n:50},b=e=>{var t,n;return x(e)*((null==(t=null==e?void 0:e.attributes)?void 0:t.script)||(null==(n=null==e?void 0:e.attributes)?void 0:n.stackText)?.7:1)},C=e=>{var t,n;return null!=(n=null==(t=null==e?void 0:e.attributes)?void 0:t.backgroundColor)?n:16777215},E=e=>{var t,n;return null!=(n=null==(t=null==e?void 0:e.attributes)?void 0:t.underline)&&n},P=e=>{var t,n;return null!=(n=null==(t=null==e?void 0:e.attributes)?void 0:t.passThrough)&&n},w=e=>{var t,n;return null!=(n=null==(t=null==e?void 0:e.attributes)?void 0:t.bold)&&n},k=e=>{var t,n;return null!=(n=null==(t=null==e?void 0:e.attributes)?void 0:t.italic)&&n},_=e=>{var t;return null==(t=null==e?void 0:e.attributes)?void 0:t.script},S=e=>{var t,n;return null!=(n=null==(t=null==e?void 0:e.attributes)?void 0:t.circle)&&n},R=e=>{var t,n;return null!=(n=null==(t=null==e?void 0:e.attributes)?void 0:t.stackText)?n:""},T=e=>1.5*b(e),A=e=>{var t,n,r;const o=b(e);if(null==(t=e.attributes)?void 0:t.stackText){const t=e.insert.split("").reduce(((e,t)=>{var n,r;return e+(null!=(r=null==(n=c(t,o))?void 0:n.width)?r:0)}),0),n=e.attributes.stackText.split("").reduce(((e,t)=>{var n,r;return e+(null!=(r=null==(n=c(t,o))?void 0:n.width)?r:0)}),0);return Math.max(n,t)}return null!=(r=null==(n=c(e.insert,o))?void 0:n.width)?r:0},L=e=>S(e)?T(e):A(e),{renderEditor:M,layoutResult:I,lineHeights:O,isSelected:D,actualHeight:B,cursorContent:z,setSelectedAttributes:F}=(0,i.useAttributedTextEditor)({state:l,setState:u,width:e,height:200,lineHeight:T,getWidth:L,getReadonlyType:e=>!!(null==e?void 0:e.stackText)||void 0,align:p,verticalAlign:f});o().useEffect((()=>{var e;e=function*(){const e=yield fetch(s.allFonts[0].url),t=yield e.arrayBuffer();n(a.parse(t))},new Promise(((t,n)=>{var r=t=>{try{i(e.next(t))}catch(e){n(e)}},o=t=>{try{i(e.throw(t))}catch(e){n(e)}},i=e=>e.done?t(e.value):Promise.resolve(e.value).then(r,o);i((e=e.apply(undefined,null)).next())}))}),[]);const N=i.reactSvgRenderTarget,U=[],G=[];for(const{x:e,y:t,i:n,content:r,visible:o,row:i}of I){if(!o)continue;const a=L(r),s=O[i],l=D(n);l&&U.push(N.renderRect(e,t,a,s,{fillColor:11785981,strokeWidth:0}));const u=b(r),p=k(r),d=w(r),f=c(r.insert,u,p,d);if(f){const n=y(r),o=v(r),i=C(r);l||16777215===i||U.push(N.renderRect(e,t,a,s,{fillColor:i,strokeWidth:0})),E(r)&&U.push(N.renderPolyline([{x:e,y:t+s},{x:e+a,y:t+s}],{strokeColor:n,strokeOpacity:o})),P(r)&&U.push(N.renderPolyline([{x:e,y:t+s/2},{x:e+a,y:t+s/2}],{strokeColor:n,strokeOpacity:o}));const g={x:e-f.x1,y:t+f.y1+(s-T(r))},m=_(r),x=R(r);if("sub"===m?g.y+=.2*u:("sup"===m||x)&&(g.y-=.7*u),x){const e=r.insert.split("").reduce(((e,t)=>{var n,r;return e+(null!=(r=null==(n=c(t,u))?void 0:n.width)?r:0)}),0);g.x+=(a-e)/2}S(r)&&(g.x+=(s-A(r))/2,U.push(N.renderCircle(e+a/2,t+s/2,s/2,{strokeColor:n,strokeOpacity:o})));const b=h?{strokeColor:n,strokeOpacity:o,strokeWidth:1}:{fillColor:n,fillOpacity:o,strokeWidth:0};if(U.push(N.renderGroup(f.commands.map((e=>N.renderPathCommands(e,b))),{translate:g})),l&&G.push(...f.commands),x){const n=x.split("").reduce(((e,t)=>{var n,r;return e+(null!=(r=null==(n=c(t,u))?void 0:n.width)?r:0)}),0);let o=0;for(const i of x.split("")){const l=c(i,u,p,d);if(l){const i={x:e-l.x1+(a-n)/2+o,y:t+l.y1+(s-T(r))+.2*u};o+=l.width,U.push(N.renderGroup(l.commands.map((e=>N.renderPathCommands(e,b))),{translate:i}))}}}}}const j=N.renderResult(U,e,B);return o().createElement(o().Fragment,null,M(j),o().createElement(i.EnumEditor,{enums:i.aligns,value:p,setValue:d}),o().createElement(i.EnumEditor,{enums:i.verticalAligns,value:f,setValue:g}),o().createElement(i.ObjectEditor,{inline:!0,properties:{color:o().createElement(i.NumberEditor,{type:"color",value:y(z),setValue:e=>F({color:e})}),opacity:o().createElement(i.NumberEditor,{value:v(z),setValue:e=>F({opacity:e})}),fontSize:o().createElement(i.NumberEditor,{value:x(z),setValue:e=>F({fontSize:e})}),backgroundColor:o().createElement(i.NumberEditor,{type:"color",value:C(z),setValue:e=>F({backgroundColor:16777215===e?void 0:e})}),underline:o().createElement(i.BooleanEditor,{value:E(z),setValue:e=>F({underline:!!e||void 0})}),passThrough:o().createElement(i.BooleanEditor,{value:P(z),setValue:e=>F({passThrough:!!e||void 0})}),bold:o().createElement(i.BooleanEditor,{value:w(z),setValue:e=>F({bold:!!e||void 0})}),italic:o().createElement(i.BooleanEditor,{value:k(z),setValue:e=>F({italic:!!e||void 0})}),strokeOnly:o().createElement(i.BooleanEditor,{value:h,setValue:e=>m(e)}),sub:o().createElement(i.BooleanEditor,{value:"sub"===_(z),setValue:e=>F({script:e?"sub":void 0})}),sup:o().createElement(i.BooleanEditor,{value:"sup"===_(z),setValue:e=>F({script:e?"sup":void 0})}),circle:o().createElement(i.BooleanEditor,{value:S(z),setValue:e=>F({circle:!!e||void 0})}),stackText:o().createElement(i.StringEditor,{value:R(z),setValue:e=>F({stackText:e||void 0})}),actions:o().createElement(i.Button,{onClick:()=>navigator.clipboard.writeText(JSON.stringify({contents:G.map(((e,t)=>({id:t,content:{type:"path",commands:e}}))),center:{x:0,y:0}}))},"copy as command path")}}))}},7474:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(3696),o=n.n(r),i=n(9758);const a=()=>{const[e,t]=o().useState([{insert:"abc"},{insert:"123",attributes:{color:16711680,readonly:"1"}},{insert:"edf",attributes:{readonly:"1"}},{insert:"ghi",attributes:{color:65280}}]),[n,r]=o().useState("left"),[a,s]=o().useState("top"),c=e=>{var t,n;return null!=(n=null==(t=null==e?void 0:e.attributes)?void 0:t.fontFamily)?n:"monospace"},l=e=>{var t,n;return null!=(n=null==(t=null==e?void 0:e.attributes)?void 0:t.color)?n:0},u=e=>{var t,n;return null!=(n=null==(t=null==e?void 0:e.attributes)?void 0:t.bold)&&n},p=e=>{var t,n;return null!=(n=null==(t=null==e?void 0:e.attributes)?void 0:t.italic)&&n},d=e=>{var t,n;return null!=(n=null==(t=(0,i.getTextSizeFromCache)(`${u(e)?"bold ":""}${p(e)?"italic ":""}20px ${c(e)}`,e.insert))?void 0:t.width)?n:0},{renderEditor:f,layoutResult:g,isSelected:h,actualHeight:m,cursorContent:y,setSelectedAttributes:v}=(0,i.useAttributedTextEditor)({state:e,setState:t,width:400,height:200,lineHeight:24,getWidth:d,align:n,verticalAlign:a,getReadonlyType:e=>null==e?void 0:e.readonly}),x=[],b=i.reactCanvasRenderTarget;for(const{x:e,y:t,i:n,content:r,visible:o}of g){if(!o)continue;const i=d(r);h(n)&&x.push(b.renderRect(e,t,i,24,{fillColor:11785981,strokeWidth:0})),x.push(b.renderText(e+i/2,t+20,r.insert,l(r),20,c(r),{textAlign:"center",fontWeight:u(r)?"bold":void 0,fontStyle:p(r)?"italic":void 0}))}const C=b.renderResult(x,400,m);return o().createElement(o().Fragment,null,f(C),o().createElement(i.EnumEditor,{enums:i.aligns,value:n,setValue:r}),o().createElement(i.EnumEditor,{enums:i.verticalAligns,value:a,setValue:s}),o().createElement(i.ObjectEditor,{inline:!0,properties:{color:o().createElement(i.NumberEditor,{type:"color",value:l(y),setValue:e=>v({color:e})}),fontFamily:o().createElement(i.StringEditor,{value:c(y),setValue:e=>v({fontFamily:e})}),bold:o().createElement(i.BooleanEditor,{value:u(y),setValue:e=>v({bold:!!e||void 0})}),italic:o().createElement(i.BooleanEditor,{value:p(y),setValue:e=>v({italic:!!e||void 0})})}}))}},8576:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(3696),o=n.n(r),i=n(9758);const a=()=>{const{start:e,stop:t,duration:n,volume:r,audioUrl:a,recording:s}=(0,i.useAudioRecorder)(),{play:c,pause:l,playing:u,currentTime:p,audio:d,duration:f}=(0,i.useAudioPlayer)(a);return o().createElement("div",null,s?null:o().createElement("button",{onClick:e},"start"),s?o().createElement("button",{onClick:t},"stop ",n):null,s&&void 0!==r?o().createElement("meter",{max:"1",value:r}):null,a&&o().createElement(o().Fragment,null,o().createElement("button",{onClick:u?l:c},u?"pause":"play"),p,"/",f,d))}},3388:(e,t,n)=>{"use strict";n.d(t,{default:()=>f});var r=n(3696),o=n.n(r),i=n(9758),a=Object.defineProperty,s=Object.defineProperties,c=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,u=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable,d=(e,t,n)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;const f=()=>{const e=o().useRef(null),t=o().useRef(),{x:n,y:r,ref:a}=(0,i.useWheelScroll)(),{scale:f,ref:g}=(0,i.useWheelZoom)(),[h,m]=o().useState({x:0,y:0}),{offset:y,onStart:v,mask:x,resetDragMove:b}=(0,i.useDragMove)((()=>{m((e=>({x:e.x+y.x,y:e.y+y.y})))})),C=(0,i.useWindowSize)(),E=C.width/2,P=C.height,[w,k]=o().useState(),_=y.x+h.x,S=y.y+h.y,R=o().useRef([]);return o().useEffect((()=>{e.current&&!t.current&&(t.current=(0,i.createWebgl3DRenderer)(e.current))}),[e.current]),(0,i.useGlobalKeyDown)((e=>{"Escape"===e.key&&b()})),o().useEffect((()=>{const e=[65,59,80,81,56,55,40].map(((e,t)=>[20*(t+1),e,0])),t=[55,49,70,71,46,45,30].map(((e,t)=>[20*(t+1),e,20])),n=[45,39,60,61,36,35,20].map(((e,t)=>[20*(t+1),e,40])),r=[75,69,90,91,66,65,50].map(((e,t)=>[20*(t+1),e,-20])),o=(0,i.getChartAxis3D)([e,t,n,r],{x:20,y:10,z:20});R.current.push(...o,...e.map((e=>({geometry:{type:"cylinder",radius:3,height:e[1]},color:[1,0,0,1],position:[e[0],e[1]/2,e[2]]}))),...t.map((e=>({geometry:{type:"cylinder",radius:3,height:e[1]},color:[0,1,0,1],position:[e[0],e[1]/2,e[2]]}))),...n.map((e=>({geometry:{type:"cylinder",radius:3,height:e[1]},color:[0,0,1,1],position:[e[0],e[1]/2,e[2]]}))),...r.map((e=>({geometry:{type:"cylinder",radius:3,height:e[1]},color:[0,0,0,1],position:[e[0],e[1]/2,e[2]]}))))}),[]),o().useEffect((()=>{var e,o;const{position:a,up:s}=(0,i.updateCamera)(-n,r,200/f,-.3*_,-.3*S);null==(o=null==(e=t.current)?void 0:e.render)||o.call(e,R.current,{eye:[a.x+40,a.y+40,a.z],up:(0,i.position3DToVec3)(s),target:[40-n,r+40,0],fov:(0,i.angleToRadian)(60),near:.1,far:2e3},{position:[1e3,1e3,1e3],color:[1,1,1,1],specular:[1,1,1,1],shininess:50,specularFactor:1},[1,1,1,1])}),[n,r,f,_,S,w,E,P]),o().createElement("div",{style:{position:"absolute",inset:"0px"}},o().createElement("canvas",{ref:(0,i.bindMultipleRefs)(a,g,e),width:E,height:P,onMouseDown:e=>v({x:e.clientX,y:e.clientY}),onMouseMove:e=>{var n,r;k(void 0);const o=null==(r=null==(n=t.current)?void 0:n.pick)?void 0:r.call(n,e.clientX,e.clientY,(e=>"cylinder"===e.geometry.type));if(void 0!==o){const t=R.current[o];t.position&&k({value:t.position,x:e.clientX,y:e.clientY})}}}),w&&o().createElement(i.ChartTooltip,(T=((e,t)=>{for(var n in t||(t={}))u.call(t,n)&&d(e,n,t[n]);if(l)for(var n of l(t))p.call(t,n)&&d(e,n,t[n]);return e})({},w),A={label:(L=w.value[0]/20,Intl.DateTimeFormat("zh",{month:"long"}).format(new Date(L.toString()))),value:w.value[1]},s(T,c(A)))),x);var T,A,L}},2268:(e,t,n)=>{"use strict";n.d(t,{default:()=>f});var r=n(3696),o=n.n(r),i=n(9758),a=Object.defineProperty,s=Object.defineProperties,c=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,u=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable,d=(e,t,n)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;const f=()=>{const e=(0,i.useWindowSize)().width/2,t=i.reactSvgRenderTarget,[n,r]=o().useState(),[a,f]=o().useState(),g=e=>Intl.DateTimeFormat("zh",{month:"long"}).format(new Date((e+1).toString()));if(o().useEffect((()=>{const n=[[65,59,80,81,56,55,40].map((e=>[e])),[55,49,70,71,46,45,30].map((e=>[e])),[45,39,60,61,36,35,30].map((e=>[e-20,e])),[65,59,80,81,56,55,40].map((e=>[e-30,e-15,e-5,e]))],r=[35,29,50,51,26,25,10].map(((e,t)=>({x:t,y:e}))),{children:o,select:a,tx:h,ty:m}=(0,i.getBarChart)(n,[[16711680],[65280],[255],[16711680,65280,255]],((e,n)=>t.renderPolygon((0,i.getRoundedRectPoints)(e,5,30),{fillColor:n,strokeWidth:0})),t,{y:5},{width:e,height:500},{left:25,right:10,top:10,bottom:20},{getXLabel:g,bounding:(0,i.getPointsBounding)(r)}),y=r.map((e=>({x:h(e.x+.5),y:m(e.y)})));o.push(t.renderPolyline(y,{strokeColor:0})),o.push(...y.map((e=>t.renderCircle(e.x,e.y,3,{fillColor:0,strokeWidth:0})))),f({children:o,select:e=>{const t=y.findIndex((t=>(0,i.getTwoPointsDistance)(t,e)<=5));return t>=0?(n=((e,t)=>{for(var n in t||(t={}))u.call(t,n)&&d(e,n,t[n]);if(l)for(var n of l(t))p.call(t,n)&&d(e,n,t[n]);return e})({},y[t]),o={value:r[t]},s(n,c(o))):a(e);var n,o}})}),[e]),!a)return null;let h=a.children;return n&&(h=[...a.children,...(0,i.renderChartTooltip)(t,n,n.value,{getXLabel:g})]),o().createElement("div",{style:{position:"absolute",inset:"0px"}},t.renderResult(h,e,500,{attributes:{onMouseMove:e=>r(a.select({x:e.clientX,y:e.clientY}))}}))}},1406:(e,t,n)=>{"use strict";n.d(t,{CADEditor:()=>_,useInitialStateValidated:()=>L,usePlugins:()=>T});var r=n(3696),o=n.n(r),i=n(9758),a=n(8662),s=n(2852),c=n(7470),l=n(3031),u=n(4469),p=n(9533),d=n(7449),f=n(81),g=n.n(f),h=n(4864),m=Object.defineProperty,y=Object.defineProperties,v=Object.getOwnPropertyDescriptors,x=Object.getOwnPropertySymbols,b=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable,E=(e,t,n)=>t in e?m(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,P=(e,t)=>{for(var n in t||(t={}))b.call(t,n)&&E(e,n,t[n]);if(x)for(var n of x(t))C.call(t,n)&&E(e,n,t[n]);return e},w=(e,t)=>y(e,v(t)),k=(e,t,n)=>new Promise(((r,o)=>{var i=e=>{try{s(n.next(e))}catch(e){o(e)}},a=e=>{try{s(n.throw(e))}catch(e){o(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(i,a);s((n=n.apply(e,t)).next())}));(0,a.enablePatches)(),(0,d.registerRenderer)(i.reactWebglRenderTarget),(0,d.registerRenderer)(i.reactSvgRenderTarget),(0,d.registerRenderer)(i.reactCanvasRenderTarget),navigator.gpu&&(0,d.registerRenderer)(i.reactWebgpuRenderTarget);const _=o().forwardRef(((e,t)=>{var n,r,s,c,l,f,h,m,y,v,x,b,C,E;const _=new i.Debug(e.debug),{width:T,height:A}=(0,i.useWindowSize)(),{filterSelection:L,selected:M,isSelected:I,addSelection:O,removeSelection:D,setSelected:B,isSelectable:z,operations:F,executeOperation:N,resetOperation:U,selectBeforeOperate:G,operate:j,message:V,onSelectBeforeOperateKeyDown:W}=(0,i.useSelectBeforeOperate)({},((e,t)=>{var n;if("command"===(null==e?void 0:e.type)){if(Ue.current)return null==(n=Ue.current)||n.call(Ue,t),Ue.current=void 0,!0;const r=(0,p.getCommand)(e.name);if(null==r?void 0:r.execute)return K((n=>{var o;n=se(n),null==(o=r.execute)||o.call(r,{contents:n,state:Y,selected:t,setEditingContentPath:ce,type:e.name,strokeStyleId:ge,fillStyleId:he,textStyleId:me,width:T,height:A,transform:ht})})),B(),U(),!0}return!1}),{onChange:t=>{var n;return null==(n=e.onSendSelection)?void 0:n.call(e,t.map((e=>e[0])))}}),{snapTypes:H,renderTarget:q,readOnly:$,inputFixed:X}=e,{state:Y,setState:K,undo:Z,redo:Q,canRedo:J,canUndo:ee,applyPatchFromSelf:te,applyPatchFromOtherOperators:ne}=(0,i.usePatchBasedUndoRedo)(e.initialState,e.operator,{onApplyPatchesFromSelf(t,n){var r;const o=[];n.forEach((e=>{if("replace"===e.op&&1===e.path.length&&"length"===e.path[0]&&"number"==typeof e.value)for(let t=e.value;t1){const e=se(r)[t];e&&p.add(e)}if("add"!==e.op||e.path.length>1){const e=se(n)[t];e&&d.add(e)}}else if("length"===t&&"replace"===e.op&&"number"==typeof e.value){const t=se(n)[e.value];t&&d.add(t)}}for(const e of p){const t=(0,i.validate)(e,u.Content);if(!0!==t)return console.error(t),!1}for(const e of p){const t=null==(a=null==(o=(0,u.getContentModel)(e))?void 0:o.getGeometries)?void 0:a.call(o,e,r);(null==t?void 0:t.bounding)?null==Bt||Bt.rtree.insert((0,u.boundingToRTreeBounding)(t.bounding),e):null==Bt||Bt.boundlessContents.add(e)}for(const e of d){const t=null==(c=null==(s=(0,u.getContentModel)(e))?void 0:s.getGeometries)?void 0:c.call(s,e,n);(null==t?void 0:t.bounding)?null==Bt||Bt.rtree.remove((0,u.boundingToRTreeBounding)(t.bounding),e):null==Bt||Bt.boundlessContents.delete(e)}Fn((0,u.zoomContentsToFit)(zn,Bn,r,r,1)),null==(l=e.onChange)||l.call(e,r)}}),{selected:re,setSelected:oe}=(0,i.useSelected)({maxCount:1}),{editingContent:ie,trimPatchPath:ae,getContentByPath:se,setEditingContentPath:ce,prependPatchPath:le}=(0,i.usePartialEdit)(Y,{onEditingContentPathChange(e){On(e)}}),[ue,pe]=o().useState(),de=[],fe=[],ge=null==(n=u.getStrokeStyles(Y).find((e=>e.content.isCurrent)))?void 0:n.index,he=null==(r=u.getFillStyles(Y).find((e=>e.content.isCurrent)))?void 0:r.index,me=null==(s=u.getTextStyles(Y).find((e=>e.content.isCurrent)))?void 0:s.index,[ye,ve]=o().useState(),[xe,be]=o().useState(),[Ce,Ee]=o().useState(),Pe=void 0!==xe?ie[xe]:void 0,we=Pe?null==(l=null==(c=(0,u.getContentModel)(Pe))?void 0:c.getGeometries)?void 0:l.call(c,Pe,ie).bounding:void 0,ke=void 0!==ye?ie[ye]:void 0,_e=ke&&(0,u.isViewportContent)(ke)?ke:void 0,Se=_e&&!_e.locked?_e:void 0,Re=void 0!==ye&&Se?ye:void 0,Te=_e?e=>u.reverseTransformPositionByViewport(e,_e):void 0,Ae=_e?e=>u.transformPositionByViewport(e,_e):void 0,[Le,Me]=o().useState(0),[Ie,Oe]=o().useState(0),[De,Be]=o().useState(1),[ze,Fe]=o().useState(0),Ne=o().useRef(),Ue=o().useRef(),Ge=o().useRef(),[je,Ve]=o().useState(),[We,He]=o().useState([]),{x:qe,y:$e,ref:Xe,setX:Ye,setY:Ke}=(0,i.useWheelScroll)({localStorageXKey:e.id+"-x",localStorageYKey:e.id+"-y",setXOffset:Se?e=>Me((t=>t+e)):void 0,setYOffset:Se?e=>Oe((t=>t+e)):void 0}),{scale:Ze,setScale:Qe,ref:Je}=(0,i.useWheelZoom)({min:S,max:R,localStorageKey:e.id+"-scale",setScaleOffset:Se?(e,t)=>{Be((t=>t*e)),t=(0,i.reverseTransformPosition)(t,ht),Me((n=>(t.x-Se.x)*Ze*(1-e)+n*e)),Oe((n=>(t.y-Se.y)*Ze*(1-e)+n*e))}:void 0,onChange(e,t,n){const r=(0,i.scaleByCursorPosition)({width:T,height:A},t/e,n);Ye(r.setX),Ke(r.setY)}}),[et,tt]=(0,i.useLocalStorageState)(e.id+"-rotate",0),{offset:nt,onStart:rt,mask:ot,resetDragRotate:it}=(0,i.useDragRotate)((()=>{_e&&void 0!==ye?K((e=>{const t=(e=se(e))[ye];t&&(0,u.isViewportContent)(t)&&(t.rotate=ft)})):tt((0,i.angleToRadian)(null==nt?void 0:nt.angle))}),{transformOffset:(e,t)=>{if(t&&void 0!==e&&!t.shiftKey){const t=90*Math.round(e/90);if(Math.abs(t-e)<5)return t}return e}}),{zoomIn:at,zoomOut:st}=(0,i.useZoom)(Ze,Qe,{min:S,max:R}),{offset:ct,onStart:lt,mask:ut,resetDragMove:pt}=(0,i.useDragMove)((()=>{void 0===Re?(Ye((e=>e+ct.x)),Ke((e=>e+ct.y))):te(le(de),le(fe))})),dt=Ze*(null!=(f=null==_e?void 0:_e.scale)?f:1),ft=void 0!==(null==nt?void 0:nt.angle)?(0,i.angleToRadian)(nt.angle):void 0,gt=null!=ft?ft:_e?null!=(h=_e.rotate)?h:0:et,ht={x:qe,y:$e,scale:Ze,center:{x:T/2,y:A/2},rotate:_e?et:null!=ft?ft:et};if(void 0!==Re){const[,e,t]=(0,a.produceWithPatches)(ie,(e=>{const t=e[Re];if(t&&(0,u.isViewportContent)(t)){const e=i.rotatePosition(ct,{x:0,y:0},-et);t.x+=(e.x+Le)/Ze,t.y+=(e.y+Ie)/Ze,t.scale*=De,void 0!==(null==nt?void 0:nt.angle)&&(t.rotate=(0,i.angleToRadian)(nt.angle))}}));de.push(...e),fe.push(...t)}else ht.x+=ct.x,ht.y+=ct.y;(0,i.useDelayedAction)(0!==Le||0!==Ie||1!==De,500,(()=>{te(le(de),le(fe)),Me(0),Oe(0),Be(1)}));const mt=e=>{Ne.current=t=>{e(t.position,t.target)}},yt=(e,t)=>{const n=M,r="operate"===F.type?F.operate:void 0;Ue.current=e=>{t(e.map((e=>({id:e[0],partIndex:e[1]})))),B(...n),r?j(r):U()},B(),G(e,{type:"command",name:""})},vt=e=>(Ae&&(e=Ae(e)),i.transformPosition(e,ht)),{editPoint:xt,editMenu:bt,editLastPosition:Ct,updateEditPreview:Et,onEditMove:Pt,onEditClick:wt,onEditContextMenu:kt,getEditAssistentContents:_t,resetEdit:St}=(0,i.useEdit)(((e,t)=>te(le([...de,...e]),le([...fe,...t]))),(e=>{var t,n;return null==(n=null==(t=(0,u.getContentModel)(e))?void 0:t.getEditPoints)?void 0:n.call(t,e,ie)}),{scale:dt,readOnly:$||"operate"===F.type,contentReadOnly:e=>e.readonly}),{snapOffset:Rt,snapOffsetActive:Tt,snapOffsetInput:At,setSnapOffset:Lt,onSnapOffsetKeyDown:Mt}=function(e){const[t,n]=o().useState(),[r,i]=o().useState(""),[a,s]=o().useState(!1);return{snapOffset:t,snapOffsetActive:a,setSnapOffset:n,onSnapOffsetKeyDown(e){"Escape"===e.key&&(n(void 0),i(""))},snapOffsetInput:e&&o().createElement("input",{placeholder:t?`${t.x},${t.y}`:"x,y",value:r,style:{position:"absolute",left:"104px",bottom:"1px",width:"70px"},onChange:e=>i(e.target.value),onFocus:()=>s(!0),onBlur:()=>s(!1),onKeyDown:e=>{if("Enter"===e.key){if(!r)return n(void 0),void s(!1);const e=r.split(",");if(2===e.length){const t=+e[0],r=+e[1];isNaN(t)||isNaN(r)||(n({x:t,y:r}),i(""),s(!1))}}}})}}("operate"===F.type&&"command"===F.operate.type||"operate"!==F.type&&void 0!==xt),{getSnapAssistentContents:It,getSnapPoint:Ot}=(0,i.usePointSnap)("operate"===F.type&&!(null==(m=(0,p.getCommand)(F.operate.name))?void 0:m.pointSnapDisabled)||void 0!==xt||void 0!==Ne.current,u.getIntersectionPoints,H,u.getContentModel,Rt,5/dt,(e=>({x:i.formatNumber(e.x,.1),y:i.formatNumber(e.y,.1)}))),Dt=e=>Bt?e?[...Bt.rtree.search({x:e.start.x,y:e.start.y,w:e.end.x-e.start.x,h:e.end.y-e.start.y}),...Bt.boundlessContents]:Y:[],[Bt,zt]=o().useState();_.mark("before search");const Ft=e=>(e=(0,i.reverseTransformPosition)(e,ht),Te&&(e=Te(e)),e),Nt=(0,i.getPointsBoundingUnsafe)((0,i.getPolygonFromTwoPointsFormRegion)({start:{x:0,y:0},end:{x:T,y:A}}).map((e=>Ft(e)))),Ut=new Set(Dt(Nt)),Gt=e=>Ut.has(e)||dn.includes(e),jt=[];ie.forEach(((e,t)=>{var n,r,o,i,a,s,c;if(e&&Ut.has(e))if(I([t])){const i=null==(o=null==(r=null==(n=(0,u.getContentModel)(e))?void 0:n.getGeometries)?void 0:r.call(n,e,ie))?void 0:o.lines;jt.push({content:e,path:[t],lines:i})}else for(const n of M)if(2===n.length&&n[0]===t){const t=null==(c=null==(s=null==(a=null==(i=(0,u.getContentModel)(e))?void 0:i.getGeometries)?void 0:a.call(i,e,ie))?void 0:s.lines)?void 0:c[n[1]];t&&jt.push({content:u.geometryLineToContent(t),path:n,lines:[t]})}}));const{commandMask:Vt,commandUpdateSelectedContent:Wt,startCommand:Ht,onCommandMouseDown:qt,onCommandMouseUp:$t,onCommandKeyDown:Xt,onCommandKeyUp:Yt,commandInput:Kt,commandButtons:Zt,commandPanel:Qt,onCommandMouseMove:Jt,commandAssistentContents:en,commandSelected:tn,commandHovering:nn,getCommandByHotkey:rn,commandLastPosition:on,resetCommand:an}=(0,p.useCommands)(((...e)=>k(void 0,[...e],(function*({updateContents:e,nextCommand:t}={}){var n;let r=Y;if(e){const[,...t]=(0,a.produceWithPatches)(ie,(t=>{e(t,M)}));r=yield te(le(t[0]),le(t[1]))}else de.length>0&&(r=yield te(le(de),le(fe)));"operate"===F.type&&"command"===F.operate.type&&(null==(n=(0,p.getCommand)(F.operate.name))?void 0:n.repeatedly)||(U(),t&&Mn({type:"command",name:t},[],se(r)))}))),(e=>Ot(Ft(e),ie,Dt,sn).position),X,"operate"===F.type&&"command"===F.operate.type?F.operate.name:void 0,jt,T,A,qe,$e,et,dt,ge,he,me,ie,e.backgroundColor,yt,(e=>{Ge.current=e}),vt,Dt,Gt,B),sn=null!=Ct?Ct:on,{onStartSelect:cn,dragSelectMask:ln,endDragSelect:un,resetDragSelect:pn}=(0,i.useDragSelect)(((e,t,n)=>{var r,o;if(t){const r=(0,i.getPolygonFromTwoPointsFormRegion)((0,i.getTwoPointsFormRegion)(e,t)).map((e=>Ft(e)));if(Ge.current)return Ge.current(r),void(Ge.current=void 0);if("operate"===F.type&&"zoom window"===F.operate.name){if(void 0!==ye&&_e){const e=(0,u.getViewportByPoints)(_e,r,Y,_e.rotate);return e&&K((t=>{const n=(t=se(t))[ye];n&&(0,u.isViewportContent)(n)&&(n.x=e.x,n.y=e.y,n.scale=e.scale)})),void U()}const e=(0,i.zoomToFitPoints)(r,{width:T,height:A},{x:T/2,y:A/2},1,ht.rotate);return e&&(Qe(e.scale),Ye(e.x),Ke(e.y)),void U()}const o=(0,i.getContentsByRegion)(ie,r,e.x>t.x,!!ht.rotate,u.getContentModel,n.shiftKey?void 0:z,Gt);n.shiftKey?D(...o):O(...o)}else{const t=Ft(e),n=ie.findIndex((e=>{var n,r;return!!e&&(0,u.isViewportContent)(e)&&!!(null==(r=null==(n=(0,u.getContentModel)(e.border))?void 0:n.isPointIn)?void 0:r.call(n,e.border,t,Y))}));if(n>=0){if(ye===n&&_e){const e=(0,u.getDefaultViewport)(_e,Y,_e.rotate);e&&K((t=>{const n=(t=se(t))[ye];n&&(0,u.isViewportContent)(n)&&(n.x=e.x,n.y=e.y,n.scale=e.scale)}))}return void ve(n)}const a=Dt({start:t,end:t}).filter((e=>!!e)).map((e=>(0,u.getContentIndex)(e,ie))),s=(0,i.getContentByClickPosition)(ie,t,(()=>!0),u.getContentModel,!1,Gt,a);if(void 0!==s){const e=ie[s[0]];if(e){const n=null==(o=null==(r=(0,u.getContentModel)(e))?void 0:r.getChildByPoint)?void 0:o.call(r,e,t,Y,{textStyleId:me});n&&(Ee(n.child),n.patches&&te(le(n.patches[0],s),le(n.patches[1],s)))}return void be(s[0])}if(void 0!==xe)return be(void 0),void Ee(void 0);if(void 0!==ye)return void ve(void 0);const c=(0,u.zoomContentsToFit)(T,A,ie,Y,.8,ht.rotate);c&&(Qe(c.scale),Ye(c.x),Ke(c.y))}}));_.mark("before assistent contents");const dn=[],fn=o().useRef(new i.ValueChangedCache);if(H.includes("grid")){const e=fn.current.get(Nt,(()=>i.getGridLines(Nt,10,10,200)));dn.push(...e.map((e=>({type:"line",points:e,strokeOpacity:.2}))))}dn.push(...It((e=>w(P({type:"circle"},e),{strokeColor:65280})),(e=>w(P({type:"rect"},e),{angle:0,strokeColor:65280})),(e=>({type:"polyline",points:e,strokeColor:65280})),(e=>w(P({type:"ray"},e),{strokeColor:65280}))),...en||[]);const gn=Et();if(de.push(...null!=(y=null==gn?void 0:gn.patches)?y:[]),fe.push(...null!=(v=null==gn?void 0:gn.reversePatches)?v:[]),dn.push(...null!=(x=null==gn?void 0:gn.assistentContents)?x:[]),gn&&dn.push(...(0,u.updateReferencedContents)(gn.content,gn.result,ie)),jt.length<100)for(const{content:e,path:t}of jt)if(1===t.length){const n=xt&&(0,i.isSamePath)(xt.path,t)?null==gn?void 0:gn.result:null==gn?void 0:gn.relatedEditPointResults.get(e);dn.push(..._t(null!=n?n:e,(e=>w(P({type:"rect"},e),{fillColor:16777215,angle:0}))))}const hn=Wt(Y);dn.push(...hn.assistentContents);for(const[e,t]of hn.patches)de.push(...e),fe.push(...t);o().useEffect((()=>{var t;return null==(t=e.setCanUndo)?void 0:t.call(e,ee)}),[ee]),o().useEffect((()=>{var t;return null==(t=e.setCanRedo)?void 0:t.call(e,J)}),[J]),o().useEffect((()=>{e.setOperation("select"!==F.type?F.operate.name:void 0)}),[F]);const[mn,yn]=o().useState([]);o().useImperativeHandle(t,(()=>({handlePatchesEvent(e){try{ne(e.patches,e.reversePatches,e.operator)}catch(e){console.error(e)}},handleSelectionEvent(e){yn((0,a.produce)(mn,(t=>{const n=mn.findIndex((t=>t.operator===e.operator));n>=0?t[n].selection=e.selectedContents:t.push({selection:e.selectedContents,operator:e.operator})})))},undo:Z,redo:Q,startOperation:Mn})),[ne]);const{input:vn,inputPosition:xn,setInputPosition:bn,setCursorPosition:Cn,clearText:En}=(0,i.useCursorInput)(V,"operate"===F.type||$?void 0:(e,t)=>{if("Enter"===e.key&&t){const n=rn(t);n&&Mn({type:"command",name:n}),En(),e.stopPropagation()}},{hideIfNoInput:!0,inputStyle:{textTransform:"uppercase"}});let Pn=vn;!$&&vn&&X&&(Pn=o().cloneElement(vn,{style:u.fixedInputStyle}));const wn=(0,i.useEvent)((e=>{e.shiftKey&&e.preventDefault();const t=Ft({x:e.clientX,y:e.clientY}),n=Ot(t,ie,Dt,sn);if(Ne.current)return Ne.current({position:n.position,target:n.target?{id:(0,u.getContentIndex)(n.target.content,Y),snapIndex:n.target.snapIndex,param:n.target.param}:void 0}),void(Ne.current=void 0);if("operate"===F.type&&"command"===F.operate.type&&(null==Ht||Ht(n.position,n.target?{id:(0,u.getContentIndex)(n.target.content,Y),snapIndex:n.target.snapIndex,param:n.target.param}:void 0)),"operate"!==F.type)if(xt)wt(n.position);else if(re.length>0)e.shiftKey?D(...re):O(...re),oe();else{if(void 0!==xe&&!_e)return be(void 0),void Ee(void 0);cn(e)}("operate"===F.type&&"zoom window"===F.operate.name||Ge.current)&&cn(e),Lt(void 0),Ve(void 0)})),kn=(0,i.useEvent)((e=>{e.shiftKey&&e.preventDefault(),"operate"===F.type&&"move canvas"===F.operate.name||4===e.buttons?lt({x:e.clientX,y:e.clientY}):qt&&qt(Ft({x:e.clientX,y:e.clientY}))})),_n=(0,i.useEvent)((e=>{null==$t||$t(Ft({x:e.clientX,y:e.clientY}))})),Sn=(0,i.useEvent)((e=>{const t={x:e.clientX,y:e.clientY};bn(t);const n=Ft(t);if(Cn(n),pe({x:Math.round(n.x),y:Math.round(n.y)}),"operate"===F.type&&"command"===F.operate.type&&Jt){const e=Ot(n,ie,Dt,sn);Jt(e.position,t,e.target?{id:(0,u.getContentIndex)(e.target.content,Y),snapIndex:e.target.snapIndex,param:e.target.param}:void 0)}if("operate"!==F.type){let t;if(xt&&(0,u.isViewportContent)(xt.content)){const e=xt.content;t=Ot(u.reverseTransformPositionByViewport(n,xt.content),ie,Dt,sn,(t=>u.transformPositionByViewport(t,e))),t.target||(t=Ot(n,ie,Dt,sn))}else t=Ot(n,ie,Dt,sn);Pt(t.position,jt,t.target);const r=Dt({start:n,end:n}).filter((e=>!!e)).map((e=>(0,u.getContentIndex)(e,ie)));oe((0,i.getContentByClickPosition)(ie,n,e.shiftKey?()=>!0:z,u.getContentModel,F.select.part,Gt,r,3/dt))}})),Rn=(0,i.useEvent)((e=>{un(e)})),Tn=(0,i.useEvent)((()=>{oe()}));(0,i.useGlobalKeyDown)((e=>{var t;null==Xt||Xt(e),W(e),Mt(e),(0,i.metaKeyIfMacElseCtrlKey)(e)?"Minus"===e.code?st(e):"Equal"===e.code?at(e):"ArrowLeft"===e.key?(void 0!==ye&&we?K((e=>{const t=(e=se(e))[ye];if(t&&(0,u.isViewportContent)(t)){const e=i.rotatePosition({x:(we.end.x-we.start.x)/10,y:0},{x:0,y:0},-et);t.x+=e.x,t.y+=e.y}})):Ye((e=>e+T/10)),e.preventDefault()):"ArrowRight"===e.key?(void 0!==ye&&we?K((e=>{const t=(e=se(e))[ye];if(t&&(0,u.isViewportContent)(t)){const e=i.rotatePosition({x:(we.end.x-we.start.x)/10,y:0},{x:0,y:0},-et);t.x-=e.x,t.y-=e.y}})):Ye((e=>e-T/10)),e.preventDefault()):"ArrowUp"===e.key?(void 0!==ye&&we?K((e=>{const t=(e=se(e))[ye];if(t&&(0,u.isViewportContent)(t)){const e=i.rotatePosition({x:0,y:(we.end.y-we.start.y)/10},{x:0,y:0},-et);t.x+=e.x,t.y+=e.y}})):Ke((e=>e+A/10)),e.preventDefault()):"ArrowDown"===e.key?(void 0!==ye&&we?K((e=>{const t=(e=se(e))[ye];if(t&&(0,u.isViewportContent)(t)){const e=i.rotatePosition({x:0,y:(we.end.y-we.start.y)/10},{x:0,y:0},-et);t.x-=e.x,t.y-=e.y}})):Ke((e=>e-A/10)),e.preventDefault()):"KeyZ"===e.code?"select"===F.type?(e.shiftKey?Q(e):Z(e),B()):(null==(t=(0,p.getCommand)(F.operate.name))?void 0:t.repeatedly)&&(e.shiftKey?Q(e):Z(e)):e.shiftKey||("KeyA"===e.code?(O(...ie.map(((e,t)=>[t]))),e.preventDefault()):"Digit0"===e.code?(Qe(1),Ye(0),Ke(0),e.preventDefault()):"KeyC"===e.code?(Mn({type:"command",name:"copy"}),e.preventDefault()):"KeyV"===e.code?(Mn({type:"command",name:"paste"}),e.preventDefault()):"KeyX"===e.code&&(Mn({type:"command",name:"cut"}),e.preventDefault())):"Escape"===e.key&&(_e||(be(void 0),Ee(void 0)),null==an||an(!0),St(),Ve(void 0),pn(),it(),pt())})),i.useGlobalKeyUp((e=>{null==Yt||Yt(e)}));const[An,Ln]=o().useState(),Mn=(e,t=M,n=ie)=>{if(Ln(e),null==an||an(),"command"===e.type){const r=(0,p.getCommand)(e.name);if(r){const o={count:r.selectCount,part:"select part"===r.selectType,selectable(e){var t,o;const i=(0,u.getContentByIndex)(n,e);return!!i&&(null==(o=null==(t=r.contentSelectable)?void 0:t.call(r,i,n))||o)}},{result:i,needSelect:a}=L(o.selectable,o.count,t);if(a)return void G(o,e);if(N(e,i))return}}if(j(e),ue&&Jt){const e=Ot(ue,n,Dt);Jt(e.position,xn,e.target?{id:(0,u.getContentIndex)(e.target.content,Y),snapIndex:e.target.snapIndex,param:e.target.param}:void 0)}},In=(0,i.useEvent)((e=>k(void 0,null,(function*(){e.preventDefault();const t={x:e.clientX,y:e.clientY},n=Ft(t);if(null==xt?void 0:xt.menu)return void kt(n,((e,n)=>o().createElement(i.Menu,{items:e.map((e=>({title:e.title,onClick:n(e)}))),style:{left:t.x+"px",top:t.y+"px"}})));if(je)return void Ve(void 0);const r=[{title:"Undo",disabled:!ee,onClick:()=>{Z(),Ve(void 0)}},{title:"Redo",disabled:!J,onClick:()=>{Q(),Ve(void 0)}}];An&&r.push({type:"divider"},{title:An.name,onClick:()=>{Mn(An),Ve(void 0)}}),r.push({type:"divider"}),r.push({title:"Create geometry lines",disabled:0===ie.length,onClick:()=>{Mn({type:"command",name:"create geometry lines"}),Ve(void 0)}}),We.length>0&&r.push({title:"Clear markers",onClick:()=>{He([]),Ve(void 0)}}),r.push({title:"Mark",onClick:()=>k(void 0,null,(function*(){try{const e=yield navigator.clipboard.readText();if(e){let t;const n=e.split(",");if(2===n.length){const e=n.map((e=>+e));e.every((e=>!isNaN(e)))&&(t={type:"point",x:e[0],y:e[1]})}if(!t){const n=JSON.parse(e);i.is(n,u.Content)?t=n:i.is(n,i.Position)?t=w(P({},n),{type:"point"}):i.is(n,i.Circle)?t=w(P({},n),{type:"circle"}):i.is(n,i.Ellipse)&&(t=w(P({},n),{type:"ellipse"}))}t&&He([...We,t])}}catch(e){console.info(e)}Ve(void 0)}))}),r.push({type:"divider"}),r.push({title:"Select All",disabled:0===ie.length,onClick:()=>{O(...ie.map(((e,t)=>[t]))),Ve(void 0)}});const a=(0,i.getContentsByClickPosition)(ie,n,e.shiftKey?()=>!0:z,u.getContentModel,Gt,3/dt);a.length>0&&r.push({title:"Select",children:a.map((e=>{var t;return{title:(null==(t=ie[e[0]])?void 0:t.type)+" "+e[0],onClick:()=>{O(e),Ve(void 0)}}}))}),r.push({type:"divider"}),r.push({title:"Cut",disabled:0===M.length,onClick:()=>{Mn({type:"command",name:"cut"}),Ve(void 0)}}),r.push({title:"Copy",disabled:0===M.length,onClick:()=>{Mn({type:"command",name:"copy"}),Ve(void 0)}}),r.push({title:"Paste",onClick:()=>{Mn({type:"command",name:"paste"}),Ve(void 0)}}),r.push({type:"divider"}),r.push({title:"Zoom In",onClick:()=>{at(),Ve(void 0)}}),r.push({title:"Zoom Out",onClick:()=>{st(),Ve(void 0)}}),r.push({title:"Reset",onClick:()=>{Qe(1),Ye(0),Ke(0),Ve(void 0)}}),Ve(o().createElement(i.Menu,{items:r,y:t.y,height:A,style:{left:t.x+"px"}}))})))),On=e=>{var t,n;const r=g()(),o=new Set;for(const i of e){if(!i)continue;const a=null==(n=null==(t=(0,u.getContentModel)(i))?void 0:t.getGeometries)?void 0:n.call(t,i,e);(null==a?void 0:a.bounding)?r.insert((0,u.boundingToRTreeBounding)(a.bounding),i):o.add(i)}zt({rtree:r,boundlessContents:o})};dn.push(...We);const Dn=void 0!==e.onApplyPatchesFromSelf,Bn=100,zn=100;o().useEffect((()=>{On(e.initialState),Fn((0,u.zoomContentsToFit)(zn,Bn,Y,Y,1))}),[e.initialState]);const{setMinimapTransform:Fn,minimap:Nn,getMinimapPosition:Un}=(0,i.useMinimap)({viewport:{width:T/ht.scale,height:A/ht.scale,rotate:ht.rotate,center:(0,i.reverseTransformPosition)(ht.center,ht)},width:zn,height:Bn,children:t=>o().createElement(o().Fragment,null,o().createElement(d.MemoizedRenderer,{type:q,contents:ie,x:t.x,y:t.y,scale:t.scale,width:zn,height:Bn,backgroundColor:e.backgroundColor,debug:e.debug,printMode:e.printMode,performanceMode:!0,operatorVisible:Dn,time:ze,onClick:e=>{if(Un){const t=Un(e);Ye((ht.center.x-t.x)*ht.scale),Ke((ht.center.y-t.y)*ht.scale)}},style:{cursor:"default"}}))}),Gn=e=>{const[,...t]=(0,a.produceWithPatches)(ie,(t=>{jt.forEach((n=>{const r=(0,u.getContentByIndex)(t,n.path);r&&e(r,t)}))}));te(le(t[0]),le(t[1]))};let jn,Vn;if(e.panelVisible&&jt.length>0&&jt.length<100){const e={},t=new Set,n=[],r=[],a=[],s=[];let c=0,l=0;jt.forEach((p=>{var d,f,g,h;t.add(p.content.type);const m=p.path[0];n.push(m);const y=null==(f=null==(d=(0,u.getContentModel)(p.content))?void 0:d.propertyPanel)?void 0:f.call(d,p.content,Gn,Y,{startTime:e=>{const t=performance.now(),n=r=>{const o=r-t;o>=e?Fe(0):(Fe(o),requestAnimationFrame(n))};requestAnimationFrame(n)},activeChild:m===xe?Ce:void 0,acquirePoint:mt,acquireContent:yt});y&&Object.entries(y).forEach((([t,n])=>{const r=e[t],o=Array.from((0,i.iterateItemOrArray)(n));0!==o.length&&(Array.isArray(r)?r.push(...o):e[t]=r?[r,...o]:o)})),r.push(o().createElement(i.BooleanEditor,{value:void 0!==p.content.z,setValue:e=>Gn((t=>{t.z=e?m:void 0}))})),void 0!==p.content.z&&r.push(o().createElement(i.NumberEditor,{value:p.content.z,setValue:e=>Gn((t=>{t.z=e}))})),a.push(o().createElement(i.BooleanEditor,{value:!1!==p.content.visible,setValue:e=>Gn((t=>{t.visible=!!e&&void 0}))})),s.push(o().createElement(i.BooleanEditor,{value:!0===p.content.readonly,setValue:e=>Gn((t=>{t.readonly=!!e||void 0}))}));const v=null==(h=null==(g=(0,u.getContentModel)(p.content))?void 0:g.getArea)?void 0:h.call(g,p.content);v&&(c+=v);const x=u.lengthCache.get(p.content,(()=>{var e,t,n,r;const o=null==(n=null==(t=null==(e=(0,u.getContentModel)(p.content))?void 0:e.getGeometries)?void 0:t.call(e,p.content,Y))?void 0:n.lines;return o&&null!=(r=i.getGeometryLinesLength(o))?r:0}));x&&(l+=x)})),e.z=r,e.visible=a,e.readonly=s,c&&(e.areas=o().createElement(i.NumberEditor,{value:c})),l&&(e.lengths=o().createElement(i.NumberEditor,{value:l})),e.debug=o().createElement(i.Button,{onClick:()=>console.info(jt.map((e=>{var t,n;return[e.content,null==(n=null==(t=(0,u.getContentModel)(e.content))?void 0:t.getGeometries)?void 0:n.call(t,e.content,Y)]})))},"log to console"),jn=o().createElement("div",{style:{position:"absolute",right:"0px",top:"100px",bottom:"0px",width:"400px",overflowY:"auto",background:"white",zIndex:11}},Array.from(t).join(","),o().createElement("div",null,n.join(",")),e&&o().createElement(i.ObjectEditor,{properties:e,readOnly:$}))}Pe&&(Vn=null==(C=null==(b=(0,u.getContentModel)(Pe))?void 0:b.editPanel)?void 0:C.call(b,Pe,dt,Gn,Y,(()=>be(void 0)),vt,Ce)),e.debug&&console.info(_.print());const Wn=o().createElement("div",{ref:(0,i.bindMultipleRefs)(Xe,Je)},o().createElement("div",{style:{cursor:null!=(E=null==xt?void 0:xt.cursor)?E:"operate"===F.type&&"move canvas"===F.operate.name?"grab":"crosshair",position:"absolute",inset:"0px",overflow:"hidden"},onMouseMove:Sn},Bt&&o().createElement(d.MemoizedRenderer,{type:q,contents:ie,previewPatches:0===de.length?void 0:de,assistentContents:0===dn.length?void 0:dn,selected:M.filter((e=>Ut.has(ie[e[0]]))),othersSelectedContents:mn,hovering:re,assistentSelected:tn,assistentHovering:nn,active:xe,activeViewportIndex:ye,onClick:wn,onMouseDown:kn,onMouseUp:_n,onContextMenu:In,onDoubleClick:Rn,onMouseLeave:Tn,x:ht.x,y:ht.y,scale:ht.scale,rotate:ht.rotate,width:T,height:A,backgroundColor:e.backgroundColor,printMode:e.printMode,performanceMode:e.performanceMode,operatorVisible:Dn,debug:e.debug,time:ze}),Nn,o().createElement("div",{style:{width:"100px",height:"100px",left:"1px",top:A-204+"px",boxSizing:"border-box",position:"absolute",transform:`rotate(${gt}rad)`,border:"1px solid black",borderRadius:"50px"}},o().createElement(i.RotationBar,{onMouseDown:()=>rt({x:51,y:A-154})})),ue&&o().createElement("span",{style:{position:"absolute",right:0}},ue.x,",",ue.y),Vt,!Tt&&Pn,!$&&!Tt&&Kt,!$&&!Tt&&Zt,Qt,bt,je,!$&&At),ln,ut,ot);return o().createElement(o().Fragment,null,Wn,jn,Vn)})),S=.001,R=100;function T(){const[e,t]=o().useState([]),[n,r]=o().useState(!1);return o().useEffect((()=>{(()=>{k(this,null,(function*(){try{const e=yield function(){return k(this,null,(function*(){const e=yield Promise.all(h.pluginScripts.map((e=>import("data:text/javascript;charset=utf-8,"+encodeURIComponent(e))))),t=w(P(P({},i),u),{React:o(),produce:a.produce,produceWithPatches:a.produceWithPatches,renderToStaticMarkup:s.renderToStaticMarkup,createRoot:c.createRoot,parseExpression:l.parseExpression,tokenizeExpression:l.tokenizeExpression,evaluateExpression:l.evaluateExpression}),n=[];for(const r of e){if(r.getModel)for(const e of(0,i.iterateItemOrArray)(r.getModel(t)))(0,u.registerModel)(e);if(r.getCommand)for(const e of(0,i.iterateItemOrArray)(r.getCommand(t)))(0,p.registerCommand)(e),e.type?n.push(...e.type):n.push(e)}return n}))}();t(e),r(!0)}catch(e){console.info(e),r(!0)}}))})()}),[]),{pluginCommandTypes:e,pluginLoaded:n}}const A=[(0,i.Nullable)(u.Content)];function L(e,t){const[n,r]=o().useState(!1);return o().useEffect((()=>{if(e&&t){const t=(0,i.validate)(e,A);!0!==t?console.error(t):r(!0)}}),[e,t]),n}},9533:(e,t,n)=>{"use strict";n.d(t,{getCommand:()=>u,registerCommand:()=>d,useCommands:()=>p});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758),s=n(4469);const c={},l={};function u(e){return c[e]}function p(e,t,n,o,u,p,d,f,g,h,m,y,v,x,b,C,E,P,w,k,_,S){let R;return Object.values(c).forEach((n=>{var r;if(n.useCommand){const i=o&&(o===n.name||(null==(r=n.type)?void 0:r.some((e=>e.name===o))))?o:void 0,a=n.useCommand({onEnd:e,transform:t,type:i,selected:u,setSelected:S,width:p,height:d,x:f,y:g,rotate:h,scale:m,strokeStyleId:y,fillStyleId:v,textStyleId:x,contents:b,backgroundColor:C,acquireContent:E,acquireRegion:P,transformPosition:w,getContentsInRange:k,contentVisible:_});i&&(R=a)}})),{commandMask:null==R?void 0:R.mask,commandInput:(null==R?void 0:R.input)?i().cloneElement(R.input,n?{style:s.fixedInputStyle}:{},...R.input.props.children):void 0,commandButtons:(null==R?void 0:R.subcommand)?i().cloneElement(R.subcommand,{style:n?s.fixedButtomStyle:s.fixedInputStyle}):void 0,commandPanel:null==R?void 0:R.panel,commandUpdateSelectedContent(e){const t=[],n=[],o=u.map((e=>e.content));let i=[];for(const{content:r,path:s}of u)if(null==R?void 0:R.updateSelectedContent){const c=R.updateSelectedContent(r,e,o);c.assistentContents&&t.push(...c.assistentContents),c.patches&&n.push([(0,a.prependPatchPath)(c.patches[0],s),(0,a.prependPatchPath)(c.patches[1],s)]),c.newContents&&i.push(...c.newContents)}const c={};for(let t=0;t{var t;const n=(0,s.getContentModel)(e);if(!n)return e;const o=null==(t=n.getRefIds)?void 0:t.call(n,e);return o?o.every((e=>!e||"number"!=typeof e.id||void 0===c[e.id]))?e:(0,r.produce)(e,(e=>{var t;null==(t=n.updateRefId)||t.call(n,e,(e=>"number"==typeof e?c[e]:void 0))})):e})),n.push(...i.map(((t,n)=>[[{op:"add",path:[e.length+n],value:t}],[{op:"replace",path:[e.length+n]}]]))),{assistentContents:t,patches:n}},commandAssistentContents:null==R?void 0:R.assistentContents,commandSelected:null==R?void 0:R.selected,commandHovering:null==R?void 0:R.hovering,startCommand:null==R?void 0:R.onStart,onCommandMouseMove:null==R?void 0:R.onMove,onCommandMouseDown:null==R?void 0:R.onMouseDown,onCommandMouseUp:null==R?void 0:R.onMouseUp,onCommandKeyDown:null==R?void 0:R.onKeyDown,onCommandKeyUp:null==R?void 0:R.onKeyUp,getCommandByHotkey:e=>l[e.toUpperCase()],commandLastPosition:null==R?void 0:R.lastPosition,resetCommand:null==R?void 0:R.reset}}function d(e){if(c[e.name]=e,e.type)for(const t of e.type)t.hotkey&&(l[t.hotkey]=t.name);else e.hotkey&&(l[e.hotkey]=e.name)}},4469:(e,t,n)=>{"use strict";n.r(t),n.d(t,{AngleDeltaFields:()=>A,ArrowFields:()=>R,BaseContent:()=>C,ClipFields:()=>L,ContainerFields:()=>S,Content:()=>E,ContentRef:()=>Zt,FillFields:()=>w,FillStyleContent:()=>ve,PartRef:()=>en,PositionRef:()=>Qt,SegmentCountFields:()=>T,SnapResult:()=>$t,SnapTarget:()=>qt,StrokeFields:()=>P,StrokeStyleContent:()=>me,TextFields:()=>k,TextStyleContent:()=>be,VariableValuesFields:()=>_,ViewportContent:()=>Ee,allContentsCache:()=>q,angleDeltaModel:()=>N,arrowModel:()=>z,assistentTextCache:()=>Wt,boundingToRTreeBounding:()=>bn,breakGeometryLinesToPathCommands:()=>jt,breakPolyline:()=>Ut,clipModel:()=>U,containerModel:()=>B,contentIndexCache:()=>Qe,contentIsClosedPath:()=>rt,contentIsDeletable:()=>nt,contentsBoundingCache:()=>mn,defaultAngleDelta:()=>Xe,defaultOpacity:()=>$e,defaultSegmentCount:()=>He,defaultStrokeColor:()=>qe,deleteFillRefIds:()=>It,deleteSelectedContents:()=>at,deleteStrokeAndFillRefIds:()=>Ot,deleteStrokeRefIds:()=>Mt,deleteTextStyleRefIds:()=>Dt,dimensionStyle:()=>Ye,fillModel:()=>I,fixedButtomStyle:()=>re,fixedInputStyle:()=>ne,fuzzyStyle:()=>cn,geometryLineToContent:()=>ie,geometryLinesToPline:()=>ae,getAngleDeltaContentPropertyPanel:()=>Re,getArrowContentPropertyPanel:()=>_e,getArrowPoints:()=>Vt,getAssistentText:()=>Ht,getClipContentEditPoints:()=>hn,getClipContentPropertyPanel:()=>Ae,getContainerExplode:()=>Ct,getContainerGeometries:()=>gt,getContainerMirror:()=>Et,getContainerMove:()=>yt,getContainerRender:()=>Pt,getContainerRenderIfSelected:()=>wt,getContainerRotate:()=>vt,getContainerScale:()=>xt,getContainerSkew:()=>bt,getContainerSnapPoints:()=>lt,getContainerVariableNames:()=>dt,getContentByIndex:()=>oe,getContentHatchGeometries:()=>xn,getContentIndex:()=>Ze,getContentModel:()=>te,getContentsBounding:()=>mt,getContentsBreak:()=>_t,getContentsExplode:()=>kt,getContentsGeometries:()=>ht,getContentsPoints:()=>se,getContentsSnapPoints:()=>ut,getDefaultStrokeWidth:()=>Ge,getDefaultViewport:()=>Xt,getEditPointsFromCache:()=>K,getFillContentPropertyPanel:()=>we,getFillRefIds:()=>At,getFillRenderOptionsFromRenderContext:()=>pn,getFillStyleContent:()=>Ve,getFillStyles:()=>fe,getGeometriesFromCache:()=>X,getGeometryLineBoundingFromCache:()=>vn,getIntersectionPoints:()=>ee,getPolylineEditPoints:()=>Ke,getRefPart:()=>tn,getRefPosition:()=>Jt,getReference:()=>tt,getSegmentCountContentPropertyPanel:()=>Se,getSnapPointsFromCache:()=>Y,getSnapTargetRef:()=>nn,getSortedContents:()=>et,getStrokeAndFillRefIds:()=>Lt,getStrokeContentPropertyPanel:()=>le,getStrokeFillRenderOptionsFromRenderContext:()=>un,getStrokeRefIds:()=>Tt,getStrokeRenderOptionsFromRenderContext:()=>ln,getStrokeStyleContent:()=>je,getStrokeStyles:()=>pe,getTextContentPropertyPanel:()=>ke,getTextStyleContent:()=>We,getTextStyleRenderOptionsFromRenderContext:()=>dn,getTextStyles:()=>he,getTimeExpressionValue:()=>Q,getVariableValuesContentPropertyPanel:()=>Te,getViewportByPoints:()=>Yt,getViewportByRegion:()=>Kt,getViewportMatrix:()=>on,hasFill:()=>Ue,isAngleDeltaContent:()=>ze,isArrowContent:()=>De,isClipContent:()=>Ne,isContainerContent:()=>Oe,isFillContent:()=>Me,isFillStyleContent:()=>xe,isSegmentCountContent:()=>Be,isStrokeContent:()=>Le,isStrokeStyleContent:()=>ye,isTextContent:()=>Ie,isTextStyleContent:()=>Ce,isVariableValuesContent:()=>Fe,isViewportContent:()=>Pe,iterateAllContents:()=>ct,iterateRefContents:()=>it,iterateRefIds:()=>ot,lengthCache:()=>$,math:()=>c.math,mergePolylines:()=>Gt,registerModel:()=>j,renderClipContent:()=>fn,renderClipContentIfSelected:()=>gn,renderContainerChildren:()=>pt,renderContainerIfSelected:()=>ft,reverseTransformPositionByViewport:()=>sn,segmentCountModel:()=>F,strokeModel:()=>M,textModel:()=>O,toRefId:()=>St,toRefIds:()=>Rt,transformPositionByViewport:()=>an,trimOffsetResult:()=>rn,updateFillRefIds:()=>zt,updateReferencedContents:()=>st,updateStrokeAndFillRefIds:()=>Ft,updateStrokeRefIds:()=>Bt,updateTextStyleRefIds:()=>Nt,variableValuesModel:()=>D,zoomContentsToFit:()=>ce});var r=n(3031),o=n(8662),i=n(3696),a=n.n(i),s=n(9758),c=n(5358),l=Object.defineProperty,u=Object.defineProperties,p=Object.getOwnPropertyDescriptors,d=Object.getOwnPropertySymbols,f=Object.prototype.hasOwnProperty,g=Object.prototype.propertyIsEnumerable,h=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),m=(e,t,n)=>t in e?l(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,y=(e,t)=>{for(var n in t||(t={}))f.call(t,n)&&m(e,n,t[n]);if(d)for(var n of d(t))g.call(t,n)&&m(e,n,t[n]);return e},v=(e,t)=>u(e,p(t)),x=function(e,t){this[0]=e,this[1]=t},b=e=>{var t,n=e[h("asyncIterator")],r=!1,o={};return null==n?(n=e[h("iterator")](),t=e=>o[e]=t=>n[e](t)):(n=n.call(e),t=e=>o[e]=t=>{if(r){if(r=!1,"throw"===e)throw t;return t}return r=!0,{done:!1,value:new x(new Promise((r=>{var o=n[e](t);o instanceof Object||(()=>{throw TypeError("Object expected")})(),r(o)})),1)}}),o[h("iterator")]=()=>o,t("next"),"throw"in n?t("throw"):o.throw=e=>{throw e},"return"in n&&t("return"),o};const C=(e=s.string)=>({type:e,z:(0,s.optional)(s.number),visible:(0,s.optional)(s.boolean),readonly:(0,s.optional)(s.boolean)}),E=(e,t)=>{if(!(0,s.isRecord)(e))return{path:t,expect:"object"};const n=e.type;if("string"!=typeof n)return{path:t,expect:"type"};const r=G[n];return r?r.isValid(e,t):{path:t,expect:"register"}},P={dashArray:(0,s.optional)([(0,s.minimum)(0,s.number)]),strokeColor:(0,s.optional)((0,s.minimum)(0,s.number)),strokeWidth:(0,s.optional)((0,s.minimum)(0,s.number)),strokeStyleId:(0,s.optional)((0,s.or)(s.number,E)),trueStrokeColor:(0,s.optional)(s.boolean),strokeOpacity:(0,s.optional)((0,s.maximum)(1,(0,s.minimum)(0,s.number))),lineJoin:(0,s.optional)((0,s.or)("round","bevel","miter")),miterLimit:(0,s.optional)(s.number),lineCap:(0,s.optional)((0,s.or)("butt","round","square"))},w={fillColor:(0,s.optional)((0,s.minimum)(0,s.number)),fillPattern:(0,s.optional)((0,s.and)(s.Size,{lines:[[s.Position]],strokeColor:(0,s.optional)((0,s.minimum)(0,s.number)),strokeOpacity:(0,s.optional)((0,s.maximum)(1,(0,s.minimum)(0,s.number)))})),fillStyleId:(0,s.optional)((0,s.or)(s.number,E)),trueFillColor:(0,s.optional)(s.boolean),fillOpacity:(0,s.optional)((0,s.maximum)(1,(0,s.minimum)(0,s.number)))},k=(0,s.and)(s.TextStyle,{color:s.number,textStyleId:(0,s.optional)((0,s.or)(s.number,E)),lineHeight:(0,s.optional)(s.number),align:(0,s.optional)(s.Align),verticalAlign:(0,s.optional)(s.VerticalAlign)}),_={variableValues:(0,s.optional)((0,s.record)(s.string,s.string))},S=v(y({},_),{contents:[(0,s.Nullable)(E)]}),R={arrowAngle:(0,s.optional)(s.number),arrowSize:(0,s.optional)((0,s.minimum)(0,s.number))},T={segmentCount:(0,s.optional)(s.number)},A={angleDelta:(0,s.optional)((0,s.exclusiveMinimum)(0,s.number))},L={clip:(0,s.optional)({border:E,reverse:(0,s.optional)(s.boolean)})},M={isStroke:!0},I={isFill:!0},O={isText:!0},D={isVariableValues:!0},B=v(y({},D),{isContainer:!0,canSelectPart:!0}),z={isArrow:!0},F={isSegmentCount:!0},N={isAngleDelta:!0},U={isClip:!0},G={};function j(e){G[e.type]=e}const V=new s.WeakmapValuesCache,W=new s.WeakmapCache,H=new s.WeakmapCache,q=new s.WeakmapCache,$=new s.WeakmapCache,X=V.get.bind(V),Y=W.get.bind(W),K=H.get.bind(H),Z=new s.MapCache;function Q(e,t,n){if(!e||!t)return n;const o=Z.get(e,(()=>{try{return(0,r.parseExpression)((0,r.tokenizeExpression)(e))}catch(e){return console.info(e),null}}));if(o)try{const e=(0,r.evaluateExpression)(o,{t});if("number"==typeof e&&!isNaN(e))return e}catch(e){console.info(e)}return n}const J=new s.WeakmapCache2;function ee(e,t,n){return J.get(e,t,(()=>Array.from((0,s.iterateIntersectionPoints)(e,t,n,te))))}function te(e){return G[e.type]}const ne={position:"absolute",bottom:"10px",left:"190px"},re={position:"absolute",bottom:"30px",left:"190px"};function oe(e,t){var n,r,o,i;const a=e[t[0]];if(!a)return;if(1===t.length)return a;const s=null==(i=null==(o=null==(r=null==(n=te(a))?void 0:n.getGeometries)?void 0:r.call(n,a,e))?void 0:o.lines)?void 0:i[t[1]];return s?ie(s):void 0}function ie(e){return Array.isArray(e)?{type:"line",points:e}:"arc"===e.type?y({type:"arc"},e.curve):"ellipse arc"===e.type?y({type:"ellipse arc"},e.curve):"quadratic curve"===e.type?{type:"path",commands:[{type:"move",to:e.curve.from},{type:"quadraticCurve",cp:e.curve.cp,to:e.curve.to}]}:"bezier curve"===e.type?{type:"path",commands:[{type:"move",to:e.curve.from},{type:"bezierCurve",cp1:e.curve.cp1,cp2:e.curve.cp2,to:e.curve.to}]}:"ray"===e.type?y({type:"ray"},e.line):"hyperbola curve"===e.type?y({type:"hyperbola"},e.curve):y({type:"nurbs"},e.curve)}function ae(e){if(1===e.length)return ie(e[0]);const t={type:"pline",points:[]};for(let n=0;n!0){const r=[];return e.forEach((e=>{if(!e)return;if(!n(e))return;const o=te(e);if(null==o?void 0:o.getGeometries){const{bounding:n}=o.getGeometries(e,t);n&&r.push(n.start,n.end)}})),r}function ce(e,t,n,r,o=.8,i){const a=se(n,r),c=(0,s.getPointsBounding)(a);if(!c)return;const l=(0,s.zoomToFitPoints)(a,{width:e,height:t},{x:e/2,y:t/2},o,i);return l?y({bounding:c},l):void 0}function le(e,t,n){var r;const o=[];if(n){const r=pe(n);r.length>0&&(o.push(a().createElement(s.BooleanEditor,{value:void 0!==e.strokeStyleId,setValue:e=>t((t=>{Le(t)&&(t.strokeStyleId=e?r[0].index:void 0)}))})),"number"==typeof e.strokeStyleId&&o.push(a().createElement(s.EnumEditor,{select:!0,enums:r.map((e=>e.index)),enumTitles:r.map((e=>e.label)),value:e.strokeStyleId,setValue:e=>t((t=>{Le(t)&&(t.strokeStyleId=e)}))})))}return o.length>1?{strokeStyleId:o}:{strokeStyleId:o,dashArray:[a().createElement(s.BooleanEditor,{value:void 0!==e.dashArray,setValue:e=>t((t=>{Le(t)&&(t.dashArray=e?[4]:void 0)}))}),void 0!==e.dashArray?a().createElement(s.ArrayEditor,v(y({inline:!0},(0,s.getArrayEditorProps)((e=>e.dashArray||[]),4,(e=>t((t=>{Le(t)&&e(t)}))))),{items:e.dashArray.map(((e,n)=>a().createElement(s.NumberEditor,{value:e,setValue:e=>t((t=>{Le(t)&&t.dashArray&&(t.dashArray[n]=e)}))})))})):void 0],strokeColor:[a().createElement(s.BooleanEditor,{value:void 0!==e.strokeColor,setValue:e=>t((t=>{Le(t)&&(t.strokeColor=e?0:void 0)}))}),void 0!==e.strokeColor?a().createElement(s.NumberEditor,{type:"color",value:e.strokeColor,setValue:e=>t((t=>{Le(t)&&(t.strokeColor=e)}))}):void 0],trueStrokeColor:a().createElement(s.BooleanEditor,{value:void 0!==e.trueStrokeColor,setValue:e=>t((t=>{Le(t)&&(t.trueStrokeColor=!!e||void 0)}))}),strokeWidth:[a().createElement(s.BooleanEditor,{value:void 0!==e.strokeWidth,setValue:e=>t((t=>{Le(t)&&(t.strokeWidth=e?2:void 0)}))}),void 0!==e.strokeWidth?a().createElement(s.NumberEditor,{value:e.strokeWidth,setValue:e=>t((t=>{Le(t)&&(t.strokeWidth=e)}))}):void 0],strokeOpacity:a().createElement(s.NumberEditor,{value:null!=(r=e.strokeOpacity)?r:1,setValue:e=>t((t=>{Le(t)&&(t.strokeOpacity=1===e?void 0:e)}))}),lineJoin:[a().createElement(s.BooleanEditor,{value:void 0!==e.lineJoin,setValue:e=>t((t=>{Le(t)&&(t.lineJoin=e?s.defaultLineJoin:void 0)}))}),void 0!==e.lineJoin?a().createElement(s.EnumEditor,{enums:["round","bevel","miter"],value:e.lineJoin,setValue:e=>t((t=>{Le(t)&&(t.lineJoin=e)}))}):void 0],miterLimit:[a().createElement(s.BooleanEditor,{value:void 0!==e.miterLimit,setValue:e=>t((t=>{Le(t)&&(t.miterLimit=e?s.defaultMiterLimit:void 0)}))}),void 0!==e.miterLimit?a().createElement(s.NumberEditor,{value:e.miterLimit,setValue:e=>t((t=>{Le(t)&&(t.miterLimit=e)}))}):void 0],lineCap:[a().createElement(s.BooleanEditor,{value:void 0!==e.lineCap,setValue:e=>t((t=>{Le(t)&&(t.lineCap=e?s.defaultLineCap:void 0)}))}),void 0!==e.lineCap?a().createElement(s.EnumEditor,{enums:["butt","round","square"],value:e.lineCap,setValue:e=>t((t=>{Le(t)&&(t.lineCap=e)}))}):void 0]}}const ue=new s.WeakmapCache;function pe(e){return ue.get(e,(()=>e.map(((e,t)=>({c:e,i:t}))).filter((e=>!!e.c&&ye(e.c))).map((({c:e,i:t})=>{var n,r,o,i,a;return{index:t,content:e,label:`${null!=(n=e.strokeWidth)?n:1}px ${null!=(o=null==(r=e.dashArray)?void 0:r.join(","))?o:"solid"} ${(0,s.getColorString)(null!=(i=e.strokeColor)?i:0)} ${null!=(a=e.strokeOpacity)?a:$e}`}}))))}const de=new s.WeakmapCache;function fe(e){return de.get(e,(()=>e.map(((e,t)=>({c:e,i:t}))).filter((e=>!!e.c&&xe(e.c))).map((({c:e,i:t})=>{var n,r;let o="";return e.fillPattern?o=`${e.fillPattern.width}*${e.fillPattern.height} ${(0,s.getColorString)(null!=(n=e.fillPattern.strokeColor)?n:0)} ${JSON.stringify(e.fillPattern.lines)}`:void 0!==e.fillColor&&(o=(0,s.getColorString)(e.fillColor)),{index:t,content:e,label:`${o} ${null!=(r=e.fillOpacity)?r:$e}`}}))))}const ge=new s.WeakmapCache;function he(e){return ge.get(e,(()=>e.map(((e,t)=>({c:e,i:t}))).filter((e=>!!e.c&&Ce(e.c))).map((({c:e,i:t})=>({index:t,content:e,label:`${e.fontFamily} ${e.fontSize} ${(0,s.getColorString)(e.color)}`})))))}const me=(0,s.and)(C("stroke style"),P,s.Region,{isCurrent:(0,s.optional)(s.boolean)});function ye(e){return"stroke style"===e.type}const ve=(0,s.and)(C("fill style"),w,s.Region,{isCurrent:(0,s.optional)(s.boolean)});function xe(e){return"fill style"===e.type}const be=(0,s.and)(C("text style"),k,s.Position,{isCurrent:(0,s.optional)(s.boolean)});function Ce(e){return"text style"===e.type}const Ee=(0,s.and)(C("viewport"),s.Position,P,{border:E,scale:s.number,rotate:(0,s.optional)(s.number),locked:(0,s.optional)(s.boolean),hidden:(0,s.optional)(s.boolean)});function Pe(e){return"viewport"===e.type}function we(e,t,n){var r,o;const i=[];if(n){const r=fe(n);r.length>0&&(i.push(a().createElement(s.BooleanEditor,{value:void 0!==e.fillStyleId,setValue:e=>t((t=>{Me(t)&&(t.fillStyleId=e?r[0].index:void 0)}))})),"number"==typeof e.fillStyleId&&i.push(a().createElement(s.EnumEditor,{select:!0,enums:r.map((e=>e.index)),enumTitles:r.map((e=>e.label)),value:e.fillStyleId,setValue:e=>t((t=>{Me(t)&&(t.fillStyleId=e)}))})))}return i.length>1?{fillStyleId:i}:{fillStyleId:i,fillColor:[a().createElement(s.BooleanEditor,{value:void 0!==e.fillColor,setValue:e=>t((t=>{Me(t)&&(t.fillColor=e?0:void 0)}))}),void 0!==e.fillColor?a().createElement(s.NumberEditor,{type:"color",value:e.fillColor,setValue:e=>t((t=>{Me(t)&&(t.fillColor=e)}))}):void 0],trueFillColor:a().createElement(s.BooleanEditor,{value:void 0!==e.trueFillColor,setValue:e=>t((t=>{Me(t)&&(t.trueFillColor=!!e||void 0)}))}),fillPattern:[a().createElement(s.BooleanEditor,{value:void 0!==e.fillPattern,setValue:e=>t((t=>{Me(t)&&(t.fillPattern=e?{width:10,height:10,lines:[[{x:0,y:5},{x:5,y:0}],[{x:10,y:5},{x:5,y:10}]]}:void 0)}))}),void 0!==e.fillPattern?a().createElement(s.ObjectEditor,{properties:{width:a().createElement(s.NumberEditor,{value:e.fillPattern.width,setValue:e=>t((t=>{Me(t)&&t.fillPattern&&(t.fillPattern.width=e)}))}),height:a().createElement(s.NumberEditor,{value:e.fillPattern.height,setValue:e=>t((t=>{Me(t)&&t.fillPattern&&(t.fillPattern.height=e)}))}),strokeColor:[a().createElement(s.BooleanEditor,{value:void 0!==e.fillPattern.strokeColor,setValue:e=>t((t=>{Me(t)&&t.fillPattern&&(t.fillPattern.strokeColor=e?0:void 0)}))}),void 0!==e.fillPattern.strokeColor?a().createElement(s.NumberEditor,{type:"color",value:e.fillPattern.strokeColor,setValue:e=>t((t=>{Me(t)&&t.fillPattern&&(t.fillPattern.strokeColor=e)}))}):void 0],strokeOpacity:a().createElement(s.NumberEditor,{value:null!=(r=e.fillPattern.strokeOpacity)?r:1,setValue:e=>t((t=>{Me(t)&&t.fillPattern&&(t.fillPattern.strokeOpacity=1===e?void 0:e)}))}),lines:a().createElement(s.ArrayEditor,v(y({},(0,s.getArrayEditorProps)((e=>{var t;return(null==(t=e.fillPattern)?void 0:t.lines)||[]}),[{x:0,y:5},{x:5,y:0}],(e=>t((t=>{Me(t)&&t.fillPattern&&e(t)}))))),{items:e.fillPattern.lines.map(((e,n)=>a().createElement(s.ObjectArrayEditor,v(y({},(0,s.getArrayEditorProps)((e=>e),{x:0,y:5},(e=>t((t=>{Me(t)&&t.fillPattern&&e(t.fillPattern.lines[n])}))))),{properties:e.map(((e,r)=>({x:a().createElement(s.NumberEditor,{value:e.x,setValue:e=>t((t=>{Me(t)&&t.fillPattern&&(t.fillPattern.lines[n][r].x=e)})),style:{width:"70px"}}),y:a().createElement(s.NumberEditor,{value:e.y,setValue:e=>t((t=>{Me(t)&&t.fillPattern&&(t.fillPattern.lines[n][r].y=e)})),style:{width:"70px"}})})))}))))}))}}):void 0],fillOpacity:a().createElement(s.NumberEditor,{value:null!=(o=e.fillOpacity)?o:1,setValue:e=>t((t=>{Me(t)&&(t.fillOpacity=1===e?void 0:e)}))})}}function ke(e,t,n){var r,o;const i=[];if(n){const r=he(n);r.length>0&&(i.push(a().createElement(s.BooleanEditor,{value:void 0!==e.textStyleId,setValue:e=>t((t=>{Ie(t)&&(t.textStyleId=e?r[0].index:void 0)}))})),"number"==typeof e.textStyleId&&i.push(a().createElement(s.EnumEditor,{select:!0,enums:r.map((e=>e.index)),enumTitles:r.map((e=>e.label)),value:e.textStyleId,setValue:e=>t((t=>{Ie(t)&&(t.textStyleId=e)}))})))}return i.length>1?{textStyleId:i}:{textStyleId:i,fontSize:a().createElement(s.NumberEditor,{value:e.fontSize,setValue:e=>t((t=>{Ie(t)&&(t.fontSize=e)}))}),fontFamily:a().createElement(s.StringEditor,{value:e.fontFamily,setValue:e=>t((t=>{Ie(t)&&(t.fontFamily=e)}))}),color:a().createElement(s.NumberEditor,{type:"color",value:e.color,setValue:e=>t((t=>{Ie(t)&&(t.color=e)}))}),lineHeight:[a().createElement(s.BooleanEditor,{value:void 0!==e.lineHeight,setValue:n=>t((t=>{Ie(t)&&(t.lineHeight=n?1.2*e.fontSize:void 0)}))}),void 0!==e.lineHeight?a().createElement(s.NumberEditor,{value:e.lineHeight,setValue:e=>t((t=>{Ie(t)&&(t.lineHeight=e)}))}):void 0],align:a().createElement(s.EnumEditor,{enums:s.aligns,value:null!=(r=e.align)?r:"center",setValue:e=>t((t=>{Ie(t)&&(t.align=e)}))}),verticalAlign:a().createElement(s.EnumEditor,{enums:s.verticalAligns,value:null!=(o=e.verticalAlign)?o:"middle",setValue:e=>t((t=>{Ie(t)&&(t.verticalAlign=e)}))})}}function _e(e,t){return{arrowAngle:[a().createElement(s.BooleanEditor,{value:void 0!==e.arrowAngle,setValue:e=>t((t=>{De(t)&&(t.arrowAngle=e?Ye.arrowAngle:void 0)}))}),void 0!==e.arrowAngle?a().createElement(s.NumberEditor,{value:e.arrowAngle,setValue:e=>t((t=>{De(t)&&(t.arrowAngle=e)}))}):void 0],arrowSize:[a().createElement(s.BooleanEditor,{value:void 0!==e.arrowSize,setValue:e=>t((t=>{De(t)&&(t.arrowSize=e?Ye.arrowSize:void 0)}))}),void 0!==e.arrowSize?a().createElement(s.NumberEditor,{value:e.arrowSize,setValue:e=>t((t=>{De(t)&&(t.arrowSize=e)}))}):void 0]}}function Se(e,t){return{segmentCount:[a().createElement(s.BooleanEditor,{value:void 0!==e.segmentCount,setValue:e=>t((t=>{Be(t)&&(t.segmentCount=e?He:void 0)}))}),void 0!==e.segmentCount?a().createElement(s.NumberEditor,{value:e.segmentCount,setValue:e=>t((t=>{Be(t)&&(t.segmentCount=e)}))}):void 0]}}function Re(e,t){return{angleDelta:[a().createElement(s.BooleanEditor,{value:void 0!==e.angleDelta,setValue:e=>t((t=>{ze(t)&&(t.angleDelta=e?Xe:void 0)}))}),void 0!==e.angleDelta?a().createElement(s.NumberEditor,{value:e.angleDelta,setValue:e=>t((t=>{ze(t)&&(t.angleDelta=e)}))}):void 0]}}function Te(e,t,n){return{variableValues:t.length>0?a().createElement(s.ObjectEditor,{properties:Object.assign({},...t.map((t=>{var r,o;return{[t]:a().createElement(s.StringEditor,{value:null!=(o=null==(r=e.variableValues)?void 0:r[t])?o:"",setValue:e=>n((n=>{Fe(n)&&(n.variableValues||(n.variableValues={}),n.variableValues[t]=e)}))})}})))}):[]}}function Ae(e,t,n,r){const o=a().createElement(s.Button,{onClick:()=>n({count:1,selectable:e=>rt(oe(t,e))},(n=>r((r=>{if(Ne(r)){const o=tn(n[0],t,(t=>t!==e));o&&(r.clip={border:o})}}))))},"select border");let i={};return i=e.clip?{change:o,border:a().createElement(s.Button,{onClick:()=>r((e=>{Ne(e)&&(e.clip=void 0)}))},"remove"),reverse:a().createElement(s.BooleanEditor,{value:!!e.clip.reverse,setValue:e=>r((t=>{Ne(t)&&t.clip&&(t.clip.reverse=!!e||void 0)}))})}:{add:o},{clip:a().createElement(s.ObjectEditor,{properties:i})}}function Le(e){var t;return!!(null==(t=te(e))?void 0:t.isStroke)}function Me(e){var t;return!!(null==(t=te(e))?void 0:t.isFill)}function Ie(e){var t;return!!(null==(t=te(e))?void 0:t.isText)}function Oe(e){var t;return!!(null==(t=te(e))?void 0:t.isContainer)}function De(e){var t;return!!(null==(t=te(e))?void 0:t.isArrow)}function Be(e){var t;return!!(null==(t=te(e))?void 0:t.isSegmentCount)}function ze(e){var t;return!!(null==(t=te(e))?void 0:t.isAngleDelta)}function Fe(e){var t;return!!(null==(t=te(e))?void 0:t.isVariableValues)}function Ne(e){var t;return!!(null==(t=te(e))?void 0:t.isClip)}function Ue(e){return void 0!==e.fillColor||void 0!==e.fillPattern||void 0!==e.fillStyleId}function Ge(e){return Me(e)&&Ue(e)?0:1}function je(e,t){if(void 0!==e.strokeStyleId){const n="number"==typeof e.strokeStyleId?t[e.strokeStyleId]:e.strokeStyleId;if(n&&ye(n))return n}return e}function Ve(e,t){if(void 0!==e.fillStyleId){const n="number"==typeof e.fillStyleId?t[e.fillStyleId]:e.fillStyleId;if(n&&xe(n))return n}return e}function We(e,t){if(void 0!==e.textStyleId){const n="number"==typeof e.textStyleId?t[e.textStyleId]:e.textStyleId;if(n&&Ce(n))return n}return e}const He=100,qe=0,$e=1,Xe=5,Ye={margin:5,arrowAngle:15,arrowSize:10};function Ke(e,t,n,r){const o=e.points,i=!n&&o.length>2&&(0,s.isSamePoint)(o[0],o[o.length-1]),a=[];if(o.forEach(((e,t)=>{if(!n&&t===o.length-1&&i||a.push({pointIndexes:[t],x:e.x,y:e.y}),!r&&t!==o.length-1){const n=o[t+1];a.push({pointIndexes:[t,t+1],x:(e.x+n.x)/2,y:(e.y+n.y)/2})}if(n&&t===o.length-1){const t=o[0];a.push({pointIndexes:[o.length-1,0],x:(e.x+t.x)/2,y:(e.y+t.y)/2})}})),i)for(const e of a)e.pointIndexes.includes(0)?e.pointIndexes.push(o.length-1):e.pointIndexes.includes(o.length-1)&&e.pointIndexes.push(0);return a.map((e=>({x:e.x,y:e.y,cursor:"move",update(n,{cursor:r,start:o,scale:i}){if(!t(n))return;const a=r.x-o.x,s=r.y-o.y;for(const t of e.pointIndexes)n.points[t].x+=a,n.points[t].y+=s;return{assistentContents:[{type:"line",dashArray:[4/i],points:[o,r]}]}}})))}function Ze(e,t){return Qe.get(e,(()=>t.findIndex((t=>e===t))))}const Qe=new s.WeakmapCache,Je=new s.WeakmapCache;function et(e){return Je.get(e,(()=>{const t=e.map(((e,t)=>{var n;return{content:e,index:t,z:null!=(n=null==e?void 0:e.z)?n:t}})),n=(0,o.produce)(t,(e=>{e.sort(((e,t)=>e.z-t.z))}));return{contents:n.map((e=>e.content)),indexes:n.map((e=>e.index))}}))}function tt(e,t,n=e=>!0,r){var o;if("number"!=typeof e)return e&&n(e)?e:void 0;let i=t[e];return!i&&r&&r.length>0&&(i=null==(o=r.find((t=>"add"===t.op&&t.path[0]===e)))?void 0:o.value),i&&n(i)?i:void 0}function nt(e,t){var n,r,o;if(e.readonly)return!1;const i=Ze(e,t);for(const e of ct(t))if(null==(o=null==(r=null==(n=te(e))?void 0:n.getRefIds)?void 0:r.call(n,e))?void 0:o.some((e=>(null==e?void 0:e.id)===i&&e.required)))return!1;return!0}function rt(e){var t;return!!e&&!e.readonly&&void 0!==(null==(t=te(e))?void 0:t.isPointIn)}function*ot(e,t){var n,r;if(e)for(const o of e){if(void 0===o)continue;if(null===o)continue;"number"==typeof o&&(yield o);const e="number"!=typeof o?o:t[o];if(e){const o=null==(r=null==(n=te(e))?void 0:n.getRefIds)?void 0:r.call(n,e);yield*b(ot(null==o?void 0:o.map((e=>null==e?void 0:e.id)),t))}}}function*it(e,t,n){var r,o;if(e)for(const i of e){if(void 0===i)continue;if(null===i)continue;const e="number"!=typeof i.id?i.id:t[i.id];if(e&&!n.includes(e)){yield e;const i=null==(o=null==(r=te(e))?void 0:r.getRefIds)?void 0:o.call(r,e);yield*b(it(i,t,[...n,e]))}}}function at(e,t){for(const n of t)e[n]=void 0;e.forEach(((e,n)=>{var r,o;e&&!t.includes(n)&&(null==(o=null==(r=te(e))?void 0:r.deleteRefId)||o.call(r,e,t))}))}function st(e,t,n,r){var i,a;const s=[],c=Ze(e,n);for(const e of ct(n)){if(null==r?void 0:r.includes(e))continue;const n=te(e);(null==(a=null==(i=null==n?void 0:n.getRefIds)?void 0:i.call(n,e))?void 0:a.some((e=>(null==e?void 0:e.id)===c)))&&s.push((0,o.produce)(e,(e=>{var r;null==(r=n.updateRefId)||r.call(n,e,(e=>{if(e===c)return t}))})))}return s}function*ct(e){for(const t of e)t&&(yield t,Oe(t)&&(yield*b(ct(t.contents))))}function lt(e,t){return ut(e,t)}function ut(e,t,n=e=>e.contents){return Y(e,(()=>{const r=[];return n(e).forEach((e=>{var n,o;if(!e)return;const i=null==(o=null==(n=te(e))?void 0:n.getSnapPoints)?void 0:o.call(n,e,t);i&&r.push(...i)})),r}))}function pt(e,t){t=v(y({},t),{variableContext:y(y({},t.variableContext),e.variableValues)});const n=[];return et(e.contents).contents.forEach((e=>{if(!e)return;const r=te(e);if(null==r?void 0:r.render){const o=r.render;n.push(o(e,t))}})),n}function dt(e){var t,n;const r=new Set;for(const o of e.contents)if(o){const e=null==(n=null==(t=te(o))?void 0:t.getVariableNames)?void 0:n.call(t,o);e&&e.forEach((e=>r.add(e)))}return Array.from(r)}function ft(e,t,n,r){const{bounding:o}=gt(e,t.contents,r,n);if(!o)return t.target.renderEmpty();const i=(0,s.getTwoPointsFormRegionSize)(o);return t.target.renderRect(o.start.x,o.start.y,i.width,i.height,{strokeColor:t.color,dashArray:[4],strokeWidth:t.strokeWidth})}function gt(e,t,n,r){return ht(e,t,n,r)}function ht(e,t,n,r,o=e=>e.contents){const i=new Set(it(n(e),t,r));return X(e,i,(()=>{const n=[],r=[],i=[],a=[];return o(e).forEach((e=>{var o,s;if(!e)return;const c=null==(s=null==(o=te(e))?void 0:o.getGeometries)?void 0:s.call(o,e,t);c&&(n.push(...c.lines),c.bounding&&i.push(c.bounding.start,c.bounding.end),c.renderingLines&&r.push(...c.renderingLines),c.regions&&a.push(...c.regions))})),{lines:n,bounding:(0,s.getPointsBounding)(i),renderingLines:r,regions:a.length>0?a:void 0}}))}function mt(e,t){const n=[];return e.forEach((e=>{var r,o;if(e){const i=null==(o=null==(r=te(e))?void 0:r.getGeometries)?void 0:o.call(r,e,t).bounding;i&&n.push(i.start,i.end)}})),(0,s.getPointsBounding)(n)}function yt(e,t){e.contents.forEach((e=>{var n,r;e&&(null==(r=null==(n=te(e))?void 0:n.move)||r.call(n,e,t))}))}function vt(e,t,n,r){e.contents.forEach((e=>{var o,i;e&&(null==(i=null==(o=te(e))?void 0:o.rotate)||i.call(o,e,t,n,r))}))}function xt(e,t,n,r,o){var i,a;for(let s=0;s{var o,i;e&&(null==(i=null==(o=te(e))?void 0:o.mirror)||i.call(o,e,t,n,r))}))}function Pt(e,t){const n=pt(e,t);return t.target.renderGroup(n)}function wt(e,t,n,r){return ft(e,t,n,r)}function kt(e){return e.filter((e=>!!e))}function _t(e,t,n){const r=[];for(const o of e)if(o){const e=te(o);if((null==e?void 0:e.break)&&e.getGeometries){const i=e.getGeometries(o,n),a=t.filter((e=>i.lines.some((t=>(0,s.isZero)((0,s.getPointAndGeometryLineMinimumDistance)(e,t),.1))))),c=e.break(o,a,n);c?r.push(...c):r.push(o)}}return r}function St(e,t){return void 0!==e?[{id:e,required:t}]:[]}function Rt(e,t){const n=[];if(e)for(const r of e)r&&n.push({id:r,required:t});return n}function Tt(e){return St(e.strokeStyleId)}function At(e){return St(e.fillStyleId)}function Lt(e){return[...St(e.strokeStyleId),...St(e.fillStyleId)]}function Mt(e,t){void 0!==e.strokeStyleId&&t.includes(e.strokeStyleId)&&(e.strokeStyleId=void 0)}function It(e,t){void 0!==e.fillStyleId&&t.includes(e.fillStyleId)&&(e.fillStyleId=void 0)}function Ot(e,t){Mt(e,t),It(e,t)}function Dt(e,t){void 0!==e.textStyleId&&t.includes(e.textStyleId)&&(e.textStyleId=void 0)}function Bt(e,t){if(void 0!==e.strokeStyleId){const n=t(e.strokeStyleId);void 0!==n&&(e.strokeStyleId=n)}}function zt(e,t){if(void 0!==e.fillStyleId){const n=t(e.fillStyleId);void 0!==n&&(e.fillStyleId=n)}}function Ft(e,t){Bt(e,t),zt(e,t)}function Nt(e,t){if(void 0!==e.textStyleId){const n=t(e.textStyleId);void 0!==n&&(e.textStyleId=n)}}function Ut(e,t){const n=(0,s.breakPolylineToPolylines)(e,t).map((e=>({type:"polyline",points:e})));for(const e of n)2===e.points.length&&(e.type="line");return n}function Gt(e){(0,s.mergePolylinesToPolyline)(e);for(const t of e)t.points.length>2&&(t.type="polyline")}function jt(e,t){return(0,s.breakGeometryLines)(e,t).map((e=>({type:"path",commands:(0,s.geometryLineToPathCommands)(e)})))}function Vt(e,t,n){var r,o;const i=null!=(r=n.arrowSize)?r:Ye.arrowSize,a=null!=(o=n.arrowAngle)?o:Ye.arrowAngle;return(0,s.getArrow)(e,t,i,a,n.strokeWidth)}const Wt=new s.MapCache3;function Ht(e,t,n,r,o=16711680){(t=Math.round(t))<12&&(t=12);const i=[];for(let a=0;a({}))),i.push({type:"text",x:n+a*t*.6,y:r,text:s,color:o,fontSize:t,fontFamily:"monospace"})}return i}const qt={snapIndex:s.number,param:(0,s.optional)(s.number),id:s.number},$t={position:s.Position,target:(0,s.optional)(qt)};function Xt(e,t,n){return Yt(e,se(t,t,(e=>!Pe(e))),t,n)}function Yt(e,t,n,r){r&&(t=t.map((e=>(0,s.rotatePosition)(e,{x:0,y:0},r))));const o=(0,s.getPointsBounding)(t);if(o)return Kt(e,o,n)}function Kt(e,t,n){var r,o;const i=null==(o=null==(r=te(e))?void 0:r.getGeometries)?void 0:o.call(r,e,n).bounding;if(!i)return;const a=i.end.x-i.start.x,s=i.end.y-i.start.y,c=t.end.x-t.start.x,l=t.end.y-t.start.y,u=a/c,p=s/l;let d,f=0,g=0;return u!n.includes(e)),r);if(c){const n=te(c);let r=null==(i=null==(o=null==n?void 0:n.getSnapPoints)?void 0:o.call(n,c,t))?void 0:i[e.snapIndex];if(!r&&void 0!==e.param){const o=null==(a=null==n?void 0:n.getGeometries)?void 0:a.call(n,c,t).lines;o&&(r=(0,s.getGeometryLinesPointAtParam)(e.param,o))}return r}}}const en={id:Zt,partIndex:(0,s.optional)(s.number)};function tn(e,t,n=e=>!0,r){var o,i,a;if(void 0!==e){const s=tt(e.id,t,n,r);if(s){const r=te(s);if(void 0!==e.partIndex){const c=null==(a=null==(i=null==(o=null==r?void 0:r.getGeometries)?void 0:o.call(r,s,t))?void 0:i.lines)?void 0:a[e.partIndex];if(c){const e=ie(c);if(e&&n(e))return e}}if(n(s))return s}}}function nn(e,t){return e?{id:Ze(e.content,t),snapIndex:e.snapIndex,param:e.param}:void 0}function rn(e,t,n,r){let o=[];for(let t=0;t0){let n=Ut(Array.from((0,s.iteratePolylineLines)(e)),o);const i=n.filter(((e,t)=>t%2==0)),a=n.filter(((e,t)=>t%2==1));return n=Math.min(...i.map((e=>{var n,o,i,a,c;return null==(c=null!=(a=null==(i=null==(o=null==(n=te(e))?void 0:n.getGeometries)?void 0:o.call(n,e,r))?void 0:i.lines)?a:[])?void 0:c.map((e=>(0,s.getPointAndGeometryLineMinimumDistance)(t,e)))})).flat(2))>Math.min(...a.map((e=>{var n,o,i,a,c;return null==(c=null!=(a=null==(i=null==(o=null==(n=te(e))?void 0:n.getGeometries)?void 0:o.call(n,e,r))?void 0:i.lines)?a:[])?void 0:c.map((e=>(0,s.getPointAndGeometryLineMinimumDistance)(t,e)))})).flat(2))?a:i,Gt(n),n.map((e=>e.points))}return[e]}function on(e){return s.m3.multiply(s.m3.multiply(s.m3.translation(e.x,e.y),s.m3.scaling(e.scale,e.scale)),s.m3.rotation(-(e.rotate||0)))}function an(e,t){return{x:(e=(0,s.rotatePosition)(e,{x:0,y:0},t.rotate||0)).x*t.scale+t.x,y:e.y*t.scale+t.y}}function sn(e,t){return(0,s.rotatePosition)({x:(e.x-t.x)/t.scale,y:(e.y-t.y)/t.scale},{x:0,y:0},-(t.rotate||0))}const cn={lineCap:"round",lineJoin:"round",strokeOpacity:.25};function ln(e,{getStrokeColor:t,time:n,transformStrokeWidth:r,isHoveringOrSelected:o,target:i,contents:a}){var s,c;const l=je(e,a),u=null!=(s=l.strokeWidth)?s:Ge(e),p=r(u),d=o&&p!==u,f=t(l),g=null!=(c=l.strokeOpacity)?c:$e;return{options:y({strokeColor:f,strokeWidth:p,strokeOpacity:g,dashArray:l.dashArray,lineJoin:l.lineJoin,miterLimit:l.miterLimit,lineCap:l.lineCap},d?cn:{}),time:n,contents:a,target:i,fillOptions:y({strokeColor:d?f:void 0,strokeWidth:d?r(0):0,fillColor:d?void 0:f},d?cn:{}),strokeColor:f,strokeOpacity:g}}function un(e,{getStrokeColor:t,getFillColor:n,getFillPattern:r,transformStrokeWidth:o,isHoveringOrSelected:i,time:a,target:s,contents:c,clip:l}){var u,p,d;const f=je(e,c),g=Ve(e,c),h=null!=(u=f.strokeWidth)?u:Ge(e),m=o(h),v=i&&m!==h,x=v&&!h&&void 0!==g.fillColor?g.fillColor:t(f),b=null!=(p=f.strokeOpacity)?p:$e,C=null!=(d=g.fillOpacity)?d:$e;return{options:y({fillColor:n(g),strokeColor:x,strokeWidth:m,strokeOpacity:b,fillPattern:r(g),fillOpacity:C,dashArray:f.dashArray,lineJoin:f.lineJoin,miterLimit:f.miterLimit,lineCap:f.lineCap,clip:l},v?cn:{}),time:a,contents:c,target:s,strokeColor:x,strokeOpacity:b,dashed:!!f.dashArray}}function pn(e,{getFillColor:t,getFillPattern:n,transformStrokeWidth:r,isHoveringOrSelected:o,time:i,target:a,contents:s,clip:c}){var l,u;const p=Ve(e,s),d=r(1),f=o&&1!==d,g=null!=(l=p.fillOpacity)?l:$e,h=null!=(u=t(p))?u:qe;return{options:y({fillColor:h,fillPattern:n(p),fillOpacity:g,clip:c,strokeColor:f?h:void 0,strokeWidth:f?d:0},f?cn:{}),time:i,contents:s,target:a}}function dn(e,{transformStrokeWidth:t,isHoveringOrSelected:n}){const r=t(0),o=n&&0!==r;return v(y({},o?cn:{}),{strokeColor:o?e:void 0,strokeWidth:o?r:void 0})}function fn(e,t,n){var r,o;if(e.clip){const i=te(e.clip.border),a=null==i?void 0:i.render;if(a){if(e.clip.reverse){const a=null==(r=i.getGeometries)?void 0:r.call(i,e.clip.border,n.contents);if(!(null==a?void 0:a.bounding))return t;const c=te(e);if(!c)return t;const l=null==(o=c.getGeometries)?void 0:o.call(c,e,n.contents);return(null==l?void 0:l.bounding)?n.target.renderPath([(0,s.getPolygonFromTwoPointsFormRegion)((0,s.mergeBoundingsUnsafe)([l.bounding,a.bounding])),(0,s.getGeometryLinesPoints)(a.lines)],v(y({},n),{strokeWidth:0,clip:()=>t})):t}return a(e.clip.border,v(y({},n),{transformStrokeWidth:()=>0,clip:()=>t}))}}return t}function gn(e,t,n){if(e.clip){const r=te(e.clip.border),o=null==r?void 0:r.render;if(o)return n.target.renderGroup([t,o(e.clip.border,v(y({},n),{transformColor:e=>e,transformStrokeWidth:()=>n.strokeWidth,getStrokeColor:()=>n.color,getFillColor:()=>{},getFillPattern:()=>{}}))])}return t}function hn(e,t){var n,r;if(!e.clip)return[];const i=null==(r=null==(n=te(e.clip.border))?void 0:n.getEditPoints)?void 0:r.call(n,e.clip.border,t);return i?i.editPoints.map((e=>v(y({},e),{update(t,n){if(!Ne(t))return;if(!t.clip)return;let r;return t.clip.border=(0,o.produce)(t.clip.border,(t=>{e.update&&(r=e.update(t,n))})),r||void 0}}))):[]}const mn=new s.WeakmapCache,yn=new s.WeakmapCache;function vn(e){if(Array.isArray(e)||"ray"!==e.type)return yn.get(e,(()=>(0,s.getGeometryLineBounding)(e)))}function xn(e,t){var n,r;if(!e)return;const o=null==(r=null==(n=te(e))?void 0:n.getGeometries)?void 0:r.call(n,e,t);return!o||o.lines.length>30?void 0:{lines:o.lines,id:Ze(e,t)}}function bn(e){const t=(0,s.getTwoPointsFormRegionSize)(e);return{x:e.start.x-1,y:e.start.y-1,w:t.width+2,h:t.height+2}}},4864:(e,t,n)=>{"use strict";n.d(t,{pluginScripts:()=>r});const r=['// dev/cad-editor/plugins/arrow.plugin.tsx\nfunction getModel(ctx) {\n const ArrowContent = ctx.and(ctx.BaseContent("arrow"), ctx.StrokeFields, ctx.ArrowFields, {\n p1: ctx.Position,\n p2: ctx.Position,\n ref1: ctx.optional(ctx.PositionRef),\n ref2: ctx.optional(ctx.PositionRef)\n });\n const getRefIds = (content) => {\n var _a, _b;\n return [...ctx.getStrokeRefIds(content), ...ctx.toRefIds([(_a = content.ref1) == null ? void 0 : _a.id, (_b = content.ref2) == null ? void 0 : _b.id])];\n };\n function getArrowGeometriesFromCache(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return ctx.getGeometriesFromCache(content, refs, () => {\n var _a, _b;\n const p1 = (_a = ctx.getRefPosition(content.ref1, contents, [content])) != null ? _a : content.p1;\n const p2 = (_b = ctx.getRefPosition(content.ref2, contents, [content])) != null ? _b : content.p2;\n const { arrowPoints, endPoint } = ctx.getArrowPoints(p1, p2, content);\n const points = [p1, endPoint];\n return {\n lines: Array.from(ctx.iteratePolylineLines(points)),\n bounding: ctx.getPointsBounding(points),\n regions: [\n {\n points: arrowPoints,\n lines: Array.from(ctx.iteratePolygonLines(arrowPoints))\n }\n ],\n renderingLines: ctx.dashedPolylineToLines(points, content.dashArray)\n };\n });\n }\n const React = ctx.React;\n return {\n type: "arrow",\n ...ctx.strokeModel,\n ...ctx.arrowModel,\n move(content, offset) {\n ctx.movePoint(content.p1, offset);\n ctx.movePoint(content.p2, offset);\n },\n rotate(content, center, angle) {\n ctx.rotatePoint(content.p1, center, angle);\n ctx.rotatePoint(content.p2, center, angle);\n },\n scale(content, center, sx, sy) {\n ctx.scalePoint(content.p1, center, sx, sy);\n ctx.scalePoint(content.p2, center, sx, sy);\n },\n skew(content, center, sx, sy) {\n ctx.skewPoint(content.p1, center, sx, sy);\n ctx.skewPoint(content.p2, center, sx, sy);\n },\n mirror(content, line) {\n ctx.mirrorPoint(content.p1, line);\n ctx.mirrorPoint(content.p2, line);\n },\n render(content, renderCtx) {\n const { options, target, contents, fillOptions } = ctx.getStrokeRenderOptionsFromRenderContext(content, renderCtx);\n const { regions, renderingLines } = getArrowGeometriesFromCache(content, contents);\n const children = [];\n for (const line of renderingLines) {\n children.push(target.renderPolyline(line, options));\n }\n if (regions) {\n for (let i = 0; i < 2 && i < regions.length; i++) {\n children.push(target.renderPolygon(regions[i].points, fillOptions));\n }\n }\n return target.renderGroup(children);\n },\n getEditPoints(content, contents) {\n return ctx.getEditPointsFromCache(content, () => {\n return {\n editPoints: [\n {\n ...content.p1,\n cursor: "move",\n update(c, { cursor, start, scale, target }) {\n if (!isArrowContent(c)) {\n return;\n }\n c.p1.x += cursor.x - start.x;\n c.p1.y += cursor.y - start.y;\n c.ref1 = ctx.getSnapTargetRef(target, contents);\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n },\n {\n ...content.p2,\n cursor: "move",\n update(c, { cursor, start, scale, target }) {\n if (!isArrowContent(c)) {\n return;\n }\n c.p2.x += cursor.x - start.x;\n c.p2.y += cursor.y - start.y;\n c.ref2 = ctx.getSnapTargetRef(target, contents);\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n }\n ]\n };\n });\n },\n getGeometries: getArrowGeometriesFromCache,\n propertyPanel(content, update, contents, { acquirePoint }) {\n var _a, _b;\n return {\n p1: /* @__PURE__ */ React.createElement(\n ctx.ObjectEditor,\n {\n inline: true,\n properties: {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p, ref) => update((c) => {\n if (isArrowContent(c)) {\n c.p1.x = p.x;\n c.p1.y = p.y;\n c.ref1 = ref;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.p1.x, setValue: (v) => update((c) => {\n if (isArrowContent(c)) {\n c.p1.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.p1.y, setValue: (v) => update((c) => {\n if (isArrowContent(c)) {\n c.p1.y = v;\n }\n }) })\n }\n }\n ),\n p2: /* @__PURE__ */ React.createElement(\n ctx.ObjectEditor,\n {\n inline: true,\n properties: {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p, ref) => update((c) => {\n if (isArrowContent(c)) {\n c.p2.x = p.x;\n c.p2.y = p.y;\n c.ref2 = ref;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.p2.x, setValue: (v) => update((c) => {\n if (isArrowContent(c)) {\n c.p2.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.p2.y, setValue: (v) => update((c) => {\n if (isArrowContent(c)) {\n c.p2.y = v;\n }\n }) })\n }\n }\n ),\n ref1: [\n /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.ref1 !== void 0, readOnly: content.ref1 === void 0, setValue: (v) => update((c) => {\n if (isArrowContent(c) && !v) {\n c.ref1 = void 0;\n }\n }) }),\n content.ref1 !== void 0 && typeof content.ref1.id === "number" ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.ref1.id, setValue: (v) => update((c) => {\n if (isArrowContent(c) && c.ref1) {\n c.ref1.id = v;\n }\n }) }) : void 0,\n content.ref1 !== void 0 ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.ref1.snapIndex, setValue: (v) => update((c) => {\n if (isArrowContent(c) && c.ref1) {\n c.ref1.snapIndex = v;\n }\n }) }) : void 0,\n ((_a = content.ref1) == null ? void 0 : _a.param) !== void 0 ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { readOnly: true, value: content.ref1.param }) : void 0\n ],\n ref2: [\n /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.ref2 !== void 0, readOnly: content.ref2 === void 0, setValue: (v) => update((c) => {\n if (isArrowContent(c) && !v) {\n c.ref2 = void 0;\n }\n }) }),\n content.ref2 !== void 0 && typeof content.ref2.id === "number" ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.ref2.id, setValue: (v) => update((c) => {\n if (isArrowContent(c) && c.ref2) {\n c.ref2.id = v;\n }\n }) }) : void 0,\n content.ref2 !== void 0 ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.ref2.snapIndex, setValue: (v) => update((c) => {\n if (isArrowContent(c) && c.ref2) {\n c.ref2.snapIndex = v;\n }\n }) }) : void 0,\n ((_b = content.ref2) == null ? void 0 : _b.param) !== void 0 ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { readOnly: true, value: content.ref2.param }) : void 0\n ],\n ...ctx.getArrowContentPropertyPanel(content, update),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents)\n };\n },\n isValid: (c, p) => ctx.validate(c, ArrowContent, p),\n getRefIds,\n updateRefId(content, update) {\n if (content.ref1) {\n const newRefId = update(content.ref1.id);\n if (newRefId !== void 0) {\n content.ref1.id = newRefId;\n }\n }\n if (content.ref2) {\n const newRefId = update(content.ref2.id);\n if (newRefId !== void 0) {\n content.ref2.id = newRefId;\n }\n }\n ctx.updateStrokeRefIds(content, update);\n },\n deleteRefId(content, ids) {\n if (content.ref1 && ids.includes(content.ref1.id)) {\n content.ref1 = void 0;\n }\n if (content.ref2 && ids.includes(content.ref2.id)) {\n content.ref2 = void 0;\n }\n ctx.deleteStrokeRefIds(content, ids);\n },\n reverse: (content) => ({\n ...content,\n p1: content.p2,\n p2: content.p1,\n ref1: content.ref2,\n ref2: content.ref1\n })\n };\n}\nfunction isArrowContent(content) {\n return content.type === "arrow";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("g", { transform: "" }, /* @__PURE__ */ React.createElement("polyline", { points: "12,86 81,20", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "88,14 72,39 62,28", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" })));\n return {\n name: "create arrow",\n hotkey: "AR",\n icon,\n useCommand({ onEnd, type, strokeStyleId }) {\n const { line, positionTargets, onClick, onMove, input, lastPosition, reset } = ctx.useLineClickCreate(\n type === "create arrow",\n (c, targets) => onEnd({\n updateContents: (contents) => contents.push({\n type: "arrow",\n p1: c[0],\n p2: c[1],\n ref1: targets[0],\n ref2: targets[1],\n strokeStyleId\n })\n }),\n {\n once: true\n }\n );\n const assistentContents = [];\n if (line) {\n assistentContents.push({\n type: "arrow",\n p1: line[0],\n p2: line[1],\n ref1: positionTargets[0],\n ref2: positionTargets[1],\n strokeStyleId\n });\n }\n return {\n onStart: onClick,\n input,\n onMove,\n assistentContents,\n lastPosition,\n reset\n };\n },\n selectCount: 0\n };\n}\nexport {\n getCommand,\n getModel,\n isArrowContent\n};\n','// dev/cad-editor/plugins/block.plugin.tsx\nfunction getModel(ctx) {\n const React = ctx.React;\n const BlockContent = ctx.and(ctx.BaseContent("block"), ctx.ContainerFields, {\n base: ctx.Position\n });\n const BlockReferenceContent = ctx.and(ctx.BaseContent("block reference"), ctx.Position, ctx.VariableValuesFields, {\n refId: ctx.ContentRef,\n angle: ctx.number,\n scale: ctx.optional(ctx.or(ctx.number, ctx.Position))\n });\n const getBlockRefIds = (content) => ctx.toRefIds(content.contents);\n const getBlockReferenceRefIds = (content) => ctx.toRefId(content.refId, true);\n const blockModel = {\n type: "block",\n ...ctx.containerModel,\n explode: ctx.getContainerExplode,\n render: ctx.getContainerRender,\n renderIfSelected: (content, renderCtx) => ctx.getContainerRenderIfSelected(content, renderCtx, [content], getBlockRefIds),\n getOperatorRenderPosition(content) {\n return content.base;\n },\n getEditPoints(content) {\n return ctx.getEditPointsFromCache(content, () => {\n return {\n editPoints: [\n {\n ...content.base,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isBlockContent(c)) {\n return;\n }\n c.base.x += cursor.x - start.x;\n c.base.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [content.base, cursor] }] };\n }\n }\n ],\n angleSnapStartPoint: content.base\n };\n });\n },\n getSnapPoints: ctx.getContainerSnapPoints,\n getGeometries: (content, contents) => ctx.getContainerGeometries(content, contents, getBlockRefIds, [content]),\n propertyPanel(content, update, _, { acquirePoint }) {\n return {\n base: /* @__PURE__ */ React.createElement(\n ctx.ObjectEditor,\n {\n inline: true,\n properties: {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isBlockContent(c)) {\n c.base.x = p.x;\n c.base.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.base.x, setValue: (v) => update((c) => {\n if (isBlockContent(c)) {\n c.base.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.base.y, setValue: (v) => update((c) => {\n if (isBlockContent(c)) {\n c.base.y = v;\n }\n }) })\n }\n }\n ),\n ...ctx.getVariableValuesContentPropertyPanel(content, ctx.getContainerVariableNames(content), update)\n };\n },\n isValid: (c, p) => ctx.validate(c, BlockContent, p),\n getRefIds: getBlockRefIds\n };\n const blockSnapPointsCache = new ctx.WeakmapCache2();\n function extractContentInBlockReference(target, content, block, contents) {\n let model = ctx.getContentModel(target);\n if (!model) {\n return void 0;\n }\n let newResult;\n const result = ctx.produce(target, (draft) => {\n var _a, _b, _c;\n const scale = ctx.getScaleOptionsScale(content);\n if (scale) {\n const r = (_a = model == null ? void 0 : model.scale) == null ? void 0 : _a.call(model, draft, block.base, scale.x, scale.y, contents);\n if (r) {\n model = ctx.getContentModel(r);\n newResult = r;\n draft = r;\n }\n }\n if (content.angle) {\n (_b = model == null ? void 0 : model.rotate) == null ? void 0 : _b.call(model, draft, block.base, content.angle, contents);\n }\n (_c = model == null ? void 0 : model.move) == null ? void 0 : _c.call(model, draft, content);\n });\n return newResult || result;\n }\n function getBlockReferenceGeometries(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getBlockReferenceRefIds(content), contents, [content]));\n return ctx.getGeometriesFromCache(content, refs, () => {\n const block = ctx.getReference(content.refId, contents, isBlockContent);\n if (block) {\n const lines = [];\n const boundings = [];\n const renderingLines = [];\n const regions = [];\n block.contents.forEach((c) => {\n var _a, _b;\n if (!c) {\n return;\n }\n const extracted = extractContentInBlockReference(c, content, block, contents);\n if (extracted) {\n const r = (_b = (_a = ctx.getContentModel(extracted)) == null ? void 0 : _a.getGeometries) == null ? void 0 : _b.call(_a, extracted, contents);\n if (r) {\n lines.push(...r.lines);\n if (r.bounding) {\n boundings.push(r.bounding);\n }\n if (r.renderingLines) {\n renderingLines.push(...r.renderingLines);\n }\n if (r.regions) {\n regions.push(...r.regions);\n }\n }\n }\n });\n return {\n lines,\n bounding: ctx.mergeBoundingsUnsafe(boundings),\n renderingLines,\n regions\n };\n }\n return { lines: [], renderingLines: [] };\n });\n }\n const blockReferenceModel = {\n type: "block reference",\n ...ctx.variableValuesModel,\n move(content, offset) {\n ctx.movePoint(content, offset);\n },\n rotate(content, center, angle, contents) {\n const block = ctx.getReference(content.refId, contents, isBlockContent);\n if (block) {\n const p = ctx.rotatePoint({ x: content.x + block.base.x, y: content.y + block.base.y }, center, angle);\n content.x = p.x - block.base.x;\n content.y = p.y - block.base.y;\n content.angle += angle;\n }\n },\n scale(content, center, sx, sy, contents) {\n var _a, _b;\n const block = ctx.getReference(content.refId, contents, isBlockContent);\n if (block) {\n const p = { x: content.x + block.base.x, y: content.y + block.base.y };\n ctx.scalePoint(p, center, sx, sy);\n content.x = p.x - block.base.x;\n content.y = p.y - block.base.y;\n const scale = ctx.getScaleOptionsScale(content);\n content.scale = {\n x: ((_a = scale == null ? void 0 : scale.x) != null ? _a : 1) * sx,\n y: ((_b = scale == null ? void 0 : scale.y) != null ? _b : 1) * sy\n };\n }\n },\n explode(content, contents) {\n const block = ctx.getReference(content.refId, contents, isBlockContent);\n if (block) {\n const result = [];\n block.contents.forEach((c) => {\n if (!c) {\n return;\n }\n const extracted = extractContentInBlockReference(c, content, block, contents);\n if (extracted) {\n result.push(extracted);\n }\n });\n return result;\n }\n return [];\n },\n mirror(content, line, angle, contents) {\n var _a, _b;\n const block = ctx.getReference(content.refId, contents, isBlockContent);\n if (block) {\n const p = ctx.mirrorPoint({ x: content.x + block.base.x, y: content.y + block.base.y }, line);\n content.x = p.x - block.base.x;\n content.y = p.y - block.base.y;\n content.angle = 2 * angle - content.angle;\n const scale = ctx.getScaleOptionsScale(content);\n content.scale = {\n x: (_a = scale == null ? void 0 : scale.x) != null ? _a : 1,\n y: -((_b = scale == null ? void 0 : scale.y) != null ? _b : 1)\n };\n }\n },\n render(content, renderCtx) {\n const block = ctx.getReference(content.refId, renderCtx.contents, isBlockContent);\n if (block) {\n const children = ctx.renderContainerChildren({ ...block, variableValues: content.variableValues }, renderCtx);\n return renderCtx.target.renderGroup(children, { translate: content, base: block.base, angle: content.angle, scale: content.scale });\n }\n return renderCtx.target.renderEmpty();\n },\n renderIfSelected(content, renderCtx) {\n const block = ctx.getReference(content.refId, renderCtx.contents, isBlockContent);\n if (block) {\n const children = ctx.renderContainerIfSelected(block, renderCtx, [content], getBlockRefIds);\n return renderCtx.target.renderGroup([children], { translate: content, base: block.base, angle: content.angle, scale: content.scale });\n }\n return renderCtx.target.renderEmpty();\n },\n getOperatorRenderPosition(content, contents) {\n const block = ctx.getReference(content.refId, contents, isBlockContent);\n if (block) {\n return { x: content.x + block.base.x, y: content.y + block.base.y };\n }\n return content;\n },\n getEditPoints(content, contents) {\n const block = ctx.getReference(content.refId, contents, isBlockContent);\n if (!block) {\n return;\n }\n return ctx.getEditPointsFromCache(content, () => {\n const p = { x: content.x + block.base.x, y: content.y + block.base.y };\n return {\n editPoints: [\n {\n ...p,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isBlockReferenceContent(c)) {\n return;\n }\n c.x += cursor.x - start.x;\n c.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [p, cursor] }] };\n }\n }\n ],\n angleSnapStartPoint: p\n };\n });\n },\n getSnapPoints(content, contents) {\n const block = ctx.getReference(content.refId, contents, isBlockContent);\n if (block) {\n return blockSnapPointsCache.get(block, content, () => {\n const result = [];\n block.contents.forEach((c) => {\n var _a;\n if (!c) {\n return;\n }\n const model = ctx.getContentModel(c);\n const extracted = extractContentInBlockReference(c, content, block, contents);\n if (extracted) {\n const r = (_a = model == null ? void 0 : model.getSnapPoints) == null ? void 0 : _a.call(model, extracted, contents);\n if (r) {\n result.push(...r);\n }\n }\n });\n return result;\n });\n }\n return [];\n },\n getGeometries: getBlockReferenceGeometries,\n propertyPanel(content, update, contents, { acquirePoint }) {\n var _a, _b;\n let variableNames = [];\n const block = ctx.getReference(content.refId, contents, isBlockContent);\n if (block) {\n variableNames = ctx.getContainerVariableNames(block);\n }\n const scale = ctx.getScaleOptionsScale(content);\n return {\n refId: typeof content.refId === "number" ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.refId, setValue: (v) => update((c) => {\n if (isBlockReferenceContent(c)) {\n c.refId = v;\n }\n }) }) : [],\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isBlockReferenceContent(c)) {\n c.x = p.x;\n c.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.x, setValue: (v) => update((c) => {\n if (isBlockReferenceContent(c)) {\n c.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.y, setValue: (v) => update((c) => {\n if (isBlockReferenceContent(c)) {\n c.y = v;\n }\n }) }),\n angle: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.angle, setValue: (v) => update((c) => {\n if (isBlockReferenceContent(c)) {\n c.angle = v;\n }\n }) }),\n sx: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: (_a = scale == null ? void 0 : scale.x) != null ? _a : 1, setValue: (v) => update((c) => {\n var _a2;\n if (isBlockReferenceContent(c)) {\n c.scale = { x: v, y: (_a2 = scale == null ? void 0 : scale.y) != null ? _a2 : v };\n }\n }) }),\n sy: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: (_b = scale == null ? void 0 : scale.y) != null ? _b : 1, setValue: (v) => update((c) => {\n var _a2;\n if (isBlockReferenceContent(c)) {\n c.scale = { x: (_a2 = scale == null ? void 0 : scale.x) != null ? _a2 : v, y: v };\n }\n }) }),\n ...ctx.getVariableValuesContentPropertyPanel(content, variableNames, update)\n };\n },\n isValid: (c, p) => ctx.validate(c, BlockReferenceContent, p),\n getRefIds: getBlockReferenceRefIds,\n updateRefId(content, update) {\n const newRefId = update(content.refId);\n if (newRefId !== void 0) {\n content.refId = newRefId;\n }\n }\n };\n return [\n blockModel,\n blockReferenceModel\n ];\n}\nfunction isBlockContent(content) {\n return content.type === "block";\n}\nfunction isBlockReferenceContent(content) {\n return content.type === "block reference";\n}\nfunction getCommand(ctx) {\n function contentSelectable(content, contents) {\n return ctx.contentIsDeletable(content, contents);\n }\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 576 512" }, /* @__PURE__ */ React.createElement("path", { fill: "currentColor", d: "M32 119.4C12.9 108.4 0 87.7 0 64C0 28.7 28.7 0 64 0c23.7 0 44.4 12.9 55.4 32H456.6C467.6 12.9 488.3 0 512 0c35.3 0 64 28.7 64 64c0 23.7-12.9 44.4-32 55.4V392.6c19.1 11.1 32 31.7 32 55.4c0 35.3-28.7 64-64 64c-23.7 0-44.4-12.9-55.4-32H119.4c-11.1 19.1-31.7 32-55.4 32c-35.3 0-64-28.7-64-64c0-23.7 12.9-44.4 32-55.4V119.4zM456.6 96H119.4c-5.6 9.7-13.7 17.8-23.4 23.4V392.6c9.7 5.6 17.8 13.7 23.4 23.4H456.6c5.6-9.7 13.7-17.8 23.4-23.4V119.4c-9.7-5.6-17.8-13.7-23.4-23.4zM128 160c0-17.7 14.3-32 32-32H288c17.7 0 32 14.3 32 32v96c0 17.7-14.3 32-32 32H160c-17.7 0-32-14.3-32-32V160zM256 320h32c35.3 0 64-28.7 64-64V224h64c17.7 0 32 14.3 32 32v96c0 17.7-14.3 32-32 32H288c-17.7 0-32-14.3-32-32V320z" }));\n const referenceIcon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 640 512" }, /* @__PURE__ */ React.createElement("path", { fill: "currentColor", d: "M32 119.4C12.9 108.4 0 87.7 0 64C0 28.7 28.7 0 64 0c23.7 0 44.4 12.9 55.4 32H328.6C339.6 12.9 360.3 0 384 0c35.3 0 64 28.7 64 64c0 23.7-12.9 44.4-32 55.4V232.6c19.1 11.1 32 31.7 32 55.4c0 35.3-28.7 64-64 64c-23.7 0-44.4-12.9-55.4-32H119.4c-11.1 19.1-31.7 32-55.4 32c-35.3 0-64-28.7-64-64c0-23.7 12.9-44.4 32-55.4V119.4zM119.4 96c-5.6 9.7-13.7 17.8-23.4 23.4V232.6c9.7 5.6 17.8 13.7 23.4 23.4H328.6c5.6-9.7 13.7-17.8 23.4-23.4V119.4c-9.7-5.6-17.8-13.7-23.4-23.4H119.4zm192 384c-11.1 19.1-31.7 32-55.4 32c-35.3 0-64-28.7-64-64c0-23.7 12.9-44.4 32-55.4V352h64v40.6c9.7 5.6 17.8 13.7 23.4 23.4H520.6c5.6-9.7 13.7-17.8 23.4-23.4V279.4c-9.7-5.6-17.8-13.7-23.4-23.4h-46c-5.4-15.4-14.6-28.9-26.5-39.6V192h72.6c11.1-19.1 31.7-32 55.4-32c35.3 0 64 28.7 64 64c0 23.7-12.9 44.4-32 55.4V392.6c19.1 11.1 32 31.7 32 55.4c0 35.3-28.7 64-64 64c-23.7 0-44.4-12.9-55.4-32H311.4z" }));\n const blockCommand = {\n name: "create block",\n useCommand({ onEnd, type }) {\n let message = "";\n if (type) {\n message = "specify base point";\n }\n const { input, setInputPosition, resetInput } = ctx.useCursorInput(message);\n return {\n onStart(p) {\n onEnd({\n updateContents: (contents, selected) => {\n const newContent = {\n type: "block",\n contents: contents.filter((c, i) => c && ctx.isSelected([i], selected) && contentSelectable(c, contents)),\n base: p\n };\n ctx.deleteSelectedContents(contents, selected.map((s) => s[0]));\n contents.push(newContent);\n }\n });\n },\n input,\n onMove(_, p) {\n setInputPosition(p);\n },\n reset: resetInput\n };\n },\n contentSelectable,\n hotkey: "B",\n icon\n };\n const blockReferenceCommand = {\n name: "create block reference",\n useCommand({ onEnd, type, scale }) {\n let message = "";\n if (type) {\n message = "specify target point";\n }\n const { input, setInputPosition, cursorPosition, setCursorPosition, resetInput } = ctx.useCursorInput(message);\n return {\n onStart(p) {\n resetInput();\n onEnd({\n updateContents: (contents, selected) => {\n contents.push(\n ...contents.filter((c, i) => !!c && ctx.isSelected([i], selected) && isBlockContent(c)).map((block) => ({\n type: "block reference",\n refId: ctx.getContentIndex(block, contents),\n x: p.x - block.base.x,\n y: p.y - block.base.y,\n angle: 0\n }))\n );\n setCursorPosition(void 0);\n }\n });\n },\n input,\n onMove(p, viewportPosition) {\n setInputPosition(viewportPosition || p);\n if (!type) {\n return;\n }\n setCursorPosition(p);\n },\n updateSelectedContent(content, contents) {\n if (!isBlockContent(content)) {\n return {};\n }\n if (cursorPosition) {\n return {\n newContents: [\n {\n type: "block reference",\n refId: ctx.getContentIndex(content, contents),\n x: cursorPosition.x - content.base.x,\n y: cursorPosition.y - content.base.y,\n angle: 0\n }\n ],\n assistentContents: [\n {\n type: "line",\n dashArray: [4 / scale],\n points: [{ x: content.base.x, y: content.base.y }, cursorPosition]\n }\n ]\n };\n }\n return {};\n },\n reset: resetInput\n };\n },\n contentSelectable: isBlockContent,\n selectCount: 1,\n icon: referenceIcon\n };\n return [blockCommand, blockReferenceCommand];\n}\nexport {\n getCommand,\n getModel,\n isBlockContent,\n isBlockReferenceContent\n};\n','// dev/cad-editor/plugins/break.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 640 512" }, /* @__PURE__ */ React.createElement("path", { fill: "currentColor", d: "M38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2S-1.2 34.7 9.2 42.9l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7L489.3 358.2l90.5-90.5c56.5-56.5 56.5-148 0-204.5c-50-50-128.8-56.5-186.3-15.4l-1.6 1.1c-14.4 10.3-17.7 30.3-7.4 44.6s30.3 17.7 44.6 7.4l1.6-1.1c32.1-22.9 76-19.3 103.8 8.6c31.5 31.5 31.5 82.5 0 114l-96 96-31.9-25C430.9 239.6 420.1 175.1 377 132c-52.2-52.3-134.5-56.2-191.3-11.7L38.8 5.1zM239 162c30.1-14.9 67.7-9.9 92.8 15.3c20 20 27.5 48.3 21.7 74.5L239 162zM406.6 416.4L220.9 270c-2.1 39.8 12.2 80.1 42.2 110c38.9 38.9 94.4 51 143.6 36.3zm-290-228.5L60.2 244.3c-56.5 56.5-56.5 148 0 204.5c50 50 128.8 56.5 186.3 15.4l1.6-1.1c14.4-10.3 17.7-30.3 7.4-44.6s-30.3-17.7-44.6-7.4l-1.6 1.1c-32.1 22.9-76 19.3-103.8-8.6C74 372 74 321 105.5 289.5l61.8-61.8-50.6-39.9z" }));\n return {\n name: "break",\n execute({ contents, selected }) {\n const newContents = [];\n const indexes = [];\n contents.forEach((content, index) => {\n var _a, _b, _c, _d;\n if (content && ctx.isSelected([index], selected) && ((_b = (_a = this.contentSelectable) == null ? void 0 : _a.call(this, content, contents)) != null ? _b : true)) {\n let intersectionPoints = [];\n for (let i = 0; i < contents.length; i++) {\n const c = contents[i];\n if (c && i !== index) {\n const p = i < index ? [c, content] : [content, c];\n intersectionPoints.push(...ctx.getIntersectionPoints(...p, contents));\n }\n }\n intersectionPoints = ctx.deduplicatePosition(intersectionPoints);\n if (intersectionPoints.length > 0) {\n const result = (_d = (_c = ctx.getContentModel(content)) == null ? void 0 : _c.break) == null ? void 0 : _d.call(_c, content, intersectionPoints, contents);\n if (result) {\n newContents.push(...result);\n indexes.push(index);\n }\n }\n }\n });\n ctx.deleteSelectedContents(contents, indexes);\n contents.push(...newContents);\n },\n contentSelectable(content, contents) {\n const model = ctx.getContentModel(content);\n return (model == null ? void 0 : model.break) !== void 0 && ctx.contentIsDeletable(content, contents);\n },\n hotkey: "BR",\n icon\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/brush.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { viewBox: "0 0 1024 1024", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React.createElement("path", { d: "m199.04 672.64 193.984 112 224-387.968-193.92-112-224 388.032zm-23.872 60.16 32.896 148.288 144.896-45.696L175.168 732.8zM455.04 229.248l193.92 112 56.704-98.112-193.984-112-56.64 98.112zM104.32 708.8l384-665.024 304.768 175.936L409.152 884.8h.064l-248.448 78.336L104.32 708.8z", fill: "currentColor" }), /* @__PURE__ */ React.createElement("rect", { x: "600", y: "600", width: "400", height: "400", fill: "currentColor" }));\n return {\n name: "brush",\n useCommand({ onEnd, type, fillStyleId }) {\n const [hatch, setHatch] = React.useState();\n const [preview, setPreview] = React.useState();\n const [inputType, setInputType] = React.useState("circle");\n const assistentContents = [];\n const reset = () => {\n setHatch(void 0);\n setPreview(void 0);\n };\n if (hatch) {\n assistentContents.push({ type: "hatch", border: hatch.border, holes: hatch.holes, fillStyleId });\n }\n if (preview) {\n assistentContents.push({ type: "hatch", border: preview.border, holes: preview.holes, fillStyleId });\n }\n return {\n onMouseDown() {\n if (!type) return;\n if (!hatch) {\n setHatch(preview);\n }\n },\n onMove(p) {\n if (!type) return;\n let h;\n if (inputType === "circle") {\n h = { border: [{ type: "arc", curve: ctx.circleToArc({ x: Math.round(p.x), y: Math.round(p.y), r: 10 }) }], holes: [] };\n } else {\n h = { border: Array.from(ctx.iteratePolygonLines(ctx.getPolygonFromRegion({ x: Math.round(p.x), y: Math.round(p.y), width: 20, height: 20 }))), holes: [] };\n }\n if (hatch) {\n setHatch(ctx.getHatchesUnion(hatch, [h])[0]);\n }\n setPreview(h);\n },\n onMouseUp() {\n if (!type) return;\n if (hatch) {\n onEnd({\n updateContents: (contents) => contents.push({ type: "hatch", border: hatch.border, holes: hatch.holes, fillStyleId })\n });\n reset();\n }\n },\n assistentContents,\n subcommand: type === "brush" ? /* @__PURE__ */ React.createElement("span", null, ["circle", "rect"].map((m) => /* @__PURE__ */ React.createElement("button", { key: m, onClick: () => setInputType(m), style: { position: "relative" } }, m))) : void 0,\n reset\n };\n },\n selectCount: 0,\n icon\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/line-polyline.plugin.tsx\nfunction isLineContent(content) {\n return content.type === "line";\n}\n\n// dev/cad-editor/plugins/center-line.plugin.tsx\nfunction getModel(ctx) {\n const CenterLineReferenceContent = ctx.and(ctx.BaseContent("center line"), {\n ref1: ctx.PartRef,\n ref2: ctx.PartRef\n });\n const getRefIds = (content) => ctx.toRefIds([content.ref1.id, content.ref2.id], true);\n function getCenterLineGeometriesFromCache(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return ctx.getGeometriesFromCache(content, refs, () => {\n const ref1 = ctx.getRefPart(content.ref1, contents, isLineContent);\n const ref2 = ctx.getRefPart(content.ref2, contents, isLineContent);\n if (ref1 && ref2) {\n const line = ctx.maximumBy([\n [ctx.getTwoPointCenter(ref1.points[0], ref2.points[0]), ctx.getTwoPointCenter(ref1.points[1], ref2.points[1])],\n [ctx.getTwoPointCenter(ref1.points[0], ref2.points[1]), ctx.getTwoPointCenter(ref1.points[1], ref2.points[0])]\n ], (v) => ctx.getTwoPointsDistance(...v));\n return {\n lines: [line],\n bounding: ctx.getPointsBounding(line),\n renderingLines: ctx.dashedPolylineToLines(line, [8, 4])\n };\n }\n return { lines: [], renderingLines: [] };\n });\n }\n const React = ctx.React;\n return {\n type: "center line",\n render(content, renderCtx) {\n const { options, target, contents } = ctx.getStrokeRenderOptionsFromRenderContext(content, renderCtx);\n const { renderingLines } = getCenterLineGeometriesFromCache(content, contents);\n return target.renderGroup(renderingLines.map((line) => target.renderPolyline(line, options)));\n },\n getGeometries: getCenterLineGeometriesFromCache,\n propertyPanel(content, update, contents, { acquireContent }) {\n return {\n ref1: [\n /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquireContent({ count: 1, part: true, selectable: (v) => contentSelectable(ctx.getContentByIndex(contents, v)) }, (r) => update((c) => {\n if (isCenterLineContent(c)) {\n c.ref1 = r[0];\n }\n })) }, "select"),\n typeof content.ref1.id === "number" ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.ref1.id, setValue: (v) => update((c) => {\n if (isCenterLineContent(c)) {\n c.ref1.id = v;\n }\n }) }) : void 0,\n content.ref1.partIndex !== void 0 ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.ref1.partIndex, setValue: (v) => update((c) => {\n if (isCenterLineContent(c)) {\n c.ref1.partIndex = v;\n }\n }) }) : void 0\n ],\n ref2: [\n /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquireContent({ count: 1, part: true, selectable: (v) => contentSelectable(ctx.getContentByIndex(contents, v)) }, (r) => update((c) => {\n if (isCenterLineContent(c)) {\n c.ref2 = r[0];\n }\n })) }, "select"),\n typeof content.ref2.id === "number" ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.ref2.id, setValue: (v) => update((c) => {\n if (isCenterLineContent(c)) {\n c.ref2.id = v;\n }\n }) }) : void 0,\n content.ref2.partIndex !== void 0 ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.ref2.partIndex, setValue: (v) => update((c) => {\n if (isCenterLineContent(c)) {\n c.ref2.partIndex = v;\n }\n }) }) : void 0\n ]\n };\n },\n isValid: (c, p) => ctx.validate(c, CenterLineReferenceContent, p),\n getRefIds,\n updateRefId(content, update) {\n const newRefId1 = update(content.ref1.id);\n if (newRefId1 !== void 0) {\n content.ref1.id = newRefId1;\n }\n const newRefId2 = update(content.ref2.id);\n if (newRefId2 !== void 0) {\n content.ref2.id = newRefId2;\n }\n }\n };\n}\nfunction isCenterLineContent(content) {\n return content.type === "center line";\n}\nfunction contentSelectable(content) {\n return !!content && isLineContent(content);\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "48,0 48,100", strokeWidth: "5", strokeDasharray: "8", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "100,0 100,100", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "0,1 0,99", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "create center line",\n icon,\n contentSelectable,\n selectCount: 2,\n selectType: "select part",\n execute({ contents, selected }) {\n contents.push({\n type: "center line",\n ref1: {\n id: selected[0][0],\n partIndex: selected[0][1]\n },\n ref2: {\n id: selected[1][0],\n partIndex: selected[1][1]\n }\n });\n }\n };\n}\nexport {\n getCommand,\n getModel,\n isCenterLineContent\n};\n','// dev/cad-editor/plugins/circle-arc.plugin.tsx\nfunction isCircleContent(content) {\n return content.type === "circle";\n}\nfunction isArcContent(content) {\n return content.type === "arc";\n}\n\n// dev/cad-editor/plugins/center-mark.plugin.tsx\nfunction getModel(ctx) {\n const CenterMarkReferenceContent = ctx.and(ctx.BaseContent("center mark"), {\n ref: ctx.PartRef\n });\n const getRefIds = (content) => ctx.toRefId(content.ref.id, true);\n function getCenterMarkGeometriesFromCache(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return ctx.getGeometriesFromCache(content, refs, () => {\n const target = ctx.getRefPart(content.ref, contents, contentSelectable);\n if (target) {\n const lines = [\n [{ x: target.x - target.r, y: target.y }, { x: target.x + target.r, y: target.y }],\n [{ x: target.x, y: target.y - target.r }, { x: target.x, y: target.y + target.r }]\n ];\n return {\n lines,\n bounding: ctx.getPointsBounding(lines.flat()),\n renderingLines: lines.map((line) => ctx.dashedPolylineToLines(line, [8, 4])).flat()\n };\n }\n return { lines: [], renderingLines: [] };\n });\n }\n const React = ctx.React;\n return {\n type: "center mark",\n render(content, renderCtx) {\n const { options, target, contents } = ctx.getStrokeRenderOptionsFromRenderContext(content, renderCtx);\n const { renderingLines } = getCenterMarkGeometriesFromCache(content, contents);\n return target.renderGroup(renderingLines.map((line) => target.renderPolyline(line, options)));\n },\n getGeometries: getCenterMarkGeometriesFromCache,\n canSelectPart: true,\n propertyPanel(content, update, contents, { acquireContent }) {\n return {\n ref: [\n /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquireContent({ count: 1, part: true, selectable: (v) => contentSelectable(ctx.getContentByIndex(contents, v)) }, (r) => update((c) => {\n if (isCenterMarkContent(c)) {\n c.ref = r[0];\n }\n })) }, "select"),\n typeof content.ref.id === "number" ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.ref.id, setValue: (v) => update((c) => {\n if (isCenterMarkContent(c)) {\n c.ref.id = v;\n }\n }) }) : void 0,\n content.ref.partIndex !== void 0 ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.ref.partIndex, setValue: (v) => update((c) => {\n if (isCenterMarkContent(c)) {\n c.ref.partIndex = v;\n }\n }) }) : void 0\n ]\n };\n },\n isValid: (c, p) => ctx.validate(c, CenterMarkReferenceContent, p),\n getRefIds,\n updateRefId(content, update) {\n const newRefId = update(content.ref.id);\n if (newRefId !== void 0) {\n content.ref.id = newRefId;\n }\n }\n };\n}\nfunction isCenterMarkContent(content) {\n return content.type === "center mark";\n}\nfunction contentSelectable(content) {\n return !!content && (isArcContent(content) || isCircleContent(content));\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "48,0 48,100", strokeWidth: "5", strokeDasharray: "8", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "0,49 100,49", strokeWidth: "5", strokeDasharray: "8", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "create center mark",\n icon,\n contentSelectable,\n selectType: "select part",\n execute({ contents, selected }) {\n contents.push(...selected.map(([index, partIndex]) => ({\n type: "center mark",\n ref: {\n id: index,\n partIndex\n }\n })));\n }\n };\n}\nexport {\n getCommand,\n getModel,\n isCenterMarkContent\n};\n','// dev/cad-editor/plugins/line-polyline.plugin.tsx\nfunction isLineContent(content) {\n return content.type === "line";\n}\n\n// dev/cad-editor/plugins/chamfer.plugin.tsx\nfunction getCommand(ctx) {\n function getChamfers(content1, content2, d1, d2) {\n const result = [];\n if (isLineContent(content1) && isLineContent(content2)) {\n const point = ctx.getTwoLinesIntersectionPoint(content1.points[0], content1.points[1], content2.points[0], content2.points[1]);\n if (point) {\n const p1 = [];\n const a1 = ctx.getPointByLengthAndDirectionSafely(point, d1, content1.points[0]);\n const b1 = ctx.getPointByLengthAndDirectionSafely(point, d1, content1.points[1]);\n if (a1) {\n p1.push(a1);\n }\n if (b1 && (!a1 || !ctx.isSamePoint(a1, b1))) {\n p1.push(b1);\n }\n const p2 = [];\n const a2 = ctx.getPointByLengthAndDirectionSafely(point, d2, content2.points[0]);\n const b2 = ctx.getPointByLengthAndDirectionSafely(point, d2, content2.points[1]);\n if (a2) {\n p2.push(a2);\n }\n if (b2 && (!a2 || !ctx.isSamePoint(a2, b2))) {\n p2.push(b2);\n }\n for (const c1 of p1) {\n for (const c2 of p2) {\n result.push([c1, c2]);\n }\n }\n }\n }\n return result;\n }\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "11,12 57,12 86,41 86,86", strokeWidth: "3", vectorEffect: "non-scaling-stroke", fill: "none", stroke: "currentColor" }));\n return {\n name: "chamfer",\n useCommand({ onEnd, type, selected, scale }) {\n const [candidates, setCandidates] = React.useState([]);\n const [result, setResult] = React.useState();\n let message = "";\n if (type) {\n if (candidates.length > 0) {\n message = "select one result";\n } else {\n message = "input distance";\n }\n }\n const assistentContents = candidates.map((c) => ({\n type: "line",\n points: c,\n dashArray: c === result ? void 0 : [4 / scale]\n }));\n const { input, setInputPosition, setCursorPosition, clearText, resetInput } = ctx.useCursorInput(message, type && candidates.length == 0 ? (e, text) => {\n if (e.key === "Enter") {\n const position = text.split(",");\n if (position.length === 2) {\n const d1 = +position[0];\n const d2 = +position[1];\n if (!isNaN(d1) && !isNaN(d2)) {\n setCandidates(getChamfers(selected[0].content, selected[1].content, d1, d2));\n clearText();\n }\n } else {\n const d = +text;\n if (!isNaN(d)) {\n setCandidates(getChamfers(selected[0].content, selected[1].content, d, d));\n clearText();\n }\n }\n }\n } : void 0);\n const reset = () => {\n setCandidates([]);\n setResult(void 0);\n clearText();\n resetInput();\n };\n return {\n onStart(p) {\n setCursorPosition(p);\n if (result) {\n onEnd({\n updateContents: (contents) => {\n contents.push({ type: "line", points: result });\n }\n });\n setCandidates([]);\n }\n },\n input,\n onMove(p, viewportPosition) {\n setCursorPosition(p);\n setInputPosition(viewportPosition || p);\n setResult(candidates.find((c) => ctx.getPointAndLineSegmentMinimumDistance(p, c[0], c[1]) < 5));\n },\n assistentContents,\n reset\n };\n },\n selectCount: 2,\n contentSelectable: (c) => isLineContent(c),\n selectType: "select part",\n hotkey: "CHA",\n icon\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/line-polyline.plugin.tsx\nfunction isLineContent(content) {\n return content.type === "line";\n}\nfunction isPolyLineContent(content) {\n return content.type === "polyline";\n}\n\n// dev/cad-editor/plugins/circle-arc.plugin.tsx\nfunction getModel(ctx) {\n const CircleContent = ctx.and(ctx.BaseContent("circle"), ctx.StrokeFields, ctx.FillFields, ctx.Circle, {\n xExpression: ctx.optional(ctx.string),\n yExpression: ctx.optional(ctx.string),\n rExpression: ctx.optional(ctx.string)\n });\n const ArcContent = ctx.and(ctx.BaseContent("arc"), ctx.StrokeFields, ctx.FillFields, ctx.AngleDeltaFields, ctx.Arc);\n const getRefIds = (content) => ctx.getStrokeAndFillRefIds(content);\n const circleGeometriesCache = new ctx.WeakmapValuesCache();\n const arcGeometriesCache = new ctx.WeakmapValuesCache();\n function getCircleGeometries(content, contents, time) {\n const quadrantPoints = ctx.getCircleQuadrantPoints(content);\n if (time && (content.xExpression || content.yExpression || content.rExpression)) {\n const x = ctx.getTimeExpressionValue(content.xExpression, time, content.x);\n const y = ctx.getTimeExpressionValue(content.yExpression, time, content.y);\n const r = ctx.getTimeExpressionValue(content.rExpression, time, content.r);\n return { quadrantPoints, ...getArcGeometries(ctx.circleToArc({ ...content, x, y, r }), contents) };\n }\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return circleGeometriesCache.get(content, refs, () => {\n return { quadrantPoints, ...getArcGeometries(ctx.circleToArc(content), contents) };\n });\n }\n function getArcGeometries(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return arcGeometriesCache.get(content, refs, () => {\n var _a;\n const points = ctx.arcToPolyline(content, (_a = content.angleDelta) != null ? _a : ctx.defaultAngleDelta);\n const middleAngle = ctx.getTwoNumberCenter(content.startAngle, ctx.getFormattedEndAngle(content));\n const geometries = {\n lines: [{ type: "arc", curve: content }],\n points,\n start: ctx.getArcPointAtAngle(content, content.startAngle),\n end: ctx.getArcPointAtAngle(content, content.endAngle),\n middle: ctx.getArcPointAtAngle(content, middleAngle),\n bounding: ctx.getArcBounding(content),\n renderingLines: ctx.dashedPolylineToLines(points, content.dashArray)\n };\n if (ctx.hasFill(content)) {\n return {\n ...geometries,\n lines: [],\n points: geometries.points,\n bounding: geometries.bounding,\n regions: [{\n lines: geometries.lines,\n points: geometries.points\n }],\n renderingLines: []\n };\n }\n return geometries;\n });\n }\n const React = ctx.React;\n return [\n {\n type: "circle",\n ...ctx.strokeModel,\n ...ctx.fillModel,\n move(content, offset) {\n ctx.movePoint(content, offset);\n },\n rotate(content, center, angle) {\n ctx.rotatePoint(content, center, angle);\n },\n scale(content, center, sx, sy) {\n if (sx !== sy && !ctx.isZero(sx + sy)) {\n const ellipse = {\n ...content,\n type: "ellipse",\n cx: content.x,\n cy: content.y,\n rx: content.r,\n ry: content.r\n };\n ctx.scaleEllipse(ellipse, center, sx, sy);\n return ellipse;\n }\n ctx.scalePoint(content, center, sx, sy);\n content.r *= Math.abs(sx);\n return;\n },\n skew(content, center, sx, sy) {\n const ellipse = {\n ...content,\n type: "ellipse",\n cx: content.x,\n cy: content.y,\n rx: content.r,\n ry: content.r\n };\n ctx.skewEllipse(ellipse, center, sx, sy);\n return ellipse;\n },\n mirror(content, line) {\n ctx.mirrorPoint(content, line);\n },\n offset(content, point, distance) {\n if (!distance) {\n distance = ctx.getTwoNumbersDistance(ctx.getTwoPointsDistance(point, content), content.r);\n }\n return ctx.getParallelCirclesByDistance(content, distance)[ctx.pointSideToIndex(ctx.getPointSideOfCircle(point, content))];\n },\n break(content, points) {\n if (points.length < 2) {\n return;\n }\n const angles = points.map((p) => ctx.radianToAngle(ctx.getCircleRadian(p, content)));\n angles.sort((a, b) => a - b);\n return angles.map((a, i) => ({\n ...content,\n type: "arc",\n startAngle: a,\n endAngle: i === angles.length - 1 ? angles[0] + 360 : angles[i + 1]\n }));\n },\n render(content, renderCtx) {\n const { options, dashed, time, contents, target } = ctx.getStrokeFillRenderOptionsFromRenderContext(content, renderCtx);\n if (dashed) {\n const { points } = getCircleGeometries(content, contents, time);\n return target.renderPolyline(points, options);\n }\n const x = ctx.getTimeExpressionValue(content.xExpression, time, content.x);\n const y = ctx.getTimeExpressionValue(content.yExpression, time, content.y);\n const r = ctx.getTimeExpressionValue(content.rExpression, time, content.r);\n return target.renderCircle(x, y, r, options);\n },\n getOperatorRenderPosition(content) {\n return content;\n },\n getEditPoints(content, contents) {\n return ctx.getEditPointsFromCache(content, () => {\n const x = content.x;\n const y = content.y;\n const { quadrantPoints } = getCircleGeometries(content, contents);\n const updateEdges = (c, { cursor, scale }) => {\n if (!isCircleContent(c)) {\n return;\n }\n c.r = ctx.getTwoPointsDistance(cursor, c);\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [content, cursor] }] };\n };\n return {\n editPoints: [\n {\n x,\n y,\n cursor: "move",\n type: "move",\n update(c, { cursor, start, scale }) {\n if (!isCircleContent(c)) {\n return;\n }\n c.x += cursor.x - start.x;\n c.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [content, cursor] }] };\n }\n },\n {\n ...quadrantPoints[0],\n cursor: "ew-resize",\n update: updateEdges\n },\n {\n ...quadrantPoints[1],\n cursor: "ns-resize",\n update: updateEdges\n },\n {\n ...quadrantPoints[2],\n cursor: "ew-resize",\n update: updateEdges\n },\n {\n ...quadrantPoints[3],\n cursor: "ns-resize",\n update: updateEdges\n }\n ],\n angleSnapStartPoint: content\n };\n });\n },\n getSnapPoints(content, contents) {\n const { quadrantPoints } = getCircleGeometries(content, contents);\n return ctx.getSnapPointsFromCache(content, () => [\n { x: content.x, y: content.y, type: "center" },\n ...quadrantPoints.map((p) => ({ ...p, type: "endpoint" }))\n ]);\n },\n getGeometries: getCircleGeometries,\n propertyPanel(content, update, contents, { acquirePoint }) {\n return {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isCircleContent(c)) {\n c.x = p.x;\n c.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.x, setValue: (v) => update((c) => {\n if (isCircleContent(c)) {\n c.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.y, setValue: (v) => update((c) => {\n if (isCircleContent(c)) {\n c.y = v;\n }\n }) }),\n r: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.r, setValue: (v) => update((c) => {\n if (isCircleContent(c)) {\n c.r = v;\n }\n }) }),\n xExpression: [\n /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.xExpression !== void 0, setValue: (v) => update((c) => {\n if (isCircleContent(c)) {\n c.xExpression = v ? "" : void 0;\n }\n }) }),\n content.xExpression !== void 0 ? /* @__PURE__ */ React.createElement(ctx.StringEditor, { value: content.xExpression, setValue: (v) => update((c) => {\n if (isCircleContent(c)) {\n c.xExpression = v;\n }\n }) }) : void 0\n ],\n yExpression: [\n /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.yExpression !== void 0, setValue: (v) => update((c) => {\n if (isCircleContent(c)) {\n c.yExpression = v ? "" : void 0;\n }\n }) }),\n content.yExpression !== void 0 ? /* @__PURE__ */ React.createElement(ctx.StringEditor, { value: content.yExpression, setValue: (v) => update((c) => {\n if (isCircleContent(c)) {\n c.yExpression = v;\n }\n }) }) : void 0\n ],\n rExpression: [\n /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.rExpression !== void 0, setValue: (v) => update((c) => {\n if (isCircleContent(c)) {\n c.rExpression = v ? "" : void 0;\n }\n }) }),\n content.rExpression !== void 0 ? /* @__PURE__ */ React.createElement(ctx.StringEditor, { value: content.rExpression, setValue: (v) => update((c) => {\n if (isCircleContent(c)) {\n c.rExpression = v;\n }\n }) }) : void 0\n ],\n ...ctx.getStrokeContentPropertyPanel(content, update, contents),\n ...ctx.getFillContentPropertyPanel(content, update, contents)\n };\n },\n isValid: (c, p) => ctx.validate(c, CircleContent, p),\n getRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n deleteRefId: ctx.deleteStrokeAndFillRefIds,\n isPointIn: (content, point) => ctx.getTwoPointsDistance(content, point) < content.r,\n getArea: (content) => Math.PI * content.r ** 2\n },\n {\n type: "arc",\n ...ctx.strokeModel,\n ...ctx.fillModel,\n ...ctx.angleDeltaModel,\n move(content, offset) {\n ctx.movePoint(content, offset);\n },\n rotate(content, center, angle) {\n ctx.rotateArc(content, center, angle);\n },\n scale(content, center, sx, sy) {\n if (sx !== sy && !ctx.isZero(sx + sy)) {\n const ellipse = {\n ...content,\n type: "ellipse arc",\n cx: content.x,\n cy: content.y,\n rx: content.r,\n ry: content.r\n };\n ctx.scaleEllipseArc(ellipse, center, sx, sy);\n return ellipse;\n }\n ctx.scalePoint(content, center, sx, sy);\n content.r *= Math.abs(sx);\n return;\n },\n skew(content, center, sx, sy) {\n const ellipse = {\n ...content,\n type: "ellipse arc",\n cx: content.x,\n cy: content.y,\n rx: content.r,\n ry: content.r\n };\n ctx.skewEllipseArc(ellipse, center, sx, sy);\n return ellipse;\n },\n mirror(content, line, angle) {\n ctx.mirrorArc(content, line, angle);\n },\n offset(content, point, distance) {\n if (!distance) {\n distance = ctx.getTwoNumbersDistance(ctx.getTwoPointsDistance(point, content), content.r);\n }\n return ctx.getParallelArcsByDistance(content, distance)[ctx.pointSideToIndex(ctx.getPointSideOfArc(point, content))];\n },\n break(content, points) {\n if (points.length === 0) {\n return;\n }\n const angles = points.map((p) => ctx.normalizeAngleInRange(ctx.radianToAngle(ctx.getCircleRadian(p, content)), content));\n angles.sort((a, b) => a - b);\n const result = [];\n if (!ctx.isSameNumber(angles[0], content.startAngle)) {\n result.push({\n ...content,\n type: "arc",\n startAngle: content.startAngle,\n endAngle: angles[0]\n });\n }\n angles.forEach((a, i) => {\n if (i === angles.length - 1) {\n if (!ctx.isSameNumber(a, content.endAngle)) {\n result.push({\n ...content,\n type: "arc",\n startAngle: a,\n endAngle: content.endAngle\n });\n }\n } else {\n result.push({\n ...content,\n type: "arc",\n startAngle: a,\n endAngle: angles[i + 1]\n });\n }\n });\n return result.length > 1 ? result : void 0;\n },\n join(content, target) {\n if (isArcContent(target)) {\n return ctx.mergeArc(content, target);\n }\n if (isLineContent(target) || isPolyLineContent(target)) {\n const newLines = ctx.mergeGeometryLines([{ type: "arc", curve: content }], Array.from(ctx.iteratePolylineLines(target.points)));\n if (newLines) {\n return ctx.geometryLinesToPline(newLines);\n }\n }\n return;\n },\n extend(content, point) {\n const angle = ctx.radianToAngle(ctx.getCircleRadian(point, content));\n const endAngle = ctx.getFormattedEndAngle({ startAngle: content.startAngle, endAngle: angle });\n const startAngle = ctx.getFormattedStartAngle({ startAngle: angle, endAngle: content.endAngle });\n const angle1 = Math.abs(endAngle - content.startAngle);\n const angle2 = Math.abs(content.endAngle - startAngle);\n if (angle1 < angle2) {\n content.endAngle = endAngle;\n } else {\n content.startAngle = startAngle;\n }\n },\n render(content, renderCtx) {\n const { options, dashed, target } = ctx.getStrokeFillRenderOptionsFromRenderContext(content, renderCtx);\n if (dashed) {\n return target.renderPolyline(getArcGeometries(content, renderCtx.contents).points, options);\n }\n return target.renderArc(content.x, content.y, content.r, content.startAngle, content.endAngle, { ...options, counterclockwise: content.counterclockwise });\n },\n renderIfSelected(content, { color, target, strokeWidth, contents }) {\n const { points } = getArcGeometries({ ...content, startAngle: content.endAngle, endAngle: content.startAngle }, contents);\n return target.renderPolyline(points, { strokeColor: color, dashArray: [4], strokeWidth });\n },\n getOperatorRenderPosition(content, contents) {\n const { points } = getArcGeometries(content, contents);\n return points[0];\n },\n getEditPoints(content, contents) {\n return ctx.getEditPointsFromCache(content, () => {\n const { start, end, middle } = getArcGeometries(content, contents);\n return {\n editPoints: [\n {\n x: content.x,\n y: content.y,\n cursor: "move",\n type: "move",\n update(c, { cursor, start: start2, scale }) {\n if (!isArcContent(c)) {\n return;\n }\n c.x += cursor.x - start2.x;\n c.y += cursor.y - start2.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [content, cursor] }] };\n }\n },\n {\n ...start,\n cursor: ctx.getResizeCursor(content.startAngle, "top"),\n update(c, { cursor, scale }) {\n if (!isArcContent(c)) {\n return;\n }\n c.startAngle = ctx.radianToAngle(ctx.getCircleRadian(cursor, c));\n c.r = ctx.getTwoPointsDistance(cursor, c);\n ctx.normalizeAngleRange(c);\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [content, cursor] }] };\n }\n },\n {\n ...end,\n cursor: ctx.getResizeCursor(content.endAngle, "top"),\n update(c, { cursor, scale }) {\n if (!isArcContent(c)) {\n return;\n }\n c.endAngle = ctx.radianToAngle(ctx.getCircleRadian(cursor, c));\n c.r = ctx.getTwoPointsDistance(cursor, c);\n ctx.normalizeAngleRange(c);\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [content, cursor] }] };\n }\n },\n {\n ...middle,\n cursor: ctx.getResizeCursor((content.startAngle + content.endAngle) / 2, "right"),\n update(c, { cursor, scale }) {\n if (!isArcContent(c)) {\n return;\n }\n c.r = ctx.getTwoPointsDistance(cursor, c);\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [content, cursor] }] };\n }\n }\n ],\n angleSnapStartPoint: content\n };\n });\n },\n getSnapPoints(content, contents) {\n return ctx.getSnapPointsFromCache(content, () => {\n const { start, end, middle } = getArcGeometries(content, contents);\n return [\n { x: content.x, y: content.y, type: "center" },\n { ...start, type: "endpoint" },\n { ...end, type: "endpoint" },\n { ...middle, type: "midpoint" }\n ];\n });\n },\n getGeometries: getArcGeometries,\n propertyPanel(content, update, contents, { acquirePoint }) {\n return {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isArcContent(c)) {\n c.x = p.x;\n c.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.x, setValue: (v) => update((c) => {\n if (isArcContent(c)) {\n c.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.y, setValue: (v) => update((c) => {\n if (isArcContent(c)) {\n c.y = v;\n }\n }) }),\n r: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.r, setValue: (v) => update((c) => {\n if (isArcContent(c)) {\n c.r = v;\n }\n }) }),\n startAngle: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.startAngle, setValue: (v) => update((c) => {\n if (isArcContent(c)) {\n c.startAngle = v;\n }\n }) }),\n endAngle: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.endAngle, setValue: (v) => update((c) => {\n if (isArcContent(c)) {\n c.endAngle = v;\n }\n }) }),\n counterclockwise: /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.counterclockwise === true, setValue: (v) => update((c) => {\n if (isArcContent(c)) {\n c.counterclockwise = v ? true : void 0;\n }\n }) }),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents),\n ...ctx.getFillContentPropertyPanel(content, update, contents),\n ...ctx.getAngleDeltaContentPropertyPanel(content, update)\n };\n },\n isValid: (c, p) => ctx.validate(c, ArcContent, p),\n getRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n deleteRefId: ctx.deleteStrokeAndFillRefIds,\n getArea: (content) => {\n const radian = ctx.angleToRadian(content.endAngle - content.startAngle);\n return content.r ** 2 * (radian - Math.sin(radian)) / 2;\n },\n reverse: (content) => ctx.reverseArc(content)\n }\n ];\n}\nfunction isCircleContent(content) {\n return content.type === "circle";\n}\nfunction isArcContent(content) {\n return content.type === "arc";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const circleIcon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("circle", { cx: "44", cy: "48", r: "39", strokeWidth: "2", vectorEffect: "non-scaling-stroke", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "44,48 66,15", strokeWidth: "2", vectorEffect: "non-scaling-stroke", fill: "none", stroke: "currentColor" }));\n const icon2 = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("circle", { cx: "44", cy: "48", r: "39", strokeWidth: "2", vectorEffect: "non-scaling-stroke", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "18", cy: "20", r: "12", strokeWidth: "0", vectorEffect: "non-scaling-stroke", fill: "currentColor", stroke: "#000000" }), /* @__PURE__ */ React.createElement("circle", { cx: "72", cy: "76", r: "12", strokeWidth: "0", vectorEffect: "non-scaling-stroke", fill: "currentColor", stroke: "#000000" }));\n const icon3 = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("circle", { cx: "44", cy: "48", r: "39", strokeWidth: "2", vectorEffect: "non-scaling-stroke", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "18", cy: "20", r: "12", strokeWidth: "0", vectorEffect: "non-scaling-stroke", fill: "currentColor", stroke: "#000000" }), /* @__PURE__ */ React.createElement("circle", { cx: "36", cy: "87", r: "12", strokeWidth: "0", vectorEffect: "non-scaling-stroke", fill: "currentColor", stroke: "#000000" }), /* @__PURE__ */ React.createElement("circle", { cx: "80", cy: "28", r: "12", strokeWidth: "0", vectorEffect: "non-scaling-stroke", fill: "currentColor", stroke: "#000000" }));\n const circleIcon4 = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("circle", { cx: "44", cy: "48", r: "39", strokeWidth: "2", vectorEffect: "non-scaling-stroke", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "25,82 66,15", strokeWidth: "2", vectorEffect: "non-scaling-stroke", fill: "none", stroke: "currentColor" }));\n const arcIcon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("path", { d: "M 31 80 A 35 35 0 1 0 25 24", strokeWidth: "2", vectorEffect: "non-scaling-stroke", fill: "none", stroke: "currentColor" }));\n return [\n {\n name: "create circle",\n type: [\n { name: "2 points", icon: icon2 },\n { name: "3 points", icon: icon3 },\n { name: "center radius", hotkey: "C", icon: circleIcon },\n { name: "center diameter", icon: circleIcon4 }\n ],\n useCommand({ onEnd, scale, type, strokeStyleId, fillStyleId }) {\n const { circle, onClick, onMove, input, startPosition, middlePosition, cursorPosition, reset } = ctx.useCircleClickCreate(\n type === "2 points" || type === "3 points" || type === "center diameter" || type === "center radius" ? type : void 0,\n (c) => onEnd({\n updateContents: (contents) => contents.push({ ...c, strokeStyleId, fillStyleId, type: "circle" })\n })\n );\n const assistentContents = [];\n if (startPosition && cursorPosition) {\n if (middlePosition) {\n assistentContents.push({ type: "polygon", points: [startPosition, middlePosition, cursorPosition], dashArray: [4 / scale] });\n } else {\n assistentContents.push(\n { type: "line", points: [startPosition, cursorPosition], dashArray: [4 / scale] },\n ...ctx.getAssistentText(\n ctx.getTwoPointsDistance(startPosition, cursorPosition).toFixed(2),\n 16 / scale,\n (startPosition.x + cursorPosition.x) / 2 - 20,\n (startPosition.y + cursorPosition.y) / 2 + 4\n )\n );\n }\n }\n if (circle) {\n assistentContents.push({ ...circle, strokeStyleId, fillStyleId, type: "circle" });\n }\n return {\n onStart: onClick,\n input,\n onMove,\n assistentContents,\n lastPosition: middlePosition != null ? middlePosition : startPosition,\n reset\n };\n },\n selectCount: 0\n },\n {\n name: "create arc",\n useCommand({ onEnd, type, scale, strokeStyleId, fillStyleId }) {\n const { circle, arc, onClick, onMove, input, startPosition, middlePosition, cursorPosition, reset } = ctx.useCircleArcClickCreate(\n type === "create arc" ? "center radius" : void 0,\n (c) => onEnd({\n updateContents: (contents) => contents.push({ ...c, strokeStyleId, fillStyleId, type: "arc" })\n })\n );\n const assistentContents = [];\n if (startPosition && cursorPosition) {\n if (middlePosition) {\n assistentContents.push({ type: "polygon", points: [startPosition, middlePosition, cursorPosition], dashArray: [4 / scale] });\n } else {\n assistentContents.push(\n { type: "line", points: [startPosition, cursorPosition], dashArray: [4 / scale] },\n ...ctx.getAssistentText(\n ctx.getTwoPointsDistance(startPosition, cursorPosition).toFixed(2),\n 16 / scale,\n (startPosition.x + cursorPosition.x) / 2 - 20,\n (startPosition.y + cursorPosition.y) / 2 + 4\n )\n );\n }\n }\n if (arc) {\n assistentContents.push({ ...arc, dashArray: [4 / scale], type: "circle" });\n if (arc.startAngle !== arc.endAngle) {\n assistentContents.push(\n {\n type: "line",\n points: [\n {\n x: arc.x + arc.r * Math.cos(ctx.angleToRadian(arc.startAngle)),\n y: arc.y + arc.r * Math.sin(ctx.angleToRadian(arc.startAngle))\n },\n {\n x: arc.x,\n y: arc.y\n }\n ],\n dashArray: [4 / scale]\n },\n {\n type: "line",\n points: [\n {\n x: arc.x,\n y: arc.y\n },\n {\n x: arc.x + arc.r * Math.cos(ctx.angleToRadian(arc.endAngle)),\n y: arc.y + arc.r * Math.sin(ctx.angleToRadian(arc.endAngle))\n }\n ],\n dashArray: [4 / scale]\n }\n );\n }\n if (cursorPosition) {\n assistentContents.push({ type: "line", points: [arc, cursorPosition], dashArray: [4 / scale] });\n }\n }\n if (circle) {\n assistentContents.push({ ...circle, dashArray: [4 / scale], type: "circle" });\n if (cursorPosition) {\n assistentContents.push({ type: "line", points: [circle, cursorPosition], dashArray: [4 / scale] });\n }\n }\n if (arc && arc.startAngle !== arc.endAngle) {\n assistentContents.push({ ...arc, strokeStyleId, fillStyleId, type: "arc" });\n }\n return {\n onStart: onClick,\n input,\n onMove,\n assistentContents,\n lastPosition: middlePosition != null ? middlePosition : startPosition,\n reset\n };\n },\n selectCount: 0,\n hotkey: "A",\n icon: arcIcon\n }\n ];\n}\nexport {\n getCommand,\n getModel,\n isArcContent,\n isCircleContent\n};\n','// dev/cad-editor/plugins/clip.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("mask", { id: "clip" }, /* @__PURE__ */ React.createElement("path", { d: "M 1 1 L 1 100 L 103 100 L 103 1", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "white", stroke: "currentColor", fillRule: "evenodd" }), /* @__PURE__ */ React.createElement("path", { d: "M 91 70 L 91 73 L 91 75 L 90 78 L 90 80 L 89 82 L 88 84 L 86 86 L 85 88 L 83 90 L 81 91 L 79 93 L 77 94 L 75 95 L 73 96 L 71 97 L 68 97 L 66 98 L 64 98 L 61 98 L 59 97 L 57 97 L 54 96 L 52 95 L 50 94 L 48 93 L 46 91 L 44 90 L 43 88 L 41 86 L 40 84 L 39 82 L 38 80 L 37 78 L 37 75 L 36 73 L 36 70 L 36 68 L 37 66 L 37 63 L 38 61 L 39 59 L 40 57 L 41 55 L 43 53 L 44 51 L 46 49 L 48 48 L 50 47 L 52 46 L 54 45 L 57 44 L 59 43 L 61 43 L 64 43 L 66 43 L 68 43 L 71 44 L 73 45 L 75 46 L 77 47 L 79 48 L 81 49 L 83 51 L 85 53 L 86 55 L 88 57 L 89 59 L 90 61 L 90 63 L 91 66 L 91 68 L 91 70", fill: "black" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#clip)" }, /* @__PURE__ */ React.createElement("polygon", { points: "83,99 77,64 103,38 67,33 51,1 35,33 1,39 25,64 19,100 51,83", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", strokeOpacity: "1", fill: "currentColor", stroke: "currentColor" })));\n return {\n name: "clip",\n icon,\n useCommand({ type, onEnd, acquireContent, selected, contents }) {\n const target = React.useRef();\n const border = React.useRef();\n const reset = () => {\n target.current = void 0;\n border.current = void 0;\n };\n React.useEffect(() => {\n if (!type) return;\n if (!target.current) {\n target.current = selected[0].path;\n acquireContent(\n {\n count: 1,\n selectable: (v) => {\n var _a, _b;\n const content = ctx.getContentByIndex(contents, v);\n if (!content) return false;\n const geometries = (_b = (_a = ctx.getContentModel(content)) == null ? void 0 : _a.getGeometries) == null ? void 0 : _b.call(_a, content, contents);\n if (!geometries) return false;\n return geometries.lines.length > 0;\n }\n },\n (r) => {\n border.current = ctx.getRefPart(r[0], contents, (c) => c !== selected[0].content);\n }\n );\n } else if (border.current) {\n onEnd({\n updateContents(contents2) {\n if (target.current) {\n const content = contents2[target.current[0]];\n if (content && ctx.isClipContent(content) && border.current) {\n content.clip = {\n border: border.current\n };\n }\n }\n }\n });\n reset();\n }\n }, [type]);\n return {\n onStart() {\n },\n reset\n };\n },\n selectCount: 1,\n contentSelectable(content) {\n return ctx.isClipContent(content) && !content.readonly;\n }\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/clone.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("rect", { x: "8", y: "27", width: "62", height: "65", strokeWidth: "3", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("rect", { x: "30", y: "8", width: "62", height: "65", strokeWidth: "3", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "clone",\n useCommand({ onEnd, transform, type, scale }) {\n const { offset, onStart, mask, startPosition, resetDragMove } = ctx.useDragMove(\n () => onEnd({}),\n {\n repeatedly: true,\n transform,\n ignoreLeavingEvent: true\n }\n );\n let message = "";\n if (type) {\n message = startPosition ? "specify end point" : "specify start point";\n }\n const { input, setInputPosition, resetInput } = ctx.useCursorInput(message);\n const reset = () => {\n resetDragMove();\n resetInput();\n };\n return {\n onStart: (s) => onStart(s),\n mask,\n reset,\n input,\n onMove(_, p) {\n setInputPosition(p);\n },\n updateSelectedContent(content) {\n if (startPosition && (offset.x !== 0 || offset.y !== 0)) {\n return {\n newContents: [\n ctx.produce(content, (d) => {\n var _a, _b;\n (_b = (_a = ctx.getContentModel(d)) == null ? void 0 : _a.move) == null ? void 0 : _b.call(_a, d, offset);\n })\n ]\n };\n }\n return {};\n },\n assistentContents: startPosition && (offset.x !== 0 || offset.y !== 0) ? [\n {\n type: "line",\n dashArray: [4 / scale],\n points: [startPosition, { x: startPosition.x + offset.x, y: startPosition.y + offset.y }]\n }\n ] : void 0\n };\n },\n contentSelectable(content) {\n var _a;\n return ((_a = ctx.getContentModel(content)) == null ? void 0 : _a.move) !== void 0;\n },\n hotkey: "CO",\n icon,\n repeatedly: true\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/circle-arc.plugin.tsx\nfunction isArcContent(content) {\n return content.type === "arc";\n}\n\n// dev/cad-editor/plugins/line-polyline.plugin.tsx\nfunction isLineContent(content) {\n return content.type === "line";\n}\nfunction isPolyLineContent(content) {\n return content.type === "polyline";\n}\n\n// dev/cad-editor/plugins/ellipse.plugin.tsx\nfunction isEllipseArcContent(content) {\n return content.type === "ellipse arc";\n}\n\n// dev/cad-editor/plugins/combined-path.plugin.tsx\nfunction getModel(ctx) {\n const CombinedPathContent = ctx.and(ctx.BaseContent("combined path"), ctx.ContainerFields, ctx.StrokeFields, ctx.FillFields);\n const getRefIds = (content) => ctx.getStrokeAndFillRefIds(content);\n const getGeometries = (content, contents) => {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return ctx.getGeometriesFromCache(content, refs, () => {\n const lines = [];\n const result = [];\n const boundings = [];\n content.contents.forEach((c) => {\n var _a, _b, _c, _d;\n if (!c) {\n return;\n }\n const r = (_b = (_a = ctx.getContentModel(c)) == null ? void 0 : _a.getGeometries) == null ? void 0 : _b.call(_a, c, contents);\n if (r) {\n lines.push(...r.lines);\n if (r.bounding) {\n boundings.push(r.bounding.start, r.bounding.end);\n }\n }\n if (isLineContent(c) || isPolyLineContent(c)) {\n result.push({ points: c.points });\n } else if (isArcContent(c)) {\n result.push({ points: ctx.arcToPolyline(c, (_c = c.angleDelta) != null ? _c : ctx.defaultAngleDelta) });\n } else if (isEllipseArcContent(c)) {\n result.push({ points: ctx.ellipseArcToPolyline(c, (_d = c.angleDelta) != null ? _d : ctx.defaultAngleDelta) });\n }\n });\n ctx.mergePolylinesToPolyline(result);\n const renderingLines = result.map((m) => m.points);\n const points = renderingLines.flat();\n return {\n lines,\n bounding: ctx.getPointsBounding(boundings),\n renderingLines,\n regions: ctx.hasFill(content) ? [{\n lines,\n points\n }] : void 0\n };\n });\n };\n return {\n type: "combined path",\n ...ctx.containerModel,\n ...ctx.strokeModel,\n ...ctx.fillModel,\n move: ctx.getContainerMove,\n rotate: ctx.getContainerRotate,\n scale: ctx.getContainerScale,\n explode: ctx.getContainerExplode,\n mirror: ctx.getContainerMirror,\n render(content, renderCtx) {\n const geometries = getGeometries(content, renderCtx.contents);\n const { options } = ctx.getStrokeFillRenderOptionsFromRenderContext(content, renderCtx);\n return renderCtx.target.renderGroup(geometries.renderingLines.map((line) => {\n return renderCtx.target.renderPolyline(line, options);\n }));\n },\n renderIfSelected: (content, renderCtx) => ctx.getContainerRenderIfSelected(content, renderCtx, [content], getRefIds),\n getSnapPoints: ctx.getContainerSnapPoints,\n getGeometries,\n propertyPanel(content, update, contents) {\n return {\n ...ctx.getStrokeContentPropertyPanel(content, update, contents),\n ...ctx.getFillContentPropertyPanel(content, update, contents)\n };\n },\n isValid: (c, p) => ctx.validate(c, CombinedPathContent, p),\n getRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n deleteRefId: ctx.deleteStrokeAndFillRefIds\n };\n}\nfunction getCommand(ctx) {\n function contentSelectable(content, contents) {\n return ctx.contentIsDeletable(content, contents) && (isLineContent(content) || isArcContent(content) || isPolyLineContent(content) || isEllipseArcContent(content));\n }\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "36,93 40,92 43,90 47,88 51,86 55,84 58,81 62,79 65,76 69,73 72,70 75,67 78,64 80,60 83,57 85,54 86,51 88,47 89,44 90,41 90,38 91,36 90,33 90,31 89,28 88,26 87,25 85,23 83,22 81,21 78,20 76,20 73,20 69,20 66,20 63,21 59,22 55,23 52,25 48,27 44,29 40,31 37,34 33,36 30,39 26,42 23,45 20,48 17,51 15,55 12,58 10,61 9,64 36,93", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }));\n return {\n name: "create combined path",\n execute({ contents, selected, strokeStyleId, fillStyleId }) {\n const newContent = {\n type: "combined path",\n strokeStyleId,\n fillStyleId,\n contents: contents.filter((c, i) => c && ctx.isSelected([i], selected) && contentSelectable(c, contents))\n };\n ctx.deleteSelectedContents(contents, selected.map((s) => s[0]));\n contents.push(newContent);\n },\n contentSelectable,\n icon\n };\n}\nexport {\n getCommand,\n getModel\n};\n','// dev/cad-editor/plugins/compress.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("rect", { x: "10", y: "44", width: "81", height: "20", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("rect", { x: "9", y: "69", width: "81", height: "20", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polygon", { points: "42,6 57,6 57,31 73,31 51,44 27,32 42,32", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }));\n return {\n name: "compress",\n execute({ contents }) {\n var _a, _b;\n const newIndexes = [];\n let validContentCount = 0;\n const invalidContentsIndex = [];\n const contentIsValid = (d) => {\n var _a2, _b2;\n return !!d && ((_b2 = (_a2 = ctx.getContentModel(d)) == null ? void 0 : _a2.isValid(d)) != null ? _b2 : true) === true;\n };\n contents.forEach((d, i) => {\n if (contentIsValid(d)) {\n newIndexes.push(validContentCount);\n if (ctx.isContainerContent(d)) {\n d.contents = d.contents.filter((c) => contentIsValid(c));\n }\n validContentCount++;\n } else {\n newIndexes.push(void 0);\n invalidContentsIndex.unshift(i);\n }\n });\n invalidContentsIndex.forEach((i) => {\n contents.splice(i, 1);\n });\n for (const content of ctx.iterateAllContents(contents)) {\n (_b = (_a = ctx.getContentModel(content)) == null ? void 0 : _a.updateRefId) == null ? void 0 : _b.call(_a, content, (refId) => typeof refId === "number" ? newIndexes[refId] : void 0);\n }\n ctx.contentIndexCache.clear();\n },\n selectCount: 0,\n icon\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/coordinate-axis.plugin.tsx\nfunction getModel(ctx) {\n const CoordinateAxisContent = ctx.and(ctx.BaseContent("coordinate axis"), ctx.StrokeFields, ctx.ArrowFields, ctx.Position, ctx.Bounding, {\n flipY: ctx.optional(ctx.boolean)\n });\n const getRefIds = (content) => ctx.getStrokeRefIds(content);\n function getGeometriesFromCache(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return ctx.getGeometriesFromCache(content, refs, () => {\n const yMin = content.flipY ? -content.yMax : content.yMin;\n const yMax = content.flipY ? -content.yMin : content.yMax;\n const lines = [\n [\n { x: content.x + content.xMin, y: content.y },\n { x: content.x + content.xMax, y: content.y }\n ],\n [\n { x: content.x, y: content.y + yMin },\n { x: content.x, y: content.y + yMax }\n ]\n ];\n const areas = [];\n const renderingLines = [];\n lines.forEach(([p1, p2], i) => {\n if (content.flipY && i === 1) {\n [p2, p1] = [p1, p2];\n }\n const { arrowPoints, endPoint } = ctx.getArrowPoints(p1, p2, content);\n areas.push(arrowPoints);\n lines[i][content.flipY && i === 1 ? 0 : 1] = endPoint;\n renderingLines.push(...ctx.dashedPolylineToLines(lines[i], content.dashArray));\n });\n return {\n lines,\n bounding: {\n start: {\n x: content.x + Math.min(0, content.xMin, content.xMax),\n y: content.y + Math.min(0, yMin, yMax)\n },\n end: {\n x: content.x + Math.max(0, content.xMin, content.xMax),\n y: content.y + Math.max(0, yMin, yMax)\n }\n },\n regions: areas.map((e) => ({\n points: e,\n lines: Array.from(ctx.iteratePolygonLines(e))\n })),\n renderingLines\n };\n });\n }\n const React = ctx.React;\n return {\n type: "coordinate axis",\n ...ctx.strokeModel,\n ...ctx.arrowModel,\n move(content, offset) {\n ctx.movePoint(content, offset);\n },\n render(content, renderCtx) {\n const { options, target, fillOptions } = ctx.getStrokeRenderOptionsFromRenderContext(content, renderCtx);\n const { regions, renderingLines } = getGeometriesFromCache(content, renderCtx.contents);\n const children = [];\n for (const line of renderingLines) {\n children.push(target.renderPolyline(line, options));\n }\n if (regions) {\n for (let i = 0; i < regions.length; i++) {\n children.push(target.renderPolygon(regions[i].points, fillOptions));\n }\n }\n return target.renderGroup(children);\n },\n getEditPoints(content) {\n return ctx.getEditPointsFromCache(content, () => {\n return {\n editPoints: [\n {\n ...content,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isCoordinateAxisContent(c)) {\n return;\n }\n c.x += cursor.x - start.x;\n c.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n }\n ]\n };\n });\n },\n getGeometries: getGeometriesFromCache,\n propertyPanel(content, update, contents, { acquirePoint }) {\n return {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isCoordinateAxisContent(c)) {\n c.x = p.x;\n c.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.x, setValue: (v) => update((c) => {\n if (isCoordinateAxisContent(c)) {\n c.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.y, setValue: (v) => update((c) => {\n if (isCoordinateAxisContent(c)) {\n c.y = v;\n }\n }) }),\n xMin: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.xMin, setValue: (v) => update((c) => {\n if (isCoordinateAxisContent(c)) {\n c.xMin = v;\n }\n }) }),\n xMax: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.xMax, setValue: (v) => update((c) => {\n if (isCoordinateAxisContent(c)) {\n c.xMax = v;\n }\n }) }),\n yMin: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.yMin, setValue: (v) => update((c) => {\n if (isCoordinateAxisContent(c)) {\n c.yMin = v;\n }\n }) }),\n yMax: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.yMax, setValue: (v) => update((c) => {\n if (isCoordinateAxisContent(c)) {\n c.yMax = v;\n }\n }) }),\n flipY: /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.flipY === true, setValue: (v) => update((c) => {\n if (isCoordinateAxisContent(c)) {\n c.flipY = v ? true : void 0;\n }\n }) }),\n ...ctx.getArrowContentPropertyPanel(content, update),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents)\n };\n },\n isValid: (c, p) => ctx.validate(c, CoordinateAxisContent, p),\n getRefIds,\n updateRefId: ctx.updateStrokeRefIds,\n deleteRefId: ctx.deleteStrokeRefIds\n };\n}\nfunction isCoordinateAxisContent(content) {\n return content.type === "coordinate axis";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "0,50 95,50", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "50,5 50,100", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "100,50 82,58 82,42", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "50,0 58,18 42,18", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }));\n return {\n name: "create coordinate axis",\n selectCount: 0,\n icon,\n useCommand({ onEnd, type }) {\n const [result, setResult] = React.useState();\n const reset = () => {\n setResult(void 0);\n };\n return {\n onStart() {\n if (result) {\n onEnd({\n updateContents: (contents) => {\n if (result) {\n contents.push(result);\n }\n }\n });\n reset();\n }\n },\n onMove(p) {\n if (type) {\n setResult({\n type: "coordinate axis",\n x: p.x,\n y: p.y,\n xMin: -50,\n xMax: 50,\n yMin: -50,\n yMax: 50,\n flipY: true\n });\n }\n },\n assistentContents: result ? [result] : void 0,\n reset\n };\n }\n };\n}\nexport {\n getCommand,\n getModel,\n isCoordinateAxisContent\n};\n','// dev/cad-editor/plugins/copy-paste.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const CopyData = {\n contents: ctx.minItems(0, [{\n id: ctx.number,\n content: ctx.Content\n }]),\n center: ctx.Position\n };\n const cutOrCopyCommand = {\n name: "copy",\n execute({ contents, selected, type }) {\n const ids = [];\n contents.forEach((content, index) => {\n if (content && ctx.isSelected([index], selected)) {\n for (const id of ctx.iterateRefIds([index], contents)) {\n const index2 = ids.indexOf(id);\n if (index2 >= 0) {\n ids.splice(index2, 1);\n }\n ids.push(id);\n }\n }\n });\n if (type === "cut") {\n ctx.deleteSelectedContents(contents, selected.map((s) => s[0]));\n }\n const copiedContents = [];\n const boundingPoints = [];\n ids.forEach((id) => {\n var _a, _b;\n const content = contents[id];\n if (content) {\n const geometries = (_b = (_a = ctx.getContentModel(content)) == null ? void 0 : _a.getGeometries) == null ? void 0 : _b.call(_a, content, contents);\n if (geometries == null ? void 0 : geometries.bounding) {\n boundingPoints.push(geometries.bounding.start, geometries.bounding.end);\n }\n copiedContents.unshift({\n id,\n content\n });\n }\n });\n const bounding = ctx.getPointsBounding(boundingPoints);\n if (!bounding) {\n return;\n }\n const copyData = {\n contents: copiedContents,\n center: ctx.getTwoPointCenter(bounding.start, bounding.end)\n };\n navigator.clipboard.writeText(JSON.stringify(copyData));\n }\n };\n return [\n cutOrCopyCommand,\n {\n ...cutOrCopyCommand,\n name: "cut"\n },\n {\n name: "paste",\n useCommand({ onEnd, type }) {\n let message = "";\n if (type) {\n message = "specify target point";\n }\n const [copyData, setCopyData] = React.useState();\n const { input, setInputPosition, cursorPosition, setCursorPosition, resetInput } = ctx.useCursorInput(message);\n ctx.useValueChanged(type, () => {\n if (type) {\n (async () => {\n try {\n const text = await navigator.clipboard.readText();\n const copyData2 = JSON.parse(text);\n const r = ctx.validate(copyData2, CopyData);\n if (r === true) {\n setCopyData(copyData2);\n return;\n } else {\n console.info(r);\n reset();\n onEnd();\n }\n } catch (error) {\n console.info(error);\n }\n })();\n }\n });\n const reset = () => {\n setCopyData(void 0);\n resetInput();\n setCursorPosition(void 0);\n setInputPosition(void 0);\n };\n const assistentContents = [];\n if (cursorPosition && copyData) {\n const offset = {\n x: cursorPosition.x - copyData.center.x,\n y: cursorPosition.y - copyData.center.y\n };\n copyData.contents.forEach((c) => {\n assistentContents.push(ctx.produce(c.content, (draft) => {\n var _a, _b;\n const model = ctx.getContentModel(draft);\n (_a = model == null ? void 0 : model.move) == null ? void 0 : _a.call(model, draft, offset);\n (_b = model == null ? void 0 : model.updateRefId) == null ? void 0 : _b.call(model, draft, (d) => {\n if (typeof d === "number") {\n const index = copyData.contents.findIndex((c2) => c2.id === d);\n if (index >= 0 && index < assistentContents.length) {\n return assistentContents[index];\n }\n }\n return void 0;\n });\n }));\n });\n }\n return {\n onStart(p) {\n resetInput();\n onEnd({\n updateContents: (contents) => {\n if (copyData) {\n const offset = {\n x: p.x - copyData.center.x,\n y: p.y - copyData.center.y\n };\n const idMap = {};\n let id = contents.length;\n copyData.contents.forEach((c) => {\n idMap[c.id] = id++;\n });\n copyData.contents.forEach((c) => {\n contents.push(ctx.produce(c.content, (draft) => {\n var _a, _b;\n const model = ctx.getContentModel(draft);\n (_a = model == null ? void 0 : model.move) == null ? void 0 : _a.call(model, draft, offset);\n (_b = model == null ? void 0 : model.updateRefId) == null ? void 0 : _b.call(model, draft, (d) => typeof d === "number" ? idMap[d] : void 0);\n }));\n });\n }\n reset();\n }\n });\n },\n input,\n onMove(p, viewportPosition) {\n setInputPosition(viewportPosition || p);\n if (!type) {\n return;\n }\n setCursorPosition(p);\n },\n assistentContents,\n reset\n };\n },\n selectCount: 0\n }\n ];\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/create-tangent-tangent-line-at-points.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("circle", { cx: "78", cy: "80", r: "18", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "29", cy: "29", r: "27", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "92", cy: "70", r: "8", fillOpacity: "1", strokeOpacity: "1", fill: "currentColor", stroke: "none" }), /* @__PURE__ */ React.createElement("circle", { cx: "51", cy: "13", r: "8", fillOpacity: "1", strokeOpacity: "1", fill: "currentColor", stroke: "none" }), /* @__PURE__ */ React.createElement("polyline", { points: "92,70 51,13", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }));\n return {\n name: "create tangent tangent line at points",\n useCommand({ onEnd, type, scale, contents }) {\n const [start, setStart] = React.useState();\n const [cursor, setCursor] = React.useState();\n const [result, setResult] = React.useState();\n const assistentContents = [];\n if (start && cursor && type) {\n assistentContents.push({\n points: [start.point, cursor],\n type: "line",\n dashArray: [4 / scale]\n });\n }\n if (result) {\n assistentContents.push({\n points: result,\n type: "line"\n });\n }\n const reset = () => {\n setStart(void 0);\n setResult(void 0);\n setCursor(void 0);\n };\n const getTarget = (point, id, param) => {\n var _a, _b, _c;\n const content = contents[id];\n if (!content) return;\n const lines = (_c = (_b = (_a = ctx.getContentModel(content)) == null ? void 0 : _a.getGeometries) == null ? void 0 : _b.call(_a, content, contents)) == null ? void 0 : _c.lines;\n if (!lines) return;\n const index = Math.floor(param);\n return { point, line: lines[index], param: param - index };\n };\n return {\n onStart(p, target) {\n if (!type) return;\n if (!target) return;\n if (target.param === void 0) return;\n if (!start) {\n setStart(getTarget(p, target.id, target.param));\n } else if (result) {\n onEnd({\n updateContents: (contents2) => {\n contents2.push({ type: "line", points: result });\n }\n });\n reset();\n }\n },\n onMove(p, _, target) {\n if (!type) return;\n setCursor(p);\n setResult(void 0);\n if (!target) return;\n if (target.param === void 0) return;\n if (!start) return;\n const end = getTarget(p, target.id, target.param);\n if (!end) return;\n const params = ctx.getLineTangentToTwoGeometryLinesNearParam(start.line, end.line, start.param, end.param);\n if (params) {\n setResult([ctx.getGeometryLinePointAtParam(params[0], start.line), ctx.getGeometryLinePointAtParam(params[1], end.line)]);\n }\n },\n assistentContents,\n reset\n };\n },\n selectCount: 0,\n icon\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/create-tangent-tangent-line.plugin.tsx\nfunction getCommand(ctx) {\n function getTangentTangentLines(line1, line2) {\n if (line1 && line2) {\n return ctx.getLinesTangentTo2GeometryLines(line1, line2);\n }\n return [];\n }\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("circle", { cx: "78", cy: "80", r: "18", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "29", cy: "29", r: "27", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "92,70 51,13", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }));\n return {\n name: "create tangent tangent line",\n useCommand({ onEnd, type, selected, scale }) {\n const [candidates, setCandidates] = React.useState();\n const [result, setResult] = React.useState();\n const assistentContents = (candidates || []).map((c) => ({\n points: c,\n type: "line",\n dashArray: c === result ? void 0 : [4 / scale]\n }));\n React.useEffect(() => {\n var _a, _b;\n if (type && !candidates) {\n setCandidates(getTangentTangentLines((_a = selected[0].lines) == null ? void 0 : _a[0], (_b = selected[1].lines) == null ? void 0 : _b[0]));\n }\n }, [type, selected]);\n const reset = () => {\n setCandidates(void 0);\n setResult(void 0);\n };\n return {\n onStart() {\n if (result) {\n onEnd({\n updateContents: (contents) => {\n contents.push({ type: "line", points: result });\n }\n });\n reset();\n }\n },\n onMove(p) {\n setResult(candidates == null ? void 0 : candidates.find((c) => ctx.getPointAndLineSegmentMinimumDistance(p, ...c) < 5));\n },\n assistentContents,\n reset\n };\n },\n selectCount: 2,\n selectType: "select part",\n icon\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/circle-arc.plugin.tsx\nfunction isCircleContent(content) {\n return content.type === "circle";\n}\nfunction isArcContent(content) {\n return content.type === "arc";\n}\n\n// dev/cad-editor/plugins/line-polyline.plugin.tsx\nfunction isLineContent(content) {\n return content.type === "line";\n}\n\n// dev/cad-editor/plugins/create-tangent-tangent-radius-circle.plugin.tsx\nfunction getCommand(ctx) {\n function getTangentTangentRadiusCircles(content1, content2, radius) {\n const result = [];\n if (isCircleContent(content1) || isArcContent(content1)) {\n if (isCircleContent(content2) || isArcContent(content2)) {\n result.push(...ctx.getCirclesTangentTo2Circles(content1, content2, radius));\n } else if (isLineContent(content2)) {\n const line2 = ctx.twoPointLineToGeneralFormLine(content2.points[0], content2.points[1]);\n if (!line2) return [];\n result.push(...ctx.getCirclesTangentToLineAndCircle(line2, content1, radius));\n }\n } else if (isLineContent(content1)) {\n const line1 = ctx.twoPointLineToGeneralFormLine(content1.points[0], content1.points[1]);\n if (!line1) return [];\n if (isCircleContent(content2) || isArcContent(content2)) {\n result.push(...ctx.getCirclesTangentToLineAndCircle(line1, content2, radius));\n } else if (isLineContent(content2)) {\n const line2 = ctx.twoPointLineToGeneralFormLine(content2.points[0], content2.points[1]);\n if (!line2) return [];\n result.push(...ctx.getCirclesTangentTo2Lines(line1, line2, radius));\n }\n }\n return result.map((c) => ({ ...c, r: radius }));\n }\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "10,87 89,87", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "17", cy: "40", r: "16", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "60", cy: "57", r: "30", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n const contentSelectable = (c) => isCircleContent(c) || isArcContent(c) || isLineContent(c);\n const command = {\n name: "create tangent tangent radius circle",\n useCommand({ onEnd, type, selected, scale }) {\n const [candidates, setCandidates] = React.useState([]);\n const [result, setResult] = React.useState();\n let message = "";\n if (type) {\n if (candidates.length > 0) {\n message = "select one result";\n } else {\n message = "input radius";\n }\n }\n const assistentContents = candidates.map((c) => ({\n ...c,\n type: "circle",\n dashArray: c === result ? void 0 : [4 / scale]\n }));\n const { input, setInputPosition, setCursorPosition, clearText, resetInput } = ctx.useCursorInput(message, type && candidates.length == 0 ? (e, text) => {\n if (e.key === "Enter") {\n const radius = +text;\n if (!isNaN(radius)) {\n setCandidates(getTangentTangentRadiusCircles(selected[0].content, selected[1].content, radius));\n clearText();\n }\n }\n } : void 0);\n const reset = () => {\n setCandidates([]);\n setResult(void 0);\n clearText();\n resetInput();\n };\n return {\n onStart(p) {\n setCursorPosition(p);\n if (result) {\n onEnd({\n updateContents: (contents) => {\n contents.push({ type: "circle", ...result });\n }\n });\n setCandidates([]);\n }\n },\n input,\n onMove(p, viewportPosition) {\n setCursorPosition(p);\n setInputPosition(viewportPosition || p);\n setResult(candidates.find((c) => ctx.getTwoNumbersDistance(ctx.getTwoPointsDistance(c, p), c.r) < 5));\n },\n assistentContents,\n reset\n };\n },\n selectCount: 2,\n contentSelectable,\n selectType: "select part",\n icon\n };\n return [\n command,\n {\n ...command,\n name: "create tangent tangent radius circle 2",\n useCommand({ onEnd, type, scale, contentVisible, contents, getContentsInRange }) {\n const [first, setFirst] = React.useState();\n const [second, setSecond] = React.useState();\n const [hovering, setHovering] = React.useState();\n const [result, setResult] = React.useState();\n let message = "";\n if (type) {\n if (!first) {\n message = "select first circle, arc or line";\n } else if (!second) {\n message = "select second circle, arc or line";\n } else {\n message = "input radius";\n }\n }\n const assistentContents = [];\n if (result) {\n assistentContents.push({ ...result, type: "circle", dashArray: [4 / scale] });\n }\n const selected = [];\n if (first) {\n selected.push(first.path);\n }\n if (second) {\n selected.push(second.path);\n }\n const getCandidate = (radius) => {\n if (!first || !second) return;\n const candidates = getTangentTangentRadiusCircles(first.content, second.content, radius);\n return ctx.minimumBy(candidates, (c) => ctx.getTwoPointsDistanceSquare(c, first.point) + ctx.getTwoPointsDistanceSquare(c, second.point));\n };\n const { input, setInputPosition, setCursorPosition, clearText, resetInput } = ctx.useCursorInput(message, type ? (e, text) => {\n if (e.key === "Enter") {\n const radius = +text;\n if (!isNaN(radius) && first && second) {\n const candidate = getCandidate(radius);\n if (!candidate) return;\n onEnd({\n updateContents: (contents2) => {\n contents2.push({ type: "circle", ...candidate });\n }\n });\n reset();\n }\n }\n } : void 0);\n const reset = () => {\n setFirst(void 0);\n setSecond(void 0);\n setHovering(void 0);\n setResult(void 0);\n clearText();\n resetInput();\n };\n const selectContent = (p) => {\n const indexes = getContentsInRange({ start: p, end: p }).filter((c) => !!c).map((c) => ctx.getContentIndex(c, contents));\n const contentPath = ctx.getContentByClickPosition(contents, p, (c) => {\n const content = ctx.getContentByIndex(contents, c);\n return !!content && contentSelectable(content);\n }, ctx.getContentModel, true, contentVisible, indexes, 3 / scale);\n if (contentPath) {\n const content = ctx.getContentByIndex(contents, contentPath);\n if (content) {\n return { content, point: p, path: contentPath };\n }\n }\n return;\n };\n return {\n onStart(p) {\n if (!first) {\n setFirst(hovering);\n setHovering(void 0);\n return;\n } else if (!second) {\n setSecond(hovering);\n setHovering(void 0);\n return;\n }\n setCursorPosition(p);\n if (result) {\n onEnd({\n updateContents: (contents2) => {\n contents2.push({ type: "circle", ...result });\n }\n });\n reset();\n }\n },\n input,\n onMove(p, viewportPosition) {\n setCursorPosition(p);\n setInputPosition(viewportPosition || p);\n if (!first) {\n setHovering(selectContent(p));\n return;\n } else if (!second) {\n setHovering(selectContent(p));\n return;\n }\n setResult(getCandidate(ctx.getTwoPointsDistance(second.point, p)));\n },\n assistentContents,\n selected,\n hovering: hovering ? [hovering.path] : void 0,\n reset\n };\n },\n selectCount: 0\n }\n ];\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/circle-arc.plugin.tsx\nfunction isCircleContent(content) {\n return content.type === "circle";\n}\nfunction isArcContent(content) {\n return content.type === "arc";\n}\n\n// dev/cad-editor/plugins/line-polyline.plugin.tsx\nfunction isLineContent(content) {\n return content.type === "line";\n}\n\n// dev/cad-editor/plugins/create-tangent-tangent-tangent-circle.plugin.tsx\nfunction getCommand(ctx) {\n function getTangentTangentTangentCircles(content1, content2, content3) {\n const result = [];\n if (isLineContent(content1)) {\n const line1 = ctx.twoPointLineToGeneralFormLine(content1.points[0], content1.points[1]);\n if (!line1) return [];\n if (isLineContent(content2)) {\n const line2 = ctx.twoPointLineToGeneralFormLine(content2.points[0], content2.points[1]);\n if (!line2) return [];\n if (isLineContent(content3)) {\n const line3 = ctx.twoPointLineToGeneralFormLine(content3.points[0], content3.points[1]);\n if (!line3) return [];\n result.push(...ctx.getCirclesTangentTo3Lines(line1, line2, line3));\n } else if (isCircleContent(content3) || isArcContent(content3)) {\n result.push(...ctx.getCirclesTangentToLineLineCircle(line1, line2, content3));\n }\n } else if (isCircleContent(content2) || isArcContent(content2)) {\n if (isLineContent(content3)) {\n const line3 = ctx.twoPointLineToGeneralFormLine(content3.points[0], content3.points[1]);\n if (!line3) return [];\n result.push(...ctx.getCirclesTangentToLineLineCircle(line1, line3, content2));\n } else if (isCircleContent(content3) || isArcContent(content3)) {\n result.push(...ctx.getCirclesTangentToLineCircleCircle(line1, content2, content3));\n }\n }\n } else if (isCircleContent(content1) || isArcContent(content1)) {\n if (isLineContent(content2)) {\n const line2 = ctx.twoPointLineToGeneralFormLine(content2.points[0], content2.points[1]);\n if (!line2) return [];\n if (isLineContent(content3)) {\n const line3 = ctx.twoPointLineToGeneralFormLine(content3.points[0], content3.points[1]);\n if (!line3) return [];\n result.push(...ctx.getCirclesTangentToLineLineCircle(line2, line3, content1));\n } else if (isCircleContent(content3) || isArcContent(content3)) {\n result.push(...ctx.getCirclesTangentToLineCircleCircle(line2, content1, content3));\n }\n } else if (isCircleContent(content2) || isArcContent(content2)) {\n if (isLineContent(content3)) {\n const line3 = ctx.twoPointLineToGeneralFormLine(content3.points[0], content3.points[1]);\n if (!line3) return [];\n result.push(...ctx.getCirclesTangentToLineCircleCircle(line3, content1, content2));\n } else if (isCircleContent(content3) || isArcContent(content3)) {\n result.push(...ctx.getCirclesTangentTo3Circles(content1, content2, content3));\n }\n }\n }\n return result;\n }\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "0,8 100,8", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "99,19 60,100", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "0,22 44,98", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "50", cy: "42", r: "34", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", strokeOpacity: "1", fill: "none", stroke: "currentColor" }));\n return {\n name: "create tangent tangent tangent circle",\n useCommand({ onEnd, type, selected, scale }) {\n const [candidates, setCandidates] = React.useState();\n const [result, setResult] = React.useState();\n const assistentContents = (candidates || []).map((c) => ({\n ...c,\n type: "circle",\n dashArray: c === result ? void 0 : [4 / scale]\n }));\n const reset = () => {\n setCandidates(void 0);\n setResult(void 0);\n };\n React.useEffect(() => {\n if (type && !candidates) {\n setCandidates(getTangentTangentTangentCircles(selected[0].content, selected[1].content, selected[2].content));\n }\n }, [type, selected]);\n return {\n onStart() {\n if (result) {\n onEnd({\n updateContents: (contents) => {\n contents.push({ type: "circle", ...result });\n }\n });\n setCandidates([]);\n }\n },\n onMove(p) {\n setResult(candidates == null ? void 0 : candidates.find((c) => ctx.getTwoNumbersDistance(ctx.getTwoPointsDistance(c, p), c.r) < 5));\n },\n assistentContents,\n reset\n };\n },\n selectCount: 3,\n contentSelectable: (c) => isLineContent(c) || isCircleContent(c) || isArcContent(c),\n selectType: "select part",\n icon\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/delete.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "17,21 80,84", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "77,23 19,81", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "delete",\n execute({ contents, selected }) {\n ctx.deleteSelectedContents(contents, selected.map((s) => s[0]));\n },\n contentSelectable(content, contents) {\n return ctx.contentIsDeletable(content, contents);\n },\n hotkey: "E",\n icon\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/diamond.plugin.tsx\nfunction getModel(ctx) {\n const DiamondContent = ctx.and(ctx.BaseContent("diamond"), ctx.StrokeFields, ctx.FillFields, ctx.Region);\n const getRefIds = (content) => ctx.getStrokeAndFillRefIds(content);\n const geometriesCache = new ctx.WeakmapValuesCache();\n function getGeometries(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return geometriesCache.get(content, refs, () => {\n const points = [\n { x: content.x, y: content.y - content.height / 2 },\n { x: content.x + content.width / 2, y: content.y },\n { x: content.x, y: content.y + content.height / 2 },\n { x: content.x - content.width / 2, y: content.y }\n ];\n const lines = Array.from(ctx.iteratePolygonLines(points));\n return {\n lines,\n points,\n bounding: ctx.getPointsBounding(points),\n renderingLines: ctx.dashedPolylineToLines(ctx.polygonToPolyline(points), content.dashArray),\n regions: ctx.hasFill(content) ? [\n {\n lines,\n points\n }\n ] : void 0\n };\n });\n }\n const React = ctx.React;\n return {\n type: "diamond",\n ...ctx.strokeModel,\n ...ctx.fillModel,\n move(content, offset) {\n ctx.movePoint(content, offset);\n },\n scale(content, center, sx, sy) {\n ctx.scalePoint(content, center, sx, sy);\n content.width *= sx;\n content.height *= sy;\n },\n skew(content, center, sx, sy, contents) {\n const points = ctx.produce(getGeometries(content, contents).points, (draft) => {\n for (const p of draft) {\n ctx.skewPoint(p, center, sx, sy);\n }\n });\n return { ...content, points, type: "polygon" };\n },\n explode(content, contents) {\n const { lines } = getGeometries(content, contents);\n return lines.map((line) => ({ type: "line", points: line }));\n },\n offset(content, point, distance, contents) {\n var _a;\n if (!distance) {\n distance = Math.min(...getGeometries(content, contents).lines.map((line) => ctx.getPointAndGeometryLineMinimumDistance(point, line)));\n }\n distance *= ((_a = this.isPointIn) == null ? void 0 : _a.call(this, content, point, contents)) ? -2 : 2;\n const scale = content.width / content.height;\n const height = distance / Math.sin(Math.atan(scale));\n const width = height * scale;\n return ctx.produce(content, (d) => {\n d.width += width;\n d.height += height;\n });\n },\n render(content, renderCtx) {\n const { options, target } = ctx.getStrokeFillRenderOptionsFromRenderContext(content, renderCtx);\n const { points } = getGeometries(content, renderCtx.contents);\n return target.renderPolygon(points, options);\n },\n getOperatorRenderPosition(content, contents) {\n const { points } = getGeometries(content, contents);\n return points[0];\n },\n getEditPoints(content, contents) {\n return ctx.getEditPointsFromCache(content, () => {\n const { points } = getGeometries(content, contents);\n return {\n editPoints: [\n { x: content.x, y: content.y, direction: "center" },\n { ...points[0], direction: "top" },\n { ...points[1], direction: "right" },\n { ...points[2], direction: "bottom" },\n { ...points[3], direction: "left" }\n ].map((p) => ({\n x: p.x,\n y: p.y,\n cursor: ctx.getResizeCursor(0, p.direction),\n update(c, { cursor, start, scale }) {\n if (!isDiamondContent(c)) {\n return;\n }\n const offset = ctx.getResizeOffset(start, cursor, p.direction);\n if (!offset) {\n return;\n }\n c.x += offset.x + offset.width / 2;\n c.y += offset.y + offset.height / 2;\n c.width += offset.width;\n c.height += offset.height;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n }))\n };\n });\n },\n getSnapPoints(content, contents) {\n return ctx.getSnapPointsFromCache(content, () => {\n const { points, lines } = getGeometries(content, contents);\n return [\n { x: content.x, y: content.y, type: "center" },\n ...points.map((p) => ({ ...p, type: "endpoint" })),\n ...lines.map(([start, end]) => ({\n x: (start.x + end.x) / 2,\n y: (start.y + end.y) / 2,\n type: "midpoint"\n }))\n ];\n });\n },\n getGeometries,\n canSelectPart: true,\n propertyPanel(content, update, contents, { acquirePoint }) {\n return {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isDiamondContent(c)) {\n c.x = p.x;\n c.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.x, setValue: (v) => update((c) => {\n if (isDiamondContent(c)) {\n c.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.y, setValue: (v) => update((c) => {\n if (isDiamondContent(c)) {\n c.y = v;\n }\n }) }),\n width: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.width, setValue: (v) => update((c) => {\n if (isDiamondContent(c)) {\n c.width = v;\n }\n }) }),\n height: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.height, setValue: (v) => update((c) => {\n if (isDiamondContent(c)) {\n c.height = v;\n }\n }) }),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents),\n ...ctx.getFillContentPropertyPanel(content, update, contents)\n };\n },\n isValid: (c, p) => ctx.validate(c, DiamondContent, p),\n getRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n deleteRefId: ctx.deleteStrokeAndFillRefIds,\n isPointIn: (content, point, contents) => ctx.pointInPolygon(point, getGeometries(content, contents).points)\n };\n}\nfunction isDiamondContent(content) {\n return content.type === "diamond";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polygon", { points: "52,5 97,50 52,96 6,50", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "create diamond",\n icon,\n useCommand({ onEnd, type, strokeStyleId, fillStyleId, scale }) {\n const { line, onClick, onMove, input, lastPosition, reset } = ctx.useLineClickCreate(\n type === "create diamond",\n (c) => onEnd({\n updateContents: (contents) => contents.push({\n type: "diamond",\n x: (c[0].x + c[1].x) / 2,\n y: (c[0].y + c[1].y) / 2,\n width: Math.abs(c[0].x - c[1].x),\n height: Math.abs(c[0].y - c[1].y),\n strokeStyleId,\n fillStyleId\n })\n }),\n {\n once: true\n }\n );\n const assistentContents = [];\n if (line) {\n assistentContents.push({\n type: "diamond",\n x: (line[0].x + line[1].x) / 2,\n y: (line[0].y + line[1].y) / 2,\n width: Math.abs(line[0].x - line[1].x),\n height: Math.abs(line[0].y - line[1].y),\n strokeStyleId,\n fillStyleId\n });\n assistentContents.push({\n type: "rect",\n x: (line[0].x + line[1].x) / 2,\n y: (line[0].y + line[1].y) / 2,\n width: Math.abs(line[0].x - line[1].x),\n height: Math.abs(line[0].y - line[1].y),\n angle: 0,\n dashArray: [4 / scale]\n });\n }\n return {\n onStart: onClick,\n input,\n onMove,\n assistentContents,\n lastPosition,\n reset\n };\n },\n selectCount: 0\n };\n}\nexport {\n getCommand,\n getModel,\n isDiamondContent\n};\n','// dev/cad-editor/plugins/difference.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("circle", { cx: "32", cy: "50", r: "32", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "65", cy: "50", r: "32", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("pattern", { id: "difference", patternUnits: "userSpaceOnUse", width: "10", height: "10" }, /* @__PURE__ */ React.createElement("path", { d: "M 0 5 L 5 0 M 10 5 L 5 10", strokeWidth: "1", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor", fillRule: "evenodd" })), /* @__PURE__ */ React.createElement("path", { d: "M 49 78 L 46 79 L 44 81 L 41 81 L 38 82 L 35 82 L 32 82 L 30 82 L 27 82 L 24 81 L 21 81 L 19 79 L 16 78 L 14 77 L 12 75 L 10 73 L 8 71 L 6 69 L 4 66 L 3 64 L 2 61 L 1 58 L 0 56 L 0 53 L 0 50 L 0 47 L 0 44 L 1 42 L 2 39 L 3 36 L 4 34 L 6 31 L 8 29 L 10 27 L 12 25 L 14 23 L 16 22 L 19 21 L 21 19 L 24 19 L 27 18 L 30 18 L 32 18 L 35 18 L 38 18 L 41 19 L 44 19 L 46 21 L 49 22 L 49 22 L 46 23 L 44 25 L 42 27 L 40 29 L 38 31 L 37 34 L 36 36 L 34 39 L 34 42 L 33 44 L 33 47 L 32 50 L 33 53 L 33 56 L 34 58 L 34 61 L 36 64 L 37 66 L 38 69 L 40 71 L 42 73 L 44 75 L 46 77 L 49 78", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", fill: "url(#difference)", stroke: "currentColor", fillRule: "evenodd" }));\n return {\n name: "difference",\n execute({ contents, selected }) {\n var _a, _b, _c, _d;\n const first = contents[selected[0][0]];\n if (!first) return;\n const firstGeometries = (_b = (_a = ctx.getContentModel(first)) == null ? void 0 : _a.getGeometries) == null ? void 0 : _b.call(_a, first, contents);\n if (!firstGeometries) return;\n const second = contents[selected[1][0]];\n if (!second) return;\n const secondGeometries = (_d = (_c = ctx.getContentModel(second)) == null ? void 0 : _c.getGeometries) == null ? void 0 : _d.call(_c, second, contents);\n if (!secondGeometries) return;\n if (firstGeometries.regions && secondGeometries.regions) {\n const result = firstGeometries.regions.map((r) => ctx.getHatchesDifference({ border: r.lines, holes: r.holes || [] }, (secondGeometries.regions || []).map((g) => ({ border: g.lines, holes: g.holes || [] })))).flat();\n ctx.deleteSelectedContents(contents, selected.map((s) => s[0]));\n contents.push(...result.map((r) => ({ ...first, type: "hatch", border: r.border, holes: r.holes, ref: void 0 })));\n return;\n }\n const lines = ctx.getGeometryLinesDifferenceLines(firstGeometries.lines, secondGeometries.lines);\n ctx.deleteSelectedContents(contents, selected.map((s) => s[0]));\n const allLines = ctx.getSeparatedGeometryLines(lines);\n contents.push(...allLines.map((n) => ({ type: "geometry lines", lines: n })));\n },\n contentSelectable(content, contents) {\n return ctx.contentIsDeletable(content, contents);\n },\n selectCount: 2,\n icon\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/edit-container.plugin.tsx\nfunction getCommand(ctx) {\n function contentSelectable(c) {\n return !c.readonly && ctx.isContainerContent(c);\n }\n const React = ctx.React;\n const startIcon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "42,73 42,74 41,75 41,77 41,78 40,79 39,81 39,82 38,83 37,84 36,85 35,86 34,86 32,87 31,88 30,88 28,88 27,89 26,89 24,89 23,88 21,88 20,88 19,87 17,86 16,86 15,85 14,84 13,83 12,82 12,81 11,79 10,78 10,77 10,75 9,74 9,73 9,71 10,70 10,68 10,67 11,66 12,64 12,63 13,62 14,61 15,60 16,59 17,59 19,58 20,57 21,57 23,57 24,56 25,56 27,56 28,57 30,57 31,57 32,58 34,59 35,59 36,60 37,61 38,62 39,63 39,64 40,66 41,67 41,68 41,70 42,71 42,73", strokeWidth: "5", strokeDasharray: "10", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polygon", { points: "12,10 76,10 76,45 12,45", strokeWidth: "5", strokeDasharray: "10", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polygon", { points: "70,93 93,52 46,52", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n const startCommand = {\n name: "start edit container",\n icon: startIcon,\n execute({ contents, selected, setEditingContentPath }) {\n contents.forEach((content, index) => {\n var _a, _b;\n if (content && ctx.isSelected([index], selected) && ((_b = (_a = this.contentSelectable) == null ? void 0 : _a.call(this, content, contents)) != null ? _b : true)) {\n setEditingContentPath(contentSelectable(content) ? [index, "contents"] : void 0);\n }\n });\n },\n contentSelectable,\n selectCount: 1\n };\n const cancelIcon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polygon", { points: "37,82 32,77 45,64 34,52 22,65 16,58 4,90", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polygon", { points: "83,40 78,34 65,46 53,35 67,24 61,17 94,8", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polygon", { points: "60,82 66,78 53,64 64,53 76,66 83,60 93,93", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polygon", { points: "17,38 22,32 35,45 46,34 34,23 40,16 7,5", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }));\n const cancelCommand = {\n name: "cancel edit container",\n execute({ setEditingContentPath }) {\n setEditingContentPath(void 0);\n },\n selectCount: 0,\n icon: cancelIcon\n };\n return [startCommand, cancelCommand];\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/ellipse.plugin.tsx\nfunction getModel(ctx) {\n const EllipseContent = ctx.and(ctx.BaseContent("ellipse"), ctx.StrokeFields, ctx.FillFields, ctx.AngleDeltaFields, ctx.Ellipse);\n const EllipseArcContent = ctx.and(ctx.BaseContent("ellipse arc"), ctx.StrokeFields, ctx.FillFields, ctx.AngleDeltaFields, ctx.EllipseArc);\n const getRefIds = (content) => ctx.getStrokeAndFillRefIds(content);\n const ellipseGeometriesCache = new ctx.WeakmapValuesCache();\n const ellipseArcGeometriesCache = new ctx.WeakmapValuesCache();\n function getEllipseGeometries(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return ellipseGeometriesCache.get(content, refs, () => {\n var _a;\n const points = ctx.ellipseToPolygon(content, (_a = content.angleDelta) != null ? _a : ctx.defaultAngleDelta);\n const lines = Array.from(ctx.iteratePolygonLines(points));\n const polylinePoints = ctx.polygonToPolyline(points);\n const center = ctx.getEllipseCenter(content);\n const left = ctx.rotatePositionByEllipseCenter({ x: content.cx - content.rx, y: content.cy }, content);\n const right = ctx.rotatePositionByEllipseCenter({ x: content.cx + content.rx, y: content.cy }, content);\n const top = ctx.rotatePositionByEllipseCenter({ x: content.cx, y: content.cy - content.ry }, content);\n const bottom = ctx.rotatePositionByEllipseCenter({ x: content.cx, y: content.cy + content.ry }, content);\n const focus = ctx.getEllipseFocus(content);\n return {\n lines: [{\n type: "ellipse arc",\n curve: ctx.ellipseToEllipseArc(content)\n }],\n points,\n center,\n left,\n right,\n top,\n bottom,\n focus,\n bounding: ctx.getEllipseBounding(content),\n renderingLines: ctx.dashedPolylineToLines(polylinePoints, content.dashArray),\n regions: ctx.hasFill(content) ? [\n {\n lines,\n points\n }\n ] : void 0\n };\n });\n }\n function getEllipseArcGeometries(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return ellipseArcGeometriesCache.get(content, refs, () => {\n var _a;\n const points = ctx.ellipseArcToPolyline(content, (_a = content.angleDelta) != null ? _a : ctx.defaultAngleDelta);\n const lines = Array.from(ctx.iteratePolylineLines(points));\n const center = ctx.getEllipseCenter(content);\n const focus = ctx.getEllipseFocus(content);\n const startRadian = ctx.angleToRadian(content.startAngle);\n const endRadian = ctx.angleToRadian(content.endAngle);\n const middleRadian = (startRadian + endRadian) / 2;\n return {\n lines: [{\n type: "ellipse arc",\n curve: content\n }],\n points,\n center,\n focus,\n start: ctx.getEllipsePointAtRadian(content, startRadian),\n end: ctx.getEllipsePointAtRadian(content, endRadian),\n middle: ctx.getEllipsePointAtRadian(content, middleRadian),\n bounding: ctx.getEllipseArcBounding(content),\n renderingLines: ctx.dashedPolylineToLines(points, content.dashArray),\n regions: ctx.hasFill(content) ? [\n {\n lines,\n points\n }\n ] : void 0\n };\n });\n }\n const React = ctx.React;\n const ellipseModel = {\n type: "ellipse",\n ...ctx.strokeModel,\n ...ctx.fillModel,\n ...ctx.angleDeltaModel,\n move(content, offset) {\n ctx.moveEllipse(content, offset);\n },\n rotate(content, center, angle) {\n ctx.rotateEllipse(content, center, angle);\n },\n scale(content, center, sx, sy) {\n ctx.scaleEllipse(content, center, sx, sy);\n },\n skew(content, center, sx, sy) {\n ctx.skewEllipse(content, center, sx, sy);\n },\n mirror(content, line, angle) {\n ctx.mirrorEllipse(content, line, angle);\n },\n offset(content, point, distance, contents) {\n if (!distance) {\n distance = Math.min(...getEllipseGeometries(content, contents).lines.map((line) => ctx.getPointAndGeometryLineMinimumDistance(point, line)));\n }\n return ctx.getParallelEllipsesByDistance(content, distance)[ctx.pointSideToIndex(ctx.getPointSideOfEllipse(point, content))];\n },\n break(content, points) {\n if (points.length < 2) {\n return;\n }\n const angles = points.map((p) => ctx.getEllipseAngle(p, content));\n angles.sort((a, b) => a - b);\n return angles.map((a, i) => ({\n ...content,\n type: "ellipse arc",\n startAngle: a,\n endAngle: i === angles.length - 1 ? angles[0] + 360 : angles[i + 1]\n }));\n },\n render(content, renderCtx) {\n const { options, target, dashed } = ctx.getStrokeFillRenderOptionsFromRenderContext(content, renderCtx);\n if (dashed) {\n const { points } = getEllipseGeometries(content, renderCtx.contents);\n return target.renderPolygon(points, options);\n }\n return target.renderEllipse(content.cx, content.cy, content.rx, content.ry, { ...options, angle: content.angle });\n },\n getOperatorRenderPosition(content) {\n return ctx.getEllipseCenter(content);\n },\n getEditPoints(content, contents) {\n return ctx.getEditPointsFromCache(content, () => {\n var _a;\n const { center, left, right, top, bottom } = getEllipseGeometries(content, contents);\n const rotate = -((_a = content.angle) != null ? _a : 0);\n return {\n editPoints: [\n {\n x: content.cx,\n y: content.cy,\n cursor: "move",\n type: "move",\n update(c, { cursor, start, scale }) {\n if (!isEllipseContent(c)) {\n return;\n }\n c.cx += cursor.x - start.x;\n c.cy += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [center, cursor] }] };\n }\n },\n {\n x: left.x,\n y: left.y,\n cursor: ctx.getResizeCursor(-rotate, "left"),\n update(c, { cursor, scale }) {\n if (!isEllipseContent(c)) {\n return;\n }\n c.rx = ctx.getTwoPointsDistance(cursor, center);\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [center, cursor] }] };\n }\n },\n {\n x: right.x,\n y: right.y,\n cursor: ctx.getResizeCursor(-rotate, "right"),\n update(c, { cursor, scale }) {\n if (!isEllipseContent(c)) {\n return;\n }\n c.rx = ctx.getTwoPointsDistance(cursor, center);\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [center, cursor] }] };\n }\n },\n {\n x: top.x,\n y: top.y,\n cursor: ctx.getResizeCursor(-rotate, "top"),\n update(c, { cursor, scale }) {\n if (!isEllipseContent(c)) {\n return;\n }\n c.ry = ctx.getTwoPointsDistance(cursor, center);\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [center, cursor] }] };\n }\n },\n {\n x: bottom.x,\n y: bottom.y,\n cursor: ctx.getResizeCursor(-rotate, "bottom"),\n update(c, { cursor, scale }) {\n if (!isEllipseContent(c)) {\n return;\n }\n c.ry = ctx.getTwoPointsDistance(cursor, center);\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [center, cursor] }] };\n }\n }\n ],\n angleSnapStartPoint: ctx.getEllipseCenter(content)\n };\n });\n },\n getSnapPoints(content, contents) {\n const { center, left, right, top, bottom, focus } = getEllipseGeometries(content, contents);\n return ctx.getSnapPointsFromCache(content, () => [\n { ...center, type: "center" },\n { ...left, type: "endpoint" },\n { ...right, type: "endpoint" },\n { ...top, type: "endpoint" },\n { ...bottom, type: "endpoint" },\n ...focus.map((p) => ({ ...p, type: "center" }))\n ]);\n },\n getGeometries: getEllipseGeometries,\n propertyPanel(content, update, contents, { acquirePoint }) {\n return {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isEllipseContent(c)) {\n c.cx = p.x;\n c.cy = p.y;\n }\n })) }, "canvas"),\n cx: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.cx, setValue: (v) => update((c) => {\n if (isEllipseContent(c)) {\n c.cx = v;\n }\n }) }),\n cy: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.cy, setValue: (v) => update((c) => {\n if (isEllipseContent(c)) {\n c.cy = v;\n }\n }) }),\n rx: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.rx, setValue: (v) => update((c) => {\n if (isEllipseContent(c)) {\n c.rx = v;\n }\n }) }),\n ry: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.ry, setValue: (v) => update((c) => {\n if (isEllipseContent(c)) {\n c.ry = v;\n }\n }) }),\n angle: [\n /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.angle !== void 0, setValue: (v) => update((c) => {\n if (isEllipseContent(c)) {\n c.angle = v ? 0 : void 0;\n }\n }) }),\n content.angle !== void 0 ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.angle, setValue: (v) => update((c) => {\n if (isEllipseContent(c)) {\n c.angle = v;\n }\n }) }) : void 0\n ],\n ...ctx.getStrokeContentPropertyPanel(content, update, contents),\n ...ctx.getFillContentPropertyPanel(content, update, contents),\n ...ctx.getAngleDeltaContentPropertyPanel(content, update)\n };\n },\n isValid: (c, p) => ctx.validate(c, EllipseContent, p),\n getRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n deleteRefId: ctx.deleteStrokeAndFillRefIds,\n isPointIn: (content, point, contents) => ctx.pointInPolygon(point, getEllipseGeometries(content, contents).points),\n getArea: (content) => Math.PI * content.rx * content.ry\n };\n return [\n ellipseModel,\n {\n type: "ellipse arc",\n ...ctx.strokeModel,\n ...ctx.fillModel,\n ...ctx.angleDeltaModel,\n move: ellipseModel.move,\n rotate: ellipseModel.rotate,\n scale(content, center, sx, sy) {\n ctx.scaleEllipseArc(content, center, sx, sy);\n },\n skew(content, center, sx, sy) {\n ctx.skewEllipseArc(content, center, sx, sy);\n },\n mirror(content, line, angle) {\n ctx.mirrorEllipseArc(content, line, angle);\n },\n break(content, points) {\n if (points.length === 0) {\n return;\n }\n const angles = points.map((p) => ctx.normalizeAngleInRange(ctx.getEllipseAngle(p, content), content));\n angles.sort((a, b) => a - b);\n const result = [];\n if (!ctx.isSameNumber(angles[0], content.startAngle)) {\n result.push({\n ...content,\n type: "ellipse arc",\n startAngle: content.startAngle,\n endAngle: angles[0]\n });\n }\n angles.forEach((a, i) => {\n if (i === angles.length - 1) {\n if (!ctx.isSameNumber(a, content.endAngle)) {\n result.push({\n ...content,\n type: "ellipse arc",\n startAngle: a,\n endAngle: content.endAngle\n });\n }\n } else {\n result.push({\n ...content,\n type: "ellipse arc",\n startAngle: a,\n endAngle: angles[i + 1]\n });\n }\n });\n return result.length > 1 ? result : void 0;\n },\n offset(content, point, distance, contents) {\n if (!distance) {\n distance = Math.min(...getEllipseArcGeometries(content, contents).lines.map((line) => ctx.getPointAndGeometryLineMinimumDistance(point, line)));\n }\n return ctx.getParallelEllipseArcsByDistance(content, distance)[ctx.pointSideToIndex(ctx.getPointSideOfEllipseArc(point, content))];\n },\n join(content, target) {\n if (isEllipseArcContent(target)) {\n return ctx.mergeEllipseArc(content, target);\n }\n return;\n },\n extend(content, point) {\n const angle = ctx.getEllipseAngle(point, content);\n const endAngle = ctx.getFormattedEndAngle({ startAngle: content.startAngle, endAngle: angle });\n const startAngle = ctx.getFormattedStartAngle({ startAngle: angle, endAngle: content.endAngle });\n const angle1 = Math.abs(endAngle - content.startAngle);\n const angle2 = Math.abs(content.endAngle - startAngle);\n if (angle1 < angle2) {\n content.endAngle = endAngle;\n } else {\n content.startAngle = startAngle;\n }\n },\n render(content, renderCtx) {\n const { options, target } = ctx.getStrokeFillRenderOptionsFromRenderContext(content, renderCtx);\n const { points } = getEllipseArcGeometries(content, renderCtx.contents);\n return target.renderPolyline(points, options);\n },\n renderIfSelected(content, { color, target, strokeWidth, contents }) {\n const { points } = getEllipseArcGeometries({ ...content, startAngle: content.endAngle, endAngle: content.startAngle }, contents);\n return target.renderPolyline(points, { strokeColor: color, dashArray: [4], strokeWidth });\n },\n getOperatorRenderPosition(content, contents) {\n const { points } = getEllipseArcGeometries(content, contents);\n return points[0];\n },\n getEditPoints(content, contents) {\n return ctx.getEditPointsFromCache(content, () => {\n var _a;\n const { center, start, end } = getEllipseArcGeometries(content, contents);\n const rotate = -((_a = content.angle) != null ? _a : 0);\n return {\n editPoints: [\n {\n x: content.cx,\n y: content.cy,\n cursor: "move",\n update(c, { cursor, start: start2, scale }) {\n if (!isEllipseArcContent(c)) {\n return;\n }\n c.cx += cursor.x - start2.x;\n c.cy += cursor.y - start2.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [center, cursor] }] };\n }\n },\n {\n ...start,\n cursor: ctx.getResizeCursor(content.startAngle - rotate, "top"),\n update(c, { cursor, scale }) {\n if (!isEllipseArcContent(c)) {\n return;\n }\n c.startAngle = ctx.getEllipseAngle(cursor, content);\n ctx.normalizeAngleRange(c);\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [center, cursor] }] };\n }\n },\n {\n ...end,\n cursor: ctx.getResizeCursor(content.endAngle - rotate, "top"),\n update(c, { cursor, scale }) {\n if (!isEllipseArcContent(c)) {\n return;\n }\n c.endAngle = ctx.getEllipseAngle(cursor, content);\n ctx.normalizeAngleRange(c);\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [center, cursor] }] };\n }\n }\n ],\n angleSnapStartPoint: center\n };\n });\n },\n getSnapPoints(content, contents) {\n return ctx.getSnapPointsFromCache(content, () => {\n const { center, start, end, middle, focus } = getEllipseArcGeometries(content, contents);\n return [\n { ...center, type: "center" },\n { ...start, type: "endpoint" },\n { ...end, type: "endpoint" },\n { ...middle, type: "midpoint" },\n ...focus.map((p) => ({ ...p, type: "center" }))\n ];\n });\n },\n getGeometries: getEllipseArcGeometries,\n propertyPanel(content, update, contents, { acquirePoint }) {\n return {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isEllipseArcContent(c)) {\n c.cx = p.x;\n c.cy = p.y;\n }\n })) }, "canvas"),\n cx: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.cx, setValue: (v) => update((c) => {\n if (isEllipseArcContent(c)) {\n c.cx = v;\n }\n }) }),\n cy: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.cy, setValue: (v) => update((c) => {\n if (isEllipseArcContent(c)) {\n c.cy = v;\n }\n }) }),\n rx: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.rx, setValue: (v) => update((c) => {\n if (isEllipseArcContent(c)) {\n c.rx = v;\n }\n }) }),\n ry: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.ry, setValue: (v) => update((c) => {\n if (isEllipseArcContent(c)) {\n c.ry = v;\n }\n }) }),\n angle: [\n /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.angle !== void 0, setValue: (v) => update((c) => {\n if (isEllipseArcContent(c)) {\n c.angle = v ? 0 : void 0;\n }\n }) }),\n content.angle !== void 0 ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.angle, setValue: (v) => update((c) => {\n if (isEllipseArcContent(c)) {\n c.angle = v;\n }\n }) }) : void 0\n ],\n startAngle: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.startAngle, setValue: (v) => update((c) => {\n if (isEllipseArcContent(c)) {\n c.startAngle = v;\n }\n }) }),\n endAngle: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.endAngle, setValue: (v) => update((c) => {\n if (isEllipseArcContent(c)) {\n c.endAngle = v;\n }\n }) }),\n counterclockwise: /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.counterclockwise === true, setValue: (v) => update((c) => {\n if (isEllipseArcContent(c)) {\n c.counterclockwise = v ? true : void 0;\n }\n }) }),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents),\n ...ctx.getFillContentPropertyPanel(content, update, contents),\n ...ctx.getAngleDeltaContentPropertyPanel(content, update)\n };\n },\n isValid: (c, p) => ctx.validate(c, EllipseArcContent, p),\n getRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n deleteRefId: ctx.deleteStrokeAndFillRefIds,\n getArea: (content) => {\n const radian = ctx.angleToRadian(content.endAngle - content.startAngle);\n return content.rx * content.ry * (radian - Math.sin(radian)) / 2;\n },\n reverse: (content) => ctx.reverseEllipseArc(content)\n }\n ];\n}\nfunction isEllipseContent(content) {\n return content.type === "ellipse";\n}\nfunction isEllipseArcContent(content) {\n return content.type === "ellipse arc";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon1 = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("ellipse", { cx: "50", cy: "50", rx: "42", ry: "25", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "50", cy: "50", r: "10", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "92", cy: "50", r: "10", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }));\n const icon2 = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("ellipse", { cx: "50", cy: "50", rx: "42", ry: "25", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "8", cy: "50", r: "10", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "92", cy: "50", r: "10", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }));\n const icon3 = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "7,71 8,69 8,66 9,64 10,61 12,58 14,55 16,52 18,49 21,46 23,43 27,40 30,38 33,35 37,32 40,30 44,28 48,25 51,23 55,22 59,20 62,19 66,18 69,17 72,16 76,16 78,16 81,16 84,17 86,17 88,18 89,19 91,21 92,22 92,24 93,26 93,29 92,31 92,34 91,36 90,39 88,42 86,45 84,48 82,51 79,54 77,57 73,60 70,62 67,65 63,68 60,70 56,72 52,75 49,77 45,78 41,80 38,81 34,82", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return [\n {\n name: "create ellipse",\n type: [\n { name: "ellipse center", hotkey: "EL", icon: icon1 },\n { name: "ellipse endpoint", icon: icon2 }\n ],\n useCommand({ onEnd, type, scale, strokeStyleId, fillStyleId }) {\n const { ellipse, onClick, onMove, input, startPosition, middlePosition, cursorPosition, reset } = ctx.useEllipseClickCreate(\n type === "ellipse center" || type === "ellipse endpoint" ? type : void 0,\n (c) => onEnd({\n updateContents: (contents) => contents.push({ ...c, strokeStyleId, fillStyleId, type: "ellipse" })\n })\n );\n const assistentContents = [];\n if (startPosition && cursorPosition) {\n if (middlePosition) {\n assistentContents.push({ type: "line", points: [startPosition, middlePosition], dashArray: [4 / scale] });\n if (type === "ellipse center") {\n assistentContents.push({ type: "line", points: [startPosition, cursorPosition], dashArray: [4 / scale] });\n } else if (ellipse) {\n assistentContents.push({ type: "line", points: [ctx.getEllipseCenter(ellipse), cursorPosition], dashArray: [4 / scale] });\n }\n } else {\n assistentContents.push({ type: "line", points: [startPosition, cursorPosition], dashArray: [4 / scale] });\n }\n }\n if (ellipse) {\n assistentContents.push({ ...ellipse, strokeStyleId, fillStyleId, type: "ellipse" });\n }\n return {\n onStart: onClick,\n input,\n onMove,\n assistentContents,\n lastPosition: middlePosition != null ? middlePosition : startPosition,\n reset\n };\n },\n selectCount: 0\n },\n {\n name: "create ellipse arc",\n useCommand({ onEnd, type, scale, strokeStyleId, fillStyleId }) {\n const { ellipse, ellipseArc, onClick, onMove, input, startPosition, middlePosition, cursorPosition, reset } = ctx.useEllipseArcClickCreate(\n type === "create ellipse arc" ? "ellipse center" : void 0,\n (c) => onEnd({\n updateContents: (contents) => contents.push({ ...c, strokeStyleId, fillStyleId, type: "ellipse arc" })\n })\n );\n const assistentContents = [];\n if (startPosition && cursorPosition) {\n if (middlePosition) {\n assistentContents.push({ type: "line", points: [startPosition, middlePosition], dashArray: [4 / scale] });\n const center = type === "create ellipse arc" ? startPosition : { x: (startPosition.x + middlePosition.x) / 2, y: (startPosition.y + middlePosition.y) / 2 };\n assistentContents.push({ type: "line", points: [center, cursorPosition], dashArray: [4 / scale] });\n } else {\n assistentContents.push({ type: "line", points: [startPosition, cursorPosition], dashArray: [4 / scale] });\n }\n }\n if (ellipseArc) {\n assistentContents.push({ ...ellipseArc, dashArray: [4 / scale], type: "ellipse" });\n if (ellipseArc.startAngle !== ellipseArc.endAngle) {\n assistentContents.push(\n {\n type: "line",\n points: [\n ctx.getEllipsePointAtRadian(ellipseArc, ctx.angleToRadian(ellipseArc.startAngle)),\n {\n x: ellipseArc.cx,\n y: ellipseArc.cy\n }\n ],\n dashArray: [4 / scale]\n },\n {\n type: "line",\n points: [\n {\n x: ellipseArc.cx,\n y: ellipseArc.cy\n },\n ctx.getEllipsePointAtRadian(ellipseArc, ctx.angleToRadian(ellipseArc.endAngle))\n ],\n dashArray: [4 / scale]\n }\n );\n }\n if (cursorPosition) {\n assistentContents.push({ type: "line", points: [ctx.getEllipseCenter(ellipseArc), cursorPosition], dashArray: [4 / scale] });\n }\n } else if (ellipse) {\n assistentContents.push({ ...ellipse, dashArray: [4 / scale], type: "ellipse" });\n if (cursorPosition) {\n assistentContents.push({ type: "line", points: [ctx.getEllipseCenter(ellipse), cursorPosition], dashArray: [4 / scale] });\n }\n }\n if (ellipseArc && ellipseArc.startAngle !== ellipseArc.endAngle) {\n assistentContents.push({ ...ellipseArc, strokeStyleId, fillStyleId, type: "ellipse arc" });\n }\n return {\n onStart: onClick,\n input,\n onMove,\n assistentContents,\n lastPosition: middlePosition != null ? middlePosition : startPosition,\n reset\n };\n },\n selectCount: 0,\n icon: icon3\n }\n ];\n}\nexport {\n getCommand,\n getModel,\n isEllipseArcContent,\n isEllipseContent\n};\n','// dev/cad-editor/plugins/coordinate-axis.plugin.tsx\nfunction isCoordinateAxisContent(content) {\n return content.type === "coordinate axis";\n}\n\n// dev/cad-editor/plugins/equation.plugin.tsx\nfunction getModel(ctx) {\n const EquationContent = ctx.and(ctx.BaseContent("equation"), ctx.StrokeFields, ctx.SegmentCountFields, {\n axisId: ctx.ContentRef,\n dependentVariable: ctx.or("x", "y"),\n expression: ctx.string\n });\n const getRefIds = (content) => [...ctx.getStrokeRefIds(content), ...ctx.toRefId(content.axisId, true)];\n const equationCache = new ctx.WeakmapValuesCache();\n function getGeometriesFromCache(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return equationCache.get(content, refs, () => {\n var _a;\n const axis = ctx.getReference(content.axisId, contents, isCoordinateAxisContent);\n if (axis) {\n if (content.expression) {\n try {\n const expression = ctx.parseExpression(ctx.tokenizeExpression(content.expression));\n const points = [];\n const segmentCount = (_a = content.segmentCount) != null ? _a : ctx.defaultSegmentCount;\n if (content.dependentVariable === "y") {\n const step = (axis.xMax - axis.xMin) / segmentCount;\n for (let x = axis.xMin; x <= axis.xMax; x += step) {\n const y = ctx.evaluateExpression(expression, {\n Math,\n x\n });\n if (typeof y === "number" && !isNaN(y)) {\n points.push({ x: x + axis.x, y: y * (axis.flipY ? -1 : 1) + axis.y });\n }\n }\n } else {\n const step = (axis.yMax - axis.yMin) / segmentCount;\n for (let y = axis.yMin; y <= axis.yMax; y += step) {\n const x = ctx.evaluateExpression(expression, {\n Math,\n y\n });\n if (typeof x === "number" && !isNaN(x)) {\n points.push({ x: x + axis.x, y: y * (axis.flipY ? -1 : 1) + axis.y });\n }\n }\n }\n const lines = Array.from(ctx.iteratePolylineLines(points));\n return {\n points,\n lines,\n bounding: ctx.getPointsBounding(points),\n renderingLines: ctx.dashedPolylineToLines(points, content.dashArray)\n };\n } catch (e) {\n console.info(e);\n }\n }\n return { lines: [], points: [], renderingLines: [] };\n }\n return { lines: [], points: [], renderingLines: [] };\n });\n }\n const React = ctx.React;\n return {\n type: "equation",\n ...ctx.strokeModel,\n ...ctx.segmentCountModel,\n render(content, renderCtx) {\n const { options, contents, target } = ctx.getStrokeRenderOptionsFromRenderContext(content, renderCtx);\n const { points } = getGeometriesFromCache(content, contents);\n return target.renderPolyline(points, options);\n },\n getGeometries: getGeometriesFromCache,\n propertyPanel(content, update, contents) {\n return {\n dependentVariable: /* @__PURE__ */ React.createElement(ctx.EnumEditor, { value: content.dependentVariable, enums: ["x", "y"], setValue: (v) => update((c) => {\n if (isEquationContent(c)) {\n c.dependentVariable = v;\n }\n }) }),\n expression: /* @__PURE__ */ React.createElement(ctx.ExpressionEditor, { suggestionSources: ctx.math, validate: ctx.validateExpression, value: content.expression, setValue: (v) => update((c) => {\n if (isEquationContent(c)) {\n c.expression = v;\n }\n }) }),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents),\n ...ctx.getSegmentCountContentPropertyPanel(content, update)\n };\n },\n isValid: (c, p) => ctx.validate(c, EquationContent, p),\n getRefIds,\n updateRefId(content, update) {\n const newAxisId = update(content.axisId);\n if (newAxisId !== void 0) {\n content.axisId = newAxisId;\n }\n ctx.updateStrokeRefIds(content, update);\n },\n deleteRefId: ctx.deleteStrokeRefIds\n };\n}\nfunction isEquationContent(content) {\n return content.type === "equation";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "7,93 88,93", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "7,12 7,93", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "97,93 68,101 68,85", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "7,3 15,32 1,32", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "7,93 8,85 9,81 10,78 11,76 12,74 12,72 13,71 14,69 15,68 16,66 17,65 18,64 19,62 20,61 21,60 21,59 22,58 23,57 24,56 25,55 26,54 27,53 28,52 29,51 29,51 30,50 31,49 32,48 33,47 34,47 35,46 36,45 37,44 38,44 38,43 39,42 40,41 41,41 42,40 43,39 44,39 45,38 46,37 47,37 47,36 48,35 49,35 50,34 51,34 52,33 53,32 54,32 55,31 56,31 56,30 57,30 58,29 59,28 60,28 61,27 62,27 63,26 64,26 65,25 65,25 66,24 67,24 68,23 69,23 70,22 71,22 72,21 73,21 74,20 74,20 75,19 76,19 77,18 78,18 79,17 80,17 81,16 82,16 83,15 84,15 84,14 85,14 86,13 87,13 88,13 89,12 90,12 91,11 92,11 93,10 93,10 94,9 95,9 96,9", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "create equation",\n icon,\n useCommand({ onEnd, type, selected }) {\n const [dependentVariable, setDependentVariable] = React.useState("y");\n const enabled = type === "create equation";\n let message = "";\n if (enabled) {\n message = dependentVariable === "x" ? "input f(y)" : "input f(x)";\n }\n const { input, setCursorPosition, clearText, setInputPosition, resetInput } = ctx.useCursorInput(message, enabled ? (e, text) => {\n if (e.key === "Enter") {\n onEnd({\n updateContents(contents) {\n contents.push({\n type: "equation",\n axisId: selected[0].path[0],\n dependentVariable,\n expression: text\n });\n }\n });\n clearText();\n }\n } : void 0);\n const reset = () => {\n resetInput();\n setDependentVariable("y");\n };\n return {\n input,\n onStart() {\n },\n onMove(p, viewportPosition) {\n setInputPosition(viewportPosition || p);\n setCursorPosition(p);\n },\n subcommand: enabled ? /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("button", { onClick: () => setDependentVariable(dependentVariable === "x" ? "y" : "x"), style: { position: "relative" } }, "f(", dependentVariable, ")")) : void 0,\n reset\n };\n },\n contentSelectable: isCoordinateAxisContent,\n selectCount: 1\n };\n}\nexport {\n getCommand,\n getModel,\n isEquationContent\n};\n','// dev/cad-editor/plugins/explode.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "17,11 83,11", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "80,91 16,91", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "9,84 9,19", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "90,19 90,85", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "explode",\n execute({ contents, selected }) {\n const newContents = [];\n const indexes = [];\n contents.forEach((content, index) => {\n var _a, _b, _c, _d;\n if (content && ctx.isSelected([index], selected) && ((_b = (_a = this.contentSelectable) == null ? void 0 : _a.call(this, content, contents)) != null ? _b : true)) {\n const result = (_d = (_c = ctx.getContentModel(content)) == null ? void 0 : _c.explode) == null ? void 0 : _d.call(_c, content, contents);\n if (result) {\n newContents.push(...result);\n indexes.push(index);\n }\n }\n });\n ctx.deleteSelectedContents(contents, indexes);\n contents.push(...newContents);\n },\n contentSelectable(content, contents) {\n const model = ctx.getContentModel(content);\n return (model == null ? void 0 : model.explode) !== void 0 && ctx.contentIsDeletable(content, contents);\n },\n hotkey: "X",\n icon\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/export-code.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "25,13 7,51 22,90", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "75,13 93,51 78,90", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "export code",\n execute({ contents, selected, width, height, transform }) {\n const result = [];\n contents.forEach((content, index) => {\n if (content && ctx.isSelected([index], selected)) {\n const model = ctx.getContentModel(content);\n if (model == null ? void 0 : model.render) {\n const code = model.render(content, {\n target: ctx.codeRenderTarget,\n transformColor: (c) => c,\n transformStrokeWidth: (w) => w,\n getFillColor: (c) => c.fillColor,\n getStrokeColor: (c) => {\n var _a;\n return (_a = c.strokeColor) != null ? _a : ctx.hasFill(c) ? void 0 : ctx.defaultStrokeColor;\n },\n getFillPattern: (c) => c.fillPattern ? {\n width: c.fillPattern.width,\n height: c.fillPattern.height,\n pattern: () => {\n var _a, _b, _c, _d;\n return ctx.codeRenderTarget.renderPath((_b = (_a = c.fillPattern) == null ? void 0 : _a.lines) != null ? _b : [], {\n strokeColor: (_d = (_c = c.fillPattern) == null ? void 0 : _c.strokeColor) != null ? _d : ctx.defaultStrokeColor\n });\n }\n } : void 0,\n contents\n });\n result.push(code);\n }\n }\n });\n navigator.clipboard.writeText(ctx.codeRenderTarget.renderResult(result, width, height, {\n transform\n }));\n },\n icon\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/export-jsx.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "25,13 7,51 22,90", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "75,13 93,51 78,90", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "64,15 51,90", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "export jsx",\n execute({ contents, selected }) {\n const result = [];\n contents.forEach((content, index) => {\n if (content && ctx.isSelected([index], selected)) {\n const model = ctx.getContentModel(content);\n if (model == null ? void 0 : model.render) {\n let color;\n if (ctx.isFillContent(content) && content.fillColor !== void 0) {\n color = content.fillColor;\n } else if (ctx.isStrokeContent(content)) {\n color = content.strokeColor;\n }\n color = color != null ? color : ctx.defaultStrokeColor;\n const svg = ctx.renderToStaticMarkup(model.render(content, {\n target: ctx.reactSvgRenderTarget,\n transformColor: (c) => c,\n transformStrokeWidth: (w) => w,\n getFillColor: (c) => c.fillColor,\n getStrokeColor: (c) => {\n var _a;\n return (_a = c.strokeColor) != null ? _a : ctx.hasFill(c) ? void 0 : ctx.defaultStrokeColor;\n },\n getFillPattern: (c) => c.fillPattern ? {\n width: c.fillPattern.width,\n height: c.fillPattern.height,\n pattern: () => {\n var _a, _b, _c, _d;\n return ctx.reactSvgRenderTarget.renderPath((_b = (_a = c.fillPattern) == null ? void 0 : _a.lines) != null ? _b : [], {\n strokeColor: (_d = (_c = c.fillPattern) == null ? void 0 : _c.strokeColor) != null ? _d : ctx.defaultStrokeColor\n });\n }\n } : void 0,\n contents\n })(index, 1, false, 100, 100));\n let jsx = "";\n for (let j = 0; j < svg.length; j++) {\n const c = svg[j];\n if (c === "-" && ctx.isLetter(svg[j + 1])) {\n jsx += svg[j + 1].toUpperCase();\n j++;\n } else {\n jsx += c;\n }\n }\n jsx = jsx.replaceAll(/[0-9]+\\.[0-9]+/g, (c) => Math.round(+c).toString());\n result.push(jsx.split(ctx.getColorString(color)).join("currentColor"));\n }\n }\n });\n navigator.clipboard.writeText(result.join("\\n"));\n },\n icon\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/export-png.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "51,0 51,60", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "51,60 83,28", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "51,60 21,31", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "11,84 91,84", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }));\n return {\n name: "export png",\n execute({ state, selected }) {\n const draws = [];\n const targets = [];\n state.forEach((content, index) => {\n if (content && ctx.isSelected([index], selected)) {\n const model = ctx.getContentModel(content);\n if (model == null ? void 0 : model.render) {\n targets.push(content);\n draws.push(model.render(content, {\n target: ctx.reactCanvasRenderTarget,\n transformColor: (c) => c,\n transformStrokeWidth: (w) => w,\n getFillColor: (c) => c.fillColor,\n getStrokeColor: (c) => {\n var _a;\n return (_a = c.strokeColor) != null ? _a : ctx.hasFill(c) ? void 0 : ctx.defaultStrokeColor;\n },\n getFillPattern: (c) => c.fillPattern ? {\n width: c.fillPattern.width,\n height: c.fillPattern.height,\n pattern: () => {\n var _a, _b, _c, _d;\n return ctx.reactCanvasRenderTarget.renderPath((_b = (_a = c.fillPattern) == null ? void 0 : _a.lines) != null ? _b : [], {\n strokeColor: (_d = (_c = c.fillPattern) == null ? void 0 : _c.strokeColor) != null ? _d : ctx.defaultStrokeColor\n });\n }\n } : void 0,\n contents: state\n }));\n }\n }\n });\n const width = window.innerWidth, height = window.innerHeight;\n const transform = ctx.zoomContentsToFit(width, height, targets, state, 0.8);\n if (!transform) return;\n const container = document.createElement("div");\n ctx.createRoot(container).render(/* @__PURE__ */ React.createElement(ctx.CanvasDrawCanvas, { width, height, draws, transform, onRender: () => {\n const child = container.children.item(0);\n if (child && child instanceof HTMLCanvasElement) {\n child.toBlob((blob) => {\n if (blob) {\n navigator.clipboard.write([new ClipboardItem({ [blob.type]: blob })]);\n }\n });\n }\n } }));\n },\n icon\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/extend.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "-0,0 101,0", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "56,-0 43,57", strokeWidth: "5", strokeDasharray: "10", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "43,57 35,100", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }));\n return {\n name: "extend",\n useCommand({ onEnd, selected, contents, backgroundColor, setSelected, contentVisible }) {\n var _a;\n const [hovering, setHovering] = React.useState();\n const [trimHovering, setTrimHovering] = React.useState();\n const [shift, setShift] = React.useState(false);\n const reset = () => {\n setHovering(void 0);\n setTrimHovering(void 0);\n };\n const assistentContents = [];\n if (hovering) {\n assistentContents.push(hovering.content);\n } else if (trimHovering) {\n if (ctx.isStrokeContent(trimHovering.content)) {\n assistentContents.push({\n ...trimHovering.content,\n strokeWidth: ((_a = trimHovering.content.strokeWidth) != null ? _a : ctx.getDefaultStrokeWidth(trimHovering.content)) + 2,\n strokeColor: backgroundColor,\n trueStrokeColor: true\n });\n }\n }\n return {\n onStart() {\n var _a2, _b, _c, _d, _e;\n if (hovering) {\n onEnd({\n updateContents(contents2) {\n var _a3, _b2;\n const content = ctx.getContentByIndex(contents2, hovering.path);\n if (content) {\n (_b2 = (_a3 = ctx.getContentModel(content)) == null ? void 0 : _a3.extend) == null ? void 0 : _b2.call(_a3, content, hovering.point, contents2);\n }\n }\n });\n } else if (trimHovering) {\n const content = ctx.getContentByIndex(contents, trimHovering.path);\n if (content) {\n const points = [];\n const lines = (_c = (_b = (_a2 = ctx.getContentModel(trimHovering.content)) == null ? void 0 : _a2.getGeometries) == null ? void 0 : _b.call(_a2, trimHovering.content, contents)) == null ? void 0 : _c.lines;\n if (lines) {\n const { start, end } = ctx.getGeometryLinesStartAndEnd(lines);\n if (start && end) {\n if (!ctx.isSamePoint(start, end)) {\n points.push(start, end);\n }\n } else if (start) {\n points.push(start);\n } else if (end) {\n points.push(end);\n }\n }\n if (points.length > 0) {\n const r = (_e = (_d = ctx.getContentModel(content)) == null ? void 0 : _d.break) == null ? void 0 : _e.call(_d, content, points, contents);\n if (r) {\n const index = ctx.getContentIndex(content, contents);\n const newContents = r.filter((c) => !ctx.deepEquals(trimHovering.content, c));\n onEnd({\n updateContents: (contents2) => {\n contents2[index] = void 0;\n contents2.push(...newContents);\n }\n });\n const newSelected = selected.map((s) => s.path);\n for (let i = 0; i < newContents.length; i++) {\n newSelected.push([contents.length + i]);\n }\n setSelected(...newSelected);\n }\n }\n }\n }\n reset();\n },\n onMove(p) {\n var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;\n for (const s of selected) {\n if (!contentVisible(s.content)) continue;\n const lines = (_c = (_b = (_a2 = ctx.getContentModel(s.content)) == null ? void 0 : _a2.getGeometries) == null ? void 0 : _b.call(_a2, s.content, contents)) == null ? void 0 : _c.lines;\n if (!lines) continue;\n if (!shift && ctx.isGeometryLinesClosed(lines)) continue;\n const lineIndex = lines.findIndex((line) => ctx.getPointAndGeometryLineMinimumDistance(p, line) < 5);\n if (lineIndex >= 0) {\n let direction;\n if (!shift) {\n if (lineIndex === 0) {\n if (lines.length === 1) {\n const { start, end } = ctx.getGeometryLineStartAndEnd(lines[0]);\n if (!start) {\n direction = "tail";\n } else if (!end) {\n direction = "head";\n } else {\n direction = ctx.getTwoPointsDistanceSquare(p, start) < ctx.getTwoPointsDistanceSquare(p, end) ? "head" : "tail";\n }\n } else {\n direction = "head";\n }\n } else if (lineIndex === lines.length - 1) {\n direction = "tail";\n }\n }\n let points = [];\n if (shift) {\n for (const c of selected) {\n if (c === s) continue;\n if (!contentVisible(c.content)) continue;\n const lines2 = (_f = (_e = (_d = ctx.getContentModel(c.content)) == null ? void 0 : _d.getGeometries) == null ? void 0 : _e.call(_d, c.content, contents)) == null ? void 0 : _f.lines;\n if (lines2) {\n for (let i = 0; i < lines.length; i++) {\n for (const line of lines2) {\n points.push(...ctx.getTwoGeometryLinesIntersectionPoint(lines[i], line));\n }\n }\n }\n }\n } else if (direction) {\n for (const c of selected) {\n if (c === s) continue;\n if (!contentVisible(c.content)) continue;\n const lines2 = (_i = (_h = (_g = ctx.getContentModel(c.content)) == null ? void 0 : _g.getGeometries) == null ? void 0 : _h.call(_g, c.content, contents)) == null ? void 0 : _i.lines;\n if (lines2) {\n for (const line of lines2) {\n points.push(...ctx.getTwoGeometryLinesIntersectionPoint(lines[lineIndex], line, [{ [direction]: true }, ctx.NOT_EXTENDED]));\n }\n }\n }\n }\n points = ctx.deduplicatePosition(points);\n if (shift) {\n let parts = [s.content];\n if (points.length > 0) {\n parts = ((_k = (_j = ctx.getContentModel(s.content)) == null ? void 0 : _j.break) == null ? void 0 : _k.call(_j, s.content, points, contents)) || [s.content];\n }\n const content = parts.length === 1 ? parts[0] : parts.find((f) => {\n var _a3, _b2, _c2;\n return (_c2 = (_b2 = (_a3 = ctx.getContentModel(f)) == null ? void 0 : _a3.getGeometries) == null ? void 0 : _b2.call(_a3, f, contents)) == null ? void 0 : _c2.lines.some((n) => ctx.getPointAndGeometryLineMinimumDistance(p, n) < 5);\n });\n if (content) {\n setTrimHovering({\n ...s,\n content\n });\n return;\n }\n } else if (points.length > 0 && direction) {\n const point = ctx.minimumBy(points, (n) => ctx.getTwoPointsDistanceSquare(n, p));\n setHovering({\n ...s,\n point,\n content: ctx.produce(s.content, (draft) => {\n var _a3, _b2;\n (_b2 = (_a3 = ctx.getContentModel(s.content)) == null ? void 0 : _a3.extend) == null ? void 0 : _b2.call(_a3, draft, point, contents);\n })\n });\n return;\n }\n }\n }\n setHovering(void 0);\n setTrimHovering(void 0);\n },\n onKeyDown(e) {\n setShift(e.shiftKey);\n },\n onKeyUp(e) {\n setShift(e.shiftKey);\n },\n reset,\n assistentContents,\n hovering: hovering ? [hovering.path] : trimHovering ? [trimHovering.path] : void 0\n };\n },\n contentSelectable(content, contents) {\n var _a, _b, _c, _d;\n return !content.readonly && !!((_d = (_c = (_b = (_a = ctx.getContentModel(content)) == null ? void 0 : _a.getGeometries) == null ? void 0 : _b.call(_a, content, contents)) == null ? void 0 : _c.lines) == null ? void 0 : _d.length);\n },\n icon,\n repeatedly: true\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/fill-style.plugin.tsx\nfunction getModel(ctx) {\n function getGeometriesFromCache(content) {\n return ctx.getGeometriesFromCache(content, /* @__PURE__ */ new Set(), () => {\n const points = [\n { x: content.x, y: content.y },\n { x: content.x + content.width, y: content.y },\n { x: content.x + content.width, y: content.y + content.height },\n { x: content.x, y: content.y + content.height }\n ];\n return {\n lines: [],\n bounding: ctx.getPointsBounding(points),\n regions: [\n {\n points,\n lines: Array.from(ctx.iteratePolygonLines(points))\n }\n ],\n renderingLines: []\n };\n });\n }\n const React = ctx.React;\n return {\n type: "fill style",\n ...ctx.fillModel,\n move(content, offset) {\n ctx.movePoint(content, offset);\n },\n scale(content, center, sx, sy) {\n ctx.scalePoint(content, center, sx, sy);\n },\n render(content, { target, getFillColor, transformColor, getFillPattern }) {\n const options = {\n strokeColor: content.isCurrent ? transformColor(16711680) : void 0,\n strokeWidth: content.isCurrent ? 1 : 0,\n fillColor: getFillColor(content),\n fillOpacity: content.fillOpacity,\n fillPattern: getFillPattern(content)\n };\n return target.renderRect(content.x, content.y, content.width, content.height, options);\n },\n getEditPoints(content) {\n return ctx.getEditPointsFromCache(content, () => {\n return {\n editPoints: [\n {\n ...content,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!ctx.isFillStyleContent(c)) {\n return;\n }\n c.x += cursor.x - start.x;\n c.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n }\n ]\n };\n });\n },\n getGeometries: getGeometriesFromCache,\n propertyPanel(content, update, contents, { acquirePoint }) {\n return {\n isCurrent: /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.isCurrent === true, setValue: (v) => update((c, draft) => {\n if (ctx.isFillStyleContent(c)) {\n const currentFillStyle = ctx.getFillStyles(contents).find((s) => s.content.isCurrent);\n if (currentFillStyle) {\n const c2 = draft[currentFillStyle.index];\n if (c2 && ctx.isFillStyleContent(c2)) {\n c2.isCurrent = void 0;\n }\n }\n c.isCurrent = v ? true : void 0;\n }\n }) }),\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (ctx.isFillStyleContent(c)) {\n c.x = p.x;\n c.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.x, setValue: (v) => update((c) => {\n if (ctx.isFillStyleContent(c)) {\n c.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.y, setValue: (v) => update((c) => {\n if (ctx.isFillStyleContent(c)) {\n c.y = v;\n }\n }) }),\n width: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.width, setValue: (v) => update((c) => {\n if (ctx.isFillStyleContent(c)) {\n c.width = v;\n }\n }) }),\n height: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.height, setValue: (v) => update((c) => {\n if (ctx.isFillStyleContent(c)) {\n c.height = v;\n }\n }) }),\n ...ctx.getFillContentPropertyPanel(content, update)\n };\n },\n isValid: (c, p) => ctx.validate(c, ctx.FillStyleContent, p)\n };\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("rect", { x: "5", y: "6", width: "89", height: "39", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("pattern", { id: "fill-style", patternUnits: "userSpaceOnUse", width: "20", height: "20" }, /* @__PURE__ */ React.createElement("path", { d: "M 0 10 L 10 0 M 20 10 L 10 20", strokeWidth: "1", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor", fillRule: "evenodd" })), /* @__PURE__ */ React.createElement("rect", { x: "5", y: "55", width: "89", height: "39", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "url(#fill-style)", stroke: "currentColor" }));\n return {\n name: "create fill style",\n selectCount: 0,\n icon,\n useCommand({ onEnd, type, scale }) {\n const [result, setResult] = React.useState();\n const reset = () => {\n setResult(void 0);\n };\n return {\n onStart() {\n if (result) {\n onEnd({\n updateContents: (contents) => {\n if (result) {\n contents.push(result);\n }\n }\n });\n reset();\n }\n },\n onMove(p) {\n if (type) {\n setResult({\n type: "fill style",\n x: p.x,\n y: p.y,\n width: 100 / scale,\n height: 20 / scale,\n fillColor: 0\n });\n }\n },\n assistentContents: result ? [result] : void 0,\n reset\n };\n }\n };\n}\nexport {\n getCommand,\n getModel\n};\n','// dev/cad-editor/plugins/circle-arc.plugin.tsx\nfunction isCircleContent(content) {\n return content.type === "circle";\n}\nfunction isArcContent(content) {\n return content.type === "arc";\n}\n\n// dev/cad-editor/plugins/line-polyline.plugin.tsx\nfunction isLineContent(content) {\n return content.type === "line";\n}\n\n// dev/cad-editor/plugins/fillet.plugin.tsx\nfunction getCommand(ctx) {\n function getFillets(content1, content2, radius) {\n const result = [];\n if (!contentSelectable(content1) || !contentSelectable(content2)) {\n return result;\n }\n const circles = [];\n if (isLineContent(content1)) {\n const line1 = ctx.twoPointLineToGeneralFormLine(content1.points[0], content1.points[1]);\n if (!line1) return [];\n if (isLineContent(content2)) {\n const line2 = ctx.twoPointLineToGeneralFormLine(content2.points[0], content2.points[1]);\n if (!line2) return [];\n circles.push(...ctx.getCirclesTangentTo2Lines(line1, line2, radius).map((c) => ({\n center: c,\n foot1: ctx.getPerpendicularPoint(c, line1),\n foot2: ctx.getPerpendicularPoint(c, line2)\n })));\n } else if (isCircleContent(content2) || isArcContent(content2)) {\n circles.push(...ctx.getCirclesTangentToLineAndCircle(line1, content2, radius).map((c) => ({\n center: c,\n foot1: ctx.getPerpendicularPoint(c, line1),\n foot2: ctx.getTwoCircleIntersectionPoints({ ...c, r: radius }, content2)[0]\n })));\n }\n } else if (isCircleContent(content1) || isArcContent(content1)) {\n if (isCircleContent(content2) || isArcContent(content2)) {\n circles.push(...ctx.getCirclesTangentTo2Circles(content1, content2, radius).map((c) => ({\n center: c,\n foot1: ctx.getTwoCircleIntersectionPoints({ ...c, r: radius }, content1)[0],\n foot2: ctx.getTwoCircleIntersectionPoints({ ...c, r: radius }, content2)[0]\n })));\n } else if (isLineContent(content2)) {\n const line2 = ctx.twoPointLineToGeneralFormLine(content2.points[0], content2.points[1]);\n if (!line2) return [];\n circles.push(...ctx.getCirclesTangentToLineAndCircle(line2, content1, radius).map((c) => ({\n center: c,\n foot1: ctx.getPerpendicularPoint(c, line2),\n foot2: ctx.getTwoCircleIntersectionPoints({ ...c, r: radius }, content1)[0]\n })));\n }\n }\n return circles.map(({ foot1, foot2, center: c }) => {\n const angle1 = ctx.radianToAngle(ctx.getTwoPointsRadian(foot1, c));\n const angle2 = ctx.radianToAngle(ctx.getTwoPointsRadian(foot2, c));\n const min = Math.min(angle1, angle2);\n const max = Math.max(angle1, angle2);\n if (max - min < 180) {\n return { ...c, r: radius, startAngle: min, endAngle: max };\n }\n return { ...c, r: radius, startAngle: max, endAngle: min + 360 };\n });\n }\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "9,10 92,10", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "92,10 92,93", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("path", { d: "M 92 60 A 50 50 0 0 0 42 10", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "fillet",\n useCommand({ onEnd, type, selected, scale }) {\n const [candidates, setCandidates] = React.useState([]);\n const [result, setResult] = React.useState();\n let message = "";\n if (type) {\n if (candidates.length > 0) {\n message = "select one result";\n } else {\n message = "input radius";\n }\n }\n const assistentContents = candidates.map((c) => ({\n ...c,\n type: "arc",\n dashArray: c === result ? void 0 : [4 / scale]\n }));\n const { input, setInputPosition, setCursorPosition, clearText, resetInput } = ctx.useCursorInput(message, type && candidates.length == 0 ? (e, text) => {\n if (e.key === "Enter") {\n const radius = +text;\n if (!isNaN(radius)) {\n setCandidates(getFillets(selected[0].content, selected[1].content, radius));\n clearText();\n }\n }\n } : void 0);\n const reset = () => {\n setCandidates([]);\n setResult(void 0);\n clearText();\n resetInput();\n };\n return {\n onStart(p) {\n setCursorPosition(p);\n if (result) {\n onEnd({\n updateContents: (contents) => {\n contents.push({ type: "arc", ...result });\n }\n });\n setCandidates([]);\n }\n },\n input,\n onMove(p, viewportPosition) {\n setCursorPosition(p);\n setInputPosition(viewportPosition || p);\n setResult(candidates.find((c) => ctx.getTwoNumbersDistance(ctx.getTwoPointsDistance(c, p), c.r) < 5));\n },\n assistentContents,\n reset\n };\n },\n selectCount: 2,\n contentSelectable,\n selectType: "select part",\n hotkey: "F",\n icon\n };\n}\nfunction contentSelectable(content) {\n return isLineContent(content) || isCircleContent(content) || isArcContent(content);\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/geometry-lines.plugin.tsx\nfunction getModel(ctx) {\n const GeometryLinesContent = ctx.and(ctx.BaseContent("geometry lines"), ctx.StrokeFields, ctx.FillFields, {\n lines: [ctx.GeometryLine]\n });\n const refGeometriesCache = new ctx.WeakmapValuesCache();\n function getGeometryLinesGeometries(content) {\n return refGeometriesCache.get(content, [], () => {\n const points = ctx.getGeometryLinesPoints(content.lines);\n const rays = [];\n const endPoints = [];\n for (const line of content.lines) {\n if (!Array.isArray(line) && line.type === "ray") {\n rays.push(line.line);\n }\n const { start, end } = ctx.getGeometryLineStartAndEnd(line);\n if (start && endPoints.every((p) => !ctx.isSamePoint(p, start))) {\n endPoints.push(start);\n }\n if (end && endPoints.every((p) => !ctx.isSamePoint(p, end))) {\n endPoints.push(end);\n }\n }\n const geometries = {\n lines: content.lines,\n points,\n endPoints,\n rays,\n bounding: ctx.getGeometryLinesBounding(content.lines),\n renderingLines: rays.length > 0 ? [] : ctx.dashedPolylineToLines(points, content.dashArray),\n region: rays.length > 0 ? [] : void 0\n };\n if (ctx.hasFill(content)) {\n return {\n ...geometries,\n lines: [],\n regions: [{\n lines: geometries.lines,\n points\n }],\n renderingLines: []\n };\n }\n return geometries;\n });\n }\n return {\n type: "geometry lines",\n ...ctx.strokeModel,\n ...ctx.fillModel,\n move(content, offset) {\n for (const line of content.lines) {\n ctx.moveGeometryLine(line, offset);\n }\n },\n rotate(content, center, angle) {\n for (const line of content.lines) {\n ctx.rotateGeometryLine(line, center, angle);\n }\n },\n scale(content, center, sx, sy) {\n ctx.scaleGeometryLines(content.lines, center, sx, sy);\n },\n skew(content, center, sx, sy) {\n ctx.skewGeometryLines(content.lines, center, sx, sy);\n },\n explode(content) {\n return content.lines.map((line) => ctx.geometryLineToContent(line));\n },\n break(content, intersectionPoints) {\n return ctx.breakGeometryLines(content.lines, intersectionPoints).map((lines) => ({ ...content, type: "geometry lines", lines }));\n },\n mirror(content, line, angle) {\n for (const n of content.lines) {\n ctx.mirrorGeometryLine(n, line, angle);\n }\n },\n offset(content, point, distance, _, lineJoin) {\n const newLines = ctx.trimGeometryLinesOffsetResult(ctx.getParallelGeometryLinesByDistancePoint(point, content.lines, distance, lineJoin), point);\n return newLines.map((n) => ctx.geometryLinesToPline(n));\n },\n join(content, target, contents) {\n var _a, _b, _c;\n const line2 = (_c = (_b = (_a = ctx.getContentModel(target)) == null ? void 0 : _a.getGeometries) == null ? void 0 : _b.call(_a, target, contents)) == null ? void 0 : _c.lines;\n if (!line2) return;\n const newLines = ctx.mergeGeometryLines(content.lines, line2);\n if (!newLines) return;\n return { ...content, lines: newLines };\n },\n extend(content, point) {\n ctx.extendGeometryLines(content.lines, point);\n },\n render(content, renderCtx) {\n const { options, target } = ctx.getStrokeFillRenderOptionsFromRenderContext(content, renderCtx);\n const { points, rays } = getGeometryLinesGeometries(content);\n return target.renderGroup([\n target.renderPath([points], options),\n ...rays.map((r) => target.renderRay(r.x, r.y, r.angle, { ...options, bidirectional: r.bidirectional }))\n ]);\n },\n getSnapPoints(content) {\n const { endPoints } = getGeometryLinesGeometries(content);\n return ctx.getSnapPointsFromCache(content, () => {\n return endPoints.map((p) => ({ ...p, type: "endpoint" }));\n });\n },\n getGeometries: getGeometryLinesGeometries,\n canSelectPart: true,\n propertyPanel(content, update, contents) {\n return {\n ...ctx.getStrokeContentPropertyPanel(content, update, contents),\n ...ctx.getFillContentPropertyPanel(content, update, contents)\n };\n },\n getRefIds: ctx.getStrokeAndFillRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n isValid: (c, p) => ctx.validate(c, GeometryLinesContent, p),\n reverse(content) {\n const newLines = ctx.reverseGeometryLines(content.lines);\n return { ...content, lines: newLines };\n }\n };\n}\nfunction isGeometryLinesContent(content) {\n return content.type === "geometry lines";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n return [\n {\n name: "create geometry lines",\n useCommand({ type, onEnd, width, height }) {\n const [json, setJson] = React.useState("");\n const reset = () => {\n setJson("");\n };\n return {\n reset,\n subcommand: type === "create geometry lines" ? /* @__PURE__ */ React.createElement("span", { style: { position: "relative" } }, /* @__PURE__ */ React.createElement(ctx.StringEditor, { textarea: true, value: json, style: { width: width * 0.7 + "px", height: height * 0.7 + "px" }, setValue: setJson }), /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => {\n if (json) {\n try {\n const lines = JSON.parse(json);\n const result = ctx.validate(lines, [ctx.GeometryLine]);\n if (result === true && lines.length > 0) {\n const allLines = ctx.getSeparatedGeometryLines(lines);\n onEnd({\n updateContents: (contents) => {\n contents.push(...allLines.map((n) => ({ type: "geometry lines", lines: n })));\n }\n });\n } else {\n console.info(result);\n }\n } catch (error) {\n console.info(error);\n }\n }\n } }, "OK")) : void 0\n };\n },\n selectCount: 0\n }\n ];\n}\nexport {\n getCommand,\n getModel,\n isGeometryLinesContent\n};\n','// dev/cad-editor/plugins/group.plugin.tsx\nfunction getModel(ctx) {\n const GroupContent = ctx.and(ctx.BaseContent("group"), ctx.ContainerFields, ctx.ClipFields);\n const getRefIds = (content) => ctx.toRefIds(content.contents);\n return {\n type: "group",\n ...ctx.containerModel,\n ...ctx.clipModel,\n move(content, offset) {\n var _a, _b;\n ctx.getContainerMove(content, offset);\n if (content.clip) {\n (_b = (_a = ctx.getContentModel(content.clip.border)) == null ? void 0 : _a.move) == null ? void 0 : _b.call(_a, content.clip.border, offset);\n }\n },\n rotate(content, center, angle, contents) {\n var _a, _b;\n ctx.getContainerRotate(content, center, angle, contents);\n if (content.clip) {\n (_b = (_a = ctx.getContentModel(content.clip.border)) == null ? void 0 : _a.rotate) == null ? void 0 : _b.call(_a, content.clip.border, center, angle, contents);\n }\n },\n scale(content, center, sx, sy, contents) {\n var _a, _b;\n ctx.getContainerScale(content, center, sx, sy, contents);\n if (content.clip) {\n return (_b = (_a = ctx.getContentModel(content.clip.border)) == null ? void 0 : _a.scale) == null ? void 0 : _b.call(_a, content.clip.border, center, sx, sy, contents);\n }\n },\n skew(content, center, sx, sy, contents) {\n var _a, _b;\n ctx.getContainerSkew(content, center, sx, sy, contents);\n if (content.clip) {\n return (_b = (_a = ctx.getContentModel(content.clip.border)) == null ? void 0 : _a.skew) == null ? void 0 : _b.call(_a, content.clip.border, center, sx, sy, contents);\n }\n },\n explode: ctx.getContainerExplode,\n mirror(content, line, angle, contents) {\n var _a, _b;\n ctx.getContainerMirror(content, line, angle, contents);\n if (content.clip) {\n (_b = (_a = ctx.getContentModel(content.clip.border)) == null ? void 0 : _a.mirror) == null ? void 0 : _b.call(_a, content.clip.border, line, angle, contents);\n }\n },\n getEditPoints(content, contents) {\n return ctx.getEditPointsFromCache(content, () => {\n return {\n editPoints: ctx.getClipContentEditPoints(content, contents)\n };\n });\n },\n render: (content, renderCtx) => {\n return ctx.renderClipContent(content, ctx.getContainerRender(content, renderCtx), renderCtx);\n },\n renderIfSelected(content, renderCtx) {\n const result = ctx.getContainerRenderIfSelected(content, renderCtx, [content], getRefIds);\n return ctx.renderClipContentIfSelected(content, result, renderCtx);\n },\n getSnapPoints: ctx.getContainerSnapPoints,\n getGeometries: (content, contents) => ctx.getContainerGeometries(content, contents, getRefIds, [content]),\n propertyPanel: (content, update, contents, { acquireContent }) => {\n return {\n ...ctx.getVariableValuesContentPropertyPanel(content, ctx.getContainerVariableNames(content), update),\n ...ctx.getClipContentPropertyPanel(content, contents, acquireContent, update)\n };\n },\n isValid: (c, p) => ctx.validate(c, GroupContent, p),\n getRefIds\n };\n}\nfunction getCommand(ctx) {\n function contentSelectable(content, contents) {\n return ctx.contentIsDeletable(content, contents);\n }\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("circle", { cx: "28", cy: "73", r: "22", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polygon", { points: "93,78 97,48 71,34 49,56 63,82", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("rect", { x: "7", y: "8", width: "50", height: "37", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "create group",\n execute({ contents, selected }) {\n const newContent = {\n type: "group",\n contents: contents.filter((c, i) => c && ctx.isSelected([i], selected) && contentSelectable(c, contents))\n };\n ctx.deleteSelectedContents(contents, selected.map((s) => s[0]));\n contents.push(newContent);\n },\n contentSelectable,\n hotkey: "G",\n icon\n };\n}\nexport {\n getCommand,\n getModel\n};\n','// dev/cad-editor/plugins/hatch.plugin.tsx\nfunction getModel(ctx) {\n const HatchContent = ctx.and(ctx.BaseContent("hatch"), ctx.FillFields, {\n border: [ctx.GeometryLine],\n holes: ctx.optional([[ctx.GeometryLine]]),\n ref: ctx.optional({\n point: ctx.Position,\n ids: [ctx.ContentRef]\n })\n });\n const getRefIds = (content) => {\n var _a;\n return [...ctx.getFillRefIds(content), ...ctx.toRefIds((_a = content.ref) == null ? void 0 : _a.ids)];\n };\n const refGeometriesCache = new ctx.WeakmapValuesCache();\n function getHatchGeometries(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return refGeometriesCache.get(content, refs, () => {\n let hatch = content;\n if (content.ref && content.ref.ids.length > 0) {\n const refContents = content.ref.ids.map((id) => ctx.getReference(id, contents)).filter((d) => !!d && !ctx.shallowEquals(d, content));\n if (refContents.length > 0) {\n const p = content.ref.point;\n const getGeometriesInRange = () => refContents.map((c) => ctx.getContentHatchGeometries(c, contents));\n const border = ctx.getHatchByPosition(p, getGeometriesInRange);\n if (border) {\n const holes = ctx.getHatchHoles(border.lines, getGeometriesInRange);\n hatch = {\n border: border.lines,\n holes: holes == null ? void 0 : holes.holes\n };\n }\n }\n }\n const points = ctx.getGeometryLinesPoints(hatch.border);\n const holesPoints = (hatch.holes || []).map((h) => ctx.getGeometryLinesPoints(h));\n return {\n lines: [],\n border: points,\n holes: holesPoints,\n bounding: ctx.getGeometryLinesBounding(hatch.border),\n renderingLines: [],\n regions: [\n {\n lines: hatch.border,\n points,\n holes: hatch.holes,\n holesPoints\n }\n ]\n };\n });\n }\n const React = ctx.React;\n return {\n type: "hatch",\n ...ctx.fillModel,\n move(content, offset) {\n if (content.ref) {\n ctx.movePoint(content.ref.point, offset);\n }\n for (const line of content.border) {\n ctx.moveGeometryLine(line, offset);\n }\n if (content.holes) {\n for (const hole of content.holes) {\n for (const line of hole) {\n ctx.moveGeometryLine(line, offset);\n }\n }\n }\n },\n rotate(content, center, angle) {\n if (content.ref) {\n ctx.rotatePoint(content.ref.point, center, angle);\n }\n for (const line of content.border) {\n ctx.rotateGeometryLine(line, center, angle);\n }\n if (content.holes) {\n for (const hole of content.holes) {\n for (const line of hole) {\n ctx.rotateGeometryLine(line, center, angle);\n }\n }\n }\n },\n scale(content, center, sx, sy) {\n if (content.ref) {\n ctx.scalePoint(content.ref.point, center, sx, sy);\n }\n ctx.scaleGeometryLines(content.border, center, sx, sy);\n if (content.holes) {\n for (const hole of content.holes) {\n ctx.scaleGeometryLines(hole, center, sx, sy);\n }\n }\n },\n skew(content, center, sx, sy) {\n if (content.ref) {\n ctx.skewPoint(content.ref.point, center, sx, sy);\n }\n ctx.skewGeometryLines(content.border, center, sx, sy);\n if (content.holes) {\n for (const hole of content.holes) {\n ctx.skewGeometryLines(hole, center, sx, sy);\n }\n }\n },\n mirror(content, line, angle) {\n if (content.ref) {\n ctx.mirrorPoint(content.ref.point, line);\n }\n for (const b of content.border) {\n ctx.mirrorGeometryLine(b, line, angle);\n }\n if (content.holes) {\n for (const hole of content.holes) {\n for (const h of hole) {\n ctx.mirrorGeometryLine(h, line, angle);\n }\n }\n }\n },\n join(content, target) {\n var _a;\n if (isHatchContent(target)) {\n const result = (_a = ctx.mergeHatches({ border: content.border, holes: content.holes || [] }, { border: target.border, holes: target.holes || [] })) == null ? void 0 : _a[0];\n if (result) {\n return {\n ...content,\n border: result.border,\n holes: result.holes,\n ref: void 0\n };\n }\n }\n return;\n },\n render(content, renderCtx) {\n const { options, target } = ctx.getFillRenderOptionsFromRenderContext(content, renderCtx);\n const { border, holes } = getHatchGeometries(content, renderCtx.contents);\n return target.renderPath([border, ...holes], options);\n },\n getGeometries: getHatchGeometries,\n getEditPoints(content) {\n return ctx.getEditPointsFromCache(content, () => {\n const editPoints = [];\n if (content.ref) {\n editPoints.push({\n x: content.ref.point.x,\n y: content.ref.point.y,\n cursor: "move",\n update(c, { cursor, start }) {\n if (!isHatchContent(c) || !c.ref) {\n return;\n }\n c.ref.point.x += cursor.x - start.x;\n c.ref.point.y += cursor.y - start.y;\n }\n });\n }\n return { editPoints };\n });\n },\n propertyPanel(content, update, contents) {\n return {\n ref: /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.ref !== void 0, readOnly: content.ref === void 0, setValue: (v) => update((c) => {\n if (isHatchContent(c) && !v) {\n c.ref = void 0;\n }\n }) }),\n ...ctx.getFillContentPropertyPanel(content, update, contents)\n };\n },\n isValid: (c, p) => ctx.validate(c, HatchContent, p),\n getRefIds,\n updateRefId(content, update) {\n if (content.ref) {\n for (const [i, id] of content.ref.ids.entries()) {\n const newRefId = update(id);\n if (newRefId !== void 0) {\n content.ref.ids[i] = newRefId;\n }\n }\n }\n ctx.updateFillRefIds(content, update);\n },\n deleteRefId(content, ids) {\n if (content.ref) {\n for (const id of ids) {\n const index = content.ref.ids.indexOf(id);\n if (index >= 0) {\n content.ref.ids.splice(index, 1);\n }\n }\n }\n ctx.deleteFillRefIds(content, ids);\n }\n };\n}\nfunction isHatchContent(content) {\n return content.type === "hatch";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "1,24 100,24", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "1,72 100,72", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "27,1 27,100", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "75,0 75,100", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("pattern", { id: "hatch", patternUnits: "userSpaceOnUse", width: "10", height: "10" }, /* @__PURE__ */ React.createElement("path", { d: "M 0 5 L 5 0 M 10 5 L 5 10", strokeWidth: "1", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor", fillRule: "evenodd" })), /* @__PURE__ */ React.createElement("polygon", { points: "75,43 75,72 27,72 27,24 75,24 75,43", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", fill: "url(#hatch)", stroke: "currentColor" }));\n return [\n {\n name: "create hatch",\n icon,\n useCommand({ onEnd, contents, getContentsInRange, width, height, x, y, rotate, scale }) {\n const [hatch, setHatch] = React.useState();\n const reset = () => {\n setHatch(void 0);\n };\n return {\n onStart: () => {\n onEnd({\n updateContents: (contents2) => {\n if (hatch) {\n contents2.push(hatch);\n }\n }\n });\n },\n onMove(p) {\n const lineSegment = ctx.getRayTransformedLineSegment({ x: p.x, y: p.y, angle: 0 }, width, height, { x, y, scale, rotate });\n if (!lineSegment) return;\n const getGeometriesInRange = (region) => getContentsInRange(region).map((c) => ctx.getContentHatchGeometries(c, contents));\n const border = ctx.getHatchByPosition(p, (line) => getGeometriesInRange(ctx.getGeometryLineBoundingFromCache(line)), lineSegment[1].x);\n if (border) {\n const holes = ctx.getHatchHoles(border.lines, getGeometriesInRange);\n setHatch({\n type: "hatch",\n border: border.lines,\n holes: holes == null ? void 0 : holes.holes,\n ref: {\n point: p,\n ids: [...border.ids, ...(holes == null ? void 0 : holes.ids) || []]\n }\n });\n } else {\n setHatch(void 0);\n }\n },\n assistentContents: hatch ? [hatch] : void 0,\n reset\n };\n },\n selectCount: 0\n }\n ];\n}\nexport {\n getCommand,\n getModel,\n isHatchContent\n};\n','// dev/cad-editor/plugins/hyperbola.plugin.tsx\nfunction getModel(ctx) {\n const HyperbolaContent = ctx.and(ctx.BaseContent("hyperbola"), ctx.StrokeFields, ctx.HyperbolaSegment, ctx.SegmentCountFields);\n const geometriesCache = new ctx.WeakmapValuesCache();\n function getHyperbolaGeometries(content, contents) {\n const refs = new Set(ctx.iterateRefContents(ctx.getStrokeRefIds(content), contents, [content]));\n return geometriesCache.get(content, refs, () => {\n var _a;\n const points = ctx.getHyperbolaPoints(content, (_a = content.segmentCount) != null ? _a : ctx.defaultSegmentCount);\n const lines = [{ type: "hyperbola curve", curve: content }];\n const c = Math.sqrt(content.a ** 2 + content.b ** 2);\n return {\n lines,\n c,\n angle: ctx.radianToAngle(Math.atan2(content.b, content.a)),\n start: ctx.getHyperbolaPointAtParam(content, content.t1),\n end: ctx.getHyperbolaPointAtParam(content, content.t2),\n startAngle: ctx.radianToAngle(ctx.getHyperbolaTangentRadianAtParam(content, content.t1)),\n endAngle: ctx.radianToAngle(ctx.getHyperbolaTangentRadianAtParam(content, content.t2)),\n origin: ctx.getPointByLengthAndRadian(content, -content.a, ctx.angleToRadian(content.angle)),\n focus: ctx.getPointByLengthAndRadian(content, c - content.a, ctx.angleToRadian(content.angle)),\n points,\n bounding: ctx.getGeometryLinesBounding(lines),\n renderingLines: ctx.dashedPolylineToLines(points, content.dashArray)\n };\n });\n }\n const React = ctx.React;\n return {\n type: "hyperbola",\n ...ctx.strokeModel,\n ...ctx.segmentCountModel,\n move(content, offset) {\n ctx.movePoint(content, offset);\n },\n rotate(content, center, angle) {\n ctx.rotateHyperbola(content, center, angle);\n },\n scale(content, center, sx, sy, contents) {\n const lines = getHyperbolaGeometries(content, contents).lines;\n ctx.scaleGeometryLines(lines, center, sx, sy);\n },\n skew(content, center, sx, sy, contents) {\n const lines = getHyperbolaGeometries(content, contents).lines;\n ctx.skewGeometryLines(lines, center, sx, sy);\n },\n mirror(content, line, angle) {\n ctx.mirrorHyperbola(content, line, angle);\n },\n break(content, intersectionPoints, contents) {\n const lines = getHyperbolaGeometries(content, contents).lines;\n return ctx.breakGeometryLines(lines, intersectionPoints).map((lines2) => ({ ...content, type: "geometry lines", lines: lines2 }));\n },\n offset(content, point, distance, contents) {\n if (!distance) {\n distance = Math.min(...getHyperbolaGeometries(content, contents).lines.map((line) => ctx.getPointAndGeometryLineMinimumDistance(point, line)));\n }\n return ctx.getParallelHyperbolaSegmentsByDistance(content, distance)[ctx.pointSideToIndex(ctx.getPointSideOfHyperbolaSegment(point, content))];\n },\n join(content, target, contents) {\n var _a, _b, _c;\n const line2 = (_c = (_b = (_a = ctx.getContentModel(target)) == null ? void 0 : _a.getGeometries) == null ? void 0 : _b.call(_a, target, contents)) == null ? void 0 : _c.lines;\n if (!line2) return;\n const lines = getHyperbolaGeometries(content, contents).lines;\n const newLines = ctx.mergeGeometryLines(lines, line2);\n if (!newLines) return;\n return { ...content, type: "geometry lines", lines: newLines };\n },\n extend(content, point) {\n const t = ctx.getHyperbolaParamAtPoint(content, point);\n if (ctx.isBefore(t, content.t1, content.t2)) {\n content.t1 = t;\n } else {\n content.t2 = t;\n }\n },\n render(content, renderCtx) {\n const { options, target } = ctx.getStrokeRenderOptionsFromRenderContext(content, renderCtx);\n const { points } = getHyperbolaGeometries(content, renderCtx.contents);\n return target.renderPolyline(points, options);\n },\n renderIfSelected(content, { color, target, strokeWidth, contents }) {\n const { origin, angle } = getHyperbolaGeometries(content, contents);\n return target.renderGroup([\n target.renderRay(content.x, content.y, content.angle, { strokeColor: color, dashArray: [4], strokeWidth }),\n target.renderRay(origin.x, origin.y, content.angle + angle, { strokeColor: color, dashArray: [4], strokeWidth }),\n target.renderRay(origin.x, origin.y, content.angle - angle, { strokeColor: color, dashArray: [4], strokeWidth })\n ]);\n },\n getEditPoints(content, contents) {\n return ctx.getEditPointsFromCache(content, () => {\n const { start, end, startAngle, endAngle, focus, origin } = getHyperbolaGeometries(content, contents);\n return {\n editPoints: [\n {\n x: content.x,\n y: content.y,\n cursor: "move",\n type: "move",\n update(c, { cursor, start: start2, scale }) {\n if (!isHyperbolaContent(c)) {\n return;\n }\n c.x += cursor.x - start2.x;\n c.y += cursor.y - start2.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [content, cursor] }] };\n }\n },\n {\n x: start.x,\n y: start.y,\n cursor: ctx.getResizeCursor(startAngle, "left"),\n update(c, { cursor, start: start2, scale }) {\n if (!isHyperbolaContent(c)) {\n return;\n }\n c.t1 = ctx.minimumBy(ctx.getPerpendicularParamsToHyperbola(cursor, content), (t) => ctx.getTwoPointsDistanceSquare(cursor, ctx.getHyperbolaPointAtParam(content, t)));\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start2, cursor] }] };\n }\n },\n {\n x: end.x,\n y: end.y,\n cursor: ctx.getResizeCursor(endAngle, "right"),\n update(c, { cursor, start: start2, scale }) {\n if (!isHyperbolaContent(c)) {\n return;\n }\n c.t2 = ctx.minimumBy(ctx.getPerpendicularParamsToHyperbola(cursor, content), (t) => ctx.getTwoPointsDistanceSquare(cursor, ctx.getHyperbolaPointAtParam(content, t)));\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start2, cursor] }] };\n }\n },\n {\n x: focus.x,\n y: focus.y,\n cursor: "move",\n update(c, { cursor, scale }) {\n if (!isHyperbolaContent(c)) {\n return;\n }\n const d = ctx.getTwoPointsDistance(content, cursor);\n c.b = Math.sqrt((content.a + d) ** 2 - content.a ** 2);\n c.angle = ctx.radianToAngle(ctx.getTwoPointsRadian(cursor, content));\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [content, cursor] }] };\n }\n },\n {\n x: origin.x,\n y: origin.y,\n cursor: "move",\n update(c, { cursor, scale }) {\n if (!isHyperbolaContent(c)) {\n return;\n }\n c.a = ctx.getTwoPointsDistance(content, cursor);\n c.angle = ctx.radianToAngle(ctx.getTwoPointsRadian(content, cursor));\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [content, cursor] }] };\n }\n }\n ]\n };\n });\n },\n getSnapPoints(content, contents) {\n return ctx.getSnapPointsFromCache(content, () => {\n const { start, end, focus } = getHyperbolaGeometries(content, contents);\n return [\n { ...start, type: "endpoint" },\n { ...end, type: "endpoint" },\n { ...content, type: "center" },\n { ...focus, type: "center" }\n ];\n });\n },\n getGeometries: getHyperbolaGeometries,\n propertyPanel(content, update, contents, { acquirePoint }) {\n const { c } = getHyperbolaGeometries(content, contents);\n return {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c2) => {\n if (isHyperbolaContent(c2)) {\n c2.x = p.x;\n c2.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.x, setValue: (v) => update((c2) => {\n if (isHyperbolaContent(c2)) {\n c2.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.y, setValue: (v) => update((c2) => {\n if (isHyperbolaContent(c2)) {\n c2.y = v;\n }\n }) }),\n a: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.a, setValue: (v) => update((c2) => {\n if (isHyperbolaContent(c2) && v > 0) {\n c2.a = v;\n }\n }) }),\n b: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.b, setValue: (v) => update((c2) => {\n if (isHyperbolaContent(c2) && v > 0) {\n c2.b = v;\n }\n }) }),\n c: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: c }),\n t1: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.t1, setValue: (v) => update((c2) => {\n if (isHyperbolaContent(c2)) {\n c2.t1 = v;\n }\n }) }),\n t2: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.t2, setValue: (v) => update((c2) => {\n if (isHyperbolaContent(c2)) {\n c2.t2 = v;\n }\n }) }),\n angle: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.angle, setValue: (v) => update((c2) => {\n if (isHyperbolaContent(c2)) {\n c2.angle = v;\n }\n }) }),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents),\n ...ctx.getSegmentCountContentPropertyPanel(content, update)\n };\n },\n isValid: (c, p) => ctx.validate(c, HyperbolaContent, p),\n getRefIds: ctx.getStrokeRefIds,\n updateRefId: ctx.updateStrokeRefIds,\n deleteRefId: ctx.deleteStrokeRefIds,\n reverse: ctx.reverseHyperbola\n };\n}\nfunction isHyperbolaContent(content) {\n return content.type === "hyperbola";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "100,93 99,92 99,92 98,91 97,90 96,89 96,88 95,87 94,86 93,86 93,85 92,84 91,83 91,82 90,81 89,80 89,79 88,79 87,78 87,77 86,76 85,75 85,74 84,73 84,73 83,72 83,71 82,70 81,69 81,68 80,67 80,66 79,66 79,65 79,64 78,63 78,62 77,61 77,60 77,60 76,59 76,58 76,57 76,56 76,55 75,54 75,53 75,53 75,52 75,51 75,50 75,49 75,48 75,47 75,47 75,46 76,45 76,44 76,43 76,42 76,41 77,40 77,40 77,39 78,38 78,37 79,36 79,35 79,34 80,34 80,33 81,32 81,31 82,30 83,29 83,28 84,27 84,27 85,26 85,25 86,24 87,23 87,22 88,21 89,21 89,20 90,19 91,18 91,17 92,16 93,15 93,14 94,14 95,13 96,12 96,11 97,10 98,9 99,8 99,8 100,7", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "0,93 1,92 1,92 2,91 3,90 4,89 4,88 5,87 6,86 7,86 7,85 8,84 9,83 9,82 10,81 11,80 11,79 12,79 13,78 13,77 14,76 15,75 15,74 16,73 16,73 17,72 17,71 18,70 19,69 19,68 20,67 20,66 21,66 21,65 21,64 22,63 22,62 23,61 23,60 23,60 24,59 24,58 24,57 24,56 24,55 25,54 25,53 25,53 25,52 25,51 25,50 25,49 25,48 25,47 25,47 25,46 24,45 24,44 24,43 24,42 24,41 23,40 23,40 23,39 22,38 22,37 21,36 21,35 21,34 20,34 20,33 19,32 19,31 18,30 17,29 17,28 16,27 16,27 15,26 15,25 14,24 13,23 13,22 12,21 11,21 11,20 10,19 9,18 9,17 8,16 7,15 7,14 6,14 5,13 4,12 4,11 3,10 2,9 1,8 1,8 0,7", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "100,0 0,100", strokeWidth: "5", strokeDasharray: "10", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "0,0 100,100", strokeWidth: "5", strokeDasharray: "10", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }));\n return {\n name: "create hyperbola",\n icon,\n useCommand({ onEnd, type, strokeStyleId }) {\n const [content, setContent] = React.useState();\n const [status, setStatus] = React.useState("position");\n const reset = () => {\n setContent(void 0);\n setStatus("position");\n };\n const assistentContents = [];\n if (content) {\n assistentContents.push(content);\n }\n return {\n onStart() {\n if (type !== "create hyperbola") return;\n if (status === "position") {\n setStatus("angle");\n } else if (status === "angle") {\n setStatus("t1");\n } else if (status === "t1") {\n setStatus("t2");\n } else if (status === "t2") {\n onEnd({\n updateContents: (contents) => contents.push(content)\n });\n reset();\n }\n },\n onMove(p) {\n if (type !== "create hyperbola") return;\n if (!content) {\n setContent({\n type: "hyperbola",\n x: p.x,\n y: p.y,\n a: 100,\n b: 100,\n t1: -2,\n t2: 2,\n angle: -90,\n strokeStyleId\n });\n } else if (status === "position") {\n setContent({\n ...content,\n x: p.x,\n y: p.y\n });\n } else if (status === "angle") {\n setContent({\n ...content,\n angle: ctx.radianToAngle(ctx.getTwoPointsRadian(p, content))\n });\n } else if (status === "t1") {\n const x = ctx.getPerpendicularParamToLine2D(p, content, ctx.getParabolaXAxisRadian(content));\n const y = ctx.getPerpendicularParamToLine2D(p, content, ctx.angleToRadian(content.angle));\n const t = x / content.b;\n const a = y / (Math.sqrt(t ** 2 + 1) - 1);\n setContent({\n ...content,\n a,\n t1: t\n });\n } else if (status === "t2") {\n setContent({\n ...content,\n t2: ctx.minimumBy(ctx.getPerpendicularParamsToHyperbola(p, content), (t) => ctx.getTwoPointsDistanceSquare(p, ctx.getHyperbolaPointAtParam(content, t)))\n });\n }\n },\n assistentContents,\n reset\n };\n },\n selectCount: 0\n };\n}\nexport {\n getCommand,\n getModel,\n isHyperbolaContent\n};\n','// dev/cad-editor/plugins/image.plugin.tsx\nfunction getModel(ctx) {\n const ImageContent = ctx.and(ctx.BaseContent("image"), ctx.Image, ctx.ClipFields);\n function getImageGeometries(content) {\n return ctx.getGeometriesFromCache(content, /* @__PURE__ */ new Set(), () => {\n const points = [\n { x: content.x, y: content.y + content.height },\n { x: content.x + content.width, y: content.y + content.height },\n { x: content.x + content.width, y: content.y },\n { x: content.x, y: content.y }\n ];\n const lines = Array.from(ctx.iteratePolygonLines(points));\n return {\n lines: [],\n bounding: ctx.getPointsBounding(points),\n regions: [\n {\n lines,\n points\n }\n ],\n renderingLines: []\n };\n });\n }\n const React = ctx.React;\n return {\n type: "image",\n ...ctx.clipModel,\n move(content, offset) {\n var _a, _b;\n ctx.movePoint(content, offset);\n if (content.clip) {\n (_b = (_a = ctx.getContentModel(content.clip.border)) == null ? void 0 : _a.move) == null ? void 0 : _b.call(_a, content.clip.border, offset);\n }\n },\n scale(content, center, sx, sy, contents) {\n var _a, _b;\n ctx.scalePoint(content, center, sx, sy);\n content.width *= sx;\n content.height *= sy;\n if (content.clip) {\n return (_b = (_a = ctx.getContentModel(content.clip.border)) == null ? void 0 : _a.scale) == null ? void 0 : _b.call(_a, content.clip.border, center, sx, sy, contents);\n }\n },\n getEditPoints(content, contents) {\n return ctx.getEditPointsFromCache(content, () => {\n return {\n editPoints: [\n {\n x: content.x,\n y: content.y,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isImageContent(c)) {\n return;\n }\n c.x += cursor.x - start.x;\n c.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [content, cursor] }] };\n }\n },\n ...ctx.getClipContentEditPoints(content, contents)\n ]\n };\n });\n },\n render(content, renderCtx) {\n const { target, isHoveringOrSelected, transformStrokeWidth } = renderCtx;\n const strokeWidth = transformStrokeWidth(0);\n const fuzzy = isHoveringOrSelected && strokeWidth !== 0;\n let image = target.renderImage(content.url, content.x, content.y, content.width, content.height);\n image = ctx.renderClipContent(content, image, renderCtx);\n if (fuzzy) {\n return target.renderGroup([\n target.renderRect(content.x, content.y, content.width, content.height, {\n strokeWidth,\n ...ctx.fuzzyStyle\n }),\n image\n ]);\n }\n return image;\n },\n renderIfSelected(content, renderCtx) {\n const { color, target, strokeWidth } = renderCtx;\n const result = target.renderRect(content.x, content.y, content.width, content.height, { strokeColor: color, dashArray: [4], strokeWidth });\n return ctx.renderClipContentIfSelected(content, result, renderCtx);\n },\n getOperatorRenderPosition(content) {\n return content;\n },\n getGeometries: getImageGeometries,\n propertyPanel(content, update, contents, { acquirePoint, acquireContent }) {\n return {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isImageContent(c)) {\n c.x = p.x;\n c.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.x, setValue: (v) => update((c) => {\n if (isImageContent(c)) {\n c.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.y, setValue: (v) => update((c) => {\n if (isImageContent(c)) {\n c.y = v;\n }\n }) }),\n width: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.width, setValue: (v) => update((c) => {\n if (isImageContent(c)) {\n c.width = v;\n }\n }) }),\n height: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.height, setValue: (v) => update((c) => {\n if (isImageContent(c)) {\n c.height = v;\n }\n }) }),\n url: /* @__PURE__ */ React.createElement(ctx.StringEditor, { value: content.url, setValue: (v) => update((c) => {\n if (isImageContent(c)) {\n c.url = v;\n }\n }) }),\n ...ctx.getClipContentPropertyPanel(content, contents, acquireContent, update)\n };\n },\n editPanel(content, _scale, update, _contents, cancel) {\n const y = 100;\n return /* @__PURE__ */ React.createElement(\n ctx.ImageEditor,\n {\n style: {\n zIndex: 11\n },\n y,\n onCancel: cancel,\n src: content.url,\n width: window.innerWidth,\n height: window.innerHeight - y,\n onCpmplete: (url, width, height) => {\n update((c) => {\n if (isImageContent(c)) {\n c.url = url;\n c.width = width;\n c.height = height;\n cancel();\n }\n });\n }\n }\n );\n },\n isValid: (c, p) => ctx.validate(c, ImageContent, p)\n };\n}\nfunction isImageContent(content) {\n return content.type === "image";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polygon", { points: "100,100 100,50 66,67 28,11 0,36 0,100", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "70", cy: "22", r: "13", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }));\n return {\n name: "create image",\n useCommand({ onEnd, type }) {\n const { image, onClick, onMove, input, reset } = ctx.useImageClickCreate(\n type === "create image",\n (c) => onEnd({\n updateContents: (contents) => contents.push({\n type: "image",\n ...c\n })\n })\n );\n const assistentContents = [];\n if (image) {\n assistentContents.push({\n type: "image",\n ...image\n });\n }\n return {\n onStart: onClick,\n input,\n onMove,\n assistentContents,\n reset\n };\n },\n selectCount: 0,\n hotkey: "I",\n icon\n };\n}\nexport {\n getCommand,\n getModel,\n isImageContent\n};\n','// dev/cad-editor/plugins/intersection.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("circle", { cx: "32", cy: "50", r: "32", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "65", cy: "50", r: "32", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("pattern", { id: "intersection", patternUnits: "userSpaceOnUse", width: "10", height: "10" }, /* @__PURE__ */ React.createElement("path", { d: "M 0 5 L 5 0 M 10 5 L 5 10", strokeWidth: "1", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor", fillRule: "evenodd" })), /* @__PURE__ */ React.createElement("path", { d: "M 49 78 L 46 77 L 44 75 L 42 73 L 40 71 L 38 69 L 37 66 L 36 64 L 34 61 L 34 58 L 33 56 L 33 53 L 32 50 L 33 47 L 33 44 L 34 42 L 34 39 L 36 36 L 37 34 L 38 31 L 40 29 L 42 27 L 44 25 L 46 23 L 49 22 L 49 22 L 51 23 L 53 25 L 55 27 L 57 29 L 59 31 L 61 34 L 62 36 L 63 39 L 64 42 L 64 44 L 65 47 L 65 50 L 65 53 L 64 56 L 64 58 L 63 61 L 62 64 L 61 66 L 59 69 L 57 71 L 55 73 L 53 75 L 51 77 L 49 78", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", fill: "url(#intersection)", stroke: "currentColor", fillRule: "evenodd" }));\n return {\n name: "intersection",\n execute({ contents, selected }) {\n var _a, _b, _c, _d;\n const first = contents[selected[0][0]];\n if (!first) return;\n const firstGeometries = (_b = (_a = ctx.getContentModel(first)) == null ? void 0 : _a.getGeometries) == null ? void 0 : _b.call(_a, first, contents);\n if (!firstGeometries) return;\n const second = contents[selected[1][0]];\n if (!second) return;\n const secondGeometries = (_d = (_c = ctx.getContentModel(second)) == null ? void 0 : _c.getGeometries) == null ? void 0 : _d.call(_c, second, contents);\n if (!secondGeometries) return;\n if (firstGeometries.regions && secondGeometries.regions) {\n const result = firstGeometries.regions.map((r) => ctx.getHatchesIntersection({ border: r.lines, holes: r.holes || [] }, (secondGeometries.regions || []).map((g) => ({ border: g.lines, holes: g.holes || [] })))).flat();\n ctx.deleteSelectedContents(contents, selected.map((s) => s[0]));\n contents.push(...result.map((r) => ({ ...first, type: "hatch", border: r.border, holes: r.holes, ref: void 0 })));\n return;\n }\n let points = ctx.deduplicatePosition(ctx.getIntersectionPoints(first, second, contents));\n const lines = Array.from(ctx.iterateGeometryLinesIntersectionLines(firstGeometries.lines, secondGeometries.lines));\n const newContents = [];\n if (lines.length > 0) {\n points = points.filter((p) => !ctx.pointIsOnGeometryLines(p, lines));\n const allLines = ctx.getSeparatedGeometryLines(lines);\n newContents.push(...allLines.map((n) => ({ type: "geometry lines", lines: n })));\n }\n newContents.push(...points.map((n) => ({ type: "point", x: n.x, y: n.y })));\n if (newContents.length > 0) {\n ctx.deleteSelectedContents(contents, selected.map((s) => s[0]));\n contents.push(...newContents);\n }\n },\n contentSelectable(content, contents) {\n return ctx.contentIsDeletable(content, contents);\n },\n selectCount: 2,\n icon\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/join.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "0,49 100,49", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "51,49 76,32 76,64", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", strokeOpacity: "1", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "54,49 27,32 28,65", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", strokeOpacity: "1", fill: "currentColor", stroke: "currentColor" }));\n return {\n name: "join",\n execute({ contents, selected }) {\n const source = new Set(contents.filter((content, index) => {\n var _a, _b;\n return !!content && ctx.isSelected([index], selected) && ((_b = (_a = this.contentSelectable) == null ? void 0 : _a.call(this, content, contents)) != null ? _b : true);\n }));\n const newContents = ctx.mergeItems(Array.from(source), (item1, item2) => {\n var _a, _b;\n return (_b = (_a = ctx.getContentModel(item1)) == null ? void 0 : _a.join) == null ? void 0 : _b.call(_a, item1, item2, contents);\n });\n ctx.deleteSelectedContents(contents, selected.map((s) => s[0]));\n contents.push(...newContents);\n },\n contentSelectable(content, contents) {\n const model = ctx.getContentModel(content);\n return (model == null ? void 0 : model.join) !== void 0 && ctx.contentIsDeletable(content, contents);\n },\n icon\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/lead.plugin.tsx\nfunction getModel(ctx) {\n const LeadContent = ctx.and(ctx.BaseContent("lead"), ctx.StrokeFields, ctx.ArrowFields, ctx.TextFields, {\n ref: ctx.optional(ctx.ContentRef),\n points: [ctx.Position],\n text: ctx.string,\n toleranceSymbolId: ctx.optional(ctx.number),\n bordered: ctx.optional(ctx.boolean)\n });\n const getRefIds = (content) => [...ctx.getStrokeRefIds(content), ...ctx.toRefId(content.ref)];\n const leadCache = new ctx.WeakmapValuesCache();\n function getLeadGeometriesFromCache(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return leadCache.get(content, refs, () => {\n var _a, _b, _c;\n const ref = ctx.getReference(content.ref, contents, (c) => !ctx.shallowEquals(c, content));\n let p0 = content.points[0];\n let line;\n if (ref && content.points.length > 1) {\n const lines2 = (_c = (_b = (_a = ctx.getContentModel(ref)) == null ? void 0 : _a.getGeometries) == null ? void 0 : _b.call(_a, ref, contents)) == null ? void 0 : _c.lines;\n if (lines2) {\n const p = ctx.getPerpendicularPointToGeometryLines(content.points[1], lines2);\n if (p) {\n p0 = p.point;\n line = p.line;\n }\n }\n }\n let points;\n let arrow;\n if (content.points.length > 1) {\n const arrowPoints = ctx.getArrowPoints(content.points[1], p0, content);\n arrow = arrowPoints.arrowPoints;\n points = [arrowPoints.endPoint, ...content.points.slice(1)];\n } else {\n points = [];\n }\n let extendLine;\n if (line) {\n const { start, end } = ctx.getGeometryLineStartAndEnd(line);\n if (start && (!end || ctx.getTwoPointsDistance(start, p0) < ctx.getTwoPointsDistance(end, p0))) {\n const param0 = ctx.getGeometryLineParamAtPoint(p0, line, true);\n line = ctx.getPartOfGeometryLine(param0, 0, line);\n const marginParam = ctx.getGeometryLineParamByLength(line, -ctx.dimensionStyle.margin);\n if (marginParam !== void 0) {\n extendLine = ctx.getPartOfGeometryLine(marginParam, 1, line);\n }\n } else if (end && (!start || ctx.getTwoPointsDistance(end, p0) < ctx.getTwoPointsDistance(start, p0))) {\n const param0 = ctx.getGeometryLineParamAtPoint(p0, line);\n line = ctx.getPartOfGeometryLine(param0, 1, line);\n const marginParam = ctx.getGeometryLineParamByLength(line, -ctx.dimensionStyle.margin);\n if (marginParam !== void 0) {\n extendLine = ctx.getPartOfGeometryLine(marginParam, 1, line);\n }\n }\n }\n const size = ctx.getTextSize(ctx.getTextStyleFont(content), content.text);\n if (!size) {\n throw "not supported";\n }\n const previous = content.points[content.points.length - 2];\n const last = content.points[content.points.length - 1];\n const right = !previous || previous.x <= last.x;\n const padding = content.fontSize / 4;\n const toleranceSymbol = content.toleranceSymbolId !== void 0 ? toleranceSymbols[content.toleranceSymbolId] : void 0;\n const width = (size.width + content.fontSize * (toleranceSymbol ? 1 : 0) + padding * (toleranceSymbol ? 4 : 2)) * (right ? 1 : -1);\n const height = Math.max(size.height, content.fontSize) / 2 + padding;\n const textPoints = [\n { x: last.x, y: last.y - height },\n { x: last.x + width, y: last.y - height },\n { x: last.x + width, y: last.y + height },\n { x: last.x, y: last.y + height }\n ];\n const lines = Array.from(ctx.iteratePolylineLines(points));\n const renderingLines = ctx.dashedPolylineToLines(points, content.dashArray);\n if (extendLine) {\n lines.push(extendLine);\n renderingLines.push(...ctx.dashedPolylineToLines(ctx.getGeometryLinesPoints([extendLine])));\n }\n return {\n lines,\n first: p0,\n last,\n right,\n padding,\n bounding: ctx.mergeBoundings([ctx.getGeometryLinesBounding(lines), ctx.getPointsBounding(textPoints)]),\n regions: [\n {\n points: textPoints,\n lines: Array.from(ctx.iteratePolygonLines(textPoints))\n },\n ...arrow ? [{\n points: arrow,\n lines: Array.from(ctx.iteratePolygonLines(arrow))\n }] : []\n ],\n renderingLines\n };\n });\n }\n const React = ctx.React;\n return {\n type: "lead",\n ...ctx.strokeModel,\n ...ctx.arrowModel,\n ...ctx.textModel,\n move(content, offset) {\n for (const point of content.points) {\n ctx.movePoint(point, offset);\n }\n },\n rotate(content, center, angle) {\n for (const point of content.points) {\n ctx.rotatePoint(point, center, angle);\n }\n },\n scale(content, center, sx, sy) {\n for (const point of content.points) {\n ctx.scalePoint(point, center, sx, sy);\n }\n content.fontSize *= Math.abs(sx);\n },\n mirror(content, line) {\n for (const point of content.points) {\n ctx.mirrorPoint(point, line);\n }\n },\n render(content, renderCtx) {\n const { options, target, contents, fillOptions } = ctx.getStrokeRenderOptionsFromRenderContext(content, renderCtx);\n const { regions, renderingLines, last, right, padding } = getLeadGeometriesFromCache(content, contents);\n const children = [];\n for (const line of renderingLines) {\n children.push(target.renderPolyline(line, options));\n }\n if (regions && regions.length > 1) {\n children.push(target.renderPolygon(regions[1].points, fillOptions));\n }\n if (content.bordered && regions && regions.length > 0) {\n children.push(target.renderPolygon(regions[0].points, options));\n }\n const textStyleContent = ctx.getTextStyleContent(content, contents);\n const color = renderCtx.transformColor(textStyleContent.color);\n let cacheKey;\n if (renderCtx.isAssistence) {\n cacheKey = ctx.assistentTextCache.get(content.text, textStyleContent.fontSize, textStyleContent.color);\n }\n if (!cacheKey) {\n cacheKey = content;\n }\n let textX = last.x;\n const toleranceSymbol = content.toleranceSymbolId !== void 0 ? toleranceSymbols[content.toleranceSymbolId] : void 0;\n if (toleranceSymbol) {\n children.push(target.renderGroup([\n toleranceSymbol(target, textStyleContent.fontSize, options)\n ], { translate: { x: last.x + textStyleContent.fontSize * (right ? 0 : -1) + padding * (right ? 1 : -1), y: last.y - textStyleContent.fontSize / 2 } }));\n textX += (textStyleContent.fontSize + padding * 2) * (right ? 1 : -1);\n if (content.bordered && regions && regions.length > 0) {\n children.push(target.renderPolyline([{ x: textX, y: regions[0].points[0].y }, { x: textX, y: regions[0].points[2].y }], options));\n }\n }\n textX += padding * (right ? 1 : -1);\n const textOptions = ctx.getTextStyleRenderOptionsFromRenderContext(color, renderCtx);\n children.push(target.renderText(textX, last.y, content.text, color, textStyleContent.fontSize, textStyleContent.fontFamily, { cacheKey, ...textOptions, textBaseline: "middle", textAlign: right ? "left" : "right" }));\n return target.renderGroup(children);\n },\n getEditPoints(content, contents) {\n return ctx.getEditPointsFromCache(content, () => {\n const geometries = getLeadGeometriesFromCache(content, contents);\n return {\n editPoints: content.points.map((p, i) => {\n if (i === 0) {\n p = geometries.first;\n }\n return {\n ...p,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isLeadContent(c)) {\n return;\n }\n c.points[i].x += cursor.x - start.x;\n c.points[i].y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n };\n })\n };\n });\n },\n getSnapPoints(content, contents) {\n return ctx.getSnapPointsFromCache(content, () => {\n const geometries = getLeadGeometriesFromCache(content, contents);\n return content.points.map((p, i) => {\n if (i === 0) {\n p = geometries.first;\n }\n return { ...p, type: "endpoint" };\n });\n });\n },\n getGeometries: getLeadGeometriesFromCache,\n propertyPanel(content, update, contents, { acquirePoint }) {\n var _a;\n return {\n ref: [\n /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.ref !== void 0, readOnly: content.ref === void 0, setValue: (v) => update((c) => {\n if (isLeadContent(c) && !v) {\n c.ref = void 0;\n }\n }) }),\n typeof content.ref === "number" ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.ref, setValue: (v) => update((c) => {\n if (isLeadContent(c)) {\n c.ref = v;\n }\n }) }) : void 0\n ],\n points: /* @__PURE__ */ React.createElement(\n ctx.ArrayEditor,\n {\n inline: true,\n ...ctx.getArrayEditorProps((v) => v.points, { x: 0, y: 0 }, (v) => update((c) => {\n if (isLeadContent(c)) {\n v(c);\n }\n })),\n items: content.points.map((f, i) => /* @__PURE__ */ React.createElement(\n ctx.ObjectEditor,\n {\n inline: true,\n properties: {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isLeadContent(c)) {\n c.points[i].x = p.x;\n c.points[i].y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.x, setValue: (v) => update((c) => {\n if (isLeadContent(c)) {\n c.points[i].x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.y, setValue: (v) => update((c) => {\n if (isLeadContent(c)) {\n c.points[i].y = v;\n }\n }) })\n }\n }\n ))\n }\n ),\n text: /* @__PURE__ */ React.createElement(ctx.StringEditor, { textarea: true, value: content.text, setValue: (v) => update((c) => {\n if (isLeadContent(c)) {\n c.text = v;\n }\n }) }),\n toleranceSymbolId: [\n /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.toleranceSymbolId !== void 0, setValue: (v) => update((c) => {\n if (isLeadContent(c)) {\n c.toleranceSymbolId = v ? 0 : void 0;\n }\n }) }),\n content.toleranceSymbolId !== void 0 ? /* @__PURE__ */ React.createElement(\n ctx.EnumEditor,\n {\n enums: toleranceSymbols.map((_, i) => i),\n enumTitles: toleranceSymbols.map((s) => ctx.reactSvgRenderTarget.renderResult([s(ctx.reactSvgRenderTarget, 13)], 13, 13)),\n value: content.toleranceSymbolId,\n setValue: (v) => update((c) => {\n if (isLeadContent(c)) {\n c.toleranceSymbolId = v;\n }\n })\n }\n ) : void 0\n ],\n bordered: /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: (_a = content.bordered) != null ? _a : false, setValue: (v) => update((c) => {\n if (isLeadContent(c)) {\n c.bordered = v;\n }\n }) }),\n ...ctx.getTextContentPropertyPanel(content, update, contents),\n ...ctx.getArrowContentPropertyPanel(content, update),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents)\n };\n },\n editPanel(content, scale, update, contents, cancel, transformPosition) {\n const p = transformPosition(content.points[content.points.length - 1]);\n const textStyleContent = ctx.getTextStyleContent(content, contents);\n const fontSize = textStyleContent.fontSize * scale;\n return /* @__PURE__ */ React.createElement(\n ctx.StringEditor,\n {\n style: {\n zIndex: 10,\n position: "absolute",\n left: `${p.x - 1}px`,\n top: `${p.y - fontSize - 1}px`,\n fontSize: `${fontSize}px`,\n fontFamily: content.fontFamily,\n color: ctx.getColorString(content.color),\n padding: "0px"\n },\n textarea: true,\n autoFocus: true,\n onCancel: cancel,\n value: content.text,\n setValue: (v) => {\n update((c) => {\n if (isLeadContent(c)) {\n c.text = v;\n }\n });\n }\n }\n );\n },\n isValid: (c, p) => ctx.validate(c, LeadContent, p),\n getRefIds,\n updateRefId(content, update) {\n if (content.ref !== void 0) {\n const newRefId = update(content.ref);\n if (newRefId !== void 0) {\n content.ref = newRefId;\n }\n }\n ctx.updateStrokeRefIds(content, update);\n },\n deleteRefId(content, ids) {\n if (content.ref && ids.includes(content.ref)) {\n content.ref = void 0;\n }\n ctx.deleteStrokeRefIds(content, ids);\n }\n };\n}\nfunction isLeadContent(content) {\n return content.type === "lead";\n}\nvar toleranceSymbols = [\n (target, size, options) => target.renderPolyline([{ x: 0, y: size * 0.5 }, { x: size, y: size * 0.5 }], options),\n (target, size, options) => target.renderPolygon([{ x: 0, y: size }, { x: size * 0.7, y: size }, { x: size, y: 0 }, { x: size * 0.3, y: 0 }], options),\n (target, size, options) => target.renderCircle(size * 0.5, size * 0.5, size * 0.48, options),\n (target, size, options) => target.renderGroup([\n target.renderCircle(size * 0.5, size * 0.5, size * 0.25, options),\n target.renderPolyline([{ x: 0, y: size }, { x: size * 0.4, y: 0 }], options),\n target.renderPolyline([{ x: size, y: 0 }, { x: size * 0.6, y: size }], options)\n ]),\n (target, size, options) => target.renderArc(size * 0.5, size * 0.7, size * 0.48, -180, 0, options),\n (target, size, options) => target.renderArc(size * 0.5, size * 0.7, size * 0.48, -180, 0, { ...options, closed: true }),\n (target, size, options) => target.renderGroup([\n target.renderPolyline([{ x: 0, y: size }, { x: size * 0.4, y: 0 }], options),\n target.renderPolyline([{ x: size, y: 0 }, { x: size * 0.6, y: size }], options)\n ]),\n (target, size, options) => target.renderGroup([\n target.renderPolyline([{ x: 0, y: size }, { x: size, y: size }], options),\n target.renderPolyline([{ x: size * 0.5, y: 0 }, { x: size * 0.5, y: size }], options)\n ]),\n (target, size, options) => target.renderPolyline([{ x: size, y: size }, { x: 0, y: size }, { x: size, y: 0 }], options),\n (target, size, options) => target.renderGroup([\n target.renderCircle(size * 0.5, size * 0.5, size * 0.25, options),\n target.renderPolyline([{ x: size * 0.5, y: 0 }, { x: size * 0.5, y: size }], options),\n target.renderPolyline([{ x: 0, y: size * 0.5 }, { x: size, y: size * 0.5 }], options)\n ]),\n (target, size, options) => target.renderGroup([\n target.renderCircle(size * 0.5, size * 0.5, size * 0.25, options),\n target.renderCircle(size * 0.5, size * 0.5, size * 0.45, options)\n ]),\n (target, size, options) => target.renderGroup([\n target.renderPolyline([{ x: 0, y: size * 0.5 }, { x: size, y: size * 0.5 }], options),\n target.renderPolyline([{ x: size * 0.25, y: size * 0.25 }, { x: size * 0.75, y: size * 0.25 }], options),\n target.renderPolyline([{ x: size * 0.25, y: size * 0.75 }, { x: size * 0.75, y: size * 0.75 }], options)\n ]),\n (target, size, options) => target.renderGroup([\n target.renderPolyline([{ x: size * 0.2, y: size }, { x: size * 0.8, y: 0 }], options),\n target.renderPolyline([{ x: size * 0.35, y: size * 0.4 }, { x: size * 0.8, y: 0 }, { x: size * 0.65, y: size * 0.55 }], options)\n ]),\n (target, size, options) => target.renderGroup([\n target.renderPolyline([{ x: size * 0.4, y: 0 }, { x: 0, y: size }, { x: size * 0.6, y: size }, { x: size, y: 0 }], options),\n target.renderPolyline([{ x: 0, y: size * 0.4 }, { x: size * 0.4, y: 0 }, { x: size * 0.35, y: size * 0.55 }], options),\n target.renderPolyline([{ x: size * 0.6, y: size * 0.4 }, { x: size, y: 0 }, { x: size * 0.95, y: size * 0.55 }], options)\n ])\n];\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "47,4 96,4", strokeWidth: "8", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "71,4 71,54", strokeWidth: "8", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "46,29 5,92", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polygon", { points: "0,100 12,62 30,73", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }));\n return {\n name: "create lead",\n icon,\n useCommand({ onEnd, type, scale, textStyleId, transformPosition, contents }) {\n const [lead, setLead] = React.useState();\n const [editText, setEditText] = React.useState(false);\n let message = "";\n if (type && !editText) {\n message = "press Enter to end";\n }\n const { input, clearText, setCursorPosition, setInputPosition, resetInput } = ctx.useCursorInput(message, type ? (e, text) => {\n if (e.key === "Enter") {\n if (text) {\n clearText();\n } else if (lead) {\n setEditText(true);\n setLead(ctx.produce(lead, (draft) => {\n draft.text = "";\n draft.points.splice(draft.points.length - 1, 1);\n }));\n e.preventDefault();\n }\n }\n } : void 0);\n const reset = () => {\n setLead(void 0);\n resetInput();\n setEditText(false);\n };\n const assistentContents = [];\n let panel;\n if (type) {\n if (lead) {\n assistentContents.push(lead);\n if (editText) {\n const last = lead.points[lead.points.length - 1];\n const p = transformPosition(last);\n const textStyleContent = ctx.getTextStyleContent(lead, contents);\n const fontSize = textStyleContent.fontSize * scale;\n panel = /* @__PURE__ */ React.createElement(\n ctx.StringEditor,\n {\n style: {\n zIndex: 10,\n position: "absolute",\n left: `${p.x - 1}px`,\n top: `${p.y - fontSize - 1}px`,\n fontSize: `${fontSize}px`,\n fontFamily: lead.fontFamily,\n color: ctx.getColorString(lead.color),\n padding: "0px"\n },\n textarea: true,\n autoFocus: true,\n onCancel: reset,\n value: lead.text,\n setValue: (v) => {\n setLead(ctx.produce(lead, (draft) => {\n draft.text = v;\n }));\n }\n }\n );\n }\n }\n }\n return {\n input,\n onStart: (p, target) => {\n if (!type) return;\n if (!lead) {\n setLead({\n type: "lead",\n text: "abc",\n textStyleId,\n color: 0,\n fontSize: 16 / scale,\n fontFamily: "monospace",\n points: [p, p],\n ref: target == null ? void 0 : target.id\n });\n } else if (editText) {\n onEnd({\n updateContents: (contents2) => contents2.push(lead)\n });\n reset();\n } else {\n const last = lead.points[lead.points.length - 1];\n setLead(ctx.produce(lead, (draft) => {\n draft.points.push(last);\n }));\n }\n },\n onMove(p, viewportPosition) {\n if (!type) return;\n if (editText) return;\n setInputPosition(viewportPosition || p);\n setCursorPosition(p);\n if (lead) {\n setLead(ctx.produce(lead, (draft) => {\n draft.points[lead.points.length - 1] = p;\n }));\n }\n },\n assistentContents,\n reset,\n panel\n };\n },\n selectCount: 0\n };\n}\nexport {\n getCommand,\n getModel,\n isLeadContent\n};\n','// dev/cad-editor/plugins/light.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("circle", { cx: "50", cy: "50", r: "30", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "50,20 50,0", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "29,29 15,15", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "20,50 0,50", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "29,71 15,85", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "50,80 50,100", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "71,29 85,15", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "71,71 85,85", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "80,50 100,50", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }));\n return {\n name: "light",\n useCommand({ type, getContentsInRange, contents }) {\n const [startPosition, setStartPosition] = React.useState();\n const [path, setPath] = React.useState();\n const reset = () => {\n setStartPosition(void 0);\n setPath(void 0);\n };\n const assistentContents = [];\n if (path) {\n assistentContents.push({ type: "geometry lines", lines: path, strokeColor: 16711680 });\n }\n return {\n onStart(s) {\n if (!type) return;\n setStartPosition(s);\n },\n reset,\n onMove(p) {\n if (!type) return;\n if (!startPosition) return;\n setPath(ctx.getLightPath(\n { x: startPosition.x, y: startPosition.y, angle: ctx.radianToAngle(ctx.getTwoPointsRadian(p, startPosition)) },\n (line) => {\n var _a, _b;\n const result = [];\n const region = ctx.getGeometryLineBoundingFromCache(line);\n for (const content of getContentsInRange(region)) {\n if (content) {\n const geometries = (_b = (_a = ctx.getContentModel(content)) == null ? void 0 : _a.getGeometries) == null ? void 0 : _b.call(_a, content, contents);\n if (geometries) {\n result.push(geometries);\n }\n }\n }\n return result;\n }\n ));\n },\n assistentContents\n };\n },\n selectCount: 0,\n icon\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/circle-arc.plugin.tsx\nfunction isArcContent(content) {\n return content.type === "arc";\n}\n\n// dev/cad-editor/plugins/line-polyline.plugin.tsx\nfunction getModel(ctx) {\n const LineContent = ctx.and(ctx.BaseContent(ctx.or("line", "polyline")), ctx.StrokeFields, ctx.FillFields, {\n points: ctx.minItems(2, [ctx.Position])\n });\n const getRefIds = (content) => ctx.getStrokeAndFillRefIds(content);\n const geometriesCache = new ctx.WeakmapValuesCache();\n function getPolylineGeometries(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return geometriesCache.get(content, refs, () => {\n const lines = Array.from(ctx.iteratePolylineLines(content.points));\n return {\n lines,\n points: content.points,\n bounding: ctx.getPointsBounding(content.points),\n renderingLines: ctx.dashedPolylineToLines(content.points, content.dashArray),\n regions: ctx.hasFill(content) ? [\n {\n lines,\n points: content.points\n }\n ] : void 0\n };\n });\n }\n const React = ctx.React;\n const lineModel = {\n type: "line",\n ...ctx.strokeModel,\n move(content, offset) {\n for (const point of content.points) {\n ctx.movePoint(point, offset);\n }\n },\n rotate(content, center, angle) {\n for (const point of content.points) {\n ctx.rotatePoint(point, center, angle);\n }\n },\n scale(content, center, sx, sy) {\n for (const point of content.points) {\n ctx.scalePoint(point, center, sx, sy);\n }\n },\n skew(content, center, sx, sy) {\n for (const point of content.points) {\n ctx.skewPoint(point, center, sx, sy);\n }\n },\n mirror(content, line) {\n for (const point of content.points) {\n ctx.mirrorPoint(point, line);\n }\n },\n break(content, intersectionPoints, contents) {\n const { lines } = getPolylineGeometries(content, contents);\n return ctx.breakPolyline(lines, intersectionPoints);\n },\n offset(content, point, distance, contents) {\n const { lines } = getPolylineGeometries(content, contents);\n if (!distance) {\n distance = Math.min(...lines.map((line) => ctx.getPointAndGeometryLineMinimumDistance(point, line)));\n }\n const index = ctx.getLinesOffsetDirection(point, lines);\n const points = ctx.getParallelPolylineByDistance(lines, distance, index);\n return ctx.trimOffsetResult(points, point, false, contents).map((p) => ctx.produce(content, (d) => {\n d.points = p;\n }));\n },\n join(content, target, contents) {\n if (isLineContent(target) || isPolyLineContent(target)) {\n const lines = [\n ...getPolylineGeometries(content, contents).lines.map((n) => ({ type: "line", points: [...n] })),\n ...getPolylineGeometries(target, contents).lines.map((n) => ({ type: "line", points: [...n] }))\n ];\n ctx.mergePolylines(lines);\n if (lines.length === 1) {\n return {\n ...content,\n points: lines[0].points\n };\n }\n }\n if (isArcContent(target)) {\n const newLines = ctx.mergeGeometryLines([{ type: "arc", curve: target }], getPolylineGeometries(content, contents).lines);\n if (newLines) {\n return ctx.geometryLinesToPline(newLines);\n }\n }\n return;\n },\n extend(content, point, contents) {\n const { lines } = getPolylineGeometries(content, contents);\n if (ctx.pointIsOnRay(point, { ...lines[0][0], angle: ctx.radianToAngle(ctx.getTwoPointsRadian(lines[0][0], lines[0][1])) })) {\n content.points[0] = point;\n } else {\n content.points[content.points.length - 1] = point;\n }\n },\n render(content, renderCtx) {\n const { options, target } = ctx.getStrokeRenderOptionsFromRenderContext(content, renderCtx);\n return target.renderPolyline(content.points, options);\n },\n getOperatorRenderPosition(content) {\n return content.points[0];\n },\n getEditPoints(content) {\n return ctx.getEditPointsFromCache(content, () => ({ editPoints: ctx.getPolylineEditPoints(content, isLineContent) }));\n },\n getSnapPoints(content, contents) {\n return ctx.getSnapPointsFromCache(content, () => {\n const { points, lines } = getPolylineGeometries(content, contents);\n return [\n ...points.map((p) => ({ ...p, type: "endpoint" })),\n ...lines.map(([start, end]) => ({\n x: (start.x + end.x) / 2,\n y: (start.y + end.y) / 2,\n type: "midpoint"\n }))\n ];\n });\n },\n getGeometries: getPolylineGeometries,\n propertyPanel(content, update, contents, { acquirePoint }) {\n return {\n points: /* @__PURE__ */ React.createElement(\n ctx.ArrayEditor,\n {\n inline: true,\n ...ctx.getArrayEditorProps((v) => v.points, { x: 0, y: 0 }, (v) => update((c) => {\n if (isLineContent(c)) {\n v(c);\n }\n })),\n items: content.points.map((f, i) => /* @__PURE__ */ React.createElement(\n ctx.ObjectEditor,\n {\n inline: true,\n properties: {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isLineContent(c)) {\n c.points[i].x = p.x;\n c.points[i].y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.x, setValue: (v) => update((c) => {\n if (isLineContent(c)) {\n c.points[i].x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.y, setValue: (v) => update((c) => {\n if (isLineContent(c)) {\n c.points[i].y = v;\n }\n }) })\n }\n }\n ))\n }\n ),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents)\n };\n },\n isValid: (c, p) => ctx.validate(c, LineContent, p),\n getRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n deleteRefId: ctx.deleteStrokeAndFillRefIds,\n reverse: (content) => ({\n ...content,\n points: content.points.slice().reverse()\n })\n };\n return [\n lineModel,\n {\n ...lineModel,\n type: "polyline",\n ...ctx.fillModel,\n explode(content, contents) {\n const { lines } = getPolylineGeometries(content, contents);\n return lines.map((line) => ({ type: "line", points: line }));\n },\n render(content, renderCtx) {\n const { options, target } = ctx.getStrokeFillRenderOptionsFromRenderContext(content, renderCtx);\n return target.renderPolyline(content.points, options);\n },\n getEditPoints(content) {\n return ctx.getEditPointsFromCache(content, () => ({ editPoints: ctx.getPolylineEditPoints(content, isPolyLineContent) }));\n },\n canSelectPart: true,\n propertyPanel(content, update, contents, { acquirePoint }) {\n return {\n points: /* @__PURE__ */ React.createElement(\n ctx.ArrayEditor,\n {\n inline: true,\n ...ctx.getArrayEditorProps((v) => v.points, { x: 0, y: 0 }, (v) => update((c) => {\n if (isPolyLineContent(c)) {\n v(c);\n }\n })),\n items: content.points.map((f, i) => /* @__PURE__ */ React.createElement(\n ctx.ObjectEditor,\n {\n inline: true,\n properties: {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isPolyLineContent(c)) {\n c.points[i].x = p.x;\n c.points[i].y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.x, setValue: (v) => update((c) => {\n if (isPolyLineContent(c)) {\n c.points[i].x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.y, setValue: (v) => update((c) => {\n if (isPolyLineContent(c)) {\n c.points[i].y = v;\n }\n }) })\n }\n }\n ))\n }\n ),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents),\n ...ctx.getFillContentPropertyPanel(content, update, contents)\n };\n }\n }\n ];\n}\nfunction isLineContent(content) {\n return content.type === "line";\n}\nfunction isPolyLineContent(content) {\n return content.type === "polyline";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon1 = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("circle", { cx: "10", cy: "87", r: "12", strokeWidth: "0", vectorEffect: "non-scaling-stroke", fill: "currentColor", stroke: "#000000" }), /* @__PURE__ */ React.createElement("circle", { cx: "87", cy: "9", r: "12", strokeWidth: "0", vectorEffect: "non-scaling-stroke", fill: "currentColor", stroke: "#000000" }), /* @__PURE__ */ React.createElement("polyline", { points: "10,87 87,9", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n const icon2 = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "12,86 38,24 62,64 88,13", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return [\n {\n name: "create line",\n useCommand({ onEnd, scale, type, strokeStyleId, fillStyleId }) {\n const { line, onClick, onMove, input, inputMode, lastPosition, reset } = ctx.useLineClickCreate(\n type === "create line",\n (c) => onEnd({\n updateContents: (contents) => contents.push(...Array.from(ctx.iteratePolylineLines(c)).map((line2) => ({ points: line2, strokeStyleId, fillStyleId, type: "line" })))\n })\n );\n const assistentContents = [];\n if (line && line.length > 1) {\n const start = line[line.length - 2];\n const end = line[line.length - 1];\n const r = ctx.getTwoPointsDistance(start, end);\n const angle = ctx.radianToAngle(ctx.getTwoPointsRadian(end, start));\n assistentContents.push(\n {\n type: "arc",\n x: start.x,\n y: start.y,\n r,\n dashArray: [4 / scale],\n startAngle: angle > 180 || angle < 0 ? angle : 0,\n endAngle: angle > 180 || angle < 0 ? 0 : angle\n },\n {\n type: "line",\n dashArray: [4 / scale],\n points: [start, { x: start.x + r, y: start.y }]\n },\n ...ctx.getAssistentText(\n r.toFixed(2),\n 16 / scale,\n (start.x + end.x) / 2 - 20,\n (start.y + end.y) / 2 + 4,\n inputMode === "length" ? 16711680 : 16764108\n ),\n ...ctx.getAssistentText(\n `${angle.toFixed(1)}\\xB0`,\n 16 / scale,\n end.x + 10,\n end.y - 10,\n inputMode === "angle" ? 16711680 : 16764108\n )\n );\n }\n if (line) {\n for (const lineSegment of ctx.iteratePolylineLines(line)) {\n assistentContents.push({ points: lineSegment, strokeStyleId, fillStyleId, type: "line" });\n }\n }\n return {\n onStart: onClick,\n input,\n onMove,\n assistentContents,\n lastPosition,\n reset\n };\n },\n selectCount: 0,\n hotkey: "L",\n icon: icon1\n },\n {\n name: "create polyline",\n useCommand({ onEnd, scale, type, strokeStyleId, fillStyleId }) {\n const { line, onClick, onMove, input, inputMode, lastPosition, reset, positions } = ctx.useLineClickCreate(\n type === "create polyline",\n (c) => onEnd({\n updateContents: (contents) => contents.push({ points: c, strokeStyleId, fillStyleId, type: "polyline" })\n })\n );\n const assistentContents = [];\n if (line && line.length > 1) {\n const start = line[line.length - 2];\n const end = line[line.length - 1];\n const r = ctx.getTwoPointsDistance(start, end);\n const angle = ctx.radianToAngle(ctx.getTwoPointsRadian(end, start));\n assistentContents.push(\n {\n type: "arc",\n x: start.x,\n y: start.y,\n r,\n dashArray: [4 / scale],\n startAngle: angle > 180 || angle < 0 ? angle : 0,\n endAngle: angle > 180 || angle < 0 ? 0 : angle\n },\n {\n type: "line",\n dashArray: [4 / scale],\n points: [start, { x: start.x + r, y: start.y }]\n },\n ...ctx.getAssistentText(\n r.toFixed(2),\n 16 / scale,\n (start.x + end.x) / 2 - 20,\n (start.y + end.y) / 2 + 4,\n inputMode === "length" ? 16711680 : 16764108\n ),\n ...ctx.getAssistentText(\n `${angle.toFixed(1)}\\xB0`,\n 16 / scale,\n end.x + 10,\n end.y - 10,\n inputMode === "angle" ? 16711680 : 16764108\n )\n );\n }\n if (line) {\n assistentContents.push({ points: line, strokeStyleId, fillStyleId, type: "polyline" });\n }\n return {\n onStart: onClick,\n input,\n onMove,\n assistentContents,\n lastPosition,\n reset,\n subcommand: type === "create polyline" && positions.length > 2 ? /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement(\n "button",\n {\n onClick: () => {\n onEnd({\n updateContents: (contents) => contents.push({ points: positions, type: "polygon" })\n });\n reset();\n },\n style: { position: "relative" }\n },\n "close"\n )) : void 0\n };\n },\n selectCount: 0,\n hotkey: "PL",\n icon: icon2\n }\n ];\n}\nexport {\n getCommand,\n getModel,\n isLineContent,\n isPolyLineContent\n};\n','// dev/cad-editor/plugins/linear-dimension.plugin.tsx\nfunction getModel(ctx) {\n const LinearDimensionContent = ctx.and(ctx.BaseContent("linear dimension"), ctx.StrokeFields, ctx.ArrowFields, ctx.LinearDimension, {\n ref1: ctx.optional(ctx.PositionRef),\n ref2: ctx.optional(ctx.PositionRef)\n });\n const getRefIds = (content) => {\n var _a, _b;\n return [...ctx.getStrokeRefIds(content), ...ctx.toRefIds([(_a = content.ref1) == null ? void 0 : _a.id, (_b = content.ref2) == null ? void 0 : _b.id])];\n };\n const linearDimensionCache = new ctx.WeakmapValuesCache();\n const getLinearDimensionPositions = (content, contents) => {\n var _a, _b;\n const p1 = (_a = ctx.getRefPosition(content.ref1, contents, [content])) != null ? _a : content.p1;\n const p2 = (_b = ctx.getRefPosition(content.ref2, contents, [content])) != null ? _b : content.p2;\n return { p1, p2 };\n };\n function getLinearDimensionGeometriesFromCache(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return linearDimensionCache.get(content, refs, () => {\n var _a, _b;\n const { p1, p2 } = getLinearDimensionPositions(content, contents);\n return ctx.getLinearDimensionGeometries({ ...content, p1, p2 }, {\n arrowAngle: (_a = content.arrowAngle) != null ? _a : ctx.dimensionStyle.arrowAngle,\n arrowSize: (_b = content.arrowSize) != null ? _b : ctx.dimensionStyle.arrowSize,\n margin: ctx.dimensionStyle.margin\n }, (c) => getTextPosition(c, contents));\n });\n }\n const textPositionMap = new ctx.WeakmapCache3();\n function getTextPosition(content, contents) {\n const { p1, p2 } = getLinearDimensionPositions(content, contents);\n return textPositionMap.get(content, p1, p2, () => {\n return ctx.getLinearDimensionTextPosition({ ...content, p1, p2 }, ctx.dimensionStyle.margin, ctx.getTextSizeFromCache);\n });\n }\n const React = ctx.React;\n return {\n type: "linear dimension",\n ...ctx.strokeModel,\n ...ctx.arrowModel,\n move(content, offset) {\n ctx.movePoint(content.p1, offset);\n ctx.movePoint(content.p2, offset);\n ctx.movePoint(content.position, offset);\n },\n scale(content, center, sx, sy) {\n ctx.scalePoint(content.p1, center, sx, sy);\n ctx.scalePoint(content.p2, center, sx, sy);\n ctx.scalePoint(content.position, center, sx, sy);\n },\n render(content, renderCtx) {\n const { options, fillOptions, contents, target, strokeColor } = ctx.getStrokeRenderOptionsFromRenderContext(content, renderCtx);\n const { regions, lines } = getLinearDimensionGeometriesFromCache(content, contents);\n const children = [];\n for (const line of lines) {\n children.push(target.renderPolyline(line, options));\n }\n if (regions) {\n for (let i = 0; i < 2 && i < regions.length; i++) {\n children.push(target.renderPolygon(regions[i].points, fillOptions));\n }\n }\n const { textPosition, text, textRotation } = getTextPosition(content, contents);\n const textOptions = ctx.getTextStyleRenderOptionsFromRenderContext(strokeColor, renderCtx);\n children.push(target.renderGroup(\n [\n target.renderText(textPosition.x, textPosition.y, text, strokeColor, content.fontSize, content.fontFamily, { cacheKey: content, ...textOptions })\n ],\n {\n rotation: textRotation,\n base: textPosition\n }\n ));\n return target.renderGroup(children);\n },\n getEditPoints(content, contents) {\n return ctx.getEditPointsFromCache(content, () => {\n const { p1, p2 } = getLinearDimensionPositions(content, contents);\n return {\n editPoints: [\n {\n x: content.position.x,\n y: content.position.y,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isLinearDimensionContent(c)) {\n return;\n }\n c.position.x += cursor.x - start.x;\n c.position.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n },\n {\n x: p1.x,\n y: p1.y,\n cursor: "move",\n update(c, { cursor, start, scale, target }) {\n if (!isLinearDimensionContent(c)) {\n return;\n }\n c.p1.x = cursor.x;\n c.p1.y = cursor.y;\n c.ref1 = ctx.getSnapTargetRef(target, contents);\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n },\n {\n x: p2.x,\n y: p2.y,\n cursor: "move",\n update(c, { cursor, start, scale, target }) {\n if (!isLinearDimensionContent(c)) {\n return;\n }\n c.p2.x = cursor.x;\n c.p2.y = cursor.y;\n c.ref2 = ctx.getSnapTargetRef(target, contents);\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n }\n ]\n };\n });\n },\n getGeometries: getLinearDimensionGeometriesFromCache,\n propertyPanel(content, update, contents, { acquirePoint }) {\n var _a, _b;\n return {\n p1: /* @__PURE__ */ React.createElement(\n ctx.ObjectEditor,\n {\n inline: true,\n properties: {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p, ref) => update((c) => {\n if (isLinearDimensionContent(c)) {\n c.p1.x = p.x;\n c.p1.y = p.y;\n c.ref1 = ref;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.p1.x, setValue: (v) => update((c) => {\n if (isLinearDimensionContent(c)) {\n c.p1.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.p1.y, setValue: (v) => update((c) => {\n if (isLinearDimensionContent(c)) {\n c.p1.y = v;\n }\n }) })\n }\n }\n ),\n p2: /* @__PURE__ */ React.createElement(\n ctx.ObjectEditor,\n {\n inline: true,\n properties: {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p, ref) => update((c) => {\n if (isLinearDimensionContent(c)) {\n c.p2.x = p.x;\n c.p2.y = p.y;\n c.ref2 = ref;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.p2.x, setValue: (v) => update((c) => {\n if (isLinearDimensionContent(c)) {\n c.p2.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.p2.y, setValue: (v) => update((c) => {\n if (isLinearDimensionContent(c)) {\n c.p2.y = v;\n }\n }) })\n }\n }\n ),\n ref1: [\n /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.ref1 !== void 0, readOnly: content.ref1 === void 0, setValue: (v) => update((c) => {\n if (isLinearDimensionContent(c) && !v) {\n c.ref1 = void 0;\n }\n }) }),\n content.ref1 !== void 0 && typeof content.ref1.id === "number" ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.ref1.id, setValue: (v) => update((c) => {\n if (isLinearDimensionContent(c) && c.ref1) {\n c.ref1.id = v;\n }\n }) }) : void 0,\n content.ref1 !== void 0 ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.ref1.snapIndex, setValue: (v) => update((c) => {\n if (isLinearDimensionContent(c) && c.ref1) {\n c.ref1.snapIndex = v;\n }\n }) }) : void 0,\n ((_a = content.ref1) == null ? void 0 : _a.param) !== void 0 ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { readOnly: true, value: content.ref1.param }) : void 0\n ],\n ref2: [\n /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.ref2 !== void 0, readOnly: content.ref2 === void 0, setValue: (v) => update((c) => {\n if (isLinearDimensionContent(c) && !v) {\n c.ref2 = void 0;\n }\n }) }),\n content.ref2 !== void 0 && typeof content.ref2.id === "number" ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.ref2.id, setValue: (v) => update((c) => {\n if (isLinearDimensionContent(c) && c.ref2) {\n c.ref2.id = v;\n }\n }) }) : void 0,\n content.ref2 !== void 0 ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.ref2.snapIndex, setValue: (v) => update((c) => {\n if (isLinearDimensionContent(c) && c.ref2) {\n c.ref2.snapIndex = v;\n }\n }) }) : void 0,\n ((_b = content.ref2) == null ? void 0 : _b.param) !== void 0 ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { readOnly: true, value: content.ref2.param }) : void 0\n ],\n position: /* @__PURE__ */ React.createElement(\n ctx.ObjectEditor,\n {\n inline: true,\n properties: {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isLinearDimensionContent(c)) {\n c.position.x = p.x;\n c.position.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.position.x, setValue: (v) => update((c) => {\n if (isLinearDimensionContent(c)) {\n c.position.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.position.y, setValue: (v) => update((c) => {\n if (isLinearDimensionContent(c)) {\n c.position.y = v;\n }\n }) })\n }\n }\n ),\n direct: /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.direct === true, setValue: (v) => update((c) => {\n if (isLinearDimensionContent(c)) {\n c.direct = v ? true : void 0;\n }\n }) }),\n text: [\n /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.text !== void 0, setValue: (v) => update((c) => {\n if (isLinearDimensionContent(c)) {\n c.text = v ? "" : void 0;\n }\n }) }),\n content.text !== void 0 ? /* @__PURE__ */ React.createElement(ctx.StringEditor, { value: content.text, setValue: (v) => update((c) => {\n if (isLinearDimensionContent(c)) {\n c.text = v;\n }\n }) }) : void 0\n ],\n fontSize: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.fontSize, setValue: (v) => update((c) => {\n if (isLinearDimensionContent(c)) {\n c.fontSize = v;\n }\n }) }),\n fontFamily: /* @__PURE__ */ React.createElement(ctx.StringEditor, { value: content.fontFamily, setValue: (v) => update((c) => {\n if (isLinearDimensionContent(c)) {\n c.fontFamily = v;\n }\n }) }),\n ...ctx.getArrowContentPropertyPanel(content, update),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents)\n };\n },\n isValid: (c, p) => ctx.validate(c, LinearDimensionContent, p),\n getRefIds,\n updateRefId(content, update) {\n if (content.ref1) {\n const newRefId = update(content.ref1.id);\n if (newRefId !== void 0) {\n content.ref1.id = newRefId;\n }\n }\n if (content.ref2) {\n const newRefId = update(content.ref2.id);\n if (newRefId !== void 0) {\n content.ref2.id = newRefId;\n }\n }\n ctx.updateStrokeRefIds(content, update);\n },\n deleteRefId(content, ids) {\n if (content.ref1 && ids.includes(content.ref1.id)) {\n content.ref1 = void 0;\n }\n if (content.ref2 && ids.includes(content.ref2.id)) {\n content.ref2 = void 0;\n }\n ctx.deleteStrokeRefIds(content, ids);\n }\n };\n}\nfunction isLinearDimensionContent(content) {\n return content.type === "linear dimension";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("circle", { cx: "15", cy: "83", r: "10", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "82", cy: "84", r: "10", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "15,83 14,7", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "82,84 82,6", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "14,25 81,25", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polygon", { points: "66,34 83,24 65,15", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polygon", { points: "29,34 12,25 29,15", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }));\n return {\n name: "create linear dimension",\n selectCount: 0,\n useCommand({ onEnd, type, scale, strokeStyleId }) {\n const [p1, setP1] = React.useState();\n const [p2, setP2] = React.useState();\n const [p1Target, setP1Target] = React.useState();\n const [p2Target, setP2Target] = React.useState();\n const [direct, setDirect] = React.useState(false);\n const [result, setResult] = React.useState();\n const [text, setText] = React.useState();\n let message = "";\n if (type) {\n message = "input text";\n }\n const { input, cursorPosition, setCursorPosition, clearText, setInputPosition, resetInput } = ctx.useCursorInput(message, type ? (e, text2) => {\n if (e.key === "Enter") {\n setText(text2);\n if (result) {\n setResult({ ...result, text: text2 });\n }\n clearText();\n }\n } : void 0);\n const reset = () => {\n setP1(void 0);\n setP2(void 0);\n setP1Target(void 0);\n setP2Target(void 0);\n setResult(void 0);\n resetInput();\n setText(void 0);\n };\n const assistentContents = [];\n if (result) {\n assistentContents.push(result);\n } else if (p1 && cursorPosition) {\n assistentContents.push({ type: "line", points: [p1, cursorPosition], dashArray: [4 / scale] });\n }\n return {\n input,\n reset,\n onStart(p, target) {\n if (!p1) {\n setP1(p);\n setP1Target(target);\n } else if (!p2) {\n setP2(p);\n setP2Target(target);\n } else if (result) {\n onEnd({\n updateContents: (contents) => {\n contents.push(result);\n },\n nextCommand: type\n });\n reset();\n }\n },\n onMove(p, viewportPosition) {\n setInputPosition(viewportPosition || p);\n setCursorPosition(p);\n if (type && p1 && p2) {\n setResult({\n type: "linear dimension",\n position: p,\n p1,\n p2,\n ref1: p1Target,\n ref2: p2Target,\n strokeStyleId,\n direct,\n fontSize: 16,\n fontFamily: "monospace",\n text\n });\n }\n },\n subcommand: type ? /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("button", { onClick: () => {\n if (result) {\n setResult({ ...result, direct: !direct });\n }\n setDirect(!direct);\n }, style: { position: "relative" } }, direct ? "direct" : "axis")) : void 0,\n assistentContents,\n lastPosition: p2 != null ? p2 : p1\n };\n },\n icon\n };\n}\nexport {\n getCommand,\n getModel,\n isLinearDimensionContent\n};\n','// dev/cad-editor/plugins/measure.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "9,14 43,92", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "94,14 93,21 92,28 91,36 88,43 86,49 82,56 78,62 74,68 69,74 63,79 57,83 51,87 44,91", strokeWidth: "5", strokeDasharray: "10", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "9,14 94,14", strokeWidth: "5", strokeDasharray: "10", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "measure",\n useCommand({ transform, type, scale }) {\n const { onStart, mask, startPosition, resetDragMove } = ctx.useDragMove(void 0, {\n transform,\n ignoreLeavingEvent: true\n });\n let message = "";\n if (type) {\n message = startPosition ? "specify end point" : "specify start point";\n }\n const { input, setInputPosition, cursorPosition, setCursorPosition, resetInput } = ctx.useCursorInput(message);\n const reset = () => {\n resetDragMove();\n resetInput();\n };\n const assistentContents = [];\n if (startPosition && cursorPosition) {\n const start = startPosition;\n const end = cursorPosition;\n const r = ctx.getTwoPointsDistance(start, end);\n const angle = ctx.radianToAngle(ctx.getTwoPointsRadian(end, start));\n assistentContents.push(\n {\n type: "arc",\n x: start.x,\n y: start.y,\n r,\n dashArray: [4 / scale],\n startAngle: angle > 180 || angle < 0 ? angle : 0,\n endAngle: angle > 180 || angle < 0 ? 0 : angle\n },\n {\n type: "line",\n dashArray: [4 / scale],\n points: [start, { x: start.x + r, y: start.y }]\n },\n ...ctx.getAssistentText(\n r.toFixed(2),\n 16 / scale,\n (start.x + end.x) / 2 - 20,\n (start.y + end.y) / 2 + 4\n ),\n ...ctx.getAssistentText(\n `${angle.toFixed(1)}\\xB0`,\n 16 / scale,\n end.x + 10,\n end.y - 10\n ),\n {\n type: "line",\n points: [startPosition, cursorPosition]\n }\n );\n }\n return {\n onStart: (s) => onStart(s),\n mask,\n input,\n reset,\n onMove(p, viewportPosition) {\n setCursorPosition(p);\n setInputPosition(viewportPosition != null ? viewportPosition : p);\n },\n assistentContents\n };\n },\n selectCount: 0,\n icon\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/mirror.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polygon", { points: "9,91 38,46 9,10", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "50,0 50,100", strokeWidth: "5", strokeDasharray: "10", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polygon", { points: "90,91 62,46 91,10", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "mirror",\n useCommand({ onEnd, transform, type, scale }) {\n const [changeOriginal, setChangeOriginal] = React.useState(false);\n const { offset, onStart, mask, startPosition, resetDragMove } = ctx.useDragMove(onEnd, {\n transform,\n ignoreLeavingEvent: true\n });\n let message = "";\n if (type) {\n message = startPosition ? "specify second point" : "specify first point";\n }\n const { input, setInputPosition, clearText, setCursorPosition, resetInput } = ctx.useCursorInput(message, type ? (e, text) => {\n if (e.key === "Enter") {\n if (text.toLowerCase() === "y" || text.toLowerCase() === "n") {\n setChangeOriginal(!changeOriginal);\n clearText();\n }\n }\n } : void 0);\n const reset = () => {\n resetDragMove();\n resetInput();\n };\n return {\n onStart: (s) => onStart(s),\n mask: type ? mask : void 0,\n input,\n reset,\n subcommand: type ? /* @__PURE__ */ React.createElement(\n "button",\n {\n onClick: (e) => {\n setChangeOriginal(!changeOriginal);\n e.stopPropagation();\n }\n },\n changeOriginal ? "create new(N)" : "change original(Y)"\n ) : void 0,\n updateSelectedContent(content, contents, selected) {\n if (startPosition && offset && (offset.x !== 0 || offset.y !== 0)) {\n const end = { x: startPosition.x + offset.x, y: startPosition.y + offset.y };\n const line = ctx.twoPointLineToGeneralFormLine(startPosition, end);\n if (!line) return {};\n const angle = ctx.radianToAngle(ctx.getTwoPointsRadian(end, startPosition));\n if (changeOriginal) {\n const [newContent, ...patches] = ctx.produceWithPatches(content, (draft) => {\n var _a, _b;\n (_b = (_a = ctx.getContentModel(content)) == null ? void 0 : _a.mirror) == null ? void 0 : _b.call(_a, draft, line, angle, contents);\n });\n const assistentContents = ctx.updateReferencedContents(content, newContent, contents, selected);\n return {\n patches,\n assistentContents\n };\n }\n return {\n newContents: [\n ctx.produce(content, (d) => {\n var _a, _b;\n (_b = (_a = ctx.getContentModel(d)) == null ? void 0 : _a.mirror) == null ? void 0 : _b.call(_a, d, line, angle, contents);\n })\n ]\n };\n }\n return {};\n },\n onMove(p, viewportPosition) {\n setCursorPosition(p);\n setInputPosition(viewportPosition || p);\n },\n assistentContents: startPosition && offset && (offset.x !== 0 || offset.y !== 0) ? [\n {\n type: "line",\n dashArray: [4 / scale],\n points: [startPosition, { x: startPosition.x + offset.x, y: startPosition.y + offset.y }]\n }\n ] : void 0\n };\n },\n contentSelectable(content) {\n var _a;\n return !content.readonly && ((_a = ctx.getContentModel(content)) == null ? void 0 : _a.mirror) !== void 0;\n },\n hotkey: "MI",\n icon\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/move.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polygon", { points: "9,60 55,60 55,91 9,91", strokeWidth: "5", strokeDasharray: "10", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("rect", { x: "44", y: "10", width: "46", height: "31", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "move",\n useCommand({ onEnd, transform, type, scale }) {\n const { offset, onStart, mask, startPosition, resetDragMove } = ctx.useDragMove(onEnd, {\n transform,\n ignoreLeavingEvent: true\n });\n let message = "";\n if (type) {\n message = startPosition ? "specify end point" : "specify start point";\n }\n const { input, setInputPosition, resetInput } = ctx.useCursorInput(message);\n const reset = () => {\n resetDragMove();\n resetInput();\n };\n return {\n onStart: (s) => onStart(s),\n mask,\n input,\n onMove(_, p) {\n setInputPosition(p);\n },\n reset,\n updateSelectedContent(content, contents, selected) {\n if (startPosition && (offset.x !== 0 || offset.y !== 0)) {\n const [newContent, ...patches] = ctx.produceWithPatches(content, (draft) => {\n var _a, _b;\n (_b = (_a = ctx.getContentModel(content)) == null ? void 0 : _a.move) == null ? void 0 : _b.call(_a, draft, offset);\n });\n const assistentContents = ctx.updateReferencedContents(content, newContent, contents, selected);\n return {\n patches,\n assistentContents\n };\n }\n return {};\n },\n assistentContents: startPosition && (offset.x !== 0 || offset.y !== 0) ? [\n {\n type: "line",\n dashArray: [4 / scale],\n points: [startPosition, { x: startPosition.x + offset.x, y: startPosition.y + offset.y }]\n }\n ] : void 0\n };\n },\n contentSelectable(content) {\n var _a;\n return !content.readonly && ((_a = ctx.getContentModel(content)) == null ? void 0 : _a.move) !== void 0;\n },\n hotkey: "M",\n icon\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/nurbs.plugin.tsx\nfunction getModel(ctx) {\n const NurbsContent = ctx.and(ctx.BaseContent("nurbs"), ctx.StrokeFields, ctx.FillFields, ctx.SegmentCountFields, ctx.Nurbs);\n const getRefIds = (content) => ctx.getStrokeAndFillRefIds(content);\n const geometriesCache = new ctx.WeakmapValuesCache();\n function getNurbsGeometries(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return geometriesCache.get(content, refs, () => {\n var _a;\n let points;\n const nurbsSegmentCount = (_a = content.segmentCount) != null ? _a : ctx.defaultSegmentCount;\n let lines;\n if (content.points.length > 2) {\n if (!content.weights && !content.knots && (content.degree === 2 || content.points.length === 3)) {\n lines = ctx.getQuadraticSplineCurves(content.points).map((c) => ({ type: "quadratic curve", curve: c }));\n points = ctx.getGeometryLinesPoints(lines, nurbsSegmentCount);\n } else if (!content.weights && !content.knots && content.degree === 3) {\n lines = ctx.getBezierSplineCurves(content.points, false).map((c) => ({ type: "bezier curve", curve: c }));\n points = ctx.getGeometryLinesPoints(lines, nurbsSegmentCount);\n } else if (!content.weights && !content.knots && content.degree === 1) {\n points = content.points;\n lines = Array.from(ctx.iteratePolylineLines(points));\n } else {\n lines = [{\n type: "nurbs curve",\n curve: {\n degree: content.degree,\n points: content.points,\n knots: content.knots || ctx.getDefaultNurbsKnots(content.points.length, content.degree),\n weights: content.weights\n }\n }];\n points = ctx.getGeometryLinesPoints(lines, nurbsSegmentCount);\n }\n } else {\n points = content.points;\n lines = Array.from(ctx.iteratePolylineLines(points));\n }\n return {\n lines,\n points,\n bounding: ctx.getGeometryLinesBounding(lines),\n renderingLines: ctx.dashedPolylineToLines(points, content.dashArray),\n regions: ctx.hasFill(content) ? [\n {\n lines,\n points: content.points\n }\n ] : void 0\n };\n });\n }\n const React = ctx.React;\n const nurbsModel = {\n type: "nurbs",\n ...ctx.strokeModel,\n ...ctx.fillModel,\n ...ctx.segmentCountModel,\n move(content, offset) {\n for (const point of content.points) {\n ctx.movePoint(point, offset);\n }\n },\n rotate(content, center, angle) {\n for (const point of content.points) {\n ctx.rotatePoint(point, center, angle);\n }\n },\n mirror(content, line) {\n for (const point of content.points) {\n ctx.mirrorPoint(point, line);\n }\n },\n break(content, intersectionPoints, contents) {\n const lines = getNurbsGeometries(content, contents).lines;\n const result = ctx.breakGeometryLines(lines, intersectionPoints);\n return result.map((r) => r.map((t) => ctx.geometryLineToContent(t))).flat();\n },\n offset(content, point, distance, contents) {\n const lines = getNurbsGeometries(content, contents).lines;\n return ctx.trimGeometryLinesOffsetResult(ctx.getParallelGeometryLinesByDistancePoint(point, lines, distance), point).map((r) => r.map((n) => ctx.geometryLineToContent(n))).flat();\n },\n render(content, renderCtx) {\n const { points } = getNurbsGeometries(content, renderCtx.contents);\n const { options, target } = ctx.getStrokeFillRenderOptionsFromRenderContext(content, renderCtx);\n return target.renderPolyline(points, options);\n },\n renderIfSelected(content, { color, target, strokeWidth }) {\n return target.renderPolyline(content.points, { strokeColor: color, dashArray: [4], strokeWidth });\n },\n getOperatorRenderPosition(content) {\n return content.points[0];\n },\n getEditPoints(content) {\n return ctx.getEditPointsFromCache(content, () => ({ editPoints: ctx.getPolylineEditPoints(content, isNurbsContent, false, true) }));\n },\n getSnapPoints(content) {\n return ctx.getSnapPointsFromCache(content, () => content.points.map((p) => ({ ...p, type: "endpoint" })));\n },\n getGeometries: getNurbsGeometries,\n propertyPanel(content, update, contents, { acquirePoint }) {\n return {\n points: /* @__PURE__ */ React.createElement(\n ctx.ArrayEditor,\n {\n inline: true,\n ...ctx.getArrayEditorProps((v) => v.points, { x: 0, y: 0 }, (v) => update((c) => {\n if (isNurbsContent(c)) {\n v(c);\n if (c.points.length !== content.points.length) {\n c.knots = void 0;\n c.weights = void 0;\n }\n }\n })),\n items: content.points.map((f, i) => /* @__PURE__ */ React.createElement(\n ctx.ObjectEditor,\n {\n inline: true,\n properties: {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isNurbsContent(c)) {\n c.points[i].x = p.x;\n c.points[i].y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.x, setValue: (v) => update((c) => {\n if (isNurbsContent(c)) {\n c.points[i].x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.y, setValue: (v) => update((c) => {\n if (isNurbsContent(c)) {\n c.points[i].y = v;\n }\n }) })\n }\n }\n ))\n }\n ),\n degree: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.degree, setValue: (v) => update((c) => {\n if (isNurbsContent(c) && Number.isInteger(v) && v >= 1) {\n c.degree = v;\n c.knots = void 0;\n }\n }) }),\n knots: [\n /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.knots !== void 0, setValue: (v) => update((c) => {\n if (isNurbsContent(c)) {\n c.knots = v ? ctx.getDefaultNurbsKnots(content.points.length, content.degree) : void 0;\n }\n }) }),\n content.knots !== void 0 ? /* @__PURE__ */ React.createElement(\n ctx.ArrayEditor,\n {\n inline: true,\n ...ctx.getArrayEditorProps((v) => v.knots || [], () => content.knots && content.knots.length > 0 ? content.knots[content.knots.length - 1] + 1 : 0, (v) => update((c) => {\n if (isNurbsContent(c)) {\n v(c);\n }\n })),\n items: content.knots.map((f, i) => /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f, setValue: (v) => update((c) => {\n if (isNurbsContent(c) && c.knots) {\n c.knots[i] = v;\n }\n }) }))\n }\n ) : void 0\n ],\n weights: [\n /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.weights !== void 0, setValue: (v) => update((c) => {\n if (isNurbsContent(c)) {\n c.weights = v ? ctx.getDefaultWeights(content.points.length) : void 0;\n }\n }) }),\n content.weights !== void 0 ? /* @__PURE__ */ React.createElement(\n ctx.ArrayEditor,\n {\n inline: true,\n ...ctx.getArrayEditorProps((v) => v.weights || [], 1, (v) => update((c) => {\n if (isNurbsContent(c)) {\n v(c);\n }\n })),\n items: content.weights.map((f, i) => /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f, setValue: (v) => update((c) => {\n if (isNurbsContent(c) && c.weights) {\n c.weights[i] = v;\n }\n }) }))\n }\n ) : void 0\n ],\n ...ctx.getStrokeContentPropertyPanel(content, update, contents),\n ...ctx.getFillContentPropertyPanel(content, update, contents),\n ...ctx.getSegmentCountContentPropertyPanel(content, update)\n };\n },\n isValid: (c, p) => ctx.validate(c, NurbsContent, p),\n getRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n deleteRefId: ctx.deleteStrokeAndFillRefIds,\n reverse: (content) => ctx.reverseNurbs(content)\n };\n return [\n nurbsModel\n ];\n}\nfunction isNurbsContent(content) {\n return content.type === "nurbs";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon1 = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("circle", { cx: "13", cy: "22", r: "5", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "28", cy: "79", r: "5", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "63", cy: "22", r: "5", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "85", cy: "80", r: "5", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "13,22 14,24 14,26 15,29 15,31 16,33 17,34 17,36 18,38 18,40 19,41 20,43 20,44 21,46 22,47 22,49 23,50 23,51 24,52 25,53 25,54 26,55 27,56 27,56 28,57 29,58 29,58 30,59 31,59 31,59 32,60 33,60 33,60 34,60 35,60 35,60 36,60 37,60 37,59 38,59 39,58 39,58 40,57 41,57 41,56 42,55 43,55 43,54 44,53 45,52 46,51 46,49 47,48 48,47 48,46 49,46 50,45 50,44 51,44 52,43 53,43 53,42 54,42 55,42 56,41 56,41 57,41 58,41 59,41 59,41 60,42 61,42 62,42 63,43 63,43 64,44 65,44 66,45 67,46 67,47 68,47 69,48 70,49 71,51 71,52 72,53 73,54 74,56 75,57 76,59 76,60 77,62 78,64 79,65 80,67 81,69 82,71 82,73 83,75 84,78 85,80", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n const nurbsCommand = {\n name: "create nurbs",\n type: [\n { name: "nurbs", icon: icon1 }\n ],\n useCommand({ onEnd, type, scale, strokeStyleId, fillStyleId }) {\n const { line, onClick, onMove, input, lastPosition, reset } = ctx.useLineClickCreate(\n type === "nurbs",\n (c) => onEnd({\n updateContents: (contents) => contents.push({ points: c, type: "nurbs", degree: 2, strokeStyleId, fillStyleId })\n })\n );\n const assistentContents = [];\n if (line) {\n assistentContents.push(\n { points: line, type: "nurbs", strokeStyleId, fillStyleId, degree: 2 },\n { points: line, type: "polyline", dashArray: [4 / scale] }\n );\n }\n return {\n onStart: onClick,\n input,\n onMove,\n assistentContents,\n lastPosition,\n reset\n };\n },\n selectCount: 0\n };\n return [\n nurbsCommand\n ];\n}\nexport {\n getCommand,\n getModel,\n isNurbsContent\n};\n','// dev/cad-editor/plugins/offset.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("rect", { x: "8", y: "9", width: "82", height: "82", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("rect", { x: "22", y: "23", width: "55", height: "55", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n function contentSelectable(content) {\n var _a;\n return ((_a = ctx.getContentModel(content)) == null ? void 0 : _a.offset) !== void 0;\n }\n function getOffsetResult(content, p, offset, contents, lineJoin) {\n const model = ctx.getContentModel(content);\n if (model == null ? void 0 : model.offset) {\n const newContent = model.offset(content, p, offset, contents, lineJoin);\n if (Array.isArray(newContent)) {\n return newContent.filter((c) => model.isValid(c) === true);\n }\n if (newContent && model.isValid(newContent) === true) {\n return [newContent];\n }\n }\n return [];\n }\n return {\n name: "offset",\n useCommand({ onEnd, type, contents }) {\n let message = "";\n if (type) {\n message = "input offset or click to end";\n }\n const [lineJoin, setLineJoin] = React.useState(ctx.defaultLineJoin);\n const [offset, setOffset] = React.useState(0);\n const { input, clearText, setInputPosition, cursorPosition, setCursorPosition, resetInput } = ctx.useCursorInput(message, type ? (e, text) => {\n if (e.key === "Enter") {\n const offset2 = +text;\n if (!isNaN(offset2) && offset2 >= 0) {\n setOffset(offset2);\n clearText();\n } else if (text.toUpperCase() === "T") {\n setOffset(0);\n clearText();\n }\n }\n } : void 0);\n return {\n onStart(p) {\n resetInput();\n onEnd({\n nextCommand: "offset",\n updateContents: (contents2, selected) => {\n const target = contents2.filter((c, i) => c && ctx.isSelected([i], selected) && contentSelectable(c));\n for (const content of target) {\n if (content) {\n contents2.push(...getOffsetResult(content, p, offset, contents2, lineJoin));\n }\n }\n setCursorPosition(void 0);\n }\n });\n },\n input,\n onMove(p, viewportPosition) {\n setInputPosition(viewportPosition || p);\n if (!type) {\n return;\n }\n setCursorPosition(p);\n },\n updateSelectedContent(content) {\n if (cursorPosition) {\n const newContents = getOffsetResult(content, cursorPosition, offset, contents, lineJoin);\n if (newContents.length > 0) {\n return {\n newContents\n };\n }\n }\n return {};\n },\n subcommand: type === "offset" ? /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement(ctx.EnumEditor, { value: lineJoin, enums: ["miter", "bevel", "round"], setValue: setLineJoin })) : void 0,\n reset: resetInput\n };\n },\n contentSelectable,\n selectCount: 1,\n icon,\n pointSnapDisabled: true\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/parabola.plugin.tsx\nfunction getModel(ctx) {\n const ParabolaContent = ctx.and(ctx.BaseContent("parabola"), ctx.StrokeFields, ctx.ParabolaSegment, ctx.SegmentCountFields);\n const geometriesCache = new ctx.WeakmapValuesCache();\n function getParabolaGeometries(content, contents) {\n const refs = new Set(ctx.iterateRefContents(ctx.getStrokeRefIds(content), contents, [content]));\n return geometriesCache.get(content, refs, () => {\n var _a;\n const segmentCount = (_a = content.segmentCount) != null ? _a : ctx.defaultSegmentCount;\n const curve = ctx.parabolaSegmentToQuadraticCurve(content);\n const points = ctx.getQuadraticCurvePoints(curve.from, curve.cp, curve.to, segmentCount);\n const lines = [\n { type: "quadratic curve", curve }\n ];\n return {\n lines,\n start: curve.from,\n end: curve.to,\n startAngle: ctx.radianToAngle(ctx.getParabolaTangentRadianAtParam(content, content.t1)),\n endAngle: ctx.radianToAngle(ctx.getParabolaTangentRadianAtParam(content, content.t2)),\n focus: ctx.getPointByLengthAndRadian(content, ctx.getParabolaFocusParameter(content.p) / 2, ctx.angleToRadian(content.angle)),\n points,\n bounding: ctx.getGeometryLinesBounding(lines),\n renderingLines: ctx.dashedPolylineToLines(points, content.dashArray)\n };\n });\n }\n const React = ctx.React;\n return {\n type: "parabola",\n ...ctx.strokeModel,\n ...ctx.segmentCountModel,\n move(content, offset) {\n ctx.movePoint(content, offset);\n },\n rotate(content, center, angle) {\n ctx.rotateParabola(content, center, angle);\n },\n scale(content, center, sx, sy) {\n const curve = ctx.parabolaSegmentToQuadraticCurve(content);\n const line = { type: "quadratic curve", curve };\n ctx.scaleGeometryLine(line, center, sx, sy);\n return ctx.geometryLineToContent(line);\n },\n skew(content, center, sx, sy) {\n const curve = ctx.parabolaSegmentToQuadraticCurve(content);\n const line = { type: "quadratic curve", curve };\n ctx.skewGeometryLine(line, center, sx, sy);\n return ctx.geometryLineToContent(line);\n },\n mirror(content, line, angle) {\n ctx.mirrorParabola(content, line, angle);\n },\n break(content, intersectionPoints, contents) {\n const lines = getParabolaGeometries(content, contents).lines;\n return ctx.breakGeometryLinesToPathCommands(lines, intersectionPoints);\n },\n offset(content, point, distance, contents) {\n if (!distance) {\n distance = Math.min(...getParabolaGeometries(content, contents).lines.map((line) => ctx.getPointAndGeometryLineMinimumDistance(point, line)));\n }\n return ctx.getParallelParabolaSegmentsByDistance(content, distance)[ctx.pointSideToIndex(ctx.getPointSideOfParabolaSegment(point, content))];\n },\n join(content, target, contents) {\n var _a, _b, _c;\n const { lines } = getParabolaGeometries(content, contents);\n const line2 = (_c = (_b = (_a = ctx.getContentModel(target)) == null ? void 0 : _a.getGeometries) == null ? void 0 : _b.call(_a, target, contents)) == null ? void 0 : _c.lines;\n if (!line2) return;\n const newLines = ctx.mergeGeometryLines(lines, line2);\n if (!newLines) return;\n return {\n ...content,\n type: "path",\n commands: ctx.geometryLineToPathCommands(newLines)\n };\n },\n extend(content, point) {\n const t = ctx.getParabolaParamAtPoint(content, point);\n if (ctx.isBefore(t, content.t1, content.t2)) {\n content.t1 = t;\n } else {\n content.t2 = t;\n }\n },\n render(content, renderCtx) {\n const { options, target } = ctx.getStrokeRenderOptionsFromRenderContext(content, renderCtx);\n const { points } = getParabolaGeometries(content, renderCtx.contents);\n return target.renderPolyline(points, options);\n },\n renderIfSelected(content, { color, target, strokeWidth }) {\n return target.renderRay(content.x, content.y, content.angle, { strokeColor: color, dashArray: [4], strokeWidth });\n },\n getEditPoints(content, contents) {\n return ctx.getEditPointsFromCache(content, () => {\n const { start, end, startAngle, endAngle, focus } = getParabolaGeometries(content, contents);\n return {\n editPoints: [\n {\n x: content.x,\n y: content.y,\n cursor: "move",\n type: "move",\n update(c, { cursor, start: start2, scale }) {\n if (!isParabolaContent(c)) {\n return;\n }\n c.x += cursor.x - start2.x;\n c.y += cursor.y - start2.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [content, cursor] }] };\n }\n },\n {\n x: start.x,\n y: start.y,\n cursor: ctx.getResizeCursor(startAngle, "left"),\n update(c, { cursor, start: start2, scale }) {\n if (!isParabolaContent(c)) {\n return;\n }\n c.t1 = ctx.minimumBy(ctx.getPerpendicularParamsToParabola(cursor, content), (t) => ctx.getTwoPointsDistanceSquare(cursor, ctx.getParabolaPointAtParam(content, t)));\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start2, cursor] }] };\n }\n },\n {\n x: end.x,\n y: end.y,\n cursor: ctx.getResizeCursor(endAngle, "right"),\n update(c, { cursor, start: start2, scale }) {\n if (!isParabolaContent(c)) {\n return;\n }\n c.t2 = ctx.minimumBy(ctx.getPerpendicularParamsToParabola(cursor, content), (t) => ctx.getTwoPointsDistanceSquare(cursor, ctx.getParabolaPointAtParam(content, t)));\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start2, cursor] }] };\n }\n },\n {\n x: focus.x,\n y: focus.y,\n cursor: "move",\n update(c, { cursor, scale }) {\n if (!isParabolaContent(c)) {\n return;\n }\n c.p = ctx.getParabolaFocusParameter(ctx.getTwoPointsDistance(content, cursor) * 2);\n c.angle = ctx.radianToAngle(ctx.getTwoPointsRadian(cursor, content));\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [content, cursor] }] };\n }\n }\n ]\n };\n });\n },\n getSnapPoints(content, contents) {\n return ctx.getSnapPointsFromCache(content, () => {\n const { start, end, focus } = getParabolaGeometries(content, contents);\n return [\n { ...start, type: "endpoint" },\n { ...end, type: "endpoint" },\n { ...content, type: "center" },\n { ...focus, type: "center" }\n ];\n });\n },\n getGeometries: getParabolaGeometries,\n propertyPanel(content, update, contents, { acquirePoint }) {\n return {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isParabolaContent(c)) {\n c.x = p.x;\n c.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.x, setValue: (v) => update((c) => {\n if (isParabolaContent(c)) {\n c.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.y, setValue: (v) => update((c) => {\n if (isParabolaContent(c)) {\n c.y = v;\n }\n }) }),\n p: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.p, setValue: (v) => update((c) => {\n if (isParabolaContent(c) && v > 0) {\n c.p = v;\n }\n }) }),\n t1: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.t1, setValue: (v) => update((c) => {\n if (isParabolaContent(c)) {\n c.t1 = v;\n }\n }) }),\n t2: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.t2, setValue: (v) => update((c) => {\n if (isParabolaContent(c)) {\n c.t2 = v;\n }\n }) }),\n angle: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.angle, setValue: (v) => update((c) => {\n if (isParabolaContent(c)) {\n c.angle = v;\n }\n }) }),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents),\n ...ctx.getSegmentCountContentPropertyPanel(content, update)\n };\n },\n isValid: (c, p) => ctx.validate(c, ParabolaContent, p),\n getRefIds: ctx.getStrokeRefIds,\n updateRefId: ctx.updateStrokeRefIds,\n deleteRefId: ctx.deleteStrokeRefIds,\n reverse: ctx.reverseParabola\n };\n}\nfunction isParabolaContent(content) {\n return content.type === "parabola";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "99,3 98,7 97,10 96,14 95,18 94,21 93,25 92,28 91,31 90,34 89,38 88,41 87,44 86,46 85,49 84,52 83,55 82,57 81,60 80,62 79,64 78,67 77,69 76,71 75,73 75,75 74,77 73,79 72,80 71,82 70,84 69,85 68,87 67,88 66,89 65,90 64,91 63,93 62,93 61,94 60,95 59,96 58,97 57,97 56,98 55,98 54,98 53,99 52,99 51,99 50,99 49,99 48,99 47,99 46,98 45,98 44,98 43,97 42,97 41,96 40,95 39,94 38,93 37,93 36,91 35,90 34,89 33,88 32,87 31,85 30,84 29,82 28,80 27,79 26,77 26,75 25,73 24,71 23,69 22,67 21,64 20,62 19,60 18,57 17,55 16,52 15,49 14,46 13,44 12,41 11,38 10,34 9,31 8,28 7,25 6,21 5,18 4,14 3,10 2,7 1,3", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }));\n return {\n name: "create parabola",\n icon,\n useCommand({ onEnd, type, strokeStyleId }) {\n const [content, setContent] = React.useState();\n const [status, setStatus] = React.useState("position");\n const reset = () => {\n setContent(void 0);\n setStatus("position");\n };\n const assistentContents = [];\n if (content) {\n assistentContents.push(content);\n }\n return {\n onStart() {\n if (type !== "create parabola") return;\n if (status === "position") {\n setStatus("angle");\n } else if (status === "angle") {\n setStatus("t1");\n } else if (status === "t1") {\n setStatus("t2");\n } else if (status === "t2") {\n onEnd({\n updateContents: (contents) => contents.push(content)\n });\n reset();\n }\n },\n onMove(p) {\n if (type !== "create parabola") return;\n if (!content) {\n setContent({\n type: "parabola",\n x: p.x,\n y: p.y,\n p: 0.01,\n t1: -100,\n t2: 100,\n angle: -90,\n strokeStyleId\n });\n } else if (status === "position") {\n setContent({\n ...content,\n x: p.x,\n y: p.y\n });\n } else if (status === "angle") {\n setContent({\n ...content,\n angle: ctx.radianToAngle(ctx.getTwoPointsRadian(p, content))\n });\n } else if (status === "t1") {\n const x = ctx.getPerpendicularParamToLine2D(p, content, ctx.getParabolaXAxisRadian(content));\n const y = ctx.getPerpendicularParamToLine2D(p, content, ctx.angleToRadian(content.angle));\n setContent({\n ...content,\n t1: x,\n p: Math.abs(y) / x / x / 2\n });\n } else if (status === "t2") {\n setContent({\n ...content,\n t2: ctx.minimumBy(ctx.getPerpendicularParamsToParabola(p, content), (t) => ctx.getTwoPointsDistanceSquare(p, ctx.getParabolaPointAtParam(content, t)))\n });\n }\n },\n assistentContents,\n reset\n };\n },\n selectCount: 0\n };\n}\nexport {\n getCommand,\n getModel,\n isParabolaContent\n};\n','// dev/cad-editor/plugins/coordinate-axis.plugin.tsx\nfunction isCoordinateAxisContent(content) {\n return content.type === "coordinate axis";\n}\n\n// dev/cad-editor/plugins/parametric-equation.plugin.tsx\nfunction getModel(ctx) {\n const ParametricEquationContent = ctx.and(ctx.BaseContent("parametric equation"), ctx.StrokeFields, ctx.SegmentCountFields, {\n axisId: ctx.ContentRef,\n xExpression: ctx.string,\n yExpression: ctx.string,\n min: ctx.number,\n max: ctx.number\n });\n const getRefIds = (content) => [...ctx.getStrokeRefIds(content), ...ctx.toRefId(content.axisId, true)];\n const equationCache = new ctx.WeakmapValuesCache();\n function getGeometriesFromCache(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return equationCache.get(content, refs, () => {\n var _a;\n const axis = ctx.getReference(content.axisId, contents, isCoordinateAxisContent);\n if (axis) {\n if (content.xExpression && content.yExpression) {\n try {\n const xExpression = ctx.parseExpression(ctx.tokenizeExpression(content.xExpression));\n const yExpression = ctx.parseExpression(ctx.tokenizeExpression(content.yExpression));\n const points = [];\n const segmentCount = (_a = content.segmentCount) != null ? _a : ctx.defaultSegmentCount;\n const step = (content.max - content.min) / segmentCount;\n for (let t = content.min; t <= content.max; t += step) {\n const x = ctx.evaluateExpression(xExpression, { Math, t });\n const y = ctx.evaluateExpression(yExpression, { Math, t });\n if (typeof x === "number" && !isNaN(x) && typeof y === "number" && !isNaN(y)) {\n points.push({ x: x + axis.x, y: y * (axis.flipY ? -1 : 1) + axis.y });\n }\n }\n const lines = Array.from(ctx.iteratePolylineLines(points));\n return {\n points,\n lines,\n bounding: ctx.getPointsBounding(points),\n renderingLines: ctx.dashedPolylineToLines(points, content.dashArray)\n };\n } catch (e) {\n console.info(e);\n }\n }\n return { lines: [], points: [], renderingLines: [] };\n }\n return { lines: [], points: [], renderingLines: [] };\n });\n }\n const React = ctx.React;\n return {\n type: "parametric equation",\n ...ctx.strokeModel,\n ...ctx.segmentCountModel,\n render(content, renderCtx) {\n const { options, contents, target } = ctx.getStrokeRenderOptionsFromRenderContext(content, renderCtx);\n const { points } = getGeometriesFromCache(content, contents);\n return target.renderPolyline(points, options);\n },\n getGeometries: getGeometriesFromCache,\n propertyPanel(content, update, contents) {\n return {\n xExpression: /* @__PURE__ */ React.createElement(ctx.ExpressionEditor, { suggestionSources: ctx.math, validate: ctx.validateExpression, value: content.xExpression, setValue: (v) => update((c) => {\n if (isParametricEquationContent(c)) {\n c.xExpression = v;\n }\n }) }),\n yExpression: /* @__PURE__ */ React.createElement(ctx.ExpressionEditor, { suggestionSources: ctx.math, validate: ctx.validateExpression, value: content.yExpression, setValue: (v) => update((c) => {\n if (isParametricEquationContent(c)) {\n c.yExpression = v;\n }\n }) }),\n min: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.min, setValue: (v) => update((c) => {\n if (isParametricEquationContent(c)) {\n c.min = v;\n }\n }) }),\n max: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.max, setValue: (v) => update((c) => {\n if (isParametricEquationContent(c)) {\n c.max = v;\n }\n }) }),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents),\n ...ctx.getSegmentCountContentPropertyPanel(content, update)\n };\n },\n isValid: (c, p) => ctx.validate(c, ParametricEquationContent, p),\n getRefIds,\n updateRefId(content, update) {\n const newAxisId = update(content.axisId);\n if (newAxisId !== void 0) {\n content.axisId = newAxisId;\n }\n ctx.updateStrokeRefIds(content, update);\n },\n deleteRefId: ctx.deleteStrokeRefIds\n };\n}\nfunction isParametricEquationContent(content) {\n return content.type === "parametric equation";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "7,93 88,93", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "7,12 7,93", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "97,93 68,101 68,85", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "7,3 15,32 1,32", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "76,49 76,47 76,46 76,44 76,43 75,41 75,40 74,38 73,37 73,35 72,34 71,33 70,32 69,31 67,29 66,29 65,28 64,27 62,26 61,26 59,25 58,25 56,24 55,24 53,24 51,24 50,24 48,24 47,24 45,25 44,25 42,26 41,26 39,27 38,28 37,29 36,29 34,31 33,32 32,33 31,34 30,35 30,37 29,38 28,40 28,41 27,43 27,44 27,46 27,47 26,49 27,50 27,52 27,53 27,55 28,56 28,58 29,59 30,61 30,62 31,63 32,65 33,66 34,67 36,68 37,69 38,70 39,71 41,71 42,72 44,73 45,73 47,73 48,74 50,74 51,74 53,74 55,74 56,73 58,73 59,73 61,72 62,71 64,71 65,70 66,69 67,68 69,67 70,66 71,65 72,63 73,62 73,61 74,59 75,58 75,56 76,55 76,53 76,52 76,50 76,49", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }));\n return {\n name: "create parametric equation",\n icon,\n execute({ contents, selected }) {\n contents.push({\n type: "parametric equation",\n axisId: selected[0][0],\n min: 0,\n max: Math.PI * 2,\n xExpression: "25 + 25 * Math.cos(t)",\n yExpression: "25 + 25 * Math.sin(t)"\n });\n },\n contentSelectable: isCoordinateAxisContent,\n selectCount: 1\n };\n}\nexport {\n getCommand,\n getModel,\n isParametricEquationContent\n};\n','// dev/cad-editor/plugins/path-array.plugin.tsx\nfunction getModel(ctx) {\n const PathArrayContent = ctx.and(ctx.BaseContent("path array"), ctx.ContainerFields, {\n path: ctx.PartRef,\n length: ctx.number,\n aligned: ctx.optional(ctx.boolean)\n });\n const getRefIds = (content) => [...ctx.toRefId(content.path.id, true), ...ctx.toRefIds(content.contents)];\n const allContentsCache = new ctx.WeakmapCache2();\n const getAllContentsFromCache = (content, contents) => {\n const path = ctx.getRefPart(content.path, contents, (c) => !ctx.shallowEquals(c, content));\n if (!path) return [];\n return allContentsCache.get(content, path, () => {\n var _a, _b, _c, _d;\n const lines = (_b = (_a = ctx.getContentModel(path)) == null ? void 0 : _a.getGeometries) == null ? void 0 : _b.call(_a, path, contents).lines;\n if (!lines) return [];\n const boundings = [];\n for (const child of content.contents) {\n if (child) {\n const geometries = (_d = (_c = ctx.getContentModel(child)) == null ? void 0 : _c.getGeometries) == null ? void 0 : _d.call(_c, child, contents);\n if (geometries == null ? void 0 : geometries.bounding) {\n boundings.push(geometries.bounding);\n }\n }\n }\n const bounding = ctx.mergeBoundingsUnsafe(boundings);\n const center = ctx.getTwoPointCenter(bounding.start, bounding.end);\n const result = [];\n const lengths = lines.map((line) => ctx.getGeometryLineLength(line) || 0);\n const totalLength = lengths.reduce((p, c) => p + c, 0);\n for (let length = 0; length <= totalLength; length += content.length) {\n const r = ctx.getGeometryLinesPointAndTangentRadianByLength(lines, length, lengths);\n if (r) {\n result.push(...content.contents.map((child) => {\n var _a2, _b2;\n if (!child) return;\n const model = ctx.getContentModel(child);\n if (!model) return;\n const bounding2 = (_b2 = (_a2 = model.getGeometries) == null ? void 0 : _a2.call(model, child, contents)) == null ? void 0 : _b2.bounding;\n if (!bounding2) return;\n const move = model.move;\n if (!move) return;\n return ctx.produce(child, (draft) => {\n var _a3;\n move(draft, { x: -center.x + r.point.x, y: -center.y + r.point.y });\n if (content.aligned) {\n (_a3 = model.rotate) == null ? void 0 : _a3.call(model, draft, r.point, ctx.radianToAngle(r.radian), contents);\n }\n });\n }));\n }\n }\n return result;\n });\n };\n const getGeometries = (content, contents) => ctx.getContentsGeometries(content, contents, getRefIds, [content], (c) => getAllContentsFromCache(c, contents));\n const React = ctx.React;\n return {\n type: "path array",\n ...ctx.containerModel,\n move: ctx.getContainerMove,\n rotate: ctx.getContainerRotate,\n scale: ctx.getContainerScale,\n explode(content, contents) {\n return ctx.getContentsExplode(getAllContentsFromCache(content, contents));\n },\n break(content, points, contents) {\n return ctx.getContentsBreak(getAllContentsFromCache(content, contents), points, contents);\n },\n render(content, renderCtx) {\n return renderCtx.target.renderGroup(ctx.renderContainerChildren({ contents: getAllContentsFromCache(content, renderCtx.contents), variableValues: content.variableValues }, renderCtx));\n },\n getSnapPoints(content, contents) {\n return ctx.getContentsSnapPoints(content, contents, (c) => getAllContentsFromCache(c, contents));\n },\n getGeometries,\n propertyPanel(content, update, contents, { acquireContent }) {\n return {\n path: [\n /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquireContent({ count: 1, selectable: (v) => pathContentSelectable(ctx, ctx.getContentByIndex(contents, v), contents) }, (r) => update((c) => {\n if (isPathArrayContent(c)) {\n c.path = r[0];\n }\n })) }, "select"),\n typeof content.path.id === "number" ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.path.id, setValue: (v) => update((c) => {\n if (isPathArrayContent(c)) {\n c.path.id = v;\n }\n }) }) : void 0\n ],\n length: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.length, setValue: (v) => update((c) => {\n if (isPathArrayContent(c)) {\n c.length = v;\n }\n }) }),\n aligned: /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.aligned === true, setValue: (v) => update((c) => {\n if (isPathArrayContent(c)) {\n c.aligned = v ? true : void 0;\n }\n }) }),\n ...ctx.getVariableValuesContentPropertyPanel(content, ctx.getContainerVariableNames(content), update)\n };\n },\n getRefIds,\n updateRefId(content, update) {\n if (content.path) {\n const newRefId = update(content.path.id);\n if (newRefId !== void 0) {\n content.path.id = newRefId;\n }\n }\n },\n isValid: (c, p) => ctx.validate(c, PathArrayContent, p)\n };\n}\nfunction isPathArrayContent(content) {\n return content.type === "path array";\n}\nfunction pathContentSelectable(ctx, content, contents) {\n var _a, _b;\n if (!content) return false;\n const geometries = (_b = (_a = ctx.getContentModel(content)) == null ? void 0 : _a.getGeometries) == null ? void 0 : _b.call(_a, content, contents);\n if (!geometries) return false;\n return geometries.lines.length > 0;\n}\nfunction getCommand(ctx) {\n function contentSelectable(content, contents) {\n return ctx.contentIsDeletable(content, contents);\n }\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "11,89 92,8", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "11", cy: "89", r: "12", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "36", cy: "64", r: "12", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "61", cy: "39", r: "12", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "86", cy: "14", r: "12", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }));\n return {\n name: "create path array",\n useCommand({ type, onEnd, acquireContent, selected, contents }) {\n const target = React.useRef();\n const path = React.useRef();\n const reset = () => {\n target.current = void 0;\n path.current = void 0;\n };\n React.useEffect(() => {\n if (!type) return;\n if (!target.current) {\n target.current = selected.map((s) => s.path);\n acquireContent(\n {\n count: 1,\n selectable: (v) => {\n const content = ctx.getContentByIndex(contents, v);\n if (!content) return false;\n return pathContentSelectable(ctx, content, contents);\n }\n },\n (r) => {\n path.current = r[0];\n }\n );\n } else if (path.current) {\n const children = target.current.map((c) => contents[c[0]]);\n const bounding = ctx.getContentsBounding(children, contents);\n if (bounding) {\n const length = ctx.getTwoPointsDistance(bounding.start, bounding.end);\n onEnd({\n updateContents(contents2) {\n if (target.current && path.current) {\n contents2.push({\n type: "path array",\n contents: children,\n path: path.current,\n length\n });\n ctx.deleteSelectedContents(contents2, target.current.map((c) => c[0]));\n }\n }\n });\n }\n reset();\n }\n }, [type]);\n return {\n onStart() {\n },\n reset\n };\n },\n contentSelectable,\n icon\n };\n}\nexport {\n getCommand,\n getModel,\n isPathArrayContent\n};\n','// dev/cad-editor/plugins/path.plugin.tsx\nfunction getModel(ctx) {\n const PathContent = ctx.and(ctx.BaseContent("path"), ctx.StrokeFields, ctx.FillFields, {\n commands: [ctx.PathCommand]\n });\n const getRefIds = (content) => ctx.getStrokeAndFillRefIds(content);\n function getPathGeometriesFromCache(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return ctx.getGeometriesFromCache(content, refs, () => {\n const lines = ctx.pathCommandsToGeometryLines(content.commands)[0];\n const points = ctx.getGeometryLinesPoints(lines);\n return {\n lines,\n bounding: ctx.getGeometryLinesBounding(lines),\n renderingLines: ctx.dashedPolylineToLines(points, content.dashArray),\n regions: ctx.hasFill(content) ? [\n {\n lines,\n points\n }\n ] : void 0\n };\n });\n }\n const React = ctx.React;\n return {\n type: "path",\n ...ctx.strokeModel,\n ...ctx.fillModel,\n move(content, offset) {\n for (const command of content.commands) {\n if (command.type !== "close") {\n ctx.movePoint(command.to, offset);\n }\n if (command.type === "arc") {\n ctx.movePoint(command.from, offset);\n } else if (command.type === "bezierCurve") {\n ctx.movePoint(command.cp1, offset);\n ctx.movePoint(command.cp2, offset);\n } else if (command.type === "quadraticCurve") {\n ctx.movePoint(command.cp, offset);\n }\n }\n },\n rotate(content, center, angle) {\n for (const command of content.commands) {\n if (command.type !== "close") {\n ctx.rotatePoint(command.to, center, angle);\n }\n if (command.type === "arc") {\n ctx.rotatePoint(command.from, center, angle);\n } else if (command.type === "bezierCurve") {\n ctx.rotatePoint(command.cp1, center, angle);\n ctx.rotatePoint(command.cp2, center, angle);\n } else if (command.type === "quadraticCurve") {\n ctx.rotatePoint(command.cp, center, angle);\n }\n }\n },\n scale(content, center, sx, sy) {\n for (const command of content.commands) {\n if (command.type !== "close") {\n ctx.scalePoint(command.to, center, sx, sy);\n }\n if (command.type === "arc") {\n ctx.scalePoint(command.from, center, sx, sy);\n } else if (command.type === "bezierCurve") {\n ctx.scalePoint(command.cp1, center, sx, sy);\n ctx.scalePoint(command.cp2, center, sx, sy);\n } else if (command.type === "quadraticCurve") {\n ctx.scalePoint(command.cp, center, sx, sy);\n }\n }\n },\n skew(content, center, sx, sy) {\n for (const command of content.commands) {\n if (command.type !== "close") {\n ctx.skewPoint(command.to, center, sx, sy);\n }\n if (command.type === "arc") {\n ctx.skewPoint(command.from, center, sx, sy);\n } else if (command.type === "bezierCurve") {\n ctx.skewPoint(command.cp1, center, sx, sy);\n ctx.skewPoint(command.cp2, center, sx, sy);\n } else if (command.type === "quadraticCurve") {\n ctx.skewPoint(command.cp, center, sx, sy);\n }\n }\n },\n mirror(content, line) {\n for (const command of content.commands) {\n if (command.type !== "close") {\n ctx.mirrorPoint(command.to, line);\n }\n if (command.type === "arc") {\n ctx.mirrorPoint(command.from, line);\n } else if (command.type === "bezierCurve") {\n ctx.mirrorPoint(command.cp1, line);\n ctx.mirrorPoint(command.cp2, line);\n } else if (command.type === "quadraticCurve") {\n ctx.mirrorPoint(command.cp, line);\n }\n }\n },\n break(content, intersectionPoints, contents) {\n const lines = getPathGeometriesFromCache(content, contents).lines;\n return ctx.breakGeometryLinesToPathCommands(lines, intersectionPoints);\n },\n offset(content, point, distance, contents, lineJoin) {\n const lines = getPathGeometriesFromCache(content, contents).lines;\n const newLines = ctx.trimGeometryLinesOffsetResult(ctx.getParallelGeometryLinesByDistancePoint(point, lines, distance, lineJoin), point);\n return newLines.map((n) => ({\n ...content,\n commands: ctx.geometryLineToPathCommands(n)\n }));\n },\n extend(content, point, contents) {\n const lines = getPathGeometriesFromCache(content, contents).lines;\n const newLines = ctx.produce(lines, (draft) => ctx.extendGeometryLines(draft, point));\n content.commands = ctx.geometryLineToPathCommands(newLines);\n },\n render(content, renderCtx) {\n const { options, target } = ctx.getStrokeFillRenderOptionsFromRenderContext(content, renderCtx);\n return target.renderPathCommands(content.commands, options);\n },\n renderIfSelected(content, { color, target, strokeWidth }) {\n const points = [];\n content.commands.forEach((c, i) => {\n const last = ctx.getPathCommandEndPoint(content.commands, i - 1);\n if (last) {\n if (c.type === "quadraticCurve") {\n points.push([last, c.cp, c.to]);\n } else if (c.type === "bezierCurve") {\n points.push([last, c.cp1, c.cp2, c.to]);\n } else if (c.type === "arc") {\n points.push([last, c.from, c.to]);\n } else if (c.type === "ellipseArc") {\n points.push([last, c.to]);\n }\n }\n });\n return target.renderPath(points, { strokeColor: color, dashArray: [4], strokeWidth });\n },\n getEditPoints(content) {\n return ctx.getEditPointsFromCache(content, () => {\n const editPoints = [];\n content.commands.forEach((command, i) => {\n if (command.type === "arc") {\n editPoints.push({\n ...command.from,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isPathContent(c)) {\n return;\n }\n const m = c.commands[i];\n if (m.type !== "arc") {\n return;\n }\n m.from.x += cursor.x - start.x;\n m.from.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n });\n } else if (command.type === "bezierCurve") {\n editPoints.push(\n {\n ...command.cp1,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isPathContent(c)) {\n return;\n }\n const m = c.commands[i];\n if (m.type !== "bezierCurve") {\n return;\n }\n m.cp1.x += cursor.x - start.x;\n m.cp1.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n },\n {\n ...command.cp2,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isPathContent(c)) {\n return;\n }\n const m = c.commands[i];\n if (m.type !== "bezierCurve") {\n return;\n }\n m.cp2.x += cursor.x - start.x;\n m.cp2.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n }\n );\n } else if (command.type === "quadraticCurve") {\n editPoints.push({\n ...command.cp,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isPathContent(c)) {\n return;\n }\n const m = c.commands[i];\n if (m.type !== "quadraticCurve") {\n return;\n }\n m.cp.x += cursor.x - start.x;\n m.cp.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n });\n }\n if (command.type !== "close") {\n editPoints.push({\n ...command.to,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isPathContent(c)) {\n return;\n }\n const m = c.commands[i];\n if (m.type === "close") {\n return;\n }\n m.to.x += cursor.x - start.x;\n m.to.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n });\n }\n });\n return {\n editPoints\n };\n });\n },\n getGeometries: getPathGeometriesFromCache,\n canSelectPart: true,\n propertyPanel(content, update, contents, { acquirePoint }) {\n return {\n commands: /* @__PURE__ */ React.createElement(\n ctx.ArrayEditor,\n {\n inline: true,\n ...ctx.getArrayEditorProps((v) => v.commands, { type: "line", to: { x: 0, y: 0 } }, (v) => update((c) => {\n if (isPathContent(c)) {\n v(c);\n }\n })),\n items: content.commands.map((f, i) => {\n const properties = {\n type: /* @__PURE__ */ React.createElement(ctx.EnumEditor, { select: true, value: f.type, enums: ["move", "line", "arc", "ellipseArc", "bezierCurve", "quadraticCurve", "close"], setValue: (v) => update((c) => {\n if (isPathContent(c)) {\n if (v === "move" || v === "line") {\n c.commands[i] = {\n type: v,\n to: { x: 0, y: 0 }\n };\n } else if (v === "arc") {\n c.commands[i] = {\n type: v,\n radius: 10,\n from: { x: 0, y: 0 },\n to: { x: 0, y: 0 }\n };\n } else if (v === "ellipseArc") {\n c.commands[i] = {\n type: v,\n rx: 10,\n ry: 10,\n angle: 0,\n sweep: true,\n largeArc: true,\n to: { x: 0, y: 0 }\n };\n } else if (v === "bezierCurve") {\n c.commands[i] = {\n type: v,\n cp1: { x: 0, y: 0 },\n cp2: { x: 0, y: 0 },\n to: { x: 0, y: 0 }\n };\n } else if (v === "quadraticCurve") {\n c.commands[i] = {\n type: v,\n cp: { x: 0, y: 0 },\n to: { x: 0, y: 0 }\n };\n } else if (v === "close") {\n c.commands[i] = {\n type: v\n };\n }\n }\n }) })\n };\n if (f.type === "arc") {\n properties.from = /* @__PURE__ */ React.createElement(ctx.ObjectEditor, { inline: true, properties: {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isPathContent(c)) {\n const m = c.commands[i];\n if (m.type === "arc") {\n m.from.x = p.x;\n m.from.y = p.y;\n }\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.from.x, setValue: (v) => update((c) => {\n if (isPathContent(c)) {\n const m = c.commands[i];\n if (m.type === "arc") {\n m.from.x = v;\n }\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.from.y, setValue: (v) => update((c) => {\n if (isPathContent(c)) {\n const m = c.commands[i];\n if (m.type === "arc") {\n m.from.y = v;\n }\n }\n }) })\n } });\n properties.radius = /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.radius, setValue: (v) => update((c) => {\n if (isPathContent(c)) {\n const m = c.commands[i];\n if (m.type === "arc") {\n m.radius = v;\n }\n }\n }) });\n } else if (f.type === "ellipseArc") {\n properties.rx = /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.rx, setValue: (v) => update((c) => {\n if (isPathContent(c)) {\n const m = c.commands[i];\n if (m.type === "ellipseArc") {\n m.rx = v;\n }\n }\n }) });\n properties.ry = /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.ry, setValue: (v) => update((c) => {\n if (isPathContent(c)) {\n const m = c.commands[i];\n if (m.type === "ellipseArc") {\n m.ry = v;\n }\n }\n }) });\n properties.angle = /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.angle, setValue: (v) => update((c) => {\n if (isPathContent(c)) {\n const m = c.commands[i];\n if (m.type === "ellipseArc") {\n m.angle = v;\n }\n }\n }) });\n properties.largeArc = /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: f.largeArc, setValue: (v) => update((c) => {\n if (isPathContent(c)) {\n const m = c.commands[i];\n if (m.type === "ellipseArc") {\n m.largeArc = v;\n }\n }\n }) });\n properties.sweep = /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: f.sweep, setValue: (v) => update((c) => {\n if (isPathContent(c)) {\n const m = c.commands[i];\n if (m.type === "ellipseArc") {\n m.sweep = v;\n }\n }\n }) });\n } else if (f.type === "bezierCurve") {\n properties.cp1 = /* @__PURE__ */ React.createElement(ctx.ObjectEditor, { inline: true, properties: {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isPathContent(c)) {\n const m = c.commands[i];\n if (m.type === "bezierCurve") {\n m.cp1.x = p.x;\n m.cp1.y = p.y;\n }\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.cp1.x, setValue: (v) => update((c) => {\n if (isPathContent(c)) {\n const m = c.commands[i];\n if (m.type === "bezierCurve") {\n m.cp1.x = v;\n }\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.cp1.y, setValue: (v) => update((c) => {\n if (isPathContent(c)) {\n const m = c.commands[i];\n if (m.type === "bezierCurve") {\n m.cp1.y = v;\n }\n }\n }) })\n } });\n properties.cp2 = /* @__PURE__ */ React.createElement(ctx.ObjectEditor, { inline: true, properties: {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isPathContent(c)) {\n const m = c.commands[i];\n if (m.type === "bezierCurve") {\n m.cp2.x = p.x;\n m.cp2.y = p.y;\n }\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.cp2.x, setValue: (v) => update((c) => {\n if (isPathContent(c)) {\n const m = c.commands[i];\n if (m.type === "bezierCurve") {\n m.cp2.x = v;\n }\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.cp2.y, setValue: (v) => update((c) => {\n if (isPathContent(c)) {\n const m = c.commands[i];\n if (m.type === "bezierCurve") {\n m.cp2.y = v;\n }\n }\n }) })\n } });\n } else if (f.type === "quadraticCurve") {\n properties.cp = /* @__PURE__ */ React.createElement(ctx.ObjectEditor, { inline: true, properties: {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isPathContent(c)) {\n const m = c.commands[i];\n if (m.type === "quadraticCurve") {\n m.cp.x = p.x;\n m.cp.y = p.y;\n }\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.cp.x, setValue: (v) => update((c) => {\n if (isPathContent(c)) {\n const m = c.commands[i];\n if (m.type === "quadraticCurve") {\n m.cp.x = v;\n }\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.cp.y, setValue: (v) => update((c) => {\n if (isPathContent(c)) {\n const m = c.commands[i];\n if (m.type === "quadraticCurve") {\n m.cp.y = v;\n }\n }\n }) })\n } });\n }\n if (f.type !== "close") {\n properties.to = /* @__PURE__ */ React.createElement(ctx.ObjectEditor, { inline: true, properties: {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isPathContent(c)) {\n const m = c.commands[i];\n if (m.type !== "close") {\n m.to.x = p.x;\n m.to.y = p.y;\n }\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.to.x, setValue: (v) => update((c) => {\n if (isPathContent(c)) {\n const m = c.commands[i];\n if (m.type !== "close") {\n m.to.x = v;\n }\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.to.y, setValue: (v) => update((c) => {\n if (isPathContent(c)) {\n const m = c.commands[i];\n if (m.type !== "close") {\n m.to.y = v;\n }\n }\n }) })\n } });\n }\n return /* @__PURE__ */ React.createElement(ctx.ObjectEditor, { inline: true, properties });\n })\n }\n ),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents),\n ...ctx.getFillContentPropertyPanel(content, update, contents)\n };\n },\n isValid: (c, p) => ctx.validate(c, PathContent, p),\n getRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n deleteRefId: ctx.deleteStrokeAndFillRefIds,\n reverse: (content, contents) => ({\n ...content,\n commands: ctx.geometryLineToPathCommands(ctx.reverseGeometryLines(getPathGeometriesFromCache(content, contents).lines))\n })\n };\n}\nfunction isPathContent(content) {\n return content.type === "path";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("path", { d: " M 8 8 L 40 7 A 50 50 0 0 1 91 57 Q 91 91, 17 90 C 50 72, 50 31, 8 24 Z", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "create path",\n hotkey: "P",\n icon,\n useCommand({ onEnd, type, scale, strokeStyleId, fillStyleId }) {\n const { path, controlPoint, controlPoint2, preview, onClick, onMove, input, setInputType, cursorPosition, reset } = ctx.usePathClickCreate(\n type === "create path",\n (c) => onEnd({\n updateContents: (contents) => contents.push({\n type: "path",\n strokeStyleId,\n fillStyleId,\n commands: c\n })\n })\n );\n const assistentContents = [];\n if (preview.length > 1) {\n assistentContents.push({\n type: "path",\n strokeStyleId,\n fillStyleId,\n commands: preview\n });\n }\n const last = ctx.getPathCommandEndPoint(path, path.length - 1);\n if (last) {\n if (controlPoint) {\n assistentContents.push({ type: "line", points: [last, controlPoint], dashArray: [4 / scale] });\n if (controlPoint2) {\n assistentContents.push({ type: "line", points: [controlPoint, controlPoint2], dashArray: [4 / scale] });\n if (cursorPosition) {\n assistentContents.push({ type: "line", points: [controlPoint2, cursorPosition], dashArray: [4 / scale] });\n }\n } else {\n if (cursorPosition) {\n assistentContents.push({ type: "line", points: [controlPoint, cursorPosition], dashArray: [4 / scale] });\n }\n }\n } else if (cursorPosition) {\n assistentContents.push({ type: "line", points: [last, cursorPosition], dashArray: [4 / scale] });\n }\n }\n return {\n onStart: onClick,\n input,\n onMove,\n reset,\n subcommand: type === "create path" ? /* @__PURE__ */ React.createElement("span", null, ["line", "arc", "bezierCurve", "quadraticCurve", "close"].map((m) => /* @__PURE__ */ React.createElement("button", { key: m, onClick: () => setInputType(m), style: { position: "relative" } }, m))) : void 0,\n assistentContents\n };\n },\n selectCount: 0\n };\n}\nexport {\n getCommand,\n getModel,\n isPathContent\n};\n','// dev/cad-editor/plugins/pen.plugin.tsx\nfunction getModel(ctx) {\n const PenContent = ctx.and(ctx.BaseContent("pen"), ctx.StrokeFields, {\n points: ctx.minItems(2, [ctx.Position])\n });\n const getRefIds = (content) => ctx.getStrokeRefIds(content);\n function getGeometries(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return ctx.getGeometriesFromCache(content, refs, () => {\n const lines = Array.from(ctx.iteratePolylineLines(content.points));\n return {\n lines,\n bounding: ctx.getPointsBounding(content.points),\n renderingLines: ctx.dashedPolylineToLines(content.points, content.dashArray)\n };\n });\n }\n return {\n type: "pen",\n ...ctx.strokeModel,\n move(content, offset) {\n for (const point of content.points) {\n ctx.movePoint(point, offset);\n }\n },\n rotate(content, center, angle) {\n for (const point of content.points) {\n ctx.rotatePoint(point, center, angle);\n }\n },\n scale(content, center, sx, sy) {\n for (const point of content.points) {\n ctx.scalePoint(point, center, sx, sy);\n }\n },\n skew(content, center, sx, sy) {\n for (const point of content.points) {\n ctx.skewPoint(point, center, sx, sy);\n }\n },\n mirror(content, line) {\n for (const point of content.points) {\n ctx.mirrorPoint(point, line);\n }\n },\n render(content, renderCtx) {\n const { options, target } = ctx.getStrokeRenderOptionsFromRenderContext(content, renderCtx);\n return target.renderPolyline(content.points, options);\n },\n getGeometries,\n propertyPanel(content, update, contents) {\n return ctx.getStrokeContentPropertyPanel(content, update, contents);\n },\n isValid: (c, p) => ctx.validate(c, PenContent, p),\n getRefIds,\n updateRefId: ctx.updateStrokeRefIds,\n deleteRefId: ctx.deleteStrokeRefIds,\n reverse: (content) => ({\n ...content,\n points: content.points.slice().reverse()\n })\n };\n}\nfunction isPenContent(content) {\n return content.type === "pen";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { viewBox: "0 0 1024 1024", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React.createElement("path", { d: "m199.04 672.64 193.984 112 224-387.968-193.92-112-224 388.032zm-23.872 60.16 32.896 148.288 144.896-45.696L175.168 732.8zM455.04 229.248l193.92 112 56.704-98.112-193.984-112-56.64 98.112zM104.32 708.8l384-665.024 304.768 175.936L409.152 884.8h.064l-248.448 78.336L104.32 708.8zm384 254.272v-64h448v64h-448z", fill: "currentColor" }));\n return {\n name: "create pen",\n useCommand({ onEnd, type, strokeStyleId }) {\n const { reset, points, onClick, onMove } = ctx.usePenClickCreate(\n type === "create pen",\n () => onEnd({\n updateContents: (contents) => contents.push({ points, strokeStyleId, type: "pen" })\n })\n );\n const assistentContents = [];\n if (points.length > 1) {\n assistentContents.push({ points, strokeStyleId, type: "pen" });\n }\n return {\n onStart: onClick,\n onMove,\n assistentContents,\n reset\n };\n },\n selectCount: 0,\n icon\n };\n}\nexport {\n getCommand,\n getModel,\n isPenContent\n};\n','// dev/cad-editor/plugins/pline.plugin.tsx\nfunction getModel(ctx) {\n const PlineContent = ctx.and(ctx.BaseContent("pline"), ctx.StrokeFields, ctx.FillFields, {\n points: ctx.minItems(2, [{ point: ctx.Position, bulge: ctx.number }]),\n closed: ctx.optional(ctx.boolean)\n });\n const getRefIds = (content) => ctx.getStrokeAndFillRefIds(content);\n const geometriesCache = new ctx.WeakmapValuesCache();\n function getPlineGeometries(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return geometriesCache.get(content, refs, () => {\n const lines = [];\n const centers = [];\n const middles = [];\n for (let i = 0; i < content.points.length; i++) {\n const p = content.points[i];\n if (i === content.points.length - 1) {\n if (content.closed) {\n lines.push(ctx.getGeometryLineByStartEndBulge(p.point, content.points[0].point, p.bulge));\n }\n } else {\n lines.push(ctx.getGeometryLineByStartEndBulge(p.point, content.points[i + 1].point, p.bulge));\n }\n }\n for (const line of lines) {\n if (Array.isArray(line)) {\n middles.push(ctx.getTwoPointCenter(...line));\n } else if (line.type === "arc") {\n centers.push(line.curve);\n middles.push(ctx.getArcPointAtAngle(line.curve, ctx.getTwoNumberCenter(line.curve.startAngle, ctx.getFormattedEndAngle(line.curve))));\n }\n }\n const points = ctx.getGeometryLinesPoints(lines);\n return {\n lines,\n points,\n centers,\n middles,\n bounding: ctx.getGeometryLinesBounding(lines),\n renderingLines: ctx.dashedPolylineToLines(points, content.dashArray),\n regions: ctx.hasFill(content) ? [\n {\n lines,\n points\n }\n ] : void 0\n };\n });\n }\n const React = ctx.React;\n return {\n type: "pline",\n ...ctx.strokeModel,\n ...ctx.fillModel,\n move(content, offset) {\n for (const point of content.points) {\n ctx.movePoint(point.point, offset);\n }\n },\n rotate(content, center, angle) {\n for (const point of content.points) {\n ctx.rotatePoint(point.point, center, angle);\n }\n },\n scale(content, center, sx, sy) {\n for (const point of content.points) {\n ctx.scalePoint(point.point, center, sx, sy);\n }\n },\n skew(content, center, sx, sy) {\n for (const point of content.points) {\n ctx.skewPoint(point.point, center, sx, sy);\n }\n },\n mirror(content, line) {\n for (const point of content.points) {\n ctx.mirrorPoint(point.point, line);\n point.bulge *= -1;\n }\n },\n break(content, intersectionPoints, contents) {\n const { lines } = getPlineGeometries(content, contents);\n const newLines = ctx.breakGeometryLines(lines, intersectionPoints);\n return newLines.map((line) => ctx.geometryLinesToPline(line));\n },\n explode(content, contents) {\n const { lines } = getPlineGeometries(content, contents);\n return lines.map((line) => ctx.geometryLineToContent(line));\n },\n offset(content, point, distance, contents, lineJoin) {\n const { lines } = getPlineGeometries(content, contents);\n const newLines = ctx.trimGeometryLinesOffsetResult(ctx.getParallelGeometryLinesByDistancePoint(point, lines, distance, lineJoin), point);\n return newLines.map((n) => ctx.geometryLinesToPline(n));\n },\n join(content, target, contents) {\n var _a, _b, _c;\n const { lines } = getPlineGeometries(content, contents);\n const line2 = (_c = (_b = (_a = ctx.getContentModel(target)) == null ? void 0 : _a.getGeometries) == null ? void 0 : _b.call(_a, target, contents)) == null ? void 0 : _c.lines;\n if (!line2) return;\n const newLines = ctx.mergeGeometryLines(lines, line2);\n if (!newLines) return;\n return ctx.geometryLinesToPline(newLines);\n },\n extend(content, point, contents) {\n if (content.closed) return;\n const { lines } = getPlineGeometries(content, contents);\n const first = lines[0], last = lines[lines.length - 1];\n if (Array.isArray(first)) {\n if (ctx.pointIsOnRay(point, { ...first[0], angle: ctx.radianToAngle(ctx.getTwoPointsRadian(...first)) })) {\n content.points[0].point = point;\n }\n } else if (first.type === "arc") {\n if (ctx.pointIsOnCircle(point, first.curve)) {\n content.points[0].point = point;\n content.points[0].bulge = ctx.getArcBulge({ ...first.curve, startAngle: ctx.radianToAngle(ctx.getCircleRadian(point, first.curve)) }, point);\n }\n }\n if (Array.isArray(last)) {\n if (ctx.pointIsOnRay(point, { ...last[1], angle: ctx.radianToAngle(ctx.getTwoPointsRadian(last[1], last[0])) })) {\n content.points[content.points.length - 1].point = point;\n }\n } else if (last.type === "arc") {\n if (ctx.pointIsOnCircle(point, last.curve)) {\n content.points[content.points.length - 1].point = point;\n content.points[content.points.length - 2].bulge = ctx.getArcBulge({ ...last.curve, endAngle: ctx.radianToAngle(ctx.getCircleRadian(point, last.curve)) }, void 0, point);\n }\n }\n },\n render(content, renderCtx) {\n const { options, target } = ctx.getStrokeFillRenderOptionsFromRenderContext(content, renderCtx);\n return target.renderPath([getPlineGeometries(content, renderCtx.contents).points], options);\n },\n getOperatorRenderPosition(content) {\n return content.points[0].point;\n },\n getEditPoints(content, contents) {\n return ctx.getEditPointsFromCache(content, () => {\n const { middles } = getPlineGeometries(content, contents);\n const endpoints = content.points.map((p, i) => ({\n x: p.point.x,\n y: p.point.y,\n cursor: "move",\n type: "move",\n update(c, { cursor, start, scale }) {\n if (!isPlineContent(c)) {\n return;\n }\n c.points[i].point.x += cursor.x - start.x;\n c.points[i].point.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [p.point, cursor] }] };\n },\n menu: [\n {\n title: "Remove",\n execute(draft) {\n if (isPlineContent(draft)) {\n draft.points.splice(i, 1);\n }\n }\n },\n ...i === 0 || i === content.points.length - 1 ? [{\n title: "Add",\n update(c, { cursor, scale }) {\n if (!isPlineContent(c)) {\n return;\n }\n c.points.splice(i === 0 ? 0 : i + 1, 0, { point: { x: cursor.x, y: cursor.y }, bulge: 0 });\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [p.point, cursor] }] };\n }\n }] : []\n ]\n }));\n const midpoints = middles.map((p, i) => ({\n x: p.x,\n y: p.y,\n cursor: "move",\n type: "move",\n update(c, { cursor, start, scale }) {\n if (!isPlineContent(c)) {\n return;\n }\n const j = i === content.points.length - 1 ? 0 : i + 1;\n if (ctx.isZero(content.points[i].bulge)) {\n c.points[i].point.x += cursor.x - start.x;\n c.points[i].point.y += cursor.y - start.y;\n c.points[j].point.x += cursor.x - start.x;\n c.points[j].point.y += cursor.y - start.y;\n } else {\n const bulge = ctx.getArcBulgeByStartEndPoint(content.points[i].point, content.points[j].point, cursor);\n if (bulge !== void 0) {\n c.points[i].bulge = bulge;\n }\n }\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [p, cursor] }] };\n },\n menu: [\n {\n title: "Add",\n update(c, { cursor, scale }) {\n if (!isPlineContent(c)) {\n return;\n }\n c.points.splice(i + 1, 0, { point: { x: cursor.x, y: cursor.y }, bulge: 0 });\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [p, cursor] }] };\n }\n },\n ctx.isZero(content.points[i].bulge) ? {\n title: "To Arc",\n update(c, { cursor, scale }) {\n if (!isPlineContent(c)) {\n return;\n }\n const j = i === content.points.length - 1 ? 0 : i + 1;\n const bulge = ctx.getArcBulgeByStartEndPoint(content.points[i].point, content.points[j].point, cursor);\n if (bulge !== void 0) {\n c.points[i].bulge = bulge;\n }\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [p, cursor] }] };\n }\n } : {\n title: "To Line",\n execute(draft) {\n if (isPlineContent(draft)) {\n draft.points[i].bulge = 0;\n }\n }\n }\n ]\n }));\n return {\n editPoints: [\n ...endpoints,\n ...midpoints\n ]\n };\n });\n },\n getSnapPoints(content, contents) {\n const { centers, middles } = getPlineGeometries(content, contents);\n return ctx.getSnapPointsFromCache(content, () => {\n return [\n ...content.points.map((p) => ({ ...p.point, type: "endpoint" })),\n ...centers.map((p) => ({ ...p, type: "center" })),\n ...middles.map((p) => ({ ...p, type: "midpoint" }))\n ];\n });\n },\n getGeometries: getPlineGeometries,\n canSelectPart: true,\n propertyPanel(content, update, contents, { acquirePoint }) {\n var _a;\n return {\n points: /* @__PURE__ */ React.createElement(\n ctx.ArrayEditor,\n {\n inline: true,\n ...ctx.getArrayEditorProps((v) => v.points, { point: { x: 0, y: 0 }, bulge: 0 }, (v) => update((c) => {\n if (isPlineContent(c)) {\n v(c);\n }\n })),\n items: content.points.map((f, i) => /* @__PURE__ */ React.createElement(\n ctx.ObjectEditor,\n {\n inline: true,\n properties: {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isPlineContent(c)) {\n c.points[i].point.x = p.x;\n c.points[i].point.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.point.x, setValue: (v) => update((c) => {\n if (isPlineContent(c)) {\n c.points[i].point.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.point.y, setValue: (v) => update((c) => {\n if (isPlineContent(c)) {\n c.points[i].point.y = v;\n }\n }) }),\n bulge: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.bulge, setValue: (v) => update((c) => {\n if (isPlineContent(c)) {\n c.points[i].bulge = v;\n }\n }) }),\n radius: f.bulge ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: ctx.getArcByStartEndBulge(f.point, (content.points[i + 1] || content.points[0]).point, f.bulge).r, setValue: (v) => update((c) => {\n if (isPlineContent(c)) {\n c.points[i].bulge = ctx.getArcBulgeByStartEndRadius(f.point, (content.points[i + 1] || content.points[0]).point, v, f.bulge) || 0;\n }\n }) }) : []\n }\n }\n ))\n }\n ),\n closed: /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: (_a = content.closed) != null ? _a : false, setValue: (v) => update((c) => {\n if (isPlineContent(c)) {\n c.closed = v;\n }\n }) }),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents),\n ...ctx.getFillContentPropertyPanel(content, update, contents)\n };\n },\n isValid: (c, p) => ctx.validate(c, PlineContent, p),\n getRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n deleteRefId: ctx.deleteStrokeAndFillRefIds,\n reverse: (content) => ({\n ...content,\n points: content.points.slice().reverse().map((p, i, points) => ({\n point: p.point,\n bulge: -points[i === points.length - 1 ? 0 : i + 1].bulge\n }))\n }),\n isPointIn: (content, point, contents) => ctx.pointInPolygon(point, getPlineGeometries(content, contents).points)\n };\n}\nfunction isPlineContent(content) {\n return content.type === "pline";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "6,92 56,92", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("path", { d: "M 54 15 A 38 38 0 0 1 55 92", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", strokeOpacity: "1", fill: "none", stroke: "currentColor" }));\n return {\n name: "create pline",\n useCommand({ onEnd, scale, type, strokeStyleId, fillStyleId }) {\n const { line, onClick, onMove, input, inputMode, lastPosition, reset, positions } = ctx.useLineClickCreate(\n type === "create pline",\n (c) => onEnd({\n updateContents: (contents) => contents.push({ points: c.map((p) => ({ point: p, bulge: 0 })), strokeStyleId, fillStyleId, type: "pline" })\n })\n );\n const assistentContents = [];\n if (line && line.length > 1) {\n const start = line[line.length - 2];\n const end = line[line.length - 1];\n const r = ctx.getTwoPointsDistance(start, end);\n const angle = ctx.radianToAngle(ctx.getTwoPointsRadian(end, start));\n assistentContents.push(\n {\n type: "arc",\n x: start.x,\n y: start.y,\n r,\n dashArray: [4 / scale],\n startAngle: angle > 180 || angle < 0 ? angle : 0,\n endAngle: angle > 180 || angle < 0 ? 0 : angle\n },\n {\n type: "line",\n dashArray: [4 / scale],\n points: [start, { x: start.x + r, y: start.y }]\n },\n ...ctx.getAssistentText(\n r.toFixed(2),\n 16 / scale,\n (start.x + end.x) / 2 - 20,\n (start.y + end.y) / 2 + 4,\n inputMode === "length" ? 16711680 : 16764108\n ),\n ...ctx.getAssistentText(\n `${angle.toFixed(1)}\\xB0`,\n 16 / scale,\n end.x + 10,\n end.y - 10,\n inputMode === "angle" ? 16711680 : 16764108\n )\n );\n }\n if (line) {\n assistentContents.push({ points: line, strokeStyleId, fillStyleId, type: "polyline" });\n }\n return {\n onStart: onClick,\n input,\n onMove,\n assistentContents,\n lastPosition,\n reset,\n subcommand: type === "create pline" && positions.length > 2 ? /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement(\n "button",\n {\n onClick: () => {\n onEnd({\n updateContents: (contents) => contents.push({ points: positions, type: "polygon" })\n });\n reset();\n },\n style: { position: "relative" }\n },\n "close"\n )) : void 0\n };\n },\n selectCount: 0,\n icon\n };\n}\nexport {\n getCommand,\n getModel,\n isPlineContent\n};\n','// dev/cad-editor/plugins/point.plugin.tsx\nfunction getModel(ctx) {\n const PointContent = ctx.and(ctx.BaseContent("point"), ctx.Position);\n function getPointGeometries(content) {\n return ctx.getGeometriesFromCache(content, /* @__PURE__ */ new Set(), () => {\n return {\n lines: [[content, content]],\n bounding: ctx.getPointsBounding([content]),\n renderingLines: [],\n regions: []\n };\n });\n }\n const React = ctx.React;\n return {\n type: "point",\n move(content, offset) {\n ctx.movePoint(content, offset);\n },\n rotate(content, center, angle) {\n ctx.rotatePoint(content, center, angle);\n },\n scale(content, center, sx, sy) {\n ctx.scalePoint(content, center, sx, sy);\n },\n skew(content, center, sx, sy) {\n ctx.skewPoint(content, center, sx, sy);\n },\n mirror(content, line) {\n ctx.mirrorPoint(content, line);\n },\n render(content, { target, isHoveringOrSelected, transformStrokeWidth }) {\n const strokeWidth = transformStrokeWidth(1);\n const fuzzy = isHoveringOrSelected && strokeWidth !== 1;\n const result = target.renderCircle(content.x, content.y, 1, { fillColor: 0 });\n if (fuzzy) {\n return target.renderGroup([\n target.renderCircle(content.x, content.y, strokeWidth, {\n fillColor: 0,\n strokeWidth: 0,\n fillOpacity: ctx.fuzzyStyle.strokeOpacity\n }),\n result\n ]);\n }\n return result;\n },\n getOperatorRenderPosition(content) {\n return content;\n },\n getEditPoints(content) {\n return ctx.getEditPointsFromCache(content, () => {\n return {\n editPoints: [\n {\n x: content.x,\n y: content.y,\n cursor: "move",\n type: "move",\n update(c, { cursor, start, scale }) {\n if (!isPointContent(c)) {\n return;\n }\n c.x += cursor.x - start.x;\n c.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [content, cursor] }] };\n }\n }\n ]\n };\n });\n },\n getSnapPoints(content) {\n return ctx.getSnapPointsFromCache(content, () => [{ x: content.x, y: content.y, type: "endpoint" }]);\n },\n getGeometries: getPointGeometries,\n propertyPanel(content, update, _, { acquirePoint }) {\n return {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isPointContent(c)) {\n c.x = p.x;\n c.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.x, setValue: (v) => update((c) => {\n if (isPointContent(c)) {\n c.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.y, setValue: (v) => update((c) => {\n if (isPointContent(c)) {\n c.y = v;\n }\n }) })\n };\n },\n isValid: (c, p) => ctx.validate(c, PointContent, p)\n };\n}\nfunction isPointContent(content) {\n return content.type === "point";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("circle", { cx: "44", cy: "48", r: "4", strokeWidth: "2", vectorEffect: "non-scaling-stroke", fill: "none", stroke: "currentColor" }));\n return [\n {\n name: "create point",\n icon,\n useCommand({ type, onEnd }) {\n const [point, setPoint] = React.useState();\n const reset = () => {\n setPoint(void 0);\n };\n const assistentContents = [];\n if (point) {\n assistentContents.push({ ...point, type: "point" });\n }\n return {\n onStart: (p) => {\n onEnd({\n updateContents: (contents) => contents.push({ x: p.x, y: p.y, type: "point" })\n });\n },\n onMove(p) {\n if (!type) return;\n setPoint(p);\n },\n assistentContents,\n reset\n };\n },\n selectCount: 0\n }\n ];\n}\nexport {\n getCommand,\n getModel,\n isPointContent\n};\n','// dev/cad-editor/plugins/polar-array.plugin.tsx\nfunction getModel(ctx) {\n const PolarArrayContent = ctx.and(ctx.BaseContent("polar array"), ctx.ContainerFields, {\n center: ctx.Position,\n itemCount: ctx.number,\n itemAngle: ctx.number,\n rowCount: ctx.number,\n rowSpacing: ctx.number\n });\n const getRefIds = (content) => ctx.toRefIds(content.contents);\n const getAllContentsFromCache = (content, contents) => {\n return ctx.allContentsCache.get(content, () => {\n const result = [];\n const bounding = ctx.getContentsBounding(content.contents, contents);\n if (!bounding) return result;\n const base = {\n x: ctx.getTwoNumberCenter(bounding.start.x, bounding.end.x),\n y: ctx.getTwoNumberCenter(bounding.start.y, bounding.end.y)\n };\n for (let i = 0; i < content.rowCount; i++) {\n for (let j = 0; j < content.itemCount; j++) {\n const angle = j * content.itemAngle;\n if (i === 0 && j === 0) {\n result.push(...content.contents);\n } else {\n result.push(...content.contents.map((c) => {\n if (!c) return;\n const model = ctx.getContentModel(c);\n const rotate = model == null ? void 0 : model.rotate;\n if (!rotate) return;\n const move = model.move;\n if (!move) return;\n return ctx.produce(c, (draft) => {\n if (i !== 0) {\n const center = ctx.getPointByLengthAndDirection(base, -i * content.rowSpacing, content.center);\n move(draft, {\n x: center.x - base.x,\n y: center.y - base.y\n });\n }\n rotate(draft, content.center, angle, contents);\n });\n }));\n }\n }\n }\n return result;\n });\n };\n const getGeometries = (content, contents) => ctx.getContentsGeometries(content, contents, getRefIds, [content], (c) => getAllContentsFromCache(c, contents));\n const React = ctx.React;\n return {\n type: "polar array",\n ...ctx.containerModel,\n move(content, offset) {\n ctx.getContainerMove(content, offset);\n ctx.movePoint(content.center, offset);\n },\n rotate(content, center, angle, contents) {\n ctx.rotatePoint(content.center, center, angle);\n content.contents.forEach((c) => {\n var _a, _b;\n if (!c) return;\n (_b = (_a = ctx.getContentModel(c)) == null ? void 0 : _a.rotate) == null ? void 0 : _b.call(_a, c, center, angle, contents);\n });\n },\n scale(content, center, sx, sy, contents) {\n ctx.scalePoint(content.center, center, sx, sy);\n ctx.getContainerScale(content, center, sx, sy, contents);\n },\n skew(content, center, sx, sy, contents) {\n ctx.skewPoint(content.center, center, sx, sy);\n ctx.getContainerSkew(content, center, sx, sy, contents);\n },\n explode(content, contents) {\n return ctx.getContentsExplode(getAllContentsFromCache(content, contents));\n },\n break(content, points, contents) {\n return ctx.getContentsBreak(getAllContentsFromCache(content, contents), points, contents);\n },\n render(content, renderCtx) {\n return renderCtx.target.renderGroup(ctx.renderContainerChildren({ contents: getAllContentsFromCache(content, renderCtx.contents), variableValues: content.variableValues }, renderCtx));\n },\n getEditPoints(content, contents) {\n return ctx.getEditPointsFromCache(content, () => {\n const bounding = ctx.getContentsBounding(content.contents, contents);\n if (!bounding) {\n return { editPoints: [] };\n }\n const base = {\n x: ctx.getTwoNumberCenter(bounding.start.x, bounding.end.x),\n y: ctx.getTwoNumberCenter(bounding.start.y, bounding.end.y)\n };\n const editPoints = [\n {\n ...base,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isPolarArrayContent(c)) {\n return;\n }\n ctx.getContainerMove(c, {\n x: cursor.x - start.x,\n y: cursor.y - start.y\n });\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n },\n {\n x: content.center.x,\n y: content.center.y,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isPolarArrayContent(c)) {\n return;\n }\n c.center.x += cursor.x - start.x;\n c.center.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n }\n ];\n if (content.rowCount > 1) {\n const p = ctx.getPointByLengthAndDirection(base, -content.rowSpacing, content.center);\n editPoints.push({\n ...p,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isPolarArrayContent(c)) {\n return;\n }\n c.rowSpacing = ctx.getTwoPointsDistance(cursor, base);\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n });\n }\n if (content.rowCount > 2) {\n const p = ctx.getPointByLengthAndDirection(base, -(content.rowCount - 1) * content.rowSpacing, content.center);\n editPoints.push({\n ...p,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isPolarArrayContent(c)) {\n return;\n }\n c.rowCount = Math.round(ctx.getTwoPointsDistance(cursor, base) / c.rowSpacing) + 1;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n });\n }\n if (content.itemCount > 1) {\n const p = ctx.rotatePositionByCenter(base, content.center, -content.itemAngle);\n editPoints.push({\n ...p,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isPolarArrayContent(c)) {\n return;\n }\n c.itemAngle = ctx.radianToAngle(ctx.getTwoPointsRadian(cursor, content.center) - ctx.getTwoPointsRadian(base, content.center));\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n });\n }\n if (content.itemCount > 2) {\n const p = ctx.rotatePositionByCenter(base, content.center, -(content.itemCount - 1) * content.itemAngle);\n editPoints.push({\n ...p,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isPolarArrayContent(c)) {\n return;\n }\n let angle = ctx.radianToAngle(ctx.getTwoPointsRadian(cursor, content.center) - ctx.getTwoPointsRadian(base, content.center));\n if (c.itemAngle > 0) {\n if (angle < 0) {\n angle += 360;\n }\n } else {\n if (angle > 0) {\n angle -= 360;\n }\n }\n c.itemCount = Math.round(angle / c.itemAngle) + 1;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n });\n }\n return {\n editPoints\n };\n });\n },\n getSnapPoints(content, contents) {\n return ctx.getContentsSnapPoints(content, contents, (c) => getAllContentsFromCache(c, contents));\n },\n getGeometries,\n propertyPanel(content, update, _, { acquirePoint }) {\n return {\n center: /* @__PURE__ */ React.createElement(\n ctx.ObjectEditor,\n {\n inline: true,\n properties: {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isPolarArrayContent(c)) {\n c.center.x = p.x;\n c.center.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.center.x, setValue: (v) => update((c) => {\n if (isPolarArrayContent(c)) {\n c.center.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.center.y, setValue: (v) => update((c) => {\n if (isPolarArrayContent(c)) {\n c.center.y = v;\n }\n }) })\n }\n }\n ),\n rowCount: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.rowCount, setValue: (v) => update((c) => {\n if (isPolarArrayContent(c)) {\n c.rowCount = v;\n }\n }) }),\n itemCount: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.itemCount, setValue: (v) => update((c) => {\n if (isPolarArrayContent(c)) {\n c.itemCount = v;\n }\n }) }),\n rowSpacing: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.rowSpacing, setValue: (v) => update((c) => {\n if (isPolarArrayContent(c)) {\n c.rowSpacing = v;\n }\n }) }),\n itemAngle: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.itemAngle, setValue: (v) => update((c) => {\n if (isPolarArrayContent(c)) {\n c.itemAngle = v;\n }\n }) }),\n ...ctx.getVariableValuesContentPropertyPanel(content, ctx.getContainerVariableNames(content), update)\n };\n },\n isValid: (c, p) => ctx.validate(c, PolarArrayContent, p),\n getRefIds\n };\n}\nfunction isPolarArrayContent(content) {\n return content.type === "polar array";\n}\nfunction getCommand(ctx) {\n function contentSelectable(content, contents) {\n return ctx.contentIsDeletable(content, contents);\n }\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("circle", { cx: "30", cy: "22", r: "12", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "67", cy: "23", r: "12", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "82", cy: "53", r: "12", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "67", cy: "81", r: "12", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "28", cy: "79", r: "12", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "13", cy: "50", r: "12", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "create polar array",\n useCommand({ onEnd, type, scale, contents }) {\n let message = "";\n if (type) {\n message = "specify target point";\n }\n const { input, setInputPosition, cursorPosition, setCursorPosition, resetInput } = ctx.useCursorInput(message);\n return {\n onStart(p) {\n resetInput();\n onEnd({\n updateContents: (contents2, selected) => {\n const target = contents2.filter((c, i) => c && ctx.isSelected([i], selected) && contentSelectable(c, contents2));\n const bounding = ctx.getContentsBounding(target, contents2);\n if (!bounding) return;\n const newContent = {\n type: "polar array",\n center: p,\n contents: target,\n rowCount: 1,\n rowSpacing: ctx.getTwoPointsDistance(bounding.end, bounding.start) * 1.5,\n itemCount: 6,\n itemAngle: 60\n };\n ctx.deleteSelectedContents(contents2, selected.map((c) => c[0]));\n contents2.push(newContent);\n setCursorPosition(void 0);\n }\n });\n },\n input,\n onMove(p, viewportPosition) {\n setInputPosition(viewportPosition || p);\n if (!type) {\n return;\n }\n setCursorPosition(p);\n },\n updateSelectedContent(content) {\n var _a, _b;\n if (cursorPosition) {\n const bounding = (_b = (_a = ctx.getContentModel(content)) == null ? void 0 : _a.getGeometries) == null ? void 0 : _b.call(_a, content, contents).bounding;\n if (!bounding) return {};\n const base = {\n x: ctx.getTwoNumberCenter(bounding.start.x, bounding.end.x),\n y: ctx.getTwoNumberCenter(bounding.start.y, bounding.end.y)\n };\n return {\n newContents: [\n {\n type: "polar array",\n center: cursorPosition,\n contents: [content],\n rowCount: 1,\n rowSpacing: ctx.getTwoPointsDistance(bounding.end, bounding.start) * 1.5,\n itemCount: 6,\n itemAngle: 60\n }\n ],\n assistentContents: [\n {\n type: "line",\n dashArray: [4 / scale],\n points: [base, cursorPosition]\n }\n ]\n };\n }\n return {};\n },\n reset: resetInput\n };\n },\n contentSelectable,\n icon\n };\n}\nexport {\n getCommand,\n getModel,\n isPolarArrayContent\n};\n','// dev/cad-editor/plugins/polygon.plugin.tsx\nfunction getModel(ctx) {\n const PolygonContent = ctx.and(ctx.BaseContent("polygon"), ctx.StrokeFields, ctx.FillFields, {\n points: [ctx.Position]\n });\n const getRefIds = (content) => ctx.getStrokeAndFillRefIds(content);\n const geometriesCache = new ctx.WeakmapValuesCache();\n function getPolygonGeometries(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return geometriesCache.get(content, refs, () => {\n const lines = Array.from(ctx.iteratePolygonLines(content.points));\n return {\n lines,\n points: content.points,\n bounding: ctx.getPointsBounding(content.points),\n renderingLines: ctx.dashedPolylineToLines(ctx.polygonToPolyline(content.points), content.dashArray),\n regions: ctx.hasFill(content) ? [\n {\n lines,\n points: content.points\n }\n ] : void 0\n };\n });\n }\n const React = ctx.React;\n return {\n type: "polygon",\n ...ctx.strokeModel,\n ...ctx.fillModel,\n move(content, offset) {\n for (const point of content.points) {\n ctx.movePoint(point, offset);\n }\n },\n rotate(content, center, angle) {\n for (const point of content.points) {\n ctx.rotatePoint(point, center, angle);\n }\n },\n scale(content, center, sx, sy) {\n for (const point of content.points) {\n ctx.scalePoint(point, center, sx, sy);\n }\n },\n skew(content, center, sx, sy) {\n for (const point of content.points) {\n ctx.skewPoint(point, center, sx, sy);\n }\n },\n mirror(content, line) {\n for (const point of content.points) {\n ctx.mirrorPoint(point, line);\n }\n },\n explode(content, contents) {\n const { lines } = getPolygonGeometries(content, contents);\n return lines.map((line) => ({ type: "line", points: line }));\n },\n break(content, intersectionPoints, contents) {\n const { lines } = getPolygonGeometries(content, contents);\n return ctx.breakPolyline(lines, intersectionPoints);\n },\n offset(content, point, distance, contents) {\n const { lines } = getPolygonGeometries(content, contents);\n if (!distance) {\n distance = Math.min(...lines.map((line) => ctx.getPointAndGeometryLineMinimumDistance(point, line)));\n }\n const index = ctx.getLinesOffsetDirection(point, lines);\n const points = ctx.getParallelPolylineByDistance(lines, distance, index);\n return ctx.trimOffsetResult(points.slice(0, points.length - 1), point, true, contents).map((p) => ctx.produce(content, (d) => {\n d.points = p;\n }));\n },\n render(content, renderCtx) {\n const { options, target } = ctx.getStrokeFillRenderOptionsFromRenderContext(content, renderCtx);\n return target.renderPolygon(content.points, options);\n },\n getOperatorRenderPosition(content) {\n return content.points[0];\n },\n getEditPoints(content) {\n return ctx.getEditPointsFromCache(content, () => ({ editPoints: ctx.getPolylineEditPoints(content, isPolygonContent, true) }));\n },\n getSnapPoints(content, contents) {\n return ctx.getSnapPointsFromCache(content, () => {\n const { points, lines } = getPolygonGeometries(content, contents);\n return [\n ...points.map((p) => ({ ...p, type: "endpoint" })),\n ...lines.map(([start, end]) => ({\n x: (start.x + end.x) / 2,\n y: (start.y + end.y) / 2,\n type: "midpoint"\n }))\n ];\n });\n },\n getGeometries: getPolygonGeometries,\n canSelectPart: true,\n propertyPanel(content, update, contents, { acquirePoint }) {\n return {\n points: /* @__PURE__ */ React.createElement(\n ctx.ArrayEditor,\n {\n inline: true,\n ...ctx.getArrayEditorProps((v) => v.points, { x: 0, y: 0 }, (v) => update((c) => {\n if (isPolygonContent(c)) {\n v(c);\n }\n })),\n items: content.points.map((f, i) => /* @__PURE__ */ React.createElement(\n ctx.ObjectEditor,\n {\n inline: true,\n properties: {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isPolygonContent(c)) {\n c.points[i].x = p.x;\n c.points[i].y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.x, setValue: (v) => update((c) => {\n if (isPolygonContent(c)) {\n c.points[i].x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.y, setValue: (v) => update((c) => {\n if (isPolygonContent(c)) {\n c.points[i].y = v;\n }\n }) })\n }\n }\n ))\n }\n ),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents),\n ...ctx.getFillContentPropertyPanel(content, update, contents)\n };\n },\n isValid: (c, p) => ctx.validate(c, PolygonContent, p),\n getRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n deleteRefId: ctx.deleteStrokeAndFillRefIds,\n isPointIn: (content, point) => ctx.pointInPolygon(point, content.points)\n };\n}\nfunction isPolygonContent(content) {\n return content.type === "polygon";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polygon", { points: "10,81 86,83 88,39 52,10 12,35", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "create polygon",\n useCommand({ onEnd, type, scale, strokeStyleId, fillStyleId }) {\n const [createType, setCreateType] = React.useState("point");\n const { polygon, onClick, onMove, input, startSetSides, startPosition, cursorPosition, reset } = ctx.usePolygonClickCreate(\n type === "create polygon",\n (c) => onEnd({\n updateContents: (contents) => contents.push({ points: c, strokeStyleId, fillStyleId, type: "polygon" })\n }),\n {\n toEdge: createType === "edge",\n setSidesKey: "S",\n switchTypeKey: "T",\n switchType: () => setCreateType(createType === "edge" ? "point" : "edge")\n }\n );\n const assistentContents = [];\n if (startPosition && cursorPosition) {\n assistentContents.push({ type: "line", points: [startPosition, cursorPosition], dashArray: [4 / scale] });\n }\n if (polygon) {\n assistentContents.push({ points: polygon, strokeStyleId, fillStyleId, type: "polygon" });\n }\n return {\n onStart: onClick,\n input,\n onMove,\n reset,\n subcommand: type === "create polygon" ? /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("button", { onClick: startSetSides, style: { position: "relative" } }, "set sides(S)"), /* @__PURE__ */ React.createElement("button", { onClick: () => setCreateType(createType === "edge" ? "point" : "edge"), style: { position: "relative" } }, createType, "(T)")) : void 0,\n assistentContents,\n lastPosition: startPosition\n };\n },\n selectCount: 0,\n hotkey: "POL",\n icon\n };\n}\nexport {\n getCommand,\n getModel,\n isPolygonContent\n};\n','// dev/cad-editor/plugins/circle-arc.plugin.tsx\nfunction isCircleContent(content) {\n return content.type === "circle";\n}\nfunction isArcContent(content) {\n return content.type === "arc";\n}\n\n// dev/cad-editor/plugins/radial-dimension.plugin.tsx\nfunction getModel(ctx) {\n const RadialDimensionReferenceContent = ctx.and(ctx.BaseContent("radial dimension reference"), ctx.StrokeFields, ctx.ArrowFields, ctx.RadialDimension, {\n ref: ctx.PartRef\n });\n const getRefIds = (content) => [...ctx.getStrokeRefIds(content), ...ctx.toRefId(content.ref.id, true)];\n const radialDimensionReferenceCache = new ctx.WeakmapValuesCache();\n function getRadialDimensionReferenceGeometriesFromCache(content, contents, patches) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return radialDimensionReferenceCache.get(content, refs, () => {\n var _a, _b;\n const target = ctx.getRefPart(content.ref, contents, contentSelectable, patches);\n if (target) {\n return ctx.getRadialDimensionGeometries(content, target, {\n arrowAngle: (_a = content.arrowAngle) != null ? _a : ctx.dimensionStyle.arrowAngle,\n arrowSize: (_b = content.arrowSize) != null ? _b : ctx.dimensionStyle.arrowSize,\n margin: ctx.dimensionStyle.margin\n }, getTextPosition);\n }\n return { lines: [], points: [], renderingLines: [] };\n });\n }\n const textPositionMap = new ctx.WeakmapCache2();\n function getTextPosition(content, circle) {\n return textPositionMap.get(content, circle, () => {\n return ctx.getRadialDimensionTextPosition(content, circle, ctx.dimensionStyle.margin, ctx.getTextSizeFromCache);\n });\n }\n const React = ctx.React;\n return {\n type: "radial dimension reference",\n ...ctx.strokeModel,\n ...ctx.arrowModel,\n move(content, offset) {\n ctx.movePoint(content.position, offset);\n },\n scale(content, center, sx, sy) {\n ctx.scalePoint(content.position, center, sx, sy);\n },\n skew(content, center, sx, sy) {\n ctx.skewPoint(content.position, center, sx, sy);\n },\n render(content, renderCtx) {\n const { options, contents, target, fillOptions, strokeColor } = ctx.getStrokeRenderOptionsFromRenderContext(content, renderCtx);\n const { regions, lines } = getRadialDimensionReferenceGeometriesFromCache(content, contents, renderCtx.patches);\n const children = [];\n for (const line of lines) {\n children.push(target.renderPolyline(line, options));\n }\n if (regions && regions.length > 0) {\n children.push(target.renderPolygon(regions[0].points, fillOptions));\n }\n const referenceTarget = ctx.getRefPart(content.ref, contents, contentSelectable, renderCtx.patches);\n if (referenceTarget) {\n const { textPosition, textRotation, text } = getTextPosition(content, referenceTarget);\n const textOptions = ctx.getTextStyleRenderOptionsFromRenderContext(strokeColor, renderCtx);\n children.push(target.renderGroup(\n [\n target.renderText(textPosition.x, textPosition.y, text, strokeColor, content.fontSize, content.fontFamily, textOptions)\n ],\n {\n rotation: textRotation,\n base: textPosition\n }\n ));\n }\n return target.renderGroup(children);\n },\n getEditPoints(content, contents) {\n return ctx.getEditPointsFromCache(content, () => {\n return {\n editPoints: [\n {\n x: content.position.x,\n y: content.position.y,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isRadialDimensionReferenceContent(c)) {\n return;\n }\n c.position.x += cursor.x - start.x;\n c.position.y += cursor.y - start.y;\n const target = ctx.getRefPart(content.ref, contents, contentSelectable);\n if (!target || ctx.getTwoPointsDistance(target, c.position) > target.r) {\n return;\n }\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [target, cursor] }] };\n }\n }\n ]\n };\n });\n },\n getGeometries: getRadialDimensionReferenceGeometriesFromCache,\n propertyPanel(content, update, contents, { acquirePoint, acquireContent }) {\n return {\n ref: [\n /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquireContent({ count: 1, part: true, selectable: (v) => contentSelectable(ctx.getContentByIndex(contents, v)) }, (r) => update((c) => {\n if (isRadialDimensionReferenceContent(c)) {\n c.ref = r[0];\n }\n })) }, "select"),\n typeof content.ref.id === "number" ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.ref.id, setValue: (v) => update((c) => {\n if (isRadialDimensionReferenceContent(c)) {\n c.ref.id = v;\n }\n }) }) : void 0,\n content.ref.partIndex !== void 0 ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.ref.partIndex, setValue: (v) => update((c) => {\n if (isRadialDimensionReferenceContent(c)) {\n c.ref.partIndex = v;\n }\n }) }) : void 0\n ],\n position: /* @__PURE__ */ React.createElement(\n ctx.ObjectEditor,\n {\n inline: true,\n properties: {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isRadialDimensionReferenceContent(c)) {\n c.position.x = p.x;\n c.position.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.position.x, setValue: (v) => update((c) => {\n if (isRadialDimensionReferenceContent(c)) {\n c.position.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.position.y, setValue: (v) => update((c) => {\n if (isRadialDimensionReferenceContent(c)) {\n c.position.y = v;\n }\n }) })\n }\n }\n ),\n text: [\n /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.text !== void 0, setValue: (v) => update((c) => {\n if (isRadialDimensionReferenceContent(c)) {\n c.text = v ? "" : void 0;\n }\n }) }),\n content.text !== void 0 ? /* @__PURE__ */ React.createElement(ctx.StringEditor, { value: content.text, setValue: (v) => update((c) => {\n if (isRadialDimensionReferenceContent(c)) {\n c.text = v;\n }\n }) }) : void 0\n ],\n fontSize: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.fontSize, setValue: (v) => update((c) => {\n if (isRadialDimensionReferenceContent(c)) {\n c.fontSize = v;\n }\n }) }),\n fontFamily: /* @__PURE__ */ React.createElement(ctx.StringEditor, { value: content.fontFamily, setValue: (v) => update((c) => {\n if (isRadialDimensionReferenceContent(c)) {\n c.fontFamily = v;\n }\n }) }),\n ...ctx.getArrowContentPropertyPanel(content, update),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents)\n };\n },\n isValid: (c, p) => ctx.validate(c, RadialDimensionReferenceContent, p),\n getRefIds,\n updateRefId(content, update) {\n const newRefId = update(content.ref.id);\n if (newRefId !== void 0) {\n content.ref.id = newRefId;\n }\n ctx.updateStrokeRefIds(content, update);\n },\n deleteRefId: ctx.deleteStrokeRefIds\n };\n}\nfunction isRadialDimensionReferenceContent(content) {\n return content.type === "radial dimension reference";\n}\nfunction contentSelectable(content) {\n return !!content && (isArcContent(content) || isCircleContent(content));\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("circle", { cx: "36", cy: "64", r: "31", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "36,64 90,9", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polygon", { points: "75,32 65,22 54,44", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }));\n return {\n name: "create radial dimension",\n selectCount: 1,\n selectType: "select part",\n icon,\n contentSelectable,\n useCommand({ onEnd, selected, type, strokeStyleId }) {\n const [result, setResult] = React.useState();\n const [text, setText] = React.useState();\n let message = "";\n if (type) {\n message = "input text";\n }\n const { input, clearText, setCursorPosition, setInputPosition, resetInput } = ctx.useCursorInput(message, type ? (e, text2) => {\n if (e.key === "Enter") {\n setText(text2);\n if (result) {\n setResult({ ...result, text: text2 });\n }\n clearText();\n }\n } : void 0);\n const reset = () => {\n setResult(void 0);\n resetInput();\n setText(void 0);\n };\n return {\n input,\n onStart() {\n if (result) {\n onEnd({\n updateContents: (draft) => {\n if (selected.length > 0 && type) {\n const { content, path } = selected[0];\n if (contentSelectable(content)) {\n result.ref = {\n id: path[0],\n partIndex: path[1]\n };\n }\n }\n draft.push({\n type: "radial dimension reference",\n position: result.position,\n fontSize: result.fontSize,\n fontFamily: result.fontFamily,\n ref: result.ref,\n text: result.text,\n strokeStyleId\n });\n },\n nextCommand: type\n });\n reset();\n }\n },\n onMove(p, viewportPosition) {\n setInputPosition(viewportPosition || p);\n setCursorPosition(p);\n if (selected.length > 0 && type) {\n const { content, path } = selected[0];\n if (contentSelectable(content)) {\n setResult({\n type: "radial dimension reference",\n position: p,\n fontSize: 16,\n fontFamily: "monospace",\n ref: {\n id: path[0],\n partIndex: path[1]\n },\n text,\n strokeStyleId\n });\n }\n }\n },\n assistentContents: result ? [result] : void 0,\n reset\n };\n }\n };\n}\nexport {\n getCommand,\n getModel,\n isRadialDimensionReferenceContent\n};\n','// dev/cad-editor/plugins/ray.plugin.tsx\nfunction getModel(ctx) {\n const RayContent = ctx.and(ctx.BaseContent("ray"), ctx.StrokeFields, ctx.Ray);\n const getRefIds = (content) => ctx.getStrokeRefIds(content);\n function getRayGeometries(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return ctx.getGeometriesFromCache(content, refs, () => {\n return {\n lines: [{ type: "ray", line: content }],\n renderingLines: []\n };\n });\n }\n const React = ctx.React;\n const rayModel = {\n type: "ray",\n ...ctx.strokeModel,\n move(content, offset) {\n ctx.movePoint(content, offset);\n },\n rotate(content, center, angle) {\n ctx.rotatePoint(content, center, angle);\n content.angle += angle;\n },\n scale(content, center, sx, sy) {\n ctx.scalePoint(content, center, sx, sy);\n },\n mirror(content, line, angle) {\n ctx.mirrorPoint(content, line);\n content.angle = 2 * angle - content.angle;\n },\n break(content, intersectionPoints, contents) {\n return ctx.breakGeometryLines(getRayGeometries(content, contents).lines, intersectionPoints).flat().map((n) => ctx.geometryLineToContent(n));\n },\n offset(content, point, distance) {\n if (!distance) {\n distance = ctx.getPointAndRayNearestPointAndDistance(point, content).distance;\n }\n const index = ctx.pointSideToIndex(ctx.getPointSideOfGeometryLine(point, { type: "ray", line: content }));\n return ctx.getParallelRaysByDistance(content, distance)[index];\n },\n render(content, renderCtx) {\n const { options, target } = ctx.getStrokeRenderOptionsFromRenderContext(content, renderCtx);\n return target.renderRay(content.x, content.y, content.angle, { ...options, bidirectional: content.bidirectional });\n },\n getEditPoints(content) {\n return ctx.getEditPointsFromCache(content, () => ({\n editPoints: [{\n x: content.x,\n y: content.y,\n cursor: "move",\n type: "move",\n update(c, { cursor, start, scale }) {\n if (!isRayContent(c)) {\n return;\n }\n c.x += cursor.x - start.x;\n c.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [content, cursor] }] };\n }\n }]\n }));\n },\n getSnapPoints(content) {\n return ctx.getSnapPointsFromCache(content, () => {\n return [{ x: content.x, y: content.y, type: "endpoint" }];\n });\n },\n getGeometries: getRayGeometries,\n propertyPanel(content, update, contents, { acquirePoint }) {\n return {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isRayContent(c)) {\n c.x = p.x;\n c.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.x, setValue: (v) => update((c) => {\n if (isRayContent(c)) {\n c.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.y, setValue: (v) => update((c) => {\n if (isRayContent(c)) {\n c.y = v;\n }\n }) }),\n angle: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.angle, setValue: (v) => update((c) => {\n if (isRayContent(c)) {\n c.angle = v;\n }\n }) }),\n bidirectional: /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.bidirectional || false, setValue: (v) => update((c) => {\n if (isRayContent(c)) {\n c.bidirectional = v;\n }\n }) }),\n reversed: /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.reversed || false, setValue: (v) => update((c) => {\n if (isRayContent(c)) {\n c.reversed = v;\n }\n }) }),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents)\n };\n },\n isValid: (c, p) => ctx.validate(c, RayContent, p),\n getRefIds,\n updateRefId: ctx.updateStrokeRefIds,\n deleteRefId: ctx.deleteStrokeRefIds,\n reverse: (content) => ({ ...content, ...ctx.reverseRay(content) })\n };\n return rayModel;\n}\nfunction isRayContent(content) {\n return content.type === "ray";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("circle", { cx: "10", cy: "87", r: "12", strokeWidth: "0", vectorEffect: "non-scaling-stroke", fill: "currentColor", stroke: "#000000" }), /* @__PURE__ */ React.createElement("polyline", { points: "10,87 87,9", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "create ray",\n useCommand({ onEnd, type, strokeStyleId }) {\n const { line, onClick, onMove, input, lastPosition, reset } = ctx.useLineClickCreate(\n type === "create ray",\n (c) => onEnd({\n updateContents: (contents) => contents.push({ type: "ray", x: c[0].x, y: c[0].y, angle: ctx.radianToAngle(ctx.getTwoPointsRadian(c[1], c[0])), strokeStyleId })\n }),\n { once: true }\n );\n const assistentContents = [];\n if (line && line.length > 1) {\n const start = line[line.length - 2];\n const end = line[line.length - 1];\n const angle = ctx.radianToAngle(ctx.getTwoPointsRadian(end, start));\n assistentContents.push({ type: "ray", x: start.x, y: start.y, angle, strokeStyleId });\n }\n return {\n onStart: onClick,\n input,\n onMove,\n assistentContents,\n lastPosition,\n reset\n };\n },\n selectCount: 0,\n icon\n };\n}\nexport {\n getCommand,\n getModel,\n isRayContent\n};\n','// dev/cad-editor/plugins/rect-array.plugin.tsx\nfunction getModel(ctx) {\n const RectArrayContent = ctx.and(ctx.BaseContent("rect array"), ctx.ContainerFields, {\n rowCount: ctx.number,\n rowSpacing: ctx.number,\n columnCount: ctx.number,\n columnSpacing: ctx.number\n });\n const getRefIds = (content) => ctx.toRefIds(content.contents);\n const getAllContentsFromCache = (content) => {\n return ctx.allContentsCache.get(content, () => {\n const result = [];\n for (let i = 0; i < content.columnCount; i++) {\n const x = i * content.columnSpacing;\n for (let j = 0; j < content.rowCount; j++) {\n const y = j * content.rowSpacing;\n if (x === 0 && y === 0) {\n result.push(...content.contents);\n } else {\n result.push(...content.contents.map((c) => {\n var _a;\n if (!c) return;\n const move = (_a = ctx.getContentModel(c)) == null ? void 0 : _a.move;\n if (!move) return;\n return ctx.produce(c, (draft) => {\n move(draft, { x, y });\n });\n }));\n }\n }\n }\n return result;\n });\n };\n const getGeometries = (content, contents) => ctx.getContentsGeometries(content, contents, getRefIds, [content], getAllContentsFromCache);\n const React = ctx.React;\n return {\n type: "rect array",\n ...ctx.containerModel,\n move: ctx.getContainerMove,\n rotate(content, center, angle, contents) {\n const x = content.columnSpacing * (content.columnCount - 1) * 0.5;\n const y = content.rowSpacing * (content.rowCount - 1) * 0.5;\n content.contents.forEach((c) => {\n var _a, _b, _c;\n if (!c) return;\n const m = ctx.getContentModel(c);\n if (!m) return;\n (_a = m.move) == null ? void 0 : _a.call(m, c, { x, y });\n (_b = m.rotate) == null ? void 0 : _b.call(m, c, center, angle, contents);\n (_c = m.move) == null ? void 0 : _c.call(m, c, { x: -x, y: -y });\n });\n },\n scale(content, center, sx, sy, contents) {\n ctx.getContainerScale(content, center, sx, sy, contents);\n content.rowSpacing *= sx;\n content.columnSpacing *= sy;\n },\n explode(content) {\n return ctx.getContentsExplode(getAllContentsFromCache(content));\n },\n break(content, points, contents) {\n return ctx.getContentsBreak(getAllContentsFromCache(content), points, contents);\n },\n render(content, renderCtx) {\n return renderCtx.target.renderGroup(ctx.renderContainerChildren({ contents: getAllContentsFromCache(content), variableValues: content.variableValues }, renderCtx));\n },\n getEditPoints(content, contents) {\n return ctx.getEditPointsFromCache(content, () => {\n const bounding = ctx.getContentsBounding(content.contents, contents);\n if (!bounding) {\n return { editPoints: [] };\n }\n const base = {\n x: ctx.getTwoNumberCenter(bounding.start.x, bounding.end.x),\n y: ctx.getTwoNumberCenter(bounding.start.y, bounding.end.y)\n };\n return {\n editPoints: [\n {\n ...base,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isRectArrayContent(c)) {\n return;\n }\n ctx.getContainerMove(c, {\n x: cursor.x - start.x,\n y: cursor.y - start.y\n });\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n },\n {\n x: base.x + content.columnSpacing,\n y: base.y,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isRectArrayContent(c)) {\n return;\n }\n c.columnSpacing = cursor.x - base.x;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n },\n {\n x: base.x,\n y: base.y + content.rowSpacing,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isRectArrayContent(c)) {\n return;\n }\n c.rowSpacing = cursor.y - base.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n },\n {\n x: base.x + content.columnSpacing * (content.columnCount - 1),\n y: base.y,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isRectArrayContent(c)) {\n return;\n }\n let columnCount = Math.round((cursor.x - base.x) / content.columnSpacing);\n if (columnCount < 0) {\n columnCount = -columnCount;\n c.columnSpacing = -content.columnSpacing;\n }\n c.columnCount = columnCount + 1;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n },\n {\n x: base.x,\n y: base.y + content.rowSpacing * (content.rowCount - 1),\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isRectArrayContent(c)) {\n return;\n }\n let rowCount = Math.round((cursor.y - base.y) / content.rowSpacing);\n if (rowCount < 0) {\n rowCount = -rowCount;\n c.rowSpacing = -content.rowSpacing;\n }\n c.rowCount = rowCount + 1;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n },\n {\n x: base.x + content.columnSpacing * (content.columnCount - 1),\n y: base.y + content.rowSpacing * (content.rowCount - 1),\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isRectArrayContent(c)) {\n return;\n }\n let rowCount = Math.round((cursor.y - base.y) / content.rowSpacing);\n if (rowCount < 0) {\n rowCount = -rowCount;\n c.rowSpacing = -content.rowSpacing;\n }\n let columnCount = Math.round((cursor.x - base.x) / content.columnSpacing);\n if (columnCount < 0) {\n columnCount = -columnCount;\n c.columnSpacing = -content.columnSpacing;\n }\n c.rowCount = rowCount + 1;\n c.columnCount = columnCount + 1;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n }\n ]\n };\n });\n },\n getSnapPoints(content, contents) {\n return ctx.getContentsSnapPoints(content, contents, getAllContentsFromCache);\n },\n getGeometries,\n propertyPanel(content, update) {\n return {\n rowCount: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.rowCount, setValue: (v) => update((c) => {\n if (isRectArrayContent(c)) {\n c.rowCount = v;\n }\n }) }),\n columnCount: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.columnCount, setValue: (v) => update((c) => {\n if (isRectArrayContent(c)) {\n c.columnCount = v;\n }\n }) }),\n rowSpacing: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.rowSpacing, setValue: (v) => update((c) => {\n if (isRectArrayContent(c)) {\n c.rowSpacing = v;\n }\n }) }),\n columnSpacing: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.columnSpacing, setValue: (v) => update((c) => {\n if (isRectArrayContent(c)) {\n c.columnSpacing = v;\n }\n }) }),\n ...ctx.getVariableValuesContentPropertyPanel(content, ctx.getContainerVariableNames(content), update)\n };\n },\n isValid: (c, p) => ctx.validate(c, RectArrayContent, p),\n getRefIds\n };\n}\nfunction isRectArrayContent(content) {\n return content.type === "rect array";\n}\nfunction getCommand(ctx) {\n function contentSelectable(content, contents) {\n return ctx.contentIsDeletable(content, contents);\n }\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("rect", { x: "3", y: "70", width: "40", height: "27", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("rect", { x: "58", y: "70", width: "40", height: "27", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("rect", { x: "3", y: "35", width: "40", height: "27", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("rect", { x: "58", y: "35", width: "40", height: "27", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("rect", { x: "3", y: "0", width: "40", height: "27", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("rect", { x: "58", y: "1", width: "40", height: "27", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "create rect array",\n execute({ contents, selected }) {\n const target = contents.filter((c, i) => c && ctx.isSelected([i], selected) && contentSelectable(c, contents));\n const bounding = ctx.getContentsBounding(target, contents);\n if (!bounding) return;\n const size = ctx.getTwoPointsFormRegionSize(bounding);\n const newContent = {\n type: "rect array",\n contents: target,\n rowCount: 3,\n rowSpacing: -size.height * 1.5,\n columnCount: 4,\n columnSpacing: size.width * 1.5\n };\n ctx.deleteSelectedContents(contents, selected.map((c) => c[0]));\n contents.push(newContent);\n },\n contentSelectable,\n icon\n };\n}\nexport {\n getCommand,\n getModel,\n isRectArrayContent\n};\n','// dev/cad-editor/plugins/rect.plugin.tsx\nfunction getModel(ctx) {\n const RectContent = ctx.and(ctx.BaseContent("rect"), ctx.StrokeFields, ctx.FillFields, ctx.Region, {\n angle: ctx.number\n });\n const getRefIds = (content) => ctx.getStrokeAndFillRefIds(content);\n const geometriesCache = new ctx.WeakmapValuesCache();\n function getRectGeometries(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return geometriesCache.get(content, refs, () => {\n const points = ctx.getPolygonFromRegion(content).map((p) => ctx.rotatePositionByCenter(p, content, -content.angle));\n const lines = Array.from(ctx.iteratePolygonLines(points));\n return {\n lines,\n points,\n midpoints: lines.map((line) => ctx.getTwoPointCenter(...line)),\n bounding: ctx.getPointsBounding(points),\n renderingLines: ctx.dashedPolylineToLines(ctx.polygonToPolyline(points), content.dashArray),\n regions: ctx.hasFill(content) ? [\n {\n lines,\n points\n }\n ] : void 0\n };\n });\n }\n const React = ctx.React;\n return {\n type: "rect",\n ...ctx.strokeModel,\n ...ctx.fillModel,\n move(content, offset) {\n ctx.movePoint(content, offset);\n },\n rotate(content, center, angle) {\n ctx.rotatePoint(content, center, angle);\n content.angle += angle;\n },\n scale(content, center, sx, sy, contents) {\n if (content.angle) {\n const points = ctx.produce(getRectGeometries(content, contents).points, (draft) => {\n for (const p of draft) {\n ctx.scalePoint(p, center, sx, sy);\n }\n });\n return { ...content, points, type: "polygon" };\n }\n ctx.scalePoint(content, center, sx, sy);\n content.width *= sx;\n content.height *= sy;\n return;\n },\n skew(content, center, sx, sy, contents) {\n const points = ctx.produce(getRectGeometries(content, contents).points, (draft) => {\n for (const p of draft) {\n ctx.skewPoint(p, center, sx, sy);\n }\n });\n return { ...content, points, type: "polygon" };\n },\n explode(content, contents) {\n const { lines } = getRectGeometries(content, contents);\n return lines.map((line) => ({ type: "line", points: line }));\n },\n break(content, intersectionPoints, contents) {\n const { lines } = getRectGeometries(content, contents);\n return ctx.breakPolyline(lines, intersectionPoints);\n },\n mirror(content, line, angle) {\n ctx.mirrorPoint(content, line);\n content.angle = 2 * angle - content.angle;\n },\n offset(content, point, distance, contents) {\n var _a;\n if (!distance) {\n distance = Math.min(...getRectGeometries(content, contents).lines.map((line) => ctx.getPointAndGeometryLineMinimumDistance(point, line)));\n }\n distance *= 2 * (((_a = this.isPointIn) == null ? void 0 : _a.call(this, content, point, contents)) ? -1 : 1);\n return ctx.produce(content, (d) => {\n d.width += distance;\n d.height += distance;\n });\n },\n render(content, renderCtx) {\n const { options, dashed, target } = ctx.getStrokeFillRenderOptionsFromRenderContext(content, renderCtx);\n if (dashed) {\n const { points } = getRectGeometries(content, renderCtx.contents);\n return target.renderPolygon(points, options);\n }\n return target.renderRect(content.x - content.width / 2, content.y - content.height / 2, content.width, content.height, { ...options, angle: content.angle });\n },\n getOperatorRenderPosition(content, contents) {\n const { points } = getRectGeometries(content, contents);\n return points[0];\n },\n getEditPoints(content, contents) {\n return ctx.getEditPointsFromCache(content, () => {\n const { points, midpoints } = getRectGeometries(content, contents);\n return {\n editPoints: [\n { x: content.x, y: content.y, direction: "center" },\n { ...points[0], direction: "left-top" },\n { ...points[1], direction: "right-top" },\n { ...points[2], direction: "right-bottom" },\n { ...points[3], direction: "left-bottom" },\n { ...midpoints[0], direction: "top" },\n { ...midpoints[1], direction: "right" },\n { ...midpoints[2], direction: "bottom" },\n { ...midpoints[3] || midpoints[1], direction: "left" }\n ].map((p, i) => ({\n x: p.x,\n y: p.y,\n type: i === 0 ? "move" : void 0,\n cursor: ctx.getResizeCursor(content.angle, p.direction),\n update(c, { cursor, start, scale }) {\n if (!isRectContent(c)) {\n return;\n }\n const offset = ctx.getResizeOffset(start, cursor, p.direction, -ctx.angleToRadian(content.angle));\n if (!offset) {\n return;\n }\n c.x += offset.x + offset.width / 2;\n c.y += offset.y + offset.height / 2;\n c.width = Math.abs(c.width + offset.width);\n c.height = Math.abs(c.height + offset.height);\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n }))\n };\n });\n },\n getSnapPoints(content, contents) {\n return ctx.getSnapPointsFromCache(content, () => {\n const { points, midpoints } = getRectGeometries(content, contents);\n return [\n { x: content.x, y: content.y, type: "center" },\n ...points.map((p) => ({ ...p, type: "endpoint" })),\n ...midpoints.map((p) => ({ ...p, type: "midpoint" }))\n ];\n });\n },\n getGeometries: getRectGeometries,\n canSelectPart: true,\n propertyPanel(content, update, contents, { acquirePoint }) {\n return {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isRectContent(c)) {\n c.x = p.x;\n c.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.x, setValue: (v) => update((c) => {\n if (isRectContent(c)) {\n c.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.y, setValue: (v) => update((c) => {\n if (isRectContent(c)) {\n c.y = v;\n }\n }) }),\n width: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.width, setValue: (v) => update((c) => {\n if (isRectContent(c)) {\n c.width = v;\n }\n }) }),\n height: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.height, setValue: (v) => update((c) => {\n if (isRectContent(c)) {\n c.height = v;\n }\n }) }),\n angle: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.angle, setValue: (v) => update((c) => {\n if (isRectContent(c)) {\n c.angle = v;\n }\n }) }),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents),\n ...ctx.getFillContentPropertyPanel(content, update, contents)\n };\n },\n isValid: (c, p) => ctx.validate(c, RectContent, p),\n getRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n deleteRefId: ctx.deleteStrokeAndFillRefIds,\n isPointIn: (content, point, contents) => ctx.pointInPolygon(point, getRectGeometries(content, contents).points),\n getArea: (content) => content.width * content.height\n };\n}\nfunction isRectContent(content) {\n return content.type === "rect";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("rect", { x: "11", y: "26", width: "79", height: "48", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "create rect",\n icon,\n useCommand({ onEnd, type, strokeStyleId, fillStyleId }) {\n const { line, onClick, onMove, input, lastPosition, reset } = ctx.useLineClickCreate(\n type === "create rect",\n (c) => onEnd({\n updateContents: (contents) => contents.push({\n type: "rect",\n x: (c[0].x + c[1].x) / 2,\n y: (c[0].y + c[1].y) / 2,\n width: Math.abs(c[0].x - c[1].x),\n height: Math.abs(c[0].y - c[1].y),\n angle: 0,\n strokeStyleId,\n fillStyleId\n })\n }),\n {\n once: true\n }\n );\n const assistentContents = [];\n if (line) {\n assistentContents.push({\n type: "rect",\n x: (line[0].x + line[1].x) / 2,\n y: (line[0].y + line[1].y) / 2,\n width: Math.abs(line[0].x - line[1].x),\n height: Math.abs(line[0].y - line[1].y),\n angle: 0,\n strokeStyleId,\n fillStyleId\n });\n }\n return {\n onStart: onClick,\n input,\n onMove,\n assistentContents,\n lastPosition,\n reset\n };\n },\n selectCount: 0,\n hotkey: "REC"\n };\n}\nexport {\n getCommand,\n getModel,\n isRectContent\n};\n','// dev/cad-editor/plugins/regular-polygon.plugin.tsx\nfunction getModel(ctx) {\n const RegularPolygonContent = ctx.and(ctx.BaseContent("regular polygon"), ctx.StrokeFields, ctx.FillFields, ctx.Position, {\n radius: ctx.number,\n count: ctx.number,\n angle: ctx.number\n });\n const getRefIds = (content) => ctx.getStrokeAndFillRefIds(content);\n const geometriesCache = new ctx.WeakmapValuesCache();\n function getRegularPolygonGeometriesFromCache(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return geometriesCache.get(content, refs, () => {\n var _a;\n const angle = -((_a = content.angle) != null ? _a : 0);\n const p0 = ctx.rotatePositionByCenter({ x: content.x + content.radius, y: content.y }, content, angle);\n const points = [];\n for (let i = 0; i < content.count; i++) {\n points.push(ctx.rotatePositionByCenter(p0, content, 360 / content.count * i));\n }\n const lines = Array.from(ctx.iteratePolygonLines(points));\n return {\n points,\n lines,\n bounding: ctx.getPointsBounding(points),\n regions: ctx.hasFill(content) ? [\n {\n lines,\n points\n }\n ] : void 0,\n renderingLines: ctx.dashedPolylineToLines(ctx.polygonToPolyline(points), content.dashArray)\n };\n });\n }\n const React = ctx.React;\n return {\n type: "regular polygon",\n ...ctx.strokeModel,\n ...ctx.fillModel,\n move(content, offset) {\n ctx.movePoint(content, offset);\n },\n scale(content, center, sx, sy, contents) {\n if (sx !== sy) {\n const points = ctx.produce(getRegularPolygonGeometriesFromCache(content, contents).points, (draft) => {\n for (const p of draft) {\n ctx.scalePoint(p, center, sx, sy);\n }\n });\n return { ...content, points, type: "polygon" };\n }\n ctx.scalePoint(content, center, sx, sy);\n content.radius *= sx;\n return;\n },\n skew(content, center, sx, sy, contents) {\n const points = ctx.produce(getRegularPolygonGeometriesFromCache(content, contents).points, (draft) => {\n for (const p of draft) {\n ctx.skewPoint(p, center, sx, sy);\n }\n });\n return { ...content, points, type: "polygon" };\n },\n offset(content, point, distance, contents) {\n var _a;\n if (!distance) {\n distance = Math.min(...getRegularPolygonGeometriesFromCache(content, contents).lines.map((line) => ctx.getPointAndGeometryLineMinimumDistance(point, line)));\n }\n distance *= ((_a = this.isPointIn) == null ? void 0 : _a.call(this, content, point, contents)) ? -1 : 1;\n const radius = distance / Math.cos(Math.PI / content.count);\n return ctx.produce(content, (d) => {\n d.radius += radius;\n });\n },\n render(content, renderCtx) {\n const { options, target } = ctx.getStrokeFillRenderOptionsFromRenderContext(content, renderCtx);\n const { points } = getRegularPolygonGeometriesFromCache(content, renderCtx.contents);\n return target.renderPolygon(points, options);\n },\n getEditPoints(content, contents) {\n return ctx.getEditPointsFromCache(content, () => {\n const { points } = getRegularPolygonGeometriesFromCache(content, contents);\n return {\n editPoints: [\n {\n ...content,\n cursor: "move",\n type: "move",\n update(c, { cursor, start, scale }) {\n if (!isRegularPolygonContent(c)) {\n return;\n }\n c.x += cursor.x - start.x;\n c.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n },\n ...points.map((p) => ({\n x: p.x,\n y: p.y,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isRegularPolygonContent(c)) {\n return;\n }\n c.radius = ctx.getTwoPointsDistance(cursor, c);\n c.angle = ctx.radianToAngle(ctx.getTwoPointsRadian(cursor, c));\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n }))\n ]\n };\n });\n },\n getGeometries: getRegularPolygonGeometriesFromCache,\n propertyPanel(content, update, contents, { acquirePoint }) {\n return {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isRegularPolygonContent(c)) {\n c.x = p.x;\n c.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.x, setValue: (v) => update((c) => {\n if (isRegularPolygonContent(c)) {\n c.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.y, setValue: (v) => update((c) => {\n if (isRegularPolygonContent(c)) {\n c.y = v;\n }\n }) }),\n radius: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.radius, setValue: (v) => update((c) => {\n if (isRegularPolygonContent(c)) {\n c.radius = v;\n }\n }) }),\n count: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.count, setValue: (v) => update((c) => {\n if (isRegularPolygonContent(c)) {\n c.count = v;\n }\n }) }),\n angle: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.angle, setValue: (v) => update((c) => {\n if (isRegularPolygonContent(c)) {\n c.angle = v;\n }\n }) }),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents),\n ...ctx.getFillContentPropertyPanel(content, update, contents)\n };\n },\n canSelectPart: true,\n isValid: (c, p) => ctx.validate(c, RegularPolygonContent, p),\n getRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n deleteRefId: ctx.deleteStrokeAndFillRefIds,\n isPointIn: (content, point, contents) => ctx.pointInPolygon(point, getRegularPolygonGeometriesFromCache(content, contents).points)\n };\n}\nfunction isRegularPolygonContent(content) {\n return content.type === "regular polygon";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polygon", { points: "91,40 53,7 10,33 22,82 72,85", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "create regular polygon",\n icon,\n useCommand({ onEnd, type, strokeStyleId, fillStyleId }) {\n const { line, onClick, onMove, input, lastPosition, reset } = ctx.useLineClickCreate(\n type === "create regular polygon",\n ([p0, p1]) => onEnd({\n updateContents: (contents) => {\n contents.push({\n type: "regular polygon",\n x: p0.x,\n y: p0.y,\n radius: ctx.getTwoPointsDistance(p0, p1),\n count: 5,\n angle: ctx.radianToAngle(ctx.getTwoPointsRadian(p1, p0)),\n strokeStyleId,\n fillStyleId\n });\n }\n }),\n {\n once: true\n }\n );\n const assistentContents = [];\n if (line) {\n const [p0, p1] = line;\n assistentContents.push({\n type: "regular polygon",\n x: p0.x,\n y: p0.y,\n radius: ctx.getTwoPointsDistance(p0, p1),\n count: 5,\n angle: ctx.radianToAngle(ctx.getTwoPointsRadian(p1, p0)),\n strokeStyleId,\n fillStyleId\n });\n }\n return {\n onStart: onClick,\n input,\n onMove,\n assistentContents,\n lastPosition,\n reset\n };\n },\n selectCount: 0\n };\n}\nexport {\n getCommand,\n getModel,\n isRegularPolygonContent\n};\n','// dev/cad-editor/plugins/reverse.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "1,71 56,7", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "62,0 54,18 46,11", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "97,27 91,34", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "84,42 78,50", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "71,57 64,65", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "58,72 51,80", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "45,87 42,90", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "36,97 45,79 53,86", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }));\n return {\n name: "reverse",\n execute({ contents, selected }) {\n contents.forEach((content, index) => {\n var _a, _b, _c, _d;\n if (content && ctx.isSelected([index], selected) && ((_b = (_a = this.contentSelectable) == null ? void 0 : _a.call(this, content, contents)) != null ? _b : true)) {\n const result = (_d = (_c = ctx.getContentModel(content)) == null ? void 0 : _c.reverse) == null ? void 0 : _d.call(_c, content, contents);\n if (result) {\n contents[index] = result;\n }\n }\n });\n },\n contentSelectable(content) {\n var _a;\n return !content.readonly && ((_a = ctx.getContentModel(content)) == null ? void 0 : _a.reverse) !== void 0;\n },\n icon\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/ring.plugin.tsx\nfunction getModel(ctx) {\n const RingContent = ctx.and(ctx.BaseContent("ring"), ctx.StrokeFields, ctx.FillFields, ctx.AngleDeltaFields, ctx.Position, {\n outerRadius: ctx.number,\n innerRadius: ctx.number\n });\n const getRefIds = (content) => ctx.getStrokeAndFillRefIds(content);\n function getRingGeometriesFromCache(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return ctx.getGeometriesFromCache(content, refs, () => {\n var _a;\n const angleDelta = (_a = content.angleDelta) != null ? _a : ctx.defaultAngleDelta;\n const arc1 = ctx.circleToArc({ ...content, r: content.outerRadius });\n const arc2 = ctx.circleToArc({ ...content, r: content.innerRadius });\n const points1 = ctx.arcToPolyline(arc1, angleDelta);\n const points2 = ctx.arcToPolyline(arc2, angleDelta);\n const lines = [{ type: "arc", curve: arc1 }, { type: "arc", curve: arc2 }];\n return {\n lines,\n bounding: ctx.getCircleBounding({ ...content, r: content.outerRadius }),\n regions: ctx.hasFill(content) ? [\n {\n lines: [lines[0]],\n points: points1,\n holesPoints: [points2],\n holes: [[lines[1]]]\n }\n ] : void 0,\n renderingLines: [\n ...ctx.dashedPolylineToLines(ctx.polygonToPolyline(points1), content.dashArray),\n ...ctx.dashedPolylineToLines(ctx.polygonToPolyline(points2), content.dashArray)\n ]\n };\n });\n }\n const React = ctx.React;\n return {\n type: "ring",\n ...ctx.strokeModel,\n ...ctx.fillModel,\n ...ctx.angleDeltaModel,\n move(content, offset) {\n ctx.movePoint(content, offset);\n },\n scale(content, center, sx, sy) {\n ctx.scalePoint(content, center, sx, sy);\n content.innerRadius *= sx;\n content.outerRadius *= sx;\n },\n render(content, renderCtx) {\n const { options, target } = ctx.getStrokeFillRenderOptionsFromRenderContext(content, renderCtx);\n const { renderingLines, regions } = getRingGeometriesFromCache(content, renderCtx.contents);\n if (regions) {\n return target.renderPath([regions[0].points, ...regions[0].holesPoints || []], options);\n }\n return target.renderGroup(renderingLines.map((r) => target.renderPolyline(r, options)));\n },\n getEditPoints(content) {\n return ctx.getEditPointsFromCache(content, () => {\n return {\n editPoints: [\n {\n ...content,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isRingContent(c)) {\n return;\n }\n c.x += cursor.x - start.x;\n c.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n }\n ]\n };\n });\n },\n getGeometries: getRingGeometriesFromCache,\n propertyPanel(content, update, contents, { acquirePoint }) {\n return {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isRingContent(c)) {\n c.x = p.x;\n c.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.x, setValue: (v) => update((c) => {\n if (isRingContent(c)) {\n c.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.y, setValue: (v) => update((c) => {\n if (isRingContent(c)) {\n c.y = v;\n }\n }) }),\n outerRadius: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.outerRadius, setValue: (v) => update((c) => {\n if (isRingContent(c)) {\n c.outerRadius = v;\n }\n }) }),\n innerRadius: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.innerRadius, setValue: (v) => update((c) => {\n if (isRingContent(c)) {\n c.innerRadius = v;\n }\n }) }),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents),\n ...ctx.getFillContentPropertyPanel(content, update, contents),\n ...ctx.getAngleDeltaContentPropertyPanel(content, update)\n };\n },\n isValid: (c, p) => ctx.validate(c, RingContent, p),\n getRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n deleteRefId: ctx.deleteStrokeAndFillRefIds\n };\n}\nfunction isRingContent(content) {\n return content.type === "ring";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "91,50 91,53 91,57 90,60 89,64 87,67 86,70 84,74 82,76 79,79 76,82 74,84 70,86 67,87 64,89 60,90 57,91 53,91 50,91 46,91 42,91 39,90 35,89 32,87 29,86 25,84 23,82 20,79 17,76 15,74 13,70 12,67 10,64 9,60 8,57 8,53 8,50 8,46 8,42 9,39 10,35 12,32 13,29 15,25 17,23 20,20 23,17 25,15 29,13 32,12 35,10 39,9 42,8 46,8 49,8 53,8 57,8 60,9 64,10 67,12 70,13 74,15 76,17 79,20 82,23 84,25 86,29 87,32 89,35 90,39 91,42 91,46 91,49", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "70,50 70,51 70,53 70,55 69,57 68,58 68,60 67,62 66,63 64,64 63,66 62,67 60,68 58,68 57,69 55,70 53,70 51,70 50,70 48,70 46,70 44,70 42,69 41,68 39,68 37,67 36,66 35,64 33,63 32,62 31,60 31,58 30,57 29,55 29,53 29,51 29,50 29,48 29,46 29,44 30,42 31,41 31,39 32,37 33,36 35,35 36,33 37,32 39,31 41,31 42,30 44,29 46,29 48,29 49,29 51,29 53,29 55,29 57,30 58,31 60,31 62,32 63,33 64,35 66,36 67,37 68,39 68,41 69,42 70,44 70,46 70,48 70,49", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "create ring",\n icon,\n useCommand({ onEnd, type, strokeStyleId, fillStyleId }) {\n const { line, onClick, onMove, input, lastPosition, reset } = ctx.useLineClickCreate(\n type === "create ring",\n (c) => onEnd({\n updateContents: (contents) => {\n const outerRadius = ctx.getTwoPointsDistance(c[0], c[1]);\n contents.push({\n type: "ring",\n x: c[0].x,\n y: c[0].y,\n outerRadius,\n innerRadius: outerRadius * 0.5,\n strokeStyleId,\n fillStyleId\n });\n }\n }),\n {\n once: true\n }\n );\n const assistentContents = [];\n if (line) {\n const outerRadius = ctx.getTwoPointsDistance(line[0], line[1]);\n assistentContents.push({\n type: "ring",\n x: line[0].x,\n y: line[0].y,\n outerRadius,\n innerRadius: outerRadius * 0.5,\n strokeStyleId,\n fillStyleId\n });\n }\n return {\n onStart: onClick,\n input,\n onMove,\n assistentContents,\n lastPosition,\n reset\n };\n },\n selectCount: 0\n };\n}\nexport {\n getCommand,\n getModel,\n isRingContent\n};\n','// dev/cad-editor/plugins/rotate.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polygon", { points: "5,66 66,66 66,94 5,94", strokeWidth: "5", strokeDasharray: "10", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("rect", { x: "35", y: "26", width: "61", height: "28", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor", transform: "rotate(56,66,40)" }));\n return {\n name: "rotate",\n icon,\n useCommand({ onEnd, transform, type, scale }) {\n const [changeOriginal, setChangeOriginal] = React.useState(true);\n const { offset, onStart, mask, center: startPosition, resetDragRotate } = ctx.useDragRotate(\n onEnd,\n {\n transform,\n transformOffset: (f) => f - 90,\n ignoreLeavingEvent: true\n }\n );\n let message = "";\n if (type) {\n message = startPosition ? "specify angle point" : "specify center point";\n }\n const { input, setInputPosition } = ctx.useCursorInput(message);\n let assistentContents;\n if (startPosition && (offset == null ? void 0 : offset.angle) !== void 0) {\n const r = ctx.getTwoPointsDistance(startPosition, offset);\n assistentContents = [\n {\n type: "line",\n dashArray: [4 / scale],\n points: [startPosition, offset]\n },\n {\n type: "arc",\n x: startPosition.x,\n y: startPosition.y,\n r,\n dashArray: [4 / scale],\n startAngle: offset.angle > 180 || offset.angle < 0 ? offset.angle : 0,\n endAngle: offset.angle > 180 || offset.angle < 0 ? 0 : offset.angle\n },\n {\n type: "line",\n dashArray: [4 / scale],\n points: [startPosition, { x: startPosition.x + r, y: startPosition.y }]\n }\n ];\n }\n return {\n onStart,\n mask,\n input,\n onMove(_, p) {\n setInputPosition(p);\n },\n reset: resetDragRotate,\n subcommand: type ? /* @__PURE__ */ React.createElement(\n "button",\n {\n onClick: (e) => {\n setChangeOriginal(!changeOriginal);\n e.stopPropagation();\n }\n },\n changeOriginal ? "create new(N)" : "change original(Y)"\n ) : void 0,\n updateSelectedContent(content, contents, selected) {\n if (startPosition && (offset == null ? void 0 : offset.angle) !== void 0) {\n const angle = offset.angle;\n if (!changeOriginal) {\n return {\n newContents: [\n ctx.produce(content, (d) => {\n var _a, _b;\n (_b = (_a = ctx.getContentModel(d)) == null ? void 0 : _a.rotate) == null ? void 0 : _b.call(_a, d, startPosition, angle, contents);\n })\n ]\n };\n }\n const [newContent, ...patches] = ctx.produceWithPatches(content, (draft) => {\n var _a, _b;\n (_b = (_a = ctx.getContentModel(content)) == null ? void 0 : _a.rotate) == null ? void 0 : _b.call(_a, draft, startPosition, angle, contents);\n });\n const assistentContents2 = ctx.updateReferencedContents(content, newContent, contents, selected);\n return {\n patches,\n assistentContents: assistentContents2\n };\n }\n return {};\n },\n assistentContents\n };\n },\n contentSelectable(content) {\n var _a;\n return !content.readonly && ((_a = ctx.getContentModel(content)) == null ? void 0 : _a.rotate) !== void 0;\n },\n hotkey: "RO"\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/rounded-rect.plugin.tsx\nfunction getModel(ctx) {\n const RoundedRectContent = ctx.and(ctx.BaseContent("rounded rect"), ctx.StrokeFields, ctx.FillFields, ctx.Region, ctx.AngleDeltaFields, {\n radius: ctx.number\n });\n const getRefIds = (content) => ctx.getStrokeAndFillRefIds(content);\n const geometriesCache = new ctx.WeakmapValuesCache();\n function getGeometries(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return geometriesCache.get(content, refs, () => {\n var _a;\n const rectPoints = [\n { x: content.x - content.width / 2, y: content.y - content.height / 2 },\n { x: content.x + content.width / 2, y: content.y - content.height / 2 },\n { x: content.x + content.width / 2, y: content.y + content.height / 2 },\n { x: content.x - content.width / 2, y: content.y + content.height / 2 }\n ];\n const points = ctx.getRoundedRectPoints(content, content.radius, (_a = content.angleDelta) != null ? _a : ctx.defaultAngleDelta);\n const lines = Array.from(ctx.iteratePolygonLines(points));\n const geometryLines = [\n { type: "arc", curve: { x: content.x - content.width / 2 + content.radius, y: content.y - content.height / 2 + content.radius, r: content.radius, startAngle: 180, endAngle: 270 } },\n [{ x: content.x - content.width / 2 + content.radius, y: content.y - content.height / 2 }, { x: content.x + content.width / 2 - content.radius, y: content.y - content.height / 2 }],\n { type: "arc", curve: { x: content.x + content.width / 2 - content.radius, y: content.y - content.height / 2 + content.radius, r: content.radius, startAngle: 270, endAngle: 360 } },\n [{ x: content.x + content.width / 2, y: content.y - content.height / 2 + content.radius }, { x: content.x + content.width / 2, y: content.y + content.height / 2 - content.radius }],\n { type: "arc", curve: { x: content.x + content.width / 2 - content.radius, y: content.y + content.height / 2 - content.radius, r: content.radius, startAngle: 0, endAngle: 90 } },\n [{ x: content.x + content.width / 2 - content.radius, y: content.y + content.height / 2 }, { x: content.x - content.width / 2 + content.radius, y: content.y + content.height / 2 }],\n { type: "arc", curve: { x: content.x - content.width / 2 + content.radius, y: content.y + content.height / 2 - content.radius, r: content.radius, startAngle: 80, endAngle: 180 } },\n [{ x: content.x - content.width / 2, y: content.y + content.height / 2 - content.radius }, { x: content.x - content.width / 2, y: content.y - content.height / 2 + content.radius }]\n ];\n return {\n lines: geometryLines,\n points: rectPoints,\n arcPoints: [\n { x: rectPoints[0].x + content.radius, y: rectPoints[0].y },\n { x: rectPoints[0].x, y: rectPoints[0].y + content.radius },\n { x: rectPoints[1].x - content.radius, y: rectPoints[1].y },\n { x: rectPoints[1].x, y: rectPoints[1].y + content.radius },\n { x: rectPoints[2].x - content.radius, y: rectPoints[2].y },\n { x: rectPoints[2].x, y: rectPoints[2].y - content.radius },\n { x: rectPoints[3].x + content.radius, y: rectPoints[3].y },\n { x: rectPoints[3].x, y: rectPoints[3].y - content.radius }\n ],\n bounding: ctx.getGeometryLinesBounding(geometryLines),\n renderingLines: ctx.dashedPolylineToLines(ctx.polygonToPolyline(points), content.dashArray),\n regions: ctx.hasFill(content) ? [\n {\n lines,\n points\n }\n ] : void 0\n };\n });\n }\n const React = ctx.React;\n return {\n type: "rounded rect",\n ...ctx.strokeModel,\n ...ctx.fillModel,\n ...ctx.angleDeltaModel,\n move(content, offset) {\n ctx.movePoint(content, offset);\n },\n scale(content, center, sx, sy) {\n ctx.scalePoint(content, center, sx, sy);\n content.width *= sx;\n content.height *= sy;\n content.radius *= sx;\n },\n offset(content, point, distance, contents) {\n var _a;\n if (!distance) {\n distance = Math.min(...getGeometries(content, contents).lines.map((line) => ctx.getPointAndGeometryLineMinimumDistance(point, line)));\n }\n distance *= ((_a = this.isPointIn) == null ? void 0 : _a.call(this, content, point, contents)) ? -2 : 2;\n return ctx.produce(content, (d) => {\n d.width += distance;\n d.height += distance;\n });\n },\n render(content, renderCtx) {\n const { options, target } = ctx.getStrokeFillRenderOptionsFromRenderContext(content, renderCtx);\n const { renderingLines } = getGeometries(content, renderCtx.contents);\n return target.renderPath(renderingLines, options);\n },\n renderIfSelected(content, { color, target, strokeWidth, contents }) {\n const { points, arcPoints } = getGeometries(content, contents);\n return target.renderGroup(points.map((p, i) => target.renderPolyline([arcPoints[2 * i], p, arcPoints[2 * i + 1]], { strokeColor: color, dashArray: [4], strokeWidth })));\n },\n getEditPoints(content, contents) {\n return ctx.getEditPointsFromCache(content, () => {\n const { points } = getGeometries(content, contents);\n return {\n editPoints: [\n { x: content.x, y: content.y, direction: "center" },\n { ...points[0], direction: "left-top" },\n { ...points[1], direction: "right-top" },\n { ...points[2], direction: "right-bottom" },\n { ...points[3], direction: "left-bottom" }\n ].map((p) => ({\n x: p.x,\n y: p.y,\n cursor: ctx.getResizeCursor(0, p.direction),\n update(c, { cursor, start, scale }) {\n if (!isRoundedRectContent(c)) {\n return;\n }\n const offset = ctx.getResizeOffset(start, cursor, p.direction);\n if (!offset) {\n return;\n }\n c.x += offset.x + offset.width / 2;\n c.y += offset.y + offset.height / 2;\n c.width += offset.width;\n c.height += offset.height;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n }))\n };\n });\n },\n getSnapPoints(content, contents) {\n return ctx.getSnapPointsFromCache(content, () => {\n const { points } = getGeometries(content, contents);\n return [\n { x: content.x, y: content.y, type: "center" },\n ...points.map((p) => ({ ...p, type: "endpoint" })),\n ...Array.from(ctx.iteratePolygonLines(points)).map(([start, end]) => ({\n x: (start.x + end.x) / 2,\n y: (start.y + end.y) / 2,\n type: "midpoint"\n }))\n ];\n });\n },\n getGeometries,\n canSelectPart: true,\n propertyPanel(content, update, contents, { acquirePoint }) {\n return {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isRoundedRectContent(c)) {\n c.x = p.x;\n c.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.x, setValue: (v) => update((c) => {\n if (isRoundedRectContent(c)) {\n c.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.y, setValue: (v) => update((c) => {\n if (isRoundedRectContent(c)) {\n c.y = v;\n }\n }) }),\n width: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.width, setValue: (v) => update((c) => {\n if (isRoundedRectContent(c)) {\n c.width = v;\n }\n }) }),\n height: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.height, setValue: (v) => update((c) => {\n if (isRoundedRectContent(c)) {\n c.height = v;\n }\n }) }),\n radius: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.radius, setValue: (v) => update((c) => {\n if (isRoundedRectContent(c)) {\n c.radius = v;\n }\n }) }),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents),\n ...ctx.getFillContentPropertyPanel(content, update, contents),\n ...ctx.getAngleDeltaContentPropertyPanel(content, update)\n };\n },\n isValid: (c, p) => ctx.validate(c, RoundedRectContent, p),\n getRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n deleteRefId: ctx.deleteStrokeAndFillRefIds,\n isPointIn: (content, point, contents) => ctx.pointInPolygon(point, getGeometries(content, contents).points)\n };\n}\nfunction isRoundedRectContent(content) {\n return content.type === "rounded rect";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("path", { d: "M 35 11 L 65 11 L 65 11 L 67 11 L 69 11 L 71 12 L 73 13 L 75 13 L 77 14 L 79 16 L 81 17 L 82 18 L 84 20 L 85 22 L 86 24 L 87 25 L 88 27 L 89 30 L 89 32 L 89 34 L 90 36 L 90 36 L 90 66 L 90 66 L 89 68 L 89 70 L 89 72 L 88 74 L 87 76 L 86 78 L 85 80 L 84 82 L 82 83 L 81 85 L 79 86 L 77 87 L 75 88 L 73 89 L 71 90 L 69 90 L 67 90 L 65 91 L 65 91 L 35 91 L 35 91 L 33 90 L 31 90 L 29 90 L 26 89 L 24 88 L 23 87 L 21 86 L 19 85 L 17 83 L 16 82 L 15 80 L 13 78 L 12 76 L 12 74 L 11 72 L 10 70 L 10 68 L 10 66 L 10 66 L 10 36 L 10 36 L 10 34 L 10 32 L 11 30 L 12 27 L 12 25 L 13 23 L 15 22 L 16 20 L 17 18 L 19 17 L 21 16 L 22 14 L 24 13 L 26 13 L 29 12 L 31 11 L 33 11 L 35 11", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor", fillRule: "evenodd" }));\n return {\n name: "create rounded rect",\n icon,\n useCommand({ onEnd, type, strokeStyleId, fillStyleId }) {\n const { line, onClick, onMove, input, lastPosition, reset } = ctx.useLineClickCreate(\n type === "create rounded rect",\n (c) => onEnd({\n updateContents: (contents) => {\n const width = Math.abs(c[0].x - c[1].x);\n const height = Math.abs(c[0].y - c[1].y);\n contents.push({\n type: "rounded rect",\n x: (c[0].x + c[1].x) / 2,\n y: (c[0].y + c[1].y) / 2,\n width,\n height,\n radius: Math.round(Math.min(width, height) / 4),\n strokeStyleId,\n fillStyleId\n });\n }\n }),\n {\n once: true\n }\n );\n const assistentContents = [];\n if (line) {\n const width = Math.abs(line[0].x - line[1].x);\n const height = Math.abs(line[0].y - line[1].y);\n assistentContents.push({\n type: "rounded rect",\n x: (line[0].x + line[1].x) / 2,\n y: (line[0].y + line[1].y) / 2,\n width,\n height,\n radius: Math.round(Math.min(width, height) / 4),\n strokeStyleId,\n fillStyleId\n });\n }\n return {\n onStart: onClick,\n input,\n onMove,\n assistentContents,\n lastPosition,\n reset\n };\n },\n selectCount: 0\n };\n}\nexport {\n getCommand,\n getModel,\n isRoundedRectContent\n};\n','// dev/cad-editor/plugins/scale.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polygon", { points: "12,11 91,11 91,90 12,90", strokeWidth: "5", strokeDasharray: "10", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("rect", { x: "40", y: "37", width: "42", height: "42", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", strokeOpacity: "1", fill: "none", stroke: "currentColor" }));\n return {\n name: "scale",\n useCommand({ onEnd, scale, type, selected, contents }) {\n const [data, setData] = React.useState();\n const [cursor, setCursor] = React.useState();\n let message = "";\n if (type) {\n message = data ? "specify scale" : "specify center point";\n }\n const { input, setInputPosition, resetInput, setCursorPosition } = ctx.useCursorInput(message, type ? (e, text) => {\n if (e.key === "Enter" && data) {\n const value = +text;\n if (!isNaN(value) && value > 0) {\n onEnd({\n updateContents(contents2, selected2) {\n contents2.forEach((content, index) => {\n var _a, _b;\n if (content && ctx.isSelected([index], selected2)) {\n const result = (_b = (_a = ctx.getContentModel(content)) == null ? void 0 : _a.scale) == null ? void 0 : _b.call(_a, content, data.center, value, value, contents2);\n if (result) {\n contents2[index] = result;\n }\n }\n });\n }\n });\n reset();\n }\n }\n } : void 0);\n const reset = () => {\n setData(void 0);\n setCursor(void 0);\n resetInput();\n };\n return {\n onStart(s) {\n var _a, _b, _c;\n if (!type) return;\n if (!data) {\n const boundings = [];\n for (const c of selected) {\n const bounding2 = (_c = (_b = (_a = ctx.getContentModel(c.content)) == null ? void 0 : _a.getGeometries) == null ? void 0 : _b.call(_a, c.content, contents)) == null ? void 0 : _c.bounding;\n if (bounding2) {\n boundings.push(bounding2);\n }\n }\n const bounding = ctx.mergeBoundings(boundings);\n if (bounding) {\n const size = ctx.getTwoPointsFormRegionSize(bounding);\n setData({ center: s, size: Math.max(size.width, size.height) });\n }\n } else {\n onEnd();\n reset();\n }\n },\n onMove(p, c) {\n if (!type) return;\n setInputPosition(c || p);\n setCursorPosition(c || p);\n if (data) {\n setCursor(p);\n }\n },\n reset,\n input,\n updateSelectedContent(content, contents2, selected2) {\n if (data && cursor) {\n const sx = ctx.getTwoNumbersDistance(cursor.x, data.center.x) / data.size;\n const sy = ctx.getTwoNumbersDistance(cursor.y, data.center.y) / data.size;\n if (!sx || !sy) {\n return {};\n }\n const [newContent, ...patches] = ctx.produceWithPatches(content, (draft) => {\n var _a, _b;\n return (_b = (_a = ctx.getContentModel(content)) == null ? void 0 : _a.scale) == null ? void 0 : _b.call(_a, draft, data.center, sx, sy, contents2);\n });\n const assistentContents = ctx.updateReferencedContents(content, newContent, contents2, selected2);\n return {\n patches,\n assistentContents\n };\n }\n return {};\n },\n assistentContents: data && cursor ? [\n {\n type: "line",\n dashArray: [4 / scale],\n points: [data.center, cursor]\n }\n ] : void 0\n };\n },\n contentSelectable(content) {\n var _a;\n return !content.readonly && ((_a = ctx.getContentModel(content)) == null ? void 0 : _a.scale) !== void 0;\n },\n icon\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/shortest.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "24,50 24,56 23,61 22,67 20,72 18,77 15,82 12,87 9,91 5,95 1,99 -3,102 -8,105 -13,108 -18,110 -23,112 -29,113 -34,114 -40,114 -46,114 -51,113 -57,112 -62,110 -67,108 -72,105 -77,102 -81,99 -85,95 -89,91 -92,87 -95,82 -98,77 -100,72 -102,67 -103,61 -104,56 -104,50 -104,44 -103,39 -102,33 -100,28 -98,23 -95,18 -92,13 -89,9 -85,5 -81,1 -77,-2 -72,-5 -67,-8 -62,-10 -57,-12 -51,-13 -46,-14 -40,-14 -34,-14 -29,-13 -23,-12 -18,-10 -13,-8 -8,-5 -3,-2 1,1 5,5 9,9 12,13 15,18 18,23 20,28 22,33 23,39 24,44 24,50", strokeWidth: "4", strokeDasharray: "10", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "204,50 204,56 203,61 202,67 200,72 198,77 195,82 192,87 189,91 185,95 181,99 177,102 172,105 167,108 162,110 157,112 151,113 146,114 140,114 134,114 129,113 123,112 118,110 113,108 108,105 103,102 99,99 95,95 91,91 88,87 85,82 82,77 80,72 78,67 77,61 76,56 76,50 76,44 77,39 78,33 80,28 82,23 85,18 88,13 91,9 95,5 99,1 103,-2 108,-5 113,-8 118,-10 123,-12 129,-13 134,-14 140,-14 146,-14 151,-13 157,-12 162,-10 167,-8 172,-5 177,-2 181,1 185,5 189,9 192,13 195,18 198,23 200,28 202,33 203,39 204,44 204,50", strokeWidth: "4", strokeDasharray: "10", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "24,50 76,50", strokeWidth: "4", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "24", cy: "50", r: "6", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", strokeOpacity: "1", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "76", cy: "50", r: "6", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", strokeOpacity: "1", fill: "currentColor", stroke: "currentColor" }));\n return {\n name: "shortest",\n execute({ contents, selected }) {\n var _a, _b, _c, _d;\n const first = contents[selected[0][0]];\n if (!first) return;\n const firstGeometries = (_b = (_a = ctx.getContentModel(first)) == null ? void 0 : _a.getGeometries) == null ? void 0 : _b.call(_a, first, contents);\n if (!firstGeometries) return;\n const second = contents[selected[1][0]];\n if (!second) return;\n const secondGeometries = (_d = (_c = ctx.getContentModel(second)) == null ? void 0 : _c.getGeometries) == null ? void 0 : _d.call(_c, second, contents);\n if (!secondGeometries) return;\n const result = ctx.getShortestDistanceOfTwoGeometryLines(firstGeometries.lines, secondGeometries.lines);\n if (result && ctx.largerThan(result.distance, 0)) {\n contents.push({ type: "line", points: result.points });\n }\n },\n contentSelectable(content, contents) {\n return ctx.contentIsDeletable(content, contents);\n },\n selectCount: 2,\n icon\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/skew.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("rect", { x: "5", y: "5", width: "51", height: "89", strokeWidth: "5", strokeDasharray: "10", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polygon", { points: "40,5 92,5 57,95 5,95", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", strokeOpacity: "1", fill: "none", stroke: "currentColor" }));\n return {\n name: "skew",\n useCommand({ onEnd, scale, type, selected, contents }) {\n const [data, setData] = React.useState();\n const [cursor, setCursor] = React.useState();\n let message = "";\n if (type) {\n message = data ? "specify skew" : "specify center point";\n }\n const { input, setInputPosition, resetInput, setCursorPosition } = ctx.useCursorInput(message, type ? (e, text) => {\n if (e.key === "Enter" && data) {\n const value = +text;\n if (!isNaN(value)) {\n onEnd({\n updateContents(contents2, selected2) {\n contents2.forEach((content, index) => {\n var _a, _b;\n if (content && ctx.isSelected([index], selected2)) {\n const result = (_b = (_a = ctx.getContentModel(content)) == null ? void 0 : _a.skew) == null ? void 0 : _b.call(_a, content, data.center, value, 0, contents2);\n if (result) {\n contents2[index] = result;\n }\n }\n });\n }\n });\n reset();\n }\n }\n } : void 0);\n const reset = () => {\n setData(void 0);\n setCursor(void 0);\n resetInput();\n };\n return {\n onStart(s) {\n var _a, _b, _c;\n if (!type) return;\n if (!data) {\n const boundings = [];\n for (const c of selected) {\n const bounding2 = (_c = (_b = (_a = ctx.getContentModel(c.content)) == null ? void 0 : _a.getGeometries) == null ? void 0 : _b.call(_a, c.content, contents)) == null ? void 0 : _c.bounding;\n if (bounding2) {\n boundings.push(bounding2);\n }\n }\n const bounding = ctx.mergeBoundings(boundings);\n if (bounding) {\n const size = ctx.getTwoPointsFormRegionSize(bounding);\n setData({ center: s, size: Math.max(size.width, size.height) });\n }\n } else {\n onEnd();\n reset();\n }\n },\n onMove(p, c) {\n if (!type) return;\n setInputPosition(c || p);\n setCursorPosition(c || p);\n if (data) {\n setCursor(p);\n }\n },\n reset,\n input,\n updateSelectedContent(content, contents2, selected2) {\n if (data && cursor) {\n const sx = (cursor.x - data.center.x) / data.size;\n if (!sx) {\n return {};\n }\n const sy = (cursor.y - data.center.y) / data.size;\n const [newContent, ...patches] = ctx.produceWithPatches(content, (draft) => {\n var _a, _b;\n return (_b = (_a = ctx.getContentModel(content)) == null ? void 0 : _a.skew) == null ? void 0 : _b.call(_a, draft, data.center, sx, sy, contents2);\n });\n const assistentContents = ctx.updateReferencedContents(content, newContent, contents2, selected2);\n return {\n patches,\n assistentContents\n };\n }\n return {};\n },\n assistentContents: data && cursor ? [\n {\n type: "line",\n dashArray: [4 / scale],\n points: [data.center, cursor]\n }\n ] : void 0\n };\n },\n contentSelectable(content) {\n var _a;\n return !content.readonly && ((_a = ctx.getContentModel(content)) == null ? void 0 : _a.skew) !== void 0;\n },\n icon\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/spline.plugin.tsx\nfunction getModel(ctx) {\n const SplineContent = ctx.and(ctx.BaseContent("spline"), ctx.StrokeFields, ctx.FillFields, ctx.SegmentCountFields, {\n points: [ctx.Position],\n fitting: ctx.optional(ctx.or(ctx.boolean, "closed"))\n });\n const SplineArrowContent = ctx.and(ctx.BaseContent("spline arrow"), ctx.StrokeFields, ctx.SegmentCountFields, {\n points: [ctx.Position],\n fitting: ctx.optional(ctx.boolean)\n });\n const getSplineRefIds = (content) => ctx.getStrokeAndFillRefIds(content);\n const getSplineArrowRefIds = (content) => ctx.getStrokeRefIds(content);\n const geometriesCache = new ctx.WeakmapValuesCache();\n function getSplineGeometries(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getSplineRefIds(content), contents, [content]));\n return geometriesCache.get(content, refs, () => {\n var _a;\n let points;\n let lines;\n const splineSegmentCount = (_a = content.segmentCount) != null ? _a : ctx.defaultSegmentCount;\n if (content.points.length > 2) {\n if (content.fitting === "closed") {\n lines = ctx.getBezierSplineCurves([...content.points.slice(content.points.length - 3), ...content.points, ...content.points.slice(0, 3)]).map((c) => ({ type: "bezier curve", curve: c }));\n lines = lines.slice(3, lines.length - 2);\n } else if (content.fitting) {\n lines = ctx.getBezierSplineCurves(content.points).map((c) => ({ type: "bezier curve", curve: c }));\n } else if (content.points.length === 3) {\n lines = ctx.getQuadraticSplineCurves(content.points).map((c) => ({ type: "quadratic curve", curve: c }));\n } else {\n lines = ctx.getBezierSplineCurves(content.points, false).map((c) => ({ type: "bezier curve", curve: c }));\n }\n points = ctx.getGeometryLinesPoints(lines, splineSegmentCount);\n } else {\n points = content.points;\n lines = Array.from(ctx.iteratePolylineLines(points));\n }\n return {\n lines,\n points,\n bounding: ctx.getGeometryLinesBounding(lines),\n renderingLines: ctx.dashedPolylineToLines(points, content.dashArray),\n regions: ctx.hasFill(content) ? [\n {\n lines,\n points: content.points\n }\n ] : void 0\n };\n });\n }\n function getSplineArrowGeometries(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getSplineArrowRefIds(content), contents, [content]));\n return geometriesCache.get(content, refs, () => {\n const geometry = getSplineGeometries(content, contents);\n let arrowPoints;\n let points = geometry.points;\n if (content.points.length > 1) {\n const p1 = content.points[content.points.length - 2];\n const p2 = content.points[content.points.length - 1];\n const r = ctx.getArrowPoints(p1, p2, content);\n arrowPoints = r.arrowPoints;\n const index = points.findIndex((p) => ctx.getTwoPointsDistance(p, p2) < r.distance);\n points = [...points.slice(0, index), r.endPoint];\n }\n const lines = Array.from(ctx.iteratePolylineLines(points));\n return {\n lines,\n points,\n bounding: ctx.getPointsBounding(points),\n renderingLines: ctx.dashedPolylineToLines(points, content.dashArray),\n regions: arrowPoints ? [\n {\n points: arrowPoints,\n lines: Array.from(ctx.iteratePolygonLines(arrowPoints))\n }\n ] : void 0\n };\n });\n }\n const React = ctx.React;\n const splineModel = {\n type: "spline",\n ...ctx.strokeModel,\n ...ctx.fillModel,\n ...ctx.segmentCountModel,\n move(content, offset) {\n for (const point of content.points) {\n ctx.movePoint(point, offset);\n }\n },\n rotate(content, center, angle) {\n for (const point of content.points) {\n ctx.rotatePoint(point, center, angle);\n }\n },\n scale(content, center, sx, sy) {\n for (const point of content.points) {\n ctx.scalePoint(point, center, sx, sy);\n }\n },\n skew(content, center, sx, sy) {\n for (const point of content.points) {\n ctx.skewPoint(point, center, sx, sy);\n }\n },\n mirror(content, line) {\n for (const point of content.points) {\n ctx.mirrorPoint(point, line);\n }\n },\n break(content, intersectionPoints, contents) {\n const lines = getSplineGeometries(content, contents).lines;\n return ctx.breakGeometryLinesToPathCommands(lines, intersectionPoints);\n },\n explode(content, contents) {\n const lines = getSplineGeometries(content, contents).lines;\n return [{ type: "path", commands: ctx.geometryLineToPathCommands(lines) }];\n },\n render(content, renderCtx) {\n const { options, target } = ctx.getStrokeFillRenderOptionsFromRenderContext(content, renderCtx);\n const { points } = getSplineGeometries(content, renderCtx.contents);\n return target.renderPolyline(points, options);\n },\n renderIfSelected(content, { color, target, strokeWidth }) {\n return target.renderPolyline(content.points, { strokeColor: color, dashArray: [4], strokeWidth });\n },\n getOperatorRenderPosition(content) {\n return content.points[0];\n },\n getEditPoints(content) {\n return ctx.getEditPointsFromCache(content, () => ({ editPoints: ctx.getPolylineEditPoints(content, isSplineContent, false, true) }));\n },\n getSnapPoints(content) {\n return ctx.getSnapPointsFromCache(content, () => content.points.map((p) => ({ ...p, type: "endpoint" })));\n },\n getGeometries: getSplineGeometries,\n propertyPanel(content, update, contents, { acquirePoint }) {\n return {\n points: /* @__PURE__ */ React.createElement(\n ctx.ArrayEditor,\n {\n inline: true,\n ...ctx.getArrayEditorProps((v) => v.points, { x: 0, y: 0 }, (v) => update((c) => {\n if (isSplineContent(c)) {\n v(c);\n }\n })),\n items: content.points.map((f, i) => /* @__PURE__ */ React.createElement(\n ctx.ObjectEditor,\n {\n inline: true,\n properties: {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isSplineContent(c)) {\n c.points[i].x = p.x;\n c.points[i].y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.x, setValue: (v) => update((c) => {\n if (isSplineContent(c)) {\n c.points[i].x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.y, setValue: (v) => update((c) => {\n if (isSplineContent(c)) {\n c.points[i].y = v;\n }\n }) })\n }\n }\n ))\n }\n ),\n fitting: /* @__PURE__ */ React.createElement(ctx.EnumEditor, { enums: ["true", "false", "closed"], value: content.fitting === "closed" ? "closed" : content.fitting ? "true" : "false", setValue: (v) => update((c) => {\n if (isSplineContent(c)) {\n c.fitting = v === "closed" ? "closed" : v === "true" ? true : void 0;\n }\n }) }),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents),\n ...ctx.getFillContentPropertyPanel(content, update, contents),\n ...ctx.getSegmentCountContentPropertyPanel(content, update)\n };\n },\n isValid: (c, p) => ctx.validate(c, SplineContent, p),\n getRefIds: getSplineRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n deleteRefId: ctx.deleteStrokeAndFillRefIds,\n reverse: (content) => ({\n ...content,\n points: content.points.slice().reverse()\n })\n };\n return [\n splineModel,\n {\n type: "spline arrow",\n ...ctx.strokeModel,\n ...ctx.arrowModel,\n ...ctx.segmentCountModel,\n move: splineModel.move,\n rotate: splineModel.rotate,\n scale: splineModel.scale,\n mirror: splineModel.mirror,\n render(content, renderCtx) {\n const { options, target, fillOptions } = ctx.getStrokeRenderOptionsFromRenderContext(content, renderCtx);\n const { regions, renderingLines } = getSplineArrowGeometries(content, renderCtx.contents);\n const children = [];\n for (const line of renderingLines) {\n children.push(target.renderPolyline(line, options));\n }\n if (regions) {\n for (let i = 0; i < 2 && i < regions.length; i++) {\n children.push(target.renderPolyline(regions[i].points, fillOptions));\n }\n }\n return target.renderGroup(children);\n },\n renderIfSelected: splineModel.renderIfSelected,\n getOperatorRenderPosition: splineModel.getOperatorRenderPosition,\n getEditPoints(content) {\n return ctx.getEditPointsFromCache(content, () => ({ editPoints: ctx.getPolylineEditPoints(content, isSplineArrowContent, false, true) }));\n },\n getSnapPoints: splineModel.getSnapPoints,\n getGeometries: getSplineArrowGeometries,\n propertyPanel(content, update, contents, { acquirePoint }) {\n return {\n points: /* @__PURE__ */ React.createElement(\n ctx.ArrayEditor,\n {\n inline: true,\n ...ctx.getArrayEditorProps((v) => v.points, { x: 0, y: 0 }, (v) => update((c) => {\n if (isSplineArrowContent(c)) {\n v(c);\n }\n })),\n items: content.points.map((f, i) => /* @__PURE__ */ React.createElement(\n ctx.ObjectEditor,\n {\n inline: true,\n properties: {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isSplineArrowContent(c)) {\n c.points[i].x = p.x;\n c.points[i].y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.x, setValue: (v) => update((c) => {\n if (isSplineArrowContent(c)) {\n c.points[i].x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.y, setValue: (v) => update((c) => {\n if (isSplineArrowContent(c)) {\n c.points[i].y = v;\n }\n }) })\n }\n }\n ))\n }\n ),\n fitting: /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.fitting === true, setValue: (v) => update((c) => {\n if (isSplineArrowContent(c)) {\n c.fitting = v ? true : void 0;\n }\n }) }),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents),\n ...ctx.getArrowContentPropertyPanel(content, update),\n ...ctx.getSegmentCountContentPropertyPanel(content, update)\n };\n },\n isValid: (c, p) => ctx.validate(c, SplineArrowContent, p),\n getRefIds: getSplineArrowRefIds,\n updateRefId: ctx.updateStrokeRefIds,\n deleteRefId: ctx.deleteStrokeRefIds,\n reverse: (content) => ({\n ...content,\n points: content.points.slice().reverse()\n })\n }\n ];\n}\nfunction isSplineContent(content) {\n return content.type === "spline";\n}\nfunction isSplineArrowContent(content) {\n return content.type === "spline arrow";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon1 = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("circle", { cx: "13", cy: "22", r: "5", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "28", cy: "79", r: "5", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "63", cy: "22", r: "5", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "85", cy: "80", r: "5", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "13,22 14,24 14,26 15,29 15,31 16,33 17,34 17,36 18,38 18,40 19,41 20,43 20,44 21,46 22,47 22,49 23,50 23,51 24,52 25,53 25,54 26,55 27,56 27,56 28,57 29,58 29,58 30,59 31,59 31,59 32,60 33,60 33,60 34,60 35,60 35,60 36,60 37,60 37,59 38,59 39,58 39,58 40,57 41,57 41,56 42,55 43,55 43,54 44,53 45,52 46,51 46,49 47,48 48,47 48,46 49,46 50,45 50,44 51,44 52,43 53,43 53,42 54,42 55,42 56,41 56,41 57,41 58,41 59,41 59,41 60,42 61,42 62,42 63,43 63,43 64,44 65,44 66,45 67,46 67,47 68,47 69,48 70,49 71,51 71,52 72,53 73,54 74,56 75,57 76,59 76,60 77,62 78,64 79,65 80,67 81,69 82,71 82,73 83,75 84,78 85,80", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n const icon2 = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("circle", { cx: "13", cy: "22", r: "5", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "28", cy: "79", r: "5", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "63", cy: "22", r: "5", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "85", cy: "80", r: "5", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "13,22 13,23 13,24 13,25 13,26 13,27 14,28 14,29 14,30 14,31 14,31 14,32 14,33 14,34 14,35 14,36 14,37 15,38 15,39 15,40 15,41 15,42 15,43 15,43 15,44 15,45 15,46 15,47 16,48 16,49 16,49 16,50 16,51 16,52 16,53 16,54 16,54 17,55 17,56 17,57 17,58 17,58 17,59 17,60 17,61 18,61 18,62 18,63 18,63 18,64 18,65 18,65 18,66 19,67 19,67 19,68 19,69 19,69 19,70 19,70 20,71 20,71 20,72 20,72 20,73 20,73 21,74 21,74 21,75 21,75 21,75 21,76 22,76 22,77 22,77 22,77 22,78 23,78 23,78 23,78 23,79 23,79 24,79 24,79 24,79 24,79 25,80 25,80 25,80 25,80 25,80 26,80 26,80 26,80 26,80 27,80 27,80 27,79 27,79 28,79 28,79 28,79 29,79 29,78 29,78 29,78 30,77 30,77 30,77 31,76 31,76 31,76 32,75 32,75 32,74 32,74 33,73 33,73 33,72 34,72 34,71 34,71 35,70 35,69 35,69 36,68 36,68 37,67 37,66 37,66 38,65 38,64 38,64 39,63 39,62 39,62 40,61 40,60 40,59 41,59 41,58 42,57 42,56 42,56 43,55 43,54 43,53 44,53 44,52 45,51 45,50 45,50 46,49 46,48 46,47 47,47 47,46 48,45 48,44 48,44 49,43 49,42 50,41 50,41 50,40 51,39 51,39 51,38 52,37 52,37 53,36 53,35 53,35 54,34 54,33 54,33 55,32 55,31 55,31 56,30 56,30 57,29 57,29 57,28 58,28 58,27 58,27 59,26 59,26 59,25 60,25 60,25 60,24 61,24 61,24 61,23 62,23 62,23 62,22 63,22 63,22 63,22 64,22 64,22 64,21 65,21 65,21 65,21 65,21 66,21 66,21 66,21 67,21 67,21 67,22 67,22 68,22 68,22 68,22 69,22 69,23 69,23 69,23 70,23 70,24 70,24 70,24 71,25 71,25 71,25 71,26 72,26 72,27 72,27 72,27 73,28 73,28 73,29 73,29 73,30 74,31 74,31 74,32 74,32 75,33 75,33 75,34 75,35 75,35 76,36 76,37 76,37 76,38 76,39 77,39 77,40 77,41 77,42 77,42 78,43 78,44 78,45 78,46 78,46 79,47 79,48 79,49 79,50 79,50 80,51 80,52 80,53 80,54 80,55 80,56 81,57 81,57 81,58 81,59 81,60 82,61 82,62 82,63 82,64 82,65 82,66 83,67 83,68 83,69 83,69 83,70 83,71 84,72 84,73 84,74 84,75 84,76 84,77 85,78 85,79 85,80", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n const icon3 = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "8,93 8,90 8,87 8,83 8,81 8,78 9,75 9,72 9,70 9,67 10,65 10,62 10,60 11,58 11,56 12,54 12,53 13,51 13,49 14,48 15,46 15,45 16,44 17,43 17,42 18,41 19,40 20,39 21,39 22,38 23,38 24,38 25,38 26,37 27,37 28,38 29,38 30,38 32,38 33,39 34,40 36,40 37,41 38,42 40,43 41,44 43,45 44,46 46,48 47,49 49,51 51,53 52,54 54,55 55,57 57,58 58,59 60,60 61,61 62,62 64,62 65,63 66,63 68,64 69,64 70,64 71,64 72,64 73,64 74,64 75,64 76,63 77,63 78,62 79,62 80,61 81,60 81,59 82,58 83,56 83,55 84,54 85,52 85,51 86,49 86,47 87,45 87,43 88,41 88,39 88,37 89,34 89,32 89,29 89,26 90,24 90,21 90,18 90,17", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "90,8 98,37 82,37", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }));\n const splineCommand = {\n name: "create spline",\n type: [\n { name: "spline", hotkey: "SPL", icon: icon1 },\n { name: "spline fitting", icon: icon2 }\n ],\n useCommand({ onEnd, type, scale, strokeStyleId, fillStyleId }) {\n const { line, onClick, onMove, input, lastPosition, reset } = ctx.useLineClickCreate(\n type === "spline" || type === "spline fitting",\n (c) => onEnd({\n updateContents: (contents) => contents.push({ points: c, type: "spline", strokeStyleId, fillStyleId, fitting: type === "spline fitting" })\n })\n );\n const assistentContents = [];\n if (line) {\n assistentContents.push(\n { points: line, type: "spline", strokeStyleId, fillStyleId, fitting: type === "spline fitting" },\n { points: line, type: "polyline", dashArray: [4 / scale] }\n );\n }\n return {\n onStart: onClick,\n input,\n onMove,\n assistentContents,\n lastPosition,\n reset\n };\n },\n selectCount: 0\n };\n return [\n splineCommand,\n {\n name: "create spline arrow",\n icon: icon3,\n useCommand({ onEnd, type, scale, strokeStyleId }) {\n const { line, onClick, onMove, input, lastPosition, reset } = ctx.useLineClickCreate(\n type === "create spline arrow",\n (c) => onEnd({\n updateContents: (contents) => contents.push({ points: c, strokeStyleId, type: "spline arrow" })\n })\n );\n const assistentContents = [];\n if (line) {\n assistentContents.push(\n { points: line, strokeStyleId, type: "spline arrow" },\n { points: line, type: "polyline", dashArray: [4 / scale] }\n );\n }\n return {\n onStart: onClick,\n input,\n onMove,\n assistentContents,\n lastPosition,\n reset\n };\n },\n selectCount: 0\n }\n ];\n}\nexport {\n getCommand,\n getModel,\n isSplineArrowContent,\n isSplineContent\n};\n','// dev/cad-editor/plugins/star.plugin.tsx\nfunction getModel(ctx) {\n const StarContent = ctx.and(ctx.BaseContent("star"), ctx.StrokeFields, ctx.FillFields, ctx.Position, {\n outerRadius: ctx.number,\n innerRadius: ctx.number,\n count: ctx.number,\n angle: ctx.optional(ctx.number)\n });\n const getRefIds = (content) => ctx.getStrokeAndFillRefIds(content);\n const geometriesCache = new ctx.WeakmapValuesCache();\n function getStarGeometriesFromCache(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return geometriesCache.get(content, refs, () => {\n var _a;\n const angle = -((_a = content.angle) != null ? _a : 0);\n const p0 = ctx.rotatePositionByCenter({ x: content.x + content.outerRadius, y: content.y }, content, angle);\n const p1 = ctx.rotatePositionByCenter({ x: content.x + content.innerRadius, y: content.y }, content, angle + 180 / content.count);\n const points = [];\n for (let i = 0; i < content.count; i++) {\n const angle2 = 360 / content.count * i;\n points.push(\n ctx.rotatePositionByCenter(p0, content, angle2),\n ctx.rotatePositionByCenter(p1, content, angle2)\n );\n }\n const lines = Array.from(ctx.iteratePolygonLines(points));\n return {\n points,\n lines,\n bounding: ctx.getPointsBounding(points),\n regions: ctx.hasFill(content) ? [\n {\n lines,\n points\n }\n ] : void 0,\n renderingLines: ctx.dashedPolylineToLines(ctx.polygonToPolyline(points), content.dashArray)\n };\n });\n }\n const React = ctx.React;\n return {\n type: "star",\n ...ctx.strokeModel,\n ...ctx.fillModel,\n move(content, offset) {\n ctx.movePoint(content, offset);\n },\n scale(content, center, sx, sy, contents) {\n if (sx !== sy) {\n const points = ctx.produce(getStarGeometriesFromCache(content, contents).points, (draft) => {\n for (const p of draft) {\n ctx.scalePoint(p, center, sx, sy);\n }\n });\n return { ...content, points, type: "polygon" };\n }\n ctx.scalePoint(content, center, sx, sy);\n content.innerRadius *= sx;\n content.outerRadius *= sy;\n return;\n },\n skew(content, center, sx, sy, contents) {\n const points = ctx.produce(getStarGeometriesFromCache(content, contents).points, (draft) => {\n for (const p of draft) {\n ctx.skewPoint(p, center, sx, sy);\n }\n });\n return { ...content, points, type: "polygon" };\n },\n break(content, intersectionPoints, contents) {\n const { lines } = getStarGeometriesFromCache(content, contents);\n return ctx.breakPolyline(lines, intersectionPoints);\n },\n offset(content, point, distance, contents) {\n var _a;\n if (!distance) {\n distance = Math.min(...getStarGeometriesFromCache(content, contents).lines.map((line) => ctx.getPointAndGeometryLineMinimumDistance(point, line)));\n }\n distance *= ((_a = this.isPointIn) == null ? void 0 : _a.call(this, content, point, contents)) ? -1 : 1;\n const angle = Math.PI / content.count;\n const length = Math.sqrt(content.innerRadius ** 2 + content.outerRadius ** 2 - 2 * content.innerRadius * content.outerRadius * Math.cos(angle));\n distance *= length / Math.sin(angle);\n return ctx.produce(content, (d) => {\n d.outerRadius += distance / content.innerRadius;\n d.innerRadius += distance / content.outerRadius;\n });\n },\n render(content, renderCtx) {\n const { options, target } = ctx.getStrokeFillRenderOptionsFromRenderContext(content, renderCtx);\n const { points } = getStarGeometriesFromCache(content, renderCtx.contents);\n return target.renderPolygon(points, options);\n },\n getEditPoints(content, contents) {\n return ctx.getEditPointsFromCache(content, () => {\n const { points } = getStarGeometriesFromCache(content, contents);\n return {\n editPoints: [\n {\n ...content,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isStarContent(c)) {\n return;\n }\n c.x += cursor.x - start.x;\n c.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n },\n ...points.map((p, i) => ({\n x: p.x,\n y: p.y,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isStarContent(c)) {\n return;\n }\n if (i % 2 === 0) {\n c.outerRadius = ctx.getTwoPointsDistance(cursor, c);\n } else {\n c.innerRadius = ctx.getTwoPointsDistance(cursor, c);\n }\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n }))\n ]\n };\n });\n },\n getGeometries: getStarGeometriesFromCache,\n propertyPanel(content, update, contents, { acquirePoint }) {\n var _a;\n return {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isStarContent(c)) {\n c.x = p.x;\n c.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.x, setValue: (v) => update((c) => {\n if (isStarContent(c)) {\n c.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.y, setValue: (v) => update((c) => {\n if (isStarContent(c)) {\n c.y = v;\n }\n }) }),\n outerRadius: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.outerRadius, setValue: (v) => update((c) => {\n if (isStarContent(c)) {\n c.outerRadius = v;\n }\n }) }),\n innerRadius: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.innerRadius, setValue: (v) => update((c) => {\n if (isStarContent(c)) {\n c.innerRadius = v;\n }\n }) }),\n count: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.count, setValue: (v) => update((c) => {\n if (isStarContent(c)) {\n c.count = v;\n }\n }) }),\n angle: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: (_a = content.angle) != null ? _a : 0, setValue: (v) => update((c) => {\n if (isStarContent(c)) {\n c.angle = v === 0 ? void 0 : v;\n }\n }) }),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents),\n ...ctx.getFillContentPropertyPanel(content, update, contents)\n };\n },\n isValid: (c, p) => ctx.validate(c, StarContent, p),\n getRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n deleteRefId: ctx.deleteStrokeAndFillRefIds,\n isPointIn: (content, point, contents) => ctx.pointInPolygon(point, getStarGeometriesFromCache(content, contents).points)\n };\n}\nfunction isStarContent(content) {\n return content.type === "star";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polygon", { points: "75,84 70,56 90,36 62,32 49,7 37,33 9,37 29,56 25,84 50,71", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "create star",\n icon,\n useCommand({ onEnd, type, strokeStyleId, fillStyleId }) {\n const { line, onClick, onMove, input, lastPosition, reset } = ctx.useLineClickCreate(\n type === "create star",\n ([p0, p1]) => onEnd({\n updateContents: (contents) => {\n const outerRadius = ctx.getTwoPointsDistance(p0, p1);\n contents.push({\n type: "star",\n x: p0.x,\n y: p0.y,\n outerRadius,\n innerRadius: outerRadius * 0.5,\n count: 5,\n angle: ctx.radianToAngle(ctx.getTwoPointsRadian(p1, p0)),\n strokeStyleId,\n fillStyleId\n });\n }\n }),\n {\n once: true\n }\n );\n const assistentContents = [];\n if (line) {\n const [p0, p1] = line;\n const outerRadius = ctx.getTwoPointsDistance(p0, p1);\n assistentContents.push({\n type: "star",\n x: p0.x,\n y: p0.y,\n outerRadius,\n innerRadius: outerRadius * 0.5,\n count: 5,\n angle: ctx.radianToAngle(ctx.getTwoPointsRadian(p1, p0)),\n strokeStyleId,\n fillStyleId\n });\n }\n return {\n onStart: onClick,\n input,\n onMove,\n assistentContents,\n lastPosition,\n reset\n };\n },\n selectCount: 0\n };\n}\nexport {\n getCommand,\n getModel,\n isStarContent\n};\n','// dev/cad-editor/plugins/stroke-style.plugin.tsx\nfunction getModel(ctx) {\n function getGeometriesFromCache(content) {\n return ctx.getGeometriesFromCache(content, /* @__PURE__ */ new Set(), () => {\n const points = [\n { x: content.x, y: content.y },\n { x: content.x + content.width, y: content.y },\n { x: content.x + content.width, y: content.y + content.height },\n { x: content.x, y: content.y + content.height }\n ];\n return {\n lines: [],\n bounding: ctx.getPointsBounding(points),\n regions: [\n {\n points,\n lines: Array.from(ctx.iteratePolygonLines(points))\n }\n ],\n renderingLines: []\n };\n });\n }\n const React = ctx.React;\n return {\n type: "stroke style",\n ...ctx.strokeModel,\n move(content, offset) {\n ctx.movePoint(content, offset);\n },\n render(content, { target, getStrokeColor, transformStrokeWidth, transformColor }) {\n var _a;\n const options = {\n strokeColor: getStrokeColor(content),\n strokeWidth: transformStrokeWidth((_a = content.strokeWidth) != null ? _a : ctx.getDefaultStrokeWidth(content)),\n dashArray: content.dashArray,\n strokeOpacity: content.strokeOpacity\n };\n return target.renderGroup([\n target.renderRect(content.x, content.y, content.width, content.height, {\n strokeColor: transformColor(content.isCurrent ? 16711680 : 0)\n }),\n target.renderPolyline([\n { x: content.x, y: content.y + content.height / 2 },\n { x: content.x + content.width, y: content.y + content.height / 2 }\n ], options)\n ]);\n },\n getEditPoints(content) {\n return ctx.getEditPointsFromCache(content, () => {\n return {\n editPoints: [\n {\n ...content,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!ctx.isStrokeStyleContent(c)) {\n return;\n }\n c.x += cursor.x - start.x;\n c.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n }\n ]\n };\n });\n },\n getGeometries: getGeometriesFromCache,\n propertyPanel(content, update, contents, { acquirePoint }) {\n return {\n isCurrent: /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.isCurrent === true, setValue: (v) => update((c, draft) => {\n if (ctx.isStrokeStyleContent(c)) {\n const currentStrokeStyle = ctx.getStrokeStyles(contents).find((s) => s.content.isCurrent);\n if (currentStrokeStyle) {\n const c2 = draft[currentStrokeStyle.index];\n if (c2 && ctx.isStrokeStyleContent(c2)) {\n c2.isCurrent = void 0;\n }\n }\n c.isCurrent = v ? true : void 0;\n }\n }) }),\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (ctx.isStrokeStyleContent(c)) {\n c.x = p.x;\n c.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.x, setValue: (v) => update((c) => {\n if (ctx.isStrokeStyleContent(c)) {\n c.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.y, setValue: (v) => update((c) => {\n if (ctx.isStrokeStyleContent(c)) {\n c.y = v;\n }\n }) }),\n width: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.width, setValue: (v) => update((c) => {\n if (ctx.isStrokeStyleContent(c)) {\n c.width = v;\n }\n }) }),\n height: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.height, setValue: (v) => update((c) => {\n if (ctx.isStrokeStyleContent(c)) {\n c.height = v;\n }\n }) }),\n ...ctx.getStrokeContentPropertyPanel(content, update)\n };\n },\n isValid: (c, p) => ctx.validate(c, ctx.StrokeStyleContent, p)\n };\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "0,22 100,22", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "0,45 100,45", strokeWidth: "10", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "0,65 100,65", strokeWidth: "5", strokeDasharray: "10 5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "0,81 100,81", strokeWidth: "5", strokeDasharray: "15", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "create stroke style",\n selectCount: 0,\n icon,\n useCommand({ onEnd, type, scale }) {\n const [result, setResult] = React.useState();\n const reset = () => {\n setResult(void 0);\n };\n return {\n onStart() {\n if (result) {\n onEnd({\n updateContents: (contents) => {\n if (result) {\n contents.push(result);\n }\n }\n });\n reset();\n }\n },\n onMove(p) {\n if (type) {\n setResult({\n type: "stroke style",\n x: p.x,\n y: p.y,\n width: 100 / scale,\n height: 20 / scale\n });\n }\n },\n assistentContents: result ? [result] : void 0,\n reset\n };\n }\n };\n}\nexport {\n getCommand,\n getModel\n};\n','// dev/cad-editor/plugins/table.plugin.tsx\nfunction getModel(ctx) {\n const TableCellText = ctx.and(ctx.TextFields, {\n type: "table cell text",\n text: ctx.string,\n column: ctx.number\n });\n const TableRow = {\n height: ctx.number,\n cells: ctx.optional([TableCellText])\n };\n const MergedCell = {\n row: ctx.tuple(ctx.number, ctx.number),\n column: ctx.tuple(ctx.number, ctx.number)\n };\n const TableContent = ctx.and(ctx.BaseContent("table"), ctx.Position, ctx.StrokeFields, {\n rows: [TableRow],\n widths: [ctx.number],\n mergedCells: ctx.optional([MergedCell])\n });\n const getRefIds = (content) => ctx.getStrokeRefIds(content);\n const geometriesCache = new ctx.WeakmapValuesCache();\n const textLayoutResultCache = new ctx.WeakmapMap3Cache();\n const getGeometries = (content, contents) => {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return geometriesCache.get(content, refs, () => {\n const lines = [];\n const width = content.widths.reduce((p, c) => p + c, 0);\n const height = content.rows.reduce((p, c) => p + c.height, 0);\n lines.push([{ x: content.x, y: content.y }, { x: content.x + width, y: content.y }]);\n lines.push([{ x: content.x, y: content.y }, { x: content.x, y: content.y + height }]);\n const rows = [];\n const columns = [];\n const xs = [];\n const ys = [];\n const children = [];\n let x = content.x;\n content.widths.forEach((w) => {\n x += w;\n xs.push(x - w / 2);\n });\n let yStart = content.y;\n content.rows.forEach((row, i) => {\n const yMiddle = yStart + row.height / 2;\n const yEnd = yStart + row.height;\n ys.push(yMiddle);\n let xStart = content.x;\n content.widths.forEach((w, j) => {\n var _a, _b, _c;\n const xMiddle = xStart + w / 2;\n const xEnd = xStart + w;\n if (!((_a = content.mergedCells) == null ? void 0 : _a.some((c) => i >= c.row[0] && i < c.row[0] + c.row[1] - 1 && j >= c.column[0] && j < c.column[0] + c.column[1]))) {\n lines.push([{ x: xStart, y: yEnd }, { x: xEnd, y: yEnd }]);\n rows.push({ x: xMiddle, y: yEnd, index: i });\n }\n if (!((_b = content.mergedCells) == null ? void 0 : _b.some((c) => i >= c.row[0] && i < c.row[0] + c.row[1] && j >= c.column[0] && j < c.column[0] + c.column[1] - 1))) {\n lines.push([{ x: xEnd, y: yStart }, { x: xEnd, y: yEnd }]);\n columns.push({ x: xEnd, y: yMiddle, index: j });\n }\n const cell = (_c = content.mergedCells) == null ? void 0 : _c.find((c) => i >= c.row[0] && i < c.row[0] + c.row[1] && j >= c.column[0] && j < c.column[0] + c.column[1]);\n if (cell) {\n if (i === cell.row[0] && j === cell.column[0]) {\n const end = {\n x: xEnd,\n y: yEnd\n };\n for (let k = 1; k < cell.column[1] && k < content.widths.length - j; k++) {\n end.x += content.widths[j + k];\n }\n for (let k = 1; k < cell.row[1] && k < content.rows.length - i; k++) {\n end.y += content.rows[i + k].height;\n }\n children.push({\n row: i,\n column: j,\n x: xStart - content.x,\n y: yStart - content.y,\n width: end.x - xStart,\n height: end.y - yStart,\n region: ctx.getPolygonFromTwoPointsFormRegion({ start: { x: xStart, y: yStart }, end })\n });\n }\n } else {\n children.push({\n row: i,\n column: j,\n x: xStart - content.x,\n y: yStart - content.y,\n width: w,\n height: row.height,\n region: ctx.getPolygonFromTwoPointsFormRegion({ start: { x: xStart, y: yStart }, end: { x: xEnd, y: yEnd } })\n });\n }\n xStart = xEnd;\n });\n yStart = yEnd;\n });\n const bounding = { start: { x: content.x, y: content.y }, end: { x: content.x + width, y: content.y + height } };\n const polygon = ctx.getPolygonFromTwoPointsFormRegion(bounding);\n return {\n lines,\n rows,\n columns,\n xs,\n ys,\n bounding,\n renderingLines: lines.map((r) => ctx.dashedPolylineToLines(r, content.dashArray)).flat(),\n regions: [{\n points: polygon,\n lines: Array.from(ctx.iteratePolygonLines(polygon))\n }],\n children\n };\n });\n };\n const React = ctx.React;\n const tableModel = {\n type: "table",\n ...ctx.strokeModel,\n move(content, offset) {\n ctx.movePoint(content, offset);\n },\n scale(content, center, sx, sy) {\n ctx.scalePoint(content, center, sx, sy);\n for (const row of content.rows) {\n row.height *= sy;\n }\n content.widths = content.widths.map((w) => w * sx);\n },\n render(content, renderCtx) {\n const geometries = getGeometries(content, renderCtx.contents);\n const { options, strokeColor } = ctx.getStrokeRenderOptionsFromRenderContext(content, renderCtx);\n const textOptions = ctx.getTextStyleRenderOptionsFromRenderContext(strokeColor, renderCtx);\n const children = geometries.renderingLines.map((line) => renderCtx.target.renderPolyline(line, options));\n content.rows.forEach((row, i) => {\n var _a;\n (_a = row.cells) == null ? void 0 : _a.forEach((cell) => {\n var _a2, _b;\n const child = geometries.children.find((f) => f.row === i && f.column === cell.column);\n if (!child) return;\n const { width, height } = child;\n const textStyleContent = ctx.getTextStyleContent(cell, renderCtx.contents);\n const textLayout = textLayoutResultCache.get(cell, textStyleContent, width, height, () => {\n var _a3, _b2, _c;\n const state = cell.text.split("");\n const getTextWidth = (text) => {\n var _a4, _b3;\n return (_b3 = (_a4 = ctx.getTextSizeFromCache(ctx.getTextStyleFont(textStyleContent), text)) == null ? void 0 : _a4.width) != null ? _b3 : 0;\n };\n return ctx.flowLayout({\n state,\n width,\n height,\n lineHeight: (_a3 = textStyleContent.lineHeight) != null ? _a3 : textStyleContent.fontSize * 1.2,\n getWidth: getTextWidth,\n align: (_b2 = textStyleContent.align) != null ? _b2 : "center",\n verticalAlign: (_c = textStyleContent.verticalAlign) != null ? _c : "middle",\n endContent: "",\n isNewLineContent: (c) => c === "\\n",\n isPartOfComposition: (c) => ctx.isWordCharactor(c),\n getComposition: (index) => ctx.getTextComposition(index, state, getTextWidth, (c) => c)\n });\n });\n const font = ctx.getTextStyleFont(textStyleContent);\n for (const { x, y, content: text } of textLayout.layoutResult) {\n const textWidth = (_b = (_a2 = ctx.getTextSizeFromCache(font, text)) == null ? void 0 : _a2.width) != null ? _b : 0;\n children.push(renderCtx.target.renderText(content.x + child.x + x + textWidth / 2, content.y + child.y + y + textStyleContent.fontSize, text, textStyleContent.color, textStyleContent.fontSize, textStyleContent.fontFamily, { textAlign: "center", cacheKey: cell, ...textOptions }));\n }\n });\n });\n return renderCtx.target.renderGroup(children);\n },\n getEditPoints(content, contents) {\n return ctx.getEditPointsFromCache(content, () => {\n const { rows, columns, xs, ys } = getGeometries(content, contents);\n return {\n editPoints: [\n {\n x: content.x,\n y: content.y,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isTableContent(c)) {\n return;\n }\n c.x += cursor.x - start.x;\n c.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n },\n ...rows.map((p) => ({\n x: p.x,\n y: p.y,\n cursor: "row-resize",\n update(c, { cursor, start, scale }) {\n if (!isTableContent(c)) {\n return;\n }\n c.rows[p.index].height += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n })),\n ...columns.map((p) => ({\n x: p.x,\n y: p.y,\n cursor: "col-resize",\n update(c, { cursor, start, scale }) {\n if (!isTableContent(c)) {\n return;\n }\n c.widths[p.index] += cursor.x - start.x;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n })),\n ...xs.map((p, i) => ({\n x: p,\n y: content.y,\n cursor: "not-allowed",\n execute(c) {\n if (isTableContent(c)) {\n deleteTableColumn(c, i);\n }\n }\n })),\n ...ys.map((p, i) => ({\n x: content.x,\n y: p,\n cursor: "not-allowed",\n execute(c) {\n if (isTableContent(c)) {\n deleteTableRow(c, i);\n }\n }\n })),\n ...xs.map((p, i) => ({\n x: p + content.widths[i] / 2,\n y: content.y,\n cursor: "cell",\n execute(c) {\n if (isTableContent(c)) {\n insertTableColumn(c, i);\n }\n }\n })),\n ...ys.map((p, i) => ({\n x: content.x,\n y: p + content.rows[i].height / 2,\n cursor: "cell",\n execute(c) {\n if (isTableContent(c)) {\n insertTableRow(c, i);\n }\n }\n }))\n ]\n };\n });\n },\n getGeometries,\n propertyPanel(content, update, contents, options) {\n var _a, _b, _c, _d, _e;\n const properties = {};\n if (options.activeChild) {\n const [row, column] = options.activeChild;\n properties.row = /* @__PURE__ */ React.createElement(ctx.NumberEditor, { readOnly: true, value: row });\n properties.column = /* @__PURE__ */ React.createElement(ctx.NumberEditor, { readOnly: true, value: column });\n const mergedCell = (_b = (_a = content.mergedCells) == null ? void 0 : _a.find) == null ? void 0 : _b.call(_a, (c) => c.row[0] === row && c.column[0] === column);\n properties.rowSpan = /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: (_c = mergedCell == null ? void 0 : mergedCell.row[1]) != null ? _c : 1, setValue: (v) => update((c) => {\n if (isTableContent(c)) {\n setTableRowSpan(c, row, column, v);\n }\n }) });\n properties.columnSpan = /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: (_d = mergedCell == null ? void 0 : mergedCell.column[1]) != null ? _d : 1, setValue: (v) => update((c) => {\n if (isTableContent(c)) {\n setTableColumnSpan(c, row, column, v);\n }\n }) });\n const cell = (_e = content.rows[row].cells) == null ? void 0 : _e.find((c) => c.column === column);\n if (cell) {\n Object.assign(properties, ctx.getTextContentPropertyPanel(cell, (f) => update((c) => {\n if (isTableContent(c)) {\n setTableCell(c, row, column, f);\n }\n }), contents));\n }\n }\n return {\n ...properties,\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.x, setValue: (v) => update((c) => {\n if (isTableContent(c)) {\n c.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.y, setValue: (v) => update((c) => {\n if (isTableContent(c)) {\n c.y = v;\n }\n }) }),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents)\n };\n },\n editPanel(content, scale, update, contents, cancel, transformPosition, activeChild) {\n var _a, _b, _c;\n const p = transformPosition(content);\n if (!activeChild) return /* @__PURE__ */ React.createElement(React.Fragment, null);\n const [row, column] = activeChild;\n const cell = (_a = content.rows[row].cells) == null ? void 0 : _a.find((c) => c.column === column);\n if (!cell) return /* @__PURE__ */ React.createElement(React.Fragment, null);\n const { children } = getGeometries(content, contents);\n const child = children.find((f) => f.row === row && f.column === column);\n if (!child) return /* @__PURE__ */ React.createElement(React.Fragment, null);\n const textStyleContent = ctx.getTextStyleContent(cell, contents);\n const fontSize = textStyleContent.fontSize * scale;\n return /* @__PURE__ */ React.createElement(\n ctx.SimpleTextEditor,\n {\n fontSize,\n width: child.width * scale,\n height: child.height * scale,\n color: textStyleContent.color,\n fontFamily: textStyleContent.fontFamily,\n align: (_b = textStyleContent.align) != null ? _b : "center",\n verticalAlign: (_c = textStyleContent.verticalAlign) != null ? _c : "middle",\n lineHeight: textStyleContent.lineHeight ? textStyleContent.lineHeight * scale : void 0,\n onCancel: cancel,\n x: p.x + child.x * scale,\n y: p.y + child.y * scale,\n borderWidth: 0,\n value: cell.text,\n setValue: (v) => update((c) => {\n if (isTableContent(c)) {\n setTableCell(c, row, column, (t) => t.text = v);\n }\n })\n }\n );\n },\n isValid: (c, p) => ctx.validate(c, TableContent, p),\n getRefIds,\n getChildByPoint(content, point, contents, { textStyleId }) {\n var _a;\n const { children } = getGeometries(content, contents);\n const child = children.find((c) => ctx.pointInPolygon(point, c.region));\n if (child) {\n if (!((_a = content.rows[child.row].cells) == null ? void 0 : _a.some((c) => c.column === child.column))) {\n const [, patches, reversePatches] = ctx.produceWithPatches(content, (draft) => {\n const row = draft.rows[child.row];\n if (!row.cells) {\n row.cells = [];\n }\n row.cells.push({\n type: "table cell text",\n textStyleId,\n text: "",\n color: 0,\n fontSize: 16,\n fontFamily: "monospace",\n column: child.column\n });\n });\n return {\n child: [child.row, child.column],\n patches: [patches, reversePatches]\n };\n }\n return {\n child: [child.row, child.column]\n };\n }\n return;\n }\n };\n return [\n tableModel,\n {\n type: "table cell text",\n ...ctx.textModel,\n isValid: (c, p) => ctx.validate(c, TableCellText, p)\n }\n ];\n}\nfunction isTableContent(content) {\n return content.type === "table";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "7,10 91,10", strokeWidth: "4", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "7,10 7,87", strokeWidth: "4", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "35,10 35,87", strokeWidth: "4", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "63,10 63,87", strokeWidth: "4", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "91,10 91,87", strokeWidth: "4", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "7,34 91,34", strokeWidth: "4", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "7,60 91,60", strokeWidth: "4", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "7,87 91,87", strokeWidth: "4", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "create table",\n useCommand({ onEnd, strokeStyleId }) {\n const assistentContents = [];\n const [position, setPosition] = React.useState();\n const newContent = {\n type: "table",\n x: 0,\n y: 0,\n widths: [100, 100, 100],\n rows: [\n { height: 20 },\n { height: 20 },\n { height: 20 },\n { height: 20 }\n ],\n strokeStyleId\n };\n if (position) {\n assistentContents.push({\n ...newContent,\n x: position.x,\n y: position.y\n });\n }\n return {\n onStart(p) {\n onEnd({\n updateContents: (contents) => {\n contents.push({\n ...newContent,\n x: p.x,\n y: p.y\n });\n }\n });\n },\n onMove(p) {\n setPosition(p);\n },\n assistentContents,\n reset() {\n setPosition(void 0);\n }\n };\n },\n selectCount: 0,\n icon\n };\n}\nfunction deleteTableColumn(c, i) {\n c.widths.splice(i, 1);\n if (c.mergedCells) {\n const indexes = [];\n c.mergedCells.forEach((cell, k) => {\n if (i < cell.column[0]) {\n cell.column[0]--;\n } else if (i === cell.column[0]) {\n indexes.unshift(k);\n } else if (i < cell.column[0] + cell.column[1]) {\n cell.column[1]--;\n }\n });\n indexes.forEach((d) => {\n var _a;\n return (_a = c.mergedCells) == null ? void 0 : _a.splice(d, 1);\n });\n }\n}\nfunction deleteTableRow(c, i) {\n c.rows.splice(i, 1);\n if (c.mergedCells) {\n const indexes = [];\n c.mergedCells.forEach((cell, k) => {\n if (i < cell.row[0]) {\n cell.row[0]--;\n } else if (i === cell.row[0]) {\n indexes.unshift(k);\n } else if (i < cell.row[0] + cell.row[1]) {\n cell.row[1]--;\n }\n });\n indexes.forEach((d) => {\n var _a;\n return (_a = c.mergedCells) == null ? void 0 : _a.splice(d, 1);\n });\n }\n}\nfunction setTableRowSpan(c, row, column, v) {\n if (!c.mergedCells) c.mergedCells = [];\n const index = c.mergedCells.findIndex((m) => m.row[0] === row && m.column[0] === column);\n if (index < 0) {\n c.mergedCells.push({ row: [row, v], column: [column, 1] });\n } else if (v <= 1 && c.mergedCells[index].column[1] <= 1) {\n c.mergedCells.splice(index, 1);\n if (c.mergedCells.length === 0) c.mergedCells = void 0;\n } else {\n c.mergedCells[index].row[1] = v;\n }\n}\nfunction setTableColumnSpan(c, row, column, v) {\n if (!c.mergedCells) c.mergedCells = [];\n const index = c.mergedCells.findIndex((m) => m.row[0] === row && m.column[0] === column);\n if (index < 0) {\n c.mergedCells.push({ row: [row, 1], column: [column, v] });\n } else if (v <= 1 && c.mergedCells[index].row[1] <= 1) {\n c.mergedCells.splice(index, 1);\n if (c.mergedCells.length === 0) c.mergedCells = void 0;\n } else {\n c.mergedCells[index].column[1] = v;\n }\n}\nfunction insertTableColumn(c, i) {\n var _a;\n c.widths.splice(i, 0, c.widths[i]);\n (_a = c.mergedCells) == null ? void 0 : _a.forEach((cell) => {\n if (i < cell.column[0]) {\n cell.column[0]++;\n } else if (i < cell.column[0] + cell.column[1] - 1) {\n cell.column[1]++;\n }\n });\n}\nfunction insertTableRow(c, i) {\n var _a;\n c.rows.splice(i, 0, c.rows[i]);\n (_a = c.mergedCells) == null ? void 0 : _a.forEach((cell) => {\n if (i < cell.row[0]) {\n cell.row[0]++;\n } else if (i < cell.row[0] + cell.row[1] - 1) {\n cell.row[1]++;\n }\n });\n}\nfunction setTableCell(c, row, column, update) {\n var _a;\n const t = (_a = c.rows[row].cells) == null ? void 0 : _a.find((c2) => c2.column === column);\n if (t) {\n update(t);\n }\n}\nexport {\n getCommand,\n getModel,\n isTableContent\n};\n','// dev/cad-editor/plugins/text-style.plugin.tsx\nfunction getModel(ctx) {\n const geometriesCache = new ctx.WeakmapCache();\n function getGeometriesFromCache(content) {\n return geometriesCache.get(content, () => {\n var _a, _b;\n const text = `${content.fontFamily} ${content.fontSize} ${ctx.getColorString(content.color)}`;\n const width = (_b = (_a = ctx.getTextSizeFromCache(ctx.getTextStyleFont(content), text)) == null ? void 0 : _a.width) != null ? _b : 0;\n const height = content.fontSize * 1.2;\n const points = ctx.getPolygonFromTwoPointsFormRegion({ start: content, end: { x: content.x + width, y: content.y + height } });\n return {\n lines: [],\n bounding: ctx.getPointsBounding(points),\n text,\n width,\n height,\n regions: [\n {\n points,\n lines: Array.from(ctx.iteratePolygonLines(points))\n }\n ],\n renderingLines: []\n };\n });\n }\n const React = ctx.React;\n return {\n type: "text style",\n ...ctx.textModel,\n move(content, offset) {\n ctx.movePoint(content, offset);\n },\n render(content, { target, transformColor }) {\n const { width, height, text } = getGeometriesFromCache(content);\n return target.renderGroup([\n target.renderRect(content.x, content.y, width, height, {\n strokeColor: transformColor(content.isCurrent ? 16711680 : 0)\n }),\n target.renderText(content.x, content.y, text, content.color, content.fontSize, content.fontFamily, { textBaseline: "top" })\n ]);\n },\n getEditPoints(content) {\n return ctx.getEditPointsFromCache(content, () => {\n return {\n editPoints: [\n {\n ...content,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!ctx.isTextStyleContent(c)) {\n return;\n }\n c.x += cursor.x - start.x;\n c.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n }\n ]\n };\n });\n },\n getGeometries: getGeometriesFromCache,\n propertyPanel(content, update, contents, { acquirePoint }) {\n return {\n isCurrent: /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.isCurrent === true, setValue: (v) => update((c, draft) => {\n if (ctx.isTextStyleContent(c)) {\n const currentTextStyle = ctx.getTextStyles(contents).find((s) => s.content.isCurrent);\n if (currentTextStyle) {\n const c2 = draft[currentTextStyle.index];\n if (c2 && ctx.isTextStyleContent(c2)) {\n c2.isCurrent = void 0;\n }\n }\n c.isCurrent = v ? true : void 0;\n }\n }) }),\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (ctx.isTextStyleContent(c)) {\n c.x = p.x;\n c.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.x, setValue: (v) => update((c) => {\n if (ctx.isTextStyleContent(c)) {\n c.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.y, setValue: (v) => update((c) => {\n if (ctx.isTextStyleContent(c)) {\n c.y = v;\n }\n }) }),\n ...ctx.getTextContentPropertyPanel(content, update)\n };\n },\n isValid: (c, p) => ctx.validate(c, ctx.TextStyleContent, p)\n };\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "6,7 40,7", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "23,7 23,43", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "61,7 82,7", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "72,7 72,26", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "51,49 90,49", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "71,47 71,94", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "11,71 32,71", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "21,71 21,89", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "create text style",\n selectCount: 0,\n icon,\n useCommand({ onEnd, type }) {\n const [result, setResult] = React.useState();\n const reset = () => {\n setResult(void 0);\n };\n return {\n onStart() {\n if (result) {\n onEnd({\n updateContents: (contents) => {\n if (result) {\n contents.push(result);\n }\n }\n });\n reset();\n }\n },\n onMove(p) {\n if (type) {\n setResult({\n type: "text style",\n x: p.x,\n y: p.y,\n fontFamily: "monospace",\n fontSize: 20,\n color: 0\n });\n }\n },\n assistentContents: result ? [result] : void 0,\n reset\n };\n }\n };\n}\nexport {\n getCommand,\n getModel\n};\n','// dev/cad-editor/plugins/text.plugin.tsx\nfunction getModel(ctx) {\n const TextContent = ctx.and(ctx.BaseContent("text"), ctx.Position, ctx.TextFields, {\n text: ctx.string,\n width: ctx.optional(ctx.number),\n textVariableName: ctx.optional(ctx.string),\n angle: ctx.optional(ctx.number),\n scale: ctx.optional(ctx.or(ctx.number, ctx.Position))\n });\n const getRefIds = (content) => ctx.toRefId(content.textStyleId);\n const textLayoutResultCache = new ctx.WeakmapCache2();\n function getTextLayoutResult(content, c, variableContext) {\n return textLayoutResultCache.get(content, c, () => {\n var _a;\n const state = getText(content, variableContext).split("");\n const getTextWidth = (text) => {\n var _a2, _b;\n return (_b = (_a2 = ctx.getTextSizeFromCache(ctx.getTextStyleFont(c), text)) == null ? void 0 : _a2.width) != null ? _b : 0;\n };\n return ctx.flowLayout({\n state,\n width: content.width,\n lineHeight: (_a = c.lineHeight) != null ? _a : c.fontSize * 1.2,\n getWidth: getTextWidth,\n align: c.align,\n endContent: "",\n isNewLineContent: (c2) => c2 === "\\n",\n isPartOfComposition: (c2) => ctx.isWordCharactor(c2),\n getComposition: (index) => ctx.getTextComposition(index, state, getTextWidth, (c2) => c2)\n });\n });\n }\n function hasWidth(content) {\n return content.width !== void 0;\n }\n function getText(content, variableContext) {\n if (content.textVariableName && variableContext) {\n const text = variableContext[content.textVariableName];\n if (typeof text === "string") {\n return text;\n }\n }\n return content.text;\n }\n function getTextGeometries(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return ctx.getGeometriesFromCache(content, refs, () => {\n let points;\n if (hasWidth(content)) {\n const textStyleContent = ctx.getTextStyleContent(content, contents);\n const { newContentHeight } = getTextLayoutResult(content, textStyleContent);\n points = [\n { x: content.x, y: content.y + newContentHeight },\n { x: content.x + content.width, y: content.y + newContentHeight },\n { x: content.x + content.width, y: content.y },\n { x: content.x, y: content.y }\n ];\n } else {\n const size = ctx.getTextSize(ctx.getTextStyleFont(content), content.text);\n if (!size) {\n throw "not supported";\n }\n points = [\n { x: content.x, y: content.y - size.height },\n { x: content.x + size.width, y: content.y - size.height },\n { x: content.x + size.width, y: content.y },\n { x: content.x, y: content.y }\n ];\n }\n const scale = ctx.getScaleOptionsScale(content);\n if (scale) {\n for (const p of points) {\n ctx.scalePoint(p, content, scale.x, scale.y);\n }\n }\n if (content.angle) {\n for (const p of points) {\n ctx.rotatePoint(p, content, content.angle);\n }\n }\n const lines = Array.from(ctx.iteratePolygonLines(points));\n return {\n lines: [],\n bounding: ctx.getPointsBounding(points),\n regions: [\n {\n lines,\n points\n }\n ],\n renderingLines: []\n };\n });\n }\n const React = ctx.React;\n return {\n type: "text",\n ...ctx.textModel,\n move(content, offset) {\n ctx.movePoint(content, offset);\n },\n rotate(content, center, angle) {\n var _a;\n ctx.rotatePoint(content, center, angle);\n content.angle = ((_a = content.angle) != null ? _a : 0) + angle;\n },\n scale(content, center, sx, sy) {\n var _a, _b;\n ctx.scalePoint(content, center, sx, sy);\n const scale = ctx.getScaleOptionsScale(content);\n content.scale = {\n x: ((_a = scale == null ? void 0 : scale.x) != null ? _a : 1) * sx,\n y: ((_b = scale == null ? void 0 : scale.y) != null ? _b : 1) * sy\n };\n },\n mirror(content, line, angle) {\n var _a, _b, _c;\n ctx.mirrorPoint(content, line);\n content.angle = 2 * angle - ((_a = content.angle) != null ? _a : 0);\n const scale = ctx.getScaleOptionsScale(content);\n content.scale = {\n x: (_b = scale == null ? void 0 : scale.x) != null ? _b : 1,\n y: -((_c = scale == null ? void 0 : scale.y) != null ? _c : 1)\n };\n },\n getEditPoints(content) {\n return ctx.getEditPointsFromCache(content, () => {\n return {\n editPoints: [\n {\n x: content.x,\n y: content.y,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isTextContent(c)) {\n return;\n }\n c.x += cursor.x - start.x;\n c.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [content, cursor] }] };\n }\n },\n {\n x: content.x,\n y: content.y + content.fontSize * (content.width ? 1 : -1),\n cursor: "move",\n update(c, { cursor, scale }) {\n if (!isTextContent(c)) {\n return;\n }\n c.fontSize = Math.abs(cursor.y - content.y);\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [content, cursor] }] };\n }\n },\n ...content.width ? [{\n x: content.x + content.width,\n y: content.y,\n cursor: "move",\n update(c, { cursor, scale }) {\n if (!isTextContent(c)) {\n return;\n }\n c.width = Math.abs(cursor.x - content.x);\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [content, cursor] }] };\n }\n }] : []\n ]\n };\n });\n },\n render(content, renderCtx) {\n var _a, _b;\n const { contents, transformColor, variableContext, isAssistence, target } = renderCtx;\n const textStyleContent = ctx.getTextStyleContent(content, contents);\n const color = transformColor(textStyleContent.color);\n const text = getText(content, variableContext);\n let cacheKey;\n if (isAssistence) {\n cacheKey = ctx.assistentTextCache.get(text, textStyleContent.fontSize, textStyleContent.color);\n }\n if (!cacheKey) {\n cacheKey = content;\n }\n const textOptions = ctx.getTextStyleRenderOptionsFromRenderContext(color, renderCtx);\n const children = [];\n if (hasWidth(content)) {\n const { layoutResult } = getTextLayoutResult(content, textStyleContent, variableContext);\n for (const { x, y, content: text2 } of layoutResult) {\n const textWidth = (_b = (_a = ctx.getTextSizeFromCache(ctx.getTextStyleFont(textStyleContent), text2)) == null ? void 0 : _a.width) != null ? _b : 0;\n children.push(target.renderText(content.x + x + textWidth / 2, content.y + y + textStyleContent.fontSize, text2, textStyleContent.color, textStyleContent.fontSize, textStyleContent.fontFamily, { textAlign: "center", cacheKey, ...textOptions }));\n }\n } else {\n children.push(target.renderText(content.x, content.y, text, color, textStyleContent.fontSize, textStyleContent.fontFamily, { cacheKey, ...textOptions }));\n }\n return target.renderGroup(children, { base: content, angle: content.angle, scale: content.scale });\n },\n getGeometries: getTextGeometries,\n propertyPanel(content, update, contents, { acquirePoint }) {\n var _a, _b, _c;\n const scale = ctx.getScaleOptionsScale(content);\n return {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isTextContent(c)) {\n c.x = p.x;\n c.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.x, setValue: (v) => update((c) => {\n if (isTextContent(c)) {\n c.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.y, setValue: (v) => update((c) => {\n if (isTextContent(c)) {\n c.y = v;\n }\n }) }),\n ...ctx.getTextContentPropertyPanel(content, update, contents),\n text: /* @__PURE__ */ React.createElement(ctx.StringEditor, { textarea: true, value: content.text, setValue: (v) => update((c) => {\n if (isTextContent(c)) {\n c.text = v;\n }\n }) }),\n width: [\n /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.width !== void 0, setValue: (v) => update((c) => {\n if (isTextContent(c)) {\n c.width = v ? 600 : void 0;\n }\n }) }),\n content.width !== void 0 ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.width, setValue: (v) => update((c) => {\n if (isTextContent(c)) {\n c.width = v;\n }\n }) }) : void 0\n ],\n textVariableName: [\n /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.textVariableName !== void 0, setValue: (v) => update((c) => {\n if (isTextContent(c)) {\n c.textVariableName = v ? "" : void 0;\n }\n }) }),\n content.textVariableName !== void 0 ? /* @__PURE__ */ React.createElement(ctx.StringEditor, { value: content.textVariableName, setValue: (v) => update((c) => {\n if (isTextContent(c)) {\n c.textVariableName = v;\n }\n }) }) : void 0\n ],\n angle: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: (_a = content.angle) != null ? _a : 0, setValue: (v) => update((c) => {\n if (isTextContent(c)) {\n c.angle = v;\n }\n }) }),\n sx: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: (_b = scale == null ? void 0 : scale.x) != null ? _b : 1, setValue: (v) => update((c) => {\n var _a2;\n if (isTextContent(c)) {\n c.scale = { x: v, y: (_a2 = scale == null ? void 0 : scale.y) != null ? _a2 : v };\n }\n }) }),\n sy: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: (_c = scale == null ? void 0 : scale.y) != null ? _c : 1, setValue: (v) => update((c) => {\n var _a2;\n if (isTextContent(c)) {\n c.scale = { x: (_a2 = scale == null ? void 0 : scale.x) != null ? _a2 : v, y: v };\n }\n }) })\n };\n },\n editPanel(content, scale, update, contents, cancel, transformPosition) {\n const p = transformPosition(content);\n const textStyleContent = ctx.getTextStyleContent(content, contents);\n const fontSize = textStyleContent.fontSize * scale;\n if (content.width) {\n return /* @__PURE__ */ React.createElement(\n ctx.SimpleTextEditor,\n {\n fontSize,\n width: content.width * scale,\n color: textStyleContent.color,\n fontFamily: textStyleContent.fontFamily,\n align: textStyleContent.align,\n lineHeight: textStyleContent.lineHeight ? textStyleContent.lineHeight * scale : void 0,\n onCancel: cancel,\n x: p.x,\n y: p.y,\n value: content.text,\n setValue: (v) => update((c) => {\n if (isTextContent(c)) {\n c.text = v;\n }\n })\n }\n );\n }\n return /* @__PURE__ */ React.createElement(ctx.StringEditor, { style: {\n zIndex: 10,\n position: "absolute",\n left: `${p.x - 1}px`,\n top: `${p.y - fontSize - 1}px`,\n fontSize: `${fontSize}px`,\n fontFamily: content.fontFamily,\n color: ctx.getColorString(content.color),\n padding: "0px"\n }, textarea: true, autoFocus: true, onCancel: cancel, value: content.text, setValue: (v) => update((c) => {\n if (isTextContent(c)) {\n c.text = v;\n }\n }) });\n },\n isValid: (c, p) => ctx.validate(c, TextContent, p),\n getRefIds,\n updateRefId: ctx.updateTextStyleRefIds,\n deleteRefId: ctx.deleteTextStyleRefIds,\n getVariableNames: (content) => content.textVariableName ? [content.textVariableName] : []\n };\n}\nfunction isTextContent(content) {\n return content.type === "text";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "16,22 83,22", strokeWidth: "10", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "49,22 49,89", strokeWidth: "10", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "create text",\n icon,\n useCommand({ onEnd, type, scale, textStyleId, transformPosition, contents }) {\n const [start, setStart] = React.useState();\n const [cursor, setCursor] = React.useState();\n const [text, setText] = React.useState();\n const reset = () => {\n setText(void 0);\n setStart(void 0);\n setCursor(void 0);\n };\n const assistentContents = [];\n let panel;\n if (type) {\n if (text) {\n assistentContents.push(text);\n const p = transformPosition(text);\n const textStyleContent = ctx.getTextStyleContent(text, contents);\n const fontSize = textStyleContent.fontSize * scale;\n if (text.width) {\n panel = /* @__PURE__ */ React.createElement(\n ctx.SimpleTextEditor,\n {\n fontSize,\n width: text.width * scale,\n color: textStyleContent.color,\n fontFamily: textStyleContent.fontFamily,\n align: textStyleContent.align,\n lineHeight: textStyleContent.lineHeight ? textStyleContent.lineHeight * scale : void 0,\n onCancel: reset,\n x: p.x,\n y: p.y,\n value: text.text,\n setValue: (v) => setText({\n ...text,\n text: v\n })\n }\n );\n }\n } else if (cursor) {\n if (start) {\n assistentContents.push({ type: "polygon", points: ctx.getPolygonFromTwoPointsFormRegion(ctx.getTwoPointsFormRegion(start, cursor)), dashArray: [4 / scale] });\n assistentContents.push({\n type: "text",\n text: "abc",\n textStyleId,\n color: 0,\n fontSize: 16 / scale,\n fontFamily: "monospace",\n x: Math.min(start.x, cursor.x),\n y: Math.min(start.y, cursor.y),\n width: Math.abs(start.x - cursor.x)\n });\n } else {\n assistentContents.push({\n type: "text",\n text: "abc",\n textStyleId,\n color: 0,\n fontSize: 16 / scale,\n fontFamily: "monospace",\n x: cursor.x,\n y: cursor.y,\n width: 100\n });\n }\n }\n }\n return {\n onStart: (p) => {\n if (!type) return;\n if (text) {\n onEnd({ updateContents: (contents2) => contents2.push(text) });\n reset();\n return;\n }\n if (start) {\n setText({\n type: "text",\n text: "",\n textStyleId,\n color: 0,\n fontSize: 16 / scale,\n fontFamily: "monospace",\n x: Math.min(start.x, p.x),\n y: Math.min(start.y, p.y),\n width: Math.abs(start.x - p.x)\n });\n } else {\n setStart(p);\n }\n },\n onMove: (p) => {\n if (!type) return;\n setCursor(p);\n },\n assistentContents,\n reset,\n panel\n };\n },\n selectCount: 0,\n hotkey: "T"\n };\n}\nexport {\n getCommand,\n getModel,\n isTextContent\n};\n','// dev/cad-editor/plugins/time-axis.plugin.tsx\nfunction getModel(ctx) {\n const TimeAxisContent = ctx.and(ctx.BaseContent("time axis"), ctx.StrokeFields, ctx.ArrowFields, ctx.Position, {\n max: ctx.number\n });\n const getRefIds = (content) => ctx.toRefId(content.strokeStyleId);\n function getGeometriesFromCache(content, contents, time) {\n const getGeometries = () => {\n const { arrowPoints, endPoint } = ctx.getArrowPoints(content, { x: content.x + content.max / 10, y: content.y }, content);\n const points = [content, endPoint];\n const result = {\n lines: Array.from(ctx.iteratePolylineLines(points)),\n bounding: ctx.getPointsBounding(points),\n regions: [\n {\n points: arrowPoints,\n lines: Array.from(ctx.iteratePolygonLines(arrowPoints))\n }\n ],\n renderingLines: ctx.dashedPolylineToLines(points, content.dashArray)\n };\n if (time) {\n const timePoints = ctx.arcToPolyline(ctx.circleToArc({ x: content.x + time / 10, y: content.y, r: 5 }), ctx.defaultAngleDelta);\n result.regions.push({\n points: timePoints,\n lines: Array.from(ctx.iteratePolygonLines(timePoints))\n });\n }\n return result;\n };\n if (time) {\n return getGeometries();\n }\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return ctx.getGeometriesFromCache(content, refs, getGeometries);\n }\n const React = ctx.React;\n return {\n type: "time axis",\n ...ctx.strokeModel,\n ...ctx.arrowModel,\n move(content, offset) {\n ctx.movePoint(content, offset);\n },\n render(content, renderCtx) {\n const { options, contents, time, target, fillOptions } = ctx.getStrokeRenderOptionsFromRenderContext(content, renderCtx);\n const { regions, renderingLines } = getGeometriesFromCache(content, contents, time);\n const children = [];\n for (const line of renderingLines) {\n children.push(target.renderPolyline(line, options));\n }\n if (regions) {\n for (let i = 0; i < regions.length; i++) {\n children.push(target.renderPolygon(regions[i].points, fillOptions));\n }\n }\n return target.renderGroup(children);\n },\n getEditPoints(content) {\n return ctx.getEditPointsFromCache(content, () => {\n return {\n editPoints: [\n {\n ...content,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isTimeAxisContent(c)) {\n return;\n }\n c.x += cursor.x - start.x;\n c.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n }\n ]\n };\n });\n },\n getGeometries: getGeometriesFromCache,\n propertyPanel(content, update, contents, { startTime, acquirePoint }) {\n return {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isTimeAxisContent(c)) {\n c.x = p.x;\n c.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.x, setValue: (v) => update((c) => {\n if (isTimeAxisContent(c)) {\n c.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.y, setValue: (v) => update((c) => {\n if (isTimeAxisContent(c)) {\n c.y = v;\n }\n }) }),\n max: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.max, setValue: (v) => update((c) => {\n if (isTimeAxisContent(c) && v > 0) {\n c.max = v;\n }\n }) }),\n action: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => startTime(content.max) }, "start"),\n ...ctx.getArrowContentPropertyPanel(content, update),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents)\n };\n },\n isValid: (c, p) => ctx.validate(c, TimeAxisContent, p),\n getRefIds,\n updateRefId: ctx.updateStrokeRefIds,\n deleteRefId: ctx.deleteStrokeRefIds\n };\n}\nfunction isTimeAxisContent(content) {\n return content.type === "time axis";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("g", { transform: "" }, /* @__PURE__ */ React.createElement("polyline", { points: "3,52 90,53", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "99,53 70,60 70,45", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" })));\n return {\n name: "create time axis",\n selectCount: 0,\n icon,\n useCommand({ onEnd, type }) {\n const [result, setResult] = React.useState();\n const reset = () => {\n setResult(void 0);\n };\n return {\n onStart() {\n if (result) {\n onEnd({\n updateContents: (contents) => {\n if (result) {\n contents.push(result);\n }\n }\n });\n reset();\n }\n },\n onMove(p) {\n if (type) {\n setResult({\n type: "time axis",\n x: p.x,\n y: p.y,\n max: 5e3\n });\n }\n },\n assistentContents: result ? [result] : void 0,\n reset\n };\n }\n };\n}\nexport {\n getCommand,\n getModel,\n isTimeAxisContent\n};\n','// dev/cad-editor/plugins/hatch.plugin.tsx\nfunction isHatchContent(content) {\n return content.type === "hatch";\n}\n\n// dev/cad-editor/plugins/trim.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { viewBox: "64 64 896 896", width: "1em", height: "1em", fill: "currentColor" }, /* @__PURE__ */ React.createElement("path", { d: "M567.1 512l318.5-319.3c5-5 1.5-13.7-5.6-13.7h-90.5c-2.1 0-4.2.8-5.6 2.3l-273.3 274-90.2-90.5c12.5-22.1 19.7-47.6 19.7-74.8 0-83.9-68.1-152-152-152s-152 68.1-152 152 68.1 152 152 152c27.7 0 53.6-7.4 75.9-20.3l90 90.3-90.1 90.3A151.04 151.04 0 00288 582c-83.9 0-152 68.1-152 152s68.1 152 152 152 152-68.1 152-152c0-27.2-7.2-52.7-19.7-74.8l90.2-90.5 273.3 274c1.5 1.5 3.5 2.3 5.6 2.3H880c7.1 0 10.7-8.6 5.6-13.7L567.1 512zM288 370c-44.1 0-80-35.9-80-80s35.9-80 80-80 80 35.9 80 80-35.9 80-80 80zm0 444c-44.1 0-80-35.9-80-80s35.9-80 80-80 80 35.9 80 80-35.9 80-80 80z" }));\n return {\n name: "trim",\n useCommand({ onEnd, type, selected, backgroundColor, contents, getContentsInRange }) {\n const [candidates, setCandidates] = React.useState([]);\n const [currents, setCurrents] = React.useState([]);\n const [trackPoints, setTrackPoints] = React.useState([]);\n const { state, setState, resetHistory, undo, redo } = ctx.useUndoRedo([]);\n React.useEffect(() => {\n var _a, _b;\n if (type) {\n const allContents = [];\n for (let i = 0; i < selected.length; i++) {\n const content = selected[i].content;\n let intersectionPoints = [];\n for (let j = 0; j < selected.length; j++) {\n const c = selected[j].content;\n if (c && i !== j) {\n const p = i < j ? [c, content] : [content, c];\n intersectionPoints.push(...ctx.getIntersectionPoints(...p, contents));\n }\n }\n intersectionPoints = ctx.deduplicatePosition(intersectionPoints);\n if (intersectionPoints.length > 0) {\n const result = (_b = (_a = ctx.getContentModel(content)) == null ? void 0 : _a.break) == null ? void 0 : _b.call(_a, content, intersectionPoints, contents);\n if (result) {\n allContents.push({ content, children: result });\n }\n } else {\n allContents.push({ content, children: [content] });\n }\n }\n setCandidates(allContents);\n }\n }, [type]);\n const assistentContents = [];\n const collectAssistentContent = (child) => {\n var _a;\n if (ctx.isStrokeContent(child)) {\n assistentContents.push({\n ...child,\n strokeWidth: ((_a = child.strokeWidth) != null ? _a : ctx.getDefaultStrokeWidth(child)) + 2,\n strokeColor: backgroundColor,\n trueStrokeColor: true\n });\n } else if (isHatchContent(child)) {\n assistentContents.push({\n ...child,\n fillPattern: void 0,\n fillColor: backgroundColor,\n trueFillColor: true\n });\n }\n };\n for (const current of currents) {\n for (const child of current.children) {\n collectAssistentContent(child);\n }\n }\n if (trackPoints.length > 1) {\n assistentContents.push({ points: trackPoints, type: "polyline" });\n }\n for (const { children } of state) {\n for (const child of children) {\n collectAssistentContent(child);\n }\n }\n const reset = () => {\n setCandidates([]);\n setCurrents([]);\n resetHistory();\n setTrackPoints([]);\n };\n return {\n onStart() {\n if (currents.length > 0) {\n setState((draft) => {\n for (const current of currents) {\n const index = state.findIndex((s) => s.content === current.content);\n if (index >= 0) {\n draft[index].children.push(...current.children);\n } else {\n draft.push(current);\n }\n }\n });\n }\n setTrackPoints([]);\n },\n onMouseDown(p) {\n if (currents.length === 0) {\n setTrackPoints([p]);\n }\n },\n onMove(p) {\n var _a, _b, _c, _d;\n if (trackPoints.length > 0) {\n const newTracePoints = [...trackPoints, p];\n if (newTracePoints.length > 1) {\n const trackLines = Array.from(ctx.iteratePolylineLines(newTracePoints));\n const newCurrents = [];\n for (const candidate of candidates) {\n for (const child of candidate.children) {\n const geometries = (_b = (_a = ctx.getContentModel(child)) == null ? void 0 : _a.getGeometries) == null ? void 0 : _b.call(_a, child, contents);\n if (geometries) {\n for (const line of geometries.lines) {\n if (trackLines.some((t) => ctx.getTwoGeometryLinesIntersectionPoint(line, t).length > 0)) {\n const index = newCurrents.findIndex((s) => s.content === candidate.content);\n if (index >= 0) {\n newCurrents[index].children.push(child);\n } else {\n newCurrents.push({ content: candidate.content, children: [child] });\n }\n break;\n }\n }\n }\n }\n }\n setCurrents(newCurrents);\n }\n setTrackPoints(newTracePoints);\n return;\n }\n for (const candidate of candidates) {\n for (const child of candidate.children) {\n const geometries = (_d = (_c = ctx.getContentModel(child)) == null ? void 0 : _c.getGeometries) == null ? void 0 : _d.call(_c, child, contents);\n if (geometries) {\n if (isHatchContent(child) && geometries.regions && geometries.bounding) {\n for (const region of geometries.regions) {\n if (region.holesPoints && region.holesPoints.some((h) => ctx.pointInPolygon(p, h))) {\n continue;\n }\n if (ctx.pointInPolygon(p, region.points)) {\n const getGeometriesInRange = (region2) => getContentsInRange(region2).map((c) => ctx.getContentHatchGeometries(c, contents));\n const border = ctx.getHatchByPosition(p, (line) => getGeometriesInRange(ctx.getGeometryLineBoundingFromCache(line)), geometries.bounding.end.x);\n if (border) {\n const holes = ctx.getHatchHoles(border.lines, getGeometriesInRange);\n setCurrents([{\n children: [{\n type: "hatch",\n border: border.lines,\n holes: holes == null ? void 0 : holes.holes,\n ref: {\n point: p,\n ids: [...border.ids, ...(holes == null ? void 0 : holes.ids) || []]\n }\n }],\n content: candidate.content\n }]);\n }\n return;\n }\n }\n }\n for (const line of geometries.lines) {\n if (ctx.getPointAndGeometryLineMinimumDistance(p, line) < 5) {\n setCurrents([{ children: [child], content: candidate.content }]);\n return;\n }\n }\n }\n }\n }\n setCurrents([]);\n },\n onKeyDown(e) {\n var _a, _b;\n if (e.code === "KeyZ" && ctx.metaKeyIfMacElseCtrlKey(e)) {\n if (e.shiftKey) {\n redo(e);\n } else {\n undo(e);\n }\n } else if (e.key === "Enter") {\n if (!type) return;\n const removedIndexes = [];\n const newContents = [];\n for (const { content, children } of state) {\n const parentModel = ctx.getContentModel(content);\n if (parentModel == null ? void 0 : parentModel.break) {\n let points = [];\n for (const child of children) {\n const geometries = (_b = (_a = ctx.getContentModel(child)) == null ? void 0 : _a.getGeometries) == null ? void 0 : _b.call(_a, child, contents);\n if (geometries) {\n const { start, end } = ctx.getGeometryLinesStartAndEnd(geometries.lines);\n if (start && end) {\n if (!ctx.isSamePoint(start, end)) {\n points.push(start, end);\n }\n } else if (start) {\n points.push(start);\n } else if (end) {\n points.push(end);\n }\n }\n }\n points = ctx.deduplicatePosition(points);\n const r = parentModel.break(content, points, contents);\n if (r) {\n removedIndexes.push(ctx.getContentIndex(content, contents));\n newContents.push(...r.filter((c) => children.every((f) => !ctx.deepEquals(f, c))));\n }\n } else if (isHatchContent(content)) {\n const holes = [];\n const ids = [];\n if (content.ref) {\n ids.push(...content.ref.ids);\n }\n const borders = [content.border];\n if (content.holes) {\n holes.push(...content.holes);\n }\n for (const child of children) {\n if (isHatchContent(child)) {\n holes.push(child.border);\n if (child.holes) {\n borders.push(...child.holes);\n }\n if (child.ref) {\n ids.push(...child.ref.ids);\n }\n }\n }\n removedIndexes.push(ctx.getContentIndex(content, contents));\n const result = borders.map((b) => {\n const polygon = ctx.getGeometryLinesPoints(b);\n return ctx.optimizeHatch(b, holes.filter((h) => {\n const start = ctx.getGeometryLineStartAndEnd(h[0]).start;\n return start && (ctx.pointIsOnGeometryLines(start, b) || ctx.pointInPolygon(start, polygon));\n }));\n }).flat();\n newContents.push(...result.map((r) => {\n let ref;\n if (content.ref) {\n const p = content.ref.point;\n if (ctx.pointInPolygon(p, ctx.getGeometryLinesPoints(r.border)) && r.holes.every((h) => !ctx.pointInPolygon(p, ctx.getGeometryLinesPoints(h)))) {\n ref = {\n point: p,\n ids: Array.from(new Set(ids))\n };\n }\n }\n return { ...content, border: r.border, holes: r.holes, ref };\n }));\n }\n }\n onEnd({\n updateContents: (contents2) => {\n ctx.deleteSelectedContents(contents2, removedIndexes);\n contents2.push(...newContents);\n }\n });\n reset();\n }\n },\n assistentContents,\n reset\n };\n },\n contentSelectable(content, contents) {\n return ctx.contentIsDeletable(content, contents);\n },\n hotkey: "TR",\n icon,\n pointSnapDisabled: true\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/union.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("circle", { cx: "32", cy: "50", r: "32", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "65", cy: "50", r: "32", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("pattern", { id: "union", patternUnits: "userSpaceOnUse", width: "10", height: "10" }, /* @__PURE__ */ React.createElement("path", { d: "M 0 5 L 5 0 M 10 5 L 5 10", strokeWidth: "1", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor", fillRule: "evenodd" })), /* @__PURE__ */ React.createElement("path", { d: "M 50 78 L 47 79 L 45 81 L 42 81 L 39 82 L 37 82 L 34 82 L 31 82 L 28 82 L 25 81 L 23 81 L 20 79 L 18 78 L 15 77 L 13 75 L 11 73 L 9 71 L 7 69 L 6 66 L 4 64 L 3 61 L 2 58 L 2 56 L 1 53 L 1 50 L 1 47 L 2 44 L 2 42 L 3 39 L 4 36 L 6 34 L 7 31 L 9 29 L 11 27 L 13 25 L 15 23 L 18 22 L 20 21 L 23 19 L 25 19 L 28 18 L 31 18 L 34 18 L 37 18 L 39 18 L 42 19 L 45 19 L 47 21 L 50 22 L 50 22 L 53 21 L 55 19 L 58 19 L 61 18 L 63 18 L 66 18 L 69 18 L 72 18 L 75 19 L 77 19 L 80 21 L 82 22 L 85 23 L 87 25 L 89 27 L 91 29 L 93 31 L 94 34 L 96 36 L 97 39 L 98 42 L 98 44 L 99 47 L 99 50 L 99 53 L 98 56 L 98 58 L 97 61 L 96 64 L 94 66 L 93 69 L 91 71 L 89 73 L 87 75 L 85 77 L 82 78 L 80 79 L 77 81 L 75 81 L 72 82 L 69 82 L 66 82 L 63 82 L 61 82 L 58 81 L 55 81 L 53 79 L 50 78", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", fill: "url(#union)", stroke: "currentColor", fillRule: "evenodd" }));\n return {\n name: "union",\n execute({ contents, selected }) {\n var _a, _b, _c, _d;\n const first = contents[selected[0][0]];\n if (!first) return;\n const firstGeometries = (_b = (_a = ctx.getContentModel(first)) == null ? void 0 : _a.getGeometries) == null ? void 0 : _b.call(_a, first, contents);\n if (!firstGeometries) return;\n const second = contents[selected[1][0]];\n if (!second) return;\n const secondGeometries = (_d = (_c = ctx.getContentModel(second)) == null ? void 0 : _c.getGeometries) == null ? void 0 : _d.call(_c, second, contents);\n if (!secondGeometries) return;\n if (firstGeometries.regions && secondGeometries.regions) {\n const result = firstGeometries.regions.map((r) => ctx.getHatchesUnion({ border: r.lines, holes: r.holes || [] }, (secondGeometries.regions || []).map((g) => ({ border: g.lines, holes: g.holes || [] })))).flat();\n ctx.deleteSelectedContents(contents, selected.map((s) => s[0]));\n contents.push(...result.map((r) => ({ ...first, type: "hatch", border: r.border, holes: r.holes, ref: void 0 })));\n return;\n }\n const lines = ctx.mergeItems([...firstGeometries.lines, ...secondGeometries.lines], ctx.getTwoGeometryLinesUnionLine);\n ctx.deleteSelectedContents(contents, selected.map((s) => s[0]));\n const allLines = ctx.getSeparatedGeometryLines(lines);\n contents.push(...allLines.map((n) => ({ type: "geometry lines", lines: n })));\n },\n contentSelectable(content, contents) {\n return ctx.contentIsDeletable(content, contents);\n },\n selectCount: 2,\n icon\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/viewport.plugin.tsx\nfunction getModel(ctx) {\n const getRefIds = (content) => [...ctx.getStrokeRefIds(content), ...ctx.toRefId(content.border, true)];\n function getViewportGeometriesFromCache(content, contents) {\n var _a, _b;\n const geometries = (_b = (_a = ctx.getContentModel(content.border)) == null ? void 0 : _a.getGeometries) == null ? void 0 : _b.call(_a, content.border, contents);\n if (geometries) {\n return geometries;\n }\n return { lines: [], renderingLines: [] };\n }\n const renderCache = new ctx.WeakmapMapCache();\n const React = ctx.React;\n return {\n type: "viewport",\n ...ctx.strokeModel,\n ...ctx.arrowModel,\n move(content, offset) {\n var _a, _b;\n (_b = (_a = ctx.getContentModel(content.border)) == null ? void 0 : _a.move) == null ? void 0 : _b.call(_a, content.border, offset);\n ctx.movePoint(content, offset);\n },\n rotate(content, center, angle, contents) {\n var _a, _b;\n (_b = (_a = ctx.getContentModel(content.border)) == null ? void 0 : _a.rotate) == null ? void 0 : _b.call(_a, content.border, center, angle, contents);\n },\n scale(content, center, sx, sy, contents) {\n var _a, _b;\n return (_b = (_a = ctx.getContentModel(content.border)) == null ? void 0 : _a.scale) == null ? void 0 : _b.call(_a, content.border, center, sx, sy, contents);\n },\n skew(content, center, sx, sy, contents) {\n var _a, _b;\n return (_b = (_a = ctx.getContentModel(content.border)) == null ? void 0 : _a.skew) == null ? void 0 : _b.call(_a, content.border, center, sx, sy, contents);\n },\n mirror(content, line, angle, contents) {\n var _a, _b;\n (_b = (_a = ctx.getContentModel(content.border)) == null ? void 0 : _a.mirror) == null ? void 0 : _b.call(_a, content.border, line, angle, contents);\n },\n render(content, renderCtx) {\n var _a;\n const render = (_a = ctx.getContentModel(content.border)) == null ? void 0 : _a.render;\n if (render) {\n return render(content.border, {\n ...renderCtx,\n clip: renderCtx.isHoveringOrSelected || content.hidden ? void 0 : () => {\n const sortedContents = ctx.getSortedContents(renderCtx.contents).contents;\n const children = renderCache.get(sortedContents, renderCtx.target.type, () => {\n const children2 = [];\n sortedContents.forEach((content2) => {\n var _a2;\n if (!content2 || content2.visible === false || ctx.isViewportContent(content2)) {\n return;\n }\n const ContentRender = (_a2 = ctx.getContentModel(content2)) == null ? void 0 : _a2.render;\n if (ContentRender) {\n children2.push(ContentRender(content2, renderCtx));\n }\n });\n return children2;\n });\n return renderCtx.target.renderGroup(children, { matrix: ctx.getViewportMatrix(content) });\n }\n });\n }\n return renderCtx.target.renderEmpty();\n },\n getEditPoints(content, contents) {\n var _a, _b;\n const editPoints = (_b = (_a = ctx.getContentModel(content.border)) == null ? void 0 : _a.getEditPoints) == null ? void 0 : _b.call(_a, content.border, contents);\n if (!editPoints) return;\n return ctx.getEditPointsFromCache(content, () => {\n return {\n ...editPoints,\n editPoints: editPoints.editPoints.map((e) => ({\n ...e,\n update(c, props) {\n var _a2;\n if (!ctx.isViewportContent(c)) {\n return;\n }\n if (e.type === "move") {\n c.x += props.cursor.x - props.start.x;\n c.y += props.cursor.y - props.start.y;\n }\n return (_a2 = e.update) == null ? void 0 : _a2.call(e, c.border, props);\n }\n }))\n };\n });\n },\n getGeometries: getViewportGeometriesFromCache,\n propertyPanel(content, update, contents, options) {\n var _a, _b;\n const border = (_b = (_a = ctx.getContentModel(content.border)) == null ? void 0 : _a.propertyPanel) == null ? void 0 : _b.call(_a, content.border, (recipe) => {\n update((c) => {\n if (ctx.isViewportContent(c)) {\n recipe(c.border, contents);\n }\n });\n }, contents, options);\n const result = {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => options.acquirePoint((p) => update((c) => {\n if (ctx.isViewportContent(c)) {\n c.x = p.x;\n c.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.x, setValue: (v) => update((c) => {\n if (ctx.isViewportContent(c)) {\n c.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.y, setValue: (v) => update((c) => {\n if (ctx.isViewportContent(c)) {\n c.y = v;\n }\n }) }),\n scale: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.scale, setValue: (v) => update((c) => {\n if (ctx.isViewportContent(c)) {\n c.scale = v;\n }\n }) }),\n rotate: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.rotate || 0, setValue: (v) => update((c) => {\n if (ctx.isViewportContent(c)) {\n c.rotate = v;\n }\n }) }),\n locked: /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.locked || false, setValue: (v) => update((c) => {\n if (ctx.isViewportContent(c)) {\n c.locked = v;\n }\n }) }),\n hidden: /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.hidden || false, setValue: (v) => update((c) => {\n if (ctx.isViewportContent(c)) {\n c.hidden = v;\n }\n }) })\n };\n if (border) {\n result.border = /* @__PURE__ */ React.createElement(ctx.ObjectEditor, { properties: border });\n }\n return {\n ...result,\n ...ctx.getStrokeContentPropertyPanel(content, update, contents)\n };\n },\n isValid: (c, p) => ctx.validate(c, ctx.ViewportContent, p),\n getRefIds,\n updateRefId: ctx.updateStrokeRefIds,\n deleteRefId: ctx.deleteStrokeRefIds\n };\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("rect", { x: "14", y: "18", width: "71", height: "71", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("g", { transform: "" }, /* @__PURE__ */ React.createElement("polyline", { points: "47,55 78,24", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "85,18 70,43 59,32", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" })), /* @__PURE__ */ React.createElement("g", { transform: "" }, /* @__PURE__ */ React.createElement("polyline", { points: "47,55 20,82", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "14,89 29,62 40,73", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" })), /* @__PURE__ */ React.createElement("g", { transform: "" }, /* @__PURE__ */ React.createElement("polyline", { points: "47,54 78,82", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "85,89 58,75 69,63", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" })), /* @__PURE__ */ React.createElement("g", { transform: "" }, /* @__PURE__ */ React.createElement("polyline", { points: "47,55 20,25", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "14,18 39,34 27,44", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" })));\n return {\n name: "create viewport",\n selectCount: 1,\n icon,\n contentSelectable(content) {\n return ctx.contentIsClosedPath(content);\n },\n execute({ contents, selected }) {\n contents.forEach((content, index) => {\n var _a, _b;\n if (content && ctx.isSelected([index], selected) && ((_b = (_a = this.contentSelectable) == null ? void 0 : _a.call(this, content, contents)) != null ? _b : true)) {\n const viewport = ctx.getDefaultViewport(content, contents);\n if (!viewport) return;\n const result = {\n type: "viewport",\n border: content,\n ...viewport\n };\n if (result) {\n contents[index] = result;\n }\n }\n });\n }\n };\n}\nexport {\n getCommand,\n getModel\n};\n','// dev/cad-editor/plugins/wire.plugin.tsx\nfunction getModel(ctx) {\n const WireContent = ctx.and(ctx.BaseContent("wire"), {\n points: ctx.minItems(2, [ctx.Position]),\n refs: [ctx.ContentRef]\n });\n const LampContent = ctx.and(ctx.BaseContent("lamp"), ctx.Position, {\n size: ctx.number\n });\n const getIntersectedWires = (content, contents) => {\n const lines = Array.from(ctx.iteratePolylineLines(content.points));\n const wires = [];\n for (const c of ctx.getSortedContents(contents).contents) {\n if (!c) continue;\n if (ctx.shallowEquals(c, content)) {\n return wires;\n }\n if (isWireContent(c) && ctx.first(ctx.iterateGeometryLinesIntersectionPoints(getWireGeometries(c, contents).lines, lines))) {\n wires.push(c);\n }\n }\n return wires;\n };\n const getWireRefIds = (content) => [...ctx.getStrokeRefIds(content), ...ctx.toRefIds(content.refs)];\n const getLampRefIds = (content) => ctx.getStrokeRefIds(content);\n const wireGeometriesCache = new ctx.WeakmapValuesCache();\n function getWireGeometries(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getWireRefIds(content), contents, [content]));\n getIntersectedWires(content, contents).forEach((e) => refs.add(e));\n return wireGeometriesCache.get(content, refs, () => {\n let lines = Array.from(ctx.iteratePolylineLines(content.points));\n const joints = [];\n for (const ref of refs) {\n if (isWireContent(ref)) {\n const intersections = Array.from(ctx.iterateGeometryLinesIntersectionPoints(lines, getWireGeometries(ref, contents).lines));\n for (const intersection of intersections) {\n const param = ctx.getGeometryLinesParamAtPoint(intersection, lines);\n if (ctx.isZero(param) || ctx.isSameNumber(lines.length, param)) {\n let joint = joints.find((j) => ctx.isSamePoint(j.position, intersection));\n if (!joint) {\n joint = { position: intersection, count: 1 };\n joints.push(joint);\n }\n joint.count++;\n continue;\n }\n const radian = ctx.getGeometryLinesTangentRadianAtParam(param, lines);\n if (radian === void 0) continue;\n const angle = ctx.radianToAngle(radian);\n const radius = 5;\n const startPoint = ctx.getPointByLengthAndRadian(intersection, -radius, radian);\n const endPoint = ctx.getPointByLengthAndRadian(intersection, radius, radian);\n lines = [\n ...ctx.getPartOfGeometryLines(0, ctx.getGeometryLinesParamAtPoint(startPoint, lines), lines),\n { type: "arc", curve: { x: intersection.x, y: intersection.y, r: radius, startAngle: angle, endAngle: ctx.reverseAngle(angle) } },\n ...ctx.getPartOfGeometryLines(ctx.getGeometryLinesParamAtPoint(endPoint, lines), lines.length, lines)\n ];\n }\n } else if (isLampContent(ref)) {\n const params = ctx.deduplicate(Array.from(ctx.iterateGeometryLinesIntersectionPoints(lines, getLampGeometries(ref, contents).lines)).map((p) => ctx.getGeometryLinesParamAtPoint(p, lines)), ctx.isSameNumber);\n if (params.length === 1) {\n const param = params[0];\n if (param < lines.length / 2) {\n lines = ctx.getPartOfGeometryLines(param, lines.length, lines);\n } else {\n lines = ctx.getPartOfGeometryLines(0, param, lines);\n }\n } else if (params.length > 1) {\n lines = [\n ...ctx.getPartOfGeometryLines(0, Math.min(...params), lines),\n ...ctx.getPartOfGeometryLines(Math.max(...params), lines.length, lines)\n ];\n }\n }\n }\n const validJoints = joints.filter((j) => j.count === 3).map((j) => j.position);\n return {\n lines,\n joints: validJoints,\n bounding: ctx.getPointsBounding(content.points),\n regions: validJoints.length > 0 ? [] : void 0,\n renderingLines: lines.map((line) => ctx.dashedPolylineToLines(ctx.getGeometryLinesPoints([line]), content.dashArray)).flat()\n };\n });\n }\n function getLampGeometries(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getLampRefIds(content), contents, [content]));\n const arc = ctx.circleToArc({ x: content.x, y: content.y, r: content.size });\n return ctx.getGeometriesFromCache(content, refs, () => {\n const size = content.size * Math.SQRT1_2;\n const lineSegments = [\n [{ x: content.x - size, y: content.y - size }, { x: content.x + size, y: content.y + size }],\n [{ x: content.x - size, y: content.y + size }, { x: content.x + size, y: content.y - size }]\n ];\n const points = ctx.arcToPolyline(arc, ctx.defaultAngleDelta);\n return {\n lines: [{ type: "arc", curve: arc }, ...lineSegments],\n bounding: {\n start: { x: content.x - content.size, y: content.y - content.size },\n end: { x: content.x + content.size, y: content.y + content.size }\n },\n renderingLines: [\n ...ctx.dashedPolylineToLines(points, content.dashArray),\n ...lineSegments.map((s) => ctx.dashedPolylineToLines(s, content.dashArray)).flat()\n ]\n };\n });\n }\n const React = ctx.React;\n return [\n {\n type: "wire",\n ...ctx.strokeModel,\n move(content, offset) {\n for (const point of content.points) {\n ctx.movePoint(point, offset);\n }\n },\n render(content, renderCtx) {\n const { options, target } = ctx.getStrokeRenderOptionsFromRenderContext(content, renderCtx);\n const { renderingLines, joints } = getWireGeometries(content, renderCtx.contents);\n return target.renderGroup([\n ...renderingLines.map((line) => target.renderPolyline(line, options)),\n ...joints.map((joint) => target.renderCircle(joint.x, joint.y, 1, { fillColor: 0 }))\n ]);\n },\n getGeometries: getWireGeometries,\n propertyPanel(content, update, contents) {\n return {\n ...ctx.getStrokeContentPropertyPanel(content, update, contents)\n };\n },\n isValid: (c, p) => ctx.validate(c, WireContent, p),\n getRefIds: getWireRefIds,\n updateRefId(content, update) {\n for (const [i, id] of content.refs.entries()) {\n const newRefId = update(id);\n if (newRefId !== void 0) {\n content.refs[i] = newRefId;\n }\n }\n ctx.updateStrokeRefIds(content, update);\n },\n deleteRefId(content, ids) {\n for (const id of ids) {\n const index = content.refs.indexOf(id);\n if (index >= 0) {\n content.refs.splice(index, 1);\n }\n }\n ctx.deleteStrokeRefIds(content, ids);\n }\n },\n {\n type: "lamp",\n ...ctx.strokeModel,\n move(content, offset) {\n ctx.movePoint(content, offset);\n },\n render(content, renderCtx) {\n const { options, target } = ctx.getStrokeRenderOptionsFromRenderContext(content, renderCtx);\n const geometries = getLampGeometries(content, renderCtx.contents);\n const children = [target.renderCircle(content.x, content.y, content.size, options)];\n for (const line of geometries.lines) {\n if (Array.isArray(line)) {\n children.push(target.renderPolyline(line, options));\n }\n }\n return target.renderGroup(children);\n },\n getGeometries: getLampGeometries,\n getEditPoints(content, contents) {\n return ctx.getEditPointsFromCache(content, () => {\n const editPoints = [{\n x: content.x,\n y: content.y,\n cursor: "move",\n update(c, { cursor, start, target }) {\n if (!isLampContent(c)) {\n return;\n }\n c.x += cursor.x - start.x;\n c.y += cursor.y - start.y;\n return {\n updateRelatedContents() {\n const index = ctx.getContentIndex(content, contents);\n const targetIndex = target ? ctx.getContentIndex(target.content, contents) : void 0;\n const [, patches, reversePatches] = ctx.produceWithPatches(contents, (draft) => {\n var _a, _b;\n for (let i = 0; i < draft.length; i++) {\n const c2 = draft[i];\n if (!c2) continue;\n if (i === targetIndex && isWireContent(c2)) {\n if (!c2.refs.includes(index)) {\n c2.refs.push(index);\n }\n } else {\n (_b = (_a = ctx.getContentModel(c2)) == null ? void 0 : _a.deleteRefId) == null ? void 0 : _b.call(_a, c2, [index]);\n }\n }\n });\n return { patches, reversePatches };\n }\n };\n }\n }];\n return { editPoints };\n });\n },\n propertyPanel(content, update, contents) {\n return {\n size: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.size, setValue: (v) => update((c) => {\n if (isLampContent(c)) {\n c.size = v;\n }\n }) }),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents)\n };\n },\n isValid: (c, p) => ctx.validate(c, LampContent, p),\n getRefIds: getLampRefIds,\n updateRefId: ctx.updateStrokeRefIds,\n deleteRefId: ctx.deleteStrokeRefIds\n }\n ];\n}\nfunction isWireContent(content) {\n return content.type === "wire";\n}\nfunction isLampContent(content) {\n return content.type === "lamp";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon1 = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "4,4 97,4 97,96", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }));\n const icon2 = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("circle", { cx: "50", cy: "50", r: "45", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "18,18 82,82", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "18,82 82,18", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }));\n return [\n {\n name: "create wire",\n useCommand({ onEnd, type, strokeStyleId }) {\n const { line, onClick, onMove, input, lastPosition, reset } = ctx.useLineClickCreate(\n type === "create wire",\n (c) => onEnd({\n updateContents: (contents) => contents.push({ points: c, refs: [], strokeStyleId, type: "wire" })\n })\n );\n const assistentContents = [];\n if (line) {\n assistentContents.push({ points: line, refs: [], strokeStyleId, type: "wire" });\n }\n return {\n onStart: onClick,\n input,\n onMove,\n assistentContents,\n lastPosition,\n reset\n };\n },\n selectCount: 0,\n icon: icon1\n },\n {\n name: "create lamp",\n useCommand({ onEnd, type, strokeStyleId }) {\n const [lamp, setLamp] = React.useState();\n const [wireId, setWireId] = React.useState();\n const reset = () => {\n setWireId(void 0);\n setLamp(void 0);\n };\n const assistentContents = [];\n if (lamp) {\n assistentContents.push(lamp);\n }\n return {\n onStart: (p) => {\n onEnd({\n updateContents: (contents) => {\n if (wireId !== void 0) {\n const content = contents[wireId];\n if (content && isWireContent(content)) {\n content.refs.push(contents.length);\n }\n }\n contents.push({ x: p.x, y: p.y, size: 5, strokeStyleId, type: "lamp" });\n }\n });\n },\n onMove(p, _, target) {\n if (!type) return;\n setWireId(target == null ? void 0 : target.id);\n setLamp({ x: p.x, y: p.y, size: 5, strokeStyleId, type: "lamp" });\n },\n assistentContents,\n reset\n };\n },\n selectCount: 0,\n icon: icon2\n }\n ];\n}\nexport {\n getCommand,\n getModel,\n isLampContent,\n isWireContent\n};\n']},7449:(e,t,n)=>{"use strict";n.d(t,{MemoizedRenderer:()=>y,getAllRendererTypes:()=>b,registerRenderer:()=>x});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758),s=n(4469),c=Object.defineProperty,l=Object.defineProperties,u=Object.getOwnPropertyDescriptors,p=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,f=Object.prototype.propertyIsEnumerable,g=(e,t,n)=>t in e?c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,h=(e,t)=>{for(var n in t||(t={}))d.call(t,n)&&g(e,n,t[n]);if(p)for(var n of p(t))f.call(t,n)&&g(e,n,t[n]);return e},m=(e,t)=>l(e,u(t));const y=i().memo((function(e){var t,n,o,c,l,u;const p=new a.Debug(e.debug),d=v[e.type||b()[0]],f=i().useRef(new a.WeakmapMapCache);(0,a.useValueChanged)(e.type,(()=>f.current.clear())),(0,a.useValueChanged)(e.backgroundColor,(()=>f.current.clear()));const g=i().useRef(new a.WeakmapCache);if((0,a.useValueChanged)(d,(()=>g.current.clear())),!d)return null;const y=(0,a.getColorString)(e.backgroundColor),x=+`0x${y.substring(1,3)}`,C=+`0x${y.substring(3,5)}`,E=+`0x${y.substring(5)}`,P=(Math.max(x,E,C)+Math.min(x,E,C))/2,w=e=>P<128?0===e?16777215:e:16777215===e?0:e;p.mark("before contents");let k=[];const _=new a.Merger((e=>k.push(d.renderPath(e.target,{strokeColor:e.type.strokeColor,dashArray:e.type.dashArray,strokeWidth:e.type.strokeWidth,strokeOpacity:e.type.strokeOpacity,lineJoin:e.type.lineJoin,miterLimit:e.type.miterLimit,lineCap:e.type.lineCap}))),((e,t)=>e.strokeColor===t.strokeColor&&e.strokeWidth===t.strokeWidth&&e.strokeOpacity===t.strokeOpacity&&e.lineJoin===t.lineJoin&&e.miterLimit===t.miterLimit&&e.lineCap===t.lineCap&&(0,a.isSamePath)(e.dashArray,t.dashArray)),(e=>e.line)),S=null!=(t=e.previewPatches)?t:[],R=S.length>0&&!e.performanceMode?(0,r.applyPatches)(e.contents,S):e.contents,T=(0,s.getSortedContents)(R).contents,A={transformColor:w,target:d,getStrokeColor:e=>void 0!==e.strokeColor?e.trueStrokeColor?e.strokeColor:w(e.strokeColor):(0,s.hasFill)(e)?void 0:s.defaultStrokeColor,getFillColor:e=>void 0!==e.fillColor?e.trueFillColor?e.fillColor:w(e.fillColor):void 0,getFillPattern:e=>{if(void 0===e.fillPattern)return;const t=e.fillPattern;return g.current.get(t,(()=>({width:t.width,height:t.height,pattern:()=>{var e;return d.renderPath(t.lines,{strokeColor:null!=(e=void 0!==t.strokeColor?w(t.strokeColor):void 0)?e:s.defaultStrokeColor,strokeOpacity:t.strokeOpacity,lineCap:"square"})}})))},time:e.time,contents:R,patches:S};k=f.current.get(T,e.time,(()=>(T.forEach((t=>{var n,r,o,i,c,l;if(!t||!1===t.visible)return;const u=(0,s.getContentModel)(t);if(u)if("svg"!==d.type&&u.getGeometries){const{renderingLines:p,regions:d,bounding:f}=u.getGeometries(t,e.contents);if(!p||!f||d||(0,s.isClipContent)(t)&&t.clip||(0,s.isViewportContent)(t)&&!t.hidden){const e=u.render;e&&(_.flushLast(),k.push(e(t,h({transformStrokeWidth:e=>e},A))))}else{const e=null!=(n=(0,s.isStrokeContent)(t)?t.strokeWidth:void 0)?n:(0,s.getDefaultStrokeWidth)(t);let u=null!=(r=(0,s.isStrokeContent)(t)?t.strokeColor:void 0)?r:s.defaultStrokeColor;u=w(u);const d=null!=(o=(0,s.isStrokeContent)(t)?t.strokeOpacity:void 0)?o:s.defaultOpacity,f=null!=(i=(0,s.isStrokeContent)(t)?t.lineJoin:void 0)?i:a.defaultLineJoin,g=null!=(c=(0,s.isStrokeContent)(t)?t.miterLimit:void 0)?c:a.defaultMiterLimit,h=null!=(l=(0,s.isStrokeContent)(t)?t.lineCap:void 0)?l:a.defaultLineCap;for(const t of p)_.push({line:t,strokeColor:u,strokeWidth:e,strokeOpacity:d,lineJoin:f,miterLimit:g,lineCap:h})}}else{const e=u.render;e&&(_.flushLast(),k.push(e(t,h({transformStrokeWidth:e=>e},A))))}})),k))),_.flushLast(),p.mark("before assistent contents");const L=[],M=[];if(e.performanceMode){const t=new Set(S.map((e=>e.path[0]))),n=[];for(const o of t){const t=S.filter((e=>e.path[0]===o));if(t.length>0){const i=e.contents[o];i?n.push((0,r.applyPatches)(i,t.map((e=>m(h({},e),{path:e.path.slice(1)}))))):t.forEach((e=>{"add"===e.op&&e.value&&n.push(e.value)}))}}let o=[];if(n.forEach((e=>{var t;const n=null==(t=(0,s.getContentModel)(e))?void 0:t.render;n&&o.push(n(e,m(h({transformStrokeWidth:e=>e},A),{isAssistence:!0})))})),o.length>0&&void 0!==e.activeViewportIndex){const t=R[e.activeViewportIndex];t&&(0,s.isViewportContent)(t)&&(o=[d.renderGroup(o,{matrix:(0,s.getViewportMatrix)(t)})])}L.push(...o)}if(!1!==e.operatorVisible){const t=e.selected||[],n=e.othersSelectedContents||[];t.length+n.length>0&&e.contents.forEach(((r,o)=>{if(!r)return;const i=(0,s.getContentModel)(r);if(!i)return;const c=n.filter((e=>e.selection.includes(o))).map((e=>e.operator));if((0,a.isSelected)([o],t)&&c.unshift("me"),i.getOperatorRenderPosition&&c.length>0){const t=i.getOperatorRenderPosition(r,e.contents);M.push(d.renderText(t.x,t.y,c.join(","),16711680,16,"monospace"))}}))}for(const t of[...e.hovering||[],...e.assistentHovering||[]]){const e=(0,s.getContentByIndex)(R,t);if(e){const t=null==(n=(0,s.getContentModel)(e))?void 0:n.render;t&&(M.push(t(e,m(h({transformStrokeWidth:e=>e+4},A),{isHoveringOrSelected:!0}))),M.push(t(e,m(h({transformStrokeWidth:e=>e+2},A),{isHoveringOrSelected:!0}))),M.push(t(e,m(h({transformStrokeWidth:e=>e},A),{isHoveringOrSelected:!0}))))}}for(const t of[...e.selected||[],...e.assistentSelected||[]]){const n=(0,s.getContentByIndex)(R,t);if(n){const t=null!=(o=(0,s.isStrokeContent)(n)?n.strokeWidth:void 0)?o:(0,s.getDefaultStrokeWidth)(n),r=(0,s.getContentModel)(n),i=null==r?void 0:r.render;i&&(M.push(i(n,m(h({transformStrokeWidth:e=>e+4},A),{isHoveringOrSelected:!0}))),M.push(i(n,m(h({transformStrokeWidth:e=>e+2},A),{isHoveringOrSelected:!0}))),M.push(i(n,m(h({transformStrokeWidth:e=>e},A),{isHoveringOrSelected:!0}))));const a=null==r?void 0:r.renderIfSelected;a&&M.push(a(n,{color:w(16711680),target:d,strokeWidth:t,contents:e.contents}))}}if(void 0!==e.activeViewportIndex){const t=R[e.activeViewportIndex];if(t){const e=null==(c=(0,s.getContentModel)(t))?void 0:c.render;e&&(L.push(e(t,m(h({transformStrokeWidth:e=>e+4},A),{isHoveringOrSelected:!0}))),L.push(e(t,m(h({transformStrokeWidth:e=>e+2},A),{isHoveringOrSelected:!0}))))}}else if(void 0!==e.active){const t=R[e.active];if(t){const e=null==(l=(0,s.getContentModel)(t))?void 0:l.render;e&&L.push(e(t,m(h({transformStrokeWidth:e=>e+1},A),{isHoveringOrSelected:!0})))}}if(null==(u=e.assistentContents)||u.forEach((e=>{var t;const n=null==(t=(0,s.getContentModel)(e))?void 0:t.render;n&&M.push(n(e,m(h({transformStrokeWidth:e=>e},A),{isAssistence:!0})))})),M.length>0){const t=void 0!==e.activeViewportIndex?R[e.activeViewportIndex]:void 0;t&&(0,s.isViewportContent)(t)?L.push(d.renderGroup(M,{matrix:(0,s.getViewportMatrix)(t)})):L.push(...M)}const I=0===L.length?k:[...k,...L];return e.debug&&console.info(p.print()),d.renderResult(I,e.width,e.height,{attributes:{style:h({position:"absolute",boxSizing:"border-box"},e.style),onClick:e.onClick,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onContextMenu:e.onContextMenu,onDoubleClick:e.onDoubleClick,onMouseLeave:e.onMouseLeave},transform:{x:e.x,y:e.y,scale:e.scale,rotate:e.rotate},backgroundColor:e.backgroundColor,debug:e.debug,strokeWidthFixed:!e.printMode})})),v={};function x(e){v[e.type]=e}function b(){return Object.keys(v)}},2197:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758);const s=()=>{const[e,t]=i().useState([]),{circle:n,arc:o,onClick:s,onMove:c,input:l,reset:u}=(0,a.useCircleArcClickCreate)("center radius",(n=>{t((0,r.produce)(e,(e=>{e.push(n)})))}));(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&u()}));const p=n||o;return i().createElement("div",{onClick:e=>s({x:e.clientX,y:e.clientY}),onMouseMove:e=>c({x:e.clientX,y:e.clientY}),style:{height:"100%"}},i().createElement("svg",{viewBox:"0 0 800 600",width:800,height:600,xmlns:"http://www.w3.org/2000/svg",fill:"none",style:{position:"absolute",left:0,top:0},onClick:e=>s({x:e.clientX,y:e.clientY}),onMouseMove:e=>c({x:e.clientX,y:e.clientY})},p&&i().createElement("circle",{cx:p.x,cy:p.y,r:p.r,stroke:"#00ff00",strokeDasharray:"4"}),[...e,o].map(((e,t)=>{if(e){const n=(0,a.polarToCartesian)(e.x,e.y,e.r,e.endAngle),r=(0,a.polarToCartesian)(e.x,e.y,e.r,e.startAngle);return i().createElement("path",{key:t,d:`M ${n.x} ${n.y} A ${e.r} ${e.r} 0 ${e.endAngle-e.startAngle<=180?"0":"1"} 0 ${r.x} ${r.y}`,stroke:"#00ff00"})}return null}))),l)}},6844:(e,t,n)=>{"use strict";n.d(t,{default:()=>m});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758),s=Object.defineProperty,c=Object.defineProperties,l=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,f=(e,t,n)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,g=(e,t)=>{for(var n in t||(t={}))p.call(t,n)&&f(e,n,t[n]);if(u)for(var n of u(t))d.call(t,n)&&f(e,n,t[n]);return e},h=(e,t)=>c(e,l(t));const m=()=>{const[e,t]=i().useState({x:200,y:200,r:100,startAngle:-30,endAngle:120}),{offset:n,onStart:o,mask:s,reset:c}=(0,a.useCircleArcEdit)((()=>t(l)));(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&c()}));const l=(0,r.produce)(e,(e=>{n&&(e.x+=n.x,e.y+=n.y,e.r+=n.r,e.startAngle+=n.startAngle,e.endAngle+=n.endAngle,(0,a.normalizeAngleRange)(e))})),u=(0,a.polarToCartesian)(l.x,l.y,l.r,l.endAngle),p=(0,a.polarToCartesian)(l.x,l.y,l.r,l.startAngle);return i().createElement(i().Fragment,null,i().createElement("svg",{viewBox:"0 0 800 600",width:800,height:600,xmlns:"http://www.w3.org/2000/svg",fill:"none",style:{position:"absolute",left:0,top:0}},i().createElement("path",{d:`M ${u.x} ${u.y} A ${l.r} ${l.r} 0 ${l.endAngle-l.startAngle<=180?"0":"1"} 0 ${p.x} ${p.y}`,stroke:"#00ff00"})),i().createElement(a.CircleArcEditBar,h(g({},l),{onMouseDown:(e,t,n)=>o(e,h(g({},l),{type:t,cursor:n}))})),s)}},2960:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758);const s=()=>{const[e,t]=i().useState([]),{circle:n,onClick:o,onMove:s,input:c,reset:l}=(0,a.useCircleClickCreate)("center radius",(n=>{t((0,r.produce)(e,(e=>{e.push(n)})))}));return(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&l()})),i().createElement("div",{onClick:e=>o({x:e.clientX,y:e.clientY}),onMouseMove:e=>s({x:e.clientX,y:e.clientY}),style:{height:"100%"}},[...e,n].map(((e,t)=>e&&i().createElement("div",{key:t,style:{width:2*e.r+"px",height:2*e.r+"px",left:e.x-e.r+"px",top:e.y-e.r+"px",borderRadius:`${e.r}px`,position:"absolute",border:"1px solid #00ff00"}}))),c)}},9857:(e,t,n)=>{"use strict";n.d(t,{default:()=>g});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758),s=Object.defineProperty,c=Object.defineProperties,l=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,f=(e,t,n)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;const g=()=>{const[e,t]=i().useState({x:300,y:200,r:100}),{offset:n,onStart:o,mask:s,reset:g}=(0,a.useCircleEdit)((()=>t(h))),h=(0,r.produce)(e,(e=>{e.x+=n.x,e.y+=n.y,e.r+=n.r}));return(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&g()})),i().createElement(i().Fragment,null,i().createElement("div",{style:{width:2*h.r+"px",height:2*h.r+"px",left:h.x-h.r+"px",top:h.y-h.r+"px",borderRadius:`${h.r}px`,position:"absolute",border:"1px solid #00ff00"}}),i().createElement(a.CircleEditBar,{x:h.x,y:h.y,radius:h.r,onMouseDown:(t,n,r)=>{return o(t,(i=((e,t)=>{for(var n in t||(t={}))p.call(t,n)&&f(e,n,t[n]);if(u)for(var n of u(t))d.call(t,n)&&f(e,n,t[n]);return e})({},e),c(i,l({type:n,cursor:r}))));var i}}),s)}},3802:(e,t,n)=>{"use strict";n.d(t,{CircuitGraphEditor:()=>h});var r=n(3696),o=n.n(r),i=n(8662),a=n(9758),s=n(7883),c=n(4942),l=n(5918),u=n(66),p=n(4607),d=n(3031),f=n(7305),g=n(3649);(0,i.enablePatches)(),(0,s.registerModel)(c.powerModel),(0,s.registerModel)(l.resistanceModel),(0,s.registerModel)(u.wireModel),(0,s.registerModel)(f.switchModel),(0,s.registerModel)(g.capacitorModel);const h=o().forwardRef(((e,t)=>{var n,r,c,l,u;const{width:f,height:g}=(0,a.useWindowSize)(),{state:h,setState:m,undo:y,redo:v,applyPatchFromSelf:x,applyPatchFromOtherOperators:b}=(0,a.usePatchBasedUndoRedo)(e.initialState,e.operator,{onApplyPatchesFromSelf:e.onApplyPatchesFromSelf}),{x:C,y:E,ref:P,setX:w,setY:k}=(0,a.useWheelScroll)(),{scale:_,ref:S}=(0,a.useWheelZoom)({min:.001,onChange(e,t,n){const r=(0,a.scaleByCursorPosition)({width:f,height:g},t/e,n);w(r.setX),k(r.setY)}}),[R,T]=o().useState(),[A,L]=o().useState(),[M,I]=o().useState(),[O,D]=o().useState(),B=M?s.modelCenter[M]:void 0,z=[],F=[],N=[],U=[],[G,j]=o().useState();let V;const[W,H]=o().useState([]),[q,$]=o().useState(),X=o().useRef(),Y=o().useRef(),{line:K,onClick:Z,reset:Q,onMove:J,lastPosition:ee}=(0,a.useLineClickCreate)(void 0!==M,(e=>{m((t=>{if(!(null==B?void 0:B.createPreview))return;let n,r,o=h.length;if(void 0===X.current){const r={type:"junction",position:e[0]};t.push(r),n=o,o++}else n=X.current;if(void 0===Y.current){const n={type:"junction",position:e[1]};t.push(n),r=o,o++}else r=Y.current;t.push(B.createPreview({start:n,end:r}))})),ne()}),{once:!0});if(K&&(null==B?void 0:B.createPreview)){const e={type:"junction",position:K[0]},t={type:"junction",position:K[1]};z.push(e,t,B.createPreview({start:e,end:t}))}const te={x:C,y:E,scale:_,center:{x:f/2,y:g/2}},ne=()=>{I(void 0),X.current=void 0,Y.current=void 0,D(void 0),T(void 0),L(void 0),$(void 0)},{editPoint:re,updateEditPreview:oe,onEditMove:ie,onEditClick:ae,editLastPosition:se,getEditAssistentContents:ce,resetEdit:le}=(0,a.useEdit)((()=>{const e=[],t=[];let n=h.length;for(const r of F)if("replace"===r.op&&2===r.path.length&&r.value&&(0,s.isJunctionContent)(r.value)){const o=r.path[1];"start"!==o&&"end"!==o||(e.push({op:"add",path:[n],value:r.value}),r.value=n,t.push({op:"replace",path:["length"],value:n}),n++)}x([...F,...e],[...N,...t])}),(e=>{var t,n;return null==(n=null==(t=(0,s.getContentModel)(e))?void 0:t.getEditPoints)?void 0:n.call(t,e,h)}),{scale:te.scale,readOnly:!!M}),ue=oe();if(F.push(...null!=(n=null==ue?void 0:ue.patches)?n:[]),N.push(...null!=(r=null==ue?void 0:ue.reversePatches)?r:[]),z.push(...null!=(c=null==ue?void 0:ue.assistentContents)?c:[]),ue&&z.push(...(0,s.updateReferencedContents)(ue.content,ue.result,h)),void 0!==A){const e=h[A];if(e){U.push({content:e,path:[A]});const t=re&&(0,a.isSamePath)(re.path,[A])?null==ue?void 0:ue.result:null==ue?void 0:ue.relatedEditPointResults.get(e);z.push(...ce(null!=t?t:e,(e=>({type:"circle",x:e.x,y:e.y,radius:7}))));const n=e=>{const[,...t]=(0,i.produceWithPatches)(h,(t=>{const n=t[A];n&&e(n,t)}));x(...t)},r=null==(u=null==(l=(0,s.getContentModel)(e))?void 0:l.propertyPanel)?void 0:u.call(l,e,n,h);let c;if((0,s.isJunctionContent)(e)){const e=W[A];void 0!==e&&(c=o().createElement("div",null,e,"V"))}V=o().createElement("div",{style:{position:"absolute",right:"0px",top:"0px",bottom:"0px",width:"300px",overflowY:"auto",background:"white",zIndex:11}},e.type,o().createElement("div",null,A),c,r&&o().createElement(a.ObjectEditor,{properties:r}))}}const pe=null!=se?se:ee,de=e=>{for(let t=0;t{const t=90*Math.round(e/90);if(t!==e&&Math.abs(t-e)<5)return t})),(0,a.isSameNumber)(pe.x,e.x)){for(const t of h)if(t&&(0,s.isJunctionContent)(t)&&(0,a.getTwoNumbersDistance)(e.y,t.position.y)<=5){const n={type:"line",point:{x:e.x,y:t.position.y},start:t.position};return D(n),n}}else if((0,a.isSameNumber)(pe.y,e.y))for(const t of h)if(t&&(0,s.isJunctionContent)(t)&&(0,a.getTwoNumbersDistance)(e.x,t.position.x)<=5){const n={type:"line",point:{x:t.position.x,y:e.y},start:t.position};return D(n),n}return D(void 0),{point:e}};"point"===(null==O?void 0:O.type)&&z.push({type:"circle",x:O.point.x,y:O.point.y,radius:7}),"line"===(null==O?void 0:O.type)&&z.push({type:"line",p1:O.start,p2:O.point});const fe=e=>{j(e),Q(),I(e)},ge=(0,a.useEvent)((e=>{const t={x:e.clientX,y:e.clientY},n=(0,a.reverseTransformPosition)(t,te),r=de(n);M?(void 0===K?X.current=r.id:Y.current=r.id,Z(r.point)):re?ae(r.point):q?q.act((e=>{const[,...t]=(0,i.produceWithPatches)(h,(t=>{const n=t[q.index];n&&e(n,t)}));x(...t)})):void 0!==R&&(L(R),T(void 0))})),he=(0,a.useEvent)((e=>{const t={x:e.clientX,y:e.clientY},n=(0,a.reverseTransformPosition)(t,te),r=de(n);M?J(r.point,t):(ie(r.point,U),T((e=>{var t,n;for(let t=0;t{var t,n;for(let r=0;r{G&&(fe(G),e.preventDefault())}));let ye;return(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key?(ne(),Q(!0),le()):(0,a.metaKeyIfMacElseCtrlKey)(e)&&(e.shiftKey?"KeyZ"===e.code&&v(e):"KeyZ"===e.code?y(e):"Backspace"===e.code&&(void 0===R||(0,s.contentIsReferenced)(R,h)?void 0===A||(0,s.contentIsReferenced)(A,h)||(m((e=>{e[A]=void 0})),L(void 0)):(m((e=>{e[R]=void 0})),T(void 0))))})),o().useImperativeHandle(t,(()=>({handlePatchesEvent(e){try{b(e.patches,e.reversePatches,e.operator)}catch(e){console.error(e)}}})),[b]),o().useEffect((()=>{const e=[];h.forEach(((t,n)=>{var r,o;if(t)if((0,s.isJunctionContent)(t)){const r=[],o=[];h.forEach(((e,t)=>{e&&(0,s.isDeviceContent)(e)&&(e.start===n?r.push(`I${t}`):e.end===n&&o.push(`I${t}`))})),r.length+o.length>0&&e.push({left:r.join(" + ")||"0",right:o.join(" + ")||"0"}),t.ground&&e.push({left:`U${n}`,right:"0"})}else if((0,s.isDeviceContent)(t)&&"number"==typeof t.start&&"number"==typeof t.end){const i=null==(o=null==(r=(0,s.getContentModel)(t))?void 0:r.getEquationData)?void 0:o.call(r,t,n);i&&e.push(i)}}));const t=e.map((e=>({left:(0,d.parseExpression)((0,d.tokenizeExpression)(e.left)),right:(0,d.parseExpression)((0,d.tokenizeExpression)(e.right))}))),n=[];for(const[e,r]of Object.entries((0,a.solveEquations)(t)[0]))Array.isArray(r)||"NumericLiteral"!==r.type||(n[+e.slice(1)]=r.value);H(n)}),[h]),re?ye=re.cursor:(void 0!==R&&R!==A||q)&&(ye="pointer"),o().createElement(o().Fragment,null,o().createElement("div",{ref:(0,a.bindMultipleRefs)(P,S)},o().createElement("div",{style:{cursor:ye,position:"absolute",inset:"0px"},onMouseMove:he},o().createElement(p.Renderer,{contents:h,x:te.x,y:te.y,scale:te.scale,width:f,height:g,assistentContents:z,hovering:R,selected:A,previewPatches:F,equationResult:W,onClick:ge,onContextMenu:me}))),o().createElement("div",{style:{position:"relative"}},Object.values(s.modelCenter).filter((e=>e.createPreview)).map((e=>{if(e.icon){const t=o().cloneElement(e.icon,{onClick:()=>fe(e.type),style:{width:"20px",height:"20px",margin:"5px",cursor:"pointer",color:M===e.type?"red":void 0}});return o().createElement("span",{title:e.type,key:e.type},t)}return null})),o().createElement("span",{title:"compress"},o().createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 100 100",style:{width:"20px",height:"20px",margin:"5px",cursor:"pointer"},onClick:()=>{m((e=>{var t,n;const r=[];let o=0;const i=[];e.forEach(((e,t)=>{e?(r.push(o),o++):(r.push(void 0),i.unshift(t))})),i.forEach((t=>{e.splice(t,1)}));for(const o of e)o&&(null==(n=null==(t=(0,s.getContentModel)(o))?void 0:t.updateRefId)||n.call(t,o,(e=>"number"==typeof e?r[e]:void 0)));s.contentIndexCache.clear()}))}},o().createElement("rect",{x:"10",y:"44",width:"81",height:"20",strokeWidth:"0",strokeMiterlimit:"10",strokeLinejoin:"miter",strokeLinecap:"butt",fill:"currentColor",stroke:"currentColor"}),o().createElement("rect",{x:"9",y:"69",width:"81",height:"20",strokeWidth:"0",strokeMiterlimit:"10",strokeLinejoin:"miter",strokeLinecap:"butt",fill:"currentColor",stroke:"currentColor"}),o().createElement("polygon",{points:"42,6 57,6 57,31 73,31 51,44 27,32 42,32",strokeWidth:"0",strokeMiterlimit:"10",strokeLinejoin:"miter",strokeLinecap:"butt",fill:"currentColor",stroke:"currentColor"})))),V)}))},7883:(e,t,n)=>{"use strict";n.d(t,{contentIndexCache:()=>g,contentIsReferenced:()=>x,deviceGeometryCache:()=>p,deviceModel:()=>s,getContentModel:()=>v,getDeviceText:()=>b,getReference:()=>f,isDeviceContent:()=>u,isJunctionContent:()=>c,modelCenter:()=>m,registerModel:()=>y,updateReferencedContents:()=>h});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758);const s={isDevice:!0,getRefIds(e){const t=[];return"number"==typeof e.start&&t.push(e.start),"number"==typeof e.end&&t.push(e.end),t},updateRefId(e,t){const n=t(e.start);void 0!==n&&(e.start=n);const r=t(e.end);void 0!==r&&(e.end=r)},getEditPoints:(e,t)=>d.get(e,(()=>{const n=[],r=f(e.start,t,c);r&&n.push({field:"start",content:r});const o=f(e.end,t,c);return o&&n.push({field:"end",content:o}),{editPoints:n.map((({field:e,content:n})=>({x:n.position.x,y:n.position.y,cursor:"move",update(r,{cursor:o}){if(!u(r))return;const i=t.findIndex((e=>e&&c(e)&&(0,a.isSamePoint)(e.position,o)));return r[e]=i>=0?i:{type:"junction",position:{x:o.x,y:o.y}},{assistentContents:[{type:"line",p1:n.position,p2:o}]}}})))}}))};function c(e){return"junction"===e.type}const l={type:"junction",render(e,{target:t,transformStrokeWidth:n}){const r=n(3),o=[t.renderCircle(e.position.x,e.position.y,r,{fillColor:0})];return e.ground&&o.push(t.renderPolyline([{x:e.position.x,y:e.position.y+20},{x:e.position.x,y:e.position.y}]),t.renderPolyline([{x:e.position.x-12,y:e.position.y+20},{x:e.position.x+12,y:e.position.y+20}]),t.renderPolyline([{x:e.position.x-8,y:e.position.y+23},{x:e.position.x+8,y:e.position.y+23}]),t.renderPolyline([{x:e.position.x-4,y:e.position.y+26},{x:e.position.x+4,y:e.position.y+26}])),t.renderGroup(o)},getEditPoints:e=>d.get(e,(()=>({editPoints:[{x:e.position.x,y:e.position.y,cursor:"move",update(t,{cursor:n}){if(c(t))return t.position.x=n.x,t.position.y=n.y,{assistentContents:[{type:"line",p1:e.position,p2:n}]}}}]}))),propertyPanel(e,t){var n;return{ground:i().createElement(a.BooleanEditor,{value:null!=(n=e.ground)&&n,setValue:e=>t((t=>{c(t)&&(t.ground=!!e||void 0)}))})}}};function u(e){var t;return!!(null==(t=v(e))?void 0:t.isDevice)}const p=new a.WeakmapCache3,d=new a.WeakmapCache;function f(e,t,n){if("number"!=typeof e)return n(e)?e:void 0;const r=t[e];return r&&n(r)?r:void 0}const g=new a.WeakmapCache;function h(e,t,n){var o,i;const a=[];if(!c(t))return a;const s=function(e,t){return g.get(e,(()=>t.findIndex((t=>e===t))))}(e,n);for(const e of n){if(!e)continue;const n=v(e);(null==(i=null==(o=null==n?void 0:n.getRefIds)?void 0:o.call(n,e))?void 0:i.includes(s))&&a.push((0,r.produce)(e,(e=>{var r;null==(r=n.updateRefId)||r.call(n,e,(e=>{if(e===s)return t}))})))}return a}const m={};function y(e){m[e.type]=e}function v(e){return m[e.type]}function x(e,t){var n,r,o;for(const i of t)if(i&&(null==(o=null==(r=null==(n=v(i))?void 0:n.getRefIds)?void 0:r.call(n,i))?void 0:o.includes(e)))return!0;return!1}function b(e,t,n,r,o="A"){const i=Math.abs((0,a.getTwoPointsRadian)(e.right,e.left))/Math.PI;let s,c,l=e.center.x,u=e.center.y,p=e.center.x,d=e.center.y;i>1/4&&i<3/4?(l+=10,p-=10,s="left",c="right"):(u-=15,d+=15,s="center",c="center");const f=[];if(n&&f.push(t.renderText(l,u,n,0,16,"monospace",{textAlign:s,textBaseline:"middle"})),void 0!==r){const n=(0,a.isZero)(r)?0:+Math.abs(r).toPrecision(3);if(f.push(t.renderText(p,d,n+o,0,16,"monospace",{textAlign:c,textBaseline:"middle"})),!(0,a.isZero)(r)&&"A"===o){const n=r>0?e.right:e.left,o=(0,a.getPointByLengthAndDirection)(e.center,12,n),i=(0,a.getPointByLengthAndDirection)(e.center,20,n);f.push(t.renderPolyline([(0,a.rotatePositionByCenter)(o,i,30),i,(0,a.rotatePositionByCenter)(o,i,-30)]))}}return f}y(l),y({type:"circle",render:(e,{target:t})=>t.renderCircle(e.x,e.y,e.radius)}),y({type:"line",render:(e,{target:t})=>t.renderPolyline([e.p1,e.p2],{dashArray:[4]})})},3649:(e,t,n)=>{"use strict";n.d(t,{capacitorModel:()=>g});var r=n(3696),o=n.n(r),i=n(9758),a=n(7883),s=Object.defineProperty,c=Object.defineProperties,l=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,f=(e,t,n)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;const g=c(((e,t)=>{for(var n in t||(t={}))p.call(t,n)&&f(e,n,t[n]);if(u)for(var n of u(t))d.call(t,n)&&f(e,n,t[n]);return e})({type:"capacitor"},a.deviceModel),l({render(e,{target:t,transformStrokeWidth:n,contents:r,value:o,equationResult:i}){const s=n(1),{lines:c,data:l}=h(e,r),u=c.map((e=>t.renderPolyline(e,{strokeWidth:s})));if(l){if(i&&"number"==typeof e.start&&"number"==typeof e.end){const t=i[e.start],n=i[e.end];void 0!==t&&void 0!==n&&(o=(n-t)*e.value)}u.push(...(0,a.getDeviceText)(l,t,e.value+"F",o,"C"))}return t.renderGroup(u)},createPreview:e=>({type:"capacitor",start:e.start,end:e.end,value:1}),getGeometries:h,icon:o().createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 100 100"},o().createElement("polyline",{points:"9,48 37,48",strokeWidth:"5",strokeMiterlimit:"10",strokeLinejoin:"miter",strokeLinecap:"butt",fill:"none",stroke:"currentColor"}),o().createElement("polyline",{points:"36,75 36,22",strokeWidth:"5",strokeMiterlimit:"10",strokeLinejoin:"miter",strokeLinecap:"butt",fill:"none",stroke:"currentColor"}),o().createElement("polyline",{points:"96,48 64,48",strokeWidth:"5",strokeMiterlimit:"10",strokeLinejoin:"miter",strokeLinecap:"butt",fill:"none",stroke:"currentColor"}),o().createElement("polyline",{points:"64,75 64,22",strokeWidth:"5",strokeMiterlimit:"10",strokeLinejoin:"miter",strokeLinecap:"butt",fill:"none",stroke:"currentColor"})),propertyPanel:(e,t)=>({value:o().createElement(i.NumberEditor,{value:e.value,setValue:e=>t((t=>{(function(e){return"capacitor"===e.type})(t)&&(t.value=e)}))})}),getEquationData:(e,t)=>({left:`I${t}`,right:"0"})}));function h(e,t){const n=(0,a.getReference)(e.start,t,a.isJunctionContent),r=(0,a.getReference)(e.end,t,a.isJunctionContent);return n&&r?a.deviceGeometryCache.get(e,n,r,(()=>{const e=(0,i.getTwoPointCenter)(n.position,r.position),t=(0,i.getPointByLengthAndDirection)(e,3,n.position),o=(0,i.getPointByLengthAndDirection)(e,3,r.position),a=(0,i.getTwoPointsRadian)(n.position,r.position)+Math.PI/2,s=[[n.position,t],[r.position,o],[(0,i.getPointByLengthAndRadian)(t,8,a),(0,i.getPointByLengthAndRadian)(t,-8,a)],[(0,i.getPointByLengthAndRadian)(o,8,a),(0,i.getPointByLengthAndRadian)(o,-8,a)]];return{data:{center:e,left:n.position,right:r.position},lines:s}})):{lines:[]}}},4942:(e,t,n)=>{"use strict";n.d(t,{powerModel:()=>h});var r=n(3696),o=n.n(r),i=n(9758),a=n(7883),s=Object.defineProperty,c=Object.defineProperties,l=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,f=(e,t,n)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;function g(e){return"power"===e.type}const h=(m=((e,t)=>{for(var n in t||(t={}))p.call(t,n)&&f(e,n,t[n]);if(u)for(var n of u(t))d.call(t,n)&&f(e,n,t[n]);return e})({type:"power"},a.deviceModel),y={render(e,{target:t,transformStrokeWidth:n,contents:r,value:o}){const i=n(1),{lines:s,data:c}=v(e,r),l=s.map((e=>t.renderPolyline(e,{strokeWidth:i})));return c&&l.push(...(0,a.getDeviceText)(c,t,e.value+"V",o)),t.renderGroup(l)},createPreview:e=>({type:"power",start:e.start,end:e.end,value:1}),getGeometries:v,icon:o().createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 100 100"},o().createElement("polyline",{points:"9,48 37,48",strokeWidth:"5",strokeMiterlimit:"10",strokeLinejoin:"miter",strokeLinecap:"butt",fill:"none",stroke:"currentColor"}),o().createElement("polyline",{points:"36,66 36,32",strokeWidth:"5",strokeMiterlimit:"10",strokeLinejoin:"miter",strokeLinecap:"butt",fill:"none",stroke:"currentColor"}),o().createElement("polyline",{points:"96,48 64,48",strokeWidth:"5",strokeMiterlimit:"10",strokeLinejoin:"miter",strokeLinecap:"butt",fill:"none",stroke:"currentColor"}),o().createElement("polyline",{points:"64,75 64,22",strokeWidth:"5",strokeMiterlimit:"10",strokeLinejoin:"miter",strokeLinecap:"butt",fill:"none",stroke:"currentColor"})),propertyPanel:(e,t)=>({value:o().createElement(i.NumberEditor,{value:e.value,setValue:e=>t((t=>{g(t)&&(t.value=e)}))}),direction:o().createElement(i.Button,{onClick:()=>t((e=>{if(g(e)){const t=e.end;e.end=e.start,e.start=t}}))},"switch")}),getEquationData:e=>({left:`U${e.start} + ${e.value}`,right:`U${e.end}`})},c(m,l(y)));var m,y;function v(e,t){const n=(0,a.getReference)(e.start,t,a.isJunctionContent),r=(0,a.getReference)(e.end,t,a.isJunctionContent);return n&&r?a.deviceGeometryCache.get(e,n,r,(()=>{const e=(0,i.getTwoPointCenter)(n.position,r.position),t=(0,i.getPointByLengthAndDirection)(e,3,n.position),o=(0,i.getPointByLengthAndDirection)(e,3,r.position),a=(0,i.getTwoPointsRadian)(n.position,r.position)+Math.PI/2,s=[[n.position,t],[r.position,o],[(0,i.getPointByLengthAndRadian)(t,4,a),(0,i.getPointByLengthAndRadian)(t,-4,a)],[(0,i.getPointByLengthAndRadian)(o,8,a),(0,i.getPointByLengthAndRadian)(o,-8,a)]];return{data:{center:e,left:n.position,right:r.position},lines:s}})):{lines:[]}}},5918:(e,t,n)=>{"use strict";n.d(t,{resistanceModel:()=>g});var r=n(3696),o=n.n(r),i=n(9758),a=n(7883),s=Object.defineProperty,c=Object.defineProperties,l=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,f=(e,t,n)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;const g=c(((e,t)=>{for(var n in t||(t={}))p.call(t,n)&&f(e,n,t[n]);if(u)for(var n of u(t))d.call(t,n)&&f(e,n,t[n]);return e})({type:"resistance"},a.deviceModel),l({render(e,{target:t,transformStrokeWidth:n,contents:r,value:o}){const i=n(1),{lines:s,data:c}=h(e,r),l=s.map((e=>t.renderPolyline(e,{strokeWidth:i})));return c&&l.push(...(0,a.getDeviceText)(c,t,e.value+"Ω",o)),t.renderGroup(l)},createPreview:e=>({type:"resistance",start:e.start,end:e.end,value:1}),getGeometries:h,icon:o().createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 100 100"},o().createElement("rect",{x:"15",y:"35",width:"71",height:"24",strokeWidth:"5",strokeMiterlimit:"10",strokeLinejoin:"miter",strokeLinecap:"butt",fill:"none",stroke:"currentColor"}),o().createElement("polyline",{points:"85,45 99,45",strokeWidth:"5",strokeMiterlimit:"10",strokeLinejoin:"miter",strokeLinecap:"butt",fill:"none",stroke:"currentColor"}),o().createElement("polyline",{points:"13,44 0,44",strokeWidth:"5",strokeMiterlimit:"10",strokeLinejoin:"miter",strokeLinecap:"butt",fill:"none",stroke:"currentColor"})),propertyPanel:(e,t)=>({value:o().createElement(i.NumberEditor,{value:e.value,setValue:e=>t((t=>{(function(e){return"resistance"===e.type})(t)&&(t.value=e)}))})}),getEquationData:(e,t)=>({left:`U${e.start} - ${e.value} * I${t}`,right:`U${e.end}`})}));function h(e,t){const n=(0,a.getReference)(e.start,t,a.isJunctionContent),r=(0,a.getReference)(e.end,t,a.isJunctionContent);return n&&r?a.deviceGeometryCache.get(e,n,r,(()=>{const e=(0,i.getTwoPointCenter)(n.position,r.position),t=(0,i.getPointByLengthAndDirection)(e,8,n.position),o=(0,i.getPointByLengthAndDirection)(e,8,r.position),a=(0,i.getTwoPointsRadian)(n.position,r.position)+Math.PI/2,s=[[n.position,t],[r.position,o],...(0,i.iteratePolygonLines)([(0,i.getPointByLengthAndRadian)(t,4,a),(0,i.getPointByLengthAndRadian)(t,-4,a),(0,i.getPointByLengthAndRadian)(o,-4,a),(0,i.getPointByLengthAndRadian)(o,4,a)])];return{data:{center:e,left:n.position,right:r.position},lines:s}})):{lines:[]}}},7305:(e,t,n)=>{"use strict";n.d(t,{switchModel:()=>h});var r=n(3696),o=n.n(r),i=n(9758),a=n(7883),s=Object.defineProperty,c=Object.defineProperties,l=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,f=(e,t,n)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;function g(e){return"switch"===e.type}const h=c(((e,t)=>{for(var n in t||(t={}))p.call(t,n)&&f(e,n,t[n]);if(u)for(var n of u(t))d.call(t,n)&&f(e,n,t[n]);return e})({type:"switch"},a.deviceModel),l({render(e,{target:t,transformStrokeWidth:n,contents:r,value:o}){const i=n(1),{lines:s,data:c}=m(e,r),l=s.map((e=>t.renderPolyline(e,{strokeWidth:i})));return c&&l.push(...(0,a.getDeviceText)(c,t,void 0,o)),t.renderGroup(l)},createPreview:e=>({type:"switch",start:e.start,end:e.end,on:!1}),getGeometries:m,icon:o().createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 100 100"},o().createElement("polyline",{points:"1,46 34,46",strokeWidth:"5",strokeMiterlimit:"10",strokeLinejoin:"miter",strokeLinecap:"butt",fill:"none",stroke:"currentColor"}),o().createElement("circle",{cx:"39",cy:"47",r:"7",strokeWidth:"5",strokeMiterlimit:"10",strokeLinejoin:"miter",strokeLinecap:"butt",fill:"none",stroke:"currentColor"}),o().createElement("polyline",{points:"43,41 71,27",strokeWidth:"5",strokeMiterlimit:"10",strokeLinejoin:"miter",strokeLinecap:"butt",fill:"none",stroke:"currentColor"}),o().createElement("polyline",{points:"69,47 100,47",strokeWidth:"5",strokeMiterlimit:"10",strokeLinejoin:"miter",strokeLinecap:"butt",fill:"none",stroke:"currentColor"})),propertyPanel:(e,t)=>({on:o().createElement(i.BooleanEditor,{value:e.on,setValue:e=>t((t=>{g(t)&&(t.on=e)}))})}),getEquationData:(e,t)=>e.on?{left:`U${e.start}`,right:`U${e.end}`}:{left:`I${t}`,right:"0"},getAction(e,t,n){const{data:r}=m(t,n);if(r&&(0,i.getTwoPointsDistance)(r.center,e)<16)return e=>{e((e=>{g(e)&&(e.on=!e.on)}))}}}));function m(e,t){const n=(0,a.getReference)(e.start,t,a.isJunctionContent),r=(0,a.getReference)(e.end,t,a.isJunctionContent);return n&&r?a.deviceGeometryCache.get(e,n,r,(()=>{const t=(0,i.getTwoPointCenter)(n.position,r.position),o=(0,i.getPointByLengthAndDirection)(t,8,n.position),a=[[n.position,(0,i.getPointByLengthAndDirection)(o,3,n.position)],...(0,i.iteratePolylineLines)((0,i.arcToPolyline)((0,i.circleToArc)({x:o.x,y:o.y,r:3}),5))];if(e.on)a.push([(0,i.getPointByLengthAndDirection)(o,3,r.position),r.position]);else{const e=(0,i.getPointByLengthAndDirection)(t,8,r.position),n=(0,i.rotatePositionByCenter)(e,o,30);a.push([(0,i.getPointByLengthAndDirection)(o,3,n),n],[e,r.position])}return{lines:a,data:{center:t,left:n.position,right:r.position}}})):{lines:[]}}},66:(e,t,n)=>{"use strict";n.d(t,{wireModel:()=>g});var r=n(3696),o=n.n(r),i=n(9758),a=n(7883),s=Object.defineProperty,c=Object.defineProperties,l=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,f=(e,t,n)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;const g=c(((e,t)=>{for(var n in t||(t={}))p.call(t,n)&&f(e,n,t[n]);if(u)for(var n of u(t))d.call(t,n)&&f(e,n,t[n]);return e})({type:"wire"},a.deviceModel),l({render(e,{target:t,transformStrokeWidth:n,contents:r,value:o}){const i=n(1),{lines:s,data:c}=h(e,r),l=s.map((e=>t.renderPolyline(e,{strokeWidth:i})));return c&&l.push(...(0,a.getDeviceText)(c,t,void 0,o)),t.renderGroup(l)},createPreview:e=>({type:"wire",start:e.start,end:e.end}),getGeometries:h,icon:o().createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 100 100"},o().createElement("polyline",{points:"1,46 100,46",strokeWidth:"5",strokeMiterlimit:"10",strokeLinejoin:"miter",strokeLinecap:"butt",fill:"none",stroke:"currentColor"})),getEquationData:e=>({left:`U${e.start}`,right:`U${e.end}`})}));function h(e,t){const n=(0,a.getReference)(e.start,t,a.isJunctionContent),r=(0,a.getReference)(e.end,t,a.isJunctionContent);return n&&r?a.deviceGeometryCache.get(e,n,r,(()=>{const e=(0,i.getTwoPointCenter)(n.position,r.position);return{lines:[[n.position,r.position]],data:{center:e,left:n.position,right:r.position}}})):{lines:[]}}},4607:(e,t,n)=>{"use strict";n.d(t,{Renderer:()=>d});var r=n(8662),o=n(9758),i=n(7883),a=Object.defineProperty,s=Object.getOwnPropertySymbols,c=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,u=(e,t,n)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,p=(e,t)=>{for(var n in t||(t={}))c.call(t,n)&&u(e,n,t[n]);if(s)for(var n of s(t))l.call(t,n)&&u(e,n,t[n]);return e};function d(e){var t,n;const a=o.reactSvgRenderTarget,s=[],c=e.previewPatches.length>0?(0,r.applyPatches)(e.contents,e.previewPatches):e.contents;for(let n=0;ne.hovering===n||e.selected===n?t+1:t,contents:c,value:e.equationResult[n],equationResult:e.equationResult}))}}for(const t of e.assistentContents){if(!t)continue;const e=null==(n=(0,i.getContentModel)(t))?void 0:n.render;e&&s.push(e(t,{target:a,transformStrokeWidth:e=>e,contents:c}))}return a.renderResult(s,e.width,e.height,{attributes:{style:p({position:"absolute",boxSizing:"border-box"},e.style),onClick:e.onClick,onMouseDown:e.onMouseDown,onContextMenu:e.onContextMenu},transform:{x:e.x,y:e.y,scale:e.scale}})}},9277:(e,t,n)=>{"use strict";n.d(t,{Combination2:()=>u});var r=n(3696),o=n.n(r),i=n(9758),a=n(7449),s=n(1406),c=Math.pow;const l=Math.round(15*Math.random()*c(16,3)+c(16,3)).toString(16);function u(){const[e,t]=o().useState(),{pluginLoaded:n,pluginCommandTypes:r}=(0,s.usePlugins)(),[c,u]=(0,i.useLocalStorageState)("composable-editor-canvas-combination2:panel",!0),[p,d]=(0,i.useLocalStorageState)("composable-editor-canvas-combination2:print-mode",!1),[f,g]=(0,i.useLocalStorageState)("composable-editor-canvas-combination2:performance-mode",!1),h=(0,s.useInitialStateValidated)(e,n);o().useEffect((()=>{t([])}),[]);const m=o().useRef(null),[y,v]=o().useState(!1),[x,b]=(0,i.useLocalStorageState)("composable-editor-canvas-combination2:snaps",i.allSnapTypes),[C,E]=(0,i.useLocalStorageState)("composable-editor-canvas-combination2:render-target",void 0),[P,w]=o().useState(!1),[k,_]=o().useState(!1),[S,R]=o().useState(),[T,A]=(0,i.useLocalStorageState)("composable-editor-canvas-combination2:input-fixed",!1),[L,M]=(0,i.useLocalStorageState)("composable-editor-canvas-combination2:background-color",16777215),[I,O]=(0,i.useLocalStorageState)("composable-editor-canvas-combination2:debug",!1);return o().createElement("div",{style:{height:"100%"}},e&&n&&h&&o().createElement(s.CADEditor,{ref:m,id:"combination2",operator:l,initialState:e,readOnly:y,snapTypes:x,renderTarget:C,setCanUndo:w,setCanRedo:_,setOperation:R,inputFixed:T,backgroundColor:L,debug:I,panelVisible:c,printMode:p,performanceMode:f}),o().createElement("div",{style:{position:"fixed",width:"100%"}},!y&&r.map((e=>{if(e.icon){const t=o().cloneElement(e.icon,{onClick:()=>{var t;return null==(t=m.current)?void 0:t.startOperation({type:"command",name:e.name})},key:e.name,style:{width:"20px",height:"20px",margin:"5px",cursor:"pointer",color:S===e.name?"red":void 0}});return o().createElement("span",{title:e.name,key:e.name},t)}return null})),["move canvas","zoom window"].map((e=>o().createElement("button",{onClick:()=>{var t;return null==(t=m.current)?void 0:t.startOperation({type:"non command",name:e})},key:e,style:{position:"relative",top:"-10px",borderColor:S===e?"red":void 0}},e))),o().createElement("button",{onClick:()=>(t(void 0),void setTimeout((()=>{const e=[];for(let t=0;t<200;t++)for(let n=0;n<200;n++){const r=Math.random();if(r<.05)e.push({type:"circle",x:100*t+50*(Math.random()-.5),y:100*n+50*(Math.random()-.5),r:80*Math.random()+20});else if(r<.1)e.push({type:"rect",x:100*t+50*(Math.random()-.5),y:100*n+50*(Math.random()-.5),width:80*Math.random()+20,height:20*Math.random()+80,angle:360*Math.random()-180});else if(r<.15)e.push({type:"ellipse",cx:100*t+50*(Math.random()-.5),cy:100*n+50*(Math.random()-.5),rx:80*Math.random()+20,ry:20*Math.random()+80,angle:360*Math.random()-180});else if(r<.2)e.push({type:"regular polygon",x:100*t+50*(Math.random()-.5),y:100*n+50*(Math.random()-.5),radius:80*Math.random()+20,count:[3,5,6,8][Math.floor(4*Math.random())],angle:360*Math.random()-180});else if(r<.25){const r=80*Math.random()+20;e.push({type:"star",x:100*t+50*(Math.random()-.5),y:100*n+50*(Math.random()-.5),innerRadius:r*(.4*Math.random()+.3),outerRadius:r,count:[5,6,8][Math.floor(3*Math.random())],angle:360*Math.random()-180})}}t(e)}),0)),style:{position:"relative",top:"-10px"}},"add mock data"),!y&&o().createElement("button",{disabled:!P,onClick:()=>{var e;return null==(e=m.current)?void 0:e.undo()},style:{position:"relative",top:"-10px"}},"undo"),!y&&o().createElement("button",{disabled:!k,onClick:()=>{var e;return null==(e=m.current)?void 0:e.redo()},style:{position:"relative",top:"-10px"}},"redo"),!y&&o().createElement("label",null,o().createElement("input",{type:"checkbox",checked:c,onChange:()=>u(!c)}),"panel"),o().createElement("label",null,o().createElement("input",{type:"checkbox",checked:p,onChange:()=>d(!p)}),"print mode"),o().createElement("label",null,o().createElement("input",{type:"checkbox",checked:f,onChange:()=>g(!f)}),"performance mode"),o().createElement("label",null,o().createElement("input",{type:"checkbox",checked:I,onChange:()=>O(!I)}),"debug"),o().createElement("select",{value:C,onChange:e=>E(e.target.value),style:{position:"relative"}},(0,a.getAllRendererTypes)().map((e=>o().createElement("option",{key:e,value:e},e)))),!y&&i.allSnapTypes.map((e=>o().createElement("label",{key:e,style:{position:"relative"}},o().createElement("input",{type:"checkbox",checked:x.includes(e),onChange:t=>b(t.target.checked?[...x,e]:x.filter((t=>t!==e)))}),e))),o().createElement("label",{style:{position:"relative"}},o().createElement("input",{type:"checkbox",checked:y,onChange:e=>v(e.target.checked)}),"read only"),!y&&o().createElement("label",{style:{position:"relative"}},o().createElement("input",{type:"checkbox",checked:T,onChange:e=>A(e.target.checked)}),"input fixed"),o().createElement("input",{type:"color",style:{position:"relative"},value:(0,i.getColorString)(L),onChange:e=>M((0,i.colorStringToNumber)(e.target.value))})))}},9456:(e,t,n)=>{"use strict";n.d(t,{Combination3:()=>y});var r=n(3696),o=n.n(r),i=n(8214),a=n(5011),s=n(395),c=n(7310),l=n(2693),u=n(726),p=n(4430),d=n(3685),f=n(8749),g=n(6286),h=Math.pow;const m=Math.round(15*Math.random()*h(16,3)+h(16,3)).toString(16);function y(){const[e]=o().useState(g.richTextData),[t,n]=o().useState(!0),[r,h]=o().useState(!1),y=o().useRef({blocks:{h1:a.h1,h2:a.h2,h3:a.h3,h4:a.h4,h5:a.h5,h6:a.h6,p:a.p,ul:a.ul,ol:a.ol,hr:a.hr},styles:{"font size":s.fontSize,"font family":s.fontFamily,bold:s.bold,italic:s.italic,underline:s.underline,"pass through":s.passThrough,color:s.color,"background color":s.backgroundColor},hooks:[c.useAt,l.useLink,u.useImage,d.useCircle,f.useStack],inlines:[l.link,u.image,d.circle,f.stack],textInlines:{span:p.span,code:p.code,mark:p.mark,sub:p.sub,sup:p.sup}});return e?o().createElement("div",null,o().createElement("div",null,o().createElement("label",null,o().createElement("input",{type:"checkbox",checked:t,onChange:e=>n(e.target.checked)}),"autoHeight"),o().createElement("label",null,o().createElement("input",{type:"checkbox",checked:r,onChange:e=>h(e.target.checked)}),"readOnly")),o().createElement(i.RichTextEditor,{initialState:e,width:500,height:300,autoHeight:t,readOnly:r,operator:m,plugin:y.current})):null}},7511:(e,t,n)=>{"use strict";n.d(t,{Combination4:()=>c});var r=n(3696),o=n.n(r),i=n(3802),a=Math.pow;const s=Math.round(15*Math.random()*a(16,3)+a(16,3)).toString(16);function c(){const[e]=o().useState([]),t=o().useRef(null);return e?o().createElement("div",null,o().createElement(i.CircuitGraphEditor,{operator:s,ref:t,initialState:e})):null}},3714:(e,t,n)=>{"use strict";n.d(t,{Combination5:()=>l});var r=n(3696),o=n.n(r),i=n(2100),a=n(6129),s=Math.pow;const c=Math.round(15*Math.random()*s(16,3)+s(16,3)).toString(16);function l(){const[e]=o().useState(a.astronomicalObjectData),t=o().useRef(null);return o().createElement("div",null,o().createElement(i.AstronomicalObjectSimulator,{operator:c,ref:t,initialState:e}))}},577:(e,t,n)=>{"use strict";n.d(t,{Combination6:()=>y});var r=n(3696),o=n.n(r),i=n(8662),a=n(9758),s=Object.defineProperty,c=Object.defineProperties,l=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,f=Math.pow,g=(e,t,n)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,h=(e,t)=>{for(var n in t||(t={}))p.call(t,n)&&g(e,n,t[n]);if(u)for(var n of u(t))d.call(t,n)&&g(e,n,t[n]);return e},m=(e,t)=>c(e,l(t));function y(){const{width:e,height:t}=(0,a.useWindowSize)(),n=a.reactCanvasRenderTarget,[r,s,c]=(0,a.useRefState)([]),[l,u]=o().useState(),[p,d]=o().useState(!1),[g,y]=o().useState(!1),P=o().useRef(!1),[w,k]=o().useState(),_=[],S={x:e/2,y:t-v},R=o().useRef(new WeakSet);o().useEffect((()=>{let n;const r=o=>{if(void 0!==n){const r=.002*(o-n),l=P.current?x:v,u=[];for(const n of c.current){if(n.x<0||n.y<0||n.x>e||n.y>t)continue;const o=(0,i.produce)(n,(e=>{e.x=n.x+r*n.speed.x;const t=n.speed.y+r*b;e.y=n.y+r*(0,a.getTwoNumberCenter)(t,n.speed.y),e.speed.y=t})),s=u.findIndex((e=>f(e.x-o.x,2)+f(e.y-o.y,2)<=f(l,2)));s>=0?u.splice(s,1):(u.push(o),R.current.has(n)&&(R.current.add(o),R.current.delete(n)))}s(u)}n=o,requestAnimationFrame(r)};requestAnimationFrame(r)}),[]),o().useEffect((()=>{if(!p)return;const t=setInterval((()=>{const t=Math.random();s((0,i.produce)(c.current,(n=>{n.push({type:"drop",x:t*e,y:v,speed:{x:(t>.5?-1:1)*Math.random()*e*.03,y:0}})})))}),1e3);return()=>clearInterval(t)}),[p]),o().useEffect((()=>{if(!g)return;const e=setInterval((()=>{D()}),1e3);return()=>clearInterval(e)}),[g]);const{line:T,cursorPosition:A,onClick:L,reset:M,onMove:I}=(0,a.useLineClickCreate)("drop"===l,(e=>{s((0,i.produce)(r,(t=>{t.push(E(e,v,l))}))),M()}),{once:!0}),O=e=>{M(),u(e)},D=()=>{const e=c.current.find((e=>"drop"===e.type&&!R.current.has(e)));if(!e)return;const t=function(e,t){const n=t.x-e.x,r=t.y-e.y,o=n*e.speed.y-r*e.speed.x,i=f(C,2),s=f(n,2)+f(r,2),c=4*i*f(n,2)-4*f(o,2)+4*i*f(r,2);if((0,a.lessThan)(c,0))return[];const l=-o*r,u=o*n;if((0,a.isZero)(c))return[{x:l/s,y:u/s}];const p=f(c,.5),d=.5*n*p,g=.5*r*p;return[{x:(l+d)/s,y:(u+g)/s},{x:(l-d)/s,y:(u-g)/s}]}(e,S);0!==t.length&&(s((0,i.produce)(c.current,(e=>{for(const n of t)n.y<0&&e.push(m(h({type:"shoot down"},S),{speed:n}))}))),R.current.add(e))};T?_.push(E(T,v,l)):A?_.push(E([A,A],v,l)):w&&_.push(E([S,w],v,l));const B=[];for(const e of[...r,..._]){const t="drop"===e.type?16711680:65280,r=P.current&&"shoot down"===e.type?x:v;if(B.push(n.renderCircle(e.x,e.y,r,{fillColor:t,strokeWidth:0})),e.speed.x||e.speed.y){const r=(0,a.getTwoPointsDistance)(e.speed),o=(0,a.getTwoPointsRadian)(e.speed),i=(0,a.getPointByLengthAndRadian)(e,r+v,o);B.push(n.renderPolyline([e,i],{strokeColor:t}))}}const z=(0,a.useEvent)((e=>{const t={x:e.clientX,y:e.clientY};"drop"===l?L(t):"shoot down"===l&&w&&s((0,i.produce)(r,(e=>{e.push(E([S,w],v,l))})))})),F=(0,a.useEvent)((e=>{const t={x:e.clientX,y:e.clientY};"drop"===l?I(t):"shoot down"===l&&k(t)}));return(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&(u(void 0),k(void 0),M(!0))})),o().createElement("div",{style:{position:"absolute",inset:"0px",overflow:"hidden"},onMouseMove:F},n.renderResult(B,e,t,{attributes:{onClick:z}}),o().createElement("div",{style:{position:"absolute",top:"0px"}},o().createElement(a.Button,{style:{color:"drop"===l?"red":void 0},onClick:()=>O("drop")},"drop"),o().createElement("label",{style:{position:"relative"}},o().createElement("input",{type:"checkbox",checked:p,onChange:e=>d(e.target.checked)}),"drop auto")),o().createElement("div",{style:{position:"absolute",bottom:"0px",right:"0px"}},o().createElement(a.Button,{style:{color:"shoot down"===l?"red":void 0},onClick:()=>O("shoot down")},"shoot down"),o().createElement("label",{style:{position:"relative"}},o().createElement("input",{type:"checkbox",checked:P.current,onChange:e=>P.current=e.target.checked}),"detonate"),o().createElement(a.Button,{onClick:()=>D()},"aim auto"),o().createElement("label",{style:{position:"relative"}},o().createElement("input",{type:"checkbox",checked:g,onChange:e=>y(e.target.checked)}),"shoot auto")))}const v=5,x=25,b=9.8,C=200;function E([e,t],n,r){if("drop"===r)e={x:e.x,y:n},t={x:t.x,y:n};else if("shoot down"===r){const n=(0,a.getTwoPointsRadian)(t,e),r=(0,a.multiplyDirection)((0,a.getDirectionByRadian)(n),C);return m(h({type:"shoot down"},e),{speed:r})}const o=(0,a.getTwoPointsDistance)(e,t);let i;if(o>n){const r=(0,a.getPointByLengthAndDirection)(t,o-n,e);i={x:t.x-r.x,y:t.y-r.y}}else i={x:0,y:0};return m(h({type:"drop"},e),{speed:i})}},84:(e,t,n)=>{"use strict";n.d(t,{Combination7:()=>f});var r=n(3696),o=n.n(r),i=n(8662),a=n(9758),s=n(7951),c=n(490),l=n(5527),u=n(3107),p=n(7728),d=n(5722);function f(){const e=a.reactCanvasRenderTarget,{width:t,height:n}=(0,a.useWindowSize)(),[r,f,g]=(0,a.useRefState)(s.initialModels),[h,m,y]=(0,a.useRefState)([]),[v,x]=o().useState([]),[,b,C]=(0,a.useRefState)(0),E=o().useRef();let P;v.length>0&&(P=o().createElement(l.Panel,{target:r[v[0]],status:E,updater:e=>{f((0,i.produce)(r,(t=>{e(t[0])})))}}));const{onStartSelect:w,dragSelectMask:k,resetDragSelect:_}=(0,a.useDragSelect)(((e,t)=>{var n,o;if(t&&Math.abs(e.x-t.x)>10&&Math.abs(e.y-t.y)>10){const n={start:{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y)},end:{x:Math.max(e.x,t.x),y:Math.max(e.y,t.y)}};x(Array.from(r.entries()).filter((([,e])=>(0,a.pointIsInRegion)(e.position,n))).map((([e])=>e)))}else{if(null==(n=E.current)?void 0:n.ability){const t=(0,d.getAbilityFromIndex)(E.current.ability);if(null==(o=null==t?void 0:t.cast)?void 0:o.radius)return f((0,i.produce)(r,(t=>{for(const n of v)t[n].canControl&&E.current&&(t[n].action={type:"attack",ability:E.current.ability,target:e})}))),void(E.current=void 0)}for(const[t,n]of r.entries())if((0,a.getTwoPointsDistance)(n.position,e)<=p.units[n.unit].size){if(E.current){f((0,i.produce)(r,(e=>{for(const n of v)e[n].canControl&&E.current&&(e[n].action={type:"attack",ability:E.current.ability,target:t})}))),E.current=void 0;break}x([t]);break}}}));return(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key?(_(),x([])):"s"===e.key?f((0,i.produce)(r,(e=>{for(const t of v)e[t].canControl&&e[t].action&&(e[t].action=void 0)}))):"a"===e.key&&(E.current={type:"attack"})})),o().useEffect((()=>{const e=t=>{if(0!==C.current){const e=(0,c.updateModels)(.001*(t-C.current),g.current,y.current);e.models&&f(e.models),e.bullets&&m(e.bullets)}b(t),requestAnimationFrame(e)};requestAnimationFrame(e)}),[]),o().createElement(o().Fragment,null,o().createElement("div",{style:{position:"absolute",inset:"0px",overflow:"hidden"},onMouseDown:w,onContextMenu:e=>{f((0,i.produce)(r,(t=>{for(const n of v)t[n].canControl&&(t[n].action={type:"move",to:{x:Math.round(e.clientX),y:Math.round(e.clientY)}})}))),e.preventDefault()}},e.renderResult((0,u.renderModels)(r,h,v),t,n),k),P)}},8977:(e,t,n)=>{"use strict";n.d(t,{abilities:()=>i});var r=n(5722),o=n(1915);const i=[{name:"Laguna Blade",cooldown:70,mana:150,cast:{range:300,bulletSpeed:400,hit:(e,t)=>(0,r.attackPureDamage)(e,t,500)},launch(e,t){t((t=>{a(t,e)}))}},{name:"Firestorm",cooldown:16,mana:110,cast:{range:300,bulletSpeed:400,radius:200,hit:(e,t)=>(0,r.attackPureDamage)(e,t,200)},launch(e,t){t((t=>{a(t,e)}))}}];function a(e,t){const n=i[t];if(void 0!==e.mana){const i=(0,r.getModelResult)(e);i.mana&&(e.mana=Math.min(e.mana-n.mana/i.mana.total,1)),(0,o.updateAbilityCooldown)(e,t,"abilities",n.cooldown)}}},7951:(e,t,n)=>{"use strict";n.d(t,{initialModels:()=>r});const r=[{unit:0,position:{x:200,y:200},facing:0,canControl:!0,health:.4,mana:.5,attackCooldown:0,items:[],abilities:[0,1]},{unit:1,position:{x:300,y:200},facing:0,canControl:!0,health:.8},{unit:2,position:{x:400,y:200},facing:0,canControl:!1,health:1}]},1915:(e,t,n)=>{"use strict";n.d(t,{items:()=>o,updateAbilityCooldown:()=>i});var r=n(5722);const o=[{name:"Icon Branch",strength:1,agility:1,intelligence:1},{name:"Boots of Speed",speed:45},{name:"Vitality Booster",health:250},{name:"Ring of Health",heathRegeneration:4.5},{name:"Platemail",armor:10},{name:"Cloak",magicResistance:.2},{name:"Aether Lens",mana:300,manaRegeneration:2.5},{name:"Monkey King Bar",attackDamage:40,attackSpeed:45},{name:"Arcane Boots",mana:250,speed:45,ability:{name:"Replenish Mana",cooldown:55,mana:0,launch(e,t){t((t=>{if(void 0!==t.mana){const e=(0,r.getModelResult)(t);e.mana&&(t.mana=Math.min(t.mana+175/e.mana.total,1))}const n=o[e];n.ability&&i(t,e,"items",n.ability.cooldown)}))}}},{name:"Dagon",strength:7,agility:7,intelligence:7,ability:{name:"Energy Burst",cooldown:35,mana:120,cast:{range:300,hit:(e,t)=>(0,r.attackMagicDamage)(e,t,400)},launch(e,t){t((t=>{!function(e,t){const n=o[t];if(void 0!==e.mana&&n.ability){const o=(0,r.getModelResult)(e);o.mana&&(e.mana=Math.min(e.mana-n.ability.mana/o.mana.total,1)),i(e,t,"items",n.ability.cooldown)}}(t,e)}))}}}];function i(e,t,n,r){e.abilityCooldowns||(e.abilityCooldowns=[]);const o=e.abilityCooldowns.find((e=>e.index===t));o?o.cooldown=r:e.abilityCooldowns.push({index:t,cooldown:r,source:n})}},5527:(e,t,n)=>{"use strict";n.d(t,{Panel:()=>l});var r=n(3696),o=n.n(r),i=n(9758),a=n(5722),s=n(1915),c=n(8977);function l({target:e,updater:t,status:n}){const[r,l]=o().useState(0),u=(0,a.getModelResult)(e),p={speed:o().createElement(i.Label,null,u.speed,"<-",u.baseSpeed),canControl:o().createElement(i.BooleanEditor,{value:e.canControl,setValue:e=>t((t=>{t.canControl=e}))})};let d;return u.health&&(p.health=o().createElement(i.Label,null,Math.round(u.health.current),"/",Math.round(u.health.total),"<-",Math.round(u.health.base.total)),p.healthRegeneration=o().createElement(i.Label,null,u.health.regeneration,"<-",u.health.base.regeneration),p.armor=o().createElement(i.Label,null,Math.round(u.health.armor),"<-",u.health.base.armor),p.magicResistance=o().createElement(i.Label,null,u.health.magicResistance,"<-",u.health.base.magicResistance)),u.mana&&(d=Math.round(u.mana.current),p.mana=o().createElement(i.Label,null,d,"/",Math.round(u.mana.total),"<-",Math.round(u.mana.base.total)),p.manaRegeneration=o().createElement(i.Label,null,u.mana.regeneration,"<-",u.mana.regeneration)),u.attack&&(p.damage=o().createElement(i.Label,null,Math.round(u.attack.damage),"+-",u.attack.damageRange,"<-",u.attack.base.damage),p.attackSpeed=o().createElement(i.Label,null,u.attack.speed,"<-",u.attack.base.speed),p.attackTime=o().createElement(i.Label,null,Math.round(u.attack.time),"<-",u.attack.base.time),p.bulletSpeed=o().createElement(i.Label,null,u.attack.bulletSpeed),p.attackRange=o().createElement(i.Label,null,u.attack.range,"<-",u.attack.base.range)),u.attributes&&(p.strength=o().createElement(i.Label,null,u.attributes.strength,"<-",u.attributes.base.strength),p.agility=o().createElement(i.Label,null,u.attributes.agility,"<-",u.attributes.base.agility),p.intelligence=o().createElement(i.Label,null,u.attributes.intelligence,"<-",u.attributes.base.intelligence),p.primary=o().createElement(i.Label,null,u.attributes.primary)),o().createElement("div",{style:{position:"absolute",right:"0px",top:"0px",bottom:"0px",width:"400px",overflowY:"auto",background:"white",zIndex:11}},o().createElement("select",{value:r,onChange:e=>l(+e.target.value)},s.items.map(((e,t)=>o().createElement("option",{key:e.name,value:t},e.name)))),e.items&&o().createElement(i.ArrayEditor,{inline:!0,add:()=>t((e=>{e.items&&e.items.push(r)})),remove:e=>t((t=>{t.items&&t.items.splice(e,1)})),items:e.items.map((r=>{var a,c;const l=s.items[r],u=null==(c=null==(a=e.abilityCooldowns)?void 0:a.find((e=>"items"===e.source&&e.index===r)))?void 0:c.cooldown;if(!l.ability)return o().createElement(i.Label,null,s.items[r].name);const p=!!u||void 0===d||d{l.ability&&!p&&(l.ability.cast?n.current={type:"attack",ability:{index:r,source:"items"}}:l.ability.launch(r,t))}},s.items[r].name," ",u?u.toFixed(1):"")}))}),e.abilities&&o().createElement(i.ArrayEditor,{inline:!0,items:e.abilities.map((r=>{var a,s;const l=c.abilities[r],u=null==(s=null==(a=e.abilityCooldowns)?void 0:a.find((e=>"abilities"===e.source&&e.index===r)))?void 0:s.cooldown,p=!!u||void 0===d||d{p||(l.cast?n.current={type:"attack",ability:{index:r,source:"abilities"}}:l.launch(r,t))}},c.abilities[r].name," ",u?u.toFixed(1):"")}))}),o().createElement(i.ObjectEditor,{inline:!0,properties:p}))}},3107:(e,t,n)=>{"use strict";n.d(t,{renderModels:()=>i});var r=n(9758),o=n(7728);function i(e,t,n){const i=r.reactCanvasRenderTarget,a=e.map(((e,t)=>{const a=o.units[e.unit].size,s=n.includes(t)?e.canControl?65280:255:void 0,c=[i.renderCircle(e.position.x,e.position.y,a,{strokeColor:s}),i.renderPolyline([(0,r.getPointByLengthAndRadian)(e.position,a,e.facing),(0,r.getPointByLengthAndRadian)(e.position,2*a,e.facing)],{strokeColor:s})];if(void 0!==e.health){const t=6,n=a,r=e.health;c.push(i.renderRect(e.position.x-n/2,e.position.y-a-t,n,t),i.renderRect(e.position.x-n/2,e.position.y-a-t,r*a,t,{fillColor:65280}))}if(void 0!==e.mana){const t=6,n=-6,r=a,o=e.mana;c.push(i.renderRect(e.position.x-r/2,e.position.y-a-t-n,r,t),i.renderRect(e.position.x-r/2,e.position.y-a-t-n,o*a,t,{fillColor:255}))}return i.renderGroup(c)}));return a.push(...t.map((e=>"instant"===e.type?i.renderEmpty():i.renderCircle(e.position.x,e.position.y,5)))),a}},490:(e,t,n)=>{"use strict";n.d(t,{updateModels:()=>c});var r=n(8662),o=n(9758),i=n(5722),a=n(1915),s=n(7728);function c(e,t,n){var c,l;const u=[...t];let p=!1;const d=[];for(const t of n){const n=u[t.source];let a;if(void 0===t.type){const n=e*t.speed,r=u[t.target];(0,o.getTwoPointsDistance)(t.position,r.position)-s.units[r.unit].size>n&&(a=(0,o.getPointByLengthAndDirection)(t.position,n,r.position))}else if("position"===t.type){const n=e*t.speed;(0,o.getTwoPointsDistance)(t.position,t.target)>n&&(a=(0,o.getPointByLengthAndDirection)(t.position,n,t.target))}if(a){const e=a;d.push((0,r.produce)(t,(t=>{void 0!==t.type&&"position"!==t.type||(t.position=e)})))}else{const e="position"===t.type?(0,i.getModelsAroundPositionByRadiusExcept)(u,t.target,t.radius,t.source):[[t.target,u[t.target]]];for(const[o,a]of e){if(!s.units[a.unit].health)continue;const e=(0,i.getModelResult)(n),c=(0,i.getModelResult)(a);if(t.ability){const e=(0,i.getAbilityFromIndex)(t.ability);if(null==e?void 0:e.cast){const t=e.cast.hit(a,c);t&&(u[o]=t,p=!0)}}else if(e.attack&&c.health){const s=(0,i.getDamageAfterArmor)(e.attack.damage+Math.random()*e.attack.damageRange,c.health.armor),l=Math.max(0,(c.health.current-s)/c.health.total);u[o]=(0,r.produce)(a,(e=>{e.health=l})),0===l&&(u[t.source]=(0,r.produce)(n,(e=>{e.action=void 0}))),p=!0}}}}for(const t of u.keys()){let n=u[t];const f=(0,i.getModelResult)(n);if(void 0!==n.health&&f.health&&f.health.regeneration&&n.health>0&&n.health<1){const o=e*f.health.regeneration,i=f.health.total;u[t]=(0,r.produce)(n,(e=>{e.health&&(e.health=Math.min(e.health+o/i,1))})),p=!0,n=u[t]}if(void 0!==n.mana&&f.mana&&f.mana.regeneration&&n.mana<1){const o=e*f.mana.regeneration,i=f.mana.total;u[t]=(0,r.produce)(n,(e=>{e.mana&&(e.mana=Math.min(e.mana+o/i,1))})),p=!0,n=u[t]}if(n.abilityCooldowns&&n.abilityCooldowns.length>0){const o=[];for(const t of n.abilityCooldowns){const n=Math.max(0,t.cooldown-e);n&&o.push({index:t.index,source:t.source,cooldown:n})}u[t]=(0,r.produce)(n,(e=>{e.abilityCooldowns=o})),p=!0,n=u[t]}if(n.action){if("attack"===n.action.type){let g,h,m=0;if("number"==typeof n.action.target){const e=u[n.action.target];g=e.position,h=!!e.health&&e.health>0,m=s.units[e.unit].size}else g=n.action.target,h=!0;const y=(0,o.getTwoPointsRadian)(g,n.position);if(h){const h=(0,o.getTwoPointsDistance)(n.position,g)-s.units[n.unit].size-m;if(n.action.ability){const m=(0,i.getAbilityFromIndex)(n.action.ability),{index:v,source:x}=n.action.ability;if(null==m?void 0:m.cast){if(h>m.cast.range){const i=e*f.speed,a=(0,o.getPointByLengthAndDirection)(n.position,i,g);u[t]=(0,r.produce)(n,(e=>{e.position=a,e.facing=y})),p=!0;continue}if(!(null==(l=null==(c=n.abilityCooldowns)?void 0:c.find((e=>e.source===x&&e.index===v)))?void 0:l.cooldown)){if(u[t]=(0,r.produce)(n,(e=>{e.facing=y,e.action=void 0,(0,a.updateAbilityCooldown)(e,v,x,m.cooldown),m.launch(v,(t=>{t(e)}))})),"number"!=typeof n.action.target){m.cast.bulletSpeed&&m.cast.radius&&(d.push({type:"position",position:(0,o.getPointByLengthAndDirection)(n.position,s.units[n.unit].size,g),source:t,target:g,speed:m.cast.bulletSpeed,radius:m.cast.radius,ability:{index:v,source:x}}),p=!0);continue}if(!m.cast.bulletSpeed){d.push({type:"instant",source:t,target:n.action.target,ability:{index:v,source:x}}),p=!0;continue}d.push({position:(0,o.getPointByLengthAndDirection)(n.position,s.units[n.unit].size,g),source:t,target:n.action.target,ability:{index:v,source:x},speed:m.cast.bulletSpeed}),p=!0;continue}u[t]=(0,r.produce)(n,(e=>{e.facing=y})),p=!0;continue}}else if(f.attack){if(h>f.attack.range){const i=e*f.speed,a=(0,o.getPointByLengthAndDirection)(n.position,i,g);u[t]=(0,r.produce)(n,(e=>{e.position=a,e.facing=y})),p=!0;continue}const i=f.attack.time;if(0===f.attack.cooldown&&"number"==typeof n.action.target){u[t]=(0,r.produce)(n,(e=>{e.facing=y,e.attackCooldown=.001*i})),d.push({position:(0,o.getPointByLengthAndDirection)(n.position,s.units[n.unit].size,g),source:t,target:n.action.target,speed:f.attack.bulletSpeed}),p=!0;continue}u[t]=(0,r.produce)(n,(t=>{t.facing=y,t.attackCooldown&&(t.attackCooldown=Math.max(0,t.attackCooldown-e))})),p=!0;continue}}y!==n.facing&&(u[t]=(0,r.produce)(n,(e=>{e.facing=y})),p=!0);continue}const g=e*f.speed,h=n.action.to,m=(0,o.getTwoPointsDistance)(n.position,h),y=(0,o.getTwoPointsRadian)(h,n.position);let v;if(m<=g)v=(0,r.produce)(n,(e=>{e.position=h,e.action=void 0,e.facing=y}));else{const e=(0,o.getPointByLengthAndDirection)(n.position,g,h);v=(0,r.produce)(n,(t=>{t.position=e,t.facing=y}))}let x=!0;for(let e=0;e{e.facing=y})),p=!0)}}return{models:p?u:void 0,bullets:d.length>0||n.length>0?d:void 0}}},7728:(e,t,n)=>{"use strict";n.d(t,{units:()=>r});const r=[{speed:300,size:24,health:{total:500,regeneration:10,armor:0,magicResistance:.25},mana:{total:400,regeneration:.5},attack:{damage:50,damageRange:2,speed:100,time:1700,bulletSpeed:900,range:300},attributes:{strength:20,agility:30,intelligence:15,primary:"agility"}},{speed:300,size:24,health:{total:600,regeneration:10,armor:10,magicResistance:.25}},{speed:300,size:24,health:{total:700,regeneration:10,armor:-10,magicResistance:0}}]},5722:(e,t,n)=>{"use strict";n.d(t,{attackMagicDamage:()=>C,attackPureDamage:()=>b,getAbilityFromIndex:()=>x,getDamageAfterArmor:()=>v,getModelResult:()=>y,getModelsAroundPositionByRadiusExcept:()=>E});var r=n(8662),o=n(8977),i=n(1915),a=n(7728),s=n(9758),c=Object.defineProperty,l=Object.defineProperties,u=Object.getOwnPropertyDescriptors,p=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,f=Object.prototype.propertyIsEnumerable,g=(e,t,n)=>t in e?c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,h=(e,t)=>{for(var n in t||(t={}))d.call(t,n)&&g(e,n,t[n]);if(p)for(var n of p(t))f.call(t,n)&&g(e,n,t[n]);return e},m=(e,t)=>l(e,u(t));function y(e){const t=a.units[e.unit];let n=t.speed;const r=t.attributes?m(h({},t.attributes),{base:t.attributes}):void 0,o=t.health&&void 0!==e.health?m(h({},t.health),{current:e.health,base:t.health}):void 0,s=t.mana&&void 0!==e.mana?m(h({},t.mana),{current:e.mana,base:t.mana}):void 0,c=t.attack&&void 0!==e.attackCooldown?m(h({},t.attack),{cooldown:e.attackCooldown,base:t.attack}):void 0;let l=1;if(e.items)for(const t of e.items){const e=i.items[t];e.speed&&(n+=e.speed),o&&(e.health&&(o.total+=e.health),e.heathRegeneration&&(o.regeneration+=e.heathRegeneration),e.armor&&(o.armor+=e.armor),e.magicResistance&&(l*=1-e.magicResistance)),s&&(e.mana&&(s.total+=e.mana),e.manaRegeneration&&(s.regeneration+=e.manaRegeneration)),c&&(e.attackDamage&&(c.damage+=e.attackDamage),e.attackSpeed&&(c.speed+=e.attackSpeed),e.attackRange&&(c.range+=e.attackRange)),r&&(e.strength&&(r.strength+=e.strength),e.agility&&(r.agility+=e.agility),e.intelligence&&(r.intelligence+=e.intelligence))}return o&&((null==r?void 0:r.strength)&&(o.total+=22*r.strength,o.regeneration+=.1*r.strength),(null==r?void 0:r.agility)&&(o.armor+=r.agility/6),(null==r?void 0:r.intelligence)&&(o.magicResistance=1-(1-(o.magicResistance+.001*r.intelligence))*l),o.current*=o.total),s&&((null==r?void 0:r.intelligence)&&(s.total+=12*r.intelligence,s.regeneration+=.05*r.intelligence),s.current*=s.total),c&&r&&("strength"===r.primary?c.damage+=r.strength:"agility"===r.primary?c.damage+=r.agility:"intelligence"===r.primary?c.damage+=r.intelligence:c.damage+=.7*(r.strength+r.agility+r.intelligence),r.agility&&(c.speed+=r.agility),c.time*=100/c.speed),{size:t.size,baseSpeed:t.speed,speed:n,health:o,mana:s,attack:c,attributes:r}}function v(e,t){return e*(1-.06*t/(1+.06*Math.abs(t)))}function x(e){return"abilities"===e.source?o.abilities[e.index]:i.items[e.index].ability}function b(e,t,n){if(!t.health||void 0===e.health)return e;const o=t.health.total,i=Math.max(0,e.health-n/o);return(0,r.produce)(e,(e=>{e.health=i}))}function C(e,t,n){if(!t.health||void 0===e.health)return e;const o=t.health.magicResistance,i=t.health.total,a=n*(1-o),s=Math.max(0,e.health-a/i);return(0,r.produce)(e,(e=>{e.health=s}))}function E(e,t,n,r){return Array.from(e.entries()).filter((([e,o])=>e!==r&&(0,s.getTwoPointsDistance)(o.position,t)-a.units[o.unit].size<=n))}},6523:(e,t,n)=>{"use strict";n.d(t,{Combination8:()=>m});var r=n(3696),o=n(8662),i=n(9397),a=n(9758),s=Object.defineProperty,c=Object.defineProperties,l=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,f=(e,t,n)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,g=(e,t)=>{for(var n in t||(t={}))p.call(t,n)&&f(e,n,t[n]);if(u)for(var n of u(t))d.call(t,n)&&f(e,n,t[n]);return e},h=(e,t)=>c(e,l(t));function m(){const e=r.useRef(null),t=r.useRef(),{x:n,y:i,setX:s,setY:c,ref:l}=(0,a.useWheelScroll)(),{scale:u,setScale:p,ref:d}=(0,a.useWheelZoom)(),f=(0,a.useWindowSize)(),m=f.width,P=f.height,[w,k]=r.useState(),_=r.useRef(new a.WeakmapCache),S=r.useRef(new a.WeakmapCache),R=r.useRef((0,a.getAxesGraphics)()),[,T,A]=(0,a.useLocalStorageState)("composable-editor-canvas-combination8-data",[]),{state:L,setState:M,undo:I,redo:O}=(0,a.useUndoRedo)(A,{onChange:({newState:e})=>{T(e)}}),[D,B]=r.useState(),z=r.useRef(16711680),F=r.useRef(1),N=r.useRef(5),U=r.useRef(0),[G,j]=r.useState(),[V,W]=r.useState(),[H,q]=r.useState();r.useEffect((()=>{e.current&&!t.current&&(t.current=(0,a.createWebgl3DRenderer)(e.current))}),[e.current]),(0,a.useGlobalKeyDown)((e=>{(0,a.metaKeyIfMacElseCtrlKey)(e)?"KeyZ"===e.code?e.shiftKey?O(e):I(e):"Digit0"!==e.code||e.shiftKey||(p(1),s(0),c(0),e.preventDefault()):"Escape"===e.key?(k(void 0),B(void 0),j(void 0),W(void 0),q(void 0)):"Delete"!==e.key&&"Backspace"!==e.key&&"KeyE"!==e.code||void 0!==V&&(M((e=>{e.splice(V,1)})),W(void 0))}));const{position:$,up:X}=(0,a.updateCamera)(0,0,200/u,-.3*n,-.3*i),Y=(0,a.position3DToVec3)($),K=[0,0,0],Z=e=>{const t=a.v3.substract(Y,K);return e?(0,a.getPlaneByPointAndNormal)(e,t):{a:t[0],b:t[1],c:t[2],d:-U.current*a.v3.length(t)}};let Q;if(void 0!==V){const e={},t=L[V].geometry;if(e.color=r.createElement(a.NumberEditor,{value:(0,a.vecToColorNumber)(L[V].color),type:"color",setValue:e=>{M((t=>{t[V].color=(0,a.colorNumberToVec)(e,L[V].color[3])}))}}),e.opacity=r.createElement(a.NumberEditor,{value:100*L[V].color[3],setValue:e=>{M((t=>{t[V].color[3]=.01*e}))}}),"cube"===t.type)e.size=r.createElement(a.NumberEditor,{value:t.size,setValue:e=>{M((t=>{"cube"===t[V].geometry.type&&(t[V].geometry.size=e)}))}});else if("sphere"===t.type)e.radius=r.createElement(a.NumberEditor,{value:t.radius,setValue:e=>{M((t=>{"sphere"===t[V].geometry.type&&(t[V].geometry.radius=e)}))}});else if("cylinder"===t.type)e.radius=r.createElement(a.NumberEditor,{value:t.radius,setValue:e=>{M((t=>{"cylinder"===t[V].geometry.type&&(t[V].geometry.radius=e)}))}}),e.height=r.createElement(a.NumberEditor,{value:t.height,setValue:e=>{M((t=>{"cylinder"===t[V].geometry.type&&(t[V].geometry.height=e)}))}});else if("cone"===t.type)e.topRadius=r.createElement(a.NumberEditor,{value:t.topRadius,setValue:e=>{M((t=>{"cone"===t[V].geometry.type&&(t[V].geometry.topRadius=e)}))}}),e.bottomRadius=r.createElement(a.NumberEditor,{value:t.bottomRadius,setValue:e=>{M((t=>{"cone"===t[V].geometry.type&&(t[V].geometry.bottomRadius=e)}))}}),e.height=r.createElement(a.NumberEditor,{value:t.height,setValue:e=>{M((t=>{"cone"===t[V].geometry.type&&(t[V].geometry.height=e)}))}});else if("point"===t.type){for(const n of["x","y","z"])e[`point ${n}`]=r.createElement(a.NumberEditor,{value:t.position[n],setValue:e=>{M((t=>{"point"===t[V].geometry.type&&(t[V].geometry.position[n]=e)}))}});e.point=r.createElement(a.Button,{onClick:()=>{k({type:"update point",plane:Z((0,a.position3DToVec3)(t.position)),updatePoint(e){B((0,o.produce)(L[V],(t=>{"point"===t.geometry.type&&(t.geometry.position=e)})))}})}},"update")}else if("triangle"===t.type)for(const n of["p1","p2"]){for(const o of["x","y","z"])e[`${n} ${o}`]=r.createElement(a.NumberEditor,{value:t[n][o],setValue:e=>{M((t=>{"triangle"===t[V].geometry.type&&(t[V].geometry[n][o]=e)}))}});e[n]=r.createElement(a.Button,{onClick:()=>{k({type:"update point",plane:Z((0,a.position3DToVec3)(t[n])),updatePoint(e){B((0,o.produce)(L[V],(t=>{"triangle"===t.geometry.type&&(t.geometry[n]=e)})))}})}},"update")}for(const t of["x","y","z"])e[`position ${t}`]=r.createElement(a.NumberEditor,{value:L[V].position[t],setValue:e=>{M((n=>{n[V].position[t]=e}))}});if(e.position=r.createElement(a.Button,{onClick:()=>{k({type:"update point",plane:Z((0,a.position3DToVec3)(L[V].position)),updatePoint(e){B((0,o.produce)(L[V],(t=>{t.position=e})))}})}},"update"),"cylinder"===t.type||"cone"===t.type){for(const t of["x","y","z"])e[`direction ${t}`]=r.createElement(a.NumberEditor,{value:(L[V].direction||{x:0,y:1,z:0})[t],setValue:e=>{M((n=>{n[V].direction||(n[V].direction={x:0,y:1,z:0}),n[V].direction[t]=e}))}});e.direction=r.createElement(a.Button,{onClick:()=>{k({type:"update point",plane:Z((0,a.position3DToVec3)(L[V].position)),updatePoint(e){B((0,o.produce)(L[V],(t=>{t.direction=(0,a.vec3ToPosition3D)(a.v3.substract((0,a.position3DToVec3)(e),(0,a.position3DToVec3)(t.position)))})))}})}},"update")}Q=r.createElement("div",{style:{position:"absolute",right:"0px",top:"40px",bottom:"0px",width:"360px",overflowY:"auto",background:"white"}},r.createElement(a.ObjectEditor,{inline:!0,properties:e}))}const J=e=>_.current.get(e,(()=>"point"===e.geometry.type?{geometry:{type:"lines",points:[...(0,a.position3DToVec3)(e.position),...(0,a.position3DToVec3)(e.geometry.position)]},color:e.color}:"triangle"===e.geometry.type?{geometry:{type:"triangles",points:[...(0,a.position3DToVec3)(e.position),...(0,a.position3DToVec3)(e.geometry.p1),...(0,a.position3DToVec3)(e.geometry.p2)]},color:e.color}:"line strip"===e.geometry.type?{geometry:{type:"line strip",points:e.geometry.points.flat()},color:e.color}:{geometry:e.geometry,color:e.color,position:(0,a.position3DToVec3)(e.position),direction:e.direction?(0,a.position3DToVec3)(e.direction):void 0}));return r.useEffect((()=>{const e=[...L.map(((e,t)=>(G!==t&&V!==t||(e=S.current.get(e,(()=>(0,o.produce)(e,(e=>{e.color[3]*=.5}))))),J(e))))];var n,r,i;e.push(...R.current),D&&e.push(J(D)),n=e,null==(i=null==(r=t.current)?void 0:r.render)||i.call(r,n,{eye:Y,up:(0,a.position3DToVec3)(X),target:K,fov:(0,a.angleToRadian)(60),near:.1,far:2e4},{position:[1e3,1e3,1e3],color:[1,1,1,1],specular:[1,1,1,1],shininess:50,specularFactor:1},[1,1,1,1])}),[L,D,G,V,n,i,u,m,P]),r.createElement("div",{ref:(0,a.bindMultipleRefs)(l,d),style:{position:"absolute",inset:"0px",cursor:H?"pointer":void 0}},r.createElement("canvas",{ref:e,width:m,height:P,onMouseMove:e=>{var n;if(!w&&void 0!==V&&t.current){const n=t.current.reversedProjection,r=L[V];if(n&&r){const o=(0,a.reverse3dPosition)(e.clientX,e.clientY,t.current.canvas,n),i=[{point:r.position,updatePoint(e,t){e.position=t}}];if("point"===r.geometry.type)i.push({point:r.geometry.position,updatePoint(e,t){"point"===e.geometry.type&&(e.geometry.position=t)}});else if("triangle"===r.geometry.type)i.push({point:r.geometry.p1,updatePoint(e,t){"triangle"===e.geometry.type&&(e.geometry.p1=t)}},{point:r.geometry.p2,updatePoint(e,t){"triangle"===e.geometry.type&&(e.geometry.p2=t)}});else if("cylinder"===r.geometry.type||"cone"===r.geometry.type){const e=(0,a.position3DToVec3)(r.position);i.push({point:(0,a.vec3ToPosition3D)((0,a.getPointByLengthAndDirection3D)(e,r.geometry.height/2,(0,a.position3DToVec3)(r.direction||{x:0,y:1,z:0}))),updatePoint(t,n){t.direction=(0,a.vec3ToPosition3D)(a.v3.substract((0,a.position3DToVec3)(n),e))}})}for(const e of i)if((0,a.getPerpendicularDistanceToLine3D)((0,a.position3DToVec3)(e.point),o,a.v3.substract(Y,o))<3)return void q(e);q(void 0)}}if(w&&"intersect"!==w){if(t.current){const n=t.current.reversedProjection;if(n){if("string"!=typeof w&&void 0!==V&&"update point"===w.type){const r=t.current.getTarget(e.clientX,e.clientY,Y,w.plane,n);return void(r&&w.updatePoint((0,a.vec3ToPosition3D)(r)))}const r=t.current.getTarget(e.clientX,e.clientY,Y,Z(),n);if(!r)return;const o=(0,a.colorNumberToVec)(z.current,F.current),i=(0,a.vec3ToPosition3D)(r);if("cube"===w?B({geometry:{type:"cube",size:N.current},color:o,position:i}):"sphere"===w?B({geometry:{type:"sphere",radius:N.current},color:o,position:i}):"cylinder"===w?B({geometry:{type:"cylinder",radius:N.current,height:N.current},color:o,position:i}):"cone"===w&&B({geometry:{type:"cone",topRadius:0,bottomRadius:N.current,height:2*N.current},color:o,position:i}),"string"==typeof w)return;"line start"===w.type?k(h(g({},w),{position:i})):"line end"===w.type?B({geometry:{type:"point",position:w.position},color:o,position:i}):"plane 1st point"===w.type?k(h(g({},w),{p1:i})):"plane 2nd point"===w.type?(k(h(g({},w),{p2:i})),B({geometry:{type:"point",position:w.p1},color:o,position:i})):"plane 3rd point"===w.type&&B({geometry:{type:"triangle",p1:w.p1,p2:w.p2},color:o,position:i})}}}else{const r=null==(n=t.current)?void 0:n.pick(e.clientX,e.clientY);j(r)}},onMouseDown:()=>{if(w){if("string"!=typeof w&&"plane 2nd point"===w.type&&w.p2)k({type:"plane 3rd point",p1:w.p1,p2:w.p2});else if(D)"string"!=typeof w&&"update point"===w.type&&void 0!==V?(M((e=>{e[V]=D})),k(void 0)):M((e=>{e.push(D)})),B(void 0),"string"==typeof w||"line end"!==w.type&&"plane 3rd point"!==w.type||k(void 0);else if("string"!=typeof w&&"line start"===w.type&&w.position)k({type:"line end",position:w.position});else if("string"!=typeof w&&"plane 1st point"===w.type&&w.p1)k({type:"plane 2nd point",p1:w.p1});else if("intersect"===w&&void 0!==G&&void 0!==V&&G!==V){const e=L[G],t=L[V];let n,r;if("point"===e.geometry.type){if("point"===t.geometry.type){const r=v(e.geometry,e.position),o=v(t.geometry,t.position),i=(0,a.getTwoLine3DIntersectionPoint)(r[0],a.v3.substract(...r),o[0],a.v3.substract(...o));i&&(n=[i])}else if("sphere"===t.geometry.type)n=(0,a.getLineAndSphereIntersectionPoints)(v(e.geometry,e.position),C(t.geometry,t.position));else if("cylinder"===t.geometry.type)n=(0,a.getLineAndCylinderIntersectionPoints)(v(e.geometry,e.position),b(t.geometry,t.position,t.direction));else if("cone"===t.geometry.type)n=(0,a.equals)(t.geometry.topRadius,t.geometry.bottomRadius)?(0,a.getLineAndCylinderIntersectionPoints)(v(e.geometry,e.position),b({type:"cylinder",height:t.geometry.height,radius:t.geometry.bottomRadius},t.position,t.direction)):(0,a.getLineAndConeIntersectionPoints)(v(e.geometry,e.position),E(t.geometry,t.position,t.direction));else if("triangle"===t.geometry.type){const r=x(t.geometry,t.position);if(r){const t=(0,a.getLineAndPlaneIntersectionPoint)(v(e.geometry,e.position),r);t&&(n=[t])}}else if("cube"===t.geometry.type){const r=y(t.geometry,t.position);n=(0,a.getLineAndTrianglesIntersectionPoint)(v(e.geometry,e.position),r)}}else if("sphere"===e.geometry.type)if("point"===t.geometry.type)n=(0,a.getLineAndSphereIntersectionPoints)(v(t.geometry,t.position),C(e.geometry,e.position));else if("triangle"===t.geometry.type){const n=x(t.geometry,t.position);n&&(r=(0,a.getPlaneSphereIntersection)(n,C(e.geometry,e.position)))}else"sphere"===t.geometry.type&&(r=(0,a.getTwoSpheresIntersection)(C(e.geometry,e.position),C(t.geometry,t.position)));else if("cylinder"===e.geometry.type){if("point"===t.geometry.type)n=(0,a.getLineAndCylinderIntersectionPoints)(v(t.geometry,t.position),b(e.geometry,e.position,e.direction));else if("triangle"===t.geometry.type){const n=x(t.geometry,t.position);n&&(r=(0,a.getPlaneCylinderIntersection)(n,b(e.geometry,e.position,e.direction)))}}else if("cone"===e.geometry.type)"point"===t.geometry.type&&(n=(0,a.equals)(e.geometry.topRadius,e.geometry.bottomRadius)?(0,a.getLineAndCylinderIntersectionPoints)(v(t.geometry,t.position),b({type:"cylinder",height:e.geometry.height,radius:e.geometry.bottomRadius},e.position,e.direction)):(0,a.getLineAndConeIntersectionPoints)(v(t.geometry,t.position),E(e.geometry,e.position,e.direction)));else if("triangle"===e.geometry.type){if("point"===t.geometry.type){const r=x(e.geometry,e.position);if(r){const e=(0,a.getLineAndPlaneIntersectionPoint)(v(t.geometry,t.position),r);e&&(n=[e])}}else if("sphere"===t.geometry.type){const n=x(e.geometry,e.position);n&&(r=(0,a.getPlaneSphereIntersection)(n,C(t.geometry,t.position)))}else if("cylinder"===t.geometry.type){const n=x(e.geometry,e.position);n&&(r=(0,a.getPlaneCylinderIntersection)(n,b(t.geometry,t.position,t.direction)))}}else if("cube"===e.geometry.type&&"point"===t.geometry.type){const r=y(e.geometry,e.position);n=(0,a.getLineAndTrianglesIntersectionPoint)(v(t.geometry,t.position),r)}n&&n.length>0&&(M((e=>{e.push(...n.map((e=>({geometry:{type:"sphere",radius:N.current},color:(0,a.colorNumberToVec)(z.current,F.current),position:(0,a.vec3ToPosition3D)(e)}))))})),k(void 0)),r&&r.length>0&&(M((e=>{e.push({geometry:{type:"line strip",points:r},color:(0,a.colorNumberToVec)(z.current,F.current),position:{x:0,y:0,z:0}})})),k(void 0))}}else{if(void 0!==V&&H){const e=L[V];if(e)return void k({type:"update point",plane:Z((0,a.position3DToVec3)(H.point)),updatePoint(t){B((0,o.produce)(e,(e=>{H.updatePoint(e,t)})))}})}void 0!==G&&W(G)}}}),r.createElement("div",{style:{position:"absolute",top:"0px"}},["cube","sphere","cylinder","cone"].map((e=>r.createElement(a.Button,{key:e,style:{color:w===e?"red":void 0},onClick:()=>k(e)},e))),r.createElement(a.Button,{style:{color:"string"!=typeof w&&"line start"===(null==w?void 0:w.type)?"red":void 0},onClick:()=>k({type:"line start"})},"line"),r.createElement(a.Button,{style:{color:"string"!=typeof w&&"plane 1st point"===(null==w?void 0:w.type)?"red":void 0},onClick:()=>k({type:"plane 1st point"})},"plane"),void 0!==V&&r.createElement(a.Button,{onClick:()=>{M((e=>{e.splice(V,1)})),W(void 0)}},"delete"),void 0!==V&&r.createElement(a.Button,{onClick:()=>k("intersect")},"intersect"),r.createElement(a.NumberEditor,{value:U.current,style:{width:"50px",position:"relative"},setValue:e=>{U.current=e}}),r.createElement(a.NumberEditor,{value:N.current,style:{width:"40px",position:"relative"},setValue:e=>{N.current=e}}),r.createElement(a.NumberEditor,{value:100*F.current,style:{width:"50px",position:"relative"},setValue:e=>{F.current=.01*e}}),r.createElement(a.NumberEditor,{value:z.current,type:"color",style:{width:"50px",position:"relative"},setValue:e=>{z.current=e}})),Q)}function y(e,t){return(0,a.getVerticesTriangles)(i.primitives.createCubeVertices(e.size),(0,a.position3DToVec3)(t))}function v(e,t){return[(0,a.position3DToVec3)(t),(0,a.position3DToVec3)(e.position)]}function x(e,t){return(0,a.getThreePointPlane)((0,a.position3DToVec3)(t),(0,a.position3DToVec3)(e.p1),(0,a.position3DToVec3)(e.p2))}function b(e,t,n={x:0,y:1,z:0}){return{base:(0,a.position3DToVec3)(t),radius:e.radius,direction:(0,a.position3DToVec3)(n),height1:-e.height/2,height2:e.height/2}}function C(e,t){return g({radius:e.radius},t)}function E(e,t,n={x:0,y:1,z:0}){const r=(0,a.position3DToVec3)(n),o=e.height/2*(e.topRadius+e.bottomRadius)/(e.bottomRadius-e.topRadius);return{base:(0,a.getPointByLengthAndDirection3D)((0,a.position3DToVec3)(t),o,r),radiusHeightRate:Math.abs(e.bottomRadius-e.topRadius)/e.height,direction:r,height1:-o-e.height/2,height2:-o+e.height/2}}},8781:(e,t,n)=>{"use strict";n.d(t,{styleGuide:()=>r});const r={name:"test",templates:[{id:"1",name:"组件",x:0,y:0,width:500,height:300,contents:[{kind:"text",text:"test",fontFamily:"serif",fontSize:50,color:"#ff0000",width:100,height:100,x:10,y:10},{kind:"image",url:"https://interactive-examples.mdn.mozilla.net/media/cc0-images/grapefruit-slice-332-332.jpg",width:100,height:100,x:210,y:10}]},{id:"2",name:"模板",x:600,y:0,width:1100,height:400,contents:[{kind:"color",x:0,y:0,width:1100,height:400,color:"#cccccc"},{kind:"reference",id:"1",x:10,y:10},{kind:"snapshot",rotate:30,snapshot:{id:"1",name:"组件",x:0,y:0,width:500,height:300,contents:[{kind:"text",text:"test",fontFamily:"serif",fontSize:50,color:"#ff0000",width:100,height:100,x:10,y:10},{kind:"image",url:"https://interactive-examples.mdn.mozilla.net/media/cc0-images/grapefruit-slice-332-332.jpg",width:100,height:100,x:210,y:10}]},x:550,y:10}]}]}},4341:(e,t,n)=>{"use strict";n.d(t,{HoverRenderer:()=>a});var r=n(3696),o=n.n(r),i=n(681);function a(e){var t,n;const{styleGuide:r,hovered:a}=e,s=(0,i.getTargetByPath)(a,r);if(!s)return null;const c=s.template;if("template"===s.kind)return o().createElement(o().Fragment,null,o().createElement("div",{style:{position:"absolute",boxSizing:"border-box",left:c.x,top:c.y,width:c.width,height:c.height,backgroundColor:"green",opacity:.1}}));const l=s.content,u=(0,i.getTemplateContentSize)(l,r);if(!u)return null;const{width:p,height:d}=u;let f=o().createElement("div",{style:{position:"absolute",boxSizing:"border-box",left:l.x,top:l.y,width:p,height:d,backgroundColor:"green",opacity:.1,transform:`rotate(${null!=(t=l.rotate)?t:0}deg)`}});for(const e of s.parents)"snapshot"===e.kind&&(f=o().createElement("div",{style:{position:"absolute",left:e.x,top:e.y,width:e.snapshot.width,height:e.snapshot.height,transform:`rotate(${null!=(n=e.rotate)?n:0}deg)`}},f));return o().createElement("div",{style:{position:"absolute",left:c.x,top:c.y,width:c.width,height:c.height}},f)}},5371:(e,t,n)=>{"use strict";n.d(t,{App:()=>f});var r=n(3696),o=n.n(r),i=n(9758),a=n(8781),s=n(4341),c=n(2550),l=n(2801),u=n(681);const p="composable-editor-canvas-draft",d=localStorage.getItem(p);function f(){var e;const{state:t,setState:n,undo:r,redo:f,stateIndex:h}=(0,i.useUndoRedo)(d?JSON.parse(d):a.styleGuide);o().useEffect((()=>{h>0&&localStorage.setItem(p,JSON.stringify(t))}),[t,h]);const m=Math.min(...t.templates.map((e=>e.x))),y=Math.min(...t.templates.map((e=>e.y))),[v]=o().useState({width:Math.max(...t.templates.map((e=>e.x+e.width)))-m,height:Math.max(...t.templates.map((e=>e.y+e.height)))-y}),x={width:window.innerWidth,height:window.innerHeight},{ref:b,scale:C,setScale:E}=(0,i.useWheelZoom)(),P=C*Math.min((x.width-80)/v.width,(x.height-80)/v.height),w={width:v.width*P+80,height:v.height*P+80},{x:k,y:_,setX:S,setY:R,ref:T}=(0,i.useWheelScroll)({maxOffsetX:(w.width-x.width)/2,maxOffsetY:(w.height-x.height)/2}),{zoomIn:A,zoomOut:L}=(0,i.useZoom)(C,E),{selected:[M],setSelected:I,onSelectedKeyDown:O}=(0,i.useSelected)({maxCount:1}),{selected:[D],setSelected:B,onSelectedKeyDown:z}=(0,i.useSelected)({maxCount:1}),F={containerSize:x,targetSize:v,x:k,y:_,scale:P},N=(0,u.getSelectedSize)(M,t),U=(0,u.getTargetByPath)(M,t),G="content"===(null==U?void 0:U.kind)?U.parents.reduce(((e,t)=>{var n;return e+(null!=(n=t.rotate)?n:0)}),0):void 0,{regionAlignmentX:j,regionAlignmentY:V,changeOffsetByRegionAlignment:W,clearRegionAlignments:H}=(0,i.useRegionAlignment)(6/P),{offset:q,onStart:$,mask:X,startPosition:Y,resetDragMove:K}=(0,i.useDragMove)((()=>{H(),0===q.x&&0===q.y&&Y?I((0,u.selectByPosition)(t,g(Y,F),P)):n((e=>{const t=(0,u.getSelectedPosition)(M,e);t&&(t.x+=q.x,t.y+=q.y)}))}),{scale:P,parentRotate:G,transformOffset:(e,n)=>{if(n&&!n.shiftKey&&"template"===(null==U?void 0:U.kind)){const n=U.template;W(e,n,t.templates.filter((e=>e!==n)))}else H();return e}}),{offset:Z,onStart:Q,mask:J,center:ee,resetDragRotate:te}=(0,i.useDragRotate)((()=>{n((e=>{const t=(0,u.getTargetByPath)(M,e);"content"===(null==t?void 0:t.kind)&&(t.content.rotate=null==Z?void 0:Z.angle)}))}),{transform:e=>g(e,F),parentRotate:G,transformOffset:(e,t)=>{if(t&&void 0!==e&&!t.shiftKey){const t=45*Math.round(e/45);Math.abs(t-e)<5&&(e=t)}return e}}),{lineAlignmentX:ne,lineAlignmentY:re,changeOffsetByLineAlignment:oe,clearLineAlignments:ie}=(0,i.useLineAlignment)(6/P),{offset:ae,onStart:se,mask:ce,startPosition:le,resetDragResize:ue}=(0,i.useDragResize)((()=>{ie(),n((e=>{const t=(0,u.getSelectedSize)(M,e),n=(0,u.getSelectedPosition)(M,e);t&&(t.width+=ae.width,t.height+=ae.height),n&&(n.x+=ae.x,n.y+=ae.y)}))}),{centeredScaling:e=>e.shiftKey,keepRatio:e=>{if((0,i.metaKeyIfMacElseCtrlKey)(e)&&N)return N.width/N.height},rotate:"content"===(null==U?void 0:U.kind)&&null!=(e=U.content.rotate)?e:0,parentRotate:G,transform:e=>g(e,F),transformOffset:(e,n,r)=>{if(n&&r&&!n.altKey&&"template"===(null==U?void 0:U.kind)){const n=U.template,o=t.templates.filter((e=>e!==n)).map((e=>[e.x,e.x+e.width])).flat(),i=t.templates.filter((e=>e!==n)).map((e=>[e.y,e.y+e.height])).flat();oe(e,r,n,o,i)}else ie();return e}}),{onStartSelect:pe,dragSelectMask:de,dragSelectStartPosition:fe,resetDragSelect:ge}=(0,i.useDragSelect)(((e,n)=>{if(n){const r=(0,u.selectTemplateByArea)(t,g(e,F),g(n,F));void 0!==r&&I([r])}else I((0,u.selectByPosition)(t,g(e,F),P))}),(e=>e.shiftKey));(0,i.useGlobalKeyDown)((e=>{O(e),z(e),"Escape"===e.key?(ge(),te(),ue(),K()):(0,i.metaKeyIfMacElseCtrlKey)(e)&&("KeyZ"===e.code?e.shiftKey?f(e):r(e):"Minus"===e.code?L(e):"Equal"===e.code&&A(e))}));const he={x:q.x+ae.x,y:q.y+ae.y,width:ae.width,height:ae.height},me=Y||ee||le||fe;return o().createElement("div",{style:{position:"absolute",inset:"0px",backgroundColor:"#E0DFDE",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden"},ref:(0,i.bindMultipleRefs)(T,b),onMouseMove:e=>{if(me)B();else{const n=(0,u.selectByPosition)(t,g({x:e.clientX,y:e.clientY},F),P);(0,i.isSamePath)(n,D)||B(n)}},onMouseDown:e=>{pe(e,void 0)}},o().createElement(c.StyleGuideRenderer,{styleGuide:t,targetSize:v,x:k,y:_,scale:P,onStartSelect:pe,offset:he,rotate:null==Z?void 0:Z.angle,selected:M}),M&&o().createElement("div",{style:{position:"absolute",transform:`translate(${k}px, ${_}px) scale(${P})`,width:v.width,height:v.height,pointerEvents:"none"}},o().createElement(l.SelectionRenderer,{styleGuide:t,scale:P,selected:M,onStartMove:$,offset:he,rotate:null==Z?void 0:Z.angle,onStartRotate:Q,onStartResize:se})),D&&o().createElement("div",{style:{position:"absolute",transform:`translate(${k}px, ${_}px) scale(${P})`,width:v.width,height:v.height,pointerEvents:"none"}},o().createElement(s.HoverRenderer,{styleGuide:t,hovered:D})),o().createElement(i.Scrollbar,{value:k,type:"horizontal",containerSize:x.width,contentSize:w.width,onChange:S}),o().createElement(i.Scrollbar,{value:_,type:"vertical",containerSize:x.height,contentSize:w.height,onChange:R}),o().createElement(i.AlignmentLine,{type:"x",value:null!=j?j:ne,transformX:e=>function(e,t){var n,r,o,i,a,s;return(null!=(r=null==(n=null==t?void 0:t.containerSize)?void 0:n.width)?r:0)/2-((null!=(i=null==(o=null==t?void 0:t.targetSize)?void 0:o.width)?i:0)/2-e)*(null!=(a=null==t?void 0:t.scale)?a:1)+(null!=(s=null==t?void 0:t.x)?s:0)}(e,F)}),o().createElement(i.AlignmentLine,{type:"y",value:null!=V?V:re,transformY:e=>function(e,t){var n,r,o,i,a,s;return(null!=(r=null==(n=null==t?void 0:t.containerSize)?void 0:n.height)?r:0)/2-((null!=(i=null==(o=null==t?void 0:t.targetSize)?void 0:o.height)?i:0)/2-e)*(null!=(a=null==t?void 0:t.scale)?a:1)+(null!=(s=null==t?void 0:t.y)?s:0)}(e,F)}),X,J,ce,de)}function g({x:e,y:t},n){var r,o,i,a,s,c,l,u,p,d,f,g;return{x:(null!=(o=null==(r=null==n?void 0:n.targetSize)?void 0:r.width)?o:0)/2-((null!=(a=null==(i=null==n?void 0:n.containerSize)?void 0:i.width)?a:0)/2-e+(null!=(s=null==n?void 0:n.x)?s:0))/(null!=(c=null==n?void 0:n.scale)?c:1),y:(null!=(u=null==(l=null==n?void 0:n.targetSize)?void 0:l.height)?u:0)/2-((null!=(d=null==(p=null==n?void 0:n.containerSize)?void 0:p.height)?d:0)/2-t+(null!=(f=null==n?void 0:n.y)?f:0))/(null!=(g=null==n?void 0:n.scale)?g:1)}}},2550:(e,t,n)=>{"use strict";n.d(t,{StyleGuideRenderer:()=>s});var r=n(3696),o=n.n(r),i=n(9758),a=n(681);function s(e){const{x:t,y:n,scale:r,styleGuide:a,targetSize:s,onStartSelect:l,selected:u,offset:p,rotate:d}=e;return o().createElement("div",{style:{position:"absolute",boxSizing:"border-box",transform:`translate(${t}px, ${n}px) scale(${r})`,width:s.width,height:s.height}},a.templates.map(((e,t)=>o().createElement(c,{key:e.id,template:e,styleGuide:a,path:[t],onStartSelect:l,selected:u,offset:p,rotate:d,scale:r,isSelected:(0,i.isSamePath)(u,[t])}))))}function c(e){const{template:t,selected:n,offset:r,rotate:i,onStartSelect:s,scale:c}=e;return o().createElement("div",{style:{position:"absolute",boxSizing:"border-box",left:t.x+(e.isSelected?r.x:0),top:t.y+(e.isSelected?r.y:0),width:t.width+(e.isSelected?r.width:0),height:t.height+(e.isSelected?r.height:0),border:1/c+"px solid rgb(160, 160, 160)",backgroundColor:"white"},onMouseDown:e=>{e.stopPropagation(),s(e)}},t.name&&o().createElement("div",{style:{position:"absolute",top:`-${a.nameSize}px`,lineHeight:`${a.nameSize}px`,fontSize:"12px",width:t.name.length*a.nameSize+"px",transform:`scale(${1/c})`,transformOrigin:"left bottom",cursor:"pointer"}},t.name),t.contents.map(((t,a)=>o().createElement(u,{key:a,content:t,styleGuide:e.styleGuide,offset:r,rotate:i,path:[...e.path,a],selected:n}))))}function l(e){var t,n,r,i,a,s;const{template:c,styleGuide:l,content:p,offset:d,rotate:f}=e;return o().createElement("div",{style:{position:"absolute",boxSizing:"border-box",left:p.x+(e.isSelected&&null!=(t=null==d?void 0:d.x)?t:0),top:p.y+(e.isSelected&&null!=(n=null==d?void 0:d.y)?n:0),width:c.width+(e.isSelected&&null!=(r=null==d?void 0:d.width)?r:0),height:c.height+(e.isSelected&&null!=(i=null==d?void 0:d.height)?i:0),clipPath:"inset(0)",backgroundColor:"white",transform:`rotate(${null!=(s=null!=(a=e.isSelected?f:void 0)?a:p.rotate)?s:0}deg)`}},c.contents.map(((t,n)=>o().createElement(u,{key:n,content:t,styleGuide:l,path:[...e.path,n],offset:d,rotate:f,selected:e.selected}))))}function u(e){const{content:t,offset:n,rotate:r}=e;if(t.hidden)return null;const a=(0,i.isSamePath)(e.selected,e.path);if("text"===t.kind)return o().createElement(p,{content:t,offset:a?n:void 0,rotate:a?r:void 0});if("image"===t.kind)return o().createElement(d,{content:t,offset:a?n:void 0,rotate:a?r:void 0});if("color"===t.kind)return o().createElement(f,{content:t,offset:a?n:void 0,rotate:a?r:void 0});if("reference"===t.kind){const i=e.styleGuide.templates.findIndex((e=>e.id===t.id));if(i>=0)return o().createElement(l,{template:e.styleGuide.templates[i],styleGuide:e.styleGuide,content:t,path:[i],offset:n,rotate:r,selected:e.selected,isSelected:a})}return"snapshot"===t.kind?o().createElement(l,{template:t.snapshot,styleGuide:e.styleGuide,content:t,path:e.path,offset:n,rotate:r,selected:e.selected,isSelected:a}):null}function p(e){var t,n,r,i,a;const{content:s,offset:c,rotate:l}=e;return o().createElement("div",{style:{position:"absolute",boxSizing:"border-box",left:s.x+(null!=(t=null==c?void 0:c.x)?t:0),top:s.y+(null!=(n=null==c?void 0:c.y)?n:0),width:s.width+(null!=(r=null==c?void 0:c.width)?r:0),height:s.height+(null!=(i=null==c?void 0:c.height)?i:0),color:s.color,fontSize:s.fontSize,fontFamily:s.fontFamily,transform:`rotate(${null!=(a=null!=l?l:s.rotate)?a:0}deg)`}},s.text)}function d(e){var t,n,r,i,a;const{content:s,offset:c,rotate:l}=e;return o().createElement("img",{src:s.url,style:{position:"absolute",boxSizing:"border-box",left:s.x+(null!=(t=null==c?void 0:c.x)?t:0),top:s.y+(null!=(n=null==c?void 0:c.y)?n:0),width:s.width+(null!=(r=null==c?void 0:c.width)?r:0),height:s.height+(null!=(i=null==c?void 0:c.height)?i:0),transform:`rotate(${null!=(a=null!=l?l:s.rotate)?a:0}deg)`}})}function f(e){var t,n,r,i,a;const{content:s,offset:c,rotate:l}=e;return o().createElement("div",{style:{position:"absolute",boxSizing:"border-box",left:s.x+(null!=(t=null==c?void 0:c.x)?t:0),top:s.y+(null!=(n=null==c?void 0:c.y)?n:0),width:s.width+(null!=(r=null==c?void 0:c.width)?r:0),height:s.height+(null!=(i=null==c?void 0:c.height)?i:0),backgroundColor:s.color,transform:`rotate(${null!=(a=null!=l?l:s.rotate)?a:0}deg)`}})}},2801:(e,t,n)=>{"use strict";n.d(t,{SelectionRenderer:()=>s});var r=n(3696),o=n.n(r),i=n(9758),a=n(681);function s(e){var t,n,r,s;const{styleGuide:c,scale:l,selected:u,offset:p,rotate:d,onStartRotate:f,onStartResize:g}=e,h=(0,a.getTargetByPath)(u,c);if(!h)return null;const m=t=>{var n;t.stopPropagation(),null==(n=e.onStartMove)||n.call(e,{x:t.clientX,y:t.clientY})},y=h.template;if("template"===h.kind)return o().createElement(o().Fragment,null,o().createElement("div",{style:{position:"absolute",boxSizing:"border-box",left:y.x+p.x,top:y.y+p.y,width:y.width+p.width,height:y.height+p.height,border:1/l+"px solid green",cursor:"move",pointerEvents:"auto"},onMouseDown:m}),o().createElement("div",{style:{position:"absolute",boxSizing:"border-box",left:y.x+p.x,top:y.y+p.y,width:y.width+p.width,height:y.height+p.height}},o().createElement(i.ResizeBar,{scale:l,onMouseDown:g})),y.name&&o().createElement("div",{style:{position:"absolute",left:y.x+p.x,top:y.y+p.y-a.nameSize,height:a.nameSize,fontSize:"12px",width:y.name.length*a.nameSize,transform:`scale(${1/l})`,transformOrigin:"left bottom",cursor:"move",pointerEvents:"auto"},onMouseDown:m}));const v=h.content,x=(0,a.getTemplateContentSize)(v,c);if(!x)return null;const{width:b,height:C}=x;let E=o().createElement(o().Fragment,null,o().createElement("div",{style:{position:"absolute",boxSizing:"border-box",left:v.x+p.x,top:v.y+p.y,width:b+p.width,height:C+p.height,border:1/l+"px solid green",cursor:"move",pointerEvents:"auto",transform:`rotate(${null!=(t=null!=d?d:v.rotate)?t:0}deg)`},onMouseDown:m}),o().createElement("div",{style:{position:"absolute",boxSizing:"border-box",left:v.x+p.x,top:v.y+p.y,width:b+p.width,height:C+p.height,transform:`rotate(${null!=(n=null!=d?d:v.rotate)?n:0}deg)`}},o().createElement(i.RotationBar,{scale:l,onMouseDown:e=>{e.stopPropagation(),f((0,a.getRotatedCenter)(h,c))}}),o().createElement(i.ResizeBar,{scale:l,onMouseDown:g,rotate:(null!=(r=v.rotate)?r:0)+h.parents.reduce(((e,t)=>{var n;return e+(null!=(n=t.rotate)?n:0)}),0)})));for(const e of h.parents)"snapshot"===e.kind&&(E=o().createElement("div",{style:{position:"absolute",left:e.x,top:e.y,width:e.snapshot.width,height:e.snapshot.height,transform:`rotate(${null!=(s=e.rotate)?s:0}deg)`}},E));return o().createElement("div",{style:{position:"absolute",left:y.x,top:y.y,width:y.width,height:y.height}},E)}},681:(e,t,n)=>{"use strict";n.d(t,{getRotatedCenter:()=>y,getSelectedPosition:()=>c,getSelectedSize:()=>s,getTargetByPath:()=>l,getTemplateContentSize:()=>p,nameSize:()=>g,selectByPosition:()=>h,selectTemplateByArea:()=>d});var r=n(9758),o=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),i=function(e,t){this[0]=e,this[1]=t},a=e=>{var t,n=e[o("asyncIterator")],r=!1,a={};return null==n?(n=e[o("iterator")](),t=e=>a[e]=t=>n[e](t)):(n=n.call(e),t=e=>a[e]=t=>{if(r){if(r=!1,"throw"===e)throw t;return t}return r=!0,{done:!1,value:new i(new Promise((r=>{var o=n[e](t);o instanceof Object||(()=>{throw TypeError("Object expected")})(),r(o)})),1)}}),a[o("iterator")]=()=>a,t("next"),"throw"in n?t("throw"):a.throw=e=>{throw e},"return"in n&&t("return"),a};function s(e,t){const n=l(e,t);if(!n)return;const r=n.template;return"content"===n.kind?p(n.content,t):r}function c(e,t){const n=l(e,t);if(n)return"template"===n.kind?n.template:n.content}function l(e,t){if(!e)return;const[n,...r]=e,o=t.templates[n];if(0===r.length)return{kind:"template",template:o};const i=u(r,o,t,[]);return i?{kind:"content",template:o,content:i.content,parents:i.parents}:void 0}function u([e,...t],n,r,o){const i=n.contents[e];if(0===t.length)return{content:i,parents:o};if("snapshot"===i.kind)return u(t,i.snapshot,r,[...o,i]);if("reference"===i.kind){const e=r.templates.find((e=>e.id===i.id));if(!e)return;return u(t,e,r,[...o,i])}}function p(e,t){if("snapshot"===e.kind)return e.snapshot;if("reference"===e.kind){const n=t.templates.find((t=>t.id===e.id));if(!n)return;return n}return e}function d(e,t,n){const r={x:Math.min(t.x,n.x),y:Math.min(t.y,n.y),width:Math.abs(t.x-n.x),height:Math.abs(t.y-n.y)};for(let t=0;tf(e,t))):(e=function(e,t){if(!t.rotate)return e;const n=t.x+t.width/2,o=t.y+t.height/2;return(0,r.rotatePositionByCenter)(e,{x:n,y:o},t.rotate)}(e,t),e.x>=t.x&&e.y>=t.y&&e.x<=t.x+t.width&&e.y<=t.y+t.height)}const g=14;function h(e,t,n){const r=g/n;for(let n=e.templates.length-1;n>=0;n--){const o=e.templates[n];if(o.name&&f(t,{x:o.x,y:o.y-r,width:r*o.name.length,height:r}))return[n];for(const r of m(o,o,e,[],[]))if(f(t,r))return[n,...r.path];if(f(t,o))return[n]}}function*m(e,t,n,o,i){var s,c,l;for(let u=e.contents.length-1;u>=0;u--){const d=e.contents[u],f=[...i,u];let g=t.x+d.x,h=t.y+d.y;if("snapshot"===d.kind){const e=[{rotate:null!=(s=d.rotate)?s:0,x:g+d.snapshot.width/2,y:h+d.snapshot.height/2},...o];yield*a(m(d.snapshot,{x:g,y:h},n,e,f))}const{width:y,height:v}=null!=(c=p(d,n))?c:{width:0,height:0};let x={x:g+y/2,y:h+v/2},b=null!=(l=d.rotate)?l:0;for(const e of o)b+=e.rotate,x=(0,r.rotatePositionByCenter)(x,e,-e.rotate);g=x.x-y/2,h=x.y-v/2,yield{x:g,y:h,rotate:b,width:y,height:v,path:f}}}function y(e,t){var n,o;let i={x:e.template.x,y:e.template.y};const a=[];for(const t of e.parents)"snapshot"===t.kind&&(i.x+=t.x,i.y+=t.y,a.unshift({rotate:null!=(n=t.rotate)?n:0,x:i.x+t.snapshot.width/2,y:i.y+t.snapshot.height/2}));const{width:s,height:c}=null!=(o=p(e.content,t))?o:{width:0,height:0};i.x+=e.content.x+s/2,i.y+=e.content.y+c/2;for(const e of a)i=(0,r.rotatePositionByCenter)(i,e,-e.rotate);return i}},3464:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(3696),o=n.n(r),i=n(9758);const a=()=>{const[e,t]=o().useState(0),[n,r]=o().useState(0),{offset:a,onStart:s,mask:c,resetDragMove:l}=(0,i.useDragMove)((()=>{t((e=>e+a.x)),r((e=>e+a.y))}));return(0,i.useGlobalKeyDown)((e=>{"Escape"===e.key&&l()})),o().createElement("div",{style:{width:"300px",height:"300px",overflow:"hidden",position:"absolute",display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid green"}},o().createElement("div",{style:{width:"800px",height:"800px",position:"absolute",transform:`translate(${e+a.x}px, ${n+a.y}px)`,background:"radial-gradient(50% 50% at 50% 50%, red 0%, white 100%)",cursor:"grab"},onMouseDown:e=>s({x:e.clientX,y:e.clientY})}),c)}},7215:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758);const s=()=>{const[e,t]=i().useState({x:200,y:200,width:100,height:100}),{offset:n,onStart:o,mask:s,resetDragResize:c}=(0,a.useDragResize)((()=>t(l)),{centeredScaling:e=>e.shiftKey,keepRatio:t=>(0,a.metaKeyIfMacElseCtrlKey)(t)?e.width/e.height:void 0,transformOffset:(t,n)=>(t.width+e.width<0&&(t.width=-e.width,t.x=Math.min(t.x,e.width*((null==n?void 0:n.shiftKey)?.5:1))),t.height+e.height<0&&(t.height=-e.height,t.y=Math.min(t.y,e.height*((null==n?void 0:n.shiftKey)?.5:1))),t)});(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&c()}));const l=(0,r.produce)(e,(e=>{e.width+=n.width,e.height+=n.height,e.x+=n.x,e.y+=n.y}));return i().createElement(i().Fragment,null,i().createElement("div",{style:{width:`${l.width}px`,height:`${l.height}px`,left:`${l.x}px`,top:`${l.y}px`,boxSizing:"border-box",position:"absolute",background:"radial-gradient(50% 50% at 50% 50%, red 0%, white 100%)"}},i().createElement(a.ResizeBar,{onMouseDown:o})),s)}},4874:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758);const s=()=>{const[e,t]=i().useState({x:200,y:200,width:100,height:100,rotate:0,url:"https://interactive-examples.mdn.mozilla.net/media/cc0-images/grapefruit-slice-332-332.jpg"}),{offset:n,onStart:o,mask:s,resetDragRotate:c}=(0,a.useDragRotate)((()=>t(l)),{transformOffset:(e,t)=>{if(t&&void 0!==e&&!t.shiftKey){const t=45*Math.round(e/45);Math.abs(t-e)<5&&(e=t)}return e}});(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&c()}));const l=(0,r.produce)(e,(e=>{void 0!==(null==n?void 0:n.angle)&&(e.rotate=n.angle)}));return i().createElement(i().Fragment,null,i().createElement("div",{style:{width:`${e.width}px`,height:`${e.width}px`,left:`${e.x}px`,top:`${e.y}px`,boxSizing:"border-box",position:"absolute",transform:`rotate(${l.rotate}deg)`,background:`url(${e.url})`,backgroundSize:"contain"}},i().createElement(a.RotationBar,{onMouseDown:()=>o({x:e.x+e.width/2,y:e.y+e.height/2})})),s)}},3191:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758);const s=()=>{const[e,t]=i().useState([]),{onStartSelect:n,dragSelectMask:o,resetDragSelect:s}=(0,a.useDragSelect)(((n,o)=>{o&&t((0,r.produce)(e,(e=>{e.push({x:Math.min(n.x,o.x),y:Math.min(n.y,o.y),width:Math.abs(o.x-n.x),height:Math.abs(o.y-n.y)})})))}),(e=>e.shiftKey));return(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&s()})),i().createElement("div",{onMouseDown:e=>n(e,void 0),style:{height:"100%"}},e.map(((e,t)=>i().createElement("div",{key:t,style:{width:`${e.width}px`,height:`${e.height}px`,left:`${e.x}px`,top:`${e.y}px`,position:"absolute",border:"1px solid green"}}))),o)}},9612:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(3696),o=n.n(r),i=n(9758);const a=()=>{var e;const[t,n]=o().useState({x:300,y:200,r:100}),{editPoint:r,updateEditPreview:a,onEditMove:s,onEditClick:c,getEditAssistentContents:l,resetEdit:u}=(0,i.useEdit)((()=>n(f)),(e=>({editPoints:[{x:e.x,y:e.y,cursor:"move",update(e,{cursor:t,start:n}){e.x+=t.x-n.x,e.y+=t.y-n.y}},{x:e.x-e.r,y:e.y,cursor:"ew-resize",update(e,{cursor:t}){e.r=(0,i.getTwoPointsDistance)(t,e)}},{x:e.x,y:e.y-e.r,cursor:"ns-resize",update(e,{cursor:t}){e.r=(0,i.getTwoPointsDistance)(t,e)}},{x:e.x+e.r,y:e.y,cursor:"ew-resize",update(e,{cursor:t}){e.r=(0,i.getTwoPointsDistance)(t,e)}},{x:e.x,y:e.y+e.r,cursor:"ns-resize",update(e,{cursor:t}){e.r=(0,i.getTwoPointsDistance)(t,e)}}]})));(0,i.useGlobalKeyDown)((e=>{"Escape"===e.key&&u()}));const p=[],d=a(),f=null!=(e=null==d?void 0:d.result)?e:t;return p.push(...l(f,(e=>e))),o().createElement(o().Fragment,null,o().createElement("svg",{viewBox:"0 0 800 600",width:800,height:600,xmlns:"http://www.w3.org/2000/svg",fill:"none",style:{position:"absolute",left:0,top:0,cursor:null==r?void 0:r.cursor},onMouseMove:e=>s({x:e.clientX,y:e.clientY},[{content:f,path:[0]}]),onClick:e=>r&&c({x:e.clientX,y:e.clientY})},o().createElement("circle",{cx:f.x,cy:f.y,r:f.r,stroke:"#00ff00"}),p.map(((e,t)=>o().createElement("rect",{key:t,x:e.x-e.width/2,y:e.y-e.height/2,width:e.width,height:e.height,stroke:"#00ff00",fill:"#ffffff"})))))}},2071:(e,t,n)=>{"use strict";n.d(t,{default:()=>c});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758),s=n(4469);const c=()=>{const[e,t]=i().useState([]),{ellipse:n,ellipseArc:o,onClick:c,onMove:l,input:u,reset:p}=(0,a.useEllipseArcClickCreate)("ellipse center",(n=>{t((0,r.produce)(e,(e=>{e.push(n)})))}));(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&p()}));const d=n||o;return i().createElement("div",{onClick:e=>c({x:e.clientX,y:e.clientY}),onMouseMove:e=>l({x:e.clientX,y:e.clientY}),style:{height:"100%"}},i().createElement("svg",{viewBox:"0 0 800 600",width:800,height:600,xmlns:"http://www.w3.org/2000/svg",fill:"none",style:{position:"absolute",left:0,top:0},onClick:e=>c({x:e.clientX,y:e.clientY}),onMouseMove:e=>l({x:e.clientX,y:e.clientY})},d&&i().createElement("ellipse",{stroke:"#00ff00",cx:d.cx,cy:d.cy,rx:d.rx,ry:d.ry,transform:d.angle?`rotate(${d.angle},${d.cx},${d.cy})`:void 0,strokeDasharray:"4"}),[...e,o].map(((e,t)=>{if(e){const n=(0,a.ellipseArcToPolyline)(e,s.defaultAngleDelta);return i().createElement("polyline",{key:t,points:n.map((e=>`${e.x},${e.y}`)).join(" "),stroke:"#00ff00"})}return null}))),u)}},7258:(e,t,n)=>{"use strict";n.d(t,{default:()=>y});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758),s=n(4469),c=Object.defineProperty,l=Object.defineProperties,u=Object.getOwnPropertyDescriptors,p=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,f=Object.prototype.propertyIsEnumerable,g=(e,t,n)=>t in e?c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,h=(e,t)=>{for(var n in t||(t={}))d.call(t,n)&&g(e,n,t[n]);if(p)for(var n of p(t))f.call(t,n)&&g(e,n,t[n]);return e},m=(e,t)=>l(e,u(t));const y=()=>{const[e,t]=i().useState({cx:200,cy:200,rx:100,ry:150,angle:45,startAngle:-30,endAngle:120}),{offset:n,onStart:o,mask:c,reset:l}=(0,a.useEllipseArcEdit)((()=>t(u))),u=(0,r.produce)(e,(e=>{n&&(e.cx+=n.cx,e.cy+=n.cy,e.rx+=n.rx,e.ry+=n.ry,e.startAngle+=n.startAngle,e.endAngle+=n.endAngle,(0,a.normalizeAngleRange)(e))}));(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&l()}));const p=(0,a.ellipseArcToPolyline)(u,s.defaultAngleDelta);return i().createElement(i().Fragment,null,i().createElement("svg",{viewBox:"0 0 800 600",width:800,height:600,xmlns:"http://www.w3.org/2000/svg",fill:"none",style:{position:"absolute",left:0,top:0}},i().createElement("polyline",{points:p.map((e=>`${e.x},${e.y}`)).join(" "),stroke:"#00ff00"})),i().createElement(a.EllipseArcEditBar,m(h({},u),{onMouseDown:(e,t,n)=>o(e,m(h({},u),{type:t,cursor:n}))})),c)}},2682:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758);const s=()=>{const[e,t]=i().useState([]),{ellipse:n,onClick:o,onMove:s,input:c,reset:l}=(0,a.useEllipseClickCreate)("ellipse center",(n=>{t((0,r.produce)(e,(e=>{e.push(n)})))}));return(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&l()})),i().createElement("div",{style:{height:"100%"}},i().createElement("svg",{viewBox:"0 0 800 600",width:800,height:600,xmlns:"http://www.w3.org/2000/svg",fill:"none",style:{position:"absolute",left:0,top:0},onClick:e=>o({x:e.clientX,y:e.clientY}),onMouseMove:e=>s({x:e.clientX,y:e.clientY})},[...e,n].map(((e,t)=>e&&i().createElement("ellipse",{key:t,stroke:"#00ff00",cx:e.cx,cy:e.cy,rx:e.rx,ry:e.ry,transform:e.angle?`rotate(${e.angle},${e.cx},${e.cy})`:void 0})))),c)}},1783:(e,t,n)=>{"use strict";n.d(t,{default:()=>m});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758),s=Object.defineProperty,c=Object.defineProperties,l=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,f=(e,t,n)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,g=(e,t)=>{for(var n in t||(t={}))p.call(t,n)&&f(e,n,t[n]);if(u)for(var n of u(t))d.call(t,n)&&f(e,n,t[n]);return e},h=(e,t)=>c(e,l(t));const m=()=>{const[e,t]=i().useState({cx:200,cy:200,rx:100,ry:150,angle:45}),{offset:n,onStart:o,mask:s,reset:c}=(0,a.useEllipseEdit)((()=>t(l))),l=(0,r.produce)(e,(e=>{n&&(e.cx+=n.cx,e.cy+=n.cy,e.rx+=n.rx,e.ry+=n.ry)}));return(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&c()})),i().createElement(i().Fragment,null,i().createElement("svg",{viewBox:"0 0 800 600",width:800,height:600,xmlns:"http://www.w3.org/2000/svg",fill:"none",style:{position:"absolute",left:0,top:0}},i().createElement("ellipse",{stroke:"#00ff00",cx:l.cx,cy:l.cy,rx:l.rx,ry:l.ry,transform:l.angle?`rotate(${l.angle},${l.cx},${l.cy})`:void 0})),i().createElement(a.EllipseEditBar,h(g({},l),{onMouseDown:(e,t,n)=>o(e,h(g({},l),{type:t,cursor:n}))})),s)}},5090:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(3031),o=n(3696),i=n.n(o),a=n(9758);const s=()=>{const[e,t]=i().useState("X1 ** 2 + X2 * X3"),[n,o]=i().useState("(-X6) ** 0.5 / (X4 - X5 ** 3)"),[s,c]=i().useState(),[l,u]=i().useState(!1);return i().useEffect((()=>{try{c({left:(0,r.parseExpression)((0,r.tokenizeExpression)(e)),right:(0,r.parseExpression)((0,r.tokenizeExpression)(n))})}catch(e){console.info(e)}}),[e,n]),i().createElement("div",null,i().createElement(a.ExpressionEditor,{value:e,setValue:t,validate:a.validateExpression}),i().createElement(a.ExpressionEditor,{value:n,setValue:o,validate:a.validateExpression}),i().createElement("label",null,i().createElement("input",{type:"checkbox",checked:l,onChange:()=>u(!l)}),"keep binary expression order"),s&&(0,a.renderEquation)(a.reactSvgRenderTarget,s,{keepBinaryExpressionOrder:l}),s&&i().createElement("code",null,(0,a.printEquation)(s,{keepBinaryExpressionOrder:l})))}},6690:(e,t,n)=>{"use strict";n.d(t,{default:()=>g});var r=n(3031),o=n(3696),i=n.n(o),a=n(9758),s=Object.defineProperty,c=Object.defineProperties,l=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,f=(e,t,n)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;const g=()=>{const{value:e,update:t,getArrayProps:n}=(0,a.useJsonEditorData)([{equation:"a * x + b * y = c",variable:"x"},{equation:"x ** 2 + y ** 2 = r",variable:"y"}]),[o,s]=i().useState(!1),[g,h]=i().useState([]),[m,y]=i().useState(!1),[v,x]=i().useState(!1);return i().useEffect((()=>{try{const t=(0,a.solveEquations)(e.map((e=>{const t=e.equation.split("=");return{left:(0,r.parseExpression)((0,r.tokenizeExpression)(o?(0,a.mathStyleExpressionToExpression)(t[0]):t[0])),right:(0,r.parseExpression)((0,r.tokenizeExpression)(o?(0,a.mathStyleExpressionToExpression)(t[1]):t[1]))}})),new Set(e.map((e=>e.variable))));h(t.map((e=>Object.entries(e).map((([e,t])=>Array.isArray(t)?{left:t[0],right:t[1]}:{left:{type:"Identifier",name:e},right:t})))))}catch(e){console.info(e)}}),[e,o]),i().createElement("div",null,i().createElement(a.ObjectArrayEditor,(b=((e,t)=>{for(var n in t||(t={}))p.call(t,n)&&f(e,n,t[n]);if(u)for(var n of u(t))d.call(t,n)&&f(e,n,t[n]);return e})({},n((e=>e),{equation:"x = 1",variable:"x"})),C={properties:e.map(((e,n)=>({equation:i().createElement(a.ExpressionEditor,{value:e.equation,setValue:t(((e,t)=>e[n].equation=t)),height:20,width:400,autoHeight:!0}),variable:i().createElement(a.StringEditor,{style:{width:"30px"},value:e.variable,setValue:t(((e,t)=>e[n].variable=t))})})))},c(b,l(C)))),i().createElement("label",null,i().createElement("input",{type:"checkbox",checked:o,onChange:()=>s(!o)}),"math style expression"),i().createElement("label",null,i().createElement("input",{type:"checkbox",checked:m,onChange:()=>y(!m)}),"keep binary expression order"),i().createElement("label",null,i().createElement("input",{type:"checkbox",checked:v,onChange:()=>x(!v)}),"show text"),g.map(((e,t)=>i().createElement("div",{key:t,style:{borderBottom:"1px solid black",display:"flex",flexDirection:"column"}},e.map(((e,t)=>i().createElement(i().Fragment,{key:t},!v&&(0,a.renderEquation)(a.reactSvgRenderTarget,e,{keepBinaryExpressionOrder:m}),v&&i().createElement("div",null,i().createElement("code",null,(0,a.printEquation)(e,{keepBinaryExpressionOrder:m}))))))))),o&&g.map(((e,t)=>i().createElement("div",{key:t,style:{borderBottom:"1px solid black",display:"flex",flexDirection:"column"}},e.map(((e,t)=>i().createElement("div",{key:t},i().createElement("code",null,(0,a.printMathStyleExpression)(e.left)," = ",(0,a.printMathStyleExpression)(e.right)))))))));var b,C}},8673:(e,t,n)=>{"use strict";n.d(t,{default:()=>m});var r=n(3696),o=n.n(r),i=n(9758),a=n(3031),s=Object.defineProperty,c=Object.defineProperties,l=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,f=(e,t,n)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,g=(e,t)=>{for(var n in t||(t={}))p.call(t,n)&&f(e,n,t[n]);if(u)for(var n of u(t))d.call(t,n)&&f(e,n,t[n]);return e},h=(e,t)=>c(e,l(t));const m=()=>{const{value:e,update:t,getArrayProps:n}=(0,i.useJsonEditorData)(["sin(x)"]),[r,s]=o().useState(),[c,l]=o().useState(0),[u,p]=o().useState(10),[d,f]=o().useState(!0),[m,y]=o().useState([]),[v,x]=o().useState(),b=(0,i.useWindowSize)().width/2,C=i.reactSvgRenderTarget,[E,P]=o().useState(),w=e=>(0,a.parseExpression)((0,a.tokenizeExpression)(d?(0,i.mathStyleExpressionToExpression)(e):e));let k;return E&&(k=E.children,r&&(k=[...E.children,...(0,i.renderChartTooltip)(C,r,r.value)])),o().createElement("div",{style:{position:"absolute",inset:"0px"}},E&&k&&o().createElement("div",null,C.renderResult(k,b,300,{attributes:{onMouseMove:e=>s(E.select({x:e.clientX,y:e.clientY}))}})),o().createElement("div",{style:{margin:"10px"}},o().createElement(i.ArrayEditor,h(g({},n((e=>e),"")),{inline:!0,style:{width:"calc(50% - 30px)"},items:e.map(((e,n)=>o().createElement(i.StringEditor,{style:{height:"50px"},textarea:!0,value:e,setValue:t(((e,t)=>e[n]=t))})))})),o().createElement("div",null,o().createElement("label",null,o().createElement("input",{type:"checkbox",checked:d,onChange:()=>f(!d)}),"input math style expression")),o().createElement("div",null,o().createElement(i.NumberEditor,{style:{width:"50px"},value:c,setValue:l}),"~",o().createElement(i.NumberEditor,{style:{width:"50px"},value:u,setValue:p})),o().createElement(i.Button,{disabled:0===e.length,onClick:()=>{try{if(0===e.length)return;const t=[],n=(u-c)/100,r=(0,i.getTwoNumberCenter)(c,u),o={sin:Math.sin,cos:Math.cos,tan:Math.tan,ln:Math.log,sqrt:Math.sqrt},s=[];for(const l of e){if(!l)continue;const e=[],p=w(l),d=(0,i.expressionToFactors)(p);if(d){const e=(0,i.factorsToEquationParams)(d,"x");e&&s.push(...(0,i.calculateEquation5)(e,r,i.delta1))}const f=w((0,a.printExpression)((0,i.optimizeExpression)((0,i.deriveExpressionWith)(p,"x"),(e=>(0,i.expressionHasVariable)(e,"x"))))),m=(0,i.newtonIterate)(r,(e=>{try{const t=(0,a.evaluateExpression)(p,h(g({},o),{x:e}));return"number"==typeof t?t:NaN}catch(e){return NaN}}),(e=>{try{const t=(0,a.evaluateExpression)(f,h(g({},o),{x:e}));return"number"==typeof t?t:NaN}catch(e){return NaN}}),i.delta1);void 0!==m&&s.every((e=>!(0,i.isSameNumber)(e,m)))&&s.push(m);for(let t=c;t<=u;t+=n){const n=(0,a.evaluateExpression)(p,h(g({},o),{x:t}));"number"!=typeof n||isNaN(n)||e.push({x:t,y:n})}e.length>0&&t.push(e)}y(s);const l=t.flat().map((e=>e.y)),p=Math.min(...l),d=Math.max(...l),f=s.filter((e=>(0,i.isBetween)(e,c,u))).map((e=>[{x:e,y:p},{x:e,y:d}])),m=(0,i.getLineChart)([[{x:c,y:0},{x:u,y:0}],...f,...t],C,{x:.01,y:.01},{width:b,height:300},{left:25,right:25,top:10,bottom:20},{xLabelDisabled:!0,yLabelDisabled:!0});if(!m)return;const{points:[v,...E],children:k,select:_}=m;k.push(C.renderPolyline(v,{strokeColor:65280}));for(let e=0;eo().createElement("div",{key:t,style:{border:"1px solid black",maxHeight:"150px",overflowY:"auto",position:"relative"}},o().createElement("code",{key:t},"x = ",e)))),v&&o().createElement("div",null,v)))}},6808:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(3696),o=n.n(r),i=n(9758),a=n(5358);const s=()=>{const[e,t]=o().useState("1 + 2 - 3");return o().createElement(i.ExpressionEditor,{suggestionSources:a.math,value:e,setValue:t,validate:i.validateExpression})}},2458:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(3696),o=n.n(r),i=n(9758),a=n(3031);const s=()=>{const[e,t]=o().useState("(x + a)^3"),[n,r]=o().useState("x"),[s,c]=o().useState(""),[l,u]=o().useState(!0),[p,d]=o().useState(!0),[f,g]=o().useState(),[h,m]=o().useState(),[y,v]=o().useState(),x=e=>(0,a.parseExpression)((0,a.tokenizeExpression)(l?(0,i.mathStyleExpressionToExpression)(e):e)),b=e=>p?(0,i.printMathStyleExpression)(e):(0,a.printExpression)(e),C=t=>{try{if(!n)return;if(!e)return;const r=x(e),o=(0,i.taylorExpandExpressionWith)(r,n,+s||5,t);v(o),g(void 0)}catch(e){g(String(e)),v(void 0)}},E=e=>{t(e),g(void 0),m(void 0),v(void 0)};return o().createElement("div",null,o().createElement(i.StringEditor,{style:{width:"calc(100% - 30px)",height:"150px"},textarea:!0,value:e,setValue:E}),o().createElement("div",null,o().createElement("label",null,o().createElement("input",{type:"checkbox",checked:l,onChange:()=>u(!l)}),"input math style expression"),o().createElement("label",null,o().createElement("input",{type:"checkbox",checked:p,onChange:()=>d(!p)}),"output math style expression")),o().createElement("div",null,o().createElement(i.StringEditor,{style:{width:"50px"},value:n,setValue:r}),"=",o().createElement(i.StringEditor,{style:{width:"calc(100% - 115px)"},value:s,setValue:c})),o().createElement(i.Button,{disabled:!e,onClick:()=>{try{if(!e)return;const t=(0,i.expandExpression)(x(e));let n=(0,i.expressionToFactors)(t);n?(n=(0,i.optimizeFactors)(n),(0,i.sortFactors)(n),m(n),v(void 0)):(v(t),m(void 0)),g(void 0)}catch(e){console.info(e),g(String(e)),m(void 0),v(void 0)}}},"expand all"),o().createElement(i.Button,{disabled:!n||!h,onClick:()=>{try{if(!n)return;if(!h)return;const e=x(n),t=(0,i.expressionToFactors)(e);if(t){const e=(0,i.divideFactors)(h,t);e&&m(e)}g(void 0)}catch(e){g(String(e))}}},"divide by"),o().createElement(i.Button,{disabled:!n||!h,onClick:()=>{try{if(!n)return;if(!h)return;const e=x(n),t=(0,i.expressionToFactors)(e);if(t&&1===t.length){const e=(0,i.groupFactorsBy)(h,t[0]);e&&v(e)}g(void 0)}catch(e){g(String(e))}}},"group by"),o().createElement(i.Button,{disabled:!e||!n||!s,onClick:()=>{try{if(!n)return;if(!s)return;if(!e)return;const t=x(e),r=x(s),o=(0,i.composeExpression)(t,{[n]:r});o&&v(o),g(void 0)}catch(e){g(String(e))}}},"replace with"),o().createElement(i.Button,{disabled:!e,onClick:()=>{try{if(!e)return;const t=x(e);v(t),g(void 0)}catch(e){g(String(e)),v(void 0)}}},"format style"),o().createElement(i.Button,{disabled:!h,onClick:()=>{h&&v((0,i.groupAllFactors)(h))}},"group all"),o().createElement(i.Button,{disabled:!e||!n,onClick:()=>{try{if(!n)return;if(!e)return;const t=x(e),r=(0,i.optimizeExpression)((0,i.deriveExpressionWith)(t,n),(e=>(0,i.expressionHasVariable)(e,n)));v(r),g(void 0)}catch(e){g(String(e)),v(void 0)}}},"derive with"),o().createElement(i.Button,{disabled:!e,onClick:()=>{try{if(!e)return;const t=x(e),n=(0,i.optimizeExpression)(t);v(n),g(void 0)}catch(e){g(String(e)),v(void 0)}}},"optimize"),o().createElement(i.Button,{disabled:!n||!h,onClick:()=>{try{if(!n)return;if(!h)return;const e=x(n),t=(0,i.expressionToFactors)(e);if(t&&1===t.length){const e=(0,i.groupFactorsByVariables)(h,t[0].variables.filter((e=>"string"==typeof e)));e&&v(e)}g(void 0)}catch(e){g(String(e))}}},"group by variables"),o().createElement(i.Button,{disabled:!e||!n,onClick:()=>C(!1)},"taylor expand"),o().createElement(i.Button,{disabled:!e||!n,onClick:()=>C(!0)},"primary function"),h&&h.length>0&&o().createElement("div",{style:{border:"1px solid black",maxHeight:"150px",overflowY:"auto",marginBottom:"5px"}},h.map(((e,t)=>o().createElement("div",{key:t},o().createElement("code",null,b((0,i.factorToExpression)(e))))))),h&&o().createElement("div",{style:{border:"1px solid black",maxHeight:"150px",overflowY:"auto",marginBottom:"5px",position:"relative"}},o().createElement("code",null,b((0,i.factorsToExpression)(h))),o().createElement(i.Button,{style:{position:"absolute",right:0,top:0,background:"wheat"},onClick:()=>navigator.clipboard.writeText(b((0,i.factorsToExpression)(h)))},"copy"),o().createElement(i.Button,{style:{position:"absolute",right:65,top:0,background:"wheat"},onClick:()=>E(b((0,i.factorsToExpression)(h)))},"edit")),y&&o().createElement("div",{style:{border:"1px solid black",maxHeight:"150px",overflowY:"auto",position:"relative"}},o().createElement("code",null,b(y)),o().createElement(i.Button,{style:{position:"absolute",right:0,top:0,background:"wheat"},onClick:()=>navigator.clipboard.writeText(b(y))},"copy"),o().createElement(i.Button,{style:{position:"absolute",right:65,top:0,background:"wheat"},onClick:()=>E(b(y))},"edit")),y&&(0,i.renderExpression)(i.reactSvgRenderTarget,y),f&&o().createElement("div",null,f))}},5358:(e,t,n)=>{"use strict";n.d(t,{math:()=>r});const r=[{name:"Math",members:[{name:"E",comment:"The mathematical constant e. This is Euler's number, the base of natural logarithms."},{name:"LN10",comment:"The natural logarithm of 10."},{name:"LN2",comment:"The natural logarithm of 2."},{name:"LOG2E",comment:"The base-2 logarithm of e."},{name:"LOG10E",comment:"The base-10 logarithm of e."},{name:"PI",comment:"Pi. This is the ratio of the circumference of a circle to its diameter."},{name:"SQRT1_2",comment:"The square root of 0.5, or, equivalently, one divided by the square root of 2."},{name:"SQRT2",comment:"The square root of 2."},{name:"abs",comment:"Returns the absolute value of a number (the value without regard to whether it is positive or negative).\r\nFor example, the absolute value of -5 is the same as the absolute value of 5.",parameters:[{name:"x",comment:"A numeric expression for which the absolute value is needed.",optional:!1}]},{name:"acos",comment:"Returns the arc cosine (or inverse cosine) of a number.",parameters:[{name:"x",comment:"A numeric expression.",optional:!1}]},{name:"asin",comment:"Returns the arcsine of a number.",parameters:[{name:"x",comment:"A numeric expression.",optional:!1}]},{name:"atan",comment:"Returns the arctangent of a number.",parameters:[{name:"x",comment:"A numeric expression for which the arctangent is needed.",optional:!1}]},{name:"atan2",comment:"Returns the angle (in radians) from the X axis to a point.",parameters:[{name:"y",comment:"A numeric expression representing the cartesian y-coordinate.",optional:!1},{name:"x",comment:"A numeric expression representing the cartesian x-coordinate.",optional:!1}]},{name:"ceil",comment:"Returns the smallest integer greater than or equal to its numeric argument.",parameters:[{name:"x",comment:"A numeric expression.",optional:!1}]},{name:"cos",comment:"Returns the cosine of a number.",parameters:[{name:"x",comment:"A numeric expression that contains an angle measured in radians.",optional:!1}]},{name:"exp",comment:"Returns e (the base of natural logarithms) raised to a power.",parameters:[{name:"x",comment:"A numeric expression representing the power of e.",optional:!1}]},{name:"floor",comment:"Returns the greatest integer less than or equal to its numeric argument.",parameters:[{name:"x",comment:"A numeric expression.",optional:!1}]},{name:"log",comment:"Returns the natural logarithm (base e) of a number.",parameters:[{name:"x",comment:"A numeric expression.",optional:!1}]},{name:"max",comment:"Returns the larger of a set of supplied numeric expressions.",parameters:[{name:"values",comment:"Numeric expressions to be evaluated.",optional:!1}]},{name:"min",comment:"Returns the smaller of a set of supplied numeric expressions.",parameters:[{name:"values",comment:"Numeric expressions to be evaluated.",optional:!1}]},{name:"pow",comment:"Returns the value of a base expression taken to a specified power.",parameters:[{name:"x",comment:"The base value of the expression.",optional:!1},{name:"y",comment:"The exponent value of the expression.",optional:!1}]},{name:"random",comment:"Returns a pseudorandom number between 0 and 1.",parameters:[]},{name:"round",comment:"Returns a supplied numeric expression rounded to the nearest integer.",parameters:[{name:"x",comment:"The value to be rounded to the nearest integer.",optional:!1}]},{name:"sin",comment:"Returns the sine of a number.",parameters:[{name:"x",comment:"A numeric expression that contains an angle measured in radians.",optional:!1}]},{name:"sqrt",comment:"Returns the square root of a number.",parameters:[{name:"x",comment:"A numeric expression.",optional:!1}]},{name:"tan",comment:"Returns the tangent of a number.",parameters:[{name:"x",comment:"A numeric expression that contains an angle measured in radians.",optional:!1}]},{name:"clz32",comment:"Returns the number of leading zero bits in the 32-bit binary representation of a number.",parameters:[{name:"x",comment:"A numeric expression.",optional:!1}]},{name:"imul",comment:"Returns the result of 32-bit multiplication of two numbers.",parameters:[{name:"x",comment:"First number",optional:!1},{name:"y",comment:"Second number",optional:!1}]},{name:"sign",comment:"Returns the sign of the x, indicating whether x is positive, negative or zero.",parameters:[{name:"x",comment:"The numeric expression to test",optional:!1}]},{name:"log10",comment:"Returns the base 10 logarithm of a number.",parameters:[{name:"x",comment:"A numeric expression.",optional:!1}]},{name:"log2",comment:"Returns the base 2 logarithm of a number.",parameters:[{name:"x",comment:"A numeric expression.",optional:!1}]},{name:"log1p",comment:"Returns the natural logarithm of 1 + x.",parameters:[{name:"x",comment:"A numeric expression.",optional:!1}]},{name:"expm1",comment:"Returns the result of (e^x - 1), which is an implementation-dependent approximation to\r\nsubtracting 1 from the exponential function of x (e raised to the power of x, where e\r\nis the base of the natural logarithms).",parameters:[{name:"x",comment:"A numeric expression.",optional:!1}]},{name:"cosh",comment:"Returns the hyperbolic cosine of a number.",parameters:[{name:"x",comment:"A numeric expression that contains an angle measured in radians.",optional:!1}]},{name:"sinh",comment:"Returns the hyperbolic sine of a number.",parameters:[{name:"x",comment:"A numeric expression that contains an angle measured in radians.",optional:!1}]},{name:"tanh",comment:"Returns the hyperbolic tangent of a number.",parameters:[{name:"x",comment:"A numeric expression that contains an angle measured in radians.",optional:!1}]},{name:"acosh",comment:"Returns the inverse hyperbolic cosine of a number.",parameters:[{name:"x",comment:"A numeric expression that contains an angle measured in radians.",optional:!1}]},{name:"asinh",comment:"Returns the inverse hyperbolic sine of a number.",parameters:[{name:"x",comment:"A numeric expression that contains an angle measured in radians.",optional:!1}]},{name:"atanh",comment:"Returns the inverse hyperbolic tangent of a number.",parameters:[{name:"x",comment:"A numeric expression that contains an angle measured in radians.",optional:!1}]},{name:"hypot",comment:"Returns the square root of the sum of squares of its arguments.",parameters:[{name:"values",comment:"Values to compute the square root for.\r\nIf no arguments are passed, the result is +0.\r\nIf there is only one argument, the result is the absolute value.\r\nIf any argument is +Infinity or -Infinity, the result is +Infinity.\r\nIf any argument is NaN, the result is NaN.\r\nIf all arguments are either +0 or −0, the result is +0.",optional:!1}]},{name:"trunc",comment:"Returns the integral part of the a numeric expression, x, removing any fractional digits.\r\nIf x is already an integer, the result is x.",parameters:[{name:"x",comment:"A numeric expression.",optional:!1}]},{name:"fround",comment:"Returns the nearest single precision float representation of a number.",parameters:[{name:"x",comment:"A numeric expression.",optional:!1}]},{name:"cbrt",comment:"Returns an implementation-dependent approximation to the cube root of number.",parameters:[{name:"x",comment:"A numeric expression.",optional:!1}]}]}]},8859:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758);const s=()=>{const[e,t]=i().useState((()=>new Array(3).fill(0).map((()=>({children:new Array(20).fill(0).map((()=>({radius:5+Math.round(20*Math.random()),color:Math.round(16777215*Math.random())}))),blockStart:5,blockEnd:5}))))),[n,o]=i().useState("left"),[s,c]=i().useState("top"),{renderEditor:l,layoutResult:u,lineHeights:p,isSelected:d,actualHeight:f,inputContent:g,inputInline:h,getCopiedContents:m}=(0,a.useFlowLayoutBlockEditor)({state:e,setState:n=>t((0,r.produce)(e,n)),width:400,height:400,lineHeight:e=>2*e.radius,getWidth:e=>2*e.radius,endContent:{radius:0,color:0},isNewLineContent:e=>0===e.radius,align:n,verticalAlign:s,processInput(e){if((0,a.metaKeyIfMacElseCtrlKey)(e)){if("v"===e.key)return navigator.clipboard.readText().then((e=>{if(e){const t=JSON.parse(e);1===t.length?h(t[0].children):g(t)}})),e.preventDefault(),!0;if("c"===e.key||"x"===e.key){const t=m("x"===e.key);return t&&navigator.clipboard.writeText(JSON.stringify(t)),!0}}return!1}}),y=a.reactCanvasRenderTarget,v=[];u.forEach(((e,t)=>{e.forEach((({x:e,y:n,content:r,visible:o,row:i},a)=>{o&&(d([t,a])&&v.push(y.renderRect(e,n,2*r.radius,p[i],{fillColor:11785981,strokeWidth:0})),v.push(y.renderCircle(e+r.radius,n+p[i]/2,r.radius,{fillColor:r.color,strokeWidth:0})))}))}));const x=y.renderResult(v,400,f);return i().createElement(i().Fragment,null,l(x),i().createElement(a.EnumEditor,{enums:a.aligns,value:n,setValue:o}),i().createElement(a.EnumEditor,{enums:a.verticalAligns,value:s,setValue:c}))}},3823:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758);const s=()=>{const[e,t]=i().useState((()=>new Array(30).fill(0).map((()=>({radius:5+Math.round(20*Math.random()),color:Math.round(16777215*Math.random())}))))),[n,o]=i().useState("left"),[s,c]=i().useState("top"),{renderEditor:l,layoutResult:u,lineHeights:p,isSelected:d,actualHeight:f,inputContent:g,getCopiedContents:h}=(0,a.useFlowLayoutEditor)({state:e,setState:n=>t((0,r.produce)(e,n)),width:400,height:200,lineHeight:e=>2*e.radius,getWidth:e=>2*e.radius,endContent:{radius:0,color:0},isNewLineContent:e=>0===e.radius,align:n,verticalAlign:s,processInput(e){if("Enter"===e.key)return g([{radius:0,color:0}]),!0;if((0,a.metaKeyIfMacElseCtrlKey)(e)){if("v"===e.key)return navigator.clipboard.readText().then((e=>{e&&g(JSON.parse(e))})),e.preventDefault(),!0;if("c"===e.key||"x"===e.key){const t=h("x"===e.key);return t&&navigator.clipboard.writeText(JSON.stringify(t)),!0}}return!1}}),m=a.reactCanvasRenderTarget,y=[];for(const{x:e,y:t,i:n,content:r,visible:o,row:i}of u)o&&(d(n)&&y.push(m.renderRect(e,t,2*r.radius,p[i],{fillColor:11785981,strokeWidth:0})),y.push(m.renderCircle(e+r.radius,t+p[i]/2,r.radius,{fillColor:r.color,strokeWidth:0})));const v=m.renderResult(y,400,f);return i().createElement(i().Fragment,null,l(v),i().createElement(a.EnumEditor,{enums:a.aligns,value:n,setValue:o}),i().createElement(a.EnumEditor,{enums:a.verticalAligns,value:s,setValue:c}))}},1805:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758);const s=()=>{const[e,t]=i().useState((()=>"1 + 2 = 3".split(""))),[n,o]=i().useState("left"),[s,c]=i().useState("top"),{renderEditor:l,layoutResult:u}=(0,a.useFlowLayoutTextEditor)({state:e,setState:n=>t((0,r.produce)(e,n)),width:400,height:200,fontSize:20,fontFamily:"monospace",lineHeight:24,align:n,verticalAlign:s});return i().createElement(i().Fragment,null,l({target:a.reactCanvasRenderTarget,getTextColors:e=>{if(["+","-","*","/","="].includes(u[e].content))return{color:255}}}),i().createElement(a.EnumEditor,{enums:a.aligns,value:n,setValue:o}),i().createElement(a.EnumEditor,{enums:a.verticalAligns,value:s,setValue:c}))}},601:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758);const s=()=>{const[e,t]=i().useState([]),{image:n,onClick:o,onMove:s,input:c,reset:l}=(0,a.useImageClickCreate)(!0,(n=>{t((0,r.produce)(e,(e=>{e.push(n)})))}));return(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&l()})),i().createElement("div",{style:{height:"100%"}},i().createElement("svg",{viewBox:"0 0 800 600",width:800,height:600,xmlns:"http://www.w3.org/2000/svg",fill:"none",style:{position:"absolute",left:0,top:0},onClick:e=>o({x:e.clientX,y:e.clientY}),onMouseMove:e=>s({x:e.clientX,y:e.clientY})},[...e,n].map(((e,t)=>e&&i().createElement("image",{key:t,href:e.url,x:e.x,y:e.y,width:e.width,height:e.height})))),c)}},2083:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(3696),o=n.n(r),i=n(9758);const a=()=>{const e=(0,i.useWindowSize)();return o().createElement(i.ImageEditor,{src:"https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg",width:e.width/2,height:e.height})}},250:(e,t,n)=>{"use strict";n.d(t,{stories:()=>fe});var r=n(8995),o=n(7474),i=n(8576),a=n(3388),s=n(2268),c=n(2197),l=n(6844),u=n(2960),p=n(9857),d=n(3464),f=n(7215),g=n(4874),h=n(3191),m=n(9612),y=n(2071),v=n(7258),x=n(2682),b=n(1783),C=n(5090),E=n(6690),P=n(8673),w=n(6808),k=n(2458),_=n(8859),S=n(3823),R=n(1805),T=n(601),A=n(2083),L=n(3613),M=n(4565),I=n(4855),O=n(7265),D=n(2754),B=n(8208),z=n(6821),F=n(425),N=n(6856),U=n(5047),G=n(5836),j=n(5207),V=n(5779),W=n(2890),H=n(1993),q=n(7631),$=n(277),X=n(574),Y=n(597),K=n(4623),Z=n(4922),Q=n(5982),J=n(7560),ee=n(4339),te=n(94),ne=n(8751),re=n(9967),oe=n(5503),ie=n(8119),ae=n(2929),se=n(8337),ce=n(1459),le=n(432),ue=n(5301),pe=n(7507),de=n(1986);const fe=[{path:"attributed-opentype-text-editor.story",name:"",Component:r.default,code:"() => {\n type Attribute = Partial<{ color: number, fontSize: number, backgroundColor: number, underline: boolean, passThrough: boolean, script?: 'sub' | 'sup', circle?: boolean, stackText?: string, bold?: boolean, italic?: boolean, opacity?: number }>\n const size = useWindowSize()\n const width = size.width / 2 - 30\n const [font, setFont] = React.useState()\n const cache = React.useRef(new MapCache4())\n const getTextLayout = (text: string, fontSize: number, italic = false, bold = false) => {\n if (!font || !text) return\n return cache.current.get(italic, bold, fontSize, text, () => {\n const path = font.getPath(text, 0, fontSize, fontSize, { xScale: fontSize / font.unitsPerEm, yScale: fontSize / font.unitsPerEm })\n const glyph = font.charToGlyph(text)\n const box = glyph.getBoundingBox()\n const advanceWidth = glyph.advanceWidth || 0\n const width = box.x2 - box.x1\n const commands = opentypeCommandsToPathCommands(path, italic ? fontSize * 0.7 : undefined)\n let hatches = geometryLinesToHatches(pathCommandsToGeometryLines(commands))\n if (bold) {\n hatches = hatches.map(h => boldHatch(h, fontSize * 0.01))\n }\n return {\n commands: hatches.map(h => [h.border, ...h.holes]).map(h => h.map(lines => geometryLineToPathCommands(lines)).flat()),\n x1: (advanceWidth > width ? 0 : box.x1) / font.unitsPerEm * fontSize,\n y1: (glyph.unicode && glyph.unicode < 256 ? 0 : box.y1) / font.unitsPerEm * fontSize,\n width: Math.max(advanceWidth, width) / font.unitsPerEm * fontSize,\n }\n })\n }\n const [state, setState] = React.useState[]>([{ insert: '我们出' }, { insert: '去吧', attributes: { stackText: 'ab' } }, { insert: 'Aag jioIb BDxVX晒回吧', attributes: { color: 0xff0000 } }])\n const [align, setAlign] = React.useState('left')\n const [verticalAlign, setVerticalAlign] = React.useState('top')\n const [strokeOnly, setStrokeOnly] = React.useState(false)\n const getColor = (content: AttributedText) => content?.attributes?.color ?? 0x000000\n const getOpacity = (content: AttributedText) => content?.attributes?.opacity ?? 1\n const getFontSize = (content?: AttributedText) => content?.attributes?.fontSize ?? 50\n const getComputedFontSize = (content?: AttributedText) => getFontSize(content) * (content?.attributes?.script || content?.attributes?.stackText ? 0.7 : 1)\n const getBackgroundColor = (content?: AttributedText) => content?.attributes?.backgroundColor ?? 0xffffff\n const getUnderline = (content?: AttributedText) => content?.attributes?.underline ?? false\n const getPassThrough = (content?: AttributedText) => content?.attributes?.passThrough ?? false\n const getBold = (content?: AttributedText) => content?.attributes?.bold ?? false\n const getItalic = (content?: AttributedText) => content?.attributes?.italic ?? false\n const getScript = (content?: AttributedText) => content?.attributes?.script\n const getCircle = (content?: AttributedText) => content?.attributes?.circle ?? false\n const getStackText = (content?: AttributedText) => content?.attributes?.stackText ?? ''\n const getLineHeight = (content: AttributedText) => getComputedFontSize(content) * 1.5\n const getWidth = (content: AttributedText) => {\n const fontSize = getComputedFontSize(content)\n if (content.attributes?.stackText) {\n const width = content.insert.split('').reduce((p, c) => p + (getTextLayout(c, fontSize)?.width ?? 0), 0)\n const stackWidth = content.attributes.stackText.split('').reduce((p, c) => p + (getTextLayout(c, fontSize)?.width ?? 0), 0)\n return Math.max(stackWidth, width)\n }\n return getTextLayout(content.insert, fontSize)?.width ?? 0\n }\n const getComputedWidth = (content: AttributedText) => getCircle(content) ? getLineHeight(content) : getWidth(content)\n const getReadonlyType = (attributes?: Attribute) => attributes?.stackText ? true : undefined\n const { renderEditor, layoutResult, lineHeights, isSelected, actualHeight, cursorContent, setSelectedAttributes } = useAttributedTextEditor({\n state,\n setState,\n width,\n height: 200,\n lineHeight: getLineHeight,\n getWidth: getComputedWidth,\n getReadonlyType,\n align,\n verticalAlign,\n })\n\n React.useEffect(() => {\n const fetchFont = async () => {\n const res = await fetch(allFonts[0].url)\n const buffer = await res.arrayBuffer()\n setFont(opentype.parse(buffer))\n }\n fetchFont()\n }, [])\n\n const target = reactSvgRenderTarget\n const children: ReturnType[] = []\n const commands: PathCommand[][] = []\n for (const { x, y, i, content, visible, row } of layoutResult) {\n if (!visible) continue\n const width = getComputedWidth(content)\n const lineHeight = lineHeights[row]\n const selected = isSelected(i)\n if (selected) {\n children.push(target.renderRect(x, y, width, lineHeight, { fillColor: 0xB3D6FD, strokeWidth: 0 }))\n }\n const fontSize = getComputedFontSize(content)\n const italic = getItalic(content)\n const bold = getBold(content)\n const layout = getTextLayout(content.insert, fontSize, italic, bold)\n if (layout) {\n const color = getColor(content)\n const opacity = getOpacity(content)\n const backgroundColor = getBackgroundColor(content)\n if (!selected && backgroundColor !== 0xffffff) {\n children.push(target.renderRect(x, y, width, lineHeight, { fillColor: backgroundColor, strokeWidth: 0 }))\n }\n if (getUnderline(content)) {\n children.push(target.renderPolyline([{ x, y: y + lineHeight }, { x: x + width, y: y + lineHeight }], { strokeColor: color, strokeOpacity: opacity }))\n }\n if (getPassThrough(content)) {\n children.push(target.renderPolyline([{ x, y: y + lineHeight / 2 }, { x: x + width, y: y + lineHeight / 2 }], { strokeColor: color, strokeOpacity: opacity }))\n }\n const pos = {\n x: x - layout.x1,\n y: y + layout.y1 + (lineHeight - getLineHeight(content)),\n }\n const script = getScript(content)\n const stackText = getStackText(content)\n if (script === 'sub') {\n pos.y += fontSize * 0.2\n } else if (script === 'sup' || stackText) {\n pos.y -= fontSize * 0.7\n }\n if (stackText) {\n const textWidth = content.insert.split('').reduce((p, c) => p + (getTextLayout(c, fontSize)?.width ?? 0), 0)\n pos.x += (width - textWidth) / 2\n }\n if (getCircle(content)) {\n pos.x += (lineHeight - getWidth(content)) / 2\n children.push(target.renderCircle(x + width / 2, y + lineHeight / 2, lineHeight / 2, { strokeColor: color, strokeOpacity: opacity }))\n }\n const style = strokeOnly ? { strokeColor: color, strokeOpacity: opacity, strokeWidth: 1 } : { fillColor: color, fillOpacity: opacity, strokeWidth: 0 }\n children.push(target.renderGroup(layout.commands.map(c => target.renderPathCommands(c, style)), { translate: pos }))\n if (selected) {\n commands.push(...layout.commands)\n }\n if (stackText) {\n const stackWidth = stackText.split('').reduce((p, c) => p + (getTextLayout(c, fontSize)?.width ?? 0), 0)\n let xOffset = 0\n for (const char of stackText.split('')) {\n const stackLayout = getTextLayout(char, fontSize, italic, bold)\n if (stackLayout) {\n const stackPos = {\n x: x - stackLayout.x1 + (width - stackWidth) / 2 + xOffset,\n y: y + stackLayout.y1 + (lineHeight - getLineHeight(content)) + fontSize * 0.2,\n }\n xOffset += stackLayout.width\n children.push(target.renderGroup(stackLayout.commands.map(c => target.renderPathCommands(c, style)), { translate: stackPos }))\n }\n }\n }\n }\n }\n const result = target.renderResult(children, width, actualHeight)\n return (\n <>\n {renderEditor(result)}\n \n \n setSelectedAttributes({ color: v })} />,\n opacity: setSelectedAttributes({ opacity: v })} />,\n fontSize: setSelectedAttributes({ fontSize: v })} />,\n backgroundColor: setSelectedAttributes({ backgroundColor: v === 0xffffff ? undefined : v })} />,\n underline: setSelectedAttributes({ underline: v ? true : undefined })} />,\n passThrough: setSelectedAttributes({ passThrough: v ? true : undefined })} />,\n bold: setSelectedAttributes({ bold: v ? true : undefined })} />,\n italic: setSelectedAttributes({ italic: v ? true : undefined })} />,\n strokeOnly: setStrokeOnly(v)} />,\n sub: setSelectedAttributes({ script: v ? 'sub' : undefined })} />,\n sup: setSelectedAttributes({ script: v ? 'sup' : undefined })} />,\n circle: setSelectedAttributes({ circle: v ? true : undefined })} />,\n stackText: setSelectedAttributes({ stackText: v ? v : undefined })} />,\n actions: ,\n }}\n />\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"attributed-text-editor.story",name:"",Component:o.default,code:"() => {\n type Attribute = Partial<{ color: number, fontFamily: string, bold: boolean, italic: boolean, readonly?: string }>\n const [state, setState] = React.useState[]>([{ insert: 'abc' }, { insert: '123', attributes: { color: 0xff0000, readonly: '1' } }, { insert: 'edf', attributes: { readonly: '1' } }, { insert: 'ghi', attributes: { color: 0x00ff00 } }])\n const [align, setAlign] = React.useState('left')\n const [verticalAlign, setVerticalAlign] = React.useState('top')\n const fontSize = 20\n const getFontFamily = (content?: AttributedText) => content?.attributes?.fontFamily ?? 'monospace'\n const getColor = (content?: AttributedText) => content?.attributes?.color ?? 0x000000\n const getBold = (content?: AttributedText) => content?.attributes?.bold ?? false\n const getItalic = (content?: AttributedText) => content?.attributes?.italic ?? false\n const width = 400\n const lineHeight = fontSize * 1.2\n const getWidth = (content: AttributedText) => getTextSizeFromCache(`${getBold(content) ? 'bold ' : ''}${getItalic(content) ? 'italic ' : ''}${fontSize}px ${getFontFamily(content)}`, content.insert)?.width ?? 0\n const { renderEditor, layoutResult, isSelected, actualHeight, cursorContent, setSelectedAttributes } = useAttributedTextEditor({\n state,\n setState,\n width,\n height: 200,\n lineHeight,\n getWidth,\n align,\n verticalAlign,\n getReadonlyType: attributes => attributes?.readonly,\n })\n const children: CanvasDraw[] = []\n const target = reactCanvasRenderTarget\n for (const { x, y, i, content, visible } of layoutResult) {\n if (!visible) continue\n const textWidth = getWidth(content)\n if (isSelected(i)) {\n children.push(target.renderRect(x, y, textWidth, lineHeight, { fillColor: 0xB3D6FD, strokeWidth: 0 }))\n }\n children.push(target.renderText(x + textWidth / 2, y + fontSize, content.insert, getColor(content), fontSize, getFontFamily(content), {\n textAlign: 'center',\n fontWeight: getBold(content) ? 'bold' : undefined,\n fontStyle: getItalic(content) ? 'italic' : undefined,\n }))\n }\n const result = target.renderResult(children, width, actualHeight)\n return (\n <>\n {renderEditor(result)}\n \n \n setSelectedAttributes({ color: v })} />,\n fontFamily: setSelectedAttributes({ fontFamily: v })} />,\n bold: setSelectedAttributes({ bold: v ? true : undefined })} />,\n italic: setSelectedAttributes({ italic: v ? true : undefined })} />,\n }}\n />\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"audio-record.story",name:"",Component:i.default,code:"() => {\n const { start, stop, duration, volume, audioUrl, recording } = useAudioRecorder()\n const { play, pause, playing, currentTime, audio, duration: audioDuration } = useAudioPlayer(audioUrl)\n return (\n
\n {!recording ? : null}\n {recording ? : null}\n {recording && volume !== undefined ? : null}\n {audioUrl && (\n <>\n \n {currentTime}/{audioDuration}\n {audio}\n \n )}\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"bar-chart-3d.story",name:"",Component:a.default,code:"() => {\n const ref = React.useRef(null)\n const renderer = React.useRef>()\n const { x, y, ref: wheelScrollRef } = useWheelScroll()\n const { scale, ref: wheelZoomRef } = useWheelZoom()\n const [rotate, setRotate] = React.useState({ x: 0, y: 0 })\n const { offset, onStart: onStartMoveCanvas, mask: moveCanvasMask, resetDragMove } = useDragMove(() => {\n setRotate((v) => ({ x: v.x + offset.x, y: v.y + offset.y }))\n })\n const size = useWindowSize()\n const width = size.width / 2\n const height = size.height\n const [hovering, setHovering] = React.useState()\n const rotateX = offset.x + rotate.x\n const rotateY = offset.y + rotate.y\n const graphics = React.useRef<(Graphic3d)[]>([])\n const getXLabel = (x: number) => Intl.DateTimeFormat('zh', { month: 'long' }).format(new Date(x.toString()))\n\n React.useEffect(() => {\n if (!ref.current || renderer.current) return\n renderer.current = createWebgl3DRenderer(ref.current)\n }, [ref.current])\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n resetDragMove()\n }\n })\n\n React.useEffect(() => {\n const points1 = [65, 59, 80, 81, 56, 55, 40].map((s, i) => [(i + 1) * 20, s, 0] as Vec3)\n const points2 = [55, 49, 70, 71, 46, 45, 30].map((s, i) => [(i + 1) * 20, s, 20] as Vec3)\n const points3 = [45, 39, 60, 61, 36, 35, 20].map((s, i) => [(i + 1) * 20, s, 40] as Vec3)\n const points4 = [75, 69, 90, 91, 66, 65, 50].map((s, i) => [(i + 1) * 20, s, -20] as Vec3)\n const axis = getChartAxis3D([points1, points2, points3, points4], { x: 20, y: 10, z: 20 })\n graphics.current.push(\n ...axis,\n ...points1.map(p => ({ geometry: { type: 'cylinder' as const, radius: 3, height: p[1] }, color: [1, 0, 0, 1] as Vec4, position: [p[0], p[1] / 2, p[2]] as Vec3 })),\n ...points2.map(p => ({ geometry: { type: 'cylinder' as const, radius: 3, height: p[1] }, color: [0, 1, 0, 1] as Vec4, position: [p[0], p[1] / 2, p[2]] as Vec3 })),\n ...points3.map(p => ({ geometry: { type: 'cylinder' as const, radius: 3, height: p[1] }, color: [0, 0, 1, 1] as Vec4, position: [p[0], p[1] / 2, p[2]] as Vec3 })),\n ...points4.map(p => ({ geometry: { type: 'cylinder' as const, radius: 3, height: p[1] }, color: [0, 0, 0, 1] as Vec4, position: [p[0], p[1] / 2, p[2]] as Vec3 })),\n )\n }, [])\n\n React.useEffect(() => {\n const { position, up } = updateCamera(-x, y, 200 / scale, -0.3 * rotateX, -0.3 * rotateY)\n renderer.current?.render?.(\n graphics.current,\n {\n eye: [position.x + 40, position.y + 40, position.z],\n up: position3DToVec3(up),\n target: [-x + 40, y + 40, 0],\n fov: angleToRadian(60),\n near: 0.1,\n far: 2000,\n },\n {\n position: [1000, 1000, 1000],\n color: [1, 1, 1, 1],\n specular: [1, 1, 1, 1],\n shininess: 50,\n specularFactor: 1,\n },\n [1, 1, 1, 1],\n )\n }, [x, y, scale, rotateX, rotateY, hovering, width, height])\n\n return (\n
\n onStartMoveCanvas({ x: e.clientX, y: e.clientY })}\n onMouseMove={e => {\n setHovering(undefined)\n const index = renderer.current?.pick?.(e.clientX, e.clientY, (g) => g.geometry.type === 'cylinder')\n if (index !== undefined) {\n const graphic = graphics.current[index]\n if (graphic.position) {\n setHovering({ value: graphic.position, x: e.clientX, y: e.clientY })\n }\n }\n }}\n />\n {hovering && }\n {moveCanvasMask}\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"bar-chart.story",name:"",Component:s.default,code:"() => {\n const size = useWindowSize()\n const width = size.width / 2\n const height = 500\n const target = reactSvgRenderTarget\n const [hovering, setHovering] = React.useState()\n const [result, setResult] = React.useState<{ children: SvgDraw[], select: (p: Position) => Position & { value: { x: number, y: number | number[] } } | undefined }>()\n const getXLabel = (x: number) => Intl.DateTimeFormat('zh', { month: 'long' }).format(new Date((x + 1).toString()))\n\n React.useEffect(() => {\n const datas = [\n [65, 59, 80, 81, 56, 55, 40].map(x => [x]),\n [55, 49, 70, 71, 46, 45, 30].map(x => [x]),\n [45, 39, 60, 61, 36, 35, 30].map(x => [x - 20, x]),\n [65, 59, 80, 81, 56, 55, 40].map(x => [x - 30, x - 15, x - 5, x]),\n ]\n const data1 = [35, 29, 50, 51, 26, 25, 10].map((s, i) => ({ x: i, y: s }))\n const colors = [[0xff0000], [0x00ff00], [0x0000ff], [0xff0000, 0x00ff00, 0x0000ff]]\n const { children, select, tx, ty } = getBarChart(datas, colors, (region, color) => target.renderPolygon(getRoundedRectPoints(region, 5, 30), { fillColor: color, strokeWidth: 0 }), target, { y: 5 }, { width, height }, { left: 25, right: 10, top: 10, bottom: 20 }, {\n getXLabel,\n bounding: getPointsBounding(data1)\n })\n\n const points1 = data1.map(c => ({ x: tx(c.x + 0.5), y: ty(c.y) }))\n children.push(target.renderPolyline(points1, { strokeColor: 0x000000 }))\n children.push(...points1.map(c => target.renderCircle(c.x, c.y, 3, { fillColor: 0x000000, strokeWidth: 0 })))\n\n setResult({\n children,\n select: (p) => {\n const j = points1.findIndex(n => getTwoPointsDistance(n, p) <= 5)\n if (j >= 0) {\n return { ...points1[j], value: data1[j] }\n }\n return select(p)\n }\n })\n }, [width])\n\n if (!result) {\n return null\n }\n let children = result.children\n if (hovering) {\n children = [\n ...result.children,\n ...renderChartTooltip(target, hovering, hovering.value, { getXLabel }),\n ]\n }\n return (\n
\n {target.renderResult(children, width, height, { attributes: { onMouseMove: e => setHovering(result.select({ x: e.clientX, y: e.clientY })) } })}\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"circle-arc-click-create.story",name:"",Component:c.default,code:"() => {\n const [contents, setContents] = React.useState([])\n const { circle, arc, onClick, onMove, input, reset } = useCircleArcClickCreate('center radius', (c) => {\n setContents(produce(contents, (draft) => {\n draft.push(c)\n }))\n })\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n reset()\n }\n })\n const arcCircle = circle || arc\n return (\n onClick({ x: e.clientX, y: e.clientY })}\n onMouseMove={(e) => onMove({ x: e.clientX, y: e.clientY })}\n style={{ height: '100%' }}\n >\n onClick({ x: e.clientX, y: e.clientY })}\n onMouseMove={(e) => onMove({ x: e.clientX, y: e.clientY })}\n >\n {arcCircle && }\n {[...contents, arc].map((content, i) => {\n if (content) {\n const start = polarToCartesian(content.x, content.y, content.r, content.endAngle)\n const end = polarToCartesian(content.x, content.y, content.r, content.startAngle)\n return (\n \n )\n }\n return null\n })}\n \n {input}\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"circle-arc-edit.story",name:"",Component:l.default,code:"() => {\n const [content, setContent] = React.useState({ x: 200, y: 200, r: 100, startAngle: -30, endAngle: 120 })\n const { offset, onStart, mask, reset } = useCircleArcEdit(() => setContent(circleArc))\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n reset()\n }\n })\n const circleArc = produce(content, (draft) => {\n if (offset) {\n draft.x += offset.x\n draft.y += offset.y\n draft.r += offset.r\n draft.startAngle += offset.startAngle\n draft.endAngle += offset.endAngle\n normalizeAngleRange(draft)\n }\n })\n const start = polarToCartesian(circleArc.x, circleArc.y, circleArc.r, circleArc.endAngle)\n const end = polarToCartesian(circleArc.x, circleArc.y, circleArc.r, circleArc.startAngle)\n return (\n <>\n \n \n \n onStart(e, { ...circleArc, type, cursor })}\n />\n {mask}\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"circle-click-create.story",name:"",Component:u.default,code:"() => {\n const [contents, setContents] = React.useState([])\n const { circle, onClick, onMove, input, reset } = useCircleClickCreate('center radius', (c) => {\n setContents(produce(contents, (draft) => {\n draft.push(c)\n }))\n })\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n reset()\n }\n })\n\n return (\n onClick({ x: e.clientX, y: e.clientY })}\n onMouseMove={(e) => onMove({ x: e.clientX, y: e.clientY })}\n style={{ height: '100%' }}\n >\n {[...contents, circle].map((content, i) => content && (\n \n \n ))}\n {input}\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"circle-edit.story",name:"",Component:p.default,code:"() => {\n const [content, setContent] = React.useState({ x: 300, y: 200, r: 100 })\n const { offset, onStart, mask, reset } = useCircleEdit(() => setContent(circle))\n const circle = produce(content, (draft) => {\n draft.x += offset.x\n draft.y += offset.y\n draft.r += offset.r\n })\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n reset()\n }\n })\n return (\n <>\n \n \n onStart(e, { ...content, type, cursor })}\n />\n {mask}\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"drag-move.story",name:"",Component:d.default,code:"() => {\n const [x, setX] = React.useState(0)\n const [y, setY] = React.useState(0)\n const { offset, onStart, mask, resetDragMove } = useDragMove(() => {\n setX((v) => v + offset.x)\n setY((v) => v + offset.y)\n })\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n resetDragMove()\n }\n })\n\n return (\n \n onStart({ x: e.clientX, y: e.clientY })}\n >\n {mask}\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"drag-resize.story",name:"",Component:f.default,code:"() => {\n const [content, setContent] = React.useState({\n x: 200,\n y: 200,\n width: 100,\n height: 100,\n })\n const { offset, onStart, mask, resetDragResize } = useDragResize(\n () => setContent(previewContent),\n {\n centeredScaling: (e) => e.shiftKey,\n keepRatio: (e) => metaKeyIfMacElseCtrlKey(e) ? content.width / content.height : undefined,\n transformOffset: (f, e) => {\n // keep width >= 0\n if (f.width + content.width < 0) {\n f.width = -content.width\n // keep x < content right border(or content center if centeredScaling is true)\n f.x = Math.min(f.x, content.width * (e?.shiftKey ? 0.5 : 1))\n }\n if (f.height + content.height < 0) {\n f.height = -content.height\n f.y = Math.min(f.y, content.height * (e?.shiftKey ? 0.5 : 1))\n }\n return f\n },\n },\n )\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n resetDragResize()\n }\n })\n const previewContent = produce(content, (draft) => {\n draft.width += offset.width\n draft.height += offset.height\n draft.x += offset.x\n draft.y += offset.y\n })\n\n return (\n <>\n \n \n \n {mask}\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"drag-rotate.story",name:"",Component:g.default,code:"() => {\n const [content, setContent] = React.useState({\n x: 200,\n y: 200,\n width: 100,\n height: 100,\n rotate: 0,\n url: 'https://interactive-examples.mdn.mozilla.net/media/cc0-images/grapefruit-slice-332-332.jpg',\n })\n const { offset, onStart, mask, resetDragRotate } = useDragRotate(\n () => setContent(previewContent),\n {\n transformOffset: (r, e) => {\n if (e && r !== undefined && !e.shiftKey) {\n const snap = Math.round(r / 45) * 45\n if (Math.abs(snap - r) < 5) {\n r = snap\n }\n }\n return r\n },\n }\n )\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n resetDragRotate()\n }\n })\n const previewContent = produce(content, (draft) => {\n if (offset?.angle !== undefined) {\n draft.rotate = offset.angle\n }\n })\n\n return (\n <>\n \n onStart({ x: content.x + content.width / 2, y: content.y + content.height / 2 })} />\n \n {mask}\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"drag-select.story",name:"",Component:h.default,code:"() => {\n const [contents, setContents] = React.useState([])\n const { onStartSelect, dragSelectMask, resetDragSelect } = useDragSelect((dragSelectStartPosition, dragSelectEndPosition) => {\n if (dragSelectEndPosition) {\n setContents(produce(contents, (draft) => {\n draft.push({\n x: Math.min(dragSelectStartPosition.x, dragSelectEndPosition.x),\n y: Math.min(dragSelectStartPosition.y, dragSelectEndPosition.y),\n width: Math.abs(dragSelectEndPosition.x - dragSelectStartPosition.x),\n height: Math.abs(dragSelectEndPosition.y - dragSelectStartPosition.y),\n })\n }))\n }\n }, (e) => e.shiftKey)\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n resetDragSelect()\n }\n })\n\n return (\n onStartSelect(e, undefined)}\n style={{ height: '100%' }}\n >\n {contents.map((content, i) => (\n \n \n ))}\n {dragSelectMask}\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"edit.story",name:"",Component:m.default,code:"() => {\n const [content, setContent] = React.useState({ x: 300, y: 200, r: 100 })\n const { editPoint, updateEditPreview, onEditMove, onEditClick, getEditAssistentContents, resetEdit } = useEdit(\n () => setContent(circle),\n (s) => ({\n editPoints: [\n {\n x: s.x,\n y: s.y,\n cursor: 'move',\n update(c, { cursor, start }) {\n c.x += cursor.x - start.x\n c.y += cursor.y - start.y\n }\n },\n { x: s.x - s.r, y: s.y, cursor: 'ew-resize', update(c, { cursor }) { c.r = getTwoPointsDistance(cursor, c) } },\n { x: s.x, y: s.y - s.r, cursor: 'ns-resize', update(c, { cursor }) { c.r = getTwoPointsDistance(cursor, c) } },\n { x: s.x + s.r, y: s.y, cursor: 'ew-resize', update(c, { cursor }) { c.r = getTwoPointsDistance(cursor, c) } },\n { x: s.x, y: s.y + s.r, cursor: 'ns-resize', update(c, { cursor }) { c.r = getTwoPointsDistance(cursor, c) } },\n ],\n }),\n )\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n resetEdit()\n }\n })\n const assistentContents: Region[] = []\n const newContent = updateEditPreview()\n const circle = newContent?.result ?? content\n assistentContents.push(...getEditAssistentContents(circle, (rect) => rect))\n\n return (\n <>\n onEditMove({ x: e.clientX, y: e.clientY }, [{ content: circle, path: [0] }])}\n onClick={(e) => editPoint && onEditClick({ x: e.clientX, y: e.clientY })}\n >\n \n {assistentContents.map((s, i) => )}\n \n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"ellipse-arc-click-create.story",name:"",Component:y.default,code:"() => {\n const [contents, setContents] = React.useState([])\n const { ellipse, ellipseArc, onClick, onMove, input, reset } = useEllipseArcClickCreate('ellipse center', (c) => {\n setContents(produce(contents, (draft) => {\n draft.push(c)\n }))\n })\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n reset()\n }\n })\n const arcEllipse = ellipse || ellipseArc\n return (\n onClick({ x: e.clientX, y: e.clientY })}\n onMouseMove={(e) => onMove({ x: e.clientX, y: e.clientY })}\n style={{ height: '100%' }}\n >\n onClick({ x: e.clientX, y: e.clientY })}\n onMouseMove={(e) => onMove({ x: e.clientX, y: e.clientY })}\n >\n {arcEllipse && }\n {[...contents, ellipseArc].map((content, i) => {\n if (content) {\n const points = ellipseArcToPolyline(content, defaultAngleDelta)\n return `${p.x},${p.y}`).join(' ')}\n stroke='#00ff00'\n />\n }\n return null\n })}\n \n {input}\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"ellipse-arc-edit.story",name:"",Component:v.default,code:"() => {\n const [content, setContent] = React.useState({ cx: 200, cy: 200, rx: 100, ry: 150, angle: 45, startAngle: -30, endAngle: 120 })\n const { offset, onStart, mask, reset } = useEllipseArcEdit(() => setContent(ellipseArc))\n const ellipseArc = produce(content, (draft) => {\n if (offset) {\n draft.cx += offset.cx\n draft.cy += offset.cy\n draft.rx += offset.rx\n draft.ry += offset.ry\n draft.startAngle += offset.startAngle\n draft.endAngle += offset.endAngle\n normalizeAngleRange(draft)\n }\n })\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n reset()\n }\n })\n const points = ellipseArcToPolyline(ellipseArc, defaultAngleDelta)\n return (\n <>\n \n `${p.x},${p.y}`).join(' ')}\n stroke='#00ff00'\n />\n \n onStart(e, { ...ellipseArc, type, cursor })}\n />\n {mask}\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"ellipse-click-create.story",name:"",Component:x.default,code:"() => {\n const [contents, setContents] = React.useState([])\n const { ellipse, onClick, onMove, input, reset } = useEllipseClickCreate('ellipse center', (c) => {\n setContents(produce(contents, (draft) => {\n draft.push(c)\n }))\n })\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n reset()\n }\n })\n\n return (\n
\n onClick({ x: e.clientX, y: e.clientY })}\n onMouseMove={(e) => onMove({ x: e.clientX, y: e.clientY })}\n >\n {[...contents, ellipse].map((content, i) => content && )}\n \n {input}\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"ellipse-edit.story",name:"",Component:b.default,code:"() => {\n const [content, setContent] = React.useState({ cx: 200, cy: 200, rx: 100, ry: 150, angle: 45 })\n const { offset, onStart, mask, reset } = useEllipseEdit(() => setContent(ellipse))\n const ellipse = produce(content, (draft) => {\n if (offset) {\n draft.cx += offset.cx\n draft.cy += offset.cy\n draft.rx += offset.rx\n draft.ry += offset.ry\n }\n })\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n reset()\n }\n })\n return (\n <>\n \n \n \n onStart(e, { ...ellipse, type, cursor })}\n />\n {mask}\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"equation-renderer.story",name:"",Component:C.default,code:"() => {\n const [left, setLeft] = React.useState('X1 ** 2 + X2 * X3')\n const [right, setRight] = React.useState('(-X6) ** 0.5 / (X4 - X5 ** 3)')\n const [equation, setEquation] = React.useState()\n const [keepBinaryExpressionOrder, setKeepBinaryExpressionOrder] = React.useState(false)\n React.useEffect(() => {\n try {\n setEquation({\n left: parseExpression(tokenizeExpression(left)),\n right: parseExpression(tokenizeExpression(right)),\n })\n } catch (error) {\n console.info(error)\n }\n }, [left, right])\n return (\n
\n \n \n \n {equation && renderEquation(reactSvgRenderTarget, equation, { keepBinaryExpressionOrder })}\n {equation && {printEquation(equation, { keepBinaryExpressionOrder })}}\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"equation-solver.story",name:"",Component:E.default,code:"() => {\n const { value, update, getArrayProps } = useJsonEditorData([\n { equation: 'a * x + b * y = c', variable: 'x' },\n { equation: 'x ** 2 + y ** 2 = r', variable: 'y' },\n ])\n const [isMath, setIsMath] = React.useState(false)\n const [equations, setEquations] = React.useState([])\n const [keepBinaryExpressionOrder, setKeepBinaryExpressionOrder] = React.useState(false)\n const [showText, setShowText] = React.useState(false)\n React.useEffect(() => {\n try {\n const result = solveEquations(value.map(e => {\n const equation = e.equation.split('=')\n return {\n left: parseExpression(tokenizeExpression(isMath ? mathStyleExpressionToExpression(equation[0]) : equation[0])),\n right: parseExpression(tokenizeExpression(isMath ? mathStyleExpressionToExpression(equation[1]) : equation[1])),\n }\n }), new Set(value.map(e => e.variable)))\n setEquations(result.map(e => Object.entries(e).map(([key, e]) => {\n return !Array.isArray(e) ? { left: { type: 'Identifier', name: key }, right: e } : { left: e[0], right: e[1] }\n })))\n } catch (error) {\n console.info(error)\n }\n }, [value, isMath])\n return (\n
\n v, { equation: 'x = 1', variable: 'x' })}\n properties={value.map((f, i) => ({\n equation: draft[i].equation = v)} height={20} width={400} autoHeight />,\n variable: draft[i].variable = v)} />\n }))}\n />\n \n \n \n {equations.map((a, j) => (\n
\n {a.map((e, i) => (\n \n {!showText && renderEquation(reactSvgRenderTarget, e, { keepBinaryExpressionOrder })}\n {showText &&
{printEquation(e, { keepBinaryExpressionOrder })}
}\n
\n ))}\n
\n ))}\n {isMath && equations.map((a, j) => (\n
\n {a.map((e, i) => (\n
{printMathStyleExpression(e.left)} = {printMathStyleExpression(e.right)}
\n ))}\n
\n ))}\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"expression-chart.story",name:"",Component:P.default,code:"() => {\n const { value, update, getArrayProps } = useJsonEditorData(['sin(x)'])\n const [hovering, setHovering] = React.useState()\n const [min, setMin] = React.useState(0)\n const [max, setMax] = React.useState(10)\n const [isMath, setIsMath] = React.useState(true)\n const [equationResult, setEquationResult] = React.useState([])\n const [error, setError] = React.useState()\n\n const size = useWindowSize()\n const width = size.width / 2\n const height = 300\n const target = reactSvgRenderTarget\n const [result, setResult] = React.useState<{ children: SvgDraw[], select: (p: Position) => Position & { value: Position } | undefined }>()\n const parseInputExpression = (v: string) => parseExpression(tokenizeExpression(isMath ? mathStyleExpressionToExpression(v) : v))\n\n const drawChart = () => {\n try {\n if (value.length === 0) return\n const points: Position[][] = []\n const step = (max - min) / 100\n const x0 = getTwoNumberCenter(min, max)\n const ctx = {\n sin: Math.sin,\n cos: Math.cos,\n tan: Math.tan,\n ln: Math.log,\n sqrt: Math.sqrt,\n }\n const newEquationResult: number[] = []\n for (const v of value) {\n if (!v) continue\n const p: Position[] = []\n const e = parseInputExpression(v)\n\n const factors = expressionToFactors(e)\n if (factors) {\n const params = factorsToEquationParams(factors, 'x')\n if (params) {\n newEquationResult.push(...calculateEquation5(params, x0, delta1))\n }\n }\n const g = parseInputExpression(printExpression(optimizeExpression(deriveExpressionWith(e, 'x'), v => expressionHasVariable(v, 'x'))))\n const r1 = newtonIterate(x0, x => {\n try {\n const y = evaluateExpression(e, { ...ctx, x })\n return typeof y === 'number' ? y : NaN\n } catch {\n return NaN\n }\n }, x => {\n try {\n const y = evaluateExpression(g, { ...ctx, x })\n return typeof y === 'number' ? y : NaN\n } catch {\n return NaN\n }\n }, delta1)\n if (r1 !== undefined && newEquationResult.every(n => !isSameNumber(n, r1))) {\n newEquationResult.push(r1)\n }\n\n for (let x = min; x <= max; x += step) {\n const y = evaluateExpression(e, { ...ctx, x })\n if (typeof y === 'number' && !isNaN(y)) {\n p.push({ x, y })\n }\n }\n if (p.length > 0) {\n points.push(p)\n }\n }\n setEquationResult(newEquationResult)\n const ys = points.flat().map(p => p.y)\n const minY = Math.min(...ys)\n const maxY = Math.max(...ys)\n const equationResultPoints = newEquationResult.filter(n => isBetween(n, min, max)).map(x => [{ x, y: minY }, { x, y: maxY }])\n const r = getLineChart([[{ x: min, y: 0 }, { x: max, y: 0 }], ...equationResultPoints, ...points], target, { x: 0.01, y: 0.01 }, { width, height }, { left: 25, right: 25, top: 10, bottom: 20 }, { xLabelDisabled: true, yLabelDisabled: true })\n if (!r) return\n const { points: [axis, ...p], children, select } = r\n children.push(target.renderPolyline(axis, { strokeColor: 0x00ff00 }))\n for (let i = 0; i < p.length; i++) {\n children.push(target.renderPolyline(p[i], { strokeColor: i < equationResultPoints.length ? 0x0000ff : 0xff0000 }))\n }\n setResult({ children, select })\n setError(undefined)\n } catch (error) {\n console.info(error)\n setError(String(error))\n }\n }\n let children: SvgDraw[] | undefined\n if (result) {\n children = result.children\n if (hovering) {\n children = [\n ...result.children,\n ...renderChartTooltip(target, hovering, hovering.value),\n ]\n }\n }\n return (\n
\n {result && children &&
\n {target.renderResult(children, width, height, { attributes: { onMouseMove: e => setHovering(result.select({ x: e.clientX, y: e.clientY })) } })}\n
}\n
\n v, '')}\n inline\n style={{ width: 'calc(50% - 30px)' }}\n items={value.map((f, i) => draft[i] = v)} />)}\n />\n
\n \n
\n
\n \n ~\n \n
\n \n {equationResult.map((r, i) =>
\n x = {r}\n
)}\n {error &&
{error}
}\n
\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"expression-editor.story",name:"",Component:w.default,code:"() => {\n const [value, setValue] = React.useState('1 + 2 - 3')\n\n return (\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"expression-expansion.story",name:"",Component:k.default,code:"() => {\n const [value, setValue] = React.useState('(x + a)^3')\n const [secondValue, setSecondValue] = React.useState('x')\n const [thirdValue, setThirdValue] = React.useState('')\n const [isMath, setIsMath] = React.useState(true)\n const [outputMath, setOutputMath] = React.useState(true)\n const [error, setError] = React.useState()\n const [factors, setFactors] = React.useState()\n const [expression, setExpression] = React.useState()\n\n const parseInputExpression = (v: string) => parseExpression(tokenizeExpression(isMath ? mathStyleExpressionToExpression(v) : v))\n const outputExpression = (e: Expression2) => outputMath ? printMathStyleExpression(e) : printExpression(e)\n const expandAll = () => {\n try {\n if (!value) return\n const r = expandExpression(parseInputExpression(value))\n let f = expressionToFactors(r)\n if (f) {\n f = optimizeFactors(f)\n sortFactors(f)\n setFactors(f)\n setExpression(undefined)\n } else {\n setExpression(r)\n setFactors(undefined)\n }\n setError(undefined)\n } catch (error) {\n console.info(error)\n setError(String(error))\n setFactors(undefined)\n setExpression(undefined)\n }\n }\n const divideBy = () => {\n try {\n if (!secondValue) return\n if (!factors) return\n const r = parseInputExpression(secondValue)\n const f = expressionToFactors(r)\n if (f) {\n const g = divideFactors(factors, f)\n if (g) {\n setFactors(g)\n }\n }\n setError(undefined)\n } catch (error) {\n setError(String(error))\n }\n }\n const groupBy = () => {\n try {\n if (!secondValue) return\n if (!factors) return\n const r = parseInputExpression(secondValue)\n const f = expressionToFactors(r)\n if (f && f.length === 1) {\n const g = groupFactorsBy(factors, f[0])\n if (g) {\n setExpression(g)\n }\n }\n setError(undefined)\n } catch (error) {\n setError(String(error))\n }\n }\n const replaceWith = () => {\n try {\n if (!secondValue) return\n if (!thirdValue) return\n if (!value) return\n const r1 = parseInputExpression(value)\n const r3 = parseInputExpression(thirdValue)\n const g = composeExpression(r1, { [secondValue]: r3 })\n if (g) {\n setExpression(g)\n }\n setError(undefined)\n } catch (error) {\n setError(String(error))\n }\n }\n const formatStyle = () => {\n try {\n if (!value) return\n const r = parseInputExpression(value)\n setExpression(r)\n setError(undefined)\n } catch (error) {\n setError(String(error))\n setExpression(undefined)\n }\n }\n const groupAll = () => {\n if (!factors) return\n setExpression(groupAllFactors(factors))\n }\n const deriveWith = () => {\n try {\n if (!secondValue) return\n if (!value) return\n const r = parseInputExpression(value)\n const g = optimizeExpression(deriveExpressionWith(r, secondValue), v => expressionHasVariable(v, secondValue))\n setExpression(g)\n setError(undefined)\n } catch (error) {\n setError(String(error))\n setExpression(undefined)\n }\n }\n const optimize = () => {\n try {\n if (!value) return\n const r = parseInputExpression(value)\n const g = optimizeExpression(r)\n setExpression(g)\n setError(undefined)\n } catch (error) {\n setError(String(error))\n setExpression(undefined)\n }\n }\n const groupByVariables = () => {\n try {\n if (!secondValue) return\n if (!factors) return\n const r = parseInputExpression(secondValue)\n const f = expressionToFactors(r)\n if (f && f.length === 1) {\n const g = groupFactorsByVariables(factors, f[0].variables.filter((v): v is string => typeof v === 'string'))\n if (g) {\n setExpression(g)\n }\n }\n setError(undefined)\n } catch (error) {\n setError(String(error))\n }\n }\n const taylorExpand = (toPrimaryFunction: boolean) => {\n try {\n if (!secondValue) return\n if (!value) return\n const r = parseInputExpression(value)\n const g = taylorExpandExpressionWith(r, secondValue, +thirdValue || 5, toPrimaryFunction)\n setExpression(g)\n setError(undefined)\n } catch (error) {\n setError(String(error))\n setExpression(undefined)\n }\n }\n const setText = (text: string) => {\n setValue(text)\n setError(undefined)\n setFactors(undefined)\n setExpression(undefined)\n }\n\n return (\n
\n \n
\n \n \n
\n
\n \n =\n \n
\n \n \n \n \n \n \n \n \n \n \n \n {factors && factors.length > 0 &&
\n {factors.map((f, i) =>
{outputExpression(factorToExpression(f))}
)}\n
}\n {factors &&
\n {outputExpression(factorsToExpression(factors))}\n \n \n
}\n {expression &&
\n {outputExpression(expression)}\n \n \n
}\n {expression && renderExpression(reactSvgRenderTarget, expression)}\n {error &&
{error}
}\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"flow-layout-block-editor.story",name:"",Component:_.default,code:"() => {\n const [state, setState] = React.useState(() => new Array(3).fill(0).map(() => ({\n children: new Array(20).fill(0).map(() => ({\n radius: 5 + Math.round(Math.random() * 20),\n color: Math.round(Math.random() * 0xffffff),\n })),\n blockStart: 5,\n blockEnd: 5\n })))\n const [align, setAlign] = React.useState('left')\n const [verticalAlign, setVerticalAlign] = React.useState('top')\n const width = 400\n const { renderEditor, layoutResult, lineHeights, isSelected, actualHeight, inputContent, inputInline, getCopiedContents } = useFlowLayoutBlockEditor<{ radius: number, color: number }>({\n state,\n setState: recipe => setState(produce(state, recipe)),\n width,\n height: 400,\n lineHeight: c => c.radius * 2,\n getWidth: c => c.radius * 2,\n endContent: { radius: 0, color: 0 },\n isNewLineContent: content => content.radius === 0,\n align,\n verticalAlign,\n processInput(e) {\n if (metaKeyIfMacElseCtrlKey(e)) {\n if (e.key === 'v') {\n navigator.clipboard.readText().then(v => {\n if (v) {\n const contents: FlowLayoutBlock<{ radius: number, color: number }>[] = JSON.parse(v)\n if (contents.length === 1) {\n inputInline(contents[0].children)\n } else {\n inputContent(contents)\n }\n }\n })\n e.preventDefault()\n return true\n }\n if (e.key === 'c' || e.key === 'x') {\n const contents = getCopiedContents(e.key === 'x')\n if (contents) {\n navigator.clipboard.writeText(JSON.stringify(contents))\n }\n return true\n }\n }\n return false\n },\n })\n const target: ReactRenderTarget = reactCanvasRenderTarget\n const children: unknown[] = []\n layoutResult.forEach((r, blockIndex) => {\n r.forEach(({ x, y, content, visible, row }, contentIndex) => {\n if (!visible) return\n if (isSelected([blockIndex, contentIndex])) {\n children.push(target.renderRect(x, y, content.radius * 2, lineHeights[row], { fillColor: 0xB3D6FD, strokeWidth: 0 }))\n }\n children.push(target.renderCircle(x + content.radius, y + lineHeights[row] / 2, content.radius, { fillColor: content.color, strokeWidth: 0 }))\n })\n })\n const result = target.renderResult(children, width, actualHeight)\n return (\n <>\n {renderEditor(result)}\n \n \n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"flow-layout-editor.story",name:"",Component:S.default,code:"() => {\n const [state, setState] = React.useState(() => new Array(30).fill(0).map(() => ({\n radius: 5 + Math.round(Math.random() * 20),\n color: Math.round(Math.random() * 0xffffff),\n })))\n const [align, setAlign] = React.useState('left')\n const [verticalAlign, setVerticalAlign] = React.useState('top')\n const width = 400\n const { renderEditor, layoutResult, lineHeights, isSelected, actualHeight, inputContent, getCopiedContents } = useFlowLayoutEditor({\n state,\n setState: recipe => setState(produce(state, recipe)),\n width,\n height: 200,\n lineHeight: c => c.radius * 2,\n getWidth: c => c.radius * 2,\n endContent: { radius: 0, color: 0 },\n isNewLineContent: content => content.radius === 0,\n align,\n verticalAlign,\n processInput(e) {\n if (e.key === 'Enter') {\n inputContent([{ radius: 0, color: 0 }])\n return true\n }\n if (metaKeyIfMacElseCtrlKey(e)) {\n if (e.key === 'v') {\n navigator.clipboard.readText().then(v => {\n if (v) {\n inputContent(JSON.parse(v))\n }\n })\n e.preventDefault()\n return true\n }\n if (e.key === 'c' || e.key === 'x') {\n const contents = getCopiedContents(e.key === 'x')\n if (contents) {\n navigator.clipboard.writeText(JSON.stringify(contents))\n }\n return true\n }\n }\n return false\n },\n })\n const target: ReactRenderTarget = reactCanvasRenderTarget\n const children: unknown[] = []\n for (const { x, y, i, content, visible, row } of layoutResult) {\n if (!visible) continue\n if (isSelected(i)) {\n children.push(target.renderRect(x, y, content.radius * 2, lineHeights[row], { fillColor: 0xB3D6FD, strokeWidth: 0 }))\n }\n children.push(target.renderCircle(x + content.radius, y + lineHeights[row] / 2, content.radius, { fillColor: content.color, strokeWidth: 0 }))\n }\n const result = target.renderResult(children, width, actualHeight)\n return (\n <>\n {renderEditor(result)}\n \n \n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"flow-layout-text-editor.story",name:"",Component:R.default,code:"() => {\n const [state, setState] = React.useState(() => '1 + 2 = 3'.split(''))\n const [align, setAlign] = React.useState('left')\n const [verticalAlign, setVerticalAlign] = React.useState('top')\n const { renderEditor, layoutResult } = useFlowLayoutTextEditor({\n state,\n setState: recipe => setState(produce(state, recipe)),\n width: 400,\n height: 200,\n fontSize: 20,\n fontFamily: 'monospace',\n lineHeight: 20 * 1.2,\n align,\n verticalAlign,\n })\n const getTextColors = (index: number) => {\n if (['+', '-', '*', '/', '='].includes(layoutResult[index].content)) {\n return { color: 0x0000ff }\n }\n return\n }\n\n return (\n <>\n {renderEditor({ target: reactCanvasRenderTarget, getTextColors })}\n \n \n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"image-click-create.story",name:"",Component:T.default,code:"() => {\n const [contents, setContents] = React.useState([])\n const { image, onClick, onMove, input, reset } = useImageClickCreate(true, (c) => {\n setContents(produce(contents, (draft) => {\n draft.push(c)\n }))\n })\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n reset()\n }\n })\n\n return (\n
\n onClick({ x: e.clientX, y: e.clientY })}\n onMouseMove={(e) => onMove({ x: e.clientX, y: e.clientY })}\n >\n {[...contents, image].map((content, i) => content && )}\n \n {input}\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"image-editor.story",name:"",Component:A.default,code:"() => {\n const size = useWindowSize()\n return (\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"keyboard-zoom.story",name:"",Component:L.default,code:"() => {\n const [scale, setScale] = React.useState(1)\n const { zoomIn, zoomOut } = useZoom(scale, setScale)\n useGlobalKeyDown(e => {\n if (metaKeyIfMacElseCtrlKey(e)) {\n if (e.code === 'Minus') {\n zoomOut(e)\n } else if (e.code === 'Equal') {\n zoomIn(e)\n }\n }\n })\n return (\n \n \n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"line-alignment-line.story",name:"",Component:M.default,code:"() => {\n const [contents, setContents] = React.useState(defaultContents)\n const [selectedIndex, setSelectedIndex] = React.useState(0)\n\n const { lineAlignmentX, lineAlignmentY, changeOffsetByLineAlignment, clearLineAlignments } = useLineAlignment(10)\n const { offset, onStart, mask, resetDragResize } = useDragResize(\n () => {\n clearLineAlignments()\n setContents(produce(contents, (draft) => {\n draft[selectedIndex].x += offset.x\n draft[selectedIndex].y += offset.y\n draft[selectedIndex].width += offset.width\n draft[selectedIndex].height += offset.height\n }))\n },\n {\n centeredScaling: (e) => e.shiftKey,\n transformOffset: (f, e, direction) => {\n if (!e?.metaKey && direction) {\n const target = contents[selectedIndex]\n const xLines = contents.filter((t) => t !== target).map((t) => [t.x, t.x + t.width]).flat()\n const yLines = contents.filter((t) => t !== target).map((t) => [t.y, t.y + t.height]).flat()\n changeOffsetByLineAlignment(f, direction, target, xLines, yLines)\n } else {\n clearLineAlignments()\n }\n return f\n },\n }\n )\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n resetDragResize()\n }\n })\n return (\n <>\n {contents.map((content, i) => (\n setSelectedIndex(i)}\n >\n \n {selectedIndex === i && }\n \n ))}\n \n \n {mask}\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"line-chart-3d.story",name:"",Component:I.default,code:"() => {\n const ref = React.useRef(null)\n const renderer = React.useRef>()\n const { x, y, ref: wheelScrollRef } = useWheelScroll()\n const { scale, ref: wheelZoomRef } = useWheelZoom()\n const [rotate, setRotate] = React.useState({ x: 0, y: 0 })\n const { offset, onStart: onStartMoveCanvas, mask: moveCanvasMask, resetDragMove } = useDragMove(() => {\n setRotate((v) => ({ x: v.x + offset.x, y: v.y + offset.y }))\n })\n const size = useWindowSize()\n const width = size.width / 2\n const height = size.height\n const [hovering, setHovering] = React.useState()\n const rotateX = offset.x + rotate.x\n const rotateY = offset.y + rotate.y\n const graphics = React.useRef<(Graphic3d)[]>([])\n const getXLabel = (x: number) => Intl.DateTimeFormat('zh', { month: 'long' }).format(new Date(x.toString()))\n\n React.useEffect(() => {\n if (!ref.current || renderer.current) return\n renderer.current = createWebgl3DRenderer(ref.current)\n }, [ref.current])\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n resetDragMove()\n }\n })\n\n React.useEffect(() => {\n const points1 = [65, 59, 80, 81, 56, 55, 40].map((s, i) => [(i + 1) * 20, s, 0] as Vec3)\n const points2 = [55, 49, 70, 71, 46, 45, 30].map((s, i) => [(i + 1) * 20, s, 20] as Vec3)\n const points3 = [45, 39, 60, 61, 36, 35, 20].map((s, i) => [(i + 1) * 20, s, -20] as Vec3)\n const points4 = [75, 69, 90, 91, 66, 65, 50].map((s, i) => [(i + 1) * 20, s, 40] as Vec3)\n const axis = getChartAxis3D([points1, points2, points3, points4], { x: 20, y: 10, z: 20 })\n graphics.current.push(\n ...axis,\n { geometry: { type: 'line strip', points: points1.flat() }, color: [1, 0, 0, 1] },\n ...points1.map(p => ({ geometry: { type: 'sphere' as const, radius: 1 }, color: [1, 0, 0, 1] as Vec4, position: p })),\n { geometry: { type: 'line strip', points: getBezierSplinePoints3D(points2, 20).flat() }, color: [0, 1, 0, 1] },\n ...points2.map(p => ({ geometry: { type: 'sphere' as const, radius: 1 }, color: [0, 1, 0, 1] as Vec4, position: p })),\n { geometry: { type: 'polygon', points: [...points3.flat(), points3[points3.length - 1][0], 0, points3[points3.length - 1][2], points3[0][0], 0, points3[0][2]] }, color: [0, 0, 1, 1] },\n ...points3.map(p => ({ geometry: { type: 'sphere' as const, radius: 1 }, color: [0, 0, 1, 1] as Vec4, position: p })),\n ...points4.map((p, i) => ({ geometry: { type: 'sphere' as const, radius: i / 2 + 1 }, color: [1, 0, 0, 1] as Vec4, position: p })),\n )\n }, [])\n\n React.useEffect(() => {\n const { position, up } = updateCamera(-x, y, 200 / scale, -0.3 * rotateX, -0.3 * rotateY)\n renderer.current?.render?.(\n graphics.current,\n {\n eye: [position.x + 40, position.y + 40, position.z],\n up: position3DToVec3(up),\n target: [-x + 40, y + 40, 0],\n fov: angleToRadian(60),\n near: 0.1,\n far: 2000,\n },\n {\n position: [1000, 1000, 1000],\n color: [1, 1, 1, 1],\n specular: [1, 1, 1, 1],\n shininess: 50,\n specularFactor: 1,\n },\n [1, 1, 1, 1],\n )\n }, [x, y, scale, rotateX, rotateY, hovering, width, height])\n\n return (\n
\n onStartMoveCanvas({ x: e.clientX, y: e.clientY })}\n onMouseMove={e => {\n setHovering(undefined)\n const index = renderer.current?.pick?.(e.clientX, e.clientY, (g) => g.geometry.type === 'sphere')\n if (index !== undefined) {\n const graphic = graphics.current[index]\n if (graphic.position) {\n setHovering({ value: graphic.position, x: e.clientX, y: e.clientY })\n }\n }\n }}\n />\n {hovering && }\n {moveCanvasMask}\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"line-chart.story",name:"",Component:O.default,code:"() => {\n const size = useWindowSize()\n const width = size.width / 2\n const height = 300\n const target = reactSvgRenderTarget\n const [hovering, setHovering] = React.useState()\n const [result, setResult] = React.useState<{ children: SvgDraw[], select: (p: Position) => Position & { value: Position } | undefined }>()\n const getXLabel = (x: number) => Intl.DateTimeFormat('zh', { month: 'long' }).format(new Date(x.toString()))\n\n React.useEffect(() => {\n const data1 = [65, 59, 80, 81, 56, 55, 40].map((s, i) => ({ x: i + 1, y: s }))\n const data2 = [55, 49, 70, 71, 46, 45, 30].map((s, i) => ({ x: i + 1, y: s }))\n const data3 = [45, 39, 60, 61, 36, 35, 20].map((s, i) => ({ x: i + 1, y: s }))\n const data4 = [35, 29, 50, 51, 26, 25, 10].map((s, i) => ({ x: i + 1, y: s }))\n const data5 = [75, 69, 90, 91, 66, 65, 50].map((s, i) => ({ x: i + 1, y: s, r: i * 3 + 5 }))\n const r = getLineChart([data1, data2, data3, data4, data5], target, { x: 1, y: 5 }, { width, height }, { left: 25, right: 25, top: 10, bottom: 20 }, {\n getXLabel,\n ySecondary: true,\n })\n if (!r) return\n const { points: [points1, points2, points3, points4, points5], children, select, minY } = r\n\n children.push(target.renderPolyline(points1, { strokeColor: 0xff0000 }))\n children.push(...points1.map(c => target.renderCircle(c.x, c.y, 3, { fillColor: 0xff0000, strokeWidth: 0 })))\n children.push(target.renderPolyline(getBezierSplinePoints(points2, 50), { strokeColor: 0x00ff00 }))\n children.push(...points2.map(c => target.renderCircle(c.x, c.y, 3, { fillColor: 0x00ff00, strokeWidth: 0 })))\n children.push(target.renderPolyline(points3.map((p, i) => {\n const r = [p]\n if (i !== 0) r.unshift({ x: getTwoNumberCenter(p.x, points3[i - 1].x), y: p.y })\n if (i !== points3.length - 1) r.push({ x: getTwoNumberCenter(p.x, points3[i + 1].x), y: p.y })\n return r\n }).flat(), { strokeColor: 0x0000ff }))\n children.push(...points3.map(c => target.renderCircle(c.x, c.y, 3, { fillColor: 0x0000ff, strokeWidth: 0 })))\n children.push(target.renderPolygon([...points4, { x: points4[points4.length - 1].x, y: minY }, { x: points4[0].x, y: minY }], { fillColor: 0xff0000, strokeWidth: 0 }))\n children.push(...points4.map(c => target.renderCircle(c.x, c.y, 3, { fillColor: 0xff0000, strokeWidth: 0 })))\n children.push(...points5.map(c => target.renderCircle(c.x, c.y, c.r ?? 5, { fillColor: 0x00ff00, strokeWidth: 0 })))\n\n setResult({ children, select })\n }, [width])\n\n if (!result) {\n return null\n }\n let children = result.children\n if (hovering) {\n children = [\n ...result.children,\n ...renderChartTooltip(target, hovering, hovering.value, { getXLabel }),\n ]\n }\n return (\n
\n {target.renderResult(children, width, height, { attributes: { onMouseMove: e => setHovering(result.select({ x: e.clientX, y: e.clientY })) } })}\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"line-click-create.story",name:"",Component:D.default,code:"() => {\n const [contents, setContents] = React.useState([])\n const { line, onClick, onMove, input, reset } = useLineClickCreate(true, (c) => {\n setContents(produce(contents, (draft) => {\n draft.push(c)\n }))\n })\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n reset(true)\n }\n })\n\n return (\n
\n onClick({ x: e.clientX, y: e.clientY })}\n onMouseMove={(e) => onMove({ x: e.clientX, y: e.clientY })}\n >\n {[...contents, line].map((content, i) => content && `${p.x},${p.y}`).join(' ')}\n />)}\n \n {input}\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"linear-dimension.story",name:"",Component:B.default,code:"() => {\n const dimension: LinearDimension = {\n p1: { x: 200, y: 200 },\n p2: { x: 300, y: 300 },\n position: {\n x: 400,\n y: 100,\n },\n fontFamily: 'monospace',\n fontSize: 16,\n direct: true,\n }\n const { regions, lines } = getLinearDimensionGeometries(\n dimension,\n dimensionStyle,\n (c) => getLinearDimensionTextPosition(c, dimensionStyle.margin, getTextSize)\n )\n const { textPosition, textRotation, text } = getLinearDimensionTextPosition(dimension, dimensionStyle.margin, getTextSize)\n return (\n \n {lines.map((line, i) => `${p.x},${p.y}`).join(' ')} />)}\n {regions[0] && `${p.x},${p.y}`).join(' ')} fill='black' />}\n {regions[1] && `${p.x},${p.y}`).join(' ')} fill='black' />}\n {text}\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"menu.story",name:"",Component:z.default,code:"() => {\n return (\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"minimap.story",name:"",Component:F.default,code:"() => {\n const { ref: scrollRef, x, setX, y, setY } = useWheelScroll()\n const { ref: zoomRef, scale } = useWheelZoom({\n onChange(oldScale, newScale, cursor) {\n const result = scaleByCursorPosition({ width, height }, newScale / oldScale, cursor)\n setX(result.setX)\n setY(result.setY)\n }\n })\n const target = reactSvgRenderTarget\n const minimapWidth = 100, minimapHeight = 100\n const size = useWindowSize()\n const width = size.width / 2, height = size.height / 2\n const contentWidth = 1200, contentHeight = 800\n const transform: Transform = {\n x,\n y,\n scale,\n center: {\n x: width / 2,\n y: height / 2,\n },\n }\n const children = [target.renderImage('https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg', 0, 0, contentWidth, contentHeight)]\n const { setMinimapTransform, minimap, getMinimapPosition } = useMinimap({\n width: minimapWidth,\n height: minimapHeight,\n viewport: {\n width: width / transform.scale,\n height: height / transform.scale,\n center: reverseTransformPosition(transform.center, transform),\n },\n children(minimapTransform) {\n return target.renderResult(children, minimapWidth, minimapHeight, {\n transform: minimapTransform, attributes: {\n onClick: e => {\n if (getMinimapPosition) {\n const p = getMinimapPosition(e)\n setX((transform.center.x - p.x) * transform.scale)\n setY((transform.center.y - p.y) * transform.scale)\n }\n }\n }\n })\n },\n })\n React.useEffect(() => {\n const bounding = {\n start: { x: 0, y: 0 },\n end: { x: contentWidth, y: contentHeight },\n }\n const result = zoomToFit(bounding, { width: minimapWidth, height: minimapHeight }, { x: minimapWidth / 2, y: minimapHeight / 2 }, 1)\n if (result) {\n setMinimapTransform({\n bounding,\n ...result,\n })\n }\n }, [])\n return (\n
\n {target.renderResult(children, width, height, { transform, attributes: { style: { border: '1px solid green' } } })}\n {minimap}\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"opentype.story",name:"",Component:N.default,code:"() => {\n const size = useWindowSize()\n const width = size.width / 2\n const height = 300\n const { x, y, ref: wheelScrollRef, setX, setY } = useWheelScroll()\n const { scale, setScale, ref: wheelZoomRef } = useWheelZoom({\n onChange(oldScale, newScale, cursor) {\n const result = scaleByCursorPosition({ width, height }, newScale / oldScale, cursor)\n setX(result.setX)\n setY(result.setY)\n }\n })\n const [fonts, setFonts] = React.useState>()\n const [text, setText] = React.useState('测试ABC')\n const [fontFamily, setFontFamily] = React.useState(allFonts[0].name)\n const [fontSize, setFontSize] = React.useState(50)\n const [color, setColor] = React.useState(0x000000)\n const [backgroundColor, setBackgroundColor] = React.useState(0xffffff)\n const [xScale, setXScale] = React.useState(1)\n const [yScale, setYScale] = React.useState(1)\n const [commands, setCommands] = React.useState([])\n const [target, setTarget] = React.useState>(allRenderTargets[0])\n const font = fonts?.[fontFamily]\n\n React.useEffect(() => {\n const fetchFonts = async () => {\n const result: Record = {}\n for (const f of allFonts) {\n const res = await fetch(f.url)\n const buffer = await res.arrayBuffer()\n result[f.name] = opentype.parse(buffer)\n }\n setFonts(result)\n }\n fetchFonts()\n }, [])\n useGlobalKeyDown(e => {\n if (e.code === 'Digit0' && !e.shiftKey && metaKeyIfMacElseCtrlKey(e)) {\n setScale(1)\n setX(0)\n setY(0)\n e.preventDefault()\n }\n })\n\n React.useEffect(() => {\n if (!font) return\n const paths = font.getPaths(text, 0, fontSize, fontSize, { xScale: xScale * fontSize / font.unitsPerEm, yScale: yScale * fontSize / font.unitsPerEm })\n const commands = paths.map(path => opentypeCommandsToPathCommands(path))\n setCommands(commands)\n }, [text, font, fontSize, target, xScale, yScale])\n\n const children = commands.map(c => target.renderPathCommands(c, { fillColor: color, strokeColor: color })).flat()\n children.push(target.renderText(0, fontSize * 2, text, color, fontSize * Math.max(xScale, yScale), fontFamily))\n return (\n
\n {target.renderResult(children, width, height, { transform: { x, y, scale }, backgroundColor })}\n
\n setText(v)} />,\n 'font family': t.name)} setValue={v => setFontFamily(allFonts.find(t => t.name === v)?.name ?? allFonts[0].name)} />,\n 'font size': setFontSize(v)} />,\n 'render target': t.type)} setValue={v => setTarget(allRenderTargets.find(t => t.type === v) ?? allRenderTargets[0])} />,\n color: setColor(v)} />,\n 'background color': setBackgroundColor(v)} />,\n 'x scale': setXScale(v)} />,\n 'y scale': setYScale(v)} />,\n actions: ,\n }}\n />\n
\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"partial-edit.story",name:"",Component:U.default,code:"() => {\n interface Content {\n value: number\n children?: Content[]\n }\n const [content, setContent] = React.useState({\n value: 1,\n children: [\n { value: 10 },\n { value: 100 }\n ]\n })\n const { editingContent, setEditingContentPath, prependPatchPath } = usePartialEdit(content)\n const addOne = () => {\n const [, patches] = produceWithPatches(editingContent, (draft) => {\n draft.value++\n })\n setContent(applyPatches(content, prependPatchPath(patches)))\n }\n\n return (\n <>\n \n \n
\n {editingContent.value}\n {editingContent.children && editingContent.children.map((c, i) => (\n \n ))}\n
\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"patch-based-undo-redo.story",name:"",Component:G.default,code:"() => {\n const { state, setState, undo, redo } = usePatchBasedUndoRedo(initialState, 'a')\n useGlobalKeyDown(e => {\n if (e.code === 'KeyZ' && metaKeyIfMacElseCtrlKey(e)) {\n if (e.shiftKey) {\n redo(e)\n } else {\n undo(e)\n }\n }\n })\n return (\n setState((draft) => { draft.count++ })}\n style={{ width: '200px', height: '100px' }}\n >\n {state.count}\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"path-click-create.story",name:"",Component:j.default,code:"() => {\n const [contents, setContents] = React.useState([])\n const { preview, onClick, onMove, input, setInputType, reset } = usePathClickCreate(true, (c) => {\n setContents(produce(contents, (draft) => {\n draft.push(c)\n }))\n })\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n reset(true)\n }\n })\n\n return (\n
\n onClick({ x: e.clientX, y: e.clientY })}\n onMouseMove={(e) => onMove({ x: e.clientX, y: e.clientY })}\n >\n {[...contents, preview].map((content, i) => content && reactSvgRenderTarget.renderPathCommands(content, { strokeColor: 0x00ff00 })(i, 1, false, 800, 600))}\n \n {(['line', 'arc', 'bezierCurve', 'quadraticCurve', 'close'] as const).map(m => )}\n {input}\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"pen-click-create.story",name:"",Component:V.default,code:"() => {\n const [contents, setContents] = React.useState([])\n const { points, onClick, onMove, reset } = usePenClickCreate(true, () => {\n setContents(produce(contents, (draft) => {\n draft.push(points)\n }))\n })\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n reset()\n }\n })\n\n return (\n
\n onClick({ x: e.clientX, y: e.clientY })}\n onMouseMove={(e) => onMove({ x: e.clientX, y: e.clientY })}\n >\n {[...contents, points].map((content, i) => content && `${p.x},${p.y}`).join(' ')}\n />)}\n \n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"pendulum.story",name:"",Component:W.default,code:"() => {\n const size = useWindowSize()\n const width = size.width / 2\n const height = size.height\n const target = reactCanvasRenderTarget\n const center = { x: width / 2, y: height / 3 }\n const [length, setLength] = React.useState(width / 2)\n const [editing, setEditing] = React.useState(false)\n const [state, setState] = React.useState({ radian: -Math.PI / 4, speed: 0 })\n const [editingState, setEditingState] = React.useState<(typeof state) & { length: number }>()\n const [running, setRunning, runningRef] = useRefState(false)\n const [runningState, setRunningState, runningStateRef] = useRefState2()\n const currentState = runningState ?? editingState ?? state\n const currentLength = editingState?.length ?? length\n const position = {\n x: center.x - currentLength * Math.sin(currentState.radian),\n y: center.y + currentLength * Math.cos(currentState.radian),\n r: 10,\n }\n const p = getPointByLengthAndRadian(position, currentState.speed * currentLength + position.r * (currentState.speed >= 0 ? 1 : -1), getTwoPointsRadian(position, center) + Math.PI / 2)\n const children = [\n target.renderCircle(center.x, center.y, 5),\n target.renderCircle(position.x, position.y, position.r, { fillColor: 0x000000, strokeWidth: 0 }),\n target.renderPolyline([center, position]),\n target.renderPolyline([position, p])\n ]\n\n const stop = () => {\n setRunning(false)\n setRunningState(undefined)\n }\n const run = () => {\n if (runningRef.current) {\n setRunning(false)\n return\n }\n setRunning(true)\n let lastTime: number | undefined\n const step = (time: number) => {\n if (!runningRef.current) return\n if (lastTime !== undefined) {\n const t = (time - lastTime) * 0.005\n const current = runningStateRef.current ?? state\n const initialY = center.y + currentLength * Math.cos(state.radian)\n const y = center.y + currentLength * Math.cos(current.radian)\n const g = 9.8\n let newSpeed = current.speed - g * Math.sin(current.radian) / currentLength * t\n if (y !== initialY) {\n const newSpeed2 = Math.sqrt(g * Math.abs(y - initialY) * 2) / currentLength\n if (newSpeed2 < Math.abs(newSpeed)) {\n newSpeed = Math.sign(newSpeed) * newSpeed2\n }\n }\n setRunningState({ radian: current.radian + current.speed * t, speed: newSpeed })\n }\n lastTime = time\n requestAnimationFrame(step)\n }\n requestAnimationFrame(step)\n }\n const onClick = useEvent(() => {\n if (editingState) {\n setState(editingState)\n setLength(editingState.length)\n setEditing(false)\n setEditingState(undefined)\n }\n })\n const onMouseMove = useEvent((e: React.MouseEvent) => {\n if (editing) {\n const p = { x: e.clientX, y: e.clientY }\n setEditingState({\n radian: getTwoPointsRadian(p, center) - Math.PI / 2,\n speed: 0,\n length: getTwoPointsDistance(p, center),\n })\n }\n })\n\n return (\n
\n {target.renderResult(children, width, height, { attributes: { onClick } })}\n
\n \n {runningState !== undefined && }\n {runningState === undefined && }\n
\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"pie-chart.story",name:"",Component:H.default,code:"() => {\n const size = useWindowSize()\n const width = size.width / 2\n const height = 350\n const target = reactSvgRenderTarget\n const [hovering, setHovering] = React.useState()\n const [hovering2, setHovering2] = React.useState()\n const [result, setResult] = React.useState<{ children: SvgDraw[], select: (p: Position) => Position & { value: { x: number, y: number } } | undefined }>()\n const [result2, setResult2] = React.useState<{ children: SvgDraw[], select: (p: Position) => Position & { value: { x: number, y: number } } | undefined }>()\n const getXLabel = (x: number) => Intl.DateTimeFormat('zh', { month: 'long' }).format(new Date(x.toString()))\n\n React.useEffect(() => {\n const datas = [\n [65, 59, 80, 81, 56, 55, 40],\n [75, 49, 70, 71, 46, 45, 30],\n [85, 39, 60, 61, 36, 35, 20],\n ]\n const colors = [0xff0000, 0x00ff00, 0x0000ff, 0xff0000, 0x00ff00, 0x0000ff, 0x000000]\n setResult(getPieChart(datas, colors, target, { width, height }, { left: 10, right: 10, top: 10, bottom: 10 }))\n setResult2(getPieChart(datas, colors, target, { width, height }, { left: 10, right: 10, top: 10, bottom: 10 }, { type: 'doughnut' }))\n }, [width])\n\n if (!result || !result2) {\n return null\n }\n let children = result.children\n if (hovering) {\n children = [\n ...result.children,\n ...renderChartTooltip(target, hovering, hovering.value, { getXLabel }),\n ]\n }\n let children2 = result2.children\n if (hovering2) {\n children2 = [\n ...result2.children,\n ...renderChartTooltip(target, hovering2, hovering2.value, { getXLabel }),\n ]\n }\n return (\n
\n {target.renderResult(children, width, height, { attributes: { onMouseMove: e => setHovering(result.select({ x: e.clientX, y: e.clientY })) } })}\n {target.renderResult(children2, width, height, { attributes: { onMouseMove: e => setHovering2(result2.select({ x: e.clientX, y: e.clientY - height })) } })}\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"point-snap.story",name:"",Component:q.default,code:"() => {\n const [position, setPosition] = React.useState()\n const { width, height } = useWindowSize()\n const startPosition = { x: 500, y: 100 }\n const gridSize = 20\n const { getSnapAssistentContents, getSnapPoint } = usePointSnap(\n true,\n (c1, c2) => intersectionPointsCache.get(c1, c2, () => Array.from(iterateIntersectionPoints(c1, c2, contents, () => ({ getGeometries: (c) => ({ lines: [{ type: 'arc', curve: circleToArc(c) }] }) })))),\n allSnapTypes,\n () => ({\n getSnapPoints(c) {\n return [\n { x: c.x, y: c.y, type: 'center' },\n { x: c.x - c.r, y: c.y, type: 'endpoint' },\n { x: c.x + c.r, y: c.y, type: 'endpoint' },\n { x: c.x, y: c.y - c.r, type: 'endpoint' },\n { x: c.x, y: c.y + c.r, type: 'endpoint' },\n ]\n },\n getGeometries(c) {\n return {\n lines: [{ type: 'arc', curve: circleToArc(c) }],\n bounding: {\n start: { x: c.x - c.r, y: c.y - c.r },\n end: { x: c.x + c.r, y: c.y + c.r },\n }\n }\n },\n }),\n undefined, undefined,\n p => ({ x: formatNumber(p.x, 1 / gridSize), y: formatNumber(p.y, 1 / gridSize) }),\n )\n const assistentContents = getSnapAssistentContents(\n (circle) => ({ type: 'circle' as const, ...circle }),\n (rect) => ({ type: 'rect' as const, ...rect }),\n (points) => ({ type: 'polyline' as const, points }),\n (ray) => ({ type: 'ray' as const, ...ray }),\n )\n const lines = getGridLines({ start: { x: 0, y: 0 }, end: { x: width / 2, y: height } }, gridSize)\n return (\n <>\n setPosition(getSnapPoint({ x: e.clientX, y: e.clientY }, contents, undefined, startPosition).position)}\n >\n {contents.map((c, i) => )}\n {lines.map((c, i) => `${p.x},${p.y}`).join(' ')} stroke=\"black\" strokeOpacity='0.2' />)}\n {position && }\n {assistentContents.map((c, i) => {\n if (c.type === 'rect') {\n return \n }\n if (c.type === 'circle') {\n return \n }\n if (c.type === 'ray') {\n return null\n }\n return `${p.x},${p.y}`).join(' ')} stroke='#00ff00' />\n })}\n {position && }\n \n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"polar-area-chart.story",name:"",Component:$.default,code:"() => {\n const size = useWindowSize()\n const width = size.width / 2\n const height = 350\n const target = reactSvgRenderTarget\n const [hovering, setHovering] = React.useState()\n const [result, setResult] = React.useState<{ children: SvgDraw[], select: (p: Position) => Position & { value: { x: number, y: number } } | undefined }>()\n const getXLabel = (x: number) => Intl.DateTimeFormat('zh', { month: 'long' }).format(new Date((x + 1).toString()))\n\n React.useEffect(() => {\n const datas = [65, 59, 80, 81, 56, 55, 40]\n const colors = [0xff0000, 0x00ff00, 0x0000ff, 0xff0000, 0x00ff00, 0x0000ff, 0x000000]\n const r = getPolarAreaChart(datas, colors, target, { width, height }, 10, { left: 10, right: 10, top: 30, bottom: 10 })\n r.angles.forEach((angle, i) => {\n const p = getArcPointAtAngle({ ...r.circle, r: r.circle.r + 30 }, angle)\n r.children.push(target.renderText(p.x, p.y, getXLabel(i), 0xcccccc, 20, 'monospace', { textAlign: 'center', textBaseline: 'middle' }))\n })\n setResult(r)\n }, [width])\n\n if (!result) {\n return null\n }\n let children = result.children\n if (hovering) {\n children = [\n ...result.children,\n ...renderChartTooltip(target, hovering, hovering.value, { getXLabel }),\n ]\n }\n return (\n
\n {target.renderResult(children, width, height, { attributes: { onMouseMove: e => setHovering(result.select({ x: e.clientX, y: e.clientY })) } })}\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"polygon-click-create.story",name:"",Component:X.default,code:"() => {\n const [contents, setContents] = React.useState([])\n const { polygon, onClick, onMove, input, reset } = usePolygonClickCreate(true, (c) => {\n const data = c || polygon\n if (data) {\n setContents(produce(contents, (draft) => {\n draft.push(data)\n }))\n }\n })\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n reset()\n }\n })\n\n return (\n
\n onClick({ x: e.clientX, y: e.clientY })}\n onMouseMove={(e) => onMove({ x: e.clientX, y: e.clientY })}\n >\n {[...contents, polygon].map((content, i) => content && `${p.x},${p.y}`).join(' ')} />\n )}\n \n {input}\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"polyline-edit.story",name:"",Component:Y.default,code:"() => {\n const [content, setContent] = React.useState([\n { x: 100, y: 100 },\n { x: 300, y: 200 },\n { x: 100, y: 200 },\n ])\n const { offset, onStart, mask, reset } = usePolylineEdit(() => setContent(points))\n const points = produce(content, (draft) => {\n if (offset) {\n for (const pointIndex of offset.pointIndexes) {\n draft[pointIndex].x += offset.x\n draft[pointIndex].y += offset.y\n }\n }\n })\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n reset()\n }\n })\n return (\n <>\n \n `${p.x},${p.y}`).join(' ')} />\n \n onStart(e, pointIndexes)}\n />\n {mask}\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"radar-chart.story",name:"",Component:K.default,code:"() => {\n const size = useWindowSize()\n const width = size.width / 2\n const height = 350\n const target = reactSvgRenderTarget\n const [hovering, setHovering] = React.useState()\n const [result, setResult] = React.useState<{ children: SvgDraw[], select: (p: Position) => Position & { value: { x: number, y: number } } | undefined }>()\n const getXLabel = (x: number) => Intl.DateTimeFormat('zh', { month: 'long' }).format(new Date((x + 1).toString()))\n\n React.useEffect(() => {\n const datas = [\n [65, 59, 80, 81, 56, 55, 40],\n [45, 39, 60, 61, 36, 35, 20],\n ]\n const colors = [0xff0000, 0x00ff00]\n const r = getRadarChart(datas, colors, target, { width, height }, 20, { left: 10, right: 10, top: 30, bottom: 30 })\n r.angles.forEach((angle, i) => {\n const p = getArcPointAtAngle({ ...r.circle, r: r.circle.r + 15 }, angle)\n r.children.push(target.renderText(p.x, p.y, getXLabel(i), 0xcccccc, 12, 'monospace', { textAlign: 'center', textBaseline: 'middle' }))\n })\n setResult(r)\n }, [width])\n\n if (!result) {\n return null\n }\n let children = result.children\n if (hovering) {\n children = [\n ...result.children,\n ...renderChartTooltip(target, hovering, hovering.value, { getXLabel }),\n ]\n }\n return (\n
\n {target.renderResult(children, width, height, { attributes: { onMouseMove: e => setHovering(result.select({ x: e.clientX, y: e.clientY })) } })}\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"radial-dimension.story",name:"",Component:Z.default,code:"() => {\n const circle: Circle = {\n x: 200,\n y: 200,\n r: 100,\n }\n const dimension: RadialDimension = {\n position: {\n x: 400,\n y: 300,\n },\n fontFamily: 'monospace',\n fontSize: 16,\n }\n const { regions, lines } = getRadialDimensionGeometries(\n dimension,\n circle,\n dimensionStyle,\n (d, c) => getRadialDimensionTextPosition(d, c, dimensionStyle.margin, getTextSize)\n )\n const { textPosition, textRotation, text } = getRadialDimensionTextPosition(dimension, circle, dimensionStyle.margin, getTextSize)\n return (\n \n \n {lines.map((line, i) => `${p.x},${p.y}`).join(' ')} />)}\n {regions && regions.length > 0 && `${p.x},${p.y}`).join(' ')} fill='black' />}\n {text}\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"react-composable-json-editor.story",name:"",Component:Q.default,code:"() => {\n const [readOnly, setReadOnly] = React.useState(false)\n const { value, update, getArrayProps } = useJsonEditorData({\n stringExample: 'a string example',\n booleanExample: false,\n numberExample: 123.4,\n objectExample: {\n propertyExample1: '',\n propertyExample2: 0,\n },\n inlineObjectExample: {\n propertyExample1: '',\n propertyExample2: 0,\n },\n arrayExample: ['item1', 'item2'],\n inlineArrayExample: ['item1', 'item2'],\n optionalExample: undefined as string | undefined,\n enumExample: 'enum 1' as 'enum 1' | 'enum 2',\n colorExample: '#000000',\n textareaExample: '',\n imagePreviewExample: 'http://image2.sina.com.cn/bj/art/2004-08-02/U91P52T4D51657F160DT20040802125523.jpg',\n itemTitleExample: [\n {\n propertyExample1: 'foo',\n propertyExample2: 1,\n },\n {\n propertyExample1: 'bar',\n propertyExample2: 2,\n },\n ],\n inlineObjectArrayExample: [\n {\n propertyExample1: 'foo',\n propertyExample2: 1,\n propertyExample3: {\n propertyExample4: 2,\n propertyExample5: '',\n },\n },\n {\n propertyExample1: 'bar',\n propertyExample2: 2,\n propertyExample3: {\n propertyExample4: 3,\n propertyExample5: '',\n },\n },\n ],\n enumTitlesExample: 'enum 1' as 'enum 1' | 'enum 2',\n enumArrayExample: ['foo'] as ('foo' | 'bar')[],\n })\n const valueHtml = JSON.stringify(value, null, ' ')\n return (\n
\n setReadOnly(v)} /> read only\n
\n
\n draft.stringExample = v)} />,\n 'A boolean example': draft.booleanExample = v)} />,\n 'A number example': draft.numberExample = v)} />,\n 'A object example': draft.objectExample.propertyExample1 = v)} />,\n 'Property example 2': draft.objectExample.propertyExample2 = v)} />,\n }}\n />,\n 'A inline object example': draft.inlineObjectExample.propertyExample1 = v)} />,\n 'Property example 2': draft.inlineObjectExample.propertyExample2 = v)} />,\n }}\n />,\n 'A array example': v.arrayExample, '')}\n items={value.arrayExample.map((f, i) => draft.arrayExample[i] = v)} />)}\n />,\n 'A inline array example': v.inlineArrayExample, '')}\n items={value.inlineArrayExample.map((f, i) => draft.inlineArrayExample[i] = v)} />)}\n />,\n 'A optional example': [\n draft.optionalExample = v ? '' : undefined)} />,\n value.optionalExample !== undefined ? draft.optionalExample = v)} /> : undefined,\n ],\n 'A enum example': draft.enumExample = v)} />,\n 'A enum example 2': draft.enumExample = v)} />,\n 'A color example': draft.colorExample = v)} />,\n 'A textarea example': draft.textareaExample = v)} />,\n 'A image preview example': draft.imagePreviewExample = v)} />,\n 'A item title example': v.itemTitleExample, { propertyExample1: '', propertyExample2: 0 })}\n title={(i) => value.itemTitleExample[i].propertyExample1}\n items={value.itemTitleExample.map((f, i) => draft.itemTitleExample[i].propertyExample1 = v)} />,\n 'Property example 2': draft.itemTitleExample[i].propertyExample2 = v)} />,\n }}\n />)}\n />,\n 'A inline object array example': v.inlineObjectArrayExample, { propertyExample1: '', propertyExample2: 0, propertyExample3: { propertyExample4: 0, propertyExample5: '' } })}\n properties={value.inlineObjectArrayExample.map((f, i) => ({\n 'Property example 1': draft.inlineObjectArrayExample[i].propertyExample1 = v)} />,\n 'Property example 2': draft.inlineObjectArrayExample[i].propertyExample2 = v)} />,\n 'Property example 3': draft.inlineObjectArrayExample[i].propertyExample3.propertyExample4 = v)} />,\n 'Property example 4': draft.inlineObjectArrayExample[i].propertyExample3.propertyExample5 = v)} />,\n }}\n />,\n }))}\n />,\n 'A enum titles example': draft.enumTitlesExample = v)} />,\n 'A enum array example': draft.enumArrayExample = v)} />,\n }}\n readOnly={readOnly}\n />\n
\n
\n
\n
\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"react-render-target.story",name:"",Component:J.default,code:"() => {\n const renderArcs = (target: ReactRenderTarget) => target.renderResult([\n target.renderArc(40, 20, 50, 0, 120, { fillPattern: { width: 10, height: 10, pattern: () => target.renderPath([[{ x: 0, y: 5 }, { x: 5, y: 0 }], [{ x: 10, y: 5 }, { x: 5, y: 10 }]], { strokeColor: 0x0000ff }) } }),\n target.renderArc(40, 40, 80, 0, 120, { fillColor: 0xff0000, strokeWidth: 0 }),\n target.renderArc(50, 50, 100, 0, 120, { strokeColor: 0x00ff00 }),\n target.renderArc(60, 60, 100, 0, 120, { strokeWidth: 5 }),\n target.renderArc(70, 70, 100, 0, 120, { dashArray: [4] }),\n target.renderArc(170, 170, 30, 0, 120, { counterclockwise: true }),\n target.renderArc(170, 170, 20, 120, 0, { counterclockwise: true }),\n target.renderArc(120, 200, 15, 0, 360,),\n target.renderArc(120, 200, 10, 360, 0, { counterclockwise: true }),\n target.renderArc(170, 170, 10, 0, 120, { closed: true }),\n ], 230, 310)\n\n const renderCircles = (target: ReactRenderTarget) => target.renderResult([\n target.renderCircle(70, 100, 30, { fillPattern: { width: 10, height: 10, pattern: () => target.renderPath([[{ x: 0, y: 5 }, { x: 5, y: 0 }], [{ x: 10, y: 5 }, { x: 5, y: 10 }]], { strokeColor: 0x0000ff }) } }),\n target.renderCircle(150, 100, 30, { fillColor: 0xff0000, strokeWidth: 0 }),\n target.renderCircle(110, 100, 70, { strokeColor: 0x00ff00 }),\n target.renderCircle(110, 100, 80, { strokeWidth: 5 }),\n target.renderCircle(110, 100, 90, { dashArray: [4] }),\n ], 230, 200)\n\n const renderTexts = (target: ReactRenderTarget) => target.renderResult([\n target.renderText(10, 30, 'Hello World!', 0xff0000, 30, 'monospace'),\n target.renderText(10, 60, 'Hello World!', 0xff0000, 30, 'monospace', { fontWeight: 'bold' }),\n target.renderText(10, 90, 'Hello World!', 0xff0000, 30, 'monospace', { fontStyle: 'italic' }),\n target.renderText(10, 150, 'He', { width: 4, height: 4, pattern: () => target.renderPath([[{ x: 0, y: 2 }, { x: 2, y: 0 }], [{ x: 4, y: 2 }, { x: 2, y: 4 }]], { strokeColor: 0x0000ff }) }, 70, 'monospace'),\n target.renderText(90, 150, 'l', undefined, 70, 'monospace', { strokeColor: 0xff0000 }),\n target.renderText(130, 150, 'l', undefined, 70, 'monospace', { strokeColor: 0xff0000, dashArray: [2] }),\n target.renderText(170, 150, 'l', undefined, 70, 'monospace', { strokeColor: 0xff0000, strokeWidth: 3 }),\n target.renderText(10, 200, 'H', 0x00ff00, 70, 'monospace', { strokeColor: 0xff0000, strokeWidth: 3 }),\n target.renderText(50, 200, 'H', 0x00ff00, 70, 'monospace', { strokeColor: 0xff0000, strokeWidth: 3, strokeOpacity: 0.3, fillOpacity: 0.3 }),\n target.renderText(90, 200, 'H', undefined, 70, 'monospace', { strokePattern: { width: 4, height: 4, pattern: () => target.renderPath([[{ x: 0, y: 2 }, { x: 2, y: 0 }], [{ x: 4, y: 2 }, { x: 2, y: 4 }]], { strokeColor: 0x0000ff }) }, strokeWidth: 3 }),\n target.renderText(130, 200, 'H', undefined, 70, 'monospace', { strokeLinearGradient: { start: { x: 150, y: 230 }, end: { x: 190, y: 150 }, stops: [{ offset: 0.2, color: 0xff0000 }, { offset: 0.5, color: 0xffff00 }, { offset: 0.8, color: 0x00ff00 }] }, strokeWidth: 3 }),\n target.renderText(170, 200, 'H', undefined, 70, 'monospace', { strokeRadialGradient: { start: { x: 190, y: 185, r: 5 }, end: { x: 190, y: 180, r: 30 }, stops: [{ offset: 0, color: 0xff0000 }, { offset: 0.5, color: 0xffff00 }, { offset: 1, color: 0x00ff00 }] }, strokeWidth: 3 }),\n target.renderText(70, 225, 'center', 0x00ff00, 30, 'monospace', { textAlign: 'center' }),\n target.renderText(130, 250, 'right', 0x00ff00, 30, 'monospace', { textAlign: 'right' }),\n target.renderText(130, 250, 'H', undefined, 70, 'monospace', { fillLinearGradient: { start: { x: 150, y: 280 }, end: { x: 190, y: 200 }, stops: [{ offset: 0.2, color: 0xff0000 }, { offset: 0.5, color: 0xffff00 }, { offset: 0.8, color: 0x00ff00 }] }, strokeWidth: 3 }),\n target.renderText(170, 250, 'H', undefined, 70, 'monospace', { fillRadialGradient: { start: { x: 190, y: 235, r: 5 }, end: { x: 190, y: 230, r: 30 }, stops: [{ offset: 0, color: 0xff0000 }, { offset: 0.5, color: 0xffff00 }, { offset: 1, color: 0x00ff00 }] }, strokeWidth: 3 }),\n target.renderText(10, 300, 'fgj', 0x00ff00, 30, 'monospace', { textBaseline: 'alphabetic' }),\n target.renderText(65, 300, 'fgj', 0x00ff00, 30, 'monospace', { textBaseline: 'top' }),\n target.renderText(120, 300, 'fgj', 0x00ff00, 30, 'monospace', { textBaseline: 'middle' }),\n target.renderText(175, 300, 'fgj', 0x00ff00, 30, 'monospace', { textBaseline: 'bottom' }),\n ], 230, 550)\n\n const renderEllipseArcs = (target: ReactRenderTarget) => target.renderResult([\n target.renderEllipseArc(40, 10, 50, 30, 0, 120, { fillPattern: { width: 10, height: 10, pattern: () => target.renderPath([[{ x: 0, y: 5 }, { x: 5, y: 0 }], [{ x: 10, y: 5 }, { x: 5, y: 10 }]], { strokeColor: 0x0000ff }) } }),\n target.renderEllipseArc(40, 30, 80, 40, 0, 120, { fillColor: 0xff0000, strokeWidth: 0 }),\n target.renderEllipseArc(50, 40, 100, 50, 0, 120, { strokeColor: 0x00ff00 }),\n target.renderEllipseArc(60, 50, 100, 50, 0, 120, { strokeWidth: 5 }),\n target.renderEllipseArc(70, 60, 100, 50, 0, 120, { dashArray: [4] }),\n target.renderEllipseArc(170, 160, 30, 15, 0, 120, { counterclockwise: true }),\n target.renderEllipseArc(170, 160, 30, 25, 120, 20, { counterclockwise: true }),\n target.renderEllipseArc(110, 100, 80, 40, 0, 120, { strokeColor: 0x00ff00, angle: 30 }),\n target.renderEllipseArc(120, 200, 30, 15, 0, 360,),\n target.renderEllipseArc(120, 200, 20, 10, 360, 0, { counterclockwise: true }),\n target.renderEllipseArc(170, 160, 25, 20, 0, 120, { closed: true }),\n ], 230, 330)\n\n const renderEllipses = (target: ReactRenderTarget) => target.renderResult([\n target.renderEllipse(70, 60, 40, 20, { fillPattern: { width: 10, height: 10, pattern: () => target.renderPath([[{ x: 0, y: 5 }, { x: 5, y: 0 }], [{ x: 10, y: 5 }, { x: 5, y: 10 }]], { strokeColor: 0x0000ff }) } }),\n target.renderEllipse(150, 60, 40, 20, { fillColor: 0xff0000, strokeWidth: 0 }),\n target.renderEllipse(110, 60, 90, 45, { strokeColor: 0x00ff00 }),\n target.renderEllipse(110, 60, 100, 50, { strokeWidth: 5 }),\n target.renderEllipse(110, 60, 110, 55, { dashArray: [4] }),\n target.renderEllipse(110, 140, 80, 40, { strokeColor: 0x0000ff, angle: 30 }),\n target.renderEllipse(110, 30, 10, 20, { angle: 60, fillPattern: { width: 10, height: 10, pattern: () => target.renderPath([[{ x: 0, y: 5 }, { x: 5, y: 0 }], [{ x: 10, y: 5 }, { x: 5, y: 10 }]], { strokeColor: 0x0000ff }) } }),\n ], 230, 230)\n\n const renderRects = (target: ReactRenderTarget) => target.renderResult([\n target.renderRect(10, 10, 50, 30, { fillPattern: { width: 10, height: 10, pattern: () => target.renderPath([[{ x: 0, y: 5 }, { x: 5, y: 0 }], [{ x: 10, y: 5 }, { x: 5, y: 10 }]], { strokeColor: 0x0000ff }) } }),\n target.renderRect(70, 10, 80, 40, { fillColor: 0xff0000, strokeWidth: 0 }),\n target.renderRect(90, 60, 100, 140, { strokeColor: 0x00ff00 }),\n target.renderRect(100, 70, 80, 120, { strokeWidth: 5 }),\n target.renderRect(110, 80, 60, 100, { dashArray: [4] }),\n target.renderRect(10, 90, 60, 30, { angle: 60 }),\n ], 230, 220)\n\n const renderPaths = (target: ReactRenderTarget) => target.renderResult([\n target.renderPath([[{ x: 5, y: 10 }, { x: 45, y: 150 }, { x: 45, y: 10 }], [{ x: 25, y: 30 }, { x: 25, y: 70 }, { x: 35, y: 70 }, { x: 35, y: 30 }]], { fillPattern: { width: 10, height: 10, pattern: () => target.renderPath([[{ x: 0, y: 5 }, { x: 5, y: 0 }], [{ x: 10, y: 5 }, { x: 5, y: 10 }]], { strokeColor: 0x0000ff }) }, strokeWidth: 0 }),\n target.renderPath([[{ x: 50, y: 10 }, { x: 90, y: 150 }, { x: 90, y: 10 }], [{ x: 70, y: 30 }, { x: 70, y: 70 }, { x: 80, y: 70 }, { x: 80, y: 30 }]], { fillColor: 0xff0000, strokeWidth: 0 }),\n target.renderPath([[{ x: 95, y: 10 }, { x: 135, y: 150 }, { x: 135, y: 10 }], [{ x: 115, y: 30 }, { x: 115, y: 70 }, { x: 125, y: 70 }, { x: 125, y: 30 }]], { strokeColor: 0x00ff00 }),\n target.renderPath([[{ x: 140, y: 10 }, { x: 180, y: 150 }, { x: 180, y: 10 }], [{ x: 160, y: 30 }, { x: 160, y: 70 }, { x: 170, y: 70 }, { x: 170, y: 30 }]], { fillPattern: { width: 100, height: 100, pattern: () => target.renderImage('https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg', 0, 0, 100, 100, { crossOrigin: '' }) }, strokeWidth: 0 }),\n target.renderPath([[{ x: 185, y: 10 }, { x: 225, y: 150 }, { x: 225, y: 10 }], [{ x: 205, y: 30 }, { x: 205, y: 70 }, { x: 215, y: 70 }, { x: 215, y: 30 }]], { dashArray: [4] }),\n target.renderPath([[{ x: 5, y: 160 }, { x: 35, y: 160 }, { x: 35, y: 190 }]], { strokeColor: 0xff0000, strokeWidth: 5 }),\n target.renderPath([[{ x: 45, y: 160 }, { x: 75, y: 160 }, { x: 75, y: 190 }]], { strokeColor: 0xff0000, strokeWidth: 5, closed: true }),\n target.renderPath([[{ x: 85, y: 160 }, { x: 125, y: 160 }, { x: 125, y: 190 }]], { strokeColor: 0xff0000, strokeWidth: 5, closed: true, miterLimit: 2 }),\n target.renderPath([[{ x: 135, y: 160 }, { x: 175, y: 160 }, { x: 175, y: 190 }]], { strokeColor: 0xff0000, strokeWidth: 10, lineJoin: 'bevel' }),\n target.renderPath([[{ x: 185, y: 160 }, { x: 225, y: 160 }, { x: 225, y: 190 }]], { strokeColor: 0xff0000, strokeWidth: 10, lineJoin: 'round' }),\n target.renderPath([[{ x: 10, y: 210 }, { x: 40, y: 210 }, { x: 40, y: 240 }]], { strokeColor: 0xff0000, strokeWidth: 10, lineCap: 'square' }),\n target.renderPath([[{ x: 55, y: 210 }, { x: 85, y: 210 }, { x: 85, y: 240 }]], { strokeColor: 0xff0000, strokeWidth: 10, lineCap: 'round' }),\n target.renderPath([[{ x: 100, y: 210 }, { x: 220, y: 210 }]], { dashArray: [12, 4] }),\n target.renderPath([[{ x: 100, y: 220 }, { x: 220, y: 220 }]], { dashArray: [12, 4], dashOffset: 4 }),\n target.renderPath([[{ x: 5, y: 250 }, { x: 45, y: 390 }, { x: 45, y: 250 }], [{ x: 25, y: 270 }, { x: 25, y: 310 }, { x: 35, y: 310 }, { x: 35, y: 270 }]], { fillLinearGradient: { start: { x: 5, y: 250 }, end: { x: 45, y: 390 }, stops: [{ offset: 0.2, color: 0xff0000 }, { offset: 0.5, color: 0xffff00 }, { offset: 0.8, color: 0x00ff00 }] }, strokeWidth: 0 }),\n target.renderPath([[{ x: 50, y: 250 }, { x: 90, y: 390 }, { x: 90, y: 250 }], [{ x: 70, y: 270 }, { x: 70, y: 310 }, { x: 80, y: 310 }, { x: 80, y: 270 }]], { fillRadialGradient: { start: { x: 70, y: 320, r: 10 }, end: { x: 70, y: 320, r: 70 }, stops: [{ offset: 0, color: 0xff0000 }, { offset: 0.5, color: 0xffff00 }, { offset: 1, color: 0x00ff00 }] }, strokeWidth: 0 }),\n target.renderPath([[{ x: 95, y: 250 }, { x: 135, y: 390 }, { x: 135, y: 250 }], [{ x: 115, y: 270 }, { x: 115, y: 310 }, { x: 125, y: 310 }, { x: 125, y: 270 }]], { fillColor: 0xff0000, fillOpacity: 0.3, strokeOpacity: 0.3 }),\n target.renderPath([[{ x: 140, y: 250 }, { x: 180, y: 390 }, { x: 180, y: 250 }], [{ x: 160, y: 270 }, { x: 160, y: 310 }, { x: 170, y: 310 }, { x: 170, y: 270 }]], { fillRadialGradient: { start: { x: 160, y: 320, r: 10 }, end: { x: 160, y: 320, r: 70 }, stops: [{ offset: 0, color: 0xff0000, opacity: 0.3 }, { offset: 0.5, color: 0xffff00, opacity: 0.3 }, { offset: 1, color: 0x00ff00, opacity: 0.3 }] }, strokeWidth: 0 }),\n target.renderPath([[{ x: 185, y: 250 }, { x: 225, y: 390 }, { x: 225, y: 250 }], [{ x: 205, y: 270 }, { x: 205, y: 310 }, { x: 215, y: 310 }, { x: 215, y: 270 }]], { strokePattern: { width: 10, height: 10, pattern: () => target.renderPath([[{ x: 0, y: 5 }, { x: 5, y: 0 }], [{ x: 10, y: 5 }, { x: 5, y: 10 }]], { strokeColor: 0x0000ff }) }, strokeWidth: 5 }),\n target.renderPath([[{ x: 5, y: 400 }, { x: 45, y: 540 }, { x: 45, y: 400 }], [{ x: 25, y: 420 }, { x: 25, y: 460 }, { x: 35, y: 460 }, { x: 35, y: 420 }]], { strokeLinearGradient: { start: { x: 5, y: 400 }, end: { x: 45, y: 540 }, stops: [{ offset: 0.2, color: 0xff0000 }, { offset: 0.5, color: 0xffff00 }, { offset: 0.8, color: 0x00ff00 }] }, strokeWidth: 5 }),\n target.renderPath([[{ x: 50, y: 400 }, { x: 90, y: 540 }, { x: 90, y: 400 }], [{ x: 70, y: 420 }, { x: 70, y: 460 }, { x: 80, y: 460 }, { x: 80, y: 420 }]], { strokeRadialGradient: { start: { x: 70, y: 470, r: 10 }, end: { x: 70, y: 470, r: 70 }, stops: [{ offset: 0, color: 0xff0000 }, { offset: 0.5, color: 0xffff00 }, { offset: 1, color: 0x00ff00 }] }, strokeWidth: 5 }),\n target.renderPath([[{ x: 110, y: 400 }, { x: 110, y: 470 }, { x: 110, y: 540 }]], { strokeColor: 0xff0000, strokeWidth: 10 }),\n target.renderPath([[{ x: 130, y: 400 }, { x: 130, y: 540 }, { x: 130, y: 470 }]], { strokeColor: 0xff0000, strokeWidth: 10 }),\n ], 230, 620)\n\n const renderImages = (target: ReactRenderTarget) => target.renderResult([\n target.renderImage('https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg', 0, 0, 75, 65, { crossOrigin: '' }),\n target.renderImage('https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg', 77, 0, 75, 65, { opacity: 0.5, crossOrigin: '' }),\n target.renderImage('https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg', 154, 0, 75, 65, { filters: [{ type: 'brightness', value: 2 }], crossOrigin: '' }),\n target.renderImage('https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg', 0, 70, 75, 65, { filters: [{ type: 'contrast', value: 2 }], crossOrigin: '' }),\n target.renderImage('https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg', 77, 70, 75, 65, { filters: [{ type: 'hue-rotate', value: 90 }], crossOrigin: '' }),\n target.renderImage('https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg', 154, 70, 75, 65, { filters: [{ type: 'saturate', value: 2 }], crossOrigin: '' }),\n target.renderImage('https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg', 0, 140, 75, 65, { filters: [{ type: 'saturate', value: 2 }, { type: 'hue-rotate', value: 90 }], crossOrigin: '' }),\n target.renderImage('https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg', 77, 140, 75, 65, { filters: [{ type: 'saturate', value: 2 }, { type: 'hue-rotate', value: 90 }, { type: 'contrast', value: 2 }], crossOrigin: '' }),\n target.renderImage('https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg', 154, 140, 75, 65, { filters: [{ type: 'grayscale', value: 1 }], crossOrigin: '' }),\n target.renderImage('https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg', 0, 210, 75, 65, { filters: [{ type: 'sepia', value: 1 }], crossOrigin: '' }),\n target.renderImage('https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg', 77, 210, 75, 65, { filters: [{ type: 'invert', value: 1 }], crossOrigin: '' }),\n target.renderImage('https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg', 154, 210, 75, 65, { filters: [{ type: 'opacity', value: 0.5 }], crossOrigin: '' }),\n target.renderImage('https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg', 0, 280, 75, 65, { filters: [{ type: 'blur', value: 2 }], crossOrigin: '' }),\n ], 230, 370)\n\n const renderPolylines = (target: ReactRenderTarget) => target.renderResult([\n target.renderPolyline([{ x: 5, y: 10 }, { x: 45, y: 150 }, { x: 45, y: 10 }], { fillPattern: { width: 10, height: 10, pattern: () => target.renderPath([[{ x: 0, y: 5 }, { x: 5, y: 0 }], [{ x: 10, y: 5 }, { x: 5, y: 10 }]], { strokeColor: 0x0000ff }) } }),\n target.renderPolyline([{ x: 50, y: 10 }, { x: 90, y: 150 }, { x: 90, y: 10 }], { fillColor: 0xff0000, strokeWidth: 0 }),\n target.renderPolyline([{ x: 95, y: 10 }, { x: 135, y: 150 }, { x: 135, y: 10 }], { strokeColor: 0x00ff00 }),\n target.renderPolyline([{ x: 140, y: 10 }, { x: 180, y: 150 }, { x: 180, y: 10 }], { strokeWidth: 5 }),\n target.renderPolyline([{ x: 185, y: 10 }, { x: 225, y: 150 }, { x: 225, y: 10 }], { dashArray: [4] }),\n target.renderPolyline([{ x: 195, y: 10 }, { x: 215, y: 80 }, { x: 215, y: 10 }], { closed: true }),\n ], 230, 220)\n\n const renderPolygons = (target: ReactRenderTarget) => target.renderResult([\n target.renderPolygon([{ x: 5, y: 10 }, { x: 45, y: 150 }, { x: 45, y: 10 }], { fillPattern: { width: 10, height: 10, pattern: () => target.renderPath([[{ x: 0, y: 5 }, { x: 5, y: 0 }], [{ x: 10, y: 5 }, { x: 5, y: 10 }]], { strokeColor: 0x0000ff }) } }),\n target.renderPolygon([{ x: 50, y: 10 }, { x: 90, y: 150 }, { x: 90, y: 10 }], { fillColor: 0xff0000, strokeWidth: 0 }),\n target.renderPolygon([{ x: 95, y: 10 }, { x: 135, y: 150 }, { x: 135, y: 10 }], { strokeColor: 0x00ff00 }),\n target.renderPolygon([{ x: 140, y: 10 }, { x: 180, y: 150 }, { x: 180, y: 10 }], { strokeWidth: 5 }),\n target.renderPolygon([{ x: 185, y: 10 }, { x: 225, y: 150 }, { x: 225, y: 10 }], { dashArray: [4] }),\n ], 230, 190)\n\n const renderPathCommands = (target: ReactRenderTarget) => target.renderResult([\n target.renderPathCommands([{ type: 'move', to: { x: 220, y: 10 } }, { type: 'arc', from: { x: 220, y: 80 }, to: { x: 150, y: 10 }, radius: 20 }, { type: 'line', to: { x: 150, y: 10 } }, { type: 'quadraticCurve', cp: { x: 150, y: 90 }, to: { x: 110, y: 70 } }, { type: 'bezierCurve', cp1: { x: 70, y: 20 }, cp2: { x: 40, y: 80 }, to: { x: 10, y: 10 } }, { type: 'ellipseArc', rx: 30, ry: 20, angle: 0, largeArc: false, sweep: true, to: { x: 50, y: 30 } }], { strokeColor: 0x00ff00 }),\n target.renderPathCommands([{ type: 'move', to: { x: 210, y: 10 } }, { type: 'arc', from: { x: 210, y: 80 }, to: { x: 160, y: 10 }, radius: 20 }, { type: 'line', to: { x: 160, y: 10 } }], { closed: true }),\n ], 230, 120)\n\n const renderGroups = (target: ReactRenderTarget) => {\n const items = [\n target.renderCircle(50, 50, 20),\n target.renderCircle(50, 50, 35),\n target.renderText(0, 40, 'abc', 0xff0000, 30, 'monospace'),\n target.renderGroup([target.renderCircle(50, 50, 15),], { translate: { x: 20, y: 20 } })\n ]\n return target.renderResult([\n target.renderGroup(items, { opacity: 0.2, translate: { x: 10, y: 0 } }),\n target.renderRect(120, 10, 80, 80, { clip: () => target.renderGroup(items, { translate: { x: 100, y: 0 } }) }),\n target.renderCircle(180, 150, 50, { clip: () => target.renderGroup(items, { matrix: m3.multiply(m3.translation(150, 150), m3.scaling(0.7, 0.7)) }) }),\n target.renderPath([[{ x: 0, y: 200 }, { x: 120, y: 200 }, { x: 120, y: 300 }, { x: 0, y: 300 }, { x: 0, y: 200 }], [{ x: 55, y: 230 }, { x: 90, y: 220 }, { x: 90, y: 260 }, { x: 50, y: 260 }, { x: 55, y: 230 }]], { clip: () => target.renderGroup(items, { translate: { x: 10, y: 200 } }), strokeWidth: 0 }),\n target.renderPolygon([{ x: 55, y: 230 }, { x: 90, y: 220 }, { x: 90, y: 260 }, { x: 50, y: 260 }]),\n target.renderRect(30, 100, 80, 80, {\n clip: () => target.renderGroup([\n target.renderCircle(90, 50, 20, { fillPattern: { width: 10, height: 10, pattern: () => target.renderPath([[{ x: 0, y: 5 }, { x: 5, y: 0 }], [{ x: 10, y: 5 }, { x: 5, y: 10 }]], { strokeColor: 0x0000ff }) } }),\n target.renderCircle(30, 50, 20),\n ], { translate: { x: 10, y: 90 } })\n }),\n target.renderGroup(items, { translate: { x: 110, y: 200 }, base: { x: 50, y: 50 }, scale: { x: 0.6, y: 0.3 } }),\n ], 230, 550)\n }\n\n const renderRay = (target: ReactRenderTarget) => target.renderResult([\n target.renderRay(50, 50, 30),\n target.renderRay(80, 50, 30, { bidirectional: true }),\n target.renderGroup([\n target.renderRay(60, 60, 30),\n target.renderGroup([\n target.renderRay(60, 60, 30),\n ], { translate: { x: 0, y: -20 } })\n ], { translate: { x: -20, y: 0 } })\n ], 230, 90)\n\n const { setOffset } = React.useContext(OffsetXContext)\n React.useEffect(() => {\n if (navigator.gpu) {\n setOffset?.(230)\n }\n }, [setOffset])\n return (\n
\n
\n {reactSvgRenderTarget.type}\n {reactCanvasRenderTarget.type}\n {reactWebglRenderTarget.type}\n {navigator.gpu && {reactWebgpuRenderTarget.type}}\n
\n {renderArcs(reactSvgRenderTarget)}\n {renderArcs(reactCanvasRenderTarget)}\n {renderArcs(reactWebglRenderTarget)}\n {navigator.gpu && renderArcs(reactWebgpuRenderTarget)}\n
\n {renderCircles(reactSvgRenderTarget)}\n {renderCircles(reactCanvasRenderTarget)}\n {renderCircles(reactWebglRenderTarget)}\n {navigator.gpu && renderCircles(reactWebgpuRenderTarget)}\n
\n {renderTexts(reactSvgRenderTarget)}\n {renderTexts(reactCanvasRenderTarget)}\n {renderTexts(reactWebglRenderTarget)}\n {navigator.gpu && renderTexts(reactWebgpuRenderTarget)}\n
\n {renderEllipseArcs(reactSvgRenderTarget)}\n {renderEllipseArcs(reactCanvasRenderTarget)}\n {renderEllipseArcs(reactWebglRenderTarget)}\n {navigator.gpu && renderEllipseArcs(reactWebgpuRenderTarget)}\n
\n {renderEllipses(reactSvgRenderTarget)}\n {renderEllipses(reactCanvasRenderTarget)}\n {renderEllipses(reactWebglRenderTarget)}\n {navigator.gpu && renderEllipses(reactWebgpuRenderTarget)}\n
\n {renderRects(reactSvgRenderTarget)}\n {renderRects(reactCanvasRenderTarget)}\n {renderRects(reactWebglRenderTarget)}\n {navigator.gpu && renderRects(reactWebgpuRenderTarget)}\n
\n {renderPaths(reactSvgRenderTarget)}\n {renderPaths(reactCanvasRenderTarget)}\n {renderPaths(reactWebglRenderTarget)}\n {navigator.gpu && renderPaths(reactWebgpuRenderTarget)}\n
\n {renderImages(reactSvgRenderTarget)}\n {renderImages(reactCanvasRenderTarget)}\n {renderImages(reactWebglRenderTarget)}\n {navigator.gpu && renderImages(reactWebgpuRenderTarget)}\n
\n {renderPolylines(reactSvgRenderTarget)}\n {renderPolylines(reactCanvasRenderTarget)}\n {renderPolylines(reactWebglRenderTarget)}\n {navigator.gpu && renderPolylines(reactWebgpuRenderTarget)}\n
\n {renderPolygons(reactSvgRenderTarget)}\n {renderPolygons(reactCanvasRenderTarget)}\n {renderPolygons(reactWebglRenderTarget)}\n {navigator.gpu && renderPolygons(reactWebgpuRenderTarget)}\n
\n {renderPathCommands(reactSvgRenderTarget)}\n {renderPathCommands(reactCanvasRenderTarget)}\n {renderPathCommands(reactWebglRenderTarget)}\n {navigator.gpu && renderPathCommands(reactWebgpuRenderTarget)}\n
\n {renderGroups(reactSvgRenderTarget)}\n {renderGroups(reactCanvasRenderTarget)}\n {renderGroups(reactWebglRenderTarget)}\n {navigator.gpu && renderGroups(reactWebgpuRenderTarget)}\n
\n {renderRay(reactSvgRenderTarget)}\n {renderRay(reactCanvasRenderTarget)}\n {renderRay(reactWebglRenderTarget)}\n {navigator.gpu && renderRay(reactWebgpuRenderTarget)}\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"region-alignment-line.story",name:"",Component:ee.default,code:"() => {\n const [contents, setContents] = React.useState(defaultContents)\n const [selectedIndex, setSelectedIndex] = React.useState(0)\n\n const { regionAlignmentX, regionAlignmentY, changeOffsetByRegionAlignment, clearRegionAlignments } = useRegionAlignment(10)\n const { offset, onStart, mask, startPosition, resetDragMove } = useDragMove(\n () => {\n clearRegionAlignments()\n if (offset.x === 0 && offset.y === 0 && startPosition?.data !== undefined) {\n setSelectedIndex(startPosition.data)\n return\n }\n setContents(produce(contents, (draft) => {\n draft[selectedIndex].x += offset.x\n draft[selectedIndex].y += offset.y\n }))\n },\n {\n transformOffset: (f, e) => {\n if (!e?.shiftKey) {\n changeOffsetByRegionAlignment(f, contents[selectedIndex], contents.filter((_, i) => i !== selectedIndex))\n } else {\n clearRegionAlignments()\n }\n return f\n },\n }\n )\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n resetDragMove()\n }\n })\n return (\n <>\n {contents.map((content, i) => (\n onStart({ x: e.clientX, y: e.clientY }, { data: i })}\n >\n \n ))}\n \n \n {mask}\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"scrollbar.story",name:"",Component:te.default,code:"() => {\n const [x, setX] = React.useState(0)\n const [y, setY] = React.useState(0)\n return (\n \n \n \n \n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"select-before-operate.story",name:"",Component:ne.default,code:"() => {\n const { isSelected, addSelection, filterSelection, executeOperation, selectBeforeOperate, message, onSelectBeforeOperateKeyDown } = useSelectBeforeOperate<{ count?: number, selectable?: (index: number[]) => boolean }, 'alert', number[]>({}, (_, s) => {\n alert(s.map(([i]) => i).join(','))\n return true\n })\n useGlobalKeyDown(e => {\n onSelectBeforeOperateKeyDown(e)\n })\n const startOperation = (maxCount?: number, selectable?: (index: number[]) => boolean) => {\n const { result, needSelect } = filterSelection(selectable, maxCount)\n if (needSelect) {\n selectBeforeOperate({ count: maxCount, selectable }, 'alert')\n } else {\n executeOperation('alert', result)\n }\n }\n\n return (\n
\n \n \n \n \n {new Array(10).fill(1).map((_, i) => (\n addSelection([i])}\n >\n {i}\n \n ))}\n {message}\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"selected.story",name:"",Component:re.default,code:"() => {\n const { isSelected, addSelection, onSelectedKeyDown } = useSelected({ maxCount: 3 })\n useGlobalKeyDown(e => {\n onSelectedKeyDown(e)\n })\n\n return (\n
\n {new Array(10).fill(1).map((_, i) => (\n addSelection([[i]])}\n >\n {i}\n \n ))}\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"text-click-create.story",name:"",Component:oe.default,code:"() => {\n const [contents, setContents] = React.useState([])\n const { text, onClick, onMove, input, reset } = useTextClickCreate(true, (c) => {\n setContents(produce(contents, (draft) => {\n draft.push(c)\n }))\n })\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n reset()\n }\n })\n\n return (\n
\n onClick({ x: e.clientX, y: e.clientY })}\n onMouseMove={(e) => onMove({ x: e.clientX, y: e.clientY })}\n >\n {[...contents, text].map((content, i) => content && {content.text})}\n \n {input}\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"undo-redo.story",name:"",Component:ie.default,code:"() => {\n const { state, setState, undo, redo } = useUndoRedo({ count: 0 })\n useGlobalKeyDown(e => {\n if (e.code === 'KeyZ' && metaKeyIfMacElseCtrlKey(e)) {\n if (e.shiftKey) {\n redo(e)\n } else {\n undo(e)\n }\n }\n })\n return (\n setState((draft) => { draft.count++ })}\n style={{ width: '200px', height: '100px' }}\n >\n {state.count}\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"webgl-3d-land.story",name:"",Component:ae.default,code:"() => {\n const ref = React.useRef(null)\n const renderer = React.useRef>()\n const size = useWindowSize()\n const width = size.width / 2\n const height = size.height\n const [point, setPoint] = React.useState()\n const eye: Vec3 = [0, -90, 90]\n const count = 10\n const step = 5\n const minZ = -100\n const zStep = 5\n const degree = 3\n const { state, setState, undo, redo } = useUndoRedo(getInitialData(getMapPoints(step, count), degree))\n const [contextMenu, setContextMenu] = React.useState()\n const [status, setStatus] = React.useState<'up' | 'down' | 'set'>()\n const [z, setZ] = React.useState(5)\n\n React.useEffect(() => {\n if (!ref.current || renderer.current) {\n return\n }\n renderer.current = createWebgl3DRenderer(ref.current)\n }, [ref.current])\n\n useGlobalKeyDown(e => {\n if (metaKeyIfMacElseCtrlKey(e)) {\n if (e.code === 'KeyZ') {\n if (e.shiftKey) {\n redo(e)\n } else {\n undo(e)\n }\n }\n } else if (e.key === 'Escape') {\n setStatus(undefined)\n setContextMenu(undefined)\n }\n })\n const render = (g: Nullable[]) => {\n renderer.current?.render?.(\n g,\n {\n eye,\n up: [0, 1, 0],\n target: [0, 0, 0],\n fov: angleToRadian(60),\n near: 0.1,\n far: 1000,\n },\n {\n position: [1000, -1000, 1000],\n color: [1, 1, 1, 1],\n specular: [1, 1, 1, 1],\n shininess: 50,\n specularFactor: 1,\n },\n [1, 1, 1, 1],\n )\n }\n\n React.useEffect(() => {\n const pointGraphics: Graphic3d[] = []\n if (point) {\n pointGraphics.push({\n geometry: {\n type: 'sphere',\n radius: 1,\n },\n color: [1, 0, 0, 1],\n position: point,\n })\n }\n render([...state, ...pointGraphics])\n }, [point, state])\n\n return (\n \n {\n if (status) {\n setPoint(undefined)\n return\n }\n setPoint(renderer.current?.pickPoint?.(e.clientX, e.clientY, eye, minZ, g => g.geometry.type === 'vertices'))\n }}\n onMouseDown={e => {\n if (!status) return\n const geometry = state[0].geometry\n if (geometry.type === 'vertices') {\n const p = renderer.current?.pickPoint?.(e.clientX, e.clientY, eye, minZ, g => g.geometry.type === 'vertices')\n if (p) {\n const x = Math.round(p[0] / step) + count\n if (x >= 0 && x < geometry.points.length) {\n const y = Math.round(p[1] / step) + count\n if (y >= 0 && y < geometry.points.length) {\n const newPoints = produce(geometry.points, draft => {\n const point = draft[x][y]\n if (status === 'set') {\n point[2] = z\n } else if (status === 'up') {\n point[2] += zStep\n } else if (point[2] - zStep < minZ) {\n return\n } else {\n point[2] -= zStep\n }\n })\n if (newPoints !== geometry.points) {\n setState(() => getInitialData(newPoints, degree))\n }\n }\n }\n }\n }\n }}\n onContextMenu={e => {\n e.preventDefault()\n const viewportPosition = { x: e.clientX, y: e.clientY }\n if (contextMenu) {\n setContextMenu(undefined)\n return\n }\n setContextMenu(\n \n \n {\n setStatus('set')\n setContextMenu(undefined)\n }}\n >set\n \n ),\n height: 41,\n },\n ]}\n y={viewportPosition.y}\n height={height}\n style={{\n left: viewportPosition.x + 'px',\n }}\n />\n )\n }}\n />\n {contextMenu}\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"webgl-3d.story",name:"",Component:se.default,code:"() => {\n const ref = React.useRef(null)\n const renderer = React.useRef>()\n const { x, y, setX, setY, ref: wheelScrollRef } = useWheelScroll()\n const { scale, setScale, ref: wheelZoomRef } = useWheelZoom()\n const [rotate, setRotate] = React.useState({ x: 0, y: 0 })\n const { offset, onStart: onStartMoveCanvas, mask: moveCanvasMask, resetDragMove } = useDragMove(() => {\n setRotate((v) => ({ x: v.x + offset.x, y: v.y + offset.y }))\n })\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n resetDragMove()\n } else if (e.code === 'Digit0' && !e.shiftKey && metaKeyIfMacElseCtrlKey(e)) {\n setScale(1)\n setX(0)\n setY(0)\n setRotate({ x: 0, y: 0 })\n e.preventDefault()\n }\n })\n const size = useWindowSize()\n const width = size.width / 2\n const height = size.height\n const rotateX = offset.x + rotate.x\n const rotateY = offset.y + rotate.y\n const [hovering, setHovering] = React.useState()\n const graphics = React.useRef([\n ...getAxesGraphics(),\n {\n geometry: {\n type: 'lines',\n points: getDashedLine([0, 0, 0], [100, 100, 100], 6).flat(),\n },\n color: [0, 0, 0, 1],\n },\n {\n geometry: {\n type: 'sphere',\n radius: 100,\n },\n color: [1, 0, 0, 1],\n position: [0, 250, 0],\n },\n {\n geometry: {\n type: 'cube',\n size: 150,\n },\n color: [0, 1, 0, 1],\n position: [250, 0, 0],\n },\n {\n geometry: {\n type: 'cylinder',\n radius: 100,\n height: 200,\n },\n color: [0, 0, 1, 1],\n position: [-250, 0, 0],\n },\n {\n geometry: {\n type: 'cone',\n topRadius: 0,\n bottomRadius: 100,\n height: 200,\n },\n color: [1, 0, 1, 1],\n position: [0, -250, 0],\n },\n {\n geometry: {\n type: 'triangles',\n points: [-50, -50, 50, 50, 50, 50, -50, 50, 50],\n },\n color: [0.5, 0, 0.5, 1],\n position: [250, 250, 250],\n },\n {\n geometry: {\n type: 'vertices',\n ...getNurbsSurfaceVertices([\n [[0, 0, -20], [20, 0, 0], [40, 0, 0], [60, 0, 0], [80, 0, 0], [100, 0, 0]],\n [[0, -20, 0], [20, -20, 10], [40, -20, 20], [60, -20, 0], [80, -20, 0], [100, -20, 0]],\n [[0, -40, 0], [20, -40, 10], [40, -40, 20], [60, -40, 0], [80, -40, -4], [100, -40, -24]],\n [[0, -50, 0], [20, -60, 0], [40, -60, -46], [60, -60, 0], [80, -60, 0], [100, -50, 0]],\n [[0, -80, 0], [20, -80, 0], [40, -80, 0], [60, -80, 8], [80, -80, -40], [100, -80, 0]],\n [[0, -100, 24], [20, -100, 0], [40, -100, 40], [60, -100, 0], [100, -100, -20], [100, -100, -30]],\n ], 3, [0, 0, 0, 0, 0.333, 0.666, 1, 1, 1, 1], 3, [0, 0, 0, 0, 0.333, 0.666, 1, 1, 1, 1]),\n },\n color: [0, 0.5, 0, 1],\n position: [-250, 250, 250],\n },\n ])\n\n React.useEffect(() => {\n if (!ref.current || renderer.current) {\n return\n }\n renderer.current = createWebgl3DRenderer(ref.current)\n }, [ref.current])\n\n React.useEffect(() => {\n const { position, up } = updateCamera(-x, y, 1000 / scale, -0.3 * rotateX, -0.3 * rotateY)\n graphics.current.forEach((g, i) => {\n g.color[3] = i === hovering ? 0.5 : 1\n })\n renderer.current?.render?.(\n graphics.current,\n {\n eye: position3DToVec3(position),\n up: position3DToVec3(up),\n target: [-x, y, 0],\n fov: angleToRadian(60),\n near: 0.1,\n far: 20000,\n },\n {\n position: [1000, 1000, 1000],\n color: [1, 1, 1, 1],\n specular: [1, 1, 1, 1],\n shininess: 50,\n specularFactor: 1,\n },\n [1, 1, 1, 1],\n )\n }, [x, y, scale, rotateX, rotateY, hovering, width, height])\n\n return (\n \n onStartMoveCanvas({ x: e.clientX, y: e.clientY })}\n onMouseMove={e => setHovering(renderer.current?.pick?.(e.clientX, e.clientY, (g) => g.geometry.type !== 'lines'))}\n />\n {moveCanvasMask}\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"webgl.story",name:"",Component:ce.default,code:"() => {\n const ref = React.useRef(null)\n const render = React.useRef<(g: typeof graphics, x: number, y: number, scale: number) => void>()\n const { x, y, ref: wheelScrollRef, setX, setY } = useWheelScroll()\n const { scale, setScale, ref: wheelZoomRef } = useWheelZoom({\n onChange(oldScale, newScale, cursor) {\n const result = scaleByCursorPosition({ width, height }, newScale / oldScale, cursor)\n setX(result.setX)\n setY(result.setY)\n }\n })\n const { zoomIn, zoomOut } = useZoom(scale, setScale)\n const { offset, onStart: onStartMoveCanvas, mask: moveCanvasMask, resetDragMove } = useDragMove(() => {\n setX((v) => v + offset.x)\n setY((v) => v + offset.y)\n })\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n resetDragMove()\n } else if (metaKeyIfMacElseCtrlKey(e) ) {\n if (e.code === 'Minus') {\n zoomOut(e)\n } else if (e.code === 'Equal') {\n zoomIn(e)\n }\n }\n })\n const size = useWindowSize()\n const width = size.width / 2\n const height = size.height\n const generateGraphics = () => {\n const canvas = document.createElement(\"canvas\")\n const ctx = canvas.getContext(\"2d\")\n if (ctx) {\n ctx.font = \"50px monospace\";\n const t = ctx.measureText('abc');\n ctx.canvas.width = Math.ceil(t.width) + 2;\n ctx.canvas.height = 50;\n ctx.font = \"50px monospace\";\n ctx.fillStyle = 'white';\n ctx.fillText('abc', 0, ctx.canvas.height);\n }\n const lineWidth = 10\n const miterLimit = 'round'\n const closed = undefined\n return {\n backgroundColor: [Math.random(), Math.random(), Math.random(), 1] as Vec4,\n lines: [\n {\n points: combineStripTriangles([\n getPolylineTriangles([\n { x: Math.random() * 600, y: Math.random() * 400 },\n { x: Math.random() * 600, y: Math.random() * 400 },\n { x: Math.random() * 600, y: Math.random() * 400 },\n { x: Math.random() * 600, y: Math.random() * 400 },\n ], lineWidth, closed, miterLimit).points,\n getPolylineTriangles([\n { x: Math.random() * 600, y: Math.random() * 400 },\n { x: Math.random() * 600, y: Math.random() * 400 },\n { x: Math.random() * 600, y: Math.random() * 400 },\n { x: Math.random() * 600, y: Math.random() * 400 },\n ], lineWidth, closed, miterLimit).points,\n ]),\n color: [Math.random(), Math.random(), Math.random(), 1],\n },\n {\n points: combineStripTriangles([\n getPolylineTriangles([\n { x: Math.random() * 600, y: Math.random() * 400 },\n { x: Math.random() * 600, y: Math.random() * 400 },\n { x: Math.random() * 600, y: Math.random() * 400 },\n { x: Math.random() * 600, y: Math.random() * 400 },\n ], lineWidth, closed, miterLimit).points,\n getPolylineTriangles([\n { x: Math.random() * 600, y: Math.random() * 400 },\n { x: Math.random() * 600, y: Math.random() * 400 },\n { x: Math.random() * 600, y: Math.random() * 400 },\n { x: Math.random() * 600, y: Math.random() * 400 },\n ], lineWidth, closed, miterLimit).points,\n ]),\n color: [Math.random(), Math.random(), Math.random(), 1],\n },\n ],\n line: [\n Math.random() * 600,\n Math.random() * 400,\n Math.random() * 600,\n Math.random() * 400,\n Math.random() * 600,\n Math.random() * 400,\n ],\n triangles: [\n Math.random() * 600,\n Math.random() * 400,\n Math.random() * 600,\n Math.random() * 400,\n Math.random() * 600,\n Math.random() * 400,\n ],\n triangleColors: [\n Math.random(), Math.random(), Math.random(), 1,\n Math.random(), Math.random(), Math.random(), 1,\n Math.random(), Math.random(), Math.random(), 1,\n ],\n canvas,\n color: [Math.random(), Math.random(), Math.random(), 1],\n position: { x: Math.random() * 600, y: Math.random() * 400 },\n }\n }\n const [graphics, setGraphics] = React.useState(generateGraphics())\n\n React.useEffect(() => {\n if (!ref.current || render.current) {\n return\n }\n const canvas = ref.current\n const gl = ref.current.getContext(\"webgl\", { antialias: true, stencil: true });\n if (!gl) {\n return\n }\n gl.enable(gl.BLEND);\n gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);\n const programInfo = twgl.createProgramInfo(gl, [`\n attribute vec4 position;\n uniform mat3 matrix;\n void main() {\n gl_Position = vec4((matrix * vec3(position.xy, 1)).xy, 0, 1);\n }\n `, `\n precision mediump float;\n uniform vec4 color;\n void main() {\n gl_FragColor = color;\n }`]);\n const programInfo2 = twgl.createProgramInfo(gl, [`\n attribute vec4 position; \n uniform mat3 matrix;\n varying vec2 texcoord;\n\n void main () {\n gl_Position = vec4((matrix * vec3(position.xy, 1)).xy, 0, 1);\n texcoord = position.xy;\n }\n `, `\n precision mediump float;\n\n varying vec2 texcoord;\n uniform sampler2D texture;\n uniform vec4 color;\n\n void main() {\n if (texcoord.x < 0.0 || texcoord.x > 1.0 ||\n texcoord.y < 0.0 || texcoord.y > 1.0) {\n discard;\n }\n vec4 color = texture2D(texture, texcoord) * color;\n if (color.a < 0.1) {\n discard;\n }\n gl_FragColor = color;\n }`]);\n gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);\n const textBufferInfo = twgl.primitives.createXYQuadBufferInfo(gl);\n const programInfo3 = twgl.createProgramInfo(gl, [`\n attribute vec4 position;\n varying vec2 texcoord;\n void main() {\n gl_Position = position;\n texcoord = position.xy * .5 + .5;\n }\n `, `\n precision mediump float;\n varying vec2 texcoord;\n uniform sampler2D texture;\n void main() {\n gl_FragColor = texture2D(texture, texcoord); \n }\n `]);\n const imageBufferInfo = twgl.primitives.createXYQuadBufferInfo(gl);\n const imageTexture = twgl.createTexture(gl, {\n src: \"https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg\",\n crossOrigin: \"\",\n });\n const gradientProgramInfo = twgl.createProgramInfo(gl, [`\n attribute vec4 position;\n attribute vec4 color;\n uniform mat3 matrix;\n varying vec4 v_color;\n\n void main () {\n gl_Position = vec4((matrix * vec3(position.xy, 1)).xy, 0, 1);\n v_color = color;\n }\n `, `\n precision mediump float;\n\n varying vec4 v_color;\n\n void main() {\n gl_FragColor = v_color;\n }`]);\n\n render.current = (gs, x, y, scale) => {\n gl.viewport(0, 0, gl.canvas.width, gl.canvas.height);\n gl.useProgram(programInfo.program);\n twgl.resizeCanvasToDisplaySize(canvas);\n gl.clearColor(...gs.backgroundColor)\n gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT)\n\n let matrix = m3.projection(gl.canvas.width, gl.canvas.height)\n matrix = m3.multiply(matrix, m3.translation(x, y))\n if (scale !== 1) {\n matrix = m3.multiply(matrix, m3.translation(gl.canvas.width / 2, gl.canvas.height / 2));\n matrix = m3.multiply(matrix, m3.scaling(scale, scale));\n matrix = m3.multiply(matrix, m3.translation(-gl.canvas.width / 2, -gl.canvas.height / 2));\n }\n\n const objectsToDraw: twgl.DrawObject[] = []\n for (const line of gs.lines) {\n objectsToDraw.push({\n programInfo,\n bufferInfo: twgl.createBufferInfoFromArrays(gl, {\n position: {\n numComponents: 2,\n data: line.points\n },\n }),\n uniforms: {\n color: line.color,\n matrix,\n },\n type: gl.TRIANGLE_STRIP,\n })\n }\n const objectsToDraw2 = [{\n programInfo,\n bufferInfo: twgl.createBufferInfoFromArrays(gl, {\n position: {\n numComponents: 2,\n data: gs.line\n },\n }),\n uniforms: {\n color: gs.color,\n matrix,\n },\n type: gl.LINE_STRIP,\n }]\n\n const objectsToDraw3 = [{\n programInfo: gradientProgramInfo,\n bufferInfo: twgl.createBufferInfoFromArrays(gl, {\n position: {\n numComponents: 2,\n data: gs.triangles\n },\n color: {\n numComponents: 4,\n data: gs.triangleColors\n },\n }),\n uniforms: {\n matrix,\n },\n type: gl.TRIANGLES,\n }]\n\n matrix = m3.multiply(matrix, m3.translation(gs.position.x, gs.position.y))\n matrix = m3.multiply(matrix, m3.scaling(gs.canvas.width, gs.canvas.height))\n twgl.drawObjectList(gl, objectsToDraw)\n\n gl.enable(gl.STENCIL_TEST);\n gl.stencilFunc(gl.ALWAYS, 1, 0xFF);\n gl.stencilOp(gl.KEEP, gl.KEEP, gl.REPLACE);\n twgl.drawObjectList(gl, [\n {\n programInfo: programInfo2,\n bufferInfo: textBufferInfo,\n uniforms: {\n matrix,\n color: gs.color,\n texture: twgl.createTexture(gl, { src: gs.canvas }),\n },\n },\n {\n programInfo: programInfo2,\n bufferInfo: textBufferInfo,\n uniforms: {\n matrix: m3.multiply(matrix, m3.translation(1, 0)),\n color: gs.color,\n texture: twgl.createTexture(gl, { src: gs.canvas }),\n },\n },\n {\n programInfo: programInfo2,\n bufferInfo: textBufferInfo,\n uniforms: {\n matrix: m3.multiply(matrix, m3.translation(1, 1)),\n color: gs.color,\n texture: twgl.createTexture(gl, { src: gs.canvas }),\n },\n }\n ])\n\n gl.stencilFunc(gl.EQUAL, 1, 0xFF);\n gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP);\n twgl.drawObjectList(gl, [{\n programInfo: programInfo3,\n bufferInfo: imageBufferInfo,\n uniforms: {\n texture: imageTexture\n },\n }])\n gl.disable(gl.STENCIL_TEST);\n\n twgl.drawObjectList(gl, objectsToDraw2)\n\n twgl.drawObjectList(gl, objectsToDraw3)\n }\n }, [ref.current])\n\n React.useEffect(() => {\n if (render.current) {\n render.current(graphics, x + offset.x, y + offset.y, scale)\n }\n }, [graphics, render.current, x, y, offset, scale])\n\n return (\n \n onStartMoveCanvas({ x: e.clientX, y: e.clientY })}\n />\n \n {moveCanvasMask}\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"webgpu-3d.story",name:"",Component:le.default,code:"() => {\n const ref = React.useRef(null)\n const renderer = React.useRef>>()\n const { x, y, setX, setY, ref: wheelScrollRef } = useWheelScroll()\n const { scale, setScale, ref: wheelZoomRef } = useWheelZoom()\n const [rotate, setRotate] = React.useState({ x: 0, y: 0 })\n const { offset, onStart: onStartMoveCanvas, mask: moveCanvasMask, resetDragMove } = useDragMove(() => {\n setRotate((v) => ({ x: v.x + offset.x, y: v.y + offset.y }))\n })\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n resetDragMove()\n } else if (e.code === 'Digit0' && !e.shiftKey && metaKeyIfMacElseCtrlKey(e)) {\n setScale(1)\n setX(0)\n setY(0)\n setRotate({ x: 0, y: 0 })\n e.preventDefault()\n }\n })\n const size = useWindowSize()\n const width = size.width / 2\n const height = size.height\n const rotateX = offset.x + rotate.x\n const rotateY = offset.y + rotate.y\n const [hovering, setHovering] = React.useState()\n const graphics = React.useRef([\n ...getAxesGraphics(),\n {\n geometry: {\n type: 'lines',\n points: getDashedLine([0, 0, 0], [100, 100, 100], 6).flat(),\n },\n color: [0, 0, 0, 1],\n },\n {\n geometry: {\n type: 'sphere',\n radius: 100,\n },\n color: [1, 0, 0, 1],\n position: [0, 250, 0],\n },\n {\n geometry: {\n type: 'cube',\n size: 150,\n },\n color: [0, 1, 0, 1],\n position: [250, 0, 0],\n },\n {\n geometry: {\n type: 'cylinder',\n radius: 100,\n height: 200,\n },\n color: [0, 0, 1, 1],\n position: [-250, 0, 0],\n },\n {\n geometry: {\n type: 'cone',\n topRadius: 0,\n bottomRadius: 100,\n height: 200,\n },\n color: [1, 0, 1, 1],\n position: [0, -250, 0],\n },\n {\n geometry: {\n type: 'triangles',\n points: [-50, -50, 50, 50, 50, 50, -50, 50, 50],\n },\n color: [0.5, 0, 0.5, 1],\n position: [250, 250, 250],\n },\n {\n geometry: {\n type: 'vertices',\n ...getNurbsSurfaceVertices([\n [[0, 0, -20], [20, 0, 0], [40, 0, 0], [60, 0, 0], [80, 0, 0], [100, 0, 0]],\n [[0, -20, 0], [20, -20, 10], [40, -20, 20], [60, -20, 0], [80, -20, 0], [100, -20, 0]],\n [[0, -40, 0], [20, -40, 10], [40, -40, 20], [60, -40, 0], [80, -40, -4], [100, -40, -24]],\n [[0, -50, 0], [20, -60, 0], [40, -60, -46], [60, -60, 0], [80, -60, 0], [100, -50, 0]],\n [[0, -80, 0], [20, -80, 0], [40, -80, 0], [60, -80, 8], [80, -80, -40], [100, -80, 0]],\n [[0, -100, 24], [20, -100, 0], [40, -100, 40], [60, -100, 0], [100, -100, -20], [100, -100, -30]],\n ], 3, [0, 0, 0, 0, 0.333, 0.666, 1, 1, 1, 1], 3, [0, 0, 0, 0, 0.333, 0.666, 1, 1, 1, 1]),\n },\n color: [0, 0.5, 0, 1],\n position: [250, 250, -250],\n rotateY: Math.PI,\n },\n ])\n\n React.useEffect(() => {\n if (!ref.current || renderer.current) {\n return\n }\n createWebgpu3DRenderer(ref.current).then(r => {\n renderer.current = r\n setHovering(-1)\n })\n }, [ref.current])\n\n React.useEffect(() => {\n const { position, up } = updateCamera(-x, y, 1000 / scale, -0.3 * rotateX, -0.3 * rotateY)\n graphics.current.forEach((g, i) => {\n g.color[3] = i === hovering ? 0.5 : 1\n })\n renderer.current?.render?.(\n graphics.current,\n {\n eye: position3DToVec3(position),\n up: position3DToVec3(up),\n target: [-x, y, 0],\n fov: angleToRadian(60),\n near: 0.1,\n far: 20000,\n },\n {\n position: [1000, 1000, 1000],\n color: [1, 1, 1, 1],\n specular: [1, 1, 1, 1],\n shininess: 50,\n specularFactor: 1,\n },\n [1, 1, 1, 1],\n )\n }, [x, y, scale, rotateX, rotateY, hovering, width, height])\n\n return (\n \n onStartMoveCanvas({ x: e.clientX, y: e.clientY })}\n onMouseMove={async e => setHovering(await renderer.current?.pick?.(e.clientX, e.clientY, (g) => g.geometry.type !== 'lines' && g.geometry.type !== 'triangles'))}\n />\n {moveCanvasMask}\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"wheel-scroll.story",name:"",Component:ue.default,code:"() => {\n const { ref, x, y } = useWheelScroll({\n maxOffsetX: 250,\n maxOffsetY: 250,\n })\n return (\n \n \n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"wheel-zoom.story",name:"",Component:pe.default,code:"() => {\n const { ref, scale } = useWheelZoom()\n return (\n \n \n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"window-size.story",name:"",Component:de.default,code:"() => {\n const { width, height } = useWindowSize()\n\n return (\n
\n {Math.round(width)} {Math.round(height)}\n
\n )\n}",props:[],componentName:"",parentComponentName:""}]},3613:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(3696),o=n.n(r),i=n(9758);const a=()=>{const[e,t]=o().useState(1),{zoomIn:n,zoomOut:r}=(0,i.useZoom)(e,t);return(0,i.useGlobalKeyDown)((e=>{(0,i.metaKeyIfMacElseCtrlKey)(e)&&("Minus"===e.code?r(e):"Equal"===e.code&&n(e))})),o().createElement("div",{style:{width:"300px",height:"300px",overflow:"hidden",position:"absolute",display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid green"}},o().createElement("div",{style:{width:"800px",height:"800px",position:"absolute",transform:`scale(${e})`,background:"radial-gradient(50% 50% at 50% 50%, red 0%, white 100%)"}}))}},4565:(e,t,n)=>{"use strict";n.d(t,{default:()=>c});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758),s=n(9299);const c=()=>{const[e,t]=i().useState(s.defaultContents),[n,o]=i().useState(0),{lineAlignmentX:c,lineAlignmentY:l,changeOffsetByLineAlignment:u,clearLineAlignments:p}=(0,a.useLineAlignment)(10),{offset:d,onStart:f,mask:g,resetDragResize:h}=(0,a.useDragResize)((()=>{p(),t((0,r.produce)(e,(e=>{e[n].x+=d.x,e[n].y+=d.y,e[n].width+=d.width,e[n].height+=d.height})))}),{centeredScaling:e=>e.shiftKey,transformOffset:(t,r,o)=>{if(!(null==r?void 0:r.metaKey)&&o){const r=e[n],i=e.filter((e=>e!==r)).map((e=>[e.x,e.x+e.width])).flat(),a=e.filter((e=>e!==r)).map((e=>[e.y,e.y+e.height])).flat();u(t,o,r,i,a)}else p();return t}});return(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&h()})),i().createElement(i().Fragment,null,e.map(((e,t)=>i().createElement("div",{key:t,style:{width:`${e.width+(n===t?d.width:0)}px`,height:`${e.height+(n===t?d.height:0)}px`,left:`${e.x+(n===t?d.x:0)}px`,top:`${e.y+(n===t?d.y:0)}px`,position:"absolute",boxSizing:"border-box",border:n===t?"1px solid green":void 0},onClick:()=>o(t)},i().createElement("img",{src:e.url,style:{objectFit:"fill",width:"100%",height:"100%"}}),n===t&&i().createElement(a.ResizeBar,{onMouseDown:f})))),i().createElement(a.AlignmentLine,{type:"x",value:c}),i().createElement(a.AlignmentLine,{type:"y",value:l}),g)}},4855:(e,t,n)=>{"use strict";n.d(t,{default:()=>f});var r=n(3696),o=n.n(r),i=n(9758),a=Object.defineProperty,s=Object.defineProperties,c=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,u=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable,d=(e,t,n)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;const f=()=>{const e=o().useRef(null),t=o().useRef(),{x:n,y:r,ref:a}=(0,i.useWheelScroll)(),{scale:f,ref:g}=(0,i.useWheelZoom)(),[h,m]=o().useState({x:0,y:0}),{offset:y,onStart:v,mask:x,resetDragMove:b}=(0,i.useDragMove)((()=>{m((e=>({x:e.x+y.x,y:e.y+y.y})))})),C=(0,i.useWindowSize)(),E=C.width/2,P=C.height,[w,k]=o().useState(),_=y.x+h.x,S=y.y+h.y,R=o().useRef([]);return o().useEffect((()=>{e.current&&!t.current&&(t.current=(0,i.createWebgl3DRenderer)(e.current))}),[e.current]),(0,i.useGlobalKeyDown)((e=>{"Escape"===e.key&&b()})),o().useEffect((()=>{const e=[65,59,80,81,56,55,40].map(((e,t)=>[20*(t+1),e,0])),t=[55,49,70,71,46,45,30].map(((e,t)=>[20*(t+1),e,20])),n=[45,39,60,61,36,35,20].map(((e,t)=>[20*(t+1),e,-20])),r=[75,69,90,91,66,65,50].map(((e,t)=>[20*(t+1),e,40])),o=(0,i.getChartAxis3D)([e,t,n,r],{x:20,y:10,z:20});R.current.push(...o,{geometry:{type:"line strip",points:e.flat()},color:[1,0,0,1]},...e.map((e=>({geometry:{type:"sphere",radius:1},color:[1,0,0,1],position:e}))),{geometry:{type:"line strip",points:(0,i.getBezierSplinePoints3D)(t,20).flat()},color:[0,1,0,1]},...t.map((e=>({geometry:{type:"sphere",radius:1},color:[0,1,0,1],position:e}))),{geometry:{type:"polygon",points:[...n.flat(),n[n.length-1][0],0,n[n.length-1][2],n[0][0],0,n[0][2]]},color:[0,0,1,1]},...n.map((e=>({geometry:{type:"sphere",radius:1},color:[0,0,1,1],position:e}))),...r.map(((e,t)=>({geometry:{type:"sphere",radius:t/2+1},color:[1,0,0,1],position:e}))))}),[]),o().useEffect((()=>{var e,o;const{position:a,up:s}=(0,i.updateCamera)(-n,r,200/f,-.3*_,-.3*S);null==(o=null==(e=t.current)?void 0:e.render)||o.call(e,R.current,{eye:[a.x+40,a.y+40,a.z],up:(0,i.position3DToVec3)(s),target:[40-n,r+40,0],fov:(0,i.angleToRadian)(60),near:.1,far:2e3},{position:[1e3,1e3,1e3],color:[1,1,1,1],specular:[1,1,1,1],shininess:50,specularFactor:1},[1,1,1,1])}),[n,r,f,_,S,w,E,P]),o().createElement("div",{style:{position:"absolute",inset:"0px"}},o().createElement("canvas",{ref:(0,i.bindMultipleRefs)(a,g,e),width:E,height:P,onMouseDown:e=>v({x:e.clientX,y:e.clientY}),onMouseMove:e=>{var n,r;k(void 0);const o=null==(r=null==(n=t.current)?void 0:n.pick)?void 0:r.call(n,e.clientX,e.clientY,(e=>"sphere"===e.geometry.type));if(void 0!==o){const t=R.current[o];t.position&&k({value:t.position,x:e.clientX,y:e.clientY})}}}),w&&o().createElement(i.ChartTooltip,(T=((e,t)=>{for(var n in t||(t={}))u.call(t,n)&&d(e,n,t[n]);if(l)for(var n of l(t))p.call(t,n)&&d(e,n,t[n]);return e})({},w),A={label:(L=w.value[0]/20,Intl.DateTimeFormat("zh",{month:"long"}).format(new Date(L.toString()))),value:w.value[1]},s(T,c(A)))),x);var T,A,L}},7265:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(3696),o=n.n(r),i=n(9758);const a=()=>{const e=(0,i.useWindowSize)().width/2,t=i.reactSvgRenderTarget,[n,r]=o().useState(),[a,s]=o().useState(),c=e=>Intl.DateTimeFormat("zh",{month:"long"}).format(new Date(e.toString()));if(o().useEffect((()=>{const n=[65,59,80,81,56,55,40].map(((e,t)=>({x:t+1,y:e}))),r=[55,49,70,71,46,45,30].map(((e,t)=>({x:t+1,y:e}))),o=[45,39,60,61,36,35,20].map(((e,t)=>({x:t+1,y:e}))),a=[35,29,50,51,26,25,10].map(((e,t)=>({x:t+1,y:e}))),l=[75,69,90,91,66,65,50].map(((e,t)=>({x:t+1,y:e,r:3*t+5}))),u=(0,i.getLineChart)([n,r,o,a,l],t,{x:1,y:5},{width:e,height:300},{left:25,right:25,top:10,bottom:20},{getXLabel:c,ySecondary:!0});if(!u)return;const{points:[p,d,f,g,h],children:m,select:y,minY:v}=u;m.push(t.renderPolyline(p,{strokeColor:16711680})),m.push(...p.map((e=>t.renderCircle(e.x,e.y,3,{fillColor:16711680,strokeWidth:0})))),m.push(t.renderPolyline((0,i.getBezierSplinePoints)(d,50),{strokeColor:65280})),m.push(...d.map((e=>t.renderCircle(e.x,e.y,3,{fillColor:65280,strokeWidth:0})))),m.push(t.renderPolyline(f.map(((e,t)=>{const n=[e];return 0!==t&&n.unshift({x:(0,i.getTwoNumberCenter)(e.x,f[t-1].x),y:e.y}),t!==f.length-1&&n.push({x:(0,i.getTwoNumberCenter)(e.x,f[t+1].x),y:e.y}),n})).flat(),{strokeColor:255})),m.push(...f.map((e=>t.renderCircle(e.x,e.y,3,{fillColor:255,strokeWidth:0})))),m.push(t.renderPolygon([...g,{x:g[g.length-1].x,y:v},{x:g[0].x,y:v}],{fillColor:16711680,strokeWidth:0})),m.push(...g.map((e=>t.renderCircle(e.x,e.y,3,{fillColor:16711680,strokeWidth:0})))),m.push(...h.map((e=>{var n;return t.renderCircle(e.x,e.y,null!=(n=e.r)?n:5,{fillColor:65280,strokeWidth:0})}))),s({children:m,select:y})}),[e]),!a)return null;let l=a.children;return n&&(l=[...a.children,...(0,i.renderChartTooltip)(t,n,n.value,{getXLabel:c})]),o().createElement("div",{style:{position:"absolute",inset:"0px"}},t.renderResult(l,e,300,{attributes:{onMouseMove:e=>r(a.select({x:e.clientX,y:e.clientY}))}}))}},2754:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758);const s=()=>{const[e,t]=i().useState([]),{line:n,onClick:o,onMove:s,input:c,reset:l}=(0,a.useLineClickCreate)(!0,(n=>{t((0,r.produce)(e,(e=>{e.push(n)})))}));return(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&l(!0)})),i().createElement("div",{style:{height:"100%"}},i().createElement("svg",{viewBox:"0 0 800 600",width:800,height:600,xmlns:"http://www.w3.org/2000/svg",fill:"none",style:{position:"absolute",left:0,top:0},onClick:e=>o({x:e.clientX,y:e.clientY}),onMouseMove:e=>s({x:e.clientX,y:e.clientY})},[...e,n].map(((e,t)=>e&&i().createElement("polyline",{key:t,stroke:"#00ff00",points:e.map((e=>`${e.x},${e.y}`)).join(" ")})))),c)}},8208:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(3696),o=n.n(r),i=n(9758),a=n(4469);const s=()=>{const e={p1:{x:200,y:200},p2:{x:300,y:300},position:{x:400,y:100},fontFamily:"monospace",fontSize:16,direct:!0},{regions:t,lines:n}=(0,i.getLinearDimensionGeometries)(e,a.dimensionStyle,(e=>(0,i.getLinearDimensionTextPosition)(e,a.dimensionStyle.margin,i.getTextSize))),{textPosition:r,textRotation:s,text:c}=(0,i.getLinearDimensionTextPosition)(e,a.dimensionStyle.margin,i.getTextSize);return o().createElement("svg",{viewBox:"0 0 800 600",width:800,height:600,xmlns:"http://www.w3.org/2000/svg",fill:"none",style:{position:"absolute",left:0,top:0}},n.map(((e,t)=>o().createElement("polyline",{key:t,stroke:"black",points:e.map((e=>`${e.x},${e.y}`)).join(" ")}))),t[0]&&o().createElement("polyline",{stroke:"black",points:t[0].points.map((e=>`${e.x},${e.y}`)).join(" "),fill:"black"}),t[1]&&o().createElement("polyline",{stroke:"black",points:t[1].points.map((e=>`${e.x},${e.y}`)).join(" "),fill:"black"}),o().createElement("text",{x:r.x,y:r.y,fill:"black",transform:(0,i.getRotateTransform)(r.x,r.y,{rotation:s}),style:{fontSize:`${e.fontSize}px`,fontFamily:e.fontFamily}},c))}},6821:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(3696),o=n.n(r),i=n(9758);const a=()=>o().createElement(i.Menu,{items:[{title:"item 1",children:[{title:"item 1 child 1"},{title:"item 1 child 2",children:[{title:"item 1 child 2 child 1"},{title:"item 1 child 2 child 2"}]}]},{title:"item 2",children:[{title:"item 2 child 1"},{title:"item 2 child 2 disabled",disabled:!0}]},{type:"divider"},{title:"item 3"}],style:{left:"100px",top:"100px"}})},425:(e,t,n)=>{"use strict";n.d(t,{default:()=>p});var r=n(3696),o=n.n(r),i=n(9758),a=Object.defineProperty,s=Object.getOwnPropertySymbols,c=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,u=(e,t,n)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;const p=()=>{const{ref:e,x:t,setX:n,y:r,setY:a}=(0,i.useWheelScroll)(),{ref:p,scale:d}=(0,i.useWheelZoom)({onChange(e,t,r){const o=(0,i.scaleByCursorPosition)({width:h,height:m},t/e,r);n(o.setX),a(o.setY)}}),f=i.reactSvgRenderTarget,g=(0,i.useWindowSize)(),h=g.width/2,m=g.height/2,y={x:t,y:r,scale:d,center:{x:h/2,y:m/2}},v=[f.renderImage("https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg",0,0,1200,800)],{setMinimapTransform:x,minimap:b,getMinimapPosition:C}=(0,i.useMinimap)({width:100,height:100,viewport:{width:h/y.scale,height:m/y.scale,center:(0,i.reverseTransformPosition)(y.center,y)},children:e=>f.renderResult(v,100,100,{transform:e,attributes:{onClick:e=>{if(C){const t=C(e);n((y.center.x-t.x)*y.scale),a((y.center.y-t.y)*y.scale)}}}})});return o().useEffect((()=>{const e={start:{x:0,y:0},end:{x:1200,y:800}},t=(0,i.zoomToFit)(e,{width:100,height:100},{x:50,y:50},1);t&&x(((e,t)=>{for(var n in t||(t={}))c.call(t,n)&&u(e,n,t[n]);if(s)for(var n of s(t))l.call(t,n)&&u(e,n,t[n]);return e})({bounding:e},t))}),[]),o().createElement("div",{ref:(0,i.bindMultipleRefs)(e,p),style:{position:"absolute",inset:"0px"}},f.renderResult(v,h,m,{transform:y,attributes:{style:{border:"1px solid green"}}}),b)}},6856:(e,t,n)=>{"use strict";n.d(t,{default:()=>c});var r=n(3696),o=n.n(r),i=n(7469),a=n(9758),s=n(3385);const c=()=>{const e=(0,a.useWindowSize)().width/2,{x:t,y:n,ref:r,setX:c,setY:u}=(0,a.useWheelScroll)(),{scale:p,setScale:d,ref:f}=(0,a.useWheelZoom)({onChange(t,n,r){const o=(0,a.scaleByCursorPosition)({width:e,height:300},n/t,r);c(o.setX),u(o.setY)}}),[g,h]=o().useState(),[m,y]=o().useState("测试ABC"),[v,x]=o().useState(s.allFonts[0].name),[b,C]=o().useState(50),[E,P]=o().useState(0),[w,k]=o().useState(16777215),[_,S]=o().useState(1),[R,T]=o().useState(1),[A,L]=o().useState([]),[M,I]=o().useState(l[0]),O=null==g?void 0:g[v];o().useEffect((()=>{var e;e=function*(){const e={};for(const t of s.allFonts){const n=yield fetch(t.url),r=yield n.arrayBuffer();e[t.name]=i.parse(r)}h(e)},new Promise(((t,n)=>{var r=t=>{try{i(e.next(t))}catch(e){n(e)}},o=t=>{try{i(e.throw(t))}catch(e){n(e)}},i=e=>e.done?t(e.value):Promise.resolve(e.value).then(r,o);i((e=e.apply(undefined,null)).next())}))}),[]),(0,a.useGlobalKeyDown)((e=>{"Digit0"===e.code&&!e.shiftKey&&(0,a.metaKeyIfMacElseCtrlKey)(e)&&(d(1),c(0),u(0),e.preventDefault())})),o().useEffect((()=>{if(!O)return;const e=O.getPaths(m,0,b,b,{xScale:_*b/O.unitsPerEm,yScale:R*b/O.unitsPerEm}).map((e=>(0,s.opentypeCommandsToPathCommands)(e)));L(e)}),[m,O,b,M,_,R]);const D=A.map((e=>M.renderPathCommands(e,{fillColor:E,strokeColor:E}))).flat();return D.push(M.renderText(0,2*b,m,E,b*Math.max(_,R),v)),o().createElement("div",{style:{position:"absolute",inset:"0px"},ref:(0,a.bindMultipleRefs)(f,r)},M.renderResult(D,e,300,{transform:{x:t,y:n,scale:p},backgroundColor:w}),o().createElement("div",{style:{display:"flex",width:`${e}px`}},o().createElement(a.ObjectEditor,{inline:!0,properties:{text:o().createElement(a.StringEditor,{value:m,setValue:e=>y(e)}),"font family":o().createElement(a.EnumEditor,{select:!0,value:v,enums:s.allFonts.map((e=>e.name)),setValue:e=>{var t,n;return x(null!=(n=null==(t=s.allFonts.find((t=>t.name===e)))?void 0:t.name)?n:s.allFonts[0].name)}}),"font size":o().createElement(a.NumberEditor,{value:b,setValue:e=>C(e)}),"render target":o().createElement(a.EnumEditor,{select:!0,value:M.type,enums:l.map((e=>e.type)),setValue:e=>{var t;return I(null!=(t=l.find((t=>t.type===e)))?t:l[0])}}),color:o().createElement(a.NumberEditor,{type:"color",value:E,setValue:e=>P(e)}),"background color":o().createElement(a.NumberEditor,{type:"color",value:w,setValue:e=>k(e)}),"x scale":o().createElement(a.NumberEditor,{value:_,setValue:e=>S(e)}),"y scale":o().createElement(a.NumberEditor,{value:R,setValue:e=>T(e)}),actions:o().createElement(a.Button,{onClick:()=>navigator.clipboard.writeText(JSON.stringify({contents:A.map(((e,t)=>({id:t,content:{type:"path",commands:e,strokeColor:E,fillColor:E}}))),center:{x:0,y:0}}))},"copy as command path")}})))},l=[a.reactCanvasRenderTarget,a.reactSvgRenderTarget,a.reactWebglRenderTarget]},3385:(e,t,n)=>{"use strict";n.d(t,{allFonts:()=>a,opentypeCommandsToPathCommands:()=>o});var r=n(9758);function o(e,t){const n=[];for(const r of e.commands)"M"===r.type?n.push({type:"move",to:i({x:r.x,y:r.y},t)}):"L"===r.type?n.push({type:"line",to:i({x:r.x,y:r.y},t)}):"C"===r.type?n.push({type:"bezierCurve",cp1:i({x:r.x1,y:r.y1},t),cp2:i({x:r.x2,y:r.y2},t),to:i({x:r.x,y:r.y},t)}):"Q"===r.type?n.push({type:"quadraticCurve",cp:i({x:r.x1,y:r.y1},t),to:i({x:r.x,y:r.y},t)}):n.push({type:"close"});return n}function i(e,t){return void 0!==t&&(0,r.skewPoint)(e,{x:0,y:t},-.15),e}const a=[{name:"STSong",url:"https://raw.githubusercontent.com/Haixing-Hu/latex-chinese-fonts/master/chinese/%E5%AE%8B%E4%BD%93/STSong.ttf"},{name:"Arial",url:"https://raw.githubusercontent.com/Haixing-Hu/latex-chinese-fonts/master/english/Sans/Arial.ttf"}]},5047:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758);const s=()=>{const[e,t]=i().useState({value:1,children:[{value:10},{value:100}]}),{editingContent:n,setEditingContentPath:o,prependPatchPath:s}=(0,a.usePartialEdit)(e);return i().createElement(i().Fragment,null,i().createElement("button",{onClick:()=>{const[,o]=(0,r.produceWithPatches)(n,(e=>{e.value++}));t((0,r.applyPatches)(e,s(o)))}},"+1"),i().createElement("button",{onClick:()=>o([])},"exit"),i().createElement("div",null,n.value,n.children&&n.children.map(((e,t)=>i().createElement("button",{key:t,style:{width:"50px",height:"50px"},onClick:()=>o(["children",t])},e.value)))))}},5836:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(3696),o=n.n(r),i=n(9758);const a={count:0},s=()=>{const{state:e,setState:t,undo:n,redo:r}=(0,i.usePatchBasedUndoRedo)(a,"a");return(0,i.useGlobalKeyDown)((e=>{"KeyZ"===e.code&&(0,i.metaKeyIfMacElseCtrlKey)(e)&&(e.shiftKey?r(e):n(e))})),o().createElement("button",{onClick:()=>t((e=>{e.count++})),style:{width:"200px",height:"100px"}},e.count)}},5207:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758);const s=()=>{const[e,t]=i().useState([]),{preview:n,onClick:o,onMove:s,input:c,setInputType:l,reset:u}=(0,a.usePathClickCreate)(!0,(n=>{t((0,r.produce)(e,(e=>{e.push(n)})))}));return(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&u(!0)})),i().createElement("div",{style:{height:"100%"}},i().createElement("svg",{viewBox:"0 0 800 600",width:800,height:600,xmlns:"http://www.w3.org/2000/svg",fill:"none",style:{position:"absolute",left:0,top:0},onClick:e=>o({x:e.clientX,y:e.clientY}),onMouseMove:e=>s({x:e.clientX,y:e.clientY})},[...e,n].map(((e,t)=>e&&a.reactSvgRenderTarget.renderPathCommands(e,{strokeColor:65280})(t,1,!1,800,600)))),["line","arc","bezierCurve","quadraticCurve","close"].map((e=>i().createElement("button",{key:e,style:{position:"relative"},onClick:()=>l(e)},e))),c)}},5779:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758);const s=()=>{const[e,t]=i().useState([]),{points:n,onClick:o,onMove:s,reset:c}=(0,a.usePenClickCreate)(!0,(()=>{t((0,r.produce)(e,(e=>{e.push(n)})))}));return(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&c()})),i().createElement("div",{style:{height:"100%"}},i().createElement("svg",{viewBox:"0 0 800 600",width:800,height:600,xmlns:"http://www.w3.org/2000/svg",fill:"none",style:{position:"absolute",left:0,top:0},onClick:e=>o({x:e.clientX,y:e.clientY}),onMouseMove:e=>s({x:e.clientX,y:e.clientY})},[...e,n].map(((e,t)=>e&&i().createElement("polyline",{key:t,stroke:"#00ff00",points:e.map((e=>`${e.x},${e.y}`)).join(" ")})))))}},2890:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(3696),o=n.n(r),i=n(9758);const a=()=>{var e,t;const n=(0,i.useWindowSize)(),r=n.width/2,a=n.height,s=i.reactCanvasRenderTarget,c={x:r/2,y:a/3},[l,u]=o().useState(r/2),[p,d]=o().useState(!1),[f,g]=o().useState({radian:-Math.PI/4,speed:0}),[h,m]=o().useState(),[y,v,x]=(0,i.useRefState)(!1),[b,C,E]=(0,i.useRefState2)(),P=null!=(e=null!=b?b:h)?e:f,w=null!=(t=null==h?void 0:h.length)?t:l,k={x:c.x-w*Math.sin(P.radian),y:c.y+w*Math.cos(P.radian),r:10},_=(0,i.getPointByLengthAndRadian)(k,P.speed*w+k.r*(P.speed>=0?1:-1),(0,i.getTwoPointsRadian)(k,c)+Math.PI/2),S=[s.renderCircle(c.x,c.y,5),s.renderCircle(k.x,k.y,k.r,{fillColor:0,strokeWidth:0}),s.renderPolyline([c,k]),s.renderPolyline([k,_])],R=(0,i.useEvent)((()=>{h&&(g(h),u(h.length),d(!1),m(void 0))})),T=(0,i.useEvent)((e=>{if(p){const t={x:e.clientX,y:e.clientY};m({radian:(0,i.getTwoPointsRadian)(t,c)-Math.PI/2,speed:0,length:(0,i.getTwoPointsDistance)(t,c)})}}));return o().createElement("div",{style:{position:"absolute",inset:"0px"},onMouseMove:T},s.renderResult(S,r,a,{attributes:{onClick:R}}),o().createElement("div",{style:{position:"absolute",top:"0px"}},o().createElement(i.Button,{onClick:()=>{if(x.current)return void v(!1);let e;v(!0);const t=n=>{var r;if(x.current){if(void 0!==e){const t=.005*(n-e),o=null!=(r=E.current)?r:f,i=c.y+w*Math.cos(f.radian),a=c.y+w*Math.cos(o.radian),s=9.8;let l=o.speed-s*Math.sin(o.radian)/w*t;if(a!==i){const e=Math.sqrt(s*Math.abs(a-i)*2)/w;e{v(!1),C(void 0)}},"stop"),void 0===b&&o().createElement(i.Button,{style:{color:p?"red":void 0},onClick:()=>d(!0)},"edit")))}},1993:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(3696),o=n.n(r),i=n(9758);const a=()=>{const e=(0,i.useWindowSize)().width/2,t=350,n=i.reactSvgRenderTarget,[r,a]=o().useState(),[s,c]=o().useState(),[l,u]=o().useState(),[p,d]=o().useState(),f=e=>Intl.DateTimeFormat("zh",{month:"long"}).format(new Date(e.toString()));if(o().useEffect((()=>{const r=[[65,59,80,81,56,55,40],[75,49,70,71,46,45,30],[85,39,60,61,36,35,20]],o=[16711680,65280,255,16711680,65280,255,0];u((0,i.getPieChart)(r,o,n,{width:e,height:t},{left:10,right:10,top:10,bottom:10})),d((0,i.getPieChart)(r,o,n,{width:e,height:t},{left:10,right:10,top:10,bottom:10},{type:"doughnut"}))}),[e]),!l||!p)return null;let g=l.children;r&&(g=[...l.children,...(0,i.renderChartTooltip)(n,r,r.value,{getXLabel:f})]);let h=p.children;return s&&(h=[...p.children,...(0,i.renderChartTooltip)(n,s,s.value,{getXLabel:f})]),o().createElement("div",{style:{position:"absolute",inset:"0px",display:"flex",flexDirection:"column"}},n.renderResult(g,e,t,{attributes:{onMouseMove:e=>a(l.select({x:e.clientX,y:e.clientY}))}}),n.renderResult(h,e,t,{attributes:{onMouseMove:e=>c(p.select({x:e.clientX,y:e.clientY-t}))}}))}},7631:(e,t,n)=>{"use strict";n.d(t,{default:()=>g});var r=n(3696),o=n.n(r),i=n(9758),a=Object.defineProperty,s=Object.getOwnPropertySymbols,c=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,u=(e,t,n)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,p=(e,t)=>{for(var n in t||(t={}))c.call(t,n)&&u(e,n,t[n]);if(s)for(var n of s(t))l.call(t,n)&&u(e,n,t[n]);return e};const d=new i.WeakmapCache2,f=[{x:300,y:200,r:100},{x:450,y:350,r:130}],g=()=>{const[e,t]=o().useState(),{width:n,height:r}=(0,i.useWindowSize)(),a={x:500,y:100},{getSnapAssistentContents:s,getSnapPoint:c}=(0,i.usePointSnap)(!0,((e,t)=>d.get(e,t,(()=>Array.from((0,i.iterateIntersectionPoints)(e,t,f,(()=>({getGeometries:e=>({lines:[{type:"arc",curve:(0,i.circleToArc)(e)}]})}))))))),i.allSnapTypes,(()=>({getSnapPoints:e=>[{x:e.x,y:e.y,type:"center"},{x:e.x-e.r,y:e.y,type:"endpoint"},{x:e.x+e.r,y:e.y,type:"endpoint"},{x:e.x,y:e.y-e.r,type:"endpoint"},{x:e.x,y:e.y+e.r,type:"endpoint"}],getGeometries:e=>({lines:[{type:"arc",curve:(0,i.circleToArc)(e)}],bounding:{start:{x:e.x-e.r,y:e.y-e.r},end:{x:e.x+e.r,y:e.y+e.r}}})})),void 0,void 0,(e=>({x:(0,i.formatNumber)(e.x,.05),y:(0,i.formatNumber)(e.y,.05)}))),l=s((e=>p({type:"circle"},e)),(e=>p({type:"rect"},e)),(e=>({type:"polyline",points:e})),(e=>p({type:"ray"},e))),u=(0,i.getGridLines)({start:{x:0,y:0},end:{x:n/2,y:r}},20);return o().createElement(o().Fragment,null,o().createElement("svg",{viewBox:`0 0 ${n/2} ${r}`,width:n/2,height:r,xmlns:"http://www.w3.org/2000/svg",fill:"none",style:{position:"absolute",left:0,top:0},onMouseMove:e=>t(c({x:e.clientX,y:e.clientY},f,void 0,a).position)},f.map(((e,t)=>o().createElement("circle",{key:t,cx:e.x,cy:e.y,r:e.r,stroke:"#000000"}))),u.map(((e,t)=>o().createElement("polyline",{key:t,points:e.map((e=>`${e.x},${e.y}`)).join(" "),stroke:"black",strokeOpacity:"0.2"}))),e&&o().createElement("polyline",{points:`${a.x},${a.y} ${e.x},${e.y}`,strokeDasharray:4,stroke:"#ff0000"}),l.map(((e,t)=>"rect"===e.type?o().createElement("rect",{key:t,x:e.x-e.width/2,y:e.y-e.height/2,width:e.width,height:e.height,stroke:"#00ff00"}):"circle"===e.type?o().createElement("circle",{key:t,cx:e.x,cy:e.y,r:e.r,stroke:"#00ff00"}):"ray"===e.type?null:o().createElement("polyline",{key:t,points:e.points.map((e=>`${e.x},${e.y}`)).join(" "),stroke:"#00ff00"}))),e&&o().createElement("circle",{cx:e.x,cy:e.y,r:5,stroke:"#ff0000"})))}},277:(e,t,n)=>{"use strict";n.d(t,{default:()=>f});var r=n(3696),o=n.n(r),i=n(9758),a=Object.defineProperty,s=Object.defineProperties,c=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,u=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable,d=(e,t,n)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;const f=()=>{const e=(0,i.useWindowSize)().width/2,t=i.reactSvgRenderTarget,[n,r]=o().useState(),[a,f]=o().useState(),g=e=>Intl.DateTimeFormat("zh",{month:"long"}).format(new Date((e+1).toString()));if(o().useEffect((()=>{const n=(0,i.getPolarAreaChart)([65,59,80,81,56,55,40],[16711680,65280,255,16711680,65280,255,0],t,{width:e,height:350},10,{left:10,right:10,top:30,bottom:10});n.angles.forEach(((e,r)=>{const o=(0,i.getArcPointAtAngle)((a=((e,t)=>{for(var n in t||(t={}))u.call(t,n)&&d(e,n,t[n]);if(l)for(var n of l(t))p.call(t,n)&&d(e,n,t[n]);return e})({},n.circle),f={r:n.circle.r+30},s(a,c(f))),e);var a,f;n.children.push(t.renderText(o.x,o.y,g(r),13421772,20,"monospace",{textAlign:"center",textBaseline:"middle"}))})),f(n)}),[e]),!a)return null;let h=a.children;return n&&(h=[...a.children,...(0,i.renderChartTooltip)(t,n,n.value,{getXLabel:g})]),o().createElement("div",{style:{position:"absolute",inset:"0px",display:"flex",flexDirection:"column"}},t.renderResult(h,e,350,{attributes:{onMouseMove:e=>r(a.select({x:e.clientX,y:e.clientY}))}}))}},574:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758);const s=()=>{const[e,t]=i().useState([]),{polygon:n,onClick:o,onMove:s,input:c,reset:l}=(0,a.usePolygonClickCreate)(!0,(o=>{const i=o||n;i&&t((0,r.produce)(e,(e=>{e.push(i)})))}));return(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&l()})),i().createElement("div",{style:{height:"100%"}},i().createElement("svg",{viewBox:"0 0 800 600",width:800,height:600,xmlns:"http://www.w3.org/2000/svg",fill:"none",style:{position:"absolute",left:0,top:0},onClick:e=>o({x:e.clientX,y:e.clientY}),onMouseMove:e=>s({x:e.clientX,y:e.clientY})},[...e,n].map(((e,t)=>e&&i().createElement("polygon",{key:t,stroke:"#00ff00",points:e.map((e=>`${e.x},${e.y}`)).join(" ")})))),c)}},597:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758);const s=()=>{const[e,t]=i().useState([{x:100,y:100},{x:300,y:200},{x:100,y:200}]),{offset:n,onStart:o,mask:s,reset:c}=(0,a.usePolylineEdit)((()=>t(l))),l=(0,r.produce)(e,(e=>{if(n)for(const t of n.pointIndexes)e[t].x+=n.x,e[t].y+=n.y}));return(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&c()})),i().createElement(i().Fragment,null,i().createElement("svg",{viewBox:"0 0 800 600",width:800,height:600,xmlns:"http://www.w3.org/2000/svg",fill:"none",style:{position:"absolute",left:0,top:0}},i().createElement("polyline",{stroke:"#00ff00",points:l.map((e=>`${e.x},${e.y}`)).join(" ")})),i().createElement(a.PolylineEditBar,{points:l,onMouseDown:(e,t)=>o(e,t)}),s)}},4623:(e,t,n)=>{"use strict";n.d(t,{default:()=>f});var r=n(3696),o=n.n(r),i=n(9758),a=Object.defineProperty,s=Object.defineProperties,c=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,u=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable,d=(e,t,n)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;const f=()=>{const e=(0,i.useWindowSize)().width/2,t=i.reactSvgRenderTarget,[n,r]=o().useState(),[a,f]=o().useState(),g=e=>Intl.DateTimeFormat("zh",{month:"long"}).format(new Date((e+1).toString()));if(o().useEffect((()=>{const n=(0,i.getRadarChart)([[65,59,80,81,56,55,40],[45,39,60,61,36,35,20]],[16711680,65280],t,{width:e,height:350},20,{left:10,right:10,top:30,bottom:30});n.angles.forEach(((e,r)=>{const o=(0,i.getArcPointAtAngle)((a=((e,t)=>{for(var n in t||(t={}))u.call(t,n)&&d(e,n,t[n]);if(l)for(var n of l(t))p.call(t,n)&&d(e,n,t[n]);return e})({},n.circle),f={r:n.circle.r+15},s(a,c(f))),e);var a,f;n.children.push(t.renderText(o.x,o.y,g(r),13421772,12,"monospace",{textAlign:"center",textBaseline:"middle"}))})),f(n)}),[e]),!a)return null;let h=a.children;return n&&(h=[...a.children,...(0,i.renderChartTooltip)(t,n,n.value,{getXLabel:g})]),o().createElement("div",{style:{position:"absolute",inset:"0px",display:"flex",flexDirection:"column"}},t.renderResult(h,e,350,{attributes:{onMouseMove:e=>r(a.select({x:e.clientX,y:e.clientY}))}}))}},4922:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(3696),o=n.n(r),i=n(9758),a=n(4469);const s=()=>{const e={x:200,y:200,r:100},t={position:{x:400,y:300},fontFamily:"monospace",fontSize:16},{regions:n,lines:r}=(0,i.getRadialDimensionGeometries)(t,e,a.dimensionStyle,((e,t)=>(0,i.getRadialDimensionTextPosition)(e,t,a.dimensionStyle.margin,i.getTextSize))),{textPosition:s,textRotation:c,text:l}=(0,i.getRadialDimensionTextPosition)(t,e,a.dimensionStyle.margin,i.getTextSize);return o().createElement("svg",{viewBox:"0 0 800 600",width:800,height:600,xmlns:"http://www.w3.org/2000/svg",fill:"none",style:{position:"absolute",left:0,top:0}},o().createElement("circle",{cx:e.x,cy:e.y,r:e.r,stroke:"black"}),r.map(((e,t)=>o().createElement("polyline",{key:t,stroke:"black",points:e.map((e=>`${e.x},${e.y}`)).join(" ")}))),n&&n.length>0&&o().createElement("polyline",{stroke:"black",points:n[0].points.map((e=>`${e.x},${e.y}`)).join(" "),fill:"black"}),o().createElement("text",{x:s.x,y:s.y,fill:"black",transform:(0,i.getRotateTransform)(s.x,s.y,{rotation:c}),style:{fontSize:`${t.fontSize}px`,fontFamily:t.fontFamily}},l))}},5982:(e,t,n)=>{"use strict";n.d(t,{default:()=>g});var r=n(3696),o=n(9758),i=Object.defineProperty,a=Object.defineProperties,s=Object.getOwnPropertyDescriptors,c=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,u=Object.prototype.propertyIsEnumerable,p=(e,t,n)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,d=(e,t)=>{for(var n in t||(t={}))l.call(t,n)&&p(e,n,t[n]);if(c)for(var n of c(t))u.call(t,n)&&p(e,n,t[n]);return e},f=(e,t)=>a(e,s(t));const g=()=>{const[e,t]=r.useState(!1),{value:n,update:i,getArrayProps:a}=(0,o.useJsonEditorData)({stringExample:"a string example",booleanExample:!1,numberExample:123.4,objectExample:{propertyExample1:"",propertyExample2:0},inlineObjectExample:{propertyExample1:"",propertyExample2:0},arrayExample:["item1","item2"],inlineArrayExample:["item1","item2"],optionalExample:void 0,enumExample:"enum 1",colorExample:"#000000",textareaExample:"",imagePreviewExample:"http://image2.sina.com.cn/bj/art/2004-08-02/U91P52T4D51657F160DT20040802125523.jpg",itemTitleExample:[{propertyExample1:"foo",propertyExample2:1},{propertyExample1:"bar",propertyExample2:2}],inlineObjectArrayExample:[{propertyExample1:"foo",propertyExample2:1,propertyExample3:{propertyExample4:2,propertyExample5:""}},{propertyExample1:"bar",propertyExample2:2,propertyExample3:{propertyExample4:3,propertyExample5:""}}],enumTitlesExample:"enum 1",enumArrayExample:["foo"]}),s=JSON.stringify(n,null," ");return r.createElement("div",{style:{position:"relative"}},r.createElement(o.BooleanEditor,{style:{display:"inline"},value:e,setValue:e=>t(e)})," read only",r.createElement("br",null),r.createElement("div",{style:{height:"400px",margin:"10px",position:"absolute",overflowY:"auto"}},r.createElement(o.ObjectEditor,{properties:{"A string example":r.createElement(o.StringEditor,{value:n.stringExample,setValue:i(((e,t)=>e.stringExample=t))}),"A boolean example":r.createElement(o.BooleanEditor,{value:n.booleanExample,setValue:i(((e,t)=>e.booleanExample=t))}),"A number example":r.createElement(o.NumberEditor,{value:n.numberExample,setValue:i(((e,t)=>e.numberExample=t))}),"A object example":r.createElement(o.ObjectEditor,{properties:{"Property example 1":r.createElement(o.StringEditor,{value:n.objectExample.propertyExample1,setValue:i(((e,t)=>e.objectExample.propertyExample1=t))}),"Property example 2":r.createElement(o.NumberEditor,{value:n.objectExample.propertyExample2,setValue:i(((e,t)=>e.objectExample.propertyExample2=t))})}}),"A inline object example":r.createElement(o.ObjectEditor,{inline:!0,properties:{"Property example 1":r.createElement(o.StringEditor,{value:n.inlineObjectExample.propertyExample1,setValue:i(((e,t)=>e.inlineObjectExample.propertyExample1=t))}),"Property example 2":r.createElement(o.NumberEditor,{value:n.inlineObjectExample.propertyExample2,setValue:i(((e,t)=>e.inlineObjectExample.propertyExample2=t))})}}),"A array example":r.createElement(o.ArrayEditor,f(d({},a((e=>e.arrayExample),"")),{items:n.arrayExample.map(((e,t)=>r.createElement(o.StringEditor,{value:e,setValue:i(((e,n)=>e.arrayExample[t]=n))})))})),"A inline array example":r.createElement(o.ArrayEditor,f(d({inline:!0},a((e=>e.inlineArrayExample),"")),{items:n.inlineArrayExample.map(((e,t)=>r.createElement(o.StringEditor,{value:e,setValue:i(((e,n)=>e.inlineArrayExample[t]=n))})))})),"A optional example":[r.createElement(o.BooleanEditor,{value:void 0!==n.optionalExample,setValue:i(((e,t)=>e.optionalExample=t?"":void 0))}),void 0!==n.optionalExample?r.createElement(o.StringEditor,{value:n.optionalExample,setValue:i(((e,t)=>e.optionalExample=t))}):void 0],"A enum example":r.createElement(o.EnumEditor,{value:n.enumExample,enums:["enum 1","enum 2"],setValue:i(((e,t)=>e.enumExample=t))}),"A enum example 2":r.createElement(o.EnumEditor,{select:!0,value:n.enumExample,enums:["enum 1","enum 2"],setValue:i(((e,t)=>e.enumExample=t))}),"A color example":r.createElement(o.StringEditor,{type:"color",value:n.colorExample,setValue:i(((e,t)=>e.colorExample=t))}),"A textarea example":r.createElement(o.StringEditor,{textarea:!0,value:n.textareaExample,setValue:i(((e,t)=>e.textareaExample=t))}),"A image preview example":r.createElement(o.StringEditor,{value:n.imagePreviewExample,setValue:i(((e,t)=>e.imagePreviewExample=t))}),"A item title example":r.createElement(o.ArrayEditor,f(d({},a((e=>e.itemTitleExample),{propertyExample1:"",propertyExample2:0})),{title:e=>n.itemTitleExample[e].propertyExample1,items:n.itemTitleExample.map(((e,t)=>r.createElement(o.ObjectEditor,{properties:{"Property example 1":r.createElement(o.StringEditor,{value:e.propertyExample1,setValue:i(((e,n)=>e.itemTitleExample[t].propertyExample1=n))}),"Property example 2":r.createElement(o.NumberEditor,{value:e.propertyExample2,setValue:i(((e,n)=>e.itemTitleExample[t].propertyExample2=n))})}})))})),"A inline object array example":r.createElement(o.ObjectArrayEditor,f(d({},a((e=>e.inlineObjectArrayExample),{propertyExample1:"",propertyExample2:0,propertyExample3:{propertyExample4:0,propertyExample5:""}})),{properties:n.inlineObjectArrayExample.map(((e,t)=>({"Property example 1":r.createElement(o.StringEditor,{value:e.propertyExample1,setValue:i(((e,n)=>e.inlineObjectArrayExample[t].propertyExample1=n))}),"Property example 2":r.createElement(o.NumberEditor,{value:e.propertyExample2,setValue:i(((e,n)=>e.inlineObjectArrayExample[t].propertyExample2=n))}),"Property example 3":r.createElement(o.DialogContainer,null,r.createElement(o.ObjectEditor,{inline:!0,properties:{"Property example 3":r.createElement(o.NumberEditor,{value:e.propertyExample3.propertyExample4,setValue:i(((e,n)=>e.inlineObjectArrayExample[t].propertyExample3.propertyExample4=n))}),"Property example 4":r.createElement(o.StringEditor,{value:e.propertyExample3.propertyExample5,setValue:i(((e,n)=>e.inlineObjectArrayExample[t].propertyExample3.propertyExample5=n))})}}))})))})),"A enum titles example":r.createElement(o.EnumEditor,{enumTitles:["enum title 1","enum title 2"],value:n.enumTitlesExample,enums:["enum 1","enum 2"],setValue:i(((e,t)=>e.enumTitlesExample=t))}),"A enum array example":r.createElement(o.EnumArrayEditor,{enumTitles:["foo title","bar title"],value:n.enumArrayExample,enums:["foo","bar"],setValue:i(((e,t)=>e.enumArrayExample=t))})},readOnly:e})),r.createElement("div",{style:{margin:"10px",position:"absolute",top:"450px"}},r.createElement("pre",{style:{borderColor:"black",padding:"10px"}},r.createElement("code",{dangerouslySetInnerHTML:{__html:s}}))))}},7560:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(3696),o=n.n(r),i=n(9758),a=n(5052);const s=()=>{const e=e=>e.renderResult([e.renderArc(40,20,50,0,120,{fillPattern:{width:10,height:10,pattern:()=>e.renderPath([[{x:0,y:5},{x:5,y:0}],[{x:10,y:5},{x:5,y:10}]],{strokeColor:255})}}),e.renderArc(40,40,80,0,120,{fillColor:16711680,strokeWidth:0}),e.renderArc(50,50,100,0,120,{strokeColor:65280}),e.renderArc(60,60,100,0,120,{strokeWidth:5}),e.renderArc(70,70,100,0,120,{dashArray:[4]}),e.renderArc(170,170,30,0,120,{counterclockwise:!0}),e.renderArc(170,170,20,120,0,{counterclockwise:!0}),e.renderArc(120,200,15,0,360),e.renderArc(120,200,10,360,0,{counterclockwise:!0}),e.renderArc(170,170,10,0,120,{closed:!0})],230,310),t=e=>e.renderResult([e.renderCircle(70,100,30,{fillPattern:{width:10,height:10,pattern:()=>e.renderPath([[{x:0,y:5},{x:5,y:0}],[{x:10,y:5},{x:5,y:10}]],{strokeColor:255})}}),e.renderCircle(150,100,30,{fillColor:16711680,strokeWidth:0}),e.renderCircle(110,100,70,{strokeColor:65280}),e.renderCircle(110,100,80,{strokeWidth:5}),e.renderCircle(110,100,90,{dashArray:[4]})],230,200),n=e=>e.renderResult([e.renderText(10,30,"Hello World!",16711680,30,"monospace"),e.renderText(10,60,"Hello World!",16711680,30,"monospace",{fontWeight:"bold"}),e.renderText(10,90,"Hello World!",16711680,30,"monospace",{fontStyle:"italic"}),e.renderText(10,150,"He",{width:4,height:4,pattern:()=>e.renderPath([[{x:0,y:2},{x:2,y:0}],[{x:4,y:2},{x:2,y:4}]],{strokeColor:255})},70,"monospace"),e.renderText(90,150,"l",void 0,70,"monospace",{strokeColor:16711680}),e.renderText(130,150,"l",void 0,70,"monospace",{strokeColor:16711680,dashArray:[2]}),e.renderText(170,150,"l",void 0,70,"monospace",{strokeColor:16711680,strokeWidth:3}),e.renderText(10,200,"H",65280,70,"monospace",{strokeColor:16711680,strokeWidth:3}),e.renderText(50,200,"H",65280,70,"monospace",{strokeColor:16711680,strokeWidth:3,strokeOpacity:.3,fillOpacity:.3}),e.renderText(90,200,"H",void 0,70,"monospace",{strokePattern:{width:4,height:4,pattern:()=>e.renderPath([[{x:0,y:2},{x:2,y:0}],[{x:4,y:2},{x:2,y:4}]],{strokeColor:255})},strokeWidth:3}),e.renderText(130,200,"H",void 0,70,"monospace",{strokeLinearGradient:{start:{x:150,y:230},end:{x:190,y:150},stops:[{offset:.2,color:16711680},{offset:.5,color:16776960},{offset:.8,color:65280}]},strokeWidth:3}),e.renderText(170,200,"H",void 0,70,"monospace",{strokeRadialGradient:{start:{x:190,y:185,r:5},end:{x:190,y:180,r:30},stops:[{offset:0,color:16711680},{offset:.5,color:16776960},{offset:1,color:65280}]},strokeWidth:3}),e.renderText(70,225,"center",65280,30,"monospace",{textAlign:"center"}),e.renderText(130,250,"right",65280,30,"monospace",{textAlign:"right"}),e.renderText(130,250,"H",void 0,70,"monospace",{fillLinearGradient:{start:{x:150,y:280},end:{x:190,y:200},stops:[{offset:.2,color:16711680},{offset:.5,color:16776960},{offset:.8,color:65280}]},strokeWidth:3}),e.renderText(170,250,"H",void 0,70,"monospace",{fillRadialGradient:{start:{x:190,y:235,r:5},end:{x:190,y:230,r:30},stops:[{offset:0,color:16711680},{offset:.5,color:16776960},{offset:1,color:65280}]},strokeWidth:3}),e.renderText(10,300,"fgj",65280,30,"monospace",{textBaseline:"alphabetic"}),e.renderText(65,300,"fgj",65280,30,"monospace",{textBaseline:"top"}),e.renderText(120,300,"fgj",65280,30,"monospace",{textBaseline:"middle"}),e.renderText(175,300,"fgj",65280,30,"monospace",{textBaseline:"bottom"})],230,550),r=e=>e.renderResult([e.renderEllipseArc(40,10,50,30,0,120,{fillPattern:{width:10,height:10,pattern:()=>e.renderPath([[{x:0,y:5},{x:5,y:0}],[{x:10,y:5},{x:5,y:10}]],{strokeColor:255})}}),e.renderEllipseArc(40,30,80,40,0,120,{fillColor:16711680,strokeWidth:0}),e.renderEllipseArc(50,40,100,50,0,120,{strokeColor:65280}),e.renderEllipseArc(60,50,100,50,0,120,{strokeWidth:5}),e.renderEllipseArc(70,60,100,50,0,120,{dashArray:[4]}),e.renderEllipseArc(170,160,30,15,0,120,{counterclockwise:!0}),e.renderEllipseArc(170,160,30,25,120,20,{counterclockwise:!0}),e.renderEllipseArc(110,100,80,40,0,120,{strokeColor:65280,angle:30}),e.renderEllipseArc(120,200,30,15,0,360),e.renderEllipseArc(120,200,20,10,360,0,{counterclockwise:!0}),e.renderEllipseArc(170,160,25,20,0,120,{closed:!0})],230,330),s=e=>e.renderResult([e.renderEllipse(70,60,40,20,{fillPattern:{width:10,height:10,pattern:()=>e.renderPath([[{x:0,y:5},{x:5,y:0}],[{x:10,y:5},{x:5,y:10}]],{strokeColor:255})}}),e.renderEllipse(150,60,40,20,{fillColor:16711680,strokeWidth:0}),e.renderEllipse(110,60,90,45,{strokeColor:65280}),e.renderEllipse(110,60,100,50,{strokeWidth:5}),e.renderEllipse(110,60,110,55,{dashArray:[4]}),e.renderEllipse(110,140,80,40,{strokeColor:255,angle:30}),e.renderEllipse(110,30,10,20,{angle:60,fillPattern:{width:10,height:10,pattern:()=>e.renderPath([[{x:0,y:5},{x:5,y:0}],[{x:10,y:5},{x:5,y:10}]],{strokeColor:255})}})],230,230),c=e=>e.renderResult([e.renderRect(10,10,50,30,{fillPattern:{width:10,height:10,pattern:()=>e.renderPath([[{x:0,y:5},{x:5,y:0}],[{x:10,y:5},{x:5,y:10}]],{strokeColor:255})}}),e.renderRect(70,10,80,40,{fillColor:16711680,strokeWidth:0}),e.renderRect(90,60,100,140,{strokeColor:65280}),e.renderRect(100,70,80,120,{strokeWidth:5}),e.renderRect(110,80,60,100,{dashArray:[4]}),e.renderRect(10,90,60,30,{angle:60})],230,220),l=e=>e.renderResult([e.renderPath([[{x:5,y:10},{x:45,y:150},{x:45,y:10}],[{x:25,y:30},{x:25,y:70},{x:35,y:70},{x:35,y:30}]],{fillPattern:{width:10,height:10,pattern:()=>e.renderPath([[{x:0,y:5},{x:5,y:0}],[{x:10,y:5},{x:5,y:10}]],{strokeColor:255})},strokeWidth:0}),e.renderPath([[{x:50,y:10},{x:90,y:150},{x:90,y:10}],[{x:70,y:30},{x:70,y:70},{x:80,y:70},{x:80,y:30}]],{fillColor:16711680,strokeWidth:0}),e.renderPath([[{x:95,y:10},{x:135,y:150},{x:135,y:10}],[{x:115,y:30},{x:115,y:70},{x:125,y:70},{x:125,y:30}]],{strokeColor:65280}),e.renderPath([[{x:140,y:10},{x:180,y:150},{x:180,y:10}],[{x:160,y:30},{x:160,y:70},{x:170,y:70},{x:170,y:30}]],{fillPattern:{width:100,height:100,pattern:()=>e.renderImage("https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg",0,0,100,100,{crossOrigin:""})},strokeWidth:0}),e.renderPath([[{x:185,y:10},{x:225,y:150},{x:225,y:10}],[{x:205,y:30},{x:205,y:70},{x:215,y:70},{x:215,y:30}]],{dashArray:[4]}),e.renderPath([[{x:5,y:160},{x:35,y:160},{x:35,y:190}]],{strokeColor:16711680,strokeWidth:5}),e.renderPath([[{x:45,y:160},{x:75,y:160},{x:75,y:190}]],{strokeColor:16711680,strokeWidth:5,closed:!0}),e.renderPath([[{x:85,y:160},{x:125,y:160},{x:125,y:190}]],{strokeColor:16711680,strokeWidth:5,closed:!0,miterLimit:2}),e.renderPath([[{x:135,y:160},{x:175,y:160},{x:175,y:190}]],{strokeColor:16711680,strokeWidth:10,lineJoin:"bevel"}),e.renderPath([[{x:185,y:160},{x:225,y:160},{x:225,y:190}]],{strokeColor:16711680,strokeWidth:10,lineJoin:"round"}),e.renderPath([[{x:10,y:210},{x:40,y:210},{x:40,y:240}]],{strokeColor:16711680,strokeWidth:10,lineCap:"square"}),e.renderPath([[{x:55,y:210},{x:85,y:210},{x:85,y:240}]],{strokeColor:16711680,strokeWidth:10,lineCap:"round"}),e.renderPath([[{x:100,y:210},{x:220,y:210}]],{dashArray:[12,4]}),e.renderPath([[{x:100,y:220},{x:220,y:220}]],{dashArray:[12,4],dashOffset:4}),e.renderPath([[{x:5,y:250},{x:45,y:390},{x:45,y:250}],[{x:25,y:270},{x:25,y:310},{x:35,y:310},{x:35,y:270}]],{fillLinearGradient:{start:{x:5,y:250},end:{x:45,y:390},stops:[{offset:.2,color:16711680},{offset:.5,color:16776960},{offset:.8,color:65280}]},strokeWidth:0}),e.renderPath([[{x:50,y:250},{x:90,y:390},{x:90,y:250}],[{x:70,y:270},{x:70,y:310},{x:80,y:310},{x:80,y:270}]],{fillRadialGradient:{start:{x:70,y:320,r:10},end:{x:70,y:320,r:70},stops:[{offset:0,color:16711680},{offset:.5,color:16776960},{offset:1,color:65280}]},strokeWidth:0}),e.renderPath([[{x:95,y:250},{x:135,y:390},{x:135,y:250}],[{x:115,y:270},{x:115,y:310},{x:125,y:310},{x:125,y:270}]],{fillColor:16711680,fillOpacity:.3,strokeOpacity:.3}),e.renderPath([[{x:140,y:250},{x:180,y:390},{x:180,y:250}],[{x:160,y:270},{x:160,y:310},{x:170,y:310},{x:170,y:270}]],{fillRadialGradient:{start:{x:160,y:320,r:10},end:{x:160,y:320,r:70},stops:[{offset:0,color:16711680,opacity:.3},{offset:.5,color:16776960,opacity:.3},{offset:1,color:65280,opacity:.3}]},strokeWidth:0}),e.renderPath([[{x:185,y:250},{x:225,y:390},{x:225,y:250}],[{x:205,y:270},{x:205,y:310},{x:215,y:310},{x:215,y:270}]],{strokePattern:{width:10,height:10,pattern:()=>e.renderPath([[{x:0,y:5},{x:5,y:0}],[{x:10,y:5},{x:5,y:10}]],{strokeColor:255})},strokeWidth:5}),e.renderPath([[{x:5,y:400},{x:45,y:540},{x:45,y:400}],[{x:25,y:420},{x:25,y:460},{x:35,y:460},{x:35,y:420}]],{strokeLinearGradient:{start:{x:5,y:400},end:{x:45,y:540},stops:[{offset:.2,color:16711680},{offset:.5,color:16776960},{offset:.8,color:65280}]},strokeWidth:5}),e.renderPath([[{x:50,y:400},{x:90,y:540},{x:90,y:400}],[{x:70,y:420},{x:70,y:460},{x:80,y:460},{x:80,y:420}]],{strokeRadialGradient:{start:{x:70,y:470,r:10},end:{x:70,y:470,r:70},stops:[{offset:0,color:16711680},{offset:.5,color:16776960},{offset:1,color:65280}]},strokeWidth:5}),e.renderPath([[{x:110,y:400},{x:110,y:470},{x:110,y:540}]],{strokeColor:16711680,strokeWidth:10}),e.renderPath([[{x:130,y:400},{x:130,y:540},{x:130,y:470}]],{strokeColor:16711680,strokeWidth:10})],230,620),u=e=>e.renderResult([e.renderImage("https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg",0,0,75,65,{crossOrigin:""}),e.renderImage("https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg",77,0,75,65,{opacity:.5,crossOrigin:""}),e.renderImage("https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg",154,0,75,65,{filters:[{type:"brightness",value:2}],crossOrigin:""}),e.renderImage("https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg",0,70,75,65,{filters:[{type:"contrast",value:2}],crossOrigin:""}),e.renderImage("https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg",77,70,75,65,{filters:[{type:"hue-rotate",value:90}],crossOrigin:""}),e.renderImage("https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg",154,70,75,65,{filters:[{type:"saturate",value:2}],crossOrigin:""}),e.renderImage("https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg",0,140,75,65,{filters:[{type:"saturate",value:2},{type:"hue-rotate",value:90}],crossOrigin:""}),e.renderImage("https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg",77,140,75,65,{filters:[{type:"saturate",value:2},{type:"hue-rotate",value:90},{type:"contrast",value:2}],crossOrigin:""}),e.renderImage("https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg",154,140,75,65,{filters:[{type:"grayscale",value:1}],crossOrigin:""}),e.renderImage("https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg",0,210,75,65,{filters:[{type:"sepia",value:1}],crossOrigin:""}),e.renderImage("https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg",77,210,75,65,{filters:[{type:"invert",value:1}],crossOrigin:""}),e.renderImage("https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg",154,210,75,65,{filters:[{type:"opacity",value:.5}],crossOrigin:""}),e.renderImage("https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg",0,280,75,65,{filters:[{type:"blur",value:2}],crossOrigin:""})],230,370),p=e=>e.renderResult([e.renderPolyline([{x:5,y:10},{x:45,y:150},{x:45,y:10}],{fillPattern:{width:10,height:10,pattern:()=>e.renderPath([[{x:0,y:5},{x:5,y:0}],[{x:10,y:5},{x:5,y:10}]],{strokeColor:255})}}),e.renderPolyline([{x:50,y:10},{x:90,y:150},{x:90,y:10}],{fillColor:16711680,strokeWidth:0}),e.renderPolyline([{x:95,y:10},{x:135,y:150},{x:135,y:10}],{strokeColor:65280}),e.renderPolyline([{x:140,y:10},{x:180,y:150},{x:180,y:10}],{strokeWidth:5}),e.renderPolyline([{x:185,y:10},{x:225,y:150},{x:225,y:10}],{dashArray:[4]}),e.renderPolyline([{x:195,y:10},{x:215,y:80},{x:215,y:10}],{closed:!0})],230,220),d=e=>e.renderResult([e.renderPolygon([{x:5,y:10},{x:45,y:150},{x:45,y:10}],{fillPattern:{width:10,height:10,pattern:()=>e.renderPath([[{x:0,y:5},{x:5,y:0}],[{x:10,y:5},{x:5,y:10}]],{strokeColor:255})}}),e.renderPolygon([{x:50,y:10},{x:90,y:150},{x:90,y:10}],{fillColor:16711680,strokeWidth:0}),e.renderPolygon([{x:95,y:10},{x:135,y:150},{x:135,y:10}],{strokeColor:65280}),e.renderPolygon([{x:140,y:10},{x:180,y:150},{x:180,y:10}],{strokeWidth:5}),e.renderPolygon([{x:185,y:10},{x:225,y:150},{x:225,y:10}],{dashArray:[4]})],230,190),f=e=>e.renderResult([e.renderPathCommands([{type:"move",to:{x:220,y:10}},{type:"arc",from:{x:220,y:80},to:{x:150,y:10},radius:20},{type:"line",to:{x:150,y:10}},{type:"quadraticCurve",cp:{x:150,y:90},to:{x:110,y:70}},{type:"bezierCurve",cp1:{x:70,y:20},cp2:{x:40,y:80},to:{x:10,y:10}},{type:"ellipseArc",rx:30,ry:20,angle:0,largeArc:!1,sweep:!0,to:{x:50,y:30}}],{strokeColor:65280}),e.renderPathCommands([{type:"move",to:{x:210,y:10}},{type:"arc",from:{x:210,y:80},to:{x:160,y:10},radius:20},{type:"line",to:{x:160,y:10}}],{closed:!0})],230,120),g=e=>{const t=[e.renderCircle(50,50,20),e.renderCircle(50,50,35),e.renderText(0,40,"abc",16711680,30,"monospace"),e.renderGroup([e.renderCircle(50,50,15)],{translate:{x:20,y:20}})];return e.renderResult([e.renderGroup(t,{opacity:.2,translate:{x:10,y:0}}),e.renderRect(120,10,80,80,{clip:()=>e.renderGroup(t,{translate:{x:100,y:0}})}),e.renderCircle(180,150,50,{clip:()=>e.renderGroup(t,{matrix:i.m3.multiply(i.m3.translation(150,150),i.m3.scaling(.7,.7))})}),e.renderPath([[{x:0,y:200},{x:120,y:200},{x:120,y:300},{x:0,y:300},{x:0,y:200}],[{x:55,y:230},{x:90,y:220},{x:90,y:260},{x:50,y:260},{x:55,y:230}]],{clip:()=>e.renderGroup(t,{translate:{x:10,y:200}}),strokeWidth:0}),e.renderPolygon([{x:55,y:230},{x:90,y:220},{x:90,y:260},{x:50,y:260}]),e.renderRect(30,100,80,80,{clip:()=>e.renderGroup([e.renderCircle(90,50,20,{fillPattern:{width:10,height:10,pattern:()=>e.renderPath([[{x:0,y:5},{x:5,y:0}],[{x:10,y:5},{x:5,y:10}]],{strokeColor:255})}}),e.renderCircle(30,50,20)],{translate:{x:10,y:90}})}),e.renderGroup(t,{translate:{x:110,y:200},base:{x:50,y:50},scale:{x:.6,y:.3}})],230,550)},h=e=>e.renderResult([e.renderRay(50,50,30),e.renderRay(80,50,30,{bidirectional:!0}),e.renderGroup([e.renderRay(60,60,30),e.renderGroup([e.renderRay(60,60,30)],{translate:{x:0,y:-20}})],{translate:{x:-20,y:0}})],230,90),{setOffset:m}=o().useContext(a.OffsetXContext);return o().useEffect((()=>{navigator.gpu&&(null==m||m(230))}),[m]),o().createElement("div",null,o().createElement("div",{style:{display:"flex",height:"40px",alignItems:"center",fontSize:"25px",justifyContent:"space-around"}},o().createElement("span",null,i.reactSvgRenderTarget.type),o().createElement("span",null,i.reactCanvasRenderTarget.type),o().createElement("span",null,i.reactWebglRenderTarget.type),navigator.gpu&&o().createElement("span",null,i.reactWebgpuRenderTarget.type)),e(i.reactSvgRenderTarget),e(i.reactCanvasRenderTarget),e(i.reactWebglRenderTarget),navigator.gpu&&e(i.reactWebgpuRenderTarget),o().createElement("br",null),t(i.reactSvgRenderTarget),t(i.reactCanvasRenderTarget),t(i.reactWebglRenderTarget),navigator.gpu&&t(i.reactWebgpuRenderTarget),o().createElement("br",null),n(i.reactSvgRenderTarget),n(i.reactCanvasRenderTarget),n(i.reactWebglRenderTarget),navigator.gpu&&n(i.reactWebgpuRenderTarget),o().createElement("br",null),r(i.reactSvgRenderTarget),r(i.reactCanvasRenderTarget),r(i.reactWebglRenderTarget),navigator.gpu&&r(i.reactWebgpuRenderTarget),o().createElement("br",null),s(i.reactSvgRenderTarget),s(i.reactCanvasRenderTarget),s(i.reactWebglRenderTarget),navigator.gpu&&s(i.reactWebgpuRenderTarget),o().createElement("br",null),c(i.reactSvgRenderTarget),c(i.reactCanvasRenderTarget),c(i.reactWebglRenderTarget),navigator.gpu&&c(i.reactWebgpuRenderTarget),o().createElement("br",null),l(i.reactSvgRenderTarget),l(i.reactCanvasRenderTarget),l(i.reactWebglRenderTarget),navigator.gpu&&l(i.reactWebgpuRenderTarget),o().createElement("br",null),u(i.reactSvgRenderTarget),u(i.reactCanvasRenderTarget),u(i.reactWebglRenderTarget),navigator.gpu&&u(i.reactWebgpuRenderTarget),o().createElement("br",null),p(i.reactSvgRenderTarget),p(i.reactCanvasRenderTarget),p(i.reactWebglRenderTarget),navigator.gpu&&p(i.reactWebgpuRenderTarget),o().createElement("br",null),d(i.reactSvgRenderTarget),d(i.reactCanvasRenderTarget),d(i.reactWebglRenderTarget),navigator.gpu&&d(i.reactWebgpuRenderTarget),o().createElement("br",null),f(i.reactSvgRenderTarget),f(i.reactCanvasRenderTarget),f(i.reactWebglRenderTarget),navigator.gpu&&f(i.reactWebgpuRenderTarget),o().createElement("br",null),g(i.reactSvgRenderTarget),g(i.reactCanvasRenderTarget),g(i.reactWebglRenderTarget),navigator.gpu&&g(i.reactWebgpuRenderTarget),o().createElement("br",null),h(i.reactSvgRenderTarget),h(i.reactCanvasRenderTarget),h(i.reactWebglRenderTarget),navigator.gpu&&h(i.reactWebgpuRenderTarget))}},4339:(e,t,n)=>{"use strict";n.d(t,{default:()=>c});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758),s=n(9299);const c=()=>{const[e,t]=i().useState(s.defaultContents),[n,o]=i().useState(0),{regionAlignmentX:c,regionAlignmentY:l,changeOffsetByRegionAlignment:u,clearRegionAlignments:p}=(0,a.useRegionAlignment)(10),{offset:d,onStart:f,mask:g,startPosition:h,resetDragMove:m}=(0,a.useDragMove)((()=>{p(),0!==d.x||0!==d.y||void 0===(null==h?void 0:h.data)?t((0,r.produce)(e,(e=>{e[n].x+=d.x,e[n].y+=d.y}))):o(h.data)}),{transformOffset:(t,r)=>((null==r?void 0:r.shiftKey)?p():u(t,e[n],e.filter(((e,t)=>t!==n))),t)});return(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&m()})),i().createElement(i().Fragment,null,e.map(((e,t)=>i().createElement("div",{key:t,style:{width:`${e.width}px`,height:`${e.height}px`,left:`${e.x+(n===t?d.x:0)}px`,top:`${e.y+(n===t?d.y:0)}px`,position:"absolute",boxSizing:"border-box",background:`url(${e.url})`,backgroundSize:"contain",border:n===t?"1px solid green":void 0},onMouseDown:e=>f({x:e.clientX,y:e.clientY},{data:t})}))),i().createElement(a.AlignmentLine,{type:"x",value:c}),i().createElement(a.AlignmentLine,{type:"y",value:l}),g)}},6286:(e,t,n)=>{"use strict";n.d(t,{richTextData:()=>r});const r=[{type:"h2",blockStart:13.28,blockEnd:13.28,children:[{text:"G"},{text:"e"},{text:"t"},{text:"t"},{text:"i"},{text:"n"},{text:"g"},{text:" "},{text:"u"},{text:"s"},{text:"e"},{text:"d"},{text:" "},{text:"t"},{text:"o"},{text:" "},{text:"a"},{text:"n"},{text:" "},{text:"e"},{text:"n"},{text:"t"},{text:"i"},{text:"r"},{text:"e"},{text:"l"},{text:"y"}]},{type:"p",blockStart:16,blockEnd:16,children:[{text:"d"},{text:"i"},{text:"f"},{text:"f"},{text:"e"},{text:"r"},{text:"e"},{text:"n"},{text:"t"},{text:" "},{text:"c"},{text:"u"},{text:"l"},{text:"t"},{text:"u"},{text:"r"},{text:"e"},{text:" "},{text:"c"},{text:"a"},{text:"n"},{text:" "},{text:"b"},{text:"e"},{text:" "},{text:"c",underline:!0},{text:"h",underline:!0},{text:"a",underline:!0},{text:"l",underline:!0},{text:"l",underline:!0},{text:"e",underline:!0},{text:"n",underline:!0},{text:"g",underline:!0},{text:"i",underline:!0},{text:"n",underline:!0},{text:"g",underline:!0},{text:"."},{text:"abc",type:"link",targetBlank:!0,url:"abc"},{text:" "},{text:" "},{text:"W"},{text:"h"},{text:"i"},{text:"l"},{text:"e"},{text:" "},{text:"i"},{text:"t"},{text:"’"},{text:"s"},{text:" "},{text:"a"},{text:"l"},{text:"s"},{text:"o"},{text:" "},{text:"n"},{text:"i"},{text:"c"},{text:"e"},{text:" "},{text:"t"},{text:"o"},{text:" "},{text:"l"},{text:"e"},{text:"a"},{text:"r"},{text:"n"},{text:" "},{text:"a"},{text:"b"},{text:"o"},{text:"u"},{text:"t"},{text:" "},{text:"c",type:"code",backgroundColor:15921649},{text:"u",type:"code",backgroundColor:15921649},{text:"l",type:"code",backgroundColor:15921649},{text:"t",type:"code",backgroundColor:15921649},{text:"u",type:"code",backgroundColor:15921649},{text:"r",type:"code",backgroundColor:15921649},{text:"e",type:"code",backgroundColor:15921649},{text:"s",type:"code",backgroundColor:15921649},{text:" "},{text:"o"},{text:"n"},{text:"l"},{text:"i"},{text:"n"},{text:"e"},{text:" "},{text:"o"},{text:"r"},{text:" "},{text:"f"},{text:"r"},{text:"o"},{text:"m"},{text:" "},{text:"b"},{text:"o"},{text:"o"},{text:"k"},{text:"s"},{text:","},{text:" "},{text:"d"},{text:"d"},{text:"d"},{text:" "},{text:"c"},{text:"o"},{text:"m"},{text:"e"},{text:"s"},{text:" "},{text:"c",type:"span"},{text:"l",type:"span"},{text:"o",type:"span"},{text:"s",type:"span"},{text:"e",type:"span"},{text:" "},{text:"t"},{text:"o"},{text:" "},{text:"e",bold:!1},{text:"x",bold:!1},{text:"p",bold:!1},{text:"e",bold:!1},{text:"r",bold:!1},{text:"i",bold:!1},{text:"e",bold:!1},{text:"n",bold:!1},{text:"c",bold:!1},{text:"i",bold:!1},{text:"n",bold:!1},{text:"g",bold:!1},{text:"a",bold:!1},{text:" "},{text:"c"},{text:"u"},{text:"l"},{text:"t"},{text:"u"},{text:"r"},{text:"a"},{text:"l"},{text:" "},{text:"d"},{text:"i"},{text:"v"},{text:"e"},{text:"r"},{text:"s"},{text:"i"},{text:"t"},{text:"y"},{text:" "},{text:"i"},{text:"n"},{text:" "},{text:"p"},{text:"e"},{text:"r"},{text:"s"},{text:"o"},{text:"n"},{text:"."},{text:" "},{text:"Y"},{text:"o"},{text:"u"},{text:"A",type:"circle"},{text:" "},{text:"B",type:"stack",bottomText:"C"},{text:" "},{text:"l"},{text:"e"},{text:"a"},{text:"r"},{text:"n"},{text:"a"},{text:"a"},{text:"啊"},{text:"啊"},{text:" "},{text:"t"},{text:"o"},{text:" "},{text:"a"},{text:"p",bold:!0,italic:!0,underline:!0,passThrough:!0},{text:"p",bold:!0,italic:!0,underline:!0,passThrough:!0},{text:"r",bold:!0,italic:!0,underline:!0,passThrough:!0},{text:"e",bold:!0,italic:!0,underline:!0,passThrough:!0},{text:"c",bold:!0,italic:!0,underline:!0,passThrough:!0},{text:"i",bold:!0,italic:!0,underline:!0,passThrough:!0},{text:"a"},{text:"t"},{text:"e"},{text:" "},{text:"e"},{text:"a"},{text:"c"},{text:"h"},{text:" "},{text:"a"},{text:"n"},{text:"d"},{text:" "},{text:"e"},{text:"v"},{text:"e"},{text:"r"},{text:"y"},{text:" "},{text:"s"},{text:"i"},{text:"n"},{text:"g"},{text:"l"},{text:"e"},{text:" "},{text:"o"},{text:"n"},{text:"e"},{text:" "},{text:"o"},{text:"f"},{text:" "},{text:"t"},{text:"h"},{text:"e"},{text:" "},{text:"d"},{text:"i"},{text:"f"},{text:"f"},{text:"e"},{text:"r"},{text:"e"},{text:"n"},{text:"c"},{text:"e"},{text:"s"},{text:" "},{text:"x"},{text:"2",type:"sub"},{text:"2",type:"sup"},{text:" "},{text:"2"},{text:" "},{text:"w"},{text:"h"},{text:"i"},{text:"l"},{text:"e"},{text:" "},{text:"y"},{text:"o"},{text:"u"},{text:" "},{text:"b"},{text:"e"},{text:"c"},{text:"o"},{text:"m"},{text:"e"},{text:" "},{text:"m"},{text:"o"},{text:"r"},{text:"e"},{text:" "},{text:"c"},{text:"u"},{text:"l"},{text:"t"},{text:"u"},{text:"r"},{text:"a"},{text:"l"},{text:"l"},{text:"y"},{text:" "},{text:"f"},{text:"l"},{text:"u"},{text:"i"},{text:"d"},{text:"."},{text:"<"},{text:"a"},{text:">"},{text:" "},{text:"@aa_2",color:16777215,backgroundColor:255},{text:" "},{text:" "},{text:"s"},{text:"d"},{text:"a"},{text:"d"},{text:" "},{text:"a"},{text:"f"},{text:"f"},{text:"s"},{text:" "},{text:"f"},{text:"d"},{text:"f"},{text:"d"},{text:"s"},{text:"f"},{text:"@aa_1",color:16777215,backgroundColor:255},{text:" "},{text:"@aa_1",color:16777215,backgroundColor:255},{text:" "},{text:"@aa_1",color:16777215,backgroundColor:255},{text:" "}]},{type:"ul",blockStart:16,blockEnd:16,children:[{text:"a"},{text:"a"}],inlineStart:40},{type:"ul",blockStart:16,blockEnd:16,children:[{text:"b"},{text:"b"}],inlineStart:40},{blockStart:.5,blockEnd:.5,void:!0,type:"hr",children:[]},{type:"ol",blockStart:16,blockEnd:16,children:[{text:"a"},{text:"a"},{text:"x"}],inlineStart:40,listStyleType:"decimal"},{type:"ol",blockStart:16,blockEnd:16,children:[{text:"https://stackoverflow.com/",type:"link",underline:!0,color:5577354,targetBlank:!0,url:"https://stackoverflow.com/"}],inlineStart:40,listStyleType:"decimal"},{type:"p",blockStart:16,blockEnd:16,children:[{text:"c",type:"code",backgroundColor:15921649},{text:"o",type:"code",backgroundColor:15921649},{text:"d",type:"code",backgroundColor:15921649},{text:"e",type:"code",backgroundColor:15921649}],fontSize:16},{type:"p",blockStart:16,blockEnd:16,children:[{url:"https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg",width:263.0291970802921,height:180.17499999999998,text:" "},{kind:"image",url:"https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg",width:192.27007299270085,height:131.705},{url:"https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg",width:195.8759124087592,height:134.17499999999998,text:" "},{url:"tyejtey",text:"tyejtey",type:"link",targetBlank:!0},{url:"https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg",width:195.8759124087592,height:134.17499999999998,text:" "}],fontSize:16},{type:"p",blockStart:16,blockEnd:16,children:[{text:"a",type:"mark",backgroundColor:16776960},{text:"a",type:"mark",backgroundColor:16776960},{text:"s",type:"mark",backgroundColor:16776960},{text:"a",type:"mark",backgroundColor:16776960},{text:" ",type:"mark",backgroundColor:16776960}],fontSize:16}]},7310:(e,t,n)=>{"use strict";n.d(t,{useAt:()=>p});var r=n(3696),o=n.n(r),i=Object.defineProperty,a=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,c=Object.prototype.propertyIsEnumerable,l=(e,t,n)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,u=(e,t)=>{for(var n in t||(t={}))s.call(t,n)&&l(e,n,t[n]);if(a)for(var n of a(t))c.call(t,n)&&l(e,n,t[n]);return e};const p=({cursor:e,cursorHeight:t,inputText:n})=>{const[r,i]=o().useState(""),[a,s]=o().useState(0),c={color:16777215,backgroundColor:255};return{processInput(e){if(r){if(1===e.key.length&&e.key>="a"&&e.key<="z")return i((t=>t+e.key)),e.preventDefault(),!0;if("Enter"===e.key&&r){const e=u({text:r+"_"+a},c);return n([e," "]),i(""),!0}if("Escape"===e.key)return i(""),e.preventDefault(),!0;if("ArrowDown"===e.key)return s((a+1)%5),e.preventDefault(),!0;if("ArrowUp"===e.key)return s((a+4)%5),e.preventDefault(),!0;if("Backspace"===e.key)return r.length>1?i((e=>e.slice(0,e.length-1))):i(""),e.preventDefault(),!0}return"@"===e.key&&(i("@"),e.preventDefault(),!0)},ui:r?o().createElement("div",{style:{position:"absolute",left:e.x+"px",top:e.y+t+"px",background:"white",width:"100px",border:"1px solid black"}},o().createElement("div",null,r),new Array(5).fill(0).map(((e,t)=>o().createElement("div",{key:t,style:{background:a===t?"#ccc":void 0},onMouseDown:e=>{e.preventDefault();const o=u({text:r+"_"+t},c);n([o," "]),i("")}},r+"_"+t)))):void 0}}},5011:(e,t,n)=>{"use strict";n.d(t,{h1:()=>r,h2:()=>o,h3:()=>i,h4:()=>a,h5:()=>s,h6:()=>c,hr:()=>d,ol:()=>p,p:()=>l,ul:()=>u});const r={blockStart:.67,blockEnd:.67},o={blockStart:.83,blockEnd:.83},i={blockStart:1.17,blockEnd:1.17},a={blockStart:1,blockEnd:1},s={blockStart:1,blockEnd:1},c={blockStart:2.33,blockEnd:2.33},l={blockStart:1,blockEnd:1},u={blockStart:1,blockEnd:1,inlineStart:40},p={blockStart:1,blockEnd:1,inlineStart:40},d={blockStart:.5,blockEnd:.5,void:!0}},3685:(e,t,n)=>{"use strict";n.d(t,{circle:()=>h,useCircle:()=>m});var r=n(3696),o=n.n(r),i=n(9758),a=Object.defineProperty,s=Object.defineProperties,c=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,u=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable,d=(e,t,n)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,f=(e,t)=>{for(var n in t||(t={}))u.call(t,n)&&d(e,n,t[n]);if(l)for(var n of l(t))p.call(t,n)&&d(e,n,t[n]);return e};function g(e){return(0,i.isHtmlText)(e)&&"circle"===e.type}const h={render(e){var t,n,r;if(g(e)){const a=(0,i.renderHtmlTextStyle)(e),l=1.2*(null!=(t=e.fontSize)?t:i.defaultFontSize);return o().createElement("span",{style:(n=f({},a),r={borderWidth:"1px",borderStyle:"solid",borderColor:a.color,borderRadius:l/2+"px",width:`${l}px`,height:`${l}px`,display:"inline-flex",justifyContent:"center"},s(n,c(r)))},e.text)}}},m=({inputText:e,currentContent:t,updateCurrentContent:n})=>{const[r,a]=o().useState(""),s={"insert circle":o().createElement(i.StringEditor,{value:r,setValue:t=>{t&&(e([{type:"circle",text:t}," "]),a(t),setTimeout((()=>{a("")}),0))}})};return t&&g(t)&&(s["circle text"]=o().createElement(i.StringEditor,{value:t.text,setValue:e=>n((t=>{g(t)&&(t.text=e)}))})),{propertyPanel:s}}},726:(e,t,n)=>{"use strict";n.d(t,{image:()=>s,useImage:()=>c});var r=n(3696),o=n.n(r),i=n(9758);function a(e){return"image"===e.kind}const s={render(e,t){if(a(e))return o().createElement("img",{style:{width:`${e.width+t.width}px`,height:`${e.height+t.height}px`},src:e.url})}},c=({inputText:e,currentContent:t,currentContentLayout:n,updateCurrentContent:r,setResizeOffset:s})=>{const[c,l]=o().useState(""),{offset:u,onStart:p,mask:d,resetDragResize:f}=(0,i.useDragResize)((()=>{r((e=>{a(e)&&(e.width+=u.width,e.height+=u.height)}))}),{keepRatio:t&&a(t)?t.width/t.height:void 0});(0,i.useGlobalKeyDown)((e=>{"Escape"===e.key&&f()})),o().useEffect((()=>{s(u)}),[u.x,u.y]);const g={"insert image":o().createElement(i.StringEditor,{value:c,setValue:t=>{t&&((0,i.getImageFromCache)(t,{callback(n){const r=Math.min(n.width,200),o=Math.round(r/n.width*n.height);e([{kind:"image",url:t,width:r,height:o}," "])}}),l(t),setTimeout((()=>{l("")}),0))}})};return t&&a(t)&&(g["image url"]=o().createElement(i.StringEditor,{value:t.url,setValue:e=>r((t=>{a(t)&&(t.url=e)}))}),g["image width"]=o().createElement(i.NumberEditor,{value:t.width,setValue:e=>r((t=>{a(t)&&(t.width=e)}))}),g["image height"]=o().createElement(i.NumberEditor,{value:t.height,setValue:e=>r((t=>{a(t)&&(t.height=e)}))})),{propertyPanel:g,ui:t&&a(t)&&n?o().createElement("div",{style:{width:`${t.width+u.width}px`,height:`${t.height+u.height}px`,left:`${n.x+u.x}px`,top:`${n.y+u.y}px`,border:"1px solid green",boxSizing:"border-box",position:"absolute"}},o().createElement(i.ResizeBar,{directions:["right-bottom"],onMouseDown:p}),d):void 0}}},4430:(e,t,n)=>{"use strict";n.d(t,{code:()=>o,mark:()=>i,span:()=>r,sub:()=>a,sup:()=>s});const r={},o={backgroundColor:15921649},i={},a={},s={}},2693:(e,t,n)=>{"use strict";n.d(t,{link:()=>s,useLink:()=>c});var r=n(3696),o=n.n(r),i=n(9758);function a(e){return(0,i.isHtmlText)(e)&&"link"===e.type}const s={render(e){if(a(e))return o().createElement("a",{style:(0,i.renderHtmlTextStyle)(e),target:e.targetBlank?"_blank":"",href:e.url},e.text)}},c=({inputText:e,currentContent:t,updateCurrentContent:n})=>{var r;const[s,c]=o().useState(""),l={"insert link":o().createElement(i.StringEditor,{value:s,setValue:t=>{t&&(e([{type:"link",text:t,targetBlank:!0,url:t}," "]),c(t),setTimeout((()=>{c("")}),0))}})};return t&&a(t)&&(l["link text"]=o().createElement(i.StringEditor,{value:t.text,setValue:e=>n((t=>{a(t)&&(t.text=e)}))}),l["link url"]=o().createElement(i.StringEditor,{value:t.url,setValue:e=>n((t=>{a(t)&&(t.url=e)}))}),l["link target blank"]=o().createElement(i.BooleanEditor,{value:null!=(r=t.targetBlank)&&r,setValue:e=>n((t=>{a(t)&&(t.targetBlank=!!e||void 0)}))})),{propertyPanel:l}}},8749:(e,t,n)=>{"use strict";n.d(t,{stack:()=>h,useStack:()=>m});var r=n(3696),o=n.n(r),i=n(9758),a=Object.defineProperty,s=Object.defineProperties,c=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,u=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable,d=(e,t,n)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,f=(e,t)=>{for(var n in t||(t={}))u.call(t,n)&&d(e,n,t[n]);if(l)for(var n of l(t))p.call(t,n)&&d(e,n,t[n]);return e};function g(e){return(0,i.isHtmlText)(e)&&"stack"===e.type}const h={render(e){if(g(e)){const r=(0,i.renderHtmlTextStyle)(e);return o().createElement("span",{style:(t=f({},r),n={display:"inline-flex",flexDirection:"column",verticalAlign:"middle"},s(t,c(n)))},o().createElement("span",{style:{borderBottomWidth:"1px",borderBottomStyle:"solid",borderBottomColor:r.color}},e.text),o().createElement("span",null,e.bottomText))}var t,n}},m=({inputText:e,currentContent:t,updateCurrentContent:n})=>{const[r,a]=o().useState(""),s={"insert stack":o().createElement(i.StringEditor,{value:r,setValue:t=>{if(t){let n=t,r=t;const o=t.indexOf("/");o>0&&o{a("")}),0)}}})};return t&&g(t)&&(s["stack top"]=o().createElement(i.StringEditor,{value:t.text,setValue:e=>n((t=>{g(t)&&(t.text=e)}))}),s["stack bottom"]=o().createElement(i.StringEditor,{value:t.bottomText,setValue:e=>n((t=>{g(t)&&(t.bottomText=e)}))})),{propertyPanel:s}}},395:(e,t,n)=>{"use strict";n.d(t,{backgroundColor:()=>f,bold:()=>c,color:()=>d,fontFamily:()=>s,fontSize:()=>a,italic:()=>l,passThrough:()=>p,underline:()=>u});var r=n(3696),o=n.n(r),i=n(9758);const a=(e,t,n)=>{var r,a;return o().createElement(i.NumberEditor,{value:null!=(a=null!=(r=null==e?void 0:e.fontSize)?r:null==t?void 0:t.fontSize)?a:i.defaultFontSize,setValue:e=>n((t=>t.fontSize=e)),style:{width:"100px"}})},s=(e,t,n)=>{var r,a;return o().createElement(i.StringEditor,{value:null!=(a=null!=(r=null==e?void 0:e.fontFamily)?r:null==t?void 0:t.fontFamily)?a:i.defaultFontFamily,setValue:e=>n((t=>t.fontFamily=e)),style:{width:"100px"}})},c=(e,t,n)=>{var r;return o().createElement(i.BooleanEditor,{value:!0===(null!=(r=null==e?void 0:e.bold)?r:null==t?void 0:t.bold),setValue:e=>n((t=>t.bold=!!e||void 0))})},l=(e,t,n)=>{var r;return o().createElement(i.BooleanEditor,{value:!0===(null!=(r=null==e?void 0:e.italic)?r:null==t?void 0:t.italic),setValue:e=>n((t=>t.italic=!!e||void 0))})},u=(e,t,n)=>{var r;return o().createElement(i.BooleanEditor,{value:!0===(null!=(r=null==e?void 0:e.underline)?r:null==t?void 0:t.underline),setValue:e=>n((t=>t.underline=!!e||void 0))})},p=(e,t,n)=>{var r;return o().createElement(i.BooleanEditor,{value:!0===(null!=(r=null==e?void 0:e.passThrough)?r:null==t?void 0:t.passThrough),setValue:e=>n((t=>t.passThrough=!!e||void 0))})},d=(e,t,n)=>{var r,a;return o().createElement(i.NumberEditor,{type:"color",value:null!=(a=null!=(r=null==e?void 0:e.color)?r:null==t?void 0:t.color)?a:0,setValue:e=>n((t=>t.color=e||void 0))})},f=(e,t,n)=>{var r,a;return o().createElement(i.NumberEditor,{type:"color",value:null!=(a=null!=(r=null==e?void 0:e.backgroundColor)?r:null==t?void 0:t.backgroundColor)?a:16777215,setValue:e=>n((t=>t.backgroundColor=e||void 0))})}},8214:(e,t,n)=>{"use strict";n.d(t,{RichTextEditor:()=>s});var r=n(3696),o=n.n(r),i=n(9758),a=n(8662);const s=o().forwardRef(((e,t)=>{var n,r,s,c,l;const{state:u,setState:p,undo:d,redo:f,applyPatchFromOtherOperators:g}=(0,i.usePatchBasedUndoRedo)(e.initialState,e.operator,{onApplyPatchesFromSelf:e.onApplyPatchesFromSelf}),[h,m]=o().useState({width:0,height:0}),{renderEditor:y,currentContent:v,currentBlock:x,currentContentLayout:b,inputText:C,layoutResult:E,cursor:P,inputContent:w,location:k,scrollY:_,updateSelection:S,updateTextInline:R,updateParagraph:T,updateCurrentContent:A}=(0,i.useHtmlEditor)({state:u,setState:p,width:e.width,height:e.height,readOnly:e.readOnly,processInput(e){for(const t of L)if(t(e))return!0;return!(!(0,i.metaKeyIfMacElseCtrlKey)(e)||"z"!==e.key||(e.shiftKey?f(e):d(e),0))},onLocationChanged:e.onSendLocation,autoHeight:e.autoHeight,plugin:e.plugin,resizeOffset:h,keepSelectionOnBlur:!0}),L=[],M=[],I={};if(null==(n=e.plugin)?void 0:n.hooks){const t={cursor:P,cursorHeight:P.height,inputText:C,inputContent:w,currentContent:v,currentContentLayout:b,updateCurrentContent:A,setResizeOffset:m};e.plugin.hooks.forEach(((e,n)=>{const{processInput:r,ui:i,propertyPanel:a}=e(t);r&&L.push(r),i&&M.push(o().cloneElement(i,{key:n})),a&&Object.assign(I,a)}))}const[O,D]=o().useState([]);o().useImperativeHandle(t,(()=>({handlePatchesEvent(e){try{g(e.patches,e.reversePatches,e.operator)}catch(e){console.error(e)}},handleLocationEvent(e){D((0,a.produce)(O,(t=>{var n,r;const o=O.findIndex((t=>t.operator===e.operator));o>=0?e.location&&(null==(r=null==(n=u[e.location[0]])?void 0:n.children)?void 0:r[e.location[1]])?t[o].location=e.location:t.splice(o,1):e.location&&t.push({location:e.location,operator:e.operator})})))}})),[g]);const B=[];if(null==(r=null==E?void 0:E.cells)||r.forEach(((e,t)=>{var n;const r=u[t],a=null!=(n=null==r?void 0:r.fontFamily)?n:i.defaultFontFamily;e.forEach((({x:e,y:n,height:r},i)=>{const s=O.filter((e=>e.location[0]===t&&e.location[1]===i));s.length>0&&B.push(o().createElement("div",{style:{position:"absolute",left:e+"px",top:n+_+"px",width:"2px",height:r+"px",backgroundColor:"red"}}),o().createElement("span",{style:{position:"absolute",left:e+"px",top:n+_+r+"px",fontSize:"12px",fontFamily:a,color:"red"}},s.map((e=>e.operator)).join(",")))}))})),(null==(s=e.plugin)?void 0:s.styles)&&v&&(0,i.isHtmlText)(v))for(const t in e.plugin.styles)I[t]=e.plugin.styles[t](v,x,S);return(null==(c=e.plugin)?void 0:c.textInlines)&&(I.textInlines=o().createElement("div",null,(0,i.getKeys)(e.plugin.textInlines).map((e=>o().createElement(i.Button,{key:e,style:{fontWeight:v&&(0,i.isHtmlText)(v)&&v.type===e?"bold":void 0},onClick:()=>R(e)},e))))),(null==(l=e.plugin)?void 0:l.blocks)&&(I.block=o().createElement("div",null,(0,i.getKeys)(e.plugin.blocks).map((e=>{var t;return o().createElement(i.Button,{key:e,style:{fontWeight:(null==(t=u[k[0]])?void 0:t.type)===e?"bold":void 0},onClick:()=>T(e)},e)})))),o().createElement("div",{style:{position:"relative",margin:"10px"}},o().createElement("div",{style:{display:"flex"}},y(o().createElement(o().Fragment,null,B)),o().createElement(i.ObjectEditor,{inline:!0,properties:I})),M)}))},94:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(3696),o=n.n(r),i=n(9758);const a=()=>{const[e,t]=o().useState(0),[n,r]=o().useState(0);return o().createElement("div",{style:{width:"300px",height:"300px",overflow:"hidden",position:"absolute",display:"flex",alignItems:"center",justifyContent:"center"}},o().createElement("div",{style:{width:"800px",height:"800px",position:"absolute",transform:`translate(${e}px, ${n}px)`,background:"radial-gradient(50% 50% at 50% 50%, red 0%, white 100%)"}}),o().createElement(i.Scrollbar,{value:e,type:"horizontal",containerSize:300,contentSize:800,onChange:t}),o().createElement(i.Scrollbar,{value:n,type:"vertical",containerSize:300,contentSize:800,onChange:r}))}},8751:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(3696),o=n.n(r),i=n(9758);const a=()=>{const{isSelected:e,addSelection:t,filterSelection:n,executeOperation:r,selectBeforeOperate:a,message:s,onSelectBeforeOperateKeyDown:c}=(0,i.useSelectBeforeOperate)({},((e,t)=>(alert(t.map((([e])=>e)).join(",")),!0)));(0,i.useGlobalKeyDown)((e=>{c(e)}));const l=(e,t)=>{const{result:o,needSelect:i}=n(t,e);i?a({count:e,selectable:t},"alert"):r("alert",o)};return o().createElement("div",null,o().createElement("button",{onClick:()=>l()},"select count ",">"," 0"),o().createElement("button",{onClick:()=>l(3)},"select count = 3"),o().createElement("button",{onClick:()=>l(void 0,(([e])=>e%2==1))},"select count ",">"," 0 && i % 2 === 1"),o().createElement("button",{onClick:()=>l(3,(([e])=>e%2==1))},"select count = 3 && i % 2 === 1"),new Array(10).fill(1).map(((n,r)=>o().createElement("button",{key:r,style:{backgroundColor:e([r])?"green":void 0,width:"50px",height:"50px"},onClick:()=>t([r])},r))),s)}},9967:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(3696),o=n.n(r),i=n(9758);const a=()=>{const{isSelected:e,addSelection:t,onSelectedKeyDown:n}=(0,i.useSelected)({maxCount:3});return(0,i.useGlobalKeyDown)((e=>{n(e)})),o().createElement("div",null,new Array(10).fill(1).map(((n,r)=>o().createElement("button",{key:r,style:{backgroundColor:e([r])?"green":void 0,width:"50px",height:"50px"},onClick:()=>t([[r]])},r))))}},5052:(e,t,n)=>{"use strict";n.d(t,{OffsetXContext:()=>b});var r=n(7470),o=n(3696),i=n.n(o),a=(n(9532),n(831),n(8941)),s=n(250),c=n(5371),l=n(9758),u=n(6708),p=n(9277),d=n(9456),f=n(7511),g=n(3714),h=n(577),m=n(84),y=n(6523);const v=[{path:"whiteboard",name:"whiteboard",component:u.WhiteBoard},{path:"index",name:"combination 1",component:c.App},{path:"combination2",name:"combination 2",component:p.Combination2},{path:"combination3",name:"combination 3",component:d.Combination3},{path:"combination4",name:"combination 4",component:f.Combination4},{path:"combination5",name:"combination 5",component:g.Combination5},{path:"combination6",name:"combination 6",component:h.Combination6},{path:"combination7",name:"combination 7",component:m.Combination7},{path:"combination8",name:"combination 8",component:y.Combination8}];function x(){const[,e]=(0,a.useLocation)(i()),[t,n]=i().useState(0),{onStart:r,offset:o,mask:c}=(0,l.useDragMove)((()=>{n((e=>e+o.x))}));if(!e)return i().createElement("ul",{style:{margin:"20px 50px"}},v.map((e=>i().createElement("li",{style:{cursor:"pointer"},key:e.path,onClick:()=>(0,a.navigateTo)(location.pathname+"?p="+e.path)},e.name))),s.stories.map((e=>i().createElement("li",{style:{cursor:"pointer"},key:e.path,onClick:()=>(0,a.navigateTo)(location.pathname+"?p="+e.path)},e.name," ",e.path))));const u=e.substring(3),p=v.find((e=>e.path===u));if(p)return i().createElement(p.component,null);for(const e of s.stories)if(u===e.path)return i().createElement("div",{style:{display:"flex",padding:"20px",height:`calc(${window.innerHeight}px - 40px)`,overflowY:"auto"}},i().createElement("div",{style:{width:`calc(50% + ${t+o.x}px)`}},i().createElement(b.Provider,{value:{offset:t,setOffset:n}},i().createElement(e.Component,null))),i().createElement("div",{style:{width:"5px",cursor:"ew-resize",zIndex:1},onMouseDown:e=>r({x:e.clientX,y:e.clientY})}),i().createElement("div",{style:{width:`calc(50% - 5px - ${t+o.x}px)`}},i().createElement(C,{code:e.code})),c);return null}const b=i().createContext({offset:0});function C(e){const t=i().useRef(null);return i().useEffect((()=>{t.current&&Prism.highlightElement(t.current)}),[e.code,t.current]),i().createElement("pre",{className:"line-numbers"},i().createElement("code",{ref:t,className:"language-tsx"},e.code))}const E=document.querySelector("#container");E&&(0,r.createRoot)(E).render(i().createElement(x,null))},9299:(e,t,n)=>{"use strict";n.d(t,{defaultContents:()=>r});const r=[{x:500,y:100,width:100,height:100,url:"https://interactive-examples.mdn.mozilla.net/media/cc0-images/grapefruit-slice-332-332.jpg"},{x:20,y:200,width:300,height:300,url:"https://interactive-examples.mdn.mozilla.net/media/cc0-images/grapefruit-slice-332-332.jpg"},{x:200,y:20,width:200,height:200,url:"https://interactive-examples.mdn.mozilla.net/media/cc0-images/grapefruit-slice-332-332.jpg"}]},5503:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758);const s=()=>{const[e,t]=i().useState([]),{text:n,onClick:o,onMove:s,input:c,reset:l}=(0,a.useTextClickCreate)(!0,(n=>{t((0,r.produce)(e,(e=>{e.push(n)})))}));return(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&l()})),i().createElement("div",{style:{height:"100%"}},i().createElement("svg",{viewBox:"0 0 800 600",width:800,height:600,xmlns:"http://www.w3.org/2000/svg",fill:"none",style:{position:"absolute",left:0,top:0},onClick:e=>o({x:e.clientX,y:e.clientY}),onMouseMove:e=>s({x:e.clientX,y:e.clientY})},[...e,n].map(((e,t)=>e&&i().createElement("text",{key:t,x:e.x,y:e.y,style:{fill:(0,a.getColorString)(e.color),fontSize:`${e.fontSize}px`,fontFamily:e.fontFamily}},e.text)))),c)}},8119:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(3696),o=n.n(r),i=n(9758);const a=()=>{const{state:e,setState:t,undo:n,redo:r}=(0,i.useUndoRedo)({count:0});return(0,i.useGlobalKeyDown)((e=>{"KeyZ"===e.code&&(0,i.metaKeyIfMacElseCtrlKey)(e)&&(e.shiftKey?r(e):n(e))})),o().createElement("button",{onClick:()=>t((e=>{e.count++})),style:{width:"200px",height:"100px"}},e.count)}},2929:(e,t,n)=>{"use strict";n.d(t,{default:()=>f});var r=n(3696),o=n(670),i=n(8662),a=n(9758),s=Object.defineProperty,c=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,u=Object.prototype.propertyIsEnumerable,p=(e,t,n)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,d=(e,t)=>{for(var n in t||(t={}))l.call(t,n)&&p(e,n,t[n]);if(c)for(var n of c(t))u.call(t,n)&&p(e,n,t[n]);return e};const f=()=>{const e=r.useRef(null),t=r.useRef(),n=(0,a.useWindowSize)(),o=n.width/2,s=n.height,[c,l]=r.useState(),u=[0,-90,90],p=-100,{state:d,setState:f,undo:h,redo:m}=(0,a.useUndoRedo)(g(function(){const e=[];for(let t=-10;t<=10;t++){const n=5*t,r=[];for(let e=-10;e<=10;e++)r.push([n,5*e,0]);e.push(r)}return e}(),3)),[y,v]=r.useState(),[x,b]=r.useState(),[C,E]=r.useState(5);return r.useEffect((()=>{e.current&&!t.current&&(t.current=(0,a.createWebgl3DRenderer)(e.current))}),[e.current]),(0,a.useGlobalKeyDown)((e=>{(0,a.metaKeyIfMacElseCtrlKey)(e)?"KeyZ"===e.code&&(e.shiftKey?m(e):h(e)):"Escape"===e.key&&(b(void 0),v(void 0))})),r.useEffect((()=>{const e=[];var n,r,o;c&&e.push({geometry:{type:"sphere",radius:1},color:[1,0,0,1],position:c}),n=[...d,...e],null==(o=null==(r=t.current)?void 0:r.render)||o.call(r,n,{eye:u,up:[0,1,0],target:[0,0,0],fov:(0,a.angleToRadian)(60),near:.1,far:1e3},{position:[1e3,-1e3,1e3],color:[1,1,1,1],specular:[1,1,1,1],shininess:50,specularFactor:1},[1,1,1,1])}),[c,d]),r.createElement("div",{style:{position:"absolute",inset:"0px"}},r.createElement("canvas",{ref:e,width:o,height:s,onMouseMove:e=>{var n,r;l(x||null==(r=null==(n=t.current)?void 0:n.pickPoint)?void 0:r.call(n,e.clientX,e.clientY,u,p,(e=>"vertices"===e.geometry.type)))},onMouseDown:e=>{var n,r;if(!x)return;const o=d[0].geometry;if("vertices"===o.type){const a=null==(r=null==(n=t.current)?void 0:n.pickPoint)?void 0:r.call(n,e.clientX,e.clientY,u,p,(e=>"vertices"===e.geometry.type));if(a){const e=Math.round(a[0]/5)+10;if(e>=0&&e=0&&t{const r=n[e][t];if("set"===x)r[2]=C;else if("up"===x)r[2]+=5;else{if(r[2]-5g(n,3)))}}}}},onContextMenu:e=>{e.preventDefault();const t={x:e.clientX,y:e.clientY};v(y?void 0:r.createElement(a.Menu,{items:[{title:"up",onClick(){b("up"),v(void 0)}},{title:"down",onClick(){b("down"),v(void 0)}},{title:r.createElement(r.Fragment,null,r.createElement(a.NumberEditor,{value:C,style:{width:"50px"},setValue:E}),r.createElement(a.Button,{onClick:()=>{b("set"),v(void 0)}},"set")),height:41}],y:t.y,height:s,style:{left:t.x+"px"}}))}}),y)};function g(e,t){const n=(0,a.getNurbsSurfaceVertices)(e,t),r=[{geometry:d({type:"vertices"},n),color:[0,1,0,1]}],i=(0,a.getDefaultNurbsKnots)(e.length,t);for(let n=0;n[e[0],e[1],e[2]+.1])).flat()}});const c=e.map((e=>e[n])),l=o.geom.NurbsCurve.byKnotsControlPointsWeights(t,i,c);r.push({color:[0,0,1,1],geometry:{type:"lines",points:l.tessellate().map((e=>[e[0],e[1],e[2]+.1])).flat()}})}return r}},8337:(e,t,n)=>{"use strict";n.d(t,{default:()=>p});var r=n(3696),o=n(9758),i=Object.defineProperty,a=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,c=Object.prototype.propertyIsEnumerable,l=(e,t,n)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,u=(e,t)=>{for(var n in t||(t={}))s.call(t,n)&&l(e,n,t[n]);if(a)for(var n of a(t))c.call(t,n)&&l(e,n,t[n]);return e};const p=()=>{const e=r.useRef(null),t=r.useRef(),{x:n,y:i,setX:a,setY:s,ref:c}=(0,o.useWheelScroll)(),{scale:l,setScale:p,ref:d}=(0,o.useWheelZoom)(),[f,g]=r.useState({x:0,y:0}),{offset:h,onStart:m,mask:y,resetDragMove:v}=(0,o.useDragMove)((()=>{g((e=>({x:e.x+h.x,y:e.y+h.y})))}));(0,o.useGlobalKeyDown)((e=>{"Escape"===e.key?v():"Digit0"===e.code&&!e.shiftKey&&(0,o.metaKeyIfMacElseCtrlKey)(e)&&(p(1),a(0),s(0),g({x:0,y:0}),e.preventDefault())}));const x=(0,o.useWindowSize)(),b=x.width/2,C=x.height,E=h.x+f.x,P=h.y+f.y,[w,k]=r.useState(),_=r.useRef([...(0,o.getAxesGraphics)(),{geometry:{type:"lines",points:(0,o.getDashedLine)([0,0,0],[100,100,100],6).flat()},color:[0,0,0,1]},{geometry:{type:"sphere",radius:100},color:[1,0,0,1],position:[0,250,0]},{geometry:{type:"cube",size:150},color:[0,1,0,1],position:[250,0,0]},{geometry:{type:"cylinder",radius:100,height:200},color:[0,0,1,1],position:[-250,0,0]},{geometry:{type:"cone",topRadius:0,bottomRadius:100,height:200},color:[1,0,1,1],position:[0,-250,0]},{geometry:{type:"triangles",points:[-50,-50,50,50,50,50,-50,50,50]},color:[.5,0,.5,1],position:[250,250,250]},{geometry:u({type:"vertices"},(0,o.getNurbsSurfaceVertices)([[[0,0,-20],[20,0,0],[40,0,0],[60,0,0],[80,0,0],[100,0,0]],[[0,-20,0],[20,-20,10],[40,-20,20],[60,-20,0],[80,-20,0],[100,-20,0]],[[0,-40,0],[20,-40,10],[40,-40,20],[60,-40,0],[80,-40,-4],[100,-40,-24]],[[0,-50,0],[20,-60,0],[40,-60,-46],[60,-60,0],[80,-60,0],[100,-50,0]],[[0,-80,0],[20,-80,0],[40,-80,0],[60,-80,8],[80,-80,-40],[100,-80,0]],[[0,-100,24],[20,-100,0],[40,-100,40],[60,-100,0],[100,-100,-20],[100,-100,-30]]],3,[0,0,0,0,.333,.666,1,1,1,1],3,[0,0,0,0,.333,.666,1,1,1,1])),color:[0,.5,0,1],position:[-250,250,250]}]);return r.useEffect((()=>{e.current&&!t.current&&(t.current=(0,o.createWebgl3DRenderer)(e.current))}),[e.current]),r.useEffect((()=>{var e,r;const{position:a,up:s}=(0,o.updateCamera)(-n,i,1e3/l,-.3*E,-.3*P);_.current.forEach(((e,t)=>{e.color[3]=t===w?.5:1})),null==(r=null==(e=t.current)?void 0:e.render)||r.call(e,_.current,{eye:(0,o.position3DToVec3)(a),up:(0,o.position3DToVec3)(s),target:[-n,i,0],fov:(0,o.angleToRadian)(60),near:.1,far:2e4},{position:[1e3,1e3,1e3],color:[1,1,1,1],specular:[1,1,1,1],shininess:50,specularFactor:1},[1,1,1,1])}),[n,i,l,E,P,w,b,C]),r.createElement("div",{ref:(0,o.bindMultipleRefs)(c,d),style:{position:"absolute",inset:"0px"}},r.createElement("canvas",{ref:e,width:b,height:C,onMouseDown:e=>m({x:e.clientX,y:e.clientY}),onMouseMove:e=>{var n,r;return k(null==(r=null==(n=t.current)?void 0:n.pick)?void 0:r.call(n,e.clientX,e.clientY,(e=>"lines"!==e.geometry.type)))}}),y)}},1459:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(3696),o=n(9397),i=n(9758);const a=()=>{const e=r.useRef(null),t=r.useRef(),{x:n,y:a,ref:s,setX:c,setY:l}=(0,i.useWheelScroll)(),{scale:u,setScale:p,ref:d}=(0,i.useWheelZoom)({onChange(e,t,n){const r=(0,i.scaleByCursorPosition)({width:b,height:C},t/e,n);c(r.setX),l(r.setY)}}),{zoomIn:f,zoomOut:g}=(0,i.useZoom)(u,p),{offset:h,onStart:m,mask:y,resetDragMove:v}=(0,i.useDragMove)((()=>{c((e=>e+h.x)),l((e=>e+h.y))}));(0,i.useGlobalKeyDown)((e=>{"Escape"===e.key?v():(0,i.metaKeyIfMacElseCtrlKey)(e)&&("Minus"===e.code?g(e):"Equal"===e.code&&f(e))}));const x=(0,i.useWindowSize)(),b=x.width/2,C=x.height,E=()=>{const e=document.createElement("canvas"),t=e.getContext("2d");if(t){t.font="50px monospace";const e=t.measureText("abc");t.canvas.width=Math.ceil(e.width)+2,t.canvas.height=50,t.font="50px monospace",t.fillStyle="white",t.fillText("abc",0,t.canvas.height)}const n="round",r=void 0;return{backgroundColor:[Math.random(),Math.random(),Math.random(),1],lines:[{points:(0,i.combineStripTriangles)([(0,i.getPolylineTriangles)([{x:600*Math.random(),y:400*Math.random()},{x:600*Math.random(),y:400*Math.random()},{x:600*Math.random(),y:400*Math.random()},{x:600*Math.random(),y:400*Math.random()}],10,r,n).points,(0,i.getPolylineTriangles)([{x:600*Math.random(),y:400*Math.random()},{x:600*Math.random(),y:400*Math.random()},{x:600*Math.random(),y:400*Math.random()},{x:600*Math.random(),y:400*Math.random()}],10,r,n).points]),color:[Math.random(),Math.random(),Math.random(),1]},{points:(0,i.combineStripTriangles)([(0,i.getPolylineTriangles)([{x:600*Math.random(),y:400*Math.random()},{x:600*Math.random(),y:400*Math.random()},{x:600*Math.random(),y:400*Math.random()},{x:600*Math.random(),y:400*Math.random()}],10,r,n).points,(0,i.getPolylineTriangles)([{x:600*Math.random(),y:400*Math.random()},{x:600*Math.random(),y:400*Math.random()},{x:600*Math.random(),y:400*Math.random()},{x:600*Math.random(),y:400*Math.random()}],10,r,n).points]),color:[Math.random(),Math.random(),Math.random(),1]}],line:[600*Math.random(),400*Math.random(),600*Math.random(),400*Math.random(),600*Math.random(),400*Math.random()],triangles:[600*Math.random(),400*Math.random(),600*Math.random(),400*Math.random(),600*Math.random(),400*Math.random()],triangleColors:[Math.random(),Math.random(),Math.random(),1,Math.random(),Math.random(),Math.random(),1,Math.random(),Math.random(),Math.random(),1],canvas:e,color:[Math.random(),Math.random(),Math.random(),1],position:{x:600*Math.random(),y:400*Math.random()}}},[P,w]=r.useState(E());return r.useEffect((()=>{if(!e.current||t.current)return;const n=e.current,r=e.current.getContext("webgl",{antialias:!0,stencil:!0});if(!r)return;r.enable(r.BLEND),r.blendFunc(r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA);const a=o.createProgramInfo(r,["\n attribute vec4 position;\n uniform mat3 matrix;\n void main() {\n gl_Position = vec4((matrix * vec3(position.xy, 1)).xy, 0, 1);\n }\n ","\n precision mediump float;\n uniform vec4 color;\n void main() {\n gl_FragColor = color;\n }"]),s=o.createProgramInfo(r,["\n attribute vec4 position; \n uniform mat3 matrix;\n varying vec2 texcoord;\n\n void main () {\n gl_Position = vec4((matrix * vec3(position.xy, 1)).xy, 0, 1);\n texcoord = position.xy;\n }\n ","\n precision mediump float;\n\n varying vec2 texcoord;\n uniform sampler2D texture;\n uniform vec4 color;\n\n void main() {\n if (texcoord.x < 0.0 || texcoord.x > 1.0 ||\n texcoord.y < 0.0 || texcoord.y > 1.0) {\n discard;\n }\n vec4 color = texture2D(texture, texcoord) * color;\n if (color.a < 0.1) {\n discard;\n }\n gl_FragColor = color;\n }"]);r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0);const c=o.primitives.createXYQuadBufferInfo(r),l=o.createProgramInfo(r,["\n attribute vec4 position;\n varying vec2 texcoord;\n void main() {\n gl_Position = position;\n texcoord = position.xy * .5 + .5;\n }\n ","\n precision mediump float;\n varying vec2 texcoord;\n uniform sampler2D texture;\n void main() {\n gl_FragColor = texture2D(texture, texcoord); \n }\n "]),u=o.primitives.createXYQuadBufferInfo(r),p=o.createTexture(r,{src:"https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg",crossOrigin:""}),d=o.createProgramInfo(r,["\n attribute vec4 position;\n attribute vec4 color;\n uniform mat3 matrix;\n varying vec4 v_color;\n\n void main () {\n gl_Position = vec4((matrix * vec3(position.xy, 1)).xy, 0, 1);\n v_color = color;\n }\n ","\n precision mediump float;\n\n varying vec4 v_color;\n\n void main() {\n gl_FragColor = v_color;\n }"]);t.current=(e,t,f,g)=>{r.viewport(0,0,r.canvas.width,r.canvas.height),r.useProgram(a.program),o.resizeCanvasToDisplaySize(n),r.clearColor(...e.backgroundColor),r.clear(r.COLOR_BUFFER_BIT|r.DEPTH_BUFFER_BIT|r.STENCIL_BUFFER_BIT);let h=i.m3.projection(r.canvas.width,r.canvas.height);h=i.m3.multiply(h,i.m3.translation(t,f)),1!==g&&(h=i.m3.multiply(h,i.m3.translation(r.canvas.width/2,r.canvas.height/2)),h=i.m3.multiply(h,i.m3.scaling(g,g)),h=i.m3.multiply(h,i.m3.translation(-r.canvas.width/2,-r.canvas.height/2)));const m=[];for(const t of e.lines)m.push({programInfo:a,bufferInfo:o.createBufferInfoFromArrays(r,{position:{numComponents:2,data:t.points}}),uniforms:{color:t.color,matrix:h},type:r.TRIANGLE_STRIP});const y=[{programInfo:a,bufferInfo:o.createBufferInfoFromArrays(r,{position:{numComponents:2,data:e.line}}),uniforms:{color:e.color,matrix:h},type:r.LINE_STRIP}],v=[{programInfo:d,bufferInfo:o.createBufferInfoFromArrays(r,{position:{numComponents:2,data:e.triangles},color:{numComponents:4,data:e.triangleColors}}),uniforms:{matrix:h},type:r.TRIANGLES}];h=i.m3.multiply(h,i.m3.translation(e.position.x,e.position.y)),h=i.m3.multiply(h,i.m3.scaling(e.canvas.width,e.canvas.height)),o.drawObjectList(r,m),r.enable(r.STENCIL_TEST),r.stencilFunc(r.ALWAYS,1,255),r.stencilOp(r.KEEP,r.KEEP,r.REPLACE),o.drawObjectList(r,[{programInfo:s,bufferInfo:c,uniforms:{matrix:h,color:e.color,texture:o.createTexture(r,{src:e.canvas})}},{programInfo:s,bufferInfo:c,uniforms:{matrix:i.m3.multiply(h,i.m3.translation(1,0)),color:e.color,texture:o.createTexture(r,{src:e.canvas})}},{programInfo:s,bufferInfo:c,uniforms:{matrix:i.m3.multiply(h,i.m3.translation(1,1)),color:e.color,texture:o.createTexture(r,{src:e.canvas})}}]),r.stencilFunc(r.EQUAL,1,255),r.stencilOp(r.KEEP,r.KEEP,r.KEEP),o.drawObjectList(r,[{programInfo:l,bufferInfo:u,uniforms:{texture:p}}]),r.disable(r.STENCIL_TEST),o.drawObjectList(r,y),o.drawObjectList(r,v)}}),[e.current]),r.useEffect((()=>{t.current&&t.current(P,n+h.x,a+h.y,u)}),[P,t.current,n,a,h,u]),r.createElement("div",{ref:(0,i.bindMultipleRefs)(s,d),style:{position:"absolute",inset:"0px"}},r.createElement("canvas",{ref:e,width:b,height:C,onMouseDown:e=>m({x:e.clientX,y:e.clientY})}),r.createElement("button",{style:{position:"fixed"},onClick:()=>w(E())},"update"),y)}},432:(e,t,n)=>{"use strict";n.d(t,{default:()=>p});var r=n(3696),o=n(9758),i=Object.defineProperty,a=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,c=Object.prototype.propertyIsEnumerable,l=(e,t,n)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,u=(e,t)=>{for(var n in t||(t={}))s.call(t,n)&&l(e,n,t[n]);if(a)for(var n of a(t))c.call(t,n)&&l(e,n,t[n]);return e};const p=()=>{const e=r.useRef(null),t=r.useRef(),{x:n,y:i,setX:a,setY:s,ref:c}=(0,o.useWheelScroll)(),{scale:l,setScale:p,ref:d}=(0,o.useWheelZoom)(),[f,g]=r.useState({x:0,y:0}),{offset:h,onStart:m,mask:y,resetDragMove:v}=(0,o.useDragMove)((()=>{g((e=>({x:e.x+h.x,y:e.y+h.y})))}));(0,o.useGlobalKeyDown)((e=>{"Escape"===e.key?v():"Digit0"===e.code&&!e.shiftKey&&(0,o.metaKeyIfMacElseCtrlKey)(e)&&(p(1),a(0),s(0),g({x:0,y:0}),e.preventDefault())}));const x=(0,o.useWindowSize)(),b=x.width/2,C=x.height,E=h.x+f.x,P=h.y+f.y,[w,k]=r.useState(),_=r.useRef([...(0,o.getAxesGraphics)(),{geometry:{type:"lines",points:(0,o.getDashedLine)([0,0,0],[100,100,100],6).flat()},color:[0,0,0,1]},{geometry:{type:"sphere",radius:100},color:[1,0,0,1],position:[0,250,0]},{geometry:{type:"cube",size:150},color:[0,1,0,1],position:[250,0,0]},{geometry:{type:"cylinder",radius:100,height:200},color:[0,0,1,1],position:[-250,0,0]},{geometry:{type:"cone",topRadius:0,bottomRadius:100,height:200},color:[1,0,1,1],position:[0,-250,0]},{geometry:{type:"triangles",points:[-50,-50,50,50,50,50,-50,50,50]},color:[.5,0,.5,1],position:[250,250,250]},{geometry:u({type:"vertices"},(0,o.getNurbsSurfaceVertices)([[[0,0,-20],[20,0,0],[40,0,0],[60,0,0],[80,0,0],[100,0,0]],[[0,-20,0],[20,-20,10],[40,-20,20],[60,-20,0],[80,-20,0],[100,-20,0]],[[0,-40,0],[20,-40,10],[40,-40,20],[60,-40,0],[80,-40,-4],[100,-40,-24]],[[0,-50,0],[20,-60,0],[40,-60,-46],[60,-60,0],[80,-60,0],[100,-50,0]],[[0,-80,0],[20,-80,0],[40,-80,0],[60,-80,8],[80,-80,-40],[100,-80,0]],[[0,-100,24],[20,-100,0],[40,-100,40],[60,-100,0],[100,-100,-20],[100,-100,-30]]],3,[0,0,0,0,.333,.666,1,1,1,1],3,[0,0,0,0,.333,.666,1,1,1,1])),color:[0,.5,0,1],position:[250,250,-250],rotateY:Math.PI}]);return r.useEffect((()=>{e.current&&!t.current&&(0,o.createWebgpu3DRenderer)(e.current).then((e=>{t.current=e,k(-1)}))}),[e.current]),r.useEffect((()=>{var e,r;const{position:a,up:s}=(0,o.updateCamera)(-n,i,1e3/l,-.3*E,-.3*P);_.current.forEach(((e,t)=>{e.color[3]=t===w?.5:1})),null==(r=null==(e=t.current)?void 0:e.render)||r.call(e,_.current,{eye:(0,o.position3DToVec3)(a),up:(0,o.position3DToVec3)(s),target:[-n,i,0],fov:(0,o.angleToRadian)(60),near:.1,far:2e4},{position:[1e3,1e3,1e3],color:[1,1,1,1],specular:[1,1,1,1],shininess:50,specularFactor:1},[1,1,1,1])}),[n,i,l,E,P,w,b,C]),r.createElement("div",{ref:(0,o.bindMultipleRefs)(c,d),style:{position:"absolute",inset:"0px"}},r.createElement("canvas",{ref:e,width:b,height:C,onMouseDown:e=>m({x:e.clientX,y:e.clientY}),onMouseMove:e=>{return n=function*(){var n,r;return k(yield null==(r=null==(n=t.current)?void 0:n.pick)?void 0:r.call(n,e.clientX,e.clientY,(e=>"lines"!==e.geometry.type&&"triangles"!==e.geometry.type)))},new Promise(((e,t)=>{var r=e=>{try{i(n.next(e))}catch(e){t(e)}},o=e=>{try{i(n.throw(e))}catch(e){t(e)}},i=t=>t.done?e(t.value):Promise.resolve(t.value).then(r,o);i((n=n.apply(undefined,null)).next())}));var n}}),y)}},5301:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(3696),o=n.n(r),i=n(9758);const a=()=>{const{ref:e,x:t,y:n}=(0,i.useWheelScroll)({maxOffsetX:250,maxOffsetY:250});return o().createElement("div",{style:{width:"300px",height:"300px",overflow:"hidden",position:"absolute",display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid green"},ref:e},o().createElement("div",{style:{width:"800px",height:"800px",position:"absolute",transform:`translate(${t}px, ${n}px)`,background:"radial-gradient(50% 50% at 50% 50%, red 0%, white 100%)"}}))}},7507:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(3696),o=n.n(r),i=n(9758);const a=()=>{const{ref:e,scale:t}=(0,i.useWheelZoom)();return o().createElement("div",{style:{width:"300px",height:"300px",overflow:"hidden",position:"absolute",display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid green"},ref:e},o().createElement("div",{style:{width:"800px",height:"800px",position:"absolute",transform:`scale(${t})`,background:"radial-gradient(50% 50% at 50% 50%, red 0%, white 100%)"}}))}},6708:(e,t,n)=>{"use strict";n.d(t,{WhiteBoard:()=>u});var r=n(3696),o=n.n(r),i=n(9758),a=n(1406),s=n(7449),c=Math.pow;const l=Math.round(15*Math.random()*c(16,3)+c(16,3)).toString(16);function u(){const[,e,t]=(0,i.useLocalStorageState)("composable-editor-canvas-whiteboard",[]),n=o().useRef(null),[r,c]=(0,i.useLocalStorageState)("composable-editor-canvas-whiteboard:snaps",i.allSnapTypes),[u,p]=(0,i.useLocalStorageState)("composable-editor-canvas-whiteboard:print-mode",!1),[d,f]=(0,i.useLocalStorageState)("composable-editor-canvas-whiteboard:performance-mode",!1),[g,h]=(0,i.useLocalStorageState)("composable-editor-canvas-whiteboard:render-target","svg"),[m,y]=o().useState(!1),[v,x]=o().useState(!1),[b,C]=(0,i.useLocalStorageState)("composable-editor-canvas-whiteboard:background-color",16777215),[E,P]=o().useState(),{pluginLoaded:w,pluginCommandTypes:k}=(0,a.usePlugins)();return(0,a.useInitialStateValidated)(t,w)?o().createElement("div",null,o().createElement(a.CADEditor,{ref:n,id:"whiteboard",operator:l,initialState:t,snapTypes:r,renderTarget:g,setCanUndo:y,setCanRedo:x,setOperation:P,backgroundColor:b,panelVisible:!0,printMode:u,performanceMode:d,onChange:e}),o().createElement("div",{style:{position:"relative"}},o().createElement("label",null,o().createElement("input",{type:"checkbox",checked:u,onChange:()=>p(!u)}),"print mode"),o().createElement("label",null,o().createElement("input",{type:"checkbox",checked:d,onChange:()=>f(!d)}),"performance mode"),i.allSnapTypes.map((e=>o().createElement("label",{key:e},o().createElement("input",{type:"checkbox",checked:r.includes(e),onChange:t=>c(t.target.checked?[...r,e]:r.filter((t=>t!==e)))}),e))),["move canvas","zoom window"].map((e=>o().createElement("button",{onClick:()=>{var t;return null==(t=n.current)?void 0:t.startOperation({type:"non command",name:e})},key:e,style:{position:"relative",borderColor:E===e?"red":void 0}},e)))),o().createElement("div",{style:{position:"relative"}},k.map((e=>{if(e.icon){const t=o().cloneElement(e.icon,{onClick:()=>{var t;return null==(t=n.current)?void 0:t.startOperation({type:"command",name:e.name})},style:{width:"20px",height:"20px",margin:"5px",cursor:"pointer",color:E===e.name?"red":void 0}});return o().createElement("span",{title:e.name,key:e.name},t)}return null})),o().createElement("input",{type:"color",style:{position:"relative",top:"-5px"},value:(0,i.getColorString)(b),onChange:e=>C((0,i.colorStringToNumber)(e.target.value))}),o().createElement("button",{disabled:!m,onClick:()=>{var e;return null==(e=n.current)?void 0:e.undo()},style:{position:"relative",top:"-10px"}},"undo"),o().createElement("button",{disabled:!v,onClick:()=>{var e;return null==(e=n.current)?void 0:e.redo()},style:{position:"relative",top:"-10px"}},"redo"),o().createElement("select",{value:g,onChange:e=>h(e.target.value),style:{position:"relative",top:"-10px"}},(0,s.getAllRendererTypes)().map((e=>o().createElement("option",{key:e,value:e},e)))))):null}},1986:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(3696),o=n.n(r),i=n(9758);const a=()=>{const{width:e,height:t}=(0,i.useWindowSize)();return o().createElement("div",null,Math.round(e)," ",Math.round(t))}},3307:(e,t,n)=>{"use strict";n.r(t),n.d(t,{AlignmentLine:()=>u});var r=n(3696),o=Object.defineProperty,i=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable,c=(e,t,n)=>t in e?o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,l=(e,t)=>{for(var n in t||(t={}))a.call(t,n)&&c(e,n,t[n]);if(i)for(var n of i(t))s.call(t,n)&&c(e,n,t[n]);return e};function u(e){var t,n,o,i;if(void 0===e.value)return null;const a=l({position:"absolute"},e.style);return"x"===e.type?(a.borderLeft="1px dashed black",a.left=(null!=(n=null==(t=e.transformX)?void 0:t.call(e,e.value))?n:e.value)+"px",a.top="0px",a.width="1px",a.height="100%"):(a.borderTop="1px dashed black",a.top=(null!=(i=null==(o=e.transformY)?void 0:o.call(e,e.value))?i:e.value)+"px",a.left="0px",a.width="100%",a.height="1px"),r.createElement("div",{style:a})}},7921:(e,t,n)=>{"use strict";n.r(t),n.d(t,{ChartTooltip:()=>A,getBarChart:()=>_,getChartAxis:()=>P,getChartAxis3D:()=>L,getGridLines:()=>w,getLineChart:()=>E,getPieChart:()=>S,getPolarAreaChart:()=>R,getRadarChart:()=>T,renderChartTooltip:()=>k});var r=n(3696),o=n.n(r),i=n(2792),a=n(8905),s=n(6842),c=n(5773),l=n(1715),u=n(2318),p=n(7486),d=n(1324),f=Object.defineProperty,g=Object.defineProperties,h=Object.getOwnPropertyDescriptors,m=Object.getOwnPropertySymbols,y=Object.prototype.hasOwnProperty,v=Object.prototype.propertyIsEnumerable,x=(e,t,n)=>t in e?f(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,b=(e,t)=>{for(var n in t||(t={}))y.call(t,n)&&x(e,n,t[n]);if(m)for(var n of m(t))v.call(t,n)&&x(e,n,t[n]);return e},C=(e,t)=>g(e,h(t));function E(e,t,n,r,o,i){const a=(0,s.getPointsBounding)(e.flat());if(!a)return;const{axis:l,tx:u,ty:p,minY:d}=P(t,a,n,r,o,i),f=e.map((e=>e.map((e=>({x:u(e.x),y:p(e.y),r:e.r})))));return{children:l,points:f,select:t=>{for(let n=0;n{var n;return(0,c.getTwoPointsDistance)(e,t)<=(null!=(n=e.r)?n:5)}));if(r>=0)return C(b({},f[n][r]),{value:e[n][r]})}},minY:d}}function P(e,t,n,{width:r,height:o},i,a){var s,c,l,u,p,d,f,g;const h=null!=(s=null==a?void 0:a.axisColor)?s:13421772,m=null!=(c=null==a?void 0:a.textColor)?c:0,y=null!=(l=null==a?void 0:a.textSize)?l:12,v=null!=(u=null==a?void 0:a.fontFamily)?u:"monospace",x=null!=(p=null==a?void 0:a.textLineLength)?p:5,b=e=>{var t,n;return null!=(n=null==(t=null==a?void 0:a.getXLabel)?void 0:t.call(a,e))?n:e.toString()},C=e=>{var t,n;return null!=(n=null==(t=null==a?void 0:a.getYLabel)?void 0:t.call(a,e))?n:e.toString()},E=null!=(d=null==n?void 0:n.x)?d:1,P=null!=(f=null==n?void 0:n.y)?f:1,w=null!=(g=null==a?void 0:a.type)?g:"line",k=Math.floor(t.start.x/E)*E,_=Math.ceil(t.end.x/E)*E,S=Math.floor(t.start.y/P)*P,R=Math.ceil(t.end.y/P)*P,T=(r-i.left-i.right)/(_-k),A=(o-i.top-i.bottom)/(R-S),L=e=>(e-k)*T+i.left,M=e=>(R-e)*A+i.top,I=L(k)-x,O=L(_)+((null==a?void 0:a.ySecondary)?x:0),D=M(S),B=D+x,z=M(R),F=E*T,N=[];if(!(null==a?void 0:a.xLabelDisabled))for(let t=k;t<=_;t+=E){const n=L(t);N.push(e.renderPolyline([{x:n,y:B},{x:n,y:z}],{strokeColor:h})),N.push(e.renderText(n+("bar"===w?F/2:0),B,b(t),m,y,v,{textBaseline:"top",textAlign:"center"}))}if(!(null==a?void 0:a.yLabelDisabled))for(let t=S;t<=R;t+=P){const n=M(t);N.push(e.renderPolyline([{x:I,y:n},{x:O,y:n}],{strokeColor:h})),N.push(e.renderText(I,n,C(t),m,y,v,{textBaseline:"middle",textAlign:"right"})),(null==a?void 0:a.ySecondary)&&N.push(e.renderText(O,n,C(t),m,y,v,{textBaseline:"middle",textAlign:"left"}))}return{axis:N,minY:D,tx:L,ty:M,unitWidth:F,reverseTransform:e=>({x:(e.x-i.left)/T+k,y:R-(e.y-i.top)/A})}}function w(e,t,n=t,r=1/0){const o=Math.floor(e.start.x/t),i=Math.ceil(e.end.x/t),a=Math.floor(e.start.y/n),s=Math.ceil(e.end.y/n);if(i-o+1+(s-a)+1>r)return[];const c=[],l=o*t,u=i*t,p=a*n,d=s*n;for(let e=o;e<=i;e++){const n=e*t;c.push([{x:n,y:p},{x:n,y:d}])}for(let e=a;e<=s;e++){const t=e*n;c.push([{x:l,y:t},{x:u,y:t}])}return c}function k(e,{x:t,y:n},r,o){var i,s,c,l,u,f;const g=null!=(i=null==o?void 0:o.textSize)?i:12,h=null!=(s=null==o?void 0:o.fontFamily)?s:"monospace",m=(y=r.x,null!=(x=null==(v=null==o?void 0:o.getXLabel)?void 0:v.call(o,y))?x:y.toString());var y,v,x;const b=(e=>{var t,n;return null!=(n=null==(t=null==o?void 0:o.getYLabel)?void 0:t.call(o,e))?n:e.toString()})(r.y);let C;if(null==o?void 0:o.width)C=o.width;else{const e=(0,d.getTextSizeFromCache)((0,a.getTextStyleFont)({fontFamily:h,fontSize:g}),m),t=(0,d.getTextSizeFromCache)((0,a.getTextStyleFont)({fontFamily:h,fontSize:g}),b);C=e&&t?Math.max(e.width,t.width,40):40}const E=null!=(c=null==o?void 0:o.height)?c:30,P=null!=(l=null==o?void 0:o.textColor)?l:16777215,w=null!=(u=null==o?void 0:o.radius)?u:5,k=null!=(f=null==o?void 0:o.backgroundColor)?f:0;return t+=C/2,n-=E/2,[e.renderPolygon((0,p.getRoundedRectPoints)({x:t,y:n,width:C,height:E},w,30),{fillColor:k}),e.renderText(t,n,m,P,g,h,{textBaseline:"bottom",textAlign:"center"}),e.renderText(t,n,b,P,g,h,{textBaseline:"top",textAlign:"center"})]}function _(e,t,n,r,o,i,a,c){var l,u;let p={start:{x:0,y:0},end:{x:Math.max(...e.map((e=>e.length))),y:0}};for(const t of e.flat(2))tp.end.y&&(p.end.y=t);(null==c?void 0:c.bounding)&&(p=(0,s.getPointsBoundingUnsafe)([c.bounding.start,c.bounding.end,p.start,p.end]));const{axis:d,tx:f,ty:g,reverseTransform:h,unitWidth:m}=P(r,p,o,i,a,b({type:"bar"},c)),y=null!=(l=null==c?void 0:c.barPadding)?l:.1,v=null!=(u=null==c?void 0:c.barSpacing)?u:.05,x=(1-2*y-(e.length-1)*v)/e.length,E=x*m,w=x+v;return e.forEach(((e,r)=>{e.forEach(((e,o)=>{1===e.length&&(e=[0,...e]);const i=f(o)+m*(y+r*w)+E/2,a=e.map((e=>g(e)));for(let e=1;e{const n=h(t),r=Math.floor(n.x),o=n.x-r;if(o>=y&&o<=1-y){const i=Math.floor((o-y)/w);if(o-y-i*w<=x&&i>=0&&i=o[a-1]&&n.y<=o[a]){const n=e[i][r];return C(b({},t),{value:{x:r,y:n.length>2?Math.abs(n[a-1]-n[a]):n}})}}}},tx:f,ty:g}}function S(e,t,n,{width:r,height:o},i,a){var s,p;const d=null!=(s=null==a?void 0:a.type)?s:"pie",f=null!=(p=null==a?void 0:a.startAngle)?p:-90,g=e.map((e=>e.reduce(((e,t)=>e+t),0))),h={x:(r+i.left-i.right)/2,y:(o+i.top-i.bottom)/2,r:Math.min((r-i.left-i.right)/2,(o-i.top-i.bottom)/2)},m=h.r*("doughnut"===d?.5:0),y=h.r-m,v=[],x=[];return e.forEach(((r,o)=>{let i=f;const a=[],s=m+y*o/e.length,c=m+y*(o+1)/e.length;r.forEach(((e,r)=>{a.push(i);const l=i+e/g[o]*360;v.push(n.renderPolygon([...(0,u.arcToPolyline)(C(b({},h),{r:s,startAngle:i,endAngle:l}),5),...(0,u.arcToPolyline)(C(b({},h),{r:c,startAngle:l,endAngle:i,counterclockwise:!0}),5)],{fillColor:t[r],strokeColor:16777215,strokeWidth:2})),i=l})),x.push(a)})),{children:v,select:t=>{const n=(0,c.getTwoPointsDistance)(t,h),r=Math.floor((n-m)/y*e.length);if(r>=0&&re>=o));return-1===i&&(i=n.length-1),C(b({},t),{value:{x:i,y:e[r][i]}})}}}}function R(e,t,n,{width:r,height:o},a,s,p){var d,f;const g=null!=(d=null==p?void 0:p.opacity)?d:.5,h=null!=(f=null==p?void 0:p.axisColor)?f:13421772,m=Math.ceil(Math.max(...e)/a)*a,y={x:(r+s.left-s.right)/2,y:(o+s.top-s.bottom)/2,r:Math.min((r-s.left-s.right)/2,(o-s.top-s.bottom)/2)},v=e=>y.r*e/m,x=[];for(let e=a;e<=m;e+=a){const t=v(e);x.push(n.renderCircle(y.x,y.y,t,{strokeColor:h})),x.push(n.renderCircle(y.x,y.y-t,8,{fillColor:16777215,strokeWidth:0})),x.push(n.renderText(y.x,y.y-t,e.toString(),h,12,"monospace",{textAlign:"center",textBaseline:"middle"}))}let E=-90;const P=[];return e.forEach(((r,o)=>{const a=E+360/e.length;P.push((0,i.getTwoNumberCenter)(E,a)),x.push(n.renderPolygon([y,...(0,u.arcToPolyline)(C(b({},y),{r:v(r),startAngle:E,endAngle:a}),5)],{fillColor:t[o],strokeColor:16777215,strokeWidth:2,fillOpacity:g})),E=a})),{children:x,select:t=>{const n=(0,c.getTwoPointsDistance)(t,y);let r=(0,l.radianToAngle)((0,l.getTwoPointsRadian)(t,y))- -90;r<0&&(r+=360);const o=Math.floor(r*e.length/360);if(o>=0&&oh.r*e/g,y=e[0].map(((t,n)=>360*n/e[0].length-90)),v=[],x=m(g);for(const e of y){const t=(0,u.getArcPointAtAngle)(C(b({},h),{r:x}),e);v.push(n.renderPolyline([h,t],{strokeColor:f}))}for(let e=i;e<=g;e+=i){const t=m(e),r=[];for(const e of y)r.push((0,u.getArcPointAtAngle)(C(b({},h),{r:t}),e));v.push(n.renderPolygon(r,{strokeColor:f})),v.push(n.renderRect(h.x-10,h.y-t-6,20,12,{fillColor:16777215,strokeWidth:0})),v.push(n.renderText(h.x,h.y-t,e.toString(),f,12,"monospace",{textAlign:"center",textBaseline:"middle"}))}const E=e.map((e=>e.map(((e,t)=>(0,u.getArcPointAtAngle)(C(b({},h),{r:m(e)}),y[t])))));return E.forEach(((e,r)=>{v.push(n.renderPolygon(e,{fillColor:t[r],strokeWidth:0,fillOpacity:d})),v.push(n.renderPolygon(e,{strokeColor:t[r],strokeWidth:2}));for(const o of e)v.push(n.renderCircle(o.x,o.y,3,{fillColor:t[r],strokeWidth:0}))})),{children:v,select:t=>{for(let n=0;n(0,c.getTwoPointsDistance)(e,t)<=3));if(r>=0)return C(b({},E[n][r]),{value:{x:r,y:e[n][r]}})}},circle:h,angles:y}}function A(e){return o().createElement("div",{style:{position:"absolute",top:e.y-35+"px",left:`${e.x}px`,display:"flex",flexDirection:"column",background:"black",color:"white",width:"40px",textAlign:"center",fontSize:"12px",borderRadius:"5px",pointerEvents:"none"}},o().createElement("span",null,e.label),o().createElement("span",null,e.value))}function L(e,t){const{minX:n,minY:r,minZ:o,maxX:i,maxY:a,maxZ:s}=function(e,t={min:1/0,max:-1/0}){let n=t.min,r=t.min,o=t.min,i=t.max,a=t.max,s=t.max;for(const t of e){const e=t[0],c=t[1],l=t[2];ei&&(i=e),ca&&(a=c),ls&&(s=l)}return{maxX:i,minX:n,minY:r,maxY:a,minZ:o,maxZ:s}}(e.flat(),{min:0,max:0}),c=Math.floor(n/t.x)*t.x,l=Math.ceil(i/t.x)*t.x,u=Math.floor(r/t.y)*t.y,p=Math.ceil(a/t.y)*t.y,d=Math.floor(o/t.z)*t.z,f=Math.ceil(s/t.z)*t.z,g=[];for(let e=n;e<=l;e+=t.x)g.push({geometry:{type:"lines",points:[e,u,0,e,p,0]},color:[0,1,0,1]}),g.push({geometry:{type:"lines",points:[e,0,d,e,0,f]},color:[0,0,1,1]});for(let e=r;e<=p;e+=t.y)g.push({geometry:{type:"lines",points:[c,e,0,l,e,0]},color:[1,0,0,1]}),g.push({geometry:{type:"lines",points:[0,e,d,0,e,f]},color:[0,0,1,1]});for(let e=o;e<=f;e+=t.z)g.push({geometry:{type:"lines",points:[c,0,e,l,0,e]},color:[1,0,0,1]}),g.push({geometry:{type:"lines",points:[0,u,e,0,p,e]},color:[0,1,0,1]});return g}},6487:(e,t,n)=>{"use strict";n.d(t,{Cursor:()=>f});var r=n(3696),o=n.n(r),i=Object.defineProperty,a=Object.defineProperties,s=Object.getOwnPropertyDescriptors,c=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,u=Object.prototype.propertyIsEnumerable,p=(e,t,n)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,d=(e,t)=>{for(var n in t||(t={}))l.call(t,n)&&p(e,n,t[n]);if(c)for(var n of c(t))u.call(t,n)&&p(e,n,t[n]);return e};const f=o().forwardRef(((e,t)=>{var n,r;const[i,c]=o().useState(!1),[l,u]=o().useState(!1),p=o().useRef();return o().useEffect((()=>{u(!0),p.current&&clearTimeout(p.current),p.current=setTimeout((()=>{u(!1)}),500)}),[null==(n=e.style)?void 0:n.left,null==(r=e.style)?void 0:r.top]),o().createElement(o().Fragment,null,o().createElement("input",{ref:t,style:(f=d({},e.style),g={border:0,outline:"none",width:"0px",position:"absolute",opacity:0},a(f,s(g))),readOnly:e.readOnly,onKeyDown:e.onKeyDown,onCompositionEnd:e.onCompositionEnd,onBlur:t=>{var n;null==(n=e.onBlur)||n.call(e,t),c(!1)},autoFocus:e.autoFocus,onFocus:t=>{var n;null==(n=e.onFocus)||n.call(e,t),c(!0)}}),o().createElement("style",null,"@-webkit-keyframes blink {\n 0%, 49.9%, 100% { opacity: 0; }\n 50%, 99.9% { opacity: 1; }\n }"),o().createElement("span",{style:d({display:!i||e.readOnly?"none":"inline-block",position:"absolute",width:"1px",animation:l?void 0:"blink 1s infinite",borderLeft:"1px solid black",userSelect:"none"},e.style)}));var f,g}))},9294:(e,t,n)=>{"use strict";n.r(t),n.d(t,{LinearDimension:()=>a,getLinearDimensionGeometries:()=>o,getLinearDimensionTextPosition:()=>i});var r=n(1324);function o(e,t,n){const o=(0,r.getTwoPointCenter)(e.p1,e.p2);let i,a,s,c,l,u=[];const{textPosition:p,size:d,textRotation:f}=n(e),g=(0,r.getTwoPointsRadian)(e.position,o),h=Math.abs(g);if(e.direct){const n=e.p1.x>e.p2.x?e.p2:e.p1,o=e.p1.x>e.p2.x?e.p1:e.p2,u=(0,r.twoPointLineToGeneralFormLine)(n,o),p=u?(0,r.getPerpendicularDistance)(e.position,u):(0,r.getTwoPointsDistance)(e.position,n),f=(0,r.getTwoPointsRadian)(o,n);let h=f-g;h<-Math.PI&&(h+=2*Math.PI);const m=h>0&&hMath.PI/4&&h<3*Math.PI/4){const n=e.position.y>o.y?1:-1;i=[e.p1,{x:e.p1.x,y:e.position.y+n*t.margin}],a=[e.p2,{x:e.p2.x,y:e.position.y+n*t.margin}];const u={x:e.p1.x,y:e.position.y},p={x:e.p2.x,y:e.position.y};s=[{x:Math.min(e.p1.x,e.p2.x,e.position.x),y:e.position.y},{x:Math.max(e.p1.x,e.p2.x,e.position.x),y:e.position.y}];let f=u.xo.x?1:-1;i=[e.p1,{x:e.position.x+n*t.margin,y:e.p1.y}],a=[e.p2,{x:e.position.x+n*t.margin,y:e.p2.y}];const u={x:e.position.x,y:e.p1.y},p={x:e.position.x,y:e.p2.y};s=[{x:e.position.x,y:Math.min(e.p1.y,e.p2.y,e.position.y)},{x:e.position.x,y:Math.max(e.p1.y,e.p2.y,e.position.y)}];let f=u.y(0,r.rotatePosition)(e,p,f))));const m=[...i,...a,...s,...c,...l,...u];return{lines:[...(0,r.iteratePolylineLines)(i),...(0,r.iteratePolylineLines)(a),...(0,r.iteratePolylineLines)(s)],regions:[{points:c,lines:Array.from((0,r.iteratePolygonLines)(c))},{points:l,lines:Array.from((0,r.iteratePolygonLines)(l))},{points:u,lines:Array.from((0,r.iteratePolygonLines)(u))}],points:m,bounding:(0,r.getPointsBounding)(m),renderingLines:[]}}function i(e,t,n){const o=(0,r.getTwoPointCenter)(e.p1,e.p2);let i,a,s,c=0;const l=(0,r.getTwoPointsRadian)(e.position,o),u=Math.abs(l);if(e.direct){const o=e.p1.x>e.p2.x?e.p2:e.p1,u=e.p1.x>e.p2.x?e.p1:e.p2,p=(0,r.twoPointLineToGeneralFormLine)(o,u),d=p?(0,r.getPerpendicularPoint)(e.position,p):o,f=(0,r.getTwoPointsDistance)(e.position,d);c=(0,r.getTwoPointsRadian)(u,o);let g=(0,r.getTwoPointsRadian)(u,o)-l;g<-Math.PI&&(g+=2*Math.PI);const h=g>0&&gMath.PI/4&&u<3*Math.PI/4?(i={x:e.position.x,y:e.position.y-t},a=(0,r.formatNumber)((0,r.getTwoNumbersDistance)(e.p1.x,e.p2.x)).toString(),s=n((0,r.getTextStyleFont)(e),a),s&&(i.x-=s.width/2)):(i={x:e.position.x-t,y:e.position.y},a=(0,r.formatNumber)((0,r.getTwoNumbersDistance)(e.p1.y,e.p2.y)).toString(),s=n((0,r.getTextStyleFont)(e),a),s&&(i.y+=s.width/2),c=-Math.PI/2);return{text:e.text||a,textPosition:i,size:s,textRotation:c}}const a=(0,r.and)(r.TextStyle,{p1:r.Position,p2:r.Position,position:r.Position,direct:(0,r.optional)(r.boolean),text:(0,r.optional)(r.string)})},6424:(e,t,n)=>{"use strict";n.r(t),n.d(t,{RadialDimension:()=>a,getRadialDimensionGeometries:()=>o,getRadialDimensionTextPosition:()=>i});var r=n(1324);function o(e,t,n,o){const i=(0,r.getPointByLengthAndDirection)(t,t.r,e.position),a=(0,r.getTwoPointsDistance)(t,e.position),s=(0,r.getPointByLengthAndDirection)(i,n.arrowSize,e.position),c=(0,r.rotatePositionByCenter)(s,i,n.arrowAngle),l=(0,r.rotatePositionByCenter)(s,i,-n.arrowAngle),u=[a>t.r?t:i,e.position],p=[i,c,l];let d=[];const{textPosition:f,textRotation:g,size:h}=o(e,t);h&&(d=[{x:f.x,y:f.y-h.height},{x:f.x+h.width,y:f.y-h.height},{x:f.x+h.width,y:f.y},{x:f.x,y:f.y}].map((e=>(0,r.rotatePosition)(e,f,g))));const m=[...u,...p,...d];return{lines:Array.from((0,r.iteratePolylineLines)(u)),regions:[{points:p,lines:Array.from((0,r.iteratePolygonLines)(p))},{points:d,lines:Array.from((0,r.iteratePolygonLines)(d))}],points:m,bounding:(0,r.getPointsBounding)(m),renderingLines:[]}}function i(e,t,n,o){let i=e.position;const a=`R${(0,r.formatNumber)(t.r)}`,s=o((0,r.getTextStyleFont)(e),a);let c=(0,r.getTwoPointsRadian)(e.position,t);return s&&((0,r.getTwoPointsDistance)(t,e.position)>t.r?e.position.x>t.x?i=(0,r.getPointByLengthAndDirection)(e.position,s.width,t):c-=Math.PI:e.position.x{"use strict";n.r(t),n.d(t,{DragMask:()=>u});var r=n(3696),o=Object.defineProperty,i=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable,c=(e,t,n)=>t in e?o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,l=(e,t)=>{for(var n in t||(t={}))a.call(t,n)&&c(e,n,t[n]);if(i)for(var n of i(t))s.call(t,n)&&c(e,n,t[n]);return e};function u(e){return r.createElement("div",{style:l({position:"fixed",inset:"0px",cursor:"grabbing"},e.style),onMouseUp:e.onDragEnd,onMouseMove:e.onDragging,onMouseLeave:e.ignoreLeavingEvent?void 0:e.onDragEnd},e.children)}},4848:(e,t,n)=>{"use strict";n.r(t),n.d(t,{CircleArcEditBar:()=>a});var r=n(3696),o=n(1324),i=n(2286);function a(e){const t=e.x,n=e.y,a=(0,o.angleToRadian)(e.startAngle),s=(0,o.angleToRadian)(e.endAngle),c=(a+s)/2,l=[{data:"center",x:t,y:n,cursor:"move"},{data:"start angle",x:t+e.r*Math.cos(a),y:n+e.r*Math.sin(a),cursor:(0,o.getResizeCursor)(e.startAngle,"top")},{data:"end angle",x:t+e.r*Math.cos(s),y:n+e.r*Math.sin(s),cursor:(0,o.getResizeCursor)(e.endAngle,"top")},{data:"radius",x:t+e.r*Math.cos(c),y:n+e.r*Math.sin(c),cursor:(0,o.getResizeCursor)((e.startAngle+e.endAngle)/2,"right")}];return r.createElement(i.EditBar,{positions:l,scale:e.scale,resizeSize:e.resizeSize,onClick:e.onClick,onMouseDown:e.onMouseDown})}},1369:(e,t,n)=>{"use strict";n.r(t),n.d(t,{CircleEditBar:()=>i});var r=n(3696),o=n(2286);function i(e){const t=e.x,n=e.y,i=[{data:"center",x:t,y:n,cursor:"move"},{data:"edge",x:t-e.radius,y:n,cursor:"ew-resize"},{data:"edge",x:t,y:n-e.radius,cursor:"ns-resize"},{data:"edge",x:t+e.radius,y:n,cursor:"ew-resize"},{data:"edge",x:t,y:n+e.radius,cursor:"ns-resize"}];return r.createElement(o.EditBar,{positions:i,scale:e.scale,resizeSize:e.resizeSize,onClick:e.onClick,onMouseDown:e.onMouseDown})}},2286:(e,t,n)=>{"use strict";n.r(t),n.d(t,{EditBar:()=>o});var r=n(3696);function o(e){var t,n;const o=null!=(t=e.scale)?t:1,i=(null!=(n=e.resizeSize)?n:5)/o,a=1/o;return r.createElement(r.Fragment,null,e.positions.map(((t,n)=>r.createElement("div",{key:n,style:{width:i+"px",height:i+"px",border:`${a}px solid green`,position:"absolute",backgroundColor:"white",boxSizing:"border-box",pointerEvents:"auto",left:t.x-i/2+"px",top:t.y-i/2+"px",cursor:t.cursor},onMouseDown:n=>{var r;return null==(r=e.onMouseDown)?void 0:r.call(e,n,t.data,t.cursor)},onClick:n=>{var r;return null==(r=e.onClick)?void 0:r.call(e,n,t.data,t.cursor)}}))))}},4332:(e,t,n)=>{"use strict";n.r(t),n.d(t,{EllipseArcEditBar:()=>h});var r=n(3696),o=n(1324),i=n(2286),a=Object.defineProperty,s=Object.defineProperties,c=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,u=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable,d=(e,t,n)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,f=(e,t)=>{for(var n in t||(t={}))u.call(t,n)&&d(e,n,t[n]);if(l)for(var n of l(t))p.call(t,n)&&d(e,n,t[n]);return e},g=(e,t)=>s(e,c(t));function h(e){var t;const n={x:e.cx,y:e.cy},a=(0,o.angleToRadian)(e.startAngle),s=(0,o.angleToRadian)(e.endAngle),c=-(null!=(t=e.angle)?t:0),l=[{data:"center",x:e.cx,y:e.cy,cursor:"move"},g(f({data:"start angle"},(0,o.rotatePositionByCenter)({x:e.cx+e.rx*Math.cos(a),y:e.cy+e.ry*Math.sin(a)},n,c)),{cursor:(0,o.getResizeCursor)(e.startAngle-c,"top")}),g(f({data:"end angle"},(0,o.rotatePositionByCenter)({x:e.cx+e.rx*Math.cos(s),y:e.cy+e.ry*Math.sin(s)},n,c)),{cursor:(0,o.getResizeCursor)(e.endAngle-c,"top")})];return r.createElement(i.EditBar,{positions:l,scale:e.scale,resizeSize:e.resizeSize,onClick:e.onClick,onMouseDown:e.onMouseDown})}},3869:(e,t,n)=>{"use strict";n.r(t),n.d(t,{EllipseEditBar:()=>a});var r=n(3696),o=n(1324),i=n(2286);function a(e){var t;const n={x:e.cx,y:e.cy},a=-(null!=(t=e.angle)?t:0),s=(0,o.rotatePositionByCenter)({x:e.cx-e.rx,y:e.cy},n,a),c=(0,o.rotatePositionByCenter)({x:e.cx+e.rx,y:e.cy},n,a),l=(0,o.rotatePositionByCenter)({x:e.cx,y:e.cy-e.ry},n,a),u=(0,o.rotatePositionByCenter)({x:e.cx,y:e.cy+e.ry},n,a),p=[{data:"center",x:e.cx,y:e.cy,cursor:"move"},{data:"major axis",x:s.x,y:s.y,cursor:(0,o.getResizeCursor)(-a,"left")},{data:"major axis",x:c.x,y:c.y,cursor:(0,o.getResizeCursor)(-a,"right")},{data:"minor axis",x:l.x,y:l.y,cursor:(0,o.getResizeCursor)(-a,"top")},{data:"minor axis",x:u.x,y:u.y,cursor:(0,o.getResizeCursor)(-a,"bottom")}];return r.createElement(i.EditBar,{positions:p,scale:e.scale,resizeSize:e.resizeSize,onClick:e.onClick,onMouseDown:e.onMouseDown})}},4489:(e,t,n)=>{"use strict";n.r(t),n.d(t,{PolylineEditBar:()=>a});var r=n(3696),o=n(1324),i=n(2286);function a(e){const t=e.points,n=!e.isPolygon&&t.length>2&&(0,o.isSamePoint)(t[0],t[t.length-1]),a=[];if(t.forEach(((r,o)=>{if(!e.isPolygon&&o===t.length-1&&n||a.push({data:[o],x:r.x,y:r.y,cursor:"move"}),!e.midpointDisabled&&o!==t.length-1){const e=t[o+1];a.push({data:[o,o+1],x:(r.x+e.x)/2,y:(r.y+e.y)/2,cursor:"move"})}if(e.isPolygon&&o===t.length-1){const e=t[0];a.push({data:[t.length-1,0],x:(r.x+e.x)/2,y:(r.y+e.y)/2,cursor:"move"})}})),n)for(const e of a)e.data.includes(0)?e.data.push(t.length-1):e.data.includes(t.length-1)&&e.data.push(0);return r.createElement(i.EditBar,{positions:a,scale:e.scale,resizeSize:e.resizeSize,onClick:e.onClick,onMouseDown:e.onMouseDown})}},5634:(e,t,n)=>{"use strict";n.r(t),n.d(t,{ResizeBar:()=>p});var r=n(3696),o=n(9758),i=Object.defineProperty,a=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,c=Object.prototype.propertyIsEnumerable,l=(e,t,n)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,u=(e,t)=>{for(var n in t||(t={}))s.call(t,n)&&l(e,n,t[n]);if(a)for(var n of a(t))c.call(t,n)&&l(e,n,t[n]);return e};function p(e){var t,n,i;const{resizeSize:a}=e,s=null!=(t=e.scale)?t:1,c=(null!=a?a:5)/s,l=1/s,p=c/2,d=c/2-l,f=null!=(n=e.rotate)?n:0,g=null!=(i=e.directions)?i:o.allDirections,h=[];for(const e of o.allDirections)if(g.includes(e)){const t={cursor:(0,o.getResizeCursor)(f,e)};e.includes("left")&&(t.left=-p+"px"),e.includes("right")&&(t.right=-d+"px"),e.includes("top")&&(t.top=-p+"px"),e.includes("bottom")&&(t.bottom=-d+"px"),"left"!==e&&"right"!==e&&"center"!==e||(t.top=`calc(50% - ${p}px)`),"top"!==e&&"bottom"!==e&&"center"!==e||(t.left=`calc(50% - ${p}px)`),h.push({direction:e,style:t})}return r.createElement(r.Fragment,null,h.map(((t,n)=>r.createElement("div",{key:n,style:u({width:c+"px",height:c+"px",border:`${l}px solid green`,position:"absolute",backgroundColor:"white",boxSizing:"border-box",pointerEvents:"auto"},t.style),onMouseDown:n=>{var r;null==(r=e.onMouseDown)||r.call(e,n,t.direction)},onClick:n=>{var r;null==(r=e.onClick)||r.call(e,n,t.direction)}}))))}},2800:(e,t,n)=>{"use strict";n.r(t),n.d(t,{RotationBar:()=>o});var r=n(3696);function o(e){var t,n,o;const i=null!=(t=e.scale)?t:1,a=(null!=(n=e.rotateStickLength)?n:40)/i,s=1/i,c=(null!=(o=e.rotateCircleSize)?o:10)/i;return r.createElement(r.Fragment,null,r.createElement("div",{style:{left:`calc(50% - ${s/2}px)`,top:-a+"px",width:Math.max(s,1)+"px",height:a+"px",position:"absolute",boxSizing:"border-box",backgroundColor:"green"}}),r.createElement("div",{style:{left:`calc(50% - ${s/2+c/2}px)`,top:-a-c+"px",width:c+"px",height:c+"px",position:"absolute",border:`${Math.max(s,1)}px solid green`,backgroundColor:"white",borderRadius:c/2+"px",cursor:"grab",pointerEvents:"auto"},onMouseDown:e.onMouseDown}))}},2607:(e,t,n)=>{"use strict";n.r(t),n.d(t,{renderEquation:()=>p,renderExpression:()=>d});var r=n(3031),o=n(8905),i=Object.defineProperty,a=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,c=Object.prototype.propertyIsEnumerable,l=(e,t,n)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,u=(e,t)=>{for(var n in t||(t={}))s.call(t,n)&&l(e,n,t[n]);if(a)for(var n of a(t))c.call(t,n)&&l(e,n,t[n]);return e};function p(e,t,n={}){const r=u(u({},f),n),{children:i,render:a,font:s}=g(e,r.color,r.fontSize,r.fontFamily,r.paddingOperator,r.keepBinaryExpressionOrder),c=a(t.left),l=a(t.right);let p;if(c&&l){const t=" = ",n=(0,o.getTextSizeFromCache)(s,t);if(n){const o=c.size.width+n.width+l.size.width,a=Math.max(c.size.height,n.height,l.size.height),s=o+2*r.paddingX,u=a+2*r.paddingY,d=u/2;let f=s/2-o/2;c.render(f+c.size.width/2,d),f+=c.size.width,i.push(e.renderText(f+n.width/2,d,t,r.color,r.fontSize,r.fontFamily,{textBaseline:"middle",textAlign:"center"})),f+=n.width,l.render(f+l.size.width/2,d),p=e.renderResult(i,s,u,{attributes:{style:{width:"100%"}}})}}return p}function d(e,t,n={}){const r=u(u({},f),n),{children:o,render:i}=g(e,r.color,r.fontSize,r.fontFamily,r.paddingOperator,r.keepBinaryExpressionOrder),a=i(t);let s;if(a){const t=a.size.width+2*r.paddingX,n=a.size.height+2*r.paddingY;a.render(t/2,n/2),s=e.renderResult(o,t,n,{attributes:{style:{width:"100%"}}})}return s}const f={color:0,fontSize:20,fontFamily:"monospace",paddingX:10,paddingY:10,paddingOperator:5,keepBinaryExpressionOrder:!1};function g(e,t,n,i,a,s){const c=[],l=`${n}px ${i}`,u=(p,d=Number.MAX_SAFE_INTEGER,f=1,g=!1)=>{const h=n*f,m=1===f?l:`${h}px ${i}`;if("BinaryExpression"===p.type){const n="/"===p.operator||"**"===p.operator&&"NumericLiteral"===p.right.type&&.5===p.right.value?Number.MAX_SAFE_INTEGER:r.priorizedBinaryOperators.findIndex((e=>e.includes(p.operator))),l=u(p.left,n,f),g=u(p.right,"+"===p.operator||"*"===p.operator?n:n-.1,"**"===p.operator?.75*f:f);if(l&&g){if("**"===p.operator){if("NumericLiteral"===p.right.type&&.5===p.right.value){const n=l.size.width+2*a,r=l.size.height+a;return{size:{width:n,height:r},render(o,i){l.render(o+a,i+a/2),c.push(e.renderPolyline([{x:o+n/2,y:i-r/2},{x:o-n/2+2*a,y:i-r/2},{x:o-n/2+a,y:i+r/2},{x:o-n/2,y:i+r/2-a}],{strokeColor:t,strokeWidth:1}))}}}const n=l.size.width+g.size.width,r=l.size.height+g.size.height/2;return{size:{width:n,height:r},render(e,t){l.render(e-n/2+l.size.width/2,t+r/2-l.size.height/2-g.size.height/4),g.render(e-n/2+l.size.width+g.size.width/2,t-r/2+g.size.height/2)}}}if("/"===p.operator){let r=Math.max(l.size.width,g.size.width)+2*a;const s=l.size.height+2*a+g.size.height;let u;const p=Math.max(s,h);return n>d&&(u=(0,o.getTextSizeFromCache)(`${p}px ${i}`,"(")),u&&(r+=2*u.width),{size:{width:r,height:s},render(n,o){var d;o=o-s/2+l.size.height+a,u&&c.push(e.renderText(n-r/2+u.width/2,o,"(",t,p,i,{textBaseline:"middle",textAlign:"center"})),l.render(n,o-a-l.size.height/2);const f=null!=(d=null==u?void 0:u.width)?d:0;c.push(e.renderPolyline([{x:n-r/2+f,y:o},{x:n+r/2-f,y:o}],{strokeColor:t,strokeWidth:1})),g.render(n,o+a+g.size.height/2),u&&c.push(e.renderText(n+r/2-u.width/2,o,")",t,p,i,{textBaseline:"middle",textAlign:"center"}))}}}const r="*"===p.operator?"":p.operator,u=(0,o.getTextSizeFromCache)(m,r);if(u){let p=l.size.width+u.width+g.size.width+a*(u.width?2:0);const f=Math.max(l.size.height,u.height,g.size.height);let m;const y=Math.max(f,h);return(n>d||n===d&&s)&&(m=(0,o.getTextSizeFromCache)(`${y}px ${i}`,"(")),m&&(p+=2*m.width),{size:{width:p,height:f},render(n,o){let s=n-p/2;m&&(c.push(e.renderText(s+m.width/2,o,"(",t,y,i,{textBaseline:"middle",textAlign:"center"})),s+=m.width),l.render(s+l.size.width/2,o),s+=l.size.width,u.width&&(s+=a,c.push(e.renderText(s+u.width/2,o,r,t,h,i,{textBaseline:"middle",textAlign:"center"})),s+=u.width+a),g.render(s+g.size.width/2,o),m&&(s+=g.size.width,c.push(e.renderText(s+m.width/2,o,")",t,y,i,{textBaseline:"middle",textAlign:"center"})))}}}}return}if("UnaryExpression"===p.type){const n=(0,o.getTextSizeFromCache)(l,p.operator),r=u(p.argument,-1,f);if(n&&r){let a=n.width+r.size.width;const s=Math.max(n.height,r.size.height);let l;const u=Math.max(s,h);return d<=1&&(l=(0,o.getTextSizeFromCache)(`${u}px ${i}`,"(")),l&&(a+=2*l.width),{size:{width:a,height:s},render(o,s){var d;l&&c.push(e.renderText(o-a/2+l.width/2,s,"(",t,u,i,{textBaseline:"middle",textAlign:"center"}));const f=null!=(d=null==l?void 0:l.width)?d:0;c.push(e.renderText(o-a/2+n.width/2+f,s,p.operator,t,h,i,{textBaseline:"middle",textAlign:"center"})),r.render(o-a/2+n.width+r.size.width/2+f,s),l&&c.push(e.renderText(o+a/2-l.width/2,s,")",t,u,i,{textBaseline:"middle",textAlign:"center"}))}}}return}let y;if("Identifier"===p.type){if(!g&&p.name.length>1){const e=u({type:"Identifier",name:p.name[0]},void 0,f),t=u({type:"Identifier",name:p.name.substring(1)},void 0,.75*f,!0);if(e&&t){const n=e.size.width+t.size.width,r=e.size.height+t.size.height/2;return{size:{width:n,height:r},render(o,i){e.render(o-n/2+e.size.width/2,i-r/2+e.size.height/2+t.size.height/4),t.render(o-n/2+e.size.width+t.size.width/2,i+r/2-t.size.height/2)}}}}y=p.name}else"NumericLiteral"===p.type&&(y=p.value.toString());if(y){const n=(0,o.getTextSizeFromCache)(l,y);if(n){const r=y;return{size:n,render:(n,o)=>c.push(e.renderText(n,o,r,t,h,i,{textBaseline:"middle",textAlign:"center"}))}}}};return{font:l,children:c,render:u}}},123:(e,t,n)=>{"use strict";n.r(t),n.d(t,{divide:()=>a,divideFactors:()=>l,expressionToFactors:()=>g,extractFactors:()=>s,factorToExpression:()=>y,factorsToEquationParams:()=>w,factorsToExpression:()=>m,optimizeFactor:()=>E,optimizeFactors:()=>C,powerFactor:()=>v});var r=n(6072),o=n(2792),i=Math.pow;function a(e,t){const n=g(e);if(!n)return;const r=g(t);if(!r)return;const o=l(n,r);return o?m(o):void 0}function s(e,t){let n;for(const r of e){const e=c(r,t);if(!e)return;if(n){const t={variables:{},constant:P(n.constant,e.constant)};for(const[r,o]of Object.entries(e.variables)){const e=n.variables[r];e&&(t.variables[r]=Math.min(e,o))}n=t}else n=e}if(n&&(Object.keys(n.variables).length>0||n.constant>1)){const r={constant:i(n.constant,1/t),variables:[]},o={constant:n.constant,variables:[]};for(const[e,i]of Object.entries(n.variables))r.variables.push(...new Array(i).fill(e)),o.variables.push(...new Array(i*t).fill(e));const a=l(e,[o]);if(!a)return;return{base:r,factors:a}}}function c(e,t){var n,r;const o=new Map;for(const t of e.variables){if("string"!=typeof t)return;o.set(t,(null!=(n=o.get(t))?n:0)+1)}const i=null!=(r=e.constant)?r:1,a={variables:{},constant:Number.isInteger(i)&&i?Math.abs(i):1};for(const[e,n]of o)n>=t&&(a.variables[e]=Math.floor(n/t));if(Object.keys(a.variables).length>0)return a}function l(e,t){for(const n of e){const r=f(n,t[0]);if(r){const n=d(e,t.map((e=>x(e,r))));if(0===n.length)return[r];if(n.length>e.length)continue;const o=l(n,t);if(!o)continue;return[r,...o]}}}function u(e,t){var n,r;const o=f(e,t);if(o&&0===o.variables.length)return(null!=(n=e.constant)?n:1)-(null!=(r=t.constant)?r:1)}function p(e,t){var n,r;const o=f(e,t);if(o&&0===o.variables.length)return(null!=(n=e.constant)?n:1)+(null!=(r=t.constant)?r:1)}function d(e,t){var n;const r=[...e];for(const e of t){let t=!1;for(let n=0;n=0)o.splice(t,1);else{for(let n=0;nb(e)))),[...t,...n]}const t=h(e);if(t)return[t]}function h(e){if("NumericLiteral"===e.type)return{constant:e.value,variables:[]};if("Identifier"===e.type)return{variables:[e.name]};if("UnaryExpression"===e.type&&"-"===e.operator){const t=h(e.argument);if(!t)return;return b(t)}if("BinaryExpression"===e.type){if("*"===e.operator){const t=h(e.left);if(!t)return;const n=h(e.right);if(!n)return;return x(t,n)}if("/"===e.operator){const t=h(e.left);if(!t)return;const n=h(e.right);if(!n)return;return f(t,n)||(t.variables.push({value:[n],power:-1}),t)}if("**"===e.operator){if("NumericLiteral"===e.right.type&&(e.right.value<1||!Number.isInteger(e.right.value))){const t=g(e.left);if(!t)return;return{variables:[{value:t,power:e.right.value}]}}const t=h(e.left);if(!t)return;if("NumericLiteral"!==e.right.type)return;if(!Number.isInteger(e.right.value))return;if(e.right.value<1)return;return v(t,e.right.value)}}return"CallExpression"===e.type?{variables:[(0,r.printMathStyleExpression)(e)]}:void 0}function m(e){if(0===e.length)return{type:"NumericLiteral",value:0};if(1===e.length)return y(e[0]);const[t,...n]=e;return{type:"BinaryExpression",left:y(t),operator:"+",right:m(n)}}function y(e){var t;if(0===e.variables.length)return{type:"NumericLiteral",value:null!=(t=e.constant)?t:1};if(void 0!==e.constant)return{type:"BinaryExpression",left:{type:"NumericLiteral",value:e.constant},operator:"*",right:y({variables:e.variables})};if(1===e.variables.length){const t=e.variables[0];return"string"!=typeof t?{type:"BinaryExpression",left:m(t.value),operator:"**",right:{type:"NumericLiteral",value:t.power}}:{type:"Identifier",name:t}}const[n,...r]=[...e.variables];return{type:"BinaryExpression",left:y({variables:[n]}),operator:"*",right:y({variables:r})}}function v(e,t){let n=1;const r=[];for(let o=0;o"string"==typeof e));let n=e.constant||1;for(const r of e.variables)if("string"!=typeof r){if(-1===r.power){for(const e of r.value){e.constant&&(n/=e.constant);for(const n of e.variables){const e=t.indexOf(n);e>=0?t.splice(e,1):t.push({power:-1,value:[{variables:[n]}]})}}continue}let e=!1;for(const a of r.value){const s=t.find((e=>"string"!=typeof e&&(0,o.deepEquals)(r.value,e.value)));if(s&&"string"!=typeof s){a.constant&&(n*=i(a.constant,r.power)),s.power+=r.power,e=!0;break}}e||t.push(r)}return{variables:t,constant:1===n?void 0:n}}function P(e,t){return e<=1||t<=1?1:e===t?e:e>t?P(e%t,t):P(e,t%e)}function w(e,t){const n=[];for(const r of e){if(r.variables.some((e=>e!==t)))return;const e=r.variables.length;for(let t=n.length;t<=e;t++)n.push(0);n[e]+=r.constant||1}return n.reverse()}},4546:(e,t,n)=>{"use strict";n.r(t);var r=n(4281),o={};for(const e in r)"default"!==e&&(o[e]=()=>r[e]);n.d(t,o);var i=n(123);o={};for(const e in i)"default"!==e&&(o[e]=()=>i[e]);n.d(t,o);var a=n(6277);o={};for(const e in a)"default"!==e&&(o[e]=()=>a[e]);n.d(t,o);var s=n(7492);o={};for(const e in s)"default"!==e&&(o[e]=()=>s[e]);n.d(t,o)},6277:(e,t,n)=>{"use strict";n.r(t),n.d(t,{expressionHasVariable:()=>d,getReverseOperator:()=>x,iterateEquation:()=>p,iterateExpression:()=>u,optimizeEquation:()=>f,optimizeExpression:()=>v,printEquation:()=>g});var r=n(3031),o=n(2792),i=n(123),a=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),s=Math.pow,c=function(e,t){this[0]=e,this[1]=t},l=e=>{var t,n=e[a("asyncIterator")],r=!1,o={};return null==n?(n=e[a("iterator")](),t=e=>o[e]=t=>n[e](t)):(n=n.call(e),t=e=>o[e]=t=>{if(r){if(r=!1,"throw"===e)throw t;return t}return r=!0,{done:!1,value:new c(new Promise((r=>{var o=n[e](t);o instanceof Object||(()=>{throw TypeError("Object expected")})(),r(o)})),1)}}),o[a("iterator")]=()=>o,t("next"),"throw"in n?t("throw"):o.throw=e=>{throw e},"return"in n&&t("return"),o};function*u(e){if(yield e,"BinaryExpression"===e.type)yield*l(u(e.left)),yield*l(u(e.right));else if("UnaryExpression"===e.type)yield*l(u(e.argument));else if("CallExpression"===e.type)for(const t of e.arguments)"SpreadElement"!==t.type&&(yield*l(u(t)))}function*p(e){yield*l(u(e.left)),yield*l(u(e.right))}function d(e,t){for(const n of u(e))if("Identifier"===n.type&&n.name===t)return!0;return!1}function f(e,t){return e.left=v(e.left,t),e.right=v(e.right,t),e}function g(e,t){return(0,r.printExpression)(e.left,t)+" = "+(0,r.printExpression)(e.right,t)}function h(e,t){return e.type===t.type&&("BinaryExpression"===e.type&&"BinaryExpression"===t.type?e.operator===t.operator&&h(e.left,t.left)&&h(e.right,t.right):"UnaryExpression"===e.type&&"UnaryExpression"===t.type?e.operator===t.operator&&h(e.argument,t.argument):"NumericLiteral"===e.type&&"NumericLiteral"===t.type?e.value===t.value:"Identifier"===e.type&&"Identifier"===t.type?e.name===t.name:"CallExpression"===e.type&&"CallExpression"===t.type&&h(e.callee,t.callee)&&e.arguments.length===t.arguments.length&&e.arguments.every(((e,n)=>h(e,t.arguments[n]))))}function m(e,t){return"UnaryExpression"===e.type?m(e.argument,t):"UnaryExpression"===t.type?m(e,t.argument):"BinaryExpression"===e.type&&"BinaryExpression"===t.type?!!m(e.left,t.left)||!!h(e,t)&&m(e.right,t.right):"Identifier"===e.type&&"Identifier"===t.type&&e.name>t.name}function y(e){return"UnaryExpression"===e.type&&"NumericLiteral"===e.argument.type||"NumericLiteral"===e.type}function v(e,t){const n=e=>{if("BinaryExpression"===e.type){if(e.left=n(e.left),e.right=n(e.right),"NumericLiteral"===e.left.type&&"NumericLiteral"===e.right.type){let t;if("+"===e.operator)t=e.left.value+e.right.value;else if("-"===e.operator)t=e.left.value-e.right.value;else if("*"===e.operator)t=e.left.value*e.right.value;else if("/"===e.operator)t=e.left.value/e.right.value;else{if("**"!==e.operator)throw new Error(`Unsupported operator: ${e.operator}`);t=s(e.left.value,e.right.value)}return{type:"NumericLiteral",value:t}}if("NumericLiteral"===e.left.type&&(0,o.isZero)(e.left.value)){if("+"===e.operator)return e.right;if("-"===e.operator)return n({type:"UnaryExpression",operator:"-",argument:e.right});if("*"===e.operator||"/"===e.operator)return e.left}if("NumericLiteral"===e.right.type&&(0,o.isZero)(e.right.value)){if("+"===e.operator||"-"===e.operator)return e.left;if("*"===e.operator)return e.right;if("**"===e.operator)return{type:"NumericLiteral",value:1}}if("NumericLiteral"===e.right.type&&1===e.right.value&&("*"===e.operator||"/"===e.operator||"**"===e.operator))return e.left;if("NumericLiteral"===e.left.type&&1===e.left.value&&"*"===e.operator)return e.right;if("NumericLiteral"===e.right.type&&-1===e.right.value&&("*"===e.operator||"/"===e.operator))return{type:"UnaryExpression",argument:e.left,operator:"-"};if("NumericLiteral"===e.left.type&&-1===e.left.value&&"*"===e.operator)return{type:"UnaryExpression",argument:e.right,operator:"-"};if(h(e.left,e.right)){if("+"===e.operator)return n({type:"BinaryExpression",left:{type:"NumericLiteral",value:2},operator:"*",right:e.left});if("-"===e.operator)return{type:"NumericLiteral",value:0};if("*"===e.operator)return n({type:"BinaryExpression",left:e.left,operator:"**",right:{type:"NumericLiteral",value:2}});if("/"===e.operator)return{type:"NumericLiteral",value:1}}if("UnaryExpression"===e.left.type&&"-"===e.left.operator&&h(e.left.argument,e.right)){if("+"===e.operator)return{type:"NumericLiteral",value:0};if("-"===e.operator)return n({type:"BinaryExpression",left:{type:"NumericLiteral",value:-2},operator:"*",right:n(e.left.argument)});if("/"===e.operator)return{type:"NumericLiteral",value:-1}}if("-"===e.operator&&"NumericLiteral"===e.right.type)return n({type:"BinaryExpression",left:e.left,operator:"+",right:{type:"NumericLiteral",value:-e.right.value}});if("/"===e.operator&&"NumericLiteral"===e.right.type){const t=(0,i.expressionToFactors)(e.left);if(t){const r=e.right.value;return t.forEach((e=>{var t;e.constant=(null!=(t=e.constant)?t:1)/r})),n((0,i.factorsToExpression)(t))}return{type:"BinaryExpression",left:e.left,operator:"*",right:{type:"NumericLiteral",value:1/e.right.value}}}if("-"===e.operator&&"UnaryExpression"===e.right.type&&"-"===e.right.operator)return n({type:"BinaryExpression",operator:"+",left:e.left,right:n(e.right.argument)});if("-"===e.operator&&"BinaryExpression"===e.right.type&&"*"===e.right.operator&&"NumericLiteral"===e.right.left.type)return n({type:"BinaryExpression",left:e.left,operator:"+",right:n({type:"BinaryExpression",left:{type:"NumericLiteral",value:-e.right.left.value},operator:e.right.operator,right:n(e.right.right)})});if("BinaryExpression"===e.left.type){if("-"===e.operator&&"+"===e.left.operator&&h(e.left.right,e.right))return n(e.left.left);if("-"===e.operator&&"-"===e.left.operator&&h(e.left.left,e.right))return n({type:"UnaryExpression",operator:"-",argument:n(e.left.right)});if("+"===e.operator&&"+"===e.left.operator&&"UnaryExpression"===e.left.right.type&&"-"===e.left.right.operator&&h(e.left.right.argument,e.right))return n(e.left.left);if("+"===e.operator&&"-"===e.left.operator&&h(e.left.right,e.right))return n(e.left.left);if("+"===e.operator&&"+"===e.left.operator&&"UnaryExpression"===e.right.type&&"-"===e.right.operator&&h(e.left.right,e.right.argument))return n(e.left.left);if(!("+"!==e.operator&&"-"!==e.operator||"+"!==e.left.operator&&"-"!==e.left.operator||"NumericLiteral"!==e.left.right.type||"NumericLiteral"!==e.right.type)){const t=e.left.right.value*("-"===e.left.operator?-1:1)+e.right.value*("-"===e.operator?-1:1);return n(0===t?e.left.left:{type:"BinaryExpression",left:n(e.left.left),operator:t>0?"+":"-",right:{type:"NumericLiteral",value:t>0?t:-t}})}if(("+"===e.operator||"*"===e.operator)&&e.left.operator===e.operator&&"NumericLiteral"===e.left.left.type&&"NumericLiteral"===e.right.type)return n({type:"BinaryExpression",operator:e.operator,left:{type:"NumericLiteral",value:"*"===e.operator?e.left.left.value*e.right.value:e.left.left.value+e.right.value},right:n(e.left.right)});if(("+"===e.operator||"*"===e.operator)&&e.left.operator===e.operator&&"NumericLiteral"===e.left.right.type&&"NumericLiteral"===e.right.type)return n({type:"BinaryExpression",operator:e.operator,left:{type:"NumericLiteral",value:"*"===e.operator?e.left.right.value*e.right.value:e.left.right.value+e.right.value},right:n(e.left.left)});if("+"===e.operator&&"+"===e.left.operator&&"NumericLiteral"===e.left.left.type&&"BinaryExpression"===e.left.right.type&&"*"===e.left.right.operator&&"NumericLiteral"===e.left.right.left.type&&h(e.left.right.right,e.right))return n({type:"BinaryExpression",left:e.left.left,operator:"+",right:n({type:"BinaryExpression",left:{type:"NumericLiteral",value:e.left.right.left.value+1},operator:"*",right:n(e.left.right.right)})});if(("+"===e.operator||"-"===e.operator)&&e.left.operator===e.operator&&h(e.left.right,e.right))return n({type:"BinaryExpression",left:n(e.left.left),operator:e.operator,right:n({type:"BinaryExpression",left:{type:"NumericLiteral",value:2},operator:"*",right:n(e.left.right)})});if("-"===e.operator&&"+"===e.left.operator&&"NumericLiteral"===e.left.left.type&&"BinaryExpression"===e.left.right.type&&"*"===e.left.right.operator&&"NumericLiteral"===e.left.right.left.type&&h(e.left.right.right,e.right))return n({type:"BinaryExpression",operator:"+",left:e.left.left,right:n({type:"BinaryExpression",left:{type:"NumericLiteral",value:e.left.right.left.value-1},operator:"*",right:e.right})});if("+"===e.operator&&"+"===e.left.operator&&"NumericLiteral"===e.left.left.type&&"BinaryExpression"===e.left.right.type&&"*"===e.left.right.operator&&"NumericLiteral"===e.left.right.left.type&&"BinaryExpression"===e.right.type&&"*"===e.right.operator&&"NumericLiteral"===e.right.left.type&&h(e.left.right.right,e.right.right))return n({type:"BinaryExpression",left:e.left.left,operator:"+",right:n({type:"BinaryExpression",left:{type:"NumericLiteral",value:e.left.right.left.value+e.right.left.value},operator:"*",right:n(e.left.right.right)})});if("+"===e.operator&&"-"===e.left.operator&&"NumericLiteral"===e.left.left.type&&"BinaryExpression"===e.right.type&&"*"===e.right.operator&&"NumericLiteral"===e.right.left.type&&h(e.left.right,e.right.right))return n({type:"BinaryExpression",left:e.left.left,operator:"+",right:n({type:"BinaryExpression",left:{type:"NumericLiteral",value:-1+e.right.left.value},operator:"*",right:n(e.right.right)})});if(!("+"!==e.operator&&"-"!==e.operator||"+"!==e.left.operator&&"-"!==e.left.operator||"NumericLiteral"!==e.left.right.type))return n({type:"BinaryExpression",left:n({type:"BinaryExpression",left:n(e.left.left),operator:e.operator,right:e.right}),operator:e.left.operator,right:e.left.right});if(("+"===e.operator||"-"===e.operator)&&t&&("+"===e.left.operator||"-"===e.left.operator)&&t(e.right)&&t(e.left.left)&&!t(e.left.right))return n({type:"BinaryExpression",operator:e.left.operator,left:n({type:"BinaryExpression",operator:e.operator,left:n(e.left.left),right:e.right}),right:n(e.left.right)});if(("+"===e.operator||"-"===e.operator)&&t&&"-"===e.left.operator&&t(e.right)&&t(e.left.right)&&!t(e.left.left))return n({type:"BinaryExpression",left:n({type:"BinaryExpression",left:n({type:"UnaryExpression",operator:"-",argument:n(e.left.right)}),operator:e.operator,right:e.right}),operator:"+",right:n(e.left.left)});if(("*"===e.operator||"/"===e.operator)&&"BinaryExpression"===e.left.type&&e.left.operator===e.operator&&(!t||!t(e.left.right))&&m(e.left.right,e.right))return n({type:"BinaryExpression",left:{type:"BinaryExpression",left:n(e.left.left),operator:e.operator,right:e.right},operator:e.left.operator,right:n(e.left.right)});if(!("*"!==e.operator||"BinaryExpression"!==e.left.type||"/"!==e.left.operator||t&&t(e.left.right)))return n({type:"BinaryExpression",left:{type:"BinaryExpression",left:n(e.left.left),operator:e.operator,right:e.right},operator:e.left.operator,right:n(e.left.right)});if(("+"===e.operator||"-"===e.operator)&&"BinaryExpression"===e.left.type&&("+"===e.left.operator||"-"===e.left.operator)&&(!t||!t(e.left.right))&&m(e.left.right,e.right))return n({type:"BinaryExpression",left:{type:"BinaryExpression",left:n(e.left.left),operator:e.operator,right:e.right},operator:e.left.operator,right:n(e.left.right)})}if("BinaryExpression"===e.right.type){if("+"===e.operator&&("+"===e.right.operator||"-"===e.right.operator))return n({type:"BinaryExpression",operator:e.right.operator,left:n({type:"BinaryExpression",operator:"+",left:e.left,right:n(e.right.left)}),right:n(e.right.right)});if("-"===e.operator&&("+"===e.right.operator||"-"===e.right.operator))return n({type:"BinaryExpression",operator:x(e.right.operator),left:n({type:"BinaryExpression",operator:"-",left:e.left,right:n(e.right.left)}),right:n(e.right.right)});if("*"===e.operator&&("*"===e.right.operator||"/"===e.right.operator))return n({type:"BinaryExpression",operator:e.right.operator,left:n({type:"BinaryExpression",operator:"*",left:e.left,right:n(e.right.left)}),right:n(e.right.right)})}if(("+"===e.operator||"*"===e.operator)&&(!t||t(e.left)&&t(e.right)||!t(e.left)&&!t(e.right))&&m(e.left,e.right))return n({type:"BinaryExpression",operator:e.operator,left:e.right,right:e.left});if("*"===e.operator&&t&&t(e.left)&&!t(e.right))return n({type:"BinaryExpression",left:e.right,operator:e.operator,right:e.left});if("+"===e.operator&&t&&!t(e.left)&&t(e.right))return n({type:"BinaryExpression",left:e.right,operator:e.operator,right:e.left});if("UnaryExpression"===e.right.type&&("*"===e.operator||"/"===e.operator)&&"-"===e.right.operator)return n({type:"UnaryExpression",operator:e.right.operator,argument:n({type:"BinaryExpression",left:e.left,right:n(e.right.argument),operator:e.operator})});if("UnaryExpression"===e.left.type&&("*"===e.operator||"/"===e.operator)&&"-"===e.left.operator)return n({type:"UnaryExpression",operator:e.left.operator,argument:n({type:"BinaryExpression",left:n(e.left.argument),right:e.right,operator:e.operator})});if("+"===e.operator||"-"===e.operator){if("BinaryExpression"===e.right.type&&"/"===e.right.operator&&!y(e.right.right))return n({type:"BinaryExpression",left:n({type:"BinaryExpression",left:n({type:"BinaryExpression",left:e.left,operator:"*",right:n(e.right.right)}),operator:e.operator,right:n(e.right.left)}),operator:"/",right:n(e.right.right)});if("BinaryExpression"===e.left.type&&"/"===e.left.operator&&!y(e.left.right))return n({type:"BinaryExpression",left:n({type:"BinaryExpression",left:n(e.left.left),operator:e.operator,right:n({type:"BinaryExpression",left:n(e.left.right),operator:"*",right:e.right})}),operator:"/",right:n(e.left.right)})}if("*"===e.operator){if(!(t&&t(e.right)||"BinaryExpression"!==e.left.type||"+"!==e.left.operator&&"-"!==e.left.operator))return n({type:"BinaryExpression",left:n({type:"BinaryExpression",left:n(e.left.left),operator:"*",right:e.right}),operator:e.left.operator,right:n({type:"BinaryExpression",left:n(e.left.right),operator:"*",right:e.right})});if(!(t&&t(e.left)||"BinaryExpression"!==e.right.type||"+"!==e.right.operator&&"-"!==e.right.operator))return n({type:"BinaryExpression",left:n({type:"BinaryExpression",left:e.left,operator:"*",right:n(e.right.left)}),operator:e.right.operator,right:n({type:"BinaryExpression",left:e.left,operator:"*",right:n(e.right.right)})})}if(t&&("+"===e.operator||"-"===e.operator)){if("BinaryExpression"===e.left.type&&"*"===e.left.operator&&"BinaryExpression"===e.right.type&&"*"===e.right.operator&&h(e.left.right,e.right.right)&&!t(e.left.left)&&t(e.left.right)&&!t(e.right.left))return n({type:"BinaryExpression",left:n({type:"BinaryExpression",left:n(e.left.left),right:n(e.right.left),operator:e.operator}),operator:"*",right:n(e.left.right)});if("BinaryExpression"===e.left.type&&"*"===e.left.operator&&!t(e.left.left)&&t(e.left.right)&&h(e.left.right,e.right))return n({type:"BinaryExpression",left:n({type:"BinaryExpression",left:n(e.left.left),right:{type:"NumericLiteral",value:1},operator:e.operator}),operator:"*",right:n(e.left.right)});if("BinaryExpression"===e.right.type&&"*"===e.right.operator&&!t(e.right.left)&&t(e.right.right)&&h(e.left,e.right.right))return n({type:"BinaryExpression",left:n({type:"BinaryExpression",left:{type:"NumericLiteral",value:1},right:n(e.right.left),operator:e.operator}),operator:"*",right:e.left});if("BinaryExpression"===e.right.type&&"*"===e.right.operator&&"UnaryExpression"===e.left.type&&"-"===e.left.operator&&!t(e.right.left)&&t(e.right.right)&&h(e.left.argument,e.right.right))return n({type:"BinaryExpression",left:n({type:"BinaryExpression",left:{type:"NumericLiteral",value:-1},right:n(e.right.left),operator:e.operator}),operator:"*",right:n(e.left.argument)})}if(t&&"**"===e.operator&&!t(e.right)&&"BinaryExpression"===e.left.type&&("*"===e.left.operator||"/"===e.left.operator)&&(t(e.left.left)&&!t(e.left.right)||!t(e.left.left)&&t(e.left.right)))return n({type:"BinaryExpression",left:n({type:"BinaryExpression",left:n(e.left.left),operator:"**",right:e.right}),operator:e.left.operator,right:n({type:"BinaryExpression",left:n(e.left.right),operator:"**",right:e.right})});if("**"===e.operator&&"NumericLiteral"===e.right.type&&2===e.right.value&&"BinaryExpression"===e.left.type&&("+"===e.left.operator||"-"===e.left.operator)){const t=n(e.left.left),r=n(e.left.right);return n({type:"BinaryExpression",left:n({type:"BinaryExpression",left:n({type:"BinaryExpression",left:t,operator:"**",right:e.right}),operator:e.left.operator,right:n({type:"BinaryExpression",left:n({type:"BinaryExpression",left:e.right,operator:"*",right:t}),operator:"*",right:r})}),operator:"+",right:n({type:"BinaryExpression",left:r,operator:"**",right:e.right})})}if("/"===e.operator){const t=(0,i.divide)(e.left,e.right);if(t)return n(t)}if("/"===e.operator&&"BinaryExpression"===e.left.type&&"/"===e.left.operator){const t=(0,i.divide)(e.left.left,e.right);if(t)return n({type:"BinaryExpression",left:n(t),operator:"/",right:n(e.left.right)})}if("+"===e.operator||"-"===e.operator){const t=(0,i.expressionToFactors)(e);if(t){const e=(0,i.optimizeFactors)(t);if(e.length0&&e.right.value<1){const t=1/e.right.value;if(Number.isInteger(t)){const r=(0,i.expressionToFactors)(e.left);if(r){const o=(0,i.extractFactors)(r,t);if(o)return n({type:"BinaryExpression",left:(0,i.factorToExpression)(o.base),operator:"*",right:n({type:"BinaryExpression",left:(0,i.factorsToExpression)(o.factors),operator:"**",right:e.right})})}}}if("/"===e.operator&&"BinaryExpression"===e.right.type&&("+"===e.right.operator||"-"===e.right.operator)){const t=(0,i.expressionToFactors)(e.right);if(t){const r=(0,i.extractFactors)(t,1);if(r)return n({type:"BinaryExpression",left:n({type:"BinaryExpression",left:e.left,operator:"/",right:(0,i.factorToExpression)(r.base)}),operator:"/",right:(0,i.factorsToExpression)(r.factors)})}}}else if("UnaryExpression"===e.type){if(e.argument=n(e.argument),"-"===e.operator){if("NumericLiteral"===e.argument.type)return{type:"NumericLiteral",value:-e.argument.value};if("UnaryExpression"===e.argument.type&&"-"===e.argument.operator)return n(e.argument.argument);if("BinaryExpression"===e.argument.type&&("+"===e.argument.operator||"-"===e.argument.operator))return n({type:"BinaryExpression",left:n({type:"UnaryExpression",operator:"-",argument:n(e.argument.left)}),operator:x(e.argument.operator),right:n(e.argument.right)});if("BinaryExpression"===e.argument.type&&("*"===e.argument.operator||"/"===e.argument.operator)){if("NumericLiteral"===e.argument.left.type)return n({type:"BinaryExpression",left:n({type:"NumericLiteral",value:-e.argument.left.value}),operator:e.argument.operator,right:n(e.argument.right)});if("NumericLiteral"===e.argument.right.type)return n({type:"BinaryExpression",left:n(e.argument.left),operator:"*",right:n({type:"NumericLiteral",value:-e.argument.right.value})})}}}else if("CallExpression"===e.type&&(e.arguments=e.arguments.map((e=>"SpreadElement"===e.type?e:n(e))),"Identifier"===e.callee.type))if("sin"===e.callee.name){if(1===e.arguments.length){const t=e.arguments[0];if("NumericLiteral"===t.type)return{type:"NumericLiteral",value:Math.sin(t.value)}}}else if("cos"===e.callee.name){if(1===e.arguments.length){const t=e.arguments[0];if("NumericLiteral"===t.type)return{type:"NumericLiteral",value:Math.cos(t.value)}}}else if("tan"===e.callee.name){if(1===e.arguments.length){const t=e.arguments[0];if("NumericLiteral"===t.type)return{type:"NumericLiteral",value:Math.tan(t.value)}}}else if("ln"===e.callee.name){if(1===e.arguments.length){const t=e.arguments[0];if("NumericLiteral"===t.type)return{type:"NumericLiteral",value:Math.log(t.value)}}}else if("exp"===e.callee.name&&1===e.arguments.length){const t=e.arguments[0];if("NumericLiteral"===t.type)return{type:"NumericLiteral",value:Math.exp(t.value)}}return e};return n(e)}function x(e){return"+"===e?"-":"-"===e?"+":"*"===e?"/":"/"===e?"*":e}},7492:(e,t,n)=>{"use strict";n.r(t),n.d(t,{solveQuadraticEquation:()=>o});var r=n(6277);function o(e,t){const n=i(e.left,t);if(n&&n.length>0){n.sort(((e,t)=>t.degree-e.degree));const t=n[0];if(2===t.degree){const r=t.constant;if(2===n.length){const t=n[1];if(1===t.degree)return l(r,t.constant,e.right)}else if(1===n.length)return l(r,{type:"NumericLiteral",value:0},e.right)}else if(1===t.degree)return[{type:"BinaryExpression",left:e.right,operator:"/",right:t.constant}]}}function i(e,t){if("BinaryExpression"===e.type&&("+"===e.operator||"-"===e.operator)){const n=i(e.left,t);if(!n)return;let r=i(e.right,t);if(!r)return;"-"===e.operator&&(r=r.map((e=>c(e))));const o=[...n];for(const e of r){const t=o.find((t=>t.degree===e.degree));t?t.constant={type:"BinaryExpression",left:t.constant,operator:"+",right:e.constant}:o.push(e)}return o}const n=a(e,t);if(n)return[n]}function a(e,t){if("NumericLiteral"===e.type)return{constant:e,degree:0};if(!(0,r.expressionHasVariable)(e,t))return{constant:e,degree:0};if("Identifier"===e.type)return e.name===t?{constant:{type:"NumericLiteral",value:1},degree:1}:{constant:e,degree:0};if("UnaryExpression"===e.type&&"-"===e.operator){const n=a(e.argument,t);if(!n)return;return c(n)}if("BinaryExpression"===e.type){if("*"===e.operator){const n=a(e.left,t);if(!n)return;const r=a(e.right,t);if(!r)return;return s(n,r)}if("**"===e.operator){const n=a(e.left,t);if(!n)return;if("NumericLiteral"!==e.right.type)return;if(!Number.isInteger(e.right.value))return;if(e.right.value<1)return;return{constant:{type:"BinaryExpression",left:n.constant,operator:"**",right:e.right},degree:n.degree*e.right.value}}}}function s(...e){let t,n=0;for(const r of e)t=t?{type:"BinaryExpression",left:t,operator:"*",right:r.constant}:r.constant,n+=r.degree;return{degree:n,constant:t||{type:"NumericLiteral",value:1}}}function c(e){return s(e,{constant:{type:"NumericLiteral",value:-1},degree:0})}function l(e,t,n){return[{type:"BinaryExpression",left:{type:"BinaryExpression",left:{type:"UnaryExpression",operator:"-",argument:t},operator:"+",right:{type:"BinaryExpression",left:{type:"BinaryExpression",left:{type:"BinaryExpression",left:t,operator:"**",right:{type:"NumericLiteral",value:2}},operator:"+",right:{type:"BinaryExpression",left:{type:"BinaryExpression",left:{type:"NumericLiteral",value:4},operator:"*",right:e},operator:"*",right:n}},operator:"**",right:{type:"NumericLiteral",value:.5}}},operator:"/",right:{type:"BinaryExpression",left:{type:"NumericLiteral",value:2},operator:"*",right:e}},{type:"BinaryExpression",left:{type:"BinaryExpression",left:{type:"UnaryExpression",operator:"-",argument:t},operator:"-",right:{type:"BinaryExpression",left:{type:"BinaryExpression",left:{type:"BinaryExpression",left:t,operator:"**",right:{type:"NumericLiteral",value:2}},operator:"+",right:{type:"BinaryExpression",left:{type:"BinaryExpression",left:{type:"NumericLiteral",value:4},operator:"*",right:e},operator:"*",right:n}},operator:"**",right:{type:"NumericLiteral",value:.5}}},operator:"/",right:{type:"BinaryExpression",left:{type:"NumericLiteral",value:2},operator:"*",right:e}}]}},4281:(e,t,n)=>{"use strict";n.r(t),n.d(t,{cloneExpression:()=>w,composeExpression:()=>C,equationHasVariable:()=>m,solveEquation:()=>h,solveEquations:()=>v});var r=n(9292),o=n(6277),i=n(7492),a=Object.defineProperty,s=Object.defineProperties,c=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,u=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable,d=(e,t,n)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,f=(e,t)=>{for(var n in t||(t={}))u.call(t,n)&&d(e,n,t[n]);if(l)for(var n of l(t))p.call(t,n)&&d(e,n,t[n]);return e},g=(e,t)=>s(e,c(t));function h(e,t){const n=e=>(0,o.expressionHasVariable)(e,t),a=e=>(0,o.optimizeExpression)(e,n),s=e=>{if((0,o.optimizeEquation)(e,n),!n(e.left)){if(!n(e.right))return e;e={left:e.right,right:e.left}}if(!n(e.right)){if("UnaryExpression"===e.left.type&&"-"===e.left.operator)return s({left:a(e.left.argument),right:a({type:"UnaryExpression",argument:e.right,operator:e.left.operator})});if("BinaryExpression"===e.left.type){if(n(e.left.left)&&!n(e.left.right)){const t="**"===e.left.operator?{type:"BinaryExpression",left:{type:"NumericLiteral",value:1},operator:"/",right:e.left.right}:e.left.right;return"**"===e.left.operator&&"NumericLiteral"===e.left.right.type&&e.left.right.value%2==0?[...(0,r.iterateItemOrArray)(s({left:a(e.left.left),right:a({type:"BinaryExpression",left:e.right,right:a(t),operator:(0,o.getReverseOperator)(e.left.operator)})})),...(0,r.iterateItemOrArray)(s({left:a(e.left.left),right:a({type:"UnaryExpression",operator:"-",argument:{type:"BinaryExpression",left:e.right,right:a(t),operator:(0,o.getReverseOperator)(e.left.operator)}})}))]:s({left:a(e.left.left),right:a({type:"BinaryExpression",left:e.right,right:a(t),operator:(0,o.getReverseOperator)(e.left.operator)})})}if(n(e.left.right)&&!n(e.left.left))return"-"===e.left.operator||"/"===e.left.operator?s({left:a(e.left.right),right:a({type:"BinaryExpression",left:a(e.left.left),right:e.right,operator:e.left.operator})}):s({left:a(e.left.right),right:a({type:"BinaryExpression",left:e.right,right:a(e.left.left),operator:(0,o.getReverseOperator)(e.left.operator)})});if("NumericLiteral"===e.right.type&&0===e.right.value&&"/"===e.left.operator)return s({left:a(e.left.left),right:e.right});if("NumericLiteral"===e.right.type&&0===e.right.value&&"*"===e.left.operator)return[...(0,r.iterateItemOrArray)(s({left:a(e.left.left),right:e.right})),...(0,r.iterateItemOrArray)(s({left:a(e.left.right),right:e.right}))];if("+"===e.left.operator||"-"===e.left.operator||"*"===e.left.operator){const n=(0,i.solveQuadraticEquation)(e,t);if(n)return n.map((e=>Array.from((0,r.iterateItemOrArray)(s({left:{type:"Identifier",name:t},right:a(e)}))).flat())).flat()}}return e}return"BinaryExpression"===e.right.type?"/"===e.right.operator?s({left:a({type:"BinaryExpression",left:e.left,right:a(e.right.right),operator:"*"}),right:a(e.right.left)}):s({left:{type:"BinaryExpression",left:e.left,operator:"-",right:e.right},right:{type:"NumericLiteral",value:0}}):"Identifier"===e.right.type?s({left:{type:"BinaryExpression",left:e.left,operator:"-",right:e.right},right:{type:"NumericLiteral",value:0}}):"UnaryExpression"===e.right.type?s({left:{type:"BinaryExpression",left:e.left,operator:"+",right:a(e.right.argument)},right:{type:"NumericLiteral",value:0}}):e};return Array.from((0,r.iterateItemOrArray)(s(e)))}function m(e,t){return(0,o.expressionHasVariable)(e.left,t)||(0,o.expressionHasVariable)(e.right,t)}function y(e){const t=new Set;for(const n of(0,o.iterateEquation)(e))"Identifier"===n.type&&t.add(n.name);return Array.from(t)}function v(e,t,n={}){if(!t){t=new Set;for(const n of e)for(const e of y(n))t.add(e)}const r=[],i=t,a=()=>{let t=e.length;for(;;){const a=[];for(let t=0;ti.has(e)));if(c.length>0){if(1===c.length){(0,o.optimizeEquation)(s,(e=>(0,o.expressionHasVariable)(e,c[0])));const[l,...u]=h(s,c[0]);r.push(...u.map((r=>v([...a.map((e=>P(e))),r,...e.slice(t+1).map((e=>P(e)))],new Set(i),x(n)))).flat()),s=l}if("Identifier"===s.left.type&&"NumericLiteral"===s.right.type){for(const e in n){const t=n[e];Array.isArray(t)?n[e]=[(0,o.optimizeExpression)(C(t[0],{[s.left.name]:s.right}),(t=>(0,o.expressionHasVariable)(t,e))),(0,o.optimizeExpression)(C(t[1],{[s.left.name]:s.right}),(t=>(0,o.expressionHasVariable)(t,e)))]:n[e]=(0,o.optimizeExpression)(C(t,{[s.left.name]:s.right}),(t=>(0,o.expressionHasVariable)(t,e)))}n[s.left.name]=s.right,i.delete(s.left.name)}else a.push(s)}}const s=b(a,n,i);if(e=s.equations,r.push(...s.result),e.length===t)break;t=e.length}};for(a();;){const t=e.shift();if(!t)break;let s=y(t).filter((e=>i.has(e)))[0],[c,...l]=h(t,s);for(;!y(c).includes(s);){const e=y(c).filter((e=>i.has(e)))[0];if(e===s)break;s=e,[c,...l]=h(c,s)}if(r.push(...l.map((t=>v([t,...e.map((e=>P(e)))],new Set(i),x(n)))).flat()),"Identifier"===c.left.type){for(const e in n){const t=n[e];Array.isArray(t)?n[e]=[(0,o.optimizeExpression)(C(t[0],{[s]:c.right}),(t=>(0,o.expressionHasVariable)(t,e))),(0,o.optimizeExpression)(C(t[1],{[s]:c.right}),(t=>(0,o.expressionHasVariable)(t,e)))]:n[e]=(0,o.optimizeExpression)(C(t,{[s]:c.right}),(t=>(0,o.expressionHasVariable)(t,e)))}n[s]=c.right,i.delete(s);const t=b(e,{[s]:c.right},i);e=t.equations,r.push(...t.result),a()}else n[s]=[c.left,c.right],i.delete(s)}return[n,...r]}function x(e){const t={};for(const[n,r]of Object.entries(e))Array.isArray(r)?t[n]=[w(r[0]),w(r[1])]:t[n]=w(r);return t}function b(e,t,n){const r=[],i=[];for(let a=0;an.has(e)));if(c.length>0)if(1===c.length){s=(0,o.optimizeEquation)(s,(e=>(0,o.expressionHasVariable)(e,c[0])));const[l,...u]=h(s,c[0]);i.push(...u.map((o=>v([...r.map((e=>P(e))),o,...e.slice(a+1).map((e=>P(e)))],new Set(n),x(t)))).flat()),r.push(l)}else r.push(s)}return{equations:r,result:i}}function C(e,t){if("BinaryExpression"===e.type)E(e,"left",t),E(e,"right",t);else if("UnaryExpression"===e.type)E(e,"argument",t);else if("Identifier"===e.type){const n=t[e.name];if(n&&!Array.isArray(n))return n}else"CallExpression"===e.type&&e.arguments.forEach(((n,r)=>{"SpreadElement"!==n.type&&(e.arguments[r]=C(n,t))}));return e}function E(e,t,n){const r=e[t];if("Identifier"===r.type){const o=n[r.name];o&&!Array.isArray(o)&&(e[t]=w(o))}else C(r,n)}function P(e){return{left:w(e.left),right:w(e.right)}}function w(e){return"BinaryExpression"===e.type?g(f({},e),{left:w(e.left),right:w(e.right)}):"UnaryExpression"===e.type?g(f({},e),{argument:w(e.argument)}):"CallExpression"===e.type?g(f({},e),{arguments:e.arguments.map((e=>"SpreadElement"===e.type?e:w(e)))}):f({},e)}},6845:(e,t,n)=>{"use strict";n.r(t),n.d(t,{ExpressionEditor:()=>m});var r=n(3696),o=n(1777),i=n(9424),a=n(7670),s=n(8905),c=n(8174),l=n(623),u=Object.defineProperty,p=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,f=Object.prototype.propertyIsEnumerable,g=(e,t,n)=>t in e?u(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,h=(e,t)=>{for(var n in t||(t={}))d.call(t,n)&&g(e,n,t[n]);if(p)for(var n of p(t))f.call(t,n)&&g(e,n,t[n]);return e};function m(e){var t,n,u,p,d,f,g,m;const y=null!=(t=e.height)?t:100,v=null!=(n=e.target)?n:o.reactCanvasRenderTarget,x=null!=(u=e.fontSize)?u:16,b=null!=(f=null!=(d=null==(p=e.style)?void 0:p.fontFamily)?d:c.controlStyle.fontFamily)?f:"monospace",C=null!=(g=e.numberColor)?g:820234,E=1.2*x,[P,w]=r.useState(null!=(m=e.width)?m:250),{state:k,setState:_,undo:S,redo:R,resetHistory:T}=(0,i.useUndoRedo)(e.value.split("")),[A,L]=r.useState([]),[M,I]=r.useState(0),[O,D]=r.useState(""),[B,z]=r.useState(),[F,N]=r.useState(),{renderEditor:U,layoutResult:G,location:j,cursor:V,setLocation:W,inputText:H}=(0,a.useFlowLayoutTextEditor)({state:k,setState:_,width:P,height:y,fontSize:x,fontFamily:b,lineHeight:E,readOnly:e.readOnly,processInput(t){var n;if("Escape"===t.key)return null==(n=e.onCancel)||n.call(e),!0;if(A.length>0&&!e.readOnly){if("ArrowDown"===t.key)return I((M+1)%A.length),t.preventDefault(),!0;if("ArrowUp"===t.key)return I((M-1+A.length)%A.length),t.preventDefault(),!0;if("Enter"===t.key&&M>=0&&M{setTimeout((()=>{$()}),0)},style:{border:"unset"}});r.useEffect((()=>{var t,n,r,o;if(!e.suggestionSources||e.readOnly)return;if(j-1<0||j-1>=k.length)return;L([]),z(void 0);const i=k[j-1];if((0,s.isLetter)(i)||(0,s.isNumber)(i)||"."==i){let r;for(let e=j-1;e>=0&&et.name===o[e])))?void 0:t.members)?n:[];else{const t=o[e].toLowerCase();i=i.filter((e=>e.name.toLowerCase().includes(t))).sort(((e,n)=>e.name.toLowerCase()===t?-1:n.name.toLowerCase()===t?1:e.name.localeCompare(n.name)))}L(i),I(0),D(o[o.length-1])}else if("("===i){let t;for(let e=j-2;e>=0&&et.name===n[e])))?void 0:r.members)?o:[]:i=a.find((t=>t.name===n[e]));z(i)}}),[k,j]),r.useEffect((()=>{T(e.value.split(""))}),[e.value]),r.useEffect((()=>{var t;N(null==(t=e.validate)?void 0:t.call(e,k.join("")))}),[k,e.validate]);const q=r.useRef(null);r.useEffect((()=>{if(!q.current)return;const e=new ResizeObserver((e=>{for(const t of e)w(t.contentRect.width)}));return e.observe(q.current),()=>e.disconnect()}),[q.current]);const $=()=>{if(!e.readOnly&&e.setValue){const t=k.join("");t!==e.value&&e.setValue(t)}},X={};e.readOnly&&(X.opacity=.5);const Y=e=>{const t=A[e];_((e=>{e.splice(j-O.length,O.length,...t.name.split(""))})),W(j-O.length+t.name.length),L([])};return r.createElement("div",{ref:q,style:h(h(h({position:"relative"},c.controlStyle),e.style),X)},U({target:v,getTextColors:t=>{let n=e.color;const r=G[t].content;if(F&&t>=F[0]&&t=0;n--){const t=G[n].content;if((0,s.isNumber)(t))e=!1;else{if(!(0,s.isLetter)(t))break;e=!0}}e||(n=C)}else if("."===r&&t0&&r.createElement("div",{style:{position:"absolute",left:V.x+"px",top:V.y+E+"px",background:"white",width:"200px",border:"1px solid black",maxHeight:"200px",overflowY:"auto"}},A.map(((e,t)=>{const n=e.name.toLowerCase().indexOf(O.toLowerCase());return r.createElement("div",{key:e.name,style:{background:M===t?"#ccc":void 0,cursor:"pointer"},onMouseDown:e=>{e.preventDefault(),Y(t)},title:e.comment},e.name.substring(0,n),r.createElement("span",{style:{color:"#0c840a"}},e.name.substring(n,n+O.length)),e.name.substring(n+O.length))}))),(null==B?void 0:B.parameters)&&r.createElement("div",{style:{position:"absolute",left:V.x+"px",top:V.y+E+"px",background:"white",width:"400px",border:"1px solid black",maxHeight:"200px",overflowY:"auto"}},r.createElement("div",{onMouseDown:e=>e.preventDefault()},B.name,"(",B.parameters.map((e=>e.name)).join(", "),")",B.parameters.map((e=>e.comment?r.createElement("div",{key:e.name,style:{fontSize:"12px"}},e.name,": ",e.comment):null)),B.comment&&r.createElement("div",{style:{fontSize:"12px"}},B.comment))))}},3549:(e,t,n)=>{"use strict";n.r(t),n.d(t,{deriveExpressionWith:()=>g,expandExpression:()=>s,groupAllFactors:()=>d,groupFactorsBy:()=>p,groupFactorsByVariables:()=>f,sortFactors:()=>c,taylorExpandExpressionWith:()=>h});var r=n(767),o=n(123),i=n(6277),a=n(4281);function s(e){if("BinaryExpression"===e.type){if("**"===e.operator&&"NumericLiteral"===e.right.type){if(2===e.right.value&&"BinaryExpression"===e.left.type){if("+"===e.left.operator||"-"===e.left.operator)return s({type:"BinaryExpression",operator:"+",left:{type:"BinaryExpression",operator:e.left.operator,left:{type:"BinaryExpression",operator:"*",left:e.left.left,right:e.left.left},right:{type:"BinaryExpression",operator:"*",left:{type:"NumericLiteral",value:2},right:{type:"BinaryExpression",operator:"*",left:e.left.left,right:e.left.right}}},right:{type:"BinaryExpression",operator:"*",left:e.left.right,right:e.left.right}});if("*"===e.left.operator||"/"===e.left.operator)return s({type:"BinaryExpression",operator:e.left.operator,left:{type:"BinaryExpression",operator:e.left.operator,left:{type:"BinaryExpression",operator:"*",left:e.left.left,right:e.left.left},right:e.left.right},right:e.left.right})}if(Number.isInteger(e.right.value)&&e.right.value>=3&&"Identifier"!==e.left.type)return s({type:"BinaryExpression",operator:"*",left:{type:"BinaryExpression",operator:"**",left:e.left,right:{type:"NumericLiteral",value:e.right.value-1}},right:e.left})}if("*"===e.operator){if("BinaryExpression"===e.right.type&&("+"===e.right.operator||"-"===e.right.operator))return s({type:"BinaryExpression",operator:e.right.operator,left:{type:"BinaryExpression",operator:"*",left:e.left,right:e.right.left},right:{type:"BinaryExpression",operator:"*",left:e.left,right:e.right.right}});if("BinaryExpression"===e.left.type){if("+"===e.left.operator||"-"===e.left.operator)return s({type:"BinaryExpression",operator:e.left.operator,left:{type:"BinaryExpression",operator:"*",left:e.left.left,right:e.right},right:{type:"BinaryExpression",operator:"*",left:e.left.right,right:e.right}});if("/"===e.left.operator&&"Identifier"===e.left.right.type){if("Identifier"!==e.right.type)return s({type:"BinaryExpression",operator:"/",left:{type:"BinaryExpression",operator:"*",left:e.left.left,right:e.right},right:e.left.right});if(e.left.right.name===e.right.name)return s(e.left.left)}}}if("/"===e.operator&&"BinaryExpression"===e.left.type&&("+"===e.left.operator||"-"===e.left.operator))return s({type:"BinaryExpression",operator:e.left.operator,left:{type:"BinaryExpression",operator:"/",left:e.left.left,right:e.right},right:{type:"BinaryExpression",operator:"/",left:e.left.right,right:e.right}});const t=s(e.left),n=s(e.right);return t===e.left&&n===e.right?e:s({type:"BinaryExpression",operator:e.operator,left:t,right:n})}if("UnaryExpression"===e.type){if("-"===e.operator&&"BinaryExpression"===e.argument.type&&("+"===e.argument.operator||"-"===e.argument.operator))return s({type:"BinaryExpression",left:{type:"UnaryExpression",operator:"-",argument:e.argument.left},operator:(0,i.getReverseOperator)(e.argument.operator),right:e.argument.right});const t=s(e.argument);return t===e.argument?e:s({type:"UnaryExpression",operator:e.operator,argument:t})}return e}function c(e){e.forEach((e=>{e.variables.sort(l)})),e.sort(((e,t)=>{for(let n=0;nt.count===e));a?a.factors.push(...i):n.push({count:e,factors:i})}return n.sort(((e,t)=>t.count-e.count)),n}function p(e,t){return function(e,t){let n;for(const r of e){let e;for(const t of r.factors){const n=(0,o.factorToExpression)(t);e=e?{type:"BinaryExpression",operator:"+",left:e,right:n}:n}if(r.count>0){const n=(0,o.factorToExpression)((0,o.powerFactor)(t,r.count));e=e?{type:"BinaryExpression",operator:"*",left:e,right:n}:n}e&&(n=n?{type:"BinaryExpression",operator:"+",left:n,right:e}:e)}return n}(u(e,t),t)}function d(e){const t=[];for(const n of e)for(const e of n.variables)if("string"==typeof e){const n=t.find((t=>t.name===e));n?n.count++:t.push({name:e,count:1})}return t.sort(((e,t)=>t.count-e.count)),f(e,t.map((e=>e.name)))}function f(e,t){const n=(e,r)=>{if(e.length<=1)return;if(!t[r])return;const i={variables:[t[r]]},a=u(e,i);let s;for(const e of a){let t=n(e.factors,r+1);if(!t)for(const n of e.factors){const e=(0,o.factorToExpression)(n);t=t?{type:"BinaryExpression",operator:"+",left:t,right:e}:e}if(e.count>0){const n=(0,o.factorToExpression)((0,o.powerFactor)(i,e.count));t=t?{type:"BinaryExpression",operator:"*",left:t,right:n}:n}t&&(s=s?{type:"BinaryExpression",operator:"+",left:s,right:t}:t)}return s};return n(e,0)}function g(e,t){if("BinaryExpression"===e.type){if("+"===e.operator||"-"===e.operator)return{type:"BinaryExpression",operator:e.operator,left:g(e.left,t),right:g(e.right,t)};if("*"===e.operator)return{type:"BinaryExpression",operator:"+",left:{type:"BinaryExpression",operator:"*",left:g(e.left,t),right:e.right},right:{type:"BinaryExpression",operator:"*",left:e.left,right:g(e.right,t)}};if("/"===e.operator)return{type:"BinaryExpression",operator:"/",left:{type:"BinaryExpression",operator:"/",left:{type:"BinaryExpression",operator:"-",left:{type:"BinaryExpression",operator:"*",left:g(e.left,t),right:e.right},right:{type:"BinaryExpression",operator:"*",left:e.left,right:g(e.right,t)}},right:e.right},right:e.right};if("**"===e.operator){if(!(0,i.expressionHasVariable)(e.left,t))return(0,i.expressionHasVariable)(e.right,t)?{type:"BinaryExpression",operator:"*",left:{type:"BinaryExpression",operator:"*",left:{type:"CallExpression",callee:{type:"Identifier",name:"ln"},arguments:[e.left]},right:e},right:g(e.right,t)}:{type:"NumericLiteral",value:0};if(!(0,i.expressionHasVariable)(e.right,t))return{type:"BinaryExpression",operator:"*",left:{type:"BinaryExpression",operator:"*",left:g(e.left,t),right:e.right},right:{type:"BinaryExpression",operator:"**",left:e.left,right:{type:"BinaryExpression",operator:"-",left:e.right,right:{type:"NumericLiteral",value:1}}}}}}if("UnaryExpression"===e.type)return{type:"UnaryExpression",operator:e.operator,argument:g(e.argument,t)};if("CallExpression"===e.type){let n;"Identifier"===e.callee.type?n=e.callee.name:"MemberExpression"===e.callee.type&&"Identifier"===e.callee.object.type&&"Math"===e.callee.object.name&&"Identifier"===e.callee.property.type&&(n=e.callee.property.name);const r=e.arguments[0];if(n&&r&&"SpreadElement"!==r.type&&(0,i.expressionHasVariable)(r,t)){if("sin"===n)return{type:"BinaryExpression",operator:"*",left:{type:"CallExpression",callee:{type:"Identifier",name:"cos"},arguments:e.arguments},right:g(r,t)};if("cos"===n)return{type:"UnaryExpression",operator:"-",argument:{type:"BinaryExpression",operator:"*",left:{type:"CallExpression",callee:{type:"Identifier",name:"sin"},arguments:e.arguments},right:g(r,t)}};if("tan"===n)return{type:"BinaryExpression",operator:"/",left:{type:"BinaryExpression",operator:"/",left:g(r,t),right:{type:"CallExpression",callee:{type:"Identifier",name:"cos"},arguments:e.arguments}},right:{type:"CallExpression",callee:{type:"Identifier",name:"cos"},arguments:e.arguments}};if("ln"===n)return{type:"BinaryExpression",operator:"/",left:g(r,t),right:r};if("exp"===n)return{type:"BinaryExpression",operator:"*",left:e,right:g(r,t)}}}return"NumericLiteral"===e.type?{type:"NumericLiteral",value:0}:"Identifier"===e.type?{type:"NumericLiteral",value:e.name===t?1:0}:e}function h(e,t,n,o){const s=e=>(0,i.expressionHasVariable)(e,t);let c=(0,i.optimizeExpression)((0,a.composeExpression)((0,a.cloneExpression)(e),{[t]:{type:"NumericLiteral",value:0}}),s);o&&(c=(0,i.optimizeExpression)({type:"BinaryExpression",operator:"*",left:c,right:{type:"Identifier",name:t}},s));for(let l=1;l{"use strict";n.r(t),n.d(t,{ImageEditor:()=>$});var r=n(3696),o=n.n(r),i=n(8662),a=n(4840),s=n(6376),c=n(8907),l=n(9182),u=n(4104),p=n(360),d=n(3537),f=n(623),g=n(370),h=n(9160),m=n(7486),y=n(5481),v=n(1796),x=n(6842),b=n(2792),C=n(7195),E=n(9424),P=n(6487),w=n(8174),k=n(3975),_=n(5644),S=n(2318),R=n(5072),T=n(2298),A=n(7662),L=n(4205),M=n(3181),I=n(6301),O=n(8905),D=n(7670),B=n(1715),z=Object.defineProperty,F=Object.defineProperties,N=Object.getOwnPropertyDescriptors,U=Object.getOwnPropertySymbols,G=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable,V=(e,t,n)=>t in e?z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,W=(e,t)=>{for(var n in t||(t={}))G.call(t,n)&&V(e,n,t[n]);if(U)for(var n of U(t))j.call(t,n)&&V(e,n,t[n]);return e},H=(e,t)=>F(e,N(t)),q=(e,t,n)=>new Promise(((r,o)=>{var i=e=>{try{s(n.next(e))}catch(e){o(e)}},a=e=>{try{s(n.throw(e))}catch(e){o(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(i,a);s((n=n.apply(e,t)).next())}));function $(e){const{state:t,setState:n,resetHistory:r,undo:z,redo:F,canRedo:N,canUndo:U}=(0,E.useUndoRedo)(void 0),[G,j]=o().useState(),[V,$]=o().useState(),[Y,K]=o().useState("select"),[Z,Q]=o().useState(),[J,ee]=o().useState(),te=o().useRef(null),[ne,re]=o().useState(10),oe=o().useRef(0),ie=o().useRef(.5),ae=o().useRef(20),se=o().useRef("monospace"),ce=o().useRef(1),[le,ue]=o().useState(),pe=()=>{setTimeout((()=>{var e;null==(e=te.current)||e.focus()}))},de=t=>q(this,null,(function*(){var n,o;const i=yield(0,y.dataUrlToImage)(t,"anonymous"),a=Math.min(e.width/i.width,e.height/i.height),s=i.width*a,c=i.height*a,l=(e.width-s)/2+(null!=(n=e.x)?n:0),u=(e.height-c)/2+(null!=(o=e.y)?o:0),d=(0,p.zoomToFitPoints)((0,m.getPolygonFromTwoPointsFormRegion)({start:{x:0,y:0},end:{x:i.width,y:i.height}}),{width:s,height:c},{x:s/2,y:c/2},1);d&&(xe(d.scale),me(d.x),ye(d.y));const f=(0,y.createCanvasContext)(i);f&&(f.drawImage(i,0,0,i.width,i.height),r({url:t,ctx:f,x:l,y:u,canvasWidth:s,canvasHeight:c}),pe())}));o().useEffect((()=>{de(e.src)}),[]);const{x:fe,y:ge,ref:he,setX:me,setY:ye}=(0,l.useWheelScroll)(),{scale:ve,setScale:xe,ref:be}=(0,u.useWheelZoom)({onChange(e,n,r){if(!t)return;const o=(0,p.scaleByCursorPosition)({width:t.canvasWidth,height:t.canvasHeight},n/e,r);me(o.setX),ye(o.setY)}}),{zoomIn:Ce,zoomOut:Ee}=(0,g.useZoom)(ve,xe),{offset:Pe,onStart:we,mask:ke,resetDragMove:_e}=(0,c.useDragMove)((()=>{me((e=>e+Pe.x)),ye((e=>e+Pe.y)),K("select"),Le()})),{onStartSelect:Se,dragSelectMask:Re,endDragSelect:Te,resetDragSelect:Ae}=(0,h.useDragSelect)(((e,t)=>{if(t){e=Je(e),t=Je(t);const n=(0,m.getTwoPointsFormRegion)(e,t);if("add text"===Y)return void ue(H(W(W({},n.start),(0,m.getTwoPointsFormRegionSize)(n)),{text:""}));const r=(0,m.getPolygonFromTwoPointsFormRegion)(n);Q({type:"polygon",points:r}),pe()}})),Le=()=>{$(void 0),pe()},Me=(e=!0)=>{K("select"),Le(),_e(),Ae(),Q(void 0),j(void 0),ee(void 0),Fe(),je(),qe(e),Ke(),ue(void 0)},{start:Ie,ui:Oe}=(0,C.useChooseFile)((e=>q(this,null,(function*(){const t=yield(0,y.blobToDataUrl)(e);if("add image"===Y){const e=yield(0,y.dataUrlToImage)(t,"anonymous"),n=(0,y.createCanvasContext)(e);return n&&(n.drawImage(e,0,0,e.width,e.height),j({url:t,ctx:n})),void K("paste")}yield de(t)})))),{circle:De,onClick:Be,onMove:ze,reset:Fe}=(0,_.useCircleClickCreate)("circle select"===Y||"add circle"===Y?"center radius":void 0,(e=>{if("add circle"===Y)return void lt((t=>{t.arc(e.x,e.y,e.r,0,2*Math.PI)}));const t=(0,S.arcToPolyline)((0,S.circleToArc)(e),10).map((e=>({x:Math.round(e.x),y:Math.round(e.y)})));Q({type:"polygon",points:t}),pe()})),{ellipse:Ne,onClick:Ue,onMove:Ge,reset:je}=(0,R.useEllipseClickCreate)("ellipse select"===Y||"add ellipse"===Y?"ellipse center":void 0,(e=>{if("add ellipse"===Y)return void lt((t=>{t.ellipse(e.cx,e.cy,e.rx,e.ry,(0,B.angleToRadian)(e.angle),0,2*Math.PI)}));const t=(0,T.ellipseArcToPolyline)((0,T.ellipseToEllipseArc)(e),10).map((e=>({x:Math.round(e.x),y:Math.round(e.y)})));Q({type:"polygon",points:t}),pe()})),{line:Ve,onClick:We,onMove:He,reset:qe}=(0,A.useLineClickCreate)("polygon select"===Y||"add polyline"===Y||"add rect"===Y,(e=>{if("add polyline"!==Y)if("add rect"!==Y){if(e.length>2){const t=e.map((e=>({x:Math.round(e.x),y:Math.round(e.y)})));Q({type:"polygon",points:t})}pe()}else{const t=(0,m.getTwoPointsFormRegion)(e[0],e[1]),n=(0,m.getTwoPointsFormRegionSize)(t);lt((e=>{e.rect(t.start.x,t.start.y,n.width,n.height)}))}else lt((t=>{for(let n=0;n{if("add pen"===Y)return void lt((e=>{for(let t=0;t<$e.length;t++)0===t?e.moveTo($e[t].x,$e[t].y):e.lineTo($e[t].x,$e[t].y)}));const e=$e.map((e=>({x:Math.round(e.x),y:Math.round(e.y)})));Q({type:"polygon",points:e}),pe()}));if(!t)return null;const Ze={x:fe,y:ge,scale:ve,center:{x:t.canvasWidth/2,y:t.canvasHeight/2}};Ze.x+=Pe.x,Ze.y+=Pe.y;const Qe=e=>({x:e.x-t.x,y:e.y-t.y}),Je=e=>(e=Qe(e),(e=(0,p.reverseTransformPosition)(e,Ze)).x=Math.floor(e.x),e.y=Math.floor(e.y),e),et=a.reactCanvasRenderTarget,tt=[];tt.push(et.renderImage(t.url,0,0,t.ctx.canvas.width,t.ctx.canvas.height)),G&&J&&tt.push(et.renderImage(G.url,J.x,J.y,G.ctx.canvas.width,G.ctx.canvas.height));const nt={strokeWidth:0,fillColor:0,fillOpacity:.3},rt={strokeWidth:ce.current,strokeColor:oe.current,strokeOpacity:ie.current};if("polygon"===(null==Z?void 0:Z.type)&&tt.push(et.renderPolygon(Z.points,nt)),"range"===(null==Z?void 0:Z.type))for(const e of Z.ranges)for(const t of e.ys)tt.push(et.renderRect(e.x,t[0],1,t[1]-t[0]+1,nt));else"brush"===Y&&J&&tt.push(et.renderRect(J.x,J.y,2*ne+1,2*ne+1,nt));if(De&&tt.push(et.renderCircle(De.x,De.y,De.r,"add circle"===Y?rt:nt)),Ne&&tt.push(et.renderEllipse(Ne.cx,Ne.cy,Ne.rx,Ne.ry,H(W({},"add ellipse"===Y?rt:nt),{angle:Ne.angle}))),Ve)if("add polyline"===Y&&Ve.length>1)tt.push(et.renderPolyline(Ve,rt));else if("add rect"===Y&&Ve.length>1){const e=(0,m.getTwoPointsFormRegion)(Ve[0],Ve[1]),t=(0,m.getTwoPointsFormRegionSize)(e);tt.push(et.renderRect(e.start.x,e.start.y,t.width,t.height,rt))}else"polygon select"===Y&&Ve.length>2&&tt.push(et.renderPolygon(Ve,nt));$e&&("add pen"===Y&&$e.length>1?tt.push(et.renderPolyline($e,rt)):"pen select"===Y&&$e.length>2&&tt.push(et.renderPolygon($e,nt))),tt.push(et.renderRect(0,0,t.ctx.canvas.width,t.ctx.canvas.height,{strokeOpacity:.3,dashArray:[4]}));const ot=e=>{let r;if("polygon"===(null==Z?void 0:Z.type)?r=e=>t=>(0,v.pointInPolygon)({x:e,y:t},Z.points):"range"===(null==Z?void 0:Z.type)&&(r=e=>{const t=Z.ranges.find((t=>t.x===e));if(t)return e=>t.ys.some((t=>(0,b.isBetween)(e,...t)))}),r){const o=t.ctx.getImageData(0,0,t.ctx.canvas.width,t.ctx.canvas.height);for(let n=0;n{e&&(e.url=t.ctx.canvas.toDataURL())}))}Q(void 0)},it=()=>{ot((()=>[0,0,0,0]))},at=()=>{let e;if("polygon"===(null==Z?void 0:Z.type))e={bounding:(0,x.getPointsBounding)(Z.points),inRange:e=>t=>(0,v.pointInPolygon)({x:e,y:t},Z.points)};else if("range"===(null==Z?void 0:Z.type)){const t=Z.ranges.map((e=>e.x));e={bounding:{start:{x:Math.min(...t),y:Math.min(...Z.ranges.map((e=>e.ys.map((e=>e[0])))).flat())},end:{x:Math.max(...t),y:Math.max(...Z.ranges.map((e=>e.ys.map((e=>e[1])))).flat())}},inRange:e=>{const t=Z.ranges.find((t=>t.x===e));if(t)return e=>t.ys.some((t=>(0,b.isBetween)(e,...t)))}}}if(e){const n=e.bounding;if(n){const r=(0,m.getTwoPointsFormRegionSize)(n);r.width++,r.height++;const o=(0,y.createCanvasContext)(r);if(o){const i=o.createImageData(r.width,r.height),a=n.start.x,s=n.start.y,c=t.ctx.getImageData(0,0,t.ctx.canvas.width,t.ctx.canvas.height);for(let t=0;t{e&&navigator.clipboard.write([new ClipboardItem({[e.type]:e})])}))}}}Q(void 0)},st=()=>q(this,null,(function*(){const e=yield navigator.clipboard.read();for(const t of e)if(t.types.includes("image/png")){const e=yield t.getType("image/png"),n=yield(0,y.blobToDataUrl)(e),r=yield(0,y.dataUrlToImage)(n,"anonymous"),o=(0,y.createCanvasContext)(r);o&&(o.drawImage(r,0,0,r.width,r.height),j({url:n,ctx:o})),K("paste");break}})),ct=()=>q(this,null,(function*(){const e=yield navigator.clipboard.read();for(const t of e)if(t.types.includes("image/png")){const e=yield t.getType("image/png"),n=yield(0,y.blobToDataUrl)(e);yield de(n);break}})),lt=e=>{t.ctx.save(),t.ctx.beginPath(),e(t.ctx),t.ctx.lineWidth=ce.current,t.ctx.strokeStyle=(0,k.getColorString)(oe.current,ie.current),t.ctx.stroke(),t.ctx.restore(),n((e=>{e&&(e.url=t.ctx.canvas.toDataURL())})),Me(!1)};let ut;if("add text"===Y&&le){const e=(0,p.transformPosition)(le,Ze);ut=o().createElement(M.SimpleTextEditor,{fontSize:ae.current*ve,width:le.width*ve,height:le.height*ve,color:oe.current,fontFamily:se.current,onCancel:Me,x:e.x,y:e.y,value:le.text,setValue:e=>{le.text=e}})}return o().createElement("div",{ref:(0,d.bindMultipleRefs)(he,be),style:{cursor:"move"===Y?"grab":"crosshair",position:"absolute",inset:"0px",left:t.x+"px",top:t.y+"px",overflow:"hidden"},onMouseMove:e=>{if("brush"===Y){const t=Je({x:e.clientX,y:e.clientY});if("range"===(null==Z?void 0:Z.type)){const e=X(t,ne);Q({type:"range",ranges:(0,i.produce)(Z.ranges,(t=>{for(const n of e){const e=t.find((e=>e.x===n.x));e?e.ys=(0,b.mergeItems)([...n.ys,...e.ys],b.getNumberRangeUnion):t.push(n)}}))})}else ee({x:t.x-ne,y:t.y-ne})}if(G&&"paste"===Y){const t=Je({x:e.clientX,y:e.clientY});ee({x:Math.floor(t.x-G.ctx.canvas.width/2),y:Math.floor(t.y-G.ctx.canvas.height/2)})}else"circle select"===Y||"add circle"===Y?ze(Je({x:e.clientX,y:e.clientY})):"ellipse select"===Y||"add ellipse"===Y?Ge(Je({x:e.clientX,y:e.clientY})):"polygon select"===Y||"add polyline"===Y||"add rect"===Y?He(Je({x:e.clientX,y:e.clientY})):"pen select"!==Y&&"add pen"!==Y||Ye(Je({x:e.clientX,y:e.clientY}))}},et.renderResult(tt,t.canvasWidth,t.canvasHeight,{attributes:{onMouseDown(e){if("move"===Y)we({x:e.clientX,y:e.clientY});else if(4===e.buttons)we({x:e.clientX,y:e.clientY});else if("brush"===Y&&"range"!==(null==Z?void 0:Z.type)){const t=X(Je({x:e.clientX,y:e.clientY}),ne);Q({type:"range",ranges:t})}},onClick(e){if("select"===Y)Se(e);else if("paste"===Y&&G&&J){const e=t.ctx.getImageData(0,0,t.ctx.canvas.width,t.ctx.canvas.height),r=G.ctx.getImageData(0,0,G.ctx.canvas.width,G.ctx.canvas.height),o=Math.floor(J.x),i=Math.floor(J.y),a=Math.max(o,0),s=Math.min(o+G.ctx.canvas.width,t.ctx.canvas.width),c=Math.max(i,0),l=Math.min(i+G.ctx.canvas.height,t.ctx.canvas.height);for(let t=a;t{e&&(e.url=t.ctx.canvas.toDataURL())})),Me()}else if("brush"===Y&&"range"===(null==Z?void 0:Z.type)){const e=Z.ranges;Me(),Q({type:"range",ranges:e})}else if("circle select"===Y||"add circle"===Y)Be(Je({x:e.clientX,y:e.clientY}));else if("ellipse select"===Y||"add ellipse"===Y)Ue(Je({x:e.clientX,y:e.clientY}));else if("polygon select"===Y||"add polyline"===Y||"add rect"===Y)We(Je({x:e.clientX,y:e.clientY})),pe();else if("pen select"===Y||"add pen"===Y)Xe(Je({x:e.clientX,y:e.clientY}));else if("add text"===Y)if(le){if(le.text){const e=le.text.split(""),r=(0,O.getTextStyleFont)({fontSize:ae.current,fontFamily:se.current}),o=e=>{var t,n;return null!=(n=null==(t=(0,O.getTextSizeFromCache)(r,e))?void 0:t.width)?n:0},{layoutResult:i}=(0,I.flowLayout)({state:e,width:le.width,lineHeight:1.2*ae.current,getWidth:o,endContent:"",isNewLineContent:e=>"\n"===e,isPartOfComposition:e=>(0,O.isWordCharactor)(e),getComposition:t=>(0,D.getTextComposition)(t,e,o,(e=>e))});t.ctx.save(),t.ctx.font=r,t.ctx.textAlign="center",t.ctx.textBaseline="alphabetic",t.ctx.fillStyle=(0,k.getColorString)(oe.current);for(const{x:e,y:n,content:r}of i){const i=o(r);t.ctx.fillText(r,le.x+e+i/2,le.y+n+ae.current)}t.ctx.restore(),n((e=>{e&&(e.url=t.ctx.canvas.toDataURL())})),Me()}}else Se(e)},onDoubleClick(e){Te(e)},onContextMenu(n){n.preventDefault();const r=Qe({x:n.clientX,y:n.clientY});if(V)return void Le();const i=[];e.onCpmplete&&i.push({title:"complete",onClick(){var n;null==(n=e.onCpmplete)||n.call(e,t.url,t.canvasWidth,t.canvasHeight),Le()}}),e.onCancel&&i.push({title:"cancel",onClick(){var t;null==(t=e.onCancel)||t.call(e),Le()}}),i.push({title:"open",children:[{title:"file",onClick(){Ie(),Le()}},{title:"clipboard image",onClick(){return q(this,null,(function*(){yield ct(),Le()}))}}]});const a=[];U&&a.push({title:"undo",onClick(){z(),Le()}}),N&&a.push({title:"redo",onClick(){F(),Le()}}),a.push({title:"move",onClick:()=>{K("move"),Le()}}),i.push({title:"select",children:[{title:o().createElement(o().Fragment,null,o().createElement(w.NumberEditor,{value:ne,style:{width:"50px"},setValue:re}),o().createElement(w.Button,{onClick:()=>{K("brush"),Le(),Q(void 0)}},"brush select")),height:41},{title:"circle select",onClick:()=>{K("circle select"),Le()}},{title:"ellipse select",onClick:()=>{K("ellipse select"),Le()}},{title:"polygon select",onClick:()=>{K("polygon select"),Le()}},{title:"pen select",onClick:()=>{K("pen select"),Le()}}]}),Z&&a.push({title:"delete",onClick(){it(),Le()}},{title:o().createElement(o().Fragment,null,o().createElement(w.NumberEditor,{value:oe.current,type:"color",style:{width:"50px"},setValue:e=>oe.current=e}),o().createElement(w.Button,{onClick:()=>{const e=(0,k.colorNumberToPixelColor)(oe.current);ot((t=>[e[0],e[1],e[2],t[3]])),Le()}},"apply color")),height:33},{title:o().createElement(o().Fragment,null,o().createElement(w.NumberEditor,{value:100*ie.current,style:{width:"50px"},setValue:e=>ie.current=.01*e}),o().createElement(w.Button,{onClick:()=>{const e=Math.round(255*ie.current);ot((t=>[t[0],t[1],t[2],e])),Le()}},"apply opacity")),height:41},{title:"cut",onClick(){at(),it(),Le()}},{title:"copy",onClick(){at(),Le()}}),i.push({title:"edit",children:a}),i.push({title:"add",children:[{title:"paste",onClick(){return q(this,null,(function*(){yield st(),Le()}))}},{title:"image",onClick(){K("add image"),Ie(),Le()}},{title:o().createElement(o().Fragment,null,o().createElement(w.NumberEditor,{value:ae.current,style:{width:"40px"},setValue:e=>ae.current=e}),o().createElement(w.StringEditor,{value:se.current,style:{width:"100px"},setValue:e=>se.current=e}),o().createElement(w.Button,{onClick:()=>{K("add text"),Le()}},"text")),height:41},{title:o().createElement(o().Fragment,null,o().createElement(w.NumberEditor,{value:oe.current,type:"color",style:{width:"50px"},setValue:e=>oe.current=e}),o().createElement(w.NumberEditor,{value:100*ie.current,style:{width:"50px"},setValue:e=>ie.current=.01*e}),o().createElement(w.NumberEditor,{value:ce.current,style:{width:"40px"},setValue:e=>ce.current=e})),height:41},{title:"polyline",onClick(){K("add polyline"),Le()}},{title:"pen",onClick(){K("add pen"),Le()}},{title:"circle",onClick(){K("add circle"),Le()}},{title:"ellipse",onClick(){K("add ellipse"),Le()}},{title:"rect",onClick(){K("add rect"),Le()}}]}),i.push({title:"export",children:[{title:"to clipboard",onClick(){t.ctx.canvas.toBlob((e=>{e&&navigator.clipboard.write([new ClipboardItem({[e.type]:e})])})),Le(),Q(void 0)}}]}),$(o().createElement(s.Menu,{items:i,y:r.y,height:t.canvasHeight,style:{left:r.x+"px"}}))},style:e.style},transform:Ze}),ut,V,Re,ke,Oe,o().createElement(P.Cursor,{ref:te,onKeyDown:n=>{var r,o;if(n.stopPropagation(),(0,f.metaKeyIfMacElseCtrlKey)(n)){if("Minus"===n.code)Ee(n);else if("Equal"===n.code)Ce(n);else if("ArrowLeft"===n.key){if(!t)return;me((e=>e+t.canvasWidth/10)),n.preventDefault()}else if("ArrowRight"===n.key){if(!t)return;me((e=>e-t.canvasWidth/10)),n.preventDefault()}else if("ArrowUp"===n.key){if(!t)return;ye((e=>e+t.canvasHeight/10)),n.preventDefault()}else if("ArrowDown"===n.key){if(!t)return;ye((e=>e-t.canvasHeight/10)),n.preventDefault()}else if("KeyZ"===n.code)n.shiftKey?F(n):z(n);else if(!n.shiftKey)if("KeyA"===n.code){if(!t)return;const e=(0,m.getPolygonFromTwoPointsFormRegion)((0,m.getTwoPointsFormRegion)({x:0,y:0},{x:t.ctx.canvas.width,y:t.ctx.canvas.height}));Q({type:"polygon",points:e}),n.preventDefault()}else"KeyC"===n.code?(at(),n.preventDefault()):"KeyV"===n.code?(st(),n.preventDefault()):"KeyX"===n.code?(at(),it(),n.preventDefault()):"KeyS"===n.code&&(t&&(null==(r=e.onCpmplete)||r.call(e,t.url,t.canvasWidth,t.canvasHeight)),n.preventDefault())}else"Escape"===n.key&&(Me(),null==(o=e.onCancel)||o.call(e))}}))}function X({x:e,y:t},n){const r=[];for(let o=-n;o<=n;o++)r.push({x:e+o,ys:[[t-n,t+n]]});return r}},7875:(e,t,n)=>{"use strict";n.r(t);var r=n(3158),o={};for(const e in r)"default"!==e&&(o[e]=()=>r[e]);n.d(t,o);var i=n(8907);o={};for(const e in i)"default"!==e&&(o[e]=()=>i[e]);n.d(t,o);var a=n(3331);o={};for(const e in a)"default"!==e&&(o[e]=()=>a[e]);n.d(t,o);var s=n(9182);o={};for(const e in s)"default"!==e&&(o[e]=()=>s[e]);n.d(t,o);var c=n(4104);o={};for(const e in c)"default"!==e&&(o[e]=()=>c[e]);n.d(t,o);var l=n(9424);o={};for(const e in l)"default"!==e&&(o[e]=()=>l[e]);n.d(t,o);var u=n(2931);o={};for(const e in u)"default"!==e&&(o[e]=()=>u[e]);n.d(t,o);var p=n(370);o={};for(const e in p)"default"!==e&&(o[e]=()=>p[e]);n.d(t,o);var d=n(2789);o={};for(const e in d)"default"!==e&&(o[e]=()=>d[e]);n.d(t,o);var f=n(2800);o={};for(const e in f)"default"!==e&&(o[e]=()=>f[e]);n.d(t,o);var g=n(5634);o={};for(const e in g)"default"!==e&&(o[e]=()=>g[e]);n.d(t,o);var h=n(1412);o={};for(const e in h)"default"!==e&&(o[e]=()=>h[e]);n.d(t,o);var m=n(9160);o={};for(const e in m)"default"!==e&&(o[e]=()=>m[e]);n.d(t,o);var y=n(3307);o={};for(const e in y)"default"!==e&&(o[e]=()=>y[e]);n.d(t,o);var v=n(7923);o={};for(const e in v)"default"!==e&&(o[e]=()=>v[e]);n.d(t,o);var x=n(6545);o={};for(const e in x)"default"!==e&&(o[e]=()=>x[e]);n.d(t,o);var b=n(5644);o={};for(const e in b)"default"!==e&&(o[e]=()=>b[e]);n.d(t,o);var C=n(7662);o={};for(const e in C)"default"!==e&&(o[e]=()=>C[e]);n.d(t,o);var E=n(5970);o={};for(const e in E)"default"!==e&&(o[e]=()=>E[e]);n.d(t,o);var P=n(1369);o={};for(const e in P)"default"!==e&&(o[e]=()=>P[e]);n.d(t,o);var w=n(8285);o={};for(const e in w)"default"!==e&&(o[e]=()=>w[e]);n.d(t,o);var k=n(4489);o={};for(const e in k)"default"!==e&&(o[e]=()=>k[e]);n.d(t,o);var _=n(341);o={};for(const e in _)"default"!==e&&(o[e]=()=>_[e]);n.d(t,o);var S=n(4840);o={};for(const e in S)"default"!==e&&(o[e]=()=>S[e]);n.d(t,o);var R=n(2628);o={};for(const e in R)"default"!==e&&(o[e]=()=>R[e]);n.d(t,o);var T=n(5072);o={};for(const e in T)"default"!==e&&(o[e]=()=>T[e]);n.d(t,o);var A=n(2817);o={};for(const e in A)"default"!==e&&(o[e]=()=>A[e]);n.d(t,o);var L=n(3869);o={};for(const e in L)"default"!==e&&(o[e]=()=>L[e]);n.d(t,o);var M=n(1749);o={};for(const e in M)"default"!==e&&(o[e]=()=>M[e]);n.d(t,o);var I=n(4848);o={};for(const e in I)"default"!==e&&(o[e]=()=>I[e]);n.d(t,o);var O=n(3404);o={};for(const e in O)"default"!==e&&(o[e]=()=>O[e]);n.d(t,o);var D=n(9345);o={};for(const e in D)"default"!==e&&(o[e]=()=>D[e]);n.d(t,o);var B=n(4970);o={};for(const e in B)"default"!==e&&(o[e]=()=>B[e]);n.d(t,o);var z=n(5115);o={};for(const e in z)"default"!==e&&(o[e]=()=>z[e]);n.d(t,o);var F=n(2286);o={};for(const e in F)"default"!==e&&(o[e]=()=>F[e]);n.d(t,o);var N=n(4332);o={};for(const e in N)"default"!==e&&(o[e]=()=>N[e]);n.d(t,o);var U=n(5384);o={};for(const e in U)"default"!==e&&(o[e]=()=>U[e]);n.d(t,o);var G=n(6421);o={};for(const e in G)"default"!==e&&(o[e]=()=>G[e]);n.d(t,o);var j=n(7332);o={};for(const e in j)"default"!==e&&(o[e]=()=>j[e]);n.d(t,o);var V=n(5632);o={};for(const e in V)"default"!==e&&(o[e]=()=>V[e]);n.d(t,o);var W=n(9055);o={};for(const e in W)"default"!==e&&(o[e]=()=>W[e]);n.d(t,o);var H=n(2244);o={};for(const e in H)"default"!==e&&(o[e]=()=>H[e]);n.d(t,o);var q=n(6424);o={};for(const e in q)"default"!==e&&(o[e]=()=>q[e]);n.d(t,o);var $=n(9294);o={};for(const e in $)"default"!==e&&(o[e]=()=>$[e]);n.d(t,o);var X=n(69);o={};for(const e in X)"default"!==e&&(o[e]=()=>X[e]);n.d(t,o);var Y=n(4399);o={};for(const e in Y)"default"!==e&&(o[e]=()=>Y[e]);n.d(t,o);var K=n(6278);o={};for(const e in K)"default"!==e&&(o[e]=()=>K[e]);n.d(t,o);var Z=n(6845);o={};for(const e in Z)"default"!==e&&(o[e]=()=>Z[e]);n.d(t,o);var Q=n(3175);o={};for(const e in Q)"default"!==e&&(o[e]=()=>Q[e]);n.d(t,o);var J=n(7195);o={};for(const e in J)"default"!==e&&(o[e]=()=>J[e]);n.d(t,o);var ee=n(7658);o={};for(const e in ee)"default"!==e&&(o[e]=()=>ee[e]);n.d(t,o);var te=n(327);o={};for(const e in te)"default"!==e&&(o[e]=()=>te[e]);n.d(t,o);var ne=n(4205);o={};for(const e in ne)"default"!==e&&(o[e]=()=>ne[e]);n.d(t,o);var re=n(4844);o={};for(const e in re)"default"!==e&&(o[e]=()=>re[e]);n.d(t,o);var oe=n(7670);o={};for(const e in oe)"default"!==e&&(o[e]=()=>oe[e]);n.d(t,o);var ie=n(135);o={};for(const e in ie)"default"!==e&&(o[e]=()=>ie[e]);n.d(t,o);var ae=n(7816);o={};for(const e in ae)"default"!==e&&(o[e]=()=>ae[e]);n.d(t,o);var se=n(2432);o={};for(const e in se)"default"!==e&&(o[e]=()=>se[e]);n.d(t,o);var ce=n(4740);o={};for(const e in ce)"default"!==e&&(o[e]=()=>ce[e]);n.d(t,o);var le=n(8174);o={};for(const e in le)"default"!==e&&(o[e]=()=>le[e]);n.d(t,o);var ue=n(2607);o={};for(const e in ue)"default"!==e&&(o[e]=()=>ue[e]);n.d(t,o);var pe=n(4546);o={};for(const e in pe)"default"!==e&&(o[e]=()=>pe[e]);n.d(t,o);var de=n(9436);o={};for(const e in de)"default"!==e&&(o[e]=()=>de[e]);n.d(t,o);var fe=n(2978);o={};for(const e in fe)"default"!==e&&(o[e]=()=>fe[e]);n.d(t,o);var ge=n(3274);o={};for(const e in ge)"default"!==e&&(o[e]=()=>ge[e]);n.d(t,o);var he=n(4468);o={};for(const e in he)"default"!==e&&(o[e]=()=>he[e]);n.d(t,o);var me=n(5936);o={};for(const e in me)"default"!==e&&(o[e]=()=>me[e]);n.d(t,o);var ye=n(2202);o={};for(const e in ye)"default"!==e&&(o[e]=()=>ye[e]);n.d(t,o);var ve=n(7921);o={};for(const e in ve)"default"!==e&&(o[e]=()=>ve[e]);n.d(t,o);var xe=n(8454);o={};for(const e in xe)"default"!==e&&(o[e]=()=>xe[e]);n.d(t,o);var be=n(9201);o={};for(const e in be)"default"!==e&&(o[e]=()=>be[e]);n.d(t,o);var Ce=n(1121);o={};for(const e in Ce)"default"!==e&&(o[e]=()=>Ce[e]);n.d(t,o);var Ee=n(3549);o={};for(const e in Ee)"default"!==e&&(o[e]=()=>Ee[e]);n.d(t,o);var Pe=n(6376);o={};for(const e in Pe)"default"!==e&&(o[e]=()=>Pe[e]);n.d(t,o);var we=n(1478);o={};for(const e in we)"default"!==e&&(o[e]=()=>we[e]);n.d(t,o);var ke=n(3181);o={};for(const e in ke)"default"!==e&&(o[e]=()=>ke[e]);n.d(t,o)},6376:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Menu:()=>p,getMenuHeight:()=>f,getMenuPosition:()=>d});var r=n(3696),o=n.n(r),i=Object.defineProperty,a=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,c=Object.prototype.propertyIsEnumerable,l=(e,t,n)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,u=(e,t)=>{for(var n in t||(t={}))s.call(t,n)&&l(e,n,t[n]);if(a)for(var n of a(t))c.call(t,n)&&l(e,n,t[n]);return e};function p(e){var t;let n=0;const r=null!=(t=e.height)?t:window.innerHeight;void 0!==e.y&&(n=Math.min(e.y,r-f(e.items,16)));const[i,a]=o().useState(-1);return o().createElement("ul",{style:u({position:"absolute",boxShadow:"0 0.5rem 1rem rgba(0, 0, 0, 0.15)",borderRadius:"0.375rem",border:"1px solid rgba(0, 0, 0, 0.175)",background:"white",padding:"0.5em 0",top:`${n}px`},e.style)},e.items.map(((t,s)=>"divider"===t.type?o().createElement("li",{key:s,style:{listStyle:"none"}},o().createElement("hr",{style:{height:0,margin:"0.5em 0",border:0,borderTop:"1px solid rgba(0, 0, 0, 0.175)"}})):o().createElement("li",{key:s,style:{padding:"0 0.5em",paddingRight:"1.5em",position:"relative",listStyle:"none",background:i===s?"#f8f9fa":void 0,color:t.disabled?"rgba(33, 37, 41, 0.5)":void 0,cursor:t.disabled?"not-allowed":"pointer",whiteSpace:"nowrap",lineHeight:"32px"},onMouseEnter:()=>a(s),onClick:t.onClick},o().createElement("span",null,t.title),t.children&&t.children.length>0&&o().createElement("svg",{style:{right:"0.5em",height:"100%",position:"absolute"},xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 10 10",width:"10",height:"10"},o().createElement("polyline",{points:"2,0 8,5 2,10",stroke:"currentColor",fill:"none"})),i===s&&t.children&&t.children.length>0&&o().createElement(p,{items:t.children,height:r-d(e.items,s,16)-n,y:0,style:{left:"100%"}})))))}function d(e,t,n){return e.slice(0,t).reduce(((e,t)=>{var r;return e+("divider"===t.type?n+1:null!=(r=t.height)?r:32)}),0)+n/2+1}function f(e,t){return e.reduce(((e,n)=>{var r;return e+("divider"===n.type?t+1:null!=(r=n.height)?r:32)}),0)+t+2}},6199:(e,t,n)=>{"use strict";n.r(t),n.d(t,{ArrayEditor:()=>d,ObjectArrayEditor:()=>f});var r=n(3696),o=n(8640),i=n(7749),a=Object.defineProperty,s=Object.getOwnPropertySymbols,c=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,u=(e,t,n)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,p=(e,t)=>{for(var n in t||(t={}))c.call(t,n)&&u(e,n,t[n]);if(s)for(var n of s(t))l.call(t,n)&&u(e,n,t[n]);return e};function d(e){return e.inline?r.createElement("div",{style:p(p({},i.groupStyle),e.style)},r.createElement("div",null,e.items.map(((t,n)=>r.createElement("div",{key:n,style:{display:"flex",alignItems:"center",marginBottom:"3px"}},r.createElement("div",{style:{paddingRight:"5px",width:"14px"}},n+1),r.createElement("div",{style:{flex:1,display:"flex"}},r.cloneElement(t,(0,i.getChildProps)(e))),!e.readOnly&&r.createElement("div",null,e.remove&&r.createElement(o.Button,{onClick:()=>{var t;return null==(t=e.remove)?void 0:t.call(e,n)}},h),e.copy&&r.createElement(o.Button,{onClick:()=>{var t;return null==(t=e.copy)?void 0:t.call(e,n)}},v),n>0&&e.moveUp&&r.createElement(o.Button,{onClick:()=>{var t;return null==(t=e.moveUp)?void 0:t.call(e,n)}},m),n{var t;return null==(t=e.moveDown)?void 0:t.call(e,n)}},y)))))),!e.readOnly&&e.add&&r.createElement(o.Button,{onClick:e.add},g)):r.createElement("div",{style:p(p({},i.groupStyle),e.style)},e.items.map(((t,n)=>{var a,s;return r.createElement(r.Fragment,{key:n},r.createElement("div",{style:{marginBottom:"5px",marginTop:"5px"}},null!=(s=null==(a=e.title)?void 0:a.call(e,n))?s:n+1,!e.readOnly&&e.remove&&r.createElement(o.Button,{style:{marginLeft:"5px"},onClick:()=>{var t;return null==(t=e.remove)?void 0:t.call(e,n)}},h),!e.readOnly&&e.copy&&r.createElement(o.Button,{onClick:()=>{var t;return null==(t=e.copy)?void 0:t.call(e,n)}},v),!e.readOnly&&e.moveUp&&n>0&&r.createElement(o.Button,{onClick:()=>{var t;return null==(t=e.moveUp)?void 0:t.call(e,n)}},m),!e.readOnly&&e.moveDown&&n{var t;return null==(t=e.moveDown)?void 0:t.call(e,n)}},y)),r.createElement("div",{style:{display:"flex"}},r.cloneElement(t,(0,i.getChildProps)(e))))})),!e.readOnly&&e.add&&r.createElement(o.Button,{onClick:e.add},g))}function f(e){return 0===e.properties.length?null:r.createElement("div",{style:p(p({},i.groupStyle),e.style)},r.createElement("table",null,r.createElement("thead",null,r.createElement("tr",null,r.createElement("td",null),Object.entries(e.properties[0]).map((([e])=>r.createElement("td",{key:e},e))),!e.readOnly&&r.createElement("td",null))),r.createElement("tbody",null,e.properties.map(((t,n)=>r.createElement("tr",{key:n},r.createElement("td",{style:{paddingRight:"5px"}},n+1),Object.values(t).map(((t,n)=>r.createElement("td",{key:n},r.cloneElement(t,(0,i.getChildProps)(e))))),!e.readOnly&&r.createElement("td",null,e.remove&&r.createElement(o.Button,{onClick:()=>{var t;return null==(t=e.remove)?void 0:t.call(e,n)}},h),e.copy&&r.createElement(o.Button,{onClick:()=>{var t;return null==(t=e.copy)?void 0:t.call(e,n)}},v),e.moveUp&&n>0&&r.createElement(o.Button,{onClick:()=>{var t;return null==(t=e.moveUp)?void 0:t.call(e,n)}},m),e.moveDown&&n{var t;return null==(t=e.moveDown)?void 0:t.call(e,n)}},y))))))),!e.readOnly&&e.add&&r.createElement(o.Button,{onClick:e.add},g))}const g=r.createElement("svg",{style:{width:"20px",height:"20px"},viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg"},r.createElement("path",{fill:"currentColor",d:"M480 480V128a32 32 0 0 1 64 0v352h352a32 32 0 1 1 0 64H544v352a32 32 0 1 1-64 0V544H128a32 32 0 0 1 0-64h352z"})),h=r.createElement("svg",{style:{width:"20px",height:"20px"},viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg"},r.createElement("path",{fill:"currentColor",d:"M764.288 214.592 512 466.88 259.712 214.592a31.936 31.936 0 0 0-45.12 45.12L466.752 512 214.528 764.224a31.936 31.936 0 1 0 45.12 45.184L512 557.184l252.288 252.288a31.936 31.936 0 0 0 45.12-45.12L557.12 512.064l252.288-252.352a31.936 31.936 0 1 0-45.12-45.184z"})),m=r.createElement("svg",{style:{width:"20px",height:"20px"},viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg"},r.createElement("path",{fill:"currentColor",d:"M572.235 205.282v600.365a30.118 30.118 0 1 1-60.235 0V205.282L292.382 438.633a28.913 28.913 0 0 1-42.646 0 33.43 33.43 0 0 1 0-45.236l271.058-288.045a28.913 28.913 0 0 1 42.647 0L834.5 393.397a33.43 33.43 0 0 1 0 45.176 28.913 28.913 0 0 1-42.647 0l-219.618-233.23z"})),y=r.createElement("svg",{style:{width:"20px",height:"20px"},viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg"},r.createElement("path",{fill:"currentColor",d:"M544 805.888V168a32 32 0 1 0-64 0v637.888L246.656 557.952a30.72 30.72 0 0 0-45.312 0 35.52 35.52 0 0 0 0 48.064l288 306.048a30.72 30.72 0 0 0 45.312 0l288-306.048a35.52 35.52 0 0 0 0-48 30.72 30.72 0 0 0-45.312 0L544 805.824z"})),v=r.createElement("svg",{style:{width:"20px",height:"20px"},viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg"},r.createElement("path",{fill:"currentColor",d:"M128 320v576h576V320H128zm-32-64h640a32 32 0 0 1 32 32v640a32 32 0 0 1-32 32H96a32 32 0 0 1-32-32V288a32 32 0 0 1 32-32zM960 96v704a32 32 0 0 1-32 32h-96v-64h64V128H384v64h-64V96a32 32 0 0 1 32-32h576a32 32 0 0 1 32 32zM256 672h320v64H256v-64zm0-192h320v64H256v-64z"}))},2290:(e,t,n)=>{"use strict";n.r(t),n.d(t,{BooleanEditor:()=>o});var r=n(3696);function o(e){return r.createElement("div",{style:e.style},r.createElement("input",{type:"checkbox",disabled:e.readOnly||!e.setValue,checked:e.value,onChange:t=>{!e.readOnly&&e.setValue&&e.setValue(t.target.checked)}}))}},8640:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Button:()=>g,Label:()=>h});var r=n(3696),o=n(7749),i=Object.defineProperty,a=Object.defineProperties,s=Object.getOwnPropertyDescriptors,c=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,u=Object.prototype.propertyIsEnumerable,p=(e,t,n)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,d=(e,t)=>{for(var n in t||(t={}))l.call(t,n)&&p(e,n,t[n]);if(c)for(var n of c(t))u.call(t,n)&&p(e,n,t[n]);return e},f=(e,t)=>a(e,s(t));function g(e){return r.createElement("button",f(d({},e),{style:d(d(d({},o.buttonStyle),e.style),e.disabled?o.disabledStyle:{})})," ",e.children)}function h(e){return r.createElement("span",f(d({},e),{style:d(d({},o.labelStyle),e.style)})," ",e.children)}},7749:(e,t,n)=>{"use strict";n.r(t),n.d(t,{buttonStyle:()=>p,controlStyle:()=>u,disabledStyle:()=>d,getChildProps:()=>h,groupStyle:()=>g,labelStyle:()=>f});var r=Object.defineProperty,o=Object.defineProperties,i=Object.getOwnPropertyDescriptors,a=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,c=Object.prototype.propertyIsEnumerable,l=(e,t,n)=>t in e?r(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;const u={outline:0,padding:"0.375rem 0.75rem",fontSize:"1rem",fontWeight:400,fontFamily:"monospace",lineHeight:1.5,color:"#212529",backgroundColor:"#fff",backgroundClip:"padding-box",border:"1px solid #ced4da",appearance:"none",borderRadius:"0.25rem",flex:1,marginBottom:"3px"},p={display:"inline-block",fontWeight:400,lineHeight:1,color:"#212529",textAlign:"center",textDecoration:"none",verticalAlign:"middle",cursor:"pointer",userSelect:"none",backgroundColor:"transparent",border:"1px solid transparent",padding:"0.375rem 0.75rem",fontSize:"1rem",borderRadius:"0.25rem"},d={cursor:"not-allowed",opacity:.5},f=o(((e,t)=>{for(var n in t||(t={}))s.call(t,n)&&l(e,n,t[n]);if(a)for(var n of a(t))c.call(t,n)&&l(e,n,t[n]);return e})({},p),i({cursor:void 0}));const g={padding:"10px",border:"1px solid rgba(0,0,0,.125)",borderRadius:"0.25rem",flex:1,marginBottom:"3px"};function h(e){const t={};return void 0!==e.readOnly&&(t.readOnly=e.readOnly),t}},1030:(e,t,n)=>{"use strict";n.r(t),n.d(t,{DialogContainer:()=>a});var r=n(3696),o=n(8640),i=n(7749);function a(e){const[t,n]=r.useState(!1);return r.createElement(r.Fragment,null,r.createElement(o.Button,{onClick:()=>n(!0)},s),t&&r.createElement("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",display:"flex",justifyContent:"center",alignItems:"center",zIndex:2},onClick:()=>n(!1)},r.createElement("div",{style:{width:"600px",display:"flex",background:"white"},onClick:e=>e.stopPropagation()},r.cloneElement(e.children,(0,i.getChildProps)(e)))))}const s=r.createElement("svg",{style:{width:"20px",height:"20px"},viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg"},r.createElement("path",{fill:"currentColor",d:"M832 512a32 32 0 1 1 64 0v352a32 32 0 0 1-32 32H160a32 32 0 0 1-32-32V160a32 32 0 0 1 32-32h352a32 32 0 0 1 0 64H192v640h640V512z"}),r.createElement("path",{fill:"currentColor",d:"m469.952 554.24 52.8-7.552L847.104 222.4a32 32 0 1 0-45.248-45.248L477.44 501.44l-7.552 52.8zm422.4-422.4a96 96 0 0 1 0 135.808l-331.84 331.84a32 32 0 0 1-18.112 9.088L436.8 623.68a32 32 0 0 1-36.224-36.224l15.104-105.6a32 32 0 0 1 9.024-18.112l331.904-331.84a96 96 0 0 1 135.744 0z"}))},6209:(e,t,n)=>{"use strict";n.r(t),n.d(t,{EnumArrayEditor:()=>d,EnumEditor:()=>f});var r=n(3696),o=n(8662),i=n(7749),a=Object.defineProperty,s=Object.getOwnPropertySymbols,c=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,u=(e,t,n)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,p=(e,t)=>{for(var n in t||(t={}))c.call(t,n)&&u(e,n,t[n]);if(s)for(var n of s(t))l.call(t,n)&&u(e,n,t[n]);return e};function d(e){return r.createElement("div",{style:e.style},e.enums.map(((t,n)=>{var i,a;return r.createElement("label",{key:t,style:{marginRight:"10px"}},r.createElement("input",{type:"checkbox",checked:e.value.includes(t),style:{marginRight:"5px"},disabled:e.readOnly||!e.setValue,onChange:()=>{if(e.readOnly||!e.setValue)return;const n=e.value.indexOf(t);e.setValue((0,o.produce)(e.value,(e=>{n>=0?e.splice(n,1):e.push((0,o.castDraft)(t))})))}}),null!=(a=null==(i=e.enumTitles)?void 0:i[n])?a:t)})))}function f(e){return e.select?r.createElement("select",{style:p(p({},i.controlStyle),e.style),disabled:e.readOnly||!e.setValue,value:e.value,onChange:t=>{if(e.readOnly||!e.setValue)return;let n=t.target.value;"number"==typeof e.enums[0]&&(n=+n),e.setValue(n)}},e.enums.map(((t,n)=>{var o,i;return r.createElement("option",{key:t,value:t},null!=(i=null==(o=e.enumTitles)?void 0:o[n])?i:t)}))):r.createElement("div",{style:e.style},e.enums.map(((t,n)=>{var o,i;return r.createElement("label",{key:t,style:{marginRight:"10px"}},r.createElement("input",{type:"radio",disabled:e.readOnly||!e.setValue,checked:e.value===t,style:{marginRight:"5px"},onChange:()=>{!e.readOnly&&e.setValue&&e.setValue(t)}}),null!=(i=null==(o=e.enumTitles)?void 0:o[n])?i:t)})))}},8174:(e,t,n)=>{"use strict";n.r(t);var r=n(6199),o={};for(const e in r)"default"!==e&&(o[e]=()=>r[e]);n.d(t,o);var i=n(2290);o={};for(const e in i)"default"!==e&&(o[e]=()=>i[e]);n.d(t,o);var a=n(1030);o={};for(const e in a)"default"!==e&&(o[e]=()=>a[e]);n.d(t,o);var s=n(6209);o={};for(const e in s)"default"!==e&&(o[e]=()=>s[e]);n.d(t,o);var c=n(4993);o={};for(const e in c)"default"!==e&&(o[e]=()=>c[e]);n.d(t,o);var l=n(6467);o={};for(const e in l)"default"!==e&&(o[e]=()=>l[e]);n.d(t,o);var u=n(2729);o={};for(const e in u)"default"!==e&&(o[e]=()=>u[e]);n.d(t,o);var p=n(3675);o={};for(const e in p)"default"!==e&&(o[e]=()=>p[e]);n.d(t,o);var d=n(8640);o={};for(const e in d)"default"!==e&&(o[e]=()=>d[e]);n.d(t,o);var f=n(7749);o={};for(const e in f)"default"!==e&&(o[e]=()=>f[e]);n.d(t,o)},4993:(e,t,n)=>{"use strict";n.r(t),n.d(t,{NumberEditor:()=>d});var r=n(3696),o=n(3975),i=n(7749),a=Object.defineProperty,s=Object.getOwnPropertySymbols,c=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,u=(e,t,n)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,p=(e,t)=>{for(var n in t||(t={}))c.call(t,n)&&u(e,n,t[n]);if(s)for(var n of s(t))l.call(t,n)&&u(e,n,t[n]);return e};function d(e){var t;const[n,a]=r.useState("color"===e.type?(0,o.getColorString)(e.value):e.value.toString());r.useEffect((()=>{a("color"===e.type?(0,o.getColorString)(e.value):e.value.toString())}),[e.value]);const s=()=>{if(e.readOnly||!e.setValue)return;let t;t="color"===e.type?(0,o.colorStringToNumber)(n):+n,isNaN(t)||t===e.value||e.setValue(t)};let c={};return"color"===e.type&&(c={flex:"unset",padding:0}),!e.readOnly&&e.setValue||(c.opacity=.5),r.createElement("input",{value:n,type:null!=(t=e.type)?t:"number",disabled:e.readOnly||!e.setValue,onChange:t=>{!e.readOnly&&e.setValue&&a(t.target.value)},style:p(p(p({},i.controlStyle),e.style),c),onKeyDown:t=>{var n;"Enter"===t.key&&s(),"Escape"!==t.key?t.stopPropagation():null==(n=e.onCancel)||n.call(e)},onBlur:()=>{setTimeout((()=>{s()}),0)}})}},6467:(e,t,n)=>{"use strict";n.r(t),n.d(t,{ObjectEditor:()=>p});var r=n(3696),o=n(7749),i=Object.defineProperty,a=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,c=Object.prototype.propertyIsEnumerable,l=(e,t,n)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,u=(e,t)=>{for(var n in t||(t={}))s.call(t,n)&&l(e,n,t[n]);if(a)for(var n of a(t))c.call(t,n)&&l(e,n,t[n]);return e};function p(e){const t=Object.entries(e.properties).map((([t,n])=>[t,Array.isArray(n)?n.map(((t,n)=>t?r.cloneElement(t,u({key:n},(0,o.getChildProps)(e))):null)):r.cloneElement(n,(0,o.getChildProps)(e))]));return e.inline?r.createElement("table",{style:o.groupStyle},r.createElement("thead",null),r.createElement("tbody",null,t.map((([e,t])=>r.createElement("tr",{key:e},r.createElement("td",{style:{paddingRight:"5px"}},e),r.createElement("td",{style:{display:"flex",flexDirection:"column"}},t)))))):r.createElement("div",{style:o.groupStyle},t.map((([e,t])=>r.createElement(r.Fragment,{key:e},r.createElement("div",{style:{marginTop:"5px",marginBottom:"5px"}},e),r.createElement("div",{style:{display:"flex",flexDirection:"column"}},t)))))}},2729:(e,t,n)=>{"use strict";n.r(t),n.d(t,{StringEditor:()=>p});var r=n(3696),o=n(7749),i=Object.defineProperty,a=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,c=Object.prototype.propertyIsEnumerable,l=(e,t,n)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,u=(e,t)=>{for(var n in t||(t={}))s.call(t,n)&&l(e,n,t[n]);if(a)for(var n of a(t))c.call(t,n)&&l(e,n,t[n]);return e};function p(e){var t;const[n,i]=r.useState(e.value);r.useEffect((()=>{i(e.value)}),[e.value]);const a=()=>{!e.readOnly&&e.setValue&&n!==e.value&&e.setValue(n)};let s,c={};return"color"===e.type&&(c={flex:"unset",padding:0}),!e.readOnly&&e.setValue||(c.opacity=.5),e.textarea?r.createElement("textarea",{value:n,disabled:e.readOnly||!e.setValue,onChange:t=>{!e.readOnly&&e.setValue&&i(t.target.value)},onKeyDown:t=>{var n;"Escape"!==t.key?t.stopPropagation():null==(n=e.onCancel)||n.call(e)},autoFocus:e.autoFocus,onBlur:()=>{setTimeout((()=>{a()}),0)},style:u(u(u({},o.controlStyle),e.style),c)}):((function(e){if(!e||e.length<=8)return!1;if("http://"!==e.substr(0,7)&&"https://"!==e.substr(0,8))return!1;const t=e.substr(e.length-4,4);return-1!==d.indexOf(t)}(e.value)||!!(l=e.value)&&0===l.indexOf("data:image/")&&-1!==l.indexOf(";base64,"))&&(s=r.createElement("img",{src:e.value,style:{display:"block",height:"auto",margin:"6px 0px",maxWidth:"100%"}})),r.createElement(r.Fragment,null,r.createElement("input",{value:n,disabled:e.readOnly||!e.setValue,type:null!=(t=e.type)?t:"text",onChange:t=>{!e.readOnly&&e.setValue&&i(t.target.value)},onKeyDown:t=>{var n;"Enter"===t.key&&a(),"Escape"!==t.key?t.stopPropagation():null==(n=e.onCancel)||n.call(e)},onBlur:()=>{setTimeout((()=>{a()}),0)},style:u(u(u({},o.controlStyle),e.style),c)}),s));var l}const d=[".png",".jpg",".bmp",".gif"]},3675:(e,t,n)=>{"use strict";n.r(t),n.d(t,{getArrayEditorProps:()=>a,useJsonEditorData:()=>i});var r=n(8662),o=n(3696);function i(e){const[t,n]=o.useState(e);return{value:t,update:e=>o=>{n((0,r.produce)(t,(t=>{e(t,o)})))},getArrayProps:(e,o)=>a(e,o,(e=>{n((0,r.produce)(t,(t=>{e(t)})))}))}}function a(e,t,n){return{add:()=>n((n=>{e(n).push("function"==typeof t?t():t)})),remove:t=>n((n=>{e(n).splice(t,1)})),copy:t=>n((n=>{const r=e(n);r.splice(t,0,r[t])})),moveUp:t=>n((n=>{const r=e(n);r.splice(t-1,0,r[t]),r.splice(t+1,1)})),moveDown:t=>n((n=>{const r=e(n);r.splice(t+2,0,r[t]),r.splice(t,1)}))}}},6176:(e,t,n)=>{"use strict";n.r(t),n.d(t,{codeRenderTarget:()=>o});var r=n(7727);const o={type:"code",renderResult:(e,t,n,r)=>`target.renderResult([\n${e.map((e=>" "+e)).join(",\n")}\n], ${t}, ${n}, ${i(r)})`,renderEmpty:()=>"target.renderEmpty()",renderGroup:(e,t)=>`target.renderGroup([\n${e.map((e=>" "+e)).join(",\n")}\n], ${i(t)})`,renderRect:(e,t,n,r,o)=>`target.renderRect(${e}, ${t}, ${n}, ${r}, ${i(o)})`,renderPolyline:(e,t)=>`target.renderPolyline(${i(e)}, ${i(t)})`,renderPolygon:(e,t)=>`target.renderPolygon(${i(e)}, ${i(t)})`,renderCircle:(e,t,n,r)=>`target.renderCircle(${e}, ${t}, ${n}, ${i(r)})`,renderEllipse:(e,t,n,r,o)=>`target.renderEllipse(${e}, ${t}, ${n}, ${r}, ${i(o)})`,renderArc:(e,t,n,r,o,a)=>`target.renderArc(${e}, ${t}, ${n}, ${r}, ${o}, ${i(a)})`,renderEllipseArc:(e,t,n,r,o,a,s)=>`target.renderEllipseArc(${e}, ${t}, ${n}, ${r}, ${o}, ${a}, ${i(s)})`,renderPathCommands:(e,t)=>`target.renderPathCommands(${i(e)}, ${i(t)})`,renderText:(e,t,n,r,o,a,s)=>`target.renderText(${e}, ${t}, ${i(n)}, ${i(r)}, ${o}, ${i(a)}, ${i(s)})`,renderImage:(e,t,n,r,o,a)=>`target.renderImage(${i(e)}, ${t}, ${n}, ${r}, ${o}, ${i(a)})`,renderPath:(e,t)=>`target.renderPath(${i(e)}, ${i(t)})`,renderRay:(e,t,n,r)=>`target.renderRay(${e}, ${t}, ${n}, ${i(r)})`};function i(e){return(0,r.printJsToCode)(e,{functionPrinter:e=>"() => "+e()})}},3876:(e,t,n)=>{"use strict";n.r(t),n.d(t,{createWebglRenderer:()=>_,defaultVec4Color:()=>R,forEachPatternGraphicRepeatedGraphic:()=>G,getImageGraphic:()=>A,getNumArrayPointsBounding:()=>U,getPathGraphics:()=>T,getTextGraphic:()=>S,getTextureGraphicMatrix:()=>j,getWorldMatrix:()=>V,setCanvasLineDash:()=>B});var r=n(9397),o=n(2087),i=n(7237),a=n(3975),s=n(5147),c=n(2792),l=n(5773),u=n(1796),p=n(2318),d=n(7713),f=n(1715),g=n(7764),h=n(8392),m=n(3793),y=Object.defineProperty,v=Object.defineProperties,x=Object.getOwnPropertyDescriptors,b=Object.getOwnPropertySymbols,C=Object.prototype.hasOwnProperty,E=Object.prototype.propertyIsEnumerable,P=(e,t,n)=>t in e?y(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,w=(e,t)=>{for(var n in t||(t={}))C.call(t,n)&&P(e,n,t[n]);if(b)for(var n of b(t))E.call(t,n)&&P(e,n,t[n]);return e},k=(e,t)=>v(e,x(t));function _(e){const t=e.getContext("webgl",{antialias:!0,stencil:!0,premultipliedAlpha:!1});if(!t)return;t.enable(t.BLEND),t.blendFunc(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA);const n=new g.Lazy((()=>r.createProgramInfo(t,["\n attribute vec2 position;\n uniform mat3 matrix;\n uniform float flipY;\n void main() {\n gl_Position = vec4((matrix * vec3(position, 1)).xy * vec2(1, flipY), 0, 1);\n }\n ","\n precision mediump float;\n uniform vec4 color;\n void main() {\n gl_FragColor = color;\n }"]))),o=new g.Lazy((()=>r.createProgramInfo(t,["\n attribute vec2 position;\n attribute vec2 base;\n uniform mat3 matrix;\n uniform float flipY;\n uniform float scale;\n void main() {\n vec2 p = (position - base) * scale + base;\n gl_Position = vec4((matrix * vec3(p, 1)).xy * vec2(1, flipY), 0, 1);\n }\n ","\n precision mediump float;\n uniform vec4 color;\n void main() {\n gl_FragColor = color;\n }"]))),i=new g.Lazy((()=>r.createProgramInfo(t,["\n attribute vec2 position;\n uniform mat3 matrix;\n varying vec2 texcoord;\n\n void main () {\n gl_Position = vec4((matrix * vec3(position, 1)).xy, 0, 1);\n texcoord = position;\n }\n ","\n precision mediump float;\n\n varying vec2 texcoord;\n uniform sampler2D texture;\n uniform vec4 color;\n\n void main() {\n if (texcoord.x < 0.0 || texcoord.x > 1.0 ||\n texcoord.y < 0.0 || texcoord.y > 1.0) {\n discard;\n }\n vec4 color = texture2D(texture, texcoord) * color;\n if (color.a < 0.1) {\n discard;\n }\n gl_FragColor = color;\n }"]))),c=new g.Lazy((()=>r.createProgramInfo(t,["\n attribute vec2 position;\n uniform mat3 matrix;\n uniform float flipY;\n varying vec2 texcoord;\n\n void main () {\n gl_Position = vec4((matrix * vec3(position, 1)).xy * vec2(1, flipY), 0, 1);\n texcoord = position;\n }\n ","\n precision mediump float;\n\n varying vec2 texcoord;\n uniform sampler2D texture;\n uniform float opacity;\n\n void main() {\n if (texcoord.x < 0.0 || texcoord.x > 1.0 ||\n texcoord.y < 0.0 || texcoord.y > 1.0) {\n discard;\n }\n gl_FragColor = texture2D(texture, texcoord) * vec4(1, 1, 1, opacity);\n }"]))),l=new g.Lazy((()=>r.createProgramInfo(t,["\n attribute vec2 position;\n uniform mat3 matrix;\n uniform float flipY;\n varying vec2 texcoord;\n\n void main () {\n gl_Position = vec4((matrix * vec3(position, 1)).xy * vec2(1, flipY), 0, 1);\n texcoord = position;\n }\n ","\n precision mediump float;\n\n varying vec2 texcoord;\n uniform sampler2D texture;\n uniform float opacity;\n uniform float colorMatrix[20];\n\n void main() {\n if (texcoord.x < 0.0 || texcoord.x > 1.0 ||\n texcoord.y < 0.0 || texcoord.y > 1.0) {\n discard;\n }\n vec4 c = texture2D(texture, texcoord) * vec4(1, 1, 1, opacity);\n\t\t\tgl_FragColor.r = colorMatrix[0] * c.r + colorMatrix[1] * c.g + colorMatrix[2] * c.b + colorMatrix[3] * c.a + colorMatrix[4];\n\t\t\tgl_FragColor.g = colorMatrix[5] * c.r + colorMatrix[6] * c.g + colorMatrix[7] * c.b + colorMatrix[8] * c.a + colorMatrix[9];\n\t\t\tgl_FragColor.b = colorMatrix[10] * c.r + colorMatrix[11] * c.g + colorMatrix[12] * c.b + colorMatrix[13] * c.a + colorMatrix[14];\n\t\t\tgl_FragColor.a = colorMatrix[15] * c.r + colorMatrix[16] * c.g + colorMatrix[17] * c.b + colorMatrix[18] * c.a + colorMatrix[19];\n }"]))),u=new g.Lazy((()=>r.createProgramInfo(t,["\n attribute vec2 position;\n uniform mat3 matrix;\n uniform float flipY;\n varying vec2 texcoord;\n\n void main () {\n gl_Position = vec4((matrix * vec3(position, 1)).xy * vec2(1, flipY), 0, 1);\n texcoord = position;\n }\n ","\n precision mediump float;\n\n varying vec2 texcoord;\n uniform sampler2D texture;\n uniform float opacity;\n uniform vec2 px;\n\n void main() {\n if (texcoord.x < 0.0 || texcoord.x > 1.0 ||\n texcoord.y < 0.0 || texcoord.y > 1.0) {\n discard;\n }\n\t\t\tgl_FragColor = vec4(0.0);\n\t\t\tgl_FragColor += texture2D(texture, texcoord + vec2(-7.0*px.x, -7.0*px.y))*0.0044299121055113265;\n\t\t\tgl_FragColor += texture2D(texture, texcoord + vec2(-6.0*px.x, -6.0*px.y))*0.00895781211794;\n\t\t\tgl_FragColor += texture2D(texture, texcoord + vec2(-5.0*px.x, -5.0*px.y))*0.0215963866053;\n\t\t\tgl_FragColor += texture2D(texture, texcoord + vec2(-4.0*px.x, -4.0*px.y))*0.0443683338718;\n\t\t\tgl_FragColor += texture2D(texture, texcoord + vec2(-3.0*px.x, -3.0*px.y))*0.0776744219933;\n\t\t\tgl_FragColor += texture2D(texture, texcoord + vec2(-2.0*px.x, -2.0*px.y))*0.115876621105;\n\t\t\tgl_FragColor += texture2D(texture, texcoord + vec2(-1.0*px.x, -1.0*px.y))*0.147308056121;\n\t\t\tgl_FragColor += texture2D(texture, texcoord )*0.159576912161;\n\t\t\tgl_FragColor += texture2D(texture, texcoord + vec2( 1.0*px.x, 1.0*px.y))*0.147308056121;\n\t\t\tgl_FragColor += texture2D(texture, texcoord + vec2( 2.0*px.x, 2.0*px.y))*0.115876621105;\n\t\t\tgl_FragColor += texture2D(texture, texcoord + vec2( 3.0*px.x, 3.0*px.y))*0.0776744219933;\n\t\t\tgl_FragColor += texture2D(texture, texcoord + vec2( 4.0*px.x, 4.0*px.y))*0.0443683338718;\n\t\t\tgl_FragColor += texture2D(texture, texcoord + vec2( 5.0*px.x, 5.0*px.y))*0.0215963866053;\n\t\t\tgl_FragColor += texture2D(texture, texcoord + vec2( 6.0*px.x, 6.0*px.y))*0.00895781211794;\n\t\t\tgl_FragColor += texture2D(texture, texcoord + vec2( 7.0*px.x, 7.0*px.y))*0.0044299121055113265;\n }"]))),p=new g.Lazy((()=>r.createProgramInfo(t,["\n attribute vec2 position;\n uniform mat3 matrix;\n varying vec2 texcoord;\n\n void main () {\n gl_Position = vec4((matrix * vec3(position, 1)).xy, 0, 1);\n texcoord = position;\n }\n ","\n precision mediump float;\n\n varying vec2 texcoord;\n uniform sampler2D texture;\n uniform vec4 color;\n\n void main() {\n if (texcoord.x < 0.0 || texcoord.x > 1.0 ||\n texcoord.y < 0.0 || texcoord.y > 1.0) {\n discard;\n }\n vec4 color2 = texture2D(texture, texcoord);\n vec4 color3 = color2 * color;\n if (color3.a < 0.1) {\n discard;\n }\n gl_FragColor = color2;\n }"]))),f=new g.Lazy((()=>r.createProgramInfo(t,["\n attribute vec2 position;\n attribute vec4 color;\n uniform mat3 matrix;\n uniform float flipY;\n varying vec4 v_color;\n\n void main () {\n gl_Position = vec4((matrix * vec3(position, 1)).xy * vec2(1, flipY), 0, 1);\n v_color = color;\n }\n ","\n precision mediump float;\n\n varying vec4 v_color;\n\n void main() {\n gl_FragColor = v_color;\n }"]))),h=r.primitives.createXYQuadBufferInfo(t),m=new d.WeakmapCache,y=new d.WeakmapCache,v=e=>{const t={};let n;return"color matrix"===e.type?(n=l.instance,t.colorMatrix=e.value):(n=u.instance,t.px=e.value),{programInfo:n,filterUniforms:t}},x=()=>{r.drawObjectList(t,b),b=[]};let b=[];const C=(n,o,i,a,l)=>{let u;if(x(),n.graphics.some((e=>e.pattern))){const a=r.createFramebufferInfo(t,void 0,e.width,e.height);r.bindFramebufferInfo(t,a),G(n,o,i,((e,t)=>{E(e,t,l)})),x(),u=a.attachments[0],t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,t.canvas.width,t.canvas.height)}t.clearStencil(0),t.clear(t.STENCIL_BUFFER_BIT),t.colorMask(!1,!1,!1,!1),t.enable(t.STENCIL_TEST),t.stencilFunc(t.ALWAYS,1,255),t.stencilOp(t.KEEP,t.KEEP,t.REPLACE),r.drawObjectList(t,[a]),t.stencilFunc(t.EQUAL,1,255),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.colorMask(!0,!0,!0,!0),u?r.drawObjectList(t,[{programInfo:c.instance,bufferInfo:h,uniforms:{matrix:s.m3.projection(1,1),opacity:null!=l?l:1,texture:u,flipY:-1}}]):(G(n,o,i,((e,t)=>{E(e,t,l)})),x()),t.disable(t.STENCIL_TEST)},E=(e,l,u,d)=>{var g,E;const P=(0,a.mergeOpacities)(e.opacity,u),_=(0,a.mergeOpacityToColor)(e.color,P);if("texture"===e.type){const{textureMatrix:n,width:o,height:a}=j(l,e);let u=m.get(e.src,(()=>r.createTexture(t,{src:e.src})));if(e.filters&&e.filters.length>1){x();const n=[];for(let o=0;o0){const t=v(e.filters[e.filters.length-1]);d=t.programInfo,f=t.filterUniforms}else d=e.pattern?p.instance:e.color?i.instance:c.instance;const y={programInfo:d,bufferInfo:h,uniforms:k(w({matrix:n,color:_,opacity:null!=(E=e.opacity)?E:1,texture:u},f),{flipY:1})};e.pattern?C(e.pattern,l,{xMin:e.x,yMin:e.y,xMax:e.x+o,yMax:e.y+a},y,P):b.push(y)}else{const i={programInfo:e.colors?f.instance:e.basePoints&&d?o.instance:n.instance,bufferInfo:y.get(e.points,(()=>{const n={position:{numComponents:2,data:e.points}};return e.colors&&(n.color={numComponents:4,data:e.colors}),e.basePoints&&d&&(n.base={numComponents:2,data:e.basePoints}),r.createBufferInfoFromArrays(t,n)})),uniforms:{color:_,matrix:l,flipY:1,scale:d?1/d:void 0},type:"triangles"===e.type?t.TRIANGLES:"line strip"===e.type?t.LINE_STRIP:"lines"===e.type?t.LINES:t.TRIANGLE_STRIP};if(e.pattern){const t=U(e.points);C(e.pattern,l,t,i,P)}else b.push(i)}};return(n,o,i,a,c,l)=>{t.viewport(0,0,t.canvas.width,t.canvas.height),r.resizeCanvasToDisplaySize(e),t.clearColor(...o),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT|t.STENCIL_BUFFER_BIT);const u=V(t.canvas,i,a,c,l);for(const e of n){const t=e.matrix?s.m3.multiply(u,e.matrix):u;E(e,t,void 0,c)}x()}}function S(e,t,n,r,o,i,s){var c;const l=null!=(c=null==s?void 0:s.strokeWidth)?c:0,u=()=>{var e,t;const c=document.createElement("canvas"),u=c.getContext("2d");if(!u)return;const p=`${null!=(e=null==s?void 0:s.fontWeight)?e:"normal"} ${null!=(t=null==s?void 0:s.fontStyle)?t:"normal"} ${o}px ${i}`;u.font=p;const d=u.measureText(n);return u.canvas.width=Math.ceil(d.width)+2,u.canvas.height=o+d.actualBoundingBoxDescent,u.font=p,(void 0!==r||(null==s?void 0:s.fillLinearGradient)||(null==s?void 0:s.fillRadialGradient))&&(u.fillStyle=void 0!==(null==s?void 0:s.strokeColor)&&"number"==typeof r?(0,a.getColorString)(r,s.fillOpacity):"white",u.fillText(n,0,o)),void 0!==(null==s?void 0:s.strokeColor)?(u.strokeStyle=void 0!==r&&"number"==typeof r?(0,a.getColorString)(s.strokeColor,s.strokeOpacity):"white",void 0!==s.strokeWidth&&(u.lineWidth=s.strokeWidth),B(u,s),u.strokeText(n,0,o)):((null==s?void 0:s.strokePattern)||(null==s?void 0:s.strokeLinearGradient)||(null==s?void 0:s.strokeRadialGradient))&&(u.strokeStyle="white",void 0!==s.strokeWidth&&(u.lineWidth=s.strokeWidth-1),B(u,s),u.strokeText(n,0,o-l)),{textMetrics:d,imageData:u.getImageData(0,0,c.width,c.height),canvas:c}},p=(null==s?void 0:s.cacheKey)?L.get(s.cacheKey,n,u):u();if(!p)return;const{imageData:d,textMetrics:f,canvas:g}=p;let h=t-d.height+l+f.actualBoundingBoxDescent;"top"===(null==s?void 0:s.textBaseline)?h+=f.actualBoundingBoxAscent+f.actualBoundingBoxDescent/2:"middle"===(null==s?void 0:s.textBaseline)?h+=(f.actualBoundingBoxAscent-f.actualBoundingBoxDescent)/2:"bottom"===(null==s?void 0:s.textBaseline)&&(h-=f.fontBoundingBoxDescent);let m,y=e;if("right"===(null==s?void 0:s.textAlign)?y-=d.width:"center"===(null==s?void 0:s.textAlign)&&(y-=d.width/2),(null==s?void 0:s.strokePattern)?m=s.strokePattern:(null==s?void 0:s.strokeLinearGradient)?m={graphics:[z(s.strokeLinearGradient,[{x:y,y:h},{x:y+d.width,y:h},{x:y,y:t},{x:y+d.width,y:t}])]}:(null==s?void 0:s.strokeRadialGradient)?m={graphics:[F(s.strokeRadialGradient,[{x:y,y:h},{x:y+d.width,y:h},{x:y,y:t},{x:y+d.width,y:t}])]}:(null==s?void 0:s.fillLinearGradient)?m={graphics:[z(s.fillLinearGradient,[{x:y,y:h},{x:y+d.width,y:h},{x:y,y:t},{x:y+d.width,y:t}])]}:(null==s?void 0:s.fillRadialGradient)&&(m={graphics:[F(s.fillRadialGradient,[{x:y,y:h},{x:y+d.width,y:h},{x:y,y:t},{x:y+d.width,y:t}])]}),m)return{type:"texture",x:y,y:h,src:d,canvas:g,color:R,pattern:m};if(void 0!==r&&"number"!=typeof r)return{type:"texture",x:y,y:h,src:d,canvas:g,color:R,pattern:r};if(void 0===r){if(void 0===(null==s?void 0:s.strokeColor))return;return{type:"texture",x:y,y:h,color:(0,a.colorNumberToVec)(s.strokeColor,s.strokeOpacity),src:d,canvas:g}}return void 0!==(null==s?void 0:s.strokeColor)?{type:"texture",x:y,y:h,src:d,canvas:g}:{type:"texture",x:y,y:h,color:(0,a.colorNumberToVec)(r,null==s?void 0:s.fillOpacity),src:d,canvas:g}}const R=[0,0,0,1];function T(e,t,n){var r,i,s,l,p;const d=null!=(r=null==n?void 0:n.strokeWidth)?r:1,f=!!(null==n?void 0:n.closed)||(null!=(i=null==n?void 0:n.lineCap)?i:m.defaultLineCap),g=null!=(s=null==n?void 0:n.lineJoin)?s:m.defaultLineJoin,h="miter"===g?null!=(l=null==n?void 0:n.miterLimit)?l:m.defaultMiterLimit:g,y=(0,a.colorNumberToVec)(null!=(p=null==n?void 0:n.strokeColor)?p:0,null==n?void 0:n.strokeOpacity),v=[];if(d){if(null==n?void 0:n.dashArray){const t=n.dashArray;e=e.map((e=>(!0===f&&(e=(0,u.polygonToPolyline)(e)),(0,u.dashedPolylineToLines)(e,t,void 0,n.dashOffset)))).flat()}if(t&&(0,c.isSameNumber)(d,1))v.push({type:"lines",points:D.get(e,f,(()=>e.map((e=>O.get(e,f,(()=>{!0===f&&(e=(0,u.polygonToPolyline)(e));const t=[];for(let n=1;n{const t={points:[],base:[]};for(const n of e){const e=M.get(n,d,f,h,(()=>{const e=(0,m.getPolylineTriangles)(n,d,f,h);return{points:(0,m.triangleStripToTriangles)(e.points),base:(0,m.triangleStripToTriangles)(e.base)}}));t.points.push(...e.points),t.base.push(...e.base)}return t}));let o,i=y;(null==n?void 0:n.strokePattern)?(o=n.strokePattern,i=[0,0,0,0]):(null==n?void 0:n.strokeLinearGradient)?(o={graphics:[z(n.strokeLinearGradient,N(r.points))]},i=[0,0,0,0]):(null==n?void 0:n.strokeRadialGradient)&&(o={graphics:[F(n.strokeRadialGradient,N(r.points))]},i=[0,0,0,0]),v.push({type:"triangles",points:r.points,basePoints:t?r.base:void 0,color:i,pattern:o})}}if(void 0!==(null==n?void 0:n.fillColor)||void 0!==(null==n?void 0:n.fillPattern)||void 0!==(null==n?void 0:n.fillLinearGradient)||void 0!==(null==n?void 0:n.fillRadialGradient)){const t=[],r=[];for(let n=0;n[e.x,e.y])).flat());const i=(0,o.default)(t,r),s=[];for(let e=0;e0&&s.filters.forEach((e=>{if("brightness"===e.type)l.push({type:"color matrix",value:[e.value,0,0,0,0,0,e.value,0,0,0,0,0,e.value,0,0,0,0,0,1,0]});else if("contrast"===e.type){const t=.5*(1-e.value);l.push({type:"color matrix",value:[e.value,0,0,0,t,0,e.value,0,0,t,0,0,e.value,0,t,0,0,0,1,0]})}else if("hue-rotate"===e.type){const t=(0,f.angleToRadian)(e.value),n=Math.cos(t),r=Math.sin(t),o=.213,i=.715,a=.072;l.push({type:"color matrix",value:[o+n*(1-o)+r*-o,i+n*-i+r*-i,a+n*-a+r*(1-a),0,0,o+n*-o+.143*r,i+n*(1-i)+.14*r,a+n*-a+-.283*r,0,0,o+n*-o+r*-(1-o),i+n*-i+r*i,a+n*(1-a)+r*a,0,0,0,0,0,1,0]})}else if("saturate"===e.type){const t=2*(e.value-1)/3+1,n=-.5*(t-1);l.push({type:"color matrix",value:[t,n,n,0,0,n,t,n,0,0,n,n,t,0,0,0,0,0,1,0]})}else if("grayscale"===e.type){const t=1-e.value;l.push({type:"color matrix",value:[.2126+.7874*t,.7152-.7152*t,.0722-.0722*t,0,0,.2126-.2126*t,.7152+.2848*t,.0722-.0722*t,0,0,.2126-.2126*t,.7152-.7152*t,.0722+.9278*t,0,0,0,0,0,1,0]})}else if("sepia"===e.type){const t=1-e.value;l.push({type:"color matrix",value:[.393+.607*t,.769-.769*t,.189-.189*t,0,0,.349-.349*t,.686+.314*t,.168-.168*t,0,0,.272-.272*t,.534-.534*t,.131+.869*t,0,0,0,0,0,1,0]})}else if("invert"===e.type){const t=1-2*e.value;l.push({type:"color matrix",value:[t,0,0,0,e.value,0,t,0,0,e.value,0,0,t,0,e.value,0,0,0,1,0]})}else"opacity"===e.type?l.push({type:"color matrix",value:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,e.value,0]}):"blur"===e.type&&l.push({type:"blur",value:[0,3*e.value/7/o]},{type:"blur",value:[3*e.value/7/r,0]})})),{type:"texture",x:t,y:n,width:r,height:o,src:c,opacity:null==s?void 0:s.opacity,filters:l.length>0?l:void 0}}const L=new d.WeakmapMapCache,M=new d.WeakmapMap3Cache,I=new d.WeakmapMap3Cache,O=new d.WeakmapMapCache,D=new d.WeakmapMapCache;function B(e,t){(null==t?void 0:t.dashArray)&&(e.setLineDash(t.dashArray),t.dashOffset&&(e.lineDashOffset=t.dashOffset))}function z(e,t){const{start:n,end:r}=e,o=r.x-n.x,i=r.y-n.y,s=(0,u.twoPointLineToGeneralFormLine)(n,r);if(!s)return{type:"triangle strip",points:[],colors:[]};const p=e.stops.slice(0).sort(((e,t)=>e.offset-t.offset)),d=[];let f=p[0].offset,g=p[p.length-1].offset;t.forEach((e=>{const t=(0,h.getPerpendicularPoint)(e,s),r=(0,u.getPointSideOfLine)(e,s);if((0,c.isZero)(r))d.push(0);else{const n=(0,l.getTwoPointsDistance)(t,e);r>0?d.push(n):r<0&&d.push(-n)}const a=(0,c.isSameNumber)(t.x,n.x)?(t.y-n.y)/i:(t.x-n.x)/o;ag&&(g=a)})),(0,c.isSameNumber)(f,p[0].offset)||p.unshift({offset:f,color:p[0].color}),(0,c.isSameNumber)(g,p[p.length-1].offset)||p.push({offset:g,color:p[p.length-1].color});const m=(0,u.getParallelLinesByDistance)(s,Math.max(...d))[1],y=(0,u.getParallelLinesByDistance)(s,Math.min(...d))[1],v=[],x=[];return p.forEach((e=>{const t={x:n.x+o*e.offset,y:n.y+i*e.offset},r=(0,h.getPerpendicularPoint)(t,m),s=(0,h.getPerpendicularPoint)(t,y),c=(0,a.colorNumberToVec)(e.color,e.opacity);v.push(r.x,r.y,s.x,s.y),x.push(...c,...c)})),{type:"triangle strip",points:v,colors:x}}function F(e,t){let{start:n,end:r,stops:o}=e;if(n.r>r.r){const e=n;n=r,r=e,o=o.map((e=>({offset:1-e.offset,color:e.color})))}const i=r.x-n.x,s=r.y-n.y,c=r.r-n.r,u=o.slice(0).sort(((e,t)=>e.offset-t.offset)).map((e=>{const t={x:n.x+i*e.offset,y:n.y+s*e.offset,r:n.r+c*e.offset};return{color:(0,a.colorNumberToVec)(e.color,e.opacity),points:(0,p.arcToPolyline)((0,p.circleToArc)(t),5)}})),d=Math.max(...t.map((e=>(0,l.getTwoPointsDistance)(e,r))));d>r.r&&u.push({color:u[u.length-1].color,points:(0,p.arcToPolyline)((0,p.circleToArc)({x:r.x,y:r.y,r:d}),5)});const f=[],g=[];if(n.r>0){const e=u[0],t=[],r=[];e.points.forEach((o=>{t.push(o.x,o.y,n.x,n.y),r.push(...e.color,...e.color)})),f.push(t),g.push(r)}for(let e=1;e{const a=n.points[i];r.unshift(e.x,e.y,a.x,a.y),o.unshift(...t.color,...n.color)})),f.push(r),g.push(o)}return{type:"triangle strip",points:(0,m.combineStripTriangles)(f),colors:(0,m.combineStripTriangleColors)(g)}}function N(e){const t=[];for(let n=0;nr&&(r=a),so&&(o=s)}return{xMax:r,xMin:t,yMin:n,yMax:o}}function G(e,t,n,r){var o,i;const{xMin:a,yMin:c,xMax:l,yMax:u}=n,p=null!=(o=e.width)?o:Number.MAX_SAFE_INTEGER,d=null!=(i=e.height)?i:Number.MAX_SAFE_INTEGER,f=Math.floor(a/p),g=Math.floor(l/p),h=Math.floor(c/d),m=Math.floor(u/d);for(let n=f;n<=g;n++)for(let o=h;o<=m;o++){const i=s.m3.multiply(t,s.m3.translation(n*p,o*d));for(const t of e.graphics)r(t,t.matrix?s.m3.multiply(i,t.matrix):i)}}function j(e,t){var n,r;const o=s.m3.multiply(e,s.m3.translation(t.x,t.y)),i=null!=(n=t.width)?n:t.src.width,a=null!=(r=t.height)?r:t.src.height;return{textureMatrix:s.m3.multiply(o,s.m3.scaling(i,a)),width:i,height:a}}function V(e,t,n,r,o){let i=s.m3.projection(e.width,e.height);return i=s.m3.multiply(i,s.m3.translation(t,n)),1!==r&&(i=s.m3.multiply(i,s.m3.translation(e.width/2,e.height/2)),i=s.m3.multiply(i,s.m3.scaling(r,r)),i=s.m3.multiply(i,s.m3.translation(-e.width/2,-e.height/2))),o&&(i=s.m3.multiply(i,s.m3.rotation(-o))),i}},7191:(e,t,n)=>{"use strict";n.r(t),n.d(t,{createUniformsBuffer:()=>p,createWebgpuRenderer:()=>u});var r=n(7764),o=n(3975),i=n(5147),a=n(6300),s=n(7713),c=n(3876),l=(e,t,n)=>new Promise(((r,o)=>{var i=e=>{try{s(n.next(e))}catch(e){o(e)}},a=e=>{try{s(n.throw(e))}catch(e){o(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(i,a);s((n=n.apply(e,t)).next())}));function u(e){return l(this,null,(function*(){if(!navigator.gpu)return;const t=e.getContext("webgpu");if(!t)return;const n=yield navigator.gpu.requestAdapter();if(!n)return;const a=yield n.requestDevice(),l=navigator.gpu.getPreferredCanvasFormat();t.configure({device:a,format:l});const u={color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha"},alpha:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha"}},f=new r.Lazy((()=>a.createShaderModule({code:"struct Uniforms {\n color: vec4f,\n matrix: mat3x3f,\n };\n @group(0) @binding(0) var uniforms: Uniforms;\n \n @vertex\n fn vertex_main(@location(0) position: vec2f) -> @builtin(position) vec4f\n {\n return vec4f((uniforms.matrix * vec3(position, 1)).xy, 0, 1);\n }\n \n @fragment\n fn fragment_main() -> @location(0) vec4f\n {\n return uniforms.color;\n }"}))),g=new r.Lazy((()=>a.createShaderModule({code:"struct Uniforms {\n color: vec4f,\n matrix: mat3x3f,\n scale: f32,\n };\n @group(0) @binding(0) var uniforms: Uniforms;\n \n @vertex\n fn vertex_main(@location(0) position: vec2f, @location(1) base: vec2f) -> @builtin(position) vec4f\n {\n let p = (position - base) * uniforms.scale + base;\n return vec4f((uniforms.matrix * vec3(p, 1)).xy, 0, 1);\n }\n \n @fragment\n fn fragment_main() -> @location(0) vec4f\n {\n return uniforms.color;\n }"}))),h=new r.Lazy((()=>a.createShaderModule({code:"struct Uniforms {\n matrix: mat3x3f,\n color: vec4f,\n };\n @group(0) @binding(0) var uniforms: Uniforms;\n @group(0) @binding(1) var mySampler: sampler;\n @group(0) @binding(2) var myTexture: texture_2d;\n\n struct VertexOutput {\n @builtin(position) position: vec4f,\n @location(0) texcoord: vec2f,\n };\n \n @vertex\n fn vertex_main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput\n {\n var pos = array(\n vec2f(0.0, 0.0),\n vec2f(0.0, 1.0),\n vec2f(1.0, 0.0),\n vec2f(0.0, 1.0),\n vec2f(1.0, 1.0),\n vec2f(1.0, 0.0),\n );\n let xy = pos[vertexIndex];\n var vsOut: VertexOutput;\n vsOut.position = vec4f((uniforms.matrix * vec3(xy, 1)).xy, 0, 1);\n vsOut.texcoord = xy;\n return vsOut;\n }\n \n @fragment\n fn fragment_main(@location(0) texcoord: vec2f) -> @location(0) vec4f\n {\n if (texcoord.x < 0.0 || texcoord.x > 1.0 || texcoord.y < 0.0 || texcoord.y > 1.0) {\n discard;\n }\n var color = textureSample(myTexture, mySampler, texcoord) * uniforms.color;\n if (color.a < 0.1) {\n discard;\n }\n return color;\n }"}))),m=new r.Lazy((()=>a.createShaderModule({code:"struct Uniforms {\n matrix: mat3x3f,\n opacity: f32,\n };\n @group(0) @binding(0) var uniforms: Uniforms;\n @group(0) @binding(1) var mySampler: sampler;\n @group(0) @binding(2) var myTexture: texture_2d;\n\n struct VertexOutput {\n @builtin(position) position: vec4f,\n @location(0) texcoord: vec2f,\n };\n \n @vertex\n fn vertex_main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput\n {\n var pos = array(\n vec2f(0.0, 0.0),\n vec2f(0.0, 1.0),\n vec2f(1.0, 0.0),\n vec2f(0.0, 1.0),\n vec2f(1.0, 1.0),\n vec2f(1.0, 0.0),\n );\n let xy = pos[vertexIndex];\n var vsOut: VertexOutput;\n vsOut.position = vec4f((uniforms.matrix * vec3(xy, 1)).xy, 0, 1);\n vsOut.texcoord = xy;\n return vsOut;\n }\n \n @fragment\n fn fragment_main(@location(0) texcoord: vec2f) -> @location(0) vec4f\n {\n if (texcoord.x < 0.0 || texcoord.x > 1.0 || texcoord.y < 0.0 || texcoord.y > 1.0) {\n discard;\n }\n return textureSample(myTexture, mySampler, texcoord) * vec4f(1, 1, 1, uniforms.opacity);\n }"}))),y=new r.Lazy((()=>a.createShaderModule({code:"struct Uniforms {\n matrix: mat3x3f,\n opacity: f32,\n colorMatrix: array,\n };\n @group(0) @binding(0) var uniforms: Uniforms;\n @group(0) @binding(1) var mySampler: sampler;\n @group(0) @binding(2) var myTexture: texture_2d;\n\n struct VertexOutput {\n @builtin(position) position: vec4f,\n @location(0) texcoord: vec2f,\n };\n \n @vertex\n fn vertex_main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput\n {\n var pos = array(\n vec2f(0.0, 0.0),\n vec2f(0.0, 1.0),\n vec2f(1.0, 0.0),\n vec2f(0.0, 1.0),\n vec2f(1.0, 1.0),\n vec2f(1.0, 0.0),\n );\n let xy = pos[vertexIndex];\n var vsOut: VertexOutput;\n vsOut.position = vec4f((uniforms.matrix * vec3(xy, 1)).xy, 0, 1);\n vsOut.texcoord = xy;\n return vsOut;\n }\n \n @fragment\n fn fragment_main(@location(0) texcoord: vec2f) -> @location(0) vec4f\n {\n if (texcoord.x < 0.0 || texcoord.x > 1.0 || texcoord.y < 0.0 || texcoord.y > 1.0) {\n discard;\n }\n var c = textureSample(myTexture, mySampler, texcoord) * vec4f(1, 1, 1, uniforms.opacity);\n var r = uniforms.colorMatrix[0][0] * c.r + uniforms.colorMatrix[0][1] * c.g + uniforms.colorMatrix[0][2] * c.b + uniforms.colorMatrix[0][3] * c.a + uniforms.colorMatrix[1][0];\n var g = uniforms.colorMatrix[1][1] * c.r + uniforms.colorMatrix[1][2] * c.g + uniforms.colorMatrix[1][3] * c.b + uniforms.colorMatrix[2][0] * c.a + uniforms.colorMatrix[2][1];\n var b = uniforms.colorMatrix[2][2] * c.r + uniforms.colorMatrix[2][3] * c.g + uniforms.colorMatrix[3][0] * c.b + uniforms.colorMatrix[3][1] * c.a + uniforms.colorMatrix[3][2];\n var a = uniforms.colorMatrix[3][3] * c.r + uniforms.colorMatrix[4][0] * c.g + uniforms.colorMatrix[4][1] * c.b + uniforms.colorMatrix[4][2] * c.a + uniforms.colorMatrix[4][3];\n return vec4f(r, g, b, a);\n }"}))),v=new r.Lazy((()=>a.createShaderModule({code:"struct Uniforms {\n matrix: mat3x3f,\n opacity: f32,\n px: vec4f,\n };\n @group(0) @binding(0) var uniforms: Uniforms;\n @group(0) @binding(1) var mySampler: sampler;\n @group(0) @binding(2) var myTexture: texture_2d;\n\n struct VertexOutput {\n @builtin(position) position: vec4f,\n @location(0) texcoord: vec2f,\n };\n \n @vertex\n fn vertex_main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput\n {\n var pos = array(\n vec2f(0.0, 0.0),\n vec2f(0.0, 1.0),\n vec2f(1.0, 0.0),\n vec2f(0.0, 1.0),\n vec2f(1.0, 1.0),\n vec2f(1.0, 0.0),\n );\n let xy = pos[vertexIndex];\n var vsOut: VertexOutput;\n vsOut.position = vec4f((uniforms.matrix * vec3(xy, 1)).xy, 0, 1);\n vsOut.texcoord = xy;\n return vsOut;\n }\n \n @fragment\n fn fragment_main(@location(0) texcoord: vec2f) -> @location(0) vec4f\n {\n if (texcoord.x < 0.0 || texcoord.x > 1.0 || texcoord.y < 0.0 || texcoord.y > 1.0) {\n discard;\n }\n var r = vec4f(0.0);\n r += textureSample(myTexture, mySampler, texcoord + vec2(-7.0*uniforms.px.x, -7.0*uniforms.px.y))*0.0044299121055113265;\n r += textureSample(myTexture, mySampler, texcoord + vec2(-6.0*uniforms.px.x, -6.0*uniforms.px.y))*0.00895781211794;\n r += textureSample(myTexture, mySampler, texcoord + vec2(-5.0*uniforms.px.x, -5.0*uniforms.px.y))*0.0215963866053;\n r += textureSample(myTexture, mySampler, texcoord + vec2(-4.0*uniforms.px.x, -4.0*uniforms.px.y))*0.0443683338718;\n r += textureSample(myTexture, mySampler, texcoord + vec2(-3.0*uniforms.px.x, -3.0*uniforms.px.y))*0.0776744219933;\n r += textureSample(myTexture, mySampler, texcoord + vec2(-2.0*uniforms.px.x, -2.0*uniforms.px.y))*0.115876621105;\n r += textureSample(myTexture, mySampler, texcoord + vec2(-1.0*uniforms.px.x, -1.0*uniforms.px.y))*0.147308056121;\n r += textureSample(myTexture, mySampler, texcoord )*0.159576912161;\n r += textureSample(myTexture, mySampler, texcoord + vec2( 1.0*uniforms.px.x, 1.0*uniforms.px.y))*0.147308056121;\n r += textureSample(myTexture, mySampler, texcoord + vec2( 2.0*uniforms.px.x, 2.0*uniforms.px.y))*0.115876621105;\n r += textureSample(myTexture, mySampler, texcoord + vec2( 3.0*uniforms.px.x, 3.0*uniforms.px.y))*0.0776744219933;\n r += textureSample(myTexture, mySampler, texcoord + vec2( 4.0*uniforms.px.x, 4.0*uniforms.px.y))*0.0443683338718;\n r += textureSample(myTexture, mySampler, texcoord + vec2( 5.0*uniforms.px.x, 5.0*uniforms.px.y))*0.0215963866053;\n r += textureSample(myTexture, mySampler, texcoord + vec2( 6.0*uniforms.px.x, 6.0*uniforms.px.y))*0.00895781211794;\n r += textureSample(myTexture, mySampler, texcoord + vec2( 7.0*uniforms.px.x, 7.0*uniforms.px.y))*0.0044299121055113265;\n return r;\n }"}))),x=new r.Lazy((()=>a.createShaderModule({code:"struct Uniforms {\n matrix: mat3x3f,\n color: vec4f,\n };\n @group(0) @binding(0) var uniforms: Uniforms;\n @group(0) @binding(1) var mySampler: sampler;\n @group(0) @binding(2) var myTexture: texture_2d;\n\n struct VertexOutput {\n @builtin(position) position: vec4f,\n @location(0) texcoord: vec2f,\n };\n \n @vertex\n fn vertex_main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput\n {\n var pos = array(\n vec2f(0.0, 0.0),\n vec2f(0.0, 1.0),\n vec2f(1.0, 0.0),\n vec2f(0.0, 1.0),\n vec2f(1.0, 1.0),\n vec2f(1.0, 0.0),\n );\n let xy = pos[vertexIndex];\n var vsOut: VertexOutput;\n vsOut.position = vec4f((uniforms.matrix * vec3(xy, 1)).xy, 0, 1);\n vsOut.texcoord = xy;\n return vsOut;\n }\n \n @fragment\n fn fragment_main(@location(0) texcoord: vec2f) -> @location(0) vec4f\n {\n if (texcoord.x < 0.0 || texcoord.x > 1.0 || texcoord.y < 0.0 || texcoord.y > 1.0) {\n discard;\n }\n var color = textureSample(myTexture, mySampler, texcoord);\n var color2 = color * uniforms.color;\n if (color2.a < 0.1) {\n discard;\n }\n return color;\n }"}))),b=new r.Lazy((()=>a.createShaderModule({code:"struct Uniforms {\n color: vec4f,\n matrix: mat3x3f,\n };\n @group(0) @binding(0) var uniforms: Uniforms;\n\n struct VertexOutput {\n @builtin(position) position: vec4f,\n @location(0) color: vec4f,\n };\n \n @vertex\n fn vertex_main(@location(0) position: vec2f, @location(1) color: vec4f) -> VertexOutput\n {\n var vsOut: VertexOutput;\n vsOut.position = vec4f((uniforms.matrix * vec3(position, 1)).xy, 0, 1);\n vsOut.color = color;\n return vsOut;\n }\n \n @fragment\n fn fragment_main(@location(0) color: vec4f) -> @location(0) vec4f\n {\n return color;\n }"}))),C=new r.Lazy((()=>a.createSampler({magFilter:"nearest",minFilter:"nearest"}))),E=new r.Lazy((()=>a.createTexture({size:[e.width,e.height],sampleCount:4,format:l,usage:GPUTextureUsage.RENDER_ATTACHMENT})),(e=>e.destroy())),P=new r.Lazy((()=>a.createTexture({format:"stencil8",sampleCount:4,size:[e.width,e.height],usage:GPUTextureUsage.RENDER_ATTACHMENT})),(e=>e.destroy())),w=new s.WeakmapCache,k=new s.WeakmapCache2,_=new s.WeakmapCache2,S=new s.WeakmapMap2Cache,R=new s.WeakmapCache,T=new s.MapCache2,A=e=>"color matrix"===e.type?{shaderModule:y.instance,input:{type:"vec4 array",count:5,value:e.value}}:{shaderModule:v.instance,input:{type:"vec2",value:e.value}},L=(e,t,n,r)=>a.createRenderPipeline({vertex:{module:e,entryPoint:"vertex_main",buffers:r?[r]:void 0},fragment:{module:e,entryPoint:"fragment_main",targets:"mask"===t?[]:[{format:l,blend:u}]},depthStencil:"mask"===t?{format:"stencil8",depthCompare:"always",depthWriteEnabled:!1,stencilFront:{passOp:"replace"}}:"masked"===t?{depthCompare:"always",depthWriteEnabled:!1,format:"stencil8",stencilFront:{compare:"equal"}}:void 0,primitive:n?{topology:"triangles"===n?"triangle-list":"line strip"===n?"line-strip":"lines"===n?"line-list":"triangle-strip"}:void 0,multisample:{count:4},label:t,layout:"auto"}),M=(e,t,n)=>{e.setPipeline(t),e.setBindGroup(0,a.createBindGroup({layout:t.getBindGroupLayout(0),entries:n.map(((e,t)=>({binding:t,resource:e})))}))},I=(e,t,n,r,o="normal")=>{const i=T.get(e,o,(()=>L(e,o)));M(t,i,[{buffer:p(a,n)},C.instance,r.createView()]),t.draw(6)},O=(e,t)=>a.createTexture({size:[e,t],format:l,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT}),D=(e,n=t.getCurrentTexture(),r)=>e.beginRenderPass({colorAttachments:[{clearValue:r,loadOp:r?"clear":"load",storeOp:"store",view:E.instance.createView(),resolveTarget:n.createView()}],label:"normal"}),B=(e,n=t.getCurrentTexture(),r=1)=>{const o=e.beginRenderPass({colorAttachments:[{view:E.instance.createView(),resolveTarget:n.createView(),loadOp:0===r?"clear":"load",storeOp:"store"}],depthStencilAttachment:{view:P.instance.createView(),stencilLoadOp:"load",stencilStoreOp:"store"},label:"masked"});return o.setStencilReference(r),o},z=(t,n,r,o,s,l)=>{let u;if(t.graphics.some((e=>e.pattern))){u=O(e.width,e.height);const o=a.createCommandEncoder();let i=B(o,u,0);(0,c.forEachPatternGraphicRepeatedGraphic)(t,n,r,((e,t)=>{i=F(e,t,i,o,!0,s,u)})),i.end(),a.queue.submit([o.finish()])}let p=B(o);return u?I(m.instance,p,[{type:"mat3x3",value:i.m3.projection(1,1)},{type:"number",value:null!=s?s:1}],u,"masked"):(0,c.forEachPatternGraphicRepeatedGraphic)(t,n,r,((e,t)=>{p=F(e,t,p,o,!0,s,l)})),p.end(),D(o,l)},F=(t,n,r,s,l=!1,u,y,v)=>{var C,E,T;const B=(0,o.mergeOpacities)(t.opacity,u),F=(0,o.mergeOpacityToColor)(t.pattern?c.defaultVec4Color:t.color,B);t.pattern&&(r.end(),r=(e=>{const t=e.beginRenderPass({colorAttachments:[],depthStencilAttachment:{view:P.instance.createView(),stencilClearValue:0,stencilLoadOp:"clear",stencilStoreOp:"store"},label:"mask"});return t.setStencilReference(1),t})(s));const N=t.pattern?"mask":l&&"masked"===r.label?"masked":"normal";if("texture"===t.type){const{textureMatrix:o,width:l,height:u}=(0,c.getTextureGraphicMatrix)(n,t);let p,d=R.get(t.src,(()=>{const e=O(t.src.width,t.src.height),n=t.src instanceof ImageBitmap?t.src:t.canvas;return n&&a.queue.copyExternalImageToTexture({source:n},{texture:e},{width:t.src.width,height:t.src.height}),e}));if(t.filters&&t.filters.length>1){const n=[];for(let r=0;r0){const e=A(t.filters[t.filters.length-1]);p=e.shaderModule,f.push({type:"number",value:null!=(E=t.opacity)?E:1},e.input)}else t.pattern?(p=x.instance,f.push({type:"vec4",value:null!=F?F:c.defaultVec4Color})):t.color?(p=h.instance,f.push({type:"vec4",value:null!=F?F:c.defaultVec4Color})):(p=m.instance,f.push({type:"number",value:null!=(T=t.opacity)?T:1}));I(p,r,f,d,N),t.pattern&&(r.end(),r=z(t.pattern,n,{xMin:t.x,yMin:t.y,xMax:t.x+l,yMax:t.y+u},s,B,y))}else{const e=t.colors?b.instance:t.basePoints&&v?g.instance:f.instance,o=S.get(e,t.type,N,(()=>{const n=t.colors?{attributes:[{shaderLocation:0,offset:0,format:"float32x2"},{shaderLocation:1,offset:8,format:"float32x4"}],arrayStride:24,stepMode:"vertex"}:t.basePoints&&v?{attributes:[{shaderLocation:0,offset:0,format:"float32x2"},{shaderLocation:1,offset:8,format:"float32x2"}],arrayStride:16,stepMode:"vertex"}:{attributes:[{shaderLocation:0,offset:0,format:"float32x2"}],arrayStride:8,stepMode:"vertex"};return L(e,N,t.type,n)})),i=[{type:"vec4",value:F||c.defaultVec4Color},{type:"mat3x3",value:n}];if(t.basePoints&&v&&i.push({type:"number",value:1/v}),M(r,o,[{buffer:p(a,i)}]),t.colors){const e=t.colors;r.setVertexBuffer(0,_.get(t.points,e,(()=>{const n=d([{data:t.points,num:2},{data:e,num:4}]),r=new Float32Array(n),o=a.createBuffer({size:r.byteLength,usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});return a.queue.writeBuffer(o,0,r,0,r.length),o})))}else if(t.basePoints&&v){const e=t.basePoints;r.setVertexBuffer(0,k.get(t.points,e,(()=>{const n=d([{data:t.points,num:2},{data:e,num:2}]),r=new Float32Array(n),o=a.createBuffer({size:r.byteLength,usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});return a.queue.writeBuffer(o,0,r,0,r.length),o})))}else r.setVertexBuffer(0,w.get(t.points,(()=>{const e=new Float32Array(t.points),n=a.createBuffer({size:e.byteLength,usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});return a.queue.writeBuffer(n,0,e,0,e.length),n})));if(r.draw(t.points.length/2),t.pattern){r.end();const e=(0,c.getNumArrayPointsBounding)(t.points);r=z(t.pattern,n,e,s,B,y)}}return r};return(t,n,r,o,s,l)=>{!E.instanced||e.width===E.instance.width&&e.height===E.instance.height||E.reset(),!P.instanced||e.width===P.instance.width&&e.height===P.instance.height||P.reset();const u=(0,c.getWorldMatrix)(e,r,o,s,l),p=a.createCommandEncoder();let d=D(p,void 0,n);for(const e of t){const t=e.matrix?i.m3.multiply(u,e.matrix):u;d=F(e,t,d,p,void 0,void 0,void 0,s)}d.end(),a.queue.submit([p.finish()])}}))}function p(e,t){const n=(0,a.createMemoryLayoutArray)(...t),r=e.createBuffer({size:n.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});return e.queue.writeBuffer(r,0,n),r}function d(e){const t=[],n=Math.min(...e.map((e=>e.data.length/e.num)));for(let r=0;r{"use strict";n.r(t),n.d(t,{getImageFromCache:()=>i});var r=n(5481);const o=new Map;function i(e,t){var n;const i=o.get(e);return i?Array.isArray(i)?void i.push((()=>{var e;null==(e=null==t?void 0:t.rerender)||e.call(t)})):(null==(n=null==t?void 0:t.callback)||n.call(t,i),i):(o.set(e,[]),void(0,r.dataUrlToImage)(e,null==t?void 0:t.crossOrigin).then((n=>{createImageBitmap(n).then((n=>{var r,i;const a=o.get(e);o.set(e,n),Array.isArray(a)&&a.forEach((e=>{e()})),null==(r=null==t?void 0:t.callback)||r.call(t,n),null==(i=null==t?void 0:t.rerender)||i.call(t)}))})))}},4840:(e,t,n)=>{"use strict";n.r(t);var r=n(8012),o={};for(const e in r)"default"!==e&&(o[e]=()=>r[e]);n.d(t,o);var i=n(9289);o={};for(const e in i)"default"!==e&&(o[e]=()=>i[e]);n.d(t,o);var a=n(1777);o={};for(const e in a)"default"!==e&&(o[e]=()=>a[e]);n.d(t,o);var s=n(7428);o={};for(const e in s)"default"!==e&&(o[e]=()=>s[e]);n.d(t,o);var c=n(7529);o={};for(const e in c)"default"!==e&&(o[e]=()=>c[e]);n.d(t,o);var l=n(3876);o={};for(const e in l)"default"!==e&&(o[e]=()=>l[e]);n.d(t,o);var u=n(7191);o={};for(const e in u)"default"!==e&&(o[e]=()=>u[e]);n.d(t,o);var p=n(7237);o={};for(const e in p)"default"!==e&&(o[e]=()=>p[e]);n.d(t,o);var d=n(6176);o={};for(const e in d)"default"!==e&&(o[e]=()=>d[e]);n.d(t,o)},1777:(e,t,n)=>{"use strict";n.r(t),n.d(t,{CanvasDrawCanvas:()=>R,reactCanvasRenderTarget:()=>P});var r=n(3696),o=n(5147),i=n(3876),a=n(7237),s=n(8012),c=n(1796),l=n(2298),u=n(3975),p=n(1715),d=n(3793),f=n(5481),g=Object.defineProperty,h=Object.defineProperties,m=Object.getOwnPropertyDescriptors,y=Object.getOwnPropertySymbols,v=Object.prototype.hasOwnProperty,x=Object.prototype.propertyIsEnumerable,b=(e,t,n)=>t in e?g(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,C=(e,t)=>{for(var n in t||(t={}))v.call(t,n)&&b(e,n,t[n]);if(y)for(var n of y(t))x.call(t,n)&&b(e,n,t[n]);return e},E=(e,t)=>h(e,m(t));const P={type:"canvas",renderResult:(e,t,n,o)=>r.createElement(R,{width:t,height:n,attributes:null==o?void 0:o.attributes,draws:e,transform:null==o?void 0:o.transform,backgroundColor:null==o?void 0:o.backgroundColor,debug:null==o?void 0:o.debug,strokeWidthFixed:null==o?void 0:o.strokeWidthFixed}),renderEmpty:()=>()=>{},renderGroup:(e,t)=>(n,r,i,a,s,c,l)=>{const u=n.globalAlpha;if(n.save(),void 0!==(null==t?void 0:t.opacity)&&(n.globalAlpha=u*t.opacity),(null==t?void 0:t.translate)&&n.translate(t.translate.x,t.translate.y),void 0!==(null==t?void 0:t.base)){const e=(0,o.getRotationOptionsAngle)(t,!0);e&&(n.translate(t.base.x,t.base.y),n.rotate(e),n.translate(-t.base.x,-t.base.y));const r=(0,o.getScaleOptionsScale)(t);r&&(n.translate(t.base.x,t.base.y),n.scale(r.x,r.y),n.translate(-t.base.x,-t.base.y))}(null==t?void 0:t.matrix)&&n.setTransform(n.getTransform().multiply(o.m3.getTransformInit(t.matrix)));const p=(0,o.multiplyMatrix)(l,(0,o.getRenderOptionsMatrix)(t));e.forEach((e=>{e(n,r,i,a,s,c,p)})),n.restore()},renderRect:(e,t,n,r,o)=>(a,s,c,l,u,d,f)=>{a.save(),a.beginPath(),(0,i.setCanvasLineDash)(a,o),(null==o?void 0:o.angle)&&(a.translate(e+n/2,t+r/2),a.rotate((0,p.angleToRadian)(o.angle)),a.translate(-(e+n/2),-(t+r/2))),(null==o?void 0:o.rotation)&&(a.translate(e+n/2,t+r/2),a.rotate(o.rotation),a.translate(-(e+n/2),-(t+r/2))),a.rect(e,t,n,r),w(a,s,c,l,u,d,f,o),_(a,s,c,l,u,d,f,o),a.restore()},renderPolyline(e,t){const n=null!=t?t:{},{partsStyles:r}=n,o=((e,t)=>{var n={};for(var r in e)v.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&y)for(var r of y(e))t.indexOf(r)<0&&x.call(e,r)&&(n[r]=e[r]);return n})(n,["partsStyles"]);return r&&r.length>0?(0,s.renderPartStyledPolyline)(this,r,e,o):(n,r,o,a,s,c,l)=>{var u;n.save(),n.beginPath(),(0,i.setCanvasLineDash)(n,t);for(let r=0;r(o,a,s,c,l,u,p)=>{o.save(),o.beginPath(),(0,i.setCanvasLineDash)(o,r),o.arc(e,t,n,0,2*Math.PI),w(o,a,s,c,l,u,p,r),_(o,a,s,c,l,u,p,r),o.restore()},renderEllipse:(e,t,n,r,o)=>(a,s,c,l,u,d,f)=>{var g;a.save(),a.beginPath(),(0,i.setCanvasLineDash)(a,o);const h=null!=(g=null==o?void 0:o.rotation)?g:(0,p.angleToRadian)(null==o?void 0:o.angle);a.ellipse(e,t,n,r,h,0,2*Math.PI),w(a,s,c,l,u,d,f,o),_(a,s,c,l,u,d,f,o),a.restore()},renderArc:(e,t,n,r,o,a)=>(s,c,l,u,d,f,g)=>{s.save(),s.beginPath(),(0,i.setCanvasLineDash)(s,a),s.arc(e,t,n,(0,p.angleToRadian)(r),(0,p.angleToRadian)(o),null==a?void 0:a.counterclockwise),(null==a?void 0:a.closed)&&s.closePath(),w(s,c,l,u,d,f,g,a),_(s,c,l,u,d,f,g,a),s.restore()},renderEllipseArc:(e,t,n,r,o,a,s)=>(c,l,u,d,f,g,h)=>{var m;c.save(),c.beginPath(),(0,i.setCanvasLineDash)(c,s);const y=null!=(m=null==s?void 0:s.rotation)?m:(0,p.angleToRadian)(null==s?void 0:s.angle);c.ellipse(e,t,n,r,y,(0,p.angleToRadian)(o),(0,p.angleToRadian)(a),null==s?void 0:s.counterclockwise),(null==s?void 0:s.closed)&&c.closePath(),w(c,l,u,d,f,g,h,s),_(c,l,u,d,f,g,h,s),c.restore()},renderPathCommands:(e,t)=>(n,r,o,a,s,c,u)=>{let d;n.save(),n.beginPath(),(0,i.setCanvasLineDash)(n,t);for(const t of e){if("move"===t.type)n.moveTo(t.to.x,t.to.y);else if("line"===t.type)n.lineTo(t.to.x,t.to.y);else if("arc"===t.type)n.arcTo(t.from.x,t.from.y,t.to.x,t.to.y,t.radius);else if("ellipseArc"===t.type){if(d){const e=(0,l.getEllipseArcByStartEnd)(d,t.rx,t.ry,t.angle,t.largeArc,t.sweep,t.to);e&&n.ellipse(e.cx,e.cy,e.rx,e.ry,(0,p.angleToRadian)(e.angle),(0,p.angleToRadian)(e.startAngle),(0,p.angleToRadian)(e.endAngle),e.counterclockwise)}}else"bezierCurve"===t.type?n.bezierCurveTo(t.cp1.x,t.cp1.y,t.cp2.x,t.cp2.y,t.to.x,t.to.y):"quadraticCurve"===t.type?n.quadraticCurveTo(t.cp.x,t.cp.y,t.to.x,t.to.y):"close"===t.type&&n.closePath();"close"!==t.type&&(d=t.to)}(null==t?void 0:t.closed)&&n.closePath(),w(n,r,o,a,s,c,u,t),_(n,r,o,a,s,c,u,t),n.restore()},renderText:(e,t,n,r,o,a,s)=>(c,l,p,d,f,g,h)=>{var m,y,v,x;c.save(),c.font=`${null!=(m=null==s?void 0:s.fontWeight)?m:"normal"} ${null!=(y=null==s?void 0:s.fontStyle)?y:"normal"} ${o}px ${a}`,c.textAlign=null!=(v=null==s?void 0:s.textAlign)?v:"left",c.textBaseline=null!=(x=null==s?void 0:s.textBaseline)?x:"alphabetic",_(c,l,p,d,f,g,h,E(C({},s),{fillColor:"number"==typeof r?r:void 0,fillPattern:void 0!==r&&"number"!=typeof r?r:void 0}),(()=>c.fillText(n,e,t))),(void 0!==(null==s?void 0:s.strokeColor)||(null==s?void 0:s.strokePattern)||(null==s?void 0:s.strokeLinearGradient)||(null==s?void 0:s.strokeRadialGradient))&&(void 0!==(null==s?void 0:s.strokeColor)?c.strokeStyle=(0,u.getColorString)(s.strokeColor,s.strokeOpacity):S(c,l,p,d,f,g,h,s),void 0!==s.strokeWidth&&(c.lineWidth=s.strokeWidth),(0,i.setCanvasLineDash)(c,s),c.strokeText(n,e,t)),c.restore()},renderImage:(e,t,n,r,o,i)=>(s,c,l)=>{const u=(0,a.getImageFromCache)(e,{rerender:l,crossOrigin:null==i?void 0:i.crossOrigin});if(u){const e=s.globalAlpha;s.save(),void 0!==(null==i?void 0:i.opacity)&&(s.globalAlpha=e*i.opacity),function(e,t){if(t&&t.length>0){const n=[];t.forEach((e=>{"hue-rotate"===e.type?n.push(`hue-rotate(${e.value}deg)`):"blur"===e.type?n.push(`blur(${e.value}px)`):"brightness"!==e.type&&"contrast"!==e.type&&"saturate"!==e.type&&"grayscale"!==e.type&&"invert"!==e.type&&"opacity"!==e.type&&"sepia"!==e.type||n.push(`${e.type}(${e.value})`)})),e.filter=n.join(" ")}}(s,null==i?void 0:i.filters),s.drawImage(u,t,n,r,o),s.restore()}},renderPath:(e,t)=>(n,r,o,a,s,c,l)=>{n.save(),n.beginPath(),(0,i.setCanvasLineDash)(n,t);for(const t of e)for(let e=0;e{const d=(0,c.getRayTransformedLineSegment)({x:e,y:t,angle:n,bidirectional:null==r?void 0:r.bidirectional},s,l,u,p);d&&this.renderPath([d],r)(o,i,a,s,l,u,p)}}};function w(e,t,n,r,o,i,a,s){var c,l,p,f,g;const h=(null!=(c=null==s?void 0:s.strokeWidth)?c:1)/t;h&&(e.lineWidth=h,e.strokeStyle=(0,u.getColorString)(null!=(l=null==s?void 0:s.strokeColor)?l:0,null==s?void 0:s.strokeOpacity),e.miterLimit=null!=(p=null==s?void 0:s.miterLimit)?p:d.defaultMiterLimit,e.lineJoin=null!=(f=null==s?void 0:s.lineJoin)?f:d.defaultLineJoin,e.lineCap=null!=(g=null==s?void 0:s.lineCap)?g:d.defaultLineCap,S(e,t,n,r,o,i,a,s),e.stroke())}function k(e,t,n,r,o,i,a,s){const c=(0,f.createCanvasContext)(t);if(c){t.pattern()(c,n,r,o,i,a,s);const l=e.createPattern(c.canvas,null);if(l)return l}}function _(e,t,n,r,o,i,a,s,c){if(void 0!==(null==s?void 0:s.clip)&&(e.clip("evenodd"),s.clip()(e,t,n,r,o,i,a)),void 0!==(null==s?void 0:s.fillColor)||void 0!==(null==s?void 0:s.fillPattern)||void 0!==(null==s?void 0:s.fillLinearGradient)||void 0!==(null==s?void 0:s.fillRadialGradient)){if(void 0!==s.fillPattern){const c=k(e,s.fillPattern,t,n,r,o,i,a);c&&(e.fillStyle=c)}else if(void 0!==s.fillColor)e.fillStyle=(0,u.getColorString)(s.fillColor,s.fillOpacity);else if(void 0!==s.fillLinearGradient){const{start:t,end:n,stops:r}=s.fillLinearGradient,o=e.createLinearGradient(t.x,t.y,n.x,n.y);r.forEach((e=>{o.addColorStop(e.offset,(0,u.getColorString)(e.color,e.opacity))})),e.fillStyle=o}else if(void 0!==s.fillRadialGradient){const{start:t,end:n,stops:r}=s.fillRadialGradient,o=e.createRadialGradient(t.x,t.y,t.r,n.x,n.y,n.r);r.forEach((e=>{o.addColorStop(e.offset,(0,u.getColorString)(e.color,e.opacity))})),e.fillStyle=o}c?c():e.fill("evenodd")}}function S(e,t,n,r,o,i,a,s){if(null==s?void 0:s.strokePattern){const c=k(e,s.strokePattern,t,n,r,o,i,a);c&&(e.strokeStyle=c)}else if(void 0!==(null==s?void 0:s.strokeLinearGradient)){const{start:t,end:n,stops:r}=s.strokeLinearGradient,o=e.createLinearGradient(t.x,t.y,n.x,n.y);r.forEach((e=>{o.addColorStop(e.offset,(0,u.getColorString)(e.color,e.opacity))})),e.strokeStyle=o}else if(void 0!==(null==s?void 0:s.strokeRadialGradient)){const{start:t,end:n,stops:r}=s.strokeRadialGradient,o=e.createRadialGradient(t.x,t.y,t.r,n.x,n.y,n.r);r.forEach((e=>{o.addColorStop(e.offset,(0,u.getColorString)(e.color,e.opacity))})),e.strokeStyle=o}}function R(e){const t=r.useRef(null),[n,o]=r.useState(0);return r.useEffect((()=>{t.current&&(t.current.width=e.width,t.current.height=e.height)}),[e.width,e.height]),r.useEffect((()=>{var n,r,i;if(t.current){const a=t.current.getContext("2d");if(a){const t=Date.now();a.fillStyle=(0,u.getColorString)(null!=(n=e.backgroundColor)?n:16777215),a.fillRect(0,0,a.canvas.width,a.canvas.height),a.save(),e.transform&&(a.translate(e.width/2,e.height/2),a.scale(e.transform.scale,e.transform.scale),a.translate(e.transform.x/e.transform.scale-e.width/2,e.transform.y/e.transform.scale-e.height/2),e.transform.rotate&&a.rotate(e.transform.rotate));const s=()=>o((e=>e+1)),c=e.strokeWidthFixed&&(null==(r=e.transform)?void 0:r.scale)?e.transform.scale:1;for(const t of e.draws)t(a,c,s,e.width,e.height,e.transform);a.restore(),e.debug&&console.info(Date.now()-t),null==(i=e.onRender)||i.call(e)}}}),[e.draws,t.current,e.transform,e.backgroundColor,n,e.width,e.height,e.onRender]),r.createElement("canvas",C({ref:t,width:e.width,height:e.height},e.attributes))}},8012:(e,t,n)=>{"use strict";n.r(t),n.d(t,{renderPartStyledPolyline:()=>d});var r=Object.defineProperty,o=Object.defineProperties,i=Object.getOwnPropertyDescriptors,a=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,c=Object.prototype.propertyIsEnumerable,l=(e,t,n)=>t in e?r(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,u=(e,t)=>{for(var n in t||(t={}))s.call(t,n)&&l(e,n,t[n]);if(a)for(var n of a(t))c.call(t,n)&&l(e,n,t[n]);return e},p=(e,t)=>o(e,i(t));function d(e,t,n,r){return e.renderGroup([e.renderPolyline(n,p(u({},r),{skippedLines:t.map((e=>e.index))})),...t.map((({index:t,color:o,opacity:i})=>e.renderPolyline([n[t],n[t+1]],p(u({},r),{strokeColor:o,strokeOpacity:i}))))])}},9289:(e,t,n)=>{"use strict";n.r(t),n.d(t,{ellipsePolarToCartesian:()=>L,getRotateTransform:()=>I,getScaleTransform:()=>M,polarToCartesian:()=>A,reactSvgRenderTarget:()=>w});var r=n(3696),o=n(3975),i=n(2792),a=n(8831),s=n(1796),c=n(5147),l=n(7713),u=n(8012),p=n(1715),d=n(491),f=n(8392),g=n(3793),h=Object.defineProperty,m=Object.defineProperties,y=Object.getOwnPropertyDescriptors,v=Object.getOwnPropertySymbols,x=Object.prototype.hasOwnProperty,b=Object.prototype.propertyIsEnumerable,C=(e,t,n)=>t in e?h(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,E=(e,t)=>{for(var n in t||(t={}))x.call(t,n)&&C(e,n,t[n]);if(v)for(var n of v(t))b.call(t,n)&&C(e,n,t[n]);return e},P=(e,t)=>m(e,y(t));const w={type:"svg",renderResult(e,t,n,i){var a,s,c,l,u,p,d,f,g,h;const m=null!=(s=null==(a=null==i?void 0:i.transform)?void 0:a.x)?s:0,y=null!=(l=null==(c=null==i?void 0:i.transform)?void 0:c.y)?l:0,v=null!=(p=null==(u=null==i?void 0:i.transform)?void 0:u.scale)?p:1,x=t/v,b=n/v,C=(t-x)/2-m/v,w=(n-b)/2-y/v,k=null!=(d=null==i?void 0:i.strokeWidthFixed)&&d,_=null!=(g=null==(f=null==i?void 0:i.transform)?void 0:f.rotate)?g:0;return r.createElement("svg",P(E({version:"1.1",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",viewBox:`${C} ${w} ${x} ${b}`,width:t,height:n,colorInterpolationFilters:"sRGB"},null==i?void 0:i.attributes),{style:P(E({},null==(h=null==i?void 0:i.attributes)?void 0:h.style),{backgroundColor:void 0!==(null==i?void 0:i.backgroundColor)?(0,o.getColorString)(i.backgroundColor):void 0})}),r.createElement("g",{style:{rotate:`${_}rad`}},e.map(((e,r)=>e(r,v,k,t,n,null==i?void 0:i.transform)))))},renderEmpty:()=>()=>r.createElement(r.Fragment,null),renderGroup(e,t){const n=[];if((null==t?void 0:t.translate)&&n.push(`translate(${t.translate.x}, ${t.translate.y})`),null==t?void 0:t.base){const e=I(t.base.x,t.base.y,t);e&&n.push(e);const r=M(t.base.x,t.base.y,t);r&&n.push(r)}return(null==t?void 0:t.matrix)&&n.push(`matrix(${c.m3.getTransform(t.matrix).join(" ")})`),(o,i,a,s,l,u,p)=>{const d=(0,c.multiplyMatrix)(p,(0,c.getRenderOptionsMatrix)(t));return r.createElement("g",{transform:n.join(" "),key:o,opacity:null==t?void 0:t.opacity},e.map(((e,t)=>e(t,i,a,s,l,u,d))))}},renderRect:(e,t,n,o,i)=>k(((a,s,c,l)=>r.createElement("rect",P(E({x:e,y:t,width:n,height:o},R(c,l,i)),{fill:a,stroke:s,transform:I(e+n/2,t+o/2,i)}))),i),renderPolyline(e,t){const n=null!=t?t:{},{partsStyles:o}=n,i=((e,t)=>{var n={};for(var r in e)x.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&v)for(var r of v(e))t.indexOf(r)<0&&b.call(e,r)&&(n[r]=e[r]);return n})(n,["partsStyles"]);if(o&&o.length>0)return(0,u.renderPartStyledPolyline)(this,o,e,i);const a=null==t?void 0:t.skippedLines;if(a&&a.length>0){const n=e.map(((e,t)=>0===t||a.includes(t-1)?`M ${e.x} ${e.y}`:`L ${e.x} ${e.y}`)).join(" ");return k(((e,o,i,a)=>r.createElement("path",P(E({d:n},R(i,a,t)),{fill:e,stroke:o}))),t)}const s=e.map((e=>`${e.x},${e.y}`)).join(" ");return k(((e,n,o,i)=>r.createElement((null==t?void 0:t.closed)?"polygon":"polyline",P(E({points:s},R(o,i,t)),{fill:e,stroke:n}))),t)},renderPolygon(e,t){return this.renderPolyline(e,P(E({},t),{closed:!0}))},renderCircle:(e,t,n,o)=>k(((i,a,s,c)=>r.createElement("circle",P(E({cx:e,cy:t,r:n},R(s,c,o)),{fill:i,stroke:a}))),o),renderEllipse:(e,t,n,o,i)=>k(((a,s,c,l)=>r.createElement("ellipse",P(E({cx:e,cy:t,rx:n,ry:o},R(c,l,i)),{fill:a,stroke:s,transform:I(e,t,i)}))),i),renderArc(e,t,n,o,s,c){if(null==c?void 0:c.counterclockwise){if((0,i.largerOrEqual)(o-s,360))return this.renderCircle(e,t,n,c)}else if((0,i.largerOrEqual)(s-o,360))return this.renderCircle(e,t,n,c);const l=A(e,t,n,s),u=A(e,t,n,o),p=(0,a.getLargeArc)({startAngle:o,endAngle:s,counterclockwise:null==c?void 0:c.counterclockwise})?"1":"0",d=(null==c?void 0:c.counterclockwise)?"1":"0";return k(((e,t,o,i)=>r.createElement("path",P(E({d:`M ${l.x} ${l.y} A ${n} ${n} 0 ${p} ${d} ${u.x} ${u.y}${(null==c?void 0:c.closed)?" Z":""}`},R(o,i,c)),{fill:e,stroke:t}))),c)},renderEllipseArc(e,t,n,o,s,c,l){if(null==l?void 0:l.counterclockwise){if((0,i.largerOrEqual)(s-c,360))return this.renderEllipse(e,t,n,o,l)}else if((0,i.largerOrEqual)(c-s,360))return this.renderEllipse(e,t,n,o,l);const u=L(e,t,n,o,c),p=L(e,t,n,o,s),d=(0,a.getLargeArc)({startAngle:s,endAngle:c,counterclockwise:null==l?void 0:l.counterclockwise})?"1":"0",f=(null==l?void 0:l.counterclockwise)?"1":"0";return k(((i,a,s,c)=>r.createElement("path",P(E({d:`M ${u.x} ${u.y} A ${n} ${o} 0 ${d} ${f} ${p.x} ${p.y}${(null==l?void 0:l.closed)?" Z":""}`},R(s,c,l)),{fill:i,stroke:a,transform:I(e,t,l)}))),l)},renderPathCommands(e,t){let n,o="";for(const t of e)if("move"===t.type)o+=` M ${t.to.x} ${t.to.y}`,n=t.to;else if("line"===t.type)o+=` L ${t.to.x} ${t.to.y}`,n=t.to;else if("arc"===t.type){if(n){const e=t.from,r=t.to,a=(0,s.twoPointLineToGeneralFormLine)(n,e),c=(0,s.twoPointLineToGeneralFormLine)(e,r),l=a?(0,s.getPointSideOfLine)(r,a):0;if(!(0,i.isZero)(l)&&a&&c){const e=l<0?0:1,r=(0,d.getTwoGeneralFormLinesIntersectionPoint)((0,s.getParallelLinesByDistance)(a,t.radius)[e],(0,s.getParallelLinesByDistance)(c,t.radius)[e]);if(r){const e=(0,f.getPerpendicularPoint)(r,a),i=(0,f.getPerpendicularPoint)(r,c);o+=` L ${e.x} ${e.y} A ${t.radius} ${t.radius} 0 0 ${l<0?1:0} ${i.x} ${i.y}`,n=i}}else o+=` L ${r.x} ${r.y}`,n=r}}else"ellipseArc"===t.type?(o+=` A ${t.rx} ${t.ry} ${t.angle} ${t.largeArc?1:0} ${t.sweep?1:0} ${t.to.x} ${t.to.y}`,n=t.to):"bezierCurve"===t.type?(o+=` C ${t.cp1.x} ${t.cp1.y}, ${t.cp2.x} ${t.cp2.y}, ${t.to.x} ${t.to.y}`,n=t.to):"quadraticCurve"===t.type?(o+=` Q ${t.cp.x} ${t.cp.y}, ${t.to.x} ${t.to.y}`,n=t.to):"close"===t.type&&(o+=" Z");return(null==t?void 0:t.closed)&&(o+=" Z"),k(((e,n,i,a)=>r.createElement("path",P(E({d:o},R(i,a,t)),{fill:e,stroke:n}))),t)},renderText:(e,t,n,o,i,a,s)=>k(((o,c,l,u)=>{var p;return r.createElement("text",{x:e,y:t,textAnchor:"center"===(null==s?void 0:s.textAlign)?"middle":"right"===(null==s?void 0:s.textAlign)?"end":"start",alignmentBaseline:"top"===(null==s?void 0:s.textBaseline)?"before-edge":"bottom"===(null==s?void 0:s.textBaseline)?"after-edge":null!=(p=null==s?void 0:s.textBaseline)?p:"alphabetic",style:{fill:o,fontWeight:null==s?void 0:s.fontWeight,fontSize:`${i}px`,fontStyle:null==s?void 0:s.fontStyle,fontFamily:a,strokeWidth:null==s?void 0:s.strokeWidth,stroke:c,strokeDasharray:T(l,u,s),strokeDashoffset:null==s?void 0:s.dashOffset,fillOpacity:null==s?void 0:s.fillOpacity,strokeOpacity:null==s?void 0:s.strokeOpacity}},n)}),P(E({},s),{fillColor:"number"==typeof o?o:void 0,fillPattern:void 0!==o&&"number"!=typeof o?o:void 0}),!0),renderImage(e,t,n,o,i,a){return s=s=>r.createElement("image",{filter:s,href:e,x:t,y:n,width:o,height:i,preserveAspectRatio:"none",crossOrigin:null==a?void 0:a.crossOrigin,opacity:null==a?void 0:a.opacity}),c=null==a?void 0:a.filters,e=>{let t,n;if(c&&c.length>0){const e=S(c),o=[];c.forEach(((e,t)=>{if("brightness"===e.type)o.push(r.createElement("feComponentTransfer",{key:t},r.createElement("feFuncR",{type:"linear",slope:e.value}),r.createElement("feFuncG",{type:"linear",slope:e.value}),r.createElement("feFuncB",{type:"linear",slope:e.value})));else if("contrast"===e.type){const n=.5*(1-e.value);o.push(r.createElement("feComponentTransfer",{key:t},r.createElement("feFuncR",{type:"linear",slope:e.value,intercept:n}),r.createElement("feFuncG",{type:"linear",slope:e.value,intercept:n}),r.createElement("feFuncB",{type:"linear",slope:e.value,intercept:n})))}else if("hue-rotate"===e.type)o.push(r.createElement("feColorMatrix",{key:t,type:"hueRotate",values:e.value.toString()}));else if("saturate"===e.type)o.push(r.createElement("feColorMatrix",{key:t,type:"saturate",values:e.value.toString()}));else if("grayscale"===e.type){const n=1-e.value;o.push(r.createElement("feColorMatrix",{key:t,type:"matrix",values:`\n ${.2126+.7874*n} ${.7152-.7152*n} ${.0722-.0722*n} 0 0\n ${.2126-.2126*n} ${.7152+.2848*n} ${.0722-.0722*n} 0 0\n ${.2126-.2126*n} ${.7152-.7152*n} ${.0722+.9278*n} 0 0\n 0 0 0 1 0`}))}else if("invert"===e.type){const n=`${e.value} ${1-e.value}`;o.push(r.createElement("feComponentTransfer",{key:t},r.createElement("feFuncR",{type:"table",tableValues:n}),r.createElement("feFuncG",{type:"table",tableValues:n}),r.createElement("feFuncB",{type:"table",tableValues:n})))}else if("sepia"===e.type){const n=1-e.value;o.push(r.createElement("feColorMatrix",{key:t,type:"matrix",values:`\n ${.393+.607*n} ${.769-.769*n} ${.189-.189*n} 0 0\n ${.349-.349*n} ${.686+.314*n} ${.168-.168*n} 0 0\n ${.272-.272*n} ${.534-.534*n} ${.131+.869*n} 0 0\n 0 0 0 1 0`}))}else"opacity"===e.type?o.push(r.createElement("feComponentTransfer",{key:t},r.createElement("feFuncA",{type:"table",tableValues:`0 ${e.value}`}))):"blur"===e.type&&o.push(r.createElement("feGaussianBlur",{key:t,in:"SourceGraphic",stdDeviation:e.value}))})),t=r.createElement("filter",{id:e},o),n=`url(#${e})`}return r.createElement(r.Fragment,{key:e},t,s(n))};var s,c},renderPath(e,t){const n=e.map((e=>e.map(((e,t)=>0===t?`M ${e.x} ${e.y}`:`L ${e.x} ${e.y}`)).join(" "))),o=(null==t?void 0:t.clip)&&n.length>1,i=o?n.slice(1).map(((e,t)=>r.createElement("path",{key:t,d:e,fill:"black"}))):void 0;return k(((e,i,a,s)=>{let c;return o?c=n[0]:(c=n.join(" "),(null==t?void 0:t.closed)&&(c+=" Z")),r.createElement("path",P(E({d:c},R(a,s,t)),{fill:e,stroke:i,fillRule:"evenodd"}))}),t,void 0,i)},renderRay:(e,t,n,o)=>k(((i,a,c,l,u,p,d,f)=>{const g=(0,s.getRayTransformedLineSegment)({x:e,y:t,angle:n,bidirectional:null==o?void 0:o.bidirectional},u,p,d,f);return g?r.createElement("line",P(E({x1:g[0].x,y1:g[0].y,x2:g[1].x,y2:g[1].y},R(c,l,o)),{fill:i,stroke:a})):r.createElement(r.Fragment,null)}),o)};function k(e,t,n,i){return(a,s,c,l,u,p,d)=>{let f,g,h,m=void 0!==(null==t?void 0:t.fillColor)?(0,o.getColorString)(t.fillColor):"none",y=void 0!==(null==t?void 0:t.strokeColor)?(0,o.getColorString)(t.strokeColor):n?void 0:(0,o.getColorString)(0);if(null==t?void 0:t.strokePattern){const e=S(t.strokePattern);g=r.createElement("pattern",{id:e,patternUnits:"userSpaceOnUse",patternTransform:O(t),width:t.strokePattern.width,height:t.strokePattern.height},t.strokePattern.pattern()(e,s,!1,l,u,p,d)),y=`url(#${e})`}else if(null==t?void 0:t.strokeLinearGradient){const e=S(t.strokeLinearGradient);g=r.createElement("linearGradient",{id:e,gradientUnits:"userSpaceOnUse",x1:t.strokeLinearGradient.start.x,y1:t.strokeLinearGradient.start.y,x2:t.strokeLinearGradient.end.x,y2:t.strokeLinearGradient.end.y},t.strokeLinearGradient.stops.map((e=>r.createElement("stop",{key:e.offset,offset:e.offset,stopColor:(0,o.getColorString)(e.color,e.opacity)})))),y=`url(#${e})`}else if(null==t?void 0:t.strokeRadialGradient){const e=S(t.strokeRadialGradient);g=r.createElement("radialGradient",{id:e,gradientUnits:"userSpaceOnUse",fx:t.strokeRadialGradient.start.x,fy:t.strokeRadialGradient.start.y,fr:t.strokeRadialGradient.start.r,cx:t.strokeRadialGradient.end.x,cy:t.strokeRadialGradient.end.y,r:t.strokeRadialGradient.end.r},t.strokeRadialGradient.stops.map((e=>r.createElement("stop",{key:e.offset,offset:e.offset,stopColor:(0,o.getColorString)(e.color,e.opacity)})))),y=`url(#${e})`}if(null==t?void 0:t.fillPattern){const e=S(t.fillPattern);f=r.createElement("pattern",{id:e,patternUnits:"userSpaceOnUse",patternTransform:O(t),width:t.fillPattern.width,height:t.fillPattern.height},t.fillPattern.pattern()(e,s,!1,l,u,p,d)),m=`url(#${e})`}else if(null==t?void 0:t.fillLinearGradient){const e=S(t.fillLinearGradient);f=r.createElement("linearGradient",{id:e,gradientUnits:"userSpaceOnUse",x1:t.fillLinearGradient.start.x,y1:t.fillLinearGradient.start.y,x2:t.fillLinearGradient.end.x,y2:t.fillLinearGradient.end.y},t.fillLinearGradient.stops.map((e=>r.createElement("stop",{key:e.offset,offset:e.offset,stopColor:(0,o.getColorString)(e.color,e.opacity)})))),m=`url(#${e})`}else if(null==t?void 0:t.fillRadialGradient){const e=S(t.fillRadialGradient);f=r.createElement("radialGradient",{id:e,gradientUnits:"userSpaceOnUse",fx:t.fillRadialGradient.start.x,fy:t.fillRadialGradient.start.y,fr:t.fillRadialGradient.start.r,cx:t.fillRadialGradient.end.x,cy:t.fillRadialGradient.end.y,r:t.fillRadialGradient.end.r},t.fillRadialGradient.stops.map((e=>r.createElement("stop",{key:e.offset,offset:e.offset,stopColor:(0,o.getColorString)(e.color,e.opacity)})))),m=`url(#${e})`}const v=e(m,y,s,c,l,u,p,d);if(null==t?void 0:t.clip){const n=S(t.clip),o=t.clip()(n,s,c,l,u,p,d);i?(f=r.createElement(r.Fragment,null,r.createElement("mask",{id:n},e("white",y,s,c,l,u,p,d),i),v),h=r.createElement("g",{mask:`url(#${n})`},o)):(f=r.createElement(r.Fragment,null,r.createElement("clipPath",{id:n},v),v),h=r.createElement("g",{clipPath:`url(#${n})`},o))}else h=v;return r.createElement(r.Fragment,{key:a},f,g,h)}}const _=new l.WeakmapCache;function S(e){return _.get(e,(()=>Math.random().toString()))}function R(e,t,n){var r,o,i,a;return{strokeWidth:null!=(r=null==n?void 0:n.strokeWidth)?r:1,vectorEffect:t?"non-scaling-stroke":void 0,strokeDasharray:T(e,t,n),strokeDashoffset:null==n?void 0:n.dashOffset,strokeMiterlimit:null!=(o=null==n?void 0:n.miterLimit)?o:g.defaultMiterLimit,strokeLinejoin:null!=(i=null==n?void 0:n.lineJoin)?i:g.defaultLineJoin,strokeLinecap:null!=(a=null==n?void 0:n.lineCap)?a:g.defaultLineCap,fillOpacity:null==n?void 0:n.fillOpacity,strokeOpacity:null==n?void 0:n.strokeOpacity}}function T(e,t,n){if((null==n?void 0:n.dashArray)&&n.dashArray.length>0)return n.dashArray.map((n=>n*(t?e:1))).join(" ")}function A(e,t,n,r){return L(e,t,n,n,r)}function L(e,t,n,r,o){const i=(0,p.angleToRadian)(o);return{x:e+n*Math.cos(i),y:t+r*Math.sin(i)}}function M(e,t,n){const r=(0,c.getScaleOptionsScale)(n);if(r)return`translate(${e},${t}) scale(${r.x},${r.y}) translate(${-e},${-t})`}function I(e,t,n){const r=(0,c.getRotationOptionsAngle)(n);if(r)return`rotate(${r},${e},${t})`}function O(e){const t=(0,c.getRotationOptionsAngle)(e);if(t)return`rotate(${-t})`}},7428:(e,t,n)=>{"use strict";n.r(t),n.d(t,{reactWebglRenderTarget:()=>k});var r=n(3696),o=n(5773),i=n(1796),a=n(2318),s=n(2298),c=n(8012),l=n(1401),u=n(3876),p=n(5147),d=n(3975),f=n(1715),g=n(2792),h=Object.defineProperty,m=Object.defineProperties,y=Object.getOwnPropertyDescriptors,v=Object.getOwnPropertySymbols,x=Object.prototype.hasOwnProperty,b=Object.prototype.propertyIsEnumerable,C=(e,t,n)=>t in e?h(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,E=(e,t)=>{for(var n in t||(t={}))x.call(t,n)&&C(e,n,t[n]);if(v)for(var n of v(t))b.call(t,n)&&C(e,n,t[n]);return e},P=(e,t)=>m(e,y(t)),w=(e,t)=>{var n={};for(var r in e)x.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&v)for(var r of v(e))t.indexOf(r)<0&&b.call(e,r)&&(n[r]=e[r]);return n};const k={type:"webgl",renderResult:(e,t,n,o)=>r.createElement(_,{width:t,height:n,attributes:null==o?void 0:o.attributes,graphics:e,transform:null==o?void 0:o.transform,backgroundColor:null==o?void 0:o.backgroundColor,debug:null==o?void 0:o.debug,strokeWidthFixed:null==o?void 0:o.strokeWidthFixed}),renderEmpty:()=>()=>[],renderGroup:(e,t)=>(n,r,o,i,a,s,c)=>{const l=(0,p.getRenderOptionsMatrix)(t),u=(0,p.multiplyMatrix)(s,l);return c=(0,g.multiplyOpacity)(c,null==t?void 0:t.opacity),e.map((e=>e(n,r,o,i,a,u))).flat().map((e=>P(E({},e),{matrix:(0,p.multiplyMatrix)(l,e.matrix),opacity:(0,g.multiplyOpacity)(c,e.opacity)})))},renderRect(e,t,n,r,i){let a=[{x:e,y:t},{x:e+n,y:t},{x:e+n,y:t+r},{x:e,y:t+r}],s=0;if((null==i?void 0:i.angle)?s=(0,f.angleToRadian)(i.angle):(null==i?void 0:i.rotation)&&(s=i.rotation),s){const i={x:e+n/2,y:t+r/2};a=a.map((e=>(0,o.rotatePosition)(e,i,s)))}return this.renderPolygon(a,i)},renderPolyline(e,t){const n=null!=t?t:{},{partsStyles:r}=n,o=w(n,["partsStyles"]);if(r&&r.length>0)return(0,c.renderPartStyledPolyline)(this,r,e,o);const a=null!=t?t:{},{dashArray:s,closed:l}=a,u=w(a,["dashArray","closed"]);l&&(e=(0,i.polygonToPolyline)(e));const p=(0,i.dashedPolylineToLines)(e,s,null==t?void 0:t.skippedLines,null==t?void 0:t.dashOffset);return this.renderPath(p,u)},renderPolygon(e,t){return this.renderPolyline(e,P(E({},t),{closed:!0}))},renderCircle(e,t,n,r){const o=(0,a.arcToPolyline)((0,a.circleToArc)({x:e,y:t,r:n}),5);return this.renderPolyline(o,r)},renderEllipse(e,t,n,r,o){let i=0;(null==o?void 0:o.angle)?i=o.angle:(null==o?void 0:o.rotation)&&(i=(0,f.radianToAngle)(o.rotation));const a=(0,s.ellipseToPolygon)({cx:e,cy:t,rx:n,ry:r,angle:i},5);return this.renderPolygon(a,o)},renderArc(e,t,n,r,o,i){const s=(0,a.arcToPolyline)({x:e,y:t,r:n,startAngle:r,endAngle:o,counterclockwise:null==i?void 0:i.counterclockwise},5);return this.renderPolyline(s,i)},renderEllipseArc(e,t,n,r,o,i,a){let c=0;(null==a?void 0:a.angle)?c=a.angle:(null==a?void 0:a.rotation)&&(c=(0,f.radianToAngle)(a.rotation));const l=(0,s.ellipseArcToPolyline)({cx:e,cy:t,rx:n,ry:r,startAngle:o,endAngle:i,angle:c,counterclockwise:null==a?void 0:a.counterclockwise},5);return this.renderPolyline(l,a)},renderPathCommands(e,t){const n=(0,l.getPathCommandsPoints)(e),r=(0,l.pathCommandPointsToPath)(n);return this.renderGroup(r.map((e=>this.renderPath(e,t))))},renderText:(e,t,n,r,o,i,a)=>(s,c,l,p,d)=>{let f,g;f=void 0!==r&&"number"!=typeof r?{graphics:r.pattern()(s,c,l,p,d),width:r.width,height:r.height}:r,void 0!==(null==a?void 0:a.strokePattern)&&(g={graphics:a.strokePattern.pattern()(s,c,l,p,d),width:a.strokePattern.width,height:a.strokePattern.height});const h=(0,u.getTextGraphic)(e,t,n,f,o,i,P(E({},a),{strokePattern:g}));return h?[h]:[]},renderImage:(e,t,n,r,o,i)=>(a,s)=>{const c=(0,u.getImageGraphic)(e,t,n,r,o,s,i);return c?[c]:[]},renderPath:(e,t)=>(n,r,o,i,a)=>{let s,c;return void 0!==(null==t?void 0:t.clip)&&(s={graphics:t.clip()(n,r,o,i,a)}),void 0!==(null==t?void 0:t.fillPattern)&&(s={graphics:t.fillPattern.pattern()(n,r,o,i,a),width:t.fillPattern.width,height:t.fillPattern.height}),void 0!==(null==t?void 0:t.strokePattern)&&(c={graphics:t.strokePattern.pattern()(n,r,o,i,a),width:t.strokePattern.width,height:t.strokePattern.height}),(0,u.getPathGraphics)(e,n,P(E({},t),{fillPattern:s,strokePattern:c}))},renderRay(e,t,n,r){return(o,a,s,c,l,u)=>{const p=(0,i.getRayTransformedLineSegment)({x:e,y:t,angle:n,bidirectional:null==r?void 0:r.bidirectional},s,c,l,u);return p?this.renderPath([p],r)(o,a,s,c,l):[]}}};function _(e){const t=r.useRef(null),[n,o]=r.useState(0),i=r.useRef();return r.useEffect((()=>{t.current&&(t.current.width=e.width,t.current.height=e.height)}),[e.width,e.height]),r.useEffect((()=>{if(!t.current||i.current)return;const n=(0,u.createWebglRenderer)(t.current);if(!n)return;const r=()=>o((e=>e+1));i.current=(t,o,i,a,s,c,l,u,p)=>{const d=performance.now();n(t.map((e=>e(c,r,l,u,p))).flat(),o,i,a,s,null==p?void 0:p.rotate),e.debug&&console.info(Math.round(performance.now()-d))}}),[t.current,e.debug]),r.useEffect((()=>{var t,n,r,o,a,s,c,l,u;if(i.current){const p=null!=(n=null==(t=e.transform)?void 0:t.x)?n:0,f=null!=(o=null==(r=e.transform)?void 0:r.y)?o:0,g=null!=(s=null==(a=e.transform)?void 0:a.scale)?s:1,h=(0,d.colorNumberToVec)(null!=(c=e.backgroundColor)?c:16777215),m=null!=(l=e.strokeWidthFixed)&&l;i.current(e.graphics,h,p,f,g,m,e.width,e.height,e.transform),null==(u=e.onRender)||u.call(e)}}),[e.graphics,e.backgroundColor,i.current,e.transform,n,e.width,e.height,e.onRender]),r.createElement("canvas",E({ref:t,width:e.width,height:e.height},e.attributes))}},7529:(e,t,n)=>{"use strict";n.r(t),n.d(t,{WebgpuDrawCanvas:()=>m,reactWebgpuRenderTarget:()=>h});var r=n(3696),o=n(3975),i=n(7191),a=n(7428),s=Object.defineProperty,c=Object.defineProperties,l=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,f=(e,t,n)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,g=(e,t)=>{for(var n in t||(t={}))p.call(t,n)&&f(e,n,t[n]);if(u)for(var n of u(t))d.call(t,n)&&f(e,n,t[n]);return e};const h=c(g({},a.reactWebglRenderTarget),l({type:"webgpu",renderResult:(e,t,n,o)=>r.createElement(m,{width:t,height:n,attributes:null==o?void 0:o.attributes,graphics:e,transform:null==o?void 0:o.transform,backgroundColor:null==o?void 0:o.backgroundColor,debug:null==o?void 0:o.debug,strokeWidthFixed:null==o?void 0:o.strokeWidthFixed})}));function m(e){const t=r.useRef(null),[n,a]=r.useState(0),s=r.useRef();return r.useEffect((()=>{t.current&&(t.current.width=e.width,t.current.height=e.height)}),[e.width,e.height]),r.useEffect((()=>{t.current&&!s.current&&(0,i.createWebgpuRenderer)(t.current).then((t=>{if(!t)return;const n=()=>a((e=>e+1));s.current=(r,o,i,a,s,c,l,u,p)=>{const d=performance.now();t(r.map((e=>e(c,n,l,u,p))).flat(),o,i,a,s,null==p?void 0:p.rotate),e.debug&&console.info(Math.round(performance.now()-d))},n()}))}),[t.current,e.debug]),r.useEffect((()=>{var t,n,r,i,a,c,l,u,p;if(s.current){const d=null!=(n=null==(t=e.transform)?void 0:t.x)?n:0,f=null!=(i=null==(r=e.transform)?void 0:r.y)?i:0,g=null!=(c=null==(a=e.transform)?void 0:a.scale)?c:1,h=(0,o.colorNumberToVec)(null!=(l=e.backgroundColor)?l:16777215),m=null!=(u=e.strokeWidthFixed)&&u;s.current(e.graphics,h,d,f,g,m,e.width,e.height,e.transform),null==(p=e.onRender)||p.call(e)}}),[e.graphics,e.backgroundColor,s.current,e.transform,n,e.width,e.height,e.onRender]),r.createElement("canvas",g({ref:t,width:e.width,height:e.height},e.attributes))}},3331:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Scrollbar:()=>p});var r=n(3696),o=n(8907),i=Object.defineProperty,a=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,c=Object.prototype.propertyIsEnumerable,l=(e,t,n)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,u=(e,t)=>{for(var n in t||(t={}))s.call(t,n)&&l(e,n,t[n]);if(a)for(var n of a(t))c.call(t,n)&&l(e,n,t[n]);return e};function p(e){const{type:t,containerSize:n,contentSize:i}=e,{onStart:a,mask:s}=(0,o.useDragMove)(void 0,{transformOffset:({x:r,y:o})=>{const i=Math.max(Math.min("vertical"===t?o:r,n-c),0);return i!==d&&e.onChange((i-l)*p),{x:r,y:o}}});if(n>=i)return null;const c=Math.max(12,i?n*n/i:0),l=(n/2-c/2)*("head"===e.align?0:"tail"===e.align?2:1),p=-(i-n)/(n-c),d=e.value/p+l,f=u({position:"absolute",userSelect:"none"},e.style),g={background:"rgba(0, 0, 0, 0.3)",borderRadius:"4px",position:"absolute",cursor:"grab"};return"vertical"===t?(f.width="8px",f.height=`${n}px`,f.right="0px",f.top="0px",g.width="8px",g.height=`${c}px`,g.top=`${d}px`):(f.height="8px",f.width=`${n}px`,f.left="0px",f.bottom="0px",g.height="8px",g.width=`${c}px`,g.left=`${d}px`),r.createElement("div",{style:f},r.createElement("div",{style:g,onMouseDown:e=>a({x:e.clientX,y:e.clientY},{["vertical"===t?"y":"x"]:d})}),s)}},3181:(e,t,n)=>{"use strict";n.r(t),n.d(t,{SimpleTextEditor:()=>x});var r=n(3696),o=n.n(r),i=n(4840),a=n(8174),s=n(623),c=n(7670),l=n(9424),u=Object.defineProperty,p=Object.defineProperties,d=Object.getOwnPropertyDescriptors,f=Object.getOwnPropertySymbols,g=Object.prototype.hasOwnProperty,h=Object.prototype.propertyIsEnumerable,m=(e,t,n)=>t in e?u(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,y=(e,t)=>{for(var n in t||(t={}))g.call(t,n)&&m(e,n,t[n]);if(f)for(var n of f(t))h.call(t,n)&&m(e,n,t[n]);return e},v=(e,t)=>p(e,d(t));function x(e){var t,n,r;const{state:u,setState:p,undo:d,redo:f}=(0,l.useUndoRedo)(e.value.split("")),{renderEditor:g}=(0,c.useFlowLayoutTextEditor)({state:u,setState:p,width:e.width,height:null!=(t=e.height)?t:100,fontSize:e.fontSize,fontFamily:e.fontFamily,lineHeight:null!=(n=e.lineHeight)?n:1.2*e.fontSize,processInput(t){var n;return"Escape"===t.key?(null==(n=e.onCancel)||n.call(e),!0):(t.stopPropagation(),!(!(0,s.metaKeyIfMacElseCtrlKey)(t)||"z"!==t.key||(t.shiftKey?f(t):d(t),0)))},autoHeight:!0,autoFocus:!0,onBlur:()=>{setTimeout((()=>{if(!e.readOnly&&e.setValue){const t=u.join("");t!==e.value&&e.setValue(t)}}),0)},align:e.align,verticalAlign:e.verticalAlign,style:{border:"unset"}}),h=null!=(r=e.borderWidth)?r:1;return o().createElement("div",{style:v(y({position:"absolute",zIndex:10},a.controlStyle),{padding:"0px",left:e.x-h+"px",top:e.y-h+"px",borderWidth:`${h}px`})},g({target:i.reactCanvasRenderTarget,getTextColors:()=>({color:e.color})}))}},1121:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useAttributedTextEditor:()=>P});var r=n(3696),o=n(6301),i=n(2792),a=n(6487),s=n(3331),c=n(4399),l=n(135),u=n(623),p=n(9182),d=n(7670),f=n(8905),g=Object.defineProperty,h=Object.defineProperties,m=Object.getOwnPropertyDescriptors,y=Object.getOwnPropertySymbols,v=Object.prototype.hasOwnProperty,x=Object.prototype.propertyIsEnumerable,b=(e,t,n)=>t in e?g(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,C=(e,t)=>{for(var n in t||(t={}))v.call(t,n)&&b(e,n,t[n]);if(y)for(var n of y(t))x.call(t,n)&&b(e,n,t[n]);return e},E=(e,t)=>h(e,m(t));function P(e){var t,n;const[g,h]=r.useState(0),[m,y]=r.useState(),v=r.useRef(null),[x,b]=r.useState(0),[P,w]=r.useState(),[k,_]=r.useState(!1),{onComposing:S,getCompositionCountThenEnd:R}=(0,d.useTextComposing)(),T=(t,n)=>{var r,o;if(e.readOnly)return;let i,a,s=P;ie?(a=ie.min,i=L(ie),fe.attributes&&!(null==(r=e.getReadonlyType)?void 0:r.call(e,fe.attributes))&&(s={attributes:fe.attributes,index:ie.min})):n?(a=g-n,i=L({min:g-n,max:g}),fe.attributes&&!(null==(o=e.getReadonlyType)?void 0:o.call(e,fe.attributes))&&(s={attributes:fe.attributes,index:a})):(a=g,i=e.state),h(a+t.length);const c=[];let l=0,u=!1;const p=Q.some((e=>e.min===a)),d=Q.some((e=>e.max===a));for(const e of i){const n=a-l,r=D(e);if(n>=0&&(d?n0&&c.push({attributes:e.attributes,insert:e.insert.slice(0,n)}),c.push({attributes:C(C({},e.attributes),s.attributes),insert:t}),n{if(e.readOnly)return;let o,i;ie?(i=ie.min,o=L(ie)):(i=g,o=e.state),void 0!==r&&(i=r),h(i+n);const a=[];let s=0,c=!1;for(const e of o){const r=i-s,o=D(e);r>=0&&r<=o&&!c?(a.push({attributes:e.attributes,insert:e.insert.slice(0,r)}),a.push(...t),s+=n,a.push({attributes:e.attributes,insert:e.insert.slice(r)}),c=!0):a.push(e),s+=o}c||a.push(...t),e.setState(a)},L=t=>{h(t.min),y(void 0);const n=[];let r=0;for(const o of e.state){const e=t.min-r,i=t.max-r,a=D(o);e<0?i>=a||(i>=0?i0&&n.push({attributes:o.attributes,insert:o.insert.slice(0,e)}),i{if(e.readOnly)return;if(ie)return void e.setState(L(ie));if(0===g)return;const t=Q.find((e=>g===e.max));if(t)return h(t.min),void e.setState(L(t));h(g-1);const n=[];let r=0,o=!1;for(const t of e.state){const e=g-r,i=D(t);e>=0&&e<=i&&!o?(n.push({attributes:t.attributes,insert:t.insert.slice(0,e-1)+t.insert.slice(e)}),o=!0):n.push(t),r+=i}e.setState(n)},I=t=>{const n=[];let r=0;for(const o of e.state){const e=t.min-r,i=t.max-r,a=D(o);e<0?i>=a?n.push(o):i>=0&&i>0&&n.push({attributes:o.attributes,insert:o.insert.slice(0,i)}):e{if(void 0===ie)return;const n=I(ie);return t&&e.setState(L(ie)),n},D=t=>{var n;return!0===(null==(n=e.getReadonlyType)?void 0:n.call(e,t.attributes))?1:t.insert.length},B=e=>{const t=V(j(e)).location,{newSelectionStart:n,newLocation:r}=(0,d.getWordByDoubleClick)(Z,t,(e=>e.insert));void 0!==n&&y(J({location:n},"min")),void 0!==r&&h(J({location:r},"max"))},z=t=>{var n;if(t.nativeEvent.isComposing)S(t,T,M);else if(229!==t.keyCode){if(!(null==(n=e.processInput)?void 0:n.call(e,t))&&!["CapsLock","Tab","Shift","Meta","Escape","Control"].includes(t.key)){if("Backspace"===t.key)return M();if("Delete"===t.key)return(()=>{if(e.readOnly)return;if(ie)return void e.setState(L(ie));if(g===Z.length)return;const t=Q.find((e=>g===e.min));if(t)return void e.setState(L(t));const n=[];let r=0,o=!1;for(const t of e.state){const e=g-r+1,i=D(t);e>=0&&e<=i&&!o?(n.push({attributes:t.attributes,insert:t.insert.slice(0,e-1)+t.insert.slice(e)}),o=!0):n.push(t),r+=i}e.setState(n)})();if("ArrowLeft"===t.key)return((e=!1)=>{if(!e&&ie)return y(void 0),void h(ie.min);0!==g&&(e&&void 0===m&&y(g),h(J({location:g-1},"min")))})(t.shiftKey);if("ArrowRight"===t.key)return((e=!1)=>{if(!e&&ie)return y(void 0),void h(ie.max);g!==Z.length&&(e&&void 0===m&&y(g),h(J({location:g+1},"max")))})(t.shiftKey);if("ArrowUp"===t.key)return((e=!1)=>{if(!e&&ie)return y(void 0),void h(ie.min);e&&void 0===m&&y(g),h(ue{if(!e&&ie)return y(void 0),void h(ie.max);e&&void 0===m&&y(g),pe>=ne.length-1?h(Z.length):h(J(V({x:le,y:ue+ne[pe]+ne[pe+1]/2+X},!1),"max"))})(t.shiftKey);if("Enter"===t.key)return T("\n");if((0,u.metaKeyIfMacElseCtrlKey)(t)){if("a"===t.key)return y(0),void h(Z.length);if("v"===t.key)return e.readOnly||navigator.clipboard.readText().then((e=>{if(e){T(e);try{const t=JSON.parse(e);A(t,function(e){let t=0;for(const n of e)t+=n.insert.length;return t}(t))}catch(t){T(e)}}})),void t.preventDefault();if("c"===t.key||"x"===t.key){const e=O("x"===t.key);return void(e&&navigator.clipboard.writeText(JSON.stringify(e)))}}else t.preventDefault(),1===t.key.length&&T(t.key)}}else S(t,T,M)},F=()=>{var t,n;null==(t=e.onLocationChanged)||t.call(e,-1),null==(n=e.onBlur)||n.call(e)},N=r.useRef(),[U,G]=r.useState(),j=e=>{const t=e.target.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}},V=(t,n=!0)=>{const r=(0,o.getFlowLayoutLocation)(t,ne,ee,X,e.getWidth,n);return r?(_(r.lineEnd),r):{location:ee.length-1}},W=t=>{t.preventDefault();const n=j(t),r=J(V(n),"nearest");if(t.shiftKey)(void 0===m||Math.abs(m-r){if(ie)for(let n=ie.min;nr.x&&t.y>r.y&&t.x{if(void 0===N.current)return void(void 0!==U&&G(V(j(t),!1).location));const n=j(t),r=J(V(n,!1),"farthest");h(r),r===N.current?y(void 0):y(N.current),e.autoHeight||(n.y>=0&&n.y<=re?Y((e=>K(e+2))):n.y<=e.height&&n.y>=e.height-oe&&Y((e=>K(e-2))))},q=e=>{var t;H(e),void 0!==U&&ie&&(Uie.max&&(A(I(ie),ie.size,U-ie.size),y(U-ie.size)),G(void 0)),null==(t=v.current)||t.focus()};(0,l.useGlobalMouseUp)((0,c.useEvent)((()=>{N.current=void 0,G(void 0)})));const{ref:$,y:X,setY:Y,filterY:K}=(0,p.useWheelScroll)({minY:e.autoHeight?0:x>e.height?e.height-x:0,maxY:0,disabled:e.autoHeight});r.useEffect((()=>{e.autoHeight&&Y(0)}),[e.autoHeight,Y]);const Z=[],Q=[];for(const n of e.state){const r=null==(t=e.getReadonlyType)?void 0:t.call(e,n.attributes);if(r){const e=Z.length,t=Z.length+D(n);if(!0===r){Q.push({min:e,max:t}),Z.push({insert:n.insert,attributes:n.attributes});continue}const o=Q.find((t=>t.type===r&&t.max===e));o?o.max=t:Q.push({min:e,max:t,type:r})}for(const e of n.insert)Z.push({insert:e,attributes:n.attributes})}const J=(e,t)=>{var n;let r;return"farthest"!==t&&"nearest"!==t||(r=e.fromRight?Q.find((t=>!t.type&&e.location===t.min)):Q.find((t=>!t.type&&e.location===t.max))),r||(r=Q.find((t=>e.location>t.min&&e.location(r.max+r.min)/2?r.min:r.max:"nearest"===t?e.location>(r.max+r.min)/2?r.max:r.min:r[t]:e.location},{layoutResult:ee,newContentHeight:te,lineHeights:ne}=(0,o.flowLayout)({state:Z,width:e.width,height:e.autoHeight?void 0:e.height,lineHeight:e.lineHeight,getWidth:e.getWidth,isNewLineContent:e=>"\n"===e.insert,isPartOfComposition:e=>(0,f.isWordCharactor)(e.insert),getComposition:t=>(0,d.getTextComposition)(t,Z,e.getWidth,(e=>e.insert)),endContent:{insert:""},scrollY:X,align:e.align,verticalAlign:e.verticalAlign});x0&&ee[ae-1];se&&ae--;const ce=null!=(n=ee[ae])?n:ee[ee.length-1],le=ce.x+(se?e.getWidth(ee[ae].content):0),ue=ce.y-X,pe=ce.row,de=ie?ie.min+1:g;let fe=Z[de>0?de-1:de];P&&!ie&&P.index===g&&(fe=E(C({},fe),{attributes:C(C({},fe.attributes),P.attributes)}));const ge=r.useRef(),he=r.useRef();r.useEffect((()=>{if((0,i.equals)(ge.current,g)&&(0,i.equals)(he.current,ue)||e.autoHeight)return;const t=ue+X;t<0?Y(-ue):t>e.height-oe&&Y(e.height-oe-ue),ge.current=g,he.current=ue}),[g,ue,X,oe]),r.useEffect((()=>{var t;null==(t=e.onLocationChanged)||t.call(e,g)}),[g]),r.useEffect((()=>{P&&g!==(null==P?void 0:P.index)&&w(void 0)}),[g,P,w]);let me=e.height;return e.autoHeight&&x>e.height&&(me=x),{ref:v,range:ie,layoutResult:ee,lineHeights:ne,cursor:{x:le,y:ue+X,row:pe},inputText:T,inputContent:A,location:g,setLocation:h,getCopiedContents:O,isSelected:e=>ie&&e>=ie.min&&e{var n;if(!ie)return void("function"!=typeof t&&((null==P?void 0:P.index)===g&&(t=C(C({},P.attributes),t)),w({index:g,attributes:t})));const r=e=>"function"==typeof t?t(e):C(C({},e),t),o=[];let i=0;for(const t of e.state){const a=ie.min-i,s=ie.max-i,c=D(t);!0===(null==(n=e.getReadonlyType)?void 0:n.call(e,t.attributes))&&0===a?o.push({attributes:r(t.attributes),insert:t.insert}):a<0?s>=c?o.push({insert:t.insert,attributes:r(t.attributes)}):s>=0?(s>0&&o.push({attributes:r(t.attributes),insert:t.insert.slice(0,s)}),s0&&o.push({attributes:t.attributes,insert:t.insert.slice(0,a)}),o.push({attributes:r(t.attributes),insert:t.insert.slice(a,s)}),sr.createElement("div",{style:C({position:"relative",width:e.width+"px",height:me+"px",border:"1px solid black",clipPath:"inset(0px 0px)"},e.style),onMouseLeave:q,ref:$},r.createElement(a.Cursor,{ref:v,onKeyDown:z,onCompositionEnd:e=>{T(e.data,R()),v.current&&(v.current.value="")},onBlur:F,onFocus:e.onFocus,readOnly:e.readOnly,autoFocus:e.autoFocus,style:{left:le+"px",top:ue+X+"px",height:ne[pe]+"px"}}),t,r.createElement("div",{onMouseDown:W,onMouseMove:H,onMouseUp:q,onDoubleClick:B,style:{inset:"0px",cursor:"text",position:"absolute"}}),!e.autoHeight&&r.createElement(s.Scrollbar,{value:X,type:"vertical",containerSize:e.height,contentSize:x,onChange:Y,align:"head"}))}}},4468:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useAudioPlayer:()=>i});var r=n(3696),o=n.n(r);function i(e){const[t,n]=o().useState(0),[r,i]=o().useState(0),[a,s]=o().useState(!1),c=o().useRef(null);return{currentTime:t,duration:r,playing:a,play(){c.current&&(c.current.play(),s(!0))},pause(){c.current&&(c.current.pause(),s(!1))},audio:e&&o().createElement("audio",{onTimeUpdate:()=>{c.current&&n(c.current.currentTime)},onEnded:()=>{s(!1)},preload:"auto",onDurationChange:()=>{c.current&&i(c.current.duration)},ref:c,src:e})}}},3274:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useAudioRecorder:()=>a});var r=n(3696),o=n.n(r),i=(e,t,n)=>new Promise(((r,o)=>{var i=e=>{try{s(n.next(e))}catch(e){o(e)}},a=e=>{try{s(n.throw(e))}catch(e){o(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(i,a);s((n=n.apply(e,t)).next())}));function a(){const e=o().useRef(),t=o().useRef(),n=o().useRef(),[r,a]=o().useState(),[s,c]=o().useState(0),[l,u]=o().useState(),[p,d]=o().useState(!1),f=o().useRef([]);return{audioUrl:r,duration:s,volume:l,start:()=>i(this,null,(function*(){const r=yield navigator.mediaDevices.getUserMedia({audio:!0});e.current=new MediaRecorder(r),e.current.ondataavailable=e=>{f.current.push(e.data)};const o=new AudioContext,i=o.createMediaStreamSource(r);n.current=o.createAnalyser(),i.connect(n.current);const s=Date.now();t.current=setInterval((()=>{if(c(Date.now()-s),n.current){const e=new Float32Array(n.current.fftSize);n.current.getFloatTimeDomainData(e);let t=0;for(const n of e)t=Math.max(t,Math.abs(n));u(Math.min(2*t,1))}}),20),a(void 0),c(0),f.current=[],d(!0),e.current.start(100)})),stop:()=>{e.current&&(e.current.stop(),e.current.stream.getAudioTracks().forEach((e=>{e.stop()})),t.current&&(clearInterval(t.current),t.current=void 0),u(void 0),d(!1),a(window.URL.createObjectURL(new Blob(f.current,{type:"audio/ogg; codecs=opus"}))))},recording:p,chunks:f.current}}},1749:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useCircleArcClickCreate:()=>m});var r=n(3696),o=n(1324),i=n(8638),a=n(5644),s=Object.defineProperty,c=Object.defineProperties,l=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,f=(e,t,n)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,g=(e,t)=>{for(var n in t||(t={}))p.call(t,n)&&f(e,n,t[n]);if(u)for(var n of u(t))d.call(t,n)&&f(e,n,t[n]);return e},h=(e,t)=>c(e,l(t));function m(e,t,n){const[s,c]=r.useState(),[l,u]=r.useState();let p;s&&(p=void 0===l?"specify start angle by click or input angle":"specify end angle by click or input angle");const{circle:d,onClick:f,onMove:m,input:y,setInputPosition:v,startPosition:x,middlePosition:b,cursorPosition:C,setCursorPosition:E,clearText:P}=(0,a.useCircleClickCreate)(e,(e=>c(e?h(g({},e),{startAngle:0,endAngle:0}):void 0)),h(g({},n),{message:p,onKeyDown:s?(e,n)=>{if("Enter"===e.key){let e=+n;isNaN(e)||(void 0===l?(u(e),c(h(g({},s),{startAngle:e,endAngle:e})),P()):(e{u(void 0),E(void 0),c(void 0),P()};return{circle:d,arc:s,startPosition:x,middlePosition:b,cursorPosition:C,onClick(r){if(e)if(s)if(r=(0,i.getAngleSnapPosition)(s,r,null==n?void 0:n.getAngleSnap),void 0===l){const e=(0,o.radianToAngle)((0,o.getTwoPointsRadian)(r,s));u(e),c(h(g({},s),{startAngle:e,endAngle:e}))}else{let e=(0,o.radianToAngle)((0,o.getTwoPointsRadian)(r,s));e{"use strict";n.r(t),n.d(t,{useCircleClickCreate:()=>y});var r=n(3696),o=n(5773),i=n(2318),a=n(8638),s=n(5970),c=Object.defineProperty,l=Object.defineProperties,u=Object.getOwnPropertyDescriptors,p=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,f=Object.prototype.propertyIsEnumerable,g=(e,t,n)=>t in e?c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,h=(e,t)=>{for(var n in t||(t={}))d.call(t,n)&&g(e,n,t[n]);if(p)for(var n of p(t))f.call(t,n)&&g(e,n,t[n]);return e},m=(e,t)=>l(e,u(t));function y(e,t,n){const[i,c]=r.useState(),[l,u]=r.useState(),[p,d]=r.useState();let f="";e&&(f=l?"3 points"===e?p?"specify third point by click":"specify second point by click":"2 points"===e?"specify second point by click, input position or input length":"specify circle edge point by click, input position or input length":"2 points"===e||"3 points"===e?"specify first point by click or input position":"specify circle center point by click or input position",(null==n?void 0:n.message)&&(f=n.message));const{input:g,setCursorPosition:y,clearText:x,cursorPosition:b,setInputPosition:C,resetInput:E}=(0,s.useCursorInput)(f,"center radius"===e||"center diameter"===e||"2 points"===e?(r,i,a)=>{if(null==n?void 0:n.onKeyDown)n.onKeyDown(r,i,a);else if("Enter"===r.key){const n=i.split(",");if(l){if("2 points"===e&&2===n.length){const e=+n[0],r=+n[1];if(!isNaN(e)&&!isNaN(r)){const n={x:l.x+e/2,y:l.y+r/2};t(m(h({},n),{r:(0,o.getTwoPointsDistance)(n,l)})),P()}return}const r=+i;if(!isNaN(r)&&r>0){let n=l.x,i=l.y;if("2 points"===e){const e=(0,o.getPointByLengthAndDirection)(l,r/2,a);n=e.x,i=e.y}t({x:n,y:i,r:"center diameter"===e||"2 points"===e?r/2:r}),P()}}else if(2===n.length){const t=+n[0],r=+n[1];if(!isNaN(t)&&!isNaN(r)){if(u({x:t,y:r}),e){const n=v(e,{x:t,y:r},void 0,a);n&&c(n)}x()}}}}:void 0),P=()=>{u(void 0),d(void 0),c(void 0),E()};return{circle:i,startPosition:l,middlePosition:p,cursorPosition:b,setCursorPosition:y,setInputPosition:C,clearText:x,onClick(r){if(e)if(y(r),l)if("3 points"!==e||p){const o=v(e,l,p,(0,a.getAngleSnapPosition)(l,r,null==n?void 0:n.getAngleSnap));o&&t(o),P()}else d((0,a.getAngleSnapPosition)(l,r,null==n?void 0:n.getAngleSnap));else u(r)},onMove(t,r){if(C(null!=r?r:t),e&&(t=(0,a.getAngleSnapPosition)(l,t,null==n?void 0:n.getAngleSnap),y(t),l)){const n=v(e,l,p,t);n&&c(n)}},input:g,reset:P}}function v(e,t,n,r){if("2 points"===e){const e={x:(t.x+r.x)/2,y:(t.y+r.y)/2};return m(h({},e),{r:(0,o.getTwoPointsDistance)(e,t)})}return"center radius"===e||"center diameter"===e?m(h({},t),{r:(0,o.getTwoPointsDistance)(r,t)}):n?(0,i.getThreePointsCircle)(t,n,r):void 0}},9345:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useEllipseArcClickCreate:()=>m});var r=n(3696),o=n(7875),i=n(1324),a=n(8638),s=Object.defineProperty,c=Object.defineProperties,l=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,f=(e,t,n)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,g=(e,t)=>{for(var n in t||(t={}))p.call(t,n)&&f(e,n,t[n]);if(u)for(var n of u(t))d.call(t,n)&&f(e,n,t[n]);return e},h=(e,t)=>c(e,l(t));function m(e,t,n){const[s,c]=r.useState(),[l,u]=r.useState();let p;s&&(p=void 0===l?"specify start angle by click or input angle":"specify end angle by click or input angle");const{ellipse:d,onClick:f,onMove:m,input:y,startPosition:v,middlePosition:x,cursorPosition:b,setCursorPosition:C,clearText:E,setInputPosition:P,reset:w}=(0,o.useEllipseClickCreate)(e,(e=>c(e?h(g({},e),{startAngle:0,endAngle:0}):void 0)),h(g({},n),{message:p,onKeyDown:s?(e,n)=>{if("Enter"===e.key){let e=+n;isNaN(e)||(void 0===l?(u(e),c(h(g({},s),{startAngle:e,endAngle:e})),E()):(e{c(void 0),u(void 0),C(void 0),E(),w()};return{ellipse:d,ellipseArc:s,startPosition:v,middlePosition:x,cursorPosition:b,reset:k,onClick(r){if(e)if(s){r=(0,a.getAngleSnapPosition)({x:s.cx,y:s.cy},r,null==n?void 0:n.getAngleSnap);let e=(0,i.getEllipseAngle)(r,s);void 0===l?(u(e),c(h(g({},s),{startAngle:e,endAngle:e}))):(e{"use strict";n.r(t),n.d(t,{useEllipseClickCreate:()=>s});var r=n(3696),o=n(7875),i=n(1324),a=n(8638);function s(e,t,n){const[s,l]=r.useState(),[u,p]=r.useState(),[d,f]=r.useState();let g="";e&&(g=u?d?"specify secondary semi-axis by click, input position or input length":"specify end point by click, input position or input length":"ellipse endpoint"===e?"specify first point by click or input position":"specify ellipse center point by click or input position",(null==n?void 0:n.message)&&(g=n.message));const{input:h,setCursorPosition:m,clearText:y,cursorPosition:v,setInputPosition:x,resetInput:b}=(0,o.useCursorInput)(g,e?(r,o,a)=>{if(null==n?void 0:n.onKeyDown)n.onKeyDown(r,o,a);else if("Enter"===r.key&&e){const n=o.split(",");if(!u){if(2===n.length){const e=+n[0],t=+n[1];isNaN(e)||isNaN(t)||(p({x:e,y:t}),y())}return}if(!d){if(2===n.length){const e=+n[0],t=+n[1];isNaN(e)||isNaN(t)||(f({x:e,y:t}),y())}else{const e=+o;!isNaN(e)&&e>0&&(f((0,i.getPointByLengthAndDirection)(u,e,a)),y())}return}if(2===n.length){const r=+n[0],o=+n[1];isNaN(r)||isNaN(o)||(t(c(e,u,d,{x:r,y:o})),C())}else{const n=+o;!isNaN(n)&&n>0&&(t(c(e,u,d,n)),C())}}}:void 0),C=()=>{p(void 0),f(void 0),l(void 0),b()};return{ellipse:s,startPosition:u,middlePosition:d,cursorPosition:v,setCursorPosition:m,setInputPosition:x,clearText:y,reset:C,onClick(r){if(e)if(m(r),u)if(d){const o="ellipse center"===e?u:{x:(u.x+d.x)/2,y:(u.y+d.y)/2};r=(0,a.getAngleSnapPosition)(o,r,null==n?void 0:n.getAngleSnap),t(c(e,u,d,r)),C()}else{const e=(0,a.getAngleSnapPosition)(u,r,null==n?void 0:n.getAngleSnap);f(e)}else p(r)},onMove(t,r){if(x(r||t),!e)return;let o;if(u&&d){const r="ellipse center"===e?u:{x:(u.x+d.x)/2,y:(u.y+d.y)/2};o=(0,a.getAngleSnapPosition)(r,t,null==n?void 0:n.getAngleSnap)}else o=(0,a.getAngleSnapPosition)(u,t,null==n?void 0:n.getAngleSnap);m(o),u&&d&&l(c(e,u,d,o))},input:h}}function c(e,t,n,r){const o="ellipse center"===e?t:{x:(t.x+n.x)/2,y:(t.y+n.y)/2};return{cx:o.x,cy:o.y,rx:(0,i.getTwoPointsDistance)(o,n),ry:"number"==typeof r?r:(0,i.getTwoPointsDistance)(o,r),angle:(0,i.radianToAngle)((0,i.getTwoPointsRadian)(n,o))}}},7195:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useChooseFile:()=>y,useImageClickCreate:()=>m});var r=n(3696),o=n(7875),i=n(1324),a=n(7237),s=Object.defineProperty,c=Object.defineProperties,l=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,f=(e,t,n)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,g=(e,t)=>{for(var n in t||(t={}))p.call(t,n)&&f(e,n,t[n]);if(u)for(var n of u(t))d.call(t,n)&&f(e,n,t[n]);return e},h=(e,t)=>c(e,l(t));function m(e,t){const[n,s]=r.useState();let c="";e&&(c=n?"specify image position":"click to select image");const{input:l,setInputPosition:u}=(0,o.useCursorInput)(c),{start:p,ui:d}=y((e=>{(0,i.blobToDataUrl)(e).then((e=>{(0,a.getImageFromCache)(e,{callback(t){s({x:0,y:0,width:t.width,height:t.height,url:e})}})}))})),f=()=>{s(void 0)};return r.useEffect((()=>{e&&p()}),[e]),{image:n,reset:f,onClick(r){e&&(n?(u(r),t(n),f()):p())},onMove(e,t){u(t||e),n&&s(h(g({},n),{x:e.x,y:e.y}))},input:r.createElement(r.Fragment,null,d,l)}}function y(e){const t=r.useRef(null);return{start(){var e;null==(e=t.current)||e.click()},ui:r.createElement("input",{type:"file",ref:t,accept:"image/*",style:{display:"none"},onChange:t=>{var n;const r=null==(n=t.currentTarget.files)?void 0:n.item(0);r&&e(r),t.target.value=null}})}}},7662:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useLineClickCreate:()=>s});var r=n(3696),o=n(7875),i=n(1324),a=n(8638);function s(e,t,n){const[s,u]=r.useState(),[p,d]=r.useState([]),[f,g]=r.useState([]),[h,m]=r.useState(0),[y,v]=r.useState(),[x,b]=r.useState(),C=c[h],E=(h+1)%c.length,P=void 0!==y?()=>y:null==n?void 0:n.getAngleSnap,w=void 0!==x?()=>x:null==n?void 0:n.getLengthSnap;let k="";s&&(k=1===s.length?"specify start point by click, input position":`specify next point by click, input position or input ${C}, press tab to input ${c[E]}`);const{input:_,setCursorPosition:S,clearText:R,setInputPosition:T,resetInput:A,cursorPosition:L}=(0,o.useCursorInput)(k,e?(e,r,o)=>{if("Enter"===e.key){if("angle"===C){const e=+r;if(!isNaN(e)&&(R(),s&&s.length>1)){const t=s[s.length-2],n=s[s.length-1];let r=(0,a.getAngleSnapPosition)(t,n,(()=>e));r=l(t,r,w),d([...p,r]),g([...f,void 0]),u([...p,r,{x:o.x,y:o.y}]),v(void 0),b(void 0)}return}const e=r.split(",");if(2===e.length){const r=+e[0],i=+e[1];if(!isNaN(r)&&!isNaN(r)){const e=p[p.length-1]||{x:0,y:0},a=e.x+r,s=e.y+i;if((null==n?void 0:n.once)&&p.length>0)return t([p[0],{x:a,y:s}],f),void M();d([...p,{x:a,y:s}]),g([...f,void 0]),u([...p,{x:a,y:s},{x:o.x,y:o.y}]),R(),v(void 0),b(void 0)}return}if(p.length>0){const e=+r;if(!isNaN(e)&&e>0){const r=(0,i.getPointByLengthAndDirection)(p[p.length-1],e,o);if((null==n?void 0:n.once)&&p.length>0)return t([p[0],r],f),void M();d([...p,r]),g([...f,void 0]),u([...p,r,{x:o.x,y:o.y}]),R(),v(void 0),b(void 0)}}}else if("Tab"===e.key){if(e.stopPropagation(),e.preventDefault(),r){const e=+r;isNaN(e)||("angle"===C?(v(e),b(void 0),R()):e>0&&(b(e),v(void 0),R()))}m(E)}}:void 0),M=e=>{e&&p.length>1&&t(p,f),d([]),u(void 0),A(),v(void 0),b(void 0),m(0),g([])};return{line:s,positionTargets:f,inputMode:C,lastPosition:null==s?void 0:s[s.length-2],cursorPosition:L,onClick(r,o){if(!e)return;let i=(0,a.getAngleSnapPosition)(p[p.length-1],r,P);if(i=l(p[p.length-1],i,w),S(i),v(void 0),b(void 0),(null==n?void 0:n.once)&&p.length>0)return t([p[0],i],f),void M();d([...p,i]),g([...f,o])},onMove(t,r){if(T(r||t),!e)return;let o=(0,a.getAngleSnapPosition)(p[p.length-1],t,P);o=l(p[p.length-1],o,w),S(o),(null==n?void 0:n.once)&&0===p.length||u([...p,o])},input:_,reset:M,positions:p}}const c=["length","angle"];function l(e,t,n){if(n&&e){const r=(0,i.getTwoPointsDistance)(e,t),o=n(r);void 0!==o&&o!==r&&(t=(0,i.getPointByLengthAndDirection)(e,o,t))}return t}},327:(e,t,n)=>{"use strict";n.r(t),n.d(t,{usePathClickCreate:()=>i});var r=n(3696),o=n(7875);function i(e,t){const[n,i]=r.useState([]),[a,s]=r.useState(),[c,l]=r.useState("move"),[u,p]=r.useState(),[d,f]=r.useState(),[g,h]=r.useState();let m="";"move"===c?m="specify start point by click":"line"===c?m="specify end point by click":"quadraticCurve"===c?m=u?"specify end point by click":"specify control point by click":"bezierCurve"===c?m=u?d?"specify end point by click":"specify control point 2 by click":"specify control point 1 by click":"arc"===c&&(m=u?d?"input radius":"specify end point by click, or input radius":"specify start point by click, or input radius");const{input:y,setCursorPosition:v,cursorPosition:x,clearText:b,setInputPosition:C,resetInput:E}=(0,o.useCursorInput)(e?m:"",e?(e,t,r)=>{if("Enter"===e.key){const e=t.split(",");if(2===e.length){const t=+e[0],n=+e[1];isNaN(t)||isNaN(n)||(w({x:t,y:n}),k(r),b())}else if(1===e.length&&"arc"===c){const e=+t;!isNaN(e)&&e>0&&(u&&d?(i([...n,{type:"arc",from:u,to:d,radius:e}]),s(void 0),p(void 0),f(void 0)):h(e),b())}}}:void 0),P=e=>{e&&n.length>1&&t(n),i([]),s(void 0),E(),l("move"),b(),p(void 0),f(void 0),h(void 0)},w=e=>{v(e),"move"===c?(i([...n,{type:"move",to:e}]),l("line")):"line"===c?(i([...n,{type:"line",to:e}]),s(void 0)):"quadraticCurve"===c?u?(i([...n,{type:"quadraticCurve",cp:u,to:e}]),s(void 0),p(void 0)):p(e):"bezierCurve"===c?u?d?(i([...n,{type:"bezierCurve",cp1:u,cp2:d,to:e}]),s(void 0),p(void 0),f(void 0)):f(e):p(e):"arc"===c&&(u?g?(i([...n,{type:"arc",from:u,to:e,radius:g}]),s(void 0),p(void 0),h(void 0)):d||f(void 0):p(e))},k=e=>{"line"===c?s({type:"line",to:e}):"quadraticCurve"===c?s(u?{type:"quadraticCurve",cp:u,to:e}:void 0):"bezierCurve"===c?s(u&&d?{type:"bezierCurve",cp1:u,cp2:d,to:e}:void 0):"arc"===c&&s(u&&g?{type:"arc",from:u,radius:g,to:e}:void 0)};return{path:n,preview:a?[...n,a]:n,controlPoint:u,controlPoint2:d,onClick(t){e&&w(t)},onMove(t,n){C(n||t),e&&(v(t),k(t))},input:y,reset:P,setInputType(e){"close"===e?(t([...n,{type:"close"}]),P()):l(e)},cursorPosition:x}}},4205:(e,t,n)=>{"use strict";n.r(t),n.d(t,{usePenClickCreate:()=>a});var r=n(8662),o=n(3696),i=n(1324);function a(e,t){const[n,a]=o.useState([]),s=()=>{a([])};return{points:n,onClick(r){e&&(0!==n.length?(t(),s()):a([{x:Math.round(r.x),y:Math.round(r.y)}]))},onMove(t){if(!e||0===n.length)return;const o=n[n.length-1];if(t={x:Math.round(t.x),y:Math.round(t.y)},!(0,i.isSamePoint)(o,t)){if(n.length>1){const e=n[n.length-2];if((0,i.pointIsOnLine)(o,e,t)&&(0,i.pointIsOnLineSegment)(o,e,t))return void a((0,r.produce)(n,(e=>{e[n.length-1]=t})))}a((0,r.produce)(n,(e=>{e.push(t)})))}},reset:s}}},2628:(e,t,n)=>{"use strict";n.r(t),n.d(t,{usePolygonClickCreate:()=>s});var r=n(3696),o=n(7875),i=n(1324),a=n(8638);function s(e,t,n){const[s,c]=r.useState(),[l,u]=r.useState(),[p,d]=r.useState("radius"),[f,g]=r.useState(6);let h="";e&&(h="sides"===p?"specify sides number by input":l?(null==n?void 0:n.toEdge)?"specify edge point by click or input length":"specify end point by click or input length":"specify center point by click");const{input:m,setCursorPosition:y,clearText:v,cursorPosition:x,setInputPosition:b,resetInput:C}=(0,o.useCursorInput)(h,e?(e,r,o)=>{if("Enter"===e.key){if((null==n?void 0:n.setSidesKey)&&r.toLowerCase()===n.setSidesKey.toLowerCase())return d("sides"),void v();if((null==n?void 0:n.switchTypeKey)&&n.switchType&&r.toLowerCase()===n.switchTypeKey.toLowerCase())return n.switchType(),void v();const e=+r;if(!isNaN(e)&&e>0)if("radius"===p){if(l){const r=(0,i.getPointByLengthAndDirection)(l,e,o);t((0,i.getPolygonPoints)(r,l,f,null==n?void 0:n.toEdge)),E()}}else"sides"===p&&Number.isInteger(e)&&e>=3&&(g(e),d("radius"),v(),l&&c((0,i.getPolygonPoints)(o,l,e,null==n?void 0:n.toEdge)))}}:void 0),E=()=>{u(void 0),c(void 0),C()};return r.useEffect((()=>{l&&x&&c((0,i.getPolygonPoints)(x,l,f,null==n?void 0:n.toEdge))}),[null==n?void 0:n.toEdge]),{polygon:s,startPosition:l,cursorPosition:x,reset:E,onClick(r){if(e)if(y(r),l){const e=(0,a.getAngleSnapPosition)(l,r,null==n?void 0:n.getAngleSnap);t((0,i.getPolygonPoints)(e,l,f,null==n?void 0:n.toEdge)),E()}else u(r)},onMove(t,r){if(b(r||t),!e)return;const o=(0,a.getAngleSnapPosition)(l,t,null==n?void 0:n.getAngleSnap);y(o),l&&c((0,i.getPolygonPoints)(o,l,f,null==n?void 0:n.toEdge))},input:m,startSetSides(){d("sides")}}}},3175:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useTextClickCreate:()=>g});var r=n(3696),o=n(7875),i=Object.defineProperty,a=Object.defineProperties,s=Object.getOwnPropertyDescriptors,c=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,u=Object.prototype.propertyIsEnumerable,p=(e,t,n)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,d=(e,t)=>{for(var n in t||(t={}))l.call(t,n)&&p(e,n,t[n]);if(c)for(var n of c(t))u.call(t,n)&&p(e,n,t[n]);return e},f=(e,t)=>a(e,s(t));function g(e,t,n){const[i,a]=r.useState();let s="";e&&(s=i?"specify text position":"input text");const{input:c,setCursorPosition:l,clearText:u,setInputPosition:p,resetInput:g}=(0,o.useCursorInput)(s,e?(e,t,r)=>{var o;"Enter"===e.key&&(a({x:r.x,y:r.y,text:t,color:0,fontSize:16/(null!=(o=null==n?void 0:n.scale)?o:1),fontFamily:"monospace"}),u())}:void 0),h=()=>{a(void 0),g()};return{text:i,onClick(n){e&&i&&(l(n),t(i),h())},onMove(e,t){p(t||e),l(e),i&&a(f(d({},i),{x:e.x,y:e.y}))},input:c,reset:h}}},5970:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useCursorInput:()=>u});var r=n(3696),o=Object.defineProperty,i=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable,c=(e,t,n)=>t in e?o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,l=(e,t)=>{for(var n in t||(t={}))a.call(t,n)&&c(e,n,t[n]);if(i)for(var n of i(t))s.call(t,n)&&c(e,n,t[n]);return e};function u(e,t,n){const[o,i]=r.useState(""),[a,s]=r.useState(),[c,u]=r.useState(),p=r.useRef(null);return r.useLayoutEffect((()=>{var e,t;const n=null==(e=document.activeElement)?void 0:e.tagName;"INPUT"!==n&&"TEXTAREA"!==n&&(null==(t=p.current)||t.focus())})),{resetInput:()=>{s(void 0),u(void 0),i("")},cursorPosition:a,inputPosition:c,setCursorPosition:s,setInputPosition:u,clearText(){i("")},input:c&&(e||t&&a)?r.createElement("span",{style:{position:"absolute",left:`${Math.min(c.x+10,window.innerWidth-54)}px`,top:`${Math.min(c.y-5,window.innerHeight-22)}px`}},e&&r.createElement("span",null,e),t&&a&&r.createElement("input",{ref:p,value:o,autoComplete:"false",style:l({width:"50px",opacity:(null==n?void 0:n.hideIfNoInput)&&!o?0:void 0},null==n?void 0:n.inputStyle),onChange:e=>i(e.target.value),onKeyDown:e=>t(e,o,a)})):void 0}}},2978:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useDelayedAction:()=>o});var r=n(3696);function o(e,t,n){const o=r.useRef();e&&(o.current&&clearTimeout(o.current),o.current=setTimeout((()=>{n()}),t))}},8907:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useDragMove:()=>s});var r=n(3696),o=n(8638),i=n(3158),a=n(1715);function s(e,t){var n;const[s,c]=r.useState({x:0,y:0}),[l,u]=r.useState(),p=null!=(n=null==t?void 0:t.scale)?n:1,d=-(0,a.angleToRadian)(null==t?void 0:t.parentRotate),f=()=>{c({x:0,y:0}),u(void 0)};return{offset:s,resetDragMove:f,startPosition:l,onStart(e,t){var n,r;u({x:e.x-(null!=(n=null==t?void 0:t.x)?n:0),y:e.y-(null!=(r=null==t?void 0:t.y)?r:0),data:null==t?void 0:t.data})},mask:l&&r.createElement(i.DragMask,{ignoreLeavingEvent:null==t?void 0:t.ignoreLeavingEvent,onDragging:e=>{var n,r,i,a;const s={x:e.clientX,y:e.clientY};let u=null!=(r=null==(n=null==t?void 0:t.transform)?void 0:n.call(t,s))?r:s;u=(0,o.getAngleSnapPosition)(l,u,null==t?void 0:t.getAngleSnap);const f=(u.x-l.x)/p,g=(u.y-l.y)/p,h=Math.sin(d),m=Math.cos(d),y={x:m*f-h*g,y:h*f+m*g};c(null!=(a=null==(i=null==t?void 0:t.transformOffset)?void 0:i.call(t,y,e))?a:y)},onDragEnd:()=>{null==e||e(),(null==t?void 0:t.repeatedly)||f()}})}}},1412:(e,t,n)=>{"use strict";n.r(t),n.d(t,{getResizeOffset:()=>v,useDragResize:()=>y});var r=n(3696),o=n(4676),i=n(8638),a=n(3158),s=n(1715),c=Object.defineProperty,l=Object.defineProperties,u=Object.getOwnPropertyDescriptors,p=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,f=Object.prototype.propertyIsEnumerable,g=(e,t,n)=>t in e?c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,h=(e,t)=>{for(var n in t||(t={}))d.call(t,n)&&g(e,n,t[n]);if(p)for(var n of p(t))f.call(t,n)&&g(e,n,t[n]);return e},m=(e,t)=>l(e,u(t));function y(e,t){var n,c;const[l,u]=r.useState({x:0,y:0,width:0,height:0}),[p,d]=r.useState(),f=-(0,s.angleToRadian)(null==t?void 0:t.rotate),g=-(0,s.angleToRadian)(null==t?void 0:t.parentRotate),[y,x]=r.useState(),b=()=>{u({x:0,y:0,width:0,height:0}),d(void 0)};return{offset:l,cursorPosition:y,startPosition:p,onStart(e,n){var r,o;e.stopPropagation();const i={x:e.clientX,y:e.clientY};d(m(h({},null!=(o=null==(r=null==t?void 0:t.transform)?void 0:r.call(t,i))?o:i),{direction:n}))},resetDragResize:b,mask:p&&r.createElement(a.DragMask,{onDragging:e=>{var n,r,o,a,s,c;let l={x:e.clientX,y:e.clientY};l=null!=(r=null==(n=null==t?void 0:t.transform)?void 0:n.call(t,l))?r:l,l=(0,i.getAngleSnapPosition)(p,l,null==t?void 0:t.getAngleSnap),x(l);const d="boolean"==typeof(null==t?void 0:t.centeredScaling)?t.centeredScaling:null==(o=null==t?void 0:t.centeredScaling)?void 0:o.call(t,e),h="number"==typeof(null==t?void 0:t.keepRatio)?t.keepRatio:null==(a=null==t?void 0:t.keepRatio)?void 0:a.call(t,e),m=v(p,l,p.direction,f,d,h,g);m&&u(null!=(c=null==(s=null==t?void 0:t.transformOffset)?void 0:s.call(t,m,e,p.direction))?c:m)},onDragEnd:()=>{e(),b()},style:{cursor:(0,o.getResizeCursor)((null!=(n=null==t?void 0:t.rotate)?n:0)+(null!=(c=null==t?void 0:t.parentRotate)?c:0),p.direction)}})}}function v(e,t,n,r=0,o,i,a=0){const s=t.x-e.x,c=t.y-e.y,l=Math.sin(a),u=Math.cos(a),p=u*s-l*c,d=l*s+u*c;if("center"===n)return{x:p,y:d,width:0,height:0};const f=Math.sin(r),g=Math.cos(r);let h=g*p-f*d,m=f*p+g*d;const y=n.includes("right")?1:n.includes("left")?-1:0,v=n.includes("bottom")?1:n.includes("top")?-1:0;if(i){if("left"===n||"right"===n||"top"===n||"bottom"===n)return;const e=h*y,t=m*v;h=Math.min(t*i,e)*y,m=Math.min(e/i,t)*v}const x={x:0,y:0,width:0,height:0};return x.width=h*(o?2:1)*y,x.height=m*(o?2:1)*v,o?(x.x-=h*y,x.y-=m*v):(n.includes("left")&&(x.x+=(g+1)*h/2,x.y-=f*h/2),n.includes("right")&&(x.x+=(g-1)*h/2,x.y-=f*h/2),n.includes("top")&&(x.x+=f*m/2,x.y+=(g+1)*m/2),n.includes("bottom")&&(x.x+=f*m/2,x.y+=(g-1)*m/2)),x}},2789:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useDragRotate:()=>m});var r=n(3696),o=n(1715),i=n(8638),a=n(3158),s=Object.defineProperty,c=Object.defineProperties,l=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,f=(e,t,n)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,g=(e,t)=>{for(var n in t||(t={}))p.call(t,n)&&f(e,n,t[n]);if(u)for(var n of u(t))d.call(t,n)&&f(e,n,t[n]);return e},h=(e,t)=>c(e,l(t));function m(e,t){var n;const[s,c]=r.useState(),[l,u]=r.useState(),p=null!=(n=null==t?void 0:t.parentRotate)?n:0,d=()=>{c(void 0),u(void 0)};return{offset:s,center:l,onStart:u,resetDragRotate:d,mask:l&&r.createElement(a.DragMask,{ignoreLeavingEvent:null==t?void 0:t.ignoreLeavingEvent,onDragging:e=>{var n,r,a,s;const u={x:e.clientX,y:e.clientY};let d=null!=(r=null==(n=null==t?void 0:t.transform)?void 0:n.call(t,u))?r:u;d=(0,i.getAngleSnapPosition)(l,d,null==t?void 0:t.getAngleSnap);const f=((0,o.radianToAngle)((0,o.getTwoPointsRadian)(d,l))+450-p)%360;c(h(g({},d),{angle:null!=(s=null==(a=null==t?void 0:t.transformOffset)?void 0:a.call(t,f,e))?s:f}))},onDragEnd:()=>{null==e||e(),d()}})}}},9160:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useDragSelect:()=>i});var r=n(3696),o=n(3158);function i(e,t){const[n,i]=r.useState(),[a,s]=r.useState(),c=()=>{i(void 0),s(void 0)},l=t=>{n&&e(n,a,t),c()};return{dragSelectStartPosition:n,onStartSelect(e,t){i({x:e.clientX,y:e.clientY,data:t})},endDragSelect:l,resetDragSelect:c,dragSelectMask:n&&r.createElement(o.DragMask,{onDragging:e=>{if("boolean"==typeof t?t:t?t(e):void 0){const t=e.clientX-n.x,r=e.clientY-n.y,o=Math.min(Math.abs(t),Math.abs(r));s({x:t>0?n.x+o:n.x-o,y:r>0?n.y+o:n.y-o})}else s({x:e.clientX,y:e.clientY})},onDragEnd:l,style:{cursor:a?"crosshair":"default"}},a&&r.createElement("div",{style:{position:"absolute",border:"1px dashed black",left:Math.min(n.x,a.x)+"px",top:Math.min(n.y,a.y)+"px",width:Math.abs(n.x-a.x)+"px",height:Math.abs(n.y-a.y)+"px"}}))}}},5115:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useEdit:()=>y});var r=n(8662),o=n(3696),i=n(1324),a=n(8638),s=n(9055),c=Object.defineProperty,l=Object.defineProperties,u=Object.getOwnPropertyDescriptors,p=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,f=Object.prototype.propertyIsEnumerable,g=(e,t,n)=>t in e?c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,h=(e,t)=>{for(var n in t||(t={}))d.call(t,n)&&g(e,n,t[n]);if(p)for(var n of p(t))f.call(t,n)&&g(e,n,t[n]);return e},m=(e,t)=>l(e,u(t));function y(e,t,n){var c,l,u;const[p,d]=o.useState(),[f,g]=o.useState(),[y,v]=o.useState(),[x,b]=o.useState(),[C,E]=o.useState(),[P,w]=o.useState(),k=5/(null!=(c=null==n?void 0:n.scale)?c:1),_=null!=(l=null==n?void 0:n.readOnly)&&l,S=()=>{d(void 0),v(void 0),b(void 0),E(void 0),w(void 0),g(void 0)};return o.useEffect((()=>{!1===_&&S()}),[_]),{editPoint:p,editLastPosition:null!=(u=null==p?void 0:p.angleSnapStartPoint)?u:y,getEditAssistentContents(e,r){var o;const i=[];if(!_&&!(null==(o=null==n?void 0:n.contentReadOnly)?void 0:o.call(n,e))){const n=null==t?void 0:t(e);n&&i.push(...n.editPoints.map((e=>r({x:e.x,y:e.y,width:k,height:k}))))}return i},updateEditPreview(){if(f&&y&&x){const e=[],t=[],o=[],[i,a,c]=(0,r.produceWithPatches)(f.content,(r=>{var i,a;const s=null==(a=f.update)?void 0:a.call(f,r,{cursor:x,start:y,scale:null!=(i=null==n?void 0:n.scale)?i:1,target:C});if((null==s?void 0:s.assistentContents)&&e.push(...s.assistentContents),null==s?void 0:s.updateRelatedContents){const e=s.updateRelatedContents();t.push(...e.patches),o.push(...e.reversePatches)}}));return{content:f.content,result:i,patches:[...(0,s.prependPatchPath)(a,f.path),...t],reversePatches:[...(0,s.prependPatchPath)(c,f.path),...o],assistentContents:e,relatedEditPointResults:new Map}}if(p&&y&&x&&p.update){const e=[],t=[],o=[],[i,a,c]=(0,r.produceWithPatches)(p.content,(r=>{var i,a;const s=null==(a=p.update)?void 0:a.call(p,r,{cursor:x,start:y,scale:null!=(i=null==n?void 0:n.scale)?i:1,target:C});if((null==s?void 0:s.assistentContents)&&e.push(...s.assistentContents),null==s?void 0:s.updateRelatedContents){const e=s.updateRelatedContents();t.push(...e.patches),o.push(...e.reversePatches)}})),l={content:p.content,result:i,patches:[...(0,s.prependPatchPath)(a,p.path),...t],reversePatches:[...(0,s.prependPatchPath)(c,p.path),...o],assistentContents:e,relatedEditPointResults:new Map};for(const t of p.relatedEditPoints){const[o,i,a]=(0,r.produceWithPatches)(t.content,(r=>{var o,i;const a=null==(i=t.update)?void 0:i.call(t,r,{cursor:x,start:y,scale:null!=(o=null==n?void 0:n.scale)?o:1});(null==a?void 0:a.assistentContents)&&e.push(...a.assistentContents)}));l.patches.push(...(0,s.prependPatchPath)(i,t.path)),l.reversePatches.push(...(0,s.prependPatchPath)(a,t.path)),l.relatedEditPointResults.set(t.content,o)}return l}},onEditMove(e,r,o){var s;if(_)return;if((null==p?void 0:p.angleSnapStartPoint)?e=(0,a.getAngleSnapPosition)(p.angleSnapStartPoint,e,null==n?void 0:n.getAngleSnap):y&&(e=(0,a.getAngleSnapPosition)(y,e,null==n?void 0:n.getAngleSnap)),y)return b(e),void E(o);let c;for(const{content:o,path:a}of r){if(null==(s=null==n?void 0:n.contentReadOnly)?void 0:s.call(n,o))continue;const r=null==t?void 0:t(o);if(r){const t=r.editPoints.find((t=>(0,i.getTwoNumbersDistance)(t.x,e.x)<=k&&(0,i.getTwoNumbersDistance)(t.y,e.y)<=k));t&&(c?c.relatedEditPoints.push(m(h({},t),{content:o,path:a})):c=m(h({},t),{content:o,path:a,angleSnapStartPoint:r.angleSnapStartPoint,relatedEditPoints:[]}))}}d(c)},onEditClick(t){if(f)return e([],[]),void S();if(p)if(p.execute){const[,t,n]=(0,r.produceWithPatches)(p.content,(e=>{var t;null==(t=p.execute)||t.call(p,e)}));e((0,s.prependPatchPath)(t,p.path),(0,s.prependPatchPath)(n,p.path))}else y?(e([],[]),S()):v(t)},onEditContextMenu(t,n){(null==p?void 0:p.menu)&&w(n(p.menu,(n=>()=>{if(w(void 0),n.execute){const[,t,o]=(0,r.produceWithPatches)(p.content,(e=>{var t;null==(t=n.execute)||t.call(n,e)}));e((0,s.prependPatchPath)(t,p.path),(0,s.prependPatchPath)(o,p.path))}else n.update&&(v(t),b(t),g({content:p.content,path:p.path,update:n.update}),d(p))})))},editMenu:P,resetEdit:S}}},3404:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useCircleArcEdit:()=>s});var r=n(3696),o=n(1324),i=n(8638),a=n(4970);function s(e,t){const[n,s]=r.useState({x:0,y:0,r:0,startAngle:0,endAngle:0}),[c,l]=r.useState(),{onStart:u,mask:p,reset:d}=(0,a.useDragEdit)((()=>{s({x:0,y:0,r:0,startAngle:0,endAngle:0}),e()}),((e,n)=>{if(n=(0,i.getAngleSnapPosition)(e.data,n,null==t?void 0:t.getAngleSnap),l(n),"center"===e.data.type){const t=n.x-e.x,r=n.y-e.y;s({x:t,y:r,r:0,startAngle:0,endAngle:0,data:e.data.data})}else if("radius"===e.data.type){const t=(0,o.getTwoPointsDistance)(n,e.data)-e.data.r;s({x:0,y:0,r:t,startAngle:0,endAngle:0,data:e.data.data})}else if("start angle"===e.data.type){const t=(0,o.radianToAngle)((0,o.getTwoPointsRadian)(n,e.data))-e.data.startAngle;s({x:0,y:0,r:0,startAngle:t,endAngle:0,data:e.data.data})}else if("end angle"===e.data.type){const t=(0,o.radianToAngle)((0,o.getTwoPointsRadian)(n,e.data))-e.data.endAngle;s({x:0,y:0,r:0,startAngle:0,endAngle:t,data:e.data.data})}}),t);return{offset:n,onStart:u,mask:p,cursorPosition:c,reset(){s({x:0,y:0,r:0,startAngle:0,endAngle:0}),d()}}}},8285:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useCircleEdit:()=>s});var r=n(3696),o=n(1324),i=n(8638),a=n(4970);function s(e,t){const[n,s]=r.useState({x:0,y:0,r:0}),[c,l]=r.useState(),{onStart:u,mask:p,reset:d}=(0,a.useDragEdit)((()=>{s({x:0,y:0,r:0}),e()}),((e,n)=>{if(n=(0,i.getAngleSnapPosition)(e.data,n,null==t?void 0:t.getAngleSnap),l(n),"center"===e.data.type){const t=n.x-e.x,r=n.y-e.y;s({x:t,y:r,r:0,data:e.data.data})}else{const t=(0,o.getTwoPointsDistance)(n,e.data)-e.data.r;s({x:0,y:0,r:t,data:e.data.data})}}),t);return{cursorPosition:c,offset:n,onStart:u,mask:p,reset(){s({x:0,y:0,r:0}),d()}}}},4970:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useDragEdit:()=>g});var r=n(3696),o=n(7875),i=Object.defineProperty,a=Object.defineProperties,s=Object.getOwnPropertyDescriptors,c=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,u=Object.prototype.propertyIsEnumerable,p=(e,t,n)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,d=(e,t)=>{for(var n in t||(t={}))l.call(t,n)&&p(e,n,t[n]);if(c)for(var n of c(t))u.call(t,n)&&p(e,n,t[n]);return e},f=(e,t)=>a(e,s(t));function g(e,t,n){const[i,a]=r.useState();return{dragStartPosition:i,onStart(e,t){var r,o;e.stopPropagation(),a(f(d({},null!=(o=null==(r=null==n?void 0:n.transform)?void 0:r.call(n,{x:e.clientX,y:e.clientY}))?o:{x:e.clientX,y:e.clientY}),{data:t}))},reset(){a(void 0)},mask:i&&r.createElement(o.DragMask,{onDragging:e=>{var r,o;e.stopPropagation();let a={x:e.clientX,y:e.clientY};a=null!=(o=null==(r=null==n?void 0:n.transform)?void 0:r.call(n,a))?o:a,t(i,a)},onDragEnd:()=>{e(),a(void 0)},style:{cursor:i.data.cursor}})}}},5384:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useEllipseArcEdit:()=>s});var r=n(3696),o=n(1324),i=n(8638),a=n(4970);function s(e,t){const[n,s]=r.useState({cx:0,cy:0,rx:0,ry:0,startAngle:0,endAngle:0}),[c,l]=r.useState(),{onStart:u,mask:p,reset:d}=(0,a.useDragEdit)((()=>{s({cx:0,cy:0,rx:0,ry:0,startAngle:0,endAngle:0}),e()}),((e,n)=>{var r,a;if(n=(0,i.getAngleSnapPosition)({x:e.data.cx,y:e.data.cy},n,null==t?void 0:t.getAngleSnap),l(n),"center"===e.data.type){const t=n.x-e.x,r=n.y-e.y;s({cx:t,cy:r,rx:0,ry:0,startAngle:0,endAngle:0,data:e.data.data})}else if("start angle"===e.data.type){const t=(0,o.rotatePositionByCenter)(n,{x:e.data.cx,y:e.data.cy},null!=(r=e.data.angle)?r:0),i=(0,o.getEllipseAngle)(t,e.data)-e.data.startAngle;s({cx:0,cy:0,rx:0,ry:0,startAngle:i,endAngle:0,data:e.data.data})}else if("end angle"===e.data.type){const t=(0,o.rotatePositionByCenter)(n,{x:e.data.cx,y:e.data.cy},null!=(a=e.data.angle)?a:0),r=(0,o.getEllipseAngle)(t,e.data)-e.data.endAngle;s({cx:0,cy:0,rx:0,ry:0,startAngle:0,endAngle:r,data:e.data.data})}}),t);return{offset:n,onStart:u,mask:p,cursorPosition:c,reset(){s({cx:0,cy:0,rx:0,ry:0,startAngle:0,endAngle:0}),d()}}}},2817:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useEllipseEdit:()=>s});var r=n(3696),o=n(1324),i=n(8638),a=n(4970);function s(e,t){const[n,s]=r.useState({cx:0,cy:0,rx:0,ry:0}),[c,l]=r.useState(),{onStart:u,mask:p,reset:d}=(0,a.useDragEdit)((()=>{s({cx:0,cy:0,rx:0,ry:0}),e()}),((e,n)=>{if(n=(0,i.getAngleSnapPosition)({x:e.data.cx,y:e.data.cy},n,null==t?void 0:t.getAngleSnap),l(n),"center"===e.data.type){const t=n.x-e.x,r=n.y-e.y;s({cx:t,cy:r,rx:0,ry:0,data:e.data.data})}else{const t=(0,o.getTwoPointsDistance)(n,{x:e.data.cx,y:e.data.cy});"major axis"===e.data.type?s({cx:0,cy:0,rx:t-e.data.rx,ry:0,data:e.data.data}):s({cx:0,cy:0,rx:0,ry:t-e.data.ry,data:e.data.data})}}),t);return{offset:n,onStart:u,mask:p,cursorPosition:c,reset(){s({cx:0,cy:0,rx:0,ry:0}),d()}}}},341:(e,t,n)=>{"use strict";n.r(t),n.d(t,{usePolylineEdit:()=>a});var r=n(3696),o=n(8638),i=n(4970);function a(e,t){const[n,a]=r.useState(),[s,c]=r.useState(),{onStart:l,mask:u,dragStartPosition:p,reset:d}=(0,i.useDragEdit)((()=>{a(void 0),e()}),((e,n)=>{n=(0,o.getAngleSnapPosition)(e,n,null==t?void 0:t.getAngleSnap),c(n);const r=n.x-e.x,i=n.y-e.y;a({x:r,y:i,pointIndexes:e.data.pointIndexes,data:e.data.data})}),t);return{offset:n,onStart(e,t,n){l(e,{pointIndexes:t,data:n,cursor:"move"})},mask:u,cursorPosition:s,dragStartPosition:p,reset(){a(void 0),d()}}}},4399:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useEvent:()=>o});var r=n(3696);function o(e){const t=r.useRef();return r.useLayoutEffect((()=>{t.current=e})),r.useCallback((e=>{var n;null==(n=t.current)||n.call(t,e)}),[])}},2432:(e,t,n)=>{"use strict";n.r(t),n.d(t,{compareLocations:()=>C,useFlowLayoutBlockEditor:()=>b,useFlowLayoutBlockOperation:()=>E});var r=n(8662),o=n(3696),i=n(7875),a=n(1324),s=n(6487),c=n(3331),l=n(623),u=n(9182),p=Object.defineProperty,d=Object.defineProperties,f=Object.getOwnPropertyDescriptors,g=Object.getOwnPropertySymbols,h=Object.prototype.hasOwnProperty,m=Object.prototype.propertyIsEnumerable,y=(e,t,n)=>t in e?p(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,v=(e,t)=>{for(var n in t||(t={}))h.call(t,n)&&y(e,n,t[n]);if(g)for(var n of g(t))m.call(t,n)&&y(e,n,t[n]);return e},x=(e,t)=>d(e,f(t));function b(e){var t,n,r,i,l;const{range:u,inputContent:p,inputInline:d,getCopiedContents:f,skipVoidBlock:g,scrollRef:h,scrollY:m,dragLocation:y,setY:x,selectionStart:b,setSelectionStart:P,ref:w,setLocation:k,location:_,contentHeight:S,setContentHeight:R,blockLocation:T,contentLocation:A,actualHeight:L,isSelected:M,onBlur:I,onMouseUp:O,onMouseDown:D,onMouseMove:B,onKeyDown:z}=E(e),[F,N]=o.useState(!1),U=(e=!1)=>{if(!e&&u)return P(void 0),void k(u.min);e&&void 0===b&&P(_),k(ue{if(!t&&u)return P(void 0),void k(u.max);t&&void 0===b&&P(_),pe>=Z.length-1?k([e.state.length-1,e.state[e.state.length-1].children.length]):k(W({x:le,y:ue+Z[pe]+Z[pe+1]/2+m},!1))},j=e=>{z(e,U,G)},V=e=>{const t=e.target.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}},W=(t,n=!0,r)=>{for(let o=0;o0&&Y[o][0].y>t.y)return g([o,0],r);const i=(0,a.getFlowLayoutLocation)(t,Z,Y[o],m,(t=>e.getWidth(t,e.state[o])),n,e.getHeight);if(void 0!==i)return N(i.lineEnd),g([o,i.location],r)}return[e.state.length-1,e.state[e.state.length-1].children.length]},H=t=>{if(u)for(let n=0;n=0&&C(r,u.max)<0&&t.x>i.x&&t.y>i.y&&t.x{D(e,V,W,H)},$=e=>{B(e,V,(e=>W(e,!1)),0,ne,re)},X=e=>{$(e),O()},Y=[];let K=0;const Z=[];let Q=0,J=0;const ee=e.getComposition,te=e.lineHeight;if(e.state.forEach(((t,n)=>{var r,o,i,s;const c=t.listStyleType&&(null==(r=e.isSameType)?void 0:r.call(e,t,e.state[n-1]))?0:null!=(o=t.blockStart)?o:0,l=t.listStyleType&&(null==(i=e.isSameType)?void 0:i.call(e,t,e.state[n+1]))?0:null!=(s=t.blockEnd)?s:0,u=Math.max(c,J),p=(0,a.flowLayout)({state:t.children,width:e.width,height:e.autoHeight?void 0:e.height,lineHeight:"number"==typeof te?te:e=>te(e,t),getWidth:n=>e.getWidth(n,t),isNewLineContent:e.isNewLineContent,isPartOfComposition:e.isPartOfComposition,getComposition:ee?e=>ee(n,e):void 0,endContent:e.endContent,scrollX:t.inlineStart,scrollY:m+K+u,row:Q,align:e.align});Y.push(p.layoutResult),t.void||(K+=p.newContentHeight),K+=u,Z.push(...p.lineHeights),Q+=p.lineHeights.length,J=l})),K+=J,e.height&&("middle"===e.verticalAlign||"bottom"===e.verticalAlign)){let t=e.height-K;t>0&&("middle"===e.verticalAlign&&(t/=2),Y.forEach((e=>{e.forEach((e=>{e.y+=t}))})))}S0&&(null==ae?void 0:ae[oe-1]);se&&oe--;const ce=null==ae?void 0:ae[oe],le=(null!=(r=null==ce?void 0:ce.x)?r:0)+(se?e.getWidth(null==ae?void 0:ae[oe].content,e.state[ie]):0),ue=(null!=(i=null==ce?void 0:ce.y)?i:0)-m,pe=null!=(l=null==ce?void 0:ce.row)?l:0,de=o.useRef(),fe=o.useRef();return o.useEffect((()=>{var t,n;if((0,a.equals)(null==(t=de.current)?void 0:t[0],_[0])&&(0,a.equals)(null==(n=de.current)?void 0:n[1],_[1])&&(0,a.equals)(fe.current,ue)||e.autoHeight)return;const r=ue+m;r<0?x(-ue):r>e.height-re&&x(e.height-re-ue),de.current=_,fe.current=ue}),[_,ue,m,re]),{ref:w,range:u,layoutResult:Y,lineHeights:Z,cursor:{x:le,y:ue+m,row:pe},inputContent:p,inputInline:d,location:_,setLocation:k,getCopiedContents:f,isSelected:M,actualHeight:L,setSelectionStart:P,getPosition:V,positionToLocation:W,scrollY:m,renderEditor:t=>o.createElement("div",{style:v({position:"relative",width:e.width+"px",height:L+"px",border:"1px solid black",clipPath:"inset(0px 0px)"},e.style),onMouseLeave:X,ref:h},o.createElement(s.Cursor,{ref:w,onKeyDown:j,onCompositionEnd:e.onCompositionEnd,onBlur:I,onFocus:e.onFocus,readOnly:e.readOnly,style:{left:le+"px",top:ue+m+"px",height:Z[pe]+"px"}}),t,o.createElement("div",{onMouseDown:q,onMouseMove:$,onMouseUp:X,onDoubleClick:e.onDoubleClick,style:{inset:"0px",cursor:"text",position:"absolute"}}),!e.autoHeight&&o.createElement(c.Scrollbar,{value:m,type:"vertical",containerSize:e.height,contentSize:S,onChange:x,align:"head"}))}}function C(e,t){return e[0]t[0]?1:e[1]t[1]?1:0}function E(e){const[t,n]=o.useState([0,0]),[a,s]=t,[c,p]=o.useState(),d=o.useRef(null),[f,g]=o.useState(0),h=void 0!==c?C(c,t)>0?{min:t,max:c}:{min:c,max:t}:void 0,m=r=>{if(!e.readOnly){if(h)return p(void 0),n([h.min[0]+r.length+1,0]),void e.setState((e=>{y(e,r)}));n([a+r.length+1,0]),e.setState((e=>{b(e,r,t)}))}},y=(t,n)=>{if(!h)return;const[o,i]=h.min,[a,s]=h.max;t[o].children.splice(i,e.state[o].children.length),a>o?(t[a].children.splice(0,s),t.splice(o+1,a-o-1,...(0,r.castDraft)(n))):t.splice(o+1,0,...(0,r.castDraft)(n),(0,r.castDraft)(x(v({},e.state[o]),{children:e.state[o].children.slice(s)})))},b=(t,n,o)=>{t[o[0]].children.splice(o[1],e.state[o[0]].children.length-o[1]),t.splice(o[0]+1,0,...(0,r.castDraft)(n),(0,r.castDraft)(x(v({},e.state[o[0]]),{children:e.state[o[0]].children.slice(o[1])})))},E=(t,n)=>{if(!h)return;const[o,i]=h.min,[a,s]=h.max,c=a>o?[...n,...e.state[a].children.slice(s)]:n,l=(o===a?s:e.state[o].children.length)-i;t[o].children.splice(i,l,...(0,r.castDraft)(c)),a>o&&t.splice(o+1,a-o)},P=(e,t,n,o=0)=>{e[n[0]].children.splice(n[1]-o,o,...(0,r.castDraft)(t))},w=()=>{if(!e.readOnly)return h?(n(h.min),p(void 0),void e.setState((e=>{E(e,[])}))):void(0===a&&0===s||(0!==s?(n([a,s-1]),e.setState((e=>{e[a].children.splice(s-1,1)}))):(n([a-1,e.state[a-1].children.length]),e.setState((e=>{e[a-1].children.push(...e[a].children),e.splice(a,1)})))))},k=t=>{const[n,r]=t.min,[o,i]=t.max,a=n===o?i:e.state[n].children.length,s=[x(v({},e.state[n]),{children:e.state[n].children.slice(r,a)})];for(let t=n+1;tn&&s.push(x(v({},e.state[o]),{children:e.state[o].children.slice(0,i)})),s},_=([t,n],r)=>{for(;e.state[t].void;)r?(t--,n=e.state[t].children.length):(t++,n=0);return[t,n]},S=o.useRef(),[R,T]=o.useState();(0,i.useGlobalMouseUp)((0,i.useEvent)((()=>{S.current=void 0,T(void 0)})));const{ref:A,y:L,setY:M,filterY:I}=(0,u.useWheelScroll)({minY:e.autoHeight?0:f>e.height?e.height-f:0,maxY:0,disabled:e.autoHeight});o.useEffect((()=>{e.autoHeight&&M(0)}),[e.autoHeight,M]);let O=e.height;return e.autoHeight&&f>e.height&&(O=f),o.useEffect((()=>{var n;null==(n=e.onLocationChanged)||n.call(e,t)}),[t]),{range:h,inputContent:m,inputInline:(r,o=0)=>{if(!e.readOnly){if(h){const[t,o]=h.min;return p(void 0),n([t,o+r.length]),void e.setState((e=>{E(e,r)}))}n([a,s+r.length-o]),e.setState((e=>{P(e,r,t,o)}))}},getCopiedContents:(e=!1)=>{if(void 0!==h)return e&&w(),k(h)},skipVoidBlock:_,scrollRef:A,backspace:w,scrollY:L,dragLocation:R,setY:M,selectionStart:c,setSelectionStart:p,ref:d,setLocation:n,location:t,contentHeight:f,setContentHeight:g,blockLocation:a,contentLocation:s,isSelected:e=>h&&C(e,h.min)>=0&&C(e,h.max)<0,actualHeight:O,onBlur:()=>{var t,n;e.keepSelectionOnBlur||p(void 0),null==(t=e.onLocationChanged)||t.call(e),null==(n=e.onBlur)||n.call(e)},onMouseUp:()=>{var t;if(void 0!==R&&h){if(C(R,h.min)<0){const t=k(h);if(1===t.length){const r=t[0].children;e.setState((e=>{E(e,[]),P(e,r,R)})),n([R[0],R[1]+r.length]),p(R)}else e.setState((e=>{E(e,[]),b(e,t,R)})),n([R[0]+t.length+1,0]),p([R[0]+1,0])}else if(C(R,h.max)>0){const t=k(h);if(1===t.length){const r=t[0].children;e.setState((e=>{P(e,r,R),E(e,[])})),p([R[0],R[1]-r.length]),n(R)}else e.setState((e=>{b(e,t,R),E(e,[])})),n([R[0]+2,0]),p([R[0]-t.length+2,0])}T(void 0)}null==(t=d.current)||t.focus()},onMouseDown:(e,r,o,i)=>{e.preventDefault();const a=r(e),s=o(a);if(e.shiftKey)void 0===c&&p(t),n(s);else{if(i(a))return void T(s);S.current=s}},onMouseMove:(t,r,o,i,a,s)=>{if(void 0===S.current)return void(void 0!==R&&T(o(r(t))));const c=r(t),l=o(c);if(n(l),l[0]===S.current[0]&&l[1]===S.current[1]?p(void 0):p(S.current),!e.autoHeight){const t=c.y+i;t>=0&&t<=a?M((e=>I(e+2))):t<=e.height&&t>=e.height-s&&M((e=>I(e-2)))}},onKeyDown:(r,o,i,u)=>{var d,f,g;if(r.nativeEvent.isComposing)null==(d=e.onComposing)||d.call(e,r);else if(229!==r.keyCode){if(!(null==(g=e.processInput)?void 0:g.call(e,r))){if("Enter"===r.key)return m([]),!0;if(!["CapsLock","Tab","Shift","Meta","Escape","Control"].includes(r.key)){if("Backspace"===r.key)return w();if("Delete"===r.key)return(()=>{if(!e.readOnly)return h?(n(h.min),p(void 0),void e.setState((e=>{E(e,[])}))):void(a===e.state.length-1&&s===e.state[e.state.length-1].children.length||(s!==e.state[a].children.length?e.setState((e=>{e[a].children.splice(s,1)})):e.setState((e=>{e[a].children.push(...e[a+1].children),e.splice(a+1,1)}))))})();if("ArrowLeft"===r.key)return((r=!1)=>{if(!r&&h)return p(void 0),void n(h.min);0===a&&0===s||(r&&void 0===c&&p(t),n(0!==s?[a,s-1]:_([a-1,e.state[a-1].children.length],!0)))})(r.shiftKey);if("ArrowRight"===r.key)return((r=!1)=>{if(!r&&h)return p(void 0),void n(h.max);a===e.state.length-1&&s===e.state[e.state.length-1].children.length||(r&&void 0===c&&p(t),s!==e.state[a].children.length?n([a,s+1]):n(_([a+1,0])))})(r.shiftKey);if("ArrowUp"===r.key)return o(r.shiftKey);if("ArrowDown"===r.key)return i(r.shiftKey);if((0,l.metaKeyIfMacElseCtrlKey)(r)){if("a"===r.key)return p([0,0]),void n([e.state.length-1,e.state[e.state.length-1].children.length])}else r.preventDefault();null==u||u()}}}else null==(f=e.onComposing)||f.call(e,r)}}}},4844:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useFlowLayoutEditor:()=>v});var r=n(3696),o=n(6301),i=n(2792),a=n(6487),s=n(3331),c=n(4399),l=n(135),u=n(623),p=n(9182),d=Object.defineProperty,f=Object.getOwnPropertySymbols,g=Object.prototype.hasOwnProperty,h=Object.prototype.propertyIsEnumerable,m=(e,t,n)=>t in e?d(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,y=(e,t)=>{for(var n in t||(t={}))g.call(t,n)&&m(e,n,t[n]);if(f)for(var n of f(t))h.call(t,n)&&m(e,n,t[n]);return e};function v(e){var t;const[n,d]=r.useState(0),[f,g]=r.useState(),h=r.useRef(null),[m,v]=r.useState(0),[x,b]=r.useState(!1),C=()=>{if(!e.readOnly)return G?(d(G.min),g(void 0),void e.setState((e=>{e.splice(G.min,G.size)}))):void(0!==n&&(d(n-1),e.setState((e=>{e.splice(n-1,1)}))))},E=t=>{var r,o,i;if(t.nativeEvent.isComposing)null==(r=e.onComposing)||r.call(e,t);else if(229!==t.keyCode){if(!(null==(i=e.processInput)?void 0:i.call(e,t))&&!["CapsLock","Tab","Shift","Meta","Escape","Control"].includes(t.key)){if("Backspace"===t.key)return C();if("Delete"===t.key)return(()=>{if(!e.readOnly)return G?(d(G.min),g(void 0),void e.setState((e=>{e.splice(G.min,G.size)}))):void(n!==e.state.length&&e.setState((e=>{e.splice(n,1)})))})();if("ArrowLeft"===t.key)return((e=!1)=>{if(!e&&G)return g(void 0),void d(G.min);0!==n&&(e&&void 0===f&&g(n),d(n-1))})(t.shiftKey);if("ArrowRight"===t.key)return((t=!1)=>{if(!t&&G)return g(void 0),void d(G.max);n!==e.state.length&&(t&&void 0===f&&g(n),d(n+1))})(t.shiftKey);if("ArrowUp"===t.key)return((e=!1)=>{if(!e&&G)return g(void 0),void d(G.min);e&&void 0===f&&g(n),d(q{if(!t&&G)return g(void 0),void d(G.max);t&&void 0===f&&g(n),$>=F.length-1?d(e.state.length):d(R({x:H,y:q+F[$]+F[$+1]/2+I},!1))})(t.shiftKey);if((0,u.metaKeyIfMacElseCtrlKey)(t)){if("a"===t.key)return g(0),void d(e.state.length)}else t.preventDefault()}}else null==(o=e.onComposing)||o.call(e,t)},P=()=>{var t,n;e.keepSelectionOnBlur||g(void 0),null==(t=e.onLocationChanged)||t.call(e,-1),null==(n=e.onBlur)||n.call(e)},w=r.useRef(),[k,_]=r.useState(),S=e=>{const t=e.target.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}},R=(t,n=!0)=>{const r=(0,o.getFlowLayoutLocation)(t,F,B,I,e.getWidth,n);return r?(b(r.lineEnd),r.location):B.length-1},T=t=>{t.preventDefault();const r=S(t),o=R(r);if(t.shiftKey)(void 0===f||Math.abs(f-o){if(G)for(let n=G.min;nr.x&&t.y>r.y&&t.x{if(void 0===w.current)return void(void 0!==k&&_(R(S(t),!1)));const n=S(t),r=R(n,!1);d(r),r===w.current?g(void 0):g(w.current),e.autoHeight||(n.y>=0&&n.y<=N?O((e=>D(e+2))):n.y<=e.height&&n.y>=e.height-U&&O((e=>D(e-2))))},L=t=>{var n;A(t),void 0!==k&&G&&(k{e.splice(k,0,...e.splice(G.min,G.size))})),d(k+G.size),g(k)):k>G.max&&(e.setState((e=>{e.splice(k-G.size,0,...e.splice(G.min,G.size))})),d(k),g(k-G.size)),_(void 0)),null==(n=h.current)||n.focus()};(0,l.useGlobalMouseUp)((0,c.useEvent)((()=>{w.current=void 0,_(void 0)})));const{ref:M,y:I,setY:O,filterY:D}=(0,p.useWheelScroll)({minY:e.autoHeight?0:m>e.height?e.height-m:0,maxY:0,disabled:e.autoHeight});r.useEffect((()=>{e.autoHeight&&O(0)}),[e.autoHeight,O]);const{layoutResult:B,newContentHeight:z,lineHeights:F}=(0,o.flowLayout)({state:e.state,width:e.width,height:e.autoHeight?void 0:e.height,lineHeight:e.lineHeight,getWidth:e.getWidth,isNewLineContent:e.isNewLineContent,isPartOfComposition:e.isPartOfComposition,getComposition:e.getComposition,endContent:e.endContent,scrollY:I,align:e.align,verticalAlign:e.verticalAlign});m0&&B[j-1];V&&j--;const W=null!=(t=B[j])?t:B[B.length-1],H=W.x+(V?e.getWidth(B[j].content):0),q=W.y-I,$=W.row,X=r.useRef(),Y=r.useRef();r.useEffect((()=>{if((0,i.equals)(X.current,n)&&(0,i.equals)(Y.current,q)||e.autoHeight)return;const t=q+I;t<0?O(-q):t>e.height-U&&O(e.height-U-q),X.current=n,Y.current=q}),[n,q,I,U]),r.useEffect((()=>{var t;null==(t=e.onLocationChanged)||t.call(e,n)}),[n]);let K=e.height;return e.autoHeight&&m>e.height&&(K=m),{ref:h,range:G,layoutResult:B,lineHeights:F,cursor:{x:H,y:q+I,row:$},backspace:C,inputContent:(t,r=t.length,o=0)=>{if(!e.readOnly){if(G)return d(G.min+r),g(void 0),void e.setState((e=>{e.splice(G.min,G.size,...t)}));d(n+r-o),e.setState((e=>{e.splice(n-o,o,...t)}))}},location:n,setLocation:d,getCopiedContents:(t=!1)=>{if(void 0!==G)return t&&C(),e.state.slice(G.min,G.max)},isSelected:e=>G&&e>=G.min&&er.createElement("div",{style:y({position:"relative",width:e.width+"px",height:K+"px",border:"1px solid black",clipPath:"inset(0px 0px)"},e.style),onMouseLeave:L,ref:M},r.createElement(a.Cursor,{ref:h,onKeyDown:E,onCompositionEnd:e.onCompositionEnd,onBlur:P,onFocus:e.onFocus,readOnly:e.readOnly,autoFocus:e.autoFocus,style:{left:H+"px",top:q+I+"px",height:F[$]+"px"}}),t,r.createElement("div",{onMouseDown:T,onMouseMove:A,onMouseUp:L,onDoubleClick:e.onDoubleClick,style:{inset:"0px",cursor:"text",position:"absolute"}}),!e.autoHeight&&r.createElement(s.Scrollbar,{value:I,type:"vertical",containerSize:e.height,contentSize:m,onChange:O,align:"head"}))}}},7670:(e,t,n)=>{"use strict";n.r(t),n.d(t,{getTextComposition:()=>u,getWordByDoubleClick:()=>l,useFlowLayoutTextEditor:()=>s,useTextComposing:()=>c});var r=n(3696),o=n(8905),i=n(4844),a=n(623);function s(e){const t=`${e.fontSize}px ${e.fontFamily}`,n=e=>{var n,r;return null!=(r=null==(n=(0,o.getTextSizeFromCache)(t,e))?void 0:n.width)?r:0},{onComposing:r,getCompositionCountThenEnd:s}=c(),{inputContent:p,getCopiedContents:d,ref:f,layoutResult:g,cursor:h,location:m,setLocation:y,isSelected:v,renderEditor:x,actualHeight:b,setSelectionStart:C,positionToLocation:E,getPosition:P,backspace:w}=(0,i.useFlowLayoutEditor)({state:e.state,width:e.width,height:e.height,lineHeight:e.lineHeight,setState:e.setState,getWidth:n,processInput(t){var n;if(null==(n=e.processInput)?void 0:n.call(e,t))return!0;if("Enter"===t.key)return k("\n"),!0;if((0,a.metaKeyIfMacElseCtrlKey)(t)){if("v"===t.key)return _(),t.preventDefault(),!0;if("c"===t.key||"x"===t.key){const e=d("x"===t.key);return e&&navigator.clipboard.writeText(e.join("")),!0}}else if(1===t.key.length)return t.preventDefault(),k(t.key),!0;return!1},onLocationChanged:e.onLocationChanged,style:e.style,autoHeight:e.autoHeight,readOnly:e.readOnly,autoFocus:e.autoFocus,onBlur:e.onBlur,onFocus:e.onFocus,isNewLineContent:e=>"\n"===e,isPartOfComposition:e=>(0,o.isWordCharactor)(e),getComposition:t=>u(t,e.state,n,(e=>e)),endContent:"",align:e.align,verticalAlign:e.verticalAlign,onCompositionEnd(e){k(e.data,void 0,s()),f.current&&(f.current.value="")},onDoubleClick(t){const n=E(P(t)),{newSelectionStart:r,newLocation:o}=l(e.state,n,(e=>e));void 0!==r&&C(r),void 0!==o&&y(o)},onComposing(e){r(e,k,w)}}),k=(t,n=t.length,r)=>{if(e.readOnly)return;const o=[];for(const e of t)o.push(e);p(o,n,r)},_=()=>{e.readOnly||navigator.clipboard.readText().then((e=>{e&&k(e)}))};return{layoutResult:g,cursor:h,inputText:k,location:m,setLocation:y,renderEditor:t=>{var r,o,i;const a=[];for(const{x:s,y:c,i:l,content:u,visible:p}of g){if(!p)continue;const d=null!=(o=null==(r=t.getTextColors)?void 0:r.call(t,l))?o:{};v(l)&&(d.backgroundColor=11785981);const f=n(u);void 0!==d.backgroundColor&&a.push(t.target.renderRect(s,c,f,e.lineHeight,{fillColor:d.backgroundColor,strokeWidth:0})),a.push(t.target.renderText(s+f/2,c+e.fontSize,u,null!=(i=d.color)?i:0,e.fontSize,e.fontFamily,{textAlign:"center"}))}t.children&&a.push(...t.children);const s=t.target.renderResult(a,e.width,b);return x(s)}}}function c(){const e=r.useRef(0);return{getCompositionCountThenEnd(){const t=e.current;return e.current=0,t},onComposing(t,n,r){if("Backspace"===t.code&&e.current>0)return e.current--,void r();for(const r of["Key","Digit"])if(t.code.startsWith(r)){const o=t.code.slice(r.length)[0].toLocaleLowerCase();if(o)return e.current+=o.length,void n(o)}}}}function l(e,t,n){let r,i,a,s;for(let i=t-1;i>=0;i--){const t=n(e[i]);if(!t||!(0,o.isWordCharactor)(t))break;r=i}for(let r=t;r{"use strict";n.r(t),n.d(t,{useGlobalKeyDown:()=>o,useGlobalKeyUp:()=>i});var r=n(3696);function o(e){r.useEffect((()=>(window.addEventListener("keydown",e,{passive:!1}),()=>{window.removeEventListener("keydown",e)})),[e])}function i(e){r.useEffect((()=>(window.addEventListener("keyup",e,{passive:!1}),()=>{window.removeEventListener("keyup",e)})),[e])}},135:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useGlobalMouseUp:()=>o});var r=n(3696);function o(e){r.useEffect((()=>(window.addEventListener("mouseup",e,{passive:!1}),()=>{window.removeEventListener("mouseup",e)})),[e])}},4740:(e,t,n)=>{"use strict";n.r(t),n.d(t,{defaultFontFamily:()=>_,defaultFontSize:()=>k,isHtmlText:()=>S,renderHtmlTextStyle:()=>R,useHtmlEditor:()=>C});var r=n(8662),o=n(3696),i=n(2852),a=n(7875),s=n(1324),c=n(6487),l=n(3331),u=n(623),p=n(2432),d=Object.defineProperty,f=Object.defineProperties,g=Object.getOwnPropertyDescriptors,h=Object.getOwnPropertySymbols,m=Object.prototype.hasOwnProperty,y=Object.prototype.propertyIsEnumerable,v=(e,t,n)=>t in e?d(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,x=(e,t)=>{for(var n in t||(t={}))m.call(t,n)&&v(e,n,t[n]);if(h)for(var n of h(t))y.call(t,n)&&v(e,n,t[n]);return e},b=(e,t)=>f(e,g(t));function C(e){var t,n,d,f,g,h,m,y,v,C,w,R,T,A,M,I,O,D,B;const z=o.useRef(null),[F,N]=o.useState(),U=o.useRef(),[G,j]=o.useState(!1),[V,W]=o.useState(),{onComposing:H,getCompositionCountThenEnd:q}=(0,a.useTextComposing)(),{range:$,inputContent:X,inputInline:Y,getCopiedContents:K,scrollRef:Z,scrollY:Q,dragLocation:J,setY:ee,selectionStart:te,setSelectionStart:ne,ref:re,setLocation:oe,location:ie,contentHeight:ae,setContentHeight:se,blockLocation:ce,contentLocation:le,actualHeight:ue,isSelected:pe,onBlur:de,onMouseUp:fe,onMouseDown:ge,onMouseMove:he,onKeyDown:me,backspace:ye}=(0,p.useFlowLayoutBlockOperation)(b(x({},e),{onComposing(e){H(e,we,ye)}})),ve=e=>{var t;const n=$?$.min[0]:ie[0],r=e[n],o=r?ie[1]<=0?0:ie[1]-1:void 0;return{currentBlock:r,currentContent:void 0!==o?r.children[o]:void 0,currentContentLayout:void 0!==n&&void 0!==o&&U.current?null==(t=U.current.cells[n])?void 0:t[o]:void 0}},{currentBlock:xe,currentContent:be,currentContentLayout:Ce}=ve(e.state);let Ee;Ee=be&&V&&!$&&0===(0,a.compareLocations)(V.index,ie)&&S(be)?x(x({},be),V.style):be;const Pe=t=>{var n,r;if(null==(n=e.plugin)?void 0:n.inlines)for(const n of e.plugin.inlines){const o=null==(r=null==n?void 0:n.render)?void 0:r.call(n,t,e.resizeOffset);if(void 0!==o)return o}},we=(t,n)=>{if(e.readOnly)return;const r=[];for(const e of t)if("string"==typeof e){const t=b(x({},be),{text:e,kind:void 0});V?r.push(x(x({},t),V.style)):r.push(t)}else r.push(x(x({},be),e));Y(r,n)},ke=(e=!1)=>{var t;if(!e&&$)return ne(void 0),void oe($.min);if(e&&void 0===te&&ne(ie),Ne=0;e--){const t=U.current.rows[e];if(t.y+t.height/2{var t,n;if(!e&&$)return ne(void 0),void oe($.max);e&&void 0===te&&ne(ie);const r=null==(t=U.current)?void 0:t.rows.find((e=>e.y>Ne+Ue/2)),o=r?r.y+r.height/2:Ne+1.5*Ue;oe(Te({x:Fe-(null!=(n=null==F?void 0:F.width)?n:0)/2,y:o+Q}))},Se=t=>{me(t,ke,_e,(()=>{if((0,u.metaKeyIfMacElseCtrlKey)(t)){if("v"===t.key)return e.readOnly||navigator.clipboard.readText().then((e=>{if(e)try{const t=JSON.parse(e);1===t.length?Y(t[0].children):X(t)}catch(t){Y(e.split("").map((e=>({text:e,kind:void 0}))))}})),void t.preventDefault();if("c"===t.key||"x"===t.key){const e=K("x"===t.key);if(e){const t=(0,i.renderToStaticMarkup)(o.createElement(o.Fragment,null,E(e,(()=>!1),Pe)));navigator.clipboard.write([new ClipboardItem({"text/plain":new Blob([JSON.stringify(e)],{type:"text/plain"}),"text/html":new Blob([t],{type:"text/html"})})])}return}}else 1===t.key.length&&we(t.key)}))},Re=e=>{var t,n,r;const o=null==(t=z.current)?void 0:t.getBoundingClientRect();return{x:e.clientX-(null!=(n=null==o?void 0:o.left)?n:0),y:e.clientY-(null!=(r=null==o?void 0:o.top)?r:0)}},Te=t=>{if(j(!1),U.current){let n;for(let r=0;r=a.x&&t.y>=a.y&&t.x<=a.x+a.width&&t.y<=a.y+a.height)return S(e.state[r].children[i])&&t.x{if($&&U.current)for(let t=0;t=0&&(0,a.compareLocations)(i,$.max)<0&&e.x>o.x&&e.y>o.y&&e.x{ge(e,Re,Te,Ae)},Me=e=>{he(e,Re,Te,Q,De,Be)},Ie=e=>{Me(e),fe()};o.useLayoutEffect((()=>{z.current&&(U.current=P(z.current.children))}),[e.state,z.current]),o.useEffect((()=>{var e,t;if(!U.current)return;const n=U.current.cells[null!=(e=null==J?void 0:J[0])?e:ce];let r;if(n){const e=null!=(t=null==J?void 0:J[1])?t:le;if(0===e)r=n[0];else if(G){const t=n[e-1];t&&(r=b(x({},t),{x:t.x+t.width}))}else r=n[e]}N(r)}),[U.current,ce,le,J,G]);const Oe=null==(t=z.current)?void 0:t.offsetHeight;Oe&&ae{var t,n;(0,s.equals)(null==(t=Ge.current)?void 0:t[0],ie[0])&&(0,s.equals)(null==(n=Ge.current)?void 0:n[1],ie[1])&&(0,s.equals)(je.current,Ne)||e.autoHeight||(Ne+Q<0&&ee(-Ne),Ge.current=ie,je.current=Ne)}),[ie,Ne,Q]);const Ve=E(e.state,pe,Pe);return o.useEffect((()=>{V&&0!==(0,a.compareLocations)(ie,V.index)&&W(void 0)}),[ie,V,W]),{currentContent:Ee,currentBlock:xe,currentContentLayout:Ce,updateSelection:t=>{if($)e.setState((e=>{for(let n=$.min[0];n<=$.max[0];n++){const r=e[n],o=n===$.min[0]?$.min[1]:0,i=n===$.max[0]?$.max[1]:r.children.length;if(0!==o||i!==r.children.length)for(let e=o;e{t(e)}))})}},updateTextInline:t=>{var n;if(!(null==(n=e.plugin)?void 0:n.textInlines))return;const r=e.plugin.textInlines[t];r&&$&&e.setState((e=>{var n;for(let o=$.min[0];o<=$.max[0];o++){const i=e[o],a=o===$.min[0]?$.min[1]:0,s=o===$.max[0]?$.max[1]:i.children.length,c=r.fontSize?r.fontSize*(null!=(n=i.fontSize)?n:k):void 0;for(let e=a;e{var n;if(!(null==(n=e.plugin)?void 0:n.blocks))return;const r=e.plugin.blocks[t];if(!r)return;if(r.void)return void X([b(x({},r),{type:t,children:[]})]);const o=e=>{var n,o,i;e.type=t;const a=k*(null!=(n=r.fontSize)?n:1);e.blockStart=a*(null!=(o=r.blockStart)?o:0),e.blockEnd=a*(null!=(i=r.blockEnd)?i:0),e.inlineStart=r.inlineStart,e.listStyleType=r.listStyleType,L(e,r),e.fontSize=r.fontSize?a:void 0};$?e.setState((e=>{const t=$.min[0],n=$.max[0];for(let r=t;r<=n;r++)o(e[r])})):e.setState((e=>{const t=ie[0];o(e[t])}))},updateCurrentContent:t=>{e.setState((e=>{const n=ve(e);n.currentContent&&t(n.currentContent)}))},inputText:we,layoutResult:U.current,cursor:{x:Fe,y:Ne+Q,height:Ue},inputContent:X,location:ie,scrollY:Q,renderEditor:t=>o.createElement("div",{style:x({position:"relative",width:e.width+"px",height:ue+"px",border:"1px solid black",clipPath:"inset(0px 0px)"},e.style),onMouseLeave:Ie,ref:Z},o.createElement(c.Cursor,{ref:re,onKeyDown:Se,onCompositionEnd:e=>{we(e.data,q()),re.current&&(re.current.value="")},onBlur:de,onFocus:e.onFocus,readOnly:e.readOnly,style:F?{left:F.x+"px",top:F.y+Q+"px",height:F.height+"px"}:void 0}),o.createElement("div",{style:{width:e.width+"px",position:"absolute",fontFamily:_,fontSize:k+"px",top:`${Q}px`,whiteSpace:"pre-wrap",overflowWrap:"break-word"},onMouseDown:Le,onMouseMove:Me,onMouseUp:Ie,onDoubleClick:t=>{const[n,r]=Te(Re(t)),{newSelectionStart:o,newLocation:i}=(0,a.getWordByDoubleClick)(e.state[n].children,r,(e=>S(e)?e.text:void 0));void 0!==o&&ne([n,o]),void 0!==i&&oe([n,i])},ref:z},Ve),t,!e.autoHeight&&o.createElement(l.Scrollbar,{value:Q,type:"vertical",containerSize:e.height,contentSize:ae,onChange:ee,align:"head"}))}}function E(e,t,n){const r=[],i=new s.Merger((e=>{const t=T(e.type.block),n=e.target.map((e=>o.createElement("li",{key:e.index},e.children)));r.push(o.createElement(e.type.block.type,{key:e.type.index,style:t},n))}),((e,t)=>e.block.type===t.block.type),(e=>({index:e.index,children:A(e.block,(n=>t([e.index,n])),n)})));for(let a=0;at([a,e])),n);"ul"!==s.type&&"ol"!==s.type?(i.flushLast(),r.push(o.createElement(s.type,{key:a,style:c},l))):i.push({index:a,block:s})}return r}function P(e,t=0){const n={rows:[],cells:[]},r=new s.Reducer((e=>n.rows.push(e)),((e,t)=>t.y>=e.y+e.height),((e,t)=>{t.ye.y+e.height&&(e.height=t.y+t.height-e.y)}));for(let o=0;o0&&(t.textDecoration=n.join(" ")),t}function T(e){const t=R(e);return e.blockStart&&(t.marginBlockStart=`${e.blockStart}px`),e.blockEnd&&(t.marginBlockEnd=`${e.blockEnd}px`),e.inlineStart&&(t.paddingInlineStart=`${e.inlineStart}px`),t}function A(e,t,n){const r=[];return e.children.forEach(((e,i)=>{const a=function(e,t,n,r){var i;const a=null==r?void 0:r(e);if(a)return o.cloneElement(a,{key:t});if(S(e)){const r=R(e);return o.createElement(null!=(i=e.type)?i:"span",{key:t,style:b(x({},r),{backgroundColor:n?"#B3D6FD":r.backgroundColor})},e.text)}}(e,i,t(i),n);a&&r.push(a)})),r.push(o.createElement("span",{key:-1},"​")),r}function L(e,t){e.bold=t.bold,e.italic=t.italic,e.fontFamily=t.fontFamily,e.underline=t.underline,e.passThrough=t.passThrough,e.color=t.color,e.backgroundColor=t.backgroundColor,e.verticalAlign=t.verticalAlign}},9436:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useInterval:()=>o});var r=n(3696);function o(e,t){const n=r.useRef();r.useEffect((()=>{n.current=e}),[e]),r.useEffect((()=>{const e=setInterval((()=>{var e;null==(e=n.current)||e.call(n)}),t);return()=>clearInterval(e)}),[t])}},6278:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useLastValidValue:()=>o});var r=n(3696);function o(e,t,n=e){const o=r.useRef(n);return t(e)&&(o.current=e),o.current}},6545:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useLineAlignment:()=>o});var r=n(3696);function o(e){const[t,n]=r.useState(),[o,i]=r.useState();return{lineAlignmentX:t,lineAlignmentY:o,changeOffsetByLineAlignment(t,r,o,a,s){if(r.includes("bottom")){const n=o.y+o.height+t.y+t.height,r=s.find((t=>Math.abs(t-n)Math.abs(t-n)Math.abs(t-r)Math.abs(t-r){"use strict";n.r(t),n.d(t,{useLocalStorageState:()=>o});var r=n(3696);function o(e,t){const[n,o]=r.useState((()=>{if(!e)return t;const n=localStorage.getItem(e);if(n)try{return JSON.parse(n)}catch(e){return t}return t})),i=r.useRef(n);return r.useEffect((()=>{e&&localStorage.setItem(e,JSON.stringify(n))}),[n,e]),[n,o,i.current]}},8454:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useMinimap:()=>a});var r=n(3696),o=n.n(r),i=n(5773);function a(e){const[t,n]=o().useState();if(!t)return{setMinimapTransform:n};const r=t.bounding.end.x-t.bounding.start.x,a=t.bounding.end.y-t.bounding.start.y,s=Math.min(e.width/r,e.height/a),c=Math.max(0,(e.width-s*r)/2),l=Math.max(0,(e.height-s*a)/2);return{setMinimapTransform:n,xOffset:c,yOffset:l,ratio:s,contentWidth:r,contentHeight:a,getMinimapPosition(n){let r={x:t.bounding.start.x+(n.nativeEvent.offsetX-c)/s,y:t.bounding.start.y+(n.nativeEvent.offsetY-l)/s};return e.viewport.rotate&&(r=(0,i.rotatePosition)(r,{x:0,y:0},e.viewport.rotate)),r},minimap:o().createElement("div",{style:{position:"absolute",left:"1px",bottom:"1px",width:`${e.width}px`,height:`${e.height}px`,clipPath:"inset(0)",border:"1px solid blue"}},e.children(t),o().createElement("div",{style:{position:"absolute",border:"1px solid red",left:`${c+s*(e.viewport.center.x-e.viewport.width/2-t.bounding.start.x)}px`,top:`${l+s*(e.viewport.center.y-e.viewport.height/2-t.bounding.start.y)}px`,width:s*e.viewport.width+"px",height:s*e.viewport.height+"px",cursor:"default",rotate:e.viewport.rotate?`${e.viewport.rotate}rad`:void 0,pointerEvents:"none"}}))}}},9055:(e,t,n)=>{"use strict";n.r(t),n.d(t,{getByPath:()=>h,getItemByPath:()=>m,prependPatchPath:()=>g,usePartialEdit:()=>f});var r=n(3696),o=Object.defineProperty,i=Object.defineProperties,a=Object.getOwnPropertyDescriptors,s=Object.getOwnPropertySymbols,c=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,u=(e,t,n)=>t in e?o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,p=(e,t)=>{for(var n in t||(t={}))c.call(t,n)&&u(e,n,t[n]);if(s)for(var n of s(t))l.call(t,n)&&u(e,n,t[n]);return e},d=(e,t)=>i(e,a(t));function f(e,t){const[n,o]=r.useState();return{editingContent:h(e,n),setEditingContentPath:n=>{var r;null==(r=null==t?void 0:t.onEditingContentPathChange)||r.call(t,h(e,n)),o(n)},prependPatchPath:(e,t)=>g(g(e,t),n),trimPatchPath:e=>function(e,t){return t&&t.length>0?e.map((e=>d(p({},e),{path:e.path.slice(t.length)}))):e}(e,n),getContentByPath:e=>h(e,n)}}function g(e,t){return t&&t.length>0?e.map((e=>d(p({},e),{path:[...t,...e.path]}))):e}function h(e,t){return t?m(e,t):e}function m(e,t){let n=e;for(const e of t)n=n[e];return n}},2931:(e,t,n)=>{"use strict";n.r(t),n.d(t,{usePatchBasedUndoRedo:()=>a});var r=n(3696),o=n(8662),i=(e,t,n)=>new Promise(((r,o)=>{var i=e=>{try{s(n.next(e))}catch(e){o(e)}},a=e=>{try{s(n.throw(e))}catch(e){o(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(i,a);s((n=n.apply(e,t)).next())}));function a(e,t,n){const[a,s]=r.useState({state:e,patchIndex:-1,patches:[]}),c=function(e,n){for(let r=e;r>=0;r--)if(n[r][2]===t)return r;return-1/0}(a.patchIndex,a.patches),l=function(e,n){for(let r=e;r=0,p=l{var i;const c=(0,o.applyPatches)(a.state,e);if(!1===(null==(i=null==n?void 0:n.onChange)?void 0:i.call(n,{patches:e,oldState:a.state,newState:c})))return a.state;const l=a.patchIndex+1;return s((0,o.produce)(a,(n=>{n.patches.splice(l,n.patches.length,[e,t,(0,o.castDraft)(r)]),n.patchIndex=l,n.state=(0,o.castDraft)(c)}))),c},f=(e,r)=>i(this,null,(function*(){var o;const i=yield null==(o=null==n?void 0:n.onApplyPatchesFromSelf)?void 0:o.call(n,e,r);return i&&(e=i[0],r=i[1]),d(e,r,t)}));return{state:a.state,applyPatchFromOtherOperators:d,applyPatchFromSelf:f,setState:e=>(0,o.produce)(a.state,e,((e,t)=>{0!==e.length&&f(e,t)})),canUndo:u,canRedo:p,undo:e=>i(this,null,(function*(){var t,r;if(null==e||e.preventDefault(),u){let[e,i]=a.patches[c];const l=yield null==(t=null==n?void 0:n.onApplyPatchesFromSelf)?void 0:t.call(n,i,e);l&&(i=l[0],e=l[1],a.patches[c][0]=e,a.patches[c][1]=i);const u=(0,o.applyPatches)(a.state,i);if(!1===(null==(r=null==n?void 0:n.onChange)?void 0:r.call(n,{patches:i,oldState:a.state,newState:u})))return;s((0,o.produce)(a,(e=>{e.patchIndex=c-1,e.state=(0,o.castDraft)(u)})))}})),redo:e=>i(this,null,(function*(){var t,r;if(null==e||e.preventDefault(),p){let[e,i]=a.patches[l];const u=yield null==(t=null==n?void 0:n.onApplyPatchesFromSelf)?void 0:t.call(n,e,i);u&&(e=u[0],i=u[1],a.patches[c][0]=e,a.patches[c][1]=i);const p=(0,o.applyPatches)(a.state,e);if(!1===(null==(r=null==n?void 0:n.onChange)?void 0:r.call(n,{patches:e,oldState:a.state,newState:p})))return;s((0,o.produce)(a,(e=>{e.patchIndex=l,e.state=(0,o.castDraft)(p)})))}})),stateIndex:a.patchIndex}}},2244:(e,t,n)=>{"use strict";n.r(t),n.d(t,{allSnapTypes:()=>S,usePointSnap:()=>_});var r=n(3696),o=n(8638),i=n(5773),a=n(5717),s=n(7486),c=n(2792),l=n(1796),u=n(8392),p=n(8230),d=n(8831),f=n(1715),g=n(2298),h=n(5689),m=n(2986),y=Object.defineProperty,v=Object.defineProperties,x=Object.getOwnPropertyDescriptors,b=Object.getOwnPropertySymbols,C=Object.prototype.hasOwnProperty,E=Object.prototype.propertyIsEnumerable,P=(e,t,n)=>t in e?y(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,w=(e,t)=>{for(var n in t||(t={}))C.call(t,n)&&P(e,n,t[n]);if(b)for(var n of b(t))E.call(t,n)&&P(e,n,t[n]);return e},k=(e,t)=>v(e,x(t));function _(e,t,n,y,v,x=5,b=e=>({x:Math.round(e.x),y:Math.round(e.y)}),C=e=>{const t=45*Math.round(e/45);if(t!==e&&Math.abs(t-e)<5)return t}){const[E,P]=r.useState();r.useEffect((()=>{!1===e&&P(void 0)}),[e]);const _=e=>v?{position:{x:e.x+v.x,y:e.y+v.y}}:{position:e},S=(e,t,n,r)=>{var o;const i=null==(o=null==e?void 0:e.getGeometries)?void 0:o.call(e,t,r).lines;if(!i)return;const s=(0,a.getGeometryLinesParamAtPoint)(n,i);return void 0!==s?{target:{snapIndex:-1,content:t,param:s}}:void 0},R=(e,t)=>e?k(w({},t),{position:e(t.position)}):t,T=(e,t,n)=>{P(t&&e?k(w(w({},t),e(t)),{startPosition:n}):t?k(w({},t),{startPosition:n}):void 0)};return{snapPoint:E,getSnapAssistentContents(e,t,n,r){const o=[],i=[];E&&(i.push(E),v&&i.push(k(w({},E),{x:E.x+v.x,y:E.y+v.y})));for(const a of i){const i=2*x;"center"===a.type?o.push(e({x:a.x,y:a.y,r:i})):"endpoint"===a.type?o.push(t({x:a.x,y:a.y,width:2*i,height:2*i})):"midpoint"===a.type?o.push(n([{x:a.x-i,y:a.y+i},{x:a.x+i,y:a.y+i},{x:a.x,y:a.y-i},{x:a.x-i,y:a.y+i}])):"intersection"===a.type?o.push(n([{x:a.x-i,y:a.y-i},{x:a.x+i,y:a.y+i}]),n([{x:a.x-i,y:a.y+i},{x:a.x+i,y:a.y-i}])):"nearest"===a.type?o.push(n([{x:a.x-i,y:a.y-i},{x:a.x+i,y:a.y+i},{x:a.x-i,y:a.y+i},{x:a.x+i,y:a.y-i},{x:a.x-i,y:a.y-i}])):"perpendicular"===a.type?(o.push(n([{x:a.x-1.5*i,y:a.y},{x:a.x+1.5*i,y:a.y}])),o.push(n([{x:a.x,y:a.y-1.5*i},{x:a.x,y:a.y}]))):"tangency"===a.type?(o.push(e({x:a.x,y:a.y+.5*i,r:i})),o.push(n([{x:a.x-1.5*i,y:a.y-.5*i},{x:a.x+1.5*i,y:a.y-.5*i}]))):"grid"===a.type?o.push(n([{x:a.x-i,y:a.y},{x:a.x+i,y:a.y}]),n([{x:a.x,y:a.y+i},{x:a.x,y:a.y-i}])):"angle"===a.type&&r&&a.startPosition&&o.push(r({x:a.startPosition.x,y:a.startPosition.y,angle:(0,f.radianToAngle)((0,f.getTwoPointsRadian)(a,a.startPosition))}))}return o},getSnapPoint(r,a,v,E,P){var A,L;if(!e)return T(P,void 0),R(P,_(r));let M=a;v&&(M=v({start:{x:r.x-x,y:r.y-x},end:{x:r.x+x,y:r.y+x}}));for(const e of M){if(!e)continue;const t=null==(L=null==(A=y(e))?void 0:A.getSnapPoints)?void 0:L.call(A,e,a);if(t)for(let o=0;o{"use strict";n.r(t),n.d(t,{useRefState:()=>i,useRefState2:()=>a});var r=n(3696),o=n.n(r);function i(e){const[t,n]=o().useState(e),r=o().useRef(e);return[t,e=>{n(e),r.current=e},r]}function a(){const[e,t]=o().useState(),n=o().useRef();return[e,e=>{t(e),n.current=e},n]}},7923:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useRegionAlignment:()=>o});var r=n(3696);function o(e){const[t,n]=r.useState(),[o,i]=r.useState();return{regionAlignmentX:t,regionAlignmentY:o,changeOffsetByRegionAlignment(t,r,o){const a=function(e,t,n,r){const o=n.x+e.x,i=n.y+e.y,a={};for(const{field:e,value:s,sizeField:c}of[{field:"x",value:o,sizeField:"width"},{field:"y",value:i,sizeField:"height"}]){let o=r.find((n=>Math.abs(n[e]-s)Math.abs(n[e]+n[c]/2-i)Math.abs(n[e]+n[c]-i){"use strict";n.r(t),n.d(t,{useSelectBeforeOperate:()=>i});var r=n(3696),o=n(7332);function i(e,t,n){const{selected:i,isSelected:a,addSelection:s,removeSelection:c,filterSelection:l,setSelected:u,onSelectedKeyDown:p}=(0,o.useSelected)(n),[d,f]=r.useState({type:"select",select:e}),g=()=>{f({type:"select",select:e})},h=(e=i)=>{if("select then operate"===d.type){if(t(d.operate,e))return;f({type:"operate",operate:d.operate})}};let m="";"select then operate"===d.type&&(m=void 0!==d.select.count?`${i.length} selected, extra ${d.select.count-i.length} targets are needed`:i.length?`${i.length} selected, press Enter to finish selection`:"select targets");const y=e=>{var t,n,r;return!a(e)&&"operate"!==d.type&&(null==(r=null==(n=(t=d.select).selectable)?void 0:n.call(t,e))||r)};return{message:m,selected:i,isSelected:a,addSelection(...e){s(e,"operate"!==d.type?d.select.count:void 0,h,y)},removeSelection(...e){c(e)},setSelected:u,filterSelection:l,isSelectable:y,operations:d,executeOperation:t,startNextOperation:h,resetOperation:g,onSelectBeforeOperateKeyDown(e){"Escape"===e.key?g():"Enter"===e.key&&h(),p(e)},selectBeforeOperate(e,t){f({type:"select then operate",select:e,operate:t})},operate(e){f({type:"operate",operate:e})}}}},7332:(e,t,n)=>{"use strict";n.r(t),n.d(t,{isSamePath:()=>a,isSelected:()=>i,useSelected:()=>o});var r=n(3696);function o(e){const[t,n]=r.useState([]);return r.useEffect((()=>{var n;null==(n=null==e?void 0:e.onChange)||n.call(e,t)}),[t]),{selected:t,filterSelection:(r,o=(null==e?void 0:e.maxCount),i=t)=>{let a=r?i.filter(r):i;return void 0!==o&&(a=a.slice(-o)),n(a),{result:a,needSelect:void 0===o?0===a.length:a.lengthi(e,n),addSelection:(r,o=(null==e?void 0:e.maxCount),s,c)=>{if((r=r.filter((e=>{var n;return!i(e,t)&&(null==(n=null==c?void 0:c(e))||n)&&t.every((t=>!a(t,e)))}))).length>0){let e=[...t,...r];void 0!==o&&(e=e.slice(-o)),n(e),void 0!==o&&o===e.length&&(null==s||s(e))}},removeSelection:e=>{n(t.filter((t=>e.every((e=>!a(e,t))))))},onSelectedKeyDown(e){"Escape"===e.key&&n([])},setSelected(...e){const r=e.filter((e=>void 0!==e));0===r.length&&0===t.length||n(r)}}}function i(e,t){return t.some((t=>a(e,t)))}function a(e,t){if(e&&t){if(e.length!==t.length)return!1;for(let n=0;n{"use strict";n.r(t),n.d(t,{useUndoRedo:()=>i});var r=n(3696),o=n(8662);function i(e,t){const[n,i]=r.useState({states:[e],stateIndex:0}),{stateIndex:a,states:s}=n,c=a>0,l=a{var r;const s=(0,o.produce)(u,e);if(s===u)return u;null==(r=null==t?void 0:t.onChange)||r.call(t,{oldState:u,newState:s});const c=a+1;return i((0,o.produce)(n,(e=>{e.states.splice(c,e.states.length,(0,o.castDraft)(s)),e.stateIndex=c}))),s},canUndo:c,canRedo:l,undo:e=>{var r;null==e||e.preventDefault(),c&&(null==(r=null==t?void 0:t.onChange)||r.call(t,{oldState:u,newState:s[a-1]}),i((0,o.produce)(n,(e=>{e.stateIndex=a-1}))))},redo:e=>{var r;null==e||e.preventDefault(),l&&(null==(r=null==t?void 0:t.onChange)||r.call(t,{oldState:u,newState:s[a+1]}),i((0,o.produce)(n,(e=>{e.stateIndex=a+1}))))},resetHistory:(t=e)=>{i({states:[t],stateIndex:0})}}}},69:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useValueChanged:()=>o});var r=n(3696);function o(e,t){const n=r.useRef(e);n.current!==e&&(t(n.current)||(n.current=e))}},9182:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useWheelScroll:()=>i});var r=n(3696),o=n(7658);function i(e){var t,n,i,a,s,c;const l=null!=(t=null==e?void 0:e.maxOffsetX)?t:-1,u=null!=(n=null==e?void 0:e.maxOffsetY)?n:-1,p=null==e?void 0:e.minX,d=null==e?void 0:e.maxX,f=null==e?void 0:e.minY,g=null==e?void 0:e.maxY,[h,m]=(0,o.useLocalStorageState)(null==e?void 0:e.localStorageXKey,null!=(a=null==(i=null==e?void 0:e.initialPosition)?void 0:i.x)?a:0),[y,v]=(0,o.useLocalStorageState)(null==e?void 0:e.localStorageYKey,null!=(c=null==(s=null==e?void 0:e.initialPosition)?void 0:s.y)?c:0),x=r.useRef(null),b=e=>(void 0!==p&&(e=Math.max(p,e)),void 0!==d&&(e=Math.min(d,e)),l>=0&&(e=Math.max(-l,Math.min(l,e))),e),C=e=>(void 0!==f&&(e=Math.max(f,e)),void 0!==g&&(e=Math.min(g,e)),u>=0&&(e=Math.max(-u,Math.min(u,e))),e);return r.useEffect((()=>{if(!x.current||(null==e?void 0:e.disabled))return;const t=t=>{t.ctrlKey||(t.preventDefault(),(null==e?void 0:e.setXOffset)?e.setXOffset(-t.deltaX):m((e=>b(e-t.deltaX))),(null==e?void 0:e.setYOffset)?e.setYOffset(-t.deltaY):v((e=>C(e-t.deltaY))))};return x.current.addEventListener("wheel",t,{passive:!1}),()=>{var e;null==(e=x.current)||e.removeEventListener("wheel",t)}}),[x.current,b,C,null==e?void 0:e.disabled]),{ref:x,x:h,y,setX:m,setY:v,filterX:b,filterY:C}}},4104:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useWheelZoom:()=>a});var r=n(3696),o=n(7658),i=n(370);function a(e){var t;const[n,a]=(0,o.useLocalStorageState)(null==e?void 0:e.localStorageKey,null!=(t=null==e?void 0:e.initialValue)?t:1),s=r.useRef(null),{min:c,max:l}=(0,i.getDefaultZoomOption)(e);return r.useEffect((()=>{if(!s.current)return;const t=t=>{if(t.ctrlKey){if(t.preventDefault(),null==e?void 0:e.setScaleOffset)return void e.setScaleOffset(Math.exp(-t.deltaY/100),{x:t.clientX,y:t.clientY});a((n=>{var r;const o=Math.min(Math.max(c,n*Math.exp(-t.deltaY/100)),l);return n!==o&&(null==(r=null==e?void 0:e.onChange)||r.call(e,n,o,{x:t.clientX,y:t.clientY})),o}))}};return s.current.addEventListener("wheel",t,{passive:!1}),()=>{var e;null==(e=s.current)||e.removeEventListener("wheel",t)}}),[s.current,null==e?void 0:e.setScaleOffset]),{ref:s,scale:n,setScale:a}}},6421:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useWindowSize:()=>o});var r=n(3696);function o(){const[e,t]=r.useState({width:window.innerWidth,height:window.innerHeight}),n=r.useRef();return window.addEventListener("resize",(()=>{n.current&&clearTimeout(n.current),n.current=setTimeout((()=>{t({width:window.innerWidth,height:window.innerHeight})}),500)})),e}},370:(e,t,n)=>{"use strict";function r(e,t,n){var r;const{min:i,max:a}=o(n),s=null!=(r=null==n?void 0:n.step)?r:1.25,c=n=>{n!==e&&(n>a?n=a:ni,zoomIn:t=>{null==t||t.preventDefault(),c(e*s)},zoomOut:t=>{null==t||t.preventDefault(),c(e/s)}}}function o(e){var t,n;return{min:null!=(t=null==e?void 0:e.min)?t:.1,max:null!=(n=null==e?void 0:e.max)?n:10}}n.r(t),n.d(t,{getDefaultZoomOption:()=>o,useZoom:()=>r})},2202:(e,t,n)=>{"use strict";n.r(t),n.d(t,{createWebgl3DRenderer:()=>E,get3dPolygonTriangles:()=>w,getAxesGraphics:()=>_,getDashedLine:()=>k,getVerticesTriangles:()=>S,reverse3dPosition:()=>P});var r=n(9397),o=n(2087),i=n(670),a=n(3975),s=n(7713),c=n(2301),l=n(7764),u=n(2792),p=n(4206),d=n(360),f=Object.defineProperty,g=Object.defineProperties,h=Object.getOwnPropertyDescriptors,m=Object.getOwnPropertySymbols,y=Object.prototype.hasOwnProperty,v=Object.prototype.propertyIsEnumerable,x=(e,t,n)=>t in e?f(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,b=(e,t)=>{for(var n in t||(t={}))y.call(t,n)&&x(e,n,t[n]);if(m)for(var n of m(t))v.call(t,n)&&x(e,n,t[n]);return e},C=(e,t)=>g(e,h(t));function E(e){const t=e.getContext("webgl",{antialias:!0,stencil:!0,premultipliedAlpha:!1});if(!t)return;t.enable(t.BLEND),t.blendFunc(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA);const n=new l.Lazy((()=>r.createProgramInfo(t,["\n uniform mat4 u_worldViewProjection;\n uniform vec3 u_lightWorldPos;\n uniform mat4 u_world;\n uniform mat4 u_viewInverse;\n uniform mat4 u_worldInverseTranspose;\n\n attribute vec4 position;\n attribute vec3 normal;\n attribute vec2 texcoord;\n\n varying vec4 v_position;\n varying vec2 v_texCoord;\n varying vec3 v_normal;\n varying vec3 v_surfaceToLight;\n varying vec3 v_surfaceToView;\n\n void main() {\n v_texCoord = texcoord;\n v_position = (u_worldViewProjection * position);\n v_normal = (u_worldInverseTranspose * vec4(normal, 0)).xyz;\n v_surfaceToLight = u_lightWorldPos - (u_world * position).xyz;\n v_surfaceToView = (u_viewInverse[3] - (u_world * position)).xyz;\n gl_Position = v_position;\n }\n ","\n precision mediump float;\n\n varying vec4 v_position;\n varying vec2 v_texCoord;\n varying vec3 v_normal;\n varying vec3 v_surfaceToLight;\n varying vec3 v_surfaceToView;\n\n uniform vec4 u_lightColor;\n uniform vec4 u_diffuseMult;\n uniform sampler2D u_diffuse;\n uniform vec4 u_specular;\n uniform float u_shininess;\n uniform float u_specularFactor;\n\n vec4 lit(float l ,float h, float m) {\n return vec4(1.0,\n abs(l),//max(l, 0.0),\n (l > 0.0) ? pow(max(0.0, h), m) : 0.0,\n 1.0);\n }\n\n void main() {\n vec4 diffuseColor = texture2D(u_diffuse, v_texCoord) * u_diffuseMult;\n vec3 normal = normalize(v_normal);\n vec3 surfaceToLight = normalize(v_surfaceToLight);\n vec3 surfaceToView = normalize(v_surfaceToView);\n vec3 halfVector = normalize(surfaceToLight + surfaceToView);\n vec4 litR = lit(dot(normal, surfaceToLight),\n dot(normal, halfVector), u_shininess);\n vec4 outColor = vec4((\n u_lightColor * (diffuseColor * litR.y +\n u_specular * litR.z * u_specularFactor)).rgb,\n diffuseColor.a);\n gl_FragColor = outColor;\n }"]))),o=new l.Lazy((()=>r.createProgramInfo(t,["\n uniform mat4 u_worldViewProjection;\n attribute vec4 position;\n\n void main() {\n gl_Position = u_worldViewProjection * position;\n }\n ","\n precision mediump float;\n uniform vec4 u_diffuseMult;\n\n void main() {\n gl_FragColor = u_diffuseMult;\n }"]))),c=new l.Lazy((()=>r.createProgramInfo(t,["\n uniform mat4 u_worldViewProjection;\n\n attribute vec4 position;\n attribute vec2 texcoord;\n\n varying vec2 v_texCoord;\n\n void main() {\n v_texCoord = texcoord;\n gl_Position = u_worldViewProjection * position;\n }\n ","\n precision mediump float;\n\n varying vec2 v_texCoord;\n\n uniform float u_threshhold;\n uniform vec4 u_pickColor;\n uniform vec4 u_diffuseMult;\n uniform sampler2D u_diffuse;\n\n void main() {\n vec4 diffuseColor = texture2D(u_diffuse, v_texCoord) * u_diffuseMult;\n if (diffuseColor.a <= u_threshhold) {\n discard;\n }\n gl_FragColor = u_pickColor;\n }\n "]))),f=r.createTexture(t,{min:t.NEAREST,mag:t.NEAREST,src:[255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255]}),g=new s.WeakmapCache,h=r.createFramebufferInfo(t);let m,y=[];const v=(n,o,i=()=>!0)=>{const s=e.getBoundingClientRect(),c=e.clientWidth,l=e.clientHeight,u=(n-s.left)*t.canvas.width/c|0,p=t.canvas.height-((o-s.top)*t.canvas.height/l|0)-1;r.resizeFramebufferInfo(t,h),r.bindFramebufferInfo(t,h),t.clearColor(1,1,1,1),t.enable(t.DEPTH_TEST),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT|t.STENCIL_BUFFER_BIT),r.drawObjectList(t,y.filter((e=>!!e&&i(e.graphic,e.index))).map((e=>e.drawObject)));const d=new Uint8Array(4);t.readPixels(u,p,1,1,t.RGBA,t.UNSIGNED_BYTE,d);const f=(0,a.pixelColorToColorNumber)(d);return 16777215===f?void 0:f},x=(t,n,r,o,i)=>{const a=P(t,n,e,i);return"number"!=typeof o?(0,p.getLineAndPlaneIntersectionPoint)([r,a],o):(0,p.getLineAndZPlaneIntersectionPoint)([r,a],o)};return{render:(i,{eye:s,up:l,fov:u,near:p,far:h,target:v},x,E)=>{r.resizeCanvasToDisplaySize(e),r.bindFramebufferInfo(t,null),t.viewport(0,0,t.canvas.width,t.canvas.height),t.enable(t.DEPTH_TEST),t.clearColor(...E),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT);const P=r.m4.perspective(u,e.clientWidth/e.clientHeight,p,h),k=r.m4.lookAt(s,v,l),_=r.m4.multiply(P,r.m4.inverse(k)),S={u_lightWorldPos:x.position,u_lightColor:x.color,u_specular:x.specular,u_shininess:x.shininess,u_specularFactor:x.specularFactor,u_diffuse:f,u_viewInverse:k,u_threshhold:.1};m=r.m4.inverse(_);const R=[];y=[],i.forEach(((e,i)=>{if(!e)return void y.push(void 0);let s,l=r.m4.identity();if(e.rotateX&&(l=r.m4.rotateX(l,e.rotateX)),e.rotateY&&(l=r.m4.rotateY(l,e.rotateY)),e.rotateZ&&(l=r.m4.rotateZ(l,e.rotateZ)),e.position&&(l=r.m4.translate(l,e.position)),e.direction){const t=(0,d.rotateToDirection)(e.direction);t&&(l=r.m4.axisRotate(l,t.axis,t.radian))}s="lines"===e.geometry.type||"line strip"===e.geometry.type||"triangles"===e.geometry.type||"triangle strip"===e.geometry.type||"polygon"===e.geometry.type?o.instance:n.instance;const u=r.m4.multiply(_,l),p={programInfo:s,bufferInfo:g.get(e.geometry,(()=>"sphere"===e.geometry.type?r.primitives.createSphereBufferInfo(t,e.geometry.radius,72,36):"cube"===e.geometry.type?r.primitives.createCubeBufferInfo(t,e.geometry.size):"cylinder"===e.geometry.type?r.primitives.createCylinderBufferInfo(t,e.geometry.radius,e.geometry.height,36,4):"cone"===e.geometry.type?r.primitives.createTruncatedConeBufferInfo(t,e.geometry.bottomRadius,e.geometry.topRadius,e.geometry.height,36,4):"polygon"===e.geometry.type?r.createBufferInfoFromArrays(t,{position:{numComponents:3,data:w(e.geometry.points)}}):"vertices"===e.geometry.type?r.createBufferInfoFromArrays(t,e.geometry.vertices):r.createBufferInfoFromArrays(t,{position:{numComponents:3,data:e.geometry.points}}))),type:"lines"===e.geometry.type?t.LINES:"line strip"===e.geometry.type?t.LINE_STRIP:"triangle strip"===e.geometry.type?t.TRIANGLE_STRIP:t.TRIANGLES,uniforms:C(b({},S),{u_diffuseMult:e.color,u_world:l,u_worldInverseTranspose:r.m4.transpose(r.m4.inverse(l)),u_worldViewProjection:u,u_pickColor:(0,a.colorNumberToVec)(i)})};R.push(p),y.push({graphic:e,index:i,drawObject:C(b({},p),{programInfo:c.instance}),reversedProjection:r.m4.inverse(u)})})),r.drawObjectList(t,R)},pick:v,pickPoint:(e,t,n,r,o=()=>!0)=>{const a=v(e,t,o);if(void 0!==a){const o=y.find((e=>e&&e.index===a));if(o&&"vertices"===o.graphic.geometry.type){const a=x(e,t,n,r,o.reversedProjection);if(!a)return;const s=new i.geom.Line(n,a),c=i.geom.Intersect.curveAndSurface(s,o.graphic.geometry.nurbs,.001);if(c.length>0){const e=(0,u.maximumBy)(c,(e=>e.surfacePoint[2])).surfacePoint;return[e[0],e[1],e[2]]}}}},getTarget:x,canvas:e,get reversedProjection(){return m}}}function P(e,t,n,o){const i=n.getBoundingClientRect(),a=(e-i.left)/n.clientWidth*2-1,s=-((t-i.top)/n.clientHeight*2-1),c=r.m4.transformPoint(o,[a,s,1]);return[c[0],c[1],c[2]]}function w(e){const t=(0,o.default)(e,void 0,3),n=[];for(let r=0;ri){s.push(c,t);break}const o=r.v3.add(e,r.v3.mulScalar(a,l));if(s.push(c,[o[0],o[1],o[2]]),l+=n,l>=i)break;const u=r.v3.add(e,r.v3.mulScalar(a,l));c=[u[0],u[1],u[2]]}return s}const _=(e=100)=>[{geometry:{type:"lines",points:[0,0,0,e,0,0]},color:[1,0,0,1]},{geometry:{type:"lines",points:[0,0,0,0,e,0]},color:[0,1,0,1]},{geometry:{type:"lines",points:[0,0,0,0,0,e]},color:[0,0,1,1]}];function S(e,t){const n=[],r=t?e.position.map(((e,n)=>e+t[n%3])):e.position;for(let t=0;t{"use strict";n.r(t),n.d(t,{createWebgpu3DRenderer:()=>d});var r=n(9397),o=n(7713),i=n(2202),a=n(7764),s=n(4840),c=n(3975),l=n(4206),u=n(360),p=(e,t,n)=>new Promise(((r,o)=>{var i=e=>{try{s(n.next(e))}catch(e){o(e)}},a=e=>{try{s(n.throw(e))}catch(e){o(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(i,a);s((n=n.apply(e,t)).next())}));function d(e){return p(this,null,(function*(){if(!navigator.gpu)return;const t=e.getContext("webgpu");if(!t)return;const n=yield navigator.gpu.requestAdapter();if(!n)return;const d=yield n.requestDevice(),h=navigator.gpu.getPreferredCanvasFormat();t.configure({device:d,format:h});const m={color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha"},alpha:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha"}},y=new a.Lazy((()=>d.createShaderModule({code:"struct Uniforms {\n worldViewProjection: mat4x4f,\n lightWorldPos: vec3f,\n world: mat4x4f,\n viewInverse: mat4x4f,\n worldInverseTranspose: mat4x4f,\n lightColor: vec4f,\n diffuseMult: vec4f,\n shininess: f32,\n specular: vec4f,\n specularFactor: f32,\n };\n @group(0) @binding(0) var uniforms: Uniforms;\n @group(0) @binding(1) var mySampler: sampler;\n @group(0) @binding(2) var myTexture: texture_2d;\n\n struct VertexInput {\n @location(0) position: vec4f,\n @location(1) normal: vec3f,\n @location(2) texcoord: vec2f,\n };\n\n struct VertexOutput {\n @builtin(position) position: vec4f,\n @location(0) texcoord: vec2f,\n @location(1) normal: vec3f,\n @location(2) surfaceToLight: vec3f,\n @location(3) surfaceToView: vec3f,\n };\n\n fn lit(l: f32, h: f32, m: f32) -> vec4f {\n var a: f32 = 0.0;\n if l > 0.0 {\n a = pow(max(0.0, h), m);\n }\n return vec4f(1.0, abs(l), a, 1.0);\n }\n \n @vertex\n fn vertex_main(v: VertexInput) -> VertexOutput {\n var vsOut: VertexOutput;\n vsOut.position = uniforms.worldViewProjection * v.position;\n vsOut.texcoord = v.texcoord;\n vsOut.normal = (uniforms.worldInverseTranspose * vec4f(v.normal, 0.0)).xyz;\n vsOut.surfaceToLight = uniforms.lightWorldPos - (uniforms.world * v.position).xyz;\n vsOut.surfaceToView = (uniforms.viewInverse[3] - (uniforms.world * v.position)).xyz;\n return vsOut;\n }\n\n @fragment\n fn fragment_main(v: VertexOutput) -> @location(0) vec4f {\n var diffuseColor = textureSample(myTexture, mySampler, v.texcoord) * uniforms.diffuseMult;\n var normal = normalize(v.normal);\n var surfaceToLight = normalize(v.surfaceToLight);\n var surfaceToView = normalize(v.surfaceToView);\n var halfVector = normalize(surfaceToLight + surfaceToView);\n var litR = lit(dot(normal, surfaceToLight), dot(normal, halfVector), uniforms.shininess);\n return vec4((uniforms.lightColor * (diffuseColor * litR.y + uniforms.specular * litR.z * uniforms.specularFactor)).rgb, diffuseColor.a);\n }"}))),v=new a.Lazy((()=>d.createShaderModule({code:"struct Uniforms {\n worldViewProjection: mat4x4f,\n lightWorldPos: vec3f,\n world: mat4x4f,\n viewInverse: mat4x4f,\n worldInverseTranspose: mat4x4f,\n lightColor: vec4f,\n diffuseMult: vec4f,\n shininess: f32,\n specular: vec4f,\n specularFactor: f32,\n };\n @group(0) @binding(0) var uniforms: Uniforms;\n\n @vertex\n fn vertex_main(@location(0) position: vec4f) -> @builtin(position) vec4f\n {\n return uniforms.worldViewProjection * position;\n }\n\n @fragment\n fn fragment_main() -> @location(0) vec4f\n {\n return uniforms.diffuseMult;\n }"}))),x=new a.Lazy((()=>d.createShaderModule({code:"struct Uniforms {\n worldViewProjection: mat4x4f,\n lightWorldPos: vec3f,\n world: mat4x4f,\n viewInverse: mat4x4f,\n worldInverseTranspose: mat4x4f,\n lightColor: vec4f,\n diffuseMult: vec4f,\n shininess: f32,\n specular: vec4f,\n specularFactor: f32,\n pickColor: vec4f,\n threshhold: f32,\n };\n @group(0) @binding(0) var uniforms: Uniforms;\n @group(0) @binding(1) var mySampler: sampler;\n @group(0) @binding(2) var myTexture: texture_2d;\n\n struct VertexInput {\n @location(0) position: vec4f,\n @location(1) texcoord: vec2f,\n };\n\n struct VertexOutput {\n @builtin(position) position: vec4f,\n @location(0) texcoord: vec2f,\n };\n\n @vertex\n fn vertex_main(v: VertexInput) -> VertexOutput {\n var vsOut: VertexOutput;\n vsOut.position = uniforms.worldViewProjection * v.position;\n vsOut.texcoord = v.texcoord;\n return vsOut;\n }\n\n @fragment\n fn fragment_main(v: VertexOutput) -> @location(0) vec4f {\n var diffuseColor = textureSample(myTexture, mySampler, v.texcoord) * uniforms.diffuseMult;\n if (diffuseColor.a <= uniforms.threshhold) {\n discard;\n }\n return uniforms.pickColor;\n }"}))),b=d.createSampler({magFilter:"nearest",minFilter:"nearest"}),C=new a.Lazy((()=>d.createTexture({size:[e.width,e.height],sampleCount:4,format:h,usage:GPUTextureUsage.RENDER_ATTACHMENT})),(e=>e.destroy())),E=new a.Lazy((()=>d.createTexture({size:[e.width,e.height],format:"depth24plus",sampleCount:4,usage:GPUTextureUsage.RENDER_ATTACHMENT})),(e=>e.destroy())),P=d.createTexture({size:[2,2],format:"rgba8unorm",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST});d.queue.writeTexture({texture:P},new Uint8Array([255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255]),{bytesPerRow:8,rowsPerImage:2},{width:2,height:2});const w=new a.Lazy((()=>d.createTexture({size:[e.width,e.height],format:h,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT})),(e=>e.destroy())),k=new o.MapCache,_=new o.MapCache,S=new o.WeakmapCache;let R,T=[];return{render:(n,{eye:o,up:a,fov:l,near:p,far:x,target:_},A,L)=>{e.width===C.instance.width&&e.height===C.instance.height||(C.reset(),E.reset(),w.reset());const M=d.createCommandEncoder(),I=M.beginRenderPass({colorAttachments:[{clearValue:L,loadOp:"clear",storeOp:"store",view:C.instance.createView(),resolveTarget:t.getCurrentTexture().createView()}],depthStencilAttachment:{view:E.instance.createView(),depthClearValue:1,depthLoadOp:"clear",depthStoreOp:"store"}}),O=r.m4.perspective(l,e.clientWidth/e.clientHeight,p,x),D=r.m4.lookAt(o,_,a),B=r.m4.multiply(O,r.m4.inverse(D));T=[],R=r.m4.inverse(B),n.forEach(((e,t)=>{if(!e)return void T.push(void 0);let n=r.m4.identity();if(e.rotateX&&(n=r.m4.rotateX(n,e.rotateX)),e.rotateY&&(n=r.m4.rotateY(n,e.rotateY)),e.rotateZ&&(n=r.m4.rotateZ(n,e.rotateZ)),e.position&&(n=r.m4.translate(n,e.position)),e.direction){const t=(0,u.rotateToDirection)(e.direction);t&&(n=r.m4.axisRotate(n,t.axis,t.radian))}const o=k.get(e.geometry.type,(()=>{let t;const n=[{arrayStride:12,attributes:[{shaderLocation:0,offset:0,format:"float32x3"}]}];return"lines"===e.geometry.type||"line strip"===e.geometry.type||"triangles"===e.geometry.type||"triangle strip"===e.geometry.type||"polygon"===e.geometry.type?t=v.instance:(t=y.instance,n.push({arrayStride:12,attributes:[{shaderLocation:1,offset:0,format:"float32x3"}]},{arrayStride:8,attributes:[{shaderLocation:2,offset:0,format:"float32x2"}]})),d.createRenderPipeline({vertex:{module:t,entryPoint:"vertex_main",buffers:n},fragment:{module:t,entryPoint:"fragment_main",targets:[{format:h,blend:m}]},primitive:{cullMode:"back",topology:"lines"===e.geometry.type?"line-list":"line strip"===e.geometry.type?"line-strip":"triangle strip"===e.geometry.type?"triangle-strip":"triangle-list"},depthStencil:{depthWriteEnabled:!0,depthCompare:"less",format:"depth24plus"},multisample:{count:4},layout:"auto"})}));I.setPipeline(o);const a=r.m4.multiply(B,n),l=[{binding:0,resource:{buffer:(0,s.createUniformsBuffer)(d,[{type:"mat4x4",value:a},{type:"vec3",value:A.position},{type:"mat4x4",value:n},{type:"mat4x4",value:D},{type:"mat4x4",value:r.m4.transpose(r.m4.inverse(n))},{type:"vec4",value:A.color},{type:"vec4",value:e.color},{type:"number",value:A.shininess},{type:"vec4",value:A.specular},{type:"number",value:A.specularFactor},{type:"vec4",value:(0,c.colorNumberToVec)(t)},{type:"number",value:.1}])}}];"lines"!==e.geometry.type&&"line strip"!==e.geometry.type&&"triangles"!==e.geometry.type&&"triangle strip"!==e.geometry.type&&"polygon"!==e.geometry.type&&l.push({binding:1,resource:b},{binding:2,resource:P.createView()}),I.setBindGroup(0,d.createBindGroup({layout:o.getBindGroupLayout(0),entries:l}));const{positionBuffer:p,primaryBuffers:x,count:C}=S.get(e.geometry,(()=>"sphere"===e.geometry.type?g(d,r.primitives.createSphereVertices(e.geometry.radius,72,36)):"cube"===e.geometry.type?g(d,r.primitives.createCubeVertices(e.geometry.size)):"cylinder"===e.geometry.type?g(d,r.primitives.createCylinderVertices(e.geometry.radius,e.geometry.height,36,4)):"cone"===e.geometry.type?g(d,r.primitives.createTruncatedConeVertices(e.geometry.bottomRadius,e.geometry.topRadius,e.geometry.height,36,4)):"polygon"===e.geometry.type?{positionBuffer:f(d,new Float32Array((0,i.get3dPolygonTriangles)(e.geometry.points))),count:e.geometry.points.length/3}:"vertices"===e.geometry.type?g(d,e.geometry.vertices):{positionBuffer:f(d,new Float32Array(e.geometry.points)),count:e.geometry.points.length/3}));I.setVertexBuffer(0,p),x?(I.setVertexBuffer(1,x.normalBuffer),I.setVertexBuffer(2,x.texcoordBuffer),I.setIndexBuffer(x.indicesBuffer,"uint16"),I.drawIndexed(C)):I.draw(C),T.push({graphic:e,index:t,bindGroupEntries:l,positionBuffer:p,primaryBuffers:x,count:C,reversedProjection:r.m4.inverse(a)})})),I.end(),d.queue.submit([M.finish()])},pick:(t,n,r=()=>!0)=>p(this,null,(function*(){const o=e.getBoundingClientRect(),i=e.clientWidth,a=e.clientHeight,s=(t-o.left)*e.width/i|0,l=(n-o.top)*e.height/a|0,u=d.createCommandEncoder(),p=u.beginRenderPass({colorAttachments:[{clearValue:[1,1,1,1],loadOp:"clear",storeOp:"store",view:C.instance.createView(),resolveTarget:w.instance.createView()}],depthStencilAttachment:{view:E.instance.createView(),depthClearValue:1,depthLoadOp:"clear",depthStoreOp:"store"}});for(const e of T)if(e&&r(e.graphic,e.index)){const t=e.graphic,n=_.get(t.geometry.type,(()=>{const e=x.instance;return d.createRenderPipeline({vertex:{module:e,entryPoint:"vertex_main",buffers:[{arrayStride:12,attributes:[{shaderLocation:0,offset:0,format:"float32x3"}]},{arrayStride:8,attributes:[{shaderLocation:1,offset:0,format:"float32x2"}]}]},fragment:{module:e,entryPoint:"fragment_main",targets:[{format:h,blend:m}]},primitive:{cullMode:"back",topology:"lines"===t.geometry.type?"line-list":"line strip"===t.geometry.type?"line-strip":"triangle strip"===t.geometry.type?"triangle-strip":"triangle-list"},depthStencil:{depthWriteEnabled:!0,depthCompare:"less",format:"depth24plus"},multisample:{count:4},layout:"auto"})}));p.setPipeline(n),p.setBindGroup(0,d.createBindGroup({layout:n.getBindGroupLayout(0),entries:e.bindGroupEntries})),p.setVertexBuffer(0,e.positionBuffer),e.primaryBuffers?(p.setVertexBuffer(1,e.primaryBuffers.texcoordBuffer),p.setIndexBuffer(e.primaryBuffers.indicesBuffer,"uint16"),p.drawIndexed(e.count)):p.draw(e.count)}p.end(),d.queue.submit([u.finish()]);const f=d.createCommandEncoder(),g=d.createBuffer({size:4,usage:GPUBufferUsage.MAP_READ|GPUBufferUsage.COPY_DST});f.copyTextureToBuffer({texture:w.instance,origin:{x:s,y:l}},{buffer:g},{width:1,height:1}),d.queue.submit([f.finish()]),yield g.mapAsync(1,0,4);const y=new Uint8Array(g.getMappedRange(0,4)),v=(0,c.pixelColorToColorNumber)([y[2],y[1],y[0]]);return 16777215===v?void 0:v})),getTarget:(t,n,r,o,a)=>{const s=(0,i.reverse3dPosition)(t,n,e,a);return"number"!=typeof o?(0,l.getLineAndPlaneIntersectionPoint)([r,s],o):(0,l.getLineAndZPlaneIntersectionPoint)([r,s],o)},canvas:e,get reversedProjection(){return R}}}))}function f(e,t){const n=e.createBuffer({size:t.byteLength,usage:GPUBufferUsage.VERTEX,mappedAtCreation:!0});return new Float32Array(n.getMappedRange()).set(t),n.unmap(),n}function g(e,t){const{position:n,normal:r,texcoord:o,indices:i}=t,a=f(e,n),s=f(e,r),c=f(e,o),l=function(e,t){const n=e.createBuffer({size:t.byteLength,usage:GPUBufferUsage.INDEX,mappedAtCreation:!0});return new Uint16Array(n.getMappedRange()).set(t),n.unmap(),n}(e,i);return{positionBuffer:a,primaryBuffers:{normalBuffer:s,texcoordBuffer:c,indicesBuffer:l},count:i.length}}},9758:(e,t,n)=>{"use strict";n.r(t);var r=n(7875),o={};for(const e in r)"default"!==e&&(o[e]=()=>r[e]);n.d(t,o);var i=n(1324);o={};for(const e in i)"default"!==e&&(o[e]=()=>i[e]);n.d(t,o)},8831:(e,t,n)=>{"use strict";n.r(t),n.d(t,{AngleRange:()=>k,angleInRange:()=>S,getAngleInRange:()=>_,getAngleRange:()=>P,getAngleRangesDifferences:()=>A,getAngleRangesIntersections:()=>T,getFormattedEndAngle:()=>C,getFormattedStartAngle:()=>b,getLargeArc:()=>E,getNormalizedAngleInRanges:()=>R,isAngleRangeClosed:()=>w,normalizeAngle:()=>m,normalizeAngleInRange:()=>g,normalizeAngleRange:()=>x,normalizeRadian:()=>h,twoAnglesSameDirection:()=>v,twoRadiansSameDirection:()=>y});var r=n(2792),o=n(5569),i=Object.defineProperty,a=Object.defineProperties,s=Object.getOwnPropertyDescriptors,c=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,u=Object.prototype.propertyIsEnumerable,p=(e,t,n)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,d=(e,t)=>{for(var n in t||(t={}))l.call(t,n)&&p(e,n,t[n]);if(c)for(var n of c(t))u.call(t,n)&&p(e,n,t[n]);return e},f=(e,t)=>a(e,s(t));function g(e,t){for(;(0,r.largerThan)(e,t.endAngle);)e-=360;for(;(0,r.lessThan)(e,t.startAngle);)e+=360;return e}function h(e){for(;(0,r.largerThan)(e,Math.PI);)e-=2*Math.PI;for(;(0,r.lessThan)(e,-Math.PI);)e+=2*Math.PI;return e}function m(e){for(;(0,r.largerThan)(e,180);)e-=360;for(;(0,r.lessThan)(e,-180);)e+=360;return e}function y(e,t){const n=h(e-t);return Math.abs(n)(0,r.applyToItems)(e,o,r.getNumberRangeDifference))).flat()}},4061:(e,t,n)=>{"use strict";n.r(t),n.d(t,{getArrow:()=>i});var r=n(5773),o=n(1715);function i(e,t,n,i,a=1){const s=(0,r.getPointByLengthAndDirection)(t,n,e),c=a/2/Math.tan((0,o.angleToRadian)(i));return{arrowPoints:[t,(0,r.rotatePositionByCenter)(s,t,i),(0,r.rotatePositionByCenter)(s,t,-i)],distance:c,endPoint:(0,r.getPointByLengthAndDirection)(t,c,e)}}},5629:(e,t,n)=>{"use strict";n.r(t),n.d(t,{BezierCurve:()=>c,QuadraticCurve:()=>l,getBezierCurveCurvatureAtParam:()=>O,getBezierCurveDerivatives:()=>M,getBezierCurvePercentAtPoint:()=>v,getBezierCurvePercentsAtBezierCurve:()=>B,getBezierCurvePointAtPercent:()=>x,getBezierCurvePoints:()=>b,getBezierCurvePoints3D:()=>C,getBezierSplineControlPointsOfPoints:()=>_,getBezierSplineControlPointsOfPoints3D:()=>S,getBezierSplineCurves:()=>E,getBezierSplinePoints:()=>w,getBezierSplinePoints3D:()=>k,getPartOfBezierCurve:()=>A,getPartOfQuadraticCurve:()=>T,getQuadraticCurveCurvatureAtParam:()=>I,getQuadraticCurveDerivatives:()=>L,getQuadraticCurvePercentAtPoint:()=>f,getQuadraticCurvePercentsAtQuadraticCurve:()=>D,getQuadraticCurvePointAtPercent:()=>g,getQuadraticCurvePoints:()=>h,getQuadraticSplineCurves:()=>P,interpolate2:()=>u,interpolate3:()=>p,interpolate4:()=>d,pointIsOnBezierCurve:()=>y,pointIsOnQuadraticCurve:()=>m});var r=n(1475),o=n(2792),i=n(5773),a=n(8230),s=Math.pow;const c={from:i.Position,cp1:i.Position,cp2:i.Position,to:i.Position},l={from:i.Position,cp:i.Position,to:i.Position};function u(e,t,n){return e+(t-e)*n}function p(e,t,n,r){return u(u(e,t,r),u(t,n,r),r)}function d(e,t,n,r,o){return p(u(e,t,o),u(t,n,o),u(n,r,o),o)}function f({from:{x:e,y:t},cp:{x:n,y:i},to:{x:a,y:s}},c){const l=n-e,u=a-n-l,p=i-t,d=s-i-p,f=l*d-u*p;return(0,o.isZero)(f)?(0,r.calculateEquation2)(u,2*l,e-c.x).filter((e=>(0,o.isSameNumber)(d*e*e+2*p*e+t,c.y,o.delta3)))[0]:-((e-c.x)*d-(t-c.y)*u)/2/f}function g(e,t,n,r){return{x:p(e.x,t.x,n.x,r),y:p(e.y,t.y,n.y,r)}}function h(e,t,n,r){const o=[];for(let i=0;i<=r;i++)o.push(g(e,t,n,i/r));return o}function m(e,{from:{x:t,y:n},cp:{x:i,y:a},to:{x:s,y:c}},l){const u=i-t,p=s-i-u,d=a-n,f=c-a-d;return(0,r.calculateEquation2)(p,2*u,t-e.x).filter((t=>(0,o.isValidPercent)(t,l)&&(0,o.isSameNumber)(f*t*t+2*d*t+n,e.y,o.delta3))).length>0}function y(e,{from:{x:t,y:n},cp1:{x:i,y:a},cp2:{x:s,y:c},to:{x:l,y:u}},p){const d=3*i-t+-3*s+l,f=3*(t-2*i+s),g=3*(i-t),h=3*a-n+-3*c+u,m=3*(n-2*a+c),y=3*(a-n);return(0,r.calculateEquation3)(d,f,g,t-e.x).filter((t=>(0,o.isValidPercent)(t,p)&&(0,o.isSameNumber)(h*t*t*t+m*t*t+y*t+n,e.y,o.delta3))).length>0}function v({from:{x:e,y:t},cp1:{x:n,y:i},cp2:{x:a,y:s},to:{x:c,y:l}},u){const p=3*n-e+-3*a+c,d=3*(e-2*n+a),f=3*(n-e),g=3*i-t+-3*s+l,h=3*(t-2*i+s),m=3*(i-t);return(0,r.calculateEquation3)(p,d,f,e-u.x).filter((e=>(0,o.isSameNumber)(g*e*e*e+h*e*e+m*e+t,u.y,o.delta3)))[0]}function x(e,t,n,r,o){return{x:d(e.x,t.x,n.x,r.x,o),y:d(e.y,t.y,n.y,r.y,o)}}function b(e,t,n,r,o){const i=[];for(let a=0;a<=o;a++)i.push(x(e,t,n,r,a/o));return i}function C(e,t,n,r,o){const i=[];for(let a=0;a<=o;a++){const s=a/o,c=d(e[0],t[0],n[0],r[0],s),l=d(e[1],t[1],n[1],r[1],s),u=d(e[2],t[2],n[2],r[2],s);i.push([c,l,u])}return i}function E(e,t=!0){const n=[];if(!t){const t=e.map((e=>e.x)),r=e.map((e=>e.y));for(let o=1;o{n.push({from:e[r],cp1:t[0],cp2:t[1],to:e[r+1]})})),n}function P(e){const t=[];for(let n=1;nb(e.from,e.cp1,e.cp2,e.to,t))).flat()}function k(e,t){const n=[];return S(e).forEach(((r,o)=>{n.push(...C(e[o],...r,e[o+1],t))})),n}function _(e){const t=R(e.map((e=>e.x))),n=R(e.map((e=>e.y)));return t.p1.map(((e,r)=>[{x:t.p1[r],y:n.p1[r]},{x:t.p2[r],y:n.p2[r]}]))}function S(e){const t=R(e.map((e=>e[0]))),n=R(e.map((e=>e[1]))),r=R(e.map((e=>e[2])));return t.p1.map(((e,o)=>[[t.p1[o],n.p1[o],r.p1[o]],[t.p2[o],n.p2[o],r.p2[o]]]))}function R(e){const t=[],n=[],r=e.length-1,o=[],i=[],a=[],s=[];o[0]=0,i[0]=2,a[0]=1,s[0]=e[0]+2*e[1];for(let t=1;t=0;--e)t[e]=(s[e]-a[e]*t[e+1])/i[e];for(let o=0;o({x:c*s(n,2)+2*a*n+e,y:u*s(n,2)+2*l*n+t}),e=>({x:2*c*e+2*a,y:2*u*e+2*l}),()=>({x:2*c,y:2*u})]}function M({from:{x:e,y:t},cp1:{x:n,y:r},cp2:{x:o,y:i},to:{x:a,y:c}}){const l=3*n-e+-3*o+a,u=3*(e-2*n+o),p=3*(n-e),d=3*r-t+-3*i+c,f=3*(t-2*r+i),g=3*(r-t);return[n=>({x:l*s(n,3)+u*s(n,2)+p*n+e,y:d*s(n,3)+f*s(n,2)+g*n+t}),e=>({x:3*l*s(e,2)+2*u*e+p,y:3*d*s(e,2)+2*f*e+g}),e=>({x:6*l*e+2*u,y:6*d*e+2*f}),()=>({x:6*l,y:6*d})]}function I(e,t){const n=L(e),{x:r,y:o}=n[1](t),{x:i,y:a}=n[2](t);return(r*a-o*i)/s(s(r,2)+s(o,2),1.5)}function O(e,t){const n=M(e),{x:r,y:o}=n[1](t),{x:i,y:a}=n[2](t);return(r*a-o*i)/s(s(r,2)+s(o,2),1.5)}function D(e,t){const{from:{x:n,y:i},cp:{x:a,y:s},to:{x:c,y:l}}=e,{from:{x:u,y:p},cp:{x:d,y:f},to:{x:g,y:h}}=t,m=a-n,y=c-a-m,v=s-i,x=l-s-v;let b=(0,r.calculateEquation2)(y,2*m,n-u);if(b=b.filter((e=>(0,o.isSameNumber)(p,i+x*e*e+2*v*e))),0===b.length)return;let C=(0,r.calculateEquation2)(y,0,2*d-u-g);if(C=C.filter((e=>(0,o.isSameNumber)(h,x*e*e-p+2*f))),0!==C.length)for(const e of b)for(const t of C)if((0,o.isSameNumber)(f,p+(x*t*e+v*t))&&(0,o.isSameNumber)(d,u+(y*t*e+m*t)))return[e,t+e]}function B(e,t){const{from:{x:n,y:i},cp1:{x:a,y:s},cp2:{x:c,y:l},to:{x:u,y:p}}=e,{from:{x:d,y:f},cp1:{x:g,y:h},cp2:{x:m,y},to:{x:v,y:x}}=t,b=3*a-n+-3*c+u,C=3*(n-2*a+c),E=3*(a-n),P=3*s-i+-3*l+p,w=3*(i-2*s+l),k=3*(s-i);let _=(0,r.calculateEquation3)(b,C,E,n-d);if(_=_.filter((e=>(0,o.isSameNumber)(f,i+P*e*e*e+w*e*e+k*e))),0===_.length)return;let S=(0,r.calculateEquation3)(b,0,0,d-3*g+3*m-v);if(S=S.filter((e=>(0,o.isSameNumber)(x,P*e*e*e+f-3*h+3*y))),0!==S.length)for(const e of _)for(const t of S)if((0,o.isSameNumber)(g,d+(3*b*t*e*e+2*C*t*e+E*t)/3)&&(0,o.isSameNumber)(m,(3*b*t*t*e+C*t*t)/3+2*g-d)&&(0,o.isSameNumber)(h,f+(3*P*t*e*e+2*w*t*e+k*t)/3)&&(0,o.isSameNumber)(y,(3*P*t*t*e+w*t*t)/3+2*h-f))return[e,t+e]}},5481:(e,t,n)=>{"use strict";n.r(t),n.d(t,{blobToDataUrl:()=>o,createCanvasContext:()=>a,dataUrlToImage:()=>i});var r=(e,t,n)=>new Promise(((r,o)=>{var i=e=>{try{s(n.next(e))}catch(e){o(e)}},a=e=>{try{s(n.throw(e))}catch(e){o(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(i,a);s((n=n.apply(e,t)).next())}));function o(e){return r(this,null,(function*(){return new Promise(((t,n)=>{const r=new FileReader;r.onloadend=()=>{const e=r.result;"string"==typeof e&&t(e)},r.onerror=()=>{n()},r.readAsDataURL(e)}))}))}function i(e,t){return new Promise(((n,r)=>{const o=new Image;void 0!==t&&(o.crossOrigin=t),o.onload=()=>{n(o)},o.onerror=()=>{r()},o.src=e}))}function a(e){const t=document.createElement("canvas");return t.width=e.width,t.height=e.height,t.getContext("2d")}},6842:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Bounding:()=>d,getArcBounding:()=>x,getBezierCurveBounding:()=>w,getCircleBounding:()=>v,getCircleQuadrantPoints:()=>y,getEllipseArcBounding:()=>E,getEllipseBounding:()=>C,getEllipseBoundingRadians:()=>b,getGeometryLineBounding:()=>_,getGeometryLinesBounding:()=>k,getPointsBounding:()=>f,getPointsBoundingUnsafe:()=>m,getQuadraticCurveBounding:()=>P,mergeBoundings:()=>h,mergeBoundingsUnsafe:()=>g});var r=n(1475),o=n(2792),i=n(8831),a=n(2298),s=n(2318),c=n(8230),l=n(1715),u=n(5569),p=n(2986);const d={xMin:u.number,xMax:u.number,yMin:u.number,yMax:u.number};function f(e){if(0!==e.length)return m(e)}function g(e){return m(e.map((e=>[e.start,e.end])).flat())}function h(e){const t=[];for(const n of e)n&&t.push(n.start,n.end);if(0!==t.length)return m(t)}function m(e){const t={start:{x:e[0].x,y:e[0].y},end:{x:e[0].x,y:e[0].y}};for(let n=1;nt.end.x&&(t.end.x=r.x),r.y>t.end.y&&(t.end.y=r.y)}return t}function y(e){return[{x:e.x-e.r,y:e.y,radian:Math.PI},{x:e.x,y:e.y-e.r,radian:-Math.PI/2},{x:e.x+e.r,y:e.y,radian:0},{x:e.x,y:e.y+e.r,radian:Math.PI/2}]}function v(e){return m(y(e))}function x(e){const t=y(e).filter((t=>(0,s.pointIsOnArc)(t,e))),{start:n,end:r}=(0,s.getArcStartAndEnd)(e);return m([...t,n,r])}function b(e){const{rx:t,ry:n,angle:r}=e,o=(0,l.angleToRadian)(r),i=Math.sin(o),a=Math.cos(o),s=Math.atan2(-i*n,a*t),c=Math.atan2(a*n,i*t);return[s,c,s+Math.PI,c+Math.PI]}function C(e){return m(b(e).map((t=>(0,a.getEllipsePointAtRadian)(e,t))))}function E(e){const{start:t,end:n}=(0,a.getEllipseArcStartAndEnd)(e),r=[t,n];for(const t of b(e))(0,i.angleInRange)((0,l.radianToAngle)(t),e)&&r.push((0,a.getEllipsePointAtRadian)(e,t));return m([...r,t,n])}function P({from:{x:e,y:t},cp:{x:n,y:r},to:{x:i,y:a}}){const s=n-e,c=i-n-s,l=r-t,u=a-r-l,p=[{x:e,y:t},{x:i,y:a}];if(!(0,o.isZero)(c)){const n=-s/c;(0,o.isValidPercent)(n)&&p.push({x:c*n*n+2*s*n+e,y:u*n*n+2*l*n+t})}if(!(0,o.isZero)(u)){const n=-l/u;(0,o.isValidPercent)(n)&&p.push({x:c*n*n+2*s*n+e,y:u*n*n+2*l*n+t})}return m(p)}function w({from:{x:e,y:t},cp1:{x:n,y:i},cp2:{x:a,y:s},to:{x:c,y:l}}){const u=3*n-e+-3*a+c,p=3*(e-2*n+a),d=3*(n-e),f=3*i-t+-3*s+l,g=3*(t-2*i+s),h=3*(i-t),y=[{x:e,y:t},{x:c,y:l}];for(const n of(0,r.calculateEquation2)(3*u,2*p,d))(0,o.isValidPercent)(n)&&y.push({x:u*n*n*n+p*n*n+d*n+e,y:f*n*n*n+g*n*n+h*n+t});for(const n of(0,r.calculateEquation2)(3*f,2*g,h))(0,o.isValidPercent)(n)&&y.push({x:u*n*n*n+p*n*n+d*n+e,y:f*n*n*n+g*n*n+h*n+t});return m(y)}function k(e,t=100){const n=[];for(const r of e){const e=_(r,t);if(!e)return;n.push(e)}return h(n)}function _(e,t=100){return Array.isArray(e)?m(e):"arc"===e.type?x(e.curve):"ellipse arc"===e.type?E(e.curve):"quadratic curve"===e.type?P(e.curve):"bezier curve"===e.type?w(e.curve):"hyperbola curve"===e.type?(0,p.getHyperbolaBounding)(e.curve):"ray"!==e.type?f((0,c.getNurbsPoints)(e.curve.degree,e.curve.points,e.curve.knots,e.curve.weights,t)):void 0}},1451:(e,t,n)=>{"use strict";n.r(t),n.d(t,{breakGeometryLines:()=>k,breakPolylineToPolylines:()=>P,mergeGeometryLines:()=>_,mergePolylinesToPolyline:()=>w});var r=n(5629),o=n(5773),i=n(8831),a=n(1796),s=n(2318),c=n(2298),l=n(5717),u=n(8230),p=n(1715),d=n(8306),f=n(2986),g=Object.defineProperty,h=Object.defineProperties,m=Object.getOwnPropertyDescriptors,y=Object.getOwnPropertySymbols,v=Object.prototype.hasOwnProperty,x=Object.prototype.propertyIsEnumerable,b=(e,t,n)=>t in e?g(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,C=(e,t)=>{for(var n in t||(t={}))v.call(t,n)&&b(e,n,t[n]);if(y)for(var n of y(t))x.call(t,n)&&b(e,n,t[n]);return e},E=(e,t)=>h(e,m(t));function P(e,t){const n=[];let r=[e[0][0]];if(e.forEach((e=>{const i=t.filter((t=>(0,a.pointIsOnLine)(t,...e)&&(0,a.pointIsOnLineSegment)(t,...e)));0===i.length?r.push(e[1]):(i.sort(((t,n)=>(0,o.getTwoPointsDistance)(t,e[0])-(0,o.getTwoPointsDistance)(n,e[0]))),i.forEach((e=>{(0,o.isSamePoint)(r[r.length-1],e)||r.push(e),r.length>1&&n.push(r),r=[e]})),(0,o.isSamePoint)(r[r.length-1],e[1])||r.push(e[1]))})),r.length>1&&n.push(r),n.length>1){const e=n[0][0],r=n[n.length-1];if((0,o.isSamePoint)(e,r[r.length-1])&&t.every((t=>!(0,o.isSamePoint)(e,t))))return n[0].unshift(...r.slice(0,r.length-1)),n.slice(0,n.length-1)}return n}function w(e){for(let t=e.length-1;t>0;t--)for(let n=t-1;n>=0;n--){const r=e[n],i=e[t];if((0,o.isSamePoint)(i.points[0],r.points[r.points.length-1])){e.splice(t,1),r.points.push(...i.points.slice(1));break}if((0,o.isSamePoint)(i.points[0],r.points[0])){e.splice(t,1),r.points.unshift(...i.points.slice(1).reverse());break}if((0,o.isSamePoint)(i.points[i.points.length-1],r.points[r.points.length-1])){e.splice(t,1),r.points.push(...i.points.reverse().slice(1));break}if((0,o.isSamePoint)(i.points[i.points.length-1],r.points[0])){e.splice(t,1),r.points.unshift(...i.points.slice(0,i.points.length-1));break}}}function k(e,t){const n=[];let g,h,m=[];const y=()=>{m.length>0&&(n.push(m),m=[])};for(const n of e){const{start:e,end:v}=(0,l.getGeometryLineStartAndEnd)(n);let x;if(g||(g=e),Array.isArray(n)?x={breakLine(t){t.sort(((e,t)=>(0,o.getTwoPointsDistance)(e,n[0])-(0,o.getTwoPointsDistance)(t,n[0]))),e&&t.unshift(e),v&&t.push(v);for(let e=1;e(0,i.getAngleInRange)((0,p.radianToAngle)((0,s.getCircleRadian)(e,n.curve)),n.curve)));t.sort(((e,t)=>e-t)),t.unshift(n.curve.startAngle),t.push(n.curve.endAngle);for(let e=1;e(0,i.getAngleInRange)((0,c.getEllipseAngle)(e,n.curve),n.curve)));t.sort(((e,t)=>e-t)),t.unshift(n.curve.startAngle),t.push(n.curve.endAngle);for(let e=1;e(0,r.getQuadraticCurvePercentAtPoint)(n.curve,e)));t.sort(((e,t)=>e-t)),t.unshift(0),t.push(1);for(let e=1;e(0,r.getBezierCurvePercentAtPoint)(n.curve,e)));t.sort(((e,t)=>e-t)),t.unshift(0),t.push(1);for(let e=1;e(0,f.getHyperbolaParamAtPoint)(n.curve,e)));t.push(n.curve.t1,n.curve.t2),n.curve.t1e-t)):t.sort(((e,t)=>t-e));for(let e=1;e(0,u.getNurbsCurveParamAtPoint)(n.curve,e)));t.sort(((e,t)=>e-t)),t.unshift(0),t.push((0,u.getNurbsMaxParam)(n.curve));for(let e=1;e(0,a.getRayParamAtPoint)(n.line,e)));if(n.line.bidirectional||t.push(0),t.sort(((e,t)=>e-t)),n.line.bidirectional){const e=(0,a.getRayPointAtDistance)(n.line,t[0]);m.push({type:"ray",line:(0,d.reverseRay)(E(C({},n.line),{x:e.x,y:e.y,bidirectional:!1}))}),y()}for(let e=1;e(0,o.isSamePoint)(t,e)))&&y();const i=t.filter((t=>(!e||!(0,o.isSamePoint)(t,e))&&(!v||!(0,o.isSamePoint)(t,v))&&(0,l.pointIsOnGeometryLine)(t,n)));0===i.length?m.push(n):r(i),v&&t.some((e=>(0,o.isSamePoint)(e,v)))&&y()}h=v}if(y(),n.length>1&&g&&h){const e=g;if((0,o.isSamePoint)(e,h)&&t.every((t=>!(0,o.isSamePoint)(e,t)))){const e=n.splice(n.length-1,1);n[0].unshift(...e[0])}}return n}function _(e,t){const n=(0,l.getGeometryLineStartAndEnd)(e[0]).start;if(!n)return;const r=(0,l.getGeometryLineStartAndEnd)(e[e.length-1]).end;if(!r)return;const i=(0,l.getGeometryLineStartAndEnd)(t[0]).start;if(!i)return;const a=(0,l.getGeometryLineStartAndEnd)(t[t.length-1]).end;return a?(0,o.isSamePoint)(r,i)?[...e,...t]:(0,o.isSamePoint)(r,a)?[...e,...(0,d.reverseGeometryLines)(t)]:(0,o.isSamePoint)(n,a)?[...t,...e]:(0,o.isSamePoint)(n,i)?[...(0,d.reverseGeometryLines)(e),...t]:void 0:void 0}},9793:(e,t,n)=>{"use strict";n.r(t),n.d(t,{updateCamera:()=>o});var r=n(5773);function o(e,t,n,r,o){return{position:i(e,t,n,r,o),up:i(0,1,0,r,o)}}function i(e,t,n,o,i){const a=(0,r.rotatePositionByCenter)({x:n,y:t},{x:0,y:0},i);n=a.x,t=a.y;const s=(0,r.rotatePositionByCenter)({x:e,y:n},{x:0,y:0},o);return{x:e=s.x,y:t,z:n=s.y}}},2318:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Arc:()=>k,Circle:()=>w,arcToPolyline:()=>R,circleToArc:()=>M,getArcBulge:()=>z,getArcBulgeByStartEndPoint:()=>F,getArcBulgeByStartEndRadius:()=>B,getArcByStartEnd:()=>I,getArcByStartEndBulge:()=>D,getArcControlPoint:()=>O,getArcCurvature:()=>j,getArcDerivatives:()=>U,getArcPointAtAngle:()=>A,getArcStartAndEnd:()=>T,getCircleCurvature:()=>G,getCircleDerivatives:()=>N,getCirclePointAtRadian:()=>L,getCircleRadian:()=>S,getThreePointsCircle:()=>P,isSameCircle:()=>_,pointIsOnArc:()=>C,pointIsOnCircle:()=>E});var r=n(8831),o=n(1715),i=n(2792),a=n(5773),s=n(5569),c=n(491),l=n(1796),u=n(8392),p=Object.defineProperty,d=Object.defineProperties,f=Object.getOwnPropertyDescriptors,g=Object.getOwnPropertySymbols,h=Object.prototype.hasOwnProperty,m=Object.prototype.propertyIsEnumerable,y=Math.pow,v=(e,t,n)=>t in e?p(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,x=(e,t)=>{for(var n in t||(t={}))h.call(t,n)&&v(e,n,t[n]);if(g)for(var n of g(t))m.call(t,n)&&v(e,n,t[n]);return e},b=(e,t)=>d(e,f(t));function C(e,t,n=i.NOT_EXTENDED){if(n.head&&n.body&&n.tail)return!0;if(!n.head&&!n.body&&!n.tail)return!1;const a=S(e,t),s=(0,r.angleInRange)((0,o.radianToAngle)(a),t);return!(!n.body||!s)||!(!n.head&&!n.tail||s)}function E(e,t){return(0,i.isSameNumber)((0,a.getTwoPointsDistance)(e,t),t.r)}function P(e,t,n){const r=t.x-e.x,o=t.y-e.y,i=n.x-t.x,s=n.y-t.y,c=y(t.x,2)-y(e.x,2)+y(t.y,2)-y(e.y,2),l=y(n.x,2)-y(t.x,2)+y(n.y,2)-y(t.y,2),u={x:(c*s-l*o)/(r*s-i*o)/2,y:(i*c-l*r)/(i*o-s*r)/2};return b(x({},u),{r:(0,a.getTwoPointsDistance)(u,e)})}const w=(0,s.and)(a.Position,{r:(0,s.minimum)(0,s.number)}),k=(0,s.and)(w,r.AngleRange);function _(e,t){return(0,a.isSamePoint)(e,t)&&(0,i.isSameNumber)(e.r,t.r)}function S(e,t){return(0,o.getTwoPointsRadian)(e,t)}function R(e,t){return(0,r.getAngleRange)(e,t).map((t=>A(e,t)))}function T(e){return{start:A(e,e.startAngle),end:A(e,e.endAngle)}}function A(e,t){return L(e,(0,o.angleToRadian)(t))}function L(e,t){return(0,a.getPointByLengthAndRadian)(e,e.r,t)}function M(e){return b(x({},e),{startAngle:0,endAngle:360})}function I(e,t,n,r,s){const c=(0,a.getTwoPointCenter)(e,s),l=(0,a.getTwoPointsDistance)(e,s)/2;if((0,i.isZero)(l))return;let u;if(l>t&&(t=l),(0,i.isSameNumber)(l,t))u=c;else{const i=Math.sqrt(y(t,2)-y(l,2)),p=(0,o.getTwoPointsRadian)(s,e);u=(0,a.getPointByLengthAndRadian)(c,i,p+Math.PI/2*(n===r?-1:1))}const p={x:u.x,y:u.y,r:t};return b(x({},p),{startAngle:(0,o.radianToAngle)(S(e,p)),endAngle:(0,o.radianToAngle)(S(s,p)),counterclockwise:!r})}function O(e){const t=L(e,(0,o.angleToRadian)(e.startAngle)),n=(0,l.twoPointLineToGeneralFormLine)(e,t);if(!n)return;const r=L(e,(0,o.angleToRadian)(e.endAngle)),i=(0,l.twoPointLineToGeneralFormLine)(e,r);if(!i)return;const a=(0,u.getPerpendicularLine)(t,n),s=(0,u.getPerpendicularLine)(r,i);return(0,c.getTwoGeneralFormLinesIntersectionPoint)(a,s)}function D(e,t,n){const r=P(e,t,(0,a.getPointByLengthAndRadian)((0,a.getTwoPointCenter)(e,t),n*(0,a.getTwoPointsDistance)(e,t)/2,(0,o.getTwoPointsRadian)(t,e)-Math.PI/2));return b(x({},r),{startAngle:(0,o.radianToAngle)((0,o.getTwoPointsRadian)(e,r)),endAngle:(0,o.radianToAngle)((0,o.getTwoPointsRadian)(t,r)),counterclockwise:n<0})}function B(e,t,n,r){let o=Math.asin((0,a.getTwoPointsDistance)(e,t)/2/n);return r&&(Math.abs(r)>1&&(o=Math.PI-o),r<0&&(o=-o)),Math.tan(o/2)}function z(e,t,n){t||(t=A(e,e.startAngle)),n||(n=A(e,e.endAngle));let o=B(t,n,e.r);return(0,r.getLargeArc)(e)&&(o=1/o),e.counterclockwise&&(o=-o),o}function F(e,t,n){const r=P(e,t,n),i=(0,o.radianToAngle)(S(e,r)),a=(0,o.radianToAngle)(S(t,r)),s=[b(x({},r),{startAngle:i,endAngle:a,counterclockwise:!1}),b(x({},r),{startAngle:i,endAngle:a,counterclockwise:!0})].find((e=>C(n,e)));if(s)return z(s,e,t)}function N({x:e,y:t,r:n}){return[r=>({x:e+n*Math.cos(r),y:t+n*Math.sin(r)}),e=>({x:-n*Math.sin(e),y:n*Math.cos(e)}),e=>({x:-n*Math.cos(e),y:-n*Math.sin(e)}),e=>({x:n*Math.sin(e),y:-n*Math.cos(e)}),e=>({x:n*Math.cos(e),y:n*Math.sin(e)})]}function U({x:e,y:t,r:n,startAngle:r,endAngle:i}){const a=(0,o.angleToRadian)(i-r),s=(0,o.angleToRadian)(r);return[r=>{const o=a*r+s;return{x:e+n*Math.cos(o),y:t+n*Math.sin(o)}},e=>{const t=a*e+s,r=n*a;return{x:-r*Math.sin(t),y:r*Math.cos(t)}},e=>{const t=a*e+s,r=n*a*a;return{x:-r*Math.cos(t),y:-r*Math.sin(t)}}]}function G(e){return 1/e.r}function j(e){const t=G(e);return e.counterclockwise?-t:t}},3975:(e,t,n)=>{"use strict";function r(e){return+`0x${e.slice(1)}`}function o(e,t){const n=e.toString(16);let r="";if(void 0!==t){const e=Math.floor(255*t).toString(16);r="0".repeat(2-e.length)+e}return`#${"0".repeat(6-n.length)}${n}${r}`}function i(e,t=1){const[n,r,o]=c(e);return[n/255,r/255,o/255,t]}function a(e){return s([Math.round(255*e[0]),Math.round(255*e[1]),Math.round(255*e[2])])}function s(e){return 256*(256*e[0]+e[1])+e[2]}function c(e){const t=[0,0,e%256];return e=Math.floor(e/256),t[1]=e%256,t[0]=Math.floor(e/256),t}function l(e,t){return void 0===t?e:void 0!==e?[e[0],e[1],e[2],e[3]*t]:void 0}function u(e,t){return void 0===e?t:void 0===t?e:e*t}n.r(t),n.d(t,{colorNumberToPixelColor:()=>c,colorNumberToVec:()=>i,colorStringToNumber:()=>r,getColorString:()=>o,mergeOpacities:()=>u,mergeOpacityToColor:()=>l,pixelColorToColorNumber:()=>s,vecToColorNumber:()=>a})},905:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Cone:()=>C,getConeNormalAtPoint:()=>_,getLineAndConeIntersectionPoints:()=>E,getParallelConesByDistance:()=>k,getPerpendicularPointsToCone:()=>w,pointIsOnCone:()=>P});var r=n(1475),o=n(2792),i=n(5147),a=n(8392),s=n(4206),c=n(5773),l=n(2301),u=n(5569),p=Object.defineProperty,d=Object.defineProperties,f=Object.getOwnPropertyDescriptors,g=Object.getOwnPropertySymbols,h=Object.prototype.hasOwnProperty,m=Object.prototype.propertyIsEnumerable,y=Math.pow,v=(e,t,n)=>t in e?p(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,x=(e,t)=>{for(var n in t||(t={}))h.call(t,n)&&v(e,n,t[n]);if(g)for(var n of g(t))m.call(t,n)&&v(e,n,t[n]);return e},b=(e,t)=>d(e,f(t));const C={base:l.Vec3,direction:l.Vec3,radiusHeightRate:u.number};function E([[e,t,n],[i,a,s]],{base:[c,l,u],direction:[p,d,f],radiusHeightRate:g,height1:h,height2:m},v){const x=i-e,b=a-t,C=s-n,E=1/(p*p+d*d+f*f),P=e-c,w=t-l,k=n-u,_=p*x*E+d*b*E+f*C*E,S=p*E*P+d*E*w+f*E*k,R=y(g,2)/E,T=p*_-x,A=p*S-P,L=d*_-b,M=d*S-w,I=f*_-C,O=f*S-k;let D=(0,r.calculateEquation2)(T*T+L*L+I*I-R*_*_,2*T*A+2*L*M+2*I*O-2*R*_*S,A*A+M*M+O*O-R*S*S);return!v&&D.length>0&&(D=D.filter((e=>(0,o.isBetween)(_*e+S,h,m)))),D.map((r=>[r*x+e,r*b+t,r*C+n]))}function P(e,t){const n=(0,a.getPerpendicularParamToLine)(e,t.base,t.direction),r=i.v3.length(t.direction),s=t.height1/r,l=t.height2/r;if(!(0,o.isBetween)(n,s,l))return!1;const u=(0,c.getPointByParamAndDirection3D)(t.base,n,t.direction),p=i.v3.length(i.v3.substract(u,t.base)),d=i.v3.length(i.v3.substract(u,e));return(0,o.equals)(d,t.radiusHeightRate*p)}function w(e,t){const n=(0,s.getPointAndTwoDirectionsPlane)(t.base,t.direction,i.v3.substract(e,t.base));if(!n)return;const r=Math.atan(t.radiusHeightRate),o=(0,s.getPlaneNormal)(n),c=[],l=(0,s.rotateDirectionByRadianOnPlane)(t.direction,r,o);l&&c.push((0,a.getPerpendicularPointToLine3D)(e,t.base,l));const u=(0,s.rotateDirectionByRadianOnPlane)(t.direction,-r,o);return u&&c.push((0,a.getPerpendicularPointToLine3D)(e,t.base,u)),c}function k(e,t){if((0,o.isZero)(t))return[e,e];const n=t/e.radiusHeightRate;return[b(x({},e),{base:(0,c.getPointByLengthAndDirection3D)(e.base,n,e.direction)}),b(x({},e),{base:(0,c.getPointByLengthAndDirection3D)(e.base,-n,e.direction)})]}function _(e,t){const n=(0,s.getPlaneByPointAndNormal)(t,i.v3.substract(t,e.base)),r=(0,s.getPointAndDirectionLineAndPlaneIntersectionPoint)(e.base,e.direction,n);if(r)return i.v3.substract(t,r)}},4676:(e,t,n)=>{"use strict";function r(e,t){if("center"===t)return"move";let n=0;return(e%=180)>22.5?e<67.5?n+=1:e<112.5?n+=2:e<157.5&&(n+=3):e<-22.5&&(e>-67.5?n+=3:e>-112.5?n+=2:e>-157.5&&(n+=1)),"top"===t||"bottom"===t?i[(n+2)%4]:"right"===t||"left"===t?i[n%4]:"right-top"===t||"left-bottom"===t?i[(n+3)%4]:i[(n+1)%4]}n.r(t),n.d(t,{allDirections:()=>o,getResizeCursor:()=>r});const o=["left","right","top","bottom","left-bottom","left-top","right-top","right-bottom","center"],i=["ew-resize","nwse-resize","ns-resize","nesw-resize"]},8780:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Cylinder:()=>E,getCylinderNormalAtPoint:()=>S,getLineAndCylinderIntersectionPoints:()=>P,getParallelCylindersByDistance:()=>_,getPerpendicularPointsToCylinder:()=>k,getPlaneCylinderIntersection:()=>R,pointIsOnCylinder:()=>w});var r=n(2298),o=n(1475),i=n(2792),a=n(5147),s=n(8392),c=n(4206),l=n(5773),u=n(360),p=n(2301),d=n(5569),f=Object.defineProperty,g=Object.defineProperties,h=Object.getOwnPropertyDescriptors,m=Object.getOwnPropertySymbols,y=Object.prototype.hasOwnProperty,v=Object.prototype.propertyIsEnumerable,x=(e,t,n)=>t in e?f(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,b=(e,t)=>{for(var n in t||(t={}))y.call(t,n)&&x(e,n,t[n]);if(m)for(var n of m(t))v.call(t,n)&&x(e,n,t[n]);return e},C=(e,t)=>g(e,h(t));const E={base:p.Vec3,direction:p.Vec3,radius:d.number,height1:d.number,height2:d.number};function P([[e,t,n],[r,a,s]],{base:[c,l,u],direction:[p,d,f],radius:g,height1:h,height2:m},y){const v=r-e,x=a-t,b=s-n,C=1/(p*p+d*d+f*f),E=e-c,P=t-l,w=n-u,k=p*v*C+d*x*C+f*b*C,_=p*C*E+d*C*P+f*C*w,S=p*k-v,R=p*_-E,T=d*k-x,A=d*_-P,L=f*k-b,M=f*_-w;let I=(0,o.calculateEquation2)(S*S+T*T+L*L,2*S*R+2*T*A+2*L*M,R*R+A*A+M*M-g*g);return!y&&I.length>0&&(I=I.filter((e=>(0,i.isBetween)(k*e+_,h,m)))),I.map((r=>[r*v+e,r*x+t,r*b+n]))}function w(e,t){const n=(0,s.getPerpendicularParamToLine)(e,t.base,t.direction),r=a.v3.length(t.direction),o=t.height1/r,c=t.height2/r;if(!(0,i.isBetween)(n,o,c))return!1;const u=(0,l.getPointByParamAndDirection3D)(t.base,n,t.direction);return(0,i.equals)(a.v3.length(a.v3.substract(e,u)),t.radius)}function k(e,t){const n=(0,s.getPerpendicularPointToLine3D)(e,t.base,t.direction),r=a.v3.substract(n,e);return[(0,l.getPointByLengthAndDirection3D)(n,t.radius,r),(0,l.getPointByLengthAndDirection3D)(n,-t.radius,r)]}function _(e,t){return(0,i.isZero)(t)?[e,e]:[C(b({},e),{radius:e.radius-t}),C(b({},e),{radius:e.radius+t})]}function S(e,t){const n=(0,s.getPerpendicularPointToLine3D)(t,e.base,e.direction);return a.v3.substract(t,n)}function R(e,t){const n=(0,c.getPointAndDirectionLineAndPlaneIntersectionPoint)(t.base,t.direction,e);if(!n)return;const o=t.radius,i=a.v3.normalize((0,c.getPlaneNormal)(e)),s=o/(a.v3.dot(t.direction,i)/a.v3.length(t.direction)),l=a.v3.normalize(a.v3.cross(t.direction,i)),d=[n,l,a.v3.normalize(a.v3.cross(l,i)),i],f=(0,u.getCoordinateMatrix)(d);return f?(0,r.ellipseArcToPolyline)((0,r.ellipseToEllipseArc)({cx:0,cy:0,rx:o,ry:s}),5).map((e=>(0,p.slice3)(a.matrix.multiplyVec(f,(0,u.getCoordinateVec)([e.x,e.y,0],d))))):void 0}},23:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Debug:()=>a,printArc:()=>u,printBezierCurve:()=>f,printEllipseArc:()=>p,printGeometryLine:()=>y,printHyperbolaHyperbola:()=>g,printLine:()=>l,printNurbsCurve:()=>h,printParam:()=>s,printPoint:()=>c,printQuadraticCurve:()=>d,printRay:()=>m});var r=n(2298),o=Object.defineProperty,i=(e,t,n)=>((e,t,n)=>t in e?o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class a{constructor(e){this.enabled=e,i(this,"last",performance.now()),i(this,"result",{})}add(e,t){this.enabled&&(this.result[e]=t)}mark(e){this.enabled&&(this.result[e]=Math.round(performance.now()-this.last),this.last=performance.now())}print(e="end"){return this.mark(e),Object.values(this.result).join(" ")}}function s(e){return e.toFixed(1)}function c(e){return`(${Math.round(e.x)},${Math.round(e.y)})`}function l(e){return`${c(e[0])}->${c(e[1])}`}function u(e){return`${c(e)} R${Math.round(e.r)} A${Math.round(e.startAngle)}${e.counterclockwise?"<-":"->"}${Math.round(e.endAngle)}`}function p(e){return`${c((0,r.getEllipseCenter)(e))} R${Math.round(e.rx)},${Math.round(e.ry)} A${Math.round(e.startAngle+(e.angle||0))}${e.counterclockwise?"<-":"->"}${Math.round(e.endAngle+(e.angle||0))}`}function d(e){return`${c(e.from)}->${c(e.cp)}->${c(e.to)}`}function f(e){return`${c(e.from)}->${c(e.cp1)}->${c(e.cp2)}->${c(e.to)}`}function g(e){return`${c(e)} A${Math.round(e.angle)} ${Math.round(e.t1)}->${Math.round(e.t2)}`}function h(e){return e.points.map((e=>c(e))).join("->")}function m(e){return`${c(e)}${e.bidirectional?"<->":e.reversed?"<-":"->"}${Math.round(e.angle)}`}function y(e){return Array.isArray(e)?l(e):"arc"===e.type?u(e.curve):"ellipse arc"===e.type?p(e.curve):"quadratic curve"===e.type?d(e.curve):"bezier curve"===e.type?f(e.curve):"ray"===e.type?m(e.line):"hyperbola curve"===e.type?g(e.curve):h(e.curve)}},9681:(e,t,n)=>{"use strict";n.r(t),n.d(t,{geometrylineIsOnGeometryLine:()=>k,getGeometryLinesDifferenceLines:()=>w,getTwoGeometryLinesDifferenceLine:()=>P,isSameGeometryline:()=>_,isSameGeometrylines:()=>S});var r=n(8831),o=n(5629),i=n(2318),a=n(2298),s=n(5717),c=n(2986),l=n(1796),u=n(2792),p=n(2572),d=n(1715),f=n(8306),g=Object.defineProperty,h=Object.defineProperties,m=Object.getOwnPropertyDescriptors,y=Object.getOwnPropertySymbols,v=Object.prototype.hasOwnProperty,x=Object.prototype.propertyIsEnumerable,b=(e,t,n)=>t in e?g(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,C=(e,t)=>{for(var n in t||(t={}))v.call(t,n)&&b(e,n,t[n]);if(y)for(var n of y(t))x.call(t,n)&&b(e,n,t[n]);return e},E=(e,t)=>h(e,m(t));function P(e,t){if(Array.isArray(e)){const n=(0,l.twoPointLineToGeneralFormLine)(...e);if(!n)return[e];if(Array.isArray(t)){const r=(0,l.twoPointLineToGeneralFormLine)(...t);if(!r)return[e];if(!(0,l.isSameLine)(n,r))return[e];const o=t.map((t=>(0,s.getGeometryLineParamAtPoint)(t,e)));return(0,u.getNumberRangeDifference)([0,1],[o[0],o[1]]).map((t=>(0,s.getPartOfGeometryLine)(...t,e)))}if("ray"===t.type){const r=(0,l.pointAndDirectionToGeneralFormLine)(t.line,(0,d.angleToRadian)(t.line.angle));if(!(0,l.isSameLine)(n,r))return[e];if(t.line.bidirectional)return[];const o=e.map((e=>(0,l.pointIsOnRay)(e,t.line)));if(o.every((e=>e)))return[];let i=o.findIndex((e=>e));return i>=0?(i=0===i?1:0,[[e[i],t.line]]):[e]}return[e]}if("arc"===e.type){if(Array.isArray(t))return[e];if("arc"===t.type){if(!(0,i.isSameCircle)(e.curve,t.curve))return[e];const n=(0,r.getAngleRangesDifferences)(e.curve,t.curve);return(0,u.mergeItems)(n.map((t=>E(C({},e.curve),{startAngle:t[0],endAngle:t[1],counterclockwise:void 0}))),p.mergeArc).map((e=>({type:"arc",curve:e})))}return[e]}if("ellipse arc"===e.type){if(Array.isArray(t))return[e];if("ellipse arc"===t.type){if(!(0,a.isSameEllipse)(e.curve,t.curve))return[e];const n=(0,r.getAngleRangesDifferences)(e.curve,t.curve);return(0,u.mergeItems)(n.map((t=>E(C({},e.curve),{startAngle:t[0],endAngle:t[1],counterclockwise:void 0}))),p.mergeEllipseArc).map((e=>({type:"ellipse arc",curve:e})))}return[e]}if("quadratic curve"===e.type){if(Array.isArray(t))return[e];if("quadratic curve"===t.type){const n=(0,o.getQuadraticCurvePercentsAtQuadraticCurve)(e.curve,t.curve);return n?(0,u.getNumberRangeDifference)([0,1],n).map((t=>(0,s.getPartOfGeometryLine)(...t,e))):[e]}return[e]}if("bezier curve"===e.type){if(Array.isArray(t))return[e];if("bezier curve"===t.type){const n=(0,o.getBezierCurvePercentsAtBezierCurve)(e.curve,t.curve);return n?(0,u.getNumberRangeDifference)([0,1],n).map((t=>(0,s.getPartOfGeometryLine)(...t,e))):[e]}return[e]}if("hyperbola curve"===e.type)return Array.isArray(t)?[e]:"hyperbola curve"===t.type&&(0,c.isSameHyperbola)(e.curve,t.curve)?(0,u.getNumberRangeDifference)([e.curve.t1,e.curve.t2],[t.curve.t1,t.curve.t2]).map((t=>({type:"hyperbola curve",curve:E(C({},e.curve),{t1:t[0],t2:t[1]})}))):[e];if("ray"===e.type){const n=(0,l.pointAndDirectionToGeneralFormLine)(e.line,(0,d.angleToRadian)(e.line.angle));if(Array.isArray(t)){const r=(0,l.twoPointLineToGeneralFormLine)(...t);if(!r)return[e];if(!(0,l.isSameLine)(n,r))return[e];if(e.line.bidirectional)return[{type:"ray",line:{x:t[0].x,y:t[0].y,angle:(0,d.radianToAngle)((0,d.getTwoPointsRadian)(t[0],t[1]))}},{type:"ray",line:{x:t[1].x,y:t[1].y,angle:(0,d.radianToAngle)((0,d.getTwoPointsRadian)(t[1],t[0]))}}];const o=t.map((t=>(0,l.pointIsOnRay)(t,e.line)));if(o.every((e=>e))){const n=(0,l.pointIsOnLineSegment)(t[0],e.line,t[1]),r=n?0:1,o=n?1:0;return[[e.line,t[r]],{type:"ray",line:E(C({},e.line),{x:t[o].x,y:t[o].y})}]}const i=o.findIndex((e=>e));return i>=0?[{type:"ray",line:E(C({},e.line),{x:t[i].x,y:t[i].y})}]:[e]}if("ray"===t.type){const o=(0,l.pointAndDirectionToGeneralFormLine)(t.line,(0,d.angleToRadian)(t.line.angle));return(0,l.isSameLine)(n,o)?t.line.bidirectional?[]:e.line.bidirectional?[{type:"ray",line:E(C({},e.line),{angle:(0,f.reverseAngle)(e.line.angle)})}]:(0,r.twoAnglesSameDirection)((0,l.getRayAngle)(e.line),(0,l.getRayAngle)(t.line))?(0,l.pointIsOnRay)(e.line,t.line)?[]:[[e.line,t.line]]:(0,l.pointIsOnRay)(e.line,t.line)?[{type:"ray",line:E(C({},e.line),{x:t.line.x,y:t.line.y})}]:[e]:[e]}return[e]}return[e]}function w(e,t){return e.map((e=>(0,u.applyToItems)(e,t,P))).flat()}function k(e,t){return 0===P(e,t).length}function _(e,t){return k(e,t)&&k(t,e)}function S(e,t){return e.length===t.length&&e.every((e=>t.some((t=>_(e,t)))))}},2298:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Ellipse:()=>S,EllipseArc:()=>R,arcToEllipseArc:()=>U,ellipseArcToPolyline:()=>D,ellipseToEllipseArc:()=>N,ellipseToPolygon:()=>O,getEllipseAngle:()=>A,getEllipseArcByStartEnd:()=>G,getEllipseArcCurvatureAtRadian:()=>H,getEllipseArcDerivatives:()=>V,getEllipseArcPointAtAngle:()=>z,getEllipseArcStartAndEnd:()=>F,getEllipseCenter:()=>M,getEllipseCoordinateVec2DAtRadian:()=>B,getEllipseCurvatureAtRadian:()=>W,getEllipseDerivatives:()=>j,getEllipseFocus:()=>q,getEllipsePointAtRadian:()=>I,getEllipseRadian:()=>L,getEllipseRadiusOfAngle:()=>_,isSameEllipse:()=>T,pointIsOnEllipse:()=>w,pointIsOnEllipseArc:()=>P,rotatePositionByEllipseCenter:()=>k});var r=n(5773),o=n(8831),i=n(1715),a=n(2792),s=n(5569),c=n(1475),l=n(1796),u=n(2301),p=n(360),d=n(5147),f=Object.defineProperty,g=Object.defineProperties,h=Object.getOwnPropertyDescriptors,m=Object.getOwnPropertySymbols,y=Object.prototype.hasOwnProperty,v=Object.prototype.propertyIsEnumerable,x=Math.pow,b=(e,t,n)=>t in e?f(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,C=(e,t)=>{for(var n in t||(t={}))y.call(t,n)&&b(e,n,t[n]);if(m)for(var n of m(t))v.call(t,n)&&b(e,n,t[n]);return e},E=(e,t)=>g(e,h(t));function P(e,t,n=a.NOT_EXTENDED){if(n.head&&n.body&&n.tail)return!0;if(!n.head&&!n.body&&!n.tail)return!1;const r=A(e,t),i=(0,o.angleInRange)(r,t);return!(!n.body||!i)||!(!n.head&&!n.tail||i)}function w({x:e,y:t},{cx:n,cy:r,rx:o,ry:s,angle:c}){const l=(0,i.angleToRadian)(c),u=Math.sin(l),p=Math.cos(l);return(0,a.isSameNumber)(x(p*(e-n)+u*(t-r),2)/o/o+x(-u*(e-n)+p*(t-r),2)/s/s,1)}function k(e,t){var n;return(0,r.rotatePositionByCenter)(e,M(t),-(null!=(n=t.angle)?n:0))}function _(e,t){return e.angle&&(t-=(0,i.angleToRadian)(e.angle)),e.rx*e.ry/Math.sqrt(x(e.rx*Math.sin(t),2)+x(e.ry*Math.cos(t),2))}const S={cx:s.number,cy:s.number,rx:(0,s.minimum)(0,s.number),ry:(0,s.minimum)(0,s.number),angle:(0,s.optional)(s.number)},R=(0,s.and)(S,o.AngleRange);function T(e,t){return(0,a.isSameNumber)(e.cx,t.cx)&&(0,a.isSameNumber)(e.cy,t.cy)&&(0,a.isSameNumber)(e.rx,t.rx)&&(0,a.isSameNumber)(e.ry,t.ry)&&(0,a.equals)(e.angle,t.angle)}function A(e,t){return(0,i.radianToAngle)(L(e,t))}function L(e,t){var n;const o=(0,r.rotatePositionByCenter)(e,M(t),null!=(n=t.angle)?n:0);return Math.atan2((o.y-t.cy)/t.ry,(o.x-t.cx)/t.rx)}function M(e){return{x:e.cx,y:e.cy}}function I(e,t){const n=(0,i.getDirectionByRadian)(t),o={x:e.cx+e.rx*n.x,y:e.cy+e.ry*n.y};return e.angle?(0,r.rotatePosition)(o,M(e),(0,i.angleToRadian)(e.angle)):o}function O(e,t){const n=360/t,o=[],a=(0,p.getCoordinateMatrix2D)(M(e),(0,i.angleToRadian)(e.angle));for(let s=0;s{const o=B(e,(0,i.angleToRadian)(t)),a=d.matrix.multiplyVec(n,o);return(0,r.vec2ToPosition)((0,u.slice2)(a))}))}function B(e,t){const n=(0,i.getDirectionByRadian)(t);return[e.rx*n.x,e.ry*n.y,1]}function z(e,t){return I(e,(0,i.angleToRadian)(t))}function F(e){return{start:z(e,e.startAngle),end:z(e,e.endAngle)}}function N(e){return E(C({},e),{startAngle:0,endAngle:360})}function U(e){return E(C({},e),{cx:e.x,cy:e.y,rx:e.r,ry:e.r})}function G(e,t,n,r,o,a,s){const u=(0,i.angleToRadian)(r),p=Math.sin(u),d=Math.cos(u),f=1/t/t,g=1/n/n,h=e.x,m=e.y,y=s.x,v=s.y,x=y-h,b=v-m,P=d*d*f+p*p*g,w=p*p*f+d*d*g,k=f-g,_=2*(k*p*d*x+w*b),S=2*(P*x+k*p*d*b)/_,R=(P*x*x+2*p*d*k*x*b+w*b*b)/_,T=(0,c.calculateEquation2)(P-2*p*d*k*S+w*S*S,-2*p*d*k*R+2*w*S*R,w*R*R-1);if(0===T.length)return;const L=T.map((e=>({x:h-e,y:m+S*e+R})));let M;if(1===L.length)M=0;else{const t=(0,l.twoPointLineToGeneralFormLine)(e,s);if(!t)return;M=(0,l.getPointSideOfLine)(L[0],t)>0?o===a?0:1:o!==a?0:1}const I=L[M],O={cx:I.x,cy:I.y,rx:t,ry:n,angle:r};return E(C({},O),{startAngle:A(e,O),endAngle:A(s,O),counterclockwise:!a})}function j({rx:e,ry:t,cx:n,cy:r,angle:o}){const a=(0,i.angleToRadian)(o),s=Math.sin(a),c=Math.cos(a);return[o=>({x:c*e*Math.cos(o)-s*t*Math.sin(o)+n,y:s*e*Math.cos(o)+c*t*Math.sin(o)+r}),n=>({x:-c*e*Math.sin(n)-s*t*Math.cos(n),y:-s*e*Math.sin(n)+c*t*Math.cos(n)}),n=>({x:s*t*Math.sin(n)+-c*e*Math.cos(n),y:-s*e*Math.cos(n)+-c*t*Math.sin(n)}),n=>({x:s*t*Math.cos(n)+c*e*Math.sin(n),y:s*e*Math.sin(n)+-c*t*Math.cos(n)}),n=>({x:c*e*Math.cos(n)-s*t*Math.sin(n),y:s*e*Math.cos(n)+c*t*Math.sin(n)})]}function V({rx:e,ry:t,cx:n,cy:r,angle:o,startAngle:a,endAngle:s}){const c=(0,i.angleToRadian)(o),l=Math.sin(c),u=Math.cos(c),p=(0,i.angleToRadian)(s-a),d=(0,i.angleToRadian)(a);return[o=>{const i=p*o+d;return{x:u*e*Math.cos(i)-l*t*Math.sin(i)+n,y:l*e*Math.cos(i)+u*t*Math.sin(i)+r}},n=>{const r=p*n+d;return{x:(-u*e*Math.sin(r)-l*t*Math.cos(r))*p,y:(-l*e*Math.sin(r)+u*t*Math.cos(r))*p}},n=>{const r=p*n+d;return{x:(l*t*Math.sin(r)+-u*e*Math.cos(r))*p*p,y:(-l*e*Math.cos(r)+-u*t*Math.sin(r))*p*p}}]}function W({rx:e,ry:t},n){return e*t/x(x(e*Math.sin(n),2)+x(t*Math.cos(n),2),1.5)}function H(e,t){const n=W(e,t);return e.counterclockwise?-n:n}function q(e){const t=M(e);if((0,a.isSameNumber)(e.rx,e.ry))return[t];const n=Math.sqrt(Math.abs(x(e.rx,2)-x(e.ry,2))),o=(0,i.angleToRadian)((e.angle||0)+(e.rx{"use strict";n.r(t),n.d(t,{calculateEquation1:()=>a,calculateEquation2:()=>s,calculateEquation3:()=>c,calculateEquation4:()=>l,calculateEquation5:()=>u,calculateEquationSet:()=>h,equationParamsToExpression:()=>g,newtonIterate:()=>p,newtonIterate2:()=>d,newtonIterates:()=>f});var r=n(2792),o=n(5147),i=Math.pow;function a(e,t,n){return(0,r.isZero)(e,n)?[]:[-t/e]}function s(e,t,n,o){if((0,r.isZero)(e,o))return a(t,n,o);if((0,r.isZero)(n,o)){const n=a(e,t,o);return n.some((e=>(0,r.isZero)(e,o)))?n:[0,...n]}1!==e&&(t/=e,n/=e);const s=i(t,2)-4*n;if((0,r.lessThan)(s,0,o))return[];if((0,r.isZero)(s,o))return[-t/2];const c=Math.sqrt(s);return[(-t+c)/2,(-t-c)/2]}function c(e,t,n,o,i){if((0,r.isZero)(e,i))return s(t,n,o,i);if((0,r.isZero)(o,i)){const o=s(e,t,n,i);return o.some((e=>(0,r.isZero)(e,i)))?o:[0,...o]}1!==e&&(t/=e,n/=e,o/=e);const a=t*t-3*n,c=t*n-9*o,l=n*n-3*t*o;if((0,r.isZero)(a,i)&&(0,r.isZero)(c,i))return[-t/3];const u=c*c-4*a*l;if((0,r.isZero)(u,i)){const e=c/a;return[-t+e,-e/2]}const p=a*t;if(u>0){const e=Math.sqrt(u),n=p+1.5*(-c+e),o=p+1.5*(-c-e);return[(-t-(0,r.sqrt3)(n)-(0,r.sqrt3)(o))/3]}const d=Math.sqrt(a),f=(p-1.5*c)/a/d,g=Math.acos(f)/3,h=Math.cos(g),m=Math.sqrt(3)*Math.sin(g);return[(-t-2*d*h)/3,(d*(h+m)-t)/3,(d*(h-m)-t)/3]}function l(e,t,n,o,a,s){if((0,r.isZero)(e,s))return c(t,n,o,a,s);if((0,r.isZero)(a,s)){const i=c(e,t,n,o,s);return i.some((e=>(0,r.isZero)(e,s)))?i:[0,...i]}1!==e&&(t/=e,n/=e,o/=e,a/=e);const l=i(t,2),u=l*t,p=3*l-8*n,d=4*n*t-u-8*o,f=3*u*t+16*i(n,2)-16*n*l+16*t*o-64*a;if((0,r.isZero)(d,s)&&(0,r.isZero)(f,s)){if((0,r.isZero)(p,s))return[-t/4];if(p<0)return[];const e=Math.sqrt(p);return[(-t+e)/4,(-t-e)/4]}const g=i(d,2),h=i(p,2),m=h-3*f,y=p*f-9*g,v=i(f,2)-3*p*g;if((0,r.isZero)(m,s)&&(0,r.isZero)(y,s)&&(0,r.isZero)(v,s)){const e=t*p,n=4*p;return[(9*d-e)/n,(-e-3*d)/n]}const x=i(y,2)-4*m*v;if((0,r.isZero)(x,s)){const e=2*m*d/y,n=-(t+e)/4;if(Math.sign(y)!==Math.sign(m))return[n];const r=Math.sqrt(2*y/m),o=-t+e;return[(o+r)/4,(o-r)/4,n]}if(x>0){const e=Math.sqrt(x),n=m*p,o=n-1.5*(y-e),a=n-1.5*(y+e),s=(0,r.sqrt3)(o)+(0,r.sqrt3)(a),c=h-p*s+i(s,2)-3*m,l=-t+Math.sign(d)*Math.sqrt((p+s)/3),u=Math.sqrt((2*p-s+2*Math.sqrt(c))/3);return[(l+u)/4,(l-u)/4]}if((0,r.largerThan)(p,0,s)&&(0,r.largerThan)(f,0,s)){if((0,r.isZero)(d,s)){const e=2*Math.sqrt(f),n=Math.sqrt(p+e),r=Math.sqrt(p-e);return[(-t+n)/4,(-t-n)/4,(-t+r)/4,(-t-r)/4]}const e=Math.sqrt(m),n=Math.acos((3*y-2*m*p)/2/m/e),o=Math.cos(n/3),i=Math.sign(d)*Math.sqrt((p-2*e*o)/3),a=Math.sqrt(3)*Math.sin(n/3),c=Math.sqrt((p+e*(o+a))/3),l=Math.sqrt((p+e*(o-a))/3),u=c+l,g=c-l;return[(-t+i+u)/4,(-t+i-u)/4,(-t-i+g)/4,(-t-i-g)/4]}return[]}function u(e,t,n=r.delta2,o){if(e.length<=5)return l(e[e.length-5]||0,e[e.length-4]||0,e[e.length-3]||0,e[e.length-2]||0,e[e.length-1]||0,n);if(Math.abs(e[0])>1/n&&(e=e.map((t=>t/e[0]))),(0,r.isZero)(e[0],n))return u(e.slice(1),t,n,o);if((0,r.isZero)(e[e.length-1],n)){const t=u(e.slice(0,e.length-1),n);return t.some((e=>(0,r.isZero)(e,n)))?t:[0,...t]}const i=p(t,(t=>{let n=0;for(const r of e)n=n*t+r;return n}),(t=>{let n=0;for(let r=0;r(0,r.isSameNumber)(e,i,n)))?s:[i,...s]}function p(e,t,n,o,i=100){let a=e,s=0;for(;;){const e=t(a);if(isNaN(e))break;if(Math.abs(e)i)return;const c=n(a);if((0,r.isZero)(c))return;const l=e/c;if(Math.abs(l)Math.abs(e)i)return;const c=o.m2.inverse(n(a));if(!c)return;a=o.v2.substract(a,o.m2.multiplyVec2(c,e)),s++}return a}function f(e,t,n,r,i=100){let a=e,s=0;for(;;){const e=t(a);if(e.every((e=>Math.abs(e)i)return;const c=o.matrix.inverse(n(a));if(!c)return;a=o.vector.substract(a,o.matrix.multiplyVec(c,e)),s++}return a}function g(e,t="x"){let n="";for(let r=0;r1&&(n+=" "+t+"^"+o)}return n}function h(e,t){if(0===e.length)return;if(1===e.length){const n=e[0];return a(n[0],n[1],t)}const n=(e=e.map((n=>({param:n,count:n.reduce(((n,o,i)=>n+(it.count-e.count)).map((e=>e.param)))[0].findIndex((e=>!(0,r.isZero)(e,t)));if(n<0)return;const o=e[0][n],i=[...e[0].slice(0,n),...e[0].slice(n+1)],s=[];for(let a=0;a0){const c=e[a][n],l=[...e[a].slice(0,n),...e[a].slice(n+1)];(0,r.isZero)(c,t)?s.push(l):s.push(l.map(((e,t)=>i[t]*c-e*o)))}const c=h(s,t);return c?[...c.slice(0,n),-i.reduce(((e,t,n)=>e+t*(c[n]||1)),0)/o,...c.slice(n)]:void 0}},6072:(e,t,n)=>{"use strict";n.r(t),n.d(t,{mathFunctions:()=>s,mathStyleExpressionToExpression:()=>a,printMathStyleExpression:()=>c,validateExpression:()=>i});var r=n(3031),o=n(8905);function i(e){try{(0,r.parseExpression)((0,r.tokenizeExpression)(e))}catch(e){if(e instanceof r.ExpressionError)return e.range}}function a(e){let t="";for(let n=0;n0&&n0&&s.every((e=>!t.endsWith(e)))&&((0,o.isLetter)(e[n-1])||(0,o.isNumber)(e[n-1])||")"===e[n-1])?t+="*(":")"===r&&n{if("NumericLiteral"===e.type)return e.value.toString();if("Identifier"===e.type)return e.name;if("UnaryExpression"===e.type){const n=t(e.argument,-1);return`(${e.operator+n})`}if("BinaryExpression"===e.type){const o=r.priorizedBinaryOperators.findIndex((t=>t.includes(e.operator))),i="+"===e.operator||"*"===e.operator?o:o-.1,a="*"===e.operator?" ":"**"===e.operator?"^":" "+e.operator+" ",s=t(e.left,o),c=t(e.right,i),l="-1"===s&&" "==a?"-"+c:s+a+c;return o>n?`(${l})`:l}return"CallExpression"===e.type?t(e.callee)+"("+e.arguments.map((e=>t(e))).join(", ")+")":""};return t(e)}},767:(e,t,n)=>{"use strict";function r(e){for(let t=o.length;t<=e;t++)o.push(t*o[t-1]);return o[e]}n.r(t),n.d(t,{factorial:()=>r});const o=[1]},6301:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Align:()=>a,VerticalAlign:()=>c,aligns:()=>i,flowLayout:()=>o,getFlowLayoutLocation:()=>l,verticalAligns:()=>s});var r=n(5569);function o(e){var t,n,r,o,i;const a=t=>void 0===e.height||(!(c.length>0)||t>=-c[0])&&t<=e.height,s=[],c=[];let l=null!=(t=e.scrollX)?t:0;const u=null!=(n=e.scrollY)?n:0;let p=u,d=0,f=null!=(r=e.row)?r:0,g=0,h=a(p),m=0,y=0;const v=()=>{if("center"===e.align||"right"===e.align){const t=s[s.length-1];let n=e.width-t.x-e.getWidth(t.content);"center"===e.align&&(n/=2);for(let e=y;e{p+=m,c.push(m),h=a(p),l=0,f++,g=0,m=0,v(),1===c.length&&s.forEach((e=>{e.visible&&!a(e.y)&&(e.visible=!1)})),y=s.length},b=t=>"number"==typeof e.lineHeight?e.lineHeight:e.lineHeight(t),C=t=>{const n=e.state[d],r=b(n);r>m&&(m=r),s.push({x:l,y:p,i:d,content:n,visible:h,row:f,column:g}),t?x():l+=e.getWidth(n),d++,g++};for(;d0&&x(),t.width<=e.width){for(;de.width&&x(),C(!1)}else l+e.getWidth(t)>e.width&&x(),C(!1)}if(0===m&&(m=b(e.endContent)),c.push(m),s.push({x:l,y:p,i:d,content:e.endContent,visible:h,row:f,column:g}),v(),e.height&&("middle"===e.verticalAlign||"bottom"===e.verticalAlign)){let t=e.height-c.reduce(((e,t)=>e+t));t>0&&("middle"===e.verticalAlign&&(t/=2),s.forEach((e=>{e.y+=t})))}return{layoutResult:s,newContentHeight:p+m-u,lineHeights:c}}const i=["left","center","right"],a=(0,r.or)(...i),s=["top","middle","bottom"],c=(0,r.or)(...s);function l({x:e,y:t},n,r,o,i,a=!0,s){if(t0&&t=u.y+p-d&&t<=u.y+p&&e>=u.x&&e<=u.x+i(u.content))return{location:u.i+1,lineEnd:!1};if(t>=u.y&&t<=u.y+p){if(e<=u.x+i(u.content)/2&&(!c||c.x+i(c.content)/2<=e))return{location:u.i,lineEnd:!1,fromRight:e>u.x};c=u}else if(void 0!==c&&o!==r.length-1)return{location:c.i+1,lineEnd:!0}}var l;return void 0!==c?{location:c.i,lineEnd:!1}:void 0}},5717:(e,t,n)=>{"use strict";n.r(t),n.d(t,{GeometryLine:()=>M,boldGeometryLines:()=>re,geometryLineInPolygon:()=>I,getGeometryLineByStartEndBulge:()=>J,getGeometryLineCurvatureAtParam:()=>ae,getGeometryLineDerivatives:()=>pe,getGeometryLineParamAtPoint:()=>N,getGeometryLinePointAndTangentRadianAtParam:()=>W,getGeometryLinePointAtParam:()=>j,getGeometryLineStartAndEnd:()=>O,getGeometryLineTangentRadianAtParam:()=>V,getGeometryLinesParamAtPoint:()=>U,getGeometryLinesPointAtParam:()=>q,getGeometryLinesStartAndEnd:()=>D,getGeometryLinesTangentRadianAtParam:()=>H,getLineSegmentOrRayPoint:()=>ue,getNearestGeometryLines:()=>se,getParamAtPercent:()=>X,getPartOfGeometryLine:()=>Z,getPartOfGeometryLines:()=>Q,getPercentAtAngle:()=>K,getPercentAtParam:()=>Y,getSeparatedGeometryLines:()=>ce,isGeometryLinesClosed:()=>B,iterateGeometryLinesParamsAtPoint:()=>G,lineSegmentOrRayToGeneralFormLine:()=>le,optimizeGeometryLine:()=>te,optimizeGeometryLines:()=>ne,pointIsOnGeometryLine:()=>F,pointIsOnGeometryLines:()=>z,splitGeometryLines:()=>ee,trimGeometryLinesOffsetResult:()=>ie,trimHatchGeometryLines:()=>oe});var r=n(491),o=n(5629),i=n(2318),a=n(2298),s=n(1074),c=n(6022),l=n(1796),u=n(8230),p=n(5773),d=n(5569),f=n(8831),g=n(2792),h=n(1715),m=n(5689),y=n(8306),v=n(8258),x=n(1785),b=n(8392),C=n(1451),E=n(2986),P=Object.defineProperty,w=Object.defineProperties,k=Object.getOwnPropertyDescriptors,_=Object.getOwnPropertySymbols,S=Object.prototype.hasOwnProperty,R=Object.prototype.propertyIsEnumerable,T=(e,t,n)=>t in e?P(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,A=(e,t)=>{for(var n in t||(t={}))S.call(t,n)&&T(e,n,t[n]);if(_)for(var n of _(t))R.call(t,n)&&T(e,n,t[n]);return e},L=(e,t)=>w(e,k(t));const M=(e,t)=>(0,s.isArray)(e)?(0,d.validate)(e,(0,d.tuple)(p.Position,p.Position),t):(0,c.isRecord)(e)?"arc"===e.type?(0,d.validate)(e,{type:"arc",curve:i.Arc},t):"ellipse arc"===e.type?(0,d.validate)(e,{type:"ellipse arc",curve:a.EllipseArc},t):"quadratic curve"===e.type?(0,d.validate)(e,{type:"quadratic curve",curve:o.QuadraticCurve},t):"bezier curve"===e.type?(0,d.validate)(e,{type:"bezier curve",curve:o.BezierCurve},t):"nurbs curve"===e.type?(0,d.validate)(e,{type:"nurbs curve",curve:u.NurbsCurve},t):"hyperbola curve"===e.type?(0,d.validate)(e,{type:"hyperbola curve",curve:E.HyperbolaSegment},t):"ray"===e.type?(0,d.validate)(e,{type:"ray",line:l.Ray},t):{path:[...t,"type"],expect:"or",args:["arc","ellipse arc","quadratic curve","bezier curve","nurbs curve","hyperbola curve","ray"]}:{path:t,expect:"object"};function I(e,t){if(Array.isArray(e))return(0,l.pointInPolygon)(e[0],t)&&(0,l.pointInPolygon)(e[1],t);let n;if("arc"===e.type)n=(0,i.getArcStartAndEnd)(e.curve);else if("ellipse arc"===e.type)n=(0,a.getEllipseArcStartAndEnd)(e.curve);else if("nurbs curve"===e.type)n=(0,u.getNurbsCurveStartAndEnd)(e.curve);else if("hyperbola curve"===e.type)n=(0,E.getHyperbolaSegmentStartAndEnd)(e.curve);else{if("ray"===e.type)return!1;n={start:e.curve.from,end:e.curve.to}}return(0,l.pointInPolygon)(n.start,t)&&(0,l.pointInPolygon)(n.end,t)&&!(0,r.geometryLineIntersectWithPolygon)(e,t)}function O(e){return Array.isArray(e)?{start:e[0],end:e[1]}:"quadratic curve"===e.type||"bezier curve"===e.type?{start:e.curve.from,end:e.curve.to}:"arc"===e.type?(0,i.getArcStartAndEnd)(e.curve):"nurbs curve"===e.type?(0,u.getNurbsCurveStartAndEnd)(e.curve):"hyperbola curve"===e.type?(0,E.getHyperbolaSegmentStartAndEnd)(e.curve):"ray"===e.type?(0,l.getRayStartAndEnd)(e.line):(0,a.getEllipseArcStartAndEnd)(e.curve)}function D(e){return{start:O(e[0]).start,end:O(e[e.length-1]).end}}function B(e){const{start:t,end:n}=D(e);return!(!t||!n)&&(0,p.isSamePoint)(t,n)}function z(e,t){return t.some((t=>F(e,t)))}function F(e,t){return Array.isArray(t)?(0,l.pointIsOnLine)(e,...t)&&(0,l.pointIsOnLineSegment)(e,...t):"arc"===t.type?(0,i.pointIsOnCircle)(e,t.curve)&&(0,i.pointIsOnArc)(e,t.curve):"ellipse arc"===t.type?(0,a.pointIsOnEllipse)(e,t.curve)&&(0,a.pointIsOnEllipseArc)(e,t.curve):"quadratic curve"===t.type?(0,o.pointIsOnQuadraticCurve)(e,t.curve):"bezier curve"===t.type?(0,o.pointIsOnBezierCurve)(e,t.curve):"hyperbola curve"===t.type?(0,E.pointIsOnHyperbola)(e,t.curve)&&(0,E.pointIsOnHyperbolaSegment)(e,t.curve):"ray"===t.type?(0,l.pointIsOnRay)(e,t.line):(0,u.pointIsOnNurbsCurve)(e,t.curve)}function N(e,t,n){if(Array.isArray(t))return(0,l.getLineParamAtPoint)(...t,e);if("arc"===t.type){const r=(0,f.getAngleInRange)((0,h.radianToAngle)((0,h.getTwoPointsRadian)(e,t.curve)),t.curve),o=t.curve.endAngle-t.curve.startAngle,i=(r-t.curve.startAngle)/o;return i>1&&n?i-360/o:i}if("ellipse arc"===t.type){const r=(0,f.getAngleInRange)((0,a.getEllipseAngle)(e,t.curve),t.curve),o=t.curve.endAngle-t.curve.startAngle,i=(r-t.curve.startAngle)/o;return i>1&&n?i-360/o:i}return"quadratic curve"===t.type?(0,o.getQuadraticCurvePercentAtPoint)(t.curve,e):"bezier curve"===t.type?(0,o.getBezierCurvePercentAtPoint)(t.curve,e):"hyperbola curve"===t.type?Y((0,E.getHyperbolaParamAtPoint)(t.curve,e),t.curve.t1,t.curve.t2):"ray"===t.type?(0,l.getRayParamAtPoint)(t.line,e):(0,u.getNurbsCurveParamAtPoint)(t.curve,e)/(0,u.getNurbsMaxParam)(t.curve)}function U(e,t){var n;return null!=(n=(0,g.first)(G(e,t)))?n:0}function*G(e,t){for(let n=0;nt)return(0,y.reverseGeometryLines)(Q(t,e,n));const r=[],o=Math.max(0,Math.floor(e)),i=Math.min(n.length-1,Math.floor(t));for(let a=o;a<=i;a++){const o=n[a],i=e-a,s=t-a;(0,g.isBetween)(i,0,1)?(0,g.isBetween)(s,0,1)?(0,g.equals)(i,s)||r.push(Z(i,s,o)):(0,g.equals)(i,1)||r.push(Z(i,1,o)):(0,g.isBetween)(s,0,1)?(0,g.equals)(s,0)||r.push(Z(0,s,o)):r.push(o)}return r}function J(e,t,n){return(0,g.isZero)(n)?[e,t]:{type:"arc",curve:(0,i.getArcByStartEndBulge)(e,t,n)}}function ee(e,t){const n=(0,p.deduplicatePosition)(Array.from((0,r.iterateGeometryLinesSelfIntersectionPoints)(e))),o=[];for(const r of n){const n=(0,g.deduplicate)(Array.from(G(r,e)),g.isSameNumber);if(n.length<2)continue;const i=[],a=[],s=[...Q(n[1],e.length,e),...Q(0,n[0],e)];if(0===s.length)continue;const c=Q(n[0],n[1],e);if(0===c.length)continue;const u=(0,l.getPolygonArea)((0,v.getGeometryLinesPoints)(s));if(!(0,g.isZero)(u)){if(u<0&&"intersection"!==t)continue;i.push(...ee(s,t)),a.push(u)}const p=(0,l.getPolygonArea)((0,v.getGeometryLinesPoints)(c));if(!(0,g.isZero)(p)){if(p<0&&"intersection"!==t)continue;i.push(...ee(c,t)),a.push(p)}if(!t)return i;i.length>0&&o.push({result:i,areas:a})}if(o.length>0){if("intersection"===t){const e=(0,g.minimumBy)(o,(e=>e.areas.reduce(((e,t)=>e+Math.abs(t))))),t=e.areas.map(((e,t)=>({area:e,index:t}))).filter((e=>e.area>0)).map((e=>e.index));return e.result.filter(((e,n)=>t.includes(n)))}return o.map((e=>e.result)).flat()}return[e]}function te(e){if(Array.isArray(e)){if((0,p.isSamePoint)(...e))return}else if("arc"===e.type){if((0,g.isSameNumber)(e.curve.startAngle,e.curve.endAngle))return;if((0,g.lessOrEqual)(e.curve.r,0))return}else if("ellipse arc"===e.type){if((0,g.isSameNumber)(e.curve.startAngle,e.curve.endAngle))return;if((0,g.lessOrEqual)(e.curve.rx,0))return;if((0,g.lessOrEqual)(e.curve.ry,0))return;if((0,g.isSameNumber)(e.curve.rx,e.curve.ry))return te({type:"arc",curve:{r:e.curve.rx,x:e.curve.cx,y:e.curve.cy,startAngle:e.curve.startAngle,endAngle:e.curve.endAngle,counterclockwise:e.curve.counterclockwise}})}else if("quadratic curve"===e.type){if((0,l.pointIsOnLine)(e.curve.cp,e.curve.from,e.curve.to))return te([e.curve.from,e.curve.to])}else if("bezier curve"===e.type){if((0,l.pointIsOnLine)(e.curve.cp1,e.curve.from,e.curve.to)&&(0,l.pointIsOnLine)(e.curve.cp2,e.curve.from,e.curve.to))return te([e.curve.from,e.curve.to])}else if("nurbs curve"===e.type){if(e.curve.points.length<2)return;if(2===e.curve.points.length)return te([e.curve.points[0],e.curve.points[1]])}return e}function ne(e){const t=[];for(const n of e){const e=te(n);e&&t.push(e)}return t}function re(e,t=1){const n=e.map((e=>{const t=(0,p.deduplicatePosition)((0,v.getGeometryLinesPoints)(e,10));return{points:t,lines:e,direction:Math.sign((0,l.getPolygonArea)(t))}})),r=(n.find((e=>n.every((t=>t===e||!(0,l.pointInPolygon)(e.points[0],t.points)))))||n[0]).direction,o=[];for(const e of n){const n=e.direction;o.push((0,x.getParallelGeometryLinesByDistanceDirectionIndex)(e.lines,n===r?t:-t,(0,x.pointSideToIndex)(n),"bevel"))}return o.map((e=>oe(e)))}function oe(e){const t=(0,y.reverseClosedGeometryLinesIfAreaIsNegative)(e),n=t!==e;return e=t,e=(0,g.maximumBy)(ee(e),(e=>Math.abs((0,l.getPolygonArea)((0,v.getGeometryLinesPoints)(e,10))))),n&&(e=(0,y.reverseGeometryLines)(e)),e}function ie(e,t){const n=(0,p.deduplicatePosition)(Array.from((0,r.iterateGeometryLinesSelfIntersectionPoints)(e)));if(n.length>0){let r=(0,C.breakGeometryLines)(e,n);const o=r.filter(((e,t)=>t%2==0)),i=r.filter(((e,t)=>t%2==1));return r=Math.min(...o.map((e=>e.map((e=>(0,b.getPointAndGeometryLineMinimumDistance)(t,e))))).flat())>Math.min(...i.map((e=>e.map((e=>(0,b.getPointAndGeometryLineMinimumDistance)(t,e))))).flat())?i:o,(0,g.mergeItems)(r,C.mergeGeometryLines)}return[e]}function ae(e,t){if(Array.isArray(e)||"ray"===e.type)return 0;if("arc"===e.type)return(0,i.getArcCurvature)(e.curve);if("ellipse arc"===e.type){const n=(0,h.angleToRadian)($(t,e.curve));return(0,a.getEllipseArcCurvatureAtRadian)(e.curve,n)}if("quadratic curve"===e.type)return(0,o.getQuadraticCurveCurvatureAtParam)(e.curve,t);if("bezier curve"===e.type)return(0,o.getBezierCurveCurvatureAtParam)(e.curve,t);if("hyperbola curve"===e.type){const n=X(t,e.curve.t1,e.curve.t2);return(0,E.getHyperbolaCurvatureAtParam)(e.curve,n)}return(0,u.getNurbsCurveCurvatureAtParam)(e.curve,t*(0,u.getNurbsMaxParam)(e.curve))}function se(e,t){let n=(0,g.minimumsBy)(t.map((t=>L(A({},(0,b.getPointAndGeometryLineNearestPointAndDistance)(e,t)),{line:t}))),(e=>e.distance));if(n.length>1){const t=(0,g.maximumsBy)(n.map((t=>{const n=N(t.point,t.line);let r=(0,f.normalizeRadian)((0,h.getTwoPointsRadian)(t.point,e)-V(n,t.line)),o=!1;return r>Math.PI/2?(r-=Math.PI,o=!0):r<-Math.PI/2?r+=Math.PI:(0,g.largerThan)(r,0)&&(o=!0),L(A({},t),{reversed:o,param:n,radian:Math.abs(r)})})),(e=>e.radian));n=t.length>1?(0,g.maximumsBy)(t,(e=>ae(e.line,e.param)*(e.reversed?-1:1))):t}return n.map((e=>e.line))}function ce(e){const t=[];let n,r=[];for(const o of e){const{start:e,end:i}=O(o);!(r.length>0)||n&&e&&(0,p.isSamePoint)(n,e)||(t.push(r),r=[]),r.push(o),n=i}return r.length>0&&t.push(r),t}function le(e){return Array.isArray(e)?(0,l.twoPointLineToGeneralFormLine)(...e):(0,l.pointAndDirectionToGeneralFormLine)(e.line,(0,h.angleToRadian)(e.line.angle))}function ue(e){return Array.isArray(e)?e[0]:e.line}function pe(e){if(Array.isArray(e)){const t=e[1].x-e[0].x,n=e[1].y-e[0].y,r=r=>({x:e[0].x+t*r,y:e[0].y+n*r});return[e=>[r(e),{x:t,y:n}],e=>[r(e),{x:t,y:n},{x:0,y:0}]]}if("arc"===e.type||"ellipse arc"===e.type||"quadratic curve"===e.type||"bezier curve"===e.type||"hyperbola curve"===e.type){let t;return"arc"===e.type?t=(0,i.getArcDerivatives)(e.curve):"ellipse arc"===e.type?t=(0,a.getEllipseArcDerivatives)(e.curve):"quadratic curve"===e.type?t=(0,o.getQuadraticCurveDerivatives)(e.curve):"bezier curve"===e.type?t=(0,o.getBezierCurveDerivatives)(e.curve):"hyperbola curve"===e.type&&(t=(0,E.getHyperbolaSegmentDerivatives)(e.curve)),[e=>[t[0](e),t[1](e)],e=>[t[0](e),t[1](e),t[2](e)]]}if("ray"===e.type){const t=(0,h.angleToRadian)(e.line.angle),n=e.line.reversed?-1:1,r={x:Math.cos(t)*n,y:Math.sin(t)*n};return[t=>[(0,l.getRayPointAtDistance)(e.line,t),r],t=>[(0,l.getRayPointAtDistance)(e.line,t),r,{x:0,y:0}]]}const t=(0,u.toVerbNurbsCurve)(e.curve);return[e=>{const n=t.derivatives(e);return[(0,u.fromVerbPoint)(n[0]),(0,u.fromVerbPoint)(n[1])]},e=>{const n=t.derivatives(e,2);return[(0,u.fromVerbPoint)(n[0]),(0,u.fromVerbPoint)(n[1]),(0,u.fromVerbPoint)(n[2])]}]}},5065:(e,t,n)=>{"use strict";n.r(t),n.d(t,{getKeys:()=>r});const r=Object.keys},8258:(e,t,n)=>{"use strict";n.r(t),n.d(t,{boldHatch:()=>W,geometryLinesToHatches:()=>V,getGeometryLinesPoints:()=>I,getHatchByPosition:()=>T,getHatchHoles:()=>L,getHatchesDifference:()=>G,getHatchesIntersection:()=>j,getHatchesUnion:()=>U,getRightSideGeometryLineAtPoint:()=>H,mergeHatchBorderAndBorder:()=>z,mergeHatchBorderAndHole:()=>O,mergeHatchBorders:()=>F,mergeHatches:()=>N,optimizeHatch:()=>D,optimizeHatchInternally:()=>B});var r=n(5629),o=n(5717),i=n(23),a=n(2792),s=n(5773),c=n(6842),l=n(1715),u=n(1796),p=n(2298),d=n(2318),f=n(491),g=n(2572),h=n(8230),m=n(1785),y=n(8306),v=n(9681),x=n(2986),b=Object.defineProperty,C=Object.defineProperties,E=Object.getOwnPropertyDescriptors,P=Object.getOwnPropertySymbols,w=Object.prototype.hasOwnProperty,k=Object.prototype.propertyIsEnumerable,_=(e,t,n)=>t in e?b(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,S=(e,t)=>{for(var n in t||(t={}))w.call(t,n)&&_(e,n,t[n]);if(P)for(var n of P(t))k.call(t,n)&&_(e,n,t[n]);return e},R=(e,t)=>C(e,E(t));function T(e,t,n,r){const o=void 0!==n&&n>e.x?[e,{x:n,y:e.y}]:{type:"ray",line:{x:e.x,y:e.y,angle:0}},i=[],a=t(o);for(const t of a)if(t)for(const n of t.lines){const r=(0,f.getTwoGeometryLinesIntersectionPoint)(n,o);i.push(...r.filter((t=>!(0,s.isSamePoint)(t,e))).map((e=>({line:n,point:e,id:t.id}))))}if(0!=i.length){i.sort(((e,t)=>e.point.x-t.point.x));for(const n of i){const o=A(n,0,t,r);if(o.lines.length>0&&(0,u.pointInPolygon)(e,I(o.lines)))return o}}}function A(e,t,n,r){r&&console.info(`Line ${(0,i.printGeometryLine)(e.line)}`),function(e,t){const n=(0,o.getGeometryLineParamAtPoint)(t.point,t.line);if((0,a.isZero)(n))return;if((0,a.isSameNumber)(n,1))return void(t.line=(0,y.reverseGeometryLine)(t.line));const r=(0,o.getGeometryLineTangentRadianAtParam)(n,t.line);1===(0,m.getRadianSideOfRadian)(e,r)&&(t.line=(0,y.reverseGeometryLine)(t.line))}(t,e);const c=(0,o.isGeometryLinesClosed)([e.line]);let l=M(e,n(e.line),r);const u=[],p=new Set;let d=0;for(;;){if(d++>=30){console.info(e.point,u);break}if(!l)break;const t=(0,o.getGeometryLineStartAndEnd)(l.line).start;if(t&&!(0,s.isSamePoint)(t,e.point)&&l.next&&(0,o.pointIsOnGeometryLine)(e.point,l.line)){u.push((0,o.getPartOfGeometryLine)(0,(0,o.getGeometryLineParamAtPoint)(e.point,l.line),l.line,c)),p.add(e.id);break}if(u.some((e=>(0,a.deepEquals)(e,null==l?void 0:l.line))))return{lines:[],ids:[]};if(u.push(l.line),p.add(l.id),!l.next)break;l=M(l.next,n(l.next.line),r)}if(0===u.length)return{lines:[],ids:[]};if(!(0,o.isGeometryLinesClosed)(u))return{lines:[],ids:[]};if(u.length>1){const e=(0,g.mergeGeometryLine)(u[u.length-1],u[0]);e&&(u.splice(0,1),u.splice(u.length-1,1,e))}return{lines:u,ids:Array.from(p)}}function L(e,t,n){const r=I(e),i=t((0,c.getPointsBoundingUnsafe)(r)),p=[];for(const t of i)if(t)for(const n of t.lines){const i=(0,o.getGeometryLineStartAndEnd)(n).start;i&&(0,u.pointInPolygon)(i,r)&&e.every((e=>!(0,o.pointIsOnGeometryLine)(i,e)))&&p.push({lines:[n],start:i,id:t.id})}if(0===p.length)return;const d=[],g=new Set;for(const e of p){if(d.length>0&&d.some((t=>(0,u.pointInPolygon)(e.start,I(t))||t.some((t=>(0,o.pointIsOnGeometryLine)(e.start,t))))))continue;const t=[r[0],e.start],i=[];for(const e of p)for(const n of e.lines){const r=(0,f.getTwoGeometryLinesIntersectionPoint)(n,t);i.push(...r.map((r=>({line:n,point:r,distance:(0,s.getTwoPointsDistance)(t[0],r),id:e.id}))))}if(0==i.length)continue;const c=A((0,a.minimumBy)(i,(e=>e.distance)),(0,l.getTwoPointsRadian)(t[1],t[0]),(()=>p),n);if(0!==c.lines.length){d.push(c.lines);for(const e of c.ids)g.add(e)}}return{holes:d,ids:Array.from(g)}}function M(e,t,n){const r=(0,o.isGeometryLinesClosed)([e.line]),s=(0,o.getGeometryLineParamAtPoint)(e.point,e.line);if(void 0===s)return;n&&console.info(`Target ${(0,i.printGeometryLine)(e.line)} at ${(0,i.printParam)(s)} ${(0,i.printPoint)(e.point)}`);let c=[];for(const n of t)if(n)for(const t of n.lines){const i=(0,f.getTwoGeometryLinesIntersectionPoint)(t,e.line);for(const l of i){const i=(0,o.getGeometryLineParamAtPoint)(l,e.line);(0,a.largerThan)(i,s)?c.push({line:t,param:i,point:l,id:n.id}):r&&c.push({line:t,param:i+1,point:l,id:n.id})}}let l,u=[];for(;!l;){if(u.length>0&&(c=c.filter((e=>!u.includes(e)))),0===c.length)return r?{line:e.line,id:e.id}:void 0;u=(0,a.minimumsBy)(c,(e=>e.param));const t=u[0].point,{line:n,reversed:o}=H(t,e.line,u.map((e=>e.line))),i=u.find((e=>e.line===n));i&&(l={line:o?(0,y.reverseGeometryLine)(n):n,point:t,id:i.id})}const p=(0,o.getGeometryLineParamAtPoint)(l.point,e.line),d=(0,o.getPartOfGeometryLine)(s,p,e.line,r);return n&&console.info(`Result ${(0,i.printParam)(s)}->${(0,i.printParam)(p)} ${(0,i.printGeometryLine)(d)}`),n&&console.info(`Line ${(0,i.printGeometryLine)(l.line)}`),{line:d,id:e.id,next:l}}function I(e,t=100,n=5){const o=[];for(const i of e)Array.isArray(i)?(0===o.length&&o.push(i[0]),o.push(i[1])):"arc"===i.type?o.push(...(0,d.arcToPolyline)(i.curve,n)):"ellipse arc"===i.type?o.push(...(0,p.ellipseArcToPolyline)(i.curve,n)):"quadratic curve"===i.type?o.push(...(0,r.getQuadraticCurvePoints)(i.curve.from,i.curve.cp,i.curve.to,t)):"bezier curve"===i.type?o.push(...(0,r.getBezierCurvePoints)(i.curve.from,i.curve.cp1,i.curve.cp2,i.curve.to,t)):"nurbs curve"===i.type?o.push(...(0,h.getNurbsPoints)(i.curve.degree,i.curve.points,i.curve.knots,i.curve.weights,t)):"hyperbola curve"===i.type&&o.push(...(0,x.getHyperbolaPoints)(i.curve,t));return o}function O(e,t){const n=(0,a.first)((0,f.iterateGeometryLinesIntersectionPoints)(e,t));if(n){const r=(0,o.getGeometryLinesParamAtPoint)(n,e),i=(0,o.getGeometryLinesParamAtPoint)(n,t);return[...(0,o.getPartOfGeometryLines)(0,r,e),...(0,o.getPartOfGeometryLines)(i,0,t),...(0,o.getPartOfGeometryLines)(t.length,i,t),...(0,o.getPartOfGeometryLines)(r,e.length,e)]}}function D(e,t){return B(e=(0,y.reverseClosedGeometryLinesIfAreaIsNegative)(e),t=t.map((e=>(0,y.reverseClosedGeometryLinesIfAreaIsNegative)(e))))}function B(e,t){for(let n=0;nB(e,t))).flat()}return[{border:e,holes:t}]}function z(e,t){const n=(0,a.first)((0,f.iterateGeometryLinesIntersectionPoints)(e,t));if(n){const r=(0,o.getGeometryLinesParamAtPoint)(n,e),i=(0,o.getGeometryLinesParamAtPoint)(n,t);return[...(0,o.getPartOfGeometryLines)(0,r,e),...(0,o.getPartOfGeometryLines)(i,t.length,t),...(0,o.getPartOfGeometryLines)(0,i,t),...(0,o.getPartOfGeometryLines)(r,e.length,e)]}}function F(e,t){const n=z(e=(0,y.reverseClosedGeometryLinesIfAreaIsNegative)(e),t=(0,y.reverseClosedGeometryLinesIfAreaIsNegative)(t));if(n){const e=(0,o.splitGeometryLines)(n,"union");return e.length<2?e[0]:(0,a.maximumBy)(e,(e=>(0,u.getPolygonArea)(I(e))))}}function N(e,t){const n=F(e.border,t.border);if(n)return D(n,(0,a.deduplicate)([...e.holes.map((e=>G({border:e,holes:[]},[t]).map((e=>e.border)))).flat(),...t.holes.map((t=>G({border:t,holes:[]},[e]).map((e=>e.border)))).flat()],v.isSameGeometrylines))}function U(e,t){return(0,a.applyToItems)(e,t,((e,t)=>N(e,t)||[e,t]))}function G(e,t){const n=[],r=[e.border];e.holes&&n.push(...e.holes);const o=[];for(const r of t)n.push(r.border),r.holes&&o.push(...r.holes.map((t=>j(e,[{border:t,holes:[]}]))).flat());return o.push(...r.map((e=>D(e,n))).flat()),o}function j(e,t){const n=G(e,t);return G(e,n)}function V(e){if(0===e.length)return[];if(1===e.length)return[{border:(0,y.reverseClosedGeometryLinesIfAreaIsNegative)(e[0]),holes:[]}];const t=e.map((e=>(e=(0,y.reverseClosedGeometryLinesIfAreaIsNegative)(e),{points:(0,s.deduplicatePosition)(I(e,10)),lines:e})));let n=[];for(const e of t){const t=n.find((t=>(0,u.pointInPolygon)(e.points[0],t.border.points)&&t.holes.every((t=>!(0,u.pointInPolygon)(e.points[0],t.points)))));if(t)t.holes.push(e);else{const t=[],r=[];for(const o of n)(0,u.pointInPolygon)(o.border.points[0],e.points)?(r.push(o.border),t.push(...o.holes.map((e=>({border:e,holes:[]}))))):t.push(o);n=t,n.push({border:e,holes:r})}}return n.map((e=>({border:e.border.lines,holes:e.holes.map((e=>(0,y.reverseGeometryLines)(e.lines)))})))}function W(e,t=1){return{border:(0,o.trimHatchGeometryLines)((0,m.getParallelGeometryLinesByDistanceDirectionIndex)(e.border,t,1,"bevel")),holes:e.holes.map((e=>(0,o.trimHatchGeometryLines)((0,m.getParallelGeometryLinesByDistanceDirectionIndex)(e,-t,0,"bevel"))))}}function H(e,t,n){const r=(0,o.getGeometryLineParamAtPoint)(e,t);(0,a.isZero)(r)||(0,a.equals)(r,1)||(n=[...n,t]);let i=(0,o.getGeometryLineTangentRadianAtParam)(r,t),s=(0,o.getGeometryLineCurvatureAtParam)(t,r);(0,a.isZero)(r)||(i=(0,y.reverseRadian)(i),s=-s);const c=(0,a.maximumsBy)(n.map((t=>{const n=(0,o.getGeometryLineParamAtPoint)(e,t),r=(0,o.getGeometryLineTangentRadianAtParam)(n,t),c=[];(0,o.isGeometryLinesClosed)([t])?c.push({radian:r,reversed:!1},{radian:(0,y.reverseRadian)(r),reversed:!0}):(0,a.isZero)(n)?c.push({radian:r,reversed:!1}):(0,a.equals)(n,1)?c.push({radian:(0,y.reverseRadian)(r),reversed:!0}):c.push({radian:r,reversed:!1},{radian:(0,y.reverseRadian)(r),reversed:!0});for(const e of c){for(;(0,a.lessOrEqual)(e.radian,i-2*Math.PI);)e.radian+=2*Math.PI;for(;(0,a.largerThan)(e.radian,i);)e.radian-=2*Math.PI;(0,a.equals)(e.radian,i)&&(e.curvature=(0,o.getGeometryLineCurvatureAtParam)(t,n)*(e.reversed?-1:1),(0,a.largerOrEqual)(e.curvature,s)&&(e.radian-=2*Math.PI))}return R(S({},(0,a.maximumBy)(c,(e=>e.radian))),{line:t,param:n})})),(e=>e.radian));let l=c[0];return c.length>1&&(l=(0,a.maximumBy)(c,(e=>{var t;return null!=(t=e.curvature)?t:(0,o.getGeometryLineCurvatureAtParam)(e.line,e.param)*(e.reversed?-1:1)}))),{line:l.line,reversed:l.reversed}}},2986:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Hyperbola:()=>T,HyperbolaSegment:()=>A,getArcHyperbolaSegmentIntersectionPoints:()=>Q,getBezierCurveAndHyperbolaExtremumPoints:()=>pe,getBezierCurveHyperbolaSegmentIntersectionPoints:()=>re,getCircleAndHyperbolaExtremumPoints:()=>ce,getCircleHyperbolaSegmentIntersectionPoints:()=>J,getEllipseAndHyperbolaExtremumPoints:()=>le,getEllipseArcHyperbolaSegmentIntersectionPoints:()=>ee,getEllipseHyperbolaSegmentIntersectionPoints:()=>te,getHyperbolaBounding:()=>z,getHyperbolaCoordinatePointAtParam:()=>O,getHyperbolaCurvatureAtParam:()=>q,getHyperbolaDerivatives:()=>W,getHyperbolaLength:()=>F,getHyperbolaParamAtPoint:()=>I,getHyperbolaParamByLength:()=>N,getHyperbolaPointAtParam:()=>M,getHyperbolaPoints:()=>D,getHyperbolaSegmentDerivatives:()=>H,getHyperbolaSegmentStartAndEnd:()=>U,getHyperbolaTangentRadianAtParam:()=>V,getLineAndHyperbolaExtremumPoint:()=>se,getLineHyperbolaSegmentIntersectionPoints:()=>Z,getLineSegmentHyperbolaSegmentIntersectionPoints:()=>K,getParallelHyperbolaSegmentsByDistance:()=>X,getPerpendicularParamsToHyperbola:()=>L,getPointAndHyperbolaNearestPointAndDistance:()=>B,getPointSideOfHyperbolaSegment:()=>Y,getQuadraticCurveAndHyperbolaExtremumPoints:()=>ue,getQuadraticCurveHyperbolaSegmentIntersectionPoints:()=>ne,getTangencyPointToHyperbola:()=>oe,getTwoHyperbolaExtremumPoints:()=>de,isSameHyperbola:()=>ie,mergeHyperbolaSegments:()=>ae,pointIsOnHyperbola:()=>G,pointIsOnHyperbolaSegment:()=>j,reverseHyperbola:()=>$});var r=n(5629),o=n(6842),i=n(2318),a=n(2298),s=n(1475),c=n(7558),l=n(1796),u=n(2792),p=n(5147),d=n(5184),f=n(8392),g=n(5773),h=n(1715),m=n(8306),y=n(360),v=n(5569),x=Object.defineProperty,b=Object.defineProperties,C=Object.getOwnPropertyDescriptors,E=Object.getOwnPropertySymbols,P=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable,k=Math.pow,_=(e,t,n)=>t in e?x(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,S=(e,t)=>{for(var n in t||(t={}))P.call(t,n)&&_(e,n,t[n]);if(E)for(var n of E(t))w.call(t,n)&&_(e,n,t[n]);return e},R=(e,t)=>b(e,C(t));const T=(0,v.and)(g.Position,{a:v.number,b:v.number,angle:v.number}),A=(0,v.and)(T,{t1:v.number,t2:v.number});function L({x:e,y:t},{a:n,b:r,angle:o,x:i,y:a},c){const l=(0,d.getParabolaXAxisRadian)({angle:o}),p=Math.sin(l),f=Math.cos(l),g=f*r,h=-p*n,m=p*r,y=f*n,v=i-h-e,x=a-y-t,b=v*h+x*y,C=v*g+x*m,E=g*h+m*y,P=n*n+r*r;let w=(0,s.calculateEquation4)(b*b+E*E,2*(b*C+E*P),-b*b+C*C+2*E*E+P*P,2*(E*P-b*C),E*E-C*C,c);w=w.filter((e=>(0,u.isBetween)(e,-1,1)));const k=w.map((e=>Math.tan(Math.asin(e))));return(0,u.deduplicate)(k,u.isSameNumber)}function M(e,t){return(0,y.transformPointFromCoordinate2D)(O(e,t),e,(0,d.getParabolaXAxisRadian)(e))}function I({angle:e,x:t,y:n,a:r,b:o},i){const a=(0,d.getParabolaXAxisRadian)({angle:e}),s=Math.sin(a),c=Math.cos(a),l=c*o,u=-s*r,p=s*o,f=c*r,g=t-u,h=n-f;return(f*i.x-u*i.y-f*g+u*h)/(f*l-u*p)}function O({a:e,b:t},n){return{x:t*n,y:e*(Math.sqrt(k(n,2)+1)-1)}}function D(e,t){const n=(e.t2-e.t1)/t,r=[],o=(0,y.getCoordinateMatrix2D)(e,(0,d.getParabolaXAxisRadian)(e));for(let i=0;i<=t;i++){const t=(0,y.getCoordinateVec2D)(O(e,e.t1+i*n)),a=p.matrix.multiplyVec(o,t);r.push({x:a[0],y:a[1]})}return r}function B(e,t,n=!1){let r=L(e,t);n||(r=r.filter((e=>(0,u.isBetween)(e,t.t1,t.t2))),r.push(t.t1,t.t2));const o=r.map((e=>({u:e,p:M(t,e)}))).map((t=>({param:t.u,point:t.p,distance:(0,g.getTwoPointsDistance)(e,t.p)})));return(0,u.minimumBy)(o,(e=>e.distance))}function z(e){const{a:t,b:n,angle:r}=e,i=(0,d.getParabolaXAxisRadian)({angle:r}),a=Math.sin(i),s=Math.cos(i),c=s*n,l=-a*t,p=a*n,f=s*t,g=[M(e,e.t1),M(e,e.t2)],h=l*l-c*c;if((0,u.largerThan)(h,0)){const t=Math.abs(c)/Math.sqrt(h)*Math.sign(-c*l);(0,u.isBetween)(t,e.t1,e.t2)&&g.push(M(e,t))}const m=f*f-p*p;if((0,u.largerThan)(m,0)){const t=Math.abs(p)/Math.sqrt(m)*Math.sign(-p*f);(0,u.isBetween)(t,e.t1,e.t2)&&g.push(M(e,t))}return(0,o.getPointsBoundingUnsafe)(g)}function F(e,t){const{a:n,b:r,t1:o,t2:i}=e,a=k(n,2),s=k(r,2);return(0,c.rombergIntegral)(o,i,(e=>{const t=k(e,2);return Math.sqrt(s+a*t/(t+1))}),t)}function N(e,t,n=u.delta2){const r=k(e.a,2),o=k(e.b,2);return(0,s.newtonIterate)((0,u.getTwoNumberCenter)(e.t1,e.t2),(n=>F(R(S({},e),{t2:n}))-t),(e=>{const t=k(e,2);return Math.sqrt(o+r*t/(t+1))}),n)}function U(e){return{start:M(e,e.t1),end:M(e,e.t2)}}function G(e,{angle:t,a:n,b:r,x:o,y:i}){const a=(0,d.getParabolaXAxisRadian)({angle:t}),c=Math.sin(a),l=Math.cos(a),p=l*r,f=-c*n,g=c*r,h=l*n,m=o-f,y=i-h,v=e.x-m;return(0,s.calculateEquation2)(f*f-p*p,2*p*v,f*f-v*v).filter((t=>(0,u.isSameNumber)(y+g*t+h*Math.sqrt(k(t,2)+1),e.y,u.delta3))).length>0}function j(e,t,n=u.NOT_EXTENDED){if(n.head&&n.body&&n.tail)return!0;if(!n.head&&!n.body&&!n.tail)return!1;const r=I(t,e);return(0,u.isBetween)(r,t.t1,t.t2,n)}function V({angle:e,a:t,b:n},r){const o=(0,d.getParabolaXAxisRadian)({angle:e}),i=Math.sin(o),a=Math.cos(o),s=a*n,c=-i*t,l=i*n,u=a*t,p=Math.sqrt(k(r,2)+1);return Math.atan2(u*r/p+l,c*r/p+s)}function W({angle:e,a:t,b:n,x:r,y:o}){const i=(0,d.getParabolaXAxisRadian)({angle:e}),a=Math.sin(i),s=Math.cos(i),c=s*n,l=-a*t,u=a*n,p=s*t,f=r-l,g=o-p;return[e=>{const t=Math.sqrt(k(e,2)+1);return{x:f+c*e+l*t,y:g+u*e+p*t}},e=>{const t=e/Math.sqrt(k(e,2)+1);return{x:l*t+c,y:p*t+u}},e=>{const t=k(e,2),n=t+1,r=Math.sqrt(n),o=1/r-t/n/r;return{x:l*o,y:p*o}}]}function H({angle:e,a:t,b:n,x:r,y:o,t1:i,t2:a}){const s=(0,d.getParabolaXAxisRadian)({angle:e}),c=Math.sin(s),l=Math.cos(s),u=l*n,p=-c*t,f=c*n,g=l*t,h=r-p,m=o-g,y=a-i;return[e=>{const t=y*e+i,n=Math.sqrt(k(t,2)+1);return{x:h+u*t+p*n,y:m+f*t+g*n}},e=>{const t=y*e+i,n=t/Math.sqrt(k(t,2)+1);return{x:(p*n+u)*y,y:(g*n+f)*y}},e=>{const t=k(y*e+i,2),n=t+1,r=Math.sqrt(n),o=(1/r-t/n/r)*y*y;return{x:p*o,y:g*o}}]}function q(e,t){const n=W(e),{x:r,y:o}=n[1](t),{x:i,y:a}=n[2](t);return(r*a-o*i)/k(k(r,2)+k(o,2),1.5)}function $(e){return R(S({},e),{t1:e.t2,t2:e.t1})}function X(e,t){if((0,u.isZero)(t))return[e,e];e.t1>e.t2&&(t=-t);const n=(0,g.getPointByLengthAndRadian)(e,t,(0,h.angleToRadian)(e.angle)),r=(0,g.getPointByLengthAndRadian)(e,-t,(0,h.angleToRadian)(e.angle));return[R(S({},e),{x:n.x,y:n.y}),R(S({},e),{x:r.x,y:r.y})]}function Y(e,t){const n=B(e,t,!0),r=V(t,n.param),o=(0,l.pointAndDirectionToGeneralFormLine)(n.point,r);return(0,l.getPointSideOfLine)(e,o)*(t.t1>t.t2?-1:1)}function K(e,t,n,r=u.NOT_EXTENDED,o=u.NOT_EXTENDED){return Z(e,t,n,o).filter((n=>(0,l.pointIsOnLineSegment)(n,e,t,r)))}function Z(e,t,{angle:n,x:r,y:o,a:i,b:a,t1:c,t2:p},f=u.NOT_EXTENDED){const{x:g,y:h}=e,{x:m,y}=t,v=(0,d.getParabolaXAxisRadian)({angle:n}),x=Math.sin(v),b=Math.cos(v),C=b*a,E=-x*i,P=x*a,w=b*i,_=r-E,S=o-w,R=m-g,T=y-h,A=(_-g)*T-(S-h)*R,L=C*T-P*R,M=E*T-w*R;let I=(0,s.calculateEquation2)(L*L-M*M,2*A*L,A*A-M*M);I=I.filter((e=>(0,u.isBetween)(e,c,p,f)));let O=I.map((e=>{const t=Math.sqrt(k(e,2)+1);return{x:_+C*e+E*t,y:S+P*e+w*t}}));return O=O.filter((n=>(0,l.pointIsOnLine)(n,e,t))),O}function Q(e,t,n=u.NOT_EXTENDED,r=u.NOT_EXTENDED){return J(e,t,r).filter((t=>(0,i.pointIsOnArc)(t,e,n)))}function J(e,{angle:t,x:n,y:r,a:o,b:a,t1:c,t2:l},p=u.NOT_EXTENDED){const{x:f,y:g,r:h}=e,m=(0,d.getParabolaXAxisRadian)({angle:t}),y=Math.sin(m),v=Math.cos(m),x=v*a,b=-y*o,C=y*a,E=v*o,P=n-b,w=r-E,_=P-f,S=w-g,R=o*o+a*a,T=2*(x*_+C*S),A=2*(b*_+E*S),L=o*o+_*_+S*S-h*h;let M=(0,s.calculateEquation4)(R*R,2*R*T,T*T+2*R*L-A*A,2*T*L,L*L-A*A);M=M.filter((e=>(0,u.isBetween)(e,c,l,p)));let I=M.map((e=>{const t=Math.sqrt(k(e,2)+1);return{x:P+x*e+b*t,y:w+C*e+E*t}}));return I=I.filter((t=>(0,i.pointIsOnCircle)(t,e))),I}function ee(e,t,n=u.NOT_EXTENDED,r=u.NOT_EXTENDED){return te(e,t,r).filter((t=>(0,a.pointIsOnEllipseArc)(t,e,n)))}function te(e,{angle:t,x:n,y:r,a:o,b:i,t1:c,t2:l},p=u.NOT_EXTENDED){const{rx:f,ry:g,cx:m,cy:y,angle:v}=e,x=(0,d.getParabolaXAxisRadian)({angle:t}),b=Math.sin(x),C=Math.cos(x),E=C*i,P=-b*o,w=b*i,_=C*o,S=n-P,R=r-_,T=(0,h.angleToRadian)(v),A=Math.sin(T),L=Math.cos(T),M=1/f/f,I=1/g/g,O=S-m,D=R-y,B=L*O+A*D,z=L*E+A*w,F=L*P+A*_,N=L*D-A*O,U=L*w-A*E,G=L*_-A*P,j=M*B*B+M*F*F+I*G*G+I*N*N-1,V=2*(M*B*z+I*N*U),W=M*z*z+I*U*U+M*F*F+I*G*G,H=2*(M*B*F+I*N*G),q=2*(M*z*F+I*U*G);let $=(0,s.calculateEquation4)(W*W-q*q,2*(V*W-H*q),V*V+2*j*W-H*H-q*q,2*(j*V-H*q),j*j-H*H);$=$.filter((e=>(0,u.isBetween)(e,c,l,p)));let X=$.map((e=>{const t=Math.sqrt(k(e,2)+1);return{x:S+E*e+P*t,y:R+w*e+_*t}}));return X=X.filter((t=>(0,a.pointIsOnEllipse)(t,e))),X}function ne(e,{angle:t,x:n,y:o,a:i,b:a,t1:c,t2:l},p=u.NOT_EXTENDED,f=p){const g=(0,d.getParabolaXAxisRadian)({angle:t}),h=Math.sin(g),m=Math.cos(g),y=m*a,v=-h*i,x=h*a,b=m*i,C=n-v,E=o-b,{from:{x:P,y:w},cp:{x:_,y:S},to:{x:R,y:T}}=e,A=_-P,L=R-_-A,M=S-w,I=T-S-M,O=2*(A*I-L*M),D=P*I-w*L;let B;if((0,u.isZero)(O)){const e=-x*L+y*I,t=v*I-b*L,n=-E*L+C*I-D;B=(0,s.calculateEquation2)(t*t-e*e,-2*e*n,t*t-n*n)}else{const e=2*A*I*O-2*L*I*D-O*O,t=-2*A*L*O+2*L*L*D,n=L*I*I,r=-2*L*L*I,o=L*L*L,i=y*y*n+v*v*n+v*b*r+y*x*r+x*x*o+b*b*o,a=2*y*v*n+v*x*r+y*b*r+2*x*b*o,c=2*y*C*n+x*C*r+y*E*r+2*x*E*o+y*e+x*t,l=2*v*C*n+b*C*r+v*E*r+2*b*E*o+v*e+b*t,u=C*C*n+v*v*n+v*b*r+C*E*r+C*e+E*E*o+b*b*o+E*t+(P*O*O+-2*A*O*D+L*D*D);B=(0,s.calculateEquation4)(a*a-i*i,2*(a*l-i*c),a*a-c*c+l*l-2*i*u,2*(a*l-c*u),l*l-u*u)}B=B.filter((e=>(0,u.isBetween)(e,c,l,f)));let z=B.map((e=>{const t=Math.sqrt(k(e,2)+1);return{x:C+y*e+v*t,y:E+x*e+b*t}}));return z=z.filter((t=>(0,r.pointIsOnQuadraticCurve)(t,e)&&(0,u.isValidPercent)((0,r.getQuadraticCurvePercentAtPoint)(e,t),p))),z}function re(e,{angle:t,x:n,y:o,a:i,b:a,t1:c,t2:l},p=u.NOT_EXTENDED,f=p){const g=(0,d.getParabolaXAxisRadian)({angle:t}),h=Math.sin(g),m=Math.cos(g),y=m*a,v=-h*i,x=h*a,b=m*i,C=n-v,E=o-b,{from:{x:P,y:w},cp1:{x:_,y:S},cp2:{x:R,y:T},to:{x:A,y:L}}=e,M=3*_-P+-3*R+A,I=3*(P-2*_+R),O=3*(_-P),D=3*S-w+-3*T+L,B=I*D-M*(3*(w-2*S+T)),z=O*D-M*(3*(S-w));let F;if((0,u.isZero)(B)){const e=P*D-w*M;if((0,u.isZero)(z)){const t=-b*M+v*D,n=-x*M+y*D,r=E*M+C*D-e;F=(0,s.calculateEquation2)(n*n+-t*t,2*n*r,r*r+-t*t)}else{const t=M*D*D*D,n=-3*M*M*D*D,r=I*D*D*z+-3*M*D*D*e,o=3*M*M*M*D,i=-2*M*I*D*z+6*M*M*D*e,a=O*D*z*z+-2*I*D*z*e+3*M*D*e*e+-z*z*z,c=-M*M*M*M,l=M*M*I*z+-3*M*M*M*e,u=-M*O*z*z+2*M*I*z*e+-3*M*M*e*e,p=v*v*v*t+v*v*b*n+v*b*b*o+b*b*b*c,d=3*y*v*v*t+v*v*x*n+2*y*v*b*n+2*v*x*b*o+y*b*b*o+3*x*b*b*c,f=3*v*v*C*t+2*v*b*C*n+v*v*E*n+b*b*C*o+2*v*b*E*o+3*b*b*E*c+v*v*r+v*b*i+b*b*l,g=6*y*v*C*t+2*v*x*C*n+2*y*b*C*n+2*y*v*E*n+2*x*b*C*o+2*v*x*E*o+2*y*b*E*o+6*x*b*E*c+2*y*v*r+v*x*i+y*b*i+2*x*b*l,h=p+(3*y*y*v*t+2*y*v*x*n+y*y*b*n+v*x*x*o+2*y*x*b*o+3*x*x*b*c),m=p+(3*v*C*C*t+b*C*C*n+2*v*C*E*n+2*b*C*E*o+v*E*E*o+3*b*E*E*c+2*v*C*r+b*C*i+2*b*E*l+v*E*i+v*a+b*u),w=d+(y*y*y*t+y*y*x*n+y*x*x*o+x*x*x*c),k=f+(3*y*y*C*t+2*y*x*C*n+y*y*E*n+x*x*C*o+2*y*x*E*o+3*x*x*E*c+y*y*r+y*x*i+x*x*l),_=d+(3*y*C*C*t+x*C*C*n+2*y*C*E*n+2*x*C*E*o+y*E*E*o+3*x*E*E*c+2*y*C*r+x*C*i+y*E*i+2*x*E*l+y*a+x*u),S=f+(C*C*C*t+C*C*E*n+C*E*E*o+E*E*E*c+C*C*r+C*E*i+E*E*l+C*a+E*u+(P*z*z*z+-O*z*z*e+I*z*e*e+-M*e*e*e));F=(0,s.calculateEquation5)([w*w+-h*h,2*w*k+-2*g*h,-g*g+k*k+2*w*_+-h*h+-2*h*m,-2*g*h+-2*g*m+2*k*_+2*w*S,-g*g+-2*h*m+-m*m+_*_+2*k*S,-2*g*m+2*_*S,-m*m+S*S],0)}}else{const e=z/B/2,t=(P*D-w*M-z*e/2)/B,n=D/B,r=M/B,o=3*M*e*e-M*t-2*I*e+O,i=P-M*e*e*e+I*e*e+3*M*e*t-O*e-I*t,a=3*M*e*r-I*r,c=I*n-3*M*e*n-1,l=M*n,u=M*r,p=-r*l*l+-2*n*l*u,d=2*n*o*l-t*l*l-c*c,f=2*r*l*u+n*u*u,g=-2*r*o*l-2*n*o*u+2*t*l*u-2*a*c,h=n*o*o-2*t*o*l-2*i*c,m=2*r*o*u-t*u*u-a*a,k=-r*o*o+2*t*o*u-2*i*a,_=n*l*l,S=-r*u*u,R=v*v*v*_+v*v*b*p+b*b*b*S+v*b*b*f,T=3*y*v*v*_+v*v*x*p+2*y*v*b*p+3*x*b*b*S+2*v*x*b*f+y*b*b*f,A=3*v*v*C*_+2*v*b*C*p+v*v*E*p+b*b*C*f+v*v*d+3*b*b*E*S+2*v*b*E*f+v*b*g+b*b*m,L=6*y*v*C*_+2*v*x*C*p+2*y*b*C*p+2*y*v*E*p+2*x*b*C*f+2*y*v*d+6*x*b*E*S+2*v*x*E*f+2*y*b*E*f+v*x*g+y*b*g+2*x*b*m,N=R+(3*y*y*v*_+2*y*v*x*p+y*y*b*p+3*x*x*b*S+v*x*x*f+2*y*x*b*f),U=R+(3*v*C*C*_+b*C*C*p+2*v*C*E*p+2*b*C*E*f+2*v*C*d+b*C*g+3*b*E*E*S+v*E*E*f+v*E*g+2*b*E*m+v*h+b*k),G=T+(y*y*y*_+y*y*x*p+x*x*x*S+y*x*x*f),j=A+(3*y*y*C*_+2*y*x*C*p+y*y*E*p+x*x*C*f+y*y*d+3*x*x*E*S+2*y*x*E*f+y*x*g+x*x*m),V=T+(3*y*C*C*_+x*C*C*p+2*y*C*E*p+2*x*C*E*f+2*y*C*d+x*C*g+3*x*E*E*S+y*E*E*f+y*E*g+2*x*E*m+y*h+x*k),W=C*C*C*_+C*C*E*p+C*E*E*f+C*C*d+C*h+E*E*E*S+C*E*g+E*E*m+E*k+(-t*o*o-i*i)+A;F=(0,s.calculateEquation5)([G*G-N*N,2*(G*j-L*N),-L*L+j*j+2*G*V-N*N-2*N*U,-2*L*N-2*L*U+2*j*V+2*G*W,-L*L-2*N*U-U*U+V*V+2*j*W,-2*L*U+2*V*W,-U*U+W*W],0)}F=F.filter((e=>(0,u.isBetween)(e,c,l,f)));let N=F.map((e=>{const t=Math.sqrt(k(e,2)+1);return{x:C+y*e+v*t,y:E+x*e+b*t}}));return N=N.filter((t=>(0,r.pointIsOnBezierCurve)(t,e)&&(0,u.isValidPercent)((0,r.getBezierCurvePercentAtPoint)(e,t),p))),N}function oe({x:e,y:t},{a:n,b:r,angle:o,x:i,y:a},c=u.delta2){const l=(0,d.getParabolaXAxisRadian)({angle:o}),p=Math.sin(l),f=Math.cos(l),g=f*r,h=-p*n,m=p*r,y=f*n,v=i-h,x=a-y,b=x-t,C=v-e,E=-h*m+g*y,P=g*b-m*C,w=h*b-y*C;return(0,s.calculateEquation2)(P*P-w*w,-2*E*w,-E*E+P*P,c).map((e=>{const t=Math.sqrt(k(e,2)+1);return{x:v+g*e+h*t,y:x+m*e+y*t}}))}function ie(e,t){return(0,g.isSamePoint)(e,t)&&(0,u.isSameNumber)(e.a,e.a)&&(0,u.isSameNumber)(e.b,e.b)&&(0,u.isSameNumber)(e.angle,e.angle)}function ae(e,t){if(!ie(e,t))return;const n=(0,u.mergeNumberRange)([e.t1,e.t2],[t.t1,t.t2]);return n?R(S({},e),{t1:n[0],t2:n[1]}):void 0}function se(e,t){const{a:n,b:r,angle:o}=t,{a:i,b:a}=e,s=(0,d.getParabolaXAxisRadian)({angle:o}),c=Math.sin(s),l=Math.cos(s),p=i*(l*r)+a*(c*r),g=i*(-c*n)+a*(l*n),h=p*p-g*g;if((0,u.isZero)(h))return[];const m=-p*p/h;if(m<0)return[];const y=M(t,Math.sqrt(m)*Math.sign(p)*Math.sign(g)*-1);return[[(0,f.getPerpendicularPoint)(y,e),y]]}function ce(e,t){return L(e,t).map((n=>{const r=M(t,n),o=(0,i.getCircleRadian)(r,e);return[[(0,i.getCirclePointAtRadian)(e,o),r],[(0,i.getCirclePointAtRadian)(e,(0,m.reverseRadian)(o)),r]]})).flat()}function le(e,t){const[n,r,o]=(0,a.getEllipseDerivatives)(e),[i,c,l]=W(t),p=e=>{const{x:t,y:o}=n(e[0]),{x:a,y:s}=r(e[0]),{x:l,y:u}=i(e[1]),{x:p,y:d}=c(e[1]);return[(t-l)*a+(o-u)*s,(l-t)*p+(u-o)*d]},d=e=>{const{x:t,y:a}=n(e[0]),{x:s,y:u}=r(e[0]),{x:p,y:d}=o(e[0]),{x:f,y:g}=i(e[1]),{x:h,y:m}=c(e[1]),{x:y,y:v}=l(e[1]);return[s*s+(t-f)*p+u*u+(a-g)*d,-h*s-m*u,-s*h-u*m,h*h+(f-t)*y+m*m+(g-a)*v]};let f=[];for(const e of[-Math.PI/2,Math.PI/2]){const t=(0,s.newtonIterate2)([e,0],p,d,u.delta2);void 0!==t&&f.push(t)}return f=(0,u.deduplicate)(f,u.deepEquals),f.filter((e=>(0,u.isBetween)(e[1],t.t1,t.t2))).map((e=>[n(e[0]),i(e[1])]))}function ue(e,t){const[n,o,i]=(0,r.getQuadraticCurveDerivatives)(e),[a,c,l]=W(t),p=[],d=(0,s.newtonIterate2)([.5,0],(e=>{const{x:t,y:r}=n(e[0]),{x:i,y:s}=o(e[0]),{x:l,y:u}=a(e[1]),{x:p,y:d}=c(e[1]);return[(t-l)*i+(r-u)*s,(l-t)*p+(u-r)*d]}),(e=>{const{x:t,y:r}=n(e[0]),{x:s,y:u}=o(e[0]),{x:p,y:d}=i(e[0]),{x:f,y:g}=a(e[1]),{x:h,y:m}=c(e[1]),{x:y,y:v}=l(e[1]);return[s*s+(t-f)*p+u*u+(r-g)*d,-h*s-m*u,-s*h-u*m,h*h+(f-t)*y+m*m+(g-r)*v]}),u.delta2);return void 0!==d&&p.push(d),p.filter((e=>(0,u.isValidPercent)(e[0])&&(0,u.isBetween)(e[1],t.t1,t.t2))).map((e=>[n(e[0]),a(e[1])]))}function pe(e,t){const[n,o,i]=(0,r.getBezierCurveDerivatives)(e),[a,c,l]=W(t),p=e=>{const{x:t,y:r}=n(e[0]),{x:i,y:s}=o(e[0]),{x:l,y:u}=a(e[1]),{x:p,y:d}=c(e[1]);return[(t-l)*i+(r-u)*s,(l-t)*p+(u-r)*d]},d=e=>{const{x:t,y:r}=n(e[0]),{x:s,y:u}=o(e[0]),{x:p,y:d}=i(e[0]),{x:f,y:g}=a(e[1]),{x:h,y:m}=c(e[1]),{x:y,y:v}=l(e[1]);return[s*s+(t-f)*p+u*u+(r-g)*d,-h*s-m*u,-s*h-u*m,h*h+(f-t)*y+m*m+(g-r)*v]};let f=[];for(const e of[.25,.75]){const t=(0,s.newtonIterate2)([e,0],p,d,u.delta2);void 0!==t&&f.push(t)}return f=(0,u.deduplicate)(f,u.deepEquals),f.filter((e=>(0,u.isValidPercent)(e[0])&&(0,u.isBetween)(e[1],t.t1,t.t2))).map((e=>[n(e[0]),a(e[1])]))}function de(e,t){const[n,r,o]=W(e),[i,a,c]=W(t),l=[],p=(0,s.newtonIterate2)([0,0],(e=>{const{x:t,y:o}=n(e[0]),{x:s,y:c}=r(e[0]),{x:l,y:u}=i(e[1]),{x:p,y:d}=a(e[1]);return[(t-l)*s+(o-u)*c,(l-t)*p+(u-o)*d]}),(e=>{const{x:t,y:s}=n(e[0]),{x:l,y:u}=r(e[0]),{x:p,y:d}=o(e[0]),{x:f,y:g}=i(e[1]),{x:h,y:m}=a(e[1]),{x:y,y:v}=c(e[1]);return[l*l+(t-f)*p+u*u+(s-g)*d,-h*l-m*u,-l*h-u*m,h*h+(f-t)*y+m*m+(g-s)*v]}),u.delta2);return void 0!==p&&l.push(p),l.filter((n=>(0,u.isBetween)(n[0],e.t1,e.t2)&&(0,u.isBetween)(n[1],t.t1,t.t2))).map((e=>[n(e[0]),i(e[1])]))}},1324:(e,t,n)=>{"use strict";n.r(t);var r=n(5773),o={};for(const e in r)"default"!==e&&(o[e]=()=>r[e]);n.d(t,o);var i=n(3537);o={};for(const e in i)"default"!==e&&(o[e]=()=>i[e]);n.d(t,o);var a=n(4676);o={};for(const e in a)"default"!==e&&(o[e]=()=>a[e]);n.d(t,o);var s=n(2792);o={};for(const e in s)"default"!==e&&(o[e]=()=>s[e]);n.d(t,o);var c=n(7713);o={};for(const e in c)"default"!==e&&(o[e]=()=>c[e]);n.d(t,o);var l=n(5974);o={};for(const e in l)"default"!==e&&(o[e]=()=>l[e]);n.d(t,o);var u=n(491);o={};for(const e in u)"default"!==e&&(o[e]=()=>u[e]);n.d(t,o);var p=n(8905);o={};for(const e in p)"default"!==e&&(o[e]=()=>p[e]);n.d(t,o);var d=n(5775);o={};for(const e in d)"default"!==e&&(o[e]=()=>d[e]);n.d(t,o);var f=n(5147);o={};for(const e in f)"default"!==e&&(o[e]=()=>f[e]);n.d(t,o);var g=n(2301);o={};for(const e in g)"default"!==e&&(o[e]=()=>g[e]);n.d(t,o);var h=n(4461);o={};for(const e in h)"default"!==e&&(o[e]=()=>h[e]);n.d(t,o);var m=n(1451);o={};for(const e in m)"default"!==e&&(o[e]=()=>m[e]);n.d(t,o);var y=n(23);o={};for(const e in y)"default"!==e&&(o[e]=()=>y[e]);n.d(t,o);var v=n(6301);o={};for(const e in v)"default"!==e&&(o[e]=()=>v[e]);n.d(t,o);var x=n(9596);o={};for(const e in x)"default"!==e&&(o[e]=()=>x[e]);n.d(t,o);var b=n(5065);o={};for(const e in b)"default"!==e&&(o[e]=()=>b[e]);n.d(t,o);var C=n(6928);o={};for(const e in C)"default"!==e&&(o[e]=()=>C[e]);n.d(t,o);var E=n(6022);o={};for(const e in E)"default"!==e&&(o[e]=()=>E[e]);n.d(t,o);var P=n(1074);o={};for(const e in P)"default"!==e&&(o[e]=()=>P[e]);n.d(t,o);var w=n(5569);o={};for(const e in w)"default"!==e&&(o[e]=()=>w[e]);n.d(t,o);var k=n(3975);o={};for(const e in k)"default"!==e&&(o[e]=()=>k[e]);n.d(t,o);var _=n(8638);o={};for(const e in _)"default"!==e&&(o[e]=()=>_[e]);n.d(t,o);var S=n(623);o={};for(const e in S)"default"!==e&&(o[e]=()=>S[e]);n.d(t,o);var R=n(9292);o={};for(const e in R)"default"!==e&&(o[e]=()=>R[e]);n.d(t,o);var T=n(4061);o={};for(const e in T)"default"!==e&&(o[e]=()=>T[e]);n.d(t,o);var A=n(6072);o={};for(const e in A)"default"!==e&&(o[e]=()=>A[e]);n.d(t,o);var L=n(9793);o={};for(const e in L)"default"!==e&&(o[e]=()=>L[e]);n.d(t,o);var M=n(1715);o={};for(const e in M)"default"!==e&&(o[e]=()=>M[e]);n.d(t,o);var I=n(6300);o={};for(const e in I)"default"!==e&&(o[e]=()=>I[e]);n.d(t,o);var O=n(7764);o={};for(const e in O)"default"!==e&&(o[e]=()=>O[e]);n.d(t,o);var D=n(1475);o={};for(const e in D)"default"!==e&&(o[e]=()=>D[e]);n.d(t,o);var B=n(3549);o={};for(const e in B)"default"!==e&&(o[e]=()=>B[e]);n.d(t,o);var z=n(5689);o={};for(const e in z)"default"!==e&&(o[e]=()=>z[e]);n.d(t,o);var F=n(8392);o={};for(const e in F)"default"!==e&&(o[e]=()=>F[e]);n.d(t,o);var N=n(5629);o={};for(const e in N)"default"!==e&&(o[e]=()=>N[e]);n.d(t,o);var U=n(3793);o={};for(const e in U)"default"!==e&&(o[e]=()=>U[e]);n.d(t,o);var G=n(8230);o={};for(const e in G)"default"!==e&&(o[e]=()=>G[e]);n.d(t,o);var j=n(1785);o={};for(const e in j)"default"!==e&&(o[e]=()=>j[e]);n.d(t,o);var V=n(767);o={};for(const e in V)"default"!==e&&(o[e]=()=>V[e]);n.d(t,o);var W=n(7558);o={};for(const e in W)"default"!==e&&(o[e]=()=>W[e]);n.d(t,o);var H=n(8306);o={};for(const e in H)"default"!==e&&(o[e]=()=>H[e]);n.d(t,o);var q=n(2572);o={};for(const e in q)"default"!==e&&(o[e]=()=>q[e]);n.d(t,o);var $=n(8258);o={};for(const e in $)"default"!==e&&(o[e]=()=>$[e]);n.d(t,o);var X=n(4575);o={};for(const e in X)"default"!==e&&(o[e]=()=>X[e]);n.d(t,o);var Y=n(6842);o={};for(const e in Y)"default"!==e&&(o[e]=()=>Y[e]);n.d(t,o);var K=n(2318);o={};for(const e in K)"default"!==e&&(o[e]=()=>K[e]);n.d(t,o);var Z=n(2298);o={};for(const e in Z)"default"!==e&&(o[e]=()=>Z[e]);n.d(t,o);var Q=n(1796);o={};for(const e in Q)"default"!==e&&(o[e]=()=>Q[e]);n.d(t,o);var J=n(8831);o={};for(const e in J)"default"!==e&&(o[e]=()=>J[e]);n.d(t,o);var ee=n(7486);o={};for(const e in ee)"default"!==e&&(o[e]=()=>ee[e]);n.d(t,o);var te=n(1401);o={};for(const e in te)"default"!==e&&(o[e]=()=>te[e]);n.d(t,o);var ne=n(5717);o={};for(const e in ne)"default"!==e&&(o[e]=()=>ne[e]);n.d(t,o);var re=n(360);o={};for(const e in re)"default"!==e&&(o[e]=()=>re[e]);n.d(t,o);var oe=n(2683);o={};for(const e in oe)"default"!==e&&(o[e]=()=>oe[e]);n.d(t,o);var ie=n(7727);o={};for(const e in ie)"default"!==e&&(o[e]=()=>ie[e]);n.d(t,o);var ae=n(5935);o={};for(const e in ae)"default"!==e&&(o[e]=()=>ae[e]);n.d(t,o);var se=n(9681);o={};for(const e in se)"default"!==e&&(o[e]=()=>se[e]);n.d(t,o);var ce=n(2808);o={};for(const e in ce)"default"!==e&&(o[e]=()=>ce[e]);n.d(t,o);var le=n(3760);o={};for(const e in le)"default"!==e&&(o[e]=()=>le[e]);n.d(t,o);var ue=n(5481);o={};for(const e in ue)"default"!==e&&(o[e]=()=>ue[e]);n.d(t,o);var pe=n(4206);o={};for(const e in pe)"default"!==e&&(o[e]=()=>pe[e]);n.d(t,o);var de=n(835);o={};for(const e in de)"default"!==e&&(o[e]=()=>de[e]);n.d(t,o);var fe=n(8780);o={};for(const e in fe)"default"!==e&&(o[e]=()=>fe[e]);n.d(t,o);var ge=n(905);o={};for(const e in ge)"default"!==e&&(o[e]=()=>ge[e]);n.d(t,o);var he=n(5184);o={};for(const e in he)"default"!==e&&(o[e]=()=>he[e]);n.d(t,o);var me=n(2986);o={};for(const e in me)"default"!==e&&(o[e]=()=>me[e]);n.d(t,o);var ye=n(4088);o={};for(const e in ye)"default"!==e&&(o[e]=()=>ye[e]);n.d(t,o)},491:(e,t,n)=>{"use strict";n.r(t),n.d(t,{geometryLineIntersectWithPolygon:()=>W,getArcBezierCurveIntersectionPoints:()=>de,getArcEllipseArcIntersectionPoints:()=>Q,getArcEllipseIntersectionPoints:()=>Z,getArcQuadraticCurveIntersectionPoints:()=>ie,getCircleBezierCurveIntersectionPoints:()=>pe,getCircleEllipseIntersectionPoints:()=>K,getCircleQuadraticCurveIntersectionPoints:()=>oe,getEllipseArcBezierCurveIntersectionPoints:()=>ge,getEllipseArcEllipseIntersectionPoints:()=>ee,getEllipseArcQuadraticCurveIntersectionPoints:()=>se,getEllipseBezierCurveIntersectionPoints:()=>fe,getEllipseQuadraticCurveIntersectionPoints:()=>ae,getGeneralFormLineCircleIntersectionPoints:()=>j,getLineBezierCurveIntersectionPoints:()=>le,getLineCircleIntersectionPoints:()=>G,getLineEllipseIntersectionPoints:()=>$,getLineQuadraticCurveIntersectionPoints:()=>ne,getLineSegmentArcIntersectionPoints:()=>N,getLineSegmentBezierCurveIntersectionPoints:()=>ue,getLineSegmentCircleIntersectionPoints:()=>F,getLineSegmentEllipseArcIntersectionPoints:()=>Y,getLineSegmentEllipseIntersectionPoints:()=>X,getLineSegmentQuadraticCurveIntersectionPoints:()=>re,getQuadraticCurveBezierCurveIntersectionPoints:()=>he,getTwoArcIntersectionPoints:()=>U,getTwoBezierCurveIntersectionPoints:()=>me,getTwoCircleIntersectionPoints:()=>z,getTwoEllipseArcIntersectionPoints:()=>te,getTwoEllipseIntersectionPoints:()=>J,getTwoGeneralFormLinesIntersectionPoint:()=>B,getTwoGeometryLinesIntersectionLine:()=>ye,getTwoGeometryLinesIntersectionPoint:()=>O,getTwoLineSegmentsIntersectionPoint:()=>I,getTwoLinesIntersectionPoint:()=>D,getTwoQuadraticCurveIntersectionPoints:()=>ce,iterateGeometryLinesIntersectionLines:()=>ve,iterateGeometryLinesIntersectionPoints:()=>L,iterateGeometryLinesSelfIntersectionPoints:()=>M,iterateIntersectionPoints:()=>A,lineIntersectWithPolygon:()=>V,lineIntersectWithTwoPointsFormRegion:()=>q});var r=n(5629),o=n(1475),i=n(2792),a=n(5773),s=n(7486),c=n(1796),l=n(2298),u=n(2318),p=n(8230),d=n(1715),f=n(5717),g=n(6842),h=n(8831),m=n(2986),y=Object.defineProperty,v=Object.defineProperties,x=Object.getOwnPropertyDescriptors,b=Object.getOwnPropertySymbols,C=Object.prototype.hasOwnProperty,E=Object.prototype.propertyIsEnumerable,P=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),w=Math.pow,k=(e,t,n)=>t in e?y(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,_=(e,t)=>{for(var n in t||(t={}))C.call(t,n)&&k(e,n,t[n]);if(b)for(var n of b(t))E.call(t,n)&&k(e,n,t[n]);return e},S=(e,t)=>v(e,x(t)),R=function(e,t){this[0]=e,this[1]=t},T=e=>{var t,n=e[P("asyncIterator")],r=!1,o={};return null==n?(n=e[P("iterator")](),t=e=>o[e]=t=>n[e](t)):(n=n.call(e),t=e=>o[e]=t=>{if(r){if(r=!1,"throw"===e)throw t;return t}return r=!0,{done:!1,value:new R(new Promise((r=>{var o=n[e](t);o instanceof Object||(()=>{throw TypeError("Object expected")})(),r(o)})),1)}}),o[P("iterator")]=()=>o,t("next"),"throw"in n?t("throw"):o.throw=e=>{throw e},"return"in n&&t("return"),o};function*A(e,t,n,r){const o=r(e),i=r(t);if(o&&i&&o.getGeometries&&i.getGeometries){const r=o.getGeometries(e,n).lines,a=i.getGeometries(t,n).lines;yield*T(L(r,a))}}function*L(e,t){for(const n of e)for(const e of t)yield*T(O(n,e))}function*M(e){var t,n;const r=(0,f.isGeometryLinesClosed)(e);for(let o=0;o!(0,a.isSamePoint)(e,n))))}if(r&&0===o&&i===e.length-1){const t=null==(n=(0,f.getGeometryLineStartAndEnd)(e[o]))?void 0:n.start;t&&(s=s.filter((e=>!(0,a.isSamePoint)(e,t))))}yield*T(s)}}function I(e,t,n,r,o=i.NOT_EXTENDED,s=i.NOT_EXTENDED){const l=D(e,t,n,r);if(l&&(0,c.pointIsOnLineSegment)(l,e,t,o)&&(0,c.pointIsOnLineSegment)(l,n,r,s))return l;if(!l&&o.body&&s.body){if((0,a.isSamePoint)(e,n)||(0,a.isSamePoint)(e,r))return e;if((0,a.isSamePoint)(t,n)||(0,a.isSamePoint)(t,r))return t}}function O(e,t,n=!1,r=i.delta2){const o=!0===n?i.EXTENDED:!1===n?i.NOT_EXTENDED:n[0],a=!0===n?i.EXTENDED:!1===n?i.NOT_EXTENDED:n[1];if(Array.isArray(e)){if(Array.isArray(t)){const n=I(...e,...t,o,a);return n?[n]:[]}if("arc"===t.type)return N(...e,t.curve,o,a);if("ellipse arc"===t.type)return Y(...e,t.curve,o,a);if("quadratic curve"===t.type)return re(...e,t.curve,o,a);if("bezier curve"===t.type)return ue(...e,t.curve,o,a);if("ray"===t.type){const n=(0,c.twoPointLineToGeneralFormLine)(...e);if(!n)return[];const r=B(n,(0,c.pointAndDirectionToGeneralFormLine)(t.line,(0,d.angleToRadian)(t.line.angle)));return r&&(0,c.pointIsOnLineSegment)(r,...e,o)&&(0,c.pointIsOnRay)(r,t.line,a)?[r]:[]}return"hyperbola curve"===t.type?(0,m.getLineSegmentHyperbolaSegmentIntersectionPoints)(...e,t.curve,o,a):(0,p.getLineSegmentNurbsCurveIntersectionPoints)(...e,t.curve)}if(Array.isArray(t))return O(t,e,[a,o],r);if("arc"===e.type)return"arc"===t.type?U(e.curve,t.curve,o,a):"ellipse arc"===t.type?Q(e.curve,t.curve,o,a):"quadratic curve"===t.type?ie(e.curve,t.curve,o,a):"bezier curve"===t.type?de(e.curve,t.curve,o,a):"ray"===t.type?G(t.line,(0,c.getRayPointAtDistance)(t.line,1),e.curve,r).filter((n=>(0,u.pointIsOnArc)(n,e.curve,o)&&(0,c.pointIsOnRay)(n,t.line,a))):"hyperbola curve"===t.type?(0,m.getArcHyperbolaSegmentIntersectionPoints)(e.curve,t.curve,o,a):(0,p.getArcNurbsCurveIntersectionPoints)(e.curve,t.curve,o);if("arc"===t.type)return O(t,e,[a,o],r);if("ellipse arc"===e.type)return"ellipse arc"===t.type?te(e.curve,t.curve,o,a):"quadratic curve"===t.type?se(e.curve,t.curve,o,a):"bezier curve"===t.type?ge(e.curve,t.curve,o,a):"ray"===t.type?$(t.line,(0,c.getRayPointAtDistance)(t.line,1),e.curve).filter((n=>(0,l.pointIsOnEllipseArc)(n,e.curve,o)&&(0,c.pointIsOnRay)(n,t.line,a))):"hyperbola curve"===t.type?(0,m.getEllipseArcHyperbolaSegmentIntersectionPoints)(e.curve,t.curve,o,a):(0,p.getEllipseArcNurbsCurveIntersectionPoints)(e.curve,t.curve,o);if("ellipse arc"===t.type)return O(t,e,[a,o],r);if("quadratic curve"===e.type)return"quadratic curve"===t.type?ce(e.curve,t.curve,o,a):"bezier curve"===t.type?he(e.curve,t.curve,void 0,o,a):"ray"===t.type?ne(t.line,(0,c.getRayPointAtDistance)(t.line,1),e.curve,o).filter((e=>(0,c.pointIsOnRay)(e,t.line,a))):"hyperbola curve"===t.type?(0,m.getQuadraticCurveHyperbolaSegmentIntersectionPoints)(e.curve,t.curve,o,a):(0,p.getQuadraticCurveNurbsCurveIntersectionPoints)(e.curve,t.curve);if("quadratic curve"===t.type)return O(t,e,[a,o],r);if("bezier curve"===e.type)return"bezier curve"===t.type?me(e.curve,t.curve,void 0,o,a):"ray"===t.type?le(t.line,(0,c.getRayPointAtDistance)(t.line,1),e.curve,o).filter((e=>(0,c.pointIsOnRay)(e,t.line,a))):"hyperbola curve"===t.type?(0,m.getBezierCurveHyperbolaSegmentIntersectionPoints)(e.curve,t.curve,o,a):(0,p.getBezierCurveNurbsCurveIntersectionPoints)(e.curve,t.curve);if("bezier curve"===t.type)return O(t,e,[a,o],r);if("ray"===e.type){if("ray"===t.type){const n=B((0,c.pointAndDirectionToGeneralFormLine)(e.line,(0,d.angleToRadian)(e.line.angle)),(0,c.pointAndDirectionToGeneralFormLine)(t.line,(0,d.angleToRadian)(t.line.angle)));return n&&(0,c.pointIsOnRay)(n,e.line,o)&&(0,c.pointIsOnRay)(n,t.line,a)?[n]:[]}if("hyperbola curve"===t.type)return(0,m.getLineHyperbolaSegmentIntersectionPoints)(e.line,(0,c.getRayPointAtDistance)(e.line,1),t.curve,o).filter((t=>(0,c.pointIsOnRay)(t,e.line,a)));const n=(0,g.getGeometryLineBounding)(t);if(n){const r=(0,c.rayToLineSegment)(e.line,(0,s.getPolygonFromTwoPointsFormRegion)(n));if(r)return(0,p.getLineSegmentNurbsCurveIntersectionPoints)(...r,t.curve)}return[]}return"ray"===t.type?O(t,e,[a,o],r):"hyperbola curve"===e.type?(t.type,[]):"hyperbola curve"===t.type?O(t,e,[a,o],r):(0,p.getTwoNurbsCurveIntersectionPoints)(e.curve,t.curve)}function D(e,t,n,r){const o=(0,c.twoPointLineToGeneralFormLine)(e,t);if(!o)return;const i=(0,c.twoPointLineToGeneralFormLine)(n,r);return i?B(o,i):void 0}function B(e,t){const{a:n,b:r,c:o}=e,{a,b:s,c}=t,l=a*r-n*s;if(!(0,i.isZero)(l))return{x:(o*s-r*c)/l,y:(c*n-o*a)/l}}function z({x:e,y:t,r:n},{x:r,y:o,r:a}){const s=w(n,2),c=w(a,2),l=r-e,u=o-t,p=w(l,2)+w(u,2),d=Math.sqrt(p),f=(p+s-c)/2/d,g=s-w(f,2);if((0,i.lessThan)(g,0))return[];const h=f/d,m=h*l+e,y=h*u+t;if((0,i.isZero)(g))return[{x:m,y}];const v=Math.sqrt(g)/d,x=v*u,b=v*l;return[{x:m+x,y:y-b},{x:m-x,y:y+b}]}function F(e,t,n,r=i.NOT_EXTENDED){return G(e,t,n).filter((n=>(0,c.pointIsOnLineSegment)(n,e,t,r)))}function N(e,t,n,r=i.NOT_EXTENDED,o=i.NOT_EXTENDED){return F(e,t,n,r).filter((e=>(0,u.pointIsOnArc)(e,n,o)))}function U(e,t,n=i.NOT_EXTENDED,r=i.NOT_EXTENDED){return z(e,t).filter((o=>(0,u.pointIsOnArc)(o,e,n)&&(0,u.pointIsOnArc)(o,t,r)))}function G({x:e,y:t},{x:n,y:r},{x:o,y:a,r:s},c=i.delta2){const l=n-e,u=r-t,p=u*(o-e)-l*(a-t),d=w(l,2)+w(u,2),f=s*s*d-p*p;if((0,i.lessThan)(f,0,c))return[];const g=-u*p/d+o,h=l*p/d+a;if((0,i.isZero)(f,c))return[{x:g,y:h}];const m=Math.sqrt(f),y=m*l/d,v=m*u/d;return[{x:g-y,y:h-v},{x:g+y,y:h+v}]}function j(e,t){return G(...(0,c.generalFormLineToTwoPointLine)(e),t)}function V(e,t,n){for(const r of(0,c.getPolygonLine)(n))if(H(e,t,...r))return!0;return!1}function W(e,t){for(const n of(0,c.getPolygonLine)(t))if(Array.isArray(e)){if(H(...e,...n))return!0}else if("arc"===e.type){if(N(...n,e.curve).length>0)return!0}else if("ellipse arc"===e.type){if(Y(...n,e.curve).length>0)return!0}else if("quadratic curve"===e.type){if(re(...n,e.curve).length>0)return!0}else if("bezier curve"===e.type){if(ue(...n,e.curve).length>0)return!0}else if("nurbs curve"===e.type){if((0,p.getLineSegmentNurbsCurveIntersectionPoints)(...n,e.curve).length>0)return!0}else if("ray"===e.type){const t=(0,c.twoPointLineToGeneralFormLine)(...n);if(!t){if((0,c.pointIsOnRay)(n[0],e.line))return!0;continue}const r=B(t,(0,c.pointAndDirectionToGeneralFormLine)(e.line,(0,d.angleToRadian)(e.line.angle)));if(r&&(0,c.pointIsOnRay)(r,e.line)&&(0,c.pointIsOnLineSegment)(r,...n))return!0}else if("hyperbola curve"===e.type&&(0,m.getLineSegmentHyperbolaSegmentIntersectionPoints)(...n,e.curve).length>0)return!0;return!1}function H(e,t,n,r){if(!((0,i.lessOrEqual)(Math.min(e.x,t.x),Math.max(n.x,r.x))&&(0,i.lessOrEqual)(Math.min(n.y,r.y),Math.max(e.y,t.y))&&(0,i.lessOrEqual)(Math.min(n.x,r.x),Math.max(e.x,t.x))&&(0,i.lessOrEqual)(Math.min(e.y,t.y),Math.max(n.y,r.y))))return!1;const o=(n.x-e.x)*(t.y-e.y)-(t.x-e.x)*(n.y-e.y),a=(r.x-e.x)*(t.y-e.y)-(t.x-e.x)*(r.y-e.y),s=(e.x-n.x)*(r.y-n.y)-(r.x-n.x)*(e.y-n.y),c=(t.x-n.x)*(r.y-n.y)-(r.x-n.x)*(t.y-n.y);return(0,i.lessOrEqual)(o*a,0)&&(0,i.lessOrEqual)(s*c,0)}function q(e,t,n){return V(e,t,(0,s.getPolygonFromTwoPointsFormRegion)(n))}function $({x:e,y:t},{x:n,y:r},{rx:o,ry:a,cx:s,cy:c,angle:l}){const u=(0,d.angleToRadian)(l),p=Math.sin(u),f=Math.cos(u),g=n-e,h=r-t,m=h*(s-e)-g*(c-t),y=f*g+p*h,v=f*h-p*g,x=a*a*y,b=o*o*v,C=x*y+b*v,E=C-m*m;if((0,i.lessThan)(E,0))return[];const P=s-m*(x*p+b*f)/C,w=c+m*(x*f-b*p)/C;if((0,i.isZero)(E))return[{x:P,y:w}];const k=o*a*Math.sqrt(E)/C,_=g*k,S=h*k;return[{x:P+_,y:w+S},{x:P-_,y:w-S}]}function X(e,t,n,r=i.NOT_EXTENDED){return $(e,t,n).filter((n=>(0,c.pointIsOnLineSegment)(n,e,t,r)))}function Y(e,t,n,r=i.NOT_EXTENDED,o=i.NOT_EXTENDED){return X(e,t,n,r).filter((e=>(0,l.pointIsOnEllipseArc)(e,n,o)))}function K({x:e,y:t,r:n},{rx:r,ry:a,cx:s,cy:c,angle:l}){if((0,i.isSameNumber)(r,a))return z({x:e,y:t,r:n},{x:s,y:c,r});const u=(0,d.angleToRadian)(l),p=Math.sin(u),f=Math.cos(u),g=1/r/r,h=1/a/a,m=p*p*g+f*f*h,y=(2*p*f*g-2*p*f*h)/m,v=(f*f*g+p*p*h)/m,x=-1/m,b=w(n,2),C=s-e,E=c-t,P=1-v,k=C*C+E*E-b-x,_=y*y*P+y*y*v+P*P,S=-2*E*y*P+2*C*y*y+-4*E*y*v+4*C*P,R=-4*C*E*y+4*E*E*v+4*C*C+y*y*x+2*P*k+y*y*k,T=4*C*k+-4*E*y*x+-2*E*y*k,A=k*k+4*E*E*x;return(0,o.calculateEquation4)(_,S,R,T,A).map((e=>({x:e+s,y:-(k+2*C*e+P*e*e)/(2*E-y*e)+c})))}function Z(e,t,n=i.NOT_EXTENDED){return K(e,t).filter((t=>(0,u.pointIsOnArc)(t,e,n)))}function Q(e,t,n=i.NOT_EXTENDED,r=i.NOT_EXTENDED){return Z(e,t,n).filter((e=>(0,l.pointIsOnEllipseArc)(e,t,r)))}function J({rx:e,ry:t,cx:n,cy:r,angle:a},{rx:s,ry:c,cx:l,cy:u,angle:p}){if((0,i.isSameNumber)(e,t))return K({x:n,y:r,r:e},{rx:s,ry:c,cx:l,cy:u,angle:p});if((0,i.isSameNumber)(s,c))return K({x:l,y:u,r:s},{rx:e,ry:t,cx:n,cy:r,angle:a});const f=(0,d.angleToRadian)(a),g=(0,d.angleToRadian)(p),h=Math.sin(f),m=Math.cos(f),y=Math.sin(g),v=Math.cos(g),x=1/e/e,b=1/t/t,C=h*h*x+m*m*b,E=2*h*m*x/C,P=2*h*m*b/C,w=(m*m*x+h*h*b)/C,k=-1/C,_=1/s/s,S=1/c/c,R=n-l,T=r-u,A=y*y*_+v*v*S,L=(2*y*v*_*R-2*y*v*S*R+2*y*y*_*T+2*v*v*S*T)/A,M=(2*v*v*_*R+2*y*y*S*R+2*y*v*_*T-2*y*v*S*T)/A,I=P+-E+(2*y*v*_-2*y*v*S)/A,O=(v*v*_+y*y*S)/A-w,D=(v*v*_*R*R+y*y*S*R*R+2*y*v*_*R*T+-2*y*v*S*R*T+y*y*_*T*T+v*v*S*T*T-1)/A-k,B=w*I*I+P*I*O+O*O+-E*I*O,z=2*w*L*I+-E*M*I+2*M*O+P*M*I+-E*L*O+P*L*O,F=w*L*L+-E*L*M+P*L*M+k*I*I+M*M+P*I*D+2*O*D+-E*I*D,N=2*k*L*I+2*M*D+-E*L*D+P*L*D,U=k*L*L+D*D;return(0,o.calculateEquation4)(B,z,F,N,U).map((e=>({x:e+n,y:-(M*e+O*e*e+D)/(I*e+L)+r})))}function ee(e,t,n=i.NOT_EXTENDED){return J(e,t).filter((t=>(0,l.pointIsOnEllipseArc)(t,e,n)))}function te(e,t,n=i.NOT_EXTENDED,r=i.NOT_EXTENDED){return ee(e,t,n).filter((e=>(0,l.pointIsOnEllipseArc)(e,t,r)))}function ne({x:e,y:t},{x:n,y:r},{from:{x:a,y:s},cp:{x:c,y:l},to:{x:u,y:p}},d=i.NOT_EXTENDED){const f=c-a,g=u-c-f,h=l-s,m=p-l-h,y=n-e,v=r-t;let x=(0,o.calculateEquation2)(-1*m*y+g*v,-2*h*y+2*f*v,-s*y+a*v+-v*e+y*t);return x=x.filter((e=>(0,i.isValidPercent)(e,d))),x.map((e=>({x:g*e*e+2*f*e+a,y:m*e*e+2*h*e+s})))}function re(e,t,n,r=i.NOT_EXTENDED,o=i.NOT_EXTENDED){return ne(e,t,n,o).filter((n=>(0,c.pointIsOnLineSegment)(n,e,t,r)))}function oe({x:e,y:t,r:n},{from:{x:r,y:a},cp:{x:s,y:c},to:{x:l,y:u}},p=i.NOT_EXTENDED){const d=s-r,f=l-s-d,g=c-a,h=u-c-g;let m=(0,o.calculateEquation4)(f*f+h*h,4*(d*f+g*h),2*(2*d*d+r*f+2*g*g+a*h-f*e-h*t),4*(r*d+a*g+-1*d*e+-1*g*t),r*r+a*a+-n*n+-2*r*e+e*e+-2*a*t+t*t);return m=m.filter((e=>(0,i.isValidPercent)(e,p))),m.map((e=>({x:f*e*e+2*d*e+r,y:h*e*e+2*g*e+a})))}function ie(e,t,n=i.NOT_EXTENDED,r=i.NOT_EXTENDED){return oe(e,t,r).filter((t=>(0,u.pointIsOnArc)(t,e,n)))}function ae({rx:e,ry:t,cx:n,cy:r,angle:a},{from:{x:s,y:c},cp:{x:l,y:u},to:{x:p,y:f}},g=i.NOT_EXTENDED){const h=l-s,m=p-l-h,y=u-c,v=f-u-y,x=(0,d.angleToRadian)(a),b=Math.sin(x),C=Math.cos(x),E=1/e/e,P=1/t/t,k=s-n,_=c-r,S=y*b+h*C,R=h*b-y*C,T=v*b+m*C,A=m*b-v*C,L=b*P*k-C*P*_,M=C*E*k+b*E*_;let I=(0,o.calculateEquation4)(w(T,2)*E+w(A,2)*P,4*(S*T*E+R*A*P),2*(2*w(S,2)*E+2*w(R,2)*P+T*M+A*L),4*(S*M+R*L),w(C*k+b*_,2)*E+w(b*k+-C*_,2)*P-1);return I=I.filter((e=>(0,i.isValidPercent)(e,g))),I.map((e=>({x:m*e*e+2*h*e+s,y:v*e*e+2*y*e+c})))}function se(e,t,n=i.NOT_EXTENDED,r=i.NOT_EXTENDED){return ae(e,t,r).filter((t=>(0,l.pointIsOnEllipseArc)(t,e,n)))}function ce(e,{from:{x:t,y:n},cp:{x:a,y:s},to:{x:c,y:l}},u=i.NOT_EXTENDED,p=u){const{from:{x:d,y:f},cp:{x:g,y:h},to:{x:m,y}}=e,v=g-d,x=m-g-v,b=h-f,C=y-h-b,E=a-t,P=c-a-E,w=s-n,k=l-s-w,_=(d-t)/x,S=2*v/x,R=P/x,T=2*E/x,A=2*b/C-S,L=(-k/C+R)/A,M=(T+-2*w/C)/A,I=((f-n)/C-_)/A;let O=(0,o.calculateEquation4)(L*L,2*L*M,-S*L+M*M+2*L*I-R,-S*M+2*M*I-T,_+-S*I+I*I);O=O.filter((e=>(0,i.isValidPercent)(e,p)));let D=O.map((e=>({x:P*e*e+2*E*e+t,y:k*e*e+2*w*e+n})));return D=D.filter((t=>(0,i.isValidPercent)((0,r.getQuadraticCurvePercentAtPoint)(e,t),u))),D}function le({x:e,y:t},{x:n,y:r},{from:{x:a,y:s},cp1:{x:c,y:l},cp2:{x:u,y:p},to:{x:d,y:f}},g=i.NOT_EXTENDED){const h=3*c-a+-3*u+d,m=3*(a-2*c+u),y=3*(c-a),v=3*l-s+-3*p+f,x=3*(s-2*l+p),b=3*(l-s),C=n-e,E=r-t;let P=(0,o.calculateEquation3)(-v*C+h*E,-x*C+m*E,-b*C+y*E,-s*C+a*E+-E*e+C*t);return P=P.filter((e=>(0,i.isValidPercent)(e,g))),P.map((e=>({x:h*e*e*e+m*e*e+y*e+a,y:v*e*e*e+x*e*e+b*e+s})))}function ue(e,t,n,r=i.NOT_EXTENDED,o=i.NOT_EXTENDED){return le(e,t,n,o).filter((n=>(0,c.pointIsOnLineSegment)(n,e,t,r)))}function pe({x:e,y:t,r:n},{from:{x:r,y:a},cp1:{x:s,y:c},cp2:{x:l,y:u},to:{x:p,y:d}},f,g=i.NOT_EXTENDED){const h=3*s-r+-3*l+p,m=3*(r-2*s+l),y=3*(s-r),v=3*c-a+-3*u+d,x=3*(a-2*c+u),b=3*(c-a),C=r-e,E=a-t,P=w(n,2),k=h*h+v*v,_=h*m+v*x,S=m*m+2*h*y+x*x+2*v*b,R=m*y+h*C+x*b+v*E,T=y*y+2*m*C+b*b+2*x*E,A=2*(y*C+b*E);let L=(0,o.calculateEquation5)([k,2*_,S,2*R,T,A,C*C+E*E-P],.5,f);return L=L.filter((e=>(0,i.isValidPercent)(e,g))),L.map((e=>({x:h*e*e*e+m*e*e+y*e+r,y:v*e*e*e+x*e*e+b*e+a})))}function de(e,t,n=i.NOT_EXTENDED,r=i.NOT_EXTENDED){let o=pe(e,t,void 0,r);return o=o.filter((t=>(0,u.pointIsOnArc)(t,e,n))),o}function fe({rx:e,ry:t,cx:n,cy:r,angle:a},{from:{x:s,y:c},cp1:{x:l,y:u},cp2:{x:p,y:f},to:{x:g,y:h}},m,y=i.NOT_EXTENDED){const v=3*l-s+-3*p+g,x=3*(s-2*l+p),b=3*(l-s),C=3*u-c+-3*f+h,E=3*(c-2*u+f),P=3*(u-c),k=(0,d.angleToRadian)(a),_=Math.sin(k),S=Math.cos(k),R=1/e/e,T=1/t/t,A=s-n,L=c-r,M=C*_+v*S,I=v*_-C*S,O=_*A-S*L,D=S*A+_*L,B=P*_+b*S,z=b*_-P*S,F=E*_+x*S,N=x*_-E*S,U=F*R,G=N*T,j=z*T,V=B*R,W=D*R,H=O*T;let q=(0,o.calculateEquation5)([w(M,2)*R+w(I,2)*T,2*(U*M+I*G),F*U+N*G+2*(V*M+j*I),2*(B*U+z*G+M*W+I*H),B*V+z*j+2*((U*S+G*_)*A+(U*_-G*S)*L),2*((V*S+j*_)*A+(V*_-j*S)*L),O*H+D*W-1],.5,m);return q=q.filter((e=>(0,i.isValidPercent)(e,y))),q.map((e=>({x:v*e*e*e+x*e*e+b*e+s,y:C*e*e*e+E*e*e+P*e+c})))}function ge(e,t,n=i.NOT_EXTENDED,r=i.NOT_EXTENDED){return fe(e,t,void 0,r).filter((t=>(0,l.pointIsOnEllipseArc)(t,e,n)))}function he(e,{from:{x:t,y:n},cp1:{x:a,y:s},cp2:{x:c,y:l},to:{x:u,y:p}},d,f=i.NOT_EXTENDED,g=f){const{from:{x:h,y:m},cp:{x:y,y:v},to:{x,y:b}}=e,C=3*a-t+-3*c+u,E=3*(t-2*a+c),P=3*(a-t),w=3*s-n+-3*l+p,k=3*(n-2*s+l),_=3*(s-n),S=y-h,R=x-y-S,T=v-m,A=b-v-T,L=2*S/R,M=C/R,I=E/R,O=P/R,D=h/R-t/R,B=2*T/A-L,z=M-w/A,F=I-k/A,N=O-_/A,U=m/A-n/A-D;let G=(0,o.calculateEquation5)([z*z,2*z*F,F*F+2*z*N,-M*B*B+-L*B*z+2*F*N+2*z*U,-I*B*B+-L*B*F+N*N+2*F*U,-O*B*B+-L*B*N+2*N*U,D*B*B+-L*B*U+U*U],.5,d);G=G.filter((e=>(0,i.isValidPercent)(e,g)));let j=G.map((e=>({x:C*e*e*e+E*e*e+P*e+t,y:w*e*e*e+k*e*e+_*e+n})));return j=j.filter((t=>(0,i.isValidPercent)((0,r.getQuadraticCurvePercentAtPoint)(e,t),f))),j}function me(e,{from:{x:t,y:n},cp1:{x:a,y:s},cp2:{x:c,y:l},to:{x:u,y:p}},d,f=i.NOT_EXTENDED,g=f){const{from:{x:h,y:m},cp1:{x:y,y:v},cp2:{x,y:b},to:{x:C,y:E}}=e,P=3*a-t+-3*c+u,w=3*(t-2*a+c),k=3*(a-t),_=3*s-n+-3*l+p,S=3*(n-2*s+l),R=3*(s-n),T=3*y-h+-3*x+C,A=3*v-m+-3*b+E,L=3*(h-2*y+x)/T,M=3*(y-h)/T,I=P/T,O=w/T,D=k/T,B=h/T-t/T,z=3*(m-2*v+b)/A-L,F=(3*(v-m)/A-M)/z/2,N=(I-_/A)/z,U=(O-S/A)/z,G=(D-R/A)/z,j=F*F-(m/A-n/A-B)/z,V=L-3*F,W=j+(-2*L*F+3*F*F+M),H=-N*V-I,q=-U*V-O,$=-G*V-D,X=j*V+(L*F*F+-M*F+B+-F*F*F);let Y=(0,o.calculateEquation5)([N*N*N,3*N*N*U,3*N*U*U+3*N*N*G,H*H+U*U*U+6*N*U*G+-N*N*j+-2*N*N*W,2*H*q+3*U*U*G+3*N*G*G+-2*N*U*j+-4*N*U*W,q*q+2*H*$+3*U*G*G+-U*U*j+-2*N*G*j+-2*U*U*W+-4*N*G*W,2*q*$+2*H*X+G*G*G+-2*U*G*j+-4*U*G*W+2*N*j*W+N*W*W,$*$+2*q*X+-G*G*j+-2*G*G*W+2*U*j*W+U*W*W,2*$*X+2*G*j*W+G*W*W,X*X+-j*W*W],.5,d);return Y=Y.filter((e=>(0,i.isValidPercent)(e,g))),Y.map((e=>({x:P*e*e*e+w*e*e+k*e+t,y:_*e*e*e+S*e*e+R*e+n}))).filter((t=>(0,i.isValidPercent)((0,r.getBezierCurvePercentAtPoint)(e,t),f)))}function ye(e,t){if(Array.isArray(e)){const n=(0,c.twoPointLineToGeneralFormLine)(...e);if(!n)return;if(Array.isArray(t)){const r=(0,c.twoPointLineToGeneralFormLine)(...t);if(!r)return;if(!(0,c.isSameLine)(n,r))return;const o=t.map((t=>(0,f.getGeometryLineParamAtPoint)(t,e))),a=(0,i.getNumberRangeIntersection)([o[0],o[1]],[0,1]);if(!a)return;return[(0,f.getPartOfGeometryLine)(...a,e)]}if("ray"===t.type){const r=(0,c.pointAndDirectionToGeneralFormLine)(t.line,(0,d.angleToRadian)(t.line.angle));if(!(0,c.isSameLine)(n,r))return;if(t.line.bidirectional)return[e];const o=e.map((e=>(0,c.pointIsOnRay)(e,t.line)));if(o.every((e=>e)))return[e];const i=o.findIndex((e=>e));return i>=0?[[e[i],t.line]]:void 0}}else{if(Array.isArray(t))return ye(t,e);if("arc"!==e.type){if("arc"===t.type)return ye(t,e);if("ellipse arc"!==e.type){if("ellipse arc"===t.type)return ye(t,e);if("quadratic curve"!==e.type){if("quadratic curve"===t.type)return ye(t,e);if("bezier curve"!==e.type){if("bezier curve"===t.type)return ye(t,e);if("hyperbola curve"!==e.type){if("hyperbola curve"===t.type)return ye(t,e);if("ray"!==e.type)return"ray"===t.type?ye(t,e):void 0;if("ray"===t.type){const n=(0,c.pointAndDirectionToGeneralFormLine)(e.line,(0,d.angleToRadian)(e.line.angle)),r=(0,c.pointAndDirectionToGeneralFormLine)(t.line,(0,d.angleToRadian)(t.line.angle));if(!(0,c.isSameLine)(n,r))return;return e.line.bidirectional?[t]:t.line.bidirectional?[e]:(0,h.twoAnglesSameDirection)((0,c.getRayAngle)(e.line),(0,c.getRayAngle)(t.line))?[(0,c.pointIsOnRay)(e.line,t.line)?e:t]:(0,c.pointIsOnRay)(e.line,t.line)&&!(0,a.isSamePoint)(e.line,t.line)?[[e.line,t.line]]:void 0}}else if("hyperbola curve"===t.type){if(!(0,m.isSameHyperbola)(e.curve,t.curve))return;const n=(0,i.getNumberRangeIntersection)([e.curve.t1,e.curve.t2],[t.curve.t1,t.curve.t2]);if(!n)return;return[{type:"hyperbola curve",curve:S(_({},e.curve),{t1:n[0],t2:n[1]})}]}}else if("bezier curve"===t.type){const n=(0,r.getBezierCurvePercentsAtBezierCurve)(e.curve,t.curve);if(!n)return;const o=(0,i.getNumberRangeIntersection)(n,[0,1]);if(!o)return;return[(0,f.getPartOfGeometryLine)(...o,e)]}}else if("quadratic curve"===t.type){const n=(0,r.getQuadraticCurvePercentsAtQuadraticCurve)(e.curve,t.curve);if(!n)return;const o=(0,i.getNumberRangeIntersection)(n,[0,1]);if(!o)return;return[(0,f.getPartOfGeometryLine)(...o,e)]}}else if("ellipse arc"===t.type){if(!(0,l.isSameEllipse)(e.curve,t.curve))return;const n=(0,h.getAngleRangesIntersections)(e.curve,t.curve);return n.length>0?n.map((t=>({type:"ellipse arc",curve:S(_({},e.curve),{startAngle:t[0],endAngle:t[1],counterclockwise:void 0})}))):void 0}}else if("arc"===t.type){if(!(0,u.isSameCircle)(e.curve,t.curve))return;const n=(0,h.getAngleRangesIntersections)(e.curve,t.curve);return n.length>0?n.map((t=>({type:"arc",curve:S(_({},e.curve),{startAngle:t[0],endAngle:t[1],counterclockwise:void 0})}))):void 0}}}function*ve(e,t){for(const n of e)for(const e of t){const t=ye(n,e);if(t)for(const e of t)yield e}}},1074:(e,t,n)=>{"use strict";function r(e){return Array.isArray(e)}n.r(t),n.d(t,{isArray:()=>r})},6022:(e,t,n)=>{"use strict";function r(e){return"object"==typeof e&&null!==e}function o(e){return"function"==typeof e}n.r(t),n.d(t,{isFunction:()=>o,isRecord:()=>r})},9292:(e,t,n)=>{"use strict";function*r(e){if(Array.isArray(e))for(const t of e)t&&(yield t);else yield e}function o(e){return void 0===e?[]:Array.isArray(e)?e:[e]}n.r(t),n.d(t,{itemToArray:()=>o,iterateItemOrArray:()=>r})},623:(e,t,n)=>{"use strict";n.r(t),n.d(t,{metaKeyIfMacElseCtrlKey:()=>o});const r="undefined"!=typeof navigator&&/Mac|iPod|iPhone|iPad/.test(navigator.platform);function o(e){return r?e.metaKey:e.ctrlKey}},7764:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Lazy:()=>o});var r=Object.defineProperty;class o{constructor(e,t){var n,o;this.getInstance=e,this.destroy=t,((e,t,n)=>{t in e?r(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(this,"symbol"!=typeof(n="_instance")?n+"":n,o)}get instance(){return void 0===this._instance&&(this._instance=this.getInstance()),this._instance}get instanced(){return void 0!==this._instance}reset(){var e;this._instance&&(null==(e=this.destroy)||e.call(this,this._instance)),this._instance=void 0}}},7558:(e,t,n)=>{"use strict";n.r(t),n.d(t,{cotesIntegral:()=>T,getArcLength:()=>w,getArcRadianByLength:()=>I,getBezierCurveLength:()=>R,getBezierCurvePercentByLength:()=>z,getCircleLength:()=>P,getCircleRadianByLength:()=>M,getEllipseArcLength:()=>_,getEllipseArcRadianByLength:()=>D,getEllipseLength:()=>k,getEllipseRadianByLength:()=>O,getGeometryLineLength:()=>U,getGeometryLineParamByLength:()=>N,getGeometryLinesLength:()=>G,getGeometryLinesPointAndTangentRadianByLength:()=>F,getLineParamByLength:()=>L,getQuadraticCurveLength:()=>S,getQuadraticCurvePercentByLength:()=>B,rombergIntegral:()=>A});var r=n(5629),o=n(1475),i=n(2792),a=n(5773),s=n(8831),c=n(2298),l=n(5717),u=n(8230),p=n(1715),d=n(2986),f=Object.defineProperty,g=Object.defineProperties,h=Object.getOwnPropertyDescriptors,m=Object.getOwnPropertySymbols,y=Object.prototype.hasOwnProperty,v=Object.prototype.propertyIsEnumerable,x=Math.pow,b=(e,t,n)=>t in e?f(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,C=(e,t)=>{for(var n in t||(t={}))y.call(t,n)&&b(e,n,t[n]);if(m)for(var n of m(t))v.call(t,n)&&b(e,n,t[n]);return e},E=(e,t)=>g(e,h(t));function P(e){return 2*Math.PI*e.r}function w(e){const t=(0,s.getFormattedEndAngle)(e);return e.r*(0,p.angleToRadian)(Math.abs(t-e.startAngle))}function k(e,t){return _((0,c.ellipseToEllipseArc)(e),t)}function _(e,t){const n=x(e.rx,2),r=x(e.ry,2),o=(0,p.angleToRadian)(e.startAngle),i=(0,p.angleToRadian)((0,s.getFormattedEndAngle)(e));return A(Math.min(o,i),Math.max(o,i),(e=>Math.sqrt(n*x(Math.sin(e),2)+r*x(Math.cos(e),2))),t)}function S({from:{x:e,y:t},cp:{x:n,y:r},to:{x:o,y:i}},a){const s=n-e,c=o-n-s,l=r-t,u=i-r-l,p=c*c+u*u,d=2*s*c+2*l*u,f=s*s+l*l;return A(0,1,(e=>2*Math.sqrt(p*e*e+d*e+f)),a)}function R({from:{x:e,y:t},cp1:{x:n,y:r},cp2:{x:o,y:i},to:{x:a,y:s}}){const c=3*n-e+-3*o+a,l=3*(e-2*n+o),u=3*(n-e),p=3*r-t+-3*i+s,d=3*(t-2*r+i),f=3*(r-t),g=9*c*c+9*p*p,h=12*c*l+12*p*d,m=4*l*l+6*c*u+4*d*d+6*p*f,y=4*l*u+4*d*f,v=u*u+f*f;return A(0,1,(e=>Math.sqrt(g*e*e*e*e+h*e*e*e+m*e*e+y*e+v)))}function T(e,t,n,r){if(r&&Number.isInteger(r)&&r>1){let o=0;const i=(t-e)/r;for(let t=0;t_(E(C({},e),{endAngle:(0,p.radianToAngle)(n)}))-t),(e=>Math.sqrt(r*x(Math.sin(e),2)+a*x(Math.cos(e),2))),n)}function B(e,t,n=i.delta2){const{from:{x:a,y:s},cp:{x:c,y:l},to:{x:u,y:p}}=e,d=c-a,f=u-c-d,g=l-s,h=p-l-g,m=f*f+h*h,y=2*d*f+2*g*h,v=d*d+g*g;return(0,o.newtonIterate)(.5,(n=>S((0,r.getPartOfQuadraticCurve)(e,0,n))-t),(e=>2*Math.sqrt(m*e*e+y*e+v)),n)}function z(e,t,n=i.delta2){const{from:{x:a,y:s},cp1:{x:c,y:l},cp2:{x:u,y:p},to:{x:d,y:f}}=e,g=3*c-a+-3*u+d,h=3*(a-2*c+u),m=3*(c-a),y=3*l-s+-3*p+f,v=3*(s-2*l+p),x=3*(l-s),b=9*g*g+9*y*y,C=12*g*h+12*y*v,E=4*h*h+6*g*m+4*v*v+6*y*x,P=4*h*m+4*v*x,w=m*m+x*x;return(0,o.newtonIterate)(.5,(n=>R((0,r.getPartOfBezierCurve)(e,0,n))-t),(e=>Math.sqrt(b*e*e*e*e+C*e*e*e+E*e*e+P*e+w)),n)}function F(e,t,n){for(const[r,o]of e.entries()){const e=n?n[r]:U(o);if(void 0===e)return;if((0,i.lessOrEqual)(t,e)){const e=N(o,t);if(void 0===e)return;return(0,l.getGeometryLinePointAndTangentRadianAtParam)(e,o)}t-=e}}function N(e,t){if(Array.isArray(e))return L(...e,t);if("arc"===e.type){const n=(0,p.radianToAngle)(I(e.curve,t));return(0,l.getPercentAtAngle)(n,e.curve)}if("ellipse arc"===e.type){const n=D(e.curve,t);if(void 0===n)return;const r=(0,p.radianToAngle)(n);return(0,l.getPercentAtAngle)(r,e.curve)}if("quadratic curve"===e.type)return B(e.curve,t);if("bezier curve"===e.type)return z(e.curve,t);if("hyperbola curve"===e.type){const n=(0,d.getHyperbolaParamByLength)(e.curve,t);if(void 0===n)return;return(0,l.getPercentAtParam)(n,e.curve.t1,e.curve.t2)}return"nurbs curve"===e.type?(0,u.getNurbsCurveParamByLength)(e.curve,t)/(0,u.getNurbsMaxParam)(e.curve):void 0}function U(e){return Array.isArray(e)?(0,a.getTwoPointsDistance)(...e):"arc"===e.type?w(e.curve):"ellipse arc"===e.type?_(e.curve):"quadratic curve"===e.type?S(e.curve):"bezier curve"===e.type?R(e.curve):"hyperbola curve"===e.type?(0,d.getHyperbolaLength)(e.curve):"ray"!==e.type?(0,u.getNurbsCurveLength)(e.curve):void 0}function G(e){let t=0;for(const n of e){const e=U(n);if(void 0===e)return;t+=e}return t}},3760:(e,t,n)=>{"use strict";n.r(t),n.d(t,{getLightPath:()=>l});var r=n(8831),o=n(5717),i=n(491),a=n(2792),s=n(5773),c=n(1715);function l(e,t,n=!1,l=10){const u=[],p={type:"ray",line:e};for(;u.length0)for(const n of t.regions){for(const t of n.lines)e.push(...(0,i.getTwoGeometryLinesIntersectionPoint)(t,p).filter((e=>!(0,s.isSamePoint)(e,p.line))).map((e=>({line:t,point:e,hatch:!0}))));if(n.holes)for(const t of n.holes)for(const n of t)e.push(...(0,i.getTwoGeometryLinesIntersectionPoint)(n,p).filter((e=>!(0,s.isSamePoint)(e,p.line))).map((e=>({line:n,point:e,hatch:!0}))))}else for(const n of t.lines)e.push(...(0,i.getTwoGeometryLinesIntersectionPoint)(n,p).filter((e=>!(0,s.isSamePoint)(e,p.line))).map((e=>({line:n,point:e,hatch:!1}))));if(0==e.length)return u.push(p),u;const d=(0,a.minimumBy)(e,(e=>(0,s.getTwoPointsDistance)(e.point,p.line)));u.push([p.line,d.point]);const f=(0,o.getGeometryLineParamAtPoint)(d.point,d.line),g=(0,o.getGeometryLineTangentRadianAtParam)(f,d.line);let h;if(d.hatch){const e=(0,r.normalizeRadian)((0,c.angleToRadian)(p.line.angle)-g);let t=Math.cos(e);n?(t/=.75,t>-1&&t<1?(n=!1,h=(0,c.radianToAngle)(Math.acos(t)*Math.sign(e)+g)):h=(0,a.mirrorNumber)(p.line.angle,(0,c.radianToAngle)(g))):(t*=.75,n=!0,h=(0,c.radianToAngle)(Math.acos(t)*Math.sign(e)+g))}else h=(0,a.mirrorNumber)(p.line.angle,(0,c.radianToAngle)(g));p.line={x:d.point.x,y:d.point.y,angle:(0,r.normalizeAngle)(h)}}return u}},1796:(e,t,n)=>{"use strict";n.r(t),n.d(t,{GeneralFormLine:()=>w,Ray:()=>k,dashedPolylineToLines:()=>D,drawDashedLine:()=>z,drawDashedPolyline:()=>B,generalFormLineToTwoPointLine:()=>O,getGeneralFormLineRadian:()=>G,getLineParamAtPoint:()=>te,getLinePointAtParam:()=>ne,getParallelLineSegmentsByDistance:()=>N,getParallelLinesByDistance:()=>F,getParallelRaysByDistance:()=>U,getPointSideOfLine:()=>L,getPolygonArea:()=>$,getPolygonLine:()=>X,getPolygonPoints:()=>Y,getRayAngle:()=>oe,getRayLineSegmentIntersectionDistance:()=>Q,getRayParamAtPoint:()=>re,getRayPointAtDistance:()=>K,getRayStartAndEnd:()=>ee,getRayTransformedLineSegment:()=>J,getSymmetryPoint:()=>j,getTwoLine3DIntersectionPoint:()=>ae,isSameLine:()=>A,iteratePolygonLines:()=>H,iteratePolylineLines:()=>W,pointAndDirectionToGeneralFormLine:()=>I,pointInPolygon:()=>V,pointIsOnGeneralFormLine:()=>R,pointIsOnLine:()=>S,pointIsOnLine3D:()=>ie,pointIsOnLineSegment:()=>_,pointIsOnRay:()=>T,polygonToPolyline:()=>q,rayToLineSegment:()=>Z,twoPointLineToGeneralFormLine:()=>M});var r=n(5773),o=n(1715),i=n(2792),a=n(5569),s=n(360),c=n(5147),l=n(8306),u=n(1475),p=Object.defineProperty,d=Object.defineProperties,f=Object.getOwnPropertyDescriptors,g=Object.getOwnPropertySymbols,h=Object.prototype.hasOwnProperty,m=Object.prototype.propertyIsEnumerable,y=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),v=Math.pow,x=(e,t,n)=>t in e?p(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,b=(e,t)=>{for(var n in t||(t={}))h.call(t,n)&&x(e,n,t[n]);if(g)for(var n of g(t))m.call(t,n)&&x(e,n,t[n]);return e},C=(e,t)=>d(e,f(t)),E=function(e,t){this[0]=e,this[1]=t},P=e=>{var t,n=e[y("asyncIterator")],r=!1,o={};return null==n?(n=e[y("iterator")](),t=e=>o[e]=t=>n[e](t)):(n=n.call(e),t=e=>o[e]=t=>{if(r){if(r=!1,"throw"===e)throw t;return t}return r=!0,{done:!1,value:new E(new Promise((r=>{var o=n[e](t);o instanceof Object||(()=>{throw TypeError("Object expected")})(),r(o)})),1)}}),o[y("iterator")]=()=>o,t("next"),"throw"in n?t("throw"):o.throw=e=>{throw e},"return"in n&&t("return"),o};const w={a:a.number,b:a.number,c:a.number},k=(0,a.and)(r.Position,{angle:a.number,bidirectional:(0,a.optional)(a.boolean),reversed:(0,a.optional)(a.boolean)});function _(e,t,n,r=i.NOT_EXTENDED){return!!(r.head&&r.body&&r.tail)||!!(r.head||r.body||r.tail)&&((0,i.isSameNumber)(t.x,n.x)?!(0,i.isSameNumber)(t.y,n.y)&&(0,i.isBetween)(e.y,t.y,n.y,r):(0,i.isBetween)(e.x,t.x,n.x,r))}function S(e,t,n){const r=M(t,n);return!!r&&R(e,r)}function R(e,{a:t,b:n,c:r}){return(0,i.isZero)(t*e.x+n*e.y+r)}function T(e,t,n=i.NOT_EXTENDED){if(n.head&&n.body&&n.tail)return!0;if(!n.head&&!n.body&&!n.tail)return!1;const a=(0,o.angleToRadian)(t.angle);if(t.bidirectional)return!!n.body&&R(e,I(e,a));if(n.body&&(0,r.isSamePoint)(e,t))return!0;const s=(0,o.getTwoPointsRadian)(e,t);return!(!n.body||!(0,i.isSameNumber)(a,s))||!(!n.head||!(0,i.isSameNumber)(a,(0,l.reverseRadian)(s)))}function A(e,t){return!!(0,i.equals)(e.a*t.b,t.a*e.b)&&((0,i.isZero)(e.a)?(0,i.equals)(e.b*t.c,t.b*e.c):(0,i.equals)(e.a*t.c,t.a*e.c))}function L(e,t){return t.a*e.x+t.b*e.y+t.c}function M(e,t){if((0,r.isSamePoint)(e,t))return;const n=t.x-e.x,o=t.y-e.y;return{a:o,b:-n,c:-e.x*o+e.y*n}}function I(e,t){const n=Math.cos(t),r=Math.sin(t);return{a:r,b:-n,c:-e.x*r+e.y*n}}function O({a:e,b:t,c:n}){return(0,i.isZero)(e)?[{x:0,y:-n/t},{x:1,y:-n/t}]:(0,i.isZero)(t)?[{x:-n/e,y:0},{x:-n/e,y:1}]:[{x:0,y:-n/t},{x:-n/e,y:0}]}function D(e,t,n,r=0){if(!t||0===t.length)return[e];const o=[];let i=[];return B({moveTo(e,t){i.length>1&&o.push(i),i=[{x:e,y:t}]},lineTo(e,t){0===i.length&&i.push({x:0,y:0}),i.push({x:e,y:t})}},e,t,n,r),i.length>1&&o.push(i),o}function B(e,t,n,r,o=0){n.length%2==1&&(n=[...n,...n]),n.reduce(((e,t)=>e+t))<=0||t.forEach(((i,a)=>{0===a||(null==r?void 0:r.includes(a-1))?e.moveTo(i.x,i.y):o=z(e,t[a-1],i,n,o)}))}function z(e,t,n,o,i=0){o.length%2==1&&(o=[...o,...o]);const a=o.reduce(((e,t)=>e+t));if(a<=0)return i;let s=(0,r.getTwoPointsDistance)(t,n);const c=(i+s)%a;let l=t;for(;s>0;)for(let t=0;t0){if(a<=i){i-=a;continue}a-=i,i=0}const u=t%2==0?"lineTo":"moveTo";if(a>=s)return e[u](n.x,n.y),c;const p=(0,r.getPointByLengthAndDirection)(l,a,n);e[u](p.x,p.y),s-=a,l=p}return c}function F(e,t){if((0,i.isZero)(t))return[e,e];const n=t*Math.sqrt(v(e.a,2)+v(e.b,2));return[C(b({},e),{c:e.c+n}),C(b({},e),{c:e.c-n})]}function N(e,t){if((0,i.isZero)(t))return[e,e];if((0,r.isSamePoint)(...e))return;const n=(0,o.getTwoPointsRadian)(e[1],e[0]),a=n-Math.PI/2,s=n+Math.PI/2;return[[(0,r.getPointByLengthAndRadian)(e[0],t,s),(0,r.getPointByLengthAndRadian)(e[1],t,s)],[(0,r.getPointByLengthAndRadian)(e[0],t,a),(0,r.getPointByLengthAndRadian)(e[1],t,a)]]}function U(e,t){if((0,i.isZero)(t))return[e,e];const n=(0,o.angleToRadian)(e.angle);return[b(b({},e),(0,r.getPointByLengthAndRadian)(e,t,n+Math.PI/2)),b(b({},e),(0,r.getPointByLengthAndRadian)(e,t,n-Math.PI/2))]}function G({a:e,b:t}){return Math.atan2(e,-t)}function j(e,{a:t,b:n,c:r}){const o=v(t,2),i=v(n,2),a=o+i,s=-2*t*n,c=i-o;return{x:(c*e.x+s*e.y-2*t*r)/a,y:(s*e.x-c*e.y-2*n*r)/a}}function V({x:e,y:t},n){let r=!1;for(let o=0,a=n.length-1;oe-t)),[K(e,n[0]),K(e,n[n.length-1])])}function Q({x:e,y:t,angle:n,bidirectional:r},a){const s=M(...a);if(!s)return;const c=(0,o.angleToRadian)(n),l=Math.cos(c),u=Math.sin(c),{a:p,b:d,c:f}=s,g=p*l+d*u;if((0,i.isZero)(g))return;const h=-(p*e+d*t+f)/g;return!r&&(0,i.lessOrEqual)(h,0)||!_({x:e+h*l,y:t+h*u},...a)?void 0:h}function J(e,t,n,r,o){let i=[{x:0,y:0},{x:t,y:0},{x:t,y:n},{x:0,y:n}];if(r){const e=C(b({},r),{center:{x:t/2,y:n/2}});i=i.map((t=>(0,s.reverseTransformPosition)(t,e)))}if(o){const e=c.m3.inverse(o);i=i.map((t=>{const n=c.m3.multiplyVec3(e,[t.x,t.y,1]);return{x:n[0],y:n[1]}}))}return Z(e,i)}function ee(e){return{start:e.bidirectional||e.reversed?void 0:e,end:!e.bidirectional&&e.reversed?e:void 0}}function te(e,t,n){return(0,i.isSameNumber)(e.x,t.x)?(n.y-e.y)/(t.y-e.y):(n.x-e.x)/(t.x-e.x)}function ne({x:e,y:t},{x:n,y:r},o){return{x:e+(n-e)*o,y:t+(r-t)*o}}function re(e,t){const n=(0,r.getTwoPointsDistance)(e,t);return(0,i.isZero)(n)?0:n*((0,i.isSameNumber)((0,o.angleToRadian)(e.angle),(0,o.getTwoPointsRadian)(t,e))?1:-1)*(e.reversed?-1:1)}function oe(e){return e.reversed?(0,l.reverseAngle)(e.angle):e.angle}function ie(e,t,n){const o=c.v3.substract(e,t);return(0,r.isSameDirection3D)(o,n)}function ae([e,t,n],[r,o,a],[s,c,l],[p,d,f]){const g=(0,u.calculateEquationSet)([[r,-p,e-s],[o,-d,t-c]]);if(!g)return;const[h,m]=g;return(0,i.isZero)(a*h+f*m+n-l)?[e+r*h,t+o*h,n+a*h]:void 0}},2792:(e,t,n)=>{"use strict";n.r(t),n.d(t,{EXTENDED:()=>v,NOT_EXTENDED:()=>x,applyToItems:()=>N,continuedFractionToFraction:()=>V,deduplicate:()=>_,deepEquals:()=>g,delta1:()=>o,delta2:()=>i,delta3:()=>a,equals:()=>S,findFrom:()=>z,findIndexFrom:()=>B,first:()=>O,formatNumber:()=>T,getCommonDivisor:()=>W,getContinuedFraction:()=>j,getLeastCommonMultiple:()=>H,getNumberRangeDifference:()=>k,getNumberRangeIntersection:()=>P,getNumberRangeUnion:()=>w,getTwoNumberCenter:()=>y,getTwoNumbersDistance:()=>m,isAfter:()=>E,isBefore:()=>C,isBetween:()=>b,isSameNumber:()=>R,isValidPercent:()=>d,isZero:()=>s,largerOrEqual:()=>u,largerThan:()=>l,lessOrEqual:()=>p,lessThan:()=>c,maximumBy:()=>L,maximumsBy:()=>I,mergeItems:()=>F,mergeNumberRange:()=>U,minimumBy:()=>A,minimumsBy:()=>M,mirrorNumber:()=>G,multiplyOpacity:()=>D,setArrayItems:()=>q,shallowEquals:()=>h,sqrt3:()=>f});var r=n(6022);const o=1e-8,i=1e-5,a=.001;function s(e,t=o){return Math.abs(e)t&&!R(e,t,n)}function u(e,t,n){return e>t||R(e,t,n)}function p(e,t,n){return e!t(e,r)))&&n.push(r);return n}function S(e,t){return void 0===e&&void 0===t||void 0!==e&&void 0!==t&&R(e,t)}function R(e,t,n){return s(e-t,n)}function T(e,t=100){return Math.round(e*t)/t}function A(e,t,n){let r,o=e[0];for(let i=1;ie.value))}function I(e,t){if(0===e.length)return[];if(1===e.length)return[e[0]];let n=[{value:e[0],byValue:t(e[0])}];for(let r=1;re.value))}function O(e){for(const t of e)return t}function D(e,t){return void 0===e?t:void 0===t?e:e*t}function B(e,t,n,r){if(null==r?void 0:r.reverse){for(let r=t;r>=0;r--)if(n(e[r]))return r;if(null==r?void 0:r.closed)for(let r=e.length-1;r>t;r--)if(n(e[r]))return r}else{for(let r=t;rn(t,e))).flat();return r}function U(e,t){return S(e[1],t[0])?[e[0],t[1]]:S(e[0],t[1])?[e[1],t[0]]:void 0}function G(e,t){return 2*t-e}function j(e,t=10){const n=[];for(;n.length=0;n--)t=[e[n]*t[0]+t[1],t[0]];return t}function W(e,t){return 0===t?e:W(t,e%t)}function H(e,t){return e*t/W(e,t)}function q(e,t,n){for(let r=0;r{"use strict";n.r(t),n.d(t,{getRenderOptionsMatrix:()=>u,getRotationOptionsAngle:()=>c,getScaleOptionsScale:()=>l,m2:()=>d,m3:()=>s,matrix:()=>h,multiplyMatrix:()=>p,v2:()=>f,v3:()=>g,vector:()=>m});var r=n(1475),o=n(2792),i=n(1715),a=Math.pow;const s={projection:(e,t)=>[2/e,0,0,0,-2/t,0,-1,1,1],identity:()=>[1,0,0,0,1,0,0,0,1],translation:(e,t)=>[1,0,0,0,1,0,e,t,1],rotation(e){const t=Math.cos(e),n=Math.sin(e);return[t,-n,0,n,t,0,0,0,1]},scaling:(e,t)=>[e,0,0,0,t,0,0,0,1],multiply:(e,t)=>[t[0]*e[0]+t[1]*e[3]+t[2]*e[6],t[0]*e[1]+t[1]*e[4]+t[2]*e[7],t[0]*e[2]+t[1]*e[5]+t[2]*e[8],t[3]*e[0]+t[4]*e[3]+t[5]*e[6],t[3]*e[1]+t[4]*e[4]+t[5]*e[7],t[3]*e[2]+t[4]*e[5]+t[5]*e[8],t[6]*e[0]+t[7]*e[3]+t[8]*e[6],t[6]*e[1]+t[7]*e[4]+t[8]*e[7],t[6]*e[2]+t[7]*e[5]+t[8]*e[8]],multiplyVec3:(e,t)=>[t[0]*e[0]+t[1]*e[3]+t[2]*e[6],t[0]*e[1]+t[1]*e[4]+t[2]*e[7],t[0]*e[2]+t[1]*e[5]+t[2]*e[8]],inverse([e,t,n,r,o,i,a,s,c]){const l=o*c-i*s,u=t*i-n*o,p=n*s-t*c,d=u*a+r*p+e*l;return[l/d,p/d,u/d,(i*a-r*c)/d,(-n*a+e*c)/d,(n*r-e*i)/d,(r*s-o*a)/d,(t*a-e*s)/d,(e*o-t*r)/d]},getTransform:e=>[e[0],e[1],e[3],e[4],e[6],e[7]],getTransformInit:e=>({a:e[0],b:e[1],c:e[3],d:e[4],e:e[6],f:e[7]})};function c(e,t=!1){return(null==e?void 0:e.angle)?t?(0,i.angleToRadian)(e.angle):e.angle:(null==e?void 0:e.rotation)?t?e.rotation:(0,i.radianToAngle)(e.rotation):void 0}function l(e){if(null==e?void 0:e.scale)return"number"==typeof e.scale?{x:e.scale,y:e.scale}:e.scale}function u(e){if(!e)return;let t=s.identity();if(e.translate&&(t=s.multiply(t,s.translation(e.translate.x,e.translate.y))),e.base){const n=c(e,!0);n&&(t=s.multiply(t,s.translation(e.base.x,e.base.y)),t=s.multiply(t,s.rotation(-n)),t=s.multiply(t,s.translation(-e.base.x,-e.base.y)));const r=l(e);r&&(t=s.multiply(t,s.translation(e.base.x,e.base.y)),t=s.multiply(t,s.scaling(r.x,r.y)),t=s.multiply(t,s.translation(-e.base.x,-e.base.y)))}return e.matrix&&(t=s.multiply(t,e.matrix)),t}function p(e,t){return void 0===e?t:void 0===t?e:s.multiply(e,t)}const d={inverse([e,t,n,r]){const i=e*r-t*n;if(!(0,o.isZero)(i))return[r/i,-t/i,-n/i,e/i]},multiplyVec2:([e,t,n,r],[o,i])=>[e*o+t*i,n*o+r*i]},f={add:([e,t],[n,r])=>[e+n,t+r],substract:([e,t],[n,r])=>[e-n,t-r]},g={cross:(e,t)=>[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]],dot:(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2],dots:(e,t)=>[g.dot(e[0],t[0]),g.dot(e[1],t[1]),g.dot(e[2],t[2])],add:(e,t)=>[e[0]+t[0],e[1]+t[1],e[2]+t[2]],addToVecs:(e,t)=>[g.add(e,t[0]),g.add(e,t[1]),g.add(e,t[2])],substract:(e,t)=>[e[0]-t[0],e[1]-t[1],e[2]-t[2]],addMultiple(...e){if(0===e.length)return[0,0,0];if(1===e.length)return e[0];const[t,n,...r]=e,o=g.add(t,n);return 2===e.length?o:g.addMultiple(o,...r)},length:e=>Math.sqrt(g.lengthSquare(e)),lengthSquare:e=>a(e[0],2)+a(e[1],2)+a(e[2],2),multiplyScalar:(e,t)=>[e[0]*t,e[1]*t,e[2]*t],multiplyScalars:(e,t)=>[g.multiplyScalar(e[0],t[0]),g.multiplyScalar(e[1],t[1]),g.multiplyScalar(e[2],t[2])],addScalar:(e,t)=>[e[0]+t,e[1]+t,e[2]+t],normalize:e=>g.multiplyScalar(e,1/g.length(e))},h={inverse(e){const t=[];for(let n=0;n[...e,t===n?-1:0])),i=(0,r.calculateEquationSet)(o);if(!i)return;for(let e=0;ee.map(((e,n)=>e+t[n])),substract:(e,t)=>e.map(((e,n)=>e-t[n]))}},6300:(e,t,n)=>{"use strict";function r(...e){let t=0;for(const n of e)t+=o(n);const n=new Float32Array(t);let r=0;for(const t of e){if("mat3x3"===t.type)n.set(t.value.slice(0,3),r),n.set(t.value.slice(3,6),r+4),n.set(t.value.slice(6,9),r+8);else if("mat4x4"===t.type)n.set(t.value.slice(0,16),r);else if("vec4"===t.type||"vec3"===t.type||"vec2"===t.type)n.set(t.value,r);else if("number"===t.type)n.set([t.value],r);else if("vec4 array"===t.type)n.set(t.value,r);else if("inline"===t.type){let e=0;for(const o of t.children)"number"===o.type?(n.set([o.value],r+e),e++):(n.set(o.value,r+e),"vec2"===o.type?e+=2:"vec3"===o.type&&(e+=3))}r+=o(t)}return n}function o(e){return"mat3x3"===e.type?12:"mat4x4"===e.type?16:"vec4"===e.type||"number"===e.type||"vec2"===e.type||"vec3"===e.type||"inline"===e.type?4:"vec4 array"===e.type?4*e.count:0}n.r(t),n.d(t,{createMemoryLayoutArray:()=>r})},2572:(e,t,n)=>{"use strict";n.r(t),n.d(t,{isSameDerivative:()=>D,mergeArc:()=>E,mergeBezierCurve:()=>A,mergeBezierCurvesToBezierSpline:()=>O,mergeEllipseArc:()=>P,mergeGeometryLine:()=>B,mergeLineSegment:()=>C,mergeQuadraticCurve:()=>k,mergeQuadraticCurvesToQuadraticSpline:()=>T});var r=n(5629),o=n(2792),i=n(5773),a=n(1796),s=n(2298),c=n(2318),l=n(8306),u=n(8831),p=n(2986),d=Object.defineProperty,f=Object.defineProperties,g=Object.getOwnPropertyDescriptors,h=Object.getOwnPropertySymbols,m=Object.prototype.hasOwnProperty,y=Object.prototype.propertyIsEnumerable,v=(e,t,n)=>t in e?d(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,x=(e,t)=>{for(var n in t||(t={}))m.call(t,n)&&v(e,n,t[n]);if(h)for(var n of h(t))y.call(t,n)&&v(e,n,t[n]);return e},b=(e,t)=>f(e,g(t));function C(e,t){return(0,i.isSamePoint)(e[1],t[0])?(0,a.pointIsOnLine)(t[1],...e)?[e[0],t[1]]:void 0:C(t,e)}function E(e,t){if((0,c.isSameCircle)(e,t))return e.counterclockwise!==t.counterclockwise&&(t=(0,l.reverseArc)(t)),w(e,t)}function P(e,t){if((0,s.isSameEllipse)(e,t))return e.counterclockwise!==t.counterclockwise&&(t=(0,l.reverseEllipseArc)(t)),w(e,t)}function w(e,t){return(0,o.isZero)(Math.abs(e.endAngle-t.startAngle)%360)?(0,o.isZero)(Math.abs(e.startAngle-t.endAngle)%360)?b(x({},e),{startAngle:0,endAngle:360}):b(x({},e),{startAngle:(0,u.normalizeAngle)(e.startAngle),endAngle:(0,u.normalizeAngle)(t.endAngle)}):(0,o.isZero)(Math.abs(e.startAngle-t.endAngle)%360)?b(x({},e),{startAngle:(0,u.normalizeAngle)(t.startAngle),endAngle:(0,u.normalizeAngle)(e.endAngle)}):void 0}function k(e,t){const n=(0,r.getQuadraticCurveDerivatives)(e),o=(0,r.getQuadraticCurveDerivatives)(t);if(S(n,o)&&R(n,o))return _(e,t)}function _(e,t){const n=(0,r.getQuadraticCurvePercentAtPoint)(e,t.to);return(0,r.getPartOfQuadraticCurve)(e,0,n)}function S(e,t){return D(e[0](1),t[0](0))&&D(e[1](1),t[1](0))}function R(e,t){return D(e[2](1),t[2](0))}function T(e){if(0===e.length)return;const t=e[0];if(1===e.length)return[t.from,t.cp,t.to];const n=[(0,r.getQuadraticCurveDerivatives)(t)],o=[t.from,t.cp];for(let t=1;;t++){if(n.push((0,r.getQuadraticCurveDerivatives)(e[t])),!S(n[t-1],n[t]))return;if(R(n[t-1],n[t]))return T([...e.slice(0,t-1),_(e[t-1],e[t]),...e.slice(t+1)]);if(!(0,i.isSamePoint)((0,i.getTwoPointCenter)(e[t-1].cp,e[t].cp),e[t-1].to))return;if(o.push(e[t].cp),e.length===t+1)return[...o,e[e.length-1].to]}}function A(e,t){const n=(0,r.getBezierCurveDerivatives)(e),o=(0,r.getBezierCurveDerivatives)(t);if(M(n,o)&&I(n,o))return L(e,t)}function L(e,t){const n=(0,r.getBezierCurvePercentAtPoint)(e,t.to);return(0,r.getPartOfBezierCurve)(e,0,n)}function M(e,t){return D(e[0](1),t[0](0))&&D(e[1](1),t[1](0))&&D(e[2](1),t[2](0))}function I(e,t){return D(e[3](1),t[3](0))}function O(e){if(0===e.length)return;const t=e[0];if(1===e.length)return[t.from,t.cp1,t.cp2,t.to];const n=[(0,r.getBezierCurveDerivatives)(t)],o=[t.from,t.cp1];for(let t=1;;t++){if(n.push((0,r.getBezierCurveDerivatives)(e[t])),!M(n[t-1],n[t]))return;if(I(n[t-1],n[t]))return O([...e.slice(0,t-1),L(e[t-1],e[t]),...e.slice(t+1)]);if(!(0,i.isSamePoint)((0,i.getTwoPointCenter)(e[t-1].cp2,e[t].cp1),e[t-1].to))return;if(o.push({x:2*e[t].cp1.x-e[t].cp2.x,y:2*e[t].cp1.y-e[t].cp2.y}),e.length===t+1)return[...o,e[e.length-1].cp2,e[e.length-1].to]}}function D(e,t){return(0,o.isSameNumber)(e.x*t.y,e.y*t.x)}function B(e,t){if(Array.isArray(e)&&Array.isArray(t))return C(e,t);if(!Array.isArray(e)&&!Array.isArray(t)){if("arc"===e.type&&"arc"===t.type){const n=E(e.curve,t.curve);if(!n)return;return{type:"arc",curve:n}}if("ellipse arc"===e.type&&"ellipse arc"===t.type){const n=P(e.curve,t.curve);if(!n)return;return{type:"ellipse arc",curve:n}}if("quadratic curve"===e.type&&"quadratic curve"===t.type){const n=k(e.curve,t.curve);if(!n)return;return{type:"quadratic curve",curve:n}}if("bezier curve"===e.type&&"bezier curve"===t.type){const n=A(e.curve,t.curve);if(!n)return;return{type:"bezier curve",curve:n}}if("hyperbola curve"===e.type&&"hyperbola curve"===t.type){const n=(0,p.mergeHyperbolaSegments)(e.curve,t.curve);if(!n)return;return{type:"hyperbola curve",curve:n}}}}},9596:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Merger:()=>o});var r=Object.defineProperty;class o{constructor(e,t,n){var o,i;this.flush=e,this.equals=t,this.getTarget=n,((e,t,n)=>{t in e?r(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(this,"symbol"!=typeof(o="last")?o+"":o,i)}flushLast(){this.last&&this.last.target.length>0&&(this.flush(this.last),this.last=void 0)}push(e){this.last?this.equals(this.last.type,e)?this.last.target.push(this.getTarget(e)):(this.flushLast(),this.push(e)):this.last={type:e,target:[this.getTarget(e)]}}}},4575:(e,t,n)=>{"use strict";n.r(t),n.d(t,{extendGeometryLines:()=>$,mirrorArc:()=>L,mirrorEllipse:()=>M,mirrorEllipseArc:()=>I,mirrorGeometryLine:()=>B,mirrorHyperbola:()=>D,mirrorParabola:()=>O,mirrorPoint:()=>A,moveEllipse:()=>E,moveGeometryLine:()=>P,movePoint:()=>C,rotateArc:()=>k,rotateEllipse:()=>_,rotateGeometryLine:()=>T,rotateHyperbola:()=>R,rotateParabola:()=>S,rotatePoint:()=>w,scaleEllipse:()=>F,scaleEllipseArc:()=>N,scaleGeometryLine:()=>U,scaleGeometryLines:()=>G,scalePoint:()=>z,skewEllipse:()=>V,skewEllipseArc:()=>W,skewGeometryLine:()=>H,skewGeometryLines:()=>q,skewPoint:()=>j});var r=n(5773),o=n(1796),i=n(2298),a=n(2318),s=n(1715),c=n(2792),l=n(1475),u=n(5629),p=n(2986),d=Object.defineProperty,f=Object.defineProperties,g=Object.getOwnPropertyDescriptors,h=Object.getOwnPropertySymbols,m=Object.prototype.hasOwnProperty,y=Object.prototype.propertyIsEnumerable,v=(e,t,n)=>t in e?d(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,x=(e,t)=>{for(var n in t||(t={}))m.call(t,n)&&v(e,n,t[n]);if(h)for(var n of h(t))y.call(t,n)&&v(e,n,t[n]);return e},b=(e,t)=>f(e,g(t));function C(e,t){e.x+=t.x,e.y+=t.y}function E(e,t){e.cx+=t.x,e.cy+=t.y}function P(e,t){if(Array.isArray(e))C(e[0],t),C(e[1],t);else if("arc"===e.type)C(e.curve,t);else if("ellipse arc"===e.type)E(e.curve,t);else if("quadratic curve"===e.type)C(e.curve.from,t),C(e.curve.cp,t),C(e.curve.to,t);else if("bezier curve"===e.type)C(e.curve.from,t),C(e.curve.cp1,t),C(e.curve.cp2,t),C(e.curve.to,t);else if("hyperbola curve"===e.type)C(e.curve,t);else if("nurbs curve"===e.type)for(const n of e.curve.points)C(n,t)}function w(e,t,n){const o=(0,r.rotatePositionByCenter)(e,t,-n);return e.x=o.x,e.y=o.y,o}function k(e,t,n){w(e,t,n),e.startAngle+=n,e.endAngle+=n}function _(e,t,n){var r;const o=w((0,i.getEllipseCenter)(e),t,n);e.cx=o.x,e.cy=o.y,e.angle=(null!=(r=e.angle)?r:0)+n}function S(e,t,n){w(e,t,n),e.angle+=n}function R(e,t,n){w(e,t,n),e.angle+=n}function T(e,t,n){if(Array.isArray(e))w(e[0],t,n),w(e[1],t,n);else if("arc"===e.type)k(e.curve,t,n);else if("ellipse arc"===e.type)_(e.curve,t,n);else if("quadratic curve"===e.type)w(e.curve.from,t,n),w(e.curve.cp,t,n),w(e.curve.to,t,n);else if("bezier curve"===e.type)w(e.curve.from,t,n),w(e.curve.cp1,t,n),w(e.curve.cp2,t,n),w(e.curve.to,t,n);else if("hyperbola curve"===e.type)R(e.curve,t,n);else if("nurbs curve"===e.type)for(const r of e.curve.points)w(r,t,n)}function A(e,t){const n=(0,o.getSymmetryPoint)(e,t);return e.x=n.x,e.y=n.y,n}function L(e,t,n){A(e,t);const r=(0,c.mirrorNumber)(e.endAngle,n),o=(0,c.mirrorNumber)(e.startAngle,n);e.startAngle=r,e.endAngle=o}function M(e,t,n){var r;const o=A((0,i.getEllipseCenter)(e),t);e.cx=o.x,e.cy=o.y,e.angle=(0,c.mirrorNumber)(null!=(r=e.angle)?r:0,n)}function I(e,t,n){var r;const o=A((0,i.getEllipseCenter)(e),t);e.cx=o.x,e.cy=o.y;const a=null!=(r=e.angle)?r:0,s=(0,c.mirrorNumber)(a,n);e.angle=s;const l=(0,c.mirrorNumber)(e.endAngle+a,n),u=(0,c.mirrorNumber)(e.startAngle+a,n);e.startAngle=l-s,e.endAngle=u-s}function O(e,t,n){A(e,t),e.angle=(0,c.mirrorNumber)(e.angle,n),e.t1*=-1,e.t2*=-1}function D(e,t,n){A(e,t),e.angle=(0,c.mirrorNumber)(e.angle,n),e.t1*=-1,e.t2*=-1}function B(e,t,n){if(Array.isArray(e))A(e[0],t),A(e[1],t);else if("arc"===e.type)L(e.curve,t,n);else if("ellipse arc"===e.type)M(e.curve,t,n);else if("quadratic curve"===e.type)A(e.curve.from,t),A(e.curve.cp,t),A(e.curve.to,t);else if("bezier curve"===e.type)A(e.curve.from,t),A(e.curve.cp1,t),A(e.curve.cp2,t),A(e.curve.to,t);else if("hyperbola curve"===e.type)D(e.curve,t,n);else if("nurbs curve"===e.type)for(const n of e.curve.points)A(n,t)}function z(e,t,n,r=n){e.x=(e.x-t.x)*n+t.x,e.y=(e.y-t.y)*r+t.y}function F(e,t,n,r=n){if(e.cx=(e.cx-t.x)*n+t.x,e.cy=(e.cy-t.y)*r+t.y,(0,c.equals)(n,r))return e.rx*=Math.abs(n),void(e.ry*=Math.abs(r));const o=(0,s.angleToRadian)(e.angle),i=Math.sin(o);if((0,c.isZero)(i))return e.rx*=Math.abs(n),void(e.ry*=Math.abs(r));const a=Math.cos(o);if((0,c.isZero)(a))return e.rx*=Math.abs(r),void(e.ry*=Math.abs(n));const u=a/n/e.rx,p=i/r/e.rx,d=-i/n/e.ry,f=a/r/e.ry,g=u*u+d*d,h=u*p+d*f,m=p*p+f*f,y=Math.atan((0,l.calculateEquation2)(h,g-m,-h)[0]);e.angle=(0,s.radianToAngle)(y);const v=Math.sin(y),x=Math.cos(y);e.rx=Math.sqrt((x*x-v*v)/(g*x*x-m*v*v)),e.ry=Math.sqrt((x*x-v*v)/(m*x*x-g*v*v))}function N(e,t,n,r=n){const o=(0,i.getEllipseArcPointAtAngle)(e,e.startAngle),a=(0,i.getEllipseArcPointAtAngle)(e,e.endAngle);z(o,t,n,r),z(a,t,n,r),F(e,t,n,r),e.startAngle=(0,i.getEllipseAngle)(o,e),e.endAngle=(0,i.getEllipseAngle)(a,e)}function U(e,t,n,r=n){if(Array.isArray(e))z(e[0],t,n,r),z(e[1],t,n,r);else if("arc"===e.type){if(n!==r&&!(0,c.isZero)(n+r)){const o=(0,i.arcToEllipseArc)(e.curve);return N(o,t,n,r),{type:"ellipse arc",curve:o}}z(e.curve,t,n,r),e.curve.r*=Math.abs(n)}else if("ellipse arc"===e.type)N(e.curve,t,n,r);else if("quadratic curve"===e.type)z(e.curve.from,t,n,r),z(e.curve.cp,t,n,r),z(e.curve.to,t,n,r);else if("bezier curve"===e.type)z(e.curve.from,t,n,r),z(e.curve.cp1,t,n,r),z(e.curve.cp2,t,n,r),z(e.curve.to,t,n,r);else if("hyperbola curve"===e.type)z(e.curve,t,n,r);else if("nurbs curve"===e.type)for(const o of e.curve.points)z(o,t,n,r)}function G(e,t,n,r=n){for(let o=0;o{"use strict";n.r(t),n.d(t,{Nurbs:()=>T,NurbsCurve:()=>j,fromVerbPoint:()=>H,getArcNurbsCurveIntersectionPoints:()=>le,getBezierCurveAndNurbsCurveExtremumPoints:()=>Ee,getBezierCurveNurbsCurveIntersectionPoints:()=>de,getCircleAndNurbsCurveExtremumPoints:()=>xe,getDefaultNurbsKnots:()=>B,getDefaultWeights:()=>z,getEllipseAndNurbsCurveExtremumPoints:()=>be,getEllipseArcNurbsCurveIntersectionPoints:()=>ue,getHyperbolaAndNurbsCurveExtremumPoints:()=>we,getLineAndNurbsCurveExtremumPoints:()=>ve,getLineSegmentNurbsCurveIntersectionPoints:()=>ce,getNurbsCurveCurvatureAtParam:()=>ye,getNurbsCurveDerivatives:()=>te,getNurbsCurveLength:()=>re,getNurbsCurveLengthByParam:()=>oe,getNurbsCurveParamAtPoint:()=>Y,getNurbsCurveParamByLength:()=>ie,getNurbsCurvePointAtParam:()=>K,getNurbsCurvePoints:()=>Q,getNurbsCurveStartAndEnd:()=>Z,getNurbsMaxParam:()=>X,getNurbsPoints:()=>F,getNurbsPoints3D:()=>N,getNurbsSurfaceTrianglePoints:()=>U,getNurbsSurfaceVertices:()=>G,getParallelNurbsCurvesByDistance:()=>me,getPartOfNurbsCurve:()=>se,getPerpendicularParamToNurbsCurve:()=>J,getPointAndNurbsCurveNearestPointAndDistance:()=>ne,getPointSideOfNurbsCurve:()=>he,getQuadraticCurveAndNurbsCurveExtremumPoints:()=>Ce,getQuadraticCurveNurbsCurveIntersectionPoints:()=>pe,getTangencyParamToNurbsCurve:()=>ee,getTwoNurbsCurveExtremumPoints:()=>Pe,getTwoNurbsCurveIntersectionPoints:()=>fe,interpolateBSpline:()=>A,interpolateNurbs:()=>L,interpolateNurbs2:()=>O,interpolateNurbs3:()=>D,pointIsOnNurbsCurve:()=>$,reverseNurbsCurve:()=>ge,splitNurbsCurve:()=>ae,toBezierCurves:()=>M,toQuadraticCurves:()=>I,toVerbNurbsCurve:()=>W});var r=n(670),o=n(9397),i=n(2792),a=n(5773),s=n(1796),c=n(2298),l=n(2318),u=n(5569),p=n(1715),d=n(5629),f=n(1475),g=n(1785),h=n(8392),m=n(8306),y=n(8831),v=n(2986),x=Object.defineProperty,b=Object.defineProperties,C=Object.getOwnPropertyDescriptors,E=Object.getOwnPropertySymbols,P=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable,k=Math.pow,_=(e,t,n)=>t in e?x(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,S=(e,t)=>{for(var n in t||(t={}))P.call(t,n)&&_(e,n,t[n]);if(E)for(var n of E(t))w.call(t,n)&&_(e,n,t[n]);return e},R=(e,t)=>b(e,C(t));const T={points:[a.Position],degree:(0,u.minimum)(1,u.integer),knots:(0,u.optional)([u.number]),weights:(0,u.optional)([u.number])};function A(e,t,n,r=B(n.length,t)){const o=t,i=r.length-1-t;e=e*(r[i]-r[o])+r[o];const a=r.findIndex(((t,n)=>n>=o&&n=e)),s=[...n];for(let t=o;t>=0;t--)for(let n=a;n>a-t;n--){const o=(e-r[n])/(r[n+t]-r[n]);s[n]=(1-o)*s[n-1]+o*s[n]}return s[a]}function L(e,t,n,r=B(n.length,t),o){return o?A(e,t,n.map(((e,t)=>n[t]*o[t])),r)/A(e,t,o,r):A(e,t,n,r)}function M(e,t){return 1===t?4===e.length?{from:e[0],cp1:e[1],cp2:e[2],to:e[3]}:5===e.length?{from:e[0],cp1:e[1],cp2:e[1]/2+e[2]/2,to:e[1]/4+e[2]/2+e[3]/4}:{from:e[0],cp1:e[1],cp2:.5*e[2]+.5*e[1],to:e[3]/6+7/12*e[2]+e[1]/4}:2===t?5===e.length?{from:.25*e[1]+.25*e[3]+.5*e[2],cp1:.5*e[2]+.5*e[3],cp2:e[3],to:e[4]}:6===e.length?{from:7/12*e[2]+e[3]/6+.25*e[1],cp1:2/3*e[2]+e[3]/3,cp2:e[2]/3+2/3*e[3],to:e[2]/6+7/12*e[3]+e[4]/4}:{from:e[1]/4+e[3]/6+7/12*e[2],cp1:e[3]/3+2*e[2]/3,cp2:2/3*e[3]+e[2]/3,to:e[4]/6+2/3*e[3]+e[2]/6}:t===e.length-4?{from:e[e.length-5]/6+2/3*e[e.length-4]+e[e.length-3]/6,cp1:e[e.length-3]/3+2/3*e[e.length-4],cp2:2/3*e[e.length-3]+e[e.length-4]/3,to:e[e.length-2]/4+7/12*e[e.length-3]+e[e.length-4]/6}:t===e.length-3?{from:e[e.length-4]/6+7/12*e[e.length-3]+e[e.length-2]/4,cp1:e[e.length-2]/2+e[e.length-3]/2,cp2:e[e.length-2],to:e[e.length-1]}:{from:e[t+1]/6+2/3*e[t]+e[t-1]/6,cp1:e[t+1]/3+2*e[t]/3,cp2:2*e[t+1]/3+e[t]/3,to:e[t+2]/6+2/3*e[t+1]+e[t]/6}}function I(e,t){return{from:1===t?e[0]:(e[t-1]+e[t])/2,cp:e[t],to:t===e.length-2?e[e.length-1]:(e[t]+e[t+1])/2}}function O(e,t,n,r=B(n.length,t),o){return[L(e,t,n.map((e=>e[0])),r,o),L(e,t,n.map((e=>e[1])),r,o)]}function D(e,t,n,r=B(n.length,t),o){return[L(e,t,n.map((e=>e[0])),r,o),L(e,t,n.map((e=>e[1])),r,o),L(e,t,n.map((e=>e[2])),r,o)]}function B(e,t){const n=[];for(let e=0;ee.x)),s=t.map((e=>e.y));for(let t=0;t<=o;t++){const c=t/o;i.push({x:L(c,e,a,n,r),y:L(c,e,s,n,r)})}return i}function N(e,t,n=B(t.length,e),r,o=100){const i=[],a=t.map((e=>e[0])),s=t.map((e=>e[1])),c=t.map((e=>e[2]));for(let t=0;t<=o;t++){const l=t/o;i.push([L(l,e,a,n,r),L(l,e,s,n,r),L(l,e,c,n,r)])}return i}function U(e,t,n=B(e.length,t),r=t,o=B(e[0].length,t),i=20){const a=[];let s;for(let c=0;c<=i;c++){const l=c/i,u=e.map((e=>D(l,t,e,n))),p=u.map((e=>e[0])),d=u.map((e=>e[1])),f=u.map((e=>e[2])),g=[];for(let e=0;e<=i;e++){const t=e/i;g.push([L(t,r,p,o),L(t,r,d,o),L(t,r,f,o)]),s&&e>0&&a.push(...s[e-1],...s[e],...g[e-1],...g[e-1],...s[e],...g[e])}s=g}return a}function G(e,t,n=B(e.length,t),i=t,a=B(e[0].length,t),s){const c=r.geom.NurbsSurface.byKnotsControlPointsWeights(t,i,n,a,e,s),l=c.tessellate(),u=o.primitives.createAugmentedTypedArray(3,l.points.length),p=o.primitives.createAugmentedTypedArray(3,l.normals.length),d=o.primitives.createAugmentedTypedArray(2,l.uvs.length),f=l.faces.length%2==1?l.faces.length+1:l.faces.length,g=o.primitives.createAugmentedTypedArray(3,f,Uint16Array);return u.push(...l.points),p.push(...l.normals),d.push(...l.uvs),g.push(...l.faces),{vertices:{position:u,normal:p,texcoord:d,indices:g},nurbs:c,points:e}}const j={points:[a.Position],degree:u.number,knots:[u.number],weights:(0,u.optional)([u.number])};function V(e){return{points:e.controlPoints().map((e=>H(e))),degree:e.degree(),knots:e.knots(),weights:e.weights()}}function W(e){return r.geom.NurbsCurve.byKnotsControlPointsWeights(e.degree,e.knots,e.points.map((e=>q(e))),e.weights)}function H(e){return{x:e[0],y:e[1]}}function q(e){return[e.x,e.y]}function $(e,t){const n=W(t).closestPoint(q(e));return(0,i.isZero)((0,a.getTwoPointsDistance)(e,H(n)),i.delta3)}function X(e){return e.points.length-e.degree}function Y(e,t){return W(e).closestParam(q(t))}function K(e,t){return H(W(e).point(t))}function Z(e){return{start:K(e,0),end:K(e,X(e))}}function Q(e,t){const n=W(e),r=[];for(let e=0;e<=t;e++)r.push(H(n.point(e/t)));return r}function J({x:e,y:t},n,r,o=i.delta2){const a=W(n),s=r?a.closestParam(q(r)):X(n)/2;return(0,f.newtonIterate)(s,(n=>{const[[r,o],[i,s]]=a.derivatives(n);return i*(r-e)+s*(o-t)}),(n=>{const[[r,o],[i,s],[c,l]]=a.derivatives(n,2);return i*i+c*(r-e)+s*s+l*(o-t)}),o)}function ee({x:e,y:t},n,r,o=i.delta2){const a=W(n),s=r?a.closestParam(q(r)):X(n)/2;return(0,f.newtonIterate)(s,(n=>{const[[r,o],[i,s]]=a.derivatives(n);return s*(r-e)-i*(o-t)}),(n=>{const[[r,o],[i,s],[c,l]]=a.derivatives(n,2);return s*i+l*(r-e)-(i*s+c*(o-t))}),o)}function te(e,t){const n=W(e),[[r,o],[i,a]]=n.derivatives(t);return[{x:r,y:o},{x:i,y:a}]}function ne(e,t){const n=W(t),r=n.closestParam(q(e)),o=H(n.point(r));return{param:r,point:o,distance:(0,a.getTwoPointsDistance)(e,o)}}function re(e){return W(e).length()}function oe(e,t){return W(e).lengthAtParam(t)}function ie(e,t){return W(e).paramAtLength(t)}function ae(e,t){const[n,r]=W(e).split(t);return[V(n),V(r)]}function se(e,t,n){let r=W(e);return(0,i.isZero)(t)||(r=r.split(t)[1]),(0,i.isZero)(n)||(r=r.split(n)[0]),V(r)}function ce(e,t,n){const o=new r.geom.Line(q(e),q(t)),i=W(n);return r.geom.Intersect.curves(o,i).map((e=>H(e.point0)))}function le(e,t,n=i.NOT_EXTENDED){let o;if(n.head||n.tail)o=new r.geom.Circle(q(e),[1,0],[0,1],e.r);else{const t=(0,p.angleToRadian)(e.startAngle),n=(0,p.angleToRadian)(e.endAngle);o=new r.geom.Arc(q(e),[1,0],[0,1],e.r,e.counterclockwise?n:t,e.counterclockwise?t:n)}const a=W(t);return r.geom.Intersect.curves(o,a).map((e=>H(e.point0))).filter((t=>(0,l.pointIsOnArc)(t,e,n)))}function ue(e,t,n=i.NOT_EXTENDED){const o=(0,p.angleToRadian)(e.angle),a=Math.cos(o),s=Math.sin(o),l=new r.geom.Ellipse([e.cx,e.cy],[e.rx*a,e.rx*s],[-e.ry*s,e.ry*a]),u=W(t);let d=r.geom.Intersect.curves(l,u).map((e=>H(e.point0)));return d=d.filter((t=>(0,c.pointIsOnEllipseArc)(t,e,n))),d}function pe(e,t){const n=new r.geom.BezierCurve([q(e.from),q(e.cp),q(e.to)]),o=W(t);return r.geom.Intersect.curves(n,o).map((e=>H(e.point0)))}function de(e,t){const n=new r.geom.BezierCurve([q(e.from),q(e.cp1),q(e.cp2),q(e.to)]),o=W(t);return r.geom.Intersect.curves(n,o).map((e=>H(e.point0)))}function fe(e,t){const n=W(e),o=W(t);return r.geom.Intersect.curves(n,o).map((e=>H(e.point0)))}function ge(e){return V(W(e).reverse())}function he(e,t){const n=ne(e,t),[r,o]=W(t).tangent(n.param),i=Math.atan2(o,r),a=(0,s.pointAndDirectionToGeneralFormLine)(n.point,i);return(0,s.getPointSideOfLine)(e,a)}function me(e,t){if((0,i.isZero)(t))return[e,e];const[n,r]=(0,g.getParallelPolylinesByDistance)(e.points,t,!1);return[R(S({},e),{points:n.length===e.points.length?n:e}),R(S({},e),{points:r.length===e.points.length?r:e})]}function ye(e,t){const n=W(e),[,[r,o],[i,a]]=n.derivatives(t,2);return(r*a-o*i)/k(k(r,2)+k(o,2),1.5)}function ve(e,t,n=i.delta2){const r=W(t),{a:o,b:a}=e,s=e=>{const[,[t,n]]=r.derivatives(e);return o*t+a*n},c=e=>{const[,,[t,n]]=r.derivatives(e,2);return o*t+a*n};let l=[];const u=X(t);for(let e=.5;e(0,i.isBetween)(e,0,u))).map((t=>{const n=H(r.point(t));return[(0,h.getPerpendicularPoint)(n,e),n]}))}function xe(e,t,n=i.delta2){const r=W(t),{x:o,y:a}=e,s=e=>{const[[t,n],[i,s]]=r.derivatives(e);return i*(t-o)+s*(n-a)},c=e=>{const[[t,n],[i,s],[c,l]]=r.derivatives(e,2);return i*i+c*(t-o)+s*s+l*(n-a)};let u=[];const p=X(t);for(let e=.5;e(0,i.isBetween)(e,0,p))).map((t=>{const n=H(r.point(t)),o=(0,l.getCircleRadian)(n,e);return[[(0,l.getCirclePointAtRadian)(e,o),n],[(0,l.getCirclePointAtRadian)(e,(0,m.reverseRadian)(o)),n]]})).flat()}function be(e,t,n=i.delta2){const[r,o,a]=(0,c.getEllipseDerivatives)(e),s=W(t),l=e=>{const{x:t,y:n}=r(e[0]),{x:i,y:a}=o(e[0]),[[c,l],[u,p]]=s.derivatives(e[1]);return[(t-c)*i+(n-l)*a,(c-t)*u+(l-n)*p]},u=e=>{const{x:t,y:n}=r(e[0]),{x:i,y:c}=o(e[0]),{x:l,y:u}=a(e[0]),[[p,d],[f,g],[h,m]]=s.derivatives(e[1],2);return[i*i+(t-p)*l+c*c+(n-d)*u,-f*i-g*c,-i*f-c*g,f*f+(p-t)*h+g*g+(d-n)*m]};let p=[];const d=X(t);for(const e of[-Math.PI/2,Math.PI/2])for(let t=.5;t(0,i.isBetween)(e[1],0,d))).map((e=>[r(e[0]),H(s.point(e[1]))]))}function Ce(e,t,n=i.delta2){const[r,o,a]=(0,d.getQuadraticCurveDerivatives)(e),s=W(t),c=e=>{const{x:t,y:n}=r(e[0]),{x:i,y:a}=o(e[0]),[[c,l],[u,p]]=s.derivatives(e[1]);return[(t-c)*i+(n-l)*a,(c-t)*u+(l-n)*p]},l=e=>{const{x:t,y:n}=r(e[0]),{x:i,y:c}=o(e[0]),{x:l,y:u}=a(e[0]),[[p,d],[f,g],[h,m]]=s.derivatives(e[1],2);return[i*i+(t-p)*l+c*c+(n-d)*u,-f*i-g*c,-i*f-c*g,f*f+(p-t)*h+g*g+(d-n)*m]};let u=[];const p=X(t);for(const e of[.25,.75])for(let t=.5;t(0,i.isBetween)(e[0],0,1)&&(0,i.isBetween)(e[1],0,p))).map((e=>[r(e[0]),H(s.point(e[1]))]))}function Ee(e,t,n=i.delta2){const[r,o,a]=(0,d.getBezierCurveDerivatives)(e),s=W(t),c=e=>{const{x:t,y:n}=r(e[0]),{x:i,y:a}=o(e[0]),[[c,l],[u,p]]=s.derivatives(e[1]);return[(t-c)*i+(n-l)*a,(c-t)*u+(l-n)*p]},l=e=>{const{x:t,y:n}=r(e[0]),{x:i,y:c}=o(e[0]),{x:l,y:u}=a(e[0]),[[p,d],[f,g],[h,m]]=s.derivatives(e[1],2);return[i*i+(t-p)*l+c*c+(n-d)*u,-f*i-g*c,-i*f-c*g,f*f+(p-t)*h+g*g+(d-n)*m]};let u=[];const p=X(t);for(const e of[.25,.75])for(let t=.5;t(0,i.isBetween)(e[0],0,1)&&(0,i.isBetween)(e[1],0,p))).map((e=>[r(e[0]),H(s.point(e[1]))]))}function Pe(e,t,n=i.delta2){const r=W(e),o=W(t),a=e=>{const[[t,n],[i,a]]=r.derivatives(e[0]),[[s,c],[l,u]]=o.derivatives(e[1]);return[(t-s)*i+(n-c)*a,(s-t)*l+(c-n)*u]},s=e=>{const[[t,n],[i,a],[s,c]]=r.derivatives(e[0],2),[[l,u],[p,d],[f,g]]=o.derivatives(e[1],2);return[i*i+(t-l)*s+a*a+(n-u)*c,-p*i-d*a,-i*p-a*d,p*p+(l-t)*f+d*d+(u-n)*g]};let c=[];const l=X(e),u=X(t);for(let e=.5;e(0,i.isBetween)(e[0],0,l)&&(0,i.isBetween)(e[1],0,u))).map((e=>[H(r.point(e[0])),H(o.point(e[1]))]))}function we(e,t,n=i.delta2){const[r,o,a]=(0,v.getHyperbolaDerivatives)(e),s=W(t),c=e=>{const{x:t,y:n}=r(e[0]),{x:i,y:a}=o(e[0]),[[c,l],[u,p]]=s.derivatives(e[1]);return[(t-c)*i+(n-l)*a,(c-t)*u+(l-n)*p]},l=e=>{const{x:t,y:n}=r(e[0]),{x:i,y:c}=o(e[0]),{x:l,y:u}=a(e[0]),[[p,d],[f,g],[h,m]]=s.derivatives(e[1],2);return[i*i+(t-p)*l+c*c+(n-d)*u,-f*i-g*c,-i*f-c*g,f*f+(p-t)*h+g*g+(d-n)*m]};let u=[];const p=X(t);for(let e=.5;e(0,i.isBetween)(t[1],e.t1,e.t2)&&(0,i.isBetween)(t[1],0,p))).map((e=>[r(e[0]),H(s.point(e[1]))]))}},5184:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Parabola:()=>w,ParabolaSegment:()=>k,getArcParabolaSegmentIntersectionPoints:()=>$,getCircleParabolaSegmentIntersectionPoints:()=>X,getEllipseArcParabolaSegmentIntersectionPoints:()=>Y,getEllipseParabolaSegmentIntersectionPoints:()=>K,getLineParabolaSegmentIntersectionPoints:()=>q,getLineSegmentParabolaSegmentIntersectionPoints:()=>H,getParabolaBounding:()=>I,getParabolaCoordinatePointAtParam:()=>A,getParabolaCurvatureAtParam:()=>G,getParabolaDerivatives:()=>U,getParabolaFocusParameter:()=>_,getParabolaLength:()=>O,getParabolaParamAtPoint:()=>T,getParabolaParamByLength:()=>D,getParabolaPointAtParam:()=>R,getParabolaSegmentStartAndEnd:()=>B,getParabolaTangentRadianAtParam:()=>N,getParabolaXAxisRadian:()=>L,getParallelParabolaSegmentsByDistance:()=>V,getPerpendicularParamsToParabola:()=>S,getPointAndParabolaNearestPointAndDistance:()=>M,getPointSideOfParabolaSegment:()=>W,parabolaSegmentToQuadraticCurve:()=>Z,pointIsOnParabola:()=>z,pointIsOnParabolaSegment:()=>F,quadraticCurveToParabolaSegment:()=>Q,reverseParabola:()=>j});var r=n(6842),o=n(2318),i=n(2298),a=n(1475),s=n(7558),c=n(1796),l=n(2792),u=n(5773),p=n(1715),d=n(360),f=n(5569),g=Object.defineProperty,h=Object.defineProperties,m=Object.getOwnPropertyDescriptors,y=Object.getOwnPropertySymbols,v=Object.prototype.hasOwnProperty,x=Object.prototype.propertyIsEnumerable,b=Math.pow,C=(e,t,n)=>t in e?g(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,E=(e,t)=>{for(var n in t||(t={}))v.call(t,n)&&C(e,n,t[n]);if(y)for(var n of y(t))x.call(t,n)&&C(e,n,t[n]);return e},P=(e,t)=>h(e,m(t));const w=(0,f.and)(u.Position,{p:f.number,angle:f.number}),k=(0,f.and)(w,{t1:f.number,t2:f.number});function _(e){return 1/4/e}function S({x:e,y:t},{p:n,angle:r,x:o,y:i},s){const c=L({angle:r}),l=Math.sin(c),u=Math.cos(c),p=o-e,d=i-t;return(0,a.calculateEquation3)(8*n*n,0,4*n*(d*u-p*l)+1,p*u+d*l,s)}function R(e,t){return(0,d.transformPointFromCoordinate2D)(A(e,t),e,L(e))}function T({angle:e,x:t,y:n},r){const o=L({angle:e}),i=Math.sin(o);return Math.cos(o)*(r.x-t)+i*(r.y-n)}function A(e,t){return{x:t,y:2*e.p*b(t,2)}}function L(e){return(0,p.angleToRadian)(e.angle-90)}function M(e,t,n=!1){let r=S(e,t);n||(r=r.filter((e=>(0,l.isBetween)(e,t.t1,t.t2))),r.push(t.t1,t.t2));const o=r.map((e=>({u:e,p:R(t,e)}))).map((t=>({param:t.u,point:t.p,distance:(0,u.getTwoPointsDistance)(e,t.p)})));return(0,l.minimumBy)(o,(e=>e.distance))}function I(e){const{p:t,angle:n}=e,o=L({angle:n}),i=Math.sin(o),a=Math.cos(o),s=[R(e,e.t1),R(e,e.t2)];if(!(0,l.isZero)(i)){const n=a/4/i/t;(0,l.isBetween)(n,e.t1,e.t2)&&s.push(R(e,n))}if(!(0,l.isZero)(a)){const n=-i/4/a/t;(0,l.isBetween)(n,e.t1,e.t2)&&s.push(R(e,n))}return(0,r.getPointsBoundingUnsafe)(s)}function O(e,t){const{p:n,t1:r,t2:o}=e,i=16*n*n;return(0,s.rombergIntegral)(r,o,(e=>Math.sqrt(i*e*e+1)),t)}function D(e,t,n=l.delta2){const r=16*e.p*e.p;return(0,a.newtonIterate)((0,l.getTwoNumberCenter)(e.t1,e.t2),(n=>O(P(E({},e),{t2:n}))-t),(e=>Math.sqrt(r*e*e+1)),n)}function B(e){return{start:R(e,e.t1),end:R(e,e.t2)}}function z(e,{angle:t,p:n,x:r,y:o}){const i=L({angle:t}),s=Math.sin(i),c=Math.cos(i);return(0,a.calculateEquation2)(-2*s*n,c,r-e.x).filter((t=>(0,l.isSameNumber)(2*c*n*t*t+s*t+o,e.y,l.delta3))).length>0}function F(e,t,n=l.NOT_EXTENDED){if(n.head&&n.body&&n.tail)return!0;if(!n.head&&!n.body&&!n.tail)return!1;const r=T(t,e);return(0,l.isBetween)(r,t.t1,t.t2,n)}function N({angle:e,p:t},n){const r=L({angle:e}),o=Math.sin(r),i=Math.cos(r);return Math.atan2(4*i*t*n+o,i-4*o*t*n)}function U({angle:e,p:t,x:n,y:r}){const o=L({angle:e}),i=Math.sin(o),a=Math.cos(o),s=-2*i*t,c=2*a*t;return[e=>({x:n+a*e+s*b(e,2),y:r+i*e+c*b(e,2)}),e=>({x:a+2*s*e,y:i+2*c*e}),()=>({x:2*s,y:2*c})]}function G(e,t){const n=U(e),{x:r,y:o}=n[1](t),{x:i,y:a}=n[2](t);return(r*a-o*i)/b(b(r,2)+b(o,2),1.5)}function j(e){return P(E({},e),{t1:e.t2,t2:e.t1})}function V(e,t){if((0,l.isZero)(t))return[e,e];e.t1>e.t2&&(t=-t);const n=(0,u.getPointByLengthAndRadian)(e,t,(0,p.angleToRadian)(e.angle)),r=(0,u.getPointByLengthAndRadian)(e,-t,(0,p.angleToRadian)(e.angle));return[P(E({},e),{x:n.x,y:n.y}),P(E({},e),{x:r.x,y:r.y})]}function W(e,t){const n=M(e,t,!0),r=N(t,n.param),o=(0,c.pointAndDirectionToGeneralFormLine)(n.point,r);return(0,c.getPointSideOfLine)(e,o)*(t.t1>t.t2?-1:1)}function H(e,t,n,r=l.NOT_EXTENDED,o=l.NOT_EXTENDED){return q(e,t,n,o).filter((n=>(0,c.pointIsOnLineSegment)(n,e,t,r)))}function q({x:e,y:t},{x:n,y:r},{angle:o,x:i,y:s,p:c,t1:u,t2:p},d=l.NOT_EXTENDED){const f=L({angle:o}),g=Math.sin(f),h=Math.cos(f),m=n-e,y=r-t,v=i-e,x=s-t;let C=(0,a.calculateEquation2)(-2*y*g*c+-2*m*h*c,-m*g+y*h,y*v+-m*x);return C=C.filter((e=>(0,l.isBetween)(e,u,p,d))),C.map((e=>({x:i+h*e-2*g*c*b(e,2),y:s+g*e+2*h*c*b(e,2)})))}function $(e,t,n=l.NOT_EXTENDED,r=l.NOT_EXTENDED){return X(e,t,r).filter((t=>(0,o.pointIsOnArc)(t,e,n)))}function X({x:e,y:t,r:n},{angle:r,x:o,y:i,p:s,t1:c,t2:u},p=l.NOT_EXTENDED){const d=L({angle:r}),f=Math.sin(d),g=Math.cos(d),h=o-e,m=i-t;let y=(0,a.calculateEquation4)(4*s*s,0,1-4*(f*h-g*m)*s,2*(g*h+f*m),h*h+m*m-n*n);return y=y.filter((e=>(0,l.isBetween)(e,c,u,p))),y.map((e=>({x:o+g*e-2*f*s*b(e,2),y:i+f*e+2*g*s*b(e,2)})))}function Y(e,t,n=l.NOT_EXTENDED,r=l.NOT_EXTENDED){return K(e,t,r).filter((t=>(0,i.pointIsOnEllipseArc)(t,e,n)))}function K({rx:e,ry:t,cx:n,cy:r,angle:o},{angle:i,x:s,y:c,p:u,t1:d,t2:f},g=l.NOT_EXTENDED){const h=L({angle:i}),m=Math.sin(h),y=Math.cos(h),v=(0,p.angleToRadian)(o),x=Math.sin(v),C=Math.cos(v),E=1/e/e,P=1/t/t,w=s-n,k=c-r,_=-C*m+x*y,S=x*m+C*y,R=C*w+x*k,T=-x*w+C*k;let A=(0,a.calculateEquation4)(4*(E*_*_+P*S*S)*u*u,4*(E-P)*_*S*u,4*(E*_*R+P*S*T)*u+P*_*_+E*S*S,2*(E*S*R-P*_*T),E*R*R+P*T*T-1);return A=A.filter((e=>(0,l.isBetween)(e,d,f,g))),A.map((e=>({x:s+y*e-2*m*u*b(e,2),y:c+m*e+2*y*u*b(e,2)})))}function Z({angle:e,x:t,y:n,p:r,t1:o,t2:i}){const a=L({angle:e}),s=Math.sin(a),c=Math.cos(a),l=i-o,u=t+c*o-2*s*r*o*o,p=u+(l*c-4*l*s*r*o)/2,d=n+s*o+2*c*r*o*o,f=d+(l*s+4*l*c*r*o)/2;return{from:{x:u,y:d},cp:{x:p,y:f},to:{x:2*p-2*l*l*s*r-u,y:2*f+2*l*l*c*r-d}}}function Q({from:{x:e,y:t},cp:{x:n,y:r},to:{x:o,y:i}}){const a=e+o-2*n,s=t+i-2*r,c=Math.atan2(-a,s),u=Math.sin(c),d=Math.cos(c),f=(0,p.radianToAngle)(c)+90,g=2*(n-e),h=2*(r-t),m=g*d+h*u,y=((0,l.isZero)(u)?s/2/d:-a/2/u)/m/m,v=(0,l.isZero)(u)?(h-m*u)/(4*m*d*y):(m*d-g)/(4*m*u*y);return{angle:f,x:e-d*v+2*u*y*v*v,y:t-u*v-2*d*y*v*v,p:y,t1:v,t2:m+v}}},1785:(e,t,n)=>{"use strict";n.r(t),n.d(t,{getLinesOffsetDirection:()=>G,getParallelArcsByDistance:()=>R,getParallelBezierCurvesByDistance:()=>M,getParallelCirclesByDistance:()=>S,getParallelEllipseArcsByDistance:()=>A,getParallelEllipsesByDistance:()=>T,getParallelGeometryLinesByDistance:()=>V,getParallelGeometryLinesByDistanceDirectionIndex:()=>H,getParallelGeometryLinesByDistancePoint:()=>W,getParallelLineSegmentsPoints:()=>Y,getParallelPolylineByDistance:()=>$,getParallelPolylinesByDistance:()=>X,getParallelQuadraticCurvesByDistance:()=>L,getPointSideOfArc:()=>O,getPointSideOfBezierCurve:()=>F,getPointSideOfCircle:()=>I,getPointSideOfEllipse:()=>D,getPointSideOfEllipseArc:()=>B,getPointSideOfGeometryLine:()=>N,getPointSideOfQuadraticCurve:()=>z,getRadianSideOfRadian:()=>U,pointSideToIndex:()=>j});var r=n(5629),o=n(5717),i=n(2792),a=n(5773),s=n(1715),c=n(8831),l=n(1796),u=n(2298),p=n(491),d=n(8230),f=n(8392),g=n(5689),h=n(3793),m=n(2986),y=Object.defineProperty,v=Object.defineProperties,x=Object.getOwnPropertyDescriptors,b=Object.getOwnPropertySymbols,C=Object.prototype.hasOwnProperty,E=Object.prototype.propertyIsEnumerable,P=Math.pow,w=(e,t,n)=>t in e?y(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,k=(e,t)=>{for(var n in t||(t={}))C.call(t,n)&&w(e,n,t[n]);if(b)for(var n of b(t))E.call(t,n)&&w(e,n,t[n]);return e},_=(e,t)=>v(e,x(t));function S(e,t){return(0,i.isZero)(t)?[e,e]:[_(k({},e),{r:e.r-t}),_(k({},e),{r:e.r+t})]}function R(e,t){const n=S(e,t);return e.counterclockwise?[n[1],n[0]]:n}function T(e,t){return(0,i.isZero)(t)?[e,e]:[_(k({},e),{rx:e.rx-t,ry:e.ry-t}),_(k({},e),{rx:e.rx+t,ry:e.ry+t})]}function A(e,t){const n=T(e,t);return e.counterclockwise?[n[1],n[0]]:n}function L(e,t){if((0,i.isZero)(t))return[e,e];const[n,r]=X([e.from,e.cp,e.to],t,!1);return[_(k({},e),{from:n[0],cp:n[1],to:n[2]}),_(k({},e),{from:r[0],cp:r[1],to:r[2]})]}function M(e,t){if((0,i.isZero)(t))return[e,e];const[n,r]=X([e.from,e.cp1,e.cp2,e.to],t,!1);return[_(k({},e),{from:n[0],cp1:n[1],cp2:n[2],to:n[3]}),_(k({},e),{from:r[0],cp1:r[1],cp2:r[2],to:r[3]})]}function I(e,t){const n=(0,a.getTwoPointsDistance)(e,t);return(0,i.isSameNumber)(n,t.r)?0:n>t.r?1:-1}function O(e,t){return I(e,t)*(t.counterclockwise?-1:1)}function D(e,{rx:t,ry:n,cx:r,cy:o,angle:a}){const c=(0,s.angleToRadian)(a),l=Math.sin(c),u=Math.cos(c),p=P(u*(e.x-r)+l*(e.y-o),2)/t/t+P(-l*(e.x-r)+u*(e.y-o),2)/n/n;return(0,i.isSameNumber)(p,1)?0:p>1?1:-1}function B(e,t){return D(e,t)*(t.counterclockwise?-1:1)}function z(e,t){const n=(0,f.getPointAndQuadraticCurveNearestPointAndDistance)(e,t,!0),r=(0,g.getQuadraticCurveTangentRadianAtPercent)(t,n.percent),o=(0,l.pointAndDirectionToGeneralFormLine)(n.point,r);return(0,l.getPointSideOfLine)(e,o)}function F(e,t){const n=(0,f.getPointAndBezierCurveNearestPointAndDistance)(e,t,!0),r=(0,g.getBezierCurveTangentRadianAtPercent)(t,n.percent),o=(0,l.pointAndDirectionToGeneralFormLine)(n.point,r);return(0,l.getPointSideOfLine)(e,o)}function N(e,t){if(Array.isArray(t)){const n=(0,l.twoPointLineToGeneralFormLine)(...t);return n?(0,l.getPointSideOfLine)(e,n):0}return"arc"===t.type?O(e,t.curve):"ellipse arc"===t.type?B(e,t.curve):"quadratic curve"===t.type?z(e,t.curve):"bezier curve"===t.type?F(e,t.curve):"ray"===t.type?(0,l.getPointSideOfLine)(e,(0,l.pointAndDirectionToGeneralFormLine)(t.line,(0,s.angleToRadian)(t.line.angle))):"hyperbola curve"===t.type?(0,m.getPointSideOfHyperbolaSegment)(e,t.curve):(0,d.getPointSideOfNurbsCurve)(e,t.curve)}function U(e,t){let n=t-e;return n=(0,c.normalizeRadian)(n),(0,i.isZero)(n)?0:n>0?-1:1}function G(e,t){return j(N(e,(0,o.getNearestGeometryLines)(e,t)[0]))}function j(e){return e>0?1:0}function V(e,t){if(Array.isArray(e))return(0,l.getParallelLineSegmentsByDistance)(e,t);if("arc"===e.type){const n=R(e.curve,t);return[{type:"arc",curve:n[0]},{type:"arc",curve:n[1]}]}if("ellipse arc"===e.type){const n=A(e.curve,t);return[{type:"ellipse arc",curve:n[0]},{type:"ellipse arc",curve:n[1]}]}if("quadratic curve"===e.type){const n=L(e.curve,t);return[{type:"quadratic curve",curve:n[0]},{type:"quadratic curve",curve:n[1]}]}if("bezier curve"===e.type){const n=M(e.curve,t);return[{type:"bezier curve",curve:n[0]},{type:"bezier curve",curve:n[1]}]}if("ray"===e.type){const n=(0,l.getParallelRaysByDistance)(e.line,t);return[{type:"ray",line:n[0]},{type:"ray",line:n[1]}]}if("hyperbola curve"===e.type){const n=(0,m.getParallelHyperbolaSegmentsByDistance)(e.curve,t);return[{type:"hyperbola curve",curve:n[0]},{type:"hyperbola curve",curve:n[1]}]}const n=(0,d.getParallelNurbsCurvesByDistance)(e.curve,t);return[{type:"nurbs curve",curve:n[0]},{type:"nurbs curve",curve:n[1]}]}function W(e,t,n,r){return n||(n=Math.min(...t.map((t=>(0,f.getPointAndGeometryLineMinimumDistance)(e,t))))),H(t,n,G(e,t),r)}function H(e,t,n,a=h.defaultLineJoin){if((0,i.isZero)(t))return e;const l=(0,o.isGeometryLinesClosed)(e)&&e.length>1,p=e.map((e=>{var r;return null==(r=V(e,t))?void 0:r[n]}));if(1===p.length){const e=p[0];return e?[e]:[]}const f=[];let g;for(let n=0;nvoid 0!==e),{closed:l,reverse:!0}),y=void 0!==h?p[h]:void 0,v=(0,i.findFrom)(p,n,(e=>void 0!==e),{closed:l});let x,b;if(y?x=v?q(y,v):(0,o.getGeometryLineStartAndEnd)(y).end:v&&(x=(0,o.getGeometryLineStartAndEnd)(v).start),y&&v&&("miter"===a||!x||(0,o.pointIsOnGeometryLine)(x,y)&&(0,o.pointIsOnGeometryLine)(x,v)||(x=void 0),!x)){if(!Array.isArray(v)&&"arc"===v.type&&v.curve.r<=0){e=e.toSpliced(n,1),p.splice(n,1),n--;continue}if("miter"===a&&Array.isArray(y)&&Array.isArray(v))x=v[0];else if("bevel"===a){x=(0,o.getGeometryLineStartAndEnd)(y).end;const e=(0,o.getGeometryLineStartAndEnd)(v).start;x&&e&&(b={current:e,line:[x,e]})}else if(void 0!==h){const n=e[h],r=(0,o.getGeometryLineStartAndEnd)(n).end;x=(0,o.getGeometryLineStartAndEnd)(y).end;const i=(0,o.getGeometryLineStartAndEnd)(v).start;if(r&&x&&i){const e={x:r.x,y:r.y,r:t,startAngle:(0,s.radianToAngle)((0,s.getTwoPointsRadian)(x,r)),endAngle:(0,s.radianToAngle)((0,s.getTwoPointsRadian)(i,r))};b={current:i,line:{type:"arc",curve:_(k({},e),{counterclockwise:!(0,c.twoRadiansSameDirection)((0,o.getGeometryLineTangentRadianAtParam)(0,{type:"arc",curve:e}),(0,o.getGeometryLineTangentRadianAtParam)(1,n))||void 0})}}}}}if(x&&g&&y){const e=y;Array.isArray(e)?f.push([g,x]):"arc"===e.type?f.push({type:"arc",curve:_(k({},e.curve),{startAngle:(0,s.radianToAngle)((0,s.getTwoPointsRadian)(g,e.curve)),endAngle:(0,s.radianToAngle)((0,s.getTwoPointsRadian)(x,e.curve))})}):"ellipse arc"===e.type?f.push({type:"ellipse arc",curve:_(k({},e.curve),{startAngle:(0,u.getEllipseAngle)(g,e.curve),endAngle:(0,u.getEllipseAngle)(x,e.curve)})}):"quadratic curve"===e.type?f.push({type:"quadratic curve",curve:(0,r.getPartOfQuadraticCurve)(e.curve,(0,r.getQuadraticCurvePercentAtPoint)(e.curve,g),(0,r.getQuadraticCurvePercentAtPoint)(e.curve,x))}):"bezier curve"===e.type?f.push({type:"bezier curve",curve:(0,r.getPartOfBezierCurve)(e.curve,(0,r.getBezierCurvePercentAtPoint)(e.curve,g),(0,r.getBezierCurvePercentAtPoint)(e.curve,x))}):"hyperbola curve"===e.type?f.push({type:"hyperbola curve",curve:_(k({},e.curve),{t1:(0,m.getHyperbolaParamAtPoint)(e.curve,g),t2:(0,m.getHyperbolaParamAtPoint)(e.curve,x)})}):"nurbs curve"===e.type&&f.push({type:"nurbs curve",curve:(0,d.getPartOfNurbsCurve)(e.curve,(0,d.getNurbsCurveParamAtPoint)(e.curve,g),(0,d.getNurbsCurveParamAtPoint)(e.curve,x))})}g=x,b&&(f.push(b.line),g=b.current)}return f}function q(e,t){var n;const r=(0,p.getTwoGeometryLinesIntersectionPoint)(e,t,!0);if(r.length>1){const t=r.map((t=>({point:t,param:(0,o.getGeometryLineParamAtPoint)(t,e)}))).filter((e=>e.param>=0));return t.length>1?(0,i.minimumBy)(t,(e=>e.param)).point:null==(n=t[0])?void 0:n.point}return r[0]}function $(e,t,n){const r=(0,a.isSamePoint)(e[0][0],e[e.length-1][1])&&e.length>1;return Y(e.map((e=>{var r;return null==(r=(0,l.getParallelLineSegmentsByDistance)(e,t))?void 0:r[n]})),r)}function X(e,t,n){const r=Array.from((0,l.iteratePolylineLines)(e)).map((e=>(0,l.getParallelLineSegmentsByDistance)(e,t)));return[Y(r.map((e=>null==e?void 0:e[0])),n),Y(r.map((e=>null==e?void 0:e[1])),n)]}function Y(e,t){const n=[];for(let r=0;rvoid 0!==e),{closed:t,reverse:!0}),a=(0,i.findFrom)(e,r,(e=>void 0!==e),{closed:t});let s;o?s=a?(0,p.getTwoLinesIntersectionPoint)(...o,...a):o[1]:a&&(s=a[0]),s&&n.push(s)}return n}},4461:(e,t,n)=>{"use strict";n.r(t),n.d(t,{applyImmutablePatches:()=>i});var r=n(8662),o=n(9758);function i(e,t){const n=[],i=[];return t.forEach(((t,a)=>{const s=t.value;e=(0,r.produce)(e,(r=>{const c=t.path.slice(0,t.path.length-1),l=t.path[t.path.length-1],u=(0,o.getByPath)(r,c);if(Array.isArray(u))if("add"===t.op){const e=[...c,u.length];n.push({op:"replace",path:e,value:s}),i.unshift({op:"replace",path:e,value:void 0}),u.push(s)}else{if("replace"!==t.op||"number"!=typeof l)throw console.info(t),new Error(`Operation not supported for patch at index ${a}`);n.push(t),i.unshift({op:"replace",path:t.path,value:(0,o.getByPath)(e,t.path)}),l===u.length-1&&null==s?u.pop():u[l]=s}else{if("object"!=typeof u||null===u)throw console.info(t),new Error(`Invalid path for patch at index ${a}`);{const r=u;n.push(t),i.unshift({op:"replace",path:t.path,value:(0,o.getByPath)(e,t.path)}),void 0===s?delete r[l]:r[l]=s}}}))})),{patches:n,reversePatches:i,result:e}}},1401:(e,t,n)=>{"use strict";n.r(t),n.d(t,{PathCommand:()=>m,geometryLineToPathCommands:()=>C,getPathCommandEndPoint:()=>y,getPathCommandsPoints:()=>x,pathCommandPointsToPath:()=>v,pathCommandsToGeometryLines:()=>b});var r=n(8831),o=n(5717),i=n(2318),a=n(2298),s=n(8258),c=n(491),l=n(6022),u=n(1796),p=n(2792),d=n(8392),f=n(5773),g=n(1715),h=n(5569);const m=(e,t)=>(0,l.isRecord)(e)?"move"===e.type?(0,h.validate)(e,{type:"move",to:f.Position},t):"line"===e.type?(0,h.validate)(e,{type:"line",to:f.Position},t):"arc"===e.type?(0,h.validate)(e,{type:"arc",from:f.Position,to:f.Position,radius:h.number},t):"ellipseArc"===e.type?(0,h.validate)(e,{type:"ellipseArc",rx:h.number,ry:h.number,angle:h.number,largeArc:h.boolean,sweep:h.boolean,to:f.Position},t):"bezierCurve"===e.type?(0,h.validate)(e,{type:"bezierCurve",cp1:f.Position,cp2:f.Position,to:f.Position},t):"quadraticCurve"===e.type?(0,h.validate)(e,{type:"quadraticCurve",cp:f.Position,to:f.Position},t):"close"===e.type?(0,h.validate)(e,{type:"close"},t):{path:[...t,"type"],expect:"or",args:["move","line","arc","ellipseArc","bezierCurve","quadraticCurve","close"]}:{path:t,expect:"object"};function y(e,t){if(t>=0){const n=e[t];if("close"!==n.type){if("arc"!==n.type)return n.to;const r=y(e,t-1);if(r){const e=n.from,t=n.to,o=(0,u.twoPointLineToGeneralFormLine)(r,e),i=(0,u.twoPointLineToGeneralFormLine)(e,t),a=o?(0,u.getPointSideOfLine)(t,o):0;if((0,p.isZero)(a)||!o||!i)return n.to;const s=a<0?0:1,l=(0,c.getTwoGeneralFormLinesIntersectionPoint)((0,u.getParallelLinesByDistance)(o,n.radius)[s],(0,u.getParallelLinesByDistance)(i,n.radius)[s]);if(l){const e=(0,d.getPerpendicularPoint)(l,i),t=(0,g.getTwoPointsRadian)(e,l);return{x:l.x+n.radius*Math.cos(t),y:l.y+n.radius*Math.sin(t)}}}}}}function v(e){const t=[];let n;for(const r of e)n?(0,u.pointInPolygon)(r[0],n.polygon)?n.holes.push(r):(n&&t.push([n.polygon,...n.holes]),n={polygon:r,holes:[]}):n={polygon:r,holes:[]};return n&&t.push([n.polygon,...n.holes]),t}function x(e){const t=[],n=b(e);for(const e of n)t.push((0,s.getGeometryLinesPoints)(e));return t}function b(e){const t=[];let n,r,i=[];for(const o of e)if("move"===o.type)i.length>0&&(i.length>1&&t.push(i),i=[],n=void 0),r=o.to,n||(n=o.to);else if("line"===o.type)r&&i.push([r,o.to]),r=o.to;else if("arc"===o.type){if(r){const e=o.from,t=o.to,n=(0,u.twoPointLineToGeneralFormLine)(r,e),a=(0,u.twoPointLineToGeneralFormLine)(e,t),s=n?(0,u.getPointSideOfLine)(t,n):0;if(!(0,p.isZero)(s)&&n&&a){const e=s<0?0:1,t=(0,c.getTwoGeneralFormLinesIntersectionPoint)((0,u.getParallelLinesByDistance)(n,o.radius)[e],(0,u.getParallelLinesByDistance)(a,o.radius)[e]);if(t){const e=(0,d.getPerpendicularPoint)(t,n),c=(0,d.getPerpendicularPoint)(t,a);r&&((0,f.isSamePoint)(r,e)||i.push([r,{x:e.x,y:e.y}]),r=c);const l=(0,g.radianToAngle)((0,g.getTwoPointsRadian)(e,t)),u=(0,g.radianToAngle)((0,g.getTwoPointsRadian)(c,t));i.push({type:"arc",curve:{x:t.x,y:t.y,startAngle:l,endAngle:u,r:o.radius,counterclockwise:s>0}})}}else r&&(i.push([r,t]),r=t)}}else if("ellipseArc"===o.type){if(r){const e=(0,a.getEllipseArcByStartEnd)(r,o.rx,o.ry,o.angle,o.largeArc,o.sweep,o.to);e&&i.push({type:"ellipse arc",curve:e})}r=o.to}else"bezierCurve"===o.type?(r&&i.push({type:"bezier curve",curve:{from:r,cp1:o.cp1,cp2:o.cp2,to:o.to}}),r=o.to):"quadraticCurve"===o.type?(r&&i.push({type:"quadratic curve",curve:{from:r,cp:o.cp,to:o.to}}),r=o.to):"close"===o.type&&i.length>0&&(i.length>1&&(n&&r&&!(0,f.isSamePoint)(n,r)&&i.push([r,n]),t.push(i)),i=[],n=void 0);return i.length>0&&t.push(i),t.map((e=>(0,o.optimizeGeometryLines)(e)))}function C(e){const t=[];let n,a;for(let s=0;s{"use strict";n.r(t),n.d(t,{getPerpendicularDistance:()=>S,getPerpendicularDistanceToLine3D:()=>_,getPerpendicularLine:()=>v,getPerpendicularLineToGeometryLine:()=>x,getPerpendicularParamToLine:()=>w,getPerpendicularParamToLine2D:()=>P,getPerpendicularPercentToBezierCurve:()=>I,getPerpendicularPercentToQuadraticCurve:()=>L,getPerpendicularPoint:()=>E,getPerpendicularPointRadiansToEllipse:()=>T,getPerpendicularPointToBezierCurve:()=>O,getPerpendicularPointToCircle:()=>R,getPerpendicularPointToEllipseArc:()=>A,getPerpendicularPointToGeometryLine:()=>b,getPerpendicularPointToGeometryLines:()=>C,getPerpendicularPointToLine3D:()=>k,getPerpendicularPointToQuadraticCurve:()=>M,getPointAndArcMinimumDistance:()=>$,getPointAndArcNearestPointAndDistance:()=>N,getPointAndBezierCurveNearestPointAndDistance:()=>j,getPointAndEllipseArcNearestPointAndDistance:()=>U,getPointAndGeometryLineMinimumDistance:()=>V,getPointAndGeometryLineNearestPointAndDistance:()=>F,getPointAndLineSegmentMinimumDistance:()=>W,getPointAndLineSegmentNearestPointAndDistance:()=>D,getPointAndPointsNearestPointAndDistance:()=>B,getPointAndPolygonMinimumDistance:()=>q,getPointAndQuadraticCurveNearestPointAndDistance:()=>G,getPointAndRayNearestPointAndDistance:()=>z,getPointAndRegionMinimumDistance:()=>H});var r=n(5629),o=n(1475),i=n(2792),a=n(5773),s=n(7486),c=n(1715),l=n(8831),u=n(1796),p=n(2298),d=n(2318),f=n(5717),g=n(8230),h=n(5147),m=n(2986),y=Math.pow;function v(e,t){return{a:-t.b,b:t.a,c:e.x*t.b-t.a*e.y}}function x(e,t){const n=b(e,t);if(n)return(0,u.twoPointLineToGeneralFormLine)(e,n)}function b(e,t){if(Array.isArray(t)){const n=(0,u.twoPointLineToGeneralFormLine)(...t);if(!n)return;return E(e,n)}let n;if("arc"===t.type)n=R(e,t.curve).point;else if("ellipse arc"===t.type){const r=T(e,t.curve)[0];void 0!==r&&(n=(0,p.getEllipsePointAtRadian)(t.curve,r))}else if("quadratic curve"===t.type){const o=L(e,t.curve)[0];void 0!==o&&(n=(0,r.getQuadraticCurvePointAtPercent)(t.curve.from,t.curve.cp,t.curve.to,o))}else if("bezier curve"===t.type){const o=I(e,t.curve)[0];void 0!==o&&(n=(0,r.getBezierCurvePointAtPercent)(t.curve.from,t.curve.cp1,t.curve.cp2,t.curve.to,o))}else if("hyperbola curve"===t.type){const r=(0,m.getPerpendicularParamsToHyperbola)(e,t.curve)[0];void 0!==r&&(n=(0,m.getHyperbolaPointAtParam)(t.curve,r))}else if("nurbs curve"===t.type){const r=(0,g.getPerpendicularParamToNurbsCurve)(e,t.curve);void 0!==r&&(n=(0,g.getNurbsCurvePointAtParam)(t.curve,r))}else"ray"===t.type&&(n=E(e,(0,u.pointAndDirectionToGeneralFormLine)(t.line,(0,c.angleToRadian)(t.line.angle))));return n}function C(e,t){const n=[],r=[];for(const o of t){const t=b(e,o);t&&((0,f.pointIsOnGeometryLine)(t,o)?n.push({point:t,distance:(0,a.getTwoPointsDistance)(t,e)}):r.push({point:t,distance:(0,a.getTwoPointsDistance)(t,e),line:o}))}return n.length>0?(0,i.minimumBy)(n,(e=>e.distance)):(0,i.minimumBy)(r,(e=>e.distance))}function E(e,{a:t,b:n,c:r}){const o=y(t,2),i=y(n,2),a=o+i,s=-t*n;return{x:(i*e.x+s*e.y-t*r)/a,y:(s*e.x+o*e.y-n*r)/a}}function P(e,t,n){return Math.sin(n)*(e.y-t.y)+Math.cos(n)*(e.x-t.x)}function w(e,t,n){return h.v3.dot(n,h.v3.substract(e,t))/h.v3.lengthSquare(n)}function k(e,t,n){const r=w(e,t,n);return(0,a.getPointByParamAndDirection3D)(t,r,n)}function _(e,t,n){const r=k(e,t,n);return h.v3.length(h.v3.substract(r,e))}function S({x:e,y:t},{a:n,b:r,c:o}){return Math.abs(n*e+r*t+o)/Math.sqrt(y(n,2)+y(r,2))}function R(e,t,n=e){let r=(0,c.getTwoPointsRadian)(e,t);if(e!==n){const o=t.x-e.x,i=t.y-e.y,a={a:o,b:i,c:-i*t.y-o*t.x};Math.sign((0,u.getPointSideOfLine)(e,a))!==Math.sign((0,u.getPointSideOfLine)(n,a))&&(r+=Math.PI)}const o=(0,d.getCirclePointAtRadian)(t,r);return{point:o,distance:(0,a.getTwoPointsDistance)(e,o),radian:r}}function T({x:e,y:t},n,r=i.delta2){const{rx:a,ry:s,angle:u,cx:p,cy:d}=n,f=(0,c.angleToRadian)(u),g=Math.sin(f),h=Math.cos(f),m=p-e,y=d-t,v=s*s-a*a,x=(y*h-m*g)*s,b=-(y*g+m*h)*a,C=(0,o.calculateEquation4)(v*v,2*v*x,-v*v+x*x+b*b,-2*v*x,-x*x,r),E=[];for(const e of C)if((0,i.isBetween)(e,-1,1)){const t=Math.asin(e);for(const n of[t,(0,l.normalizeRadian)((0,i.mirrorNumber)(t,Math.PI/2))])(0,i.isZero)(v*e*Math.cos(n)+x*Math.cos(n)+b*e)&&E.push(n)}return(0,i.deduplicate)(E,i.isSameNumber)}function A(e,t,n=i.delta2){return T(e,t,n).filter((e=>(0,l.angleInRange)((0,c.radianToAngle)(e),t))).map((e=>(0,p.getEllipsePointAtRadian)(t,e)))}function L({x:e,y:t},{from:{x:n,y:r},cp:{x:a,y:s},to:{x:c,y:l}},u=i.delta2){const p=a-n,d=c-a-p,f=s-r,g=l-s-f,h=n-e,m=r-t;return(0,o.calculateEquation3)(d*d+g*g,3*(p*d+f*g),2*p*p+h*d+2*f*f+m*g,h*p+m*f,u)}function M(e,t,n=i.delta2){return L(e,t,n).filter((e=>(0,i.isValidPercent)(e))).map((e=>(0,r.getQuadraticCurvePointAtPercent)(t.from,t.cp,t.to,e)))}function I({x:e,y:t},{from:{x:n,y:r},cp1:{x:a,y:s},cp2:{x:c,y:l},to:{x:u,y:p}},d=i.delta2){const f=3*a-n+-3*c+u,g=3*(n-2*a+c),h=3*(a-n),m=3*s-r+-3*l+p,y=3*(r-2*s+l),v=3*(s-r),x=r-t,b=n-e;return(0,o.calculateEquation5)([3*(m*m+f*f),5*(m*y+f*g),2*(g*g+2*f*h+y*y+2*m*v),3*(g*h+y*v+m*x+f*b),h*h+v*v+2*y*x+2*g*b,v*x+h*b],d)}function O(e,t,n=i.delta2){return I(e,t,n).filter((e=>(0,i.isValidPercent)(e))).map((e=>(0,r.getBezierCurvePointAtPercent)(t.from,t.cp1,t.cp2,t.to,e)))}function D(e,t,n,r=!1){const o=(0,u.twoPointLineToGeneralFormLine)(t,n),i=o?E(e,o):t;return r||(0,u.pointIsOnLineSegment)(i,t,n)?{point:i,distance:(0,a.getTwoPointsDistance)(e,i)}:B(e,[t,n])}function B(e,t){return(0,i.minimumBy)(t.map((t=>({point:t,distance:(0,a.getTwoPointsDistance)(e,t)}))),(e=>e.distance))}function z(e,t,n=!1){const r=E(e,(0,u.pointAndDirectionToGeneralFormLine)(t,(0,c.angleToRadian)(t.angle)));return n||t.bidirectional||(0,u.pointIsOnRay)(r,t)?{point:r,distance:(0,a.getTwoPointsDistance)(e,r)}:{point:t,distance:(0,a.getTwoPointsDistance)(e,t)}}function F(e,t){return Array.isArray(t)?D(e,...t):"arc"===t.type?N(e,t.curve):"ellipse arc"===t.type?U(e,t.curve):"quadratic curve"===t.type?G(e,t.curve):"bezier curve"===t.type?j(e,t.curve):"hyperbola curve"===t.type?(0,m.getPointAndHyperbolaNearestPointAndDistance)(e,t.curve):"ray"===t.type?z(e,t.line):(0,g.getPointAndNurbsCurveNearestPointAndDistance)(e,t.curve)}function N(e,t,n=!1){const{point:r,distance:o,radian:i}=R(e,t);if(n||(0,l.angleInRange)((0,c.radianToAngle)(i),t))return{point:r,distance:o};const{start:a,end:s}=(0,d.getArcStartAndEnd)(t);return B(e,[a,s])}function U(e,t,n=!1){let r=T(e,t);n||(r=r.filter((e=>(0,l.angleInRange)((0,c.radianToAngle)(e),t))));const o=r.map((e=>(0,p.getEllipsePointAtRadian)(t,e))),{start:i,end:a}=(0,p.getEllipseArcStartAndEnd)(t);return o.push(i,a),B(e,o)}function G(e,t,n=!1){let o=L(e,t);n||(o=o.filter((e=>(0,i.isValidPercent)(e))));const s=o.map((e=>({u:e,p:(0,r.getQuadraticCurvePointAtPercent)(t.from,t.cp,t.to,e)})));s.push({u:0,p:t.from},{u:1,p:t.to});const c=s.map((t=>({percent:t.u,point:t.p,distance:(0,a.getTwoPointsDistance)(e,t.p)})));return(0,i.minimumBy)(c,(e=>e.distance))}function j(e,t,n=!1){let o=I(e,t);n||(o=o.filter((e=>(0,i.isValidPercent)(e))));const s=o.map((e=>({u:e,p:(0,r.getBezierCurvePointAtPercent)(t.from,t.cp1,t.cp2,t.to,e)})));s.push({u:0,p:t.from},{u:1,p:t.to});const c=s.map((t=>({percent:t.u,point:t.p,distance:(0,a.getTwoPointsDistance)(e,t.p)})));return(0,i.minimumBy)(c,(e=>e.distance))}function V(e,t,n=!1){return Array.isArray(t)?W(e,...t,n):"arc"===t.type?$(e,t.curve,n):"ellipse arc"===t.type?U(e,t.curve,n).distance:"quadratic curve"===t.type?G(e,t.curve,n).distance:"bezier curve"===t.type?j(e,t.curve,n).distance:"hyperbola curve"===t.type?(0,m.getPointAndHyperbolaNearestPointAndDistance)(e,t.curve,n).distance:"ray"===t.type?z(e,t.line,n).distance:(0,g.getPointAndNurbsCurveNearestPointAndDistance)(e,t.curve).distance}function W(e,t,n,r=!1){const{distance:o}=D(e,t,n,r);return o}function H(e,t){return q(e,(0,s.getPolygonFromTwoPointsFormRegion)(t))}function q(e,t){const n=Array.from((0,u.getPolygonLine)(t));return Math.min(...n.map((t=>W(e,...t))))}function $(e,t,n=!1){const{distance:r}=N(e,t,n);return r}},4206:(e,t,n)=>{"use strict";n.r(t),n.d(t,{GeneralFormPlane:()=>c,directionIsOnPlane:()=>f,getCoordinate:()=>w,getLineAndPlaneIntersectionPoint:()=>l,getLineAndTrianglesIntersectionPoint:()=>E,getLineAndZPlaneIntersectionPoint:()=>p,getParallelPlanesByDistance:()=>C,getPerpendicularDistanceToPlane:()=>b,getPerpendicularPointToPlane:()=>x,getPlaneByPointAndNormal:()=>m,getPlaneNormal:()=>v,getPointAndDirectionLineAndPlaneIntersectionPoint:()=>u,getPointAndTwoDirectionsPlane:()=>h,getThreePointPlane:()=>g,pointInTriangle:()=>y,pointIsOnPlane:()=>d,rotateDirectionByRadianOnPlane:()=>P});var r=n(1796),o=n(2792),i=n(5147),a=n(360),s=n(5569);const c=(0,s.and)(r.GeneralFormLine,{d:s.number});function l([e,t],n){return u(e,i.v3.substract(t,e),n)}function u([e,t,n],[r,i,a],{a:s,b:c,c:l,d:u}){const p=s*r+c*i+l*a;if((0,o.isZero)(p))return;const d=-(s*e+c*t+l*n+u)/p;return[e+r*d,t+i*d,n+a*d]}function p([[e,t,n],[r,i,a]],s){const c=a-n;if((0,o.isZero)(c))return;const l=(s-n)/c;return[e+(r-e)*l,t+(i-t)*l,s]}function d([e,t,n],{a:r,b:i,c:a,d:s}){return(0,o.isZero)(r*e+i*t+a*n+s)}function f([e,t,n],{a:r,b:i,c:a}){return(0,o.isZero)(r*e+i*t+a*n)}function g(e,t,n){return h(e,i.v3.substract(t,e),i.v3.substract(n,e))}function h(e,t,n){return m(e,i.v3.cross(t,n))}function m([e,t,n],[r,o,i]){return{a:r,b:o,c:i,d:-(r*e+o*t+i*n)}}function y(e,t,n,r){const o=i.v3.substract(r,t),a=i.v3.substract(n,t),s=i.v3.substract(e,t),c=i.v3.dot(o,o),l=i.v3.dot(o,a),u=i.v3.dot(o,s),p=i.v3.dot(a,a),d=i.v3.dot(a,s),f=c*p-l*l,g=(u*p-l*d)/f;if(g<0||g>1)return!1;const h=(c*d-l*u)/f;return!(h<0||h>1)&&g+h<=1}function v(e){return[e.a,e.b,e.c]}function x([e,t,n],{a:r,b:o,c:i,d:a}){const s=-(r*e+o*t+i*n+a)/(r*r+o*o+i*i);return[e+r*s,t+o*s,n+i*s]}function b([e,t,n],{a:r,b:o,c:i,d:a}){return Math.abs(r*e+o*t+i*n+a)/Math.sqrt(r*r+o*o+i*i)}function C({a:e,b:t,c:n,d:r},o){const i=e*e+t*t+n*n,a=o*Math.sqrt(i);return[{a:e,b:t,c:n,d:r+a},{a:e,b:t,c:n,d:r-a}]}function E(e,t){const n=[];for(const r of t){const t=g(...r);if(t){const o=l(e,t);o&&y(o,...r)&&n.push(o)}}return n}function P(e,t,n){e=i.v3.normalize(e),n=i.v3.normalize(n);const r=[[0,0,0],e,i.v3.cross(e,n),n],o=Math.cos(t),s=Math.sin(t),c=(0,a.transformPointFromCoordinate)([o,s,0],r);if(c)return i.v3.normalize(c)}function w(e){e=i.v3.normalize(e);const t=(0,o.isZero)(e[0])&&(0,o.isZero)(e[1])?[1,0,0]:[0,0,1],n=i.v3.normalize(i.v3.cross(e,t));return[n,i.v3.cross(e,n),e]}},5773:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Position:()=>c,Position3D:()=>l,deduplicatePosition:()=>k,getPointAndPolygonMaximumDistance:()=>x,getPointByLengthAndDirection:()=>g,getPointByLengthAndDirection3D:()=>A,getPointByLengthAndDirectionSafely:()=>h,getPointByLengthAndRadian:()=>y,getPointByParamAndDirection3D:()=>L,getTwoPointCenter:()=>w,getTwoPointsDistance:()=>b,getTwoPointsDistance3D:()=>E,getTwoPointsDistance3DSquare:()=>P,getTwoPointsDistanceSquare:()=>C,isSameDirection:()=>R,isSameDirection3D:()=>T,isSamePoint:()=>m,multiplyDirection:()=>v,position3DToVec3:()=>u,positionToVec2:()=>d,rotatePosition:()=>S,rotatePositionByCenter:()=>_,vec2ToPosition:()=>f,vec3ToPosition3D:()=>p});var r=n(2792),o=n(5147),i=n(1715),a=n(5569),s=Math.pow;const c={x:a.number,y:a.number},l=(0,a.and)(c,{z:a.number});function u(e){return[e.x,e.y,e.z]}function p(e){return{x:e[0],y:e[1],z:e[2]}}function d(e){return[e.x,e.y]}function f(e){return{x:e[0],y:e[1]}}function g(e,t,n){if((0,r.isZero)(t))return e;let o=n.x-e.x,i=n.y-e.y;if(t<0&&(t=-t,o=-o,i=-i),(0,r.isZero)(o))return{x:e.x,y:e.y+t*(i>0?1:-1)};const a=Math.sqrt(s(t,2)*s(o,2)/(s(o,2)+s(i,2)))*(o>0?1:-1);return{x:e.x+a,y:e.y+i/o*a}}function h(e,t,n){if(!m(e,n))return g(e,t,n)}function m(e,t,n){return(0,r.isSameNumber)(e.x,t.x,n)&&(0,r.isSameNumber)(e.y,t.y,n)}function y(e,t,n){const r=v((0,i.getDirectionByRadian)(n),t);return{x:e.x+r.x,y:e.y+r.y}}function v(e,t){return{x:e.x*t,y:e.y*t}}function x(e,t){return Math.max(...t.map((t=>b(e,t))))}function b(e,t={x:0,y:0}){return Math.sqrt(C(e,t))}function C(e,t={x:0,y:0}){return s(e.x-t.x,2)+s(e.y-t.y,2)}function E(e,t={x:0,y:0,z:0}){return Math.sqrt(P(e,t))}function P(e,t={x:0,y:0,z:0}){return s(e.x-t.x,2)+s(e.y-t.y,2)+s(e.z-t.z,2)}function w(e,t){return{x:(0,r.getTwoNumberCenter)(e.x,t.x),y:(0,r.getTwoNumberCenter)(e.y,t.y)}}function k(e){return(0,r.deduplicate)(e,m)}function _(e,t,n){return n?S(e,t,-(0,i.angleToRadian)(n)):e}function S(e,t,n){if(!n)return e;const r=e.x-t.x,o=e.y-t.y,i=Math.sin(n),a=Math.cos(n);return{x:a*r-i*o+t.x,y:i*r+a*o+t.y}}function R(e,t){return(0,r.equals)(e.x*t.y,e.y*t.x)}function T(e,t){return R({x:e[0],y:e[1]},{x:t[0],y:t[1]})&&R({x:e[0],y:e[2]},{x:t[0],y:t[2]})}function A(e,t,n){return L(e,t/o.v3.length(n),n)}function L(e,t,n){return o.v3.add(e,o.v3.multiplyScalar(n,t))}},7727:(e,t,n)=>{"use strict";n.r(t),n.d(t,{printJsToCode:()=>o});var r=n(6022);function o(e,t){const n=null==t?void 0:t.space;let r;if("number"==typeof n&&!isNaN(n)&&n>=1){r="";const e=Math.min(Math.floor(n),10);for(let t=0;t0&&(a+=`\n${r}`),a+"]"}(e,t,n,o,a):(0,r.isRecord)(e)?function(e,t,n,r,o){let a="{",s=!1;for(const r in e){const l=e[r];if(void 0===l||"function"==typeof l&&!t)continue;s&&(a+=",");const u=/^[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*$/u.test(r)?r:c(r);a+=void 0!==n?`\n${o}${u}: `:`${u}:`,s=!0,a+=i(l,t,n,o)}return void 0!==n&&Object.keys(e).length>0&&(a+=`\n${r}`),a+"}"}(e,t,n,o,a):""}const a=/[\\"\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,s={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};function c(e){return a.lastIndex=0,a.test(e)?'"'+e.replace(a,(e=>{const t=s[e];return"string"==typeof t?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)}))+'"':'"'+e+'"'}},1715:(e,t,n)=>{"use strict";function r(e=0){return 180*e/Math.PI}function o(e=0){return e*Math.PI/180}function i(e,t={x:0,y:0}){return Math.atan2(e.y-t.y,e.x-t.x)}function a(e){return{x:Math.cos(e),y:Math.sin(e)}}n.r(t),n.d(t,{angleToRadian:()=>o,getDirectionByRadian:()=>a,getTwoPointsRadian:()=>i,radianToAngle:()=>r})},6928:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Reducer:()=>o});var r=Object.defineProperty;class o{constructor(e,t,n){var o,i;this.flush=e,this.newItem=t,this.reduceItem=n,((e,t,n)=>{t in e?r(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(this,"symbol"!=typeof(o="last")?o+"":o,i)}flushLast(){this.last&&(this.flush(this.last),this.last=void 0)}push(e){this.last?this.newItem(this.last,e)?(this.flushLast(),this.push(e)):this.reduceItem(this.last,e):this.last=e}}},3537:(e,t,n)=>{"use strict";function r(...e){return t=>{for(const n of e)"function"==typeof n?n(t):n&&(n.current=t)}}n.r(t),n.d(t,{bindMultipleRefs:()=>r})},7486:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Region:()=>c,Size:()=>s,getPointAndRegionMaximumDistance:()=>h,getPolygonFromRegion:()=>g,getPolygonFromTwoPointsFormRegion:()=>f,getRegion:()=>u,getRoundedRectPoints:()=>m,getTwoPointsFormRegion:()=>l,getTwoPointsFormRegionSize:()=>p,pointIsInRegion:()=>d});var r=n(2318),o=n(2792),i=n(5773),a=n(5569);const s={width:(0,a.minimum)(0,a.number),height:(0,a.minimum)(0,a.number)},c=(0,a.and)(i.Position,s);function l(e,t){return{start:{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y)},end:{x:Math.max(e.x,t.x),y:Math.max(e.y,t.y)}}}function u(e,t){return{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),width:(0,o.getTwoNumbersDistance)(e.x,t.x),height:(0,o.getTwoNumbersDistance)(e.y,t.y)}}function p(e){return{width:(0,o.getTwoNumbersDistance)(e.start.x,e.end.x),height:(0,o.getTwoNumbersDistance)(e.start.y,e.end.y)}}function d(e,t){return(0,o.largerOrEqual)(e.x,t.start.x)&&(0,o.largerOrEqual)(e.y,t.start.y)&&(0,o.lessOrEqual)(e.x,t.end.x)&&(0,o.lessOrEqual)(e.y,t.end.y)}function f(e){return[e.start,{x:e.start.x,y:e.end.y},e.end,{x:e.end.x,y:e.start.y}]}function g(e){return[{x:e.x-e.width/2,y:e.y-e.height/2},{x:e.x+e.width/2,y:e.y-e.height/2},{x:e.x+e.width/2,y:e.y+e.height/2},{x:e.x-e.width/2,y:e.y+e.height/2}]}function h(e,t){return(0,i.getPointAndPolygonMaximumDistance)(e,f(t))}function m(e,t,n){return[...(0,r.arcToPolyline)({x:e.x+e.width/2-t,y:e.y-e.height/2+t,r:t,startAngle:-90,endAngle:0},n),...(0,r.arcToPolyline)({x:e.x+e.width/2-t,y:e.y+e.height/2-t,r:t,startAngle:0,endAngle:90},n),...(0,r.arcToPolyline)({x:e.x-e.width/2+t,y:e.y+e.height/2-t,r:t,startAngle:90,endAngle:180},n),...(0,r.arcToPolyline)({x:e.x-e.width/2+t,y:e.y-e.height/2+t,r:t,startAngle:180,endAngle:270},n)]}},8306:(e,t,n)=>{"use strict";n.r(t),n.d(t,{reverseAngle:()=>S,reverseArc:()=>v,reverseBezierCurve:()=>C,reverseClosedGeometryLinesIfAreaIsNegative:()=>w,reverseEllipseArc:()=>x,reverseGeometryLine:()=>E,reverseGeometryLines:()=>P,reverseLineSegment:()=>y,reverseNurbs:()=>T,reverseQuadraticCurve:()=>b,reverseRadian:()=>_,reverseRay:()=>k});var r=n(8230),o=n(1796),i=n(8831),a=n(8258),s=n(2986),c=Object.defineProperty,l=Object.defineProperties,u=Object.getOwnPropertyDescriptors,p=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,f=Object.prototype.propertyIsEnumerable,g=(e,t,n)=>t in e?c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,h=(e,t)=>{for(var n in t||(t={}))d.call(t,n)&&g(e,n,t[n]);if(p)for(var n of p(t))f.call(t,n)&&g(e,n,t[n]);return e},m=(e,t)=>l(e,u(t));function y(e){return[e[1],e[0]]}function v(e){return m(h({},e),{startAngle:e.endAngle,endAngle:e.startAngle,counterclockwise:!e.counterclockwise})}function x(e){return m(h({},e),{startAngle:e.endAngle,endAngle:e.startAngle,counterclockwise:!e.counterclockwise})}function b(e){return m(h({},e),{from:e.to,to:e.from})}function C(e){return m(h({},e),{from:e.to,cp1:e.cp2,cp2:e.cp1,to:e.from})}function E(e){return Array.isArray(e)?y(e):"arc"===e.type?m(h({},e),{curve:v(e.curve)}):"ellipse arc"===e.type?m(h({},e),{curve:x(e.curve)}):"quadratic curve"===e.type?m(h({},e),{curve:b(e.curve)}):"bezier curve"===e.type?m(h({},e),{curve:C(e.curve)}):"ray"===e.type?m(h({},e),{line:k(e.line)}):"hyperbola curve"===e.type?m(h({},e),{curve:(0,s.reverseHyperbola)(e.curve)}):m(h({},e),{curve:(0,r.reverseNurbsCurve)(e.curve)})}function P(e){return e.map((e=>E(e))).reverse()}function w(e){return(0,o.getPolygonArea)((0,a.getGeometryLinesPoints)(e))<0?P(e):e}function k(e){return e.bidirectional?m(h({},e),{angle:(0,i.normalizeAngle)(e.angle+180)}):m(h({},e),{reversed:!e.reversed})}function _(e){return(0,i.normalizeRadian)(e+Math.PI)}function S(e){return(0,i.normalizeAngle)(e+180)}function R(e){const t=[e[0]];for(let n=0;n{"use strict";n.r(t),n.d(t,{ContentPath:()=>g,getContentByClickPosition:()=>u,getContentsByClickPosition:()=>p,getContentsByClickTwoPositions:()=>d,getContentsByRegion:()=>f});var r=n(2792),o=n(7486),i=n(1796),a=n(491),s=n(5717),c=n(8392),l=n(5569);function u(e,t,n,r,o=!1,a,s=e.map(((e,t)=>t)),l=3){for(let u=s.length-1;u>=0;u--){const p=s[u],d=e[p];if(!d)continue;if(a&&!a(d))continue;const f=r(d);if(null==f?void 0:f.getGeometries){const{lines:r,regions:a}=f.getGeometries(d,e);for(let e=0;e(0,i.pointInPolygon)(t,e))))&&(0,i.pointInPolygon)(t,s.points)){if(o&&f.canSelectPart&&n([p,e]))return[p,e+r.length];if(n([p]))return[p]}}}}}function p(e,t,n,r,o,a=3){const s=[];return e.forEach(((l,u)=>{if(!l)return;if(o&&!o(l))return;const p=r(l);if(null==p?void 0:p.getGeometries){const{lines:r,regions:o}=p.getGeometries(l,e);for(let e=0;e(0,i.pointInPolygon)(t,e))))return;if((0,i.pointInPolygon)(t,r.points)&&n([u]))return void s.push([u])}}})),s}function d(e,t,n,i,a,s){const c=(0,o.getTwoPointsFormRegion)(t,n),l=(0,r.largerThan)(t.x,n.x);return f(e,(0,o.getPolygonFromTwoPointsFormRegion)(c),l,!1,i,a,s)}function f(e,t,n,r,o,c,l){const u=[];return e.forEach(((p,d)=>{if(p&&(!l||l(p))&&(!c||c([d]))){const c=o(p);if(null==c?void 0:c.getGeometries){const{lines:o,bounding:l,regions:f}=c.getGeometries(p,e);if(r?o.every((e=>(0,s.geometryLineInPolygon)(e,t)))&&(!f||f.every((e=>e.points.every((e=>(0,i.pointInPolygon)(e,t)))))):l&&(0,i.pointInPolygon)(l.start,t)&&(0,i.pointInPolygon)(l.end,t))u.push([d]);else if(n){for(const e of o)if((0,a.geometryLineIntersectWithPolygon)(e,t))return void u.push([d]);if(f)for(const e of f)for(const n of e.lines)if((0,a.geometryLineIntersectWithPolygon)(n,t))return void u.push([d])}}}})),u}const g=(0,l.minItems)(1,(0,l.maxItems)(2,[l.number]))},2808:(e,t,n)=>{"use strict";n.r(t),n.d(t,{getCircleAndBezierCurveExtremumPoints:()=>R,getCircleAndEllipseExtremumPoints:()=>_,getCircleAndQuadraticCurveExtremumPoints:()=>S,getEllipseBezierCurveExtremumPoints:()=>L,getEllipseQuadraticCurveExtremumPoints:()=>A,getLineAndBezierCurveExtremumPoints:()=>w,getLineAndCircleExtremumPoints:()=>C,getLineAndEllipseExtremumPoints:()=>E,getLineAndQuadraticCurveExtremumPoint:()=>P,getQuadraticCurveAndBezierCurveExtremumPoints:()=>I,getShortestDistanceOfTwoDisjointGeometryLine:()=>x,getShortestDistanceOfTwoGeometryLine:()=>v,getShortestDistanceOfTwoGeometryLines:()=>b,getTwoBezierCurveExtremumPoints:()=>O,getTwoCircleExtremumPoints:()=>k,getTwoEllipseExtremumPoints:()=>T,getTwoQuadraticCurveExtremumPoints:()=>M});var r=n(5629),o=n(2318),i=n(2298),a=n(1475),s=n(5717),c=n(2986),l=n(491),u=n(9292),p=n(1796),d=n(2792),f=n(8230),g=n(8392),h=n(5773),m=n(1715),y=n(8306);function v(e,t){const n=(0,l.getTwoGeometryLinesIntersectionPoint)(e,t)[0];return n?{points:[n,n],distance:0}:x(e,t)}function x(e,t){let n=[];if(Array.isArray(e)||"ray"===e.type){const r=(0,s.lineSegmentOrRayToGeneralFormLine)(e);if(r)if(Array.isArray(t)||"ray"===t.type)n=[];else if("arc"===t.type)n=C(r,t.curve).map((e=>({points:e,distance:(0,h.getTwoPointsDistance)(...e)})));else if("ellipse arc"===t.type)n=E(r,t.curve).map((e=>({points:e,distance:(0,h.getTwoPointsDistance)(...e)})));else if("quadratic curve"===t.type){const e=P(r,t.curve);n=[{points:e,distance:(0,h.getTwoPointsDistance)(...e)}]}else"bezier curve"===t.type?n=w(r,t.curve).map((e=>({points:e,distance:(0,h.getTwoPointsDistance)(...e)}))):"hyperbola curve"===t.type?n=(0,c.getLineAndHyperbolaExtremumPoint)(r,t.curve).map((e=>({points:e,distance:(0,h.getTwoPointsDistance)(...e)}))):"nurbs curve"===t.type&&(n=(0,f.getLineAndNurbsCurveExtremumPoints)(r,t.curve).map((e=>({points:e,distance:(0,h.getTwoPointsDistance)(...e)}))));else{const r=(0,s.getLineSegmentOrRayPoint)(e),o=(0,g.getPointAndGeometryLineNearestPointAndDistance)(r,t);n=[{points:[r,o.point],distance:o.distance}]}}else{if(Array.isArray(t)||"ray"===t.type)return x(t,e);if("arc"===e.type)"arc"===t.type?n=k(e.curve,t.curve).map((e=>({points:e,distance:(0,h.getTwoPointsDistance)(...e)}))):"ellipse arc"===t.type?n=_(e.curve,t.curve).map((e=>({points:e,distance:(0,h.getTwoPointsDistance)(...e)}))):"quadratic curve"===t.type?n=S(e.curve,t.curve).map((e=>({points:e,distance:(0,h.getTwoPointsDistance)(...e)}))):"bezier curve"===t.type?n=R(e.curve,t.curve).map((e=>({points:e,distance:(0,h.getTwoPointsDistance)(...e)}))):"hyperbola curve"===t.type?n=(0,c.getCircleAndHyperbolaExtremumPoints)(e.curve,t.curve).map((e=>({points:e,distance:(0,h.getTwoPointsDistance)(...e)}))):"nurbs curve"===t.type&&(n=(0,f.getCircleAndNurbsCurveExtremumPoints)(e.curve,t.curve).map((e=>({points:e,distance:(0,h.getTwoPointsDistance)(...e)}))));else{if("arc"===t.type)return x(t,e);if("ellipse arc"===e.type)"ellipse arc"===t.type?n=T(e.curve,t.curve).map((e=>({points:e,distance:(0,h.getTwoPointsDistance)(...e)}))):"quadratic curve"===t.type?n=A(e.curve,t.curve).map((e=>({points:e,distance:(0,h.getTwoPointsDistance)(...e)}))):"bezier curve"===t.type?n=L(e.curve,t.curve).map((e=>({points:e,distance:(0,h.getTwoPointsDistance)(...e)}))):"hyperbola curve"===t.type?n=(0,c.getEllipseAndHyperbolaExtremumPoints)(e.curve,t.curve).map((e=>({points:e,distance:(0,h.getTwoPointsDistance)(...e)}))):"nurbs curve"===t.type&&(n=(0,f.getEllipseAndNurbsCurveExtremumPoints)(e.curve,t.curve).map((e=>({points:e,distance:(0,h.getTwoPointsDistance)(...e)}))));else{if("ellipse arc"===t.type)return x(t,e);if("quadratic curve"===e.type)"quadratic curve"===t.type?n=M(e.curve,t.curve).map((e=>({points:e,distance:(0,h.getTwoPointsDistance)(...e)}))):"bezier curve"===t.type?n=I(e.curve,t.curve).map((e=>({points:e,distance:(0,h.getTwoPointsDistance)(...e)}))):"hyperbola curve"===t.type?n=(0,c.getQuadraticCurveAndHyperbolaExtremumPoints)(e.curve,t.curve).map((e=>({points:e,distance:(0,h.getTwoPointsDistance)(...e)}))):"nurbs curve"===t.type&&(n=(0,f.getQuadraticCurveAndNurbsCurveExtremumPoints)(e.curve,t.curve).map((e=>({points:e,distance:(0,h.getTwoPointsDistance)(...e)}))));else{if("quadratic curve"===t.type)return x(t,e);if("bezier curve"===e.type)"bezier curve"===t.type?n=O(e.curve,t.curve).map((e=>({points:e,distance:(0,h.getTwoPointsDistance)(...e)}))):"hyperbola curve"===t.type?n=(0,c.getBezierCurveAndHyperbolaExtremumPoints)(e.curve,t.curve).map((e=>({points:e,distance:(0,h.getTwoPointsDistance)(...e)}))):"nurbs curve"===t.type&&(n=(0,f.getBezierCurveAndNurbsCurveExtremumPoints)(e.curve,t.curve).map((e=>({points:e,distance:(0,h.getTwoPointsDistance)(...e)}))));else{if("bezier curve"===t.type)return x(t,e);if("hyperbola curve"===e.type)"hyperbola curve"===t.type?n=(0,c.getTwoHyperbolaExtremumPoints)(e.curve,t.curve).map((e=>({points:e,distance:(0,h.getTwoPointsDistance)(...e)}))):"nurbs curve"===t.type&&(n=(0,f.getHyperbolaAndNurbsCurveExtremumPoints)(e.curve,t.curve).map((e=>({points:e,distance:(0,h.getTwoPointsDistance)(...e)}))));else{if("hyperbola curve"===t.type)return x(t,e);if("nurbs curve"===e.type)"nurbs curve"===t.type&&(n=(0,f.getTwoNurbsCurveExtremumPoints)(e.curve,t.curve).map((e=>({points:e,distance:(0,h.getTwoPointsDistance)(...e)}))));else if("nurbs curve"===t.type)return x(t,e)}}}}}}n=n.filter((n=>(0,s.pointIsOnGeometryLine)(n.points[0],e)&&(0,s.pointIsOnGeometryLine)(n.points[1],t)));const{start:r,end:o}=(0,s.getGeometryLineStartAndEnd)(e);n.push(...Array.from((0,u.iterateItemOrArray)([r,o])).map((e=>{const n=(0,g.getPointAndGeometryLineNearestPointAndDistance)(e,t);return{points:[e,n.point],distance:n.distance}})));const{start:i,end:a}=(0,s.getGeometryLineStartAndEnd)(t);return n.push(...Array.from((0,u.iterateItemOrArray)([i,a])).map((t=>{const n=(0,g.getPointAndGeometryLineNearestPointAndDistance)(t,e);return{points:[t,n.point],distance:n.distance}}))),(0,d.minimumBy)(n,(e=>e.distance))}function b(e,t){return(0,d.minimumBy)(e.map((e=>(0,d.minimumBy)(t.map((t=>v(e,t))),(e=>e.distance),d.isZero))),(e=>e.distance),d.isZero)}function C(e,t){const n=(0,g.getPerpendicularPoint)(t,e);if((0,h.isSamePoint)(n,t)){const r=(0,p.getGeneralFormLineRadian)(e);return[[n,(0,h.getPointByLengthAndRadian)(t,t.r,r+Math.PI/2)],[n,(0,h.getPointByLengthAndRadian)(t,-t.r,r-Math.PI/2)]]}return[[n,(0,h.getPointByLengthAndDirection)(t,t.r,n)],[n,(0,h.getPointByLengthAndDirection)(t,-t.r,n)]]}function E(e,t){const{a:n,b:r}=e,{rx:o,ry:a,angle:s}=t,c=(0,m.angleToRadian)(s),l=Math.sin(c),u=Math.cos(c),p=Math.atan2((n*l-r*u)*a,(-r*l-n*u)*o);return[p,(0,y.reverseRadian)(p)].map((n=>{const r=(0,i.getEllipsePointAtRadian)(t,n);return[(0,g.getPerpendicularPoint)(r,e),r]}))}function P(e,t){const{a:n,b:o}=e,{from:{x:i,y:a},cp:{x:s,y:c},to:{x:l,y:u}}=t,p=s-i,d=c-a,f=-(n*p+o*d)/(n*(l-s-p)+o*(u-c-d)),h=(0,r.getQuadraticCurvePointAtPercent)(t.from,t.cp,t.to,f);return[(0,g.getPerpendicularPoint)(h,e),h]}function w(e,t){const{a:n,b:o}=e,{from:{x:i,y:s},cp1:{x:c,y:l},cp2:{x:u,y:p},to:{x:d,y:f}}=t,h=3*c-i-3*u+d,m=3*(i-2*c+u),y=3*(c-i),v=3*l-s-3*p+f,x=3*(s-2*l+p),b=3*(l-s);return(0,a.calculateEquation2)(3*n*h+3*o*v,2*n*m+2*o*x,n*y+o*b).map((n=>{const o=(0,r.getBezierCurvePointAtPercent)(t.from,t.cp1,t.cp2,t.to,n);return[(0,g.getPerpendicularPoint)(o,e),o]}))}function k(e,t){if((0,h.isSamePoint)(e,t))return[];const n=Math.atan2(e.y-t.y,e.x-t.x),r=(0,y.reverseRadian)(n),i=(0,o.getCirclePointAtRadian)(e,n),a=(0,o.getCirclePointAtRadian)(e,r),s=(0,o.getCirclePointAtRadian)(t,n),c=(0,o.getCirclePointAtRadian)(t,r);return[[i,s],[a,s],[i,c],[a,c]]}function _(e,t){return(0,d.isSameNumber)(t.rx,t.ry)?k(e,{x:t.cx,y:t.cy,r:t.rx}):(0,g.getPerpendicularPointRadiansToEllipse)(e,t).map((n=>{const r=(0,i.getEllipsePointAtRadian)(t,n),a=(0,o.getCircleRadian)(r,e);return[[(0,o.getCirclePointAtRadian)(e,a),r],[(0,o.getCirclePointAtRadian)(e,(0,y.reverseRadian)(a)),r]]})).flat()}function S(e,t){return(0,g.getPerpendicularPercentToQuadraticCurve)(e,t).map((n=>{const i=(0,r.getQuadraticCurvePointAtPercent)(t.from,t.cp,t.to,n),a=(0,o.getCircleRadian)(i,e);return[[(0,o.getCirclePointAtRadian)(e,a),i],[(0,o.getCirclePointAtRadian)(e,(0,y.reverseRadian)(a)),i]]})).flat()}function R(e,t){return(0,g.getPerpendicularPercentToBezierCurve)(e,t).map((n=>{const i=(0,r.getBezierCurvePointAtPercent)(t.from,t.cp1,t.cp2,t.to,n),a=(0,o.getCircleRadian)(i,e);return[[(0,o.getCirclePointAtRadian)(e,a),i],[(0,o.getCirclePointAtRadian)(e,(0,y.reverseRadian)(a)),i]]})).flat()}function T(e,t){const[n,r,o]=(0,i.getEllipseDerivatives)(e),[s,c,l]=(0,i.getEllipseDerivatives)(t),u=e=>{const{x:t,y:o}=n(e[0]),{x:i,y:a}=r(e[0]),{x:l,y:u}=s(e[1]),{x:p,y:d}=c(e[1]);return[(t-l)*i+(o-u)*a,(l-t)*p+(u-o)*d]},p=e=>{const{x:t,y:i}=n(e[0]),{x:a,y:u}=r(e[0]),{x:p,y:d}=o(e[0]),{x:f,y:g}=s(e[1]),{x:h,y:m}=c(e[1]),{x:y,y:v}=l(e[1]);return[a*a+(t-f)*p+u*u+(i-g)*d,-h*a-m*u,-a*h-u*m,h*h+(f-t)*y+m*m+(g-i)*v]};let f=[];for(const e of[-Math.PI/2,Math.PI/2])for(const t of[-Math.PI/2,Math.PI/2]){const n=(0,a.newtonIterate2)([e,t],u,p,d.delta2);void 0!==n&&f.push(n)}return f=(0,d.deduplicate)(f,d.deepEquals),f.map((e=>[n(e[0]),s(e[1])]))}function A(e,t){const[n,o,s]=(0,i.getEllipseDerivatives)(e),[c,l,u]=(0,r.getQuadraticCurveDerivatives)(t),p=e=>{const{x:t,y:r}=n(e[0]),{x:i,y:a}=o(e[0]),{x:s,y:u}=c(e[1]),{x:p,y:d}=l(e[1]);return[(t-s)*i+(r-u)*a,(s-t)*p+(u-r)*d]},f=e=>{const{x:t,y:r}=n(e[0]),{x:i,y:a}=o(e[0]),{x:p,y:d}=s(e[0]),{x:f,y:g}=c(e[1]),{x:h,y:m}=l(e[1]),{x:y,y:v}=u(e[1]);return[i*i+(t-f)*p+a*a+(r-g)*d,-h*i-m*a,-i*h-a*m,h*h+(f-t)*y+m*m+(g-r)*v]};let g=[];for(const e of[-Math.PI/2,Math.PI/2])for(const t of[.25,.75]){const n=(0,a.newtonIterate2)([e,t],p,f,d.delta2);void 0!==n&&g.push(n)}return g=(0,d.deduplicate)(g,d.deepEquals),g.filter((e=>(0,d.isValidPercent)(e[1]))).map((e=>[n(e[0]),c(e[1])]))}function L(e,t){const[n,o,s]=(0,i.getEllipseDerivatives)(e),[c,l,u]=(0,r.getBezierCurveDerivatives)(t),p=e=>{const{x:t,y:r}=n(e[0]),{x:i,y:a}=o(e[0]),{x:s,y:u}=c(e[1]),{x:p,y:d}=l(e[1]);return[(t-s)*i+(r-u)*a,(s-t)*p+(u-r)*d]},f=e=>{const{x:t,y:r}=n(e[0]),{x:i,y:a}=o(e[0]),{x:p,y:d}=s(e[0]),{x:f,y:g}=c(e[1]),{x:h,y:m}=l(e[1]),{x:y,y:v}=u(e[1]);return[i*i+(t-f)*p+a*a+(r-g)*d,-h*i-m*a,-i*h-a*m,h*h+(f-t)*y+m*m+(g-r)*v]};let g=[];for(const e of[-Math.PI/2,Math.PI/2])for(const t of[.25,.75]){const n=(0,a.newtonIterate2)([e,t],p,f,d.delta2);void 0!==n&&g.push(n)}return g=(0,d.deduplicate)(g,d.deepEquals),g.filter((e=>(0,d.isValidPercent)(e[1]))).map((e=>[n(e[0]),c(e[1])]))}function M(e,t){const{from:{x:n,y:o},cp:{x:i,y:s},to:{x:c,y:l}}=e,u=i-n,p=c-i-u,f=s-o,g=l-s-f,{from:{x:h,y:m},cp:{x:y,y:v},to:{x,y:b}}=t,C=y-h,E=x-y-C,P=v-m,w=b-v-P,k=g*E-p*w,_=g*C-p*P,S=f*E-u*w,R=f*C-u*P,T=n-h,A=o-m,L=-p*p-g*g,M=-3*u*p-3*f*g,I=p*E+g*w,O=2*p*C+2*g*P,D=-2*u*u-2*f*f-p*T-g*A,B=u*E+f*w,z=2*u*C+2*f*P,F=-u*T-f*A;let N=(0,a.calculateEquation5)([B*k*k*k-I*k*k*S,z*k*k*k+3*B*k*k*_-O*k*k*S-2*I*k*_*S-I*k*k*R,F*k*k*k+3*z*k*k*_+3*B*k*_*_+M*k*S*S-D*k*k*S-2*O*k*_*S-I*_*_*S-L*S*S*S-O*k*k*R-2*I*k*_*R,3*F*k*k*_+3*z*k*_*_+B*_*_*_+M*_*S*S-2*D*k*_*S-O*_*_*S-D*k*k*R-2*O*k*_*R-I*_*_*R+2*M*k*S*R-3*L*S*S*R,3*F*k*_*_+z*_*_*_-D*_*_*S-2*D*k*_*R-O*_*_*R+2*M*_*S*R+M*k*R*R-3*L*S*R*R,F*_*_*_-D*_*_*R+M*_*R*R-L*R*R*R],.5);N=N.filter((e=>(0,d.isValidPercent)(e)));const U=[];for(const n of N){const o=-(S*n+R)/(k*n+_);(0,d.isValidPercent)(o)&&U.push([(0,r.getQuadraticCurvePointAtPercent)(e.from,e.cp,e.to,o),(0,r.getQuadraticCurvePointAtPercent)(t.from,t.cp,t.to,n)])}return U}function I(e,t){const{from:{x:n,y:o},cp:{x:i,y:s},to:{x:c,y:l}}=e,u=i-n,p=c-i-u,f=s-o,g=l-s-f,{from:{x:h,y:m},cp1:{x:y,y:v},cp2:{x,y:b},to:{x:C,y:E}}=t,P=3*y-h+-3*x+C,w=3*(h-2*y+x),k=3*(y-h),_=3*v-m+-3*b+E,S=3*(m-2*v+b),R=3*(v-m),T=3*P*g-3*_*p,A=-2*S*p+2*w*g,L=-R*p+k*g,M=3*_*u-3*P*f,I=2*S*u-2*w*f,O=R*u-k*f,D=-p*p-g*g,B=-3*u*p-3*f*g,z=P*p+_*g,F=w*p+S*g,N=k*p+R*g,U=-2*u*u+h*p-n*p-2*f*f+m*g-o*g,G=P*u+_*f,j=w*u+S*f,V=k*u+R*f,W=h*u-n*u+m*f-o*f;let H=(0,a.calculateEquation5)([T*T*M*z+T*T*T*G,2*T*A*M*z+T*T*I*z+T*T*M*F+3*T*T*A*G+T*T*T*j,A*A*M*z+2*T*L*M*z+2*T*A*I*z+T*T*O*z+2*T*A*M*F+T*T*I*F+T*T*M*N+3*T*A*A*G+3*T*T*L*G+3*T*T*A*j+T*T*T*V,T*T*T*W+M*M*M*D+T*M*M*B+2*A*L*M*z+A*A*I*z+2*T*L*I*z+2*T*A*O*z+A*A*M*F+2*T*L*M*F+2*T*A*I*F+T*T*O*F+2*T*A*M*N+T*T*I*N+T*T*M*U+A*A*A*G+6*T*A*L*G+3*T*A*A*j+3*T*T*L*j+3*T*T*A*V,3*T*T*A*W+3*M*M*I*D+A*M*M*B+2*T*M*I*B+L*L*M*z+2*A*L*I*z+A*A*O*z+2*T*L*O*z+2*A*L*M*F+A*A*I*F+2*T*L*I*F+2*T*A*O*F+A*A*M*N+2*T*L*M*N+2*T*A*I*N+T*T*O*N+2*T*A*M*U+T*T*I*U+3*A*A*L*G+3*T*L*L*G+A*A*A*j+6*T*A*L*j+3*T*A*A*V+3*T*T*L*V,3*T*A*A*W+3*T*T*L*W+3*M*I*I*D+3*M*M*O*D+L*M*M*B+2*A*M*I*B+T*I*I*B+2*T*M*O*B+L*L*I*z+2*A*L*O*z+L*L*M*F+2*A*L*I*F+A*A*O*F+2*T*L*O*F+2*A*L*M*N+A*A*I*N+2*T*L*I*N+2*T*A*O*N+A*A*M*U+2*T*L*M*U+2*T*A*I*U+T*T*O*U+3*A*L*L*G+3*A*A*L*j+3*T*L*L*j+A*A*A*V+6*T*A*L*V,A*A*A*W+6*T*A*L*W+I*I*I*D+6*M*I*O*D+2*L*M*I*B+A*I*I*B+2*A*M*O*B+2*T*I*O*B+L*L*O*z+L*L*I*F+2*A*L*O*F+L*L*M*N+2*A*L*I*N+A*A*O*N+2*T*L*O*N+2*A*L*M*U+A*A*I*U+2*T*L*I*U+2*T*A*O*U+L*L*L*G+3*A*L*L*j+3*A*A*L*V+3*T*L*L*V,3*A*A*L*W+3*T*L*L*W+3*I*I*O*D+3*M*O*O*D+L*I*I*B+2*L*M*O*B+2*A*I*O*B+T*O*O*B+L*L*O*F+L*L*I*N+2*A*L*O*N+L*L*M*U+2*A*L*I*U+A*A*O*U+2*T*L*O*U+L*L*L*j+3*A*L*L*V,3*A*L*L*W+3*I*O*O*D+2*L*I*O*B+A*O*O*B+L*L*O*N+L*L*I*U+2*A*L*O*U+L*L*L*V,L*L*L*W+O*O*O*D+L*O*O*B+L*L*O*U],.5);H=H.filter((e=>(0,d.isValidPercent)(e)));const q=[];for(const n of H){const o=(M*n*n+I*n+O)/(T*n*n+A*n+L);(0,d.isValidPercent)(o)&&q.push([(0,r.getQuadraticCurvePointAtPercent)(e.from,e.cp,e.to,o),(0,r.getBezierCurvePointAtPercent)(t.from,t.cp1,t.cp2,t.to,n)])}return q}function O(e,t){const[n,o,i]=(0,r.getBezierCurveDerivatives)(e),[s,c,l]=(0,r.getBezierCurveDerivatives)(t),u=e=>{const{x:t,y:r}=n(e[0]),{x:i,y:a}=o(e[0]),{x:l,y:u}=s(e[1]),{x:p,y:d}=c(e[1]);return[(t-l)*i+(r-u)*a,(l-t)*p+(u-r)*d]},p=e=>{const{x:t,y:r}=n(e[0]),{x:a,y:u}=o(e[0]),{x:p,y:d}=i(e[0]),{x:f,y:g}=s(e[1]),{x:h,y:m}=c(e[1]),{x:y,y:v}=l(e[1]);return[a*a+(t-f)*p+u*u+(r-g)*d,-h*a-m*u,-a*h-u*m,h*h+(f-t)*y+m*m+(g-r)*v]};let f=[];for(const e of[.25,.75])for(const t of[.25,.75]){const n=(0,a.newtonIterate2)([e,t],u,p,d.delta2);void 0!==n&&f.push(n)}return f=(0,d.deduplicate)(f,d.deepEquals),f.filter((e=>(0,d.isValidPercent)(e[0])&&(0,d.isValidPercent)(e[1]))).map((e=>[n(e[0]),s(e[1])]))}},2683:(e,t,n)=>{"use strict";function r(e){return new Promise((t=>{setTimeout((()=>{t()}),e)}))}n.r(t),n.d(t,{sleep:()=>r})},8638:(e,t,n)=>{"use strict";n.r(t),n.d(t,{getAngleSnapPosition:()=>i});var r=n(5773),o=n(1715);function i(e,t,n){if(n&&e){const i=(0,o.radianToAngle)((0,o.getTwoPointsRadian)(t,e)),a=n(i);void 0!==a&&a!==i&&(t=(0,r.rotatePositionByCenter)(t,e,i-a))}return t}},835:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Sphere:()=>E,getLineAndSphereIntersectionPoints:()=>P,getParallelSpheresByDistance:()=>_,getPerpendicularPointsToSphere:()=>k,getPlaneSphereIntersection:()=>R,getSphereNormalAtPoint:()=>S,getTwoSpheresIntersection:()=>T,pointIsOnSphere:()=>w});var r=n(2318),o=n(1475),i=n(2792),a=n(5147),s=n(4206),c=n(5773),l=n(360),u=n(2301),p=n(5569),d=Object.defineProperty,f=Object.defineProperties,g=Object.getOwnPropertyDescriptors,h=Object.getOwnPropertySymbols,m=Object.prototype.hasOwnProperty,y=Object.prototype.propertyIsEnumerable,v=Math.pow,x=(e,t,n)=>t in e?d(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,b=(e,t)=>{for(var n in t||(t={}))m.call(t,n)&&x(e,n,t[n]);if(h)for(var n of h(t))y.call(t,n)&&x(e,n,t[n]);return e},C=(e,t)=>f(e,g(t));const E=(0,p.and)(c.Position3D,{radius:p.number});function P([[e,t,n],[r,i,a]],{x:s,y:c,z:l,radius:u}){const p=v(u,2),d=r-e,f=i-t,g=a-n,h=e-s,m=t-c,y=n-l;return(0,o.calculateEquation2)(d*d+f*f+g*g,2*(h*d+m*f+y*g),h*h+m*m+y*y-p).map((e=>[d*e+h+s,f*e+m+c,g*e+y+l]))}function w(e,t){return(0,i.equals)((0,c.getTwoPointsDistance3D)((0,c.vec3ToPosition3D)(e),t),t.radius)}function k(e,t){const n=[e[0]-t.x,e[1]-t.y,e[2]-t.z];return[(0,c.getPointByLengthAndDirection3D)(e,t.radius,n),(0,c.getPointByLengthAndDirection3D)(e,-t.radius,n)]}function _(e,t){return(0,i.isZero)(t)?[e,e]:[C(b({},e),{radius:e.radius-t}),C(b({},e),{radius:e.radius+t})]}function S(e,t){return a.v3.substract(t,(0,c.position3DToVec3)(e))}function R(e,t){const n=(0,c.position3DToVec3)(t),o=(0,s.getPerpendicularPointToPlane)(n,e),i=a.v3.substract(o,n),p=Math.sqrt(v(t.radius,2)-a.v3.lengthSquare(i));if(isNaN(p))return;const d=[o,...(0,s.getCoordinate)(i)],f=(0,l.getCoordinateMatrix)(d);return f?(0,r.arcToPolyline)((0,r.circleToArc)({x:0,y:0,r:p}),5).map((e=>(0,u.slice3)(a.matrix.multiplyVec(f,(0,l.getCoordinateVec)([e.x,e.y,0],d))))):void 0}function T(e,t){const n=(0,c.position3DToVec3)(e),o=a.v3.substract((0,c.position3DToVec3)(t),n),i=a.v3.lengthSquare(o),p=Math.sqrt(i),d=(v(e.radius,2)+i-v(t.radius,2))/2/e.radius/p;if(d<-1||d>1)return;const f=e.radius*d,g=(0,c.getPointByLengthAndDirection3D)(n,f,o),h=Math.sqrt(v(e.radius,2)-v(f,2));if(isNaN(h))return;const m=[g,...(0,s.getCoordinate)(o)],y=(0,l.getCoordinateMatrix)(m);return y?(0,r.arcToPolyline)((0,r.circleToArc)({x:0,y:0,r:h}),5).map((e=>(0,u.slice3)(a.matrix.multiplyVec(y,(0,l.getCoordinateVec)([e.x,e.y,0],m))))):void 0}},5689:(e,t,n)=>{"use strict";n.r(t),n.d(t,{getArcTangentRadianAtRadian:()=>B,getBezierCurveTangentRadianAtPercent:()=>U,getCircleTangentRadianAtRadian:()=>D,getCirclesTangentTo2Circles:()=>w,getCirclesTangentTo2Lines:()=>E,getCirclesTangentTo3Circles:()=>A,getCirclesTangentTo3Lines:()=>S,getCirclesTangentToLineAndCircle:()=>P,getCirclesTangentToLineCircleCircle:()=>T,getCirclesTangentToLineLineCircle:()=>R,getEllipseArcTangentRadianAtRadian:()=>F,getEllipseTangentRadianAtRadian:()=>z,getLinesTangentTo2Circles:()=>k,getQuadraticCurveTangentRadianAtPercent:()=>N,getTangencyPointToBezierCurve:()=>O,getTangencyPointToCircle:()=>L,getTangencyPointToEllipse:()=>M,getTangencyPointToQuadraticCurve:()=>I,getTwoLinesCenterLines:()=>_});var r=n(1475),o=n(2792),i=n(5773),a=n(1715),s=n(8831),c=n(1796),l=n(2318),u=n(491),p=n(8392),d=Object.defineProperty,f=Object.defineProperties,g=Object.getOwnPropertyDescriptors,h=Object.getOwnPropertySymbols,m=Object.prototype.hasOwnProperty,y=Object.prototype.propertyIsEnumerable,v=Math.pow,x=(e,t,n)=>t in e?d(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,b=(e,t)=>{for(var n in t||(t={}))m.call(t,n)&&x(e,n,t[n]);if(h)for(var n of h(t))y.call(t,n)&&x(e,n,t[n]);return e},C=(e,t)=>f(e,g(t));function E(e,t,n){const r=[],o=(0,c.getParallelLinesByDistance)(e,n),i=(0,c.getParallelLinesByDistance)(t,n);for(const e of o)for(const t of i){const n=(0,u.getTwoGeneralFormLinesIntersectionPoint)(e,t);n&&r.push(n)}return r}function P(e,t,n){const r=[],o=(0,c.getParallelLinesByDistance)(e,n),i=[t.r+n,Math.abs(t.r-n)];for(const e of o)for(const n of i)r.push(...(0,u.getGeneralFormLineCircleIntersectionPoints)(e,C(b({},t),{r:n})));return r}function w(e,t,n){const r=[],o=[e.r+n,Math.abs(e.r-n)],i=[t.r+n,Math.abs(t.r-n)];for(const n of o)for(const o of i)r.push(...(0,u.getTwoCircleIntersectionPoints)(C(b({},e),{r:n}),C(b({},t),{r:o})));return r}function k(e,t){const n=[],r=t.r-e.r,s=(0,i.getTwoPointsDistance)(e,t);if((0,o.lessThan)(Math.abs(r),s)){const i=(0,a.getTwoPointsRadian)(t,e),c=Math.asin(r/s)+Math.PI/2,u=i-c,p=i+c;n.push([(0,l.getCirclePointAtRadian)(e,u),(0,l.getCirclePointAtRadian)(t,u)],[(0,l.getCirclePointAtRadian)(e,p),(0,l.getCirclePointAtRadian)(t,p)]);const d=e.r+t.r;if((0,o.lessThan)(d,s)){const r=Math.asin(d/s);n.push([(0,l.getCirclePointAtRadian)(e,i+r-Math.PI/2),(0,l.getCirclePointAtRadian)(t,i+r+Math.PI/2)],[(0,l.getCirclePointAtRadian)(e,i-r+Math.PI/2),(0,l.getCirclePointAtRadian)(t,i-r-Math.PI/2)])}}return n}function _(e,t){const n=(0,c.getGeneralFormLineRadian)(e),r=(0,c.getGeneralFormLineRadian)(t),a=(0,u.getTwoGeneralFormLinesIntersectionPoint)(e,t);if(!a){const r=(0,c.generalFormLineToTwoPointLine)(e)[0],o=(0,c.generalFormLineToTwoPointLine)(t)[0];return[(0,c.pointAndDirectionToGeneralFormLine)((0,i.getTwoPointCenter)(r,o),n)]}const s=(0,o.getTwoNumberCenter)(n,r);return[s,s+Math.PI/2].map((e=>(0,c.pointAndDirectionToGeneralFormLine)(a,e)))}function S(e,t,n){const r=[],o=_(e,t),i=_(e,n);for(const t of o)for(const n of i){const o=(0,u.getTwoGeneralFormLinesIntersectionPoint)(t,n);o&&r.push(C(b({},o),{r:(0,p.getPerpendicularDistance)(o,e)}))}return r}function R(e,t,{x:n,y:i,r:a}){const s=[],c=_(e,t),{a:l,b:u,c:p}=e,d=v(l,2)+v(u,2),f=Math.sqrt(d),g=l/f,h=u/f,m=g*n+h*i+p/f,y=g*g,x=h*h,b=2*g*h,C=2*g*m,E=2*h*m,P=m*m,w=1-y,k=1-x,S=a*a,R=S+P;for(const{a:e,b:t,c:a}of c){const c=e*n+t*i+a;if((0,o.isZero)(t)){const t=-c/e,o=-b*t-E,a=w*t*t+-C*t-R,l=4*x*S,u=-4*b*S*t+-4*E*S,p=-4*y*S*t*t+-4*C*S*t+-4*P*S,d=(0,r.calculateEquation4)(k*k,2*k*o,o*o+2*k*a-l,2*o*a+u,a*a+p);s.push(...d.map((e=>({x:t+n,y:e+i,r:Math.abs(g*t+h*e+m)}))))}else{const o=-e/t,a=c/t,l=-b*o+k*o*o+w,u=b*a-C+-2*k*o*a+-E*o,p=k*a*a+E*a-R,d=-4*x*S*o*o+-4*b*S*o+-4*y*S,f=8*x*S*o*a+-4*E*S*o+4*b*S*a+-4*C*S,v=-4*x*S*a*a+4*E*S*a+-4*P*S,_=(0,r.calculateEquation4)(l*l,2*l*u,u*u+2*l*p+d,2*u*p+f,p*p+v);s.push(..._.map((e=>{const t=o*e-a;return{x:e+n,y:t+i,r:Math.abs(g*e+h*t+m)}})))}}return s}function T({a:e,b:t,c:n},{x:i,y:a,r:s},{x:c,y:l,r:u}){const p=[],d=v(e,2)+v(t,2),f=Math.sqrt(d),g=e/f,h=t/f,m=i-c,y=a-l,x=g*i+h*a+n/f;for(const e of[1,-1]){const t=e*g,n=e*h,c=1-t*t,l=1-n*n;for(const d of[s,-s]){const s=e*x+d;for(const e of[u,-u]){const u=d-e,f=u*t+m,g=u*n+y,h=u*s+(m*m+y*y-u*u)/2;if((0,o.isZero)(g)){const e=-h/f,u=(0,r.calculateEquation2)(l,-2*t*n*e+-2*n*s,-2*t*s*e+-1*s*s+c*e*e);for(const r of u){const c=t*e+n*r+s-d;(0,o.largerThan)(c,0)&&p.push({x:e+i,y:r+a,r:c})}continue}const v=-f/g,x=-h/g,b=(0,r.calculateEquation2)(-2*t*n*v+v*v*l+c,-2*n*s*v+-2*t*n*x+2*v*x*l+-2*t*s,-2*n*s*x+-1*s*s+x*x*l);for(const e of b){const r=v*e+x,c=t*e+n*r+s-d;(0,o.largerThan)(c,0)&&p.push({x:e+i,y:r+a,r:c})}}}}return p}function A({x:e,y:t,r:n},{x:i,y:a,r:s},{x:c,y:l,r:u}){const p=[],d=e-i,f=e-c,g=t-a,h=t-l;for(const i of[n,-n])for(const n of[s,-s])for(const a of[u,-u]){const s=n-i,c=a-i,l=(d*d+g*g+-s*s)/2,u=(f*f+h*h+-c*c)/2;if((0,o.isZero)(g)){if((0,o.isZero)(h)){const n=(c*l-s*u)/(f*s-d*c),r=(0,o.isZero)(s)?(f*n+u)/c:(d*n+l)/s,a=r-i;if((0,o.largerThan)(a,0)){const i=r*r-n*n;if((0,o.isZero)(i))p.push({x:n+e,y:t,r:a});else if((0,o.largerThan)(i,0)){const r=Math.sqrt(i);p.push({x:n+e,y:r+t,r:a},{x:n+e,y:-r+t,r:a})}}continue}const n=f*f+h*h,a=c*c-h*h,g=(0,r.calculateEquation2)(-2*d*f*s*c+s*s*n+d*d*a,-2*f*s*c*l+2*f*s*s*u+-2*d*s*c*u+2*d*l*a,-2*s*c*l*u+s*s*u*u+l*l*a);for(const n of g){const r=(0,o.isZero)(s)?(f*n+u)/c:(d*n+l)/s,a=r-i;if((0,o.largerThan)(a,0)){const o=(c*r-f*n-u)/h;p.push({x:n+e,y:o+t,r:a})}}continue}const m=-f*g+d*h,y=-h*s+g*c,v=h*l+-g*u,x=d*d+g*g,b=-g*g+s*s;if((0,o.isZero)(y)){const n=-v/m,a=(0,r.calculateEquation2)(b,-2*d*s*n+-2*s*l,2*d*l*n+l*l+x*n*n);for(const r of a){const a=r-i;if((0,o.largerThan)(a,0)){const o=(s*r-d*n-l)/g;p.push({x:n+e,y:o+t,r:a})}}continue}const C=(0,r.calculateEquation2)(2*d*s*m*y+y*y*x+m*m*b,2*s*l*m*y+2*d*l*y*y+2*d*s*y*v+2*m*v*b,l*l*y*y+2*s*l*y*v+v*v*b);for(const n of C){const r=(-m*n-v)/y,a=r-i;if((0,o.largerThan)(a,0)){const o=(s*r-d*n-l)/g;p.push({x:n+e,y:o+t,r:a})}}}return p}function L({x:e,y:t},{x:n,y:r,r:i}){const a=v(i,2),s=n-e,c=r-t,l=v(s,2)+v(c,2),u=l-a;if((0,o.lessThan)(u,0))return[];const p=n+-s*a/l,d=r+-c*a/l;if((0,o.isZero)(u))return[{x:p,y:d}];const f=i*Math.sqrt(u)/l,g=c*f,h=s*f;return[{x:p+g,y:d-h},{x:p-g,y:d+h}]}function M({x:e,y:t},{cx:n,cy:i,rx:s,ry:c,angle:l},u=o.delta2){const p=(0,a.angleToRadian)(l),d=Math.sin(p),f=Math.cos(p),g=n-e,h=i-t,m=s*s,y=c*c,v=f*f*m+d*d*y,x=(-2*d*f*m+2*d*f*y)/v,b=(d*d*m+f*f*y)/v,C=-m*y/v,E=-g*g;let P,w,k,_,S,R,T=2*g*h,A=-2*d*f*g*m+2*f*f*h*m+2*d*f*g*y+2*d*d*h*y,L=-h*h,M=2*d*d*g*m+-2*d*f*h*m+2*f*f*g*y+2*d*f*h*y,I=d*d*g*g*m+-2*d*f*g*h*m+f*f*h*h*m+f*f*g*g*y+2*d*f*g*h*y+d*d*h*h*y+m*y;if((0,o.isZero)(g,u))P=L*L+-T*L*x+T*T*b,w=2*L*M+-A*L*x+-T*M*x+2*T*A*b,k=M*M+2*L*I+-A*M*x+-T*I*x+A*A*b+T*T*C,_=2*M*I+-A*I*x+2*T*A*C,S=I*I+A*A*C,R=e=>{const t=T*e+A;return(0,o.isZero)(t,u)?(0,r.calculateEquation2)(1,x*e,b*e*e+C,u)[0]:-(L*e*e+M*e+I)/t};else{T/=E,A/=E,L/=E,M/=E,I/=E;const e=T-x,t=L-b,n=I-C;P=b*e*e+t*t+-x*e*t,w=-M*x*e+2*A*b*e+2*M*t+-A*x*t,k=-A*M*x+A*A*b+C*e*e+-x*e*n+M*M+2*t*n,_=2*A*C*e+-A*x*n+2*M*n,S=A*A*C+n*n,R=i=>{const a=e*i+A;return(0,o.isZero)(a,u)?(0,r.calculateEquation2)(1,x*i,b*i*i+C,u)[0]:-(t*i*i+M*i+n)/a}}return(0,r.calculateEquation4)(P,w,k,_,S,u).map((e=>{const t=R(e);return{x:e+n,y:t+i}}))}function I({x:e,y:t},{from:{x:n,y:i},cp:{x:a,y:s},to:{x:c,y:l}},u=o.delta2){const p=a-n,d=c-a-p,f=s-i,g=l-s-f,h=n-e,m=i-t;return(0,r.calculateEquation2)(p*g-d*f,h*g-m*d,h*f-m*p,u).filter((e=>(0,o.isValidPercent)(e))).map((e=>({x:d*e*e+2*p*e+n,y:g*e*e+2*f*e+i})))}function O({x:e,y:t},{from:{x:n,y:i},cp1:{x:a,y:s},cp2:{x:c,y:l},to:{x:u,y:p}},d=o.delta2){const f=3*a-n+-3*c+u,g=3*(n-2*a+c),h=3*(a-n),m=3*s-i+-3*l+p,y=3*(i-2*s+l),v=3*(s-i),x=i-t,b=n-e;return(0,r.calculateEquation4)(g*m-f*y,2*(h*m+-f*v),h*y+-g*v+-3*f*x+3*m*b,2*(y*b-g*x),v*b-h*x,d).filter((e=>(0,o.isValidPercent)(e))).map((e=>({x:f*e*e*e+g*e*e+h*e+n,y:m*e*e*e+y*e*e+v*e+i})))}function D(e,t){return(0,s.normalizeRadian)(t+Math.PI/2)}function B(e,t){return(0,s.normalizeRadian)(t+Math.PI/2*(e.counterclockwise?-1:1))}function z(e,t){const{rx:n,ry:r,angle:o}=e,i=(0,a.angleToRadian)(o),s=Math.sin(i),c=Math.cos(i),l=Math.cos(t)*r,u=Math.sin(t)*n;return Math.atan2(l*c-s*u,-l*s-c*u)}function F(e,t){return(0,s.normalizeRadian)(z(e,t)+(e.counterclockwise?Math.PI:0))}function N({from:{x:e,y:t},cp:{x:n,y:r},to:{x:o,y:i}},a){const s=n-e,c=o-n-s,l=r-t,u=i-r-l;return Math.atan2(u*a+l,c*a+s)}function U({from:{x:e,y:t},cp1:{x:n,y:r},cp2:{x:o,y:i},to:{x:a,y:s}},c){const l=3*n-e+-3*o+a,u=3*(e-2*n+o),p=3*(n-e),d=3*r-t+-3*i+s,f=3*(t-2*r+i),g=3*(r-t);return Math.atan2(3*d*v(c,2)+2*f*c+g,3*l*v(c,2)+2*u*c+p)}},4088:(e,t,n)=>{"use strict";n.r(t),n.d(t,{getLineTangentToTwoGeometryLinesNearParam:()=>g,getLinesTangentTo2BezierCurves:()=>T,getLinesTangentTo2EllipseArcs:()=>b,getLinesTangentTo2GeometryLines:()=>f,getLinesTangentTo2Hyperbolas:()=>M,getLinesTangentTo2QuadraticCurves:()=>k,getLinesTangentToArcAndBezierCurve:()=>y,getLinesTangentToArcAndEllipseArc:()=>h,getLinesTangentToArcAndHyperbola:()=>v,getLinesTangentToArcAndNurbsCurve:()=>x,getLinesTangentToArcAndQuadraticCurve:()=>m,getLinesTangentToBezierCurveAndHyperbola:()=>A,getLinesTangentToBezierCurveAndNurbsCurve:()=>L,getLinesTangentToEllipseArcAndBezierCurve:()=>E,getLinesTangentToEllipseArcAndHyperbola:()=>P,getLinesTangentToEllipseArcAndNurbsCurve:()=>w,getLinesTangentToEllipseArcAndQuadraticCurve:()=>C,getLinesTangentToHyperbolaAndNurbsCurve:()=>I,getLinesTangentToQuadraticCurveAndBezierCurve:()=>_,getLinesTangentToQuadraticCurveAndHyperbola:()=>S,getLinesTangentToQuadraticCurveAndNurbsCurve:()=>R,getLinesTangentToTwoNurbsCurves:()=>O});var r=n(8831),o=n(5629),i=n(2318),a=n(2298),s=n(1475),c=n(5717),l=n(2986),u=n(2792),p=n(8230),d=n(5689);function f(e,t){return Array.isArray(e)||"ray"===e.type||Array.isArray(t)||"ray"===t.type?[]:"arc"===e.type?"arc"===t.type?(0,d.getLinesTangentTo2Circles)(e.curve,t.curve):"ellipse arc"===t.type?h(e.curve,t.curve):"quadratic curve"===t.type?m(e.curve,t.curve):"bezier curve"===t.type?y(e.curve,t.curve):"hyperbola curve"===t.type?v(e.curve,t.curve):x(e.curve,t.curve):"arc"===t.type?f(t,e):"ellipse arc"===e.type?"ellipse arc"===t.type?b(e.curve,t.curve):"quadratic curve"===t.type?C(e.curve,t.curve):"bezier curve"===t.type?E(e.curve,t.curve):"hyperbola curve"===t.type?P(e.curve,t.curve):w(e.curve,t.curve):"ellipse arc"===t.type?f(t,e):"quadratic curve"===e.type?"quadratic curve"===t.type?k(e.curve,t.curve):"bezier curve"===t.type?_(e.curve,t.curve):"hyperbola curve"===t.type?S(e.curve,t.curve):R(e.curve,t.curve):"quadratic curve"===t.type?f(t,e):"bezier curve"===e.type?"bezier curve"===t.type?T(e.curve,t.curve):"hyperbola curve"===t.type?A(e.curve,t.curve):L(e.curve,t.curve):"bezier curve"===t.type?f(t,e):"hyperbola curve"===e.type?"hyperbola curve"===t.type?M(e.curve,t.curve):I(e.curve,t.curve):"hyperbola curve"===t.type?f(t,e):O(e.curve,t.curve)}function g(e,t,n,r){const o=(0,c.getGeometryLineDerivatives)(e),i=(0,c.getGeometryLineDerivatives)(t);return(0,s.newtonIterate2)([n,r],(e=>{const[{x:t,y:n},{x:r,y:a}]=o[0](e[0]),[{x:s,y:c},{x:l,y:u}]=i[0](e[1]);return[(n-c)*r-(t-s)*a,a*l-r*u]}),(e=>{const[{x:t,y:n},{x:r,y:a},{x:s,y:c}]=o[1](e[0]),[{x:l,y:u},{x:p,y:d},{x:f,y:g}]=i[1](e[1]);return[a*r+(n-u)*s-(r*a+(t-l)*c),-d*r+p*a,c*p-s*d,a*f-r*g]}),u.delta2)}function h(e,t){const[n,o,c]=(0,i.getCircleDerivatives)(e),[l,p,d]=(0,a.getEllipseDerivatives)(t),f=e=>{const{x:t,y:r}=n(e[0]),{x:i,y:a}=o(e[0]),{x:s,y:c}=l(e[1]),{x:u,y:d}=p(e[1]);return[(r-c)*i-(t-s)*a,a*u-i*d]},g=e=>{const{x:t,y:r}=n(e[0]),{x:i,y:a}=o(e[0]),{x:s,y:u}=c(e[0]),{x:f,y:g}=l(e[1]),{x:h,y:m}=p(e[1]),{x:y,y:v}=d(e[1]);return[a*i+(r-g)*s-(i*a+(t-f)*u),-m*i+h*a,u*h-s*m,a*y-i*v]};let h=[];for(const e of[-Math.PI/2,Math.PI/2])for(const t of[-Math.PI/2,Math.PI/2]){const n=(0,s.newtonIterate2)([e,t],f,g,u.delta2);void 0!==n&&h.push(n)}return h=(0,u.deduplicate)(h,u.deepEquals),h.filter((n=>(0,r.angleInRange)(n[0],e)&&(0,r.angleInRange)(n[1],t))).map((e=>[n(e[0]),l(e[1])]))}function m(e,t){const[n,a,c]=(0,i.getCircleDerivatives)(e),[l,p,d]=(0,o.getQuadraticCurveDerivatives)(t),f=e=>{const{x:t,y:r}=n(e[0]),{x:o,y:i}=a(e[0]),{x:s,y:c}=l(e[1]),{x:u,y:d}=p(e[1]);return[(r-c)*o-(t-s)*i,i*u-o*d]},g=e=>{const{x:t,y:r}=n(e[0]),{x:o,y:i}=a(e[0]),{x:s,y:u}=c(e[0]),{x:f,y:g}=l(e[1]),{x:h,y:m}=p(e[1]),{x:y,y:v}=d(e[1]);return[i*o+(r-g)*s-(o*i+(t-f)*u),-m*o+h*i,u*h-s*m,i*y-o*v]};let h=[];for(const e of[-Math.PI/2,Math.PI/2])for(const t of[.25,.75]){const n=(0,s.newtonIterate2)([e,t],f,g,u.delta2);void 0!==n&&h.push(n)}return h=(0,u.deduplicate)(h,u.deepEquals),h.filter((t=>(0,r.angleInRange)(t[0],e)&&(0,u.isValidPercent)(t[1]))).map((e=>[n(e[0]),l(e[1])]))}function y(e,t){const[n,a,c]=(0,i.getCircleDerivatives)(e),[l,p,d]=(0,o.getBezierCurveDerivatives)(t),f=e=>{const{x:t,y:r}=n(e[0]),{x:o,y:i}=a(e[0]),{x:s,y:c}=l(e[1]),{x:u,y:d}=p(e[1]);return[(r-c)*o-(t-s)*i,i*u-o*d]},g=e=>{const{x:t,y:r}=n(e[0]),{x:o,y:i}=a(e[0]),{x:s,y:u}=c(e[0]),{x:f,y:g}=l(e[1]),{x:h,y:m}=p(e[1]),{x:y,y:v}=d(e[1]);return[i*o+(r-g)*s-(o*i+(t-f)*u),-m*o+h*i,u*h-s*m,i*y-o*v]};let h=[];for(const e of[-Math.PI/2,Math.PI/2])for(const t of[0,.5,1]){const n=(0,s.newtonIterate2)([e,t],f,g,u.delta2);void 0!==n&&h.push(n)}return h=(0,u.deduplicate)(h,u.deepEquals),h.filter((t=>(0,r.angleInRange)(t[0],e)&&(0,u.isValidPercent)(t[1]))).map((e=>[n(e[0]),l(e[1])]))}function v(e,t){const[n,o,a]=(0,i.getCircleDerivatives)(e),[c,p,d]=(0,l.getHyperbolaDerivatives)(t),f=e=>{const{x:t,y:r}=n(e[0]),{x:i,y:a}=o(e[0]),{x:s,y:l}=c(e[1]),{x:u,y:d}=p(e[1]);return[(r-l)*i-(t-s)*a,a*u-i*d]},g=e=>{const{x:t,y:r}=n(e[0]),{x:i,y:s}=o(e[0]),{x:l,y:u}=a(e[0]),{x:f,y:g}=c(e[1]),{x:h,y:m}=p(e[1]),{x:y,y:v}=d(e[1]);return[s*i+(r-g)*l-(i*s+(t-f)*u),-m*i+h*s,u*h-l*m,s*y-i*v]};let h=[];for(const e of[-Math.PI/2,Math.PI/2]){const t=(0,s.newtonIterate2)([e,0],f,g,u.delta2);void 0!==t&&h.push(t)}return h=(0,u.deduplicate)(h,u.deepEquals),h.filter((n=>(0,r.angleInRange)(n[0],e)&&(0,u.isBetween)(n[1],t.t1,t.t2))).map((e=>[n(e[0]),c(e[1])]))}function x(e,t){const[n,o,a]=(0,i.getCircleDerivatives)(e),c=(0,p.toVerbNurbsCurve)(t),l=e=>{const{x:t,y:r}=n(e[0]),{x:i,y:a}=o(e[0]),[[s,l],[u,p]]=c.derivatives(e[1]);return[(r-l)*i-(t-s)*a,a*u-i*p]},d=e=>{const{x:t,y:r}=n(e[0]),{x:i,y:s}=o(e[0]),{x:l,y:u}=a(e[0]),[[p,d],[f,g],[h,m]]=c.derivatives(e[1],2);return[s*i+(r-d)*l-(i*s+(t-p)*u),-g*i+f*s,u*f-l*g,s*h-i*m]};let f=[];const g=(0,p.getNurbsMaxParam)(t);for(const e of[-Math.PI/2,Math.PI/2])for(let t=.5;t(0,r.angleInRange)(t[0],e)&&(0,u.isBetween)(t[1],0,g))).map((e=>[n(e[0]),(0,p.fromVerbPoint)(c.point(e[1]))]))}function b(e,t){const[n,o,i]=(0,a.getEllipseDerivatives)(e),[c,l,p]=(0,a.getEllipseDerivatives)(t),d=e=>{const{x:t,y:r}=n(e[0]),{x:i,y:a}=o(e[0]),{x:s,y:u}=c(e[1]),{x:p,y:d}=l(e[1]);return[(r-u)*i-(t-s)*a,a*p-i*d]},f=e=>{const{x:t,y:r}=n(e[0]),{x:a,y:s}=o(e[0]),{x:u,y:d}=i(e[0]),{x:f,y:g}=c(e[1]),{x:h,y:m}=l(e[1]),{x:y,y:v}=p(e[1]);return[s*a+(r-g)*u-(a*s+(t-f)*d),-m*a+h*s,d*h-u*m,s*y-a*v]};let g=[];for(const e of[-Math.PI/2,Math.PI/2])for(const t of[-Math.PI/2,Math.PI/2]){const n=(0,s.newtonIterate2)([e,t],d,f,u.delta2);void 0!==n&&g.push(n)}return g=(0,u.deduplicate)(g,u.deepEquals),g.filter((n=>(0,r.angleInRange)(n[0],e)&&(0,r.angleInRange)(n[1],t))).map((e=>[n(e[0]),c(e[1])]))}function C(e,t){const[n,i,c]=(0,a.getEllipseDerivatives)(e),[l,p,d]=(0,o.getQuadraticCurveDerivatives)(t),f=e=>{const{x:t,y:r}=n(e[0]),{x:o,y:a}=i(e[0]),{x:s,y:c}=l(e[1]),{x:u,y:d}=p(e[1]);return[(r-c)*o-(t-s)*a,a*u-o*d]},g=e=>{const{x:t,y:r}=n(e[0]),{x:o,y:a}=i(e[0]),{x:s,y:u}=c(e[0]),{x:f,y:g}=l(e[1]),{x:h,y:m}=p(e[1]),{x:y,y:v}=d(e[1]);return[a*o+(r-g)*s-(o*a+(t-f)*u),-m*o+h*a,u*h-s*m,a*y-o*v]};let h=[];for(const e of[-Math.PI/2,Math.PI/2])for(const t of[.25,.75]){const n=(0,s.newtonIterate2)([e,t],f,g,u.delta2);void 0!==n&&h.push(n)}return h=(0,u.deduplicate)(h,u.deepEquals),h.filter((t=>(0,r.angleInRange)(t[0],e)&&(0,u.isValidPercent)(t[1]))).map((e=>[n(e[0]),l(e[1])]))}function E(e,t){const[n,i,c]=(0,a.getEllipseDerivatives)(e),[l,p,d]=(0,o.getBezierCurveDerivatives)(t),f=e=>{const{x:t,y:r}=n(e[0]),{x:o,y:a}=i(e[0]),{x:s,y:c}=l(e[1]),{x:u,y:d}=p(e[1]);return[(r-c)*o-(t-s)*a,a*u-o*d]},g=e=>{const{x:t,y:r}=n(e[0]),{x:o,y:a}=i(e[0]),{x:s,y:u}=c(e[0]),{x:f,y:g}=l(e[1]),{x:h,y:m}=p(e[1]),{x:y,y:v}=d(e[1]);return[a*o+(r-g)*s-(o*a+(t-f)*u),-m*o+h*a,u*h-s*m,a*y-o*v]};let h=[];for(const e of[-Math.PI/2,Math.PI/2])for(const t of[0,.5,1]){const n=(0,s.newtonIterate2)([e,t],f,g,u.delta2);void 0!==n&&h.push(n)}return h=(0,u.deduplicate)(h,u.deepEquals),h.filter((t=>(0,r.angleInRange)(t[0],e)&&(0,u.isValidPercent)(t[1]))).map((e=>[n(e[0]),l(e[1])]))}function P(e,t){const[n,o,i]=(0,a.getEllipseDerivatives)(e),[c,p,d]=(0,l.getHyperbolaDerivatives)(t),f=e=>{const{x:t,y:r}=n(e[0]),{x:i,y:a}=o(e[0]),{x:s,y:l}=c(e[1]),{x:u,y:d}=p(e[1]);return[(r-l)*i-(t-s)*a,a*u-i*d]},g=e=>{const{x:t,y:r}=n(e[0]),{x:a,y:s}=o(e[0]),{x:l,y:u}=i(e[0]),{x:f,y:g}=c(e[1]),{x:h,y:m}=p(e[1]),{x:y,y:v}=d(e[1]);return[s*a+(r-g)*l-(a*s+(t-f)*u),-m*a+h*s,u*h-l*m,s*y-a*v]};let h=[];for(const e of[-Math.PI/2,Math.PI/2]){const t=(0,s.newtonIterate2)([e,0],f,g,u.delta2);void 0!==t&&h.push(t)}return h=(0,u.deduplicate)(h,u.deepEquals),h.filter((n=>(0,r.angleInRange)(n[0],e)&&(0,u.isBetween)(n[1],t.t1,t.t2))).map((e=>[n(e[0]),c(e[1])]))}function w(e,t){const[n,o,i]=(0,a.getEllipseDerivatives)(e),c=(0,p.toVerbNurbsCurve)(t),l=e=>{const{x:t,y:r}=n(e[0]),{x:i,y:a}=o(e[0]),[[s,l],[u,p]]=c.derivatives(e[1]);return[(r-l)*i-(t-s)*a,a*u-i*p]},d=e=>{const{x:t,y:r}=n(e[0]),{x:a,y:s}=o(e[0]),{x:l,y:u}=i(e[0]),[[p,d],[f,g],[h,m]]=c.derivatives(e[1],2);return[s*a+(r-d)*l-(a*s+(t-p)*u),-g*a+f*s,u*f-l*g,s*h-a*m]};let f=[];const g=(0,p.getNurbsMaxParam)(t);for(const e of[-Math.PI/2,Math.PI/2])for(let t=.5;t(0,r.angleInRange)(t[0],e)&&(0,u.isBetween)(t[1],0,g))).map((e=>[n(e[0]),(0,p.fromVerbPoint)(c.point(e[1]))]))}function k(e,t){const{from:{x:n,y:r},cp:{x:i,y:a},to:{x:c,y:l}}=e,p=i-n,d=c-i-p,f=a-r,g=l-a-f,{from:{x:h,y:m},cp:{x:y,y:v},to:{x,y:b}}=t,C=y-h,E=x-y-C,P=v-m,w=b-v-P,k=g*E-d*w,_=g*C-d*P,S=f*E-p*w,R=f*C-p*P,T=n-h,A=r-m,L=d*f-p*g,M=-d*w+g*E,I=2*g*C-2*d*P,O=d*A-g*T,D=f*E-p*w,B=-2*p*P+2*f*C,z=-f*T+p*A;let F=(0,s.calculateEquation4)(D*k*k-M*k*S,B*k*k+2*D*k*_+-I*k*S+-M*_*S-M*k*R,z*k*k+L*S*S+2*B*k*_+D*_*_+-O*k*S+-I*_*S-I*k*R-M*_*R,2*L*S*R+2*z*k*_+B*_*_+-O*_*S-O*k*R-I*_*R,L*R*R+z*_*_-O*_*R);F=F.filter((e=>(0,u.isValidPercent)(e)));const N=[];for(const n of F){const r=-(S*n+R)/(k*n+_);(0,u.isValidPercent)(r)&&N.push([(0,o.getQuadraticCurvePointAtPercent)(e.from,e.cp,e.to,r),(0,o.getQuadraticCurvePointAtPercent)(t.from,t.cp,t.to,n)])}return N}function _(e,t){const{from:{x:n,y:r},cp:{x:i,y:a},to:{x:c,y:l}}=e,p=i-n,d=c-i-p,f=a-r,g=l-a-f,{from:{x:h,y:m},cp1:{x:y,y:v},cp2:{x,y:b},to:{x:C,y:E}}=t,P=3*y-h+-3*x+C,w=3*(h-2*y+x),k=3*(y-h),_=3*v-m+-3*b+E,S=3*(m-2*v+b),R=3*(v-m),T=3*P*g-3*_*d,A=-2*S*d+2*w*g,L=-R*d+k*g,M=3*_*p-3*P*f,I=2*S*p-2*w*f,O=R*p-k*f,D=r-m,B=n-h,z=d*f-p*g,F=-_*d+P*g,N=-S*d+w*g,U=-R*d+k*g,G=d*D-g*B,j=-_*p+P*f,V=-S*p+w*f,W=-R*p+k*f,H=p*D-f*B;let q=(0,s.calculateEquation5)([T*M*F+T*T*j,A*M*F+T*I*F+T*M*N+2*T*A*j+T*T*V,L*M*F+A*I*F+T*O*F+A*M*N+T*I*N+T*M*U+A*A*j+2*T*L*j+2*T*A*V+T*T*W,M*M*z+L*I*F+A*O*F+L*M*N+A*I*N+T*O*N+A*M*U+T*I*U+T*M*G+2*A*L*j+A*A*V+2*T*L*V+2*T*A*W+T*T*H,2*M*I*z+L*O*F+L*I*N+A*O*N+L*M*U+A*I*U+T*O*U+A*M*G+T*I*G+L*L*j+2*A*L*V+A*A*W+2*T*L*W+2*T*A*H,I*I*z+2*M*O*z+L*O*N+L*I*U+A*O*U+L*M*G+A*I*G+T*O*G+L*L*V+2*A*L*W+A*A*H+2*T*L*H,2*I*O*z+L*O*U+L*I*G+A*O*G+L*L*W+2*A*L*H,O*O*z+L*O*G+L*L*H],.5);q=q.filter((e=>(0,u.isValidPercent)(e)));const $=[];for(const n of q){const r=(M*n*n+I*n+O)/(T*n*n+A*n+L);(0,u.isValidPercent)(r)&&$.push([(0,o.getQuadraticCurvePointAtPercent)(e.from,e.cp,e.to,r),(0,o.getBezierCurvePointAtPercent)(t.from,t.cp1,t.cp2,t.to,n)])}return $}function S(e,t){const[n,r,i]=(0,o.getQuadraticCurveDerivatives)(e),[a,c,p]=(0,l.getHyperbolaDerivatives)(t),d=e=>{const{x:t,y:o}=n(e[0]),{x:i,y:s}=r(e[0]),{x:l,y:u}=a(e[1]),{x:p,y:d}=c(e[1]);return[(o-u)*i-(t-l)*s,s*p-i*d]},f=e=>{const{x:t,y:o}=n(e[0]),{x:s,y:l}=r(e[0]),{x:u,y:d}=i(e[0]),{x:f,y:g}=a(e[1]),{x:h,y:m}=c(e[1]),{x:y,y:v}=p(e[1]);return[l*s+(o-g)*u-(s*l+(t-f)*d),-m*s+h*l,d*h-u*m,l*y-s*v]};let g=[];for(const e of[.25,.75]){const t=(0,s.newtonIterate2)([e,0],d,f,u.delta2);void 0!==t&&g.push(t)}return g=(0,u.deduplicate)(g,u.deepEquals),g.filter((e=>(0,u.isValidPercent)(e[0])&&(0,u.isBetween)(e[1],t.t1,t.t2))).map((e=>[n(e[0]),a(e[1])]))}function R(e,t){const[n,r,i]=(0,o.getQuadraticCurveDerivatives)(e),a=(0,p.toVerbNurbsCurve)(t),c=e=>{const{x:t,y:o}=n(e[0]),{x:i,y:s}=r(e[0]),[[c,l],[u,p]]=a.derivatives(e[1]);return[(o-l)*i-(t-c)*s,s*u-i*p]},l=e=>{const{x:t,y:o}=n(e[0]),{x:s,y:c}=r(e[0]),{x:l,y:u}=i(e[0]),[[p,d],[f,g],[h,m]]=a.derivatives(e[1],2);return[c*s+(o-d)*l-(s*c+(t-p)*u),-g*s+f*c,u*f-l*g,c*h-s*m]};let d=[];const f=(0,p.getNurbsMaxParam)(t);for(const e of[.25,.75])for(let t=.5;t(0,u.isValidPercent)(e[0])&&(0,u.isBetween)(e[1],0,f))).map((e=>[n(e[0]),(0,p.fromVerbPoint)(a.point(e[1]))]))}function T(e,t){const[n,r,i]=(0,o.getBezierCurveDerivatives)(e),[a,c,l]=(0,o.getBezierCurveDerivatives)(t),p=e=>{const{x:t,y:o}=n(e[0]),{x:i,y:s}=r(e[0]),{x:l,y:u}=a(e[1]),{x:p,y:d}=c(e[1]);return[(o-u)*i-(t-l)*s,s*p-i*d]},d=e=>{const{x:t,y:o}=n(e[0]),{x:s,y:u}=r(e[0]),{x:p,y:d}=i(e[0]),{x:f,y:g}=a(e[1]),{x:h,y:m}=c(e[1]),{x:y,y:v}=l(e[1]);return[u*s+(o-g)*p-(s*u+(t-f)*d),-m*s+h*u,d*h-p*m,u*y-s*v]};let f=[];for(const e of[.25,.5,.75])for(const t of[.25,.5,.75]){const n=(0,s.newtonIterate2)([e,t],p,d,u.delta2);void 0!==n&&f.push(n)}return f=(0,u.deduplicate)(f,u.deepEquals),f.filter((e=>(0,u.isValidPercent)(e[0])&&(0,u.isValidPercent)(e[1]))).map((e=>[n(e[0]),a(e[1])]))}function A(e,t){const[n,r,i]=(0,o.getBezierCurveDerivatives)(e),[a,c,p]=(0,l.getHyperbolaDerivatives)(t),d=e=>{const{x:t,y:o}=n(e[0]),{x:i,y:s}=r(e[0]),{x:l,y:u}=a(e[1]),{x:p,y:d}=c(e[1]);return[(o-u)*i-(t-l)*s,s*p-i*d]},f=e=>{const{x:t,y:o}=n(e[0]),{x:s,y:l}=r(e[0]),{x:u,y:d}=i(e[0]),{x:f,y:g}=a(e[1]),{x:h,y:m}=c(e[1]),{x:y,y:v}=p(e[1]);return[l*s+(o-g)*u-(s*l+(t-f)*d),-m*s+h*l,d*h-u*m,l*y-s*v]};let g=[];for(const e of[.25,.5,.75]){const t=(0,s.newtonIterate2)([e,0],d,f,u.delta2);void 0!==t&&g.push(t)}return g=(0,u.deduplicate)(g,u.deepEquals),g.filter((e=>(0,u.isValidPercent)(e[0])&&(0,u.isBetween)(e[1],t.t1,t.t2))).map((e=>[n(e[0]),a(e[1])]))}function L(e,t){const[n,r,i]=(0,o.getBezierCurveDerivatives)(e),a=(0,p.toVerbNurbsCurve)(t),c=e=>{const{x:t,y:o}=n(e[0]),{x:i,y:s}=r(e[0]),[[c,l],[u,p]]=a.derivatives(e[1]);return[(o-l)*i-(t-c)*s,s*u-i*p]},l=e=>{const{x:t,y:o}=n(e[0]),{x:s,y:c}=r(e[0]),{x:l,y:u}=i(e[0]),[[p,d],[f,g],[h,m]]=a.derivatives(e[1],2);return[c*s+(o-d)*l-(s*c+(t-p)*u),-g*s+f*c,u*f-l*g,c*h-s*m]};let d=[];const f=(0,p.getNurbsMaxParam)(t);for(const e of[.25,.5,.75])for(let t=.5;t(0,u.isValidPercent)(e[0])&&(0,u.isBetween)(e[1],0,f))).map((e=>[n(e[0]),(0,p.fromVerbPoint)(a.point(e[1]))]))}function M(e,t){const[n,r,o]=(0,l.getHyperbolaDerivatives)(e),[i,a,c]=(0,l.getHyperbolaDerivatives)(t),p=e=>{const{x:t,y:o}=n(e[0]),{x:s,y:c}=r(e[0]),{x:l,y:u}=i(e[1]),{x:p,y:d}=a(e[1]);return[(o-u)*s-(t-l)*c,c*p-s*d]},d=e=>{const{x:t,y:s}=n(e[0]),{x:l,y:u}=r(e[0]),{x:p,y:d}=o(e[0]),{x:f,y:g}=i(e[1]),{x:h,y:m}=a(e[1]),{x:y,y:v}=c(e[1]);return[u*l+(s-g)*p-(l*u+(t-f)*d),-m*l+h*u,d*h-p*m,u*y-l*v]};let f=[];for(const e of[-1,1]){const t=(0,s.newtonIterate2)([e,0],p,d,u.delta2);void 0!==t&&f.push(t)}return f=(0,u.deduplicate)(f,u.deepEquals),f.filter((n=>(0,u.isBetween)(n[0],e.t1,e.t2)&&(0,u.isBetween)(n[1],t.t1,t.t2))).map((e=>[n(e[0]),i(e[1])]))}function I(e,t){const[n,r,o]=(0,l.getHyperbolaDerivatives)(e),i=(0,p.toVerbNurbsCurve)(t),a=e=>{const{x:t,y:o}=n(e[0]),{x:a,y:s}=r(e[0]),[[c,l],[u,p]]=i.derivatives(e[1]);return[(o-l)*a-(t-c)*s,s*u-a*p]},c=e=>{const{x:t,y:a}=n(e[0]),{x:s,y:c}=r(e[0]),{x:l,y:u}=o(e[0]),[[p,d],[f,g],[h,m]]=i.derivatives(e[1],2);return[c*s+(a-d)*l-(s*c+(t-p)*u),-g*s+f*c,u*f-l*g,c*h-s*m]};let d=[];const f=(0,p.getNurbsMaxParam)(t);for(const e of[-1,1])for(let t=.5;t(0,u.isBetween)(t[0],e.t1,e.t2)&&(0,u.isBetween)(t[1],0,f))).map((e=>[n(e[0]),(0,p.fromVerbPoint)(i.point(e[1]))]))}function O(e,t){const n=(0,p.toVerbNurbsCurve)(e),r=(0,p.toVerbNurbsCurve)(t),o=e=>{const[[t,o],[i,a]]=n.derivatives(e[0]),[[s,c],[l,u]]=r.derivatives(e[1]);return[(o-c)*i-(t-s)*a,a*l-i*u]},i=e=>{const[[t,o],[i,a],[s,c]]=n.derivatives(e[0],2),[[l,u],[p,d],[f,g]]=r.derivatives(e[1],2);return[a*i+(o-u)*s-(i*a+(t-l)*c),-d*i+p*a,c*p-s*d,a*f-i*g]};let a=[];const c=(0,p.getNurbsMaxParam)(e),l=(0,p.getNurbsMaxParam)(t);for(let e=.5;e(0,u.isBetween)(e[0],0,c)&&(0,u.isBetween)(e[1],0,l))).map((e=>[(0,p.fromVerbPoint)(r.point(e[0])),(0,p.fromVerbPoint)(r.point(e[1]))]))}},8905:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Image:()=>d,Text:()=>p,TextStyle:()=>l,getTextSize:()=>a,getTextSizeFromCache:()=>c,getTextStyleFont:()=>u,isLetter:()=>g,isNumber:()=>h,isWordCharactor:()=>f});var r=n(5773),o=n(7486),i=n(5569);function a(e,t){const n=new OffscreenCanvas(0,0).getContext("2d");if(n){n.font=e;const r=n.measureText(t),o=r.actualBoundingBoxAscent+r.actualBoundingBoxDescent;return{width:r.width,height:o}}}const s=new(n(7713).MapCache2);function c(e,t){return s.get(e,t,(()=>a(e,t)))}const l={fontSize:i.number,fontFamily:i.string};function u(e){return`${e.fontSize}px ${e.fontFamily}`}const p=(0,i.and)(r.Position,l,{text:i.string,color:i.number}),d=(0,i.and)(o.Region,{url:i.string});function f(e){return"."===e||!!g(e)||!!h(e)}function g(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"}function h(e){return e>="0"&&e<="9"}},360:(e,t,n)=>{"use strict";n.r(t),n.d(t,{getCoordinateMatrix:()=>y,getCoordinateMatrix2D:()=>C,getCoordinateVec:()=>m,getCoordinateVec2D:()=>b,reverseTransformPosition:()=>l,rotateToDirection:()=>v,scaleByCursorPosition:()=>f,transformPointFromCoordinate:()=>h,transformPointFromCoordinate2D:()=>x,transformPointToCoordinate:()=>g,transformPosition:()=>u,zoomToFit:()=>p,zoomToFitPoints:()=>d});var r=n(2792),o=n(5773),i=n(6842),a=n(7486),s=n(2301),c=n(5147);function l(e,t){return t?(e={x:(e.x-t.center.x-t.x)/t.scale+t.center.x,y:(e.y-t.center.y-t.y)/t.scale+t.center.y},t.rotate&&(e=(0,o.rotatePosition)(e,{x:0,y:0},-t.rotate)),e):e}function u(e,t){return t?(t.rotate&&(e=(0,o.rotatePosition)(e,{x:0,y:0},t.rotate)),{x:(e.x-t.center.x)*t.scale+t.center.x+t.x,y:(e.y-t.center.y)*t.scale+t.center.y+t.y}):e}function p(e,{width:t,height:n},o,i=.8){if(e&&!(0,r.isSameNumber)(e.start.x,e.end.x)&&!(0,r.isSameNumber)(e.start.y,e.end.y)){const s=(0,a.getTwoPointsFormRegionSize)(e),c=Math.min(t/s.width,n/s.height)*i;return{scale:c,x:(o.x-(0,r.getTwoNumberCenter)(e.start.x,e.end.x))*c,y:(o.y-(0,r.getTwoNumberCenter)(e.start.y,e.end.y))*c}}}function d(e,{width:t,height:n},s,c=.8,l){const u=(0,i.getPointsBoundingUnsafe)(e);if(u&&!(0,r.isSameNumber)(u.start.x,u.end.x)&&!(0,r.isSameNumber)(u.start.y,u.end.y)){let r;if(l){const t=(0,i.getPointsBoundingUnsafe)(e.map((e=>(0,o.rotatePosition)(e,{x:0,y:0},l))));r=(0,a.getTwoPointsFormRegionSize)(t)}else r=(0,a.getTwoPointsFormRegionSize)(u);const p=Math.min(t/r.width,n/r.height)*c;let d=(0,o.getTwoPointCenter)(u.start,u.end);return l&&(d=(0,o.rotatePosition)(d,{x:0,y:0},l)),{scale:p,x:(s.x-d.x)*p,y:(s.y-d.y)*p}}}function f({width:e,height:t},n,r){return{setX:t=>r.x-e/2-(r.x-e/2-t)*n,setY:e=>r.y-t/2-(r.y-t/2-e)*n}}function g(e,[t,...n]){return(0,s.slice3)(c.matrix.multiplyVec(n,c.v3.substract(e,t)))}function h(e,t){const n=m(e,t),r=y(t);if(r)return(0,s.slice3)(c.matrix.multiplyVec(r,n))}function m(e,[t,...n]){return c.v3.dots(n,c.v3.addToVecs(t,c.v3.multiplyScalars(n,e)))}function y(e){return c.matrix.inverse((0,s.slice3)(e,1))}function v(e,t=[0,1,0]){e=c.v3.normalize(e);const n=c.v3.cross(t,e);if(c.v3.lengthSquare(n)>0)return{axis:n,radian:Math.acos(c.v3.dot(t,e))}}function x(e,t,n){const{x:r,y:o}=e,i=Math.sin(n),a=Math.cos(n);return{x:t.x+a*r-i*o,y:t.y+i*r+a*o}}function b(e){return[e.x,e.y,1]}function C(e,t){const n=Math.sin(t),r=Math.cos(t);return[[r,-n,e.x],[n,r,e.y]]}},3793:(e,t,n)=>{"use strict";n.r(t),n.d(t,{combineStripTriangleColors:()=>g,combineStripTriangles:()=>d,defaultLineCap:()=>y,defaultLineJoin:()=>m,defaultMiterLimit:()=>h,getPolylineTriangles:()=>p,triangleStripToTriangles:()=>f});var r=n(2792),o=n(5773),i=n(1715),a=n(8831),s=n(1796),c=n(2318),l=n(491),u=n(8392);function p(e,t,n=y,p=h){const d=t/2;!0===n?e=(0,s.polygonToPolyline)(e):(0,o.isSamePoint)(e[0],e[e.length-1])&&(n=!0);const f=[e[0]],g=[],m=[];for(let t=1;t{"use strict";n.r(t),n.d(t,{Nullable:()=>o,Vec2:()=>i,Vec3:()=>a,Vec4:()=>s,slice2:()=>c,slice3:()=>l});var r=n(5569);const o=e=>(0,r.or)(void 0,null,e),i=(0,r.tuple)(r.number,r.number),a=(0,r.tuple)(r.number,r.number,r.number),s=(0,r.tuple)(r.number,r.number,r.number,r.number);function c(e,t=0){return[e[t],e[t+1]]}function l(e,t=0){return[e[t],e[t+1],e[t+2]]}},5935:(e,t,n)=>{"use strict";n.r(t),n.d(t,{getTwoGeometryLinesUnionLine:()=>E});var r=n(8831),o=n(5629),i=n(2318),a=n(2298),s=n(5717),c=n(2986),l=n(1796),u=n(2792),p=n(2572),d=n(1715),f=Object.defineProperty,g=Object.defineProperties,h=Object.getOwnPropertyDescriptors,m=Object.getOwnPropertySymbols,y=Object.prototype.hasOwnProperty,v=Object.prototype.propertyIsEnumerable,x=(e,t,n)=>t in e?f(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,b=(e,t)=>{for(var n in t||(t={}))y.call(t,n)&&x(e,n,t[n]);if(m)for(var n of m(t))v.call(t,n)&&x(e,n,t[n]);return e},C=(e,t)=>g(e,h(t));function E(e,t){if(Array.isArray(e)){const n=(0,l.twoPointLineToGeneralFormLine)(...e);if(!n)return;if(Array.isArray(t)){const r=(0,l.twoPointLineToGeneralFormLine)(...t);if(!r)return;if(!(0,l.isSameLine)(n,r))return;const o=t.map((t=>(0,s.getGeometryLineParamAtPoint)(t,e))),i=(0,u.getNumberRangeUnion)([o[0],o[1]],[0,1]);if(!i)return;return(0,s.getPartOfGeometryLine)(...i,e)}if("ray"===t.type){const r=(0,l.pointAndDirectionToGeneralFormLine)(t.line,(0,d.angleToRadian)(t.line.angle));if(!(0,l.isSameLine)(n,r))return;if(t.line.bidirectional)return t;const o=e.map((e=>(0,l.pointIsOnRay)(e,t.line)));if(o.every((e=>e)))return t;let i=o.findIndex((e=>e));return i>=0?(i=0===i?1:0,{type:"ray",line:C(b({},t.line),{x:e[i].x,y:e[i].y})}):void 0}}else{if(Array.isArray(t))return E(t,e);if("arc"!==e.type){if("arc"===t.type)return E(t,e);if("ellipse arc"!==e.type){if("ellipse arc"===t.type)return E(t,e);if("quadratic curve"!==e.type){if("quadratic curve"===t.type)return E(t,e);if("bezier curve"!==e.type){if("bezier curve"===t.type)return E(t,e);if("hyperbola curve"!==e.type){if("hyperbola curve"===t.type)return E(t,e);if("ray"!==e.type)return"ray"===t.type?E(t,e):void 0;if("ray"===t.type){const n=(0,l.pointAndDirectionToGeneralFormLine)(e.line,(0,d.angleToRadian)(e.line.angle)),o=(0,l.pointAndDirectionToGeneralFormLine)(t.line,(0,d.angleToRadian)(t.line.angle));if(!(0,l.isSameLine)(n,o))return;return e.line.bidirectional?e:t.line.bidirectional?t:(0,r.twoAnglesSameDirection)((0,l.getRayAngle)(e.line),(0,l.getRayAngle)(t.line))?(0,l.pointIsOnRay)(e.line,t.line)?t:e:(0,l.pointIsOnRay)(e.line,t.line)?{type:"ray",line:C(b({},t.line),{bidirectional:!0})}:void 0}}else if("hyperbola curve"===t.type){if(!(0,c.isSameHyperbola)(e.curve,t.curve))return;const n=(0,u.getNumberRangeUnion)([e.curve.t1,e.curve.t2],[t.curve.t1,t.curve.t2]);if(!n)return;return{type:"hyperbola curve",curve:C(b({},e.curve),{t1:n[0],t2:n[1]})}}}else if("bezier curve"===t.type){const n=(0,o.getBezierCurvePercentsAtBezierCurve)(e.curve,t.curve);if(!n)return;const r=(0,u.getNumberRangeUnion)(n,[0,1]);if(!r)return;return(0,s.getPartOfGeometryLine)(...r,e)}}else if("quadratic curve"===t.type){const n=(0,o.getQuadraticCurvePercentsAtQuadraticCurve)(e.curve,t.curve);if(!n)return;const r=(0,u.getNumberRangeUnion)(n,[0,1]);if(!r)return;return(0,s.getPartOfGeometryLine)(...r,e)}}else if("ellipse arc"===t.type){if(!(0,a.isSameEllipse)(e.curve,t.curve))return;const n=(0,u.mergeItems)([...(0,r.getNormalizedAngleInRanges)(e.curve),...(0,r.getNormalizedAngleInRanges)(t.curve)],u.getNumberRangeUnion),o=(0,u.mergeItems)(n.map((t=>C(b({},e.curve),{startAngle:t[0],endAngle:t[1],counterclockwise:void 0}))),p.mergeEllipseArc);return o.length>0?{type:"ellipse arc",curve:o[0]}:void 0}}else if("arc"===t.type){if(!(0,i.isSameCircle)(e.curve,t.curve))return;const n=(0,u.mergeItems)([...(0,r.getNormalizedAngleInRanges)(e.curve),...(0,r.getNormalizedAngleInRanges)(t.curve)],u.getNumberRangeUnion),o=(0,u.mergeItems)(n.map((t=>C(b({},e.curve),{startAngle:t[0],endAngle:t[1],counterclockwise:void 0}))),p.mergeArc);return o.length>0?{type:"arc",curve:o[0]}:void 0}}}},5569:(e,t,n)=>{"use strict";n.r(t),n.d(t,{and:()=>k,bigint:()=>s,boolean:()=>l,exclusiveMaximum:()=>E,exclusiveMinimum:()=>C,integer:()=>c,is:()=>T,maxItems:()=>h,maxLength:()=>y,maximum:()=>b,minItems:()=>g,minLength:()=>m,minimum:()=>x,multipleOf:()=>P,never:()=>d,number:()=>a,optional:()=>f,or:()=>w,pattern:()=>v,record:()=>_,string:()=>i,symbol:()=>u,tuple:()=>S,unknown:()=>p,validate:()=>R});var r=n(6022),o=n(1074);const i=(e,t)=>"string"==typeof e||{path:t,expect:"string"},a=(e,t)=>"number"==typeof e&&!isNaN(e)||{path:t,expect:"number"},s=(e,t)=>"bigint"==typeof e||{path:t,expect:"bigint"},c=(e,t)=>!!Number.isInteger(e)||{path:t,expect:"integer"},l=(e,t)=>"boolean"==typeof e||{path:t,expect:"boolean"},u=(e,t)=>"symbol"==typeof e||{path:t,expect:"symbol"},p=()=>!0,d=(e,t)=>({path:t,expect:"never"}),f=e=>(t,n)=>void 0===t||R(t,e,n),g=(e,t)=>(n,r)=>(0,o.isArray)(n)?n.length>=e?R(n,t,r):{path:r,expect:"minItems",args:[e]}:{path:r,expect:"array"},h=(e,t)=>(n,r)=>(0,o.isArray)(n)?n.length<=e?R(n,t,r):{path:r,expect:"maxItems",args:[e]}:{path:r,expect:"array"},m=(e,t)=>(n,r)=>"string"!=typeof n?{path:r,expect:"string"}:n.length>=e?R(n,t,r):{path:r,expect:"minLength",args:[e]},y=(e,t)=>(n,r)=>"string"!=typeof n?{path:r,expect:"string"}:n.length<=e?R(n,t,r):{path:r,expect:"maxLength",args:[e]},v=(e,t)=>(n,r)=>"string"!=typeof n?{path:r,expect:"string"}:n.match(e)?R(n,t,r):{path:r,expect:"pattern",args:[e]},x=(e,t)=>(n,r)=>"number"!=typeof n||isNaN(n)?{path:r,expect:"number"}:n>=e?R(n,t,r):{path:r,expect:"minimum",args:[e]},b=(e,t)=>(n,r)=>"number"!=typeof n||isNaN(n)?{path:r,expect:"number"}:n<=e?R(n,t,r):{path:r,expect:"maximum",args:[e]},C=(e,t)=>(n,r)=>"number"!=typeof n||isNaN(n)?{path:r,expect:"number"}:n>e?R(n,t,r):{path:r,expect:"exclusiveMinimum",args:[e]},E=(e,t)=>(n,r)=>"number"!=typeof n||isNaN(n)?{path:r,expect:"number"}:n(n,r)=>"number"!=typeof n?{path:r,expect:"number"}:Number.isInteger(n)?n%e==0?R(n,t,r):{path:r,expect:"multipleOf",args:[e]}:{path:r,expect:"integer"},w=(...e)=>(t,n)=>{const r=[];for(const n of e){const e=R(t,n);if(!0===e)return!0;r.push(e)}return{path:n,expect:"or",args:r}},k=(...e)=>Object.assign({},...e),_=(e,t)=>(n,o)=>{if(!(0,r.isRecord)(n))return{path:o,expect:"object"};for(const[r,i]of Object.entries(n)){const n=[...o,r],a=R(r,e,n);if(!0!==a)return a;const s=R(i,t,n);if(!0!==s)return s}return!0},S=(...e)=>(t,n)=>{if(!(0,o.isArray)(t))return{path:n,expect:"array"};if(e.length!==t.length)return{path:n,expect:"length",args:[e.length]};for(let r=0;r{"use strict";n.r(t),n.d(t,{MapCache:()=>v,MapCache2:()=>x,MapCache3:()=>b,MapCache4:()=>C,ValueChangedCache:()=>f,WeakmapCache:()=>s,WeakmapCache2:()=>c,WeakmapCache3:()=>l,WeakmapCache4:()=>u,WeakmapMap2Cache:()=>h,WeakmapMap3Cache:()=>m,WeakmapMap4Cache:()=>y,WeakmapMapCache:()=>g,WeakmapValueCache:()=>d,WeakmapValuesCache:()=>p});var r=n(2792),o=n(5775),i=Object.defineProperty,a=(e,t,n)=>((e,t,n)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class s{constructor(){a(this,"cache",new WeakMap)}get(e,t){let n=this.cache.get(e);return void 0===n&&(n=t(),this.cache.set(e,n)),n}clear(){this.cache=new WeakMap}}class c{constructor(){a(this,"cache",new WeakMap)}get(e,t,n){let r=this.cache.get(e);r||(r=new WeakMap,this.cache.set(e,r));let o=r.get(t);return void 0===o&&(o=n(),r.set(t,o)),o}clear(){this.cache=new WeakMap}}class l{constructor(){a(this,"cache",new WeakMap)}get(e,t,n,r){let o=this.cache.get(e);o||(o=new WeakMap,this.cache.set(e,o));let i=o.get(t);i||(i=new WeakMap,o.set(t,i));let a=i.get(n);return void 0===a&&(a=r(),i.set(n,a)),a}clear(){this.cache=new WeakMap}}class u{constructor(){a(this,"cache",new WeakMap)}get(e,t,n,r,o){let i=this.cache.get(e);return i||(i=new l,this.cache.set(e,i)),i.get(t,n,r,o)}clear(){this.cache=new WeakMap}}class p{constructor(){a(this,"caches",new WeakMap)}get(e,t,n){let r=this.caches.get(e);return r||(r=new o.WeakValuesChangedCache,this.caches.set(e,r)),r.get(t,n)}clear(){this.caches=new WeakMap}}class d{constructor(){a(this,"caches",new WeakMap)}get(e,t,n){let r=this.caches.get(e);return r||(r=new f,this.caches.set(e,r)),r.get(t,n)}clear(){this.caches=new WeakMap}}class f{constructor(){a(this,"cache")}get(e,t){return void 0!==this.cache&&(0,r.deepEquals)(this.cache.key,e)||(this.cache={key:e,value:t()}),this.cache.value}clear(){this.cache=void 0}}class g{constructor(){a(this,"cache",new WeakMap)}get(e,t,n){let r=this.cache.get(e);r||(r=new Map,this.cache.set(e,r));let o=r.get(t);return void 0===o&&(o=n(),r.set(t,o)),o}clear(){this.cache=new WeakMap}}class h{constructor(){a(this,"cache",new WeakMap)}get(e,t,n,r){let o=this.cache.get(e);o||(o=new Map,this.cache.set(e,o));let i=o.get(t);i||(i=new Map,o.set(t,i));let a=i.get(n);return void 0===a&&(a=r(),i.set(n,a)),a}clear(){this.cache=new WeakMap}}class m{constructor(){a(this,"cache",new WeakMap)}get(e,t,n,r,o){let i=this.cache.get(e);i||(i=new Map,this.cache.set(e,i));let a=i.get(t);a||(a=new Map,i.set(t,a));let s=a.get(n);s||(s=new Map,a.set(n,s));let c=s.get(r);return void 0===c&&(c=o(),s.set(r,c)),c}clear(){this.cache=new WeakMap}}class y{constructor(){a(this,"cache",new WeakMap)}get(e,t,n,r,o,i){let a=this.cache.get(e);a||(a=new Map,this.cache.set(e,a));let s=a.get(t);s||(s=new Map,a.set(t,s));let c=s.get(n);c||(c=new Map,s.set(n,c));let l=c.get(r);l||(l=new Map,c.set(r,l));let u=l.get(o);return void 0===u&&(u=i(),l.set(o,u)),u}clear(){this.cache=new WeakMap}}class v{constructor(){a(this,"cache",new Map)}get(e,t){let n=this.cache.get(e);return void 0===n&&(n=t(),this.cache.set(e,n)),n}clear(){this.cache.clear()}values(){return this.cache.values()}}class x{constructor(){a(this,"cache",new Map)}get(e,t,n){let r=this.cache.get(e);r||(r=new Map,this.cache.set(e,r));let o=r.get(t);if(void 0===o){if(!n)return;o=n(),r.set(t,o)}return o}}class b{constructor(){a(this,"cache",new Map)}get(e,t,n,r){let o=this.cache.get(e);o||(o=new Map,this.cache.set(e,o));let i=o.get(t);i||(i=new Map,o.set(t,i));let a=i.get(n);if(void 0===a){if(!r)return;a=r(),i.set(n,a)}return a}}class C{constructor(){a(this,"cache",new Map)}get(e,t,n,r,o){let i=this.cache.get(e);i||(i=new Map,this.cache.set(e,i));let a=i.get(t);a||(a=new Map,i.set(t,a));let s=a.get(n);s||(s=new Map,a.set(n,s));let c=s.get(r);if(void 0===c){if(!o)return;c=o(),s.set(r,c)}return c}}},5775:(e,t,n)=>{"use strict";n.r(t),n.d(t,{WeakValuesChangedCache:()=>a,WeaksetCache:()=>i});var r=Object.defineProperty,o=(e,t,n)=>((e,t,n)=>t in e?r(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class i{constructor(){o(this,"cache",new WeakSet),o(this,"count",0)}clear(){this.cache=new WeakSet,this.count=0}add(...e){for(const t of e)this.cache.add(t);this.count+=e.length}has(e){return this.cache.has(e)}delete(e){return this.count--,this.cache.delete(e)}get size(){return this.count}}class a{constructor(){o(this,"cache")}get(e,t){if(Array.isArray(e)&&(e=new Set(e)),void 0===this.cache||e.size!==this.cache.size)return this.cache={keys:new WeakSet(e),value:t(),size:e.size},this.cache.value;for(const n of e)if(!this.cache.keys.has(n))return this.cache={keys:new WeakSet(e),value:t(),size:e.size},this.cache.value;return this.cache.value}clear(){this.cache=void 0}}},1717:(e,t,n)=>{"use strict";n.d(t,{ExpressionError:()=>r});class r extends Error{constructor(e,t){super(e),this.range=t}}},4486:(e,t,n)=>{"use strict";n.d(t,{evaluateExpression:()=>o});var r=n(3031);function o(e,t,n,r){return new(u(e)?a:i)(n,Array.isArray(r)?e=>r.some((t=>e instanceof t)):r).evalutate(e,t,!0)}class i{constructor(e,t){this.isCustomData=t,this.locale=(0,r.getLocale)(e)}evalutate(e,t,n){return s(e,t,n,this)}evaluateBinaryExpression(e,t){return c(e,this.evalutate(e.left,t,!0),this.evalutate(e.right,t,!0),this.locale,this.isCustomData)}evaluateLogicalExpression(e,t){const n=this.evalutate(e.left,t,!0);if("&&"===e.operator)return n&&this.evalutate(e.right,t,!0);if("||"===e.operator)return n||this.evalutate(e.right,t,!0);if("??"===e.operator)return null!=n?n:this.evalutate(e.right,t,!0);throw new r.ExpressionError(this.locale.unexpectToken,e.range)}evaluateUnaryExpression(e,t){return l(e,this.evalutate(e.argument,t,!0),this.locale)}}class a{constructor(e,t){this.isCustomData=t,this.locale=(0,r.getLocale)(e)}evalutate(e,t,n){return s(e,t,n,this)}async evaluateBinaryExpression(e,t){return c(e,await this.evalutate(e.left,t,!0),await this.evalutate(e.right,t,!0),this.locale,this.isCustomData)}evaluateLogicalExpression(e,t){const n=this.evalutate(e.left,t,!0);if("&&"===e.operator)return n&&this.evalutate(e.right,t,!0);if("||"===e.operator)return n||this.evalutate(e.right,t,!0);if("??"===e.operator)return null!=n?n:this.evalutate(e.right,t,!0);throw new r.ExpressionError(this.locale.unexpectToken,e.range)}async evaluateUnaryExpression(e,t){return l(e,await this.evalutate(e.argument,t,!0),this.locale)}}function s(e,t,n,o){if("BinaryExpression"===e.type)return o.evaluateBinaryExpression(e,t);if("MemberExpression"===e.type){const n=o.evalutate(e.object,t,!0),i=o.evalutate(e.property,t,!1);if(e.optional&&!n)return;if(!["length","name","toString","valueOf","toLocaleString"].includes(i)&&(i in Object.prototype||i in Function.prototype))throw new r.ExpressionError(`No access to property "${i}"`,e.property.range);const a=n[i];return"function"==typeof a?a.bind(n):a}if("ConditionalExpression"===e.type)return o.evalutate(e.test,t,!0)?o.evalutate(e.consequent,t,!0):o.evalutate(e.alternate,t,!0);if("CallExpression"===e.type){const n=o.evalutate(e.callee,t,!0),r=[];for(const n of e.arguments)"SpreadElement"===n.type?r.push(...o.evalutate(n.argument,t,!0)):r.push(o.evalutate(n,t,!0));return n(...r)}if("LogicalExpression"===e.type)return o.evaluateLogicalExpression(e,t);if("UnaryExpression"===e.type)return o.evaluateUnaryExpression(e,t);if("Identifier"===e.type||"ThisExpression"===e.type){const r="Identifier"===e.type?e.name:"this";return n?t[r]:r}if("NumericLiteral"===e.type)return e.value;if("StringLiteral"===e.type)return e.value;if("NullLiteral"===e.type)return null;if("BooleanLiteral"===e.type)return e.value;if("ArrayExpression"===e.type){const n=[];for(const r of e.elements)"SpreadElement"===r.type?n.push(...o.evalutate(r.argument,t,!0)):n.push(o.evalutate(r,t,!0));return n}if("ObjectExpression"===e.type){const n={};for(const r of e.properties)"Property"===r.type?n["Identifier"===r.key.type?r.key.name:r.key.value]=o.evalutate(r.value,t,!0):Object.assign(n,o.evalutate(r.argument,t,!0));return n}if("ArrowFunctionExpression"===e.type)return(...n)=>{let r;if(0===n.length)r=t;else{r={...t};for(let t=0;t"===e.operator&&t.greaterThan)return t.greaterThan(n);if("<="===e.operator&&t.lessThanOrEqual)return t.lessThanOrEqual(n);if(">"===e.operator&&t.greaterThanOrEqual)return t.greaterThanOrEqual(n)}if(i(n)){if("+"===e.operator&&n.added)return n.added(t);if("-"===e.operator&&n.subtracted)return n.subtracted(t);if("*"===e.operator&&n.multiplied)return n.multiplied(t);if("/"===e.operator&&n.divided)return n.divided(t);if("%"===e.operator&&n.remainered)return n.remainered(t);if("**"===e.operator&&n.powered)return n.powered(t);if(("=="===e.operator||"==="===e.operator)&&n.equal)return n.equal(t);if(("!="===e.operator||"!=="===e.operator)&&n.equal)return!n.equal(t);if("<"===e.operator&&n.greaterThanOrEqual)return n.greaterThanOrEqual(t);if(">"===e.operator&&n.lessThanOrEqual)return n.lessThanOrEqual(t);if("<="===e.operator&&n.greaterThan)return n.greaterThan(t);if(">="===e.operator&&n.lessThan)return n.lessThan(t)}}if("+"===e.operator){if("string"==typeof t)return t+n;if("number"!=typeof t||isNaN(t))throw new r.ExpressionError((0,r.replaceLocaleParameters)(o.expect,"Number",e.left.range[0]),e.left.range);if("string"==typeof n)return t+n;if("number"!=typeof n||isNaN(n))throw new r.ExpressionError((0,r.replaceLocaleParameters)(o.expect,"Number",e.right.range[0]),e.right.range);return t+n}if("=="===e.operator||"==="===e.operator||"!="===e.operator||"!=="===e.operator)return"=="===e.operator||"==="===e.operator?t===n:t!==n;if("string"==typeof t&&"string"==typeof n){if(">"===e.operator)return t>n;if(">="===e.operator)return t>=n;if("<"===e.operator)return t"===e.operator)return n(t);if("number"!=typeof t)throw new r.ExpressionError((0,r.replaceLocaleParameters)(o.expect,"Number",e.left.range[0]),e.left.range);if("number"!=typeof n)throw new r.ExpressionError((0,r.replaceLocaleParameters)(o.expect,"Number",e.right.range[0]),e.right.range);if("-"===e.operator)return t-n;if("*"===e.operator)return t*n;if("/"===e.operator)return t/n;if("%"===e.operator)return t%n;if(">"===e.operator)return t>n;if(">="===e.operator)return t>=n;if("<"===e.operator)return t>"===e.operator)return t>>n;if("<<"===e.operator)return t<>>"===e.operator)return t>>>n;if("&"===e.operator)return t&n;if("^"===e.operator)return t^n;if("|"===e.operator)return t|n;throw new r.ExpressionError(o.unexpectToken,e.range)}function l(e,t,n){if("!"===e.operator)return!t;if("+"===e.operator&&("number"==typeof t||"string"==typeof t))return+t;if("number"!=typeof t||isNaN(t))throw new r.ExpressionError((0,r.replaceLocaleParameters)(n.expect,"Number",e.argument.range[0]),e.argument.range);if("-"===e.operator)return-t;if("~"===e.operator)return~t;if("%"===e.operator)return t/100;if("await"===e.operator)return t;throw new r.ExpressionError(n.unexpectToken,e.range)}function u(e){return"NumericLiteral"!==e.type&&"StringLiteral"!==e.type&&"Identifier"!==e.type&&"ThisExpression"!==e.type&&"NullLiteral"!==e.type&&"BooleanLiteral"!==e.type&&("SpreadElement"===e.type||"RestElement"===e.type?u(e.argument):"AssignmentPattern"===e.type?u(e.left)||u(e.right):"ArrayExpression"===e.type?e.elements.some((e=>u(e))):"ArrowFunctionExpression"===e.type?e.params.some((e=>u(e)))||u(e.body):"UnaryExpression"===e.type?"await"===e.operator||u(e.argument):"BinaryExpression"===e.type||"LogicalExpression"===e.type?u(e.left)||u(e.right):"MemberExpression"===e.type?u(e.object)||u(e.property):"CallExpression"===e.type?e.arguments.some((e=>u(e)))||u(e.callee):"ConditionalExpression"===e.type?u(e.test)||u(e.consequent)||u(e.alternate):"Property"===e.type?u(e.key)||u(e.value):"ObjectExpression"===e.type?e.properties.some((e=>u(e))):e.params.some((e=>u(e))))}},3031:(e,t,n)=>{"use strict";var r=n(1283);n.o(r,"ExpressionError")&&n.d(t,{ExpressionError:function(){return r.ExpressionError}}),n.o(r,"evaluateExpression")&&n.d(t,{evaluateExpression:function(){return r.evaluateExpression}}),n.o(r,"getLocale")&&n.d(t,{getLocale:function(){return r.getLocale}}),n.o(r,"parseExpression")&&n.d(t,{parseExpression:function(){return r.parseExpression}}),n.o(r,"postfixUnaryOperators")&&n.d(t,{postfixUnaryOperators:function(){return r.postfixUnaryOperators}}),n.o(r,"printExpression")&&n.d(t,{printExpression:function(){return r.printExpression}}),n.o(r,"priorizedBinaryOperators")&&n.d(t,{priorizedBinaryOperators:function(){return r.priorizedBinaryOperators}}),n.o(r,"replaceLocaleParameters")&&n.d(t,{replaceLocaleParameters:function(){return r.replaceLocaleParameters}}),n.o(r,"tokenizeExpression")&&n.d(t,{tokenizeExpression:function(){return r.tokenizeExpression}});var o=n(5138);n.o(o,"ExpressionError")&&n.d(t,{ExpressionError:function(){return o.ExpressionError}}),n.o(o,"evaluateExpression")&&n.d(t,{evaluateExpression:function(){return o.evaluateExpression}}),n.o(o,"getLocale")&&n.d(t,{getLocale:function(){return o.getLocale}}),n.o(o,"parseExpression")&&n.d(t,{parseExpression:function(){return o.parseExpression}}),n.o(o,"postfixUnaryOperators")&&n.d(t,{postfixUnaryOperators:function(){return o.postfixUnaryOperators}}),n.o(o,"printExpression")&&n.d(t,{printExpression:function(){return o.printExpression}}),n.o(o,"priorizedBinaryOperators")&&n.d(t,{priorizedBinaryOperators:function(){return o.priorizedBinaryOperators}}),n.o(o,"replaceLocaleParameters")&&n.d(t,{replaceLocaleParameters:function(){return o.replaceLocaleParameters}}),n.o(o,"tokenizeExpression")&&n.d(t,{tokenizeExpression:function(){return o.tokenizeExpression}});var i=n(8296);n.o(i,"ExpressionError")&&n.d(t,{ExpressionError:function(){return i.ExpressionError}}),n.o(i,"evaluateExpression")&&n.d(t,{evaluateExpression:function(){return i.evaluateExpression}}),n.o(i,"getLocale")&&n.d(t,{getLocale:function(){return i.getLocale}}),n.o(i,"parseExpression")&&n.d(t,{parseExpression:function(){return i.parseExpression}}),n.o(i,"postfixUnaryOperators")&&n.d(t,{postfixUnaryOperators:function(){return i.postfixUnaryOperators}}),n.o(i,"printExpression")&&n.d(t,{printExpression:function(){return i.printExpression}}),n.o(i,"priorizedBinaryOperators")&&n.d(t,{priorizedBinaryOperators:function(){return i.priorizedBinaryOperators}}),n.o(i,"replaceLocaleParameters")&&n.d(t,{replaceLocaleParameters:function(){return i.replaceLocaleParameters}}),n.o(i,"tokenizeExpression")&&n.d(t,{tokenizeExpression:function(){return i.tokenizeExpression}});var a=n(6257);n.o(a,"ExpressionError")&&n.d(t,{ExpressionError:function(){return a.ExpressionError}}),n.o(a,"evaluateExpression")&&n.d(t,{evaluateExpression:function(){return a.evaluateExpression}}),n.o(a,"getLocale")&&n.d(t,{getLocale:function(){return a.getLocale}}),n.o(a,"parseExpression")&&n.d(t,{parseExpression:function(){return a.parseExpression}}),n.o(a,"postfixUnaryOperators")&&n.d(t,{postfixUnaryOperators:function(){return a.postfixUnaryOperators}}),n.o(a,"printExpression")&&n.d(t,{printExpression:function(){return a.printExpression}}),n.o(a,"priorizedBinaryOperators")&&n.d(t,{priorizedBinaryOperators:function(){return a.priorizedBinaryOperators}}),n.o(a,"replaceLocaleParameters")&&n.d(t,{replaceLocaleParameters:function(){return a.replaceLocaleParameters}}),n.o(a,"tokenizeExpression")&&n.d(t,{tokenizeExpression:function(){return a.tokenizeExpression}});var s=n(4486);n.o(s,"ExpressionError")&&n.d(t,{ExpressionError:function(){return s.ExpressionError}}),n.o(s,"evaluateExpression")&&n.d(t,{evaluateExpression:function(){return s.evaluateExpression}}),n.o(s,"getLocale")&&n.d(t,{getLocale:function(){return s.getLocale}}),n.o(s,"parseExpression")&&n.d(t,{parseExpression:function(){return s.parseExpression}}),n.o(s,"postfixUnaryOperators")&&n.d(t,{postfixUnaryOperators:function(){return s.postfixUnaryOperators}}),n.o(s,"printExpression")&&n.d(t,{printExpression:function(){return s.printExpression}}),n.o(s,"priorizedBinaryOperators")&&n.d(t,{priorizedBinaryOperators:function(){return s.priorizedBinaryOperators}}),n.o(s,"replaceLocaleParameters")&&n.d(t,{replaceLocaleParameters:function(){return s.replaceLocaleParameters}}),n.o(s,"tokenizeExpression")&&n.d(t,{tokenizeExpression:function(){return s.tokenizeExpression}});var c=n(856);n.o(c,"ExpressionError")&&n.d(t,{ExpressionError:function(){return c.ExpressionError}}),n.o(c,"evaluateExpression")&&n.d(t,{evaluateExpression:function(){return c.evaluateExpression}}),n.o(c,"getLocale")&&n.d(t,{getLocale:function(){return c.getLocale}}),n.o(c,"parseExpression")&&n.d(t,{parseExpression:function(){return c.parseExpression}}),n.o(c,"postfixUnaryOperators")&&n.d(t,{postfixUnaryOperators:function(){return c.postfixUnaryOperators}}),n.o(c,"printExpression")&&n.d(t,{printExpression:function(){return c.printExpression}}),n.o(c,"priorizedBinaryOperators")&&n.d(t,{priorizedBinaryOperators:function(){return c.priorizedBinaryOperators}}),n.o(c,"replaceLocaleParameters")&&n.d(t,{replaceLocaleParameters:function(){return c.replaceLocaleParameters}}),n.o(c,"tokenizeExpression")&&n.d(t,{tokenizeExpression:function(){return c.tokenizeExpression}});var l=n(1717);n.o(l,"ExpressionError")&&n.d(t,{ExpressionError:function(){return l.ExpressionError}}),n.o(l,"evaluateExpression")&&n.d(t,{evaluateExpression:function(){return l.evaluateExpression}}),n.o(l,"getLocale")&&n.d(t,{getLocale:function(){return l.getLocale}}),n.o(l,"parseExpression")&&n.d(t,{parseExpression:function(){return l.parseExpression}}),n.o(l,"postfixUnaryOperators")&&n.d(t,{postfixUnaryOperators:function(){return l.postfixUnaryOperators}}),n.o(l,"printExpression")&&n.d(t,{printExpression:function(){return l.printExpression}}),n.o(l,"priorizedBinaryOperators")&&n.d(t,{priorizedBinaryOperators:function(){return l.priorizedBinaryOperators}}),n.o(l,"replaceLocaleParameters")&&n.d(t,{replaceLocaleParameters:function(){return l.replaceLocaleParameters}}),n.o(l,"tokenizeExpression")&&n.d(t,{tokenizeExpression:function(){return l.tokenizeExpression}})},1283:()=>{},6257:(e,t,n)=>{"use strict";n.d(t,{getLocale:()=>o,replaceLocaleParameters:()=>i});const r={multipleDecimalPoint:"Multiple decimal point: {0}",expect:"Expect {0}: {1}",unexpectToken:"Unexpected token: {0} {1}",expectUnaryOperator:"Expect unary operator: {0}",expectConditionalOperator:"Expect conditional operator: {0} {1}",invalidPropertyName:"Invalid property name: {0}",emptyExpression:"Empty expression",invalidFunctionParameter:"Invalid function parameter: {0}"};function o(e){return e||r}function i(e,...t){for(let n=0;n{"use strict";n.d(t,{parseExpression:()=>o,postfixUnaryOperators:()=>u,priorizedBinaryOperators:()=>c});var r=n(3031);function o(e,t){return new i(t).parseExpression(e,a(e))}class i{constructor(e){this.locale=(0,r.getLocale)(e)}parseExpression(e,t,n){if(0===e.length)throw new r.ExpressionError(this.locale.emptyExpression,[0,0]);if(1===e.length)return this.parseLiteral(e[0]);if(2===e.length)return this.parseUnaryExpression(e,null!=n?n:t);const o=e[0],i=e[e.length-1];if("PunctuatorToken"===o.type&&"{"===o.value&&"PunctuatorToken"===i.type&&"}"===i.value)return this.parseObjectLiteral(e,t);if(3===e.length){const[r,o,i]=e;if("PunctuatorToken"===o.type){if(p.includes(o.value))return this.parseMemberExpression(r,o,i,t);if("=>"===o.value)return{type:"ArrowFunctionExpression",params:"FunctionParamsExpression"===r.type?r.params:[r],body:i,range:t};if(c.some((e=>e.some((e=>e===o.value)))))return this.parseBinaryExpression(r,o,i,t,n)}else if("PunctuatorToken"===i.type&&u.includes(i.value)){const e=this.parseExpression([o,i],[o.range[0],t[1]]);return this.parseExpression([r,e],t)}}if(e.some((e=>"PunctuatorToken"===e.type&&"("===e.value))){const t=this.parseGroup(e);if(t.length!==e.length)return this.parseExpression(t,a(e))}if(e.some((e=>"PunctuatorToken"===e.type&&"["===e.value))){const t=this.parseArrayLiteral(e);if(t.length!==e.length)return this.parseExpression(t,a(e))}if(e.some((e=>"PunctuatorToken"===e.type&&(p.includes(e.value)||"("===e.value||"["===e.value))))return this.parseMemberOrCallExpression(e);const l=this.getPostfixUnaryOperatorIndex(e);if(l>=0){const n=e[l-1],r=e[l],o=[n.range[0],r.range[1]],i=this.parseExpression([n,r],o);return e.splice(l-1,2,i),this.parseExpression(e,t)}const d=this.getPrefixUnaryOperatorIndex(e);if(d>=0){const n=e[d],r=e[d+1],o=[n.range[0],r.range[1]],i=this.parseExpression([n,r],o);return e.splice(d,2,i),this.parseExpression(e,t)}for(const n of c)if(e.some((e=>"PunctuatorToken"===e.type&&n.includes(e.value))))return this.parsePreviousExpression(e,n,t);if(5===e.length)return this.parseConditionalExpression(e,t);const f=s(0,e);if(f>=0){const n=this.parseFunctionParameters(e.slice(0,f),[e[0].range[0],e[f-1].range[1]]),r=this.parseExpression(e.slice(f+1),[e[f+1].range[0],e[e.length-1].range[1]]);return{type:"ArrowFunctionExpression",params:n.params,body:r,range:t}}throw new r.ExpressionError((0,r.replaceLocaleParameters)(this.locale.unexpectToken,t[0],t[1]),t)}parseObjectLiteral(e,t){const n=[];let r=[],o=[],i=!0;const a=(...e)=>{i?r.push(...e):o.push(...e)};for(let t=1;t0&&n.push(this.parseProperty(r,o)),{type:"ObjectExpression",properties:n,range:t}}parseProperty(e,t){if(2===e.length&&0===t.length){const[t,n]=e;if("PunctuatorToken"===t.type&&"..."===t.value&&!g(n))return{type:"SpreadElement",argument:n,range:[t.range[0],n.range[1]]}}const n=this.parseExpression(e,a(e));if("Identifier"!==n.type&&"StringLiteral"!==n.type&&"NumericLiteral"!==n.type)throw new r.ExpressionError((0,r.replaceLocaleParameters)(this.locale.invalidPropertyName,n.range[0]),n.range);if(0===t.length)return{type:"Property",key:n,shorthand:!0,value:n,range:n.range};const o=this.parseExpression(t,a(t));return{type:"Property",key:n,shorthand:!1,value:o,range:[n.range[0],o.range[1]]}}parseMemberExpression(e,t,n,r){const o={type:"MemberExpression",object:this.parseTokenOrExpression(e),property:this.parseTokenOrExpression(n),range:r};return"?."===t.value&&(o.optional=!0),o}parseGroup(e){const t=[];for(let n=0;n=0;t--){const n=e[t];if("PunctuatorToken"===n.type&&l.includes(n.value)&&(0===t||"PunctuatorToken"===e[t-1].type)&&"PunctuatorToken"!==e[t+1].type)return t}return-1}getPostfixUnaryOperatorIndex(e){for(let t=1;t1){const n=e[t-2];return"PunctuatorToken"!==n.type||")"===n.value||"]"===n.value}return!1}parseItems(e,t,n){const r=[];let o=[];for(let i=t+1;i0&&r.push(this.parseMayBeSpreadExpression(o,a(o))),r}parseMayBeSpreadExpression(e,t){if(2===e.length){const[n,r]=e;if("PunctuatorToken"===n.type&&"..."===n.value&&!g(r))return{type:"SpreadElement",argument:r,range:t}}return this.parseExpression(e,t)}parseConditionalExpression(e,t){const[n,o,i,a,s]=e;if("PunctuatorToken"===o.type&&"?"===o.value&&"PunctuatorToken"===a.type&&":"===a.value)return n.range[1]=o.range[0]-1,{type:"ConditionalExpression",test:this.parseTokenOrExpression(n),consequent:this.parseTokenOrExpression(i),alternate:this.parseTokenOrExpression(s),range:t};throw new r.ExpressionError((0,r.replaceLocaleParameters)(this.locale.expectConditionalOperator,o.range[0],a.range[0]),[o.range[0],a.range[0]])}parseTokenOrExpression(e){return g(e)?this.parseExpression([e],e.range):e}findGroupEnd(e,t,n){const o=d[n];let i=1;for(let r=t+1;r"===n.value)return e+1}return-1}const c=[["**"],["*","/","%"],["+","-"],["<<",">>",">>>"],[">","<",">=","<="],["==","!=","===","!=="],["&&"],["&"],["^"],["|"],["||","??"],["|>"]],l=["+","-","!","~","await"],u=["%"],p=[".","?."],d={"{":"}","[":"]","(":")"},f=Object.keys(d);function g(e){return"EOFToken"===e.type||"PunctuatorToken"===e.type||"KeywordToken"===e.type}},856:(e,t,n)=>{"use strict";n.d(t,{printExpression:()=>o});var r=n(3031);function o(e,t){const n=(e,o=Number.MAX_SAFE_INTEGER)=>{if("NumericLiteral"===e.type)return e.value.toString();if("StringLiteral"===e.type)return`'${e.value}'`;if("Identifier"===e.type)return e.name;if("ThisExpression"===e.type)return"this";if("NullLiteral"===e.type)return"null";if("BooleanLiteral"===e.type)return e.value?"true":"false";if("SpreadElement"===e.type||"RestElement"===e.type)return"..."+n(e.argument);if("AssignmentPattern"===e.type)return n(e.left)+" = "+n(e.right);if("ArrayExpression"===e.type)return"["+e.elements.map((e=>n(e))).join(", ")+"]";if("ArrowFunctionExpression"===e.type){const t=e.params.map((e=>n(e))).join(", "),r=n(e.body);return 1===e.params.length&&"Identifier"===e.params[0].type?`${t} => ${r}`:`(${t}) => ${r}`}if("UnaryExpression"===e.type){const t=n(e.argument,-1);return r.postfixUnaryOperators.includes(e.operator)?t+e.operator:"await"===e.operator?e.operator+" "+t:e.operator+t}if("BinaryExpression"===e.type||"LogicalExpression"===e.type){const i=r.priorizedBinaryOperators.findIndex((t=>t.includes(e.operator))),a="+"===e.operator||"*"===e.operator?i:i-.1,s=n(e.left,i)+" "+e.operator+" "+n(e.right,a);return i>o||i===o&&(null==t?void 0:t.keepBinaryExpressionOrder)?`(${s})`:s}if("MemberExpression"===e.type){const t=n(e.object),r=n(e.property);return"Identifier"===e.property.type?e.optional?t+"?."+r:t+"."+r:e.optional?t+"?.["+r+"]":t+"["+r+"]"}return"CallExpression"===e.type?e.optional?n(e.callee)+"?.("+e.arguments.map((e=>n(e))).join(", ")+")":n(e.callee)+"("+e.arguments.map((e=>n(e))).join(", ")+")":"ConditionalExpression"===e.type?n(e.test)+" ? "+n(e.consequent)+" : "+n(e.alternate):"Property"===e.type?e.shorthand?n(e.key):n(e.key)+": "+n(e.value):"ObjectExpression"===e.type?0===e.properties.length?"{}":"{ "+e.properties.map((e=>n(e))).join(", ")+" }":e.params.map((e=>n(e))).join(", ")};return n(e)}},5138:(e,t,n)=>{"use strict";n.d(t,{tokenizeExpression:()=>o});var r=n(3031);function o(e){return new i(e).toTokens()}class i{constructor(e,t){this.source=e,this.index=0,this.previousToken={type:"EOFToken",range:[0,0]},this.locale=(0,r.getLocale)(t)}toTokens(){const e=[];let t=this.nextToken();for(;"EOFToken"!==t.type;)e.push(t),t=this.nextToken();return e}nextToken(){if(this.index>=this.source.length)this.previousToken={type:"EOFToken",range:[this.source.length,this.source.length]};else{const e=this.source[this.index];" "===e?(this.index++,this.previousToken=this.nextToken()):'"'===e||"'"===e?this.previousToken=this.nextStringToken(e):"."===e?"."===this.source[this.index+1]&&"."===this.source[this.index+2]?this.previousToken=this.nextPunctuator(e):"EOFToken"===this.previousToken.type||"PunctuatorToken"===this.previousToken.type&&a.includes(this.previousToken.value)?this.previousToken=this.nextNumericToken(!0):this.previousToken=this.nextPunctuator(e):e>="0"&&e<="9"?this.previousToken=this.nextNumericToken(!1):s.includes(e)?this.previousToken=this.nextPunctuator(e):this.previousToken=this.nextIdentifierToken()}return this.previousToken}nextPunctuator(e){const t=this.index;return">"===e||"<"===e||"="===e||"!"===e?"="===this.source[this.index+1]?"="!==e&&"!"!==e||"="!==this.source[this.index+2]?(e+="=",this.index++):(e+="==",this.index+=2):">"===e&&">"===this.source[this.index+1]?">"===this.source[this.index+2]?(e+=">>",this.index+=2):(e+=">",this.index++):"<"===e&&"<"===this.source[this.index+1]?(e+="<",this.index++):"="===e&&">"===this.source[this.index+1]&&(e+=">",this.index++):"&"!==e&&"|"!==e||this.source[this.index+1]!==e?"*"===e&&"*"===this.source[this.index+1]?(e+="*",this.index++):"?"!==e||"."!==this.source[this.index+1]&&"?"!==this.source[this.index+1]?"."===e&&"."===this.source[this.index+1]&&"."===this.source[this.index+1]?(e+="..",this.index+=2):"|"===e&&">"===this.source[this.index+1]&&(e+=">",this.index++):(e+=this.source[this.index+1],this.index++):(e+=e,this.index++),this.index++,{type:"PunctuatorToken",value:e,range:[t,this.index]}}nextIdentifierToken(){const e=this.findEndOfIdentifier();if(void 0===e){const e=[this.index,this.source.length],t=this.getExplicitIdentifierToken(this.source.substring(this.index),e);return this.index=this.source.length,t}const t=[this.index,e],n=this.getExplicitIdentifierToken(this.source.substring(this.index,e),t);return this.index=e,n}getExplicitIdentifierToken(e,t){return"true"===e||"false"===e?{type:"BooleanLiteral",value:"true"===e,range:t}:"this"===e?{type:"KeywordToken",name:e,range:t}:"null"===e?{type:"NullLiteral",range:t}:"and"===e?{type:"PunctuatorToken",value:"&&",range:t}:"or"===e?{type:"PunctuatorToken",value:"||",range:t}:"not"===e?{type:"PunctuatorToken",value:"!",range:t}:"await"===e?{type:"PunctuatorToken",value:e,range:t}:{type:"Identifier",name:e,range:t}}findEndOfIdentifier(){for(let e=this.index;ee>="0"&&e<="9",i=this.index;for(let a=this.index+1;ae>="0"&&e<="9"||e>="a"&&e<="f":"b"===s||"B"===s?e=>e>="0"&&e<="1":e=>e>="0"&&e<="7"}}const a=void 0===n?this.getNumber(this.index):n*10**this.getNumber(i);return this.index=this.source.length,{type:"NumericLiteral",value:a,range:[t,this.index]}}getNumber(e,t){return+Array.from(this.source.substring(e,t)).filter((e=>"_"!==e)).join("")}nextStringToken(e){const t=this.index;this.index++;const n=this.findEndOfString(e);if(void 0===n)throw new r.ExpressionError((0,r.replaceLocaleParameters)(this.locale.expect,e,t),[t,this.source.length]);const o=this.source.substring(this.index,n);return this.index=n+1,{type:"StringLiteral",value:o,range:[t,this.index]}}findEndOfString(e){for(let t=this.index;t","<","=","!","&","^","|"],s=["(",")","[","]","{","}",...a,"?",":",",","~"]},7469:(e,t,n)=>{"use strict";var r,o;function i(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function a(e,t){this.source=e,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=t,this.destLen=0,this.ltree=new i,this.dtree=new i}n.d(t,{parse:()=>Lr}),String.prototype.codePointAt||(o=function(e){if(null==this)throw TypeError();var t=String(this),n=t.length,r=e?Number(e):0;if(r!=r&&(r=0),!(r<0||r>=n)){var o,i=t.charCodeAt(r);return i>=55296&&i<=56319&&n>r+1&&(o=t.charCodeAt(r+1))>=56320&&o<=57343?1024*(i-55296)+o-56320+65536:i}},(r=function(){try{var e={},t=Object.defineProperty,n=t(e,e,e)&&t}catch(e){}return n}())?r(String.prototype,"codePointAt",{value:o,configurable:!0,writable:!0}):String.prototype.codePointAt=o);var s=new i,c=new i,l=new Uint8Array(30),u=new Uint16Array(30),p=new Uint8Array(30),d=new Uint16Array(30),f=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),g=new i,h=new Uint8Array(320);function m(e,t,n,r){var o,i;for(o=0;o>>=1,t}function b(e,t,n){if(!t)return n;for(;e.bitcount<24;)e.tag|=e.source[e.sourceIndex++]<>>16-t;return e.tag>>>=t,e.bitcount-=t,r+n}function C(e,t){for(;e.bitcount<24;)e.tag|=e.source[e.sourceIndex++]<>>=1,++o,n+=t.table[o],r-=t.table[o]}while(r>=0);return e.tag=i,e.bitcount-=o,t.trans[n+r]}function E(e,t,n){var r,o,i,a,s,c;for(r=b(e,5,257),o=b(e,5,1),i=b(e,4,4),a=0;a<19;++a)h[a]=0;for(a=0;a8;)e.sourceIndex--,e.bitcount-=8;if((t=256*(t=e.source[e.sourceIndex+1])+e.source[e.sourceIndex])!==(65535&~(256*e.source[e.sourceIndex+3]+e.source[e.sourceIndex+2])))return-3;for(e.sourceIndex+=4,n=t;n;--n)e.dest[e.destLen++]=e.source[e.sourceIndex++];return e.bitcount=0,0}!function(e,t){var n;for(n=0;n<7;++n)e.table[n]=0;for(e.table[7]=24,e.table[8]=152,e.table[9]=112,n=0;n<24;++n)e.trans[n]=256+n;for(n=0;n<144;++n)e.trans[24+n]=n;for(n=0;n<8;++n)e.trans[168+n]=280+n;for(n=0;n<112;++n)e.trans[176+n]=144+n;for(n=0;n<5;++n)t.table[n]=0;for(t.table[5]=32,n=0;n<32;++n)t.trans[n]=n}(s,c),m(l,u,4,3),m(p,d,2,1),l[28]=0,u[28]=258;var k=function(e,t){var n,r,o=new a(e,t);do{switch(n=x(o),b(o,2,0)){case 0:r=w(o);break;case 1:r=P(o,s,c);break;case 2:E(o,o.ltree,o.dtree),r=P(o,o.ltree,o.dtree);break;default:r=-3}if(0!==r)throw new Error("Data error")}while(!n);return o.destLenthis.x2&&(this.x2=e)),"number"==typeof t&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=t,this.y2=t),tthis.y2&&(this.y2=t))},S.prototype.addX=function(e){this.addPoint(e,null)},S.prototype.addY=function(e){this.addPoint(null,e)},S.prototype.addBezier=function(e,t,n,r,o,i,a,s){var c=[e,t],l=[n,r],u=[o,i],p=[a,s];this.addPoint(e,t),this.addPoint(a,s);for(var d=0;d<=1;d++){var f=6*c[d]-12*l[d]+6*u[d],g=-3*c[d]+9*l[d]-9*u[d]+3*p[d],h=3*l[d]-3*c[d];if(0!==g){var m=Math.pow(f,2)-4*h*g;if(!(m<0)){var y=(-f+Math.sqrt(m))/(2*g);0=0&&r>0&&(n+=" "),n+=t(o)}return n}e=void 0!==e?e:2;for(var r="",o=0;o"},R.prototype.toDOMElement=function(e){var t=this.toPathData(e),n=document.createElementNS("http://www.w3.org/2000/svg","path");return n.setAttribute("d",t),n};var L={fail:T,argument:A,assert:A},M=2147483648,I={},O={},D={};function B(e){return function(){return e}}O.BYTE=function(e){return L.argument(e>=0&&e<=255,"Byte value should be between 0 and 255."),[e]},D.BYTE=B(1),O.CHAR=function(e){return[e.charCodeAt(0)]},D.CHAR=B(1),O.CHARARRAY=function(e){void 0===e&&(e="",console.warn("Undefined CHARARRAY encountered and treated as an empty string. This is probably caused by a missing glyph name."));for(var t=[],n=0;n>8&255,255&e]},D.USHORT=B(2),O.SHORT=function(e){return e>=32768&&(e=-(65536-e)),[e>>8&255,255&e]},D.SHORT=B(2),O.UINT24=function(e){return[e>>16&255,e>>8&255,255&e]},D.UINT24=B(3),O.ULONG=function(e){return[e>>24&255,e>>16&255,e>>8&255,255&e]},D.ULONG=B(4),O.LONG=function(e){return e>=M&&(e=-(2*M-e)),[e>>24&255,e>>16&255,e>>8&255,255&e]},D.LONG=B(4),O.FIXED=O.ULONG,D.FIXED=D.ULONG,O.FWORD=O.SHORT,D.FWORD=D.SHORT,O.UFWORD=O.USHORT,D.UFWORD=D.USHORT,O.LONGDATETIME=function(e){return[0,0,0,0,e>>24&255,e>>16&255,e>>8&255,255&e]},D.LONGDATETIME=B(8),O.TAG=function(e){return L.argument(4===e.length,"Tag should be exactly 4 ASCII characters."),[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]},D.TAG=B(4),O.Card8=O.BYTE,D.Card8=D.BYTE,O.Card16=O.USHORT,D.Card16=D.USHORT,O.OffSize=O.BYTE,D.OffSize=D.BYTE,O.SID=O.USHORT,D.SID=D.USHORT,O.NUMBER=function(e){return e>=-107&&e<=107?[e+139]:e>=108&&e<=1131?[247+((e-=108)>>8),255&e]:e>=-1131&&e<=-108?[251+((e=-e-108)>>8),255&e]:e>=-32768&&e<=32767?O.NUMBER16(e):O.NUMBER32(e)},D.NUMBER=function(e){return O.NUMBER(e).length},O.NUMBER16=function(e){return[28,e>>8&255,255&e]},D.NUMBER16=B(3),O.NUMBER32=function(e){return[29,e>>24&255,e>>16&255,e>>8&255,255&e]},D.NUMBER32=B(5),O.REAL=function(e){var t=e.toString(),n=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(t);if(n){var r=parseFloat("1e"+((n[2]?+n[2]:0)+n[1].length));t=(Math.round(e*r)/r).toString()}for(var o="",i=0,a=t.length;i>8&255,t[t.length]=255&r}return t},D.UTF16=function(e){return 2*e.length};var z={"x-mac-croatian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®Š™´¨≠ŽØ∞±≤≥∆µ∂∑∏š∫ªºΩžø¿¡¬√ƒ≈Ć«Č… ÀÃÕŒœĐ—“”‘’÷◊©⁄€‹›Æ»–·‚„‰ÂćÁčÈÍÎÏÌÓÔđÒÚÛÙıˆ˜¯πË˚¸Êæˇ","x-mac-cyrillic":"АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ†°Ґ£§•¶І®©™Ђђ≠Ѓѓ∞±≤≥іµґЈЄєЇїЉљЊњјЅ¬√ƒ≈∆«»… ЋћЌќѕ–—“”‘’÷„ЎўЏџ№Ёёяабвгдежзийклмнопрстуфхцчшщъыьэю","x-mac-gaelic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØḂ±≤≥ḃĊċḊḋḞḟĠġṀæøṁṖṗɼƒſṠ«»… ÀÃÕŒœ–—“”‘’ṡẛÿŸṪ€‹›Ŷŷṫ·Ỳỳ⁊ÂÊÁËÈÍÎÏÌÓÔ♣ÒÚÛÙıÝýŴŵẄẅẀẁẂẃ","x-mac-greek":"Ĺ²É³ÖÜ΅àâä΄¨çéèê룙î‰ôö¦€ùûü†ΓΔΘΛΞΠß®©ΣΪ§≠°·Α±≤≥¥ΒΕΖΗΙΚΜΦΫΨΩάΝ¬ΟΡ≈Τ«»… ΥΧΆΈœ–―“”‘’÷ΉΊΌΎέήίόΏύαβψδεφγηιξκλμνοπώρστθωςχυζϊϋΐΰ­","x-mac-icelandic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûüÝ°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€ÐðÞþý·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-inuit":"ᐃᐄᐅᐆᐊᐋᐱᐲᐳᐴᐸᐹᑉᑎᑏᑐᑑᑕᑖᑦᑭᑮᑯᑰᑲᑳᒃᒋᒌᒍᒎᒐᒑ°ᒡᒥᒦ•¶ᒧ®©™ᒨᒪᒫᒻᓂᓃᓄᓅᓇᓈᓐᓯᓰᓱᓲᓴᓵᔅᓕᓖᓗᓘᓚᓛᓪᔨᔩᔪᔫᔭ… ᔮᔾᕕᕖᕗ–—“”‘’ᕘᕙᕚᕝᕆᕇᕈᕉᕋᕌᕐᕿᖀᖁᖂᖃᖄᖅᖏᖐᖑᖒᖓᖔᖕᙱᙲᙳᙴᙵᙶᖖᖠᖡᖢᖣᖤᖥᖦᕼŁł","x-mac-ce":"ÄĀāÉĄÖÜáąČäčĆć鏟ĎíďĒēĖóėôöõúĚěü†°Ę£§•¶ß®©™ę¨≠ģĮįĪ≤≥īĶ∂∑łĻļĽľĹĺŅņѬ√ńŇ∆«»… ňŐÕőŌ–—“”‘’÷◊ōŔŕŘ‹›řŖŗŠ‚„šŚśÁŤťÍŽžŪÓÔūŮÚůŰűŲųÝýķŻŁżĢˇ",macintosh:"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›fifl‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-romanian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ĂȘ∞±≤≥¥µ∂∑∏π∫ªºΩăș¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›Țț‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-turkish":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸĞğİıŞş‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙˆ˜¯˘˙˚¸˝˛ˇ"};I.MACSTRING=function(e,t,n,r){var o=z[r];if(void 0!==o){for(var i="",a=0;a=-128&&e<=127}function G(e,t,n){for(var r=0,o=e.length;t>8&255,c+256&255)}return i}O.MACSTRING=function(e,t){var n=function(e){if(!F)for(var t in F={},z)F[t]=new String(t);var n=F[e];if(void 0!==n){if(N){var r=N.get(n);if(void 0!==r)return r}var o=z[e];if(void 0!==o){for(var i={},a=0;a=128&&void 0===(i=n[i]))return;r[o]=i}return r}},D.MACSTRING=function(e,t){var n=O.MACSTRING(e,t);return void 0!==n?n.length:0},O.VARDELTAS=function(e){for(var t=0,n=[];t=-128&&r<=127?j(e,t,n):V(e,t,n)}return n},O.INDEX=function(e){for(var t=1,n=[t],r=[],o=0;o>8,t[p+1]=255&d,t=t.concat(r[u])}return t},D.TABLE=function(e){for(var t=0,n=e.fields.length,r=0;r0)return new ie(this.data,this.offset+t).parseStruct(e)},ie.prototype.parsePointer32=function(e){var t=this.parseOffset32();if(t>0)return new ie(this.data,this.offset+t).parseStruct(e)},ie.prototype.parseListOfLists=function(e){for(var t=this.parseOffset16List(),n=t.length,r=this.relativeOffset,o=new Array(n),i=0;i=0;o-=1){var i=se.getUShort(e,t+4+8*o),a=se.getUShort(e,t+4+8*o+2);if(3===i&&(0===a||1===a||10===a)||0===i&&(0===a||1===a||2===a||3===a||4===a)){r=se.getULong(e,t+4+8*o+4);break}}if(-1===r)throw new Error("No valid cmap sub-tables found.");var s=new se.Parser(e,t+r);if(n.format=s.parseUShort(),12===n.format)!function(e,t){var n;t.parseUShort(),e.length=t.parseULong(),e.language=t.parseULong(),e.groupCount=n=t.parseULong(),e.glyphIndexMap={};for(var r=0;r>1,t.skip("uShort",3),e.glyphIndexMap={};for(var a=new se.Parser(n,r+o+14),s=new se.Parser(n,r+o+16+2*i),c=new se.Parser(n,r+o+16+4*i),l=new se.Parser(n,r+o+16+6*i),u=r+o+16+8*i,p=0;p0;t-=1)if(e.get(t).unicode>65535){console.log("Adding CMAP format 12 (needed!)"),n=!1;break}var r=[{name:"version",type:"USHORT",value:0},{name:"numTables",type:"USHORT",value:n?1:2},{name:"platformID",type:"USHORT",value:3},{name:"encodingID",type:"USHORT",value:1},{name:"offset",type:"ULONG",value:n?12:20}];n||(r=r.concat([{name:"cmap12PlatformID",type:"USHORT",value:3},{name:"cmap12EncodingID",type:"USHORT",value:10},{name:"cmap12Offset",type:"ULONG",value:0}])),r=r.concat([{name:"format",type:"USHORT",value:4},{name:"cmap4Length",type:"USHORT",value:0},{name:"language",type:"USHORT",value:0},{name:"segCountX2",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0}]);var o=new J.Table("cmap",r);for(o.segments=[],t=0;t>4,i=15&r;if(15===o)break;if(t+=n[o],15===i)break;t+=n[i]}return parseFloat(t)}(e);if(t>=32&&t<=246)return t-139;if(t>=247&&t<=250)return 256*(t-247)+e.parseByte()+108;if(t>=251&&t<=254)return 256*-(t-251)-e.parseByte()-108;throw new Error("Invalid b0 "+t)}function Se(e,t,n){t=void 0!==t?t:0;var r=new se.Parser(e,t),o=[],i=[];for(n=void 0!==n?n:e.length;r.relativeOffset>1,d.length=0,g=!0}return function n(l){for(var v,x,P,w,k,_,S,R,T,A,L,M,I=0;I1&&!g&&(b=d.shift()+u,g=!0),y+=d.pop(),C(m,y);break;case 5:for(;d.length>0;)m+=d.shift(),y+=d.shift(),p.lineTo(m,y);break;case 6:for(;d.length>0&&(m+=d.shift(),p.lineTo(m,y),0!==d.length);)y+=d.shift(),p.lineTo(m,y);break;case 7:for(;d.length>0&&(y+=d.shift(),p.lineTo(m,y),0!==d.length);)m+=d.shift(),p.lineTo(m,y);break;case 8:for(;d.length>0;)r=m+d.shift(),o=y+d.shift(),i=r+d.shift(),a=o+d.shift(),m=i+d.shift(),y=a+d.shift(),p.curveTo(r,o,i,a,m,y);break;case 10:k=d.pop()+c,(_=s[k])&&n(_);break;case 11:return;case 12:switch(O=l[I],I+=1,O){case 35:r=m+d.shift(),o=y+d.shift(),i=r+d.shift(),a=o+d.shift(),S=i+d.shift(),R=a+d.shift(),T=S+d.shift(),A=R+d.shift(),L=T+d.shift(),M=A+d.shift(),m=L+d.shift(),y=M+d.shift(),d.shift(),p.curveTo(r,o,i,a,S,R),p.curveTo(T,A,L,M,m,y);break;case 34:r=m+d.shift(),o=y,i=r+d.shift(),a=o+d.shift(),S=i+d.shift(),R=a,T=S+d.shift(),A=a,L=T+d.shift(),M=y,m=L+d.shift(),p.curveTo(r,o,i,a,S,R),p.curveTo(T,A,L,M,m,y);break;case 36:r=m+d.shift(),o=y+d.shift(),i=r+d.shift(),a=o+d.shift(),S=i+d.shift(),R=a,T=S+d.shift(),A=a,L=T+d.shift(),M=A+d.shift(),m=L+d.shift(),p.curveTo(r,o,i,a,S,R),p.curveTo(T,A,L,M,m,y);break;case 37:r=m+d.shift(),o=y+d.shift(),i=r+d.shift(),a=o+d.shift(),S=i+d.shift(),R=a+d.shift(),T=S+d.shift(),A=R+d.shift(),L=T+d.shift(),M=A+d.shift(),Math.abs(L-m)>Math.abs(M-y)?m=L+d.shift():y=M+d.shift(),p.curveTo(r,o,i,a,S,R),p.curveTo(T,A,L,M,m,y);break;default:console.log("Glyph "+t.index+": unknown operator 1200"+O),d.length=0}break;case 14:d.length>0&&!g&&(b=d.shift()+u,g=!0),h&&(p.closePath(),h=!1);break;case 19:case 20:E(),I+=f+7>>3;break;case 21:d.length>2&&!g&&(b=d.shift()+u,g=!0),y+=d.pop(),C(m+=d.pop(),y);break;case 22:d.length>1&&!g&&(b=d.shift()+u,g=!0),C(m+=d.pop(),y);break;case 24:for(;d.length>2;)r=m+d.shift(),o=y+d.shift(),i=r+d.shift(),a=o+d.shift(),m=i+d.shift(),y=a+d.shift(),p.curveTo(r,o,i,a,m,y);m+=d.shift(),y+=d.shift(),p.lineTo(m,y);break;case 25:for(;d.length>6;)m+=d.shift(),y+=d.shift(),p.lineTo(m,y);r=m+d.shift(),o=y+d.shift(),i=r+d.shift(),a=o+d.shift(),m=i+d.shift(),y=a+d.shift(),p.curveTo(r,o,i,a,m,y);break;case 26:for(d.length%2&&(m+=d.shift());d.length>0;)r=m,o=y+d.shift(),i=r+d.shift(),a=o+d.shift(),m=i,y=a+d.shift(),p.curveTo(r,o,i,a,m,y);break;case 27:for(d.length%2&&(y+=d.shift());d.length>0;)r=m+d.shift(),o=y,i=r+d.shift(),a=o+d.shift(),m=i+d.shift(),y=a,p.curveTo(r,o,i,a,m,y);break;case 28:v=l[I],x=l[I+1],d.push((v<<24|x<<16)>>16),I+=2;break;case 29:k=d.pop()+e.gsubrsBias,(_=e.gsubrs[k])&&n(_);break;case 30:for(;d.length>0&&(r=m,o=y+d.shift(),i=r+d.shift(),a=o+d.shift(),m=i+d.shift(),y=a+(1===d.length?d.shift():0),p.curveTo(r,o,i,a,m,y),0!==d.length);)r=m+d.shift(),o=y,i=r+d.shift(),a=o+d.shift(),y=a+d.shift(),m=i+(1===d.length?d.shift():0),p.curveTo(r,o,i,a,m,y);break;case 31:for(;d.length>0&&(r=m+d.shift(),o=y,i=r+d.shift(),a=o+d.shift(),y=a+d.shift(),m=i+(1===d.length?d.shift():0),p.curveTo(r,o,i,a,m,y),0!==d.length);)r=m,o=y+d.shift(),i=r+d.shift(),a=o+d.shift(),m=i+d.shift(),y=a+(1===d.length?d.shift():0),p.curveTo(r,o,i,a,m,y);break;default:O<32?console.log("Glyph "+t.index+": unknown operator "+O):O<247?d.push(O-139):O<251?(v=l[I],I+=1,d.push(256*(O-247)+v+108)):O<255?(v=l[I],I+=1,d.push(256*-(O-251)-v-108)):(v=l[I],x=l[I+1],P=l[I+2],w=l[I+3],I+=4,d.push((v<<24|x<<16|P<<8|w)/65536))}}}(n),t.advanceWidth=b,p}function Be(e,t){var n,r=ue.indexOf(e);return r>=0&&(n=r),(r=t.indexOf(e))>=0?n=r+ue.length:(n=ue.length+t.length,t.push(e)),n}function ze(e,t,n){for(var r={},o=0;o=r)throw new Error("CFF table CID Font FDSelect has bad FD index value "+o+" (FD count "+r+")");i.push(o)}else{if(3!==s)throw new Error("CFF Table CID Font FDSelect table has unsupported format "+s);var l,u=a.parseCard16(),p=a.parseCard16();if(0!==p)throw new Error("CFF Table CID Font FDSelect format 3 range has bad initial GID "+p);for(var d=0;d=r)throw new Error("CFF table CID Font FDSelect has bad FD index value "+o+" (FD count "+r+")");if(l>n)throw new Error("CFF Table CID Font FDSelect format 3 range has bad GID "+l);for(;p=1&&(n.ulCodePageRange1=r.parseULong(),n.ulCodePageRange2=r.parseULong()),n.version>=2&&(n.sxHeight=r.parseShort(),n.sCapHeight=r.parseShort(),n.usDefaultChar=r.parseUShort(),n.usBreakChar=r.parseUShort(),n.usMaxContent=r.parseUShort()),n},make:function(e){return new J.Table("OS/2",[{name:"version",type:"USHORT",value:3},{name:"xAvgCharWidth",type:"SHORT",value:0},{name:"usWeightClass",type:"USHORT",value:0},{name:"usWidthClass",type:"USHORT",value:0},{name:"fsType",type:"USHORT",value:0},{name:"ySubscriptXSize",type:"SHORT",value:650},{name:"ySubscriptYSize",type:"SHORT",value:699},{name:"ySubscriptXOffset",type:"SHORT",value:0},{name:"ySubscriptYOffset",type:"SHORT",value:140},{name:"ySuperscriptXSize",type:"SHORT",value:650},{name:"ySuperscriptYSize",type:"SHORT",value:699},{name:"ySuperscriptXOffset",type:"SHORT",value:0},{name:"ySuperscriptYOffset",type:"SHORT",value:479},{name:"yStrikeoutSize",type:"SHORT",value:49},{name:"yStrikeoutPosition",type:"SHORT",value:258},{name:"sFamilyClass",type:"SHORT",value:0},{name:"bFamilyType",type:"BYTE",value:0},{name:"bSerifStyle",type:"BYTE",value:0},{name:"bWeight",type:"BYTE",value:0},{name:"bProportion",type:"BYTE",value:0},{name:"bContrast",type:"BYTE",value:0},{name:"bStrokeVariation",type:"BYTE",value:0},{name:"bArmStyle",type:"BYTE",value:0},{name:"bLetterform",type:"BYTE",value:0},{name:"bMidline",type:"BYTE",value:0},{name:"bXHeight",type:"BYTE",value:0},{name:"ulUnicodeRange1",type:"ULONG",value:0},{name:"ulUnicodeRange2",type:"ULONG",value:0},{name:"ulUnicodeRange3",type:"ULONG",value:0},{name:"ulUnicodeRange4",type:"ULONG",value:0},{name:"achVendID",type:"CHARARRAY",value:"XXXX"},{name:"fsSelection",type:"USHORT",value:0},{name:"usFirstCharIndex",type:"USHORT",value:0},{name:"usLastCharIndex",type:"USHORT",value:0},{name:"sTypoAscender",type:"SHORT",value:0},{name:"sTypoDescender",type:"SHORT",value:0},{name:"sTypoLineGap",type:"SHORT",value:0},{name:"usWinAscent",type:"USHORT",value:0},{name:"usWinDescent",type:"USHORT",value:0},{name:"ulCodePageRange1",type:"ULONG",value:0},{name:"ulCodePageRange2",type:"ULONG",value:0},{name:"sxHeight",type:"SHORT",value:0},{name:"sCapHeight",type:"SHORT",value:0},{name:"usDefaultChar",type:"USHORT",value:0},{name:"usBreakChar",type:"USHORT",value:0},{name:"usMaxContext",type:"USHORT",value:0}],e)},unicodeRanges:at,getUnicodeRange:function(e){for(var t=0;t=n.begin&&e=fe.length){var a=r.parseChar();n.names.push(r.parseString(a))}break;case 2.5:n.numberOfGlyphs=r.parseUShort(),n.offset=new Array(n.numberOfGlyphs);for(var s=0;st.value.tag?1:-1})),t.fields=t.fields.concat(r),t.fields=t.fields.concat(o),t}function vt(e,t,n){for(var r=0;r0)return e.glyphs.get(o).getMetrics()}return n}function xt(e){for(var t=0,n=0;nm||void 0===t)&&m>0&&(t=m),l 123 are reserved for internal usage");f|=1<0?He.make(M):void 0,D=ct.make(),B=Ge.make(e.glyphs,{version:e.getEnglishName("version"),fullName:R,familyName:_,weightName:S,postScriptName:T,unitsPerEm:e.unitsPerEm,fontBBox:[0,x.yMin,x.ascender,x.advanceWidthMax]}),z=e.metas&&Object.keys(e.metas).length>0?ft.make(e.metas):void 0,F=[b,C,E,P,I,k,D,B,w];O&&F.push(O),e.tables.gsub&&F.push(dt.make(e.tables.gsub)),z&&F.push(z);for(var N=yt(F),U=ht(N.encode()),G=N.fields,j=!1,V=0;V>>1,i=e[o].tag;if(i===t)return o;i>>1,i=e[o];if(i===t)return o;i>>1,a=(n=e[i]).start;if(a===t)return n;a0)return t>(n=e[r-1]).end?0:n}function wt(e,t){this.font=e,this.tableName=t}function kt(e){wt.call(this,e,"gpos")}function _t(e){wt.call(this,e,"gsub")}function St(e,t){var n=e.length;if(n!==t.length)return!1;for(var r=0;r0?(i=e.parseByte(),t&o||(i=-i),i=n+i):i=(t&o)>0?n:n+e.parseShort(),i}function Lt(e,t,n){var r,o,i=new se.Parser(t,n);if(e.numberOfContours=i.parseShort(),e._xMin=i.parseShort(),e._yMin=i.parseShort(),e._xMax=i.parseShort(),e._yMax=i.parseShort(),e.numberOfContours>0){for(var a=e.endPointIndices=[],s=0;s0)for(var p=i.parseByte(),d=0;d0){var f,g=[];if(l>0){for(var h=0;h=0,g.push(f);for(var m=0,y=0;y0?(2&r)>0?(C.dx=i.parseShort(),C.dy=i.parseShort()):C.matchedPoints=[i.parseUShort(),i.parseUShort()]:(2&r)>0?(C.dx=i.parseChar(),C.dy=i.parseChar()):C.matchedPoints=[i.parseByte(),i.parseByte()],(8&r)>0?C.xScale=C.yScale=i.parseF2Dot14():(64&r)>0?(C.xScale=i.parseF2Dot14(),C.yScale=i.parseF2Dot14()):(128&r)>0&&(C.xScale=i.parseF2Dot14(),C.scale01=i.parseF2Dot14(),C.scale10=i.parseF2Dot14(),C.yScale=i.parseF2Dot14()),e.components.push(C),b=!!(32&r)}if(256&r){e.instructionLength=i.parseUShort(),e.instructions=[];for(var E=0;Et.points.length-1||r.matchedPoints[1]>o.points.length-1)throw Error("Matched points out of range in "+t.name);var a=t.points[r.matchedPoints[0]],s=o.points[r.matchedPoints[1]],c={xScale:r.xScale,scale01:r.scale01,scale10:r.scale10,yScale:r.yScale,dx:0,dy:0};s=Mt([s],c)[0],c.dx=a.x-s.x,c.dy=a.y-s.y,i=Mt(o.points,c)}t.points=t.points.concat(i)}}return It(t.points)}wt.prototype={searchTag:Ct,binSearch:Et,getTable:function(e){var t=this.font.tables[this.tableName];return!t&&e&&(t=this.font.tables[this.tableName]=this.createDefaultTable()),t},getScriptNames:function(){var e=this.getTable();return e?e.scripts.map((function(e){return e.tag})):[]},getDefaultScriptName:function(){var e=this.getTable();if(e){for(var t=!1,n=0;n=0)return r[o].script;if(t){var i={tag:e,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return r.splice(-1-o,0,i),i.script}}},getLangSysTable:function(e,t,n){var r=this.getScriptTable(e,n);if(r){if(!t||"dflt"===t||"DFLT"===t)return r.defaultLangSys;var o=Ct(r.langSysRecords,t);if(o>=0)return r.langSysRecords[o].langSys;if(n){var i={tag:t,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return r.langSysRecords.splice(-1-o,0,i),i.langSys}}},getFeatureTable:function(e,t,n,r){var o=this.getLangSysTable(e,t,r);if(o){for(var i,a=o.featureIndexes,s=this.font.tables[this.tableName].features,c=0;c=s[l-1].tag,"Features must be added in alphabetical order."),i={tag:n,feature:{params:0,lookupListIndexes:[]}},s.push(i),a.push(l),i.feature}}},getLookupTables:function(e,t,n,r,o){var i=this.getFeatureTable(e,t,n,o),a=[];if(i){for(var s,c=i.lookupListIndexes,l=this.font.tables[this.tableName].lookups,u=0;u=0?n:-1;case 2:var r=Pt(e.ranges,t);return r?r.index+t-r.start:-1}},expandCoverage:function(e){if(1===e.format)return e.glyphs;for(var t=[],n=e.ranges,r=0;r1,'Multiple: "by" must be an array of two or more ids');var o=Rt(this.getLookupTables(n,r,e,2,!0)[0],1,{substFormat:1,coverage:{format:1,glyphs:[]},sequences:[]});L.assert(1===o.coverage.format,"Multiple: unable to modify coverage table format "+o.coverage.format);var i=t.sub,a=this.binSearch(o.coverage.glyphs,i);a<0&&(a=-1-a,o.coverage.glyphs.splice(a,0,i),o.sequences.splice(a,0,0)),o.sequences[a]=t.by},_t.prototype.addAlternate=function(e,t,n,r){var o=Rt(this.getLookupTables(n,r,e,3,!0)[0],1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});L.assert(1===o.coverage.format,"Alternate: unable to modify coverage table format "+o.coverage.format);var i=t.sub,a=this.binSearch(o.coverage.glyphs,i);a<0&&(a=-1-a,o.coverage.glyphs.splice(a,0,i),o.alternateSets.splice(a,0,0)),o.alternateSets[a]=t.by},_t.prototype.addLigature=function(e,t,n,r){var o=this.getLookupTables(n,r,e,4,!0)[0],i=o.subtables[0];i||(i={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},o.subtables[0]=i),L.assert(1===i.coverage.format,"Ligature: unable to modify coverage table format "+i.coverage.format);var a=t.sub[0],s=t.sub.slice(1),c={ligGlyph:t.by,components:s},l=this.binSearch(i.coverage.glyphs,a);if(l>=0){for(var u=i.ligatureSets[l],p=0;p=176&&n<=183)o+=n-176+1;else if(n>=184&&n<=191)o+=2*(n-184+1);else if(t&&1===i&&27===n)break}while(i>0);e.ip=o}function on(e,t){exports.DEBUG&&console.log(t.step,"SVTCA["+e.axis+"]"),t.fv=t.pv=t.dpv=e}function an(e,t){exports.DEBUG&&console.log(t.step,"SPVTCA["+e.axis+"]"),t.pv=t.dpv=e}function sn(e,t){exports.DEBUG&&console.log(t.step,"SFVTCA["+e.axis+"]"),t.fv=e}function cn(e,t){var n,r,o=t.stack,i=o.pop(),a=o.pop(),s=t.z2[i],c=t.z1[a];exports.DEBUG&&console.log("SPVTL["+e+"]",i,a),e?(n=s.y-c.y,r=c.x-s.x):(n=c.x-s.x,r=c.y-s.y),t.pv=t.dpv=Zt(n,r)}function ln(e,t){var n,r,o=t.stack,i=o.pop(),a=o.pop(),s=t.z2[i],c=t.z1[a];exports.DEBUG&&console.log("SFVTL["+e+"]",i,a),e?(n=s.y-c.y,r=c.x-s.x):(n=c.x-s.x,r=c.y-s.y),t.fv=Zt(n,r)}function un(e){exports.DEBUG&&console.log(e.step,"POP[]"),e.stack.pop()}function pn(e,t){var n=t.stack.pop(),r=t.z0[n],o=t.fv,i=t.pv;exports.DEBUG&&console.log(t.step,"MDAP["+e+"]",n);var a=i.distance(r,Jt);e&&(a=t.round(a)),o.setRelative(r,Jt,a,i),o.touch(r),t.rp0=t.rp1=n}function dn(e,t){var n,r,o,i=t.z2,a=i.length-2;exports.DEBUG&&console.log(t.step,"IUP["+e.axis+"]");for(var s=0;s1?"loop "+(t.loop-s)+": ":"")+"SHP["+(e?"rp1":"rp2")+"]",l)}t.loop=1}function gn(e,t){var n=t.stack,r=e?t.rp1:t.rp2,o=(e?t.z0:t.z1)[r],i=t.fv,a=t.pv,s=n.pop(),c=t.z2[t.contours[s]],l=c;exports.DEBUG&&console.log(t.step,"SHC["+e+"]",s);var u=a.distance(o,o,!1,!0);do{l!==o&&i.setRelative(l,l,u,a),l=l.nextPointOnContour}while(l!==c)}function hn(e,t){var n,r,o=t.stack,i=e?t.rp1:t.rp2,a=(e?t.z0:t.z1)[i],s=t.fv,c=t.pv,l=o.pop();switch(exports.DEBUG&&console.log(t.step,"SHZ["+e+"]",l),l){case 0:n=t.tZone;break;case 1:n=t.gZone;break;default:throw new Error("Invalid zone")}for(var u=c.distance(a,a,!1,!0),p=n.length-2,d=0;d",s),t.stack.push(Math.round(64*s))}function bn(e,t){var n=t.stack,r=n.pop(),o=t.fv,i=t.pv,a=t.ppem,s=t.deltaBase+16*(e-1),c=t.deltaShift,l=t.z0;exports.DEBUG&&console.log(t.step,"DELTAP["+e+"]",r,n);for(var u=0;u>4)===a){var f=(15&d)-8;f>=0&&f++,exports.DEBUG&&console.log(t.step,"DELTAPFIX",p,"by",f*c);var g=l[p];o.setRelative(g,g,f*c,i)}}}function Cn(e,t){var n=t.stack,r=n.pop();exports.DEBUG&&console.log(t.step,"ROUND[]"),n.push(64*t.round(r/64))}function En(e,t){var n=t.stack,r=n.pop(),o=t.ppem,i=t.deltaBase+16*(e-1),a=t.deltaShift;exports.DEBUG&&console.log(t.step,"DELTAC["+e+"]",r,n);for(var s=0;s>4)===o){var u=(15&l)-8;u>=0&&u++;var p=u*a;exports.DEBUG&&console.log(t.step,"DELTACFIX",c,"by",p),t.cvt[c]+=p}}}function Pn(e,t){var n,r,o=t.stack,i=o.pop(),a=o.pop(),s=t.z2[i],c=t.z1[a];exports.DEBUG&&console.log(t.step,"SDPVTL["+e+"]",i,a),e?(n=s.y-c.y,r=c.x-s.x):(n=c.x-s.x,r=c.y-s.y),t.dpv=Zt(n,r)}function wn(e,t){var n=t.stack,r=t.prog,o=t.ip;exports.DEBUG&&console.log(t.step,"PUSHB["+e+"]");for(var i=0;i=0?1:-1,s=Math.abs(s),e&&(l=i.cvt[p],r&&Math.abs(s-l)":"_")+(r?"R":"_")+(0===o?"Gr":1===o?"Bl":2===o?"Wh":"")+"]",e?p+"("+i.cvt[p]+","+l+")":"",d,"(d =",a,"->",c*s,")"),i.rp1=i.rp0,i.rp2=d,t&&(i.rp0=d)}function Sn(e){this.char=e,this.state={},this.activeState=null}function Rn(e,t,n){this.contextName=n,this.startIndex=e,this.endOffset=t}function Tn(e,t,n){this.contextName=e,this.openRange=null,this.ranges=[],this.checkStart=t,this.checkEnd=n}function An(e,t){this.context=e,this.index=t,this.length=e.length,this.current=e[t],this.backtrack=e.slice(0,t),this.lookahead=e.slice(t+1)}function Ln(e){this.eventId=e,this.subscribers=[]}function Mn(e){var t=this,n=["start","end","next","newToken","contextStart","contextEnd","insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD","updateContextsRanges"];n.forEach((function(e){Object.defineProperty(t.events,e,{value:new Ln(e)})})),e&&n.forEach((function(n){var r=e[n];"function"==typeof r&&t.events[n].subscribe(r)})),["insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD"].forEach((function(e){t.events[e].subscribe(t.updateContextsRanges)}))}function In(e){this.tokens=[],this.registeredContexts={},this.contextCheckers=[],this.events={},this.registeredModifiers=[],Mn.call(this,e)}function On(e){return/[\u0600-\u065F\u066A-\u06D2\u06FA-\u06FF]/.test(e)}function Dn(e){return/[\u0630\u0690\u0621\u0631\u0661\u0671\u0622\u0632\u0672\u0692\u06C2\u0623\u0673\u0693\u06C3\u0624\u0694\u06C4\u0625\u0675\u0695\u06C5\u06E5\u0676\u0696\u06C6\u0627\u0677\u0697\u06C7\u0648\u0688\u0698\u06C8\u0689\u0699\u06C9\u068A\u06CA\u066B\u068B\u06CB\u068C\u068D\u06CD\u06FD\u068E\u06EE\u06FE\u062F\u068F\u06CF\u06EF]/.test(e)}function Bn(e){return/[\u0600-\u0605\u060C-\u060E\u0610-\u061B\u061E\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED]/.test(e)}function zn(e){return/[A-z]/.test(e)}function Fn(e){this.font=e,this.features={}}function Nn(e){this.id=e.id,this.tag=e.tag,this.substitution=e.substitution}function Un(e,t){if(!e)return-1;switch(t.format){case 1:return t.glyphs.indexOf(e);case 2:for(var n=t.ranges,r=0;r=o.start&&e<=o.end){var i=e-o.start;return o.index+i}}break;default:return-1}return-1}function Gn(e,t){return-1===Un(e,t.coverage)?null:e+t.deltaGlyphId}function jn(e,t){var n=Un(e,t.coverage);return-1===n?null:t.substitute[n]}function Vn(e,t){for(var n=[],r=0;r2)){var n=this.font,r=this._prepState;if(!r||r.ppem!==t){var o=this._fpgmState;if(!o){tn.prototype=en,(o=this._fpgmState=new tn("fpgm",n.tables.fpgm)).funcs=[],o.font=n,exports.DEBUG&&(console.log("---EXEC FPGM---"),o.step=-1);try{Bt(o)}catch(e){return console.log("Hinting error in FPGM:"+e),void(this._errorState=3)}}tn.prototype=o,(r=this._prepState=new tn("prep",n.tables.prep)).ppem=t;var i=n.tables.cvt;if(i)for(var a=r.cvt=new Array(i.length),s=t/n.unitsPerEm,c=0;c1))try{return zt(e,r)}catch(e){return this._errorState<1&&(console.log("Hinting error:"+e),console.log("Note: further hinting errors are silenced")),void(this._errorState=1)}}},zt=function(e,t){var n,r,o,i=t.ppem/t.font.unitsPerEm,a=i,s=e.components;if(tn.prototype=t,s){var c=t.font;r=[],n=[];for(var l=0;l1?"loop "+(e.loop-n)+": ":"")+"SHPIX[]",a,o),r.setRelative(s,s,o),r.touch(s)}e.loop=1},function(e){for(var t=e.stack,n=e.rp1,r=e.rp2,o=e.loop,i=e.z0[n],a=e.z1[r],s=e.fv,c=e.dpv,l=e.z2;o--;){var u=t.pop(),p=l[u];exports.DEBUG&&console.log(e.step,(e.loop>1?"loop "+(e.loop-o)+": ":"")+"IP[]",u,n,"<->",r),s.interpolate(p,i,a,c),s.touch(p)}e.loop=1},mn.bind(void 0,0),mn.bind(void 0,1),function(e){for(var t=e.stack,n=e.rp0,r=e.z0[n],o=e.loop,i=e.fv,a=e.pv,s=e.z1;o--;){var c=t.pop(),l=s[c];exports.DEBUG&&console.log(e.step,(e.loop>1?"loop "+(e.loop-o)+": ":"")+"ALIGNRP[]",c),i.setRelative(l,r,0,a),i.touch(l)}e.loop=1},function(e){exports.DEBUG&&console.log(e.step,"RTDG[]"),e.round=Vt},yn.bind(void 0,0),yn.bind(void 0,1),function(e){var t=e.prog,n=e.ip,r=e.stack,o=t[++n];exports.DEBUG&&console.log(e.step,"NPUSHB[]",o);for(var i=0;in?1:0)},function(e){var t=e.stack,n=t.pop(),r=t.pop();exports.DEBUG&&console.log(e.step,"GTEQ[]",n,r),t.push(r>=n?1:0)},function(e){var t=e.stack,n=t.pop(),r=t.pop();exports.DEBUG&&console.log(e.step,"EQ[]",n,r),t.push(n===r?1:0)},function(e){var t=e.stack,n=t.pop(),r=t.pop();exports.DEBUG&&console.log(e.step,"NEQ[]",n,r),t.push(n!==r?1:0)},function(e){var t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"ODD[]",n),t.push(Math.trunc(n)%2?1:0)},function(e){var t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"EVEN[]",n),t.push(Math.trunc(n)%2?0:1)},function(e){var t=e.stack.pop();exports.DEBUG&&console.log(e.step,"IF[]",t),t||(rn(e,!0),exports.DEBUG&&console.log(e.step,"EIF[]"))},function(e){exports.DEBUG&&console.log(e.step,"EIF[]")},function(e){var t=e.stack,n=t.pop(),r=t.pop();exports.DEBUG&&console.log(e.step,"AND[]",n,r),t.push(n&&r?1:0)},function(e){var t=e.stack,n=t.pop(),r=t.pop();exports.DEBUG&&console.log(e.step,"OR[]",n,r),t.push(n||r?1:0)},function(e){var t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"NOT[]",n),t.push(n?0:1)},bn.bind(void 0,1),function(e){var t=e.stack.pop();exports.DEBUG&&console.log(e.step,"SDB[]",t),e.deltaBase=t},function(e){var t=e.stack.pop();exports.DEBUG&&console.log(e.step,"SDS[]",t),e.deltaShift=Math.pow(.5,t)},function(e){var t=e.stack,n=t.pop(),r=t.pop();exports.DEBUG&&console.log(e.step,"ADD[]",n,r),t.push(r+n)},function(e){var t=e.stack,n=t.pop(),r=t.pop();exports.DEBUG&&console.log(e.step,"SUB[]",n,r),t.push(r-n)},function(e){var t=e.stack,n=t.pop(),r=t.pop();exports.DEBUG&&console.log(e.step,"DIV[]",n,r),t.push(64*r/n)},function(e){var t=e.stack,n=t.pop(),r=t.pop();exports.DEBUG&&console.log(e.step,"MUL[]",n,r),t.push(r*n/64)},function(e){var t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"ABS[]",n),t.push(Math.abs(n))},function(e){var t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"NEG[]",n),t.push(-n)},function(e){var t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"FLOOR[]",n),t.push(64*Math.floor(n/64))},function(e){var t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"CEILING[]",n),t.push(64*Math.ceil(n/64))},Cn.bind(void 0,0),Cn.bind(void 0,1),Cn.bind(void 0,2),Cn.bind(void 0,3),void 0,void 0,void 0,void 0,function(e){var t=e.stack,n=t.pop(),r=t.pop();exports.DEBUG&&console.log(e.step,"WCVTF[]",n,r),e.cvt[r]=n*e.ppem/e.font.unitsPerEm},bn.bind(void 0,2),bn.bind(void 0,3),En.bind(void 0,1),En.bind(void 0,2),En.bind(void 0,3),function(e){var t,n=e.stack.pop();switch(exports.DEBUG&&console.log(e.step,"SROUND[]",n),e.round=$t,192&n){case 0:t=.5;break;case 64:t=1;break;case 128:t=2;break;default:throw new Error("invalid SROUND value")}switch(e.srPeriod=t,48&n){case 0:e.srPhase=0;break;case 16:e.srPhase=.25*t;break;case 32:e.srPhase=.5*t;break;case 48:e.srPhase=.75*t;break;default:throw new Error("invalid SROUND value")}n&=15,e.srThreshold=0===n?0:(n/8-.5)*t},function(e){var t,n=e.stack.pop();switch(exports.DEBUG&&console.log(e.step,"S45ROUND[]",n),e.round=$t,192&n){case 0:t=Math.sqrt(2)/2;break;case 64:t=Math.sqrt(2);break;case 128:t=2*Math.sqrt(2);break;default:throw new Error("invalid S45ROUND value")}switch(e.srPeriod=t,48&n){case 0:e.srPhase=0;break;case 16:e.srPhase=.25*t;break;case 32:e.srPhase=.5*t;break;case 48:e.srPhase=.75*t;break;default:throw new Error("invalid S45ROUND value")}n&=15,e.srThreshold=0===n?0:(n/8-.5)*t},void 0,void 0,function(e){exports.DEBUG&&console.log(e.step,"ROFF[]"),e.round=Gt},void 0,function(e){exports.DEBUG&&console.log(e.step,"RUTG[]"),e.round=Ht},function(e){exports.DEBUG&&console.log(e.step,"RDTG[]"),e.round=qt},un,un,void 0,void 0,void 0,void 0,void 0,function(e){var t=e.stack.pop();exports.DEBUG&&console.log(e.step,"SCANCTRL[]",t)},Pn.bind(void 0,0),Pn.bind(void 0,1),function(e){var t=e.stack,n=t.pop(),r=0;exports.DEBUG&&console.log(e.step,"GETINFO[]",n),1&n&&(r=35),32&n&&(r|=4096),t.push(r)},void 0,function(e){var t=e.stack,n=t.pop(),r=t.pop(),o=t.pop();exports.DEBUG&&console.log(e.step,"ROLL[]"),t.push(r),t.push(n),t.push(o)},function(e){var t=e.stack,n=t.pop(),r=t.pop();exports.DEBUG&&console.log(e.step,"MAX[]",n,r),t.push(Math.max(r,n))},function(e){var t=e.stack,n=t.pop(),r=t.pop();exports.DEBUG&&console.log(e.step,"MIN[]",n,r),t.push(Math.min(r,n))},function(e){var t=e.stack.pop();exports.DEBUG&&console.log(e.step,"SCANTYPE[]",t)},function(e){var t=e.stack.pop(),n=e.stack.pop();switch(exports.DEBUG&&console.log(e.step,"INSTCTRL[]",t,n),t){case 1:return void(e.inhibitGridFit=!!n);case 2:return void(e.ignoreCvt=!!n);default:throw new Error("invalid INSTCTRL[] selector")}},void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,wn.bind(void 0,1),wn.bind(void 0,2),wn.bind(void 0,3),wn.bind(void 0,4),wn.bind(void 0,5),wn.bind(void 0,6),wn.bind(void 0,7),wn.bind(void 0,8),kn.bind(void 0,1),kn.bind(void 0,2),kn.bind(void 0,3),kn.bind(void 0,4),kn.bind(void 0,5),kn.bind(void 0,6),kn.bind(void 0,7),kn.bind(void 0,8),_n.bind(void 0,0,0,0,0,0),_n.bind(void 0,0,0,0,0,1),_n.bind(void 0,0,0,0,0,2),_n.bind(void 0,0,0,0,0,3),_n.bind(void 0,0,0,0,1,0),_n.bind(void 0,0,0,0,1,1),_n.bind(void 0,0,0,0,1,2),_n.bind(void 0,0,0,0,1,3),_n.bind(void 0,0,0,1,0,0),_n.bind(void 0,0,0,1,0,1),_n.bind(void 0,0,0,1,0,2),_n.bind(void 0,0,0,1,0,3),_n.bind(void 0,0,0,1,1,0),_n.bind(void 0,0,0,1,1,1),_n.bind(void 0,0,0,1,1,2),_n.bind(void 0,0,0,1,1,3),_n.bind(void 0,0,1,0,0,0),_n.bind(void 0,0,1,0,0,1),_n.bind(void 0,0,1,0,0,2),_n.bind(void 0,0,1,0,0,3),_n.bind(void 0,0,1,0,1,0),_n.bind(void 0,0,1,0,1,1),_n.bind(void 0,0,1,0,1,2),_n.bind(void 0,0,1,0,1,3),_n.bind(void 0,0,1,1,0,0),_n.bind(void 0,0,1,1,0,1),_n.bind(void 0,0,1,1,0,2),_n.bind(void 0,0,1,1,0,3),_n.bind(void 0,0,1,1,1,0),_n.bind(void 0,0,1,1,1,1),_n.bind(void 0,0,1,1,1,2),_n.bind(void 0,0,1,1,1,3),_n.bind(void 0,1,0,0,0,0),_n.bind(void 0,1,0,0,0,1),_n.bind(void 0,1,0,0,0,2),_n.bind(void 0,1,0,0,0,3),_n.bind(void 0,1,0,0,1,0),_n.bind(void 0,1,0,0,1,1),_n.bind(void 0,1,0,0,1,2),_n.bind(void 0,1,0,0,1,3),_n.bind(void 0,1,0,1,0,0),_n.bind(void 0,1,0,1,0,1),_n.bind(void 0,1,0,1,0,2),_n.bind(void 0,1,0,1,0,3),_n.bind(void 0,1,0,1,1,0),_n.bind(void 0,1,0,1,1,1),_n.bind(void 0,1,0,1,1,2),_n.bind(void 0,1,0,1,1,3),_n.bind(void 0,1,1,0,0,0),_n.bind(void 0,1,1,0,0,1),_n.bind(void 0,1,1,0,0,2),_n.bind(void 0,1,1,0,0,3),_n.bind(void 0,1,1,0,1,0),_n.bind(void 0,1,1,0,1,1),_n.bind(void 0,1,1,0,1,2),_n.bind(void 0,1,1,0,1,3),_n.bind(void 0,1,1,1,0,0),_n.bind(void 0,1,1,1,0,1),_n.bind(void 0,1,1,1,0,2),_n.bind(void 0,1,1,1,0,3),_n.bind(void 0,1,1,1,1,0),_n.bind(void 0,1,1,1,1,1),_n.bind(void 0,1,1,1,1,2),_n.bind(void 0,1,1,1,1,3)],Sn.prototype.setState=function(e,t){return this.state[e]=t,this.activeState={key:e,value:this.state[e]},this.activeState},Sn.prototype.getState=function(e){return this.state[e]||null},In.prototype.inboundIndex=function(e){return e>=0&&e0&&e<=this.lookahead.length:return this.lookahead[e-1];default:return null}},In.prototype.rangeToText=function(e){if(e instanceof Rn)return this.getRangeTokens(e).map((function(e){return e.char})).join("")},In.prototype.getText=function(){return this.tokens.map((function(e){return e.char})).join("")},In.prototype.getContext=function(e){return this.registeredContexts[e]||null},In.prototype.on=function(e,t){var n=this.events[e];return n?n.subscribe(t):null},In.prototype.dispatch=function(e,t){var n=this,r=this.events[e];r instanceof Ln&&r.subscribers.forEach((function(e){e.apply(n,t||[])}))},In.prototype.registerContextChecker=function(e,t,n){if(this.getContext(e))return{FAIL:"context name '"+e+"' is already registered."};if("function"!=typeof t)return{FAIL:"missing context start check."};if("function"!=typeof n)return{FAIL:"missing context end check."};var r=new Tn(e,t,n);return this.registeredContexts[e]=r,this.contextCheckers.push(r),r},In.prototype.getRangeTokens=function(e){var t=e.startIndex+e.endOffset;return[].concat(this.tokens.slice(e.startIndex,t))},In.prototype.getContextRanges=function(e){var t=this.getContext(e);return t?t.ranges:{FAIL:"context checker '"+e+"' is not registered."}},In.prototype.resetContextsRanges=function(){var e=this.registeredContexts;for(var t in e)e.hasOwnProperty(t)&&(e[t].ranges=[])},In.prototype.updateContextsRanges=function(){this.resetContextsRanges();for(var e=this.tokens.map((function(e){return e.char})),t=0;t=0;n--){var r=t[n],o=Dn(r),i=Bn(r);if(!o&&!i)return!0;if(o)return!1}return!1}(a)&&(l|=1),function(e){if(Dn(e.current))return!1;for(var t=0;t=1.2&&(o.markGlyphSets=n.parsePointer(Er)),o}},wr=new Array(10);wr[1]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();return 1===t?{posFormat:1,coverage:this.parsePointer(ie.coverage),value:this.parseValueRecord()}:2===t?{posFormat:2,coverage:this.parsePointer(ie.coverage),values:this.parseValueRecordList()}:void L.assert(!1,"0x"+e.toString(16)+": GPOS lookup type 1 format must be 1 or 2.")},wr[2]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();L.assert(1===t||2===t,"0x"+e.toString(16)+": GPOS lookup type 2 format must be 1 or 2.");var n=this.parsePointer(ie.coverage),r=this.parseUShort(),o=this.parseUShort();if(1===t)return{posFormat:t,coverage:n,valueFormat1:r,valueFormat2:o,pairSets:this.parseList(ie.pointer(ie.list((function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(r),value2:this.parseValueRecord(o)}}))))};if(2===t){var i=this.parsePointer(ie.classDef),a=this.parsePointer(ie.classDef),s=this.parseUShort(),c=this.parseUShort();return{posFormat:t,coverage:n,valueFormat1:r,valueFormat2:o,classDef1:i,classDef2:a,class1Count:s,class2Count:c,classRecords:this.parseList(s,ie.list(c,(function(){return{value1:this.parseValueRecord(r),value2:this.parseValueRecord(o)}})))}}},wr[3]=function(){return{error:"GPOS Lookup 3 not supported"}},wr[4]=function(){return{error:"GPOS Lookup 4 not supported"}},wr[5]=function(){return{error:"GPOS Lookup 5 not supported"}},wr[6]=function(){return{error:"GPOS Lookup 6 not supported"}},wr[7]=function(){return{error:"GPOS Lookup 7 not supported"}},wr[8]=function(){return{error:"GPOS Lookup 8 not supported"}},wr[9]=function(){return{error:"GPOS Lookup 9 not supported"}};var kr=new Array(10),_r={parse:function(e,t){var n=new ie(e,t=t||0),r=n.parseVersion(1);return L.argument(1===r||1.1===r,"Unsupported GPOS table version "+r),1===r?{version:r,scripts:n.parseScriptList(),features:n.parseFeatureList(),lookups:n.parseLookupList(wr)}:{version:r,scripts:n.parseScriptList(),features:n.parseFeatureList(),lookups:n.parseLookupList(wr),variations:n.parseFeatureVariationsList()}},make:function(e){return new J.Table("GPOS",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new J.ScriptList(e.scripts)},{name:"features",type:"TABLE",value:new J.FeatureList(e.features)},{name:"lookups",type:"TABLE",value:new J.LookupList(e.lookups,kr)}])}},Sr={parse:function(e,t){var n=new se.Parser(e,t),r=n.parseUShort();if(0===r)return function(e){var t={};e.skip("uShort");var n=e.parseUShort();L.argument(0===n,"Unsupported kern sub-table version."),e.skip("uShort",2);var r=e.parseUShort();e.skip("uShort",3);for(var o=0;o1&&console.warn("Only the first kern subtable is supported."),e.skip("uLong");var n=255&e.parseUShort();if(e.skip("uShort"),0===n){var r=e.parseUShort();e.skip("uShort",3);for(var o=0;o{"use strict";var r=n(3696);function o(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n