diff --git a/dev/expression-expansion.story.tsx b/dev/expression-expansion.story.tsx index 73d5a5cd..9351c50e 100644 --- a/dev/expression-expansion.story.tsx +++ b/dev/expression-expansion.story.tsx @@ -1,5 +1,5 @@ import React from "react" -import { Button, Factor, StringEditor, composeExpression, deriveExpressionWith, divideFactors, expandExpression, expressionToFactors, factorToExpression, factorsToExpression, groupAllFactors, groupFactorsBy, groupFactorsByVariables, mathStyleExpressionToExpression, optimizeExpression, optimizeFactors, printMathStyleExpression, reactSvgRenderTarget, renderExpression, sortFactors } from "../src" +import { Button, Factor, StringEditor, composeExpression, deriveExpressionWith, divideFactors, expandExpression, expressionHasVariable, expressionToFactors, factorToExpression, factorsToExpression, groupAllFactors, groupFactorsBy, groupFactorsByVariables, mathStyleExpressionToExpression, optimizeExpression, optimizeFactors, printMathStyleExpression, reactSvgRenderTarget, renderExpression, sortFactors, taylorExpandExpressionWith } from "../src" import { Expression2, parseExpression, printExpression, tokenizeExpression } from "expression-engine" export default () => { @@ -106,7 +106,7 @@ export default () => { if (!secondValue) return if (!value) return const r = parseInputExpression(value) - const g = deriveExpressionWith(r, secondValue) + const g = optimizeExpression(deriveExpressionWith(r, secondValue), v => expressionHasVariable(v, secondValue)) setExpression(g) setError(undefined) } catch (error) { @@ -143,6 +143,19 @@ export default () => { setError(String(error)) } } + const taylorExpand = (toPrimaryFunction: boolean) => { + try { + if (!secondValue) return + if (!value) return + const r = parseInputExpression(value) + const g = taylorExpandExpressionWith(r, secondValue, +thirdValue || 5, toPrimaryFunction) + setExpression(g) + setError(undefined) + } catch (error) { + setError(String(error)) + setExpression(undefined) + } + } const setText = (text: string) => { setValue(text) setError(undefined) @@ -177,6 +190,8 @@ export default () => { + + {factors && factors.length > 0 &&
{factors.map((f, i) =>
{outputExpression(factorToExpression(f))}
)}
} diff --git a/main.bundle.js b/main.bundle.js index 6f2f0a06..165912c5 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={6704:(e,t,n)=>{var r=function(e){var t=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,n=0,r={},o={manual:e.Prism&&e.Prism.manual,disableWorkerMessageHandler:e.Prism&&e.Prism.disableWorkerMessageHandler,util:{encode:function e(t){return t instanceof i?new i(t.type,e(t.content),t.alias):Array.isArray(t)?t.map(e):t.replace(/&/g,"&").replace(/=p.reach);k+=E.value.length,E=E.next){var w=E.value;if(n.length>t.length)return;if(!(w instanceof i)){var S,P=1;if(x){if(!(S=a(C,k,t,y))||S.index>=t.length)break;var R=S.index,_=S.index+S[0].length,T=k;for(T+=E.value.length;T<=R;)T+=(E=E.next).value.length;if(k=T-=E.value.length,E.value instanceof i)continue;for(var A=E;A!==n.tail&&(T<_||"string"==typeof A.value);A=A.next)P++,T+=A.value.length;P--,w=t.slice(k,T),S.index-=k}else if(!(S=a(C,0,w,y)))continue;R=S.index;var M=S[0],L=w.slice(0,R),O=w.slice(R+M.length),I=k+w.length;p&&I>p.reach&&(p.reach=I);var F=E.prev;if(L&&(F=l(n,F,L),k+=L.length),c(n,F,P),E=l(n,F,new i(d,m?o.tokenize(M,m):M,v,M)),O&&l(n,E,O),1p.reach&&(p.reach=D.reach)}}}}}}(e,u,t,u.head,0),function(e){for(var t=[],n=e.head.next;n!==e.tail;)t.push(n.value),n=n.next;return t}(u)},hooks:{all:{},add:function(e,t){var n=o.hooks.all;n[e]=n[e]||[],n[e].push(t)},run:function(e,t){var n=o.hooks.all[e];if(n&&n.length)for(var r,i=0;r=n[i++];)r(t)}},Token:i};function i(e,t,n,r){this.type=e,this.content=t,this.alias=n,this.length=0|(r||"").length}function a(e,t,n,r){e.lastIndex=t;var o=e.exec(n);if(o&&r&&o[1]){var i=o[1].length;o.index+=i,o[0]=o[0].slice(i)}return o}function s(){var e={value:null,prev:null,next:null},t={value:null,prev:e,next:null};e.next=t,this.head=e,this.tail=t,this.length=0}function l(e,t,n){var r=t.next,o={value:n,prev:t,next:r};return t.next=o,r.prev=o,e.length++,o}function c(e,t,n){for(var r=t.next,o=0;o"+i.content+""},!e.document)return e.addEventListener&&(o.disableWorkerMessageHandler||e.addEventListener("message",(function(t){var n=JSON.parse(t.data),r=n.language,i=n.code,a=n.immediateClose;e.postMessage(o.highlight(i,o.languages[r],r)),a&&e.close()}),!1)),o;var u=o.util.currentScript();function p(){o.manual||o.highlightAll()}if(u&&(o.filename=u.src,u.hasAttribute("data-manual")&&(o.manual=!0)),!o.manual){var d=document.readyState;"loading"===d||"interactive"===d&&u&&u.defer?document.addEventListener("DOMContentLoaded",p):window.requestAnimationFrame?window.requestAnimationFrame(p):window.setTimeout(p,16)}return o}("undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{});e.exports&&(e.exports=r),void 0!==n.g&&(n.g.Prism=r),r.languages.markup={comment:{pattern://,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern://i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:"named-entity"},/&#x?[\da-f]{1,8};/i]},r.languages.markup.tag.inside["attr-value"].inside.entity=r.languages.markup.entity,r.languages.markup.doctype.inside["internal-subset"].inside=r.languages.markup,r.hooks.add("wrap",(function(e){"entity"===e.type&&(e.attributes.title=e.content.replace(/&/,"&"))})),Object.defineProperty(r.languages.markup.tag,"addInlined",{value:function(e,t){var n={};n["language-"+t]={pattern:/(^$)/i,lookbehind:!0,inside:r.languages[t]},n.cdata=/^$/i;var o={"included-cdata":{pattern://i,inside:n}};o["language-"+t]={pattern:/[\s\S]+/,inside:r.languages[t]};var i={};i[e]={pattern:RegExp("(<__[^>]*>)(?:))*\\]\\]>|(?!)".replace(/__/g,(function(){return e})),"i"),lookbehind:!0,greedy:!0,inside:o},r.languages.insertBefore("markup","cdata",i)}}),Object.defineProperty(r.languages.markup.tag,"addAttribute",{value:function(e,t){r.languages.markup.tag.inside["special-attr"].push({pattern:RegExp("(^|[\"'\\s])(?:"+e+")\\s*=\\s*(?:\"[^\"]*\"|'[^']*'|[^\\s'\">=]+(?=[\\s>]))","i"),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[t,"language-"+t],inside:r.languages[t]},punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}}}})}}),r.languages.html=r.languages.markup,r.languages.mathml=r.languages.markup,r.languages.svg=r.languages.markup,r.languages.xml=r.languages.extend("markup",{}),r.languages.ssml=r.languages.xml,r.languages.atom=r.languages.xml,r.languages.rss=r.languages.xml,r.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,boolean:/\b(?:false|true)\b/,function:/\b\w+(?=\()/,number:/\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,operator:/[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},r.languages.javascript=r.languages.extend("clike",{"class-name":[r.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp("(^|[^\\w$])(?:NaN|Infinity|0[bB][01]+(?:_[01]+)*n?|0[oO][0-7]+(?:_[0-7]+)*n?|0[xX][\\dA-Fa-f]+(?:_[\\dA-Fa-f]+)*n?|\\d+(?:_\\d+)*n|(?:\\d+(?:_\\d+)*(?:\\.(?:\\d+(?:_\\d+)*)?)?|\\.\\d+(?:_\\d+)*)(?:[Ee][+-]?\\d+(?:_\\d+)*)?)(?![\\w$])"),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),r.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,r.languages.insertBefore("javascript","keyword",{regex:{pattern:/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)\/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/,lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:r.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:r.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:r.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:r.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:r.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),r.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:r.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),r.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),r.languages.markup&&(r.languages.markup.tag.addInlined("script","javascript"),r.languages.markup.tag.addAttribute("on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)","javascript")),r.languages.js=r.languages.javascript,function(e){var t=e.util.clone(e.languages.javascript),n="(?:\\{*\\.{3}(?:[^{}]|)*\\})";function r(e,t){return e=e.replace(//g,(function(){return"(?:\\s|//.*(?!.)|/\\*(?:[^*]|\\*(?!/))\\*/)"})).replace(//g,(function(){return"(?:\\{(?:\\{(?:\\{[^{}]*\\}|[^{}])*\\}|[^{}])*\\})"})).replace(//g,(function(){return n})),RegExp(e,t)}n=r(n).source,e.languages.jsx=e.languages.extend("markup",t),e.languages.jsx.tag.pattern=r("+(?:[\\w.:$-]+(?:=(?:\"(?:\\\\[^]|[^\\\\\"])*\"|'(?:\\\\[^]|[^\\\\'])*'|[^\\s{'\"/>=]+|))?|))**/?)?>"),e.languages.jsx.tag.inside.tag.pattern=/^<\/?[^\s>\/]*/,e.languages.jsx.tag.inside["attr-value"].pattern=/=(?!\{)(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s'">]+)/,e.languages.jsx.tag.inside.tag.inside["class-name"]=/^[A-Z]\w*(?:\.[A-Z]\w*)*$/,e.languages.jsx.tag.inside.comment=t.comment,e.languages.insertBefore("inside","attr-name",{spread:{pattern:r(""),inside:e.languages.jsx}},e.languages.jsx.tag),e.languages.insertBefore("inside","special-attr",{script:{pattern:r("="),alias:"language-javascript",inside:{"script-punctuation":{pattern:/^=(?=\{)/,alias:"punctuation"},rest:e.languages.jsx}}},e.languages.jsx.tag);var o=function(e){return e?"string"==typeof e?e:"string"==typeof e.content?e.content:e.content.map(o).join(""):""},i=function(t){for(var n=[],r=0;r"===a.content[a.content.length-1].content||n.push({tagName:o(a.content[0].content[1]),openedBraces:0}):0]|<(?:[^<>]|<[^<>]*>)*>)*>)?/,lookbehind:!0,greedy:!0,inside:null},builtin:/\b(?:Array|Function|Promise|any|boolean|console|never|number|string|symbol|unknown)\b/}),e.languages.typescript.keyword.push(/\b(?:abstract|declare|is|keyof|readonly|require)\b/,/\b(?:asserts|infer|interface|module|namespace|type)\b(?=\s*(?:[{_$a-zA-Z\xA0-\uFFFF]|$))/,/\btype\b(?=\s*(?:[\{*]|$))/),delete e.languages.typescript.parameter,delete e.languages.typescript["literal-property"];var t=e.languages.extend("typescript",{});delete t["class-name"],e.languages.typescript["class-name"].inside=t,e.languages.insertBefore("typescript","function",{decorator:{pattern:/@[$\w\xA0-\uFFFF]+/,inside:{at:{pattern:/^@/,alias:"operator"},function:/^[\s\S]+/}},"generic-function":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>(?=\s*\()/,greedy:!0,inside:{function:/^#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*/,generic:{pattern:/<[\s\S]+/,alias:"class-name",inside:t}}}}),e.languages.ts=e.languages.typescript}(r),function(e){var t=e.util.clone(e.languages.typescript);e.languages.tsx=e.languages.extend("jsx",t),delete e.languages.tsx.parameter,delete e.languages.tsx["literal-property"];var n=e.languages.tsx.tag;n.pattern=RegExp("(^|[^\\w$]|(?=");(s=document.createElement("span")).setAttribute("aria-hidden","true"),s.className="line-numbers-rows",s.innerHTML=u,a.hasAttribute("data-start")&&(a.style.counterReset="linenumber "+(parseInt(a.getAttribute("data-start"),10)-1)),n.element.appendChild(s),i([a]),r.hooks.run("line-numbers",n)}}})),r.hooks.add("line-numbers",(function(e){e.plugins=e.plugins||{},e.plugins.lineNumbers=!0}))}function i(e){if(0!=(e=e.filter((function(e){var t=function(e){return e?window.getComputedStyle?getComputedStyle(e):e.currentStyle||null:null}(e)["white-space"];return"pre-wrap"===t||"pre-line"===t}))).length){var n=e.map((function(e){var n=e.querySelector("code"),r=e.querySelector(".line-numbers-rows");if(n&&r){var o=e.querySelector(".line-numbers-sizer"),i=n.textContent.split(t);o||((o=document.createElement("span")).className="line-numbers-sizer",n.appendChild(o)),o.innerHTML="0",o.style.display="block";var a=o.getBoundingClientRect().height;return o.innerHTML="",{element:e,lines:i,lineHeights:[],oneLinerHeight:a,sizer:o}}})).filter(Boolean);n.forEach((function(e){var t=e.sizer,n=e.lines,r=e.lineHeights,o=e.oneLinerHeight;r[n.length-1]=void 0,n.forEach((function(e,n){if(e&&1{"use strict";n.d(t,{navigateTo:()=>a,useLocation:()=>l});var r=n(5556),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 l=(0,r.__assign)((0,r.__assign)({},s()),{state:history.state});history[n](a,"",e),dispatchEvent(new CustomEvent(n,{detail:l}))}function s(){return{path:location.pathname||"/",search:location.search}}function l(e,t){var n=this,i=(0,r.__read)(e.useState((function(){return s()})),2),a=i[0],l=a.path,c=a.search,u=i[1],p=e.useRef(l+c);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]}}))}))},l=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]}}))}))},c=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(4933),o=n.n(r),i=n(3476),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},3476: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}},4933:e=>{"use strict";e.exports=function(e){return e[1]}},1106:e=>{"use strict";function t(e,t,r){r=r||2;var i,a,s,l,p,d,g,h=t&&t.length,m=h?t[0]*r:e.length,y=n(e,0,m,r,!0),x=[];if(!y||y.next===y.prev)return x;if(h&&(y=function(e,t,r,o){var i,a,s,l=[];for(i=0,a=t.length;i80*r){i=s=e[0],a=l=e[1];for(var v=r;vs&&(s=p),d>l&&(l=d);g=0!==(g=Math.max(s-i,l-a))?32767/g:0}return o(y,x,r,i,a,g,0),x}function n(e,t,n,r,o){var i,a;if(o===P(e,t,n,r)>0)for(i=t;i=t;i-=r)a=k(i,e[i],e[i+1],a);return a&&y(a,a.next)&&(w(a),a=a.next),a}function r(e,t){if(!e)return e;t||(t=e);var n,r=e;do{if(n=!1,r.steiner||!y(r,r.next)&&0!==m(r.prev,r,r.next))r=r.next;else{if(w(r),(r=t=r.prev)===r.next)break;n=!0}}while(n||r!==t);return t}function o(e,t,n,c,u,p,f){if(e){!f&&p&&function(e,t,n,r){var o=e;do{0===o.z&&(o.z=d(o.x,o.y,t,n,r)),o.prevZ=o.prev,o.nextZ=o.next,o=o.next}while(o!==e);o.prevZ.nextZ=null,o.prevZ=null,function(e){var t,n,r,o,i,a,s,l,c=1;do{for(n=e,e=null,i=null,a=0;n;){for(a++,r=n,s=0,t=0;t0||l>0&&r;)0!==s&&(0===l||!r||n.z<=r.z)?(o=n,n=n.nextZ,s--):(o=r,r=r.nextZ,l--),i?i.nextZ=o:e=o,o.prevZ=i,i=o;n=r}i.nextZ=null,c*=2}while(a>1)}(o)}(e,c,u,p);for(var g,h,m=e;e.prev!==e.next;)if(g=e.prev,h=e.next,p?a(e,c,u,p):i(e))t.push(g.i/n|0),t.push(e.i/n|0),t.push(h.i/n|0),w(e),e=h.next,m=h.next;else if((e=h)===m){f?1===f?o(e=s(r(e),t,n),t,n,c,u,p,2):2===f&&l(e,t,n,c,u,p):o(r(e),t,n,c,u,p,1);break}}}function i(e){var t=e.prev,n=e,r=e.next;if(m(t,n,r)>=0)return!1;for(var o=t.x,i=n.x,a=r.x,s=t.y,l=n.y,c=r.y,u=oi?o>a?o:a:i>a?i:a,f=s>l?s>c?s:c:l>c?l:c,h=r.next;h!==t;){if(h.x>=u&&h.x<=d&&h.y>=p&&h.y<=f&&g(o,s,i,l,a,c,h.x,h.y)&&m(h.prev,h,h.next)>=0)return!1;h=h.next}return!0}function a(e,t,n,r){var o=e.prev,i=e,a=e.next;if(m(o,i,a)>=0)return!1;for(var s=o.x,l=i.x,c=a.x,u=o.y,p=i.y,f=a.y,h=sl?s>c?s:c:l>c?l:c,v=u>p?u>f?u:f:p>f?p:f,b=d(h,y,t,n,r),C=d(x,v,t,n,r),E=e.prevZ,k=e.nextZ;E&&E.z>=b&&k&&k.z<=C;){if(E.x>=h&&E.x<=x&&E.y>=y&&E.y<=v&&E!==o&&E!==a&&g(s,u,l,p,c,f,E.x,E.y)&&m(E.prev,E,E.next)>=0)return!1;if(E=E.prevZ,k.x>=h&&k.x<=x&&k.y>=y&&k.y<=v&&k!==o&&k!==a&&g(s,u,l,p,c,f,k.x,k.y)&&m(k.prev,k,k.next)>=0)return!1;k=k.nextZ}for(;E&&E.z>=b;){if(E.x>=h&&E.x<=x&&E.y>=y&&E.y<=v&&E!==o&&E!==a&&g(s,u,l,p,c,f,E.x,E.y)&&m(E.prev,E,E.next)>=0)return!1;E=E.prevZ}for(;k&&k.z<=C;){if(k.x>=h&&k.x<=x&&k.y>=y&&k.y<=v&&k!==o&&k!==a&&g(s,u,l,p,c,f,k.x,k.y)&&m(k.prev,k,k.next)>=0)return!1;k=k.nextZ}return!0}function s(e,t,n){var o=e;do{var i=o.prev,a=o.next.next;!y(i,a)&&x(i,o,o.next,a)&&C(i,a)&&C(a,i)&&(t.push(i.i/n|0),t.push(o.i/n|0),t.push(a.i/n|0),w(o),w(o.next),o=e=a),o=o.next}while(o!==e);return r(o)}function l(e,t,n,i,a,s){var l=e;do{for(var c=l.next.next;c!==l.prev;){if(l.i!==c.i&&h(l,c)){var u=E(l,c);return l=r(l,l.next),u=r(u,u.next),o(l,t,n,i,a,s,0),void o(u,t,n,i,a,s,0)}c=c.next}l=l.next}while(l!==e)}function c(e,t){return e.x-t.x}function u(e,t){var n=function(e,t){var n,r=t,o=e.x,i=e.y,a=-1/0;do{if(i<=r.y&&i>=r.next.y&&r.next.y!==r.y){var s=r.x+(i-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(s<=o&&s>a&&(a=s,n=r.x=r.x&&r.x>=u&&o!==r.x&&g(in.x||r.x===n.x&&p(n,r)))&&(n=r,f=l)),r=r.next}while(r!==c);return n}(e,t);if(!n)return t;var o=E(n,e);return r(o,o.next),r(n,n.next)}function p(e,t){return m(e.prev,e,t.prev)<0&&m(t.next,e,e.next)<0}function d(e,t,n,r,o){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*o|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*o|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function f(e){var t=e,n=e;do{(t.x=(e-a)*(i-s)&&(e-a)*(r-s)>=(n-a)*(t-s)&&(n-a)*(i-s)>=(o-a)*(r-s)}function h(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&x(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(C(e,t)&&C(t,e)&&function(e,t){var n=e,r=!1,o=(e.x+t.x)/2,i=(e.y+t.y)/2;do{n.y>i!=n.next.y>i&&n.next.y!==n.y&&o<(n.next.x-n.x)*(i-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==e);return r}(e,t)&&(m(e.prev,e,t.prev)||m(e,t.prev,t))||y(e,t)&&m(e.prev,e,e.next)>0&&m(t.prev,t,t.next)>0)}function m(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function y(e,t){return e.x===t.x&&e.y===t.y}function x(e,t,n,r){var o=b(m(e,t,n)),i=b(m(e,t,r)),a=b(m(n,r,e)),s=b(m(n,r,t));return o!==i&&a!==s||!(0!==o||!v(e,n,t))||!(0!==i||!v(e,r,t))||!(0!==a||!v(n,e,r))||!(0!==s||!v(n,t,r))}function v(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function b(e){return e>0?1:e<0?-1:0}function C(e,t){return m(e.prev,e,e.next)<0?m(e,t,e.next)>=0&&m(e,e.prev,t)>=0:m(e,t,e.prev)<0||m(e,e.next,t)<0}function E(e,t){var n=new S(e.i,e.x,e.y),r=new S(t.i,t.x,t.y),o=e.next,i=t.prev;return e.next=t,t.prev=e,n.next=o,o.prev=n,r.next=n,n.prev=r,i.next=r,r.prev=i,r}function k(e,t,n,r){var o=new S(e,t,n);return r?(o.next=r.next,o.prev=r,r.next.prev=o,r.next=o):(o.prev=o,o.next=o),o}function w(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function S(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function P(e,t,n,r){for(var o=0,i=t,a=n-r;i0&&(r+=e[o-1].length,n.holes.push(r))}return n}},9586:(e,t,n)=>{"use strict";n.d(t,{AstronomicalObjectSimulator:()=>C});var r=n(7378),o=n.n(r),i=n(5188),a=n(6645),s=n(9397),l=n(9721),c=n(9081),u=n(2074),p=Object.defineProperty,d=Object.defineProperties,f=Object.getOwnPropertyDescriptors,g=Object.getOwnPropertySymbols,h=Object.prototype.hasOwnProperty,m=Object.prototype.propertyIsEnumerable,y=Math.pow,x=(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)&&x(e,n,t[n]);if(g)for(var n of g(t))m.call(t,n)&&x(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:x,applyPatchFromSelf:C}=(0,s.usePatchBasedUndoRedo)(e.initialState,e.operator,{onApplyPatchesFromSelf:e.onApplyPatchesFromSelf}),{x:E,y:k,ref:w,setX:S,setY:P}=(0,s.useWheelScroll)(),{scale:R,setScale:_,ref:T}=(0,s.useWheelZoom)({min:.001,onChange(e,t,n){const r=(0,s.scaleByCursorPosition)({width:p,height:d},t/e,n);S(r.setX),P(r.setY)}}),[A,M]=o().useState({x:0,y:0}),{offset:L,onStart:O,mask:I,resetDragMove:F}=(0,s.useDragMove)((()=>{K?M((e=>({x:e.x+L.x,y:e.y+L.y}))):(S((e=>e+L.x)),P((e=>e+L.y)))})),[D,B]=o().useState(),[z,U]=o().useState(),[N,j]=o().useState(!1),[W,G]=o().useState(),V=[],$=[],H=[],q=[],[Y,X]=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:le,reset:ce,onMove:ue}=(0,s.useLineClickCreate)(N,(e=>{g((t=>{const n={type:"sphere",x:Y?0:e[0].x,y:e[0].y,z:Y?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:Y?0:se[0].x,y:se[0].y,z:Y?se[0].x:0,radius:(0,s.getTwoPointsDistance)(se[0],se[1]),speed:{x:0,y:0,z:0},mass:1,color:16711680};V.push(e)}W&&V.push(W);const pe={x:K?E:E+L.x,y:K?k:k+L.y,scale:R,center:{x:p/2,y:d/2}},de=()=>{j(!1),B(void 0),U(void 0),G(void 0)},{editPoint:fe,updateEditPreview:ge,onEditMove:he,onEditClick:me,resetEdit:ye}=(0,s.useEdit)((()=>C($,H)),(e=>{if((0,c.isSphereContent)(e)){const t=Y?e.z:e.x,n=[{x:t,y:e.y,cursor:"move",update(e,{cursor:t}){(0,c.isSphereContent)(e)&&(Y?e.z=t.x:e.x=t.x,e.y=t.y)}}],r=Y?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,c.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}),l=(a-e.radius)/a;Y?n.speed.z=o*l:n.speed.x=o*l,n.speed.y=i*l}})}return{editPoints:n}}}),{scale:pe.scale,readOnly:N}),xe=ge();if($.push(...null!=(n=null==xe?void 0:xe.patches)?n:[]),H.push(...null!=(r=null==xe?void 0:xe.reversePatches)?r:[]),void 0!==z&&!ee){const e=ae[z];if(e&&(0,c.isSphereContent)(e)){q.push({content:e,path:[z]});const t=e=>{const[,...t]=(0,i.produceWithPatches)(ae,(t=>{const n=t[z];n&&e(n,t)}));C(...t)},n={x:o().createElement(s.NumberEditor,{value:e.x,setValue:e=>t((t=>{(0,c.isSphereContent)(t)&&(t.x=e)}))}),y:o().createElement(s.NumberEditor,{value:e.y,setValue:e=>t((t=>{(0,c.isSphereContent)(t)&&(t.y=e)}))}),z:o().createElement(s.NumberEditor,{value:e.z,setValue:e=>t((t=>{(0,c.isSphereContent)(t)&&(t.z=e)}))}),radius:o().createElement(s.NumberEditor,{value:e.radius,setValue:e=>t((t=>{(0,c.isSphereContent)(t)&&(t.radius=e)}))}),mass:o().createElement(s.NumberEditor,{value:e.mass,setValue:e=>t((t=>{(0,c.isSphereContent)(t)&&(t.mass=e)}))}),color:o().createElement(s.NumberEditor,{type:"color",value:e.color,setValue:e=>t((t=>{(0,c.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,c.isSphereContent)(t)&&(t.speed.x=e)}))}),y:o().createElement(s.NumberEditor,{value:e.speed.y,setValue:e=>t((t=>{(0,c.isSphereContent)(t)&&(t.speed.y=e)}))}),z:o().createElement(s.NumberEditor,{value:e.speed.z,setValue:e=>t((t=>{(0,c.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,z),o().createElement(s.ObjectEditor,{readOnly:void 0!==re,properties:n}))}}(0,s.useGlobalKeyDown)((e=>{return void 0,null,t=function*(){if("Escape"===e.key)de(),ce(!0),ye(),F();else if("Backspace"===e.code){if(K)return;void 0!==D?(g((e=>{e[D]=void 0})),B(void 0)):void 0!==z&&(g((e=>{e[z]=void 0})),U(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)_(1),S(0),P(0),M({x:0,y:0}),e.preventDefault();else if("KeyC"===e.code){if(e.preventDefault(),void 0!==z){const e=f[z];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,c.isSphereContent)(t))return void G(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{x(e.patches,e.reversePatches,e.operator)}catch(e){console.error(e)}}})),[x]);const ve=(0,s.useEvent)((e=>{const t={x:e.clientX,y:e.clientY};4===e.buttons?O(t):N||fe||void 0!==D||W||O(t)})),be=(0,s.useEvent)((e=>{const t={x:e.clientX,y:e.clientY},n=(0,s.reverseTransformPosition)(t,pe);N?le(n):W?g((e=>{e.push(b(v({},W),{x:n.x,y:n.y}))})):fe?me(n):void 0!==D&&(U(D),B(void 0))})),Ce=(0,s.useEvent)((e=>{var t;const n={x:e.clientX,y:e.clientY};if(K)return void B(null==(t=J.current)?void 0:t.getContentByPosition(n));const r=(0,s.reverseTransformPosition)(n,pe);N?ue(r,n):W?G(b(v({},W),{x:r.x,y:r.y})):(he(r,q),B((e=>{for(let t=0;tZ(!K)},K?"3D":"2D"),!K&&o().createElement(s.Button,{style:{color:N?"red":void 0},onClick:()=>{ce(),j(!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=[],l=null!=(r=ie.current)?r:f;for(const e of l)if(e&&(0,c.isSphereContent)(e)){const n={x:0,y:0,z:0};for(const t of l)if(t&&t!==e&&(0,c.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:()=>X(!Y)},Y?"y-z":"x-y"))),Q,I)}))},9081:(e,t,n)=>{"use strict";n.d(t,{getContentModel:()=>a,isSphereContent:()=>o});var r=n(9397);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},l=[t.renderCircle(a,e.y,i,{fillColor:e.color,strokeWidth:0})],c=o?e.speed.z:e.speed.x;if(c||e.speed.y){const n={x:c,y:e.speed.y},o=(0,r.getPointByLengthAndRadian)(s,e.radius+(0,r.getTwoPointsDistance)(n),Math.atan2(e.speed.y,c)),{arrowPoints:i,endPoint:a}=(0,r.getArrow)(s,o,10,15);l.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:c}=(0,r.getArrow)(s,i,10,15);l.push(t.renderPolyline([s,c],{strokeColor:e.color,dashArray:[5]}),t.renderPolygon(a,{fillColor:e.color,strokeWidth:0}))}}return t.renderGroup(l)}}).type]=s},2074:(e,t,n)=>{"use strict";n.d(t,{Renderer3d:()=>l});var r=n(7378),o=n.n(r),i=n(6645),a=n(9397),s=n(9081);const l=o().forwardRef(((e,t)=>{const n=o().useRef(null),r=o().useRef(),l=o().useRef(new a.MapCache),c=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.colorNumberToRec)(r.color);e.hovering!==o&&e.selected!==o||(s[3]=.5),t.push({geometry:l.current.get(r.radius,(()=>({type:"sphere",radius:r.radius}))),color:s,position:[r.x,r.y,r.z]});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:c.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:[o.x,o.y,o.z],up:[p.x,p.y,p.z],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})}))},9721:(e,t,n)=>{"use strict";n.d(t,{Renderer:()=>d});var r=n(5188),o=n(9397),i=n(9081),a=Object.defineProperty,s=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,c=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={}))l.call(t,n)&&u(e,n,t[n]);if(s)for(var n of s(t))c.call(t,n)&&u(e,n,t[n]);return e};function d(e){var t,n;const a=o.reactSvgRenderTarget,s=[],l=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}})}},5207:(e,t,n)=>{"use strict";n.d(t,{default:()=>l});var r=n(7378),o=n.n(r),i=n(9397),a=n(8266),s=n(4918);const l=()=>{const e=(0,i.useWindowSize)().width/2-30,[t,n]=o().useState(),r=o().useRef(new i.MapCache2),l=(e,n)=>{if(t&&e)return r.current.get(e,n,(()=>{const r=t.getPath(e,0,n,n,{xScale:n/t.unitsPerEm,yScale:n/t.unitsPerEm}),o=t.charToGlyph(e),i=o.getBoundingBox(),a=o.advanceWidth||0,l=i.x2-i.x1;return{commands:(0,s.opentypeCommandsToPathCommands)(r),x1:(a>l?0:i.x1)/t.unitsPerEm*n,y1:(o.unicode&&o.unicode<256?0:i.y1)/t.unitsPerEm*n,width:Math.max(a,l)/t.unitsPerEm*n}}))},[c,u]=o().useState([{insert:"我们出"},{insert:"去吧",attributes:{stackText:"ab"}},{insert:"Aag j",attributes:{color:16711680}}]),[p,d]=o().useState("left"),[f,g]=o().useState("top"),h=e=>{var t,n;return null!=(n=null==(t=null==e?void 0:e.attributes)?void 0:t.color)?n:0},m=e=>{var t,n;return null!=(n=null==(t=null==e?void 0:e.attributes)?void 0:t.fontSize)?n:50},y=e=>{var t,n;return m(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)},x=e=>{var t,n;return null!=(n=null==(t=null==e?void 0:e.attributes)?void 0:t.backgroundColor)?n:16777215},v=e=>{var t,n;return null!=(n=null==(t=null==e?void 0:e.attributes)?void 0:t.underline)&&n},b=e=>{var t,n;return null!=(n=null==(t=null==e?void 0:e.attributes)?void 0:t.passThrough)&&n},C=e=>{var t;return null==(t=null==e?void 0:e.attributes)?void 0:t.script},E=e=>{var t,n;return null!=(n=null==(t=null==e?void 0:e.attributes)?void 0:t.circle)&&n},k=e=>{var t,n;return null!=(n=null==(t=null==e?void 0:e.attributes)?void 0:t.stackText)?n:""},w=e=>1.2*y(e),S=e=>{var t,n,r;if(null==(t=e.attributes)?void 0:t.stackText){const t=e.insert.split("").reduce(((t,n)=>{var r,o;return t+(null!=(o=null==(r=l(n,y(e)))?void 0:r.width)?o:0)}),0),n=e.attributes.stackText.split("").reduce(((t,n)=>{var r,o;return t+(null!=(o=null==(r=l(n,y(e)))?void 0:r.width)?o:0)}),0);return Math.max(n,t)}return null!=(r=null==(n=l(e.insert,y(e)))?void 0:n.width)?r:0},P=e=>E(e)?w(e):S(e),{renderEditor:R,layoutResult:_,lineHeights:T,isSelected:A,actualHeight:M,cursorContent:L,setSelectedAttributes:O}=(0,i.useAttributedTextEditor)({state:c,setState:u,width:e,height:200,lineHeight:w,getWidth:P,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 I=i.reactSvgRenderTarget,F=[];for(const{x:e,y:t,i:n,content:r,visible:o,row:i}of _){if(!o)continue;const a=P(r),s=T[i];A(n)&&F.push(I.renderRect(e,t,a,s,{fillColor:11785981,strokeWidth:0}));const c=y(r),u=l(r.insert,c);if(u){const o=h(r),i=x(r);A(n)||16777215===i||F.push(I.renderRect(e,t,a,s,{fillColor:i,strokeWidth:0})),v(r)&&F.push(I.renderPolyline([{x:e,y:t+s},{x:e+a,y:t+s}],{strokeColor:o})),b(r)&&F.push(I.renderPolyline([{x:e,y:t+s/2},{x:e+a,y:t+s/2}],{strokeColor:o}));const p={x:e-u.x1,y:u.y1+(s-w(r))},d=C(r),f=k(r);if("sub"===d?p.y+=.2*c:("sup"===d||f)&&(p.y-=.7*c),f){const e=r.insert.split("").reduce(((e,t)=>{var n,r;return e+(null!=(r=null==(n=l(t,c))?void 0:n.width)?r:0)}),0);p.x+=(a-e)/2}if(E(r)&&(p.x+=(s-S(r))/2,F.push(I.renderCircle(e+a/2,t+s/2,s/2,{strokeColor:o}))),F.push(I.renderGroup([I.renderPathCommands(u.commands,{fillColor:o,strokeColor:o})],{translate:p})),f){const t=f.split("").reduce(((e,t)=>{var n,r;return e+(null!=(r=null==(n=l(t,c))?void 0:n.width)?r:0)}),0);let n=0;for(const i of f.split("")){const u=l(i,c);if(u){const i={x:e-u.x1+(a-t)/2+n,y:u.y1+(s-w(r))+.2*c};n+=u.width,F.push(I.renderGroup([I.renderPathCommands(u.commands,{fillColor:o,strokeColor:o})],{translate:i}))}}}}}const D=I.renderResult(F,e,M);return o().createElement(o().Fragment,null,R(D),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:h(L),setValue:e=>O({color:e})}),fontSize:o().createElement(i.NumberEditor,{value:m(L),setValue:e=>O({fontSize:e})}),backgroundColor:o().createElement(i.NumberEditor,{type:"color",value:x(L),setValue:e=>O({backgroundColor:16777215===e?void 0:e})}),underline:o().createElement(i.BooleanEditor,{value:v(L),setValue:e=>O({underline:!!e||void 0})}),passThrough:o().createElement(i.BooleanEditor,{value:b(L),setValue:e=>O({passThrough:!!e||void 0})}),sub:o().createElement(i.BooleanEditor,{value:"sub"===C(L),setValue:e=>O({script:e?"sub":void 0})}),sup:o().createElement(i.BooleanEditor,{value:"sup"===C(L),setValue:e=>O({script:e?"sup":void 0})}),circle:o().createElement(i.BooleanEditor,{value:E(L),setValue:e=>O({circle:!!e||void 0})}),stackText:o().createElement(i.StringEditor,{value:k(L),setValue:e=>O({stackText:e||void 0})})}}))}},6295:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(7378),o=n.n(r),i=n(9397);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"),l=e=>{var t,n;return null!=(n=null==(t=null==e?void 0:e.attributes)?void 0:t.fontFamily)?n:"monospace"},c=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 ${l(e)}`,e.insert))?void 0:t.width)?n:0},{renderEditor:f,layoutResult:g,isSelected:h,actualHeight:m,cursorContent:y,setSelectedAttributes:x}=(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}),v=[],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)&&v.push(b.renderRect(e,t,i,24,{fillColor:11785981,strokeWidth:0})),v.push(b.renderText(e+i/2,t+20,r.insert,c(r),20,l(r),{textAlign:"center",fontWeight:u(r)?"bold":void 0,fontStyle:p(r)?"italic":void 0}))}const C=b.renderResult(v,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:c(y),setValue:e=>x({color:e})}),fontFamily:o().createElement(i.StringEditor,{value:l(y),setValue:e=>x({fontFamily:e})}),bold:o().createElement(i.BooleanEditor,{value:u(y),setValue:e=>x({bold:!!e||void 0})}),italic:o().createElement(i.BooleanEditor,{value:p(y),setValue:e=>x({italic:!!e||void 0})})}}))}},9474:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(7378),o=n.n(r),i=n(9397);const a=()=>{const{start:e,stop:t,duration:n,volume:r,audioUrl:a,recording:s}=(0,i.useAudioRecorder)(),{play:l,pause:c,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?c:l},u?"pause":"play"),p,"/",f,d))}},8022:(e,t,n)=>{"use strict";n.d(t,{default:()=>f});var r=n(7378),o=n.n(r),i=n(9397),a=Object.defineProperty,s=Object.defineProperties,l=Object.getOwnPropertyDescriptors,c=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:x,mask:v,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,k=C.height,[w,S]=o().useState(),P=y.x+h.x,R=y.y+h.y,_=o().useRef([]);return o().useEffect((()=>{e.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});_.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*P,-.3*R);null==(o=null==(e=t.current)?void 0:e.render)||o.call(e,_.current,{eye:[a.x+40,a.y+40,a.z],up:[s.x,s.y,s.z],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,P,R,w,E,k]),o().createElement("div",{style:{position:"absolute",inset:"0px"}},o().createElement("canvas",{ref:(0,i.bindMultipleRefs)(a,g,e),width:E,height:k,onMouseDown:e=>x({x:e.clientX,y:e.clientY}),onMouseMove:e=>{var n,r;S(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=_.current[o];t.position&&S({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(c)for(var n of c(t))p.call(t,n)&&d(e,n,t[n]);return e})({},w),A={label:(M=w.value[0]/20,Intl.DateTimeFormat("zh",{month:"long"}).format(new Date(M.toString()))),value:w.value[1]},s(T,l(A)))),v);var T,A,M}},79:(e,t,n)=>{"use strict";n.d(t,{default:()=>f});var r=n(7378),o=n.n(r),i=n(9397),a=Object.defineProperty,s=Object.defineProperties,l=Object.getOwnPropertyDescriptors,c=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(c)for(var n of c(t))p.call(t,n)&&d(e,n,t[n]);return e})({},y[t]),o={value:r[t]},s(n,l(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}))}}))}},4732:(e,t,n)=>{"use strict";n.d(t,{CADEditor:()=>S,useInitialStateValidated:()=>_,usePlugins:()=>P});var r=n(7378),o=n.n(r),i=n(9397),a=n(5188),s=n(7803),l=n(2845),c=n(1240),u=n(9541),p=n(4788),d=n(8071),f=n.n(d),g=n(6953),h=Object.defineProperty,m=Object.defineProperties,y=Object.getOwnPropertyDescriptors,x=Object.getOwnPropertySymbols,v=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={}))v.call(t,n)&&C(e,n,t[n]);if(x)for(var n of x(t))b.call(t,n)&&C(e,n,t[n]);return e},k=(e,t)=>m(e,y(t)),w=(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,p.registerRenderer)(i.reactWebglRenderTarget),(0,p.registerRenderer)(i.reactSvgRenderTarget),(0,p.registerRenderer)(i.reactCanvasRenderTarget),navigator.gpu&&(0,p.registerRenderer)(i.reactWebgpuRenderTarget);const S=o().forwardRef(((e,t)=>{var n,r,s,l,d,g,h,m,y,x,v,b,C,w;const S=new i.Debug(e.debug),{width:P,height:R}=(0,i.useWindowSize)(),{filterSelection:_,selected:T,isSelected:A,addSelection:M,removeSelection:L,setSelected:O,isSelectable:I,operations:F,executeOperation:D,resetOperation:B,selectBeforeOperate:z,operate:U,message:N,onSelectBeforeOperateKeyDown:j}=(0,i.useSelectBeforeOperate)({},((e,t)=>{var n;if("command"===(null==e?void 0:e.type)){if("acquire content"===e.name)return null==(n=Ie.current)||n.call(Ie,t),Ie.current=void 0,O(),!0;const r=(0,u.getCommand)(e.name);if(null==r?void 0:r.execute)return q((n=>{var o;n=oe(n),null==(o=r.execute)||o.call(r,{contents:n,selected:t,setEditingContentPath:ie,type:e.name,strokeStyleId:pe,fillStyleId:de,textStyleId:fe,width:P,height:R,transform:ot})})),O(),!0}return!1}),{onChange:t=>{var n;return null==(n=e.onSendSelection)?void 0:n.call(e,t.map((e=>e[0])))}}),{snapTypes:W,renderTarget:G,readOnly:V,inputFixed:$}=e,{state:H,setState:q,undo:Y,redo:X,canRedo:K,canUndo:Z,applyPatchFromSelf:Q,applyPatchFromOtherOperators:J}=(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=oe(r)[t];e&&p.add(e)}if("add"!==e.op||e.path.length>1){const e=oe(n)[t];e&&d.add(e)}}else if("length"===t&&"replace"===e.op&&"number"==typeof e.value){const t=oe(n)[e.value];t&&d.add(t)}}for(const e of p){const t=(0,i.validate)(e,c.Content);if(!0!==t)return console.error(t),!1}for(const e of p){const t=null==(a=null==(o=(0,c.getContentModel)(e))?void 0:o.getGeometries)?void 0:a.call(o,e,r);(null==t?void 0:t.bounding)&&(null==on||on.insert({x:t.bounding.start.x,y:t.bounding.start.y,w:t.bounding.end.x-t.bounding.start.x,h:t.bounding.end.y-t.bounding.start.y},e))}for(const e of d){const t=null==(l=null==(s=(0,c.getContentModel)(e))?void 0:s.getGeometries)?void 0:l.call(s,e,n);(null==t?void 0:t.bounding)&&(null==on||on.remove({x:t.bounding.start.x,y:t.bounding.start.y,w:t.bounding.end.x-t.bounding.start.x,h:t.bounding.end.y-t.bounding.start.y},e))}hn((0,c.zoomContentsToFit)(gn,fn,r,r,1)),null==(u=e.onChange)||u.call(e,r)}}),{selected:ee,setSelected:te}=(0,i.useSelected)({maxCount:1}),{editingContent:ne,trimPatchPath:re,getContentByPath:oe,setEditingContentPath:ie,prependPatchPath:ae}=(0,i.usePartialEdit)(H,{onEditingContentPathChange(e){pn(e)}}),[se,le]=o().useState(),ce=[],ue=[],pe=null==(n=c.getStrokeStyles(H).find((e=>e.content.isCurrent)))?void 0:n.index,de=null==(r=c.getFillStyles(H).find((e=>e.content.isCurrent)))?void 0:r.index,fe=null==(s=c.getTextStyles(H).find((e=>e.content.isCurrent)))?void 0:s.index,[ge,he]=o().useState(),[me,ye]=o().useState(),[xe,ve]=o().useState(),be=void 0!==me?ne[me]:void 0,Ce=be?null==(d=null==(l=(0,c.getContentModel)(be))?void 0:l.getGeometries)?void 0:d.call(l,be).bounding:void 0,Ee=void 0!==ge?ne[ge]:void 0,ke=Ee&&(0,c.isViewportContent)(Ee)?Ee:void 0,we=ke?e=>c.reverseTransformPositionByViewport(e,ke):void 0,Se=ke?e=>c.transformPositionByViewport(e,ke):void 0,[Pe,Re]=o().useState(0),[_e,Te]=o().useState(0),[Ae,Me]=o().useState(1),[Le,Oe]=o().useState(0),Ie=o().useRef(),{x:Fe,y:De,ref:Be,setX:ze,setY:Ue}=(0,i.useWheelScroll)({localStorageXKey:e.id+"-x",localStorageYKey:e.id+"-y",setXOffset:ke?e=>Re((t=>t+e)):void 0,setYOffset:ke?e=>Te((t=>t+e)):void 0}),{scale:Ne,setScale:je,ref:We}=(0,i.useWheelZoom)({min:.001,localStorageKey:e.id+"-scale",setScaleOffset:ke?(e,t)=>{Me((t=>t*e)),t=(0,i.reverseTransformPosition)(t,ot),Re((n=>(t.x-ke.x)*Ne*(1-e)+n*e)),Te((n=>(t.y-ke.y)*Ne*(1-e)+n*e))}:void 0,onChange(e,t,n){const r=(0,i.scaleByCursorPosition)({width:P,height:R},t/e,n);ze(r.setX),Ue(r.setY)}}),[Ge,Ve]=(0,i.useLocalStorageState)(e.id+"-rotate",0),{offset:$e,onStart:He,mask:qe,resetDragRotate:Ye}=(0,i.useDragRotate)((()=>{ke&&void 0!==ge?q((e=>{const t=(e=oe(e))[ge];t&&(0,c.isViewportContent)(t)&&(t.rotate=nt)})):Ve((0,i.angleToRadian)(null==$e?void 0:$e.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:Xe,zoomOut:Ke}=(0,i.useZoom)(Ne,je,{min:.001}),{offset:Ze,onStart:Qe,mask:Je,resetDragMove:et}=(0,i.useDragMove)((()=>{void 0===ge?(ze((e=>e+Ze.x)),Ue((e=>e+Ze.y))):Q(ae(ce),ae(ue))})),tt=Ne*(null!=(g=null==ke?void 0:ke.scale)?g:1),nt=void 0!==(null==$e?void 0:$e.angle)?(0,i.angleToRadian)($e.angle):void 0,rt=null!=nt?nt:ke?null!=(h=ke.rotate)?h:0:Ge,ot={x:Fe,y:De,scale:Ne,center:{x:P/2,y:R/2},rotate:ke?Ge:null!=nt?nt:Ge};if(void 0!==ge){const[,e,t]=(0,a.produceWithPatches)(ne,(e=>{const t=e[ge];if(t&&(0,c.isViewportContent)(t)){const e=i.rotatePosition(Ze,{x:0,y:0},-Ge);t.x+=(e.x+Pe)/Ne,t.y+=(e.y+_e)/Ne,t.scale*=Ae,void 0!==(null==$e?void 0:$e.angle)&&(t.rotate=(0,i.angleToRadian)($e.angle))}}));ce.push(...e),ue.push(...t)}else ot.x+=Ze.x,ot.y+=Ze.y;(0,i.useDelayedAction)(0!==Pe||0!==_e||1!==Ae,500,(()=>{Q(ae(ce),ae(ue)),Re(0),Te(0),Me(1)}));const it=[];ne.forEach(((e,t)=>{var n,r,o,i;if(e)if(A([t]))it.push({content:e,path:[t]});else for(const a of T)if(2===a.length&&a[0]===t){const t=null==(i=null==(o=null==(r=null==(n=(0,c.getContentModel)(e))?void 0:n.getGeometries)?void 0:r.call(n,e))?void 0:o.lines)?void 0:i[a[1]];t&&it.push({content:c.geometryLineToContent(t),path:a})}}));const{editPoint:at,editLastPosition:st,updateEditPreview:lt,onEditMove:ct,onEditClick:ut,getEditAssistentContents:pt,resetEdit:dt}=(0,i.useEdit)(((e,t)=>Q(ae([...ce,...e]),ae([...ue,...t]))),(e=>{var t,n;return null==(n=null==(t=(0,c.getContentModel)(e))?void 0:t.getEditPoints)?void 0:n.call(t,e,ne)}),{scale:tt,readOnly:V||"operate"===F.type}),{snapOffset:ft,snapOffsetActive:gt,snapOffsetInput:ht,setSnapOffset:mt,onSnapOffsetKeyDown:yt}=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!==at),{getSnapAssistentContents:xt,getSnapPoint:vt}=(0,i.usePointSnap)("operate"===F.type&&!(null==(m=(0,u.getCommand)(F.operate.name))?void 0:m.pointSnapDisabled)||void 0!==at,c.getIntersectionPoints,W,c.getContentModel,ft,5/tt),{commandMasks:bt,updateSelectedContents:Ct,startCommand:Et,onCommandDown:kt,onCommandUp:wt,onCommandKeyDown:St,commandInputs:Pt,onCommandMove:Rt,commandAssistentContents:_t,getCommandByHotkey:Tt,commandLastPosition:At,resetCommands:Mt}=(0,u.useCommands)((({updateContents:e,nextCommand:t,repeatedly:n,result:r}={})=>{var o;if(null==(o=Ie.current)||o.call(Ie,r),Ie.current=void 0,e){const[,...t]=(0,a.produceWithPatches)(ne,(t=>{e(t,T)}));Q(ae(t[0]),ae(t[1]))}else ce.length>0&&Q(ae(ce),ae(ue));n||(B(),O(),t&&nn({type:"command",name:t},[]))}),(e=>vt(Ot(e),ne,sn,Lt).position),$,"operate"===F.type&&"command"===F.operate.type?F.operate.name:void 0,it,tt,pe,de,fe,ne,e.backgroundColor),Lt=null!=st?st:At,Ot=e=>(e=(0,i.reverseTransformPosition)(e,ot),we&&(e=we(e)),e),{onStartSelect:It,dragSelectMask:Ft,endDragSelect:Dt,resetDragSelect:Bt}=(0,i.useDragSelect)(((e,t,n)=>{var r,o;if(t){const r=(0,i.getPolygonFromTwoPointsFormRegion)((0,i.getTwoPointsFormRegion)(e,t)).map((e=>Ot(e)));if("operate"===F.type&&"zoom window"===F.operate.name){if(void 0!==ge&&ke){const e=(0,c.getViewportByPoints)(ke,r,ke.rotate);return e&&q((t=>{const n=(t=oe(t))[ge];n&&(0,c.isViewportContent)(n)&&(n.x=e.x,n.y=e.y,n.scale=e.scale)})),void B()}const e=(0,i.zoomToFitPoints)(r,{width:P,height:R},{x:P/2,y:R/2},1,ot.rotate);return e&&(je(e.scale),ze(e.x),Ue(e.y)),void B()}const o=(0,i.getContentsByRegion)(ne,r,e.x>t.x,!!ot.rotate,c.getContentModel,n.shiftKey?void 0:I,un);n.shiftKey?L(...o):M(...o)}else{const t=Ot(e),n=ne.findIndex((e=>{var n,r;return!!e&&(0,c.isViewportContent)(e)&&!!(null==(r=null==(n=(0,c.getContentModel)(e.border))?void 0:n.isPointIn)?void 0:r.call(n,e.border,t))}));if(n>=0){if(ge===n&&ke){const e=(0,c.getDefaultViewport)(ke,H,ke.rotate);e&&q((t=>{const n=(t=oe(t))[ge];n&&(0,c.isViewportContent)(n)&&(n.x=e.x,n.y=e.y,n.scale=e.scale)}))}return void he(n)}const a=(0,c.getSortedContents)(ne).indexes,s=(0,i.getContentByClickPosition)(ne,t,(()=>!0),c.getContentModel,!1,un,a);if(void 0!==s){const e=ne[s[0]];if(e){const n=null==(o=null==(r=(0,c.getContentModel)(e))?void 0:r.getChildByPoint)?void 0:o.call(r,e,t,{textStyleId:fe});n&&(ve(n.child),n.patches&&Q(ae(n.patches[0],s),ae(n.patches[1],s)))}return void ye(s[0])}if(void 0!==me)return ye(void 0),void ve(void 0);if(void 0!==ge)return void he(void 0);const l=(0,c.zoomContentsToFit)(P,R,ne,H,.8,ot.rotate);l&&(je(l.scale),ze(l.x),Ue(l.y))}}));S.mark("before assistent contents");const zt=[...xt((e=>k(E({type:"circle"},e),{strokeColor:65280})),(e=>k(E({type:"rect"},e),{angle:0,strokeColor:65280})),(e=>({type:"polyline",points:e,strokeColor:65280}))),..._t],Ut=lt();ce.push(...null!=(y=null==Ut?void 0:Ut.patches)?y:[]),ue.push(...null!=(x=null==Ut?void 0:Ut.reversePatches)?x:[]),zt.push(...null!=(v=null==Ut?void 0:Ut.assistentContents)?v:[]),Ut&&zt.push(...(0,c.updateReferencedContents)(Ut.content,Ut.result,ne));for(const{content:e,path:t}of it)if(1===t.length){const n=at&&(0,i.isSamePath)(at.path,t)?null==Ut?void 0:Ut.result:null==Ut?void 0:Ut.relatedEditPointResults.get(e);zt.push(...pt(null!=n?n:e,(e=>k(E({type:"rect"},e),{fillColor:16777215,angle:0}))))}const Nt=Ct(H);zt.push(...Nt.assistentContents);for(const[e,t]of Nt.patches)ce.push(...e),ue.push(...t);o().useEffect((()=>{var t;return null==(t=e.setCanUndo)?void 0:t.call(e,Z)}),[Z]),o().useEffect((()=>{var t;return null==(t=e.setCanRedo)?void 0:t.call(e,K)}),[K]),o().useEffect((()=>{e.setOperation("select"!==F.type?F.operate.name:void 0)}),[F]);const[jt,Wt]=o().useState([]);o().useImperativeHandle(t,(()=>({handlePatchesEvent(e){try{J(e.patches,e.reversePatches,e.operator)}catch(e){console.error(e)}},handleSelectionEvent(e){Wt((0,a.produce)(jt,(t=>{const n=jt.findIndex((t=>t.operator===e.operator));n>=0?t[n].selection=e.selectedContents:t.push({selection:e.selectedContents,operator:e.operator})})))},undo:Y,redo:X,startOperation:nn})),[J]);const{input:Gt,inputPosition:Vt,setInputPosition:$t,setCursorPosition:Ht,clearText:qt}=(0,i.useCursorInput)(N,"operate"===F.type||V?void 0:(e,t)=>{if("Enter"===e.key&&t){const n=Tt(t);n&&nn({type:"command",name:n}),qt(),e.stopPropagation()}},{hideIfNoInput:!0,inputStyle:{textTransform:"uppercase"}});let Yt=Gt;!V&&Gt&&$&&(Yt=o().cloneElement(Gt,{style:c.fixedInputStyle}));const Xt=(0,i.useEvent)((e=>{const t=Ot({x:e.clientX,y:e.clientY}),n=vt(t,ne,sn,Lt);if("operate"===F.type&&"command"===F.operate.type&&Et(F.operate.name,n.position,n.target?{id:(0,c.getContentIndex)(n.target.content,H),snapIndex:n.target.snapIndex,param:n.target.param}:void 0),"operate"!==F.type)if(at)ut(n.position);else if(ee.length>0)e.shiftKey?L(...ee):M(...ee),te();else{if(void 0!==me&&!ke)return ye(void 0),void ve(void 0);It(e)}"operate"===F.type&&"zoom window"===F.operate.name&&It(e),mt(void 0)})),Kt=(0,i.useEvent)((e=>{"operate"===F.type&&"move canvas"===F.operate.name||4===e.buttons?Qe({x:e.clientX,y:e.clientY}):kt(Ot({x:e.clientX,y:e.clientY}))})),Zt=(0,i.useEvent)((e=>{wt(Ot({x:e.clientX,y:e.clientY}))})),Qt=(0,i.useEvent)((e=>{const t={x:e.clientX,y:e.clientY};$t(t);const n=Ot(t);if(Ht(n),le({x:Math.round(n.x),y:Math.round(n.y)}),"operate"===F.type&&"command"===F.operate.type){const e=vt(n,ne,sn,Lt);Rt(e.position,t,e.target?{id:(0,c.getContentIndex)(e.target.content,H),snapIndex:e.target.snapIndex,param:e.target.param}:void 0)}if("operate"!==F.type){let t;if(at&&(0,c.isViewportContent)(at.content)){const e=at.content;t=vt(c.reverseTransformPositionByViewport(n,at.content),ne,sn,Lt,(t=>c.transformPositionByViewport(t,e))),t.target||(t=vt(n,ne,sn,Lt))}else t=vt(n,ne,sn,Lt);ct(t.position,it,t.target);const r=(0,c.getSortedContents)(ne).indexes;te((0,i.getContentByClickPosition)(ne,n,e.shiftKey?()=>!0:I,c.getContentModel,F.select.part,un,r,3/tt))}})),Jt=(0,i.useEvent)((e=>{Dt(e)}));(0,i.useGlobalKeyDown)((e=>{St(e),j(e),yt(e),(0,i.metaKeyIfMacElseCtrlKey)(e)?"Minus"===e.code?Ke(e):"Equal"===e.code?Xe(e):"ArrowLeft"===e.key?(void 0!==ge&&Ce?q((e=>{const t=(e=oe(e))[ge];if(t&&(0,c.isViewportContent)(t)){const e=i.rotatePosition({x:(Ce.end.x-Ce.start.x)/10,y:0},{x:0,y:0},-Ge);t.x+=e.x,t.y+=e.y}})):ze((e=>e+P/10)),e.preventDefault()):"ArrowRight"===e.key?(void 0!==ge&&Ce?q((e=>{const t=(e=oe(e))[ge];if(t&&(0,c.isViewportContent)(t)){const e=i.rotatePosition({x:(Ce.end.x-Ce.start.x)/10,y:0},{x:0,y:0},-Ge);t.x-=e.x,t.y-=e.y}})):ze((e=>e-P/10)),e.preventDefault()):"ArrowUp"===e.key?(void 0!==ge&&Ce?q((e=>{const t=(e=oe(e))[ge];if(t&&(0,c.isViewportContent)(t)){const e=i.rotatePosition({x:0,y:(Ce.end.y-Ce.start.y)/10},{x:0,y:0},-Ge);t.x+=e.x,t.y+=e.y}})):Ue((e=>e+R/10)),e.preventDefault()):"ArrowDown"===e.key?(void 0!==ge&&Ce?q((e=>{const t=(e=oe(e))[ge];if(t&&(0,c.isViewportContent)(t)){const e=i.rotatePosition({x:0,y:(Ce.end.y-Ce.start.y)/10},{x:0,y:0},-Ge);t.x-=e.x,t.y-=e.y}})):Ue((e=>e-R/10)),e.preventDefault()):"KeyZ"===e.code?"select"===F.type&&(e.shiftKey?X(e):Y(e),O()):e.shiftKey||("KeyA"===e.code?(M(...ne.map(((e,t)=>[t]))),e.preventDefault()):"Digit0"===e.code?(je(1),ze(0),Ue(0),e.preventDefault()):"KeyC"===e.code?(nn({type:"command",name:"copy"}),e.preventDefault()):"KeyV"===e.code?(nn({type:"command",name:"paste"}),e.preventDefault()):"KeyX"===e.code&&(nn({type:"command",name:"cut"}),e.preventDefault())):"Escape"===e.key&&(ke||(ye(void 0),ve(void 0)),Mt(!0),dt(),Bt(),Ye(),et())}));const[en,tn]=o().useState(),nn=(e,t=T)=>{if(tn(e),Mt(),"command"===e.type){const n=(0,u.getCommand)(e.name);if(n){const r={count:n.selectCount,part:"select part"===n.selectType,selectable(e){var t,r;const o=(0,c.getContentByIndex)(ne,e);return!!o&&(null==(r=null==(t=n.contentSelectable)?void 0:t.call(n,o,ne))||r)}},{result:o,needSelect:i}=_(r.selectable,r.count,t);if(i)return void z(r,e);if(D(e,o))return}}if(U(e),se){const e=vt(se,ne,sn);Rt(e.position,Vt,e.target?{id:(0,c.getContentIndex)(e.target.content,H),snapIndex:e.target.snapIndex,param:e.target.param}:void 0)}},rn=(0,i.useEvent)((e=>{en&&(nn(en),e.preventDefault())})),[on,an]=o().useState(),sn=e=>on?on.search({x:e.start.x,y:e.start.y,w:e.end.x-e.start.x,h:e.end.y-e.start.y}):[];S.mark("before search");const ln=(0,i.getPointsBoundingUnsafe)((0,i.getPolygonFromTwoPointsFormRegion)({start:{x:0,y:0},end:{x:P,y:R}}).map((e=>Ot(e)))),cn=new Set(sn(ln)),un=e=>cn.has(e)||zt.includes(e),pn=e=>{var t,n;const r=f()();for(const o of e){if(!o)continue;const i=null==(n=null==(t=(0,c.getContentModel)(o))?void 0:t.getGeometries)?void 0:n.call(t,o,e);(null==i?void 0:i.bounding)&&r.insert({x:i.bounding.start.x,y:i.bounding.start.y,w:i.bounding.end.x-i.bounding.start.x,h:i.bounding.end.y-i.bounding.start.y},o)}an(r)},dn=void 0!==e.onApplyPatchesFromSelf,fn=100,gn=100;o().useEffect((()=>{pn(e.initialState),hn((0,c.zoomContentsToFit)(gn,fn,H,H,1))}),[e.initialState]);const{setMinimapTransform:hn,minimap:mn,getMinimapPosition:yn}=(0,i.useMinimap)({viewport:{width:P/ot.scale,height:R/ot.scale,rotate:ot.rotate,center:(0,i.reverseTransformPosition)(ot.center,ot)},width:gn,height:fn,children:t=>o().createElement(o().Fragment,null,o().createElement(p.MemoizedRenderer,{type:G,contents:ne,x:t.x,y:t.y,scale:t.scale,width:gn,height:fn,backgroundColor:e.backgroundColor,debug:e.debug,printMode:e.printMode,performanceMode:!0,operatorVisible:dn,time:Le,onClick:e=>{if(yn){const t=yn(e);ze((ot.center.x-t.x)*ot.scale),Ue((ot.center.y-t.y)*ot.scale)}},style:{cursor:"default"}}))}),xn=e=>{const[,...t]=(0,a.produceWithPatches)(ne,(t=>{it.forEach((n=>{const r=(0,c.getContentByIndex)(t,n.path);r&&e(r,t)}))}));Q(ae(t[0]),ae(t[1]))};let vn,bn;if(e.panelVisible&&it.length>0){const e={},t=new Set,n=[],r=[],a=[];let s=0;it.forEach((l=>{var u,p,d,f;t.add(l.content.type);const g=l.path[0];n.push(g);const h=null==(p=null==(u=(0,c.getContentModel)(l.content))?void 0:u.propertyPanel)?void 0:p.call(u,l.content,xn,H,{startTime:e=>{const t=performance.now(),n=r=>{const o=r-t;o>=e?Oe(0):(Oe(o),requestAnimationFrame(n))};requestAnimationFrame(n)},activeChild:g===me?xe:void 0,acquirePoint:e=>{Ie.current=t=>{(0,i.is)(t,c.SnapResult)&&e(t.position,t.target)},nn({type:"command",name:"acquire point"})},acquireContent:(e,t)=>{Ie.current=e=>{(0,i.is)(e,[[i.number]])&&t(e)},O(),z(e,{type:"command",name:"acquire content"})}});h&&Object.entries(h).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!==l.content.z,setValue:e=>xn((t=>{t.z=e?g:void 0}))})),void 0!==l.content.z&&r.push(o().createElement(i.NumberEditor,{value:l.content.z,setValue:e=>xn((t=>{t.z=e}))})),a.push(o().createElement(i.BooleanEditor,{value:!1!==l.content.visible,setValue:e=>xn((t=>{t.visible=!!e&&void 0}))}));const m=null==(f=null==(d=(0,c.getContentModel)(l.content))?void 0:d.getArea)?void 0:f.call(d,l.content);m&&(s+=m)})),e.z=r,e.visible=a,s&&(e.areas=o().createElement(i.NumberEditor,{value:s})),e.debug=o().createElement(i.Button,{onClick:()=>console.info(it.map((e=>e.content)))},"log to console"),vn=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:V}))}be&&(bn=null==(C=null==(b=(0,c.getContentModel)(be))?void 0:b.editPanel)?void 0:C.call(b,be,tt,xn,H,(()=>ye(void 0)),(e=>(Se&&(e=Se(e)),i.transformPosition(e,ot))),xe)),e.debug&&console.info(S.print());const Cn=o().createElement("div",{ref:(0,i.bindMultipleRefs)(Be,We)},o().createElement("div",{style:{cursor:null!=(w=null==at?void 0:at.cursor)?w:"operate"===F.type&&"move canvas"===F.operate.name?"grab":"crosshair",position:"absolute",inset:"0px",overflow:"hidden"},onMouseMove:Qt},on&&o().createElement(p.MemoizedRenderer,{type:G,contents:ne,previewPatches:0===ce.length?void 0:ce,assistentContents:0===zt.length?void 0:zt,selected:T,othersSelectedContents:jt,hovering:ee,active:me,activeViewportIndex:ge,onClick:Xt,onMouseDown:Kt,onMouseUp:Zt,onContextMenu:rn,onDoubleClick:Jt,x:ot.x,y:ot.y,scale:ot.scale,rotate:ot.rotate,width:P,height:R,backgroundColor:e.backgroundColor,printMode:e.printMode,performanceMode:e.performanceMode,operatorVisible:dn,debug:e.debug,time:Le}),mn,o().createElement("div",{style:{width:"100px",height:"100px",left:"1px",top:R-204+"px",boxSizing:"border-box",position:"absolute",transform:`rotate(${rt}rad)`,border:"1px solid black",borderRadius:"50px"}},o().createElement(i.RotationBar,{onMouseDown:()=>He({x:51,y:R-154})})),se&&o().createElement("span",{style:{position:"absolute",right:0}},se.x,",",se.y),bt,!gt&&Yt,!V&&!gt&&Pt,!V&&ht),Ft,Je,qe);return o().createElement(o().Fragment,null,Cn,vn,bn)}));function P(){const[e,t]=o().useState([]),[n,r]=o().useState(!1);return o().useEffect((()=>{(()=>{w(this,null,(function*(){try{const e=yield function(){return w(this,null,(function*(){const e=yield Promise.all(g.pluginScripts.map((e=>import("data:text/javascript;charset=utf-8,"+encodeURIComponent(e))))),t=k(E(E({},i),c),{React:o(),produce:a.produce,produceWithPatches:a.produceWithPatches,renderToStaticMarkup:s.renderToStaticMarkup,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,c.registerModel)(e);if(r.getCommand)for(const e of(0,i.iterateItemOrArray)(r.getCommand(t)))(0,u.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 R=[(0,i.Nullable)(c.Content)];function _(e,t){const[n,r]=o().useState(!1);return o().useEffect((()=>{if(e&&t){const t=(0,i.validate)(e,R);!0!==t?console.error(t):r(!0)}}),[e,t]),n}},9541:(e,t,n)=>{"use strict";n.d(t,{getCommand:()=>l,registerCommand:()=>u,useCommands:()=>c});var r=n(7378),o=n.n(r),i=n(9397),a=n(1240);const s={};function l(e){return s[e]}function c(e,t,n,r,l,c,u,p,d,f,g){const h=[],m=[],y=[],x=[],v=[],b=[],C=[],E=[],k={},w=[],S=[],P=[];return Object.values(s).forEach((i=>{var s;if(i.type)for(const e of i.type)e.hotkey&&w.push({key:e.hotkey,command:e.name});else i.hotkey&&w.push({key:i.hotkey,command:i.name});if(i.useCommand){const w=r&&(r===i.name||(null==(s=i.type)?void 0:s.some((e=>e.name===r))))?r:void 0,{onStart:R,mask:_,updateSelectedContent:T,assistentContents:A,input:M,subcommand:L,onMove:O,onMouseDown:I,onMouseUp:F,onKeyDown:D,lastPosition:B,reset:z}=i.useCommand({onEnd:e,transform:t,type:w,selected:l,scale:c,strokeStyleId:u,fillStyleId:p,textStyleId:d,contents:f,backgroundColor:g});if(!w)return;if(_&&m.push(o().cloneElement(_,{key:i.name})),w){if(k[i.name]=R,i.type)for(const e of i.type)k[e.name]=R;T&&C.push(T)}if(O&&y.push(O),I&&x.push(I),F&&v.push(F),D&&b.push(D),A&&E.push(...A),B&&S.push(B),z&&P.push(z),M){const e=[...M.props.children];if(L){const t={key:i.name+"sub command"};n?e.push(o().cloneElement(L,t)):(t.style=a.fixedInputStyle,h.push(o().cloneElement(L,t)))}const t={key:i.name};n&&(t.style=a.fixedInputStyle),h.push(o().cloneElement(M,t,...e))}else if(L){const e={key:i.name+"sub command"};e.style=a.fixedInputStyle,h.push(o().cloneElement(L,e))}}})),{commandMasks:m,commandInputs:h,updateSelectedContents(e){const t=[],n=[];let r=0;const o=l.map((e=>e.content));for(const{content:a,path:s}of l)for(const l of C){const c=l(a,e,o);c.assistentContents&&t.push(...c.assistentContents),c.patches&&n.push([(0,i.prependPatchPath)(c.patches[0],s),(0,i.prependPatchPath)(c.patches[1],s)]),c.newContents&&(n.push(...c.newContents.map(((t,n)=>[[{op:"add",path:[e.length+n+r],value:t}],[{op:"remove",path:[e.length+n+r]}]]))),r+=c.newContents.length)}return{assistentContents:t,patches:n}},commandAssistentContents:E,startCommand(e,t,n){e&&k[e]&&k[e](t,n)},onCommandMove(e,t,n){for(const r of y)r(e,t,n)},onCommandDown(e){for(const t of x)t(e)},onCommandUp(e){for(const t of v)t(e)},onCommandKeyDown(e){for(const t of b)t(e)},getCommandByHotkey(e){var t;return e=e.toUpperCase(),null==(t=w.find((t=>t.key===e)))?void 0:t.command},commandLastPosition:S[0],resetCommands(e){P.forEach((t=>{t(e)}))}}}function u(e){s[e.name]=e}},1240:(e,t,n)=>{"use strict";n.r(t),n.d(t,{AngleDeltaFields:()=>T,ArrowFields:()=>R,BaseContent:()=>b,ContainerFields:()=>P,Content:()=>C,FillFields:()=>k,FillStyleContent:()=>de,PositionRef:()=>At,SegmentCountFields:()=>_,SnapResult:()=>wt,SnapTarget:()=>kt,StrokeFields:()=>E,StrokeStyleContent:()=>ue,TextEditor:()=>It,TextFields:()=>w,TextStyleContent:()=>ge,VariableValuesFields:()=>S,ViewportContent:()=>me,allContentsCache:()=>G,angleDeltaModel:()=>B,arrowModel:()=>F,assistentTextCache:()=>Ct,breakGeometryLinesToPathCommands:()=>vt,breakPolyline:()=>yt,containerModel:()=>I,contentIndexCache:()=>Ge,contentIsReferenced:()=>qe,defaultAngleDelta:()=>Ue,defaultSegmentCount:()=>Be,defaultStrokeColor:()=>ze,dimensionStyle:()=>Ne,fillModel:()=>M,fixedInputStyle:()=>Q,geometryLineToContent:()=>ee,getAngleDeltaContentPropertyPanel:()=>Ee,getArrowContentPropertyPanel:()=>be,getArrowPoints:()=>bt,getAssistentText:()=>Et,getContainerExplode:()=>at,getContainerGeometries:()=>tt,getContainerMirror:()=>st,getContainerMove:()=>ot,getContainerRender:()=>lt,getContainerRenderIfSelected:()=>ct,getContainerRotate:()=>it,getContainerSnapPoints:()=>Ke,getContainerVariableNames:()=>Je,getContentByIndex:()=>J,getContentIndex:()=>We,getContentModel:()=>Z,getContentsBounding:()=>rt,getContentsBreak:()=>pt,getContentsExplode:()=>ut,getContentsGeometries:()=>nt,getContentsPoints:()=>te,getContentsSnapPoints:()=>Ze,getDefaultStrokeWidth:()=>Oe,getDefaultViewport:()=>St,getEditPointsFromCache:()=>H,getFillContentPropertyPanel:()=>xe,getFillStyleContent:()=>Fe,getFillStyles:()=>se,getGeometriesFromCache:()=>V,getIntersectionPoints:()=>K,getLinesParamAtPoint:()=>_t,getLinesPointAtParam:()=>Tt,getPolylineEditPoints:()=>je,getRefPosition:()=>Mt,getReference:()=>He,getSegmentCountContentPropertyPanel:()=>Ce,getSnapPointsFromCache:()=>$,getSnapTargetRef:()=>Lt,getSortedContents:()=>$e,getStrokeAndFillRefIds:()=>ht,getStrokeContentPropertyPanel:()=>re,getStrokeRefIds:()=>dt,getStrokeStyleContent:()=>Ie,getStrokeStyles:()=>ie,getTextContentPropertyPanel:()=>ve,getTextStyleContent:()=>De,getTextStyles:()=>ce,getTimeExpressionValue:()=>Y,getVariableValuesContentPropertyPanel:()=>ke,getViewportByPoints:()=>Pt,getViewportByRegion:()=>Rt,getViewportMatrix:()=>Ft,hasFill:()=>Le,isAngleDeltaContent:()=>Ae,isArrowContent:()=>_e,isContainerContent:()=>Re,isFillContent:()=>Se,isFillStyleContent:()=>fe,isSegmentCountContent:()=>Te,isStrokeContent:()=>we,isStrokeStyleContent:()=>pe,isTextContent:()=>Pe,isTextStyleContent:()=>he,isVariableValuesContent:()=>Me,isViewportContent:()=>ye,iterateAllContents:()=>Xe,mergePolylines:()=>xt,registerModel:()=>U,renderContainerChildren:()=>Qe,renderContainerIfSelected:()=>et,reverseTransformPositionByViewport:()=>Bt,segmentCountModel:()=>D,strokeModel:()=>A,textModel:()=>L,transformPositionByViewport:()=>Dt,trimOffsetResult:()=>Ot,updateReferencedContents:()=>Ye,updateStrokeAndFillRefIds:()=>mt,updateStrokeRefIds:()=>ft,variableValuesModel:()=>O,zoomContentsToFit:()=>ne});var r=n(2845),o=n(5188),i=n(7378),a=n.n(i),s=n(9397),l=Object.defineProperty,c=Object.defineProperties,u=Object.getOwnPropertyDescriptors,p=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,f=Object.prototype.propertyIsEnumerable,g=(e,t)=>{if(t=Symbol[e])return t;throw Error("Symbol."+e+" is not defined")},h=(e,t,n)=>t in e?l(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,m=(e,t)=>{for(var n in t||(t={}))d.call(t,n)&&h(e,n,t[n]);if(p)for(var n of p(t))f.call(t,n)&&h(e,n,t[n]);return e},y=(e,t)=>c(e,u(t)),x=function(e,t){this[0]=e,this[1]=t},v=e=>{var t,n=e[g("asyncIterator")],r=!1,o={};return null==n?(n=e[g("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);if(!(o instanceof Object))throw TypeError("Object expected");r(o)})),1)}}),o[g("iterator")]=()=>o,t("next"),"throw"in n?t("throw"):o.throw=e=>{throw e},"return"in n&&t("return"),o};const b=(e=s.string)=>({type:e,z:(0,s.optional)(s.number),visible:(0,s.optional)(s.boolean)}),C=(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=z[n];return r?r.isValid(e,t):{path:t,expect:"register"}},E={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,C)),trueStrokeColor:(0,s.optional)(s.boolean)},k={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))})),fillStyleId:(0,s.optional)((0,s.or)(s.number,C))},w=(0,s.and)(s.TextStyle,{color:s.number,textStyleId:(0,s.optional)((0,s.or)(s.number,C)),lineHeight:(0,s.optional)(s.number),align:(0,s.optional)(s.Align),verticalAlign:(0,s.optional)(s.VerticalAlign)}),S={variableValues:(0,s.optional)((0,s.record)(s.string,s.string))},P=y(m({},S),{contents:[(0,s.Nullable)(C)]}),R={arrowAngle:(0,s.optional)(s.number),arrowSize:(0,s.optional)((0,s.minimum)(0,s.number))},_={segmentCount:(0,s.optional)(s.number)},T={angleDelta:(0,s.optional)((0,s.exclusiveMinimum)(0,s.number))},A={isStroke:!0},M={isFill:!0},L={isText:!0},O={isVariableValues:!0},I=y(m({},O),{isContainer:!0}),F={isArrow:!0},D={isSegmentCount:!0},B={isAngleDelta:!0},z={};function U(e){z[e.type]=e}const N=new s.WeakmapCache,j=new s.WeakmapCache,W=new s.WeakmapCache,G=new s.WeakmapCache,V=N.get.bind(N),$=j.get.bind(j),H=W.get.bind(W),q=new s.MapCache;function Y(e,t,n){if(!e||!t)return n;const o=q.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 X=new s.WeakmapCache2;function K(e,t,n){return X.get(e,t,(()=>Array.from((0,s.iterateIntersectionPoints)(e,t,n,Z))))}function Z(e){return z[e.type]}const Q={position:"absolute",bottom:"10px",left:"190px"};function J(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=Z(a))?void 0:n.getGeometries)?void 0:r.call(n,a))?void 0:o.lines)?void 0:i[t[1]];return s?ee(s):void 0}function ee(e){return Array.isArray(e)?{type:"line",points:e}:"arc"===e.type?m({type:"arc"},e.curve):"ellipse arc"===e.type?m({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}]}:{type:"path",commands:[{type:"move",to:e.curve.from},{type:"bezierCurve",cp1:e.curve.cp1,cp2:e.curve.cp2,to:e.curve.to}]}}function te(e,t,n=(()=>!0)){const r=[];return e.forEach((e=>{if(!e)return;if(!n(e))return;const o=Z(e);if(null==o?void 0:o.getGeometries){const{bounding:n}=o.getGeometries(e,t);n&&r.push(n.start,n.end)}})),r}function ne(e,t,n,r,o=.8,i){const a=te(n,r),l=(0,s.getPointsBounding)(a);if(!l)return;const c=(0,s.zoomToFitPoints)(a,{width:e,height:t},{x:e/2,y:t/2},o,i);return c?m({bounding:l},c):void 0}function re(e,t,n){const r=[];if(n){const o=ie(n);o.length>0&&(r.push(a().createElement(s.BooleanEditor,{value:void 0!==e.strokeStyleId,setValue:e=>t((t=>{we(t)&&(t.strokeStyleId=e?o[0].index:void 0)}))})),"number"==typeof e.strokeStyleId&&r.push(a().createElement(s.EnumEditor,{select:!0,enums:o.map((e=>e.index)),enumTitles:o.map((e=>e.label)),value:e.strokeStyleId,setValue:e=>t((t=>{we(t)&&(t.strokeStyleId=e)}))})))}return r.length>1?{strokeStyleId:r}:{strokeStyleId:r,dashArray:[a().createElement(s.BooleanEditor,{value:void 0!==e.dashArray,setValue:e=>t((t=>{we(t)&&(t.dashArray=e?[4]:void 0)}))}),void 0!==e.dashArray?a().createElement(s.ArrayEditor,y(m({inline:!0},(0,s.getArrayEditorProps)((e=>e.dashArray||[]),4,(e=>t((t=>{we(t)&&e(t)}))))),{items:e.dashArray.map(((e,n)=>a().createElement(s.NumberEditor,{value:e,setValue:e=>t((t=>{we(t)&&t.dashArray&&(t.dashArray[n]=e)}))})))})):void 0],strokeColor:[a().createElement(s.BooleanEditor,{value:void 0!==e.strokeColor,setValue:e=>t((t=>{we(t)&&(t.strokeColor=e?0:void 0)}))}),void 0!==e.strokeColor?a().createElement(s.NumberEditor,{type:"color",value:e.strokeColor,setValue:e=>t((t=>{we(t)&&(t.strokeColor=e)}))}):void 0],trueStrokeColor:a().createElement(s.BooleanEditor,{value:void 0!==e.trueStrokeColor,setValue:e=>t((t=>{we(t)&&(t.trueStrokeColor=!!e||void 0)}))}),strokeWidth:[a().createElement(s.BooleanEditor,{value:void 0!==e.strokeWidth,setValue:e=>t((t=>{we(t)&&(t.strokeWidth=e?2:void 0)}))}),void 0!==e.strokeWidth?a().createElement(s.NumberEditor,{value:e.strokeWidth,setValue:e=>t((t=>{we(t)&&(t.strokeWidth=e)}))}):void 0]}}const oe=new s.WeakmapCache;function ie(e){return oe.get(e,(()=>e.map(((e,t)=>({c:e,i:t}))).filter((e=>!!e.c&&pe(e.c))).map((({c:e,i:t})=>{var n,r,o,i;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)}`}}))))}const ae=new s.WeakmapCache;function se(e){return ae.get(e,(()=>e.map(((e,t)=>({c:e,i:t}))).filter((e=>!!e.c&&fe(e.c))).map((({c:e,i:t})=>{var n;let r="";return e.fillPattern?r=`${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&&(r=(0,s.getColorString)(e.fillColor)),{index:t,content:e,label:r}}))))}const le=new s.WeakmapCache;function ce(e){return le.get(e,(()=>e.map(((e,t)=>({c:e,i:t}))).filter((e=>!!e.c&&he(e.c))).map((({c:e,i:t})=>({index:t,content:e,label:`${e.fontFamily} ${e.fontSize} ${(0,s.getColorString)(e.color)}`})))))}const ue=(0,s.and)(b("stroke style"),E,s.Region,{isCurrent:(0,s.optional)(s.boolean)});function pe(e){return"stroke style"===e.type}const de=(0,s.and)(b("fill style"),k,s.Region,{isCurrent:(0,s.optional)(s.boolean)});function fe(e){return"fill style"===e.type}const ge=(0,s.and)(b("text style"),w,s.Position,{isCurrent:(0,s.optional)(s.boolean)});function he(e){return"text style"===e.type}const me=(0,s.and)(b("viewport"),s.Position,E,{border:C,scale:s.number,rotate:(0,s.optional)(s.number)});function ye(e){return"viewport"===e.type}function xe(e,t,n){const r=[];if(n){const o=se(n);o.length>0&&(r.push(a().createElement(s.BooleanEditor,{value:void 0!==e.fillStyleId,setValue:e=>t((t=>{Se(t)&&(t.fillStyleId=e?o[0].index:void 0)}))})),"number"==typeof e.fillStyleId&&r.push(a().createElement(s.EnumEditor,{select:!0,enums:o.map((e=>e.index)),enumTitles:o.map((e=>e.label)),value:e.fillStyleId,setValue:e=>t((t=>{Se(t)&&(t.fillStyleId=e)}))})))}return r.length>1?{fillStyleId:r}:{fillStyleId:r,fillColor:[a().createElement(s.BooleanEditor,{value:void 0!==e.fillColor,setValue:e=>t((t=>{Se(t)&&(t.fillColor=e?0:void 0)}))}),void 0!==e.fillColor?a().createElement(s.NumberEditor,{type:"color",value:e.fillColor,setValue:e=>t((t=>{Se(t)&&(t.fillColor=e)}))}):void 0],fillPattern:[a().createElement(s.BooleanEditor,{value:void 0!==e.fillPattern,setValue:e=>t((t=>{Se(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=>{Se(t)&&t.fillPattern&&(t.fillPattern.width=e)}))}),height:a().createElement(s.NumberEditor,{value:e.fillPattern.height,setValue:e=>t((t=>{Se(t)&&t.fillPattern&&(t.fillPattern.height=e)}))}),strokeColor:[a().createElement(s.BooleanEditor,{value:void 0!==e.fillPattern.strokeColor,setValue:e=>t((t=>{Se(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=>{Se(t)&&t.fillPattern&&(t.fillPattern.strokeColor=e)}))}):void 0],lines:a().createElement(s.ArrayEditor,y(m({},(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=>{Se(t)&&t.fillPattern&&e(t)}))))),{items:e.fillPattern.lines.map(((e,n)=>a().createElement(s.ObjectArrayEditor,y(m({},(0,s.getArrayEditorProps)((e=>e),{x:0,y:5},(e=>t((t=>{Se(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=>{Se(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=>{Se(t)&&t.fillPattern&&(t.fillPattern.lines[n][r].y=e)})),style:{width:"70px"}})})))}))))}))}}):void 0]}}function ve(e,t,n){var r,o;const i=[];if(n){const r=ce(n);r.length>0&&(i.push(a().createElement(s.BooleanEditor,{value:void 0!==e.textStyleId,setValue:e=>t((t=>{Pe(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=>{Pe(t)&&(t.textStyleId=e)}))})))}return i.length>1?{textStyleId:i}:{textStyleId:i,fontSize:a().createElement(s.NumberEditor,{value:e.fontSize,setValue:e=>t((t=>{Pe(t)&&(t.fontSize=e)}))}),fontFamily:a().createElement(s.StringEditor,{value:e.fontFamily,setValue:e=>t((t=>{Pe(t)&&(t.fontFamily=e)}))}),color:a().createElement(s.NumberEditor,{type:"color",value:e.color,setValue:e=>t((t=>{Pe(t)&&(t.color=e)}))}),lineHeight:[a().createElement(s.BooleanEditor,{value:void 0!==e.lineHeight,setValue:n=>t((t=>{Pe(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=>{Pe(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=>{Pe(t)&&(t.align=e)}))}),verticalAlign:a().createElement(s.EnumEditor,{enums:s.verticalAligns,value:null!=(o=e.verticalAlign)?o:"middle",setValue:e=>t((t=>{Pe(t)&&(t.verticalAlign=e)}))})}}function be(e,t){return{arrowAngle:[a().createElement(s.BooleanEditor,{value:void 0!==e.arrowAngle,setValue:e=>t((t=>{_e(t)&&(t.arrowAngle=e?Ne.arrowAngle:void 0)}))}),void 0!==e.arrowAngle?a().createElement(s.NumberEditor,{value:e.arrowAngle,setValue:e=>t((t=>{_e(t)&&(t.arrowAngle=e)}))}):void 0],arrowSize:[a().createElement(s.BooleanEditor,{value:void 0!==e.arrowSize,setValue:e=>t((t=>{_e(t)&&(t.arrowSize=e?Ne.arrowSize:void 0)}))}),void 0!==e.arrowSize?a().createElement(s.NumberEditor,{value:e.arrowSize,setValue:e=>t((t=>{_e(t)&&(t.arrowSize=e)}))}):void 0]}}function Ce(e,t){return{segmentCount:[a().createElement(s.BooleanEditor,{value:void 0!==e.segmentCount,setValue:e=>t((t=>{Te(t)&&(t.segmentCount=e?Be:void 0)}))}),void 0!==e.segmentCount?a().createElement(s.NumberEditor,{value:e.segmentCount,setValue:e=>t((t=>{Te(t)&&(t.segmentCount=e)}))}):void 0]}}function Ee(e,t){return{angleDelta:[a().createElement(s.BooleanEditor,{value:void 0!==e.angleDelta,setValue:e=>t((t=>{Ae(t)&&(t.angleDelta=e?Ue:void 0)}))}),void 0!==e.angleDelta?a().createElement(s.NumberEditor,{value:e.angleDelta,setValue:e=>t((t=>{Ae(t)&&(t.angleDelta=e)}))}):void 0]}}function ke(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=>{Me(n)&&(n.variableValues||(n.variableValues={}),n.variableValues[t]=e)}))})}})))}):[]}}function we(e){var t;return!!(null==(t=Z(e))?void 0:t.isStroke)}function Se(e){var t;return!!(null==(t=Z(e))?void 0:t.isFill)}function Pe(e){var t;return!!(null==(t=Z(e))?void 0:t.isText)}function Re(e){var t;return!!(null==(t=Z(e))?void 0:t.isContainer)}function _e(e){var t;return!!(null==(t=Z(e))?void 0:t.isArrow)}function Te(e){var t;return!!(null==(t=Z(e))?void 0:t.isSegmentCount)}function Ae(e){var t;return!!(null==(t=Z(e))?void 0:t.isAngleDelta)}function Me(e){var t;return!!(null==(t=Z(e))?void 0:t.isVariableValues)}function Le(e){return void 0!==e.fillColor||void 0!==e.fillPattern||void 0!==e.fillStyleId}function Oe(e){return Se(e)&&Le(e)?0:1}function Ie(e,t){if(void 0!==e.strokeStyleId){const n="number"==typeof e.strokeStyleId?t[e.strokeStyleId]:e.strokeStyleId;if(n&&pe(n))return n}return e}function Fe(e,t){if(void 0!==e.fillStyleId){const n="number"==typeof e.fillStyleId?t[e.fillStyleId]:e.fillStyleId;if(n&&fe(n))return n}return e}function De(e,t){if(void 0!==e.textStyleId){const n="number"==typeof e.textStyleId?t[e.textStyleId]:e.textStyleId;if(n&&he(n))return n}return e}const Be=100,ze=0,Ue=5,Ne={margin:5,arrowAngle:15,arrowSize:10};function je(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 We(e,t){return Ge.get(e,(()=>t.findIndex((t=>e===t))))}const Ge=new s.WeakmapCache,Ve=new s.WeakmapCache;function $e(e){return Ve.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 He(e,t,n=(e=>!0)){if("number"!=typeof e)return n(e)?e:void 0;const r=t[e];return r&&n(r)?r:void 0}function qe(e,t){var n,r,o;const i=We(e,t);for(const e of Xe(t))if(null==(o=null==(r=null==(n=Z(e))?void 0:n.getRefIds)?void 0:r.call(n,e))?void 0:o.includes(i))return!0;return!1}function Ye(e,t,n,r){var i,a;const s=[],l=We(e,n);for(const e of Xe(n)){if(null==r?void 0:r.includes(e))continue;const n=Z(e);(null==(a=null==(i=null==n?void 0:n.getRefIds)?void 0:i.call(n,e))?void 0:a.includes(l))&&s.push((0,o.produce)(e,(e=>{var r;null==(r=n.updateRefId)||r.call(n,e,(e=>{if(e===l)return t}))})))}return s}function*Xe(e){for(const t of e)t&&(yield t,Re(t)&&(yield*v(Xe(t.contents))))}function Ke(e,t){return Ze(e,t)}function Ze(e,t,n=(e=>e.contents)){return $(e,(()=>{const r=[];return n(e).forEach((e=>{var n,o;if(!e)return;const i=null==(o=null==(n=Z(e))?void 0:n.getSnapPoints)?void 0:o.call(n,e,t);i&&r.push(...i)})),r}))}function Qe(e,t){t=y(m({},t),{variableContext:m(m({},t.variableContext),e.variableValues)});const n=[];return $e(e.contents).contents.forEach((e=>{if(!e)return;const r=Z(e);if(null==r?void 0:r.render){const o=r.render;n.push(o(e,t))}})),n}function Je(e){var t,n;const r=new Set;for(const o of e.contents)if(o){const e=null==(n=null==(t=Z(o))?void 0:t.getVariableNames)?void 0:n.call(t,o);e&&e.forEach((e=>r.add(e)))}return Array.from(r)}function et(e,t){const{bounding:n}=tt(e);return n?t.target.renderRect(n.start.x,n.start.y,n.end.x-n.start.x,n.end.y-n.start.y,{strokeColor:t.color,dashArray:[4],strokeWidth:t.strokeWidth}):t.target.renderEmpty()}function tt(e){return nt(e)}function nt(e,t=(e=>e.contents)){return V(e,(()=>{const n=[],r=[],o=[],i=[];return t(e).forEach((e=>{var t,a;if(!e)return;const s=null==(a=null==(t=Z(e))?void 0:t.getGeometries)?void 0:a.call(t,e);s&&(n.push(...s.lines),s.bounding&&o.push(s.bounding.start,s.bounding.end),s.renderingLines&&r.push(...s.renderingLines),s.regions&&i.push(...s.regions))})),{lines:n,bounding:(0,s.getPointsBounding)(o),renderingLines:r,regions:i.length>0?i:void 0}}))}function rt(e){const t=[];return e.forEach((e=>{var n,r;if(e){const o=null==(r=null==(n=Z(e))?void 0:n.getGeometries)?void 0:r.call(n,e).bounding;o&&t.push(o.start,o.end)}})),(0,s.getPointsBounding)(t)}function ot(e,t){e.contents.forEach((e=>{var n,r;e&&(null==(r=null==(n=Z(e))?void 0:n.move)||r.call(n,e,t))}))}function it(e,t,n,r){e.contents.forEach((e=>{var o,i;e&&(null==(i=null==(o=Z(e))?void 0:o.rotate)||i.call(o,e,t,n,r))}))}function at(e){return ut(e.contents)}function st(e,t,n,r){e.contents.forEach((e=>{var o,i;e&&(null==(i=null==(o=Z(e))?void 0:o.mirror)||i.call(o,e,t,n,r))}))}function lt(e,t){const n=Qe(e,t);return t.target.renderGroup(n)}function ct(e,t){return et(e,t)}function ut(e){return e.filter((e=>!!e))}function pt(e,t,n){const r=[];for(const o of e)if(o){const e=Z(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))))),l=e.break(o,a,n);l?r.push(...l):r.push(o)}}return r}function dt(e){return"number"==typeof e.strokeStyleId?[e.strokeStyleId]:[]}function ft(e,t){if(void 0!==e.strokeStyleId){const n=t(e.strokeStyleId);void 0!==n&&(e.strokeStyleId=n)}}function gt(e){return"number"==typeof e.fillStyleId?[e.fillStyleId]:[]}function ht(e){return[...dt(e),...gt(e)]}function mt(e,t){ft(e,t),function(e,t){if(void 0!==e.fillStyleId){const n=t(e.fillStyleId);void 0!==n&&(e.fillStyleId=n)}}(e,t)}function yt(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 xt(e){(0,s.mergePolylinesToPolyline)(e);for(const t of e)t.points.length>2&&(t.type="polyline")}function vt(e,t){return(0,s.breakGeometryLines)(e,t).map((e=>({type:"path",commands:(0,s.geometryLineToPathCommands)(e)})))}function bt(e,t,n){var r,o;const i=null!=(r=n.arrowSize)?r:Ne.arrowSize,a=null!=(o=n.arrowAngle)?o:Ne.arrowAngle;return(0,s.getArrow)(e,t,i,a,n.strokeWidth)}const Ct=new s.MapCache3;function Et(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 kt={snapIndex:s.number,param:(0,s.optional)(s.number),id:s.number},wt={position:s.Position,target:(0,s.optional)(kt)};function St(e,t,n){return Pt(e,te(t,t,(e=>!ye(e))),n)}function Pt(e,t,n){n&&(t=t.map((e=>(0,s.rotatePosition)(e,{x:0,y:0},n))));const r=(0,s.getPointsBounding)(t);if(r)return Rt(e,r)}function Rt(e,t){var n,r;const o=null==(r=null==(n=Z(e))?void 0:n.getGeometries)?void 0:r.call(n,e).bounding;if(!o)return;const i=o.end.x-o.start.x,a=o.end.y-o.start.y,s=t.end.x-t.start.x,l=t.end.y-t.start.y,c=i/s,u=a/l;let p,d=0,f=0;return c0){let n=yt(Array.from((0,s.iteratePolylineLines)(e)),r);const o=n.filter(((e,t)=>t%2==0)),i=n.filter(((e,t)=>t%2==1));return n=Math.min(...o.map((e=>{var n,r,o,i,a;return null==(a=null!=(i=null==(o=null==(r=null==(n=Z(e))?void 0:n.getGeometries)?void 0:r.call(n,e))?void 0:o.lines)?i:[])?void 0:a.map((e=>(0,s.getPointAndGeometryLineMinimumDistance)(t,e)))})).flat(2))>Math.min(...i.map((e=>{var n,r,o,i,a;return null==(a=null!=(i=null==(o=null==(r=null==(n=Z(e))?void 0:n.getGeometries)?void 0:r.call(n,e))?void 0:o.lines)?i:[])?void 0:a.map((e=>(0,s.getPointAndGeometryLineMinimumDistance)(t,e)))})).flat(2))?i:o,xt(n),n.map((e=>e.points))}return[e]}function It(e){var t,n,r;const{state:o,setState:i,undo:l,redo:c}=(0,s.useUndoRedo)(e.value.split("")),{renderEditor:u}=(0,s.useFlowLayoutTextEditor)({state:o,setState:i,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?c(t):l(t),0)))},autoHeight:!e.height,autoFocus:!0,onBlur:()=>{setTimeout((()=>{if(!e.readOnly&&e.setValue){const t=o.join("");t!==e.value&&e.setValue(t)}}),0)},align:e.align,verticalAlign:e.verticalAlign,style:{border:"unset"}}),p=null!=(r=e.borderWidth)?r:1;return a().createElement("div",{style:y(m({position:"absolute",zIndex:10},s.controlStyle),{padding:"0px",left:e.x-p+"px",top:e.y-p+"px",borderWidth:`${p}px`})},u({target:s.reactCanvasRenderTarget,getTextColors:()=>({color:e.color})}))}function Ft(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 Dt(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 Bt(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))}},6953:(e,t,n)=>{"use strict";n.d(t,{pluginScripts:()=>r});const r=['// dev/cad-editor/plugins/acquire-point.plugin.tsx\nfunction getCommand() {\n return {\n name: "acquire point",\n useCommand({ onEnd }) {\n return {\n onStart(p, target) {\n onEnd({\n result: {\n position: p,\n target\n }\n });\n }\n };\n },\n selectCount: 0\n };\n}\nexport {\n getCommand\n};\n','// 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 arrowCache = new ctx.WeakmapCache3();\n function getArrowGeometriesFromCache(content, contents) {\n var _a, _b;\n const p1 = (_a = ctx.getRefPosition(content.ref1, contents)) != null ? _a : content.p1;\n const p2 = (_b = ctx.getRefPosition(content.ref2, contents)) != null ? _b : content.p2;\n return arrowCache.get(content, p1, 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 content.p1.x += offset.x;\n content.p1.y += offset.y;\n content.p2.x += offset.x;\n content.p2.y += offset.y;\n },\n rotate(content, center, angle) {\n content.p1 = ctx.rotatePositionByCenter(content.p1, center, -angle);\n content.p2 = ctx.rotatePositionByCenter(content.p2, center, -angle);\n },\n mirror(content, line) {\n content.p1 = ctx.getSymmetryPoint(content.p1, line);\n content.p2 = ctx.getSymmetryPoint(content.p2, line);\n },\n render(content, { target, getStrokeColor, transformStrokeWidth, contents }) {\n var _a;\n const strokeStyleContent = ctx.getStrokeStyleContent(content, contents);\n const strokeColor = getStrokeColor(strokeStyleContent);\n const strokeWidth = transformStrokeWidth((_a = strokeStyleContent.strokeWidth) != null ? _a : ctx.getDefaultStrokeWidth(content));\n const { regions, renderingLines } = getArrowGeometriesFromCache(content, contents);\n const children = [];\n for (const line of renderingLines) {\n children.push(target.renderPolyline(line, { strokeColor, strokeWidth }));\n }\n if (regions) {\n for (let i = 0; i < 2 && i < regions.length; i++) {\n children.push(target.renderPolyline(regions[i].points, { strokeWidth: 0, fillColor: strokeColor }));\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: (content) => [\n ...ctx.getStrokeRefIds(content),\n ...content.ref1 && typeof content.ref1.id === "number" ? [content.ref1.id] : [],\n ...content.ref2 && typeof content.ref2.id === "number" ? [content.ref2.id] : []\n ],\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 };\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.or(ctx.number, ctx.Content),\n angle: ctx.number\n });\n const blockModel = {\n type: "block",\n ...ctx.containerModel,\n explode: ctx.getContainerExplode,\n render: ctx.getContainerRender,\n renderIfSelected: ctx.getContainerRenderIfSelected,\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: ctx.getContainerGeometries,\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, 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 };\n const blockLinesCache = new ctx.WeakmapCache2();\n const blockSnapPointsCache = new ctx.WeakmapCache2();\n function extractContentInBlockReference(target, content, block, contents) {\n const model = ctx.getContentModel(target);\n if (!model) {\n return void 0;\n }\n return ctx.produce(target, (draft) => {\n var _a, _b;\n (_a = model.rotate) == null ? void 0 : _a.call(model, draft, block.base, content.angle, contents);\n (_b = model.move) == null ? void 0 : _b.call(model, draft, content);\n });\n }\n function getBlockReferenceGeometries(content, contents) {\n const block = ctx.getReference(content.refId, contents, isBlockContent);\n if (block) {\n return blockLinesCache.get(block, content, () => {\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(c)) == null ? void 0 : _a.getGeometries) == null ? void 0 : _b.call(_a, extracted);\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 [\n regions.push(...r.regions)\n ];\n }\n }\n });\n return {\n lines,\n bounding: ctx.mergeBoundings(boundings),\n renderingLines,\n regions\n };\n });\n }\n return { lines: [], renderingLines: [] };\n }\n const blockReferenceModel = {\n type: "block reference",\n ...ctx.variableValuesModel,\n move(content, offset) {\n content.x += offset.x;\n content.y += offset.y;\n },\n rotate(content, center, angle, contents) {\n const block = ctx.getReference(content.refId, contents, isBlockContent);\n if (block) {\n const p = ctx.rotatePositionByCenter({ 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 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 const block = ctx.getReference(content.refId, contents, isBlockContent);\n if (block) {\n const p = ctx.getSymmetryPoint({ 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 }\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 });\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);\n return renderCtx.target.renderGroup([children], { translate: content, base: block.base, angle: content.angle });\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 let variableNames = [];\n const block = ctx.getReference(content.refId, contents, isBlockContent);\n if (block) {\n variableNames = ctx.getContainerVariableNames(block);\n }\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, 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 ...ctx.getVariableValuesContentPropertyPanel(content, variableNames, update)\n };\n },\n isValid: (c, p) => ctx.validate(c, BlockReferenceContent, p),\n getRefIds(content) {\n return typeof content.refId === "number" ? [content.refId] : void 0;\n },\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.contentIsReferenced(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 contents.forEach((_, i) => {\n if (ctx.isSelected([i], selected)) {\n contents[i] = void 0;\n }\n });\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 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 contents[index] = void 0;\n }\n }\n }\n });\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.contentIsReferenced(content, contents);\n },\n hotkey: "BR",\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/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/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 geometriesCache = new ctx.WeakmapCache();\n const arcGeometriesCache = new ctx.WeakmapCache();\n function getCircleGeometries(content, _, time) {\n const quadrantPoints = [\n { x: content.x - content.r, y: content.y },\n { x: content.x, y: content.y - content.r },\n { x: content.x + content.r, y: content.y },\n { x: content.x, y: content.y + content.r }\n ];\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({ ...content, x, y, r, startAngle: 0, endAngle: 360 }) };\n }\n return geometriesCache.get(content, () => {\n return { quadrantPoints, ...getArcGeometries({ ...content, startAngle: 0, endAngle: 360 }) };\n });\n }\n function getArcGeometries(content) {\n return arcGeometriesCache.get(content, () => {\n var _a;\n const points = ctx.arcToPolyline(content, (_a = content.angleDelta) != null ? _a : ctx.defaultAngleDelta);\n const startAngle = ctx.angleToRadian(content.startAngle);\n const endAngle = ctx.angleToRadian(content.endAngle);\n const middleAngle = (startAngle + endAngle) / 2;\n const geometries = {\n lines: [{ type: "arc", curve: content }],\n points,\n start: {\n x: content.x + content.r * Math.cos(startAngle),\n y: content.y + content.r * Math.sin(startAngle)\n },\n end: {\n x: content.x + content.r * Math.cos(endAngle),\n y: content.y + content.r * Math.sin(endAngle)\n },\n middle: {\n x: content.x + content.r * Math.cos(middleAngle),\n y: content.y + content.r * Math.sin(middleAngle)\n },\n bounding: ctx.getPointsBounding(points),\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 content.x += offset.x;\n content.y += offset.y;\n },\n rotate(content, center, angle) {\n const p = ctx.rotatePositionByCenter(content, center, -angle);\n content.x = p.x;\n content.y = p.y;\n },\n mirror(content, line) {\n const p = ctx.getSymmetryPoint(content, line);\n content.x = p.x;\n content.y = p.y;\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, { getFillColor, getStrokeColor, target, transformStrokeWidth, getFillPattern, contents, clip, time }) {\n var _a;\n const strokeStyleContent = ctx.getStrokeStyleContent(content, contents);\n const fillStyleContent = ctx.getFillStyleContent(content, contents);\n const options = {\n fillColor: getFillColor(fillStyleContent),\n strokeColor: getStrokeColor(strokeStyleContent),\n strokeWidth: transformStrokeWidth((_a = strokeStyleContent.strokeWidth) != null ? _a : ctx.getDefaultStrokeWidth(content)),\n fillPattern: getFillPattern(fillStyleContent)\n };\n if (strokeStyleContent.dashArray) {\n const { points } = getCircleGeometries(content, contents, time);\n return target.renderPolyline(points, { ...options, dashArray: strokeStyleContent.dashArray, clip });\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, clip });\n },\n getOperatorRenderPosition(content) {\n return content;\n },\n getEditPoints(content) {\n return ctx.getEditPointsFromCache(content, () => {\n const x = content.x;\n const y = content.y;\n const { quadrantPoints } = getCircleGeometries(content);\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) {\n const { quadrantPoints } = getCircleGeometries(content);\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, 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: ctx.getStrokeAndFillRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n isPointIn: (content, point) => ctx.getTwoPointsDistance(content, point) < content.r,\n getParam: (content, point) => ctx.getCircleRadian(point, content),\n getPoint: (content, param) => ctx.getCirclePointAtRadian(content, param),\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 content.x += offset.x;\n content.y += offset.y;\n },\n rotate(content, center, angle) {\n const p = ctx.rotatePositionByCenter(content, center, -angle);\n content.x = p.x;\n content.y = p.y;\n content.startAngle += angle;\n content.endAngle += angle;\n },\n mirror(content, line, angle) {\n const p = ctx.getSymmetryPoint(content, line);\n content.x = p.x;\n content.y = p.y;\n const startAngle = 2 * angle - content.endAngle;\n const endAngle = 2 * angle - content.startAngle;\n content.startAngle = startAngle;\n content.endAngle = endAngle;\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.equals(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.equals(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 render(content, { getFillColor, getStrokeColor, target, transformStrokeWidth, getFillPattern, contents }) {\n var _a;\n const strokeStyleContent = ctx.getStrokeStyleContent(content, contents);\n const fillStyleContent = ctx.getFillStyleContent(content, contents);\n const options = {\n fillColor: getFillColor(fillStyleContent),\n strokeColor: getStrokeColor(strokeStyleContent),\n strokeWidth: transformStrokeWidth((_a = strokeStyleContent.strokeWidth) != null ? _a : ctx.getDefaultStrokeWidth(content)),\n fillPattern: getFillPattern(fillStyleContent)\n };\n if (strokeStyleContent.dashArray) {\n const { points } = getCircleGeometries(content);\n return target.renderPolyline(points, { ...options, dashArray: strokeStyleContent.dashArray });\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 }) {\n const { points } = getArcGeometries({ ...content, startAngle: content.endAngle, endAngle: content.startAngle + 360 });\n return target.renderPolyline(points, { strokeColor: color, dashArray: [4], strokeWidth });\n },\n getOperatorRenderPosition(content) {\n const { points } = getArcGeometries(content);\n return points[0];\n },\n getEditPoints(content) {\n return ctx.getEditPointsFromCache(content, () => {\n const { start, end, middle } = getArcGeometries(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: 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) {\n return ctx.getSnapPointsFromCache(content, () => {\n const { start, end, middle } = getArcGeometries(content);\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 (isCircleContent(c)) {\n c.x = p.x, 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: ctx.getStrokeAndFillRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n getStartPoint: (content) => ctx.getArcPointAtAngle(content, content.startAngle),\n getEndPoint: (content) => ctx.getArcPointAtAngle(content, content.endAngle),\n getParam: (content, point) => ctx.getCircleRadian(point, content),\n getPoint: (content, param) => ctx.getCirclePointAtRadian(content, param),\n getArea: (content) => {\n const radian = ctx.angleToRadian(content.endAngle - content.startAngle);\n return content.r ** 2 * (radian - Math.sin(radian)) / 2;\n }\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/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({ repeatedly: true }),\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 };\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 isArcContent(content) {\n return content.type === "arc";\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 getGeometries = (content) => {\n return ctx.getGeometriesFromCache(content, () => {\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);\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 explode: ctx.getContainerExplode,\n mirror: ctx.getContainerMirror,\n render(content, renderCtx) {\n var _a;\n const geometries = getGeometries(content);\n const strokeStyleContent = ctx.getStrokeStyleContent(content, renderCtx.contents);\n const fillStyleContent = ctx.getFillStyleContent(content, renderCtx.contents);\n const options = {\n ...renderCtx,\n fillColor: renderCtx.getFillColor(fillStyleContent),\n fillPattern: renderCtx.getFillPattern(fillStyleContent),\n strokeColor: renderCtx.getStrokeColor(strokeStyleContent),\n strokeWidth: renderCtx.transformStrokeWidth((_a = strokeStyleContent.strokeWidth) != null ? _a : ctx.getDefaultStrokeWidth(content)),\n dashArray: strokeStyleContent.dashArray\n };\n return renderCtx.target.renderGroup(geometries.renderingLines.map((line) => {\n return renderCtx.target.renderPolyline(line, options);\n }));\n },\n renderIfSelected: ctx.getContainerRenderIfSelected,\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: ctx.getStrokeAndFillRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds\n };\n}\nfunction getCommand(ctx) {\n function contentSelectable(content, contents) {\n return !ctx.contentIsReferenced(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 for (let i = contents.length; i >= 0; i--) {\n if (ctx.isSelected([i], selected)) {\n contents[i] = void 0;\n }\n }\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 function getGeometriesFromCache(content) {\n return ctx.getGeometriesFromCache(content, () => {\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 content.x += offset.x;\n content.y += offset.y;\n },\n render(content, { target, getStrokeColor, transformStrokeWidth, contents }) {\n var _a;\n const strokeStyleContent = ctx.getStrokeStyleContent(content, contents);\n const strokeColor = getStrokeColor(strokeStyleContent);\n const strokeWidth = transformStrokeWidth((_a = strokeStyleContent.strokeWidth) != null ? _a : ctx.getDefaultStrokeWidth(content));\n const { regions, renderingLines } = getGeometriesFromCache(content);\n const children = [];\n for (const line of renderingLines) {\n children.push(target.renderPolyline(line, { strokeColor, strokeWidth }));\n }\n if (regions) {\n for (let i = 0; i < regions.length; i++) {\n children.push(target.renderPolyline(regions[i].points, { strokeWidth: 0, fillColor: strokeColor }));\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, 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: ctx.getStrokeRefIds,\n updateRefId: ctx.updateStrokeRefIds\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 = /* @__PURE__ */ new Set();\n contents.forEach((content, index) => {\n if (content && ctx.isSelected([index], selected)) {\n for (const id of iterateRefContents(index, contents, ctx)) {\n ids.add(id);\n }\n if (type === "cut" && !ctx.contentIsReferenced(content, contents)) {\n contents[index] = void 0;\n }\n }\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}\nfunction* iterateRefContents(id, contents, ctx) {\n var _a, _b;\n yield id;\n const content = contents[id];\n if (content) {\n const refIds = (_b = (_a = ctx.getContentModel(content)) == null ? void 0 : _a.getRefIds) == null ? void 0 : _b.call(_a, content);\n if (refIds) {\n for (const refId of refIds) {\n yield* iterateRefContents(refId, contents, ctx);\n }\n }\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/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/create-tangent-tangent-radius-circle.plugin.tsx\nfunction getCommand(ctx) {\n function getTangentTangentRadiusCircles(content1, content2, radius) {\n const result = [];\n const content1IsCircle = isCircleContent(content1) || isArcContent(content1);\n const content2IsCircle = isCircleContent(content2) || isArcContent(content2);\n if (content1IsCircle && content2IsCircle) {\n result.push(...ctx.getCirclesTangentTo2Circles(content1, content2, radius).map((c) => ({ ...c, r: radius })));\n } else if (content1IsCircle && isLineContent(content2)) {\n result.push(...ctx.getCirclesTangentToLineAndCircle(content2.points[0], content2.points[1], content1, radius).map((c) => ({ ...c, r: radius })));\n } else if (content2IsCircle && isLineContent(content1)) {\n result.push(...ctx.getCirclesTangentToLineAndCircle(content1.points[0], content1.points[1], content2, radius).map((c) => ({ ...c, r: radius })));\n } else if (isLineContent(content1) && isLineContent(content2)) {\n result.push(...ctx.getCirclesTangentTo2Lines(content1.points[0], content1.points[1], content2.points[0], content2.points[1], radius).map((c) => ({ ...c, r: radius })));\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: "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 return {\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: (c) => isCircleContent(c) || isArcContent(c) || isLineContent(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 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 contents[index] = void 0;\n }\n });\n },\n contentSelectable(content, contents) {\n return !ctx.contentIsReferenced(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 geometriesCache = new ctx.WeakmapCache();\n function getGeometries(content) {\n return geometriesCache.get(content, () => {\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 content.x += offset.x;\n content.y += offset.y;\n },\n explode(content) {\n const { lines } = getGeometries(content);\n return lines.map((line) => ({ type: "line", points: line }));\n },\n offset(content, point, distance) {\n var _a;\n if (!distance) {\n distance = Math.min(...getGeometries(content).lines.map((line) => ctx.getPointAndGeometryLineMinimumDistance(point, line)));\n }\n distance *= ((_a = this.isPointIn) == null ? void 0 : _a.call(this, content, point)) ? -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, { getFillColor, getStrokeColor, target, transformStrokeWidth, getFillPattern, contents, clip }) {\n var _a;\n const strokeStyleContent = ctx.getStrokeStyleContent(content, contents);\n const fillStyleContent = ctx.getFillStyleContent(content, contents);\n const options = {\n fillColor: getFillColor(fillStyleContent),\n strokeColor: getStrokeColor(strokeStyleContent),\n strokeWidth: transformStrokeWidth((_a = strokeStyleContent.strokeWidth) != null ? _a : ctx.getDefaultStrokeWidth(content)),\n fillPattern: getFillPattern(fillStyleContent),\n clip\n };\n const { points } = getGeometries(content);\n return target.renderPolygon(points, { ...options, dashArray: strokeStyleContent.dashArray });\n },\n getOperatorRenderPosition(content) {\n const { points } = getGeometries(content);\n return points[0];\n },\n getEditPoints(content) {\n return ctx.getEditPointsFromCache(content, () => {\n const { points } = getGeometries(content);\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) {\n return ctx.getSnapPointsFromCache(content, () => {\n const { points, lines } = getGeometries(content);\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, 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: ctx.getStrokeAndFillRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n isPointIn: (content, point) => ctx.pointInPolygon(point, getGeometries(content).points),\n getParam: (content, point) => ctx.getLinesParamAtPoint(point, getGeometries(content).lines),\n getPoint: (content, param) => ctx.getLinesPointAtParam(param, getGeometries(content).lines)\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/edit-container.plugin.tsx\nfunction getCommand(ctx) {\n function contentSelectable(c) {\n return 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 geometriesCache = new ctx.WeakmapCache();\n const ellipseArcGeometriesCache = new ctx.WeakmapCache();\n function getEllipseGeometries(content) {\n return geometriesCache.get(content, () => {\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 return {\n lines: [{\n type: "ellipse arc",\n curve: {\n ...content,\n startAngle: 0,\n endAngle: 360\n }\n }],\n points,\n center,\n left,\n right,\n top,\n bottom,\n bounding: ctx.getPointsBounding(points),\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) {\n return ellipseArcGeometriesCache.get(content, () => {\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 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 start: ctx.getEllipsePointAtRadian(content, startRadian),\n end: ctx.getEllipsePointAtRadian(content, endRadian),\n middle: ctx.getEllipsePointAtRadian(content, middleRadian),\n bounding: ctx.getPointsBounding(points),\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 content.cx += offset.x;\n content.cy += offset.y;\n },\n rotate(content, center, angle) {\n var _a;\n const p = ctx.rotatePositionByCenter(ctx.getEllipseCenter(content), center, -angle);\n content.cx = p.x;\n content.cy = p.y;\n content.angle = ((_a = content.angle) != null ? _a : 0) + angle;\n },\n mirror(content, line, angle) {\n var _a;\n const p = ctx.getSymmetryPoint(ctx.getEllipseCenter(content), line);\n content.cx = p.x;\n content.cy = p.y;\n content.angle = 2 * angle - ((_a = content.angle) != null ? _a : 0);\n },\n offset(content, point, distance) {\n if (!distance) {\n distance = Math.min(...getEllipseGeometries(content).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, { getFillColor, getStrokeColor, target, transformStrokeWidth, getFillPattern, contents, clip }) {\n var _a;\n const strokeStyleContent = ctx.getStrokeStyleContent(content, contents);\n const fillStyleContent = ctx.getFillStyleContent(content, contents);\n const options = {\n fillColor: getFillColor(fillStyleContent),\n strokeColor: getStrokeColor(strokeStyleContent),\n strokeWidth: transformStrokeWidth((_a = strokeStyleContent.strokeWidth) != null ? _a : ctx.getDefaultStrokeWidth(content)),\n fillPattern: getFillPattern(fillStyleContent),\n clip\n };\n if (strokeStyleContent.dashArray) {\n const { points } = getEllipseGeometries(content);\n return target.renderPolygon(points, { ...options, dashArray: strokeStyleContent.dashArray });\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) {\n return ctx.getEditPointsFromCache(content, () => {\n var _a;\n const { center, left, right, top, bottom } = getEllipseGeometries(content);\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) {\n const { center, left, right, top, bottom } = getEllipseGeometries(content);\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 ]);\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, 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: ctx.getStrokeAndFillRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n isPointIn: (content, point) => ctx.pointInPolygon(point, getEllipseGeometries(content).points),\n getParam: (content, point) => ctx.getEllipseAngle(point, content),\n getPoint: (content, param) => ctx.getEllipsePointAtRadian(content, ctx.angleToRadian(param)),\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 mirror: ellipseModel.mirror,\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.equals(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.equals(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) {\n if (!distance) {\n distance = Math.min(...getEllipseArcGeometries(content).lines.map((line) => ctx.getPointAndGeometryLineMinimumDistance(point, line)));\n }\n return ctx.getParallelEllipseArcsByDistance(content, distance)[ctx.pointSideToIndex(ctx.getPointSideOfEllipseArc(point, content))];\n },\n render(content, { getFillColor, getStrokeColor, target, transformStrokeWidth, getFillPattern, contents }) {\n var _a;\n const strokeStyleContent = ctx.getStrokeStyleContent(content, contents);\n const fillStyleContent = ctx.getFillStyleContent(content, contents);\n const options = {\n fillColor: getFillColor(fillStyleContent),\n strokeColor: getStrokeColor(strokeStyleContent),\n strokeWidth: transformStrokeWidth((_a = strokeStyleContent.strokeWidth) != null ? _a : ctx.getDefaultStrokeWidth(content)),\n fillPattern: getFillPattern(fillStyleContent),\n dashArray: strokeStyleContent.dashArray\n };\n const { points } = getEllipseArcGeometries(content);\n return target.renderPolyline(points, options);\n },\n renderIfSelected(content, { color, target, strokeWidth }) {\n const { points } = getEllipseArcGeometries({ ...content, startAngle: content.endAngle, endAngle: content.startAngle + 360 });\n return target.renderPolyline(points, { strokeColor: color, dashArray: [4], strokeWidth });\n },\n getOperatorRenderPosition(content) {\n const { points } = getEllipseArcGeometries(content);\n return points[0];\n },\n getEditPoints(content) {\n return ctx.getEditPointsFromCache(content, () => {\n var _a;\n const { center, start, end } = getEllipseArcGeometries(content);\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) {\n return ctx.getSnapPointsFromCache(content, () => {\n const { center, start, end, middle } = getEllipseArcGeometries(content);\n return [\n { ...center, type: "center" },\n { ...start, type: "endpoint" },\n { ...end, type: "endpoint" },\n { ...middle, type: "midpoint" }\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, 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: ctx.getStrokeAndFillRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n getStartPoint: (content) => ctx.getEllipseArcPointAtAngle(content, content.startAngle),\n getEndPoint: (content) => ctx.getEllipseArcPointAtAngle(content, content.endAngle),\n getParam: (content, point) => ctx.getEllipseAngle(point, content),\n getPoint: (content, param) => ctx.getEllipsePointAtRadian(content, ctx.angleToRadian(param)),\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 }\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/expression/math.ts\nvar math = [\n {\n "name": "Math",\n "members": [\n {\n "name": "E",\n "comment": "The mathematical constant e. This is Euler\'s number, the base of natural logarithms."\n },\n {\n "name": "LN10",\n "comment": "The natural logarithm of 10."\n },\n {\n "name": "LN2",\n "comment": "The natural logarithm of 2."\n },\n {\n "name": "LOG2E",\n "comment": "The base-2 logarithm of e."\n },\n {\n "name": "LOG10E",\n "comment": "The base-10 logarithm of e."\n },\n {\n "name": "PI",\n "comment": "Pi. This is the ratio of the circumference of a circle to its diameter."\n },\n {\n "name": "SQRT1_2",\n "comment": "The square root of 0.5, or, equivalently, one divided by the square root of 2."\n },\n {\n "name": "SQRT2",\n "comment": "The square root of 2."\n },\n {\n "name": "abs",\n "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.",\n "parameters": [\n {\n "name": "x",\n "comment": "A numeric expression for which the absolute value is needed.",\n "optional": false\n }\n ]\n },\n {\n "name": "acos",\n "comment": "Returns the arc cosine (or inverse cosine) of a number.",\n "parameters": [\n {\n "name": "x",\n "comment": "A numeric expression.",\n "optional": false\n }\n ]\n },\n {\n "name": "asin",\n "comment": "Returns the arcsine of a number.",\n "parameters": [\n {\n "name": "x",\n "comment": "A numeric expression.",\n "optional": false\n }\n ]\n },\n {\n "name": "atan",\n "comment": "Returns the arctangent of a number.",\n "parameters": [\n {\n "name": "x",\n "comment": "A numeric expression for which the arctangent is needed.",\n "optional": false\n }\n ]\n },\n {\n "name": "atan2",\n "comment": "Returns the angle (in radians) from the X axis to a point.",\n "parameters": [\n {\n "name": "y",\n "comment": "A numeric expression representing the cartesian y-coordinate.",\n "optional": false\n },\n {\n "name": "x",\n "comment": "A numeric expression representing the cartesian x-coordinate.",\n "optional": false\n }\n ]\n },\n {\n "name": "ceil",\n "comment": "Returns the smallest integer greater than or equal to its numeric argument.",\n "parameters": [\n {\n "name": "x",\n "comment": "A numeric expression.",\n "optional": false\n }\n ]\n },\n {\n "name": "cos",\n "comment": "Returns the cosine of a number.",\n "parameters": [\n {\n "name": "x",\n "comment": "A numeric expression that contains an angle measured in radians.",\n "optional": false\n }\n ]\n },\n {\n "name": "exp",\n "comment": "Returns e (the base of natural logarithms) raised to a power.",\n "parameters": [\n {\n "name": "x",\n "comment": "A numeric expression representing the power of e.",\n "optional": false\n }\n ]\n },\n {\n "name": "floor",\n "comment": "Returns the greatest integer less than or equal to its numeric argument.",\n "parameters": [\n {\n "name": "x",\n "comment": "A numeric expression.",\n "optional": false\n }\n ]\n },\n {\n "name": "log",\n "comment": "Returns the natural logarithm (base e) of a number.",\n "parameters": [\n {\n "name": "x",\n "comment": "A numeric expression.",\n "optional": false\n }\n ]\n },\n {\n "name": "max",\n "comment": "Returns the larger of a set of supplied numeric expressions.",\n "parameters": [\n {\n "name": "values",\n "comment": "Numeric expressions to be evaluated.",\n "optional": false\n }\n ]\n },\n {\n "name": "min",\n "comment": "Returns the smaller of a set of supplied numeric expressions.",\n "parameters": [\n {\n "name": "values",\n "comment": "Numeric expressions to be evaluated.",\n "optional": false\n }\n ]\n },\n {\n "name": "pow",\n "comment": "Returns the value of a base expression taken to a specified power.",\n "parameters": [\n {\n "name": "x",\n "comment": "The base value of the expression.",\n "optional": false\n },\n {\n "name": "y",\n "comment": "The exponent value of the expression.",\n "optional": false\n }\n ]\n },\n {\n "name": "random",\n "comment": "Returns a pseudorandom number between 0 and 1.",\n "parameters": []\n },\n {\n "name": "round",\n "comment": "Returns a supplied numeric expression rounded to the nearest integer.",\n "parameters": [\n {\n "name": "x",\n "comment": "The value to be rounded to the nearest integer.",\n "optional": false\n }\n ]\n },\n {\n "name": "sin",\n "comment": "Returns the sine of a number.",\n "parameters": [\n {\n "name": "x",\n "comment": "A numeric expression that contains an angle measured in radians.",\n "optional": false\n }\n ]\n },\n {\n "name": "sqrt",\n "comment": "Returns the square root of a number.",\n "parameters": [\n {\n "name": "x",\n "comment": "A numeric expression.",\n "optional": false\n }\n ]\n },\n {\n "name": "tan",\n "comment": "Returns the tangent of a number.",\n "parameters": [\n {\n "name": "x",\n "comment": "A numeric expression that contains an angle measured in radians.",\n "optional": false\n }\n ]\n },\n {\n "name": "clz32",\n "comment": "Returns the number of leading zero bits in the 32-bit binary representation of a number.",\n "parameters": [\n {\n "name": "x",\n "comment": "A numeric expression.",\n "optional": false\n }\n ]\n },\n {\n "name": "imul",\n "comment": "Returns the result of 32-bit multiplication of two numbers.",\n "parameters": [\n {\n "name": "x",\n "comment": "First number",\n "optional": false\n },\n {\n "name": "y",\n "comment": "Second number",\n "optional": false\n }\n ]\n },\n {\n "name": "sign",\n "comment": "Returns the sign of the x, indicating whether x is positive, negative or zero.",\n "parameters": [\n {\n "name": "x",\n "comment": "The numeric expression to test",\n "optional": false\n }\n ]\n },\n {\n "name": "log10",\n "comment": "Returns the base 10 logarithm of a number.",\n "parameters": [\n {\n "name": "x",\n "comment": "A numeric expression.",\n "optional": false\n }\n ]\n },\n {\n "name": "log2",\n "comment": "Returns the base 2 logarithm of a number.",\n "parameters": [\n {\n "name": "x",\n "comment": "A numeric expression.",\n "optional": false\n }\n ]\n },\n {\n "name": "log1p",\n "comment": "Returns the natural logarithm of 1 + x.",\n "parameters": [\n {\n "name": "x",\n "comment": "A numeric expression.",\n "optional": false\n }\n ]\n },\n {\n "name": "expm1",\n "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).",\n "parameters": [\n {\n "name": "x",\n "comment": "A numeric expression.",\n "optional": false\n }\n ]\n },\n {\n "name": "cosh",\n "comment": "Returns the hyperbolic cosine of a number.",\n "parameters": [\n {\n "name": "x",\n "comment": "A numeric expression that contains an angle measured in radians.",\n "optional": false\n }\n ]\n },\n {\n "name": "sinh",\n "comment": "Returns the hyperbolic sine of a number.",\n "parameters": [\n {\n "name": "x",\n "comment": "A numeric expression that contains an angle measured in radians.",\n "optional": false\n }\n ]\n },\n {\n "name": "tanh",\n "comment": "Returns the hyperbolic tangent of a number.",\n "parameters": [\n {\n "name": "x",\n "comment": "A numeric expression that contains an angle measured in radians.",\n "optional": false\n }\n ]\n },\n {\n "name": "acosh",\n "comment": "Returns the inverse hyperbolic cosine of a number.",\n "parameters": [\n {\n "name": "x",\n "comment": "A numeric expression that contains an angle measured in radians.",\n "optional": false\n }\n ]\n },\n {\n "name": "asinh",\n "comment": "Returns the inverse hyperbolic sine of a number.",\n "parameters": [\n {\n "name": "x",\n "comment": "A numeric expression that contains an angle measured in radians.",\n "optional": false\n }\n ]\n },\n {\n "name": "atanh",\n "comment": "Returns the inverse hyperbolic tangent of a number.",\n "parameters": [\n {\n "name": "x",\n "comment": "A numeric expression that contains an angle measured in radians.",\n "optional": false\n }\n ]\n },\n {\n "name": "hypot",\n "comment": "Returns the square root of the sum of squares of its arguments.",\n "parameters": [\n {\n "name": "values",\n "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 \\u22120, the result is +0.",\n "optional": false\n }\n ]\n },\n {\n "name": "trunc",\n "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.",\n "parameters": [\n {\n "name": "x",\n "comment": "A numeric expression.",\n "optional": false\n }\n ]\n },\n {\n "name": "fround",\n "comment": "Returns the nearest single precision float representation of a number.",\n "parameters": [\n {\n "name": "x",\n "comment": "A numeric expression.",\n "optional": false\n }\n ]\n },\n {\n "name": "cbrt",\n "comment": "Returns an implementation-dependent approximation to the cube root of number.",\n "parameters": [\n {\n "name": "x",\n "comment": "A numeric expression.",\n "optional": false\n }\n ]\n }\n ]\n }\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.or(ctx.number, ctx.Content),\n dependentVariable: ctx.or("x", "y"),\n expression: ctx.string\n });\n const equationCache = new ctx.WeakmapCache2();\n function getGeometriesFromCache(content, contents) {\n const axis = ctx.getReference(content.axisId, contents, isCoordinateAxisContent);\n if (axis) {\n return equationCache.get(content, axis, () => {\n var _a;\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 }\n return { lines: [], points: [], renderingLines: [] };\n }\n const React = ctx.React;\n return {\n type: "equation",\n ...ctx.strokeModel,\n ...ctx.segmentCountModel,\n render(content, { target, getStrokeColor, transformStrokeWidth, contents }) {\n var _a;\n const { points } = getGeometriesFromCache(content, contents);\n const strokeStyleContent = ctx.getStrokeStyleContent(content, contents);\n const options = {\n strokeColor: getStrokeColor(strokeStyleContent),\n strokeWidth: transformStrokeWidth((_a = strokeStyleContent.strokeWidth) != null ? _a : ctx.getDefaultStrokeWidth(content)),\n dashArray: strokeStyleContent.dashArray\n };\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: 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: (content) => [...ctx.getStrokeRefIds(content), ...typeof content.axisId === "number" ? [content.axisId] : []],\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 };\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 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 contents[index] = void 0;\n }\n }\n });\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.contentIsReferenced(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, 1));\n let jsx = "";\n for (let j = 0; j < svg.length; j++) {\n const c = svg[j];\n if (c === "-") {\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/fill-style.plugin.tsx\nfunction getModel(ctx) {\n function getGeometriesFromCache(content) {\n return ctx.getGeometriesFromCache(content, () => {\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 content.x += offset.x;\n content.y += offset.y;\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 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, 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: "1", 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(#1)", 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/line-polyline.plugin.tsx\nfunction isLineContent(content) {\n return content.type === "line";\n}\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/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) && isLineContent(content2)) {\n circles.push(...ctx.getCirclesTangentTo2Lines(content1.points[0], content1.points[1], content2.points[0], content2.points[1], radius).map((c) => ({\n center: c,\n foot1: ctx.getPerpendicularPoint(c, ctx.twoPointLineToGeneralFormLine(content1.points[0], content1.points[1])),\n foot2: ctx.getPerpendicularPoint(c, ctx.twoPointLineToGeneralFormLine(content2.points[0], content2.points[1]))\n })));\n } else if ((isCircleContent(content1) || isArcContent(content1)) && (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(content1) && (isCircleContent(content2) || isArcContent(content2))) {\n circles.push(...ctx.getCirclesTangentToLineAndCircle(content1.points[0], content1.points[1], content2, radius).map((c) => ({\n center: c,\n foot1: ctx.getPerpendicularPoint(c, ctx.twoPointLineToGeneralFormLine(content1.points[0], content1.points[1])),\n foot2: ctx.getTwoCircleIntersectionPoints({ ...c, r: radius }, content2)[0]\n })));\n } else if (isLineContent(content2) && (isCircleContent(content1) || isArcContent(content1))) {\n circles.push(...ctx.getCirclesTangentToLineAndCircle(content2.points[0], content2.points[1], content1, radius).map((c) => ({\n center: c,\n foot1: ctx.getPerpendicularPoint(c, ctx.twoPointLineToGeneralFormLine(content2.points[0], content2.points[1])),\n foot2: ctx.getTwoCircleIntersectionPoints({ ...c, r: radius }, content1)[0]\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/group.plugin.tsx\nfunction getModel(ctx) {\n const GroupContent = ctx.and(ctx.BaseContent("group"), ctx.ContainerFields);\n return {\n type: "group",\n ...ctx.containerModel,\n move: ctx.getContainerMove,\n rotate: ctx.getContainerRotate,\n explode: ctx.getContainerExplode,\n mirror: ctx.getContainerMirror,\n render: ctx.getContainerRender,\n renderIfSelected: ctx.getContainerRenderIfSelected,\n getSnapPoints: ctx.getContainerSnapPoints,\n getGeometries: ctx.getContainerGeometries,\n propertyPanel: (content, update) => ctx.getVariableValuesContentPropertyPanel(content, ctx.getContainerVariableNames(content), update),\n isValid: (c, p) => ctx.validate(c, GroupContent, p)\n };\n}\nfunction getCommand(ctx) {\n function contentSelectable(content, contents) {\n return !ctx.contentIsReferenced(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 for (let i = contents.length; i >= 0; i--) {\n if (ctx.isSelected([i], selected)) {\n contents[i] = void 0;\n }\n }\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/image.plugin.tsx\nfunction getModel(ctx) {\n const ImageContent = ctx.and(ctx.BaseContent("image"), ctx.Image);\n function getImageGeometries(content) {\n return ctx.getGeometriesFromCache(content, () => {\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 move(content, offset) {\n content.x += offset.x;\n content.y += offset.y;\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 (!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 ]\n };\n });\n },\n render(content, { target }) {\n return target.renderImage(content.url, content.x, content.y, content.width, content.height);\n },\n renderIfSelected(content, { color, target, strokeWidth }) {\n return target.renderRect(content.x, content.y, content.width, content.height, { strokeColor: color, dashArray: [4], strokeWidth });\n },\n getOperatorRenderPosition(content) {\n return content;\n },\n getGeometries: getImageGeometries,\n propertyPanel(content, update, _, { acquirePoint }) {\n return {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isImageContent(c)) {\n c.x = p.x, 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 };\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/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 geometriesCache = new ctx.WeakmapCache();\n function getPolylineGeometries(content) {\n return geometriesCache.get(content, () => {\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 point.x += offset.x;\n point.y += offset.y;\n }\n },\n rotate(content, center, angle) {\n content.points = content.points.map((p) => ctx.rotatePositionByCenter(p, center, -angle));\n },\n mirror(content, line) {\n content.points = content.points.map((p) => ctx.getSymmetryPoint(p, line));\n },\n break(content, intersectionPoints) {\n const { lines } = getPolylineGeometries(content);\n return ctx.breakPolyline(lines, intersectionPoints);\n },\n offset(content, point, distance) {\n const [p1, p2] = content.points;\n const line = ctx.twoPointLineToGeneralFormLine(p1, p2);\n if (!distance) {\n distance = Math.min(...getPolylineGeometries(content).lines.map((line2) => ctx.getPointAndGeometryLineMinimumDistance(point, line2)));\n }\n const newLine = ctx.getParallelLinesByDistance(line, distance)[ctx.pointSideToIndex(ctx.getPointSideOfLine(point, line))];\n const r1 = ctx.getTwoGeneralFormLinesIntersectionPoint(newLine, ctx.getPerpendicular(p1, newLine));\n const r2 = ctx.getTwoGeneralFormLinesIntersectionPoint(newLine, ctx.getPerpendicular(p2, newLine));\n if (!r1 || !r2)\n return;\n return ctx.produce(content, (d) => {\n d.points = [r1, r2];\n });\n },\n render(content, { getStrokeColor, target, transformStrokeWidth, contents }) {\n var _a;\n const strokeStyleContent = ctx.getStrokeStyleContent(content, contents);\n const options = {\n strokeColor: getStrokeColor(strokeStyleContent),\n strokeWidth: transformStrokeWidth((_a = strokeStyleContent.strokeWidth) != null ? _a : ctx.getDefaultStrokeWidth(content)),\n dashArray: strokeStyleContent.dashArray\n };\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) {\n return ctx.getSnapPointsFromCache(content, () => {\n const { points, lines } = getPolylineGeometries(content);\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, 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: ctx.getStrokeAndFillRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n getStartPoint: (content) => content.points[0],\n getEndPoint: (content) => content.points[content.points.length - 1],\n getParam: (content, point) => ctx.getLinesParamAtPoint(point, getPolylineGeometries(content).lines),\n getPoint: (content, param) => ctx.getLinesPointAtParam(param, getPolylineGeometries(content).lines)\n };\n return [\n lineModel,\n {\n ...lineModel,\n type: "polyline",\n ...ctx.fillModel,\n explode(content) {\n const { lines } = getPolylineGeometries(content);\n return lines.map((line) => ({ type: "line", points: line }));\n },\n offset(content, point, distance) {\n var _a;\n if (!distance) {\n distance = Math.min(...getPolylineGeometries(content).lines.map((line) => ctx.getPointAndGeometryLineMinimumDistance(point, line)));\n }\n if (content.points.length === 2) {\n return (_a = lineModel.offset) == null ? void 0 : _a.call(lineModel, content, point, distance);\n }\n const first = content.points[0];\n const last = content.points[content.points.length - 1];\n const closed = ctx.isSamePoint(first, last);\n const { lines } = getPolylineGeometries(content);\n const generalFormLines = lines.map((line) => ctx.twoPointLineToGeneralFormLine(...line));\n const index = ctx.getLinesOffsetDirection(point, lines);\n const parallelLines = generalFormLines.map((line) => ctx.getParallelLinesByDistance(line, distance)[index]);\n const points = [];\n for (let i = 0; i < parallelLines.length + 1; i++) {\n let newLine;\n let parallelLine = parallelLines[i];\n if (i === 0) {\n if (closed) {\n newLine = parallelLines[parallelLines.length - 1];\n } else {\n newLine = ctx.getPerpendicular(first, parallelLine);\n }\n } else if (i === parallelLines.length) {\n parallelLine = parallelLines[parallelLines.length - 1];\n if (closed) {\n newLine = parallelLines[0];\n } else {\n newLine = ctx.getPerpendicular(last, parallelLine);\n }\n } else {\n newLine = parallelLines[i - 1];\n }\n const p = ctx.getTwoGeneralFormLinesIntersectionPoint(newLine, parallelLine);\n if (p) {\n points.push(p);\n }\n }\n return ctx.trimOffsetResult(points, point, closed).map((p) => ctx.produce(content, (d) => {\n d.points = p;\n }));\n },\n render(content, { target, transformStrokeWidth, getFillColor, getStrokeColor, getFillPattern, contents }) {\n var _a;\n const strokeStyleContent = ctx.getStrokeStyleContent(content, contents);\n const fillStyleContent = ctx.getFillStyleContent(content, contents);\n const options = {\n fillColor: getFillColor(fillStyleContent),\n strokeColor: getStrokeColor(strokeStyleContent),\n strokeWidth: transformStrokeWidth((_a = strokeStyleContent.strokeWidth) != null ? _a : ctx.getDefaultStrokeWidth(content)),\n fillPattern: getFillPattern(fillStyleContent)\n };\n return target.renderPolyline(content.points, { ...options, dashArray: strokeStyleContent.dashArray });\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, 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("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 linearDimensionCache = new ctx.WeakmapCache3();\n const getLinearDimensionPositions = (content, contents) => {\n var _a, _b;\n const p1 = (_a = ctx.getRefPosition(content.ref1, contents)) != null ? _a : content.p1;\n const p2 = (_b = ctx.getRefPosition(content.ref2, contents)) != null ? _b : content.p2;\n return { p1, p2 };\n };\n function getLinearDimensionGeometriesFromCache(content, contents) {\n const { p1, p2 } = getLinearDimensionPositions(content, contents);\n return linearDimensionCache.get(content, p1, p2, () => {\n var _a, _b;\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 content.p1.x += offset.x;\n content.p1.y += offset.y;\n content.p2.x += offset.x;\n content.p2.y += offset.y;\n content.position.x += offset.x;\n content.position.y += offset.y;\n },\n render(content, { target, getStrokeColor, transformStrokeWidth, contents }) {\n var _a;\n const strokeStyleContent = ctx.getStrokeStyleContent(content, contents);\n const strokeColor = getStrokeColor(strokeStyleContent);\n const strokeWidth = transformStrokeWidth((_a = strokeStyleContent.strokeWidth) != null ? _a : ctx.getDefaultStrokeWidth(content));\n const { regions, lines } = getLinearDimensionGeometriesFromCache(content, contents);\n const children = [];\n for (const line of lines) {\n children.push(target.renderPolyline(line, { strokeColor, strokeWidth, dashArray: strokeStyleContent.dashArray }));\n }\n if (regions) {\n for (let i = 0; i < 2 && i < regions.length; i++) {\n children.push(target.renderPolyline(regions[i].points, { strokeWidth: 0, fillColor: strokeColor }));\n }\n }\n const { textPosition, text, textRotation } = getTextPosition(content, contents);\n children.push(target.renderGroup(\n [\n target.renderText(textPosition.x, textPosition.y, text, strokeColor, content.fontSize, content.fontFamily, { cacheKey: content })\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 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: content.p1.x,\n y: content.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: content.p2.x,\n y: content.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, 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: (content) => [\n ...ctx.getStrokeRefIds(content),\n ...content.ref1 && typeof content.ref1.id === "number" ? [content.ref1.id] : [],\n ...content.ref2 && typeof content.ref2.id === "number" ? [content.ref2.id] : []\n ],\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 };\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 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 ((_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 ((_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, {\n points: [ctx.Position],\n degree: ctx.minimum(1, ctx.integer),\n knots: ctx.optional([ctx.number]),\n weights: ctx.optional([ctx.number])\n });\n const geometriesCache = new ctx.WeakmapCache();\n function getNurbsGeometries(content) {\n return geometriesCache.get(content, () => {\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 points = ctx.getNurbsPoints(content.degree, content.points, content.knots, content.weights, nurbsSegmentCount);\n lines = Array.from(ctx.iteratePolylineLines(points));\n }\n } else {\n points = content.points;\n lines = Array.from(ctx.iteratePolylineLines(points));\n }\n return {\n lines,\n points,\n bounding: ctx.getPointsBounding(points),\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 point.x += offset.x;\n point.y += offset.y;\n }\n },\n rotate(content, center, angle) {\n content.points = content.points.map((p) => ctx.rotatePositionByCenter(p, center, -angle));\n },\n mirror(content, line) {\n content.points = content.points.map((p) => ctx.getSymmetryPoint(p, line));\n },\n render(content, { getFillColor, getStrokeColor, target, transformStrokeWidth, getFillPattern, contents }) {\n var _a;\n const { points } = getNurbsGeometries(content);\n const strokeStyleContent = ctx.getStrokeStyleContent(content, contents);\n const fillStyleContent = ctx.getFillStyleContent(content, contents);\n const options = {\n fillColor: getFillColor(fillStyleContent),\n strokeColor: getStrokeColor(strokeStyleContent),\n strokeWidth: transformStrokeWidth((_a = strokeStyleContent.strokeWidth) != null ? _a : ctx.getDefaultStrokeWidth(content)),\n fillPattern: getFillPattern(fillStyleContent),\n dashArray: strokeStyleContent.dashArray\n };\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, 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: ctx.getStrokeAndFillRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds\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) {\n const model = ctx.getContentModel(content);\n if (model == null ? void 0 : model.offset) {\n const newContent = model.offset(content, p, offset);\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 }) {\n let message = "";\n if (type) {\n message = "input offset or click to end";\n }\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 }\n }\n } : void 0);\n return {\n onStart(p) {\n resetInput();\n onEnd({\n updateContents: (contents, selected) => {\n const target = contents.filter((c, i) => c && ctx.isSelected([i], selected) && contentSelectable(c));\n for (const content of target) {\n if (content) {\n contents.push(...getOffsetResult(content, p, offset));\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);\n if (newContents.length > 0) {\n return {\n newContents\n };\n }\n }\n return {};\n },\n reset: resetInput\n };\n },\n contentSelectable,\n icon\n };\n}\nexport {\n getCommand\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 function getPathGeometriesFromCache(content) {\n return ctx.getGeometriesFromCache(content, () => {\n const lines = ctx.pathCommandsToGeometryLines(content.commands)[0];\n const points = ctx.getGeometryLinesPoints(lines);\n return {\n lines,\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: "path",\n ...ctx.strokeModel,\n ...ctx.fillModel,\n move(content, offset) {\n for (const command of content.commands) {\n if (command.type !== "close") {\n command.to.x += offset.x;\n command.to.y += offset.y;\n }\n if (command.type === "arc") {\n command.from.x += offset.x;\n command.from.y += offset.y;\n } else if (command.type === "bezierCurve") {\n command.cp1.x += offset.x;\n command.cp1.y += offset.y;\n command.cp2.x += offset.x;\n command.cp2.y += offset.y;\n } else if (command.type === "quadraticCurve") {\n command.cp.x += offset.x;\n command.cp.y += offset.y;\n }\n }\n },\n rotate(content, center, angle) {\n for (const command of content.commands) {\n if (command.type !== "close") {\n command.to = ctx.rotatePositionByCenter(command.to, center, -angle);\n }\n if (command.type === "arc") {\n command.from = ctx.rotatePositionByCenter(command.from, center, -angle);\n } else if (command.type === "bezierCurve") {\n command.cp1 = ctx.rotatePositionByCenter(command.cp1, center, -angle);\n command.cp2 = ctx.rotatePositionByCenter(command.cp2, center, -angle);\n } else if (command.type === "quadraticCurve") {\n command.cp = ctx.rotatePositionByCenter(command.cp, center, -angle);\n }\n }\n },\n mirror(content, line) {\n for (const command of content.commands) {\n if (command.type !== "close") {\n command.to = ctx.getSymmetryPoint(command.to, line);\n }\n if (command.type === "arc") {\n command.from = ctx.getSymmetryPoint(command.from, line);\n } else if (command.type === "bezierCurve") {\n command.cp1 = ctx.getSymmetryPoint(command.cp1, line);\n command.cp2 = ctx.getSymmetryPoint(command.cp2, line);\n } else if (command.type === "quadraticCurve") {\n command.cp = ctx.getSymmetryPoint(command.cp, line);\n }\n }\n },\n break(content, intersectionPoints) {\n const lines = getPathGeometriesFromCache(content).lines;\n return ctx.breakGeometryLinesToPathCommands(lines, intersectionPoints);\n },\n offset(content, point, distance) {\n const lines = getPathGeometriesFromCache(content).lines;\n return ctx.getParallelGeometryLinesByDistance(point, lines, distance).map((g) => ({\n ...content,\n commands: ctx.geometryLineToPathCommands(g)\n }));\n },\n render(content, { target, getStrokeColor, getFillColor, transformStrokeWidth, getFillPattern, contents }) {\n var _a;\n const strokeStyleContent = ctx.getStrokeStyleContent(content, contents);\n const fillStyleContent = ctx.getFillStyleContent(content, contents);\n const options = {\n fillColor: getFillColor(fillStyleContent),\n strokeColor: getStrokeColor(strokeStyleContent),\n strokeWidth: transformStrokeWidth((_a = strokeStyleContent.strokeWidth) != null ? _a : ctx.getDefaultStrokeWidth(content)),\n dashArray: strokeStyleContent.dashArray,\n fillPattern: getFillPattern(fillStyleContent)\n };\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 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: ctx.getStrokeAndFillRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n getStartPoint: (content) => {\n const lines = getPathGeometriesFromCache(content).lines;\n return ctx.getGeometryLineStartAndEnd(lines[0]).start;\n },\n getEndPoint: (content) => {\n const lines = getPathGeometriesFromCache(content).lines;\n return ctx.getGeometryLineStartAndEnd(lines[lines.length - 1]).end;\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 function getGeometries(content) {\n return ctx.getGeometriesFromCache(content, () => {\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 point.x += offset.x;\n point.y += offset.y;\n }\n },\n rotate(content, center, angle) {\n content.points = content.points.map((p) => ctx.rotatePositionByCenter(p, center, -angle));\n },\n mirror(content, line) {\n content.points = content.points.map((p) => ctx.getSymmetryPoint(p, line));\n },\n render(content, { target, transformStrokeWidth, getStrokeColor, contents }) {\n var _a;\n const strokeStyleContent = ctx.getStrokeStyleContent(content, contents);\n const options = {\n strokeColor: getStrokeColor(strokeStyleContent),\n strokeWidth: transformStrokeWidth((_a = strokeStyleContent.strokeWidth) != null ? _a : ctx.getDefaultStrokeWidth(content)),\n dashArray: strokeStyleContent.dashArray\n };\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: ctx.getStrokeRefIds,\n updateRefId: ctx.updateStrokeRefIds\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/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 getAllContentsFromCache = (content, contents) => {\n return ctx.allContentsCache.get(content, () => {\n const result = [];\n const bounding = ctx.getContentsBounding(content.contents);\n if (!bounding)\n 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)\n return;\n const model = ctx.getContentModel(c);\n const rotate = model == null ? void 0 : model.rotate;\n if (!rotate)\n return;\n const move = model.move;\n if (!move)\n 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, (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 content.center.x += offset.x;\n content.center.y += offset.y;\n },\n rotate(content, center, angle, contents) {\n content.center = ctx.rotatePositionByCenter(content.center, center, -angle);\n content.contents.forEach((c) => {\n var _a, _b;\n if (!c)\n 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 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) {\n return ctx.getEditPointsFromCache(content, () => {\n const bounding = ctx.getContentsBounding(content.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, 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 };\n}\nfunction isPolarArrayContent(content) {\n return content.type === "polar array";\n}\nfunction getCommand(ctx) {\n function contentSelectable(content, contents) {\n return !ctx.contentIsReferenced(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 }) {\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 const target = contents.filter((c, i) => c && ctx.isSelected([i], selected) && contentSelectable(c, contents));\n const bounding = ctx.getContentsBounding(target);\n if (!bounding)\n 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 for (let i = contents.length; i >= 0; i--) {\n if (ctx.isSelected([i], selected)) {\n contents[i] = void 0;\n }\n }\n contents.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).bounding;\n if (!bounding)\n 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 geometriesCache = new ctx.WeakmapCache();\n function getPolygonGeometries(content) {\n return geometriesCache.get(content, () => {\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 point.x += offset.x;\n point.y += offset.y;\n }\n },\n rotate(content, center, angle) {\n content.points = content.points.map((p) => ctx.rotatePositionByCenter(p, center, -angle));\n },\n mirror(content, line) {\n content.points = content.points.map((p) => ctx.getSymmetryPoint(p, line));\n },\n explode(content) {\n const { lines } = getPolygonGeometries(content);\n return lines.map((line) => ({ type: "line", points: line }));\n },\n break(content, intersectionPoints) {\n const { lines } = getPolygonGeometries(content);\n return ctx.breakPolyline(lines, intersectionPoints);\n },\n offset(content, point, distance) {\n const { lines } = getPolygonGeometries(content);\n if (!distance) {\n distance = Math.min(...lines.map((line) => ctx.getPointAndGeometryLineMinimumDistance(point, line)));\n }\n const generalFormLines = lines.map((line) => ctx.twoPointLineToGeneralFormLine(...line));\n const index = ctx.getLinesOffsetDirection(point, lines);\n const parallelLines = generalFormLines.map((line) => ctx.getParallelLinesByDistance(line, distance)[index]);\n const points = [];\n for (let i = 0; i < parallelLines.length; i++) {\n const previous = parallelLines[i === 0 ? parallelLines.length - 1 : i - 1];\n const p = ctx.getTwoGeneralFormLinesIntersectionPoint(previous, parallelLines[i]);\n if (p) {\n points.push(p);\n }\n }\n return ctx.trimOffsetResult(points, point, true).map((p) => ctx.produce(content, (d) => {\n d.points = p;\n }));\n },\n render(content, { getFillColor, getStrokeColor, target, transformStrokeWidth, getFillPattern, contents, clip }) {\n var _a;\n const strokeStyleContent = ctx.getStrokeStyleContent(content, contents);\n const fillStyleContent = ctx.getFillStyleContent(content, contents);\n const options = {\n fillColor: getFillColor(fillStyleContent),\n strokeColor: getStrokeColor(strokeStyleContent),\n strokeWidth: transformStrokeWidth((_a = strokeStyleContent.strokeWidth) != null ? _a : ctx.getDefaultStrokeWidth(content)),\n fillPattern: getFillPattern(fillStyleContent),\n dashArray: strokeStyleContent.dashArray,\n clip\n };\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) {\n return ctx.getSnapPointsFromCache(content, () => {\n const { points, lines } = getPolygonGeometries(content);\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, 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: ctx.getStrokeAndFillRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n isPointIn: (content, point) => ctx.pointInPolygon(point, content.points),\n getParam: (content, point) => ctx.getLinesParamAtPoint(point, getPolygonGeometries(content).lines),\n getPoint: (content, param) => ctx.getLinesPointAtParam(param, getPolygonGeometries(content).lines)\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 refId: ctx.or(ctx.number, ctx.Content)\n });\n function getRadialDimensionReferenceGeometriesFromCache(content, contents) {\n const target = ctx.getReference(content.refId, contents, contentSelectable);\n if (target) {\n return radialDimensionReferenceLinesCache.get(target, content, () => {\n var _a, _b;\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 }\n return { lines: [], points: [], renderingLines: [] };\n }\n const radialDimensionReferenceLinesCache = new ctx.WeakmapCache2();\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 content.position.x += offset.x;\n content.position.y += offset.y;\n },\n render(content, { target, getStrokeColor, transformStrokeWidth, contents }) {\n var _a;\n const strokeStyleContent = ctx.getStrokeStyleContent(content, contents);\n const strokeColor = getStrokeColor(strokeStyleContent);\n const strokeWidth = transformStrokeWidth((_a = strokeStyleContent.strokeWidth) != null ? _a : ctx.getDefaultStrokeWidth(content));\n const { regions, lines } = getRadialDimensionReferenceGeometriesFromCache(content, contents);\n const children = [];\n for (const line of lines) {\n children.push(target.renderPolyline(line, { strokeColor, strokeWidth, dashArray: strokeStyleContent.dashArray }));\n }\n if (regions && regions.length > 0) {\n children.push(target.renderPolyline(regions[0].points, { strokeWidth: 0, fillColor: strokeColor }));\n }\n const referenceTarget = ctx.getReference(content.refId, contents, contentSelectable);\n if (referenceTarget) {\n const { textPosition, textRotation, text } = getTextPosition(content, referenceTarget);\n children.push(target.renderGroup(\n [\n target.renderText(textPosition.x, textPosition.y, text, strokeColor, content.fontSize, content.fontFamily)\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.getReference(c.refId, 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 refId: typeof content.refId === "number" ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.refId, setValue: (v) => update((c) => {\n if (isRadialDimensionReferenceContent(c)) {\n c.refId = v;\n }\n }) }) : [],\n refIdFrom: typeof content.refId === "number" ? /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquireContent({ count: 1, selectable: (i) => contentSelectable(contents[i[0]]) }, (p) => update((c) => {\n if (isRadialDimensionReferenceContent(c)) {\n c.refId = p[0][0];\n }\n })) }, "canvas") : [],\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, 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: (content) => [...ctx.getStrokeRefIds(content), ...typeof content.refId === "number" ? [content.refId] : []],\n updateRefId(content, update) {\n const newRefId = update(content.refId);\n if (newRefId !== void 0) {\n content.refId = newRefId;\n }\n ctx.updateStrokeRefIds(content, update);\n }\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 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: (contents) => {\n if (!result.refId && selected.length > 0 && type) {\n const content = selected[0].content;\n if (contentSelectable(content)) {\n result.refId = ctx.getContentIndex(content, contents);\n }\n }\n if (result.refId) {\n contents.push({\n type: "radial dimension reference",\n position: result.position,\n fontSize: result.fontSize,\n fontFamily: result.fontFamily,\n refId: result.refId,\n text: result.text,\n strokeStyleId\n });\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 = selected[0].content;\n if (contentSelectable(content)) {\n setResult({\n type: "radial dimension reference",\n position: p,\n fontSize: 16,\n fontFamily: "monospace",\n refId: selected[0].path[0],\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/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 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)\n return;\n const move = (_a = ctx.getContentModel(c)) == null ? void 0 : _a.move;\n if (!move)\n 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) => ctx.getContentsGeometries(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)\n return;\n const m = ctx.getContentModel(c);\n if (!m)\n 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 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) {\n return ctx.getEditPointsFromCache(content, () => {\n const bounding = ctx.getContentsBounding(content.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 };\n}\nfunction isRectArrayContent(content) {\n return content.type === "rect array";\n}\nfunction getCommand(ctx) {\n function contentSelectable(content, contents) {\n return !ctx.contentIsReferenced(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);\n if (!bounding)\n return;\n const newContent = {\n type: "rect array",\n contents: target,\n rowCount: 3,\n rowSpacing: -(bounding.end.y - bounding.start.y) * 1.5,\n columnCount: 4,\n columnSpacing: (bounding.end.x - bounding.start.x) * 1.5\n };\n for (let i = contents.length; i >= 0; i--) {\n if (ctx.isSelected([i], selected)) {\n contents[i] = void 0;\n }\n }\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 geometriesCache = new ctx.WeakmapCache();\n function getRectGeometries(content) {\n return geometriesCache.get(content, () => {\n const points = [\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 ].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 content.x += offset.x;\n content.y += offset.y;\n },\n rotate(content, center, angle) {\n const p = ctx.rotatePositionByCenter(content, center, -angle);\n content.x = p.x;\n content.y = p.y;\n content.angle += angle;\n },\n explode(content) {\n const { lines } = getRectGeometries(content);\n return lines.map((line) => ({ type: "line", points: line }));\n },\n break(content, intersectionPoints) {\n const { lines } = getRectGeometries(content);\n return ctx.breakPolyline(lines, intersectionPoints);\n },\n mirror(content, line, angle) {\n const p = ctx.getSymmetryPoint(content, line);\n content.x = p.x;\n content.y = p.y;\n content.angle = 2 * angle - content.angle;\n },\n offset(content, point, distance) {\n var _a;\n if (!distance) {\n distance = Math.min(...getRectGeometries(content).lines.map((line) => ctx.getPointAndGeometryLineMinimumDistance(point, line)));\n }\n distance *= 2 * (((_a = this.isPointIn) == null ? void 0 : _a.call(this, content, point)) ? -1 : 1);\n return ctx.produce(content, (d) => {\n d.width += distance;\n d.height += distance;\n });\n },\n render(content, { getFillColor, getStrokeColor, target, transformStrokeWidth, getFillPattern, contents, clip }) {\n var _a;\n const strokeStyleContent = ctx.getStrokeStyleContent(content, contents);\n const fillStyleContent = ctx.getFillStyleContent(content, contents);\n const options = {\n fillColor: getFillColor(fillStyleContent),\n strokeColor: getStrokeColor(strokeStyleContent),\n strokeWidth: transformStrokeWidth((_a = strokeStyleContent.strokeWidth) != null ? _a : ctx.getDefaultStrokeWidth(content)),\n fillPattern: getFillPattern(fillStyleContent)\n };\n if (strokeStyleContent.dashArray) {\n const { points } = getRectGeometries(content);\n return target.renderPolygon(points, { ...options, dashArray: strokeStyleContent.dashArray, clip });\n }\n return target.renderRect(content.x - content.width / 2, content.y - content.height / 2, content.width, content.height, { ...options, angle: content.angle, clip });\n },\n getOperatorRenderPosition(content) {\n const { points } = getRectGeometries(content);\n return points[0];\n },\n getEditPoints(content) {\n return ctx.getEditPointsFromCache(content, () => {\n const { points, midpoints } = getRectGeometries(content);\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) {\n return ctx.getSnapPointsFromCache(content, () => {\n const { points, midpoints } = getRectGeometries(content);\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, 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: ctx.getStrokeAndFillRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n isPointIn: (content, point) => ctx.pointInPolygon(point, getRectGeometries(content).points),\n getParam: (content, point) => ctx.getLinesParamAtPoint(point, getRectGeometries(content).lines),\n getPoint: (content, param) => ctx.getLinesPointAtParam(param, getRectGeometries(content).lines),\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 geometriesCache = new ctx.WeakmapCache();\n function getRegularPolygonGeometriesFromCache(content) {\n return geometriesCache.get(content, () => {\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 content.x += offset.x;\n content.y += offset.y;\n },\n offset(content, point, distance) {\n var _a;\n if (!distance) {\n distance = Math.min(...getRegularPolygonGeometriesFromCache(content).lines.map((line) => ctx.getPointAndGeometryLineMinimumDistance(point, line)));\n }\n distance *= ((_a = this.isPointIn) == null ? void 0 : _a.call(this, content, point)) ? -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, { target, getFillColor, getStrokeColor, transformStrokeWidth, getFillPattern, contents, clip }) {\n var _a;\n const strokeStyleContent = ctx.getStrokeStyleContent(content, contents);\n const fillStyleContent = ctx.getFillStyleContent(content, contents);\n const options = {\n fillColor: getFillColor(fillStyleContent),\n strokeColor: getStrokeColor(strokeStyleContent),\n strokeWidth: transformStrokeWidth((_a = strokeStyleContent.strokeWidth) != null ? _a : ctx.getDefaultStrokeWidth(content)),\n fillPattern: getFillPattern(fillStyleContent),\n dashArray: strokeStyleContent.dashArray,\n clip\n };\n const { points } = getRegularPolygonGeometriesFromCache(content);\n return target.renderPolygon(points, options);\n },\n getEditPoints(content) {\n return ctx.getEditPointsFromCache(content, () => {\n const { points } = getRegularPolygonGeometriesFromCache(content);\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, 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 isValid: (c, p) => ctx.validate(c, RegularPolygonContent, p),\n getRefIds: ctx.getStrokeAndFillRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n isPointIn: (content, point) => ctx.pointInPolygon(point, getRegularPolygonGeometriesFromCache(content).points),\n getParam: (content, point) => ctx.getLinesParamAtPoint(point, getRegularPolygonGeometriesFromCache(content).lines),\n getPoint: (content, param) => ctx.getLinesPointAtParam(param, getRegularPolygonGeometriesFromCache(content).lines)\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/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 function getRingGeometriesFromCache(content) {\n return ctx.getGeometriesFromCache(content, () => {\n var _a;\n const angleDelta = (_a = content.angleDelta) != null ? _a : ctx.defaultAngleDelta;\n const arc1 = { ...content, r: content.outerRadius, startAngle: 0, endAngle: 360 };\n const arc2 = { ...content, r: content.innerRadius, startAngle: 0, endAngle: 360 };\n const points1 = ctx.arcToPolyline(arc1, angleDelta);\n const points2 = ctx.arcToPolyline(arc2, angleDelta);\n const points = [...points1, ...points2];\n const lines1 = [{ type: "arc", curve: arc1 }];\n const lines2 = [{ type: "arc", curve: arc2 }];\n return {\n lines: [...lines1, ...lines2],\n bounding: ctx.getPointsBounding(points),\n regions: ctx.hasFill(content) ? [\n {\n lines: lines1,\n points: points1\n },\n {\n lines: lines2,\n points: points2\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 content.x += offset.x;\n content.y += offset.y;\n },\n render(content, { target, getFillColor, getStrokeColor, transformStrokeWidth, getFillPattern, contents }) {\n var _a;\n const strokeStyleContent = ctx.getStrokeStyleContent(content, contents);\n const fillStyleContent = ctx.getFillStyleContent(content, contents);\n const options = {\n fillColor: getFillColor(fillStyleContent),\n strokeColor: getStrokeColor(strokeStyleContent),\n strokeWidth: transformStrokeWidth((_a = strokeStyleContent.strokeWidth) != null ? _a : ctx.getDefaultStrokeWidth(content)),\n fillPattern: getFillPattern(fillStyleContent),\n dashArray: strokeStyleContent.dashArray\n };\n const { renderingLines, regions } = getRingGeometriesFromCache(content);\n if (regions) {\n return target.renderPath([regions[0].points, regions[1].points], 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, 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: ctx.getStrokeAndFillRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n getParam: (content, point) => ctx.getLinesParamAtPoint(point, getRingGeometriesFromCache(content).lines),\n getPoint: (content, param) => ctx.getLinesPointAtParam(param, getRingGeometriesFromCache(content).lines)\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 ((_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 geometriesCache = new ctx.WeakmapCache();\n function getGeometries(content) {\n return geometriesCache.get(content, () => {\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 return {\n lines: [\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 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.getPointsBounding(rectPoints),\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 content.x += offset.x;\n content.y += offset.y;\n },\n offset(content, point, distance) {\n var _a;\n if (!distance) {\n distance = Math.min(...getGeometries(content).lines.map((line) => ctx.getPointAndGeometryLineMinimumDistance(point, line)));\n }\n distance *= ((_a = this.isPointIn) == null ? void 0 : _a.call(this, content, point)) ? -2 : 2;\n return ctx.produce(content, (d) => {\n d.width += distance;\n d.height += distance;\n });\n },\n render(content, { getFillColor, getStrokeColor, target, transformStrokeWidth, getFillPattern, contents, clip }) {\n var _a;\n const strokeStyleContent = ctx.getStrokeStyleContent(content, contents);\n const fillStyleContent = ctx.getFillStyleContent(content, contents);\n const options = {\n fillColor: getFillColor(fillStyleContent),\n strokeColor: getStrokeColor(strokeStyleContent),\n strokeWidth: transformStrokeWidth((_a = strokeStyleContent.strokeWidth) != null ? _a : ctx.getDefaultStrokeWidth(content)),\n fillPattern: getFillPattern(fillStyleContent),\n clip\n };\n const { renderingLines } = getGeometries(content);\n return target.renderPath(renderingLines, options);\n },\n renderIfSelected(content, { color, target, strokeWidth }) {\n const { points, arcPoints } = getGeometries(content);\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) {\n return ctx.getEditPointsFromCache(content, () => {\n const { points } = getGeometries(content);\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) {\n return ctx.getSnapPointsFromCache(content, () => {\n const { points } = getGeometries(content);\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, 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: ctx.getStrokeAndFillRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n isPointIn: (content, point) => ctx.pointInPolygon(point, getGeometries(content).points),\n getParam: (content, point) => ctx.getLinesParamAtPoint(point, getGeometries(content).lines),\n getPoint: (content, param) => ctx.getLinesPointAtParam(param, getGeometries(content).lines)\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/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.boolean)\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 geometriesCache = new ctx.WeakmapCache();\n function getSplineGeometries(content) {\n return geometriesCache.get(content, () => {\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) {\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.getPointsBounding(points),\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) {\n return ctx.getGeometriesFromCache(content, () => {\n const geometry = getSplineGeometries(content);\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 point.x += offset.x;\n point.y += offset.y;\n }\n },\n rotate(content, center, angle) {\n content.points = content.points.map((p) => ctx.rotatePositionByCenter(p, center, -angle));\n },\n mirror(content, line) {\n content.points = content.points.map((p) => ctx.getSymmetryPoint(p, line));\n },\n break(content, intersectionPoints) {\n const lines = getSplineGeometries(content).lines;\n return ctx.breakGeometryLinesToPathCommands(lines, intersectionPoints);\n },\n render(content, { getFillColor, getStrokeColor, target, transformStrokeWidth, getFillPattern, contents }) {\n var _a;\n const { points } = getSplineGeometries(content);\n const strokeStyleContent = ctx.getStrokeStyleContent(content, contents);\n const fillStyleContent = ctx.getFillStyleContent(content, contents);\n const options = {\n fillColor: getFillColor(fillStyleContent),\n strokeColor: getStrokeColor(strokeStyleContent),\n strokeWidth: transformStrokeWidth((_a = strokeStyleContent.strokeWidth) != null ? _a : ctx.getDefaultStrokeWidth(content)),\n fillPattern: getFillPattern(fillStyleContent),\n dashArray: strokeStyleContent.dashArray\n };\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, 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.BooleanEditor, { value: content.fitting === true, setValue: (v) => update((c) => {\n if (isSplineContent(c)) {\n c.fitting = v ? 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: ctx.getStrokeAndFillRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds\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 mirror: splineModel.mirror,\n render(content, { getStrokeColor, target, transformStrokeWidth, contents }) {\n var _a;\n const strokeStyleContent = ctx.getStrokeStyleContent(content, contents);\n const strokeColor = getStrokeColor(strokeStyleContent);\n const strokeWidth = transformStrokeWidth((_a = strokeStyleContent.strokeWidth) != null ? _a : ctx.getDefaultStrokeWidth(content));\n const { regions, renderingLines } = getSplineArrowGeometries(content);\n const children = [];\n for (const line of renderingLines) {\n children.push(target.renderPolyline(line, { strokeColor, strokeWidth }));\n }\n if (regions) {\n for (let i = 0; i < 2 && i < regions.length; i++) {\n children.push(target.renderPolyline(regions[i].points, { strokeWidth: 0, fillColor: strokeColor }));\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, 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: ctx.getStrokeRefIds,\n updateRefId: ctx.updateStrokeRefIds\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 geometriesCache = new ctx.WeakmapCache();\n function getStarGeometriesFromCache(content) {\n return geometriesCache.get(content, () => {\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 content.x += offset.x;\n content.y += offset.y;\n },\n offset(content, point, distance) {\n var _a;\n if (!distance) {\n distance = Math.min(...getStarGeometriesFromCache(content).lines.map((line) => ctx.getPointAndGeometryLineMinimumDistance(point, line)));\n }\n distance *= ((_a = this.isPointIn) == null ? void 0 : _a.call(this, content, point)) ? -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, { target, getFillColor, getStrokeColor, transformStrokeWidth, getFillPattern, contents, clip }) {\n var _a;\n const strokeStyleContent = ctx.getStrokeStyleContent(content, contents);\n const fillStyleContent = ctx.getFillStyleContent(content, contents);\n const options = {\n fillColor: getFillColor(fillStyleContent),\n strokeColor: getStrokeColor(strokeStyleContent),\n strokeWidth: transformStrokeWidth((_a = strokeStyleContent.strokeWidth) != null ? _a : ctx.getDefaultStrokeWidth(content)),\n fillPattern: getFillPattern(fillStyleContent),\n dashArray: strokeStyleContent.dashArray,\n clip\n };\n const { points } = getStarGeometriesFromCache(content);\n return target.renderPolygon(points, options);\n },\n getEditPoints(content) {\n return ctx.getEditPointsFromCache(content, () => {\n const { points } = getStarGeometriesFromCache(content);\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, 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: ctx.getStrokeAndFillRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n isPointIn: (content, point) => ctx.pointInPolygon(point, getStarGeometriesFromCache(content).points),\n getParam: (content, point) => ctx.getLinesParamAtPoint(point, getStarGeometriesFromCache(content).lines),\n getPoint: (content, param) => ctx.getLinesPointAtParam(param, getStarGeometriesFromCache(content).lines)\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, () => {\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 content.x += offset.x;\n content.y += offset.y;\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 };\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, 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 geometriesCache = new ctx.WeakmapCache();\n const textLayoutResultCache = new ctx.WeakmapMap3Cache();\n const getGeometries = (content) => {\n return geometriesCache.get(content, () => {\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 content.x += offset.x;\n content.y += offset.y;\n },\n render(content, renderCtx) {\n var _a;\n const geometries = getGeometries(content);\n const strokeStyleContent = ctx.getStrokeStyleContent(content, renderCtx.contents);\n const options = {\n ...renderCtx,\n strokeColor: renderCtx.getStrokeColor(strokeStyleContent),\n strokeWidth: renderCtx.transformStrokeWidth((_a = strokeStyleContent.strokeWidth) != null ? _a : ctx.getDefaultStrokeWidth(content)),\n dashArray: strokeStyleContent.dashArray\n };\n const children = geometries.renderingLines.map((line) => renderCtx.target.renderPolyline(line, options));\n content.rows.forEach((row, i) => {\n var _a2;\n (_a2 = row.cells) == null ? void 0 : _a2.forEach((cell) => {\n var _a3, _b;\n const child = geometries.children.find((f) => f.row === i && f.column === cell.column);\n if (!child)\n 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 _a4, _b2, _c;\n const state = cell.text.split("");\n const getTextWidth = (text) => {\n var _a5, _b3;\n return (_b3 = (_a5 = ctx.getTextSizeFromCache(ctx.getTextStyleFont(textStyleContent), text)) == null ? void 0 : _a5.width) != null ? _b3 : 0;\n };\n return ctx.flowLayout({\n state,\n width,\n height,\n lineHeight: (_a4 = textStyleContent.lineHeight) != null ? _a4 : 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 = (_a3 = ctx.getTextSizeFromCache(font, text)) == null ? void 0 : _a3.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 }));\n }\n });\n });\n return renderCtx.target.renderGroup(children);\n },\n getEditPoints(content) {\n return ctx.getEditPointsFromCache(content, () => {\n const { rows, columns, xs, ys } = getGeometries(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 (!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)\n 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)\n return /* @__PURE__ */ React.createElement(React.Fragment, null);\n const { children } = getGeometries(content);\n const child = children.find((f) => f.row === row && f.column === column);\n if (!child)\n 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.TextEditor,\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 getChildByPoint(content, point, { textStyleId }) {\n var _a;\n const { children } = getGeometries(content);\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)\n 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)\n 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)\n 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)\n 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 content.x += offset.x;\n content.y += offset.y;\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, 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 });\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 return ctx.getGeometriesFromCache(content, () => {\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 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 content.x += offset.x;\n content.y += offset.y;\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, { target, transformColor, isAssistence, variableContext, contents }) {\n var _a, _b;\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 if (hasWidth(content)) {\n const { layoutResult } = getTextLayoutResult(content, textStyleContent, variableContext);\n const children = [];\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 }));\n }\n return target.renderGroup(children);\n }\n return target.renderText(content.x, content.y, text, color, textStyleContent.fontSize, textStyleContent.fontFamily, { cacheKey });\n },\n getGeometries: getTextGeometries,\n propertyPanel(content, update, contents, { acquirePoint }) {\n return {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isTextContent(c)) {\n c.x = p.x, 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 };\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.TextEditor,\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 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 }) {\n const { text, onClick, onMove, input, reset } = ctx.useTextClickCreate(\n type === "create text",\n (c) => onEnd({\n updateContents: (contents) => contents.push({\n type: "text",\n textStyleId,\n ...c\n })\n }),\n {\n scale\n }\n );\n const assistentContents = [];\n if (text) {\n assistentContents.push({\n type: "text",\n textStyleId,\n ...text\n });\n }\n return {\n onStart: onClick,\n input,\n onMove,\n assistentContents,\n reset\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 function getGeometriesFromCache(content, _, 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({ x: content.x + time / 10, y: content.y, r: 5, startAngle: 0, endAngle: 360 }, 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 return ctx.getGeometriesFromCache(content, getGeometries);\n }\n const React = ctx.React;\n return {\n type: "time axis",\n ...ctx.strokeModel,\n ...ctx.arrowModel,\n move(content, offset) {\n content.x += offset.x;\n content.y += offset.y;\n },\n render(content, { target, getStrokeColor, transformStrokeWidth, contents, time }) {\n var _a;\n const strokeStyleContent = ctx.getStrokeStyleContent(content, contents);\n const strokeColor = getStrokeColor(strokeStyleContent);\n const strokeWidth = transformStrokeWidth((_a = strokeStyleContent.strokeWidth) != null ? _a : ctx.getDefaultStrokeWidth(content));\n const { regions, renderingLines } = getGeometriesFromCache(content, contents, time);\n const children = [];\n for (const line of renderingLines) {\n children.push(target.renderPolyline(line, { strokeColor, strokeWidth }));\n }\n if (regions) {\n for (let i = 0; i < regions.length; i++) {\n children.push(target.renderPolyline(regions[i].points, { strokeWidth: 0, fillColor: strokeColor }));\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, 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: ctx.getStrokeRefIds,\n updateRefId: ctx.updateStrokeRefIds\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/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 }) {\n var _a, _b;\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 _a2, _b2;\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 = (_b2 = (_a2 = ctx.getContentModel(content)) == null ? void 0 : _a2.break) == null ? void 0 : _b2.call(_a2, 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 for (const current of currents) {\n for (const child of current.children) {\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 }\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 if (ctx.isStrokeContent(child)) {\n assistentContents.push({\n ...child,\n strokeWidth: ((_b = child.strokeWidth) != null ? _b : ctx.getDefaultStrokeWidth(child)) + 2,\n strokeColor: backgroundColor,\n trueStrokeColor: true\n });\n }\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 _a2, _b2, _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 = (_b2 = (_a2 = ctx.getContentModel(child)) == null ? void 0 : _a2.getGeometries) == null ? void 0 : _b2.call(_a2, 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 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 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)\n 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 model = ctx.getContentModel(child);\n if ((model == null ? void 0 : model.getStartPoint) && model.getEndPoint) {\n points.push(model.getStartPoint(child), model.getEndPoint(child));\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 }\n }\n onEnd({\n updateContents: (contents2) => {\n for (const index of removedIndexes) {\n contents2[index] = void 0;\n }\n contents2.push(...newContents);\n }\n });\n reset();\n }\n },\n assistentContents,\n reset\n };\n },\n contentSelectable(content, contents) {\n const model = ctx.getContentModel(content);\n return (model == null ? void 0 : model.break) !== void 0 && !ctx.contentIsReferenced(content, contents);\n },\n hotkey: "TR",\n icon,\n pointSnapDisabled: true\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/viewport.plugin.tsx\nfunction getModel(ctx) {\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 {\n ...geometries,\n regions: [{\n points: [],\n lines: []\n }]\n };\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 content.x += offset.x;\n content.y += offset.y;\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 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 ? 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)\n 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, 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 };\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: (content) => ctx.getStrokeRefIds(content),\n updateRefId(content, update) {\n ctx.updateStrokeRefIds(content, update);\n }\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 var _a;\n return ((_a = ctx.getContentModel(content)) == null ? void 0 : _a.isPointIn) !== void 0;\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)\n 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']},4788:(e,t,n)=>{"use strict";n.d(t,{MemoizedRenderer:()=>y,getAllRendererTypes:()=>b,registerRenderer:()=>v});var r=n(5188),o=n(7378),i=n.n(o),a=n(9397),s=n(1240),l=Object.defineProperty,c=Object.defineProperties,u=Object.getOwnPropertyDescriptors,p=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,f=Object.prototype.propertyIsEnumerable,g=(e,t,n)=>t in e?l(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)=>c(e,u(t));const y=i().memo((function(e){var t,n,o,l,c,u;const p=new a.Debug(e.debug),d=x[e.type||b()[0]],f=e.printMode?0:1/e.scale,g=i().useRef(new a.WeakmapMapCache);(0,a.useValueChanged)(e.type,(()=>g.current.clear())),(0,a.useValueChanged)(e.backgroundColor,(()=>g.current.clear()));const y=i().useRef(new a.WeakmapCache);if((0,a.useValueChanged)(d,(()=>y.current.clear())),!d)return null;const v=(0,a.getColorString)(e.backgroundColor),C=+`0x${v.substring(1,3)}`,E=+`0x${v.substring(3,5)}`,k=+`0x${v.substring(5)}`,w=(Math.max(C,k,E)+Math.min(C,k,E))/2,S=e=>w<128?0===e?16777215:e:16777215===e?0:e;p.mark("before contents");let P=[];const R=new a.Merger((e=>P.push(d.renderPath(e.target,{strokeColor:e.type.strokeColor,dashArray:e.type.dashArray,strokeWidth:e.type.strokeWidth}))),((e,t)=>e.strokeColor===t.strokeColor&&e.strokeWidth===t.strokeWidth&&(0,a.isSamePath)(e.dashArray,t.dashArray)),(e=>e.line)),_=null!=(t=e.previewPatches)?t:[],T=_.length>0&&!e.performanceMode?(0,r.applyPatches)(e.contents,_):e.contents,A=(0,s.getSortedContents)(T).contents,M={transformColor:S,target:d,getStrokeColor:e=>void 0!==e.strokeColor?e.trueStrokeColor?e.strokeColor:S(e.strokeColor):(0,s.hasFill)(e)?void 0:s.defaultStrokeColor,getFillColor:e=>void 0!==e.fillColor?S(e.fillColor):void 0,getFillPattern:e=>{if(void 0===e.fillPattern)return;const t=e.fillPattern;return y.current.get(t,(()=>({width:t.width,height:t.height,pattern:()=>{var e;return d.renderPath(t.lines,{strokeColor:null!=(e=void 0!==t.strokeColor?S(t.strokeColor):void 0)?e:s.defaultStrokeColor})}})))},time:e.time,contents:T};P=g.current.get(A,e.time,(()=>(A.forEach((t=>{var n,r;if(!t||!1===t.visible)return;const o=(0,s.getContentModel)(t);if(o)if("svg"!==d.type&&o.getGeometries){const{renderingLines:i,regions:a}=o.getGeometries(t,e.contents);if(i&&!a){const e=null!=(n=(0,s.isStrokeContent)(t)?t.strokeWidth:void 0)?n:(0,s.getDefaultStrokeWidth)(t);let o=null!=(r=(0,s.isStrokeContent)(t)?t.strokeColor:void 0)?r:s.defaultStrokeColor;o=S(o);for(const t of i)R.push({line:t,strokeColor:o,strokeWidth:e})}else{const e=o.render;e&&(R.flushLast(),P.push(e(t,h({transformStrokeWidth:e=>e},M))))}}else{const e=o.render;e&&(R.flushLast(),P.push(e(t,h({transformStrokeWidth:e=>e},M))))}})),P))),R.flushLast(),p.mark("before assistent contents");const L=[],O=[];if(e.performanceMode){const t=new Set(_.map((e=>e.path[0]))),n=[];for(const o of t){const t=_.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},M),{isAssistence:!0})))})),o.length>0&&void 0!==e.activeViewportIndex){const t=T[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 l=n.filter((e=>e.selection.includes(o))).map((e=>e.operator));if((0,a.isSelected)([o],t)&&l.unshift("me"),i.getOperatorRenderPosition&&l.length>0){const t=i.getOperatorRenderPosition(r,e.contents);O.push(d.renderText(t.x,t.y,l.join(","),16711680,16,"monospace"))}}))}for(const t of e.hovering||[]){const e=(0,s.getContentByIndex)(T,t);if(e){const t=null==(n=(0,s.getContentModel)(e))?void 0:n.render;t&&O.push(t(e,m(h({transformStrokeWidth:e=>e+1},M),{isHoveringOrSelected:!0})))}}for(const t of e.selected||[]){const n=(0,s.getContentByIndex)(T,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&&O.push(i(n,m(h({transformStrokeWidth:e=>e+1},M),{isHoveringOrSelected:!0})));const a=null==r?void 0:r.renderIfSelected;a&&O.push(a(n,{color:S(16711680),target:d,strokeWidth:t,contents:e.contents}))}}if(void 0!==e.activeViewportIndex){const t=T[e.activeViewportIndex];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},M),{isHoveringOrSelected:!0})))}}else if(void 0!==e.active){const t=T[e.active];if(t){const e=null==(c=(0,s.getContentModel)(t))?void 0:c.render;e&&L.push(e(t,m(h({transformStrokeWidth:e=>e+1},M),{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&&O.push(n(e,m(h({transformStrokeWidth:e=>e},M),{isAssistence:!0})))})),O.length>0){const t=void 0!==e.activeViewportIndex?T[e.activeViewportIndex]:void 0;t&&(0,s.isViewportContent)(t)?L.push(d.renderGroup(O,{matrix:(0,s.getViewportMatrix)(t)})):L.push(...O)}const I=0===L.length?P:[...P,...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},transform:{x:e.x,y:e.y,scale:e.scale,rotate:e.rotate},backgroundColor:e.backgroundColor,debug:e.debug,strokeWidthScale:f})})),x={};function v(e){x[e.type]=e}function b(){return Object.keys(x)}},5559:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(5188),o=n(7378),i=n.n(o),a=n(9397);const s=()=>{const[e,t]=i().useState([]),{circle:n,arc:o,onClick:s,onMove:l,input:c,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=>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=>s({x:e.clientX,y:e.clientY}),onMouseMove:e=>l({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}))),c)}},3102:(e,t,n)=>{"use strict";n.d(t,{default:()=>m});var r=n(5188),o=n(7378),i=n.n(o),a=n(9397),s=Object.defineProperty,l=Object.defineProperties,c=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)=>l(e,c(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:l}=(0,a.useCircleArcEdit)((()=>t(c)));(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&l()}));const c=(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)(c.x,c.y,c.r,c.endAngle),p=(0,a.polarToCartesian)(c.x,c.y,c.r,c.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 ${c.r} ${c.r} 0 ${c.endAngle-c.startAngle<=180?"0":"1"} 0 ${p.x} ${p.y}`,stroke:"#00ff00"})),i().createElement(a.CircleArcEditBar,h(g({},c),{onMouseDown:(e,t,n)=>o(e,h(g({},c),{type:t,cursor:n}))})),s)}},9879:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(5188),o=n(7378),i=n.n(o),a=n(9397);const s=()=>{const[e,t]=i().useState([]),{circle:n,onClick:o,onMove:s,input:l,reset:c}=(0,a.useCircleClickCreate)("center radius",(n=>{t((0,r.produce)(e,(e=>{e.push(n)})))}));return(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&c()})),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"}}))),l)}},1940:(e,t,n)=>{"use strict";n.d(t,{default:()=>g});var r=n(5188),o=n(7378),i=n.n(o),a=n(9397),s=Object.defineProperty,l=Object.defineProperties,c=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),l(i,c({type:n,cursor:r}))));var i}}),s)}},9966:(e,t,n)=>{"use strict";n.d(t,{CircuitGraphEditor:()=>h});var r=n(7378),o=n.n(r),i=n(5188),a=n(9397),s=n(5472),l=n(7527),c=n(1789),u=n(3907),p=n(8560),d=n(2845),f=n(2006),g=n(4484);(0,i.enablePatches)(),(0,s.registerModel)(l.powerModel),(0,s.registerModel)(c.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,l,c,u;const{width:f,height:g}=(0,a.useWindowSize)(),{state:h,setState:m,undo:y,redo:x,applyPatchFromSelf:v,applyPatchFromOtherOperators:b}=(0,a.usePatchBasedUndoRedo)(e.initialState,e.operator,{onApplyPatchesFromSelf:e.onApplyPatchesFromSelf}),{x:C,y:E,ref:k,setX:w,setY:S}=(0,a.useWheelScroll)(),{scale:P,ref:R}=(0,a.useWheelZoom)({min:.001,onChange(e,t,n){const r=(0,a.scaleByCursorPosition)({width:f,height:g},t/e,n);w(r.setX),S(r.setY)}}),[_,T]=o().useState(),[A,M]=o().useState(),[L,O]=o().useState(),[I,F]=o().useState(),D=L?s.modelCenter[L]:void 0,B=[],z=[],U=[],N=[],[j,W]=o().useState();let G;const[V,$]=o().useState([]),[H,q]=o().useState(),Y=o().useRef(),X=o().useRef(),{line:K,onClick:Z,reset:Q,onMove:J,lastPosition:ee}=(0,a.useLineClickCreate)(void 0!==L,(e=>{m((t=>{if(!(null==D?void 0:D.createPreview))return;let n,r,o=h.length;if(void 0===Y.current){const r={type:"junction",position:e[0]};t.push(r),n=o,o++}else n=Y.current;if(void 0===X.current){const n={type:"junction",position:e[1]};t.push(n),r=o,o++}else r=X.current;t.push(D.createPreview({start:n,end:r}))})),ne()}),{once:!0});if(K&&(null==D?void 0:D.createPreview)){const e={type:"junction",position:K[0]},t={type:"junction",position:K[1]};B.push(e,t,D.createPreview({start:e,end:t}))}const te={x:C,y:E,scale:P,center:{x:f/2,y:g/2}},ne=()=>{O(void 0),Y.current=void 0,X.current=void 0,F(void 0),T(void 0),M(void 0),q(void 0)},{editPoint:re,updateEditPreview:oe,onEditMove:ie,onEditClick:ae,editLastPosition:se,getEditAssistentContents:le,resetEdit:ce}=(0,a.useEdit)((()=>{const e=[],t=[];let n=h.length;for(const r of z)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++)}v([...z,...e],[...U,...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:!!L}),ue=oe();if(z.push(...null!=(n=null==ue?void 0:ue.patches)?n:[]),U.push(...null!=(r=null==ue?void 0:ue.reversePatches)?r:[]),B.push(...null!=(l=null==ue?void 0:ue.assistentContents)?l:[]),ue&&B.push(...(0,s.updateReferencedContents)(ue.content,ue.result,h)),void 0!==A){const e=h[A];if(e){N.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);B.push(...le(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)}));v(...t)},r=null==(u=null==(c=(0,s.getContentModel)(e))?void 0:c.propertyPanel)?void 0:u.call(c,e,n,h);let l;if((0,s.isJunctionContent)(e)){const e=V[A];void 0!==e&&(l=o().createElement("div",null,e,"V"))}G=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),l,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.equals)(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 F(n),n}}else if((0,a.equals)(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 F(n),n}return F(void 0),{point:e}};"point"===(null==I?void 0:I.type)&&B.push({type:"circle",x:I.point.x,y:I.point.y,radius:7}),"line"===(null==I?void 0:I.type)&&B.push({type:"line",p1:I.start,p2:I.point});const fe=e=>{W(e),Q(),O(e)},ge=(0,a.useEvent)((e=>{const t={x:e.clientX,y:e.clientY},n=(0,a.reverseTransformPosition)(t,te),r=de(n);L?(void 0===K?Y.current=r.id:X.current=r.id,Z(r.point)):re?ae(r.point):H?H.act((e=>{const[,...t]=(0,i.produceWithPatches)(h,(t=>{const n=t[H.index];n&&e(n,t)}));v(...t)})):void 0!==_&&(M(_),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);L?J(r.point,t):(ie(r.point,N),T((e=>{var t,n;for(let t=0;t{var t,n;for(let r=0;r{j&&(fe(j),e.preventDefault())}));let ye;return(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key?(ne(),Q(!0),ce()):(0,a.metaKeyIfMacElseCtrlKey)(e)&&(e.shiftKey?"KeyZ"===e.code&&x(e):"KeyZ"===e.code?y(e):"Backspace"===e.code&&(void 0===_||(0,s.contentIsReferenced)(_,h)?void 0===A||(0,s.contentIsReferenced)(A,h)||(m((e=>{e[A]=void 0})),M(void 0)):(m((e=>{e[_]=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);$(n)}),[h]),re?ye=re.cursor:(void 0!==_&&_!==A||H)&&(ye="pointer"),o().createElement(o().Fragment,null,o().createElement("div",{ref:(0,a.bindMultipleRefs)(k,R)},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:B,hovering:_,selected:A,previewPatches:z,equationResult:V,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:L===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"})))),G)}))},5472:(e,t,n)=>{"use strict";n.d(t,{contentIndexCache:()=>g,contentIsReferenced:()=>v,deviceGeometryCache:()=>p,deviceModel:()=>s,getContentModel:()=>x,getDeviceText:()=>b,getReference:()=>f,isDeviceContent:()=>u,isJunctionContent:()=>l,modelCenter:()=>m,registerModel:()=>y,updateReferencedContents:()=>h});var r=n(5188),o=n(7378),i=n.n(o),a=n(9397);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,l);r&&n.push({field:"start",content:r});const o=f(e.end,t,l);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&&l(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 l(e){return"junction"===e.type}const c={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(l(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=>{l(t)&&(t.ground=!!e||void 0)}))})}}};function u(e){var t;return!!(null==(t=x(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(!l(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=x(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 x(e){return m[e.type]}function v(e,t){var n,r,o;for(const i of t)if(i&&(null==(o=null==(r=null==(n=x(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,l,c=e.center.x,u=e.center.y,p=e.center.x,d=e.center.y;i>1/4&&i<3/4?(c+=10,p-=10,s="left",l="right"):(u-=15,d+=15,s="center",l="center");const f=[];if(n&&f.push(t.renderText(c,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:l,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(c),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]})})},4484:(e,t,n)=>{"use strict";n.d(t,{capacitorModel:()=>g});var r=n(7378),o=n.n(r),i=n(9397),a=n(5472),s=Object.defineProperty,l=Object.defineProperties,c=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=l(((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),c({render(e,{target:t,transformStrokeWidth:n,contents:r,value:o,equationResult:i}){const s=n(1),{lines:l,data:c}=h(e,r),u=l.map((e=>t.renderPolyline(e,{strokeWidth:s})));if(c){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)(c,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),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:[]}}},7527:(e,t,n)=>{"use strict";n.d(t,{powerModel:()=>h});var r=n(7378),o=n.n(r),i=n(9397),a=n(5472),s=Object.defineProperty,l=Object.defineProperties,c=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:l}=x(e,r),c=s.map((e=>t.renderPolyline(e,{strokeWidth:i})));return l&&c.push(...(0,a.getDeviceText)(l,t,e.value+"V",o)),t.renderGroup(c)},createPreview:e=>({type:"power",start:e.start,end:e.end,value:1}),getGeometries:x,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}`})},l(m,c(y)));var m,y;function x(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),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:[]}}},1789:(e,t,n)=>{"use strict";n.d(t,{resistanceModel:()=>g});var r=n(7378),o=n.n(r),i=n(9397),a=n(5472),s=Object.defineProperty,l=Object.defineProperties,c=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=l(((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),c({render(e,{target:t,transformStrokeWidth:n,contents:r,value:o}){const i=n(1),{lines:s,data:l}=h(e,r),c=s.map((e=>t.renderPolyline(e,{strokeWidth:i})));return l&&c.push(...(0,a.getDeviceText)(l,t,e.value+"Ω",o)),t.renderGroup(c)},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),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:[]}}},2006:(e,t,n)=>{"use strict";n.d(t,{switchModel:()=>h});var r=n(7378),o=n.n(r),i=n(9397),a=n(5472),s=Object.defineProperty,l=Object.defineProperties,c=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=l(((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),c({render(e,{target:t,transformStrokeWidth:n,contents:r,value:o}){const i=n(1),{lines:s,data:l}=m(e,r),c=s.map((e=>t.renderPolyline(e,{strokeWidth:i})));return l&&c.push(...(0,a.getDeviceText)(l,t,void 0,o)),t.renderGroup(c)},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)({x:o.x,y:o.y,r:3,startAngle:0,endAngle:360},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:[]}}},3907:(e,t,n)=>{"use strict";n.d(t,{wireModel:()=>g});var r=n(7378),o=n.n(r),i=n(9397),a=n(5472),s=Object.defineProperty,l=Object.defineProperties,c=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=l(((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),c({render(e,{target:t,transformStrokeWidth:n,contents:r,value:o}){const i=n(1),{lines:s,data:l}=h(e,r),c=s.map((e=>t.renderPolyline(e,{strokeWidth:i})));return l&&c.push(...(0,a.getDeviceText)(l,t,void 0,o)),t.renderGroup(c)},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:[]}}},8560:(e,t,n)=>{"use strict";n.d(t,{Renderer:()=>d});var r=n(5188),o=n(9397),i=n(5472),a=Object.defineProperty,s=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,c=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={}))l.call(t,n)&&u(e,n,t[n]);if(s)for(var n of s(t))c.call(t,n)&&u(e,n,t[n]);return e};function d(e){var t,n;const a=o.reactSvgRenderTarget,s=[],l=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:l,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:l}))}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}})}},3501:(e,t,n)=>{"use strict";n.d(t,{Combination2:()=>E});var r=n(7378),o=n.n(r),i=n(9397),a=n(5878),s=n(4788),l=n(4732),c=Object.defineProperty,u=Object.defineProperties,p=Object.getOwnPropertyDescriptors,d=Object.getOwnPropertySymbols,f=Object.prototype.hasOwnProperty,g=Object.prototype.propertyIsEnumerable,h=Math.pow,m=(e,t,n)=>t in e?c(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},x=(e,t)=>u(e,p(t)),v=(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())}));const b=Math.round(15*Math.random()*h(16,3)+h(16,3)).toString(16),C="combination-2.json";function E(){const[e,t]=o().useState(),[n,r]=o().useState(!0),{pluginLoaded:c,pluginCommandTypes:u}=(0,l.usePlugins)(),[p,d]=(0,i.useLocalStorageState)("composable-editor-canvas-combination2:panel",!0),[f,g]=(0,i.useLocalStorageState)("composable-editor-canvas-combination2:print-mode",!1),[h,m]=(0,i.useLocalStorageState)("composable-editor-canvas-combination2:performance-mode",!1),E=(0,l.useInitialStateValidated)(e,c);o().useEffect((()=>{(()=>{v(this,null,(function*(){try{const e=yield fetch(`https://storage.yorkyao.com/${C}`),n=yield e.json();t(n)}catch(e){t([])}}))})()}),[]);const k=o().useRef();o().useEffect((()=>(k.current=new WebSocket(`wss://storage.yorkyao.com/ws/composable-editor-canvas?key=${C}`),(0,a.setWsHeartbeat)(k.current,'{"method":"ping"}'),()=>{var e;return null==(e=k.current)?void 0:e.close()})),[]);const w=o().useRef(null);o().useEffect((()=>{k.current&&w.current&&(k.current.onmessage=e=>{if(w.current&&"string"==typeof e.data&&e.data&&n){const t=JSON.parse(e.data);"patch"===t.method?w.current.handlePatchesEvent(x(y({},t),{patches:t.operations.map((e=>x(y({},e),{path:e.path.substring(1).split("/")})))})):"selection"===t.method&&w.current.handleSelectionEvent(t)}})}),[k.current,w.current]);const[S,P]=o().useState(!1),[R,_]=(0,i.useLocalStorageState)("composable-editor-canvas-combination2:snaps",i.allSnapTypes),[T,A]=(0,i.useLocalStorageState)("composable-editor-canvas-combination2:render-target",void 0),[M,L]=o().useState(!1),[O,I]=o().useState(!1),[F,D]=o().useState(),[B,z]=(0,i.useLocalStorageState)("composable-editor-canvas-combination2:input-fixed",!1),[U,N]=(0,i.useLocalStorageState)("composable-editor-canvas-combination2:background-color",16777215),[j,W]=(0,i.useLocalStorageState)("composable-editor-canvas-combination2:debug",!1);return o().createElement("div",{style:{height:"100%"}},e&&c&&E&&o().createElement(l.CADEditor,{ref:w,id:"combination2",operator:b,initialState:e,onApplyPatchesFromSelf:(e,t)=>{if(k.current&&k.current.readyState===k.current.OPEN&&n){const n=e.map((e=>x(y({},e),{path:e.path.map((e=>`/${e}`)).join("")})));k.current.send(JSON.stringify({method:"patch",operations:n,reversePatches:t,operator:b}))}},onSendSelection:e=>{k.current&&k.current.readyState===k.current.OPEN&&n&&k.current.send(JSON.stringify({method:"selection",selectedContents:e,operator:b}))},readOnly:S,snapTypes:R,renderTarget:T,setCanUndo:L,setCanRedo:I,setOperation:D,inputFixed:B,backgroundColor:U,debug:j,panelVisible:p,printMode:f,performanceMode:h}),o().createElement("div",{style:{position:"fixed",width:"100%"}},!S&&u.map((e=>{if(e.icon){const t=o().cloneElement(e.icon,{onClick:()=>{var t;return null==(t=w.current)?void 0:t.startOperation({type:"command",name:e.name})},key:e.name,style:{width:"20px",height:"20px",margin:"5px",cursor:"pointer",color:F===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=w.current)?void 0:t.startOperation({type:"non command",name:e})},key:e,style:{position:"relative",borderColor:F===e?"red":void 0}},e))),o().createElement("button",{onClick:()=>(t(void 0),r(!1),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"}},"add mock data"),!S&&o().createElement("button",{disabled:!M,onClick:()=>{var e;return null==(e=w.current)?void 0:e.undo()},style:{position:"relative"}},"undo"),!S&&o().createElement("button",{disabled:!O,onClick:()=>{var e;return null==(e=w.current)?void 0:e.redo()},style:{position:"relative"}},"redo"),!S&&o().createElement("label",null,o().createElement("input",{type:"checkbox",checked:p,onChange:()=>d(!p)}),"panel"),o().createElement("label",null,o().createElement("input",{type:"checkbox",checked:f,onChange:()=>g(!f)}),"print mode"),o().createElement("label",null,o().createElement("input",{type:"checkbox",checked:h,onChange:()=>m(!h)}),"performance mode"),o().createElement("label",null,o().createElement("input",{type:"checkbox",checked:j,onChange:()=>W(!j)}),"debug"),o().createElement("select",{value:T,onChange:e=>A(e.target.value),style:{position:"relative"}},(0,s.getAllRendererTypes)().map((e=>o().createElement("option",{key:e,value:e},e)))),!S&&i.allSnapTypes.map((e=>o().createElement("label",{key:e,style:{position:"relative"}},o().createElement("input",{type:"checkbox",checked:R.includes(e),onChange:t=>_(t.target.checked?[...R,e]:R.filter((t=>t!==e)))}),e))),o().createElement("label",{style:{position:"relative"}},o().createElement("input",{type:"checkbox",checked:S,onChange:e=>P(e.target.checked)}),"read only"),!S&&o().createElement("label",{style:{position:"relative"}},o().createElement("input",{type:"checkbox",checked:B,onChange:e=>z(e.target.checked)}),"input fixed"),o().createElement("input",{type:"color",style:{position:"relative"},value:(0,i.getColorString)(U),onChange:e=>N((0,i.colorStringToNumber)(e.target.value))})))}},2734:(e,t,n)=>{"use strict";n.d(t,{Combination3:()=>T});var r=n(7378),o=n.n(r),i=n(5878),a=n(5188),s=n(7866),l=n(1037),c=n(6214),u=n(4405),p=n(9107),d=n(4090),f=n(4615),g=n(6946),h=n(1247),m=Object.defineProperty,y=Object.defineProperties,x=Object.getOwnPropertyDescriptors,v=Object.getOwnPropertySymbols,b=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable,E=Math.pow,k=(e,t,n)=>t in e?m(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,w=(e,t)=>{for(var n in t||(t={}))b.call(t,n)&&k(e,n,t[n]);if(v)for(var n of v(t))C.call(t,n)&&k(e,n,t[n]);return e},S=(e,t)=>y(e,x(t)),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())}));const R=Math.round(15*Math.random()*E(16,3)+E(16,3)).toString(16),_="combination-3.json";function T(){const[e,t]=o().useState(),[n,r]=o().useState(!0),[m,y]=o().useState(!1),x=o().useRef({blocks:{h1:l.h1,h2:l.h2,h3:l.h3,h4:l.h4,h5:l.h5,h6:l.h6,p:l.p,ul:l.ul,ol:l.ol,hr:l.hr},styles:{"font size":c.fontSize,"font family":c.fontFamily,bold:c.bold,italic:c.italic,underline:c.underline,"pass through":c.passThrough,color:c.color,"background color":c.backgroundColor},hooks:[u.useAt,p.useLink,d.useImage,g.useCircle,h.useStack],inlines:[p.link,d.image,g.circle,h.stack],textInlines:{span:f.span,code:f.code,mark:f.mark,sub:f.sub,sup:f.sup}});o().useEffect((()=>{(()=>{P(this,null,(function*(){let e;try{const t=yield fetch(`https://storage.yorkyao.com/${_}`);e=yield t.json()}catch(t){e=[]}if(0===e.length){const n=(0,a.produceWithPatches)(e,(e=>{e.push({type:"p",blockStart:0,blockEnd:0,children:[]})}));t(n[0]),b(n[1],n[2])}else t(e)}))})()}),[]);const v=o().useRef();o().useEffect((()=>(v.current=new WebSocket(`wss://storage.yorkyao.com/ws/composable-editor-canvas?key=${_}`),(0,i.setWsHeartbeat)(v.current,'{"method":"ping"}'),()=>{var e;return null==(e=v.current)?void 0:e.close()})),[]);const b=(e,t)=>{if(v.current&&v.current.readyState===v.current.OPEN){const n=e.map((e=>S(w({},e),{path:e.path.map((e=>`/${e}`)).join("")})));v.current.send(JSON.stringify({method:"patch",operations:n,reversePatches:t,operator:R}))}},C=o().useRef(null);return o().useEffect((()=>{v.current&&C.current&&(v.current.onmessage=e=>{if(C.current&&"string"==typeof e.data&&e.data){const t=JSON.parse(e.data);"patch"===t.method?C.current.handlePatchesEvent(S(w({},t),{patches:t.operations.map((e=>S(w({},e),{path:e.path.substring(1).split("/")})))})):"location"===t.method&&C.current.handleLocationEvent(t)}})}),[v.current,C.current]),e?o().createElement("div",null,o().createElement("div",null,o().createElement("label",null,o().createElement("input",{type:"checkbox",checked:n,onChange:e=>r(e.target.checked)}),"autoHeight"),o().createElement("label",null,o().createElement("input",{type:"checkbox",checked:m,onChange:e=>y(e.target.checked)}),"readOnly")),o().createElement(s.RichTextEditor,{ref:C,initialState:e,width:500,height:300,onApplyPatchesFromSelf:b,onSendLocation:e=>{v.current&&v.current.readyState===v.current.OPEN&&v.current.send(JSON.stringify({method:"location",location:e,operator:R}))},autoHeight:n,readOnly:m,operator:R,plugin:x.current})):null}},6717:(e,t,n)=>{"use strict";n.d(t,{Combination4:()=>b});var r=n(7378),o=n.n(r),i=n(5878),a=n(9966),s=Object.defineProperty,l=Object.defineProperties,c=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)=>l(e,c(t)),y=(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())}));const x=Math.round(15*Math.random()*f(16,3)+f(16,3)).toString(16),v="combination-4.json";function b(){const[e,t]=o().useState(),n=o().useRef(null);o().useEffect((()=>{(()=>{y(this,null,(function*(){try{const e=yield fetch(`https://storage.yorkyao.com/${v}`),n=yield e.json();t(n)}catch(e){t([])}}))})()}),[]);const r=o().useRef();return o().useEffect((()=>(r.current=new WebSocket(`wss://storage.yorkyao.com/ws/composable-editor-canvas?key=${v}`),(0,i.setWsHeartbeat)(r.current,'{"method":"ping"}'),()=>{var e;return null==(e=r.current)?void 0:e.close()})),[]),o().useEffect((()=>{r.current&&n.current&&(r.current.onmessage=e=>{if(n.current&&"string"==typeof e.data&&e.data){const t=JSON.parse(e.data);"patch"===t.method&&n.current.handlePatchesEvent(m(h({},t),{patches:t.operations.map((e=>m(h({},e),{path:e.path.substring(1).split("/")})))}))}})}),[r.current,n.current]),e?o().createElement("div",null,o().createElement(a.CircuitGraphEditor,{operator:x,ref:n,initialState:e,onApplyPatchesFromSelf:(e,t)=>{if(r.current&&r.current.readyState===r.current.OPEN){const n=e.map((e=>m(h({},e),{path:e.path.map((e=>`/${e}`)).join("")})));r.current.send(JSON.stringify({method:"patch",operations:n,reversePatches:t,operator:x}))}}})):null}},5031:(e,t,n)=>{"use strict";n.d(t,{Combination5:()=>b});var r=n(7378),o=n.n(r),i=n(5878),a=n(9586),s=Object.defineProperty,l=Object.defineProperties,c=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)=>l(e,c(t)),y=(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())}));const x=Math.round(15*Math.random()*f(16,3)+f(16,3)).toString(16),v="combination-5.json";function b(){const[e,t]=o().useState(),n=o().useRef(null);o().useEffect((()=>{(()=>{y(this,null,(function*(){try{const e=yield fetch(`https://storage.yorkyao.com/${v}`),n=yield e.json();t(n)}catch(e){t([])}}))})()}),[]);const r=o().useRef();return o().useEffect((()=>(r.current=new WebSocket(`wss://storage.yorkyao.com/ws/composable-editor-canvas?key=${v}`),(0,i.setWsHeartbeat)(r.current,'{"method":"ping"}'),()=>{var e;return null==(e=r.current)?void 0:e.close()})),[]),o().useEffect((()=>{r.current&&n.current&&(r.current.onmessage=e=>{if(n.current&&"string"==typeof e.data&&e.data){const t=JSON.parse(e.data);"patch"===t.method&&n.current.handlePatchesEvent(m(h({},t),{patches:t.operations.map((e=>m(h({},e),{path:e.path.substring(1).split("/")})))}))}})}),[r.current,n.current]),e?o().createElement("div",null,o().createElement(a.AstronomicalObjectSimulator,{operator:x,ref:n,initialState:e,onApplyPatchesFromSelf:(e,t)=>{if(r.current&&r.current.readyState===r.current.OPEN){const n=e.map((e=>m(h({},e),{path:e.path.map((e=>`/${e}`)).join("")})));r.current.send(JSON.stringify({method:"patch",operations:n,reversePatches:t,operator:x}))}}})):null}},1509:(e,t,n)=>{"use strict";n.d(t,{Combination6:()=>y});var r=n(7378),o=n.n(r),i=n(5188),a=n(9397),s=Object.defineProperty,l=Object.defineProperties,c=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)=>l(e,c(t));function y(){const{width:e,height:t}=(0,a.useWindowSize)(),n=a.reactCanvasRenderTarget,[r,s,l]=(0,a.useRefState)([]),[c,u]=o().useState(),[p,d]=o().useState(!1),[g,y]=o().useState(!1),k=o().useRef(!1),[w,S]=o().useState(),P=[],R={x:e/2,y:t-x},_=o().useRef(new WeakSet);o().useEffect((()=>{let n;const r=o=>{if(void 0!==n){const r=.002*(o-n),c=k.current?v:x,u=[];for(const n of l.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(c,2)));s>=0?u.splice(s,1):(u.push(o),_.current.has(n)&&(_.current.add(o),_.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)(l.current,(n=>{n.push({type:"drop",x:t*e,y:x,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((()=>{F()}),1e3);return()=>clearInterval(e)}),[g]);const{line:T,cursorPosition:A,onClick:M,reset:L,onMove:O}=(0,a.useLineClickCreate)("drop"===c,(e=>{s((0,i.produce)(r,(t=>{t.push(E(e,x,c))}))),L()}),{once:!0}),I=e=>{L(),u(e)},F=()=>{const e=l.current.find((e=>"drop"===e.type&&!_.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),l=4*i*f(n,2)-4*f(o,2)+4*i*f(r,2);if(l<0)return[];const c=-o*r,u=o*n;if((0,a.isZero)(l))return[{x:c/s,y:u/s}];const p=f(l,.5),d=.5*n*p,g=.5*r*p;return[{x:(c+d)/s,y:(u+g)/s},{x:(c-d)/s,y:(u-g)/s}]}(e,R);0!==t.length&&(s((0,i.produce)(l.current,(e=>{for(const n of t)n.y<0&&e.push(m(h({type:"shoot down"},R),{speed:n}))}))),_.current.add(e))};T?P.push(E(T,x,c)):A?P.push(E([A,A],x,c)):w&&P.push(E([R,w],x,c));const D=[];for(const e of[...r,...P]){const t="drop"===e.type?16711680:65280,r=k.current&&"shoot down"===e.type?v:x;if(D.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+x,o);D.push(n.renderPolyline([e,i],{strokeColor:t}))}}const B=(0,a.useEvent)((e=>{const t={x:e.clientX,y:e.clientY};"drop"===c?M(t):"shoot down"===c&&w&&s((0,i.produce)(r,(e=>{e.push(E([R,w],x,c))})))})),z=(0,a.useEvent)((e=>{const t={x:e.clientX,y:e.clientY};"drop"===c?O(t):"shoot down"===c&&S(t)}));return(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&(u(void 0),S(void 0),L(!0))})),o().createElement("div",{style:{position:"absolute",inset:"0px",overflow:"hidden"},onMouseMove:z},n.renderResult(D,e,t,{attributes:{onClick:B}}),o().createElement("div",{style:{position:"absolute",top:"0px"}},o().createElement(a.Button,{style:{color:"drop"===c?"red":void 0},onClick:()=>I("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"===c?"red":void 0},onClick:()=>I("shoot down")},"shoot down"),o().createElement("label",{style:{position:"relative"}},o().createElement("input",{type:"checkbox",checked:k.current,onChange:e=>k.current=e.target.checked}),"detonate"),o().createElement(a.Button,{onClick:()=>F()},"aim auto"),o().createElement("label",{style:{position:"relative"}},o().createElement("input",{type:"checkbox",checked:g,onChange:e=>y(e.target.checked)}),"shoot auto")))}const x=5,v=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.multipleDirection)((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})}},1423:(e,t,n)=>{"use strict";n.d(t,{Combination7:()=>f});var r=n(7378),o=n.n(r),i=n(5188),a=n(9397),s=n(9769),l=n(1692),c=n(5767),u=n(1145),p=n(5533),d=n(7939);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)([]),[x,v]=o().useState([]),[,b,C]=(0,a.useRefState)(0),E=o().useRef();let k;x.length>0&&(k=o().createElement(c.Panel,{target:r[x[0]],status:E,updater:e=>{f((0,i.produce)(r,(t=>{e(t[0])})))}}));const{onStartSelect:w,dragSelectMask:S,resetDragSelect:P}=(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)}};v(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 x)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 x)e[n].canControl&&E.current&&(e[n].action={type:"attack",ability:E.current.ability,target:t})}))),E.current=void 0;break}v([t]);break}}}));return(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key?(P(),v([])):"s"===e.key?f((0,i.produce)(r,(e=>{for(const t of x)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,l.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 x)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,x),t,n),S),k)}},4928:(e,t,n)=>{"use strict";n.d(t,{abilities:()=>i});var r=n(7939),o=n(4323);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)}}},9769:(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}]},4323:(e,t,n)=>{"use strict";n.d(t,{items:()=>o,updateAbilityCooldown:()=>i});var r=n(7939);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})}},5767:(e,t,n)=>{"use strict";n.d(t,{Panel:()=>c});var r=n(7378),o=n.n(r),i=n(9397),a=n(7939),s=n(4323),l=n(4928);function c({target:e,updater:t,status:n}){const[r,c]=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=>c(+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,l;const c=s.items[r],u=null==(l=null==(a=e.abilityCooldowns)?void 0:a.find((e=>"items"===e.source&&e.index===r)))?void 0:l.cooldown;if(!c.ability)return o().createElement(i.Label,null,s.items[r].name);const p=!!u||void 0===d||d{c.ability&&!p&&(c.ability.cast?n.current={type:"attack",ability:{index:r,source:"items"}}:c.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 c=l.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||(c.cast?n.current={type:"attack",ability:{index:r,source:"abilities"}}:c.launch(r,t))}},l.abilities[r].name," ",u?u.toFixed(1):"")}))}),o().createElement(i.ObjectEditor,{inline:!0,properties:p}))}},1145:(e,t,n)=>{"use strict";n.d(t,{renderModels:()=>i});var r=n(9397),o=n(5533);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,l=[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;l.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;l.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(l)}));return a.push(...t.map((e=>"instant"===e.type?i.renderEmpty():i.renderCircle(e.position.x,e.position.y,5)))),a}},1692:(e,t,n)=>{"use strict";n.d(t,{updateModels:()=>l});var r=n(5188),o=n(9397),i=n(7939),a=n(4323),s=n(5533);function l(e,t,n){var l,c;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),l=(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,l);t&&(u[o]=t,p=!0)}}else if(e.attack&&l.health){const s=(0,i.getDamageAfterArmor)(e.attack.damage+Math.random()*e.attack.damageRange,l.health.armor),c=Math.max(0,(l.health.current-s)/l.health.total);u[o]=(0,r.produce)(a,(e=>{e.health=c})),0===c&&(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:x,source:v}=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==(c=null==(l=n.abilityCooldowns)?void 0:l.find((e=>e.source===v&&e.index===x)))?void 0:c.cooldown)){if(u[t]=(0,r.produce)(n,(e=>{e.facing=y,e.action=void 0,(0,a.updateAbilityCooldown)(e,x,v,m.cooldown),m.launch(x,(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:x,source:v}}),p=!0);continue}if(!m.cast.bulletSpeed){d.push({type:"instant",source:t,target:n.action.target,ability:{index:x,source:v}}),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:x,source:v},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 x;if(m<=g)x=(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);x=(0,r.produce)(n,(t=>{t.position=e,t.facing=y}))}let v=!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}}},5533:(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}}]},7939:(e,t,n)=>{"use strict";n.d(t,{attackMagicDamage:()=>C,attackPureDamage:()=>b,getAbilityFromIndex:()=>v,getDamageAfterArmor:()=>x,getModelResult:()=>y,getModelsAroundPositionByRadiusExcept:()=>E});var r=n(5188),o=n(4928),i=n(4323),a=n(5533),s=n(9397),l=Object.defineProperty,c=Object.defineProperties,u=Object.getOwnPropertyDescriptors,p=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,f=Object.prototype.propertyIsEnumerable,g=(e,t,n)=>t in e?l(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)=>c(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,l=t.attack&&void 0!==e.attackCooldown?m(h({},t.attack),{cooldown:e.attackCooldown,base:t.attack}):void 0;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&&e.magicResistance),s&&(e.mana&&(s.total+=e.mana),e.manaRegeneration&&(s.regeneration+=e.manaRegeneration)),l&&(e.attackDamage&&(l.damage+=e.attackDamage),e.attackSpeed&&(l.speed+=e.attackSpeed),e.attackRange&&(l.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*(1-(o.magicResistance+.001*r.intelligence))),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),l&&r&&("strength"===r.primary?l.damage+=r.strength:"agility"===r.primary?l.damage+=r.agility:"intelligence"===r.primary?l.damage+=r.intelligence:l.damage+=.7*(r.strength+r.agility+r.intelligence),r.agility&&(l.speed+=r.agility),l.time*=100/l.speed),{size:t.size,baseSpeed:t.speed,speed:n,health:o,mana:s,attack:l,attributes:r}}function x(e,t){return e*(1-.06*t/(1+.06*Math.abs(t)))}function v(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))}},6530:(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}]}]}},2240:(e,t,n)=>{"use strict";n.d(t,{HoverRenderer:()=>a});var r=n(7378),o=n.n(r),i=n(3150);function a(e){var t,n;const{styleGuide:r,hovered:a}=e,s=(0,i.getTargetByPath)(a,r);if(!s)return null;const l=s.template;if("template"===s.kind)return o().createElement(o().Fragment,null,o().createElement("div",{style:{position:"absolute",boxSizing:"border-box",left:l.x,top:l.y,width:l.width,height:l.height,backgroundColor:"green",opacity:.1}}));const c=s.content,u=(0,i.getTemplateContentSize)(c,r);if(!u)return null;const{width:p,height:d}=u;let f=o().createElement("div",{style:{position:"absolute",boxSizing:"border-box",left:c.x,top:c.y,width:p,height:d,backgroundColor:"green",opacity:.1,transform:`rotate(${null!=(t=c.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:l.x,top:l.y,width:l.width,height:l.height}},f)}},7456:(e,t,n)=>{"use strict";n.d(t,{App:()=>f});var r=n(7378),o=n.n(r),i=n(9397),a=n(6530),s=n(2240),l=n(5952),c=n(207),u=n(3150);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))),[x]=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}),v={width:window.innerWidth,height:window.innerHeight},{ref:b,scale:C,setScale:E}=(0,i.useWheelZoom)(),k=C*Math.min((v.width-80)/x.width,(v.height-80)/x.height),w={width:x.width*k+80,height:x.height*k+80},{x:S,y:P,setX:R,setY:_,ref:T}=(0,i.useWheelScroll)({maxOffsetX:(w.width-v.width)/2,maxOffsetY:(w.height-v.height)/2}),{zoomIn:A,zoomOut:M}=(0,i.useZoom)(C,E),{selected:[L],setSelected:O,onSelectedKeyDown:I}=(0,i.useSelected)({maxCount:1}),{selected:[F],setSelected:D,onSelectedKeyDown:B}=(0,i.useSelected)({maxCount:1}),z={containerSize:v,targetSize:x,x:S,y:P,scale:k},U=(0,u.getSelectedSize)(L,t),N=(0,u.getTargetByPath)(L,t),j="content"===(null==N?void 0:N.kind)?N.parents.reduce(((e,t)=>{var n;return e+(null!=(n=t.rotate)?n:0)}),0):void 0,{regionAlignmentX:W,regionAlignmentY:G,changeOffsetByRegionAlignment:V,clearRegionAlignments:$}=(0,i.useRegionAlignment)(6/k),{offset:H,onStart:q,mask:Y,startPosition:X,resetDragMove:K}=(0,i.useDragMove)((()=>{$(),0===H.x&&0===H.y&&X?O((0,u.selectByPosition)(t,g(X,z),k)):n((e=>{const t=(0,u.getSelectedPosition)(L,e);t&&(t.x+=H.x,t.y+=H.y)}))}),{scale:k,parentRotate:j,transformOffset:(e,n)=>{if(n&&!n.shiftKey&&"template"===(null==N?void 0:N.kind)){const n=N.template;V(e,n,t.templates.filter((e=>e!==n)))}else $();return e}}),{offset:Z,onStart:Q,mask:J,center:ee,resetDragRotate:te}=(0,i.useDragRotate)((()=>{n((e=>{const t=(0,u.getTargetByPath)(L,e);"content"===(null==t?void 0:t.kind)&&(t.content.rotate=null==Z?void 0:Z.angle)}))}),{transform:e=>g(e,z),parentRotate:j,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/k),{offset:ae,onStart:se,mask:le,startPosition:ce,resetDragResize:ue}=(0,i.useDragResize)((()=>{ie(),n((e=>{const t=(0,u.getSelectedSize)(L,e),n=(0,u.getSelectedPosition)(L,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)&&U)return U.width/U.height},rotate:"content"===(null==N?void 0:N.kind)&&null!=(e=N.content.rotate)?e:0,parentRotate:j,transform:e=>g(e,z),transformOffset:(e,n,r)=>{if(n&&r&&!n.altKey&&"template"===(null==N?void 0:N.kind)){const n=N.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,z),g(n,z));void 0!==r&&O([r])}else O((0,u.selectByPosition)(t,g(e,z),k))}),(e=>e.shiftKey));(0,i.useGlobalKeyDown)((e=>{I(e),B(e),"Escape"===e.key?(ge(),te(),ue(),K()):(0,i.metaKeyIfMacElseCtrlKey)(e)&&("KeyZ"===e.code?e.shiftKey?f(e):r(e):"Minus"===e.code?M(e):"Equal"===e.code&&A(e))}));const he={x:H.x+ae.x,y:H.y+ae.y,width:ae.width,height:ae.height},me=X||ee||ce||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)D();else{const n=(0,u.selectByPosition)(t,g({x:e.clientX,y:e.clientY},z),k);(0,i.isSamePath)(n,F)||D(n)}},onMouseDown:e=>{pe(e,void 0)}},o().createElement(l.StyleGuideRenderer,{styleGuide:t,targetSize:x,x:S,y:P,scale:k,onStartSelect:pe,offset:he,rotate:null==Z?void 0:Z.angle,selected:L}),L&&o().createElement("div",{style:{position:"absolute",transform:`translate(${S}px, ${P}px) scale(${k})`,width:x.width,height:x.height,pointerEvents:"none"}},o().createElement(c.SelectionRenderer,{styleGuide:t,scale:k,selected:L,onStartMove:q,offset:he,rotate:null==Z?void 0:Z.angle,onStartRotate:Q,onStartResize:se})),F&&o().createElement("div",{style:{position:"absolute",transform:`translate(${S}px, ${P}px) scale(${k})`,width:x.width,height:x.height,pointerEvents:"none"}},o().createElement(s.HoverRenderer,{styleGuide:t,hovered:F})),o().createElement(i.Scrollbar,{value:S,type:"horizontal",containerSize:v.width,contentSize:w.width,onChange:R}),o().createElement(i.Scrollbar,{value:P,type:"vertical",containerSize:v.height,contentSize:w.height,onChange:_}),o().createElement(i.AlignmentLine,{type:"x",value:null!=W?W: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,z)}),o().createElement(i.AlignmentLine,{type:"y",value:null!=G?G: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,z)}),Y,J,le,de)}function g({x:e,y:t},n){var r,o,i,a,s,l,c,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!=(l=null==n?void 0:n.scale)?l:1),y:(null!=(u=null==(c=null==n?void 0:n.targetSize)?void 0:c.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)}}},5952:(e,t,n)=>{"use strict";n.d(t,{StyleGuideRenderer:()=>s});var r=n(7378),o=n.n(r),i=n(9397),a=n(3150);function s(e){const{x:t,y:n,scale:r,styleGuide:a,targetSize:s,onStartSelect:c,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(l,{key:e.id,template:e,styleGuide:a,path:[t],onStartSelect:c,selected:u,offset:p,rotate:d,scale:r,isSelected:(0,i.isSamePath)(u,[t])}))))}function l(e){const{template:t,selected:n,offset:r,rotate:i,onStartSelect:s,scale:l}=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/l+"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/l})`,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 c(e){var t,n,r,i,a,s;const{template:l,styleGuide:c,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:l.width+(e.isSelected&&null!=(r=null==d?void 0:d.width)?r:0),height:l.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)`}},l.contents.map(((t,n)=>o().createElement(u,{key:n,content:t,styleGuide:c,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(c,{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(c,{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:l,rotate:c}=e;return o().createElement("div",{style:{position:"absolute",boxSizing:"border-box",left:s.x+(null!=(t=null==l?void 0:l.x)?t:0),top:s.y+(null!=(n=null==l?void 0:l.y)?n:0),width:s.width+(null!=(r=null==l?void 0:l.width)?r:0),height:s.height+(null!=(i=null==l?void 0:l.height)?i:0),color:s.color,fontSize:s.fontSize,fontFamily:s.fontFamily,transform:`rotate(${null!=(a=null!=c?c:s.rotate)?a:0}deg)`}},s.text)}function d(e){var t,n,r,i,a;const{content:s,offset:l,rotate:c}=e;return o().createElement("img",{src:s.url,style:{position:"absolute",boxSizing:"border-box",left:s.x+(null!=(t=null==l?void 0:l.x)?t:0),top:s.y+(null!=(n=null==l?void 0:l.y)?n:0),width:s.width+(null!=(r=null==l?void 0:l.width)?r:0),height:s.height+(null!=(i=null==l?void 0:l.height)?i:0),transform:`rotate(${null!=(a=null!=c?c:s.rotate)?a:0}deg)`}})}function f(e){var t,n,r,i,a;const{content:s,offset:l,rotate:c}=e;return o().createElement("div",{style:{position:"absolute",boxSizing:"border-box",left:s.x+(null!=(t=null==l?void 0:l.x)?t:0),top:s.y+(null!=(n=null==l?void 0:l.y)?n:0),width:s.width+(null!=(r=null==l?void 0:l.width)?r:0),height:s.height+(null!=(i=null==l?void 0:l.height)?i:0),backgroundColor:s.color,transform:`rotate(${null!=(a=null!=c?c:s.rotate)?a:0}deg)`}})}},207:(e,t,n)=>{"use strict";n.d(t,{SelectionRenderer:()=>s});var r=n(7378),o=n.n(r),i=n(9397),a=n(3150);function s(e){var t,n,r,s;const{styleGuide:l,scale:c,selected:u,offset:p,rotate:d,onStartRotate:f,onStartResize:g}=e,h=(0,a.getTargetByPath)(u,l);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/c+"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:c,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/c})`,transformOrigin:"left bottom",cursor:"move",pointerEvents:"auto"},onMouseDown:m}));const x=h.content,v=(0,a.getTemplateContentSize)(x,l);if(!v)return null;const{width:b,height:C}=v;let E=o().createElement(o().Fragment,null,o().createElement("div",{style:{position:"absolute",boxSizing:"border-box",left:x.x+p.x,top:x.y+p.y,width:b+p.width,height:C+p.height,border:1/c+"px solid green",cursor:"move",pointerEvents:"auto",transform:`rotate(${null!=(t=null!=d?d:x.rotate)?t:0}deg)`},onMouseDown:m}),o().createElement("div",{style:{position:"absolute",boxSizing:"border-box",left:x.x+p.x,top:x.y+p.y,width:b+p.width,height:C+p.height,transform:`rotate(${null!=(n=null!=d?d:x.rotate)?n:0}deg)`}},o().createElement(i.RotationBar,{scale:c,onMouseDown:e=>{e.stopPropagation(),f((0,a.getRotatedCenter)(h,l))}}),o().createElement(i.ResizeBar,{scale:c,onMouseDown:g,rotate:(null!=(r=x.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)}},3150:(e,t,n)=>{"use strict";n.d(t,{getRotatedCenter:()=>y,getSelectedPosition:()=>l,getSelectedSize:()=>s,getTargetByPath:()=>c,getTemplateContentSize:()=>p,nameSize:()=>g,selectByPosition:()=>h,selectTemplateByArea:()=>d});var r=n(9397),o=(e,t)=>{if(t=Symbol[e])return t;throw Error("Symbol."+e+" is not defined")},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);if(!(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=c(e,t);if(!n)return;const r=n.template;return"content"===n.kind?p(n.content,t):r}function l(e,t){const n=c(e,t);if(n)return"template"===n.kind?n.template:n.content}function c(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,l,c;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:x}=null!=(l=p(d,n))?l:{width:0,height:0};let v={x:g+y/2,y:h+x/2},b=null!=(c=d.rotate)?c:0;for(const e of o)b+=e.rotate,v=(0,r.rotatePositionByCenter)(v,e,-e.rotate);g=v.x-y/2,h=v.y-x/2,yield{x:g,y:h,rotate:b,width:y,height:x,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:l}=null!=(o=p(e.content,t))?o:{width:0,height:0};i.x+=e.content.x+s/2,i.y+=e.content.y+l/2;for(const e of a)i=(0,r.rotatePositionByCenter)(i,e,-e.rotate);return i}},5982:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(7378),o=n.n(r),i=n(9397);const a=()=>{const[e,t]=o().useState(0),[n,r]=o().useState(0),{offset:a,onStart:s,mask:l,resetDragMove:c}=(0,i.useDragMove)((()=>{t((e=>e+a.x)),r((e=>e+a.y))}));return(0,i.useGlobalKeyDown)((e=>{"Escape"===e.key&&c()})),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})}),l)}},6681:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(5188),o=n(7378),i=n.n(o),a=n(9397);const s=()=>{const[e,t]=i().useState({x:200,y:200,width:100,height:100}),{offset:n,onStart:o,mask:s,resetDragResize:l}=(0,a.useDragResize)((()=>t(c)),{centeredScaling:e=>e.shiftKey,keepRatio:t=>(0,a.metaKeyIfMacElseCtrlKey)(t)?e.width/e.height:void 0});(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&l()}));const c=(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:`${c.width}px`,height:`${c.height}px`,left:`${c.x}px`,top:`${c.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)}},6405:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(5188),o=n(7378),i=n.n(o),a=n(9397);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:l}=(0,a.useDragRotate)((()=>t(c)),{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&&l()}));const c=(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(${c.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)}},2309:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(5188),o=n(7378),i=n.n(o),a=n(9397);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)}},4981:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(7378),o=n.n(r),i=n(9397);const a=()=>{var e;const[t,n]=o().useState({x:300,y:200,r:100}),{editPoint:r,updateEditPreview:a,onEditMove:s,onEditClick:l,getEditAssistentContents:c,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(...c(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&&l({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"})))))}},1456:(e,t,n)=>{"use strict";n.d(t,{default:()=>l});var r=n(5188),o=n(7378),i=n.n(o),a=n(9397),s=n(1240);const l=()=>{const[e,t]=i().useState([]),{ellipse:n,ellipseArc:o,onClick:l,onMove:c,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=>l({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=>l({x:e.clientX,y:e.clientY}),onMouseMove:e=>c({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)}},372:(e,t,n)=>{"use strict";n.d(t,{default:()=>y});var r=n(5188),o=n(7378),i=n.n(o),a=n(9397),s=n(1240),l=Object.defineProperty,c=Object.defineProperties,u=Object.getOwnPropertyDescriptors,p=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,f=Object.prototype.propertyIsEnumerable,g=(e,t,n)=>t in e?l(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)=>c(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:l,reset:c}=(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&&c()}));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}))})),l)}},4582:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(5188),o=n(7378),i=n.n(o),a=n(9397);const s=()=>{const[e,t]=i().useState([]),{ellipse:n,onClick:o,onMove:s,input:l,reset:c}=(0,a.useEllipseClickCreate)("ellipse center",(n=>{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("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})))),l)}},233:(e,t,n)=>{"use strict";n.d(t,{default:()=>m});var r=n(5188),o=n(7378),i=n.n(o),a=n(9397),s=Object.defineProperty,l=Object.defineProperties,c=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)=>l(e,c(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:l}=(0,a.useEllipseEdit)((()=>t(c))),c=(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&&l()})),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:c.cx,cy:c.cy,rx:c.rx,ry:c.ry,transform:c.angle?`rotate(${c.angle},${c.cx},${c.cy})`:void 0})),i().createElement(a.EllipseEditBar,h(g({},c),{onMouseDown:(e,t,n)=>o(e,h(g({},c),{type:t,cursor:n}))})),s)}},8572:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(2845),o=n(7378),i=n.n(o),a=n(9397);const s=()=>{const[e,t]=i().useState("X1 ** 2 + X2 * X3"),[n,o]=i().useState("(-X6) ** 0.5 / (X4 - X5 ** 3)"),[s,l]=i().useState(),[c,u]=i().useState(!1);return i().useEffect((()=>{try{l({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:c,onChange:()=>u(!c)}),"keep binary expression order"),s&&(0,a.renderEquation)(a.reactSvgRenderTarget,s,{keepBinaryExpressionOrder:c}),s&&i().createElement("code",null,(0,a.printEquation)(s,{keepBinaryExpressionOrder:c})))}},708:(e,t,n)=>{"use strict";n.d(t,{default:()=>g});var r=n(2845),o=n(7378),i=n.n(o),a=n(9397),s=Object.defineProperty,l=Object.defineProperties,c=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),[x,v]=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))})})))},l(b,c(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:x,onChange:()=>v(!x)}),"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},!x&&(0,a.renderEquation)(a.reactSvgRenderTarget,e,{keepBinaryExpressionOrder:m}),x&&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}},9672:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(7378),o=n.n(r),i=n(9397),a=n(2845);const s=()=>{const[e,t]=o().useState("sin(x)"),[n,r]=o().useState(),[s,l]=o().useState(0),[c,u]=o().useState(10),[p,d]=o().useState(!0),[f,g]=o().useState(),h=(0,i.useWindowSize)().width/2,m=i.reactSvgRenderTarget,[y,x]=o().useState();let v;return y&&(v=y.children,n&&(v=[...y.children,...(0,i.renderChartTooltip)(m,n,n.value)])),o().createElement("div",{style:{position:"absolute",inset:"0px"}},y&&v&&o().createElement("div",null,m.renderResult(v,h,300,{attributes:{onMouseMove:e=>r(y.select({x:e.clientX,y:e.clientY}))}})),o().createElement("div",{style:{margin:"10px"}},o().createElement(i.StringEditor,{style:{width:"calc(50% - 30px)",height:"150px"},textarea:!0,value:e,setValue:t}),o().createElement("div",null,o().createElement("label",null,o().createElement("input",{type:"checkbox",checked:p,onChange:()=>d(!p)}),"input math style expression")),o().createElement("div",null,o().createElement(i.NumberEditor,{style:{width:"50px"},value:s,setValue:l}),"~",o().createElement(i.NumberEditor,{style:{width:"50px"},value:c,setValue:u})),o().createElement(i.Button,{disabled:!e,onClick:()=>{try{if(!e)return;const n=(t=e,(0,a.parseExpression)((0,a.tokenizeExpression)(p?(0,i.mathStyleExpressionToExpression)(t):t))),r=[],o=(c-s)/100;for(let e=s;e<=c;e+=o){const t=(0,a.evaluateExpression)(n,{sin:Math.sin,cos:Math.cos,tan:Math.tan,x:e});"number"!=typeof t||isNaN(t)||r.push({x:e,y:t})}const l=(0,i.getLineChart)([r,[{x:s,y:0},{x:c,y:0}]],m,{x:.01,y:.01},{width:h,height:300},{left:25,right:25,top:10,bottom:20},{xLabelDisabled:!0,yLabelDisabled:!0});if(!l)return;const{points:[u,d],children:f,select:y}=l;f.push(m.renderPolyline(d,{strokeColor:65280})),f.push(m.renderPolyline(u,{strokeColor:16711680})),x({children:f,select:y}),g(void 0)}catch(e){console.info(e),g(String(e))}var t}},"draw chart"),f&&o().createElement("div",null,f)))}},1711:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(7378),o=n.n(r),i=n(9397),a=n(325);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})}},5704:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(7378),o=n.n(r),i=n(9397),a=n(2845);const s=()=>{const[e,t]=o().useState("(x + a)^3"),[n,r]=o().useState("x"),[s,l]=o().useState(""),[c,u]=o().useState(!0),[p,d]=o().useState(!0),[f,g]=o().useState(),[h,m]=o().useState(),[y,x]=o().useState(),v=e=>(0,a.parseExpression)((0,a.tokenizeExpression)(c?(0,i.mathStyleExpressionToExpression)(e):e)),b=e=>p?(0,i.printMathStyleExpression)(e):(0,a.printExpression)(e),C=e=>{t(e),g(void 0),m(void 0),x(void 0)};return o().createElement("div",null,o().createElement(i.StringEditor,{style:{width:"calc(100% - 30px)",height:"150px"},textarea:!0,value:e,setValue:C}),o().createElement("div",null,o().createElement("label",null,o().createElement("input",{type:"checkbox",checked:c,onChange:()=>u(!c)}),"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:l})),o().createElement(i.Button,{disabled:!e,onClick:()=>{try{if(!e)return;const t=(0,i.expandExpression)(v(e));let n=(0,i.expressionToFactors)(t);n?(n=(0,i.optimizeFactors)(n),(0,i.sortFactors)(n),m(n),x(void 0)):(x(t),m(void 0)),g(void 0)}catch(e){console.info(e),g(String(e)),m(void 0),x(void 0)}}},"expand all"),o().createElement(i.Button,{disabled:!n||!h,onClick:()=>{try{if(!n)return;if(!h)return;const e=v(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=v(n),t=(0,i.expressionToFactors)(e);if(t&&1===t.length){const e=(0,i.groupFactorsBy)(h,t[0]);e&&x(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=v(e),r=v(s),o=(0,i.composeExpression)(t,{[n]:r});o&&x(o),g(void 0)}catch(e){g(String(e))}}},"replace with"),o().createElement(i.Button,{disabled:!e,onClick:()=>{try{if(!e)return;const t=v(e);x(t),g(void 0)}catch(e){g(String(e)),x(void 0)}}},"format style"),o().createElement(i.Button,{disabled:!h,onClick:()=>{h&&x((0,i.groupAllFactors)(h))}},"group all"),o().createElement(i.Button,{disabled:!e||!n,onClick:()=>{try{if(!n)return;if(!e)return;const t=v(e),r=(0,i.deriveExpressionWith)(t,n);x(r),g(void 0)}catch(e){g(String(e)),x(void 0)}}},"derive with"),o().createElement(i.Button,{disabled:!e,onClick:()=>{try{if(!e)return;const t=v(e),n=(0,i.optimizeExpression)(t);x(n),g(void 0)}catch(e){g(String(e)),x(void 0)}}},"optimize"),o().createElement(i.Button,{disabled:!n||!h,onClick:()=>{try{if(!n)return;if(!h)return;const e=v(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&&x(e)}g(void 0)}catch(e){g(String(e))}}},"group by variables"),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:()=>C(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:()=>C(b(y))},"edit")),y&&(0,i.renderExpression)(i.reactSvgRenderTarget,y),f&&o().createElement("div",null,f))}},325:(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}]}]}]},9350:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(5188),o=n(7378),i=n.n(o),a=n(9397);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,l]=i().useState("top"),{renderEditor:c,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,x=[];u.forEach(((e,t)=>{e.forEach((({x:e,y:n,content:r,visible:o,row:i},a)=>{o&&(d([t,a])&&x.push(y.renderRect(e,n,2*r.radius,p[i],{fillColor:11785981,strokeWidth:0})),x.push(y.renderCircle(e+r.radius,n+p[i]/2,r.radius,{fillColor:r.color,strokeWidth:0})))}))}));const v=y.renderResult(x,400,f);return i().createElement(i().Fragment,null,c(v),i().createElement(a.EnumEditor,{enums:a.aligns,value:n,setValue:o}),i().createElement(a.EnumEditor,{enums:a.verticalAligns,value:s,setValue:l}))}},8149:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(5188),o=n(7378),i=n.n(o),a=n(9397);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,l]=i().useState("top"),{renderEditor:c,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 x=m.renderResult(y,400,f);return i().createElement(i().Fragment,null,c(x),i().createElement(a.EnumEditor,{enums:a.aligns,value:n,setValue:o}),i().createElement(a.EnumEditor,{enums:a.verticalAligns,value:s,setValue:l}))}},9800:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(5188),o=n(7378),i=n.n(o),a=n(9397);const s=()=>{const[e,t]=i().useState((()=>"1 + 2 = 3".split(""))),[n,o]=i().useState("left"),[s,l]=i().useState("top"),{renderEditor:c,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,c({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:l}))}},4195:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(5188),o=n(7378),i=n.n(o),a=n(9397);const s=()=>{const[e,t]=i().useState([]),{image:n,onClick:o,onMove:s,input:l,reset:c}=(0,a.useImageClickCreate)(!0,(n=>{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("image",{key:t,href:e.url,x:e.x,y:e.y,width:e.width,height:e.height})))),l)}},7239:(e,t,n)=>{"use strict";n.d(t,{stories:()=>ue});var r=n(5207),o=n(6295),i=n(9474),a=n(8022),s=n(79),l=n(5559),c=n(3102),u=n(9879),p=n(1940),d=n(5982),f=n(6681),g=n(6405),h=n(2309),m=n(4981),y=n(1456),x=n(372),v=n(4582),b=n(233),C=n(8572),E=n(708),k=n(9672),w=n(1711),S=n(5704),P=n(9350),R=n(8149),_=n(9800),T=n(4195),A=n(116),M=n(5333),L=n(2968),O=n(4600),I=n(900),F=n(1934),D=n(8412),B=n(1482),z=n(8076),U=n(1255),N=n(1354),j=n(1974),W=n(1667),G=n(6067),V=n(6165),$=n(1926),H=n(6141),q=n(7767),Y=n(9332),X=n(3892),K=n(3542),Z=n(6110),Q=n(3524),J=n(9594),ee=n(1879),te=n(7701),ne=n(8041),re=n(9681),oe=n(4796),ie=n(83),ae=n(2503),se=n(6956),le=n(5454),ce=n(7817);const ue=[{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 }>\n const size = useWindowSize()\n const width = size.width / 2 - 30\n const [font, setFont] = React.useState()\n const cache = React.useRef(new MapCache2())\n const getTextLayout = (text: string, fontSize: number) => {\n if (!font || !text) return\n return cache.current.get(text, fontSize, () => {\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 return {\n commands: opentypeCommandsToPathCommands(path),\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 j', attributes: { color: 0xff0000 } }])\n const [align, setAlign] = React.useState('left')\n const [verticalAlign, setVerticalAlign] = React.useState('top')\n const getColor = (content: AttributedText) => content?.attributes?.color ?? 0x000000\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 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.2\n const getWidth = (content: AttributedText) => {\n if (content.attributes?.stackText) {\n const width = content.insert.split('').reduce((p, c) => p + (getTextLayout(c, getComputedFontSize(content))?.width ?? 0), 0)\n const stackWidth = content.attributes.stackText.split('').reduce((p, c) => p + (getTextLayout(c, getComputedFontSize(content))?.width ?? 0), 0)\n return Math.max(stackWidth, width)\n }\n return getTextLayout(content.insert, getComputedFontSize(content))?.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 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 if (isSelected(i)) {\n children.push(target.renderRect(x, y, width, lineHeight, { fillColor: 0xB3D6FD, strokeWidth: 0 }))\n }\n const fontSize = getComputedFontSize(content)\n const layout = getTextLayout(content.insert, fontSize)\n if (layout) {\n const color = getColor(content)\n const backgroundColor = getBackgroundColor(content)\n if (!isSelected(i) && 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 }))\n }\n if (getPassThrough(content)) {\n children.push(target.renderPolyline([{ x, y: y + lineHeight / 2 }, { x: x + width, y: y + lineHeight / 2 }], { strokeColor: color }))\n }\n const pos = {\n x: x - layout.x1,\n 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 }))\n }\n children.push(target.renderGroup([target.renderPathCommands(layout.commands, { fillColor: color, strokeColor: color })], { translate: pos }))\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)\n if (stackLayout) {\n const stackPos = {\n x: x - stackLayout.x1 + (width - stackWidth) / 2 + xOffset,\n y: stackLayout.y1 + (lineHeight - getLineHeight(content)) + fontSize * 0.2,\n }\n xOffset += stackLayout.width\n children.push(target.renderGroup([target.renderPathCommands(stackLayout.commands, { fillColor: color, strokeColor: color })], { 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 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 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 }}\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) 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: [up.x, up.y, up.z],\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:l.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:c.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 },\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:x.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:v.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:k.default,code:"() => {\n const [value, setValue] = React.useState('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 [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) return\n const e = parseInputExpression(value)\n const points: Position[] = []\n const step = (max - min) / 100\n for (let x = min; x <= max; x += step) {\n const y = evaluateExpression(e, {\n sin: Math.sin,\n cos: Math.cos,\n tan: Math.tan,\n x,\n })\n if (typeof y === 'number' && !isNaN(y)) {\n points.push({ x, y })\n }\n }\n const r = getLineChart([points, [{ x: min, y: 0 }, { x: max, y: 0 }]], 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: [points1, points2], children, select } = r\n children.push(target.renderPolyline(points2, { strokeColor: 0x00ff00 }))\n children.push(target.renderPolyline(points1, { strokeColor: 0xff0000 }))\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 \n
\n \n
\n
\n \n ~\n \n
\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:S.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 = deriveExpressionWith(r, 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 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 {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:P.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 // eslint-disable-next-line plantain/promise-not-await\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 // eslint-disable-next-line plantain/promise-not-await\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:R.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 // eslint-disable-next-line plantain/promise-not-await\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 // eslint-disable-next-line plantain/promise-not-await\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:_.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:"keyboard-zoom.story",name:"",Component:A.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:L.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) 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: [up.x, up.y, up.z],\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:I.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:F.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:"minimap.story",name:"",Component:D.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:B.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:z.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:U.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:N.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, 1))}\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:j.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:G.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:V.default,code:"() => {\n const [position, setPosition] = React.useState()\n const startPosition = { x: 500, y: 100 }\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: { ...c, startAngle: 0, endAngle: 360 } }] }) })))),\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: { ...c, startAngle: 0, endAngle: 360 } }],\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 )\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 )\n if (position) {\n assistentContents.push({ type: 'polyline', points: [startPosition, position] })\n }\n\n return (\n <>\n setPosition(getSnapPoint({ x: e.clientX, y: e.clientY }, contents, undefined, startPosition).position)}\n >\n {contents.map((c, i) => )}\n {assistentContents.map((c, i) => {\n if (c.type === 'rect') {\n return \n }\n if (c.type === 'circle') {\n return \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:H.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:q.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:Y.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:X.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:K.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:Z.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 ], 230, 220)\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(110, 100, 80, 40, 0, 120, { strokeColor: 0x00ff00, angle: 30 }),\n ], 230, 230)\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 ], 230, 200)\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 ], 230, 570)\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 ], 230, 190)\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 ], 230, 90)\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 ]\n return target.renderResult([\n target.renderGroup(items, { opacity: 0.2 }),\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 ], { translate: { x: 10, y: 90 } })\n }),\n ], 230, 300)\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 )\n}",props:[],componentName:"",parentComponentName:""},{path:"region-alignment-line.story",name:"",Component:Q.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:J.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:ee.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:te.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:ne.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:re.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.story",name:"",Component:oe.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: 'cune',\n topRadius: 0,\n bottomRadius: 100,\n height: 200,\n },\n color: [1, 0, 1, 1],\n position: [0, -250, 0],\n },\n ])\n\n React.useEffect(() => {\n if (!ref.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: [position.x, position.y, position.z],\n up: [up.x, up.y, up.z],\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:ie.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),\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),\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),\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),\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) {\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:ae.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: 'cune',\n topRadius: 0,\n bottomRadius: 100,\n height: 200,\n },\n color: [1, 0, 1, 1],\n position: [0, -250, 0],\n },\n ])\n\n React.useEffect(() => {\n if (!ref.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: [position.x, position.y, position.z],\n up: [up.x, up.y, up.z],\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'))}\n />\n {moveCanvasMask}\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"wheel-scroll.story",name:"",Component:se.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:le.default,code:"() => {\n const { ref, scale } = useWheelZoom()\n return (\n \n \n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"window-size.story",name:"",Component:ce.default,code:"() => {\n const { width, height } = useWindowSize()\n\n return (\n
\n {Math.round(width)} {Math.round(height)}\n
\n )\n}",props:[],componentName:"",parentComponentName:""}]},116:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(7378),o=n.n(r),i=n(9397);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%)"}}))}},5333:(e,t,n)=>{"use strict";n.d(t,{default:()=>l});var r=n(5188),o=n(7378),i=n.n(o),a=n(9397),s=n(1077);const l=()=>{const[e,t]=i().useState(s.defaultContents),[n,o]=i().useState(0),{lineAlignmentX:l,lineAlignmentY:c,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:l}),i().createElement(a.AlignmentLine,{type:"y",value:c}),g)}},2968:(e,t,n)=>{"use strict";n.d(t,{default:()=>f});var r=n(7378),o=n.n(r),i=n(9397),a=Object.defineProperty,s=Object.defineProperties,l=Object.getOwnPropertyDescriptors,c=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:x,mask:v,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,k=C.height,[w,S]=o().useState(),P=y.x+h.x,R=y.y+h.y,_=o().useRef([]);return o().useEffect((()=>{e.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});_.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*P,-.3*R);null==(o=null==(e=t.current)?void 0:e.render)||o.call(e,_.current,{eye:[a.x+40,a.y+40,a.z],up:[s.x,s.y,s.z],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,P,R,w,E,k]),o().createElement("div",{style:{position:"absolute",inset:"0px"}},o().createElement("canvas",{ref:(0,i.bindMultipleRefs)(a,g,e),width:E,height:k,onMouseDown:e=>x({x:e.clientX,y:e.clientY}),onMouseMove:e=>{var n,r;S(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=_.current[o];t.position&&S({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(c)for(var n of c(t))p.call(t,n)&&d(e,n,t[n]);return e})({},w),A={label:(M=w.value[0]/20,Intl.DateTimeFormat("zh",{month:"long"}).format(new Date(M.toString()))),value:w.value[1]},s(T,l(A)))),v);var T,A,M}},4600:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(7378),o=n.n(r),i=n(9397);const a=()=>{const e=(0,i.useWindowSize)().width/2,t=i.reactSvgRenderTarget,[n,r]=o().useState(),[a,s]=o().useState(),l=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}))),c=[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,c],t,{x:1,y:5},{width:e,height:300},{left:25,right:25,top:10,bottom:20},{getXLabel:l,ySecondary:!0});if(!u)return;const{points:[p,d,f,g,h],children:m,select:y,minY:x}=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:x},{x:g[0].x,y:x}],{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 c=a.children;return n&&(c=[...a.children,...(0,i.renderChartTooltip)(t,n,n.value,{getXLabel:l})]),o().createElement("div",{style:{position:"absolute",inset:"0px"}},t.renderResult(c,e,300,{attributes:{onMouseMove:e=>r(a.select({x:e.clientX,y:e.clientY}))}}))}},900:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(5188),o=n(7378),i=n.n(o),a=n(9397);const s=()=>{const[e,t]=i().useState([]),{line:n,onClick:o,onMove:s,input:l,reset:c}=(0,a.useLineClickCreate)(!0,(n=>{t((0,r.produce)(e,(e=>{e.push(n)})))}));return(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&c(!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(" ")})))),l)}},1934:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(7378),o=n.n(r),i=n(9397),a=n(1240);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:l}=(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}},l))}},8412:(e,t,n)=>{"use strict";n.d(t,{default:()=>p});var r=n(7378),o=n.n(r),i=n(9397),a=Object.defineProperty,s=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,c=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}},x=[f.renderImage("https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg",0,0,1200,800)],{setMinimapTransform:v,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(x,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&&v(((e,t)=>{for(var n in t||(t={}))l.call(t,n)&&u(e,n,t[n]);if(s)for(var n of s(t))c.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(x,h,m,{transform:y,attributes:{style:{border:"1px solid green"}}}),b)}},1482:(e,t,n)=>{"use strict";n.d(t,{default:()=>l});var r=n(7378),o=n.n(r),i=n(8266),a=n(9397),s=n(4918);const l=()=>{const e=(0,a.useWindowSize)().width/2,{x:t,y:n,ref:r,setX:l,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);l(o.setX),u(o.setY)}}),[g,h]=o().useState(),[m,y]=o().useState("测试ABC"),[x,v]=o().useState(s.allFonts[0].name),[b,C]=o().useState(50),[E,k]=o().useState(0),[w,S]=o().useState(16777215),[P,R]=o().useState(1),[_,T]=o().useState(1),[A,M]=o().useState([]),[L,O]=o().useState(c[0]),I=null==g?void 0:g[x];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),l(0),u(0),e.preventDefault())})),o().useEffect((()=>{if(!I)return;const e=I.getPaths(m,0,b,b,{xScale:P*b/I.unitsPerEm,yScale:_*b/I.unitsPerEm}).map((e=>(0,s.opentypeCommandsToPathCommands)(e)));M(e)}),[m,I,b,L,P,_]);const F=A.map((e=>L.renderPathCommands(e,{fillColor:E,strokeColor:E}))).flat();return F.push(L.renderText(0,2*b,m,E,b*Math.max(P,_),x)),o().createElement("div",{style:{position:"absolute",inset:"0px"},ref:(0,a.bindMultipleRefs)(f,r)},L.renderResult(F,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:x,enums:s.allFonts.map((e=>e.name)),setValue:e=>{var t,n;return v(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:L.type,enums:c.map((e=>e.type)),setValue:e=>{var t;return O(null!=(t=c.find((t=>t.type===e)))?t:c[0])}}),color:o().createElement(a.NumberEditor,{type:"color",value:E,setValue:e=>k(e)}),"background color":o().createElement(a.NumberEditor,{type:"color",value:w,setValue:e=>S(e)}),"x scale":o().createElement(a.NumberEditor,{value:P,setValue:e=>R(e)}),"y scale":o().createElement(a.NumberEditor,{value:_,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")}})))},c=[a.reactCanvasRenderTarget,a.reactSvgRenderTarget,a.reactWebglRenderTarget]},4918:(e,t,n)=>{"use strict";function r(e){return e.commands.map((e=>"M"===e.type?{type:"move",to:e}:"L"===e.type?{type:"line",to:e}:"C"===e.type?{type:"bezierCurve",cp1:{x:e.x1,y:e.y1},cp2:{x:e.x2,y:e.y2},to:e}:"Q"===e.type?{type:"quadraticCurve",cp:{x:e.x1,y:e.y1},to:e}:{type:"close"}))}n.d(t,{allFonts:()=>o,opentypeCommandsToPathCommands:()=>r});const o=[{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"}]},8076:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(5188),o=n(7378),i=n.n(o),a=n(9397);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)))))}},1255:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(7378),o=n.n(r),i=n(9397);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)}},1354:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(5188),o=n(7378),i=n.n(o),a=n(9397);const s=()=>{const[e,t]=i().useState([]),{preview:n,onClick:o,onMove:s,input:l,setInputType:c,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)))),["line","arc","bezierCurve","quadraticCurve","close"].map((e=>i().createElement("button",{key:e,style:{position:"relative"},onClick:()=>c(e)},e))),l)}},1974:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(5188),o=n(7378),i=n.n(o),a=n(9397);const s=()=>{const[e,t]=i().useState([]),{points:n,onClick:o,onMove:s,reset:l}=(0,a.usePenClickCreate)(!0,(()=>{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("polyline",{key:t,stroke:"#00ff00",points:e.map((e=>`${e.x},${e.y}`)).join(" ")})))))}},1667:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(7378),o=n.n(r),i=n(9397);const a=()=>{var e,t;const n=(0,i.useWindowSize)(),r=n.width/2,a=n.height,s=i.reactCanvasRenderTarget,l={x:r/2,y:a/3},[c,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,x,v]=(0,i.useRefState)(!1),[b,C,E]=(0,i.useRefState2)(),k=null!=(e=null!=b?b:h)?e:f,w=null!=(t=null==h?void 0:h.length)?t:c,S={x:l.x-w*Math.sin(k.radian),y:l.y+w*Math.cos(k.radian),r:10},P=(0,i.getPointByLengthAndRadian)(S,k.speed*w+S.r*(k.speed>=0?1:-1),(0,i.getTwoPointsRadian)(S,l)+Math.PI/2),R=[s.renderCircle(l.x,l.y,5),s.renderCircle(S.x,S.y,S.r,{fillColor:0,strokeWidth:0}),s.renderPolyline([l,S]),s.renderPolyline([S,P])],_=(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,l)-Math.PI/2,speed:0,length:(0,i.getTwoPointsDistance)(t,l)})}}));return o().createElement("div",{style:{position:"absolute",inset:"0px"},onMouseMove:T},s.renderResult(R,r,a,{attributes:{onClick:_}}),o().createElement("div",{style:{position:"absolute",top:"0px"}},o().createElement(i.Button,{onClick:()=>{if(v.current)return void x(!1);let e;x(!0);const t=n=>{var r;if(v.current){if(void 0!==e){const t=.005*(n-e),o=null!=(r=E.current)?r:f,i=l.y+w*Math.cos(f.radian),a=l.y+w*Math.cos(o.radian),s=9.8;let c=o.speed-s*Math.sin(o.radian)/w*t;if(a!==i){const e=Math.sqrt(s*Math.abs(a-i)*2)/w;e{x(!1),C(void 0)}},"stop"),void 0===b&&o().createElement(i.Button,{style:{color:p?"red":void 0},onClick:()=>d(!0)},"edit")))}},6067:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(7378),o=n.n(r),i=n(9397);const a=()=>{const e=(0,i.useWindowSize)().width/2,t=350,n=i.reactSvgRenderTarget,[r,a]=o().useState(),[s,l]=o().useState(),[c,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]),!c||!p)return null;let g=c.children;r&&(g=[...c.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(c.select({x:e.clientX,y:e.clientY}))}}),n.renderResult(h,e,t,{attributes:{onMouseMove:e=>l(p.select({x:e.clientX,y:e.clientY-t}))}}))}},6165:(e,t,n)=>{"use strict";n.d(t,{default:()=>y});var r=n(7378),o=n.n(r),i=n(9397),a=Object.defineProperty,s=Object.defineProperties,l=Object.getOwnPropertyDescriptors,c=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(c)for(var n of c(t))p.call(t,n)&&d(e,n,t[n]);return e},g=(e,t)=>s(e,l(t));const h=new i.WeakmapCache2,m=[{x:300,y:200,r:100},{x:450,y:350,r:130}],y=()=>{const[e,t]=o().useState(),n={x:500,y:100},{getSnapAssistentContents:r,getSnapPoint:a}=(0,i.usePointSnap)(!0,((e,t)=>h.get(e,t,(()=>Array.from((0,i.iterateIntersectionPoints)(e,t,m,(()=>({getGeometries:e=>({lines:[{type:"arc",curve:g(f({},e),{startAngle:0,endAngle:360})}]})}))))))),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:g(f({},e),{startAngle:0,endAngle:360})}],bounding:{start:{x:e.x-e.r,y:e.y-e.r},end:{x:e.x+e.r,y:e.y+e.r}}})}))),s=r((e=>f({type:"circle"},e)),(e=>f({type:"rect"},e)),(e=>({type:"polyline",points:e})));return e&&s.push({type:"polyline",points:[n,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},onMouseMove:e=>t(a({x:e.clientX,y:e.clientY},m,void 0,n).position)},m.map(((e,t)=>o().createElement("circle",{key:t,cx:e.x,cy:e.y,r:e.r,stroke:"#00ff00"}))),s.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"}):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"})))}},1926:(e,t,n)=>{"use strict";n.d(t,{default:()=>f});var r=n(7378),o=n.n(r),i=n(9397),a=Object.defineProperty,s=Object.defineProperties,l=Object.getOwnPropertyDescriptors,c=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(c)for(var n of c(t))p.call(t,n)&&d(e,n,t[n]);return e})({},n.circle),f={r:n.circle.r+30},s(a,l(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}))}}))}},6141:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(5188),o=n(7378),i=n.n(o),a=n(9397);const s=()=>{const[e,t]=i().useState([]),{polygon:n,onClick:o,onMove:s,input:l,reset:c}=(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&&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("polygon",{key:t,stroke:"#00ff00",points:e.map((e=>`${e.x},${e.y}`)).join(" ")})))),l)}},7767:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(5188),o=n(7378),i=n.n(o),a=n(9397);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:l}=(0,a.usePolylineEdit)((()=>t(c))),c=(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&&l()})),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:c.map((e=>`${e.x},${e.y}`)).join(" ")})),i().createElement(a.PolylineEditBar,{points:c,onMouseDown:(e,t)=>o(e,t)}),s)}},9332:(e,t,n)=>{"use strict";n.d(t,{default:()=>f});var r=n(7378),o=n.n(r),i=n(9397),a=Object.defineProperty,s=Object.defineProperties,l=Object.getOwnPropertyDescriptors,c=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(c)for(var n of c(t))p.call(t,n)&&d(e,n,t[n]);return e})({},n.circle),f={r:n.circle.r+15},s(a,l(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}))}}))}},3892:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(7378),o=n.n(r),i=n(9397),a=n(1240);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:l,text:c}=(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:l}),style:{fontSize:`${t.fontSize}px`,fontFamily:t.fontFamily}},c))}},3542:(e,t,n)=>{"use strict";n.d(t,{default:()=>g});var r=n(7378),o=n(9397),i=Object.defineProperty,a=Object.defineProperties,s=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,c=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={}))c.call(t,n)&&p(e,n,t[n]);if(l)for(var n of l(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}}))))}},6110:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(7378),o=n.n(r),i=n(9397),a=n(6345);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})],230,220),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(110,100,80,40,0,120,{strokeColor:65280,angle:30})],230,230),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})],230,200),l=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),c=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})],230,570),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]})],230,190),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})],230,90),g=e=>{const t=[e.renderCircle(50,50,20),e.renderCircle(50,50,35),e.renderText(0,40,"abc",16711680,30,"monospace")];return e.renderResult([e.renderGroup(t,{opacity:.2}),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})}})],{translate:{x:10,y:90}})})],230,300)},{setOffset:h}=o().useContext(a.OffsetXContext);return o().useEffect((()=>{navigator.gpu&&(null==h||h(230))}),[h]),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),l(i.reactSvgRenderTarget),l(i.reactCanvasRenderTarget),l(i.reactWebglRenderTarget),navigator.gpu&&l(i.reactWebgpuRenderTarget),o().createElement("br",null),c(i.reactSvgRenderTarget),c(i.reactCanvasRenderTarget),c(i.reactWebglRenderTarget),navigator.gpu&&c(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))}},3524:(e,t,n)=>{"use strict";n.d(t,{default:()=>l});var r=n(5188),o=n(7378),i=n.n(o),a=n(9397),s=n(1077);const l=()=>{const[e,t]=i().useState(s.defaultContents),[n,o]=i().useState(0),{regionAlignmentX:l,regionAlignmentY:c,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:l}),i().createElement(a.AlignmentLine,{type:"y",value:c}),g)}},4405:(e,t,n)=>{"use strict";n.d(t,{useAt:()=>p});var r=n(7378),o=n.n(r),i=Object.defineProperty,a=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,c=(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)&&c(e,n,t[n]);if(a)for(var n of a(t))l.call(t,n)&&c(e,n,t[n]);return e};const p=({cursor:e,cursorHeight:t,inputText:n})=>{const[r,i]=o().useState(""),[a,s]=o().useState(0),l={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},l);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},l);n([o," "]),i("")}},r+"_"+t)))):void 0}}},1037:(e,t,n)=>{"use strict";n.d(t,{h1:()=>r,h2:()=>o,h3:()=>i,h4:()=>a,h5:()=>s,h6:()=>l,hr:()=>d,ol:()=>p,p:()=>c,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},l={blockStart:2.33,blockEnd:2.33},c={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}},6946:(e,t,n)=>{"use strict";n.d(t,{circle:()=>h,useCircle:()=>m});var r=n(7378),o=n.n(r),i=n(9397),a=Object.defineProperty,s=Object.defineProperties,l=Object.getOwnPropertyDescriptors,c=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(c)for(var n of c(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),c=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:c/2+"px",width:`${c}px`,height:`${c}px`,display:"inline-flex",justifyContent:"center"},s(n,l(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}}},4090:(e,t,n)=>{"use strict";n.d(t,{image:()=>s,useImage:()=>l});var r=n(7378),o=n.n(r),i=n(9397);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})}},l=({inputText:e,currentContent:t,currentContentLayout:n,updateCurrentContent:r,setResizeOffset:s})=>{const[l,c]=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:l,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}," "])}}),c(t),setTimeout((()=>{c("")}),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}}},4615:(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={}},9107:(e,t,n)=>{"use strict";n.d(t,{link:()=>s,useLink:()=>l});var r=n(7378),o=n.n(r),i=n(9397);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)}},l=({inputText:e,currentContent:t,updateCurrentContent:n})=>{var r;const[s,l]=o().useState(""),c={"insert link":o().createElement(i.StringEditor,{value:s,setValue:t=>{t&&(e([{type:"link",text:t,targetBlank:!0,url:t}," "]),l(t),setTimeout((()=>{l("")}),0))}})};return t&&a(t)&&(c["link text"]=o().createElement(i.StringEditor,{value:t.text,setValue:e=>n((t=>{a(t)&&(t.text=e)}))}),c["link url"]=o().createElement(i.StringEditor,{value:t.url,setValue:e=>n((t=>{a(t)&&(t.url=e)}))}),c["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:c}}},1247:(e,t,n)=>{"use strict";n.d(t,{stack:()=>h,useStack:()=>m});var r=n(7378),o=n.n(r),i=n(9397),a=Object.defineProperty,s=Object.defineProperties,l=Object.getOwnPropertyDescriptors,c=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(c)for(var n of c(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,l(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}}},6214:(e,t,n)=>{"use strict";n.d(t,{backgroundColor:()=>f,bold:()=>l,color:()=>d,fontFamily:()=>s,fontSize:()=>a,italic:()=>c,passThrough:()=>p,underline:()=>u});var r=n(7378),o=n.n(r),i=n(9397);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"}})},l=(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))})},c=(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))})}},7866:(e,t,n)=>{"use strict";n.d(t,{RichTextEditor:()=>s});var r=n(7378),o=n.n(r),i=n(9397),a=n(5188);const s=o().forwardRef(((e,t)=>{var n,r,s,l,c;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:x,currentBlock:v,currentContentLayout:b,inputText:C,layoutResult:E,cursor:k,inputContent:w,location:S,scrollY:P,updateSelection:R,updateTextInline:_,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 M)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}),M=[],L=[],O={};if(null==(n=e.plugin)?void 0:n.hooks){const t={cursor:k,cursorHeight:k.height,inputText:C,inputContent:w,currentContent:x,currentContentLayout:b,updateCurrentContent:A,setResizeOffset:m};e.plugin.hooks.forEach(((e,n)=>{const{processInput:r,ui:i,propertyPanel:a}=e(t);r&&M.push(r),i&&L.push(o().cloneElement(i,{key:n})),a&&Object.assign(O,a)}))}const[I,F]=o().useState([]);o().useImperativeHandle(t,(()=>({handlePatchesEvent(e){try{g(e.patches,e.reversePatches,e.operator)}catch(e){console.error(e)}},handleLocationEvent(e){F((0,a.produce)(I,(t=>{var n,r;const o=I.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 D=[];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=I.filter((e=>e.location[0]===t&&e.location[1]===i));s.length>0&&D.push(o().createElement("div",{style:{position:"absolute",left:e+"px",top:n+P+"px",width:"2px",height:r+"px",backgroundColor:"red"}}),o().createElement("span",{style:{position:"absolute",left:e+"px",top:n+P+r+"px",fontSize:"12px",fontFamily:a,color:"red"}},s.map((e=>e.operator)).join(",")))}))})),(null==(s=e.plugin)?void 0:s.styles)&&x&&(0,i.isHtmlText)(x))for(const t in e.plugin.styles)O[t]=e.plugin.styles[t](x,v,R);return(null==(l=e.plugin)?void 0:l.textInlines)&&(O.textInlines=o().createElement("div",null,(0,i.getKeys)(e.plugin.textInlines).map((e=>o().createElement(i.Button,{key:e,style:{fontWeight:x&&(0,i.isHtmlText)(x)&&x.type===e?"bold":void 0},onClick:()=>_(e)},e))))),(null==(c=e.plugin)?void 0:c.blocks)&&(O.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[S[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,D)),o().createElement(i.ObjectEditor,{inline:!0,properties:O})),L)}))},9594:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(7378),o=n.n(r),i=n(9397);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}))}},1879:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(7378),o=n.n(r),i=n(9397);const a=()=>{const{isSelected:e,addSelection:t,filterSelection:n,executeOperation:r,selectBeforeOperate:a,message:s,onSelectBeforeOperateKeyDown:l}=(0,i.useSelectBeforeOperate)({},((e,t)=>(alert(t.map((([e])=>e)).join(",")),!0)));(0,i.useGlobalKeyDown)((e=>{l(e)}));const c=(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:()=>c()},"select count ",">"," 0"),o().createElement("button",{onClick:()=>c(3)},"select count = 3"),o().createElement("button",{onClick:()=>c(void 0,(([e])=>e%2==1))},"select count ",">"," 0 && i % 2 === 1"),o().createElement("button",{onClick:()=>c(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)}},7701:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(7378),o=n.n(r),i=n(9397);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))))}},6345:(e,t,n)=>{"use strict";n.d(t,{OffsetXContext:()=>v});var r=n(7634),o=n(7378),i=n.n(o),a=(n(6704),n(5882),n(4601)),s=n(7239),l=n(7456),c=n(9397),u=n(8497),p=n(3501),d=n(2734),f=n(6717),g=n(5031),h=n(1509),m=n(1423);const y=[{path:"whiteboard",name:"whiteboard",component:u.WhiteBoard},{path:"index",name:"combination 1",component:l.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}];function x(){const[,e]=(0,a.useLocation)(i()),[t,n]=i().useState(0),{onStart:r,offset:o,mask:l}=(0,c.useDragMove)((()=>{n((e=>e+o.x))}));if(!e)return i().createElement("ul",{style:{margin:"20px 50px"}},y.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=y.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(v.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(b,{code:e.code})),l);return null}const v=i().createContext({offset:0});function b(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 C=document.querySelector("#container");C&&(0,r.createRoot)(C).render(i().createElement(x,null))},1077:(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"}]},8041:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(5188),o=n(7378),i=n.n(o),a=n(9397);const s=()=>{const[e,t]=i().useState([]),{text:n,onClick:o,onMove:s,input:l,reset:c}=(0,a.useTextClickCreate)(!0,(n=>{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("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)))),l)}},9681:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(7378),o=n.n(r),i=n(9397);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)}},4796:(e,t,n)=>{"use strict";n.d(t,{default:()=>i});var r=n(7378),o=n(9397);const i=()=>{const e=r.useRef(null),t=r.useRef(),{x:n,y:i,setX:a,setY:s,ref:l}=(0,o.useWheelScroll)(),{scale:c,setScale:u,ref:p}=(0,o.useWheelZoom)(),[d,f]=r.useState({x:0,y:0}),{offset:g,onStart:h,mask:m,resetDragMove:y}=(0,o.useDragMove)((()=>{f((e=>({x:e.x+g.x,y:e.y+g.y})))}));(0,o.useGlobalKeyDown)((e=>{"Escape"===e.key?y():"Digit0"===e.code&&!e.shiftKey&&(0,o.metaKeyIfMacElseCtrlKey)(e)&&(u(1),a(0),s(0),f({x:0,y:0}),e.preventDefault())}));const x=(0,o.useWindowSize)(),v=x.width/2,b=x.height,C=g.x+d.x,E=g.y+d.y,[k,w]=r.useState(),S=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:"cune",topRadius:0,bottomRadius:100,height:200},color:[1,0,1,1],position:[0,-250,0]}]);return r.useEffect((()=>{e.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/c,-.3*C,-.3*E);S.current.forEach(((e,t)=>{e.color[3]=t===k?.5:1})),null==(r=null==(e=t.current)?void 0:e.render)||r.call(e,S.current,{eye:[a.x,a.y,a.z],up:[s.x,s.y,s.z],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,c,C,E,k,v,b]),r.createElement("div",{ref:(0,o.bindMultipleRefs)(l,p),style:{position:"absolute",inset:"0px"}},r.createElement("canvas",{ref:e,width:v,height:b,onMouseDown:e=>h({x:e.clientX,y:e.clientY}),onMouseMove:e=>{var n,r;return w(null==(r=null==(n=t.current)?void 0:n.pick)?void 0:r.call(n,e.clientX,e.clientY,(e=>"lines"!==e.geometry.type)))}}),m)}},83:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(7378),o=n(6645),i=n(9397);const a=()=>{const e=r.useRef(null),t=r.useRef(),{x:n,y:a,ref:s,setX:l,setY:c}=(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);l(r.setX),c(r.setY)}}),{zoomIn:f,zoomOut:g}=(0,i.useZoom)(u,p),{offset:h,onStart:m,mask:y,resetDragMove:x}=(0,i.useDragMove)((()=>{l((e=>e+h.x)),c((e=>e+h.y))}));(0,i.useGlobalKeyDown)((e=>{"Escape"===e.key?x():(0,i.metaKeyIfMacElseCtrlKey)(e)&&("Minus"===e.code?g(e):"Equal"===e.code&&f(e))}));const v=(0,i.useWindowSize)(),b=v.width/2,C=v.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),(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)]),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),(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)]),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()}}},[k,w]=r.useState(E());return r.useEffect((()=>{if(!e.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 l=o.primitives.createXYQuadBufferInfo(r),c=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}],x=[{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:l,uniforms:{matrix:h,color:e.color,texture:o.createTexture(r,{src:e.canvas})}},{programInfo:s,bufferInfo:l,uniforms:{matrix:i.m3.multiply(h,i.m3.translation(1,0)),color:e.color,texture:o.createTexture(r,{src:e.canvas})}},{programInfo:s,bufferInfo:l,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:c,bufferInfo:u,uniforms:{texture:p}}]),r.disable(r.STENCIL_TEST),o.drawObjectList(r,y),o.drawObjectList(r,x)}}),[e.current]),r.useEffect((()=>{t.current&&t.current(k,n+h.x,a+h.y,u)}),[k,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)}},2503:(e,t,n)=>{"use strict";n.d(t,{default:()=>i});var r=n(7378),o=n(9397);const i=()=>{const e=r.useRef(null),t=r.useRef(),{x:n,y:i,setX:a,setY:s,ref:l}=(0,o.useWheelScroll)(),{scale:c,setScale:u,ref:p}=(0,o.useWheelZoom)(),[d,f]=r.useState({x:0,y:0}),{offset:g,onStart:h,mask:m,resetDragMove:y}=(0,o.useDragMove)((()=>{f((e=>({x:e.x+g.x,y:e.y+g.y})))}));(0,o.useGlobalKeyDown)((e=>{"Escape"===e.key?y():"Digit0"===e.code&&!e.shiftKey&&(0,o.metaKeyIfMacElseCtrlKey)(e)&&(u(1),a(0),s(0),f({x:0,y:0}),e.preventDefault())}));const x=(0,o.useWindowSize)(),v=x.width/2,b=x.height,C=g.x+d.x,E=g.y+d.y,[k,w]=r.useState(),S=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:"cune",topRadius:0,bottomRadius:100,height:200},color:[1,0,1,1],position:[0,-250,0]}]);return r.useEffect((()=>{e.current&&(0,o.createWebgpu3DRenderer)(e.current).then((e=>{t.current=e,w(-1)}))}),[e.current]),r.useEffect((()=>{var e,r;const{position:a,up:s}=(0,o.updateCamera)(-n,i,1e3/c,-.3*C,-.3*E);S.current.forEach(((e,t)=>{e.color[3]=t===k?.5:1})),null==(r=null==(e=t.current)?void 0:e.render)||r.call(e,S.current,{eye:[a.x,a.y,a.z],up:[s.x,s.y,s.z],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,c,C,E,k,v,b]),r.createElement("div",{ref:(0,o.bindMultipleRefs)(l,p),style:{position:"absolute",inset:"0px"}},r.createElement("canvas",{ref:e,width:v,height:b,onMouseDown:e=>h({x:e.clientX,y:e.clientY}),onMouseMove:e=>{return void 0,null,n=function*(){var n,r;return w(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)))},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}}),m)}},6956:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(7378),o=n.n(r),i=n(9397);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%)"}}))}},5454:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(7378),o=n.n(r),i=n(9397);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%)"}}))}},8497:(e,t,n)=>{"use strict";n.d(t,{WhiteBoard:()=>c});var r=n(7378),o=n.n(r),i=n(9397),a=n(4732),s=Math.pow;const l=Math.round(15*Math.random()*s(16,3)+s(16,3)).toString(16);function c(){const[,e,t]=(0,i.useLocalStorageState)("composable-editor-canvas-whiteboard",[]),n=o().useRef(null),[r,s]=(0,i.useLocalStorageState)("composable-editor-canvas-whiteboard:snaps",i.allSnapTypes),[c,u]=(0,i.useLocalStorageState)("composable-editor-canvas-whiteboard:print-mode",!1),[p,d]=o().useState(),{pluginLoaded:f,pluginCommandTypes:g}=(0,a.usePlugins)();return(0,a.useInitialStateValidated)(t,f)?o().createElement("div",null,o().createElement(a.CADEditor,{ref:n,id:"whiteboard",operator:l,initialState:t,snapTypes:r,renderTarget:"svg",setOperation:d,backgroundColor:16777215,panelVisible:!0,printMode:c,onChange:e}),o().createElement("div",{style:{position:"relative"}},o().createElement("label",null,o().createElement("input",{type:"checkbox",checked:c,onChange:()=>u(!c)}),"print mode"),i.allSnapTypes.map((e=>o().createElement("label",{key:e},o().createElement("input",{type:"checkbox",checked:r.includes(e),onChange:t=>s(t.target.checked?[...r,e]:r.filter((t=>t!==e)))}),e)))),o().createElement("div",{style:{position:"relative"}},g.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:p===e.name?"red":void 0}});return o().createElement("span",{title:e.name,key:e.name},t)}return null})))):null}},7817:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(7378),o=n.n(r),i=n(9397);const a=()=>{const{width:e,height:t}=(0,i.useWindowSize)();return o().createElement("div",null,Math.round(e)," ",Math.round(t))}},6848:(e,t,n)=>{"use strict";n.r(t),n.d(t,{AlignmentLine:()=>u});var r=n(7378),o=Object.defineProperty,i=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable,l=(e,t,n)=>t in e?o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,c=(e,t)=>{for(var n in t||(t={}))a.call(t,n)&&l(e,n,t[n]);if(i)for(var n of i(t))s.call(t,n)&&l(e,n,t[n]);return e};function u(e){var t,n,o,i;if(void 0===e.value)return null;const a=c({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})}},9065:(e,t,n)=>{"use strict";n.r(t),n.d(t,{ChartTooltip:()=>S,getBarChart:()=>C,getChartAxis:()=>v,getChartAxis3D:()=>P,getLineChart:()=>x,getPieChart:()=>E,getPolarAreaChart:()=>k,getRadarChart:()=>w,renderChartTooltip:()=>b});var r=n(7378),o=n.n(r),i=n(9195),a=n(5136),s=n(3516),l=n(9254),c=Object.defineProperty,u=Object.defineProperties,p=Object.getOwnPropertyDescriptors,d=Object.getOwnPropertySymbols,f=Object.prototype.hasOwnProperty,g=Object.prototype.propertyIsEnumerable,h=(e,t,n)=>t in e?c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,m=(e,t)=>{for(var n in t||(t={}))f.call(t,n)&&h(e,n,t[n]);if(d)for(var n of d(t))g.call(t,n)&&h(e,n,t[n]);return e},y=(e,t)=>u(e,p(t));function x(e,t,n,r,o,a){const s=(0,i.getPointsBounding)(e.flat());if(!s)return;const{axis:l,tx:c,ty:u,minY:p}=v(t,s,n,r,o,a),d=e.map((e=>e.map((e=>({x:c(e.x),y:u(e.y),r:e.r})))));return{children:l,points:d,select:t=>{for(let n=0;n{var n;return(0,i.getTwoPointsDistance)(e,t)<=(null!=(n=e.r)?n:5)}));if(r>=0)return y(m({},d[n][r]),{value:e[n][r]})}},minY:p}}function v(e,t,n,{width:r,height:o},i,a){var s,l,c,u,p,d,f,g;const h=null!=(s=null==a?void 0:a.axisColor)?s:13421772,m=null!=(l=null==a?void 0:a.textColor)?l:0,y=null!=(c=null==a?void 0:a.textSize)?c:12,x=null!=(u=null==a?void 0:a.fontFamily)?u:"monospace",v=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,k=null!=(f=null==n?void 0:n.y)?f:1,w=null!=(g=null==a?void 0:a.type)?g:"line",S=Math.floor(t.start.x/E)*E,P=Math.ceil(t.end.x/E)*E,R=Math.floor(t.start.y/k)*k,_=Math.ceil(t.end.y/k)*k,T=(r-i.left-i.right)/(P-S),A=(o-i.top-i.bottom)/(_-R),M=e=>(e-S)*T+i.left,L=e=>(_-e)*A+i.top,O=M(S)-v,I=M(P)+((null==a?void 0:a.ySecondary)?v:0),F=L(R),D=F+v,B=L(_),z=E*T,U=[];if(!(null==a?void 0:a.xLabelDisabled))for(let t=S;t<=P;t+=E){const n=M(t);U.push(e.renderPolyline([{x:n,y:D},{x:n,y:B}],{strokeColor:h})),U.push(e.renderText(n+("bar"===w?z/2:0),D,b(t),m,y,x,{textBaseline:"top",textAlign:"center"}))}if(!(null==a?void 0:a.yLabelDisabled))for(let t=R;t<=_;t+=k){const n=L(t);U.push(e.renderPolyline([{x:O,y:n},{x:I,y:n}],{strokeColor:h})),U.push(e.renderText(O,n,C(t),m,y,x,{textBaseline:"middle",textAlign:"right"})),(null==a?void 0:a.ySecondary)&&U.push(e.renderText(I,n,C(t),m,y,x,{textBaseline:"middle",textAlign:"left"}))}return{axis:U,minY:F,tx:M,ty:L,unitWidth:z,reverseTransform:e=>({x:(e.x-i.left)/T+S,y:_-(e.y-i.top)/A})}}function b(e,{x:t,y:n},r,o){var s,c,u,p,d,f;const g=null!=(s=null==o?void 0:o.textSize)?s:12,h=null!=(c=null==o?void 0:o.fontFamily)?c:"monospace",m=(y=r.x,null!=(v=null==(x=null==o?void 0:o.getXLabel)?void 0:x.call(o,y))?v:y.toString());var y,x,v;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,l.getTextSizeFromCache)((0,i.getTextStyleFont)({fontFamily:h,fontSize:g}),m),t=(0,l.getTextSizeFromCache)((0,i.getTextStyleFont)({fontFamily:h,fontSize:g}),b);C=e&&t?Math.max(e.width,t.width,40):40}const E=null!=(u=null==o?void 0:o.height)?u:30,k=null!=(p=null==o?void 0:o.textColor)?p:16777215,w=null!=(d=null==o?void 0:o.radius)?d:5,S=null!=(f=null==o?void 0:o.backgroundColor)?f:0;return t+=C/2,n-=E/2,[e.renderPolygon((0,a.getRoundedRectPoints)({x:t,y:n,width:C,height:E},w,30),{fillColor:S}),e.renderText(t,n,m,k,g,h,{textBaseline:"bottom",textAlign:"center"}),e.renderText(t,n,b,k,g,h,{textBaseline:"top",textAlign:"center"})]}function C(e,t,n,r,o,a,s,l){var c,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==l?void 0:l.bounding)&&(p=(0,i.getPointsBoundingUnsafe)([l.bounding.start,l.bounding.end,p.start,p.end]));const{axis:d,tx:f,ty:g,reverseTransform:h,unitWidth:x}=v(r,p,o,a,s,m({type:"bar"},l)),b=null!=(c=null==l?void 0:l.barPadding)?c:.1,C=null!=(u=null==l?void 0:l.barSpacing)?u:.05,E=(1-2*b-(e.length-1)*C)/e.length,k=E*x,w=E+C;return e.forEach(((e,r)=>{e.forEach(((e,o)=>{1===e.length&&(e=[0,...e]);const i=f(o)+x*(b+r*w)+k/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>=b&&o<=1-b){const i=Math.floor((o-b)/w);if(o-b-i*w<=E&&i>=0&&i=o[a-1]&&n.y<=o[a]){const n=e[i][r];return y(m({},t),{value:{x:r,y:n.length>2?Math.abs(n[a-1]-n[a]):n}})}}}},tx:f,ty:g}}function E(e,t,n,{width:r,height:o},a,l){var c,u;const p=null!=(c=null==l?void 0:l.type)?c:"pie",d=null!=(u=null==l?void 0:l.startAngle)?u:-90,f=e.map((e=>e.reduce(((e,t)=>e+t),0))),g={x:(r+a.left-a.right)/2,y:(o+a.top-a.bottom)/2,r:Math.min((r-a.left-a.right)/2,(o-a.top-a.bottom)/2)},h=g.r*("doughnut"===p?.5:0),x=g.r-h,v=[],b=[];return e.forEach(((r,o)=>{let a=d;const s=[],l=h+x*o/e.length,c=h+x*(o+1)/e.length;r.forEach(((e,r)=>{s.push(a);const u=a+e/f[o]*360;v.push(n.renderPolygon([...(0,i.arcToPolyline)(y(m({},g),{r:l,startAngle:a,endAngle:u}),5),...(0,i.arcToPolyline)(y(m({},g),{r:c,startAngle:u,endAngle:a,counterclockwise:!0}),5)],{fillColor:t[r],strokeColor:16777215,strokeWidth:2})),a=u})),b.push(s)})),{children:v,select:t=>{const n=(0,i.getTwoPointsDistance)(t,g),r=Math.floor((n-h)/x*e.length);if(r>=0&&re>=o));return-1===a&&(a=n.length-1),y(m({},t),{value:{x:a,y:e[r][a]}})}}}}function k(e,t,n,{width:r,height:o},a,l,c){var u,p;const d=null!=(u=null==c?void 0:c.opacity)?u:.5,f=null!=(p=null==c?void 0:c.axisColor)?p:13421772,g=Math.ceil(Math.max(...e)/a)*a,h={x:(r+l.left-l.right)/2,y:(o+l.top-l.bottom)/2,r:Math.min((r-l.left-l.right)/2,(o-l.top-l.bottom)/2)},x=e=>h.r*e/g,v=[];for(let e=a;e<=g;e+=a){const t=x(e);v.push(n.renderCircle(h.x,h.y,t,{strokeColor:f})),v.push(n.renderCircle(h.x,h.y-t,8,{fillColor:16777215,strokeWidth:0})),v.push(n.renderText(h.x,h.y-t,e.toString(),f,12,"monospace",{textAlign:"center",textBaseline:"middle"}))}let b=-90;const C=[];return e.forEach(((r,o)=>{const a=b+360/e.length;C.push((0,i.getTwoNumberCenter)(b,a)),v.push(n.renderPolygon([h,...(0,i.arcToPolyline)(y(m({},h),{r:x(r),startAngle:b,endAngle:a}),5)],{fillColor:t[o],strokeColor:16777215,strokeWidth:2,fillOpacity:d})),b=a})),{children:v,select:t=>{const n=(0,i.getTwoPointsDistance)(t,h);let r=(0,s.radianToAngle)((0,i.getTwoPointsRadian)(t,h))- -90;r<0&&(r+=360);const o=Math.floor(r*e.length/360);if(o>=0&&og.r*e/f,x=e[0].map(((t,n)=>360*n/e[0].length-90)),v=[],b=h(f);for(const e of x){const t=(0,i.getArcPointAtAngle)(y(m({},g),{r:b}),e);v.push(n.renderPolyline([g,t],{strokeColor:d}))}for(let e=a;e<=f;e+=a){const t=h(e),r=[];for(const e of x)r.push((0,i.getArcPointAtAngle)(y(m({},g),{r:t}),e));v.push(n.renderPolygon(r,{strokeColor:d})),v.push(n.renderRect(g.x-10,g.y-t-6,20,12,{fillColor:16777215,strokeWidth:0})),v.push(n.renderText(g.x,g.y-t,e.toString(),d,12,"monospace",{textAlign:"center",textBaseline:"middle"}))}const C=e.map((e=>e.map(((e,t)=>(0,i.getArcPointAtAngle)(y(m({},g),{r:h(e)}),x[t])))));return C.forEach(((e,r)=>{v.push(n.renderPolygon(e,{fillColor:t[r],strokeWidth:0,fillOpacity:p})),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,i.getTwoPointsDistance)(e,t)<=3));if(r>=0)return y(m({},C[n][r]),{value:{x:r,y:e[n][r]}})}},circle:g,angles:x}}function S(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 P(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],l=t[1],c=t[2];ei&&(i=e),la&&(a=l),cs&&(s=c)}return{maxX:i,minX:n,minY:r,maxY:a,minZ:o,maxZ:s}}(e.flat(),{min:0,max:0}),l=Math.floor(n/t.x)*t.x,c=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<=c;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:[l,e,0,c,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:[l,0,e,c,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}},1799:(e,t,n)=>{"use strict";n.d(t,{Cursor:()=>f});var r=n(7378),o=n.n(r),i=Object.defineProperty,a=Object.defineProperties,s=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,c=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={}))c.call(t,n)&&p(e,n,t[n]);if(l)for(var n of l(t))u.call(t,n)&&p(e,n,t[n]);return e};const f=o().forwardRef(((e,t)=>{const[n,r]=o().useState(!1);return o().createElement(o().Fragment,null,o().createElement("input",{ref:t,style:(i=d({},e.style),l={border:0,outline:"none",width:"0px",position:"absolute",opacity:0},a(i,s(l))),readOnly:e.readOnly,onKeyDown:e.onKeyDown,onCompositionEnd:e.onCompositionEnd,onBlur:t=>{var n;null==(n=e.onBlur)||n.call(e,t),r(!1)},autoFocus:e.autoFocus,onFocus:t=>{var n;null==(n=e.onFocus)||n.call(e,t),r(!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:!n||e.readOnly?"none":"inline-block",position:"absolute",width:"1px",animation:"blink 1s infinite",borderLeft:"1px solid black",userSelect:"none"},e.style)}));var i,l}))},3134:(e,t,n)=>{"use strict";n.r(t),n.d(t,{LinearDimension:()=>a,getLinearDimensionGeometries:()=>o,getLinearDimensionTextPosition:()=>i});var r=n(9254);function o(e,t,n){const o=(0,r.getTwoPointCenter)(e.p1,e.p2);let i,a,s,l,c,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.getPerpendicularPoint)(e.position,(0,r.twoPointLineToGeneralFormLine)(n,o)),p=(0,r.getTwoPointsDistance)(e.position,u),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,...l,...c,...u];return{lines:[...(0,r.iteratePolylineLines)(i),...(0,r.iteratePolylineLines)(a),...(0,r.iteratePolylineLines)(s)],regions:[{points:l,lines:Array.from((0,r.iteratePolygonLines)(l))},{points:c,lines:Array.from((0,r.iteratePolygonLines)(c))},{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,l=0;const c=(0,r.getTwoPointsRadian)(e.position,o),u=Math.abs(c);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.getPerpendicularPoint)(e.position,(0,r.twoPointLineToGeneralFormLine)(o,u)),d=(0,r.getTwoPointsDistance)(e.position,p);l=(0,r.getTwoPointsRadian)(u,o);let f=(0,r.getTwoPointsRadian)(u,o)-c;f<-Math.PI&&(f+=2*Math.PI);const g=f>0&&fMath.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),l=-Math.PI/2);return{text:e.text||a,textPosition:i,size:s,textRotation:l}}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)})},8805:(e,t,n)=>{"use strict";n.r(t),n.d(t,{RadialDimension:()=>a,getRadialDimensionGeometries:()=>o,getRadialDimensionTextPosition:()=>i});var r=n(9254);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),l=(0,r.rotatePositionByCenter)(s,i,n.arrowAngle),c=(0,r.rotatePositionByCenter)(s,i,-n.arrowAngle),u=[a>t.r?t:i,e.position],p=[i,l,c];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 l=(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):l-=Math.PI:e.position.x{"use strict";n.r(t),n.d(t,{DragMask:()=>u});var r=n(7378),o=Object.defineProperty,i=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable,l=(e,t,n)=>t in e?o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,c=(e,t)=>{for(var n in t||(t={}))a.call(t,n)&&l(e,n,t[n]);if(i)for(var n of i(t))s.call(t,n)&&l(e,n,t[n]);return e};function u(e){return r.createElement("div",{style:c({position:"fixed",inset:"0px",cursor:"grabbing"},e.style),onMouseUp:e.onDragEnd,onMouseMove:e.onDragging,onMouseLeave:e.ignoreLeavingEvent?void 0:e.onDragEnd},e.children)}},615:(e,t,n)=>{"use strict";n.r(t),n.d(t,{CircleArcEditBar:()=>a});var r=n(7378),o=n(9254),i=n(2242);function a(e){const t=e.x,n=e.y,a=(0,o.angleToRadian)(e.startAngle),s=(0,o.angleToRadian)(e.endAngle),l=(a+s)/2,c=[{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(l),y:n+e.r*Math.sin(l),cursor:(0,o.getResizeCursor)((e.startAngle+e.endAngle)/2,"right")}];return r.createElement(i.EditBar,{positions:c,scale:e.scale,resizeSize:e.resizeSize,onClick:e.onClick,onMouseDown:e.onMouseDown})}},2022:(e,t,n)=>{"use strict";n.r(t),n.d(t,{CircleEditBar:()=>i});var r=n(7378),o=n(2242);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})}},2242:(e,t,n)=>{"use strict";n.r(t),n.d(t,{EditBar:()=>o});var r=n(7378);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)}}))))}},499:(e,t,n)=>{"use strict";n.r(t),n.d(t,{EllipseArcEditBar:()=>h});var r=n(7378),o=n(9254),i=n(2242),a=Object.defineProperty,s=Object.defineProperties,l=Object.getOwnPropertyDescriptors,c=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(c)for(var n of c(t))p.call(t,n)&&d(e,n,t[n]);return e},g=(e,t)=>s(e,l(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),l=-(null!=(t=e.angle)?t:0),c=[{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,l)),{cursor:(0,o.getResizeCursor)(e.startAngle-l,"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,l)),{cursor:(0,o.getResizeCursor)(e.endAngle-l,"top")})];return r.createElement(i.EditBar,{positions:c,scale:e.scale,resizeSize:e.resizeSize,onClick:e.onClick,onMouseDown:e.onMouseDown})}},7983:(e,t,n)=>{"use strict";n.r(t),n.d(t,{EllipseEditBar:()=>a});var r=n(7378),o=n(9254),i=n(2242);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),l=(0,o.rotatePositionByCenter)({x:e.cx+e.rx,y:e.cy},n,a),c=(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:l.x,y:l.y,cursor:(0,o.getResizeCursor)(-a,"right")},{data:"minor axis",x:c.x,y:c.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})}},5800:(e,t,n)=>{"use strict";n.r(t),n.d(t,{PolylineEditBar:()=>a});var r=n(7378),o=n(9254),i=n(2242);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})}},6746:(e,t,n)=>{"use strict";n.r(t),n.d(t,{ResizeBar:()=>p});var r=n(7378),o=n(9397),i=Object.defineProperty,a=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,c=(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)&&c(e,n,t[n]);if(a)for(var n of a(t))l.call(t,n)&&c(e,n,t[n]);return e};function p(e){var t,n,i;const{resizeSize:a}=e,s=null!=(t=e.scale)?t:1,l=(null!=a?a:5)/s,c=1/s,p=l/2,d=l/2-c,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:l+"px",height:l+"px",border:`${c}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)}}))))}},9512:(e,t,n)=>{"use strict";n.r(t),n.d(t,{RotationBar:()=>o});var r=n(7378);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,l=(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+l/2}px)`,top:-a-l+"px",width:l+"px",height:l+"px",position:"absolute",border:`${Math.max(s,1)}px solid green`,backgroundColor:"white",borderRadius:l/2+"px",cursor:"grab",pointerEvents:"auto"},onMouseDown:e.onMouseDown}))}},1588:(e,t,n)=>{"use strict";n.r(t),n.d(t,{renderEquation:()=>p,renderExpression:()=>d});var r=n(2845),o=n(6564),i=Object.defineProperty,a=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,c=(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)&&c(e,n,t[n]);if(a)for(var n of a(t))l.call(t,n)&&c(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),l=a(t.left),c=a(t.right);let p;if(l&&c){const t=" = ",n=(0,o.getTextSizeFromCache)(s,t);if(n){const o=l.size.width+n.width+c.size.width,a=Math.max(l.size.height,n.height,c.size.height),s=o+2*r.paddingX,u=a+2*r.paddingY,d=u/2;let f=s/2-o/2;l.render(f+l.size.width/2,d),f+=l.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,c.render(f+c.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 l=[],c=`${n}px ${i}`,u=(p,d=Number.MAX_SAFE_INTEGER,f=1,g=!1)=>{const h=n*f,m=1===f?c:`${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))),c=u(p.left,n,f),g=u(p.right,"+"===p.operator||"*"===p.operator?n:n-.1,"**"===p.operator?.75*f:f);if(c&&g){if("**"===p.operator){if("NumericLiteral"===p.right.type&&.5===p.right.value){const n=c.size.width+2*a,r=c.size.height+a;return{size:{width:n,height:r},render(o,i){c.render(o+a,i+a/2),l.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=c.size.width+g.size.width,r=c.size.height+g.size.height/2;return{size:{width:n,height:r},render(e,t){c.render(e-n/2+c.size.width/2,t+r/2-c.size.height/2-g.size.height/4),g.render(e-n/2+c.size.width+g.size.width/2,t-r/2+g.size.height/2)}}}if("/"===p.operator){let r=Math.max(c.size.width,g.size.width)+2*a;const s=c.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+c.size.height+a,u&&l.push(e.renderText(n-r/2+u.width/2,o,"(",t,p,i,{textBaseline:"middle",textAlign:"center"})),c.render(n,o-a-c.size.height/2);const f=null!=(d=null==u?void 0:u.width)?d:0;l.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&&l.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=c.size.width+u.width+g.size.width+a*(u.width?2:0);const f=Math.max(c.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&&(l.push(e.renderText(s+m.width/2,o,"(",t,y,i,{textBaseline:"middle",textAlign:"center"})),s+=m.width),c.render(s+c.size.width/2,o),s+=c.size.width,u.width&&(s+=a,l.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,l.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)(c,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 c;const u=Math.max(s,h);return d<=1&&(c=(0,o.getTextSizeFromCache)(`${u}px ${i}`,"(")),c&&(a+=2*c.width),{size:{width:a,height:s},render(o,s){var d;c&&l.push(e.renderText(o-a/2+c.width/2,s,"(",t,u,i,{textBaseline:"middle",textAlign:"center"}));const f=null!=(d=null==c?void 0:c.width)?d:0;l.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),c&&l.push(e.renderText(o+a/2-c.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)(c,y);if(n){const r=y;return{size:n,render:(n,o)=>l.push(e.renderText(n,o,r,t,h,i,{textBaseline:"middle",textAlign:"center"}))}}}};return{font:c,children:l,render:u}}},7628:(e,t,n)=>{"use strict";n.r(t),n.d(t,{divide:()=>i,divideFactors:()=>l,expressionToFactors:()=>f,extractFactors:()=>a,factorToExpression:()=>m,factorsToExpression:()=>h,optimizeFactor:()=>C,optimizeFactors:()=>b,powerFactor:()=>y});var r=n(7227),o=Math.pow;function i(e,t){const n=f(e);if(!n)return;const r=f(t);if(!r)return;const o=l(n,r);return o?h(o):void 0}function a(e,t){let n;for(const r of e){const e=s(r,t);if(!e)return;if(n){const t={variables:{},constant:E(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:o(n.constant,1/t),variables:[]},i={constant:n.constant,variables:[]};for(const[e,o]of Object.entries(n.variables))r.variables.push(...new Array(o).fill(e)),i.variables.push(...new Array(o*t).fill(e));const a=l(e,[i]);if(!a)return;return{base:r,factors:a}}}function s(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=d(n,t[0]);if(r){const n=p(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 c(e,t){var n,r;const o=d(e,t);if(o&&0===o.variables.length)return(null!=(n=e.constant)?n:1)-(null!=(r=t.constant)?r:1)}function u(e,t){var n,r;const o=d(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;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;nv(e)))),[...t,...n]}const t=g(e);if(t)return[t]}function g(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=g(e.argument);if(!t)return;return v(t)}if("BinaryExpression"===e.type){if("*"===e.operator){const t=g(e.left);if(!t)return;const n=g(e.right);if(!n)return;return x(t,n)}if("/"===e.operator){const t=g(e.left);if(!t)return;const n=g(e.right);if(!n)return;return d(t,n)||(t.variables.push({value:[n],power:-1}),t)}if("**"===e.operator){if("NumericLiteral"===e.right.type&&e.right.value<1){const t=f(e.left);if(!t)return;return{variables:[{value:t,power:e.right.value}]}}const t=g(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 y(t,e.right.value)}}return"CallExpression"===e.type?{variables:[(0,r.printMathStyleExpression)(e)]}:void 0}function h(e){if(0===e.length)return{type:"NumericLiteral",value:0};if(1===e.length)return m(e[0]);const[t,...n]=e;return{type:"BinaryExpression",left:m(t),operator:"+",right:h(n)}}function m(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:m({variables:e.variables})};if(1===e.variables.length){const t=e.variables[0];return"string"!=typeof t?{type:"BinaryExpression",left:h(t.value),operator:"**",right:{type:"NumericLiteral",value:t.power}}:{type:"Identifier",name:t}}const[n,...r]=[...e.variables];return{type:"BinaryExpression",left:m({variables:[n]}),operator:"*",right:m({variables:r})}}function y(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}t.push(r)}return{variables:t,constant:1===n?void 0:n}}function E(e,t){return e<=1||t<=1?1:e===t?e:e>t?E(e%t,t):E(e,t%e)}},4985:(e,t,n)=>{"use strict";n.r(t);var r=n(1328),o={};for(const e in r)"default"!==e&&(o[e]=()=>r[e]);n.d(t,o);var i=n(7628);o={};for(const e in i)"default"!==e&&(o[e]=()=>i[e]);n.d(t,o);var a=n(4214);o={};for(const e in a)"default"!==e&&(o[e]=()=>a[e]);n.d(t,o);var s=n(6666);o={};for(const e in s)"default"!==e&&(o[e]=()=>s[e]);n.d(t,o)},4214:(e,t,n)=>{"use strict";n.r(t),n.d(t,{expressionHasVariable:()=>d,getReverseOperator:()=>v,iterateEquation:()=>p,iterateExpression:()=>u,optimizeEquation:()=>f,optimizeExpression:()=>x,printEquation:()=>g});var r=n(2845),o=n(9195),i=n(7628),a=(e,t)=>{if(t=Symbol[e])return t;throw Error("Symbol."+e+" is not defined")},s=Math.pow,l=function(e,t){this[0]=e,this[1]=t},c=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 l(new Promise((r=>{var o=n[e](t);if(!(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){yield e,"BinaryExpression"===e.type?(yield*c(u(e.left)),yield*c(u(e.right))):"UnaryExpression"===e.type&&(yield*c(u(e.argument)))}function*p(e){yield*c(u(e.left)),yield*c(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=x(e.left,t),e.right=x(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 x(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:v(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&&(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:v(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})})}}return e};return n(e)}function v(e){return"+"===e?"-":"-"===e?"+":"*"===e?"/":"/"===e?"*":e}},6666:(e,t,n)=>{"use strict";n.r(t),n.d(t,{solveQuadraticEquation:()=>o});var r=n(4214);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 c(r,t.constant,e.right)}else if(1===n.length)return c(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=>l(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 l(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 l(e){return s(e,{constant:{type:"NumericLiteral",value:-1},degree:0})}function c(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}}]}},1328:(e,t,n)=>{"use strict";n.r(t),n.d(t,{composeExpression:()=>C,equationHasVariable:()=>m,solveEquation:()=>h,solveEquations:()=>x});var r=n(9642),o=n(4214),i=n(6666),a=Object.defineProperty,s=Object.defineProperties,l=Object.getOwnPropertyDescriptors,c=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(c)for(var n of c(t))p.call(t,n)&&d(e,n,t[n]);return e},g=(e,t)=>s(e,l(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 x(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(l.length>0){if(1===l.length){(0,o.optimizeEquation)(s,(e=>(0,o.expressionHasVariable)(e,l[0])));const[c,...u]=h(s,l[0]);r.push(...u.map((r=>x([...a.map((e=>k(e))),r,...e.slice(t+1).map((e=>k(e)))],new Set(i),v(n)))).flat()),s=c}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],[l,...c]=h(t,s);for(;!y(l).includes(s);){const e=y(l).filter((e=>i.has(e)))[0];if(e===s)break;s=e,[l,...c]=h(l,s)}if(r.push(...c.map((t=>x([t,...e.map((e=>k(e)))],new Set(i),v(n)))).flat()),"Identifier"===l.left.type){for(const e in n){const t=n[e];Array.isArray(t)?n[e]=[(0,o.optimizeExpression)(C(t[0],{[s]:l.right}),(t=>(0,o.expressionHasVariable)(t,e))),(0,o.optimizeExpression)(C(t[1],{[s]:l.right}),(t=>(0,o.expressionHasVariable)(t,e)))]:n[e]=(0,o.optimizeExpression)(C(t,{[s]:l.right}),(t=>(0,o.expressionHasVariable)(t,e)))}n[s]=l.right,i.delete(s);const t=b(e,{[s]:l.right},i);e=t.equations,r.push(...t.result),a()}else n[s]=[l.left,l.right],i.delete(s)}return[n,...r]}function v(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(l.length>0)if(1===l.length){s=(0,o.optimizeEquation)(s,(e=>(0,o.expressionHasVariable)(e,l[0])));const[c,...u]=h(s,l[0]);i.push(...u.map((o=>x([...r.map((e=>k(e))),o,...e.slice(a+1).map((e=>k(e)))],new Set(n),v(t)))).flat()),r.push(c)}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}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 k(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)}):f({},e)}},7931:(e,t,n)=>{"use strict";n.r(t),n.d(t,{ExpressionEditor:()=>h});var r=n(7378),o=n(194),i=n(7250),a=n(8137),s=n(7907),l=n(2357),c=Object.defineProperty,u=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,f=(e,t,n)=>t in e?c(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};function h(e){var t,n,c,u,p,d,f,h;const m=null!=(t=e.height)?t:100,y=null!=(n=e.target)?n:o.reactCanvasRenderTarget,x=null!=(c=e.fontSize)?c:16,v=null!=(d=null!=(p=null==(u=e.style)?void 0:u.fontFamily)?p:s.controlStyle.fontFamily)?d:"monospace",b=null!=(f=e.numberColor)?f:820234,C=1.2*x,[E,k]=r.useState(null!=(h=e.width)?h:250),{state:w,setState:S,undo:P,redo:R,resetHistory:_}=(0,i.useUndoRedo)(e.value.split("")),[T,A]=r.useState([]),[M,L]=r.useState(0),[O,I]=r.useState(""),[F,D]=r.useState(),[B,z]=r.useState(),{renderEditor:U,layoutResult:N,location:j,cursor:W,setLocation:G,inputText:V}=(0,a.useFlowLayoutTextEditor)({state:w,setState:S,width:E,height:m,fontSize:x,fontFamily:v,lineHeight:C,readOnly:e.readOnly,processInput(t){var n;if("Escape"===t.key)return null==(n=e.onCancel)||n.call(e),!0;if(T.length>0&&!e.readOnly){if("ArrowDown"===t.key)return L((M+1)%T.length),t.preventDefault(),!0;if("ArrowUp"===t.key)return L((M-1+T.length)%T.length),t.preventDefault(),!0;if("Enter"===t.key&&M>=0&&M{setTimeout((()=>{H()}),0)},style:{border:"unset"}});r.useEffect((()=>{var t,n,r,o;if(!e.suggestionSources||e.readOnly)return;if(j-1<0||j-1>=w.length)return;A([]),D(void 0);const i=w[j-1];if((0,a.isLetter)(i)||(0,a.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)))}A(i),L(0),I(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=s.find((t=>t.name===n[e]));D(i)}}),[w,j]),r.useEffect((()=>{_(e.value.split(""))}),[e.value]),r.useEffect((()=>{var t;z(null==(t=e.validate)?void 0:t.call(e,w.join("")))}),[w,e.validate]);const $=r.useRef(null);r.useEffect((()=>{if(!$.current)return;const e=new ResizeObserver((e=>{for(const t of e)k(t.contentRect.width)}));return e.observe($.current),()=>e.disconnect()}),[$.current]);const H=()=>{if(!e.readOnly&&e.setValue){const t=w.join("");t!==e.value&&e.setValue(t)}},q={};e.readOnly&&(q.opacity=.5);const Y=e=>{const t=T[e];S((e=>{e.splice(j-O.length,O.length,...t.name.split(""))})),G(j-O.length+t.name.length),A([])};return r.createElement("div",{ref:$,style:g(g(g({position:"relative"},s.controlStyle),e.style),q)},U({target:y,getTextColors:t=>{let n=e.color;const r=N[t].content;if(B&&t>=B[0]&&t=0;n--){const t=N[n].content;if((0,a.isNumber)(t))e=!1;else{if(!(0,a.isLetter)(t))break;e=!0}}e||(n=b)}else if("."===r&&t0&&r.createElement("div",{style:{position:"absolute",left:W.x+"px",top:W.y+C+"px",background:"white",width:"200px",border:"1px solid black",maxHeight:"200px",overflowY:"auto"}},T.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==F?void 0:F.parameters)&&r.createElement("div",{style:{position:"absolute",left:W.x+"px",top:W.y+C+"px",background:"white",width:"400px",border:"1px solid black",maxHeight:"200px",overflowY:"auto"}},r.createElement("div",{onMouseDown:e=>e.preventDefault()},F.name,"(",F.parameters.map((e=>e.name)).join(", "),")",F.parameters.map((e=>e.comment?r.createElement("div",{key:e.name,style:{fontSize:"12px"}},e.name,": ",e.comment):null)),F.comment&&r.createElement("div",{style:{fontSize:"12px"}},F.comment))))}},9300:(e,t,n)=>{"use strict";n.r(t);var r=n(8150),o={};for(const e in r)"default"!==e&&(o[e]=()=>r[e]);n.d(t,o);var i=n(6239);o={};for(const e in i)"default"!==e&&(o[e]=()=>i[e]);n.d(t,o);var a=n(2997);o={};for(const e in a)"default"!==e&&(o[e]=()=>a[e]);n.d(t,o),o={};for(const e in i)"default"!==e&&(o[e]=()=>i[e]);n.d(t,o);var s=n(8533);o={};for(const e in s)"default"!==e&&(o[e]=()=>s[e]);n.d(t,o);var l=n(6071);o={};for(const e in l)"default"!==e&&(o[e]=()=>l[e]);n.d(t,o);var c=n(7250);o={};for(const e in c)"default"!==e&&(o[e]=()=>c[e]);n.d(t,o);var u=n(951);o={};for(const e in u)"default"!==e&&(o[e]=()=>u[e]);n.d(t,o);var p=n(8231);o={};for(const e in p)"default"!==e&&(o[e]=()=>p[e]);n.d(t,o);var d=n(3876);o={};for(const e in d)"default"!==e&&(o[e]=()=>d[e]);n.d(t,o);var f=n(9512);o={};for(const e in f)"default"!==e&&(o[e]=()=>f[e]);n.d(t,o);var g=n(6746);o={};for(const e in g)"default"!==e&&(o[e]=()=>g[e]);n.d(t,o);var h=n(4558);o={};for(const e in h)"default"!==e&&(o[e]=()=>h[e]);n.d(t,o);var m=n(8574);o={};for(const e in m)"default"!==e&&(o[e]=()=>m[e]);n.d(t,o);var y=n(6848);o={};for(const e in y)"default"!==e&&(o[e]=()=>y[e]);n.d(t,o);var x=n(2635);o={};for(const e in x)"default"!==e&&(o[e]=()=>x[e]);n.d(t,o);var v=n(1151);o={};for(const e in v)"default"!==e&&(o[e]=()=>v[e]);n.d(t,o);var b=n(8385);o={};for(const e in b)"default"!==e&&(o[e]=()=>b[e]);n.d(t,o);var C=n(5490);o={};for(const e in C)"default"!==e&&(o[e]=()=>C[e]);n.d(t,o);var E=n(2592);o={};for(const e in E)"default"!==e&&(o[e]=()=>E[e]);n.d(t,o);var k=n(2022);o={};for(const e in k)"default"!==e&&(o[e]=()=>k[e]);n.d(t,o);var w=n(2877);o={};for(const e in w)"default"!==e&&(o[e]=()=>w[e]);n.d(t,o);var S=n(5800);o={};for(const e in S)"default"!==e&&(o[e]=()=>S[e]);n.d(t,o);var P=n(4554);o={};for(const e in P)"default"!==e&&(o[e]=()=>P[e]);n.d(t,o);var R=n(7731);o={};for(const e in R)"default"!==e&&(o[e]=()=>R[e]);n.d(t,o);var _=n(8313);o={};for(const e in _)"default"!==e&&(o[e]=()=>_[e]);n.d(t,o);var T=n(5665);o={};for(const e in T)"default"!==e&&(o[e]=()=>T[e]);n.d(t,o);var A=n(9988);o={};for(const e in A)"default"!==e&&(o[e]=()=>A[e]);n.d(t,o);var M=n(7983);o={};for(const e in M)"default"!==e&&(o[e]=()=>M[e]);n.d(t,o);var L=n(6911);o={};for(const e in L)"default"!==e&&(o[e]=()=>L[e]);n.d(t,o);var O=n(615);o={};for(const e in O)"default"!==e&&(o[e]=()=>O[e]);n.d(t,o);var I=n(447);o={};for(const e in I)"default"!==e&&(o[e]=()=>I[e]);n.d(t,o);var F=n(7535);o={};for(const e in F)"default"!==e&&(o[e]=()=>F[e]);n.d(t,o);var D=n(5736);o={};for(const e in D)"default"!==e&&(o[e]=()=>D[e]);n.d(t,o);var B=n(1252);o={};for(const e in B)"default"!==e&&(o[e]=()=>B[e]);n.d(t,o);var z=n(2242);o={};for(const e in z)"default"!==e&&(o[e]=()=>z[e]);n.d(t,o);var U=n(499);o={};for(const e in U)"default"!==e&&(o[e]=()=>U[e]);n.d(t,o);var N=n(2722);o={};for(const e in N)"default"!==e&&(o[e]=()=>N[e]);n.d(t,o);var j=n(7698);o={};for(const e in j)"default"!==e&&(o[e]=()=>j[e]);n.d(t,o);var W=n(1059);o={};for(const e in W)"default"!==e&&(o[e]=()=>W[e]);n.d(t,o);var G=n(2223);o={};for(const e in G)"default"!==e&&(o[e]=()=>G[e]);n.d(t,o);var V=n(1273);o={};for(const e in V)"default"!==e&&(o[e]=()=>V[e]);n.d(t,o);var $=n(8374);o={};for(const e in $)"default"!==e&&(o[e]=()=>$[e]);n.d(t,o);var H=n(8805);o={};for(const e in H)"default"!==e&&(o[e]=()=>H[e]);n.d(t,o);var q=n(3134);o={};for(const e in q)"default"!==e&&(o[e]=()=>q[e]);n.d(t,o);var Y=n(1935);o={};for(const e in Y)"default"!==e&&(o[e]=()=>Y[e]);n.d(t,o);var X=n(1301);o={};for(const e in X)"default"!==e&&(o[e]=()=>X[e]);n.d(t,o);var K=n(4411);o={};for(const e in K)"default"!==e&&(o[e]=()=>K[e]);n.d(t,o);var Z=n(7931);o={};for(const e in Z)"default"!==e&&(o[e]=()=>Z[e]);n.d(t,o);var Q=n(9990);o={};for(const e in Q)"default"!==e&&(o[e]=()=>Q[e]);n.d(t,o);var J=n(1487);o={};for(const e in J)"default"!==e&&(o[e]=()=>J[e]);n.d(t,o);var ee=n(5439);o={};for(const e in ee)"default"!==e&&(o[e]=()=>ee[e]);n.d(t,o);var te=n(9328);o={};for(const e in te)"default"!==e&&(o[e]=()=>te[e]);n.d(t,o);var ne=n(5069);o={};for(const e in ne)"default"!==e&&(o[e]=()=>ne[e]);n.d(t,o);var re=n(1497);o={};for(const e in re)"default"!==e&&(o[e]=()=>re[e]);n.d(t,o);var oe=n(8137);o={};for(const e in oe)"default"!==e&&(o[e]=()=>oe[e]);n.d(t,o);var ie=n(1502);o={};for(const e in ie)"default"!==e&&(o[e]=()=>ie[e]);n.d(t,o);var ae=n(5436);o={};for(const e in ae)"default"!==e&&(o[e]=()=>ae[e]);n.d(t,o);var se=n(4507);o={};for(const e in se)"default"!==e&&(o[e]=()=>se[e]);n.d(t,o);var le=n(6739);o={};for(const e in le)"default"!==e&&(o[e]=()=>le[e]);n.d(t,o);var ce=n(7907);o={};for(const e in ce)"default"!==e&&(o[e]=()=>ce[e]);n.d(t,o);var ue=n(1588);o={};for(const e in ue)"default"!==e&&(o[e]=()=>ue[e]);n.d(t,o);var pe=n(4985);o={};for(const e in pe)"default"!==e&&(o[e]=()=>pe[e]);n.d(t,o);var de=n(1950);o={};for(const e in de)"default"!==e&&(o[e]=()=>de[e]);n.d(t,o);var fe=n(2293);o={};for(const e in fe)"default"!==e&&(o[e]=()=>fe[e]);n.d(t,o);var ge=n(3860);o={};for(const e in ge)"default"!==e&&(o[e]=()=>ge[e]);n.d(t,o);var he=n(1138);o={};for(const e in he)"default"!==e&&(o[e]=()=>he[e]);n.d(t,o);var me=n(6752);o={};for(const e in me)"default"!==e&&(o[e]=()=>me[e]);n.d(t,o);var ye=n(2115);o={};for(const e in ye)"default"!==e&&(o[e]=()=>ye[e]);n.d(t,o);var xe=n(9065);o={};for(const e in xe)"default"!==e&&(o[e]=()=>xe[e]);n.d(t,o);var ve=n(4984);o={};for(const e in ve)"default"!==e&&(o[e]=()=>ve[e]);n.d(t,o);var be=n(8705);o={};for(const e in be)"default"!==e&&(o[e]=()=>be[e]);n.d(t,o);var Ce=n(7732);o={};for(const e in Ce)"default"!==e&&(o[e]=()=>Ce[e]);n.d(t,o)},917:(e,t,n)=>{"use strict";n.r(t),n.d(t,{ArrayEditor:()=>a,ObjectArrayEditor:()=>s});var r=n(7378),o=n(2785),i=n(6041);function a(e){return e.inline?r.createElement("div",{style:i.groupStyle},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)}},c),e.copy&&r.createElement(o.Button,{onClick:()=>{var t;return null==(t=e.copy)?void 0:t.call(e,n)}},d),n>0&&e.moveUp&&r.createElement(o.Button,{onClick:()=>{var t;return null==(t=e.moveUp)?void 0:t.call(e,n)}},u),n{var t;return null==(t=e.moveDown)?void 0:t.call(e,n)}},p)))))),!e.readOnly&&e.add&&r.createElement(o.Button,{onClick:e.add},l)):r.createElement("div",{style:i.groupStyle},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)}},c),!e.readOnly&&e.copy&&r.createElement(o.Button,{onClick:()=>{var t;return null==(t=e.copy)?void 0:t.call(e,n)}},d),!e.readOnly&&e.moveUp&&n>0&&r.createElement(o.Button,{onClick:()=>{var t;return null==(t=e.moveUp)?void 0:t.call(e,n)}},u),!e.readOnly&&e.moveDown&&n{var t;return null==(t=e.moveDown)?void 0:t.call(e,n)}},p)),r.createElement("div",{style:{display:"flex"}},r.cloneElement(t,(0,i.getChildProps)(e))))})),!e.readOnly&&e.add&&r.createElement(o.Button,{onClick:e.add},l))}function s(e){return 0===e.properties.length?null:r.createElement("div",{style:i.groupStyle},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)}},c),e.copy&&r.createElement(o.Button,{onClick:()=>{var t;return null==(t=e.copy)?void 0:t.call(e,n)}},d),e.moveUp&&n>0&&r.createElement(o.Button,{onClick:()=>{var t;return null==(t=e.moveUp)?void 0:t.call(e,n)}},u),e.moveDown&&n{var t;return null==(t=e.moveDown)?void 0:t.call(e,n)}},p))))))),!e.readOnly&&e.add&&r.createElement(o.Button,{onClick:e.add},l))}const l=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"})),c=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"})),u=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"})),p=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"})),d=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"}))},9221:(e,t,n)=>{"use strict";n.r(t),n.d(t,{BooleanEditor:()=>o});var r=n(7378);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)}}))}},2785:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Button:()=>g,Label:()=>h});var r=n(7378),o=n(6041),i=Object.defineProperty,a=Object.defineProperties,s=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,c=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={}))c.call(t,n)&&p(e,n,t[n]);if(l)for(var n of l(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)}},6041:(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,l=Object.prototype.propertyIsEnumerable,c=(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)&&c(e,n,t[n]);if(a)for(var n of a(t))l.call(t,n)&&c(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}},8727:(e,t,n)=>{"use strict";n.r(t),n.d(t,{DialogContainer:()=>a});var r=n(7378),o=n(2785),i=n(6041);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"}))},2520:(e,t,n)=>{"use strict";n.r(t),n.d(t,{EnumArrayEditor:()=>d,EnumEditor:()=>f});var r=n(7378),o=n(5188),i=n(6041),a=Object.defineProperty,s=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,c=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={}))l.call(t,n)&&u(e,n,t[n]);if(s)for(var n of s(t))c.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)})))}},7907:(e,t,n)=>{"use strict";n.r(t);var r=n(917),o={};for(const e in r)"default"!==e&&(o[e]=()=>r[e]);n.d(t,o);var i=n(9221);o={};for(const e in i)"default"!==e&&(o[e]=()=>i[e]);n.d(t,o);var a=n(8727);o={};for(const e in a)"default"!==e&&(o[e]=()=>a[e]);n.d(t,o);var s=n(2520);o={};for(const e in s)"default"!==e&&(o[e]=()=>s[e]);n.d(t,o);var l=n(1230);o={};for(const e in l)"default"!==e&&(o[e]=()=>l[e]);n.d(t,o);var c=n(8839);o={};for(const e in c)"default"!==e&&(o[e]=()=>c[e]);n.d(t,o);var u=n(5200);o={};for(const e in u)"default"!==e&&(o[e]=()=>u[e]);n.d(t,o);var p=n(7179);o={};for(const e in p)"default"!==e&&(o[e]=()=>p[e]);n.d(t,o);var d=n(2785);o={};for(const e in d)"default"!==e&&(o[e]=()=>d[e]);n.d(t,o);var f=n(6041);o={};for(const e in f)"default"!==e&&(o[e]=()=>f[e]);n.d(t,o)},1230:(e,t,n)=>{"use strict";n.r(t),n.d(t,{NumberEditor:()=>d});var r=n(7378),o=n(7504),i=n(6041),a=Object.defineProperty,s=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,c=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={}))l.call(t,n)&&u(e,n,t[n]);if(s)for(var n of s(t))c.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 l={};return"color"===e.type&&(l={flex:"unset",padding:0}),!e.readOnly&&e.setValue||(l.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),l),onKeyDown:t=>{var n;"Enter"===t.key&&s(),"Escape"!==t.key?t.stopPropagation():null==(n=e.onCancel)||n.call(e)},onBlur:()=>{setTimeout((()=>{s()}),0)}})}},8839:(e,t,n)=>{"use strict";n.r(t),n.d(t,{ObjectEditor:()=>p});var r=n(7378),o=n(6041),i=Object.defineProperty,a=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,c=(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)&&c(e,n,t[n]);if(a)for(var n of a(t))l.call(t,n)&&c(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)))))}},5200:(e,t,n)=>{"use strict";n.r(t),n.d(t,{StringEditor:()=>p});var r=n(7378),o=n(6041),i=Object.defineProperty,a=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,c=(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)&&c(e,n,t[n]);if(a)for(var n of a(t))l.call(t,n)&&c(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,l={};return"color"===e.type&&(l={flex:"unset",padding:0}),!e.readOnly&&e.setValue||(l.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),l)}):((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)||!!(c=e.value)&&0===c.indexOf("data:image/")&&-1!==c.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),l)}),s));var c}const d=[".png",".jpg",".bmp",".gif"]},7179:(e,t,n)=>{"use strict";n.r(t),n.d(t,{getArrayEditorProps:()=>a,useJsonEditorData:()=>i});var r=n(5188),o=n(7378);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)}))}}},8797:(e,t,n)=>{"use strict";n.r(t),n.d(t,{codeRenderTarget:()=>r});const r={type:"code",renderResult:(e,t,n,r)=>`target.renderResult([\n${e.map((e=>" "+e)).join("\n")}\n], ${t}, ${n}, ${JSON.stringify(r)})`,renderEmpty:()=>"target.renderEmpty()",renderGroup:(e,t)=>`target.renderGroup([\n${e.map((e=>" "+e)).join("\n")}\n], ${JSON.stringify(t)})`,renderRect:(e,t,n,r,o)=>`target.renderRect(${e}, ${t}, ${n}, ${r}, ${JSON.stringify(o)})`,renderPolyline:(e,t)=>`target.renderPolyline(${JSON.stringify(e)}, ${JSON.stringify(t)})`,renderPolygon:(e,t)=>`target.renderPolygon(${JSON.stringify(e)}, ${JSON.stringify(t)})`,renderCircle:(e,t,n,r)=>`target.renderCircle(${e}, ${t}, ${n}, ${JSON.stringify(r)})`,renderEllipse:(e,t,n,r,o)=>`target.renderEllipse(${e}, ${t}, ${n}, ${r}, ${JSON.stringify(o)})`,renderArc:(e,t,n,r,o,i)=>`target.renderArc(${e}, ${t}, ${n}, ${r}, ${o}, ${JSON.stringify(i)})`,renderEllipseArc:(e,t,n,r,o,i,a)=>`target.renderEllipseArc(${e}, ${t}, ${n}, ${r}, ${o}, ${i}, ${JSON.stringify(a)})`,renderPathCommands:(e,t)=>`target.renderPathCommands(${JSON.stringify(e)}, ${JSON.stringify(t)})`,renderText:(e,t,n,r,o,i,a)=>`target.renderText(${e}, ${t}, ${JSON.stringify(n)}, ${JSON.stringify(r)}, ${o}, ${JSON.stringify(i)}, ${JSON.stringify(a)})`,renderImage:(e,t,n,r,o,i)=>`target.renderImage(${JSON.stringify(e)}, ${t}, ${n}, ${r}, ${o}, ${JSON.stringify(i)})`,renderPath:(e,t)=>`target.renderPath(${JSON.stringify(e)}, ${JSON.stringify(t)})`}},8485:(e,t,n)=>{"use strict";n.r(t),n.d(t,{createWebglRenderer:()=>S,defaultVec4Color:()=>R,forEachPatternGraphicRepeatedGraphic:()=>j,getGroupGraphics:()=>A,getImageGraphic:()=>T,getNumArrayPointsBounding:()=>N,getPathGraphics:()=>_,getTextGraphic:()=>P,getTextureGraphicMatrix:()=>W,getWorldMatrix:()=>G,setCanvasLineDash:()=>D});var r=n(6645),o=n(1106),i=n.n(o),a=n(1948),s=n(7504),l=n(6581),c=n(9195),u=n(5547),p=n(3516),d=n(7459),f=n(9605),g=n(6003),h=n(5395),m=Object.defineProperty,y=Object.defineProperties,x=Object.getOwnPropertyDescriptors,v=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,k=(e,t)=>{for(var n in t||(t={}))b.call(t,n)&&E(e,n,t[n]);if(v)for(var n of v(t))C.call(t,n)&&E(e,n,t[n]);return e},w=(e,t)=>y(e,x(t));function S(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 d.Lazy((()=>r.createProgramInfo(t,["\n attribute vec4 position;\n uniform mat3 matrix;\n uniform float flipY;\n void main() {\n gl_Position = vec4((matrix * vec3(position.xy, 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 d.Lazy((()=>r.createProgramInfo(t,["\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 }"]))),i=new d.Lazy((()=>r.createProgramInfo(t,["\n attribute vec4 position;\n uniform mat3 matrix;\n uniform float flipY;\n varying vec2 texcoord;\n\n void main () {\n gl_Position = vec4((matrix * vec3(position.xy, 1)).xy * vec2(1, flipY), 0, 1);\n texcoord = position.xy;\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 }"]))),a=new d.Lazy((()=>r.createProgramInfo(t,["\n attribute vec4 position;\n uniform mat3 matrix;\n uniform float flipY;\n varying vec2 texcoord;\n\n void main () {\n gl_Position = vec4((matrix * vec3(position.xy, 1)).xy * vec2(1, flipY), 0, 1);\n texcoord = position.xy;\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 }"]))),c=new d.Lazy((()=>r.createProgramInfo(t,["\n attribute vec4 position;\n uniform mat3 matrix;\n uniform float flipY;\n varying vec2 texcoord;\n\n void main () {\n gl_Position = vec4((matrix * vec3(position.xy, 1)).xy * vec2(1, flipY), 0, 1);\n texcoord = position.xy;\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 d.Lazy((()=>r.createProgramInfo(t,["\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 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 d.Lazy((()=>r.createProgramInfo(t,["\n attribute vec4 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.xy, 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 }"]))),g=r.primitives.createXYQuadBufferInfo(t),h=new u.WeakmapCache,m=new u.WeakmapCache,y=e=>{const t={};let n;return"color matrix"===e.type?(n=a.instance,t.colorMatrix=e.value):(n=c.instance,t.px=e.value),{programInfo:n,filterUniforms:t}},x=()=>{r.drawObjectList(t,v),v=[]};let v=[];const b=(n,o,a,s,c)=>{let u;if(x(),n.graphics.some((e=>e.pattern))){const i=r.createFramebufferInfo(t,void 0,e.width,e.height);r.bindFramebufferInfo(t,i),j(n,o,a,((e,t)=>{C(e,t,c)})),x(),u=i.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,[s]),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:i.instance,bufferInfo:g,uniforms:{matrix:l.m3.projection(1,1),opacity:null!=c?c:1,texture:u,flipY:-1}}]):(j(n,o,a,((e,t)=>{C(e,t,c)})),x()),t.disable(t.STENCIL_TEST)},C=(e,a,c)=>{var u,d;const C=(0,s.mergeOpacities)(e.opacity,c),E=(0,s.mergeOpacityToColor)(e.color,C);if("texture"===e.type){const{textureMatrix:n,width:s,height:c}=W(a,e);let f=h.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=y(e.filters[e.filters.length-1]);m=t.programInfo,S=t.filterUniforms}else m=e.pattern?p.instance:e.color?o.instance:i.instance;const P={programInfo:m,bufferInfo:g,uniforms:w(k({matrix:n,color:E,opacity:null!=(d=e.opacity)?d:1,texture:f},S),{flipY:1})};e.pattern?b(e.pattern,a,{xMin:e.x,yMin:e.y,xMax:e.x+s,yMax:e.y+c},P,C):v.push(P)}else{const o={programInfo:e.colors?f.instance:n.instance,bufferInfo:m.get(e.points,(()=>{const n={position:{numComponents:2,data:e.points}};return e.colors&&(n.color={numComponents:4,data:e.colors}),r.createBufferInfoFromArrays(t,n)})),uniforms:{color:E,matrix:a,flipY:1},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=N(e.points);b(e.pattern,a,t,o,C)}else v.push(o)}};return(n,o,i,a,s,c)=>{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=G(t.canvas,i,a,s,c);for(const e of n){const t=e.matrix?l.m3.multiply(u,e.matrix):u;C(e,t)}x()}}function P(e,t,n,r,o,i,a){var l;const c=null!=(l=null==a?void 0:a.strokeWidth)?l:0,u=()=>{var e,t;const l=document.createElement("canvas"),u=l.getContext("2d");if(!u)return;const p=`${null!=(e=null==a?void 0:a.fontWeight)?e:"normal"} ${null!=(t=null==a?void 0:a.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==a?void 0:a.fillLinearGradient)||(null==a?void 0:a.fillRadialGradient))&&(u.fillStyle=void 0!==(null==a?void 0:a.strokeColor)&&"number"==typeof r?(0,s.getColorString)(r,a.fillOpacity):"white",u.fillText(n,0,o)),void 0!==(null==a?void 0:a.strokeColor)?(u.strokeStyle=void 0!==r&&"number"==typeof r?(0,s.getColorString)(a.strokeColor,a.strokeOpacity):"white",void 0!==a.strokeWidth&&(u.lineWidth=a.strokeWidth),D(u,a),u.strokeText(n,0,o)):((null==a?void 0:a.strokePattern)||(null==a?void 0:a.strokeLinearGradient)||(null==a?void 0:a.strokeRadialGradient))&&(u.strokeStyle="white",void 0!==a.strokeWidth&&(u.lineWidth=a.strokeWidth-1),D(u,a),u.strokeText(n,0,o-c)),{textMetrics:d,imageData:u.getImageData(0,0,l.width,l.height),canvas:l}},p=(null==a?void 0:a.cacheKey)?M.get(a.cacheKey,u):u();if(!p)return;const{imageData:d,textMetrics:f,canvas:g}=p;let h=t-d.height+c+f.actualBoundingBoxDescent;"top"===(null==a?void 0:a.textBaseline)?h+=f.actualBoundingBoxAscent+f.actualBoundingBoxDescent/2:"middle"===(null==a?void 0:a.textBaseline)?h+=(f.actualBoundingBoxAscent-f.actualBoundingBoxDescent)/2:"bottom"===(null==a?void 0:a.textBaseline)&&(h-=f.fontBoundingBoxDescent);let m,y=e;if("right"===(null==a?void 0:a.textAlign)?y-=d.width:"center"===(null==a?void 0:a.textAlign)&&(y-=d.width/2),(null==a?void 0:a.strokePattern)?m=a.strokePattern:(null==a?void 0:a.strokeLinearGradient)?m={graphics:[B(a.strokeLinearGradient,[{x:y,y:h},{x:y+d.width,y:h},{x:y,y:t},{x:y+d.width,y:t}])]}:(null==a?void 0:a.strokeRadialGradient)?m={graphics:[z(a.strokeRadialGradient,[{x:y,y:h},{x:y+d.width,y:h},{x:y,y:t},{x:y+d.width,y:t}])]}:(null==a?void 0:a.fillLinearGradient)?m={graphics:[B(a.fillLinearGradient,[{x:y,y:h},{x:y+d.width,y:h},{x:y,y:t},{x:y+d.width,y:t}])]}:(null==a?void 0:a.fillRadialGradient)&&(m={graphics:[z(a.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==a?void 0:a.strokeColor))return;return{type:"texture",x:y,y:h,color:(0,s.colorNumberToRec)(a.strokeColor,a.strokeOpacity),src:d,canvas:g}}return void 0!==(null==a?void 0:a.strokeColor)?{type:"texture",x:y,y:h,src:d,canvas:g}:{type:"texture",x:y,y:h,color:(0,s.colorNumberToRec)(r,null==a?void 0:a.fillOpacity),src:d,canvas:g}}const R=[0,0,0,1];function _(e,t,n){var r,o,a,l,u;let p=null!=(r=null==n?void 0:n.strokeWidth)?r:1;const d=!!(null==n?void 0:n.closed)||(null!=(o=null==n?void 0:n.lineCap)?o:"butt"),f=null!=(a=null==n?void 0:n.lineJoin)?a:"miter",g="miter"===f?null!=(l=null==n?void 0:n.miterLimit)?l:h.defaultMiterLimit:f,m=(0,s.colorNumberToRec)(null!=(u=null==n?void 0:n.strokeColor)?u:0,null==n?void 0:n.strokeOpacity),y=[];if(p){if(null==n?void 0:n.dashArray){const t=n.dashArray;e=e.map((e=>(!0===d&&(e=(0,c.polygonToPolyline)(e)),(0,c.dashedPolylineToLines)(e,t,void 0,n.dashOffset)))).flat()}if(0===t||1!==p&&p*t!=1){p*=t||1;const r=O.get(e,p,d,g,(()=>e.map((e=>L.get(e,p,d,g,(()=>(0,h.triangleStripToTriangles)((0,h.getPolylineTriangles)(e,p,d,g)))))).flat()));let o,i=m;(null==n?void 0:n.strokePattern)?(o=n.strokePattern,i=[0,0,0,0]):(null==n?void 0:n.strokeLinearGradient)?(o={graphics:[B(n.strokeLinearGradient,U(r))]},i=[0,0,0,0]):(null==n?void 0:n.strokeRadialGradient)&&(o={graphics:[z(n.strokeRadialGradient,U(r))]},i=[0,0,0,0]),y.push({type:"triangles",points:r,color:i,pattern:o})}else y.push({type:"lines",points:F.get(e,d,(()=>e.map((e=>I.get(e,d,(()=>{!0===d&&(e=(0,c.polygonToPolyline)(e));const t=[];for(let n=1;n[e.x,e.y])).flat());const o=i()(t,r),a=[];for(let e=0;e0&&s.filters.forEach((e=>{if("brightness"===e.type)c.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);c.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,p.angleToRadian)(e.value),n=Math.cos(t),r=Math.sin(t),o=.213,i=.715,a=.072;c.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);c.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;c.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;c.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;c.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?c.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&&c.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:l,opacity:null==s?void 0:s.opacity,filters:c.length>0?c:void 0}}function A(e,t,n,r=1){return n&&(t||(t=l.m3.identity()),n.translate&&(t=l.m3.multiply(t,l.m3.translation(n.translate.x,n.translate.y))),n.base&&(n.angle||n.rotation)&&(t=l.m3.multiply(t,l.m3.translation(n.base.x,n.base.y)),n.angle?t=l.m3.multiply(t,l.m3.rotation(-(0,p.angleToRadian)(n.angle))):n.rotation&&(t=l.m3.multiply(t,l.m3.rotation(-n.rotation))),t=l.m3.multiply(t,l.m3.translation(-n.base.x,-n.base.y))),n.matrix&&(t=l.m3.multiply(t,n.matrix)),void 0!==n.opacity&&(r*=n.opacity)),e.map((e=>w(k({},e),{matrix:e.matrix?t?l.m3.multiply(t,e.matrix):e.matrix:t,opacity:void 0!==e.opacity?r*e.opacity:r})))}const M=new u.WeakmapCache,L=new u.WeakmapMap3Cache,O=new u.WeakmapMap3Cache,I=new u.WeakmapMapCache,F=new u.WeakmapMapCache;function D(e,t){(null==t?void 0:t.dashArray)&&(e.setLineDash(t.dashArray),t.dashOffset&&(e.lineDashOffset=t.dashOffset))}function B(e,t){const{start:n,end:r}=e,o=r.x-n.x,i=r.y-n.y,a=(0,c.twoPointLineToGeneralFormLine)(n,r),l=e.stops.slice(0).sort(((e,t)=>e.offset-t.offset)),u=[];let p=l[0].offset,d=l[l.length-1].offset;t.forEach((e=>{const t=(0,g.getPerpendicularPoint)(e,a),r=(0,c.getPointSideOfLine)(e,a);if((0,c.isZero)(r))u.push(0);else{const n=(0,c.getTwoPointsDistance)(t,e);r>0?u.push(n):r<0&&u.push(-n)}const s=(0,c.equals)(t.x,n.x)?(t.y-n.y)/i:(t.x-n.x)/o;sd&&(d=s)})),(0,c.equals)(p,l[0].offset)||l.unshift({offset:p,color:l[0].color}),(0,c.equals)(d,l[l.length-1].offset)||l.push({offset:d,color:l[l.length-1].color});const h=(0,c.getParallelLinesByDistance)(a,Math.max(...u))[1],m=(0,c.getParallelLinesByDistance)(a,Math.min(...u))[1],y=[],x=[];return l.forEach((e=>{const t={x:n.x+o*e.offset,y:n.y+i*e.offset},r=(0,f.getTwoGeneralFormLinesIntersectionPoint)(h,(0,g.getPerpendicular)(t,h)),a=(0,f.getTwoGeneralFormLinesIntersectionPoint)(m,(0,g.getPerpendicular)(t,m)),l=(0,s.colorNumberToRec)(e.color,e.opacity);r&&a&&(y.push(r.x,r.y,a.x,a.y),x.push(...l,...l))})),{type:"triangle strip",points:y,colors:x}}function z(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,a=r.y-n.y,l=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+a*e.offset,r:n.r+l*e.offset};return{color:(0,s.colorNumberToRec)(e.color,e.opacity),points:(0,c.arcToPolyline)({x:t.x,y:t.y,r:t.r,startAngle:0,endAngle:360},5)}})),p=Math.max(...t.map((e=>(0,c.getTwoPointsDistance)(e,r))));p>r.r&&u.push({color:u[u.length-1].color,points:(0,c.arcToPolyline)({x:r.x,y:r.y,r:p,startAngle:0,endAngle:360},5)});const d=[],f=[];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)})),d.push(t),f.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)})),d.push(r),f.push(o)}return{type:"triangle strip",points:(0,h.combineStripTriangles)(d),colors:(0,h.combineStripTriangleColors)(f)}}function U(e){const t=[];for(let n=0;nr&&(r=a),so&&(o=s)}return{xMax:r,xMin:t,yMin:n,yMax:o}}function j(e,t,n,r){var o,i;const{xMin:a,yMin:s,xMax:c,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(c/p),h=Math.floor(s/d),m=Math.floor(u/d);for(let n=f;n<=g;n++)for(let o=h;o<=m;o++){const i=l.m3.multiply(t,l.m3.translation(n*p,o*d));for(const t of e.graphics)r(t,t.matrix?l.m3.multiply(i,t.matrix):i)}}function W(e,t){var n,r;const o=l.m3.multiply(e,l.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:l.m3.multiply(o,l.m3.scaling(i,a)),width:i,height:a}}function G(e,t,n,r,o){let i=l.m3.projection(e.width,e.height);return i=l.m3.multiply(i,l.m3.translation(t,n)),1!==r&&(i=l.m3.multiply(i,l.m3.translation(e.width/2,e.height/2)),i=l.m3.multiply(i,l.m3.scaling(r,r)),i=l.m3.multiply(i,l.m3.translation(-e.width/2,-e.height/2))),o&&(i=l.m3.multiply(i,l.m3.rotation(-o))),i}},9417:(e,t,n)=>{"use strict";n.r(t),n.d(t,{createUniformsBuffer:()=>p,createWebgpuRenderer:()=>u});var r=n(7459),o=n(7504),i=n(6581),a=n(863),s=n(5547),l=n(8485),c=(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 c(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(),c=navigator.gpu.getPreferredCanvasFormat();t.configure({device:a,format:c});const u={color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha"},alpha:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha"}},d=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.xy, 1)).xy, 0, 1);\n }\n \n @fragment\n fn fragment_main() -> @location(0) vec4f\n {\n return uniforms.color;\n }"}))),f=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 }"}))),g=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 }"}))),h=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 }"}))),m=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 }"}))),y=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 }"}))),x=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.xy, 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 }"}))),v=new r.Lazy((()=>a.createSampler({magFilter:"nearest",minFilter:"nearest"}))),b=new r.Lazy((()=>a.createTexture({size:[e.width,e.height],sampleCount:4,format:c,usage:GPUTextureUsage.RENDER_ATTACHMENT})),(e=>e.destroy())),C=new r.Lazy((()=>a.createTexture({format:"stencil8",sampleCount:4,size:[e.width,e.height],usage:GPUTextureUsage.RENDER_ATTACHMENT})),(e=>e.destroy())),E=new s.WeakmapCache,k=new s.WeakmapCache2,w=new s.WeakmapMap2Cache,S=new s.WeakmapCache,P=new s.MapCache2,R=e=>"color matrix"===e.type?{shaderModule:h.instance,input:{type:"vec4 array",count:5,value:e.value}}:{shaderModule:m.instance,input:{type:"vec2",value:e.value}},_=(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:c,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},layout:"auto"}),T=(e,t,n)=>{e.setPipeline(t),e.setBindGroup(0,a.createBindGroup({layout:t.getBindGroupLayout(0),entries:n.map(((e,t)=>({binding:t,resource:e})))}))},A=(e,t,n,r,o="normal")=>{const i=P.get(e,o,(()=>_(e,o)));T(t,i,[{buffer:p(a,n)},v.instance,r.createView()]),t.draw(6)},M=(e,t)=>a.createTexture({size:[e,t],format:c,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT}),L=(e,n=t.getCurrentTexture(),r)=>e.beginRenderPass({colorAttachments:[{clearValue:r,loadOp:r?"clear":"load",storeOp:"store",view:b.instance.createView(),resolveTarget:n.createView()}]}),O=(e,n=t.getCurrentTexture(),r=1)=>{const o=e.beginRenderPass({colorAttachments:[{view:b.instance.createView(),resolveTarget:n.createView(),loadOp:"load",storeOp:"store"}],depthStencilAttachment:{view:C.instance.createView(),stencilLoadOp:"load",stencilStoreOp:"store"}});return o.setStencilReference(r),o},I=(t,n,r,o,s,c)=>{let u;if(t.graphics.some((e=>e.pattern))){u=M(e.width,e.height);const o=a.createCommandEncoder();let i=O(o,u,0);(0,l.forEachPatternGraphicRepeatedGraphic)(t,n,r,((e,t)=>{i=F(e,t,i,o,!0,s,u)})),i.end(),a.queue.submit([o.finish()])}let p=O(o);return u?A(g.instance,p,[{type:"mat3x3",value:i.m3.projection(1,1)},{type:"number",value:null!=s?s:1}],u,"masked"):(0,l.forEachPatternGraphicRepeatedGraphic)(t,n,r,((e,t)=>{p=F(e,t,p,o,!0,s,c)})),p.end(),L(o,c)},F=(t,n,r,s,c=!1,u,h)=>{var m,v,b;const P=(0,o.mergeOpacities)(t.opacity,u),O=(0,o.mergeOpacityToColor)(t.pattern?l.defaultVec4Color:t.color,P);t.pattern&&(r.end(),r=(e=>{const t=e.beginRenderPass({colorAttachments:[],depthStencilAttachment:{view:C.instance.createView(),stencilClearValue:0,stencilLoadOp:"clear",stencilStoreOp:"store"}});return t.setStencilReference(1),t})(s));const F=t.pattern?"mask":c?"masked":"normal";if("texture"===t.type){const{textureMatrix:o,width:c,height:u}=(0,l.getTextureGraphicMatrix)(n,t);let p,d=S.get(t.src,(()=>{const e=M(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=R(t.filters[t.filters.length-1]);p=e.shaderModule,x.push({type:"number",value:null!=(v=t.opacity)?v:1},e.input)}else t.pattern?(p=y.instance,x.push({type:"vec4",value:null!=O?O:l.defaultVec4Color})):t.color?(p=f.instance,x.push({type:"vec4",value:null!=O?O:l.defaultVec4Color})):(p=g.instance,x.push({type:"number",value:null!=(b=t.opacity)?b:1}));A(p,r,x,d,F),t.pattern&&(r.end(),r=I(t.pattern,n,{xMin:t.x,yMin:t.y,xMax:t.x+c,yMax:t.y+u},s,P,h))}else{const e=t.colors?x.instance:d.instance,o=w.get(e,t.type,F,(()=>{const n=t.colors?{attributes:[{shaderLocation:0,offset:0,format:"float32x2"},{shaderLocation:1,offset:8,format:"float32x4"}],arrayStride:24,stepMode:"vertex"}:{attributes:[{shaderLocation:0,offset:0,format:"float32x2"}],arrayStride:8,stepMode:"vertex"};return _(e,F,t.type,n)}));if(T(r,o,[{buffer:p(a,[{type:"vec4",value:O||l.defaultVec4Color},{type:"mat3x3",value:n}])}]),t.colors){const e=t.colors;r.setVertexBuffer(0,k.get(t.points,e,(()=>{const n=function(e){const t=[],n=Math.min(...e.map((e=>e.data.length/e.num)));for(let r=0;r{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,l.getNumArrayPointsBounding)(t.points);r=I(t.pattern,n,e,s,P,h)}}return r};return(t,n,r,o,s,c)=>{!b.instanced||e.width===b.instance.width&&e.height===b.instance.height||b.reset(),!C.instanced||e.width===C.instance.width&&e.height===C.instance.height||C.reset();const u=(0,l.getWorldMatrix)(e,r,o,s,c),p=a.createCommandEncoder();let d=L(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)}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}},1948:(e,t,n)=>{"use strict";n.r(t),n.d(t,{getImageFromCache:()=>o});const r=new Map;function o(e,t){var n;const o=r.get(e);return o?Array.isArray(o)?void o.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,o),o):(r.set(e,[]),void function(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}))}(e,null==t?void 0:t.crossOrigin).then((n=>{createImageBitmap(n).then((n=>{var o,i;const a=r.get(e);r.set(e,n),Array.isArray(a)&&a.forEach((e=>{e()})),null==(o=null==t?void 0:t.callback)||o.call(t,n),null==(i=null==t?void 0:t.rerender)||i.call(t)}))})))}},7731:(e,t,n)=>{"use strict";n.r(t);var r=n(5136),o={};for(const e in r)"default"!==e&&(o[e]=()=>r[e]);n.d(t,o);var i=n(5319);o={};for(const e in i)"default"!==e&&(o[e]=()=>i[e]);n.d(t,o);var a=n(194);o={};for(const e in a)"default"!==e&&(o[e]=()=>a[e]);n.d(t,o);var s=n(9625);o={};for(const e in s)"default"!==e&&(o[e]=()=>s[e]);n.d(t,o);var l=n(7043);o={};for(const e in l)"default"!==e&&(o[e]=()=>l[e]);n.d(t,o);var c=n(6299);o={};for(const e in c)"default"!==e&&(o[e]=()=>c[e]);n.d(t,o);var u=n(8485);o={};for(const e in u)"default"!==e&&(o[e]=()=>u[e]);n.d(t,o);var p=n(9417);o={};for(const e in p)"default"!==e&&(o[e]=()=>p[e]);n.d(t,o);var d=n(1948);o={};for(const e in d)"default"!==e&&(o[e]=()=>d[e]);n.d(t,o);var f=n(8797);o={};for(const e in f)"default"!==e&&(o[e]=()=>f[e]);n.d(t,o)},194:(e,t,n)=>{"use strict";n.r(t),n.d(t,{reactCanvasRenderTarget:()=>b});var r=n(7378),o=n(6581),i=n(8485),a=n(1948),s=n(5136),l=n(7504),c=n(3516),u=n(5395),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,x=(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},v=(e,t)=>d(e,f(t));const b={type:"canvas",renderResult:(e,t,n,o)=>r.createElement(S,{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,strokeWidthScale:null==o?void 0:o.strokeWidthScale}),renderEmpty:()=>()=>{},renderGroup:(e,t)=>(n,r,i)=>{const a=n.globalAlpha;n.save(),void 0!==(null==t?void 0:t.opacity)&&(n.globalAlpha=a*t.opacity),(null==t?void 0:t.translate)&&n.translate(t.translate.x,t.translate.y),(null==t?void 0:t.angle)&&void 0!==(null==t?void 0:t.base)&&(n.translate(t.base.x,null==t?void 0:t.base.y),n.rotate((0,c.angleToRadian)(t.angle)),n.translate(-t.base.x,-t.base.y)),(null==t?void 0:t.rotation)&&void 0!==(null==t?void 0:t.base)&&(n.translate(t.base.x,null==t?void 0:t.base.y),n.rotate(t.rotation),n.translate(-t.base.x,-t.base.y)),(null==t?void 0:t.matrix)&&n.setTransform(n.getTransform().multiply(o.m3.getTransformInit(t.matrix))),e.forEach((e=>{e(n,r,i)})),n.restore()},renderRect:(e,t,n,r,o)=>(a,s,u)=>{var p,d;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,c.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);const f=(null!=(p=null==o?void 0:o.strokeWidth)?p:1)*s;f&&(a.lineWidth=f,a.strokeStyle=(0,l.getColorString)(null!=(d=null==o?void 0:o.strokeColor)?d:0),a.strokeRect(e,t,n,r)),C(a,s,u,o),k(a,s,u,o),a.restore()},renderPolyline(e,t){const n=null!=t?t:{},{partsStyles:r}=n,o=((e,t)=>{var n={};for(var r in e)h.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&g)for(var r of g(e))t.indexOf(r)<0&&m.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)=>{var a;n.save(),n.beginPath(),(0,i.setCanvasLineDash)(n,t);for(let r=0;r(o,a,s)=>{o.save(),o.beginPath(),(0,i.setCanvasLineDash)(o,r),o.arc(e,t,n,0,2*Math.PI),C(o,a,s,r),k(o,a,s,r),o.restore()},renderEllipse:(e,t,n,r,o)=>(a,s,l)=>{var u;a.save(),a.beginPath(),(0,i.setCanvasLineDash)(a,o);const p=null!=(u=null==o?void 0:o.rotation)?u:(0,c.angleToRadian)(null==o?void 0:o.angle);a.ellipse(e,t,n,r,p,0,2*Math.PI),C(a,s,l,o),k(a,s,l,o),a.restore()},renderArc:(e,t,n,r,o,a)=>(s,l,u)=>{s.save(),s.beginPath(),(0,i.setCanvasLineDash)(s,a),s.arc(e,t,n,(0,c.angleToRadian)(r),(0,c.angleToRadian)(o),null==a?void 0:a.counterclockwise),C(s,l,u,a),k(s,l,u,a),s.restore()},renderEllipseArc:(e,t,n,r,o,a,s)=>(l,u,p)=>{var d;l.save(),l.beginPath(),(0,i.setCanvasLineDash)(l,s);const f=null!=(d=null==s?void 0:s.rotation)?d:(0,c.angleToRadian)(null==s?void 0:s.angle);l.ellipse(e,t,n,r,f,(0,c.angleToRadian)(o),(0,c.angleToRadian)(a),null==s?void 0:s.counterclockwise),C(l,u,p,s),k(l,u,p,s),l.restore()},renderPathCommands:(e,t)=>(n,r,o)=>{let a;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(a){const e=(0,s.getEllipseArcByStartEnd)(a,t.rx,t.ry,t.angle,t.largeArc,t.sweep,t.to);e&&n.ellipse(e.cx,e.cy,e.rx,e.ry,(0,c.angleToRadian)(e.angle),(0,c.angleToRadian)(e.startAngle),(0,c.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&&(a=t.to)}(null==t?void 0:t.closed)&&n.closePath(),C(n,r,o,t),k(n,r,o,t),n.restore()},renderText:(e,t,n,r,o,a,s)=>(c,u,p)=>{var d,f,g,h;c.save(),c.font=`${null!=(d=null==s?void 0:s.fontWeight)?d:"normal"} ${null!=(f=null==s?void 0:s.fontStyle)?f:"normal"} ${o}px ${a}`,c.textAlign=null!=(g=null==s?void 0:s.textAlign)?g:"left",c.textBaseline=null!=(h=null==s?void 0:s.textBaseline)?h:"alphabetic",k(c,u,p,v(x({},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,l.getColorString)(s.strokeColor,s.strokeOpacity):w(c,u,p,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,l,c)=>{const u=(0,a.getImageFromCache)(e,{rerender:c,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)=>{n.save(),n.beginPath(),(0,i.setCanvasLineDash)(n,t);for(const t of e)for(let e=0;e{i.addColorStop(e.offset,(0,l.getColorString)(e.color,e.opacity))})),e.fillStyle=i}else if(void 0!==r.fillRadialGradient){const{start:t,end:n,stops:o}=r.fillRadialGradient,i=e.createRadialGradient(t.x,t.y,t.r,n.x,n.y,n.r);o.forEach((e=>{i.addColorStop(e.offset,(0,l.getColorString)(e.color,e.opacity))})),e.fillStyle=i}o?o():e.fill("evenodd")}}function w(e,t,n,r){if(null==r?void 0:r.strokePattern){const o=E(e,r.strokePattern,t,n);o&&(e.strokeStyle=o)}else if(void 0!==(null==r?void 0:r.strokeLinearGradient)){const{start:t,end:n,stops:o}=r.strokeLinearGradient,i=e.createLinearGradient(t.x,t.y,n.x,n.y);o.forEach((e=>{i.addColorStop(e.offset,(0,l.getColorString)(e.color,e.opacity))})),e.strokeStyle=i}else if(void 0!==(null==r?void 0:r.strokeRadialGradient)){const{start:t,end:n,stops:o}=r.strokeRadialGradient,i=e.createRadialGradient(t.x,t.y,t.r,n.x,n.y,n.r);o.forEach((e=>{i.addColorStop(e.offset,(0,l.getColorString)(e.color,e.opacity))})),e.strokeStyle=i}}function S(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;if(t.current){const r=t.current.getContext("2d");if(r){const t=Date.now();r.fillStyle=(0,l.getColorString)(null!=(n=e.backgroundColor)?n:16777215),r.fillRect(0,0,r.canvas.width,r.canvas.height),r.save(),e.transform&&(r.translate(e.width/2,e.height/2),r.scale(e.transform.scale,e.transform.scale),r.translate(e.transform.x/e.transform.scale-e.width/2,e.transform.y/e.transform.scale-e.height/2),e.transform.rotate&&r.rotate(e.transform.rotate));const i=e.strokeWidthScale||1,a=()=>o((e=>e+1));for(const t of e.draws)t(r,i,a);r.restore(),e.debug&&console.info(Date.now()-t)}}}),[e.draws,t.current,e.transform,e.backgroundColor,n]),r.createElement("canvas",x({ref:t,width:e.width,height:e.height},e.attributes))}},5136:(e,t,n)=>{"use strict";n.r(t),n.d(t,{geometryLineToPathCommands:()=>w,getArcControlPoint:()=>S,getEllipseArcByStartEnd:()=>_,getGeometryLinesPoints:()=>E,getPathCommandEndPoint:()=>R,getPathCommandsPoints:()=>C,getRoundedRectPoints:()=>b,pathCommandPointsToPath:()=>P,pathCommandsToGeometryLines:()=>k,renderPartStyledPolyline:()=>v});var r=n(9195),o=n(3516),i=n(9605),a=n(6003),s=n(6632),l=n(5791),c=n(4275),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},x=(e,t)=>p(e,d(t));function v(e,t,n,r){return e.renderGroup([e.renderPolyline(n,x(y({},r),{skippedLines:t.map((e=>e.index))})),...t.map((({index:t,color:o,opacity:i})=>e.renderPolyline([n[t],n[t+1]],x(y({},r),{strokeColor:o,strokeOpacity:i}))))])}function b(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)]}function C(e){const t=[],n=k(e);for(const e of n)t.push(E(e));return t}function E(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,r.arcToPolyline)(i.curve,n)):"ellipse arc"===i.type?o.push(...(0,r.ellipseArcToPolyline)(i.curve,n)):"quadratic curve"===i.type?o.push(...(0,s.getQuadraticCurvePoints)(i.curve.from,i.curve.cp,i.curve.to,t)):"bezier curve"===i.type&&o.push(...(0,s.getBezierCurvePoints)(i.curve.from,i.curve.cp1,i.curve.cp2,i.curve.to,t));return o}function k(e){const t=[];let n,s,l=[];for(const c of e)if("move"===c.type)l.length>0&&(l.length>1&&t.push(l),l=[],n=void 0),s=c.to,n||(n=c.to);else if("line"===c.type)s&&l.push([s,c.to]),s=c.to;else if("arc"===c.type){if(s){const e=c.from,t=c.to,n=(0,r.twoPointLineToGeneralFormLine)(s,e),u=(0,r.twoPointLineToGeneralFormLine)(e,t),p=(0,r.getPointSideOfLine)(t,n);if((0,r.isZero)(p))s&&(l.push([s,t]),s=t);else{const e=p<0?0:1,t=(0,i.getTwoGeneralFormLinesIntersectionPoint)((0,r.getParallelLinesByDistance)(n,c.radius)[e],(0,r.getParallelLinesByDistance)(u,c.radius)[e]);if(t){const e=(0,a.getPerpendicularPoint)(t,n),i=(0,a.getPerpendicularPoint)(t,u);s&&((0,r.isSamePoint)(s,e)||l.push([s,{x:e.x,y:e.y}]),s=i);const d=(0,o.radianToAngle)((0,r.getTwoPointsRadian)(e,t)),f=(0,o.radianToAngle)((0,r.getTwoPointsRadian)(i,t));l.push({type:"arc",curve:{x:t.x,y:t.y,startAngle:d,endAngle:f,r:c.radius,counterclockwise:p>0}})}}}}else if("ellipseArc"===c.type){if(s){const e=_(s,c.rx,c.ry,c.angle,c.largeArc,c.sweep,c.to);e&&l.push({type:"ellipse arc",curve:e})}s=c.to}else"bezierCurve"===c.type?(s&&l.push({type:"bezier curve",curve:{from:s,cp1:c.cp1,cp2:c.cp2,to:c.to}}),s=c.to):"quadraticCurve"===c.type?(s&&l.push({type:"quadratic curve",curve:{from:s,cp:c.cp,to:c.to}}),s=c.to):"close"===c.type&&l.length>0&&(l.length>1&&(n&&s&&!(0,r.isSamePoint)(n,s)&&l.push([s,n]),t.push(l)),l=[],n=void 0);return l.length>0&&t.push(l),t}function w(e){const t=[];let n;for(const o of e){const{start:e,end:i}=(0,l.getGeometryLineStartAndEnd)(o);if(n&&(0,r.isSamePoint)(n,e)||t.push({type:"move",to:e}),Array.isArray(o))t.push({type:"line",to:i});else if("arc"===o.type){const e=S(o.curve);e&&t.push({type:"arc",from:e,to:i,radius:o.curve.r})}else if("ellipse arc"===o.type){const e=(0,r.getFormattedEndAngle)(o.curve),n=Math.abs(e-o.curve.startAngle)>180;t.push({type:"ellipseArc",to:i,rx:o.curve.rx,ry:o.curve.ry,angle:o.curve.angle||0,sweep:!o.curve.counterclockwise,largeArc:n})}else"quadratic curve"===o.type?t.push({type:"quadraticCurve",cp:o.curve.cp,to:o.curve.to}):"bezier curve"===o.type&&t.push({type:"bezierCurve",cp1:o.curve.cp1,cp2:o.curve.cp2,to:o.curve.to});n=i}return t}function S(e){const t=(0,r.getCirclePointAtRadian)(e,(0,o.angleToRadian)(e.startAngle)),n=(0,r.getCirclePointAtRadian)(e,(0,o.angleToRadian)(e.endAngle)),s=(0,a.getPerpendicular)(t,(0,r.twoPointLineToGeneralFormLine)(e,t)),l=(0,a.getPerpendicular)(n,(0,r.twoPointLineToGeneralFormLine)(e,n));return(0,i.getTwoGeneralFormLinesIntersectionPoint)(s,l)}function P(e){const t=[];let n;for(const o of e)n?(0,r.pointInPolygon)(o[0],n.polygon)?n.holes.push(o):(n&&t.push([n.polygon,...n.holes]),n={polygon:o,holes:[]}):n={polygon:o,holes:[]};return n&&t.push([n.polygon,...n.holes]),t}function R(e,t){if(t>=0){const n=e[t];if("close"!==n.type){if("arc"!==n.type)return n.to;const o=R(e,t-1);if(o){const e=n.from,t=n.to,s=(0,r.twoPointLineToGeneralFormLine)(o,e),l=(0,r.twoPointLineToGeneralFormLine)(e,t),c=(0,r.getPointSideOfLine)(t,s);if((0,r.isZero)(c))return n.to;const u=c<0?0:1,p=(0,i.getTwoGeneralFormLinesIntersectionPoint)((0,r.getParallelLinesByDistance)(s,n.radius)[u],(0,r.getParallelLinesByDistance)(l,n.radius)[u]);if(p){const e=(0,a.getPerpendicularPoint)(p,l),t=(0,r.getTwoPointsRadian)(e,p);return{x:p.x+n.radius*Math.cos(t),y:p.y+n.radius*Math.sin(t)}}}}}}function _(e,t,n,i,a,s,l){const u=(0,o.angleToRadian)(i),p=Math.sin(u),d=Math.cos(u),f=1/t/t,g=1/n/n,h=e.x,m=e.y,v=l.x,b=l.y,C=v-h,E=b-m,k=d*d*f+p*p*g,w=p*p*f+d*d*g,S=f-g,P=2*(S*p*d*C+w*E),R=2*(k*C+S*p*d*E)/P,_=(k*C*C+2*p*d*S*C*E+w*E*E)/P,T=(0,c.calculateEquation2)(k-2*p*d*S*R+w*R*R,-2*p*d*S*_+2*w*R*_,w*_*_-1);if(0===T.length)return;const A=T.map((e=>({x:h-e,y:m+R*e+_})));let M;M=1===A.length?0:(0,r.getPointSideOfLine)(A[0],(0,r.twoPointLineToGeneralFormLine)(e,l))>0?a===s?0:1:a!==s?0:1;const L=A[M],O={cx:L.x,cy:L.y,rx:t,ry:n,angle:i};return x(y({},O),{startAngle:(0,r.getEllipseAngle)(e,O),endAngle:(0,r.getEllipseAngle)(l,O),counterclockwise:!s})}},5319:(e,t,n)=>{"use strict";n.r(t),n.d(t,{ellipsePolarToCartesian:()=>T,getRotateTransform:()=>A,polarToCartesian:()=>_,reactSvgRenderTarget:()=>E});var r=n(7378),o=n(7504),i=n(9195),a=n(6581),s=n(5547),l=n(5136),c=n(3516),u=n(9605),p=n(6003),d=n(5395),f=Object.defineProperty,g=Object.defineProperties,h=Object.getOwnPropertyDescriptors,m=Object.getOwnPropertySymbols,y=Object.prototype.hasOwnProperty,x=Object.prototype.propertyIsEnumerable,v=(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)&&v(e,n,t[n]);if(m)for(var n of m(t))x.call(t,n)&&v(e,n,t[n]);return e},C=(e,t)=>g(e,h(t));const E={type:"svg",renderResult(e,t,n,i){var a,s,l,c,u,p,d,f,g;const h=null!=(s=null==(a=null==i?void 0:i.transform)?void 0:a.x)?s:0,m=null!=(c=null==(l=null==i?void 0:i.transform)?void 0:l.y)?c:0,y=null!=(p=null==(u=null==i?void 0:i.transform)?void 0:u.scale)?p:1,x=t/y,v=n/y,E=(t-x)/2-h/y,k=(n-v)/2-m/y,w=(null==i?void 0:i.strokeWidthScale)||1,S=null!=(f=null==(d=null==i?void 0:i.transform)?void 0:d.rotate)?f:0;return r.createElement("svg",C(b({version:"1.1",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",viewBox:`${E} ${k} ${x} ${v}`,width:t,height:n,colorInterpolationFilters:"sRGB"},null==i?void 0:i.attributes),{style:C(b({},null==(g=null==i?void 0:i.attributes)?void 0:g.style),{backgroundColor:void 0!==(null==i?void 0:i.backgroundColor)?(0,o.getColorString)(i.backgroundColor):void 0})}),r.createElement("g",{style:{rotate:`${S}rad`}},e.map(((e,t)=>e(t,y,w)))))},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=A(t.base.x,t.base.y,t);e&&n.push(e)}return(null==t?void 0:t.matrix)&&n.push(`matrix(${a.m3.getTransform(t.matrix).join(" ")})`),(o,i,a)=>r.createElement("g",{transform:n.join(" "),key:o,opacity:null==t?void 0:t.opacity},e.map(((e,t)=>e(t,i,a))))},renderRect:(e,t,n,o,i)=>k(((a,s,l,c)=>r.createElement("rect",C(b({x:e,y:t,width:n,height:o},P(l,c,i)),{fill:a,stroke:s,transform:A(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)y.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&m)for(var r of m(e))t.indexOf(r)<0&&x.call(e,r)&&(n[r]=e[r]);return n})(n,["partsStyles"]);if(o&&o.length>0)return(0,l.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",C(b({d:n},P(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",C(b({points:s},P(o,i,t)),{fill:e,stroke:n}))),t)},renderPolygon(e,t){return this.renderPolyline(e,C(b({},t),{closed:!0}))},renderCircle:(e,t,n,o)=>k(((i,a,s,l)=>r.createElement("circle",C(b({cx:e,cy:t,r:n},P(s,l,o)),{fill:i,stroke:a}))),o),renderEllipse:(e,t,n,o,i)=>k(((a,s,l,c)=>r.createElement("ellipse",C(b({cx:e,cy:t,rx:n,ry:o},P(l,c,i)),{fill:a,stroke:s,transform:A(e,t,i)}))),i),renderArc(e,t,n,o,i,a){const s=_(e,t,n,i),l=_(e,t,n,o),c=i-o<=180,u=((null==a?void 0:a.counterclockwise)?!c:c)?"0":"1",p=(null==a?void 0:a.counterclockwise)?"1":"0";return k(((e,t,o,i)=>r.createElement("path",C(b({d:`M ${s.x} ${s.y} A ${n} ${n} 0 ${u} ${p} ${l.x} ${l.y}`},P(o,i,a)),{fill:e,stroke:t}))),a)},renderEllipseArc(e,t,n,o,i,a,s){const l=T(e,t,n,o,a),c=T(e,t,n,o,i),u=a-i<=180,p=((null==s?void 0:s.counterclockwise)?!u:u)?"0":"1",d=(null==s?void 0:s.counterclockwise)?"1":"0";return k(((i,a,u,f)=>r.createElement("path",C(b({d:`M ${l.x} ${l.y} A ${n} ${o} 0 ${p} ${d} ${c.x} ${c.y}`},P(u,f,s)),{fill:i,stroke:a,transform:A(e,t,s)}))),s)},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,i.twoPointLineToGeneralFormLine)(n,e),s=(0,i.twoPointLineToGeneralFormLine)(e,r),l=(0,i.getPointSideOfLine)(r,a);if((0,i.isZero)(l))o+=` L ${r.x} ${r.y}`,n=r;else{const e=l<0?0:1,r=(0,u.getTwoGeneralFormLinesIntersectionPoint)((0,i.getParallelLinesByDistance)(a,t.radius)[e],(0,i.getParallelLinesByDistance)(s,t.radius)[e]);if(r){const e=(0,p.getPerpendicularPoint)(r,a),i=(0,p.getPerpendicularPoint)(r,s);o+=` L ${e.x} ${e.y} A ${t.radius} ${t.radius} 0 0 ${l<0?1:0} ${i.x} ${i.y}`,n=i}}}}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 k(((e,n,i,a)=>r.createElement("path",C(b({d:o},P(i,a,t)),{fill:e,stroke:n}))),t)},renderText:(e,t,n,o,i,a,s)=>k(((o,l,c,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:l,strokeDasharray:R(c,u,s),strokeDashoffset:null==s?void 0:s.dashOffset,fillOpacity:null==s?void 0:s.fillOpacity,strokeOpacity:null==s?void 0:s.strokeOpacity}},n)}),C(b({},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}),l=null==a?void 0:a.filters,e=>{let t,n;if(l&&l.length>0){const e=S(l),o=[];l.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,l},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 l;return o?l=n[0]:(l=n.join(" "),(null==t?void 0:t.closed)&&(l+=" Z")),r.createElement("path",C(b({d:l},P(a,s,t)),{fill:e,stroke:i,fillRule:"evenodd"}))}),t,void 0,i)}};function k(e,t,n,i){return(a,s,l)=>{let c,u,p,d=void 0!==(null==t?void 0:t.fillColor)?(0,o.getColorString)(t.fillColor):"none",f=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);u=r.createElement("pattern",{id:e,patternUnits:"userSpaceOnUse",width:t.strokePattern.width,height:t.strokePattern.height},t.strokePattern.pattern()(e,s,l)),f=`url(#${e})`}else if(null==t?void 0:t.strokeLinearGradient){const e=S(t.strokeLinearGradient);u=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)})))),f=`url(#${e})`}else if(null==t?void 0:t.strokeRadialGradient){const e=S(t.strokeRadialGradient);u=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)})))),f=`url(#${e})`}if(null==t?void 0:t.fillPattern){const e=S(t.fillPattern);c=r.createElement("pattern",{id:e,patternUnits:"userSpaceOnUse",width:t.fillPattern.width,height:t.fillPattern.height},t.fillPattern.pattern()(e,s,l)),d=`url(#${e})`}else if(null==t?void 0:t.fillLinearGradient){const e=S(t.fillLinearGradient);c=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)})))),d=`url(#${e})`}else if(null==t?void 0:t.fillRadialGradient){const e=S(t.fillRadialGradient);c=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)})))),d=`url(#${e})`}const g=e(d,f,s,l);if(null==t?void 0:t.clip){const n=S(t.clip),o=t.clip()(n,s,l);i?(c=r.createElement(r.Fragment,null,r.createElement("mask",{id:n},e("white",f,s,l),i),g),p=r.createElement("g",{mask:`url(#${n})`},o)):(c=r.createElement(r.Fragment,null,r.createElement("clipPath",{id:n},g),g),p=r.createElement("g",{clipPath:`url(#${n})`},o))}else p=g;return r.createElement(r.Fragment,{key:a},c,u,p)}}const w=new s.WeakmapCache;function S(e){return w.get(e,(()=>Math.random().toString()))}function P(e,t,n){var r,o,i,a;return{strokeWidth:null!=(r=null==n?void 0:n.strokeWidth)?r:1,vectorEffect:1===t?void 0:"non-scaling-stroke",strokeDasharray:R(e,t,n),strokeDashoffset:null==n?void 0:n.dashOffset,strokeMiterlimit:null!=(o=null==n?void 0:n.miterLimit)?o:d.defaultMiterLimit,strokeLinejoin:null!=(i=null==n?void 0:n.lineJoin)?i:"miter",strokeLinecap:null!=(a=null==n?void 0:n.lineCap)?a:"butt",fillOpacity:null==n?void 0:n.fillOpacity,strokeOpacity:null==n?void 0:n.strokeOpacity}}function R(e,t,n){if((null==n?void 0:n.dashArray)&&n.dashArray.length>0)return n.dashArray.map((n=>n*(1===t?1:e))).join(" ")}function _(e,t,n,r){return T(e,t,n,n,r)}function T(e,t,n,r,o){const i=(0,c.angleToRadian)(o);return{x:e+n*Math.cos(i),y:t+r*Math.sin(i)}}function A(e,t,n){return(null==n?void 0:n.angle)?`rotate(${n.angle},${e},${t})`:(null==n?void 0:n.rotation)?`rotate(${(0,c.radianToAngle)(n.rotation)},${e},${t})`:void 0}},9625:(e,t,n)=>{"use strict";n.r(t),n.d(t,{reactWebglRenderTarget:()=>v});var r=n(7378),o=n(9195),i=n(5136),a=n(8485),s=n(7504),l=n(3516),c=Object.defineProperty,u=Object.defineProperties,p=Object.getOwnPropertyDescriptors,d=Object.getOwnPropertySymbols,f=Object.prototype.hasOwnProperty,g=Object.prototype.propertyIsEnumerable,h=(e,t,n)=>t in e?c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,m=(e,t)=>{for(var n in t||(t={}))f.call(t,n)&&h(e,n,t[n]);if(d)for(var n of d(t))g.call(t,n)&&h(e,n,t[n]);return e},y=(e,t)=>u(e,p(t)),x=(e,t)=>{var n={};for(var r in e)f.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&d)for(var r of d(e))t.indexOf(r)<0&&g.call(e,r)&&(n[r]=e[r]);return n};const v={type:"webgl",renderResult:(e,t,n,o)=>r.createElement(b,{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,strokeWidthScale:null==o?void 0:o.strokeWidthScale}),renderEmpty:()=>()=>[],renderGroup:(e,t)=>(n,r,o,i)=>(0,a.getGroupGraphics)(e.map((e=>e(n,r))).flat(),o,t,i),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,l.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,a=x(n,["partsStyles"]);if(r&&r.length>0)return(0,i.renderPartStyledPolyline)(this,r,e,a);const s=null!=t?t:{},{dashArray:l,closed:c}=s,u=x(s,["dashArray","closed"]);c&&(e=(0,o.polygonToPolyline)(e));const p=(0,o.dashedPolylineToLines)(e,l,null==t?void 0:t.skippedLines,null==t?void 0:t.dashOffset);return this.renderPath(p,u)},renderPolygon(e,t){return this.renderPolyline(e,y(m({},t),{closed:!0}))},renderCircle(e,t,n,r){const i=(0,o.arcToPolyline)({x:e,y:t,r:n,startAngle:0,endAngle:360},5);return this.renderPolyline(i,r)},renderEllipse(e,t,n,r,i){let a=0;(null==i?void 0:i.angle)?a=i.angle:(null==i?void 0:i.rotation)&&(a=(0,l.radianToAngle)(i.rotation));const s=(0,o.ellipseToPolygon)({cx:e,cy:t,rx:n,ry:r,angle:a},5);return this.renderPolygon(s,i)},renderArc(e,t,n,r,i,a){const s=(0,o.arcToPolyline)({x:e,y:t,r:n,startAngle:r,endAngle:i,counterclockwise:null==a?void 0:a.counterclockwise},5);return this.renderPolyline(s,a)},renderEllipseArc(e,t,n,r,i,a,s){let c=0;(null==s?void 0:s.angle)?c=s.angle:(null==s?void 0:s.rotation)&&(c=(0,l.radianToAngle)(s.rotation));const u=(0,o.ellipseArcToPolyline)({cx:e,cy:t,rx:n,ry:r,startAngle:i,endAngle:a,angle:c,counterclockwise:null==s?void 0:s.counterclockwise},5);return this.renderPolyline(u,s)},renderPathCommands(e,t){const n=(0,i.getPathCommandsPoints)(e),r=(0,i.pathCommandPointsToPath)(n);return this.renderGroup(r.map((e=>this.renderPath(e,t))))},renderText:(e,t,n,r,o,i,s)=>(l,c)=>{let u,p;u=void 0!==r&&"number"!=typeof r?{graphics:r.pattern()(l,c),width:r.width,height:r.height}:r,void 0!==(null==s?void 0:s.strokePattern)&&(p={graphics:s.strokePattern.pattern()(l,c),width:s.strokePattern.width,height:s.strokePattern.height});const d=(0,a.getTextGraphic)(e,t,n,u,o,i,y(m({},s),{strokePattern:p}));return d?[d]:[]},renderImage:(e,t,n,r,o,i)=>(s,l)=>{const c=(0,a.getImageGraphic)(e,t,n,r,o,l,i);return c?[c]:[]},renderPath:(e,t)=>(n,r)=>{let o,i;return void 0!==(null==t?void 0:t.clip)&&(o={graphics:t.clip()(n,r)}),void 0!==(null==t?void 0:t.fillPattern)&&(o={graphics:t.fillPattern.pattern()(n,r),width:t.fillPattern.width,height:t.fillPattern.height}),void 0!==(null==t?void 0:t.strokePattern)&&(i={graphics:t.strokePattern.pattern()(n,r),width:t.strokePattern.width,height:t.strokePattern.height}),(0,a.getPathGraphics)(e,n,y(m({},t),{fillPattern:o,strokePattern:i}))}};function b(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)return;const n=(0,a.createWebglRenderer)(t.current);if(!n)return;const r=()=>o((e=>e+1));i.current=(t,o,i,a,s,l,c)=>{const u=performance.now();n(t.map((e=>e(l,r))).flat(),o,i,a,s,c),e.debug&&console.info(Math.round(performance.now()-u))}}),[t.current,e.debug]),r.useEffect((()=>{var t,n,r,o,a,l,c,u,p;if(i.current){const d=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!=(l=null==(a=e.transform)?void 0:a.scale)?l:1,h=(0,s.colorNumberToRec)(null!=(c=e.backgroundColor)?c:16777215),m=null!=(u=e.strokeWidthScale)?u:1;i.current(e.graphics,h,d,f,g,m,null==(p=e.transform)?void 0:p.rotate)}}),[e.graphics,e.backgroundColor,i.current,e.transform,n]),r.createElement("canvas",m({ref:t,width:e.width,height:e.height},e.attributes))}},7043:(e,t,n)=>{"use strict";n.r(t),n.d(t,{reactWebgpuRenderTarget:()=>h});var r=n(7378),o=n(7504),i=n(9417),a=n(9625),s=Object.defineProperty,l=Object.defineProperties,c=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=l(g({},a.reactWebglRenderTarget),c({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,strokeWidthScale:null==o?void 0:o.strokeWidthScale})}));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&&(0,i.createWebgpuRenderer)(t.current).then((t=>{if(!t)return;const n=()=>a((e=>e+1));s.current=(r,o,i,a,s,l,c)=>{const u=performance.now();t(r.map((e=>e(l,n))).flat(),o,i,a,s,c),e.debug&&console.info(Math.round(performance.now()-u))},n()}))}),[t.current,e.debug]),r.useEffect((()=>{var t,n,r,i,a,l,c,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!=(l=null==(a=e.transform)?void 0:a.scale)?l:1,h=(0,o.colorNumberToRec)(null!=(c=e.backgroundColor)?c:16777215),m=null!=(u=e.strokeWidthScale)?u:1;s.current(e.graphics,h,d,f,g,m,null==(p=e.transform)?void 0:p.rotate)}}),[e.graphics,e.backgroundColor,s.current,e.transform,n]),r.createElement("canvas",g({ref:t,width:e.width,height:e.height},e.attributes))}},6299:(e,t,n)=>{"use strict";n.r(t),n.d(t,{reverseTransformPosition:()=>o,scaleByCursorPosition:()=>l,transformPosition:()=>i,zoomToFit:()=>a,zoomToFitPoints:()=>s});var r=n(9195);function o(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,r.rotatePosition)(e,{x:0,y:0},-t.rotate)),e):e}function i(e,t){return t?(t.rotate&&(e=(0,r.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 a(e,{width:t,height:n},o,i=.8){if(e&&!(0,r.equals)(e.start.x,e.end.x)&&!(0,r.equals)(e.start.y,e.end.y)){const a=Math.min(t/Math.abs(e.end.x-e.start.x),n/Math.abs(e.end.y-e.start.y))*i;return{scale:a,x:(o.x-(0,r.getTwoNumberCenter)(e.start.x,e.end.x))*a,y:(o.y-(0,r.getTwoNumberCenter)(e.start.y,e.end.y))*a}}}function s(e,{width:t,height:n},o,i=.8,a){const s=(0,r.getPointsBoundingUnsafe)(e);if(s&&!(0,r.equals)(s.start.x,s.end.x)&&!(0,r.equals)(s.start.y,s.end.y)){let l,c;if(a){const t=(0,r.getPointsBoundingUnsafe)(e.map((e=>(0,r.rotatePosition)(e,{x:0,y:0},a))));l=Math.abs(t.end.x-t.start.x),c=Math.abs(t.end.y-t.start.y)}else l=Math.abs(s.end.x-s.start.x),c=Math.abs(s.end.y-s.start.y);const u=Math.min(t/l,n/c)*i;let p=(0,r.getTwoPointCenter)(s.start,s.end);return a&&(p=(0,r.rotatePosition)(p,{x:0,y:0},a)),{scale:u,x:(o.x-p.x)*u,y:(o.y-p.y)*u}}}function l({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}}},2997:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Scrollbar:()=>p});var r=n(7378),o=n(6239),i=Object.defineProperty,a=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,c=(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)&&c(e,n,t[n]);if(a)for(var n of a(t))l.call(t,n)&&c(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-l),0);return i!==d&&e.onChange((i-c)*p),{x:r,y:o}}});if(n>=i)return null;const l=Math.max(12,i?n*n/i:0),c=(n/2-l/2)*("head"===e.align?0:"tail"===e.align?2:1),p=-(i-n)/(n-l),d=e.value/p+c,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=`${l}px`,g.top=`${d}px`):(f.height="8px",f.width=`${n}px`,f.left="0px",f.bottom="0px",g.height="8px",g.width=`${l}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)}},7732:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useAttributedTextEditor:()=>E});var r=n(7378),o=n(7310),i=n(9195),a=n(1799),s=n(2997),l=n(1301),c=n(1502),u=n(2357),p=n(8533),d=n(8137),f=Object.defineProperty,g=Object.defineProperties,h=Object.getOwnPropertyDescriptors,m=Object.getOwnPropertySymbols,y=Object.prototype.hasOwnProperty,x=Object.prototype.propertyIsEnumerable,v=(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)&&v(e,n,t[n]);if(m)for(var n of m(t))x.call(t,n)&&v(e,n,t[n]);return e},C=(e,t)=>g(e,h(t));function E(e){var t,n;const[f,g]=r.useState(0),[h,m]=r.useState(),y=r.useRef(null),[x,v]=r.useState(0),[E,k]=r.useState(),[w,S]=r.useState(!1),P=t=>{var n,r,o;if(e.readOnly)return;let i,a,s=E;te?(a=te.min,i=_(te),ce.attributes&&!(null==(n=e.getReadonlyType)?void 0:n.call(e,ce.attributes))&&(s={attributes:ce.attributes,index:te.min})):(a=f,i=e.state),g(a+t.length);const l=[];let c=0,u=!1;const p=(null==(r=Y.find((e=>f===e.min)))?void 0:r.min)===a,d=(null==(o=Y.find((e=>f===e.max)))?void 0:o.max)===a;for(const e of i){const n=a-c,r=M(e);if(n>=0&&(d?n0&&l.push({attributes:e.attributes,insert:e.insert.slice(0,n)}),l.push({attributes:b(b({},e.attributes),s.attributes),insert:t}),n{if(e.readOnly)return;let o,i;te?(i=te.min,o=_(te)):(i=f,o=e.state),void 0!==r&&(i=r),g(i+n);const a=[];let s=0,l=!1;for(const e of o){const r=i-s,o=M(e);r>=0&&r<=o&&!l?(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)}),l=!0):a.push(e),s+=o}l||a.push(...t),e.setState(a)},_=t=>{g(t.min),m(void 0);const n=[];let r=0;for(const o of e.state){const e=t.min-r,i=t.max-r,a=M(o);e<0?i>=a||(i>=0?i0&&n.push({attributes:o.attributes,insert:o.insert.slice(0,e)}),i{const n=[];let r=0;for(const o of e.state){const e=t.min-r,i=t.max-r,a=M(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===te)return;const n=T(te);return t&&e.setState(_(te)),n},M=t=>{var n;return!0===(null==(n=e.getReadonlyType)?void 0:n.call(e,t.attributes))?1:t.insert.length},L=e=>{const t=U(z(e)).location,{newSelectionStart:n,newLocation:r}=(0,d.getWordByDoubleClick)(q,t,(e=>e.insert));void 0!==n&&m(X({location:n},"min")),void 0!==r&&g(X({location:r},"max"))},O=t=>{var n;if(!t.nativeEvent.isComposing&&229!==t.keyCode&&!(null==(n=e.processInput)?void 0:n.call(e,t))&&!["CapsLock","Tab","Shift","Meta","Escape","Control"].includes(t.key)){if("Backspace"===t.key)return(()=>{if(e.readOnly)return;if(te)return void e.setState(_(te));if(0===f)return;const t=Y.find((e=>f===e.max));if(t)return g(t.min),void e.setState(_(t));g(f-1);const n=[];let r=0,o=!1;for(const t of e.state){const e=f-r,i=M(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("Delete"===t.key)return(()=>{if(e.readOnly)return;if(te)return void e.setState(_(te));if(f===q.length)return;const t=Y.find((e=>f===e.min));if(t)return void e.setState(_(t));const n=[];let r=0,o=!1;for(const t of e.state){const e=f-r+1,i=M(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&&te)return m(void 0),void g(te.min);0!==f&&(e&&void 0===h&&m(f),g(X({location:f-1},"min")))})(t.shiftKey);if("ArrowRight"===t.key)return((e=!1)=>{if(!e&&te)return m(void 0),void g(te.max);f!==q.length&&(e&&void 0===h&&m(f),g(X({location:f+1},"max")))})(t.shiftKey);if("ArrowUp"===t.key)return((e=!1)=>{if(!e&&te)return m(void 0),void g(te.min);e&&void 0===h&&m(f),g(ae{if(!e&&te)return m(void 0),void g(te.max);e&&void 0===h&&m(f),se>=Q.length-1?g(q.length):g(X(U({x:ie,y:ae+Q[se]+Q[se+1]/2+V},!1),"max"))})(t.shiftKey);if("Enter"===t.key)return P("\n");if((0,u.metaKeyIfMacElseCtrlKey)(t)){if("a"===t.key)return m(0),void g(q.length);if("v"===t.key)return e.readOnly||navigator.clipboard.readText().then((e=>{if(e){P(e);try{const t=JSON.parse(e);R(t,function(e){let t=0;for(const n of e)t+=n.insert.length;return t}(t))}catch(t){P(e)}}})),void t.preventDefault();if("c"===t.key||"x"===t.key){const e=A("x"===t.key);return void(e&&navigator.clipboard.writeText(JSON.stringify(e)))}}else t.preventDefault(),1===t.key.length&&P(t.key)}},I=()=>{var t,n;null==(t=e.onLocationChanged)||t.call(e,-1),null==(n=e.onBlur)||n.call(e)},F=r.useRef(),[D,B]=r.useState(),z=e=>{const t=e.target.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}},U=(t,n=!0)=>{const r=(0,o.getFlowLayoutLocation)(t,Q,K,V,e.getWidth,n);return r?(S(r.lineEnd),r):{location:K.length-1}},N=t=>{t.preventDefault();const n=z(t),r=X(U(n),"nearest");if(t.shiftKey)(void 0===h||Math.abs(h-r){if(te)for(let n=te.min;nr.x&&t.y>r.y&&t.x{if(void 0===F.current)return void(void 0!==D&&B(U(z(t),!1).location));const n=z(t),r=X(U(n,!1),"farthest");g(r),r===F.current?m(void 0):m(F.current),e.autoHeight||(n.y>=0&&n.y<=J?$((e=>H(e+2))):n.y<=e.height&&n.y>=e.height-ee&&$((e=>H(e-2))))},W=e=>{var t;j(e),void 0!==D&&te&&(Dte.max&&(R(T(te),te.size,D-te.size),m(D-te.size)),B(void 0)),null==(t=y.current)||t.focus()};(0,c.useGlobalMouseUp)((0,l.useEvent)((()=>{F.current=void 0,B(void 0)})));const{ref:G,y:V,setY:$,filterY:H}=(0,p.useWheelScroll)({minY:e.autoHeight?0:x>e.height?e.height-x:0,maxY:0,disabled:e.autoHeight});r.useEffect((()=>{e.autoHeight&&$(0)}),[e.autoHeight,$]);const q=[],Y=[];for(const n of e.state){const r=null==(t=e.getReadonlyType)?void 0:t.call(e,n.attributes);if(r){const e=q.length,t=q.length+M(n);if(!0===r){Y.push({min:e,max:t}),q.push({insert:n.insert,attributes:n.attributes});continue}const o=Y.find((t=>t.type===r&&t.max===e));o?o.max=t:Y.push({min:e,max:t,type:r})}for(const e of n.insert)q.push({insert:e,attributes:n.attributes})}const X=(e,t)=>{var n;if("farthest"===t||"nearest"===t)if(e.fromRight){const n=Y.find((t=>!t.type&&e.location===t.min));if(n)return"nearest"===t?n.min:n.max}else{const n=Y.find((t=>!t.type&&e.location===t.max));if(n)return"nearest"===t?n.max:n.min}const r=Y.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:K,newContentHeight:Z,lineHeights:Q}=(0,o.flowLayout)({state:q,width:e.width,height:e.autoHeight?void 0:e.height,lineHeight:e.lineHeight,getWidth:e.getWidth,isNewLineContent:e=>"\n"===e.insert,isPartOfComposition:e=>(0,d.isWordCharactor)(e.insert),getComposition:t=>(0,d.getTextComposition)(t,q,e.getWidth,(e=>e.insert)),endContent:{insert:""},scrollY:V,align:e.align,verticalAlign:e.verticalAlign});x0&&K[ne-1];re&&ne--;const oe=null!=(n=K[ne])?n:K[K.length-1],ie=oe.x+(re?e.getWidth(K[ne].content):0),ae=oe.y-V,se=oe.row,le=te?te.min+1:f;let ce=q[le>0?le-1:le];E&&!te&&E.index===f&&(ce=C(b({},ce),{attributes:b(b({},ce.attributes),E.attributes)}));const ue=r.useRef(),pe=r.useRef();r.useEffect((()=>{if((0,i.equals)(ue.current,f)&&(0,i.equals)(pe.current,ae)||e.autoHeight)return;const t=ae+V;t<0?$(-ae):t>e.height-ee&&$(e.height-ee-ae),ue.current=f,pe.current=ae}),[f,ae,V,ee]),r.useEffect((()=>{var t;null==(t=e.onLocationChanged)||t.call(e,f)}),[f]),r.useEffect((()=>{E&&f!==(null==E?void 0:E.index)&&k(void 0)}),[f,E,k]);let de=e.height;return e.autoHeight&&x>e.height&&(de=x),{ref:y,range:te,layoutResult:K,lineHeights:Q,cursor:{x:ie,y:ae+V,row:se},inputText:P,inputContent:R,location:f,setLocation:g,getCopiedContents:A,isSelected:e=>te&&e>=te.min&&e{var n;if(!te)return void("function"!=typeof t&&((null==E?void 0:E.index)===f&&(t=b(b({},E.attributes),t)),k({index:f,attributes:t})));const r=e=>"function"==typeof t?t(e):b(b({},e),t),o=[];let i=0;for(const t of e.state){const a=te.min-i,s=te.max-i,l=M(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>=l?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:b({position:"relative",width:e.width+"px",height:de+"px",border:"1px solid black",clipPath:"inset(0px 0px)"},e.style),onMouseLeave:W,ref:G},r.createElement(a.Cursor,{ref:y,onKeyDown:O,onCompositionEnd:e=>{P(e.data),y.current&&(y.current.value="")},onBlur:I,onFocus:e.onFocus,readOnly:e.readOnly,autoFocus:e.autoFocus,style:{left:ie+"px",top:ae+V+"px",height:Q[se]+"px"}}),t,r.createElement("div",{onMouseDown:N,onMouseMove:j,onMouseUp:W,onDoubleClick:L,style:{inset:"0px",cursor:"text",position:"absolute"}}),!e.autoHeight&&r.createElement(s.Scrollbar,{value:V,type:"vertical",containerSize:e.height,contentSize:x,onChange:$,align:"head"}))}}},1138:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useAudioPlayer:()=>i});var r=n(7378),o=n.n(r);function i(e){const[t,n]=o().useState(0),[r,i]=o().useState(0),[a,s]=o().useState(!1),l=o().useRef(null);return{currentTime:t,duration:r,playing:a,play(){l.current&&(l.current.play(),s(!0))},pause(){l.current&&(l.current.pause(),s(!1))},audio:e&&o().createElement("audio",{onTimeUpdate:()=>{l.current&&n(l.current.currentTime)},onEnded:()=>{s(!1)},preload:"auto",onDurationChange:()=>{l.current&&i(l.current.duration)},ref:l,src:e})}}},3860:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useAudioRecorder:()=>a});var r=n(7378),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,l]=o().useState(0),[c,u]=o().useState(),[p,d]=o().useState(!1),f=o().useRef([]);return{audioUrl:r,duration:s,volume:c,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(l(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),l(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}}},6911:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useCircleArcClickCreate:()=>m});var r=n(7378),o=n(9254),i=n(7386),a=n(8385),s=Object.defineProperty,l=Object.defineProperties,c=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)=>l(e,c(t));function m(e,t,n){const[s,l]=r.useState(),[c,u]=r.useState();let p;s&&(p=void 0===c?"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:x,startPosition:v,middlePosition:b,cursorPosition:C,setCursorPosition:E,clearText:k}=(0,a.useCircleClickCreate)(e,(e=>l(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===c?(u(e),l(h(g({},s),{startAngle:e,endAngle:e})),k()):(e{u(void 0),E(void 0),l(void 0),k()};return{circle:d,arc:s,startPosition:v,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===c){const e=(0,o.radianToAngle)((0,o.getTwoPointsRadian)(r,s));u(e),l(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:()=>m});var r=n(7378),o=n(9195),i=n(7386),a=n(2592),s=Object.defineProperty,l=Object.defineProperties,c=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)=>l(e,c(t));function m(e,t,n){const[s,l]=r.useState(),[c,u]=r.useState(),[p,d]=r.useState();let f="";e&&(f=c?"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:m,setCursorPosition:x,clearText:v,cursorPosition:b,setInputPosition:C,resetInput:E}=(0,a.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(c){if("2 points"===e&&2===n.length){const e=+n[0],r=+n[1];if(!isNaN(e)&&!isNaN(r)){const n={x:c.x+e/2,y:c.y+r/2};t(h(g({},n),{r:(0,o.getTwoPointsDistance)(n,c)})),k()}return}const r=+i;if(!isNaN(r)&&r>0){let n=c.x,i=c.y;if("2 points"===e){const e=(0,o.getPointByLengthAndDirection)(c,r/2,a);n=e.x,i=e.y}t({x:n,y:i,r:"center diameter"===e||"2 points"===e?r/2:r}),k()}}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=y(e,{x:t,y:r},void 0,a);n&&l(n)}v()}}}}:void 0),k=()=>{u(void 0),d(void 0),l(void 0),E()};return{circle:s,startPosition:c,middlePosition:p,cursorPosition:b,setCursorPosition:x,setInputPosition:C,clearText:v,onClick(r){if(e)if(x(r),c)if("3 points"!==e||p){const o=y(e,c,p,(0,i.getAngleSnapPosition)(c,r,null==n?void 0:n.getAngleSnap));o&&t(o),k()}else d((0,i.getAngleSnapPosition)(c,r,null==n?void 0:n.getAngleSnap));else u(r)},onMove(t,r){if(C(null!=r?r:t),e&&(t=(0,i.getAngleSnapPosition)(c,t,null==n?void 0:n.getAngleSnap),x(t),c)){const n=y(e,c,p,t);n&&l(n)}},input:m,reset:k}}function y(e,t,n,r){if("2 points"===e){const e={x:(t.x+r.x)/2,y:(t.y+r.y)/2};return h(g({},e),{r:(0,o.getTwoPointsDistance)(e,t)})}return"center radius"===e||"center diameter"===e?h(g({},t),{r:(0,o.getTwoPointsDistance)(r,t)}):n?(0,o.getThreePointsCircle)(t,n,r):void 0}},7535:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useEllipseArcClickCreate:()=>m});var r=n(7378),o=n(9300),i=n(9254),a=n(7386),s=Object.defineProperty,l=Object.defineProperties,c=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)=>l(e,c(t));function m(e,t,n){const[s,l]=r.useState(),[c,u]=r.useState();let p;s&&(p=void 0===c?"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:x,middlePosition:v,cursorPosition:b,setCursorPosition:C,clearText:E,setInputPosition:k}=(0,o.useEllipseClickCreate)(e,(e=>l(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===c?(u(e),l(h(g({},s),{startAngle:e,endAngle:e})),E()):(e{l(void 0),u(void 0),C(void 0),E()};return{ellipse:d,ellipseArc:s,startPosition:x,middlePosition:v,cursorPosition:b,reset:w,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===c?(u(e),l(h(g({},s),{startAngle:e,endAngle:e}))):(e{"use strict";n.r(t),n.d(t,{useEllipseClickCreate:()=>s});var r=n(7378),o=n(9300),i=n(9254),a=n(7386);function s(e,t,n){const[s,c]=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:x,setInputPosition:v,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(l(e,u,d,{x:r,y:o})),C())}else{const n=+o;!isNaN(n)&&n>0&&(t(l(e,u,d,n)),C())}}}:void 0),C=()=>{p(void 0),f(void 0),c(void 0),b()};return{ellipse:s,startPosition:u,middlePosition:d,cursorPosition:x,setCursorPosition:m,setInputPosition:v,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(l(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(v(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&&c(l(e,u,d,o))},input:h}}function l(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))}}},1487:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useImageClickCreate:()=>h});var r=n(7378),o=n(9300),i=n(1948),a=Object.defineProperty,s=Object.defineProperties,l=Object.getOwnPropertyDescriptors,c=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(c)for(var n of c(t))p.call(t,n)&&d(e,n,t[n]);return e},g=(e,t)=>s(e,l(t));function h(e,t){const[n,a]=r.useState(),s=r.useRef(null);let l="";e&&(l=n?"specify image position":"click to select image");const{input:c,setInputPosition:u}=(0,o.useCursorInput)(l),p=()=>{a(void 0)};return r.useEffect((()=>{var t;e&&(null==(t=s.current)||t.click())}),[e]),{image:n,reset:p,onClick(r){var o;e&&(n?(u(r),t(n),p()):null==(o=s.current)||o.click())},onMove(e,t){u(t||e),n&&a(g(f({},n),{x:e.x,y:e.y}))},input:r.createElement(r.Fragment,null,r.createElement("input",{type:"file",ref:s,accept:"image/*",style:{display:"none"},onChange:e=>{var t;const n=null==(t=e.currentTarget.files)?void 0:t.item(0);if(n){const e=new FileReader;e.onloadend=()=>{const t=e.result;"string"==typeof t&&(0,i.getImageFromCache)(t,{callback(e){a({x:0,y:0,width:e.width,height:e.height,url:t})}})},e.readAsDataURL(n)}e.target.value=null}}),c)}}},5490:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useLineClickCreate:()=>s});var r=n(7378),o=n(9300),i=n(9254),a=n(7386);function s(e,t,n){const[s,u]=r.useState(),[p,d]=r.useState([]),[f,g]=r.useState([]),[h,m]=r.useState(0),[y,x]=r.useState(),[v,b]=r.useState(),C=l[h],E=(h+1)%l.length,k=void 0!==y?()=>y:null==n?void 0:n.getAngleSnap,w=void 0!==v?()=>v:null==n?void 0:n.getLengthSnap;let S="";s&&(S=1===s.length?"specify start point by click, input position":`specify next point by click, input position or input ${C}, press tab to input ${l[E]}`);const{input:P,setCursorPosition:R,clearText:_,setInputPosition:T,resetInput:A,cursorPosition:M}=(0,o.useCursorInput)(S,e?(e,r,o)=>{if("Enter"===e.key){if("angle"===C){const e=+r;if(!isNaN(e)&&(_(),s&&s.length>1)){const t=s[s.length-2],n=s[s.length-1];let r=(0,a.getAngleSnapPosition)(t,n,(()=>e));r=c(t,r,w),d([...p,r]),g([...f,void 0]),u([...p,r,{x:o.x,y:o.y}]),x(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 L();d([...p,{x:a,y:s}]),g([...f,void 0]),u([...p,{x:a,y:s},{x:o.x,y:o.y}]),_(),x(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 L();d([...p,r]),g([...f,void 0]),u([...p,r,{x:o.x,y:o.y}]),_(),x(void 0),b(void 0)}}}else if("Tab"===e.key){if(e.stopPropagation(),e.preventDefault(),r){const e=+r;isNaN(e)||("angle"===C?(x(e),b(void 0),_()):e>0&&(b(e),x(void 0),_()))}m(E)}}:void 0),L=e=>{e&&p.length>1&&t(p,f),d([]),u(void 0),A(),x(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:M,onClick(r,o){if(!e)return;let i=(0,a.getAngleSnapPosition)(p[p.length-1],r,k);if(i=c(p[p.length-1],i,w),R(i),x(void 0),b(void 0),(null==n?void 0:n.once)&&p.length>0)return t([p[0],i],f),void L();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,k);o=c(p[p.length-1],o,w),R(o),(null==n?void 0:n.once)&&0===p.length||u([...p,o])},input:P,reset:L,positions:p}}const l=["length","angle"];function c(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}},9328:(e,t,n)=>{"use strict";n.r(t),n.d(t,{usePathClickCreate:()=>i});var r=n(7378),o=n(9300);function i(e,t){const[n,i]=r.useState([]),[a,s]=r.useState(),[l,c]=r.useState("move"),[u,p]=r.useState(),[d,f]=r.useState(),[g,h]=r.useState();let m="";"move"===l?m="specify start point by click":"line"===l?m="specify end point by click":"quadraticCurve"===l?m=u?"specify end point by click":"specify control point by click":"bezierCurve"===l?m=u?d?"specify end point by click":"specify control point 2 by click":"specify control point 1 by click":"arc"===l&&(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:x,cursorPosition:v,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}),S(r),b())}else if(1===e.length&&"arc"===l){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),k=e=>{e&&n.length>1&&t(n),i([]),s(void 0),E(),c("move"),b(),p(void 0),f(void 0),h(void 0)},w=e=>{x(e),"move"===l?(i([...n,{type:"move",to:e}]),c("line")):"line"===l?(i([...n,{type:"line",to:e}]),s(void 0)):"quadraticCurve"===l?u?(i([...n,{type:"quadraticCurve",cp:u,to:e}]),s(void 0),p(void 0)):p(e):"bezierCurve"===l?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"===l&&(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))},S=e=>{"line"===l?s({type:"line",to:e}):"quadraticCurve"===l?s(u?{type:"quadraticCurve",cp:u,to:e}:void 0):"bezierCurve"===l?s(u&&d?{type:"bezierCurve",cp1:u,cp2:d,to:e}:void 0):"arc"===l&&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&&(x(t),S(t))},input:y,reset:k,setInputType(e){"close"===e?(t([...n,{type:"close"}]),k()):c(e)},cursorPosition:v}}},5069:(e,t,n)=>{"use strict";n.r(t),n.d(t,{usePenClickCreate:()=>a});var r=n(5188),o=n(7378),i=n(9254);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}}},8313:(e,t,n)=>{"use strict";n.r(t),n.d(t,{usePolygonClickCreate:()=>s});var r=n(7378),o=n(9300),i=n(9254),a=n(7386);function s(e,t,n){const[s,l]=r.useState(),[c,u]=r.useState(),[p,d]=r.useState("radius"),[f,g]=r.useState(6);let h="";e&&(h="sides"===p?"specify sides number by input":c?(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:x,cursorPosition:v,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 x();if((null==n?void 0:n.switchTypeKey)&&n.switchType&&r.toLowerCase()===n.switchTypeKey.toLowerCase())return n.switchType(),void x();const e=+r;if(!isNaN(e)&&e>0)if("radius"===p){if(c){const r=(0,i.getPointByLengthAndDirection)(c,e,o);t((0,i.getPolygonPoints)(r,c,f,null==n?void 0:n.toEdge)),E()}}else"sides"===p&&Number.isInteger(e)&&e>=3&&(g(e),d("radius"),x(),c&&l((0,i.getPolygonPoints)(o,c,e,null==n?void 0:n.toEdge)))}}:void 0),E=()=>{u(void 0),l(void 0),C()};return r.useEffect((()=>{c&&v&&l((0,i.getPolygonPoints)(v,c,f,null==n?void 0:n.toEdge))}),[null==n?void 0:n.toEdge]),{polygon:s,startPosition:c,cursorPosition:v,reset:E,onClick(r){if(e)if(y(r),c){const e=(0,a.getAngleSnapPosition)(c,r,null==n?void 0:n.getAngleSnap);t((0,i.getPolygonPoints)(e,c,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)(c,t,null==n?void 0:n.getAngleSnap);y(o),c&&l((0,i.getPolygonPoints)(o,c,f,null==n?void 0:n.toEdge))},input:m,startSetSides(){d("sides")}}}},9990:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useTextClickCreate:()=>g});var r=n(7378),o=n(9300),i=Object.defineProperty,a=Object.defineProperties,s=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,c=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={}))c.call(t,n)&&p(e,n,t[n]);if(l)for(var n of l(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:l,setCursorPosition:c,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&&(c(n),t(i),h())},onMove(e,t){p(t||e),c(e),i&&a(f(d({},i),{x:e.x,y:e.y}))},input:l,reset:h}}},2592:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useCursorInput:()=>u});var r=n(7378),o=Object.defineProperty,i=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable,l=(e,t,n)=>t in e?o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,c=(e,t)=>{for(var n in t||(t={}))a.call(t,n)&&l(e,n,t[n]);if(i)for(var n of i(t))s.call(t,n)&&l(e,n,t[n]);return e};function u(e,t,n){const[o,i]=r.useState(""),[a,s]=r.useState(),[l,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:l,setCursorPosition:s,setInputPosition:u,clearText(){i("")},input:l&&(e||t&&a)?r.createElement("span",{style:{position:"absolute",left:`${Math.min(l.x+10,window.innerWidth-54)}px`,top:`${Math.min(l.y-5,window.innerHeight-22)}px`}},e&&r.createElement("span",null,e),t&&a&&r.createElement("input",{ref:p,value:o,autoComplete:"false",style:c({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}}},2293:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useDelayedAction:()=>o});var r=n(7378);function o(e,t,n){const o=r.useRef();e&&(o.current&&clearTimeout(o.current),o.current=setTimeout((()=>{n()}),t))}},6239:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useDragMove:()=>s});var r=n(7378),o=n(7386),i=n(8150),a=n(3516);function s(e,t){var n;const[s,l]=r.useState({x:0,y:0}),[c,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=()=>{l({x:0,y:0}),u(void 0)};return{offset:s,resetDragMove:f,startPosition:c,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:c&&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)(c,u,null==t?void 0:t.getAngleSnap);const f=(u.x-c.x)/p,g=(u.y-c.y)/p,h=Math.sin(d),m=Math.cos(d),y={x:m*f-h*g,y:h*f+m*g};l(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()}})}}},4558:(e,t,n)=>{"use strict";n.r(t),n.d(t,{getResizeOffset:()=>x,useDragResize:()=>y});var r=n(7378),o=n(8626),i=n(7386),a=n(8150),s=n(3516),l=Object.defineProperty,c=Object.defineProperties,u=Object.getOwnPropertyDescriptors,p=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,f=Object.prototype.propertyIsEnumerable,g=(e,t,n)=>t in e?l(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)=>c(e,u(t));function y(e,t){var n,l;const[c,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,v]=r.useState(),b=()=>{u({x:0,y:0,width:0,height:0}),d(void 0)};return{offset:c,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,l;let c={x:e.clientX,y:e.clientY};c=null!=(r=null==(n=null==t?void 0:t.transform)?void 0:n.call(t,c))?r:c,c=(0,i.getAngleSnapPosition)(p,c,null==t?void 0:t.getAngleSnap),v(c);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=x(p,c,p.direction,f,d,h,g);m&&u(null!=(l=null==(s=null==t?void 0:t.transformOffset)?void 0:s.call(t,m,e,p.direction))?l:m)},onDragEnd:()=>{e(),b()},style:{cursor:(0,o.getResizeCursor)((null!=(n=null==t?void 0:t.rotate)?n:0)+(null!=(l=null==t?void 0:t.parentRotate)?l:0),p.direction)}})}}function x(e,t,n,r=0,o,i,a=0){const s=t.x-e.x,l=t.y-e.y,c=Math.sin(a),u=Math.cos(a),p=u*s-c*l,d=c*s+u*l;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,x=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*x;h=Math.min(t*i,e)*y,m=Math.min(e/i,t)*x}const v={x:0,y:0,width:0,height:0};return v.width=h*(o?2:1)*y,v.height=m*(o?2:1)*x,o?(v.x-=h*y,v.y-=m*x):(n.includes("left")&&(v.x+=(g+1)*h/2,v.y-=f*h/2),n.includes("right")&&(v.x+=(g-1)*h/2,v.y-=f*h/2),n.includes("top")&&(v.x+=f*m/2,v.y+=(g+1)*m/2),n.includes("bottom")&&(v.x+=f*m/2,v.y+=(g-1)*m/2)),v}},3876:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useDragRotate:()=>y});var r=n(7378),o=n(9195),i=n(7386),a=n(8150),s=n(3516),l=Object.defineProperty,c=Object.defineProperties,u=Object.getOwnPropertyDescriptors,p=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,f=Object.prototype.propertyIsEnumerable,g=(e,t,n)=>t in e?l(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)=>c(e,u(t));function y(e,t){var n;const[l,c]=r.useState(),[u,p]=r.useState(),d=null!=(n=null==t?void 0:t.parentRotate)?n:0,f=()=>{c(void 0),p(void 0)};return{offset:l,center:u,onStart:p,resetDragRotate:f,mask:u&&r.createElement(a.DragMask,{ignoreLeavingEvent:null==t?void 0:t.ignoreLeavingEvent,onDragging:e=>{var n,r,a,l;const p={x:e.clientX,y:e.clientY};let f=null!=(r=null==(n=null==t?void 0:t.transform)?void 0:n.call(t,p))?r:p;f=(0,i.getAngleSnapPosition)(u,f,null==t?void 0:t.getAngleSnap);const g=((0,s.radianToAngle)((0,o.getTwoPointsRadian)(f,u))+450-d)%360;c(m(h({},f),{angle:null!=(l=null==(a=null==t?void 0:t.transformOffset)?void 0:a.call(t,g,e))?l:g}))},onDragEnd:()=>{null==e||e(),f()}})}}},8574:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useDragSelect:()=>i});var r=n(7378),o=n(8150);function i(e,t){const[n,i]=r.useState(),[a,s]=r.useState(),l=()=>{i(void 0),s(void 0)},c=t=>{n&&e(n,a,t),l()};return{dragSelectStartPosition:n,onStartSelect(e,t){i({x:e.clientX,y:e.clientY,data:t})},endDragSelect:c,resetDragSelect:l,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:c,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"}}))}}},1252:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useEdit:()=>y});var r=n(5188),o=n(7378),i=n(9254),a=n(7386),s=n(1273),l=Object.defineProperty,c=Object.defineProperties,u=Object.getOwnPropertyDescriptors,p=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,f=Object.prototype.propertyIsEnumerable,g=(e,t,n)=>t in e?l(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)=>c(e,u(t));function y(e,t,n){var l,c,u;const[p,d]=o.useState(),[f,g]=o.useState(),[y,x]=o.useState(),[v,b]=o.useState(),C=5/(null!=(l=null==n?void 0:n.scale)?l:1),E=null!=(c=null==n?void 0:n.readOnly)&&c,k=()=>{d(void 0),g(void 0),x(void 0),b(void 0)};return o.useEffect((()=>{!1===E&&k()}),[E]),{editPoint:p,editLastPosition:null!=(u=null==p?void 0:p.angleSnapStartPoint)?u:f,getEditAssistentContents(e,n){const r=[];if(!E){const o=null==t?void 0:t(e);o&&r.push(...o.editPoints.map((e=>n({x:e.x,y:e.y,width:C,height:C}))))}return r},updateEditPreview(){if(p&&f&&y&&p.update){const e=[],[t,o,i]=(0,r.produceWithPatches)(p.content,(t=>{var r,o;const i=null==(o=p.update)?void 0:o.call(p,t,{cursor:y,start:f,scale:null!=(r=null==n?void 0:n.scale)?r:1,target:v});(null==i?void 0:i.assistentContents)&&e.push(...i.assistentContents)})),a={content:p.content,result:t,patches:(0,s.prependPatchPath)(o,p.path),reversePatches:(0,s.prependPatchPath)(i,p.path),assistentContents:e,relatedEditPointResults:new Map};for(const t of p.relatedEditPoints){const[o,i,l]=(0,r.produceWithPatches)(t.content,(r=>{var o,i;const a=null==(i=t.update)?void 0:i.call(t,r,{cursor:y,start:f,scale:null!=(o=null==n?void 0:n.scale)?o:1});(null==a?void 0:a.assistentContents)&&e.push(...a.assistentContents)}));a.patches.push(...(0,s.prependPatchPath)(i,t.path)),a.reversePatches.push(...(0,s.prependPatchPath)(l,t.path)),a.relatedEditPointResults.set(t.content,o)}return a}},onEditMove(e,r,o){if(E)return;if((null==p?void 0:p.angleSnapStartPoint)?e=(0,a.getAngleSnapPosition)(p.angleSnapStartPoint,e,null==n?void 0:n.getAngleSnap):f&&(e=(0,a.getAngleSnapPosition)(f,e,null==n?void 0:n.getAngleSnap)),f)return x(e),void b(o);let s;for(const{content:n,path:o}of r){const r=null==t?void 0:t(n);if(r){const t=r.editPoints.find((t=>(0,i.getTwoNumbersDistance)(t.x,e.x)<=C&&(0,i.getTwoNumbersDistance)(t.y,e.y)<=C));t&&(s?s.relatedEditPoints.push(m(h({},t),{content:n,path:o})):s=m(h({},t),{content:n,path:o,angleSnapStartPoint:r.angleSnapStartPoint,relatedEditPoints:[]}))}}d(s)},onEditClick(t){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 f?(e([],[]),k()):g(t)},resetEdit:k}}},447:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useCircleArcEdit:()=>s});var r=n(7378),o=n(9254),i=n(7386),a=n(5736);function s(e,t){const[n,s]=r.useState({x:0,y:0,r:0,startAngle:0,endAngle:0}),[l,c]=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),c(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:l,reset(){s({x:0,y:0,r:0,startAngle:0,endAngle:0}),d()}}}},2877:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useCircleEdit:()=>s});var r=n(7378),o=n(9254),i=n(7386),a=n(5736);function s(e,t){const[n,s]=r.useState({x:0,y:0,r:0}),[l,c]=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),c(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:l,offset:n,onStart:u,mask:p,reset(){s({x:0,y:0,r:0}),d()}}}},5736:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useDragEdit:()=>g});var r=n(7378),o=n(9300),i=Object.defineProperty,a=Object.defineProperties,s=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,c=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={}))c.call(t,n)&&p(e,n,t[n]);if(l)for(var n of l(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}})}}},2722:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useEllipseArcEdit:()=>s});var r=n(7378),o=n(9254),i=n(7386),a=n(5736);function s(e,t){const[n,s]=r.useState({cx:0,cy:0,rx:0,ry:0,startAngle:0,endAngle:0}),[l,c]=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),c(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:l,reset(){s({cx:0,cy:0,rx:0,ry:0,startAngle:0,endAngle:0}),d()}}}},9988:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useEllipseEdit:()=>s});var r=n(7378),o=n(9254),i=n(7386),a=n(5736);function s(e,t){const[n,s]=r.useState({cx:0,cy:0,rx:0,ry:0}),[l,c]=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),c(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:l,reset(){s({cx:0,cy:0,rx:0,ry:0}),d()}}}},4554:(e,t,n)=>{"use strict";n.r(t),n.d(t,{usePolylineEdit:()=>a});var r=n(7378),o=n(7386),i=n(5736);function a(e,t){const[n,a]=r.useState(),[s,l]=r.useState(),{onStart:c,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),l(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){c(e,{pointIndexes:t,data:n,cursor:"move"})},mask:u,cursorPosition:s,dragStartPosition:p,reset(){a(void 0),d()}}}},1301:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useEvent:()=>o});var r=n(7378);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)}),[])}},4507:(e,t,n)=>{"use strict";n.r(t),n.d(t,{compareLocations:()=>C,useFlowLayoutBlockEditor:()=>b,useFlowLayoutBlockOperation:()=>E});var r=n(5188),o=n(7378),i=n(9300),a=n(9254),s=n(1799),l=n(2997),c=n(2357),u=n(8533),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,x=(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},v=(e,t)=>d(e,f(t));function b(e){var t,n,r,i,c;const{range:u,inputContent:p,inputInline:d,getCopiedContents:f,skipVoidBlock:g,scrollRef:h,scrollY:m,dragLocation:y,setY:v,selectionStart:b,setSelectionStart:k,ref:w,setLocation:S,location:P,contentHeight:R,setContentHeight:_,blockLocation:T,contentLocation:A,actualHeight:M,isSelected:L,onBlur:O,onMouseUp:I,onMouseDown:F,onMouseMove:D,onKeyDown:B}=E(e),[z,U]=o.useState(!1),N=(e=!1)=>{if(!e&&u)return k(void 0),void S(u.min);e&&void 0===b&&k(P),S(ue{if(!t&&u)return k(void 0),void S(u.max);t&&void 0===b&&k(P),pe>=Z.length-1?S([e.state.length-1,e.state[e.state.length-1].children.length]):S(V({x:ce,y:ue+Z[pe]+Z[pe+1]/2+m},!1))},W=e=>{B(e,N,j)},G=e=>{const t=e.target.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}},V=(t,n=!0,r)=>{for(let o=0;o0&&X[o][0].y>t.y)return g([o,0],r);const i=(0,a.getFlowLayoutLocation)(t,Z,X[o],m,(t=>e.getWidth(t,e.state[o])),n,e.getHeight);if(void 0!==i)return U(i.lineEnd),g([o,i.location],r)}return[e.state.length-1,e.state[e.state.length-1].children.length]},$=t=>{if(u)for(let n=0;n=0&&C(r,u.max)<0&&t.x>i.x&&t.y>i.y&&t.x{F(e,G,V,$)},q=e=>{D(e,G,(e=>V(e,!1)),0,ne,re)},Y=e=>{q(e),I()},X=[];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 l=t.listStyleType&&(null==(r=e.isSameType)?void 0:r.call(e,t,e.state[n-1]))?0:null!=(o=t.blockStart)?o:0,c=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(l,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});X.push(p.layoutResult),t.void||(K+=p.newContentHeight),K+=u,Z.push(...p.lineHeights),Q+=p.lineHeights.length,J=c})),K+=J,e.height&&("middle"===e.verticalAlign||"bottom"===e.verticalAlign)){let t=e.height-K;t>0&&("middle"===e.verticalAlign&&(t/=2),X.forEach((e=>{e.forEach((e=>{e.y+=t}))})))}R0&&(null==ae?void 0:ae[oe-1]);se&&oe--;const le=null==ae?void 0:ae[oe],ce=(null!=(r=null==le?void 0:le.x)?r:0)+(se?e.getWidth(null==ae?void 0:ae[oe].content,e.state[ie]):0),ue=(null!=(i=null==le?void 0:le.y)?i:0)-m,pe=null!=(c=null==le?void 0:le.row)?c: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],P[0])&&(0,a.equals)(null==(n=de.current)?void 0:n[1],P[1])&&(0,a.equals)(fe.current,ue)||e.autoHeight)return;const r=ue+m;r<0?v(-ue):r>e.height-re&&v(e.height-re-ue),de.current=P,fe.current=ue}),[P,ue,m,re]),{ref:w,range:u,layoutResult:X,lineHeights:Z,cursor:{x:ce,y:ue+m,row:pe},inputContent:p,inputInline:d,location:P,setLocation:S,getCopiedContents:f,isSelected:L,actualHeight:M,setSelectionStart:k,getPosition:G,positionToLocation:V,scrollY:m,renderEditor:t=>o.createElement("div",{style:x({position:"relative",width:e.width+"px",height:M+"px",border:"1px solid black",clipPath:"inset(0px 0px)"},e.style),onMouseLeave:Y,ref:h},o.createElement(s.Cursor,{ref:w,onKeyDown:W,onCompositionEnd:e.onCompositionEnd,onBlur:O,onFocus:e.onFocus,readOnly:e.readOnly,style:{left:ce+"px",top:ue+m+"px",height:Z[pe]+"px"}}),t,o.createElement("div",{onMouseDown:H,onMouseMove:q,onMouseUp:Y,onDoubleClick:e.onDoubleClick,style:{inset:"0px",cursor:"text",position:"absolute"}}),!e.autoHeight&&o.createElement(l.Scrollbar,{value:m,type:"vertical",containerSize:e.height,contentSize:R,onChange:v,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,[l,p]=o.useState(),d=o.useRef(null),[f,g]=o.useState(0),h=void 0!==l?C(l,t)>0?{min:t,max:l}:{min:l,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)(v(x({},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)(v(x({},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,l=a>o?[...n,...e.state[a].children.slice(s)]:n,c=(o===a?s:e.state[o].children.length)-i;t[o].children.splice(i,c,...(0,r.castDraft)(l)),a>o&&t.splice(o+1,a-o)},k=(e,t,n)=>{e[n[0]].children.splice(n[1],0,...(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)})))))},S=t=>{const[n,r]=t.min,[o,i]=t.max,a=n===o?i:e.state[n].children.length,s=[v(x({},e.state[n]),{children:e.state[n].children.slice(r,a)})];for(let t=n+1;tn&&s.push(v(x({},e.state[o]),{children:e.state[o].children.slice(0,i)})),s},P=([t,n],r)=>{for(;e.state[t].void;)r?(t--,n=e.state[t].children.length):(t++,n=0);return[t,n]},R=o.useRef(),[_,T]=o.useState();(0,i.useGlobalMouseUp)((0,i.useEvent)((()=>{R.current=void 0,T(void 0)})));const{ref:A,y:M,setY:L,filterY:O}=(0,u.useWheelScroll)({minY:e.autoHeight?0:f>e.height?e.height-f:0,maxY:0,disabled:e.autoHeight});o.useEffect((()=>{e.autoHeight&&L(0)}),[e.autoHeight,L]);let I=e.height;return e.autoHeight&&f>e.height&&(I=f),o.useEffect((()=>{var n;null==(n=e.onLocationChanged)||n.call(e,t)}),[t]),{range:h,inputContent:m,inputInline:r=>{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]),e.setState((e=>{k(e,r,t)}))}},getCopiedContents:(e=!1)=>{if(void 0!==h)return e&&w(),S(h)},skipVoidBlock:P,scrollRef:A,scrollY:M,dragLocation:_,setY:L,selectionStart:l,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:I,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!==_&&h){if(C(_,h.min)<0){const t=S(h);if(1===t.length){const r=t[0].children;e.setState((e=>{E(e,[]),k(e,r,_)})),n([_[0],_[1]+r.length]),p(_)}else e.setState((e=>{E(e,[]),b(e,t,_)})),n([_[0]+t.length+1,0]),p([_[0]+1,0])}else if(C(_,h.max)>0){const t=S(h);if(1===t.length){const r=t[0].children;e.setState((e=>{k(e,r,_),E(e,[])})),p([_[0],_[1]-r.length]),n(_)}else e.setState((e=>{b(e,t,_),E(e,[])})),n([_[0]+2,0]),p([_[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===l&&p(t),n(s);else{if(i(a))return void T(s);R.current=s}},onMouseMove:(t,r,o,i,a,s)=>{if(void 0===R.current)return void(void 0!==_&&T(o(r(t))));const l=r(t),c=o(l);if(n(c),c[0]===R.current[0]&&c[1]===R.current[1]?p(void 0):p(R.current),!e.autoHeight){const t=l.y+i;t>=0&&t<=a?L((e=>O(e+2))):t<=e.height&&t>=e.height-s&&L((e=>O(e-2)))}},onKeyDown:(r,o,i,u)=>{var d;if(!r.nativeEvent.isComposing&&229!==r.keyCode&&!(null==(d=e.processInput)?void 0:d.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===l&&p(t),n(0!==s?[a,s-1]:P([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===l&&p(t),s!==e.state[a].children.length?n([a,s+1]):n(P([a+1,0])))})(r.shiftKey);if("ArrowUp"===r.key)return o(r.shiftKey);if("ArrowDown"===r.key)return i(r.shiftKey);if((0,c.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()}}}}}},1497:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useFlowLayoutEditor:()=>x});var r=n(7378),o=n(7310),i=n(9195),a=n(1799),s=n(2997),l=n(1301),c=n(1502),u=n(2357),p=n(8533),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 x(e){var t;const[n,d]=r.useState(0),[f,g]=r.useState(),h=r.useRef(null),[m,x]=r.useState(0),[v,b]=r.useState(!1),C=()=>{if(!e.readOnly)return j?(d(j.min),g(void 0),void e.setState((e=>{e.splice(j.min,j.size)}))):void(0!==n&&(d(n-1),e.setState((e=>{e.splice(n-1,1)}))))},E=t=>{var r;if(!t.nativeEvent.isComposing&&229!==t.keyCode&&!(null==(r=e.processInput)?void 0:r.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 j?(d(j.min),g(void 0),void e.setState((e=>{e.splice(j.min,j.size)}))):void(n!==e.state.length&&e.setState((e=>{e.splice(n,1)})))})();if("ArrowLeft"===t.key)return((e=!1)=>{if(!e&&j)return g(void 0),void d(j.min);0!==n&&(e&&void 0===f&&g(n),d(n-1))})(t.shiftKey);if("ArrowRight"===t.key)return((t=!1)=>{if(!t&&j)return g(void 0),void d(j.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&&j)return g(void 0),void d(j.min);e&&void 0===f&&g(n),d(H{if(!t&&j)return g(void 0),void d(j.max);t&&void 0===f&&g(n),q>=z.length-1?d(e.state.length):d(_({x:$,y:H+z[q]+z[q+1]/2+O},!1))})(t.shiftKey);if((0,u.metaKeyIfMacElseCtrlKey)(t)){if("a"===t.key)return g(0),void d(e.state.length)}else t.preventDefault()}},k=()=>{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(),[S,P]=r.useState(),R=e=>{const t=e.target.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}},_=(t,n=!0)=>{const r=(0,o.getFlowLayoutLocation)(t,z,D,O,e.getWidth,n);return r?(b(r.lineEnd),r.location):D.length-1},T=t=>{t.preventDefault();const r=R(t),o=_(r);if(t.shiftKey)(void 0===f||Math.abs(f-o){if(j)for(let n=j.min;nr.x&&t.y>r.y&&t.x{if(void 0===w.current)return void(void 0!==S&&P(_(R(t),!1)));const n=R(t),r=_(n,!1);d(r),r===w.current?g(void 0):g(w.current),e.autoHeight||(n.y>=0&&n.y<=U?I((e=>F(e+2))):n.y<=e.height&&n.y>=e.height-N&&I((e=>F(e-2))))},M=t=>{var n;A(t),void 0!==S&&j&&(S{e.splice(S,0,...e.splice(j.min,j.size))})),d(S+j.size),g(S)):S>j.max&&(e.setState((e=>{e.splice(S-j.size,0,...e.splice(j.min,j.size))})),d(S),g(S-j.size)),P(void 0)),null==(n=h.current)||n.focus()};(0,c.useGlobalMouseUp)((0,l.useEvent)((()=>{w.current=void 0,P(void 0)})));const{ref:L,y:O,setY:I,filterY:F}=(0,p.useWheelScroll)({minY:e.autoHeight?0:m>e.height?e.height-m:0,maxY:0,disabled:e.autoHeight});r.useEffect((()=>{e.autoHeight&&I(0)}),[e.autoHeight,I]);const{layoutResult:D,newContentHeight:B,lineHeights:z}=(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:O,align:e.align,verticalAlign:e.verticalAlign});m0&&D[W-1];G&&W--;const V=null!=(t=D[W])?t:D[D.length-1],$=V.x+(G?e.getWidth(D[W].content):0),H=V.y-O,q=V.row,Y=r.useRef(),X=r.useRef();r.useEffect((()=>{if((0,i.equals)(Y.current,n)&&(0,i.equals)(X.current,H)||e.autoHeight)return;const t=H+O;t<0?I(-H):t>e.height-N&&I(e.height-N-H),Y.current=n,X.current=H}),[n,H,O,N]),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:j,layoutResult:D,lineHeights:z,cursor:{x:$,y:H+O,row:q},inputContent:(t,r=t.length)=>{if(!e.readOnly){if(j)return d(j.min+r),g(void 0),void e.setState((e=>{e.splice(j.min,j.size,...t)}));d(n+r),e.setState((e=>{e.splice(n,0,...t)}))}},location:n,setLocation:d,getCopiedContents:(t=!1)=>{if(void 0!==j)return t&&C(),e.state.slice(j.min,j.max)},isSelected:e=>j&&e>=j.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:M,ref:L},r.createElement(a.Cursor,{ref:h,onKeyDown:E,onCompositionEnd:e.onCompositionEnd,onBlur:k,onFocus:e.onFocus,readOnly:e.readOnly,autoFocus:e.autoFocus,style:{left:$+"px",top:H+O+"px",height:z[q]+"px"}}),t,r.createElement("div",{onMouseDown:T,onMouseMove:A,onMouseUp:M,onDoubleClick:e.onDoubleClick,style:{inset:"0px",cursor:"text",position:"absolute"}}),!e.autoHeight&&r.createElement(s.Scrollbar,{value:O,type:"vertical",containerSize:e.height,contentSize:m,onChange:I,align:"head"}))}}},8137:(e,t,n)=>{"use strict";n.r(t),n.d(t,{getTextComposition:()=>l,getWordByDoubleClick:()=>s,isLetter:()=>u,isNumber:()=>p,isWordCharactor:()=>c,useFlowLayoutTextEditor:()=>a});var r=n(6564),o=n(1497),i=n(2357);function a(e){const t=`${e.fontSize}px ${e.fontFamily}`,n=e=>{var n,o;return null!=(o=null==(n=(0,r.getTextSizeFromCache)(t,e))?void 0:n.width)?o:0},{inputContent:a,getCopiedContents:u,ref:p,layoutResult:d,cursor:f,location:g,setLocation:h,isSelected:m,renderEditor:y,actualHeight:x,setSelectionStart:v,positionToLocation:b,getPosition:C}=(0,o.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 E("\n"),!0;if((0,i.metaKeyIfMacElseCtrlKey)(t)){if("v"===t.key)return k(),t.preventDefault(),!0;if("c"===t.key||"x"===t.key){const e=u("x"===t.key);return e&&navigator.clipboard.writeText(e.join("")),!0}}else if(1===t.key.length)return t.preventDefault(),E(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=>c(e),getComposition:t=>l(t,e.state,n,(e=>e)),endContent:"",align:e.align,verticalAlign:e.verticalAlign,onCompositionEnd(e){E(e.data),p.current&&(p.current.value="")},onDoubleClick(t){const n=b(C(t)),{newSelectionStart:r,newLocation:o}=s(e.state,n,(e=>e));void 0!==r&&v(r),void 0!==o&&h(o)}}),E=(t,n=t.length)=>{if(e.readOnly)return;const r=[];for(const e of t)r.push(e);a(r,n)},k=()=>{e.readOnly||navigator.clipboard.readText().then((e=>{e&&E(e)}))};return{layoutResult:d,cursor:f,inputText:E,location:g,setLocation:h,renderEditor:t=>{var r,o,i;const a=[];for(const{x:s,y:l,i:c,content:u,visible:p}of d){if(!p)continue;const d=null!=(o=null==(r=t.getTextColors)?void 0:r.call(t,c))?o:{};m(c)&&(d.backgroundColor=11785981);const f=n(u);void 0!==d.backgroundColor&&a.push(t.target.renderRect(s,l,f,e.lineHeight,{fillColor:d.backgroundColor,strokeWidth:0})),a.push(t.target.renderText(s+f/2,l+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,x);return y(s)}}}function s(e,t,n){let r,o,i,a;for(let o=t-1;o>=0;o--){const t=n(e[o]);if(!t||!c(t))break;r=o}for(let r=t;r="a"&&e<="z"||e>="A"&&e<="Z"}function p(e){return e>="0"&&e<="9"}},5436:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useGlobalKeyDown:()=>o});var r=n(7378);function o(e){r.useEffect((()=>(window.addEventListener("keydown",e,{passive:!1}),()=>{window.removeEventListener("keydown",e)})),[e])}},1502:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useGlobalMouseUp:()=>o});var r=n(7378);function o(e){r.useEffect((()=>(window.addEventListener("mouseup",e,{passive:!1}),()=>{window.removeEventListener("mouseup",e)})),[e])}},6739:(e,t,n)=>{"use strict";n.r(t),n.d(t,{defaultFontFamily:()=>P,defaultFontSize:()=>S,isHtmlText:()=>R,renderHtmlTextStyle:()=>_,useHtmlEditor:()=>C});var r=n(5188),o=n(7378),i=n(7803),a=n(9300),s=n(9254),l=n(1799),c=n(2997),u=n(2357),p=n(4507),d=Object.defineProperty,f=Object.defineProperties,g=Object.getOwnPropertyDescriptors,h=Object.getOwnPropertySymbols,m=Object.prototype.hasOwnProperty,y=Object.prototype.propertyIsEnumerable,x=(e,t,n)=>t in e?d(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,v=(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},b=(e,t)=>f(e,g(t));function C(e){var t,n,d,f,g,h,m,y,x,C,w,_,T,A,L,O,I,F,D;const B=o.useRef(null),[z,U]=o.useState(),N=o.useRef(),[j,W]=o.useState(!1),[G,V]=o.useState(),{range:$,inputContent:H,inputInline:q,getCopiedContents:Y,scrollRef:X,scrollY:K,dragLocation:Z,setY:Q,selectionStart:J,setSelectionStart:ee,ref:te,setLocation:ne,location:re,contentHeight:oe,setContentHeight:ie,blockLocation:ae,contentLocation:se,actualHeight:le,isSelected:ce,onBlur:ue,onMouseUp:pe,onMouseDown:de,onMouseMove:fe,onKeyDown:ge}=(0,p.useFlowLayoutBlockOperation)(e),he=e=>{var t;const n=$?$.min[0]:re[0],r=e[n],o=r?re[1]<=0?0:re[1]-1:void 0;return{currentBlock:r,currentContent:void 0!==o?r.children[o]:void 0,currentContentLayout:void 0!==n&&void 0!==o&&N.current?null==(t=N.current.cells[n])?void 0:t[o]:void 0}},{currentBlock:me,currentContent:ye,currentContentLayout:xe}=he(e.state);let ve;ve=ye&&G&&!$&&0===(0,a.compareLocations)(G.index,re)&&R(ye)?v(v({},ye),G.style):ye;const be=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}},Ce=t=>{if(e.readOnly)return;const n=[];for(const e of t)if("string"==typeof e){const t=b(v({},ye),{text:e,kind:void 0});G?n.push(v(v({},t),G.style)):n.push(t)}else n.push(v(v({},ye),e));q(n)},Ee=(e=!1)=>{var t;if(!e&&$)return ee(void 0),void ne($.min);if(e&&void 0===J&&ee(re),De=0;e--){const t=N.current.rows[e];if(t.y+t.height/2{var t,n;if(!e&&$)return ee(void 0),void ne($.max);e&&void 0===J&&ee(re);const r=null==(t=N.current)?void 0:t.rows.find((e=>e.y>De+Be/2)),o=r?r.y+r.height/2:De+1.5*Be;ne(Pe({x:Fe-(null!=(n=null==z?void 0:z.width)?n:0)/2,y:o+K}))},we=t=>{ge(t,Ee,ke,(()=>{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?q(t[0].children):H(t)}catch(t){q(e.split("").map((e=>({text:e,kind:void 0}))))}})),void t.preventDefault();if("c"===t.key||"x"===t.key){const e=Y("x"===t.key);if(e){const t=(0,i.renderToStaticMarkup)(o.createElement(o.Fragment,null,E(e,(()=>!1),be)));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&&Ce(t.key)}))},Se=e=>{var t,n,r;const o=null==(t=B.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)}},Pe=t=>{if(W(!1),N.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 R(e.state[r].children[i])&&t.x{if($&&N.current)for(let t=0;t=0&&(0,a.compareLocations)(i,$.max)<0&&e.x>o.x&&e.y>o.y&&e.x{de(e,Se,Pe,Re)},Te=e=>{fe(e,Se,Pe,K,Le,Oe)},Ae=e=>{Te(e),pe()};o.useLayoutEffect((()=>{B.current&&(N.current=k(B.current.children))}),[e.state,B.current]),o.useEffect((()=>{var e,t;if(!N.current)return;const n=N.current.cells[null!=(e=null==Z?void 0:Z[0])?e:ae];let r;if(n){const e=null!=(t=null==Z?void 0:Z[1])?t:se;if(0===e)r=n[0];else if(j){const t=n[e-1];t&&(r=b(v({},t),{x:t.x+t.width}))}else r=n[e]}U(r)}),[N.current,ae,se,Z,j]);const Me=null==(t=B.current)?void 0:t.offsetHeight;Me&&oe{var t,n;(0,s.equals)(null==(t=ze.current)?void 0:t[0],re[0])&&(0,s.equals)(null==(n=ze.current)?void 0:n[1],re[1])&&(0,s.equals)(Ue.current,De)||e.autoHeight||(De+K<0&&Q(-De),ze.current=re,Ue.current=De)}),[re,De,K]);const Ne=E(e.state,ce,be);return o.useEffect((()=>{G&&0!==(0,a.compareLocations)(re,G.index)&&V(void 0)}),[re,G,V]),{currentContent:ve,currentBlock:me,currentContentLayout:xe,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,l=r.fontSize?r.fontSize*(null!=(n=i.fontSize)?n:S):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 H([b(v({},r),{type:t,children:[]})]);const o=e=>{var n,o,i;e.type=t;const a=S*(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,M(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=re[0];o(e[t])}))},updateCurrentContent:t=>{e.setState((e=>{const n=he(e);n.currentContent&&t(n.currentContent)}))},inputText:Ce,layoutResult:N.current,cursor:{x:Fe,y:De+K,height:Be},inputContent:H,location:re,scrollY:K,renderEditor:t=>o.createElement("div",{style:v({position:"relative",width:e.width+"px",height:le+"px",border:"1px solid black",clipPath:"inset(0px 0px)"},e.style),onMouseLeave:Ae,ref:X},o.createElement(l.Cursor,{ref:te,onKeyDown:we,onCompositionEnd:e=>{Ce(e.data),te.current&&(te.current.value="")},onBlur:ue,onFocus:e.onFocus,readOnly:e.readOnly,style:z?{left:z.x+"px",top:z.y+K+"px",height:z.height+"px"}:void 0}),o.createElement("div",{style:{width:e.width+"px",position:"absolute",fontFamily:P,fontSize:S+"px",top:`${K}px`,whiteSpace:"pre-wrap",overflowWrap:"break-word"},onMouseDown:_e,onMouseMove:Te,onMouseUp:Ae,onDoubleClick:t=>{const[n,r]=Pe(Se(t)),{newSelectionStart:o,newLocation:i}=(0,a.getWordByDoubleClick)(e.state[n].children,r,(e=>R(e)?e.text:void 0));void 0!==o&&ee([n,o]),void 0!==i&&ne([n,i])},ref:B},Ne),t,!e.autoHeight&&o.createElement(c.Scrollbar,{value:K,type:"vertical",containerSize:e.height,contentSize:oe,onChange:Q,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:l},c))):i.push({index:a,block:s})}return r}function k(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=_(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(R(e)){const r=_(e);return o.createElement(null!=(i=e.type)?i:"span",{key:t,style:b(v({},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 M(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}},1950:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useInterval:()=>o});var r=n(7378);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])}},4411:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useLastValidValue:()=>o});var r=n(7378);function o(e,t,n=e){const o=r.useRef(n);return t(e)&&(o.current=e),o.current}},1151:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useLineAlignment:()=>o});var r=n(7378);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(7378);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]}},4984:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useMinimap:()=>a});var r=n(7378),o=n.n(r),i=n(9195);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),l=Math.max(0,(e.width-s*r)/2),c=Math.max(0,(e.height-s*a)/2);return{setMinimapTransform:n,xOffset:l,yOffset:c,ratio:s,contentWidth:r,contentHeight:a,getMinimapPosition(n){let r={x:t.bounding.start.x+(n.nativeEvent.offsetX-l)/s,y:t.bounding.start.y+(n.nativeEvent.offsetY-c)/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:`${l+s*(e.viewport.center.x-e.viewport.width/2-t.bounding.start.x)}px`,top:`${c+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"}}))}}},1273:(e,t,n)=>{"use strict";n.r(t),n.d(t,{getByPath:()=>h,getItemByPath:()=>m,prependPatchPath:()=>g,usePartialEdit:()=>f});var r=n(7378),o=Object.defineProperty,i=Object.defineProperties,a=Object.getOwnPropertyDescriptors,s=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,c=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={}))l.call(t,n)&&u(e,n,t[n]);if(s)for(var n of s(t))c.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}},951:(e,t,n)=>{"use strict";n.r(t),n.d(t,{usePatchBasedUndoRedo:()=>a});var r=n(7378),o=n(5188),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:[]}),l=function(e,n,r){for(let r=e;r>=0;r--)if(n[r][2]===t)return r;return-1/0}(a.patchIndex,a.patches),c=function(e,n,r){for(let r=e;r=0,p=c{var i;const l=(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:l})))return a.state;const c=a.patchIndex+1;return s((0,o.produce)(a,(n=>{n.patches.splice(c,n.patches.length,[e,t,(0,o.castDraft)(r)]),n.patchIndex=c,n.state=(0,o.castDraft)(l)}))),l},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[l];const c=yield null==(t=null==n?void 0:n.onApplyPatchesFromSelf)?void 0:t.call(n,i,e);c&&(i=c[0],e=c[1],a.patches[l][0]=e,a.patches[l][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=l-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[c];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[l][0]=e,a.patches[l][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=c,e.state=(0,o.castDraft)(p)})))}})),stateIndex:a.patchIndex}}},8374:(e,t,n)=>{"use strict";n.r(t),n.d(t,{allSnapTypes:()=>m,usePointSnap:()=>h});var r=n(7378),o=n(9254),i=n(7386),a=Object.defineProperty,s=Object.defineProperties,l=Object.getOwnPropertyDescriptors,c=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(c)for(var n of c(t))p.call(t,n)&&d(e,n,t[n]);return e},g=(e,t)=>s(e,l(t));function h(e,t,n,a,s,l=5,c=(e=>({x:Math.round(e.x),y:Math.round(e.y)})),u=(e=>{const t=45*Math.round(e/45);if(t!==e&&Math.abs(t-e)<5)return t})){const[p,d]=r.useState();r.useEffect((()=>{!1===e&&d(void 0)}),[e]);const h=e=>s?{position:{x:e.x+s.x,y:e.y+s.y}}:{position:e},m=(e,t,n)=>{var r;const o=null==(r=null==e?void 0:e.getParam)?void 0:r.call(e,t,n);if(void 0!==o)return{target:{snapIndex:-1,content:t,param:o}}},y=(e,t)=>e?g(f({},t),{position:e(t.position)}):t,x=(e,t)=>{d(t&&e?f(f({},t),e(t)):t)};return{snapPoint:p,getSnapAssistentContents(e,t,n){const r=[],o=[];p&&(o.push(p),s&&o.push(g(f({},p),{x:p.x+s.x,y:p.y+s.y})));for(const i of o){const o=2*l;"center"===i.type?r.push(e({x:i.x,y:i.y,r:o})):"endpoint"===i.type?r.push(t({x:i.x,y:i.y,width:2*o,height:2*o})):"midpoint"===i.type?r.push(n([{x:i.x-o,y:i.y+o},{x:i.x+o,y:i.y+o},{x:i.x,y:i.y-o},{x:i.x-o,y:i.y+o}])):"intersection"===i.type?r.push(n([{x:i.x-o,y:i.y-o},{x:i.x+o,y:i.y+o}]),n([{x:i.x-o,y:i.y+o},{x:i.x+o,y:i.y-o}])):"nearest"===i.type?r.push(n([{x:i.x-o,y:i.y-o},{x:i.x+o,y:i.y+o},{x:i.x-o,y:i.y+o},{x:i.x+o,y:i.y-o},{x:i.x-o,y:i.y-o}])):"perpendicular"===i.type?(r.push(n([{x:i.x-1.5*o,y:i.y},{x:i.x+1.5*o,y:i.y}])),r.push(n([{x:i.x,y:i.y-1.5*o},{x:i.x,y:i.y}]))):"tangency"===i.type&&(r.push(e({x:i.x,y:i.y+.5*o,r:o})),r.push(n([{x:i.x-1.5*o,y:i.y-.5*o},{x:i.x+1.5*o,y:i.y-.5*o}])))}return r},getSnapPoint(r,s,p,d,v){var b,C;if(!e)return x(v,void 0),y(v,h(r));let E=s;p&&(E=p({start:{x:r.x-l,y:r.y-l},end:{x:r.x+l,y:r.y+l}}));for(const e of E){if(!e)continue;const t=null==(C=null==(b=a(e))?void 0:b.getSnapPoints)?void 0:C.call(b,e,s);if(t)for(let i=0;i{"use strict";n.r(t),n.d(t,{useRefState:()=>i,useRefState2:()=>a});var r=n(7378),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]}},2635:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useRegionAlignment:()=>o});var r=n(7378);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:l}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[l]/2-i)Math.abs(n[e]+n[l]-i){"use strict";n.r(t),n.d(t,{useSelectBeforeOperate:()=>i});var r=n(7378),o=n(1059);function i(e,t,n){const{selected:i,isSelected:a,addSelection:s,removeSelection:l,filterSelection:c,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 void g();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){l(e)},setSelected:u,filterSelection:c,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})}}}},1059:(e,t,n)=>{"use strict";n.r(t),n.d(t,{isSamePath:()=>a,isSelected:()=>i,useSelected:()=>o});var r=n(7378);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,l)=>{if((r=r.filter((e=>{var n;return!i(e,t)&&(null==(n=null==l?void 0:l(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(7378),o=n(5188);function i(e){const[t,n]=r.useState({states:[e],stateIndex:0}),{stateIndex:i,states:a}=t,s=i>0,l=i{const r=(0,o.produce)(c,e);if(r===c)return c;const a=i+1;return n((0,o.produce)(t,(e=>{e.states.splice(a,e.states.length,(0,o.castDraft)(r)),e.stateIndex=a}))),r},canUndo:s,canRedo:l,undo:e=>{null==e||e.preventDefault(),s&&n((0,o.produce)(t,(e=>{e.stateIndex=i-1})))},redo:e=>{null==e||e.preventDefault(),l&&n((0,o.produce)(t,(e=>{e.stateIndex=i+1})))},resetHistory:(t=e)=>{n({states:[t],stateIndex:0})}}}},1935:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useValueChanged:()=>o});var r=n(7378);function o(e,t){const n=r.useRef(e);n.current!==e&&(t(n.current)||(n.current=e))}},8533:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useWheelScroll:()=>i});var r=n(7378),o=n(5439);function i(e){var t,n,i,a,s,l;const c=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,x]=(0,o.useLocalStorageState)(null==e?void 0:e.localStorageYKey,null!=(l=null==(s=null==e?void 0:e.initialPosition)?void 0:s.y)?l:0),v=r.useRef(null),b=e=>(void 0!==p&&(e=Math.max(p,e)),void 0!==d&&(e=Math.min(d,e)),c>=0&&(e=Math.max(-c,Math.min(c,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(!v.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):x((e=>C(e-t.deltaY))))};return v.current.addEventListener("wheel",t,{passive:!1}),()=>{var e;null==(e=v.current)||e.removeEventListener("wheel",t)}}),[v.current,b,C,null==e?void 0:e.disabled]),{ref:v,x:h,y,setX:m,setY:x,filterX:b,filterY:C}}},6071:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useWheelZoom:()=>a});var r=n(7378),o=n(5439),i=n(8231);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:l,max:c}=(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(l,n*Math.exp(-t.deltaY/100)),c);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}}},7698:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useWindowSize:()=>o});var r=n(7378);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}},8231:(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,l=n=>{n!==e&&(n>a?n=a:ni,zoomIn:t=>{null==t||t.preventDefault(),l(e*s)},zoomOut:t=>{null==t||t.preventDefault(),l(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})},2115:(e,t,n)=>{"use strict";n.r(t),n.d(t,{createWebgl3DRenderer:()=>x,get3dPolygonTriangles:()=>v,getAxesGraphics:()=>C,getDashedLine:()=>b});var r=n(6645),o=n(1106),i=n.n(o),a=n(7504),s=n(5547),l=n(7459),c=Object.defineProperty,u=Object.defineProperties,p=Object.getOwnPropertyDescriptors,d=Object.getOwnPropertySymbols,f=Object.prototype.hasOwnProperty,g=Object.prototype.propertyIsEnumerable,h=(e,t,n)=>t in e?c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,m=(e,t)=>{for(var n in t||(t={}))f.call(t,n)&&h(e,n,t[n]);if(d)for(var n of d(t))g.call(t,n)&&h(e,n,t[n]);return e},y=(e,t)=>u(e,p(t));function x(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 }"]))),i=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 "]))),c=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]}),u=new s.WeakmapCache,p=r.createFramebufferInfo(t);let d=[];return{render:(s,{eye:l,up:p,fov:f,near:g,far:h,target:x},b,C)=>{r.resizeCanvasToDisplaySize(e),r.bindFramebufferInfo(t,null),t.viewport(0,0,t.canvas.width,t.canvas.height),t.enable(t.DEPTH_TEST),t.clearColor(...C),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT);const E=r.m4.perspective(f,e.clientWidth/e.clientHeight,g,h),k=r.m4.lookAt(l,x,p),w=r.m4.multiply(E,r.m4.inverse(k)),S={u_lightWorldPos:b.position,u_lightColor:b.color,u_specular:b.specular,u_shininess:b.shininess,u_specularFactor:b.specularFactor,u_diffuse:c,u_viewInverse:k,u_threshhold:.1},P=[];d=[],s.forEach(((e,s)=>{if(!e)return void d.push(void 0);let l,c=r.m4.identity();e.position&&(c=r.m4.translate(c,e.position)),l="lines"===e.geometry.type||"line strip"===e.geometry.type||"polygon"===e.geometry.type?o.instance:n.instance;const p={programInfo:l,bufferInfo:u.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):"cune"===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:v(e.geometry.points)}}):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:t.TRIANGLES,uniforms:y(m({},S),{u_diffuseMult:e.color,u_world:c,u_worldInverseTranspose:r.m4.transpose(r.m4.inverse(c)),u_worldViewProjection:r.m4.multiply(w,c),u_pickColor:(0,a.colorNumberToRec)(s)})};P.push(p),d.push({graphic:e,index:s,drawObject:y(m({},p),{programInfo:i.instance})})})),r.drawObjectList(t,P)},pick:(n,o,i=(()=>!0))=>{const s=e.getBoundingClientRect(),l=e.clientWidth,c=e.clientHeight,u=(n-s.left)*t.canvas.width/l|0,f=t.canvas.height-((o-s.top)*t.canvas.height/c|0)-1;r.resizeFramebufferInfo(t,p),r.bindFramebufferInfo(t,p),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,d.filter((e=>!!e&&i(e.graphic,e.index))).map((e=>e.drawObject)));const g=new Uint8Array(4);t.readPixels(u,f,1,1,t.RGBA,t.UNSIGNED_BYTE,g);const h=(0,a.pixelColorToColorNumber)(g);return 16777215===h?void 0:h}}}function v(e){const t=i()(e,void 0,3),n=[];for(let r=0;ri){s.push(l,t);break}const o=r.v3.add(e,r.v3.mulScalar(a,c));if(s.push(l,[o[0],o[1],o[2]]),c+=n,c>=i)break;const u=r.v3.add(e,r.v3.mulScalar(a,c));l=[u[0],u[1],u[2]]}return s}const C=(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]}]},8705:(e,t,n)=>{"use strict";n.r(t),n.d(t,{createWebgpu3DRenderer:()=>u});var r=n(6645),o=n(5547),i=n(2115),a=n(7459),s=n(7731),l=n(7504),c=(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 c(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 u=yield n.requestDevice(),f=navigator.gpu.getPreferredCanvasFormat();t.configure({device:u,format:f});const g={color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha"},alpha:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha"}},h=new a.Lazy((()=>u.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 }"}))),m=new a.Lazy((()=>u.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 }"}))),y=new a.Lazy((()=>u.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 }"}))),x=u.createSampler({magFilter:"nearest",minFilter:"nearest"}),v=new a.Lazy((()=>u.createTexture({size:[e.width,e.height],sampleCount:4,format:f,usage:GPUTextureUsage.RENDER_ATTACHMENT})),(e=>e.destroy())),b=new a.Lazy((()=>u.createTexture({size:[e.width,e.height],format:"depth24plus",sampleCount:4,usage:GPUTextureUsage.RENDER_ATTACHMENT})),(e=>e.destroy())),C=u.createTexture({size:[2,2],format:"rgba8unorm",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST});u.queue.writeTexture({texture:C},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 E=new a.Lazy((()=>u.createTexture({size:[e.width,e.height],format:f,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT})),(e=>e.destroy())),k=new o.MapCache,w=new o.MapCache,S=new o.WeakmapCache;let P=[];return{render:(n,{eye:o,up:a,fov:c,near:y,far:w,target:R},_,T)=>{e.width===v.instance.width&&e.height===v.instance.height||(v.reset(),b.reset(),E.reset());const A=u.createCommandEncoder(),M=A.beginRenderPass({colorAttachments:[{clearValue:T,loadOp:"clear",storeOp:"store",view:v.instance.createView(),resolveTarget:t.getCurrentTexture().createView()}],depthStencilAttachment:{view:b.instance.createView(),depthClearValue:1,depthLoadOp:"clear",depthStoreOp:"store"}}),L=r.m4.perspective(c,e.clientWidth/e.clientHeight,y,w),O=r.m4.lookAt(o,R,a),I=r.m4.multiply(L,r.m4.inverse(O));P=[],n.forEach(((e,t)=>{if(!e)return void P.push(void 0);let n=r.m4.identity();e.position&&(n=r.m4.translate(n,e.position));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||"polygon"===e.geometry.type?t=m.instance:(t=h.instance,n.push({arrayStride:12,attributes:[{shaderLocation:1,offset:0,format:"float32x3"}]},{arrayStride:8,attributes:[{shaderLocation:2,offset:0,format:"float32x2"}]})),u.createRenderPipeline({vertex:{module:t,entryPoint:"vertex_main",buffers:n},fragment:{module:t,entryPoint:"fragment_main",targets:[{format:f,blend:g}]},primitive:{cullMode:"back",topology:"lines"===e.geometry.type?"line-list":"line strip"===e.geometry.type?"line-strip":"triangle-list"},depthStencil:{depthWriteEnabled:!0,depthCompare:"less",format:"depth24plus"},multisample:{count:4},layout:"auto"})}));M.setPipeline(o);const a=[{binding:0,resource:{buffer:(0,s.createUniformsBuffer)(u,[{type:"mat4x4",value:r.m4.multiply(I,n)},{type:"vec3",value:_.position},{type:"mat4x4",value:n},{type:"mat4x4",value:O},{type:"mat4x4",value:r.m4.transpose(r.m4.inverse(n))},{type:"vec4",value:_.color},{type:"vec4",value:e.color},{type:"number",value:_.shininess},{type:"vec4",value:_.specular},{type:"number",value:_.specularFactor},{type:"vec4",value:(0,l.colorNumberToRec)(t)},{type:"number",value:.1}])}}];"lines"!==e.geometry.type&&"line strip"!==e.geometry.type&&"polygon"!==e.geometry.type&&a.push({binding:1,resource:x},{binding:2,resource:C.createView()}),M.setBindGroup(0,u.createBindGroup({layout:o.getBindGroupLayout(0),entries:a}));const{positionBuffer:c,primaryBuffers:y,count:v}=S.get(e.geometry,(()=>"sphere"===e.geometry.type?d(u,r.primitives.createSphereVertices(e.geometry.radius,72,36)):"cube"===e.geometry.type?d(u,r.primitives.createCubeVertices(e.geometry.size)):"cylinder"===e.geometry.type?d(u,r.primitives.createCylinderVertices(e.geometry.radius,e.geometry.height,36,4)):"cune"===e.geometry.type?d(u,r.primitives.createTruncatedConeVertices(e.geometry.bottomRadius,e.geometry.topRadius,e.geometry.height,36,4)):"polygon"===e.geometry.type?{positionBuffer:p(u,new Float32Array((0,i.get3dPolygonTriangles)(e.geometry.points))),count:e.geometry.points.length/3}:{positionBuffer:p(u,new Float32Array(e.geometry.points)),count:e.geometry.points.length/3}));M.setVertexBuffer(0,c),y?(M.setVertexBuffer(1,y.normalBuffer),M.setVertexBuffer(2,y.texcoordBuffer),M.setIndexBuffer(y.indicesBuffer,"uint16"),M.drawIndexed(v)):M.draw(v),P.push({graphic:e,index:t,bindGroupEntries:a,positionBuffer:c,primaryBuffers:y,count:v})})),M.end(),u.queue.submit([A.finish()])},pick:(t,n,r=(()=>!0))=>c(this,null,(function*(){const o=e.getBoundingClientRect(),i=e.clientWidth,a=e.clientHeight,s=(t-o.left)*e.width/i|0,c=(n-o.top)*e.height/a|0,p=u.createCommandEncoder(),d=p.beginRenderPass({colorAttachments:[{clearValue:[1,1,1,1],loadOp:"clear",storeOp:"store",view:v.instance.createView(),resolveTarget:E.instance.createView()}],depthStencilAttachment:{view:b.instance.createView(),depthClearValue:1,depthLoadOp:"clear",depthStoreOp:"store"}});for(const e of P)if(e&&r(e.graphic,e.index)){const t=e.graphic,n=w.get(t.geometry.type,(()=>{const e=y.instance;return u.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:f,blend:g}]},primitive:{cullMode:"back",topology:"lines"===t.geometry.type?"line-list":"line strip"===t.geometry.type?"line-strip":"triangle-list"},depthStencil:{depthWriteEnabled:!0,depthCompare:"less",format:"depth24plus"},multisample:{count:4},layout:"auto"})}));d.setPipeline(n),d.setBindGroup(0,u.createBindGroup({layout:n.getBindGroupLayout(0),entries:e.bindGroupEntries})),d.setVertexBuffer(0,e.positionBuffer),e.primaryBuffers?(d.setVertexBuffer(1,e.primaryBuffers.texcoordBuffer),d.setIndexBuffer(e.primaryBuffers.indicesBuffer,"uint16"),d.drawIndexed(e.count)):d.draw(e.count)}d.end(),u.queue.submit([p.finish()]);const h=u.createCommandEncoder(),m=u.createBuffer({size:4,usage:GPUBufferUsage.MAP_READ|GPUBufferUsage.COPY_DST});h.copyTextureToBuffer({texture:E.instance,origin:{x:s,y:c}},{buffer:m},{width:1,height:1}),u.queue.submit([h.finish()]),yield m.mapAsync(1,0,4);const x=new Uint8Array(m.getMappedRange(0,4)),C=(0,l.pixelColorToColorNumber)([x[2],x[1],x[0]]);return 16777215===C?void 0:C}))}}))}function p(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 d(e,t){const{position:n,normal:r,texcoord:o,indices:i}=t,a=p(e,n),s=p(e,r),l=p(e,o),c=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:l,indicesBuffer:c},count:i.length}}},9397:(e,t,n)=>{"use strict";n.r(t);var r=n(9300),o={};for(const e in r)"default"!==e&&(o[e]=()=>r[e]);n.d(t,o);var i=n(9254);o={};for(const e in i)"default"!==e&&(o[e]=()=>i[e]);n.d(t,o)},4427:(e,t,n)=>{"use strict";n.r(t),n.d(t,{getArrow:()=>i});var r=n(9195),o=n(3516);function i(e,t,n,i,a=1){const s=(0,r.getPointByLengthAndDirection)(t,n,e),l=a/2/Math.tan((0,o.angleToRadian)(i));return{arrowPoints:[t,(0,r.rotatePositionByCenter)(s,t,i),(0,r.rotatePositionByCenter)(s,t,-i)],distance:l,endPoint:(0,r.getPointByLengthAndDirection)(t,l,e)}}},6632:(e,t,n)=>{"use strict";n.r(t),n.d(t,{getBezierCurvePercentAtPoint:()=>g,getBezierCurvePointAtPercent:()=>h,getBezierCurvePoints:()=>m,getBezierCurvePoints3D:()=>y,getBezierSplineControlPointsOfPoints:()=>E,getBezierSplineControlPointsOfPoints3D:()=>k,getBezierSplineCurves:()=>x,getBezierSplinePoints:()=>b,getBezierSplinePoints3D:()=>C,getPartOfBezierCurve:()=>P,getPartOfQuadraticCurve:()=>S,getQuadraticCurvePercentAtPoint:()=>c,getQuadraticCurvePointAtPercent:()=>u,getQuadraticCurvePoints:()=>p,getQuadraticSplineCurves:()=>v,interpolate2:()=>a,interpolate3:()=>s,interpolate4:()=>l,pointIsOnBezierCurve:()=>f,pointIsOnQuadraticCurve:()=>d});var r=n(4275),o=n(9195),i=n(937);function a(e,t,n){return e+(t-e)*n}function s(e,t,n,r){return a(a(e,t,r),a(t,n,r),r)}function l(e,t,n,r,o){return s(a(e,t,o),a(t,n,o),a(n,r,o),o)}function c({from:{x:e,y:t},cp:{x:n,y:r},to:{x:o,y:i}},a){const s=n-e,l=o-n-s,c=r-t,u=i-r-c;return-((e-a.x)*u-(t-a.y)*l)/2/(s*u-l*c)}function u(e,t,n,r){return{x:s(e.x,t.x,n.x,r),y:s(e.y,t.y,n.y,r)}}function p(e,t,n,r){const o=[];for(let i=0;i<=r;i++)o.push(u(e,t,n,i/r));return o}function d(e,{from:{x:t,y:n},cp:{x:i,y:a},to:{x:s,y:l}}){const c=i-t,u=s-i-c,p=a-n,d=l-a-p;return(0,r.calculateEquation2)(u,2*c,t-e.x).filter((t=>t>=0&&t<=1&&(0,o.isZero)(d*t*t+2*p*t+n-e.y))).length>0}function f(e,{from:{x:t,y:n},cp1:{x:i,y:a},cp2:{x:s,y:l},to:{x:c,y:u}}){const p=3*i-t+-3*s+c,d=3*(t-2*i+s),f=3*(i-t),g=3*a-n+-3*l+u,h=3*(n-2*a+l),m=3*(a-n);return(0,r.calculateEquation3)(p,d,f,t-e.x).filter((t=>t>=0&&t<=1&&(0,o.isZero)(g*t*t*t+h*t*t+m*t+n-e.y))).length>0}function g({from:{x:e,y:t},cp1:{x:n,y:i},cp2:{x:a,y:s},to:{x:l,y:c}},u){const p=3*n-e+-3*a+l,d=3*(e-2*n+a),f=3*(n-e),g=3*i-t+-3*s+c,h=3*(t-2*i+s),m=3*(i-t);return(0,r.calculateEquation3)(p,d,f,e-u.x).filter((e=>(0,o.isZero)(g*e*e*e+h*e*e+m*e+t-u.y)))[0]}function h(e,t,n,r,o){return{x:l(e.x,t.x,n.x,r.x,o),y:l(e.y,t.y,n.y,r.y,o)}}function m(e,t,n,r,o){const i=[];for(let a=0;a<=o;a++)i.push(h(e,t,n,r,a/o));return i}function y(e,t,n,r,o){const i=[];for(let a=0;a<=o;a++){const s=a/o,c=l(e[0],t[0],n[0],r[0],s),u=l(e[1],t[1],n[1],r[1],s),p=l(e[2],t[2],n[2],r[2],s);i.push([c,u,p])}return i}function x(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 v(e){const t=[];for(let n=1;nm(e.from,e.cp1,e.cp2,e.to,t))).flat()}function C(e,t){const n=[];return k(e).forEach(((r,o)=>{n.push(...y(e[o],...r,e[o+1],t))})),n}function E(e){const t=w(e.map((e=>e.x))),n=w(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 k(e){const t=w(e.map((e=>e[0]))),n=w(e.map((e=>e[1]))),r=w(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 w(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{"use strict";n.r(t),n.d(t,{breakGeometryLines:()=>x,breakPolylineToPolylines:()=>h,getGeometryLineStartAndEnd:()=>y,mergePolylinesToPolyline:()=>m});var r=n(6632),o=n(9195),i=n(3516),a=Object.defineProperty,s=Object.defineProperties,l=Object.getOwnPropertyDescriptors,c=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(c)for(var n of c(t))p.call(t,n)&&d(e,n,t[n]);return e},g=(e,t)=>s(e,l(t));function h(e,t){const n=[];let r=[e[0][0]];if(e.forEach((e=>{const i=t.filter((t=>(0,o.pointIsOnLine)(t,...e)&&(0,o.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 m(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 y(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?{start:(0,o.getCirclePointAtRadian)(e.curve,(0,i.angleToRadian)(e.curve.startAngle)),end:(0,o.getCirclePointAtRadian)(e.curve,(0,i.angleToRadian)(e.curve.endAngle))}:{start:(0,o.getEllipseArcPointAtAngle)(e.curve,e.curve.startAngle),end:(0,o.getEllipseArcPointAtAngle)(e.curve,e.curve.endAngle)}}function x(e,t){const n=[];let a,s,l=[];const c=()=>{l.length>0&&(n.push(l),l=[])};for(const n of e){const{start:e,end:u}=y(n);let p;if(a||(a=e),Array.isArray(n)?p={isOnLine:e=>(0,o.pointIsOnLine)(e,...n)&&(0,o.pointIsOnLineSegment)(e,...n),breakLine(t){t.sort(((e,t)=>(0,o.getTwoPointsDistance)(e,n[0])-(0,o.getTwoPointsDistance)(t,n[0]))),t.unshift(e),t.push(u);for(let e=1;e(0,o.pointIsOnCircle)(e,n.curve)&&(0,o.pointIsOnArc)(e,n.curve),breakLine(e){const t=e.map((e=>(0,o.getAngleInRange)((0,i.radianToAngle)((0,o.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,o.pointIsOnEllipse)(e,n.curve)&&(0,o.pointIsOnEllipseArc)(e,n.curve),breakLine(e){const t=e.map((e=>(0,o.getAngleInRange)((0,o.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.pointIsOnQuadraticCurve)(e,n.curve),breakLine(e){const t=e.map((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.pointIsOnBezierCurve)(e,n.curve),breakLine(e){const t=e.map((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,o.isSamePoint)(t,e)))&&c();const a=t.filter((t=>!(0,o.isSamePoint)(t,e)&&!(0,o.isSamePoint)(t,u)&&r(t)));0===a.length?l.push(n):i(a),t.some((e=>(0,o.isSamePoint)(e,u)))&&c()}s=u}if(c(),n.length>1&&a&&s){const e=a;if((0,o.isSamePoint)(e,s)&&t.every((t=>!(0,o.isSamePoint)(e,t)))){const e=n.splice(n.length-1,1);n[0].unshift(...e[0])}}return n}},9354:(e,t,n)=>{"use strict";n.r(t),n.d(t,{updateCamera:()=>o});var r=n(9195);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}}},7504:(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]=l(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 l(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 c(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:()=>l,colorNumberToRec:()=>i,colorStringToNumber:()=>r,getColorString:()=>o,mergeOpacities:()=>u,mergeOpacityToColor:()=>c,pixelColorToColorNumber:()=>s,recToColorNumber:()=>a})},8626:(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"]},6725:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Debug:()=>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),n);class i{constructor(e){this.enabled=e,o(this,"last",performance.now()),o(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(" ")}}},4275:(e,t,n)=>{"use strict";n.r(t),n.d(t,{calculateEquation1:()=>i,calculateEquation2:()=>a,calculateEquation3:()=>s,calculateEquation4:()=>l,calculateEquation5:()=>c,newtonIterate:()=>u});var r=n(9195),o=Math.pow;function i(e,t,n){return(0,r.isZero)(e,n)?[]:[-t/e]}function a(e,t,n,a){if((0,r.isZero)(e,a))return i(t,n,a);1!==e&&(t/=e,n/=e);const s=o(t,2)-4*n;if(s<0&&!(0,r.isZero)(s,a))return[];if((0,r.isZero)(s,a))return[-t/2];const l=Math.sqrt(s);return[(-t+l)/2,(-t-l)/2]}function s(e,t,n,o,i){if((0,r.isZero)(e,i))return a(t,n,o,i);1!==e&&(t/=e,n/=e,o/=e);const s=t*t-3*n,l=t*n-9*o,c=n*n-3*t*o;if((0,r.isZero)(s,i)&&(0,r.isZero)(l,i))return[-t/3];const u=l*l-4*s*c;if((0,r.isZero)(u,i)){const e=l/s;return[-t+e,-e/2]}const p=s*t;if(u>0){const e=Math.sqrt(u),n=p+1.5*(-l+e),o=p+1.5*(-l-e);return[(-t-(0,r.sqrt3)(n)-(0,r.sqrt3)(o))/3]}const d=Math.sqrt(s),f=(p-1.5*l)/s/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,i,a,l){if((0,r.isZero)(e,l))return s(t,n,i,a,l);1!==e&&(t/=e,n/=e,i/=e,a/=e);const c=o(t,2),u=c*t,p=3*c-8*n,d=4*n*t-u-8*i,f=3*u*t+16*o(n,2)-16*n*c+16*t*i-64*a;if((0,r.isZero)(d,l)&&(0,r.isZero)(f,l)){if((0,r.isZero)(p,l))return[-t/4];if(p<0)return[];const e=Math.sqrt(p);return[(-t+e)/4,(-t-e)/4]}const g=o(d,2),h=o(p,2),m=h-3*f,y=p*f-9*g,x=o(f,2)-3*p*g;if((0,r.isZero)(m,l)&&(0,r.isZero)(y,l)&&(0,r.isZero)(x,l)){const e=t*p,n=4*p;return[(9*d-e)/n,(-e-3*d)/n]}const v=o(y,2)-4*m*x;if((0,r.isZero)(v,l)){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(v>0){const e=Math.sqrt(v),n=m*p,i=n-1.5*(y-e),a=n-1.5*(y+e),s=(0,r.sqrt3)(i)+(0,r.sqrt3)(a),l=h-p*s+o(s,2)-3*m,c=-t+Math.sign(d)*Math.sqrt((p+s)/3),u=Math.sqrt((2*p-s+2*Math.sqrt(l))/3);return[(c+u)/4,(c-u)/4]}if((0,r.largerThan)(p,0,l)&&(0,r.largerThan)(f,0,l)){if((0,r.isZero)(d,l)){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),s=Math.sqrt((p+e*(o+a))/3),c=Math.sqrt((p+e*(o-a))/3),u=s+c,g=s-c;return[(-t+i+u)/4,(-t+i-u)/4,(-t-i+g)/4,(-t-i-g)/4]}return[]}function c(e,t,n=1e-5,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);const i=u(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.isZero)(e-i,n)))?s:[i,...s]}function u(e,t,n,r,o=100){let i=e,a=0;for(;;){const e=t(i);if(Math.abs(e)o)return;i-=e/n(i),a++}return i}},7227:(e,t,n)=>{"use strict";n.r(t),n.d(t,{deriveExpressionWith:()=>h,expandExpression:()=>i,groupAllFactors:()=>f,groupFactorsBy:()=>d,groupFactorsByVariables:()=>g,mathStyleExpressionToExpression:()=>u,printMathStyleExpression:()=>l,sortFactors:()=>a});var r=n(2845),o=n(9300);function i(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 i({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 i({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 i({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 i({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 i({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 i({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 i(e.left.left)}}}if("/"===e.operator&&"BinaryExpression"===e.left.type&&("+"===e.left.operator||"-"===e.left.operator))return i({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=i(e.left),n=i(e.right);return t===e.left&&n===e.right?e:i({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 i({type:"BinaryExpression",left:{type:"UnaryExpression",operator:"-",argument:e.argument.left},operator:(0,o.getReverseOperator)(e.argument.operator),right:e.argument.right});const t=i(e.argument);return t===e.argument?e:i({type:"UnaryExpression",operator:e.operator,argument:t})}return e}function a(e){e.forEach((e=>{e.variables.sort(s)})),e.sort(((e,t)=>{for(let n=0;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),l=t(e.right,i),c="-1"===s&&" "==a?"-"+l:s+a+l;return o>n?`(${c})`:c}return"CallExpression"===e.type?t(e.callee)+"("+e.arguments.map((e=>t(e))).join(", ")+")":""};return t(e)}const c=["sin","cos","tan"];function u(e){let t="";for(let n=0;n0&&n0&&c.every((e=>!t.endsWith(e)))&&((0,o.isLetter)(e[n-1])||(0,o.isNumber)(e[n-1])||")"===e[n-1])?t+="*(":")"===r&&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 d(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}(p(e,t),t)}function f(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)),g(e,t.map((e=>e.name)))}function g(e,t){const n=(e,r)=>{if(e.length<=1)return;if(!t[r])return;const i={variables:[t[r]]},a=p(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 h(e,t){if("BinaryExpression"===e.type){if("+"===e.operator||"-"===e.operator)return{type:"BinaryExpression",operator:e.operator,left:h(e.left,t),right:h(e.right,t)};if("*"===e.operator)return{type:"BinaryExpression",operator:"+",left:{type:"BinaryExpression",operator:"*",left:h(e.left,t),right:e.right},right:{type:"BinaryExpression",operator:"*",left:e.left,right:h(e.right,t)}};if("/"===e.operator)return{type:"BinaryExpression",operator:"/",left:{type:"BinaryExpression",operator:"/",left:{type:"BinaryExpression",operator:"-",left:{type:"BinaryExpression",operator:"*",left:h(e.left,t),right:e.right},right:{type:"BinaryExpression",operator:"*",left:e.left,right:h(e.right,t)}},right:e.right},right:e.right};if("**"===e.operator&&(0,o.expressionHasVariable)(e.left,t)&&!(0,o.expressionHasVariable)(e.right,t))return{type:"BinaryExpression",operator:"*",left: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:h(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&&e.callee.property.name;const r=e.arguments[0];if(n&&r&&"SpreadElement"!==r.type&&(0,o.expressionHasVariable)(r,t)){if("sin"===n)return{type:"BinaryExpression",operator:"*",left:{type:"CallExpression",callee:{type:"Identifier",name:"cos"},arguments:e.arguments},right:h(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:h(r,t)}}}}return"NumericLiteral"===e.type?{type:"NumericLiteral",value:0}:"Identifier"===e.type?{type:"NumericLiteral",value:e.name===t?1:0}:e}},4523:(e,t,n)=>{"use strict";n.r(t),n.d(t,{validateExpression:()=>o});var r=n(2845);function o(e){try{(0,r.parseExpression)((0,r.tokenizeExpression)(e))}catch(e){if(e instanceof r.ExpressionError)return e.range}}},7310:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Align:()=>a,VerticalAlign:()=>l,aligns:()=>i,flowLayout:()=>o,getFlowLayoutLocation:()=>c,verticalAligns:()=>s});var r=n(9247);function o(e){var t,n,r,o,i;const a=t=>void 0===e.height||(!(l.length>0)||t>=-l[0])&&t<=e.height,s=[],l=[];let c=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 x=()=>{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,l.push(m),h=a(p),c=0,f++,g=0,m=0,x(),1===l.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:c,y:p,i:d,content:n,visible:h,row:f,column:g}),t?v():c+=e.getWidth(n),d++,g++};for(;d0&&v(),t.width<=e.width){for(;de.width&&v(),C(!1)}else c+e.getWidth(t)>e.width&&v(),C(!1)}if(0===m&&(m=b(e.endContent)),l.push(m),s.push({x:c,y:p,i:d,content:e.endContent,visible:h,row:f,column:g}),x(),e.height&&("middle"===e.verticalAlign||"bottom"===e.verticalAlign)){let t=e.height-l.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:l}}const i=["left","center","right"],a=(0,r.or)(...i),s=["top","middle","bottom"],l=(0,r.or)(...s);function c({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&&(!l||l.x+i(l.content)/2<=e))return{location:u.i,lineEnd:!1,fromRight:e>u.x};l=u}else if(void 0!==l&&o!==r.length-1)return{location:l.i+1,lineEnd:!0}}var c;return void 0!==l?{location:l.i,lineEnd:!1}:void 0}},9195:(e,t,n)=>{"use strict";n.r(t),n.d(t,{AngleRange:()=>ve,Arc:()=>be,Bounding:()=>ye,Circle:()=>xe,Ellipse:()=>me,EllipseArc:()=>Ce,Image:()=>Je,PathCommand:()=>Xe,Position:()=>fe,Region:()=>he,Size:()=>ge,Text:()=>Qe,TextStyle:()=>Ke,angleInRange:()=>M,arcToPolyline:()=>ze,dashedPolylineToLines:()=>ue,deduplicate:()=>we,deduplicatePosition:()=>Pe,deepEquals:()=>P,drawDashedLine:()=>de,drawDashedPolyline:()=>pe,ellipseArcToPolyline:()=>qe,ellipseToPolygon:()=>He,equals:()=>Se,generalFormLineToTwoPointLine:()=>Y,getAngleInRange:()=>A,getArcLength:()=>Ve,getArcPointAtAngle:()=>Ue,getCirclePointAtRadian:()=>Ne,getCircleRadian:()=>Ae,getDirectionByRadian:()=>_,getEllipseAngle:()=>Re,getEllipseArcPointAtAngle:()=>Ye,getEllipseCenter:()=>Te,getEllipsePointAtRadian:()=>je,getEllipseRadian:()=>_e,getEllipseRadiusOfAngle:()=>ce,getFormattedEndAngle:()=>We,getParallelLineSegmentsByDistance:()=>ke,getParallelLinesByDistance:()=>Ee,getPointAndPolygonMaximumDistance:()=>U,getPointAndRegionMaximumDistance:()=>z,getPointByLengthAndDirection:()=>v,getPointByLengthAndDirectionSafely:()=>w,getPointByLengthAndRadian:()=>R,getPointSideOfLine:()=>N,getPointsBounding:()=>ee,getPointsBoundingUnsafe:()=>te,getPolygonArea:()=>$e,getPolygonFromTwoPointsFormRegion:()=>ne,getPolygonLine:()=>re,getPolygonPoints:()=>le,getRegion:()=>Z,getSymmetryPoint:()=>oe,getTextStyleFont:()=>Ze,getThreePointsCircle:()=>X,getTwoNumberCenter:()=>V,getTwoNumbersDistance:()=>W,getTwoPointCenter:()=>G,getTwoPointsDistance:()=>j,getTwoPointsFormRegion:()=>K,getTwoPointsRadian:()=>Me,isBetween:()=>$,isSamePoint:()=>S,isZero:()=>b,iteratePolygonLines:()=>De,iteratePolylineLines:()=>Fe,largerThan:()=>E,lessThan:()=>C,maxmiumBy:()=>tt,mergeBoundings:()=>J,minimumBy:()=>et,multipleDirection:()=>T,normalizeAngleInRange:()=>Le,normalizeAngleRange:()=>Oe,pointAndDirectionToGeneralFormLine:()=>q,pointInPolygon:()=>Ie,pointIsInRegion:()=>Q,pointIsOnArc:()=>O,pointIsOnCircle:()=>I,pointIsOnEllipse:()=>D,pointIsOnEllipseArc:()=>F,pointIsOnLine:()=>B,pointIsOnLineSegment:()=>L,polygonToPolyline:()=>Be,rotatePosition:()=>se,rotatePositionByCenter:()=>ie,rotatePositionByEllipseCenter:()=>ae,sqrt3:()=>k,twoPointLineToGeneralFormLine:()=>H});var r=n(3490),o=n(3516),i=n(9247),a=Object.defineProperty,s=Object.defineProperties,l=Object.getOwnPropertyDescriptors,c=Object.getOwnPropertySymbols,u=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable,d=(e,t)=>{if(t=Symbol[e])return t;throw Error("Symbol."+e+" is not defined")},f=Math.pow,g=(e,t,n)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,h=(e,t)=>{for(var n in t||(t={}))u.call(t,n)&&g(e,n,t[n]);if(c)for(var n of c(t))p.call(t,n)&&g(e,n,t[n]);return e},m=(e,t)=>s(e,l(t)),y=function(e,t){this[0]=e,this[1]=t},x=e=>{var t,n=e[d("asyncIterator")],r=!1,o={};return null==n?(n=e[d("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 y(new Promise((r=>{var o=n[e](t);if(!(o instanceof Object))throw TypeError("Object expected");r(o)})),1)}}),o[d("iterator")]=()=>o,t("next"),"throw"in n?t("throw"):o.throw=e=>{throw e},"return"in n&&t("return"),o};function v(e,t,n){let r=n.x-e.x,o=n.y-e.y;if(t<0&&(t=-t,r=-r,o=-o),b(r))return{x:e.x,y:e.y+t*(o>0?1:-1)};const i=Math.sqrt(f(t,2)*f(r,2)/(f(r,2)+f(o,2)))*(r>0?1:-1);return{x:e.x+i,y:e.y+o/r*i}}function b(e,t=1e-8){return Math.abs(e)t&&!b(e-t,n)}function k(e){return e<0?-Math.pow(-e,1/3):Math.pow(e,1/3)}function w(e,t,n){if(!S(e,n))return v(e,t,n)}function S(e,t){return Se(e.x,t.x)&&Se(e.y,t.y)}function P(e,t){if(e===t)return!0;if(Array.isArray(e)){if(!Array.isArray(t))return!1;if(e.length!==t.length)return!1;for(let n=0;nt.startAngle;)e-=360;return e}for(;e>t.endAngle&&e>=t.startAngle+360;)e-=360;for(;et.startAngle?e>=t.endAngle-360:e>=t.endAngle:t.endAnglej(e,t))))}function N(e,t){return t.a*e.x+t.b*e.y+t.c}function j(e,t={x:0,y:0}){return Math.sqrt(f(e.x-t.x,2)+f(e.y-t.y,2))}function W(e,t){return Math.abs(e-t)}function G(e,t){return{x:V(e.x,t.x),y:V(e.y,t.y)}}function V(e,t){return(e+t)/2}function $(e,t,n){return e<=Math.max(t,n)&&e>=Math.min(t,n)}function H(e,t){const n=t.x-e.x,r=t.y-e.y;return{a:r,b:-n,c:-e.x*r+e.y*n}}function q(e,t){const n=Math.cos(t),r=Math.sin(t);return{a:r,b:-n,c:-e.x*r+e.y*n}}function Y({a:e,b:t,c:n}){return b(e)?[{x:0,y:-n/t},{x:1,y:-n/t}]:b(t)?[{x:-n/e,y:0},{x:-n/e,y:1}]:[{x:0,y:-n/t},{x:-n/e,y:0}]}function X(e,t,n){const r=t.x-e.x,o=t.y-e.y,i=n.x-t.x,a=n.y-t.y,s=f(t.x,2)-f(e.x,2)+f(t.y,2)-f(e.y,2),l=f(n.x,2)-f(t.x,2)+f(n.y,2)-f(t.y,2),c={x:(s*a-l*o)/(r*a-i*o)/2,y:(i*s-l*r)/(i*o-a*r)/2};return m(h({},c),{r:j(c,e)})}function K(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 Z(e,t){return{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),width:W(e.x,t.x),height:W(e.y,t.y)}}function Q(e,t){return e.x>=t.start.x&&e.y>=t.start.y&&e.x<=t.end.x&&e.y<=t.end.y}function J(e){return te(e.map((e=>[e.start,e.end])).flat())}function ee(e){if(0!==e.length)return te(e)}function te(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 ne(e){return[e.start,{x:e.start.x,y:e.end.y},e.end,{x:e.end.x,y:e.start.y}]}function*re(e){for(let t=0;t1&&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 pe(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=de(e,t[a-1],i,n,o)}))}function de(e,t,n,r,o=0){r.length%2==1&&(r=[...r,...r]);const i=r.reduce(((e,t)=>e+t));if(i<=0)return o;let a=j(t,n);const s=(o+a)%i;let l=t;for(;a>0;)for(let t=0;t0){if(i<=o){o-=i;continue}i-=o,o=0}const c=t%2==0?"lineTo":"moveTo";if(i>=a)return e[c](n.x,n.y),s;const u=v(l,i,n);e[c](u.x,u.y),a-=i,l=u}return s}const fe={x:i.number,y:i.number},ge={width:(0,i.minimum)(0,i.number),height:(0,i.minimum)(0,i.number)},he=(0,i.and)(fe,ge),me={cx:i.number,cy:i.number,rx:(0,i.minimum)(0,i.number),ry:(0,i.minimum)(0,i.number),angle:(0,i.optional)(i.number)},ye={xMin:i.number,xMax:i.number,yMin:i.number,yMax:i.number},xe=(0,i.and)(fe,{r:(0,i.minimum)(0,i.number)}),ve={startAngle:i.number,endAngle:i.number,counterclockwise:(0,i.optional)(i.boolean)},be=(0,i.and)(xe,ve),Ce=(0,i.and)(me,ve);function Ee(e,t){if(b(t))return[e,e];const n=t*Math.sqrt(f(e.a,2)+f(e.b,2));return[m(h({},e),{c:e.c+n}),m(h({},e),{c:e.c-n})]}function ke(e,t){if(b(t))return[e,e];const n=Me(e[1],e[0]),r=n-Math.PI/2,o=n+Math.PI/2;return[[R(e[0],t,o),R(e[1],t,o)],[R(e[0],t,r),R(e[1],t,r)]]}function we(e,t){const n=[];for(const r of e)n.every((e=>!t(e,r)))&&n.push(r);return n}function Se(e,t){return void 0===e&&void 0===t||void 0!==e&&void 0!==t&&b(e-t)}function Pe(e){return we(e,S)}function Re(e,t){return(0,o.radianToAngle)(_e(e,t))}function _e(e,t){var n;const r=ie(e,Te(t),null!=(n=t.angle)?n:0);return Math.atan2((r.y-t.cy)/t.ry,(r.x-t.cx)/t.rx)}function Te(e){return{x:e.cx,y:e.cy}}function Ae(e,t){return Me(e,t)}function Me(e,t={x:0,y:0}){return Math.atan2(e.y-t.y,e.x-t.x)}function Le(e,t){for(;e>t.endAngle;)e-=360;for(;e360&&(e.endAngle-=360)}function Ie({x:e,y:t},n){let r=!1;for(let o=0,i=n.length-1;ot!=c>t&&e<(l-a)*(t-s)/(c-s)+a&&(r=!r)}return r}function*Fe(e){for(let t=1;tUe(e,t)))}function Ue(e,t){return Ne(e,(0,o.angleToRadian)(t))}function Ne(e,t){return R(e,e.r,t)}function je(e,t){const n=_(t),r={x:e.cx+e.rx*n.x,y:e.cy+e.ry*n.y};return e.angle?se(r,Te(e),(0,o.angleToRadian)(e.angle)):r}function We(e){let t;return t=e.counterclockwise?e.startAnglee.endAngle?e.endAngle+360:e.endAngle,t}function Ge(e,t){const n=We(e),r=[];for(let o=e.startAngle;!Se(o,n)&&!(e.counterclockwise?on);)r.push(o),e.counterclockwise?o-=t:o+=t;return 0!==r.length&&Se(r[r.length-1],n)||r.push(n),r}function Ve(e){const t=We(e);return e.r*(0,o.angleToRadian)(Math.abs(t-e.startAngle))}function $e(e){let t=0;for(let n=0;nYe(e,t)))}function Ye(e,t){return je(e,(0,o.angleToRadian)(t))}const Xe=(e,t)=>(0,r.isRecord)(e)?"move"===e.type?(0,i.validate)(e,{type:"move",to:fe},t):"line"===e.type?(0,i.validate)(e,{type:"line",to:fe},t):"arc"===e.type?(0,i.validate)(e,{type:"arc",from:fe,to:fe,radius:i.number},t):"ellipseArc"===e.type?(0,i.validate)(e,{type:"ellipseArc",rx:i.number,ry:i.number,angle:i.number,largeArc:i.boolean,sweep:i.boolean,to:fe},t):"bezierCurve"===e.type?(0,i.validate)(e,{type:"bezierCurve",cp1:fe,cp2:fe,to:fe},t):"quadraticCurve"===e.type?(0,i.validate)(e,{type:"quadraticCurve",cp:fe,to:fe},t):"close"===e.type?(0,i.validate)(e,{type:"close"},t):{path:[...t,"type"],expect:"or",args:["move","line","arc","ellipseArc","bezierCurve","quadraticCurve","close"]}:{path:t,expect:"object"},Ke={fontSize:i.number,fontFamily:i.string};function Ze(e){return`${e.fontSize}px ${e.fontFamily}`}const Qe=(0,i.and)(fe,Ke,{text:i.string,color:i.number}),Je=(0,i.and)(he,{url:i.string});function et(e,t){let n=e[0];for(let r=1;r{"use strict";n.r(t),n.d(t,{getKeys:()=>r});const r=Object.keys},9254:(e,t,n)=>{"use strict";n.r(t);var r=n(8119),o={};for(const e in r)"default"!==e&&(o[e]=()=>r[e]);n.d(t,o);var i=n(8626);o={};for(const e in i)"default"!==e&&(o[e]=()=>i[e]);n.d(t,o);var a=n(9195);o={};for(const e in a)"default"!==e&&(o[e]=()=>a[e]);n.d(t,o);var s=n(5547);o={};for(const e in s)"default"!==e&&(o[e]=()=>s[e]);n.d(t,o);var l=n(8260);o={};for(const e in l)"default"!==e&&(o[e]=()=>l[e]);n.d(t,o);var c=n(9605);o={};for(const e in c)"default"!==e&&(o[e]=()=>c[e]);n.d(t,o);var u=n(6564);o={};for(const e in u)"default"!==e&&(o[e]=()=>u[e]);n.d(t,o);var p=n(4029);o={};for(const e in p)"default"!==e&&(o[e]=()=>p[e]);n.d(t,o);var d=n(6581);o={};for(const e in d)"default"!==e&&(o[e]=()=>d[e]);n.d(t,o);var f=n(1684);o={};for(const e in f)"default"!==e&&(o[e]=()=>f[e]);n.d(t,o);var g=n(7270);o={};for(const e in g)"default"!==e&&(o[e]=()=>g[e]);n.d(t,o);var h=n(5791);o={};for(const e in h)"default"!==e&&(o[e]=()=>h[e]);n.d(t,o);var m=n(6725);o={};for(const e in m)"default"!==e&&(o[e]=()=>m[e]);n.d(t,o);var y=n(7310);o={};for(const e in y)"default"!==e&&(o[e]=()=>y[e]);n.d(t,o);var x=n(4402);o={};for(const e in x)"default"!==e&&(o[e]=()=>x[e]);n.d(t,o);var v=n(216);o={};for(const e in v)"default"!==e&&(o[e]=()=>v[e]);n.d(t,o);var b=n(2070);o={};for(const e in b)"default"!==e&&(o[e]=()=>b[e]);n.d(t,o);var C=n(3490);o={};for(const e in C)"default"!==e&&(o[e]=()=>C[e]);n.d(t,o);var E=n(2233);o={};for(const e in E)"default"!==e&&(o[e]=()=>E[e]);n.d(t,o);var k=n(9247);o={};for(const e in k)"default"!==e&&(o[e]=()=>k[e]);n.d(t,o);var w=n(7504);o={};for(const e in w)"default"!==e&&(o[e]=()=>w[e]);n.d(t,o);var S=n(7386);o={};for(const e in S)"default"!==e&&(o[e]=()=>S[e]);n.d(t,o);var P=n(2357);o={};for(const e in P)"default"!==e&&(o[e]=()=>P[e]);n.d(t,o);var R=n(9642);o={};for(const e in R)"default"!==e&&(o[e]=()=>R[e]);n.d(t,o);var _=n(4427);o={};for(const e in _)"default"!==e&&(o[e]=()=>_[e]);n.d(t,o);var T=n(4523);o={};for(const e in T)"default"!==e&&(o[e]=()=>T[e]);n.d(t,o);var A=n(9354);o={};for(const e in A)"default"!==e&&(o[e]=()=>A[e]);n.d(t,o);var M=n(3516);o={};for(const e in M)"default"!==e&&(o[e]=()=>M[e]);n.d(t,o);var L=n(863);o={};for(const e in L)"default"!==e&&(o[e]=()=>L[e]);n.d(t,o);var O=n(7459);o={};for(const e in O)"default"!==e&&(o[e]=()=>O[e]);n.d(t,o);var I=n(4275);o={};for(const e in I)"default"!==e&&(o[e]=()=>I[e]);n.d(t,o);var F=n(7227);o={};for(const e in F)"default"!==e&&(o[e]=()=>F[e]);n.d(t,o);var D=n(5810);o={};for(const e in D)"default"!==e&&(o[e]=()=>D[e]);n.d(t,o);var B=n(6003);o={};for(const e in B)"default"!==e&&(o[e]=()=>B[e]);n.d(t,o);var z=n(6632);o={};for(const e in z)"default"!==e&&(o[e]=()=>z[e]);n.d(t,o);var U=n(5395);o={};for(const e in U)"default"!==e&&(o[e]=()=>U[e]);n.d(t,o);var N=n(937);o={};for(const e in N)"default"!==e&&(o[e]=()=>N[e]);n.d(t,o);var j=n(5521);o={};for(const e in j)"default"!==e&&(o[e]=()=>j[e]);n.d(t,o)},9605:(e,t,n)=>{"use strict";n.r(t),n.d(t,{geometryLineInPolygon:()=>p,geometryLineIntersectWithPolygon:()=>k,getArcBezierCurveIntersectionPoints:()=>$,getArcEllipseArcIntersectionPoints:()=>M,getArcEllipseIntersectionPoints:()=>A,getArcQuadraticCurveIntersectionPoints:()=>z,getCircleBezierCurveIntersectionPoints:()=>V,getCircleEllipseIntersectionPoints:()=>T,getCircleQuadraticCurveIntersectionPoints:()=>B,getEllipseArcBezierCurveIntersectionPoints:()=>q,getEllipseArcEllipseIntersectionPoints:()=>O,getEllipseArcQuadraticCurveIntersectionPoints:()=>N,getEllipseBezierCurveIntersectionPoints:()=>H,getEllipseQuadraticCurveIntersectionPoints:()=>U,getGeneralFormLineCircleIntersectionPoints:()=>C,getLineBezierCurveIntersectionPoints:()=>W,getLineCircleIntersectionPoints:()=>b,getLineEllipseIntersectionPoints:()=>P,getLineQuadraticCurveIntersectionPoints:()=>F,getLineSegmentArcIntersectionPoints:()=>x,getLineSegmentBezierCurveIntersectionPoints:()=>G,getLineSegmentCircleIntersectionPoints:()=>y,getLineSegmentEllipseArcIntersectionPoints:()=>_,getLineSegmentEllipseIntersectionPoints:()=>R,getLineSegmentQuadraticCurveIntersectionPoints:()=>D,getQuadraticCurveBezierCurveIntersectionPoints:()=>Y,getTwoArcIntersectionPoints:()=>v,getTwoBezierCurveIntersectionPoints:()=>X,getTwoCircleIntersectionPoints:()=>m,getTwoEllipseArcIntersectionPoints:()=>I,getTwoEllipseIntersectionPoints:()=>L,getTwoGeneralFormLinesIntersectionPoint:()=>h,getTwoGeometryLinesIntersectionPoint:()=>f,getTwoLineSegmentsIntersectionPoint:()=>d,getTwoLinesIntersectionPoint:()=>g,getTwoQuadraticCurveIntersectionPoints:()=>j,iterateIntersectionPoints:()=>u,lineIntersectWithPolygon:()=>E,lineIntersectWithTwoPointsFormRegion:()=>S});var r=n(4275),o=n(9195),i=n(3516),a=(e,t)=>{if(t=Symbol[e])return t;throw Error("Symbol."+e+" is not defined")},s=Math.pow,l=function(e,t){this[0]=e,this[1]=t},c=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 l(new Promise((r=>{var o=n[e](t);if(!(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,t,n,r){const o=r(e),i=r(t);if(o&&i&&o.getGeometries&&i.getGeometries)for(const r of o.getGeometries(e,n).lines)for(const e of i.getGeometries(t,n).lines)yield*c(f(r,e))}function p(e,t){if(Array.isArray(e))return(0,o.pointInPolygon)(e[0],t)&&(0,o.pointInPolygon)(e[1],t);let n,r;return"arc"===e.type?(n=(0,o.getArcPointAtAngle)(e.curve,e.curve.startAngle),r=(0,o.getArcPointAtAngle)(e.curve,e.curve.endAngle)):"ellipse arc"===e.type?(n=(0,o.getEllipseArcPointAtAngle)(e.curve,e.curve.startAngle),r=(0,o.getEllipseArcPointAtAngle)(e.curve,e.curve.endAngle)):(n=e.curve.from,r=e.curve.to),(0,o.pointInPolygon)(n,t)&&(0,o.pointInPolygon)(r,t)&&!k(e,t)}function d(e,t,n,r){const i=g(e,t,n,r);if(i&&(0,o.pointIsOnLineSegment)(i,e,t)&&(0,o.pointIsOnLineSegment)(i,n,r))return i}function f(e,t,n=!1,r=1e-5){if(Array.isArray(e)){if(Array.isArray(t)){const r=n?g(...e,...t):d(...e,...t);return r?[r]:[]}return"arc"===t.type?n?b(...e,t.curve,r):x(...e,t.curve):"ellipse arc"===t.type?n?P(...e,t.curve):_(...e,t.curve):"quadratic curve"===t.type?n?F(...e,t.curve,!0):D(...e,t.curve):n?W(...e,t.curve,!0):G(...e,t.curve)}return Array.isArray(t)?f(t,e,n):"arc"===e.type?"arc"===t.type?n?m(e.curve,t.curve):v(e.curve,t.curve):"ellipse arc"===t.type?n?T(e.curve,t.curve):M(e.curve,t.curve):"quadratic curve"===t.type?n?B(e.curve,t.curve,!0):z(e.curve,t.curve):n?V(e.curve,t.curve,void 0,!0):$(e.curve,t.curve):"arc"===t.type?f(t,e,n):"ellipse arc"===e.type?"ellipse arc"===t.type?n?L(e.curve,t.curve):I(e.curve,t.curve):"quadratic curve"===t.type?n?U(e.curve,t.curve,!0):N(e.curve,t.curve):n?H(e.curve,t.curve,void 0,!0):q(e.curve,t.curve):"ellipse arc"===t.type?f(t,e,n):"quadratic curve"===e.type?"quadratic curve"===t.type?j(e.curve,t.curve,n):Y(e.curve,t.curve,void 0,n):"quadratic curve"===t.type?f(t,e,n):X(e.curve,t.curve,void 0,n)}function g(e,t,n,r){return h((0,o.twoPointLineToGeneralFormLine)(e,t),(0,o.twoPointLineToGeneralFormLine)(n,r))}function h(e,t){const{a:n,b:r,c:i}=e,{a,b:s,c:l}=t,c=a*r-n*s;if(!(0,o.isZero)(c))return{x:(i*s-r*l)/c,y:(l*n-i*a)/c}}function m({x:e,y:t,r:n},{x:r,y:i,r:a}){const l=s(n,2),c=s(a,2),u=r-e,p=i-t,d=s(u,2)+s(p,2),f=Math.sqrt(d),g=(d+l-c)/2/f,h=l-s(g,2);if(h<0&&!(0,o.isZero)(h))return[];const m=g/f,y=m*u+e,x=m*p+t;if((0,o.isZero)(h))return[{x:y,y:x}];const v=Math.sqrt(h)/f,b=v*p,C=v*u;return[{x:y+b,y:x-C},{x:y-b,y:x+C}]}function y(e,t,n){return b(e,t,n).filter((n=>(0,o.pointIsOnLineSegment)(n,e,t)))}function x(e,t,n){return y(e,t,n).filter((e=>(0,o.pointIsOnArc)(e,n)))}function v(e,t){return m(e,t).filter((n=>(0,o.pointIsOnArc)(n,e)&&(0,o.pointIsOnArc)(n,t)))}function b({x:e,y:t},{x:n,y:r},{x:i,y:a,r:l},c){const u=n-e,p=r-t,d=p*(i-e)-u*(a-t),f=s(u,2)+s(p,2),g=l*l*f-d*d;if(g<0&&!(0,o.isZero)(g,c))return[];const h=-p*d/f+i,m=u*d/f+a;if((0,o.isZero)(g,c))return[{x:h,y:m}];const y=Math.sqrt(g),x=y*u/f,v=y*p/f;return[{x:h-x,y:m-v},{x:h+x,y:m+v}]}function C(e,t){return b(...(0,o.generalFormLineToTwoPointLine)(e),t)}function E(e,t,n){for(const r of(0,o.getPolygonLine)(n))if(w(e,t,...r))return!0;return!1}function k(e,t){for(const n of(0,o.getPolygonLine)(t))if(Array.isArray(e)){if(w(...e,...n))return!0}else if("arc"===e.type){if(x(...n,e.curve).length>0)return!0}else if("ellipse arc"===e.type){if(_(...n,e.curve).length>0)return!0}else if("quadratic curve"===e.type){if(D(...n,e.curve).length>0)return!0}else if("bezier curve"===e.type&&G(...n,e.curve).length>0)return!0;return!1}function w(e,t,n,r){if(!(Math.min(e.x,t.x)<=Math.max(n.x,r.x)&&Math.min(n.y,r.y)<=Math.max(e.y,t.y)&&Math.min(n.x,r.x)<=Math.max(e.x,t.x)&&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),i=(r.x-e.x)*(t.y-e.y)-(t.x-e.x)*(r.y-e.y),a=(e.x-n.x)*(r.y-n.y)-(r.x-n.x)*(e.y-n.y),s=(t.x-n.x)*(r.y-n.y)-(r.x-n.x)*(t.y-n.y);return o*i<=0&&a*s<=0}function S(e,t,n){return E(e,t,(0,o.getPolygonFromTwoPointsFormRegion)(n))}function P({x:e,y:t},{x:n,y:r},{rx:a,ry:s,cx:l,cy:c,angle:u}){const p=(0,i.angleToRadian)(u),d=Math.sin(p),f=Math.cos(p),g=n-e,h=r-t,m=h*(l-e)-g*(c-t),y=f*g+d*h,x=f*h-d*g,v=s*s*y,b=a*a*x,C=v*y+b*x,E=C-m*m;if(E<0&&!(0,o.isZero)(E))return[];const k=l-m*(v*d+b*f)/C,w=c+m*(v*f-b*d)/C;if((0,o.isZero)(E))return[{x:k,y:w}];const S=a*s*Math.sqrt(E)/C,P=g*S,R=h*S;return[{x:k+P,y:w+R},{x:k-P,y:w-R}]}function R(e,t,n){return P(e,t,n).filter((n=>(0,o.pointIsOnLineSegment)(n,e,t)))}function _(e,t,n){return R(e,t,n).filter((e=>(0,o.pointIsOnEllipseArc)(e,n)))}function T({x:e,y:t,r:n},{rx:a,ry:l,cx:c,cy:u,angle:p}){if((0,o.isZero)(a-l))return m({x:e,y:t,r:n},{x:c,y:u,r:a});const d=(0,i.angleToRadian)(p),f=Math.sin(d),g=Math.cos(d),h=1/a/a,y=1/l/l,x=f*f*h+g*g*y,v=(2*f*g*h-2*f*g*y)/x,b=(g*g*h+f*f*y)/x,C=-1/x,E=s(n,2),k=c-e,w=u-t,S=1-b,P=k*k+w*w-E-C,R=v*v*S+v*v*b+S*S,_=-2*w*v*S+2*k*v*v+-4*w*v*b+4*k*S,T=-4*k*w*v+4*w*w*b+4*k*k+v*v*C+2*S*P+v*v*P,A=4*k*P+-4*w*v*C+-2*w*v*P,M=P*P+4*w*w*C;return(0,r.calculateEquation4)(R,_,T,A,M).map((e=>({x:e+c,y:-(P+2*k*e+S*e*e)/(2*w-v*e)+u})))}function A(e,t){return T(e,t).filter((t=>(0,o.pointIsOnArc)(t,e)))}function M(e,t){return A(e,t).filter((e=>(0,o.pointIsOnEllipseArc)(e,t)))}function L({rx:e,ry:t,cx:n,cy:a,angle:s},{rx:l,ry:c,cx:u,cy:p,angle:d}){if((0,o.isZero)(e-t))return T({x:n,y:a,r:e},{rx:l,ry:c,cx:u,cy:p,angle:d});if((0,o.isZero)(l-c))return T({x:u,y:p,r:l},{rx:e,ry:t,cx:n,cy:a,angle:s});const f=(0,i.angleToRadian)(s),g=(0,i.angleToRadian)(d),h=Math.sin(f),m=Math.cos(f),y=Math.sin(g),x=Math.cos(g),v=1/e/e,b=1/t/t,C=h*h*v+m*m*b,E=2*h*m*v/C,k=2*h*m*b/C,w=(m*m*v+h*h*b)/C,S=-1/C,P=1/l/l,R=1/c/c,_=n-u,A=a-p,M=y*y*P+x*x*R,L=(2*y*x*P*_-2*y*x*R*_+2*y*y*P*A+2*x*x*R*A)/M,O=(2*x*x*P*_+2*y*y*R*_+2*y*x*P*A-2*y*x*R*A)/M,I=k+-E+(2*y*x*P-2*y*x*R)/M,F=(x*x*P+y*y*R)/M-w,D=(x*x*P*_*_+y*y*R*_*_+2*y*x*P*_*A+-2*y*x*R*_*A+y*y*P*A*A+x*x*R*A*A-1)/M-S,B=w*I*I+k*I*F+F*F+-E*I*F,z=2*w*L*I+-E*O*I+2*O*F+k*O*I+-E*L*F+k*L*F,U=w*L*L+-E*L*O+k*L*O+S*I*I+O*O+k*I*D+2*F*D+-E*I*D,N=2*S*L*I+2*O*D+-E*L*D+k*L*D,j=S*L*L+D*D;return(0,r.calculateEquation4)(B,z,U,N,j).map((e=>({x:e+n,y:-(O*e+F*e*e+D)/(I*e+L)+a})))}function O(e,t){return L(e,t).filter((t=>(0,o.pointIsOnEllipseArc)(t,e)))}function I(e,t){return O(e,t).filter((e=>(0,o.pointIsOnEllipseArc)(e,t)))}function F({x:e,y:t},{x:n,y:o},{from:{x:i,y:a},cp:{x:s,y:l},to:{x:c,y:u}},p=!1){const d=s-i,f=c-s-d,g=l-a,h=u-l-g,m=n-e,y=o-t;let x=(0,r.calculateEquation2)(-1*h*m+f*y,-2*g*m+2*d*y,-a*m+i*y+-y*e+m*t);return p||(x=x.filter((e=>e>=0&&e<=1))),x.map((e=>({x:f*e*e+2*d*e+i,y:h*e*e+2*g*e+a})))}function D(e,t,n){return F(e,t,n).filter((n=>(0,o.pointIsOnLineSegment)(n,e,t)))}function B({x:e,y:t,r:n},{from:{x:o,y:i},cp:{x:a,y:s},to:{x:l,y:c}},u=!1){const p=a-o,d=l-a-p,f=s-i,g=c-s-f;let h=(0,r.calculateEquation4)(d*d+g*g,4*(p*d+f*g),2*(2*p*p+o*d+2*f*f+i*g-d*e-g*t),4*(o*p+i*f+-1*p*e+-1*f*t),o*o+i*i+-n*n+-2*o*e+e*e+-2*i*t+t*t);return u||(h=h.filter((e=>e>=0&&e<=1))),h.map((e=>({x:d*e*e+2*p*e+o,y:g*e*e+2*f*e+i})))}function z(e,t){return B(e,t).filter((t=>(0,o.pointIsOnArc)(t,e)))}function U({rx:e,ry:t,cx:n,cy:o,angle:a},{from:{x:l,y:c},cp:{x:u,y:p},to:{x:d,y:f}},g=!1){const h=u-l,m=d-u-h,y=p-c,x=f-p-y,v=(0,i.angleToRadian)(a),b=Math.sin(v),C=Math.cos(v),E=1/e/e,k=1/t/t,w=l-n,S=c-o,P=y*b+h*C,R=h*b-y*C,_=x*b+m*C,T=m*b-x*C,A=b*k*w-C*k*S,M=C*E*w+b*E*S;let L=(0,r.calculateEquation4)(s(_,2)*E+s(T,2)*k,4*(P*_*E+R*T*k),2*(2*s(P,2)*E+2*s(R,2)*k+_*M+T*A),4*(P*M+R*A),s(C*w+b*S,2)*E+s(b*w+-C*S,2)*k-1);return g||(L=L.filter((e=>e>=0&&e<=1))),L.map((e=>({x:m*e*e+2*h*e+l,y:x*e*e+2*y*e+c})))}function N(e,t){return U(e,t).filter((t=>(0,o.pointIsOnEllipseArc)(t,e)))}function j({from:{x:e,y:t},cp:{x:n,y:o},to:{x:i,y:a}},{from:{x:s,y:l},cp:{x:c,y:u},to:{x:p,y:d}},f=!1){const g=n-e,h=i-n-g,m=o-t,y=a-o-m,x=c-s,v=p-c-x,b=u-l,C=d-u-b,E=(e-s)/h,k=2*g/h,w=v/h,S=2*x/h,P=2*m/y-k,R=(-C/y+w)/P,_=(S+-2*b/y)/P,T=((t-l)/y-E)/P;let A=(0,r.calculateEquation4)(R*R,2*R*_,-k*R+_*_+2*R*T-w,-k*_+2*_*T-S,E+-k*T+T*T);return f||(A=A.filter((e=>e>=0&&e<=1))),A.map((e=>({x:v*e*e+2*x*e+s,y:C*e*e+2*b*e+l})))}function W({x:e,y:t},{x:n,y:o},{from:{x:i,y:a},cp1:{x:s,y:l},cp2:{x:c,y:u},to:{x:p,y:d}},f=!1){const g=3*s-i+-3*c+p,h=3*(i-2*s+c),m=3*(s-i),y=3*l-a+-3*u+d,x=3*(a-2*l+u),v=3*(l-a),b=n-e,C=o-t;let E=(0,r.calculateEquation3)(-y*b+g*C,-x*b+h*C,-v*b+m*C,-a*b+i*C+-C*e+b*t);return f||(E=E.filter((e=>e>=0&&e<=1))),E.map((e=>({x:g*e*e*e+h*e*e+m*e+i,y:y*e*e*e+x*e*e+v*e+a})))}function G(e,t,n){return W(e,t,n).filter((n=>(0,o.pointIsOnLineSegment)(n,e,t)))}function V({x:e,y:t,r:n},{from:{x:o,y:i},cp1:{x:a,y:l},cp2:{x:c,y:u},to:{x:p,y:d}},f=1e-5,g=!1){const h=3*a-o+-3*c+p,m=3*(o-2*a+c),y=3*(a-o),x=3*l-i+-3*u+d,v=3*(i-2*l+u),b=3*(l-i),C=o-e,E=i-t,k=s(n,2),w=h*h+x*x,S=h*m+x*v,P=m*m+2*h*y+v*v+2*x*b,R=m*y+h*C+v*b+x*E,_=y*y+2*m*C+b*b+2*v*E,T=2*(y*C+b*E);let A=(0,r.calculateEquation5)([w,2*S,P,2*R,_,T,C*C+E*E-k],.5,f);return g||(A=A.filter((e=>e>=0&&e<=1))),A.map((e=>({x:h*e*e*e+m*e*e+y*e+o,y:x*e*e*e+v*e*e+b*e+i})))}function $(e,t){return V(e,t).filter((t=>(0,o.pointIsOnArc)(t,e)))}function H({rx:e,ry:t,cx:n,cy:o,angle:a},{from:{x:l,y:c},cp1:{x:u,y:p},cp2:{x:d,y:f},to:{x:g,y:h}},m=1e-5,y=!1){const x=3*u-l+-3*d+g,v=3*(l-2*u+d),b=3*(u-l),C=3*p-c+-3*f+h,E=3*(c-2*p+f),k=3*(p-c),w=(0,i.angleToRadian)(a),S=Math.sin(w),P=Math.cos(w),R=1/e/e,_=1/t/t,T=l-n,A=c-o,M=C*S+x*P,L=x*S-C*P,O=S*T-P*A,I=P*T+S*A,F=k*S+b*P,D=b*S-k*P,B=E*S+v*P,z=v*S-E*P,U=B*R,N=z*_,j=D*_,W=F*R,G=I*R,V=O*_;let $=(0,r.calculateEquation5)([s(M,2)*R+s(L,2)*_,2*(U*M+L*N),B*U+z*N+2*(W*M+j*L),2*(F*U+D*N+M*G+L*V),F*W+D*j+2*((U*P+N*S)*T+(U*S-N*P)*A),2*((W*P+j*S)*T+(W*S-j*P)*A),O*V+I*G-1],.5,m);return y||($=$.filter((e=>e>=0&&e<=1))),$.map((e=>({x:x*e*e*e+v*e*e+b*e+l,y:C*e*e*e+E*e*e+k*e+c})))}function q(e,t){return H(e,t).filter((t=>(0,o.pointIsOnEllipseArc)(t,e)))}function Y({from:{x:e,y:t},cp:{x:n,y:o},to:{x:i,y:a}},{from:{x:s,y:l},cp1:{x:c,y:u},cp2:{x:p,y:d},to:{x:f,y:g}},h=1e-5,m=!1){const y=3*c-s+-3*p+f,x=3*(s-2*c+p),v=3*(c-s),b=3*u-l+-3*d+g,C=3*(l-2*u+d),E=3*(u-l),k=n-e,w=i-n-k,S=o-t,P=a-o-S,R=2*k/w,_=y/w,T=x/w,A=v/w,M=e/w-s/w,L=2*S/P-R,O=_-b/P,I=T-C/P,F=A-E/P,D=t/P-l/P-M;let B=(0,r.calculateEquation5)([O*O,2*O*I,I*I+2*O*F,-_*L*L+-R*L*O+2*I*F+2*O*D,-T*L*L+-R*L*I+F*F+2*I*D,-A*L*L+-R*L*F+2*F*D,M*L*L+-R*L*D+D*D],.5,h);return m||(B=B.filter((e=>e>=0&&e<=1))),B.map((e=>({x:y*e*e*e+x*e*e+v*e+s,y:b*e*e*e+C*e*e+E*e+l})))}function X({from:{x:e,y:t},cp1:{x:n,y:o},cp2:{x:i,y:a},to:{x:s,y:l}},{from:{x:c,y:u},cp1:{x:p,y:d},cp2:{x:f,y:g},to:{x:h,y:m}},y=1e-5,x=!1){const v=3*p-c+-3*f+h,b=3*(c-2*p+f),C=3*(p-c),E=3*d-u+-3*g+m,k=3*(u-2*d+g),w=3*(d-u),S=3*n-e+-3*i+s,P=3*o-t+-3*a+l,R=3*(e-2*n+i)/S,_=3*(n-e)/S,T=v/S,A=b/S,M=C/S,L=e/S-c/S,O=3*(t-2*o+a)/P-R,I=(3*(o-t)/P-_)/O/2,F=(T-E/P)/O,D=(A-k/P)/O,B=(M-w/P)/O,z=I*I-(t/P-u/P-L)/O,U=R-3*I,N=z+(-2*R*I+3*I*I+_),j=-F*U-T,W=-D*U-A,G=-B*U-M,V=z*U+(R*I*I+-_*I+L+-I*I*I);let $=(0,r.calculateEquation5)([F*F*F,3*F*F*D,3*F*D*D+3*F*F*B,j*j+D*D*D+6*F*D*B+-F*F*z+-2*F*F*N,2*j*W+3*D*D*B+3*F*B*B+-2*F*D*z+-4*F*D*N,W*W+2*j*G+3*D*B*B+-D*D*z+-2*F*B*z+-2*D*D*N+-4*F*B*N,2*W*G+2*j*V+B*B*B+-2*D*B*z+-4*D*B*N+2*F*z*N+F*N*N,G*G+2*W*V+-B*B*z+-2*B*B*N+2*D*z*N+D*N*N,2*G*V+2*B*z*N+B*N*N,V*V+-z*N*N],.5,y);return x||($=$.filter((e=>e>=0&&e<=1))),$.map((e=>({x:v*e*e*e+b*e*e+C*e+c,y:E*e*e*e+k*e*e+w*e+u})))}},2233:(e,t,n)=>{"use strict";n.r(t),n.d(t,{isArray:()=>r});const r=Array.isArray},3490:(e,t,n)=>{"use strict";function r(e){return"object"==typeof e&&null!==e}n.r(t),n.d(t,{isRecord:()=>r})},9642:(e,t,n)=>{"use strict";function*r(e){if(Array.isArray(e))for(const t of e)t&&(yield t);else yield e}n.r(t),n.d(t,{iterateItemOrArray:()=>r})},2357:(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}},7459:(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}}},6581:(e,t,n)=>{"use strict";n.r(t),n.d(t,{m3:()=>r});const r={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){const n=e[0],r=e[1],o=e[2],i=e[3],a=e[4],s=e[5],l=e[6],c=e[7],u=e[8],p=t[0],d=t[1],f=t[2],g=t[3],h=t[4],m=t[5],y=t[6],x=t[7],v=t[8];return[p*n+d*i+f*l,p*r+d*a+f*c,p*o+d*s+f*u,g*n+h*i+m*l,g*r+h*a+m*c,g*o+h*s+m*u,y*n+x*i+v*l,y*r+x*a+v*c,y*o+x*s+v*u]},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]],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]})}},863:(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})},4402:(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)]}}}},937:(e,t,n)=>{"use strict";function r(e,t,n,r=l(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 o(e,t,n,o=l(n.length,t),i){return i?r(e,t,n.map(((e,t)=>n[t]*i[t])),o)/r(e,t,i,o):r(e,t,n,o)}function i(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 a(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 s(e,t,n,r=l(n.length,t),i){return n[0].map(((a,s)=>o(e,t,n.map((e=>e[s])),r,i)))}function l(e,t){const n=[];for(let e=0;ee.x)),c=t.map((e=>e.y));for(let t=0;t<=i;t++){const l=t/i;a.push({x:o(l,e,s,n,r),y:o(l,e,c,n,r)})}return a}n.r(t),n.d(t,{getDefaultNurbsKnots:()=>l,getDefaultWeights:()=>c,getNurbsPoints:()=>u,interpolateBSpline:()=>r,interpolateNurbs:()=>o,interpolateNurbs2:()=>s,toBezierCurves:()=>i,toQuadraticCurves:()=>a})},5521:(e,t,n)=>{"use strict";n.r(t),n.d(t,{getLinesOffsetDirection:()=>O,getParallelArcsByDistance:()=>C,getParallelBezierCurvesByDistance:()=>S,getParallelCirclesByDistance:()=>b,getParallelEllipseArcsByDistance:()=>k,getParallelEllipsesByDistance:()=>E,getParallelGeometryLineByDistance:()=>F,getParallelGeometryLinesByDistance:()=>D,getParallelQuadraticCurvesByDistance:()=>w,getPointSideOfArc:()=>R,getPointSideOfBezierCurve:()=>M,getPointSideOfCircle:()=>P,getPointSideOfEllipse:()=>_,getPointSideOfEllipseArc:()=>T,getPointSideOfGeometryLine:()=>L,getPointSideOfQuadraticCurve:()=>A,pointSideToIndex:()=>I});var r=n(6632),o=n(5791),i=n(9195),a=n(9605),s=n(6003),l=n(3516),c=n(5810),u=Object.defineProperty,p=Object.defineProperties,d=Object.getOwnPropertyDescriptors,f=Object.getOwnPropertySymbols,g=Object.prototype.hasOwnProperty,h=Object.prototype.propertyIsEnumerable,m=Math.pow,y=(e,t,n)=>t in e?u(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,x=(e,t)=>{for(var n in t||(t={}))g.call(t,n)&&y(e,n,t[n]);if(f)for(var n of f(t))h.call(t,n)&&y(e,n,t[n]);return e},v=(e,t)=>p(e,d(t));function b(e,t){return(0,i.isZero)(t)?[e,e]:[v(x({},e),{r:e.r-t}),v(x({},e),{r:e.r+t})]}function C(e,t){const n=b(e,t);return e.counterclockwise?[n[1],n[0]]:n}function E(e,t){return(0,i.isZero)(t)?[e,e]:[v(x({},e),{rx:e.rx-t,ry:e.ry-t}),v(x({},e),{rx:e.rx+t,ry:e.ry+t})]}function k(e,t){const n=E(e,t);return e.counterclockwise?[n[1],n[0]]:n}function w(e,t){if((0,i.isZero)(t))return[e,e];const n=(0,i.twoPointLineToGeneralFormLine)(e.from,e.cp),r=(0,i.twoPointLineToGeneralFormLine)(e.cp,e.to),o=(0,i.getParallelLinesByDistance)(n,t),l=(0,i.getParallelLinesByDistance)(r,t),c=(0,s.getPerpendicular)(e.from,n),u=(0,s.getPerpendicular)(e.to,r);return[v(x({},e),{from:(0,a.getTwoGeneralFormLinesIntersectionPoint)(c,o[0]),cp:(0,a.getTwoGeneralFormLinesIntersectionPoint)(o[0],l[0]),to:(0,a.getTwoGeneralFormLinesIntersectionPoint)(u,l[0])}),v(x({},e),{from:(0,a.getTwoGeneralFormLinesIntersectionPoint)(c,o[1]),cp:(0,a.getTwoGeneralFormLinesIntersectionPoint)(o[1],l[1]),to:(0,a.getTwoGeneralFormLinesIntersectionPoint)(u,l[1])})]}function S(e,t){if((0,i.isZero)(t))return[e,e];const n=(0,i.twoPointLineToGeneralFormLine)(e.from,e.cp1),r=(0,i.twoPointLineToGeneralFormLine)(e.cp1,e.cp2),o=(0,i.twoPointLineToGeneralFormLine)(e.cp2,e.to),l=(0,i.getParallelLinesByDistance)(n,t),c=(0,i.getParallelLinesByDistance)(r,t),u=(0,i.getParallelLinesByDistance)(o,t),p=(0,s.getPerpendicular)(e.from,n),d=(0,s.getPerpendicular)(e.to,o);return[v(x({},e),{from:(0,a.getTwoGeneralFormLinesIntersectionPoint)(p,l[0]),cp1:(0,a.getTwoGeneralFormLinesIntersectionPoint)(l[0],c[0]),cp2:(0,a.getTwoGeneralFormLinesIntersectionPoint)(c[0],u[0]),to:(0,a.getTwoGeneralFormLinesIntersectionPoint)(d,u[0])}),v(x({},e),{from:(0,a.getTwoGeneralFormLinesIntersectionPoint)(p,l[1]),cp1:(0,a.getTwoGeneralFormLinesIntersectionPoint)(l[1],c[1]),cp2:(0,a.getTwoGeneralFormLinesIntersectionPoint)(c[1],u[1]),to:(0,a.getTwoGeneralFormLinesIntersectionPoint)(d,u[1])})]}function P(e,t){const n=(0,i.getTwoPointsDistance)(e,t);return(0,i.isZero)(n-t.r)?0:n>t.r?1:-1}function R(e,t){return P(e,t)*(t.counterclockwise?-1:1)}function _(e,{rx:t,ry:n,cx:r,cy:o,angle:a}){const s=(0,l.angleToRadian)(a),c=Math.sin(s),u=Math.cos(s),p=m(u*(e.x-r)+c*(e.y-o),2)/t/t+m(-c*(e.x-r)+u*(e.y-o),2)/n/n;return(0,i.isZero)(p-1)?0:p>1?1:-1}function T(e,t){return _(e,t)*(t.counterclockwise?-1:1)}function A(e,t){const n=(0,s.getPointAndQuadraticCurveNearestPointAndDistance)(e,t,!0),r=(0,c.getQuadraticCurveTangentRadianAtPercent)(t,n.percent),o=(0,i.pointAndDirectionToGeneralFormLine)(n.point,r);return(0,i.getPointSideOfLine)(e,o)}function M(e,t){const n=(0,s.getPointAndBezierCurveNearestPointAndDistance)(e,t,!0),r=(0,c.getBezierCurveTangentRadianAtPercent)(t,n.percent),o=(0,i.pointAndDirectionToGeneralFormLine)(n.point,r);return(0,i.getPointSideOfLine)(e,o)}function L(e,t){return Array.isArray(t)?(0,i.getPointSideOfLine)(e,(0,i.twoPointLineToGeneralFormLine)(...t)):"arc"===t.type?R(e,t.curve):"ellipse arc"===t.type?T(e,t.curve):"quadratic curve"===t.type?A(e,t.curve):M(e,t.curve)}function O(e,t){const n=(0,i.minimumBy)(t.map((t=>({distance:(0,s.getPointAndGeometryLineMinimumDistance)(e,t),line:t}))),(e=>e.distance));return I(L(e,n.line))}function I(e){return e>0?1:0}function F(e,t,n){return Array.isArray(e)?(0,i.getParallelLineSegmentsByDistance)(e,t)[n]:"arc"===e.type?{type:"arc",curve:C(e.curve,t)[n]}:"ellipse arc"===e.type?{type:"ellipse arc",curve:k(e.curve,t)[n]}:"quadratic curve"===e.type?{type:e.type,curve:w(e.curve,t)[n]}:{type:e.type,curve:S(e.curve,t)[n]}}function D(e,t,n){if(n||(n=Math.min(...t.map((t=>(0,s.getPointAndGeometryLineMinimumDistance)(e,t))))),(0,i.isZero)(n))return[t];const a=(0,o.getGeometryLineStartAndEnd)(t[0]).start,c=(0,o.getGeometryLineStartAndEnd)(t[t.length-1]).end,u=(0,i.isSamePoint)(a,c)&&t.length>1,p=O(e,t),d=t.map((e=>F(e,n,p))),f=[];let g;for(let e=0;e1){const e=(0,o.getGeometryLineStartAndEnd)(t).start;return(0,i.minimumBy)(n.map((t=>({point:t,distance:(0,i.getTwoPointsDistance)(t,e)}))),(e=>e.distance)).point}return n[0]}},7270:(e,t,n)=>{"use strict";n.r(t),n.d(t,{applyImmutablePatches:()=>i});var r=n(5188),o=n(9397);function i(e,t){const n=[],i=[];return t.forEach(((t,a)=>{const s=t.value;e=(0,r.produce)(e,(r=>{const l=t.path.slice(0,t.path.length-1),c=t.path[t.path.length-1],u=(0,o.getByPath)(r,l);if(Array.isArray(u))if("add"===t.op){const e=[...l,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 c)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)}),c===u.length-1&&null==s?u.pop():u[c]=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[c]:r[c]=s}}}))})),{patches:n,reversePatches:i,result:e}}},6003:(e,t,n)=>{"use strict";n.r(t),n.d(t,{getPerpendicular:()=>l,getPerpendicularPercentToBezierCurve:()=>h,getPerpendicularPercentToQuadraticCurve:()=>f,getPerpendicularPoint:()=>u,getPerpendicularPointRadianToEllipse:()=>d,getPerpendicularPointToBezierCurve:()=>m,getPerpendicularPointToCircle:()=>p,getPerpendicularPointToQuadraticCurve:()=>g,getPerpendicularToGeometryLine:()=>c,getPointAndArcMinimumDistance:()=>R,getPointAndArcNearestPointAndDistance:()=>v,getPointAndBezierCurveNearestPointAndDistance:()=>E,getPointAndEllipseArcNearestPointAndDistance:()=>b,getPointAndGeometryLineMinimumDistance:()=>k,getPointAndGeometryLineNearestPointAndDistance:()=>x,getPointAndLineSegmentMinimumDistance:()=>w,getPointAndLineSegmentNearestPointAndDistance:()=>y,getPointAndPolygonMinimumDistance:()=>P,getPointAndQuadraticCurveNearestPointAndDistance:()=>C,getPointAndRegionMinimumDistance:()=>S});var r=n(6632),o=n(4275),i=n(9195),a=n(3516),s=Math.pow;function l(e,t){return{a:-t.b,b:t.a,c:e.x*t.b-t.a*e.y}}function c(e,t){if(Array.isArray(t))return l(e,(0,i.twoPointLineToGeneralFormLine)(...t));let n;if("arc"===t.type)n=p(e,t.curve).point;else if("ellipse arc"===t.type){const r=d(e,t.curve);void 0!==r&&(n=(0,i.getEllipsePointAtRadian)(t.curve,r))}else if("quadratic curve"===t.type){const o=f(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=h(e,t.curve)[0];void 0!==o&&(n=(0,r.getBezierCurvePointAtPercent)(t.curve.from,t.curve.cp1,t.curve.cp2,t.curve.to,o))}return n?(0,i.twoPointLineToGeneralFormLine)(e,n):void 0}function u(e,{a:t,b:n,c:r}){const o=s(t,2),i=s(n,2),a=o+i,l=-t*n;return{x:(i*e.x+l*e.y-t*r)/a,y:(l*e.x+o*e.y-n*r)/a}}function p(e,t,n=e){let r=(0,i.getTwoPointsRadian)(e,t);if(e!==n){const o=t.x-e.x,a=t.y-e.y,s={a:o,b:a,c:-a*t.y-o*t.x};Math.sign((0,i.getPointSideOfLine)(e,s))!==Math.sign((0,i.getPointSideOfLine)(n,s))&&(r+=Math.PI)}const o=(0,i.getCirclePointAtRadian)(t,r);return{point:o,distance:(0,i.getTwoPointsDistance)(e,o),radian:r}}function d(e,t,n=e,r=1e-5){const{rx:s,ry:l,cx:c,cy:u,angle:p}=t,d=(0,i.getEllipseRadian)(n,t),f=(0,a.angleToRadian)(p),g=Math.sin(f),h=Math.cos(f),m=e.x-c,y=e.y-u,x=(m*g-h*y)*l,v=l*l-s*s,b=(m*h+g*y)*s;return(0,o.newtonIterate)(d,(e=>{return t=Math.cos(e),n=Math.sin(e),x*t+v*n*t+b*n;var t,n}),(e=>{return t=Math.cos(e),n=Math.sin(e),x*-n+v*(t*t-n*n)+b*t;var t,n}),r)}function f({x:e,y:t},{from:{x:n,y:r},cp:{x:i,y:a},to:{x:s,y:l}},c=1e-5){const u=i-n,p=s-i-u,d=a-r,f=l-a-d,g=n-e,h=r-t;return(0,o.calculateEquation3)(p*p+f*f,3*(u*p+d*f),2*u*u+g*p+2*d*d+h*f,g*u+h*d,c)}function g(e,t,n=1e-5){return f(e,t,n).filter((e=>e>=0&&e<=1)).map((e=>(0,r.getQuadraticCurvePointAtPercent)(t.from,t.cp,t.to,e)))}function h({x:e,y:t},{from:{x:n,y:r},cp1:{x:i,y:a},cp2:{x:s,y:l},to:{x:c,y:u}},p=1e-5){const d=3*i-n+-3*s+c,f=3*(n-2*i+s),g=3*(i-n),h=3*a-r+-3*l+u,m=3*(r-2*a+l),y=3*(a-r),x=r-t,v=n-e;return(0,o.calculateEquation5)([3*(h*h+d*d),5*(h*m+d*f),2*(f*f+2*d*g+m*m+2*h*y),3*(f*g+m*y+h*x+d*v),g*g+y*y+2*m*x+2*f*v,y*x+g*v],p)}function m(e,t,n=1e-5){return h(e,t,n).filter((e=>e>=0&&e<=1)).map((e=>(0,r.getBezierCurvePointAtPercent)(t.from,t.cp1,t.cp2,t.to,e)))}function y(e,t,n){const r=u(e,(0,i.twoPointLineToGeneralFormLine)(t,n));return(0,i.pointIsOnLineSegment)(r,t,n)?{point:r,distance:(0,i.getTwoPointsDistance)(e,r)}:(0,i.minimumBy)([{point:t,distance:(0,i.getTwoPointsDistance)(e,t)},{point:n,distance:(0,i.getTwoPointsDistance)(e,n)}],(e=>e.distance))}function x(e,t){return Array.isArray(t)?y(e,...t):"arc"===t.type?v(e,t.curve):"ellipse arc"===t.type?b(e,t.curve):"quadratic curve"===t.type?C(e,t.curve):E(e,t.curve)}function v(e,t){const{point:n,distance:r,radian:o}=p(e,t);if((0,i.angleInRange)((0,a.radianToAngle)(o),t))return{point:n,distance:r};const s=(0,i.getArcPointAtAngle)(t,t.startAngle),l=(0,i.getArcPointAtAngle)(t,t.endAngle);return(0,i.minimumBy)([{point:s,distance:(0,i.getTwoPointsDistance)(e,s)},{point:l,distance:(0,i.getTwoPointsDistance)(e,l)}],(e=>e.distance))}function b(e,t){const n=d(e,t);if(void 0!==n&&(0,i.angleInRange)((0,a.radianToAngle)(n),t)){const r=(0,i.getEllipsePointAtRadian)(t,n);return{point:r,distance:(0,i.getTwoPointsDistance)(e,r)}}const r=(0,i.getEllipseArcPointAtAngle)(t,t.startAngle),o=(0,i.getEllipseArcPointAtAngle)(t,t.endAngle);return(0,i.minimumBy)([{point:r,distance:(0,i.getTwoPointsDistance)(e,r)},{point:o,distance:(0,i.getTwoPointsDistance)(e,o)}],(e=>e.distance))}function C(e,t,n=!1){let o=f(e,t);n||(o=o.filter((e=>e>=0&&e<=1)));const a=o.map((e=>({u:e,p:(0,r.getQuadraticCurvePointAtPercent)(t.from,t.cp,t.to,e)})));a.push({u:0,p:t.from},{u:1,p:t.to});const s=a.map((t=>({percent:t.u,point:t.p,distance:(0,i.getTwoPointsDistance)(e,t.p)})));return(0,i.minimumBy)(s,(e=>e.distance))}function E(e,t,n=!1){let o=h(e,t);n||(o=o.filter((e=>e>=0&&e<=1)));const a=o.map((e=>({u:e,p:(0,r.getBezierCurvePointAtPercent)(t.from,t.cp1,t.cp2,t.to,e)})));a.push({u:0,p:t.from},{u:1,p:t.to});const s=a.map((t=>({percent:t.u,point:t.p,distance:(0,i.getTwoPointsDistance)(e,t.p)})));return(0,i.minimumBy)(s,(e=>e.distance))}function k(e,t){return Array.isArray(t)?w(e,...t):"arc"===t.type?R(e,t.curve):"ellipse arc"===t.type?x(e,t).distance:"quadratic curve"===t.type?C(e,t.curve).distance:E(e,t.curve).distance}function w(e,t,n){const{distance:r}=y(e,t,n);return r}function S(e,t){return P(e,(0,i.getPolygonFromTwoPointsFormRegion)(t))}function P(e,t){const n=Array.from((0,i.getPolygonLine)(t));return Math.min(...n.map((t=>w(e,...t))))}function R(e,t){const{distance:n}=v(e,t);return n}},3516:(e,t,n)=>{"use strict";function r(e=0){return 180*e/Math.PI}function o(e=0){return e*Math.PI/180}n.r(t),n.d(t,{angleToRadian:()=>o,radianToAngle:()=>r})},2070:(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}}},8119:(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})},8260:(e,t,n)=>{"use strict";n.r(t),n.d(t,{getContentByClickPosition:()=>a,getContentsByClickTwoPositions:()=>s,getContentsByRegion:()=>l});var r=n(9195),o=n(9605),i=n(6003);function a(e,t,n,o,a=!1,s,l=e.map(((e,t)=>t)),c=3){for(let u=l.length-1;u>=0;u--){const p=l[u],d=e[p];if(!d)continue;if(s&&!s(d))continue;const f=o(d);if(null==f?void 0:f.getGeometries){const{lines:o,regions:s}=f.getGeometries(d,e);for(let e=0;en.x;return l(e,(0,r.getPolygonFromTwoPointsFormRegion)(s),c,!1,o,i,a)}function l(e,t,n,i,a,s,l){const c=[];return e.forEach(((u,p)=>{if(u&&(!l||l(u))&&(!s||s([p]))){const s=a(u);if(null==s?void 0:s.getGeometries){const{lines:a,bounding:l,regions:d}=s.getGeometries(u,e);if(i?a.every((e=>(0,o.geometryLineInPolygon)(e,t)))&&(!d||d.every((e=>e.points.every((e=>(0,r.pointInPolygon)(e,t)))))):l&&(0,r.pointInPolygon)(l.start,t)&&(0,r.pointInPolygon)(l.end,t))c.push([p]);else if(n){for(const e of a)if((0,o.geometryLineIntersectWithPolygon)(e,t))return void c.push([p]);if(d)for(const e of d)for(const n of e.lines)if((0,o.geometryLineIntersectWithPolygon)(n,t))return void c.push([p])}}}})),c}},7386:(e,t,n)=>{"use strict";n.r(t),n.d(t,{getAngleSnapPosition:()=>i});var r=n(9195),o=n(3516);function i(e,t,n){if(n&&e){const i=(0,o.radianToAngle)((0,r.getTwoPointsRadian)(t,e)),a=n(i);void 0!==a&&a!==i&&(t=(0,r.rotatePositionByCenter)(t,e,i-a))}return t}},5810:(e,t,n)=>{"use strict";n.r(t),n.d(t,{getBezierCurveTangentRadianAtPercent:()=>R,getCircleTangentRadianAtRadian:()=>w,getCirclesTangentTo2Circles:()=>v,getCirclesTangentTo2Lines:()=>y,getCirclesTangentToLineAndCircle:()=>x,getEllipseTangentRadianAtRadian:()=>S,getQuadraticCurveTangentRadianAtPercent:()=>P,getTangencyPointToBezierCurve:()=>k,getTangencyPointToCircle:()=>b,getTangencyPointToEllipse:()=>C,getTangencyPointToQuadraticCurve:()=>E});var r=n(4275),o=n(9195),i=n(9605),a=n(3516),s=Object.defineProperty,l=Object.defineProperties,c=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)=>l(e,c(t));function y(e,t,n,r,a){const s=[],l=(0,o.getParallelLinesByDistance)((0,o.twoPointLineToGeneralFormLine)(e,t),a),c=(0,o.getParallelLinesByDistance)((0,o.twoPointLineToGeneralFormLine)(n,r),a);for(const e of l)for(const t of c){const n=(0,i.getTwoGeneralFormLinesIntersectionPoint)(e,t);n&&s.push(n)}return s}function x(e,t,n,r){const a=[],s=(0,o.getParallelLinesByDistance)((0,o.twoPointLineToGeneralFormLine)(e,t),r),l=[n.r+r,Math.abs(n.r-r)];for(const e of s)for(const t of l)a.push(...(0,i.getGeneralFormLineCircleIntersectionPoints)(e,m(h({},n),{r:t})));return a}function v(e,t,n){const r=[],o=[e.r+n,Math.abs(e.r-n)],a=[t.r+n,Math.abs(t.r-n)];for(const n of o)for(const o of a)r.push(...(0,i.getTwoCircleIntersectionPoints)(m(h({},e),{r:n}),m(h({},t),{r:o})));return r}function b({x:e,y:t},{x:n,y:r,r:i}){const a=f(i,2),s=n-e,l=r-t,c=f(s,2)+f(l,2),u=c-a;if(u<0&&!(0,o.isZero)(u))return[];const p=n+-s*a/c,d=r+-l*a/c;if((0,o.isZero)(u))return[{x:p,y:d}];const g=i*Math.sqrt(u)/c,h=l*g,m=s*g;return[{x:p+h,y:d-m},{x:p-h,y:d+m}]}function C({x:e,y:t},{cx:n,cy:i,rx:s,ry:l,angle:c},u=1e-5){const p=(0,a.angleToRadian)(c),d=Math.sin(p),f=Math.cos(p),g=n-e,h=i-t,m=s*s,y=l*l,x=f*f*m+d*d*y,v=(-2*d*f*m+2*d*f*y)/x,b=(d*d*m+f*f*y)/x,C=-m*y/x,E=-g*g;let k,w,S,P,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,M=-h*h,L=2*d*d*g*m+-2*d*f*h*m+2*f*f*g*y+2*d*f*h*y,O=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))k=M*M+-T*M*v+T*T*b,w=2*M*L+-A*M*v+-T*L*v+2*T*A*b,S=L*L+2*M*O+-A*L*v+-T*O*v+A*A*b+T*T*C,P=2*L*O+-A*O*v+2*T*A*C,R=O*O+A*A*C,_=e=>{const t=T*e+A;return(0,o.isZero)(t,u)?(0,r.calculateEquation2)(1,v*e,b*e*e+C,u)[0]:-(M*e*e+L*e+O)/t};else{T/=E,A/=E,M/=E,L/=E,O/=E;const e=T-v,t=M-b,n=O-C;k=b*e*e+t*t+-v*e*t,w=-L*v*e+2*A*b*e+2*L*t+-A*v*t,S=-A*L*v+A*A*b+C*e*e+-v*e*n+L*L+2*t*n,P=2*A*C*e+-A*v*n+2*L*n,R=A*A*C+n*n,_=i=>{const a=e*i+A;return(0,o.isZero)(a,u)?(0,r.calculateEquation2)(1,v*i,b*i*i+C,u)[0]:-(t*i*i+L*i+n)/a}}return(0,r.calculateEquation4)(k,w,S,P,R,u).map((e=>{const t=_(e);return{x:e+n,y:t+i}}))}function E({x:e,y:t},{from:{x:n,y:o},cp:{x:i,y:a},to:{x:s,y:l}},c=1e-5){const u=i-n,p=s-i-u,d=a-o,f=l-a-d,g=n-e,h=o-t;return(0,r.calculateEquation2)(u*f-p*d,g*f-h*p,g*d-h*u,c).filter((e=>e>=0&&e<=1)).map((e=>({x:p*e*e+2*u*e+n,y:f*e*e+2*d*e+o})))}function k({x:e,y:t},{from:{x:n,y:o},cp1:{x:i,y:a},cp2:{x:s,y:l},to:{x:c,y:u}},p=1e-5){const d=3*i-n+-3*s+c,f=3*(n-2*i+s),g=3*(i-n),h=3*a-o+-3*l+u,m=3*(o-2*a+l),y=3*(a-o),x=o-t,v=n-e;return(0,r.calculateEquation4)(f*h-d*m,2*(g*h+-d*y),g*m+-f*y+-3*d*x+3*h*v,2*(m*v-f*x),y*v-g*x,p).filter((e=>e>=0&&e<=1)).map((e=>({x:d*e*e*e+f*e*e+g*e+n,y:h*e*e*e+m*e*e+y*e+o})))}function w(e,t){return t+Math.PI/2}function S(e,t){const{rx:n,ry:r,angle:o}=e,i=(0,a.angleToRadian)(o),s=Math.sin(i),l=Math.cos(i),c=Math.cos(t)*r,u=Math.sin(t)*n;return Math.atan2(c*l-s*u,-c*s-l*u)}function P({from:{x:e,y:t},cp:{x:n,y:r},to:{x:o,y:i}},a){const s=n-e,l=o-n-s,c=r-t,u=i-r-c;return Math.atan2(u*a+c,l*a+s)}function R({from:{x:e,y:t},cp1:{x:n,y:r},cp2:{x:o,y:i},to:{x:a,y:s}},l){const c=3*n-e+-3*o+a,u=3*(e-2*n+o),p=3*(n-e),d=3*r-t+-3*i+s,g=3*(t-2*r+i),h=3*(r-t);return Math.atan2(3*d*f(l,2)+2*g*l+h,3*c*f(l,2)+2*u*l+p)}},6564:(e,t,n)=>{"use strict";function r(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}}}n.r(t),n.d(t,{formatNumber:()=>a,getTextSize:()=>r,getTextSizeFromCache:()=>i});const o=new(n(5547).MapCache2);function i(e,t){return o.get(e,t,(()=>r(e,t)))}function a(e,t=100){return Math.round(e*t)/t}},5395:(e,t,n)=>{"use strict";n.r(t),n.d(t,{combineStripTriangleColors:()=>u,combineStripTriangles:()=>l,defaultMiterLimit:()=>p,getPolylineTriangles:()=>s,triangleStripToTriangles:()=>c});var r=n(9195),o=n(9605),i=n(6003),a=n(3516);function s(e,t,n="butt",s=p){const l=t/2;!0===n?e=(0,r.polygonToPolyline)(e):(0,r.isSamePoint)(e[0],e[e.length-1])&&(n=!0);const c=[],u=[];for(let t=1;tMath.PI&&(b-=2*Math.PI),!(0,r.equals)(b,0)&&!(0,r.equals)(b,Math.PI)&&!(0,r.equals)(b,-Math.PI)){let n=s;if(void 0!==d){let e=Math.abs(b);e>Math.PI/2&&(e=Math.PI-e),e0&&b{"use strict";n.r(t),n.d(t,{Nullable:()=>o});var r=n(9247);const o=e=>(0,r.or)(void 0,null,e)},9247:(e,t,n)=>{"use strict";n.r(t),n.d(t,{and:()=>S,bigint:()=>s,boolean:()=>c,exclusiveMaximum:()=>E,exclusiveMinimum:()=>C,integer:()=>l,is:()=>T,maxItems:()=>h,maxLength:()=>y,maximum:()=>b,minItems:()=>g,minLength:()=>m,minimum:()=>v,multipleOf:()=>k,never:()=>d,number:()=>a,optional:()=>f,or:()=>w,pattern:()=>x,record:()=>P,string:()=>i,symbol:()=>u,tuple:()=>R,unknown:()=>p,validate:()=>_});var r=n(3490),o=n(2233);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"},l=(e,t)=>!!Number.isInteger(e)||{path:t,expect:"integer"},c=(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||_(t,e,n),g=(e,t)=>(n,r)=>(0,o.isArray)(n)?n.length>=e?_(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?_(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?_(n,t,r):{path:r,expect:"minLength",args:[e]},y=(e,t)=>(n,r)=>"string"!=typeof n?{path:r,expect:"string"}:n.length<=e?_(n,t,r):{path:r,expect:"maxLength",args:[e]},x=(e,t)=>(n,r)=>"string"!=typeof n?{path:r,expect:"string"}:n.match(e)?_(n,t,r):{path:r,expect:"pattern",args:[e]},v=(e,t)=>(n,r)=>"number"!=typeof n||isNaN(n)?{path:r,expect:"number"}:n>=e?_(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?_(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?_(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?_(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=_(t,n);if(!0===e)return!0;r.push(e)}return{path:n,expect:"or",args:r}},S=(...e)=>Object.assign({},...e),P=(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,e,n);if(!0!==a)return a;const s=_(i,t,n);if(!0!==s)return s}return!0},R=(...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:()=>d,MapCache2:()=>f,MapCache3:()=>g,WeakmapCache:()=>i,WeakmapCache2:()=>a,WeakmapCache3:()=>s,WeakmapMap2Cache:()=>c,WeakmapMap3Cache:()=>u,WeakmapMap4Cache:()=>p,WeakmapMapCache:()=>l});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),n);class i{constructor(){o(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 a{constructor(){o(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 s{constructor(){o(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 l{constructor(){o(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 c{constructor(){o(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 u{constructor(){o(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 l=s.get(r);return void 0===l&&(l=o(),s.set(r,l)),l}clear(){this.cache=new WeakMap}}class p{constructor(){o(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 l=s.get(n);l||(l=new Map,s.set(n,l));let c=l.get(r);c||(c=new Map,l.set(r,c));let u=c.get(o);return void 0===u&&(u=i(),c.set(o,u)),u}clear(){this.cache=new WeakMap}}class d{constructor(){o(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 f{constructor(){o(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 g{constructor(){o(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}}},4029:(e,t,n)=>{"use strict";n.r(t),n.d(t,{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),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}}},8952:(e,t,n)=>{"use strict";n.d(t,{ExpressionError:()=>r});class r extends Error{constructor(e,t){super(e),this.range=t}}},1014:(e,t,n)=>{"use strict";n.d(t,{evaluateExpression:()=>o});var r=n(2845);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 l(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 c(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 l(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 c(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("|>"===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 c(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))))}},2845:(e,t,n)=>{"use strict";var r=n(1891);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(8110);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(4440);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(9394);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(1014);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 l=n(1031);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}});var c=n(8952);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}})},1891:()=>{},9394:(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:()=>l});var r=n(2845);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(l.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 c=this.getPostfixUnaryOperatorIndex(e);if(c>=0){const n=e[c-1],r=e[c],o=[n.range[0],r.range[1]],i=this.parseExpression([n,r],o);return e.splice(c-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 l)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&&c.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 l=[["**"],["*","/","%"],["+","-"],["<<",">>",">>>"],[">","<",">=","<="],["==","!=","===","!=="],["&&"],["&"],["^"],["|"],["||","??"],["|>"]],c=["+","-","!","~","await"],u=["%"],p=[".","?."],d={"{":"}","[":"]","(":")"},f=Object.keys(d);function g(e){return"EOFToken"===e.type||"PunctuatorToken"===e.type||"KeywordToken"===e.type}},1031:(e,t,n)=>{"use strict";n.d(t,{printExpression:()=>o});var r=n(2845);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)}},8110:(e,t,n)=>{"use strict";n.d(t,{tokenizeExpression:()=>o});var r=n(2845);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,"?",":",",","~"]},8266:(e,t,n)=>{"use strict";var r,o;n.d(t,{parse:()=>Mr}),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);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}var s=new i,l=new i,c=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,l;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,l),m(c,u,4,3),m(p,d,2,1),c[28]=0,u[28]=258;var S=function(e,t){var n,r,o=new a(e,t);do{switch(n=v(o),b(o,2,0)){case 0:r=w(o);break;case 1:r=k(o,s,l);break;case 2:E(o,o.ltree,o.dtree),r=k(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))},R.prototype.addX=function(e){this.addPoint(e,null)},R.prototype.addY=function(e){this.addPoint(null,e)},R.prototype.addBezier=function(e,t,n,r,o,i,a,s){var l=[e,t],c=[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*l[d]-12*c[d]+6*u[d],g=-3*l[d]+9*c[d]-9*u[d]+3*p[d],h=3*c[d]-3*l[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"},_.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 M={fail:T,argument:A,assert:A},L=2147483648,O={},I={},F={};function D(e){return function(){return e}}I.BYTE=function(e){return M.argument(e>=0&&e<=255,"Byte value should be between 0 and 255."),[e]},F.BYTE=D(1),I.CHAR=function(e){return[e.charCodeAt(0)]},F.CHAR=D(1),I.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]},F.USHORT=D(2),I.SHORT=function(e){return e>=32768&&(e=-(65536-e)),[e>>8&255,255&e]},F.SHORT=D(2),I.UINT24=function(e){return[e>>16&255,e>>8&255,255&e]},F.UINT24=D(3),I.ULONG=function(e){return[e>>24&255,e>>16&255,e>>8&255,255&e]},F.ULONG=D(4),I.LONG=function(e){return e>=L&&(e=-(2*L-e)),[e>>24&255,e>>16&255,e>>8&255,255&e]},F.LONG=D(4),I.FIXED=I.ULONG,F.FIXED=F.ULONG,I.FWORD=I.SHORT,F.FWORD=F.SHORT,I.UFWORD=I.USHORT,F.UFWORD=F.USHORT,I.LONGDATETIME=function(e){return[0,0,0,0,e>>24&255,e>>16&255,e>>8&255,255&e]},F.LONGDATETIME=D(8),I.TAG=function(e){return M.argument(4===e.length,"Tag should be exactly 4 ASCII characters."),[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]},F.TAG=D(4),I.Card8=I.BYTE,F.Card8=F.BYTE,I.Card16=I.USHORT,F.Card16=F.USHORT,I.OffSize=I.BYTE,F.OffSize=F.BYTE,I.SID=I.USHORT,F.SID=F.USHORT,I.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?I.NUMBER16(e):I.NUMBER32(e)},F.NUMBER=function(e){return I.NUMBER(e).length},I.NUMBER16=function(e){return[28,e>>8&255,255&e]},F.NUMBER16=D(3),I.NUMBER32=function(e){return[29,e>>24&255,e>>16&255,e>>8&255,255&e]},F.NUMBER32=D(5),I.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},F.UTF16=function(e){return 2*e.length};var B={"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":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸĞğİıŞş‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙˆ˜¯˘˙˚¸˝˛ˇ"};O.MACSTRING=function(e,t,n,r){var o=B[r];if(void 0!==o){for(var i="",a=0;a=-128&&e<=127}function j(e,t,n){for(var r=0,o=e.length;t>8&255,l+256&255)}return i}I.MACSTRING=function(e,t){var n=function(e){if(!z)for(var t in z={},B)z[t]=new String(t);var n=z[e];if(void 0!==n){if(U){var r=U.get(n);if(void 0!==r)return r}var o=B[e];if(void 0!==o){for(var i={},a=0;a=128&&void 0===(i=n[i]))return;r[o]=i}return r}},F.MACSTRING=function(e,t){var n=I.MACSTRING(e,t);return void 0!==n?n.length:0},I.VARDELTAS=function(e){for(var t=0,n=[];t=-128&&r<=127?W(e,t,n):G(e,t,n)}return n},I.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},F.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),l=new se.Parser(n,r+o+16+4*i),c=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 Re(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(c){for(var x,v,k,w,S,P,R,_,T,A,M,L,O=0;O1&&!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:S=d.pop()+l,(P=s[S])&&n(P);break;case 11:return;case 12:switch(I=c[O],O+=1,I){case 35:r=m+d.shift(),o=y+d.shift(),i=r+d.shift(),a=o+d.shift(),R=i+d.shift(),_=a+d.shift(),T=R+d.shift(),A=_+d.shift(),M=T+d.shift(),L=A+d.shift(),m=M+d.shift(),y=L+d.shift(),d.shift(),p.curveTo(r,o,i,a,R,_),p.curveTo(T,A,M,L,m,y);break;case 34:r=m+d.shift(),o=y,i=r+d.shift(),a=o+d.shift(),R=i+d.shift(),_=a,T=R+d.shift(),A=a,M=T+d.shift(),L=y,m=M+d.shift(),p.curveTo(r,o,i,a,R,_),p.curveTo(T,A,M,L,m,y);break;case 36:r=m+d.shift(),o=y+d.shift(),i=r+d.shift(),a=o+d.shift(),R=i+d.shift(),_=a,T=R+d.shift(),A=a,M=T+d.shift(),L=A+d.shift(),m=M+d.shift(),p.curveTo(r,o,i,a,R,_),p.curveTo(T,A,M,L,m,y);break;case 37:r=m+d.shift(),o=y+d.shift(),i=r+d.shift(),a=o+d.shift(),R=i+d.shift(),_=a+d.shift(),T=R+d.shift(),A=_+d.shift(),M=T+d.shift(),L=A+d.shift(),Math.abs(M-m)>Math.abs(L-y)?m=M+d.shift():y=L+d.shift(),p.curveTo(r,o,i,a,R,_),p.curveTo(T,A,M,L,m,y);break;default:console.log("Glyph "+t.index+": unknown operator 1200"+I),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(),O+=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:x=c[O],v=c[O+1],d.push((x<<24|v<<16)>>16),O+=2;break;case 29:S=d.pop()+e.gsubrsBias,(P=e.gsubrs[S])&&n(P);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:I<32?console.log("Glyph "+t.index+": unknown operator "+I):I<247?d.push(I-139):I<251?(x=c[O],O+=1,d.push(256*(I-247)+x+108)):I<255?(x=c[O],O+=1,d.push(256*-(I-251)-x-108)):(x=c[O],v=c[O+1],k=c[O+2],w=c[O+3],O+=4,d.push((x<<24|v<<16|k<<8|w)/65536))}}}(n),t.advanceWidth=b,p}function De(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 Be(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 c,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(c>n)throw new Error("CFF Table CID Font FDSelect format 3 range has bad GID "+c);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 xt(e,t,n){for(var r=0;r0)return e.glyphs.get(o).getMetrics()}return n}function vt(e){for(var t=0,n=0;nm||void 0===t)&&m>0&&(t=m),c 123 are reserved for internal usage");f|=1<0?$e.make(L):void 0,F=lt.make(),D=je.make(e.glyphs,{version:e.getEnglishName("version"),fullName:_,familyName:P,weightName:R,postScriptName:T,unitsPerEm:e.unitsPerEm,fontBBox:[0,v.yMin,v.ascender,v.advanceWidthMax]}),B=e.metas&&Object.keys(e.metas).length>0?ft.make(e.metas):void 0,z=[b,C,E,k,O,S,F,D,w];I&&z.push(I),e.tables.gsub&&z.push(dt.make(e.tables.gsub)),B&&z.push(B);for(var U=yt(z),N=ht(U.encode()),j=U.fields,W=!1,G=0;G>>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 St(e){wt.call(this,e,"gpos")}function Pt(e){wt.call(this,e,"gsub")}function Rt(e,t){var n=e.length;if(n!==t.length)return!1;for(var r=0;r0?(i=e.parseByte(),0==(t&o)&&(i=-i),i=n+i):i=(t&o)>0?n:n+e.parseShort(),i}function Mt(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(c>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]],l={xScale:r.xScale,scale01:r.scale01,scale10:r.scale10,yScale:r.yScale,dx:0,dy:0};s=Lt([s],l)[0],l.dx=a.x-s.x,l.dy=a.y-s.y,i=Lt(o.points,l)}t.points=t.points.concat(i)}}return Ot(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,l=0;l=s[c-1].tag,"Features must be added in alphabetical order."),i={tag:n,feature:{params:0,lookupListIndexes:[]}},s.push(i),a.push(c),i.feature}}},getLookupTables:function(e,t,n,r,o){var i=this.getFeatureTable(e,t,n,o),a=[];if(i){for(var s,l=i.lookupListIndexes,c=this.font.tables[this.tableName].lookups,u=0;u=0?n:-1;case 2:var r=kt(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=_t(this.getLookupTables(n,r,e,2,!0)[0],1,{substFormat:1,coverage:{format:1,glyphs:[]},sequences:[]});M.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},Pt.prototype.addAlternate=function(e,t,n,r){var o=_t(this.getLookupTables(n,r,e,3,!0)[0],1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});M.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},Pt.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),M.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),l={ligGlyph:t.by,components:s},c=this.binSearch(i.coverage.glyphs,a);if(c>=0){for(var u=i.ligatureSets[c],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 ln(e,t){var n,r,o=t.stack,i=o.pop(),a=o.pop(),s=t.z2[i],l=t.z1[a];exports.DEBUG&&console.log("SPVTL["+e+"]",i,a),e?(n=s.y-l.y,r=l.x-s.x):(n=l.x-s.x,r=l.y-s.y),t.pv=t.dpv=Zt(n,r)}function cn(e,t){var n,r,o=t.stack,i=o.pop(),a=o.pop(),s=t.z2[i],l=t.z1[a];exports.DEBUG&&console.log("SFVTL["+e+"]",i,a),e?(n=s.y-l.y,r=l.x-s.x):(n=l.x-s.x,r=l.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")+"]",c)}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(),l=t.z2[t.contours[s]],c=l;exports.DEBUG&&console.log(t.step,"SHC["+e+"]",s);var u=a.distance(o,o,!1,!0);do{c!==o&&i.setRelative(c,c,u,a),c=c.nextPointOnContour}while(c!==l)}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,l=t.pv,c=o.pop();switch(exports.DEBUG&&console.log(t.step,"SHZ["+e+"]",c),c){case 0:n=t.tZone;break;case 1:n=t.gZone;break;default:throw new Error("Invalid zone")}for(var u=l.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),l=t.deltaShift,c=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*l);var g=c[p];o.setRelative(g,g,f*l,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&c)-8;u>=0&&u++;var p=u*a;exports.DEBUG&&console.log(t.step,"DELTACFIX",l,"by",p),t.cvt[l]+=p}}}function kn(e,t){var n,r,o=t.stack,i=o.pop(),a=o.pop(),s=t.z2[i],l=t.z1[a];exports.DEBUG&&console.log(t.step,"SDPVTL["+e+"]",i,a),e?(n=s.y-l.y,r=l.x-s.x):(n=l.x-s.x,r=l.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&&(c=i.cvt[p],r&&Math.abs(s-c)":"_")+(r?"R":"_")+(0===o?"Gr":1===o?"Bl":2===o?"Wh":"")+"]",e?p+"("+i.cvt[p]+","+c+")":"",d,"(d =",a,"->",l*s,")"),i.rp1=i.rp0,i.rp2=d,t&&(i.rp0=d)}function Rn(e){this.char=e,this.state={},this.activeState=null}function _n(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 Mn(e){this.eventId=e,this.subscribers=[]}function Ln(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 Mn(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 On(e){this.tokens=[],this.registeredContexts={},this.contextCheckers=[],this.events={},this.registeredModifiers=[],Ln.call(this,e)}function In(e){return/[\u0600-\u065F\u066A-\u06D2\u06FA-\u06FF]/.test(e)}function Fn(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 Dn(e){return/[\u0600-\u0605\u060C-\u060E\u0610-\u061B\u061E\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED]/.test(e)}function Bn(e){return/[A-z]/.test(e)}function zn(e){this.font=e,this.features={}}function Un(e){this.id=e.id,this.tag=e.tag,this.substitution=e.substitution}function Nn(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 jn(e,t){return-1===Nn(e,t.coverage)?null:e+t.deltaGlyphId}function Wn(e,t){var n=Nn(e,t.coverage);return-1===n?null:t.substitute[n]}function Gn(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{Dt(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,l=0;l1))try{return Bt(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)}}},Bt=function(e,t){var n,r,o,i=t.ppem/t.font.unitsPerEm,a=i,s=e.components;if(tn.prototype=t,s){var l=t.font;r=[],n=[];for(var c=0;c1?"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,l=e.dpv,c=e.z2;o--;){var u=t.pop(),p=c[u];exports.DEBUG&&console.log(e.step,(e.loop>1?"loop "+(e.loop-o)+": ":"")+"IP[]",u,n,"<->",r),s.interpolate(p,i,a,l),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 l=t.pop(),c=s[l];exports.DEBUG&&console.log(e.step,(e.loop>1?"loop "+(e.loop-o)+": ":"")+"ALIGNRP[]",l),i.setRelative(c,r,0,a),i.touch(c)}e.loop=1},function(e){exports.DEBUG&&console.log(e.step,"RTDG[]"),e.round=Gt},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=qt,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=qt,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=jt},void 0,function(e){exports.DEBUG&&console.log(e.step,"RUTG[]"),e.round=$t},function(e){exports.DEBUG&&console.log(e.step,"RDTG[]"),e.round=Ht},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)},kn.bind(void 0,0),kn.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),Sn.bind(void 0,1),Sn.bind(void 0,2),Sn.bind(void 0,3),Sn.bind(void 0,4),Sn.bind(void 0,5),Sn.bind(void 0,6),Sn.bind(void 0,7),Sn.bind(void 0,8),Pn.bind(void 0,0,0,0,0,0),Pn.bind(void 0,0,0,0,0,1),Pn.bind(void 0,0,0,0,0,2),Pn.bind(void 0,0,0,0,0,3),Pn.bind(void 0,0,0,0,1,0),Pn.bind(void 0,0,0,0,1,1),Pn.bind(void 0,0,0,0,1,2),Pn.bind(void 0,0,0,0,1,3),Pn.bind(void 0,0,0,1,0,0),Pn.bind(void 0,0,0,1,0,1),Pn.bind(void 0,0,0,1,0,2),Pn.bind(void 0,0,0,1,0,3),Pn.bind(void 0,0,0,1,1,0),Pn.bind(void 0,0,0,1,1,1),Pn.bind(void 0,0,0,1,1,2),Pn.bind(void 0,0,0,1,1,3),Pn.bind(void 0,0,1,0,0,0),Pn.bind(void 0,0,1,0,0,1),Pn.bind(void 0,0,1,0,0,2),Pn.bind(void 0,0,1,0,0,3),Pn.bind(void 0,0,1,0,1,0),Pn.bind(void 0,0,1,0,1,1),Pn.bind(void 0,0,1,0,1,2),Pn.bind(void 0,0,1,0,1,3),Pn.bind(void 0,0,1,1,0,0),Pn.bind(void 0,0,1,1,0,1),Pn.bind(void 0,0,1,1,0,2),Pn.bind(void 0,0,1,1,0,3),Pn.bind(void 0,0,1,1,1,0),Pn.bind(void 0,0,1,1,1,1),Pn.bind(void 0,0,1,1,1,2),Pn.bind(void 0,0,1,1,1,3),Pn.bind(void 0,1,0,0,0,0),Pn.bind(void 0,1,0,0,0,1),Pn.bind(void 0,1,0,0,0,2),Pn.bind(void 0,1,0,0,0,3),Pn.bind(void 0,1,0,0,1,0),Pn.bind(void 0,1,0,0,1,1),Pn.bind(void 0,1,0,0,1,2),Pn.bind(void 0,1,0,0,1,3),Pn.bind(void 0,1,0,1,0,0),Pn.bind(void 0,1,0,1,0,1),Pn.bind(void 0,1,0,1,0,2),Pn.bind(void 0,1,0,1,0,3),Pn.bind(void 0,1,0,1,1,0),Pn.bind(void 0,1,0,1,1,1),Pn.bind(void 0,1,0,1,1,2),Pn.bind(void 0,1,0,1,1,3),Pn.bind(void 0,1,1,0,0,0),Pn.bind(void 0,1,1,0,0,1),Pn.bind(void 0,1,1,0,0,2),Pn.bind(void 0,1,1,0,0,3),Pn.bind(void 0,1,1,0,1,0),Pn.bind(void 0,1,1,0,1,1),Pn.bind(void 0,1,1,0,1,2),Pn.bind(void 0,1,1,0,1,3),Pn.bind(void 0,1,1,1,0,0),Pn.bind(void 0,1,1,1,0,1),Pn.bind(void 0,1,1,1,0,2),Pn.bind(void 0,1,1,1,0,3),Pn.bind(void 0,1,1,1,1,0),Pn.bind(void 0,1,1,1,1,1),Pn.bind(void 0,1,1,1,1,2),Pn.bind(void 0,1,1,1,1,3)],Rn.prototype.setState=function(e,t){return this.state[e]=t,this.activeState={key:e,value:this.state[e]},this.activeState},Rn.prototype.getState=function(e){return this.state[e]||null},On.prototype.inboundIndex=function(e){return e>=0&&e0&&e<=this.lookahead.length:return this.lookahead[e-1];default:return null}},On.prototype.rangeToText=function(e){if(e instanceof _n)return this.getRangeTokens(e).map((function(e){return e.char})).join("")},On.prototype.getText=function(){return this.tokens.map((function(e){return e.char})).join("")},On.prototype.getContext=function(e){return this.registeredContexts[e]||null},On.prototype.on=function(e,t){var n=this.events[e];return n?n.subscribe(t):null},On.prototype.dispatch=function(e,t){var n=this,r=this.events[e];r instanceof Mn&&r.subscribers.forEach((function(e){e.apply(n,t||[])}))},On.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},On.prototype.getRangeTokens=function(e){var t=e.startIndex+e.endOffset;return[].concat(this.tokens.slice(e.startIndex,t))},On.prototype.getContextRanges=function(e){var t=this.getContext(e);return t?t.ranges:{FAIL:"context checker '"+e+"' is not registered."}},On.prototype.resetContextsRanges=function(){var e=this.registeredContexts;for(var t in e)e.hasOwnProperty(t)&&(e[t].ranges=[])},On.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=Fn(r),i=Dn(r);if(!o&&!i)return!0;if(o)return!1}return!1}(a)&&(c|=1),function(e){if(Fn(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 M.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();M.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(),l=this.parseUShort();return{posFormat:t,coverage:n,valueFormat1:r,valueFormat2:o,classDef1:i,classDef2:a,class1Count:s,class2Count:l,classRecords:this.parseList(s,ie.list(l,(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 Sr=new Array(10),Pr={parse:function(e,t){var n=new ie(e,t=t||0),r=n.parseVersion(1);return M.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,Sr)}])}},Rr={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();M.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(7378);function o(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n