@skillpet/circuit 0.6.0 → 0.6.1

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.
@@ -30920,13 +30920,28 @@ var Circuit = (() => {
30920
30920
  }
30921
30921
  _initTooltip() {
30922
30922
  const tip = document.createElement("div");
30923
- tip.style.cssText = "position:fixed;z-index:99999;pointer-events:none;opacity:0;transition:opacity .12s ease;background:rgba(30,30,30,.92);color:#fff;font-size:12px;line-height:1.4;padding:5px 10px;border-radius:4px;max-width:260px;white-space:pre-wrap;box-shadow:0 2px 8px rgba(0,0,0,.25)";
30923
+ tip.className = "schemdraw-tooltip";
30924
+ tip.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;";
30925
+ this._applyTooltipTheme(tip);
30924
30926
  document.body.appendChild(tip);
30925
30927
  this._tooltipEl = tip;
30926
30928
  }
30929
+ _applyTooltipTheme(tip) {
30930
+ const isDark = document.documentElement.classList.contains("dark") || document.documentElement.getAttribute("data-theme") === "dark" || typeof window !== "undefined" && window.matchMedia?.("(prefers-color-scheme: dark)").matches && !document.documentElement.classList.contains("light");
30931
+ if (isDark) {
30932
+ tip.style.background = "rgba(250,250,250,.95)";
30933
+ tip.style.color = "#1a1a1a";
30934
+ tip.style.boxShadow = "0 2px 12px rgba(0,0,0,.4)";
30935
+ } else {
30936
+ tip.style.background = "rgba(15,15,15,.92)";
30937
+ tip.style.color = "#fff";
30938
+ tip.style.boxShadow = "0 2px 8px rgba(0,0,0,.2)";
30939
+ }
30940
+ }
30927
30941
  _showTooltip(text2, clientX, clientY) {
30928
30942
  const tip = this._tooltipEl;
30929
30943
  if (!tip) return;
30944
+ this._applyTooltipTheme(tip);
30930
30945
  tip.textContent = text2;
30931
30946
  tip.style.opacity = "1";
30932
30947
  const gap2 = 10;
@@ -269,4 +269,4 @@ l0,-`+(t+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
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 x=Cl(h,o),{width:v,height:S}=ya(h,o);e.mathText(x,s.x,s.y,{width:v,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=qp(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 qp(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 Hp(r,e){let t=r==null||r===""?e:r;return{bot:"bottom",lft:"left",rgt:"right",T:"top"}[t]??t}var Yp=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 Xp=[["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 x=r.anchors[e],v=x instanceof A?x.x:x[0],S=x instanceof A?x.y:x[1],k=.15,M="center",_="center";if(Math.abs(v-o)<k?M="right":Math.abs(v-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]=Xp[f];if(typeof s=="number"){let x=s,v,S;e==="bottom"?(v=0,S=-x):e==="left"?(v=-x,S=0):e==="right"?(v=x,S=0):(v=0,S=x),c=new A(v,S)}return{halign:g,valign:b,ofst:c}}function Gp(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]),x=m.flip===!0,v=m.reverse===!0,S=m.ignore_hints===!0;for(let k of t){let M=mc(Hp(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;x&&($==="top"?$="bottom":$==="bottom"&&($="top")),v&&(Y==="left"?Y="right":Y==="right"&&(Y="left"));let Z=Gp(k.ofst??B?.ofst,x,v);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(!Yp.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 Wp(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 Vp(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)Wp(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)Vp(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],x=g instanceof A?g.y:g[1];this.absanchors[f]=this.transform.transform([b,x])}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,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;")}function Up(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(Up(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,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;")}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 Jp(r,e){return t1(r)===t1(e)}function r1(r){return Mr(r.userParams,r.elmParams,r.defaults,r.dwgParams).color??"black"}function s1(r){let e=[],t=new Set,n=.5;for(let s=0;s<r.length;s++){let i=r[s],o=i.absanchors.end;if(o)for(let a=0;a<r.length;a++){if(s===a)continue;let l=r[a],h=l.absanchors.start;if(!h)continue;let c=o.x-h.x,m=o.y-h.y;if(Math.hypot(c,m)>n)continue;let f=r1(i),g=r1(l);if(Jp(f,g))continue;let b=`${s}|${a}`;t.has(b)||(t.add(b),e.push({fromEl:i,toEl:l,fromColor:f,toColor:g}))}}return e}function Dl(r){return Number.isInteger(r)?String(r):r.toFixed(4).replace(/0+$/,"").replace(/\.$/,"")}function i1(r,e,t){if(e.length===0)return{defsXml:"",cleanup:()=>{}};let n=[],s=[],i=0;for(let o of e){let a=n1(o.fromEl,"lead2"),l=n1(o.toEl,"lead1");if(!a&&!l||a?.gradientStrokeId&&l?.gradientStrokeId)continue;let h,c,m,f;if(a&&l){let b=Nl(o.fromEl,a,t),x=Nl(o.toEl,l,t);h=b.x1,c=b.y1,m=x.x2,f=x.y2}else if(a){let b=Nl(o.fromEl,a,t);h=b.x1,c=b.y1,m=b.x2,f=b.y2}else{let b=Nl(o.toEl,l,t);h=b.x1,c=b.y1,m=b.x2,f=b.y2}if(Kp({x1:h,y1:c,x2:m,y2:f})<1e-6)continue;let g=`sd-trans-${i++}`;n.push(Zp(g,h,c,m,f,o.fromColor,o.toColor)),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 n1(r,e){for(let t of r.segments)if(t instanceof p&&t.role===e)return t}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 Kp(r){return Math.hypot(r.x2-r.x1,r.y2-r.y1)}function Zp(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 Qp(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),e2(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=s1(this.elements),h=i1(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 e2(r){return new Proxy(r,{get(e,t,n){if(typeof t=="symbol")return Reflect.get(e,t,n);if(!Qp(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 o1(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 x=this.segments[0];if(!(x instanceof p))throw new Error("Element2Term requires first segment to be Segment");this.anchors.istart=x.path[0],this.anchors.iend=x.path[x.path.length-1];let v,S;if(T(this.params,"extend",!0)){let M=x.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]);v=L.sub([$+Z,0]),S=I.add([$-Z,0]),this._localshift=v.neg();let X={color:x.color,lw:x.lw,ls:x.ls,capstyle:x.capstyle,joinstyle:x.joinstyle,fill:x.fill,zorder:x.zorder},j=new p([[v.x,v.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(x);this.segments.splice(ve,1,j,te,ke)}else v=A.fromXY(M[0]),S=A.fromXY(M[M.length-1]),this._localshift=new A(0,0)}else v=A.fromXY(x.path[0]),S=A.fromXY(x.path[x.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([v.x,v.y],k,{fill:_,zorder:3}))}if(this.placeAnchors(v,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,x)=>[b,h[x]]);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 x=(b+1-(t/2+.5))*m,v=t-b;this.anchors[`in${v}`]=[0,x],this.segments.push(new p([[0,x],[s,x]]))}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,t2=.65,Sc=.12,r2=.5,a1=.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?a1:0),l=ze(0,t2+.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+r2)],f=Math.min(...h),g=ze(f,-f,50),b=g.map(L=>-L*L),x=Math.min(...b);b=b.map(L=>L-x);let v=m.map(L=>L+i),S=b.map(L=>L+i),k=Math.max(...v),M=Math.abs(f),_=h.map(L=>-L),B=[...v.map((L,I)=>[L,h[I]]),...[...v].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-a1);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-x;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,x=g*b,v=f*b,S=[0,1,3,2],k={lw:m};this.segments.push(new p([[0,0],[x,0],[x,v],[0,v],[0,0]],k));for(let j=0;j<f;j++)this.segments.push(new p([[0,j*b],[x,j*b]],k));for(let j=0;j<g;j++)this.segments.push(new p([[j*b,0],[j*b,v]],k));let M=b/Math.SQRT2;this.segments.push(new p([[0,v],[-M,v+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,v+3*M/4],$,{align:["right","bottom"],fontsize:12})),this.segments.push(new W([-(3*M)/4,v],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,v+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,v-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,v-ke*b-b/2],de,{align:["center","center"],fontsize:12})),this.anchors[`cell${he}`]=[re*b+b/2,v-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-l1(he)),Fe=Math.pow(2,ke-l1(ve)),qe=X[he]??0,Ie=X[ve]??0,ge=qe*b,Me=ge+de*b,be=v-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,v+I],[Me-I,v+I],[Me-I,v-b+I],[ge+I,v-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,v+I],[b-I,v+I],[b-I,v-b+I],[-I,v-b+I]],[[ge+I,v+I],[ge+b+I,v+I],[ge+b+I,v-b+I],[ge+I,v-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 l1(r){let e=0;for(let t of r)(t==="0"||t==="1")&&e++;return e}function h1(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 c1(r){let e=[];for(let t of r)typeof t!="string"&&(Array.isArray(t)?e.push(...c1(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 n2(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}},s2={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=c1(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="-",x=n+f,v=-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=v+M*m,L={state:S,pstate:b,nstate:$,plevel:h1(b),nlevel:h1($),periods:M,period:m,x0:v,xend:Z,y0:n,y1:Y,y1_prev:x,rise:l,data:c,datacolor:this.datacolor,kwargs:h},I=s2[S]??Ec;this.segments.push(...new I(L).segments());for(let X of k)this.segments.push(...n2(v+(X+1)*m-m/2,n,Y));b=S,x=Y,v+=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(":"),x=g.slice(0,b),v=g.slice(b+1),S=parseInt(x.replace(/[^0-9]/g,""),10),k=parseFloat(v),M=this.yheight/2;x.includes("^")?M=this.yheight+.2:x.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 x=k=>k instanceof A?[k.x,k.y]:[k[0],k[1]],v=x(g),S=x(b);if(this.segments.push(new p([v,S],{lw:1,color:l,arrow:h,zorder:3})),o){let k=(v[0]+S[0])/2,M=(v[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),i2={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 x;s.bits!==void 0?(h=s.bits,x=h/g):g>1?(h%2!==0&&(h+=1),x=s.bits??h/g):x=h;let v=null,S=null,k=s.label;if(k){if(k.left!==void 0)if(typeof k.left=="number")v=Array.from({length:g},(X,j)=>String(j+k.left));else if(typeof k.left=="string")v=Array(g).fill(k.left);else{let X=k.left,j=X.length;v=[...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/x,_=m,B=0,$=_/8,Y=0,Z=a?-1:1,L=0,I=this.params.lw??1;for(let X=0;X<g;X++){v&&this.segments.push(new W([-c,L+_/2],v[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<x&&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>x){let ye=x-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=i2[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*x+te,_e=X*x+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*x+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 u1(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}=u1(h),f=L=>L.replace(/^\|?\s*|\s*\|?$/g,""),g=l.filter(L=>!L.includes("---")&&!L.includes("===")),b=f(g[0]).split("|").length,x=e.colfmt;(x==null||x==="")&&(x="c".repeat(b));let{justs:v,bars:S}=u1(x),k=v.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"}[v[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(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,v)=>{let S=A.fromXY([x,l[v]]).rotate(c,[0,0]);return[S.x,S.y]}),f=h.map((x,v)=>{let S=A.fromXY([x-.2,l[v]]).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(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,S)=>{let k=A.fromXY([v,l[S]]).rotate(c,[0,0]);return[k.x,k.y]}),f=h.map((v,S)=>{let k=A.fromXY([v-.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]),x=m.length;this.segments.push(new p([[m[x-2][0],m[x-2][1]],[g.x,g.y]],{arrow:"->",arrowwidth:n,arrowlength:s,color:i})),this.segments.push(new p([[f[x-2][0],f[x-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(v=>t*v-n*Math.sin(v)),c=l.map(v=>t-n*Math.cos(v)),m=h[0];if(h=h.map(v=>v-m),s){let v=h[h.length-1]-h[0];v!==0&&(h=h.map(S=>S/v))}o&&(c=c.map(v=>-v));let g=Math.max(...c)-Math.min(...c);c=c.map(v=>v*g/.25);let b=h,x=c;return i&&(b=c,x=h),b.map((v,S)=>[v+e[0],x[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 d1(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=d1(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=d1(this.segments,"pmos",t,n,s);Object.assign(this.anchors,i),this.elmParams.drop=[0,-20*C],this.elmParams.lblloc="rgt"}};function p1(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=p1(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=p1(this.segments,"pmos",t,n,s);Object.assign(this.anchors,i),this.elmParams.drop=[20*C,0],this.elmParams.lblloc="bottom"}},q=Ye*4,o2=Ye*5,O=o2/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]}},m1=.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,m1/2],m1,{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 a2(r,e){let t=Math.max(.15,r.length*e/72),n=e/72*1.2;return[t*2,n*2]}function f1(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=f1(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,a2(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=f1(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,x=this.userParams.reverse===!0,v={L:"right",R:"left",T:"left",B:"left"},S={L:"bottom",R:"bottom",T:"bottom",B:"top"},k=v[t],M=S[t];b&&(t==="L"||t==="R")&&(g=g.flip()),b&&(t==="T"||t==="B")&&(M=t==="T"?"top":"bottom"),x&&(t==="L"||t==="R")&&(k=t==="L"?"left":"right"),x&&(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"},x={L:"center",R:"center",T:"top",B:"bottom"},v=b[t],S=x[t];f&&(t==="T"||t==="B")&&(S=t==="T"?"bottom":"top"),g&&(t==="L"||t==="R")&&(v=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:[v,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),x=[f,f+c,n-f-c,n-f,n-f-c,f+c],v=[0,c,c,0,-c,-c],S=[...x],k=[...x],M=v.map(Te=>Te+n*2),_=v.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]),x=x.map((Te,nt)=>Te+b*v[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);x=ge(x),v=Me(v),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(x,v,_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,x)=>[b,g[x]])))}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 l2(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 h2(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"})),l2(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)),h2(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:()=>c2,PINSPACING:()=>ee,Resistor:()=>Dc,TO92:()=>Gc,fritzParts:()=>f2,parseSizeToUnits:()=>m2,resistorColors:()=>b1});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,c2=Ce/25.4,ee=.1*Ce,Pa="#333",g1="#777",Lt="#A0A0A0",u2=96;function m2(r){return d2(r)/u2*Ce}function d2(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"},p2={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 b1(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?p2[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,x]=b1(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})),x&&this.segments.push(new U([[c,o],[c,-o],[c+m,-o],[c+m,o]],{fill:x,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:g1,zorder:2})),this.segments.push(new xe([a,i+n],t,s,{theta1:0,theta2:180,fill:Pa,lw:1,color:g1,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,x=b+m;this.segments.push(new U([[b,g],[x,g],[x,g-f],[b,g-f]],{lw:2}));let v=0,S=0;for(let k=0;k<2;k++)for(let M=0;M<a;M++){if(M%6===0)continue;let _=[v,S-M*ee],B=[v+ee,S-M*ee];o(..._),o(...B),this.anchors[`L1_${M}`]=_,this.anchors[`L2_${M}`]=B}v=x-c;for(let k=0;k<2;k++)for(let M=0;M<a;M++){if(M%6===0)continue;let _=[v,S-M*ee],B=[v-ee,S-M*ee];o(..._),o(...B),this.anchors[`R1_${M}`]=B,this.anchors[`R2_${M}`]=_}v=h;for(let k=0;k<l;k++){let M=String.fromCharCode(65+k);this.segments.push(new W([v+k*ee,S+ee],M,{fontsize:8,rotation:0,align:["center","center"],color:i,zorder:1}));for(let _=0;_<a;_++){let B=[v+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([v+ee*7+k*ee,S+ee],M,{fontsize:8,rotation:0,align:["center","center"],color:i,zorder:1}));for(let _=0;_<a;_++){let B=[v+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([v-ee,S-k*ee-.04],String(k+1),{fontsize:8,rotation:0,align:["center","bottom"],color:i,zorder:1})),this.segments.push(new W([v+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([[x-c*.4,g-ee*2],[x-c*.4,g-f+ee]],{color:"blue",lw:.5})),this.segments.push(new p([[x-h+c*.4,g-ee*2],[x-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 f2(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 w1=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 x=-b*l,v;f>0?v=m>0?g+l*b:g-l*b:v=m>0?g+(a-b)*l:g-(a-b)*l,this.segments.push(new p([[0,x],[v,x],[v,x+f],[m,x+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,x=this.params.pinalignleft??"bottom",v=(n-1)*o+a*2,S=(t-1)*o+a*2;this.segments.push(new U([[0,0],[0,S],[v,S],[v,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?v+.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",x]}))}if(i.length>0&&(n===1||M%2)){let Z=[v+.05,B];this.segments.push(new W(Z,i[k]??"",{fontsize:b,align:["left",x]}))}}}},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],w1,[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],w1,[-.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 y1(r,e){r.x+=e;for(let t of r.children)y1(t,e)}function g2(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 b2(r,e,t){return e.parent&&e.parent.children.includes(r.ancestor)?r.ancestor:t}function w2(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 x2(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&&(w2(b2(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 S1(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)S1(i),t=x2(i,t,e);g2(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 k1(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=k1(s,e+r.mod,t+1,n);return n}function Ra(r){let e=S1(new l0(r)),t=k1(e);return t<0&&y1(e,-t),e}var v2=new Set(["and","or","not","nand","nor","xor","xnor","true","false"]),M1=(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))(M1||{});function y2(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++;v2.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??M1[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 x1(r){return{"&":"and","\u2227":"and","|":"or","\u2228":"or","+":"or","\u2295":"xor","\u22BB":"xor"}[r]??r}var S2={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=x1(n.op),i=S2[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=x1(r.op),t=Zl(r,r.op);return new gr(e,...t.map(Pi))}var z1={and:Bt,or:$t,not:Kt,buf:Jt};function k2(r,e){let t=z1[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 v1(r){return r in z1||["nand","nor","xor","xnor"].includes(r)}function M2(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=k2(a.node,m);h&&f.label(h,{loc:"end"});for(let g=0;g<a.children.length;g++){let b=a.children[g],x=c?"start":`in${g+1}`;v1(b.node)||f.label(b.node,{loc:x})}s.add(f);for(let g=0;g<a.children.length;g++){let b=a.children[g],x=c?"start":`in${g+1}`;if(v1(b.node)){let v=o(b,l+1);s.add(new Hs({at:[f,x],to:v.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=y2(r),o=new Kc(i).parse(),a=Pi(o);return M2(a,n,t,s)}var eh=.12,z2=.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?z2: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 E1(r="svg"){if(r==="matplotlib")throw new Error("@skillpet/circuit: use('matplotlib') is not supported; only 'svg' is available.")}function P1(r=!0,e=!0){kt({dwgbbox:r,elmbbox:e})}function T1(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}},R1=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(x=>m+h/2+Math.sin((x-i)/a*Math.PI*2)*(h/2)*.75),b=f.map((x,v)=>[x,g[v]]);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,x=i+a*2/3-.1,v=i+a-.1;this.segments.push(new p([[i,f],[b,f],[b,g],[x,g],[x,f],[v,f],[v,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,x=i+a*2/3-.1,v=i+a-.1;this.segments.push(new p([[i,f],[b,g],[x,f],[v,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,x=.35,v=.4,S=.5;i&&(g+=.2),t&&n&&(x+=.2,b-=.2),t?(s&&this.segments.push(new D([0,-x],a,{fill:o,zorder:4})),this.segments.push(new p([[-a,-x],[-l,-x],[-l,0],[-l,f],[-l-m,f],[-l-m,0],[-l,0]])),this.anchors.sleeve=[0,-x],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-v],a,{fill:o,zorder:4})),this.segments.push(new p([[0,g-v],[-S,g-v]])),this.segments.push(new p([[-S,g-v],[-S,g]],{arrow:"->"})),this.anchors.tipswitch=[0,g-v]),t&&n&&(s&&this.segments.push(new D([0,b+v],a,{fill:o,zorder:4})),this.segments.push(new p([[0,b+v],[-S,b+v]])),this.segments.push(new p([[-S,b+v],[-S,b]],{arrow:"->"})),this.anchors.ringswitch=[0,b+v])}};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,x=(v,S)=>{if(h==="center"){let k=v/2-S/2;return[k,k+S]}else return h==="bottom"?[0,S]:[v-S,v]};if(a){let v=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=v.reduce((re,te)=>re+te[te.length-1][1],0)+o*(v.length-1),M=S.reduce((re,te)=>re+te[te.length-1][1],0)+o*(S.length-1);f=k,[g,b]=x(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<v.length;re++){let te=v[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 v=this.params.arcwidth,S=s.reduce((B,$)=>B+$,0)*v+o*(s.length-1),k=i.reduce((B,$)=>B+$,0)*v+o*(i.length-1);f=S,[g,b]=x(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+$*v];for(let Y=0;Y<$;Y++)this.segments.push(new xe([0,M+v/2],v,v,{theta1:270,theta2:90})),Y<$-1&&(this.anchors[`tapP${_+Y+1}`]=[0,M+v]),M+=v;_+=$-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+$*v];for(let Y=0;Y<$;Y++)this.segments.push(new xe([c,M+v/2],v,v,{theta1:90,theta2:270})),Y<$-1&&(this.anchors[`tapS${_+Y+1}`]=[c,M+v]),M+=v;_+=$-1,M+=o}}if(l){let v=Math.max(f,b),S=Math.min(m,g),k=c/2,M=c/10;this.segments.push(new p([[k-M,v],[k-M,S]])),this.segments.push(new p([[k+M,v],[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 E2(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(E2(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 A1(r,e,t=.01){return Math.abs(r-e)<=t}function _1(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",x=.1,v=0;return A1(m[1],c[1])?(g="center",x=0):m[1]>c[1]&&(g="top",x=-.1),A1(m[0],c[0])?b="center":m[0]>c[0]?(b="right",x=0,v=-.1):(v=.1,x=0),this.elmParams.lblofst=[v,x],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,x=this.params.arrowlength,v=this.params.arrowwidth;return this.segments.push(new Ut([[0,0],f,g,[a,l]],{arrow:b,arrowlength:x,arrowwidth:v})),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),x=[c+b*(-l/f),m+b*(a/f)],v=Math.sqrt(c*c+m*m),S=Math.atan2(m,c),k=Math.acos(v/h),M=S-k,_=S+k,B=ze(Math.PI+_,M,50),$=[],Y=[];for(let re of B)$.push(x[0]+h*Math.cos(re)),Y.push(x[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=_1(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 x=_1(s);this.userParams.at=[x.x,x.y];let v=s.transform.theta;(v%360+360)%360>90&&(v%360+360)%360<=270&&(v+=180),this.userParams.theta=v;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,x=h-c;super({...s,width:b,height:x,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),x=Math.cos(Math.PI/4),v=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*x,-f/2*b],this.anchors.SW=[-m/2*x,-f/2*b],this.anchors.NW=[-m/2*x,f/2*b],this.anchors.NE=[m/2*x,f/2*b],this.anchors.ENE=[m/2*S,f/2*v],this.anchors.WNW=[-m/2*S,f/2*v],this.anchors.ESE=[m/2*S,-f/2*v],this.anchors.WSW=[-m/2*S,-f/2*v],this.anchors.NNE=[m/2*v,f/2*S],this.anchors.NNW=[-m/2*v,f/2*S],this.anchors.SSE=[m/2*v,-f/2*S],this.anchors.SSW=[-m/2*v,-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 v of t){let S=v.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 x=b-b*Math.sqrt(2)/2;this.anchors.NE=[m/2-x,f/2-x],this.anchors.NW=[-m/2+x,f/2-x],this.anchors.SE=[m/2-x,-f/2+x],this.anchors.SW=[-m/2+x,-f/2+x],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),x=o.absanchors.center;this.add(new Pe({d:"l",at:[b.xmin,x.y],l:.15}));let v=this.add(new Pe({d:"d",toy:h.ymax+s}));this.anchors.base=fe(v,"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 x=new Xr({d:"d",reverse:l,flip:h}),v=x.getBBox(!1);x.userParams.at=[g-(h?-v.ymax:v.ymin),0],this.add(x),this.anchors.a=fe(x,"start"),this.anchors.b=fe(x,"end"),b=x}else if(n==="spdt"){let x=new Xs({d:"d",reverse:l,flip:h}),v=x.getBBox(!1);x.userParams.at=[g-(h?-v.ymax:v.ymin),-.5],this.add(x);let S=l?-e:0,k=l?0:-e,M=this.add(new Pe({d:l?"d":"u",at:fe(x,"a"),toy:S})),_=this.add(new Pe({d:l?"u":"d",at:fe(x,"b"),toy:k})),B=this.add(new Pe({d:l?"u":"d",at:fe(x,"c"),toy:k}));this.anchors.a=fe(M,"end"),this.anchors.b=fe(_,"end"),this.anchors.c=fe(B,"end"),b=x}else if(n==="dpst"){let x=new Gs({d:"d",link:!1,reverse:l,flip:h}),v=x.getBBox(!1);x.userParams.at=[g-(h?-v.ymax:v.ymin),-.5],this.add(x);let S=l?0:-e,k=l?-e:0,M=this.add(new Pe({d:l?"u":"d",at:fe(x,"t1"),toy:S})),_=this.add(new Pe({d:l?"u":"d",at:fe(x,"t2"),toy:S})),B=this.add(new Pe({d:l?"d":"u",at:fe(x,"p1"),toy:k})),$=this.add(new Pe({d:l?"d":"u",at:fe(x,"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=x}else if(n==="dpdt"){let x=new Ws({d:"d",link:!1,reverse:l,flip:h}),v=x.getBBox(!1);x.userParams.at=[g-(h?-v.ymax:v.ymin),-.5],this.add(x);let S=l?0:-e,k=l?-e:0,M=this.add(new Pe({d:l?"u":"d",at:fe(x,"t1"),toy:S})),_=this.add(new Pe({d:l?"u":"d",at:fe(x,"t2"),toy:S})),B=this.add(new Pe({d:l?"u":"d",at:fe(x,"t3"),toy:S})),$=this.add(new Pe({d:l?"u":"d",at:fe(x,"t4"),toy:S})),Y=this.add(new Pe({d:l?"d":"u",at:fe(x,"p1"),toy:k})),Z=this.add(new Pe({d:l?"d":"u",at:fe(x,"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=x}else{let x=new Xr({d:"d"});x.userParams.at=[g,0],this.add(x),b=x}if(c){let x=b.getBBox(!1),v=h?x.ymax:x.ymin;this.add(new Pe({d:"r",at:[f+.2,-e/2],ls:":",tox:v}))}if(i){let x=this.getBBox(!1);this.add(new xr({d:"r",at:[0,0],corner1:[x.xmin-a,x.ymin+.2],corner2:[x.xmax+a,x.ymax-.2],fill:o,zorder:0}))}}};var B1=1,C1=.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 x=g.getBBox(!1,!1),v=b.getBBox(!1,!1),S=Math.max((x.ymax-x.ymin)/2,o/2),k=Math.max((v.ymax-v.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")?-C1:C1,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]-B1/2,s[1]],[s[0]+B1/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,x=b*1.25,v=b/2,S=x/2,k=s/2.2,M=n?"black":"bg";this.segments.push(new U([[-k,S],[-k,S-x],[-k+g,S-x],[-k+g,S]],{fill:M,zorder:3})),this.segments.push(new U([[k,v],[k,v-b],[k-g,v-b],[k-g,v]],{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,x)=>[b,a[x]]);this.segments.push(new U(c,{fill:h,zorder:3}));let m=s/2,f=this.segments[1];f.verts=f.verts.map(([b,x])=>[b,x+m]);let g=this.segments[2];g.verts=g.verts.map(([b,x])=>[b,x+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,x=Gt/(b+2),v=(Gt-x*(b-1))/b,S=[];for(let _=0;_<b;_++)S.push(m+_*(v+x));for(let _=0;_<s;_++){let B=h-or*_;for(let $=0;$<b;$++)this.segments.push(new p([[S[$],B],[S[$]+v,B]],{lw:this.params.grid_lw}));s===1?(this.anchors[`grid${a}`]=[m-x,B],this.anchors[`grid${a}_R`]=[f+x,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-x,B],this.anchors[`grid${a}_${_+1}R`]=[f+x,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 I1=eu;function L1(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 P2(){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 P2();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 D1={bg:"bgcolor",stroke:"color",fill:"fill",font:"font",lw:"lw"};function N1(r,e){let t={};for(let n of Object.keys(D1)){let s=D1[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?N1(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 O1(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 T2(r){r.hasAttribute(na)||r.setAttribute(na,r.getAttribute("style")??"")}function F1(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.style.cssText="position:fixed;z-index:99999;pointer-events:none;opacity:0;transition:opacity .12s ease;background:rgba(30,30,30,.92);color:#fff;font-size:12px;line-height:1.4;padding:5px 10px;border-radius:4px;max-width:260px;white-space:pre-wrap;box-shadow:0 2px 8px rgba(0,0,0,.25)",document.body.appendChild(e),this._tooltipEl=e}_showTooltip(e,t,n){let s=this._tooltipEl;if(!s)return;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)&&F1(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;T2(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)&&F1(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 $1(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 ed(R2);})();
272
+ `),h="";for(let L of l)L.includes("---")?h+="|":L.includes("===")?h+="\u01C1":h+="l";let{justs:c,bars:m}=u1(h),f=L=>L.replace(/^\|?\s*|\s*\|?$/g,""),g=l.filter(L=>!L.includes("---")&&!L.includes("===")),b=f(g[0]).split("|").length,x=e.colfmt;(x==null||x==="")&&(x="c".repeat(b));let{justs:v,bars:S}=u1(x),k=v.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"}[v[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(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,v)=>{let S=A.fromXY([x,l[v]]).rotate(c,[0,0]);return[S.x,S.y]}),f=h.map((x,v)=>{let S=A.fromXY([x-.2,l[v]]).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(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,S)=>{let k=A.fromXY([v,l[S]]).rotate(c,[0,0]);return[k.x,k.y]}),f=h.map((v,S)=>{let k=A.fromXY([v-.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]),x=m.length;this.segments.push(new p([[m[x-2][0],m[x-2][1]],[g.x,g.y]],{arrow:"->",arrowwidth:n,arrowlength:s,color:i})),this.segments.push(new p([[f[x-2][0],f[x-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(v=>t*v-n*Math.sin(v)),c=l.map(v=>t-n*Math.cos(v)),m=h[0];if(h=h.map(v=>v-m),s){let v=h[h.length-1]-h[0];v!==0&&(h=h.map(S=>S/v))}o&&(c=c.map(v=>-v));let g=Math.max(...c)-Math.min(...c);c=c.map(v=>v*g/.25);let b=h,x=c;return i&&(b=c,x=h),b.map((v,S)=>[v+e[0],x[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 d1(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=d1(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=d1(this.segments,"pmos",t,n,s);Object.assign(this.anchors,i),this.elmParams.drop=[0,-20*C],this.elmParams.lblloc="rgt"}};function p1(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=p1(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=p1(this.segments,"pmos",t,n,s);Object.assign(this.anchors,i),this.elmParams.drop=[20*C,0],this.elmParams.lblloc="bottom"}},q=Ye*4,o2=Ye*5,O=o2/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]}},m1=.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,m1/2],m1,{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 a2(r,e){let t=Math.max(.15,r.length*e/72),n=e/72*1.2;return[t*2,n*2]}function f1(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=f1(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,a2(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=f1(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,x=this.userParams.reverse===!0,v={L:"right",R:"left",T:"left",B:"left"},S={L:"bottom",R:"bottom",T:"bottom",B:"top"},k=v[t],M=S[t];b&&(t==="L"||t==="R")&&(g=g.flip()),b&&(t==="T"||t==="B")&&(M=t==="T"?"top":"bottom"),x&&(t==="L"||t==="R")&&(k=t==="L"?"left":"right"),x&&(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"},x={L:"center",R:"center",T:"top",B:"bottom"},v=b[t],S=x[t];f&&(t==="T"||t==="B")&&(S=t==="T"?"bottom":"top"),g&&(t==="L"||t==="R")&&(v=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:[v,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),x=[f,f+c,n-f-c,n-f,n-f-c,f+c],v=[0,c,c,0,-c,-c],S=[...x],k=[...x],M=v.map(Te=>Te+n*2),_=v.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]),x=x.map((Te,nt)=>Te+b*v[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);x=ge(x),v=Me(v),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(x,v,_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,x)=>[b,g[x]])))}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 l2(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 h2(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"})),l2(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)),h2(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:()=>c2,PINSPACING:()=>ee,Resistor:()=>Dc,TO92:()=>Gc,fritzParts:()=>f2,parseSizeToUnits:()=>m2,resistorColors:()=>b1});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,c2=Ce/25.4,ee=.1*Ce,Pa="#333",g1="#777",Lt="#A0A0A0",u2=96;function m2(r){return d2(r)/u2*Ce}function d2(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"},p2={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 b1(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?p2[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,x]=b1(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})),x&&this.segments.push(new U([[c,o],[c,-o],[c+m,-o],[c+m,o]],{fill:x,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:g1,zorder:2})),this.segments.push(new xe([a,i+n],t,s,{theta1:0,theta2:180,fill:Pa,lw:1,color:g1,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,x=b+m;this.segments.push(new U([[b,g],[x,g],[x,g-f],[b,g-f]],{lw:2}));let v=0,S=0;for(let k=0;k<2;k++)for(let M=0;M<a;M++){if(M%6===0)continue;let _=[v,S-M*ee],B=[v+ee,S-M*ee];o(..._),o(...B),this.anchors[`L1_${M}`]=_,this.anchors[`L2_${M}`]=B}v=x-c;for(let k=0;k<2;k++)for(let M=0;M<a;M++){if(M%6===0)continue;let _=[v,S-M*ee],B=[v-ee,S-M*ee];o(..._),o(...B),this.anchors[`R1_${M}`]=B,this.anchors[`R2_${M}`]=_}v=h;for(let k=0;k<l;k++){let M=String.fromCharCode(65+k);this.segments.push(new W([v+k*ee,S+ee],M,{fontsize:8,rotation:0,align:["center","center"],color:i,zorder:1}));for(let _=0;_<a;_++){let B=[v+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([v+ee*7+k*ee,S+ee],M,{fontsize:8,rotation:0,align:["center","center"],color:i,zorder:1}));for(let _=0;_<a;_++){let B=[v+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([v-ee,S-k*ee-.04],String(k+1),{fontsize:8,rotation:0,align:["center","bottom"],color:i,zorder:1})),this.segments.push(new W([v+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([[x-c*.4,g-ee*2],[x-c*.4,g-f+ee]],{color:"blue",lw:.5})),this.segments.push(new p([[x-h+c*.4,g-ee*2],[x-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 f2(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 w1=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 x=-b*l,v;f>0?v=m>0?g+l*b:g-l*b:v=m>0?g+(a-b)*l:g-(a-b)*l,this.segments.push(new p([[0,x],[v,x],[v,x+f],[m,x+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,x=this.params.pinalignleft??"bottom",v=(n-1)*o+a*2,S=(t-1)*o+a*2;this.segments.push(new U([[0,0],[0,S],[v,S],[v,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?v+.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",x]}))}if(i.length>0&&(n===1||M%2)){let Z=[v+.05,B];this.segments.push(new W(Z,i[k]??"",{fontsize:b,align:["left",x]}))}}}},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],w1,[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],w1,[-.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 y1(r,e){r.x+=e;for(let t of r.children)y1(t,e)}function g2(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 b2(r,e,t){return e.parent&&e.parent.children.includes(r.ancestor)?r.ancestor:t}function w2(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 x2(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&&(w2(b2(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 S1(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)S1(i),t=x2(i,t,e);g2(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 k1(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=k1(s,e+r.mod,t+1,n);return n}function Ra(r){let e=S1(new l0(r)),t=k1(e);return t<0&&y1(e,-t),e}var v2=new Set(["and","or","not","nand","nor","xor","xnor","true","false"]),M1=(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))(M1||{});function y2(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++;v2.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??M1[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 x1(r){return{"&":"and","\u2227":"and","|":"or","\u2228":"or","+":"or","\u2295":"xor","\u22BB":"xor"}[r]??r}var S2={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=x1(n.op),i=S2[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=x1(r.op),t=Zl(r,r.op);return new gr(e,...t.map(Pi))}var z1={and:Bt,or:$t,not:Kt,buf:Jt};function k2(r,e){let t=z1[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 v1(r){return r in z1||["nand","nor","xor","xnor"].includes(r)}function M2(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=k2(a.node,m);h&&f.label(h,{loc:"end"});for(let g=0;g<a.children.length;g++){let b=a.children[g],x=c?"start":`in${g+1}`;v1(b.node)||f.label(b.node,{loc:x})}s.add(f);for(let g=0;g<a.children.length;g++){let b=a.children[g],x=c?"start":`in${g+1}`;if(v1(b.node)){let v=o(b,l+1);s.add(new Hs({at:[f,x],to:v.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=y2(r),o=new Kc(i).parse(),a=Pi(o);return M2(a,n,t,s)}var eh=.12,z2=.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?z2: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 E1(r="svg"){if(r==="matplotlib")throw new Error("@skillpet/circuit: use('matplotlib') is not supported; only 'svg' is available.")}function P1(r=!0,e=!0){kt({dwgbbox:r,elmbbox:e})}function T1(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}},R1=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(x=>m+h/2+Math.sin((x-i)/a*Math.PI*2)*(h/2)*.75),b=f.map((x,v)=>[x,g[v]]);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,x=i+a*2/3-.1,v=i+a-.1;this.segments.push(new p([[i,f],[b,f],[b,g],[x,g],[x,f],[v,f],[v,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,x=i+a*2/3-.1,v=i+a-.1;this.segments.push(new p([[i,f],[b,g],[x,f],[v,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,x=.35,v=.4,S=.5;i&&(g+=.2),t&&n&&(x+=.2,b-=.2),t?(s&&this.segments.push(new D([0,-x],a,{fill:o,zorder:4})),this.segments.push(new p([[-a,-x],[-l,-x],[-l,0],[-l,f],[-l-m,f],[-l-m,0],[-l,0]])),this.anchors.sleeve=[0,-x],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-v],a,{fill:o,zorder:4})),this.segments.push(new p([[0,g-v],[-S,g-v]])),this.segments.push(new p([[-S,g-v],[-S,g]],{arrow:"->"})),this.anchors.tipswitch=[0,g-v]),t&&n&&(s&&this.segments.push(new D([0,b+v],a,{fill:o,zorder:4})),this.segments.push(new p([[0,b+v],[-S,b+v]])),this.segments.push(new p([[-S,b+v],[-S,b]],{arrow:"->"})),this.anchors.ringswitch=[0,b+v])}};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,x=(v,S)=>{if(h==="center"){let k=v/2-S/2;return[k,k+S]}else return h==="bottom"?[0,S]:[v-S,v]};if(a){let v=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=v.reduce((re,te)=>re+te[te.length-1][1],0)+o*(v.length-1),M=S.reduce((re,te)=>re+te[te.length-1][1],0)+o*(S.length-1);f=k,[g,b]=x(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<v.length;re++){let te=v[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 v=this.params.arcwidth,S=s.reduce((B,$)=>B+$,0)*v+o*(s.length-1),k=i.reduce((B,$)=>B+$,0)*v+o*(i.length-1);f=S,[g,b]=x(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+$*v];for(let Y=0;Y<$;Y++)this.segments.push(new xe([0,M+v/2],v,v,{theta1:270,theta2:90})),Y<$-1&&(this.anchors[`tapP${_+Y+1}`]=[0,M+v]),M+=v;_+=$-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+$*v];for(let Y=0;Y<$;Y++)this.segments.push(new xe([c,M+v/2],v,v,{theta1:90,theta2:270})),Y<$-1&&(this.anchors[`tapS${_+Y+1}`]=[c,M+v]),M+=v;_+=$-1,M+=o}}if(l){let v=Math.max(f,b),S=Math.min(m,g),k=c/2,M=c/10;this.segments.push(new p([[k-M,v],[k-M,S]])),this.segments.push(new p([[k+M,v],[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 E2(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(E2(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 A1(r,e,t=.01){return Math.abs(r-e)<=t}function _1(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",x=.1,v=0;return A1(m[1],c[1])?(g="center",x=0):m[1]>c[1]&&(g="top",x=-.1),A1(m[0],c[0])?b="center":m[0]>c[0]?(b="right",x=0,v=-.1):(v=.1,x=0),this.elmParams.lblofst=[v,x],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,x=this.params.arrowlength,v=this.params.arrowwidth;return this.segments.push(new Ut([[0,0],f,g,[a,l]],{arrow:b,arrowlength:x,arrowwidth:v})),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),x=[c+b*(-l/f),m+b*(a/f)],v=Math.sqrt(c*c+m*m),S=Math.atan2(m,c),k=Math.acos(v/h),M=S-k,_=S+k,B=ze(Math.PI+_,M,50),$=[],Y=[];for(let re of B)$.push(x[0]+h*Math.cos(re)),Y.push(x[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=_1(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 x=_1(s);this.userParams.at=[x.x,x.y];let v=s.transform.theta;(v%360+360)%360>90&&(v%360+360)%360<=270&&(v+=180),this.userParams.theta=v;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,x=h-c;super({...s,width:b,height:x,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),x=Math.cos(Math.PI/4),v=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*x,-f/2*b],this.anchors.SW=[-m/2*x,-f/2*b],this.anchors.NW=[-m/2*x,f/2*b],this.anchors.NE=[m/2*x,f/2*b],this.anchors.ENE=[m/2*S,f/2*v],this.anchors.WNW=[-m/2*S,f/2*v],this.anchors.ESE=[m/2*S,-f/2*v],this.anchors.WSW=[-m/2*S,-f/2*v],this.anchors.NNE=[m/2*v,f/2*S],this.anchors.NNW=[-m/2*v,f/2*S],this.anchors.SSE=[m/2*v,-f/2*S],this.anchors.SSW=[-m/2*v,-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 v of t){let S=v.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 x=b-b*Math.sqrt(2)/2;this.anchors.NE=[m/2-x,f/2-x],this.anchors.NW=[-m/2+x,f/2-x],this.anchors.SE=[m/2-x,-f/2+x],this.anchors.SW=[-m/2+x,-f/2+x],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),x=o.absanchors.center;this.add(new Pe({d:"l",at:[b.xmin,x.y],l:.15}));let v=this.add(new Pe({d:"d",toy:h.ymax+s}));this.anchors.base=fe(v,"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 x=new Xr({d:"d",reverse:l,flip:h}),v=x.getBBox(!1);x.userParams.at=[g-(h?-v.ymax:v.ymin),0],this.add(x),this.anchors.a=fe(x,"start"),this.anchors.b=fe(x,"end"),b=x}else if(n==="spdt"){let x=new Xs({d:"d",reverse:l,flip:h}),v=x.getBBox(!1);x.userParams.at=[g-(h?-v.ymax:v.ymin),-.5],this.add(x);let S=l?-e:0,k=l?0:-e,M=this.add(new Pe({d:l?"d":"u",at:fe(x,"a"),toy:S})),_=this.add(new Pe({d:l?"u":"d",at:fe(x,"b"),toy:k})),B=this.add(new Pe({d:l?"u":"d",at:fe(x,"c"),toy:k}));this.anchors.a=fe(M,"end"),this.anchors.b=fe(_,"end"),this.anchors.c=fe(B,"end"),b=x}else if(n==="dpst"){let x=new Gs({d:"d",link:!1,reverse:l,flip:h}),v=x.getBBox(!1);x.userParams.at=[g-(h?-v.ymax:v.ymin),-.5],this.add(x);let S=l?0:-e,k=l?-e:0,M=this.add(new Pe({d:l?"u":"d",at:fe(x,"t1"),toy:S})),_=this.add(new Pe({d:l?"u":"d",at:fe(x,"t2"),toy:S})),B=this.add(new Pe({d:l?"d":"u",at:fe(x,"p1"),toy:k})),$=this.add(new Pe({d:l?"d":"u",at:fe(x,"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=x}else if(n==="dpdt"){let x=new Ws({d:"d",link:!1,reverse:l,flip:h}),v=x.getBBox(!1);x.userParams.at=[g-(h?-v.ymax:v.ymin),-.5],this.add(x);let S=l?0:-e,k=l?-e:0,M=this.add(new Pe({d:l?"u":"d",at:fe(x,"t1"),toy:S})),_=this.add(new Pe({d:l?"u":"d",at:fe(x,"t2"),toy:S})),B=this.add(new Pe({d:l?"u":"d",at:fe(x,"t3"),toy:S})),$=this.add(new Pe({d:l?"u":"d",at:fe(x,"t4"),toy:S})),Y=this.add(new Pe({d:l?"d":"u",at:fe(x,"p1"),toy:k})),Z=this.add(new Pe({d:l?"d":"u",at:fe(x,"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=x}else{let x=new Xr({d:"d"});x.userParams.at=[g,0],this.add(x),b=x}if(c){let x=b.getBBox(!1),v=h?x.ymax:x.ymin;this.add(new Pe({d:"r",at:[f+.2,-e/2],ls:":",tox:v}))}if(i){let x=this.getBBox(!1);this.add(new xr({d:"r",at:[0,0],corner1:[x.xmin-a,x.ymin+.2],corner2:[x.xmax+a,x.ymax-.2],fill:o,zorder:0}))}}};var B1=1,C1=.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 x=g.getBBox(!1,!1),v=b.getBBox(!1,!1),S=Math.max((x.ymax-x.ymin)/2,o/2),k=Math.max((v.ymax-v.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")?-C1:C1,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]-B1/2,s[1]],[s[0]+B1/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,x=b*1.25,v=b/2,S=x/2,k=s/2.2,M=n?"black":"bg";this.segments.push(new U([[-k,S],[-k,S-x],[-k+g,S-x],[-k+g,S]],{fill:M,zorder:3})),this.segments.push(new U([[k,v],[k,v-b],[k-g,v-b],[k-g,v]],{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,x)=>[b,a[x]]);this.segments.push(new U(c,{fill:h,zorder:3}));let m=s/2,f=this.segments[1];f.verts=f.verts.map(([b,x])=>[b,x+m]);let g=this.segments[2];g.verts=g.verts.map(([b,x])=>[b,x+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,x=Gt/(b+2),v=(Gt-x*(b-1))/b,S=[];for(let _=0;_<b;_++)S.push(m+_*(v+x));for(let _=0;_<s;_++){let B=h-or*_;for(let $=0;$<b;$++)this.segments.push(new p([[S[$],B],[S[$]+v,B]],{lw:this.params.grid_lw}));s===1?(this.anchors[`grid${a}`]=[m-x,B],this.anchors[`grid${a}_R`]=[f+x,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-x,B],this.anchors[`grid${a}_${_+1}R`]=[f+x,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 I1=eu;function L1(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 P2(){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 P2();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 D1={bg:"bgcolor",stroke:"color",fill:"fill",font:"font",lw:"lw"};function N1(r,e){let t={};for(let n of Object.keys(D1)){let s=D1[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?N1(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 O1(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 T2(r){r.hasAttribute(na)||r.setAttribute(na,r.getAttribute("style")??"")}function F1(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)&&F1(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;T2(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)&&F1(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 $1(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 ed(R2);})();
@@ -30527,13 +30527,28 @@ var SchemdrawController = class {
30527
30527
  }
30528
30528
  _initTooltip() {
30529
30529
  const tip = document.createElement("div");
30530
- tip.style.cssText = "position:fixed;z-index:99999;pointer-events:none;opacity:0;transition:opacity .12s ease;background:rgba(30,30,30,.92);color:#fff;font-size:12px;line-height:1.4;padding:5px 10px;border-radius:4px;max-width:260px;white-space:pre-wrap;box-shadow:0 2px 8px rgba(0,0,0,.25)";
30530
+ tip.className = "schemdraw-tooltip";
30531
+ tip.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;";
30532
+ this._applyTooltipTheme(tip);
30531
30533
  document.body.appendChild(tip);
30532
30534
  this._tooltipEl = tip;
30533
30535
  }
30536
+ _applyTooltipTheme(tip) {
30537
+ const isDark = document.documentElement.classList.contains("dark") || document.documentElement.getAttribute("data-theme") === "dark" || typeof window !== "undefined" && window.matchMedia?.("(prefers-color-scheme: dark)").matches && !document.documentElement.classList.contains("light");
30538
+ if (isDark) {
30539
+ tip.style.background = "rgba(250,250,250,.95)";
30540
+ tip.style.color = "#1a1a1a";
30541
+ tip.style.boxShadow = "0 2px 12px rgba(0,0,0,.4)";
30542
+ } else {
30543
+ tip.style.background = "rgba(15,15,15,.92)";
30544
+ tip.style.color = "#fff";
30545
+ tip.style.boxShadow = "0 2px 8px rgba(0,0,0,.2)";
30546
+ }
30547
+ }
30534
30548
  _showTooltip(text2, clientX, clientY) {
30535
30549
  const tip = this._tooltipEl;
30536
30550
  if (!tip) return;
30551
+ this._applyTooltipTheme(tip);
30537
30552
  tip.textContent = text2;
30538
30553
  tip.style.opacity = "1";
30539
30554
  const gap2 = 10;
package/dist/index.cjs CHANGED
@@ -30914,13 +30914,28 @@ var SchemdrawController = class {
30914
30914
  }
30915
30915
  _initTooltip() {
30916
30916
  const tip = document.createElement("div");
30917
- tip.style.cssText = "position:fixed;z-index:99999;pointer-events:none;opacity:0;transition:opacity .12s ease;background:rgba(30,30,30,.92);color:#fff;font-size:12px;line-height:1.4;padding:5px 10px;border-radius:4px;max-width:260px;white-space:pre-wrap;box-shadow:0 2px 8px rgba(0,0,0,.25)";
30917
+ tip.className = "schemdraw-tooltip";
30918
+ tip.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;";
30919
+ this._applyTooltipTheme(tip);
30918
30920
  document.body.appendChild(tip);
30919
30921
  this._tooltipEl = tip;
30920
30922
  }
30923
+ _applyTooltipTheme(tip) {
30924
+ const isDark = document.documentElement.classList.contains("dark") || document.documentElement.getAttribute("data-theme") === "dark" || typeof window !== "undefined" && window.matchMedia?.("(prefers-color-scheme: dark)").matches && !document.documentElement.classList.contains("light");
30925
+ if (isDark) {
30926
+ tip.style.background = "rgba(250,250,250,.95)";
30927
+ tip.style.color = "#1a1a1a";
30928
+ tip.style.boxShadow = "0 2px 12px rgba(0,0,0,.4)";
30929
+ } else {
30930
+ tip.style.background = "rgba(15,15,15,.92)";
30931
+ tip.style.color = "#fff";
30932
+ tip.style.boxShadow = "0 2px 8px rgba(0,0,0,.2)";
30933
+ }
30934
+ }
30921
30935
  _showTooltip(text2, clientX, clientY) {
30922
30936
  const tip = this._tooltipEl;
30923
30937
  if (!tip) return;
30938
+ this._applyTooltipTheme(tip);
30924
30939
  tip.textContent = text2;
30925
30940
  tip.style.opacity = "1";
30926
30941
  const gap2 = 10;
@@ -31,6 +31,7 @@ export declare class SchemdrawController {
31
31
  private _teardownAutoTheme;
32
32
  private _render;
33
33
  private _initTooltip;
34
+ private _applyTooltipTheme;
34
35
  private _showTooltip;
35
36
  private _hideTooltip;
36
37
  private _bindEvents;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skillpet/circuit",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Circuit diagram library — render electrical schematics from JSON, with interactive SVG, themes, and Vue/React components",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",