@skillpet/circuit 0.6.3 → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.de.md +150 -0
- package/README.es.md +150 -0
- package/README.fr.md +150 -0
- package/README.ja.md +150 -0
- package/README.ko.md +150 -0
- package/README.md +26 -1
- package/README.zh-CN.md +150 -0
- package/dist/circuit.bundle.js +3 -4
- package/dist/circuit.bundle.min.js +5 -5
- package/dist/circuit.esm.js +3 -4
- package/dist/index.cjs +3 -4
- package/package.json +1 -1
|
@@ -262,11 +262,11 @@ l0,-`+(t+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
|
262
262
|
|[ \r ]+
|
|
263
263
|
?)[ \r ]*`,Vh="[\u0300-\u036F]",Op=new RegExp(Vh+"+$"),Fp="("+Nm+"+)|"+(Np+"|")+"([!-\\[\\]-\u2027\u202A-\uD7FF\uF900-\uFFFF]"+(Vh+"*")+"|[\uD800-\uDBFF][\uDC00-\uDFFF]"+(Vh+"*")+"|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5"+("|"+Dp)+("|"+Lp+")"),bl=class{constructor(e,t){this.input=e,this.settings=t,this.tokenRegex=new RegExp(Fp,"g"),this.catcodes={"%":14,"~":13}}setCatcode(e,t){this.catcodes[e]=t}lex(){var e=this.input,t=this.tokenRegex.lastIndex;if(t===e.length)return new Nt("EOF",new _t(this,t,t));var n=this.tokenRegex.exec(e);if(n===null||n.index!==t)throw new J("Unexpected character: '"+e[t]+"'",new Nt(e[t],new _t(this,t,t+1)));var s=n[6]||n[3]||(n[2]?"\\ ":" ");if(this.catcodes[s]===14){var i=e.indexOf(`
|
|
264
264
|
`,this.tokenRegex.lastIndex);return i===-1?(this.tokenRegex.lastIndex=e.length,this.settings.reportNonstrict("commentAtEnd","% comment has no terminating newline; LaTeX would fail because of commenting the end of math mode (e.g. $)")):this.tokenRegex.lastIndex=i+1,this.lex()}return new Nt(s,new _t(this,t,this.tokenRegex.lastIndex))}},Uh=class{constructor(e,t){e===void 0&&(e={}),t===void 0&&(t={}),this.current=t,this.builtins=e,this.undefStack=[]}beginGroup(){this.undefStack.push({})}endGroup(){if(this.undefStack.length===0)throw new J("Unbalanced namespace destruction: attempt to pop global namespace; please report this as a bug");var e=this.undefStack.pop();for(var t in e)e.hasOwnProperty(t)&&(e[t]==null?delete this.current[t]:this.current[t]=e[t])}endGroups(){for(;this.undefStack.length>0;)this.endGroup()}has(e){return this.current.hasOwnProperty(e)||this.builtins.hasOwnProperty(e)}get(e){return this.current.hasOwnProperty(e)?this.current[e]:this.builtins[e]}set(e,t,n){if(n===void 0&&(n=!1),n){for(var s=0;s<this.undefStack.length;s++)delete this.undefStack[s][e];this.undefStack.length>0&&(this.undefStack[this.undefStack.length-1][e]=t)}else{var i=this.undefStack[this.undefStack.length-1];i&&!i.hasOwnProperty(e)&&(i[e]=this.current[e])}t==null?delete this.current[e]:this.current[e]=t}},$p=Em;y("\\noexpand",function(r){var e=r.popToken();return r.isExpandable(e.text)&&(e.noexpand=!0,e.treatAsRelax=!0),{tokens:[e],numArgs:0}});y("\\expandafter",function(r){var e=r.popToken();return r.expandOnce(!0),{tokens:[e],numArgs:0}});y("\\@firstoftwo",function(r){var e=r.consumeArgs(2);return{tokens:e[0],numArgs:0}});y("\\@secondoftwo",function(r){var e=r.consumeArgs(2);return{tokens:e[1],numArgs:0}});y("\\@ifnextchar",function(r){var e=r.consumeArgs(3);r.consumeSpaces();var t=r.future();return e[0].length===1&&e[0][0].text===t.text?{tokens:e[1],numArgs:0}:{tokens:e[2],numArgs:0}});y("\\@ifstar","\\@ifnextchar *{\\@firstoftwo{#1}}");y("\\TextOrMath",function(r){var e=r.consumeArgs(2);return r.mode==="text"?{tokens:e[0],numArgs:0}:{tokens:e[1],numArgs:0}});Hu={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15};y("\\char",function(r){var e=r.popToken(),t,n=0;if(e.text==="'")t=8,e=r.popToken();else if(e.text==='"')t=16,e=r.popToken();else if(e.text==="`")if(e=r.popToken(),e.text[0]==="\\")n=e.text.charCodeAt(1);else{if(e.text==="EOF")throw new J("\\char` missing argument");n=e.text.charCodeAt(0)}else t=10;if(t){if(n=Hu[e.text],n==null||n>=t)throw new J("Invalid base-"+t+" digit "+e.text);for(var s;(s=Hu[r.future().text])!=null&&s<t;)n*=t,n+=s,r.popToken()}return"\\@char{"+n+"}"});lc=(r,e,t,n)=>{var s=r.consumeArg().tokens;if(s.length!==1)throw new J("\\newcommand's first argument must be a macro name");var i=s[0].text,o=r.isDefined(i);if(o&&!e)throw new J("\\newcommand{"+i+"} attempting to redefine "+(i+"; use \\renewcommand"));if(!o&&!t)throw new J("\\renewcommand{"+i+"} when command "+i+" does not yet exist; use \\newcommand");var a=0;if(s=r.consumeArg().tokens,s.length===1&&s[0].text==="["){for(var l="",h=r.expandNextToken();h.text!=="]"&&h.text!=="EOF";)l+=h.text,h=r.expandNextToken();if(!l.match(/^\s*[0-9]+\s*$/))throw new J("Invalid number of arguments: "+l);a=parseInt(l),s=r.consumeArg().tokens}return o&&n||r.macros.set(i,{tokens:s,numArgs:a}),""};y("\\newcommand",r=>lc(r,!1,!0,!1));y("\\renewcommand",r=>lc(r,!0,!1,!1));y("\\providecommand",r=>lc(r,!0,!0,!0));y("\\message",r=>{var e=r.consumeArgs(1)[0];return console.log(e.reverse().map(t=>t.text).join("")),""});y("\\errmessage",r=>{var e=r.consumeArgs(1)[0];return console.error(e.reverse().map(t=>t.text).join("")),""});y("\\show",r=>{var e=r.popToken(),t=e.text;return console.log(e,r.macros.get(t),vn[t],Ge.math[t],Ge.text[t]),""});y("\\bgroup","{");y("\\egroup","}");y("~","\\nobreakspace");y("\\lq","`");y("\\rq","'");y("\\aa","\\r a");y("\\AA","\\r A");y("\\textcopyright","\\html@mathml{\\textcircled{c}}{\\char`\xA9}");y("\\copyright","\\TextOrMath{\\textcopyright}{\\text{\\textcopyright}}");y("\\textregistered","\\html@mathml{\\textcircled{\\scriptsize R}}{\\char`\xAE}");y("\u212C","\\mathscr{B}");y("\u2130","\\mathscr{E}");y("\u2131","\\mathscr{F}");y("\u210B","\\mathscr{H}");y("\u2110","\\mathscr{I}");y("\u2112","\\mathscr{L}");y("\u2133","\\mathscr{M}");y("\u211B","\\mathscr{R}");y("\u212D","\\mathfrak{C}");y("\u210C","\\mathfrak{H}");y("\u2128","\\mathfrak{Z}");y("\\Bbbk","\\Bbb{k}");y("\\llap","\\mathllap{\\textrm{#1}}");y("\\rlap","\\mathrlap{\\textrm{#1}}");y("\\clap","\\mathclap{\\textrm{#1}}");y("\\mathstrut","\\vphantom{(}");y("\\underbar","\\underline{\\text{#1}}");y("\\not",'\\html@mathml{\\mathrel{\\mathrlap\\@not}\\nobreak}{\\char"338}');y("\\neq","\\html@mathml{\\mathrel{\\not=}}{\\mathrel{\\char`\u2260}}");y("\\ne","\\neq");y("\u2260","\\neq");y("\\notin","\\html@mathml{\\mathrel{{\\in}\\mathllap{/\\mskip1mu}}}{\\mathrel{\\char`\u2209}}");y("\u2209","\\notin");y("\u2258","\\html@mathml{\\mathrel{=\\kern{-1em}\\raisebox{0.4em}{$\\scriptsize\\frown$}}}{\\mathrel{\\char`\u2258}}");y("\u2259","\\html@mathml{\\stackrel{\\tiny\\wedge}{=}}{\\mathrel{\\char`\u2258}}");y("\u225A","\\html@mathml{\\stackrel{\\tiny\\vee}{=}}{\\mathrel{\\char`\u225A}}");y("\u225B","\\html@mathml{\\stackrel{\\scriptsize\\star}{=}}{\\mathrel{\\char`\u225B}}");y("\u225D","\\html@mathml{\\stackrel{\\tiny\\mathrm{def}}{=}}{\\mathrel{\\char`\u225D}}");y("\u225E","\\html@mathml{\\stackrel{\\tiny\\mathrm{m}}{=}}{\\mathrel{\\char`\u225E}}");y("\u225F","\\html@mathml{\\stackrel{\\tiny?}{=}}{\\mathrel{\\char`\u225F}}");y("\u27C2","\\perp");y("\u203C","\\mathclose{!\\mkern-0.8mu!}");y("\u220C","\\notni");y("\u231C","\\ulcorner");y("\u231D","\\urcorner");y("\u231E","\\llcorner");y("\u231F","\\lrcorner");y("\xA9","\\copyright");y("\xAE","\\textregistered");y("\\ulcorner",'\\html@mathml{\\@ulcorner}{\\mathop{\\char"231c}}');y("\\urcorner",'\\html@mathml{\\@urcorner}{\\mathop{\\char"231d}}');y("\\llcorner",'\\html@mathml{\\@llcorner}{\\mathop{\\char"231e}}');y("\\lrcorner",'\\html@mathml{\\@lrcorner}{\\mathop{\\char"231f}}');y("\\vdots","{\\varvdots\\rule{0pt}{15pt}}");y("\u22EE","\\vdots");y("\\varGamma","\\mathit{\\Gamma}");y("\\varDelta","\\mathit{\\Delta}");y("\\varTheta","\\mathit{\\Theta}");y("\\varLambda","\\mathit{\\Lambda}");y("\\varXi","\\mathit{\\Xi}");y("\\varPi","\\mathit{\\Pi}");y("\\varSigma","\\mathit{\\Sigma}");y("\\varUpsilon","\\mathit{\\Upsilon}");y("\\varPhi","\\mathit{\\Phi}");y("\\varPsi","\\mathit{\\Psi}");y("\\varOmega","\\mathit{\\Omega}");y("\\substack","\\begin{subarray}{c}#1\\end{subarray}");y("\\colon","\\nobreak\\mskip2mu\\mathpunct{}\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu\\relax");y("\\boxed","\\fbox{$\\displaystyle{#1}$}");y("\\iff","\\DOTSB\\;\\Longleftrightarrow\\;");y("\\implies","\\DOTSB\\;\\Longrightarrow\\;");y("\\impliedby","\\DOTSB\\;\\Longleftarrow\\;");y("\\dddot","{\\overset{\\raisebox{-0.1ex}{\\normalsize ...}}{#1}}");y("\\ddddot","{\\overset{\\raisebox{-0.1ex}{\\normalsize ....}}{#1}}");Yu={",":"\\dotsc","\\not":"\\dotsb","+":"\\dotsb","=":"\\dotsb","<":"\\dotsb",">":"\\dotsb","-":"\\dotsb","*":"\\dotsb",":":"\\dotsb","\\DOTSB":"\\dotsb","\\coprod":"\\dotsb","\\bigvee":"\\dotsb","\\bigwedge":"\\dotsb","\\biguplus":"\\dotsb","\\bigcap":"\\dotsb","\\bigcup":"\\dotsb","\\prod":"\\dotsb","\\sum":"\\dotsb","\\bigotimes":"\\dotsb","\\bigoplus":"\\dotsb","\\bigodot":"\\dotsb","\\bigsqcup":"\\dotsb","\\And":"\\dotsb","\\longrightarrow":"\\dotsb","\\Longrightarrow":"\\dotsb","\\longleftarrow":"\\dotsb","\\Longleftarrow":"\\dotsb","\\longleftrightarrow":"\\dotsb","\\Longleftrightarrow":"\\dotsb","\\mapsto":"\\dotsb","\\longmapsto":"\\dotsb","\\hookrightarrow":"\\dotsb","\\doteq":"\\dotsb","\\mathbin":"\\dotsb","\\mathrel":"\\dotsb","\\relbar":"\\dotsb","\\Relbar":"\\dotsb","\\xrightarrow":"\\dotsb","\\xleftarrow":"\\dotsb","\\DOTSI":"\\dotsi","\\int":"\\dotsi","\\oint":"\\dotsi","\\iint":"\\dotsi","\\iiint":"\\dotsi","\\iiiint":"\\dotsi","\\idotsint":"\\dotsi","\\DOTSX":"\\dotsx"},jp=new Set(["bin","rel"]);y("\\dots",function(r){var e="\\dotso",t=r.expandAfterFuture().text;return t in Yu?e=Yu[t]:(t.slice(0,4)==="\\not"||t in Ge.math&&jp.has(Ge.math[t].group))&&(e="\\dotsb"),e});hc={")":!0,"]":!0,"\\rbrack":!0,"\\}":!0,"\\rbrace":!0,"\\rangle":!0,"\\rceil":!0,"\\rfloor":!0,"\\rgroup":!0,"\\rmoustache":!0,"\\right":!0,"\\bigr":!0,"\\biggr":!0,"\\Bigr":!0,"\\Biggr":!0,$:!0,";":!0,".":!0,",":!0};y("\\dotso",function(r){var e=r.future().text;return e in hc?"\\ldots\\,":"\\ldots"});y("\\dotsc",function(r){var e=r.future().text;return e in hc&&e!==","?"\\ldots\\,":"\\ldots"});y("\\cdots",function(r){var e=r.future().text;return e in hc?"\\@cdots\\,":"\\@cdots"});y("\\dotsb","\\cdots");y("\\dotsm","\\cdots");y("\\dotsi","\\!\\cdots");y("\\dotsx","\\ldots\\,");y("\\DOTSI","\\relax");y("\\DOTSB","\\relax");y("\\DOTSX","\\relax");y("\\tmspace","\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax");y("\\,","\\tmspace+{3mu}{.1667em}");y("\\thinspace","\\,");y("\\>","\\mskip{4mu}");y("\\:","\\tmspace+{4mu}{.2222em}");y("\\medspace","\\:");y("\\;","\\tmspace+{5mu}{.2777em}");y("\\thickspace","\\;");y("\\!","\\tmspace-{3mu}{.1667em}");y("\\negthinspace","\\!");y("\\negmedspace","\\tmspace-{4mu}{.2222em}");y("\\negthickspace","\\tmspace-{5mu}{.277em}");y("\\enspace","\\kern.5em ");y("\\enskip","\\hskip.5em\\relax");y("\\quad","\\hskip1em\\relax");y("\\qquad","\\hskip2em\\relax");y("\\tag","\\@ifstar\\tag@literal\\tag@paren");y("\\tag@paren","\\tag@literal{({#1})}");y("\\tag@literal",r=>{if(r.macros.get("\\df@tag"))throw new J("Multiple \\tag");return"\\gdef\\df@tag{\\text{#1}}"});y("\\bmod","\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}\\mathbin{\\rm mod}\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}");y("\\pod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)");y("\\pmod","\\pod{{\\rm mod}\\mkern6mu#1}");y("\\mod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}{\\rm mod}\\,\\,#1");y("\\newline","\\\\\\relax");y("\\TeX","\\textrm{\\html@mathml{T\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125emX}{TeX}}");Om=Q(Pr["Main-Regular"][84][1]-.7*Pr["Main-Regular"][65][1]);y("\\LaTeX","\\textrm{\\html@mathml{"+("L\\kern-.36em\\raisebox{"+Om+"}{\\scriptstyle A}")+"\\kern-.15em\\TeX}{LaTeX}}");y("\\KaTeX","\\textrm{\\html@mathml{"+("K\\kern-.17em\\raisebox{"+Om+"}{\\scriptstyle A}")+"\\kern-.15em\\TeX}{KaTeX}}");y("\\hspace","\\@ifstar\\@hspacer\\@hspace");y("\\@hspace","\\hskip #1\\relax");y("\\@hspacer","\\rule{0pt}{0pt}\\hskip #1\\relax");y("\\ordinarycolon",":");y("\\vcentcolon","\\mathrel{\\mathop\\ordinarycolon}");y("\\dblcolon",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-.9mu}\\vcentcolon}}{\\mathop{\\char"2237}}');y("\\coloneqq",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2254}}');y("\\Coloneqq",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2237\\char"3d}}');y("\\coloneq",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"3a\\char"2212}}');y("\\Coloneq",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"2237\\char"2212}}');y("\\eqqcolon",'\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2255}}');y("\\Eqqcolon",'\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"3d\\char"2237}}');y("\\eqcolon",'\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2239}}');y("\\Eqcolon",'\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"2212\\char"2237}}');y("\\colonapprox",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"3a\\char"2248}}');y("\\Colonapprox",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"2237\\char"2248}}');y("\\colonsim",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"3a\\char"223c}}');y("\\Colonsim",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"2237\\char"223c}}');y("\u2237","\\dblcolon");y("\u2239","\\eqcolon");y("\u2254","\\coloneqq");y("\u2255","\\eqqcolon");y("\u2A74","\\Coloneqq");y("\\ratio","\\vcentcolon");y("\\coloncolon","\\dblcolon");y("\\colonequals","\\coloneqq");y("\\coloncolonequals","\\Coloneqq");y("\\equalscolon","\\eqqcolon");y("\\equalscoloncolon","\\Eqqcolon");y("\\colonminus","\\coloneq");y("\\coloncolonminus","\\Coloneq");y("\\minuscolon","\\eqcolon");y("\\minuscoloncolon","\\Eqcolon");y("\\coloncolonapprox","\\Colonapprox");y("\\coloncolonsim","\\Colonsim");y("\\simcolon","\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\vcentcolon}");y("\\simcoloncolon","\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon}");y("\\approxcolon","\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\vcentcolon}");y("\\approxcoloncolon","\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon}");y("\\notni","\\html@mathml{\\not\\ni}{\\mathrel{\\char`\u220C}}");y("\\limsup","\\DOTSB\\operatorname*{lim\\,sup}");y("\\liminf","\\DOTSB\\operatorname*{lim\\,inf}");y("\\injlim","\\DOTSB\\operatorname*{inj\\,lim}");y("\\projlim","\\DOTSB\\operatorname*{proj\\,lim}");y("\\varlimsup","\\DOTSB\\operatorname*{\\overline{lim}}");y("\\varliminf","\\DOTSB\\operatorname*{\\underline{lim}}");y("\\varinjlim","\\DOTSB\\operatorname*{\\underrightarrow{lim}}");y("\\varprojlim","\\DOTSB\\operatorname*{\\underleftarrow{lim}}");y("\\gvertneqq","\\html@mathml{\\@gvertneqq}{\u2269}");y("\\lvertneqq","\\html@mathml{\\@lvertneqq}{\u2268}");y("\\ngeqq","\\html@mathml{\\@ngeqq}{\u2271}");y("\\ngeqslant","\\html@mathml{\\@ngeqslant}{\u2271}");y("\\nleqq","\\html@mathml{\\@nleqq}{\u2270}");y("\\nleqslant","\\html@mathml{\\@nleqslant}{\u2270}");y("\\nshortmid","\\html@mathml{\\@nshortmid}{\u2224}");y("\\nshortparallel","\\html@mathml{\\@nshortparallel}{\u2226}");y("\\nsubseteqq","\\html@mathml{\\@nsubseteqq}{\u2288}");y("\\nsupseteqq","\\html@mathml{\\@nsupseteqq}{\u2289}");y("\\varsubsetneq","\\html@mathml{\\@varsubsetneq}{\u228A}");y("\\varsubsetneqq","\\html@mathml{\\@varsubsetneqq}{\u2ACB}");y("\\varsupsetneq","\\html@mathml{\\@varsupsetneq}{\u228B}");y("\\varsupsetneqq","\\html@mathml{\\@varsupsetneqq}{\u2ACC}");y("\\imath","\\html@mathml{\\@imath}{\u0131}");y("\\jmath","\\html@mathml{\\@jmath}{\u0237}");y("\\llbracket","\\html@mathml{\\mathopen{[\\mkern-3.2mu[}}{\\mathopen{\\char`\u27E6}}");y("\\rrbracket","\\html@mathml{\\mathclose{]\\mkern-3.2mu]}}{\\mathclose{\\char`\u27E7}}");y("\u27E6","\\llbracket");y("\u27E7","\\rrbracket");y("\\lBrace","\\html@mathml{\\mathopen{\\{\\mkern-3.2mu[}}{\\mathopen{\\char`\u2983}}");y("\\rBrace","\\html@mathml{\\mathclose{]\\mkern-3.2mu\\}}}{\\mathclose{\\char`\u2984}}");y("\u2983","\\lBrace");y("\u2984","\\rBrace");y("\\minuso","\\mathbin{\\html@mathml{{\\mathrlap{\\mathchoice{\\kern{0.145em}}{\\kern{0.145em}}{\\kern{0.1015em}}{\\kern{0.0725em}}\\circ}{-}}}{\\char`\u29B5}}");y("\u29B5","\\minuso");y("\\darr","\\downarrow");y("\\dArr","\\Downarrow");y("\\Darr","\\Downarrow");y("\\lang","\\langle");y("\\rang","\\rangle");y("\\uarr","\\uparrow");y("\\uArr","\\Uparrow");y("\\Uarr","\\Uparrow");y("\\N","\\mathbb{N}");y("\\R","\\mathbb{R}");y("\\Z","\\mathbb{Z}");y("\\alef","\\aleph");y("\\alefsym","\\aleph");y("\\Alpha","\\mathrm{A}");y("\\Beta","\\mathrm{B}");y("\\bull","\\bullet");y("\\Chi","\\mathrm{X}");y("\\clubs","\\clubsuit");y("\\cnums","\\mathbb{C}");y("\\Complex","\\mathbb{C}");y("\\Dagger","\\ddagger");y("\\diamonds","\\diamondsuit");y("\\empty","\\emptyset");y("\\Epsilon","\\mathrm{E}");y("\\Eta","\\mathrm{H}");y("\\exist","\\exists");y("\\harr","\\leftrightarrow");y("\\hArr","\\Leftrightarrow");y("\\Harr","\\Leftrightarrow");y("\\hearts","\\heartsuit");y("\\image","\\Im");y("\\infin","\\infty");y("\\Iota","\\mathrm{I}");y("\\isin","\\in");y("\\Kappa","\\mathrm{K}");y("\\larr","\\leftarrow");y("\\lArr","\\Leftarrow");y("\\Larr","\\Leftarrow");y("\\lrarr","\\leftrightarrow");y("\\lrArr","\\Leftrightarrow");y("\\Lrarr","\\Leftrightarrow");y("\\Mu","\\mathrm{M}");y("\\natnums","\\mathbb{N}");y("\\Nu","\\mathrm{N}");y("\\Omicron","\\mathrm{O}");y("\\plusmn","\\pm");y("\\rarr","\\rightarrow");y("\\rArr","\\Rightarrow");y("\\Rarr","\\Rightarrow");y("\\real","\\Re");y("\\reals","\\mathbb{R}");y("\\Reals","\\mathbb{R}");y("\\Rho","\\mathrm{P}");y("\\sdot","\\cdot");y("\\sect","\\S");y("\\spades","\\spadesuit");y("\\sub","\\subset");y("\\sube","\\subseteq");y("\\supe","\\supseteq");y("\\Tau","\\mathrm{T}");y("\\thetasym","\\vartheta");y("\\weierp","\\wp");y("\\Zeta","\\mathrm{Z}");y("\\argmin","\\DOTSB\\operatorname*{arg\\,min}");y("\\argmax","\\DOTSB\\operatorname*{arg\\,max}");y("\\plim","\\DOTSB\\mathop{\\operatorname{plim}}\\limits");y("\\bra","\\mathinner{\\langle{#1}|}");y("\\ket","\\mathinner{|{#1}\\rangle}");y("\\braket","\\mathinner{\\langle{#1}\\rangle}");y("\\Bra","\\left\\langle#1\\right|");y("\\Ket","\\left|#1\\right\\rangle");Fm=r=>e=>{var t=e.consumeArg().tokens,n=e.consumeArg().tokens,s=e.consumeArg().tokens,i=e.consumeArg().tokens,o=e.macros.get("|"),a=e.macros.get("\\|");e.macros.beginGroup();var l=m=>f=>{r&&(f.macros.set("|",o),s.length&&f.macros.set("\\|",a));var g=m;if(!m&&s.length){var b=f.future();b.text==="|"&&(f.popToken(),g=!0)}return{tokens:g?s:n,numArgs:0}};e.macros.set("|",l(!1)),s.length&&e.macros.set("\\|",l(!0));var h=e.consumeArg().tokens,c=e.expandTokens([...i,...h,...t]);return e.macros.endGroup(),{tokens:c.reverse(),numArgs:0}};y("\\bra@ket",Fm(!1));y("\\bra@set",Fm(!0));y("\\Braket","\\bra@ket{\\left\\langle}{\\,\\middle\\vert\\,}{\\,\\middle\\vert\\,}{\\right\\rangle}");y("\\Set","\\bra@set{\\left\\{\\:}{\\;\\middle\\vert\\;}{\\;\\middle\\Vert\\;}{\\:\\right\\}}");y("\\set","\\bra@set{\\{\\,}{\\mid}{}{\\,\\}}");y("\\angln","{\\angl n}");y("\\blue","\\textcolor{##6495ed}{#1}");y("\\orange","\\textcolor{##ffa500}{#1}");y("\\pink","\\textcolor{##ff00af}{#1}");y("\\red","\\textcolor{##df0030}{#1}");y("\\green","\\textcolor{##28ae7b}{#1}");y("\\gray","\\textcolor{gray}{#1}");y("\\purple","\\textcolor{##9d38bd}{#1}");y("\\blueA","\\textcolor{##ccfaff}{#1}");y("\\blueB","\\textcolor{##80f6ff}{#1}");y("\\blueC","\\textcolor{##63d9ea}{#1}");y("\\blueD","\\textcolor{##11accd}{#1}");y("\\blueE","\\textcolor{##0c7f99}{#1}");y("\\tealA","\\textcolor{##94fff5}{#1}");y("\\tealB","\\textcolor{##26edd5}{#1}");y("\\tealC","\\textcolor{##01d1c1}{#1}");y("\\tealD","\\textcolor{##01a995}{#1}");y("\\tealE","\\textcolor{##208170}{#1}");y("\\greenA","\\textcolor{##b6ffb0}{#1}");y("\\greenB","\\textcolor{##8af281}{#1}");y("\\greenC","\\textcolor{##74cf70}{#1}");y("\\greenD","\\textcolor{##1fab54}{#1}");y("\\greenE","\\textcolor{##0d923f}{#1}");y("\\goldA","\\textcolor{##ffd0a9}{#1}");y("\\goldB","\\textcolor{##ffbb71}{#1}");y("\\goldC","\\textcolor{##ff9c39}{#1}");y("\\goldD","\\textcolor{##e07d10}{#1}");y("\\goldE","\\textcolor{##a75a05}{#1}");y("\\redA","\\textcolor{##fca9a9}{#1}");y("\\redB","\\textcolor{##ff8482}{#1}");y("\\redC","\\textcolor{##f9685d}{#1}");y("\\redD","\\textcolor{##e84d39}{#1}");y("\\redE","\\textcolor{##bc2612}{#1}");y("\\maroonA","\\textcolor{##ffbde0}{#1}");y("\\maroonB","\\textcolor{##ff92c6}{#1}");y("\\maroonC","\\textcolor{##ed5fa6}{#1}");y("\\maroonD","\\textcolor{##ca337c}{#1}");y("\\maroonE","\\textcolor{##9e034e}{#1}");y("\\purpleA","\\textcolor{##ddd7ff}{#1}");y("\\purpleB","\\textcolor{##c6b9fc}{#1}");y("\\purpleC","\\textcolor{##aa87ff}{#1}");y("\\purpleD","\\textcolor{##7854ab}{#1}");y("\\purpleE","\\textcolor{##543b78}{#1}");y("\\mintA","\\textcolor{##f5f9e8}{#1}");y("\\mintB","\\textcolor{##edf2df}{#1}");y("\\mintC","\\textcolor{##e0e5cc}{#1}");y("\\grayA","\\textcolor{##f6f7f7}{#1}");y("\\grayB","\\textcolor{##f0f1f2}{#1}");y("\\grayC","\\textcolor{##e3e5e6}{#1}");y("\\grayD","\\textcolor{##d6d8da}{#1}");y("\\grayE","\\textcolor{##babec2}{#1}");y("\\grayF","\\textcolor{##888d93}{#1}");y("\\grayG","\\textcolor{##626569}{#1}");y("\\grayH","\\textcolor{##3b3e40}{#1}");y("\\grayI","\\textcolor{##21242c}{#1}");y("\\kaBlue","\\textcolor{##314453}{#1}");y("\\kaGreen","\\textcolor{##71B307}{#1}");$m={"^":!0,_:!0,"\\limits":!0,"\\nolimits":!0},Jh=class{constructor(e,t,n){this.settings=t,this.expansionCount=0,this.feed(e),this.macros=new Uh($p,t.macros),this.mode=n,this.stack=[]}feed(e){this.lexer=new bl(e,this.settings)}switchMode(e){this.mode=e}beginGroup(){this.macros.beginGroup()}endGroup(){this.macros.endGroup()}endGroups(){this.macros.endGroups()}future(){return this.stack.length===0&&this.pushToken(this.lexer.lex()),this.stack[this.stack.length-1]}popToken(){return this.future(),this.stack.pop()}pushToken(e){this.stack.push(e)}pushTokens(e){this.stack.push(...e)}scanArgument(e){var t,n,s;if(e){if(this.consumeSpaces(),this.future().text!=="[")return null;t=this.popToken(),{tokens:s,end:n}=this.consumeArg(["]"])}else({tokens:s,start:t,end:n}=this.consumeArg());return this.pushToken(new Nt("EOF",n.loc)),this.pushTokens(s),new Nt("",_t.range(t,n))}consumeSpaces(){for(;;){var e=this.future();if(e.text===" ")this.stack.pop();else break}}consumeArg(e){var t=[],n=e&&e.length>0;n||this.consumeSpaces();var s=this.future(),i,o=0,a=0;do{if(i=this.popToken(),t.push(i),i.text==="{")++o;else if(i.text==="}"){if(--o,o===-1)throw new J("Extra }",i)}else if(i.text==="EOF")throw new J("Unexpected end of input in a macro argument, expected '"+(e&&n?e[a]:"}")+"'",i);if(e&&n)if((o===0||o===1&&e[a]==="{")&&i.text===e[a]){if(++a,a===e.length){t.splice(-a,a);break}}else a=0}while(o!==0||n);return s.text==="{"&&t[t.length-1].text==="}"&&(t.pop(),t.shift()),t.reverse(),{tokens:t,start:s,end:i}}consumeArgs(e,t){if(t){if(t.length!==e+1)throw new J("The length of delimiters doesn't match the number of args!");for(var n=t[0],s=0;s<n.length;s++){var i=this.popToken();if(n[s]!==i.text)throw new J("Use of the macro doesn't match its definition",i)}}for(var o=[],a=0;a<e;a++)o.push(this.consumeArg(t&&t[a+1]).tokens);return o}countExpansion(e){if(this.expansionCount+=e,this.expansionCount>this.settings.maxExpand)throw new J("Too many expansions: infinite loop or need to increase maxExpand setting")}expandOnce(e){var t=this.popToken(),n=t.text,s=t.noexpand?null:this._getExpansion(n);if(s==null||e&&s.unexpandable){if(e&&s==null&&n[0]==="\\"&&!this.isDefined(n))throw new J("Undefined control sequence: "+n);return this.pushToken(t),!1}this.countExpansion(1);var i=s.tokens,o=this.consumeArgs(s.numArgs,s.delimiters);if(s.numArgs){i=i.slice();for(var a=i.length-1;a>=0;--a){var l=i[a];if(l.text==="#"){if(a===0)throw new J("Incomplete placeholder at end of macro body",l);if(l=i[--a],l.text==="#")i.splice(a+1,1);else if(/^[1-9]$/.test(l.text))i.splice(a,2,...o[+l.text-1]);else throw new J("Not a valid argument number",l)}}}return this.pushTokens(i),i.length}expandAfterFuture(){return this.expandOnce(),this.future()}expandNextToken(){for(;;)if(this.expandOnce()===!1){var e=this.stack.pop();return e.treatAsRelax&&(e.text="\\relax"),e}}expandMacro(e){return this.macros.has(e)?this.expandTokens([new Nt(e)]):void 0}expandTokens(e){var t=[],n=this.stack.length;for(this.pushTokens(e);this.stack.length>n;)if(this.expandOnce(!0)===!1){var s=this.stack.pop();s.treatAsRelax&&(s.noexpand=!1,s.treatAsRelax=!1),t.push(s)}return this.countExpansion(t.length),t}expandMacroAsText(e){var t=this.expandMacro(e);return t&&t.map(n=>n.text).join("")}_getExpansion(e){var t=this.macros.get(e);if(t==null)return t;if(e.length===1){var n=this.lexer.catcodes[e];if(n!=null&&n!==13)return}var s=typeof t=="function"?t(this):t;if(typeof s=="string"){var i=0;if(s.includes("#"))for(var o=s.replace(/##/g,"");o.includes("#"+(i+1));)++i;for(var a=new bl(s,this.settings),l=[],h=a.lex();h.text!=="EOF";)l.push(h),h=a.lex();l.reverse();var c={tokens:l,numArgs:i};return c}return s}isDefined(e){return this.macros.has(e)||vn.hasOwnProperty(e)||Ge.math.hasOwnProperty(e)||Ge.text.hasOwnProperty(e)||$m.hasOwnProperty(e)}isExpandable(e){var t=this.macros.get(e);return t!=null?typeof t=="string"||typeof t=="function"||!t.unexpandable:vn.hasOwnProperty(e)&&!vn[e].primitive}},Xu=/^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/,ol=Object.freeze({"\u208A":"+","\u208B":"-","\u208C":"=","\u208D":"(","\u208E":")","\u2080":"0","\u2081":"1","\u2082":"2","\u2083":"3","\u2084":"4","\u2085":"5","\u2086":"6","\u2087":"7","\u2088":"8","\u2089":"9","\u2090":"a","\u2091":"e","\u2095":"h","\u1D62":"i","\u2C7C":"j","\u2096":"k","\u2097":"l","\u2098":"m","\u2099":"n","\u2092":"o","\u209A":"p","\u1D63":"r","\u209B":"s","\u209C":"t","\u1D64":"u","\u1D65":"v","\u2093":"x","\u1D66":"\u03B2","\u1D67":"\u03B3","\u1D68":"\u03C1","\u1D69":"\u03D5","\u1D6A":"\u03C7","\u207A":"+","\u207B":"-","\u207C":"=","\u207D":"(","\u207E":")","\u2070":"0","\xB9":"1","\xB2":"2","\xB3":"3","\u2074":"4","\u2075":"5","\u2076":"6","\u2077":"7","\u2078":"8","\u2079":"9","\u1D2C":"A","\u1D2E":"B","\u1D30":"D","\u1D31":"E","\u1D33":"G","\u1D34":"H","\u1D35":"I","\u1D36":"J","\u1D37":"K","\u1D38":"L","\u1D39":"M","\u1D3A":"N","\u1D3C":"O","\u1D3E":"P","\u1D3F":"R","\u1D40":"T","\u1D41":"U","\u2C7D":"V","\u1D42":"W","\u1D43":"a","\u1D47":"b","\u1D9C":"c","\u1D48":"d","\u1D49":"e","\u1DA0":"f","\u1D4D":"g",\u02B0:"h","\u2071":"i",\u02B2:"j","\u1D4F":"k",\u02E1:"l","\u1D50":"m",\u207F:"n","\u1D52":"o","\u1D56":"p",\u02B3:"r",\u02E2:"s","\u1D57":"t","\u1D58":"u","\u1D5B":"v",\u02B7:"w",\u02E3:"x",\u02B8:"y","\u1DBB":"z","\u1D5D":"\u03B2","\u1D5E":"\u03B3","\u1D5F":"\u03B4","\u1D60":"\u03D5","\u1D61":"\u03C7","\u1DBF":"\u03B8"}),Lh={"\u0301":{text:"\\'",math:"\\acute"},"\u0300":{text:"\\`",math:"\\grave"},"\u0308":{text:'\\"',math:"\\ddot"},"\u0303":{text:"\\~",math:"\\tilde"},"\u0304":{text:"\\=",math:"\\bar"},"\u0306":{text:"\\u",math:"\\breve"},"\u030C":{text:"\\v",math:"\\check"},"\u0302":{text:"\\^",math:"\\hat"},"\u0307":{text:"\\.",math:"\\dot"},"\u030A":{text:"\\r",math:"\\mathring"},"\u030B":{text:"\\H"},"\u0327":{text:"\\c"}},Gu={\u00E1:"a\u0301",\u00E0:"a\u0300",\u00E4:"a\u0308",\u01DF:"a\u0308\u0304",\u00E3:"a\u0303",\u0101:"a\u0304",\u0103:"a\u0306",\u1EAF:"a\u0306\u0301",\u1EB1:"a\u0306\u0300",\u1EB5:"a\u0306\u0303",\u01CE:"a\u030C",\u00E2:"a\u0302",\u1EA5:"a\u0302\u0301",\u1EA7:"a\u0302\u0300",\u1EAB:"a\u0302\u0303",\u0227:"a\u0307",\u01E1:"a\u0307\u0304",\u00E5:"a\u030A",\u01FB:"a\u030A\u0301",\u1E03:"b\u0307",\u0107:"c\u0301",\u1E09:"c\u0327\u0301",\u010D:"c\u030C",\u0109:"c\u0302",\u010B:"c\u0307",\u00E7:"c\u0327",\u010F:"d\u030C",\u1E0B:"d\u0307",\u1E11:"d\u0327",\u00E9:"e\u0301",\u00E8:"e\u0300",\u00EB:"e\u0308",\u1EBD:"e\u0303",\u0113:"e\u0304",\u1E17:"e\u0304\u0301",\u1E15:"e\u0304\u0300",\u0115:"e\u0306",\u1E1D:"e\u0327\u0306",\u011B:"e\u030C",\u00EA:"e\u0302",\u1EBF:"e\u0302\u0301",\u1EC1:"e\u0302\u0300",\u1EC5:"e\u0302\u0303",\u0117:"e\u0307",\u0229:"e\u0327",\u1E1F:"f\u0307",\u01F5:"g\u0301",\u1E21:"g\u0304",\u011F:"g\u0306",\u01E7:"g\u030C",\u011D:"g\u0302",\u0121:"g\u0307",\u0123:"g\u0327",\u1E27:"h\u0308",\u021F:"h\u030C",\u0125:"h\u0302",\u1E23:"h\u0307",\u1E29:"h\u0327",\u00ED:"i\u0301",\u00EC:"i\u0300",\u00EF:"i\u0308",\u1E2F:"i\u0308\u0301",\u0129:"i\u0303",\u012B:"i\u0304",\u012D:"i\u0306",\u01D0:"i\u030C",\u00EE:"i\u0302",\u01F0:"j\u030C",\u0135:"j\u0302",\u1E31:"k\u0301",\u01E9:"k\u030C",\u0137:"k\u0327",\u013A:"l\u0301",\u013E:"l\u030C",\u013C:"l\u0327",\u1E3F:"m\u0301",\u1E41:"m\u0307",\u0144:"n\u0301",\u01F9:"n\u0300",\u00F1:"n\u0303",\u0148:"n\u030C",\u1E45:"n\u0307",\u0146:"n\u0327",\u00F3:"o\u0301",\u00F2:"o\u0300",\u00F6:"o\u0308",\u022B:"o\u0308\u0304",\u00F5:"o\u0303",\u1E4D:"o\u0303\u0301",\u1E4F:"o\u0303\u0308",\u022D:"o\u0303\u0304",\u014D:"o\u0304",\u1E53:"o\u0304\u0301",\u1E51:"o\u0304\u0300",\u014F:"o\u0306",\u01D2:"o\u030C",\u00F4:"o\u0302",\u1ED1:"o\u0302\u0301",\u1ED3:"o\u0302\u0300",\u1ED7:"o\u0302\u0303",\u022F:"o\u0307",\u0231:"o\u0307\u0304",\u0151:"o\u030B",\u1E55:"p\u0301",\u1E57:"p\u0307",\u0155:"r\u0301",\u0159:"r\u030C",\u1E59:"r\u0307",\u0157:"r\u0327",\u015B:"s\u0301",\u1E65:"s\u0301\u0307",\u0161:"s\u030C",\u1E67:"s\u030C\u0307",\u015D:"s\u0302",\u1E61:"s\u0307",\u015F:"s\u0327",\u1E97:"t\u0308",\u0165:"t\u030C",\u1E6B:"t\u0307",\u0163:"t\u0327",\u00FA:"u\u0301",\u00F9:"u\u0300",\u00FC:"u\u0308",\u01D8:"u\u0308\u0301",\u01DC:"u\u0308\u0300",\u01D6:"u\u0308\u0304",\u01DA:"u\u0308\u030C",\u0169:"u\u0303",\u1E79:"u\u0303\u0301",\u016B:"u\u0304",\u1E7B:"u\u0304\u0308",\u016D:"u\u0306",\u01D4:"u\u030C",\u00FB:"u\u0302",\u016F:"u\u030A",\u0171:"u\u030B",\u1E7D:"v\u0303",\u1E83:"w\u0301",\u1E81:"w\u0300",\u1E85:"w\u0308",\u0175:"w\u0302",\u1E87:"w\u0307",\u1E98:"w\u030A",\u1E8D:"x\u0308",\u1E8B:"x\u0307",\u00FD:"y\u0301",\u1EF3:"y\u0300",\u00FF:"y\u0308",\u1EF9:"y\u0303",\u0233:"y\u0304",\u0177:"y\u0302",\u1E8F:"y\u0307",\u1E99:"y\u030A",\u017A:"z\u0301",\u017E:"z\u030C",\u1E91:"z\u0302",\u017C:"z\u0307",\u00C1:"A\u0301",\u00C0:"A\u0300",\u00C4:"A\u0308",\u01DE:"A\u0308\u0304",\u00C3:"A\u0303",\u0100:"A\u0304",\u0102:"A\u0306",\u1EAE:"A\u0306\u0301",\u1EB0:"A\u0306\u0300",\u1EB4:"A\u0306\u0303",\u01CD:"A\u030C",\u00C2:"A\u0302",\u1EA4:"A\u0302\u0301",\u1EA6:"A\u0302\u0300",\u1EAA:"A\u0302\u0303",\u0226:"A\u0307",\u01E0:"A\u0307\u0304",\u00C5:"A\u030A",\u01FA:"A\u030A\u0301",\u1E02:"B\u0307",\u0106:"C\u0301",\u1E08:"C\u0327\u0301",\u010C:"C\u030C",\u0108:"C\u0302",\u010A:"C\u0307",\u00C7:"C\u0327",\u010E:"D\u030C",\u1E0A:"D\u0307",\u1E10:"D\u0327",\u00C9:"E\u0301",\u00C8:"E\u0300",\u00CB:"E\u0308",\u1EBC:"E\u0303",\u0112:"E\u0304",\u1E16:"E\u0304\u0301",\u1E14:"E\u0304\u0300",\u0114:"E\u0306",\u1E1C:"E\u0327\u0306",\u011A:"E\u030C",\u00CA:"E\u0302",\u1EBE:"E\u0302\u0301",\u1EC0:"E\u0302\u0300",\u1EC4:"E\u0302\u0303",\u0116:"E\u0307",\u0228:"E\u0327",\u1E1E:"F\u0307",\u01F4:"G\u0301",\u1E20:"G\u0304",\u011E:"G\u0306",\u01E6:"G\u030C",\u011C:"G\u0302",\u0120:"G\u0307",\u0122:"G\u0327",\u1E26:"H\u0308",\u021E:"H\u030C",\u0124:"H\u0302",\u1E22:"H\u0307",\u1E28:"H\u0327",\u00CD:"I\u0301",\u00CC:"I\u0300",\u00CF:"I\u0308",\u1E2E:"I\u0308\u0301",\u0128:"I\u0303",\u012A:"I\u0304",\u012C:"I\u0306",\u01CF:"I\u030C",\u00CE:"I\u0302",\u0130:"I\u0307",\u0134:"J\u0302",\u1E30:"K\u0301",\u01E8:"K\u030C",\u0136:"K\u0327",\u0139:"L\u0301",\u013D:"L\u030C",\u013B:"L\u0327",\u1E3E:"M\u0301",\u1E40:"M\u0307",\u0143:"N\u0301",\u01F8:"N\u0300",\u00D1:"N\u0303",\u0147:"N\u030C",\u1E44:"N\u0307",\u0145:"N\u0327",\u00D3:"O\u0301",\u00D2:"O\u0300",\u00D6:"O\u0308",\u022A:"O\u0308\u0304",\u00D5:"O\u0303",\u1E4C:"O\u0303\u0301",\u1E4E:"O\u0303\u0308",\u022C:"O\u0303\u0304",\u014C:"O\u0304",\u1E52:"O\u0304\u0301",\u1E50:"O\u0304\u0300",\u014E:"O\u0306",\u01D1:"O\u030C",\u00D4:"O\u0302",\u1ED0:"O\u0302\u0301",\u1ED2:"O\u0302\u0300",\u1ED6:"O\u0302\u0303",\u022E:"O\u0307",\u0230:"O\u0307\u0304",\u0150:"O\u030B",\u1E54:"P\u0301",\u1E56:"P\u0307",\u0154:"R\u0301",\u0158:"R\u030C",\u1E58:"R\u0307",\u0156:"R\u0327",\u015A:"S\u0301",\u1E64:"S\u0301\u0307",\u0160:"S\u030C",\u1E66:"S\u030C\u0307",\u015C:"S\u0302",\u1E60:"S\u0307",\u015E:"S\u0327",\u0164:"T\u030C",\u1E6A:"T\u0307",\u0162:"T\u0327",\u00DA:"U\u0301",\u00D9:"U\u0300",\u00DC:"U\u0308",\u01D7:"U\u0308\u0301",\u01DB:"U\u0308\u0300",\u01D5:"U\u0308\u0304",\u01D9:"U\u0308\u030C",\u0168:"U\u0303",\u1E78:"U\u0303\u0301",\u016A:"U\u0304",\u1E7A:"U\u0304\u0308",\u016C:"U\u0306",\u01D3:"U\u030C",\u00DB:"U\u0302",\u016E:"U\u030A",\u0170:"U\u030B",\u1E7C:"V\u0303",\u1E82:"W\u0301",\u1E80:"W\u0300",\u1E84:"W\u0308",\u0174:"W\u0302",\u1E86:"W\u0307",\u1E8C:"X\u0308",\u1E8A:"X\u0307",\u00DD:"Y\u0301",\u1EF2:"Y\u0300",\u0178:"Y\u0308",\u1EF8:"Y\u0303",\u0232:"Y\u0304",\u0176:"Y\u0302",\u1E8E:"Y\u0307",\u0179:"Z\u0301",\u017D:"Z\u030C",\u1E90:"Z\u0302",\u017B:"Z\u0307",\u03AC:"\u03B1\u0301",\u1F70:"\u03B1\u0300",\u1FB1:"\u03B1\u0304",\u1FB0:"\u03B1\u0306",\u03AD:"\u03B5\u0301",\u1F72:"\u03B5\u0300",\u03AE:"\u03B7\u0301",\u1F74:"\u03B7\u0300",\u03AF:"\u03B9\u0301",\u1F76:"\u03B9\u0300",\u03CA:"\u03B9\u0308",\u0390:"\u03B9\u0308\u0301",\u1FD2:"\u03B9\u0308\u0300",\u1FD1:"\u03B9\u0304",\u1FD0:"\u03B9\u0306",\u03CC:"\u03BF\u0301",\u1F78:"\u03BF\u0300",\u03CD:"\u03C5\u0301",\u1F7A:"\u03C5\u0300",\u03CB:"\u03C5\u0308",\u03B0:"\u03C5\u0308\u0301",\u1FE2:"\u03C5\u0308\u0300",\u1FE1:"\u03C5\u0304",\u1FE0:"\u03C5\u0306",\u03CE:"\u03C9\u0301",\u1F7C:"\u03C9\u0300",\u038E:"\u03A5\u0301",\u1FEA:"\u03A5\u0300",\u03AB:"\u03A5\u0308",\u1FE9:"\u03A5\u0304",\u1FE8:"\u03A5\u0306",\u038F:"\u03A9\u0301",\u1FFA:"\u03A9\u0300"},wl=class r{constructor(e,t){this.mode="math",this.gullet=new Jh(e,t,this.mode),this.settings=t,this.leftrightDepth=0,this.nextToken=null}expect(e,t){if(t===void 0&&(t=!0),this.fetch().text!==e)throw new J("Expected '"+e+"', got '"+this.fetch().text+"'",this.fetch());t&&this.consume()}consume(){this.nextToken=null}fetch(){return this.nextToken==null&&(this.nextToken=this.gullet.expandNextToken()),this.nextToken}switchMode(e){this.mode=e,this.gullet.switchMode(e)}parse(){this.settings.globalGroup||this.gullet.beginGroup(),this.settings.colorIsTextColor&&this.gullet.macros.set("\\color","\\textcolor");try{var e=this.parseExpression(!1);return this.expect("EOF"),this.settings.globalGroup||this.gullet.endGroup(),e}finally{this.gullet.endGroups()}}subparse(e){var t=this.nextToken;this.consume(),this.gullet.pushToken(new Nt("}")),this.gullet.pushTokens(e);var n=this.parseExpression(!1);return this.expect("}"),this.nextToken=t,n}parseExpression(e,t){for(var n=[];;){this.mode==="math"&&this.consumeSpaces();var s=this.fetch();if(r.endOfExpression.has(s.text)||t&&s.text===t||e&&vn[s.text]&&vn[s.text].infix)break;var i=this.parseAtom(t);if(i){if(i.type==="internal")continue}else break;n.push(i)}return this.mode==="text"&&this.formLigatures(n),this.handleInfixNodes(n)}handleInfixNodes(e){for(var t=-1,n,s=0;s<e.length;s++){var i=e[s];if(i.type==="infix"){if(t!==-1)throw new J("only one infix operator per group",i.token);t=s,n=i.replaceWith}}if(t!==-1&&n){var o,a,l=e.slice(0,t),h=e.slice(t+1);l.length===1&&l[0].type==="ordgroup"?o=l[0]:o={type:"ordgroup",mode:this.mode,body:l},h.length===1&&h[0].type==="ordgroup"?a=h[0]:a={type:"ordgroup",mode:this.mode,body:h};var c;return n==="\\\\abovefrac"?c=this.callFunction(n,[o,e[t],a],[]):c=this.callFunction(n,[o,a],[]),[c]}else return e}handleSupSubscript(e){var t=this.fetch(),n=t.text;this.consume(),this.consumeSpaces();var s;do{var i;s=this.parseGroup(e)}while(((i=s)==null?void 0:i.type)==="internal");if(!s)throw new J("Expected group after '"+n+"'",t);return s}formatUnsupportedCmd(e){for(var t=[],n=0;n<e.length;n++)t.push({type:"textord",mode:"text",text:e[n]});var s={type:"text",mode:this.mode,body:t},i={type:"color",mode:this.mode,color:this.settings.errorColor,body:[s]};return i}parseAtom(e){var t=this.parseGroup("atom",e);if(t?.type==="internal"||this.mode==="text")return t;for(var n,s;;){this.consumeSpaces();var i=this.fetch();if(i.text==="\\limits"||i.text==="\\nolimits"){if(t&&t.type==="op"){var o=i.text==="\\limits";t.limits=o,t.alwaysHandleSupSub=!0}else if(t&&t.type==="operatorname")t.alwaysHandleSupSub&&(t.limits=i.text==="\\limits");else throw new J("Limit controls must follow a math operator",i);this.consume()}else if(i.text==="^"){if(n)throw new J("Double superscript",i);n=this.handleSupSubscript("superscript")}else if(i.text==="_"){if(s)throw new J("Double subscript",i);s=this.handleSupSubscript("subscript")}else if(i.text==="'"){if(n)throw new J("Double superscript",i);var a={type:"textord",mode:this.mode,text:"\\prime"},l=[a];for(this.consume();this.fetch().text==="'";)l.push(a),this.consume();this.fetch().text==="^"&&l.push(this.handleSupSubscript("superscript")),n={type:"ordgroup",mode:this.mode,body:l}}else if(ol[i.text]){var h=Xu.test(i.text),c=[];for(c.push(new Nt(ol[i.text])),this.consume();;){var m=this.fetch().text;if(!ol[m]||Xu.test(m)!==h)break;c.unshift(new Nt(ol[m])),this.consume()}var f=this.subparse(c);h?s={type:"ordgroup",mode:"math",body:f}:n={type:"ordgroup",mode:"math",body:f}}else break}return n||s?{type:"supsub",mode:this.mode,base:t,sup:n,sub:s}:t}parseFunction(e,t){var n=this.fetch(),s=n.text,i=vn[s];if(!i)return null;if(this.consume(),t&&t!=="atom"&&!i.allowedInArgument)throw new J("Got function '"+s+"' with no arguments"+(t?" as "+t:""),n);if(this.mode==="text"&&!i.allowedInText)throw new J("Can't use function '"+s+"' in text mode",n);if(this.mode==="math"&&i.allowedInMath===!1)throw new J("Can't use function '"+s+"' in math mode",n);var{args:o,optArgs:a}=this.parseArguments(s,i);return this.callFunction(s,o,a,n,e)}callFunction(e,t,n,s,i){var o={funcName:e,parser:this,token:s,breakOnTokenText:i},a=vn[e];if(a&&a.handler)return a.handler(o,t,n);throw new J("No function handler for "+e)}parseArguments(e,t){var n=t.numArgs+t.numOptionalArgs;if(n===0)return{args:[],optArgs:[]};for(var s=[],i=[],o=0;o<n;o++){var a=t.argTypes&&t.argTypes[o],l=o<t.numOptionalArgs;("primitive"in t&&t.primitive&&a==null||t.type==="sqrt"&&o===1&&i[0]==null)&&(a="primitive");var h=this.parseGroupOfType("argument to '"+e+"'",a,l);if(l)i.push(h);else if(h!=null)s.push(h);else throw new J("Null argument, please report this as a bug")}return{args:s,optArgs:i}}parseGroupOfType(e,t,n){switch(t){case"color":return this.parseColorGroup(n);case"size":return this.parseSizeGroup(n);case"url":return this.parseUrlGroup(n);case"math":case"text":return this.parseArgumentGroup(n,t);case"hbox":{var s=this.parseArgumentGroup(n,"text");return s!=null?{type:"styling",mode:s.mode,body:[s],style:"text"}:null}case"raw":{var i=this.parseStringGroup("raw",n);return i!=null?{type:"raw",mode:"text",string:i.text}:null}case"primitive":{if(n)throw new J("A primitive argument cannot be optional");var o=this.parseGroup(e);if(o==null)throw new J("Expected group as "+e,this.fetch());return o}case"original":case null:case void 0:return this.parseArgumentGroup(n);default:throw new J("Unknown group type as "+e,this.fetch())}}consumeSpaces(){for(;this.fetch().text===" ";)this.consume()}parseStringGroup(e,t){var n=this.gullet.scanArgument(t);if(n==null)return null;for(var s="",i;(i=this.fetch()).text!=="EOF";)s+=i.text,this.consume();return this.consume(),n.text=s,n}parseRegexGroup(e,t){for(var n=this.fetch(),s=n,i="",o;(o=this.fetch()).text!=="EOF"&&e.test(i+o.text);)s=o,i+=s.text,this.consume();if(i==="")throw new J("Invalid "+t+": '"+n.text+"'",n);return n.range(s,i)}parseColorGroup(e){var t=this.parseStringGroup("color",e);if(t==null)return null;var n=/^(#[a-f0-9]{3,4}|#[a-f0-9]{6}|#[a-f0-9]{8}|[a-f0-9]{6}|[a-z]+)$/i.exec(t.text);if(!n)throw new J("Invalid color: '"+t.text+"'",t);var s=n[0];return/^[0-9a-f]{6}$/i.test(s)&&(s="#"+s),{type:"color-token",mode:this.mode,color:s}}parseSizeGroup(e){var t,n=!1;if(this.gullet.consumeSpaces(),!e&&this.gullet.future().text!=="{"?t=this.parseRegexGroup(/^[-+]? *(?:$|\d+|\d+\.\d*|\.\d*) *[a-z]{0,2} *$/,"size"):t=this.parseStringGroup("size",e),!t)return null;!e&&t.text.length===0&&(t.text="0pt",n=!0);var s=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(t.text);if(!s)throw new J("Invalid size: '"+t.text+"'",t);var i={number:+(s[1]+s[2]),unit:s[3]};if(!Vu(i))throw new J("Invalid unit: '"+i.unit+"'",t);return{type:"size",mode:this.mode,value:i,isBlank:n}}parseUrlGroup(e){this.gullet.lexer.setCatcode("%",13),this.gullet.lexer.setCatcode("~",12);var t=this.parseStringGroup("url",e);if(this.gullet.lexer.setCatcode("%",14),this.gullet.lexer.setCatcode("~",13),t==null)return null;var n=t.text.replace(/\\([#$%&~_^{}])/g,"$1");return{type:"url",mode:this.mode,url:n}}parseArgumentGroup(e,t){var n=this.gullet.scanArgument(e);if(n==null)return null;var s=this.mode;t&&this.switchMode(t),this.gullet.beginGroup();var i=this.parseExpression(!1,"EOF");this.expect("EOF"),this.gullet.endGroup();var o={type:"ordgroup",mode:this.mode,loc:n.loc,body:i};return t&&this.switchMode(s),o}parseGroup(e,t){var n=this.fetch(),s=n.text,i;if(s==="{"||s==="\\begingroup"){this.consume();var o=s==="{"?"}":"\\endgroup";this.gullet.beginGroup();var a=this.parseExpression(!1,o),l=this.fetch();this.expect(o),this.gullet.endGroup(),i={type:"ordgroup",mode:this.mode,loc:_t.range(n,l),body:a,semisimple:s==="\\begingroup"||void 0}}else if(i=this.parseFunction(t,e)||this.parseSymbol(),i==null&&s[0]==="\\"&&!$m.hasOwnProperty(s)){if(this.settings.throwOnError)throw new J("Undefined control sequence: "+s,n);i=this.formatUnsupportedCmd(s),this.consume()}return i}formLigatures(e){for(var t=e.length-1,n=0;n<t;++n){var s=e[n];if(s.type==="textord"){var i=s.text,o=e[n+1];if(!(!o||o.type!=="textord")){if(i==="-"&&o.text==="-"){var a=e[n+2];n+1<t&&a&&a.type==="textord"&&a.text==="-"?(e.splice(n,3,{type:"textord",mode:"text",loc:_t.range(s,a),text:"---"}),t-=2):(e.splice(n,2,{type:"textord",mode:"text",loc:_t.range(s,o),text:"--"}),t-=1)}(i==="'"||i==="`")&&o.text===i&&(e.splice(n,2,{type:"textord",mode:"text",loc:_t.range(s,o),text:i+i}),t-=1)}}}}parseSymbol(){var e=this.fetch(),t=e.text;if(/^\\verb[^a-zA-Z]/.test(t)){this.consume();var n=t.slice(5),s=n.charAt(0)==="*";if(s&&(n=n.slice(1)),n.length<2||n.charAt(0)!==n.slice(-1))throw new J(`\\verb assertion failed --
|
|
265
|
-
please report what input caused this bug`);return n=n.slice(1,-1),{type:"verb",mode:"text",body:n,star:s}}Gu.hasOwnProperty(t[0])&&!Ge[this.mode][t[0]]&&(this.settings.strict&&this.mode==="math"&&this.settings.reportNonstrict("unicodeTextInMathMode",'Accented Unicode text character "'+t[0]+'" used in math mode',e),t=Gu[t[0]]+t.slice(1));var i=Op.exec(t);i&&(t=t.substring(0,i.index),t==="i"?t="\u0131":t==="j"&&(t="\u0237"));var o;if(Ge[this.mode][t]){this.settings.strict&&this.mode==="math"&&Fh.includes(t)&&this.settings.reportNonstrict("unicodeTextInMathMode",'Latin-1/Unicode text character "'+t[0]+'" used in math mode',e);var a=Ge[this.mode][t].group,l=_t.range(e),h;if(Fd.hasOwnProperty(a)){var c=a;h={type:"atom",mode:this.mode,family:c,loc:l,text:t}}else h={type:a,mode:this.mode,loc:l,text:t};o=h}else if(t.charCodeAt(0)>=128)this.settings.strict&&(Wu(t.charCodeAt(0))?this.mode==="math"&&this.settings.reportNonstrict("unicodeTextInMathMode",'Unicode text character "'+t[0]+'" used in math mode',e):this.settings.reportNonstrict("unknownSymbol",'Unrecognized Unicode character "'+t[0]+'"'+(" ("+t.charCodeAt(0)+")"),e)),o={type:"textord",mode:"text",loc:_t.range(e),text:t};else return null;if(this.consume(),i)for(var m=0;m<i[0].length;m++){var f=i[0][m];if(!Lh[f])throw new J("Unknown accent ' "+f+"'",e);var g=Lh[f][this.mode]||Lh[f].text;if(!g)throw new J("Accent "+f+" unsupported in "+this.mode+" mode",e);o={type:"accent",mode:this.mode,loc:_t.range(e),label:g,isStretchy:!1,isShifty:!0,base:o}}return o}};wl.endOfExpression=new Set(["}","\\endgroup","\\end","\\right","&"]);cc=function(e,t){if(!(typeof e=="string"||e instanceof String))throw new TypeError("KaTeX can only parse string typed expression");var n=new wl(e,t);delete n.gullet.macros.current["\\df@tag"];var s=n.parse();if(delete n.gullet.macros.current["\\current@color"],delete n.gullet.macros.current["\\color"],n.gullet.macros.get("\\df@tag")){if(!t.displayMode)throw new J("\\tag works only in display equations");s=[{type:"tag",mode:"text",body:s,tag:n.subparse([new Nt("\\df@tag")])}]}return s},uc=function(e,t,n){t.textContent="";var s=Al(e,n).toNode();t.appendChild(s)};typeof document<"u"&&document.compatMode!=="CSS1Compat"&&(typeof console<"u"&&console.warn("Warning: KaTeX doesn't work in quirks mode. Make sure your website has a suitable doctype."),uc=function(){throw new J("KaTeX doesn't work in quirks mode.")});jm=function(e,t){var n=Al(e,t).toMarkup();return n},qm=function(e,t){var n=new pa(t);return cc(e,n)},Hm=function(e,t,n){if(n.throwOnError||!(e instanceof J))throw e;var s=V(["katex-error"],[new Pt(t)]);return s.setAttribute("title",e.toString()),s.setAttribute("style","color:"+n.errorColor),s},Al=function(e,t){var n=new pa(t);try{var s=cc(e,n);return tp(s,e,n)}catch(i){return Hm(i,e,n)}},Ym=function(e,t){var n=new pa(t);try{var s=cc(e,n);return rp(s,e,n)}catch(i){return Hm(i,e,n)}},Xm="0.16.44",Gm={Span:kn,Anchor:y0,SymbolNode:Pt,SvgNode:ar,PathNode:Tr,LineNode:ga},qp={version:Xm,render:uc,renderToString:jm,ParseError:J,SETTINGS_SCHEMA:hl,__parse:qm,__renderToDomTree:Al,__renderToHTMLTree:Ym,__setFontMetrics:Zu,__defineSymbol:u,__defineFunction:ie,__defineMacro:y,__domTree:Gm}});var L2={};$a(L2,{Adc:()=>Ls,Amp:()=>un,AnalogBiasedFet:()=>j0,AnalogNFet:()=>F0,AnalogPFet:()=>$0,And:()=>Bt,Annotate:()=>zo,Antenna:()=>Qi,AntennaLoop:()=>eo,AntennaLoop2:()=>to,Arc2:()=>Mo,Arc3:()=>fn,ArcLoop:()=>To,ArcN:()=>Po,ArcZ:()=>Eo,Arrow:()=>dn,Arrowhead:()=>xo,AudioJack:()=>po,BUILTIN_THEMES:()=>yr,Battery:()=>Ni,BatteryCell:()=>Di,BatteryDouble:()=>Oi,BitField:()=>s0,Bjt:()=>qr,Bjt2:()=>Hr,BjtNpn:()=>Ht,BjtNpn2:()=>Ss,BjtPnp:()=>rr,BjtPnp2:()=>ln,BjtPnp2c:()=>W0,BjtPnp2c2:()=>ei,Breaker:()=>as,Buf:()=>Jt,BusConnect:()=>gi,BusLine:()=>bi,Button:()=>oo,CPE:()=>ls,CSS_VARS:()=>Ks,Capacitor:()=>Cr,Capacitor2:()=>Cn,CapacitorTrim:()=>Ln,CapacitorVar:()=>In,Circle:()=>ui,Circulator:()=>Os,Coax:()=>fo,CoaxConnect:()=>ki,Connect:()=>pr,ConnectorTerminal:()=>Ei,Container:()=>P0,Crystal:()=>Un,CurrentLabel:()=>h0,CurrentLabelInline:()=>gn,CurrentMirror:()=>Fr,CurrentTransactor:()=>Oo,DA15:()=>vi,DB25:()=>xi,DB9:()=>wi,DC37:()=>yi,DD50:()=>Si,DE9:()=>a0,DFlipFlop:()=>ri,Dac:()=>Ds,Data:()=>Ms,DataBusLine:()=>wo,Decision:()=>Es,Demod:()=>Ns,Diac:()=>on,Diode:()=>et,DiodeShockley:()=>$n,DiodeTVS:()=>Fn,DiodeTunnel:()=>On,Dot:()=>pn,DotDotDot:()=>vo,DrawTree:()=>l0,Drawing:()=>lr,DspBox:()=>sr,DspCircle:()=>Yt,DspSpeaker:()=>_s,DualVacuumTube:()=>Ko,ELEMENT_GETATTR_ANCHOR_NAMES:()=>gc,ELEMENT_REGISTRY:()=>Js,Element:()=>N,Element2Term:()=>se,ElementCompound:()=>ir,ElementDrawing:()=>Ol,ElementImage:()=>js,ElementTwoport:()=>vr,Ellipse:()=>zs,Encircle:()=>sh,EncircleBox:()=>ih,Filter:()=>Is,FlowBox:()=>cn,Fuse:()=>rs,FuseIEC:()=>Dr,FuseIEEE:()=>dr,FuseUS:()=>os,GAP:()=>H,Gap:()=>Xt,Ground:()=>Ti,GroundChassis:()=>Zi,GroundSignal:()=>Ki,Header:()=>pi,Hemt:()=>G0,Ic:()=>nr,Ic555:()=>ii,IcDIP:()=>ai,IcPin:()=>Kl,IgbtN:()=>Z0,IgbtP:()=>Q0,ImageFormat:()=>ja,Inductor:()=>Ir,Inductor2:()=>Lr,Isolator:()=>Fs,JFet:()=>vs,JFet2:()=>ys,JFetN:()=>q0,JFetN2:()=>Y0,JFetP:()=>H0,JFetP2:()=>X0,JKFlipFlop:()=>ni,Jack:()=>zi,Josephson:()=>is,Jumper:()=>fi,Kmap:()=>A0,LED:()=>qn,LED2:()=>Hn,Label:()=>So,Lamp:()=>Xi,Lamp2:()=>Gi,Line:()=>Pe,LogicTree:()=>gr,LoopArrow:()=>c0,LoopCurrent:()=>nh,Memristor:()=>ns,Memristor2:()=>ss,MeterA:()=>qi,MeterAnalog:()=>Vi,MeterArrow:()=>Yi,MeterBox:()=>mn,MeterDigital:()=>Ji,MeterI:()=>ji,MeterOhm:()=>Hi,MeterV:()=>$i,Mic:()=>uo,Mixer:()=>As,Motor:()=>mo,Multiplexer:()=>ti,NAMED_COLORS:()=>fh,NFet:()=>gs,NFet2:()=>ws,NMos:()=>ms,NMos2:()=>ps,Neon:()=>Wi,NixieTube:()=>Zo,NoConnect:()=>so,Norator:()=>Or,Not:()=>Kt,NotNot:()=>C0,NpnPhoto:()=>J0,NpnSchottky:()=>V0,Nullator:()=>Nr,Nullor:()=>$o,Opamp:()=>cs,Optocoupler:()=>_o,Or:()=>$t,OrthoLines:()=>di,Oscillator:()=>Cs,OscillatorBox:()=>Bs,Oscilloscope:()=>Ui,OutletA:()=>u0,OutletB:()=>qo,OutletC:()=>m0,OutletD:()=>Ho,OutletE:()=>Yo,OutletF:()=>Xo,OutletG:()=>Go,OutletH:()=>d0,OutletI:()=>Wo,OutletJ:()=>Vo,OutletK:()=>Uo,OutletL:()=>Jo,PFet:()=>bs,PFet2:()=>xs,PMos:()=>ds,PMos2:()=>fs,Pentode:()=>ra,Photodiode:()=>Yn,Photoresistor:()=>ts,PhotoresistorBox:()=>Qt,PhotoresistorIEC:()=>Qt,PhotoresistorIEEE:()=>ur,Plug:()=>Mi,PnpPhoto:()=>K0,PnpSchottky:()=>U0,Point:()=>A,PotBox:()=>er,Potentiometer:()=>es,PotentiometerIEC:()=>er,PotentiometerIEEE:()=>mr,Process:()=>hi,RBox:()=>mt,RBoxVar:()=>Zt,Rect:()=>xr,Rectifier:()=>Bo,Relay:()=>Io,Resistor:()=>Zn,ResistorIEC:()=>mt,ResistorIEEE:()=>dt,ResistorVar:()=>Qn,ResistorVarIEC:()=>Zt,ResistorVarIEEE:()=>cr,RightLines:()=>Hs,RoundBox:()=>Yr,RoundProcess:()=>li,Rshunt:()=>Kn,SCR:()=>Xn,STYLE_IEC:()=>Xl,STYLE_IEEE:()=>an,SchemdrawController:()=>La,Schmitt:()=>L0,SchmittAnd:()=>o0,SchmittNand:()=>Yl,SchmittNot:()=>D0,Schottky:()=>Dn,Segment:()=>p,SegmentArc:()=>xe,SegmentBezier:()=>Ut,SegmentCircle:()=>D,SegmentImage:()=>Br,SegmentPath:()=>ut,SegmentPoly:()=>U,SegmentText:()=>W,SevenSegment:()=>oi,Solar:()=>Fi,Source:()=>rt,SourceControlled:()=>Ys,SourceControlledI:()=>wr,SourceControlledV:()=>br,SourceI:()=>Ai,SourcePulse:()=>Bi,SourceRamp:()=>Ii,SourceSin:()=>_i,SourceSquare:()=>Li,SourceTriangle:()=>Ci,SourceV:()=>Ri,SparkGap:()=>hs,Speaker:()=>co,Start:()=>ci,State:()=>mi,StateEnd:()=>Ps,Subroutine:()=>ks,Sum:()=>Ts,SumSigma:()=>Rs,SvgBackendConfig:()=>Aa,SvgFigure:()=>g0,Switch:()=>Xr,SwitchDIP:()=>ho,SwitchDpdt:()=>Ws,SwitchDpst:()=>Gs,SwitchReed:()=>ao,SwitchRotary:()=>lo,SwitchSpdt:()=>io,SwitchSpdt2:()=>Xs,Table:()=>B0,Tag:()=>ko,Terminal:()=>hn,Tetrode:()=>ta,Tgate:()=>I0,Thermistor:()=>Jn,TimingDiagram:()=>n0,TransadmittanceTransactor:()=>Fo,Transform:()=>p0,Transformer:()=>bo,TransimpedanceTransactor:()=>No,Triac:()=>Gn,Triax:()=>go,Triode:()=>ea,Tristate:()=>Bn,TubeDiode:()=>Qo,TwoPort:()=>Lo,VERSION:()=>au,VGA:()=>$s,VMCMPair:()=>jo,VacuumTube:()=>Gr,Varactor:()=>jn,Vdd:()=>no,VoltageLabelArc:()=>Ro,VoltageMirror:()=>$r,VoltageRegulator:()=>si,VoltageTransactor:()=>Do,Vss:()=>ro,Wheatstone:()=>Co,Wire:()=>yo,ZLabel:()=>Ao,Zener:()=>Nn,alignLabelForPlace:()=>pc,angle:()=>ia,bbox:()=>He,buchheim:()=>Ra,buildLabelSpecsFromParams:()=>Ll,colorHex:()=>gh,colorHsl:()=>xh,colorHsla:()=>vh,colorRgb:()=>bh,colorRgba:()=>wh,config:()=>kt,cycloid:()=>Vn,dasharray:()=>yh,debug:()=>A1,delta:()=>qa,dist:()=>Qs,ensureKatex:()=>Zm,estimateMathSize:()=>ya,flip:()=>du,getAnchors:()=>O1,getAvailableTypes:()=>N1,getGlobalStyle:()=>f0,getParam:()=>T,getRegisteredTypes:()=>eu,hasMath:()=>va,isKatexAvailable:()=>Bl,linspace:()=>ze,logicparse:()=>Ql,mergeParams:()=>oa,mergeParamsFirstWins:()=>Mr,mirrorx:()=>mu,mountFromJson:()=>H1,nand:()=>Tn,nor:()=>Rn,placeElementLabels:()=>Il,point:()=>uu,renderFromJson:()=>hh,renderMathHtml:()=>Cl,resetConfigForTests:()=>fu,resetElementStyleForTests:()=>Wl,resheight:()=>F,resolveLabelRotateDeg:()=>dc,resolvePosition:()=>Ia,resolvePositionX:()=>ah,resolvePositionY:()=>lh,resolveTheme:()=>Zs,reswidth:()=>Ye,rotate:()=>Wr,setBoxAnchors16:()=>fr,setElementStyle:()=>Gl,sevensegdigit:()=>Cc,subsystems:()=>Zc,svgconfig:()=>B1,swapLabelLocForTheta:()=>mc,swapPause:()=>la,textSize:()=>b0,theme:()=>_1,use:()=>R1,validateCircuitJson:()=>j1,validateColor:()=>Vr,validateLinestyle:()=>Wa,withDrawing:()=>h1,xnor:()=>_n,xor:()=>An});var au="0.5.0";function He(r,e,t,n){return{xmin:r,ymin:e,xmax:t,ymax:n}}var ja=(c=>(c.EPS="eps",c.JPG="jpg",c.PDF="pdf",c.PGF="pgf",c.PNG="png",c.PS="ps",c.RAW="raw",c.RGBA="rgba",c.SVG="svg",c.TIF="tif",c))(ja||{});function ze(r,e,t=50){if(t<2)return[r];let n=(e-r)/(t-1);return Array.from({length:t},(s,i)=>r+n*i)}function dh(r,e,t,n,s){let i=Math.cos(t*Math.PI/180),o=Math.sin(t*Math.PI/180),a=r-n,l=e-s,h=a*i-l*o,c=a*o+l*i;return[h+n,c+s]}function Sr(r,e,t){return[-(r-t)+t,e]}function kr(r,e){return[r,-e]}function lu(r,e,t,n){return[t-r,n-e]}function hu(r,e,t,n){return Math.atan2(n-e,t-r)*180/Math.PI}function cu(r,e,t,n){return Math.hypot(t-r,n-e)}function Dt(r){return r instanceof A?r:{x:r[0],y:r[1]}}var A=class r{constructor(e,t){z(this,"x");z(this,"y");this.x=e,this.y=t}static fromXY(e){return new r(e[0],e[1])}add(e){let t=Dt(e);return new r(this.x+t.x,this.y+t.y)}sub(e){let t=Dt(e);return new r(this.x-t.x,this.y-t.y)}subFromScalar(e){return new r(e-this.x,e-this.y)}mul(e){return typeof e=="number"?new r(this.x*e,this.y*e):new r(this.x*e.x,this.y*e.y)}div(e){return typeof e=="number"?new r(this.x/e,this.y/e):new r(this.x/e.x,this.y/e.y)}neg(){return new r(-this.x,-this.y)}rotate(e,t=[0,0]){let n=Dt(t),[s,i]=dh(this.x,this.y,e,n.x,n.y);return new r(s,i)}mirrorx(e=0){let[t,n]=Sr(this.x,this.y,e);return new r(t,n)}flip(){let[e,t]=kr(this.x,this.y);return new r(e,t)}toTuple(){return[this.x,this.y]}};function uu(r,e){return new A(r,e)}function Wr(r,e,t=[0,0]){let n=Dt(r),s=Dt(t),[i,o]=dh(n.x,n.y,e,s.x,s.y);return new A(i,o)}function mu(r,e=0){let t=Dt(r),[n,s]=Sr(t.x,t.y,e);return new A(n,s)}function du(r){let e=Dt(r),[t,n]=kr(e.x,e.y);return new A(t,n)}function qa(r,e){let t=Dt(r),n=Dt(e),[s,i]=lu(t.x,t.y,n.x,n.y);return new A(s,i)}function ia(r,e){let t=Dt(r),n=Dt(e);return hu(t.x,t.y,n.x,n.y)}function Qs(r,e){let t=Dt(r),n=Dt(e);return cu(t.x,t.y,n.x,n.y)}function Ha(r){return r instanceof A?r:A.fromXY([r[0],r[1]])}function sd(r){return typeof r=="number"?new A(r,r):Ha(r)}var p0=class{constructor(e,t,n=[0,0],s=[1,1]){z(this,"theta");z(this,"shift");z(this,"localshift");z(this,"zoom");this.theta=e,this.shift=Ha(t),this.localshift=Ha(n),this.zoom=sd(s)}transform(e){return Ha(e).add(this.localshift).mul(this.zoom).rotate(this.theta).add(this.shift)}transformArray(e){return e.map(t=>this.transform(t))}};var pu={unit:3,inches_per_unit:.5,lblofst:.1,fontsize:14,font:"sans-serif",color:"black",lw:2,ls:"-",fill:null,margin:.1},Ya={...pu};function kt(r){Ya={...Ya,...r}}function f0(){return Ya}function fu(){Ya={...pu}}function oa(...r){let e={};for(let t of r)if(t)for(let[n,s]of Object.entries(t))s!==void 0&&(e[n]=s);return e}function Mr(...r){let e={};for(let t of r)if(t)for(let[n,s]of Object.entries(t))s!==void 0&&!(n in e)&&(e[n]=s);return e}function T(r,e,t){let n=r[e];return n!==void 0?n:t}var aa=new Map,ph=!1;function la(r){let e=ph;return ph=r,e}function id(){return[...aa.entries()]}function Xa(r){aa.set(r,null)}function Ga(r){aa.delete(r)}function At(r){if(ph||aa.size===0)return;let e=id().at(-1);if(!e)return;let[t,n]=e;n!==null&&!t.containsElement(n)&&t.add(n),aa.set(t,r)}var fh=["black","silver","gray","white","maroon","red","purple","fuchsia","green","lime","olive","yellow","navy","blue","teal","aqua","aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"],od=new Set(fh);function gh(r){return/^#[A-Fa-f\d]{3}(?:[A-Fa-f\d]{3}|(?:[A-Fa-f\d]{5})?)$/i.test(r)}function bh(r){return/^rgb(\s*)\((\s*)(?:\d*\.?\d*%?)(\s*),(\s*)(?:\d*\.?\d*%?)(\s*),(\s*)(?:\d*\.?\d*%?)(\s*)\)$/i.test(r)}function wh(r){return/^rgba(\s*)\((\s*)(?:\d*\.?\d*%?)(\s*),(\s*)(?:\d*\.?\d*%?)(\s*),(\s*)(?:\d*\.?\d*%?)(\s*),(\s*)(?:\d*\.?\d*%?)(\s*)\)$/i.test(r)}function xh(r){return/^hsl(\s*)\((\s*)(?:-?\d*\.?\d*)(\s*),(\s*)(?:-?\d*\.?\d*%)(\s*),(\s*)(?:-?\d*\.?\d*%)(\s*)\)$/i.test(r)}function vh(r){return/^hsla(\s*)\((\s*)(?:-?\d*\.?\d*)(\s*),(\s*)(?:-?\d*\.?\d*%)(\s*),(\s*)(?:-?\d*\.?\d*%)(\s*),(\s*)(?:-?\d*\.?\d*%?)(\s*)\)$/i.test(r)}function yh(r){return/^(\d+\.?\d*)(,\s*\d+\.?\d*)*$/i.test(r)}function Vr(r){if(r==null||r===!0||r===!1)return;if(Array.isArray(r)){let t=r;if(t.length!==3||typeof t[0]!="number"||typeof t[1]!="number"||typeof t[2]!="number")throw new Error(`Invalid color tuple ${String(r)}`);return}if(typeof r!="string")throw new Error(`Invalid color ${String(r)}`);let e=r;if(!(od.has(e)||e==="bg"||gh(e)||bh(e)||wh(e)||xh(e)||vh(e)||e.startsWith("url(")))throw new Error(`Invalid color name ${e}`)}function Wa(r){if(![null,""," ","-","--",":","-.","dashed","dotted","dashdot"].includes(r)&&!yh(r))throw new Error(`Invalid line style ${r}`)}function Va(r){return r instanceof A?r:{x:r[0],y:r[1]}}function gu(r,e){let t=r.length;if(t<3||e<=0)return r.map(s=>{let i=Va(s);return new A(i.x,i.y)});let n=[];for(let s=t-1;s>=0;s--){let i=Va(r[s]),o=Va(r[(s-1+t)%t]),a=Va(r[(s-2+t)%t]),l=o.x-i.x,h=o.y-i.y,c=o.x-a.x,m=o.y-a.y,f=(Math.atan2(h,l)-Math.atan2(m,c))/2,g=Math.abs(Math.tan(f)),b=e/g,v=(te,ke)=>Math.hypot(te,ke),x=(te,ke,he,ve,de)=>{let Fe=ke/he;return[te.x-ve*Fe,te.y-de*Fe]},S=v(l,h),k=v(c,m),M=Math.min(S,k);b>M&&(b=M,e=M*g);let _=x(o,b,S,l,h),B=x(o,b,k,c,m),$=o.x*2-_[0]-B[0],Y=o.y*2-_[1]-B[1],Z=v($,Y),L=v(b,e),I=x(o,L,Z,$,Y),X=Math.atan2(_[1]-I[1],_[0]-I[0]),j=Math.atan2(B[1]-I[1],B[0]-I[0]);for(;j<X;)j+=2*Math.PI;let re=ze(X,j,100);for(let te of re)n.push(new A(I[0]+Math.cos(te)*e,I[1]+Math.sin(te)*e))}return n.length>0&&n.push(n[0]),n}function ae(r){return r.toFixed(3).replace(/\.?0+$/,"")||"0"}function wn(r){let e="",{color:t,ls:n,lw:s,capstyle:i,joinstyle:o,fill:a,hatch:l}=r;if(t!==void 0&&(Array.isArray(t)?e+=`stroke:rgb(${Math.round(t[0]*255)},${Math.round(t[1]*255)},${Math.round(t[2]*255)});`:t&&(e+=`stroke:${t};`)),l?e+="fill:url(#hatch);":a===!1?e+="fill:none;":a!=null&&(e+=`fill:${String(a).toLowerCase()};`),s!==void 0&&s>0&&(e+=`stroke-width:${s};`),n){let h={"--":"7.4,3.2",dashed:"7.4,3.2",":":"2,3.3",dotted:"2,3.3","-.":"12.8,3.2,2,3.2",dashdot:"12.8,3.2,2,3.2"};n in h&&(e+=`stroke-dasharray:${h[n]};`)}return i&&(e+=`stroke-linecap:${i==="projecting"?"square":i};`),o&&(e+=`stroke-linejoin:${o};`),e}var Ur={};for(let r of"lij|' ")Ur[r]=37;for(let r of"![]fI.,:;/\\t")Ur[r]=50;for(let r of'`-(){}r"')Ur[r]=60;for(let r of"*^zcsJkvxy\u03BC\xB0")Ur[r]=85;for(let r of"aebdhnopqug#$L+<>=?_~FZT\u03B10123456789")Ur[r]=95;for(let r of"BSPEAKVXY&UwNRCHD")Ur[r]=112;for(let r of"QGOMm%@\u03A9")Ur[r]=140;for(let r of"W\u2220")Ur[r]=155;var Mt={};for(let r of"lij:.,;t")Mt[r]=47;for(let r of"|")Mt[r]=37;for(let r of"![]fI/\\")Mt[r]=55;for(let r of"`-(){}r")Mt[r]=60;for(let r of"sJ\xB0")Mt[r]=68;for(let r of'"zcae?1')Mt[r]=74;for(let r of"*^kvxy\u03BCbdhnopqug#$_\u03B10123456789")Mt[r]=85;for(let r of"#$+<>=~FSP")Mt[r]=95;for(let r of"ELZT")Mt[r]=105;for(let r of"BRC")Mt[r]=112;for(let r of"DAwHUKVXYNQGO")Mt[r]=122;for(let r of"&m\u03A9")Mt[r]=130;for(let r of"%")Mt[r]=140;for(let r of"MW@\u2220")Mt[r]=155;function bu(r){if(!r)return!1;let e=r.toLowerCase();return e.includes("times")||e.includes("serif")&&!e.includes("sans")}function ld(r,e,t){let n=bu(t)?Mt:Ur,s=bu(t)?60:75,i=0;for(let o of r)i+=n[o]??s;return i*72/1e3*(e/12)}function b0(r,e,t){if(r==="")return{width:0,height:0};let n=r.split(`
|
|
266
|
-
`),s=0;for(let i of n)s=Math.max(s,ld(i,e,t));return{width:s,height:n.length*e}}function it(r){return r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}var Ua=class Ua{constructor(e,t={}){z(this,"bbox");z(this,"scale");z(this,"pxwidth");z(this,"pxheight");z(this,"elements",[]);z(this,"backgroundColor");z(this,"showbbox");z(this,"extraDefs");z(this,"svgDefs",[]);z(this,"clips",new Map);z(this,"_groupStack",[]);z(this,"_hasGroups",!1);let n=t.inchesPerUnit??.5,s=(t.margin??.1)+2/72;this.scale=72*n,this.showbbox=t.showbbox??!1,this.bbox={xmin:e.xmin-s,ymin:e.ymin-s,xmax:e.xmax+s,ymax:e.ymax+s};let i=this.bbox.xmax-this.bbox.xmin,o=this.bbox.ymax-this.bbox.ymin;this.pxwidth=Math.max(5,i*this.scale),this.pxheight=Math.max(5,o*this.scale),this.extraDefs=t.extraDefs??""}setBbox(e){let t=.1+2/72;this.bbox={xmin:e.xmin-t,ymin:e.ymin-t,xmax:e.xmax+t,ymax:e.ymax+t};let n=this.bbox.xmax-this.bbox.xmin,s=this.bbox.ymax-this.bbox.ymin;this.pxwidth=Math.max(5,n*this.scale),this.pxheight=Math.max(5,s*this.scale)}xform(e,t){return[e*this.scale,-t*this.scale]}bgcolor(e){this.backgroundColor=e}hatchpattern(e="hatch",t="black",n=.5){let s=`<pattern id="${e}" patternUnits="userSpaceOnUse" width="4" height="4"><path d="M-1,1 l2,-2 M0,4 l4,-4 M3,5 l2,-2" style="stroke:${t}; stroke-width:${n}" /></pattern>`;return this.svgDefs.push(s),e}addclip(e,t){let n=`<clipPath id="${e}"><path d="${t}" /></clipPath>`;this.svgDefs.push(n)}addclipBbox(e){let t=`${e.xmin},${e.ymin},${e.xmax},${e.ymax}`,n;if(this.clips.has(t))n=this.clips.get(t);else{n=Ua.totalClips++,this.clips.set(t,n);let[s,i]=this.xform(e.xmin,e.ymin),[o,a]=this.xform(e.xmax,e.ymax),l=Math.min(s,o)-1,h=Math.min(i,a)-1,c=Math.abs(o-s)+2,m=Math.abs(a-i)+2;this.svgDefs.push(`<clipPath id="clip${n}"><rect x="${
|
|
267
|
-
`).length;a-=(
|
|
268
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="${
|
|
265
|
+
please report what input caused this bug`);return n=n.slice(1,-1),{type:"verb",mode:"text",body:n,star:s}}Gu.hasOwnProperty(t[0])&&!Ge[this.mode][t[0]]&&(this.settings.strict&&this.mode==="math"&&this.settings.reportNonstrict("unicodeTextInMathMode",'Accented Unicode text character "'+t[0]+'" used in math mode',e),t=Gu[t[0]]+t.slice(1));var i=Op.exec(t);i&&(t=t.substring(0,i.index),t==="i"?t="\u0131":t==="j"&&(t="\u0237"));var o;if(Ge[this.mode][t]){this.settings.strict&&this.mode==="math"&&Fh.includes(t)&&this.settings.reportNonstrict("unicodeTextInMathMode",'Latin-1/Unicode text character "'+t[0]+'" used in math mode',e);var a=Ge[this.mode][t].group,l=_t.range(e),h;if(Fd.hasOwnProperty(a)){var c=a;h={type:"atom",mode:this.mode,family:c,loc:l,text:t}}else h={type:a,mode:this.mode,loc:l,text:t};o=h}else if(t.charCodeAt(0)>=128)this.settings.strict&&(Wu(t.charCodeAt(0))?this.mode==="math"&&this.settings.reportNonstrict("unicodeTextInMathMode",'Unicode text character "'+t[0]+'" used in math mode',e):this.settings.reportNonstrict("unknownSymbol",'Unrecognized Unicode character "'+t[0]+'"'+(" ("+t.charCodeAt(0)+")"),e)),o={type:"textord",mode:"text",loc:_t.range(e),text:t};else return null;if(this.consume(),i)for(var m=0;m<i[0].length;m++){var f=i[0][m];if(!Lh[f])throw new J("Unknown accent ' "+f+"'",e);var g=Lh[f][this.mode]||Lh[f].text;if(!g)throw new J("Accent "+f+" unsupported in "+this.mode+" mode",e);o={type:"accent",mode:this.mode,loc:_t.range(e),label:g,isStretchy:!1,isShifty:!0,base:o}}return o}};wl.endOfExpression=new Set(["}","\\endgroup","\\end","\\right","&"]);cc=function(e,t){if(!(typeof e=="string"||e instanceof String))throw new TypeError("KaTeX can only parse string typed expression");var n=new wl(e,t);delete n.gullet.macros.current["\\df@tag"];var s=n.parse();if(delete n.gullet.macros.current["\\current@color"],delete n.gullet.macros.current["\\color"],n.gullet.macros.get("\\df@tag")){if(!t.displayMode)throw new J("\\tag works only in display equations");s=[{type:"tag",mode:"text",body:s,tag:n.subparse([new Nt("\\df@tag")])}]}return s},uc=function(e,t,n){t.textContent="";var s=Al(e,n).toNode();t.appendChild(s)};typeof document<"u"&&document.compatMode!=="CSS1Compat"&&(typeof console<"u"&&console.warn("Warning: KaTeX doesn't work in quirks mode. Make sure your website has a suitable doctype."),uc=function(){throw new J("KaTeX doesn't work in quirks mode.")});jm=function(e,t){var n=Al(e,t).toMarkup();return n},qm=function(e,t){var n=new pa(t);return cc(e,n)},Hm=function(e,t,n){if(n.throwOnError||!(e instanceof J))throw e;var s=V(["katex-error"],[new Pt(t)]);return s.setAttribute("title",e.toString()),s.setAttribute("style","color:"+n.errorColor),s},Al=function(e,t){var n=new pa(t);try{var s=cc(e,n);return tp(s,e,n)}catch(i){return Hm(i,e,n)}},Ym=function(e,t){var n=new pa(t);try{var s=cc(e,n);return rp(s,e,n)}catch(i){return Hm(i,e,n)}},Xm="0.16.44",Gm={Span:kn,Anchor:y0,SymbolNode:Pt,SvgNode:ar,PathNode:Tr,LineNode:ga},qp={version:Xm,render:uc,renderToString:jm,ParseError:J,SETTINGS_SCHEMA:hl,__parse:qm,__renderToDomTree:Al,__renderToHTMLTree:Ym,__setFontMetrics:Zu,__defineSymbol:u,__defineFunction:ie,__defineMacro:y,__domTree:Gm}});var L2={};$a(L2,{Adc:()=>Ls,Amp:()=>un,AnalogBiasedFet:()=>j0,AnalogNFet:()=>F0,AnalogPFet:()=>$0,And:()=>Bt,Annotate:()=>zo,Antenna:()=>Qi,AntennaLoop:()=>eo,AntennaLoop2:()=>to,Arc2:()=>Mo,Arc3:()=>fn,ArcLoop:()=>To,ArcN:()=>Po,ArcZ:()=>Eo,Arrow:()=>dn,Arrowhead:()=>xo,AudioJack:()=>po,BUILTIN_THEMES:()=>yr,Battery:()=>Ni,BatteryCell:()=>Di,BatteryDouble:()=>Oi,BitField:()=>s0,Bjt:()=>qr,Bjt2:()=>Hr,BjtNpn:()=>Ht,BjtNpn2:()=>Ss,BjtPnp:()=>rr,BjtPnp2:()=>ln,BjtPnp2c:()=>W0,BjtPnp2c2:()=>ei,Breaker:()=>as,Buf:()=>Jt,BusConnect:()=>gi,BusLine:()=>bi,Button:()=>oo,CPE:()=>ls,CSS_VARS:()=>Ks,Capacitor:()=>Cr,Capacitor2:()=>Cn,CapacitorTrim:()=>Ln,CapacitorVar:()=>In,Circle:()=>ui,Circulator:()=>Os,Coax:()=>fo,CoaxConnect:()=>ki,Connect:()=>pr,ConnectorTerminal:()=>Ei,Container:()=>P0,Crystal:()=>Un,CurrentLabel:()=>h0,CurrentLabelInline:()=>gn,CurrentMirror:()=>Fr,CurrentTransactor:()=>Oo,DA15:()=>vi,DB25:()=>xi,DB9:()=>wi,DC37:()=>yi,DD50:()=>Si,DE9:()=>a0,DFlipFlop:()=>ri,Dac:()=>Ds,Data:()=>Ms,DataBusLine:()=>wo,Decision:()=>Es,Demod:()=>Ns,Diac:()=>on,Diode:()=>et,DiodeShockley:()=>$n,DiodeTVS:()=>Fn,DiodeTunnel:()=>On,Dot:()=>pn,DotDotDot:()=>vo,DrawTree:()=>l0,Drawing:()=>lr,DspBox:()=>sr,DspCircle:()=>Yt,DspSpeaker:()=>_s,DualVacuumTube:()=>Ko,ELEMENT_GETATTR_ANCHOR_NAMES:()=>gc,ELEMENT_REGISTRY:()=>Js,Element:()=>N,Element2Term:()=>se,ElementCompound:()=>ir,ElementDrawing:()=>Ol,ElementImage:()=>js,ElementTwoport:()=>vr,Ellipse:()=>zs,Encircle:()=>sh,EncircleBox:()=>ih,Filter:()=>Is,FlowBox:()=>cn,Fuse:()=>rs,FuseIEC:()=>Dr,FuseIEEE:()=>dr,FuseUS:()=>os,GAP:()=>H,Gap:()=>Xt,Ground:()=>Ti,GroundChassis:()=>Zi,GroundSignal:()=>Ki,Header:()=>pi,Hemt:()=>G0,Ic:()=>nr,Ic555:()=>ii,IcDIP:()=>ai,IcPin:()=>Kl,IgbtN:()=>Z0,IgbtP:()=>Q0,ImageFormat:()=>ja,Inductor:()=>Ir,Inductor2:()=>Lr,Isolator:()=>Fs,JFet:()=>vs,JFet2:()=>ys,JFetN:()=>q0,JFetN2:()=>Y0,JFetP:()=>H0,JFetP2:()=>X0,JKFlipFlop:()=>ni,Jack:()=>zi,Josephson:()=>is,Jumper:()=>fi,Kmap:()=>A0,LED:()=>qn,LED2:()=>Hn,Label:()=>So,Lamp:()=>Xi,Lamp2:()=>Gi,Line:()=>Pe,LogicTree:()=>gr,LoopArrow:()=>c0,LoopCurrent:()=>nh,Memristor:()=>ns,Memristor2:()=>ss,MeterA:()=>qi,MeterAnalog:()=>Vi,MeterArrow:()=>Yi,MeterBox:()=>mn,MeterDigital:()=>Ji,MeterI:()=>ji,MeterOhm:()=>Hi,MeterV:()=>$i,Mic:()=>uo,Mixer:()=>As,Motor:()=>mo,Multiplexer:()=>ti,NAMED_COLORS:()=>fh,NFet:()=>gs,NFet2:()=>ws,NMos:()=>ms,NMos2:()=>ps,Neon:()=>Wi,NixieTube:()=>Zo,NoConnect:()=>so,Norator:()=>Or,Not:()=>Kt,NotNot:()=>C0,NpnPhoto:()=>J0,NpnSchottky:()=>V0,Nullator:()=>Nr,Nullor:()=>$o,Opamp:()=>cs,Optocoupler:()=>_o,Or:()=>$t,OrthoLines:()=>di,Oscillator:()=>Cs,OscillatorBox:()=>Bs,Oscilloscope:()=>Ui,OutletA:()=>u0,OutletB:()=>qo,OutletC:()=>m0,OutletD:()=>Ho,OutletE:()=>Yo,OutletF:()=>Xo,OutletG:()=>Go,OutletH:()=>d0,OutletI:()=>Wo,OutletJ:()=>Vo,OutletK:()=>Uo,OutletL:()=>Jo,PFet:()=>bs,PFet2:()=>xs,PMos:()=>ds,PMos2:()=>fs,Pentode:()=>ra,Photodiode:()=>Yn,Photoresistor:()=>ts,PhotoresistorBox:()=>Qt,PhotoresistorIEC:()=>Qt,PhotoresistorIEEE:()=>ur,Plug:()=>Mi,PnpPhoto:()=>K0,PnpSchottky:()=>U0,Point:()=>A,PotBox:()=>er,Potentiometer:()=>es,PotentiometerIEC:()=>er,PotentiometerIEEE:()=>mr,Process:()=>hi,RBox:()=>mt,RBoxVar:()=>Zt,Rect:()=>xr,Rectifier:()=>Bo,Relay:()=>Io,Resistor:()=>Zn,ResistorIEC:()=>mt,ResistorIEEE:()=>dt,ResistorVar:()=>Qn,ResistorVarIEC:()=>Zt,ResistorVarIEEE:()=>cr,RightLines:()=>Hs,RoundBox:()=>Yr,RoundProcess:()=>li,Rshunt:()=>Kn,SCR:()=>Xn,STYLE_IEC:()=>Xl,STYLE_IEEE:()=>an,SchemdrawController:()=>La,Schmitt:()=>L0,SchmittAnd:()=>o0,SchmittNand:()=>Yl,SchmittNot:()=>D0,Schottky:()=>Dn,Segment:()=>p,SegmentArc:()=>xe,SegmentBezier:()=>Ut,SegmentCircle:()=>D,SegmentImage:()=>Br,SegmentPath:()=>ut,SegmentPoly:()=>U,SegmentText:()=>W,SevenSegment:()=>oi,Solar:()=>Fi,Source:()=>rt,SourceControlled:()=>Ys,SourceControlledI:()=>wr,SourceControlledV:()=>br,SourceI:()=>Ai,SourcePulse:()=>Bi,SourceRamp:()=>Ii,SourceSin:()=>_i,SourceSquare:()=>Li,SourceTriangle:()=>Ci,SourceV:()=>Ri,SparkGap:()=>hs,Speaker:()=>co,Start:()=>ci,State:()=>mi,StateEnd:()=>Ps,Subroutine:()=>ks,Sum:()=>Ts,SumSigma:()=>Rs,SvgBackendConfig:()=>Aa,SvgFigure:()=>g0,Switch:()=>Xr,SwitchDIP:()=>ho,SwitchDpdt:()=>Ws,SwitchDpst:()=>Gs,SwitchReed:()=>ao,SwitchRotary:()=>lo,SwitchSpdt:()=>io,SwitchSpdt2:()=>Xs,Table:()=>B0,Tag:()=>ko,Terminal:()=>hn,Tetrode:()=>ta,Tgate:()=>I0,Thermistor:()=>Jn,TimingDiagram:()=>n0,TransadmittanceTransactor:()=>Fo,Transform:()=>p0,Transformer:()=>bo,TransimpedanceTransactor:()=>No,Triac:()=>Gn,Triax:()=>go,Triode:()=>ea,Tristate:()=>Bn,TubeDiode:()=>Qo,TwoPort:()=>Lo,VERSION:()=>au,VGA:()=>$s,VMCMPair:()=>jo,VacuumTube:()=>Gr,Varactor:()=>jn,Vdd:()=>no,VoltageLabelArc:()=>Ro,VoltageMirror:()=>$r,VoltageRegulator:()=>si,VoltageTransactor:()=>Do,Vss:()=>ro,Wheatstone:()=>Co,Wire:()=>yo,ZLabel:()=>Ao,Zener:()=>Nn,alignLabelForPlace:()=>pc,angle:()=>ia,bbox:()=>He,buchheim:()=>Ra,buildLabelSpecsFromParams:()=>Ll,colorHex:()=>gh,colorHsl:()=>xh,colorHsla:()=>vh,colorRgb:()=>bh,colorRgba:()=>wh,config:()=>kt,cycloid:()=>Vn,dasharray:()=>yh,debug:()=>A1,delta:()=>qa,dist:()=>Qs,ensureKatex:()=>Zm,estimateMathSize:()=>ya,flip:()=>du,getAnchors:()=>O1,getAvailableTypes:()=>N1,getGlobalStyle:()=>f0,getParam:()=>T,getRegisteredTypes:()=>eu,hasMath:()=>va,isKatexAvailable:()=>Bl,linspace:()=>ze,logicparse:()=>Ql,mergeParams:()=>oa,mergeParamsFirstWins:()=>Mr,mirrorx:()=>mu,mountFromJson:()=>H1,nand:()=>Tn,nor:()=>Rn,placeElementLabels:()=>Il,point:()=>uu,renderFromJson:()=>hh,renderMathHtml:()=>Cl,resetConfigForTests:()=>fu,resetElementStyleForTests:()=>Wl,resheight:()=>F,resolveLabelRotateDeg:()=>dc,resolvePosition:()=>Ia,resolvePositionX:()=>ah,resolvePositionY:()=>lh,resolveTheme:()=>Zs,reswidth:()=>Ye,rotate:()=>Wr,setBoxAnchors16:()=>fr,setElementStyle:()=>Gl,sevensegdigit:()=>Cc,subsystems:()=>Zc,svgconfig:()=>B1,swapLabelLocForTheta:()=>mc,swapPause:()=>la,textSize:()=>b0,theme:()=>_1,use:()=>R1,validateCircuitJson:()=>j1,validateColor:()=>Vr,validateLinestyle:()=>Wa,withDrawing:()=>h1,xnor:()=>_n,xor:()=>An});var au="0.5.0";function He(r,e,t,n){return{xmin:r,ymin:e,xmax:t,ymax:n}}var ja=(c=>(c.EPS="eps",c.JPG="jpg",c.PDF="pdf",c.PGF="pgf",c.PNG="png",c.PS="ps",c.RAW="raw",c.RGBA="rgba",c.SVG="svg",c.TIF="tif",c))(ja||{});function ze(r,e,t=50){if(t<2)return[r];let n=(e-r)/(t-1);return Array.from({length:t},(s,i)=>r+n*i)}function dh(r,e,t,n,s){let i=Math.cos(t*Math.PI/180),o=Math.sin(t*Math.PI/180),a=r-n,l=e-s,h=a*i-l*o,c=a*o+l*i;return[h+n,c+s]}function Sr(r,e,t){return[-(r-t)+t,e]}function kr(r,e){return[r,-e]}function lu(r,e,t,n){return[t-r,n-e]}function hu(r,e,t,n){return Math.atan2(n-e,t-r)*180/Math.PI}function cu(r,e,t,n){return Math.hypot(t-r,n-e)}function Dt(r){return r instanceof A?r:{x:r[0],y:r[1]}}var A=class r{constructor(e,t){z(this,"x");z(this,"y");this.x=e,this.y=t}static fromXY(e){return new r(e[0],e[1])}add(e){let t=Dt(e);return new r(this.x+t.x,this.y+t.y)}sub(e){let t=Dt(e);return new r(this.x-t.x,this.y-t.y)}subFromScalar(e){return new r(e-this.x,e-this.y)}mul(e){return typeof e=="number"?new r(this.x*e,this.y*e):new r(this.x*e.x,this.y*e.y)}div(e){return typeof e=="number"?new r(this.x/e,this.y/e):new r(this.x/e.x,this.y/e.y)}neg(){return new r(-this.x,-this.y)}rotate(e,t=[0,0]){let n=Dt(t),[s,i]=dh(this.x,this.y,e,n.x,n.y);return new r(s,i)}mirrorx(e=0){let[t,n]=Sr(this.x,this.y,e);return new r(t,n)}flip(){let[e,t]=kr(this.x,this.y);return new r(e,t)}toTuple(){return[this.x,this.y]}};function uu(r,e){return new A(r,e)}function Wr(r,e,t=[0,0]){let n=Dt(r),s=Dt(t),[i,o]=dh(n.x,n.y,e,s.x,s.y);return new A(i,o)}function mu(r,e=0){let t=Dt(r),[n,s]=Sr(t.x,t.y,e);return new A(n,s)}function du(r){let e=Dt(r),[t,n]=kr(e.x,e.y);return new A(t,n)}function qa(r,e){let t=Dt(r),n=Dt(e),[s,i]=lu(t.x,t.y,n.x,n.y);return new A(s,i)}function ia(r,e){let t=Dt(r),n=Dt(e);return hu(t.x,t.y,n.x,n.y)}function Qs(r,e){let t=Dt(r),n=Dt(e);return cu(t.x,t.y,n.x,n.y)}function Ha(r){return r instanceof A?r:A.fromXY([r[0],r[1]])}function sd(r){return typeof r=="number"?new A(r,r):Ha(r)}var p0=class{constructor(e,t,n=[0,0],s=[1,1]){z(this,"theta");z(this,"shift");z(this,"localshift");z(this,"zoom");this.theta=e,this.shift=Ha(t),this.localshift=Ha(n),this.zoom=sd(s)}transform(e){return Ha(e).add(this.localshift).mul(this.zoom).rotate(this.theta).add(this.shift)}transformArray(e){return e.map(t=>this.transform(t))}};var pu={unit:3,inches_per_unit:.5,lblofst:.1,fontsize:14,font:"sans-serif",color:"black",lw:2,ls:"-",fill:null,margin:.1},Ya={...pu};function kt(r){Ya={...Ya,...r}}function f0(){return Ya}function fu(){Ya={...pu}}function oa(...r){let e={};for(let t of r)if(t)for(let[n,s]of Object.entries(t))s!==void 0&&(e[n]=s);return e}function Mr(...r){let e={};for(let t of r)if(t)for(let[n,s]of Object.entries(t))s!==void 0&&!(n in e)&&(e[n]=s);return e}function T(r,e,t){let n=r[e];return n!==void 0?n:t}var aa=new Map,ph=!1;function la(r){let e=ph;return ph=r,e}function id(){return[...aa.entries()]}function Xa(r){aa.set(r,null)}function Ga(r){aa.delete(r)}function At(r){if(ph||aa.size===0)return;let e=id().at(-1);if(!e)return;let[t,n]=e;n!==null&&!t.containsElement(n)&&t.add(n),aa.set(t,r)}var fh=["black","silver","gray","white","maroon","red","purple","fuchsia","green","lime","olive","yellow","navy","blue","teal","aqua","aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"],od=new Set(fh);function gh(r){return/^#[A-Fa-f\d]{3}(?:[A-Fa-f\d]{3}|(?:[A-Fa-f\d]{5})?)$/i.test(r)}function bh(r){return/^rgb(\s*)\((\s*)(?:\d*\.?\d*%?)(\s*),(\s*)(?:\d*\.?\d*%?)(\s*),(\s*)(?:\d*\.?\d*%?)(\s*)\)$/i.test(r)}function wh(r){return/^rgba(\s*)\((\s*)(?:\d*\.?\d*%?)(\s*),(\s*)(?:\d*\.?\d*%?)(\s*),(\s*)(?:\d*\.?\d*%?)(\s*),(\s*)(?:\d*\.?\d*%?)(\s*)\)$/i.test(r)}function xh(r){return/^hsl(\s*)\((\s*)(?:-?\d*\.?\d*)(\s*),(\s*)(?:-?\d*\.?\d*%)(\s*),(\s*)(?:-?\d*\.?\d*%)(\s*)\)$/i.test(r)}function vh(r){return/^hsla(\s*)\((\s*)(?:-?\d*\.?\d*)(\s*),(\s*)(?:-?\d*\.?\d*%)(\s*),(\s*)(?:-?\d*\.?\d*%)(\s*),(\s*)(?:-?\d*\.?\d*%?)(\s*)\)$/i.test(r)}function yh(r){return/^(\d+\.?\d*)(,\s*\d+\.?\d*)*$/i.test(r)}function Vr(r){if(r==null||r===!0||r===!1)return;if(Array.isArray(r)){let t=r;if(t.length!==3||typeof t[0]!="number"||typeof t[1]!="number"||typeof t[2]!="number")throw new Error(`Invalid color tuple ${String(r)}`);return}if(typeof r!="string")throw new Error(`Invalid color ${String(r)}`);let e=r;if(!(od.has(e)||e==="bg"||gh(e)||bh(e)||wh(e)||xh(e)||vh(e)||e.startsWith("url(")))throw new Error(`Invalid color name ${e}`)}function Wa(r){if(![null,""," ","-","--",":","-.","dashed","dotted","dashdot"].includes(r)&&!yh(r))throw new Error(`Invalid line style ${r}`)}function Va(r){return r instanceof A?r:{x:r[0],y:r[1]}}function gu(r,e){let t=r.length;if(t<3||e<=0)return r.map(s=>{let i=Va(s);return new A(i.x,i.y)});let n=[];for(let s=t-1;s>=0;s--){let i=Va(r[s]),o=Va(r[(s-1+t)%t]),a=Va(r[(s-2+t)%t]),l=o.x-i.x,h=o.y-i.y,c=o.x-a.x,m=o.y-a.y,f=(Math.atan2(h,l)-Math.atan2(m,c))/2,g=Math.abs(Math.tan(f)),b=e/g,v=(te,ke)=>Math.hypot(te,ke),x=(te,ke,he,ve,de)=>{let Fe=ke/he;return[te.x-ve*Fe,te.y-de*Fe]},S=v(l,h),k=v(c,m),M=Math.min(S,k);b>M&&(b=M,e=M*g);let _=x(o,b,S,l,h),B=x(o,b,k,c,m),$=o.x*2-_[0]-B[0],Y=o.y*2-_[1]-B[1],Z=v($,Y),L=v(b,e),I=x(o,L,Z,$,Y),X=Math.atan2(_[1]-I[1],_[0]-I[0]),j=Math.atan2(B[1]-I[1],B[0]-I[0]);for(;j<X;)j+=2*Math.PI;let re=ze(X,j,100);for(let te of re)n.push(new A(I[0]+Math.cos(te)*e,I[1]+Math.sin(te)*e))}return n.length>0&&n.push(n[0]),n}function le(r){return r.toFixed(3).replace(/\.?0+$/,"")||"0"}function wn(r){let e="",{color:t,ls:n,lw:s,capstyle:i,joinstyle:o,fill:a,hatch:l}=r;if(t!==void 0&&(Array.isArray(t)?e+=`stroke:rgb(${Math.round(t[0]*255)},${Math.round(t[1]*255)},${Math.round(t[2]*255)});`:t&&(e+=`stroke:${t};`)),l?e+="fill:url(#hatch);":a===!1?e+="fill:none;":a!=null&&(e+=`fill:${String(a).toLowerCase()};`),s!==void 0&&s>0&&(e+=`stroke-width:${s};`),n){let h={"--":"7.4,3.2",dashed:"7.4,3.2",":":"2,3.3",dotted:"2,3.3","-.":"12.8,3.2,2,3.2",dashdot:"12.8,3.2,2,3.2"};n in h&&(e+=`stroke-dasharray:${h[n]};`)}return i&&(e+=`stroke-linecap:${i==="projecting"?"square":i};`),o&&(e+=`stroke-linejoin:${o};`),e}var Ur={};for(let r of"lij|' ")Ur[r]=37;for(let r of"![]fI.,:;/\\t")Ur[r]=50;for(let r of'`-(){}r"')Ur[r]=60;for(let r of"*^zcsJkvxy\u03BC\xB0")Ur[r]=85;for(let r of"aebdhnopqug#$L+<>=?_~FZT\u03B10123456789")Ur[r]=95;for(let r of"BSPEAKVXY&UwNRCHD")Ur[r]=112;for(let r of"QGOMm%@\u03A9")Ur[r]=140;for(let r of"W\u2220")Ur[r]=155;var Mt={};for(let r of"lij:.,;t")Mt[r]=47;for(let r of"|")Mt[r]=37;for(let r of"![]fI/\\")Mt[r]=55;for(let r of"`-(){}r")Mt[r]=60;for(let r of"sJ\xB0")Mt[r]=68;for(let r of'"zcae?1')Mt[r]=74;for(let r of"*^kvxy\u03BCbdhnopqug#$_\u03B10123456789")Mt[r]=85;for(let r of"#$+<>=~FSP")Mt[r]=95;for(let r of"ELZT")Mt[r]=105;for(let r of"BRC")Mt[r]=112;for(let r of"DAwHUKVXYNQGO")Mt[r]=122;for(let r of"&m\u03A9")Mt[r]=130;for(let r of"%")Mt[r]=140;for(let r of"MW@\u2220")Mt[r]=155;function bu(r){if(!r)return!1;let e=r.toLowerCase();return e.includes("times")||e.includes("serif")&&!e.includes("sans")}function ld(r,e,t){let n=bu(t)?Mt:Ur,s=bu(t)?60:75,i=0;for(let o of r)i+=n[o]??s;return i*72/1e3*(e/12)}function b0(r,e,t){if(r==="")return{width:0,height:0};let n=r.split(`
|
|
266
|
+
`),s=0;for(let i of n)s=Math.max(s,ld(i,e,t));return{width:s,height:n.length*e}}function it(r){return r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}var Ua=class Ua{constructor(e,t={}){z(this,"bbox");z(this,"scale");z(this,"pxwidth");z(this,"pxheight");z(this,"elements",[]);z(this,"backgroundColor");z(this,"showbbox");z(this,"extraDefs");z(this,"svgDefs",[]);z(this,"clips",new Map);z(this,"_groupStack",[]);z(this,"_hasGroups",!1);let n=t.inchesPerUnit??.5,s=(t.margin??.1)+2/72;this.scale=72*n,this.showbbox=t.showbbox??!1,this.bbox={xmin:e.xmin-s,ymin:e.ymin-s,xmax:e.xmax+s,ymax:e.ymax+s};let i=this.bbox.xmax-this.bbox.xmin,o=this.bbox.ymax-this.bbox.ymin;this.pxwidth=Math.max(5,i*this.scale),this.pxheight=Math.max(5,o*this.scale),this.extraDefs=t.extraDefs??""}setBbox(e){let t=.1+2/72;this.bbox={xmin:e.xmin-t,ymin:e.ymin-t,xmax:e.xmax+t,ymax:e.ymax+t};let n=this.bbox.xmax-this.bbox.xmin,s=this.bbox.ymax-this.bbox.ymin;this.pxwidth=Math.max(5,n*this.scale),this.pxheight=Math.max(5,s*this.scale)}xform(e,t){return[e*this.scale,-t*this.scale]}bgcolor(e){this.backgroundColor=e}hatchpattern(e="hatch",t="black",n=.5){let s=`<pattern id="${e}" patternUnits="userSpaceOnUse" width="4" height="4"><path d="M-1,1 l2,-2 M0,4 l4,-4 M3,5 l2,-2" style="stroke:${t}; stroke-width:${n}" /></pattern>`;return this.svgDefs.push(s),e}addclip(e,t){let n=`<clipPath id="${e}"><path d="${t}" /></clipPath>`;this.svgDefs.push(n)}addclipBbox(e){let t=`${e.xmin},${e.ymin},${e.xmax},${e.ymax}`,n;if(this.clips.has(t))n=this.clips.get(t);else{n=Ua.totalClips++,this.clips.set(t,n);let[s,i]=this.xform(e.xmin,e.ymin),[o,a]=this.xform(e.xmax,e.ymax),l=Math.min(s,o)-1,h=Math.min(i,a)-1,c=Math.abs(o-s)+2,m=Math.abs(a-i)+2;this.svgDefs.push(`<clipPath id="clip${n}"><rect x="${le(l)}" y="${le(h)}" width="${le(c)}" height="${le(m)}" /></clipPath>`)}return`url(#clip${n})`}plot(e,t,n={}){let s=n.zorder??2,i=n.color??"black",o=n.ls??"-",a=n.lw??2,l=n.capstyle??"round",h=n.joinstyle??"round",c=typeof n.fill=="string"||n.fill===void 0?n.fill??"none":"none",m="",[f,g]=this.xform(e[0],t[0]);m+=`M ${le(f)} ${le(g)} `;for(let v=1;v<e.length;v++){if(Number.isNaN(e[v])||Number.isNaN(t[v])){m+="M ";continue}m.endsWith("M ")||(m+="L ");let[x,S]=this.xform(e[v],t[v]);m+=`${le(x)},${le(S)} `}m=m.trim();let b=wn({color:i,ls:o,lw:a,capstyle:l,joinstyle:h,fill:c});this.elements.push({z:s,xml:`<path d="${m}" style="${it(b)}"/>`})}circle(e,t,n,s={}){let i=s.zorder??1,[o,a]=this.xform(e,t),l=n*this.scale,h=s.fill,c=h??"none",m=wn({color:s.color??"black",ls:s.ls??"-",lw:s.lw??2,fill:c});this.elements.push({z:i,xml:`<circle cx="${le(o)}" cy="${le(a)}" r="${le(l)}" style="${it(m)}"/>`})}arrow(e,t,n={}){let s=n.arrowwidth??.15,i=n.arrowlength??.25,o=n.color??"black",a=n.lw??1,l=n.zorder??1,[h,c]=this.xform(e[0],e[1]),m=i/2*Math.cos(t*Math.PI/180)*this.scale,f=i/2*Math.sin(t*Math.PI/180)*this.scale,g=s*this.scale,b=i*this.scale,v=Math.hypot(m,f),x=-Math.atan2(f,m)*180/Math.PI,S=new A(h-m,c+f),k=new A(v-b,g/2).rotate(x,[0,0]).add(S),M=new A(v-b,-g/2).rotate(x,[0,0]).add(S),_=new A(h-a*2*Math.cos(x*Math.PI/180),c-a*2*Math.sin(x*Math.PI/180)),B=wn({color:o,lw:0,capstyle:"butt",joinstyle:"miter",fill:o}),$=`M ${le(_.x)} ${le(_.y)} L ${le(k.x)} ${le(k.y)} L ${le(M.x)} ${le(M.y)} Z`;this.elements.push({z:l,xml:`<path d="${$}" style="${it(B)}"/>`})}text(e,t,n,s={}){if(e==="")return;let i=s.zorder??3,[o,a]=this.xform(t,n),l=s.fontsize??14,h=s.fontfamily??"sans-serif";(h.toLowerCase()==="sans"||h.toLowerCase()==="arial")&&(h="sans-serif");let c=s.valign??"center";if(c==="base"){let k=e.split(`
|
|
267
|
+
`).length;a-=(k-1)*l}let m=s.halign==="left"?"start":s.halign==="right"?"end":"middle",f=c==="top"?"hanging":c==="bottom"?"ideographic":"central",g=s.rotation??0,b=g!==0?` transform="rotate(${le(g)} ${le(o)} ${le(a)})"`:"",v=s.color??"black",x;s.textDecoration?x=`<tspan text-decoration="${s.textDecoration}">${it(e)}</tspan>`:x=it(e);let S=`<text x="${le(o)}" y="${le(a)}" dominant-baseline="${f}" fill="${it(v)}" font-size="${le(l)}" font-family="${it(h)}" text-anchor="${m}"${b}>${x}</text>`;s.href&&(S=`<a href="${it(s.href)}">${S}</a>`),this.elements.push({z:i,xml:S})}poly(e,t={}){let n=t.closed??!0,s=t.zorder??1,i=t.color??"black",o=t.lw??2,a=t.ls??"-",l=t.capstyle??"round",h=t.joinstyle??"round",c=typeof t.fill=="string"?t.fill:"none",m=e.map(b=>{let[v,x]=this.xform(b.x,b.y);return`${le(v)},${le(x)}`}).join(" "),f=n?"polygon":"polyline",g=wn({color:i,ls:a,lw:o,capstyle:l,joinstyle:h,fill:c,hatch:t.hatch});this.elements.push({z:s,xml:`<${f} points="${m}" style="${it(g)}"/>`})}bezier(e,t={}){if(e.length!==3&&e.length!==4)throw new Error("bezier expects 3 (quadratic) or 4 (cubic) control points");let n=t.zorder??1,s=t.color??"black",i=t.lw??2,o=t.ls??"-",a=t.capstyle??"round",l=e.length===4?"C":"Q",h=t.arrow,c=t.arrowlength??.25,m=t.arrowwidth??.15,f=e.map(x=>({x:x.x,y:x.y}));if(h!=null){if(h.includes("<")){let x=Math.atan2(e[0].y-e[1].y,e[0].x-e[1].x);f[0]={x:e[0].x-Math.cos(x)*c/2,y:e[0].y-Math.sin(x)*c/2}}if(h.includes(">")){let x=e.length-1,S=e.length-2,k=Math.atan2(e[x].y-e[S].y,e[x].x-e[S].x);f[x]={x:e[x].x-Math.cos(k)*c/2,y:e[x].y-Math.sin(k)*c/2}}}let g=f.map(x=>{let[S,k]=this.xform(x.x,x.y);return{x:S,y:k}}),b=`M ${le(g[0].x)} ${le(g[0].y)} ${l}`;for(let x=1;x<g.length;x++)b+=` ${le(g[x].x)} ${le(g[x].y)}`;let v=wn({color:s,ls:o,lw:i,capstyle:a,fill:"none"});if(this.elements.push({z:n,xml:`<path d="${b}" style="${it(v)}"/>`}),h!=null){if(h.includes("<")){let x=e[0].x-e[1].x,S=e[0].y-e[1].y,k=Math.atan2(S,x)*180/Math.PI;this.arrow([e[0].x,e[0].y],k,{color:s,lw:1,zorder:n,arrowlength:c,arrowwidth:m})}else h.startsWith("o")&&this.circle(e[0].x,e[0].y,m/2,{color:s,fill:s,lw:0,zorder:n});if(h.includes(">")){let x=e.length-1,S=e.length-2,k=e[x].x-e[S].x,M=e[x].y-e[S].y,_=Math.atan2(M,k)*180/Math.PI;this.arrow([e[x].x,e[x].y],_,{color:s,lw:1,zorder:n,arrowlength:c,arrowwidth:m})}else if(h.endsWith("o")){let x=e.length-1;this.circle(e[x].x,e[x].y,m/2,{color:s,fill:s,lw:0,zorder:n})}}}arc(e,t,n,s={}){let i=s.zorder??1,o=s.color??"black",a=s.lw??2,l=s.ls??"-",h=s.fill??void 0;h==null&&(h="none");let c=s.theta1??0,m=s.theta2??90,f=s.angle??0,[g,b]=this.xform(e[0],e[1]),v=t*this.scale,x=n*this.scale;f=-f;let S=-c*Math.PI/180,k=-m*Math.PI/180,M=f*Math.PI/180;for(S=Math.atan2(v*Math.sin(S),x*Math.cos(S)),k=Math.atan2(v*Math.sin(k),x*Math.cos(k));S<k;)S+=2*Math.PI;let _=g+v/2*Math.cos(k)*Math.cos(M)-x/2*Math.sin(k)*Math.sin(M),B=b+v/2*Math.cos(k)*Math.sin(M)+x/2*Math.sin(k)*Math.cos(M),$=g+v/2*Math.cos(S)*Math.cos(M)-x/2*Math.sin(S)*Math.sin(M),Y=b+v/2*Math.cos(S)*Math.sin(M)+x/2*Math.sin(S)*Math.cos(M),Z=$-_,L=Y-B,I=wn({color:o,ls:l,lw:a,fill:h});if(Math.abs(Z)<.1&&Math.abs(L)<.1){let X=-(s.angle??0),j=X!==0?` transform="rotate(${le(X)} ${le(g)} ${le(b)})"`:"";this.elements.push({z:i,xml:`<ellipse cx="${le(g)}" cy="${le(b)}" rx="${le(v/2)}" ry="${le(x/2)}"${j} style="${it(I)}"/>`})}else{let X=Math.abs(k-S)>=Math.PI?"1 1":"0 1",j=`M ${le(_)} ${le(B)} a ${le(v/2)} ${le(x/2)} ${le(f)} ${X} ${le(Z)} ${le(L)}`;this.elements.push({z:i,xml:`<path d="${j}" style="${it(I)}"/>`})}if(s.arrow){let X=s.arrowwidth??.15,j=s.arrowlength??.25,re=s.angle??0,te=s.theta1??0,ke=s.theta2??90,he=re*Math.PI/180,ve=Math.cos(ke*Math.PI/180),de=Math.sin(ke*Math.PI/180),Fe=Math.atan2(t/n*de,ve)*180/Math.PI,qe=Math.cos(te*Math.PI/180),Ie=Math.sin(te*Math.PI/180),ge=Math.atan2(t/n*Ie,qe)*180/Math.PI,Me=(De,ye)=>{if(re===0)return[De,ye];let _e=De-e[0],Ae=ye-e[1];return[e[0]+_e*Math.cos(he)-Ae*Math.sin(he),e[1]+_e*Math.sin(he)+Ae*Math.cos(he)]},be=(De,ye)=>re===0?[De,ye]:[De*Math.cos(he)-ye*Math.sin(he),De*Math.sin(he)+ye*Math.cos(he)],Be=s.arrow;if(Be==="ccw"||Be==="end"||Be==="both"){let De=Math.cos((Fe+90)*Math.PI/180)*j,ye=Math.sin((Fe+90)*Math.PI/180)*j,_e=Me(e[0]+t/2*Math.cos(Fe*Math.PI/180),e[1]+n/2*Math.sin(Fe*Math.PI/180)),Ae=be(De,ye),Ze=Math.atan2(Ae[1],Ae[0])*180/Math.PI;this.arrow([_e[0]+Ae[0],_e[1]+Ae[1]],Ze,{arrowwidth:X,arrowlength:j,color:o,lw:1,zorder:i})}if(Be==="cw"||Be==="start"||Be==="both"){let De=-Math.cos((ge+90)*Math.PI/180)*j,ye=-Math.sin((ge+90)*Math.PI/180)*j,_e=Me(e[0]+t/2*Math.cos(ge*Math.PI/180),e[1]+n/2*Math.sin(ge*Math.PI/180)),Ae=be(De,ye),Ze=Math.atan2(Ae[1],Ae[0])*180/Math.PI;this.arrow([_e[0]+Ae[0],_e[1]+Ae[1]],Ze,{arrowwidth:X,arrowlength:j,color:o,lw:1,zorder:i})}}}path(e,t={}){let n=t.zorder??1,s=t.color??"black",i=t.lw??2,o=t.ls??"-",a=t.capstyle??"round",l=t.joinstyle??"round",h=t.fill??"none",c=[];for(let f of e)if(typeof f=="string")c.push(f);else{let[g,b]=this.xform(f.x,f.y);c.push(le(g),le(b))}let m=wn({color:s,ls:o,lw:i,capstyle:a,joinstyle:l,fill:h});this.elements.push({z:n,xml:`<path d="${c.join(" ")}" style="${it(m)}"/>`})}image(e,t,n,s,i={}){let o=i.zorder??1,a=i.rotate??0,l=n*this.scale,h=s*this.scale,[c,m]=this.xform(t[0],t[1]),f=m-h,g=e.startsWith("data:")?e:`data:image/${i.imgfmt??"png"};base64,${e}`,b=a!==0?` transform="rotate(${le(-a)} ${le(c)} ${le(f+h)})"`:"";this.elements.push({z:o,xml:`<image x="${le(c)}" y="${le(f)}" width="${le(l)}" height="${le(h)}" href="${it(g)}"${b}/>`})}mathText(e,t,n,s){let i=s.zorder??3,[o,a]=this.xform(t,n),l=s.fontsize??14,h=s.color??"black",c=s.width,m=s.height,f=s.halign??"center",g=s.valign??"center",b=o,v=a;f==="center"?b-=c/2:f==="right"&&(b-=c),g==="center"?v-=m/2:g==="bottom"&&(v-=m);let x=s.rotation??0,S=x!==0?` transform="rotate(${le(x)} ${le(o)} ${le(a)})"`:"",k=f==="left"?"flex-start":f==="right"?"flex-end":"center",M=g==="top"?"flex-start":g==="bottom"?"flex-end":"center",_=`<foreignObject x="${le(b)}" y="${le(v)}" width="${le(c)}" height="${le(m)}"${S}><div xmlns="http://www.w3.org/1999/xhtml" style="color:${it(h)};font-size:${l}px;display:flex;align-items:${M};justify-content:${k};width:100%;height:100%;">`+e+"</div></foreignObject>";this.elements.push({z:i,xml:_})}beginGroup(e,t){this._hasGroups=!0,this._groupStack.push({startIndex:this.elements.length,attrs:e,title:t})}endGroup(){let e=this._groupStack.pop();if(!e)throw new Error("endGroup called without matching beginGroup");let t=this.elements.splice(e.startIndex);if(t.length===0){let a=Object.entries(e.attrs).map(([h,c])=>`${h}="${it(c)}"`).join(" "),l=e.title?`<title>${it(e.title)}</title>`:"";this.elements.push({z:0,xml:`<g ${a}>${l}</g>`});return}let n=t[0].z;for(let a=1;a<t.length;a++)t[a].z<n&&(n=t[a].z);let s=t.map(a=>a.xml).join(""),i=Object.entries(e.attrs).map(([a,l])=>`${a}="${it(l)}"`).join(" "),o=e.title?`<title>${it(e.title)}</title>`:"";this.elements.push({z:n,xml:`<g ${i}>${o}${s}</g>`})}toSvgInnerXml(){return[...this.elements].sort((e,t)=>e.z-t.z).map(e=>e.xml).join("")}toSvgString(){let e=this.bbox.xmin*this.scale,t=-this.bbox.ymax*this.scale,n=this.pxwidth,s=this.pxheight,i=this.backgroundColor?` style="background-color:${it(this.backgroundColor)}"`:"",o=this.extraDefs+this.svgDefs.join("");this._hasGroups&&(o+="<style>.sd-el{cursor:pointer;transition:filter .15s ease}.sd-el:hover path,.sd-el:hover polyline,.sd-el:hover polygon,.sd-el:hover circle,.sd-el:hover ellipse{filter:drop-shadow(0 0 3px rgba(66,133,244,.6))}.sd-el.sd-selected path,.sd-el.sd-selected polyline,.sd-el.sd-selected polygon,.sd-el.sd-selected circle,.sd-el.sd-selected ellipse{stroke:#4285f4;filter:drop-shadow(0 0 4px rgba(66,133,244,.8))}</style>");let a=o?`<defs>${o}</defs>`:"",l=this.toSvgInnerXml();return`<?xml version="1.0" encoding="UTF-8"?>
|
|
268
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="${le(n)}pt" height="${le(s)}pt" viewBox="${le(e)} ${le(t)} ${le(n)} ${le(s)}"${i}>${a}${l}</svg>`}};z(Ua,"totalClips",0);var g0=Ua;var E0=null,Um=!1,_l=null;function Jm(){return _l||(_l=Promise.resolve().then(()=>(Vm(),Wm)).then(r=>{E0=r.default??r}).catch(()=>{E0=null}).finally(()=>{Um=!0}),_l)}Jm();var Km=/\$([^$]+)\$/g;function va(r){return/\$[^$]+\$/.test(r)}function Bl(){return E0!==null}async function Zm(){return Um||await Jm(),E0!==null}function Cl(r,e){return E0?r.replace(Km,(t,n)=>{try{return E0.renderToString(n,{throwOnError:!1})}catch{return t}}):r}function ya(r,e){let t=r.replace(Km,(a,l)=>l),n=e*.65,s=Math.max(e*2,t.length*n+e),o=/\\frac|\\sum|\\int|\\prod|\\sqrt/.test(r)?e*2.8:e*1.8;return{width:s,height:o}}var H=[Number.NaN,Number.NaN];function Sa(r,e){return typeof r=="string"&&r.toLowerCase()==="bg"?e.bgcolor??"white":r}function Hp(r){return Array.isArray(r)?Number.isNaN(r[0])&&Number.isNaN(r[1]):!1}function Yp(r){return Hp(r)?[Number.NaN,Number.NaN]:r instanceof A?[r.x,r.y]:[r[0],r[1]]}var p=class r{constructor(e,t={}){z(this,"path");z(this,"color");z(this,"lw");z(this,"ls");z(this,"capstyle");z(this,"joinstyle");z(this,"fill");z(this,"arrow");z(this,"arrowwidth",.15);z(this,"arrowlength",.25);z(this,"zorder");z(this,"visible",!0);z(this,"clip");z(this,"role");z(this,"gradientStrokeId");this.path=e.map(Yp),Object.assign(this,t)}xform(e,t){let s=e.transformArray(this.path.map(([i,o])=>[i,o])).map(i=>[i.x,i.y]);return new r(s,{color:this.color??t.color,lw:this.lw??t.lw,ls:this.ls??t.ls,capstyle:this.capstyle??t.capstyle,joinstyle:this.joinstyle??t.joinstyle,fill:this.fill??t.fill,arrow:this.arrow,arrowwidth:this.arrowwidth,arrowlength:this.arrowlength,zorder:this.zorder??t.zorder,visible:this.visible,clip:this.clip})}getBBox(){let e=this.path.map(s=>s[0]).filter(s=>!Number.isNaN(s)),t=this.path.map(s=>s[1]).filter(s=>!Number.isNaN(s)),n=this.arrow?this.arrowwidth??0:0;return He(Math.min(...e),Math.min(...t)-n,Math.max(...e),Math.max(...t)+n)}doreverse(e){let t=[...this.path].reverse();this.path=t.map(([n,s])=>Number.isNaN(n)&&Number.isNaN(s)?[n,s]:Sr(n,s,e)),this.arrow&&(this.arrow=this.arrow.split("").map(n=>n==="<"?">":n===">"?"<":n).join(""))}doflip(){this.path=this.path.map(([e,t])=>Number.isNaN(e)&&Number.isNaN(t)?[e,t]:kr(e,t))}draw(e,t,n){if(!this.visible)return;let s=t.transformArray(this.path.map(([S,k])=>[S,k])),i=s.map(S=>new A(S.x,S.y)),o=this.color??n.color??"black",a=this.ls??n.ls??"-",l=this.lw??n.lw??2,h=this.capstyle??n.capstyle??"round",c=this.joinstyle??n.joinstyle??"round",m=Sa(this.fill??n.fill,n),f=this.zorder??n.zorder??2,g=n._svgGradientFillId;if(m){let S=i.map(_=>`${_.x},${_.y}`),k=new Set(S);S.length!==k.size?m===!0&&(m=o):m=void 0}if(g&&m&&(m=`url(#${g})`),this.arrow?.includes("<")){let S=i[1].sub(i[0]),k=Math.atan2(S.y,S.x);i=[...i],i[0]=new A(i[0].x+this.arrowlength*Math.cos(k),i[0].y+this.arrowlength*Math.sin(k))}if(this.arrow?.includes(">")){let S=i[i.length-1].sub(i[i.length-2]),k=Math.atan2(S.y,S.x);i=[...i];let M=i.length-1;i[M]=new A(i[M].x-this.arrowlength*Math.cos(k),i[M].y-this.arrowlength*Math.sin(k))}let b=this.gradientStrokeId?`url(#${this.gradientStrokeId})`:o,v=i.map(S=>S.x),x=i.map(S=>S.y);if(e.plot(v,x,{color:b,ls:a,lw:l,capstyle:h,joinstyle:c,fill:m??"none",zorder:f}),this.arrow){let S=s.map(k=>new A(k.x,k.y));if(this.arrow.includes("<")){let k=Math.atan2(S[0].y-S[1].y,S[0].x-S[1].x)*180/Math.PI;e.arrow([S[0].x,S[0].y],k,{color:o,zorder:f,arrowlength:this.arrowlength,arrowwidth:this.arrowwidth,lw:1})}if(this.arrow.includes(">")){let k=Math.atan2(S[S.length-1].y-S[S.length-2].y,S[S.length-1].x-S[S.length-2].x)*180/Math.PI;e.arrow([S[S.length-1].x,S[S.length-1].y],k,{color:o,zorder:f,arrowlength:this.arrowlength,arrowwidth:this.arrowwidth,lw:1})}}}},D=class r{constructor(e,t,n={}){z(this,"center");z(this,"radius");z(this,"color");z(this,"lw");z(this,"ls");z(this,"fill");z(this,"zorder");z(this,"visible",!0);this.center=e,this.radius=t,Object.assign(this,n)}xform(e,t){let n=e.transform(this.center),s=e.zoom;if(!(s.x===s.y))throw new Error("SegmentCircle xform with non-uniform zoom not implemented in TS subset");return new r([n.x,n.y],this.radius*s.x,{color:this.color??t.color,lw:this.lw??t.lw,ls:this.ls??t.ls,fill:this.fill??t.fill,zorder:this.zorder??t.zorder})}getBBox(){let[e,t]=this.center,n=this.radius;return He(e-n,t-n,e+n,t+n)}doreverse(e){this.center=Sr(this.center[0],this.center[1],e)}doflip(){this.center=kr(this.center[0],this.center[1])}draw(e,t,n){if(!this.visible)return;let s=n._svgGradientFillId,i=t.transform(this.center),o=this.radius*t.zoom.x,a=this.color??n.color??"black",l=this.lw??n.lw??2,h=Sa(this.fill??n.fill,n);s?h=`url(#${s})`:h===!0?h=a:h===!1&&(h="none"),h==null&&(h="none"),e.circle(i.x,i.y,o,{color:a,lw:l,ls:this.ls??n.ls,fill:h,zorder:this.zorder??n.zorder??1})}},W=class r{constructor(e,t,n={}){z(this,"xy");z(this,"text");z(this,"color");z(this,"fontsize");z(this,"fontfamily");z(this,"mathfont");z(this,"zorder");z(this,"visible",!0);z(this,"halign");z(this,"valign");z(this,"href");z(this,"decoration");z(this,"rotation");let s=e instanceof A?e:A.fromXY(e);this.xy=[s.x,s.y],this.text=t;let i=n.align;i&&(this.halign=i[0],this.valign=i[1]),Object.assign(this,n)}xform(e,t){let n=e.transform(this.xy);return new r([n.x,n.y],this.text,{color:this.color??t.color,fontsize:this.fontsize??t.fontsize,fontfamily:this.fontfamily??t.font,mathfont:this.mathfont??t.mathfont,zorder:this.zorder??t.zorder,visible:this.visible,halign:this.halign,valign:this.valign,href:this.href,decoration:this.decoration,rotation:this.rotation})}getBBox(){let e=this.fontsize??14,t=72*.5,n,s;if(va(this.text)){let c=ya(this.text,e);n=c.width/t,s=c.height/t}else{let{width:c,height:m}=b0(this.text,e,this.fontfamily);n=c/t,s=m/t}let i=this.halign??"center",o,a;i==="left"?(o=this.xy[0],a=this.xy[0]+n):i==="right"?(o=this.xy[0]-n,a=this.xy[0]):(o=this.xy[0]-n/2,a=this.xy[0]+n/2);let l=this.valign??"center",h=this.xy[1];if(l==="center")h-=s/2;else if(l==="top")h-=s;else if(l!=="bottom"){let c=this.text.split(`
|
|
269
269
|
`).length;h+=e*(2/72)*(c-1)}return He(o,h,a,h+s)}doreverse(e){this.xy=Sr(this.xy[0],this.xy[1],e),this.halign==="left"?this.halign="right":this.halign==="right"&&(this.halign="left")}doflip(){this.xy=kr(this.xy[0],this.xy[1]),this.valign==="top"?this.valign="bottom":this.valign==="bottom"&&(this.valign="top")}draw(e,t,n){if(!this.visible)return;let s=t.transform(this.xy),i=this.color??n.color??"black",o=this.fontsize??n.fontsize??14,a=this.fontfamily??n.font??"sans-serif",l=this.mathfont??n.mathfont,h=this.text,c=t.theta*180/Math.PI,m=this.rotation!==void 0?c+this.rotation:void 0;if(va(h)&&Bl()){let v=Cl(h,o),{width:x,height:S}=ya(h,o);e.mathText(v,s.x,s.y,{width:x,height:S,color:i,fontsize:o,halign:this.halign??"center",valign:this.valign??"center",zorder:this.zorder??n.zorder??3,rotation:m});return}let f=l!==void 0&&l!==""&&h.includes("$")?l:a,g=this.decoration?.toLowerCase(),b=g==="underline"||g==="overline"?g:void 0;e.text(this.text,s.x,s.y,{color:i,fontsize:o,fontfamily:f,halign:this.halign??"center",valign:this.valign??"center",zorder:this.zorder??n.zorder??3,href:this.href??void 0,textDecoration:b,rotation:m})}},U=class r{constructor(e,t={}){z(this,"verts");z(this,"closed",!0);z(this,"cornerradius",0);z(this,"color");z(this,"fill");z(this,"lw");z(this,"ls");z(this,"hatch");z(this,"joinstyle");z(this,"capstyle");z(this,"zorder");z(this,"visible",!0);z(this,"clip");this.verts=e,Object.assign(this,t)}xform(e,t){let s=e.transformArray(this.verts.map(([i,o])=>[i,o])).map(i=>[i.x,i.y]);return new r(s,{closed:this.closed,cornerradius:this.cornerradius,color:this.color??t.color,fill:this.fill??t.fill,lw:this.lw??t.lw,ls:this.ls??t.ls,hatch:this.hatch,joinstyle:this.joinstyle??t.joinstyle,capstyle:this.capstyle??t.capstyle,zorder:this.zorder??t.zorder,visible:this.visible,clip:this.clip})}getBBox(){let e=this.verts.map(n=>n[0]),t=this.verts.map(n=>n[1]);return He(Math.min(...e),Math.min(...t),Math.max(...e),Math.max(...t))}doreverse(e){this.verts=[...this.verts].reverse().map(([t,n])=>Sr(t,n,e))}doflip(){this.verts=this.verts.map(([e,t])=>kr(e,t))}draw(e,t,n){if(!this.visible)return;let s=n._svgGradientFillId,i=this.fill!==void 0?this.fill:n.fill;i=Sa(i,n);let o=i===!0?n.color??"black":typeof i=="string"?i:void 0;s&&this.closed&&(o=`url(#${s})`);let a=this.color??n.color??"black",h=t.transformArray(this.verts.map(([c,m])=>[c,m])).map(c=>({x:c.x,y:c.y}));if(this.cornerradius>0){let c=gu(this.verts.map(([m,f])=>[m,f]),this.cornerradius);h=t.transformArray(c.map(m=>[m.x,m.y])).map(m=>({x:m.x,y:m.y}))}e.poly(h,{closed:this.closed,color:a,fill:o===void 0?"none":o,lw:this.lw??n.lw??2,ls:this.ls??n.ls??"-",hatch:this.hatch,capstyle:this.capstyle??n.capstyle??"round",joinstyle:this.joinstyle??n.joinstyle??"round",zorder:this.zorder??n.zorder??1})}},xe=class r{constructor(e,t,n,s={}){z(this,"center");z(this,"width");z(this,"height");z(this,"theta1");z(this,"theta2");z(this,"arrow");z(this,"arrowwidth",.15);z(this,"arrowlength",.25);z(this,"angle",0);z(this,"color");z(this,"lw");z(this,"ls");z(this,"fill");z(this,"zorder");z(this,"visible",!0);z(this,"clip");this.center=e,this.width=t,this.height=n,this.theta1=s.theta1??35,this.theta2=s.theta2??-35,this.arrow=s.arrow,s.arrowwidth!==void 0&&(this.arrowwidth=s.arrowwidth),s.arrowlength!==void 0&&(this.arrowlength=s.arrowlength),this.angle=s.angle??0,this.color=s.color,this.lw=s.lw,this.ls=s.ls,this.fill=s.fill,this.zorder=s.zorder,this.visible=s.visible??!0,this.clip=s.clip}xform(e,t){let n=e.transform(this.center),s=this.angle+e.theta;return new r([n.x,n.y],this.width*e.zoom.x,this.height*e.zoom.y,{theta1:this.theta1,theta2:this.theta2,angle:s,arrow:this.arrow,arrowwidth:this.arrowwidth,arrowlength:this.arrowlength,color:this.color??t.color,lw:this.lw??t.lw,ls:this.ls??t.ls,fill:this.fill??t.fill,zorder:this.zorder??t.zorder,visible:this.visible,clip:this.clip})}getBBox(){let e=this.theta1*Math.PI/180,t=this.theta2*Math.PI/180,n=Math.atan2(this.width*Math.sin(e),this.height*Math.cos(e)),s=Math.atan2(this.width*Math.sin(t),this.height*Math.cos(t));for(;s<n;)s+=2*Math.PI;let i=this.angle*Math.PI/180,o=this.width/2,a=this.height/2,l=50,h=[],c=[];for(let m=0;m<=l;m++){let f=n+(s-n)*m/l,g=Math.sin(f),b=Math.cos(f);h.push(this.center[0]+o*b*Math.cos(i)-a*g*Math.sin(i)),c.push(this.center[1]+o*b*Math.sin(i)+a*g*Math.cos(i))}return He(Math.min(...h),Math.min(...c),Math.max(...h),Math.max(...c))}doreverse(e){this.center=Sr(this.center[0],this.center[1],e);let t=this.theta1,n=this.theta2;this.theta1=180-n,this.theta2=180-t,this.arrow==="cw"?this.arrow="ccw":this.arrow==="ccw"&&(this.arrow="cw")}doflip(){this.center=kr(this.center[0],this.center[1]);let e=this.theta1,t=this.theta2;this.theta1=-t,this.theta2=-e,this.arrow==="cw"?this.arrow="ccw":this.arrow==="ccw"&&(this.arrow="cw")}draw(e,t,n){if(!this.visible)return;let s=t.transform(this.center),i=this.width*t.zoom.x,o=this.height*t.zoom.y;e.arc([s.x,s.y],i,o,{theta1:this.theta1,theta2:this.theta2,angle:this.angle+t.theta,color:this.color??n.color??"black",lw:this.lw??n.lw??2,ls:this.ls??n.ls??"-",fill:Sa(this.fill??n.fill,n),zorder:this.zorder??n.zorder??1,arrow:this.arrow??void 0,arrowwidth:this.arrowwidth,arrowlength:this.arrowlength})}},Ut=class r{constructor(e,t={}){z(this,"p");z(this,"color");z(this,"lw");z(this,"ls");z(this,"capstyle");z(this,"arrow");z(this,"arrowlength",.25);z(this,"arrowwidth",.15);z(this,"zorder");z(this,"visible",!0);z(this,"clip");this.p=e,Object.assign(this,t)}xform(e,t){let s=e.transformArray(this.p.map(([i,o])=>[i,o])).map(i=>[i.x,i.y]);return new r(s,{color:this.color??t.color,lw:this.lw??t.lw,ls:this.ls??t.ls,capstyle:this.capstyle??t.capstyle,arrow:this.arrow,arrowlength:this.arrowlength,arrowwidth:this.arrowwidth,zorder:this.zorder??t.zorder,visible:this.visible,clip:this.clip})}getBBox(){let e=Xp(0,1,50),t=this.p.map(o=>o[0]),n=this.p.map(o=>o[1]),s,i;return this.p.length===3?(s=e.map(o=>(1-o)**2*t[0]+2*(1-o)*o*t[1]+o**2*t[2]),i=e.map(o=>(1-o)**2*n[0]+2*(1-o)*o*n[1]+o**2*n[2])):(s=e.map(o=>(1-o)**3*t[0]+3*(1-o)**2*o*t[1]+3*(1-o)*o**2*t[2]+o**3*t[3]),i=e.map(o=>(1-o)**3*n[0]+3*(1-o)**2*o*n[1]+3*(1-o)*o**2*n[2]+o**3*n[3])),He(Math.min(...s),Math.min(...i),Math.max(...s),Math.max(...i))}doreverse(e){if(this.p=this.p.map(([t,n])=>Sr(t,n,e)),this.arrow){let t=[...this.arrow].reverse().join("");this.arrow=t.split("").map(n=>n==="<"?">":n===">"?"<":n).join("")}}doflip(){this.p=this.p.map(([e,t])=>kr(e,t))}draw(e,t,n){if(!this.visible)return;let i=t.transformArray(this.p.map(([o,a])=>[o,a])).map(o=>({x:o.x,y:o.y}));e.bezier(i,{color:this.color??n.color??"black",lw:this.lw??n.lw??2,ls:this.ls??n.ls??"-",capstyle:this.capstyle??n.capstyle??"round",zorder:this.zorder??n.zorder??1,arrow:this.arrow,arrowlength:this.arrowlength,arrowwidth:this.arrowwidth})}};function Xp(r,e,t){if(t<2)return[r];let n=(e-r)/(t-1);return Array.from({length:t},(s,i)=>r+n*i)}var ut=class r{constructor(e,t={}){z(this,"path");z(this,"color");z(this,"lw");z(this,"ls");z(this,"capstyle");z(this,"joinstyle");z(this,"fill");z(this,"zorder");z(this,"visible",!0);z(this,"clip");this.path=e,Object.assign(this,t)}xform(e,t){let n=[];for(let s of this.path)if(typeof s=="string")n.push(s);else{let i=e.transform(s);n.push([i.x,i.y])}return new r(n,{color:this.color??t.color,lw:this.lw??t.lw,ls:this.ls??t.ls,capstyle:this.capstyle??t.capstyle,joinstyle:this.joinstyle??t.joinstyle,fill:this.fill??t.fill,zorder:this.zorder??t.zorder,visible:this.visible,clip:this.clip})}getBBox(){let e=[],t=[];for(let n of this.path)typeof n!="string"&&(e.push(n[0]),t.push(n[1]));return e.length===0?He(0,0,0,0):He(Math.min(...e),Math.min(...t),Math.max(...e),Math.max(...t))}doreverse(e){}doflip(){}draw(e,t,n){if(!this.visible)return;let s=[];for(let i of this.path)if(typeof i=="string")s.push(i);else{let o=t.transform(i);s.push({x:o.x,y:o.y})}e.path(s,{color:this.color??n.color??"black",lw:this.lw??n.lw??2,ls:this.ls??n.ls??"-",capstyle:this.capstyle??n.capstyle??"round",joinstyle:this.joinstyle??n.joinstyle??"round",fill:this.fill===!0?n.color:Sa(this.fill,n),zorder:this.zorder??n.zorder??1})}},Br=class r{constructor(e,t={}){z(this,"image");z(this,"xy");z(this,"width");z(this,"height");z(this,"rotate");z(this,"imgfmt");z(this,"zorder");z(this,"visible",!0);this.image=e,this.xy=t.xy??[0,0],this.width=t.width??3,this.height=t.height??1,this.rotate=t.rotate??0,this.imgfmt=t.imgfmt,this.zorder=t.zorder}getBBox(){if(this.rotate%360===0)return He(this.xy[0],this.xy[1],this.xy[0]+this.width,this.xy[1]+this.height);let e=new A(this.xy[0],this.xy[1]).rotate(this.rotate),t=new A(this.xy[0]+this.width,this.xy[1]).rotate(this.rotate),n=new A(this.xy[0]+this.width,this.xy[1]+this.height).rotate(this.rotate),s=new A(this.xy[0],this.xy[1]+this.height).rotate(this.rotate),i=[e,t,n,s];return He(Math.min(...i.map(o=>o.x)),Math.min(...i.map(o=>o.y)),Math.max(...i.map(o=>o.x)),Math.max(...i.map(o=>o.y)))}xform(e,t){let n=e.transform(this.xy);return new r(this.image,{xy:[n.x,n.y],width:this.width*e.zoom.x,height:this.height*e.zoom.y,rotate:this.rotate+e.theta,imgfmt:this.imgfmt,zorder:this.zorder??t.zorder})}doreverse(e){}doflip(){}draw(e,t,n){if(!this.visible)return;let s=t.transform(this.xy);e.image(this.image,[s.x,s.y],this.width*t.zoom.x,this.height*t.zoom.y,{rotate:this.rotate+t.theta,zorder:this.zorder??n.zorder??1,imgfmt:this.imgfmt})}};function Gp(r,e){let t=r==null||r===""?e:r;return{bot:"bottom",lft:"left",rgt:"right",T:"top"}[t]??t}var Wp=new Set(["top","bottom","left","right","center"]);function mc(r,e){let t=(e%360+360)%360;return t<=90||t>270?r:r==="top"?"bottom":r==="bottom"?"top":r==="left"?"right":r==="right"?"left":r}function dc(r,e){if(r.rotate===!0){let t=e%360;return t<0&&(t+=360),t>90&&t<270&&(t-=180),(t%360+360)%360}return typeof r.rotate=="number"?(r.rotate%360+360)%360:0}var Vp=[["center","bottom"],["right","bottom"],["right","center"],["right","top"],["center","top"],["left","top"],["left","center"],["left","bottom"]];function pc(r,e,t,n,s,i){let o=i.xmin,a=i.ymin,l=i.xmax,h=i.ymax,c;if(typeof s=="number"?c=new A(s,s):c=s instanceof A?s:A.fromXY(s),e==="center")return{halign:"center",valign:"center",ofst:c};if(e in r.anchors){let v=r.anchors[e],x=v instanceof A?v.x:v[0],S=v instanceof A?v.y:v[1],k=.15,M="center",_="center";if(Math.abs(x-o)<k?M="right":Math.abs(x-l)<k&&(M="left"),Math.abs(S-a)<k?_="top":Math.abs(S-h)<k&&(_="bottom"),typeof s=="number"){let B=s,$=`${M},${_}`,Z={"center,bottom":[0,B],"right,bottom":[-B,B],"right,center":[-B,0],"right,top":[-B,-B],"center,top":[0,-B],"left,top":[B,-B],"left,center":[B,0],"left,bottom":[B,B]}[$]??[0,B];c=new A(Z[0],Z[1])}return{halign:M,valign:_,ofst:c}}let m=t-n;e==="left"?m+=90:e==="bottom"?m+=180:e==="right"&&(m+=270),m=(m%360+360)%360;let f=Math.round(m/360*8)%8,[g,b]=Vp[f];if(typeof s=="number"){let v=s,x,S;e==="bottom"?(x=0,S=-v):e==="left"?(x=-v,S=0):e==="right"?(x=v,S=0):(x=0,S=v),c=new A(x,S)}return{halign:g,valign:b,ofst:c}}function Up(r,e,t){if(r===void 0||typeof r=="number")return r;let n=r instanceof A?r:A.fromXY(r);return e&&(n=n.flip()),t&&(n=n.mirrorx(0)),[n.x,n.y]}function Il(r,e,t){let n=r.getBBox(!1,!1),s=n.xmin,i=n.xmax,o=n.ymin,a=n.ymax;Number.isFinite(i+s+a+o)||(s=i=o=a=.1);let l={xmin:s,xmax:i,ymin:o,ymax:a},h=(i+s)/2,c=(a+o)/2,m=r.params,f=T(m,"lblloc","top"),g=T(m,"lblofst",.1),b=T(m,"lblalign",[void 0,void 0]),v=m.flip===!0,x=m.reverse===!0,S=m.ignore_hints===!0;for(let k of t){let M=mc(Gp(k.loc,f),e),_=Array.isArray(k.text)?k.text:[k.text];if(_.length===0)continue;let B=S?void 0:r.getLabelHint(M),$=k.valign??B?.valign,Y=k.halign??B?.halign;v&&($==="top"?$="bottom":$==="bottom"&&($="top")),x&&(Y==="left"?Y="right":Y==="right"&&(Y="left"));let Z=Up(k.ofst??B?.ofst,v,x);Z===void 0&&(Z=g);let L=Y??b[0],I=$??b[1],X=dc(k,e),re=pc(r,M,e,X,Z,l),te=L??re.halign,ke=I??re.valign,he=re.ofst,ve=m._shift_magnitude;ve!==void 0&&(M==="top"||M==="bottom")&&(he=he.add(new A(ve,0)));let de;k.rotate===!0?de=0:typeof k.rotate=="number"&&(de=k.rotate);let Fe=k.fontsize??B?.fontsize??T(m,"fontsize",14),qe=k.color??T(m,"color","black"),Ie=k.font??T(m,"font","sans-serif"),ge=k.mathfont??T(m,"mathfont",void 0),Me={fontsize:Fe,color:qe,fontfamily:Ie,align:[te,ke],href:k.href??void 0,decoration:k.decoration??void 0};if(ge!==void 0&&ge!==""&&(Me.mathfont=ge),de!==void 0&&(Me.rotation=de),Array.isArray(k.text)){if(!Wp.has(M))throw new Error(`Array element labels require loc top|bottom|left|right|center (after lblloc), got ${M}`);let Be=_.length,De=(i-s)/(Be+1),ye=(a-o)/(Be+1);for(let _e=0;_e<Be;_e++){let Ae;M==="top"?Ae=new A(s+De*(_e+1),a):M==="bottom"?Ae=new A(s+De*(_e+1),o):M==="left"?Ae=new A(s,o+ye*(_e+1)):M==="right"?Ae=new A(i,o+ye*(_e+1)):Ae=new A(s+De*(_e+1),0),Ae=Ae.add(he),r.segments.push(new W([Ae.x,Ae.y],_[_e],Me))}continue}let be;if(M in r.anchors){let Be=r.anchors[M];be=new A(Be instanceof A?Be.x:Be[0],Be instanceof A?Be.y:Be[1])}else if(M==="top")be=new A(h,a);else if(M==="bottom")be=new A(h,o);else if(M==="left")be=new A(s,c);else if(M==="right")be=new A(i,c);else if(M==="center")be=new A(h,c);else throw new Error(`Unknown label location ${M}`);be=be.add(he),r.segments.push(new W([be.x,be.y],_[0],Me))}}function Ll(r,e){let t=[],n=T(r,"lblloc","top"),s=T(r,"fontsize",14),i=r.color??"black",o=r.lblrotate===!0,a=r.mathfont!=null&&r.mathfont!==""?String(r.mathfont):void 0,l=(h,c)=>{if(h!=null)if(Array.isArray(h)){if(h.length===0)return;t.push({text:h.map(String),loc:c,fontsize:s,color:i,rotate:o?!0:void 0,mathfont:a})}else h!==""&&t.push({text:String(h),loc:c,fontsize:s,color:i,rotate:o?!0:void 0,mathfont:a})};return r.toplabel!=null&&l(r.toplabel,"top"),r.botlabel!=null&&l(r.botlabel,"bottom"),r.lftlabel!=null&&l(r.lftlabel,"left"),r.rgtlabel!=null&&l(r.rgtlabel,"right"),r.clabel!=null&&l(r.clabel,"center"),r.label!=null&&l(r.label,n),t}function Jp(r){(r instanceof p||r instanceof D||r instanceof W||r instanceof U||r instanceof xe||r instanceof Ut||r instanceof ut||r instanceof Br)&&r.doflip()}function Kp(r,e){(r instanceof p||r instanceof D||r instanceof W||r instanceof U||r instanceof xe||r instanceof Ut||r instanceof ut||r instanceof Br)&&r.doreverse(e)}function fc(r){return r instanceof A?[r.x,r.y]:[r[0],r[1]]}var gc=["start","end","center","istart","iend","N","S","E","W","NE","NW","SE","SW","NNE","NNW","ENE","WNW","SSE","SSW","ESE","WSW"],N=class r{constructor(e={}){z(this,"userParams",{});z(this,"elmParams",{});z(this,"dwgParams",{});z(this,"defaults",{});z(this,"segments",[]);z(this,"anchors",{});z(this,"absanchors",{});z(this,"transform");z(this,"absdrop");z(this,"_positioned",!1);z(this,"_localshift",new A(0,0));z(this,"bbox",He(0,0,0,0));z(this,"userLabels",[]);z(this,"_labelhints",{});z(this,"_segmentCountBeforeLabels",0);Object.assign(this.userParams,e),At(this)}get params(){let e=f0();return Mr(this.userParams,this.elmParams,this.defaults,this.dwgParams,e)}getAbsAnchor(e){return this.absanchors[e]}getAnchorNamesForGetattr(){let e=new Set(gc);for(let t of Object.keys(this.anchors))e.add(t);return[...e]}touchAnchorAccess(e){e in this.absanchors||this.getAnchorNamesForGetattr().includes(e)&&At(this)}resolveAnchor(e){return this.touchAnchorAccess(e),this.getAbsAnchor(e)}_position(){let e=this.userParams.at;if(Array.isArray(e)&&e.length===2&&typeof e[1]=="string"&&e[0]instanceof r){let t=e[0],n=e[1];if(!(n in t.absanchors))throw new Error(`Unknown anchor name ${n}`);let s=t.absanchors[n];this.userParams.at=[s.x,s.y]}this._flipreverse(),this._positioned=!0}_flipreverse(){if(this.userParams.flip===!0){for(let e of this.segments)Jp(e);for(let e of Object.keys(this.anchors)){let t=A.fromXY(fc(this.anchors[e]));this.anchors[e]=t.flip().toTuple()}}if(this.userParams.reverse===!0){let e;if(this.anchors.center!==void 0)e=fc(this.anchors.center)[0];else{let t=this.getBBox(!1,!1);e=(t.xmin+t.xmax)/2}for(let t of this.segments)Kp(t,e);for(let t of Object.keys(this.anchors)){let n=A.fromXY(fc(this.anchors[t]));this.anchors[t]=n.mirrorx(e).toTuple()}}}up(){return this.userParams.d="up",this}down(){return this.userParams.d="down",this}left(){return this.userParams.d="left",this}right(){return this.userParams.d="right",this}theta(e){return this.userParams.theta=e,this}drop(e){return this.userParams.drop=e,this}at(e,t=0,n=0){if(Array.isArray(e)&&e.length===2&&typeof e[1]=="string"&&e[0]instanceof r){if(t!==0||n!==0)throw new Error("dx and dy must be zero when at is [Element, anchorName]");this.userParams.at=e}else{let s=A.fromXY(e);this.userParams.at=[s.x+t,s.y+n]}return this}scale(e=1){return this.userParams.zoom=new A(e,e),this}scalex(e=1){let t=this.userParams.zoom,n=new A(1,1);return typeof t=="number"?n=new A(t,t):t instanceof A?n=t:Array.isArray(t)&&t.length>=2&&(n=new A(Number(t[0]),Number(t[1]))),this.userParams.zoom=new A(e,n.y),this}scaley(e=1){let t=this.userParams.zoom,n=new A(1,1);return typeof t=="number"?n=new A(t,t):t instanceof A?n=t:Array.isArray(t)&&t.length>=2&&(n=new A(Number(t[0]),Number(t[1]))),this.userParams.zoom=new A(n.x,e),this}flip(){return this.userParams.flip=!0,this}reverse(){return this.userParams.reverse!==void 0?this.userParams.reverse=!this.userParams.reverse:this.userParams.reverse=!0,this}anchor(e){return this.userParams.anchor=e,this}color(e){return Vr(e),this.userParams.color=e,this}linestyle(e){return Wa(e),this.userParams.ls=e,this}linewidth(e){return this.userParams.lw=e,this}fill(e=!0){return Vr(e),this.userParams.fill=e,this}zorder(e){return this.userParams.zorder=e,this}hold(){return this.userParams.move_cur=!1,this}style(e){return e.color!==void 0&&this.color(e.color),e.fill!==void 0&&this.fill(e.fill),e.ls!==void 0&&this.linestyle(e.ls),e.lw!==void 0&&(this.userParams.lw=e.lw),this}fontsize(e){return this.userParams.fontsize=e,this}font(e){return this.userParams.font=e,this}mathfont(e){return this.userParams.mathfont=e,this}gradientFill(e,t,n=!0){return this.userParams.gradient=[e,t,n],this}label(e,t={}){return this.userLabels.push({text:e,...t}),this}getLabelHint(e){return this._labelhints[e]}_place(e,t,n){this.dwgParams={...n},this._positioned||this._position(),this._segmentCountBeforeLabels===0&&(this._segmentCountBeforeLabels=this.segments.length),this.segments.splice(this._segmentCountBeforeLabels);let s=T(this.params,"anchor",void 0),i=this.params.zoom??this.params.scale??1,o=typeof i=="number"?new A(i,i):Array.isArray(i)?new A(i[0],i[1]):i,a=this.params.at!==void 0?A.fromXY(this.params.at):A.fromXY(e),l;if(this.params.endpts!==void 0)l=t;else if(this.params.d!==void 0){let f=this.params.d;if(/^-?\d+(\.\d+)?$/.test(String(f).replace("-","")))l=Number(f);else{let g=String(f).toLowerCase()[0];l={u:90,r:0,l:180,d:270}[g]??0}}else l=this.params.theta??t;if(s!==void 0){let f=this.anchors[s];if(f===void 0)throw new Error(`Unknown anchor ${s}`);let g=f instanceof A?f.x:f[0],b=f instanceof A?f.y:f[1];this._localshift=new A(-g,-b)}this.transform=new p0(l,[a.x,a.y],this._localshift.toTuple(),o);let h=[...Ll(this.params,l),...this.userLabels];h.length>0&&Il(this,l,h);for(let[f,g]of Object.entries(this.anchors)){let b=g instanceof A?g.x:g[0],v=g instanceof A?g.y:g[1];this.absanchors[f]=this.transform.transform([b,v])}this.absanchors.xy=this.transform.transform([0,0]);let c=this.params.drop,m=f=>{if(f instanceof A)return[f.x,f.y];if(Array.isArray(f)&&f.length>=2)return[Number(f[0]),Number(f[1])];throw new Error("invalid drop")};if(c!==void 0&&typeof c=="string"&&c in this.anchors){let f=this.anchors[c],g=f instanceof A?f.x:f[0],b=f instanceof A?f.y:f[1];this.absdrop={point:this.transform.transform([g,b]),theta:l}}else c!=null&&this.params.move_cur!==!1?this.params.droptheta!==void 0?this.absdrop={point:this.transform.transform(m(c)),theta:this.params.droptheta}:this.params.theta===0?this.absdrop={point:this.transform.transform(m(c)),theta:t}:this.absdrop={point:this.transform.transform(m(c)),theta:l}:this.absdrop={point:A.fromXY(e),theta:t};return this.bbox=this.getBBox(!1,!1),this.absdrop}getBBox(e,t=!0){let n=1/0,s=1/0,i=-1/0,o=-1/0;for(let a of this.segments){if(!t&&a instanceof W)continue;let l;e?l=a.xform(this.transform,this.params).getBBox():l=a.getBBox(),n=Math.min(n,l.xmin),s=Math.min(s,l.ymin),i=Math.max(i,l.xmax),o=Math.max(o,l.ymax)}return He(n,s,i,o)}_draw(e){this.segments.length===0&&this._place([0,0],0,{});for(let t of this.segments)t instanceof p?t.draw(e,this.transform,this.params):t instanceof D?t.draw(e,this.transform,this.params):t instanceof W?t.draw(e,this.transform,this.params):t instanceof U?t.draw(e,this.transform,this.params):t instanceof xe?t.draw(e,this.transform,this.params):t instanceof Ut?t.draw(e,this.transform,this.params):t instanceof ut?t.draw(e,this.transform,this.params):t instanceof Br&&t.draw(e,this.transform,this.params)}};var P0=class r extends N{constructor(t,n={}){super(n);this.parent=t;z(this,"inner",[]);Object.assign(this.defaults,{cornerradius:.3,padx:.75,pady:.75,theta:0,anchor:"boxNW"})}container(t={}){return new r(this,{...t})}add(t){return this.inner.push(t),this.parent.add(t),t}containsElement(t){return this.inner.includes(t)}enter(){Xa(this)}exit(){At(this),Ga(this)}containerBBox(t=!0){let n=1/0,s=1/0,i=-1/0,o=-1/0;for(let a of this.inner){let l=a.getBBox(t,!1);n=Math.min(n,l.xmin),s=Math.min(s,l.ymin),i=Math.max(i,l.xmax),o=Math.max(o,l.ymax)}return Number.isFinite(n)?He(n,s,i,o):He(0,0,0,0)}getBBox(t,n=!0){let s=this.containerBBox(t),i=T(this.params,"padx",.75),o=T(this.params,"pady",.75);return He(s.xmin-i,s.ymin-o,s.xmax+i,s.ymax+o)}_place(t,n,s){this.dwgParams={...s};let i=this.containerBBox(!1),o=T(this.params,"padx",.75),a=T(this.params,"pady",.75),l=i.xmax-i.xmin+o*2,h=i.ymax-i.ymin+a*2,c=T(this.params,"cornerradius",0);return this.elmParams.at=[i.xmin-o,i.ymax+a],this.segments=[],c>0?this.segments.push(new U([[0,h/2],[l,h/2],[l,-h/2],[0,-h/2]],{closed:!0,cornerradius:c})):this.segments.push(new p([[0,0],[0,h/2],[l,h/2],[l,-h/2],[0,-h/2],[0,0]])),this.anchors.center=[l/2,0],this.anchors.boxNW=[0,h/2],this.anchors.N=[l/2,h/2],this.anchors.E=[l,0],this.anchors.S=[l/2,-h/2],this.anchors.W=[0,0],super._place(t,n,s)}};function bc(r){return r.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<")}function Zp(r,e,t,n){let s=n?"0%":"100%",i=n?"100%":"0%";return`<linearGradient id="${bc(r)}" x1="0%" y1="0%" x2="${s}" y2="${i}"><stop offset="0%" stop-color="${bc(e)}"/><stop offset="100%" stop-color="${bc(t)}"/></linearGradient>`}function Qm(r){let e=[],t=0,n=[];for(let s of r){let o=Mr(s.userParams,s.elmParams,s.defaults,s.dwgParams).gradient;if(o&&Array.isArray(o)&&o.length>=2){let a=`sdg${t++}`;e.push(Zp(a,String(o[0]),String(o[1]),o[2]!==!1)),s.elmParams._svgGradientFillId=a,n.push(()=>{delete s.elmParams._svgGradientFillId})}}return{defsXml:e.join(""),cleanup:()=>{for(let s of n)s()}}}function wc(r){return r.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<")}var e1={black:"#000000",white:"#ffffff",red:"#ff0000",green:"#008000",blue:"#0000ff",gray:"#808080",grey:"#808080",silver:"#c0c0c0",maroon:"#800000",navy:"#000080"};function t1(r){let e=r.trim().toLowerCase();if(e1[e])return e1[e];if(e.startsWith("#"))return e.length===4&&e[1]&&e[2]&&e[3]?`#${e[1]}${e[1]}${e[2]}${e[2]}${e[3]}${e[3]}`:(e.length===7,e);let t=e.match(/^rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/);if(t){let n=Number(t[1]).toString(16).padStart(2,"0"),s=Number(t[2]).toString(16).padStart(2,"0"),i=Number(t[3]).toString(16).padStart(2,"0");return`#${n}${s}${i}`}return e}function Qp(r,e){return t1(r)===t1(e)}function r1(r){return Mr(r.userParams,r.elmParams,r.defaults,r.dwgParams).color??"black"}var e2=new Set(["xy","center","istart","iend","mid","label","vd","vs","n1","n2","n1a","n2a"]);function t2(r){return!e2.has(r)}function n1(r){let e=[];for(let[t,n]of Object.entries(r.absanchors))t2(t)&&e.push(n);return e}function o1(r){let e=[],t=new Set,n=.5;for(let s=0;s<r.length;s++){let i=r[s],o=r1(i),a=n1(i);if(a.length!==0)for(let l=s+1;l<r.length;l++){let h=r[l],c=r1(h);if(Qp(o,c))continue;let m=n1(h);if(m.length!==0)for(let f of a){for(let g of m){if(Math.hypot(f.x-g.x,f.y-g.y)>n)continue;let b=`${s}|${l}`;if(!t.has(b)){t.add(b),e.push({elA:i,elB:h,colorA:o,colorB:c,junctionPt:f});break}}if(t.has(`${s}|${l}`))break}}}return e}function Dl(r){return Number.isInteger(r)?String(r):r.toFixed(4).replace(/0+$/,"").replace(/\.$/,"")}function a1(r,e,t){if(e.length===0)return{defsXml:"",cleanup:()=>{}};let n=[],s=[],i=0;for(let o of e){let a=s1(o.elA,o.junctionPt),l=s1(o.elB,o.junctionPt);if(!a&&!l||a?.gradientStrokeId&&l?.gradientStrokeId)continue;let h,c,m,f;if(a&&l){let b=Nl(o.elA,a,t),v=Nl(o.elB,l,t),x=i1(o.elA,a,o.junctionPt,t),S=i1(o.elB,l,o.junctionPt,t);h=x.farX,c=x.farY,m=S.farX,f=S.farY}else if(a){let b=Nl(o.elA,a,t);h=b.x1,c=b.y1,m=b.x2,f=b.y2}else{let b=Nl(o.elB,l,t);h=b.x1,c=b.y1,m=b.x2,f=b.y2}if(n2({x1:h,y1:c,x2:m,y2:f})<1e-6)continue;let g=`sd-trans-${i++}`;n.push(s2(g,h,c,m,f,o.colorA,o.colorB)),a&&!a.gradientStrokeId&&(a.gradientStrokeId=g,s.push(()=>{a.gradientStrokeId=void 0})),l&&!l.gradientStrokeId&&(l.gradientStrokeId=g,s.push(()=>{l.gradientStrokeId=void 0}))}return{defsXml:n.join(""),cleanup:()=>{for(let o of s)o()}}}function s1(r,e){for(let i of r.segments)if(i instanceof p&&!(i.role!=="lead1"&&i.role!=="lead2")&&r2(r,i,e,.6))return i;let n,s=1/0;for(let i of r.segments){if(!(i instanceof p)||i.path.length<2||i.role==="body"||i.path.length>6)continue;let o=l1(r,i,e);o<s&&o<.6&&(s=o,n=i)}return n}function r2(r,e,t,n){return l1(r,e,t)<n}function l1(r,e,t){let n=r.transform.transform(e.path[0]),s=r.transform.transform(e.path[e.path.length-1]);return Math.min(Math.hypot(n.x-t.x,n.y-t.y),Math.hypot(s.x-t.x,s.y-t.y))}function i1(r,e,t,n){let s=r.transform.transform(e.path[0]),i=r.transform.transform(e.path[e.path.length-1]),o=Math.hypot(s.x-t.x,s.y-t.y),a=Math.hypot(i.x-t.x,i.y-t.y),l=o>a?s:i;return{farX:l.x*n,farY:-l.y*n}}function Nl(r,e,t){let n=r.transform.transform(e.path[0]),s=r.transform.transform(e.path[e.path.length-1]);return{x1:n.x*t,y1:-n.y*t,x2:s.x*t,y2:-s.y*t}}function n2(r){return Math.hypot(r.x2-r.x1,r.y2-r.y1)}function s2(r,e,t,n,s,i,o){return`<linearGradient id="${wc(r)}" gradientUnits="userSpaceOnUse" x1="${Dl(e)}" y1="${Dl(t)}" x2="${Dl(n)}" y2="${Dl(s)}"><stop offset="0%" stop-color="${wc(i)}"/><stop offset="100%" stop-color="${wc(o)}"/></linearGradient>`}function i2(r,e){let t=r;for(;t;){if(Object.prototype.hasOwnProperty.call(t,e)||Object.getOwnPropertyDescriptor(t,e)!==void 0)return!0;t=Object.getPrototypeOf(t)}return!1}var lr=class{constructor(e={}){z(this,"elements",[]);z(this,"anchors",{});z(this,"svgdefs",[]);z(this,"dwgparams",{});z(this,"_here",new A(0,0));z(this,"_theta",0);z(this,"_state",[]);z(this,"outfile");z(this,"_elementMeta",new Map);let t=f0();return this.dwgparams=oa(t,e),e.file!==void 0&&(this.outfile=e.file),o2(this)}setElementMeta(e,t){this._elementMeta.set(e,t)}getElementMeta(e){return this._elementMeta.get(e)}get here(){return At(null),this._here}set here(e){At(null),this._here=e instanceof A?e:A.fromXY(e)}get theta(){return At(null),this._theta}set theta(e){this._theta=e}get unit(){return this.dwgparams.unit??3}set unit(e){this.dwgparams.unit=e}getAnchor(e){let t=this.anchors[e];return t===void 0?void 0:new A(t[0],t[1])}enter(){Xa(this)}exit(){At(null),Ga(this)}containsElement(e){return this.elements.includes(e)}add(e){let t=e._place(this._here.toTuple(),this._theta,this.dwgparams);return this.elements.push(e),this._here=t.point,this._theta=t.theta,e}undo(){if(this.elements.pop(),this.elements.length>0){let e=this.elements[this.elements.length-1];this._here=e.absdrop.point,this._theta=e.absdrop.theta}else this._here=new A(0,0),this._theta=0}config(e){this.dwgparams=oa(this.dwgparams,e)}addElements(...e){for(let t of e)this.add(t)}container(e){return new P0(this,{...e??{}})}move(e=0,t=0){this._here=this._here.add([e,t])}moveFrom(e,t=0,n=0,s){this._here=e.add([t,n]),s!==void 0&&(this._theta=s)}push(){this._state.push([new A(this._here.x,this._here.y),this._theta])}pop(){let e=this._state.pop();e!==void 0&&(this._here=e[0],this._theta=e[1])}withHold(e){this.push();try{return e()}finally{this.pop()}}hold(){this.push();let e=this;return{close:()=>{e.pop()}}}addSvgDef(e){this.svgdefs.push(e)}setAnchor(e){this.anchors[e]=this._here.toTuple()}getSegments(){let e=[];for(let t of this.elements){let n=Mr(t.userParams,t.elmParams,t.defaults);for(let s of t.segments)e.push(s.xform(t.transform,n))}return e}async save(e){try{let{writeFileSync:t}=await import("node:fs");t(e,this.toSvgString(),"utf8")}catch(t){throw t instanceof Error&&/Cannot find module|not supported|Failed to resolve|dynamically imported module|Module not found/.test(t.message)?new Error("Drawing.save() requires Node.js. In the browser, use drawing.toSvgString() instead."):t}}getBBox(){let e=1/0,t=1/0,n=-1/0,s=-1/0;for(let i of this.elements){let o=i.getBBox(!0,!0);e=Math.min(e,o.xmin),t=Math.min(t,o.ymin),n=Math.max(n,o.xmax),s=Math.max(s,o.ymax)}return Number.isFinite(e)?He(e,t,n,s):He(0,0,0,0)}toSvgString(){let e=this.getBBox(),{defsXml:t,cleanup:n}=Qm(this.elements),s="",i=()=>{};if(this.dwgparams.colorTransition){let o=this.dwgparams.inches_per_unit??.5,a=72*o,l=o1(this.elements),h=a1(this.elements,l,a);s=h.defsXml,i=h.cleanup}try{let o=[this.svgdefs.join(""),t,s].filter(h=>h.length>0),a=new g0(e,{inchesPerUnit:this.dwgparams.inches_per_unit,margin:this.dwgparams.margin,extraDefs:o.length>0?o.join(""):void 0}),l=this.dwgparams.bgcolor;l&&a.bgcolor(l);for(let h of this.elements){let c=this._elementMeta.get(h);if(this.dwgparams.interactive&&c){let m={"data-id":c.id,"data-type":c.type,class:"sd-el"};c.tooltip&&(m["data-tooltip"]=c.tooltip);let f=c.tooltip||`${c.id} \u2014 ${c.type}`;a.beginGroup(m,f)}h._draw(a),this.dwgparams.interactive&&c&&a.endGroup()}return a.toSvgString()}finally{n(),i()}}getImageData(e="svg"){if((typeof e=="string"?e.toLowerCase():String(e).toLowerCase())!=="svg")throw new Error(`@skillpet/circuit: getImageData('${e}') is not supported; only SVG bytes are available in this build.`);return new TextEncoder().encode(this.toSvgString())}};function o2(r){return new Proxy(r,{get(e,t,n){if(typeof t=="symbol")return Reflect.get(e,t,n);if(!i2(e,t)&&t in e.anchors){let s=e.anchors[t];return new A(s[0],s[1])}return Reflect.get(e,t,n)}})}function h1(r,e){let t=new lr(e??{});t.enter();try{r(t)}finally{t.exit()}return t}function xc(r){return r instanceof A?[r.x,r.y]:[r[0],r[1]]}var se=class extends N{_place(e,t,n){this.dwgParams={...n},this._positioned||this._position();let s=T(this.params,"unit",3),i=T(this.params,"l",s),o=this.params.endpts,a=this.params.to,l=this.params.tox,h=this.params.toy,c=this.params.anchor,m=this.params.zoom??this.params.scale??1,f=typeof m=="number"?m:Array.isArray(m)?m[0]:m.x,g=A.fromXY(this.params.at!==void 0?this.params.at:e),b=this.params.theta!==void 0?this.params.theta:t;if(o!==void 0)b=ia(o[0],o[1]);else if(a!==void 0)b=ia(g,a);else if(this.params.d!==void 0){let M=String(this.params.d);if(/^-?\d+(\.\d+)?$/.test(M.replace("-","")))b=Number(M);else{let _=M.toLowerCase()[0];b={u:90,r:0,l:180,d:270}[_]??0}}if(this.elmParams.theta=b,o!==void 0&&(g=A.fromXY(o[0])),o!==void 0)i=Qs(o[0],o[1]);else if(a!==void 0)i=Qs(g,a);else if(l!==void 0){let M=typeof l=="number"?l:l[0],_=this.params.theta;if(_!==void 0){let B=g.x-M,$=Math.tan(_*Math.PI/180)*B;i=Math.hypot(B,$)}else{let B=new A(M,g.y);i=Qs(g,B),b=g.x>M?180:0,this.elmParams.theta=b}}else if(h!==void 0){let M=typeof h=="number"?h:h[1],_=this.params.theta;if(_!==void 0){let B=g.y-M,$=B/Math.tan(_*Math.PI/180);i=Math.hypot($,B)}else{let B=new A(g.x,M);i=Qs(g,B),b=g.y>M?-90:90,this.elmParams.theta=b}}let v=this.segments[0];if(!(v instanceof p))throw new Error("Element2Term requires first segment to be Segment");this.anchors.istart=v.path[0],this.anchors.iend=v.path[v.path.length-1];let x,S;if(T(this.params,"extend",!0)){let M=v.path,_=qa(M[M.length-1],M[0]),B=Math.hypot(_.x,_.y),$;try{let Y=m,Z=typeof Y=="number"?Y:Y.x;$=(i-B*Z)/2/Z}catch{$=(i-B*f)/2/f}if($>0){let Z=T(this.params,"shift",0)*$;this.elmParams._shift_magnitude=Z;let L=A.fromXY(M[0]),I=A.fromXY(M[M.length-1]);x=L.sub([$+Z,0]),S=I.add([$-Z,0]),this._localshift=x.neg();let X={color:v.color,lw:v.lw,ls:v.ls,capstyle:v.capstyle,joinstyle:v.joinstyle,fill:v.fill,zorder:v.zorder},j=new p([[x.x,x.y],[L.x,L.y]],{...X});j.role="lead1";let re=M.map(de=>[de[0],de[1]]),te=new p(re,{...X});te.role="body";let ke=new p([[I.x,I.y],[S.x,S.y]],{...X});ke.role="lead2";let he=this.params.leadcolor;B>0&&he&&(j.color=he,ke.color=he);let ve=this.segments.indexOf(v);this.segments.splice(ve,1,j,te,ke)}else x=A.fromXY(M[0]),S=A.fromXY(M[M.length-1]),this._localshift=new A(0,0)}else x=A.fromXY(v.path[0]),S=A.fromXY(v.path[v.path.length-1]);let k=T(this.params,"dotradius",.075);if(this.params.dot){let _=this.params.dot==="open"?"bg":!0;this.segments.push(new D([S.x,S.y],k,{fill:_,zorder:3}))}if(this.params.idot){let _=this.params.idot==="open"?"bg":!0;this.segments.push(new D([x.x,x.y],k,{fill:_,zorder:3}))}if(this.placeAnchors(x,S),c!==void 0){let M=this.anchors[c];if(M===void 0)throw new Error(`Unknown anchor ${c}`);let _=M instanceof A?M.x:M[0],B=M instanceof A?M.y:M[1];this._localshift=this._localshift.sub([_,B])}return this.elmParams.drop=[S.x,S.y],super._place(e,t,n)}placeAnchors(e,t){this.anchors.start=[e.x,e.y],this.anchors.end=[t.x,t.y],this.anchors.center=[(e.x+t.x)/2,(e.y+t.y)/2]}to(e,t=0,n=0){let s=A.fromXY(xc(e));return this.userParams.to=[s.x+t,s.y+n],this}tox(e){return this.userParams.tox=e,this}toy(e){return this.userParams.toy=e,this}length(e){return this.userParams.l=e,this}endpoints(e,t){return this.userParams.endpts=[xc(e),xc(t)],this}dot(e=!1){return this.userParams.dot=e?"open":!0,this}idot(e=!1){return this.userParams.idot=e?"open":!0,this}shift(e){return this.userParams.shift=e,this}up(e){return this.userParams.d="up",e!==void 0&&(this.userParams.l=e),this}down(e){return this.userParams.d="down",e!==void 0&&(this.userParams.l=e),this}left(e){return this.userParams.d="left",e!==void 0&&(this.userParams.l=e),this}right(e){return this.userParams.d="right",e!==void 0&&(this.userParams.l=e),this}};var Ol=class extends N{constructor(t,n={}){super(n);z(this,"drawing");this.drawing=t,this.segments=t.getSegments();for(let[i,o]of Object.entries(t.anchors))this.anchors[i]=[o[0],o[1]];let s=t.here;this.elmParams.drop=[s.x,s.y],this.elmParams.d="right"}};var rn=1,Pn=.65,vc=.12,Bt=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{leadin:.35,leadout:.35});let t=e.inputs??2,n=e.nand??!1,s=T(this.params,"leadin",.35),i=T(this.params,"leadout",.35),o=rn/2,a=ze(-Math.PI/2,Math.PI/2,50),l=a.map(b=>o*Math.cos(b)+Pn+s),h=a.map(b=>o*Math.sin(b)),c=l.map((b,v)=>[b,h[v]]);c.push([Pn+s,o],[s,o],[s,0],[s,-o],[Pn+s,-o]),this.segments.push(new p(c)),this.anchors.out=[Pn+rn/2+s+i,0],this.anchors.end=this.anchors.out,n&&this.segments.push(new D([s+Pn+rn/2+vc,0],vc));let m;t===2?m=rn*.5:t===3?m=rn*.33:m=rn*.4;for(let b=0;b<t;b++){let v=(b+1-(t/2+.5))*m,x=t-b;this.anchors[`in${x}`]=[0,v],this.segments.push(new p([[0,v],[s,v]]))}let f=n?Pn+rn/2+s+vc*2:Pn+rn/2+s;this.segments.push(new p([[f,0],[Pn+rn/2+s+i,0]]));let g=this.segments[this.segments.length-1];if(g instanceof p){let b=g.path[g.path.length-1];this.elmParams.drop=[b[0],b[1]]}}};function Tn(r){return new Bt({...r,nand:!0})}var yc=1,a2=.65,Sc=.12,l2=.5,c1=.15,$t=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{leadin:.35,leadout:.35});let t=e.inputs??2,n=e.nor??!1,s=e.xor??!1,i=T(this.params,"leadin",.35),o=T(this.params,"leadout",.35),a=i-(s?c1:0),l=ze(0,a2+.05,50),h=l.map(L=>L*L),c=Math.max(...h);h=h.map(L=>L-c),h=[Math.min(...h),...h];let m=[0,...l.map(L=>L+l2)],f=Math.min(...h),g=ze(f,-f,50),b=g.map(L=>-L*L),v=Math.min(...b);b=b.map(L=>L-v);let x=m.map(L=>L+i),S=b.map(L=>L+i),k=Math.max(...x),M=Math.abs(f),_=h.map(L=>-L),B=[...x.map((L,I)=>[L,h[I]]),...[...x].reverse().map((L,I)=>{let X=_.length-1-I;return[L,_[X]]}),...[...S].reverse().map((L,I)=>[L,g[g.length-1-I]])];if(this.segments.push(new p(B)),this.anchors.out=[k+o,0],this.anchors.end=this.anchors.out,s){let L=S.map(I=>I-c1);this.segments.push(new p(L.map((I,X)=>[I,g[X]])))}n&&this.segments.push(new D([k+Sc,0],Sc));let $,Y=0;t===2?$=yc*.5:t===3?$=yc*.33:($=yc*.4,Y=$*(t-1));for(let L=0;L<t;L++){let I=(L+1-(t/2+.5))*$,X=a-I*I-v;t>3&&(I>M||I<-M)&&(X=a);let j=t-L;this.anchors[`in${j}`]=[0,I],this.segments.push(new p([[0,I],[X,I]]))}t>3&&(this.segments.push(new p([[a,Y/2+$/2],[a,M]])),this.segments.push(new p([[a,-Y/2-$/2],[a,-M]]))),n?this.segments.push(new p([[k+Sc*2,0],[k+o,0]])):this.segments.push(new p([[k,0],[k+o,0]]));let Z=this.segments[this.segments.length-1];if(Z instanceof p){let L=Z.path[Z.path.length-1];this.elmParams.drop=[L[0],L[1]]}}};function Rn(r){return new $t({...r,nor:!0})}function An(r){return new $t({...r,xor:!0})}function _n(r){return new $t({...r,nor:!0,xor:!0})}var T0=1,r0=.65,Fl=.12,Jt=class extends se{constructor(e={}){super(e),this.segments.push(new p([[0,0],H,[r0,0]])),this.segments.push(new p([[0,T0/2],[r0,0],[0,-T0/2],[0,T0/2]])),this.anchors.out=[r0,0],this.anchors.in1=[0,0]}},Kt=class extends se{constructor(e={}){super(e),this.segments.push(new p([[0,0],H,[r0+Fl*2,0]])),this.segments.push(new p([[0,T0/2],[r0,0],[0,-T0/2],[0,T0/2]])),this.segments.push(new D([r0+Fl,0],Fl)),this.anchors.out=[r0+Fl*2,0],this.anchors.in1=[0,0]}};var kc=1,hr=.65,R0=.12,Bn=class extends se{constructor(e={}){super(e),Object.assign(this.defaults,{outputnot:!0,control:!1});let t=T(this.params,"outputnot",!0),n=T(this.params,"control",!1);t?(this.segments.push(new p([[0,0],H,[hr+R0*2,0]])),this.segments.push(new D([hr+R0,0],R0))):this.segments.push(new p([[0,0],H,[hr,0]])),this.segments.push(new p([[0,kc/2],[hr,0],[0,-kc/2],[0,kc/2]])),n?(this.segments.push(new D([hr/2,.42],R0)),this.segments.push(new p([[hr/2,.42+R0],[hr/2,.7]]))):this.segments.push(new p([[hr/2,.28],[hr/2,.7]])),this.anchors.out=[hr+R0*2,0],this.anchors.in1=[0,0],this.anchors.c=[hr/2,.7]}};var A0=class extends N{constructor(e={}){let{names:t,truthtable:n,groups:s,default:i,...o}=e;super(o);let a=t??"ABCD",l=n??[],h=s??{},c=i??"0",m=o.lw??1.25,f,g;if(a.length===4)f=4,g=4;else if(a.length===3)f=2,g=4;else if(a.length===2)f=2,g=2;else throw new Error("Kmap requires 2 to 4 variable names");let b=1,v=g*b,x=f*b,S=[0,1,3,2],k={lw:m};this.segments.push(new p([[0,0],[v,0],[v,x],[0,x],[0,0]],k));for(let j=0;j<f;j++)this.segments.push(new p([[0,j*b],[v,j*b]],k));for(let j=0;j<g;j++)this.segments.push(new p([[j*b,0],[j*b,x]],k));let M=b/Math.SQRT2;this.segments.push(new p([[0,x],[-M,x+M]],k));let _=f>2?2:1,B=g>2?2:1,$=a.length>2?a.slice(0,2):a[0],Y=a.length>2?a.slice(2):a[1];this.segments.push(new W([0,x+3*M/4],$,{align:["right","bottom"],fontsize:12})),this.segments.push(new W([-(3*M)/4,x],Y,{align:["right","bottom"],fontsize:12}));for(let j=0;j<g;j++){let re=S[j];this.segments.push(new W([re*b+b/2,x+b/20],$l(j,B),{align:["center","bottom"],fontsize:10}))}for(let j=0;j<f;j++){let re=S[j];this.segments.push(new W([-b/10,x-re*b-b/2],$l(j,_),{align:["right","center"],fontsize:10}))}let Z=l.map(j=>j[0]),L=l.map(j=>j[1]);for(let j=0;j<g;j++){let re=S[j];for(let te=0;te<f;te++){let ke=S[te],he=$l(j,B)+$l(te,_),ve=Z.indexOf(he),de=ve===-1?c:String(L[ve]);this.segments.push(new W([re*b+b/2,x-ke*b-b/2],de,{align:["center","center"],fontsize:12})),this.anchors[`cell${he}`]=[re*b+b/2,x-ke*b-b/2]}}let I=.1,X={0:0,1:1,".":0,"..":0,"00":0,"01":1,10:3,11:2,".0":3,".1":1,"0.":0,"1.":2};for(let[j,re]of Object.entries(h)){let te=$.length,ke=Y.length,he=j.slice(0,te),ve=j.slice(te),de=Math.pow(2,te-u1(he)),Fe=Math.pow(2,ke-u1(ve)),qe=X[he]??0,Ie=X[ve]??0,ge=qe*b,Me=ge+de*b,be=x-Ie*b,Be=be-Fe*b,De=[];qe+de<=g&&Ie+Fe<=f?De=[[[ge+I,be-I],[Me-I,be-I],[Me-I,Be+I],[ge+I,Be+I]]]:Ie+Fe<=f?De=[[[ge+I,be-I],[ge+b+I,be-I],[ge+b+I,Be+I],[ge+I,Be+I]],[[-I,be-I],[b-I,be-I],[b-I,Be+I],[-I,Be+I]]]:qe+de<=g?De=[[[ge+I,be-I],[Me-I,be-I],[Me-I,be-b-I],[ge+I,be-b-I]],[[ge+I,x+I],[Me-I,x+I],[Me-I,x-b+I],[ge+I,x-b+I]]]:De=[[[ge+I,be-I],[ge+b+I,be-I],[ge+b+I,be-b-I],[ge+I,be-b-I]],[[-I,be-I],[b-I,be-I],[b-I,be-b-I],[-I,be-b-I]],[[-I,x+I],[b-I,x+I],[b-I,x-b+I],[-I,x-b+I]],[[ge+I,x+I],[ge+b+I,x+I],[ge+b+I,x-b+I],[ge+I,x-b+I]]];let ye=re.lw??1;for(let _e of De)this.segments.push(new U(_e,{cornerradius:.25,color:re.color,fill:re.fill,lw:ye,ls:re.ls}))}}};function $l(r,e){return r.toString(2).padStart(e,"0")}function u1(r){let e=0;for(let t of r)(t==="0"||t==="1")&&e++;return e}function m1(r){return r.replace(/[2-9]|=|x/g,"V").replace(/u/g,"1").replace(/d/g,"0").replace(/[nN]/g,"1").replace(/[pP]/g,"0").replace(/[lL]/g,"0").replace(/[hH]/g,"1")}function d1(r){let e=[];for(let t of r)typeof t!="string"&&(Array.isArray(t)?e.push(...d1(t)):typeof t=="object"&&t!==null&&e.push(t));return e}function Rc(r){let e=ze(0,1,10),t=e.map(n=>r*Math.exp(-n*6));return{xs:e,ys:t}}var Mc=class{constructor(e,t,n,s=.1,i=.2){z(this,"y0");z(this,"height");z(this,"curve1x");z(this,"curve2x");z(this,"extend");z(this,"rate",25);this.y0=t,this.extend=s,this.height=n-t,this.curve1x=e-i*this.height/2,this.curve2x=e+i*this.height/2}curve(e){let t=this.height*(1+this.extend*2),n=this.height*this.extend,s=ze(-.15,.15),i=s.map(a=>1/(1+Math.exp(-a*this.rate))*t-n),o=e==="left"?this.curve1x:this.curve2x;return{xs:s.map(a=>a+o),ys:i.map(a=>a+this.y0)}}};function h2(r,e,t){let n=new Mc(r,e,t),s=n.curve("left"),i=n.curve("right"),o=s.xs.map((l,h)=>[l,s.ys[h]]),a=i.xs.map((l,h)=>[l,i.ys[h]]);return[new p(o,{lw:1,zorder:3}),new p(a,{lw:1,zorder:3}),new U([...o,...[...a].reverse()],{zorder:3,color:"none",fill:"white",lw:1,closed:!1})]}var nn=class{constructor(e){z(this,"params");z(this,"x0");z(this,"xend");z(this,"y0");z(this,"y1");z(this,"y1_prev");z(this,"pstate");z(this,"nstate");z(this,"plevel");z(this,"rise");z(this,"xrise");z(this,"xrisehalf");z(this,"yhalf");z(this,"xcenter");z(this,"xtext");z(this,"kwargs");this.params=e,this.x0=e.x0,this.xend=e.xend,this.y0=e.y0,this.y1=e.y1,this.y1_prev=e.y1_prev,this.pstate=e.pstate,this.nstate=e.nstate,this.plevel=e.plevel,this.rise=e.rise,this.xrise=this.x0+this.rise,this.xrisehalf=this.x0+this.rise/2,this.yhalf=(this.y0+this.y1)/2,this.xcenter=(this.x0+this.xend)/2,this.xtext=this.xcenter+this.rise/2,this.kwargs=e.kwargs}vertsIn(){return{"-":[[this.x0,this.y0]],"|":[[this.x0,this.y0]],0:[[this.x0,this.y0],[this.xrisehalf,this.yhalf],[this.xrise,this.y0]],1:[[this.x0,this.y1],[this.xrise,this.y0]],z:[[this.x0,this.yhalf],[this.xrisehalf,this.y0]],V:[[this.xrise,this.y0]]}[this.plevel]??[]}vertsOut(){return[[this.xend,this.y0]]}segments(){let e=[...this.vertsIn(),...this.vertsOut()];return[new p(e,this.kwargs)]}},jl=class extends nn{vertsIn(){return"pP".includes(this.params.pstate)?[[this.x0,this.y0]]:[[this.x0,this.y1],[this.x0,this.y0]]}segments(){let e=super.segments();return this.params.state==="L"&&e.push(new p([[this.x0,this.yhalf+.25/2],[this.x0,this.yhalf-.25/2]],{arrow:"->",arrowwidth:.12,arrowlength:.25})),e}},ka=class extends nn{vertsIn(){return{"-":[[this.x0,this.y1]],h:[[this.x0,this.y1]],H:[[this.x0,this.y1]],l:[[this.x0,this.y1]],L:[[this.x0,this.y1]],0:[[this.x0,this.y0],[this.xrise,this.y1]],1:this.y1_prev!==this.y1?[[this.x0,this.y1_prev],[this.xrise,this.y1]]:[[this.x0,this.y1],[this.xrisehalf,this.yhalf],[this.xrise,this.y1]],z:[[this.x0,this.yhalf],[this.xrisehalf,this.y1]],V:[[this.xrise,this.y1]]}[this.plevel]??[]}vertsOut(){return[[this.xend,this.y1]]}},ql=class extends ka{vertsIn(){return"nN".includes(this.params.pstate)?[[this.x0,this.y1]]:[[this.x0,this.y0],[this.x0,this.y1]]}segments(){let e=super.segments();return this.params.state==="H"&&e.push(new p([[this.x0,this.yhalf-.25/2],[this.x0,this.yhalf+.25/2]],{arrow:"->",arrowwidth:.12,arrowlength:.25})),e}},zc=class extends nn{vertsIn(){let{xs:e,ys:t}=Rc((this.y1-this.y0)/2),n=t.map(a=>this.yhalf+a),s=t.map(a=>this.yhalf-a),i=e.map(a=>this.x0+a*this.rise*6);return{"-":[[this.x0,this.yhalf]],0:i.map((a,l)=>[a,s[l]]),1:i.map((a,l)=>[a,n[l]]),z:[[this.x0,this.yhalf]],V:[[this.xrise+this.rise,this.yhalf]]}[this.plevel]??[]}vertsOut(){return[[this.xend,this.yhalf]]}},Ec=class extends nn{vertsIn(){return{"-":[[this.x0,this.y1],[this.x0,this.y0]],"|":[[this.x0,this.y1],[this.x0,this.y0]],0:[[this.xrise,this.y1],[this.x0,this.y0]],1:[[this.x0,this.y1],[this.xrise,this.y0]],z:[[this.xrise,this.y1],[this.xrisehalf,this.yhalf],[this.xrise,this.y0]],V:[[this.xrise,this.y1],[this.xrisehalf,this.yhalf],[this.xrise,this.y0]]}[this.plevel]??[]}vertsOut(){let e="=23456789x".includes(this.nstate)?"V":this.nstate;return{0:[[this.xend+this.rise,this.y0],[this.xend,this.y1]],L:[[this.xend,this.y0],[this.xend,this.y1]],l:[[this.xend,this.y0],[this.xend,this.y1]],1:[[this.xend,this.y0],[this.xend+this.rise,this.y1]],H:[[this.xend,this.y0],[this.xend,this.y1]],h:[[this.xend,this.y0],[this.xend,this.y1]],z:[[this.xend,this.y0],[this.xend,this.y1]],V:[[this.xend,this.y0],[this.xend+this.rise/2,this.yhalf],[this.xend,this.y1]],"-":[[this.xend,this.y0],[this.xend,this.y1]],n:[[this.xend,this.y0],[this.xend,this.y1]],p:[[this.xend,this.y0],[this.xend,this.y1]],N:[[this.xend,this.y0],[this.xend,this.y1]],P:[[this.xend,this.y0],[this.xend,this.y1]]}[e]??[]}fillOpts(){return{fill:{3:"#feffc2",4:"#ffe2ba",5:"#abd9ff",6:"#bdfbff",7:"#bdffcb",8:"#e3a5fa",9:"#f7b7bd"}[this.params.state],hatch:this.params.state==="x"}}segments(){let{fill:e,hatch:t}=this.fillOpts(),n=[],s="-|".includes(this.pstate),i="-|".includes(this.nstate);return s&&i?(n.push(new p([[this.x0,this.y0],[this.xend,this.y0]],this.kwargs)),n.push(new p([[this.x0,this.y1],[this.xend,this.y1]],this.kwargs)),n.push(new U([[this.x0,this.y0],[this.xend,this.y0],[this.xend,this.y1],[this.x0,this.y1]],{color:"none",fill:e,hatch:t}))):s?n.push(new U([[this.x0,this.y0],...this.vertsOut(),[this.x0,this.y1]],{closed:!1,fill:e,hatch:t,...this.kwargs})):i?n.push(new U([[this.xend,this.y1],...this.vertsIn(),[this.xend,this.y0]],{closed:!1,fill:e,hatch:t,...this.kwargs})):n.push(new U([...this.vertsIn(),...this.vertsOut()],{fill:e,hatch:t,...this.kwargs})),this.params.data.length>0&&this.params.state!=="x"&&(n.push(new W([this.xtext,this.yhalf],this.params.data[0],{color:this.params.datacolor,fontsize:11,align:["center","center"]})),this.params.data.shift()),n}},Pc=class extends ka{vertsIn(){let{xs:e,ys:t}=Rc(this.y1-this.y0),n=e.map(a=>this.x0+a*this.rise*6),s=t.map(a=>this.y1-a),i=t.map(a=>this.y1-a/2);return{"-":[[this.x0,this.y1]],0:n.map((a,l)=>[a,s[l]]),1:[[this.x0,this.y1]],z:n.map((a,l)=>[a,i[l]]),V:[[this.xrise,this.y1]]}[this.plevel]??[]}segments(){let e=this.vertsIn();return[new p(e,this.kwargs),new p([e[e.length-1],[this.xend,this.y1]],{...this.kwargs,ls:":"})]}},Tc=class extends nn{vertsIn(){let{xs:e,ys:t}=Rc(this.y1-this.y0),n=e.map(a=>this.x0+a*this.rise*6),s=t.map(a=>this.y0+a),i=t.map(a=>this.y0+a/2);return{"-":[[this.x0,this.y0]],0:[[this.x0,this.y0]],1:n.map((a,l)=>[a,s[l]]),z:n.map((a,l)=>[a,i[l]]),V:[[this.x0,this.y0]]}[this.plevel]??[]}segments(){let e=this.vertsIn();return[new p(e,this.kwargs),new p([e[e.length-1],[this.xend,this.y0]],{...this.kwargs,ls:":"})]}},_0=class extends nn{vertsIn(){let e=this.params.state,t=this.params.period,n=this.y1,s=this.y0;"nN".includes(e)&&([n,s]=[s,n]);let i=[];for(let o=0;o<this.params.periods;o++)i.push([this.x0+t*o,s],[this.x0+t*o,n],[this.x0+t*o+t/2,n],[this.x0+t*o+t/2,s]);return"nN".includes(e)&&"lL".includes(this.params.pstate)||"pP".includes(e)&&"hH".includes(this.params.pstate)?i.slice(1):i}vertsOut(){let e="nN".includes(this.params.state)?this.y1:this.y0;return[[this.xend,e]]}segments(){let e=super.segments();if("NP".includes(this.params.state)){let t=this.params.period,n=.25,s=.12,i=this.yhalf-n/2,o=this.yhalf+n/2;this.params.state==="P"&&([i,o]=[o,i]);for(let a=0;a<this.params.periods;a++){let l=this.x0+t*a;e.push(new p([[l,o],[l,i]],{arrow:"->",arrowwidth:s,arrowlength:n,...this.kwargs}))}}return e}},c2={0:nn,1:ka,H:ql,h:ql,L:jl,l:jl,z:zc,u:Pc,d:Tc,n:_0,p:_0,N:_0,P:_0},n0=class extends N{constructor(t,n={}){super(n);z(this,"waveData");z(this,"yheight");z(this,"ygap");z(this,"risetime");z(this,"_fontSize");z(this,"namecolor");z(this,"datacolor");z(this,"gridcolor");z(this,"tickcolor");z(this,"edgecolor");z(this,"hscale");z(this,"showGrid");this.waveData=t,this.yheight=n.yheight??.5,this.ygap=n.ygap??.3,this.risetime=n.risetime??.15,this._fontSize=n.fontsize??12,this.namecolor=n.namecolor??"blue",this.datacolor=n.datacolor,this.gridcolor=n.gridcolor??"#DDDDDD",this.tickcolor=n.tickcolor??"#888888",this.edgecolor=n.edgecolor??"blue",this.showGrid=n.grid??!0;let s=this.waveData.signal??[],i=d1(s),o=this.waveData.config??{};this.hscale=o.hscale??1;let a=this.waveData.head??{},l=this.waveData.foot??{},h=(this.yheight+this.ygap)*i.length,c=0;for(let g of i)c=Math.max(c,(g.wave??"").length);this.showGrid&&this._drawGrid(c,h);let m=He(0,this.yheight+.05,c*this.yheight*2*this.hscale,-h),f=0;for(let g of i)this._drawName(g.name??"",f),this._drawWave(g,f,m),f-=this.yheight+this.ygap;this._drawEdges(i),this._drawHeadFoot(a,l,c,f),this.anchors.topleft=[0,0]}_drawGrid(t,n){for(let s=0;s<=t;s++){let i=s*2*this.yheight*this.hscale;this.segments.push(new p([[i,this.yheight+this.ygap/2],[i,this.yheight-n]],{ls:":",lw:1,color:this.gridcolor,zorder:0}))}}_drawName(t,n){if(!t)return;let s=.2;this.segments.push(new W([-s,n],t,{align:["right","bottom"],fontsize:this._fontSize,color:this.namecolor}))}_drawWave(t,n,s){let i=t.wave??"";if(!i)return;let o=t.phase??0,a=t.level??"0",l=t.risetime??this.risetime,h={color:t.color??void 0,lw:t.lw??1,clip:s},c=t.data?Array.isArray(t.data)?[...t.data]:t.data.split(" "):[];a.length===1?a=a.repeat(i.length):a.length<i.length&&(a+=a[a.length-1].repeat(i.length-a.length));let m=2*this.yheight*(t.period??1)*this.hscale,f=this.yheight,g=0,b="-",v=n+f,x=-m*o;for(;g<i.length;){let S=i[g],k=[],M=1,_=parseInt(a[g],10);!isNaN(_)&&_>0&&(f=_/10*this.yheight),f===0&&(f=this.yheight);let B=g+1;for(;B<i.length&&(i[B]==="|"||i[B]===".");)i[B]==="|"&&k.push(M),M++,B++;let $=B<i.length?i[B]:"-",Y=n+f,Z=x+M*m,L={state:S,pstate:b,nstate:$,plevel:m1(b),nlevel:m1($),periods:M,period:m,x0:x,xend:Z,y0:n,y1:Y,y1_prev:v,rise:l,data:c,datacolor:this.datacolor,kwargs:h},I=c2[S]??Ec;this.segments.push(...new I(L).segments());for(let X of k)this.segments.push(...h2(x+(X+1)*m-m/2,n,Y));b=S,v=Y,x+=M*m,g=B}}_drawEdges(t){let n=this.waveData.edge??[];if(n.length===0)return;let s=2*this.yheight*this.hscale;for(let i of n){let o="";if(i.includes(" ")){let m=i.indexOf(" ");o=i.slice(m+1),i=i.slice(0,m)}let a=i.match(/\{(.*?)\}/),l=this.edgecolor;a&&(l=a[1].split(",")[0]||l,i=i.replace(/\{.*?\}/,""));let h;i.includes("<")&&i.includes(">")?h="<>":i.includes("<")?h="<":i.includes(">")&&(h=">");let c=i.match(/\[(.+?)\]/g);if(c&&c.length===2){let m=[];for(let f of c){let g=f.slice(1,-1),b=g.indexOf(":"),v=g.slice(0,b),x=g.slice(b+1),S=parseInt(v.replace(/[^0-9]/g,""),10),k=parseFloat(x),M=this.yheight/2;v.includes("^")?M=this.yheight+.2:v.includes("v")&&(M=-.2);let _=t[S]?.phase??0,B=k*s-s*_,$=-S*(this.yheight+this.ygap)+M;m.push([B,$])}if(m.length===2&&(this.segments.push(new p(m,{lw:1,color:l,arrow:h,zorder:3})),o)){let f=(m[0][0]+m[1][0])/2,g=(m[0][1]+m[1][1])/2;this.segments.push(new W([f,g],o,{fontsize:8,color:l,align:["center","center"],zorder:4}))}}else if(i.length>=3){let m=i[0],f=i[i.length-1],g=this.anchors[`node_${m}`],b=this.anchors[`node_${f}`];if(g&&b){let v=k=>k instanceof A?[k.x,k.y]:[k[0],k[1]],x=v(g),S=v(b);if(this.segments.push(new p([x,S],{lw:1,color:l,arrow:h,zorder:3})),o){let k=(x[0]+S[0])/2,M=(x[1]+S[1])/2;this.segments.push(new W([k,M],o,{fontsize:8,color:l,align:["center","center"],zorder:4}))}}}}}_drawHeadFoot(t,n,s,i){if(t.tick!==void 0||t.tock!==void 0){let o=t.tick??t.tock??0,a=t.every??1,l=t.tick!==void 0?0:this.hscale/2;for(let h=0;h<s;h+=a){let c=(l+h*this.hscale)*2*this.yheight;this.segments.push(new W([c,this.yheight+this.ygap],String(o+h),{color:this.tickcolor,fontsize:this._fontSize,align:["center","bottom"]}))}}if(n.tick!==void 0||n.tock!==void 0){let o=n.tick??n.tock??0,a=n.every??1,l=n.tick!==void 0?0:this.hscale/2;for(let h=0;h<s;h+=a){let c=(l+h*this.hscale)*2*this.yheight;this.segments.push(new W([c,i+this.yheight],String(o+h),{color:this.tickcolor,fontsize:this._fontSize,align:["center","top"]}))}}}};var Ac=2/72*(3/4),u2={1:"#dadada",2:"#f2dbdc",3:"#ecf2da",4:"#e2f2ee",5:"#f2eddb",6:"#e2f2db",7:"#dee5f2",8:"#f2d6ff",9:"#feffdb"};function Hl(r){return r===!0||r===1||r==="true"||r==="True"}var s0=class extends N{constructor(e,t={}){super(t),this.defaults={bitheight:.625,width:15,fontsize:12,lw:1,ygap:null,vflip:!1,hflip:!1,compact:!1},this.anchors.origin=[0,0];let n=e.reg??[],s=e.config??{},i=s.fontsize??this.params.fontsize??12,o=Hl(s.hflip??this.params.hflip),a=Hl(s.vflip??this.params.vflip),l=Hl(s.compact??this.params.compact),h=n.reduce((X,j)=>X+(j.bits??0),0),c=this.params.lblofst??.1,m;s.vspace!==void 0?m=(s.vspace??30)*Ac:m=this.params.bitheight??.625;let f;s.hspace!==void 0?f=(s.hspace??800)*Ac:f=this.params.width??15;let g=s.lanes??1,b=this.params.ygap;if(b==null){b=0;for(let X of n){let j=X.attr??[];(typeof j=="number"||typeof j=="string")&&(j=[j]);let re=(j.length+1.5)*Ac*1.5*i;b=Math.max(b,re)}}let v;s.bits!==void 0?(h=s.bits,v=h/g):g>1?(h%2!==0&&(h+=1),v=s.bits??h/g):v=h;let x=null,S=null,k=s.label;if(k){if(k.left!==void 0)if(typeof k.left=="number")x=Array.from({length:g},(X,j)=>String(j+k.left));else if(typeof k.left=="string")x=Array(g).fill(k.left);else{let X=k.left,j=X.length;x=[...X,...Array.from({length:g-j},(re,te)=>String(te+j))]}if(k.right!==void 0)if(typeof k.right=="number")S=Array.from({length:g},(X,j)=>String(j+k.right));else if(typeof k.right=="string")S=Array(g).fill(k.right);else{let X=k.right,j=X.length;S=[...X,...Array.from({length:g-j},(re,te)=>String(te+j))]}}let M=f/v,_=m,B=0,$=_/8,Y=0,Z=a?-1:1,L=0,I=this.params.lw??1;for(let X=0;X<g;X++){x&&this.segments.push(new W([-c,L+_/2],x[X],{fontsize:i,align:["right","center"]})),S&&this.segments.push(new W([f+c,L+_/2],S[X],{fontsize:i,align:["left","center"]}));let j=a?0:f,re=L+_/2,te=0;for(;te<v&&Y<n.length;){let he=n[Y],ve=he.bits??1,de=B||ve,Fe=he.attr,qe=he.rotate??0,Ie=he.name??"",ge=he.type,Me=he.scale??1,be=Hl(he.number??!0);if(de+te>v){let ye=v-te;B=de-ye,de=ye}else B=0;let Be=j-Z*de*M/2*Me,De=j;if(j-=de*M*Z*Me,this.segments.push(new U([[j,L+_],[j,L],[De,L],[De,L+_]],{lw:I})),ge!==void 0||!Ie){let ye;ge==null||String(ge).length===1?ye=u2[String(ge)]??"#dadada":ye=String(ge),this.segments.push(new U([[j,L+_],[j,L],[De,L],[De,L+_]],{lw:0,color:"none",fill:ye,zorder:0}))}for(let ye=0;ye<de-1;ye++){let _e=j+(ye+1)*Z*M*Me;this.segments.push(new p([[_e,L+_],[_e,L+_-$]],{lw:I})),this.segments.push(new p([[_e,L],[_e,L+$]],{lw:I}))}if(Ie){this.segments.push(new W([Be,re],Ie,{fontsize:i,align:["center","center"],rotation:-qe}));let ye=Ie.replace(/[^a-zA-Z0-9_]/g,"_");this.anchors[`field_${ye}`]=[Be,re]}if(be&&(o&&X===0||!o&&X===g-1||!l))if(de>1){let ye=X*v+te,_e=X*v+te+de-1,Ae=ye<100&&M/2*Me>.22,Ze=_e<100&&M/2*Me>.22,bn=Ae?Z*M/2*Me:.12;this.segments.push(new W([De-bn,L+_+c],String(ye),{fontsize:i,align:[Ae?"center":"right","bottom"]}));let ft=Ze?Z*M/2*Me:.12;this.segments.push(new W([j+ft,L+_+c],String(_e),{fontsize:i,align:[Ze?"center":"left","bottom"]}))}else this.segments.push(new W([Be,L+_+c],String(X*v+te+de-1),{fontsize:i,align:["center","bottom"]}));if(Fe!=null){let ye;if(typeof Fe=="string"||typeof Fe=="number"?ye=[Fe]:ye=Fe,typeof ye[0]=="string"){let _e=ye.join(`
|
|
270
270
|
`);this.segments.push(new W([Be,L-c],_e,{fontsize:i,align:["center","top"]}))}else{let Ae=ye.map(Ze=>Ze<0?Ze+(1<<ve):Ze).map(Ze=>Ze.toString(2).padStart(ve,"0"));for(let Ze=0;Ze<de;Ze++){let bn=de+B-Ze-1,Rt=Ae.map(Te=>Te[bn]).join(`
|
|
271
271
|
`);this.segments.push(new W([De-Z*M*Ze-Z*M/2,L-c],Rt,{fontsize:i,align:["center","top"]}))}}}te+=de,B||(Y+=1)}let ke=l?_:_+b;o?L-=ke:L+=ke}}};var i0=1,lt=.65,sn=.12;function p1(r){let e=r.replace(/\|\|/g,"\u01C1");for(;;){let s=e.replace(/([lcr])([lcr])/g,"$1.$2");if(s===e)break;e=s}!e.startsWith("|")&&!e.startsWith("\u01C1")&&(e="."+e),!e.endsWith("|")&&!e.endsWith("\u01C1")&&(e+=".");let t="",n="";for(let s=0;s<e.length;s++)s%2===0?t+=e[s]:n+=e[s];return{justs:n,bars:t}}var B0=class extends N{constructor(e){super(e);let t=e.table,n=e.fontsize??12,s=e.font??"sans",i=.03,o=.3,a=.4,l=t.trim().split(`
|
|
272
|
-
`),h="";for(let L of l)L.includes("---")?h+="|":L.includes("===")?h+="\u01C1":h+="l";let{justs:c,bars:m}=p1(h),f=L=>L.replace(/^\|?\s*|\s*\|?$/g,""),g=l.filter(L=>!L.includes("---")&&!L.includes("===")),b=f(g[0]).split("|").length,v=e.colfmt;(v==null||v==="")&&(v="c".repeat(b));let{justs:x,bars:S}=p1(v),k=x.length,M=c.length;if(f(g[0]).split("|").length!==k)throw new Error("Number of columns in table does not match colfmt string.");let _=new Array(k).fill(0),B=new Array(M).fill(0);for(let L=0;L<g.length;L++){let I=f(g[L]).split("|").map(X=>X.trim());for(let X=0;X<I.length;X++){let{width:j,height:re}=b0(I[X],n,s);_[X]=Math.max(_[X],j/72*2+a),B[L]=Math.max(B[L],re/72*2+o)}}let $=B.reduce((L,I)=>L+I,0),Y=_.reduce((L,I)=>L+I,0),Z=(L,I)=>L.slice(0,I).reduce((X,j)=>X+j,0);for(let L=0;L<S.length;L++){let I=Z(_,L);S[L]==="|"?this.segments.push(new p([[I,0],[I,-$]],{lw:1})):S[L]==="\u01C1"&&(this.segments.push(new p([[I-i,0],[I-i,-$]],{lw:1})),this.segments.push(new p([[I+i,0],[I+i,-$]],{lw:1})))}for(let L=0;L<m.length;L++){let I=-Z(B,L);m[L]==="|"?this.segments.push(new p([[0,I],[Y,I]],{lw:1})):m[L]==="\u01C1"&&(this.segments.push(new p([[0,I-i],[Y,I-i]],{lw:1})),this.segments.push(new p([[0,I+i],[Y,I+i]],{lw:1})))}for(let L=0;L<g.length;L++){let I=f(g[L]).split("|").map(X=>X.trim());for(let X=0;X<I.length;X++){let j=Z(_,X),re=-Z(B,L)-B[L],te={c:"center",l:"left",r:"right"}[x[X]]??"center";te==="center"?j+=_[X]/2:te==="right"?j+=_[X]-a/2:j+=a/2,this.segments.push(new W([j,re+o/3],I[X],{fontfamily:s,fontsize:n,align:[te,"bottom"]})),this.anchors[`cell${L}_${X}`]=[j,re+B[L]/2]}}}},C0=class extends se{constructor(e={}){super(e),this.segments.push(new p([[-sn*2,0],H,[lt+sn*2,0]])),this.segments.push(new p([[0,i0/2],[lt,0],[0,-i0/2],[0,i0/2]])),this.segments.push(new D([lt+sn,0],sn)),this.segments.push(new D([lt+sn,0],sn)),this.segments.push(new D([-sn,0],sn)),this.anchors.out=[lt+sn*2,0],this.anchors.in1=[0,0]}},I0=class extends se{constructor(e={}){super(e),this.segments.push(new p([[0,0],H,[lt,0]])),this.segments.push(new p([[0,0],[0,-i0/2],[lt,0],[0,i0/2],[0,0]])),this.segments.push(new p([[lt,0],[lt,-i0/2],[0,0],[lt,i0/2],[lt,0]])),this.segments.push(new D([lt/2,.28+.08],.08)),this.segments.push(new p([[lt/2,.28+.16],[lt/2,.7]])),this.segments.push(new p([[lt/2,-.28],[lt/2,-.7]])),this.anchors.out=[lt,0],this.anchors.in1=[0,0],this.anchors.c=[lt/2,-.7],this.anchors.cbar=[lt/2,.7]}},_c=(r=0)=>new p([[r+.07,-.15],[r+.25,-.15],[r+.25,.15],H,[r+.33,.15],[r+.15,.15],[r+.15,-.15]],{lw:1}),L0=class extends Jt{constructor(e={}){super(e),this.segments.push(_c())}},D0=class extends Kt{constructor(e={}){super(e),this.segments.push(_c())}},o0=class extends Bt{constructor(e={}){super(e);let n=T(this.params,"leadin",.35)+lt/2;this.segments.push(_c(n))}};function Yl(r){return new o0({...r,nand:!0})}var F=.25,Ye=.16666666666666666;var Cr=class extends se{constructor(e={}){super(e),Object.assign(this.defaults,{polar:!1});let t=.18;this.segments.push(new p([[0,0],H,[0,.25],[0,-.25],H,[t,.25],[t,-.25],H,[t,0]])),T(this.params,"polar",!1)&&this.segments.push(new W([-t*1.2,t],"+"))}},Cn=class extends se{constructor(e={}){super(e),Object.assign(this.defaults,{polar:!1});let t=.18;this.segments.push(new p([[0,0],H,[0,.25],[0,-.25],H,[t,0]])),this.segments.push(new xe([t*1.5,0],t*1.5,.25*2.5,{theta1:105,theta2:-105})),T(this.params,"polar",!1)&&this.segments.push(new W([-t*1.2,t],"+"))}},In=class extends Cr{constructor(e={}){super(e),Object.assign(this.defaults,{arrowwidth:.16,arrowlength:.2});let t=Ye,n=.25,s=T(this.params,"arrowwidth",.16),i=T(this.params,"arrowlength",.2),o=T(this.params,"arrow_lw",void 0),a=T(this.params,"arrow_color",void 0);this.segments.push(new p([[-2*t,-n],[3*t,t*2]],{arrow:"->",arrowwidth:s,arrowlength:i,lw:o,color:a}))}},Ln=class extends Cr{constructor(e={}){super(e),Object.assign(this.defaults,{trim_lw:void 0,trim_color:void 0});let t=.18,n=Ye,s=.25,i=[-1.8*n,-s],o=[1.8*n+t,s],a=o[0]-i[0],l=o[1]-i[1],h=.14,c=Math.atan2(l,a)+Math.PI/2,m=[o[0]+h*Math.cos(c),o[1]+h*Math.sin(c)],f=[o[0]+h*Math.cos(c-Math.PI),o[1]+h*Math.sin(c-Math.PI)],g=T(this.params,"trim_lw",void 0),b=T(this.params,"trim_color",void 0);this.segments.push(new p([i,o],{lw:g,color:b})),this.segments.push(new p([m,f],{lw:g,color:b}))}};var et=class extends se{constructor(e={}){super(e);let t=.25*1.4;this.segments.push(new p([[0,0],H,[t,.25],[t,-.25],H,[t,0]])),this.segments.push(new U([[0,.25],[t,0],[0,-.25]],{closed:!0,fill:!1}))}},Dn=class extends et{constructor(e={}){super(e);let t=.25*1.4,n=.1;this.segments.push(new p([[t,.25],[t-n,.25],[t-n,.25-n]])),this.segments.push(new p([[t,-.25],[t+n,-.25],[t+n,-.25+n]]))}},Nn=class extends et{constructor(e={}){super(e);let t=.25*1.4,n=.1;this.segments.push(new p([[t,.25],[t+n,.25+n]])),this.segments.push(new p([[t,-.25],[t-n,-.25-n]]))}};var On=class extends et{constructor(e={}){super(e);let t=.25*1.4,n=.1;this.segments.push(new p([[t,.25],[t-n,.25]])),this.segments.push(new p([[t,-.25],[t-n,-.25]]))}},Fn=class extends se{constructor(e={}){super(e);let t=.25*1.4,n=.1;this.segments.push(new p([[0,0],H,[2*t,0]])),this.segments.push(new U([[0,.25],[t,0],[0,-.25]],{closed:!0,fill:!1})),this.segments.push(new U([[t,0],[t*2,.25],[t*2,-.25]],{closed:!0,fill:!1})),this.segments.push(new p([[t+n,.25],[t,.25],[t,-.25],[t-n,-.25]]))}},$n=class extends se{constructor(e={}){super(e);let t=.25*1.4;this.segments.push(new p([[0,0],[t,0],[t,.25],[t,-.25],H,[t,0]])),this.segments.push(new p([[0,-.25],[0,.25],[t,0]]))}},jn=class extends se{constructor(e={}){super(e);let t=.13,n=.25*1.4;this.segments.push(new p([[0,0],H,[n,.25],[n,-.25],H,[n+t,.25],[n+t,-.25],H,[n+t,0]])),this.segments.push(new U([[0,.25],[n,0],[0,-.25]],{closed:!0,fill:!1}))}},qn=class extends et{constructor(e={}){super(e),Object.assign(this.defaults,{arrowwidth:.16,arrowlength:.2});let t=.25,n=T(this.params,"arrowwidth",.16),s=T(this.params,"arrowlength",.2),i=T(this.params,"arrow_color",void 0);this.segments.push(new p([[t,t*1.5],[t*2,t*3.25]],{arrow:"->",arrowwidth:n,arrowlength:s,color:i})),this.segments.push(new p([[t*.1,t*1.5],[t*1.1,t*3.25]],{arrow:"->",arrowwidth:n,arrowlength:s,color:i})),this.elmParams.lblloc="bot"}},Hn=class extends et{constructor(e={}){super(e),Object.assign(this.defaults,{arrowwidth:.16,arrowlength:.2});let t=.25,n=T(this.params,"arrowwidth",.16),s=T(this.params,"arrowlength",.2),i=T(this.params,"arrow_color",void 0),o=T(this.params,"arrow_lw",void 0),a=ze(-1,1),l=a.map(v=>-v*(v-.7)*(v+.7)/2+t*2.5),h=ze(t*.75,t*1.25,a.length),c=20,m=h.map((v,x)=>{let S=A.fromXY([v,l[x]]).rotate(c,[0,0]);return[S.x,S.y]}),f=h.map((v,x)=>{let S=A.fromXY([v-.2,l[x]]).rotate(c,[0,0]);return[S.x,S.y]});this.segments.push(new p(m,{lw:o,color:i})),this.segments.push(new p(f,{lw:o,color:i}));let g=A.fromXY([h[0],l[0]+.1]).rotate(c,[0,0]),b=A.fromXY([h[0]-.2,l[0]+.1]).rotate(c,[0,0]);this.segments.push(new p([[m[1][0],m[1][1]],[g.x,g.y]],{arrow:"->",arrowwidth:n,arrowlength:s,color:i})),this.segments.push(new p([[f[1][0],f[1][1]],[b.x,b.y]],{arrow:"->",arrowwidth:n,arrowlength:s,color:i})),this.elmParams.lblloc="bot"}},Yn=class extends et{constructor(e={}){super(e),Object.assign(this.defaults,{arrowwidth:.16,arrowlength:.2});let t=.25,n=T(this.params,"arrowwidth",.16),s=T(this.params,"arrowlength",.2),i=T(this.params,"arrow_color",void 0),o=T(this.params,"arrow_lw",void 0),a=ze(-1,1),l=a.map(x=>-x*(x-.7)*(x+.7)/2+t*2.5),h=ze(t*.75,t*1.25,a.length),c=20,m=h.map((x,S)=>{let k=A.fromXY([x,l[S]]).rotate(c,[0,0]);return[k.x,k.y]}),f=h.map((x,S)=>{let k=A.fromXY([x-.2,l[S]]).rotate(c,[0,0]);return[k.x,k.y]});this.segments.push(new p(m,{lw:o,color:i})),this.segments.push(new p(f,{lw:o,color:i}));let g=A.fromXY([h[h.length-1],l[l.length-1]-.1]).rotate(c,[0,0]),b=A.fromXY([h[h.length-1]-.2,l[l.length-1]-.1]).rotate(c,[0,0]),v=m.length;this.segments.push(new p([[m[v-2][0],m[v-2][1]],[g.x,g.y]],{arrow:"->",arrowwidth:n,arrowlength:s,color:i})),this.segments.push(new p([[f[v-2][0],f[v-2][1]],[b.x,b.y]],{arrow:"->",arrowwidth:n,arrowlength:s,color:i})),this.elmParams.lblloc="bot"}},Xn=class extends et{constructor(e={}){super(e);let t=.25*1.4;this.segments.push(new p([[t,0],[t+.3,-.3],[t+.3,-.5]])),this.anchors.gate=[t+.3,-.5]}},on=class extends se{constructor(e={}){super(e);let t=.25*1.4;this.segments.push(new p([[0,0],H,[t,.25*1.8],[t,-.25*1.8],H,[0,.25*1.8],[0,-.25*1.8],H,[t,0]])),this.segments.push(new U([[0,-.25-.25],[t,-.25],[0,-.25+.25]],{closed:!0,fill:!1})),this.segments.push(new U([[t,.25+.25],[0,.25],[t,.25-.25]],{closed:!0,fill:!1}))}},Gn=class extends on{constructor(e={}){super(e);let t=.25*1.4;this.segments.push(new p([[t,.25],[t+.5,.5]])),this.anchors.gate=[t+.5,.5]}};var Wn=.25;function Vn(r=4,e=[0,0],t=.06,n=.19,s=!0,i=!1,o=!1){let a=Math.acos(t/n),l=ze(a,2*(r+1)*Math.PI-a,r*50),h=l.map(x=>t*x-n*Math.sin(x)),c=l.map(x=>t-n*Math.cos(x)),m=h[0];if(h=h.map(x=>x-m),s){let x=h[h.length-1]-h[0];x!==0&&(h=h.map(S=>S/x))}o&&(c=c.map(x=>-x));let g=Math.max(...c)-Math.min(...c);c=c.map(x=>x*g/.25);let b=h,v=c;return i&&(b=c,v=h),b.map((x,S)=>[x+e[0],v[S]+e[1]])}var Ir=class extends se{constructor(e={}){super(e),Object.assign(this.defaults,{core:0});let t=T(this.params,"core",0),n=T(this.params,"core_ls",void 0),s=T(this.params,"core_lw",void 0),i=T(this.params,"core_color",void 0);this.segments.push(new p([[0,0],H,[1,0]]));for(let a=0;a<4;a++)this.segments.push(new xe([(a*2+1)*Wn/2,0],Wn,Wn,{theta1:0,theta2:180}));let o=.12;if(t>0)for(let a=0;a<t;a++){let l=Wn+o*a,h={};n!==void 0&&(h.ls=n),s!==void 0&&(h.lw=s),i!==void 0&&(h.color=i),this.segments.push(new p([[0,l],[1,l]],h))}this.anchors.NE=[1,Wn+o],this.anchors.NW=[0,Wn+o],this.anchors.SE=[1,-Wn],this.anchors.SW=[0,-Wn]}},Lr=class extends se{constructor(e={}){super(e),Object.assign(this.defaults,{loops:4,core:0});let t=T(this.params,"loops",4),n=T(this.params,"core",0),s=T(this.params,"core_ls",void 0),i=T(this.params,"core_lw",void 0),o=T(this.params,"core_color",void 0);this.segments.push(new p(Vn(t)));let a=.12,l=.5;if(n>0)for(let h=0;h<n;h++){let c=l+a*h,m={};s!==void 0&&(m.ls=s),i!==void 0&&(m.lw=i),o!==void 0&&(m.color=o),this.segments.push(new p([[0,c],[1,c]],m))}this.anchors.NE=[1,l+a],this.anchors.NW=[0,l+a],this.anchors.SE=[1,-l],this.anchors.SW=[0,-l]}};var Un=class extends se{constructor(e={}){super(e);let t=.2,n=.25;this.segments.push(new p([[0,0],H,[0,n],[0,-n],H,[t/2,n],[t/2,-n],[t*1.5,-n],[t*1.5,n],[t/2,n],H,[t*2,n],[t*2,-n],H,[t*2,0]]))}};var dt=class extends se{constructor(e={}){super(e);let t=Ye,n=.25;this.segments.push(new p([[0,0],[.5*t,n],[1.5*t,-n],[2.5*t,n],[3.5*t,-n],[4.5*t,n],[5.5*t,-n],[6*t,0]]))}};var mt=class extends se{constructor(e={}){super(e);let t=Ye,n=.25;this.segments.push(new p([[0,0],[0,n],[t*6,n],[t*6,-n],[0,-n],[0,0],H,[t*6,0]]))}},cr=class extends dt{constructor(e={}){super(e),Object.assign(this.defaults,{arrowwidth:.16,arrowlength:.2});let t=Ye,n=.25,s=T(this.params,"arrowwidth",.16),i=T(this.params,"arrowlength",.2),o=T(this.params,"arrow_lw",void 0),a=T(this.params,"arrow_color",void 0);this.segments.push(new p([[1.5*t,-n*2],[4.5*t,t*3.5]],{arrow:"->",arrowwidth:s,arrowlength:i,lw:o,color:a}))}},Zt=class extends mt{constructor(e={}){super(e),Object.assign(this.defaults,{arrowwidth:.16,arrowlength:.2});let t=Ye,n=.25,s=T(this.params,"arrowwidth",.16),i=T(this.params,"arrowlength",.2),o=T(this.params,"arrow_lw",void 0),a=T(this.params,"arrow_color",void 0);this.segments.push(new p([[1*t,-n*2],[5*t,t*3.5]],{arrow:"->",arrowwidth:s,arrowlength:i,lw:o,color:a}))}},Jn=class extends mt{constructor(e={}){super(e),this.segments.push(new p([[0,-.25-.2],[.2,-.25-.2],[1,.25+.2]]))}},ur=class extends dt{constructor(e={}){super(e),Object.assign(this.defaults,{arrowwidth:.16,arrowlength:.2});let t=T(this.params,"arrowwidth",.16),n=T(this.params,"arrowlength",.2),s=T(this.params,"arrow_lw",void 0),i=T(this.params,"arrow_color",void 0);this.segments.push(new p([[.7,.75],[.4,.4]],{arrow:"->",arrowwidth:t,arrowlength:n,lw:s,color:i})),this.segments.push(new p([[1,.75],[.7,.4]],{arrow:"->",arrowwidth:t,arrowlength:n,lw:s,color:i}))}},Qt=class extends mt{constructor(e={}){super(e),Object.assign(this.defaults,{arrowwidth:.16,arrowlength:.2});let t=T(this.params,"arrowwidth",.16),n=T(this.params,"arrowlength",.2),s=T(this.params,"arrow_lw",void 0),i=T(this.params,"arrow_color",void 0);this.segments.push(new p([[.7,.75],[.4,.4]],{arrow:"->",arrowwidth:t,arrowlength:n,lw:s,color:i})),this.segments.push(new p([[1,.75],[.7,.4]],{arrow:"->",arrowwidth:t,arrowlength:n,lw:s,color:i}))}},Kn=class extends mt{constructor(e={}){super(e);let t=Ye,n=.25;this.segments.push(new p([[0,0],[-n*1.5,-n],[-n*1.5,-n*2]])),this.segments.push(new p([[t*6,0],[t*6+n*1.5,-n],[t*6+n*1.5,-n*2]])),this.anchors.v1=[-n*1.5,-n*2],this.anchors.v2=[t*6+n*1.5,-n*2]}},mr=class extends dt{constructor(e={}){super(e),Object.assign(this.defaults,{arrowwidth:.15,arrowlength:.25,tap_length:.72});let t=Ye,n=T(this.params,"tap_length",.72),s=T(this.params,"arrowwidth",.15),i=T(this.params,"arrowlength",.25);this.anchors.tap=[t*3,n],this.elmParams.lblloc="bot",this.segments.push(new p([[t*3,n],[t*3,t*1.5]],{arrow:"->",arrowwidth:s,arrowlength:i}))}},er=class extends mt{constructor(e={}){super(e),Object.assign(this.defaults,{arrowwidth:.15,arrowlength:.25,tap_length:.72});let t=Ye,n=T(this.params,"tap_length",.72),s=T(this.params,"arrowwidth",.15),i=T(this.params,"arrowlength",.25);this.anchors.tap=[t*3,n],this.elmParams.lblloc="bot",this.segments.push(new p([[t*3,n],[t*3,t*1.5]],{arrow:"->",arrowwidth:s,arrowlength:i}))}},dr=class extends mt{constructor(e={}){super(e);let t=Ye;this.segments.push(new p([[0,0],[t*6,0]]))}},Dr=class extends mt{constructor(e={}){super(e);let t=Ye,n=.25,s=n*.66;this.segments.push(new p([[s,n],[s,-n]])),this.segments.push(new p([[6*t-s,n],[6*t-s,-n]]))}};var an={Resistor:dt,ResistorVar:cr,Potentiometer:mr,Photoresistor:ur,Fuse:dr},Xl={Resistor:mt,ResistorVar:Zt,Potentiometer:er,Photoresistor:Qt,Fuse:Dr},Zn=dt,Qn=cr,es=mr,ts=ur,rs=dr;function Gl(r){r.Resistor!==void 0&&(Zn=r.Resistor),r.ResistorVar!==void 0&&(Qn=r.ResistorVar),r.Potentiometer!==void 0&&(es=r.Potentiometer),r.Photoresistor!==void 0&&(ts=r.Photoresistor),r.Fuse!==void 0&&(rs=r.Fuse)}function Wl(){Zn=an.Resistor,Qn=an.ResistorVar,es=an.Potentiometer,ts=an.Photoresistor,rs=an.Fuse}var ns=class extends se{constructor(e={}){super(e);let t=.2;this.segments.push(new p([[0,0],[t,0],[t,-t*.75],[t*2,-t*.75],[t*2,t*.75],[t*3,t*.75],[t*3,-t*.75],[t*4,-t*.75],[t*4,0],[t*5,0]])),this.segments.push(new p([[0,t*1.25],[t*5,t*1.25],[t*5,t*-1.25],[0,t*-1.25],[0,t*1.25]])),this.segments.push(new U([[0,t*1.25],[0,-t*1.25],[t/2,-t*1.25],[t/2,t*1.25]],{closed:!0,fill:"black"}))}},ss=class extends se{constructor(e={}){super(e);let t=.2,n=.25;this.segments.push(new p([[0,0],[0,n],[t,n],[t,-n],[t*2,-n],[t*2,n],[t*3,n],[t*3,-n],[t*4,-n],[t*4,n],[t*5,n],[t*5,-n],[t*6,-n],[t*6,0],[t*7,0]]))}},is=class extends se{constructor(e={}){super(e),Object.assign(this.defaults,{box:!1});let t=.25;T(this.params,"box",!1)?(this.segments.push(new p([[-t,0],H,[t,0]])),this.segments.push(new p([[-t,t],[t,-t],H,[t,t],[-t,-t]])),this.segments.push(new U([[-t,t],[-t,-t],[t,-t],[t,t]],{closed:!0,fill:!1}))):this.segments.push(new p([[0,0],H,[-t,t],[t,-t],H,[t,t],[-t,-t],H,[0,0]]))}},os=class extends se{constructor(e={}){super(e),Object.assign(this.defaults,{dots:!0,dot_r:.12});let t=T(this.params,"dot_r",.12),n=50,s=ze(t*2,1+t,n),o=ze(0,2*Math.PI,n).map(l=>Math.sin(l)*.25),a=s.map((l,h)=>[l,o[h]]);this.segments.push(new p(a)),this.segments.push(new p([[0,0],H,[1+t*3,0]])),T(this.params,"dots",!0)&&(this.segments.push(new D([t,0],t,{zorder:4,fill:"bg"})),this.segments.push(new D([t*2+1,0],t,{zorder:4,fill:"bg"})))}},as=class extends se{constructor(e={}){super(e),Object.assign(this.defaults,{dots:!0,dot_r:.12});let t=e.dots,n=T(this.params,"dots",!0),s=t?25:10,i=t?155:170,o=T(this.params,"arc_lw",void 0),a=T(this.params,"arc_color",void 0);if(this.segments.push(new p([[0,0],H,[1,0]])),this.segments.push(new xe([.5,0],1,.65,{theta1:s,theta2:i,lw:o,color:a})),n){let l=T(this.params,"dot_r",.12);this.segments.push(new D([l,0],l,{zorder:4})),this.segments.push(new D([1-l,0],l,{zorder:4}))}}},ls=class extends se{constructor(e={}){super(e);let t=.25,n=.25,s=.25;this.segments.push(new p([[0,0],[-n,0],H,[n,0],[0,-s],H,[t,0]])),this.segments.push(new p([[0,0],[-n,0],H,[n,0],[0,s],H,[t,0]])),this.segments.push(new p([[0,0],[-n,s],H,[0,-s],H,[t,0]])),this.segments.push(new p([[0,0],[-n,-s],H,[0,-s],H,[t,0]]))}},hs=class extends se{constructor(e={}){super(e),Object.assign(this.defaults,{gap:.08,arrowwidth:.25,arrowlength:.25});let t=T(this.params,"gap",.08),n=T(this.params,"arrowwidth",.25),s=T(this.params,"arrowlength",.25);this.segments.push(new p([[0,0],H,[1,0]])),this.segments.push(new p([[0,0],[.5-t/2,0]],{arrow:"->",arrowwidth:n,arrowlength:s})),this.segments.push(new p([[1,0],[.5+t/2,0]],{arrow:"->",arrowwidth:n,arrowlength:s}))}},Nr=class extends se{constructor(e={}){super(e),this.segments.push(new p([[0,0],[0,0],H,[1,0],[1,0]])),this.segments.push(new xe([.5,0],1,.5,{theta1:0,theta2:360})),this.elmParams.theta=90}},Or=class extends se{constructor(e={}){super(e),this.segments.push(new p([[0,0],[0,0],H,[1,0],[1,0]])),this.segments.push(new D([.25,0],.25)),this.segments.push(new D([1-.25,0],.25)),this.elmParams.theta=90}},Fr=class extends se{constructor(e={}){super(e),this.segments.push(new p([[0,0],[0,0],H,[1,0],[1,0]])),this.segments.push(new D([.3,0],.3,{lw:1e-9,ls:"None"})),this.segments.push(new D([1-.3,0],.3,{lw:1e-9,ls:"None"})),this.segments.push(new D([.3,0],.3,{fill:!1})),this.segments.push(new D([1-.3,0],.3,{fill:!1})),this.elmParams.theta=90,this.anchors.common=[.5,Math.sqrt(.3**2-.2**2)]}},$r=class extends se{constructor(e={}){super(e),this.segments.push(new p([[0,0],[0,0],H,[1,0],[1,0]])),this.segments.push(new xe([.7,0],.6,.3,{theta1:0,theta2:360})),this.segments.push(new xe([.3,0],.6,.3,{theta1:0,theta2:360})),this.elmParams.theta=90,this.anchors.common=[.5,Math.sqrt(1-.2**2/.3**2)*.15]}};var wt=2.5,jt=wt*Math.sqrt(3)/2,N0=jt/8,O0=.2,cs=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{sign:!0,leads:!1});let t=T(this.params,"leads",!1),n=T(this.params,"sign",!0),s=wt/4,i=t?s:0;this.segments.push(new p([[i,0],[i,wt/2],[i+jt,0],[i,-wt/2],[i,0],H,[i+jt,0]])),n&&(this.segments.push(new p([[i+N0-O0/2,wt/4],[i+N0+O0/2,wt/4]])),this.segments.push(new p([[i+N0-O0/2,-wt/4],[i+N0+O0/2,-wt/4]])),this.segments.push(new p([[i+N0,-wt/4-O0/2],[i+N0,-wt/4+O0/2]]))),t&&(this.segments.push(new p([[0,wt/4],[s,wt/4]])),this.segments.push(new p([[0,-wt/4],[s,-wt/4]])),this.segments.push(new p([[s+jt,0],[jt+2*s,0]])));let o=jt+2*i;this.anchors.out=[o,0],this.anchors.in1=[0,wt/4],this.anchors.in2=[0,-wt/4],this.anchors.center=[i+jt/2,0],this.anchors.vd=[i+jt/3,.84],this.anchors.vs=[i+jt/3,-.84],this.anchors.n1=[i+jt*2/3,-.42],this.anchors.n2=[i+jt*2/3,.42],this.anchors.n1a=[i+jt*.9,-.13],this.anchors.n2a=[i+jt*.9,.13],this.elmParams.drop=[o,0],Object.assign(this._labelhints,{in1:{ofst:[-.1,.1],halign:"right",valign:"bottom",fontsize:9},in2:{ofst:[-.1,.1],halign:"right",valign:"bottom",fontsize:9},out:{ofst:[0,.1],halign:"left",valign:"bottom",fontsize:9},vd:{ofst:[-.1,.25],halign:"right",valign:"bottom",fontsize:9},vs:{ofst:[-.1,-.25],halign:"right",valign:"top",fontsize:9},n1:{ofst:[-.1,-.25],halign:"right",valign:"top",fontsize:9},n1a:{ofst:[-.1,-.3],halign:"right",valign:"top",fontsize:9},n2:{ofst:[-.1,.25],halign:"right",valign:"bottom",fontsize:9},n2a:{ofst:[-.1,.3],halign:"right",valign:"bottom",fontsize:9}})}};var C=Ye*.5;function g1(r,e,t,n,s){r.push(new p([[-3*C,-6.5*C],[-3*C,-7.5*C]])),r.push(new p([[-3*C,-9.5*C],[-3*C,-10.5*C]])),r.push(new p([[-3*C,-12.5*C],[-3*C,-13.5*C]])),r.push(new p([[0,-7*C],[0,0]])),r.push(new p([[-3*C,-7*C],[0,-7*C]])),r.push(new p([[0,-20*C],[0,-13*C]])),r.push(new p([[-3*C,-13*C],[0,-13*C]]));let i={};return e==="nmos"?(r.push(new p([[-10*C,-14*C],[-5*C,-14*C]])),r.push(new p([[-5*C,-14*C],[-5*C,-6*C]])),r.push(new p([[-3*C,-10*C],[0,-10*C]],{arrow:"<-",arrowwidth:2*C,arrowlength:2*C})),r.push(new p([[0,-10*C],[0,-13*C]])),i.drain=[0,0],i.gate=[-10*C,-14*C],i.center=[0,-10*C],i.source=[0,-20*C]):(r.push(new p([[-10*C,-6*C],[-5*C,-6*C]])),r.push(new p([[-5*C,-6*C],[-5*C,-14*C]])),r.push(new p([[-3*C,-10*C],[0,-10*C]],{arrow:"->",arrowwidth:2*C,arrowlength:2*C})),r.push(new p([[0,-10*C],[0,-7*C]])),i.source=[0,0],i.gate=[-10*C,-6*C],i.center=[0,-10*C],i.drain=[0,-20*C]),t&&(r.push(new p([[0,-7*C],[3*C,-7*C]])),r.push(new p([[3*C,-7*C],[3*C,-9*C]])),r.push(new p([[2*C,-9*C],[4*C,-9*C]])),r.push(new U([[3*C,-9*C],[2*C,-11*C],[4*C,-11*C]],{closed:!0,fill:!1})),r.push(new p([[3*C,-11*C],[3*C,-13*C]])),r.push(new p([[3*C,-13*C],[0,-13*C]]))),n&&r.push(new D([-1*C,-10*C],7*C,{lw:s})),i}var ms=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{diode:!1,circle:!1});let t=T(this.params,"diode",!1),n=T(this.params,"circle",!1),s=T(this.params,"circle_lw",void 0),i=g1(this.segments,"nmos",t,n,s);Object.assign(this.anchors,i),this.elmParams.drop=[0,-20*C],this.elmParams.lblloc="rgt"}},ds=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{diode:!1,circle:!1});let t=T(this.params,"diode",!1),n=T(this.params,"circle",!1),s=T(this.params,"circle_lw",void 0),i=g1(this.segments,"pmos",t,n,s);Object.assign(this.anchors,i),this.elmParams.drop=[0,-20*C],this.elmParams.lblloc="rgt"}};function b1(r,e,t,n,s){r.push(new p([[0,0],[7*C,0],[7*C,-3*C],H,[13*C,-3*C],[13*C,0],[20*C,0]])),r.push(new p([[6.5*C,-3*C],[7.5*C,-3*C]])),r.push(new p([[9.5*C,-3*C],[10.5*C,-3*C]])),r.push(new p([[12.5*C,-3*C],[13.5*C,-3*C]]));let i={};return e==="nmos"?(r.push(new p([[14*C,-10*C],[14*C,-5*C]])),r.push(new p([[14*C,-5*C],[6*C,-5*C]])),r.push(new p([[10*C,-3*C],[10*C,0]],{arrow:"<-",arrowwidth:2*C,arrowlength:2*C})),r.push(new p([[10*C,0],[13*C,0]])),i.drain=[0,0],i.gate=[14*C,-10*C],i.source=[20*C,0]):(r.push(new p([[6*C,-10*C],[6*C,-5*C]])),r.push(new p([[6*C,-5*C],[14*C,-5*C]])),r.push(new p([[10*C,-3*C],[10*C,0]],{arrow:"->",arrowwidth:2*C,arrowlength:2*C})),r.push(new p([[10*C,0],[7*C,0]])),i.source=[0,0],i.gate=[6*C,-10*C],i.drain=[20*C,0]),i.center=[10*C,0],t&&(r.push(new p([[7*C,0],[7*C,3*C]])),r.push(new p([[7*C,3*C],[9*C,3*C]])),r.push(new p([[9*C,2*C],[9*C,4*C]])),r.push(new U([[9*C,3*C],[11*C,2*C],[11*C,4*C]],{closed:!0,fill:!1})),r.push(new p([[11*C,3*C],[13*C,3*C]])),r.push(new p([[13*C,3*C],[13*C,0]]))),n&&r.push(new D([10*C,-1*C],7*C,{lw:s})),i}var ps=class extends se{constructor(e={}){super(e),Object.assign(this.defaults,{diode:!1,circle:!1});let t=T(this.params,"diode",!1),n=T(this.params,"circle",!1),s=T(this.params,"circle_lw",void 0),i=b1(this.segments,"nmos",t,n,s);Object.assign(this.anchors,i),this.elmParams.drop=[20*C,0],this.elmParams.lblloc="bottom"}},fs=class extends se{constructor(e={}){super(e),Object.assign(this.defaults,{diode:!1,circle:!1});let t=T(this.params,"diode",!1),n=T(this.params,"circle",!1),s=T(this.params,"circle_lw",void 0),i=b1(this.segments,"pmos",t,n,s);Object.assign(this.anchors,i),this.elmParams.drop=[20*C,0],this.elmParams.lblloc="bottom"}},q=Ye*4,m2=Ye*5,O=m2/2,tt=Ye,Xe=Ye*.7,gs=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{bulk:!1,arrowlength:.25,arrowwidth:.2}),this.segments.push(new p([[0,0],[0,-O],[q,-O],[q,-O-q],[0,-O-q],[0,-2*O-q]])),this.segments.push(new p([[q+tt,-O],[q+tt,-O-q]])),this.segments.push(new p([[q+tt,-O-q/2],[q+tt+O+Xe,-O-q/2]])),this.anchors.source=[0,-2*O-q],this.anchors.drain=[0,0],this.anchors.gate=[q+tt+O+Xe,-O-q/2],this.anchors.center=[0,-O-q/2],this.elmParams.drop=[0,-2*O-q],this.elmParams.lblloc="lft",T(this.params,"bulk",!1)&&(this.segments.push(new p([[0,-O-q/2],[q,-O-q/2]],{arrow:"->",arrowwidth:T(this.params,"arrowwidth",.2),arrowlength:T(this.params,"arrowlength",.25)})),this.anchors.bulk=[0,-O-q/2])}},bs=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{bulk:!1,arrowlength:.25,arrowwidth:.2}),this.segments.push(new p([[0,0],[0,-O],[q,-O],[q,-O-q],[0,-O-q],[0,-2*O-q]])),this.segments.push(new p([[q+tt,-O],[q+tt,-O-q]])),this.segments.push(new p([[q+tt+Xe*2,-O-q/2],[q+tt+O+Xe,-O-q/2]])),this.segments.push(new D([q+tt+Xe,-O-q/2],Xe)),this.anchors.source=[0,0],this.anchors.drain=[0,-2*O-q],this.anchors.gate=[q+tt+O+Xe,-O-q/2],this.anchors.center=[0,-O-q/2],this.elmParams.drop=[0,-2*O-q],this.elmParams.lblloc="lft",T(this.params,"bulk",!1)&&(this.segments.push(new p([[0,-O-q/2],[q,-O-q/2]],{arrow:"->",arrowwidth:T(this.params,"arrowwidth",.2),arrowlength:T(this.params,"arrowlength",.25)})),this.anchors.bulk=[0,-O-q/2])}},ws=class extends se{constructor(e={}){super(e),Object.assign(this.defaults,{bulk:!1,arrowlength:.25,arrowwidth:.2}),this.segments.push(new p([[0,0],[O,0],[O,q],[O+q,q],[O+q,0],[2*O+q,0]])),this.segments.push(new p([[O,q+tt],[O+q,q+tt]])),this.segments.push(new p([[O+q/2,q+tt],[O+q/2,q+tt+Xe+O]])),this.anchors.isource=[2*O+q,0],this.anchors.idrain=[0,0],this.anchors.gate=[O+q/2,q+tt+Xe+O],this.elmParams.lblloc="bottom",T(this.params,"bulk",!1)&&(this.segments.push(new p([[O+q/2,0],[O+q/2,q]],{arrow:"->",arrowwidth:T(this.params,"arrowwidth",.2),arrowlength:T(this.params,"arrowlength",.25)})),this.anchors.bulk=[O+q/2,0])}placeAnchors(e,t){super.placeAnchors(e,t),this.anchors.source=this.anchors.end,this.anchors.drain=this.anchors.start,T(this.params,"reverse",!1)&&(this.anchors.source=this.anchors.start,this.anchors.drain=this.anchors.end)}},xs=class extends se{constructor(e={}){super(e),Object.assign(this.defaults,{bulk:!1,arrowlength:.25,arrowwidth:.2}),this.segments.push(new p([[0,0],[O,0],[O,q],[O+q,q],[O+q,0],[2*O+q,0]])),this.segments.push(new p([[O,q+tt],[O+q,q+tt]])),this.segments.push(new D([O+q/2,q+tt+Xe],Xe)),this.segments.push(new p([[O+q/2,q+tt+Xe*2],[O+q/2,q+tt+Xe+O]])),this.anchors.isource=[2*O+q,0],this.anchors.idrain=[0,0],this.anchors.gate=[O+q/2,q+tt+Xe+O],this.elmParams.lblloc="bottom",T(this.params,"bulk",!1)&&(this.segments.push(new p([[O+q/2,0],[O+q/2,q]],{arrow:"->",arrowwidth:T(this.params,"arrowwidth",.2),arrowlength:T(this.params,"arrowlength",.25)})),this.anchors.bulk=[O+q/2,0])}placeAnchors(e,t){super.placeAnchors(e,t),this.anchors.source=this.anchors.end,this.anchors.drain=this.anchors.start,T(this.params,"reverse",!1)&&(this.anchors.source=this.anchors.start,this.anchors.drain=this.anchors.end)}},Re=Ye*2.5,me=Re*2,ne=me*.5,Ve=Re*.2,yt=me*.1,Vl=yt*.75,us=.25,F0=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{bulk:!1,offset_gate:!0,arrow:!0});let t=T(this.params,"bulk",!1),n=T(this.params,"offset_gate",!0),i=T(this.params,"arrow",!0)&&!t;this.segments.push(new p([[0,0],[0,-ne],[Re,-ne],[Re,-ne-me],[0,-ne-me],[0,-2*ne-me]])),i&&this.segments.push(new p([[Re,-ne-me],[0,-ne-me]],{arrow:"->",arrowwidth:us,arrowlength:us})),this.segments.push(new p([[Re+Ve,-ne-yt],[Re+Ve,-ne-me+yt]])),n?(this.segments.push(new p([[Re+Ve,-ne-me+yt],[Re+Ve+ne,-ne-me+yt]])),this.anchors.gate=[Re+Ve+ne,-ne-me+yt]):(this.segments.push(new p([[Re+Ve,-ne-me/2],[Re+Ve+ne,-ne-me/2]])),this.anchors.gate=[Re+Ve+ne,-ne-me/2]),this.anchors.source=[0,-2*ne-me],this.anchors.drain=[0,0],this.anchors.center=[0,-ne-me/2],this.elmParams.drop=[0,-2*ne-me],this.elmParams.lblloc="lft",t&&(this.segments.push(new p([[0,-ne-me/2],[Re,-ne-me/2]],{arrow:"->",arrowwidth:us,arrowlength:us})),this.anchors.bulk=[0,-ne-me/2])}},$0=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{bulk:!1,offset_gate:!0,arrow:!0});let t=T(this.params,"bulk",!1),n=T(this.params,"offset_gate",!0),i=T(this.params,"arrow",!0)&&!t;this.segments.push(new p([[0,0],[0,-ne],[Re,-ne],[Re,-ne-me],[0,-ne-me],[0,-2*ne-me]])),i&&this.segments.push(new p([[0,-ne],[Re,-ne]],{arrow:"->",arrowwidth:us,arrowlength:us})),this.segments.push(new p([[Re+Ve,-ne-yt],[Re+Ve,-ne-me+yt]])),n?(this.segments.push(new p([[Re+Ve,-ne-yt],[Re+Ve+ne,-ne-yt]])),this.anchors.gate=[Re+Ve+ne,-ne-yt]):(this.segments.push(new p([[Re+Ve,-ne-me/2],[Re+Ve+ne,-ne-me/2]])),this.anchors.gate=[Re+Ve+ne,-ne-me/2]),this.anchors.source=[0,0],this.anchors.drain=[0,-2*ne-me],this.anchors.center=[0,-ne-me/2],this.elmParams.drop=[0,-2*ne-me],this.elmParams.lblloc="lft",t&&(this.segments.push(new p([[Re,-ne-me/2],[0,-ne-me/2]],{arrow:"->",arrowwidth:us,arrowlength:us})),this.anchors.bulk=[0,-ne-me/2])}},j0=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{bulk:!1,offset_gate:!0,arrow:!0});let t=T(this.params,"bulk",!1),n=T(this.params,"offset_gate",!0),i=T(this.params,"arrow",!0)&&!t;this.segments.push(new p([[0,0],[0,-ne],[Re,-ne],[Re,-ne-me],[0,-ne-me],[0,-2*ne-me]])),i&&this.segments.push(new D([Vl*2,-ne-me],Vl,{fill:!0})),this.segments.push(new p([[Re+Ve,-ne-yt],[Re+Ve,-ne-me+yt]])),n?(this.segments.push(new p([[Re+Ve,-ne-me+yt],[Re+Ve+ne,-ne-me+yt]])),this.anchors.gate=[Re+Ve+ne,-ne-me+yt]):(this.segments.push(new p([[Re+Ve,-ne-me/2],[Re+Ve+ne,-ne-me/2]])),this.anchors.gate=[Re+Ve+ne,-ne-me/2]),this.anchors.source=[0,-2*ne-me],this.anchors.drain=[0,0],this.anchors.center=[0,-ne-me/2],this.elmParams.drop=[0,-2*ne-me],this.elmParams.lblloc="lft",t&&(this.segments.push(new p([[0,-ne-me/2],[Re,-ne-me/2]])),this.segments.push(new D([Re-Vl*2,-ne-me/2],Vl,{fill:!0})),this.anchors.bulk=[0,-ne-me/2])}},Jl=q*.2,ue=Ye*3,vs=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{circle:!1,arrowlength:.25,arrowwidth:.2}),this.segments.push(new p([[0,0],[0,-O],[ue,-O],[ue,-O+Jl],[ue,-O-ue-Jl],[ue,-O-ue],[0,-O-ue],[0,-2*O-ue]])),this.segments.push(new p([[ue,-O-ue],[ue+O,-O-ue]])),this.elmParams.drop=[ue+O,-O-ue],this.anchors.source=[0,-2*O-ue],this.anchors.drain=[0,0],this.anchors.gate=[ue+O,-O-ue],this.anchors.center=[0,-O-ue/2],this.elmParams.lblloc="lft",T(this.params,"circle",!1)&&this.segments.push(new D([ue/2,-q],q*1.1,{lw:T(this.params,"circle_lw",void 0)}))}},q0=class extends vs{constructor(e={}){super(e),this.segments.push(new p([[ue+.1,-O-ue],[ue+.3,-O-ue]],{arrow:"->",arrowwidth:T(this.params,"arrowwidth",.2),arrowlength:T(this.params,"arrowlength",.25)}))}},H0=class extends vs{constructor(e={}){super(e),this.segments.push(new p([[ue+.25,-O-ue],[ue,-O-ue]],{arrow:"->",arrowwidth:T(this.params,"arrowwidth",.2),arrowlength:T(this.params,"arrowlength",.25)}))}},ys=class extends se{constructor(e={}){super(e),Object.assign(this.defaults,{circle:!1,arrowlength:.25,arrowwidth:.2}),this.segments.push(new p([[0,0],[O,0],[O,ue],[O+ue,ue],[O+ue,0],[2*O+ue,0]])),this.segments.push(new p([[O-Jl,ue],[O+ue+Jl,ue]])),this.segments.push(new p([[O+ue,ue],[O+ue,ue+O]])),this.anchors.isource=[2*O+ue,0],this.anchors.idrain=[0,0],this.anchors.gate=[O+ue,ue+O],this.elmParams.lblloc="bottom",T(this.params,"circle",!1)&&this.segments.push(new D([O+ue/2,ue/2],q*1.1,{lw:T(this.params,"circle_lw",void 0)}))}placeAnchors(e,t){super.placeAnchors(e,t),this.anchors.source=this.anchors.end,this.anchors.drain=this.anchors.start,T(this.params,"reverse",!1)&&(this.anchors.source=this.anchors.start,this.anchors.drain=this.anchors.end)}},Y0=class extends ys{constructor(e={}){super(e),this.segments.push(new p([[O+ue,ue],[O+ue,ue+.3]],{arrow:"->",arrowwidth:T(this.params,"arrowwidth",.2),arrowlength:T(this.params,"arrowlength",.25)}))}},X0=class extends ys{constructor(e={}){super(e),this.segments.push(new p([[O+ue,ue+.3],[O+ue,ue]],{arrow:"->",arrowwidth:T(this.params,"arrowwidth",.2),arrowlength:T(this.params,"arrowlength",.25)}))}},Ma=(q+2*Xe)/5,G0=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{split:!0,arrow:!0,arrowlength:.25,arrowwidth:.2});let t=T(this.params,"split",!0),n=this.params.arrow,s=T(this.params,"arrowwidth",.2),i=T(this.params,"arrowlength",.25);t?this.segments.push(new p([[0,0],[0,-O],[q,-O],H,[q,-O+Xe],[q,-O+Xe-Ma],H,[q,-O+Xe-2*Ma],[q,-O+Xe-3*Ma],H,[q,-O+Xe-4*Ma],[q,-O+Xe-5*Ma],H,[q,-O-q],[0,-O-q],[0,-2*O-q]])):this.segments.push(new p([[0,0],[0,-O],[q,-O],H,[q,-O+Xe],[q,-O-q-Xe],H,[q,-O-q],[0,-O-q],[0,-2*O-q]])),this.segments.push(new p([[q,-O-q/2],[q+O+Xe,-O-q/2]])),n===">"?this.segments.push(new p([[0,-O-q],[q,-O-q]],{arrow:"->",arrowwidth:s,arrowlength:i})):n!==!1&&this.segments.push(new p([[0,-O-q],[q,-O-q]],{arrow:"<-",arrowwidth:s,arrowlength:i})),this.anchors.drain=[0,-2*O-q],this.anchors.source=[0,0],this.anchors.gate=[q+O+Xe,-O-q/2],this.anchors.center=[0,-O-q/2],this.elmParams.drop=[0,-2*O-q],this.elmParams.lblloc="lft"}},za=Ye*3.3,pe=za*2/3,ht=za*(4/3),tr=ht/4,It=pe+za*.7,qt=ht*.7,qr=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{circle:!1,arrowwidth:.2,arrowlength:.25}),this.segments.push(new p([[0,0],[pe,0]])),this.segments.push(new p([[pe,ht/2],[pe,-ht/2]])),this.segments.push(new p([[pe,tr],[It,qt],[It,qt+tr]])),this.segments.push(new p([[pe,-tr],[It,-qt],[It,-qt-tr]])),T(this.params,"circle",!1)&&this.segments.push(new D([za,0],za,{lw:T(this.params,"circle_lw",void 0)})),this.elmParams.drop=[It,qt+tr],this.anchors.base=[0,0],this.anchors.collector=[It,qt+tr],this.anchors.emitter=[It,-qt-tr],this.anchors.center=[It,0]}},Ht=class extends qr{constructor(e={}){super(e),this.segments.push(new p([[pe,-tr],[It,-qt]],{arrow:"->",arrowwidth:T(this.params,"arrowwidth",.2),arrowlength:T(this.params,"arrowlength",.25)}))}},rr=class extends qr{constructor(e={}){super(e),this.segments.push(new p([[It,qt],[pe,tr]],{arrow:"->",arrowwidth:T(this.params,"arrowwidth",.2),arrowlength:T(this.params,"arrowlength",.25)})),this.anchors.base=[0,0],this.anchors.collector=[It,-qt-tr],this.anchors.emitter=[It,qt+tr]}},f1=.55,Ea=.2,Ul=.75,jr=.42,Ct=1.1,Hr=class extends se{constructor(e={}){super(e),Object.assign(this.defaults,{circle:!1,lblloc:"bottom",theta:90,arrowwidth:.2,arrowlength:.25}),this.segments.push(new p([[0,0],[Ct/2-Ea,jr],[Ct/2+Ea,jr],[Ct,0]])),this.segments.push(new p([[Ct/2-Ul/2,jr],[Ct/2+Ul/2,jr]])),this.segments.push(new p([[Ct/2,jr],[Ct/2,jr+Ul/2]])),T(this.params,"circle",!1)&&this.segments.push(new D([Ct/2,f1/2],f1,{lw:T(this.params,"circle_lw",void 0)})),this.anchors.base=[Ct/2,jr+Ul/2],this.anchors.icollector=[Ct,0],this.anchors.iemitter=[0,0]}placeAnchors(e,t){super.placeAnchors(e,t),this.anchors.emitter=this.anchors.start,this.anchors.collector=this.anchors.end,T(this.params,"reverse",!1)&&(this.anchors.emitter=this.anchors.end,this.anchors.collector=this.anchors.start)}},Ss=class extends Hr{constructor(e={}){super(e),this.segments.push(new p([[0,0],[Ct/2-Ea,jr]],{arrow:"->",arrowwidth:T(this.params,"arrowwidth",.2),arrowlength:T(this.params,"arrowlength",.25)}))}},ln=class extends Hr{constructor(e={}){super(e),this.segments.push(new p([[Ct/2+Ea,jr],[Ct,0]],{arrow:"->",arrowwidth:T(this.params,"arrowwidth",.2),arrowlength:T(this.params,"arrowlength",.25)}));let t=this.anchors.icollector,n=this.anchors.iemitter;this.anchors.icollector=n,this.anchors.iemitter=t}placeAnchors(e,t){super.placeAnchors(e,t),this.anchors.emitter=this.anchors.end,this.anchors.collector=this.anchors.start,T(this.params,"reverse",!1)&&(this.anchors.emitter=this.anchors.start,this.anchors.collector=this.anchors.end)}},W0=class extends rr{constructor(e={}){super(e);let t=-.25;this.segments.push(new p([[pe,-tr-t],[It,-qt-t]])),this.anchors.C2=[It,-qt-t]}},xt=.1,V0=class extends Ht{constructor(e={}){super(e),this.segments.push(new p([[pe,ht/2],[pe,ht/2+xt],[pe+xt,ht/2+xt],[pe+xt,ht/2]])),this.segments.push(new p([[pe,-ht/2],[pe,-ht/2-xt],[pe-xt,-ht/2-xt],[pe-xt,-ht/2]]))}},U0=class extends rr{constructor(e={}){super(e),this.segments.push(new p([[pe,ht/2],[pe,ht/2+xt],[pe-xt,ht/2+xt],[pe-xt,ht/2]])),this.segments.push(new p([[pe,-ht/2],[pe,-ht/2-xt],[pe+xt,-ht/2-xt],[pe+xt,-ht/2]]))}},J0=class extends Ht{constructor(e={}){super(e),this.segments.shift();let t=.25;this.segments.push(new p([[-.1,pe],[pe*.75,.1]],{arrow:"->",arrowwidth:T(this.params,"arrowwidth",.2),arrowlength:T(this.params,"arrowlength",.25)})),this.segments.push(new p([[-.1,pe-t],[pe*.75,.1-t]],{arrow:"->",arrowwidth:T(this.params,"arrowwidth",.2),arrowlength:T(this.params,"arrowlength",.25)}))}},K0=class extends rr{constructor(e={}){super(e),this.segments.shift();let t=.25;this.segments.push(new p([[-.1,pe],[pe*.75,.1]],{arrow:"->",arrowwidth:T(this.params,"arrowwidth",.2),arrowlength:T(this.params,"arrowlength",.25)})),this.segments.push(new p([[-.1,pe-t],[pe*.75,.1-t]],{arrow:"->",arrowwidth:T(this.params,"arrowwidth",.2),arrowlength:T(this.params,"arrowlength",.25)}))}},vt=.15,Z0=class extends Ht{constructor(e={}){super(e),this.segments.shift(),this.segments.push(new p([[pe-vt,pe-vt/2],[pe-vt,-pe+vt/2],[pe-vt*2,-pe+vt/2]])),this.anchors.base=[pe-vt*2,-pe+vt/2]}},Q0=class extends rr{constructor(e={}){super(e),this.segments.shift(),this.segments.push(new p([[pe-vt*2,pe-vt/2],[pe-vt,pe-vt/2],[pe-vt,-pe+vt/2]])),this.anchors.base=[pe-vt*2,pe-vt/2]}},ei=class extends ln{constructor(e={}){super(e);let t=.25;this.segments.push(new p([[t,0],[t+Ct/2-Ea,jr]])),this.anchors.C2=[t,0]}};function Bc(r){let e=r[0].toUpperCase();return e==="L"||e==="R"||e==="T"||e==="B"?e:"L"}var Kl=class{constructor(e={}){z(this,"name");z(this,"pin");z(this,"side");z(this,"pos");z(this,"slot");z(this,"invert",!1);z(this,"invertradius",.15);z(this,"color");z(this,"rotation",0);z(this,"anchorname");z(this,"lblsize");z(this,"pinlblsize");z(this,"href");z(this,"decoration");this.side=e.side!==void 0?Bc(String(e.side)):"L",e.name!==void 0&&(this.name=e.name),e.pin!==void 0&&(this.pin=e.pin),e.pos!==void 0&&(this.pos=e.pos),e.slot!==void 0&&(this.slot=e.slot),e.invert!==void 0&&(this.invert=e.invert),e.invertradius!==void 0&&(this.invertradius=e.invertradius),e.color!==void 0&&(this.color=e.color),e.rotation!==void 0&&(this.rotation=e.rotation),e.anchorname!==void 0&&(this.anchorname=e.anchorname),e.lblsize!==void 0&&(this.lblsize=e.lblsize),e.pinlblsize!==void 0&&(this.pinlblsize=e.pinlblsize),e.href!==void 0&&(this.href=e.href),e.decoration!==void 0&&(this.decoration=e.decoration)}};function d2(r,e){let t=Math.max(.15,r.length*e/72),n=e/72*1.2;return[t*2,n*2]}function w1(r){return{...r}}var nr=class extends N{constructor(t={}){let{size:n,pins:s,slant:i,label:o,...a}=t;super({...a,...o!==void 0?{label:o}:{}});z(this,"size");z(this,"slant");z(this,"pins");z(this,"usersides");z(this,"sides");z(this,"pincount",{L:0,R:0,T:0,B:0});z(this,"_sizeauto");z(this,"_icbox");z(this,"_dflt");if(Object.assign(this.defaults,{pinspacing:0,edgepadH:.5,edgepadW:.5,leadlen:.5,lsize:14,lofst:.15,plblofst:.075,plblsize:11}),this.slant=i??0,this.pins={L:[],R:[],T:[],B:[]},this.usersides={},this.sides={L:this.mkSide(),R:this.mkSide(),T:this.mkSide(),B:this.mkSide()},this._dflt=this.mkSide(),this.size=n??this.params.size,s)for(let l of s)this.pins[l.side].push({...l,side:l.side});this._setsize()}mkSide(){return{spacing:T(this.params,"pinspacing",0),pad:T(this.params,"edgepadH",.25),leadlen:T(this.params,"leadlen",.5),label_ofst:T(this.params,"lofst",.15),label_size:T(this.params,"lsize",14),pinlabel_ofst:T(this.params,"plblofst",.05),pinlabel_size:T(this.params,"plblsize",11)}}pin(t){let n=Bc(t.side??"L"),s={side:n,name:t.name,pin:t.pin,pos:t.pos,slot:t.slot,invert:t.invert??!1,invertradius:t.invertradius??.15,color:t.color,rotation:t.rotation??0,anchorname:t.anchorname,lblsize:t.lblsize,pinlblsize:t.pinlblsize,href:t.href,decoration:t.decoration};return this.pins[n].push(s),this._setsize(),this}side(t,n=0,s=.5,i=.5,o=.15,a=14,l=.05,h=11){let c=Bc(t);return this.usersides[c]={spacing:n,pad:s,leadlen:i,label_ofst:o,label_size:a,pinlabel_ofst:l,pinlabel_size:h},this._setsize(),this}get pinnames(){let t=[];for(let n of["L","R","T","B"])for(let s of this.pins[n])s.name&&t.push(s.anchorname??s.name);return t}getAnchorNamesForGetattr(){let t=new Set(super.getAnchorNamesForGetattr());for(let n of["L","R","T","B"])for(let s of this.pins[n])s.name&&t.add(s.anchorname??s.name),s.pin&&t.add(`pin${s.pin}`);return[...t]}getPinAnchor(t){return this.resolveAnchor(t)}_countpins(){let t={L:0,R:0,T:0,B:0};for(let n of["L","R","T","B"]){let i=this.pins[n].map(o=>o.slot).filter(o=>o!=null).map(o=>Number(o.split("/")[1])).concat([0]);t[n]=Math.max(this.pins[n].length,Math.max(...i))}return t}_autosize(){let t={},n={};for(let a of["L","R","T","B"]){let l=w1(this.usersides[a]??this._dflt);l.spacing===0&&(l={...l,spacing:.6}),this.sides[a]=l;let h=Math.max(1,this.pincount[a]);t[a]=l.pad*2+l.spacing*(h-1);let c=0;for(let m of this.pins[a])if(m.name){let f=m.lblsize??T(this.params,"lsize",14);c=Math.max(c,d2(m.name,f)[0])}n[a]=c}let s=n.L+n.R+4*T(this.params,"lofst",.15),i=Math.max(t.L??0,t.R??0,2+T(this.params,"edgepadH",.5)),o=Math.max(t.T??0,t.B??0,2+T(this.params,"edgepadW",.5),s);this._sizeauto=[o,i];for(let a of["L","R"]){let l=this.sides[a],h=Math.max(1,this.pincount[a]);l.pad=(i-l.spacing*(h-1))/2}for(let a of["T","B"]){let l=this.sides[a],h=Math.max(1,this.pincount[a]);l.pad=(o-l.spacing*(h-1))/2}}_autopinlayout(){let t=this.size;for(let n of["L","R","T","B"]){let s=w1(this.usersides[n]??this._dflt);this.sides[n]=s;let i=["T","B"].includes(n)?t[0]:t[1],o=s.pad;s.spacing===0?this.pincount[n]>1?s.spacing=(i-2*o)/(this.pincount[n]-1):s.pad=i/2:s.pad=(i-s.spacing*(this.pincount[n]-1))/2}}_setsize(){this.pincount=this._countpins(),this.size===void 0?this._autosize():this._autopinlayout()}_drawBox(){let t,n;this.size?[t,n]=this.size:this._sizeauto?[t,n]=this._sizeauto:(t=2,n=3);let s=t*Math.tan(this.slant*Math.PI/180),i=0,o=n,a;return this.slant>0?(i=0-s,o=n+s,a=[new A(0,0),new A(t,i),new A(t,o),new A(0,n),new A(0,0)]):this.slant<0?(i=0+s,o=n-s,a=[new A(0,i),new A(t,0),new A(t,n),new A(0,o),new A(0,i)]):(i=0,o=n,a=[new A(0,0),new A(t,0),new A(t,n),new A(0,n),new A(0,0)]),this.segments.push(new p(a.map(l=>[l.x,l.y]),{})),{w:t,h:n,y1:i,y2:o}}_pinpos(t,n,s){let i=this.sides[t]??this._dflt,o=i.spacing>0?i.spacing:.6,a=s;n.slot&&(a=Number(n.slot.split("/")[0])-1);let l=i.pad+a*o;n.pos!==void 0&&n.pos!==null&&(l=i.pad+n.pos*(this.pincount[t]-1)*o);let h;return t==="L"?h=new A(0,l):t==="R"?h=new A(this._icbox.w,l):t==="T"?h=new A(l,this._icbox.h):h=new A(l,0),t==="T"&&this.slant>0?h=new A(h.x,h.y-h.x*Math.tan(-this.slant*Math.PI/180)):t==="T"&&this.slant<0?h=new A(h.x,h.y+(this._icbox.y2-this._icbox.h)-h.x*Math.tan(-this.slant*Math.PI/180)):t==="B"&&this.slant<0?h=new A(h.x,h.y-(this._icbox.y2-this._icbox.h)-h.x*Math.tan(this.slant*Math.PI/180)):t==="B"&&this.slant>0&&(h=new A(h.x,h.y-h.x*Math.tan(this.slant*Math.PI/180))),h}_drawClkpin(t,n,s){let i=this.sides[s]??this._dflt,o=.4*(i.label_size/16),a=.2*(i.label_size/16),l;if(s==="T"||s==="B"){let h=n.y!==0?Math.sign(n.y):1,c=Math.abs(o)*h;l=[new A(t.x-a,t.y),new A(t.x,t.y-c),new A(t.x+a,t.y)]}else{let h=n.x!==0?-Math.sign(n.x):1,c=Math.abs(o)*h;l=[new A(t.x,t.y+a),new A(t.x+c,t.y),new A(t.x,t.y-a)]}this.segments.push(new p(l.map(h=>[h.x,h.y])))}_drawPin(t,n,s){let i=this.sides[t]??this._dflt,o=this._pinpos(t,n,s),l={L:new A(-i.leadlen,0),R:new A(i.leadlen,0),T:new A(0,i.leadlen),B:new A(0,-i.leadlen)}[t],h=o.add(l);if(this.anchors[`in${t}${s+1}`]=[h.x,h.y],n.anchorname?this.anchors[n.anchorname]=[h.x,h.y]:n.name&&(n.name===">"&&(this.anchors.CLK=[h.x,h.y]),this.anchors[n.name]=[h.x,h.y]),n.pin&&(this.anchors[`pin${n.pin}`]=[h.x,h.y]),i.leadlen>0)if(n.invert){let c=n.invertradius??.15,f={L:new A(-c,0),R:new A(c,0),T:new A(0,c),B:new A(0,-c)}[t],g=o.add(f);this.segments.push(new D([g.x,g.y],c));let b=g.add(f.mul(2));this.segments.push(new p([[b.x,b.y],[h.x,h.y]],{}))}else this.segments.push(new p([[o.x,o.y],[h.x,h.y]],{}));if(n.pin){let c=(n.invert?n.invertradius??.15:0)*(n.invert?1:0),m=i.pinlabel_ofst,g={L:new A(-m-c*2,m),R:new A(m+c*2,m),T:new A(m,m+c*2),B:new A(m,-m-c*2)}[t],b=this.userParams.flip===!0,v=this.userParams.reverse===!0,x={L:"right",R:"left",T:"left",B:"left"},S={L:"bottom",R:"bottom",T:"bottom",B:"top"},k=x[t],M=S[t];b&&(t==="L"||t==="R")&&(g=g.flip()),b&&(t==="T"||t==="B")&&(M=t==="T"?"top":"bottom"),v&&(t==="L"||t==="R")&&(k=t==="L"?"left":"right"),v&&(t==="T"||t==="B")&&(g=g.mirrorx(0));let _=o.add(g);this.segments.push(new W([_.x,_.y],String(n.pin),{fontsize:n.pinlblsize??i.pinlabel_size,align:[k,M]}))}if(n.name===">"){this._drawClkpin(o,l,t);return}if(n.name&&n.name!==""){let c={L:new A(i.label_ofst,0),R:new A(-i.label_ofst,0),T:new A(0,-i.label_ofst),B:new A(0,i.label_ofst)},m=o.add(c[t]),f=this.userParams.flip===!0,g=this.userParams.reverse===!0,b={L:"left",R:"right",T:"center",B:"center"},v={L:"center",R:"center",T:"top",B:"bottom"},x=b[t],S=v[t];f&&(t==="T"||t==="B")&&(S=t==="T"?"bottom":"top"),g&&(t==="L"||t==="R")&&(x=t==="L"?"right":"left"),this.segments.push(new W([m.x,m.y],n.name,{fontsize:n.lblsize??i.label_size,color:n.color??void 0,align:[x,S],href:n.href??void 0,decoration:n.decoration??void 0,rotation:n.rotation??0}))}}_drawPins(){for(let t of["L","R","T","B"])this.pins[t].forEach((n,s)=>this._drawPin(t,n,s))}_place(t,n,s){return this.anchors={},this._setsize(),this._icbox=this._drawBox(),this._drawPins(),this.elmParams.lblloc="center",this.anchors.center=[this._icbox.w/2,this._icbox.h/2],this.elmParams.drop=[this._icbox.w,this._icbox.h/2],super._place(t,n,s)}},ti=class extends nr{constructor(e={}){let{demux:t=!1,...n}=e,s=e.slant!==void 0?e.slant:25;super({...n,slant:t?s:-s})}},ri=class extends nr{constructor(e={}){let{preclr:t=!1,preclrinvert:n=!0,...s}=e,i=[{name:"D",side:"L",slot:"2/2"},{name:">",side:"L",slot:"1/2"},{name:"Q",side:"R",slot:"2/2"},{name:"Q",side:"R",slot:"1/2",anchorname:"Qbar",decoration:"overline"}];t&&(i.push({name:"PRE",side:"T",invert:n}),i.push({name:"CLR",side:"B",invert:n})),super({...s,pins:i,size:s.size??[2,3]})}},ni=class extends nr{constructor(e={}){let{preclr:t=!1,preclrinvert:n=!0,...s}=e,i=[{name:"J",side:"L",slot:"3/3"},{name:">",side:"L",slot:"2/3"},{name:"K",side:"L",slot:"1/3"},{name:"Q",side:"R",slot:"3/3"},{name:"Q",side:"R",slot:"1/3",anchorname:"Qbar",decoration:"overline"}];t&&(i.push({name:"PRE",side:"T",invert:n}),i.push({name:"CLR",side:"B",invert:n})),super({...s,pins:i,size:s.size??[2,3]})}},si=class extends nr{constructor(e={}){let t=[{name:"in",side:"L",slot:"3/3"},{name:"out",side:"R",slot:"3/3"},{name:"gnd",side:"B"}];super({...e,pins:t,size:e.size??[2,1.5]})}},ii=class extends nr{constructor(e={}){let t=[{name:"TRG",side:"L",pin:"2"},{name:"THR",side:"L",pin:"6"},{name:"DIS",side:"L",pin:"7"},{name:"CTL",side:"R",pin:"5"},{name:"OUT",side:"R",pin:"3"},{name:"RST",side:"T",pin:"4"},{name:"Vcc",side:"T",pin:"8"},{name:"GND",side:"B",pin:"1"}];super({...e,edgepadW:.5,edgepadH:1,pinspacing:1.5,leadlen:1,pins:t,label:"555"})}};function Cc(r){let e=r.bottom??0,t=r.left??0,n=r.seglen??1.5,s=r.segw??.3,i=r.spacing??.12,o=r.digit??8,a=r.segcolor??"red",l=r.tilt??10,h=r.labelsegments??!0,c=s/2,m=s/5,f=i/2,g=l*Math.PI/180,b=Math.sin(g),v=[f,f+c,n-f-c,n-f,n-f-c,f+c],x=[0,c,c,0,-c,-c],S=[...v],k=[...v],M=x.map(Te=>Te+n*2),_=x.map(Te=>Te+n),B=[0,c,c,0,-c,-c],$=[f,f+c,n-f-c,n-f,n-f-c,f+c],Y=[...B],Z=$.map(Te=>Te+n),L=B.map(Te=>Te+n),I=[...Z],X=[...L],j=[...$],re=[n/2+f,n*2+c+m],te=[n/2+f,n+c+m],ke=[n/2+f,c+m],he=[n+c+f,n*1.5],ve=[n+c+f,n*.5],de=[-c-f,n*.5],Fe=[-c-f,n*1.5],qe=Te=>[Te[0]+Te[1]*b,Te[1]],Ie=t;l!==0&&(S=S.map((Te,nt)=>Te+b*M[nt]),L=L.map((Te,nt)=>Te+b*I[nt]),X=X.map((Te,nt)=>Te+b*j[nt]),v=v.map((Te,nt)=>Te+b*x[nt]),B=B.map((Te,nt)=>Te+b*$[nt]),Y=Y.map((Te,nt)=>Te+b*Z[nt]),k=k.map((Te,nt)=>Te+b*_[nt]),re=qe(re),te=qe(te),ke=qe(ke),he=qe(he),ve=qe(ve),de=qe(de),Fe=qe(Fe),Ie-=b*n);let ge=Te=>Te.map(nt=>nt+Ie),Me=Te=>Te.map(nt=>nt+e);v=ge(v),x=Me(x),k=ge(k),_=Me(_),S=ge(S),M=Me(M),B=ge(B),$=Me($),Y=ge(Y),Z=Me(Z),L=ge(L),I=Me(I),X=ge(X),j=Me(j),re=[re[0]+Ie,re[1]+e],te=[te[0]+Ie,te[1]+e],ke=[ke[0]+Ie,ke[1]+e],he=[he[0]+Ie,he[1]+e],ve=[ve[0]+Ie,ve[1]+e],de=[de[0]+Ie,de[1]+e],Fe=[Fe[0]+Ie,Fe[1]+e];let be=String(o).toLowerCase(),Be=["2","3","5","6","7","8","9","0","a","c","e","f"].includes(be)?a:void 0,De=["1","2","3","4","7","8","9","0","a","d"].includes(be)?a:void 0,ye=["1","3","4","5","6","7","8","9","0","a","b","d"].includes(be)?a:void 0,_e=["2","3","5","6","8","9","0","b","c","d","e"].includes(be)?a:void 0,Ae=["2","6","8","0","a","b","c","d","e","f"].includes(be)?a:void 0,Ze=["4","5","6","8","9","0","a","b","c","e","f"].includes(be)?a:void 0,bn=["2","3","4","5","6","8","9","a","b","d","e","f"].includes(be)?a:void 0,ft=[],Rt=(Te,nt,ch)=>ft.push(new U(Te.map((uh,Da)=>[uh,nt[Da]]),{closed:!0,fill:ch??!1,color:"gray",lw:.5}));return Rt(S,M,Be),Rt(L,I,De),Rt(X,j,ye),Rt(v,x,_e),Rt(B,$,Ae),Rt(Y,Z,Ze),Rt(k,_,bn),h&&(ft.push(new W(re,"a",{align:["center","bottom"],fontsize:10})),ft.push(new W(te,"g",{align:["center","bottom"],fontsize:10})),ft.push(new W(ke,"d",{align:["center","bottom"],fontsize:10})),ft.push(new W(he,"b",{align:["left","center"],fontsize:10})),ft.push(new W(ve,"c",{align:["left","center"],fontsize:10})),ft.push(new W(de,"e",{align:["right","center"],fontsize:10})),ft.push(new W(Fe,"f",{align:["right","center"],fontsize:10}))),r.decimal&&ft.push(new D([Ie+n+s+.15/2,e],.15,{color:"gray",fill:a,lw:.5})),ft}var oi=class extends nr{constructor(e={}){let t=T(e,"decimal",!1),n=t?"8":"7",s=t?5.9:5.3,o=e.size??[3,s],a=[{pin:"a",side:"L",slot:`${7+(t?1:0)}/${n}`,anchorname:"a"},{pin:"b",side:"L",slot:`${6+(t?1:0)}/${n}`,anchorname:"b"},{pin:"c",side:"L",slot:`${5+(t?1:0)}/${n}`,anchorname:"c"},{pin:"d",side:"L",slot:`${4+(t?1:0)}/${n}`,anchorname:"d"},{pin:"e",side:"L",slot:`${3+(t?1:0)}/${n}`,anchorname:"e"},{pin:"f",side:"L",slot:`${2+(t?1:0)}/${n}`,anchorname:"f"},{pin:"g",side:"L",slot:`${1+(t?1:0)}/${n}`,anchorname:"g"}];t&&a.push({pin:"dp",side:"L",slot:`1/${n}`,anchorname:"dp"}),T(e,"anode",!1)&&a.push({pin:"ca",side:"T",anchorname:"anode"}),T(e,"cathode",!1)&&a.push({pin:"cc",side:"B",anchorname:"cathode"}),super({...e,pins:a,size:o,pinspacing:.6});let l=.8,c=(s-1.5*2)/2;this.segments.push(...Cc({left:l,bottom:c,decimal:t,digit:T(e,"digit",8),segcolor:T(e,"segcolor","red"),tilt:T(e,"tilt",10),labelsegments:T(e,"labelsegments",!0)}))}},ai=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{pins:8,notch:!0,width:3,pinw:.6,spacing:.5,number:!0,fontsize:12,pfontsize:10});let t=T(this.params,"width",3),n=T(this.params,"pinw",.6),s=T(this.params,"spacing",.5),i=T(this.params,"pins",8),o=T(this.params,"names",void 0);if(i%2===1)throw new Error("pins must be even");let a=i/2*n+s*(i/2+1);if(this.segments.push(new U([[0,0],[t,0],[t,a],[0,a]],{closed:!0})),T(this.params,"notch",!0)){let h=t/2,c=ze(-Math.PI,0,50),m=n/2,f=c.map(b=>h+m*Math.cos(b)),g=c.map(b=>a+m*Math.sin(b));this.segments.push(new p(f.map((b,v)=>[b,g[v]])))}let l=i/2;for(let h=0;h<l;h++){let c=s+s*h+h*n,m=s+s*h+(h+1)*n,f=(c+m)/2;this.segments.push(new U([[0,c],[0,m],[-n,m],[-n,c]],{closed:!0}));let g=l-h;this.anchors[`p${g}`]=[-n,f],this.anchors[`p${g}_in`]=[0,f],T(this.params,"number",!0)&&this.segments.push(new W([-n/2,f],String(g),{fontsize:T(this.params,"pfontsize",10)})),o&&o[g-1]&&(this.segments.push(new W([.1,f],o[g-1],{align:["left","center"],fontsize:T(this.params,"fontsize",12)})),this.anchors[o[g-1]]=[-n,f],this.anchors[`${o[g-1]}_in`]=[0,f]),this.segments.push(new U([[t,c],[t,m],[t+n,m],[t+n,c]],{closed:!0})),g=l+h+1,this.anchors[`p${g}`]=[t+n,f],this.anchors[`p${g}_in`]=[t,f],T(this.params,"number",!0)&&this.segments.push(new W([t+n/2,f],String(g),{fontsize:T(this.params,"pfontsize",10)})),o&&o[g-1]&&(this.segments.push(new W([t-.1,f],o[g-1],{align:["right","center"],fontsize:T(this.params,"fontsize",12)})),this.anchors[o[g-1]]=[t+n,f],this.anchors[`${o[g-1]}_in`]=[t,f])}}};var Zc={};$a(Zc,{Adc:()=>Ls,Amp:()=>un,And:()=>Bt,Bjt:()=>qr,Bjt2:()=>Hr,BjtNpn:()=>Ht,BjtNpn2:()=>Ss,BjtPnp:()=>rr,BjtPnp2:()=>ln,Breaker:()=>as,Buf:()=>Jt,CPE:()=>ls,Capacitor:()=>Cr,Capacitor2:()=>Cn,CapacitorTrim:()=>Ln,CapacitorVar:()=>In,Circle:()=>ui,Circulator:()=>Os,Connect:()=>pr,Crystal:()=>Un,CurrentMirror:()=>Fr,Dac:()=>Ds,Data:()=>Ms,Decision:()=>Es,Demod:()=>Ns,Diac:()=>on,Diode:()=>et,DiodeShockley:()=>$n,DiodeTVS:()=>Fn,DiodeTunnel:()=>On,DrawTree:()=>l0,DspBox:()=>sr,DspCircle:()=>Yt,DspSpeaker:()=>_s,Ellipse:()=>zs,Filter:()=>Is,FlowBox:()=>cn,Fuse:()=>rs,FuseIEC:()=>Dr,FuseIEEE:()=>dr,FuseUS:()=>os,Inductor:()=>Ir,Inductor2:()=>Lr,Isolator:()=>Fs,Josephson:()=>is,LED:()=>qn,LED2:()=>Hn,LogicTree:()=>gr,Memristor:()=>ns,Memristor2:()=>ss,Mixer:()=>As,NFet:()=>gs,NFet2:()=>ws,NMos:()=>ms,NMos2:()=>ps,Norator:()=>Or,Not:()=>Kt,Nullator:()=>Nr,Opamp:()=>cs,Or:()=>$t,Oscillator:()=>Cs,OscillatorBox:()=>Bs,PFet:()=>bs,PFet2:()=>xs,PMos:()=>ds,PMos2:()=>fs,Photodiode:()=>Yn,Photoresistor:()=>ts,PhotoresistorIEC:()=>Qt,PhotoresistorIEEE:()=>ur,Potentiometer:()=>es,PotentiometerIEC:()=>er,PotentiometerIEEE:()=>mr,Process:()=>hi,Resistor:()=>Zn,ResistorIEC:()=>mt,ResistorVar:()=>Qn,ResistorVarIEC:()=>Zt,ResistorVarIEEE:()=>cr,RoundBox:()=>Yr,RoundProcess:()=>li,Rshunt:()=>Kn,SCR:()=>Xn,STYLE_IEC:()=>Xl,STYLE_IEEE:()=>an,Schottky:()=>Dn,SparkGap:()=>hs,Start:()=>ci,State:()=>mi,StateEnd:()=>Ps,Subroutine:()=>ks,Sum:()=>Ts,SumSigma:()=>Rs,Terminal:()=>hn,Thermistor:()=>Jn,Triac:()=>Gn,Tristate:()=>Bn,VGA:()=>$s,Varactor:()=>jn,VoltageMirror:()=>$r,Zener:()=>Nn,buchheim:()=>Ra,cycloid:()=>Vn,logicparse:()=>Ql,nand:()=>Tn,nor:()=>Rn,pictorial:()=>Jc,resetElementStyleForTests:()=>Wl,setBoxAnchors16:()=>fr,setElementStyle:()=>Gl,xnor:()=>_n,xor:()=>An});function fr(r,e,t){r.center=[e/2,0],r.N=[e/2,t/2],r.E=[e,0],r.S=[e/2,-t/2],r.W=[0,0],r.NW=[0,t/2],r.NE=[e,t/2],r.SW=[0,-t/2],r.SE=[e,-t/2],r.NNE=[3*e/4,t/2],r.NNW=[e/4,t/2],r.SSE=[3*e/4,-t/2],r.SSW=[e/4,-t/2],r.ENE=[e,t/3],r.ESE=[e,-t/3],r.WNW=[0,t/3],r.WSW=[0,-t/3]}function p2(r,e,t,n){let s=n-n*Math.sqrt(2)/2;fr(r,e,t),r.NW=[s,t/2-s],r.NE=[e-s,t/2-s],r.SW=[s,-t/2+s],r.SE=[e-s,-t/2+s],r.NNE=[n<e/4?3*e/4:e-n,t/2],r.NNW=[n<e/4?e/4:n,t/2],r.SSE=[n<e/4?3*e/4:e-n,-t/2],r.SSW=[n<e/4?e/4:n,-t/2],r.ENE=[e,n<t/4?t/4:t/2-n],r.ESE=[e,n<t/4?-t/4:-t/2+n],r.WNW=[0,n<t/4?t/4:t/2-n],r.WSW=[0,n<t/4?-t/4:-t/2+n]}function f2(r,e,t,n){fr(r,e,t);let s=n*Math.sqrt(2)/2;r.SE=[n+s,-s],r.SW=[n-s,-s],r.NE=[n+s,s],r.NW=[n-s,s];let i=n*Math.cos(22.5*Math.PI/180),o=n*Math.cos(67.5*Math.PI/180);r.NNE=[n+o,i],r.ENE=[n+i,o],r.ESE=[n+i,-o],r.SSE=[n+o,-i],r.NNW=[n-o,i],r.WNW=[n-i,o],r.WSW=[n-i,-o],r.SSW=[n-o,-i]}var Yr=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{w:3,h:2,theta:0,cornerradius:.3});let t=T(this.params,"w",3),n=T(this.params,"h",2),s=T(this.params,"cornerradius",.3);this.segments.push(new U([[0,n/2],[t,n/2],[t,-n/2],[0,-n/2]],{closed:!0,cornerradius:s,fill:"none"})),p2(this.anchors,t,n,s),this.elmParams.drop=[t,0]}},hn=class extends Yr{constructor(e={}){let t=e.h??1.25,n=e.w??3,s=e.anchor??"N";super({...e,w:n,h:t,cornerradius:t/2,anchor:s}),this.elmParams.drop=[n/2,-t/2],this.elmParams.droptheta=-90}},li=Yr,cn=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{w:3,h:2,theta:0});let t=T(this.params,"w",3),n=T(this.params,"h",2);this.segments.push(new p([[0,0],[0,n/2],[t,n/2],[t,-n/2],[0,-n/2],[0,0]])),fr(this.anchors,t,n),this.elmParams.drop=[t,0]}},hi=cn,ci=hn,ks=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{w:3,h:2,theta:0,s:.3});let t=T(this.params,"s",.3),n=T(this.params,"w",3)+t*2,s=T(this.params,"h",2);this.segments.push(new p([[0,0],[0,s/2],[n,s/2],[n,-s/2],[0,-s/2],[0,0]])),this.segments.push(new p([[n-t,s/2],[n-t,-s/2]])),this.segments.push(new p([[t,s/2],[t,-s/2]])),fr(this.anchors,n,s),this.elmParams.drop=[n,0]}},Ms=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{w:3,h:2,theta:0,slant:.5});let t=T(this.params,"w",3),n=T(this.params,"h",2),s=T(this.params,"slant",.5);this.segments.push(new U([[0,0],[s/2,n/2],[t+s/2,n/2],[t-s/2,-n/2],[-s/2,-n/2]],{closed:!0,fill:"none"})),fr(this.anchors,t,n),this.anchors.N=[t/2+s/2,n/2],this.anchors.S=[t/2-s/2,-n/2],this.anchors.NE=[t+s/2,n/2],this.anchors.SE=[t-s/2,-n/2],this.anchors.NW=[s/2,n/2],this.anchors.SW=[-s/2,-n/2],this.anchors.ENE=[t+s/4,n/4],this.anchors.WNW=[s/4,n/4],this.anchors.ESE=[t-s/4,-n/4],this.anchors.WSW=[-s/4,-n/4],this.anchors.NNE=[3*t/4+s/2,n/2],this.anchors.SSE=[3*t/4-s/2,-n/2],this.anchors.NNW=[t/4+s/2,n/2],this.anchors.SSW=[t/4-s/2,-n/2],this.elmParams.drop=[t,0]}},zs=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{w:3,h:2,theta:0});let t=T(this.params,"w",3),n=T(this.params,"h",2),i=ze(0,Math.PI*2,50).map(c=>{let m=n/2*Math.sin(c);return[t/2*Math.cos(c)+t/2,m]});i[i.length-1]=[i[0][0],i[0][1]],this.segments.push(new p(i)),fr(this.anchors,t,n);let o=Math.sin(Math.PI/4),a=Math.cos(Math.PI/4),l=Math.sin(Math.PI/8),h=Math.cos(Math.PI/8);this.anchors.SE=[t/2+t/2*a,-n/2*o],this.anchors.SW=[t/2-t/2*a,-n/2*o],this.anchors.NW=[t/2-t/2*a,n/2*o],this.anchors.NE=[t/2+t/2*a,n/2*o],this.anchors.ENE=[t/2+t/2*h,n/2*l],this.anchors.WNW=[t/2-t/2*h,n/2*l],this.anchors.ESE=[t/2+t/2*h,-n/2*l],this.anchors.WSW=[t/2-t/2*h,-n/2*l],this.anchors.NNE=[t/2+t/2*l,n/2*h],this.anchors.NNW=[t/2-t/2*l,n/2*h],this.anchors.SSE=[t/2+t/2*l,-n/2*h],this.anchors.SSW=[t/2-t/2*l,-n/2*h],this.elmParams.drop=[t,0]}},Es=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{w:4,h:2.25,theta:0,fontsize:14});let t=T(this.params,"w",4),n=T(this.params,"h",2.25),s=T(this.params,"fontsize",14),i=T(this.params,"font",void 0),o=.13,a=e.N,l=e.E,h=e.S,c=e.W;this.segments.push(new U([[0,0],[t/2,n/2],[t,0],[t/2,-n/2]],{closed:!0,fill:"none"})),a&&this.segments.push(new W([t/2+o,n/2+o],a,{align:["left","bottom"],fontsize:s,fontfamily:i})),h&&this.segments.push(new W([t/2+o,-n/2-o],h,{align:["left","top"],fontsize:s,fontfamily:i})),l&&this.segments.push(new W([t+o,o],l,{align:["left","bottom"],fontsize:s,fontfamily:i})),c&&this.segments.push(new W([-o,o],c,{align:["right","bottom"],fontsize:s,fontfamily:i})),fr(this.anchors,t,n),this.anchors.NE=[3*t/4,n/4],this.anchors.NW=[t/4,n/4],this.anchors.SE=[3*t/4,-n/4],this.anchors.SW=[t/4,-n/4],this.anchors.NNE=[5*t/8,3*n/8],this.anchors.NNW=[3*t/8,3*n/8],this.anchors.SSE=[5*t/8,-3*n/8],this.anchors.SSW=[3*t/8,-3*n/8],this.anchors.ENE=[7*t/8,n/8],this.anchors.ESE=[7*t/8,-n/8],this.anchors.WNW=[t/8,n/8],this.anchors.WSW=[t/8,-n/8],this.elmParams.drop=[t,0]}},pr=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{w:1.5,h:1.5,r:.75});let t=T(this.params,"w",1.5),n=T(this.params,"h",1.5);if(e.r!==void 0){let i=e.r;t=i*2,n=i*2}let s=t/2;this.segments.push(new D([s,0],s)),f2(this.anchors,t,n,s),this.elmParams.drop=[t,0]}},ui=pr,mi=pr,Ps=class extends pr{constructor(e={}){let t=e.dr??.15,n=e.w??1.5,s=e.h??1.5;if(e.r!==void 0){let h=e.r;n=h*2,s=h*2}let{r:i,...o}=e;super({...o,w:n,h:s});let l=T(this.params,"w",n)/2;this.segments.push(new D([l,0],l-t))}};var sr=class extends N{constructor(e={}){super(e),this.segments.push(new p([[0,0],[0,.5],[1,.5],[1,-.5],[0,-.5],[0,0]])),this.elmParams.lblloc="center",this.elmParams.lblofst=0,this.anchors.N=[.5,.5],this.anchors.S=[.5,-.5],this.anchors.E=[1,0],this.anchors.W=[0,0],this.elmParams.drop=[1,0]}},Yt=class extends N{constructor(e={}){super(e);let t=e.radius??.5,n=t*Math.SQRT2/2;this.segments.push(new D([t,0],t)),this.elmParams.lblloc="center",this.elmParams.lblofst=0,this.elmParams.drop=[2*t,0],this.anchors.N=[t,t],this.anchors.S=[t,-t],this.anchors.E=[2*t,0],this.anchors.W=[0,0],this.anchors.NW=[t-n,n],this.anchors.NE=[t+n,n],this.anchors.SW=[t-n,-n],this.anchors.SE=[t+n,-n],this.anchors.center=[t,0]}},Ts=class extends Yt{constructor(e={}){super(e),this.segments.push(new p([[.5,.2],[.5,-.2]])),this.segments.push(new p([[.3,0],[.7,0]]))}},Rs=class extends Yt{constructor(e={}){super(e),this.segments.push(new W([.45,0],"\u03A3",{align:["center","center"]}))}},As=class extends Yt{constructor(e={}){super(e);let t=.5,n=t*Math.SQRT2/2;this.segments.push(new p([[t+n,n],[t-n,-n]],{lw:1})),this.segments.push(new p([[t+n,-n],[t-n,n]],{lw:1})),this.elmParams.lblloc="top",this.elmParams.lblofst=.2;let s=e.font,i=e.fontsize??10;e.N&&this.segments.push(new W([t,t/2+.01],e.N,{fontfamily:s,fontsize:i})),e.S&&this.segments.push(new W([t,-t/2-.065],e.S,{fontfamily:s,fontsize:i})),e.E&&this.segments.push(new W([t*1.5+.05,0],e.E,{fontfamily:s,fontsize:i})),e.W&&this.segments.push(new W([t/2-.05,0],e.W,{fontfamily:s,fontsize:i}))}},_s=class extends N{constructor(e={}){super(e),this.segments.push(new p([[0,0],[0,.25],[.25,.25],[.25,-.25],[0,-.25],[0,0]])),this.segments.push(new p([[.25,.25],[.5,.5],[.5,-.5],[.25,-.25],[.25,.25]]))}},un=class extends N{constructor(e={}){super(e);let t=1,n=.75;this.segments.push(new p([[0,0],[0,-t/2],[n,0],[0,t/2],[0,0]])),this.elmParams.drop=[n,0],this.anchors.input=[0,0],this.anchors.out=[n,0]}};function Ic(){return ze(-Math.PI,Math.PI,20).map(e=>[e/Math.PI*.3+.5,-Math.sin(e)/10])}var Bs=class extends sr{constructor(e={}){super(e),this.segments.push(new p(Ic()))}},Cs=class extends Yt{constructor(e={}){super(e),this.segments.push(new p(Ic()))}},Is=class extends sr{constructor(e={}){super(e);let t=Ic(),n=t.map(([o,a])=>[o,a+.25]),s=t.map(([o,a])=>[o,a-.25]);this.segments.push(new p(t)),this.segments.push(new p(n)),this.segments.push(new p(s));let i=e.response;if(i){let o=i.toLowerCase();(o==="bp"||o==="lp")&&this.segments.push(new p([[.45,.17],[.55,.33]])),(o==="bp"||o==="hp")&&this.segments.push(new p([[.45,-.33],[.55,-.17]])),(o==="lp"||o==="hp"||o==="notch")&&this.segments.push(new p([[.45,-.08],[.55,.08]]))}}},Ls=class extends N{constructor(e={}){super(e),this.segments.push(new p([[0,0],[.22,.5],[1.4,.5],[1.4,-.5],[.22,-.5],[0,0]])),this.elmParams.lblloc="center",this.elmParams.lblofst=0,this.elmParams.drop=[1.4,0],this.anchors.input=[0,0],this.anchors.out=[1.4,0],this.anchors.E=[1.4,0],this.anchors.W=[0,0]}},Ds=class extends N{constructor(e={}){super(e),this.segments.push(new p([[0,0],[0,.5],[1.18,.5],[1.4,0],[1.18,-.5],[0,-.5],[0,0]])),this.elmParams.lblloc="center",this.elmParams.lblofst=0,this.elmParams.drop=[1.4,0],this.anchors.input=[0,0],this.anchors.out=[1.4,0],this.anchors.E=[1.4,0],this.anchors.W=[0,0]}},Ns=class extends sr{constructor(e={}){super(e),this.segments.push(new p([[.15,0],[.3,0]])),this.segments.push(new p([[.3,.25],[.7,0],[.3,-.25],[.3,.25]])),this.segments.push(new p([[.7,.25],[.7,-.25]])),this.segments.push(new p([[.7,0],[.85,0]]))}},Os=class extends Yt{constructor(e={}){super(e);let t=.5;this.segments.push(new xe([.5,0],.9*t,.9*t,{theta1:20,theta2:200,arrow:"cw"}))}},Fs=class extends sr{constructor(e={}){super(e);let t=.25;this.segments.push(new p([[t,0],[1-t,0]],{arrow:"->"}))}},$s=class extends un{constructor(e={}){super(e);let t=e.tuneup??!0;this.segments.push(new p([[-.1,-.5],[.75,.5]],{arrow:"->"})),this.anchors.tune=[.325,t?.5:-.5]}};var Jc={};$a(Jc,{Breadboard:()=>Vc,CapacitorCeramic:()=>Xc,CapacitorElectrolytic:()=>Hc,CapacitorMylar:()=>Yc,DIP:()=>Wc,Diode:()=>Nc,ElementPictorial:()=>Ta,FritzingPart:()=>Uc,INCH:()=>Ce,LED:()=>qs,LEDBlue:()=>jc,LEDGreen:()=>$c,LEDOrange:()=>Oc,LEDWhite:()=>qc,LEDYellow:()=>Fc,MILLIMETER:()=>g2,PINSPACING:()=>ee,Resistor:()=>Dc,TO92:()=>Gc,fritzParts:()=>y2,parseSizeToUnits:()=>w2,resistorColors:()=>v1});var js=class extends N{constructor(e,t,n,s={}){super(s);let{xy:i,imgfmt:o,zorder:a,...l}=s;this.segments.push(new Br(e,{xy:i??[0,0],width:t,height:n,zorder:a??1,imgfmt:o})),this.elmParams.theta=0;let h=t/2,c=n/2,m=(i?.[0]??0)+h,f=(i?.[1]??0)+c;this.anchors.center=[m,f],this.anchors.N=[m,f+c],this.anchors.S=[m,f-c],this.anchors.E=[m+h,f],this.anchors.W=[m-h,f]}};var Ce=3.5,g2=Ce/25.4,ee=.1*Ce,Pa="#333",x1="#777",Lt="#A0A0A0",b2=96;function w2(r){return x2(r)/b2*Ce}function x2(r){let e=r.match(/^([0-9.]+)\s*(px|pt|in|mm|cm|pc|em|ex|%)?$/i);if(!e)return 0;let t=parseFloat(e[1]);switch((e[2]??"px").toLowerCase()){case"px":return t;case"pt":return t*(96/72);case"in":return t*96;case"mm":return t*(96/25.4);case"cm":return t*(96/2.54);case"pc":return t*16;default:return t}}var Lc={0:"black",1:"brown",2:"red",3:"orange",4:"yellow",5:"green",6:"blue",7:"violet",8:"gray",9:"white",[-1]:"gold",[-2]:"silver",[-3]:"pink"},v2={1:"brown",2:"red","0.05":"orange","0.02":"yellow","0.5":"green","0.25":"blue","0.1":"violet","0.01":"gray",5:"gold",10:"silver"};function v1(r,e){let t=Math.floor(Math.log10(r))-1,n=r/10**t;n<10&&(t-=1,n=r/10**t);let s=Math.floor(n/10),i=Math.floor(n%10),o=e!==void 0?v2[String(e)]:void 0;return[Lc[s],Lc[i],Lc[t],o]}var Ta=class extends se{constructor(e={}){super(e),Object.assign(this.defaults,{leadcolor:Lt,lw:3})}},Dc=class extends Ta{constructor(e=1e3,t,n={}){super(n),Object.assign(this.defaults,{fill:"blanchedalmond"});let s=ee,i=ee/2,o=i*.9;this.segments.push(new p([[0,0],[NaN,NaN],[i*3+s,0]])),this.segments.push(new ut(["M",[0,0],"Q",[0,i],[i,i],"Q",[i*1.25,i],[i*1.5,o],"L",[i*1.5+s,o],"Q",[i*1.75+s,i],[i*2+s,i],"Q",[i*3+s,i],[i*3+s,0],"Q",[i*3+s,-i],[i*2+s,-i],"Q",[i*1.75+s,-i],[i*1.5+s,-o],"L",[i*1.5,-o],"Q",[i*1.25,-i],[i,-i],"Q",[0,-i],[0,0],"Z"],{color:"black",lw:1}));let a=.16,l=.32,h=.48,c=.68,m=.08,[f,g,b,v]=v1(e,t);this.segments.push(new U([[a,o],[a,-o],[a+m,-o],[a+m,o]],{fill:f,lw:.1,zorder:2})),this.segments.push(new U([[l,o],[l,-o],[l+m,-o],[l+m,o]],{fill:g,lw:.1,zorder:2})),this.segments.push(new U([[h,o],[h,-o],[h+m,-o],[h+m,o]],{fill:b,lw:.1,zorder:2})),v&&this.segments.push(new U([[c,o],[c,-o],[c+m,-o],[c+m,o]],{fill:v,lw:.1,zorder:2}))}},Nc=class extends Ta{constructor(e={}){super(e),Object.assign(this.defaults,{fill:Pa,stripe_color:"silver"});let t=ee/2,n=ee*2.5,s=n*.78,i=.08,o=this.params.stripe_color??"silver";Vr(o),this.segments.push(new p([[0,0],[NaN,NaN],[n,0]])),this.segments.push(new U([[0,t],[n,t],[n,-t],[0,-t]],{closed:!0,lw:1,color:"black",zorder:2})),this.segments.push(new U([[s,t],[s+i,t],[s+i,-t],[s,-t]],{closed:!0,lw:1,color:"none",fill:o,zorder:2}))}},qs=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{lead_length:ee*5,fill:"#dd4433",theta:0});let t=.197*Ce,n=.338*Ce,s=this.params.lead_length??ee*5,i=ee*5;this.segments.push(new p([[0,0],[0,s]],{color:Lt,lw:4})),this.segments.push(new p([[ee,0],[ee,s-i*.3],[ee*.6,s-i*.2],[ee*.6,s]],{color:Lt,lw:4}));let o=t*.8,a=ee/2-t/2,l=ee/2,h=s+n;this.segments.push(new ut(["M",[a,s],"Q",[l,s-i*.2],[a+t,s],"L",[a+t,h-o],"C",[a+t,h],[a,h],[a,h-o],"Z"],{color:"none"}));let c=.039*Ce;this.segments.push(new ut(["M",[a,s+c/2],"Q",[l*.5,s-i*.16+c],[a+t*.7,s-i*.03],"L",[a+t,s+c/2]],{color:"#FFFFFF55",lw:2}));let m=a+.03*Ce;this.segments.push(new ut(["M",[m,s+c*2],"L",[m,h-o],"Q",[m,h-o+.04*Ce],[m+.04*Ce,h-o+.07*Ce]],{color:"#FFFFFF55",lw:3}))}},Oc=class extends qs{constructor(e={}){super(e),Object.assign(this.defaults,{fill:"#efa207"})}},Fc=class extends qs{constructor(e={}){super(e),Object.assign(this.defaults,{fill:"#f1de0f"})}},$c=class extends qs{constructor(e={}){super(e),Object.assign(this.defaults,{fill:"#4be317"})}},jc=class extends qs{constructor(e={}){super(e),Object.assign(this.defaults,{fill:"#3892bc"})}},qc=class extends qs{constructor(e={}){super(e),Object.assign(this.defaults,{fill:"#e5e5e5"})}},Hc=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{fill:"#303b91",lead_length:.2*Ce,cap_color:"#CCC",stripe_color:"#dff1f6",theta:0});let t=ee*1.7,n=.3*Ce,s=this.params.lead_length??.2*Ce;this.segments.push(new p([[0,0],[0,s]],{color:Lt,lw:4})),this.segments.push(new p([[ee,0],[ee,s]],{color:Lt,lw:4}));let i=ee*2,o=i*.3,a=ee/2-t/2,l=ee/2,h=s+n;this.segments.push(new ut(["M",[a,s],"Q",[l,s-i*.3],[a+t,s],"L",[a+t,h-o],"Q",[l,h],[a,h-o],"Z"],{color:"none"}));let c=this.params.cap_color??"#CCC";this.segments.push(new xe([l,h-o-.01*Ce],t-.03*Ce,o*.9,{theta1:0,theta2:360,fill:c,color:"none",lw:.5,zorder:2}));let m=.039*Ce/2;this.segments.push(new ut(["M",[a,s+m],"Q",[l,s-i*.1],[a+t,s+m]],{color:"#FFFFFF99",fill:"none",lw:1.5}));let f=this.params.stripe_color??"#dff1f6",g=a+.03*Ce;this.segments.push(new ut(["M",[g,s+m],"L",[g,h-o*2]],{color:f,fill:"none",lw:3}))}},Yc=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{fill:"#8c2510",lead_length:.4*Ce,theta:0});let t=ee*1.75,n=t*.75,s=ee/2,i=s-t/2,o=this.params.lead_length??.4*Ce;this.segments.push(new p([[0,0],[0,o]],{color:Lt,lw:4})),this.segments.push(new p([[ee,0],[ee,o]],{color:Lt,lw:4}));let a=.02*Ce;this.segments.push(new ut(["M",[i,o],"Q",[i-a,o+n/2],[i,o+n],"Q",[s,o+n+a],[i+t,o+n],"Q",[i+t+a,o+n/2],[i+t,o],"Q",[s,o+a/2],[i,o],"Z"],{color:"none"}));let l=o+n-.025*Ce;this.segments.push(new p([[-.01*Ce,l],[ee*.8,l]],{color:"#FFFFFF44",lw:3}))}},Xc=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{fill:"#e2800b",radius:.1*Ce,lead_length:.4*Ce,theta:0});let t=this.params.radius??.1*Ce,n=this.params.lead_length??.4*Ce,s=[ee/2,n+t-.05*Ce];this.segments.push(new p([[0,0],[0,n]],{color:Lt,lw:4})),this.segments.push(new p([[ee,0],[ee,n]],{color:Lt,lw:4})),this.segments.push(new D(s,t,{color:"none",zorder:2})),this.segments.push(new xe(s,t*2*.7,t*2*.7,{theta1:100,theta2:200,color:"#FFFFFF44",zorder:2}))}},Gc=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{theta:0});let t=.175*Ce,n=.17*Ce*.9,s=ee*1.2,i=ee*1.3,o=ee-t/2,a=ee;this.segments.push(new p([[0,0],[0,ee*.8],[ee/2,i]],{color:Lt,lw:4})),this.segments.push(new p([[a,0],[a,i]],{color:Lt,lw:4})),this.segments.push(new p([[ee*2,0],[ee*2,ee*.8],[3*ee/2,i]],{color:Lt,lw:4})),this.segments.push(new U([[o,i],[o+t,i],[o+t,i+n],[o,i+n]],{fill:Pa,lw:1,color:x1,zorder:2})),this.segments.push(new xe([a,i+n],t,s,{theta1:0,theta2:180,fill:Pa,lw:1,color:x1,zorder:2})),this.anchors.pin1=[0,0],this.anchors.pin2=[ee,0],this.anchors.pin3=[ee*2,0],this.anchors.case_center=[a,i+n/2],this.elmParams.lblloc="case_center",this.elmParams.lblalign=["center","center"]}},Wc=class extends N{constructor(e=8,t=!1,n={}){super(n),Object.assign(this.defaults,{theta:0});let s=e;s%2!==0&&(s+=1);let i=t?6*ee:3*ee,o=ee*.25,a=ee*.25,l=(s/2-1)*ee,h=i/2,c=ee*.75,m=a,f=i-a,g=5;for(let b=0;b<s/2;b++)this.segments.push(new p([[0,-b*ee],[m,-b*ee]],{color:Lt,lw:g,zorder:1})),this.segments.push(new p([[f,-b*ee],[f+a,-b*ee]],{color:Lt,lw:g,zorder:1})),this.anchors[`pin${b+1}`]=[0,-b*ee],this.anchors[`pin${s-b}`]=[f+a,-b*ee];this.segments.push(new U([[a,o],[f,o],[f,-o-l],[a,-o-l]],{fill:Pa,lw:1,color:"#444"})),this.segments.push(new xe([h,o],c,c,{theta1:180,theta2:0,lw:1,color:"#777",fill:"#555"})),this.elmParams.lblloc="center",this.elmParams.lblrotate=!0,this.elmParams.lblofst=0}},Vc=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{color:"#DDD",fill:"#F8F8F5",shadow_color:"#E5E5E5",text_color:"#666"});let t=.02,n=.1,s=this.params.shadow_color??"#E5E5E5",i=this.params.text_color??"#666";Vr(s),Vr(i);let o=(k,M)=>{this.segments.push(new U([[k-n,M+n],[k+n,M+n],[k+n,M-n]],{fill:!0,color:s,lw:2})),this.segments.push(new U([[k-t,M-t],[k-t,M+t],[k+t,M+t],[k+t,M-t]],{fill:!0,color:Pa,lw:2}))},a=30,l=5,h=.37*Ce,c=(h-ee)/2,m=2.1*Ce,f=3.3*Ce,g=1.5*c,b=-c,v=b+m;this.segments.push(new U([[b,g],[v,g],[v,g-f],[b,g-f]],{lw:2}));let x=0,S=0;for(let k=0;k<2;k++)for(let M=0;M<a;M++){if(M%6===0)continue;let _=[x,S-M*ee],B=[x+ee,S-M*ee];o(..._),o(...B),this.anchors[`L1_${M}`]=_,this.anchors[`L2_${M}`]=B}x=v-c;for(let k=0;k<2;k++)for(let M=0;M<a;M++){if(M%6===0)continue;let _=[x,S-M*ee],B=[x-ee,S-M*ee];o(..._),o(...B),this.anchors[`R1_${M}`]=B,this.anchors[`R2_${M}`]=_}x=h;for(let k=0;k<l;k++){let M=String.fromCharCode(65+k);this.segments.push(new W([x+k*ee,S+ee],M,{fontsize:8,rotation:0,align:["center","center"],color:i,zorder:1}));for(let _=0;_<a;_++){let B=[x+k*ee,S-_*ee];o(...B),this.anchors[`${M}${_+1}`]=B}}for(let k=0;k<l;k++){let M=String.fromCharCode(70+k);this.segments.push(new W([x+ee*7+k*ee,S+ee],M,{fontsize:8,rotation:0,align:["center","center"],color:i,zorder:1}));for(let _=0;_<a;_++){let B=[x+ee*7+k*ee,S-_*ee];o(...B),this.anchors[`${M}${_+1}`]=B}}for(let k=0;k<a;k++)this.segments.push(new W([x-ee,S-k*ee-.04],String(k+1),{fontsize:8,rotation:0,align:["center","bottom"],color:i,zorder:1})),this.segments.push(new W([x+ee*12,S-k*ee-.04],String(k+1),{fontsize:8,rotation:0,align:["center","bottom"],color:i,zorder:1}));this.segments.push(new p([[b+c*.4,g-ee*2],[b+c*.4,g-f+ee]],{color:"red",lw:.5})),this.segments.push(new p([[b+h-c*.4,g-ee*2],[b+h-c*.4,g-f+ee]],{color:"blue",lw:.5})),this.segments.push(new p([[v-c*.4,g-ee*2],[v-c*.4,g-f+ee]],{color:"blue",lw:.5})),this.segments.push(new p([[v-h+c*.4,g-ee*2],[v-h+c*.4,g-f+ee]],{color:"red",lw:.5}))}},Uc=class extends js{constructor(t,n,s,i,o,a={}){super(t,n,s,{imgfmt:"svg",...a});z(this,"info");if(this.info=o,i)for(let[l,h]of Object.entries(i))this.anchors[l]=h}};function y2(r){throw new Error("fritzParts requires a .fzpz zip parser. Use a library like 'jszip' and pass the extracted SVG/anchors to FritzingPart directly.")}var Pe=class extends se{constructor(e={}){let{arrow:t,...n}=e;super(n),Object.assign(this.defaults,{arrowwidth:.15,arrowlength:.25});let s=this.params.arrowwidth,i=this.params.arrowlength;this.segments.push(new p([[0,0]],{arrow:t,arrowwidth:s,arrowlength:i}))}};var y1=H,di=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{dy:.6,to:[1,1]})}toXY(e){return this.userParams.to=e,this}delta(e=0,t=0){return this.userParams.delta=[e,t],this}_place(e,t,n){this.dwgParams={...n},this._positioned||this._position(),this.elmParams.theta=0;let s=this.params.at!==void 0?A.fromXY(this.params.at):A.fromXY(e),i=this.params.to!==void 0?A.fromXY(this.params.to):A.fromXY(e),o=this.params.delta,a=this.params.n??1,l=this.params.dy??.6,h=this.params.xstart,c=this.params.arrow,m,f;if(o!==void 0?[m,f]=o:(m=i.x!==void 0?i.x-s.x:this.params.to[0]-(this.params.at!==void 0?this.params.at[0]:e[0]),f=i.x!==void 0?i.y-s.y:this.params.to[1]-(this.params.at!==void 0?this.params.at[1]:e[1])),Math.abs(f)<.05)for(let g=0;g<a;g++){let b=-g*l;this.segments.push(new p([[0,b],[m,b]],{arrow:c}))}else{let g;h!==void 0?f>0?g=m*h:g=m*h-l-l*(a-1)*h:m>0?g=m/2-l*(a-1)/2:g=m/2+l*(a-1)/2;for(let b=0;b<a;b++){let v=-b*l,x;f>0?x=m>0?g+l*b:g-l*b:x=m>0?g+(a-b)*l:g-(a-b)*l,this.segments.push(new p([[0,v],[x,v],[x,v+f],[m,v+f]],{arrow:c}))}}return super._place(e,t,n)}},Hs=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{dy:.6,to:[3,-2],theta:0,n:1})}toXY(e){return this.userParams.to=e,this}delta(e=0,t=0){return this.userParams.delta=[e,t],this}_place(e,t,n){this.dwgParams={...n},this._positioned||this._position();let s=this.params.at!==void 0?A.fromXY(this.params.at):A.fromXY(e),i=this.params.delta,o=this.params.to,a=this.params.n??1,l=this.params.dy??.6,h=this.params.arrow,c,m;i!==void 0?[c,m]=i:(c=o[0]-s.x,m=o[1]-s.y);let f=0;for(let g=0;g<a;g++){let b=-g*l;m>0?f=c<0?c-g*l:c+g*l:f=c>0?c+(a-g-1)*l:c-(a-g-1)*l,this.segments.push(new p([[0,b],[f,b],[f,m]],{arrow:h}))}return this.anchors.mid=[c/2,0],this.elmParams.lblloc="mid",this.elmParams.drop=[f,m],this.elmParams.droptheta=m>0?90:-90,super._place(e,t,n)}},pi=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{pinspacing:.6,style:"round",numbering:"lr",pinfontsizeleft:9,pinfontsizeright:9,edge:.3,pinfill:"bg",shownumber:!1,pinalignleft:"bottom",pinalignright:"bottom",pinrad:.1});let t=e.rows??4,n=e.cols??1,s=e.pinsleft??[],i=e.pinsright??[];this.elmParams.d="right";let o=this.params.pinspacing??.6,a=this.params.edge??.3,l=this.params.pinrad??.1,h=this.params.style??"round",c=this.params.numbering??"lr",m=this.params.shownumber??!1,f=this.params.pinfill??"bg",g=this.params.pinfontsizeleft??9,b=this.params.pinfontsizeright??9,v=this.params.pinalignleft??"bottom",x=(n-1)*o+a*2,S=(t-1)*o+a*2;this.segments.push(new U([[0,0],[0,S],[x,S],[x,0]]));for(let k=0;k<t;k++)for(let M=0;M<n;M++){let _=M*o+a,B=S-k*o-a,$=[_,B];h==="square"?this.segments.push(new U([[_-l,B-l],[_+l,B-l],[_+l,B+l],[_-l,B+l]],{fill:"bg",zorder:4})):h==="screw"?(this.segments.push(new D($,l*1.75,{fill:f,zorder:4})),this.segments.push(new p([[_+l,B+l],[_-l,B-l]],{zorder:5}))):this.segments.push(new D($,l,{fill:f,zorder:4}));let Y;if(c==="lr"||c===!0?Y=String(k*n+M+1):c==="ud"?Y=String(k+M*t+1):Y=M%2?String(t*M+(t-k)):String(k+1),this.anchors[`pin${Y}`]=$,m){let Z=[M%2?x+.05:-.05,B],L=M%2?"left":"right";this.segments.push(new W(Z,Y,{fontsize:g,align:[L,"bottom"]}))}if(s.length>0&&(n===1||!(M%2))){let Z=[-.05,B];this.segments.push(new W(Z,s[k]??"",{fontsize:g,align:["right",v]}))}if(i.length>0&&(n===1||M%2)){let Z=[x+.05,B];this.segments.push(new W(Z,i[k]??"",{fontsize:b,align:["left",v]}))}}}},fi=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{pinspacing:.6,pinrad:.1,theta:0});let t=this.params.pinrad??.1,n=this.params.pinspacing??.6,s=t*2.5;this.segments.push(new U([[-s,-s],[n+s,-s],[n+s,s],[-s,s]]))}},gi=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{dy:.6,lwbus:4,l:3,slantx:.5}),this.elmParams.theta=0;let t=e.n??1,n=e.up??!0,s=this.params.l??3,i=this.params.dy??.6,o=this.params.lwbus??4,a=this.params.slantx??.5,l=n?a:-a;for(let h=0;h<t;h++){let c=-h*i;this.segments.push(new p([[0,c],[s-a,c],[s,c+l]])),this.anchors[`pin${h+1}`]=[0,c]}this.segments.push(new p([[s,a],[s,l-t*i]],{lw:o})),this.elmParams.drop=[s,a],this.anchors.start=[s,a],this.anchors.end=[s,l-t*i]}},bi=class extends Pe{constructor(e={}){super(e),Object.assign(this.defaults,{lw:4})}},a0=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{pinspacing:.6,edge:.3,pinfill:"bg",pinrad:.1,number:!1,theta:0});let t=this.params.pinspacing??.6,n=this.params.edge??.3,s=this.params.pinfill??"bg",i=this.params.pinrad??.1,o=this.params.number??!1,a=t+n*2,l=4*t+n*2,h=l+.5;this.segments.push(new U([[0,0],[0,l],[a,h],[a,-.5]],{cornerradius:.25}));for(let c=0;c<4;c++){let m=[n,l-(c+.5)*t-n];this.segments.push(new D(m,i,{fill:s,zorder:4})),this.anchors[`pin${9-c}`]=m,o&&this.segments.push(new W([m[0],m[1]+i],String(9-c),{fontsize:9,align:["center","bottom"]}))}for(let c=0;c<5;c++){let m=[n+t,h-(c+.75)*t-n];this.segments.push(new D(m,i,{fill:s,zorder:4})),this.anchors[`pin${5-c}`]=m,o&&this.segments.push(new W([m[0],m[1]+i],String(5-c),{fontsize:9,align:["center","bottom"]}))}}},wi=class extends a0{},xi=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{pinspacing:.6,edge:.3,pinfill:"bg",number:!1,pinrad:.1,theta:0});let t=this.params.pinspacing??.6,n=this.params.edge??.3,s=this.params.pinfill??"bg",i=this.params.pinrad??.1,o=this.params.number??!1,a=t+n*2,l=12*t+n*2,h=l+.5;this.segments.push(new U([[0,0],[0,l],[a,h],[a,-.5]],{cornerradius:.25}));for(let c=0;c<12;c++){let m=[n,l-(c+.5)*t-n];this.segments.push(new D(m,i,{fill:s,zorder:4})),this.anchors[`pin${25-c}`]=m,o&&this.segments.push(new W([m[0],m[1]+i],String(25-c),{fontsize:9,align:["center","bottom"]}))}for(let c=0;c<13;c++){let m=[n+t,h-(c+.75)*t-n];this.segments.push(new D(m,i,{fill:s,zorder:4})),this.anchors[`pin${13-c}`]=m,o&&this.segments.push(new W([m[0],m[1]+i],String(13-c),{fontsize:9,align:["center","bottom"]}))}}},vi=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{pinspacing:.6,edge:.3,pinfill:"bg",pinrad:.1,number:!1,theta:0});let t=this.params.pinspacing??.6,n=this.params.edge??.3,s=this.params.pinfill??"bg",i=this.params.pinrad??.1,o=this.params.number??!1,a=t+n*2,l=7*t+n*2,h=l+.5;this.segments.push(new U([[0,0],[0,l],[a,h],[a,-.5]],{cornerradius:.25}));for(let c=0;c<7;c++){let m=[n,l-(c+.5)*t-n];this.segments.push(new D(m,i,{fill:s,zorder:4})),this.anchors[`pin${15-c}`]=m,o&&this.segments.push(new W([m[0],m[1]+i],String(15-c),{fontsize:9,align:["center","bottom"]}))}for(let c=0;c<8;c++){let m=[n+t,h-(c+.75)*t-n];this.segments.push(new D(m,i,{fill:s,zorder:4})),this.anchors[`pin${8-c}`]=m,o&&this.segments.push(new W([m[0],m[1]+i],String(8-c),{fontsize:9,align:["center","bottom"]}))}}},yi=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{pinspacing:.6,edge:.3,pinfill:"bg",pinrad:.1,number:!1,theta:0});let t=this.params.pinspacing??.6,n=this.params.edge??.3,s=this.params.pinfill??"bg",i=this.params.pinrad??.1,o=this.params.number??!1,a=t+n*2,l=18*t+n*2,h=l+.5;this.segments.push(new U([[0,0],[0,l],[a,h],[a,-.5]],{cornerradius:.25}));for(let c=0;c<18;c++){let m=[n,l-(c+.5)*t-n];this.segments.push(new D(m,i,{fill:s,zorder:4})),this.anchors[`pin${37-c}`]=m,o&&this.segments.push(new W([m[0],m[1]+i],String(37-c),{fontsize:9,align:["center","bottom"]}))}for(let c=0;c<19;c++){let m=[n+t,h-(c+.75)*t-n];this.segments.push(new D(m,i,{fill:s,zorder:4})),this.anchors[`pin${19-c}`]=m,o&&this.segments.push(new W([m[0],m[1]+i],String(19-c),{fontsize:9,align:["center","bottom"]}))}}},Si=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{pinspacing:.6,edge:.3,pinfill:"bg",pinrad:.1,number:!1,theta:0});let t=this.params.pinspacing??.6,n=this.params.edge??.3,s=this.params.pinfill??"bg",i=this.params.pinrad??.1,o=this.params.number??!1,a=t*2+n*2,l=16*t+n*2,h=l+.5;this.segments.push(new U([[0,0],[0,l],[a,h],[a,-.5]],{cornerradius:.25}));for(let c=0;c<17;c++){let m=[n,h-(c+.75)*t-n];this.segments.push(new D(m,i,{fill:s,zorder:4})),this.anchors[`pin${50-c}`]=m,o&&this.segments.push(new W([m[0],m[1]+i],String(50-c),{fontsize:9,align:["center","bottom"]}))}for(let c=0;c<16;c++){let m=[n+t,l-(c+.5)*t-n];this.segments.push(new D(m,i,{fill:s,zorder:4})),this.anchors[`pin${33-c}`]=m,o&&this.segments.push(new W([m[0],m[1]+i],String(33-c),{fontsize:9,align:["center","bottom"]}))}for(let c=0;c<17;c++){let m=[n+t*2,h-(c+.75)*t-n];this.segments.push(new D(m,i,{fill:s,zorder:4})),this.anchors[`pin${17-c}`]=m,o&&this.segments.push(new W([m[0],m[1]+i],String(17-c),{fontsize:9,align:["center","bottom"]}))}}},ki=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{radius:.4,radiusinner:.12,fillinner:"bg"});let t=this.params.radius??.4,n=this.params.radiusinner??.12,s=this.params.fillinner??"bg";this.segments.push(new D([0,0],t)),this.segments.push(new D([0,0],n,{fill:s,zorder:4})),this.anchors.center=[0,0],this.anchors.N=[0,t],this.anchors.S=[0,-t],this.anchors.E=[t,0],this.anchors.W=[-t,0]}},Mi=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{pluggap:.18});let t=this.params.pluggap??.18;this.segments.push(new p([[0,0],[1,0],y1,[1-.25,.25],[1,0],[1-.25,-.25]])),this.elmParams.drop=[1+t,0]}},zi=class extends N{constructor(e={}){super(e),this.segments.push(new p([[0,0],[-.25,.25],y1,[-.25,-.25],[0,0],[1,0]])),this.elmParams.drop=[1,0]}},Ei=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{r:.18,open:!0,fill:"bg",drop:[0,0],theta:0,zorder:4});let t=this.params.r??.18;this.anchors.start=[0,0],this.anchors.center=[0,0],this.anchors.end=[0,0];let n=this.params.open??!0;this.elmParams.fill=n?"bg":!0,this.segments.push(new D([0,0],t));let s=1,i=2;this.segments.push(new p([[-s*t,-i*t],[s*t,i*t]]))}};var gr=class{constructor(e,...t){z(this,"node");z(this,"children");this.node=e,this.children=t}[Symbol.iterator](){return this.children[Symbol.iterator]()}},l0=class r{constructor(e,t=null,n=0,s=1){z(this,"x",-1);z(this,"y");z(this,"node");z(this,"children");z(this,"parent");z(this,"thread",null);z(this,"mod",0);z(this,"ancestor",this);z(this,"change",0);z(this,"shift",0);z(this,"number");z(this,"_lmostSibling",null);this.y=n,this.node=e.node,this.parent=t,this.number=s,this.children=e.children.map((i,o)=>new r(i,this,n+1,o+1)),this.ancestor=this}left(){return this.thread??(this.children.length>0?this.children[0]:null)}right(){return this.thread??(this.children.length>0?this.children[this.children.length-1]:null)}lbrother(){let e=null;if(this.parent)for(let t of this.parent.children){if(t===this)return e;e=t}return e}get lmostSibling(){return!this._lmostSibling&&this.parent&&this!==this.parent.children[0]&&(this._lmostSibling=this.parent.children[0]),this._lmostSibling}};function M1(r,e){r.x+=e;for(let t of r.children)M1(t,e)}function S2(r){let e=0,t=0;for(let n=r.children.length-1;n>=0;n--){let s=r.children[n];s.x+=e,s.mod+=e,t+=s.change,e+=s.shift+t}}function k2(r,e,t){return e.parent&&e.parent.children.includes(r.ancestor)?r.ancestor:t}function M2(r,e,t){let n=e.number-r.number;e.change-=t/n,e.shift+=t,r.change+=t/n,e.x+=t,e.mod+=t}function z2(r,e,t){let n=r.lbrother();if(n!==null){let s=r,i=r,o=n,a=r.lmostSibling,l=r.mod,h=r.mod,c=o.mod,m=a.mod;for(;o.right()&&s.left();){o=o.right(),s=s.left(),a=a.left(),i=i.right(),i.ancestor=r;let f=o.x+c-(s.x+l)+t;f>0&&(M2(k2(o,r,e),r,f),l+=f,h+=f),c+=o.mod,l+=s.mod,m+=a.mod,h+=i.mod}o.right()&&!i.right()?(i.thread=o.right(),i.mod+=c-h):(s.left()&&!a.left()&&(a.thread=s.left(),a.mod+=l-m),e=r)}return e}function z1(r,e=1){if(r.children.length===0)r.lmostSibling?r.x=r.lbrother().x+e:r.x=0;else{let t=r.children[0];for(let i of r.children)z1(i),t=z2(i,t,e);S2(r);let n=(r.children[0].x+r.children[r.children.length-1].x)/2,s=r.lbrother();s?(r.x=s.x+e,r.mod=r.x-n):r.x=n}return r}function E1(r,e=0,t=0,n=null){r.x+=e,r.y=t,(n===null||r.x<n)&&(n=r.x);for(let s of r.children)n=E1(s,e+r.mod,t+1,n);return n}function Ra(r){let e=z1(new l0(r)),t=E1(e);return t<0&&M1(e,-t),e}var E2=new Set(["and","or","not","nand","nor","xor","xnor","true","false"]),P1=(o=>(o[o.IDENT=0]="IDENT",o[o.KEYWORD=1]="KEYWORD",o[o.LPAREN=2]="LPAREN",o[o.RPAREN=3]="RPAREN",o[o.SYMBOL=4]="SYMBOL",o[o.EOF=5]="EOF",o))(P1||{});function P2(r){let e=[],t=0;for(;t<r.length;){let n=r[t];if(/\s/.test(n)){t++;continue}if(n==="("){e.push({tt:2,val:"("}),t++;continue}if(n===")"){e.push({tt:3,val:")"}),t++;continue}if("&|+~\xAC\u2227\u2228\u2295\u22BB".includes(n)){e.push({tt:4,val:n}),t++;continue}if(/[$_a-zA-Z]/.test(n)){let s="";for(;t<r.length&&/[$_a-zA-Z0-9]/.test(r[t]);)s+=r[t],t++;E2.has(s)?e.push({tt:1,val:s}):e.push({tt:0,val:s});continue}throw new Error(`logicparse: unexpected character '${n}'`)}return e.push({tt:5,val:""}),e}var Kc=class{constructor(e){z(this,"tokens");z(this,"pos",0);this.tokens=e}peek(){return this.tokens[this.pos]}advance(){return this.tokens[this.pos++]}expect(e,t){let n=this.advance();if(n.tt!==e||t!==void 0&&n.val!==t)throw new Error(`logicparse: expected ${t??P1[e]}, got '${n.val}'`);return n}parse(){let e=this.xorExpr();if(this.peek().tt!==5)throw new Error(`logicparse: unexpected token '${this.peek().val}'`);return e}isNotOp(e){return e.tt===1&&e.val==="not"||e.tt===4&&(e.val==="~"||e.val==="\xAC")}isAndOp(e){return e.tt===1&&(e.val==="and"||e.val==="nand")||e.tt===4&&(e.val==="&"||e.val==="\u2227")}isOrOp(e){return e.tt===1&&(e.val==="or"||e.val==="nor")||e.tt===4&&(e.val==="|"||e.val==="\u2228"||e.val==="+")}isXorOp(e){return e.tt===1&&(e.val==="xor"||e.val==="xnor")||e.tt===4&&(e.val==="\u2295"||e.val==="\u22BB")}xorExpr(){let e=this.orExpr();for(;this.isXorOp(this.peek());){let t=this.advance(),n=this.orExpr();e={kind:"binary",op:t.val,left:e,right:n}}return e}orExpr(){let e=this.andExpr();for(;this.isOrOp(this.peek());){let t=this.advance(),n=this.andExpr();e={kind:"binary",op:t.val,left:e,right:n}}return e}andExpr(){let e=this.unary();for(;this.isAndOp(this.peek());){let t=this.advance(),n=this.unary();e={kind:"binary",op:t.val,left:e,right:n}}return e}unary(){return this.isNotOp(this.peek())?(this.advance(),{kind:"unary",operand:this.unary()}):this.atom()}atom(){let e=this.peek();if(e.tt===2){this.advance();let t=this.xorExpr();return this.expect(3,")"),t}if(e.tt===0||e.tt===1&&(e.val==="true"||e.val==="false"))return this.advance(),{kind:"ident",name:e.val};throw new Error(`logicparse: unexpected token '${e.val}'`)}};function Zl(r,e){return r.kind==="binary"&&r.op===e?[...Zl(r.left,e),...Zl(r.right,e)]:[r]}function S1(r){return{"&":"and","\u2227":"and","|":"or","\u2228":"or","+":"or","\u2295":"xor","\u22BB":"xor"}[r]??r}var T2={and:"nand",or:"nor",not:"buf",nand:"and",nor:"or",buf:"not",xor:"xnor",xnor:"xor"};function Pi(r){if(r.kind==="ident")return new gr(r.name);if(r.kind==="unary"){if(r.operand.kind==="ident")return new gr("not",Pi(r.operand));let n=r.operand;if(n.kind==="binary"){let s=S1(n.op),i=T2[s];if(i){let o=Zl(n,n.op);return new gr(i,...o.map(Pi))}}return n.kind==="unary"?Pi(n.operand):new gr("not",Pi(n))}let e=S1(r.op),t=Zl(r,r.op);return new gr(e,...t.map(Pi))}var T1={and:Bt,or:$t,not:Kt,buf:Jt};function R2(r,e){let t=T1[r];if(t)return new t(e);switch(r){case"nand":return Tn(e);case"nor":return Rn(e);case"xor":return An(e);case"xnor":return _n(e);default:return new Bt(e)}}function k1(r){return r in T1||["nand","nor","xor","xnor"].includes(r)}function A2(r,e=.7,t=2,n){let s=new lr;s.unit=t;let i=Ra(r);function o(a,l=0,h){let c=a.node==="not"||a.node==="buf",m={d:"r",at:[a.y*-t,-a.x*e],anchor:"end",l:t,...c?{}:{inputs:a.children.length}},f=R2(a.node,m);h&&f.label(h,{loc:"end"});for(let g=0;g<a.children.length;g++){let b=a.children[g],v=c?"start":`in${g+1}`;k1(b.node)||f.label(b.node,{loc:v})}s.add(f);for(let g=0;g<a.children.length;g++){let b=a.children[g],v=c?"start":`in${g+1}`;if(k1(b.node)){let x=o(b,l+1);s.add(new Hs({at:[f,v],to:x.anchors.end}))}}return f}return o(i,0,n),s}function Ql(r,e={}){let{gateW:t=2,gateH:n=.75,outlabel:s}=e,i=P2(r),o=new Kc(i).parse(),a=Pi(o);return A2(a,n,t,s)}var eh=.12,_2=.4,Ti=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{lead:!0,theta:0,drop:[0,0]});let n=this.params.lead!==!1?_2:0;this.segments.push(new p([[0,0],[0,-n],[-.25,-n],[.25,-n],H,[-.25*.7,-eh-n],[.25*.7,-eh-n],H,[-.25*.2,-eh*2-n],[.25*.2,-eh*2-n]])),this.anchors.start=[0,0],this.anchors.center=[0,0],this.anchors.end=[0,0]}};function R1(r="svg"){if(r==="matplotlib")throw new Error("@skillpet/circuit: use('matplotlib') is not supported; only 'svg' is available.")}function A1(r=!0,e=!0){kt({dwgbbox:r,elmbbox:e})}function _1(r="default"){switch(r){case"default":kt({bgcolor:"white",color:"black"});break;case"dark":kt({color:"white",bgcolor:"black"});break;case"solarizedd":kt({bgcolor:"#002b36",color:"#657b83"});break;case"solarizedl":kt({bgcolor:"#eee8d5",color:"#073642"});break;case"onedork":kt({bgcolor:"#373e4b",color:"#899ab8"});break;case"oceans16":kt({bgcolor:"#384151",color:"#CDD2E9"});break;case"monokai":kt({bgcolor:"#232323",color:"#BBBBBB"});break;case"gruvboxl":kt({bgcolor:"#ebdbb2",color:"#3c3836"});break;case"gruvboxd":kt({bgcolor:"#1d2021",color:"#d5c4a1"});break;case"grade3":kt({bgcolor:"#ffffff",color:"#3f3d46"});break;case"chesterish":kt({bgcolor:"#323A48",color:"#92A2BD"});break;default:throw new Error(`Unknown theme ${r}`)}}var Aa=class{constructor(){z(this,"_text","text");z(this,"_svg2",!0);z(this,"precision",3);z(this,"useBatik",!1)}get text(){return this._text}set text(e){this._text=e}get svg2(){return this._svg2}set svg2(e){this._svg2=e}},B1=new Aa;var $e=.25*.75,pt=.25*1.5,St=.25*.75,rt=class extends se{constructor(e={}){super(e),this.elmParams.theta=90,this.segments.push(new p([[0,0],[0,0],H,[1,0],[1,0]])),this.segments.push(new D([.5,0],.5))}},Ri=class extends rt{constructor(e={}){super(e);let t=.2;this.segments.push(new p([[.25,-t/2],[.25,t/2]])),this.segments.push(new p([[.75-t/2,0],[.75+t/2,0]])),this.segments.push(new p([[.75,-t/2],[.75,t/2]]))}},Ai=class extends rt{constructor(e={}){super(e),Object.assign(this.defaults,{arrowwidth:.15,arrowlength:.25,arrow_lw:void 0,arrow_color:void 0});let t=this.params;this.segments.push(new p([[.25,0],[.75,0]],{arrow:"->",arrowwidth:t.arrowwidth,arrowlength:t.arrowlength,lw:t.arrow_lw,color:t.arrow_color}))}},_i=class extends rt{constructor(e={}){super(e),Object.assign(this.defaults,{sin_lw:void 0,sin_color:void 0});let t=ze(-.25,.25,25),s=t.map(i=>.2*Math.sin((i-.25)*Math.PI*2/.5)+.5).map((i,o)=>[i,t[o]]);this.segments.push(new p(s,{lw:this.params.sin_lw,color:this.params.sin_color}))}},Bi=class extends rt{constructor(e={}){super(e),Object.assign(this.defaults,{pulse_lw:void 0,pulse_color:void 0});let t=.15,n=.4;this.segments.push(new p([[n,t*2],[n,t],[n+t,t],[n+t,-t],[n,-t],[n,-t*2]],{lw:this.params.pulse_lw,color:this.params.pulse_color}))}},Ci=class extends rt{constructor(e={}){super(e),Object.assign(this.defaults,{tri_lw:void 0,tri_color:void 0}),this.segments.push(new p([[.4,.25],[.7,0],[.4,-.25]],{lw:this.params.tri_lw,color:this.params.tri_color}))}},Ii=class extends rt{constructor(e={}){super(e),Object.assign(this.defaults,{ramp_lw:void 0,ramp_color:void 0}),this.segments.push(new p([[.4,.25],[.8,-.2],[.4,-.2]],{lw:this.params.ramp_lw,color:this.params.ramp_color}))}},Li=class extends rt{constructor(e={}){super(e),Object.assign(this.defaults,{square_lw:void 0,square_color:void 0}),this.segments.push(new p([[.5,.25],[.7,.25],[.7,0],[.3,0],[.3,-.25],[.5,-.25]],{lw:this.params.square_lw,color:this.params.square_color}))}},Ys=class extends se{constructor(e={}){super(e),this.elmParams.theta=90,this.segments.push(new p([[0,0],[.5,.5],[1,0],[.5,-.5],[0,0],H,[1,0]]))}},br=class extends Ys{constructor(e={}){super(e);let t=.2;this.segments.push(new p([[.25,-t/2],[.25,t/2]])),this.segments.push(new p([[.75-t/2,0],[.75+t/2,0]])),this.segments.push(new p([[.75,-t/2],[.75,t/2]]))}},wr=class extends Ys{constructor(e={}){super(e),Object.assign(this.defaults,{arrowwidth:.15,arrowlength:.25,arrow_lw:void 0,arrow_color:void 0});let t=this.params;this.segments.push(new p([[.25,0],[.75,0]],{arrow:"->",arrowwidth:t.arrowwidth,arrowlength:t.arrowlength,lw:t.arrow_lw,color:t.arrow_color}))}},Di=class extends se{constructor(e={}){super(e),this.segments.push(new p([[0,0],H,[$e,0]])),this.segments.push(new p([[0,pt],[0,-pt]])),this.segments.push(new p([[$e,St],[$e,-St]]))}},Ni=class extends se{constructor(e={}){super(e),this.segments.push(new p([[0,0],H,[$e*3,0]])),this.segments.push(new p([[0,pt],[0,-pt]])),this.segments.push(new p([[$e,St],[$e,-St]])),this.segments.push(new p([[$e*2,pt],[$e*2,-pt]])),this.segments.push(new p([[$e*3,St],[$e*3,-St]]))}},Oi=class extends se{constructor(e={}){super(e),this.segments.push(new p([[0,0],H,[$e*9,0]])),this.segments.push(new p([[0,pt],[0,-pt]])),this.segments.push(new p([[$e,St],[$e,-St]])),this.segments.push(new p([[$e*2,pt],[$e*2,-pt]])),this.segments.push(new p([[$e*3,St],[$e*3,-St]])),this.segments.push(new p([[$e*4,pt],[$e*4,-pt]])),this.segments.push(new p([[$e*5,St],[$e*5,-St]])),this.segments.push(new p([[$e*6,pt],[$e*6,-pt]])),this.segments.push(new p([[$e*7,St],[$e*7,-St]])),this.segments.push(new p([[$e*8,pt],[$e*8,-pt]])),this.segments.push(new p([[$e*9,St],[$e*9,-St]])),this.anchors.tap=[$e*4,pt]}},Fi=class extends rt{constructor(e={}){super(e),Object.assign(this.defaults,{arrowwidth:.15,arrowlength:.25,arrow_lw:void 0,arrow_color:void 0});let t=.25*.5,n=t+.15,s=.4,i=this.params;this.segments.push(new p([[s,t],[s,-t]])),this.segments.push(new p([[s+.2,n],[s+.2,-n]])),this.segments.push(new p([[0,0],[s,0],H,[s+.2,0],[1,0]]));let o=i.arrowwidth,a=i.arrowlength;this.segments.push(new p([[1.1,.9],[.8,.6]],{arrow:"->",arrowwidth:o,arrowlength:a,lw:i.arrow_lw,color:i.arrow_color})),this.segments.push(new p([[1.3,.7],[1,.4]],{arrow:"->",arrowwidth:o,arrowlength:a,lw:i.arrow_lw,color:i.arrow_color}))}},$i=class extends rt{constructor(e={}){super(e),this.segments.push(new W([.5,0],"V",{halign:"center",valign:"center"}))}},ji=class extends rt{constructor(e={}){super(e),this.segments.push(new W([.5,0],"I",{halign:"center",valign:"center"}))}},qi=class extends rt{constructor(e={}){super(e),this.segments.push(new W([.5,0],"A",{halign:"center",valign:"center"}))}},Hi=class extends rt{constructor(e={}){super(e),this.segments.push(new W([.5,0],"\u03A9",{halign:"center",valign:"center"}))}},Yi=class extends rt{constructor(e={}){super(e),Object.assign(this.defaults,{arrowwidth:.15,arrowlength:.25,arrow_lw:void 0,arrow_color:void 0});let t=this.params;this.segments.push(new p([[.25,.16],[.75,-.16]],{arrow:"->",arrowwidth:t.arrowwidth,arrowlength:t.arrowlength,lw:t.arrow_lw,color:t.arrow_color}))}},Xi=class extends rt{constructor(e={}){super(e),Object.assign(this.defaults,{filament_lw:void 0,filament_color:void 0});let t=.25,n=.7,s=ze(1.4,3.6*Math.PI,80),i=s.map(c=>t*c-n*Math.sin(c)),o=s.map(c=>t-n*Math.cos(c));i=i.map(c=>c-i[0]);let a=i[i.length-1];i=i.map(c=>c/a);let l=o.map(c=>(c-o[0])*.25),h=i.map((c,m)=>[c,l[m]]);this.segments.push(new p(h,{lw:this.params.filament_lw,color:this.params.filament_color}))}},Gi=class extends rt{constructor(e={}){super(e),Object.assign(this.defaults,{filament_lw:void 0,filament_color:void 0});let t=.5,n=this.params;this.segments.push(new p([[t-t/2**.5,-t/2**.5],[t+t/2**.5,t/2**.5]],{lw:n.filament_lw,color:n.filament_color})),this.segments.push(new p([[t-t/2**.5,t/2**.5],[t+t/2**.5,-t/2**.5]],{lw:n.filament_lw,color:n.filament_color}))}},Wi=class extends rt{constructor(e={}){super(e);let t=.25,n=.4;this.segments.push(new p([[n,t],[n,-t]])),this.segments.push(new p([[n+.2,t],[n+.2,-t]])),this.segments.push(new p([[0,0],[n,0],H,[n+.2,0],[1,0]])),this.segments.push(new D([n-.15,.2],.05,{fill:!0}))}},mn=class extends N{constructor(e={}){let{inputs:t,...n}=e,s=t!==!1;super(n),Object.assign(this.defaults,{width:1.5,corner:.2,input_ofst:[.4,.3],input_lw:1,input_rad:.1,input_fill:"none"});let i=this.params.width,o=this.params.corner,a=this.params.input_ofst,l=this.params.input_lw,h=this.params.input_rad;this.segments.push(new U([[0,0],[0,i],[i,i],[i,0]],{closed:!0,cornerradius:o})),s&&(this.segments.push(new D([a[0],a[1]],h,{lw:l,fill:this.params.input_fill,zorder:4})),this.segments.push(new D([i-a[0],a[1]],h,{lw:l,fill:this.params.input_fill,zorder:4}))),this.anchors.N=[i/2,i],this.anchors.S=[i/2,0],this.anchors.E=[i,i/2],this.anchors.W=[0,i/2],this.anchors.NE=[i,i],this.anchors.SE=[i,0],this.anchors.NW=[0,i],this.anchors.SW=[0,0],this.anchors.in1=[a[0],a[1]],this.anchors.in2=[i-a[0],a[1]],this.anchors.name=[i/2,0],this.elmParams.drop=this.anchors.in2}},Vi=class extends mn{constructor(e={}){super(e);let t=e.needle_percent??70;Object.assign(this.defaults,{needle_color:"black",needle_width:1.5,window_fill:"none"});let n=this.params.width,s=n/2,i=1.2,o=.86,a=.2;this.segments.push(new ut(["M",[s-n/3,i],"Q",[s,i+a],[s+n/3,i],"L",[s+n/4,o],"Q",[s,o+a*.7],[s-n/4,o],"Z"],{color:"black",fill:this.params.window_fill,lw:1}));let l=.94,h=1.2,c=(112-45*t/100)*Math.PI/180,m=[s+l*Math.cos(c),l*Math.sin(c)],f=[s+h*Math.cos(c),h*Math.sin(c)];this.segments.push(new p([m,f],{lw:this.params.needle_width,color:this.params.needle_color}))}},Ui=class extends mn{constructor(e={}){super(e);let t=e.signal??"none";Object.assign(this.defaults,{screen_fill:"none",screen_lw:1,grid:!0,grid_color:"#666666",grid_lw:.3,signal_lw:2,signal_color:"#e0213b"});let n=this.params.width,s=4,i=n*.15,o=n*.85,a=o-i,l=a/(s+1),h=l*3,c=n*.9,m=c-h;if(this.segments.push(new U([[i,m],[i,c],[o,c],[o,m]],{closed:!0,lw:this.params.screen_lw,fill:this.params.screen_fill})),this.params.grid){for(let f=0;f<s;f++){let g=i+(f+1)*l;this.segments.push(new p([[g,m],[g,c]],{lw:this.params.grid_lw,color:this.params.grid_color}))}for(let f=0;f<2;f++){let g=m+(f+1)*l;this.segments.push(new p([[i,g],[o,g]],{lw:this.params.grid_lw,color:this.params.grid_color}))}}if(t==="sine"){let f=ze(i,o,20),g=f.map(v=>m+h/2+Math.sin((v-i)/a*Math.PI*2)*(h/2)*.75),b=f.map((v,x)=>[v,g[x]]);this.segments.push(new p(b,{lw:this.params.signal_lw,color:this.params.signal_color}))}else if(t==="square"){let f=m+h/4,g=c-h/4,b=i+a/3-.1,v=i+a*2/3-.1,x=i+a-.1;this.segments.push(new p([[i,f],[b,f],[b,g],[v,g],[v,f],[x,f],[x,g],[o,g]],{lw:this.params.signal_lw,color:this.params.signal_color}))}else if(t==="triangle"){let f=m+h/4,g=c-h/4,b=i+a/3-.1,v=i+a*2/3-.1,x=i+a-.1;this.segments.push(new p([[i,f],[b,g],[v,f],[x,g],[o,g-.1]],{lw:this.params.signal_lw,color:this.params.signal_color}))}}},Ji=class extends mn{constructor(e={}){super(e),Object.assign(this.defaults,{screen_fill:"none",screen_lw:1});let t=this.params.width,n=t*.1,s=t*.9,i=t/3,o=t*.85,a=o-i;this.segments.push(new U([[n,a],[n,o],[s,o],[s,a]],{closed:!0,lw:this.params.screen_lw,fill:this.params.screen_fill})),this.anchors.display=[(n+s)/2,a]}};var th=.4,Ki=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{lead:!0,theta:0,drop:[0,0]});let n=this.params.lead!==!1?th:0;this.segments.push(new p([[0,0],[0,-n],[-.25,-n],[0,-n-.25],[.25,-n],[0,-n]])),this.anchors.start=[0,0],this.anchors.center=[0,0],this.anchors.end=[0,0]}},Zi=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{lead:!0,drop:[0,0],theta:0});let n=this.params.lead!==!1?th:0,s=.25*.75,i=.25;this.segments.push(new p([[0,0],[0,-n],[-s,-n-i]])),this.segments.push(new p([[0,-n],[-s,-n],[-s*2,-n-i]])),this.segments.push(new p([[0,-n],[s,-n],[0,-n-i]])),this.elmParams.drop=[0,0],this.elmParams.theta=0,this.anchors.start=[0,0],this.anchors.center=[0,0],this.anchors.end=[0,0]}},Qi=class extends N{constructor(e={}){super(e);let t=.6,n=.6,s=.38;this.segments.push(new p([[0,0],[0,t],[-s,t+n],[s,t+n],[0,t]])),this.elmParams.drop=[0,0],this.elmParams.theta=0,this.anchors.start=[0,0],this.anchors.center=[0,0],this.anchors.end=[0,0]}},eo=class extends N{constructor(e={}){super(e);let t=.2,n=.5;this.segments.push(new p([[0,0],[0,t],[-n,n+t],[t/2,n*2+1.5*t],[n+t,n+t],[t,t],[t,0]])),this.elmParams.drop=[0,0],this.elmParams.theta=0,this.anchors.start=[0,0],this.anchors.end=[t,0]}},to=class extends N{constructor(e={}){super(e);let t=.25,n=1,s=-n/2-t/2,i=s+t,o=n/2+t/2,a=o+t,l=t,h=t*2,c=n+h,m=c+t;this.segments.push(new p([[0,0],[0,l],[s,l],[s,c],[o,c],[o,h],[i,h],[i,m],[a,m],[a,l],[t,l],[t,0]])),this.elmParams.drop=[t,0],this.elmParams.theta=0,this.anchors.start=[0,0],this.anchors.end=[t,0]}},ro=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{lead:!0,drop:[0,0],theta:0,lblloc:"bottom"});let t=.25*.75,s=this.params.lead!==!1?th:0;this.segments.push(new p([[0,0],[0,-s]])),this.segments.push(new p([[0,-s],[-t,-s]])),this.segments.push(new p([[0,-s],[t,-s]])),this.anchors.start=[0,0],this.anchors.center=[0,0],this.anchors.end=[0,0]}},no=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{lead:!0,drop:[0,0],theta:0});let t=.25*.75,s=this.params.lead!==!1?th:0;this.segments.push(new p([[0,0],[0,s]])),this.segments.push(new p([[0,s],[-t,s]])),this.segments.push(new p([[0,s],[t,s]])),this.anchors.start=[0,0],this.anchors.center=[0,0],this.anchors.end=[0,0]}},so=class extends N{constructor(e={}){super(e);let t=.25*.75,n=.25*.75;this.segments.push(new p([[-t,-n],[t,n]])),this.segments.push(new p([[-t,n],[t,-n]])),this.elmParams.drop=[0,0],this.elmParams.theta=0,this.elmParams.lblofst="bottom",this.anchors.start=[0,0],this.anchors.center=[0,0],this.anchors.end=[0,0]}};var le=.12,Xr=class extends se{constructor(e={}){super(e),Object.assign(this.defaults,{arrowwidth:.15,arrowlength:.25,arrow_lw:void 0,arrow_color:void 0});let{action:t,contacts:n=!0,nc:s=!1}=e,i=this.params;n?(s?this.segments.push(new p([[0,0],H,[le*2,0],[.9,le+.05],H,[1,0]])):this.segments.push(new p([[0,0],H,[le*2,.1],[.8,.45],H,[1,0]])),this.segments.push(new D([le,0],le,{fill:"bg",zorder:3})),this.segments.push(new D([1-le,0],le,{fill:"bg",zorder:3}))):s?(this.segments.push(new p([[0,0],[1.15,.45],H,[1,0]])),this.segments.push(new p([[1,0],[1,.55]]))):this.segments.push(new p([[0,0],[.85,.45],H,[1,0]])),t==="open"?this.segments.push(new xe([.4,.1],.5,.75,{theta1:-10,theta2:70,arrow:"ccw",lw:i.arrow_lw,color:i.arrow_color,arrowwidth:i.arrowwidth,arrowlength:i.arrowlength})):t==="close"&&this.segments.push(new xe([.4,.25],.5,.75,{theta1:-10,theta2:70,arrow:"cw",lw:i.arrow_lw,color:i.arrow_color,arrowwidth:i.arrowwidth,arrowlength:i.arrowlength}))}},io=class extends Xr{constructor(e={}){super(e),e.contacts!==!1?(this.segments.push(new D([1-le,.7],le,{fill:"bg",zorder:3})),this.anchors.a=[le,0],this.anchors.b=[1-le,0],this.anchors.c=[1-le,.7]):(this.anchors.a=[0,0],this.anchors.b=[1,0],this.anchors.c=[1,.7])}},Xs=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{arrowwidth:.15,arrowlength:.25,arrow_lw:void 0,arrow_color:void 0});let{action:t,contacts:n=!0}=e,s=this.params;n?(this.segments.push(new p([[0,0],H,[le*2,.1],[.7,.25],H,[1,.4]])),this.segments.push(new D([le,0],le,{fill:"bg",zorder:3})),this.segments.push(new D([1-le,-.4],le,{fill:"bg",zorder:3})),this.segments.push(new D([1-le,.4],le,{fill:"bg",zorder:3})),this.anchors.a=[le,0],this.anchors.b=[1-le,.4],this.anchors.c=[1-le,-.4]):(this.segments.push(new p([[0,0],[.85,.25],H,[1,.4]])),this.anchors.a=[0,0],this.anchors.b=[1,.4],this.anchors.c=[1,-.4]),t==="open"?this.segments.push(new xe([.35,0],.5,.75,{theta1:-10,theta2:70,arrow:"ccw",lw:s.arrow_lw,color:s.arrow_color,arrowwidth:s.arrowwidth,arrowlength:s.arrowlength})):t==="close"&&this.segments.push(new xe([.3,0],.5,.75,{theta1:-10,theta2:70,arrow:"cw",lw:s.arrow_lw,color:s.arrow_color,arrowwidth:s.arrowwidth,arrowlength:s.arrowlength})),this.elmParams.drop=[1,.4]}},oo=class extends se{constructor(e={}){super(e);let{nc:t=!1,contacts:n=!0}=e,s,i;n?(s=[[0,0],H],i=[H,[1,0]]):(s=[[0,0],[le,0],H],i=[H,[1-le,0],[1,0]]);let o=t?-le-.05:.3,a=t?le+.15:.5,l=[[le,o],[1-le,o],H,[.5,o],[.5,a]],h=[...s,...l,...i];this.segments.push(new p(h)),n&&(this.segments.push(new D([le,0],le)),this.segments.push(new D([1-le,0],le)))}},Gs=class extends N{constructor(e={}){super(e);let t=-1,{link:n=!0,contacts:s=!0}=e,i,o;s?(i=[[0,0],H,[le*2,.1],[.8,.45],H,[1,0]],o=[[le*2,t+.1],[.8,t+.45]],this.anchors.p1=[le,0],this.anchors.t1=[1-le,0],this.anchors.p2=[le,t],this.anchors.t2=[1-le,t]):(i=[[0,0],[.8,.45],H,[1,0]],o=[[0,t],[.8,t+.45]],this.anchors.p1=[0,0],this.anchors.t1=[1,0],this.anchors.p2=[0,t],this.anchors.t2=[1,t]),this.segments.push(new p(i)),this.segments.push(new p(o)),s&&(this.segments.push(new D([le,0],le,{fill:"bg",zorder:3})),this.segments.push(new D([1-le,0],le,{fill:"bg",zorder:3})),this.segments.push(new D([le,t],le,{fill:"bg",zorder:3})),this.segments.push(new D([1-le,t],le,{fill:"bg",zorder:3}))),n&&this.segments.push(new p([[.5,t+.25],[.5,.2]],{ls:":"}))}},Ws=class extends N{constructor(e={}){super(e);let t=-1.4,{link:n=!0,contacts:s=!0}=e,i,o;s?(i=[[0,0],H,[le*2,.1],[.7,.25],H,[1,.4]],o=[[le*2,t+.1],[.7,t+.25]],this.anchors.p1=[le,0],this.anchors.t1=[1-le,.4],this.anchors.t2=[1-le,-.4],this.anchors.p2=[le,t],this.anchors.t3=[1-le,t+.4],this.anchors.t4=[1-le,t-.4]):(i=[[0,0],[.7,.25],H,[1,.4]],o=[[0,t],[.7,t+.25]],this.anchors.p1=[0,0],this.anchors.t1=[1,.4],this.anchors.t2=[1,-.4],this.anchors.p2=[0,t],this.anchors.t3=[1,t+.4],this.anchors.t4=[1,t-.4]),this.segments.push(new p(i)),this.segments.push(new p(o)),s&&(this.segments.push(new D([le,0],le,{fill:"bg",zorder:3})),this.segments.push(new D([1-le,-.4],le,{fill:"bg",zorder:3})),this.segments.push(new D([1-le,.4],le,{fill:"bg",zorder:3})),this.segments.push(new D([le,t],le,{fill:"bg",zorder:3})),this.segments.push(new D([1-le,t-.4],le,{fill:"bg",zorder:3})),this.segments.push(new D([1-le,t+.4],le,{fill:"bg",zorder:3}))),n&&this.segments.push(new p([[.5,t+.25],[.5,.2]],{ls:":"}))}},ao=class extends se{constructor(e={}){super(e),this.segments.push(new p([[0,0],[.85,.15],H,[.8,0]]));let t=.3,n=ze(-Math.PI/2,Math.PI/2,32),s=n.map(m=>-t*Math.cos(m)),i=n.map(m=>t*Math.sin(m)),o=s.map(m=>1-m),a=[...i].reverse(),l=[...s,...o,s[0]],h=[...i,...a,i[0]],c=l.map((m,f)=>[m,h[f]]);this.segments.push(new p(c))}},lo=class extends N{constructor(e={}){super(e);let t=e.n??4,n=e.dtheta,s=e.radius??1,i=e.arrowlen??.75,o=e.arrowcontact??0;this.elmParams.fill="bg",this.elmParams.zorder=4,this.segments.push(new D([0,0],le)),this.anchors.P=[0,0],n===void 0&&(n=Math.min(35,360/(t+1)));let a=n*Math.PI/180,l=e.theta0;l===void 0?l=-a*(t-1)/2:l=l*Math.PI/180;for(let h=0;h<t;h++){let c=l+a*h,m=s*Math.cos(c),f=s*Math.sin(c);if(this.segments.push(new D([m,f],le)),this.anchors[`T${h+1}`]=[m,f],h===o){let g=i*Math.cos(c),b=i*Math.sin(c);this.segments.push(new p([[0,0],[g,b]],{arrow:"->",zorder:2}))}}}},ho=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{switchcolor:"#333333",swidth:.4,spacing:.2});let t=e.n??3,n=e.pattern,s=this.params.swidth,i=this.params.spacing,o=s*t+i*(t+1),a=s*2+i*2;this.segments.push(new U([[0,0],[o,0],[o,a],[0,a]]));for(let l=0;l<t;l++){let h=i*(l+1)+s*l,c=n?n[l]:!1,m=n?!n[l]:!1;this.segments.push(new U([[h,i+s],[h+s,i+s],[h+s,i+s*2],[h,i+s*2]],{fill:c?this.params.switchcolor:void 0})),this.segments.push(new U([[h,i],[h+s,i],[h+s,i+s],[h,i+s]],{fill:m?this.params.switchcolor:void 0})),this.anchors[`a${l+1}`]=[h+s/2,0],this.anchors[`b${l+1}`]=[h+s/2,a]}}};var co=class extends N{constructor(e={}){super(e);let t=.5;this.segments.push(new p([[0,0],[.25,0]])),this.segments.push(new p([[0,-t],[.25,-t]])),this.segments.push(new U([[.25,t/2],[.25,-t*1.5],[.25*2,-t*1.5],[.25*2,t/2]])),this.segments.push(new U([[.25*2,t/2],[.25*3.5,t*1.25],[.25*3.5,-t*2.25],[.25*2,-t*1.5]],{closed:!1})),this.anchors.in1=[0,0],this.anchors.in2=[0,-t],this.elmParams.drop=[0,-t]}},uo=class extends N{constructor(e={}){super(e);let t=.5;this.segments.push(new p([[0,0],[.25,0]])),this.segments.push(new p([[0,-t],[.25,-t]])),this.segments.push(new p([[-.25*2,.25],[-.25*2,-.25*3]])),this.segments.push(new xe([-.25*2,-.25],.25*4,.25*4,{theta1:270,theta2:90})),this.anchors.in1=[.25,0],this.anchors.in2=[.25,-t],this.elmParams.drop=[0,-t]}},mo=class extends se{constructor(e={}){super(e);let t=.22;this.segments.push(new p([[-t,0],[-t,0],H,[1+t,0],[1+t,0]])),this.segments.push(new p([[0,-t],[-t,-t],[-t,t],[0,t]])),this.segments.push(new p([[1,-t],[1+t,-t],[1+t,t],[1,t]])),this.segments.push(new D([.5,0],.5))}},po=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{radius:.075,open:!0});let{ring:t=!1,ringswitch:n=!1,dots:s=!0,switch:i=!1}=e,o=this.params.open?"bg":void 0,a=this.params.radius,l=2,h=.75,c=.55,m=.2,f=1,g=1,b=.1,v=.35,x=.4,S=.5;i&&(g+=.2),t&&n&&(v+=.2,b-=.2),t?(s&&this.segments.push(new D([0,-v],a,{fill:o,zorder:4})),this.segments.push(new p([[-a,-v],[-l,-v],[-l,0],[-l,f],[-l-m,f],[-l-m,0],[-l,0]])),this.anchors.sleeve=[0,-v],s&&this.segments.push(new D([0,b],a,{fill:o,zorder:4})),this.segments.push(new p([[-a,b],[-l*.75,b],[-l*h-2*a,b+2*a],[-l*h-a*4,b]])),this.anchors.ring=[0,b]):(s&&this.segments.push(new D([0,0],a,{fill:o,zorder:4})),this.segments.push(new p([[-a,0],[-l,0],[-l,f],[-l+m,f],[-l+m,0]])),this.anchors.sleeve=[0,0]),s&&this.segments.push(new D([0,g],a,{fill:o,zorder:4})),this.segments.push(new p([[-a,g],[-l*.55,g],[-l*c-2*a,g-2*a],[-l*c-a*4,g]])),this.anchors.tip=[0,g],i&&(s&&this.segments.push(new D([0,g-x],a,{fill:o,zorder:4})),this.segments.push(new p([[0,g-x],[-S,g-x]])),this.segments.push(new p([[-S,g-x],[-S,g]],{arrow:"->"})),this.anchors.tipswitch=[0,g-x]),t&&n&&(s&&this.segments.push(new D([0,b+x],a,{fill:o,zorder:4})),this.segments.push(new p([[0,b+x],[-S,b+x]])),this.segments.push(new p([[-S,b+x],[-S,b]],{arrow:"->"})),this.anchors.ringswitch=[0,b+x])}};var fo=class extends se{constructor(e={}){super(e),Object.assign(this.defaults,{length:3,leadlen:.6,radius:.3});let t=this.params.leadlen,n=this.params.length,s=this.params.radius;this.segments.push(new p([[0,0],[t,0],H,[n-t+s/2,0],[n,0]])),this.segments.push(new p([[t,s],[n-t,s]])),this.segments.push(new p([[t,-s],[n-t,-s]])),this.segments.push(new xe([t,0],s,s*2,{theta1:0,theta2:360})),this.segments.push(new xe([n-t,0],s,s*2,{theta1:270,theta2:90})),this.anchors.shieldstart=[t,-s],this.anchors.shieldstart_top=[t,s],this.anchors.shieldend=[n-t,-s],this.anchors.shieldend_top=[n-t,s],this.anchors.shieldcenter=[n/2,-s],this.anchors.shieldcenter_top=[n/2,s]}},go=class extends se{constructor(e={}){super(e),Object.assign(this.defaults,{length:3,leadlen:.6,radiusinner:.3,radiusouter:.6,shieldofststart:.3,shieldofstend:.3});let t=this.params.radiusinner,n=this.params.radiusouter,s=this.params.length,i=this.params.leadlen,o=this.params.shieldofstend,a=this.params.shieldofststart;if(n<t)throw new Error("Triax inner radius > outer radius");let l=n/2*Math.sqrt(1-t*t/(n*n)),h=180;a-l>-t/2&&(h=180-Math.atan2(t,l)*180/Math.PI),s-i-o+n<s?(this.segments.push(new p([[0,0],[i,0],H,[s-i+t/2,0],[s,0]])),this.segments.push(new p([[s-i-o+l,t],[s-i,t]])),this.segments.push(new p([[s-i-o+l,-t],[s-i,-t]])),this.segments.push(new xe([s-i,0],t,t*2,{theta1:270,theta2:90}))):this.segments.push(new p([[0,0],[i,0],H,[s-i-o+n/2,0]])),this.segments.push(new p([[i,t],[i+a+l,t]])),this.segments.push(new p([[i,-t],[i+a+l,-t]])),this.segments.push(new p([[i+a,n],[s-i-o,n]])),this.segments.push(new p([[i+a,-n],[s-i-o,-n]])),this.segments.push(new xe([i,0],t,t*2,{theta1:0,theta2:360})),this.segments.push(new xe([i+a,0],n,n*2,{theta1:-h,theta2:h})),this.segments.push(new xe([s-i-o,0],n,n*2,{theta1:270,theta2:90})),this.anchors.guardstart=[i,-t],this.anchors.guardstart_top=[i,t],this.anchors.guardend=[s-i,-t],this.anchors.guardend_top=[s-i,t],this.anchors.shieldstart=[i+a,-n],this.anchors.shieldstart_top=[i+a,n],this.anchors.shieldend=[s-i-o,-n],this.anchors.shieldend_top=[s-i-o,n],this.anchors.shieldcenter=[s/2,-n],this.anchors.shieldcenter_top=[s/2,n]}};var bo=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{core:!0,loop:!1,corewidth:.75,phasegap:.4,arcwidth:.4});let t=e.t1??4,n=e.t2??4;typeof t=="number"&&(t=[t]),typeof n=="number"&&(n=[n]);let s=t,i=n,o=this.params.phasegap,a=this.params.loop,l=this.params.core,h=e.align??"center",c=this.params.corewidth;a&&(c+=.4),l&&(c+=.25);let m=0,f,g,b,v=(x,S)=>{if(h==="center"){let k=x/2-S/2;return[k,k+S]}else return h==="bottom"?[0,S]:[x-S,x]};if(a){let x=s.map(re=>Vn(re,[0,0],.06,.19,!1,!0,!1)),S=i.map(re=>Vn(re,[c,0],.06,.19,!1,!0,!0)),k=x.reduce((re,te)=>re+te[te.length-1][1],0)+o*(x.length-1),M=S.reduce((re,te)=>re+te[te.length-1][1],0)+o*(S.length-1);f=k,[g,b]=v(k,M);let _=.06,B=.19,$=Math.acos(_/B),Y=Math.PI*2*_,Z=Y-(_*$-B*Math.sin($)),I=(_-B)/2/.25,X=m,j=0;for(let re=0;re<x.length;re++){let te=x[re],ke=te[te.length-1][1],he=te.map(de=>[de[0],de[1]+X]);this.segments.push(new p(he)),this.anchors[`p${re*2+1}`]=he[0],this.anchors[`p${re*2+2}`]=he[he.length-1],f=he[he.length-1][1];let ve=0;for(ve=0;ve<s[re];ve++)this.anchors[`tapP${j+ve+1}`]=[I,he[0][1]+ve*Y+Z];j+=ve,X+=ke+o}X=g,j=0;for(let re=0;re<S.length;re++){let te=S[re],ke=te[te.length-1][1],he=te.map(de=>[de[0],de[1]+X]);this.segments.push(new p(he)),this.anchors[`s${re*2+1}`]=he[0],this.anchors[`s${re*2+2}`]=he[he.length-1],b=he[he.length-1][1];let ve=0;for(ve=0;ve<i[re];ve++)this.anchors[`tapS${j+ve+1}`]=[c-I,he[0][1]+ve*Y+Z];j+=ve,X+=ke+o}}else{let x=this.params.arcwidth,S=s.reduce((B,$)=>B+$,0)*x+o*(s.length-1),k=i.reduce((B,$)=>B+$,0)*x+o*(i.length-1);f=S,[g,b]=v(S,k);let M=m,_=0;for(let B=0;B<s.length;B++){let $=s[B];this.anchors[`p${B*2+2}`]=[0,M],this.anchors[`p${B*2+1}`]=[0,M+$*x];for(let Y=0;Y<$;Y++)this.segments.push(new xe([0,M+x/2],x,x,{theta1:270,theta2:90})),Y<$-1&&(this.anchors[`tapP${_+Y+1}`]=[0,M+x]),M+=x;_+=$-1,M+=o}M=g,_=0;for(let B=0;B<i.length;B++){let $=i[B];this.anchors[`s${B*2+2}`]=[c,M],this.anchors[`s${B*2+1}`]=[c,M+$*x];for(let Y=0;Y<$;Y++)this.segments.push(new xe([c,M+x/2],x,x,{theta1:90,theta2:270})),Y<$-1&&(this.anchors[`tapS${_+Y+1}`]=[c,M+x]),M+=x;_+=$-1,M+=o}}if(l){let x=Math.max(f,b),S=Math.min(m,g),k=c/2,M=c/10;this.segments.push(new p([[k-M,x],[k-M,S]])),this.segments.push(new p([[k+M,x],[k+M,S]]))}}tap(e,t,n="primary"){let s=n==="primary"?"P":"S",i;if(t===0?i=this.anchors[`${s.toLowerCase()}1`]:i=this.anchors[`tap${s}${t}`],i)this.anchors[e]=i;else throw new Error(`No tap at position ${t}`);return this}};function B2(r){return r instanceof A?[r.x,r.y]:[r[0],r[1]]}var rh=.25,dn=class extends Pe{constructor(e={}){let{double:t,...n}=e;super({...n,arrow:t?"<->":e.arrow??"->"}),this.anchors.center=[0,0]}},wo=class extends se{constructor(e={}){super(e),this.segments.push(new p([[0,0],H,[-rh/2,rh],[rh/2,-rh],H,[0,0]]))}},Xt=class extends se{constructor(e={}){super(e),Object.assign(this.defaults,{lblloc:"center",lblalign:["center","center"],lblofst:0}),this.segments.push(new p([[0,0],H,[1,0]],{visible:!1}))}},pn=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{radius:.075,open:!1});let n=this.params.open===!0?"bg":!0;this.anchors.start=[0,0],this.anchors.center=[0,0],this.anchors.end=[0,0],this.elmParams.drop=[0,0],this.elmParams.theta=0,this.elmParams.zorder=4,this.elmParams.fill=n,this.segments.push(new D([0,0],this.params.radius,{fill:n}))}},xo=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{headwidth:.15,headlength:.25,lblofst:.25});let t=this.params.headwidth,n=this.params.headlength;this.segments.push(new p([[-n,0],[0,0]],{arrowwidth:t,arrowlength:n,arrow:"->"})),this.anchors.start=[0,0],this.anchors.center=[0,0],this.anchors.end=[0,0]}},vo=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{radius:.075,open:!1});let t=this.params.radius,n=this.params.open?"bg":!0;this.elmParams.fill=n,this.segments.push(new D([.5,0],t)),this.segments.push(new D([1,0],t)),this.segments.push(new D([1.5,0],t)),this.elmParams.drop=[2,0]}},xr=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{zorder:0});let t=e.corner1??[0,0],n=e.corner2??[1,1],s=[t[0],n[1]],i=[n[0],t[1]];this.segments.push(new U([t,s,n,i],{closed:!0,zorder:0,fill:e.fill,lw:e.lw,ls:e.ls}))}},yo=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{shape:"-",k:1,to:[3,-2],dotradius:.075})}to(e,t=0,n=0){let s=A.fromXY(B2(e));return this.userParams.to=[s.x+t,s.y+n],this}delta(e,t){return this.userParams.delta=[e,t],this}dot(e=!1){return this.userParams.dot=e?"open":!0,this}idot(e=!1){return this.userParams.idot=e?"open":!0,this}shape(e){return this.userParams.shape=e,this}k(e){return this.userParams.k=e,this}arrow(e){return this.userParams.arrow=e,this}_place(e,t,n){this.dwgParams={...n},this._positioned||this._position(),this.elmParams.theta=0;let s=this.params.at??e,i=this.params.to??e,o=this.params.delta,a=this.params.arrow,l=this.params.shape,h=this.params.k??1,c,m;if(o!==void 0?(c=o[0],m=o[1]):(c=i[0]-s[0],m=i[1]-s[1]),this.segments=[],l==="-")this.segments.push(new p([[0,0],[c,m]],{arrow:a})),this.anchors.mid=[c/2,m/2];else if(l==="-|")this.segments.push(new p([[0,0],[c,0],[c,m]],{arrow:a})),this.anchors.mid=[c,m/2],this.elmParams.droptheta=m>0?90:-90;else if(l==="|-")this.segments.push(new p([[0,0],[0,m],[c,m]],{arrow:a})),this.anchors.mid=[c/2,m],this.elmParams.droptheta=c>0?0:180;else if(l==="z"||l==="Z"){let g=c>0?Math.abs(h):-Math.abs(h);this.segments.push(new p([[0,0],[g,0],[c-g,m],[c,m]],{arrow:a})),this.anchors.mid=[c/2,m/2],this.elmParams.droptheta=c>0?0:180}else if(l==="N"){let g=m>0?Math.abs(h):-Math.abs(h);this.segments.push(new p([[0,0],[0,g],[c,m-g],[c,m]],{arrow:a})),this.anchors.mid=[c/2,m/2],this.elmParams.droptheta=m>0?90:-90}else if(l==="n")this.segments.push(new p([[0,0],[0,h],[c,h],[c,m]],{arrow:a})),this.anchors.mid=[c/2,h],this.elmParams.droptheta=m>h?90:-90;else if(l==="c")this.segments.push(new p([[0,0],[h,0],[h,m],[c,m]],{arrow:a})),this.anchors.mid=[h,m/2],this.elmParams.droptheta=c>h?0:180;else throw new Error(`Wire: undefined shape ${l}`);let f=T(this.params,"dotradius",.075);if(this.params.dot){let b=this.params.dot==="open"?"bg":!0;this.segments.push(new D([c,m],f,{fill:b,zorder:3}))}if(this.params.idot){let b=this.params.idot==="open"?"bg":!0;this.segments.push(new D([0,0],f,{fill:b,zorder:3}))}return this.elmParams.lblloc="mid",this.elmParams.drop=[c,m],this.anchors.start=[0,0],this.anchors.end=[c,m],this._positioned=!0,super._place(e,t,n)}},So=class extends N{constructor(e={}){super(e),this.elmParams.lblloc="center",this.elmParams.lblofst=0;let t=e.label;t!==void 0&&t!==""&&this.label(t)}},ko=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{width:1.5,height:.625,lblloc:"center",fontsize:12,lblofst:0});let t=e.width??1.5,n=(e.height??.625)/2;this.segments.push(new U([[0,0],[n,n],[t,n],[t,-n],[n,-n]],{closed:!0})),this.anchors.start=[0,0];let s=e.s;s&&this.segments.push(new W([t/2,0],s,{fontsize:12}))}};function Qc(r){return r instanceof A?[r.x,r.y]:[r[0],r[1]]}function C1(r,e,t=.01){return Math.abs(r-e)<=t}function I1(r){let e=r.absanchors.center;if(e!==void 0)return e;let t=r.getBBox(!1,!1),n=(t.xmin+t.xmax)/2,s=(t.ymin+t.ymax)/2;return r.transform.transform([n,s])}var Mo=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{k:.5})}to(e,t=0,n=0){let s=A.fromXY(Qc(e));return this.userParams.to=[s.x+t,s.y+n],this}delta(e,t){return this.userParams.delta=[e,t],this}k(e){return this.userParams.k=e,this}arrow(e){return this.userParams.arrow=e,this}_place(e,t,n){this.dwgParams={...n},this._positioned||this._position(),this.segments=[],this.elmParams.theta=0;let s=this.params.at??e,i=this.params.to??[s[0]+3,s[1]],o=this.params.delta,a,l;o!==void 0?(a=o[0],l=o[1]):(a=i[0]-s[0],l=i[1]-s[1]);let h=this.params.k??.5,c=[a/2-l*h,l/2+a*h],m=[a/2-l*h/2,l/2+a*h/2],f=this.params.arrow;this.segments.push(new Ut([[0,0],c,[a,l]],{arrow:f})),this.anchors.ctrl=c,this.anchors.mid=m,this.anchors.start=[0,0],this.anchors.end=[a,l],this.elmParams.lblloc="mid",this.elmParams.drop=[a,l];let g="bottom",b="left",v=.1,x=0;return C1(m[1],c[1])?(g="center",v=0):m[1]>c[1]&&(g="top",v=-.1),C1(m[0],c[0])?b="center":m[0]>c[0]?(b="right",v=0,x=-.1):(x=.1,v=0),this.elmParams.lblofst=[x,v],this.elmParams.lblalign=[b,g],this._positioned=!0,super._place(e,t,n)}},fn=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{k:.75,th1:0,th2:180,to:[1,0],arrowlength:.25,arrowwidth:.2})}to(e,t=0,n=0){let s=A.fromXY(Qc(e));return this.userParams.to=[s.x+t,s.y+n],this}delta(e,t){return this.userParams.delta=[e,t],this}k(e){return this.userParams.k=e,this}th1(e){return this.userParams.th1=e,this}th2(e){return this.userParams.th2=e,this}arrow(e){return this.userParams.arrow=e,this}arrowlength(e){return this.userParams.arrowlength=e,this}arrowwidth(e){return this.userParams.arrowwidth=e,this}setLabelAlign(e,t){this.elmParams.lblloc="center";let n="left",s="bottom";t>0&&(s="top",this.elmParams.lblofst=-.1),e<=0&&(n="right"),this.elmParams.lblalign=[n,s]}_place(e,t,n){this.dwgParams={...n},this._positioned||this._position(),this.segments=[],this.userParams.theta=0;let s=this.params.at??e,i=this.params.to??e,o=this.params.delta,a,l;o!==void 0?(a=o[0],l=o[1]):(a=i[0]-s[0],l=i[1]-s[1]);let h=this.params.k??.75,c=(this.params.th1??0)*(Math.PI/180),m=(this.params.th2??180)*(Math.PI/180),f=[a*h*Math.cos(c),l*h*Math.sin(c)],g=[a+a*h*Math.cos(m),l+l*h*Math.sin(m)],b=this.params.arrow,v=this.params.arrowlength,x=this.params.arrowwidth;return this.segments.push(new Ut([[0,0],f,g,[a,l]],{arrow:b,arrowlength:v,arrowwidth:x})),this.anchors.center=[a/2,l/2],this.anchors.start=[0,0],this.anchors.end=[a,l],this.anchors.ctrl1=f,this.anchors.ctrl2=g,this.elmParams.drop=[a,l],this.setLabelAlign(a,l),this._positioned=!0,super._place(e,t,n)}},zo=class extends fn{constructor(e={}){super({...e,to:e.to??[1,1],th1:e.th1??75,th2:e.th2??180,arrow:e.arrow??"<-"})}setLabelAlign(e,t){this.elmParams.lblloc="end";let n=this.anchors.ctrl2,s=this.anchors.end,i;for(n[0]===s[0]&&n[1]===s[1]?i=t<0?-90:90:i=Math.atan2(s[1]-n[1],s[0]-n[0])*180/Math.PI;i<0;)i+=360;i<45||i>315?(this.elmParams.lblalign=["left","center"],this.elmParams.lblofst=[.1,0]):i>=45&&i<=135?(this.elmParams.lblalign=["center","bottom"],this.elmParams.lblofst=[0,.1]):i>135&&i<=225?(this.elmParams.lblalign=["right","center"],this.elmParams.lblofst=[-.1,0]):(this.elmParams.lblalign=["center","top"],this.elmParams.lblofst=[0,-.1])}},Eo=class extends fn{constructor(e={}){super({...e,th1:0,th2:180})}},Po=class extends fn{constructor(e={}){super({...e,th1:90,th2:-90})}},To=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{radius:.6,arrowlength:.25,arrowwidth:.2})}to(e,t=0,n=0){let s=A.fromXY(Qc(e));return this.userParams.to=[s.x+t,s.y+n],this}delta(e,t){return this.userParams.delta=[e,t],this}radius(e){return this.userParams.radius=e,this}arrow(e){return this.userParams.arrow=e,this}arrowlength(e){return this.userParams.arrowlength=e,this}arrowwidth(e){return this.userParams.arrowwidth=e,this}_place(e,t,n){this.dwgParams={...n},this._positioned||this._position(),this.segments=[],this.elmParams.theta=0;let s=this.params.at??e,i=this.params.to??e,o=this.params.delta,a,l;o!==void 0?(a=o[0],l=o[1]):(a=i[0]-s[0],l=i[1]-s[1]);let h=this.params.radius??.6,c=a/2,m=l/2,f=Math.sqrt(a*a+l*l),g=h*h-f/2*(f/2);if(g<0)throw new Error(`ArcLoop: no solution for radius ${h}`);let b=Math.sqrt(g),v=[c+b*(-l/f),m+b*(a/f)],x=Math.sqrt(c*c+m*m),S=Math.atan2(m,c),k=Math.acos(x/h),M=S-k,_=S+k,B=ze(Math.PI+_,M,50),$=[],Y=[];for(let re of B)$.push(v[0]+h*Math.cos(re)),Y.push(v[1]+h*Math.sin(re));let Z=$.map((re,te)=>[re,Y[te]]),L=this.params.arrow,I=this.params.arrowlength,X=this.params.arrowwidth;this.segments.push(new p(Z,{arrow:L,arrowlength:I,arrowwidth:X}));let j=Math.floor($.length/2);return this.anchors.start=[0,0],this.anchors.end=[$[$.length-1],Y[Y.length-1]],this.anchors.mid=[$[j],Y[j]],this.anchors.BL=[Math.min(...$),Math.min(...Y)],this.anchors.BR=[Math.max(...$),Math.min(...Y)],this.anchors.TL=[Math.min(...$),Math.max(...Y)],this.anchors.TR=[Math.max(...$),Math.max(...Y)],this.elmParams.lblloc="mid",this.elmParams.drop=[i[0]-s[0],i[1]-s[1]],this.elmParams.lblofst=[0,.2],Y[j]<Y[0]&&(this.elmParams.lblofst=[0,-.25]),this._positioned=!0,super._place(e,t,n)}},h0=class extends N{constructor(t={}){super(t);z(this,"_side","top");Object.assign(this.defaults,{ofst:.15,length:2,top:!0,reverse:!1,headlength:.3,headwidth:.2,anchor:"center",drop:null}),this.anchors.center=[0,0]}at(t,n=0,s=0){return t instanceof N?(this.userParams.overElement=t,this):super.at(t,n,s)}over(t){return this.userParams.overElement=t,this}placeArrowSegment(t){let n=this.params.ofst??.15,s=this.params.length??2;this._side==="bottom"&&(n=-n);let i=[-s/2,n],o=[s/2,n],a=this.params.headwidth??.2,l=this.params.headlength??.3;this.segments.push(new p([i,o],{arrow:"->",arrowwidth:a,arrowlength:l}))}placeFromOverElement(t){let n=String(T(t.params,"ilabel","top")).toLowerCase();n==="bot"&&(n="bottom"),this.params.top!==!1||(n={top:"bottom",bottom:"top",left:"right",right:"left"}[n]??n);let i=this.userParams.reverse===!0;if(t.userParams.reverse===!0){let f={left:"right",right:"left"};f[n]!==void 0?n=f[n]:i=!i}t.userParams.flip===!0&&(n==="left"||n==="right")&&(i=!i),n==="left"&&(i=!i),this.userParams.reverse=i;let o=t.transform.theta,a=t.getBBox(!1,!1),l,h;n==="top"?(l=new A((a.xmin+a.xmax)/2,a.ymax),h="top"):n==="bottom"?(l=new A((a.xmin+a.xmax)/2,a.ymin),h="bot"):n==="right"?(l=new A(a.xmax,(a.ymin+a.ymax)/2),h="bot",o-=90):n==="left"?(l=new A(a.xmin,(a.ymin+a.ymax)/2),h="top",o+=90):(l=new A((a.xmin+a.xmax)/2,a.ymax),h="top");let c=t.transform.transform(l.toTuple());this.userParams.at=[c.x,c.y],this.userParams.theta=o,this.elmParams.lblloc=h,this._side=n==="bottom"?"bottom":n==="top"?"top":n==="left"?"left":"right";let m=t.userParams.color;m!==void 0&&(this.userParams.color=m)}_place(t,n,s){this.dwgParams={...s};let i=this.params.overElement;i!==void 0&&this.placeFromOverElement(i),this.segments=[];let o=((this.params.theta??0)%360+360)%360,a=this.params.lblloc??"top",l=this._side;if(l==="right"&&(o<=90||o>270)){let h=this.elmParams.lblloc??"top";this.elmParams.lblloc=h==="bot"?"top":"bot",a=this.elmParams.lblloc}else if((l==="top"||l==="left"||l==="bottom")&&o>90&&o<=270){let h=this.elmParams.lblloc??"top";this.elmParams.lblloc=h==="bot"?"top":"bot",a=this.elmParams.lblloc}return this.placeArrowSegment(a),super._place(t,n,s)}},Ro=class extends h0{constructor(e={}){super(e),Object.assign(this.defaults,{length:1.75,ofst:.075,bend:.6})}placeArrowSegment(e){let t=this.params.ofst??.075,n=this.params.bend??.6,s=this.params.length??1.75;this._side==="bottom"&&(t=-t,n=-n);let i=this.params.headwidth??.2,o=this.params.headlength??.3,a=this.params.reverse===!0?"<-":"->",l=[-s/2,t],h=[s/2,t],c=[0,n];this.segments.push(new Ut([l,c,h],{arrow:a,arrowlength:o,arrowwidth:i}))}},gn=class extends N{constructor(e="in",t=.8,n=!0,s={}){super(s),Object.assign(this.defaults,{headlength:.3,headwidth:.3}),this.elmParams.lblofst=0,this.elmParams.drop=null,this.elmParams.zorder=4;let i=t,o=this.params.headlength??.3;e==="in"&&(i+=this.params.headlength??.3,o=-o),n&&(i=-i,o=-o);let a=this.params.headwidth??.3,l=this.params.headlength??.3;this.segments.push(new p([[i,0],[i+o,0]],{arrow:"->",arrowwidth:a,arrowlength:l}))}at(e,t=0,n=0){return e instanceof N?(this.userParams.overElement=e,this):super.at(e,t,n)}over(e){return this.userParams.overElement=e,this}_place(e,t,n){this.dwgParams={...n},this._positioned||this._position();let s=this.params.overElement;if(s!==void 0){let i=I1(s);this.userParams.at=[i.x,i.y],this.userParams.theta=s.transform.theta;let o=s.userParams.color;o!==void 0&&(this.userParams.color=o)}return this._positioned=!0,super._place(e,t,n)}},Ao=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{ofst:.5,hofst:.4,length:1,lengthtip:.5,headlength:.25,headwidth:.15}),this.userParams.anchor="center",this.anchors.center=[0,0]}at(e,t=0,n=0){return e instanceof N?(this.userParams.overElement=e,this):super.at(e,t,n)}over(e){return this.userParams.overElement=e,this}_place(e,t,n){this.dwgParams={...n},this._positioned||this._position();let s=this.params.overElement;if(s!==void 0){let v=I1(s);this.userParams.at=[v.x,v.y];let x=s.transform.theta;(x%360+360)%360>90&&(x%360+360)%360<=270&&(x+=180),this.userParams.theta=x;let S=s.userParams.color;S!==void 0&&(this.userParams.color=S)}let i=this.params.hofst??.4,o=this.params.ofst??.5,a=this.params.lengthtip??.5,l=this.params.length??1,h=this.params.headwidth??.15,c=this.params.headlength??.25,m=[-i,o],f=[-i-a,o],g=[-i-a,o-l];this.anchors.head=m,this.anchors.tail=g,this.segments=[],this.segments.push(new p([g,f,m],{arrow:"->",arrowwidth:h,arrowlength:c})),this.elmParams.lblloc="tail";let b=this.params.theta??0;return this.params.flip===!0&&(b+=180),b-=90,b=(b%360+360)%360,b<45||b>315?(this.elmParams.lblalign=["left","center"],this.elmParams.lblofst=[0,-.1]):b>=45&&b<=135?(this.elmParams.lblalign=["center","bottom"],this.elmParams.lblofst=[0,.1]):b>135&&b<=225?(this.elmParams.lblalign=["right","center"],this.elmParams.lblofst=[0,.1]):(this.elmParams.lblalign=["center","top"],this.elmParams.lblofst=[0,-.1]),this._positioned=!0,super._place(e,t,n)}},c0=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{lblloc:"center",lblofst:0,theta:0});let t=e.direction??"cw",n=e.theta1??35,s=e.theta2??-35,i=e.width??1,o=e.height??1;this.segments.push(new xe([0,0],i,o,{theta1:n,theta2:s,arrow:t})),this.anchors.center=[0,0]}},nh=class extends c0{constructor(e){At(null);let{elm_list:t,pad:n=.2,...s}=e,i=t[0].getBBox(!0,!1),o=t[1].getBBox(!0,!1),a=t[2].getBBox(!0,!1),l=t[3].getBBox(!0,!1),h=i.ymin-n,c=a.ymax+n,m=l.xmax+n,f=o.xmin-n,g=[(m+f)/2,(h+c)/2],b=f-m,v=h-c;super({...s,width:b,height:v,at:g})}},sh=class extends N{constructor(e){At(null);let{elm_list:t,includelabels:n=!0,...s}=e;super(s),Object.assign(this.defaults,{padx:.2,pady:.2,theta:0});let i=1/0,o=-1/0,a=1/0,l=-1/0;for(let k of t){let M=k.getBBox(!0,n);i=Math.min(i,M.xmin),o=Math.max(o,M.xmax),a=Math.min(a,M.ymin),l=Math.max(l,M.ymax)}let h=this.params.padx??.2,c=this.params.pady??.2;i-=h,o+=h,a-=c,l+=c;let m=o-i,f=l-a,g=[(o+i)/2,(l+a)/2];this.userParams.at=g,this.segments.push(new xe([0,0],m,f,{theta1:0,theta2:360}));let b=Math.sin(Math.PI/4),v=Math.cos(Math.PI/4),x=Math.sin(Math.PI/8),S=Math.cos(Math.PI/8);this.anchors.N=[0,f/2],this.anchors.S=[0,-f/2],this.anchors.E=[m/2,0],this.anchors.W=[-m/2,0],this.anchors.SE=[m/2*v,-f/2*b],this.anchors.SW=[-m/2*v,-f/2*b],this.anchors.NW=[-m/2*v,f/2*b],this.anchors.NE=[m/2*v,f/2*b],this.anchors.ENE=[m/2*S,f/2*x],this.anchors.WNW=[-m/2*S,f/2*x],this.anchors.ESE=[m/2*S,-f/2*x],this.anchors.WSW=[-m/2*S,-f/2*x],this.anchors.NNE=[m/2*x,f/2*S],this.anchors.NNW=[-m/2*x,f/2*S],this.anchors.SSE=[m/2*x,-f/2*S],this.anchors.SSW=[-m/2*x,-f/2*S]}},ih=class extends N{constructor(e){At(null);let{elm_list:t,includelabels:n=!0,...s}=e;super(s),Object.assign(this.defaults,{cornerradius:.3,padx:.2,pady:.2,theta:0});let i=1/0,o=-1/0,a=1/0,l=-1/0;for(let x of t){let S=x.getBBox(!0,n);i=Math.min(i,S.xmin),o=Math.max(o,S.xmax),a=Math.min(a,S.ymin),l=Math.max(l,S.ymax)}let h=this.params.padx??.2,c=this.params.pady??.2;i-=h,o+=h,a-=c,l+=c;let m=o-i,f=l-a,g=[(o+i)/2,(l+a)/2];this.userParams.at=g;let b=this.params.cornerradius??.3;this.segments.push(new U([[-m/2,f/2],[m/2,f/2],[m/2,-f/2],[-m/2,-f/2]],{closed:!0,cornerradius:b}));let v=b-b*Math.sqrt(2)/2;this.anchors.NE=[m/2-v,f/2-v],this.anchors.NW=[-m/2+v,f/2-v],this.anchors.SE=[m/2-v,-f/2+v],this.anchors.SW=[-m/2+v,-f/2+v],this.anchors.N=[0,f/2],this.anchors.S=[0,-f/2],this.anchors.E=[m/2,0],this.anchors.W=[-m/2,0]}};var ir=class extends N{constructor(t={}){super(t);z(this,"compoundDwgParams");z(this,"elements",[]);z(this,"_here",new A(0,0));z(this,"_theta",0);this.compoundDwgParams={unit:t.unit??3,font:t.font??null,fontsize:t.fontsize??14,lblofst:t.lblofst??.1,color:t.color??"black",lw:t.lw??2,ls:t.ls??"-",fill:t.fill??"none"};let n=la(!0);try{this.setup(),this._initAnchors()}finally{la(n)}}_initAnchors(){for(let[t,n]of Object.entries(this))if(n instanceof N&&t!=="elements")for(let s of Object.keys(n.anchors)){let i=n.absanchors[s];i&&(this.anchors[`${t}.${s}`]=[i.x,i.y])}}move(t,n){this._here=new A(this._here.x+t,this._here.y+n)}moveFrom(t,n=0,s=0,i){let o=t instanceof A?t.x:t[0],a=t instanceof A?t.y:t[1];this._here=new A(o+n,a+s),i!==void 0&&(this._theta=i)}contains(t){return this.elements.includes(t)}add(t){this.elements.push(t);let n=t._place(this._here.toTuple(),this._theta,this.compoundDwgParams);this._here=n.point,this._theta=n.theta;for(let s of t.segments){let i=s.xform(t.transform,t.params);this.segments.push(i)}return t}};function fe(r,e){let t=r.absanchors[e];return[t.x,t.y]}var _o=class extends ir{constructor(e={}){super({...e,unit:1.5,_box:e.box!==!1,_boxfill:e.boxfill??"none",_boxpad:e.boxpad??.2,_base:e.base===!0})}setup(){let t=this.userParams._box!==!1,n=this.userParams._boxfill??"none",s=this.userParams._boxpad??.2,i=this.userParams._base===!0,o=this.add(new et({d:"d"})),a=new Ht({d:"r",at:[1,-1.5/2]});a.segments.splice(0,1);let l=this.add(a);this.add(new dn({d:"r",at:[.5,-1.5/2+.2],l:.6,arrowwidth:.15,arrowlength:.2})),this.add(new dn({d:"r",at:[.5,-1.5/2-.2],l:.6,arrowwidth:.15,arrowlength:.2}));let h=this.getBBox(!1);if(t&&this.add(new xr({d:"r",at:[0,0],corner1:[h.xmin-s,h.ymin-s],corner2:[h.xmax+s,h.ymax+s],fill:n,zorder:0})),i){let b=l.getBBox(!0),v=o.absanchors.center;this.add(new Pe({d:"l",at:[b.xmin,v.y],l:.15}));let x=this.add(new Pe({d:"d",toy:h.ymax+s}));this.anchors.base=fe(x,"end")}let c=this.add(new Pe({d:"r",at:fe(a,"collector"),l:s})),m=this.add(new Pe({d:"r",at:fe(a,"emitter"),l:s})),f=this.add(new Pe({d:"l",at:fe(o,"start"),tox:h.xmin-s})),g=this.add(new Pe({d:"l",at:fe(o,"end"),tox:h.xmin-s}));this.anchors.anode=fe(f,"end"),this.anchors.cathode=fe(g,"end"),this.anchors.emitter=fe(m,"end"),this.anchors.collector=fe(c,"end")}},Bo=class extends ir{constructor(e={}){super(e)}setup(){let e=this.userParams.fill??!1,t=this.userParams.labels,n=new et({fill:e}).theta(45),s=new et({fill:e}).theta(-45),i=new et({fill:e}).theta(-135).reverse(),o=new et({fill:e}).theta(135).reverse(),a=["top","top","bottom","bottom"];t&&[n,s,i,o].forEach((l,h)=>{t[h]&&l.label(t[h],{loc:a[h]})}),this.add(n),this.add(s),this.add(i),this.add(o),this.anchors.W=fe(n,"start"),this.anchors.N=fe(s,"start"),this.anchors.E=fe(i,"start"),this.anchors.S=fe(o,"start"),this.elmParams.theta=0}},Co=class extends ir{constructor(e={}){super(e)}setup(){let e=this.userParams.vout===!0,t=this.userParams.labels,n=new dt().theta(45),s=new dt().theta(-45),i=new dt().theta(-135),o=new dt().theta(135),a=["top","top","bottom","bottom"];if(t&&[n,s,i,o].forEach((l,h)=>{t[h]&&l.label(t[h],{loc:a[h]})}),this.add(n),this.add(s),this.add(i),this.add(o),e){let l=n.absanchors.start;this.add(new Pe({}).right().at([l.x,l.y]).length(1));let h=this.add(new pn({open:!0})),c=i.absanchors.start;this.add(new Pe({}).left().at([c.x,c.y]).length(1));let m=this.add(new pn({open:!0}));this.anchors.vo1=fe(h,"center"),this.anchors.vo2=fe(m,"center"),this._labelhints.vo1={ofst:[0,.1],halign:"center",valign:"bottom"},this._labelhints.vo2={ofst:[0,.1],halign:"center",valign:"bottom"}}this.anchors.W=fe(n,"start"),this.anchors.N=fe(s,"start"),this.anchors.E=fe(i,"start"),this.anchors.S=fe(o,"start"),this.elmParams.theta=0}},Io=class extends ir{constructor(e={}){let t=e.unit??2;super({...e,unit:t})}setup(){let e=this.userParams.unit??2,t=this.userParams.cycl===!0,n=this.userParams.switch??"spst",s=this.userParams.core!==!1,i=this.userParams.box!==!1,o=this.userParams.boxfill??"none",a=this.userParams.boxpad??.25,l=this.userParams.swreverse===!0,h=this.userParams.swflip===!0,c=this.userParams.link!==!1,m=t?this.add(new Lr({d:"d"})):this.add(new Ir({d:"d"}));this.anchors.in1=fe(m,"start"),this.anchors.in2=fe(m,"end");let f=m.getBBox(!0).xmax,g=f+.6;s&&(this.add(new Pe({d:"d",at:[f+.15,-e/2],anchor:"center",l:1})),g+=.1);let b;if(n==="spst"){let v=new Xr({d:"d",reverse:l,flip:h}),x=v.getBBox(!1);v.userParams.at=[g-(h?-x.ymax:x.ymin),0],this.add(v),this.anchors.a=fe(v,"start"),this.anchors.b=fe(v,"end"),b=v}else if(n==="spdt"){let v=new Xs({d:"d",reverse:l,flip:h}),x=v.getBBox(!1);v.userParams.at=[g-(h?-x.ymax:x.ymin),-.5],this.add(v);let S=l?-e:0,k=l?0:-e,M=this.add(new Pe({d:l?"d":"u",at:fe(v,"a"),toy:S})),_=this.add(new Pe({d:l?"u":"d",at:fe(v,"b"),toy:k})),B=this.add(new Pe({d:l?"u":"d",at:fe(v,"c"),toy:k}));this.anchors.a=fe(M,"end"),this.anchors.b=fe(_,"end"),this.anchors.c=fe(B,"end"),b=v}else if(n==="dpst"){let v=new Gs({d:"d",link:!1,reverse:l,flip:h}),x=v.getBBox(!1);v.userParams.at=[g-(h?-x.ymax:x.ymin),-.5],this.add(v);let S=l?0:-e,k=l?-e:0,M=this.add(new Pe({d:l?"u":"d",at:fe(v,"t1"),toy:S})),_=this.add(new Pe({d:l?"u":"d",at:fe(v,"t2"),toy:S})),B=this.add(new Pe({d:l?"d":"u",at:fe(v,"p1"),toy:k})),$=this.add(new Pe({d:l?"d":"u",at:fe(v,"p2"),toy:k}));this.anchors.t1=fe(M,"end"),this.anchors.t2=fe(_,"end"),this.anchors.p1=fe(B,"end"),this.anchors.p2=fe($,"end"),b=v}else if(n==="dpdt"){let v=new Ws({d:"d",link:!1,reverse:l,flip:h}),x=v.getBBox(!1);v.userParams.at=[g-(h?-x.ymax:x.ymin),-.5],this.add(v);let S=l?0:-e,k=l?-e:0,M=this.add(new Pe({d:l?"u":"d",at:fe(v,"t1"),toy:S})),_=this.add(new Pe({d:l?"u":"d",at:fe(v,"t2"),toy:S})),B=this.add(new Pe({d:l?"u":"d",at:fe(v,"t3"),toy:S})),$=this.add(new Pe({d:l?"u":"d",at:fe(v,"t4"),toy:S})),Y=this.add(new Pe({d:l?"d":"u",at:fe(v,"p1"),toy:k})),Z=this.add(new Pe({d:l?"d":"u",at:fe(v,"p2"),toy:k}));this.anchors.t1=fe(M,"end"),this.anchors.t2=fe(_,"end"),this.anchors.t3=fe(B,"end"),this.anchors.t4=fe($,"end"),this.anchors.p1=fe(Y,"end"),this.anchors.p2=fe(Z,"end"),b=v}else{let v=new Xr({d:"d"});v.userParams.at=[g,0],this.add(v),b=v}if(c){let v=b.getBBox(!1),x=h?v.ymax:v.ymin;this.add(new Pe({d:"r",at:[f+.2,-e/2],ls:":",tox:x}))}if(i){let v=this.getBBox(!1);this.add(new xr({d:"r",at:[0,0],corner1:[v.xmin-a,v.ymin+.2],corner2:[v.xmax+a,v.ymax-.2],fill:o,zorder:0}))}}};var L1=1,D1=.5;function Vs(r,e){let t=r.absanchors[e];return[t.x,t.y]}var vr=class extends ir{constructor(t={}){super({unit:t.unit??1.5,...t});z(this,"inputComponent");z(this,"outputComponent")}setup(){let t=this.userParams._inputFactory,n=this.userParams._outputFactory,s=this.userParams.boxpadx??.2,i=this.userParams.boxpady??.2,o=this.userParams.minw??.5,a=this.userParams.terminals??!0,l=this.userParams.width??2.15,h=this.userParams.box??!0,c=this.userParams.boxfill,m=this.userParams.boxlw,f=this.userParams.boxls,g=(t??(()=>new Xt))();g.down();let b=(n??(()=>new Xt))();b.down();let v=g.getBBox(!1,!1),x=b.getBBox(!1,!1),S=Math.max((v.ymax-v.ymin)/2,o/2),k=Math.max((x.ymax-x.ymin)/2,o/2);g.at([s+S,0]),b.at([l-s-k,0]),this.inputComponent=this.add(g),this.outputComponent=this.add(b);let M=this.getBBox(!1,!1);h&&this.add(new xr({theta:0,at:[0,0],corner1:[0,M.ymin-i],corner2:[l,M.ymax+i],fill:c??"none",lw:m,ls:f,zorder:0})),M=this.getBBox(!1,!1);let _=this.add(new Pe({at:Vs(this.outputComponent,"start")}).tox(M.xmax).right()),B=this.add(new Pe({at:Vs(this.outputComponent,"end")}).tox(M.xmax).right()),$=this.add(new Pe({at:Vs(this.inputComponent,"start")}).tox(M.xmin).left()),Y=this.add(new Pe({at:Vs(this.inputComponent,"end")}).tox(M.xmin).left());if(this.anchors.in_p=Vs($,"end"),this.anchors.in_n=Vs(Y,"end"),this.anchors.out_p=Vs(_,"end"),this.anchors.out_n=Vs(B,"end"),this.anchors.center=[(M.xmin+M.xmax)/2,(M.ymin+M.ymax)/2],this._labelhints.in_p={ofst:[0,.15],halign:"right"},this._labelhints.in_n={ofst:[0,.15],halign:"right"},this._labelhints.out_p={ofst:[0,.15],halign:"left"},this._labelhints.out_n={ofst:[0,.15],halign:"left"},a)for(let Z of["in_p","in_n","out_p","out_n"]){let L=Z.startsWith("in")?-D1:D1,I=this.anchors[Z],X=[I[0]+L,I[1]];this.anchors[Z]=X,this.segments.push(new p([I,X]))}}},Lo=class extends vr{constructor(e={}){super({...e,_inputFactory:()=>new Xt,_outputFactory:()=>new Xt,boxpadx:e.boxpadx??0,minw:e.minw??0})}setup(){super.setup();let e=this.userParams.sign??!0,t=this.userParams.arrow??!0,n=this.userParams.reverse_output??!1;if(e){let s=this.inputComponent.absanchors.end,i=this.inputComponent.absanchors.start;this.segments.push(new W([s.x+.1,s.y+.1],"\u2212",{halign:"left",valign:"center",rotation:0})),this.segments.push(new W([i.x+.1,i.y-.1],"+",{halign:"left",valign:"center",rotation:0}));let o=this.outputComponent.absanchors.end,a=this.outputComponent.absanchors.start;n?(this.segments.push(new W([o.x-.1,o.y+.1],"+",{halign:"right",valign:"center",rotation:0})),this.segments.push(new W([a.x-.1,a.y-.1],"\u2212",{halign:"right",valign:"center",rotation:0}))):(this.segments.push(new W([o.x-.1,o.y+.1],"\u2212",{halign:"right",valign:"center",rotation:0})),this.segments.push(new W([a.x-.1,a.y-.1],"+",{halign:"right",valign:"center",rotation:0})))}if(t){let s=this.anchors.center;this.segments.push(new p([[s[0]-L1/2,s[1]],[s[0]+L1/2,s[1]]],{arrow:"->",lw:2,arrowwidth:.3,arrowlength:.3}))}}},Do=class extends vr{constructor(e={}){let t=e.reverse_output??!1;super({...e,_inputFactory:()=>new Xt,_outputFactory:()=>t?new br:new br({reverse:!0})})}setup(){super.setup();let e=this.inputComponent.absanchors.end,t=this.inputComponent.absanchors.start;this.segments.push(new W([e.x,e.y+.05],"\u2212",{halign:"right",valign:"bottom",rotation:0})),this.segments.push(new W([t.x,t.y-.05],"+",{halign:"right",valign:"top",rotation:0}))}},No=class extends vr{constructor(e={}){let t=e.reverse_output??!1;super({...e,_inputFactory:()=>new Pe,_outputFactory:()=>t?new br:new br({reverse:!0})})}setup(){super.setup();let e=new gn("in",-.15,!0,{headlength:.3});e.at(this.inputComponent),this.add(e)}},Oo=class extends vr{constructor(e={}){let t=e.reverse_output??!1;super({...e,_inputFactory:()=>new Pe,_outputFactory:()=>t?new wr:new wr({reverse:!0})})}setup(){super.setup();let e=new gn("in",-.15,!0,{headlength:.3});e.at(this.inputComponent),this.add(e)}},Fo=class extends vr{constructor(e={}){let t=e.reverse_output??!1;super({...e,_inputFactory:()=>new Xt,_outputFactory:()=>t?new wr:new wr({reverse:!0})})}setup(){super.setup();let e=this.inputComponent.absanchors.end,t=this.inputComponent.absanchors.start;this.segments.push(new W([e.x,e.y+.05],"\u2212",{halign:"right",valign:"bottom",rotation:0})),this.segments.push(new W([t.x,t.y-.05],"+",{halign:"right",valign:"top",rotation:0}))}},$o=class extends vr{constructor(e={}){super({...e,_inputFactory:()=>new Nr,_outputFactory:()=>new Or,boxpadx:e.boxpadx??.3})}},jo=class extends vr{constructor(e={}){super({...e,_inputFactory:()=>new $r,_outputFactory:()=>new Fr,boxpadx:e.boxpadx??.3})}};var Le=1.1,u0=class extends N{constructor(t={}){super(t);z(this,"_outletrad",1.5);let n=!!t.plug,s=this._outletrad,i=ze(Math.PI*3/4,Math.PI*5/4),o=i.map(_=>.15+s*Math.cos(_)),a=i.map(_=>s*Math.sin(_)),l=i.map(_=>-.15+-s*Math.cos(_)),h=i.map(_=>-s*Math.sin(_)),c=[...o,...l],m=[...a,...h],f=c.map((_,B)=>[_,m[B]]);this.segments.push(new U(f));let g=s/8,b=g*3,v=b*1.25,x=b/2,S=v/2,k=s/2.2,M=n?"black":"bg";this.segments.push(new U([[-k,S],[-k,S-v],[-k+g,S-v],[-k+g,S]],{fill:M,zorder:3})),this.segments.push(new U([[k,x],[k,x-b],[k-g,x-b],[k-g,x]],{fill:M,zorder:3})),this.anchors.hot=[k-g/2,0],this.anchors.neutral=[-k+g/2,0],this.elmParams.drop=[k-g/2,0]}},qo=class extends u0{constructor(e={}){super(e);let t=!!e.plug,n=this._outletrad,s=n/4,i=-n/2.5,o=[-s/2,-s/2,s/2,s/2],a=[i,i-s/2,i-s/2,i],l=ze(0,Math.PI);for(let b of l)o.push(s/2*Math.cos(b)),a.push(i+s/2*Math.sin(b));let h=t?"black":"bg",c=o.map((b,v)=>[b,a[v]]);this.segments.push(new U(c,{fill:h,zorder:3}));let m=s/2,f=this.segments[1];f.verts=f.verts.map(([b,v])=>[b,v+m]);let g=this.segments[2];g.verts=g.verts.map(([b,v])=>[b,v+m]),this.anchors.hot=[this.anchors.hot[0],this.anchors.hot[1]+m],this.anchors.neutral=[this.anchors.neutral[0],this.anchors.neutral[1]+m],this.anchors.ground=[0,i]}},m0=class extends N{constructor(e={}){super(e);let n=!!e.plug?"black":"bg";this.segments.push(new D([0,0],Le));let s=Le/8,i=Le/2;this.segments.push(new D([-i,0],s,{fill:n,zorder:3})),this.segments.push(new D([i,0],s,{fill:n,zorder:3})),this.anchors.hot=[i,0],this.anchors.neutral=[-i,0],this.elmParams.drop=[i,0]}},Ho=class extends N{constructor(e={}){super(e);let n=!!e.plug?"black":"bg";this.segments.push(new D([0,0],Le));let s=Le/8,i=Le/2,o=-Le/4,a=Le/2.5;this.segments.push(new D([-i,o],s,{fill:n,zorder:3})),this.segments.push(new D([i,o],s,{fill:n,zorder:3})),this.segments.push(new D([0,a],s*1.2,{fill:n,zorder:3})),this.anchors.hot=[i,o],this.anchors.neutral=[-i,o],this.anchors.ground=[0,a],this.elmParams.drop=[0,a]}},Yo=class extends N{constructor(e={}){super(e);let n=!!e.plug?"black":"bg";this.segments.push(new D([0,0],Le));let s=Le/8,i=Le/2,o=0,a=Le/2;this.segments.push(new D([-i,o],s,{fill:n,zorder:3})),this.segments.push(new D([i,o],s,{fill:n,zorder:3})),this.segments.push(new D([0,a],s,{fill:n,zorder:3})),this.anchors.hot=[i,o],this.anchors.neutral=[-i,o],this.anchors.ground=[0,a],this.elmParams.drop=[-i,o]}},Xo=class extends m0{constructor(e={}){super(e);let n=!!e.plug?"black":"bg",s=Le/8,i=Le/6,o=Le-.05,a=-Le+.05;this.segments.push(new p([[-s,o],[-s,o-i],[s,o-i],[s,o]],{fill:n,zorder:3})),this.segments.push(new p([[-s,a],[-s,a+i],[s,a+i],[s,a]],{fill:n,zorder:3}))}},Go=class extends N{constructor(e={}){super(e);let n=!!e.plug?"black":"bg";this.segments.push(new D([0,0],Le));let s=Le/6,i=s*3,o=Le/5,a=Le*3/4,l=-Le/2.5,h=s;this.segments.push(new U([[-o/2,a],[-o/2,a-i],[o/2,a-i],[o/2,a]],{fill:n,zorder:3})),this.segments.push(new U([[-h,l],[-h,l-s],[-h-i,l-s],[-h-i,l]],{fill:n,zorder:3})),this.segments.push(new U([[h,l],[h,l-s],[h+i,l-s],[h+i,l]],{fill:n,zorder:3})),this.anchors.hot=[h+i/2,l-s/2],this.anchors.neutral=[-h-i/2,l-s/2],this.anchors.ground=[0,a-i/2],this.elmParams.drop=[h+i/2,l-s/2]}},d0=class extends N{constructor(e={}){super(e);let n=!!e.plug?"black":"bg";this.segments.push(new D([0,0],Le));let s=Le/8,i=s*3,o=-s*2,a=[[-s/2,o],[-s/2,o-i],[s/2,o-i],[s/2,o]],l=a.map(c=>Wr(c,120).toTuple()),h=a.map(c=>Wr(c,-120).toTuple());this.segments.push(new U(a,{fill:n,zorder:3})),this.segments.push(new U(l,{fill:n,zorder:3})),this.segments.push(new U(h,{fill:n,zorder:3})),this.anchors.hot=l[1],this.anchors.neutral=h[2],this.anchors.ground=[0,o-i],this.elmParams.drop=l[1]}},Wo=class extends d0{constructor(e={}){super(e);let t=[.4,.3],n=[-.4,.3],s=this.segments[2];s.verts=s.verts.map(o=>Wr(o,90,t).toTuple());let i=this.segments[3];i.verts=i.verts.map(o=>Wr(o,-90,n).toTuple()),this.anchors.hot=Wr(this.anchors.hot,90,t).toTuple(),this.anchors.neutral=Wr(this.anchors.neutral,-90,n).toTuple()}},Vo=class extends N{constructor(e={}){super(e);let n=!!e.plug?"black":"bg",s=Le*1.5,i=s*2,o=i/5;this.segments.push(new U([[-i/2,0],[-i/2+o,s/2],[i/2-o,s/2],[i/2,0],[i/2-o,-s/2],[-i/2+o,-s/2]]));let a=Le/8;this.segments.push(new D([-i/4,0],a,{fill:n,zorder:3})),this.segments.push(new D([0,-a*2],a,{fill:n,zorder:3})),this.segments.push(new D([i/4,0],a,{fill:n,zorder:3})),this.anchors.hot=[i/4,0],this.anchors.neutral=[-i/4,0],this.anchors.ground=[0,-a*2],this.elmParams.drop=[i/4,0]}},Uo=class extends N{constructor(e={}){super(e);let n=!!e.plug?"black":"bg";this.segments.push(new D([0,0],Le));let s=Le/8,i=Le/2;this.segments.push(new D([-i,0],s,{fill:n,zorder:3})),this.segments.push(new D([i,0],s,{fill:n,zorder:3})),this.anchors.hot=[i,0],this.anchors.neutral=[-i,0],this.elmParams.drop=[i,0];let o=Le/4,a=-Le/2,l=[-o/2,-o/2,o/2,o/2],h=[a,a+o/2,a+o/2,a],c=ze(0,Math.PI);for(let f of c)l.push(o/2*Math.cos(f)),h.push(a-o/2*Math.sin(f));let m=l.map((f,g)=>[f,h[g]]);this.segments.push(new U(m,{fill:n,zorder:3})),this.anchors.ground=[0,a]}},Jo=class extends N{constructor(e={}){super(e);let n=!!e.plug?"black":"bg",s=Le*1.2,i=s*2.25;this.segments.push(new U([[-i/2,s/2],[i/2,s/2],[i/2,-s/2],[-i/2,-s/2]]));let o=Le/8;this.segments.push(new D([-i/4,0],o,{fill:n,zorder:3})),this.segments.push(new D([0,0],o,{fill:n,zorder:3})),this.segments.push(new D([i/4,0],o,{fill:n,zorder:3})),this.anchors.hot=[i/4,0],this.anchors.neutral=[-i/4,0],this.anchors.ground=[0,0],this.elmParams.drop=[i/4,0]}};var Us=0,st=1.75,_a=st/2,oh=20,Gt=st*.4,or=st/9,Ba=st/6,Ca=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{tube_lw:2.5,anode_lw:2,cathode_lw:2,heat_lw:2,grid_lw:2,n_grid_dashes:3,dot_radius:.075,theta:0})}_drawEnvelope(e,t,n="none"){let s=-e,i=t/2,o=-i,a=i,l=[0,-e/2],h=Math.min(t/2,e/2);n==="left"?this.segments.push(new xe(l,t,e,{theta1:90-oh,theta2:270+oh,lw:this.params.tube_lw})):n==="right"?this.segments.push(new xe(l,t,e,{theta1:270-oh,theta2:90+oh,lw:this.params.tube_lw})):this.segments.push(new U([[o,Us],[a,Us],[a,s],[o,s]],{cornerradius:h,lw:this.params.tube_lw})),this.anchors.N=[0,0],this.anchors.S=[0,-e],this.anchors.E=[a,-e/2],this.anchors.W=[o,-e/2];let c=_a/Math.sqrt(2);this.anchors.NE=[c,-_a+c],this.anchors.NW=[-c,-_a+c],this.anchors.SE=[c,-_a-c],this.anchors.SW=[-c,-_a-c],this._labelhints.NE={ofst:[.12,.12],halign:"left"},this._labelhints.NW={ofst:[-.12,.12],halign:"right"},this._labelhints.SE={ofst:[.12,-.12],halign:"left",valign:"top"},this._labelhints.SW={ofst:[-.12,-.12],halign:"right",valign:"top"}}_drawElements(e,t,n,s,i,o,a=""){let l=this.params.dot_radius,h=Us-t/2+Math.max(0,s-1)*or/2,c=h-or*Math.max(0,s-1),m=e-Gt/2,f=e+Gt/2,g=h+or;o==="narrow"?this.segments.push(new p([[e-l,g],[e+l,g]],{lw:this.params.anode_lw})):o==="dot"?(g+=l*2,this.segments.push(new D([e,g-l],l,{lw:this.params.anode_lw}))):o!=="none"&&o!=null&&this.segments.push(new p([[m,g],[f,g]],{lw:this.params.anode_lw})),o!=="none"&&o!=null&&(this.segments.push(new p([[e,Us],[e,g]],{lw:this.params.anode_lw})),this.anchors[`anode${a}`]=[e,Us],this._labelhints[`anode${a}`]={ofst:[.1,.1],halign:"left",valign:"bottom",fontsize:11});let b=this.params.n_grid_dashes,v=Gt/(b+2),x=(Gt-v*(b-1))/b,S=[];for(let _=0;_<b;_++)S.push(m+_*(x+v));for(let _=0;_<s;_++){let B=h-or*_;for(let $=0;$<b;$++)this.segments.push(new p([[S[$],B],[S[$]+x,B]],{lw:this.params.grid_lw}));s===1?(this.anchors[`grid${a}`]=[m-v,B],this.anchors[`grid${a}_R`]=[f+v,B],this._labelhints[`grid${a}`]={ofst:[-n/2-m+.1,.1],halign:"right",valign:"bottom",fontsize:11},this._labelhints[`grid${a}_R`]={ofst:[n/2-f-.1,.1],halign:"left",valign:"bottom",fontsize:11}):(this.anchors[`grid${a}_${_+1}`]=[m-v,B],this.anchors[`grid${a}_${_+1}R`]=[f+v,B],this._labelhints[`grid${a}_${_+1}`]={ofst:[-n/2-m+.1,.1],halign:"right",valign:"bottom",fontsize:11},this._labelhints[`grid${a}_${_+1}R`]={ofst:[n/2-f-.1,.1],halign:"left",valign:"bottom",fontsize:11})}let k=c-or,M=l*2;return i==="cold"?(this.segments.push(new p([[e,k-l*2],[e,-t]])),this.segments.push(new D([e,k-l],l)),this.anchors[`cathode${a}`]=[e,-t],this._labelhints[`cathode${a}`]={ofst:[.1,-.1],halign:"left",valign:"top",fontsize:11}):i!=="none"&&i!=null&&(this.segments.push(new p([[m,k-M],[m,k],[f,k],[f,k-M]],{lw:this.params.cathode_lw})),this.anchors[`cathode${a}`]=[m,k-M],this.anchors[`cathode${a}_R`]=[f,k-M],this._labelhints[`cathode${a}`]={ofst:[-.1,-t-k+M],halign:"right",valign:"top",fontsize:11},this._labelhints[`cathode${a}_R`]={ofst:[.1,-t-k+M],halign:"left",valign:"top",fontsize:11}),k}_drawHeat(e,t){let n=e-or*1.25,s=-Gt/3.5,i=Gt/3.5,o=Us-t-or,a=n-Math.sqrt(2)*i;this.segments.push(new p([[s,o],[s,a],[0,n],[i,a],[i,o]],{lw:this.params.heat_lw})),this.anchors.heat1=[s,o],this.anchors.heat2=[i,o],this._labelhints.heat1={ofst:[-.1,0],halign:"right",valign:"bottom",fontsize:11},this._labelhints.heat2={ofst:[.1,0],halign:"left",valign:"bottom",fontsize:11}}},Gr=class extends Ca{constructor(e={}){let{cathode:t="heated",anodetype:n="plate",grids:s=1,heater:i=!0,split:o="none",...a}=e;super(a);let l=Math.max(st,st+(s-4)*or);this._drawEnvelope(l,st,o);let h=this._drawElements(0,l,st,s,t,n);i&&this._drawHeat(h,l)}},Ko=class extends Ca{constructor(e={}){let{cathode:t="heated",anodetype:n="plate",grids_left:s=1,grids_right:i=1,heater:o=!0,...a}=e;super(a);let l=Math.max(s,i),h=Math.max(st,st+(l-4)*or),c=st*1.5,m=-c*.2,f=c*.2;this._drawEnvelope(h,c);let g=this._drawElements(m,h,c,s,t,n,"A"),b=this._drawElements(f,h,c,i,t,n,"B");o&&this._drawHeat(Math.min(g,b),h)}},Zo=class extends Ca{constructor(e={}){let{anodes:t=3,cathode:n="T",anodetype:s="narrow",grid:i=!1,...o}=e;super(o);let a=st,l=Math.max(st,(t-1)*Ba+st);this._drawEnvelope(a,l),i&&this._drawNixieGrid(t,l),this._drawNixieAnodes(t,s),this._drawNixieCathode(t,n)}_drawNixieAnodes(e,t){let n=-st/4,i=-((e-1)*Ba)/2,o=this.params.dot_radius;for(let a=0;a<e;a++){let l=i+a*Ba;t==="dot"?this.segments.push(new D([l,n-o],o,{lw:this.params.anode_lw})):this.segments.push(new p([[l-o,n],[l+o,n]],{lw:this.params.anode_lw})),this.segments.push(new p([[l,Us],[l,n]],{lw:this.params.anode_lw})),this.anchors[`anode${a}`]=[l,Us],this._labelhints[`anode${a}`]={ofst:[-.1,.1],halign:"right",valign:"bottom",fontsize:11}}}_drawNixieGrid(e,t){let n=(e-1)*Ba,s=-n/2,i=e+1,o=n/(i+2),a=(n-o*(i-1))/i,l=[];for(let c=0;c<i;c++)l.push(s+c*(a+o));let h=-st/2;for(let c=0;c<i;c++)this.segments.push(new p([[l[c],h],[l[c]+a,h]],{lw:this.params.grid_lw}));this.anchors.grid=[s-o,h],this.anchors.grid_R=[s+n+o,h],this._labelhints.grid={ofst:[-t/2-s,.1],halign:"right",valign:"bottom",fontsize:11},this._labelhints.grid_R={ofst:[t/2-n/2,.1],halign:"left",valign:"bottom",fontsize:11}}_drawNixieCathode(e,t){let n=this.params.dot_radius,s=-3*st/4,i=n,o=(e-1)*Ba;t==="cold"?(this.segments.push(new p([[0,s-n*2],[0,-st]],{lw:this.params.cathode_lw})),this.segments.push(new D([0,s-n],n)),this.anchors.cathode=[0,-st]):t==="heated"?(this.segments.push(new p([[-Gt/2,s-i],[-Gt/2,s],[Gt/2,s],[Gt/2,s-i]],{lw:this.params.cathode_lw})),this.anchors.cathode=[-Gt/2,s-i],this.anchors.cathode_R=[Gt/2,s-i]):t!=="none"&&t!=null&&(this.segments.push(new p([[0,-st],[0,s],H,[-o/2,s],[o/2,s]],{lw:this.params.cathode_lw})),this.anchors.cathode=[0,-st])}},Qo=class extends Gr{constructor(e={}){let{heater:t=!1,split:n="none",...s}=e;super({cathode:"heated",grids:0,heater:t,split:n,...s})}},ea=class extends Gr{constructor(e={}){let{heater:t=!1,split:n="none",...s}=e;super({cathode:"heated",grids:1,heater:t,split:n,...s}),this.anchors.control=this.anchors.grid,this.anchors.control_R=this.anchors.grid_R,this._labelhints.control=this._labelhints.grid,this._labelhints.control_R=this._labelhints.grid_R}},ta=class extends Gr{constructor(e={}){let{heater:t=!1,split:n="none",...s}=e;super({cathode:"heated",grids:2,heater:t,split:n,...s}),this.anchors.screen=this.anchors.grid_1,this.anchors.screen_R=this.anchors.grid_1R,this.anchors.control=this.anchors.grid_2,this.anchors.control_R=this.anchors.grid_2R,this._labelhints.screen=this._labelhints.grid_1,this._labelhints.screen_R=this._labelhints.grid_1R,this._labelhints.control=this._labelhints.grid_2,this._labelhints.control_R=this._labelhints.grid_2R}},ra=class extends Gr{constructor(e={}){let{strap:t=!1,heater:n=!1,split:s="none",...i}=e;if(super({cathode:"heated",grids:3,heater:n,split:s,...i}),this.anchors.suppressor=this.anchors.grid_1,this.anchors.suppressor_R=this.anchors.grid_1R,this.anchors.screen=this.anchors.grid_2,this.anchors.screen_R=this.anchors.grid_2R,this.anchors.control=this.anchors.grid_3,this.anchors.control_R=this.anchors.grid_3R,this._labelhints.suppressor=this._labelhints.grid_1,this._labelhints.suppressor_R=this._labelhints.grid_1R,this._labelhints.screen=this._labelhints.grid_2,this._labelhints.screen_R=this._labelhints.grid_2R,this._labelhints.control=this._labelhints.grid_3,this._labelhints.control_R=this._labelhints.grid_3R,t){let o=this.params.dot_radius,a=this.anchors.cathode_R,l=[a[0],a[1]+o*2],h=this.anchors.suppressor_R,c=[Gt/2,h[1]],m=[l[0]+or*.75,l[1]+or/2],f=[m[0],c[1]-or/2];this.segments.push(new p([l,m,f,c],{lw:this.params.cathode_lw}))}}};var Js={ResistorIEEE:r=>new dt(r??{}),ResistorIEC:r=>new mt(r??{}),ResistorVarIEEE:r=>new cr(r??{}),ResistorVarIEC:r=>new Zt(r??{}),Thermistor:r=>new Jn(r??{}),PhotoresistorIEEE:r=>new ur(r??{}),PhotoresistorIEC:r=>new Qt(r??{}),Rshunt:r=>new Kn(r??{}),PotentiometerIEEE:r=>new mr(r??{}),PotentiometerIEC:r=>new er(r??{}),FuseIEEE:r=>new dr(r??{}),FuseIEC:r=>new Dr(r??{}),Resistor:r=>new Zn(r??{}),ResistorVar:r=>new Qn(r??{}),Photoresistor:r=>new ts(r??{}),Potentiometer:r=>new es(r??{}),Fuse:r=>new rs(r??{}),Memristor:r=>new ns(r??{}),Memristor2:r=>new ss(r??{}),Josephson:r=>new is(r??{}),FuseUS:r=>new os(r??{}),Breaker:r=>new as(r??{}),CPE:r=>new ls(r??{}),SparkGap:r=>new hs(r??{}),Nullator:r=>new Nr(r??{}),Norator:r=>new Or(r??{}),CurrentMirror:r=>new Fr(r??{}),VoltageMirror:r=>new $r(r??{}),Capacitor:r=>new Cr(r??{}),Capacitor2:r=>new Cn(r??{}),CapacitorVar:r=>new In(r??{}),CapacitorTrim:r=>new Ln(r??{}),Diode:r=>new et(r??{}),Schottky:r=>new Dn(r??{}),Zener:r=>new Nn(r??{}),DiodeTunnel:r=>new On(r??{}),DiodeTVS:r=>new Fn(r??{}),DiodeShockley:r=>new $n(r??{}),Varactor:r=>new jn(r??{}),LED:r=>new qn(r??{}),LED2:r=>new Hn(r??{}),Photodiode:r=>new Yn(r??{}),SCR:r=>new Xn(r??{}),Diac:r=>new on(r??{}),Triac:r=>new Gn(r??{}),Inductor:r=>new Ir(r??{}),Inductor2:r=>new Lr(r??{}),Crystal:r=>new Un(r??{}),Opamp:r=>new cs(r??{}),AnalogBiasedFet:r=>new j0(r??{}),AnalogNFet:r=>new F0(r??{}),AnalogPFet:r=>new $0(r??{}),Bjt:r=>new qr(r??{}),Bjt2:r=>new Hr(r??{}),BjtNpn:r=>new Ht(r??{}),BjtNpn2:r=>new Ss(r??{}),BjtPnp:r=>new rr(r??{}),BjtPnp2:r=>new ln(r??{}),BjtPnp2c:r=>new W0(r??{}),BjtPnp2c2:r=>new ei(r??{}),Hemt:r=>new G0(r??{}),IgbtN:r=>new Z0(r??{}),IgbtP:r=>new Q0(r??{}),JFet:r=>new vs(r??{}),JFet2:r=>new ys(r??{}),JFetN:r=>new q0(r??{}),JFetN2:r=>new Y0(r??{}),JFetP:r=>new H0(r??{}),JFetP2:r=>new X0(r??{}),NFet:r=>new gs(r??{}),NFet2:r=>new ws(r??{}),NMos:r=>new ms(r??{}),NMos2:r=>new ps(r??{}),NpnPhoto:r=>new J0(r??{}),NpnSchottky:r=>new V0(r??{}),PFet:r=>new bs(r??{}),PFet2:r=>new xs(r??{}),PMos:r=>new ds(r??{}),PMos2:r=>new fs(r??{}),PnpPhoto:r=>new K0(r??{}),PnpSchottky:r=>new U0(r??{}),DFlipFlop:r=>new ri(r??{}),Ic:r=>new nr(r??{}),Ic555:r=>new ii(r??{}),IcDIP:r=>new ai(r??{}),JKFlipFlop:r=>new ni(r??{}),Multiplexer:r=>new ti(r??{}),SevenSegment:r=>new oi(r??{}),VoltageRegulator:r=>new si(r??{}),Source:r=>new rt(r??{}),SourceV:r=>new Ri(r??{}),SourceI:r=>new Ai(r??{}),SourceSin:r=>new _i(r??{}),SourcePulse:r=>new Bi(r??{}),SourceSquare:r=>new Li(r??{}),SourceTriangle:r=>new Ci(r??{}),SourceRamp:r=>new Ii(r??{}),SourceControlled:r=>new Ys(r??{}),SourceControlledV:r=>new br(r??{}),SourceControlledI:r=>new wr(r??{}),BatteryCell:r=>new Di(r??{}),Battery:r=>new Ni(r??{}),BatteryDouble:r=>new Oi(r??{}),Solar:r=>new Fi(r??{}),MeterV:r=>new $i(r??{}),MeterI:r=>new ji(r??{}),MeterA:r=>new qi(r??{}),MeterOhm:r=>new Hi(r??{}),MeterArrow:r=>new Yi(r??{}),Lamp:r=>new Xi(r??{}),Lamp2:r=>new Gi(r??{}),Neon:r=>new Wi(r??{}),MeterBox:r=>new mn(r??{}),MeterAnalog:r=>new Vi(r??{}),Oscilloscope:r=>new Ui(r??{}),MeterDigital:r=>new Ji(r??{}),GroundSignal:r=>new Ki(r??{}),GroundChassis:r=>new Zi(r??{}),Antenna:r=>new Qi(r??{}),AntennaLoop:r=>new eo(r??{}),AntennaLoop2:r=>new to(r??{}),Vss:r=>new ro(r??{}),Vdd:r=>new no(r??{}),NoConnect:r=>new so(r??{}),Switch:r=>new Xr(r??{}),SwitchSpdt:r=>new io(r??{}),SwitchSpdt2:r=>new Xs(r??{}),SwitchDpst:r=>new Gs(r??{}),SwitchDpdt:r=>new Ws(r??{}),Button:r=>new oo(r??{}),SwitchReed:r=>new ao(r??{}),SwitchRotary:r=>new lo(r??{}),SwitchDIP:r=>new ho(r??{}),Speaker:r=>new co(r??{}),Mic:r=>new uo(r??{}),Motor:r=>new mo(r??{}),AudioJack:r=>new po(r??{}),Coax:r=>new fo(r??{}),Triax:r=>new go(r??{}),Transformer:r=>new bo(r??{}),Line:r=>new Pe(r??{}),Ground:r=>new Ti(r??{}),Arrow:r=>new dn(r??{}),DataBusLine:r=>new wo(r??{}),Dot:r=>new pn(r??{}),DotDotDot:r=>new vo(r??{}),Gap:r=>new Xt(r??{}),Arrowhead:r=>new xo(r??{}),Label:r=>new So(r??{}),Rect:r=>new xr(r??{}),Tag:r=>new ko(r??{}),Wire:r=>new yo(r??{}),Annotate:r=>new zo(r??{}),Arc2:r=>new Mo(r??{}),Arc3:r=>new fn(r??{}),ArcLoop:r=>new To(r??{}),ArcN:r=>new Po(r??{}),ArcZ:r=>new Eo(r??{}),CurrentLabel:r=>new h0(r??{}),CurrentLabelInline:r=>{let{direction:e,ofst:t,start:n,...s}=r??{};return new gn(e,t,n,s)},LoopArrow:r=>new c0(r??{}),VoltageLabelArc:r=>new Ro(r??{}),ZLabel:r=>new Ao(r??{}),Optocoupler:r=>new _o(r??{}),Rectifier:r=>new Bo(r??{}),Relay:r=>new Io(r??{}),Wheatstone:r=>new Co(r??{}),TwoPort:r=>new Lo(r??{}),VoltageTransactor:r=>new Do(r??{}),TransimpedanceTransactor:r=>new No(r??{}),CurrentTransactor:r=>new Oo(r??{}),TransadmittanceTransactor:r=>new Fo(r??{}),Nullor:r=>new $o(r??{}),VMCMPair:r=>new jo(r??{}),OrthoLines:r=>new di(r??{}),RightLines:r=>new Hs(r??{}),Header:r=>new pi(r??{}),Jumper:r=>new fi(r??{}),BusConnect:r=>new gi(r??{}),BusLine:r=>new bi(r??{}),DB25:r=>new xi(r??{}),DE9:r=>new a0(r??{}),DB9:r=>new wi(r??{}),DA15:r=>new vi(r??{}),DC37:r=>new yi(r??{}),DD50:r=>new Si(r??{}),CoaxConnect:r=>new ki(r??{}),Plug:r=>new Mi(r??{}),Jack:r=>new zi(r??{}),ConnectorTerminal:r=>new Ei(r??{}),OutletA:r=>new u0(r??{}),OutletB:r=>new qo(r??{}),OutletC:r=>new m0(r??{}),OutletD:r=>new Ho(r??{}),OutletE:r=>new Yo(r??{}),OutletF:r=>new Xo(r??{}),OutletG:r=>new Go(r??{}),OutletH:r=>new d0(r??{}),OutletI:r=>new Wo(r??{}),OutletJ:r=>new Vo(r??{}),OutletK:r=>new Uo(r??{}),OutletL:r=>new Jo(r??{}),VacuumTube:r=>new Gr(r??{}),DualVacuumTube:r=>new Ko(r??{}),NixieTube:r=>new Zo(r??{}),TubeDiode:r=>new Qo(r??{}),Triode:r=>new ea(r??{}),Tetrode:r=>new ta(r??{}),Pentode:r=>new ra(r??{}),ElementImage:r=>{let{image:e,width:t,height:n,...s}=r??{};return new js(e,t,n,s)},And:r=>new Bt(r??{}),Or:r=>new $t(r??{}),Buf:r=>new Jt(r??{}),Not:r=>new Kt(r??{}),Tristate:r=>new Bn(r??{}),Kmap:r=>new A0(r??{}),BitField:r=>new s0(r??{}),NotNot:r=>new C0(r??{}),Schmitt:r=>new L0(r??{}),SchmittAnd:r=>new o0(r??{}),SchmittNand:r=>Yl(r),SchmittNot:r=>new D0(r??{}),Table:r=>new B0(r),Tgate:r=>new I0(r??{}),TimingDiagram:r=>new n0(r??{}),FlowBox:r=>new cn(r??{}),RoundBox:r=>new Yr(r??{}),Terminal:r=>new hn(r??{}),RoundProcess:r=>new li(r??{}),Process:r=>new hi(r??{}),Start:r=>new ci(r??{}),Subroutine:r=>new ks(r??{}),Data:r=>new Ms(r??{}),Ellipse:r=>new zs(r??{}),Decision:r=>new Es(r??{}),Connect:r=>new pr(r??{}),Circle:r=>new ui(r??{}),State:r=>new mi(r??{}),StateEnd:r=>new Ps(r??{}),DspBox:r=>new sr(r??{}),DspCircle:r=>new Yt(r??{}),Sum:r=>new Ts(r??{}),SumSigma:r=>new Rs(r??{}),Mixer:r=>new As(r??{}),DspSpeaker:r=>new _s(r??{}),Amp:r=>new un(r??{}),OscillatorBox:r=>new Bs(r??{}),Oscillator:r=>new Cs(r??{}),Filter:r=>new Is(r??{}),Adc:r=>new Ls(r??{}),Dac:r=>new Ds(r??{}),Demod:r=>new Ns(r??{}),Circulator:r=>new Os(r??{}),Isolator:r=>new Fs(r??{}),VGA:r=>new $s(r??{}),RBox:r=>new mt(r??{}),RBoxVar:r=>new Zt(r??{}),PotBox:r=>new er(r??{}),PhotoresistorBox:r=>new Qt(r??{}),Nand:r=>Tn(r),Nor:r=>Rn(r),Xor:r=>An(r),Xnor:r=>_n(r)};function eu(){return Object.keys(Js).sort()}var N1=eu;function O1(r){let e=Js[r];if(!e)throw new Error(`Unknown element type "${r}". Use getAvailableTypes() to see all available types.`);let t=e();return new lr().add(t),Object.keys(t.absanchors).sort()}function tu(r,e){let t=r.indexOf(".");if(t<0)throw new Error(`Invalid anchor reference "${r}". Expected format "elementId.anchorName"`);let n=r.slice(0,t),s=r.slice(t+1),i=e.get(n);if(!i){let a=[...e.keys()].join(", ")||"(none)";throw new Error(`Element "${n}" not found. Available elements: ${a}`)}let o=i.absanchors[s];if(!o){let a=Object.keys(i.absanchors).join(", ")||"(none)";throw new Error(`Anchor "${s}" not found on element "${n}". Available anchors: ${a}`)}return o.toTuple()}function Ia(r,e){return Array.isArray(r)?r:tu(r,e)}function ah(r,e){return typeof r=="number"?r:tu(r,e)}function lh(r,e){return typeof r=="number"?r:tu(r,e)}var yr={light:{bg:"#ffffff",stroke:"#000000",fill:"none",text:"#000000",font:"sans-serif",lw:2},dark:{bg:"#1a1a2e",stroke:"#c8d6e5",fill:"none",text:"#dfe6e9",font:"sans-serif",lw:2},print:{bg:"#ffffff",stroke:"#333333",fill:"none",text:"#333333",font:"serif",lw:1.5}},Ks={bg:"--circuit-bg",stroke:"--circuit-stroke",fill:"--circuit-fill",text:"--circuit-text",font:"--circuit-font",lw:"--circuit-lw"};function C2(){if(typeof getComputedStyle>"u")return{...yr.light};let r=getComputedStyle(document.documentElement),e=t=>r.getPropertyValue(t).trim();return{bg:e(Ks.bg)||"transparent",stroke:e(Ks.stroke)||yr.light.stroke,fill:e(Ks.fill)||"none",text:e(Ks.text)||yr.light.text,font:e(Ks.font)||yr.light.font,lw:parseFloat(e(Ks.lw))||yr.light.lw}}function Zs(r){if(r===void 0)return{...yr.light};if(typeof r=="string"){if(r==="auto")return C2();let e=yr[r];if(!e)throw new Error(`Unknown theme "${r}". Available: ${Object.keys(yr).join(", ")}, auto`);return{...e}}return{...yr.light,...r}}var F1={bg:"bgcolor",stroke:"color",fill:"fill",font:"font",lw:"lw"};function $1(r,e){let t={};for(let n of Object.keys(F1)){let s=F1[n];s&&(t[s]=r[n])}return{...t,...e}}function hh(r,e){let t=typeof r=="string"?JSON.parse(r):r,n=e?.theme??t.theme,s=n!==void 0?$1(Zs(n),t.drawing):{...t.drawing??{}},i=e?.colorTransition??t.drawing?.colorTransition??!1,o={...s,...e?.interactive?{interactive:!0}:{},...i?{colorTransition:!0}:{}},a=new lr(o),l=new Map;for(let h of t.elements){if(h==="push"){a.push();continue}if(h==="pop"){a.pop();continue}let c=Js[h.type];if(!c)throw new Error(`Unknown element type "${h.type}". Use getAvailableTypes() to see all available types.`);let m=c(h.params);if(h.d)switch(h.d){case"up":m.up();break;case"down":m.down();break;case"left":m.left();break;case"right":m.right();break}if(h.theta!==void 0&&m.theta(h.theta),h.at!==void 0&&m.at(Ia(h.at,l)),h.anchor&&m.anchor(h.anchor),h.flip&&m.flip(),h.reverse&&m.reverse(),h.scale!==void 0&&m.scale(h.scale),m instanceof se&&(h.to!==void 0&&m.to(Ia(h.to,l)),h.tox!==void 0&&m.tox(ah(h.tox,l)),h.toy!==void 0&&m.toy(lh(h.toy,l)),h.l!==void 0&&m.length(h.l),h.dot&&m.dot(h.dot==="open"),h.idot&&m.idot(h.idot==="open")),h.label)if(typeof h.label=="string")m.label(h.label);else{let{text:f,...g}=h.label;m.label(f,g)}if(h.labels)for(let f of h.labels){let{text:g,...b}=f;m.label(g,b)}h.color&&m.color(h.color),h.fill&&m.fill(h.fill),h.lw!==void 0&&m.linewidth(h.lw),h.ls&&m.linestyle(h.ls),a.add(m),h.id&&(l.set(h.id,m),e?.interactive&&a.setElementMeta(m,{id:h.id,type:h.type,tooltip:h.tooltip??`${h.id} \u2014 ${h.type}`}))}return a.toSvgString()}function j1(r){let e=[],t;if(typeof r=="string")try{t=JSON.parse(r)}catch(i){return{valid:!1,errors:[{path:"",message:`Invalid JSON: ${i.message}`}]}}else t=r;if(!t.elements||!Array.isArray(t.elements))return e.push({path:"elements",message:'"elements" must be an array'}),{valid:!1,errors:e};let n=new Set,s=0;for(let i=0;i<t.elements.length;i++){let o=t.elements[i],a=`elements[${i}]`;if(typeof o=="string"){o==="push"?s++:o==="pop"?(s--,s<0&&(e.push({path:a,message:'"pop" without matching "push"'}),s=0)):e.push({path:a,message:`Invalid control instruction "${o}". Expected "push" or "pop"`});continue}if(typeof o!="object"||o===null){e.push({path:a,message:'Element must be an object or "push"/"pop" string'});continue}let l=o;if(!l.type||typeof l.type!="string"){e.push({path:`${a}.type`,message:'"type" is required and must be a string'});continue}Js[l.type]||e.push({path:`${a}.type`,message:`Unknown element type "${l.type}"`}),l.d&&!["up","down","left","right"].includes(l.d)&&e.push({path:`${a}.d`,message:`Invalid direction "${l.d}". Expected "up", "down", "left", or "right"`});for(let h of["at","to","tox","toy"]){let c=l[h];if(typeof c=="string"&&c.includes(".")){let m=c.slice(0,c.indexOf("."));n.has(m)||e.push({path:`${a}.${h}`,message:`Element "${m}" referenced before definition`})}else typeof c=="string"&&!c.includes(".")&&e.push({path:`${a}.${h}`,message:`Invalid anchor reference "${c}". Expected format "elementId.anchorName"`})}l.id&&n.add(l.id)}return s>0&&e.push({path:"elements",message:`${s} unmatched "push" without "pop"`}),{valid:e.length===0,errors:e}}var na="data-sd-original-style",ru="path,polyline,polygon,circle,ellipse,line";function I2(r){r.hasAttribute(na)||r.setAttribute(na,r.getAttribute("style")??"")}function q1(r){let e=r.getAttribute(na);e!==null?(r.setAttribute("style",e),r.removeAttribute(na)):r.style.removeProperty("stroke")}var La=class{constructor(e,t,n){z(this,"_container");z(this,"_json");z(this,"_opts");z(this,"_svg");z(this,"_elementMap",new Map);z(this,"_listeners",new Map);z(this,"_selectedId",null);z(this,"_theme");z(this,"_destroyed",!1);z(this,"_tooltipEl",null);z(this,"_autoObserver",null);z(this,"_mediaQuery",null);z(this,"_mediaHandler",null);z(this,"_boundClick");z(this,"_boundMouseover");z(this,"_boundMouseout");z(this,"_boundContextmenu");z(this,"_boundMousemove");this._container=e,this._json=t,this._opts={...n,interactive:!0},this._theme=Zs(n.theme??this._json.theme),this._boundClick=this._onClick.bind(this),this._boundMouseover=this._onMouseover.bind(this),this._boundMouseout=this._onMouseout.bind(this),this._boundContextmenu=this._onContextmenu.bind(this),this._boundMousemove=this._onMousemove.bind(this),this._render(),this._bindEvents(),this._initTooltip(),this._initAutoTheme()}_isAutoTheme(){return(this._opts.theme??this._json.theme)==="auto"}_initAutoTheme(){if(!this._isAutoTheme())return;let e=()=>{this._destroyed||(this._theme=Zs("auto"),this._unbindEvents(),this._render(),this._bindEvents(),this._selectedId=null)};this._autoObserver=new MutationObserver(e),this._autoObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-theme","data-color-mode","style"]}),typeof matchMedia<"u"&&(this._mediaQuery=matchMedia("(prefers-color-scheme: dark)"),this._mediaHandler=e,this._mediaQuery.addEventListener("change",this._mediaHandler))}_teardownAutoTheme(){this._autoObserver&&(this._autoObserver.disconnect(),this._autoObserver=null),this._mediaQuery&&this._mediaHandler&&(this._mediaQuery.removeEventListener("change",this._mediaHandler),this._mediaQuery=null,this._mediaHandler=null)}_render(){let e=hh(this._json,this._opts);this._container.innerHTML=e;let t=this._container.querySelector("svg");if(!t)throw new Error("Failed to render SVG from circuit JSON.");this._svg=t,this._svg.querySelectorAll("g.sd-el > title").forEach(o=>o.remove()),this._elementMap.clear();let n=this._svg.querySelectorAll("g.sd-el[data-id]"),s=new Map;for(let o of this._json.elements)o!=="push"&&o!=="pop"&&o.id&&s.set(o.id,o);let i="http://www.w3.org/2000/svg";n.forEach(o=>{let a=o.getAttribute("data-id"),l=o.getAttribute("data-type")??"",h=o.getAttribute("data-tooltip")??void 0,c=o.getBBox(),m=document.createElementNS(i,"rect");m.setAttribute("x",String(c.x)),m.setAttribute("y",String(c.y)),m.setAttribute("width",String(c.width)),m.setAttribute("height",String(c.height)),m.setAttribute("fill","transparent"),m.setAttribute("stroke","none"),o.prepend(m);let f=s.get(a)??{type:l,id:a};this._elementMap.set(a,{info:{id:a,type:l,tooltip:h,bbox:{x:c.x,y:c.y,width:c.width,height:c.height},anchors:{},element:o,spec:f},spec:f})})}_initTooltip(){let e=document.createElement("div");e.className="schemdraw-tooltip",e.style.cssText="position:fixed;z-index:99999;pointer-events:none;opacity:0;transition:opacity .15s ease;font-size:12px;line-height:1.4;padding:6px 12px;border-radius:6px;max-width:260px;white-space:pre-wrap;",this._applyTooltipTheme(e),document.body.appendChild(e),this._tooltipEl=e}_applyTooltipTheme(e){document.documentElement.classList.contains("dark")||document.documentElement.getAttribute("data-theme")==="dark"||typeof window<"u"&&window.matchMedia?.("(prefers-color-scheme: dark)").matches&&!document.documentElement.classList.contains("light")?(e.style.background="rgba(250,250,250,.95)",e.style.color="#1a1a1a",e.style.boxShadow="0 2px 12px rgba(0,0,0,.4)"):(e.style.background="rgba(15,15,15,.92)",e.style.color="#fff",e.style.boxShadow="0 2px 8px rgba(0,0,0,.2)")}_showTooltip(e,t,n){let s=this._tooltipEl;if(!s)return;this._applyTooltipTheme(s),s.textContent=e,s.style.opacity="1";let i=10,o=window.innerWidth,a=window.innerHeight;s.style.left="0",s.style.top="0";let l=s.getBoundingClientRect(),h=t+i,c=n+i;h+l.width>o&&(h=t-l.width-i),c+l.height>a&&(c=n-l.height-i),s.style.left=`${h}px`,s.style.top=`${c}px`}_hideTooltip(){this._tooltipEl&&(this._tooltipEl.style.opacity="0")}_bindEvents(){this._svg.addEventListener("click",this._boundClick),this._svg.addEventListener("mouseover",this._boundMouseover),this._svg.addEventListener("mouseout",this._boundMouseout),this._svg.addEventListener("mousemove",this._boundMousemove),this._svg.addEventListener("contextmenu",this._boundContextmenu)}_unbindEvents(){this._svg.removeEventListener("click",this._boundClick),this._svg.removeEventListener("mouseover",this._boundMouseover),this._svg.removeEventListener("mouseout",this._boundMouseout),this._svg.removeEventListener("mousemove",this._boundMousemove),this._svg.removeEventListener("contextmenu",this._boundContextmenu)}_closestGroup(e){let t=e.target;return t?t.closest("g.sd-el[data-id]"):null}_svgPoint(e){let t=this._svg.getScreenCTM();if(t){let n=t.inverse();return{x:n.a*e.clientX+n.c*e.clientY+n.e,y:n.b*e.clientX+n.d*e.clientY+n.f,clientX:e.clientX,clientY:e.clientY}}return{x:e.offsetX,y:e.offsetY,clientX:e.clientX,clientY:e.clientY}}_getInfoForGroup(e){let t=e.getAttribute("data-id");if(t)return this._elementMap.get(t)?.info}_onClick(e){let t=this._closestGroup(e);if(t){let n=this._getInfoForGroup(t);if(n){this._emit("element:click",n,e);let s=this._selectedId;this._selectedId=n.id,s&&s!==n.id&&this._clearSelectedClass(s),t.classList.add("sd-selected"),this._emit("element:select",n,e)}}else this._selectedId&&(this._clearSelectedClass(this._selectedId),this._selectedId=null,this._emit("element:select",null,e)),this._emit("canvas:click",this._svgPoint(e),e)}_onMouseover(e){let t=this._closestGroup(e);if(!t)return;let n=e.relatedTarget;if(n&&t.contains(n))return;let s=this._getInfoForGroup(t);s&&(this._emit("element:hover",s,e),s.tooltip&&this._showTooltip(s.tooltip,e.clientX,e.clientY))}_onMousemove(e){let t=this._closestGroup(e);if(t){let n=t.getAttribute("data-tooltip");n&&this._showTooltip(n,e.clientX,e.clientY)}else this._hideTooltip()}_onMouseout(e){let t=this._closestGroup(e);if(!t)return;let n=e.relatedTarget;if(n&&t.contains(n))return;let s=this._getInfoForGroup(t);s&&(this._emit("element:leave",s,e),this._hideTooltip())}_onContextmenu(e){this._emit("canvas:contextmenu",this._svgPoint(e),e)}_clearSelectedClass(e){let t=this._elementMap.get(e);t&&(t.info.element.classList.remove("sd-selected"),t.info.element.style.removeProperty("--sd-highlight"),t.info.element.querySelectorAll(ru).forEach(n=>{let s=n;s.hasAttribute(na)&&q1(s)}))}_emit(e,...t){let n=this._listeners.get(e);if(n)for(let s of n)try{s(...t)}catch{}}on(e,t){return this._listeners.has(e)||this._listeners.set(e,new Set),this._listeners.get(e).add(t),this}off(e,t){return t?this._listeners.get(e)?.delete(t):this._listeners.delete(e),this}highlight(e,t){let n=this._elementMap.get(e);n&&(n.info.element.classList.add("sd-selected"),t&&(n.info.element.style.setProperty("--sd-highlight",t),n.info.element.querySelectorAll(ru).forEach(s=>{let i=s;I2(i),i.style.setProperty("stroke",t)})))}clearHighlight(){this._svg.querySelectorAll("g.sd-selected").forEach(t=>{t.classList.remove("sd-selected"),t.style.removeProperty("--sd-highlight"),t.querySelectorAll(ru).forEach(n=>{let s=n;s.hasAttribute(na)&&q1(s)})}),this._selectedId=null}setTheme(e){this._teardownAutoTheme(),this._opts={...this._opts,theme:e},this._theme=Zs(e),this.update(this._json),this._initAutoTheme()}update(e){let t=typeof e=="string"?JSON.parse(e):e;this._json=t,this._unbindEvents(),this._render(),this._bindEvents(),this._selectedId=null}destroy(){this._destroyed||(this._destroyed=!0,this._unbindEvents(),this._teardownAutoTheme(),this._tooltipEl&&(this._tooltipEl.remove(),this._tooltipEl=null),this._container.innerHTML="",this._elementMap.clear(),this._listeners.clear())}get svgElement(){return this._svg}getElementInfo(e){return this._elementMap.get(e)?.info}getAllElements(){return[...this._elementMap.values()].map(e=>e.info)}getDrawingInfo(){let e=this._svg.getAttribute("viewBox")??"",t=this._svg.width.baseVal.value||parseFloat(this._svg.getAttribute("width")??"0"),n=this._svg.height.baseVal.value||parseFloat(this._svg.getAttribute("height")??"0");return{width:t,height:n,viewBox:e,theme:this._theme,elementCount:this._json.elements.filter(s=>s!=="push"&&s!=="pop").length,namedElementCount:this._elementMap.size}}};function H1(r,e,t){if(typeof document>"u")throw new Error("mountFromJson requires a browser environment with DOM access.");let n=typeof e=="string"?JSON.parse(e):e;return new La(r,n,t??{})}return nd(L2);})();
|
|
272
|
+
`),h="";for(let L of l)L.includes("---")?h+="|":L.includes("===")?h+="\u01C1":h+="l";let{justs:c,bars:m}=p1(h),f=L=>L.replace(/^\|?\s*|\s*\|?$/g,""),g=l.filter(L=>!L.includes("---")&&!L.includes("===")),b=f(g[0]).split("|").length,v=e.colfmt;(v==null||v==="")&&(v="c".repeat(b));let{justs:x,bars:S}=p1(v),k=x.length,M=c.length;if(f(g[0]).split("|").length!==k)throw new Error("Number of columns in table does not match colfmt string.");let _=new Array(k).fill(0),B=new Array(M).fill(0);for(let L=0;L<g.length;L++){let I=f(g[L]).split("|").map(X=>X.trim());for(let X=0;X<I.length;X++){let{width:j,height:re}=b0(I[X],n,s);_[X]=Math.max(_[X],j/72*2+a),B[L]=Math.max(B[L],re/72*2+o)}}let $=B.reduce((L,I)=>L+I,0),Y=_.reduce((L,I)=>L+I,0),Z=(L,I)=>L.slice(0,I).reduce((X,j)=>X+j,0);for(let L=0;L<S.length;L++){let I=Z(_,L);S[L]==="|"?this.segments.push(new p([[I,0],[I,-$]],{lw:1})):S[L]==="\u01C1"&&(this.segments.push(new p([[I-i,0],[I-i,-$]],{lw:1})),this.segments.push(new p([[I+i,0],[I+i,-$]],{lw:1})))}for(let L=0;L<m.length;L++){let I=-Z(B,L);m[L]==="|"?this.segments.push(new p([[0,I],[Y,I]],{lw:1})):m[L]==="\u01C1"&&(this.segments.push(new p([[0,I-i],[Y,I-i]],{lw:1})),this.segments.push(new p([[0,I+i],[Y,I+i]],{lw:1})))}for(let L=0;L<g.length;L++){let I=f(g[L]).split("|").map(X=>X.trim());for(let X=0;X<I.length;X++){let j=Z(_,X),re=-Z(B,L)-B[L],te={c:"center",l:"left",r:"right"}[x[X]]??"center";te==="center"?j+=_[X]/2:te==="right"?j+=_[X]-a/2:j+=a/2,this.segments.push(new W([j,re+o/3],I[X],{fontfamily:s,fontsize:n,align:[te,"bottom"]})),this.anchors[`cell${L}_${X}`]=[j,re+B[L]/2]}}}},C0=class extends se{constructor(e={}){super(e),this.segments.push(new p([[-sn*2,0],H,[lt+sn*2,0]])),this.segments.push(new p([[0,i0/2],[lt,0],[0,-i0/2],[0,i0/2]])),this.segments.push(new D([lt+sn,0],sn)),this.segments.push(new D([lt+sn,0],sn)),this.segments.push(new D([-sn,0],sn)),this.anchors.out=[lt+sn*2,0],this.anchors.in1=[0,0]}},I0=class extends se{constructor(e={}){super(e),this.segments.push(new p([[0,0],H,[lt,0]])),this.segments.push(new p([[0,0],[0,-i0/2],[lt,0],[0,i0/2],[0,0]])),this.segments.push(new p([[lt,0],[lt,-i0/2],[0,0],[lt,i0/2],[lt,0]])),this.segments.push(new D([lt/2,.28+.08],.08)),this.segments.push(new p([[lt/2,.28+.16],[lt/2,.7]])),this.segments.push(new p([[lt/2,-.28],[lt/2,-.7]])),this.anchors.out=[lt,0],this.anchors.in1=[0,0],this.anchors.c=[lt/2,-.7],this.anchors.cbar=[lt/2,.7]}},_c=(r=0)=>new p([[r+.07,-.15],[r+.25,-.15],[r+.25,.15],H,[r+.33,.15],[r+.15,.15],[r+.15,-.15]],{lw:1}),L0=class extends Jt{constructor(e={}){super(e),this.segments.push(_c())}},D0=class extends Kt{constructor(e={}){super(e),this.segments.push(_c())}},o0=class extends Bt{constructor(e={}){super(e);let n=T(this.params,"leadin",.35)+lt/2;this.segments.push(_c(n))}};function Yl(r){return new o0({...r,nand:!0})}var F=.25,Ye=.16666666666666666;var Cr=class extends se{constructor(e={}){super(e),Object.assign(this.defaults,{polar:!1});let t=.18;this.segments.push(new p([[0,0],H,[0,.25],[0,-.25],H,[t,.25],[t,-.25],H,[t,0]])),T(this.params,"polar",!1)&&this.segments.push(new W([-t*1.2,t],"+"))}},Cn=class extends se{constructor(e={}){super(e),Object.assign(this.defaults,{polar:!1});let t=.18;this.segments.push(new p([[0,0],H,[0,.25],[0,-.25],H,[t,0]])),this.segments.push(new xe([t*1.5,0],t*1.5,.25*2.5,{theta1:105,theta2:-105})),T(this.params,"polar",!1)&&this.segments.push(new W([-t*1.2,t],"+"))}},In=class extends Cr{constructor(e={}){super(e),Object.assign(this.defaults,{arrowwidth:.16,arrowlength:.2});let t=Ye,n=.25,s=T(this.params,"arrowwidth",.16),i=T(this.params,"arrowlength",.2),o=T(this.params,"arrow_lw",void 0),a=T(this.params,"arrow_color",void 0);this.segments.push(new p([[-2*t,-n],[3*t,t*2]],{arrow:"->",arrowwidth:s,arrowlength:i,lw:o,color:a}))}},Ln=class extends Cr{constructor(e={}){super(e),Object.assign(this.defaults,{trim_lw:void 0,trim_color:void 0});let t=.18,n=Ye,s=.25,i=[-1.8*n,-s],o=[1.8*n+t,s],a=o[0]-i[0],l=o[1]-i[1],h=.14,c=Math.atan2(l,a)+Math.PI/2,m=[o[0]+h*Math.cos(c),o[1]+h*Math.sin(c)],f=[o[0]+h*Math.cos(c-Math.PI),o[1]+h*Math.sin(c-Math.PI)],g=T(this.params,"trim_lw",void 0),b=T(this.params,"trim_color",void 0);this.segments.push(new p([i,o],{lw:g,color:b})),this.segments.push(new p([m,f],{lw:g,color:b}))}};var et=class extends se{constructor(e={}){super(e);let t=.25*1.4;this.segments.push(new p([[0,0],H,[t,.25],[t,-.25],H,[t,0]])),this.segments.push(new U([[0,.25],[t,0],[0,-.25]],{closed:!0,fill:!1}))}},Dn=class extends et{constructor(e={}){super(e);let t=.25*1.4,n=.1;this.segments.push(new p([[t,.25],[t-n,.25],[t-n,.25-n]])),this.segments.push(new p([[t,-.25],[t+n,-.25],[t+n,-.25+n]]))}},Nn=class extends et{constructor(e={}){super(e);let t=.25*1.4,n=.1;this.segments.push(new p([[t,.25],[t+n,.25+n]])),this.segments.push(new p([[t,-.25],[t-n,-.25-n]]))}};var On=class extends et{constructor(e={}){super(e);let t=.25*1.4,n=.1;this.segments.push(new p([[t,.25],[t-n,.25]])),this.segments.push(new p([[t,-.25],[t-n,-.25]]))}},Fn=class extends se{constructor(e={}){super(e);let t=.25*1.4,n=.1;this.segments.push(new p([[0,0],H,[2*t,0]])),this.segments.push(new U([[0,.25],[t,0],[0,-.25]],{closed:!0,fill:!1})),this.segments.push(new U([[t,0],[t*2,.25],[t*2,-.25]],{closed:!0,fill:!1})),this.segments.push(new p([[t+n,.25],[t,.25],[t,-.25],[t-n,-.25]]))}},$n=class extends se{constructor(e={}){super(e);let t=.25*1.4;this.segments.push(new p([[0,0],[t,0],[t,.25],[t,-.25],H,[t,0]])),this.segments.push(new p([[0,-.25],[0,.25],[t,0]]))}},jn=class extends se{constructor(e={}){super(e);let t=.13,n=.25*1.4;this.segments.push(new p([[0,0],H,[n,.25],[n,-.25],H,[n+t,.25],[n+t,-.25],H,[n+t,0]])),this.segments.push(new U([[0,.25],[n,0],[0,-.25]],{closed:!0,fill:!1}))}},qn=class extends et{constructor(e={}){super(e),Object.assign(this.defaults,{arrowwidth:.16,arrowlength:.2});let t=.25,n=T(this.params,"arrowwidth",.16),s=T(this.params,"arrowlength",.2),i=T(this.params,"arrow_color",void 0);this.segments.push(new p([[t,t*1.5],[t*2,t*3.25]],{arrow:"->",arrowwidth:n,arrowlength:s,color:i})),this.segments.push(new p([[t*.1,t*1.5],[t*1.1,t*3.25]],{arrow:"->",arrowwidth:n,arrowlength:s,color:i})),this.elmParams.lblloc="bot"}},Hn=class extends et{constructor(e={}){super(e),Object.assign(this.defaults,{arrowwidth:.16,arrowlength:.2});let t=.25,n=T(this.params,"arrowwidth",.16),s=T(this.params,"arrowlength",.2),i=T(this.params,"arrow_color",void 0),o=T(this.params,"arrow_lw",void 0),a=ze(-1,1),l=a.map(v=>-v*(v-.7)*(v+.7)/2+t*2.5),h=ze(t*.75,t*1.25,a.length),c=20,m=h.map((v,x)=>{let S=A.fromXY([v,l[x]]).rotate(c,[0,0]);return[S.x,S.y]}),f=h.map((v,x)=>{let S=A.fromXY([v-.2,l[x]]).rotate(c,[0,0]);return[S.x,S.y]});this.segments.push(new p(m,{lw:o,color:i})),this.segments.push(new p(f,{lw:o,color:i}));let g=A.fromXY([h[0],l[0]+.1]).rotate(c,[0,0]),b=A.fromXY([h[0]-.2,l[0]+.1]).rotate(c,[0,0]);this.segments.push(new p([[m[1][0],m[1][1]],[g.x,g.y]],{arrow:"->",arrowwidth:n,arrowlength:s,color:i})),this.segments.push(new p([[f[1][0],f[1][1]],[b.x,b.y]],{arrow:"->",arrowwidth:n,arrowlength:s,color:i})),this.elmParams.lblloc="bot"}},Yn=class extends et{constructor(e={}){super(e),Object.assign(this.defaults,{arrowwidth:.16,arrowlength:.2});let t=.25,n=T(this.params,"arrowwidth",.16),s=T(this.params,"arrowlength",.2),i=T(this.params,"arrow_color",void 0),o=T(this.params,"arrow_lw",void 0),a=ze(-1,1),l=a.map(x=>-x*(x-.7)*(x+.7)/2+t*2.5),h=ze(t*.75,t*1.25,a.length),c=20,m=h.map((x,S)=>{let k=A.fromXY([x,l[S]]).rotate(c,[0,0]);return[k.x,k.y]}),f=h.map((x,S)=>{let k=A.fromXY([x-.2,l[S]]).rotate(c,[0,0]);return[k.x,k.y]});this.segments.push(new p(m,{lw:o,color:i})),this.segments.push(new p(f,{lw:o,color:i}));let g=A.fromXY([h[h.length-1],l[l.length-1]-.1]).rotate(c,[0,0]),b=A.fromXY([h[h.length-1]-.2,l[l.length-1]-.1]).rotate(c,[0,0]),v=m.length;this.segments.push(new p([[m[v-2][0],m[v-2][1]],[g.x,g.y]],{arrow:"->",arrowwidth:n,arrowlength:s,color:i})),this.segments.push(new p([[f[v-2][0],f[v-2][1]],[b.x,b.y]],{arrow:"->",arrowwidth:n,arrowlength:s,color:i})),this.elmParams.lblloc="bot"}},Xn=class extends et{constructor(e={}){super(e);let t=.25*1.4;this.segments.push(new p([[t,0],[t+.3,-.3],[t+.3,-.5]])),this.anchors.gate=[t+.3,-.5]}},on=class extends se{constructor(e={}){super(e);let t=.25*1.4;this.segments.push(new p([[0,0],H,[t,.25*1.8],[t,-.25*1.8],H,[0,.25*1.8],[0,-.25*1.8],H,[t,0]])),this.segments.push(new U([[0,-.25-.25],[t,-.25],[0,-.25+.25]],{closed:!0,fill:!1})),this.segments.push(new U([[t,.25+.25],[0,.25],[t,.25-.25]],{closed:!0,fill:!1}))}},Gn=class extends on{constructor(e={}){super(e);let t=.25*1.4;this.segments.push(new p([[t,.25],[t+.5,.5]])),this.anchors.gate=[t+.5,.5]}};var Wn=.25;function Vn(r=4,e=[0,0],t=.06,n=.19,s=!0,i=!1,o=!1){let a=Math.acos(t/n),l=ze(a,2*(r+1)*Math.PI-a,r*50),h=l.map(x=>t*x-n*Math.sin(x)),c=l.map(x=>t-n*Math.cos(x)),m=h[0];if(h=h.map(x=>x-m),s){let x=h[h.length-1]-h[0];x!==0&&(h=h.map(S=>S/x))}o&&(c=c.map(x=>-x));let g=Math.max(...c)-Math.min(...c);c=c.map(x=>x*g/.25);let b=h,v=c;return i&&(b=c,v=h),b.map((x,S)=>[x+e[0],v[S]+e[1]])}var Ir=class extends se{constructor(e={}){super(e),Object.assign(this.defaults,{core:0});let t=T(this.params,"core",0),n=T(this.params,"core_ls",void 0),s=T(this.params,"core_lw",void 0),i=T(this.params,"core_color",void 0);this.segments.push(new p([[0,0],H,[1,0]]));for(let a=0;a<4;a++)this.segments.push(new xe([(a*2+1)*Wn/2,0],Wn,Wn,{theta1:0,theta2:180}));let o=.12;if(t>0)for(let a=0;a<t;a++){let l=Wn+o*a,h={};n!==void 0&&(h.ls=n),s!==void 0&&(h.lw=s),i!==void 0&&(h.color=i),this.segments.push(new p([[0,l],[1,l]],h))}this.anchors.NE=[1,Wn+o],this.anchors.NW=[0,Wn+o],this.anchors.SE=[1,-Wn],this.anchors.SW=[0,-Wn]}},Lr=class extends se{constructor(e={}){super(e),Object.assign(this.defaults,{loops:4,core:0});let t=T(this.params,"loops",4),n=T(this.params,"core",0),s=T(this.params,"core_ls",void 0),i=T(this.params,"core_lw",void 0),o=T(this.params,"core_color",void 0);this.segments.push(new p(Vn(t)));let a=.12,l=.5;if(n>0)for(let h=0;h<n;h++){let c=l+a*h,m={};s!==void 0&&(m.ls=s),i!==void 0&&(m.lw=i),o!==void 0&&(m.color=o),this.segments.push(new p([[0,c],[1,c]],m))}this.anchors.NE=[1,l+a],this.anchors.NW=[0,l+a],this.anchors.SE=[1,-l],this.anchors.SW=[0,-l]}};var Un=class extends se{constructor(e={}){super(e);let t=.2,n=.25;this.segments.push(new p([[0,0],H,[0,n],[0,-n],H,[t/2,n],[t/2,-n],[t*1.5,-n],[t*1.5,n],[t/2,n],H,[t*2,n],[t*2,-n],H,[t*2,0]]))}};var dt=class extends se{constructor(e={}){super(e);let t=Ye,n=.25;this.segments.push(new p([[0,0],[.5*t,n],[1.5*t,-n],[2.5*t,n],[3.5*t,-n],[4.5*t,n],[5.5*t,-n],[6*t,0]]))}};var mt=class extends se{constructor(e={}){super(e);let t=Ye,n=.25;this.segments.push(new p([[0,0],[0,n],[t*6,n],[t*6,-n],[0,-n],[0,0],H,[t*6,0]]))}},cr=class extends dt{constructor(e={}){super(e),Object.assign(this.defaults,{arrowwidth:.16,arrowlength:.2});let t=Ye,n=.25,s=T(this.params,"arrowwidth",.16),i=T(this.params,"arrowlength",.2),o=T(this.params,"arrow_lw",void 0),a=T(this.params,"arrow_color",void 0);this.segments.push(new p([[1.5*t,-n*2],[4.5*t,t*3.5]],{arrow:"->",arrowwidth:s,arrowlength:i,lw:o,color:a}))}},Zt=class extends mt{constructor(e={}){super(e),Object.assign(this.defaults,{arrowwidth:.16,arrowlength:.2});let t=Ye,n=.25,s=T(this.params,"arrowwidth",.16),i=T(this.params,"arrowlength",.2),o=T(this.params,"arrow_lw",void 0),a=T(this.params,"arrow_color",void 0);this.segments.push(new p([[1*t,-n*2],[5*t,t*3.5]],{arrow:"->",arrowwidth:s,arrowlength:i,lw:o,color:a}))}},Jn=class extends mt{constructor(e={}){super(e),this.segments.push(new p([[0,-.25-.2],[.2,-.25-.2],[1,.25+.2]]))}},ur=class extends dt{constructor(e={}){super(e),Object.assign(this.defaults,{arrowwidth:.16,arrowlength:.2});let t=T(this.params,"arrowwidth",.16),n=T(this.params,"arrowlength",.2),s=T(this.params,"arrow_lw",void 0),i=T(this.params,"arrow_color",void 0);this.segments.push(new p([[.7,.75],[.4,.4]],{arrow:"->",arrowwidth:t,arrowlength:n,lw:s,color:i})),this.segments.push(new p([[1,.75],[.7,.4]],{arrow:"->",arrowwidth:t,arrowlength:n,lw:s,color:i}))}},Qt=class extends mt{constructor(e={}){super(e),Object.assign(this.defaults,{arrowwidth:.16,arrowlength:.2});let t=T(this.params,"arrowwidth",.16),n=T(this.params,"arrowlength",.2),s=T(this.params,"arrow_lw",void 0),i=T(this.params,"arrow_color",void 0);this.segments.push(new p([[.7,.75],[.4,.4]],{arrow:"->",arrowwidth:t,arrowlength:n,lw:s,color:i})),this.segments.push(new p([[1,.75],[.7,.4]],{arrow:"->",arrowwidth:t,arrowlength:n,lw:s,color:i}))}},Kn=class extends mt{constructor(e={}){super(e);let t=Ye,n=.25;this.segments.push(new p([[0,0],[-n*1.5,-n],[-n*1.5,-n*2]])),this.segments.push(new p([[t*6,0],[t*6+n*1.5,-n],[t*6+n*1.5,-n*2]])),this.anchors.v1=[-n*1.5,-n*2],this.anchors.v2=[t*6+n*1.5,-n*2]}},mr=class extends dt{constructor(e={}){super(e),Object.assign(this.defaults,{arrowwidth:.15,arrowlength:.25,tap_length:.72});let t=Ye,n=T(this.params,"tap_length",.72),s=T(this.params,"arrowwidth",.15),i=T(this.params,"arrowlength",.25);this.anchors.tap=[t*3,n],this.elmParams.lblloc="bot",this.segments.push(new p([[t*3,n],[t*3,t*1.5]],{arrow:"->",arrowwidth:s,arrowlength:i}))}},er=class extends mt{constructor(e={}){super(e),Object.assign(this.defaults,{arrowwidth:.15,arrowlength:.25,tap_length:.72});let t=Ye,n=T(this.params,"tap_length",.72),s=T(this.params,"arrowwidth",.15),i=T(this.params,"arrowlength",.25);this.anchors.tap=[t*3,n],this.elmParams.lblloc="bot",this.segments.push(new p([[t*3,n],[t*3,t*1.5]],{arrow:"->",arrowwidth:s,arrowlength:i}))}},dr=class extends mt{constructor(e={}){super(e);let t=Ye;this.segments.push(new p([[0,0],[t*6,0]]))}},Dr=class extends mt{constructor(e={}){super(e);let t=Ye,n=.25,s=n*.66;this.segments.push(new p([[s,n],[s,-n]])),this.segments.push(new p([[6*t-s,n],[6*t-s,-n]]))}};var an={Resistor:dt,ResistorVar:cr,Potentiometer:mr,Photoresistor:ur,Fuse:dr},Xl={Resistor:mt,ResistorVar:Zt,Potentiometer:er,Photoresistor:Qt,Fuse:Dr},Zn=dt,Qn=cr,es=mr,ts=ur,rs=dr;function Gl(r){r.Resistor!==void 0&&(Zn=r.Resistor),r.ResistorVar!==void 0&&(Qn=r.ResistorVar),r.Potentiometer!==void 0&&(es=r.Potentiometer),r.Photoresistor!==void 0&&(ts=r.Photoresistor),r.Fuse!==void 0&&(rs=r.Fuse)}function Wl(){Zn=an.Resistor,Qn=an.ResistorVar,es=an.Potentiometer,ts=an.Photoresistor,rs=an.Fuse}var ns=class extends se{constructor(e={}){super(e);let t=.2;this.segments.push(new p([[0,0],[t,0],[t,-t*.75],[t*2,-t*.75],[t*2,t*.75],[t*3,t*.75],[t*3,-t*.75],[t*4,-t*.75],[t*4,0],[t*5,0]])),this.segments.push(new p([[0,t*1.25],[t*5,t*1.25],[t*5,t*-1.25],[0,t*-1.25],[0,t*1.25]])),this.segments.push(new U([[0,t*1.25],[0,-t*1.25],[t/2,-t*1.25],[t/2,t*1.25]],{closed:!0,fill:"black"}))}},ss=class extends se{constructor(e={}){super(e);let t=.2,n=.25;this.segments.push(new p([[0,0],[0,n],[t,n],[t,-n],[t*2,-n],[t*2,n],[t*3,n],[t*3,-n],[t*4,-n],[t*4,n],[t*5,n],[t*5,-n],[t*6,-n],[t*6,0],[t*7,0]]))}},is=class extends se{constructor(e={}){super(e),Object.assign(this.defaults,{box:!1});let t=.25;T(this.params,"box",!1)?(this.segments.push(new p([[-t,0],H,[t,0]])),this.segments.push(new p([[-t,t],[t,-t],H,[t,t],[-t,-t]])),this.segments.push(new U([[-t,t],[-t,-t],[t,-t],[t,t]],{closed:!0,fill:!1}))):this.segments.push(new p([[0,0],H,[-t,t],[t,-t],H,[t,t],[-t,-t],H,[0,0]]))}},os=class extends se{constructor(e={}){super(e),Object.assign(this.defaults,{dots:!0,dot_r:.12});let t=T(this.params,"dot_r",.12),n=50,s=ze(t*2,1+t,n),o=ze(0,2*Math.PI,n).map(l=>Math.sin(l)*.25),a=s.map((l,h)=>[l,o[h]]);this.segments.push(new p(a)),this.segments.push(new p([[0,0],H,[1+t*3,0]])),T(this.params,"dots",!0)&&(this.segments.push(new D([t,0],t,{zorder:4,fill:"bg"})),this.segments.push(new D([t*2+1,0],t,{zorder:4,fill:"bg"})))}},as=class extends se{constructor(e={}){super(e),Object.assign(this.defaults,{dots:!0,dot_r:.12});let t=e.dots,n=T(this.params,"dots",!0),s=t?25:10,i=t?155:170,o=T(this.params,"arc_lw",void 0),a=T(this.params,"arc_color",void 0);if(this.segments.push(new p([[0,0],H,[1,0]])),this.segments.push(new xe([.5,0],1,.65,{theta1:s,theta2:i,lw:o,color:a})),n){let l=T(this.params,"dot_r",.12);this.segments.push(new D([l,0],l,{zorder:4})),this.segments.push(new D([1-l,0],l,{zorder:4}))}}},ls=class extends se{constructor(e={}){super(e);let t=.25,n=.25,s=.25;this.segments.push(new p([[0,0],[-n,0],H,[n,0],[0,-s],H,[t,0]])),this.segments.push(new p([[0,0],[-n,0],H,[n,0],[0,s],H,[t,0]])),this.segments.push(new p([[0,0],[-n,s],H,[0,-s],H,[t,0]])),this.segments.push(new p([[0,0],[-n,-s],H,[0,-s],H,[t,0]]))}},hs=class extends se{constructor(e={}){super(e),Object.assign(this.defaults,{gap:.08,arrowwidth:.25,arrowlength:.25});let t=T(this.params,"gap",.08),n=T(this.params,"arrowwidth",.25),s=T(this.params,"arrowlength",.25);this.segments.push(new p([[0,0],H,[1,0]])),this.segments.push(new p([[0,0],[.5-t/2,0]],{arrow:"->",arrowwidth:n,arrowlength:s})),this.segments.push(new p([[1,0],[.5+t/2,0]],{arrow:"->",arrowwidth:n,arrowlength:s}))}},Nr=class extends se{constructor(e={}){super(e),this.segments.push(new p([[0,0],[0,0],H,[1,0],[1,0]])),this.segments.push(new xe([.5,0],1,.5,{theta1:0,theta2:360})),this.elmParams.theta=90}},Or=class extends se{constructor(e={}){super(e),this.segments.push(new p([[0,0],[0,0],H,[1,0],[1,0]])),this.segments.push(new D([.25,0],.25)),this.segments.push(new D([1-.25,0],.25)),this.elmParams.theta=90}},Fr=class extends se{constructor(e={}){super(e),this.segments.push(new p([[0,0],[0,0],H,[1,0],[1,0]])),this.segments.push(new D([.3,0],.3,{lw:1e-9,ls:"None"})),this.segments.push(new D([1-.3,0],.3,{lw:1e-9,ls:"None"})),this.segments.push(new D([.3,0],.3,{fill:!1})),this.segments.push(new D([1-.3,0],.3,{fill:!1})),this.elmParams.theta=90,this.anchors.common=[.5,Math.sqrt(.3**2-.2**2)]}},$r=class extends se{constructor(e={}){super(e),this.segments.push(new p([[0,0],[0,0],H,[1,0],[1,0]])),this.segments.push(new xe([.7,0],.6,.3,{theta1:0,theta2:360})),this.segments.push(new xe([.3,0],.6,.3,{theta1:0,theta2:360})),this.elmParams.theta=90,this.anchors.common=[.5,Math.sqrt(1-.2**2/.3**2)*.15]}};var wt=2.5,jt=wt*Math.sqrt(3)/2,N0=jt/8,O0=.2,cs=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{sign:!0,leads:!1});let t=T(this.params,"leads",!1),n=T(this.params,"sign",!0),s=wt/4,i=t?s:0;this.segments.push(new p([[i,0],[i,wt/2],[i+jt,0],[i,-wt/2],[i,0],H,[i+jt,0]])),n&&(this.segments.push(new p([[i+N0-O0/2,wt/4],[i+N0+O0/2,wt/4]])),this.segments.push(new p([[i+N0-O0/2,-wt/4],[i+N0+O0/2,-wt/4]])),this.segments.push(new p([[i+N0,-wt/4-O0/2],[i+N0,-wt/4+O0/2]]))),t&&(this.segments.push(new p([[0,wt/4],[s,wt/4]])),this.segments.push(new p([[0,-wt/4],[s,-wt/4]])),this.segments.push(new p([[s+jt,0],[jt+2*s,0]])));let o=jt+2*i;this.anchors.out=[o,0],this.anchors.in1=[0,wt/4],this.anchors.in2=[0,-wt/4],this.anchors.center=[i+jt/2,0],this.anchors.vd=[i+jt/3,.84],this.anchors.vs=[i+jt/3,-.84],this.anchors.n1=[i+jt*2/3,-.42],this.anchors.n2=[i+jt*2/3,.42],this.anchors.n1a=[i+jt*.9,-.13],this.anchors.n2a=[i+jt*.9,.13],this.elmParams.drop=[o,0],Object.assign(this._labelhints,{in1:{ofst:[-.1,.1],halign:"right",valign:"bottom",fontsize:9},in2:{ofst:[-.1,.1],halign:"right",valign:"bottom",fontsize:9},out:{ofst:[0,.1],halign:"left",valign:"bottom",fontsize:9},vd:{ofst:[-.1,.25],halign:"right",valign:"bottom",fontsize:9},vs:{ofst:[-.1,-.25],halign:"right",valign:"top",fontsize:9},n1:{ofst:[-.1,-.25],halign:"right",valign:"top",fontsize:9},n1a:{ofst:[-.1,-.3],halign:"right",valign:"top",fontsize:9},n2:{ofst:[-.1,.25],halign:"right",valign:"bottom",fontsize:9},n2a:{ofst:[-.1,.3],halign:"right",valign:"bottom",fontsize:9}})}};var C=Ye*.5;function g1(r,e,t,n,s){r.push(new p([[-3*C,-6.5*C],[-3*C,-7.5*C]])),r.push(new p([[-3*C,-9.5*C],[-3*C,-10.5*C]])),r.push(new p([[-3*C,-12.5*C],[-3*C,-13.5*C]])),r.push(new p([[0,-7*C],[0,0]])),r.push(new p([[-3*C,-7*C],[0,-7*C]])),r.push(new p([[0,-20*C],[0,-13*C]])),r.push(new p([[-3*C,-13*C],[0,-13*C]]));let i={};return e==="nmos"?(r.push(new p([[-10*C,-14*C],[-5*C,-14*C]])),r.push(new p([[-5*C,-14*C],[-5*C,-6*C]])),r.push(new p([[-3*C,-10*C],[0,-10*C]],{arrow:"<-",arrowwidth:2*C,arrowlength:2*C})),r.push(new p([[0,-10*C],[0,-13*C]])),i.drain=[0,0],i.gate=[-10*C,-14*C],i.center=[0,-10*C],i.source=[0,-20*C]):(r.push(new p([[-10*C,-6*C],[-5*C,-6*C]])),r.push(new p([[-5*C,-6*C],[-5*C,-14*C]])),r.push(new p([[-3*C,-10*C],[0,-10*C]],{arrow:"->",arrowwidth:2*C,arrowlength:2*C})),r.push(new p([[0,-10*C],[0,-7*C]])),i.source=[0,0],i.gate=[-10*C,-6*C],i.center=[0,-10*C],i.drain=[0,-20*C]),t&&(r.push(new p([[0,-7*C],[3*C,-7*C]])),r.push(new p([[3*C,-7*C],[3*C,-9*C]])),r.push(new p([[2*C,-9*C],[4*C,-9*C]])),r.push(new U([[3*C,-9*C],[2*C,-11*C],[4*C,-11*C]],{closed:!0,fill:!1})),r.push(new p([[3*C,-11*C],[3*C,-13*C]])),r.push(new p([[3*C,-13*C],[0,-13*C]]))),n&&r.push(new D([-1*C,-10*C],7*C,{lw:s})),i}var ms=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{diode:!1,circle:!1});let t=T(this.params,"diode",!1),n=T(this.params,"circle",!1),s=T(this.params,"circle_lw",void 0),i=g1(this.segments,"nmos",t,n,s);Object.assign(this.anchors,i),this.elmParams.drop=[0,-20*C],this.elmParams.lblloc="rgt"}},ds=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{diode:!1,circle:!1});let t=T(this.params,"diode",!1),n=T(this.params,"circle",!1),s=T(this.params,"circle_lw",void 0),i=g1(this.segments,"pmos",t,n,s);Object.assign(this.anchors,i),this.elmParams.drop=[0,-20*C],this.elmParams.lblloc="rgt"}};function b1(r,e,t,n,s){r.push(new p([[0,0],[7*C,0],[7*C,-3*C],H,[13*C,-3*C],[13*C,0],[20*C,0]])),r.push(new p([[6.5*C,-3*C],[7.5*C,-3*C]])),r.push(new p([[9.5*C,-3*C],[10.5*C,-3*C]])),r.push(new p([[12.5*C,-3*C],[13.5*C,-3*C]]));let i={};return e==="nmos"?(r.push(new p([[14*C,-10*C],[14*C,-5*C]])),r.push(new p([[14*C,-5*C],[6*C,-5*C]])),r.push(new p([[10*C,-3*C],[10*C,0]],{arrow:"<-",arrowwidth:2*C,arrowlength:2*C})),r.push(new p([[10*C,0],[13*C,0]])),i.drain=[0,0],i.gate=[14*C,-10*C],i.source=[20*C,0]):(r.push(new p([[6*C,-10*C],[6*C,-5*C]])),r.push(new p([[6*C,-5*C],[14*C,-5*C]])),r.push(new p([[10*C,-3*C],[10*C,0]],{arrow:"->",arrowwidth:2*C,arrowlength:2*C})),r.push(new p([[10*C,0],[7*C,0]])),i.source=[0,0],i.gate=[6*C,-10*C],i.drain=[20*C,0]),i.center=[10*C,0],t&&(r.push(new p([[7*C,0],[7*C,3*C]])),r.push(new p([[7*C,3*C],[9*C,3*C]])),r.push(new p([[9*C,2*C],[9*C,4*C]])),r.push(new U([[9*C,3*C],[11*C,2*C],[11*C,4*C]],{closed:!0,fill:!1})),r.push(new p([[11*C,3*C],[13*C,3*C]])),r.push(new p([[13*C,3*C],[13*C,0]]))),n&&r.push(new D([10*C,-1*C],7*C,{lw:s})),i}var ps=class extends se{constructor(e={}){super(e),Object.assign(this.defaults,{diode:!1,circle:!1});let t=T(this.params,"diode",!1),n=T(this.params,"circle",!1),s=T(this.params,"circle_lw",void 0),i=b1(this.segments,"nmos",t,n,s);Object.assign(this.anchors,i),this.elmParams.drop=[20*C,0],this.elmParams.lblloc="bottom"}},fs=class extends se{constructor(e={}){super(e),Object.assign(this.defaults,{diode:!1,circle:!1});let t=T(this.params,"diode",!1),n=T(this.params,"circle",!1),s=T(this.params,"circle_lw",void 0),i=b1(this.segments,"pmos",t,n,s);Object.assign(this.anchors,i),this.elmParams.drop=[20*C,0],this.elmParams.lblloc="bottom"}},q=Ye*4,m2=Ye*5,O=m2/2,tt=Ye,Xe=Ye*.7,gs=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{bulk:!1,arrowlength:.25,arrowwidth:.2}),this.segments.push(new p([[0,0],[0,-O],[q,-O],[q,-O-q],[0,-O-q],[0,-2*O-q]])),this.segments.push(new p([[q+tt,-O],[q+tt,-O-q]])),this.segments.push(new p([[q+tt,-O-q/2],[q+tt+O+Xe,-O-q/2]])),this.anchors.source=[0,-2*O-q],this.anchors.drain=[0,0],this.anchors.gate=[q+tt+O+Xe,-O-q/2],this.anchors.center=[0,-O-q/2],this.elmParams.drop=[0,-2*O-q],this.elmParams.lblloc="lft",T(this.params,"bulk",!1)&&(this.segments.push(new p([[0,-O-q/2],[q,-O-q/2]],{arrow:"->",arrowwidth:T(this.params,"arrowwidth",.2),arrowlength:T(this.params,"arrowlength",.25)})),this.anchors.bulk=[0,-O-q/2])}},bs=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{bulk:!1,arrowlength:.25,arrowwidth:.2}),this.segments.push(new p([[0,0],[0,-O],[q,-O],[q,-O-q],[0,-O-q],[0,-2*O-q]])),this.segments.push(new p([[q+tt,-O],[q+tt,-O-q]])),this.segments.push(new p([[q+tt+Xe*2,-O-q/2],[q+tt+O+Xe,-O-q/2]])),this.segments.push(new D([q+tt+Xe,-O-q/2],Xe)),this.anchors.source=[0,0],this.anchors.drain=[0,-2*O-q],this.anchors.gate=[q+tt+O+Xe,-O-q/2],this.anchors.center=[0,-O-q/2],this.elmParams.drop=[0,-2*O-q],this.elmParams.lblloc="lft",T(this.params,"bulk",!1)&&(this.segments.push(new p([[0,-O-q/2],[q,-O-q/2]],{arrow:"->",arrowwidth:T(this.params,"arrowwidth",.2),arrowlength:T(this.params,"arrowlength",.25)})),this.anchors.bulk=[0,-O-q/2])}},ws=class extends se{constructor(e={}){super(e),Object.assign(this.defaults,{bulk:!1,arrowlength:.25,arrowwidth:.2}),this.segments.push(new p([[0,0],[O,0],[O,q],[O+q,q],[O+q,0],[2*O+q,0]])),this.segments.push(new p([[O,q+tt],[O+q,q+tt]])),this.segments.push(new p([[O+q/2,q+tt],[O+q/2,q+tt+Xe+O]])),this.anchors.isource=[2*O+q,0],this.anchors.idrain=[0,0],this.anchors.gate=[O+q/2,q+tt+Xe+O],this.elmParams.lblloc="bottom",T(this.params,"bulk",!1)&&(this.segments.push(new p([[O+q/2,0],[O+q/2,q]],{arrow:"->",arrowwidth:T(this.params,"arrowwidth",.2),arrowlength:T(this.params,"arrowlength",.25)})),this.anchors.bulk=[O+q/2,0])}placeAnchors(e,t){super.placeAnchors(e,t),this.anchors.source=this.anchors.end,this.anchors.drain=this.anchors.start,T(this.params,"reverse",!1)&&(this.anchors.source=this.anchors.start,this.anchors.drain=this.anchors.end)}},xs=class extends se{constructor(e={}){super(e),Object.assign(this.defaults,{bulk:!1,arrowlength:.25,arrowwidth:.2}),this.segments.push(new p([[0,0],[O,0],[O,q],[O+q,q],[O+q,0],[2*O+q,0]])),this.segments.push(new p([[O,q+tt],[O+q,q+tt]])),this.segments.push(new D([O+q/2,q+tt+Xe],Xe)),this.segments.push(new p([[O+q/2,q+tt+Xe*2],[O+q/2,q+tt+Xe+O]])),this.anchors.isource=[2*O+q,0],this.anchors.idrain=[0,0],this.anchors.gate=[O+q/2,q+tt+Xe+O],this.elmParams.lblloc="bottom",T(this.params,"bulk",!1)&&(this.segments.push(new p([[O+q/2,0],[O+q/2,q]],{arrow:"->",arrowwidth:T(this.params,"arrowwidth",.2),arrowlength:T(this.params,"arrowlength",.25)})),this.anchors.bulk=[O+q/2,0])}placeAnchors(e,t){super.placeAnchors(e,t),this.anchors.source=this.anchors.end,this.anchors.drain=this.anchors.start,T(this.params,"reverse",!1)&&(this.anchors.source=this.anchors.start,this.anchors.drain=this.anchors.end)}},Re=Ye*2.5,me=Re*2,ne=me*.5,Ve=Re*.2,yt=me*.1,Vl=yt*.75,us=.25,F0=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{bulk:!1,offset_gate:!0,arrow:!0});let t=T(this.params,"bulk",!1),n=T(this.params,"offset_gate",!0),i=T(this.params,"arrow",!0)&&!t;this.segments.push(new p([[0,0],[0,-ne],[Re,-ne],[Re,-ne-me],[0,-ne-me],[0,-2*ne-me]])),i&&this.segments.push(new p([[Re,-ne-me],[0,-ne-me]],{arrow:"->",arrowwidth:us,arrowlength:us})),this.segments.push(new p([[Re+Ve,-ne-yt],[Re+Ve,-ne-me+yt]])),n?(this.segments.push(new p([[Re+Ve,-ne-me+yt],[Re+Ve+ne,-ne-me+yt]])),this.anchors.gate=[Re+Ve+ne,-ne-me+yt]):(this.segments.push(new p([[Re+Ve,-ne-me/2],[Re+Ve+ne,-ne-me/2]])),this.anchors.gate=[Re+Ve+ne,-ne-me/2]),this.anchors.source=[0,-2*ne-me],this.anchors.drain=[0,0],this.anchors.center=[0,-ne-me/2],this.elmParams.drop=[0,-2*ne-me],this.elmParams.lblloc="lft",t&&(this.segments.push(new p([[0,-ne-me/2],[Re,-ne-me/2]],{arrow:"->",arrowwidth:us,arrowlength:us})),this.anchors.bulk=[0,-ne-me/2])}},$0=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{bulk:!1,offset_gate:!0,arrow:!0});let t=T(this.params,"bulk",!1),n=T(this.params,"offset_gate",!0),i=T(this.params,"arrow",!0)&&!t;this.segments.push(new p([[0,0],[0,-ne],[Re,-ne],[Re,-ne-me],[0,-ne-me],[0,-2*ne-me]])),i&&this.segments.push(new p([[0,-ne],[Re,-ne]],{arrow:"->",arrowwidth:us,arrowlength:us})),this.segments.push(new p([[Re+Ve,-ne-yt],[Re+Ve,-ne-me+yt]])),n?(this.segments.push(new p([[Re+Ve,-ne-yt],[Re+Ve+ne,-ne-yt]])),this.anchors.gate=[Re+Ve+ne,-ne-yt]):(this.segments.push(new p([[Re+Ve,-ne-me/2],[Re+Ve+ne,-ne-me/2]])),this.anchors.gate=[Re+Ve+ne,-ne-me/2]),this.anchors.source=[0,0],this.anchors.drain=[0,-2*ne-me],this.anchors.center=[0,-ne-me/2],this.elmParams.drop=[0,-2*ne-me],this.elmParams.lblloc="lft",t&&(this.segments.push(new p([[Re,-ne-me/2],[0,-ne-me/2]],{arrow:"->",arrowwidth:us,arrowlength:us})),this.anchors.bulk=[0,-ne-me/2])}},j0=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{bulk:!1,offset_gate:!0,arrow:!0});let t=T(this.params,"bulk",!1),n=T(this.params,"offset_gate",!0),i=T(this.params,"arrow",!0)&&!t;this.segments.push(new p([[0,0],[0,-ne],[Re,-ne],[Re,-ne-me],[0,-ne-me],[0,-2*ne-me]])),i&&this.segments.push(new D([Vl*2,-ne-me],Vl,{fill:!0})),this.segments.push(new p([[Re+Ve,-ne-yt],[Re+Ve,-ne-me+yt]])),n?(this.segments.push(new p([[Re+Ve,-ne-me+yt],[Re+Ve+ne,-ne-me+yt]])),this.anchors.gate=[Re+Ve+ne,-ne-me+yt]):(this.segments.push(new p([[Re+Ve,-ne-me/2],[Re+Ve+ne,-ne-me/2]])),this.anchors.gate=[Re+Ve+ne,-ne-me/2]),this.anchors.source=[0,-2*ne-me],this.anchors.drain=[0,0],this.anchors.center=[0,-ne-me/2],this.elmParams.drop=[0,-2*ne-me],this.elmParams.lblloc="lft",t&&(this.segments.push(new p([[0,-ne-me/2],[Re,-ne-me/2]])),this.segments.push(new D([Re-Vl*2,-ne-me/2],Vl,{fill:!0})),this.anchors.bulk=[0,-ne-me/2])}},Jl=q*.2,ue=Ye*3,vs=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{circle:!1,arrowlength:.25,arrowwidth:.2}),this.segments.push(new p([[0,0],[0,-O],[ue,-O],[ue,-O+Jl],[ue,-O-ue-Jl],[ue,-O-ue],[0,-O-ue],[0,-2*O-ue]])),this.segments.push(new p([[ue,-O-ue],[ue+O,-O-ue]])),this.elmParams.drop=[ue+O,-O-ue],this.anchors.source=[0,-2*O-ue],this.anchors.drain=[0,0],this.anchors.gate=[ue+O,-O-ue],this.anchors.center=[0,-O-ue/2],this.elmParams.lblloc="lft",T(this.params,"circle",!1)&&this.segments.push(new D([ue/2,-q],q*1.1,{lw:T(this.params,"circle_lw",void 0)}))}},q0=class extends vs{constructor(e={}){super(e),this.segments.push(new p([[ue+.1,-O-ue],[ue+.3,-O-ue]],{arrow:"->",arrowwidth:T(this.params,"arrowwidth",.2),arrowlength:T(this.params,"arrowlength",.25)}))}},H0=class extends vs{constructor(e={}){super(e),this.segments.push(new p([[ue+.25,-O-ue],[ue,-O-ue]],{arrow:"->",arrowwidth:T(this.params,"arrowwidth",.2),arrowlength:T(this.params,"arrowlength",.25)}))}},ys=class extends se{constructor(e={}){super(e),Object.assign(this.defaults,{circle:!1,arrowlength:.25,arrowwidth:.2}),this.segments.push(new p([[0,0],[O,0],[O,ue],[O+ue,ue],[O+ue,0],[2*O+ue,0]])),this.segments.push(new p([[O-Jl,ue],[O+ue+Jl,ue]])),this.segments.push(new p([[O+ue,ue],[O+ue,ue+O]])),this.anchors.isource=[2*O+ue,0],this.anchors.idrain=[0,0],this.anchors.gate=[O+ue,ue+O],this.elmParams.lblloc="bottom",T(this.params,"circle",!1)&&this.segments.push(new D([O+ue/2,ue/2],q*1.1,{lw:T(this.params,"circle_lw",void 0)}))}placeAnchors(e,t){super.placeAnchors(e,t),this.anchors.source=this.anchors.end,this.anchors.drain=this.anchors.start,T(this.params,"reverse",!1)&&(this.anchors.source=this.anchors.start,this.anchors.drain=this.anchors.end)}},Y0=class extends ys{constructor(e={}){super(e),this.segments.push(new p([[O+ue,ue],[O+ue,ue+.3]],{arrow:"->",arrowwidth:T(this.params,"arrowwidth",.2),arrowlength:T(this.params,"arrowlength",.25)}))}},X0=class extends ys{constructor(e={}){super(e),this.segments.push(new p([[O+ue,ue+.3],[O+ue,ue]],{arrow:"->",arrowwidth:T(this.params,"arrowwidth",.2),arrowlength:T(this.params,"arrowlength",.25)}))}},Ma=(q+2*Xe)/5,G0=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{split:!0,arrow:!0,arrowlength:.25,arrowwidth:.2});let t=T(this.params,"split",!0),n=this.params.arrow,s=T(this.params,"arrowwidth",.2),i=T(this.params,"arrowlength",.25);t?this.segments.push(new p([[0,0],[0,-O],[q,-O],H,[q,-O+Xe],[q,-O+Xe-Ma],H,[q,-O+Xe-2*Ma],[q,-O+Xe-3*Ma],H,[q,-O+Xe-4*Ma],[q,-O+Xe-5*Ma],H,[q,-O-q],[0,-O-q],[0,-2*O-q]])):this.segments.push(new p([[0,0],[0,-O],[q,-O],H,[q,-O+Xe],[q,-O-q-Xe],H,[q,-O-q],[0,-O-q],[0,-2*O-q]])),this.segments.push(new p([[q,-O-q/2],[q+O+Xe,-O-q/2]])),n===">"?this.segments.push(new p([[0,-O-q],[q,-O-q]],{arrow:"->",arrowwidth:s,arrowlength:i})):n!==!1&&this.segments.push(new p([[0,-O-q],[q,-O-q]],{arrow:"<-",arrowwidth:s,arrowlength:i})),this.anchors.drain=[0,-2*O-q],this.anchors.source=[0,0],this.anchors.gate=[q+O+Xe,-O-q/2],this.anchors.center=[0,-O-q/2],this.elmParams.drop=[0,-2*O-q],this.elmParams.lblloc="lft"}},za=Ye*3.3,pe=za*2/3,ht=za*(4/3),tr=ht/4,It=pe+za*.7,qt=ht*.7,qr=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{circle:!1,arrowwidth:.2,arrowlength:.25}),this.segments.push(new p([[0,0],[pe,0]])),this.segments.push(new p([[pe,ht/2],[pe,-ht/2]])),this.segments.push(new p([[pe,tr],[It,qt],[It,qt+tr]])),this.segments.push(new p([[pe,-tr],[It,-qt],[It,-qt-tr]])),T(this.params,"circle",!1)&&this.segments.push(new D([za,0],za,{lw:T(this.params,"circle_lw",void 0)})),this.elmParams.drop=[It,qt+tr],this.anchors.base=[0,0],this.anchors.collector=[It,qt+tr],this.anchors.emitter=[It,-qt-tr],this.anchors.center=[It,0]}},Ht=class extends qr{constructor(e={}){super(e),this.segments.push(new p([[pe,-tr],[It,-qt]],{arrow:"->",arrowwidth:T(this.params,"arrowwidth",.2),arrowlength:T(this.params,"arrowlength",.25)}))}},rr=class extends qr{constructor(e={}){super(e),this.segments.push(new p([[It,qt],[pe,tr]],{arrow:"->",arrowwidth:T(this.params,"arrowwidth",.2),arrowlength:T(this.params,"arrowlength",.25)})),this.anchors.base=[0,0],this.anchors.collector=[It,-qt-tr],this.anchors.emitter=[It,qt+tr]}},f1=.55,Ea=.2,Ul=.75,jr=.42,Ct=1.1,Hr=class extends se{constructor(e={}){super(e),Object.assign(this.defaults,{circle:!1,lblloc:"bottom",theta:90,arrowwidth:.2,arrowlength:.25}),this.segments.push(new p([[0,0],[Ct/2-Ea,jr],[Ct/2+Ea,jr],[Ct,0]])),this.segments.push(new p([[Ct/2-Ul/2,jr],[Ct/2+Ul/2,jr]])),this.segments.push(new p([[Ct/2,jr],[Ct/2,jr+Ul/2]])),T(this.params,"circle",!1)&&this.segments.push(new D([Ct/2,f1/2],f1,{lw:T(this.params,"circle_lw",void 0)})),this.anchors.base=[Ct/2,jr+Ul/2],this.anchors.icollector=[Ct,0],this.anchors.iemitter=[0,0]}placeAnchors(e,t){super.placeAnchors(e,t),this.anchors.emitter=this.anchors.start,this.anchors.collector=this.anchors.end,T(this.params,"reverse",!1)&&(this.anchors.emitter=this.anchors.end,this.anchors.collector=this.anchors.start)}},Ss=class extends Hr{constructor(e={}){super(e),this.segments.push(new p([[0,0],[Ct/2-Ea,jr]],{arrow:"->",arrowwidth:T(this.params,"arrowwidth",.2),arrowlength:T(this.params,"arrowlength",.25)}))}},ln=class extends Hr{constructor(e={}){super(e),this.segments.push(new p([[Ct/2+Ea,jr],[Ct,0]],{arrow:"->",arrowwidth:T(this.params,"arrowwidth",.2),arrowlength:T(this.params,"arrowlength",.25)}));let t=this.anchors.icollector,n=this.anchors.iemitter;this.anchors.icollector=n,this.anchors.iemitter=t}placeAnchors(e,t){super.placeAnchors(e,t),this.anchors.emitter=this.anchors.end,this.anchors.collector=this.anchors.start,T(this.params,"reverse",!1)&&(this.anchors.emitter=this.anchors.start,this.anchors.collector=this.anchors.end)}},W0=class extends rr{constructor(e={}){super(e);let t=-.25;this.segments.push(new p([[pe,-tr-t],[It,-qt-t]])),this.anchors.C2=[It,-qt-t]}},xt=.1,V0=class extends Ht{constructor(e={}){super(e),this.segments.push(new p([[pe,ht/2],[pe,ht/2+xt],[pe+xt,ht/2+xt],[pe+xt,ht/2]])),this.segments.push(new p([[pe,-ht/2],[pe,-ht/2-xt],[pe-xt,-ht/2-xt],[pe-xt,-ht/2]]))}},U0=class extends rr{constructor(e={}){super(e),this.segments.push(new p([[pe,ht/2],[pe,ht/2+xt],[pe-xt,ht/2+xt],[pe-xt,ht/2]])),this.segments.push(new p([[pe,-ht/2],[pe,-ht/2-xt],[pe+xt,-ht/2-xt],[pe+xt,-ht/2]]))}},J0=class extends Ht{constructor(e={}){super(e),this.segments.shift();let t=.25;this.segments.push(new p([[-.1,pe],[pe*.75,.1]],{arrow:"->",arrowwidth:T(this.params,"arrowwidth",.2),arrowlength:T(this.params,"arrowlength",.25)})),this.segments.push(new p([[-.1,pe-t],[pe*.75,.1-t]],{arrow:"->",arrowwidth:T(this.params,"arrowwidth",.2),arrowlength:T(this.params,"arrowlength",.25)}))}},K0=class extends rr{constructor(e={}){super(e),this.segments.shift();let t=.25;this.segments.push(new p([[-.1,pe],[pe*.75,.1]],{arrow:"->",arrowwidth:T(this.params,"arrowwidth",.2),arrowlength:T(this.params,"arrowlength",.25)})),this.segments.push(new p([[-.1,pe-t],[pe*.75,.1-t]],{arrow:"->",arrowwidth:T(this.params,"arrowwidth",.2),arrowlength:T(this.params,"arrowlength",.25)}))}},vt=.15,Z0=class extends Ht{constructor(e={}){super(e),this.segments.shift(),this.segments.push(new p([[pe-vt,pe-vt/2],[pe-vt,-pe+vt/2],[pe-vt*2,-pe+vt/2]])),this.anchors.base=[pe-vt*2,-pe+vt/2]}},Q0=class extends rr{constructor(e={}){super(e),this.segments.shift(),this.segments.push(new p([[pe-vt*2,pe-vt/2],[pe-vt,pe-vt/2],[pe-vt,-pe+vt/2]])),this.anchors.base=[pe-vt*2,pe-vt/2]}},ei=class extends ln{constructor(e={}){super(e);let t=.25;this.segments.push(new p([[t,0],[t+Ct/2-Ea,jr]])),this.anchors.C2=[t,0]}};function Bc(r){let e=r[0].toUpperCase();return e==="L"||e==="R"||e==="T"||e==="B"?e:"L"}var Kl=class{constructor(e={}){z(this,"name");z(this,"pin");z(this,"side");z(this,"pos");z(this,"slot");z(this,"invert",!1);z(this,"invertradius",.15);z(this,"color");z(this,"rotation",0);z(this,"anchorname");z(this,"lblsize");z(this,"pinlblsize");z(this,"href");z(this,"decoration");this.side=e.side!==void 0?Bc(String(e.side)):"L",e.name!==void 0&&(this.name=e.name),e.pin!==void 0&&(this.pin=e.pin),e.pos!==void 0&&(this.pos=e.pos),e.slot!==void 0&&(this.slot=e.slot),e.invert!==void 0&&(this.invert=e.invert),e.invertradius!==void 0&&(this.invertradius=e.invertradius),e.color!==void 0&&(this.color=e.color),e.rotation!==void 0&&(this.rotation=e.rotation),e.anchorname!==void 0&&(this.anchorname=e.anchorname),e.lblsize!==void 0&&(this.lblsize=e.lblsize),e.pinlblsize!==void 0&&(this.pinlblsize=e.pinlblsize),e.href!==void 0&&(this.href=e.href),e.decoration!==void 0&&(this.decoration=e.decoration)}};function d2(r,e){let t=Math.max(.15,r.length*e/72),n=e/72*1.2;return[t*2,n*2]}function w1(r){return{...r}}var nr=class extends N{constructor(t={}){let{size:n,pins:s,slant:i,label:o,...a}=t;super({...a,...o!==void 0?{label:o}:{}});z(this,"size");z(this,"slant");z(this,"pins");z(this,"usersides");z(this,"sides");z(this,"pincount",{L:0,R:0,T:0,B:0});z(this,"_sizeauto");z(this,"_icbox");z(this,"_dflt");if(Object.assign(this.defaults,{pinspacing:0,edgepadH:.5,edgepadW:.5,leadlen:.5,lsize:14,lofst:.15,plblofst:.075,plblsize:11}),this.slant=i??0,this.pins={L:[],R:[],T:[],B:[]},this.usersides={},this.sides={L:this.mkSide(),R:this.mkSide(),T:this.mkSide(),B:this.mkSide()},this._dflt=this.mkSide(),this.size=n??this.params.size,s)for(let l of s)this.pins[l.side].push({...l,side:l.side});this._setsize()}mkSide(){return{spacing:T(this.params,"pinspacing",0),pad:T(this.params,"edgepadH",.25),leadlen:T(this.params,"leadlen",.5),label_ofst:T(this.params,"lofst",.15),label_size:T(this.params,"lsize",14),pinlabel_ofst:T(this.params,"plblofst",.05),pinlabel_size:T(this.params,"plblsize",11)}}pin(t){let n=Bc(t.side??"L"),s={side:n,name:t.name,pin:t.pin,pos:t.pos,slot:t.slot,invert:t.invert??!1,invertradius:t.invertradius??.15,color:t.color,rotation:t.rotation??0,anchorname:t.anchorname,lblsize:t.lblsize,pinlblsize:t.pinlblsize,href:t.href,decoration:t.decoration};return this.pins[n].push(s),this._setsize(),this}side(t,n=0,s=.5,i=.5,o=.15,a=14,l=.05,h=11){let c=Bc(t);return this.usersides[c]={spacing:n,pad:s,leadlen:i,label_ofst:o,label_size:a,pinlabel_ofst:l,pinlabel_size:h},this._setsize(),this}get pinnames(){let t=[];for(let n of["L","R","T","B"])for(let s of this.pins[n])s.name&&t.push(s.anchorname??s.name);return t}getAnchorNamesForGetattr(){let t=new Set(super.getAnchorNamesForGetattr());for(let n of["L","R","T","B"])for(let s of this.pins[n])s.name&&t.add(s.anchorname??s.name),s.pin&&t.add(`pin${s.pin}`);return[...t]}getPinAnchor(t){return this.resolveAnchor(t)}_countpins(){let t={L:0,R:0,T:0,B:0};for(let n of["L","R","T","B"]){let i=this.pins[n].map(o=>o.slot).filter(o=>o!=null).map(o=>Number(o.split("/")[1])).concat([0]);t[n]=Math.max(this.pins[n].length,Math.max(...i))}return t}_autosize(){let t={},n={};for(let a of["L","R","T","B"]){let l=w1(this.usersides[a]??this._dflt);l.spacing===0&&(l={...l,spacing:.6}),this.sides[a]=l;let h=Math.max(1,this.pincount[a]);t[a]=l.pad*2+l.spacing*(h-1);let c=0;for(let m of this.pins[a])if(m.name){let f=m.lblsize??T(this.params,"lsize",14);c=Math.max(c,d2(m.name,f)[0])}n[a]=c}let s=n.L+n.R+4*T(this.params,"lofst",.15),i=Math.max(t.L??0,t.R??0,2+T(this.params,"edgepadH",.5)),o=Math.max(t.T??0,t.B??0,2+T(this.params,"edgepadW",.5),s);this._sizeauto=[o,i];for(let a of["L","R"]){let l=this.sides[a],h=Math.max(1,this.pincount[a]);l.pad=(i-l.spacing*(h-1))/2}for(let a of["T","B"]){let l=this.sides[a],h=Math.max(1,this.pincount[a]);l.pad=(o-l.spacing*(h-1))/2}}_autopinlayout(){let t=this.size;for(let n of["L","R","T","B"]){let s=w1(this.usersides[n]??this._dflt);this.sides[n]=s;let i=["T","B"].includes(n)?t[0]:t[1],o=s.pad;s.spacing===0?this.pincount[n]>1?s.spacing=(i-2*o)/(this.pincount[n]-1):s.pad=i/2:s.pad=(i-s.spacing*(this.pincount[n]-1))/2}}_setsize(){this.pincount=this._countpins(),this.size===void 0?this._autosize():this._autopinlayout()}_drawBox(){let t,n;this.size?[t,n]=this.size:this._sizeauto?[t,n]=this._sizeauto:(t=2,n=3);let s=t*Math.tan(this.slant*Math.PI/180),i=0,o=n,a;return this.slant>0?(i=0-s,o=n+s,a=[new A(0,0),new A(t,i),new A(t,o),new A(0,n),new A(0,0)]):this.slant<0?(i=0+s,o=n-s,a=[new A(0,i),new A(t,0),new A(t,n),new A(0,o),new A(0,i)]):(i=0,o=n,a=[new A(0,0),new A(t,0),new A(t,n),new A(0,n),new A(0,0)]),this.segments.push(new p(a.map(l=>[l.x,l.y]),{})),{w:t,h:n,y1:i,y2:o}}_pinpos(t,n,s){let i=this.sides[t]??this._dflt,o=i.spacing>0?i.spacing:.6,a=s;n.slot&&(a=Number(n.slot.split("/")[0])-1);let l=i.pad+a*o;n.pos!==void 0&&n.pos!==null&&(l=i.pad+n.pos*(this.pincount[t]-1)*o);let h;return t==="L"?h=new A(0,l):t==="R"?h=new A(this._icbox.w,l):t==="T"?h=new A(l,this._icbox.h):h=new A(l,0),t==="T"&&this.slant>0?h=new A(h.x,h.y-h.x*Math.tan(-this.slant*Math.PI/180)):t==="T"&&this.slant<0?h=new A(h.x,h.y+(this._icbox.y2-this._icbox.h)-h.x*Math.tan(-this.slant*Math.PI/180)):t==="B"&&this.slant<0?h=new A(h.x,h.y-(this._icbox.y2-this._icbox.h)-h.x*Math.tan(this.slant*Math.PI/180)):t==="B"&&this.slant>0&&(h=new A(h.x,h.y-h.x*Math.tan(this.slant*Math.PI/180))),h}_drawClkpin(t,n,s){let i=this.sides[s]??this._dflt,o=.4*(i.label_size/16),a=.2*(i.label_size/16),l;if(s==="T"||s==="B"){let h=n.y!==0?Math.sign(n.y):1,c=Math.abs(o)*h;l=[new A(t.x-a,t.y),new A(t.x,t.y-c),new A(t.x+a,t.y)]}else{let h=n.x!==0?-Math.sign(n.x):1,c=Math.abs(o)*h;l=[new A(t.x,t.y+a),new A(t.x+c,t.y),new A(t.x,t.y-a)]}this.segments.push(new p(l.map(h=>[h.x,h.y])))}_drawPin(t,n,s){let i=this.sides[t]??this._dflt,o=this._pinpos(t,n,s),l={L:new A(-i.leadlen,0),R:new A(i.leadlen,0),T:new A(0,i.leadlen),B:new A(0,-i.leadlen)}[t],h=o.add(l);if(this.anchors[`in${t}${s+1}`]=[h.x,h.y],n.anchorname?this.anchors[n.anchorname]=[h.x,h.y]:n.name&&(n.name===">"&&(this.anchors.CLK=[h.x,h.y]),this.anchors[n.name]=[h.x,h.y]),n.pin&&(this.anchors[`pin${n.pin}`]=[h.x,h.y]),i.leadlen>0)if(n.invert){let c=n.invertradius??.15,f={L:new A(-c,0),R:new A(c,0),T:new A(0,c),B:new A(0,-c)}[t],g=o.add(f);this.segments.push(new D([g.x,g.y],c));let b=g.add(f.mul(2));this.segments.push(new p([[b.x,b.y],[h.x,h.y]],{}))}else this.segments.push(new p([[o.x,o.y],[h.x,h.y]],{}));if(n.pin){let c=(n.invert?n.invertradius??.15:0)*(n.invert?1:0),m=i.pinlabel_ofst,g={L:new A(-m-c*2,m),R:new A(m+c*2,m),T:new A(m,m+c*2),B:new A(m,-m-c*2)}[t],b=this.userParams.flip===!0,v=this.userParams.reverse===!0,x={L:"right",R:"left",T:"left",B:"left"},S={L:"bottom",R:"bottom",T:"bottom",B:"top"},k=x[t],M=S[t];b&&(t==="L"||t==="R")&&(g=g.flip()),b&&(t==="T"||t==="B")&&(M=t==="T"?"top":"bottom"),v&&(t==="L"||t==="R")&&(k=t==="L"?"left":"right"),v&&(t==="T"||t==="B")&&(g=g.mirrorx(0));let _=o.add(g);this.segments.push(new W([_.x,_.y],String(n.pin),{fontsize:n.pinlblsize??i.pinlabel_size,align:[k,M]}))}if(n.name===">"){this._drawClkpin(o,l,t);return}if(n.name&&n.name!==""){let c={L:new A(i.label_ofst,0),R:new A(-i.label_ofst,0),T:new A(0,-i.label_ofst),B:new A(0,i.label_ofst)},m=o.add(c[t]),f=this.userParams.flip===!0,g=this.userParams.reverse===!0,b={L:"left",R:"right",T:"center",B:"center"},v={L:"center",R:"center",T:"top",B:"bottom"},x=b[t],S=v[t];f&&(t==="T"||t==="B")&&(S=t==="T"?"bottom":"top"),g&&(t==="L"||t==="R")&&(x=t==="L"?"right":"left"),this.segments.push(new W([m.x,m.y],n.name,{fontsize:n.lblsize??i.label_size,color:n.color??void 0,align:[x,S],href:n.href??void 0,decoration:n.decoration??void 0,rotation:n.rotation??0}))}}_drawPins(){for(let t of["L","R","T","B"])this.pins[t].forEach((n,s)=>this._drawPin(t,n,s))}_place(t,n,s){return this.anchors={},this._setsize(),this._icbox=this._drawBox(),this._drawPins(),this.elmParams.lblloc="center",this.anchors.center=[this._icbox.w/2,this._icbox.h/2],this.elmParams.drop=[this._icbox.w,this._icbox.h/2],super._place(t,n,s)}},ti=class extends nr{constructor(e={}){let{demux:t=!1,...n}=e,s=e.slant!==void 0?e.slant:25;super({...n,slant:t?s:-s})}},ri=class extends nr{constructor(e={}){let{preclr:t=!1,preclrinvert:n=!0,...s}=e,i=[{name:"D",side:"L",slot:"2/2"},{name:">",side:"L",slot:"1/2"},{name:"Q",side:"R",slot:"2/2"},{name:"Q",side:"R",slot:"1/2",anchorname:"Qbar",decoration:"overline"}];t&&(i.push({name:"PRE",side:"T",invert:n}),i.push({name:"CLR",side:"B",invert:n})),super({...s,pins:i,size:s.size??[2,3]})}},ni=class extends nr{constructor(e={}){let{preclr:t=!1,preclrinvert:n=!0,...s}=e,i=[{name:"J",side:"L",slot:"3/3"},{name:">",side:"L",slot:"2/3"},{name:"K",side:"L",slot:"1/3"},{name:"Q",side:"R",slot:"3/3"},{name:"Q",side:"R",slot:"1/3",anchorname:"Qbar",decoration:"overline"}];t&&(i.push({name:"PRE",side:"T",invert:n}),i.push({name:"CLR",side:"B",invert:n})),super({...s,pins:i,size:s.size??[2,3]})}},si=class extends nr{constructor(e={}){let t=[{name:"in",side:"L",slot:"3/3"},{name:"out",side:"R",slot:"3/3"},{name:"gnd",side:"B"}];super({...e,pins:t,size:e.size??[2,1.5]})}},ii=class extends nr{constructor(e={}){let t=[{name:"TRG",side:"L",pin:"2"},{name:"THR",side:"L",pin:"6"},{name:"DIS",side:"L",pin:"7"},{name:"CTL",side:"R",pin:"5"},{name:"OUT",side:"R",pin:"3"},{name:"RST",side:"T",pin:"4"},{name:"Vcc",side:"T",pin:"8"},{name:"GND",side:"B",pin:"1"}];super({...e,edgepadW:.5,edgepadH:1,pinspacing:1.5,leadlen:1,pins:t,label:"555"})}};function Cc(r){let e=r.bottom??0,t=r.left??0,n=r.seglen??1.5,s=r.segw??.3,i=r.spacing??.12,o=r.digit??8,a=r.segcolor??"red",l=r.tilt??10,h=r.labelsegments??!0,c=s/2,m=s/5,f=i/2,g=l*Math.PI/180,b=Math.sin(g),v=[f,f+c,n-f-c,n-f,n-f-c,f+c],x=[0,c,c,0,-c,-c],S=[...v],k=[...v],M=x.map(Te=>Te+n*2),_=x.map(Te=>Te+n),B=[0,c,c,0,-c,-c],$=[f,f+c,n-f-c,n-f,n-f-c,f+c],Y=[...B],Z=$.map(Te=>Te+n),L=B.map(Te=>Te+n),I=[...Z],X=[...L],j=[...$],re=[n/2+f,n*2+c+m],te=[n/2+f,n+c+m],ke=[n/2+f,c+m],he=[n+c+f,n*1.5],ve=[n+c+f,n*.5],de=[-c-f,n*.5],Fe=[-c-f,n*1.5],qe=Te=>[Te[0]+Te[1]*b,Te[1]],Ie=t;l!==0&&(S=S.map((Te,nt)=>Te+b*M[nt]),L=L.map((Te,nt)=>Te+b*I[nt]),X=X.map((Te,nt)=>Te+b*j[nt]),v=v.map((Te,nt)=>Te+b*x[nt]),B=B.map((Te,nt)=>Te+b*$[nt]),Y=Y.map((Te,nt)=>Te+b*Z[nt]),k=k.map((Te,nt)=>Te+b*_[nt]),re=qe(re),te=qe(te),ke=qe(ke),he=qe(he),ve=qe(ve),de=qe(de),Fe=qe(Fe),Ie-=b*n);let ge=Te=>Te.map(nt=>nt+Ie),Me=Te=>Te.map(nt=>nt+e);v=ge(v),x=Me(x),k=ge(k),_=Me(_),S=ge(S),M=Me(M),B=ge(B),$=Me($),Y=ge(Y),Z=Me(Z),L=ge(L),I=Me(I),X=ge(X),j=Me(j),re=[re[0]+Ie,re[1]+e],te=[te[0]+Ie,te[1]+e],ke=[ke[0]+Ie,ke[1]+e],he=[he[0]+Ie,he[1]+e],ve=[ve[0]+Ie,ve[1]+e],de=[de[0]+Ie,de[1]+e],Fe=[Fe[0]+Ie,Fe[1]+e];let be=String(o).toLowerCase(),Be=["2","3","5","6","7","8","9","0","a","c","e","f"].includes(be)?a:void 0,De=["1","2","3","4","7","8","9","0","a","d"].includes(be)?a:void 0,ye=["1","3","4","5","6","7","8","9","0","a","b","d"].includes(be)?a:void 0,_e=["2","3","5","6","8","9","0","b","c","d","e"].includes(be)?a:void 0,Ae=["2","6","8","0","a","b","c","d","e","f"].includes(be)?a:void 0,Ze=["4","5","6","8","9","0","a","b","c","e","f"].includes(be)?a:void 0,bn=["2","3","4","5","6","8","9","a","b","d","e","f"].includes(be)?a:void 0,ft=[],Rt=(Te,nt,ch)=>ft.push(new U(Te.map((uh,Da)=>[uh,nt[Da]]),{closed:!0,fill:ch??!1,color:"gray",lw:.5}));return Rt(S,M,Be),Rt(L,I,De),Rt(X,j,ye),Rt(v,x,_e),Rt(B,$,Ae),Rt(Y,Z,Ze),Rt(k,_,bn),h&&(ft.push(new W(re,"a",{align:["center","bottom"],fontsize:10})),ft.push(new W(te,"g",{align:["center","bottom"],fontsize:10})),ft.push(new W(ke,"d",{align:["center","bottom"],fontsize:10})),ft.push(new W(he,"b",{align:["left","center"],fontsize:10})),ft.push(new W(ve,"c",{align:["left","center"],fontsize:10})),ft.push(new W(de,"e",{align:["right","center"],fontsize:10})),ft.push(new W(Fe,"f",{align:["right","center"],fontsize:10}))),r.decimal&&ft.push(new D([Ie+n+s+.15/2,e],.15,{color:"gray",fill:a,lw:.5})),ft}var oi=class extends nr{constructor(e={}){let t=T(e,"decimal",!1),n=t?"8":"7",s=t?5.9:5.3,o=e.size??[3,s],a=[{pin:"a",side:"L",slot:`${7+(t?1:0)}/${n}`,anchorname:"a"},{pin:"b",side:"L",slot:`${6+(t?1:0)}/${n}`,anchorname:"b"},{pin:"c",side:"L",slot:`${5+(t?1:0)}/${n}`,anchorname:"c"},{pin:"d",side:"L",slot:`${4+(t?1:0)}/${n}`,anchorname:"d"},{pin:"e",side:"L",slot:`${3+(t?1:0)}/${n}`,anchorname:"e"},{pin:"f",side:"L",slot:`${2+(t?1:0)}/${n}`,anchorname:"f"},{pin:"g",side:"L",slot:`${1+(t?1:0)}/${n}`,anchorname:"g"}];t&&a.push({pin:"dp",side:"L",slot:`1/${n}`,anchorname:"dp"}),T(e,"anode",!1)&&a.push({pin:"ca",side:"T",anchorname:"anode"}),T(e,"cathode",!1)&&a.push({pin:"cc",side:"B",anchorname:"cathode"}),super({...e,pins:a,size:o,pinspacing:.6});let l=.8,c=(s-1.5*2)/2;this.segments.push(...Cc({left:l,bottom:c,decimal:t,digit:T(e,"digit",8),segcolor:T(e,"segcolor","red"),tilt:T(e,"tilt",10),labelsegments:T(e,"labelsegments",!0)}))}},ai=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{pins:8,notch:!0,width:3,pinw:.6,spacing:.5,number:!0,fontsize:12,pfontsize:10});let t=T(this.params,"width",3),n=T(this.params,"pinw",.6),s=T(this.params,"spacing",.5),i=T(this.params,"pins",8),o=T(this.params,"names",void 0);if(i%2===1)throw new Error("pins must be even");let a=i/2*n+s*(i/2+1);if(this.segments.push(new U([[0,0],[t,0],[t,a],[0,a]],{closed:!0})),T(this.params,"notch",!0)){let h=t/2,c=ze(-Math.PI,0,50),m=n/2,f=c.map(b=>h+m*Math.cos(b)),g=c.map(b=>a+m*Math.sin(b));this.segments.push(new p(f.map((b,v)=>[b,g[v]])))}let l=i/2;for(let h=0;h<l;h++){let c=s+s*h+h*n,m=s+s*h+(h+1)*n,f=(c+m)/2;this.segments.push(new U([[0,c],[0,m],[-n,m],[-n,c]],{closed:!0}));let g=l-h;this.anchors[`p${g}`]=[-n,f],this.anchors[`p${g}_in`]=[0,f],T(this.params,"number",!0)&&this.segments.push(new W([-n/2,f],String(g),{fontsize:T(this.params,"pfontsize",10)})),o&&o[g-1]&&(this.segments.push(new W([.1,f],o[g-1],{align:["left","center"],fontsize:T(this.params,"fontsize",12)})),this.anchors[o[g-1]]=[-n,f],this.anchors[`${o[g-1]}_in`]=[0,f]),this.segments.push(new U([[t,c],[t,m],[t+n,m],[t+n,c]],{closed:!0})),g=l+h+1,this.anchors[`p${g}`]=[t+n,f],this.anchors[`p${g}_in`]=[t,f],T(this.params,"number",!0)&&this.segments.push(new W([t+n/2,f],String(g),{fontsize:T(this.params,"pfontsize",10)})),o&&o[g-1]&&(this.segments.push(new W([t-.1,f],o[g-1],{align:["right","center"],fontsize:T(this.params,"fontsize",12)})),this.anchors[o[g-1]]=[t+n,f],this.anchors[`${o[g-1]}_in`]=[t,f])}}};var Zc={};$a(Zc,{Adc:()=>Ls,Amp:()=>un,And:()=>Bt,Bjt:()=>qr,Bjt2:()=>Hr,BjtNpn:()=>Ht,BjtNpn2:()=>Ss,BjtPnp:()=>rr,BjtPnp2:()=>ln,Breaker:()=>as,Buf:()=>Jt,CPE:()=>ls,Capacitor:()=>Cr,Capacitor2:()=>Cn,CapacitorTrim:()=>Ln,CapacitorVar:()=>In,Circle:()=>ui,Circulator:()=>Os,Connect:()=>pr,Crystal:()=>Un,CurrentMirror:()=>Fr,Dac:()=>Ds,Data:()=>Ms,Decision:()=>Es,Demod:()=>Ns,Diac:()=>on,Diode:()=>et,DiodeShockley:()=>$n,DiodeTVS:()=>Fn,DiodeTunnel:()=>On,DrawTree:()=>l0,DspBox:()=>sr,DspCircle:()=>Yt,DspSpeaker:()=>_s,Ellipse:()=>zs,Filter:()=>Is,FlowBox:()=>cn,Fuse:()=>rs,FuseIEC:()=>Dr,FuseIEEE:()=>dr,FuseUS:()=>os,Inductor:()=>Ir,Inductor2:()=>Lr,Isolator:()=>Fs,Josephson:()=>is,LED:()=>qn,LED2:()=>Hn,LogicTree:()=>gr,Memristor:()=>ns,Memristor2:()=>ss,Mixer:()=>As,NFet:()=>gs,NFet2:()=>ws,NMos:()=>ms,NMos2:()=>ps,Norator:()=>Or,Not:()=>Kt,Nullator:()=>Nr,Opamp:()=>cs,Or:()=>$t,Oscillator:()=>Cs,OscillatorBox:()=>Bs,PFet:()=>bs,PFet2:()=>xs,PMos:()=>ds,PMos2:()=>fs,Photodiode:()=>Yn,Photoresistor:()=>ts,PhotoresistorIEC:()=>Qt,PhotoresistorIEEE:()=>ur,Potentiometer:()=>es,PotentiometerIEC:()=>er,PotentiometerIEEE:()=>mr,Process:()=>hi,Resistor:()=>Zn,ResistorIEC:()=>mt,ResistorVar:()=>Qn,ResistorVarIEC:()=>Zt,ResistorVarIEEE:()=>cr,RoundBox:()=>Yr,RoundProcess:()=>li,Rshunt:()=>Kn,SCR:()=>Xn,STYLE_IEC:()=>Xl,STYLE_IEEE:()=>an,Schottky:()=>Dn,SparkGap:()=>hs,Start:()=>ci,State:()=>mi,StateEnd:()=>Ps,Subroutine:()=>ks,Sum:()=>Ts,SumSigma:()=>Rs,Terminal:()=>hn,Thermistor:()=>Jn,Triac:()=>Gn,Tristate:()=>Bn,VGA:()=>$s,Varactor:()=>jn,VoltageMirror:()=>$r,Zener:()=>Nn,buchheim:()=>Ra,cycloid:()=>Vn,logicparse:()=>Ql,nand:()=>Tn,nor:()=>Rn,pictorial:()=>Jc,resetElementStyleForTests:()=>Wl,setBoxAnchors16:()=>fr,setElementStyle:()=>Gl,xnor:()=>_n,xor:()=>An});function fr(r,e,t){r.center=[e/2,0],r.N=[e/2,t/2],r.E=[e,0],r.S=[e/2,-t/2],r.W=[0,0],r.NW=[0,t/2],r.NE=[e,t/2],r.SW=[0,-t/2],r.SE=[e,-t/2],r.NNE=[3*e/4,t/2],r.NNW=[e/4,t/2],r.SSE=[3*e/4,-t/2],r.SSW=[e/4,-t/2],r.ENE=[e,t/3],r.ESE=[e,-t/3],r.WNW=[0,t/3],r.WSW=[0,-t/3]}function p2(r,e,t,n){let s=n-n*Math.sqrt(2)/2;fr(r,e,t),r.NW=[s,t/2-s],r.NE=[e-s,t/2-s],r.SW=[s,-t/2+s],r.SE=[e-s,-t/2+s],r.NNE=[n<e/4?3*e/4:e-n,t/2],r.NNW=[n<e/4?e/4:n,t/2],r.SSE=[n<e/4?3*e/4:e-n,-t/2],r.SSW=[n<e/4?e/4:n,-t/2],r.ENE=[e,n<t/4?t/4:t/2-n],r.ESE=[e,n<t/4?-t/4:-t/2+n],r.WNW=[0,n<t/4?t/4:t/2-n],r.WSW=[0,n<t/4?-t/4:-t/2+n]}function f2(r,e,t,n){fr(r,e,t);let s=n*Math.sqrt(2)/2;r.SE=[n+s,-s],r.SW=[n-s,-s],r.NE=[n+s,s],r.NW=[n-s,s];let i=n*Math.cos(22.5*Math.PI/180),o=n*Math.cos(67.5*Math.PI/180);r.NNE=[n+o,i],r.ENE=[n+i,o],r.ESE=[n+i,-o],r.SSE=[n+o,-i],r.NNW=[n-o,i],r.WNW=[n-i,o],r.WSW=[n-i,-o],r.SSW=[n-o,-i]}var Yr=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{w:3,h:2,theta:0,cornerradius:.3});let t=T(this.params,"w",3),n=T(this.params,"h",2),s=T(this.params,"cornerradius",.3);this.segments.push(new U([[0,n/2],[t,n/2],[t,-n/2],[0,-n/2]],{closed:!0,cornerradius:s,fill:"none"})),p2(this.anchors,t,n,s),this.elmParams.drop=[t,0]}},hn=class extends Yr{constructor(e={}){let t=e.h??1.25,n=e.w??3,s=e.anchor??"N";super({...e,w:n,h:t,cornerradius:t/2,anchor:s}),this.elmParams.drop=[n/2,-t/2],this.elmParams.droptheta=-90}},li=Yr,cn=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{w:3,h:2,theta:0});let t=T(this.params,"w",3),n=T(this.params,"h",2);this.segments.push(new p([[0,0],[0,n/2],[t,n/2],[t,-n/2],[0,-n/2],[0,0]])),fr(this.anchors,t,n),this.elmParams.drop=[t,0]}},hi=cn,ci=hn,ks=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{w:3,h:2,theta:0,s:.3});let t=T(this.params,"s",.3),n=T(this.params,"w",3)+t*2,s=T(this.params,"h",2);this.segments.push(new p([[0,0],[0,s/2],[n,s/2],[n,-s/2],[0,-s/2],[0,0]])),this.segments.push(new p([[n-t,s/2],[n-t,-s/2]])),this.segments.push(new p([[t,s/2],[t,-s/2]])),fr(this.anchors,n,s),this.elmParams.drop=[n,0]}},Ms=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{w:3,h:2,theta:0,slant:.5});let t=T(this.params,"w",3),n=T(this.params,"h",2),s=T(this.params,"slant",.5);this.segments.push(new U([[0,0],[s/2,n/2],[t+s/2,n/2],[t-s/2,-n/2],[-s/2,-n/2]],{closed:!0,fill:"none"})),fr(this.anchors,t,n),this.anchors.N=[t/2+s/2,n/2],this.anchors.S=[t/2-s/2,-n/2],this.anchors.NE=[t+s/2,n/2],this.anchors.SE=[t-s/2,-n/2],this.anchors.NW=[s/2,n/2],this.anchors.SW=[-s/2,-n/2],this.anchors.ENE=[t+s/4,n/4],this.anchors.WNW=[s/4,n/4],this.anchors.ESE=[t-s/4,-n/4],this.anchors.WSW=[-s/4,-n/4],this.anchors.NNE=[3*t/4+s/2,n/2],this.anchors.SSE=[3*t/4-s/2,-n/2],this.anchors.NNW=[t/4+s/2,n/2],this.anchors.SSW=[t/4-s/2,-n/2],this.elmParams.drop=[t,0]}},zs=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{w:3,h:2,theta:0});let t=T(this.params,"w",3),n=T(this.params,"h",2),i=ze(0,Math.PI*2,50).map(c=>{let m=n/2*Math.sin(c);return[t/2*Math.cos(c)+t/2,m]});i[i.length-1]=[i[0][0],i[0][1]],this.segments.push(new p(i)),fr(this.anchors,t,n);let o=Math.sin(Math.PI/4),a=Math.cos(Math.PI/4),l=Math.sin(Math.PI/8),h=Math.cos(Math.PI/8);this.anchors.SE=[t/2+t/2*a,-n/2*o],this.anchors.SW=[t/2-t/2*a,-n/2*o],this.anchors.NW=[t/2-t/2*a,n/2*o],this.anchors.NE=[t/2+t/2*a,n/2*o],this.anchors.ENE=[t/2+t/2*h,n/2*l],this.anchors.WNW=[t/2-t/2*h,n/2*l],this.anchors.ESE=[t/2+t/2*h,-n/2*l],this.anchors.WSW=[t/2-t/2*h,-n/2*l],this.anchors.NNE=[t/2+t/2*l,n/2*h],this.anchors.NNW=[t/2-t/2*l,n/2*h],this.anchors.SSE=[t/2+t/2*l,-n/2*h],this.anchors.SSW=[t/2-t/2*l,-n/2*h],this.elmParams.drop=[t,0]}},Es=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{w:4,h:2.25,theta:0,fontsize:14});let t=T(this.params,"w",4),n=T(this.params,"h",2.25),s=T(this.params,"fontsize",14),i=T(this.params,"font",void 0),o=.13,a=e.N,l=e.E,h=e.S,c=e.W;this.segments.push(new U([[0,0],[t/2,n/2],[t,0],[t/2,-n/2]],{closed:!0,fill:"none"})),a&&this.segments.push(new W([t/2+o,n/2+o],a,{align:["left","bottom"],fontsize:s,fontfamily:i})),h&&this.segments.push(new W([t/2+o,-n/2-o],h,{align:["left","top"],fontsize:s,fontfamily:i})),l&&this.segments.push(new W([t+o,o],l,{align:["left","bottom"],fontsize:s,fontfamily:i})),c&&this.segments.push(new W([-o,o],c,{align:["right","bottom"],fontsize:s,fontfamily:i})),fr(this.anchors,t,n),this.anchors.NE=[3*t/4,n/4],this.anchors.NW=[t/4,n/4],this.anchors.SE=[3*t/4,-n/4],this.anchors.SW=[t/4,-n/4],this.anchors.NNE=[5*t/8,3*n/8],this.anchors.NNW=[3*t/8,3*n/8],this.anchors.SSE=[5*t/8,-3*n/8],this.anchors.SSW=[3*t/8,-3*n/8],this.anchors.ENE=[7*t/8,n/8],this.anchors.ESE=[7*t/8,-n/8],this.anchors.WNW=[t/8,n/8],this.anchors.WSW=[t/8,-n/8],this.elmParams.drop=[t,0]}},pr=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{w:1.5,h:1.5,r:.75});let t=T(this.params,"w",1.5),n=T(this.params,"h",1.5);if(e.r!==void 0){let i=e.r;t=i*2,n=i*2}let s=t/2;this.segments.push(new D([s,0],s)),f2(this.anchors,t,n,s),this.elmParams.drop=[t,0]}},ui=pr,mi=pr,Ps=class extends pr{constructor(e={}){let t=e.dr??.15,n=e.w??1.5,s=e.h??1.5;if(e.r!==void 0){let h=e.r;n=h*2,s=h*2}let{r:i,...o}=e;super({...o,w:n,h:s});let l=T(this.params,"w",n)/2;this.segments.push(new D([l,0],l-t))}};var sr=class extends N{constructor(e={}){super(e),this.segments.push(new p([[0,0],[0,.5],[1,.5],[1,-.5],[0,-.5],[0,0]])),this.elmParams.lblloc="center",this.elmParams.lblofst=0,this.anchors.N=[.5,.5],this.anchors.S=[.5,-.5],this.anchors.E=[1,0],this.anchors.W=[0,0],this.elmParams.drop=[1,0]}},Yt=class extends N{constructor(e={}){super(e);let t=e.radius??.5,n=t*Math.SQRT2/2;this.segments.push(new D([t,0],t)),this.elmParams.lblloc="center",this.elmParams.lblofst=0,this.elmParams.drop=[2*t,0],this.anchors.N=[t,t],this.anchors.S=[t,-t],this.anchors.E=[2*t,0],this.anchors.W=[0,0],this.anchors.NW=[t-n,n],this.anchors.NE=[t+n,n],this.anchors.SW=[t-n,-n],this.anchors.SE=[t+n,-n],this.anchors.center=[t,0]}},Ts=class extends Yt{constructor(e={}){super(e),this.segments.push(new p([[.5,.2],[.5,-.2]])),this.segments.push(new p([[.3,0],[.7,0]]))}},Rs=class extends Yt{constructor(e={}){super(e),this.segments.push(new W([.45,0],"\u03A3",{align:["center","center"]}))}},As=class extends Yt{constructor(e={}){super(e);let t=.5,n=t*Math.SQRT2/2;this.segments.push(new p([[t+n,n],[t-n,-n]],{lw:1})),this.segments.push(new p([[t+n,-n],[t-n,n]],{lw:1})),this.elmParams.lblloc="top",this.elmParams.lblofst=.2;let s=e.font,i=e.fontsize??10;e.N&&this.segments.push(new W([t,t/2+.01],e.N,{fontfamily:s,fontsize:i})),e.S&&this.segments.push(new W([t,-t/2-.065],e.S,{fontfamily:s,fontsize:i})),e.E&&this.segments.push(new W([t*1.5+.05,0],e.E,{fontfamily:s,fontsize:i})),e.W&&this.segments.push(new W([t/2-.05,0],e.W,{fontfamily:s,fontsize:i}))}},_s=class extends N{constructor(e={}){super(e),this.segments.push(new p([[0,0],[0,.25],[.25,.25],[.25,-.25],[0,-.25],[0,0]])),this.segments.push(new p([[.25,.25],[.5,.5],[.5,-.5],[.25,-.25],[.25,.25]]))}},un=class extends N{constructor(e={}){super(e);let t=1,n=.75;this.segments.push(new p([[0,0],[0,-t/2],[n,0],[0,t/2],[0,0]])),this.elmParams.drop=[n,0],this.anchors.input=[0,0],this.anchors.out=[n,0]}};function Ic(){return ze(-Math.PI,Math.PI,20).map(e=>[e/Math.PI*.3+.5,-Math.sin(e)/10])}var Bs=class extends sr{constructor(e={}){super(e),this.segments.push(new p(Ic()))}},Cs=class extends Yt{constructor(e={}){super(e),this.segments.push(new p(Ic()))}},Is=class extends sr{constructor(e={}){super(e);let t=Ic(),n=t.map(([o,a])=>[o,a+.25]),s=t.map(([o,a])=>[o,a-.25]);this.segments.push(new p(t)),this.segments.push(new p(n)),this.segments.push(new p(s));let i=e.response;if(i){let o=i.toLowerCase();(o==="bp"||o==="lp")&&this.segments.push(new p([[.45,.17],[.55,.33]])),(o==="bp"||o==="hp")&&this.segments.push(new p([[.45,-.33],[.55,-.17]])),(o==="lp"||o==="hp"||o==="notch")&&this.segments.push(new p([[.45,-.08],[.55,.08]]))}}},Ls=class extends N{constructor(e={}){super(e),this.segments.push(new p([[0,0],[.22,.5],[1.4,.5],[1.4,-.5],[.22,-.5],[0,0]])),this.elmParams.lblloc="center",this.elmParams.lblofst=0,this.elmParams.drop=[1.4,0],this.anchors.input=[0,0],this.anchors.out=[1.4,0],this.anchors.E=[1.4,0],this.anchors.W=[0,0]}},Ds=class extends N{constructor(e={}){super(e),this.segments.push(new p([[0,0],[0,.5],[1.18,.5],[1.4,0],[1.18,-.5],[0,-.5],[0,0]])),this.elmParams.lblloc="center",this.elmParams.lblofst=0,this.elmParams.drop=[1.4,0],this.anchors.input=[0,0],this.anchors.out=[1.4,0],this.anchors.E=[1.4,0],this.anchors.W=[0,0]}},Ns=class extends sr{constructor(e={}){super(e),this.segments.push(new p([[.15,0],[.3,0]])),this.segments.push(new p([[.3,.25],[.7,0],[.3,-.25],[.3,.25]])),this.segments.push(new p([[.7,.25],[.7,-.25]])),this.segments.push(new p([[.7,0],[.85,0]]))}},Os=class extends Yt{constructor(e={}){super(e);let t=.5;this.segments.push(new xe([.5,0],.9*t,.9*t,{theta1:20,theta2:200,arrow:"cw"}))}},Fs=class extends sr{constructor(e={}){super(e);let t=.25;this.segments.push(new p([[t,0],[1-t,0]],{arrow:"->"}))}},$s=class extends un{constructor(e={}){super(e);let t=e.tuneup??!0;this.segments.push(new p([[-.1,-.5],[.75,.5]],{arrow:"->"})),this.anchors.tune=[.325,t?.5:-.5]}};var Jc={};$a(Jc,{Breadboard:()=>Vc,CapacitorCeramic:()=>Xc,CapacitorElectrolytic:()=>Hc,CapacitorMylar:()=>Yc,DIP:()=>Wc,Diode:()=>Nc,ElementPictorial:()=>Ta,FritzingPart:()=>Uc,INCH:()=>Ce,LED:()=>qs,LEDBlue:()=>jc,LEDGreen:()=>$c,LEDOrange:()=>Oc,LEDWhite:()=>qc,LEDYellow:()=>Fc,MILLIMETER:()=>g2,PINSPACING:()=>ee,Resistor:()=>Dc,TO92:()=>Gc,fritzParts:()=>y2,parseSizeToUnits:()=>w2,resistorColors:()=>v1});var js=class extends N{constructor(e,t,n,s={}){super(s);let{xy:i,imgfmt:o,zorder:a,...l}=s;this.segments.push(new Br(e,{xy:i??[0,0],width:t,height:n,zorder:a??1,imgfmt:o})),this.elmParams.theta=0;let h=t/2,c=n/2,m=(i?.[0]??0)+h,f=(i?.[1]??0)+c;this.anchors.center=[m,f],this.anchors.N=[m,f+c],this.anchors.S=[m,f-c],this.anchors.E=[m+h,f],this.anchors.W=[m-h,f]}};var Ce=3.5,g2=Ce/25.4,ee=.1*Ce,Pa="#333",x1="#777",Lt="#A0A0A0",b2=96;function w2(r){return x2(r)/b2*Ce}function x2(r){let e=r.match(/^([0-9.]+)\s*(px|pt|in|mm|cm|pc|em|ex|%)?$/i);if(!e)return 0;let t=parseFloat(e[1]);switch((e[2]??"px").toLowerCase()){case"px":return t;case"pt":return t*(96/72);case"in":return t*96;case"mm":return t*(96/25.4);case"cm":return t*(96/2.54);case"pc":return t*16;default:return t}}var Lc={0:"black",1:"brown",2:"red",3:"orange",4:"yellow",5:"green",6:"blue",7:"violet",8:"gray",9:"white",[-1]:"gold",[-2]:"silver",[-3]:"pink"},v2={1:"brown",2:"red","0.05":"orange","0.02":"yellow","0.5":"green","0.25":"blue","0.1":"violet","0.01":"gray",5:"gold",10:"silver"};function v1(r,e){let t=Math.floor(Math.log10(r))-1,n=r/10**t;n<10&&(t-=1,n=r/10**t);let s=Math.floor(n/10),i=Math.floor(n%10),o=e!==void 0?v2[String(e)]:void 0;return[Lc[s],Lc[i],Lc[t],o]}var Ta=class extends se{constructor(e={}){super(e),Object.assign(this.defaults,{leadcolor:Lt,lw:3})}},Dc=class extends Ta{constructor(e=1e3,t,n={}){super(n),Object.assign(this.defaults,{fill:"blanchedalmond"});let s=ee,i=ee/2,o=i*.9;this.segments.push(new p([[0,0],[NaN,NaN],[i*3+s,0]])),this.segments.push(new ut(["M",[0,0],"Q",[0,i],[i,i],"Q",[i*1.25,i],[i*1.5,o],"L",[i*1.5+s,o],"Q",[i*1.75+s,i],[i*2+s,i],"Q",[i*3+s,i],[i*3+s,0],"Q",[i*3+s,-i],[i*2+s,-i],"Q",[i*1.75+s,-i],[i*1.5+s,-o],"L",[i*1.5,-o],"Q",[i*1.25,-i],[i,-i],"Q",[0,-i],[0,0],"Z"],{color:"black",lw:1}));let a=.16,l=.32,h=.48,c=.68,m=.08,[f,g,b,v]=v1(e,t);this.segments.push(new U([[a,o],[a,-o],[a+m,-o],[a+m,o]],{fill:f,lw:.1,zorder:2})),this.segments.push(new U([[l,o],[l,-o],[l+m,-o],[l+m,o]],{fill:g,lw:.1,zorder:2})),this.segments.push(new U([[h,o],[h,-o],[h+m,-o],[h+m,o]],{fill:b,lw:.1,zorder:2})),v&&this.segments.push(new U([[c,o],[c,-o],[c+m,-o],[c+m,o]],{fill:v,lw:.1,zorder:2}))}},Nc=class extends Ta{constructor(e={}){super(e),Object.assign(this.defaults,{fill:Pa,stripe_color:"silver"});let t=ee/2,n=ee*2.5,s=n*.78,i=.08,o=this.params.stripe_color??"silver";Vr(o),this.segments.push(new p([[0,0],[NaN,NaN],[n,0]])),this.segments.push(new U([[0,t],[n,t],[n,-t],[0,-t]],{closed:!0,lw:1,color:"black",zorder:2})),this.segments.push(new U([[s,t],[s+i,t],[s+i,-t],[s,-t]],{closed:!0,lw:1,color:"none",fill:o,zorder:2}))}},qs=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{lead_length:ee*5,fill:"#dd4433",theta:0});let t=.197*Ce,n=.338*Ce,s=this.params.lead_length??ee*5,i=ee*5;this.segments.push(new p([[0,0],[0,s]],{color:Lt,lw:4})),this.segments.push(new p([[ee,0],[ee,s-i*.3],[ee*.6,s-i*.2],[ee*.6,s]],{color:Lt,lw:4}));let o=t*.8,a=ee/2-t/2,l=ee/2,h=s+n;this.segments.push(new ut(["M",[a,s],"Q",[l,s-i*.2],[a+t,s],"L",[a+t,h-o],"C",[a+t,h],[a,h],[a,h-o],"Z"],{color:"none"}));let c=.039*Ce;this.segments.push(new ut(["M",[a,s+c/2],"Q",[l*.5,s-i*.16+c],[a+t*.7,s-i*.03],"L",[a+t,s+c/2]],{color:"#FFFFFF55",lw:2}));let m=a+.03*Ce;this.segments.push(new ut(["M",[m,s+c*2],"L",[m,h-o],"Q",[m,h-o+.04*Ce],[m+.04*Ce,h-o+.07*Ce]],{color:"#FFFFFF55",lw:3}))}},Oc=class extends qs{constructor(e={}){super(e),Object.assign(this.defaults,{fill:"#efa207"})}},Fc=class extends qs{constructor(e={}){super(e),Object.assign(this.defaults,{fill:"#f1de0f"})}},$c=class extends qs{constructor(e={}){super(e),Object.assign(this.defaults,{fill:"#4be317"})}},jc=class extends qs{constructor(e={}){super(e),Object.assign(this.defaults,{fill:"#3892bc"})}},qc=class extends qs{constructor(e={}){super(e),Object.assign(this.defaults,{fill:"#e5e5e5"})}},Hc=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{fill:"#303b91",lead_length:.2*Ce,cap_color:"#CCC",stripe_color:"#dff1f6",theta:0});let t=ee*1.7,n=.3*Ce,s=this.params.lead_length??.2*Ce;this.segments.push(new p([[0,0],[0,s]],{color:Lt,lw:4})),this.segments.push(new p([[ee,0],[ee,s]],{color:Lt,lw:4}));let i=ee*2,o=i*.3,a=ee/2-t/2,l=ee/2,h=s+n;this.segments.push(new ut(["M",[a,s],"Q",[l,s-i*.3],[a+t,s],"L",[a+t,h-o],"Q",[l,h],[a,h-o],"Z"],{color:"none"}));let c=this.params.cap_color??"#CCC";this.segments.push(new xe([l,h-o-.01*Ce],t-.03*Ce,o*.9,{theta1:0,theta2:360,fill:c,color:"none",lw:.5,zorder:2}));let m=.039*Ce/2;this.segments.push(new ut(["M",[a,s+m],"Q",[l,s-i*.1],[a+t,s+m]],{color:"#FFFFFF99",fill:"none",lw:1.5}));let f=this.params.stripe_color??"#dff1f6",g=a+.03*Ce;this.segments.push(new ut(["M",[g,s+m],"L",[g,h-o*2]],{color:f,fill:"none",lw:3}))}},Yc=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{fill:"#8c2510",lead_length:.4*Ce,theta:0});let t=ee*1.75,n=t*.75,s=ee/2,i=s-t/2,o=this.params.lead_length??.4*Ce;this.segments.push(new p([[0,0],[0,o]],{color:Lt,lw:4})),this.segments.push(new p([[ee,0],[ee,o]],{color:Lt,lw:4}));let a=.02*Ce;this.segments.push(new ut(["M",[i,o],"Q",[i-a,o+n/2],[i,o+n],"Q",[s,o+n+a],[i+t,o+n],"Q",[i+t+a,o+n/2],[i+t,o],"Q",[s,o+a/2],[i,o],"Z"],{color:"none"}));let l=o+n-.025*Ce;this.segments.push(new p([[-.01*Ce,l],[ee*.8,l]],{color:"#FFFFFF44",lw:3}))}},Xc=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{fill:"#e2800b",radius:.1*Ce,lead_length:.4*Ce,theta:0});let t=this.params.radius??.1*Ce,n=this.params.lead_length??.4*Ce,s=[ee/2,n+t-.05*Ce];this.segments.push(new p([[0,0],[0,n]],{color:Lt,lw:4})),this.segments.push(new p([[ee,0],[ee,n]],{color:Lt,lw:4})),this.segments.push(new D(s,t,{color:"none",zorder:2})),this.segments.push(new xe(s,t*2*.7,t*2*.7,{theta1:100,theta2:200,color:"#FFFFFF44",zorder:2}))}},Gc=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{theta:0});let t=.175*Ce,n=.17*Ce*.9,s=ee*1.2,i=ee*1.3,o=ee-t/2,a=ee;this.segments.push(new p([[0,0],[0,ee*.8],[ee/2,i]],{color:Lt,lw:4})),this.segments.push(new p([[a,0],[a,i]],{color:Lt,lw:4})),this.segments.push(new p([[ee*2,0],[ee*2,ee*.8],[3*ee/2,i]],{color:Lt,lw:4})),this.segments.push(new U([[o,i],[o+t,i],[o+t,i+n],[o,i+n]],{fill:Pa,lw:1,color:x1,zorder:2})),this.segments.push(new xe([a,i+n],t,s,{theta1:0,theta2:180,fill:Pa,lw:1,color:x1,zorder:2})),this.anchors.pin1=[0,0],this.anchors.pin2=[ee,0],this.anchors.pin3=[ee*2,0],this.anchors.case_center=[a,i+n/2],this.elmParams.lblloc="case_center",this.elmParams.lblalign=["center","center"]}},Wc=class extends N{constructor(e=8,t=!1,n={}){super(n),Object.assign(this.defaults,{theta:0});let s=e;s%2!==0&&(s+=1);let i=t?6*ee:3*ee,o=ee*.25,a=ee*.25,l=(s/2-1)*ee,h=i/2,c=ee*.75,m=a,f=i-a,g=5;for(let b=0;b<s/2;b++)this.segments.push(new p([[0,-b*ee],[m,-b*ee]],{color:Lt,lw:g,zorder:1})),this.segments.push(new p([[f,-b*ee],[f+a,-b*ee]],{color:Lt,lw:g,zorder:1})),this.anchors[`pin${b+1}`]=[0,-b*ee],this.anchors[`pin${s-b}`]=[f+a,-b*ee];this.segments.push(new U([[a,o],[f,o],[f,-o-l],[a,-o-l]],{fill:Pa,lw:1,color:"#444"})),this.segments.push(new xe([h,o],c,c,{theta1:180,theta2:0,lw:1,color:"#777",fill:"#555"})),this.elmParams.lblloc="center",this.elmParams.lblrotate=!0,this.elmParams.lblofst=0}},Vc=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{color:"#DDD",fill:"#F8F8F5",shadow_color:"#E5E5E5",text_color:"#666"});let t=.02,n=.1,s=this.params.shadow_color??"#E5E5E5",i=this.params.text_color??"#666";Vr(s),Vr(i);let o=(k,M)=>{this.segments.push(new U([[k-n,M+n],[k+n,M+n],[k+n,M-n]],{fill:!0,color:s,lw:2})),this.segments.push(new U([[k-t,M-t],[k-t,M+t],[k+t,M+t],[k+t,M-t]],{fill:!0,color:Pa,lw:2}))},a=30,l=5,h=.37*Ce,c=(h-ee)/2,m=2.1*Ce,f=3.3*Ce,g=1.5*c,b=-c,v=b+m;this.segments.push(new U([[b,g],[v,g],[v,g-f],[b,g-f]],{lw:2}));let x=0,S=0;for(let k=0;k<2;k++)for(let M=0;M<a;M++){if(M%6===0)continue;let _=[x,S-M*ee],B=[x+ee,S-M*ee];o(..._),o(...B),this.anchors[`L1_${M}`]=_,this.anchors[`L2_${M}`]=B}x=v-c;for(let k=0;k<2;k++)for(let M=0;M<a;M++){if(M%6===0)continue;let _=[x,S-M*ee],B=[x-ee,S-M*ee];o(..._),o(...B),this.anchors[`R1_${M}`]=B,this.anchors[`R2_${M}`]=_}x=h;for(let k=0;k<l;k++){let M=String.fromCharCode(65+k);this.segments.push(new W([x+k*ee,S+ee],M,{fontsize:8,rotation:0,align:["center","center"],color:i,zorder:1}));for(let _=0;_<a;_++){let B=[x+k*ee,S-_*ee];o(...B),this.anchors[`${M}${_+1}`]=B}}for(let k=0;k<l;k++){let M=String.fromCharCode(70+k);this.segments.push(new W([x+ee*7+k*ee,S+ee],M,{fontsize:8,rotation:0,align:["center","center"],color:i,zorder:1}));for(let _=0;_<a;_++){let B=[x+ee*7+k*ee,S-_*ee];o(...B),this.anchors[`${M}${_+1}`]=B}}for(let k=0;k<a;k++)this.segments.push(new W([x-ee,S-k*ee-.04],String(k+1),{fontsize:8,rotation:0,align:["center","bottom"],color:i,zorder:1})),this.segments.push(new W([x+ee*12,S-k*ee-.04],String(k+1),{fontsize:8,rotation:0,align:["center","bottom"],color:i,zorder:1}));this.segments.push(new p([[b+c*.4,g-ee*2],[b+c*.4,g-f+ee]],{color:"red",lw:.5})),this.segments.push(new p([[b+h-c*.4,g-ee*2],[b+h-c*.4,g-f+ee]],{color:"blue",lw:.5})),this.segments.push(new p([[v-c*.4,g-ee*2],[v-c*.4,g-f+ee]],{color:"blue",lw:.5})),this.segments.push(new p([[v-h+c*.4,g-ee*2],[v-h+c*.4,g-f+ee]],{color:"red",lw:.5}))}},Uc=class extends js{constructor(t,n,s,i,o,a={}){super(t,n,s,{imgfmt:"svg",...a});z(this,"info");if(this.info=o,i)for(let[l,h]of Object.entries(i))this.anchors[l]=h}};function y2(r){throw new Error("fritzParts requires a .fzpz zip parser. Use a library like 'jszip' and pass the extracted SVG/anchors to FritzingPart directly.")}var Pe=class extends se{constructor(e={}){let{arrow:t,...n}=e;super(n),Object.assign(this.defaults,{arrowwidth:.15,arrowlength:.25});let s=this.params.arrowwidth,i=this.params.arrowlength;this.segments.push(new p([[0,0]],{arrow:t,arrowwidth:s,arrowlength:i}))}};var y1=H,di=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{dy:.6,to:[1,1]})}toXY(e){return this.userParams.to=e,this}delta(e=0,t=0){return this.userParams.delta=[e,t],this}_place(e,t,n){this.dwgParams={...n},this._positioned||this._position(),this.elmParams.theta=0;let s=this.params.at!==void 0?A.fromXY(this.params.at):A.fromXY(e),i=this.params.to!==void 0?A.fromXY(this.params.to):A.fromXY(e),o=this.params.delta,a=this.params.n??1,l=this.params.dy??.6,h=this.params.xstart,c=this.params.arrow,m,f;if(o!==void 0?[m,f]=o:(m=i.x!==void 0?i.x-s.x:this.params.to[0]-(this.params.at!==void 0?this.params.at[0]:e[0]),f=i.x!==void 0?i.y-s.y:this.params.to[1]-(this.params.at!==void 0?this.params.at[1]:e[1])),Math.abs(f)<.05)for(let g=0;g<a;g++){let b=-g*l;this.segments.push(new p([[0,b],[m,b]],{arrow:c}))}else{let g;h!==void 0?f>0?g=m*h:g=m*h-l-l*(a-1)*h:m>0?g=m/2-l*(a-1)/2:g=m/2+l*(a-1)/2;for(let b=0;b<a;b++){let v=-b*l,x;f>0?x=m>0?g+l*b:g-l*b:x=m>0?g+(a-b)*l:g-(a-b)*l,this.segments.push(new p([[0,v],[x,v],[x,v+f],[m,v+f]],{arrow:c}))}}return super._place(e,t,n)}},Hs=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{dy:.6,to:[3,-2],theta:0,n:1})}toXY(e){return this.userParams.to=e,this}delta(e=0,t=0){return this.userParams.delta=[e,t],this}_place(e,t,n){this.dwgParams={...n},this._positioned||this._position();let s=this.params.at!==void 0?A.fromXY(this.params.at):A.fromXY(e),i=this.params.delta,o=this.params.to,a=this.params.n??1,l=this.params.dy??.6,h=this.params.arrow,c,m;i!==void 0?[c,m]=i:(c=o[0]-s.x,m=o[1]-s.y);let f=0;for(let g=0;g<a;g++){let b=-g*l;m>0?f=c<0?c-g*l:c+g*l:f=c>0?c+(a-g-1)*l:c-(a-g-1)*l,this.segments.push(new p([[0,b],[f,b],[f,m]],{arrow:h}))}return this.anchors.mid=[c/2,0],this.elmParams.lblloc="mid",this.elmParams.drop=[f,m],this.elmParams.droptheta=m>0?90:-90,super._place(e,t,n)}},pi=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{pinspacing:.6,style:"round",numbering:"lr",pinfontsizeleft:9,pinfontsizeright:9,edge:.3,pinfill:"bg",shownumber:!1,pinalignleft:"bottom",pinalignright:"bottom",pinrad:.1});let t=e.rows??4,n=e.cols??1,s=e.pinsleft??[],i=e.pinsright??[];this.elmParams.d="right";let o=this.params.pinspacing??.6,a=this.params.edge??.3,l=this.params.pinrad??.1,h=this.params.style??"round",c=this.params.numbering??"lr",m=this.params.shownumber??!1,f=this.params.pinfill??"bg",g=this.params.pinfontsizeleft??9,b=this.params.pinfontsizeright??9,v=this.params.pinalignleft??"bottom",x=(n-1)*o+a*2,S=(t-1)*o+a*2;this.segments.push(new U([[0,0],[0,S],[x,S],[x,0]]));for(let k=0;k<t;k++)for(let M=0;M<n;M++){let _=M*o+a,B=S-k*o-a,$=[_,B];h==="square"?this.segments.push(new U([[_-l,B-l],[_+l,B-l],[_+l,B+l],[_-l,B+l]],{fill:"bg",zorder:4})):h==="screw"?(this.segments.push(new D($,l*1.75,{fill:f,zorder:4})),this.segments.push(new p([[_+l,B+l],[_-l,B-l]],{zorder:5}))):this.segments.push(new D($,l,{fill:f,zorder:4}));let Y;if(c==="lr"||c===!0?Y=String(k*n+M+1):c==="ud"?Y=String(k+M*t+1):Y=M%2?String(t*M+(t-k)):String(k+1),this.anchors[`pin${Y}`]=$,m){let Z=[M%2?x+.05:-.05,B],L=M%2?"left":"right";this.segments.push(new W(Z,Y,{fontsize:g,align:[L,"bottom"]}))}if(s.length>0&&(n===1||!(M%2))){let Z=[-.05,B];this.segments.push(new W(Z,s[k]??"",{fontsize:g,align:["right",v]}))}if(i.length>0&&(n===1||M%2)){let Z=[x+.05,B];this.segments.push(new W(Z,i[k]??"",{fontsize:b,align:["left",v]}))}}}},fi=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{pinspacing:.6,pinrad:.1,theta:0});let t=this.params.pinrad??.1,n=this.params.pinspacing??.6,s=t*2.5;this.segments.push(new U([[-s,-s],[n+s,-s],[n+s,s],[-s,s]]))}},gi=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{dy:.6,lwbus:4,l:3,slantx:.5}),this.elmParams.theta=0;let t=e.n??1,n=e.up??!0,s=this.params.l??3,i=this.params.dy??.6,o=this.params.lwbus??4,a=this.params.slantx??.5,l=n?a:-a;for(let h=0;h<t;h++){let c=-h*i;this.segments.push(new p([[0,c],[s-a,c],[s,c+l]])),this.anchors[`pin${h+1}`]=[0,c]}this.segments.push(new p([[s,a],[s,l-t*i]],{lw:o})),this.elmParams.drop=[s,a],this.anchors.start=[s,a],this.anchors.end=[s,l-t*i]}},bi=class extends Pe{constructor(e={}){super(e),Object.assign(this.defaults,{lw:4})}},a0=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{pinspacing:.6,edge:.3,pinfill:"bg",pinrad:.1,number:!1,theta:0});let t=this.params.pinspacing??.6,n=this.params.edge??.3,s=this.params.pinfill??"bg",i=this.params.pinrad??.1,o=this.params.number??!1,a=t+n*2,l=4*t+n*2,h=l+.5;this.segments.push(new U([[0,0],[0,l],[a,h],[a,-.5]],{cornerradius:.25}));for(let c=0;c<4;c++){let m=[n,l-(c+.5)*t-n];this.segments.push(new D(m,i,{fill:s,zorder:4})),this.anchors[`pin${9-c}`]=m,o&&this.segments.push(new W([m[0],m[1]+i],String(9-c),{fontsize:9,align:["center","bottom"]}))}for(let c=0;c<5;c++){let m=[n+t,h-(c+.75)*t-n];this.segments.push(new D(m,i,{fill:s,zorder:4})),this.anchors[`pin${5-c}`]=m,o&&this.segments.push(new W([m[0],m[1]+i],String(5-c),{fontsize:9,align:["center","bottom"]}))}}},wi=class extends a0{},xi=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{pinspacing:.6,edge:.3,pinfill:"bg",number:!1,pinrad:.1,theta:0});let t=this.params.pinspacing??.6,n=this.params.edge??.3,s=this.params.pinfill??"bg",i=this.params.pinrad??.1,o=this.params.number??!1,a=t+n*2,l=12*t+n*2,h=l+.5;this.segments.push(new U([[0,0],[0,l],[a,h],[a,-.5]],{cornerradius:.25}));for(let c=0;c<12;c++){let m=[n,l-(c+.5)*t-n];this.segments.push(new D(m,i,{fill:s,zorder:4})),this.anchors[`pin${25-c}`]=m,o&&this.segments.push(new W([m[0],m[1]+i],String(25-c),{fontsize:9,align:["center","bottom"]}))}for(let c=0;c<13;c++){let m=[n+t,h-(c+.75)*t-n];this.segments.push(new D(m,i,{fill:s,zorder:4})),this.anchors[`pin${13-c}`]=m,o&&this.segments.push(new W([m[0],m[1]+i],String(13-c),{fontsize:9,align:["center","bottom"]}))}}},vi=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{pinspacing:.6,edge:.3,pinfill:"bg",pinrad:.1,number:!1,theta:0});let t=this.params.pinspacing??.6,n=this.params.edge??.3,s=this.params.pinfill??"bg",i=this.params.pinrad??.1,o=this.params.number??!1,a=t+n*2,l=7*t+n*2,h=l+.5;this.segments.push(new U([[0,0],[0,l],[a,h],[a,-.5]],{cornerradius:.25}));for(let c=0;c<7;c++){let m=[n,l-(c+.5)*t-n];this.segments.push(new D(m,i,{fill:s,zorder:4})),this.anchors[`pin${15-c}`]=m,o&&this.segments.push(new W([m[0],m[1]+i],String(15-c),{fontsize:9,align:["center","bottom"]}))}for(let c=0;c<8;c++){let m=[n+t,h-(c+.75)*t-n];this.segments.push(new D(m,i,{fill:s,zorder:4})),this.anchors[`pin${8-c}`]=m,o&&this.segments.push(new W([m[0],m[1]+i],String(8-c),{fontsize:9,align:["center","bottom"]}))}}},yi=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{pinspacing:.6,edge:.3,pinfill:"bg",pinrad:.1,number:!1,theta:0});let t=this.params.pinspacing??.6,n=this.params.edge??.3,s=this.params.pinfill??"bg",i=this.params.pinrad??.1,o=this.params.number??!1,a=t+n*2,l=18*t+n*2,h=l+.5;this.segments.push(new U([[0,0],[0,l],[a,h],[a,-.5]],{cornerradius:.25}));for(let c=0;c<18;c++){let m=[n,l-(c+.5)*t-n];this.segments.push(new D(m,i,{fill:s,zorder:4})),this.anchors[`pin${37-c}`]=m,o&&this.segments.push(new W([m[0],m[1]+i],String(37-c),{fontsize:9,align:["center","bottom"]}))}for(let c=0;c<19;c++){let m=[n+t,h-(c+.75)*t-n];this.segments.push(new D(m,i,{fill:s,zorder:4})),this.anchors[`pin${19-c}`]=m,o&&this.segments.push(new W([m[0],m[1]+i],String(19-c),{fontsize:9,align:["center","bottom"]}))}}},Si=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{pinspacing:.6,edge:.3,pinfill:"bg",pinrad:.1,number:!1,theta:0});let t=this.params.pinspacing??.6,n=this.params.edge??.3,s=this.params.pinfill??"bg",i=this.params.pinrad??.1,o=this.params.number??!1,a=t*2+n*2,l=16*t+n*2,h=l+.5;this.segments.push(new U([[0,0],[0,l],[a,h],[a,-.5]],{cornerradius:.25}));for(let c=0;c<17;c++){let m=[n,h-(c+.75)*t-n];this.segments.push(new D(m,i,{fill:s,zorder:4})),this.anchors[`pin${50-c}`]=m,o&&this.segments.push(new W([m[0],m[1]+i],String(50-c),{fontsize:9,align:["center","bottom"]}))}for(let c=0;c<16;c++){let m=[n+t,l-(c+.5)*t-n];this.segments.push(new D(m,i,{fill:s,zorder:4})),this.anchors[`pin${33-c}`]=m,o&&this.segments.push(new W([m[0],m[1]+i],String(33-c),{fontsize:9,align:["center","bottom"]}))}for(let c=0;c<17;c++){let m=[n+t*2,h-(c+.75)*t-n];this.segments.push(new D(m,i,{fill:s,zorder:4})),this.anchors[`pin${17-c}`]=m,o&&this.segments.push(new W([m[0],m[1]+i],String(17-c),{fontsize:9,align:["center","bottom"]}))}}},ki=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{radius:.4,radiusinner:.12,fillinner:"bg"});let t=this.params.radius??.4,n=this.params.radiusinner??.12,s=this.params.fillinner??"bg";this.segments.push(new D([0,0],t)),this.segments.push(new D([0,0],n,{fill:s,zorder:4})),this.anchors.center=[0,0],this.anchors.N=[0,t],this.anchors.S=[0,-t],this.anchors.E=[t,0],this.anchors.W=[-t,0]}},Mi=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{pluggap:.18});let t=this.params.pluggap??.18;this.segments.push(new p([[0,0],[1,0],y1,[1-.25,.25],[1,0],[1-.25,-.25]])),this.elmParams.drop=[1+t,0]}},zi=class extends N{constructor(e={}){super(e),this.segments.push(new p([[0,0],[-.25,.25],y1,[-.25,-.25],[0,0],[1,0]])),this.elmParams.drop=[1,0]}},Ei=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{r:.18,open:!0,fill:"bg",drop:[0,0],theta:0,zorder:4});let t=this.params.r??.18;this.anchors.start=[0,0],this.anchors.center=[0,0],this.anchors.end=[0,0];let n=this.params.open??!0;this.elmParams.fill=n?"bg":!0,this.segments.push(new D([0,0],t));let s=1,i=2;this.segments.push(new p([[-s*t,-i*t],[s*t,i*t]]))}};var gr=class{constructor(e,...t){z(this,"node");z(this,"children");this.node=e,this.children=t}[Symbol.iterator](){return this.children[Symbol.iterator]()}},l0=class r{constructor(e,t=null,n=0,s=1){z(this,"x",-1);z(this,"y");z(this,"node");z(this,"children");z(this,"parent");z(this,"thread",null);z(this,"mod",0);z(this,"ancestor",this);z(this,"change",0);z(this,"shift",0);z(this,"number");z(this,"_lmostSibling",null);this.y=n,this.node=e.node,this.parent=t,this.number=s,this.children=e.children.map((i,o)=>new r(i,this,n+1,o+1)),this.ancestor=this}left(){return this.thread??(this.children.length>0?this.children[0]:null)}right(){return this.thread??(this.children.length>0?this.children[this.children.length-1]:null)}lbrother(){let e=null;if(this.parent)for(let t of this.parent.children){if(t===this)return e;e=t}return e}get lmostSibling(){return!this._lmostSibling&&this.parent&&this!==this.parent.children[0]&&(this._lmostSibling=this.parent.children[0]),this._lmostSibling}};function M1(r,e){r.x+=e;for(let t of r.children)M1(t,e)}function S2(r){let e=0,t=0;for(let n=r.children.length-1;n>=0;n--){let s=r.children[n];s.x+=e,s.mod+=e,t+=s.change,e+=s.shift+t}}function k2(r,e,t){return e.parent&&e.parent.children.includes(r.ancestor)?r.ancestor:t}function M2(r,e,t){let n=e.number-r.number;e.change-=t/n,e.shift+=t,r.change+=t/n,e.x+=t,e.mod+=t}function z2(r,e,t){let n=r.lbrother();if(n!==null){let s=r,i=r,o=n,a=r.lmostSibling,l=r.mod,h=r.mod,c=o.mod,m=a.mod;for(;o.right()&&s.left();){o=o.right(),s=s.left(),a=a.left(),i=i.right(),i.ancestor=r;let f=o.x+c-(s.x+l)+t;f>0&&(M2(k2(o,r,e),r,f),l+=f,h+=f),c+=o.mod,l+=s.mod,m+=a.mod,h+=i.mod}o.right()&&!i.right()?(i.thread=o.right(),i.mod+=c-h):(s.left()&&!a.left()&&(a.thread=s.left(),a.mod+=l-m),e=r)}return e}function z1(r,e=1){if(r.children.length===0)r.lmostSibling?r.x=r.lbrother().x+e:r.x=0;else{let t=r.children[0];for(let i of r.children)z1(i),t=z2(i,t,e);S2(r);let n=(r.children[0].x+r.children[r.children.length-1].x)/2,s=r.lbrother();s?(r.x=s.x+e,r.mod=r.x-n):r.x=n}return r}function E1(r,e=0,t=0,n=null){r.x+=e,r.y=t,(n===null||r.x<n)&&(n=r.x);for(let s of r.children)n=E1(s,e+r.mod,t+1,n);return n}function Ra(r){let e=z1(new l0(r)),t=E1(e);return t<0&&M1(e,-t),e}var E2=new Set(["and","or","not","nand","nor","xor","xnor","true","false"]),P1=(o=>(o[o.IDENT=0]="IDENT",o[o.KEYWORD=1]="KEYWORD",o[o.LPAREN=2]="LPAREN",o[o.RPAREN=3]="RPAREN",o[o.SYMBOL=4]="SYMBOL",o[o.EOF=5]="EOF",o))(P1||{});function P2(r){let e=[],t=0;for(;t<r.length;){let n=r[t];if(/\s/.test(n)){t++;continue}if(n==="("){e.push({tt:2,val:"("}),t++;continue}if(n===")"){e.push({tt:3,val:")"}),t++;continue}if("&|+~\xAC\u2227\u2228\u2295\u22BB".includes(n)){e.push({tt:4,val:n}),t++;continue}if(/[$_a-zA-Z]/.test(n)){let s="";for(;t<r.length&&/[$_a-zA-Z0-9]/.test(r[t]);)s+=r[t],t++;E2.has(s)?e.push({tt:1,val:s}):e.push({tt:0,val:s});continue}throw new Error(`logicparse: unexpected character '${n}'`)}return e.push({tt:5,val:""}),e}var Kc=class{constructor(e){z(this,"tokens");z(this,"pos",0);this.tokens=e}peek(){return this.tokens[this.pos]}advance(){return this.tokens[this.pos++]}expect(e,t){let n=this.advance();if(n.tt!==e||t!==void 0&&n.val!==t)throw new Error(`logicparse: expected ${t??P1[e]}, got '${n.val}'`);return n}parse(){let e=this.xorExpr();if(this.peek().tt!==5)throw new Error(`logicparse: unexpected token '${this.peek().val}'`);return e}isNotOp(e){return e.tt===1&&e.val==="not"||e.tt===4&&(e.val==="~"||e.val==="\xAC")}isAndOp(e){return e.tt===1&&(e.val==="and"||e.val==="nand")||e.tt===4&&(e.val==="&"||e.val==="\u2227")}isOrOp(e){return e.tt===1&&(e.val==="or"||e.val==="nor")||e.tt===4&&(e.val==="|"||e.val==="\u2228"||e.val==="+")}isXorOp(e){return e.tt===1&&(e.val==="xor"||e.val==="xnor")||e.tt===4&&(e.val==="\u2295"||e.val==="\u22BB")}xorExpr(){let e=this.orExpr();for(;this.isXorOp(this.peek());){let t=this.advance(),n=this.orExpr();e={kind:"binary",op:t.val,left:e,right:n}}return e}orExpr(){let e=this.andExpr();for(;this.isOrOp(this.peek());){let t=this.advance(),n=this.andExpr();e={kind:"binary",op:t.val,left:e,right:n}}return e}andExpr(){let e=this.unary();for(;this.isAndOp(this.peek());){let t=this.advance(),n=this.unary();e={kind:"binary",op:t.val,left:e,right:n}}return e}unary(){return this.isNotOp(this.peek())?(this.advance(),{kind:"unary",operand:this.unary()}):this.atom()}atom(){let e=this.peek();if(e.tt===2){this.advance();let t=this.xorExpr();return this.expect(3,")"),t}if(e.tt===0||e.tt===1&&(e.val==="true"||e.val==="false"))return this.advance(),{kind:"ident",name:e.val};throw new Error(`logicparse: unexpected token '${e.val}'`)}};function Zl(r,e){return r.kind==="binary"&&r.op===e?[...Zl(r.left,e),...Zl(r.right,e)]:[r]}function S1(r){return{"&":"and","\u2227":"and","|":"or","\u2228":"or","+":"or","\u2295":"xor","\u22BB":"xor"}[r]??r}var T2={and:"nand",or:"nor",not:"buf",nand:"and",nor:"or",buf:"not",xor:"xnor",xnor:"xor"};function Pi(r){if(r.kind==="ident")return new gr(r.name);if(r.kind==="unary"){if(r.operand.kind==="ident")return new gr("not",Pi(r.operand));let n=r.operand;if(n.kind==="binary"){let s=S1(n.op),i=T2[s];if(i){let o=Zl(n,n.op);return new gr(i,...o.map(Pi))}}return n.kind==="unary"?Pi(n.operand):new gr("not",Pi(n))}let e=S1(r.op),t=Zl(r,r.op);return new gr(e,...t.map(Pi))}var T1={and:Bt,or:$t,not:Kt,buf:Jt};function R2(r,e){let t=T1[r];if(t)return new t(e);switch(r){case"nand":return Tn(e);case"nor":return Rn(e);case"xor":return An(e);case"xnor":return _n(e);default:return new Bt(e)}}function k1(r){return r in T1||["nand","nor","xor","xnor"].includes(r)}function A2(r,e=.7,t=2,n){let s=new lr;s.unit=t;let i=Ra(r);function o(a,l=0,h){let c=a.node==="not"||a.node==="buf",m={d:"r",at:[a.y*-t,-a.x*e],anchor:"end",l:t,...c?{}:{inputs:a.children.length}},f=R2(a.node,m);h&&f.label(h,{loc:"end"});for(let g=0;g<a.children.length;g++){let b=a.children[g],v=c?"start":`in${g+1}`;k1(b.node)||f.label(b.node,{loc:v})}s.add(f);for(let g=0;g<a.children.length;g++){let b=a.children[g],v=c?"start":`in${g+1}`;if(k1(b.node)){let x=o(b,l+1);s.add(new Hs({at:[f,v],to:x.anchors.end}))}}return f}return o(i,0,n),s}function Ql(r,e={}){let{gateW:t=2,gateH:n=.75,outlabel:s}=e,i=P2(r),o=new Kc(i).parse(),a=Pi(o);return A2(a,n,t,s)}var eh=.12,_2=.4,Ti=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{lead:!0,theta:0,drop:[0,0]});let n=this.params.lead!==!1?_2:0;this.segments.push(new p([[0,0],[0,-n],[-.25,-n],[.25,-n],H,[-.25*.7,-eh-n],[.25*.7,-eh-n],H,[-.25*.2,-eh*2-n],[.25*.2,-eh*2-n]])),this.anchors.start=[0,0],this.anchors.center=[0,0],this.anchors.end=[0,0]}};function R1(r="svg"){if(r==="matplotlib")throw new Error("@skillpet/circuit: use('matplotlib') is not supported; only 'svg' is available.")}function A1(r=!0,e=!0){kt({dwgbbox:r,elmbbox:e})}function _1(r="default"){switch(r){case"default":kt({bgcolor:"white",color:"black"});break;case"dark":kt({color:"white",bgcolor:"black"});break;case"solarizedd":kt({bgcolor:"#002b36",color:"#657b83"});break;case"solarizedl":kt({bgcolor:"#eee8d5",color:"#073642"});break;case"onedork":kt({bgcolor:"#373e4b",color:"#899ab8"});break;case"oceans16":kt({bgcolor:"#384151",color:"#CDD2E9"});break;case"monokai":kt({bgcolor:"#232323",color:"#BBBBBB"});break;case"gruvboxl":kt({bgcolor:"#ebdbb2",color:"#3c3836"});break;case"gruvboxd":kt({bgcolor:"#1d2021",color:"#d5c4a1"});break;case"grade3":kt({bgcolor:"#ffffff",color:"#3f3d46"});break;case"chesterish":kt({bgcolor:"#323A48",color:"#92A2BD"});break;default:throw new Error(`Unknown theme ${r}`)}}var Aa=class{constructor(){z(this,"_text","text");z(this,"_svg2",!0);z(this,"precision",3);z(this,"useBatik",!1)}get text(){return this._text}set text(e){this._text=e}get svg2(){return this._svg2}set svg2(e){this._svg2=e}},B1=new Aa;var $e=.25*.75,pt=.25*1.5,St=.25*.75,rt=class extends se{constructor(e={}){super(e),this.elmParams.theta=90,this.segments.push(new p([[0,0],[0,0],H,[1,0],[1,0]])),this.segments.push(new D([.5,0],.5))}},Ri=class extends rt{constructor(e={}){super(e);let t=.2;this.segments.push(new p([[.25,-t/2],[.25,t/2]])),this.segments.push(new p([[.75-t/2,0],[.75+t/2,0]])),this.segments.push(new p([[.75,-t/2],[.75,t/2]]))}},Ai=class extends rt{constructor(e={}){super(e),Object.assign(this.defaults,{arrowwidth:.15,arrowlength:.25,arrow_lw:void 0,arrow_color:void 0});let t=this.params;this.segments.push(new p([[.25,0],[.75,0]],{arrow:"->",arrowwidth:t.arrowwidth,arrowlength:t.arrowlength,lw:t.arrow_lw,color:t.arrow_color}))}},_i=class extends rt{constructor(e={}){super(e),Object.assign(this.defaults,{sin_lw:void 0,sin_color:void 0});let t=ze(-.25,.25,25),s=t.map(i=>.2*Math.sin((i-.25)*Math.PI*2/.5)+.5).map((i,o)=>[i,t[o]]);this.segments.push(new p(s,{lw:this.params.sin_lw,color:this.params.sin_color}))}},Bi=class extends rt{constructor(e={}){super(e),Object.assign(this.defaults,{pulse_lw:void 0,pulse_color:void 0});let t=.15,n=.4;this.segments.push(new p([[n,t*2],[n,t],[n+t,t],[n+t,-t],[n,-t],[n,-t*2]],{lw:this.params.pulse_lw,color:this.params.pulse_color}))}},Ci=class extends rt{constructor(e={}){super(e),Object.assign(this.defaults,{tri_lw:void 0,tri_color:void 0}),this.segments.push(new p([[.4,.25],[.7,0],[.4,-.25]],{lw:this.params.tri_lw,color:this.params.tri_color}))}},Ii=class extends rt{constructor(e={}){super(e),Object.assign(this.defaults,{ramp_lw:void 0,ramp_color:void 0}),this.segments.push(new p([[.4,.25],[.8,-.2],[.4,-.2]],{lw:this.params.ramp_lw,color:this.params.ramp_color}))}},Li=class extends rt{constructor(e={}){super(e),Object.assign(this.defaults,{square_lw:void 0,square_color:void 0}),this.segments.push(new p([[.5,.25],[.7,.25],[.7,0],[.3,0],[.3,-.25],[.5,-.25]],{lw:this.params.square_lw,color:this.params.square_color}))}},Ys=class extends se{constructor(e={}){super(e),this.elmParams.theta=90,this.segments.push(new p([[0,0],[.5,.5],[1,0],[.5,-.5],[0,0],H,[1,0]]))}},br=class extends Ys{constructor(e={}){super(e);let t=.2;this.segments.push(new p([[.25,-t/2],[.25,t/2]])),this.segments.push(new p([[.75-t/2,0],[.75+t/2,0]])),this.segments.push(new p([[.75,-t/2],[.75,t/2]]))}},wr=class extends Ys{constructor(e={}){super(e),Object.assign(this.defaults,{arrowwidth:.15,arrowlength:.25,arrow_lw:void 0,arrow_color:void 0});let t=this.params;this.segments.push(new p([[.25,0],[.75,0]],{arrow:"->",arrowwidth:t.arrowwidth,arrowlength:t.arrowlength,lw:t.arrow_lw,color:t.arrow_color}))}},Di=class extends se{constructor(e={}){super(e),this.segments.push(new p([[0,0],H,[$e,0]])),this.segments.push(new p([[0,pt],[0,-pt]])),this.segments.push(new p([[$e,St],[$e,-St]]))}},Ni=class extends se{constructor(e={}){super(e),this.segments.push(new p([[0,0],H,[$e*3,0]])),this.segments.push(new p([[0,pt],[0,-pt]])),this.segments.push(new p([[$e,St],[$e,-St]])),this.segments.push(new p([[$e*2,pt],[$e*2,-pt]])),this.segments.push(new p([[$e*3,St],[$e*3,-St]]))}},Oi=class extends se{constructor(e={}){super(e),this.segments.push(new p([[0,0],H,[$e*9,0]])),this.segments.push(new p([[0,pt],[0,-pt]])),this.segments.push(new p([[$e,St],[$e,-St]])),this.segments.push(new p([[$e*2,pt],[$e*2,-pt]])),this.segments.push(new p([[$e*3,St],[$e*3,-St]])),this.segments.push(new p([[$e*4,pt],[$e*4,-pt]])),this.segments.push(new p([[$e*5,St],[$e*5,-St]])),this.segments.push(new p([[$e*6,pt],[$e*6,-pt]])),this.segments.push(new p([[$e*7,St],[$e*7,-St]])),this.segments.push(new p([[$e*8,pt],[$e*8,-pt]])),this.segments.push(new p([[$e*9,St],[$e*9,-St]])),this.anchors.tap=[$e*4,pt]}},Fi=class extends rt{constructor(e={}){super(e),Object.assign(this.defaults,{arrowwidth:.15,arrowlength:.25,arrow_lw:void 0,arrow_color:void 0});let t=.25*.5,n=t+.15,s=.4,i=this.params;this.segments.push(new p([[s,t],[s,-t]])),this.segments.push(new p([[s+.2,n],[s+.2,-n]])),this.segments.push(new p([[0,0],[s,0],H,[s+.2,0],[1,0]]));let o=i.arrowwidth,a=i.arrowlength;this.segments.push(new p([[1.1,.9],[.8,.6]],{arrow:"->",arrowwidth:o,arrowlength:a,lw:i.arrow_lw,color:i.arrow_color})),this.segments.push(new p([[1.3,.7],[1,.4]],{arrow:"->",arrowwidth:o,arrowlength:a,lw:i.arrow_lw,color:i.arrow_color}))}},$i=class extends rt{constructor(e={}){super(e),this.segments.push(new W([.5,0],"V",{halign:"center",valign:"center"}))}},ji=class extends rt{constructor(e={}){super(e),this.segments.push(new W([.5,0],"I",{halign:"center",valign:"center"}))}},qi=class extends rt{constructor(e={}){super(e),this.segments.push(new W([.5,0],"A",{halign:"center",valign:"center"}))}},Hi=class extends rt{constructor(e={}){super(e),this.segments.push(new W([.5,0],"\u03A9",{halign:"center",valign:"center"}))}},Yi=class extends rt{constructor(e={}){super(e),Object.assign(this.defaults,{arrowwidth:.15,arrowlength:.25,arrow_lw:void 0,arrow_color:void 0});let t=this.params;this.segments.push(new p([[.25,.16],[.75,-.16]],{arrow:"->",arrowwidth:t.arrowwidth,arrowlength:t.arrowlength,lw:t.arrow_lw,color:t.arrow_color}))}},Xi=class extends rt{constructor(e={}){super(e),Object.assign(this.defaults,{filament_lw:void 0,filament_color:void 0});let t=.25,n=.7,s=ze(1.4,3.6*Math.PI,80),i=s.map(c=>t*c-n*Math.sin(c)),o=s.map(c=>t-n*Math.cos(c));i=i.map(c=>c-i[0]);let a=i[i.length-1];i=i.map(c=>c/a);let l=o.map(c=>(c-o[0])*.25),h=i.map((c,m)=>[c,l[m]]);this.segments.push(new p(h,{lw:this.params.filament_lw,color:this.params.filament_color}))}},Gi=class extends rt{constructor(e={}){super(e),Object.assign(this.defaults,{filament_lw:void 0,filament_color:void 0});let t=.5,n=this.params;this.segments.push(new p([[t-t/2**.5,-t/2**.5],[t+t/2**.5,t/2**.5]],{lw:n.filament_lw,color:n.filament_color})),this.segments.push(new p([[t-t/2**.5,t/2**.5],[t+t/2**.5,-t/2**.5]],{lw:n.filament_lw,color:n.filament_color}))}},Wi=class extends rt{constructor(e={}){super(e);let t=.25,n=.4;this.segments.push(new p([[n,t],[n,-t]])),this.segments.push(new p([[n+.2,t],[n+.2,-t]])),this.segments.push(new p([[0,0],[n,0],H,[n+.2,0],[1,0]])),this.segments.push(new D([n-.15,.2],.05,{fill:!0}))}},mn=class extends N{constructor(e={}){let{inputs:t,...n}=e,s=t!==!1;super(n),Object.assign(this.defaults,{width:1.5,corner:.2,input_ofst:[.4,.3],input_lw:1,input_rad:.1,input_fill:"none"});let i=this.params.width,o=this.params.corner,a=this.params.input_ofst,l=this.params.input_lw,h=this.params.input_rad;this.segments.push(new U([[0,0],[0,i],[i,i],[i,0]],{closed:!0,cornerradius:o})),s&&(this.segments.push(new D([a[0],a[1]],h,{lw:l,fill:this.params.input_fill,zorder:4})),this.segments.push(new D([i-a[0],a[1]],h,{lw:l,fill:this.params.input_fill,zorder:4}))),this.anchors.N=[i/2,i],this.anchors.S=[i/2,0],this.anchors.E=[i,i/2],this.anchors.W=[0,i/2],this.anchors.NE=[i,i],this.anchors.SE=[i,0],this.anchors.NW=[0,i],this.anchors.SW=[0,0],this.anchors.in1=[a[0],a[1]],this.anchors.in2=[i-a[0],a[1]],this.anchors.name=[i/2,0],this.elmParams.drop=this.anchors.in2}},Vi=class extends mn{constructor(e={}){super(e);let t=e.needle_percent??70;Object.assign(this.defaults,{needle_color:"black",needle_width:1.5,window_fill:"none"});let n=this.params.width,s=n/2,i=1.2,o=.86,a=.2;this.segments.push(new ut(["M",[s-n/3,i],"Q",[s,i+a],[s+n/3,i],"L",[s+n/4,o],"Q",[s,o+a*.7],[s-n/4,o],"Z"],{color:"black",fill:this.params.window_fill,lw:1}));let l=.94,h=1.2,c=(112-45*t/100)*Math.PI/180,m=[s+l*Math.cos(c),l*Math.sin(c)],f=[s+h*Math.cos(c),h*Math.sin(c)];this.segments.push(new p([m,f],{lw:this.params.needle_width,color:this.params.needle_color}))}},Ui=class extends mn{constructor(e={}){super(e);let t=e.signal??"none";Object.assign(this.defaults,{screen_fill:"none",screen_lw:1,grid:!0,grid_color:"#666666",grid_lw:.3,signal_lw:2,signal_color:"#e0213b"});let n=this.params.width,s=4,i=n*.15,o=n*.85,a=o-i,l=a/(s+1),h=l*3,c=n*.9,m=c-h;if(this.segments.push(new U([[i,m],[i,c],[o,c],[o,m]],{closed:!0,lw:this.params.screen_lw,fill:this.params.screen_fill})),this.params.grid){for(let f=0;f<s;f++){let g=i+(f+1)*l;this.segments.push(new p([[g,m],[g,c]],{lw:this.params.grid_lw,color:this.params.grid_color}))}for(let f=0;f<2;f++){let g=m+(f+1)*l;this.segments.push(new p([[i,g],[o,g]],{lw:this.params.grid_lw,color:this.params.grid_color}))}}if(t==="sine"){let f=ze(i,o,20),g=f.map(v=>m+h/2+Math.sin((v-i)/a*Math.PI*2)*(h/2)*.75),b=f.map((v,x)=>[v,g[x]]);this.segments.push(new p(b,{lw:this.params.signal_lw,color:this.params.signal_color}))}else if(t==="square"){let f=m+h/4,g=c-h/4,b=i+a/3-.1,v=i+a*2/3-.1,x=i+a-.1;this.segments.push(new p([[i,f],[b,f],[b,g],[v,g],[v,f],[x,f],[x,g],[o,g]],{lw:this.params.signal_lw,color:this.params.signal_color}))}else if(t==="triangle"){let f=m+h/4,g=c-h/4,b=i+a/3-.1,v=i+a*2/3-.1,x=i+a-.1;this.segments.push(new p([[i,f],[b,g],[v,f],[x,g],[o,g-.1]],{lw:this.params.signal_lw,color:this.params.signal_color}))}}},Ji=class extends mn{constructor(e={}){super(e),Object.assign(this.defaults,{screen_fill:"none",screen_lw:1});let t=this.params.width,n=t*.1,s=t*.9,i=t/3,o=t*.85,a=o-i;this.segments.push(new U([[n,a],[n,o],[s,o],[s,a]],{closed:!0,lw:this.params.screen_lw,fill:this.params.screen_fill})),this.anchors.display=[(n+s)/2,a]}};var th=.4,Ki=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{lead:!0,theta:0,drop:[0,0]});let n=this.params.lead!==!1?th:0;this.segments.push(new p([[0,0],[0,-n],[-.25,-n],[0,-n-.25],[.25,-n],[0,-n]])),this.anchors.start=[0,0],this.anchors.center=[0,0],this.anchors.end=[0,0]}},Zi=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{lead:!0,drop:[0,0],theta:0});let n=this.params.lead!==!1?th:0,s=.25*.75,i=.25;this.segments.push(new p([[0,0],[0,-n],[-s,-n-i]])),this.segments.push(new p([[0,-n],[-s,-n],[-s*2,-n-i]])),this.segments.push(new p([[0,-n],[s,-n],[0,-n-i]])),this.elmParams.drop=[0,0],this.elmParams.theta=0,this.anchors.start=[0,0],this.anchors.center=[0,0],this.anchors.end=[0,0]}},Qi=class extends N{constructor(e={}){super(e);let t=.6,n=.6,s=.38;this.segments.push(new p([[0,0],[0,t],[-s,t+n],[s,t+n],[0,t]])),this.elmParams.drop=[0,0],this.elmParams.theta=0,this.anchors.start=[0,0],this.anchors.center=[0,0],this.anchors.end=[0,0]}},eo=class extends N{constructor(e={}){super(e);let t=.2,n=.5;this.segments.push(new p([[0,0],[0,t],[-n,n+t],[t/2,n*2+1.5*t],[n+t,n+t],[t,t],[t,0]])),this.elmParams.drop=[0,0],this.elmParams.theta=0,this.anchors.start=[0,0],this.anchors.end=[t,0]}},to=class extends N{constructor(e={}){super(e);let t=.25,n=1,s=-n/2-t/2,i=s+t,o=n/2+t/2,a=o+t,l=t,h=t*2,c=n+h,m=c+t;this.segments.push(new p([[0,0],[0,l],[s,l],[s,c],[o,c],[o,h],[i,h],[i,m],[a,m],[a,l],[t,l],[t,0]])),this.elmParams.drop=[t,0],this.elmParams.theta=0,this.anchors.start=[0,0],this.anchors.end=[t,0]}},ro=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{lead:!0,drop:[0,0],theta:0,lblloc:"bottom"});let t=.25*.75,s=this.params.lead!==!1?th:0;this.segments.push(new p([[0,0],[0,-s]])),this.segments.push(new p([[0,-s],[-t,-s]])),this.segments.push(new p([[0,-s],[t,-s]])),this.anchors.start=[0,0],this.anchors.center=[0,0],this.anchors.end=[0,0]}},no=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{lead:!0,drop:[0,0],theta:0});let t=.25*.75,s=this.params.lead!==!1?th:0;this.segments.push(new p([[0,0],[0,s]])),this.segments.push(new p([[0,s],[-t,s]])),this.segments.push(new p([[0,s],[t,s]])),this.anchors.start=[0,0],this.anchors.center=[0,0],this.anchors.end=[0,0]}},so=class extends N{constructor(e={}){super(e);let t=.25*.75,n=.25*.75;this.segments.push(new p([[-t,-n],[t,n]])),this.segments.push(new p([[-t,n],[t,-n]])),this.elmParams.drop=[0,0],this.elmParams.theta=0,this.elmParams.lblofst="bottom",this.anchors.start=[0,0],this.anchors.center=[0,0],this.anchors.end=[0,0]}};var ae=.12,Xr=class extends se{constructor(e={}){super(e),Object.assign(this.defaults,{arrowwidth:.15,arrowlength:.25,arrow_lw:void 0,arrow_color:void 0});let{action:t,contacts:n=!0,nc:s=!1}=e,i=this.params;n?(s?this.segments.push(new p([[0,0],H,[ae*2,0],[.9,ae+.05],H,[1,0]])):this.segments.push(new p([[0,0],H,[ae*2,.1],[.8,.45],H,[1,0]])),this.segments.push(new D([ae,0],ae,{fill:"bg",zorder:3})),this.segments.push(new D([1-ae,0],ae,{fill:"bg",zorder:3}))):s?(this.segments.push(new p([[0,0],[1.15,.45],H,[1,0]])),this.segments.push(new p([[1,0],[1,.55]]))):this.segments.push(new p([[0,0],[.85,.45],H,[1,0]])),t==="open"?this.segments.push(new xe([.4,.1],.5,.75,{theta1:-10,theta2:70,arrow:"ccw",lw:i.arrow_lw,color:i.arrow_color,arrowwidth:i.arrowwidth,arrowlength:i.arrowlength})):t==="close"&&this.segments.push(new xe([.4,.25],.5,.75,{theta1:-10,theta2:70,arrow:"cw",lw:i.arrow_lw,color:i.arrow_color,arrowwidth:i.arrowwidth,arrowlength:i.arrowlength}))}},io=class extends Xr{constructor(e={}){super(e),e.contacts!==!1?(this.segments.push(new D([1-ae,.7],ae,{fill:"bg",zorder:3})),this.anchors.a=[ae,0],this.anchors.b=[1-ae,0],this.anchors.c=[1-ae,.7]):(this.anchors.a=[0,0],this.anchors.b=[1,0],this.anchors.c=[1,.7])}},Xs=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{arrowwidth:.15,arrowlength:.25,arrow_lw:void 0,arrow_color:void 0});let{action:t,contacts:n=!0}=e,s=this.params;n?(this.segments.push(new p([[0,0],H,[ae*2,.1],[.7,.25],H,[1,.4]])),this.segments.push(new D([ae,0],ae,{fill:"bg",zorder:3})),this.segments.push(new D([1-ae,-.4],ae,{fill:"bg",zorder:3})),this.segments.push(new D([1-ae,.4],ae,{fill:"bg",zorder:3})),this.anchors.a=[ae,0],this.anchors.b=[1-ae,.4],this.anchors.c=[1-ae,-.4]):(this.segments.push(new p([[0,0],[.85,.25],H,[1,.4]])),this.anchors.a=[0,0],this.anchors.b=[1,.4],this.anchors.c=[1,-.4]),t==="open"?this.segments.push(new xe([.35,0],.5,.75,{theta1:-10,theta2:70,arrow:"ccw",lw:s.arrow_lw,color:s.arrow_color,arrowwidth:s.arrowwidth,arrowlength:s.arrowlength})):t==="close"&&this.segments.push(new xe([.3,0],.5,.75,{theta1:-10,theta2:70,arrow:"cw",lw:s.arrow_lw,color:s.arrow_color,arrowwidth:s.arrowwidth,arrowlength:s.arrowlength})),this.elmParams.drop=[1,.4]}},oo=class extends se{constructor(e={}){super(e);let{nc:t=!1,contacts:n=!0}=e,s,i;n?(s=[[0,0],H],i=[H,[1,0]]):(s=[[0,0],[ae,0],H],i=[H,[1-ae,0],[1,0]]);let o=t?-ae-.05:.3,a=t?ae+.15:.5,l=[[ae,o],[1-ae,o],H,[.5,o],[.5,a]],h=[...s,...l,...i];this.segments.push(new p(h)),n&&(this.segments.push(new D([ae,0],ae)),this.segments.push(new D([1-ae,0],ae)))}},Gs=class extends N{constructor(e={}){super(e);let t=-1,{link:n=!0,contacts:s=!0}=e,i,o;s?(i=[[0,0],H,[ae*2,.1],[.8,.45],H,[1,0]],o=[[ae*2,t+.1],[.8,t+.45]],this.anchors.p1=[ae,0],this.anchors.t1=[1-ae,0],this.anchors.p2=[ae,t],this.anchors.t2=[1-ae,t]):(i=[[0,0],[.8,.45],H,[1,0]],o=[[0,t],[.8,t+.45]],this.anchors.p1=[0,0],this.anchors.t1=[1,0],this.anchors.p2=[0,t],this.anchors.t2=[1,t]),this.segments.push(new p(i)),this.segments.push(new p(o)),s&&(this.segments.push(new D([ae,0],ae,{fill:"bg",zorder:3})),this.segments.push(new D([1-ae,0],ae,{fill:"bg",zorder:3})),this.segments.push(new D([ae,t],ae,{fill:"bg",zorder:3})),this.segments.push(new D([1-ae,t],ae,{fill:"bg",zorder:3}))),n&&this.segments.push(new p([[.5,t+.25],[.5,.2]],{ls:":"}))}},Ws=class extends N{constructor(e={}){super(e);let t=-1.4,{link:n=!0,contacts:s=!0}=e,i,o;s?(i=[[0,0],H,[ae*2,.1],[.7,.25],H,[1,.4]],o=[[ae*2,t+.1],[.7,t+.25]],this.anchors.p1=[ae,0],this.anchors.t1=[1-ae,.4],this.anchors.t2=[1-ae,-.4],this.anchors.p2=[ae,t],this.anchors.t3=[1-ae,t+.4],this.anchors.t4=[1-ae,t-.4]):(i=[[0,0],[.7,.25],H,[1,.4]],o=[[0,t],[.7,t+.25]],this.anchors.p1=[0,0],this.anchors.t1=[1,.4],this.anchors.t2=[1,-.4],this.anchors.p2=[0,t],this.anchors.t3=[1,t+.4],this.anchors.t4=[1,t-.4]),this.segments.push(new p(i)),this.segments.push(new p(o)),s&&(this.segments.push(new D([ae,0],ae,{fill:"bg",zorder:3})),this.segments.push(new D([1-ae,-.4],ae,{fill:"bg",zorder:3})),this.segments.push(new D([1-ae,.4],ae,{fill:"bg",zorder:3})),this.segments.push(new D([ae,t],ae,{fill:"bg",zorder:3})),this.segments.push(new D([1-ae,t-.4],ae,{fill:"bg",zorder:3})),this.segments.push(new D([1-ae,t+.4],ae,{fill:"bg",zorder:3}))),n&&this.segments.push(new p([[.5,t+.25],[.5,.2]],{ls:":"}))}},ao=class extends se{constructor(e={}){super(e),this.segments.push(new p([[0,0],[.85,.15],H,[.8,0]]));let t=.3,n=ze(-Math.PI/2,Math.PI/2,32),s=n.map(m=>-t*Math.cos(m)),i=n.map(m=>t*Math.sin(m)),o=s.map(m=>1-m),a=[...i].reverse(),l=[...s,...o,s[0]],h=[...i,...a,i[0]],c=l.map((m,f)=>[m,h[f]]);this.segments.push(new p(c))}},lo=class extends N{constructor(e={}){super(e);let t=e.n??4,n=e.dtheta,s=e.radius??1,i=e.arrowlen??.75,o=e.arrowcontact??0;this.elmParams.fill="bg",this.elmParams.zorder=4,this.segments.push(new D([0,0],ae)),this.anchors.P=[0,0],n===void 0&&(n=Math.min(35,360/(t+1)));let a=n*Math.PI/180,l=e.theta0;l===void 0?l=-a*(t-1)/2:l=l*Math.PI/180;for(let h=0;h<t;h++){let c=l+a*h,m=s*Math.cos(c),f=s*Math.sin(c);if(this.segments.push(new D([m,f],ae)),this.anchors[`T${h+1}`]=[m,f],h===o){let g=i*Math.cos(c),b=i*Math.sin(c);this.segments.push(new p([[0,0],[g,b]],{arrow:"->",zorder:2}))}}}},ho=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{switchcolor:"#333333",swidth:.4,spacing:.2});let t=e.n??3,n=e.pattern,s=this.params.swidth,i=this.params.spacing,o=s*t+i*(t+1),a=s*2+i*2;this.segments.push(new U([[0,0],[o,0],[o,a],[0,a]]));for(let l=0;l<t;l++){let h=i*(l+1)+s*l,c=n?n[l]:!1,m=n?!n[l]:!1;this.segments.push(new U([[h,i+s],[h+s,i+s],[h+s,i+s*2],[h,i+s*2]],{fill:c?this.params.switchcolor:void 0})),this.segments.push(new U([[h,i],[h+s,i],[h+s,i+s],[h,i+s]],{fill:m?this.params.switchcolor:void 0})),this.anchors[`a${l+1}`]=[h+s/2,0],this.anchors[`b${l+1}`]=[h+s/2,a]}}};var co=class extends N{constructor(e={}){super(e);let t=.5;this.segments.push(new p([[0,0],[.25,0]])),this.segments.push(new p([[0,-t],[.25,-t]])),this.segments.push(new U([[.25,t/2],[.25,-t*1.5],[.25*2,-t*1.5],[.25*2,t/2]])),this.segments.push(new U([[.25*2,t/2],[.25*3.5,t*1.25],[.25*3.5,-t*2.25],[.25*2,-t*1.5]],{closed:!1})),this.anchors.in1=[0,0],this.anchors.in2=[0,-t],this.elmParams.drop=[0,-t]}},uo=class extends N{constructor(e={}){super(e);let t=.5;this.segments.push(new p([[0,0],[.25,0]])),this.segments.push(new p([[0,-t],[.25,-t]])),this.segments.push(new p([[-.25*2,.25],[-.25*2,-.25*3]])),this.segments.push(new xe([-.25*2,-.25],.25*4,.25*4,{theta1:270,theta2:90})),this.anchors.in1=[.25,0],this.anchors.in2=[.25,-t],this.elmParams.drop=[0,-t]}},mo=class extends se{constructor(e={}){super(e);let t=.22;this.segments.push(new p([[-t,0],[-t,0],H,[1+t,0],[1+t,0]])),this.segments.push(new p([[0,-t],[-t,-t],[-t,t],[0,t]])),this.segments.push(new p([[1,-t],[1+t,-t],[1+t,t],[1,t]])),this.segments.push(new D([.5,0],.5))}},po=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{radius:.075,open:!0});let{ring:t=!1,ringswitch:n=!1,dots:s=!0,switch:i=!1}=e,o=this.params.open?"bg":void 0,a=this.params.radius,l=2,h=.75,c=.55,m=.2,f=1,g=1,b=.1,v=.35,x=.4,S=.5;i&&(g+=.2),t&&n&&(v+=.2,b-=.2),t?(s&&this.segments.push(new D([0,-v],a,{fill:o,zorder:4})),this.segments.push(new p([[-a,-v],[-l,-v],[-l,0],[-l,f],[-l-m,f],[-l-m,0],[-l,0]])),this.anchors.sleeve=[0,-v],s&&this.segments.push(new D([0,b],a,{fill:o,zorder:4})),this.segments.push(new p([[-a,b],[-l*.75,b],[-l*h-2*a,b+2*a],[-l*h-a*4,b]])),this.anchors.ring=[0,b]):(s&&this.segments.push(new D([0,0],a,{fill:o,zorder:4})),this.segments.push(new p([[-a,0],[-l,0],[-l,f],[-l+m,f],[-l+m,0]])),this.anchors.sleeve=[0,0]),s&&this.segments.push(new D([0,g],a,{fill:o,zorder:4})),this.segments.push(new p([[-a,g],[-l*.55,g],[-l*c-2*a,g-2*a],[-l*c-a*4,g]])),this.anchors.tip=[0,g],i&&(s&&this.segments.push(new D([0,g-x],a,{fill:o,zorder:4})),this.segments.push(new p([[0,g-x],[-S,g-x]])),this.segments.push(new p([[-S,g-x],[-S,g]],{arrow:"->"})),this.anchors.tipswitch=[0,g-x]),t&&n&&(s&&this.segments.push(new D([0,b+x],a,{fill:o,zorder:4})),this.segments.push(new p([[0,b+x],[-S,b+x]])),this.segments.push(new p([[-S,b+x],[-S,b]],{arrow:"->"})),this.anchors.ringswitch=[0,b+x])}};var fo=class extends se{constructor(e={}){super(e),Object.assign(this.defaults,{length:3,leadlen:.6,radius:.3});let t=this.params.leadlen,n=this.params.length,s=this.params.radius;this.segments.push(new p([[0,0],[t,0],H,[n-t+s/2,0],[n,0]])),this.segments.push(new p([[t,s],[n-t,s]])),this.segments.push(new p([[t,-s],[n-t,-s]])),this.segments.push(new xe([t,0],s,s*2,{theta1:0,theta2:360})),this.segments.push(new xe([n-t,0],s,s*2,{theta1:270,theta2:90})),this.anchors.shieldstart=[t,-s],this.anchors.shieldstart_top=[t,s],this.anchors.shieldend=[n-t,-s],this.anchors.shieldend_top=[n-t,s],this.anchors.shieldcenter=[n/2,-s],this.anchors.shieldcenter_top=[n/2,s]}},go=class extends se{constructor(e={}){super(e),Object.assign(this.defaults,{length:3,leadlen:.6,radiusinner:.3,radiusouter:.6,shieldofststart:.3,shieldofstend:.3});let t=this.params.radiusinner,n=this.params.radiusouter,s=this.params.length,i=this.params.leadlen,o=this.params.shieldofstend,a=this.params.shieldofststart;if(n<t)throw new Error("Triax inner radius > outer radius");let l=n/2*Math.sqrt(1-t*t/(n*n)),h=180;a-l>-t/2&&(h=180-Math.atan2(t,l)*180/Math.PI),s-i-o+n<s?(this.segments.push(new p([[0,0],[i,0],H,[s-i+t/2,0],[s,0]])),this.segments.push(new p([[s-i-o+l,t],[s-i,t]])),this.segments.push(new p([[s-i-o+l,-t],[s-i,-t]])),this.segments.push(new xe([s-i,0],t,t*2,{theta1:270,theta2:90}))):this.segments.push(new p([[0,0],[i,0],H,[s-i-o+n/2,0]])),this.segments.push(new p([[i,t],[i+a+l,t]])),this.segments.push(new p([[i,-t],[i+a+l,-t]])),this.segments.push(new p([[i+a,n],[s-i-o,n]])),this.segments.push(new p([[i+a,-n],[s-i-o,-n]])),this.segments.push(new xe([i,0],t,t*2,{theta1:0,theta2:360})),this.segments.push(new xe([i+a,0],n,n*2,{theta1:-h,theta2:h})),this.segments.push(new xe([s-i-o,0],n,n*2,{theta1:270,theta2:90})),this.anchors.guardstart=[i,-t],this.anchors.guardstart_top=[i,t],this.anchors.guardend=[s-i,-t],this.anchors.guardend_top=[s-i,t],this.anchors.shieldstart=[i+a,-n],this.anchors.shieldstart_top=[i+a,n],this.anchors.shieldend=[s-i-o,-n],this.anchors.shieldend_top=[s-i-o,n],this.anchors.shieldcenter=[s/2,-n],this.anchors.shieldcenter_top=[s/2,n]}};var bo=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{core:!0,loop:!1,corewidth:.75,phasegap:.4,arcwidth:.4});let t=e.t1??4,n=e.t2??4;typeof t=="number"&&(t=[t]),typeof n=="number"&&(n=[n]);let s=t,i=n,o=this.params.phasegap,a=this.params.loop,l=this.params.core,h=e.align??"center",c=this.params.corewidth;a&&(c+=.4),l&&(c+=.25);let m=0,f,g,b,v=(x,S)=>{if(h==="center"){let k=x/2-S/2;return[k,k+S]}else return h==="bottom"?[0,S]:[x-S,x]};if(a){let x=s.map(re=>Vn(re,[0,0],.06,.19,!1,!0,!1)),S=i.map(re=>Vn(re,[c,0],.06,.19,!1,!0,!0)),k=x.reduce((re,te)=>re+te[te.length-1][1],0)+o*(x.length-1),M=S.reduce((re,te)=>re+te[te.length-1][1],0)+o*(S.length-1);f=k,[g,b]=v(k,M);let _=.06,B=.19,$=Math.acos(_/B),Y=Math.PI*2*_,Z=Y-(_*$-B*Math.sin($)),I=(_-B)/2/.25,X=m,j=0;for(let re=0;re<x.length;re++){let te=x[re],ke=te[te.length-1][1],he=te.map(de=>[de[0],de[1]+X]);this.segments.push(new p(he)),this.anchors[`p${re*2+1}`]=he[0],this.anchors[`p${re*2+2}`]=he[he.length-1],f=he[he.length-1][1];let ve=0;for(ve=0;ve<s[re];ve++)this.anchors[`tapP${j+ve+1}`]=[I,he[0][1]+ve*Y+Z];j+=ve,X+=ke+o}X=g,j=0;for(let re=0;re<S.length;re++){let te=S[re],ke=te[te.length-1][1],he=te.map(de=>[de[0],de[1]+X]);this.segments.push(new p(he)),this.anchors[`s${re*2+1}`]=he[0],this.anchors[`s${re*2+2}`]=he[he.length-1],b=he[he.length-1][1];let ve=0;for(ve=0;ve<i[re];ve++)this.anchors[`tapS${j+ve+1}`]=[c-I,he[0][1]+ve*Y+Z];j+=ve,X+=ke+o}}else{let x=this.params.arcwidth,S=s.reduce((B,$)=>B+$,0)*x+o*(s.length-1),k=i.reduce((B,$)=>B+$,0)*x+o*(i.length-1);f=S,[g,b]=v(S,k);let M=m,_=0;for(let B=0;B<s.length;B++){let $=s[B];this.anchors[`p${B*2+2}`]=[0,M],this.anchors[`p${B*2+1}`]=[0,M+$*x];for(let Y=0;Y<$;Y++)this.segments.push(new xe([0,M+x/2],x,x,{theta1:270,theta2:90})),Y<$-1&&(this.anchors[`tapP${_+Y+1}`]=[0,M+x]),M+=x;_+=$-1,M+=o}M=g,_=0;for(let B=0;B<i.length;B++){let $=i[B];this.anchors[`s${B*2+2}`]=[c,M],this.anchors[`s${B*2+1}`]=[c,M+$*x];for(let Y=0;Y<$;Y++)this.segments.push(new xe([c,M+x/2],x,x,{theta1:90,theta2:270})),Y<$-1&&(this.anchors[`tapS${_+Y+1}`]=[c,M+x]),M+=x;_+=$-1,M+=o}}if(l){let x=Math.max(f,b),S=Math.min(m,g),k=c/2,M=c/10;this.segments.push(new p([[k-M,x],[k-M,S]])),this.segments.push(new p([[k+M,x],[k+M,S]]))}}tap(e,t,n="primary"){let s=n==="primary"?"P":"S",i;if(t===0?i=this.anchors[`${s.toLowerCase()}1`]:i=this.anchors[`tap${s}${t}`],i)this.anchors[e]=i;else throw new Error(`No tap at position ${t}`);return this}};function B2(r){return r instanceof A?[r.x,r.y]:[r[0],r[1]]}var rh=.25,dn=class extends Pe{constructor(e={}){let{double:t,...n}=e;super({...n,arrow:t?"<->":e.arrow??"->"}),this.anchors.center=[0,0]}},wo=class extends se{constructor(e={}){super(e),this.segments.push(new p([[0,0],H,[-rh/2,rh],[rh/2,-rh],H,[0,0]]))}},Xt=class extends se{constructor(e={}){super(e),Object.assign(this.defaults,{lblloc:"center",lblalign:["center","center"],lblofst:0}),this.segments.push(new p([[0,0],H,[1,0]],{visible:!1}))}},pn=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{radius:.075,open:!1});let n=this.params.open===!0?"bg":!0;this.anchors.start=[0,0],this.anchors.center=[0,0],this.anchors.end=[0,0],this.elmParams.drop=[0,0],this.elmParams.theta=0,this.elmParams.zorder=4,this.elmParams.fill=n,this.segments.push(new D([0,0],this.params.radius,{fill:n}))}},xo=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{headwidth:.15,headlength:.25,lblofst:.25});let t=this.params.headwidth,n=this.params.headlength;this.segments.push(new p([[-n,0],[0,0]],{arrowwidth:t,arrowlength:n,arrow:"->"})),this.anchors.start=[0,0],this.anchors.center=[0,0],this.anchors.end=[0,0]}},vo=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{radius:.075,open:!1});let t=this.params.radius,n=this.params.open?"bg":!0;this.elmParams.fill=n,this.segments.push(new D([.5,0],t)),this.segments.push(new D([1,0],t)),this.segments.push(new D([1.5,0],t)),this.elmParams.drop=[2,0]}},xr=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{zorder:0});let t=e.corner1??[0,0],n=e.corner2??[1,1],s=[t[0],n[1]],i=[n[0],t[1]];this.segments.push(new U([t,s,n,i],{closed:!0,zorder:0,fill:e.fill,lw:e.lw,ls:e.ls}))}},yo=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{shape:"-",k:1,to:[3,-2],dotradius:.075})}to(e,t=0,n=0){let s=A.fromXY(B2(e));return this.userParams.to=[s.x+t,s.y+n],this}delta(e,t){return this.userParams.delta=[e,t],this}dot(e=!1){return this.userParams.dot=e?"open":!0,this}idot(e=!1){return this.userParams.idot=e?"open":!0,this}shape(e){return this.userParams.shape=e,this}k(e){return this.userParams.k=e,this}arrow(e){return this.userParams.arrow=e,this}_place(e,t,n){this.dwgParams={...n},this._positioned||this._position(),this.elmParams.theta=0;let s=this.params.at??e,i=this.params.to??e,o=this.params.delta,a=this.params.arrow,l=this.params.shape,h=this.params.k??1,c,m;if(o!==void 0?(c=o[0],m=o[1]):(c=i[0]-s[0],m=i[1]-s[1]),this.segments=[],l==="-")this.segments.push(new p([[0,0],[c,m]],{arrow:a})),this.anchors.mid=[c/2,m/2];else if(l==="-|")this.segments.push(new p([[0,0],[c,0],[c,m]],{arrow:a})),this.anchors.mid=[c,m/2],this.elmParams.droptheta=m>0?90:-90;else if(l==="|-")this.segments.push(new p([[0,0],[0,m],[c,m]],{arrow:a})),this.anchors.mid=[c/2,m],this.elmParams.droptheta=c>0?0:180;else if(l==="z"||l==="Z"){let g=c>0?Math.abs(h):-Math.abs(h);this.segments.push(new p([[0,0],[g,0],[c-g,m],[c,m]],{arrow:a})),this.anchors.mid=[c/2,m/2],this.elmParams.droptheta=c>0?0:180}else if(l==="N"){let g=m>0?Math.abs(h):-Math.abs(h);this.segments.push(new p([[0,0],[0,g],[c,m-g],[c,m]],{arrow:a})),this.anchors.mid=[c/2,m/2],this.elmParams.droptheta=m>0?90:-90}else if(l==="n")this.segments.push(new p([[0,0],[0,h],[c,h],[c,m]],{arrow:a})),this.anchors.mid=[c/2,h],this.elmParams.droptheta=m>h?90:-90;else if(l==="c")this.segments.push(new p([[0,0],[h,0],[h,m],[c,m]],{arrow:a})),this.anchors.mid=[h,m/2],this.elmParams.droptheta=c>h?0:180;else throw new Error(`Wire: undefined shape ${l}`);let f=T(this.params,"dotradius",.075);if(this.params.dot){let b=this.params.dot==="open"?"bg":!0;this.segments.push(new D([c,m],f,{fill:b,zorder:3}))}if(this.params.idot){let b=this.params.idot==="open"?"bg":!0;this.segments.push(new D([0,0],f,{fill:b,zorder:3}))}return this.elmParams.lblloc="mid",this.elmParams.drop=[c,m],this.anchors.start=[0,0],this.anchors.end=[c,m],this._positioned=!0,super._place(e,t,n)}},So=class extends N{constructor(e={}){super(e),this.elmParams.lblloc="center",this.elmParams.lblofst=0;let t=e.label;t!==void 0&&t!==""&&this.label(t)}},ko=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{width:1.5,height:.625,lblloc:"center",fontsize:12,lblofst:0});let t=e.width??1.5,n=(e.height??.625)/2;this.segments.push(new U([[0,0],[n,n],[t,n],[t,-n],[n,-n]],{closed:!0})),this.anchors.start=[0,0];let s=e.s;s&&this.segments.push(new W([t/2,0],s,{fontsize:12}))}};function Qc(r){return r instanceof A?[r.x,r.y]:[r[0],r[1]]}function C1(r,e,t=.01){return Math.abs(r-e)<=t}function I1(r){let e=r.absanchors.center;if(e!==void 0)return e;let t=r.getBBox(!1,!1),n=(t.xmin+t.xmax)/2,s=(t.ymin+t.ymax)/2;return r.transform.transform([n,s])}var Mo=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{k:.5})}to(e,t=0,n=0){let s=A.fromXY(Qc(e));return this.userParams.to=[s.x+t,s.y+n],this}delta(e,t){return this.userParams.delta=[e,t],this}k(e){return this.userParams.k=e,this}arrow(e){return this.userParams.arrow=e,this}_place(e,t,n){this.dwgParams={...n},this._positioned||this._position(),this.segments=[],this.elmParams.theta=0;let s=this.params.at??e,i=this.params.to??[s[0]+3,s[1]],o=this.params.delta,a,l;o!==void 0?(a=o[0],l=o[1]):(a=i[0]-s[0],l=i[1]-s[1]);let h=this.params.k??.5,c=[a/2-l*h,l/2+a*h],m=[a/2-l*h/2,l/2+a*h/2],f=this.params.arrow;this.segments.push(new Ut([[0,0],c,[a,l]],{arrow:f})),this.anchors.ctrl=c,this.anchors.mid=m,this.anchors.start=[0,0],this.anchors.end=[a,l],this.elmParams.lblloc="mid",this.elmParams.drop=[a,l];let g="bottom",b="left",v=.1,x=0;return C1(m[1],c[1])?(g="center",v=0):m[1]>c[1]&&(g="top",v=-.1),C1(m[0],c[0])?b="center":m[0]>c[0]?(b="right",v=0,x=-.1):(x=.1,v=0),this.elmParams.lblofst=[x,v],this.elmParams.lblalign=[b,g],this._positioned=!0,super._place(e,t,n)}},fn=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{k:.75,th1:0,th2:180,to:[1,0],arrowlength:.25,arrowwidth:.2})}to(e,t=0,n=0){let s=A.fromXY(Qc(e));return this.userParams.to=[s.x+t,s.y+n],this}delta(e,t){return this.userParams.delta=[e,t],this}k(e){return this.userParams.k=e,this}th1(e){return this.userParams.th1=e,this}th2(e){return this.userParams.th2=e,this}arrow(e){return this.userParams.arrow=e,this}arrowlength(e){return this.userParams.arrowlength=e,this}arrowwidth(e){return this.userParams.arrowwidth=e,this}setLabelAlign(e,t){this.elmParams.lblloc="center";let n="left",s="bottom";t>0&&(s="top",this.elmParams.lblofst=-.1),e<=0&&(n="right"),this.elmParams.lblalign=[n,s]}_place(e,t,n){this.dwgParams={...n},this._positioned||this._position(),this.segments=[],this.userParams.theta=0;let s=this.params.at??e,i=this.params.to??e,o=this.params.delta,a,l;o!==void 0?(a=o[0],l=o[1]):(a=i[0]-s[0],l=i[1]-s[1]);let h=this.params.k??.75,c=(this.params.th1??0)*(Math.PI/180),m=(this.params.th2??180)*(Math.PI/180),f=[a*h*Math.cos(c),l*h*Math.sin(c)],g=[a+a*h*Math.cos(m),l+l*h*Math.sin(m)],b=this.params.arrow,v=this.params.arrowlength,x=this.params.arrowwidth;return this.segments.push(new Ut([[0,0],f,g,[a,l]],{arrow:b,arrowlength:v,arrowwidth:x})),this.anchors.center=[a/2,l/2],this.anchors.start=[0,0],this.anchors.end=[a,l],this.anchors.ctrl1=f,this.anchors.ctrl2=g,this.elmParams.drop=[a,l],this.setLabelAlign(a,l),this._positioned=!0,super._place(e,t,n)}},zo=class extends fn{constructor(e={}){super({...e,to:e.to??[1,1],th1:e.th1??75,th2:e.th2??180,arrow:e.arrow??"<-"})}setLabelAlign(e,t){this.elmParams.lblloc="end";let n=this.anchors.ctrl2,s=this.anchors.end,i;for(n[0]===s[0]&&n[1]===s[1]?i=t<0?-90:90:i=Math.atan2(s[1]-n[1],s[0]-n[0])*180/Math.PI;i<0;)i+=360;i<45||i>315?(this.elmParams.lblalign=["left","center"],this.elmParams.lblofst=[.1,0]):i>=45&&i<=135?(this.elmParams.lblalign=["center","bottom"],this.elmParams.lblofst=[0,.1]):i>135&&i<=225?(this.elmParams.lblalign=["right","center"],this.elmParams.lblofst=[-.1,0]):(this.elmParams.lblalign=["center","top"],this.elmParams.lblofst=[0,-.1])}},Eo=class extends fn{constructor(e={}){super({...e,th1:0,th2:180})}},Po=class extends fn{constructor(e={}){super({...e,th1:90,th2:-90})}},To=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{radius:.6,arrowlength:.25,arrowwidth:.2})}to(e,t=0,n=0){let s=A.fromXY(Qc(e));return this.userParams.to=[s.x+t,s.y+n],this}delta(e,t){return this.userParams.delta=[e,t],this}radius(e){return this.userParams.radius=e,this}arrow(e){return this.userParams.arrow=e,this}arrowlength(e){return this.userParams.arrowlength=e,this}arrowwidth(e){return this.userParams.arrowwidth=e,this}_place(e,t,n){this.dwgParams={...n},this._positioned||this._position(),this.segments=[],this.elmParams.theta=0;let s=this.params.at??e,i=this.params.to??e,o=this.params.delta,a,l;o!==void 0?(a=o[0],l=o[1]):(a=i[0]-s[0],l=i[1]-s[1]);let h=this.params.radius??.6,c=a/2,m=l/2,f=Math.sqrt(a*a+l*l),g=h*h-f/2*(f/2);if(g<0)throw new Error(`ArcLoop: no solution for radius ${h}`);let b=Math.sqrt(g),v=[c+b*(-l/f),m+b*(a/f)],x=Math.sqrt(c*c+m*m),S=Math.atan2(m,c),k=Math.acos(x/h),M=S-k,_=S+k,B=ze(Math.PI+_,M,50),$=[],Y=[];for(let re of B)$.push(v[0]+h*Math.cos(re)),Y.push(v[1]+h*Math.sin(re));let Z=$.map((re,te)=>[re,Y[te]]),L=this.params.arrow,I=this.params.arrowlength,X=this.params.arrowwidth;this.segments.push(new p(Z,{arrow:L,arrowlength:I,arrowwidth:X}));let j=Math.floor($.length/2);return this.anchors.start=[0,0],this.anchors.end=[$[$.length-1],Y[Y.length-1]],this.anchors.mid=[$[j],Y[j]],this.anchors.BL=[Math.min(...$),Math.min(...Y)],this.anchors.BR=[Math.max(...$),Math.min(...Y)],this.anchors.TL=[Math.min(...$),Math.max(...Y)],this.anchors.TR=[Math.max(...$),Math.max(...Y)],this.elmParams.lblloc="mid",this.elmParams.drop=[i[0]-s[0],i[1]-s[1]],this.elmParams.lblofst=[0,.2],Y[j]<Y[0]&&(this.elmParams.lblofst=[0,-.25]),this._positioned=!0,super._place(e,t,n)}},h0=class extends N{constructor(t={}){super(t);z(this,"_side","top");Object.assign(this.defaults,{ofst:.15,length:2,top:!0,reverse:!1,headlength:.3,headwidth:.2,anchor:"center",drop:null}),this.anchors.center=[0,0]}at(t,n=0,s=0){return t instanceof N?(this.userParams.overElement=t,this):super.at(t,n,s)}over(t){return this.userParams.overElement=t,this}placeArrowSegment(t){let n=this.params.ofst??.15,s=this.params.length??2;this._side==="bottom"&&(n=-n);let i=[-s/2,n],o=[s/2,n],a=this.params.headwidth??.2,l=this.params.headlength??.3;this.segments.push(new p([i,o],{arrow:"->",arrowwidth:a,arrowlength:l}))}placeFromOverElement(t){let n=String(T(t.params,"ilabel","top")).toLowerCase();n==="bot"&&(n="bottom"),this.params.top!==!1||(n={top:"bottom",bottom:"top",left:"right",right:"left"}[n]??n);let i=this.userParams.reverse===!0;if(t.userParams.reverse===!0){let f={left:"right",right:"left"};f[n]!==void 0?n=f[n]:i=!i}t.userParams.flip===!0&&(n==="left"||n==="right")&&(i=!i),n==="left"&&(i=!i),this.userParams.reverse=i;let o=t.transform.theta,a=t.getBBox(!1,!1),l,h;n==="top"?(l=new A((a.xmin+a.xmax)/2,a.ymax),h="top"):n==="bottom"?(l=new A((a.xmin+a.xmax)/2,a.ymin),h="bot"):n==="right"?(l=new A(a.xmax,(a.ymin+a.ymax)/2),h="bot",o-=90):n==="left"?(l=new A(a.xmin,(a.ymin+a.ymax)/2),h="top",o+=90):(l=new A((a.xmin+a.xmax)/2,a.ymax),h="top");let c=t.transform.transform(l.toTuple());this.userParams.at=[c.x,c.y],this.userParams.theta=o,this.elmParams.lblloc=h,this._side=n==="bottom"?"bottom":n==="top"?"top":n==="left"?"left":"right";let m=t.userParams.color;m!==void 0&&(this.userParams.color=m)}_place(t,n,s){this.dwgParams={...s};let i=this.params.overElement;i!==void 0&&this.placeFromOverElement(i),this.segments=[];let o=((this.params.theta??0)%360+360)%360,a=this.params.lblloc??"top",l=this._side;if(l==="right"&&(o<=90||o>270)){let h=this.elmParams.lblloc??"top";this.elmParams.lblloc=h==="bot"?"top":"bot",a=this.elmParams.lblloc}else if((l==="top"||l==="left"||l==="bottom")&&o>90&&o<=270){let h=this.elmParams.lblloc??"top";this.elmParams.lblloc=h==="bot"?"top":"bot",a=this.elmParams.lblloc}return this.placeArrowSegment(a),super._place(t,n,s)}},Ro=class extends h0{constructor(e={}){super(e),Object.assign(this.defaults,{length:1.75,ofst:.075,bend:.6})}placeArrowSegment(e){let t=this.params.ofst??.075,n=this.params.bend??.6,s=this.params.length??1.75;this._side==="bottom"&&(t=-t,n=-n);let i=this.params.headwidth??.2,o=this.params.headlength??.3,a=this.params.reverse===!0?"<-":"->",l=[-s/2,t],h=[s/2,t],c=[0,n];this.segments.push(new Ut([l,c,h],{arrow:a,arrowlength:o,arrowwidth:i}))}},gn=class extends N{constructor(e="in",t=.8,n=!0,s={}){super(s),Object.assign(this.defaults,{headlength:.3,headwidth:.3}),this.elmParams.lblofst=0,this.elmParams.drop=null,this.elmParams.zorder=4;let i=t,o=this.params.headlength??.3;e==="in"&&(i+=this.params.headlength??.3,o=-o),n&&(i=-i,o=-o);let a=this.params.headwidth??.3,l=this.params.headlength??.3;this.segments.push(new p([[i,0],[i+o,0]],{arrow:"->",arrowwidth:a,arrowlength:l}))}at(e,t=0,n=0){return e instanceof N?(this.userParams.overElement=e,this):super.at(e,t,n)}over(e){return this.userParams.overElement=e,this}_place(e,t,n){this.dwgParams={...n},this._positioned||this._position();let s=this.params.overElement;if(s!==void 0){let i=I1(s);this.userParams.at=[i.x,i.y],this.userParams.theta=s.transform.theta;let o=s.userParams.color;o!==void 0&&(this.userParams.color=o)}return this._positioned=!0,super._place(e,t,n)}},Ao=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{ofst:.5,hofst:.4,length:1,lengthtip:.5,headlength:.25,headwidth:.15}),this.userParams.anchor="center",this.anchors.center=[0,0]}at(e,t=0,n=0){return e instanceof N?(this.userParams.overElement=e,this):super.at(e,t,n)}over(e){return this.userParams.overElement=e,this}_place(e,t,n){this.dwgParams={...n},this._positioned||this._position();let s=this.params.overElement;if(s!==void 0){let v=I1(s);this.userParams.at=[v.x,v.y];let x=s.transform.theta;(x%360+360)%360>90&&(x%360+360)%360<=270&&(x+=180),this.userParams.theta=x;let S=s.userParams.color;S!==void 0&&(this.userParams.color=S)}let i=this.params.hofst??.4,o=this.params.ofst??.5,a=this.params.lengthtip??.5,l=this.params.length??1,h=this.params.headwidth??.15,c=this.params.headlength??.25,m=[-i,o],f=[-i-a,o],g=[-i-a,o-l];this.anchors.head=m,this.anchors.tail=g,this.segments=[],this.segments.push(new p([g,f,m],{arrow:"->",arrowwidth:h,arrowlength:c})),this.elmParams.lblloc="tail";let b=this.params.theta??0;return this.params.flip===!0&&(b+=180),b-=90,b=(b%360+360)%360,b<45||b>315?(this.elmParams.lblalign=["left","center"],this.elmParams.lblofst=[0,-.1]):b>=45&&b<=135?(this.elmParams.lblalign=["center","bottom"],this.elmParams.lblofst=[0,.1]):b>135&&b<=225?(this.elmParams.lblalign=["right","center"],this.elmParams.lblofst=[0,.1]):(this.elmParams.lblalign=["center","top"],this.elmParams.lblofst=[0,-.1]),this._positioned=!0,super._place(e,t,n)}},c0=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{lblloc:"center",lblofst:0,theta:0});let t=e.direction??"cw",n=e.theta1??35,s=e.theta2??-35,i=e.width??1,o=e.height??1;this.segments.push(new xe([0,0],i,o,{theta1:n,theta2:s,arrow:t})),this.anchors.center=[0,0]}},nh=class extends c0{constructor(e){At(null);let{elm_list:t,pad:n=.2,...s}=e,i=t[0].getBBox(!0,!1),o=t[1].getBBox(!0,!1),a=t[2].getBBox(!0,!1),l=t[3].getBBox(!0,!1),h=i.ymin-n,c=a.ymax+n,m=l.xmax+n,f=o.xmin-n,g=[(m+f)/2,(h+c)/2],b=f-m,v=h-c;super({...s,width:b,height:v,at:g})}},sh=class extends N{constructor(e){At(null);let{elm_list:t,includelabels:n=!0,...s}=e;super(s),Object.assign(this.defaults,{padx:.2,pady:.2,theta:0});let i=1/0,o=-1/0,a=1/0,l=-1/0;for(let k of t){let M=k.getBBox(!0,n);i=Math.min(i,M.xmin),o=Math.max(o,M.xmax),a=Math.min(a,M.ymin),l=Math.max(l,M.ymax)}let h=this.params.padx??.2,c=this.params.pady??.2;i-=h,o+=h,a-=c,l+=c;let m=o-i,f=l-a,g=[(o+i)/2,(l+a)/2];this.userParams.at=g,this.segments.push(new xe([0,0],m,f,{theta1:0,theta2:360}));let b=Math.sin(Math.PI/4),v=Math.cos(Math.PI/4),x=Math.sin(Math.PI/8),S=Math.cos(Math.PI/8);this.anchors.N=[0,f/2],this.anchors.S=[0,-f/2],this.anchors.E=[m/2,0],this.anchors.W=[-m/2,0],this.anchors.SE=[m/2*v,-f/2*b],this.anchors.SW=[-m/2*v,-f/2*b],this.anchors.NW=[-m/2*v,f/2*b],this.anchors.NE=[m/2*v,f/2*b],this.anchors.ENE=[m/2*S,f/2*x],this.anchors.WNW=[-m/2*S,f/2*x],this.anchors.ESE=[m/2*S,-f/2*x],this.anchors.WSW=[-m/2*S,-f/2*x],this.anchors.NNE=[m/2*x,f/2*S],this.anchors.NNW=[-m/2*x,f/2*S],this.anchors.SSE=[m/2*x,-f/2*S],this.anchors.SSW=[-m/2*x,-f/2*S]}},ih=class extends N{constructor(e){At(null);let{elm_list:t,includelabels:n=!0,...s}=e;super(s),Object.assign(this.defaults,{cornerradius:.3,padx:.2,pady:.2,theta:0});let i=1/0,o=-1/0,a=1/0,l=-1/0;for(let x of t){let S=x.getBBox(!0,n);i=Math.min(i,S.xmin),o=Math.max(o,S.xmax),a=Math.min(a,S.ymin),l=Math.max(l,S.ymax)}let h=this.params.padx??.2,c=this.params.pady??.2;i-=h,o+=h,a-=c,l+=c;let m=o-i,f=l-a,g=[(o+i)/2,(l+a)/2];this.userParams.at=g;let b=this.params.cornerradius??.3;this.segments.push(new U([[-m/2,f/2],[m/2,f/2],[m/2,-f/2],[-m/2,-f/2]],{closed:!0,cornerradius:b}));let v=b-b*Math.sqrt(2)/2;this.anchors.NE=[m/2-v,f/2-v],this.anchors.NW=[-m/2+v,f/2-v],this.anchors.SE=[m/2-v,-f/2+v],this.anchors.SW=[-m/2+v,-f/2+v],this.anchors.N=[0,f/2],this.anchors.S=[0,-f/2],this.anchors.E=[m/2,0],this.anchors.W=[-m/2,0]}};var ir=class extends N{constructor(t={}){super(t);z(this,"compoundDwgParams");z(this,"elements",[]);z(this,"_here",new A(0,0));z(this,"_theta",0);this.compoundDwgParams={unit:t.unit??3,font:t.font??null,fontsize:t.fontsize??14,lblofst:t.lblofst??.1,color:t.color??"black",lw:t.lw??2,ls:t.ls??"-",fill:t.fill??"none"};let n=la(!0);try{this.setup(),this._initAnchors()}finally{la(n)}}_initAnchors(){for(let[t,n]of Object.entries(this))if(n instanceof N&&t!=="elements")for(let s of Object.keys(n.anchors)){let i=n.absanchors[s];i&&(this.anchors[`${t}.${s}`]=[i.x,i.y])}}move(t,n){this._here=new A(this._here.x+t,this._here.y+n)}moveFrom(t,n=0,s=0,i){let o=t instanceof A?t.x:t[0],a=t instanceof A?t.y:t[1];this._here=new A(o+n,a+s),i!==void 0&&(this._theta=i)}contains(t){return this.elements.includes(t)}add(t){this.elements.push(t);let n=t._place(this._here.toTuple(),this._theta,this.compoundDwgParams);this._here=n.point,this._theta=n.theta;for(let s of t.segments){let i=s.xform(t.transform,t.params);this.segments.push(i)}return t}};function fe(r,e){let t=r.absanchors[e];return[t.x,t.y]}var _o=class extends ir{constructor(e={}){super({...e,unit:1.5,_box:e.box!==!1,_boxfill:e.boxfill??"none",_boxpad:e.boxpad??.2,_base:e.base===!0})}setup(){let t=this.userParams._box!==!1,n=this.userParams._boxfill??"none",s=this.userParams._boxpad??.2,i=this.userParams._base===!0,o=this.add(new et({d:"d"})),a=new Ht({d:"r",at:[1,-1.5/2]});a.segments.splice(0,1);let l=this.add(a);this.add(new dn({d:"r",at:[.5,-1.5/2+.2],l:.6,arrowwidth:.15,arrowlength:.2})),this.add(new dn({d:"r",at:[.5,-1.5/2-.2],l:.6,arrowwidth:.15,arrowlength:.2}));let h=this.getBBox(!1);if(t&&this.add(new xr({d:"r",at:[0,0],corner1:[h.xmin-s,h.ymin-s],corner2:[h.xmax+s,h.ymax+s],fill:n,zorder:0})),i){let b=l.getBBox(!0),v=o.absanchors.center;this.add(new Pe({d:"l",at:[b.xmin,v.y],l:.15}));let x=this.add(new Pe({d:"d",toy:h.ymax+s}));this.anchors.base=fe(x,"end")}let c=this.add(new Pe({d:"r",at:fe(a,"collector"),l:s})),m=this.add(new Pe({d:"r",at:fe(a,"emitter"),l:s})),f=this.add(new Pe({d:"l",at:fe(o,"start"),tox:h.xmin-s})),g=this.add(new Pe({d:"l",at:fe(o,"end"),tox:h.xmin-s}));this.anchors.anode=fe(f,"end"),this.anchors.cathode=fe(g,"end"),this.anchors.emitter=fe(m,"end"),this.anchors.collector=fe(c,"end")}},Bo=class extends ir{constructor(e={}){super(e)}setup(){let e=this.userParams.fill??!1,t=this.userParams.labels,n=new et({fill:e}).theta(45),s=new et({fill:e}).theta(-45),i=new et({fill:e}).theta(-135).reverse(),o=new et({fill:e}).theta(135).reverse(),a=["top","top","bottom","bottom"];t&&[n,s,i,o].forEach((l,h)=>{t[h]&&l.label(t[h],{loc:a[h]})}),this.add(n),this.add(s),this.add(i),this.add(o),this.anchors.W=fe(n,"start"),this.anchors.N=fe(s,"start"),this.anchors.E=fe(i,"start"),this.anchors.S=fe(o,"start"),this.elmParams.theta=0}},Co=class extends ir{constructor(e={}){super(e)}setup(){let e=this.userParams.vout===!0,t=this.userParams.labels,n=new dt().theta(45),s=new dt().theta(-45),i=new dt().theta(-135),o=new dt().theta(135),a=["top","top","bottom","bottom"];if(t&&[n,s,i,o].forEach((l,h)=>{t[h]&&l.label(t[h],{loc:a[h]})}),this.add(n),this.add(s),this.add(i),this.add(o),e){let l=n.absanchors.start;this.add(new Pe({}).right().at([l.x,l.y]).length(1));let h=this.add(new pn({open:!0})),c=i.absanchors.start;this.add(new Pe({}).left().at([c.x,c.y]).length(1));let m=this.add(new pn({open:!0}));this.anchors.vo1=fe(h,"center"),this.anchors.vo2=fe(m,"center"),this._labelhints.vo1={ofst:[0,.1],halign:"center",valign:"bottom"},this._labelhints.vo2={ofst:[0,.1],halign:"center",valign:"bottom"}}this.anchors.W=fe(n,"start"),this.anchors.N=fe(s,"start"),this.anchors.E=fe(i,"start"),this.anchors.S=fe(o,"start"),this.elmParams.theta=0}},Io=class extends ir{constructor(e={}){let t=e.unit??2;super({...e,unit:t})}setup(){let e=this.userParams.unit??2,t=this.userParams.cycl===!0,n=this.userParams.switch??"spst",s=this.userParams.core!==!1,i=this.userParams.box!==!1,o=this.userParams.boxfill??"none",a=this.userParams.boxpad??.25,l=this.userParams.swreverse===!0,h=this.userParams.swflip===!0,c=this.userParams.link!==!1,m=t?this.add(new Lr({d:"d"})):this.add(new Ir({d:"d"}));this.anchors.in1=fe(m,"start"),this.anchors.in2=fe(m,"end");let f=m.getBBox(!0).xmax,g=f+.6;s&&(this.add(new Pe({d:"d",at:[f+.15,-e/2],anchor:"center",l:1})),g+=.1);let b;if(n==="spst"){let v=new Xr({d:"d",reverse:l,flip:h}),x=v.getBBox(!1);v.userParams.at=[g-(h?-x.ymax:x.ymin),0],this.add(v),this.anchors.a=fe(v,"start"),this.anchors.b=fe(v,"end"),b=v}else if(n==="spdt"){let v=new Xs({d:"d",reverse:l,flip:h}),x=v.getBBox(!1);v.userParams.at=[g-(h?-x.ymax:x.ymin),-.5],this.add(v);let S=l?-e:0,k=l?0:-e,M=this.add(new Pe({d:l?"d":"u",at:fe(v,"a"),toy:S})),_=this.add(new Pe({d:l?"u":"d",at:fe(v,"b"),toy:k})),B=this.add(new Pe({d:l?"u":"d",at:fe(v,"c"),toy:k}));this.anchors.a=fe(M,"end"),this.anchors.b=fe(_,"end"),this.anchors.c=fe(B,"end"),b=v}else if(n==="dpst"){let v=new Gs({d:"d",link:!1,reverse:l,flip:h}),x=v.getBBox(!1);v.userParams.at=[g-(h?-x.ymax:x.ymin),-.5],this.add(v);let S=l?0:-e,k=l?-e:0,M=this.add(new Pe({d:l?"u":"d",at:fe(v,"t1"),toy:S})),_=this.add(new Pe({d:l?"u":"d",at:fe(v,"t2"),toy:S})),B=this.add(new Pe({d:l?"d":"u",at:fe(v,"p1"),toy:k})),$=this.add(new Pe({d:l?"d":"u",at:fe(v,"p2"),toy:k}));this.anchors.t1=fe(M,"end"),this.anchors.t2=fe(_,"end"),this.anchors.p1=fe(B,"end"),this.anchors.p2=fe($,"end"),b=v}else if(n==="dpdt"){let v=new Ws({d:"d",link:!1,reverse:l,flip:h}),x=v.getBBox(!1);v.userParams.at=[g-(h?-x.ymax:x.ymin),-.5],this.add(v);let S=l?0:-e,k=l?-e:0,M=this.add(new Pe({d:l?"u":"d",at:fe(v,"t1"),toy:S})),_=this.add(new Pe({d:l?"u":"d",at:fe(v,"t2"),toy:S})),B=this.add(new Pe({d:l?"u":"d",at:fe(v,"t3"),toy:S})),$=this.add(new Pe({d:l?"u":"d",at:fe(v,"t4"),toy:S})),Y=this.add(new Pe({d:l?"d":"u",at:fe(v,"p1"),toy:k})),Z=this.add(new Pe({d:l?"d":"u",at:fe(v,"p2"),toy:k}));this.anchors.t1=fe(M,"end"),this.anchors.t2=fe(_,"end"),this.anchors.t3=fe(B,"end"),this.anchors.t4=fe($,"end"),this.anchors.p1=fe(Y,"end"),this.anchors.p2=fe(Z,"end"),b=v}else{let v=new Xr({d:"d"});v.userParams.at=[g,0],this.add(v),b=v}if(c){let v=b.getBBox(!1),x=h?v.ymax:v.ymin;this.add(new Pe({d:"r",at:[f+.2,-e/2],ls:":",tox:x}))}if(i){let v=this.getBBox(!1);this.add(new xr({d:"r",at:[0,0],corner1:[v.xmin-a,v.ymin+.2],corner2:[v.xmax+a,v.ymax-.2],fill:o,zorder:0}))}}};var L1=1,D1=.5;function Vs(r,e){let t=r.absanchors[e];return[t.x,t.y]}var vr=class extends ir{constructor(t={}){super({unit:t.unit??1.5,...t});z(this,"inputComponent");z(this,"outputComponent")}setup(){let t=this.userParams._inputFactory,n=this.userParams._outputFactory,s=this.userParams.boxpadx??.2,i=this.userParams.boxpady??.2,o=this.userParams.minw??.5,a=this.userParams.terminals??!0,l=this.userParams.width??2.15,h=this.userParams.box??!0,c=this.userParams.boxfill,m=this.userParams.boxlw,f=this.userParams.boxls,g=(t??(()=>new Xt))();g.down();let b=(n??(()=>new Xt))();b.down();let v=g.getBBox(!1,!1),x=b.getBBox(!1,!1),S=Math.max((v.ymax-v.ymin)/2,o/2),k=Math.max((x.ymax-x.ymin)/2,o/2);g.at([s+S,0]),b.at([l-s-k,0]),this.inputComponent=this.add(g),this.outputComponent=this.add(b);let M=this.getBBox(!1,!1);h&&this.add(new xr({theta:0,at:[0,0],corner1:[0,M.ymin-i],corner2:[l,M.ymax+i],fill:c??"none",lw:m,ls:f,zorder:0})),M=this.getBBox(!1,!1);let _=this.add(new Pe({at:Vs(this.outputComponent,"start")}).tox(M.xmax).right()),B=this.add(new Pe({at:Vs(this.outputComponent,"end")}).tox(M.xmax).right()),$=this.add(new Pe({at:Vs(this.inputComponent,"start")}).tox(M.xmin).left()),Y=this.add(new Pe({at:Vs(this.inputComponent,"end")}).tox(M.xmin).left());if(this.anchors.in_p=Vs($,"end"),this.anchors.in_n=Vs(Y,"end"),this.anchors.out_p=Vs(_,"end"),this.anchors.out_n=Vs(B,"end"),this.anchors.center=[(M.xmin+M.xmax)/2,(M.ymin+M.ymax)/2],this._labelhints.in_p={ofst:[0,.15],halign:"right"},this._labelhints.in_n={ofst:[0,.15],halign:"right"},this._labelhints.out_p={ofst:[0,.15],halign:"left"},this._labelhints.out_n={ofst:[0,.15],halign:"left"},a)for(let Z of["in_p","in_n","out_p","out_n"]){let L=Z.startsWith("in")?-D1:D1,I=this.anchors[Z],X=[I[0]+L,I[1]];this.anchors[Z]=X,this.segments.push(new p([I,X]))}}},Lo=class extends vr{constructor(e={}){super({...e,_inputFactory:()=>new Xt,_outputFactory:()=>new Xt,boxpadx:e.boxpadx??0,minw:e.minw??0})}setup(){super.setup();let e=this.userParams.sign??!0,t=this.userParams.arrow??!0,n=this.userParams.reverse_output??!1;if(e){let s=this.inputComponent.absanchors.end,i=this.inputComponent.absanchors.start;this.segments.push(new W([s.x+.1,s.y+.1],"\u2212",{halign:"left",valign:"center",rotation:0})),this.segments.push(new W([i.x+.1,i.y-.1],"+",{halign:"left",valign:"center",rotation:0}));let o=this.outputComponent.absanchors.end,a=this.outputComponent.absanchors.start;n?(this.segments.push(new W([o.x-.1,o.y+.1],"+",{halign:"right",valign:"center",rotation:0})),this.segments.push(new W([a.x-.1,a.y-.1],"\u2212",{halign:"right",valign:"center",rotation:0}))):(this.segments.push(new W([o.x-.1,o.y+.1],"\u2212",{halign:"right",valign:"center",rotation:0})),this.segments.push(new W([a.x-.1,a.y-.1],"+",{halign:"right",valign:"center",rotation:0})))}if(t){let s=this.anchors.center;this.segments.push(new p([[s[0]-L1/2,s[1]],[s[0]+L1/2,s[1]]],{arrow:"->",lw:2,arrowwidth:.3,arrowlength:.3}))}}},Do=class extends vr{constructor(e={}){let t=e.reverse_output??!1;super({...e,_inputFactory:()=>new Xt,_outputFactory:()=>t?new br:new br({reverse:!0})})}setup(){super.setup();let e=this.inputComponent.absanchors.end,t=this.inputComponent.absanchors.start;this.segments.push(new W([e.x,e.y+.05],"\u2212",{halign:"right",valign:"bottom",rotation:0})),this.segments.push(new W([t.x,t.y-.05],"+",{halign:"right",valign:"top",rotation:0}))}},No=class extends vr{constructor(e={}){let t=e.reverse_output??!1;super({...e,_inputFactory:()=>new Pe,_outputFactory:()=>t?new br:new br({reverse:!0})})}setup(){super.setup();let e=new gn("in",-.15,!0,{headlength:.3});e.at(this.inputComponent),this.add(e)}},Oo=class extends vr{constructor(e={}){let t=e.reverse_output??!1;super({...e,_inputFactory:()=>new Pe,_outputFactory:()=>t?new wr:new wr({reverse:!0})})}setup(){super.setup();let e=new gn("in",-.15,!0,{headlength:.3});e.at(this.inputComponent),this.add(e)}},Fo=class extends vr{constructor(e={}){let t=e.reverse_output??!1;super({...e,_inputFactory:()=>new Xt,_outputFactory:()=>t?new wr:new wr({reverse:!0})})}setup(){super.setup();let e=this.inputComponent.absanchors.end,t=this.inputComponent.absanchors.start;this.segments.push(new W([e.x,e.y+.05],"\u2212",{halign:"right",valign:"bottom",rotation:0})),this.segments.push(new W([t.x,t.y-.05],"+",{halign:"right",valign:"top",rotation:0}))}},$o=class extends vr{constructor(e={}){super({...e,_inputFactory:()=>new Nr,_outputFactory:()=>new Or,boxpadx:e.boxpadx??.3})}},jo=class extends vr{constructor(e={}){super({...e,_inputFactory:()=>new $r,_outputFactory:()=>new Fr,boxpadx:e.boxpadx??.3})}};var Le=1.1,u0=class extends N{constructor(t={}){super(t);z(this,"_outletrad",1.5);let n=!!t.plug,s=this._outletrad,i=ze(Math.PI*3/4,Math.PI*5/4),o=i.map(_=>.15+s*Math.cos(_)),a=i.map(_=>s*Math.sin(_)),l=i.map(_=>-.15+-s*Math.cos(_)),h=i.map(_=>-s*Math.sin(_)),c=[...o,...l],m=[...a,...h],f=c.map((_,B)=>[_,m[B]]);this.segments.push(new U(f));let g=s/8,b=g*3,v=b*1.25,x=b/2,S=v/2,k=s/2.2,M=n?"black":"bg";this.segments.push(new U([[-k,S],[-k,S-v],[-k+g,S-v],[-k+g,S]],{fill:M,zorder:3})),this.segments.push(new U([[k,x],[k,x-b],[k-g,x-b],[k-g,x]],{fill:M,zorder:3})),this.anchors.hot=[k-g/2,0],this.anchors.neutral=[-k+g/2,0],this.elmParams.drop=[k-g/2,0]}},qo=class extends u0{constructor(e={}){super(e);let t=!!e.plug,n=this._outletrad,s=n/4,i=-n/2.5,o=[-s/2,-s/2,s/2,s/2],a=[i,i-s/2,i-s/2,i],l=ze(0,Math.PI);for(let b of l)o.push(s/2*Math.cos(b)),a.push(i+s/2*Math.sin(b));let h=t?"black":"bg",c=o.map((b,v)=>[b,a[v]]);this.segments.push(new U(c,{fill:h,zorder:3}));let m=s/2,f=this.segments[1];f.verts=f.verts.map(([b,v])=>[b,v+m]);let g=this.segments[2];g.verts=g.verts.map(([b,v])=>[b,v+m]),this.anchors.hot=[this.anchors.hot[0],this.anchors.hot[1]+m],this.anchors.neutral=[this.anchors.neutral[0],this.anchors.neutral[1]+m],this.anchors.ground=[0,i]}},m0=class extends N{constructor(e={}){super(e);let n=!!e.plug?"black":"bg";this.segments.push(new D([0,0],Le));let s=Le/8,i=Le/2;this.segments.push(new D([-i,0],s,{fill:n,zorder:3})),this.segments.push(new D([i,0],s,{fill:n,zorder:3})),this.anchors.hot=[i,0],this.anchors.neutral=[-i,0],this.elmParams.drop=[i,0]}},Ho=class extends N{constructor(e={}){super(e);let n=!!e.plug?"black":"bg";this.segments.push(new D([0,0],Le));let s=Le/8,i=Le/2,o=-Le/4,a=Le/2.5;this.segments.push(new D([-i,o],s,{fill:n,zorder:3})),this.segments.push(new D([i,o],s,{fill:n,zorder:3})),this.segments.push(new D([0,a],s*1.2,{fill:n,zorder:3})),this.anchors.hot=[i,o],this.anchors.neutral=[-i,o],this.anchors.ground=[0,a],this.elmParams.drop=[0,a]}},Yo=class extends N{constructor(e={}){super(e);let n=!!e.plug?"black":"bg";this.segments.push(new D([0,0],Le));let s=Le/8,i=Le/2,o=0,a=Le/2;this.segments.push(new D([-i,o],s,{fill:n,zorder:3})),this.segments.push(new D([i,o],s,{fill:n,zorder:3})),this.segments.push(new D([0,a],s,{fill:n,zorder:3})),this.anchors.hot=[i,o],this.anchors.neutral=[-i,o],this.anchors.ground=[0,a],this.elmParams.drop=[-i,o]}},Xo=class extends m0{constructor(e={}){super(e);let n=!!e.plug?"black":"bg",s=Le/8,i=Le/6,o=Le-.05,a=-Le+.05;this.segments.push(new p([[-s,o],[-s,o-i],[s,o-i],[s,o]],{fill:n,zorder:3})),this.segments.push(new p([[-s,a],[-s,a+i],[s,a+i],[s,a]],{fill:n,zorder:3}))}},Go=class extends N{constructor(e={}){super(e);let n=!!e.plug?"black":"bg";this.segments.push(new D([0,0],Le));let s=Le/6,i=s*3,o=Le/5,a=Le*3/4,l=-Le/2.5,h=s;this.segments.push(new U([[-o/2,a],[-o/2,a-i],[o/2,a-i],[o/2,a]],{fill:n,zorder:3})),this.segments.push(new U([[-h,l],[-h,l-s],[-h-i,l-s],[-h-i,l]],{fill:n,zorder:3})),this.segments.push(new U([[h,l],[h,l-s],[h+i,l-s],[h+i,l]],{fill:n,zorder:3})),this.anchors.hot=[h+i/2,l-s/2],this.anchors.neutral=[-h-i/2,l-s/2],this.anchors.ground=[0,a-i/2],this.elmParams.drop=[h+i/2,l-s/2]}},d0=class extends N{constructor(e={}){super(e);let n=!!e.plug?"black":"bg";this.segments.push(new D([0,0],Le));let s=Le/8,i=s*3,o=-s*2,a=[[-s/2,o],[-s/2,o-i],[s/2,o-i],[s/2,o]],l=a.map(c=>Wr(c,120).toTuple()),h=a.map(c=>Wr(c,-120).toTuple());this.segments.push(new U(a,{fill:n,zorder:3})),this.segments.push(new U(l,{fill:n,zorder:3})),this.segments.push(new U(h,{fill:n,zorder:3})),this.anchors.hot=l[1],this.anchors.neutral=h[2],this.anchors.ground=[0,o-i],this.elmParams.drop=l[1]}},Wo=class extends d0{constructor(e={}){super(e);let t=[.4,.3],n=[-.4,.3],s=this.segments[2];s.verts=s.verts.map(o=>Wr(o,90,t).toTuple());let i=this.segments[3];i.verts=i.verts.map(o=>Wr(o,-90,n).toTuple()),this.anchors.hot=Wr(this.anchors.hot,90,t).toTuple(),this.anchors.neutral=Wr(this.anchors.neutral,-90,n).toTuple()}},Vo=class extends N{constructor(e={}){super(e);let n=!!e.plug?"black":"bg",s=Le*1.5,i=s*2,o=i/5;this.segments.push(new U([[-i/2,0],[-i/2+o,s/2],[i/2-o,s/2],[i/2,0],[i/2-o,-s/2],[-i/2+o,-s/2]]));let a=Le/8;this.segments.push(new D([-i/4,0],a,{fill:n,zorder:3})),this.segments.push(new D([0,-a*2],a,{fill:n,zorder:3})),this.segments.push(new D([i/4,0],a,{fill:n,zorder:3})),this.anchors.hot=[i/4,0],this.anchors.neutral=[-i/4,0],this.anchors.ground=[0,-a*2],this.elmParams.drop=[i/4,0]}},Uo=class extends N{constructor(e={}){super(e);let n=!!e.plug?"black":"bg";this.segments.push(new D([0,0],Le));let s=Le/8,i=Le/2;this.segments.push(new D([-i,0],s,{fill:n,zorder:3})),this.segments.push(new D([i,0],s,{fill:n,zorder:3})),this.anchors.hot=[i,0],this.anchors.neutral=[-i,0],this.elmParams.drop=[i,0];let o=Le/4,a=-Le/2,l=[-o/2,-o/2,o/2,o/2],h=[a,a+o/2,a+o/2,a],c=ze(0,Math.PI);for(let f of c)l.push(o/2*Math.cos(f)),h.push(a-o/2*Math.sin(f));let m=l.map((f,g)=>[f,h[g]]);this.segments.push(new U(m,{fill:n,zorder:3})),this.anchors.ground=[0,a]}},Jo=class extends N{constructor(e={}){super(e);let n=!!e.plug?"black":"bg",s=Le*1.2,i=s*2.25;this.segments.push(new U([[-i/2,s/2],[i/2,s/2],[i/2,-s/2],[-i/2,-s/2]]));let o=Le/8;this.segments.push(new D([-i/4,0],o,{fill:n,zorder:3})),this.segments.push(new D([0,0],o,{fill:n,zorder:3})),this.segments.push(new D([i/4,0],o,{fill:n,zorder:3})),this.anchors.hot=[i/4,0],this.anchors.neutral=[-i/4,0],this.anchors.ground=[0,0],this.elmParams.drop=[i/4,0]}};var Us=0,st=1.75,_a=st/2,oh=20,Gt=st*.4,or=st/9,Ba=st/6,Ca=class extends N{constructor(e={}){super(e),Object.assign(this.defaults,{tube_lw:2.5,anode_lw:2,cathode_lw:2,heat_lw:2,grid_lw:2,n_grid_dashes:3,dot_radius:.075,theta:0})}_drawEnvelope(e,t,n="none"){let s=-e,i=t/2,o=-i,a=i,l=[0,-e/2],h=Math.min(t/2,e/2);n==="left"?this.segments.push(new xe(l,t,e,{theta1:90-oh,theta2:270+oh,lw:this.params.tube_lw})):n==="right"?this.segments.push(new xe(l,t,e,{theta1:270-oh,theta2:90+oh,lw:this.params.tube_lw})):this.segments.push(new U([[o,Us],[a,Us],[a,s],[o,s]],{cornerradius:h,lw:this.params.tube_lw})),this.anchors.N=[0,0],this.anchors.S=[0,-e],this.anchors.E=[a,-e/2],this.anchors.W=[o,-e/2];let c=_a/Math.sqrt(2);this.anchors.NE=[c,-_a+c],this.anchors.NW=[-c,-_a+c],this.anchors.SE=[c,-_a-c],this.anchors.SW=[-c,-_a-c],this._labelhints.NE={ofst:[.12,.12],halign:"left"},this._labelhints.NW={ofst:[-.12,.12],halign:"right"},this._labelhints.SE={ofst:[.12,-.12],halign:"left",valign:"top"},this._labelhints.SW={ofst:[-.12,-.12],halign:"right",valign:"top"}}_drawElements(e,t,n,s,i,o,a=""){let l=this.params.dot_radius,h=Us-t/2+Math.max(0,s-1)*or/2,c=h-or*Math.max(0,s-1),m=e-Gt/2,f=e+Gt/2,g=h+or;o==="narrow"?this.segments.push(new p([[e-l,g],[e+l,g]],{lw:this.params.anode_lw})):o==="dot"?(g+=l*2,this.segments.push(new D([e,g-l],l,{lw:this.params.anode_lw}))):o!=="none"&&o!=null&&this.segments.push(new p([[m,g],[f,g]],{lw:this.params.anode_lw})),o!=="none"&&o!=null&&(this.segments.push(new p([[e,Us],[e,g]],{lw:this.params.anode_lw})),this.anchors[`anode${a}`]=[e,Us],this._labelhints[`anode${a}`]={ofst:[.1,.1],halign:"left",valign:"bottom",fontsize:11});let b=this.params.n_grid_dashes,v=Gt/(b+2),x=(Gt-v*(b-1))/b,S=[];for(let _=0;_<b;_++)S.push(m+_*(x+v));for(let _=0;_<s;_++){let B=h-or*_;for(let $=0;$<b;$++)this.segments.push(new p([[S[$],B],[S[$]+x,B]],{lw:this.params.grid_lw}));s===1?(this.anchors[`grid${a}`]=[m-v,B],this.anchors[`grid${a}_R`]=[f+v,B],this._labelhints[`grid${a}`]={ofst:[-n/2-m+.1,.1],halign:"right",valign:"bottom",fontsize:11},this._labelhints[`grid${a}_R`]={ofst:[n/2-f-.1,.1],halign:"left",valign:"bottom",fontsize:11}):(this.anchors[`grid${a}_${_+1}`]=[m-v,B],this.anchors[`grid${a}_${_+1}R`]=[f+v,B],this._labelhints[`grid${a}_${_+1}`]={ofst:[-n/2-m+.1,.1],halign:"right",valign:"bottom",fontsize:11},this._labelhints[`grid${a}_${_+1}R`]={ofst:[n/2-f-.1,.1],halign:"left",valign:"bottom",fontsize:11})}let k=c-or,M=l*2;return i==="cold"?(this.segments.push(new p([[e,k-l*2],[e,-t]])),this.segments.push(new D([e,k-l],l)),this.anchors[`cathode${a}`]=[e,-t],this._labelhints[`cathode${a}`]={ofst:[.1,-.1],halign:"left",valign:"top",fontsize:11}):i!=="none"&&i!=null&&(this.segments.push(new p([[m,k-M],[m,k],[f,k],[f,k-M]],{lw:this.params.cathode_lw})),this.anchors[`cathode${a}`]=[m,k-M],this.anchors[`cathode${a}_R`]=[f,k-M],this._labelhints[`cathode${a}`]={ofst:[-.1,-t-k+M],halign:"right",valign:"top",fontsize:11},this._labelhints[`cathode${a}_R`]={ofst:[.1,-t-k+M],halign:"left",valign:"top",fontsize:11}),k}_drawHeat(e,t){let n=e-or*1.25,s=-Gt/3.5,i=Gt/3.5,o=Us-t-or,a=n-Math.sqrt(2)*i;this.segments.push(new p([[s,o],[s,a],[0,n],[i,a],[i,o]],{lw:this.params.heat_lw})),this.anchors.heat1=[s,o],this.anchors.heat2=[i,o],this._labelhints.heat1={ofst:[-.1,0],halign:"right",valign:"bottom",fontsize:11},this._labelhints.heat2={ofst:[.1,0],halign:"left",valign:"bottom",fontsize:11}}},Gr=class extends Ca{constructor(e={}){let{cathode:t="heated",anodetype:n="plate",grids:s=1,heater:i=!0,split:o="none",...a}=e;super(a);let l=Math.max(st,st+(s-4)*or);this._drawEnvelope(l,st,o);let h=this._drawElements(0,l,st,s,t,n);i&&this._drawHeat(h,l)}},Ko=class extends Ca{constructor(e={}){let{cathode:t="heated",anodetype:n="plate",grids_left:s=1,grids_right:i=1,heater:o=!0,...a}=e;super(a);let l=Math.max(s,i),h=Math.max(st,st+(l-4)*or),c=st*1.5,m=-c*.2,f=c*.2;this._drawEnvelope(h,c);let g=this._drawElements(m,h,c,s,t,n,"A"),b=this._drawElements(f,h,c,i,t,n,"B");o&&this._drawHeat(Math.min(g,b),h)}},Zo=class extends Ca{constructor(e={}){let{anodes:t=3,cathode:n="T",anodetype:s="narrow",grid:i=!1,...o}=e;super(o);let a=st,l=Math.max(st,(t-1)*Ba+st);this._drawEnvelope(a,l),i&&this._drawNixieGrid(t,l),this._drawNixieAnodes(t,s),this._drawNixieCathode(t,n)}_drawNixieAnodes(e,t){let n=-st/4,i=-((e-1)*Ba)/2,o=this.params.dot_radius;for(let a=0;a<e;a++){let l=i+a*Ba;t==="dot"?this.segments.push(new D([l,n-o],o,{lw:this.params.anode_lw})):this.segments.push(new p([[l-o,n],[l+o,n]],{lw:this.params.anode_lw})),this.segments.push(new p([[l,Us],[l,n]],{lw:this.params.anode_lw})),this.anchors[`anode${a}`]=[l,Us],this._labelhints[`anode${a}`]={ofst:[-.1,.1],halign:"right",valign:"bottom",fontsize:11}}}_drawNixieGrid(e,t){let n=(e-1)*Ba,s=-n/2,i=e+1,o=n/(i+2),a=(n-o*(i-1))/i,l=[];for(let c=0;c<i;c++)l.push(s+c*(a+o));let h=-st/2;for(let c=0;c<i;c++)this.segments.push(new p([[l[c],h],[l[c]+a,h]],{lw:this.params.grid_lw}));this.anchors.grid=[s-o,h],this.anchors.grid_R=[s+n+o,h],this._labelhints.grid={ofst:[-t/2-s,.1],halign:"right",valign:"bottom",fontsize:11},this._labelhints.grid_R={ofst:[t/2-n/2,.1],halign:"left",valign:"bottom",fontsize:11}}_drawNixieCathode(e,t){let n=this.params.dot_radius,s=-3*st/4,i=n,o=(e-1)*Ba;t==="cold"?(this.segments.push(new p([[0,s-n*2],[0,-st]],{lw:this.params.cathode_lw})),this.segments.push(new D([0,s-n],n)),this.anchors.cathode=[0,-st]):t==="heated"?(this.segments.push(new p([[-Gt/2,s-i],[-Gt/2,s],[Gt/2,s],[Gt/2,s-i]],{lw:this.params.cathode_lw})),this.anchors.cathode=[-Gt/2,s-i],this.anchors.cathode_R=[Gt/2,s-i]):t!=="none"&&t!=null&&(this.segments.push(new p([[0,-st],[0,s],H,[-o/2,s],[o/2,s]],{lw:this.params.cathode_lw})),this.anchors.cathode=[0,-st])}},Qo=class extends Gr{constructor(e={}){let{heater:t=!1,split:n="none",...s}=e;super({cathode:"heated",grids:0,heater:t,split:n,...s})}},ea=class extends Gr{constructor(e={}){let{heater:t=!1,split:n="none",...s}=e;super({cathode:"heated",grids:1,heater:t,split:n,...s}),this.anchors.control=this.anchors.grid,this.anchors.control_R=this.anchors.grid_R,this._labelhints.control=this._labelhints.grid,this._labelhints.control_R=this._labelhints.grid_R}},ta=class extends Gr{constructor(e={}){let{heater:t=!1,split:n="none",...s}=e;super({cathode:"heated",grids:2,heater:t,split:n,...s}),this.anchors.screen=this.anchors.grid_1,this.anchors.screen_R=this.anchors.grid_1R,this.anchors.control=this.anchors.grid_2,this.anchors.control_R=this.anchors.grid_2R,this._labelhints.screen=this._labelhints.grid_1,this._labelhints.screen_R=this._labelhints.grid_1R,this._labelhints.control=this._labelhints.grid_2,this._labelhints.control_R=this._labelhints.grid_2R}},ra=class extends Gr{constructor(e={}){let{strap:t=!1,heater:n=!1,split:s="none",...i}=e;if(super({cathode:"heated",grids:3,heater:n,split:s,...i}),this.anchors.suppressor=this.anchors.grid_1,this.anchors.suppressor_R=this.anchors.grid_1R,this.anchors.screen=this.anchors.grid_2,this.anchors.screen_R=this.anchors.grid_2R,this.anchors.control=this.anchors.grid_3,this.anchors.control_R=this.anchors.grid_3R,this._labelhints.suppressor=this._labelhints.grid_1,this._labelhints.suppressor_R=this._labelhints.grid_1R,this._labelhints.screen=this._labelhints.grid_2,this._labelhints.screen_R=this._labelhints.grid_2R,this._labelhints.control=this._labelhints.grid_3,this._labelhints.control_R=this._labelhints.grid_3R,t){let o=this.params.dot_radius,a=this.anchors.cathode_R,l=[a[0],a[1]+o*2],h=this.anchors.suppressor_R,c=[Gt/2,h[1]],m=[l[0]+or*.75,l[1]+or/2],f=[m[0],c[1]-or/2];this.segments.push(new p([l,m,f,c],{lw:this.params.cathode_lw}))}}};var Js={ResistorIEEE:r=>new dt(r??{}),ResistorIEC:r=>new mt(r??{}),ResistorVarIEEE:r=>new cr(r??{}),ResistorVarIEC:r=>new Zt(r??{}),Thermistor:r=>new Jn(r??{}),PhotoresistorIEEE:r=>new ur(r??{}),PhotoresistorIEC:r=>new Qt(r??{}),Rshunt:r=>new Kn(r??{}),PotentiometerIEEE:r=>new mr(r??{}),PotentiometerIEC:r=>new er(r??{}),FuseIEEE:r=>new dr(r??{}),FuseIEC:r=>new Dr(r??{}),Resistor:r=>new Zn(r??{}),ResistorVar:r=>new Qn(r??{}),Photoresistor:r=>new ts(r??{}),Potentiometer:r=>new es(r??{}),Fuse:r=>new rs(r??{}),Memristor:r=>new ns(r??{}),Memristor2:r=>new ss(r??{}),Josephson:r=>new is(r??{}),FuseUS:r=>new os(r??{}),Breaker:r=>new as(r??{}),CPE:r=>new ls(r??{}),SparkGap:r=>new hs(r??{}),Nullator:r=>new Nr(r??{}),Norator:r=>new Or(r??{}),CurrentMirror:r=>new Fr(r??{}),VoltageMirror:r=>new $r(r??{}),Capacitor:r=>new Cr(r??{}),Capacitor2:r=>new Cn(r??{}),CapacitorVar:r=>new In(r??{}),CapacitorTrim:r=>new Ln(r??{}),Diode:r=>new et(r??{}),Schottky:r=>new Dn(r??{}),Zener:r=>new Nn(r??{}),DiodeTunnel:r=>new On(r??{}),DiodeTVS:r=>new Fn(r??{}),DiodeShockley:r=>new $n(r??{}),Varactor:r=>new jn(r??{}),LED:r=>new qn(r??{}),LED2:r=>new Hn(r??{}),Photodiode:r=>new Yn(r??{}),SCR:r=>new Xn(r??{}),Diac:r=>new on(r??{}),Triac:r=>new Gn(r??{}),Inductor:r=>new Ir(r??{}),Inductor2:r=>new Lr(r??{}),Crystal:r=>new Un(r??{}),Opamp:r=>new cs(r??{}),AnalogBiasedFet:r=>new j0(r??{}),AnalogNFet:r=>new F0(r??{}),AnalogPFet:r=>new $0(r??{}),Bjt:r=>new qr(r??{}),Bjt2:r=>new Hr(r??{}),BjtNpn:r=>new Ht(r??{}),BjtNpn2:r=>new Ss(r??{}),BjtPnp:r=>new rr(r??{}),BjtPnp2:r=>new ln(r??{}),BjtPnp2c:r=>new W0(r??{}),BjtPnp2c2:r=>new ei(r??{}),Hemt:r=>new G0(r??{}),IgbtN:r=>new Z0(r??{}),IgbtP:r=>new Q0(r??{}),JFet:r=>new vs(r??{}),JFet2:r=>new ys(r??{}),JFetN:r=>new q0(r??{}),JFetN2:r=>new Y0(r??{}),JFetP:r=>new H0(r??{}),JFetP2:r=>new X0(r??{}),NFet:r=>new gs(r??{}),NFet2:r=>new ws(r??{}),NMos:r=>new ms(r??{}),NMos2:r=>new ps(r??{}),NpnPhoto:r=>new J0(r??{}),NpnSchottky:r=>new V0(r??{}),PFet:r=>new bs(r??{}),PFet2:r=>new xs(r??{}),PMos:r=>new ds(r??{}),PMos2:r=>new fs(r??{}),PnpPhoto:r=>new K0(r??{}),PnpSchottky:r=>new U0(r??{}),DFlipFlop:r=>new ri(r??{}),Ic:r=>new nr(r??{}),Ic555:r=>new ii(r??{}),IcDIP:r=>new ai(r??{}),JKFlipFlop:r=>new ni(r??{}),Multiplexer:r=>new ti(r??{}),SevenSegment:r=>new oi(r??{}),VoltageRegulator:r=>new si(r??{}),Source:r=>new rt(r??{}),SourceV:r=>new Ri(r??{}),SourceI:r=>new Ai(r??{}),SourceSin:r=>new _i(r??{}),SourcePulse:r=>new Bi(r??{}),SourceSquare:r=>new Li(r??{}),SourceTriangle:r=>new Ci(r??{}),SourceRamp:r=>new Ii(r??{}),SourceControlled:r=>new Ys(r??{}),SourceControlledV:r=>new br(r??{}),SourceControlledI:r=>new wr(r??{}),BatteryCell:r=>new Di(r??{}),Battery:r=>new Ni(r??{}),BatteryDouble:r=>new Oi(r??{}),Solar:r=>new Fi(r??{}),MeterV:r=>new $i(r??{}),MeterI:r=>new ji(r??{}),MeterA:r=>new qi(r??{}),MeterOhm:r=>new Hi(r??{}),MeterArrow:r=>new Yi(r??{}),Lamp:r=>new Xi(r??{}),Lamp2:r=>new Gi(r??{}),Neon:r=>new Wi(r??{}),MeterBox:r=>new mn(r??{}),MeterAnalog:r=>new Vi(r??{}),Oscilloscope:r=>new Ui(r??{}),MeterDigital:r=>new Ji(r??{}),GroundSignal:r=>new Ki(r??{}),GroundChassis:r=>new Zi(r??{}),Antenna:r=>new Qi(r??{}),AntennaLoop:r=>new eo(r??{}),AntennaLoop2:r=>new to(r??{}),Vss:r=>new ro(r??{}),Vdd:r=>new no(r??{}),NoConnect:r=>new so(r??{}),Switch:r=>new Xr(r??{}),SwitchSpdt:r=>new io(r??{}),SwitchSpdt2:r=>new Xs(r??{}),SwitchDpst:r=>new Gs(r??{}),SwitchDpdt:r=>new Ws(r??{}),Button:r=>new oo(r??{}),SwitchReed:r=>new ao(r??{}),SwitchRotary:r=>new lo(r??{}),SwitchDIP:r=>new ho(r??{}),Speaker:r=>new co(r??{}),Mic:r=>new uo(r??{}),Motor:r=>new mo(r??{}),AudioJack:r=>new po(r??{}),Coax:r=>new fo(r??{}),Triax:r=>new go(r??{}),Transformer:r=>new bo(r??{}),Line:r=>new Pe(r??{}),Ground:r=>new Ti(r??{}),Arrow:r=>new dn(r??{}),DataBusLine:r=>new wo(r??{}),Dot:r=>new pn(r??{}),DotDotDot:r=>new vo(r??{}),Gap:r=>new Xt(r??{}),Arrowhead:r=>new xo(r??{}),Label:r=>new So(r??{}),Rect:r=>new xr(r??{}),Tag:r=>new ko(r??{}),Wire:r=>new yo(r??{}),Annotate:r=>new zo(r??{}),Arc2:r=>new Mo(r??{}),Arc3:r=>new fn(r??{}),ArcLoop:r=>new To(r??{}),ArcN:r=>new Po(r??{}),ArcZ:r=>new Eo(r??{}),CurrentLabel:r=>new h0(r??{}),CurrentLabelInline:r=>{let{direction:e,ofst:t,start:n,...s}=r??{};return new gn(e,t,n,s)},LoopArrow:r=>new c0(r??{}),VoltageLabelArc:r=>new Ro(r??{}),ZLabel:r=>new Ao(r??{}),Optocoupler:r=>new _o(r??{}),Rectifier:r=>new Bo(r??{}),Relay:r=>new Io(r??{}),Wheatstone:r=>new Co(r??{}),TwoPort:r=>new Lo(r??{}),VoltageTransactor:r=>new Do(r??{}),TransimpedanceTransactor:r=>new No(r??{}),CurrentTransactor:r=>new Oo(r??{}),TransadmittanceTransactor:r=>new Fo(r??{}),Nullor:r=>new $o(r??{}),VMCMPair:r=>new jo(r??{}),OrthoLines:r=>new di(r??{}),RightLines:r=>new Hs(r??{}),Header:r=>new pi(r??{}),Jumper:r=>new fi(r??{}),BusConnect:r=>new gi(r??{}),BusLine:r=>new bi(r??{}),DB25:r=>new xi(r??{}),DE9:r=>new a0(r??{}),DB9:r=>new wi(r??{}),DA15:r=>new vi(r??{}),DC37:r=>new yi(r??{}),DD50:r=>new Si(r??{}),CoaxConnect:r=>new ki(r??{}),Plug:r=>new Mi(r??{}),Jack:r=>new zi(r??{}),ConnectorTerminal:r=>new Ei(r??{}),OutletA:r=>new u0(r??{}),OutletB:r=>new qo(r??{}),OutletC:r=>new m0(r??{}),OutletD:r=>new Ho(r??{}),OutletE:r=>new Yo(r??{}),OutletF:r=>new Xo(r??{}),OutletG:r=>new Go(r??{}),OutletH:r=>new d0(r??{}),OutletI:r=>new Wo(r??{}),OutletJ:r=>new Vo(r??{}),OutletK:r=>new Uo(r??{}),OutletL:r=>new Jo(r??{}),VacuumTube:r=>new Gr(r??{}),DualVacuumTube:r=>new Ko(r??{}),NixieTube:r=>new Zo(r??{}),TubeDiode:r=>new Qo(r??{}),Triode:r=>new ea(r??{}),Tetrode:r=>new ta(r??{}),Pentode:r=>new ra(r??{}),ElementImage:r=>{let{image:e,width:t,height:n,...s}=r??{};return new js(e,t,n,s)},And:r=>new Bt(r??{}),Or:r=>new $t(r??{}),Buf:r=>new Jt(r??{}),Not:r=>new Kt(r??{}),Tristate:r=>new Bn(r??{}),Kmap:r=>new A0(r??{}),BitField:r=>new s0(r??{}),NotNot:r=>new C0(r??{}),Schmitt:r=>new L0(r??{}),SchmittAnd:r=>new o0(r??{}),SchmittNand:r=>Yl(r),SchmittNot:r=>new D0(r??{}),Table:r=>new B0(r),Tgate:r=>new I0(r??{}),TimingDiagram:r=>new n0(r??{}),FlowBox:r=>new cn(r??{}),RoundBox:r=>new Yr(r??{}),Terminal:r=>new hn(r??{}),RoundProcess:r=>new li(r??{}),Process:r=>new hi(r??{}),Start:r=>new ci(r??{}),Subroutine:r=>new ks(r??{}),Data:r=>new Ms(r??{}),Ellipse:r=>new zs(r??{}),Decision:r=>new Es(r??{}),Connect:r=>new pr(r??{}),Circle:r=>new ui(r??{}),State:r=>new mi(r??{}),StateEnd:r=>new Ps(r??{}),DspBox:r=>new sr(r??{}),DspCircle:r=>new Yt(r??{}),Sum:r=>new Ts(r??{}),SumSigma:r=>new Rs(r??{}),Mixer:r=>new As(r??{}),DspSpeaker:r=>new _s(r??{}),Amp:r=>new un(r??{}),OscillatorBox:r=>new Bs(r??{}),Oscillator:r=>new Cs(r??{}),Filter:r=>new Is(r??{}),Adc:r=>new Ls(r??{}),Dac:r=>new Ds(r??{}),Demod:r=>new Ns(r??{}),Circulator:r=>new Os(r??{}),Isolator:r=>new Fs(r??{}),VGA:r=>new $s(r??{}),RBox:r=>new mt(r??{}),RBoxVar:r=>new Zt(r??{}),PotBox:r=>new er(r??{}),PhotoresistorBox:r=>new Qt(r??{}),Nand:r=>Tn(r),Nor:r=>Rn(r),Xor:r=>An(r),Xnor:r=>_n(r)};function eu(){return Object.keys(Js).sort()}var N1=eu;function O1(r){let e=Js[r];if(!e)throw new Error(`Unknown element type "${r}". Use getAvailableTypes() to see all available types.`);let t=e();return new lr().add(t),Object.keys(t.absanchors).sort()}function tu(r,e){let t=r.indexOf(".");if(t<0)throw new Error(`Invalid anchor reference "${r}". Expected format "elementId.anchorName"`);let n=r.slice(0,t),s=r.slice(t+1),i=e.get(n);if(!i){let a=[...e.keys()].join(", ")||"(none)";throw new Error(`Element "${n}" not found. Available elements: ${a}`)}let o=i.absanchors[s];if(!o){let a=Object.keys(i.absanchors).join(", ")||"(none)";throw new Error(`Anchor "${s}" not found on element "${n}". Available anchors: ${a}`)}return o.toTuple()}function Ia(r,e){return Array.isArray(r)?r:tu(r,e)}function ah(r,e){return typeof r=="number"?r:tu(r,e)}function lh(r,e){return typeof r=="number"?r:tu(r,e)}var yr={light:{bg:"#ffffff",stroke:"#000000",fill:"none",text:"#000000",font:"sans-serif",lw:2},dark:{bg:"#1a1a2e",stroke:"#c8d6e5",fill:"none",text:"#dfe6e9",font:"sans-serif",lw:2},print:{bg:"#ffffff",stroke:"#333333",fill:"none",text:"#333333",font:"serif",lw:1.5}},Ks={bg:"--circuit-bg",stroke:"--circuit-stroke",fill:"--circuit-fill",text:"--circuit-text",font:"--circuit-font",lw:"--circuit-lw"};function C2(){if(typeof getComputedStyle>"u")return{...yr.light};let r=getComputedStyle(document.documentElement),e=t=>r.getPropertyValue(t).trim();return{bg:e(Ks.bg)||"transparent",stroke:e(Ks.stroke)||yr.light.stroke,fill:e(Ks.fill)||"none",text:e(Ks.text)||yr.light.text,font:e(Ks.font)||yr.light.font,lw:parseFloat(e(Ks.lw))||yr.light.lw}}function Zs(r){if(r===void 0)return{...yr.light};if(typeof r=="string"){if(r==="auto")return C2();let e=yr[r];if(!e)throw new Error(`Unknown theme "${r}". Available: ${Object.keys(yr).join(", ")}, auto`);return{...e}}return{...yr.light,...r}}var F1={bg:"bgcolor",stroke:"color",fill:"fill",font:"font",lw:"lw"};function $1(r,e){let t={};for(let n of Object.keys(F1)){let s=F1[n];s&&(t[s]=r[n])}return{...t,...e}}function hh(r,e){let t=typeof r=="string"?JSON.parse(r):r,n=e?.theme??t.theme,s=n!==void 0?$1(Zs(n),t.drawing):{...t.drawing??{}},i=e?.colorTransition??t.drawing?.colorTransition??!1,o={...s,...e?.interactive?{interactive:!0}:{},...i?{colorTransition:!0}:{}},a=new lr(o),l=new Map;for(let h of t.elements){if(h==="push"){a.push();continue}if(h==="pop"){a.pop();continue}let c=Js[h.type];if(!c)throw new Error(`Unknown element type "${h.type}". Use getAvailableTypes() to see all available types.`);let m=c(h.params);if(h.d)switch(h.d){case"up":m.up();break;case"down":m.down();break;case"left":m.left();break;case"right":m.right();break}if(h.theta!==void 0&&m.theta(h.theta),h.at!==void 0&&m.at(Ia(h.at,l)),h.anchor&&m.anchor(h.anchor),h.flip&&m.flip(),h.reverse&&m.reverse(),h.scale!==void 0&&m.scale(h.scale),m instanceof se&&(h.to!==void 0&&m.to(Ia(h.to,l)),h.tox!==void 0&&m.tox(ah(h.tox,l)),h.toy!==void 0&&m.toy(lh(h.toy,l)),h.l!==void 0&&m.length(h.l),h.dot&&m.dot(h.dot==="open"),h.idot&&m.idot(h.idot==="open")),h.label)if(typeof h.label=="string")m.label(h.label);else{let{text:f,...g}=h.label;m.label(f,g)}if(h.labels)for(let f of h.labels){let{text:g,...b}=f;m.label(g,b)}h.color&&m.color(h.color),h.fill&&m.fill(h.fill),h.lw!==void 0&&m.linewidth(h.lw),h.ls&&m.linestyle(h.ls),a.add(m),h.id&&(l.set(h.id,m),e?.interactive&&a.setElementMeta(m,{id:h.id,type:h.type,tooltip:h.tooltip??`${h.id} \u2014 ${h.type}`}))}return a.toSvgString()}function j1(r){let e=[],t;if(typeof r=="string")try{t=JSON.parse(r)}catch(i){return{valid:!1,errors:[{path:"",message:`Invalid JSON: ${i.message}`}]}}else t=r;if(!t.elements||!Array.isArray(t.elements))return e.push({path:"elements",message:'"elements" must be an array'}),{valid:!1,errors:e};let n=new Set,s=0;for(let i=0;i<t.elements.length;i++){let o=t.elements[i],a=`elements[${i}]`;if(typeof o=="string"){o==="push"?s++:o==="pop"?(s--,s<0&&(e.push({path:a,message:'"pop" without matching "push"'}),s=0)):e.push({path:a,message:`Invalid control instruction "${o}". Expected "push" or "pop"`});continue}if(typeof o!="object"||o===null){e.push({path:a,message:'Element must be an object or "push"/"pop" string'});continue}let l=o;if(!l.type||typeof l.type!="string"){e.push({path:`${a}.type`,message:'"type" is required and must be a string'});continue}Js[l.type]||e.push({path:`${a}.type`,message:`Unknown element type "${l.type}"`}),l.d&&!["up","down","left","right"].includes(l.d)&&e.push({path:`${a}.d`,message:`Invalid direction "${l.d}". Expected "up", "down", "left", or "right"`});for(let h of["at","to","tox","toy"]){let c=l[h];if(typeof c=="string"&&c.includes(".")){let m=c.slice(0,c.indexOf("."));n.has(m)||e.push({path:`${a}.${h}`,message:`Element "${m}" referenced before definition`})}else typeof c=="string"&&!c.includes(".")&&e.push({path:`${a}.${h}`,message:`Invalid anchor reference "${c}". Expected format "elementId.anchorName"`})}l.id&&n.add(l.id)}return s>0&&e.push({path:"elements",message:`${s} unmatched "push" without "pop"`}),{valid:e.length===0,errors:e}}var na="data-sd-original-style",ru="path,polyline,polygon,circle,ellipse,line";function I2(r){r.hasAttribute(na)||r.setAttribute(na,r.getAttribute("style")??"")}function q1(r){let e=r.getAttribute(na);e!==null?(r.setAttribute("style",e),r.removeAttribute(na)):r.style.removeProperty("stroke")}var La=class{constructor(e,t,n){z(this,"_container");z(this,"_json");z(this,"_opts");z(this,"_svg");z(this,"_elementMap",new Map);z(this,"_listeners",new Map);z(this,"_selectedId",null);z(this,"_theme");z(this,"_destroyed",!1);z(this,"_tooltipEl",null);z(this,"_autoObserver",null);z(this,"_mediaQuery",null);z(this,"_mediaHandler",null);z(this,"_boundClick");z(this,"_boundMouseover");z(this,"_boundMouseout");z(this,"_boundContextmenu");z(this,"_boundMousemove");this._container=e,this._json=t,this._opts={...n,interactive:!0},this._theme=Zs(n.theme??this._json.theme),this._boundClick=this._onClick.bind(this),this._boundMouseover=this._onMouseover.bind(this),this._boundMouseout=this._onMouseout.bind(this),this._boundContextmenu=this._onContextmenu.bind(this),this._boundMousemove=this._onMousemove.bind(this),this._render(),this._bindEvents(),this._initTooltip(),this._initAutoTheme()}_isAutoTheme(){return(this._opts.theme??this._json.theme)==="auto"}_initAutoTheme(){if(!this._isAutoTheme())return;let e=()=>{this._destroyed||(this._theme=Zs("auto"),this._unbindEvents(),this._render(),this._bindEvents(),this._selectedId=null)};this._autoObserver=new MutationObserver(e),this._autoObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-theme","data-color-mode","style"]}),typeof matchMedia<"u"&&(this._mediaQuery=matchMedia("(prefers-color-scheme: dark)"),this._mediaHandler=e,this._mediaQuery.addEventListener("change",this._mediaHandler))}_teardownAutoTheme(){this._autoObserver&&(this._autoObserver.disconnect(),this._autoObserver=null),this._mediaQuery&&this._mediaHandler&&(this._mediaQuery.removeEventListener("change",this._mediaHandler),this._mediaQuery=null,this._mediaHandler=null)}_render(){let e=hh(this._json,this._opts);this._container.innerHTML=e;let t=this._container.querySelector("svg");if(!t)throw new Error("Failed to render SVG from circuit JSON.");this._svg=t,this._svg.querySelectorAll("g.sd-el > title").forEach(o=>o.remove()),this._elementMap.clear();let n=this._svg.querySelectorAll("g.sd-el[data-id]"),s=new Map;for(let o of this._json.elements)o!=="push"&&o!=="pop"&&o.id&&s.set(o.id,o);let i="http://www.w3.org/2000/svg";n.forEach(o=>{let a=o.getAttribute("data-id"),l=o.getAttribute("data-type")??"",h=o.getAttribute("data-tooltip")??void 0,c=o.getBBox(),m=document.createElementNS(i,"rect");m.setAttribute("x",String(c.x)),m.setAttribute("y",String(c.y)),m.setAttribute("width",String(c.width)),m.setAttribute("height",String(c.height)),m.setAttribute("fill","transparent"),m.setAttribute("stroke","none"),o.prepend(m);let f=s.get(a)??{type:l,id:a};this._elementMap.set(a,{info:{id:a,type:l,tooltip:h,bbox:{x:c.x,y:c.y,width:c.width,height:c.height},anchors:{},element:o,spec:f},spec:f})})}_initTooltip(){let e=document.createElement("div");e.className="schemdraw-tooltip",e.style.cssText="position:fixed;z-index:99999;pointer-events:none;opacity:0;transition:opacity .15s ease;font-size:12px;line-height:1.4;padding:6px 12px;border-radius:6px;max-width:260px;white-space:pre-wrap;",this._applyTooltipTheme(e),document.body.appendChild(e),this._tooltipEl=e}_applyTooltipTheme(e){document.documentElement.classList.contains("dark")||document.documentElement.getAttribute("data-theme")==="dark"||typeof window<"u"&&window.matchMedia?.("(prefers-color-scheme: dark)").matches&&!document.documentElement.classList.contains("light")?(e.style.background="rgba(250,250,250,.95)",e.style.color="#1a1a1a",e.style.boxShadow="0 2px 12px rgba(0,0,0,.4)"):(e.style.background="rgba(15,15,15,.92)",e.style.color="#fff",e.style.boxShadow="0 2px 8px rgba(0,0,0,.2)")}_showTooltip(e,t,n){let s=this._tooltipEl;if(!s)return;this._applyTooltipTheme(s),s.textContent=e,s.style.opacity="1";let i=10,o=window.innerWidth,a=window.innerHeight;s.style.left="0",s.style.top="0";let l=s.getBoundingClientRect(),h=t+i,c=n+i;h+l.width>o&&(h=t-l.width-i),c+l.height>a&&(c=n-l.height-i),s.style.left=`${h}px`,s.style.top=`${c}px`}_hideTooltip(){this._tooltipEl&&(this._tooltipEl.style.opacity="0")}_bindEvents(){this._svg.addEventListener("click",this._boundClick),this._svg.addEventListener("mouseover",this._boundMouseover),this._svg.addEventListener("mouseout",this._boundMouseout),this._svg.addEventListener("mousemove",this._boundMousemove),this._svg.addEventListener("contextmenu",this._boundContextmenu)}_unbindEvents(){this._svg.removeEventListener("click",this._boundClick),this._svg.removeEventListener("mouseover",this._boundMouseover),this._svg.removeEventListener("mouseout",this._boundMouseout),this._svg.removeEventListener("mousemove",this._boundMousemove),this._svg.removeEventListener("contextmenu",this._boundContextmenu)}_closestGroup(e){let t=e.target;return t?t.closest("g.sd-el[data-id]"):null}_svgPoint(e){let t=this._svg.getScreenCTM();if(t){let n=t.inverse();return{x:n.a*e.clientX+n.c*e.clientY+n.e,y:n.b*e.clientX+n.d*e.clientY+n.f,clientX:e.clientX,clientY:e.clientY}}return{x:e.offsetX,y:e.offsetY,clientX:e.clientX,clientY:e.clientY}}_getInfoForGroup(e){let t=e.getAttribute("data-id");if(t)return this._elementMap.get(t)?.info}_onClick(e){let t=this._closestGroup(e);if(t){let n=this._getInfoForGroup(t);if(n){this._emit("element:click",n,e);let s=this._selectedId;this._selectedId=n.id,s&&s!==n.id&&this._clearSelectedClass(s),t.classList.add("sd-selected"),this._emit("element:select",n,e)}}else this._selectedId&&(this._clearSelectedClass(this._selectedId),this._selectedId=null,this._emit("element:select",null,e)),this._emit("canvas:click",this._svgPoint(e),e)}_onMouseover(e){let t=this._closestGroup(e);if(!t)return;let n=e.relatedTarget;if(n&&t.contains(n))return;let s=this._getInfoForGroup(t);s&&(this._emit("element:hover",s,e),s.tooltip&&this._showTooltip(s.tooltip,e.clientX,e.clientY))}_onMousemove(e){let t=this._closestGroup(e);if(t){let n=t.getAttribute("data-tooltip");n&&this._showTooltip(n,e.clientX,e.clientY)}else this._hideTooltip()}_onMouseout(e){let t=this._closestGroup(e);if(!t)return;let n=e.relatedTarget;if(n&&t.contains(n))return;let s=this._getInfoForGroup(t);s&&(this._emit("element:leave",s,e),this._hideTooltip())}_onContextmenu(e){this._emit("canvas:contextmenu",this._svgPoint(e),e)}_clearSelectedClass(e){let t=this._elementMap.get(e);t&&(t.info.element.classList.remove("sd-selected"),t.info.element.style.removeProperty("--sd-highlight"),t.info.element.querySelectorAll(ru).forEach(n=>{let s=n;s.hasAttribute(na)&&q1(s)}))}_emit(e,...t){let n=this._listeners.get(e);if(n)for(let s of n)try{s(...t)}catch{}}on(e,t){return this._listeners.has(e)||this._listeners.set(e,new Set),this._listeners.get(e).add(t),this}off(e,t){return t?this._listeners.get(e)?.delete(t):this._listeners.delete(e),this}highlight(e,t){let n=this._elementMap.get(e);n&&(n.info.element.classList.add("sd-selected"),t&&(n.info.element.style.setProperty("--sd-highlight",t),n.info.element.querySelectorAll(ru).forEach(s=>{let i=s;I2(i),i.style.setProperty("stroke",t)})))}clearHighlight(){this._svg.querySelectorAll("g.sd-selected").forEach(t=>{t.classList.remove("sd-selected"),t.style.removeProperty("--sd-highlight"),t.querySelectorAll(ru).forEach(n=>{let s=n;s.hasAttribute(na)&&q1(s)})}),this._selectedId=null}setTheme(e){this._teardownAutoTheme(),this._opts={...this._opts,theme:e},this._theme=Zs(e),this.update(this._json),this._initAutoTheme()}update(e){let t=typeof e=="string"?JSON.parse(e):e;this._json=t,this._unbindEvents(),this._render(),this._bindEvents(),this._selectedId=null}destroy(){this._destroyed||(this._destroyed=!0,this._unbindEvents(),this._teardownAutoTheme(),this._tooltipEl&&(this._tooltipEl.remove(),this._tooltipEl=null),this._container.innerHTML="",this._elementMap.clear(),this._listeners.clear())}get svgElement(){return this._svg}getElementInfo(e){return this._elementMap.get(e)?.info}getAllElements(){return[...this._elementMap.values()].map(e=>e.info)}getDrawingInfo(){let e=this._svg.getAttribute("viewBox")??"",t=this._svg.width.baseVal.value||parseFloat(this._svg.getAttribute("width")??"0"),n=this._svg.height.baseVal.value||parseFloat(this._svg.getAttribute("height")??"0");return{width:t,height:n,viewBox:e,theme:this._theme,elementCount:this._json.elements.filter(s=>s!=="push"&&s!=="pop").length,namedElementCount:this._elementMap.size}}};function H1(r,e,t){if(typeof document>"u")throw new Error("mountFromJson requires a browser environment with DOM access.");let n=typeof e=="string"?JSON.parse(e):e;return new La(r,n,t??{})}return nd(L2);})();
|