@tscircuit/eval 0.0.584 → 0.0.585

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.
@@ -207,7 +207,7 @@ No matching component was found for:
207
207
  `+h2+` |
208
208
  `+y3.line+" | "+p2+`
209
209
  `+h2+" | "+hr("",a2.column-1," ")+hr("",f2,"^")}else o4+=`
210
- at `+n3}return o4};$t.buildMessage=function(t5,o4){var i3={literal:function(p2){return'"'+a2(p2.text)+'"'},class:function(p2){var x3=p2.parts.map(function(f2){return Array.isArray(f2)?y3(f2[0])+"-"+y3(f2[1]):y3(f2)});return"["+(p2.inverted?"^":"")+x3.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(p2){return p2.description}};function l2(p2){return p2.charCodeAt(0).toString(16).toUpperCase()}function a2(p2){return p2.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(x3){return"\\x0"+l2(x3)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(x3){return"\\x"+l2(x3)})}function y3(p2){return p2.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(x3){return"\\x0"+l2(x3)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(x3){return"\\x"+l2(x3)})}function n3(p2){return i3[p2.type](p2)}function m3(p2){var x3=p2.map(n3),f2,d3;if(x3.sort(),x3.length>0){for(f2=1,d3=1;f2<x3.length;f2++)x3[f2-1]!==x3[f2]&&(x3[d3]=x3[f2],d3++);x3.length=d3}switch(x3.length){case 1:return x3[0];case 2:return x3[0]+" or "+x3[1];default:return x3.slice(0,-1).join(", ")+", or "+x3[x3.length-1]}}function h2(p2){return p2?'"'+a2(p2)+'"':"end of input"}return"Expected "+m3(t5)+" but "+h2(o4)+" found."};wf=(t5,o4="right")=>{switch(o4){case"down":switch(t5){case"middle_top":return"middle_right";case"middle_bottom":return"middle_left";case"middle_left":return"middle_bottom";case"middle_right":return"middle_top"}break;case"up":switch(t5){case"middle_top":return"middle_left";case"middle_bottom":return"middle_right";case"middle_left":return"middle_top";case"middle_right":return"middle_bottom"}break;case"left":switch(t5){case"middle_top":return"middle_bottom";case"middle_bottom":return"middle_top";case"middle_left":return"middle_right";case"middle_right":return"middle_left"}break;case"right":return t5}return t5},v=(t5,o4)=>{let{primitives:i3,center:l2,ports:a2,size:y3}=t5,n3=L({a:1,b:0,c:0,d:-1,e:0,f:2*l2.y}),m3=i3.map(p2=>{switch(p2={...p2},p2.type){case"path":return{...p2,points:p2.points.map(c3=>_(n3,c3))};case"text":let x3=_(n3,{x:p2.x,y:p2.y}),f2={top_left:"bottom_left",top_right:"bottom_right",bottom_left:"top_left",bottom_right:"top_right",center:"center",middle_top:"middle_bottom",middle_bottom:"middle_top",middle_left:"middle_left",middle_right:"middle_right"};return{...p2,x:x3.x,y:x3.y,anchor:f2[p2.anchor]};case"circle":case"box":let d3=_(n3,{x:p2.x,y:p2.y});return{...p2,x:d3.x,y:d3.y}}}),h2=a2.map(p2=>({...p2,..._(n3,p2)}));return{primitives:m3,center:l2,ports:h2,size:y3,...o4}},Y=(t5,o4)=>{let{primitives:i3,center:l2,ports:a2,size:y3}=t5,n3=L({a:-1,b:0,c:0,d:1,e:0,f:2*l2.x}),m3=i3.map(p2=>{switch(p2={...p2},p2.type){case"path":return{...p2,points:p2.points.map(c3=>_(n3,c3))};case"text":let x3=_(n3,{x:p2.x,y:p2.y}),f2={top_left:"top_right",top_right:"top_left",bottom_left:"bottom_right",bottom_right:"bottom_left",center:"center",middle_top:"middle_top",middle_bottom:"middle_bottom",middle_left:"middle_right",middle_right:"middle_left"};return{...p2,x:x3.x,y:x3.y,anchor:f2[p2.anchor]};case"circle":case"box":let d3=_(n3,{x:p2.x,y:p2.y});return{...p2,x:d3.x,y:d3.y}}}),h2=a2.map(p2=>({...p2,..._(n3,p2)}));return{primitives:m3,center:l2,ports:h2,size:y3,...o4}},At=(t5,o4)=>{let{newOrientation:i3,overrides:l2}=o4,a2={up:Math.PI/2,right:0,down:-Math.PI/2,left:-Math.PI},y3=cr(i3?a2[i3]:Math.PI/2,t5.center.x,t5.center.y),{primitives:n3,center:m3,size:h2,ports:p2}=t5,x3=n3.map(c3=>{switch(c3={...c3},c3.type){case"path":return{...c3,points:c3.points.map(bf=>_(y3,bf))};case"text":let Ql=_(y3,{x:c3.x,y:c3.y});return c3.anchor=wf(c3.anchor,i3??"right"),{...c3,x:Ql.x,y:Ql.y};case"circle":let Kl=_(y3,{x:c3.x,y:c3.y});return{...c3,x:Kl.x,y:Kl.y};case"box":let tp=_(y3,{x:c3.x,y:c3.y});return{...c3,x:tp.x,y:tp.y,width:c3.height,height:c3.width}}}),f2=p2.map(c3=>({...c3,..._(y3,c3)})),d3=_t(x3);return{primitives:x3,center:m3,ports:f2,size:{width:d3.maxX-d3.minX,height:d3.maxY-d3.minY},...l2}},r=(t5,o4="down",i3={})=>At(t5,{newOrientation:o4,overrides:i3}),dr=class{constructor(o4){__publicField(this,"symbol");this.symbol=JSON.parse(JSON.stringify(o4)),this.symbol.size=this.computeSize()}changeTextAnchor(o4,i3,l2){return this.symbol={...this.symbol,primitives:this.symbol.primitives.map(a2=>a2.type==="text"&&a2.text===o4?{...a2,anchor:i3,...l2?{x:a2.x+l2.x,y:a2.y+l2.y}:{}}:a2)},this}labelPort(o4,i3){return this.symbol={...this.symbol,ports:this.symbol.ports.map(l2=>l2.labels.includes(o4)?{...l2,labels:i3}:l2)},this}rotateRightFacingSymbol(o4){return this.symbol=At(this.symbol,{newOrientation:o4}),this}computeSize(){let o4=_t(this.symbol.primitives);return{width:o4.maxX-o4.minX,height:o4.maxY-o4.minY}}build(){return{...this.symbol,size:this.computeSize()}}},e=t5=>{let o4=t5.primitives??[...Object.values(t5.paths??{}),...Object.values(t5.texts??{}),...Object.values(t5.circles??{}),...Object.values(t5.rects??{})],i3=t5.ports??Object.entries(t5.refblocks).flatMap(([a2,y3])=>[{...y3,labels:[a2]}]),l2=t5.center??{x:t5.bounds.centerX,y:t5.bounds.centerY};return i3.length===2&&(l2={x:(i3[0].x+i3[1].x)/2,y:(i3[0].y+i3[1].y)/2}),new dr({...t5,primitives:o4,ports:i3,center:l2})},w={paths:{path11:{type:"path",points:[{x:-.54,y:.03},{x:-.3,y:.04}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:.04},{x:.54,y:.04}],color:"primary",fill:!1},"path11-5-5":{type:"path",points:[{x:.1,y:.13},{x:0,y:-.06},{x:-.11,y:.13}],color:"primary",fill:!1},path17:{type:"path",points:[{x:0,y:-.13},{x:.07,y:-.11}],color:"primary",fill:!1},path18:{type:"path",points:[{x:.07,y:-.11},{x:.14,y:-.13}],color:"primary",fill:!1},path19:{type:"path",points:[{x:-.15,y:-.13},{x:-.07,y:-.11}],color:"primary",fill:!1},path20:{type:"path",points:[{x:-.07,y:-.11},{x:0,y:-.13}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.17,y:.4},bottom1:{type:"text",text:"{VAL}",x:-.01,y:-.4}},refblocks:{left1:{x:-.54,y:.03},right1:{x:.54,y:.04}},bounds:{minX:-.57,maxX:.57,minY:-.4,maxY:.4,width:1.14,height:.79,centerX:0,centerY:0},circles:{path1:{type:"circle",x:0,y:.04,radius:.29,color:"primary",fill:!1}}},{paths:Pf,texts:z4,bounds:Mt,refblocks:rp,circles:Sf}=w,op=e({primitives:[...Object.values(Pf),...Object.values(Sf),{type:"text",text:"{REF}",x:-.15,y:.3894553499999995},{type:"text",text:"{VAL}",x:.15,y:.3894553499999995}],ports:[{...rp.left1,labels:["1"]},{...rp.right1,labels:["2"]}],size:{width:Mt.width,height:Mt.height},center:{x:Mt.centerX,y:Mt.centerY}}).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:Rf,texts:M4,bounds:Ct,refblocks:ip,circles:Ff}=w,lp=e({primitives:[...Object.values(Rf),...Object.values(Ff),{type:"text",text:"{REF}",x:-0,y:.4094553499999995},{type:"text",text:"{VAL}",x:0,y:-.4094553499999995}],ports:[{...ip.left1,labels:["1"]},{...ip.right1,labels:["2"]}],size:{width:Ct.width,height:Ct.height},center:{x:Ct.centerX,y:Ct.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:Tf,texts:B4,bounds:Nt,refblocks:pp,circles:Ef}=w,ap=e({primitives:[...Object.values(Tf),...Object.values(Ef),{type:"text",text:"{REF}",x:-0,y:-.3094553499999995},{type:"text",text:"{VAL}",x:0,y:.4094553499999995}],ports:[{...pp.left1,labels:["1"]},{...pp.right1,labels:["2"]}],size:{width:Nt.width,height:Nt.height},center:{x:Nt.centerX,y:Nt.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:Yf,texts:U4,bounds:It,refblocks:yp,circles:Xf}=w,xp=e({primitives:[...Object.values(Yf),...Object.values(Xf),{type:"text",text:"{REF}",x:-0,y:.4094553499999995},{type:"text",text:"{VAL}",x:0,y:-.4094553499999995}],ports:[{...yp.left1,labels:["1"]},{...yp.right1,labels:["2"]}],size:{width:It.width,height:It.height},center:{x:It.centerX,y:It.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:Lf,texts:Q4,bounds:Bt,refblocks:sp,circles:Vf}=w,mp=e({primitives:[...Object.values(Lf),...Object.values(Vf),{type:"text",text:"{REF}",x:.15,y:-.2894553499999995},{type:"text",text:"{VAL}",x:-.15,y:-.2894553499999995}],ports:[{...sp.left1,labels:["1"]},{...sp.right1,labels:["2"]}],size:{width:Bt.width,height:Bt.height},center:{x:Bt.centerX,y:Bt.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:jf,texts:r5,bounds:qt,refblocks:np,circles:kf}=w,fp2=e({primitives:[...Object.values(jf),...Object.values(kf),{type:"text",text:"{REF}",x:.15,y:-.2894553499999995},{type:"text",text:"{VAL}",x:-.15,y:-.2894553499999995}],ports:[{...np.left1,labels:["1"]},{...np.right1,labels:["2"]}],size:{width:qt.width,height:qt.height},center:{x:qt.centerX,y:qt.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),A={paths:{path40:{type:"path",points:[{x:.14,y:.04},{x:-.12,y:-.09}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.12,y:.18},{x:.14,y:.04}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.12,y:-.09},{x:-.12,y:.18}],color:"primary",fill:!1},path43:{type:"path",points:[{x:.14,y:.18},{x:.14,y:-.09}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.12,y:.04},{x:-.52,y:.04}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.52,y:.04},{x:.15,y:.04}],color:"primary",fill:!1},"path43-8":{type:"path",points:[{x:.14,y:.18},{x:.08,y:.2}],color:"primary",fill:!1},"path43-8-3":{type:"path",points:[{x:.21,y:-.11},{x:.15,y:-.09}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.01,y:.27},bottom1:{type:"text",text:"{VAL}",x:0,y:-.27}},refblocks:{left1:{x:-.52,y:.04},right1:{x:.52,y:.04}},bounds:{minX:-.55,maxX:.55,minY:-.27,maxY:.27,width:1.09,height:.55,centerX:0,centerY:0},circles:{}},{paths:Of,texts:a5,bounds:Dt,refblocks:cp,circles:Jf}=A,hp=e({primitives:[...Object.values(Of),...Object.values(Jf),{type:"text",text:"{REF}",x:-.15,y:.3294553499999995},{type:"text",text:"{VAL}",x:.15,y:.3294553499999995}],ports:[{...cp.left1,labels:["1"]},{...cp.right1,labels:["2"]}],size:{width:Dt.width,height:Dt.height},center:{x:Dt.centerX,y:Dt.centerY}}).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),dp=e(A).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1","neg"]).labelPort("right1",["2","pos"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:$f,texts:c5,bounds:Gt,refblocks:bp,circles:Mf}=A,_p=e({primitives:[...Object.values($f),...Object.values(Mf),{type:"text",text:"{REF}",x:-0,y:-.2294553499999995},{type:"text",text:"{VAL}",x:0,y:.3294553499999995}],ports:[{...bp.left1,labels:["1"]},{...bp.right1,labels:["2"]}],size:{width:Gt.width,height:Gt.height},center:{x:Gt.centerX,y:Gt.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),gp=e(A).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1","neg"]).labelPort("right1",["2","pos"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:Cf,texts:v5,bounds:Ut,refblocks:up,circles:Nf}=A,vp=e({primitives:[...Object.values(Cf),...Object.values(Nf),{type:"text",text:"{REF}",x:.15,y:-.2294553499999995},{type:"text",text:"{VAL}",x:-.15,y:-.2294553499999995}],ports:[{...up.left1,labels:["1"]},{...up.right1,labels:["2"]}],size:{width:Ut.width,height:Ut.height},center:{x:Ut.centerX,y:Ut.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:If,texts:S5,bounds:Wt,refblocks:wp,circles:Bf}=A,Ap=e({primitives:[...Object.values(If),...Object.values(Bf),{type:"text",text:"{REF}",x:.15,y:-.2294553499999995},{type:"text",text:"{VAL}",x:-.15,y:-.2294553499999995}],ports:[{...wp.left1,labels:["1"]},{...wp.right1,labels:["2"]}],size:{width:Wt.width,height:Wt.height},center:{x:Wt.centerX,y:Wt.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),V={paths:{path40:{type:"path",points:[{x:.14,y:.04},{x:-.12,y:-.09}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.12,y:.18},{x:.14,y:.04}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.12,y:-.09},{x:-.12,y:.18}],color:"primary",fill:!1},path43:{type:"path",points:[{x:.14,y:.18},{x:.14,y:-.09}],color:"primary",fill:!1},path44:{type:"path",points:[{x:.14,y:.04},{x:-.52,y:.04}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.52,y:.04},{x:.15,y:.04}],color:"primary",fill:!1},"path43-8":{type:"path",points:[{x:.18,y:.18},{x:.11,y:.18}],color:"primary",fill:!1},"path43-8-8":{type:"path",points:[{x:.18,y:-.09},{x:.11,y:-.09}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.01,y:.27},bottom1:{type:"text",text:"{VAL}",x:0,y:-.27}},refblocks:{left1:{x:-.52,y:.04},right1:{x:.52,y:.04}},bounds:{minX:-.55,maxX:.55,minY:-.27,maxY:.27,width:1.09,height:.55,centerX:0,centerY:0},circles:{}},{paths:Df,texts:Y5,bounds:Ht,refblocks:Pp,circles:Gf}=V,Sp=e({primitives:[...Object.values(Df),...Object.values(Gf),{type:"text",text:"{REF}",x:-.16,y:.2294553499999995},{type:"text",text:"{VAL}",x:.16,y:.2294553499999995}],ports:[{...Pp.left1,labels:["1"]},{...Pp.right1,labels:["2"]}],size:{width:Ht.width,height:Ht.height},center:{x:Ht.centerX,y:Ht.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").build(),{paths:Uf,texts:j5,bounds:Zt,refblocks:Rp,circles:Wf}=V,Qt=e({primitives:[...Object.values(Uf),...Object.values(Wf),{type:"text",text:"{REF}",x:-1118e-7,y:-.18},{type:"text",text:"{VAL}",x:1118e-7,y:.2738453}],ports:[{...Rp.left1,labels:["1"]},{...Rp.right1,labels:["2"]}],size:{width:Zt.width,height:Zt.height},center:{x:Zt.centerX,y:Zt.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("left").labelPort("left1",["2"]).labelPort("right1",["1"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:Hf,texts:J5,bounds:Kt,refblocks:Fp,circles:Zf}=V,Tp=e({primitives:[...Object.values(Hf),...Object.values(Zf),{type:"text",text:"{REF}",x:-.0050250999999996715,y:.27384529999999985,anchor:"middle_left"},{type:"text",text:"{VAL}",x:-.00011179999999999524,y:-.27384530000000007,anchor:"middle_left"}],ports:[{...Fp.left1,labels:["1"]},{...Fp.right1,labels:["2"]}],size:{width:Kt.width,height:Kt.height},center:{x:Kt.centerX,y:Kt.centerY}}).changeTextAnchor("{VAL}","middle_top").labelPort("right1",["2"]).labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:I5,texts:B5,bounds:q5,refblocks:D5,circles:G5}=V,br=r(Qt,"down"),_r=br.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),gr=br.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");_r.anchor="middle_left";gr.anchor="middle_left";_r.x=.25;_r.y+=.21;gr.y-=.21;gr.x=.25;Ep=br;Yp={paths:{path43:{type:"path",points:[{x:-.06,y:.19},{x:-.06,y:-.12}],color:"primary",fill:!1},"path43-6":{type:"path",points:[{x:.02,y:.13},{x:.02,y:-.06}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.06,y:.03},{x:-.45,y:.03}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.45,y:.03},{x:.03,y:.03}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.03,y:.27},bottom1:{type:"text",text:"{VAL}",x:-.03,y:-.28}},refblocks:{left1:{x:-.45,y:.03},right1:{x:.45,y:.03}},bounds:{minX:-.47,maxX:.47,minY:-.38,maxY:.27,width:.95,height:.29,centerX:0,centerY:.06},circles:{}},{paths:Kf,texts:Xp,bounds:te,refblocks:Lp,circles:tc}=Yp,ee=s({primitives:[...Object.values(Kf),...Object.values(tc),{...Xp.top1,anchor:"middle_bottom"},{...Xp.bottom1,anchor:"middle_top"}],ports:[{...Lp.left1,labels:["1"]},{...Lp.right1,labels:["2"]}],size:{width:te.width,height:te.height},center:{x:te.centerX,y:te.centerY}}),Vp=At(ee,{newOrientation:"up"}),j={paths:{path1:{type:"path",points:[{x:-.53,y:.05},{x:-.25,y:.05}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.28,y:.05},{x:.57,y:.05}],color:"primary",fill:!1},path3:{type:"path",points:[{x:.02,y:.18},{x:.28,y:.18},{x:.28,y:-.09},{x:-.25,y:-.09},{x:-.25,y:.18},{x:.02,y:.18}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:0,y:.25},bottom1:{type:"text",text:"{VAL}",x:0,y:-.25}},refblocks:{left1:{x:-.53,y:.05},right1:{x:.57,y:.05}},bounds:{minX:-.56,maxX:.56,minY:-.25,maxY:.25,width:1.12,height:.5,centerX:0,centerY:0},circles:{}},{paths:rc,texts:ag,bounds:jp,refblocks:kp,circles:oc}=j,zp=e({primitives:[...Object.values(rc),...Object.values(oc),{type:"text",text:"{REF}",x:-.16,y:.2294553499999995},{type:"text",text:"{VAL}",x:.16,y:.2294553499999995}],ports:[{...kp.left1,labels:["1"]},{...kp.right1,labels:["2"]}],center:{x:jp.centerX,y:jp.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").build(),{paths:ic,texts:mg,bounds:Op,refblocks:Jp,circles:lc}=j,$p=e({primitives:[...Object.values(ic),...Object.values(lc),{type:"text",text:"{REF}",x:0,y:-.1994553499999995},{type:"text",text:"{VAL}",x:0,y:.2694553499999995}],ports:[{...Jp.left1,labels:["1"]},{...Jp.right1,labels:["2"]}],center:{x:Op.centerX,y:Op.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:pc,texts:hg,bounds:Mp,refblocks:Cp,circles:ac}=j,Np=e({primitives:[...Object.values(pc),...Object.values(ac),{type:"text",text:"{REF}",x:0,y:.2294553499999995},{type:"text",text:"{VAL}",x:0,y:-.1594553499999995}],ports:[{...Cp.left1,labels:["1"]},{...Cp.right1,labels:["2"]}],center:{x:Mp.centerX,y:Mp.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),k={paths:{path2:{type:"path",points:[{x:.15,y:-.01},{x:.55,y:-.01}],color:"primary",fill:!0},"path2-5":{type:"path",points:[{x:-.15,y:.06},{x:.14,y:.06}],color:"primary",fill:!0},"path2-5-1":{type:"path",points:[{x:.14,y:.06},{x:.14,y:-.08}],color:"primary",fill:!0},"path2-5-1-6":{type:"path",points:[{x:-.16,y:.06},{x:-.16,y:-.08}],color:"primary",fill:!0},"path2-5-4":{type:"path",points:[{x:-.15,y:-.08},{x:.14,y:-.08}],color:"primary",fill:!0},"path2-9":{type:"path",points:[{x:-.55,y:-.01},{x:-.17,y:-.01}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:-.01,y:.17},bottom1:{type:"text",text:"{VAL}",x:0,y:-.17}},refblocks:{left1:{x:-.55,y:-.01},right1:{x:.55,y:-.01}},bounds:{minX:-.58,maxX:.58,minY:-.17,maxY:.17,width:1.16,height:.35,centerX:0,centerY:0},circles:{}},{paths:xc,texts:ug,bounds:re,refblocks:Ip,circles:sc}=k,Bp=e({primitives:[...Object.values(xc),...Object.values(sc),{type:"text",text:"{REF}",x:-.2,y:.1404553499999995},{type:"text",text:"{VAL}",x:.2,y:.1494553499999995}],ports:[{...Ip.left1,labels:["1"]},{...Ip.right1,labels:["2"]}],size:{width:re.width,height:re.height},center:{x:re.centerX,y:re.centerY}}).rotateRightFacingSymbol("down").labelPort("left",["1"]).labelPort("right",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:mc,texts:Pg,bounds:oe,refblocks:qp,circles:nc}=k,Dp=e({primitives:[...Object.values(mc),...Object.values(nc),{type:"text",text:"{REF}",x:0,y:-.2294553499999995},{type:"text",text:"{VAL}",x:0,y:.1704553499999995}],ports:[{...qp.left1,labels:["1"]},{...qp.right1,labels:["2"]}],size:{width:oe.width,height:oe.height},center:{x:oe.centerX,y:oe.centerY}}).rotateRightFacingSymbol("left").labelPort("left",["1"]).labelPort("right",["2"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),{paths:fc,texts:Tg,bounds:ie,refblocks:Gp,circles:cc}=k,Up=e({primitives:[...Object.values(fc),...Object.values(cc),{type:"text",text:"{REF}",x:0,y:.2294553499999995},{type:"text",text:"{VAL}",x:0,y:-.1704553499999995}],ports:[{...Gp.left1,labels:["1"]},{...Gp.right1,labels:["2"]}],size:{width:ie.width,height:ie.height},center:{x:ie.centerX,y:ie.centerY}}).rotateRightFacingSymbol("right").labelPort("left",["1"]).labelPort("right",["2"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),{paths:hc,texts:Lg,bounds:le,refblocks:Wp,circles:dc}=k,Hp=e({primitives:[...Object.values(hc),...Object.values(dc),{type:"text",text:"{REF}",x:.2,y:-.1404553499999995},{type:"text",text:"{VAL}",x:-.2,y:-.1494553499999995}],ports:[{...Wp.left1,labels:["1"]},{...Wp.right1,labels:["2"]}],size:{width:le.width,height:le.height},center:{x:le.centerX,y:le.centerY}}).rotateRightFacingSymbol("up").labelPort("left",["1"]).labelPort("right",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:bc,texts:zg,bounds:Zp,refblocks:Qp,circles:_c}=j,Kp=e({primitives:[...Object.values(bc),...Object.values(_c),{type:"text",text:"{REF}",x:.16,y:-.2294553499999995},{type:"text",text:"{VAL}",x:-.16,y:-.2294553499999995}],ports:[{...Qp.left1,labels:["1"]},{...Qp.right1,labels:["2"]}],center:{x:Zp.centerX,y:Zp.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").build(),gt={paths:{"horizontal-bar":{type:"path",points:[{x:-.4,y:0},{x:.4,y:0}],color:"primary",fill:!1},"middle-dash-1":{type:"path",points:[{x:0,y:.2},{x:0,y:.07}],color:"primary",fill:!1},"middle-dash-2":{type:"path",points:[{x:0,y:.01},{x:0,y:-.12}],color:"primary",fill:!1},"middle-dash-3":{type:"path",points:[{x:0,y:-.18},{x:0,y:-.31}],color:"primary",fill:!1},"left-vertical":{type:"path",points:[{x:-.25,y:0},{x:-.25,y:-.2}],color:"primary",fill:!1},"right-vertical":{type:"path",points:[{x:.25,y:0},{x:.25,y:-.2}],color:"primary",fill:!1},"left-ground":{type:"path",points:[{x:-.3,y:-.2},{x:-.25,y:-.3},{x:-.2,y:-.2},{x:-.3,y:-.2}],color:"primary",fill:!1},"right-ground":{type:"path",points:[{x:.2,y:-.2},{x:.25,y:-.3},{x:.3,y:-.2},{x:.2,y:-.2}],color:"primary",fill:!1}},refblocks:{left1:{x:-.4,y:0},right1:{x:.4,y:0}},texts:{ref:{type:"text",text:"{REF}",x:0,y:.35}},bounds:{minX:-.4,maxX:.4,minY:-.4,maxY:.35,width:.8,height:.75,centerX:0,centerY:-.02},circles:{}},{paths:uc,texts:Cg,bounds:ta,refblocks:ea,circles:vc}=gt,ra=e({primitives:[...Object.values(uc),...Object.values(vc),{type:"text",text:"{REF}",x:0,y:.2594553499999995}],ports:[{...ea.left1,labels:["1"]},{...ea.right1,labels:["2"]}],center:{x:ta.centerX,y:ta.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").build(),{paths:wc,texts:qg,bounds:oa,refblocks:ia,circles:Ac}=gt,pe=e({primitives:[...Object.values(wc),...Object.values(Ac),{type:"text",text:"{REF}",x:0,y:.2594553499999995}],ports:[{...ia.left1,labels:["1"]},{...ia.right1,labels:["2"]}],center:{x:oa.centerX,y:oa.centerY}}).rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),la=Y(pe),{paths:Pc,texts:Qg,bounds:pa,refblocks:aa,circles:Sc}=gt,ya=e({primitives:[...Object.values(Pc),...Object.values(Sc),{type:"text",text:"{REF}",x:0,y:.2594553499999995}],ports:[{...aa.left1,labels:["1"]},{...aa.right1,labels:["2"]}],center:{x:pa.centerX,y:pa.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_right").build(),z={paths:{path27:{type:"path",points:[{x:.55,y:.02},{x:.07,y:.02}],color:"primary",fill:!1},path28:{type:"path",points:[{x:-.09,y:.02},{x:-.55,y:.02}],color:"primary",fill:!1},path29:{type:"path",points:[{x:.07,y:.28},{x:.07,y:-.25}],color:"primary",fill:!1},path30:{type:"path",points:[{x:-.09,y:.28},{x:-.09,y:-.25}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.01,y:.42},bottom1:{type:"text",text:"{VAL}",x:0,y:-.42}},refblocks:{left1:{x:-.55,y:.02},right1:{x:.55,y:.02}},bounds:{minX:-.58,maxX:.58,minY:-.42,maxY:.42,width:1.16,height:.84,centerX:0,centerY:0},circles:{}},{paths:Fc,texts:ou,bounds:ae,refblocks:xa,circles:Tc}=z,sa=e({primitives:[...Object.values(Fc),...Object.values(Tc),{type:"text",text:"{REF}",x:-.2,y:.115},{type:"text",text:"{VAL}",x:.2,y:.115}],ports:[{...xa.left1,labels:["1"]},{...xa.right1,labels:["2"]}],size:{width:ae.width,height:ae.height},center:{x:ae.centerX,y:ae.centerY}}).changeTextAnchor("{VAL}","top_left").rotateRightFacingSymbol("down").labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{REF}","bottom_left").build(),ma=e(z).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["2","neg"]).labelPort("right1",["1","pos"]).changeTextAnchor("{REF}","middle_bottom").build(),O={paths:{"path27-5":{type:"path",points:[{x:.45,y:.02},{x:0,y:.02}],color:"primary",fill:!1},"path28-5":{type:"path",points:[{x:-.09,y:.02},{x:-.54,y:.02}],color:"primary",fill:!1},"path30-7":{type:"path",points:[{x:0,y:.28},{x:0,y:-.25}],color:"primary",fill:!1},path8704:{type:"path",points:[{x:-.14,y:-.24},{x:-.14,y:-.24},{x:-.14,y:-.24},{x:-.14,y:-.24},{x:-.14,y:-.24},{x:-.14,y:-.24},{x:-.14,y:-.24},{x:-.14,y:-.24},{x:-.14,y:-.24},{x:-.14,y:-.23},{x:-.14,y:-.23},{x:-.14,y:-.23},{x:-.14,y:-.23},{x:-.13,y:-.23},{x:-.13,y:-.23},{x:-.13,y:-.23},{x:-.13,y:-.23},{x:-.13,y:-.22},{x:-.13,y:-.22},{x:-.13,y:-.22},{x:-.13,y:-.22},{x:-.13,y:-.22},{x:-.13,y:-.22},{x:-.13,y:-.22},{x:-.13,y:-.22},{x:-.13,y:-.21},{x:-.13,y:-.21},{x:-.13,y:-.21},{x:-.12,y:-.21},{x:-.12,y:-.21},{x:-.12,y:-.21},{x:-.12,y:-.21},{x:-.12,y:-.21},{x:-.12,y:-.2},{x:-.12,y:-.2},{x:-.12,y:-.2},{x:-.12,y:-.2},{x:-.12,y:-.2},{x:-.12,y:-.2},{x:-.12,y:-.2},{x:-.12,y:-.2},{x:-.12,y:-.19},{x:-.12,y:-.19},{x:-.12,y:-.19},{x:-.12,y:-.19},{x:-.11,y:-.19},{x:-.11,y:-.19},{x:-.11,y:-.19},{x:-.11,y:-.18},{x:-.11,y:-.18},{x:-.11,y:-.18},{x:-.11,y:-.18},{x:-.11,y:-.18},{x:-.11,y:-.18},{x:-.11,y:-.18},{x:-.11,y:-.18},{x:-.11,y:-.17},{x:-.11,y:-.17},{x:-.11,y:-.17},{x:-.11,y:-.17},{x:-.11,y:-.17},{x:-.11,y:-.17},{x:-.11,y:-.17},{x:-.11,y:-.17},{x:-.1,y:-.16},{x:-.1,y:-.16},{x:-.1,y:-.16},{x:-.1,y:-.16},{x:-.1,y:-.16},{x:-.1,y:-.16},{x:-.1,y:-.16},{x:-.1,y:-.16},{x:-.1,y:-.15},{x:-.1,y:-.15},{x:-.1,y:-.15},{x:-.1,y:-.15},{x:-.1,y:-.15},{x:-.1,y:-.15},{x:-.1,y:-.15},{x:-.1,y:-.14},{x:-.1,y:-.14},{x:-.1,y:-.14},{x:-.1,y:-.14},{x:-.1,y:-.14},{x:-.1,y:-.14},{x:-.1,y:-.14},{x:-.09,y:-.14},{x:-.09,y:-.13},{x:-.09,y:-.13},{x:-.09,y:-.13},{x:-.09,y:-.13},{x:-.09,y:-.13},{x:-.09,y:-.13},{x:-.09,y:-.13},{x:-.09,y:-.13},{x:-.09,y:-.12},{x:-.09,y:-.12},{x:-.09,y:-.12},{x:-.09,y:-.12},{x:-.09,y:-.12},{x:-.09,y:-.12},{x:-.09,y:-.12},{x:-.09,y:-.12},{x:-.09,y:-.11},{x:-.09,y:-.11},{x:-.09,y:-.11},{x:-.09,y:-.11},{x:-.09,y:-.11},{x:-.09,y:-.11},{x:-.09,y:-.1},{x:-.09,y:-.1},{x:-.09,y:-.1},{x:-.09,y:-.1},{x:-.09,y:-.1},{x:-.09,y:-.1},{x:-.08,y:-.09},{x:-.08,y:-.09},{x:-.08,y:-.09},{x:-.08,y:-.09},{x:-.08,y:-.09},{x:-.08,y:-.09},{x:-.08,y:-.08},{x:-.08,y:-.08},{x:-.08,y:-.08},{x:-.08,y:-.08},{x:-.08,y:-.08},{x:-.08,y:-.08},{x:-.08,y:-.07},{x:-.08,y:-.07},{x:-.08,y:-.07},{x:-.08,y:-.07},{x:-.08,y:-.07},{x:-.08,y:-.07},{x:-.08,y:-.06},{x:-.08,y:-.06},{x:-.08,y:-.06},{x:-.08,y:-.06},{x:-.08,y:-.06},{x:-.08,y:-.05},{x:-.08,y:-.05},{x:-.08,y:-.05},{x:-.08,y:-.05},{x:-.08,y:-.05},{x:-.08,y:-.05},{x:-.08,y:-.04},{x:-.08,y:-.04},{x:-.08,y:-.04},{x:-.08,y:-.04},{x:-.08,y:-.04},{x:-.08,y:-.04},{x:-.08,y:-.03},{x:-.08,y:-.03},{x:-.08,y:-.03},{x:-.08,y:-.03},{x:-.08,y:-.03},{x:-.08,y:-.03},{x:-.08,y:-.02},{x:-.08,y:-.02},{x:-.08,y:-.02},{x:-.08,y:-.02},{x:-.08,y:-.02},{x:-.08,y:-.02},{x:-.08,y:-.01},{x:-.08,y:-.01},{x:-.08,y:-.01},{x:-.08,y:-.01},{x:-.08,y:-.01},{x:-.08,y:0},{x:-.08,y:0},{x:-.08,y:0},{x:-.08,y:0},{x:-.08,y:0},{x:-.08,y:0},{x:-.08,y:.01},{x:-.07,y:.01},{x:-.07,y:.01},{x:-.07,y:.01},{x:-.07,y:.01},{x:-.07,y:.01},{x:-.08,y:.02},{x:-.08,y:.02},{x:-.08,y:.02},{x:-.08,y:.02},{x:-.08,y:.02},{x:-.08,y:.02},{x:-.08,y:.03},{x:-.08,y:.03},{x:-.08,y:.03},{x:-.08,y:.03},{x:-.08,y:.03},{x:-.08,y:.03},{x:-.08,y:.04},{x:-.08,y:.04},{x:-.08,y:.04},{x:-.08,y:.04},{x:-.08,y:.04},{x:-.08,y:.05},{x:-.08,y:.05},{x:-.08,y:.05},{x:-.08,y:.05},{x:-.08,y:.05},{x:-.08,y:.05},{x:-.08,y:.06},{x:-.08,y:.06},{x:-.08,y:.06},{x:-.08,y:.06},{x:-.08,y:.06},{x:-.08,y:.06},{x:-.08,y:.06},{x:-.08,y:.06},{x:-.08,y:.07},{x:-.08,y:.07},{x:-.08,y:.07},{x:-.08,y:.07},{x:-.08,y:.07},{x:-.08,y:.07},{x:-.08,y:.07},{x:-.08,y:.08},{x:-.08,y:.08},{x:-.08,y:.08},{x:-.08,y:.08},{x:-.08,y:.08},{x:-.08,y:.08},{x:-.08,y:.09},{x:-.08,y:.09},{x:-.08,y:.09},{x:-.08,y:.09},{x:-.08,y:.09},{x:-.08,y:.09},{x:-.08,y:.09},{x:-.08,y:.1},{x:-.08,y:.1},{x:-.08,y:.1},{x:-.08,y:.1},{x:-.08,y:.1},{x:-.08,y:.1},{x:-.08,y:.1},{x:-.08,y:.11},{x:-.08,y:.11},{x:-.08,y:.11},{x:-.08,y:.11},{x:-.08,y:.11},{x:-.08,y:.11},{x:-.08,y:.11},{x:-.08,y:.12},{x:-.08,y:.12},{x:-.08,y:.12},{x:-.08,y:.12},{x:-.09,y:.12},{x:-.09,y:.12},{x:-.09,y:.12},{x:-.09,y:.13},{x:-.09,y:.13},{x:-.09,y:.13},{x:-.09,y:.13},{x:-.09,y:.13},{x:-.09,y:.13},{x:-.09,y:.14},{x:-.09,y:.14},{x:-.09,y:.14},{x:-.09,y:.14},{x:-.09,y:.14},{x:-.09,y:.14},{x:-.09,y:.14},{x:-.09,y:.15},{x:-.09,y:.15},{x:-.09,y:.15},{x:-.09,y:.15},{x:-.09,y:.15},{x:-.09,y:.15},{x:-.09,y:.15},{x:-.09,y:.16},{x:-.09,y:.16},{x:-.09,y:.16},{x:-.09,y:.16},{x:-.09,y:.16},{x:-.09,y:.16},{x:-.09,y:.16},{x:-.09,y:.17},{x:-.09,y:.17},{x:-.1,y:.17},{x:-.1,y:.17},{x:-.1,y:.17},{x:-.1,y:.17},{x:-.1,y:.17},{x:-.1,y:.18},{x:-.1,y:.18},{x:-.1,y:.18},{x:-.1,y:.18},{x:-.1,y:.18},{x:-.1,y:.18},{x:-.1,y:.18},{x:-.1,y:.19},{x:-.1,y:.19},{x:-.1,y:.19},{x:-.1,y:.19},{x:-.1,y:.19},{x:-.1,y:.19},{x:-.1,y:.19},{x:-.1,y:.2},{x:-.1,y:.2},{x:-.1,y:.2},{x:-.1,y:.2},{x:-.1,y:.2},{x:-.1,y:.2},{x:-.11,y:.2},{x:-.11,y:.2},{x:-.11,y:.2},{x:-.11,y:.21},{x:-.11,y:.21},{x:-.11,y:.21},{x:-.11,y:.21},{x:-.11,y:.21},{x:-.11,y:.21},{x:-.11,y:.21},{x:-.11,y:.21},{x:-.11,y:.21},{x:-.11,y:.21},{x:-.11,y:.21},{x:-.11,y:.21},{x:-.11,y:.21},{x:-.11,y:.22},{x:-.11,y:.22},{x:-.11,y:.22},{x:-.11,y:.22},{x:-.11,y:.22},{x:-.11,y:.22},{x:-.11,y:.22},{x:-.11,y:.22},{x:-.11,y:.22},{x:-.11,y:.22},{x:-.11,y:.22},{x:-.11,y:.22},{x:-.11,y:.23},{x:-.11,y:.23},{x:-.11,y:.23},{x:-.11,y:.23},{x:-.12,y:.23},{x:-.12,y:.23},{x:-.12,y:.23},{x:-.12,y:.23},{x:-.12,y:.23},{x:-.12,y:.23},{x:-.12,y:.23},{x:-.12,y:.23},{x:-.12,y:.24},{x:-.12,y:.24},{x:-.12,y:.24},{x:-.12,y:.24},{x:-.12,y:.24},{x:-.12,y:.24},{x:-.12,y:.24},{x:-.12,y:.24},{x:-.12,y:.24},{x:-.12,y:.24},{x:-.12,y:.24},{x:-.12,y:.24},{x:-.12,y:.25},{x:-.12,y:.25},{x:-.12,y:.25},{x:-.12,y:.25},{x:-.12,y:.25},{x:-.12,y:.25},{x:-.13,y:.25},{x:-.13,y:.25},{x:-.13,y:.25},{x:-.13,y:.25},{x:-.13,y:.25},{x:-.13,y:.25},{x:-.13,y:.25},{x:-.13,y:.26},{x:-.13,y:.26},{x:-.13,y:.26},{x:-.13,y:.26},{x:-.13,y:.26},{x:-.13,y:.26},{x:-.13,y:.26},{x:-.13,y:.26},{x:-.13,y:.26},{x:-.13,y:.26},{x:-.13,y:.26},{x:-.13,y:.26},{x:-.13,y:.26},{x:-.13,y:.27},{x:-.13,y:.27},{x:-.13,y:.27},{x:-.13,y:.27},{x:-.14,y:.27},{x:-.14,y:.27},{x:-.14,y:.27},{x:-.14,y:.27},{x:-.14,y:.27},{x:-.14,y:.27},{x:-.14,y:.27},{x:-.14,y:.27},{x:-.14,y:.27},{x:-.14,y:.28},{x:-.14,y:.28},{x:-.14,y:.28},{x:-.14,y:.28},{x:-.14,y:.28},{x:-.14,y:.28},{x:-.14,y:.28},{x:-.14,y:.28},{x:-.14,y:.28}],color:"primary",fill:!1},"rect1577-4":{type:"path",points:[{x:.26,y:.25},{x:.12,y:.25},{x:.12,y:.25},{x:.26,y:.25}],color:"primary",fill:!0},"rect1577-4-7":{type:"path",points:[{x:.2,y:.32},{x:.2,y:.18},{x:.19,y:.18},{x:.19,y:.32}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:-.01,y:.42},bottom1:{type:"text",text:"{VAL}",x:0,y:-.42}},refblocks:{left1:{x:-.54,y:.02},right1:{x:.45,y:.02}},bounds:{minX:-.58,maxX:.58,minY:-.42,maxY:.42,width:1.16,height:.84,centerX:0,centerY:0},circles:{}},{paths:Yc,texts:mu,bounds:ye,refblocks:na,circles:Xc}=O,fa=e({primitives:[...Object.values(Yc),...Object.values(Xc),{type:"text",text:"{REF}",x:.1,y:-.2094553499999995},{type:"text",text:"{VAL}",x:-.2,y:-.2094553499999995}],ports:[{...na.left1,labels:["2","neg"]},{...na.right1,labels:["1","pos"]}],size:{width:ye.width,height:ye.height},center:{x:ye.centerX,y:ye.centerY}}).changeTextAnchor("{VAL}","top_left").rotateRightFacingSymbol("up").changeTextAnchor("{REF}","bottom_left").build(),ca=e(O).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["2","neg"]).labelPort("right1",["1","pos"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:Lc,texts:_u,bounds:xe,refblocks:ha,circles:Vc}=O,da=e({primitives:[...Object.values(Lc),...Object.values(Vc),{type:"text",text:"{REF}",x:0,y:-.4094553499999995},{type:"text",text:"{VAL}",x:-0,y:.4094553499999995}],ports:[{...ha.left1,labels:["2","neg"]},{...ha.right1,labels:["1","pos"]}],size:{width:xe.width,height:xe.height},center:{x:xe.centerX,y:xe.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("left").changeTextAnchor("{REF}","middle_bottom").build(),{paths:jc,texts:wu,bounds:se,refblocks:ba,circles:kc}=O,_a=e({primitives:[...Object.values(jc),...Object.values(kc),{type:"text",text:"{REF}",x:-.2,y:.2094553499999995},{type:"text",text:"{VAL}",x:.3,y:.2094553499999995}],ports:[{...ba.left1,labels:["2","neg"]},{...ba.right1,labels:["1","pos"]}],size:{width:se.width,height:se.height},center:{x:se.centerX,y:se.centerY}}).changeTextAnchor("{VAL}","top_left").rotateRightFacingSymbol("down").changeTextAnchor("{REF}","bottom_left").build(),ga=e(z).rotateRightFacingSymbol("right").changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:zc,texts:Eu,bounds:me,refblocks:ua,circles:Oc}=z,va=e({primitives:[...Object.values(zc),...Object.values(Oc),{type:"text",text:"{REF}",x:.2,y:-.095},{type:"text",text:"{VAL}",x:-.2,y:-.095}],ports:[{...ua.left1,labels:["1"]},{...ua.right1,labels:["2"]}],size:{width:me.width,height:me.height},center:{x:me.centerX,y:me.centerY}}).changeTextAnchor("{VAL}","top_left").rotateRightFacingSymbol("up").labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{REF}","bottom_left").build(),P={paths:{path11:{type:"path",points:[{x:-.54,y:.03},{x:-.3,y:.03}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:.03},{x:.54,y:.03}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.29,y:.29},{x:.29,y:-.23}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.02,y:.37},bottom1:{type:"text",text:"{VAL}",x:-.01,y:-.37}},refblocks:{left1:{x:-.54,y:.03},right1:{x:.54,y:.03}},bounds:{minX:-.57,maxX:.57,minY:-.37,maxY:.37,width:1.14,height:.74,centerX:0,centerY:0},circles:{path1:{type:"circle",x:0,y:.04,radius:.29,color:"primary",fill:!1}}},{paths:$c,texts:ju,bounds:ne,refblocks:wa,circles:Mc}=P,Aa=e({primitives:[...Object.values($c),...Object.values(Mc),{type:"text",text:"{REF}",x:-.15,y:.3894553499999995},{type:"text",text:"{VAL}",x:.15,y:.3894553499999995}],ports:[{...wa.left1,labels:["1"]},{...wa.right1,labels:["2"]}],size:{width:ne.width,height:ne.height},center:{x:ne.centerX,y:ne.centerY}}).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),Pa=e(P).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:Cc,texts:Cu,bounds:fe,refblocks:Sa,circles:Nc}=P,Ra=e({primitives:[...Object.values(Cc),...Object.values(Nc),{type:"text",text:"{REF}",x:-0,y:-.2894553499999995},{type:"text",text:"{VAL}",x:0,y:.3894553499999995}],ports:[{...Sa.left1,labels:["1"]},{...Sa.right1,labels:["2"]}],size:{width:fe.width,height:fe.height},center:{x:fe.centerX,y:fe.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),Fa=e(P).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1","neg"]).labelPort("right1",["2","pos"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:Ic,texts:Uu,bounds:ce,refblocks:Ta,circles:Bc}=P,Ea=e({primitives:[...Object.values(Ic),...Object.values(Bc),{type:"text",text:"{REF}",x:.15,y:-.2894553499999995},{type:"text",text:"{VAL}",x:-.15,y:-.2894553499999995}],ports:[{...Ta.left1,labels:["1"]},{...Ta.right1,labels:["2"]}],size:{width:ce.width,height:ce.height},center:{x:ce.centerX,y:ce.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:qc,texts:Qu,bounds:he,refblocks:Ya,circles:Dc}=P,Xa=e({primitives:[...Object.values(qc),...Object.values(Dc),{type:"text",text:"{REF}",x:.15,y:-.2894553499999995},{type:"text",text:"{VAL}",x:-.15,y:-.2894553499999995}],ports:[{...Ya.left1,labels:["1"]},{...Ya.right1,labels:["2"]}],size:{width:he.width,height:he.height},center:{x:he.centerX,y:he.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),J={paths:{path27:{type:"path",points:[{x:.54,y:-.01},{x:.13,y:-.01}],color:"primary",fill:!1},path29:{type:"path",points:[{x:.13,y:.25},{x:.13,y:-.27}],color:"primary",fill:!1},"path29-2":{type:"path",points:[{x:.07,y:.25},{x:.07,y:-.28}],color:"primary",fill:!1},path30:{type:"path",points:[{x:-.14,y:.25},{x:-.14,y:-.27}],color:"primary",fill:!1},"path29-5":{type:"path",points:[{x:-.08,y:.26},{x:-.08,y:-.27}],color:"primary",fill:!1},"path29-2-7":{type:"path",points:[{x:.07,y:.26},{x:-.08,y:.26}],color:"primary",fill:!1},"path29-2-7-6":{type:"path",points:[{x:.07,y:-.28},{x:-.08,y:-.28}],color:"primary",fill:!1},path43:{type:"path",points:[{x:-.21,y:.32},{x:.2,y:.32}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:0,y:.71},{x:0,y:.33},{x:0,y:.32}],color:"primary",fill:!1},"path43-8":{type:"path",points:[{x:-.21,y:.32},{x:-.21,y:.25}],color:"primary",fill:!1},"path43-8-8":{type:"path",points:[{x:.2,y:.32},{x:.2,y:.25}],color:"primary",fill:!1},"path43-9":{type:"path",points:[{x:.19,y:-.35},{x:-.22,y:-.35}],color:"primary",fill:!1},"path44-0-5":{type:"path",points:[{x:-.02,y:-.71},{x:-.02,y:-.36},{x:-.02,y:-.35}],color:"primary",fill:!1},"path43-8-1":{type:"path",points:[{x:.19,y:-.35},{x:.19,y:-.28}],color:"primary",fill:!1},"path43-8-8-9":{type:"path",points:[{x:-.22,y:-.35},{x:-.22,y:-.28}],color:"primary",fill:!1},path28:{type:"path",points:[{x:-.14,y:-.01},{x:-.54,y:-.01}],color:"primary",fill:!1}},texts:{left1:{type:"text",text:"{REF}",x:.53,y:.28},right1:{type:"text",text:"{VAL}",x:.54,y:-.28}},refblocks:{top1:{x:0,y:.71},bottom1:{x:-.02,y:-.71},left1:{x:-.54,y:-.01},right1:{x:.54,y:-.01}},bounds:{minX:-.57,maxX:.57,minY:-.74,maxY:.74,width:1.14,height:1.48,centerX:0,centerY:0},circles:{}},{paths:Uc,texts:o3,bounds:de,refblocks:be,circles:Wc}=J,La=e({primitives:[...Object.values(Uc),...Object.values(Wc),{type:"text",text:"{REF}",x:-.4,y:.4094554499999995},{type:"text",text:"{VAL}",x:.4,y:.4094553499999995}],ports:[{...be.left1,labels:["1"]},{...be.right1,labels:["3"]},{...be.bottom1,labels:["2"]},{...be.top1,labels:["4"]}],size:{width:de.width,height:de.height},center:{x:de.centerX,y:de.centerY}}).rotateRightFacingSymbol("down").changeTextAnchor("{REF}","bottom_left").changeTextAnchor("{VAL}","top_left").build(),Va=e(J).labelPort("top1",["2","gnd1"]).labelPort("bottom1",["4","gnd2"]).labelPort("left1",["3"]).labelPort("right1",["1"]).changeTextAnchor("{REF}","bottom_left").changeTextAnchor("{VAL}","top_left").build(),ja=e(J).labelPort("top1",["4","gnd1"]).labelPort("bottom1",["2","gnd2"]).labelPort("left1",["1"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","bottom_left").changeTextAnchor("{VAL}","top_left").build(),{paths:Hc,texts:f3,bounds:_e,refblocks:ge,circles:Zc}=J,ka=e({primitives:[...Object.values(Hc),...Object.values(Zc),{type:"text",text:"{VAL}",x:-.4,y:-.4094554499999995},{type:"text",text:"{REF}",x:.4,y:-.4094553499999995}],ports:[{...ge.left1,labels:["1"]},{...ge.right1,labels:["3"]},{...ge.bottom1,labels:["2"]},{...ge.top1,labels:["4"]}],size:{width:_e.width,height:_e.height},center:{x:_e.centerX,y:_e.centerY}}).rotateRightFacingSymbol("up").changeTextAnchor("{REF}","bottom_left").changeTextAnchor("{VAL}","top_left").build(),$={paths:{path27:{type:"path",points:[{x:.55,y:-.01},{x:.13,y:-.01}],color:"primary",fill:!1},path28:{type:"path",points:[{x:-.14,y:-.01},{x:-.55,y:-.01}],color:"primary",fill:!1},path29:{type:"path",points:[{x:.13,y:-.28},{x:.13,y:.25}],color:"primary",fill:!1},"path29-2":{type:"path",points:[{x:.07,y:-.28},{x:.07,y:.25}],color:"primary",fill:!1},path30:{type:"path",points:[{x:-.14,y:-.28},{x:-.14,y:.25}],color:"primary",fill:!1},"path29-5":{type:"path",points:[{x:-.08,y:-.28},{x:-.08,y:.25}],color:"primary",fill:!1},"path29-2-7":{type:"path",points:[{x:.07,y:-.28},{x:-.08,y:-.28}],color:"primary",fill:!1},"path29-2-7-6":{type:"path",points:[{x:.07,y:.26},{x:-.08,y:.26}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{VAL}",x:-.01,y:-.42},bottom1:{type:"text",text:"{REF}",x:0,y:.43}},refblocks:{left1:{x:-.55,y:-.01},right1:{x:.55,y:-.01}},bounds:{minX:-.58,maxX:.58,minY:-.52,maxY:.43,width:1.16,height:1,centerX:0,centerY:-.04},circles:{}},{paths:Kc,texts:_3,bounds:ue,refblocks:za,circles:th}=$,Oa=e({primitives:[...Object.values(Kc),...Object.values(th),{type:"text",text:"{REF}",x:-.3,y:.3094553499999995},{type:"text",text:"{VAL}",x:.3,y:.3094553499999995}],ports:[{...za.left1,labels:["1"]},{...za.right1,labels:["2"]}],size:{width:ue.width,height:ue.height},center:{x:ue.centerX,y:ue.centerY}}).changeTextAnchor("{VAL}","top_left").rotateRightFacingSymbol("down").labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{REF}","bottom_left").build(),Ja=e($).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["2","neg"]).labelPort("right1",["1","pos"]).changeTextAnchor("{REF}","middle_bottom").build(),$a=e($).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:eh,texts:T3,bounds:ve,refblocks:Ma,circles:rh}=$,Ca=e({primitives:[...Object.values(eh),...Object.values(rh),{type:"text",text:"{REF}",x:.3,y:-.3094553499999995},{type:"text",text:"{VAL}",x:-.3,y:-.3094553499999995}],ports:[{...Ma.left1,labels:["1"]},{...Ma.right1,labels:["2"]}],size:{width:ve.width,height:ve.height},center:{x:ve.centerX,y:ve.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("up").labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{REF}","bottom_left").build(),Pt=.6,ur=.3,oh=[{type:"path",points:[{x:-Pt,y:0},{x:-ur,y:0}],color:"primary",fill:!1},{type:"path",points:[{x:ur,y:0},{x:Pt,y:0}],color:"primary",fill:!1},{type:"circle",x:0,y:0,radius:ur,color:"primary",fill:!1},{type:"path",points:[{x:-.1,y:0},{x:.15,y:0}],color:"primary",fill:!1},{type:"path",points:[{x:.15,y:0},{x:.05,y:.08}],color:"primary",fill:!1},{type:"path",points:[{x:.15,y:0},{x:.05,y:-.08}],color:"primary",fill:!1}],Na=e({primitives:[...oh,{type:"text",text:"{REF}",x:-.2,y:.35},{type:"text",text:"{VAL}",x:.2,y:.35}],ports:[{x:-Pt,y:0,labels:["1"]},{x:Pt,y:0,labels:["2"]}],center:{x:0,y:0},size:{width:Pt*2,height:.9}}).rotateRightFacingSymbol("down").changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),St=.6,vr=.3,ih=[{type:"path",points:[{x:-St,y:0},{x:-vr,y:0}],color:"primary",fill:!1},{type:"path",points:[{x:vr,y:0},{x:St,y:0}],color:"primary",fill:!1},{type:"circle",x:0,y:0,radius:vr,color:"primary",fill:!1},{type:"path",points:[{x:-.1,y:0},{x:.15,y:0}],color:"primary",fill:!1},{type:"path",points:[{x:.15,y:0},{x:.05,y:.08}],color:"primary",fill:!1},{type:"path",points:[{x:.15,y:0},{x:.05,y:-.08}],color:"primary",fill:!1}],Ia=e({primitives:[...ih,{type:"text",text:"{REF}",x:0,y:-.4},{type:"text",text:"{VAL}",x:0,y:.4}],ports:[{x:-St,y:0,labels:["1"]},{x:St,y:0,labels:["2"]}],center:{x:0,y:0},size:{width:St*2,height:.9}}).rotateRightFacingSymbol("left").changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),Rt=.6,wr=.3,lh=[{type:"path",points:[{x:-Rt,y:0},{x:-wr,y:0}],color:"primary",fill:!1},{type:"path",points:[{x:wr,y:0},{x:Rt,y:0}],color:"primary",fill:!1},{type:"circle",x:0,y:0,radius:wr,color:"primary",fill:!1},{type:"path",points:[{x:-.1,y:0},{x:.15,y:0}],color:"primary",fill:!1},{type:"path",points:[{x:.15,y:0},{x:.05,y:.08}],color:"primary",fill:!1},{type:"path",points:[{x:.15,y:0},{x:.05,y:-.08}],color:"primary",fill:!1}],Ba=e({primitives:[...lh,{type:"text",text:"{REF}",x:0,y:.4},{type:"text",text:"{VAL}",x:0,y:-.4}],ports:[{x:-Rt,y:0,labels:["1"]},{x:Rt,y:0,labels:["2"]}],center:{x:0,y:0},size:{width:Rt*2,height:.9}}).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),Ft=.6,Ar=.3,ph=[{type:"path",points:[{x:-Ft,y:0},{x:-Ar,y:0}],color:"primary",fill:!1},{type:"path",points:[{x:Ar,y:0},{x:Ft,y:0}],color:"primary",fill:!1},{type:"circle",x:0,y:0,radius:Ar,color:"primary",fill:!1},{type:"path",points:[{x:-.1,y:0},{x:.15,y:0}],color:"primary",fill:!1},{type:"path",points:[{x:.15,y:0},{x:.05,y:.08}],color:"primary",fill:!1},{type:"path",points:[{x:.15,y:0},{x:.05,y:-.08}],color:"primary",fill:!1}],qa=e({primitives:[...ph,{type:"text",text:"{REF}",x:.2,y:-.35},{type:"text",text:"{VAL}",x:-.2,y:-.35}],ports:[{x:-Ft,y:0,labels:["1"]},{x:Ft,y:0,labels:["2"]}],center:{x:0,y:0},size:{width:Ft*2,height:.9}}).rotateRightFacingSymbol("up").changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),S={paths:{path11:{type:"path",points:[{x:1.99,y:-1.64},{x:2.1,y:-1.64}],color:"primary",fill:!1},"path40-0":{type:"path",points:[{x:2.1,y:-1.48},{x:2.1,y:-1.8}],color:"primary",fill:!1},"path40-0-5":{type:"path",points:[{x:2.22,y:-1.5},{x:2.11,y:-1.58}],color:"primary",fill:!1},"path40-0-5-0":{type:"path",points:[{x:2.23,y:-1.78},{x:2.11,y:-1.7}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:2.23,y:-1.49},{x:2.23,y:-1.14}],color:"primary",fill:!1},"path12-1-5-3":{type:"path",points:[{x:2.23,y:-1.97},{x:2.23,y:-1.79}],color:"primary",fill:!1},"arrow-2":{type:"path",points:[{x:2.17,y:-1.7},{x:2.13,y:-1.76},{x:2.19,y:-1.76},{x:2.17,y:-1.7}],color:"primary",fill:!0},path1:{type:"path",points:[{x:1.6,y:-1.5},{x:1.86,y:-1.5}],color:"primary",fill:!1},path2:{type:"path",points:[{x:1.87,y:-1.34},{x:1.87,y:-1.66}],color:"primary",fill:!1},path3:{type:"path",points:[{x:1.99,y:-1.36},{x:1.87,y:-1.44}],color:"primary",fill:!1},path4:{type:"path",points:[{x:1.99,y:-1.64},{x:1.88,y:-1.56}],color:"primary",fill:!1},"arrow-1":{type:"path",points:[{x:1.94,y:-1.56},{x:1.89,y:-1.62},{x:1.96,y:-1.62},{x:1.94,y:-1.56}],color:"primary",fill:!0},path9:{type:"path",points:[{x:1.99,y:-1.35},{x:2.23,y:-1.36}],color:"primary",fill:!1}},texts:{bottom1:{type:"text",text:"{VAL}",x:1.88,y:-1.94},right1:{type:"text",text:"{REF}",x:1.88,y:-1.14}},refblocks:{right1:{x:2.23,y:-1.97},right2:{x:1.6,y:-1.5},right3:{x:2.23,y:-1.14}},bounds:{minX:1.58,maxX:2.35,minY:-1.98,maxY:-1.12,width:.77,height:.86,centerX:1.96,centerY:-1.55},circles:{"path1-0":{type:"circle",x:2.05,y:-1.54,radius:.3,color:"primary",fill:!1}}},Da=e(S).rotateRightFacingSymbol("down").labelPort("right2",["1"]).labelPort("right1",["2"]).labelPort("right3",["3"]).changeTextAnchor("{VAL}","middle_left",{x:.8,y:-.15}).changeTextAnchor("{REF}","middle_left",{x:0,y:.15}).build(),Ga=e(S).rotateRightFacingSymbol("right").labelPort("right2",["1"]).labelPort("right1",["2"]).labelPort("right3",["3"]).changeTextAnchor("{VAL}","middle_right").changeTextAnchor("{REF}","middle_right").build(),Ua=e(S).rotateRightFacingSymbol("left").labelPort("right2",["1"]).labelPort("right1",["2"]).labelPort("right3",["3"]).changeTextAnchor("{VAL}","middle_left",{x:0,y:-.8}).changeTextAnchor("{REF}","middle_left",{x:0,y:.8}).build(),Wa=e(S).rotateRightFacingSymbol("right").labelPort("right2",["1"]).labelPort("right1",["2"]).labelPort("right3",["3"]).changeTextAnchor("{VAL}","middle_right").changeTextAnchor("{REF}","middle_right").build(),Ha=e(S).rotateRightFacingSymbol("up").labelPort("right2",["1"]).labelPort("right1",["2"]).labelPort("right3",["3"]).changeTextAnchor("{VAL}","middle_left",{x:0,y:-.15}).changeTextAnchor("{REF}","middle_left",{x:.8,y:.15}).build(),Za=e(S).rotateRightFacingSymbol("up").labelPort("right2",["1"]).labelPort("right1",["2"]).labelPort("right3",["3"]).changeTextAnchor("{VAL}","middle_left",{x:0,y:-.15}).changeTextAnchor("{REF}","middle_left",{x:.8,y:.15}).build(),Qa={paths:{path11:{type:"path",points:[{x:-.54,y:0},{x:-.3,y:0}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:0},{x:.54,y:0}],color:"primary",fill:!1},path2:{type:"path",points:[{x:-.12,y:.09},{x:.12,y:.09}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.18,y:-.45},bottom1:{type:"text",text:"{VAL}",x:-.01,y:.35},left1:{type:"text",text:"A",x:0,y:-.1}},refblocks:{left1:{x:-.54,y:0},right1:{x:.54,y:0}},bounds:{minX:-.53,maxX:.53,minY:-.09,maxY:.09,width:1.06,height:1,centerX:0,centerY:0},circles:{path1:{type:"circle",x:0,y:0,radius:.29,color:"primary",fill:!1}}},{paths:xh,texts:sh,bounds:we,refblocks:Ka,circles:mh}=Qa,Tt=s({primitives:[...Object.values(xh),...Object.values(mh),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"},{...sh.left1,x:0,y:.01,anchor:"center",fontSize:.3}],ports:[{...Ka.left1,labels:["1"]},{...Ka.right1,labels:["2"]}],size:{width:we.width,height:we.height},center:{x:we.centerX,y:we.centerY}});({6:Pr,2:Sr,...ch}=Tt.primitives);nh(Sr)&&Sr.points.map(t5=>{t5.y+=.05});fh(Pr)&&(Pr.y+=.025);ty=r({...Tt,primitives:Object.values(ch).filter(hh)}),ey={...ty,primitives:[...ty.primitives,Pr,Sr]},R={paths:{path11:{type:"path",points:[{x:-.54,y:.03},{x:-.3,y:.04}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:.04},{x:.54,y:.04}],color:"primary",fill:!1},"path11-5-5":{type:"path",points:[{x:.1,y:.13},{x:0,y:-.06},{x:-.11,y:.13}],color:"primary",fill:!1},path2:{type:"path",points:[{x:-.12,y:-.14},{x:.12,y:-.14}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.17,y:.4},bottom1:{type:"text",text:"{VAL}",x:-.01,y:-.4}},refblocks:{left1:{x:-.54,y:.03},right1:{x:.54,y:.04}},bounds:{minX:-.57,maxX:.57,minY:-.4,maxY:.4,width:1.14,height:.79,centerX:0,centerY:0},circles:{path1:{type:"circle",x:0,y:.04,radius:.29,color:"primary",fill:!1}}},{paths:bh,texts:f7,bounds:Ae,refblocks:ry,circles:_h}=R,oy=e({primitives:[...Object.values(bh),...Object.values(_h),{type:"text",text:"{REF}",x:-.15,y:.3894553499999995},{type:"text",text:"{VAL}",x:.15,y:.3894553499999995}],ports:[{...ry.left1,labels:["1"]},{...ry.right1,labels:["2"]}],size:{width:Ae.width,height:Ae.height},center:{x:Ae.centerX,y:Ae.centerY}}).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:gh,texts:b7,bounds:Pe,refblocks:iy,circles:uh}=R,ly=e({primitives:[...Object.values(gh),...Object.values(uh),{type:"text",text:"{REF}",x:-0,y:.3894553499999995},{type:"text",text:"{VAL}",x:0,y:-.3294553499999995}],ports:[{...iy.left1,labels:["1"]},{...iy.right1,labels:["2"]}],size:{width:Pe.width,height:Pe.height},center:{x:Pe.centerX,y:Pe.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:vh,texts:v7,bounds:Se,refblocks:py,circles:wh}=R,ay=e({primitives:[...Object.values(vh),...Object.values(wh),{type:"text",text:"{REF}",x:-0,y:-.3294553499999995},{type:"text",text:"{VAL}",x:0,y:.4294553499999995}],ports:[{...py.left1,labels:["1"]},{...py.right1,labels:["2"]}],size:{width:Se.width,height:Se.height},center:{x:Se.centerX,y:Se.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:Ah,texts:S7,bounds:Re,refblocks:yy,circles:Ph}=R,xy=e({primitives:[...Object.values(Ah),...Object.values(Ph),{type:"text",text:"{REF}",x:-0,y:.3894553499999995},{type:"text",text:"{VAL}",x:0,y:-.3294553499999995}],ports:[{...yy.left1,labels:["1"]},{...yy.right1,labels:["2"]}],size:{width:Re.width,height:Re.height},center:{x:Re.centerX,y:Re.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:Sh,texts:E7,bounds:Fe,refblocks:sy,circles:Rh}=R,my=e({primitives:[...Object.values(Sh),...Object.values(Rh),{type:"text",text:"{REF}",x:.15,y:-.2894553499999995},{type:"text",text:"{VAL}",x:-.15,y:-.2894553499999995}],ports:[{...sy.left1,labels:["1"]},{...sy.right1,labels:["2"]}],size:{width:Fe.width,height:Fe.height},center:{x:Fe.centerX,y:Fe.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:Fh,texts:V7,bounds:Te,refblocks:ny,circles:Th}=R,fy=e({primitives:[...Object.values(Fh),...Object.values(Th),{type:"text",text:"{REF}",x:.15,y:-.2894553499999995},{type:"text",text:"{VAL}",x:-.15,y:-.2894553499999995}],ports:[{...ny.left1,labels:["1"]},{...ny.right1,labels:["2"]}],size:{width:Te.width,height:Te.height},center:{x:Te.centerX,y:Te.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),F={paths:{path11:{type:"path",points:[{x:-.54,y:.04},{x:-.11,y:.04}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.1,y:.04},{x:.54,y:.04}],color:"primary",fill:!1},"path11-0":{type:"path",points:[{x:-.09,y:-.15},{x:-.09,y:.26}],color:"primary",fill:!1},"path11-0-3":{type:"path",points:[{x:.09,y:-.15},{x:.09,y:.26}],color:"primary",fill:!1},"path11-0-9":{type:"path",points:[{x:-.08,y:.06},{x:-.08,y:-.15},{x:.09,y:-.05},{x:-.08,y:.06}],color:"primary",fill:!0},"path11-0-9-0":{type:"path",points:[{x:.08,y:.26},{x:.08,y:.05},{x:-.09,y:.15},{x:.07,y:.26}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:-.03,y:.42},bottom1:{type:"text",text:"{VAL}",x:-.03,y:-.42}},refblocks:{left1:{x:-.54,y:.04},right1:{x:.54,y:.04}},bounds:{minX:-.57,maxX:.57,minY:-.42,maxY:.42,width:1.14,height:.83,centerX:0,centerY:0},circles:{path1:{type:"circle",x:0,y:.05,radius:.29,color:"primary",fill:!1}}},cy=e(F).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left",{x:-.03,y:.2}).changeTextAnchor("{VAL}","middle_left",{x:.8,y:-.2}).build(),hy=e(F).rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom",{x:0,y:.1}).changeTextAnchor("{VAL}","middle_top").build(),dy=e(F).rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom",{x:0,y:.8}).changeTextAnchor("{VAL}","middle_top",{x:0,y:-.9}).build(),by=e(F).rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom",{x:0,y:.1}).changeTextAnchor("{VAL}","middle_top").build(),_y=e(F).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left",{x:.7,y:.2}).changeTextAnchor("{VAL}","middle_left",{x:-.13,y:-.2}).build(),gy=e(F).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left",{x:.7,y:.2}).changeTextAnchor("{VAL}","middle_left",{x:-.13,y:-.2}).build(),M={paths:{triangle:{type:"path",points:[{x:-.06,y:-.09},{x:-.06,y:.09},{x:.06,y:0},{x:-.06,y:-.09}],color:"primary",fill:!1},stem:{type:"path",points:[{x:-.11,y:0},{x:-.06,y:0}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:0,y:.03}},refblocks:{left1:{x:-.11,y:0}},bounds:{minX:-.57,maxX:.57,minY:-.37,maxY:.37,width:1.14,height:.74,centerX:0,centerY:0},circles:{}},{paths:Xh,bounds:uy,refblocks:Lh}=M,vy=e({primitives:[...Object.values(Xh),{type:"text",text:"{REF}",x:-.13,y:-0}],ports:[{...Lh.left1,labels:["1"]}],center:{x:uy.centerX,y:uy.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_top").build(),{paths:Vh,bounds:wy,refblocks:jh}=M,Ay=e({primitives:[...Object.values(Vh),{type:"text",text:"{REF}",x:-.13,y:0}],ports:[{...jh.left1,labels:["1"]}],center:{x:wy.centerX,y:wy.centerY}}).rotateRightFacingSymbol("right").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_right").build(),{paths:kh,bounds:Py,refblocks:zh}=M,Sy=e({primitives:[...Object.values(kh),{type:"text",text:"{REF}",x:-.13,y:-0}],ports:[{...zh.left1,labels:["1"]}],center:{x:Py.centerX,y:Py.centerY}}).rotateRightFacingSymbol("left").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_left").build(),{paths:Oh,bounds:Ry,refblocks:Jh}=M,Fy=e({primitives:[...Object.values(Oh),{type:"text",text:"{REF}",x:-.13,y:0}],ports:[{...Jh.left1,labels:["1"]}],center:{x:Ry.centerX,y:Ry.centerY}}).rotateRightFacingSymbol("down").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_bottom").build(),Ty={paths:{path40:{type:"path",points:[{x:.14,y:.04},{x:-.12,y:-.09}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.12,y:.18},{x:.14,y:.04}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.12,y:-.09},{x:-.12,y:.18}],color:"primary",fill:!1},path43:{type:"path",points:[{x:.14,y:.18},{x:.14,y:-.09}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.12,y:.04},{x:-.52,y:.04}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.52,y:.04},{x:.15,y:.04}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.01,y:.27},bottom1:{type:"text",text:"{VAL}",x:0,y:-.27}},refblocks:{left1:{x:-.52,y:.04},right1:{x:.52,y:.04}},bounds:{minX:-.55,maxX:.55,minY:-.27,maxY:.27,width:1.09,height:.55,centerX:0,centerY:0},circles:{}},C=e(Ty).labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),Ey=r(C,"down"),Yy=r(C,"left"),Xy=r(C,"up"),Ly={paths:{path1:{type:"path",points:[{x:-.37,y:.22},{x:-.13,y:.22}],color:"primary",fill:!1},"path-1-2":{type:"path",points:[{x:-.07,y:.22},{x:.11,y:.16}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.1,y:.13},{x:.37,y:.13}],color:"primary",fill:!1},path3:{type:"path",points:[{x:.12,y:.36},{x:.37,y:.36}],color:"primary",fill:!1},path4:{type:"path",points:[{x:-.37,y:-.18},{x:-.13,y:-.18}],color:"primary",fill:!1},"path4-5":{type:"path",points:[{x:-.07,y:-.19},{x:.1,y:-.24}],color:"primary",fill:!1},path5:{type:"path",points:[{x:.1,y:-.27},{x:.37,y:-.27}],color:"primary",fill:!1},path6:{type:"path",points:[{x:.12,y:-.04},{x:.37,y:-.04}],color:"primary",fill:!1},"path1-4-join":{type:"path",points:[{x:0,y:-.2},{x:0,y:.19}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:0,y:.56},bottom1:{type:"text",text:"{VAL}",x:0,y:-.42}},refblocks:{left1:{x:-.37,y:.22},left2:{x:-.37,y:-.18},right1:{x:.37,y:.36},right2:{x:.37,y:.13},right3:{x:.37,y:-.04},right5:{x:.37,y:-.27}},bounds:{minX:-.4,maxX:.4,minY:-.47,maxY:.56,width:1,height:1.04,centerX:0,centerY:.05},circles:{"circle-2":{type:"circle",x:.08,y:.13,radius:.02,color:"primary",fill:!1},"circle-5":{type:"circle",x:.08,y:-.27,radius:.02,color:"primary",fill:!1},"circle-3":{type:"circle",x:.08,y:.37,radius:.02,color:"primary",fill:!1},"circle-6":{type:"circle",x:.08,y:-.04,radius:.02,color:"primary",fill:!1},"circle-1":{type:"circle",x:-.1,y:.22,radius:.02,color:"primary",fill:!1},"circle-4":{type:"circle",x:-.1,y:-.18,radius:.02,color:"primary",fill:!1}}},N=e(Ly).labelPort("left1",["1"]).labelPort("right1",["3"]).labelPort("right2",["2"]).labelPort("right3",["6"]).labelPort("left2",["4"]).labelPort("right5",["5"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),Rr=r(N,"down"),Fr=Rr.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),Tr=Rr.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Fr.anchor="middle_bottom";Tr.anchor="middle_top";Fr.x=0;Fr.y+=.537;Tr.y-=.5375;Tr.x=0;Vy=Rr,Er=r(N,"left"),Yr=Er.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),Xr=Er.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Yr.anchor="middle_bottom";Xr.anchor="middle_top";Yr.x=0;Yr.y+=1;Xr.y-=1;Xr.x=0;jy=Er,Lr=r(N,"up"),Vr=Lr.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),jr=Lr.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Vr.anchor="middle_bottom";jr.anchor="middle_top";Vr.x=0;Vr.y+=.537;jr.y-=.5375;jr.x=0;ky=Lr,zy={paths:{path1:{type:"path",points:[{x:-.37,y:.22},{x:-.13,y:.22}],color:"primary",fill:!1},"path-1-3":{type:"path",points:[{x:-.07,y:.23},{x:.11,y:.33}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.1,y:.13},{x:.37,y:.13}],color:"primary",fill:!1},path3:{type:"path",points:[{x:.12,y:.36},{x:.37,y:.36}],color:"primary",fill:!1},path4:{type:"path",points:[{x:-.37,y:-.18},{x:-.13,y:-.18}],color:"primary",fill:!1},"path4-6":{type:"path",points:[{x:-.07,y:-.18},{x:.11,y:-.07}],color:"primary",fill:!1},path5:{type:"path",points:[{x:.1,y:-.27},{x:.37,y:-.27}],color:"primary",fill:!1},path6:{type:"path",points:[{x:.12,y:-.04},{x:.37,y:-.04}],color:"primary",fill:!1},"path1-4-join":{type:"path",points:[{x:0,y:-.12},{x:0,y:.27}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:0,y:.61},bottom1:{type:"text",text:"{VAL}",x:0,y:-.52}},refblocks:{left1:{x:-.37,y:.22},left2:{x:-.37,y:-.18},right1:{x:.37,y:.36},right2:{x:.37,y:.13},right3:{x:.37,y:-.04},right5:{x:.37,y:-.27}},bounds:{minX:-.4,maxX:.4,minY:-.47,maxY:.56,width:1,height:1.04,centerX:0,centerY:.05},circles:{"circle-2":{type:"circle",x:.08,y:.13,radius:.02,color:"primary",fill:!1},"circle-5":{type:"circle",x:.08,y:-.27,radius:.02,color:"primary",fill:!1},"circle-3":{type:"circle",x:.08,y:.37,radius:.02,color:"primary",fill:!1},"circle-6":{type:"circle",x:.08,y:-.04,radius:.02,color:"primary",fill:!1},"circle-1":{type:"circle",x:-.1,y:.22,radius:.02,color:"primary",fill:!1},"circle-4":{type:"circle",x:-.1,y:-.18,radius:.02,color:"primary",fill:!1}}},I=e(zy).labelPort("left1",["1"]).labelPort("right1",["3"]).labelPort("right2",["2"]).labelPort("right3",["6"]).labelPort("left2",["4"]).labelPort("right5",["5"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),kr=r(I,"down"),zr=kr.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),Or=kr.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");zr.anchor="middle_bottom";Or.anchor="middle_top";zr.x=0;zr.y+=.565;Or.y-=.555;Or.x=0;Oy=kr,Jr=r(I,"left"),$r=Jr.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),Mr=Jr.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");$r.anchor="middle_bottom";Mr.anchor="middle_top";$r.x=0;$r.y+=1.09;Mr.y-=1.09;Mr.x=0;Jy=Jr,Cr=r(I,"up"),Nr=Cr.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),Ir=Cr.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Nr.anchor="middle_bottom";Ir.anchor="middle_top";Nr.x=0;Nr.y+=.565;Ir.y-=.555;Ir.x=0;$y=Cr,My={paths:{path11:{type:"path",points:[{x:-.38,y:.06},{x:-.14,y:.06}],color:"primary",fill:!1},"path11-0":{type:"path",points:[{x:-.09,y:.07},{x:.11,y:.11}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.13,y:.06},{x:.38,y:.06}],color:"primary",fill:!1},"path11-5":{type:"path",points:[{x:-.38,y:-.17},{x:-.14,y:-.17}],color:"primary",fill:!1},"path11-0-3":{type:"path",points:[{x:-.09,y:-.17},{x:.11,y:-.12}],color:"primary",fill:!1},"path12-0":{type:"path",points:[{x:.13,y:-.17},{x:.38,y:-.17}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:0,y:.31},bottom1:{type:"text",text:"{VAL}",x:0,y:-.31}},refblocks:{left1:{x:-.38,y:-.17},left3:{x:-.38,y:.06},right1:{x:.38,y:-.17},right3:{x:.38,y:.06}},bounds:{minX:-.4,maxX:.4,minY:-.4,maxY:.4,width:.81,height:.79,centerX:0,centerY:0},circles:{"circle-4":{type:"circle",x:.1,y:.06,radius:.02,color:"primary",fill:!1},"circle-2":{type:"circle",x:.1,y:-.17,radius:.02,color:"primary",fill:!1},"circle-3":{type:"circle",x:-.11,y:.06,radius:.02,color:"primary",fill:!1},"circle-1":{type:"circle",x:-.11,y:-.17,radius:.02,color:"primary",fill:!1}}},B=e(My).labelPort("left1",["1"]).labelPort("right1",["2"]).labelPort("right3",["4"]).labelPort("left3",["3"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),Br=r(B,"down"),qr=Br.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),Dr=Br.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");qr.anchor="middle_bottom";Dr.anchor="middle_top";qr.x=.4;qr.y+=.265;Dr.y-=.265;Dr.x=.4;Cy=Br,Gr=r(B,"left"),Ur=Gr.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),Wr=Gr.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Ur.anchor="middle_bottom";Wr.anchor="middle_top";Ur.x=0;Ur.y+=.67;Wr.y-=.67;Wr.x=0;Ny=Gr,Hr=r(B,"up"),Zr=Hr.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),Qr=Hr.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Zr.anchor="middle_bottom";Qr.anchor="middle_top";Zr.x=.46;Zr.y+=.265;Qr.y-=.265;Qr.x=.46;Iy=Hr,By={paths:{path11:{type:"path",points:[{x:-.38,y:.06},{x:-.14,y:.06}],color:"primary",fill:!1},"path11-0":{type:"path",points:[{x:-.09,y:.07},{x:.1,y:.2}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.13,y:.06},{x:.38,y:.06}],color:"primary",fill:!1},"path11-5":{type:"path",points:[{x:-.38,y:-.17},{x:-.14,y:-.17}],color:"primary",fill:!1},"path11-0-3":{type:"path",points:[{x:-.09,y:-.16},{x:.1,y:-.03}],color:"primary",fill:!1},"path12-0":{type:"path",points:[{x:.13,y:-.17},{x:.38,y:-.17}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:0,y:.42},bottom1:{type:"text",text:"{VAL}",x:0,y:-.42}},refblocks:{left1:{x:-.38,y:-.17},left3:{x:-.38,y:.06},right1:{x:.38,y:-.17},right3:{x:.38,y:.06}},bounds:{minX:-.4,maxX:.4,minY:-.4,maxY:.4,width:.81,height:.79,centerX:0,centerY:0},circles:{"circle-4":{type:"circle",x:.1,y:.06,radius:.02,color:"primary",fill:!1},"circle-2":{type:"circle",x:.1,y:-.17,radius:.02,color:"primary",fill:!1},"circle-3":{type:"circle",x:-.11,y:.06,radius:.02,color:"primary",fill:!1},"circle-1":{type:"circle",x:-.11,y:-.17,radius:.02,color:"primary",fill:!1}}},q=e(By).labelPort("left1",["1"]).labelPort("right1",["2"]).labelPort("right3",["4"]).labelPort("left3",["3"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),Kr=r(q,"down"),to=Kr.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),eo=Kr.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");to.anchor="middle_bottom";eo.anchor="middle_top";to.x=.4;to.y+=.295;eo.y-=.295;eo.x=.42;qy=Kr,ro=r(q,"left"),oo=ro.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),io=ro.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");oo.anchor="middle_bottom";io.anchor="middle_top";oo.x=0;oo.y+=.795;io.y-=.795;io.x=0;Dy=ro,lo=r(q,"up"),po=lo.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),ao=lo.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");po.anchor="middle_bottom";ao.anchor="middle_top";po.x=.46;po.y+=.315;ao.y-=.315;ao.x=.46;Gy=lo,Ee={paths:{path5:{type:"path",points:[{x:-.44,y:0},{x:-.16,y:0}],color:"primary",fill:!1},path6:{type:"path",points:[{x:.17,y:0},{x:.44,y:.01}],color:"primary",fill:!1},path9:{type:"path",points:[{x:-.25,y:-.16},{x:.02,y:.3},{x:.25,y:.17},{x:-.02,y:-.29},{x:-.25,y:-.16}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:0,y:.37},bottom1:{type:"text",text:"{VAL}",x:0,y:-.37}},refblocks:{left1:{x:-.44,y:0},right1:{x:.44,y:.01}},bounds:{minX:-.57,maxX:.57,minY:-.25,maxY:.25,width:1.13,height:.5,centerX:0,centerY:0},circles:{}},{paths:qh,texts:Fv,bounds:Ye,refblocks:Uy,circles:Dh}=Ee,Xe=e({primitives:[...Object.values(qh),...Object.values(Dh),{type:"text",text:"{REF}",x:.18,y:-.3204553499999995},{type:"text",text:"{VAL}",x:-.25,y:-.3294553499999995}],ports:[{...Uy.left1,labels:["1"]},{...Uy.right1,labels:["2"]}],size:{width:Ye.width,height:Ye.height},center:{x:Ye.centerX,y:Ye.centerY}}).rotateRightFacingSymbol("up").labelPort("left",["1"]).labelPort("right",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),yo=v(Xe),xo=yo.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),so=yo.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");xo.anchor="middle_left";so.anchor="middle_left";xo.y+=.4;xo.x=.32;so.y-=.45;so.x=.32;Wy=yo,Le=e(Ee).labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),Hy=Y(Le),T={paths:{path11:{type:"path",points:[{x:-.56,y:.04},{x:-.22,y:.04}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.14,y:.05},{x:.48,y:.05}],color:"primary",fill:!1},"path12-6":{type:"path",points:[{x:.14,y:-.15},{x:.14,y:.25}],color:"primary",fill:!1},"path11-0-9":{type:"path",points:[{x:-.22,y:.25},{x:-.21,y:-.15},{x:.14,y:.05},{x:-.22,y:.25}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:-.09,y:.38},bottom1:{type:"text",text:"{VAL}",x:-.07,y:-.38},right1:{type:"text",text:"",x:.59,y:-.33}},refblocks:{left1:{x:-.56,y:.04},right1:{x:.48,y:.05}},bounds:{minX:-.59,maxX:.59,minY:-.38,maxY:.38,width:1.18,height:.76,centerX:0,centerY:0},circles:{}},{paths:Uh,texts:Nv,bounds:Ve,refblocks:Zy,circles:Wh}=T,Qy=e({primitives:[...Object.values(Uh),...Object.values(Wh),{type:"text",text:"{REF}",x:-.15,y:.3294553499999995},{type:"text",text:"{VAL}",x:.15,y:.3294553499999995}],ports:[{...Zy.left1,labels:["1"]},{...Zy.right1,labels:["2"]}],size:{width:Ve.width,height:Ve.height},center:{x:Ve.centerX,y:Ve.centerY}}).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:Hh,texts:Dv,bounds:je,refblocks:Ky,circles:Zh}=T,tx=e({primitives:[...Object.values(Hh),...Object.values(Zh),{type:"text",text:"{REF}",x:-0,y:.4094553499999995},{type:"text",text:"{VAL}",x:0,y:-.4094553499999995}],ports:[{...Ky.left1,labels:["1"]},{...Ky.right1,labels:["2"]}],size:{width:je.width,height:je.height},center:{x:je.centerX,y:je.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:Qh,texts:Hv,bounds:ke,refblocks:ex,circles:Kh}=T,rx=e({primitives:[...Object.values(Qh),...Object.values(Kh),{type:"text",text:"{REF}",x:-0,y:-.3094553499999995},{type:"text",text:"{VAL}",x:0,y:.4094553499999995}],ports:[{...ex.left1,labels:["1"]},{...ex.right1,labels:["2"]}],size:{width:ke.width,height:ke.height},center:{x:ke.centerX,y:ke.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:td,texts:t6,bounds:ze,refblocks:ox,circles:ed}=T,ix=e({primitives:[...Object.values(td),...Object.values(ed),{type:"text",text:"{REF}",x:-0,y:.4094553499999995},{type:"text",text:"{VAL}",x:0,y:-.4094553499999995}],ports:[{...ox.left1,labels:["1"]},{...ox.right1,labels:["2"]}],size:{width:ze.width,height:ze.height},center:{x:ze.centerX,y:ze.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:rd,texts:i6,bounds:Oe,refblocks:lx,circles:od}=T,px=e({primitives:[...Object.values(rd),...Object.values(od),{type:"text",text:"{REF}",x:.15,y:-.2894553499999995},{type:"text",text:"{VAL}",x:-.15,y:-.2894553499999995}],ports:[{...lx.left1,labels:["1"]},{...lx.right1,labels:["2"]}],size:{width:Oe.width,height:Oe.height},center:{x:Oe.centerX,y:Oe.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:id,texts:y6,bounds:Je,refblocks:ax,circles:ld}=T,yx=e({primitives:[...Object.values(id),...Object.values(ld),{type:"text",text:"{REF}",x:.15,y:-.2894553499999995},{type:"text",text:"{VAL}",x:-.15,y:-.2894553499999995}],ports:[{...ax.left1,labels:["1"]},{...ax.right1,labels:["2"]}],size:{width:Je.width,height:Je.height},center:{x:Je.centerX,y:Je.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),xx={paths:{path11:{type:"path",points:[{x:-.54,y:0},{x:-.3,y:0}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:0},{x:.54,y:0}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.18,y:-.36},bottom1:{type:"text",text:"{VAL}",x:-.01,y:.43},left1:{type:"text",text:"Hz",x:0,y:-.04}},refblocks:{left1:{x:-.54,y:0},right1:{x:.54,y:0}},bounds:{minX:-.53,maxX:.53,minY:0,maxY:0,width:1.06,height:1,centerX:0,centerY:0},circles:{path1:{type:"circle",x:-.01,y:-.01,radius:.29,color:"primary",fill:!1}}},{paths:ad,texts:yd,bounds:$e,refblocks:sx,circles:xd}=xx,Et=s({primitives:[...Object.values(ad),...Object.values(xd),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"},{...yd.left1,x:0,y:.01,anchor:"center",fontSize:.2}],ports:[{...sx.left1,labels:["1"]},{...sx.right1,labels:["2"]}],size:{width:$e.width,height:$e.height},center:{x:$e.centerX,y:$e.centerY}}),{5:sd,...md}=Et.primitives;mx=r({...Et,primitives:Object.values(md).filter(nd)}),nx={...mx,primitives:[...mx.primitives,sd]},fx={paths:{path10:{type:"path",points:[{x:-.53,y:.04},{x:.53,y:.04}],color:"primary",fill:!1},path14:{type:"path",points:[{x:0,y:.17},{x:.27,y:.17},{x:.27,y:-.1},{x:-.26,y:-.1},{x:-.26,y:.17},{x:0,y:.17}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.01,y:.24},bottom1:{type:"text",text:"{VAL}",x:-.17,y:-.24}},refblocks:{left1:{x:-.53,y:.04},right1:{x:.53,y:.04}},bounds:{minX:-.56,maxX:.56,minY:-.24,maxY:.24,width:1.13,height:.47,centerX:0,centerY:0},circles:{}},{paths:cd,texts:hd,bounds:Me,refblocks:cx}=fx,Ce=s({primitives:[...Object.values(cd),{...hd.top1,anchor:"middle_bottom"},{type:"text",text:"{VAL}",x:0,y:-.2,anchor:"middle_top"}],ports:[{...cx.left1,labels:["1"]},{...cx.right1,labels:["2"]}],size:{width:Me.width,height:Me.height},center:{x:Me.centerX,y:Me.centerY}}),hx=r(Ce),E={paths:{path1:{type:"path",points:[{x:-.29,y:.01},{x:.04,y:0}],color:"primary",fill:!0},path2:{type:"path",points:[{x:.04,y:-.22},{x:.04,y:.22}],color:"primary",fill:!0},path3:{type:"path",points:[{x:.12,y:-.17},{x:.12,y:.17}],color:"primary",fill:!0},path4:{type:"path",points:[{x:.19,y:-.06},{x:.19,y:.06}],color:"primary",fill:!0}},texts:{right1:{type:"text",text:"{REF}",x:.31,y:-.02}},refblocks:{left1:{x:-.29,y:.01}},bounds:{minX:-.31,maxX:.31,minY:-.22,maxY:.22,width:.62,height:.45,centerX:0,centerY:0},circles:{}},dx=e(E).rotateRightFacingSymbol("down").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_top").build(),bx=e(E).rotateRightFacingSymbol("right").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_left").build(),_x=e(E).rotateRightFacingSymbol("left").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_right").build(),gx=e(E).rotateRightFacingSymbol("right").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_left").build(),ux=e(E).rotateRightFacingSymbol("up").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_bottom").build(),vx=e(E).rotateRightFacingSymbol("up").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_bottom").build(),Yt={paths:{path11:{type:"path",points:[{x:-.52,y:.03},{x:-.18,y:.04}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.19,y:.04},{x:.52,y:.04}],color:"primary",fill:!1},"path11-0-9":{type:"path",points:[{x:-.31,y:.2},{x:-.31,y:-.11},{x:-.01,y:.04},{x:-.3,y:.2}],color:"primary",fill:!0},"path11-0-9-5":{type:"path",points:[{x:.33,y:.2},{x:.33,y:-.1},{x:.04,y:.04},{x:.33,y:.2}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:.04,y:.32},bottom1:{type:"text",text:"{VAL}",x:.04,y:-.32}},refblocks:{left1:{x:-.52,y:.03},right1:{x:.52,y:.04}},bounds:{minX:-.55,maxX:.55,minY:-.32,maxY:.32,width:1.09,height:.63,centerX:0,centerY:0},circles:{}},{paths:D6,texts:G6,bounds:U6,refblocks:W6,circles:H6}=Yt,wx=e(Yt).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),Ax=e(Yt).rotateRightFacingSymbol("down").changeTextAnchor("{VAL}","middle_right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").build(),Px={paths:{path45:{type:"path",points:[{x:.14,y:0},{x:-.13,y:-.14}],color:"primary",fill:!1},"path1-8":{type:"path",points:[{x:.13,y:0},{x:.3,y:0}],color:"primary",fill:!1},path46:{type:"path",points:[{x:-.13,y:.13},{x:.14,y:0}],color:"primary",fill:!1},path47:{type:"path",points:[{x:-.13,y:-.14},{x:-.13,y:.13}],color:"primary",fill:!1},path48:{type:"path",points:[{x:.14,y:.13},{x:.14,y:-.14}],color:"primary",fill:!1},path49:{type:"path",points:[{x:-.13,y:0},{x:-.3,y:0}],color:"primary",fill:!1},path25:{type:"path",points:[{x:.16,y:.29},{x:.25,y:.3},{x:.22,y:.21}],color:"primary",fill:!0},path78:{type:"path",points:[{x:.08,y:.17},{x:.09,y:.17},{x:.21,y:.27},{x:.21,y:.27}],color:"primary",fill:!1},"path25-0":{type:"path",points:[{x:-.02,y:.31},{x:.08,y:.32},{x:.04,y:.23}],color:"primary",fill:!0},"path78-6":{type:"path",points:[{x:-.1,y:.19},{x:-.09,y:.2},{x:.04,y:.29},{x:.04,y:.29}],color:"primary",fill:!1},box:{type:"path",points:[{x:-.3,y:-.4},{x:.3,y:-.4},{x:.3,y:.4},{x:-.3,y:.4},{x:-.3,y:-.4},{x:-.3,y:.4}],color:"primary",fill:!1},"path48-1":{type:"path",points:[{x:-.3,y:.13},{x:-.54,y:.13}],color:"primary",fill:!1},"path48-2":{type:"path",points:[{x:-.3,y:-.13},{x:-.54,y:-.13}],color:"primary",fill:!1},"path48-3":{type:"path",points:[{x:.3,y:-.13},{x:.54,y:-.13}],color:"primary",fill:!1},"path48-4":{type:"path",points:[{x:.3,y:.13},{x:.54,y:.13}],color:"primary",fill:!1}},texts:{bottom1:{type:"text",text:"{VAL}",x:0,y:-.43},right1:{type:"text",text:"{REF}",x:0,y:.43}},refblocks:{left1:{x:-.54,y:.13},left2:{x:-.54,y:-.13},right1:{x:.54,y:-.13},right2:{x:.54,y:.13}},bounds:{minX:-.56,maxX:.56,minY:-.32,maxY:.32,width:1.13,height:.65,centerX:0,centerY:0},circles:{}},D=e(Px).labelPort("left1",["1","DIN"]).labelPort("left2",["2","POWER"]).labelPort("right1",["3","GND"]).labelPort("right2",["4","DOUT"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),Sx=r(D,"down"),Rx=Y(D),mo=r(D,"up"),no=mo.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),fo=mo.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");no.anchor="middle_left";fo.anchor="middle_left";no.y+=.21;no.x=.44;fo.y-=.21;fo.x=.44;Fx=mo,Tx={paths:{path11:{type:"path",points:[{x:-.4,y:0},{x:-.01,y:0}],color:"primary",fill:!1},path40:{type:"path",points:[{x:.07,y:.19},{x:.07,y:-.18}],color:"primary",fill:!1},path42:{type:"path",points:[{x:.01,y:-.12},{x:.01,y:.14}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.28,y:-.25},{x:.28,y:-.56}],color:"primary",fill:!1},"path12-1":{type:"path",points:[{x:.28,y:.56},{x:.28,y:.27}],color:"primary",fill:!1},path15:{type:"path",points:[{x:.17,y:-.22},{x:.28,y:-.23},{x:.23,y:-.14}],color:"primary",fill:!0},path17:{type:"path",points:[{x:.08,y:-.09},{x:.23,y:-.2}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.07,y:.11},{x:.28,y:.26}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.01,y:.36},bottom1:{type:"text",text:"{VAL}",x:.02,y:-.42}},refblocks:{top1:{x:.28,y:.56},bottom1:{x:.28,y:-.56},left1:{x:-.4,y:0}},bounds:{minX:-.43,maxX:.43,minY:-.58,maxY:.58,width:.85,height:1.17,centerX:0,centerY:0},circles:{path1:{type:"circle",x:.14,y:.01,radius:.29,color:"primary",fill:!1}}},Ne=e(Tx).changeTextAnchor("{VAL}","middle_right").labelPort("left1",["3"]).labelPort("top1",["2"]).labelPort("bottom1",["1"]).changeTextAnchor("{REF}","middle_right").build(),co=r(Ne),ho=co.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),Ex=co.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");ho.anchor="middle_left";Ex.anchor="middle_right";ho.x=.45;ho.y+=.065;Ex.y+=.065;Yx=co,Xx={paths:{"path12-1-8-6-9":{type:"path",points:[{x:.02,y:-.02},{x:.02,y:-.1}],color:"primary",fill:!1},"path12-1-5-6":{type:"path",points:[{x:-.47,y:-.19},{x:-.17,y:-.19}],color:"primary",fill:!1},"path12-1-5-6-8":{type:"path",points:[{x:.02,y:.17},{x:.02,y:.11}],color:"primary",fill:!1},"path12-1-8-0":{type:"path",points:[{x:-.15,y:-.03},{x:.2,y:-.19}],color:"primary",fill:!1},"path12-1-0":{type:"path",points:[{x:.2,y:-.19},{x:.47,y:-.19}],color:"primary",fill:!1},"path12-1-8-6-9-4":{type:"path",points:[{x:.02,y:.12},{x:.02,y:.02}],color:"primary",fill:!1},"path12-1-8-6-9-4-3":{type:"path",points:[{x:.08,y:.11},{x:.08,y:.05}],color:"primary",fill:!1},"path12-1-8-6-9-4-3-1":{type:"path",points:[{x:-.04,y:.11},{x:-.04,y:.05}],color:"primary",fill:!1},"path12-1-8-6-9-4-4":{type:"path",points:[{x:.08,y:.11},{x:-.04,y:.11}],color:"primary",fill:!1},"path14-5":{type:"path",points:[{x:-.01,y:.28},{x:.01,y:.25},{x:.04,y:.23},{x:.06,y:.2}],color:"primary",fill:!0},"path14-5-3":{type:"path",points:[{x:-.01,y:.2},{x:.01,y:.23},{x:.04,y:.25},{x:.06,y:.28}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:.01,y:.38},bottom1:{type:"text",text:"{VAL}",x:.06,y:-.38}},refblocks:{left1:{x:-.47,y:-.19},right1:{x:.47,y:-.19}},bounds:{minX:-.5,maxX:.5,minY:-.38,maxY:.38,width:1,height:.76,centerX:0,centerY:0},circles:{path9:{type:"circle",x:.02,y:.24,radius:.06,color:"primary",fill:!1}}},Ie=e(Xx).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),Lx=r(Ie),Vx=Lx.primitives.filter(t5=>t5.type==="text"),bo=Vx.find(t5=>t5.text==="{VAL}");bo.x=-.35;bo.y=0;bo.anchor="middle_right";_o=Vx.find(t5=>t5.text==="{REF}");_o.y=0;_o.x=.35;_o.anchor="middle_left";jx=Lx,kx={paths:{path8698:{type:"path",points:[{x:-.2,y:-.02},{x:-.2,y:-.02},{x:-.21,y:-.01},{x:-.21,y:-.01},{x:-.21,y:0},{x:-.21,y:0},{x:-.21,y:0},{x:-.22,y:.01},{x:-.22,y:.01},{x:-.22,y:.02},{x:-.22,y:.02},{x:-.23,y:.03},{x:-.23,y:.03},{x:-.23,y:.03},{x:-.23,y:.04},{x:-.24,y:.04},{x:-.24,y:.04},{x:-.24,y:.05},{x:-.24,y:.05},{x:-.25,y:.05},{x:-.25,y:.06},{x:-.25,y:.06},{x:-.25,y:.06},{x:-.26,y:.06},{x:-.26,y:.06},{x:-.26,y:.07},{x:-.26,y:.07},{x:-.27,y:.07},{x:-.27,y:.07},{x:-.27,y:.07},{x:-.27,y:.07},{x:-.28,y:.07},{x:-.28,y:.07},{x:-.28,y:.07},{x:-.28,y:.07},{x:-.29,y:.07},{x:-.29,y:.08},{x:-.29,y:.08},{x:-.29,y:.08},{x:-.3,y:.08},{x:-.3,y:.08},{x:-.3,y:.08},{x:-.3,y:.08},{x:-.31,y:.08},{x:-.31,y:.08},{x:-.31,y:.07},{x:-.31,y:.07},{x:-.32,y:.07},{x:-.32,y:.07},{x:-.32,y:.07},{x:-.32,y:.07},{x:-.33,y:.07},{x:-.33,y:.07},{x:-.33,y:.07},{x:-.33,y:.07},{x:-.34,y:.07},{x:-.34,y:.06},{x:-.34,y:.06},{x:-.34,y:.06},{x:-.35,y:.06},{x:-.35,y:.06},{x:-.35,y:.05},{x:-.35,y:.05},{x:-.36,y:.05},{x:-.36,y:.04},{x:-.36,y:.04},{x:-.36,y:.04},{x:-.37,y:.03},{x:-.37,y:.03},{x:-.37,y:.03},{x:-.37,y:.02},{x:-.38,y:.02},{x:-.38,y:.01},{x:-.38,y:.01},{x:-.38,y:0},{x:-.39,y:0},{x:-.39,y:0},{x:-.39,y:-.01},{x:-.39,y:-.01},{x:-.4,y:-.02},{x:-.4,y:-.02}],color:"primary",fill:!1},path8700:{type:"path",points:[{x:0,y:-.02},{x:0,y:-.02},{x:-.01,y:-.01},{x:-.01,y:-.01},{x:-.01,y:0},{x:-.01,y:0},{x:-.02,y:0},{x:-.02,y:.01},{x:-.02,y:.01},{x:-.02,y:.02},{x:-.03,y:.02},{x:-.03,y:.03},{x:-.03,y:.03},{x:-.03,y:.03},{x:-.04,y:.04},{x:-.04,y:.04},{x:-.04,y:.04},{x:-.04,y:.05},{x:-.05,y:.05},{x:-.05,y:.05},{x:-.05,y:.06},{x:-.05,y:.06},{x:-.06,y:.06},{x:-.06,y:.06},{x:-.06,y:.06},{x:-.06,y:.07},{x:-.07,y:.07},{x:-.07,y:.07},{x:-.07,y:.07},{x:-.07,y:.07},{x:-.08,y:.07},{x:-.08,y:.07},{x:-.08,y:.07},{x:-.08,y:.07},{x:-.09,y:.07},{x:-.09,y:.07},{x:-.09,y:.08},{x:-.09,y:.08},{x:-.1,y:.08},{x:-.1,y:.08},{x:-.1,y:.08},{x:-.1,y:.08},{x:-.11,y:.08},{x:-.11,y:.08},{x:-.11,y:.08},{x:-.11,y:.07},{x:-.12,y:.07},{x:-.12,y:.07},{x:-.12,y:.07},{x:-.12,y:.07},{x:-.13,y:.07},{x:-.13,y:.07},{x:-.13,y:.07},{x:-.13,y:.07},{x:-.14,y:.07},{x:-.14,y:.07},{x:-.14,y:.06},{x:-.14,y:.06},{x:-.15,y:.06},{x:-.15,y:.06},{x:-.15,y:.06},{x:-.15,y:.05},{x:-.16,y:.05},{x:-.16,y:.05},{x:-.16,y:.04},{x:-.16,y:.04},{x:-.17,y:.04},{x:-.17,y:.03},{x:-.17,y:.03},{x:-.17,y:.03},{x:-.18,y:.02},{x:-.18,y:.02},{x:-.18,y:.01},{x:-.18,y:.01},{x:-.19,y:0},{x:-.19,y:0},{x:-.19,y:0},{x:-.19,y:-.01},{x:-.2,y:-.01},{x:-.2,y:-.02},{x:-.2,y:-.02}],color:"primary",fill:!1},path8702:{type:"path",points:[{x:.2,y:-.02},{x:.2,y:-.02},{x:.19,y:-.01},{x:.19,y:-.01},{x:.19,y:0},{x:.19,y:0},{x:.18,y:0},{x:.18,y:.01},{x:.18,y:.01},{x:.18,y:.02},{x:.17,y:.02},{x:.17,y:.03},{x:.17,y:.03},{x:.17,y:.03},{x:.16,y:.04},{x:.16,y:.04},{x:.16,y:.04},{x:.16,y:.05},{x:.15,y:.05},{x:.15,y:.05},{x:.15,y:.06},{x:.15,y:.06},{x:.14,y:.06},{x:.14,y:.06},{x:.14,y:.06},{x:.14,y:.07},{x:.13,y:.07},{x:.13,y:.07},{x:.13,y:.07},{x:.13,y:.07},{x:.12,y:.07},{x:.12,y:.07},{x:.12,y:.07},{x:.12,y:.07},{x:.11,y:.07},{x:.11,y:.07},{x:.11,y:.08},{x:.11,y:.08},{x:.1,y:.08},{x:.1,y:.08},{x:.1,y:.08},{x:.1,y:.08},{x:.09,y:.08},{x:.09,y:.08},{x:.09,y:.08},{x:.09,y:.07},{x:.08,y:.07},{x:.08,y:.07},{x:.08,y:.07},{x:.08,y:.07},{x:.07,y:.07},{x:.07,y:.07},{x:.07,y:.07},{x:.07,y:.07},{x:.06,y:.07},{x:.06,y:.07},{x:.06,y:.06},{x:.06,y:.06},{x:.05,y:.06},{x:.05,y:.06},{x:.05,y:.06},{x:.05,y:.05},{x:.04,y:.05},{x:.04,y:.05},{x:.04,y:.04},{x:.04,y:.04},{x:.03,y:.04},{x:.03,y:.03},{x:.03,y:.03},{x:.03,y:.03},{x:.02,y:.02},{x:.02,y:.02},{x:.02,y:.01},{x:.02,y:.01},{x:.01,y:0},{x:.01,y:0},{x:.01,y:0},{x:.01,y:-.01},{x:0,y:-.01},{x:0,y:-.02},{x:0,y:-.02}],color:"primary",fill:!1},path8704:{type:"path",points:[{x:.4,y:-.02},{x:.39,y:-.02},{x:.39,y:-.01},{x:.39,y:-.01},{x:.39,y:0},{x:.39,y:0},{x:.38,y:0},{x:.38,y:.01},{x:.38,y:.01},{x:.38,y:.02},{x:.37,y:.02},{x:.37,y:.03},{x:.37,y:.03},{x:.37,y:.03},{x:.36,y:.04},{x:.36,y:.04},{x:.36,y:.04},{x:.36,y:.05},{x:.35,y:.05},{x:.35,y:.05},{x:.35,y:.06},{x:.35,y:.06},{x:.34,y:.06},{x:.34,y:.06},{x:.34,y:.06},{x:.34,y:.07},{x:.33,y:.07},{x:.33,y:.07},{x:.33,y:.07},{x:.33,y:.07},{x:.32,y:.07},{x:.32,y:.07},{x:.32,y:.07},{x:.32,y:.07},{x:.31,y:.07},{x:.31,y:.07},{x:.31,y:.08},{x:.31,y:.08},{x:.3,y:.08},{x:.3,y:.08},{x:.3,y:.08},{x:.3,y:.08},{x:.29,y:.08},{x:.29,y:.08},{x:.29,y:.08},{x:.29,y:.07},{x:.28,y:.07},{x:.28,y:.07},{x:.28,y:.07},{x:.28,y:.07},{x:.27,y:.07},{x:.27,y:.07},{x:.27,y:.07},{x:.27,y:.07},{x:.26,y:.07},{x:.26,y:.07},{x:.26,y:.06},{x:.26,y:.06},{x:.25,y:.06},{x:.25,y:.06},{x:.25,y:.06},{x:.25,y:.05},{x:.24,y:.05},{x:.24,y:.05},{x:.24,y:.04},{x:.24,y:.04},{x:.23,y:.04},{x:.23,y:.03},{x:.23,y:.03},{x:.23,y:.03},{x:.22,y:.02},{x:.22,y:.02},{x:.22,y:.01},{x:.22,y:.01},{x:.21,y:0},{x:.21,y:0},{x:.21,y:0},{x:.21,y:-.01},{x:.2,y:-.01},{x:.2,y:-.02},{x:.2,y:-.02}],color:"primary",fill:!1},path8706:{type:"path",points:[{x:-.4,y:-.02},{x:-.55,y:-.02}],color:"primary",fill:!1},"path8706-5":{type:"path",points:[{x:.55,y:-.03},{x:.4,y:-.03}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:0,y:.23},bottom1:{type:"text",text:"{VAL}",x:0,y:-.23}},refblocks:{left1:{x:-.55,y:-.02},right1:{x:.55,y:-.03}},bounds:{minX:-.58,maxX:.58,minY:-.23,maxY:.23,width:1.16,height:.46,centerX:0,centerY:0},circles:{}},{paths:wd,texts:zx,bounds:Be,refblocks:Ox,circles:Ad}=kx,ut=s({primitives:[...Object.values(wd),...Object.values(Ad),{...zx.top1,anchor:"middle_bottom"},{...zx.bottom1,anchor:"middle_top"}],ports:[{...Ox.left1,labels:["1"]},{...Ox.right1,labels:["2"]}],size:{width:Be.width,height:Be.height},center:{x:Be.centerX,y:Be.centerY}}),qe=r(ut,"up"),Jx=v(qe),$x=Y(ut),go={paths:{path11:{type:"path",points:[{x:-.54,y:-.06},{x:-.15,y:-.06}],color:"primary",fill:!1},path40:{type:"path",points:[{x:.13,y:-.05},{x:-.13,y:-.18}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.13,y:.08},{x:.13,y:-.05}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.13,y:-.18},{x:-.13,y:.08}],color:"primary",fill:!1},path43:{type:"path",points:[{x:.13,y:.08},{x:.13,y:-.18}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.14,y:-.05},{x:.54,y:-.06}],color:"primary",fill:!1},"path25-0-9-8":{type:"path",points:[{x:-.03,y:.39},{x:-.05,y:.47},{x:-.08,y:.39}],color:"primary",fill:!0},"path78-6-5-5":{type:"path",points:[{x:-.05,y:.27},{x:-.05,y:.29},{x:-.05,y:.41},{x:-.05,y:.42}],color:"primary",fill:!1},"path25-0-9-8-2":{type:"path",points:[{x:.07,y:.39},{x:.04,y:.47},{x:.02,y:.39}],color:"primary",fill:!0},"path78-6-5-5-7":{type:"path",points:[{x:.04,y:.27},{x:.04,y:.29},{x:.04,y:.41},{x:.04,y:.42}],color:"primary",fill:!1},"path43-1":{type:"path",points:[{x:.03,y:.06},{x:.03,y:-.16}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:.38,y:.38},bottom1:{type:"text",text:"{VAL}",x:.38,y:-.47}},refblocks:{left1:{x:-.54,y:-.06},right1:{x:.54,y:-.06}},bounds:{minX:-.57,maxX:.57,minY:-.47,maxY:.47,width:1.14,height:.93,centerX:0,centerY:0},circles:{path1:{type:"circle",x:0,y:-.05,radius:.29,color:"primary",fill:!1}}};go.bounds.width+=.2;G=e(go).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),uo=r(G,"down"),vo=uo.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),wo=uo.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");vo.anchor="middle_left";wo.anchor="middle_left";vo.y+=.9;vo.x=.3;wo.y-=.1;wo.x=.3;Mx=uo,Ao=r(G,"left"),Po=Ao.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),So=Ao.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Po.anchor="middle_left";So.anchor="middle_left";Po.y+=.71;Po.x=.44;So.y-=.71;So.x=.44;Cx=Ao,Ro=r(G,"up"),Fo=Ro.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),To=Ro.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Fo.anchor="middle_left";To.anchor="middle_left";Fo.y+=.1;Fo.x=.3;To.y-=.71;To.x=.3;Nx=Ro,Ix={paths:{path45:{type:"path",points:[{x:.14,y:0},{x:-.13,y:-.14}],color:"primary",fill:!1},"path1-8":{type:"path",points:[{x:.13,y:0},{x:.54,y:0}],color:"primary",fill:!1},path46:{type:"path",points:[{x:-.13,y:.13},{x:.14,y:0}],color:"primary",fill:!1},path47:{type:"path",points:[{x:-.13,y:-.14},{x:-.13,y:.13}],color:"primary",fill:!1},path48:{type:"path",points:[{x:.14,y:.13},{x:.14,y:-.14}],color:"primary",fill:!1},path49:{type:"path",points:[{x:-.13,y:0},{x:-.54,y:0}],color:"primary",fill:!1},path25:{type:"path",points:[{x:.16,y:.29},{x:.25,y:.3},{x:.22,y:.21}],color:"primary",fill:!0},path78:{type:"path",points:[{x:.08,y:.17},{x:.09,y:.17},{x:.21,y:.27},{x:.21,y:.27}],color:"primary",fill:!1},"path25-0":{type:"path",points:[{x:-.02,y:.31},{x:.08,y:.32},{x:.04,y:.23}],color:"primary",fill:!0},"path78-6":{type:"path",points:[{x:-.1,y:.19},{x:-.09,y:.2},{x:.04,y:.29},{x:.04,y:.29}],color:"primary",fill:!1}},texts:{bottom1:{type:"text",text:"{VAL}",x:0,y:-.21},right1:{type:"text",text:"{REF}",x:0,y:.41}},refblocks:{left1:{x:-.54,y:0},right1:{x:.54,y:0}},bounds:{minX:-.56,maxX:.56,minY:-.32,maxY:.32,width:1.13,height:.65,centerX:0,centerY:0},circles:{}},{paths:Rd,texts:Bx,bounds:De,refblocks:qx,circles:Fd}=Ix,vt=s({primitives:[...Object.values(Rd),...Object.values(Fd),{...Bx.bottom1,anchor:"middle_top"},{...Bx.right1,anchor:"middle_bottom"}],ports:[{...qx.left1,labels:["1"]},{...qx.right1,labels:["2"]}],size:{width:De.width,height:De.height},center:{x:De.centerX,y:De.centerY}}),Eo=r(vt,"up"),Yo=Eo.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),Xo=Eo.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Yo.anchor="middle_left";Xo.anchor="middle_left";Yo.y+=.21;Yo.x=.21;Xo.y-=.21;Xo.x=.21;Ge=Eo,Lo=v(Ge),Vo=Lo.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),jo=Lo.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Vo.anchor="middle_left";jo.anchor="middle_left";Vo.y+=.4;Vo.x=.2;jo.y-=.41;jo.x=.2;Dx=Lo,Gx=Y(vt),Ux={paths:{path11:{type:"path",points:[{x:-.52,y:-.01},{x:-.18,y:-.01}],color:"primary",fill:!1},"path11-2":{type:"path",points:[{x:-.17,y:-.11},{x:-.17,y:.08}],color:"primary",fill:!1},"path11-5":{type:"path",points:[{x:-.17,y:-.12},{x:.16,y:-.12}],color:"primary",fill:!1},"path11-5-5":{type:"path",points:[{x:-.17,y:.08},{x:.16,y:.08}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.17,y:-.01},{x:.52,y:-.01}],color:"primary",fill:!1},"path11-2-1":{type:"path",points:[{x:.16,y:-.12},{x:.16,y:.08}],color:"primary",fill:!1},"path25-0-9":{type:"path",points:[{x:-.4,y:-.21},{x:-.33,y:-.18},{x:-.34,y:-.27}],color:"primary",fill:!0},"path78-6-5":{type:"path",points:[{x:-.45,y:-.34},{x:-.44,y:-.32},{x:-.35,y:-.22},{x:-.35,y:-.22}],color:"primary",fill:!1},"path25-0-9-0":{type:"path",points:[{x:-.3,y:-.34},{x:-.22,y:-.31},{x:-.24,y:-.4}],color:"primary",fill:!0},"path78-6-5-9":{type:"path",points:[{x:-.35,y:-.46},{x:-.34,y:-.45},{x:-.25,y:-.35},{x:-.25,y:-.35}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.17,y:-.41},bottom1:{type:"text",text:"{VAL}",x:-.01,y:.46}},refblocks:{left1:{x:-.52,y:-.01},right1:{x:.52,y:-.01}},bounds:{minX:-.55,maxX:.55,minY:-.51,maxY:.46,width:1.1,height:.62,centerX:0,centerY:-.02},circles:{path1:{type:"circle",x:0,y:-.02,radius:.28,color:"primary",fill:!1}}},{paths:Ed,texts:Wx,bounds:Ue,refblocks:Hx,circles:Yd}=Ux,We=s({primitives:[...Object.values(Ed),...Object.values(Yd),{...Wx.top1,anchor:"middle_left",x:0},{...Wx.bottom1,anchor:"middle_left",x:0}],ports:[{...Hx.left1,labels:["1"]},{...Hx.right1,labels:["2"]}],size:{width:Ue.width,height:Ue.height},center:{x:Ue.centerX,y:Ue.centerY}}),Zx=r(We),Qx=Zx.primitives.filter(t5=>t5.type==="text"),ko=Qx.find(t5=>t5.text==="{VAL}");ko.x=-.35;ko.y=0;ko.anchor="middle_right";zo=Qx.find(t5=>t5.text==="{REF}");zo.y=0;zo.x=.35;zo.anchor="middle_left";Kx=Zx,ts={paths:{path208:{type:"path",points:[{x:.38,y:.13},{x:.52,y:-.13}],color:"primary",fill:!1},path209:{type:"path",points:[{x:.25,y:-.13},{x:.38,y:.13}],color:"primary",fill:!1},path210:{type:"path",points:[{x:.52,y:-.13},{x:.25,y:-.13}],color:"primary",fill:!1},path211:{type:"path",points:[{x:.25,y:.13},{x:.52,y:.13}],color:"primary",fill:!1},path212:{type:"path",points:[{x:.12,y:-.4},{x:.38,y:-.4}],color:"primary",fill:!1},path213:{type:"path",points:[{x:.38,y:.4},{x:.12,y:.4}],color:"primary",fill:!1},path214:{type:"path",points:[{x:.12,y:.54},{x:.12,y:.18}],color:"primary",fill:!1},path215:{type:"path",points:[{x:.12,y:-.54},{x:.12,y:0}],color:"primary",fill:!1},path216:{type:"path",points:[{x:.38,y:-.4},{x:.38,y:.4}],color:"primary",fill:!1},path217:{type:"path",points:[{x:-.14,y:.26},{x:-.14,y:-.27}],color:"primary",fill:!1},path218:{type:"path",points:[{x:-.22,y:-.27},{x:-.22,y:.26}],color:"primary",fill:!1},path219:{type:"path",points:[{x:-.54,y:-.27},{x:-.22,y:-.27}],color:"primary",fill:!1},path220:{type:"path",points:[{x:-.14,y:-.19},{x:.12,y:-.19}],color:"primary",fill:!1},path221:{type:"path",points:[{x:-.14,y:.18},{x:.12,y:.18}],color:"primary",fill:!1},path222:{type:"path",points:[{x:-.07,y:0},{x:.12,y:0}],color:"primary",fill:!1}},texts:{right1:{type:"text",text:"{VAL}",x:.57,y:.02},right2:{type:"text",text:"{REF}",x:.57,y:.21}},refblocks:{top1:{x:.12,y:.54},bottom1:{x:.12,y:-.54},left1:{x:-.54,y:-.27}},bounds:{minX:-.57,maxX:.57,minY:-.57,maxY:.57,width:1.14,height:1.14,centerX:0,centerY:0},circles:{}},{paths:Ld,texts:es,bounds:He,refblocks:Oo}=ts,Ze=s({primitives:[...Object.values(Ld),{...es.right1,anchor:"middle_left"},{...es.right2,anchor:"middle_left"}],ports:[{...Oo.top1,labels:["1"]},{...Oo.bottom1,labels:["2"]},{...Oo.left1,labels:["3"]}],size:{width:He.width+.4,height:He.height},center:{x:He.centerX+.2,y:He.centerY}}),Jo=r(Ze),rs=Jo.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),$o=Jo.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");rs.anchor="middle_top";$o.anchor="middle_top";rs.x=$o.x;$o.y+=.15;os=Jo,is={paths:{"path12-1-8-6-9":{type:"path",points:[{x:.01,y:.07},{x:.01,y:-.01}],color:"primary",fill:!1},"path12-1-5-6":{type:"path",points:[{x:-.47,y:-.09},{x:-.17,y:-.09}],color:"primary",fill:!1},"path12-1-8-0":{type:"path",points:[{x:-.16,y:-.01},{x:.17,y:-.01}],color:"primary",fill:!1},"path12-1-0":{type:"path",points:[{x:.2,y:-.09},{x:.47,y:-.09}],color:"primary",fill:!1},path2:{type:"path",points:[{x:-.1,y:.06},{x:-.1,y:.06},{x:-.1,y:.07},{x:-.1,y:.07},{x:-.1,y:.07},{x:-.1,y:.08},{x:-.1,y:.08},{x:-.1,y:.08},{x:-.1,y:.09},{x:-.09,y:.09},{x:-.09,y:.09},{x:-.09,y:.1},{x:-.09,y:.1},{x:-.09,y:.1},{x:-.09,y:.1},{x:-.09,y:.11},{x:-.09,y:.11},{x:-.08,y:.11},{x:-.08,y:.12},{x:-.08,y:.12},{x:-.08,y:.12},{x:-.08,y:.12},{x:-.07,y:.13},{x:-.07,y:.13},{x:-.07,y:.13},{x:-.07,y:.13},{x:-.06,y:.14},{x:-.06,y:.14},{x:-.06,y:.14},{x:-.06,y:.14},{x:-.05,y:.14},{x:-.05,y:.15},{x:-.05,y:.15},{x:-.04,y:.15},{x:-.04,y:.15},{x:-.04,y:.15},{x:-.04,y:.15},{x:-.03,y:.16},{x:-.03,y:.16},{x:-.03,y:.16},{x:-.02,y:.16},{x:-.02,y:.16},{x:-.02,y:.16},{x:-.01,y:.16},{x:-.01,y:.16},{x:0,y:.16},{x:0,y:.16},{x:0,y:.16},{x:.01,y:.16},{x:.01,y:.16},{x:.01,y:.16},{x:.02,y:.16},{x:.02,y:.16},{x:.02,y:.16},{x:.03,y:.16},{x:.03,y:.16},{x:.03,y:.16},{x:.04,y:.16},{x:.04,y:.16},{x:.04,y:.16},{x:.05,y:.15},{x:.05,y:.15},{x:.05,y:.15},{x:.06,y:.15},{x:.06,y:.15},{x:.06,y:.15},{x:.06,y:.14},{x:.07,y:.14},{x:.07,y:.14},{x:.07,y:.14},{x:.08,y:.14},{x:.08,y:.13},{x:.08,y:.13},{x:.08,y:.13},{x:.09,y:.13},{x:.09,y:.12},{x:.09,y:.12},{x:.09,y:.12},{x:.09,y:.12},{x:.1,y:.11},{x:.1,y:.11},{x:.1,y:.1},{x:.1,y:.1},{x:.11,y:.09},{x:.11,y:.09},{x:.11,y:.09},{x:.11,y:.08},{x:.11,y:.08},{x:.11,y:.08},{x:.11,y:.07},{x:.11,y:.07},{x:.11,y:.07},{x:.11,y:.06},{x:.11,y:.06},{x:.1,y:.06},{x:.1,y:.06},{x:.09,y:.06},{x:.09,y:.06},{x:.08,y:.06},{x:.07,y:.06},{x:.07,y:.06},{x:.06,y:.06},{x:.05,y:.06},{x:.05,y:.06},{x:.04,y:.06},{x:.03,y:.06},{x:.03,y:.06},{x:.02,y:.06},{x:.01,y:.06},{x:.01,y:.06},{x:0,y:.06},{x:-.01,y:.06},{x:-.01,y:.06},{x:-.02,y:.06},{x:-.03,y:.06},{x:-.03,y:.06},{x:-.04,y:.06},{x:-.05,y:.06},{x:-.05,y:.06},{x:-.06,y:.06},{x:-.07,y:.06},{x:-.07,y:.06},{x:-.08,y:.06},{x:-.09,y:.06},{x:-.09,y:.06}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:.01,y:.27},bottom1:{type:"text",text:"{VAL}",x:-.16,y:-.27}},refblocks:{left1:{x:-.47,y:-.09},right1:{x:.47,y:-.09}},bounds:{minX:-.5,maxX:.5,minY:-.27,maxY:.27,width:1,height:.53,centerX:0,centerY:0},circles:{}},{paths:jd,texts:ls,bounds:Qe,refblocks:ps,circles:kd}=is,Ke=s({primitives:[...Object.values(jd),...Object.values(kd),{...ls.top1,anchor:"middle_bottom",x:0},{...ls.bottom1,anchor:"middle_top",x:0}],ports:[{...ps.left1,labels:["1"]},{...ps.right1,labels:["2"]}],size:{width:Qe.width,height:Qe.height},center:{x:Qe.centerX+.006,y:Qe.centerY+.06}}),Mo=r(Ke),Xt=Mo.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),t0=Mo.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Xt.anchor="middle_left";t0.anchor="middle_right";Xt.x=Xt.x-.03;Xt.y=Xt.y;t0.x=t0.x;t0.y=0;as=Mo,ys={paths:{path11:{type:"path",points:[{x:-.42,y:-.1},{x:.05,y:-.11}],color:"primary",fill:!1},path40:{type:"path",points:[{x:.09,y:.19},{x:.09,y:-.18}],color:"primary",fill:!1},"path12-1":{type:"path",points:[{x:.3,y:.55},{x:.3,y:.11}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:.31,y:-.55},{x:.31,y:-.01}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.09,y:.11},{x:.31,y:.11}],color:"primary",fill:!1},"path2-5":{type:"path",points:[{x:.09,y:-.1},{x:.31,y:-.1}],color:"primary",fill:!1},path15:{type:"path",points:[{x:.27,y:-.04},{x:.27,y:.03},{x:.2,y:0},{x:.27,y:-.04}],color:"primary",fill:!0},"path2-0":{type:"path",points:[{x:.09,y:0},{x:.31,y:-.01}],color:"primary",fill:!1},"path12-1-0":{type:"path",points:[{x:.05,y:.17},{x:.05,y:-.11}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.13,y:.36},bottom1:{type:"text",text:"{VAL}",x:.06,y:-.42}},refblocks:{top1:{x:.3,y:.55},bottom1:{x:.31,y:-.55},left1:{x:-.42,y:-.1}},bounds:{minX:-.45,maxX:.45,minY:-.58,maxY:.58,width:.89,height:1.16,centerX:0,centerY:0},circles:{path1:{type:"circle",x:.16,y:0,radius:.29,color:"primary",fill:!1}}},{paths:Od,texts:xs,bounds:e0,refblocks:Co,circles:Jd}=ys,r0=s({primitives:[...Object.values(Od),...Object.values(Jd),{...xs.top1,anchor:"middle_right",x:0},{...xs.bottom1,anchor:"middle_right",x:0}],ports:[{...Co.top1,labels:["1","drain"]},{...Co.bottom1,labels:["2","source"]},{...Co.left1,labels:["3","gate"]}],size:{width:e0.width,height:e0.height},center:{x:e0.centerX,y:e0.centerY}}),ss=r(r0),ms2=ss.primitives.filter(t5=>t5.type==="text"),No=ms2.find(t5=>t5.text==="{VAL}");No.x=-.35;No.y=0;No.anchor="middle_right";Io=ms2.find(t5=>t5.text==="{REF}");Io.y=0;Io.x=.35;Io.anchor="middle_left";ns=ss,fs={paths:{path11:{type:"path",points:[{x:-.42,y:-.1},{x:.05,y:-.11}],color:"primary",fill:!1},"path12-1":{type:"path",points:[{x:.3,y:.55},{x:.3,y:.11}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:.31,y:-.55},{x:.31,y:-.01}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.09,y:.11},{x:.31,y:.11}],color:"primary",fill:!1},"path2-8-3-7":{type:"path",points:[{x:.09,y:.15},{x:.09,y:.07}],color:"primary",fill:!1},"path2-5":{type:"path",points:[{x:.09,y:-.1},{x:.31,y:-.1}],color:"primary",fill:!1},"path2-8-3":{type:"path",points:[{x:.09,y:-.08},{x:.09,y:-.15}],color:"primary",fill:!1},"path2-8-3-2":{type:"path",points:[{x:.09,y:.03},{x:.09,y:-.04}],color:"primary",fill:!1},path15:{type:"path",points:[{x:.27,y:-.04},{x:.27,y:.03},{x:.2,y:0},{x:.27,y:-.04}],color:"primary",fill:!0},"path2-0":{type:"path",points:[{x:.09,y:0},{x:.31,y:-.01}],color:"primary",fill:!1},"path12-1-0":{type:"path",points:[{x:.05,y:.11},{x:.05,y:-.11}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.13,y:.36},bottom1:{type:"text",text:"{VAL}",x:.06,y:-.42}},refblocks:{top1:{x:.3,y:.55},bottom1:{x:.31,y:-.55},left1:{x:-.42,y:-.1}},bounds:{minX:-.45,maxX:.45,minY:-.58,maxY:.58,width:.89,height:1.16,centerX:0,centerY:0},circles:{path1:{type:"circle",x:.16,y:0,radius:.29,color:"primary",fill:!1}}},{paths:Md,texts:cs,bounds:o0,refblocks:Bo,circles:Cd}=fs,i0=s({primitives:[...Object.values(Md),...Object.values(Cd),{...cs.top1,anchor:"middle_right",x:0},{...cs.bottom1,anchor:"middle_right",x:0}],ports:[{...Bo.top1,labels:["1","drain"]},{...Bo.bottom1,labels:["2","source"]},{...Bo.left1,labels:["3","gate"]}],size:{width:o0.width,height:o0.height},center:{x:o0.centerX,y:o0.centerY}}),hs=r(i0),ds=hs.primitives.filter(t5=>t5.type==="text"),qo=ds.find(t5=>t5.text==="{VAL}");qo.x=-.35;qo.y=0;qo.anchor="middle_right";Do=ds.find(t5=>t5.text==="{REF}");Do.y=0;Do.x=.35;Do.anchor="middle_left";bs=hs,_s={paths:{path11:{type:"path",points:[{x:-.4,y:0},{x:.06,y:-.01}],color:"primary",fill:!1},path40:{type:"path",points:[{x:.07,y:.19},{x:.07,y:-.18}],color:"primary",fill:!1},"path12-1":{type:"path",points:[{x:.28,y:.55},{x:.28,y:.11}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:.29,y:-.55},{x:.29,y:-.1}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.07,y:.11},{x:.29,y:.11}],color:"primary",fill:!1},"path2-5":{type:"path",points:[{x:.07,y:-.1},{x:.29,y:-.1}],color:"primary",fill:!1},path15:{type:"path",points:[{x:-.08,y:.06},{x:-.08,y:-.07},{x:.01,y:0},{x:-.08,y:.06}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:-.15,y:.36},bottom1:{type:"text",text:"{VAL}",x:.04,y:-.42}},refblocks:{top1:{x:.28,y:.55},bottom1:{x:.29,y:-.55},left1:{x:-.4,y:0}},bounds:{minX:-.43,maxX:.43,minY:-.58,maxY:.58,width:.85,height:1.16,centerX:0,centerY:0},circles:{path1:{type:"circle",x:.14,y:0,radius:.29,color:"primary",fill:!1}}},{paths:Id,texts:gs,bounds:l0,refblocks:Go,circles:Bd}=_s,p0=s({primitives:[...Object.values(Id),...Object.values(Bd),{...gs.top1,anchor:"middle_right",x:0},{...gs.bottom1,anchor:"middle_right",x:0}],ports:[{...Go.top1,labels:["1","drain"]},{...Go.bottom1,labels:["2","source"]},{...Go.left1,labels:["3","gate"]}],size:{width:l0.width,height:l0.height},center:{x:l0.centerX,y:l0.centerY}}),us=r(p0),vs=us.primitives.filter(t5=>t5.type==="text"),Uo=vs.find(t5=>t5.text==="{VAL}");Uo.x=-.35;Uo.y=0;Uo.anchor="middle_right";Wo=vs.find(t5=>t5.text==="{REF}");Wo.y=0;Wo.x=.35;Wo.anchor="middle_left";ws=us,As={paths:{diag1:{type:"path",points:[{x:-.1,y:-.1},{x:.1,y:.1}],color:"primary",fill:!1},diag2:{type:"path",points:[{x:-.1,y:.1},{x:.1,y:-.1}],color:"primary",fill:!1},stem:{type:"path",points:[{x:-.2,y:0},{x:0,y:0}],color:"primary",fill:!1}},texts:{},refblocks:{left1:{x:-.2,y:0}},bounds:{minX:-.19,maxX:.2,minY:-.12,maxY:.12,width:.39,height:.24,centerX:0,centerY:0},circles:{}},{paths:Dd,bounds:Ps,refblocks:Gd}=As,U=e({primitives:[...Object.values(Dd)],ports:[{...Gd.left1,labels:["1"]}],center:{x:Ps.centerX,y:Ps.centerY}}).rotateRightFacingSymbol("right").labelPort("left1",["1"]).build(),Ss=r(U,"down"),Rs=r(U,"left"),Fs=r(U,"up"),g={paths:{path11:{type:"path",points:[{x:-.4,y:0},{x:.06,y:-.01}],color:"primary",fill:!1},"path40-0":{type:"path",points:[{x:.07,y:.27},{x:.07,y:-.28}],color:"primary",fill:!1},"path40-0-5":{type:"path",points:[{x:.28,y:.24},{x:.08,y:.11}],color:"primary",fill:!1},"path40-0-5-0":{type:"path",points:[{x:.29,y:-.24},{x:.09,y:-.11}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:.29,y:.25},{x:.29,y:.55}],color:"primary",fill:!1},"path12-1-5-3":{type:"path",points:[{x:.29,y:-.55},{x:.29,y:-.25}],color:"primary",fill:!1},path15:{type:"path",points:[{x:.19,y:-.1},{x:.12,y:-.2},{x:.22,y:-.2},{x:.19,y:-.1}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:-.08,y:.36},bottom1:{type:"text",text:"{VAL}",x:-.07,y:-.41}},refblocks:{top1:{x:.29,y:.55},bottom1:{x:.29,y:-.55},left1:{x:-.4,y:0}},bounds:{minX:-.43,maxX:.43,minY:-.58,maxY:.58,width:.85,height:1.16,centerX:0,centerY:0},circles:{"path1-0":{type:"circle",x:.14,y:0,radius:.29,color:"primary",fill:!1}}},{paths:Wd,texts:gP,bounds:a0,refblocks:Ho,circles:Hd}=g,Ts=e({primitives:[...Object.values(Wd),...Object.values(Hd),{type:"text",text:"{REF}",x:-.1,y:.3094553499999995},{type:"text",text:"{VAL}",x:-.1,y:-.3094553499999995}],ports:[{...Ho.top1,labels:["1","collector"]},{...Ho.bottom1,labels:["2","emitter"]},{...Ho.left1,labels:["3","base"]}],size:{width:a0.width,height:a0.height},center:{x:a0.centerX,y:a0.centerY}}).rotateRightFacingSymbol("right").changeTextAnchor("{REF}","middle_right").changeTextAnchor("{VAL}","middle_right").build(),{paths:AP,texts:PP,bounds:SP,refblocks:RP,circles:FP}=g,Es=e(g).rotateRightFacingSymbol("up").changeTextAnchor("{VAL}","middle_left").labelPort("left1",["3","base"]).labelPort("top1",["1","collector"]).labelPort("bottom1",["2","emitter"]).changeTextAnchor("{REF}","middle_right").build(),{paths:Zd,texts:XP,bounds:y0,refblocks:Zo,circles:Qd}=g,Ys=e({primitives:[...Object.values(Zd),...Object.values(Qd),{type:"text",text:"{REF}",x:-.1,y:-.3094553499999995},{type:"text",text:"{VAL}",x:-.1,y:.3094553499999995}],ports:[{...Zo.top1,labels:["1","collector"]},{...Zo.bottom1,labels:["2","emitter"]},{...Zo.left1,labels:["3","base"]}],size:{width:y0.width,height:y0.height},center:{x:y0.centerX,y:y0.centerY}}).rotateRightFacingSymbol("down").changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_bottom").build(),{paths:Kd,texts:kP,bounds:x0,refblocks:Qo,circles:t2}=g,Xs=e({primitives:[...Object.values(Kd),...Object.values(t2),{type:"text",text:"{REF}",x:-.1,y:-.3094553499999995},{type:"text",text:"{VAL}",x:-.1,y:.3094553499999995}],ports:[{...Qo.top1,labels:["1","collector"]},{...Qo.bottom1,labels:["2","emitter"]},{...Qo.left1,labels:["3","base"]}],size:{width:x0.width,height:x0.height},center:{x:x0.centerX,y:x0.centerY}}).rotateRightFacingSymbol("up").changeTextAnchor("{REF}","middle_top").changeTextAnchor("{VAL}","middle_top").build(),{paths:e2,texts:$P,bounds:s0,refblocks:Ko,circles:r2}=g,Ls=e({primitives:[...Object.values(e2),...Object.values(r2),{type:"text",text:"{REF}",x:-.1,y:-.3094553499999995},{type:"text",text:"{VAL}",x:-.1,y:.3094553499999995}],ports:[{...Ko.top1,labels:["1","collector"]},{...Ko.bottom1,labels:["2","emitter"]},{...Ko.left1,labels:["3","base"]}],size:{width:s0.width,height:s0.height},center:{x:s0.centerX,y:s0.centerY}}).rotateRightFacingSymbol("left").changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:o2,texts:IP,bounds:m0,refblocks:ti,circles:i2}=g,Vs=e({primitives:[...Object.values(o2),...Object.values(i2),{type:"text",text:"{REF}",x:-.1,y:-.3094553499999995},{type:"text",text:"{VAL}",x:-.1,y:.3094553499999995}],ports:[{...ti.top1,labels:["1","collector"]},{...ti.bottom1,labels:["2","emitter"]},{...ti.left1,labels:["3","base"]}],size:{width:m0.width,height:m0.height},center:{x:m0.centerX,y:m0.centerY}}).rotateRightFacingSymbol("left").changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),js={paths:{path40:{type:"path",points:[{x:.14,y:.04},{x:-.32,y:-.21}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.32,y:.31},{x:.14,y:.04}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.32,y:-.21},{x:-.32,y:.31}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.32,y:.18},{x:-.57,y:.18}],color:"primary",fill:!1},path45:{type:"path",points:[{x:-.32,y:-.09},{x:-.57,y:-.09}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.43,y:.04},{x:.15,y:.04}],color:"primary",fill:!1},"rect1577-3":{type:"path",points:[{x:-.19,y:-.09},{x:-.27,y:-.09}],color:"primary",fill:!0},"rect1577-4":{type:"path",points:[{x:-.19,y:.18},{x:-.27,y:.18}],color:"primary",fill:!0},"rect1577-4-7":{type:"path",points:[{x:-.23,y:.14},{x:-.23,y:.22}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:-.01,y:.42},bottom1:{type:"text",text:"{VAL}",x:0,y:-.3}},refblocks:{left1:{x:-.57,y:.18},left2:{x:-.57,y:-.09},right1:{x:.43,y:.04}},bounds:{minX:-.55,maxX:.55,minY:-.38,maxY:.27,width:1.09,height:.3,centerX:0,centerY:.05},circles:{}},W=e(js).labelPort("left1",["1","inp1"]).labelPort("left2",["2","inp2"]).labelPort("right1",["3","out"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),ks=r(W,"down"),zs=v(r(W,"left")),Os=r(W,"up"),Js={paths:{path40:{type:"path",points:[{x:.14,y:.04},{x:-.32,y:-.21}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.32,y:.31},{x:.14,y:.04}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.32,y:-.21},{x:-.32,y:.31}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.32,y:.18},{x:-.57,y:.18}],color:"primary",fill:!1},path45:{type:"path",points:[{x:-.32,y:-.09},{x:-.57,y:-.09}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.43,y:.04},{x:.15,y:.04}],color:"primary",fill:!1},"path44-1":{type:"path",points:[{x:-.1,y:.44},{x:-.1,y:.18}],color:"primary",fill:!1},"path44-2":{type:"path",points:[{x:-.09,y:-.34},{x:-.09,y:-.09}],color:"primary",fill:!1},"rect1577-3":{type:"path",points:[{x:-.19,y:.18},{x:-.27,y:.18}],color:"primary",fill:!0},"rect1577-4":{type:"path",points:[{x:-.19,y:-.09},{x:-.27,y:-.09}],color:"primary",fill:!0},"rect1577-4-7":{type:"path",points:[{x:-.23,y:.14},{x:-.23,y:.22}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:.25,y:.32},bottom1:{type:"text",text:"{VAL}",x:.25,y:-.24}},refblocks:{left1:{x:-.57,y:.18},left2:{x:-.57,y:-.09},right1:{x:.43,y:.04},top2:{x:-.1,y:.44},bottom1:{x:-.09,y:-.34}},bounds:{minX:-.55,maxX:.55,minY:-.38,maxY:.27,width:1.09,height:.3,centerX:0,centerY:.05},circles:{}},H=e(Js).labelPort("left1",["1","inp1"]).labelPort("left2",["2","inp2"]).labelPort("right1",["4","out"]).labelPort("top2",["5","V+"]).labelPort("bottom1",["3","V-"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),$s=r(H,"down"),Ms=v(r(H,"left")),Cs=r(H,"up"),Ns={paths:{path11:{type:"path",points:[{x:-.42,y:-.1},{x:.05,y:-.11}],color:"primary",fill:!1},path40:{type:"path",points:[{x:.09,y:.19},{x:.09,y:-.18}],color:"primary",fill:!1},"path12-1":{type:"path",points:[{x:.3,y:.55},{x:.3,y:.11}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:.31,y:-.55},{x:.31,y:-.01}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.09,y:.11},{x:.31,y:.11}],color:"primary",fill:!1},"path2-5":{type:"path",points:[{x:.09,y:-.1},{x:.31,y:-.1}],color:"primary",fill:!1},path15:{type:"path",points:[{x:.2,y:.03},{x:.2,y:-.04},{x:.27,y:-.01},{x:.2,y:.03}],color:"primary",fill:!0},"path2-0":{type:"path",points:[{x:.09,y:0},{x:.31,y:-.01}],color:"primary",fill:!1},"path12-1-0":{type:"path",points:[{x:.05,y:.17},{x:.05,y:-.11}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.13,y:.36},bottom1:{type:"text",text:"{VAL}",x:.06,y:-.42}},refblocks:{top1:{x:.3,y:.55},bottom1:{x:.31,y:-.55},left1:{x:-.42,y:-.1}},bounds:{minX:-.45,maxX:.45,minY:-.58,maxY:.58,width:.89,height:1.16,centerX:0,centerY:0},circles:{path1:{type:"circle",x:.16,y:0,radius:.29,color:"primary",fill:!1}}},{paths:y2,texts:Is,bounds:n0,refblocks:ei,circles:x2}=Ns,f0=s({primitives:[...Object.values(y2),...Object.values(x2),{...Is.top1,anchor:"middle_right",x:0},{...Is.bottom1,anchor:"middle_right",x:0}],ports:[{...ei.top1,labels:["1","drain"]},{...ei.bottom1,labels:["2","source"]},{...ei.left1,labels:["3","gate"]}],size:{width:n0.width,height:n0.height},center:{x:n0.centerX,y:n0.centerY}}),Bs=r(f0),qs=Bs.primitives.filter(t5=>t5.type==="text"),ri=qs.find(t5=>t5.text==="{VAL}");ri.x=-.35;ri.y=0;ri.anchor="middle_right";oi=qs.find(t5=>t5.text==="{REF}");oi.y=0;oi.x=.35;oi.anchor="middle_left";Ds=Bs,Gs={paths:{path11:{type:"path",points:[{x:-.42,y:-.1},{x:.05,y:-.11}],color:"primary",fill:!1},"path12-1":{type:"path",points:[{x:.3,y:.55},{x:.3,y:.11}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:.31,y:-.55},{x:.31,y:-.01}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.09,y:.11},{x:.31,y:.11}],color:"primary",fill:!1},"path2-8-3-7":{type:"path",points:[{x:.09,y:.15},{x:.09,y:.07}],color:"primary",fill:!1},"path2-5":{type:"path",points:[{x:.09,y:-.1},{x:.31,y:-.1}],color:"primary",fill:!1},"path2-8-3":{type:"path",points:[{x:.09,y:-.08},{x:.09,y:-.15}],color:"primary",fill:!1},"path2-8-3-2":{type:"path",points:[{x:.09,y:.03},{x:.09,y:-.04}],color:"primary",fill:!1},path15:{type:"path",points:[{x:.2,y:.03},{x:.2,y:-.04},{x:.27,y:-.01},{x:.2,y:.03}],color:"primary",fill:!0},"path2-0":{type:"path",points:[{x:.09,y:0},{x:.31,y:-.01}],color:"primary",fill:!1},"path12-1-0":{type:"path",points:[{x:.05,y:.11},{x:.05,y:-.11}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.13,y:.36},bottom1:{type:"text",text:"{VAL}",x:.06,y:-.42}},refblocks:{top1:{x:.3,y:.55},bottom1:{x:.31,y:-.55},left1:{x:-.42,y:-.1}},bounds:{minX:-.45,maxX:.45,minY:-.58,maxY:.58,width:.89,height:1.16,centerX:0,centerY:0},circles:{path1:{type:"circle",x:.16,y:0,radius:.29,color:"primary",fill:!1}}},{paths:m2,texts:Us,bounds:c0,refblocks:ii,circles:n2}=Gs,h0=s({primitives:[...Object.values(m2),...Object.values(n2),{...Us.top1,anchor:"middle_right",x:0},{...Us.bottom1,anchor:"middle_right",x:0}],ports:[{...ii.top1,labels:["1","drain"]},{...ii.bottom1,labels:["2","source"]},{...ii.left1,labels:["3","gate"]}],size:{width:c0.width,height:c0.height},center:{x:c0.centerX,y:c0.centerY}}),Ws=r(h0),Hs=Ws.primitives.filter(t5=>t5.type==="text"),li=Hs.find(t5=>t5.text==="{VAL}");li.x=-.35;li.y=0;li.anchor="middle_right";pi=Hs.find(t5=>t5.text==="{REF}");pi.y=0;pi.x=.35;pi.anchor="middle_left";Zs=Ws,Qs={paths:{path11:{type:"path",points:[{x:-.54,y:-.01},{x:-.15,y:-.02}],color:"primary",fill:!1},path40:{type:"path",points:[{x:.13,y:0},{x:-.13,y:-.13}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.13,y:.13},{x:.13,y:0}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.13,y:-.13},{x:-.13,y:.13}],color:"primary",fill:!1},path43:{type:"path",points:[{x:.13,y:.13},{x:.13,y:-.13}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.14,y:0},{x:.54,y:-.01}],color:"primary",fill:!1},"path25-0":{type:"path",points:[{x:.2,y:.38},{x:.16,y:.28},{x:.26,y:.3}],color:"primary",fill:!0},"path78-6":{type:"path",points:[{x:.33,y:.43},{x:.32,y:.42},{x:.21,y:.31},{x:.21,y:.31}],color:"primary",fill:!1},"path25-0-9":{type:"path",points:[{x:.35,y:.35},{x:.31,y:.26},{x:.41,y:.27}],color:"primary",fill:!0},"path78-6-5":{type:"path",points:[{x:.48,y:.4},{x:.47,y:.39},{x:.35,y:.29},{x:.35,y:.29}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.1,y:.35},bottom1:{type:"text",text:"{VAL}",x:0,y:-.43}},refblocks:{left1:{x:-.54,y:-.01},right1:{x:.54,y:-.01}},bounds:{minX:-.57,maxX:.57,minY:-.43,maxY:.43,width:1.14,height:.85,centerX:0,centerY:0},circles:{path1:{type:"circle",x:0,y:-.01,radius:.29,color:"primary",fill:!1}}},d0=e(Qs).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),Ks=r(d0),c2=Ks.primitives.filter(t5=>t5.type==="text"),tm=c2.find(t5=>t5.text==="{REF}");tm.y=0;tm.anchor="middle_left";em=Ks,rm={paths:{path11:{type:"path",points:[{x:-.4,y:0},{x:.06,y:-.01}],color:"primary",fill:!1},path40:{type:"path",points:[{x:.07,y:.19},{x:.07,y:-.18}],color:"primary",fill:!1},"path12-1":{type:"path",points:[{x:.28,y:.55},{x:.28,y:.11}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:.29,y:-.55},{x:.29,y:-.1}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.07,y:.11},{x:.29,y:.11}],color:"primary",fill:!1},"path2-5":{type:"path",points:[{x:.07,y:-.1},{x:.29,y:-.1}],color:"primary",fill:!1},path15:{type:"path",points:[{x:.01,y:-.07},{x:.01,y:.06},{x:-.08,y:0},{x:.01,y:-.07}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:-.15,y:.36},bottom1:{type:"text",text:"{VAL}",x:.04,y:-.42}},refblocks:{top1:{x:.28,y:.55},bottom1:{x:.29,y:-.55},left1:{x:-.4,y:0}},bounds:{minX:-.43,maxX:.43,minY:-.58,maxY:.58,width:.85,height:1.16,centerX:0,centerY:0},circles:{path1:{type:"circle",x:.14,y:0,radius:.29,color:"primary",fill:!1}}},{paths:d2,texts:om,bounds:b0,refblocks:ai,circles:b2}=rm,_0=s({primitives:[...Object.values(d2),...Object.values(b2),{...om.top1,anchor:"middle_right",x:0},{...om.bottom1,anchor:"middle_right"}],ports:[{...ai.top1,labels:["1","drain"]},{...ai.bottom1,labels:["2","source"]},{...ai.left1,labels:["3","gate"]}],size:{width:b0.width,height:b0.height},center:{x:b0.centerX,y:b0.centerY}}),im=r(_0),lm=im.primitives.filter(t5=>t5.type==="text"),yi=lm.find(t5=>t5.text==="{VAL}");yi.x=-.35;yi.y=0;yi.anchor="middle_right";xi=lm.find(t5=>t5.text==="{REF}");xi.y=0;xi.x=.35;xi.anchor="middle_left";pm=im,u={paths:{path11:{type:"path",points:[{x:-.4,y:0},{x:.06,y:-.01}],color:"primary",fill:!1},"path40-0":{type:"path",points:[{x:.07,y:.27},{x:.07,y:-.28}],color:"primary",fill:!1},"path40-0-5":{type:"path",points:[{x:.28,y:.24},{x:.08,y:.11}],color:"primary",fill:!1},"path40-0-5-0":{type:"path",points:[{x:.29,y:-.24},{x:.09,y:-.11}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:.29,y:.25},{x:.29,y:.55}],color:"primary",fill:!1},"path12-1-5-3":{type:"path",points:[{x:.29,y:-.55},{x:.29,y:-.25}],color:"primary",fill:!1},path15:{type:"path",points:[{x:.15,y:-.23},{x:.22,y:-.12},{x:.12,y:-.12},{x:.15,y:-.23}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:-.08,y:.37},bottom1:{type:"text",text:"{VAL}",x:-.07,y:-.41}},refblocks:{top1:{x:.29,y:.55},bottom1:{x:.29,y:-.55},left1:{x:-.4,y:0}},bounds:{minX:-.43,maxX:.43,minY:-.58,maxY:.58,width:.85,height:1.16,centerX:0,centerY:0},circles:{"path1-0":{type:"circle",x:.14,y:0,radius:.29,color:"primary",fill:!1}}},{paths:g2,texts:US,bounds:g0,refblocks:si,circles:u2}=u,am=e({primitives:[...Object.values(g2),...Object.values(u2),{type:"text",text:"{REF}",x:-.1,y:.3094553499999995},{type:"text",text:"{VAL}",x:-.1,y:-.3094553499999995}],ports:[{...si.top1,labels:["1","collector"]},{...si.bottom1,labels:["2","emitter"]},{...si.left1,labels:["3","base"]}],size:{width:g0.width,height:g0.height},center:{x:g0.centerX,y:g0.centerY}}).rotateRightFacingSymbol("right").changeTextAnchor("{REF}","middle_right").changeTextAnchor("{VAL}","middle_right").build(),{paths:QS,texts:KS,bounds:tR,refblocks:eR,circles:rR}=u,ym=e(u).rotateRightFacingSymbol("up").changeTextAnchor("{VAL}","middle_left").labelPort("left1",["3","base"]).labelPort("top1",["1","collector"]).labelPort("bottom1",["2","emitter"]).changeTextAnchor("{REF}","middle_right").build(),{paths:v2,texts:pR,bounds:u0,refblocks:mi,circles:w2}=u,xm=e({primitives:[...Object.values(v2),...Object.values(w2),{type:"text",text:"{REF}",x:-.1,y:-.3094553499999995},{type:"text",text:"{VAL}",x:-.1,y:.3094553499999995}],ports:[{...mi.top1,labels:["1","collector"]},{...mi.bottom1,labels:["2","emitter"]},{...mi.left1,labels:["3","base"]}],size:{width:u0.width,height:u0.height},center:{x:u0.centerX,y:u0.centerY}}).rotateRightFacingSymbol("down").changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_bottom").build(),{paths:A2,texts:sR,bounds:v0,refblocks:ni,circles:P2}=u,sm=e({primitives:[...Object.values(A2),...Object.values(P2),{type:"text",text:"{REF}",x:-.1,y:-.3094553499999995},{type:"text",text:"{VAL}",x:-.1,y:.3094553499999995}],ports:[{...ni.top1,labels:["1","collector"]},{...ni.bottom1,labels:["2","emitter"]},{...ni.left1,labels:["3","base"]}],size:{width:v0.width,height:v0.height},center:{x:v0.centerX,y:v0.centerY}}).rotateRightFacingSymbol("up").changeTextAnchor("{REF}","middle_top").changeTextAnchor("{VAL}","middle_top").build(),{paths:S2,texts:cR,bounds:w0,refblocks:fi,circles:R2}=u,mm2=e({primitives:[...Object.values(S2),...Object.values(R2),{type:"text",text:"{REF}",x:-.1,y:-.3094553499999995},{type:"text",text:"{VAL}",x:-.1,y:.3094553499999995}],ports:[{...fi.top1,labels:["1","collector"]},{...fi.bottom1,labels:["2","emitter"]},{...fi.left1,labels:["3","base"]}],size:{width:w0.width,height:w0.height},center:{x:w0.centerX,y:w0.centerY}}).rotateRightFacingSymbol("left").changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:F2,texts:_R,bounds:A0,refblocks:ci,circles:T2}=u,nm=e({primitives:[...Object.values(F2),...Object.values(T2),{type:"text",text:"{REF}",x:-.1,y:-.3094553499999995},{type:"text",text:"{VAL}",x:-.1,y:.3094553499999995}],ports:[{...ci.top1,labels:["1","collector"]},{...ci.bottom1,labels:["2","emitter"]},{...ci.left1,labels:["3","base"]}],size:{width:A0.width,height:A0.height},center:{x:A0.centerX,y:A0.centerY}}).rotateRightFacingSymbol("left").changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),fm={paths:{path40:{type:"path",points:[{x:-.19,y:.33},{x:-.26,y:.14}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.38,y:.26},{x:-.19,y:.33}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.26,y:.14},{x:-.38,y:.26}],color:"primary",fill:!1},path43:{type:"path",points:[{x:-.26,y:.39},{x:-.13,y:.26}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.32,y:.2},{x:-.52,y:0}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:0,y:.52},{x:-.19,y:.33}],color:"primary",fill:!1},"path40-4":{type:"path",points:[{x:-.19,y:-.32},{x:-.38,y:-.26}],color:"primary",fill:!1},"path41-1":{type:"path",points:[{x:-.26,y:-.13},{x:-.19,y:-.32}],color:"primary",fill:!1},"path42-7":{type:"path",points:[{x:-.38,y:-.26},{x:-.26,y:-.13}],color:"primary",fill:!1},"path43-1":{type:"path",points:[{x:-.13,y:-.26},{x:-.26,y:-.39}],color:"primary",fill:!1},"path44-8":{type:"path",points:[{x:-.32,y:-.19},{x:-.51,y:-.01}],color:"primary",fill:!1},"path44-0-7":{type:"path",points:[{x:-.01,y:-.5},{x:-.19,y:-.32}],color:"primary",fill:!1},"path40-4-0":{type:"path",points:[{x:.32,y:.19},{x:.13,y:.26}],color:"primary",fill:!1},"path41-1-2":{type:"path",points:[{x:.26,y:.38},{x:.32,y:.19}],color:"primary",fill:!1},"path42-7-1":{type:"path",points:[{x:.13,y:.26},{x:.26,y:.38}],color:"primary",fill:!1},"path43-1-8":{type:"path",points:[{x:.39,y:.26},{x:.26,y:.13}],color:"primary",fill:!1},"path44-8-7":{type:"path",points:[{x:.2,y:.32},{x:.01,y:.51}],color:"primary",fill:!1},"path44-0-7-1":{type:"path",points:[{x:.52,y:0},{x:.32,y:.19}],color:"primary",fill:!1},"path40-4-8":{type:"path",points:[{x:.32,y:-.19},{x:.26,y:-.38}],color:"primary",fill:!1},"path41-1-4":{type:"path",points:[{x:.13,y:-.26},{x:.32,y:-.19}],color:"primary",fill:!1},"path42-7-0":{type:"path",points:[{x:.26,y:-.38},{x:.13,y:-.26}],color:"primary",fill:!1},"path43-1-0":{type:"path",points:[{x:.26,y:-.13},{x:.39,y:-.26}],color:"primary",fill:!1},"path44-8-9":{type:"path",points:[{x:.19,y:-.32},{x:0,y:-.52}],color:"primary",fill:!1},"path44-0-7-3":{type:"path",points:[{x:.5,y:-.01},{x:.32,y:-.19}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.29,y:.46},bottom1:{type:"text",text:"{VAL}",x:-.29,y:-.5}},refblocks:{top1:{x:0,y:.52},bottom1:{x:0,y:-.52},left1:{x:-.52,y:0},right1:{x:.52,y:0}},bounds:{minX:-.55,maxX:.55,minY:-.55,maxY:.55,width:1.09,height:1.09,centerX:0,centerY:0},circles:{}},{paths:Y2,texts:cm,bounds:P0,refblocks:hm}=fm,S0=s({primitives:[...Object.values(Y2),{...cm.bottom1,y:.35,anchor:"middle_top"},{...cm.top1,anchor:"middle_left"}],ports:[{...hm.left1,labels:["1"]},{...hm.right1,labels:["2"]}],size:{width:P0.width+.05,height:P0.height},center:{x:P0.centerX,y:P0.centerY}}),X2=r(S0),dm=X2,bm={paths:{path18:{type:"path",points:[{x:-.53,y:0},{x:-.27,y:0}],color:"primary",fill:!1},path19:{type:"path",points:[{x:.26,y:0},{x:.53,y:0}],color:"primary",fill:!1},path20:{type:"path",points:[{x:0,y:.13},{x:.26,y:.13},{x:.26,y:-.13},{x:-.27,y:-.13},{x:-.27,y:.13},{x:0,y:.13}],color:"primary",fill:!1},path23:{type:"path",points:[{x:.28,y:-.28},{x:.18,y:-.25},{x:.25,y:-.18}],color:"primary",fill:!0},path24:{type:"path",points:[{x:.29,y:-.29},{x:.25,y:-.17},{x:.16,y:-.26}],color:"primary",fill:!0},path26:{type:"path",points:[{x:-.3,y:.29},{x:.23,y:-.23}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:.06,y:.2},bottom1:{type:"text",text:"{VAL}",x:-.1,y:-.28}},refblocks:{left1:{x:-.53,y:0},right1:{x:.53,y:0}},bounds:{minX:-.56,maxX:.56,minY:-.29,maxY:.29,width:1.13,height:.58,centerX:0,centerY:0},circles:{}},{paths:V2,texts:_m,bounds:R0,refblocks:gm}=bm,Z=s({primitives:[...Object.values(V2),{..._m.bottom1,x:0,y:-.35,anchor:"middle_top"},{..._m.top1,x:0,y:.35,anchor:"middle_bottom"}],ports:[{...gm.left1,labels:["1"]},{...gm.right1,labels:["2"]}],size:{width:R0.width+.05,height:R0.height},center:{x:R0.centerX,y:R0.centerY}}),hi=r(Z,"down"),di=hi.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),bi=hi.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");di.anchor="middle_left";bi.anchor="middle_left";di.y+=.31;di.x=.34;bi.y-=.31;bi.x=.34;um=hi,_i=r(Z,"left"),gi=_i.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),ui=_i.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");gi.anchor="middle_bottom";ui.anchor="middle_top";gi.y+=.73;gi.x=0;ui.y-=.7;ui.x=0;vm=_i,vi=r(Z,"up"),wi=vi.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),Ai=vi.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");wi.anchor="middle_left";Ai.anchor="middle_left";wi.y+=.21;wi.x=.34;Ai.y-=.21;Ai.x=.34;wm=vi,Q={paths:{path1:{type:"path",points:[{x:-.42,y:0},{x:-.3,y:0}],color:"primary",fill:!1},"path1-2-1":{type:"path",points:[{x:-.3,y:0},{x:-.25,y:.1},{x:-.15,y:-.1},{x:-.05,y:.1},{x:.05,y:-.1},{x:.15,y:.1},{x:.25,y:-.1},{x:.3,y:0}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.3,y:0},{x:.42,y:0}],color:"primary",fill:!1},path3:{type:"path",points:[{x:0,y:-.17},{x:0,y:-.4}],color:"primary",fill:!1},path15:{type:"path",points:[{x:0,y:-.12},{x:.05,y:-.2},{x:-.05,y:-.2},{x:0,y:-.12}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:.3,y:.25},bottom1:{type:"text",text:"{VAL}",x:.3,y:-.25}},refblocks:{left:{x:-.42,y:0},right:{x:.42,y:0},bottom:{x:0,y:-.4}},bounds:{minX:-.42,maxX:.42,minY:-.2,maxY:.2,width:.84,height:.4,centerX:0,centerY:0},circles:{}},{paths:k2,texts:IR,bounds:F0,refblocks:Pi,circles:z2}=Q,Am=e({primitives:[...Object.values(k2),...Object.values(z2),{type:"text",text:"{REF}",x:-.15,y:.2394553499999995},{type:"text",text:"{VAL}",x:.15,y:.2394553499999995}],ports:[{...Pi.left,labels:["1"]},{...Pi.right,labels:["3"]},{...Pi.bottom,labels:["2"]}],size:{width:F0.width,height:F0.height},center:{x:F0.centerX,y:F0.centerY}}).rotateRightFacingSymbol("down").labelPort("left",["1"]).labelPort("right",["2"]).labelPort("bottom",["3"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:O2,texts:GR,bounds:T0,refblocks:Si,circles:J2}=Q,Pm=e({primitives:[...Object.values(O2),...Object.values(J2),{type:"text",text:"{REF}",x:-.3,y:-.3894553499999995},{type:"text",text:"{VAL}",x:-.3,y:.3194553499999995}],ports:[{...Si.left,labels:["1"]},{...Si.right,labels:["3"]},{...Si.bottom,labels:["2"]}],size:{width:T0.width,height:T0.height},center:{x:T0.centerX,y:T0.centerY}}).rotateRightFacingSymbol("left").labelPort("left",["1"]).labelPort("right",["2"]).labelPort("bottom",["3"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),Sm=e(Q).labelPort("left",["1"]).labelPort("right",["3"]).labelPort("bottom",["2"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),{paths:$2,texts:tF,bounds:E0,refblocks:Ri,circles:M2}=Q,Rm=e({primitives:[...Object.values($2),...Object.values(M2),{type:"text",text:"{REF}",x:.3,y:-.2894553499999995},{type:"text",text:"{VAL}",x:-.3,y:-.2894553499999995}],ports:[{...Ri.left,labels:["1"]},{...Ri.right,labels:["3"]},{...Ri.bottom,labels:["2"]}],size:{width:E0.width,height:E0.height},center:{x:E0.centerX,y:E0.centerY}}).rotateRightFacingSymbol("up").labelPort("left",["1"]).labelPort("right",["2"]).labelPort("bottom",["3"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),Fm={paths:{path11:{type:"path",points:[{x:-.54,y:.03},{x:-.3,y:.03}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:.03},{x:.54,y:.03}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.16,y:.4},bottom1:{type:"text",text:"{VAL}",x:0,y:-.4},left1:{type:"text",text:"COS \u03C6",x:-.15,y:.01}},refblocks:{left1:{x:-.54,y:.03},right1:{x:.54,y:.03}},bounds:{minX:-.57,maxX:.57,minY:-.4,maxY:.4,width:1.14,height:.79,centerX:0,centerY:0},circles:{path1:{type:"circle",x:0,y:.04,radius:.29,color:"primary",fill:!1}}},{paths:N2,texts:lF,bounds:Y0,refblocks:Tm,circles:I2}=Fm,X0=s({primitives:[...Object.values(N2),...Object.values(I2),{type:"text",text:"{REF}",x:-.15,y:-.42330070000000064,anchor:"middle_top"},{type:"text",text:"{VAL}",x:-.15,y:.42330070000000064,anchor:"middle_bottom"},{type:"text",text:"COS \u03C6",x:0,y:.014279000000000375,anchor:"center"}],ports:[{...Tm.left1,labels:["1"]},{...Tm.right1,labels:["2"]}],size:{width:Y0.width,height:Y0.height},center:{x:Y0.centerX,y:Y0.centerY}}),Em=r(X0),Fi=Em.primitives.filter(t5=>t5.type==="text"),Ti=Fi.find(t5=>t5.text==="{REF}"),Ei=Fi.find(t5=>t5.text==="{VAL}"),Yi=Fi.find(t5=>t5.text==="COS \u03C6");Ti.x=.35;Ti.y=0;Ti.anchor="middle_left";Ei.anchor="middle_right";Ei.x=-.35;Ei.y=0;Yi.x=0;Yi.y=0;Yi.anchor="center";Ym=Em,Xm={paths:{"path12-1-8-6-9-9":{type:"path",points:[{x:.01,y:.03},{x:.01,y:-.09}],color:"primary",fill:!1},"path12-1-5-6-4":{type:"path",points:[{x:-.47,y:-.05},{x:-.17,y:-.05}],color:"primary",fill:!1},"path12-1-8-0-0":{type:"path",points:[{x:-.16,y:-.09},{x:.18,y:-.09}],color:"primary",fill:!1},"path12-1-0-1":{type:"path",points:[{x:.2,y:-.05},{x:.47,y:-.05}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:.01,y:.22},bottom1:{type:"text",text:"{VAL}",x:-.16,y:-.22}},refblocks:{left1:{x:-.47,y:-.05},right1:{x:.47,y:-.05}},bounds:{minX:-.5,maxX:.5,minY:-.22,maxY:.22,width:1,height:.45,centerX:0,centerY:0},circles:{"circle-2":{type:"circle",x:-.14,y:-.05,radius:.02,color:"primary",fill:!1},circle:{type:"circle",x:.17,y:-.05,radius:.02,color:"primary",fill:!1}}},{paths:q2,texts:Lm,bounds:L0,refblocks:Vm,circles:D2}=Xm,V0=s({primitives:[...Object.values(q2),...Object.values(D2),{...Lm.top1,anchor:"middle_left"},{...Lm.bottom1,anchor:"middle_left"}],ports:[{...Vm.left1,labels:["1"]},{...Vm.right1,labels:["2"]}],size:{width:L0.width,height:L0.height},center:{x:L0.centerX,y:L0.centerY}}),jm=r(V0,"up"),km={paths:{"path12-1-8-6-9-9":{type:"path",points:[{x:-.05,y:.09},{x:-.05,y:.04}],color:"primary",fill:!1},"path12-1-8-7-9-9":{type:"path",points:[{x:-.05,y:.09},{x:.07,y:.09}],color:"primary",fill:!1},"path12-1-8-6-9-10":{type:"path",points:[{x:.07,y:.09},{x:.07,y:.04}],color:"primary",fill:!1},"path12-1-5-6-4":{type:"path",points:[{x:-.47,y:-.05},{x:-.17,y:-.05}],color:"primary",fill:!1},"path12-1-8-0-0":{type:"path",points:[{x:-.16,y:.04},{x:.18,y:.04}],color:"primary",fill:!1},"path12-1-0-1":{type:"path",points:[{x:.2,y:-.05},{x:.47,y:-.05}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:.01,y:.29},bottom1:{type:"text",text:"{VAL}",x:-.16,y:-.22}},refblocks:{left1:{x:-.47,y:-.05},right1:{x:.47,y:-.05}},bounds:{minX:-.5,maxX:.5,minY:-.22,maxY:.22,width:1,height:.45,centerX:0,centerY:0},circles:{"circle-2":{type:"circle",x:-.14,y:-.05,radius:.02,color:"primary",fill:!1},circle:{type:"circle",x:.17,y:-.05,radius:.02,color:"primary",fill:!1}}},{paths:U2,texts:zm,bounds:j0,refblocks:Om,circles:W2}=km,k0=s({primitives:[...Object.values(U2),...Object.values(W2),{...zm.top1,anchor:"middle_left"},{...zm.bottom1,anchor:"middle_left"}],ports:[{...Om.left1,labels:["1"]},{...Om.right1,labels:["2"]}],size:{width:j0.width,height:j0.height},center:{x:j0.centerX,y:j0.centerY}}),Jm=r(k0,"up"),K={paths:{path12_rotated:{type:"path",points:[{x:-.09,y:.12},{x:-.09,y:-.12}],color:"primary",fill:!1},path2_rotated:{type:"path",points:[{x:-.09,y:0},{x:.09,y:0}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:0,y:.03}},refblocks:{left1:{x:.09,y:0}},bounds:{minX:-.57,maxX:.57,minY:-.37,maxY:.37,width:1.14,height:.74,centerX:0,centerY:0},circles:{}},{paths:Z2,texts:FF,bounds:$m,refblocks:Q2,circles:K2}=K,Mm=e({primitives:[...Object.values(Z2),...Object.values(K2),{type:"text",text:"{REF}",x:-.14,y:-0}],ports:[{...Q2.left1,labels:["1"]}],center:{x:$m.centerX,y:$m.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_top").build(),{paths:t9,texts:XF,bounds:Cm,refblocks:e9,circles:r9}=K,Nm=e({primitives:[...Object.values(t9),...Object.values(r9),{type:"text",text:"{REF}",x:-.13,y:0}],ports:[{...e9.left1,labels:["1"]}],center:{x:Cm.centerX,y:Cm.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_right").build(),{paths:o9,texts:kF,bounds:Im,refblocks:i9,circles:l9}=K,Bm=e({primitives:[...Object.values(o9),...Object.values(l9),{type:"text",text:"{REF}",x:-.14,y:-0}],ports:[{...i9.left1,labels:["1"]}],center:{x:Im.centerX,y:Im.centerY}}).rotateRightFacingSymbol("left").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_left").build(),{paths:p9,texts:$F,bounds:qm,refblocks:a9}=K,Dm=e({primitives:[...Object.values(p9),{type:"text",text:"{REF}",x:-.14,y:0}],ports:[{...a9.left1,labels:["1"]}],center:{x:qm.centerX,y:qm.centerY}}).rotateRightFacingSymbol("down").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_bottom").build(),Gm={paths:{path40:{type:"path",points:[{x:-.19,y:-.33},{x:-.26,y:-.14}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.38,y:-.26},{x:-.19,y:-.33}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.26,y:-.14},{x:-.38,y:-.26}],color:"primary",fill:!1},path43:{type:"path",points:[{x:-.26,y:-.39},{x:-.13,y:-.26}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.32,y:-.2},{x:-.52,y:0}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:0,y:-.52},{x:-.19,y:-.33}],color:"primary",fill:!1},"path40-4":{type:"path",points:[{x:-.19,y:.32},{x:-.38,y:.26}],color:"primary",fill:!1},"path41-1":{type:"path",points:[{x:-.26,y:.13},{x:-.19,y:.32}],color:"primary",fill:!1},"path42-7":{type:"path",points:[{x:-.38,y:.26},{x:-.26,y:.13}],color:"primary",fill:!1},"path43-1":{type:"path",points:[{x:-.13,y:.26},{x:-.26,y:.39}],color:"primary",fill:!1},"path44-8":{type:"path",points:[{x:-.32,y:.19},{x:-.51,y:.01}],color:"primary",fill:!1},"path44-0-7":{type:"path",points:[{x:-.01,y:.5},{x:-.19,y:.32}],color:"primary",fill:!1},"path40-4-0":{type:"path",points:[{x:.32,y:-.19},{x:.13,y:-.26}],color:"primary",fill:!1},"path41-1-2":{type:"path",points:[{x:.26,y:-.38},{x:.32,y:-.19}],color:"primary",fill:!1},"path42-7-1":{type:"path",points:[{x:.13,y:-.26},{x:.26,y:-.38}],color:"primary",fill:!1},"path43-1-8":{type:"path",points:[{x:.39,y:-.26},{x:.26,y:-.13}],color:"primary",fill:!1},"path44-8-7":{type:"path",points:[{x:.2,y:-.32},{x:.01,y:-.51}],color:"primary",fill:!1},"path44-0-7-1":{type:"path",points:[{x:.52,y:0},{x:.32,y:-.19}],color:"primary",fill:!1},"path40-4-8":{type:"path",points:[{x:.32,y:.19},{x:.26,y:.38}],color:"primary",fill:!1},"path41-1-4":{type:"path",points:[{x:.13,y:.26},{x:.32,y:.19}],color:"primary",fill:!1},"path42-7-0":{type:"path",points:[{x:.26,y:.38},{x:.13,y:.26}],color:"primary",fill:!1},"path43-1-0":{type:"path",points:[{x:.26,y:.13},{x:.39,y:.26}],color:"primary",fill:!1},"path44-8-9":{type:"path",points:[{x:.19,y:.32},{x:0,y:.52}],color:"primary",fill:!1},"path44-0-7-3":{type:"path",points:[{x:.5,y:.01},{x:.32,y:.19}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.29,y:-.46},bottom1:{type:"text",text:"{VAL}",x:-.29,y:.5}},refblocks:{top1:{x:0,y:-.52},bottom1:{x:0,y:.52},left1:{x:-.52,y:0},right1:{x:.52,y:0}},bounds:{minX:-.55,maxX:.55,minY:-.56,maxY:.55,width:1.09,height:1.1,centerX:0,centerY:0},circles:{}},{paths:x9,texts:Um,bounds:z0,refblocks:O0,circles:s9}=Gm,J0=s({primitives:[...Object.values(x9),...Object.values(s9),{...Um.top1,anchor:"middle_right"},{...Um.bottom1,anchor:"middle_right"}],ports:[{...O0.top1,labels:["1"]},{...O0.bottom1,labels:["2"]},{...O0.left1,labels:["3"]},{...O0.right1,labels:["4"]}],size:{width:z0.width,height:z0.height},center:{x:z0.centerX,y:z0.centerY}}),Xi=r(J0),m9=Xi.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),n9=Xi.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");m9.anchor="middle_left";n9.anchor="middle_right";Wm=Xi,tt={paths:{path27:{type:"path",points:[{x:.47,y:.04},{x:.21,y:.04}],color:"primary",fill:!1},"path27-0":{type:"path",points:[{x:-.21,y:.04},{x:-.47,y:.04}],color:"primary",fill:!1},"path27-8-2-4":{type:"path",points:[{x:.21,y:.04},{x:.19,y:-.05}],color:"primary",fill:!1},"path27-8-2-4-29":{type:"path",points:[{x:-.19,y:.14},{x:-.21,y:.04}],color:"primary",fill:!1},"path27-8-2-4-5":{type:"path",points:[{x:.19,y:-.05},{x:.13,y:.14}],color:"primary",fill:!1},"path27-8-2-4-5-1":{type:"path",points:[{x:.08,y:-.05},{x:.13,y:.14}],color:"primary",fill:!1},"path27-8-2-4-5-1-9":{type:"path",points:[{x:.08,y:-.05},{x:.03,y:.14}],color:"primary",fill:!1},"path27-8-2-4-5-1-9-2":{type:"path",points:[{x:-.03,y:-.05},{x:.03,y:.14}],color:"primary",fill:!1},"path27-8-2-4-5-1-9-2-1":{type:"path",points:[{x:-.03,y:-.05},{x:-.08,y:.14}],color:"primary",fill:!1},"path27-8-2-4-5-1-9-2-1-2":{type:"path",points:[{x:-.13,y:-.05},{x:-.08,y:.14}],color:"primary",fill:!1},"path27-8-2-4-5-1-9-2-1-2-2":{type:"path",points:[{x:-.13,y:-.05},{x:-.19,y:.14}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.05,y:.42},bottom1:{type:"text",text:"{VAL}",x:-.04,y:-.42}},refblocks:{left1:{x:-.47,y:.04},right1:{x:.47,y:.04}},bounds:{minX:-.49,maxX:.49,minY:-.42,maxY:.42,width:.99,height:.84,centerX:0,centerY:0},circles:{}},{paths:c9,texts:ZF,bounds:$0,refblocks:Hm,circles:h9}=tt,Zm=e({primitives:[...Object.values(c9),...Object.values(h9),{type:"text",text:"{REF}",x:-.2,y:.2194553499999995},{type:"text",text:"{VAL}",x:.2,y:.2194553499999995}],ports:[{...Hm.left1,labels:["1"]},{...Hm.right1,labels:["2"]}],size:{width:$0.width,height:$0.height},center:{x:$0.centerX,y:$0.centerY}}).rotateRightFacingSymbol("down").labelPort("left",["1"]).labelPort("right",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:d9,texts:eT,bounds:M0,refblocks:Qm,circles:b9}=tt,Km=e({primitives:[...Object.values(d9),...Object.values(b9),{type:"text",text:"{REF}",x:0,y:-.1704553499999995},{type:"text",text:"{VAL}",x:0,y:.2294553499999995}],ports:[{...Qm.left1,labels:["1"]},{...Qm.right1,labels:["2"]}],size:{width:M0.width,height:M0.height},center:{x:M0.centerX,y:M0.centerY}}).rotateRightFacingSymbol("left").labelPort("left",["1"]).labelPort("right",["2"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),{paths:_9,texts:lT,bounds:C0,refblocks:tn,circles:g9}=tt,en=e({primitives:[...Object.values(_9),...Object.values(g9),{type:"text",text:"{REF}",x:0,y:.2294553499999995},{type:"text",text:"{VAL}",x:0,y:-.1704553499999995}],ports:[{...tn.left1,labels:["1"]},{...tn.right1,labels:["2"]}],size:{width:C0.width,height:C0.height},center:{x:C0.centerX,y:C0.centerY}}).rotateRightFacingSymbol("right").labelPort("left",["1"]).labelPort("right",["2"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),{paths:u9,texts:xT,bounds:N0,refblocks:rn,circles:v9}=tt,on=e({primitives:[...Object.values(u9),...Object.values(v9),{type:"text",text:"{REF}",x:.2,y:-.1404553499999995},{type:"text",text:"{VAL}",x:-.2,y:-.1494553499999995}],ports:[{...rn.left1,labels:["1"]},{...rn.right1,labels:["2"]}],size:{width:N0.width,height:N0.height},center:{x:N0.centerX,y:N0.centerY}}).rotateRightFacingSymbol("up").labelPort("left",["1"]).labelPort("right",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),I0={paths:{path27:{type:"path",points:[{x:.76,y:-.28},{x:.31,y:-.28}],color:"primary",fill:!1},path28:{type:"path",points:[{x:-.3,y:-.02},{x:-.77,y:-.02}],color:"primary",fill:!1},path30:{type:"path",points:[{x:-.3,y:.35},{x:-.3,y:-.28}],color:"primary",fill:!1},"path27-3":{type:"path",points:[{x:.77,y:.35},{x:.32,y:.35}],color:"primary",fill:!1},"path29-5":{type:"path",points:[{x:-.07,y:-.28},{x:-.3,y:-.28}],color:"primary",fill:!1},"path29-5-7":{type:"path",points:[{x:.33,y:-.28},{x:.11,y:-.28}],color:"primary",fill:!1},"path29-5-7-6":{type:"path",points:[{x:-.06,y:-.17},{x:-.06,y:-.39}],color:"primary",fill:!1},"path29-5-7-6-6":{type:"path",points:[{x:.09,y:-.17},{x:.09,y:-.39}],color:"primary",fill:!1},"path29-5-9":{type:"path",points:[{x:-.07,y:.35},{x:-.3,y:.35}],color:"primary",fill:!1},"path29-5-7-2":{type:"path",points:[{x:.33,y:.35},{x:.11,y:.35}],color:"primary",fill:!1},"path29-5-7-6-0":{type:"path",points:[{x:-.06,y:.46},{x:-.06,y:.24}],color:"primary",fill:!1},"path29-5-7-6-6-2":{type:"path",points:[{x:.09,y:.46},{x:.09,y:.24}],color:"primary",fill:!1},"path29-5-92":{type:"path",points:[{x:.33,y:.13},{x:.33,y:.35}],color:"primary",fill:!1},"path29-5-7-28":{type:"path",points:[{x:.33,y:-.28},{x:.33,y:-.05}],color:"primary",fill:!1},"path29-5-7-6-9":{type:"path",points:[{x:.44,y:.11},{x:.22,y:.11}],color:"primary",fill:!1},"path29-5-7-6-6-7":{type:"path",points:[{x:.44,y:-.04},{x:.22,y:-.04}],color:"primary",fill:!1},"path29-5-7-6-9-2":{type:"path",points:[{x:.44,y:.07},{x:.22,y:.07}],color:"primary",fill:!1},"path29-5-7-6-9-2-4":{type:"path",points:[{x:.44,y:0},{x:.44,y:.07}],color:"primary",fill:!1},"path29-5-7-6-9-2-4-6":{type:"path",points:[{x:.22,y:0},{x:.22,y:.07}],color:"primary",fill:!1},"path29-5-7-6-9-2-9":{type:"path",points:[{x:.44,y:0},{x:.22,y:0}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:.02,y:.53},bottom1:{type:"text",text:"{VAL}",x:.01,y:-.54}},refblocks:{left1:{x:-.77,y:-.02},right1:{x:.76,y:-.28},right2:{x:.77,y:.35}},bounds:{minX:-.79,maxX:.79,minY:-.54,maxY:.54,width:1.59,height:1.07,centerX:0,centerY:0},circles:{}},{paths:A9,texts:ln,bounds:B0,refblocks:Li,circles:P9}=I0,et=s({primitives:[...Object.values(A9),...Object.values(P9),{...ln.top1,anchor:"middle_bottom"},{...ln.bottom1,anchor:"middle_top"}],ports:[{...Li.left1,labels:["1"]},{...Li.right1,labels:["2"]},{...Li.right2,labels:["3"]}],size:{width:B0.width,height:B0.height},center:{x:B0.centerX,y:B0.centerY}}),Vi=r(et,"down"),ji=Vi.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),ki=Vi.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");ji.anchor="middle_bottom";ki.anchor="middle_top";ji.y+=.3;ji.x+=.101;ki.y-=.49999;ki.x+=1.19999;pn=Vi,{paths:S9,texts:uT,bounds:q0,refblocks:zi,circles:R9}=I0,D0=s({primitives:[...Object.values(S9),...Object.values(R9),{type:"text",text:"{REF}",x:.01596175000000022,y:-.5308501500000009,anchor:"middle_top"},{type:"text",text:"{VAL}",x:.013116750000000454,y:.5408501499999989,anchor:"middle_bottom"}],ports:[{...zi.left1,labels:["1"]},{...zi.right1,labels:["2"]},{...zi.right2,labels:["3"]}],size:{width:q0.width,height:q0.height},center:{x:q0.centerX,y:q0.centerY}}),Oi=r(et,"left"),Ji=Oi.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),$i=Oi.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Ji.anchor="middle_bottom";$i.anchor="middle_top";Ji.y+=.99;Ji.x-=0;$i.y-=1.10999;$i.x=0;an=Oi,Mi=r(et,"up"),Ci=Mi.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),Ni=Mi.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Ci.anchor="middle_bottom";Ni.anchor="middle_top";Ci.y+=.499;Ci.x=.62;Ni.y-=.29999;Ni.x+=.1;yn=Mi,xn=r(D0),sn={paths:{path40:{type:"path",points:[{x:.14,y:.04},{x:-.12,y:-.09}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.12,y:.18},{x:.14,y:.04}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.12,y:-.09},{x:-.12,y:.18}],color:"primary",fill:!1},path43:{type:"path",points:[{x:.14,y:.18},{x:.14,y:-.09}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.12,y:.04},{x:-.52,y:.04}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.52,y:.04},{x:.15,y:.04}],color:"primary",fill:!1},"path43-7":{type:"path",points:[{x:.21,y:.18},{x:.14,y:.18}],color:"primary",fill:!1},"path43-7-9":{type:"path",points:[{x:.21,y:.13},{x:.21,y:.18}],color:"primary",fill:!1},"path43-7-2":{type:"path",points:[{x:.08,y:-.09},{x:.14,y:-.09}],color:"primary",fill:!1},"path43-7-9-3":{type:"path",points:[{x:.08,y:-.04},{x:.08,y:-.09}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.01,y:.27},bottom1:{type:"text",text:"{VAL}",x:0,y:-.27}},refblocks:{left1:{x:-.52,y:.04},right1:{x:.52,y:.04}},bounds:{minX:-.55,maxX:.55,minY:-.27,maxY:.27,width:1.09,height:.55,centerX:0,centerY:0},circles:{}},rt=e(sn).labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{VAL}","middle_top").changeTextAnchor("{REF}","middle_bottom").build(),Ii=r(rt,"down"),Bi=Ii.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),qi=Ii.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Bi.anchor="middle_left";qi.anchor="middle_left";Bi.y+=.3;Bi.x=.3;qi.y-=.3;qi.x=.3;mn=Ii,Di=r(rt,"left"),Gi=Di.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),Ui=Di.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Gi.anchor="middle_bottom";Ui.anchor="middle_top";Gi.y+=.5;Gi.x=0;Ui.y-=.55;Ui.x=0;nn=Di,Wi=r(rt,"up"),Hi=Wi.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),Zi=Wi.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Hi.anchor="middle_left";Zi.anchor="middle_left";Hi.y+=.3;Hi.x=.3;Zi.y-=.3;Zi.x=.3;fn=Wi,Qi={paths:{path11:{type:"path",points:[{x:-.52,y:.04},{x:-.18,y:.04}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.19,y:.05},{x:.52,y:.05}],color:"primary",fill:!1},"path12-6":{type:"path",points:[{x:.18,y:-.15},{x:.18,y:.25}],color:"primary",fill:!1},"path12-2":{type:"path",points:[{x:.19,y:0},{x:.35,y:-.14}],color:"primary",fill:!1},"path12-2-9":{type:"path",points:[{x:.35,y:-.14},{x:.34,y:-.35}],color:"primary",fill:!1},"path11-0-9":{type:"path",points:[{x:-.17,y:.27},{x:-.17,y:-.15},{x:.18,y:.05},{x:-.17,y:.27}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:-.22,y:.38},bottom1:{type:"text",text:"{VAL}",x:.11,y:-.38}},refblocks:{bottom1:{x:.34,y:-.35},left1:{x:-.52,y:.04},right1:{x:.52,y:.05}},bounds:{minX:-.55,maxX:.55,minY:-.38,maxY:.38,width:1.09,height:.77,centerX:0,centerY:0},circles:{}},{paths:GT,texts:UT,bounds:WT,refblocks:HT,circles:ZT}=Qi,G0=e(Qi).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).labelPort("bottom1",["3"]).changeTextAnchor("{REF}","middle_bottom").build(),cn=r(G0),E9=cn.primitives.filter(t5=>t5.type==="text"),hn=E9.find(t5=>t5.text==="{REF}");hn.y=0;hn.anchor="middle_left";dn=cn,ot={paths:{path44:{type:"path",points:[{x:-.18,y:-.03},{x:-.45,y:-.03}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.45,y:-.03},{x:.18,y:-.02}],color:"primary",fill:!1},"path44-0-7":{type:"path",points:[{x:.07,y:-.02},{x:-.07,y:-.02}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.07,y:.1},{x:.07,y:-.15}],color:"primary",fill:!0},"path2-8":{type:"path",points:[{x:-.07,y:.1},{x:-.07,y:-.15}],color:"primary",fill:!0},"path8704-1":{type:"path",points:[{x:-.07,y:-.15},{x:-.07,y:-.15},{x:-.09,y:-.15},{x:-.1,y:-.14},{x:-.11,y:-.13},{x:-.13,y:-.12},{x:-.14,y:-.11},{x:-.14,y:-.1},{x:-.15,y:-.09},{x:-.16,y:-.08},{x:-.16,y:-.07},{x:-.16,y:-.06},{x:-.17,y:-.05},{x:-.17,y:-.04},{x:-.17,y:-.03},{x:-.17,y:-.02},{x:-.17,y:-.01},{x:-.16,y:0},{x:-.16,y:.01},{x:-.16,y:.02},{x:-.15,y:.03},{x:-.15,y:.04},{x:-.14,y:.05},{x:-.14,y:.05},{x:-.13,y:.06},{x:-.12,y:.07},{x:-.11,y:.08},{x:-.11,y:.08},{x:-.1,y:.09},{x:-.09,y:.09},{x:-.08,y:.1},{x:-.07,y:.1},{x:-.07,y:.1}],color:"primary",fill:!1},"path8704-1-7":{type:"path",points:[{x:.07,y:-.15},{x:.07,y:-.15},{x:.09,y:-.15},{x:.1,y:-.14},{x:.12,y:-.13},{x:.13,y:-.12},{x:.14,y:-.11},{x:.14,y:-.1},{x:.15,y:-.09},{x:.16,y:-.08},{x:.16,y:-.07},{x:.17,y:-.06},{x:.17,y:-.05},{x:.17,y:-.04},{x:.17,y:-.03},{x:.17,y:-.02},{x:.17,y:-.01},{x:.16,y:0},{x:.16,y:.01},{x:.16,y:.02},{x:.15,y:.03},{x:.15,y:.04},{x:.14,y:.05},{x:.14,y:.05},{x:.13,y:.06},{x:.12,y:.07},{x:.11,y:.08},{x:.11,y:.08},{x:.1,y:.09},{x:.09,y:.09},{x:.08,y:.1},{x:.07,y:.1},{x:.07,y:.1}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.02,y:.15}},refblocks:{left1:{x:-.45,y:-.03},right1:{x:.45,y:-.03}},bounds:{minX:-.47,maxX:.47,minY:-.15,maxY:.15,width:.95,height:.31,centerX:0,centerY:0},circles:{}},bn=e(ot).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").build(),_n=e(ot).rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_top").build(),gn=e(ot).rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),un=e(ot).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_right").build(),it={paths:{path44:{type:"path",points:[{x:-.18,y:-.03},{x:-.45,y:-.03}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.45,y:-.03},{x:.18,y:-.02}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.07,y:.1},{x:.07,y:-.15}],color:"primary",fill:!0},"path2-8":{type:"path",points:[{x:-.07,y:.1},{x:-.07,y:-.15}],color:"primary",fill:!0},"path8704-1":{type:"path",points:[{x:-.07,y:-.15},{x:-.07,y:-.15},{x:-.09,y:-.15},{x:-.1,y:-.14},{x:-.11,y:-.13},{x:-.13,y:-.12},{x:-.14,y:-.11},{x:-.14,y:-.1},{x:-.15,y:-.09},{x:-.16,y:-.08},{x:-.16,y:-.07},{x:-.16,y:-.06},{x:-.17,y:-.05},{x:-.17,y:-.04},{x:-.17,y:-.03},{x:-.17,y:-.02},{x:-.17,y:-.01},{x:-.16,y:0},{x:-.16,y:.01},{x:-.16,y:.02},{x:-.15,y:.03},{x:-.15,y:.04},{x:-.14,y:.05},{x:-.14,y:.05},{x:-.13,y:.06},{x:-.12,y:.07},{x:-.11,y:.08},{x:-.11,y:.08},{x:-.1,y:.09},{x:-.09,y:.09},{x:-.08,y:.1},{x:-.07,y:.1},{x:-.07,y:.1}],color:"primary",fill:!1},"path8704-1-7":{type:"path",points:[{x:.07,y:-.15},{x:.07,y:-.15},{x:.09,y:-.15},{x:.1,y:-.14},{x:.12,y:-.13},{x:.13,y:-.12},{x:.14,y:-.11},{x:.14,y:-.1},{x:.15,y:-.09},{x:.16,y:-.08},{x:.16,y:-.07},{x:.17,y:-.06},{x:.17,y:-.05},{x:.17,y:-.04},{x:.17,y:-.03},{x:.17,y:-.02},{x:.17,y:-.01},{x:.16,y:0},{x:.16,y:.01},{x:.16,y:.02},{x:.15,y:.03},{x:.15,y:.04},{x:.14,y:.05},{x:.14,y:.05},{x:.13,y:.06},{x:.12,y:.07},{x:.11,y:.08},{x:.11,y:.08},{x:.1,y:.09},{x:.09,y:.09},{x:.08,y:.1},{x:.07,y:.1},{x:.07,y:.1}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.02,y:.15}},refblocks:{left1:{x:-.45,y:-.03},right1:{x:.45,y:-.03}},bounds:{minX:-.47,maxX:.47,minY:-.15,maxY:.15,width:.95,height:.31,centerX:0,centerY:0},circles:{}},vn=e(it).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").build(),wn=e(it).rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_top").build(),An=e(it).rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),Pn=e(it).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_right").build(),lt={paths:{path44:{type:"path",points:[{x:-.22,y:.1},{x:-.45,y:.1}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.45,y:.1},{x:.22,y:.1}],color:"primary",fill:!1},"path44-5":{type:"path",points:[{x:0,y:-.03},{x:0,y:-.25}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.12,y:.23},{x:.12,y:-.02}],color:"primary",fill:!0},"path2-88":{type:"path",points:[{x:.04,y:.22},{x:.04,y:-.02}],color:"primary",fill:!0},"path2-88-5":{type:"path",points:[{x:-.05,y:.22},{x:-.05,y:-.02}],color:"primary",fill:!0},"path2-88-5-1":{type:"path",points:[{x:.04,y:.22},{x:-.05,y:.22}],color:"primary",fill:!0},"path2-88-5-1-6":{type:"path",points:[{x:.04,y:-.02},{x:-.05,y:-.02}],color:"primary",fill:!0},"path2-8":{type:"path",points:[{x:-.12,y:.23},{x:-.12,y:-.02}],color:"primary",fill:!0},"path8704-1":{type:"path",points:[{x:-.13,y:-.03},{x:-.13,y:-.03},{x:-.14,y:-.02},{x:-.16,y:-.01},{x:-.17,y:0},{x:-.18,y:.01},{x:-.19,y:.02},{x:-.2,y:.03},{x:-.2,y:.04},{x:-.21,y:.05},{x:-.21,y:.06},{x:-.22,y:.07},{x:-.22,y:.08},{x:-.22,y:.09},{x:-.22,y:.1},{x:-.22,y:.11},{x:-.22,y:.12},{x:-.22,y:.13},{x:-.21,y:.14},{x:-.21,y:.15},{x:-.21,y:.15},{x:-.2,y:.16},{x:-.19,y:.17},{x:-.19,y:.18},{x:-.18,y:.19},{x:-.17,y:.2},{x:-.17,y:.2},{x:-.16,y:.21},{x:-.15,y:.22},{x:-.14,y:.22},{x:-.13,y:.23},{x:-.13,y:.23},{x:-.13,y:.23}],color:"primary",fill:!1},"path8704-1-7":{type:"path",points:[{x:.12,y:-.03},{x:.12,y:-.03},{x:.14,y:-.02},{x:.15,y:-.01},{x:.17,y:0},{x:.18,y:.01},{x:.19,y:.02},{x:.2,y:.03},{x:.2,y:.04},{x:.21,y:.05},{x:.21,y:.06},{x:.22,y:.07},{x:.22,y:.08},{x:.22,y:.09},{x:.22,y:.1},{x:.22,y:.11},{x:.22,y:.12},{x:.22,y:.13},{x:.21,y:.14},{x:.21,y:.15},{x:.2,y:.15},{x:.2,y:.16},{x:.19,y:.17},{x:.19,y:.18},{x:.18,y:.19},{x:.17,y:.2},{x:.17,y:.2},{x:.16,y:.21},{x:.15,y:.21},{x:.14,y:.22},{x:.13,y:.23},{x:.12,y:.23},{x:.12,y:.23}],color:"primary",fill:!1},path1:{type:"path",points:[{x:-.05,y:.1},{x:-.12,y:.1}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.02,y:.28}},refblocks:{bottom1:{x:0,y:-.25},left1:{x:-.45,y:.1},right1:{x:.45,y:.1}},bounds:{minX:-.47,maxX:.47,minY:-.28,maxY:.28,width:.95,height:.56,centerX:0,centerY:0},circles:{}},Sn=e(lt).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_left").build(),Rn=e(lt).rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_top").build(),Fn=e(lt).rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_bottom").build(),Tn=e(lt).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_right").build(),pt={paths:{path44:{type:"path",points:[{x:-.22,y:.1},{x:-.45,y:.1}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.45,y:.1},{x:.22,y:.1}],color:"primary",fill:!1},"path44-0-7":{type:"path",points:[{x:.12,y:.1},{x:.04,y:.1}],color:"primary",fill:!1},"path44-5":{type:"path",points:[{x:0,y:-.03},{x:0,y:-.25}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.12,y:.23},{x:.12,y:-.02}],color:"primary",fill:!0},"path2-88":{type:"path",points:[{x:.04,y:.22},{x:.04,y:-.02}],color:"primary",fill:!0},"path2-88-5":{type:"path",points:[{x:-.05,y:.22},{x:-.05,y:-.02}],color:"primary",fill:!0},"path2-88-5-1":{type:"path",points:[{x:.04,y:.22},{x:-.05,y:.22}],color:"primary",fill:!0},"path2-88-5-1-6":{type:"path",points:[{x:.04,y:-.02},{x:-.05,y:-.02}],color:"primary",fill:!0},"path2-8":{type:"path",points:[{x:-.12,y:.23},{x:-.12,y:-.02}],color:"primary",fill:!0},"path8704-1":{type:"path",points:[{x:-.13,y:-.03},{x:-.13,y:-.03},{x:-.14,y:-.02},{x:-.16,y:-.01},{x:-.17,y:0},{x:-.18,y:.01},{x:-.19,y:.02},{x:-.2,y:.03},{x:-.2,y:.04},{x:-.21,y:.05},{x:-.21,y:.06},{x:-.22,y:.07},{x:-.22,y:.08},{x:-.22,y:.09},{x:-.22,y:.1},{x:-.22,y:.11},{x:-.22,y:.12},{x:-.22,y:.13},{x:-.21,y:.14},{x:-.21,y:.15},{x:-.21,y:.15},{x:-.2,y:.16},{x:-.19,y:.17},{x:-.19,y:.18},{x:-.18,y:.19},{x:-.17,y:.2},{x:-.17,y:.2},{x:-.16,y:.21},{x:-.15,y:.22},{x:-.14,y:.22},{x:-.13,y:.23},{x:-.13,y:.23},{x:-.13,y:.23}],color:"primary",fill:!1},"path8704-1-7":{type:"path",points:[{x:.12,y:-.03},{x:.12,y:-.03},{x:.14,y:-.02},{x:.15,y:-.01},{x:.17,y:0},{x:.18,y:.01},{x:.19,y:.02},{x:.2,y:.03},{x:.2,y:.04},{x:.21,y:.05},{x:.21,y:.06},{x:.22,y:.07},{x:.22,y:.08},{x:.22,y:.09},{x:.22,y:.1},{x:.22,y:.11},{x:.22,y:.12},{x:.22,y:.13},{x:.21,y:.14},{x:.21,y:.15},{x:.2,y:.15},{x:.2,y:.16},{x:.19,y:.17},{x:.19,y:.18},{x:.18,y:.19},{x:.17,y:.2},{x:.17,y:.2},{x:.16,y:.21},{x:.15,y:.21},{x:.14,y:.22},{x:.13,y:.23},{x:.12,y:.23},{x:.12,y:.23}],color:"primary",fill:!1},path1:{type:"path",points:[{x:-.05,y:.1},{x:-.12,y:.1}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.02,y:.28}},refblocks:{bottom1:{x:0,y:-.25},left1:{x:-.45,y:.1},right1:{x:.45,y:.1}},bounds:{minX:-.47,maxX:.47,minY:-.28,maxY:.28,width:.95,height:.56,centerX:0,centerY:0},circles:{}},En=e(pt).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_left").build(),Yn=e(pt).rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_top").build(),Xn=e(pt).rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_bottom").build(),Ln=e(pt).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_right").build(),at={paths:{path44:{type:"path",points:[{x:-.22,y:.1},{x:-.45,y:.1}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.45,y:.1},{x:.22,y:.1}],color:"primary",fill:!1},"path44-0-7":{type:"path",points:[{x:.12,y:.1},{x:.04,y:.1}],color:"primary",fill:!1},"path44-5":{type:"path",points:[{x:0,y:-.03},{x:0,y:-.25}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.12,y:.23},{x:.12,y:-.02}],color:"primary",fill:!0},"path2-88":{type:"path",points:[{x:.04,y:.22},{x:.04,y:-.02}],color:"primary",fill:!0},"path2-88-5":{type:"path",points:[{x:-.05,y:.22},{x:-.05,y:-.02}],color:"primary",fill:!0},"path2-88-5-1":{type:"path",points:[{x:.04,y:.22},{x:-.05,y:.22}],color:"primary",fill:!0},"path2-88-5-1-6":{type:"path",points:[{x:.04,y:-.02},{x:-.05,y:-.02}],color:"primary",fill:!0},"path2-8":{type:"path",points:[{x:-.12,y:.23},{x:-.12,y:-.02}],color:"primary",fill:!0},"path8704-1":{type:"path",points:[{x:-.13,y:-.03},{x:-.13,y:-.03},{x:-.14,y:-.02},{x:-.16,y:-.01},{x:-.17,y:0},{x:-.18,y:.01},{x:-.19,y:.02},{x:-.2,y:.03},{x:-.2,y:.04},{x:-.21,y:.05},{x:-.21,y:.06},{x:-.22,y:.07},{x:-.22,y:.08},{x:-.22,y:.09},{x:-.22,y:.1},{x:-.22,y:.11},{x:-.22,y:.12},{x:-.22,y:.13},{x:-.21,y:.14},{x:-.21,y:.15},{x:-.21,y:.15},{x:-.2,y:.16},{x:-.19,y:.17},{x:-.19,y:.18},{x:-.18,y:.19},{x:-.17,y:.2},{x:-.17,y:.2},{x:-.16,y:.21},{x:-.15,y:.22},{x:-.14,y:.22},{x:-.13,y:.23},{x:-.13,y:.23},{x:-.13,y:.23}],color:"primary",fill:!1},"path8704-1-7":{type:"path",points:[{x:.12,y:-.03},{x:.12,y:-.03},{x:.14,y:-.02},{x:.15,y:-.01},{x:.17,y:0},{x:.18,y:.01},{x:.19,y:.02},{x:.2,y:.03},{x:.2,y:.04},{x:.21,y:.05},{x:.21,y:.06},{x:.22,y:.07},{x:.22,y:.08},{x:.22,y:.09},{x:.22,y:.1},{x:.22,y:.11},{x:.22,y:.12},{x:.22,y:.13},{x:.21,y:.14},{x:.21,y:.15},{x:.2,y:.15},{x:.2,y:.16},{x:.19,y:.17},{x:.19,y:.18},{x:.18,y:.19},{x:.17,y:.2},{x:.17,y:.2},{x:.16,y:.21},{x:.15,y:.21},{x:.14,y:.22},{x:.13,y:.23},{x:.12,y:.23},{x:.12,y:.23}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.02,y:.28}},refblocks:{bottom1:{x:0,y:-.25},left1:{x:-.45,y:.1},right1:{x:.45,y:.1}},bounds:{minX:-.47,maxX:.47,minY:-.28,maxY:.28,width:.95,height:.56,centerX:0,centerY:0},circles:{}},Vn=e(at).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_left").build(),jn=e(at).rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_top").build(),kn=e(at).rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_bottom").build(),zn=e(at).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_right").build(),yt={paths:{path44:{type:"path",points:[{x:-.22,y:.1},{x:-.45,y:.1}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.45,y:.1},{x:.22,y:.1}],color:"primary",fill:!1},"path44-5":{type:"path",points:[{x:0,y:-.03},{x:0,y:-.25}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.12,y:.23},{x:.12,y:-.02}],color:"primary",fill:!0},"path2-88":{type:"path",points:[{x:.04,y:.22},{x:.04,y:-.02}],color:"primary",fill:!0},"path2-88-5":{type:"path",points:[{x:-.05,y:.22},{x:-.05,y:-.02}],color:"primary",fill:!0},"path2-88-5-1":{type:"path",points:[{x:.04,y:.22},{x:-.05,y:.22}],color:"primary",fill:!0},"path2-88-5-1-6":{type:"path",points:[{x:.04,y:-.02},{x:-.05,y:-.02}],color:"primary",fill:!0},"path2-8":{type:"path",points:[{x:-.12,y:.23},{x:-.12,y:-.02}],color:"primary",fill:!0},"path8704-1":{type:"path",points:[{x:-.13,y:-.03},{x:-.13,y:-.03},{x:-.14,y:-.02},{x:-.16,y:-.01},{x:-.17,y:0},{x:-.18,y:.01},{x:-.19,y:.02},{x:-.2,y:.03},{x:-.2,y:.04},{x:-.21,y:.05},{x:-.21,y:.06},{x:-.22,y:.07},{x:-.22,y:.08},{x:-.22,y:.09},{x:-.22,y:.1},{x:-.22,y:.11},{x:-.22,y:.12},{x:-.22,y:.13},{x:-.21,y:.14},{x:-.21,y:.15},{x:-.21,y:.15},{x:-.2,y:.16},{x:-.19,y:.17},{x:-.19,y:.18},{x:-.18,y:.19},{x:-.17,y:.2},{x:-.17,y:.2},{x:-.16,y:.21},{x:-.15,y:.22},{x:-.14,y:.22},{x:-.13,y:.23},{x:-.13,y:.23},{x:-.13,y:.23}],color:"primary",fill:!1},"path8704-1-7":{type:"path",points:[{x:.12,y:-.03},{x:.12,y:-.03},{x:.14,y:-.02},{x:.15,y:-.01},{x:.17,y:0},{x:.18,y:.01},{x:.19,y:.02},{x:.2,y:.03},{x:.2,y:.04},{x:.21,y:.05},{x:.21,y:.06},{x:.22,y:.07},{x:.22,y:.08},{x:.22,y:.09},{x:.22,y:.1},{x:.22,y:.11},{x:.22,y:.12},{x:.22,y:.13},{x:.21,y:.14},{x:.21,y:.15},{x:.2,y:.15},{x:.2,y:.16},{x:.19,y:.17},{x:.19,y:.18},{x:.18,y:.19},{x:.17,y:.2},{x:.17,y:.2},{x:.16,y:.21},{x:.15,y:.21},{x:.14,y:.22},{x:.13,y:.23},{x:.12,y:.23},{x:.12,y:.23}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.02,y:.28}},refblocks:{bottom1:{x:0,y:-.25},left1:{x:-.45,y:.1},right1:{x:.45,y:.1}},bounds:{minX:-.47,maxX:.47,minY:-.28,maxY:.28,width:.95,height:.56,centerX:0,centerY:0},circles:{}},On=e(yt).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_left").build(),Jn=e(yt).rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_top").build(),$n=e(yt).rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_bottom").build(),Mn=e(yt).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_right").build(),Cn={paths:{path1:{type:"path",points:[{x:-.37,y:.03},{x:-.13,y:.03}],color:"primary",fill:!1},"path-1-3":{type:"path",points:[{x:-.07,y:.03},{x:.11,y:-.03}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.1,y:-.06},{x:.37,y:-.06}],color:"primary",fill:!1},path3:{type:"path",points:[{x:.12,y:.17},{x:.37,y:.17}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:0,y:.37},bottom1:{type:"text",text:"{VAL}",x:0,y:-.37}},refblocks:{left1:{x:-.37,y:.03},right1:{x:.37,y:-.06},right2:{x:.37,y:.17}},bounds:{minX:-.4,maxX:.4,minY:-.4,maxY:.4,width:.79,height:.79,centerX:0,centerY:0},circles:{"circle-3":{type:"circle",x:.08,y:-.07,radius:.02,color:"primary",fill:!1},"circle-1":{type:"circle",x:-.1,y:.03,radius:.02,color:"primary",fill:!1},"circle-2":{type:"circle",x:.08,y:.17,radius:.02,color:"primary",fill:!1}}},xt=e(Cn).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right2",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_bottom").build(),Ki=r(xt,"down"),tl=Ki.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),el=Ki.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");tl.anchor="middle_bottom";el.anchor="middle_top";tl.x=.44;tl.y+=.28;el.y-=.28;el.x=.44;Nn=Ki,rl=r(xt,"left"),ol=rl.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),il=rl.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");ol.anchor="middle_bottom";il.anchor="middle_top";ol.x=0;ol.y+=.625;il.y-=.695;il.x=0;In=rl,ll=r(xt,"up"),pl=ll.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),al=ll.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");pl.anchor="middle_bottom";al.anchor="middle_top";pl.x=.4;pl.y+=.28;al.y-=.28;al.x=.4;Bn=ll,qn={paths:{path1:{type:"path",points:[{x:-.37,y:.03},{x:-.13,y:.03}],color:"primary",fill:!1},"path-1-3":{type:"path",points:[{x:-.07,y:.03},{x:.11,y:.14}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.1,y:-.06},{x:.37,y:-.06}],color:"primary",fill:!1},path3:{type:"path",points:[{x:.12,y:.17},{x:.37,y:.17}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:0,y:.4},bottom1:{type:"text",text:"{VAL}",x:0,y:-.4}},refblocks:{left1:{x:-.37,y:.03},right1:{x:.37,y:-.06},right3:{x:.37,y:.17}},bounds:{minX:-.4,maxX:.4,minY:-.4,maxY:.4,width:.79,height:.79,centerX:0,centerY:0},circles:{"circle-3":{type:"circle",x:.08,y:-.07,radius:.02,color:"primary",fill:!1},"circle-1":{type:"circle",x:-.1,y:.03,radius:.02,color:"primary",fill:!1},"circle-2":{type:"circle",x:.08,y:.17,radius:.02,color:"primary",fill:!1}}},st=e(qn).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right3",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_bottom").build(),yl=r(st,"down"),xl=yl.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),sl=yl.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");xl.anchor="middle_bottom";sl.anchor="middle_top";xl.x=.44;xl.y+=.28;sl.y-=.28;sl.x=.44;Dn=yl,ml=r(st,"left"),nl=ml.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),fl=ml.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");nl.anchor="middle_bottom";fl.anchor="middle_top";nl.x=0;nl.y+=.625;fl.y-=.695;fl.x=0;Gn=ml,cl=r(st,"up"),hl=cl.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),dl=cl.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");hl.anchor="middle_bottom";dl.anchor="middle_top";hl.x=.4;hl.y+=.28;dl.y-=.28;dl.x=.4;Un=cl,Lt={paths:{path11:{type:"path",points:[{x:-.38,y:0},{x:-.12,y:-.01}],color:"primary",fill:!1},"path11-0":{type:"path",points:[{x:-.07,y:0},{x:.11,y:.05}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.12,y:-.01},{x:.38,y:0}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:0,y:.31},bottom1:{type:"text",text:"{VAL}",x:0,y:-.28}},refblocks:{left1:{x:-.12,y:-.01},left2:{x:-.38,y:0},right1:{x:.12,y:-.01},right2:{x:.38,y:0}},bounds:{minX:-.4,maxX:.4,minY:-.25,maxY:.25,width:.81,height:.5,centerX:0,centerY:0},circles:{"circle-2":{type:"circle",x:.1,y:0,radius:.02,color:"primary",fill:!1},"circle-1":{type:"circle",x:-.1,y:0,radius:.02,color:"primary",fill:!1}}};delete Lt.refblocks.left1;delete Lt.refblocks.right1;Lt.bounds.width+=.2;mt=e(Lt).changeTextAnchor("{VAL}","middle_top").labelPort("left2",["1"]).labelPort("right2",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),bl=r(mt,"down"),_l=bl.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),gl=bl.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");_l.anchor="middle_bottom";gl.anchor="middle_top";_l.x=.3;_l.y+=.265;gl.y-=.265;gl.x=.3;Wn=bl,ul=r(mt,"left"),vl=ul.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),wl=ul.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");vl.anchor="middle_bottom";wl.anchor="middle_top";vl.x=0;vl.y+=.57;wl.y-=.57;wl.x=0;Hn=ul,Al=r(mt,"up"),Pl=Al.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),Sl=Al.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Pl.anchor="middle_bottom";Sl.anchor="middle_top";Pl.x=.3;Pl.y+=.265;Sl.y-=.265;Sl.x=.3;Zn=Al,Vt={paths:{path11:{type:"path",points:[{x:-.38,y:0},{x:-.12,y:-.01}],color:"primary",fill:!1},"path11-0":{type:"path",points:[{x:-.07,y:.01},{x:.1,y:.14}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.12,y:-.01},{x:.38,y:0}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:0,y:.25},bottom1:{type:"text",text:"{VAL}",x:0,y:-.25}},refblocks:{left1:{x:-.12,y:-.01},left2:{x:-.38,y:0},right1:{x:.12,y:-.01},right2:{x:.38,y:0}},bounds:{minX:-.4,maxX:.4,minY:-.25,maxY:.25,width:.81,height:.5,centerX:0,centerY:0},circles:{"circle-2":{type:"circle",x:.1,y:0,radius:.02,color:"primary",fill:!1},"circle-1":{type:"circle",x:-.1,y:0,radius:.02,color:"primary",fill:!1}}};delete Vt.refblocks.left1;delete Vt.refblocks.right1;Vt.bounds.width+=.2;nt=e(Vt).changeTextAnchor("{VAL}","middle_top").labelPort("left2",["1"]).labelPort("right2",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),Rl=r(nt,"down"),Fl=Rl.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),Tl=Rl.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Fl.anchor="middle_bottom";Tl.anchor="middle_top";Fl.x=.3;Fl.y+=.265;Tl.y-=.265;Tl.x=.3;Qn=Rl,El=r(nt,"left"),Yl=El.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),Xl=El.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Yl.anchor="middle_bottom";Xl.anchor="middle_top";Yl.x=0;Yl.y+=.57;Xl.y-=.57;Xl.x=0;Kn=El,Ll=r(nt,"up"),Vl=Ll.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),jl=Ll.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Vl.anchor="middle_bottom";jl.anchor="middle_top";Vl.x=.3;Vl.y+=.265;jl.y-=.265;jl.x=.3;t1=Ll,ft={paths:{path44:{type:"path",points:[{x:-.16845120000000047,y:.02621170000000017},{x:-.4458008,y:.02709619999999968}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.4458008,y:.026971799999999657},{x:.1677968999999997,y:.027926399999999685}],color:"primary",fill:!1},"path8704-1":{type:"path",points:[{x:-.0040837000000002455,y:-.13467459999999964},{x:-.0040837000000002455,y:-.13467459999999964},{x:-.017668143940740948,y:-.1311205263185182},{x:-.03043520885925943,y:-.12727072121481456},{x:-.04240966440000013,y:-.1231399985999998},{x:-.05361628020740751,y:-.11874317238518502},{x:-.064079825925926,y:-.11409505648148131},{x:-.07382507120000005,y:-.10921046479999987},{x:-.0828767856740741,y:-.10410421125185171},{x:-.0912597389925926,y:-.09879110974814802},{x:-.09899870079999995,y:-.0932859741999998},{x:-.10611844074074069,y:-.08760361851851838},{x:-.11264372845925916,y:-.0817588566148146},{x:-.11859933359999993,y:-.07576650239999982},{x:-.12401002580740728,y:-.06964136978518495},{x:-.12890057472592584,y:-.06339827268148127},{x:-.13329574999999985,y:-.05705202499999972},{x:-.13722032127407394,y:-.05061744065185156},{x:-.14069905819259243,y:-.04410933354814783},{x:-.14375673039999987,y:-.03754251759999966},{x:-.14641810754074058,y:-.030931806718518143},{x:-.1487079592592591,y:-.0242920148148144},{x:-.15065105519999983,y:-.017637955799999563},{x:-.15227216500740723,y:-.01098444358518472},{x:-.15359605832592574,y:-.004346292081480994},{x:-.1546475047999998,y:.00226168480000051},{x:-.15545127407407386,y:.008824673148148676},{x:-.1560321357925924,y:.015327859051852397},{x:-.1564148595999998,y:.02175642860000056},{x:-.1566242151407405,y:.028095567881482052},{x:-.15668497205925902,y:.03433046298518576},{x:-.15662189999999976,y:.04044630000000058},{x:-.15662189999999976,y:.0404463000000006},{x:-.15662189999999976,y:.0404463000000006},{x:-.15622857394444417,y:.04717166472222282},{x:-.1553217675555553,y:.05388046444444503},{x:-.15392183849999977,y:.060558907500000585},{x:-.1520491444444442,y:.0671932022222228},{x:-.1497240430555553,y:.07376955694444502},{x:-.14696689199999974,y:.08027418000000058},{x:-.14379804894444415,y:.0866932797222228},{x:-.1402378715555553,y:.09301306444444506},{x:-.13630671749999965,y:.09921974250000057},{x:-.13202494444444415,y:.10529952222222282},{x:-.12741291005555522,y:.11123861194444501},{x:-.1224909719999997,y:.1170232200000006},{x:-.11727948794444407,y:.12263955472222278},{x:-.11179881555555524,y:.12807382444444504},{x:-.10606931249999965,y:.13331223750000057},{x:-.1001113364444441,y:.13834100222222284},{x:-.09394524505555521,y:.14314632694444504},{x:-.08759139599999967,y:.14771442000000062},{x:-.08107014694444413,y:.15203148972222283},{x:-.07440185555555523,y:.15608374444444503},{x:-.0676068794999997,y:.15985739250000058},{x:-.06070557644444415,y:.16333864222222283},{x:-.05371830405555529,y:.16651370194444504},{x:-.04666541999999976,y:.1693687800000006},{x:-.03956728194444424,y:.1718900847222228},{x:-.03244424755555539,y:.17406382444444501},{x:-.025316674499999876,y:.17587620750000055},{x:-.01820492044444437,y:.17731344222222278},{x:-.01112934305555553,y:.178361736944445},{x:-.004110300000000034,y:.17900730000000054},{x:-.004110300000000011,y:.17900730000000054}],color:"primary",fill:!1},"path8704-1-9":{type:"path",points:[{x:.004158700000000071,y:-.1355885000000001},{x:.004158700000000071,y:-.1355885000000001},{x:.017743143940740766,y:-.1320344263185187},{x:.03051020885925925,y:-.12818462121481505},{x:.042484664399999955,y:-.12405389860000024},{x:.053691280207407335,y:-.11965707238518546},{x:.0641548259259258,y:-.11500895648148178},{x:.07390007119999986,y:-.1101243648000003},{x:.0829517856740739,y:-.10501811125185218},{x:.0913347389925924,y:-.09970500974814848},{x:.09907370079999973,y:-.09419987420000027},{x:.10619344074074046,y:-.08851751851851883},{x:.11271872845925893,y:-.08267275661481507},{x:.11867433359999968,y:-.07668040240000029},{x:.12408502580740703,y:-.0705552697851854},{x:.12897557472592555,y:-.06431217268148172},{x:.13337074999999957,y:-.05796592500000018},{x:.13729532127407365,y:-.05153134065185202},{x:.14077405819259214,y:-.045023233548148286},{x:.14383173039999952,y:-.038456417600000126},{x:.14649310754074024,y:-.03184570671851861},{x:.14878295925925875,y:-.02520591481481487},{x:.1507260551999995,y:-.01855185580000003},{x:.15234716500740686,y:-.011898343585185192},{x:.15367105832592537,y:-.005260192081481464},{x:.15472250479999944,y:.001347784800000043},{x:.1555262740740735,y:.007910773148148207},{x:.156107135792592,y:.01441395905185193},{x:.1564898595999994,y:.020842528600000094},{x:.15669921514074014,y:.02718166788148159},{x:.15675997205925862,y:.03341656298518529},{x:.15669689999999936,y:.03953240000000011},{x:.15669689999999936,y:.039532400000000134},{x:.15669689999999936,y:.039532400000000134},{x:.1563035739444438,y:.04625776472222235},{x:.15539676755555493,y:.05296656444444457},{x:.15399683849999934,y:.05964500750000013},{x:.1521241444444438,y:.06627930222222234},{x:.14979904305555491,y:.07285565694444456},{x:.14704189199999937,y:.07936028000000013},{x:.1438730489444438,y:.08577937972222234},{x:.1403128715555549,y:.09209916444444458},{x:.13638171749999925,y:.0983058425000001},{x:.13209994444444376,y:.10438562222222235},{x:.12748791005555482,y:.11032471194444453},{x:.12256597199999929,y:.11610932000000013},{x:.1173544879444437,y:.1217256547222223},{x:.11187381555555485,y:.12715992444444457},{x:.10614431249999925,y:.1323983375000001},{x:.10018633644444369,y:.13742710222222235},{x:.09402024505555481,y:.14223242694444457},{x:.08766639599999927,y:.14680052000000016},{x:.08114514694444372,y:.15111758972222236},{x:.07447685555555483,y:.15516984444444457},{x:.06768187949999929,y:.15894349250000012},{x:.06078057644444377,y:.16242474222222236},{x:.053793304055554894,y:.16559980194444457},{x:.046740419999999366,y:.16845488000000014},{x:.039642281944443844,y:.17097618472222234},{x:.03251924755555499,y:.17314992444444455},{x:.02539167449999948,y:.17496230750000008},{x:.018279920444443973,y:.17639954222222232},{x:.011204343055555134,y:.17744783694444452},{x:.004185299999999637,y:.17809340000000007},{x:.004185299999999614,y:.17809340000000007}],color:"primary",fill:!1},path4:{type:"path",points:[{x:-.08039130000000005,y:.0179576999999993},{x:-.08039130000000005,y:.09650599999999931}],color:"primary",fill:!0},"path4-5":{type:"path",points:[{x:.01494479999999987,y:-.055216500000000224},{x:.01494479999999987,y:.09691909999999937}],color:"primary",fill:!0},"path4-5-8":{type:"path",points:[{x:.06871169999999927,y:-.056870000000000864},{x:.06871169999999927,y:.018784499999999538}],color:"primary",fill:!0},"path4-1":{type:"path",points:[{x:-.08179359999999969,y:.09650570000000003},{x:.015771699999999722,y:.09650570000000003}],color:"primary",fill:!0},"path4-1-6":{type:"path",points:[{x:.0117995999999998,y:-.05594970000000088},{x:.06843709999999925,y:-.05594970000000088}],color:"primary",fill:!0},"rect1577-4":{type:"path",points:[{x:-.17162450000000073,y:.11125030000000025},{x:-.2688274000000015,y:.11125030000000025},{x:-.2688274000000015,y:.11469129999999961},{x:-.17162450000000073,y:.11469129999999961}],color:"primary",fill:!0},"rect1577-4-7":{type:"path",points:[{x:-.2184661999999995,y:.16159429999999997},{x:-.2184661999999995,y:.06439139999999943},{x:-.22190719999999908,y:.06439139999999943},{x:-.22190719999999908,y:.16159429999999997}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:-.0024445000000006267,y:.23933980000000044},bottom1:{type:"text",text:"{VAL}",x:.00341719999999901,y:-.23933980000000066}},refblocks:{left1:{x:-.4458008,y:.02709619999999968},right1:{x:.4458008,y:.026971799999999657}},bounds:{minX:-.473959241,maxX:.473959241,minY:-.23933980000000066,maxY:.23933980000000044,width:.947918482,height:.4786796000000011,centerX:0,centerY:-11102230246251565e-32},circles:{}},e1=e(ft).rotateRightFacingSymbol("down").labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{REF}","middle_left",{x:.02,y:.2}).changeTextAnchor("{VAL}","middle_left",{x:.5,y:-.2}).build(),r1=e(ft).rotateRightFacingSymbol("left").labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{REF}","middle_bottom",{x:0,y:.45}).changeTextAnchor("{VAL}","middle_top",{x:0,y:-.55}).build(),o1=e(ft).rotateRightFacingSymbol("right").labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),i1=e(ft).rotateRightFacingSymbol("up").labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{VAL}","middle_left",{x:.02,y:-.2}).changeTextAnchor("{REF}","middle_left",{x:.5,y:.2}).build(),kl={paths:{path40:{type:"path",points:[{x:.14,y:.04},{x:-.12,y:-.09}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.12,y:.18},{x:.14,y:.04}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.12,y:-.09},{x:-.12,y:.18}],color:"primary",fill:!1},path43:{type:"path",points:[{x:.14,y:.18},{x:.14,y:-.09}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.12,y:.04},{x:-.52,y:.04}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.52,y:.04},{x:.15,y:.04}],color:"primary",fill:!1},"path43-5":{type:"path",points:[{x:.19,y:-.09},{x:.15,y:-.09}],color:"primary",fill:!1},"path43-5-2":{type:"path",points:[{x:.19,y:-.14},{x:.19,y:-.09}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.01,y:.27},bottom1:{type:"text",text:"{VAL}",x:0,y:-.27}},refblocks:{left1:{x:-.52,y:.04},right1:{x:.52,y:.04}},bounds:{minX:-.55,maxX:.55,minY:-.27,maxY:.27,width:1.09,height:.55,centerX:0,centerY:0},circles:{}},{paths:MX,texts:CX,bounds:NX,refblocks:IX,circles:BX}=kl,U0=e(kl).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),l1=r(U0),p1={paths:{path11:{type:"path",points:[{x:-.54,y:0},{x:-.3,y:0}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:0},{x:.54,y:0}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.18,y:-.36},bottom1:{type:"text",text:"{VAL}",x:-.01,y:.43},left1:{type:"text",text:"RPM",x:0,y:-.02}},refblocks:{left1:{x:-.54,y:0},right1:{x:.54,y:0}},bounds:{minX:-.53,maxX:.53,minY:0,maxY:0,width:1.06,height:1,centerX:0,centerY:0},circles:{path1:{type:"circle",x:-.01,y:-.01,radius:.29,color:"primary",fill:!1}}},{paths:I9,texts:B9,bounds:W0,refblocks:a1,circles:q9}=p1,jt=s({primitives:[...Object.values(I9),...Object.values(q9),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"},{...B9.left1,y:.01,anchor:"center",fontSize:.2}],ports:[{...a1.left1,labels:["1"]},{...a1.right1,labels:["2"]}],size:{width:W0.width,height:W0.height},center:{x:W0.centerX,y:W0.centerY}}),{5:D9,...G9}=jt.primitives;y1=r({...jt,primitives:Object.values(G9).filter(U9)}),x1={...y1,primitives:[...y1.primitives,D9]},ct=s({primitives:[{type:"path",points:[{x:-.2,y:0},{x:0,y:0}],color:"primary",fill:!1},{type:"path",points:Array.from({length:8},(t5,o4)=>{let i3=Math.PI/2-o4*Math.PI/7,l2=.1;return{x:.1-l2*Math.cos(i3),y:l2*Math.sin(i3)}}),color:"primary",fill:!1},{type:"text",text:"{REF}",x:.125,y:0,anchor:"middle_left"}],ports:[{x:-.2,y:0,labels:["1"]}],center:{x:0,y:0}}),m1=r(ct,"down"),s1=m1.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}");s1&&(s1.anchor="middle_top");n1=m1,f1=r(ct,"left"),h1=r(ct,"up"),c1=h1.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}");c1&&(c1.anchor="middle_bottom");d1=h1,b1={paths:{path40:{type:"path",points:[{x:.44,y:.04},{x:.19,y:-.09}],color:"primary",fill:!1},path41:{type:"path",points:[{x:.19,y:.18},{x:.44,y:.04}],color:"primary",fill:!1},path42:{type:"path",points:[{x:.19,y:-.09},{x:.19,y:.18}],color:"primary",fill:!1},path44:{type:"path",points:[{x:.19,y:.04},{x:-.11,y:.04}],color:"primary",fill:!1},path45:{type:"path",points:[{x:-.43,y:.22},{x:-.11,y:.04}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.01,y:.27},bottom1:{type:"text",text:"{VAL}",x:0,y:-.27}},refblocks:{right1:{x:-.43,y:.22}},bounds:{minX:-.55,maxX:.55,minY:-.27,maxY:.27,width:1.09,height:.55,centerX:0,centerY:0},circles:{}},wt=e(b1).labelPort("right1",["1"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),zl=r(wt,"up"),Ol=zl.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),Jl=zl.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Ol.anchor="middle_bottom";Jl.anchor="middle_top";Ol.x=.4;Ol.y+=.2;Jl.y-=.3;Jl.x=.4;H0=zl,$l=v(H0),Ml=$l.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),Cl=$l.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Ml.anchor="middle_bottom";Cl.anchor="middle_top";Ml.x=.35;Ml.y+=.4;Cl.y-=.4;Cl.x=.35;_1=$l,Nl=r(wt,"left"),Il=Nl.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),Bl=Nl.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Il.anchor="middle_bottom";Bl.anchor="middle_top";Il.x=0;Il.y+=.5;Bl.y-=.6;Bl.x=0;g1=Nl,ql={paths:{path11:{type:"path",points:[{x:-.54,y:.04},{x:-.11,y:.04}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.1,y:.04},{x:.54,y:.04}],color:"primary",fill:!1},"path11-0":{type:"path",points:[{x:-.09,y:-.15},{x:-.09,y:.26}],color:"primary",fill:!1},"path11-0-3":{type:"path",points:[{x:.09,y:-.15},{x:.09,y:.26}],color:"primary",fill:!1},"path11-0-9":{type:"path",points:[{x:-.08,y:.06},{x:-.08,y:-.15},{x:.09,y:-.05},{x:-.08,y:.06}],color:"primary",fill:!0},"path11-0-9-0":{type:"path",points:[{x:.08,y:.26},{x:.08,y:.05},{x:-.09,y:.15},{x:.07,y:.26}],color:"primary",fill:!0},"path12-2":{type:"path",points:[{x:.09,y:-.06},{x:.27,y:-.17}],color:"primary",fill:!1},"path12-2-9":{type:"path",points:[{x:.27,y:-.18},{x:.27,y:-.31}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:.01,y:.42},bottom1:{type:"text",text:"{VAL}",x:-.03,y:-.42}},refblocks:{bottom1:{x:.27,y:-.31},left1:{x:-.54,y:.04},right1:{x:.54,y:.04}},bounds:{minX:-.57,maxX:.57,minY:-.42,maxY:.42,width:1.14,height:.83,centerX:0,centerY:0},circles:{path1:{type:"circle",x:0,y:.05,radius:.29,color:"primary",fill:!1}}},{paths:EL,texts:YL,bounds:XL,refblocks:LL,circles:VL}=ql,Z0=e(ql).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).labelPort("bottom1",["3"]).changeTextAnchor("{REF}","middle_bottom").build(),u1=r(Z0),v1=u1.primitives.filter(t5=>t5.type==="text"),Z9=v1.find(t5=>t5.text==="{REF}"),Q9=v1.find(t5=>t5.text==="{VAL}");Z9.y=0;Q9.y=0;w1=u1,A1={paths:{path40:{type:"path",points:[{x:.14,y:.04},{x:-.12,y:-.09}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.12,y:.18},{x:.14,y:.04}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.12,y:-.09},{x:-.12,y:.18}],color:"primary",fill:!1},path43:{type:"path",points:[{x:.14,y:.18},{x:.14,y:-.09}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.12,y:.04},{x:-.52,y:.04}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.52,y:.04},{x:.15,y:.04}],color:"primary",fill:!1},"path43-8":{type:"path",points:[{x:.14,y:.18},{x:.08,y:.18}],color:"primary",fill:!1},"path43-8-8":{type:"path",points:[{x:.14,y:-.09},{x:.08,y:-.09}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.01,y:.27},bottom1:{type:"text",text:"{VAL}",x:0,y:-.27}},refblocks:{left1:{x:-.52,y:.04},right1:{x:.52,y:.04}},bounds:{minX:-.55,maxX:.55,minY:-.27,maxY:.27,width:1.09,height:.55,centerX:0,centerY:0},circles:{}},{paths:tb,texts:P1,bounds:Q0,refblocks:S1,circles:eb}=A1,K0=s({primitives:[...Object.values(tb),...Object.values(eb),{...P1.top1,anchor:"middle_bottom"},{...P1.bottom1,anchor:"middle_top"}],ports:[{...S1.left1,labels:["1"]},{...S1.right1,labels:["2"]}],size:{width:Q0.width,height:Q0.height},center:{x:Q0.centerX,y:Q0.centerY}}),Dl=r(K0),rb=Dl.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),ob=Dl.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");rb.anchor="middle_left";ob.anchor="middle_right";R1=Dl,F1={paths:{path11:{type:"path",points:[{x:-.34,y:.22},{x:-.02,y:.01}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.23,y:.13},{x:.23,y:.4}],color:"primary",fill:!1},"path12-2":{type:"path",points:[{x:.23,y:-.08},{x:.23,y:-.35}],color:"primary",fill:!1},"path11-0":{type:"path",points:[{x:-.01,y:-.18},{x:-.01,y:.23}],color:"primary",fill:!1},"path11-0-3":{type:"path",points:[{x:.23,y:.12},{x:-.01,y:.12}],color:"primary",fill:!1},"path11-0-9":{type:"path",points:[{x:-.11,y:.13},{x:-.17,y:.04},{x:-.06,y:.03},{x:-.11,y:.13}],color:"primary",fill:!0},"path11-0-3-8":{type:"path",points:[{x:.23,y:-.08},{x:-.01,y:-.08}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.2,y:.39},bottom1:{type:"text",text:"{VAL}",x:-.03,y:-.42}},refblocks:{top1:{x:.23,y:.4},bottom1:{x:.23,y:-.35},left1:{x:-.34,y:.22}},bounds:{minX:-.37,maxX:.37,minY:-.42,maxY:.42,width:.74,height:.85,centerX:0,centerY:0},circles:{path1:{type:"circle",x:.08,y:.01,radius:.29,color:"primary",fill:!1}}},{paths:lb,texts:T1,bounds:tr,refblocks:Gl,circles:pb}=F1,er=s({primitives:[...Object.values(lb),...Object.values(pb),{...T1.top1,anchor:"middle_left"},{...T1.bottom1,anchor:"middle_right"}],ports:[{...Gl.top1,labels:["1"]},{...Gl.bottom1,labels:["2"]},{...Gl.left1,labels:["3"]}],size:{width:tr.width,height:tr.height},center:{x:tr.centerX,y:tr.centerY}}),E1=r(er),Y1=E1.primitives.filter(t5=>t5.type==="text"),ab=Y1.find(t5=>t5.text==="{REF}");ab.y=.1;X1=Y1.find(t5=>t5.text==="{VAL}");X1.y=.1;X1.x=-.4;L1=E1,V1={paths:{capsule_outer:{type:"path",points:[{x:-.44,y:.34},{x:-.45,y:.39},{x:-.46,y:.42},{x:-.49,y:.44},{x:-.52,y:.46},{x:-.56,y:.46},{x:-.6,y:.46},{x:-.63,y:.44},{x:-.65,y:.42},{x:-.67,y:.39},{x:-.68,y:.34},{x:-.68,y:-.34},{x:-.67,y:-.39},{x:-.65,y:-.42},{x:-.63,y:-.44},{x:-.6,y:-.45},{x:-.56,y:-.46},{x:-.52,y:-.45},{x:-.49,y:-.44},{x:-.46,y:-.42},{x:-.45,y:-.39},{x:-.44,y:-.34},{x:-.44,y:.34}],color:"primary",fill:!1},capsule_inner:{type:"path",points:[{x:-.51,y:.28},{x:-.52,y:.32},{x:-.53,y:.34},{x:-.56,y:.35},{x:-.57,y:.35},{x:-.58,y:.34},{x:-.6,y:.32},{x:-.61,y:.28},{x:-.61,y:-.28},{x:-.6,y:-.32},{x:-.58,y:-.34},{x:-.57,y:-.35},{x:-.56,y:-.35},{x:-.53,y:-.34},{x:-.52,y:-.32},{x:-.51,y:-.28},{x:-.51,y:.28}],color:"primary",fill:!0},usb_vertical:{type:"path",points:[{x:.1,y:-.4},{x:.1,y:.4}],color:"primary",fill:!1},usb_left_branch:{type:"path",points:[{x:.1,y:-.1},{x:-.03,y:.05},{x:-.03,y:.15}],color:"primary",fill:!1},usb_right_branch:{type:"path",points:[{x:.1,y:0},{x:.25,y:.15},{x:.25,y:.25}],color:"primary",fill:!1},usb_arrow:{type:"path",points:[{x:.05,y:.4},{x:.1,y:.5},{x:.15,y:.4},{x:.05,y:.4}],color:"primary",fill:!0},usb_square:{type:"path",points:[{x:.2,y:.25},{x:.3,y:.25},{x:.3,y:.35},{x:.2,y:.35},{x:.2,y:.25}],color:"primary",fill:!0}},circles:{usb_base:{type:"circle",x:.1,y:-.4,radius:.07,color:"primary",fill:!0},usb_tip_circle:{type:"circle",x:-.03,y:.15,radius:.04,color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:-.25,y:.7}},refblocks:{},bounds:{minX:-.75,maxX:.35,minY:-.6,maxY:.75,width:1.1,height:1.35,centerX:-.2,centerY:.08}},j1=e(V1).changeTextAnchor("{REF}","middle_bottom").build(),k1={paths:{path11:{type:"path",points:[{x:-.54,y:0},{x:-.3,y:0}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:0},{x:.54,y:0}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.18,y:-.36},bottom1:{type:"text",text:"{VAL}",x:-.01,y:.43},left1:{type:"text",text:"Var",x:-.19,y:.07}},refblocks:{left1:{x:-.54,y:0},right1:{x:.54,y:0}},bounds:{minX:-.53,maxX:.53,minY:0,maxY:0,width:1.06,height:1,centerX:0,centerY:0},circles:{path1:{type:"circle",x:-.01,y:-.01,radius:.29,color:"primary",fill:!1}}},{paths:sb,texts:Ul,bounds:rr,refblocks:z1,circles:mb}=k1,or=s({primitives:[...Object.values(sb),...Object.values(mb),{...Ul.top1,x:0,y:-.3594553499999995,anchor:"middle_top"},{...Ul.bottom1,x:0,y:.35,anchor:"middle_bottom"},{...Ul.left1,x:-.02,y:.01,fontSize:.2,anchor:"center"}],ports:[{...z1.left1,labels:["1"]},{...z1.right1,labels:["2"]}],size:{width:rr.width,height:rr.height},center:{x:rr.centerX,y:rr.centerY}}),O1=r(or),J1={paths:{path40:{type:"path",points:[{x:.08,y:.04},{x:-.18,y:-.09}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.18,y:.18},{x:.08,y:.04}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.18,y:-.09},{x:-.18,y:.18}],color:"primary",fill:!1},path43:{type:"path",points:[{x:.09,y:.17},{x:.1,y:-.09}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.2,y:.04},{x:-.52,y:.04}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.52,y:.04},{x:.21,y:.04}],color:"primary",fill:!1},"path43-6":{type:"path",points:[{x:.19,y:.17},{x:.19,y:-.09}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.01,y:.27},bottom1:{type:"text",text:"{VAL}",x:0,y:-.27}},refblocks:{left1:{x:-.52,y:.04},right1:{x:.52,y:.04}},bounds:{minX:-.55,maxX:.55,minY:-.27,maxY:.27,width:1.09,height:.55,centerX:0,centerY:0},circles:{}},{paths:fb,texts:$1,bounds:ir,refblocks:M1,circles:cb}=J1,lr=s({primitives:[...Object.values(fb),...Object.values(cb),{...$1.top1,anchor:"middle_bottom"},{...$1.bottom1,anchor:"middle_top"}],ports:[{...M1.left1,labels:["1"]},{...M1.right1,labels:["2"]}],size:{width:ir.width,height:ir.height},center:{x:ir.centerX,y:ir.centerY}}),Wl=r(lr),hb=Wl.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),db=Wl.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");hb.anchor="middle_left";db.anchor="middle_right";C1=Wl,N1={paths:{path5:{type:"path",points:[{x:-.54,y:0},{x:-.26,y:0}],color:"primary",fill:!1},path6:{type:"path",points:[{x:.27,y:0},{x:.54,y:.01}],color:"primary",fill:!1},path7:{type:"path",points:[{x:.27,y:-.23},{x:-.26,y:.24}],color:"primary",fill:!1},path8:{type:"path",points:[{x:.38,y:-.23},{x:.27,y:-.23}],color:"primary",fill:!1},path9:{type:"path",points:[{x:0,y:.14},{x:.27,y:.14},{x:.27,y:-.13},{x:-.26,y:-.13},{x:-.26,y:.14},{x:0,y:.14}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.06,y:.25},bottom1:{type:"text",text:"{VAL}",x:.01,y:-.25}},refblocks:{left1:{x:-.54,y:0},right1:{x:.54,y:.01}},bounds:{minX:-.57,maxX:.57,minY:-.25,maxY:.25,width:1.13,height:.5,centerX:0,centerY:0},circles:{}},{paths:_b,texts:I1,bounds:pr,refblocks:B1}=N1,ar=s({primitives:[...Object.values(_b),{...I1.top1,anchor:"middle_left"},{...I1.bottom1,anchor:"middle_right"}],ports:[{...B1.left1,labels:["1","-"]},{...B1.right1,labels:["2","+"]}],size:{width:pr.width,height:pr.height},center:{x:pr.centerX,y:pr.centerY}}),q1=r(ar),D1={paths:{path11:{type:"path",points:[{x:-.54,y:0},{x:-.3,y:0}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:0},{x:.54,y:0}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.18,y:-.36},bottom1:{type:"text",text:"{VAL}",x:-.01,y:.43},left1:{type:"text",text:"Var",x:0,y:-.02}},refblocks:{left1:{x:-.54,y:0},right1:{x:.54,y:0}},bounds:{minX:-.53,maxX:.53,minY:0,maxY:0,width:1.06,height:1,centerX:0,centerY:0},circles:{path1:{type:"circle",x:-.01,y:-.01,radius:.29,color:"primary",fill:!1}}},{paths:ub,texts:vb,bounds:yr,refblocks:G1,circles:wb}=D1,kt=s({primitives:[...Object.values(ub),...Object.values(wb),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"},{...vb.left1,anchor:"center",y:.02,fontSize:.2}],ports:[{...G1.left1,labels:["1"]},{...G1.right1,labels:["2"]}],size:{width:yr.width,height:yr.height},center:{x:yr.centerX,y:yr.centerY}}),{5:Ab,...Pb}=kt.primitives;U1=r({...kt,primitives:Object.values(Pb).filter(Sb)}),W1={...U1,primitives:[...U1.primitives,Ab]},ht={paths:{"path28-2":{type:"path",points:[{x:.19,y:0},{x:0,y:.09}],color:"primary",fill:!1},"path28-2-6":{type:"path",points:[{x:.19,y:0},{x:0,y:-.09}],color:"primary",fill:!1},"path29-3":{type:"path",points:[{x:.19,y:0},{x:-.23,y:0}],color:"primary",fill:!1}},texts:{right1:{type:"text",text:"{REF}",x:.25,y:0}},refblocks:{left1:{x:-.23,y:0}},bounds:{minX:-.25,maxX:.25,minY:-.09,maxY:.09,width:.5,height:.19,centerX:0,centerY:0},circles:{}};Fb=e(ht).rotateRightFacingSymbol("down").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_top").build(),H1=X(Fb,{width:.24,height:.23}),Tb=e(ht).rotateRightFacingSymbol("left").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_right").build(),Z1=X(Tb,{width:.23,height:.24}),Eb=e(ht).rotateRightFacingSymbol("right").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_left").build(),Q1=X(Eb,{width:.23,height:.24}),Yb=e(ht).rotateRightFacingSymbol("up").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_bottom").build(),K1=X(Yb,{width:.24,height:.23}),Hl={paths:{path11:{type:"path",points:[{x:-.54,y:.03},{x:-.3,y:.03}],color:"primary",fill:!1},"path11-5-5":{type:"path",points:[{x:.1,y:.13},{x:0,y:-.06},{x:-.11,y:.13}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:.03},{x:.54,y:.03}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.02,y:.4},bottom1:{type:"text",text:"{VAL}",x:-.01,y:-.4}},refblocks:{left1:{x:-.54,y:.03},right1:{x:.54,y:.03}},bounds:{minX:-.57,maxX:.57,minY:-.4,maxY:.4,width:1.14,height:.8,centerX:0,centerY:0},circles:{path1:{type:"circle",x:0,y:.04,radius:.29,color:"primary",fill:!1}}},{paths:ZV,texts:QV,bounds:KV,circles:tj,refblocks:ej}=Hl,xr=e(Hl).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),tf=r(xr),ef={paths:{path11:{type:"path",points:[{x:-.54,y:0},{x:-.3,y:0}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:0},{x:.54,y:0}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.18,y:-.36},bottom1:{type:"text",text:"{VAL}",x:-.01,y:.43},left1:{type:"text",text:"Wh",x:0,y:-.02}},refblocks:{left1:{x:-.54,y:0},right1:{x:.54,y:0}},bounds:{minX:-.53,maxX:.53,minY:0,maxY:0,width:1.06,height:1,centerX:0,centerY:0},circles:{path1:{type:"circle",x:-.01,y:-.01,radius:.29,color:"primary",fill:!1}}},{paths:Vb,texts:jb,bounds:sr,refblocks:rf,circles:kb}=ef,zt=s({primitives:[...Object.values(Vb),...Object.values(kb),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"},{...jb.left1,anchor:"center",y:.01,fontSize:.2}],ports:[{...rf.left1,labels:["1"]},{...rf.right1,labels:["2"]}],size:{width:sr.width,height:sr.height},center:{x:sr.centerX,y:sr.centerY}}),{5:zb,...Ob}=zt.primitives;of=r({...zt,primitives:Object.values(Ob).filter(Jb)}),lf={...of,primitives:[...of.primitives,zb]},pf={paths:{path11:{type:"path",points:[{x:-.54,y:0},{x:-.3,y:0}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:0},{x:.54,y:0}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.18,y:-.36},bottom1:{type:"text",text:"{VAL}",x:-.01,y:.43},left1:{type:"text",text:"W",x:0,y:-.02}},refblocks:{left1:{x:-.54,y:0},right1:{x:.54,y:0}},bounds:{minX:-.53,maxX:.53,minY:0,maxY:0,width:1.06,height:1,centerX:0,centerY:0},circles:{path1:{type:"circle",x:-.01,y:-.01,radius:.29,color:"primary",fill:!1}}},{paths:Mb,texts:Cb,bounds:mr,refblocks:af,circles:Nb}=pf,Ot=s({primitives:[...Object.values(Mb),...Object.values(Nb),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"},{...Cb.left1,anchor:"center",y:.01,fontSize:.3}],ports:[{...af.left1,labels:["1"]},{...af.right1,labels:["2"]}],size:{width:mr.width,height:mr.height},center:{x:mr.centerX,y:mr.centerY}}),{5:Ib,...Bb}=Ot.primitives;yf=r({...Ot,primitives:Object.values(Bb).filter(qb)}),xf={...yf,primitives:[...yf.primitives,Ib]},sf={paths:{path40:{type:"path",points:[{x:.14,y:.04},{x:-.12,y:-.09}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.12,y:.18},{x:.14,y:.04}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.12,y:-.09},{x:-.12,y:.18}],color:"primary",fill:!1},path43:{type:"path",points:[{x:.14,y:.18},{x:.14,y:-.09}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.12,y:.04},{x:-.52,y:.04}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.52,y:.04},{x:.15,y:.04}],color:"primary",fill:!1},"path43-8":{type:"path",points:[{x:.14,y:.18},{x:.08,y:.18}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.01,y:.27},bottom1:{type:"text",text:"{VAL}",x:0,y:-.27}},refblocks:{left1:{x:-.52,y:.04},right1:{x:.52,y:.04}},bounds:{minX:-.55,maxX:.55,minY:-.27,maxY:.27,width:1.09,height:.55,centerX:0,centerY:0},circles:{}},{paths:Gb,texts:mf,bounds:nr,refblocks:nf,circles:Ub}=sf,fr=s({primitives:[...Object.values(Gb),...Object.values(Ub),{...mf.top1,anchor:"middle_bottom"},{...mf.bottom1,anchor:"middle_top"}],ports:[{...nf.left1,labels:["1"]},{...nf.right1,labels:["2"]}],size:{width:nr.width,height:nr.height},center:{x:nr.centerX,y:nr.centerY}}),Zl=r(fr),Wb=Zl.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),Hb=Zl.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Wb.anchor="middle_left";Hb.anchor="middle_right";ff=Zl,cf={ac_voltmeter_down:op,ac_voltmeter_horz:lp,ac_voltmeter_left:ap,ac_voltmeter_right:xp,ac_voltmeter_up:mp,ac_voltmeter_vert:fp2,avalanche_diode_down:hp,avalanche_diode_horz:dp,avalanche_diode_left:_p,avalanche_diode_right:gp,avalanche_diode_up:vp,avalanche_diode_vert:Ap,backward_diode_down:Sp,backward_diode_left:Qt,backward_diode_right:Tp,backward_diode_up:Ep,battery_horz:ee,battery_vert:Vp,boxresistor_down:zp,boxresistor_left:$p,boxresistor_right:Np,boxresistor_small_down:Bp,boxresistor_small_left:Dp,boxresistor_small_right:Up,boxresistor_small_up:Hp,boxresistor_up:Kp,bridged_ground_down:ra,bridged_ground_left:la,bridged_ground_right:pe,bridged_ground_up:ya,capacitor_down:sa,capacitor_left:ma,capacitor_polarized_down:fa,capacitor_polarized_left:ca,capacitor_polarized_right:da,capacitor_polarized_up:_a,capacitor_right:ga,capacitor_up:va,constant_current_diode_down:Aa,constant_current_diode_horz:Pa,constant_current_diode_left:Ra,constant_current_diode_right:Fa,constant_current_diode_up:Ea,constant_current_diode_vert:Xa,crystal_4pin_down:La,crystal_4pin_left:Va,crystal_4pin_right:ja,crystal_4pin_up:ka,crystal_down:Oa,crystal_left:Ja,crystal_right:$a,crystal_up:Ca,current_source_down:Na,current_source_left:Ia,current_source_right:Ba,current_source_up:qa,darlington_pair_transistor_down:Da,darlington_pair_transistor_horz:Ga,darlington_pair_transistor_left:Ua,darlington_pair_transistor_right:Wa,darlington_pair_transistor_up:Ha,darlington_pair_transistor_vert:Za,dc_ammeter_horz:Tt,dc_ammeter_vert:ey,dc_voltmeter_down:oy,dc_voltmeter_horz:ly,dc_voltmeter_left:ay,dc_voltmeter_right:xy,dc_voltmeter_up:my,dc_voltmeter_vert:fy,diac_down:cy,diac_horz:hy,diac_left:dy,diac_right:by,diac_up:_y,diac_vert:gy,digital_ground_down:vy,digital_ground_left:Ay,digital_ground_right:Sy,digital_ground_up:Fy,diode_down:Ey,diode_left:Yy,diode_right:C,diode_up:Xy,dpdt_normally_closed_switch_down:Vy,dpdt_normally_closed_switch_left:jy,dpdt_normally_closed_switch_right:N,dpdt_normally_closed_switch_up:ky,dpdt_switch_down:Oy,dpdt_switch_left:Jy,dpdt_switch_right:I,dpdt_switch_up:$y,dpst_normally_closed_switch_down:Cy,dpst_normally_closed_switch_left:Ny,dpst_normally_closed_switch_right:B,dpst_normally_closed_switch_up:Iy,dpst_switch_down:qy,dpst_switch_left:Dy,dpst_switch_right:q,dpst_switch_up:Gy,ferrite_bead_down:Wy,ferrite_bead_left:Hy,ferrite_bead_right:Le,ferrite_bead_up:Xe,filled_diode_down:Qy,filled_diode_horz:tx,filled_diode_left:rx,filled_diode_right:ix,filled_diode_up:px,filled_diode_vert:yx,frequency_meter_horz:Et,frequency_meter_vert:nx,fuse_horz:Ce,fuse_vert:hx,ground_down:dx,ground_horz:bx,ground_left:_x,ground_right:gx,ground_up:ux,ground_vert:vx,gunn_diode_horz:wx,gunn_diode_vert:Ax,icled_down:Sx,icled_left:Rx,icled_right:D,icled_up:Fx,igbt_transistor_horz:Ne,igbt_transistor_vert:Yx,illuminated_push_button_normally_open_horz:Ie,illuminated_push_button_normally_open_vert:jx,inductor_down:Jx,inductor_left:$x,inductor_right:ut,inductor_up:qe,laser_diode_down:Mx,laser_diode_left:Cx,laser_diode_right:G,laser_diode_up:Nx,led_down:Dx,led_left:Gx,led_right:vt,led_up:Ge,light_dependent_resistor_horz:We,light_dependent_resistor_vert:Kx,mosfet_depletion_normally_on_horz:Ze,mosfet_depletion_normally_on_vert:os,mushroom_head_normally_open_momentary_horz:Ke,mushroom_head_normally_open_momentary_vert:as,n_channel_d_mosfet_transistor_horz:r0,n_channel_d_mosfet_transistor_vert:ns,n_channel_e_mosfet_transistor_horz:i0,n_channel_e_mosfet_transistor_vert:bs,njfet_transistor_horz:p0,njfet_transistor_vert:ws,not_connected_down:Ss,not_connected_left:Rs,not_connected_right:U,not_connected_up:Fs,npn_bipolar_transistor_down:Ts,npn_bipolar_transistor_horz:Es,npn_bipolar_transistor_left:Ys,npn_bipolar_transistor_right:Xs,npn_bipolar_transistor_up:Ls,npn_bipolar_transistor_vert:Vs,opamp_no_power_down:ks,opamp_no_power_left:zs,opamp_no_power_right:W,opamp_no_power_up:Os,opamp_with_power_down:$s,opamp_with_power_left:Ms,opamp_with_power_right:H,opamp_with_power_up:Cs,p_channel_d_mosfet_transistor_horz:f0,p_channel_d_mosfet_transistor_vert:Ds,p_channel_e_mosfet_transistor_horz:h0,p_channel_e_mosfet_transistor_vert:Zs,photodiode_horz:d0,photodiode_vert:em,pjfet_transistor_horz:_0,pjfet_transistor_vert:pm,pnp_bipolar_transistor_down:am,pnp_bipolar_transistor_horz:ym,pnp_bipolar_transistor_left:xm,pnp_bipolar_transistor_right:sm,pnp_bipolar_transistor_up:mm2,pnp_bipolar_transistor_vert:nm,potentiometer_horz:S0,potentiometer_vert:dm,potentiometer2_down:um,potentiometer2_left:vm,potentiometer2_right:Z,potentiometer2_up:wm,potentiometer3_down:Am,potentiometer3_left:Pm,potentiometer3_right:Sm,potentiometer3_up:Rm,power_factor_meter_horz:X0,power_factor_meter_vert:Ym,push_button_normally_closed_momentary_horz:V0,push_button_normally_closed_momentary_vert:jm,push_button_normally_open_momentary_horz:k0,push_button_normally_open_momentary_vert:Jm,rail_down:Mm,rail_left:Nm,rail_right:Bm,rail_up:Dm,rectifier_diode_horz:J0,rectifier_diode_vert:Wm,resistor_down:Zm,resistor_left:Km,resistor_right:en,resistor_up:on,resonator_down:pn,resonator_horz:D0,resonator_left:an,resonator_right:et,resonator_up:yn,resonator_vert:xn,schottky_diode_down:mn,schottky_diode_left:nn,schottky_diode_right:rt,schottky_diode_up:fn,silicon_controlled_rectifier_horz:G0,silicon_controlled_rectifier_vert:dn,solderjumper2_bridged12_down:bn,solderjumper2_bridged12_left:_n,solderjumper2_bridged12_right:gn,solderjumper2_bridged12_up:un,solderjumper2_down:vn,solderjumper2_left:wn,solderjumper2_right:An,solderjumper2_up:Pn,solderjumper3_bridged12_down:Sn,solderjumper3_bridged12_left:Rn,solderjumper3_bridged12_right:Fn,solderjumper3_bridged12_up:Tn,solderjumper3_bridged123_down:En,solderjumper3_bridged123_left:Yn,solderjumper3_bridged123_right:Xn,solderjumper3_bridged123_up:Ln,solderjumper3_bridged23_down:Vn,solderjumper3_bridged23_left:jn,solderjumper3_bridged23_right:kn,solderjumper3_bridged23_up:zn,solderjumper3_down:On,solderjumper3_left:Jn,solderjumper3_right:$n,solderjumper3_up:Mn,spdt_normally_closed_switch_down:Nn,spdt_normally_closed_switch_left:In,spdt_normally_closed_switch_right:xt,spdt_normally_closed_switch_up:Bn,spdt_switch_down:Dn,spdt_switch_left:Gn,spdt_switch_right:st,spdt_switch_up:Un,spst_normally_closed_switch_down:Wn,spst_normally_closed_switch_left:Hn,spst_normally_closed_switch_right:mt,spst_normally_closed_switch_up:Zn,spst_switch_down:Qn,spst_switch_left:Kn,spst_switch_right:nt,spst_switch_up:t1,square_wave_down:e1,square_wave_left:r1,square_wave_right:o1,square_wave_up:i1,step_recovery_diode_horz:U0,step_recovery_diode_vert:l1,tachometer_horz:jt,tachometer_vert:x1,testpoint_down:n1,testpoint_left:f1,testpoint_right:ct,testpoint_up:d1,tilted_ground_down:_1,tilted_ground_left:g1,tilted_ground_right:wt,tilted_ground_up:H0,triac_horz:Z0,triac_vert:w1,tunnel_diode_horz:K0,tunnel_diode_vert:R1,unijunction_transistor_horz:er,unijunction_transistor_vert:L1,usbc:j1,var_meter_horz:or,var_meter_vert:O1,varactor_diode_horz:lr,varactor_diode_vert:C1,varistor_horz:ar,varistor_vert:q1,varmeter_horz:kt,varmeter_vert:W1,vcc_down:H1,vcc_left:Z1,vcc_right:Q1,vcc_up:K1,volt_meter_horz:xr,volt_meter_vert:tf,watt_hour_meter_horz:zt,watt_hour_meter_vert:lf,wattmeter_horz:Ot,wattmeter_vert:xf,zener_diode_horz:fr,zener_diode_vert:ff},GM=Object.fromEntries(Object.keys(cf).map(t5=>[t5,t5]))}});var require_boolbase=__commonJS({"node_modules/boolbase/index.js"(exports,module){"use strict";module.exports={trueFunc:function(){return!0},falseFunc:function(){return!1}}}});function applyToPoint2(matrix2,point6){return Array.isArray(point6)?[matrix2.a*point6[0]+matrix2.c*point6[1]+matrix2.e,matrix2.b*point6[0]+matrix2.d*point6[1]+matrix2.f]:{x:matrix2.a*point6.x+matrix2.c*point6.y+matrix2.e,y:matrix2.b*point6.x+matrix2.d*point6.y+matrix2.f}}var init_applyToPoint=__esm({"node_modules/transformation-matrix/src/applyToPoint.js"(){"use strict"}});var init_fromObject=__esm({"node_modules/transformation-matrix/src/fromObject.js"(){"use strict"}});var init_fromString=__esm({"node_modules/transformation-matrix/src/fromString.js"(){"use strict"}});var init_identity=__esm({"node_modules/transformation-matrix/src/identity.js"(){"use strict"}});var init_inverse=__esm({"node_modules/transformation-matrix/src/inverse.js"(){"use strict"}});function isUndefined2(val){return typeof val>"u"}var init_utils=__esm({"node_modules/transformation-matrix/src/utils.js"(){"use strict"}});var init_isAffineMatrix=__esm({"node_modules/transformation-matrix/src/isAffineMatrix.js"(){"use strict";init_utils()}});function translate2(tx2,ty2=0){return{a:1,c:0,e:tx2,b:0,d:1,f:ty2}}var init_translate=__esm({"node_modules/transformation-matrix/src/translate.js"(){"use strict"}});function transform2(...matrices){matrices=Array.isArray(matrices[0])?matrices[0]:matrices;let multiply=(m12,m22)=>({a:m12.a*m22.a+m12.c*m22.b,c:m12.a*m22.c+m12.c*m22.d,e:m12.a*m22.e+m12.c*m22.f+m12.e,b:m12.b*m22.a+m12.d*m22.b,d:m12.b*m22.c+m12.d*m22.d,f:m12.b*m22.e+m12.d*m22.f+m12.f});switch(matrices.length){case 0:throw new Error("no matrices provided");case 1:return matrices[0];case 2:return multiply(matrices[0],matrices[1]);default:{let[m12,m22,...rest]=matrices,m3=multiply(m12,m22);return transform2(m3,...rest)}}}function compose2(...matrices){return transform2(...matrices)}var init_transform=__esm({"node_modules/transformation-matrix/src/transform.js"(){"use strict"}});function rotate2(angle,cx2,cy2){let cosAngle=cos2(angle),sinAngle=sin2(angle),rotationMatrix={a:cosAngle,c:-sinAngle,e:0,b:sinAngle,d:cosAngle,f:0};return isUndefined2(cx2)||isUndefined2(cy2)?rotationMatrix:transform2([translate2(cx2,cy2),rotationMatrix,translate2(-cx2,-cy2)])}function rotateDEG2(angle,cx2=void 0,cy2=void 0){return rotate2(angle*PI2/180,cx2,cy2)}var cos2,sin2,PI2,init_rotate=__esm({"node_modules/transformation-matrix/src/rotate.js"(){"use strict";init_utils();init_translate();init_transform();({cos:cos2,sin:sin2,PI:PI2}=Math)}});function scale2(sx2,sy2=void 0,cx2=void 0,cy2=void 0){isUndefined2(sy2)&&(sy2=sx2);let scaleMatrix={a:sx2,c:0,e:0,b:0,d:sy2,f:0};return isUndefined2(cx2)||isUndefined2(cy2)?scaleMatrix:transform2([translate2(cx2,cy2),scaleMatrix,translate2(-cx2,-cy2)])}var init_scale=__esm({"node_modules/transformation-matrix/src/scale.js"(){"use strict";init_utils();init_translate();init_transform()}});var init_shear=__esm({"node_modules/transformation-matrix/src/shear.js"(){"use strict"}});var tan2,init_skew=__esm({"node_modules/transformation-matrix/src/skew.js"(){"use strict";({tan:tan2}=Math)}});var init_toString=__esm({"node_modules/transformation-matrix/src/toString.js"(){"use strict"}});var init_smoothMatrix=__esm({"node_modules/transformation-matrix/src/smoothMatrix.js"(){"use strict"}});var init_fromTriangles=__esm({"node_modules/transformation-matrix/src/fromTriangles.js"(){"use strict";init_inverse();init_transform();init_smoothMatrix()}});var init_fromDefinition=__esm({"node_modules/transformation-matrix/src/fromDefinition.js"(){"use strict";init_fromObject();init_translate();init_scale();init_rotate();init_skew();init_shear()}});var init_fromTransformAttribute_autogenerated=__esm({"node_modules/transformation-matrix/src/fromTransformAttribute.autogenerated.js"(){"use strict"}});var init_fromTransformAttribute=__esm({"node_modules/transformation-matrix/src/fromTransformAttribute.js"(){"use strict";init_fromTransformAttribute_autogenerated()}});function decomposeTSR2(matrix2,flipX=!1,flipY2=!1){flipX?flipY2?matrix2=compose2(matrix2,scale2(-1,-1)):matrix2=compose2(matrix2,scale2(1,-1)):flipY2&&(matrix2=compose2(matrix2,scale2(-1,1)));let a2=matrix2.a,b3=matrix2.b,c3=matrix2.c,d3=matrix2.d,scaleX,scaleY,rotation4;if(a2!==0||c3!==0){let hypotAc=Math.hypot(a2,c3);scaleX=hypotAc,scaleY=(a2*d3-b3*c3)/hypotAc;let acos=Math.acos(a2/hypotAc);rotation4=c3>0?-acos:acos}else if(b3!==0||d3!==0){let hypotBd=Math.hypot(b3,d3);scaleX=(a2*d3-b3*c3)/hypotBd,scaleY=hypotBd;let acos=Math.acos(b3/hypotBd);rotation4=Math.PI/2+(d3>0?-acos:acos)}else scaleX=0,scaleY=0,rotation4=0;return flipY2&&(scaleX=-scaleX),flipX&&(scaleY=-scaleY),{translate:{tx:matrix2.e,ty:matrix2.f},scale:{sx:scaleX,sy:scaleY},rotation:{angle:rotation4}}}var init_decompose=__esm({"node_modules/transformation-matrix/src/decompose.js"(){"use strict";init_scale();init_transform()}});var init_flip=__esm({"node_modules/transformation-matrix/src/flip.js"(){"use strict"}});var init_fromMovingPoints=__esm({"node_modules/transformation-matrix/src/fromMovingPoints.js"(){"use strict";init_translate();init_applyToPoint();init_rotate();init_scale();init_transform()}});var init_src=__esm({"node_modules/transformation-matrix/src/index.js"(){"use strict";init_applyToPoint();init_fromObject();init_fromString();init_identity();init_inverse();init_isAffineMatrix();init_rotate();init_scale();init_shear();init_skew();init_toString();init_transform();init_translate();init_fromTriangles();init_smoothMatrix();init_fromDefinition();init_fromTransformAttribute();init_decompose();init_flip();init_fromMovingPoints()}});var init_parsel=__esm({"node_modules/parsel-js/dist/parsel.js"(){"use strict"}});var require_performance_now=__commonJS({"node_modules/performance-now/lib/performance-now.js"(exports,module){"use strict";(function(){var getNanoSeconds,hrtime,loadTime,moduleLoadTime,nodeLoadTime,upTime;typeof performance<"u"&&performance!==null&&performance.now?module.exports=function(){return performance.now()}:typeof process<"u"&&process!==null&&process.hrtime?(module.exports=function(){return(getNanoSeconds()-nodeLoadTime)/1e6},hrtime=process.hrtime,getNanoSeconds=function(){var hr3;return hr3=hrtime(),hr3[0]*1e9+hr3[1]},moduleLoadTime=getNanoSeconds(),upTime=process.uptime()*1e9,nodeLoadTime=moduleLoadTime-upTime):Date.now?(module.exports=function(){return Date.now()-loadTime},loadTime=Date.now()):(module.exports=function(){return new Date().getTime()-loadTime},loadTime=new Date().getTime())}).call(exports)}});var init_chunk_GIGMPRPV=__esm({"node_modules/circuit-json-to-connectivity-map/node_modules/@tscircuit/math-utils/dist/chunk-GIGMPRPV.js"(){"use strict"}});var init_chunk_LL3GOPYX=__esm({"node_modules/circuit-json-to-connectivity-map/node_modules/@tscircuit/math-utils/dist/chunk-LL3GOPYX.js"(){"use strict"}});function doesLineIntersectLine([a12,a2],[b12,b22],{lineThickness=0}={}){return lineThickness===0?doSegmentsIntersect(a12,a2,b12,b22):segmentsDistance(a12,a2,b12,b22)<=lineThickness}function doSegmentsIntersect(p12,q12,p2,q22){let o12=orientation(p12,q12,p2),o22=orientation(p12,q12,q22),o32=orientation(p2,q22,p12),o4=orientation(p2,q22,q12);return!!(o12!==o22&&o32!==o4||o12===0&&onSegment(p12,p2,q12)||o22===0&&onSegment(p12,q22,q12)||o32===0&&onSegment(p2,p12,q22)||o4===0&&onSegment(p2,q12,q22))}function orientation(p2,q4,r4){let val=(q4.y-p2.y)*(r4.x-q4.x)-(q4.x-p2.x)*(r4.y-q4.y);return val===0?0:val>0?1:2}function onSegment(p2,q4,r4){return q4.x<=Math.max(p2.x,r4.x)&&q4.x>=Math.min(p2.x,r4.x)&&q4.y<=Math.max(p2.y,r4.y)&&q4.y>=Math.min(p2.y,r4.y)}function segmentsDistance(a12,a2,b12,b22){if(a12.x===a2.x&&a12.y===a2.y)return pointToSegmentDistance(a12,b12,b22);if(b12.x===b22.x&&b12.y===b22.y)return pointToSegmentDistance(b12,a12,a2);if(doSegmentsIntersect(a12,a2,b12,b22))return 0;let distances=[pointToSegmentDistance(a12,b12,b22),pointToSegmentDistance(a2,b12,b22),pointToSegmentDistance(b12,a12,a2),pointToSegmentDistance(b22,a12,a2)];return Math.min(...distances)}function pointToSegmentDistance(p2,v4,w4){let l2=(w4.x-v4.x)**2+(w4.y-v4.y)**2;if(l2===0)return distance2(p2,v4);let t5=((p2.x-v4.x)*(w4.x-v4.x)+(p2.y-v4.y)*(w4.y-v4.y))/l2;t5=Math.max(0,Math.min(1,t5));let projection={x:v4.x+t5*(w4.x-v4.x),y:v4.y+t5*(w4.y-v4.y)};return distance2(p2,projection)}function distance2(p12,p2){let dx2=p12.x-p2.x,dy2=p12.y-p2.y;return Math.sqrt(dx2*dx2+dy2*dy2)}var init_chunk_CHQOCSFB=__esm({"node_modules/circuit-json-to-connectivity-map/node_modules/@tscircuit/math-utils/dist/chunk-CHQOCSFB.js"(){"use strict"}});var init_chunk_MHHTZHOJ=__esm({"node_modules/circuit-json-to-connectivity-map/node_modules/@tscircuit/math-utils/dist/chunk-MHHTZHOJ.js"(){"use strict"}});var init_dist3=__esm({"node_modules/circuit-json-to-connectivity-map/node_modules/@tscircuit/math-utils/dist/index.js"(){"use strict";init_chunk_GIGMPRPV();init_chunk_LL3GOPYX();init_chunk_CHQOCSFB();init_chunk_MHHTZHOJ()}});function findConnectedNetworks(connections){let networks=new Map,netCounter=0;function getOrCreateNetwork(nodeId){for(let[,network]of networks)if(network.has(nodeId))return network;let newNetwork=new Set;return networks.set(`connectivity_net${netCounter++}`,newNetwork),newNetwork}for(let connection of connections){let network=null;for(let nodeId of connection){if(!network)network=getOrCreateNetwork(nodeId);else if(!network.has(nodeId)){let existingNetwork=getOrCreateNetwork(nodeId);if(existingNetwork!==network){for(let node of existingNetwork)network.add(node);networks.delete(Array.from(networks.entries()).find(([,net])=>net===existingNetwork)[0])}}network.add(nodeId)}}return Object.fromEntries(Array.from(networks.entries()).map(([netId,connectedNodes])=>[netId,Array.from(connectedNodes)]))}var ConnectivityMap,getFullConnectivityMapFromCircuitJson,PcbConnectivityMap,init_dist4=__esm({"node_modules/circuit-json-to-connectivity-map/dist/index.js"(){"use strict";init_dist3();ConnectivityMap=class{constructor(netMap){__publicField(this,"netMap");__publicField(this,"idToNetMap");this.netMap=netMap,this.idToNetMap={};for(let[netId,ids]of Object.entries(netMap))for(let id2 of ids)this.idToNetMap[id2]=netId}addConnections(connections){for(let connection of connections){let existingNets=new Set;for(let id2 of connection){let existingNetId=this.idToNetMap[id2];existingNetId&&existingNets.add(existingNetId)}let targetNetId;if(existingNets.size===0)targetNetId=`connectivity_net${Object.keys(this.netMap).length}`,this.netMap[targetNetId]=[];else if(existingNets.size===1)targetNetId=existingNets.values().next().value??`connectivity_net${Object.keys(this.netMap).length}`;else{targetNetId=existingNets.values().next().value??`connectivity_net${Object.keys(this.netMap).length}`;for(let netId of existingNets)if(netId!==targetNetId){this.netMap[targetNetId].push(...this.netMap[netId]),this.netMap[netId]=this.netMap[targetNetId];for(let id2 of this.netMap[targetNetId])this.idToNetMap[id2]=targetNetId}}for(let id2 of connection)this.netMap[targetNetId].includes(id2)||this.netMap[targetNetId].push(id2),this.idToNetMap[id2]=targetNetId}}getIdsConnectedToNet(netId){return this.netMap[netId]||[]}getNetConnectedToId(id2){return this.idToNetMap[id2]}areIdsConnected(id1,id2){if(id1===id2)return!0;let netId1=this.getNetConnectedToId(id1);if(!netId1)return!1;let netId2=this.getNetConnectedToId(id2);return netId2?netId1===netId2||netId2===id1||netId2===id1:!1}areAllIdsConnected(ids){let netId=this.getNetConnectedToId(ids[0]);for(let id2 of ids){let nextNetId=this.getNetConnectedToId(id2);if(nextNetId===void 0||nextNetId!==netId)return!1}return!0}},getFullConnectivityMapFromCircuitJson=circuitJson=>{let connections=[];for(let element of circuitJson)if(element.type==="source_trace")connections.push([element.source_trace_id,...element.connected_source_port_ids??[],...element.connected_source_net_ids??[]].filter(Boolean));else if(element.type==="pcb_port"){let{pcb_port_id,source_port_id}=element;source_port_id&&pcb_port_id&&connections.push([source_port_id,pcb_port_id])}else if(element.type==="pcb_smtpad"){let{pcb_smtpad_id,pcb_port_id}=element;pcb_port_id&&pcb_smtpad_id&&connections.push([pcb_smtpad_id,pcb_port_id])}else if(element.type==="pcb_plated_hole"){let{pcb_plated_hole_id,pcb_port_id}=element;pcb_port_id&&pcb_plated_hole_id&&connections.push([pcb_plated_hole_id,pcb_port_id])}else if(element.type==="pcb_trace"){let{pcb_trace_id,source_trace_id}=element,route=Array.isArray(element.route)?element.route.filter(rp2=>rp2&&rp2.route_type==="wire"):[];if(source_trace_id&&pcb_trace_id&&connections.push([pcb_trace_id,source_trace_id]),Array.isArray(route)){let startId=route.find(rp2=>rp2?.start_pcb_port_id)?.start_pcb_port_id,endId=route.find(rp2=>rp2?.end_pcb_port_id)?.end_pcb_port_id;startId&&pcb_trace_id&&endId&&connections.push([startId,pcb_trace_id,endId])}}else if(element.type==="pcb_via"){let{pcb_via_id,pcb_trace_id}=element;pcb_trace_id&&pcb_via_id&&connections.push([pcb_via_id,pcb_trace_id])}else if(element.type==="source_component"&&element.internally_connected_source_port_ids)for(let portGroup of element.internally_connected_source_port_ids)connections.push(portGroup);let netMap=findConnectedNetworks(connections);return new ConnectivityMap(netMap)},PcbConnectivityMap=class{constructor(circuitJson){__publicField(this,"circuitJson");__publicField(this,"traceIdToElm");__publicField(this,"portIdToElm");__publicField(this,"connMap");this.circuitJson=circuitJson||[],this.traceIdToElm=new Map,this.portIdToElm=new Map,circuitJson?(this._buildTraceMap(),this._buildPortMap(),this.connMap=this._buildTraceConnectivityMap()):this.connMap=new ConnectivityMap({})}_buildPortMap(){for(let element of this.circuitJson)element.type==="pcb_port"&&this.portIdToElm.set(element.pcb_port_id,element)}_buildTraceMap(){for(let element of this.circuitJson)element.type==="pcb_trace"&&this.traceIdToElm.set(element.pcb_trace_id,element)}_buildTraceConnectivityMap(){let connections=[],traceIds=Array.from(this.traceIdToElm.keys());for(let i3=0;i3<traceIds.length;i3++)for(let j3=i3+1;j3<traceIds.length;j3++){let trace1=this.traceIdToElm.get(traceIds[i3]),trace2=this.traceIdToElm.get(traceIds[j3]);this._arePcbTracesConnected(trace1,trace2)&&connections.push([traceIds[i3],traceIds[j3]])}for(let port of this.portIdToElm.values())for(let trace of this.traceIdToElm.values())for(let rp2 of trace.route)rp2.route_type==="wire"&&(rp2.start_pcb_port_id===port.pcb_port_id?connections.push([port.pcb_port_id,trace.pcb_trace_id]):rp2.end_pcb_port_id===port.pcb_port_id&&connections.push([trace.pcb_trace_id,port.pcb_port_id]));return new ConnectivityMap(findConnectedNetworks(connections))}addTrace(trace){this.traceIdToElm.set(trace.pcb_trace_id,trace);let connections=[];for(let rp2 of trace.route)rp2.route_type==="wire"&&(rp2.start_pcb_port_id&&connections.push([rp2.start_pcb_port_id,trace.pcb_trace_id]),rp2.end_pcb_port_id&&connections.push([rp2.end_pcb_port_id,trace.pcb_trace_id]));this.connMap.addConnections(connections)}_arePcbTracesConnected(trace1,trace2){for(let i3=0;i3<trace1.route.length-1;i3++){let segment1A=trace1.route[i3],segment1B=trace1.route[i3+1];if(segment1A.route_type==="wire"&&segment1B.route_type==="wire")for(let j3=0;j3<trace2.route.length-1;j3++){let segment2A=trace2.route[j3],segment2B=trace2.route[j3+1];if(segment2A.route_type!=="wire"||segment2B.route_type!=="wire")continue;if(doesLineIntersectLine([segment1A,segment1B],[segment2A,segment2B],{lineThickness:(segment1A.width+segment2A.width)/2}))return!0}}return!1}areTracesConnected(traceId1,traceId2){return this.connMap.areIdsConnected(traceId1,traceId2)}getAllTracesConnectedToTrace(traceId){let netId=this.connMap.getNetConnectedToId(traceId);return netId?this.connMap.getIdsConnectedToNet(netId).filter(id2=>this.traceIdToElm.has(id2)).map(id2=>this.traceIdToElm.get(id2)):[]}getAllTracesConnectedToPort(portId){let netId=this.connMap.getNetConnectedToId(portId);return netId?this.connMap.getIdsConnectedToNet(netId).filter(id2=>this.traceIdToElm.has(id2)).map(id2=>this.traceIdToElm.get(id2)):[]}}}});var calculateElbowBends,calculateElbow,init_dist5=__esm({"node_modules/calculate-elbow/dist/index.js"(){"use strict";calculateElbowBends=(p12,p2,overshootAmount)=>{let result=[{x:p12.x,y:p12.y}],midX=(p12.x+p2.x)/2,midY=(p12.y+p2.y)/2,p2Target={x:p2.x,y:p2.y};switch(p2.facingDirection){case"x+":p2Target.x+=overshootAmount;break;case"x-":p2Target.x-=overshootAmount;break;case"y+":p2Target.y+=overshootAmount;break;case"y-":p2Target.y-=overshootAmount;break}let startDir=p12.facingDirection??"none",endDir=p2.facingDirection??"none",push=pt3=>{let last=result[result.length-1];(last.x!==pt3.x||last.y!==pt3.y)&&result.push(pt3)},yAligned=Math.abs(p12.y-p2.y)<=Math.max(1e-6,overshootAmount*.1),xAligned=Math.abs(p12.x-p2.x)<=Math.max(1e-6,overshootAmount*.1);if(startDir==="none"&&endDir==="none")push({x:midX,y:p12.y}),push({x:midX,y:p2.y});else if(startDir==="x+"&&endDir==="y+")p12.x>p2.x&&p12.y<p2.y?(push({x:p12.x+overshootAmount,y:p12.y}),push({x:p12.x+overshootAmount,y:p2.y+overshootAmount}),push({x:p2.x,y:p2.y+overshootAmount})):!xAligned&&!yAligned&&p12.x<p2.x&&p12.y>p2.y?push({x:p2.x,y:p12.y}):xAligned?(push({x:p12.x+overshootAmount,y:p12.y}),push({x:p12.x+overshootAmount,y:p2.y+overshootAmount}),push({x:p2.x,y:p2.y+overshootAmount})):p12.x<p2.x?(push({x:midX,y:p12.y}),push({x:midX,y:p2Target.y}),push({x:p2.x,y:p2Target.y})):p12.y<=p2.y+overshootAmount?(push({x:p12.x+overshootAmount,y:p12.y}),push({x:p12.x+overshootAmount,y:p12.y+overshootAmount}),push({x:p2.x,y:p12.y+overshootAmount}),push({x:p2.x,y:p2.y})):(push({x:p12.x+overshootAmount,y:p12.y}),push({x:p12.x+overshootAmount,y:(p12.y+p2.y)/2}),push({x:p2.x,y:(p12.y+p2.y)/2}));else if(startDir==="x+"&&endDir==="x+"&&!yAligned){let commonX=Math.max(p12.x+overshootAmount,p2Target.x);push({x:commonX,y:p12.y}),push({x:commonX,y:p2.y})}else if(startDir==="x+"&&endDir==="x+"&&yAligned)push({x:p12.x+overshootAmount,y:p12.y}),push({x:p12.x+overshootAmount,y:p12.y+overshootAmount}),push({x:p2.x+overshootAmount,y:p12.y+overshootAmount}),push({x:p2.x+overshootAmount,y:p2.y});else if(startDir==="x+"&&endDir==="y-")if(xAligned&&p12.y<=p2.y)push({x:p12.x+overshootAmount,y:p12.y}),push({x:p12.x+overshootAmount,y:midY}),push({x:p2.x,y:midY});else if(xAligned&&p12.y>p2.y)push({x:p12.x+overshootAmount,y:p12.y}),push({x:p12.x+overshootAmount,y:p2.y-overshootAmount}),push({x:p2.x,y:p2.y-overshootAmount});else if(p12.x<p2.x&&p12.y<p2.y)push({x:p2.x,y:p12.y});else if(p12.x>p2.x&&p12.y<p2.y){let p1OvershootX=p12.x+overshootAmount;push({x:p1OvershootX,y:p12.y}),push({x:p1OvershootX,y:midY}),push({x:p2.x,y:midY})}else if(p12.x>p2.x&&p12.y>p2.y){let p1OvershootX=p12.x+overshootAmount;push({x:p1OvershootX,y:p12.y}),push({x:p1OvershootX,y:p2Target.y}),push({x:p2.x,y:p2Target.y})}else p12.y===p2.y?(push({x:p12.x+overshootAmount,y:p12.y}),push({x:p12.x+overshootAmount,y:p12.y-overshootAmount}),push({x:p2.x,y:p12.y-overshootAmount})):(push({x:midX,y:p12.y}),push({x:midX,y:p2Target.y}),push({x:p2.x,y:p2Target.y}));else if(startDir==="x+"&&endDir==="x-"&&p12.x+overshootAmount>=p2.x-overshootAmount&&!yAligned){let p1OvershootX=p12.x+overshootAmount;push({x:p1OvershootX,y:p12.y}),push({x:p1OvershootX,y:midY}),push({x:p2Target.x,y:midY}),push({x:p2Target.x,y:p2Target.y})}else startDir==="x+"&&endDir==="x-"&&yAligned&&p2.x>p12.x||(startDir==="x+"&&endDir==="x-"&&yAligned?(push({x:p12.x+overshootAmount,y:p12.y}),push({x:p12.x+overshootAmount,y:p12.y+overshootAmount}),push({x:p2.x-overshootAmount,y:p12.y+overshootAmount}),push({x:p2.x-overshootAmount,y:p12.y})):(startDir==="x+"&&push({x:p12.x+overshootAmount,y:p12.y}),push({x:midX,y:result[result.length-1].y}),push({x:midX,y:p2Target.y}),push({x:p2Target.x,y:p2Target.y})));return push({x:p2.x,y:p2.y}),result},calculateElbow=(point1,point23,options={})=>{let p12=point1,p2=point23,orderFlipped=!1;(p12.x>p2.x||p12.x===p2.x&&p12.y>p2.y)&&(orderFlipped=!0,[p12,p2]=[p2,p12]);let mirrorX=p12.facingDirection==="x-",mirrorY=p12.facingDirection==="y-",mirrorPoint=pt3=>{let x3=mirrorX?p12.x-(pt3.x-p12.x):pt3.x,y3=mirrorY?p12.y-(pt3.y-p12.y):pt3.y,facing=pt3.facingDirection;return mirrorX&&(facing==="x+"?facing="x-":facing==="x-"&&(facing="x+")),mirrorY&&(facing==="y+"?facing="y-":facing==="y-"&&(facing="y+")),{x:x3,y:y3,facingDirection:facing}},rotateCW=(pt3,centre)=>{let dx2=pt3.x-centre.x,dy2=pt3.y-centre.y,x3=centre.x+dy2,y3=centre.y-dx2,facing=pt3.facingDirection;switch(facing){case"x+":facing="y-";break;case"y-":facing="x-";break;case"x-":facing="y+";break;case"y+":facing="x+";break}return{x:x3,y:y3,facingDirection:facing}},rotateCCW=(pt3,centre)=>{let dx2=pt3.x-centre.x,dy2=pt3.y-centre.y;return{x:centre.x-dy2,y:centre.y+dx2}},mp1=mirrorX||mirrorY?mirrorPoint(p12):p12,mp2=mirrorX||mirrorY?mirrorPoint(p2):p2,rp1=mp1,rp2=mp2,rotated=!1;mp1.facingDirection==="y+"&&(rotated=!0,rp1={...mp1,facingDirection:"x+"},rp2=rotateCW(mp2,mp1));let overshootAmount=options?.overshoot??.1*Math.max(Math.abs(rp1.x-rp2.x),Math.abs(rp1.y-rp2.y)),result=calculateElbowBends(rp1,rp2,overshootAmount);return rotated&&(result=result.map(pt3=>rotateCCW(pt3,rp1))),(mirrorX||mirrorY)&&(result=result.map(({x:x3,y:y3})=>({x:mirrorX?p12.x-(x3-p12.x):x3,y:mirrorY?p12.y-(y3-p12.y):y3}))),orderFlipped?result.reverse():result}}});function connect(map,a2,b3){if(!a2||!b3)return;let setA=map.get(a2);setA||(setA=new Set,map.set(a2,setA)),setA.add(b3);let setB=map.get(b3);setB||(setB=new Set,map.set(b3,setB)),setB.add(a2)}function buildSubtree(soup,opts){if(!opts.subcircuit_id&&!opts.source_group_id)return[...soup];let idMap=new Map;for(let elm of soup){let idVal=elm[`${elm.type}_id`];typeof idVal=="string"&&idMap.set(idVal,elm)}let adj=new Map;for(let elm of soup){let entries=Object.entries(elm);for(let[key,val]of entries)if(key!=="parent_source_group_id"){if(key.endsWith("_id")&&typeof val=="string"){let other=idMap.get(val);connect(adj,elm,other)}else if(key.endsWith("_ids")&&Array.isArray(val)){for(let v4 of val)if(typeof v4=="string"){let other=idMap.get(v4);connect(adj,elm,other)}}}}let queue=[],included=new Set;for(let elm of soup)(opts.subcircuit_id&&elm.subcircuit_id===opts.subcircuit_id||opts.source_group_id&&(elm.source_group_id===opts.source_group_id||Array.isArray(elm.member_source_group_ids)&&elm.member_source_group_ids.includes(opts.source_group_id)))&&(queue.push(elm),included.add(elm));for(;queue.length>0;){let elm=queue.shift(),neighbors=adj.get(elm);if(neighbors)for(let n3 of neighbors)included.has(n3)||(included.add(n3),queue.push(n3))}return soup.filter(e4=>included.has(e4))}function createIdKey(element){let type=element.type;return`${type}:${element[`${type}_id`]}`}function getReadableNameForPcbTrace(soup,pcb_trace_id){let pcbTrace=cju(soup).pcb_trace.get(pcb_trace_id);if(!pcbTrace)return`trace[${pcb_trace_id}]`;let connectedPcbPortIds=pcbTrace.route.flatMap(point6=>[point6.start_pcb_port_id,point6.end_pcb_port_id]).filter(Boolean);if(connectedPcbPortIds.length===0)return`trace[${pcb_trace_id}]`;function getComponentAndPortInfo(pcb_port_id){let pcbPort=cju(soup).pcb_port.get(pcb_port_id);if(!pcbPort)return null;let pcbComponent=cju(soup).pcb_component.get(pcbPort.pcb_component_id);if(!pcbComponent)return null;let sourceComponent=cju(soup).source_component.get(pcbComponent.source_component_id);if(!sourceComponent)return null;let sourcePort=cju(soup).source_port.get(pcbPort.source_port_id),portHint=sourcePort?.port_hints?sourcePort.port_hints[1]:"";return{componentName:sourceComponent.name,portHint}}return`trace[${connectedPcbPortIds.map(portId=>{let info=getComponentAndPortInfo(portId);return info?`.${info.componentName} > port.${info.portHint}`:`port[${portId}]`}).join(", ")}]`}function getReadableNameForPcbSmtpad(soup,pcb_smtpad_id){let pcbSmtpad=cju(soup).pcb_smtpad.get(pcb_smtpad_id);return!pcbSmtpad||!pcbSmtpad.pcb_port_id?`smtpad[${pcb_smtpad_id}]`:getReadableNameForPcbPort(soup,pcbSmtpad.pcb_port_id)}function stringHash(str){let hash=0;if(str.length==0)return hash;for(var i3=0;i3<str.length;i3++){var char=str.charCodeAt(i3);hash=(hash<<5)-hash+char,hash=hash&hash}return Math.abs(hash)}function getMinimumFlexContainer(children,options={}){if(children.length===0)return{width:0,height:0};let direction2=options.direction??"row",columnGap=options.columnGap??0,rowGap=options.rowGap??0;if(direction2==="row"||direction2==="row-reverse"){let width=children.reduce((sum,c3)=>sum+c3.width,0)+columnGap*Math.max(0,children.length-1),height=children.reduce((max,c3)=>Math.max(max,c3.height),0);return{width,height}}else{let height=children.reduce((sum,c3)=>sum+c3.height,0)+rowGap*Math.max(0,children.length-1);return{width:children.reduce((max,c3)=>Math.max(max,c3.width),0),height}}}var cju,su2,cju_default,cjuIndexed,rotateClockwise,rotateCounterClockwise,rotateDirection,oppositeSide,transformSchematicElement,transformSchematicElements,transformPCBElement,transformPCBElements,getElementId,getElementById2,getReadableNameForPcbPort,getReadableNameForElement,getBoundsOfPcbElements,nice_color_palettes,getDebugLayoutObject,isTruthy,findBoundsAndCenter,getPrimaryId,repositionPcbComponentTo,findAllDescendantGroupIds,repositionPcbGroupTo,repositionSchematicComponentTo,findAllDescendantGroupIds2,repositionSchematicGroupTo,getCircuitJsonTree,init_dist6=__esm({"node_modules/@tscircuit/circuit-json-util/dist/index.js"(){"use strict";init_dist();init_dist();init_src();init_parsel();init_src();init_src();init_src();init_src();cju=((circuitJsonInput,options={})=>{let circuitJson=circuitJsonInput,internalStore=circuitJson._internal_store;if(!internalStore){internalStore={counts:{},editCount:0},circuitJson._internal_store=internalStore;for(let elm of circuitJson){let type=elm.type,idVal=elm[`${type}_id`];if(!idVal)continue;let idNum=Number.parseInt(idVal.split("_").pop());Number.isNaN(idNum)||(internalStore.counts[type]=Math.max(internalStore.counts[type]??0,idNum))}}return new Proxy({},{get:(proxy_target,prop)=>{if(prop==="toArray")return()=>(circuitJson.editCount=internalStore.editCount,circuitJson);if(prop==="editCount")return internalStore.editCount;if(prop==="subtree")return opts=>cju(buildSubtree(circuitJson,opts),options);let component_type=prop;return{get:id2=>circuitJson.find(e4=>e4.type===component_type&&e4[`${component_type}_id`]===id2),getUsing:using=>{let keys=Object.keys(using);if(keys.length!==1)throw new Error("getUsing requires exactly one key, e.g. { pcb_component_id }");let join_key=keys[0],join_type=join_key.replace("_id",""),joiner=circuitJson.find(e4=>e4.type===join_type&&e4[join_key]===using[join_key]);return joiner?circuitJson.find(e4=>e4.type===component_type&&e4[`${component_type}_id`]===joiner[`${component_type}_id`]):null},getWhere:where=>{let keys=Object.keys(where);return circuitJson.find(e4=>e4.type===component_type&&keys.every(key=>e4[key]===where[key]))},list:where=>{let keys=where?Object.keys(where):[];return circuitJson.filter(e4=>e4.type===component_type&&keys.every(key=>e4[key]===where[key]))},insert:elm=>{var _a359;(_a359=internalStore.counts)[component_type]??(_a359[component_type]=-1),internalStore.counts[component_type]++;let index=internalStore.counts[component_type],newElm={type:component_type,[`${component_type}_id`]:`${component_type}_${index}`,...elm};return options.validateInserts&&(dist_exports[component_type]??any_soup_element).parse(newElm),circuitJson.push(newElm),internalStore.editCount++,newElm},delete:id2=>{let elm=circuitJson.find(e4=>e4[`${component_type}_id`]===id2);elm&&(circuitJson.splice(circuitJson.indexOf(elm),1),internalStore.editCount++)},update:(id2,newProps)=>{let elm=circuitJson.find(e4=>e4.type===component_type&&e4[`${component_type}_id`]===id2);return elm?(Object.assign(elm,newProps),internalStore.editCount++,elm):null},select:selector=>{if(component_type==="source_component")return circuitJson.find(e4=>e4.type==="source_component"&&e4.name===selector.replace(/\./g,""));if(component_type==="pcb_port"||component_type==="source_port"||component_type==="schematic_port"){let[component_name,port_selector]=selector.replace(/\./g,"").split(/[\s\>]+/),source_component=circuitJson.find(e4=>e4.type==="source_component"&&e4.name===component_name);if(!source_component)return null;let source_port2=circuitJson.find(e4=>e4.type==="source_port"&&e4.source_component_id===source_component.source_component_id&&(e4.name===port_selector||(e4.port_hints??[]).includes(port_selector)));if(!source_port2)return null;if(component_type==="source_port")return source_port2;if(component_type==="pcb_port")return circuitJson.find(e4=>e4.type==="pcb_port"&&e4.source_port_id===source_port2.source_port_id);if(component_type==="schematic_port")return circuitJson.find(e4=>e4.type==="schematic_port"&&e4.source_port_id===source_port2.source_port_id)}}}}})});cju.unparsed=cju;su2=cju,cju_default=cju;cjuIndexed=((soup,options={})=>{let internalStore=soup._internal_store_indexed;if(!internalStore){internalStore={counts:{},editCount:0,indexes:{}};for(let elm of soup){let type=elm.type,idVal=elm[`${type}_id`];if(!idVal)continue;let idNum=Number.parseInt(idVal.split("_").pop()||"");Number.isNaN(idNum)||(internalStore.counts[type]=Math.max(internalStore.counts[type]??0,idNum))}let indexConfig=options.indexConfig||{},indexes=internalStore.indexes;if(indexConfig.byId&&(indexes.byId=new Map),indexConfig.byType&&(indexes.byType=new Map),indexConfig.byRelation&&(indexes.byRelation=new Map),indexConfig.bySubcircuit&&(indexes.bySubcircuit=new Map),indexConfig.byCustomField&&indexConfig.byCustomField.length>0){indexes.byCustomField=new Map;for(let field of indexConfig.byCustomField)indexes.byCustomField.set(field,new Map)}for(let element of soup){if(indexConfig.byId){let idKey=createIdKey(element);indexes.byId.set(idKey,element)}if(indexConfig.byType){let elementsOfType=indexes.byType.get(element.type)||[];elementsOfType.push(element),indexes.byType.set(element.type,elementsOfType)}if(indexConfig.byRelation){let elementEntries=Object.entries(element);for(let[key,value]of elementEntries)if(key.endsWith("_id")&&key!==`${element.type}_id`&&typeof value=="string"){let relationTypeMap=indexes.byRelation.get(key)||new Map,relatedElements=relationTypeMap.get(value)||[];relatedElements.push(element),relationTypeMap.set(value,relatedElements),indexes.byRelation.set(key,relationTypeMap)}}if(indexConfig.bySubcircuit&&"subcircuit_id"in element){let subcircuitId=element.subcircuit_id;if(subcircuitId&&typeof subcircuitId=="string"){let subcircuitElements=indexes.bySubcircuit.get(subcircuitId)||[];subcircuitElements.push(element),indexes.bySubcircuit.set(subcircuitId,subcircuitElements)}}if(indexConfig.byCustomField&&indexes.byCustomField){for(let field of indexConfig.byCustomField)if(field in element){let fieldValue=element[field];if(fieldValue!==void 0&&(typeof fieldValue=="string"||typeof fieldValue=="number")){let fieldValueStr=String(fieldValue),fieldMap=indexes.byCustomField.get(field),elementsWithFieldValue=fieldMap.get(fieldValueStr)||[];elementsWithFieldValue.push(element),fieldMap.set(fieldValueStr,elementsWithFieldValue)}}}}soup._internal_store_indexed=internalStore}return new Proxy({},{get:(proxy_target,prop)=>{if(prop==="toArray")return()=>(soup.editCount=internalStore.editCount,soup);if(prop==="editCount")return internalStore.editCount;let component_type=prop;return{get:id2=>{let indexConfig=options.indexConfig||{};return indexConfig.byId&&internalStore.indexes.byId?internalStore.indexes.byId.get(`${component_type}:${id2}`)||null:indexConfig.byType&&internalStore.indexes.byType?(internalStore.indexes.byType.get(component_type)||[]).find(e4=>e4[`${component_type}_id`]===id2)||null:soup.find(e4=>e4.type===component_type&&e4[`${component_type}_id`]===id2)||null},getUsing:using=>{let indexConfig=options.indexConfig||{},keys=Object.keys(using);if(keys.length!==1)throw new Error("getUsing requires exactly one key, e.g. { pcb_component_id }");let join_key=keys[0],join_type=join_key.replace("_id","");if(indexConfig.byRelation&&internalStore.indexes.byRelation){let relationMap=internalStore.indexes.byRelation.get(join_key);if(relationMap){let joiner2=(relationMap.get(using[join_key])||[]).find(e4=>e4.type===join_type);if(!joiner2)return null;let joinerId=joiner2[`${component_type}_id`];return indexConfig.byId&&internalStore.indexes.byId?internalStore.indexes.byId.get(`${component_type}:${joinerId}`)||null:indexConfig.byType&&internalStore.indexes.byType?(internalStore.indexes.byType.get(component_type)||[]).find(e4=>e4[`${component_type}_id`]===joinerId)||null:soup.find(e4=>e4.type===component_type&&e4[`${component_type}_id`]===joinerId)||null}}let joiner=soup.find(e4=>e4.type===join_type&&e4[join_key]===using[join_key]);return joiner&&soup.find(e4=>e4.type===component_type&&e4[`${component_type}_id`]===joiner[`${component_type}_id`])||null},getWhere:where=>{let indexConfig=options.indexConfig||{},keys=Object.keys(where);if(keys.length===1&&indexConfig.byCustomField&&internalStore.indexes.byCustomField){let field=keys[0],fieldMap=internalStore.indexes.byCustomField.get(field);if(fieldMap){let fieldValue=String(where[field]);return(fieldMap.get(fieldValue)||[]).find(e4=>e4.type===component_type)||null}}if("subcircuit_id"in where&&indexConfig.bySubcircuit&&internalStore.indexes.bySubcircuit){let subcircuitId=where.subcircuit_id;return(internalStore.indexes.bySubcircuit.get(subcircuitId)||[]).find(e4=>e4.type===component_type&&keys.every(key=>e4[key]===where[key]))||null}return indexConfig.byType&&internalStore.indexes.byType?(internalStore.indexes.byType.get(component_type)||[]).find(e4=>keys.every(key=>e4[key]===where[key]))||null:soup.find(e4=>e4.type===component_type&&keys.every(key=>e4[key]===where[key]))||null},list:where=>{let indexConfig=options.indexConfig||{},keys=where?Object.keys(where):[];if(keys.length===0&&indexConfig.byType&&internalStore.indexes.byType)return internalStore.indexes.byType.get(component_type)||[];if(keys.length===1&&keys[0]==="subcircuit_id"&&indexConfig.bySubcircuit&&internalStore.indexes.bySubcircuit){let subcircuitId=where.subcircuit_id;return(internalStore.indexes.bySubcircuit.get(subcircuitId)||[]).filter(e4=>e4.type===component_type)}let elementsToFilter;return indexConfig.byType&&internalStore.indexes.byType?elementsToFilter=internalStore.indexes.byType.get(component_type)||[]:elementsToFilter=soup.filter(e4=>e4.type===component_type),keys.length>0?elementsToFilter.filter(e4=>keys.every(key=>e4[key]===where[key])):elementsToFilter},insert:elm=>{var _a359;(_a359=internalStore.counts)[component_type]??(_a359[component_type]=-1),internalStore.counts[component_type]++;let index=internalStore.counts[component_type],newElm={type:component_type,[`${component_type}_id`]:`${component_type}_${index}`,...elm};options.validateInserts&&(dist_exports[component_type]??any_soup_element).parse(newElm),soup.push(newElm),internalStore.editCount++;let indexConfig=options.indexConfig||{};if(indexConfig.byId&&internalStore.indexes.byId){let idKey=createIdKey(newElm);internalStore.indexes.byId.set(idKey,newElm)}if(indexConfig.byType&&internalStore.indexes.byType){let elementsOfType=internalStore.indexes.byType.get(component_type)||[];elementsOfType.push(newElm),internalStore.indexes.byType.set(component_type,elementsOfType)}if(indexConfig.byRelation&&internalStore.indexes.byRelation){let elementEntries=Object.entries(newElm);for(let[key,value]of elementEntries)if(key.endsWith("_id")&&key!==`${newElm.type}_id`&&typeof value=="string"){let relationTypeMap=internalStore.indexes.byRelation.get(key)||new Map,relatedElements=relationTypeMap.get(value)||[];relatedElements.push(newElm),relationTypeMap.set(value,relatedElements),internalStore.indexes.byRelation.set(key,relationTypeMap)}}if(indexConfig.bySubcircuit&&internalStore.indexes.bySubcircuit&&"subcircuit_id"in newElm){let subcircuitId=newElm.subcircuit_id;if(subcircuitId&&typeof subcircuitId=="string"){let subcircuitElements=internalStore.indexes.bySubcircuit.get(subcircuitId)||[];subcircuitElements.push(newElm),internalStore.indexes.bySubcircuit.set(subcircuitId,subcircuitElements)}}if(indexConfig.byCustomField&&internalStore.indexes.byCustomField){for(let field of indexConfig.byCustomField)if(field in newElm){let fieldValue=newElm[field];if(fieldValue!==void 0&&(typeof fieldValue=="string"||typeof fieldValue=="number")){let fieldValueStr=String(fieldValue),fieldMap=internalStore.indexes.byCustomField.get(field),elementsWithFieldValue=fieldMap.get(fieldValueStr)||[];elementsWithFieldValue.push(newElm),fieldMap.set(fieldValueStr,elementsWithFieldValue)}}}return newElm},delete:id2=>{let indexConfig=options.indexConfig||{},elm;if(indexConfig.byId&&internalStore.indexes.byId?elm=internalStore.indexes.byId.get(`${component_type}:${id2}`):indexConfig.byType&&internalStore.indexes.byType?elm=(internalStore.indexes.byType.get(component_type)||[]).find(e4=>e4[`${component_type}_id`]===id2):elm=soup.find(e4=>e4[`${component_type}_id`]===id2),!elm)return;let elmIndex=soup.indexOf(elm);if(elmIndex>=0&&(soup.splice(elmIndex,1),internalStore.editCount++),indexConfig.byId&&internalStore.indexes.byId){let idKey=createIdKey(elm);internalStore.indexes.byId.delete(idKey)}if(indexConfig.byType&&internalStore.indexes.byType){let filteredElements=(internalStore.indexes.byType.get(component_type)||[]).filter(e4=>e4[`${component_type}_id`]!==id2);internalStore.indexes.byType.set(component_type,filteredElements)}if(indexConfig.byRelation&&internalStore.indexes.byRelation)for(let[relationKey,relationMap]of internalStore.indexes.byRelation.entries())for(let[relationValue,elements]of relationMap.entries()){let updatedElements=elements.filter(e4=>e4!==elm);updatedElements.length===0?relationMap.delete(relationValue):relationMap.set(relationValue,updatedElements)}if(indexConfig.bySubcircuit&&internalStore.indexes.bySubcircuit&&"subcircuit_id"in elm){let subcircuitId=elm.subcircuit_id;if(subcircuitId){let updatedElements=(internalStore.indexes.bySubcircuit.get(subcircuitId)||[]).filter(e4=>e4!==elm);updatedElements.length===0?internalStore.indexes.bySubcircuit.delete(subcircuitId):internalStore.indexes.bySubcircuit.set(subcircuitId,updatedElements)}}if(indexConfig.byCustomField&&internalStore.indexes.byCustomField)for(let fieldMap of internalStore.indexes.byCustomField.values())for(let[fieldValue,elements]of fieldMap.entries()){let updatedElements=elements.filter(e4=>e4!==elm);updatedElements.length===0?fieldMap.delete(fieldValue):fieldMap.set(fieldValue,updatedElements)}},update:(id2,newProps)=>{let indexConfig=options.indexConfig||{},elm;if(indexConfig.byId&&internalStore.indexes.byId?elm=internalStore.indexes.byId.get(`${component_type}:${id2}`):indexConfig.byType&&internalStore.indexes.byType?elm=(internalStore.indexes.byType.get(component_type)||[]).find(e4=>e4[`${component_type}_id`]===id2):elm=soup.find(e4=>e4.type===component_type&&e4[`${component_type}_id`]===id2),!elm)return null;if(indexConfig.byRelation&&internalStore.indexes.byRelation){let elementEntries=Object.entries(elm);for(let[key,value]of elementEntries)if(key.endsWith("_id")&&key!==`${elm.type}_id`&&typeof value=="string"&&key in newProps&&newProps[key]!==value){let relationTypeMap=internalStore.indexes.byRelation.get(key);if(relationTypeMap){let updatedElements=(relationTypeMap.get(value)||[]).filter(e4=>e4!==elm);updatedElements.length===0?relationTypeMap.delete(value):relationTypeMap.set(value,updatedElements)}}}if(indexConfig.bySubcircuit&&internalStore.indexes.bySubcircuit&&"subcircuit_id"in elm&&"subcircuit_id"in newProps){let oldSubcircuitId=elm.subcircuit_id,newSubcircuitId=newProps.subcircuit_id;if(oldSubcircuitId!==newSubcircuitId){let updatedElements=(internalStore.indexes.bySubcircuit.get(oldSubcircuitId)||[]).filter(e4=>e4!==elm);updatedElements.length===0?internalStore.indexes.bySubcircuit.delete(oldSubcircuitId):internalStore.indexes.bySubcircuit.set(oldSubcircuitId,updatedElements)}}if(indexConfig.byCustomField&&internalStore.indexes.byCustomField){for(let field of indexConfig.byCustomField)if(field in elm&&field in newProps&&elm[field]!==newProps[field]){let fieldMap=internalStore.indexes.byCustomField.get(field);if(fieldMap){let oldValue=String(elm[field]),updatedElements=(fieldMap.get(oldValue)||[]).filter(e4=>e4!==elm);updatedElements.length===0?fieldMap.delete(oldValue):fieldMap.set(oldValue,updatedElements)}}}if(Object.assign(elm,newProps),internalStore.editCount++,indexConfig.byRelation&&internalStore.indexes.byRelation){let elementEntries=Object.entries(elm);for(let[key,value]of elementEntries)if(key.endsWith("_id")&&key!==`${elm.type}_id`&&typeof value=="string"&&key in newProps){let relationTypeMap=internalStore.indexes.byRelation.get(key)||new Map,relatedElements=relationTypeMap.get(value)||[];relatedElements.includes(elm)||(relatedElements.push(elm),relationTypeMap.set(value,relatedElements),internalStore.indexes.byRelation.set(key,relationTypeMap))}}if(indexConfig.bySubcircuit&&internalStore.indexes.bySubcircuit&&"subcircuit_id"in elm&&"subcircuit_id"in newProps){let subcircuitId=elm.subcircuit_id;if(subcircuitId&&typeof subcircuitId=="string"){let subcircuitElements=internalStore.indexes.bySubcircuit.get(subcircuitId)||[];subcircuitElements.includes(elm)||(subcircuitElements.push(elm),internalStore.indexes.bySubcircuit.set(subcircuitId,subcircuitElements))}}if(indexConfig.byCustomField&&internalStore.indexes.byCustomField){for(let field of indexConfig.byCustomField)if(field in elm&&field in newProps){let fieldValue=elm[field];if(fieldValue!==void 0&&(typeof fieldValue=="string"||typeof fieldValue=="number")){let fieldValueStr=String(fieldValue),fieldMap=internalStore.indexes.byCustomField.get(field),elementsWithFieldValue=fieldMap.get(fieldValueStr)||[];elementsWithFieldValue.includes(elm)||(elementsWithFieldValue.push(elm),fieldMap.set(fieldValueStr,elementsWithFieldValue))}}}return elm},select:selector=>{if(component_type==="source_component")return soup.find(e4=>e4.type==="source_component"&&e4.name===selector.replace(/\./g,""))||null;if(component_type==="pcb_port"||component_type==="source_port"||component_type==="schematic_port"){let[component_name,port_selector]=selector.replace(/\./g,"").split(/[\s\>]+/),source_component=soup.find(e4=>e4.type==="source_component"&&e4.name===component_name);if(!source_component)return null;let source_port2=soup.find(e4=>e4.type==="source_port"&&e4.source_component_id===source_component.source_component_id&&(e4.name===port_selector||(e4.port_hints??[]).includes(port_selector)));if(!source_port2)return null;if(component_type==="source_port")return source_port2;if(component_type==="pcb_port")return soup.find(e4=>e4.type==="pcb_port"&&e4.source_port_id===source_port2.source_port_id)||null;if(component_type==="schematic_port")return soup.find(e4=>e4.type==="schematic_port"&&e4.source_port_id===source_port2.source_port_id)||null}return null}}}})});cjuIndexed.unparsed=cjuIndexed;rotateClockwise=direction2=>{if(direction2==="up")return"right";if(direction2==="right")return"down";if(direction2==="down")return"left";if(direction2==="left")return"up";throw new Error(`Invalid direction: ${direction2}`)},rotateCounterClockwise=direction2=>{if(direction2==="up")return"left";if(direction2==="left")return"down";if(direction2==="down")return"right";if(direction2==="right")return"up";throw new Error(`Invalid direction: ${direction2}`)},rotateDirection=(direction2,num90DegreeClockwiseTurns)=>{for(;num90DegreeClockwiseTurns>0;)direction2=rotateClockwise(direction2),num90DegreeClockwiseTurns--;for(;num90DegreeClockwiseTurns<0;)direction2=rotateCounterClockwise(direction2),num90DegreeClockwiseTurns++;return direction2},oppositeSide=sideOrDir=>{if(sideOrDir==="top"||sideOrDir==="up")return"bottom";if(sideOrDir==="bottom"||sideOrDir==="down")return"top";if(sideOrDir==="left")return"right";if(sideOrDir==="right")return"left";throw new Error(`Invalid sideOrDir: ${sideOrDir}`)},transformSchematicElement=(elm,matrix2)=>{if(elm.type==="schematic_component")elm.center=applyToPoint2(matrix2,elm.center);else if(elm.type==="schematic_port")elm.center=applyToPoint2(matrix2,elm.center),elm.facing_direction&&(elm.facing_direction=rotateDirection(elm.facing_direction,-(Math.atan2(matrix2.b,matrix2.a)/Math.PI)*2));else if(elm.type==="schematic_text")elm.position=applyToPoint2(matrix2,elm.position);else if(elm.type==="schematic_trace"){let anyElm=elm;anyElm.route=(anyElm.route??[]).map(rp2=>{let tp=applyToPoint2(matrix2,rp2);return rp2.x=tp.x,rp2.y=tp.y,rp2}),Array.isArray(anyElm.junctions)&&(anyElm.junctions=anyElm.junctions.map(j3=>{let tp=applyToPoint2(matrix2,j3);return j3.x=tp.x,j3.y=tp.y,j3})),Array.isArray(anyElm.edges)&&(anyElm.edges=anyElm.edges.map(e4=>(e4.from=applyToPoint2(matrix2,e4.from),e4.to=applyToPoint2(matrix2,e4.to),e4)))}else if(elm.type==="schematic_box"){let{x:x3,y:y3}=applyToPoint2(matrix2,{x:elm.x,y:elm.y});elm.x=x3,elm.y=y3}else if(elm.type==="schematic_line"){let{x:x12,y:y12}=applyToPoint2(matrix2,{x:elm.x1,y:elm.y1}),{x:x22,y:y22}=applyToPoint2(matrix2,{x:elm.x2,y:elm.y2});elm.x1=x12,elm.y1=y12,elm.x2=x22,elm.y2=y22}return elm},transformSchematicElements=(elms,matrix2)=>elms.map(elm=>transformSchematicElement(elm,matrix2)),transformPCBElement=(elm,matrix2)=>{let tsr=decomposeTSR2(matrix2),flipPadWidthHeight=Math.round(tsr.rotation.angle/(Math.PI/2))%2===1;if(elm.type==="pcb_plated_hole"||elm.type==="pcb_hole"||elm.type==="pcb_via"||elm.type==="pcb_smtpad"||elm.type==="pcb_port"){let{x:x3,y:y3}=applyToPoint2(matrix2,{x:Number(elm.x),y:Number(elm.y)});elm.x=x3,elm.y=y3,elm.type==="pcb_smtpad"&&elm.shape==="polygon"&&Array.isArray(elm.points)&&(elm.points=elm.points.map(point6=>{let tp=applyToPoint2(matrix2,{x:point6.x,y:point6.y});return{x:tp.x,y:tp.y}}))}else if(elm.type==="pcb_keepout"||elm.type==="pcb_board")elm.center=applyToPoint2(matrix2,elm.center);else if(elm.type==="pcb_silkscreen_text"||elm.type==="pcb_fabrication_note_text")elm.anchor_position=applyToPoint2(matrix2,elm.anchor_position);else if(elm.type==="pcb_silkscreen_circle"||elm.type==="pcb_silkscreen_rect")elm.center=applyToPoint2(matrix2,elm.center);else if(elm.type==="pcb_component")elm.center=applyToPoint2(matrix2,elm.center),elm.rotation=elm.rotation+tsr.rotation.angle/Math.PI*180,elm.rotation=elm.rotation%360,flipPadWidthHeight&&([elm.width,elm.height]=[elm.height,elm.width]);else if(elm.type==="pcb_silkscreen_path"||elm.type==="pcb_trace"||elm.type==="pcb_fabrication_note_path")elm.route=elm.route.map(rp2=>{let tp=applyToPoint2(matrix2,rp2);return rp2.x=tp.x,rp2.y=tp.y,rp2});else if(elm.type==="pcb_silkscreen_line"){let p12={x:elm.x1,y:elm.y1},p2={x:elm.x2,y:elm.y2},p1t=applyToPoint2(matrix2,p12),p2t=applyToPoint2(matrix2,p2);elm.x1=p1t.x,elm.y1=p1t.y,elm.x2=p2t.x,elm.y2=p2t.y}else if(elm.type==="cad_component"){let newPos=applyToPoint2(matrix2,{x:elm.position.x,y:elm.position.y});elm.position.x=newPos.x,elm.position.y=newPos.y}return elm},transformPCBElements=(elms,matrix2)=>{let tsr=decomposeTSR2(matrix2),quarterTurns=Math.round(tsr.rotation.angle/(Math.PI/2)),flipPadWidthHeight=Math.abs(quarterTurns)%2===1,transformedElms=elms.map(elm=>transformPCBElement(elm,matrix2));return flipPadWidthHeight&&(transformedElms=transformedElms.map(elm=>(elm.type==="pcb_smtpad"&&elm.shape==="rect"&&([elm.width,elm.height]=[elm.height,elm.width]),elm))),transformedElms},getElementId=elm=>{let type=elm.type;return elm[`${type}_id`]},getElementById2=(soup,id2)=>soup.find(elm=>getElementId(elm)===id2)??null;getReadableNameForPcbPort=(soup,pcb_port_id)=>{let pcbPort=cju(soup).pcb_port.get(pcb_port_id);if(!pcbPort)return`pcb_port[#${pcb_port_id}]`;let pcbComponent=cju(soup).pcb_component.get(pcbPort?.pcb_component_id);if(!pcbComponent)return`pcb_port[#${pcb_port_id}]`;let sourceComponent=cju(soup).source_component.get(pcbComponent.source_component_id);if(!sourceComponent)return`pcb_port[#${pcb_port_id}]`;let sourcePort=cju(soup).source_port.get(pcbPort.source_port_id);if(!sourcePort)return`pcb_port[#${pcb_port_id}]`;let padIdentifier;return sourcePort?.port_hints&&sourcePort.port_hints.length>0||sourcePort.port_hints&&sourcePort.port_hints.length>0?padIdentifier=sourcePort.port_hints[0]:padIdentifier=pcb_port_id,`pcb_port[.${sourceComponent.name} > .${padIdentifier}]`};getReadableNameForElement=(soup,elm)=>{if(typeof elm=="string"){let elmObj=getElementById2(soup,elm);return elmObj||`${elm}`,getReadableNameForElement(soup,elmObj)}switch(elm.type){case"pcb_port":return getReadableNameForPcbPort(soup,elm.pcb_port_id);case"pcb_smtpad":return getReadableNameForPcbSmtpad(soup,elm.pcb_smtpad_id);case"pcb_trace":return getReadableNameForPcbTrace(soup,elm.pcb_trace_id);case"source_component":return`source_component[${elm.name}]`;default:return`${elm.type}[#${getElementId(elm)}]`}},getBoundsOfPcbElements=elements=>{let minX=Number.POSITIVE_INFINITY,minY=Number.POSITIVE_INFINITY,maxX=Number.NEGATIVE_INFINITY,maxY=Number.NEGATIVE_INFINITY;for(let elm of elements){if(!elm.type.startsWith("pcb_"))continue;if(elm.type==="pcb_smtpad"&&elm.shape==="polygon"&&Array.isArray(elm.points)){for(let point6 of elm.points)minX=Math.min(minX,point6.x),minY=Math.min(minY,point6.y),maxX=Math.max(maxX,point6.x),maxY=Math.max(maxY,point6.y);continue}let centerX,centerY,width,height;if("x"in elm&&"y"in elm&&(centerX=Number(elm.x),centerY=Number(elm.y)),"outer_diameter"in elm&&(width=Number(elm.outer_diameter),height=Number(elm.outer_diameter)),"width"in elm&&(width=Number(elm.width)),"height"in elm&&(height=Number(elm.height)),"center"in elm&&(centerX=elm.center.x,centerY=elm.center.y),centerX!==void 0&&centerY!==void 0)minX=Math.min(minX,centerX),minY=Math.min(minY,centerY),maxX=Math.max(maxX,centerX),maxY=Math.max(maxY,centerY),width!==void 0&&height!==void 0&&(minX=Math.min(minX,centerX-width/2),minY=Math.min(minY,centerY-height/2),maxX=Math.max(maxX,centerX+width/2),maxY=Math.max(maxY,centerY+height/2)),"radius"in elm&&(minX=Math.min(minX,centerX-elm.radius),minY=Math.min(minY,centerY-elm.radius),maxX=Math.max(maxX,centerX+elm.radius),maxY=Math.max(maxY,centerY+elm.radius));else if(elm.type==="pcb_trace")for(let point6 of elm.route)minX=Math.min(minX,point6.x),minY=Math.min(minY,point6.y),maxX=Math.max(maxX,point6.x),maxY=Math.max(maxY,point6.y)}return{minX,minY,maxX,maxY}};nice_color_palettes=[["#69d2e7","#a7dbd8","#e0e4cc","#f38630","#fa6900"],["#fe4365","#fc9d9a","#f9cdad","#c8c8a9","#83af9b"],["#ecd078","#d95b43","#c02942","#542437","#53777a"],["#556270","#4ecdc4","#c7f464","#ff6b6b","#c44d58"],["#774f38","#e08e79","#f1d4af","#ece5ce","#c5e0dc"],["#e8ddcb","#cdb380","#036564","#033649","#031634"],["#490a3d","#bd1550","#e97f02","#f8ca00","#8a9b0f"],["#594f4f","#547980","#45ada8","#9de0ad","#e5fcc2"],["#00a0b0","#6a4a3c","#cc333f","#eb6841","#edc951"],["#e94e77","#d68189","#c6a49a","#c6e5d9","#f4ead5"],["#3fb8af","#7fc7af","#dad8a7","#ff9e9d","#ff3d7f"],["#d9ceb2","#948c75","#d5ded9","#7a6a53","#99b2b7"],["#ffffff","#cbe86b","#f2e9e1","#1c140d","#cbe86b"],["#efffcd","#dce9be","#555152","#2e2633","#99173c"],["#343838","#005f6b","#008c9e","#00b4cc","#00dffc"],["#413e4a","#73626e","#b38184","#f0b49e","#f7e4be"],["#ff4e50","#fc913a","#f9d423","#ede574","#e1f5c4"],["#99b898","#fecea8","#ff847c","#e84a5f","#2a363b"],["#655643","#80bca3","#f6f7bd","#e6ac27","#bf4d28"],["#00a8c6","#40c0cb","#f9f2e7","#aee239","#8fbe00"],["#351330","#424254","#64908a","#e8caa4","#cc2a41"],["#554236","#f77825","#d3ce3d","#f1efa5","#60b99a"],["#5d4157","#838689","#a8caba","#cad7b2","#ebe3aa"],["#8c2318","#5e8c6a","#88a65e","#bfb35a","#f2c45a"],["#fad089","#ff9c5b","#f5634a","#ed303c","#3b8183"],["#ff4242","#f4fad2","#d4ee5e","#e1edb9","#f0f2eb"],["#f8b195","#f67280","#c06c84","#6c5b7b","#355c7d"],["#d1e751","#ffffff","#000000","#4dbce9","#26ade4"],["#1b676b","#519548","#88c425","#bef202","#eafde6"],["#5e412f","#fcebb6","#78c0a8","#f07818","#f0a830"],["#bcbdac","#cfbe27","#f27435","#f02475","#3b2d38"],["#452632","#91204d","#e4844a","#e8bf56","#e2f7ce"],["#eee6ab","#c5bc8e","#696758","#45484b","#36393b"],["#f0d8a8","#3d1c00","#86b8b1","#f2d694","#fa2a00"],["#2a044a","#0b2e59","#0d6759","#7ab317","#a0c55f"],["#f04155","#ff823a","#f2f26f","#fff7bd","#95cfb7"],["#b9d7d9","#668284","#2a2829","#493736","#7b3b3b"],["#bbbb88","#ccc68d","#eedd99","#eec290","#eeaa88"],["#b3cc57","#ecf081","#ffbe40","#ef746f","#ab3e5b"],["#a3a948","#edb92e","#f85931","#ce1836","#009989"],["#300030","#480048","#601848","#c04848","#f07241"],["#67917a","#170409","#b8af03","#ccbf82","#e33258"],["#aab3ab","#c4cbb7","#ebefc9","#eee0b7","#e8caaf"],["#e8d5b7","#0e2430","#fc3a51","#f5b349","#e8d5b9"],["#ab526b","#bca297","#c5ceae","#f0e2a4","#f4ebc3"],["#607848","#789048","#c0d860","#f0f0d8","#604848"],["#b6d8c0","#c8d9bf","#dadabd","#ecdbbc","#fedcba"],["#a8e6ce","#dcedc2","#ffd3b5","#ffaaa6","#ff8c94"],["#3e4147","#fffedf","#dfba69","#5a2e2e","#2a2c31"],["#fc354c","#29221f","#13747d","#0abfbc","#fcf7c5"],["#cc0c39","#e6781e","#c8cf02","#f8fcc1","#1693a7"],["#1c2130","#028f76","#b3e099","#ffeaad","#d14334"],["#a7c5bd","#e5ddcb","#eb7b59","#cf4647","#524656"],["#dad6ca","#1bb0ce","#4f8699","#6a5e72","#563444"],["#5c323e","#a82743","#e15e32","#c0d23e","#e5f04c"],["#edebe6","#d6e1c7","#94c7b6","#403b33","#d3643b"],["#fdf1cc","#c6d6b8","#987f69","#e3ad40","#fcd036"],["#230f2b","#f21d41","#ebebbc","#bce3c5","#82b3ae"],["#b9d3b0","#81bda4","#b28774","#f88f79","#f6aa93"],["#3a111c","#574951","#83988e","#bcdea5","#e6f9bc"],["#5e3929","#cd8c52","#b7d1a3","#dee8be","#fcf7d3"],["#1c0113","#6b0103","#a30006","#c21a01","#f03c02"],["#000000","#9f111b","#b11623","#292c37","#cccccc"],["#382f32","#ffeaf2","#fcd9e5","#fbc5d8","#f1396d"],["#e3dfba","#c8d6bf","#93ccc6","#6cbdb5","#1a1f1e"],["#f6f6f6","#e8e8e8","#333333","#990100","#b90504"],["#1b325f","#9cc4e4","#e9f2f9","#3a89c9","#f26c4f"],["#a1dbb2","#fee5ad","#faca66","#f7a541","#f45d4c"],["#c1b398","#605951","#fbeec2","#61a6ab","#accec0"],["#5e9fa3","#dcd1b4","#fab87f","#f87e7b","#b05574"],["#951f2b","#f5f4d7","#e0dfb1","#a5a36c","#535233"],["#8dccad","#988864","#fea6a2","#f9d6ac","#ffe9af"],["#2d2d29","#215a6d","#3ca2a2","#92c7a3","#dfece6"],["#413d3d","#040004","#c8ff00","#fa023c","#4b000f"],["#eff3cd","#b2d5ba","#61ada0","#248f8d","#605063"],["#ffefd3","#fffee4","#d0ecea","#9fd6d2","#8b7a5e"],["#cfffdd","#b4dec1","#5c5863","#a85163","#ff1f4c"],["#9dc9ac","#fffec7","#f56218","#ff9d2e","#919167"],["#4e395d","#827085","#8ebe94","#ccfc8e","#dc5b3e"],["#a8a7a7","#cc527a","#e8175d","#474747","#363636"],["#f8edd1","#d88a8a","#474843","#9d9d93","#c5cfc6"],["#046d8b","#309292","#2fb8ac","#93a42a","#ecbe13"],["#f38a8a","#55443d","#a0cab5","#cde9ca","#f1edd0"],["#a70267","#f10c49","#fb6b41","#f6d86b","#339194"],["#ff003c","#ff8a00","#fabe28","#88c100","#00c176"],["#ffedbf","#f7803c","#f54828","#2e0d23","#f8e4c1"],["#4e4d4a","#353432","#94ba65","#2790b0","#2b4e72"],["#0ca5b0","#4e3f30","#fefeeb","#f8f4e4","#a5b3aa"],["#4d3b3b","#de6262","#ffb88c","#ffd0b3","#f5e0d3"],["#fffbb7","#a6f6af","#66b6ab","#5b7c8d","#4f2958"],["#edf6ee","#d1c089","#b3204d","#412e28","#151101"],["#9d7e79","#ccac95","#9a947c","#748b83","#5b756c"],["#fcfef5","#e9ffe1","#cdcfb7","#d6e6c3","#fafbe3"],["#9cddc8","#bfd8ad","#ddd9ab","#f7af63","#633d2e"],["#30261c","#403831","#36544f","#1f5f61","#0b8185"],["#aaff00","#ffaa00","#ff00aa","#aa00ff","#00aaff"],["#d1313d","#e5625c","#f9bf76","#8eb2c5","#615375"],["#ffe181","#eee9e5","#fad3b2","#ffba7f","#ff9c97"],["#73c8a9","#dee1b6","#e1b866","#bd5532","#373b44"],["#805841","#dcf7f3","#fffcdd","#ffd8d8","#f5a2a2"]],getDebugLayoutObject=lo3=>{let{x:x3,y:y3,width,height}={...lo3,...lo3.size,...lo3.center,...lo3.position};if(lo3.x1!==void 0&&lo3.x2!==void 0&&lo3.y1!==void 0&&lo3.y2!==void 0&&(x3=(lo3.x1+lo3.x2)/2,y3=(lo3.y1+lo3.y2)/2,width=Math.abs(lo3.x1-lo3.x2),height=Math.abs(lo3.y1-lo3.y2)),lo3.points&&Array.isArray(lo3.points)&&lo3.points.length>0){let xCoords=lo3.points.map(point6=>point6.x),yCoords=lo3.points.map(point6=>point6.y),minX=Math.min(...xCoords),maxX=Math.max(...xCoords),minY=Math.min(...yCoords),maxY=Math.max(...yCoords);x3=(minX+maxX)/2,y3=(minY+maxY)/2,width=maxX-minX,height=maxY-minY}let title=lo3.text||lo3.name||lo3.source?.text||lo3.source?.name||"?",content=lo3;return x3===void 0||y3===void 0?null:(width===void 0&&"outer_diameter"in lo3&&(width=lo3.outer_diameter,height=lo3.outer_diameter),(width===void 0||height===void 0)&&(width=.1,height=.1),{x:x3,y:y3,width,height,title,content,bg_color:nice_color_palettes[stringHash(lo3.type||title)%nice_color_palettes.length]?.[4]??"#f00"})},isTruthy=value=>!!value,findBoundsAndCenter=elements=>{let debugObjects=elements.filter(elm=>elm.type.startsWith("pcb_")||elm.type.startsWith("schematic_")).concat(elements.filter(elm=>elm.type==="pcb_trace"||elm.type==="schematic_trace").flatMap(elm=>elm.route)).map(elm=>getDebugLayoutObject(elm)).filter(isTruthy);if(debugObjects.length===0)return{center:{x:0,y:0},width:0,height:0};let minX=debugObjects[0].x-debugObjects[0].width/2,maxX=debugObjects[0].x+debugObjects[0].width/2,minY=debugObjects[0].y-debugObjects[0].height/2,maxY=debugObjects[0].y+debugObjects[0].height/2;for(let obj of debugObjects.slice(1))minX=Math.min(minX,obj.x-obj.width/2),maxX=Math.max(maxX,obj.x+obj.width/2),minY=Math.min(minY,obj.y-obj.height/2),maxY=Math.max(maxY,obj.y+obj.height/2);let width=maxX-minX,height=maxY-minY;return{center:{x:minX+width/2,y:minY+height/2},width,height}},getPrimaryId=element=>element[`${element.type}_id`],repositionPcbComponentTo=(circuitJson,pcb_component_id,newCenter)=>{let pcbComponent=circuitJson.find(e4=>e4.type==="pcb_component"&&e4.pcb_component_id===pcb_component_id);if(!pcbComponent)return;let currentCenter="center"in pcbComponent?pcbComponent.center:{x:pcbComponent.x,y:pcbComponent.y},dx2=newCenter.x-currentCenter.x,dy2=newCenter.y-currentCenter.y,portIds=circuitJson.filter(e4=>e4.type==="pcb_port"&&e4.pcb_component_id===pcb_component_id).map(e4=>e4.pcb_port_id),elementsToMove=circuitJson.filter(elm=>{if(elm===pcbComponent)return!0;let anyElm=elm;return!!(anyElm.pcb_component_id===pcb_component_id||Array.isArray(anyElm.pcb_component_ids)&&anyElm.pcb_component_ids.includes(pcb_component_id)||anyElm.pcb_port_id&&portIds.includes(anyElm.pcb_port_id)||Array.isArray(anyElm.pcb_port_ids)&&anyElm.pcb_port_ids.some(id2=>portIds.includes(id2))||anyElm.start_pcb_port_id&&portIds.includes(anyElm.start_pcb_port_id)||anyElm.end_pcb_port_id&&portIds.includes(anyElm.end_pcb_port_id)||Array.isArray(anyElm.route)&&anyElm.route.some(pt3=>pt3.start_pcb_port_id&&portIds.includes(pt3.start_pcb_port_id)||pt3.end_pcb_port_id&&portIds.includes(pt3.end_pcb_port_id)))}),matrix2=translate2(dx2,dy2);transformPCBElements(elementsToMove,matrix2)},findAllDescendantGroupIds=(circuitJson,parentGroupId)=>{let childGroupIds=[],directChildren=circuitJson.filter(elm=>elm.type==="source_group"&&elm.parent_source_group_id===parentGroupId).map(elm=>elm.source_group_id);childGroupIds.push(...directChildren);for(let childId of directChildren)childGroupIds.push(...findAllDescendantGroupIds(circuitJson,childId));return childGroupIds},repositionPcbGroupTo=(circuitJson,source_group_id,newCenter)=>{let allGroupIds=[source_group_id,...findAllDescendantGroupIds(circuitJson,source_group_id)],allGroupElements=new Set;for(let groupId of allGroupIds)buildSubtree(circuitJson,{source_group_id:groupId}).forEach(elm=>allGroupElements.add(elm));let portIds=Array.from(allGroupElements).filter(e4=>e4.type==="pcb_port").map(e4=>e4.pcb_port_id);circuitJson.filter(elm=>{if(elm.type!=="pcb_trace"||allGroupElements.has(elm))return!1;let anyElm=elm;return!!(anyElm.start_pcb_port_id&&portIds.includes(anyElm.start_pcb_port_id)||anyElm.end_pcb_port_id&&portIds.includes(anyElm.end_pcb_port_id)||Array.isArray(anyElm.route)&&anyElm.route.some(pt3=>pt3.start_pcb_port_id&&portIds.includes(pt3.start_pcb_port_id)||pt3.end_pcb_port_id&&portIds.includes(pt3.end_pcb_port_id)))}).forEach(trace=>allGroupElements.add(trace));let pcbElements=Array.from(allGroupElements).filter(elm=>elm.type.startsWith("pcb_"));if(pcbElements.length===0)return;let{center:currentCenter}=findBoundsAndCenter(pcbElements),dx2=newCenter.x-currentCenter.x,dy2=newCenter.y-currentCenter.y,matrix2=translate2(dx2,dy2);transformPCBElements(pcbElements,matrix2)},repositionSchematicComponentTo=(circuitJson,schematic_component_id,newCenter)=>{let schematicComponent=circuitJson.find(e4=>e4.type==="schematic_component"&&e4.schematic_component_id===schematic_component_id);if(!schematicComponent)return;let currentCenter="center"in schematicComponent?schematicComponent.center:{x:schematicComponent.x,y:schematicComponent.y},dx2=newCenter.x-currentCenter.x,dy2=newCenter.y-currentCenter.y,portIds=circuitJson.filter(e4=>e4.type==="schematic_port"&&e4.schematic_component_id===schematic_component_id).map(e4=>e4.schematic_port_id),elementsToMove=circuitJson.filter(elm=>{if(elm===schematicComponent)return!0;let anyElm=elm;return!!(anyElm.schematic_component_id===schematic_component_id||Array.isArray(anyElm.schematic_component_ids)&&anyElm.schematic_component_ids.includes(schematic_component_id)||anyElm.schematic_port_id&&portIds.includes(anyElm.schematic_port_id)||Array.isArray(anyElm.schematic_port_ids)&&anyElm.schematic_port_ids.some(id2=>portIds.includes(id2))||anyElm.start_schematic_port_id&&portIds.includes(anyElm.start_schematic_port_id)||anyElm.end_schematic_port_id&&portIds.includes(anyElm.end_schematic_port_id)||Array.isArray(anyElm.route)&&anyElm.route.some(pt3=>pt3.start_schematic_port_id&&portIds.includes(pt3.start_schematic_port_id)||pt3.end_schematic_port_id&&portIds.includes(pt3.end_schematic_port_id)))}),matrix2=translate2(dx2,dy2);transformSchematicElements(elementsToMove,matrix2)},findAllDescendantGroupIds2=(circuitJson,parentGroupId)=>{let childGroupIds=[],directChildren=circuitJson.filter(elm=>elm.type==="source_group"&&elm.parent_source_group_id===parentGroupId).map(elm=>elm.source_group_id);childGroupIds.push(...directChildren);for(let childId of directChildren)childGroupIds.push(...findAllDescendantGroupIds2(circuitJson,childId));return childGroupIds},repositionSchematicGroupTo=(circuitJson,source_group_id,newCenter)=>{let allGroupIds=[source_group_id,...findAllDescendantGroupIds2(circuitJson,source_group_id)],allGroupElements=new Set;for(let groupId of allGroupIds)buildSubtree(circuitJson,{source_group_id:groupId}).forEach(elm=>allGroupElements.add(elm));let portIds=Array.from(allGroupElements).filter(e4=>e4.type==="schematic_port").map(e4=>e4.schematic_port_id);circuitJson.filter(elm=>{if(elm.type!=="schematic_trace"||allGroupElements.has(elm))return!1;let anyElm=elm;return!!(anyElm.start_schematic_port_id&&portIds.includes(anyElm.start_schematic_port_id)||anyElm.end_schematic_port_id&&portIds.includes(anyElm.end_schematic_port_id)||Array.isArray(anyElm.route)&&anyElm.route.some(pt3=>pt3.start_schematic_port_id&&portIds.includes(pt3.start_schematic_port_id)||pt3.end_schematic_port_id&&portIds.includes(pt3.end_schematic_port_id)))}).forEach(trace=>allGroupElements.add(trace));let schematicElements=Array.from(allGroupElements).filter(elm=>elm.type.startsWith("schematic_"));if(schematicElements.length===0)return;let{center:currentCenter}=findBoundsAndCenter(schematicElements),dx2=newCenter.x-currentCenter.x,dy2=newCenter.y-currentCenter.y,matrix2=translate2(dx2,dy2);transformSchematicElements(schematicElements,matrix2)},getCircuitJsonTree=(circuitJson,opts)=>{let groupChildMap=new Map,existingGroupIds=new Set;for(let elm of circuitJson)elm.type==="source_group"&&existingGroupIds.add(elm.source_group_id);let orphanedGroups=[];for(let elm of circuitJson)if(elm.type==="source_group"&&elm.parent_source_group_id){let parentId=elm.parent_source_group_id,childId=elm.source_group_id;if(!existingGroupIds.has(parentId))orphanedGroups.push(childId),groupChildMap.has(childId)||groupChildMap.set(childId,[]);else{let children=groupChildMap.get(parentId)??[];children.push(childId),groupChildMap.set(parentId,children),groupChildMap.has(childId)||groupChildMap.set(childId,[])}}for(let elm of circuitJson)elm.type==="source_group"&&!groupChildMap.has(elm.source_group_id)&&groupChildMap.set(elm.source_group_id,[]);let groupNodes=new Map,getNextGroupId=()=>{for(let[parentId,children]of groupChildMap)if(!groupNodes.has(parentId)&&children.every(childId=>groupNodes.has(childId)))return parentId;return null},lastGroupId=null;for(;;){let nextGroupId=getNextGroupId();if(!nextGroupId)break;let node={nodeType:"group",sourceGroup:circuitJson.find(elm=>elm.type==="source_group"&&elm.source_group_id===nextGroupId),otherChildElements:[],childNodes:[...groupChildMap.get(nextGroupId)?.map(childId=>groupNodes.get(childId))??[],...circuitJson.filter(elm=>elm.type==="source_component"&&elm.source_group_id===nextGroupId).map(elm=>({nodeType:"component",sourceComponent:elm,childNodes:[],otherChildElements:[...circuitJson.filter(e4=>e4.type==="pcb_component"&&e4.source_component_id===elm.source_component_id)]}))]};groupNodes.set(nextGroupId,node),lastGroupId=nextGroupId}if(!lastGroupId)return console.warn("No groups were processed, returning tree without sourceGroup"),{nodeType:"group",childNodes:[],otherChildElements:circuitJson};let rootGroupId=null;return opts&&opts.source_group_id!==void 0?rootGroupId=opts.source_group_id:orphanedGroups.length>0?rootGroupId=orphanedGroups[0]:rootGroupId=lastGroupId,rootGroupId?groupNodes.get(rootGroupId):(console.warn("No valid root group found, returning tree without sourceGroup"),{nodeType:"group",childNodes:[],otherChildElements:circuitJson})}}});var require_object_hash=__commonJS({"node_modules/object-hash/dist/object_hash.js"(exports,module){"use strict";(function(e4){var t5;typeof exports=="object"?module.exports=e4():typeof define=="function"&&define.amd?define(e4):(typeof window<"u"?t5=window:typeof global<"u"?t5=global:typeof self<"u"&&(t5=self),t5.objectHash=e4())})(function(){return(function r4(o4,i3,u4){function s3(n3,e5){if(!i3[n3]){if(!o4[n3]){var t5=typeof __require=="function"&&__require;if(!e5&&t5)return t5(n3,!0);if(a2)return a2(n3,!0);throw new Error("Cannot find module '"+n3+"'")}e5=i3[n3]={exports:{}},o4[n3][0].call(e5.exports,function(e6){var t7=o4[n3][1][e6];return s3(t7||e6)},e5,e5.exports,r4,o4,i3,u4)}return i3[n3].exports}for(var a2=typeof __require=="function"&&__require,e4=0;e4<u4.length;e4++)s3(u4[e4]);return s3})({1:[function(w4,b3,m3){(function(e4,n3,s3,c3,d3,h2,p2,g4,y3){"use strict";var r4=w4("crypto");function t5(e5,t7){t7=u4(e5,t7);var n4;return(n4=t7.algorithm!=="passthrough"?r4.createHash(t7.algorithm):new l2).write===void 0&&(n4.write=n4.update,n4.end=n4.update),f2(t7,n4).dispatch(e5),n4.update||n4.end(""),n4.digest?n4.digest(t7.encoding==="buffer"?void 0:t7.encoding):(e5=n4.read(),t7.encoding!=="buffer"?e5.toString(t7.encoding):e5)}(m3=b3.exports=t5).sha1=function(e5){return t5(e5)},m3.keys=function(e5){return t5(e5,{excludeValues:!0,algorithm:"sha1",encoding:"hex"})},m3.MD5=function(e5){return t5(e5,{algorithm:"md5",encoding:"hex"})},m3.keysMD5=function(e5){return t5(e5,{algorithm:"md5",encoding:"hex",excludeValues:!0})};var o4=r4.getHashes?r4.getHashes().slice():["sha1","md5"],i3=(o4.push("passthrough"),["buffer","hex","binary","base64"]);function u4(e5,t7){var n4={};if(n4.algorithm=(t7=t7||{}).algorithm||"sha1",n4.encoding=t7.encoding||"hex",n4.excludeValues=!!t7.excludeValues,n4.algorithm=n4.algorithm.toLowerCase(),n4.encoding=n4.encoding.toLowerCase(),n4.ignoreUnknown=t7.ignoreUnknown===!0,n4.respectType=t7.respectType!==!1,n4.respectFunctionNames=t7.respectFunctionNames!==!1,n4.respectFunctionProperties=t7.respectFunctionProperties!==!1,n4.unorderedArrays=t7.unorderedArrays===!0,n4.unorderedSets=t7.unorderedSets!==!1,n4.unorderedObjects=t7.unorderedObjects!==!1,n4.replacer=t7.replacer||void 0,n4.excludeKeys=t7.excludeKeys||void 0,e5===void 0)throw new Error("Object argument required.");for(var r6=0;r6<o4.length;++r6)o4[r6].toLowerCase()===n4.algorithm.toLowerCase()&&(n4.algorithm=o4[r6]);if(o4.indexOf(n4.algorithm)===-1)throw new Error('Algorithm "'+n4.algorithm+'" not supported. supported values: '+o4.join(", "));if(i3.indexOf(n4.encoding)===-1&&n4.algorithm!=="passthrough")throw new Error('Encoding "'+n4.encoding+'" not supported. supported values: '+i3.join(", "));return n4}function a2(e5){if(typeof e5=="function")return/^function\s+\w*\s*\(\s*\)\s*{\s+\[native code\]\s+}$/i.exec(Function.prototype.toString.call(e5))!=null}function f2(o5,t7,i4){i4=i4||[];function u5(e5){return t7.update?t7.update(e5,"utf8"):t7.write(e5,"utf8")}return{dispatch:function(e5){return this["_"+((e5=o5.replacer?o5.replacer(e5):e5)===null?"null":typeof e5)](e5)},_object:function(t8){var n4,e5=Object.prototype.toString.call(t8),r6=/\[object (.*)\]/i.exec(e5);if(r6=(r6=r6?r6[1]:"unknown:["+e5+"]").toLowerCase(),0<=(e5=i4.indexOf(t8)))return this.dispatch("[CIRCULAR:"+e5+"]");if(i4.push(t8),s3!==void 0&&s3.isBuffer&&s3.isBuffer(t8))return u5("buffer:"),u5(t8);if(r6==="object"||r6==="function"||r6==="asyncfunction")return e5=Object.keys(t8),o5.unorderedObjects&&(e5=e5.sort()),o5.respectType===!1||a2(t8)||e5.splice(0,0,"prototype","__proto__","constructor"),o5.excludeKeys&&(e5=e5.filter(function(e6){return!o5.excludeKeys(e6)})),u5("object:"+e5.length+":"),n4=this,e5.forEach(function(e6){n4.dispatch(e6),u5(":"),o5.excludeValues||n4.dispatch(t8[e6]),u5(",")});if(!this["_"+r6]){if(o5.ignoreUnknown)return u5("["+r6+"]");throw new Error('Unknown object type "'+r6+'"')}this["_"+r6](t8)},_array:function(e5,t8){t8=t8!==void 0?t8:o5.unorderedArrays!==!1;var n4=this;if(u5("array:"+e5.length+":"),!t8||e5.length<=1)return e5.forEach(function(e6){return n4.dispatch(e6)});var r6=[],t8=e5.map(function(e6){var t10=new l2,n5=i4.slice();return f2(o5,t10,n5).dispatch(e6),r6=r6.concat(n5.slice(i4.length)),t10.read().toString()});return i4=i4.concat(r6),t8.sort(),this._array(t8,!1)},_date:function(e5){return u5("date:"+e5.toJSON())},_symbol:function(e5){return u5("symbol:"+e5.toString())},_error:function(e5){return u5("error:"+e5.toString())},_boolean:function(e5){return u5("bool:"+e5.toString())},_string:function(e5){u5("string:"+e5.length+":"),u5(e5.toString())},_function:function(e5){u5("fn:"),a2(e5)?this.dispatch("[native]"):this.dispatch(e5.toString()),o5.respectFunctionNames!==!1&&this.dispatch("function-name:"+String(e5.name)),o5.respectFunctionProperties&&this._object(e5)},_number:function(e5){return u5("number:"+e5.toString())},_xml:function(e5){return u5("xml:"+e5.toString())},_null:function(){return u5("Null")},_undefined:function(){return u5("Undefined")},_regexp:function(e5){return u5("regex:"+e5.toString())},_uint8array:function(e5){return u5("uint8array:"),this.dispatch(Array.prototype.slice.call(e5))},_uint8clampedarray:function(e5){return u5("uint8clampedarray:"),this.dispatch(Array.prototype.slice.call(e5))},_int8array:function(e5){return u5("int8array:"),this.dispatch(Array.prototype.slice.call(e5))},_uint16array:function(e5){return u5("uint16array:"),this.dispatch(Array.prototype.slice.call(e5))},_int16array:function(e5){return u5("int16array:"),this.dispatch(Array.prototype.slice.call(e5))},_uint32array:function(e5){return u5("uint32array:"),this.dispatch(Array.prototype.slice.call(e5))},_int32array:function(e5){return u5("int32array:"),this.dispatch(Array.prototype.slice.call(e5))},_float32array:function(e5){return u5("float32array:"),this.dispatch(Array.prototype.slice.call(e5))},_float64array:function(e5){return u5("float64array:"),this.dispatch(Array.prototype.slice.call(e5))},_arraybuffer:function(e5){return u5("arraybuffer:"),this.dispatch(new Uint8Array(e5))},_url:function(e5){return u5("url:"+e5.toString())},_map:function(e5){return u5("map:"),e5=Array.from(e5),this._array(e5,o5.unorderedSets!==!1)},_set:function(e5){return u5("set:"),e5=Array.from(e5),this._array(e5,o5.unorderedSets!==!1)},_file:function(e5){return u5("file:"),this.dispatch([e5.name,e5.size,e5.type,e5.lastModfied])},_blob:function(){if(o5.ignoreUnknown)return u5("[blob]");throw Error(`Hashing Blob objects is currently not supported
210
+ at `+n3}return o4};$t.buildMessage=function(t5,o4){var i3={literal:function(p2){return'"'+a2(p2.text)+'"'},class:function(p2){var x3=p2.parts.map(function(f2){return Array.isArray(f2)?y3(f2[0])+"-"+y3(f2[1]):y3(f2)});return"["+(p2.inverted?"^":"")+x3.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(p2){return p2.description}};function l2(p2){return p2.charCodeAt(0).toString(16).toUpperCase()}function a2(p2){return p2.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(x3){return"\\x0"+l2(x3)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(x3){return"\\x"+l2(x3)})}function y3(p2){return p2.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(x3){return"\\x0"+l2(x3)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(x3){return"\\x"+l2(x3)})}function n3(p2){return i3[p2.type](p2)}function m3(p2){var x3=p2.map(n3),f2,d3;if(x3.sort(),x3.length>0){for(f2=1,d3=1;f2<x3.length;f2++)x3[f2-1]!==x3[f2]&&(x3[d3]=x3[f2],d3++);x3.length=d3}switch(x3.length){case 1:return x3[0];case 2:return x3[0]+" or "+x3[1];default:return x3.slice(0,-1).join(", ")+", or "+x3[x3.length-1]}}function h2(p2){return p2?'"'+a2(p2)+'"':"end of input"}return"Expected "+m3(t5)+" but "+h2(o4)+" found."};wf=(t5,o4="right")=>{switch(o4){case"down":switch(t5){case"middle_top":return"middle_right";case"middle_bottom":return"middle_left";case"middle_left":return"middle_bottom";case"middle_right":return"middle_top"}break;case"up":switch(t5){case"middle_top":return"middle_left";case"middle_bottom":return"middle_right";case"middle_left":return"middle_top";case"middle_right":return"middle_bottom"}break;case"left":switch(t5){case"middle_top":return"middle_bottom";case"middle_bottom":return"middle_top";case"middle_left":return"middle_right";case"middle_right":return"middle_left"}break;case"right":return t5}return t5},v=(t5,o4)=>{let{primitives:i3,center:l2,ports:a2,size:y3}=t5,n3=L({a:1,b:0,c:0,d:-1,e:0,f:2*l2.y}),m3=i3.map(p2=>{switch(p2={...p2},p2.type){case"path":return{...p2,points:p2.points.map(c3=>_(n3,c3))};case"text":let x3=_(n3,{x:p2.x,y:p2.y}),f2={top_left:"bottom_left",top_right:"bottom_right",bottom_left:"top_left",bottom_right:"top_right",center:"center",middle_top:"middle_bottom",middle_bottom:"middle_top",middle_left:"middle_left",middle_right:"middle_right"};return{...p2,x:x3.x,y:x3.y,anchor:f2[p2.anchor]};case"circle":case"box":let d3=_(n3,{x:p2.x,y:p2.y});return{...p2,x:d3.x,y:d3.y}}}),h2=a2.map(p2=>({...p2,..._(n3,p2)}));return{primitives:m3,center:l2,ports:h2,size:y3,...o4}},Y=(t5,o4)=>{let{primitives:i3,center:l2,ports:a2,size:y3}=t5,n3=L({a:-1,b:0,c:0,d:1,e:0,f:2*l2.x}),m3=i3.map(p2=>{switch(p2={...p2},p2.type){case"path":return{...p2,points:p2.points.map(c3=>_(n3,c3))};case"text":let x3=_(n3,{x:p2.x,y:p2.y}),f2={top_left:"top_right",top_right:"top_left",bottom_left:"bottom_right",bottom_right:"bottom_left",center:"center",middle_top:"middle_top",middle_bottom:"middle_bottom",middle_left:"middle_right",middle_right:"middle_left"};return{...p2,x:x3.x,y:x3.y,anchor:f2[p2.anchor]};case"circle":case"box":let d3=_(n3,{x:p2.x,y:p2.y});return{...p2,x:d3.x,y:d3.y}}}),h2=a2.map(p2=>({...p2,..._(n3,p2)}));return{primitives:m3,center:l2,ports:h2,size:y3,...o4}},At=(t5,o4)=>{let{newOrientation:i3,overrides:l2}=o4,a2={up:Math.PI/2,right:0,down:-Math.PI/2,left:-Math.PI},y3=cr(i3?a2[i3]:Math.PI/2,t5.center.x,t5.center.y),{primitives:n3,center:m3,size:h2,ports:p2}=t5,x3=n3.map(c3=>{switch(c3={...c3},c3.type){case"path":return{...c3,points:c3.points.map(bf=>_(y3,bf))};case"text":let Ql=_(y3,{x:c3.x,y:c3.y});return c3.anchor=wf(c3.anchor,i3??"right"),{...c3,x:Ql.x,y:Ql.y};case"circle":let Kl=_(y3,{x:c3.x,y:c3.y});return{...c3,x:Kl.x,y:Kl.y};case"box":let tp=_(y3,{x:c3.x,y:c3.y});return{...c3,x:tp.x,y:tp.y,width:c3.height,height:c3.width}}}),f2=p2.map(c3=>({...c3,..._(y3,c3)})),d3=_t(x3);return{primitives:x3,center:m3,ports:f2,size:{width:d3.maxX-d3.minX,height:d3.maxY-d3.minY},...l2}},r=(t5,o4="down",i3={})=>At(t5,{newOrientation:o4,overrides:i3}),dr=class{constructor(o4){__publicField(this,"symbol");this.symbol=JSON.parse(JSON.stringify(o4)),this.symbol.size=this.computeSize()}changeTextAnchor(o4,i3,l2){return this.symbol={...this.symbol,primitives:this.symbol.primitives.map(a2=>a2.type==="text"&&a2.text===o4?{...a2,anchor:i3,...l2?{x:a2.x+l2.x,y:a2.y+l2.y}:{}}:a2)},this}labelPort(o4,i3){return this.symbol={...this.symbol,ports:this.symbol.ports.map(l2=>l2.labels.includes(o4)?{...l2,labels:i3}:l2)},this}rotateRightFacingSymbol(o4){return this.symbol=At(this.symbol,{newOrientation:o4}),this}computeSize(){let o4=_t(this.symbol.primitives);return{width:o4.maxX-o4.minX,height:o4.maxY-o4.minY}}build(){return{...this.symbol,size:this.computeSize()}}},e=t5=>{let o4=t5.primitives??[...Object.values(t5.paths??{}),...Object.values(t5.texts??{}),...Object.values(t5.circles??{}),...Object.values(t5.rects??{})],i3=t5.ports??Object.entries(t5.refblocks).flatMap(([a2,y3])=>[{...y3,labels:[a2]}]),l2=t5.center??{x:t5.bounds.centerX,y:t5.bounds.centerY};return i3.length===2&&(l2={x:(i3[0].x+i3[1].x)/2,y:(i3[0].y+i3[1].y)/2}),new dr({...t5,primitives:o4,ports:i3,center:l2})},w={paths:{path11:{type:"path",points:[{x:-.54,y:.03},{x:-.3,y:.04}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:.04},{x:.54,y:.04}],color:"primary",fill:!1},"path11-5-5":{type:"path",points:[{x:.1,y:.13},{x:0,y:-.06},{x:-.11,y:.13}],color:"primary",fill:!1},path17:{type:"path",points:[{x:0,y:-.13},{x:.07,y:-.11}],color:"primary",fill:!1},path18:{type:"path",points:[{x:.07,y:-.11},{x:.14,y:-.13}],color:"primary",fill:!1},path19:{type:"path",points:[{x:-.15,y:-.13},{x:-.07,y:-.11}],color:"primary",fill:!1},path20:{type:"path",points:[{x:-.07,y:-.11},{x:0,y:-.13}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.17,y:.4},bottom1:{type:"text",text:"{VAL}",x:-.01,y:-.4}},refblocks:{left1:{x:-.54,y:.03},right1:{x:.54,y:.04}},bounds:{minX:-.57,maxX:.57,minY:-.4,maxY:.4,width:1.14,height:.79,centerX:0,centerY:0},circles:{path1:{type:"circle",x:0,y:.04,radius:.29,color:"primary",fill:!1}}},{paths:Pf,texts:z4,bounds:Mt,refblocks:rp,circles:Sf}=w,op=e({primitives:[...Object.values(Pf),...Object.values(Sf),{type:"text",text:"{REF}",x:-.15,y:.3894553499999995},{type:"text",text:"{VAL}",x:.15,y:.3894553499999995}],ports:[{...rp.left1,labels:["1"]},{...rp.right1,labels:["2"]}],size:{width:Mt.width,height:Mt.height},center:{x:Mt.centerX,y:Mt.centerY}}).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:Rf,texts:M4,bounds:Ct,refblocks:ip,circles:Ff}=w,lp=e({primitives:[...Object.values(Rf),...Object.values(Ff),{type:"text",text:"{REF}",x:-0,y:.4094553499999995},{type:"text",text:"{VAL}",x:0,y:-.4094553499999995}],ports:[{...ip.left1,labels:["1"]},{...ip.right1,labels:["2"]}],size:{width:Ct.width,height:Ct.height},center:{x:Ct.centerX,y:Ct.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:Tf,texts:B4,bounds:Nt,refblocks:pp,circles:Ef}=w,ap=e({primitives:[...Object.values(Tf),...Object.values(Ef),{type:"text",text:"{REF}",x:-0,y:-.3094553499999995},{type:"text",text:"{VAL}",x:0,y:.4094553499999995}],ports:[{...pp.left1,labels:["1"]},{...pp.right1,labels:["2"]}],size:{width:Nt.width,height:Nt.height},center:{x:Nt.centerX,y:Nt.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:Yf,texts:U4,bounds:It,refblocks:yp,circles:Xf}=w,xp=e({primitives:[...Object.values(Yf),...Object.values(Xf),{type:"text",text:"{REF}",x:-0,y:.4094553499999995},{type:"text",text:"{VAL}",x:0,y:-.4094553499999995}],ports:[{...yp.left1,labels:["1"]},{...yp.right1,labels:["2"]}],size:{width:It.width,height:It.height},center:{x:It.centerX,y:It.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:Lf,texts:Q4,bounds:Bt,refblocks:sp,circles:Vf}=w,mp=e({primitives:[...Object.values(Lf),...Object.values(Vf),{type:"text",text:"{REF}",x:.15,y:-.2894553499999995},{type:"text",text:"{VAL}",x:-.15,y:-.2894553499999995}],ports:[{...sp.left1,labels:["1"]},{...sp.right1,labels:["2"]}],size:{width:Bt.width,height:Bt.height},center:{x:Bt.centerX,y:Bt.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:jf,texts:r5,bounds:qt,refblocks:np,circles:kf}=w,fp2=e({primitives:[...Object.values(jf),...Object.values(kf),{type:"text",text:"{REF}",x:.15,y:-.2894553499999995},{type:"text",text:"{VAL}",x:-.15,y:-.2894553499999995}],ports:[{...np.left1,labels:["1"]},{...np.right1,labels:["2"]}],size:{width:qt.width,height:qt.height},center:{x:qt.centerX,y:qt.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),A={paths:{path40:{type:"path",points:[{x:.14,y:.04},{x:-.12,y:-.09}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.12,y:.18},{x:.14,y:.04}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.12,y:-.09},{x:-.12,y:.18}],color:"primary",fill:!1},path43:{type:"path",points:[{x:.14,y:.18},{x:.14,y:-.09}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.12,y:.04},{x:-.52,y:.04}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.52,y:.04},{x:.15,y:.04}],color:"primary",fill:!1},"path43-8":{type:"path",points:[{x:.14,y:.18},{x:.08,y:.2}],color:"primary",fill:!1},"path43-8-3":{type:"path",points:[{x:.21,y:-.11},{x:.15,y:-.09}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.01,y:.27},bottom1:{type:"text",text:"{VAL}",x:0,y:-.27}},refblocks:{left1:{x:-.52,y:.04},right1:{x:.52,y:.04}},bounds:{minX:-.55,maxX:.55,minY:-.27,maxY:.27,width:1.09,height:.55,centerX:0,centerY:0},circles:{}},{paths:Of,texts:a5,bounds:Dt,refblocks:cp,circles:Jf}=A,hp=e({primitives:[...Object.values(Of),...Object.values(Jf),{type:"text",text:"{REF}",x:-.15,y:.3294553499999995},{type:"text",text:"{VAL}",x:.15,y:.3294553499999995}],ports:[{...cp.left1,labels:["1"]},{...cp.right1,labels:["2"]}],size:{width:Dt.width,height:Dt.height},center:{x:Dt.centerX,y:Dt.centerY}}).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),dp=e(A).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1","neg"]).labelPort("right1",["2","pos"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:$f,texts:c5,bounds:Gt,refblocks:bp,circles:Mf}=A,_p=e({primitives:[...Object.values($f),...Object.values(Mf),{type:"text",text:"{REF}",x:-0,y:-.2294553499999995},{type:"text",text:"{VAL}",x:0,y:.3294553499999995}],ports:[{...bp.left1,labels:["1"]},{...bp.right1,labels:["2"]}],size:{width:Gt.width,height:Gt.height},center:{x:Gt.centerX,y:Gt.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),gp=e(A).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1","neg"]).labelPort("right1",["2","pos"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:Cf,texts:v5,bounds:Ut,refblocks:up,circles:Nf}=A,vp=e({primitives:[...Object.values(Cf),...Object.values(Nf),{type:"text",text:"{REF}",x:.15,y:-.2294553499999995},{type:"text",text:"{VAL}",x:-.15,y:-.2294553499999995}],ports:[{...up.left1,labels:["1"]},{...up.right1,labels:["2"]}],size:{width:Ut.width,height:Ut.height},center:{x:Ut.centerX,y:Ut.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:If,texts:S5,bounds:Wt,refblocks:wp,circles:Bf}=A,Ap=e({primitives:[...Object.values(If),...Object.values(Bf),{type:"text",text:"{REF}",x:.15,y:-.2294553499999995},{type:"text",text:"{VAL}",x:-.15,y:-.2294553499999995}],ports:[{...wp.left1,labels:["1"]},{...wp.right1,labels:["2"]}],size:{width:Wt.width,height:Wt.height},center:{x:Wt.centerX,y:Wt.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),V={paths:{path40:{type:"path",points:[{x:.14,y:.04},{x:-.12,y:-.09}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.12,y:.18},{x:.14,y:.04}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.12,y:-.09},{x:-.12,y:.18}],color:"primary",fill:!1},path43:{type:"path",points:[{x:.14,y:.18},{x:.14,y:-.09}],color:"primary",fill:!1},path44:{type:"path",points:[{x:.14,y:.04},{x:-.52,y:.04}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.52,y:.04},{x:.15,y:.04}],color:"primary",fill:!1},"path43-8":{type:"path",points:[{x:.18,y:.18},{x:.11,y:.18}],color:"primary",fill:!1},"path43-8-8":{type:"path",points:[{x:.18,y:-.09},{x:.11,y:-.09}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.01,y:.27},bottom1:{type:"text",text:"{VAL}",x:0,y:-.27}},refblocks:{left1:{x:-.52,y:.04},right1:{x:.52,y:.04}},bounds:{minX:-.55,maxX:.55,minY:-.27,maxY:.27,width:1.09,height:.55,centerX:0,centerY:0},circles:{}},{paths:Df,texts:Y5,bounds:Ht,refblocks:Pp,circles:Gf}=V,Sp=e({primitives:[...Object.values(Df),...Object.values(Gf),{type:"text",text:"{REF}",x:-.16,y:.2294553499999995},{type:"text",text:"{VAL}",x:.16,y:.2294553499999995}],ports:[{...Pp.left1,labels:["1"]},{...Pp.right1,labels:["2"]}],size:{width:Ht.width,height:Ht.height},center:{x:Ht.centerX,y:Ht.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").build(),{paths:Uf,texts:j5,bounds:Zt,refblocks:Rp,circles:Wf}=V,Qt=e({primitives:[...Object.values(Uf),...Object.values(Wf),{type:"text",text:"{REF}",x:-1118e-7,y:-.18},{type:"text",text:"{VAL}",x:1118e-7,y:.2738453}],ports:[{...Rp.left1,labels:["1"]},{...Rp.right1,labels:["2"]}],size:{width:Zt.width,height:Zt.height},center:{x:Zt.centerX,y:Zt.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("left").labelPort("left1",["2"]).labelPort("right1",["1"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:Hf,texts:J5,bounds:Kt,refblocks:Fp,circles:Zf}=V,Tp=e({primitives:[...Object.values(Hf),...Object.values(Zf),{type:"text",text:"{REF}",x:-.0050250999999996715,y:.27384529999999985,anchor:"middle_left"},{type:"text",text:"{VAL}",x:-.00011179999999999524,y:-.27384530000000007,anchor:"middle_left"}],ports:[{...Fp.left1,labels:["1"]},{...Fp.right1,labels:["2"]}],size:{width:Kt.width,height:Kt.height},center:{x:Kt.centerX,y:Kt.centerY}}).changeTextAnchor("{VAL}","middle_top").labelPort("right1",["2"]).labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:I5,texts:B5,bounds:q5,refblocks:D5,circles:G5}=V,br=r(Qt,"down"),_r=br.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),gr=br.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");_r.anchor="middle_left";gr.anchor="middle_left";_r.x=.25;_r.y+=.21;gr.y-=.21;gr.x=.25;Ep=br;Yp={paths:{path43:{type:"path",points:[{x:-.06,y:.19},{x:-.06,y:-.12}],color:"primary",fill:!1},"path43-6":{type:"path",points:[{x:.02,y:.13},{x:.02,y:-.06}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.06,y:.03},{x:-.45,y:.03}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.45,y:.03},{x:.03,y:.03}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.03,y:.27},bottom1:{type:"text",text:"{VAL}",x:-.03,y:-.28}},refblocks:{left1:{x:-.45,y:.03},right1:{x:.45,y:.03}},bounds:{minX:-.47,maxX:.47,minY:-.38,maxY:.27,width:.95,height:.29,centerX:0,centerY:.06},circles:{}},{paths:Kf,texts:Xp,bounds:te,refblocks:Lp,circles:tc}=Yp,ee=s({primitives:[...Object.values(Kf),...Object.values(tc),{...Xp.top1,anchor:"middle_bottom"},{...Xp.bottom1,anchor:"middle_top"}],ports:[{...Lp.left1,labels:["1"]},{...Lp.right1,labels:["2"]}],size:{width:te.width,height:te.height},center:{x:te.centerX,y:te.centerY}}),Vp=At(ee,{newOrientation:"up"}),j={paths:{path1:{type:"path",points:[{x:-.53,y:.05},{x:-.25,y:.05}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.28,y:.05},{x:.57,y:.05}],color:"primary",fill:!1},path3:{type:"path",points:[{x:.02,y:.18},{x:.28,y:.18},{x:.28,y:-.09},{x:-.25,y:-.09},{x:-.25,y:.18},{x:.02,y:.18}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:0,y:.25},bottom1:{type:"text",text:"{VAL}",x:0,y:-.25}},refblocks:{left1:{x:-.53,y:.05},right1:{x:.57,y:.05}},bounds:{minX:-.56,maxX:.56,minY:-.25,maxY:.25,width:1.12,height:.5,centerX:0,centerY:0},circles:{}},{paths:rc,texts:ag,bounds:jp,refblocks:kp,circles:oc}=j,zp=e({primitives:[...Object.values(rc),...Object.values(oc),{type:"text",text:"{REF}",x:-.16,y:.2294553499999995},{type:"text",text:"{VAL}",x:.16,y:.2294553499999995}],ports:[{...kp.left1,labels:["1"]},{...kp.right1,labels:["2"]}],center:{x:jp.centerX,y:jp.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").build(),{paths:ic,texts:mg,bounds:Op,refblocks:Jp,circles:lc}=j,$p=e({primitives:[...Object.values(ic),...Object.values(lc),{type:"text",text:"{REF}",x:0,y:-.1994553499999995},{type:"text",text:"{VAL}",x:0,y:.2694553499999995}],ports:[{...Jp.left1,labels:["1"]},{...Jp.right1,labels:["2"]}],center:{x:Op.centerX,y:Op.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:pc,texts:hg,bounds:Mp,refblocks:Cp,circles:ac}=j,Np=e({primitives:[...Object.values(pc),...Object.values(ac),{type:"text",text:"{REF}",x:0,y:.2294553499999995},{type:"text",text:"{VAL}",x:0,y:-.1594553499999995}],ports:[{...Cp.left1,labels:["1"]},{...Cp.right1,labels:["2"]}],center:{x:Mp.centerX,y:Mp.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),k={paths:{path2:{type:"path",points:[{x:.15,y:-.01},{x:.55,y:-.01}],color:"primary",fill:!0},"path2-5":{type:"path",points:[{x:-.15,y:.06},{x:.14,y:.06}],color:"primary",fill:!0},"path2-5-1":{type:"path",points:[{x:.14,y:.06},{x:.14,y:-.08}],color:"primary",fill:!0},"path2-5-1-6":{type:"path",points:[{x:-.16,y:.06},{x:-.16,y:-.08}],color:"primary",fill:!0},"path2-5-4":{type:"path",points:[{x:-.15,y:-.08},{x:.14,y:-.08}],color:"primary",fill:!0},"path2-9":{type:"path",points:[{x:-.55,y:-.01},{x:-.17,y:-.01}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:-.01,y:.17},bottom1:{type:"text",text:"{VAL}",x:0,y:-.17}},refblocks:{left1:{x:-.55,y:-.01},right1:{x:.55,y:-.01}},bounds:{minX:-.58,maxX:.58,minY:-.17,maxY:.17,width:1.16,height:.35,centerX:0,centerY:0},circles:{}},{paths:xc,texts:ug,bounds:re,refblocks:Ip,circles:sc}=k,Bp=e({primitives:[...Object.values(xc),...Object.values(sc),{type:"text",text:"{REF}",x:-.2,y:.1404553499999995},{type:"text",text:"{VAL}",x:.2,y:.1494553499999995}],ports:[{...Ip.left1,labels:["1"]},{...Ip.right1,labels:["2"]}],size:{width:re.width,height:re.height},center:{x:re.centerX,y:re.centerY}}).rotateRightFacingSymbol("down").labelPort("left",["1"]).labelPort("right",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:mc,texts:Pg,bounds:oe,refblocks:qp,circles:nc}=k,Dp=e({primitives:[...Object.values(mc),...Object.values(nc),{type:"text",text:"{REF}",x:0,y:-.2294553499999995},{type:"text",text:"{VAL}",x:0,y:.1704553499999995}],ports:[{...qp.left1,labels:["1"]},{...qp.right1,labels:["2"]}],size:{width:oe.width,height:oe.height},center:{x:oe.centerX,y:oe.centerY}}).rotateRightFacingSymbol("left").labelPort("left",["1"]).labelPort("right",["2"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),{paths:fc,texts:Tg,bounds:ie,refblocks:Gp,circles:cc}=k,Up=e({primitives:[...Object.values(fc),...Object.values(cc),{type:"text",text:"{REF}",x:0,y:.2294553499999995},{type:"text",text:"{VAL}",x:0,y:-.1704553499999995}],ports:[{...Gp.left1,labels:["1"]},{...Gp.right1,labels:["2"]}],size:{width:ie.width,height:ie.height},center:{x:ie.centerX,y:ie.centerY}}).rotateRightFacingSymbol("right").labelPort("left",["1"]).labelPort("right",["2"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),{paths:hc,texts:Lg,bounds:le,refblocks:Wp,circles:dc}=k,Hp=e({primitives:[...Object.values(hc),...Object.values(dc),{type:"text",text:"{REF}",x:.2,y:-.1404553499999995},{type:"text",text:"{VAL}",x:-.2,y:-.1494553499999995}],ports:[{...Wp.left1,labels:["1"]},{...Wp.right1,labels:["2"]}],size:{width:le.width,height:le.height},center:{x:le.centerX,y:le.centerY}}).rotateRightFacingSymbol("up").labelPort("left",["1"]).labelPort("right",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:bc,texts:zg,bounds:Zp,refblocks:Qp,circles:_c}=j,Kp=e({primitives:[...Object.values(bc),...Object.values(_c),{type:"text",text:"{REF}",x:.16,y:-.2294553499999995},{type:"text",text:"{VAL}",x:-.16,y:-.2294553499999995}],ports:[{...Qp.left1,labels:["1"]},{...Qp.right1,labels:["2"]}],center:{x:Zp.centerX,y:Zp.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").build(),gt={paths:{"horizontal-bar":{type:"path",points:[{x:-.4,y:0},{x:.4,y:0}],color:"primary",fill:!1},"middle-dash-1":{type:"path",points:[{x:0,y:.2},{x:0,y:.07}],color:"primary",fill:!1},"middle-dash-2":{type:"path",points:[{x:0,y:.01},{x:0,y:-.12}],color:"primary",fill:!1},"middle-dash-3":{type:"path",points:[{x:0,y:-.18},{x:0,y:-.31}],color:"primary",fill:!1},"left-vertical":{type:"path",points:[{x:-.25,y:0},{x:-.25,y:-.2}],color:"primary",fill:!1},"right-vertical":{type:"path",points:[{x:.25,y:0},{x:.25,y:-.2}],color:"primary",fill:!1},"left-ground":{type:"path",points:[{x:-.3,y:-.2},{x:-.25,y:-.3},{x:-.2,y:-.2},{x:-.3,y:-.2}],color:"primary",fill:!1},"right-ground":{type:"path",points:[{x:.2,y:-.2},{x:.25,y:-.3},{x:.3,y:-.2},{x:.2,y:-.2}],color:"primary",fill:!1}},refblocks:{left1:{x:-.4,y:0},right1:{x:.4,y:0}},texts:{ref:{type:"text",text:"{REF}",x:0,y:.35}},bounds:{minX:-.4,maxX:.4,minY:-.4,maxY:.35,width:.8,height:.75,centerX:0,centerY:-.02},circles:{}},{paths:uc,texts:Cg,bounds:ta,refblocks:ea,circles:vc}=gt,ra=e({primitives:[...Object.values(uc),...Object.values(vc),{type:"text",text:"{REF}",x:0,y:.2594553499999995}],ports:[{...ea.left1,labels:["1"]},{...ea.right1,labels:["2"]}],center:{x:ta.centerX,y:ta.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").build(),{paths:wc,texts:qg,bounds:oa,refblocks:ia,circles:Ac}=gt,pe=e({primitives:[...Object.values(wc),...Object.values(Ac),{type:"text",text:"{REF}",x:0,y:.2594553499999995}],ports:[{...ia.left1,labels:["1"]},{...ia.right1,labels:["2"]}],center:{x:oa.centerX,y:oa.centerY}}).rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),la=Y(pe),{paths:Pc,texts:Qg,bounds:pa,refblocks:aa,circles:Sc}=gt,ya=e({primitives:[...Object.values(Pc),...Object.values(Sc),{type:"text",text:"{REF}",x:0,y:.2594553499999995}],ports:[{...aa.left1,labels:["1"]},{...aa.right1,labels:["2"]}],center:{x:pa.centerX,y:pa.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_right").build(),z={paths:{path27:{type:"path",points:[{x:.55,y:.02},{x:.07,y:.02}],color:"primary",fill:!1},path28:{type:"path",points:[{x:-.09,y:.02},{x:-.55,y:.02}],color:"primary",fill:!1},path29:{type:"path",points:[{x:.07,y:.28},{x:.07,y:-.25}],color:"primary",fill:!1},path30:{type:"path",points:[{x:-.09,y:.28},{x:-.09,y:-.25}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.01,y:.42},bottom1:{type:"text",text:"{VAL}",x:0,y:-.42}},refblocks:{left1:{x:-.55,y:.02},right1:{x:.55,y:.02}},bounds:{minX:-.58,maxX:.58,minY:-.42,maxY:.42,width:1.16,height:.84,centerX:0,centerY:0},circles:{}},{paths:Fc,texts:ou,bounds:ae,refblocks:xa,circles:Tc}=z,sa=e({primitives:[...Object.values(Fc),...Object.values(Tc),{type:"text",text:"{REF}",x:-.2,y:.115},{type:"text",text:"{VAL}",x:.2,y:.115}],ports:[{...xa.left1,labels:["1"]},{...xa.right1,labels:["2"]}],size:{width:ae.width,height:ae.height},center:{x:ae.centerX,y:ae.centerY}}).changeTextAnchor("{VAL}","top_left").rotateRightFacingSymbol("down").labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{REF}","bottom_left").build(),ma=e(z).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["2","neg"]).labelPort("right1",["1","pos"]).changeTextAnchor("{REF}","middle_bottom").build(),O={paths:{"path27-5":{type:"path",points:[{x:.45,y:.02},{x:0,y:.02}],color:"primary",fill:!1},"path28-5":{type:"path",points:[{x:-.09,y:.02},{x:-.54,y:.02}],color:"primary",fill:!1},"path30-7":{type:"path",points:[{x:0,y:.28},{x:0,y:-.25}],color:"primary",fill:!1},path8704:{type:"path",points:[{x:-.14,y:-.24},{x:-.14,y:-.24},{x:-.14,y:-.24},{x:-.14,y:-.24},{x:-.14,y:-.24},{x:-.14,y:-.24},{x:-.14,y:-.24},{x:-.14,y:-.24},{x:-.14,y:-.24},{x:-.14,y:-.23},{x:-.14,y:-.23},{x:-.14,y:-.23},{x:-.14,y:-.23},{x:-.13,y:-.23},{x:-.13,y:-.23},{x:-.13,y:-.23},{x:-.13,y:-.23},{x:-.13,y:-.22},{x:-.13,y:-.22},{x:-.13,y:-.22},{x:-.13,y:-.22},{x:-.13,y:-.22},{x:-.13,y:-.22},{x:-.13,y:-.22},{x:-.13,y:-.22},{x:-.13,y:-.21},{x:-.13,y:-.21},{x:-.13,y:-.21},{x:-.12,y:-.21},{x:-.12,y:-.21},{x:-.12,y:-.21},{x:-.12,y:-.21},{x:-.12,y:-.21},{x:-.12,y:-.2},{x:-.12,y:-.2},{x:-.12,y:-.2},{x:-.12,y:-.2},{x:-.12,y:-.2},{x:-.12,y:-.2},{x:-.12,y:-.2},{x:-.12,y:-.2},{x:-.12,y:-.19},{x:-.12,y:-.19},{x:-.12,y:-.19},{x:-.12,y:-.19},{x:-.11,y:-.19},{x:-.11,y:-.19},{x:-.11,y:-.19},{x:-.11,y:-.18},{x:-.11,y:-.18},{x:-.11,y:-.18},{x:-.11,y:-.18},{x:-.11,y:-.18},{x:-.11,y:-.18},{x:-.11,y:-.18},{x:-.11,y:-.18},{x:-.11,y:-.17},{x:-.11,y:-.17},{x:-.11,y:-.17},{x:-.11,y:-.17},{x:-.11,y:-.17},{x:-.11,y:-.17},{x:-.11,y:-.17},{x:-.11,y:-.17},{x:-.1,y:-.16},{x:-.1,y:-.16},{x:-.1,y:-.16},{x:-.1,y:-.16},{x:-.1,y:-.16},{x:-.1,y:-.16},{x:-.1,y:-.16},{x:-.1,y:-.16},{x:-.1,y:-.15},{x:-.1,y:-.15},{x:-.1,y:-.15},{x:-.1,y:-.15},{x:-.1,y:-.15},{x:-.1,y:-.15},{x:-.1,y:-.15},{x:-.1,y:-.14},{x:-.1,y:-.14},{x:-.1,y:-.14},{x:-.1,y:-.14},{x:-.1,y:-.14},{x:-.1,y:-.14},{x:-.1,y:-.14},{x:-.09,y:-.14},{x:-.09,y:-.13},{x:-.09,y:-.13},{x:-.09,y:-.13},{x:-.09,y:-.13},{x:-.09,y:-.13},{x:-.09,y:-.13},{x:-.09,y:-.13},{x:-.09,y:-.13},{x:-.09,y:-.12},{x:-.09,y:-.12},{x:-.09,y:-.12},{x:-.09,y:-.12},{x:-.09,y:-.12},{x:-.09,y:-.12},{x:-.09,y:-.12},{x:-.09,y:-.12},{x:-.09,y:-.11},{x:-.09,y:-.11},{x:-.09,y:-.11},{x:-.09,y:-.11},{x:-.09,y:-.11},{x:-.09,y:-.11},{x:-.09,y:-.1},{x:-.09,y:-.1},{x:-.09,y:-.1},{x:-.09,y:-.1},{x:-.09,y:-.1},{x:-.09,y:-.1},{x:-.08,y:-.09},{x:-.08,y:-.09},{x:-.08,y:-.09},{x:-.08,y:-.09},{x:-.08,y:-.09},{x:-.08,y:-.09},{x:-.08,y:-.08},{x:-.08,y:-.08},{x:-.08,y:-.08},{x:-.08,y:-.08},{x:-.08,y:-.08},{x:-.08,y:-.08},{x:-.08,y:-.07},{x:-.08,y:-.07},{x:-.08,y:-.07},{x:-.08,y:-.07},{x:-.08,y:-.07},{x:-.08,y:-.07},{x:-.08,y:-.06},{x:-.08,y:-.06},{x:-.08,y:-.06},{x:-.08,y:-.06},{x:-.08,y:-.06},{x:-.08,y:-.05},{x:-.08,y:-.05},{x:-.08,y:-.05},{x:-.08,y:-.05},{x:-.08,y:-.05},{x:-.08,y:-.05},{x:-.08,y:-.04},{x:-.08,y:-.04},{x:-.08,y:-.04},{x:-.08,y:-.04},{x:-.08,y:-.04},{x:-.08,y:-.04},{x:-.08,y:-.03},{x:-.08,y:-.03},{x:-.08,y:-.03},{x:-.08,y:-.03},{x:-.08,y:-.03},{x:-.08,y:-.03},{x:-.08,y:-.02},{x:-.08,y:-.02},{x:-.08,y:-.02},{x:-.08,y:-.02},{x:-.08,y:-.02},{x:-.08,y:-.02},{x:-.08,y:-.01},{x:-.08,y:-.01},{x:-.08,y:-.01},{x:-.08,y:-.01},{x:-.08,y:-.01},{x:-.08,y:0},{x:-.08,y:0},{x:-.08,y:0},{x:-.08,y:0},{x:-.08,y:0},{x:-.08,y:0},{x:-.08,y:.01},{x:-.07,y:.01},{x:-.07,y:.01},{x:-.07,y:.01},{x:-.07,y:.01},{x:-.07,y:.01},{x:-.08,y:.02},{x:-.08,y:.02},{x:-.08,y:.02},{x:-.08,y:.02},{x:-.08,y:.02},{x:-.08,y:.02},{x:-.08,y:.03},{x:-.08,y:.03},{x:-.08,y:.03},{x:-.08,y:.03},{x:-.08,y:.03},{x:-.08,y:.03},{x:-.08,y:.04},{x:-.08,y:.04},{x:-.08,y:.04},{x:-.08,y:.04},{x:-.08,y:.04},{x:-.08,y:.05},{x:-.08,y:.05},{x:-.08,y:.05},{x:-.08,y:.05},{x:-.08,y:.05},{x:-.08,y:.05},{x:-.08,y:.06},{x:-.08,y:.06},{x:-.08,y:.06},{x:-.08,y:.06},{x:-.08,y:.06},{x:-.08,y:.06},{x:-.08,y:.06},{x:-.08,y:.06},{x:-.08,y:.07},{x:-.08,y:.07},{x:-.08,y:.07},{x:-.08,y:.07},{x:-.08,y:.07},{x:-.08,y:.07},{x:-.08,y:.07},{x:-.08,y:.08},{x:-.08,y:.08},{x:-.08,y:.08},{x:-.08,y:.08},{x:-.08,y:.08},{x:-.08,y:.08},{x:-.08,y:.09},{x:-.08,y:.09},{x:-.08,y:.09},{x:-.08,y:.09},{x:-.08,y:.09},{x:-.08,y:.09},{x:-.08,y:.09},{x:-.08,y:.1},{x:-.08,y:.1},{x:-.08,y:.1},{x:-.08,y:.1},{x:-.08,y:.1},{x:-.08,y:.1},{x:-.08,y:.1},{x:-.08,y:.11},{x:-.08,y:.11},{x:-.08,y:.11},{x:-.08,y:.11},{x:-.08,y:.11},{x:-.08,y:.11},{x:-.08,y:.11},{x:-.08,y:.12},{x:-.08,y:.12},{x:-.08,y:.12},{x:-.08,y:.12},{x:-.09,y:.12},{x:-.09,y:.12},{x:-.09,y:.12},{x:-.09,y:.13},{x:-.09,y:.13},{x:-.09,y:.13},{x:-.09,y:.13},{x:-.09,y:.13},{x:-.09,y:.13},{x:-.09,y:.14},{x:-.09,y:.14},{x:-.09,y:.14},{x:-.09,y:.14},{x:-.09,y:.14},{x:-.09,y:.14},{x:-.09,y:.14},{x:-.09,y:.15},{x:-.09,y:.15},{x:-.09,y:.15},{x:-.09,y:.15},{x:-.09,y:.15},{x:-.09,y:.15},{x:-.09,y:.15},{x:-.09,y:.16},{x:-.09,y:.16},{x:-.09,y:.16},{x:-.09,y:.16},{x:-.09,y:.16},{x:-.09,y:.16},{x:-.09,y:.16},{x:-.09,y:.17},{x:-.09,y:.17},{x:-.1,y:.17},{x:-.1,y:.17},{x:-.1,y:.17},{x:-.1,y:.17},{x:-.1,y:.17},{x:-.1,y:.18},{x:-.1,y:.18},{x:-.1,y:.18},{x:-.1,y:.18},{x:-.1,y:.18},{x:-.1,y:.18},{x:-.1,y:.18},{x:-.1,y:.19},{x:-.1,y:.19},{x:-.1,y:.19},{x:-.1,y:.19},{x:-.1,y:.19},{x:-.1,y:.19},{x:-.1,y:.19},{x:-.1,y:.2},{x:-.1,y:.2},{x:-.1,y:.2},{x:-.1,y:.2},{x:-.1,y:.2},{x:-.1,y:.2},{x:-.11,y:.2},{x:-.11,y:.2},{x:-.11,y:.2},{x:-.11,y:.21},{x:-.11,y:.21},{x:-.11,y:.21},{x:-.11,y:.21},{x:-.11,y:.21},{x:-.11,y:.21},{x:-.11,y:.21},{x:-.11,y:.21},{x:-.11,y:.21},{x:-.11,y:.21},{x:-.11,y:.21},{x:-.11,y:.21},{x:-.11,y:.21},{x:-.11,y:.22},{x:-.11,y:.22},{x:-.11,y:.22},{x:-.11,y:.22},{x:-.11,y:.22},{x:-.11,y:.22},{x:-.11,y:.22},{x:-.11,y:.22},{x:-.11,y:.22},{x:-.11,y:.22},{x:-.11,y:.22},{x:-.11,y:.22},{x:-.11,y:.23},{x:-.11,y:.23},{x:-.11,y:.23},{x:-.11,y:.23},{x:-.12,y:.23},{x:-.12,y:.23},{x:-.12,y:.23},{x:-.12,y:.23},{x:-.12,y:.23},{x:-.12,y:.23},{x:-.12,y:.23},{x:-.12,y:.23},{x:-.12,y:.24},{x:-.12,y:.24},{x:-.12,y:.24},{x:-.12,y:.24},{x:-.12,y:.24},{x:-.12,y:.24},{x:-.12,y:.24},{x:-.12,y:.24},{x:-.12,y:.24},{x:-.12,y:.24},{x:-.12,y:.24},{x:-.12,y:.24},{x:-.12,y:.25},{x:-.12,y:.25},{x:-.12,y:.25},{x:-.12,y:.25},{x:-.12,y:.25},{x:-.12,y:.25},{x:-.13,y:.25},{x:-.13,y:.25},{x:-.13,y:.25},{x:-.13,y:.25},{x:-.13,y:.25},{x:-.13,y:.25},{x:-.13,y:.25},{x:-.13,y:.26},{x:-.13,y:.26},{x:-.13,y:.26},{x:-.13,y:.26},{x:-.13,y:.26},{x:-.13,y:.26},{x:-.13,y:.26},{x:-.13,y:.26},{x:-.13,y:.26},{x:-.13,y:.26},{x:-.13,y:.26},{x:-.13,y:.26},{x:-.13,y:.26},{x:-.13,y:.27},{x:-.13,y:.27},{x:-.13,y:.27},{x:-.13,y:.27},{x:-.14,y:.27},{x:-.14,y:.27},{x:-.14,y:.27},{x:-.14,y:.27},{x:-.14,y:.27},{x:-.14,y:.27},{x:-.14,y:.27},{x:-.14,y:.27},{x:-.14,y:.27},{x:-.14,y:.28},{x:-.14,y:.28},{x:-.14,y:.28},{x:-.14,y:.28},{x:-.14,y:.28},{x:-.14,y:.28},{x:-.14,y:.28},{x:-.14,y:.28},{x:-.14,y:.28}],color:"primary",fill:!1},"rect1577-4":{type:"path",points:[{x:.26,y:.25},{x:.12,y:.25},{x:.12,y:.25},{x:.26,y:.25}],color:"primary",fill:!0},"rect1577-4-7":{type:"path",points:[{x:.2,y:.32},{x:.2,y:.18},{x:.19,y:.18},{x:.19,y:.32}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:-.01,y:.42},bottom1:{type:"text",text:"{VAL}",x:0,y:-.42}},refblocks:{left1:{x:-.54,y:.02},right1:{x:.45,y:.02}},bounds:{minX:-.58,maxX:.58,minY:-.42,maxY:.42,width:1.16,height:.84,centerX:0,centerY:0},circles:{}},{paths:Yc,texts:mu,bounds:ye,refblocks:na,circles:Xc}=O,fa=e({primitives:[...Object.values(Yc),...Object.values(Xc),{type:"text",text:"{REF}",x:.1,y:-.2094553499999995},{type:"text",text:"{VAL}",x:-.2,y:-.2094553499999995}],ports:[{...na.left1,labels:["2","neg"]},{...na.right1,labels:["1","pos"]}],size:{width:ye.width,height:ye.height},center:{x:ye.centerX,y:ye.centerY}}).changeTextAnchor("{VAL}","top_left").rotateRightFacingSymbol("up").changeTextAnchor("{REF}","bottom_left").build(),ca=e(O).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["2","neg"]).labelPort("right1",["1","pos"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:Lc,texts:_u,bounds:xe,refblocks:ha,circles:Vc}=O,da=e({primitives:[...Object.values(Lc),...Object.values(Vc),{type:"text",text:"{REF}",x:0,y:-.4094553499999995},{type:"text",text:"{VAL}",x:-0,y:.4094553499999995}],ports:[{...ha.left1,labels:["2","neg"]},{...ha.right1,labels:["1","pos"]}],size:{width:xe.width,height:xe.height},center:{x:xe.centerX,y:xe.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("left").changeTextAnchor("{REF}","middle_bottom").build(),{paths:jc,texts:wu,bounds:se,refblocks:ba,circles:kc}=O,_a=e({primitives:[...Object.values(jc),...Object.values(kc),{type:"text",text:"{REF}",x:-.2,y:.2094553499999995},{type:"text",text:"{VAL}",x:.3,y:.2094553499999995}],ports:[{...ba.left1,labels:["2","neg"]},{...ba.right1,labels:["1","pos"]}],size:{width:se.width,height:se.height},center:{x:se.centerX,y:se.centerY}}).changeTextAnchor("{VAL}","top_left").rotateRightFacingSymbol("down").changeTextAnchor("{REF}","bottom_left").build(),ga=e(z).rotateRightFacingSymbol("right").changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:zc,texts:Eu,bounds:me,refblocks:ua,circles:Oc}=z,va=e({primitives:[...Object.values(zc),...Object.values(Oc),{type:"text",text:"{REF}",x:.2,y:-.095},{type:"text",text:"{VAL}",x:-.2,y:-.095}],ports:[{...ua.left1,labels:["1"]},{...ua.right1,labels:["2"]}],size:{width:me.width,height:me.height},center:{x:me.centerX,y:me.centerY}}).changeTextAnchor("{VAL}","top_left").rotateRightFacingSymbol("up").labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{REF}","bottom_left").build(),P={paths:{path11:{type:"path",points:[{x:-.54,y:.03},{x:-.3,y:.03}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:.03},{x:.54,y:.03}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.29,y:.29},{x:.29,y:-.23}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.02,y:.37},bottom1:{type:"text",text:"{VAL}",x:-.01,y:-.37}},refblocks:{left1:{x:-.54,y:.03},right1:{x:.54,y:.03}},bounds:{minX:-.57,maxX:.57,minY:-.37,maxY:.37,width:1.14,height:.74,centerX:0,centerY:0},circles:{path1:{type:"circle",x:0,y:.04,radius:.29,color:"primary",fill:!1}}},{paths:$c,texts:ju,bounds:ne,refblocks:wa,circles:Mc}=P,Aa=e({primitives:[...Object.values($c),...Object.values(Mc),{type:"text",text:"{REF}",x:-.15,y:.3894553499999995},{type:"text",text:"{VAL}",x:.15,y:.3894553499999995}],ports:[{...wa.left1,labels:["1"]},{...wa.right1,labels:["2"]}],size:{width:ne.width,height:ne.height},center:{x:ne.centerX,y:ne.centerY}}).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),Pa=e(P).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:Cc,texts:Cu,bounds:fe,refblocks:Sa,circles:Nc}=P,Ra=e({primitives:[...Object.values(Cc),...Object.values(Nc),{type:"text",text:"{REF}",x:-0,y:-.2894553499999995},{type:"text",text:"{VAL}",x:0,y:.3894553499999995}],ports:[{...Sa.left1,labels:["1"]},{...Sa.right1,labels:["2"]}],size:{width:fe.width,height:fe.height},center:{x:fe.centerX,y:fe.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),Fa=e(P).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1","neg"]).labelPort("right1",["2","pos"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:Ic,texts:Uu,bounds:ce,refblocks:Ta,circles:Bc}=P,Ea=e({primitives:[...Object.values(Ic),...Object.values(Bc),{type:"text",text:"{REF}",x:.15,y:-.2894553499999995},{type:"text",text:"{VAL}",x:-.15,y:-.2894553499999995}],ports:[{...Ta.left1,labels:["1"]},{...Ta.right1,labels:["2"]}],size:{width:ce.width,height:ce.height},center:{x:ce.centerX,y:ce.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:qc,texts:Qu,bounds:he,refblocks:Ya,circles:Dc}=P,Xa=e({primitives:[...Object.values(qc),...Object.values(Dc),{type:"text",text:"{REF}",x:.15,y:-.2894553499999995},{type:"text",text:"{VAL}",x:-.15,y:-.2894553499999995}],ports:[{...Ya.left1,labels:["1"]},{...Ya.right1,labels:["2"]}],size:{width:he.width,height:he.height},center:{x:he.centerX,y:he.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),J={paths:{path27:{type:"path",points:[{x:.54,y:-.01},{x:.13,y:-.01}],color:"primary",fill:!1},path29:{type:"path",points:[{x:.13,y:.25},{x:.13,y:-.27}],color:"primary",fill:!1},"path29-2":{type:"path",points:[{x:.07,y:.25},{x:.07,y:-.28}],color:"primary",fill:!1},path30:{type:"path",points:[{x:-.14,y:.25},{x:-.14,y:-.27}],color:"primary",fill:!1},"path29-5":{type:"path",points:[{x:-.08,y:.26},{x:-.08,y:-.27}],color:"primary",fill:!1},"path29-2-7":{type:"path",points:[{x:.07,y:.26},{x:-.08,y:.26}],color:"primary",fill:!1},"path29-2-7-6":{type:"path",points:[{x:.07,y:-.28},{x:-.08,y:-.28}],color:"primary",fill:!1},path43:{type:"path",points:[{x:-.21,y:.32},{x:.2,y:.32}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:0,y:.71},{x:0,y:.33},{x:0,y:.32}],color:"primary",fill:!1},"path43-8":{type:"path",points:[{x:-.21,y:.32},{x:-.21,y:.25}],color:"primary",fill:!1},"path43-8-8":{type:"path",points:[{x:.2,y:.32},{x:.2,y:.25}],color:"primary",fill:!1},"path43-9":{type:"path",points:[{x:.19,y:-.35},{x:-.22,y:-.35}],color:"primary",fill:!1},"path44-0-5":{type:"path",points:[{x:-.02,y:-.71},{x:-.02,y:-.36},{x:-.02,y:-.35}],color:"primary",fill:!1},"path43-8-1":{type:"path",points:[{x:.19,y:-.35},{x:.19,y:-.28}],color:"primary",fill:!1},"path43-8-8-9":{type:"path",points:[{x:-.22,y:-.35},{x:-.22,y:-.28}],color:"primary",fill:!1},path28:{type:"path",points:[{x:-.14,y:-.01},{x:-.54,y:-.01}],color:"primary",fill:!1}},texts:{left1:{type:"text",text:"{REF}",x:.53,y:.28},right1:{type:"text",text:"{VAL}",x:.54,y:-.28}},refblocks:{top1:{x:0,y:.71},bottom1:{x:-.02,y:-.71},left1:{x:-.54,y:-.01},right1:{x:.54,y:-.01}},bounds:{minX:-.57,maxX:.57,minY:-.74,maxY:.74,width:1.14,height:1.48,centerX:0,centerY:0},circles:{}},{paths:Uc,texts:o3,bounds:de,refblocks:be,circles:Wc}=J,La=e({primitives:[...Object.values(Uc),...Object.values(Wc),{type:"text",text:"{REF}",x:-.4,y:.4094554499999995},{type:"text",text:"{VAL}",x:.4,y:.4094553499999995}],ports:[{...be.left1,labels:["1"]},{...be.right1,labels:["3"]},{...be.bottom1,labels:["2"]},{...be.top1,labels:["4"]}],size:{width:de.width,height:de.height},center:{x:de.centerX,y:de.centerY}}).rotateRightFacingSymbol("down").changeTextAnchor("{REF}","bottom_left").changeTextAnchor("{VAL}","top_left").build(),Va=e(J).labelPort("top1",["2","gnd1"]).labelPort("bottom1",["4","gnd2"]).labelPort("left1",["3"]).labelPort("right1",["1"]).changeTextAnchor("{REF}","bottom_left").changeTextAnchor("{VAL}","top_left").build(),ja=e(J).labelPort("top1",["4","gnd1"]).labelPort("bottom1",["2","gnd2"]).labelPort("left1",["1"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","bottom_left").changeTextAnchor("{VAL}","top_left").build(),{paths:Hc,texts:f3,bounds:_e,refblocks:ge,circles:Zc}=J,ka=e({primitives:[...Object.values(Hc),...Object.values(Zc),{type:"text",text:"{VAL}",x:-.4,y:-.4094554499999995},{type:"text",text:"{REF}",x:.4,y:-.4094553499999995}],ports:[{...ge.left1,labels:["1"]},{...ge.right1,labels:["3"]},{...ge.bottom1,labels:["2"]},{...ge.top1,labels:["4"]}],size:{width:_e.width,height:_e.height},center:{x:_e.centerX,y:_e.centerY}}).rotateRightFacingSymbol("up").changeTextAnchor("{REF}","bottom_left").changeTextAnchor("{VAL}","top_left").build(),$={paths:{path27:{type:"path",points:[{x:.55,y:-.01},{x:.13,y:-.01}],color:"primary",fill:!1},path28:{type:"path",points:[{x:-.14,y:-.01},{x:-.55,y:-.01}],color:"primary",fill:!1},path29:{type:"path",points:[{x:.13,y:-.28},{x:.13,y:.25}],color:"primary",fill:!1},"path29-2":{type:"path",points:[{x:.07,y:-.28},{x:.07,y:.25}],color:"primary",fill:!1},path30:{type:"path",points:[{x:-.14,y:-.28},{x:-.14,y:.25}],color:"primary",fill:!1},"path29-5":{type:"path",points:[{x:-.08,y:-.28},{x:-.08,y:.25}],color:"primary",fill:!1},"path29-2-7":{type:"path",points:[{x:.07,y:-.28},{x:-.08,y:-.28}],color:"primary",fill:!1},"path29-2-7-6":{type:"path",points:[{x:.07,y:.26},{x:-.08,y:.26}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{VAL}",x:-.01,y:-.42},bottom1:{type:"text",text:"{REF}",x:0,y:.43}},refblocks:{left1:{x:-.55,y:-.01},right1:{x:.55,y:-.01}},bounds:{minX:-.58,maxX:.58,minY:-.52,maxY:.43,width:1.16,height:1,centerX:0,centerY:-.04},circles:{}},{paths:Kc,texts:_3,bounds:ue,refblocks:za,circles:th}=$,Oa=e({primitives:[...Object.values(Kc),...Object.values(th),{type:"text",text:"{REF}",x:-.3,y:.3094553499999995},{type:"text",text:"{VAL}",x:.3,y:.3094553499999995}],ports:[{...za.left1,labels:["1"]},{...za.right1,labels:["2"]}],size:{width:ue.width,height:ue.height},center:{x:ue.centerX,y:ue.centerY}}).changeTextAnchor("{VAL}","top_left").rotateRightFacingSymbol("down").labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{REF}","bottom_left").build(),Ja=e($).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["2","neg"]).labelPort("right1",["1","pos"]).changeTextAnchor("{REF}","middle_bottom").build(),$a=e($).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:eh,texts:T3,bounds:ve,refblocks:Ma,circles:rh}=$,Ca=e({primitives:[...Object.values(eh),...Object.values(rh),{type:"text",text:"{REF}",x:.3,y:-.3094553499999995},{type:"text",text:"{VAL}",x:-.3,y:-.3094553499999995}],ports:[{...Ma.left1,labels:["1"]},{...Ma.right1,labels:["2"]}],size:{width:ve.width,height:ve.height},center:{x:ve.centerX,y:ve.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("up").labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{REF}","bottom_left").build(),Pt=.6,ur=.3,oh=[{type:"path",points:[{x:-Pt,y:0},{x:-ur,y:0}],color:"primary",fill:!1},{type:"path",points:[{x:ur,y:0},{x:Pt,y:0}],color:"primary",fill:!1},{type:"circle",x:0,y:0,radius:ur,color:"primary",fill:!1},{type:"path",points:[{x:-.1,y:0},{x:.15,y:0}],color:"primary",fill:!1},{type:"path",points:[{x:.15,y:0},{x:.05,y:.08}],color:"primary",fill:!1},{type:"path",points:[{x:.15,y:0},{x:.05,y:-.08}],color:"primary",fill:!1}],Na=e({primitives:[...oh,{type:"text",text:"{REF}",x:-.2,y:.35},{type:"text",text:"{VAL}",x:.2,y:.35}],ports:[{x:-Pt,y:0,labels:["1"]},{x:Pt,y:0,labels:["2"]}],center:{x:0,y:0},size:{width:Pt*2,height:.9}}).rotateRightFacingSymbol("down").changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),St=.6,vr=.3,ih=[{type:"path",points:[{x:-St,y:0},{x:-vr,y:0}],color:"primary",fill:!1},{type:"path",points:[{x:vr,y:0},{x:St,y:0}],color:"primary",fill:!1},{type:"circle",x:0,y:0,radius:vr,color:"primary",fill:!1},{type:"path",points:[{x:-.1,y:0},{x:.15,y:0}],color:"primary",fill:!1},{type:"path",points:[{x:.15,y:0},{x:.05,y:.08}],color:"primary",fill:!1},{type:"path",points:[{x:.15,y:0},{x:.05,y:-.08}],color:"primary",fill:!1}],Ia=e({primitives:[...ih,{type:"text",text:"{REF}",x:0,y:-.4},{type:"text",text:"{VAL}",x:0,y:.4}],ports:[{x:-St,y:0,labels:["1"]},{x:St,y:0,labels:["2"]}],center:{x:0,y:0},size:{width:St*2,height:.9}}).rotateRightFacingSymbol("left").changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),Rt=.6,wr=.3,lh=[{type:"path",points:[{x:-Rt,y:0},{x:-wr,y:0}],color:"primary",fill:!1},{type:"path",points:[{x:wr,y:0},{x:Rt,y:0}],color:"primary",fill:!1},{type:"circle",x:0,y:0,radius:wr,color:"primary",fill:!1},{type:"path",points:[{x:-.1,y:0},{x:.15,y:0}],color:"primary",fill:!1},{type:"path",points:[{x:.15,y:0},{x:.05,y:.08}],color:"primary",fill:!1},{type:"path",points:[{x:.15,y:0},{x:.05,y:-.08}],color:"primary",fill:!1}],Ba=e({primitives:[...lh,{type:"text",text:"{REF}",x:0,y:.4},{type:"text",text:"{VAL}",x:0,y:-.4}],ports:[{x:-Rt,y:0,labels:["1"]},{x:Rt,y:0,labels:["2"]}],center:{x:0,y:0},size:{width:Rt*2,height:.9}}).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),Ft=.6,Ar=.3,ph=[{type:"path",points:[{x:-Ft,y:0},{x:-Ar,y:0}],color:"primary",fill:!1},{type:"path",points:[{x:Ar,y:0},{x:Ft,y:0}],color:"primary",fill:!1},{type:"circle",x:0,y:0,radius:Ar,color:"primary",fill:!1},{type:"path",points:[{x:-.1,y:0},{x:.15,y:0}],color:"primary",fill:!1},{type:"path",points:[{x:.15,y:0},{x:.05,y:.08}],color:"primary",fill:!1},{type:"path",points:[{x:.15,y:0},{x:.05,y:-.08}],color:"primary",fill:!1}],qa=e({primitives:[...ph,{type:"text",text:"{REF}",x:.2,y:-.35},{type:"text",text:"{VAL}",x:-.2,y:-.35}],ports:[{x:-Ft,y:0,labels:["1"]},{x:Ft,y:0,labels:["2"]}],center:{x:0,y:0},size:{width:Ft*2,height:.9}}).rotateRightFacingSymbol("up").changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),S={paths:{path11:{type:"path",points:[{x:1.99,y:-1.64},{x:2.1,y:-1.64}],color:"primary",fill:!1},"path40-0":{type:"path",points:[{x:2.1,y:-1.48},{x:2.1,y:-1.8}],color:"primary",fill:!1},"path40-0-5":{type:"path",points:[{x:2.22,y:-1.5},{x:2.11,y:-1.58}],color:"primary",fill:!1},"path40-0-5-0":{type:"path",points:[{x:2.23,y:-1.78},{x:2.11,y:-1.7}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:2.23,y:-1.49},{x:2.23,y:-1.14}],color:"primary",fill:!1},"path12-1-5-3":{type:"path",points:[{x:2.23,y:-1.97},{x:2.23,y:-1.79}],color:"primary",fill:!1},"arrow-2":{type:"path",points:[{x:2.17,y:-1.7},{x:2.13,y:-1.76},{x:2.19,y:-1.76},{x:2.17,y:-1.7}],color:"primary",fill:!0},path1:{type:"path",points:[{x:1.6,y:-1.5},{x:1.86,y:-1.5}],color:"primary",fill:!1},path2:{type:"path",points:[{x:1.87,y:-1.34},{x:1.87,y:-1.66}],color:"primary",fill:!1},path3:{type:"path",points:[{x:1.99,y:-1.36},{x:1.87,y:-1.44}],color:"primary",fill:!1},path4:{type:"path",points:[{x:1.99,y:-1.64},{x:1.88,y:-1.56}],color:"primary",fill:!1},"arrow-1":{type:"path",points:[{x:1.94,y:-1.56},{x:1.89,y:-1.62},{x:1.96,y:-1.62},{x:1.94,y:-1.56}],color:"primary",fill:!0},path9:{type:"path",points:[{x:1.99,y:-1.35},{x:2.23,y:-1.36}],color:"primary",fill:!1}},texts:{bottom1:{type:"text",text:"{VAL}",x:1.88,y:-1.94},right1:{type:"text",text:"{REF}",x:1.88,y:-1.14}},refblocks:{right1:{x:2.23,y:-1.97},right2:{x:1.6,y:-1.5},right3:{x:2.23,y:-1.14}},bounds:{minX:1.58,maxX:2.35,minY:-1.98,maxY:-1.12,width:.77,height:.86,centerX:1.96,centerY:-1.55},circles:{"path1-0":{type:"circle",x:2.05,y:-1.54,radius:.3,color:"primary",fill:!1}}},Da=e(S).rotateRightFacingSymbol("down").labelPort("right2",["1"]).labelPort("right1",["2"]).labelPort("right3",["3"]).changeTextAnchor("{VAL}","middle_left",{x:.8,y:-.15}).changeTextAnchor("{REF}","middle_left",{x:0,y:.15}).build(),Ga=e(S).rotateRightFacingSymbol("right").labelPort("right2",["1"]).labelPort("right1",["2"]).labelPort("right3",["3"]).changeTextAnchor("{VAL}","middle_right").changeTextAnchor("{REF}","middle_right").build(),Ua=e(S).rotateRightFacingSymbol("left").labelPort("right2",["1"]).labelPort("right1",["2"]).labelPort("right3",["3"]).changeTextAnchor("{VAL}","middle_left",{x:0,y:-.8}).changeTextAnchor("{REF}","middle_left",{x:0,y:.8}).build(),Wa=e(S).rotateRightFacingSymbol("right").labelPort("right2",["1"]).labelPort("right1",["2"]).labelPort("right3",["3"]).changeTextAnchor("{VAL}","middle_right").changeTextAnchor("{REF}","middle_right").build(),Ha=e(S).rotateRightFacingSymbol("up").labelPort("right2",["1"]).labelPort("right1",["2"]).labelPort("right3",["3"]).changeTextAnchor("{VAL}","middle_left",{x:0,y:-.15}).changeTextAnchor("{REF}","middle_left",{x:.8,y:.15}).build(),Za=e(S).rotateRightFacingSymbol("up").labelPort("right2",["1"]).labelPort("right1",["2"]).labelPort("right3",["3"]).changeTextAnchor("{VAL}","middle_left",{x:0,y:-.15}).changeTextAnchor("{REF}","middle_left",{x:.8,y:.15}).build(),Qa={paths:{path11:{type:"path",points:[{x:-.54,y:0},{x:-.3,y:0}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:0},{x:.54,y:0}],color:"primary",fill:!1},path2:{type:"path",points:[{x:-.12,y:.09},{x:.12,y:.09}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.18,y:-.45},bottom1:{type:"text",text:"{VAL}",x:-.01,y:.35},left1:{type:"text",text:"A",x:0,y:-.1}},refblocks:{left1:{x:-.54,y:0},right1:{x:.54,y:0}},bounds:{minX:-.53,maxX:.53,minY:-.09,maxY:.09,width:1.06,height:1,centerX:0,centerY:0},circles:{path1:{type:"circle",x:0,y:0,radius:.29,color:"primary",fill:!1}}},{paths:xh,texts:sh,bounds:we,refblocks:Ka,circles:mh}=Qa,Tt=s({primitives:[...Object.values(xh),...Object.values(mh),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"},{...sh.left1,x:0,y:.01,anchor:"center",fontSize:.3}],ports:[{...Ka.left1,labels:["1"]},{...Ka.right1,labels:["2"]}],size:{width:we.width,height:we.height},center:{x:we.centerX,y:we.centerY}});({6:Pr,2:Sr,...ch}=Tt.primitives);nh(Sr)&&Sr.points.map(t5=>{t5.y+=.05});fh(Pr)&&(Pr.y+=.025);ty=r({...Tt,primitives:Object.values(ch).filter(hh)}),ey={...ty,primitives:[...ty.primitives,Pr,Sr]},R={paths:{path11:{type:"path",points:[{x:-.54,y:.03},{x:-.3,y:.04}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:.04},{x:.54,y:.04}],color:"primary",fill:!1},"path11-5-5":{type:"path",points:[{x:.1,y:.13},{x:0,y:-.06},{x:-.11,y:.13}],color:"primary",fill:!1},path2:{type:"path",points:[{x:-.12,y:-.14},{x:.12,y:-.14}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.17,y:.4},bottom1:{type:"text",text:"{VAL}",x:-.01,y:-.4}},refblocks:{left1:{x:-.54,y:.03},right1:{x:.54,y:.04}},bounds:{minX:-.57,maxX:.57,minY:-.4,maxY:.4,width:1.14,height:.79,centerX:0,centerY:0},circles:{path1:{type:"circle",x:0,y:.04,radius:.29,color:"primary",fill:!1}}},{paths:bh,texts:f7,bounds:Ae,refblocks:ry,circles:_h}=R,oy=e({primitives:[...Object.values(bh),...Object.values(_h),{type:"text",text:"{REF}",x:-.15,y:.3894553499999995},{type:"text",text:"{VAL}",x:.15,y:.3894553499999995}],ports:[{...ry.left1,labels:["1"]},{...ry.right1,labels:["2"]}],size:{width:Ae.width,height:Ae.height},center:{x:Ae.centerX,y:Ae.centerY}}).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:gh,texts:b7,bounds:Pe,refblocks:iy,circles:uh}=R,ly=e({primitives:[...Object.values(gh),...Object.values(uh),{type:"text",text:"{REF}",x:-0,y:.3894553499999995},{type:"text",text:"{VAL}",x:0,y:-.3294553499999995}],ports:[{...iy.left1,labels:["1"]},{...iy.right1,labels:["2"]}],size:{width:Pe.width,height:Pe.height},center:{x:Pe.centerX,y:Pe.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:vh,texts:v7,bounds:Se,refblocks:py,circles:wh}=R,ay=e({primitives:[...Object.values(vh),...Object.values(wh),{type:"text",text:"{REF}",x:-0,y:-.3294553499999995},{type:"text",text:"{VAL}",x:0,y:.4294553499999995}],ports:[{...py.left1,labels:["1"]},{...py.right1,labels:["2"]}],size:{width:Se.width,height:Se.height},center:{x:Se.centerX,y:Se.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:Ah,texts:S7,bounds:Re,refblocks:yy,circles:Ph}=R,xy=e({primitives:[...Object.values(Ah),...Object.values(Ph),{type:"text",text:"{REF}",x:-0,y:.3894553499999995},{type:"text",text:"{VAL}",x:0,y:-.3294553499999995}],ports:[{...yy.left1,labels:["1"]},{...yy.right1,labels:["2"]}],size:{width:Re.width,height:Re.height},center:{x:Re.centerX,y:Re.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:Sh,texts:E7,bounds:Fe,refblocks:sy,circles:Rh}=R,my=e({primitives:[...Object.values(Sh),...Object.values(Rh),{type:"text",text:"{REF}",x:.15,y:-.2894553499999995},{type:"text",text:"{VAL}",x:-.15,y:-.2894553499999995}],ports:[{...sy.left1,labels:["1"]},{...sy.right1,labels:["2"]}],size:{width:Fe.width,height:Fe.height},center:{x:Fe.centerX,y:Fe.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:Fh,texts:V7,bounds:Te,refblocks:ny,circles:Th}=R,fy=e({primitives:[...Object.values(Fh),...Object.values(Th),{type:"text",text:"{REF}",x:.15,y:-.2894553499999995},{type:"text",text:"{VAL}",x:-.15,y:-.2894553499999995}],ports:[{...ny.left1,labels:["1"]},{...ny.right1,labels:["2"]}],size:{width:Te.width,height:Te.height},center:{x:Te.centerX,y:Te.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),F={paths:{path11:{type:"path",points:[{x:-.54,y:.04},{x:-.11,y:.04}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.1,y:.04},{x:.54,y:.04}],color:"primary",fill:!1},"path11-0":{type:"path",points:[{x:-.09,y:-.15},{x:-.09,y:.26}],color:"primary",fill:!1},"path11-0-3":{type:"path",points:[{x:.09,y:-.15},{x:.09,y:.26}],color:"primary",fill:!1},"path11-0-9":{type:"path",points:[{x:-.08,y:.06},{x:-.08,y:-.15},{x:.09,y:-.05},{x:-.08,y:.06}],color:"primary",fill:!0},"path11-0-9-0":{type:"path",points:[{x:.08,y:.26},{x:.08,y:.05},{x:-.09,y:.15},{x:.07,y:.26}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:-.03,y:.42},bottom1:{type:"text",text:"{VAL}",x:-.03,y:-.42}},refblocks:{left1:{x:-.54,y:.04},right1:{x:.54,y:.04}},bounds:{minX:-.57,maxX:.57,minY:-.42,maxY:.42,width:1.14,height:.83,centerX:0,centerY:0},circles:{path1:{type:"circle",x:0,y:.05,radius:.29,color:"primary",fill:!1}}},cy=e(F).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left",{x:-.03,y:.2}).changeTextAnchor("{VAL}","middle_left",{x:.8,y:-.2}).build(),hy=e(F).rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom",{x:0,y:.1}).changeTextAnchor("{VAL}","middle_top").build(),dy=e(F).rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom",{x:0,y:.8}).changeTextAnchor("{VAL}","middle_top",{x:0,y:-.9}).build(),by=e(F).rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom",{x:0,y:.1}).changeTextAnchor("{VAL}","middle_top").build(),_y=e(F).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left",{x:.7,y:.2}).changeTextAnchor("{VAL}","middle_left",{x:-.13,y:-.2}).build(),gy=e(F).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left",{x:.7,y:.2}).changeTextAnchor("{VAL}","middle_left",{x:-.13,y:-.2}).build(),M={paths:{triangle:{type:"path",points:[{x:-.06,y:-.09},{x:-.06,y:.09},{x:.06,y:0},{x:-.06,y:-.09}],color:"primary",fill:!1},stem:{type:"path",points:[{x:-.11,y:0},{x:-.06,y:0}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:0,y:.03}},refblocks:{left1:{x:-.11,y:0}},bounds:{minX:-.57,maxX:.57,minY:-.37,maxY:.37,width:1.14,height:.74,centerX:0,centerY:0},circles:{}},{paths:Xh,bounds:uy,refblocks:Lh}=M,vy=e({primitives:[...Object.values(Xh),{type:"text",text:"{REF}",x:-.13,y:-0}],ports:[{...Lh.left1,labels:["1"]}],center:{x:uy.centerX,y:uy.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_top").build(),{paths:Vh,bounds:wy,refblocks:jh}=M,Ay=e({primitives:[...Object.values(Vh),{type:"text",text:"{REF}",x:-.13,y:0}],ports:[{...jh.left1,labels:["1"]}],center:{x:wy.centerX,y:wy.centerY}}).rotateRightFacingSymbol("right").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_right").build(),{paths:kh,bounds:Py,refblocks:zh}=M,Sy=e({primitives:[...Object.values(kh),{type:"text",text:"{REF}",x:-.13,y:-0}],ports:[{...zh.left1,labels:["1"]}],center:{x:Py.centerX,y:Py.centerY}}).rotateRightFacingSymbol("left").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_left").build(),{paths:Oh,bounds:Ry,refblocks:Jh}=M,Fy=e({primitives:[...Object.values(Oh),{type:"text",text:"{REF}",x:-.13,y:0}],ports:[{...Jh.left1,labels:["1"]}],center:{x:Ry.centerX,y:Ry.centerY}}).rotateRightFacingSymbol("down").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_bottom").build(),Ty={paths:{path40:{type:"path",points:[{x:.14,y:.04},{x:-.12,y:-.09}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.12,y:.18},{x:.14,y:.04}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.12,y:-.09},{x:-.12,y:.18}],color:"primary",fill:!1},path43:{type:"path",points:[{x:.14,y:.18},{x:.14,y:-.09}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.12,y:.04},{x:-.52,y:.04}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.52,y:.04},{x:.15,y:.04}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.01,y:.27},bottom1:{type:"text",text:"{VAL}",x:0,y:-.27}},refblocks:{left1:{x:-.52,y:.04},right1:{x:.52,y:.04}},bounds:{minX:-.55,maxX:.55,minY:-.27,maxY:.27,width:1.09,height:.55,centerX:0,centerY:0},circles:{}},C=e(Ty).labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),Ey=r(C,"down"),Yy=r(C,"left"),Xy=r(C,"up"),Ly={paths:{path1:{type:"path",points:[{x:-.37,y:.22},{x:-.13,y:.22}],color:"primary",fill:!1},"path-1-2":{type:"path",points:[{x:-.07,y:.22},{x:.11,y:.16}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.1,y:.13},{x:.37,y:.13}],color:"primary",fill:!1},path3:{type:"path",points:[{x:.12,y:.36},{x:.37,y:.36}],color:"primary",fill:!1},path4:{type:"path",points:[{x:-.37,y:-.18},{x:-.13,y:-.18}],color:"primary",fill:!1},"path4-5":{type:"path",points:[{x:-.07,y:-.19},{x:.1,y:-.24}],color:"primary",fill:!1},path5:{type:"path",points:[{x:.1,y:-.27},{x:.37,y:-.27}],color:"primary",fill:!1},path6:{type:"path",points:[{x:.12,y:-.04},{x:.37,y:-.04}],color:"primary",fill:!1},"path1-4-join":{type:"path",points:[{x:0,y:-.2},{x:0,y:.19}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:0,y:.56},bottom1:{type:"text",text:"{VAL}",x:0,y:-.42}},refblocks:{left1:{x:-.37,y:.22},left2:{x:-.37,y:-.18},right1:{x:.37,y:.36},right2:{x:.37,y:.13},right3:{x:.37,y:-.04},right5:{x:.37,y:-.27}},bounds:{minX:-.4,maxX:.4,minY:-.47,maxY:.56,width:1,height:1.04,centerX:0,centerY:.05},circles:{"circle-2":{type:"circle",x:.08,y:.13,radius:.02,color:"primary",fill:!1},"circle-5":{type:"circle",x:.08,y:-.27,radius:.02,color:"primary",fill:!1},"circle-3":{type:"circle",x:.08,y:.37,radius:.02,color:"primary",fill:!1},"circle-6":{type:"circle",x:.08,y:-.04,radius:.02,color:"primary",fill:!1},"circle-1":{type:"circle",x:-.1,y:.22,radius:.02,color:"primary",fill:!1},"circle-4":{type:"circle",x:-.1,y:-.18,radius:.02,color:"primary",fill:!1}}},N=e(Ly).labelPort("left1",["1"]).labelPort("right1",["3"]).labelPort("right2",["2"]).labelPort("right3",["6"]).labelPort("left2",["4"]).labelPort("right5",["5"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),Rr=r(N,"down"),Fr=Rr.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),Tr=Rr.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Fr.anchor="middle_bottom";Tr.anchor="middle_top";Fr.x=0;Fr.y+=.537;Tr.y-=.5375;Tr.x=0;Vy=Rr,Er=r(N,"left"),Yr=Er.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),Xr=Er.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Yr.anchor="middle_bottom";Xr.anchor="middle_top";Yr.x=0;Yr.y+=1;Xr.y-=1;Xr.x=0;jy=Er,Lr=r(N,"up"),Vr=Lr.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),jr=Lr.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Vr.anchor="middle_bottom";jr.anchor="middle_top";Vr.x=0;Vr.y+=.537;jr.y-=.5375;jr.x=0;ky=Lr,zy={paths:{path1:{type:"path",points:[{x:-.37,y:.22},{x:-.13,y:.22}],color:"primary",fill:!1},"path-1-3":{type:"path",points:[{x:-.07,y:.23},{x:.11,y:.33}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.1,y:.13},{x:.37,y:.13}],color:"primary",fill:!1},path3:{type:"path",points:[{x:.12,y:.36},{x:.37,y:.36}],color:"primary",fill:!1},path4:{type:"path",points:[{x:-.37,y:-.18},{x:-.13,y:-.18}],color:"primary",fill:!1},"path4-6":{type:"path",points:[{x:-.07,y:-.18},{x:.11,y:-.07}],color:"primary",fill:!1},path5:{type:"path",points:[{x:.1,y:-.27},{x:.37,y:-.27}],color:"primary",fill:!1},path6:{type:"path",points:[{x:.12,y:-.04},{x:.37,y:-.04}],color:"primary",fill:!1},"path1-4-join":{type:"path",points:[{x:0,y:-.12},{x:0,y:.27}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:0,y:.61},bottom1:{type:"text",text:"{VAL}",x:0,y:-.52}},refblocks:{left1:{x:-.37,y:.22},left2:{x:-.37,y:-.18},right1:{x:.37,y:.36},right2:{x:.37,y:.13},right3:{x:.37,y:-.04},right5:{x:.37,y:-.27}},bounds:{minX:-.4,maxX:.4,minY:-.47,maxY:.56,width:1,height:1.04,centerX:0,centerY:.05},circles:{"circle-2":{type:"circle",x:.08,y:.13,radius:.02,color:"primary",fill:!1},"circle-5":{type:"circle",x:.08,y:-.27,radius:.02,color:"primary",fill:!1},"circle-3":{type:"circle",x:.08,y:.37,radius:.02,color:"primary",fill:!1},"circle-6":{type:"circle",x:.08,y:-.04,radius:.02,color:"primary",fill:!1},"circle-1":{type:"circle",x:-.1,y:.22,radius:.02,color:"primary",fill:!1},"circle-4":{type:"circle",x:-.1,y:-.18,radius:.02,color:"primary",fill:!1}}},I=e(zy).labelPort("left1",["1"]).labelPort("right1",["3"]).labelPort("right2",["2"]).labelPort("right3",["6"]).labelPort("left2",["4"]).labelPort("right5",["5"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),kr=r(I,"down"),zr=kr.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),Or=kr.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");zr.anchor="middle_bottom";Or.anchor="middle_top";zr.x=0;zr.y+=.565;Or.y-=.555;Or.x=0;Oy=kr,Jr=r(I,"left"),$r=Jr.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),Mr=Jr.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");$r.anchor="middle_bottom";Mr.anchor="middle_top";$r.x=0;$r.y+=1.09;Mr.y-=1.09;Mr.x=0;Jy=Jr,Cr=r(I,"up"),Nr=Cr.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),Ir=Cr.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Nr.anchor="middle_bottom";Ir.anchor="middle_top";Nr.x=0;Nr.y+=.565;Ir.y-=.555;Ir.x=0;$y=Cr,My={paths:{path11:{type:"path",points:[{x:-.38,y:.06},{x:-.14,y:.06}],color:"primary",fill:!1},"path11-0":{type:"path",points:[{x:-.09,y:.07},{x:.11,y:.11}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.13,y:.06},{x:.38,y:.06}],color:"primary",fill:!1},"path11-5":{type:"path",points:[{x:-.38,y:-.17},{x:-.14,y:-.17}],color:"primary",fill:!1},"path11-0-3":{type:"path",points:[{x:-.09,y:-.17},{x:.11,y:-.12}],color:"primary",fill:!1},"path12-0":{type:"path",points:[{x:.13,y:-.17},{x:.38,y:-.17}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:0,y:.31},bottom1:{type:"text",text:"{VAL}",x:0,y:-.31}},refblocks:{left1:{x:-.38,y:-.17},left3:{x:-.38,y:.06},right1:{x:.38,y:-.17},right3:{x:.38,y:.06}},bounds:{minX:-.4,maxX:.4,minY:-.4,maxY:.4,width:.81,height:.79,centerX:0,centerY:0},circles:{"circle-4":{type:"circle",x:.1,y:.06,radius:.02,color:"primary",fill:!1},"circle-2":{type:"circle",x:.1,y:-.17,radius:.02,color:"primary",fill:!1},"circle-3":{type:"circle",x:-.11,y:.06,radius:.02,color:"primary",fill:!1},"circle-1":{type:"circle",x:-.11,y:-.17,radius:.02,color:"primary",fill:!1}}},B=e(My).labelPort("left1",["1"]).labelPort("right1",["2"]).labelPort("right3",["4"]).labelPort("left3",["3"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),Br=r(B,"down"),qr=Br.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),Dr=Br.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");qr.anchor="middle_bottom";Dr.anchor="middle_top";qr.x=.4;qr.y+=.265;Dr.y-=.265;Dr.x=.4;Cy=Br,Gr=r(B,"left"),Ur=Gr.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),Wr=Gr.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Ur.anchor="middle_bottom";Wr.anchor="middle_top";Ur.x=0;Ur.y+=.67;Wr.y-=.67;Wr.x=0;Ny=Gr,Hr=r(B,"up"),Zr=Hr.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),Qr=Hr.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Zr.anchor="middle_bottom";Qr.anchor="middle_top";Zr.x=.46;Zr.y+=.265;Qr.y-=.265;Qr.x=.46;Iy=Hr,By={paths:{path11:{type:"path",points:[{x:-.38,y:.06},{x:-.14,y:.06}],color:"primary",fill:!1},"path11-0":{type:"path",points:[{x:-.09,y:.07},{x:.1,y:.2}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.13,y:.06},{x:.38,y:.06}],color:"primary",fill:!1},"path11-5":{type:"path",points:[{x:-.38,y:-.17},{x:-.14,y:-.17}],color:"primary",fill:!1},"path11-0-3":{type:"path",points:[{x:-.09,y:-.16},{x:.1,y:-.03}],color:"primary",fill:!1},"path12-0":{type:"path",points:[{x:.13,y:-.17},{x:.38,y:-.17}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:0,y:.42},bottom1:{type:"text",text:"{VAL}",x:0,y:-.42}},refblocks:{left1:{x:-.38,y:-.17},left3:{x:-.38,y:.06},right1:{x:.38,y:-.17},right3:{x:.38,y:.06}},bounds:{minX:-.4,maxX:.4,minY:-.4,maxY:.4,width:.81,height:.79,centerX:0,centerY:0},circles:{"circle-4":{type:"circle",x:.1,y:.06,radius:.02,color:"primary",fill:!1},"circle-2":{type:"circle",x:.1,y:-.17,radius:.02,color:"primary",fill:!1},"circle-3":{type:"circle",x:-.11,y:.06,radius:.02,color:"primary",fill:!1},"circle-1":{type:"circle",x:-.11,y:-.17,radius:.02,color:"primary",fill:!1}}},q=e(By).labelPort("left1",["1"]).labelPort("right1",["2"]).labelPort("right3",["4"]).labelPort("left3",["3"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),Kr=r(q,"down"),to=Kr.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),eo=Kr.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");to.anchor="middle_bottom";eo.anchor="middle_top";to.x=.4;to.y+=.295;eo.y-=.295;eo.x=.42;qy=Kr,ro=r(q,"left"),oo=ro.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),io=ro.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");oo.anchor="middle_bottom";io.anchor="middle_top";oo.x=0;oo.y+=.795;io.y-=.795;io.x=0;Dy=ro,lo=r(q,"up"),po=lo.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),ao=lo.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");po.anchor="middle_bottom";ao.anchor="middle_top";po.x=.46;po.y+=.315;ao.y-=.315;ao.x=.46;Gy=lo,Ee={paths:{path5:{type:"path",points:[{x:-.44,y:0},{x:-.16,y:0}],color:"primary",fill:!1},path6:{type:"path",points:[{x:.17,y:0},{x:.44,y:.01}],color:"primary",fill:!1},path9:{type:"path",points:[{x:-.25,y:-.16},{x:.02,y:.3},{x:.25,y:.17},{x:-.02,y:-.29},{x:-.25,y:-.16}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:0,y:.37},bottom1:{type:"text",text:"{VAL}",x:0,y:-.37}},refblocks:{left1:{x:-.44,y:0},right1:{x:.44,y:.01}},bounds:{minX:-.57,maxX:.57,minY:-.25,maxY:.25,width:1.13,height:.5,centerX:0,centerY:0},circles:{}},{paths:qh,texts:Fv,bounds:Ye,refblocks:Uy,circles:Dh}=Ee,Xe=e({primitives:[...Object.values(qh),...Object.values(Dh),{type:"text",text:"{REF}",x:.18,y:-.3204553499999995},{type:"text",text:"{VAL}",x:-.25,y:-.3294553499999995}],ports:[{...Uy.left1,labels:["1"]},{...Uy.right1,labels:["2"]}],size:{width:Ye.width,height:Ye.height},center:{x:Ye.centerX,y:Ye.centerY}}).rotateRightFacingSymbol("up").labelPort("left",["1"]).labelPort("right",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),yo=v(Xe),xo=yo.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),so=yo.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");xo.anchor="middle_left";so.anchor="middle_left";xo.y+=.4;xo.x=.32;so.y-=.45;so.x=.32;Wy=yo,Le=e(Ee).labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),Hy=Y(Le),T={paths:{path11:{type:"path",points:[{x:-.56,y:.04},{x:-.22,y:.04}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.14,y:.05},{x:.48,y:.05}],color:"primary",fill:!1},"path12-6":{type:"path",points:[{x:.14,y:-.15},{x:.14,y:.25}],color:"primary",fill:!1},"path11-0-9":{type:"path",points:[{x:-.22,y:.25},{x:-.21,y:-.15},{x:.14,y:.05},{x:-.22,y:.25}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:-.09,y:.38},bottom1:{type:"text",text:"{VAL}",x:-.07,y:-.38},right1:{type:"text",text:"",x:.59,y:-.33}},refblocks:{left1:{x:-.56,y:.04},right1:{x:.48,y:.05}},bounds:{minX:-.59,maxX:.59,minY:-.38,maxY:.38,width:1.18,height:.76,centerX:0,centerY:0},circles:{}},{paths:Uh,texts:Nv,bounds:Ve,refblocks:Zy,circles:Wh}=T,Qy=e({primitives:[...Object.values(Uh),...Object.values(Wh),{type:"text",text:"{REF}",x:-.15,y:.3294553499999995},{type:"text",text:"{VAL}",x:.15,y:.3294553499999995}],ports:[{...Zy.left1,labels:["1"]},{...Zy.right1,labels:["2"]}],size:{width:Ve.width,height:Ve.height},center:{x:Ve.centerX,y:Ve.centerY}}).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:Hh,texts:Dv,bounds:je,refblocks:Ky,circles:Zh}=T,tx=e({primitives:[...Object.values(Hh),...Object.values(Zh),{type:"text",text:"{REF}",x:-0,y:.4094553499999995},{type:"text",text:"{VAL}",x:0,y:-.4094553499999995}],ports:[{...Ky.left1,labels:["1"]},{...Ky.right1,labels:["2"]}],size:{width:je.width,height:je.height},center:{x:je.centerX,y:je.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:Qh,texts:Hv,bounds:ke,refblocks:ex,circles:Kh}=T,rx=e({primitives:[...Object.values(Qh),...Object.values(Kh),{type:"text",text:"{REF}",x:-0,y:-.3094553499999995},{type:"text",text:"{VAL}",x:0,y:.4094553499999995}],ports:[{...ex.left1,labels:["1"]},{...ex.right1,labels:["2"]}],size:{width:ke.width,height:ke.height},center:{x:ke.centerX,y:ke.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:td,texts:t6,bounds:ze,refblocks:ox,circles:ed}=T,ix=e({primitives:[...Object.values(td),...Object.values(ed),{type:"text",text:"{REF}",x:-0,y:.4094553499999995},{type:"text",text:"{VAL}",x:0,y:-.4094553499999995}],ports:[{...ox.left1,labels:["1"]},{...ox.right1,labels:["2"]}],size:{width:ze.width,height:ze.height},center:{x:ze.centerX,y:ze.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:rd,texts:i6,bounds:Oe,refblocks:lx,circles:od}=T,px=e({primitives:[...Object.values(rd),...Object.values(od),{type:"text",text:"{REF}",x:.15,y:-.2894553499999995},{type:"text",text:"{VAL}",x:-.15,y:-.2894553499999995}],ports:[{...lx.left1,labels:["1"]},{...lx.right1,labels:["2"]}],size:{width:Oe.width,height:Oe.height},center:{x:Oe.centerX,y:Oe.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:id,texts:y6,bounds:Je,refblocks:ax,circles:ld}=T,yx=e({primitives:[...Object.values(id),...Object.values(ld),{type:"text",text:"{REF}",x:.15,y:-.2894553499999995},{type:"text",text:"{VAL}",x:-.15,y:-.2894553499999995}],ports:[{...ax.left1,labels:["1"]},{...ax.right1,labels:["2"]}],size:{width:Je.width,height:Je.height},center:{x:Je.centerX,y:Je.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),xx={paths:{path11:{type:"path",points:[{x:-.54,y:0},{x:-.3,y:0}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:0},{x:.54,y:0}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.18,y:-.36},bottom1:{type:"text",text:"{VAL}",x:-.01,y:.43},left1:{type:"text",text:"Hz",x:0,y:-.04}},refblocks:{left1:{x:-.54,y:0},right1:{x:.54,y:0}},bounds:{minX:-.53,maxX:.53,minY:0,maxY:0,width:1.06,height:1,centerX:0,centerY:0},circles:{path1:{type:"circle",x:-.01,y:-.01,radius:.29,color:"primary",fill:!1}}},{paths:ad,texts:yd,bounds:$e,refblocks:sx,circles:xd}=xx,Et=s({primitives:[...Object.values(ad),...Object.values(xd),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"},{...yd.left1,x:0,y:.01,anchor:"center",fontSize:.2}],ports:[{...sx.left1,labels:["1"]},{...sx.right1,labels:["2"]}],size:{width:$e.width,height:$e.height},center:{x:$e.centerX,y:$e.centerY}}),{5:sd,...md}=Et.primitives;mx=r({...Et,primitives:Object.values(md).filter(nd)}),nx={...mx,primitives:[...mx.primitives,sd]},fx={paths:{path10:{type:"path",points:[{x:-.53,y:.04},{x:.53,y:.04}],color:"primary",fill:!1},path14:{type:"path",points:[{x:0,y:.17},{x:.27,y:.17},{x:.27,y:-.1},{x:-.26,y:-.1},{x:-.26,y:.17},{x:0,y:.17}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.01,y:.24},bottom1:{type:"text",text:"{VAL}",x:-.17,y:-.24}},refblocks:{left1:{x:-.53,y:.04},right1:{x:.53,y:.04}},bounds:{minX:-.56,maxX:.56,minY:-.24,maxY:.24,width:1.13,height:.47,centerX:0,centerY:0},circles:{}},{paths:cd,texts:hd,bounds:Me,refblocks:cx}=fx,Ce=s({primitives:[...Object.values(cd),{...hd.top1,anchor:"middle_bottom"},{type:"text",text:"{VAL}",x:0,y:-.2,anchor:"middle_top"}],ports:[{...cx.left1,labels:["1"]},{...cx.right1,labels:["2"]}],size:{width:Me.width,height:Me.height},center:{x:Me.centerX,y:Me.centerY}}),hx=r(Ce),E={paths:{path1:{type:"path",points:[{x:-.29,y:.01},{x:.04,y:0}],color:"primary",fill:!0},path2:{type:"path",points:[{x:.04,y:-.22},{x:.04,y:.22}],color:"primary",fill:!0},path3:{type:"path",points:[{x:.12,y:-.17},{x:.12,y:.17}],color:"primary",fill:!0},path4:{type:"path",points:[{x:.19,y:-.06},{x:.19,y:.06}],color:"primary",fill:!0}},texts:{right1:{type:"text",text:"{REF}",x:.31,y:-.02}},refblocks:{left1:{x:-.29,y:.01}},bounds:{minX:-.31,maxX:.31,minY:-.22,maxY:.22,width:.62,height:.45,centerX:0,centerY:0},circles:{}},dx=e(E).rotateRightFacingSymbol("down").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_top").build(),bx=e(E).rotateRightFacingSymbol("right").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_left").build(),_x=e(E).rotateRightFacingSymbol("left").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_right").build(),gx=e(E).rotateRightFacingSymbol("right").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_left").build(),ux=e(E).rotateRightFacingSymbol("up").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_bottom").build(),vx=e(E).rotateRightFacingSymbol("up").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_bottom").build(),Yt={paths:{path11:{type:"path",points:[{x:-.52,y:.03},{x:-.18,y:.04}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.19,y:.04},{x:.52,y:.04}],color:"primary",fill:!1},"path11-0-9":{type:"path",points:[{x:-.31,y:.2},{x:-.31,y:-.11},{x:-.01,y:.04},{x:-.3,y:.2}],color:"primary",fill:!0},"path11-0-9-5":{type:"path",points:[{x:.33,y:.2},{x:.33,y:-.1},{x:.04,y:.04},{x:.33,y:.2}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:.04,y:.32},bottom1:{type:"text",text:"{VAL}",x:.04,y:-.32}},refblocks:{left1:{x:-.52,y:.03},right1:{x:.52,y:.04}},bounds:{minX:-.55,maxX:.55,minY:-.32,maxY:.32,width:1.09,height:.63,centerX:0,centerY:0},circles:{}},{paths:D6,texts:G6,bounds:U6,refblocks:W6,circles:H6}=Yt,wx=e(Yt).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),Ax=e(Yt).rotateRightFacingSymbol("down").changeTextAnchor("{VAL}","middle_right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").build(),Px={paths:{path45:{type:"path",points:[{x:.14,y:0},{x:-.13,y:-.14}],color:"primary",fill:!1},"path1-8":{type:"path",points:[{x:.13,y:0},{x:.3,y:0}],color:"primary",fill:!1},path46:{type:"path",points:[{x:-.13,y:.13},{x:.14,y:0}],color:"primary",fill:!1},path47:{type:"path",points:[{x:-.13,y:-.14},{x:-.13,y:.13}],color:"primary",fill:!1},path48:{type:"path",points:[{x:.14,y:.13},{x:.14,y:-.14}],color:"primary",fill:!1},path49:{type:"path",points:[{x:-.13,y:0},{x:-.3,y:0}],color:"primary",fill:!1},path25:{type:"path",points:[{x:.16,y:.29},{x:.25,y:.3},{x:.22,y:.21}],color:"primary",fill:!0},path78:{type:"path",points:[{x:.08,y:.17},{x:.09,y:.17},{x:.21,y:.27},{x:.21,y:.27}],color:"primary",fill:!1},"path25-0":{type:"path",points:[{x:-.02,y:.31},{x:.08,y:.32},{x:.04,y:.23}],color:"primary",fill:!0},"path78-6":{type:"path",points:[{x:-.1,y:.19},{x:-.09,y:.2},{x:.04,y:.29},{x:.04,y:.29}],color:"primary",fill:!1},box:{type:"path",points:[{x:-.3,y:-.4},{x:.3,y:-.4},{x:.3,y:.4},{x:-.3,y:.4},{x:-.3,y:-.4},{x:-.3,y:.4}],color:"primary",fill:!1},"path48-1":{type:"path",points:[{x:-.3,y:.13},{x:-.54,y:.13}],color:"primary",fill:!1},"path48-2":{type:"path",points:[{x:-.3,y:-.13},{x:-.54,y:-.13}],color:"primary",fill:!1},"path48-3":{type:"path",points:[{x:.3,y:-.13},{x:.54,y:-.13}],color:"primary",fill:!1},"path48-4":{type:"path",points:[{x:.3,y:.13},{x:.54,y:.13}],color:"primary",fill:!1}},texts:{bottom1:{type:"text",text:"{VAL}",x:0,y:-.43},right1:{type:"text",text:"{REF}",x:0,y:.43}},refblocks:{left1:{x:-.54,y:.13},left2:{x:-.54,y:-.13},right1:{x:.54,y:-.13},right2:{x:.54,y:.13}},bounds:{minX:-.56,maxX:.56,minY:-.32,maxY:.32,width:1.13,height:.65,centerX:0,centerY:0},circles:{}},D=e(Px).labelPort("left1",["1","DIN"]).labelPort("left2",["2","POWER"]).labelPort("right1",["3","GND"]).labelPort("right2",["4","DOUT"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),Sx=r(D,"down"),Rx=Y(D),mo=r(D,"up"),no=mo.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),fo=mo.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");no.anchor="middle_left";fo.anchor="middle_left";no.y+=.21;no.x=.44;fo.y-=.21;fo.x=.44;Fx=mo,Tx={paths:{path11:{type:"path",points:[{x:-.4,y:0},{x:-.01,y:0}],color:"primary",fill:!1},path40:{type:"path",points:[{x:.07,y:.19},{x:.07,y:-.18}],color:"primary",fill:!1},path42:{type:"path",points:[{x:.01,y:-.12},{x:.01,y:.14}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.28,y:-.25},{x:.28,y:-.56}],color:"primary",fill:!1},"path12-1":{type:"path",points:[{x:.28,y:.56},{x:.28,y:.27}],color:"primary",fill:!1},path15:{type:"path",points:[{x:.17,y:-.22},{x:.28,y:-.23},{x:.23,y:-.14}],color:"primary",fill:!0},path17:{type:"path",points:[{x:.08,y:-.09},{x:.23,y:-.2}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.07,y:.11},{x:.28,y:.26}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.01,y:.36},bottom1:{type:"text",text:"{VAL}",x:.02,y:-.42}},refblocks:{top1:{x:.28,y:.56},bottom1:{x:.28,y:-.56},left1:{x:-.4,y:0}},bounds:{minX:-.43,maxX:.43,minY:-.58,maxY:.58,width:.85,height:1.17,centerX:0,centerY:0},circles:{path1:{type:"circle",x:.14,y:.01,radius:.29,color:"primary",fill:!1}}},Ne=e(Tx).changeTextAnchor("{VAL}","middle_right").labelPort("left1",["3"]).labelPort("top1",["2"]).labelPort("bottom1",["1"]).changeTextAnchor("{REF}","middle_right").build(),co=r(Ne),ho=co.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),Ex=co.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");ho.anchor="middle_left";Ex.anchor="middle_right";ho.x=.45;ho.y+=.065;Ex.y+=.065;Yx=co,Xx={paths:{"path12-1-8-6-9":{type:"path",points:[{x:.02,y:-.02},{x:.02,y:-.1}],color:"primary",fill:!1},"path12-1-5-6":{type:"path",points:[{x:-.47,y:-.19},{x:-.17,y:-.19}],color:"primary",fill:!1},"path12-1-5-6-8":{type:"path",points:[{x:.02,y:.17},{x:.02,y:.11}],color:"primary",fill:!1},"path12-1-8-0":{type:"path",points:[{x:-.15,y:-.03},{x:.2,y:-.19}],color:"primary",fill:!1},"path12-1-0":{type:"path",points:[{x:.2,y:-.19},{x:.47,y:-.19}],color:"primary",fill:!1},"path12-1-8-6-9-4":{type:"path",points:[{x:.02,y:.12},{x:.02,y:.02}],color:"primary",fill:!1},"path12-1-8-6-9-4-3":{type:"path",points:[{x:.08,y:.11},{x:.08,y:.05}],color:"primary",fill:!1},"path12-1-8-6-9-4-3-1":{type:"path",points:[{x:-.04,y:.11},{x:-.04,y:.05}],color:"primary",fill:!1},"path12-1-8-6-9-4-4":{type:"path",points:[{x:.08,y:.11},{x:-.04,y:.11}],color:"primary",fill:!1},"path14-5":{type:"path",points:[{x:-.01,y:.28},{x:.01,y:.25},{x:.04,y:.23},{x:.06,y:.2}],color:"primary",fill:!0},"path14-5-3":{type:"path",points:[{x:-.01,y:.2},{x:.01,y:.23},{x:.04,y:.25},{x:.06,y:.28}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:.01,y:.38},bottom1:{type:"text",text:"{VAL}",x:.06,y:-.38}},refblocks:{left1:{x:-.47,y:-.19},right1:{x:.47,y:-.19}},bounds:{minX:-.5,maxX:.5,minY:-.38,maxY:.38,width:1,height:.76,centerX:0,centerY:0},circles:{path9:{type:"circle",x:.02,y:.24,radius:.06,color:"primary",fill:!1}}},Ie=e(Xx).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),Lx=r(Ie),Vx=Lx.primitives.filter(t5=>t5.type==="text"),bo=Vx.find(t5=>t5.text==="{VAL}");bo.x=-.35;bo.y=0;bo.anchor="middle_right";_o=Vx.find(t5=>t5.text==="{REF}");_o.y=0;_o.x=.35;_o.anchor="middle_left";jx=Lx,kx={paths:{path8698:{type:"path",points:[{x:-.2,y:-.02},{x:-.2,y:-.02},{x:-.21,y:-.01},{x:-.21,y:-.01},{x:-.21,y:0},{x:-.21,y:0},{x:-.21,y:0},{x:-.22,y:.01},{x:-.22,y:.01},{x:-.22,y:.02},{x:-.22,y:.02},{x:-.23,y:.03},{x:-.23,y:.03},{x:-.23,y:.03},{x:-.23,y:.04},{x:-.24,y:.04},{x:-.24,y:.04},{x:-.24,y:.05},{x:-.24,y:.05},{x:-.25,y:.05},{x:-.25,y:.06},{x:-.25,y:.06},{x:-.25,y:.06},{x:-.26,y:.06},{x:-.26,y:.06},{x:-.26,y:.07},{x:-.26,y:.07},{x:-.27,y:.07},{x:-.27,y:.07},{x:-.27,y:.07},{x:-.27,y:.07},{x:-.28,y:.07},{x:-.28,y:.07},{x:-.28,y:.07},{x:-.28,y:.07},{x:-.29,y:.07},{x:-.29,y:.08},{x:-.29,y:.08},{x:-.29,y:.08},{x:-.3,y:.08},{x:-.3,y:.08},{x:-.3,y:.08},{x:-.3,y:.08},{x:-.31,y:.08},{x:-.31,y:.08},{x:-.31,y:.07},{x:-.31,y:.07},{x:-.32,y:.07},{x:-.32,y:.07},{x:-.32,y:.07},{x:-.32,y:.07},{x:-.33,y:.07},{x:-.33,y:.07},{x:-.33,y:.07},{x:-.33,y:.07},{x:-.34,y:.07},{x:-.34,y:.06},{x:-.34,y:.06},{x:-.34,y:.06},{x:-.35,y:.06},{x:-.35,y:.06},{x:-.35,y:.05},{x:-.35,y:.05},{x:-.36,y:.05},{x:-.36,y:.04},{x:-.36,y:.04},{x:-.36,y:.04},{x:-.37,y:.03},{x:-.37,y:.03},{x:-.37,y:.03},{x:-.37,y:.02},{x:-.38,y:.02},{x:-.38,y:.01},{x:-.38,y:.01},{x:-.38,y:0},{x:-.39,y:0},{x:-.39,y:0},{x:-.39,y:-.01},{x:-.39,y:-.01},{x:-.4,y:-.02},{x:-.4,y:-.02}],color:"primary",fill:!1},path8700:{type:"path",points:[{x:0,y:-.02},{x:0,y:-.02},{x:-.01,y:-.01},{x:-.01,y:-.01},{x:-.01,y:0},{x:-.01,y:0},{x:-.02,y:0},{x:-.02,y:.01},{x:-.02,y:.01},{x:-.02,y:.02},{x:-.03,y:.02},{x:-.03,y:.03},{x:-.03,y:.03},{x:-.03,y:.03},{x:-.04,y:.04},{x:-.04,y:.04},{x:-.04,y:.04},{x:-.04,y:.05},{x:-.05,y:.05},{x:-.05,y:.05},{x:-.05,y:.06},{x:-.05,y:.06},{x:-.06,y:.06},{x:-.06,y:.06},{x:-.06,y:.06},{x:-.06,y:.07},{x:-.07,y:.07},{x:-.07,y:.07},{x:-.07,y:.07},{x:-.07,y:.07},{x:-.08,y:.07},{x:-.08,y:.07},{x:-.08,y:.07},{x:-.08,y:.07},{x:-.09,y:.07},{x:-.09,y:.07},{x:-.09,y:.08},{x:-.09,y:.08},{x:-.1,y:.08},{x:-.1,y:.08},{x:-.1,y:.08},{x:-.1,y:.08},{x:-.11,y:.08},{x:-.11,y:.08},{x:-.11,y:.08},{x:-.11,y:.07},{x:-.12,y:.07},{x:-.12,y:.07},{x:-.12,y:.07},{x:-.12,y:.07},{x:-.13,y:.07},{x:-.13,y:.07},{x:-.13,y:.07},{x:-.13,y:.07},{x:-.14,y:.07},{x:-.14,y:.07},{x:-.14,y:.06},{x:-.14,y:.06},{x:-.15,y:.06},{x:-.15,y:.06},{x:-.15,y:.06},{x:-.15,y:.05},{x:-.16,y:.05},{x:-.16,y:.05},{x:-.16,y:.04},{x:-.16,y:.04},{x:-.17,y:.04},{x:-.17,y:.03},{x:-.17,y:.03},{x:-.17,y:.03},{x:-.18,y:.02},{x:-.18,y:.02},{x:-.18,y:.01},{x:-.18,y:.01},{x:-.19,y:0},{x:-.19,y:0},{x:-.19,y:0},{x:-.19,y:-.01},{x:-.2,y:-.01},{x:-.2,y:-.02},{x:-.2,y:-.02}],color:"primary",fill:!1},path8702:{type:"path",points:[{x:.2,y:-.02},{x:.2,y:-.02},{x:.19,y:-.01},{x:.19,y:-.01},{x:.19,y:0},{x:.19,y:0},{x:.18,y:0},{x:.18,y:.01},{x:.18,y:.01},{x:.18,y:.02},{x:.17,y:.02},{x:.17,y:.03},{x:.17,y:.03},{x:.17,y:.03},{x:.16,y:.04},{x:.16,y:.04},{x:.16,y:.04},{x:.16,y:.05},{x:.15,y:.05},{x:.15,y:.05},{x:.15,y:.06},{x:.15,y:.06},{x:.14,y:.06},{x:.14,y:.06},{x:.14,y:.06},{x:.14,y:.07},{x:.13,y:.07},{x:.13,y:.07},{x:.13,y:.07},{x:.13,y:.07},{x:.12,y:.07},{x:.12,y:.07},{x:.12,y:.07},{x:.12,y:.07},{x:.11,y:.07},{x:.11,y:.07},{x:.11,y:.08},{x:.11,y:.08},{x:.1,y:.08},{x:.1,y:.08},{x:.1,y:.08},{x:.1,y:.08},{x:.09,y:.08},{x:.09,y:.08},{x:.09,y:.08},{x:.09,y:.07},{x:.08,y:.07},{x:.08,y:.07},{x:.08,y:.07},{x:.08,y:.07},{x:.07,y:.07},{x:.07,y:.07},{x:.07,y:.07},{x:.07,y:.07},{x:.06,y:.07},{x:.06,y:.07},{x:.06,y:.06},{x:.06,y:.06},{x:.05,y:.06},{x:.05,y:.06},{x:.05,y:.06},{x:.05,y:.05},{x:.04,y:.05},{x:.04,y:.05},{x:.04,y:.04},{x:.04,y:.04},{x:.03,y:.04},{x:.03,y:.03},{x:.03,y:.03},{x:.03,y:.03},{x:.02,y:.02},{x:.02,y:.02},{x:.02,y:.01},{x:.02,y:.01},{x:.01,y:0},{x:.01,y:0},{x:.01,y:0},{x:.01,y:-.01},{x:0,y:-.01},{x:0,y:-.02},{x:0,y:-.02}],color:"primary",fill:!1},path8704:{type:"path",points:[{x:.4,y:-.02},{x:.39,y:-.02},{x:.39,y:-.01},{x:.39,y:-.01},{x:.39,y:0},{x:.39,y:0},{x:.38,y:0},{x:.38,y:.01},{x:.38,y:.01},{x:.38,y:.02},{x:.37,y:.02},{x:.37,y:.03},{x:.37,y:.03},{x:.37,y:.03},{x:.36,y:.04},{x:.36,y:.04},{x:.36,y:.04},{x:.36,y:.05},{x:.35,y:.05},{x:.35,y:.05},{x:.35,y:.06},{x:.35,y:.06},{x:.34,y:.06},{x:.34,y:.06},{x:.34,y:.06},{x:.34,y:.07},{x:.33,y:.07},{x:.33,y:.07},{x:.33,y:.07},{x:.33,y:.07},{x:.32,y:.07},{x:.32,y:.07},{x:.32,y:.07},{x:.32,y:.07},{x:.31,y:.07},{x:.31,y:.07},{x:.31,y:.08},{x:.31,y:.08},{x:.3,y:.08},{x:.3,y:.08},{x:.3,y:.08},{x:.3,y:.08},{x:.29,y:.08},{x:.29,y:.08},{x:.29,y:.08},{x:.29,y:.07},{x:.28,y:.07},{x:.28,y:.07},{x:.28,y:.07},{x:.28,y:.07},{x:.27,y:.07},{x:.27,y:.07},{x:.27,y:.07},{x:.27,y:.07},{x:.26,y:.07},{x:.26,y:.07},{x:.26,y:.06},{x:.26,y:.06},{x:.25,y:.06},{x:.25,y:.06},{x:.25,y:.06},{x:.25,y:.05},{x:.24,y:.05},{x:.24,y:.05},{x:.24,y:.04},{x:.24,y:.04},{x:.23,y:.04},{x:.23,y:.03},{x:.23,y:.03},{x:.23,y:.03},{x:.22,y:.02},{x:.22,y:.02},{x:.22,y:.01},{x:.22,y:.01},{x:.21,y:0},{x:.21,y:0},{x:.21,y:0},{x:.21,y:-.01},{x:.2,y:-.01},{x:.2,y:-.02},{x:.2,y:-.02}],color:"primary",fill:!1},path8706:{type:"path",points:[{x:-.4,y:-.02},{x:-.55,y:-.02}],color:"primary",fill:!1},"path8706-5":{type:"path",points:[{x:.55,y:-.03},{x:.4,y:-.03}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:0,y:.23},bottom1:{type:"text",text:"{VAL}",x:0,y:-.23}},refblocks:{left1:{x:-.55,y:-.02},right1:{x:.55,y:-.03}},bounds:{minX:-.58,maxX:.58,minY:-.23,maxY:.23,width:1.16,height:.46,centerX:0,centerY:0},circles:{}},{paths:wd,texts:zx,bounds:Be,refblocks:Ox,circles:Ad}=kx,ut=s({primitives:[...Object.values(wd),...Object.values(Ad),{...zx.top1,anchor:"middle_bottom"},{...zx.bottom1,anchor:"middle_top"}],ports:[{...Ox.left1,labels:["1"]},{...Ox.right1,labels:["2"]}],size:{width:Be.width,height:Be.height},center:{x:Be.centerX,y:Be.centerY}}),qe=r(ut,"up"),Jx=v(qe),$x=Y(ut),go={paths:{path11:{type:"path",points:[{x:-.54,y:-.06},{x:-.15,y:-.06}],color:"primary",fill:!1},path40:{type:"path",points:[{x:.13,y:-.05},{x:-.13,y:-.18}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.13,y:.08},{x:.13,y:-.05}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.13,y:-.18},{x:-.13,y:.08}],color:"primary",fill:!1},path43:{type:"path",points:[{x:.13,y:.08},{x:.13,y:-.18}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.14,y:-.05},{x:.54,y:-.06}],color:"primary",fill:!1},"path25-0-9-8":{type:"path",points:[{x:-.03,y:.39},{x:-.05,y:.47},{x:-.08,y:.39}],color:"primary",fill:!0},"path78-6-5-5":{type:"path",points:[{x:-.05,y:.27},{x:-.05,y:.29},{x:-.05,y:.41},{x:-.05,y:.42}],color:"primary",fill:!1},"path25-0-9-8-2":{type:"path",points:[{x:.07,y:.39},{x:.04,y:.47},{x:.02,y:.39}],color:"primary",fill:!0},"path78-6-5-5-7":{type:"path",points:[{x:.04,y:.27},{x:.04,y:.29},{x:.04,y:.41},{x:.04,y:.42}],color:"primary",fill:!1},"path43-1":{type:"path",points:[{x:.03,y:.06},{x:.03,y:-.16}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:.38,y:.38},bottom1:{type:"text",text:"{VAL}",x:.38,y:-.47}},refblocks:{left1:{x:-.54,y:-.06},right1:{x:.54,y:-.06}},bounds:{minX:-.57,maxX:.57,minY:-.47,maxY:.47,width:1.14,height:.93,centerX:0,centerY:0},circles:{path1:{type:"circle",x:0,y:-.05,radius:.29,color:"primary",fill:!1}}};go.bounds.width+=.2;G=e(go).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),uo=r(G,"down"),vo=uo.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),wo=uo.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");vo.anchor="middle_left";wo.anchor="middle_left";vo.y+=.9;vo.x=.3;wo.y-=.1;wo.x=.3;Mx=uo,Ao=r(G,"left"),Po=Ao.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),So=Ao.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Po.anchor="middle_left";So.anchor="middle_left";Po.y+=.71;Po.x=.44;So.y-=.71;So.x=.44;Cx=Ao,Ro=r(G,"up"),Fo=Ro.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),To=Ro.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Fo.anchor="middle_left";To.anchor="middle_left";Fo.y+=.1;Fo.x=.3;To.y-=.71;To.x=.3;Nx=Ro,Ix={paths:{path45:{type:"path",points:[{x:.14,y:0},{x:-.13,y:-.14}],color:"primary",fill:!1},"path1-8":{type:"path",points:[{x:.13,y:0},{x:.54,y:0}],color:"primary",fill:!1},path46:{type:"path",points:[{x:-.13,y:.13},{x:.14,y:0}],color:"primary",fill:!1},path47:{type:"path",points:[{x:-.13,y:-.14},{x:-.13,y:.13}],color:"primary",fill:!1},path48:{type:"path",points:[{x:.14,y:.13},{x:.14,y:-.14}],color:"primary",fill:!1},path49:{type:"path",points:[{x:-.13,y:0},{x:-.54,y:0}],color:"primary",fill:!1},path25:{type:"path",points:[{x:.16,y:.29},{x:.25,y:.3},{x:.22,y:.21}],color:"primary",fill:!0},path78:{type:"path",points:[{x:.08,y:.17},{x:.09,y:.17},{x:.21,y:.27},{x:.21,y:.27}],color:"primary",fill:!1},"path25-0":{type:"path",points:[{x:-.02,y:.31},{x:.08,y:.32},{x:.04,y:.23}],color:"primary",fill:!0},"path78-6":{type:"path",points:[{x:-.1,y:.19},{x:-.09,y:.2},{x:.04,y:.29},{x:.04,y:.29}],color:"primary",fill:!1}},texts:{bottom1:{type:"text",text:"{VAL}",x:0,y:-.21},right1:{type:"text",text:"{REF}",x:0,y:.41}},refblocks:{left1:{x:-.54,y:0},right1:{x:.54,y:0}},bounds:{minX:-.56,maxX:.56,minY:-.32,maxY:.32,width:1.13,height:.65,centerX:0,centerY:0},circles:{}},{paths:Rd,texts:Bx,bounds:De,refblocks:qx,circles:Fd}=Ix,vt=s({primitives:[...Object.values(Rd),...Object.values(Fd),{...Bx.bottom1,anchor:"middle_top"},{...Bx.right1,anchor:"middle_bottom"}],ports:[{...qx.left1,labels:["1"]},{...qx.right1,labels:["2"]}],size:{width:De.width,height:De.height},center:{x:De.centerX,y:De.centerY}}),Eo=r(vt,"up"),Yo=Eo.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),Xo=Eo.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Yo.anchor="middle_left";Xo.anchor="middle_left";Yo.y+=.21;Yo.x=.21;Xo.y-=.21;Xo.x=.21;Ge=Eo,Lo=v(Ge),Vo=Lo.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),jo=Lo.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Vo.anchor="middle_left";jo.anchor="middle_left";Vo.y+=.4;Vo.x=.2;jo.y-=.41;jo.x=.2;Dx=Lo,Gx=Y(vt),Ux={paths:{path11:{type:"path",points:[{x:-.52,y:-.01},{x:-.18,y:-.01}],color:"primary",fill:!1},"path11-2":{type:"path",points:[{x:-.17,y:-.11},{x:-.17,y:.08}],color:"primary",fill:!1},"path11-5":{type:"path",points:[{x:-.17,y:-.12},{x:.16,y:-.12}],color:"primary",fill:!1},"path11-5-5":{type:"path",points:[{x:-.17,y:.08},{x:.16,y:.08}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.17,y:-.01},{x:.52,y:-.01}],color:"primary",fill:!1},"path11-2-1":{type:"path",points:[{x:.16,y:-.12},{x:.16,y:.08}],color:"primary",fill:!1},"path25-0-9":{type:"path",points:[{x:-.4,y:-.21},{x:-.33,y:-.18},{x:-.34,y:-.27}],color:"primary",fill:!0},"path78-6-5":{type:"path",points:[{x:-.45,y:-.34},{x:-.44,y:-.32},{x:-.35,y:-.22},{x:-.35,y:-.22}],color:"primary",fill:!1},"path25-0-9-0":{type:"path",points:[{x:-.3,y:-.34},{x:-.22,y:-.31},{x:-.24,y:-.4}],color:"primary",fill:!0},"path78-6-5-9":{type:"path",points:[{x:-.35,y:-.46},{x:-.34,y:-.45},{x:-.25,y:-.35},{x:-.25,y:-.35}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.17,y:-.41},bottom1:{type:"text",text:"{VAL}",x:-.01,y:.46}},refblocks:{left1:{x:-.52,y:-.01},right1:{x:.52,y:-.01}},bounds:{minX:-.55,maxX:.55,minY:-.51,maxY:.46,width:1.1,height:.62,centerX:0,centerY:-.02},circles:{path1:{type:"circle",x:0,y:-.02,radius:.28,color:"primary",fill:!1}}},{paths:Ed,texts:Wx,bounds:Ue,refblocks:Hx,circles:Yd}=Ux,We=s({primitives:[...Object.values(Ed),...Object.values(Yd),{...Wx.top1,anchor:"middle_left",x:0},{...Wx.bottom1,anchor:"middle_left",x:0}],ports:[{...Hx.left1,labels:["1"]},{...Hx.right1,labels:["2"]}],size:{width:Ue.width,height:Ue.height},center:{x:Ue.centerX,y:Ue.centerY}}),Zx=r(We),Qx=Zx.primitives.filter(t5=>t5.type==="text"),ko=Qx.find(t5=>t5.text==="{VAL}");ko.x=-.35;ko.y=0;ko.anchor="middle_right";zo=Qx.find(t5=>t5.text==="{REF}");zo.y=0;zo.x=.35;zo.anchor="middle_left";Kx=Zx,ts={paths:{path208:{type:"path",points:[{x:.38,y:.13},{x:.52,y:-.13}],color:"primary",fill:!1},path209:{type:"path",points:[{x:.25,y:-.13},{x:.38,y:.13}],color:"primary",fill:!1},path210:{type:"path",points:[{x:.52,y:-.13},{x:.25,y:-.13}],color:"primary",fill:!1},path211:{type:"path",points:[{x:.25,y:.13},{x:.52,y:.13}],color:"primary",fill:!1},path212:{type:"path",points:[{x:.12,y:-.4},{x:.38,y:-.4}],color:"primary",fill:!1},path213:{type:"path",points:[{x:.38,y:.4},{x:.12,y:.4}],color:"primary",fill:!1},path214:{type:"path",points:[{x:.12,y:.54},{x:.12,y:.18}],color:"primary",fill:!1},path215:{type:"path",points:[{x:.12,y:-.54},{x:.12,y:0}],color:"primary",fill:!1},path216:{type:"path",points:[{x:.38,y:-.4},{x:.38,y:.4}],color:"primary",fill:!1},path217:{type:"path",points:[{x:-.14,y:.26},{x:-.14,y:-.27}],color:"primary",fill:!1},path218:{type:"path",points:[{x:-.22,y:-.27},{x:-.22,y:.26}],color:"primary",fill:!1},path219:{type:"path",points:[{x:-.54,y:-.27},{x:-.22,y:-.27}],color:"primary",fill:!1},path220:{type:"path",points:[{x:-.14,y:-.19},{x:.12,y:-.19}],color:"primary",fill:!1},path221:{type:"path",points:[{x:-.14,y:.18},{x:.12,y:.18}],color:"primary",fill:!1},path222:{type:"path",points:[{x:-.07,y:0},{x:.12,y:0}],color:"primary",fill:!1}},texts:{right1:{type:"text",text:"{VAL}",x:.57,y:.02},right2:{type:"text",text:"{REF}",x:.57,y:.21}},refblocks:{top1:{x:.12,y:.54},bottom1:{x:.12,y:-.54},left1:{x:-.54,y:-.27}},bounds:{minX:-.57,maxX:.57,minY:-.57,maxY:.57,width:1.14,height:1.14,centerX:0,centerY:0},circles:{}},{paths:Ld,texts:es,bounds:He,refblocks:Oo}=ts,Ze=s({primitives:[...Object.values(Ld),{...es.right1,anchor:"middle_left"},{...es.right2,anchor:"middle_left"}],ports:[{...Oo.top1,labels:["1"]},{...Oo.bottom1,labels:["2"]},{...Oo.left1,labels:["3"]}],size:{width:He.width+.4,height:He.height},center:{x:He.centerX+.2,y:He.centerY}}),Jo=r(Ze),rs=Jo.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),$o=Jo.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");rs.anchor="middle_top";$o.anchor="middle_top";rs.x=$o.x;$o.y+=.15;os=Jo,is={paths:{"path12-1-8-6-9":{type:"path",points:[{x:.01,y:.07},{x:.01,y:-.01}],color:"primary",fill:!1},"path12-1-5-6":{type:"path",points:[{x:-.47,y:-.09},{x:-.17,y:-.09}],color:"primary",fill:!1},"path12-1-8-0":{type:"path",points:[{x:-.16,y:-.01},{x:.17,y:-.01}],color:"primary",fill:!1},"path12-1-0":{type:"path",points:[{x:.2,y:-.09},{x:.47,y:-.09}],color:"primary",fill:!1},path2:{type:"path",points:[{x:-.1,y:.06},{x:-.1,y:.06},{x:-.1,y:.07},{x:-.1,y:.07},{x:-.1,y:.07},{x:-.1,y:.08},{x:-.1,y:.08},{x:-.1,y:.08},{x:-.1,y:.09},{x:-.09,y:.09},{x:-.09,y:.09},{x:-.09,y:.1},{x:-.09,y:.1},{x:-.09,y:.1},{x:-.09,y:.1},{x:-.09,y:.11},{x:-.09,y:.11},{x:-.08,y:.11},{x:-.08,y:.12},{x:-.08,y:.12},{x:-.08,y:.12},{x:-.08,y:.12},{x:-.07,y:.13},{x:-.07,y:.13},{x:-.07,y:.13},{x:-.07,y:.13},{x:-.06,y:.14},{x:-.06,y:.14},{x:-.06,y:.14},{x:-.06,y:.14},{x:-.05,y:.14},{x:-.05,y:.15},{x:-.05,y:.15},{x:-.04,y:.15},{x:-.04,y:.15},{x:-.04,y:.15},{x:-.04,y:.15},{x:-.03,y:.16},{x:-.03,y:.16},{x:-.03,y:.16},{x:-.02,y:.16},{x:-.02,y:.16},{x:-.02,y:.16},{x:-.01,y:.16},{x:-.01,y:.16},{x:0,y:.16},{x:0,y:.16},{x:0,y:.16},{x:.01,y:.16},{x:.01,y:.16},{x:.01,y:.16},{x:.02,y:.16},{x:.02,y:.16},{x:.02,y:.16},{x:.03,y:.16},{x:.03,y:.16},{x:.03,y:.16},{x:.04,y:.16},{x:.04,y:.16},{x:.04,y:.16},{x:.05,y:.15},{x:.05,y:.15},{x:.05,y:.15},{x:.06,y:.15},{x:.06,y:.15},{x:.06,y:.15},{x:.06,y:.14},{x:.07,y:.14},{x:.07,y:.14},{x:.07,y:.14},{x:.08,y:.14},{x:.08,y:.13},{x:.08,y:.13},{x:.08,y:.13},{x:.09,y:.13},{x:.09,y:.12},{x:.09,y:.12},{x:.09,y:.12},{x:.09,y:.12},{x:.1,y:.11},{x:.1,y:.11},{x:.1,y:.1},{x:.1,y:.1},{x:.11,y:.09},{x:.11,y:.09},{x:.11,y:.09},{x:.11,y:.08},{x:.11,y:.08},{x:.11,y:.08},{x:.11,y:.07},{x:.11,y:.07},{x:.11,y:.07},{x:.11,y:.06},{x:.11,y:.06},{x:.1,y:.06},{x:.1,y:.06},{x:.09,y:.06},{x:.09,y:.06},{x:.08,y:.06},{x:.07,y:.06},{x:.07,y:.06},{x:.06,y:.06},{x:.05,y:.06},{x:.05,y:.06},{x:.04,y:.06},{x:.03,y:.06},{x:.03,y:.06},{x:.02,y:.06},{x:.01,y:.06},{x:.01,y:.06},{x:0,y:.06},{x:-.01,y:.06},{x:-.01,y:.06},{x:-.02,y:.06},{x:-.03,y:.06},{x:-.03,y:.06},{x:-.04,y:.06},{x:-.05,y:.06},{x:-.05,y:.06},{x:-.06,y:.06},{x:-.07,y:.06},{x:-.07,y:.06},{x:-.08,y:.06},{x:-.09,y:.06},{x:-.09,y:.06}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:.01,y:.27},bottom1:{type:"text",text:"{VAL}",x:-.16,y:-.27}},refblocks:{left1:{x:-.47,y:-.09},right1:{x:.47,y:-.09}},bounds:{minX:-.5,maxX:.5,minY:-.27,maxY:.27,width:1,height:.53,centerX:0,centerY:0},circles:{}},{paths:jd,texts:ls,bounds:Qe,refblocks:ps,circles:kd}=is,Ke=s({primitives:[...Object.values(jd),...Object.values(kd),{...ls.top1,anchor:"middle_bottom",x:0},{...ls.bottom1,anchor:"middle_top",x:0}],ports:[{...ps.left1,labels:["1"]},{...ps.right1,labels:["2"]}],size:{width:Qe.width,height:Qe.height},center:{x:Qe.centerX+.006,y:Qe.centerY+.06}}),Mo=r(Ke),Xt=Mo.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),t0=Mo.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Xt.anchor="middle_left";t0.anchor="middle_right";Xt.x=Xt.x-.03;Xt.y=Xt.y;t0.x=t0.x;t0.y=0;as=Mo,ys={paths:{path11:{type:"path",points:[{x:-.42,y:-.1},{x:.05,y:-.11}],color:"primary",fill:!1},path40:{type:"path",points:[{x:.09,y:.19},{x:.09,y:-.18}],color:"primary",fill:!1},"path12-1":{type:"path",points:[{x:.3,y:.55},{x:.3,y:.11}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:.31,y:-.55},{x:.31,y:-.01}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.09,y:.11},{x:.31,y:.11}],color:"primary",fill:!1},"path2-5":{type:"path",points:[{x:.09,y:-.1},{x:.31,y:-.1}],color:"primary",fill:!1},path15:{type:"path",points:[{x:.27,y:-.04},{x:.27,y:.03},{x:.2,y:0},{x:.27,y:-.04}],color:"primary",fill:!0},"path2-0":{type:"path",points:[{x:.09,y:0},{x:.31,y:-.01}],color:"primary",fill:!1},"path12-1-0":{type:"path",points:[{x:.05,y:.17},{x:.05,y:-.11}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.13,y:.36},bottom1:{type:"text",text:"{VAL}",x:.06,y:-.42}},refblocks:{top1:{x:.3,y:.55},bottom1:{x:.31,y:-.55},left1:{x:-.42,y:-.1}},bounds:{minX:-.45,maxX:.45,minY:-.58,maxY:.58,width:.89,height:1.16,centerX:0,centerY:0},circles:{path1:{type:"circle",x:.16,y:0,radius:.29,color:"primary",fill:!1}}},{paths:Od,texts:xs,bounds:e0,refblocks:Co,circles:Jd}=ys,r0=s({primitives:[...Object.values(Od),...Object.values(Jd),{...xs.top1,anchor:"middle_right",x:0},{...xs.bottom1,anchor:"middle_right",x:0}],ports:[{...Co.top1,labels:["1","drain"]},{...Co.bottom1,labels:["2","source"]},{...Co.left1,labels:["3","gate"]}],size:{width:e0.width,height:e0.height},center:{x:e0.centerX,y:e0.centerY}}),ss=r(r0),ms2=ss.primitives.filter(t5=>t5.type==="text"),No=ms2.find(t5=>t5.text==="{VAL}");No.x=-.35;No.y=0;No.anchor="middle_right";Io=ms2.find(t5=>t5.text==="{REF}");Io.y=0;Io.x=.35;Io.anchor="middle_left";ns=ss,fs={paths:{path11:{type:"path",points:[{x:-.42,y:-.1},{x:.05,y:-.11}],color:"primary",fill:!1},"path12-1":{type:"path",points:[{x:.3,y:.55},{x:.3,y:.11}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:.31,y:-.55},{x:.31,y:-.01}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.09,y:.11},{x:.31,y:.11}],color:"primary",fill:!1},"path2-8-3-7":{type:"path",points:[{x:.09,y:.15},{x:.09,y:.07}],color:"primary",fill:!1},"path2-5":{type:"path",points:[{x:.09,y:-.1},{x:.31,y:-.1}],color:"primary",fill:!1},"path2-8-3":{type:"path",points:[{x:.09,y:-.08},{x:.09,y:-.15}],color:"primary",fill:!1},"path2-8-3-2":{type:"path",points:[{x:.09,y:.03},{x:.09,y:-.04}],color:"primary",fill:!1},path15:{type:"path",points:[{x:.27,y:-.04},{x:.27,y:.03},{x:.2,y:0},{x:.27,y:-.04}],color:"primary",fill:!0},"path2-0":{type:"path",points:[{x:.09,y:0},{x:.31,y:-.01}],color:"primary",fill:!1},"path12-1-0":{type:"path",points:[{x:.05,y:.11},{x:.05,y:-.11}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.13,y:.36},bottom1:{type:"text",text:"{VAL}",x:.06,y:-.42}},refblocks:{top1:{x:.3,y:.55},bottom1:{x:.31,y:-.55},left1:{x:-.42,y:-.1}},bounds:{minX:-.45,maxX:.45,minY:-.58,maxY:.58,width:.89,height:1.16,centerX:0,centerY:0},circles:{path1:{type:"circle",x:.16,y:0,radius:.29,color:"primary",fill:!1}}},{paths:Md,texts:cs,bounds:o0,refblocks:Bo,circles:Cd}=fs,i0=s({primitives:[...Object.values(Md),...Object.values(Cd),{...cs.top1,anchor:"middle_right",x:0},{...cs.bottom1,anchor:"middle_right",x:0}],ports:[{...Bo.top1,labels:["1","drain"]},{...Bo.bottom1,labels:["2","source"]},{...Bo.left1,labels:["3","gate"]}],size:{width:o0.width,height:o0.height},center:{x:o0.centerX,y:o0.centerY}}),hs=r(i0),ds=hs.primitives.filter(t5=>t5.type==="text"),qo=ds.find(t5=>t5.text==="{VAL}");qo.x=-.35;qo.y=0;qo.anchor="middle_right";Do=ds.find(t5=>t5.text==="{REF}");Do.y=0;Do.x=.35;Do.anchor="middle_left";bs=hs,_s={paths:{path11:{type:"path",points:[{x:-.4,y:0},{x:.06,y:-.01}],color:"primary",fill:!1},path40:{type:"path",points:[{x:.07,y:.19},{x:.07,y:-.18}],color:"primary",fill:!1},"path12-1":{type:"path",points:[{x:.28,y:.55},{x:.28,y:.11}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:.29,y:-.55},{x:.29,y:-.1}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.07,y:.11},{x:.29,y:.11}],color:"primary",fill:!1},"path2-5":{type:"path",points:[{x:.07,y:-.1},{x:.29,y:-.1}],color:"primary",fill:!1},path15:{type:"path",points:[{x:-.08,y:.06},{x:-.08,y:-.07},{x:.01,y:0},{x:-.08,y:.06}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:-.15,y:.36},bottom1:{type:"text",text:"{VAL}",x:.04,y:-.42}},refblocks:{top1:{x:.28,y:.55},bottom1:{x:.29,y:-.55},left1:{x:-.4,y:0}},bounds:{minX:-.43,maxX:.43,minY:-.58,maxY:.58,width:.85,height:1.16,centerX:0,centerY:0},circles:{path1:{type:"circle",x:.14,y:0,radius:.29,color:"primary",fill:!1}}},{paths:Id,texts:gs,bounds:l0,refblocks:Go,circles:Bd}=_s,p0=s({primitives:[...Object.values(Id),...Object.values(Bd),{...gs.top1,anchor:"middle_right",x:0},{...gs.bottom1,anchor:"middle_right",x:0}],ports:[{...Go.top1,labels:["1","drain"]},{...Go.bottom1,labels:["2","source"]},{...Go.left1,labels:["3","gate"]}],size:{width:l0.width,height:l0.height},center:{x:l0.centerX,y:l0.centerY}}),us=r(p0),vs=us.primitives.filter(t5=>t5.type==="text"),Uo=vs.find(t5=>t5.text==="{VAL}");Uo.x=-.35;Uo.y=0;Uo.anchor="middle_right";Wo=vs.find(t5=>t5.text==="{REF}");Wo.y=0;Wo.x=.35;Wo.anchor="middle_left";ws=us,As={paths:{diag1:{type:"path",points:[{x:-.1,y:-.1},{x:.1,y:.1}],color:"primary",fill:!1},diag2:{type:"path",points:[{x:-.1,y:.1},{x:.1,y:-.1}],color:"primary",fill:!1},stem:{type:"path",points:[{x:-.2,y:0},{x:0,y:0}],color:"primary",fill:!1}},texts:{},refblocks:{left1:{x:-.2,y:0}},bounds:{minX:-.19,maxX:.2,minY:-.12,maxY:.12,width:.39,height:.24,centerX:0,centerY:0},circles:{}},{paths:Dd,bounds:Ps,refblocks:Gd}=As,U=e({primitives:[...Object.values(Dd)],ports:[{...Gd.left1,labels:["1"]}],center:{x:Ps.centerX,y:Ps.centerY}}).rotateRightFacingSymbol("right").labelPort("left1",["1"]).build(),Ss=r(U,"down"),Rs=r(U,"left"),Fs=r(U,"up"),g={paths:{path11:{type:"path",points:[{x:-.4,y:0},{x:.06,y:-.01}],color:"primary",fill:!1},"path40-0":{type:"path",points:[{x:.07,y:.27},{x:.07,y:-.28}],color:"primary",fill:!1},"path40-0-5":{type:"path",points:[{x:.28,y:.24},{x:.08,y:.11}],color:"primary",fill:!1},"path40-0-5-0":{type:"path",points:[{x:.29,y:-.24},{x:.09,y:-.11}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:.29,y:.25},{x:.29,y:.55}],color:"primary",fill:!1},"path12-1-5-3":{type:"path",points:[{x:.29,y:-.55},{x:.29,y:-.25}],color:"primary",fill:!1},path15:{type:"path",points:[{x:.19,y:-.1},{x:.12,y:-.2},{x:.22,y:-.2},{x:.19,y:-.1}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:-.08,y:.36},bottom1:{type:"text",text:"{VAL}",x:-.07,y:-.41}},refblocks:{top1:{x:.29,y:.55},bottom1:{x:.29,y:-.55},left1:{x:-.4,y:0}},bounds:{minX:-.43,maxX:.43,minY:-.58,maxY:.58,width:.85,height:1.16,centerX:0,centerY:0},circles:{"path1-0":{type:"circle",x:.14,y:0,radius:.29,color:"primary",fill:!1}}},{paths:Wd,texts:gP,bounds:a0,refblocks:Ho,circles:Hd}=g,Ts=e({primitives:[...Object.values(Wd),...Object.values(Hd),{type:"text",text:"{REF}",x:-.1,y:.3094553499999995},{type:"text",text:"{VAL}",x:-.1,y:-.3094553499999995}],ports:[{...Ho.top1,labels:["1","collector"]},{...Ho.bottom1,labels:["2","emitter"]},{...Ho.left1,labels:["3","base"]}],size:{width:a0.width,height:a0.height},center:{x:a0.centerX,y:a0.centerY}}).rotateRightFacingSymbol("right").changeTextAnchor("{REF}","middle_right").changeTextAnchor("{VAL}","middle_right").build(),{paths:AP,texts:PP,bounds:SP,refblocks:RP,circles:FP}=g,Es=e(g).rotateRightFacingSymbol("up").changeTextAnchor("{VAL}","middle_left").labelPort("left1",["3","base"]).labelPort("top1",["1","collector"]).labelPort("bottom1",["2","emitter"]).changeTextAnchor("{REF}","middle_right").build(),{paths:Zd,texts:XP,bounds:y0,refblocks:Zo,circles:Qd}=g,Ys=e({primitives:[...Object.values(Zd),...Object.values(Qd),{type:"text",text:"{REF}",x:-.1,y:-.3094553499999995},{type:"text",text:"{VAL}",x:-.1,y:.3094553499999995}],ports:[{...Zo.top1,labels:["1","collector"]},{...Zo.bottom1,labels:["2","emitter"]},{...Zo.left1,labels:["3","base"]}],size:{width:y0.width,height:y0.height},center:{x:y0.centerX,y:y0.centerY}}).rotateRightFacingSymbol("down").changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_bottom").build(),{paths:Kd,texts:kP,bounds:x0,refblocks:Qo,circles:t2}=g,Xs=e({primitives:[...Object.values(Kd),...Object.values(t2),{type:"text",text:"{REF}",x:-.1,y:-.3094553499999995},{type:"text",text:"{VAL}",x:-.1,y:.3094553499999995}],ports:[{...Qo.top1,labels:["1","collector"]},{...Qo.bottom1,labels:["2","emitter"]},{...Qo.left1,labels:["3","base"]}],size:{width:x0.width,height:x0.height},center:{x:x0.centerX,y:x0.centerY}}).rotateRightFacingSymbol("up").changeTextAnchor("{REF}","middle_top").changeTextAnchor("{VAL}","middle_top").build(),{paths:e2,texts:$P,bounds:s0,refblocks:Ko,circles:r2}=g,Ls=e({primitives:[...Object.values(e2),...Object.values(r2),{type:"text",text:"{REF}",x:-.1,y:-.3094553499999995},{type:"text",text:"{VAL}",x:-.1,y:.3094553499999995}],ports:[{...Ko.top1,labels:["1","collector"]},{...Ko.bottom1,labels:["2","emitter"]},{...Ko.left1,labels:["3","base"]}],size:{width:s0.width,height:s0.height},center:{x:s0.centerX,y:s0.centerY}}).rotateRightFacingSymbol("left").changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:o2,texts:IP,bounds:m0,refblocks:ti,circles:i2}=g,Vs=e({primitives:[...Object.values(o2),...Object.values(i2),{type:"text",text:"{REF}",x:-.1,y:-.3094553499999995},{type:"text",text:"{VAL}",x:-.1,y:.3094553499999995}],ports:[{...ti.top1,labels:["1","collector"]},{...ti.bottom1,labels:["2","emitter"]},{...ti.left1,labels:["3","base"]}],size:{width:m0.width,height:m0.height},center:{x:m0.centerX,y:m0.centerY}}).rotateRightFacingSymbol("left").changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),js={paths:{path40:{type:"path",points:[{x:.14,y:.04},{x:-.32,y:-.21}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.32,y:.31},{x:.14,y:.04}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.32,y:-.21},{x:-.32,y:.31}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.32,y:.18},{x:-.57,y:.18}],color:"primary",fill:!1},path45:{type:"path",points:[{x:-.32,y:-.09},{x:-.57,y:-.09}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.43,y:.04},{x:.15,y:.04}],color:"primary",fill:!1},"rect1577-3":{type:"path",points:[{x:-.19,y:-.09},{x:-.27,y:-.09}],color:"primary",fill:!0},"rect1577-4":{type:"path",points:[{x:-.19,y:.18},{x:-.27,y:.18}],color:"primary",fill:!0},"rect1577-4-7":{type:"path",points:[{x:-.23,y:.14},{x:-.23,y:.22}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:-.01,y:.42},bottom1:{type:"text",text:"{VAL}",x:0,y:-.3}},refblocks:{left1:{x:-.57,y:.18},left2:{x:-.57,y:-.09},right1:{x:.43,y:.04}},bounds:{minX:-.55,maxX:.55,minY:-.38,maxY:.27,width:1.09,height:.3,centerX:0,centerY:.05},circles:{}},W=e(js).labelPort("left1",["1","inp1"]).labelPort("left2",["2","inp2"]).labelPort("right1",["3","out"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),ks=r(W,"down"),zs=v(r(W,"left")),Os=r(W,"up"),Js={paths:{path40:{type:"path",points:[{x:.14,y:.04},{x:-.32,y:-.21}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.32,y:.31},{x:.14,y:.04}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.32,y:-.21},{x:-.32,y:.31}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.32,y:.18},{x:-.57,y:.18}],color:"primary",fill:!1},path45:{type:"path",points:[{x:-.32,y:-.09},{x:-.57,y:-.09}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.43,y:.04},{x:.15,y:.04}],color:"primary",fill:!1},"path44-1":{type:"path",points:[{x:-.1,y:.44},{x:-.1,y:.18}],color:"primary",fill:!1},"path44-2":{type:"path",points:[{x:-.09,y:-.34},{x:-.09,y:-.09}],color:"primary",fill:!1},"rect1577-3":{type:"path",points:[{x:-.19,y:.18},{x:-.27,y:.18}],color:"primary",fill:!0},"rect1577-4":{type:"path",points:[{x:-.19,y:-.09},{x:-.27,y:-.09}],color:"primary",fill:!0},"rect1577-4-7":{type:"path",points:[{x:-.23,y:.14},{x:-.23,y:.22}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:.25,y:.32},bottom1:{type:"text",text:"{VAL}",x:.25,y:-.24}},refblocks:{left1:{x:-.57,y:.18},left2:{x:-.57,y:-.09},right1:{x:.43,y:.04},top2:{x:-.1,y:.44},bottom1:{x:-.09,y:-.34}},bounds:{minX:-.55,maxX:.55,minY:-.38,maxY:.27,width:1.09,height:.3,centerX:0,centerY:.05},circles:{}},H=e(Js).labelPort("left1",["1","inp1"]).labelPort("left2",["2","inp2"]).labelPort("right1",["4","out"]).labelPort("top2",["5","V+"]).labelPort("bottom1",["3","V-"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),$s=r(H,"down"),Ms=v(r(H,"left")),Cs=r(H,"up"),Ns={paths:{path11:{type:"path",points:[{x:-.42,y:-.1},{x:.05,y:-.11}],color:"primary",fill:!1},path40:{type:"path",points:[{x:.09,y:.19},{x:.09,y:-.18}],color:"primary",fill:!1},"path12-1":{type:"path",points:[{x:.3,y:.55},{x:.3,y:.11}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:.31,y:-.55},{x:.31,y:-.01}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.09,y:.11},{x:.31,y:.11}],color:"primary",fill:!1},"path2-5":{type:"path",points:[{x:.09,y:-.1},{x:.31,y:-.1}],color:"primary",fill:!1},path15:{type:"path",points:[{x:.2,y:.03},{x:.2,y:-.04},{x:.27,y:-.01},{x:.2,y:.03}],color:"primary",fill:!0},"path2-0":{type:"path",points:[{x:.09,y:0},{x:.31,y:-.01}],color:"primary",fill:!1},"path12-1-0":{type:"path",points:[{x:.05,y:.17},{x:.05,y:-.11}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.13,y:.36},bottom1:{type:"text",text:"{VAL}",x:.06,y:-.42}},refblocks:{top1:{x:.3,y:.55},bottom1:{x:.31,y:-.55},left1:{x:-.42,y:-.1}},bounds:{minX:-.45,maxX:.45,minY:-.58,maxY:.58,width:.89,height:1.16,centerX:0,centerY:0},circles:{path1:{type:"circle",x:.16,y:0,radius:.29,color:"primary",fill:!1}}},{paths:y2,texts:Is,bounds:n0,refblocks:ei,circles:x2}=Ns,f0=s({primitives:[...Object.values(y2),...Object.values(x2),{...Is.top1,anchor:"middle_right",x:0},{...Is.bottom1,anchor:"middle_right",x:0}],ports:[{...ei.top1,labels:["1","drain"]},{...ei.bottom1,labels:["2","source"]},{...ei.left1,labels:["3","gate"]}],size:{width:n0.width,height:n0.height},center:{x:n0.centerX,y:n0.centerY}}),Bs=r(f0),qs=Bs.primitives.filter(t5=>t5.type==="text"),ri=qs.find(t5=>t5.text==="{VAL}");ri.x=-.35;ri.y=0;ri.anchor="middle_right";oi=qs.find(t5=>t5.text==="{REF}");oi.y=0;oi.x=.35;oi.anchor="middle_left";Ds=Bs,Gs={paths:{path11:{type:"path",points:[{x:-.42,y:-.1},{x:.05,y:-.11}],color:"primary",fill:!1},"path12-1":{type:"path",points:[{x:.3,y:.55},{x:.3,y:.11}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:.31,y:-.55},{x:.31,y:-.01}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.09,y:.11},{x:.31,y:.11}],color:"primary",fill:!1},"path2-8-3-7":{type:"path",points:[{x:.09,y:.15},{x:.09,y:.07}],color:"primary",fill:!1},"path2-5":{type:"path",points:[{x:.09,y:-.1},{x:.31,y:-.1}],color:"primary",fill:!1},"path2-8-3":{type:"path",points:[{x:.09,y:-.08},{x:.09,y:-.15}],color:"primary",fill:!1},"path2-8-3-2":{type:"path",points:[{x:.09,y:.03},{x:.09,y:-.04}],color:"primary",fill:!1},path15:{type:"path",points:[{x:.2,y:.03},{x:.2,y:-.04},{x:.27,y:-.01},{x:.2,y:.03}],color:"primary",fill:!0},"path2-0":{type:"path",points:[{x:.09,y:0},{x:.31,y:-.01}],color:"primary",fill:!1},"path12-1-0":{type:"path",points:[{x:.05,y:.11},{x:.05,y:-.11}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.13,y:.36},bottom1:{type:"text",text:"{VAL}",x:.06,y:-.42}},refblocks:{top1:{x:.3,y:.55},bottom1:{x:.31,y:-.55},left1:{x:-.42,y:-.1}},bounds:{minX:-.45,maxX:.45,minY:-.58,maxY:.58,width:.89,height:1.16,centerX:0,centerY:0},circles:{path1:{type:"circle",x:.16,y:0,radius:.29,color:"primary",fill:!1}}},{paths:m2,texts:Us,bounds:c0,refblocks:ii,circles:n2}=Gs,h0=s({primitives:[...Object.values(m2),...Object.values(n2),{...Us.top1,anchor:"middle_right",x:0},{...Us.bottom1,anchor:"middle_right",x:0}],ports:[{...ii.top1,labels:["1","drain"]},{...ii.bottom1,labels:["2","source"]},{...ii.left1,labels:["3","gate"]}],size:{width:c0.width,height:c0.height},center:{x:c0.centerX,y:c0.centerY}}),Ws=r(h0),Hs=Ws.primitives.filter(t5=>t5.type==="text"),li=Hs.find(t5=>t5.text==="{VAL}");li.x=-.35;li.y=0;li.anchor="middle_right";pi=Hs.find(t5=>t5.text==="{REF}");pi.y=0;pi.x=.35;pi.anchor="middle_left";Zs=Ws,Qs={paths:{path11:{type:"path",points:[{x:-.54,y:-.01},{x:-.15,y:-.02}],color:"primary",fill:!1},path40:{type:"path",points:[{x:.13,y:0},{x:-.13,y:-.13}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.13,y:.13},{x:.13,y:0}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.13,y:-.13},{x:-.13,y:.13}],color:"primary",fill:!1},path43:{type:"path",points:[{x:.13,y:.13},{x:.13,y:-.13}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.14,y:0},{x:.54,y:-.01}],color:"primary",fill:!1},"path25-0":{type:"path",points:[{x:.2,y:.38},{x:.16,y:.28},{x:.26,y:.3}],color:"primary",fill:!0},"path78-6":{type:"path",points:[{x:.33,y:.43},{x:.32,y:.42},{x:.21,y:.31},{x:.21,y:.31}],color:"primary",fill:!1},"path25-0-9":{type:"path",points:[{x:.35,y:.35},{x:.31,y:.26},{x:.41,y:.27}],color:"primary",fill:!0},"path78-6-5":{type:"path",points:[{x:.48,y:.4},{x:.47,y:.39},{x:.35,y:.29},{x:.35,y:.29}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.1,y:.35},bottom1:{type:"text",text:"{VAL}",x:0,y:-.43}},refblocks:{left1:{x:-.54,y:-.01},right1:{x:.54,y:-.01}},bounds:{minX:-.57,maxX:.57,minY:-.43,maxY:.43,width:1.14,height:.85,centerX:0,centerY:0},circles:{path1:{type:"circle",x:0,y:-.01,radius:.29,color:"primary",fill:!1}}},d0=e(Qs).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),Ks=r(d0),c2=Ks.primitives.filter(t5=>t5.type==="text"),tm=c2.find(t5=>t5.text==="{REF}");tm.y=0;tm.anchor="middle_left";em=Ks,rm={paths:{path11:{type:"path",points:[{x:-.4,y:0},{x:.06,y:-.01}],color:"primary",fill:!1},path40:{type:"path",points:[{x:.07,y:.19},{x:.07,y:-.18}],color:"primary",fill:!1},"path12-1":{type:"path",points:[{x:.28,y:.55},{x:.28,y:.11}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:.29,y:-.55},{x:.29,y:-.1}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.07,y:.11},{x:.29,y:.11}],color:"primary",fill:!1},"path2-5":{type:"path",points:[{x:.07,y:-.1},{x:.29,y:-.1}],color:"primary",fill:!1},path15:{type:"path",points:[{x:.01,y:-.07},{x:.01,y:.06},{x:-.08,y:0},{x:.01,y:-.07}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:-.15,y:.36},bottom1:{type:"text",text:"{VAL}",x:.04,y:-.42}},refblocks:{top1:{x:.28,y:.55},bottom1:{x:.29,y:-.55},left1:{x:-.4,y:0}},bounds:{minX:-.43,maxX:.43,minY:-.58,maxY:.58,width:.85,height:1.16,centerX:0,centerY:0},circles:{path1:{type:"circle",x:.14,y:0,radius:.29,color:"primary",fill:!1}}},{paths:d2,texts:om,bounds:b0,refblocks:ai,circles:b2}=rm,_0=s({primitives:[...Object.values(d2),...Object.values(b2),{...om.top1,anchor:"middle_right",x:0},{...om.bottom1,anchor:"middle_right"}],ports:[{...ai.top1,labels:["1","drain"]},{...ai.bottom1,labels:["2","source"]},{...ai.left1,labels:["3","gate"]}],size:{width:b0.width,height:b0.height},center:{x:b0.centerX,y:b0.centerY}}),im=r(_0),lm=im.primitives.filter(t5=>t5.type==="text"),yi=lm.find(t5=>t5.text==="{VAL}");yi.x=-.35;yi.y=0;yi.anchor="middle_right";xi=lm.find(t5=>t5.text==="{REF}");xi.y=0;xi.x=.35;xi.anchor="middle_left";pm=im,u={paths:{path11:{type:"path",points:[{x:-.4,y:0},{x:.06,y:-.01}],color:"primary",fill:!1},"path40-0":{type:"path",points:[{x:.07,y:.27},{x:.07,y:-.28}],color:"primary",fill:!1},"path40-0-5":{type:"path",points:[{x:.28,y:.24},{x:.08,y:.11}],color:"primary",fill:!1},"path40-0-5-0":{type:"path",points:[{x:.29,y:-.24},{x:.09,y:-.11}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:.29,y:.25},{x:.29,y:.55}],color:"primary",fill:!1},"path12-1-5-3":{type:"path",points:[{x:.29,y:-.55},{x:.29,y:-.25}],color:"primary",fill:!1},path15:{type:"path",points:[{x:.15,y:-.23},{x:.22,y:-.12},{x:.12,y:-.12},{x:.15,y:-.23}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:-.08,y:.37},bottom1:{type:"text",text:"{VAL}",x:-.07,y:-.41}},refblocks:{top1:{x:.29,y:.55},bottom1:{x:.29,y:-.55},left1:{x:-.4,y:0}},bounds:{minX:-.43,maxX:.43,minY:-.58,maxY:.58,width:.85,height:1.16,centerX:0,centerY:0},circles:{"path1-0":{type:"circle",x:.14,y:0,radius:.29,color:"primary",fill:!1}}},{paths:g2,texts:US,bounds:g0,refblocks:si,circles:u2}=u,am=e({primitives:[...Object.values(g2),...Object.values(u2),{type:"text",text:"{REF}",x:-.1,y:.3094553499999995},{type:"text",text:"{VAL}",x:-.1,y:-.3094553499999995}],ports:[{...si.top1,labels:["1","collector"]},{...si.bottom1,labels:["2","emitter"]},{...si.left1,labels:["3","base"]}],size:{width:g0.width,height:g0.height},center:{x:g0.centerX,y:g0.centerY}}).rotateRightFacingSymbol("right").changeTextAnchor("{REF}","middle_right").changeTextAnchor("{VAL}","middle_right").build(),{paths:QS,texts:KS,bounds:tR,refblocks:eR,circles:rR}=u,ym=e(u).rotateRightFacingSymbol("up").changeTextAnchor("{VAL}","middle_left").labelPort("left1",["3","base"]).labelPort("top1",["1","collector"]).labelPort("bottom1",["2","emitter"]).changeTextAnchor("{REF}","middle_right").build(),{paths:v2,texts:pR,bounds:u0,refblocks:mi,circles:w2}=u,xm=e({primitives:[...Object.values(v2),...Object.values(w2),{type:"text",text:"{REF}",x:-.1,y:-.3094553499999995},{type:"text",text:"{VAL}",x:-.1,y:.3094553499999995}],ports:[{...mi.top1,labels:["1","collector"]},{...mi.bottom1,labels:["2","emitter"]},{...mi.left1,labels:["3","base"]}],size:{width:u0.width,height:u0.height},center:{x:u0.centerX,y:u0.centerY}}).rotateRightFacingSymbol("down").changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_bottom").build(),{paths:A2,texts:sR,bounds:v0,refblocks:ni,circles:P2}=u,sm=e({primitives:[...Object.values(A2),...Object.values(P2),{type:"text",text:"{REF}",x:-.1,y:-.3094553499999995},{type:"text",text:"{VAL}",x:-.1,y:.3094553499999995}],ports:[{...ni.top1,labels:["1","collector"]},{...ni.bottom1,labels:["2","emitter"]},{...ni.left1,labels:["3","base"]}],size:{width:v0.width,height:v0.height},center:{x:v0.centerX,y:v0.centerY}}).rotateRightFacingSymbol("up").changeTextAnchor("{REF}","middle_top").changeTextAnchor("{VAL}","middle_top").build(),{paths:S2,texts:cR,bounds:w0,refblocks:fi,circles:R2}=u,mm2=e({primitives:[...Object.values(S2),...Object.values(R2),{type:"text",text:"{REF}",x:-.1,y:-.3094553499999995},{type:"text",text:"{VAL}",x:-.1,y:.3094553499999995}],ports:[{...fi.top1,labels:["1","collector"]},{...fi.bottom1,labels:["2","emitter"]},{...fi.left1,labels:["3","base"]}],size:{width:w0.width,height:w0.height},center:{x:w0.centerX,y:w0.centerY}}).rotateRightFacingSymbol("left").changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:F2,texts:_R,bounds:A0,refblocks:ci,circles:T2}=u,nm=e({primitives:[...Object.values(F2),...Object.values(T2),{type:"text",text:"{REF}",x:-.1,y:-.3094553499999995},{type:"text",text:"{VAL}",x:-.1,y:.3094553499999995}],ports:[{...ci.top1,labels:["1","collector"]},{...ci.bottom1,labels:["2","emitter"]},{...ci.left1,labels:["3","base"]}],size:{width:A0.width,height:A0.height},center:{x:A0.centerX,y:A0.centerY}}).rotateRightFacingSymbol("left").changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),fm={paths:{path40:{type:"path",points:[{x:-.19,y:.33},{x:-.26,y:.14}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.38,y:.26},{x:-.19,y:.33}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.26,y:.14},{x:-.38,y:.26}],color:"primary",fill:!1},path43:{type:"path",points:[{x:-.26,y:.39},{x:-.13,y:.26}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.32,y:.2},{x:-.52,y:0}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:0,y:.52},{x:-.19,y:.33}],color:"primary",fill:!1},"path40-4":{type:"path",points:[{x:-.19,y:-.32},{x:-.38,y:-.26}],color:"primary",fill:!1},"path41-1":{type:"path",points:[{x:-.26,y:-.13},{x:-.19,y:-.32}],color:"primary",fill:!1},"path42-7":{type:"path",points:[{x:-.38,y:-.26},{x:-.26,y:-.13}],color:"primary",fill:!1},"path43-1":{type:"path",points:[{x:-.13,y:-.26},{x:-.26,y:-.39}],color:"primary",fill:!1},"path44-8":{type:"path",points:[{x:-.32,y:-.19},{x:-.51,y:-.01}],color:"primary",fill:!1},"path44-0-7":{type:"path",points:[{x:-.01,y:-.5},{x:-.19,y:-.32}],color:"primary",fill:!1},"path40-4-0":{type:"path",points:[{x:.32,y:.19},{x:.13,y:.26}],color:"primary",fill:!1},"path41-1-2":{type:"path",points:[{x:.26,y:.38},{x:.32,y:.19}],color:"primary",fill:!1},"path42-7-1":{type:"path",points:[{x:.13,y:.26},{x:.26,y:.38}],color:"primary",fill:!1},"path43-1-8":{type:"path",points:[{x:.39,y:.26},{x:.26,y:.13}],color:"primary",fill:!1},"path44-8-7":{type:"path",points:[{x:.2,y:.32},{x:.01,y:.51}],color:"primary",fill:!1},"path44-0-7-1":{type:"path",points:[{x:.52,y:0},{x:.32,y:.19}],color:"primary",fill:!1},"path40-4-8":{type:"path",points:[{x:.32,y:-.19},{x:.26,y:-.38}],color:"primary",fill:!1},"path41-1-4":{type:"path",points:[{x:.13,y:-.26},{x:.32,y:-.19}],color:"primary",fill:!1},"path42-7-0":{type:"path",points:[{x:.26,y:-.38},{x:.13,y:-.26}],color:"primary",fill:!1},"path43-1-0":{type:"path",points:[{x:.26,y:-.13},{x:.39,y:-.26}],color:"primary",fill:!1},"path44-8-9":{type:"path",points:[{x:.19,y:-.32},{x:0,y:-.52}],color:"primary",fill:!1},"path44-0-7-3":{type:"path",points:[{x:.5,y:-.01},{x:.32,y:-.19}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.29,y:.46},bottom1:{type:"text",text:"{VAL}",x:-.29,y:-.5}},refblocks:{top1:{x:0,y:.52},bottom1:{x:0,y:-.52},left1:{x:-.52,y:0},right1:{x:.52,y:0}},bounds:{minX:-.55,maxX:.55,minY:-.55,maxY:.55,width:1.09,height:1.09,centerX:0,centerY:0},circles:{}},{paths:Y2,texts:cm,bounds:P0,refblocks:hm}=fm,S0=s({primitives:[...Object.values(Y2),{...cm.bottom1,y:.35,anchor:"middle_top"},{...cm.top1,anchor:"middle_left"}],ports:[{...hm.left1,labels:["1"]},{...hm.right1,labels:["2"]}],size:{width:P0.width+.05,height:P0.height},center:{x:P0.centerX,y:P0.centerY}}),X2=r(S0),dm=X2,bm={paths:{path18:{type:"path",points:[{x:-.53,y:0},{x:-.27,y:0}],color:"primary",fill:!1},path19:{type:"path",points:[{x:.26,y:0},{x:.53,y:0}],color:"primary",fill:!1},path20:{type:"path",points:[{x:0,y:.13},{x:.26,y:.13},{x:.26,y:-.13},{x:-.27,y:-.13},{x:-.27,y:.13},{x:0,y:.13}],color:"primary",fill:!1},path23:{type:"path",points:[{x:.28,y:-.28},{x:.18,y:-.25},{x:.25,y:-.18}],color:"primary",fill:!0},path24:{type:"path",points:[{x:.29,y:-.29},{x:.25,y:-.17},{x:.16,y:-.26}],color:"primary",fill:!0},path26:{type:"path",points:[{x:-.3,y:.29},{x:.23,y:-.23}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:.06,y:.2},bottom1:{type:"text",text:"{VAL}",x:-.1,y:-.28}},refblocks:{left1:{x:-.53,y:0},right1:{x:.53,y:0}},bounds:{minX:-.56,maxX:.56,minY:-.29,maxY:.29,width:1.13,height:.58,centerX:0,centerY:0},circles:{}},{paths:V2,texts:_m,bounds:R0,refblocks:gm}=bm,Z=s({primitives:[...Object.values(V2),{..._m.bottom1,x:0,y:-.35,anchor:"middle_top"},{..._m.top1,x:0,y:.35,anchor:"middle_bottom"}],ports:[{...gm.left1,labels:["1"]},{...gm.right1,labels:["2"]}],size:{width:R0.width+.05,height:R0.height},center:{x:R0.centerX,y:R0.centerY}}),hi=r(Z,"down"),di=hi.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),bi=hi.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");di.anchor="middle_left";bi.anchor="middle_left";di.y+=.31;di.x=.34;bi.y-=.31;bi.x=.34;um=hi,_i=r(Z,"left"),gi=_i.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),ui=_i.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");gi.anchor="middle_bottom";ui.anchor="middle_top";gi.y+=.73;gi.x=0;ui.y-=.7;ui.x=0;vm=_i,vi=r(Z,"up"),wi=vi.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),Ai=vi.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");wi.anchor="middle_left";Ai.anchor="middle_left";wi.y+=.21;wi.x=.34;Ai.y-=.21;Ai.x=.34;wm=vi,Q={paths:{path1:{type:"path",points:[{x:-.42,y:0},{x:-.3,y:0}],color:"primary",fill:!1},"path1-2-1":{type:"path",points:[{x:-.3,y:0},{x:-.25,y:.1},{x:-.15,y:-.1},{x:-.05,y:.1},{x:.05,y:-.1},{x:.15,y:.1},{x:.25,y:-.1},{x:.3,y:0}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.3,y:0},{x:.42,y:0}],color:"primary",fill:!1},path3:{type:"path",points:[{x:0,y:-.17},{x:0,y:-.4}],color:"primary",fill:!1},path15:{type:"path",points:[{x:0,y:-.12},{x:.05,y:-.2},{x:-.05,y:-.2},{x:0,y:-.12}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:.3,y:.25},bottom1:{type:"text",text:"{VAL}",x:.3,y:-.25}},refblocks:{left:{x:-.42,y:0},right:{x:.42,y:0},bottom:{x:0,y:-.4}},bounds:{minX:-.42,maxX:.42,minY:-.2,maxY:.2,width:.84,height:.4,centerX:0,centerY:0},circles:{}},{paths:k2,texts:IR,bounds:F0,refblocks:Pi,circles:z2}=Q,Am=e({primitives:[...Object.values(k2),...Object.values(z2),{type:"text",text:"{REF}",x:-.15,y:.2394553499999995},{type:"text",text:"{VAL}",x:.15,y:.2394553499999995}],ports:[{...Pi.left,labels:["1"]},{...Pi.right,labels:["3"]},{...Pi.bottom,labels:["2"]}],size:{width:F0.width,height:F0.height},center:{x:F0.centerX,y:F0.centerY}}).rotateRightFacingSymbol("down").labelPort("left",["1"]).labelPort("right",["2"]).labelPort("bottom",["3"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:O2,texts:GR,bounds:T0,refblocks:Si,circles:J2}=Q,Pm=e({primitives:[...Object.values(O2),...Object.values(J2),{type:"text",text:"{REF}",x:-.3,y:-.3894553499999995},{type:"text",text:"{VAL}",x:-.3,y:.3194553499999995}],ports:[{...Si.left,labels:["1"]},{...Si.right,labels:["3"]},{...Si.bottom,labels:["2"]}],size:{width:T0.width,height:T0.height},center:{x:T0.centerX,y:T0.centerY}}).rotateRightFacingSymbol("left").labelPort("left",["1"]).labelPort("right",["2"]).labelPort("bottom",["3"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),Sm=e(Q).labelPort("left",["1"]).labelPort("right",["3"]).labelPort("bottom",["2"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),{paths:$2,texts:tF,bounds:E0,refblocks:Ri,circles:M2}=Q,Rm=e({primitives:[...Object.values($2),...Object.values(M2),{type:"text",text:"{REF}",x:.3,y:-.2894553499999995},{type:"text",text:"{VAL}",x:-.3,y:-.2894553499999995}],ports:[{...Ri.left,labels:["1"]},{...Ri.right,labels:["3"]},{...Ri.bottom,labels:["2"]}],size:{width:E0.width,height:E0.height},center:{x:E0.centerX,y:E0.centerY}}).rotateRightFacingSymbol("up").labelPort("left",["1"]).labelPort("right",["2"]).labelPort("bottom",["3"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),Fm={paths:{path11:{type:"path",points:[{x:-.54,y:.03},{x:-.3,y:.03}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:.03},{x:.54,y:.03}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.16,y:.4},bottom1:{type:"text",text:"{VAL}",x:0,y:-.4},left1:{type:"text",text:"COS \u03C6",x:-.15,y:.01}},refblocks:{left1:{x:-.54,y:.03},right1:{x:.54,y:.03}},bounds:{minX:-.57,maxX:.57,minY:-.4,maxY:.4,width:1.14,height:.79,centerX:0,centerY:0},circles:{path1:{type:"circle",x:0,y:.04,radius:.29,color:"primary",fill:!1}}},{paths:N2,texts:lF,bounds:Y0,refblocks:Tm,circles:I2}=Fm,X0=s({primitives:[...Object.values(N2),...Object.values(I2),{type:"text",text:"{REF}",x:-.15,y:-.42330070000000064,anchor:"middle_top"},{type:"text",text:"{VAL}",x:-.15,y:.42330070000000064,anchor:"middle_bottom"},{type:"text",text:"COS \u03C6",x:0,y:.014279000000000375,anchor:"center"}],ports:[{...Tm.left1,labels:["1"]},{...Tm.right1,labels:["2"]}],size:{width:Y0.width,height:Y0.height},center:{x:Y0.centerX,y:Y0.centerY}}),Em=r(X0),Fi=Em.primitives.filter(t5=>t5.type==="text"),Ti=Fi.find(t5=>t5.text==="{REF}"),Ei=Fi.find(t5=>t5.text==="{VAL}"),Yi=Fi.find(t5=>t5.text==="COS \u03C6");Ti.x=.35;Ti.y=0;Ti.anchor="middle_left";Ei.anchor="middle_right";Ei.x=-.35;Ei.y=0;Yi.x=0;Yi.y=0;Yi.anchor="center";Ym=Em,Xm={paths:{"path12-1-8-6-9-9":{type:"path",points:[{x:.01,y:.03},{x:.01,y:-.09}],color:"primary",fill:!1},"path12-1-5-6-4":{type:"path",points:[{x:-.47,y:-.05},{x:-.17,y:-.05}],color:"primary",fill:!1},"path12-1-8-0-0":{type:"path",points:[{x:-.16,y:-.09},{x:.18,y:-.09}],color:"primary",fill:!1},"path12-1-0-1":{type:"path",points:[{x:.2,y:-.05},{x:.47,y:-.05}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:.01,y:.22},bottom1:{type:"text",text:"{VAL}",x:-.16,y:-.22}},refblocks:{left1:{x:-.47,y:-.05},right1:{x:.47,y:-.05}},bounds:{minX:-.5,maxX:.5,minY:-.22,maxY:.22,width:1,height:.45,centerX:0,centerY:0},circles:{"circle-2":{type:"circle",x:-.14,y:-.05,radius:.02,color:"primary",fill:!1},circle:{type:"circle",x:.17,y:-.05,radius:.02,color:"primary",fill:!1}}},{paths:q2,texts:Lm,bounds:L0,refblocks:Vm,circles:D2}=Xm,V0=s({primitives:[...Object.values(q2),...Object.values(D2),{...Lm.top1,anchor:"middle_left"},{...Lm.bottom1,anchor:"middle_left"}],ports:[{...Vm.left1,labels:["1"]},{...Vm.right1,labels:["2"]}],size:{width:L0.width,height:L0.height},center:{x:L0.centerX,y:L0.centerY}}),jm=r(V0,"up"),km={paths:{"path12-1-8-6-9-9":{type:"path",points:[{x:-.05,y:.09},{x:-.05,y:.04}],color:"primary",fill:!1},"path12-1-8-7-9-9":{type:"path",points:[{x:-.05,y:.09},{x:.07,y:.09}],color:"primary",fill:!1},"path12-1-8-6-9-10":{type:"path",points:[{x:.07,y:.09},{x:.07,y:.04}],color:"primary",fill:!1},"path12-1-5-6-4":{type:"path",points:[{x:-.47,y:-.05},{x:-.17,y:-.05}],color:"primary",fill:!1},"path12-1-8-0-0":{type:"path",points:[{x:-.16,y:.04},{x:.18,y:.04}],color:"primary",fill:!1},"path12-1-0-1":{type:"path",points:[{x:.2,y:-.05},{x:.47,y:-.05}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:.01,y:.29},bottom1:{type:"text",text:"{VAL}",x:-.16,y:-.22}},refblocks:{left1:{x:-.47,y:-.05},right1:{x:.47,y:-.05}},bounds:{minX:-.5,maxX:.5,minY:-.22,maxY:.22,width:1,height:.45,centerX:0,centerY:0},circles:{"circle-2":{type:"circle",x:-.14,y:-.05,radius:.02,color:"primary",fill:!1},circle:{type:"circle",x:.17,y:-.05,radius:.02,color:"primary",fill:!1}}},{paths:U2,texts:zm,bounds:j0,refblocks:Om,circles:W2}=km,k0=s({primitives:[...Object.values(U2),...Object.values(W2),{...zm.top1,anchor:"middle_left"},{...zm.bottom1,anchor:"middle_left"}],ports:[{...Om.left1,labels:["1"]},{...Om.right1,labels:["2"]}],size:{width:j0.width,height:j0.height},center:{x:j0.centerX,y:j0.centerY}}),Jm=r(k0,"up"),K={paths:{path12_rotated:{type:"path",points:[{x:-.09,y:.12},{x:-.09,y:-.12}],color:"primary",fill:!1},path2_rotated:{type:"path",points:[{x:-.09,y:0},{x:.09,y:0}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:0,y:.03}},refblocks:{left1:{x:.09,y:0}},bounds:{minX:-.57,maxX:.57,minY:-.37,maxY:.37,width:1.14,height:.74,centerX:0,centerY:0},circles:{}},{paths:Z2,texts:FF,bounds:$m,refblocks:Q2,circles:K2}=K,Mm=e({primitives:[...Object.values(Z2),...Object.values(K2),{type:"text",text:"{REF}",x:-.14,y:-0}],ports:[{...Q2.left1,labels:["1"]}],center:{x:$m.centerX,y:$m.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_top").build(),{paths:t9,texts:XF,bounds:Cm,refblocks:e9,circles:r9}=K,Nm=e({primitives:[...Object.values(t9),...Object.values(r9),{type:"text",text:"{REF}",x:-.13,y:0}],ports:[{...e9.left1,labels:["1"]}],center:{x:Cm.centerX,y:Cm.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_right").build(),{paths:o9,texts:kF,bounds:Im,refblocks:i9,circles:l9}=K,Bm=e({primitives:[...Object.values(o9),...Object.values(l9),{type:"text",text:"{REF}",x:-.14,y:-0}],ports:[{...i9.left1,labels:["1"]}],center:{x:Im.centerX,y:Im.centerY}}).rotateRightFacingSymbol("left").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_left").build(),{paths:p9,texts:$F,bounds:qm,refblocks:a9}=K,Dm=e({primitives:[...Object.values(p9),{type:"text",text:"{REF}",x:-.14,y:0}],ports:[{...a9.left1,labels:["1"]}],center:{x:qm.centerX,y:qm.centerY}}).rotateRightFacingSymbol("down").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_bottom").build(),Gm={paths:{path40:{type:"path",points:[{x:-.19,y:-.33},{x:-.26,y:-.14}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.38,y:-.26},{x:-.19,y:-.33}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.26,y:-.14},{x:-.38,y:-.26}],color:"primary",fill:!1},path43:{type:"path",points:[{x:-.26,y:-.39},{x:-.13,y:-.26}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.32,y:-.2},{x:-.52,y:0}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:0,y:-.52},{x:-.19,y:-.33}],color:"primary",fill:!1},"path40-4":{type:"path",points:[{x:-.19,y:.32},{x:-.38,y:.26}],color:"primary",fill:!1},"path41-1":{type:"path",points:[{x:-.26,y:.13},{x:-.19,y:.32}],color:"primary",fill:!1},"path42-7":{type:"path",points:[{x:-.38,y:.26},{x:-.26,y:.13}],color:"primary",fill:!1},"path43-1":{type:"path",points:[{x:-.13,y:.26},{x:-.26,y:.39}],color:"primary",fill:!1},"path44-8":{type:"path",points:[{x:-.32,y:.19},{x:-.51,y:.01}],color:"primary",fill:!1},"path44-0-7":{type:"path",points:[{x:-.01,y:.5},{x:-.19,y:.32}],color:"primary",fill:!1},"path40-4-0":{type:"path",points:[{x:.32,y:-.19},{x:.13,y:-.26}],color:"primary",fill:!1},"path41-1-2":{type:"path",points:[{x:.26,y:-.38},{x:.32,y:-.19}],color:"primary",fill:!1},"path42-7-1":{type:"path",points:[{x:.13,y:-.26},{x:.26,y:-.38}],color:"primary",fill:!1},"path43-1-8":{type:"path",points:[{x:.39,y:-.26},{x:.26,y:-.13}],color:"primary",fill:!1},"path44-8-7":{type:"path",points:[{x:.2,y:-.32},{x:.01,y:-.51}],color:"primary",fill:!1},"path44-0-7-1":{type:"path",points:[{x:.52,y:0},{x:.32,y:-.19}],color:"primary",fill:!1},"path40-4-8":{type:"path",points:[{x:.32,y:.19},{x:.26,y:.38}],color:"primary",fill:!1},"path41-1-4":{type:"path",points:[{x:.13,y:.26},{x:.32,y:.19}],color:"primary",fill:!1},"path42-7-0":{type:"path",points:[{x:.26,y:.38},{x:.13,y:.26}],color:"primary",fill:!1},"path43-1-0":{type:"path",points:[{x:.26,y:.13},{x:.39,y:.26}],color:"primary",fill:!1},"path44-8-9":{type:"path",points:[{x:.19,y:.32},{x:0,y:.52}],color:"primary",fill:!1},"path44-0-7-3":{type:"path",points:[{x:.5,y:.01},{x:.32,y:.19}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.29,y:-.46},bottom1:{type:"text",text:"{VAL}",x:-.29,y:.5}},refblocks:{top1:{x:0,y:-.52},bottom1:{x:0,y:.52},left1:{x:-.52,y:0},right1:{x:.52,y:0}},bounds:{minX:-.55,maxX:.55,minY:-.56,maxY:.55,width:1.09,height:1.1,centerX:0,centerY:0},circles:{}},{paths:x9,texts:Um,bounds:z0,refblocks:O0,circles:s9}=Gm,J0=s({primitives:[...Object.values(x9),...Object.values(s9),{...Um.top1,anchor:"middle_right"},{...Um.bottom1,anchor:"middle_right"}],ports:[{...O0.top1,labels:["1"]},{...O0.bottom1,labels:["2"]},{...O0.left1,labels:["3"]},{...O0.right1,labels:["4"]}],size:{width:z0.width,height:z0.height},center:{x:z0.centerX,y:z0.centerY}}),Xi=r(J0),m9=Xi.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),n9=Xi.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");m9.anchor="middle_left";n9.anchor="middle_right";Wm=Xi,tt={paths:{path27:{type:"path",points:[{x:.47,y:.04},{x:.21,y:.04}],color:"primary",fill:!1},"path27-0":{type:"path",points:[{x:-.21,y:.04},{x:-.47,y:.04}],color:"primary",fill:!1},"path27-8-2-4":{type:"path",points:[{x:.21,y:.04},{x:.19,y:-.05}],color:"primary",fill:!1},"path27-8-2-4-29":{type:"path",points:[{x:-.19,y:.14},{x:-.21,y:.04}],color:"primary",fill:!1},"path27-8-2-4-5":{type:"path",points:[{x:.19,y:-.05},{x:.13,y:.14}],color:"primary",fill:!1},"path27-8-2-4-5-1":{type:"path",points:[{x:.08,y:-.05},{x:.13,y:.14}],color:"primary",fill:!1},"path27-8-2-4-5-1-9":{type:"path",points:[{x:.08,y:-.05},{x:.03,y:.14}],color:"primary",fill:!1},"path27-8-2-4-5-1-9-2":{type:"path",points:[{x:-.03,y:-.05},{x:.03,y:.14}],color:"primary",fill:!1},"path27-8-2-4-5-1-9-2-1":{type:"path",points:[{x:-.03,y:-.05},{x:-.08,y:.14}],color:"primary",fill:!1},"path27-8-2-4-5-1-9-2-1-2":{type:"path",points:[{x:-.13,y:-.05},{x:-.08,y:.14}],color:"primary",fill:!1},"path27-8-2-4-5-1-9-2-1-2-2":{type:"path",points:[{x:-.13,y:-.05},{x:-.19,y:.14}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.05,y:.42},bottom1:{type:"text",text:"{VAL}",x:-.04,y:-.42}},refblocks:{left1:{x:-.47,y:.04},right1:{x:.47,y:.04}},bounds:{minX:-.49,maxX:.49,minY:-.42,maxY:.42,width:.99,height:.84,centerX:0,centerY:0},circles:{}},{paths:c9,texts:ZF,bounds:$0,refblocks:Hm,circles:h9}=tt,Zm=e({primitives:[...Object.values(c9),...Object.values(h9),{type:"text",text:"{REF}",x:-.2,y:.2194553499999995},{type:"text",text:"{VAL}",x:.2,y:.2194553499999995}],ports:[{...Hm.left1,labels:["1"]},{...Hm.right1,labels:["2"]}],size:{width:$0.width,height:$0.height},center:{x:$0.centerX,y:$0.centerY}}).rotateRightFacingSymbol("down").labelPort("left",["1"]).labelPort("right",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:d9,texts:eT,bounds:M0,refblocks:Qm,circles:b9}=tt,Km=e({primitives:[...Object.values(d9),...Object.values(b9),{type:"text",text:"{REF}",x:0,y:-.1704553499999995},{type:"text",text:"{VAL}",x:0,y:.2294553499999995}],ports:[{...Qm.left1,labels:["1"]},{...Qm.right1,labels:["2"]}],size:{width:M0.width,height:M0.height},center:{x:M0.centerX,y:M0.centerY}}).rotateRightFacingSymbol("left").labelPort("left",["1"]).labelPort("right",["2"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),{paths:_9,texts:lT,bounds:C0,refblocks:tn,circles:g9}=tt,en=e({primitives:[...Object.values(_9),...Object.values(g9),{type:"text",text:"{REF}",x:0,y:.2294553499999995},{type:"text",text:"{VAL}",x:0,y:-.1704553499999995}],ports:[{...tn.left1,labels:["1"]},{...tn.right1,labels:["2"]}],size:{width:C0.width,height:C0.height},center:{x:C0.centerX,y:C0.centerY}}).rotateRightFacingSymbol("right").labelPort("left",["1"]).labelPort("right",["2"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),{paths:u9,texts:xT,bounds:N0,refblocks:rn,circles:v9}=tt,on=e({primitives:[...Object.values(u9),...Object.values(v9),{type:"text",text:"{REF}",x:.2,y:-.1404553499999995},{type:"text",text:"{VAL}",x:-.2,y:-.1494553499999995}],ports:[{...rn.left1,labels:["1"]},{...rn.right1,labels:["2"]}],size:{width:N0.width,height:N0.height},center:{x:N0.centerX,y:N0.centerY}}).rotateRightFacingSymbol("up").labelPort("left",["1"]).labelPort("right",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),I0={paths:{path27:{type:"path",points:[{x:.76,y:-.28},{x:.31,y:-.28}],color:"primary",fill:!1},path28:{type:"path",points:[{x:-.3,y:-.02},{x:-.77,y:-.02}],color:"primary",fill:!1},path30:{type:"path",points:[{x:-.3,y:.35},{x:-.3,y:-.28}],color:"primary",fill:!1},"path27-3":{type:"path",points:[{x:.77,y:.35},{x:.32,y:.35}],color:"primary",fill:!1},"path29-5":{type:"path",points:[{x:-.07,y:-.28},{x:-.3,y:-.28}],color:"primary",fill:!1},"path29-5-7":{type:"path",points:[{x:.33,y:-.28},{x:.11,y:-.28}],color:"primary",fill:!1},"path29-5-7-6":{type:"path",points:[{x:-.06,y:-.17},{x:-.06,y:-.39}],color:"primary",fill:!1},"path29-5-7-6-6":{type:"path",points:[{x:.09,y:-.17},{x:.09,y:-.39}],color:"primary",fill:!1},"path29-5-9":{type:"path",points:[{x:-.07,y:.35},{x:-.3,y:.35}],color:"primary",fill:!1},"path29-5-7-2":{type:"path",points:[{x:.33,y:.35},{x:.11,y:.35}],color:"primary",fill:!1},"path29-5-7-6-0":{type:"path",points:[{x:-.06,y:.46},{x:-.06,y:.24}],color:"primary",fill:!1},"path29-5-7-6-6-2":{type:"path",points:[{x:.09,y:.46},{x:.09,y:.24}],color:"primary",fill:!1},"path29-5-92":{type:"path",points:[{x:.33,y:.13},{x:.33,y:.35}],color:"primary",fill:!1},"path29-5-7-28":{type:"path",points:[{x:.33,y:-.28},{x:.33,y:-.05}],color:"primary",fill:!1},"path29-5-7-6-9":{type:"path",points:[{x:.44,y:.11},{x:.22,y:.11}],color:"primary",fill:!1},"path29-5-7-6-6-7":{type:"path",points:[{x:.44,y:-.04},{x:.22,y:-.04}],color:"primary",fill:!1},"path29-5-7-6-9-2":{type:"path",points:[{x:.44,y:.07},{x:.22,y:.07}],color:"primary",fill:!1},"path29-5-7-6-9-2-4":{type:"path",points:[{x:.44,y:0},{x:.44,y:.07}],color:"primary",fill:!1},"path29-5-7-6-9-2-4-6":{type:"path",points:[{x:.22,y:0},{x:.22,y:.07}],color:"primary",fill:!1},"path29-5-7-6-9-2-9":{type:"path",points:[{x:.44,y:0},{x:.22,y:0}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:.02,y:.53},bottom1:{type:"text",text:"{VAL}",x:.01,y:-.54}},refblocks:{left1:{x:-.77,y:-.02},right1:{x:.76,y:-.28},right2:{x:.77,y:.35}},bounds:{minX:-.79,maxX:.79,minY:-.54,maxY:.54,width:1.59,height:1.07,centerX:0,centerY:0},circles:{}},{paths:A9,texts:ln,bounds:B0,refblocks:Li,circles:P9}=I0,et=s({primitives:[...Object.values(A9),...Object.values(P9),{...ln.top1,anchor:"middle_bottom"},{...ln.bottom1,anchor:"middle_top"}],ports:[{...Li.left1,labels:["1"]},{...Li.right1,labels:["2"]},{...Li.right2,labels:["3"]}],size:{width:B0.width,height:B0.height},center:{x:B0.centerX,y:B0.centerY}}),Vi=r(et,"down"),ji=Vi.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),ki=Vi.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");ji.anchor="middle_bottom";ki.anchor="middle_top";ji.y+=.3;ji.x+=.101;ki.y-=.49999;ki.x+=1.19999;pn=Vi,{paths:S9,texts:uT,bounds:q0,refblocks:zi,circles:R9}=I0,D0=s({primitives:[...Object.values(S9),...Object.values(R9),{type:"text",text:"{REF}",x:.01596175000000022,y:-.5308501500000009,anchor:"middle_top"},{type:"text",text:"{VAL}",x:.013116750000000454,y:.5408501499999989,anchor:"middle_bottom"}],ports:[{...zi.left1,labels:["1"]},{...zi.right1,labels:["2"]},{...zi.right2,labels:["3"]}],size:{width:q0.width,height:q0.height},center:{x:q0.centerX,y:q0.centerY}}),Oi=r(et,"left"),Ji=Oi.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),$i=Oi.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Ji.anchor="middle_bottom";$i.anchor="middle_top";Ji.y+=.99;Ji.x-=0;$i.y-=1.10999;$i.x=0;an=Oi,Mi=r(et,"up"),Ci=Mi.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),Ni=Mi.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Ci.anchor="middle_bottom";Ni.anchor="middle_top";Ci.y+=.499;Ci.x=.62;Ni.y-=.29999;Ni.x+=.1;yn=Mi,xn=r(D0),sn={paths:{path40:{type:"path",points:[{x:.14,y:.04},{x:-.12,y:-.09}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.12,y:.18},{x:.14,y:.04}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.12,y:-.09},{x:-.12,y:.18}],color:"primary",fill:!1},path43:{type:"path",points:[{x:.14,y:.18},{x:.14,y:-.09}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.12,y:.04},{x:-.52,y:.04}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.52,y:.04},{x:.15,y:.04}],color:"primary",fill:!1},"path43-7":{type:"path",points:[{x:.21,y:.18},{x:.14,y:.18}],color:"primary",fill:!1},"path43-7-9":{type:"path",points:[{x:.21,y:.13},{x:.21,y:.18}],color:"primary",fill:!1},"path43-7-2":{type:"path",points:[{x:.08,y:-.09},{x:.14,y:-.09}],color:"primary",fill:!1},"path43-7-9-3":{type:"path",points:[{x:.08,y:-.04},{x:.08,y:-.09}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.01,y:.27},bottom1:{type:"text",text:"{VAL}",x:0,y:-.27}},refblocks:{left1:{x:-.52,y:.04},right1:{x:.52,y:.04}},bounds:{minX:-.55,maxX:.55,minY:-.27,maxY:.27,width:1.09,height:.55,centerX:0,centerY:0},circles:{}},rt=e(sn).labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{VAL}","middle_top").changeTextAnchor("{REF}","middle_bottom").build(),Ii=r(rt,"down"),Bi=Ii.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),qi=Ii.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Bi.anchor="middle_left";qi.anchor="middle_left";Bi.y+=.3;Bi.x=.3;qi.y-=.3;qi.x=.3;mn=Ii,Di=r(rt,"left"),Gi=Di.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),Ui=Di.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Gi.anchor="middle_bottom";Ui.anchor="middle_top";Gi.y+=.5;Gi.x=0;Ui.y-=.55;Ui.x=0;nn=Di,Wi=r(rt,"up"),Hi=Wi.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),Zi=Wi.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Hi.anchor="middle_left";Zi.anchor="middle_left";Hi.y+=.3;Hi.x=.3;Zi.y-=.3;Zi.x=.3;fn=Wi,Qi={paths:{path11:{type:"path",points:[{x:-.52,y:.04},{x:-.18,y:.04}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.19,y:.05},{x:.52,y:.05}],color:"primary",fill:!1},"path12-6":{type:"path",points:[{x:.18,y:-.15},{x:.18,y:.25}],color:"primary",fill:!1},"path12-2":{type:"path",points:[{x:.19,y:0},{x:.35,y:-.14}],color:"primary",fill:!1},"path12-2-9":{type:"path",points:[{x:.35,y:-.14},{x:.34,y:-.35}],color:"primary",fill:!1},"path11-0-9":{type:"path",points:[{x:-.17,y:.27},{x:-.17,y:-.15},{x:.18,y:.05},{x:-.17,y:.27}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:-.22,y:.38},bottom1:{type:"text",text:"{VAL}",x:.11,y:-.38}},refblocks:{bottom1:{x:.34,y:-.35},left1:{x:-.52,y:.04},right1:{x:.52,y:.05}},bounds:{minX:-.55,maxX:.55,minY:-.38,maxY:.38,width:1.09,height:.77,centerX:0,centerY:0},circles:{}},{paths:GT,texts:UT,bounds:WT,refblocks:HT,circles:ZT}=Qi,G0=e(Qi).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).labelPort("bottom1",["3"]).changeTextAnchor("{REF}","middle_bottom").build(),cn=r(G0),E9=cn.primitives.filter(t5=>t5.type==="text"),hn=E9.find(t5=>t5.text==="{REF}");hn.y=0;hn.anchor="middle_left";dn=cn,ot={paths:{path44:{type:"path",points:[{x:-.18,y:-.03},{x:-.45,y:-.03}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.45,y:-.03},{x:.18,y:-.02}],color:"primary",fill:!1},"path44-0-7":{type:"path",points:[{x:.07,y:-.02},{x:-.07,y:-.02}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.07,y:.1},{x:.07,y:-.15}],color:"primary",fill:!0},"path2-8":{type:"path",points:[{x:-.07,y:.1},{x:-.07,y:-.15}],color:"primary",fill:!0},"path8704-1":{type:"path",points:[{x:-.07,y:-.15},{x:-.07,y:-.15},{x:-.09,y:-.15},{x:-.1,y:-.14},{x:-.11,y:-.13},{x:-.13,y:-.12},{x:-.14,y:-.11},{x:-.14,y:-.1},{x:-.15,y:-.09},{x:-.16,y:-.08},{x:-.16,y:-.07},{x:-.16,y:-.06},{x:-.17,y:-.05},{x:-.17,y:-.04},{x:-.17,y:-.03},{x:-.17,y:-.02},{x:-.17,y:-.01},{x:-.16,y:0},{x:-.16,y:.01},{x:-.16,y:.02},{x:-.15,y:.03},{x:-.15,y:.04},{x:-.14,y:.05},{x:-.14,y:.05},{x:-.13,y:.06},{x:-.12,y:.07},{x:-.11,y:.08},{x:-.11,y:.08},{x:-.1,y:.09},{x:-.09,y:.09},{x:-.08,y:.1},{x:-.07,y:.1},{x:-.07,y:.1}],color:"primary",fill:!1},"path8704-1-7":{type:"path",points:[{x:.07,y:-.15},{x:.07,y:-.15},{x:.09,y:-.15},{x:.1,y:-.14},{x:.12,y:-.13},{x:.13,y:-.12},{x:.14,y:-.11},{x:.14,y:-.1},{x:.15,y:-.09},{x:.16,y:-.08},{x:.16,y:-.07},{x:.17,y:-.06},{x:.17,y:-.05},{x:.17,y:-.04},{x:.17,y:-.03},{x:.17,y:-.02},{x:.17,y:-.01},{x:.16,y:0},{x:.16,y:.01},{x:.16,y:.02},{x:.15,y:.03},{x:.15,y:.04},{x:.14,y:.05},{x:.14,y:.05},{x:.13,y:.06},{x:.12,y:.07},{x:.11,y:.08},{x:.11,y:.08},{x:.1,y:.09},{x:.09,y:.09},{x:.08,y:.1},{x:.07,y:.1},{x:.07,y:.1}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.02,y:.15}},refblocks:{left1:{x:-.45,y:-.03},right1:{x:.45,y:-.03}},bounds:{minX:-.47,maxX:.47,minY:-.15,maxY:.15,width:.95,height:.31,centerX:0,centerY:0},circles:{}},bn=e(ot).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").build(),_n=e(ot).rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_top").build(),gn=e(ot).rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),un=e(ot).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_right").build(),it={paths:{path44:{type:"path",points:[{x:-.18,y:-.03},{x:-.45,y:-.03}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.45,y:-.03},{x:.18,y:-.02}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.07,y:.1},{x:.07,y:-.15}],color:"primary",fill:!0},"path2-8":{type:"path",points:[{x:-.07,y:.1},{x:-.07,y:-.15}],color:"primary",fill:!0},"path8704-1":{type:"path",points:[{x:-.07,y:-.15},{x:-.07,y:-.15},{x:-.09,y:-.15},{x:-.1,y:-.14},{x:-.11,y:-.13},{x:-.13,y:-.12},{x:-.14,y:-.11},{x:-.14,y:-.1},{x:-.15,y:-.09},{x:-.16,y:-.08},{x:-.16,y:-.07},{x:-.16,y:-.06},{x:-.17,y:-.05},{x:-.17,y:-.04},{x:-.17,y:-.03},{x:-.17,y:-.02},{x:-.17,y:-.01},{x:-.16,y:0},{x:-.16,y:.01},{x:-.16,y:.02},{x:-.15,y:.03},{x:-.15,y:.04},{x:-.14,y:.05},{x:-.14,y:.05},{x:-.13,y:.06},{x:-.12,y:.07},{x:-.11,y:.08},{x:-.11,y:.08},{x:-.1,y:.09},{x:-.09,y:.09},{x:-.08,y:.1},{x:-.07,y:.1},{x:-.07,y:.1}],color:"primary",fill:!1},"path8704-1-7":{type:"path",points:[{x:.07,y:-.15},{x:.07,y:-.15},{x:.09,y:-.15},{x:.1,y:-.14},{x:.12,y:-.13},{x:.13,y:-.12},{x:.14,y:-.11},{x:.14,y:-.1},{x:.15,y:-.09},{x:.16,y:-.08},{x:.16,y:-.07},{x:.17,y:-.06},{x:.17,y:-.05},{x:.17,y:-.04},{x:.17,y:-.03},{x:.17,y:-.02},{x:.17,y:-.01},{x:.16,y:0},{x:.16,y:.01},{x:.16,y:.02},{x:.15,y:.03},{x:.15,y:.04},{x:.14,y:.05},{x:.14,y:.05},{x:.13,y:.06},{x:.12,y:.07},{x:.11,y:.08},{x:.11,y:.08},{x:.1,y:.09},{x:.09,y:.09},{x:.08,y:.1},{x:.07,y:.1},{x:.07,y:.1}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.02,y:.15}},refblocks:{left1:{x:-.45,y:-.03},right1:{x:.45,y:-.03}},bounds:{minX:-.47,maxX:.47,minY:-.15,maxY:.15,width:.95,height:.31,centerX:0,centerY:0},circles:{}},vn=e(it).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").build(),wn=e(it).rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_top").build(),An=e(it).rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),Pn=e(it).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_right").build(),lt={paths:{path44:{type:"path",points:[{x:-.22,y:.1},{x:-.45,y:.1}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.45,y:.1},{x:.22,y:.1}],color:"primary",fill:!1},"path44-5":{type:"path",points:[{x:0,y:-.03},{x:0,y:-.25}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.12,y:.23},{x:.12,y:-.02}],color:"primary",fill:!0},"path2-88":{type:"path",points:[{x:.04,y:.22},{x:.04,y:-.02}],color:"primary",fill:!0},"path2-88-5":{type:"path",points:[{x:-.05,y:.22},{x:-.05,y:-.02}],color:"primary",fill:!0},"path2-88-5-1":{type:"path",points:[{x:.04,y:.22},{x:-.05,y:.22}],color:"primary",fill:!0},"path2-88-5-1-6":{type:"path",points:[{x:.04,y:-.02},{x:-.05,y:-.02}],color:"primary",fill:!0},"path2-8":{type:"path",points:[{x:-.12,y:.23},{x:-.12,y:-.02}],color:"primary",fill:!0},"path8704-1":{type:"path",points:[{x:-.13,y:-.03},{x:-.13,y:-.03},{x:-.14,y:-.02},{x:-.16,y:-.01},{x:-.17,y:0},{x:-.18,y:.01},{x:-.19,y:.02},{x:-.2,y:.03},{x:-.2,y:.04},{x:-.21,y:.05},{x:-.21,y:.06},{x:-.22,y:.07},{x:-.22,y:.08},{x:-.22,y:.09},{x:-.22,y:.1},{x:-.22,y:.11},{x:-.22,y:.12},{x:-.22,y:.13},{x:-.21,y:.14},{x:-.21,y:.15},{x:-.21,y:.15},{x:-.2,y:.16},{x:-.19,y:.17},{x:-.19,y:.18},{x:-.18,y:.19},{x:-.17,y:.2},{x:-.17,y:.2},{x:-.16,y:.21},{x:-.15,y:.22},{x:-.14,y:.22},{x:-.13,y:.23},{x:-.13,y:.23},{x:-.13,y:.23}],color:"primary",fill:!1},"path8704-1-7":{type:"path",points:[{x:.12,y:-.03},{x:.12,y:-.03},{x:.14,y:-.02},{x:.15,y:-.01},{x:.17,y:0},{x:.18,y:.01},{x:.19,y:.02},{x:.2,y:.03},{x:.2,y:.04},{x:.21,y:.05},{x:.21,y:.06},{x:.22,y:.07},{x:.22,y:.08},{x:.22,y:.09},{x:.22,y:.1},{x:.22,y:.11},{x:.22,y:.12},{x:.22,y:.13},{x:.21,y:.14},{x:.21,y:.15},{x:.2,y:.15},{x:.2,y:.16},{x:.19,y:.17},{x:.19,y:.18},{x:.18,y:.19},{x:.17,y:.2},{x:.17,y:.2},{x:.16,y:.21},{x:.15,y:.21},{x:.14,y:.22},{x:.13,y:.23},{x:.12,y:.23},{x:.12,y:.23}],color:"primary",fill:!1},path1:{type:"path",points:[{x:-.05,y:.1},{x:-.12,y:.1}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.02,y:.28}},refblocks:{bottom1:{x:0,y:-.25},left1:{x:-.45,y:.1},right1:{x:.45,y:.1}},bounds:{minX:-.47,maxX:.47,minY:-.28,maxY:.28,width:.95,height:.56,centerX:0,centerY:0},circles:{}},Sn=e(lt).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_left").build(),Rn=e(lt).rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_top").build(),Fn=e(lt).rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_bottom").build(),Tn=e(lt).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_right").build(),pt={paths:{path44:{type:"path",points:[{x:-.22,y:.1},{x:-.45,y:.1}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.45,y:.1},{x:.22,y:.1}],color:"primary",fill:!1},"path44-0-7":{type:"path",points:[{x:.12,y:.1},{x:.04,y:.1}],color:"primary",fill:!1},"path44-5":{type:"path",points:[{x:0,y:-.03},{x:0,y:-.25}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.12,y:.23},{x:.12,y:-.02}],color:"primary",fill:!0},"path2-88":{type:"path",points:[{x:.04,y:.22},{x:.04,y:-.02}],color:"primary",fill:!0},"path2-88-5":{type:"path",points:[{x:-.05,y:.22},{x:-.05,y:-.02}],color:"primary",fill:!0},"path2-88-5-1":{type:"path",points:[{x:.04,y:.22},{x:-.05,y:.22}],color:"primary",fill:!0},"path2-88-5-1-6":{type:"path",points:[{x:.04,y:-.02},{x:-.05,y:-.02}],color:"primary",fill:!0},"path2-8":{type:"path",points:[{x:-.12,y:.23},{x:-.12,y:-.02}],color:"primary",fill:!0},"path8704-1":{type:"path",points:[{x:-.13,y:-.03},{x:-.13,y:-.03},{x:-.14,y:-.02},{x:-.16,y:-.01},{x:-.17,y:0},{x:-.18,y:.01},{x:-.19,y:.02},{x:-.2,y:.03},{x:-.2,y:.04},{x:-.21,y:.05},{x:-.21,y:.06},{x:-.22,y:.07},{x:-.22,y:.08},{x:-.22,y:.09},{x:-.22,y:.1},{x:-.22,y:.11},{x:-.22,y:.12},{x:-.22,y:.13},{x:-.21,y:.14},{x:-.21,y:.15},{x:-.21,y:.15},{x:-.2,y:.16},{x:-.19,y:.17},{x:-.19,y:.18},{x:-.18,y:.19},{x:-.17,y:.2},{x:-.17,y:.2},{x:-.16,y:.21},{x:-.15,y:.22},{x:-.14,y:.22},{x:-.13,y:.23},{x:-.13,y:.23},{x:-.13,y:.23}],color:"primary",fill:!1},"path8704-1-7":{type:"path",points:[{x:.12,y:-.03},{x:.12,y:-.03},{x:.14,y:-.02},{x:.15,y:-.01},{x:.17,y:0},{x:.18,y:.01},{x:.19,y:.02},{x:.2,y:.03},{x:.2,y:.04},{x:.21,y:.05},{x:.21,y:.06},{x:.22,y:.07},{x:.22,y:.08},{x:.22,y:.09},{x:.22,y:.1},{x:.22,y:.11},{x:.22,y:.12},{x:.22,y:.13},{x:.21,y:.14},{x:.21,y:.15},{x:.2,y:.15},{x:.2,y:.16},{x:.19,y:.17},{x:.19,y:.18},{x:.18,y:.19},{x:.17,y:.2},{x:.17,y:.2},{x:.16,y:.21},{x:.15,y:.21},{x:.14,y:.22},{x:.13,y:.23},{x:.12,y:.23},{x:.12,y:.23}],color:"primary",fill:!1},path1:{type:"path",points:[{x:-.05,y:.1},{x:-.12,y:.1}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.02,y:.28}},refblocks:{bottom1:{x:0,y:-.25},left1:{x:-.45,y:.1},right1:{x:.45,y:.1}},bounds:{minX:-.47,maxX:.47,minY:-.28,maxY:.28,width:.95,height:.56,centerX:0,centerY:0},circles:{}},En=e(pt).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_left").build(),Yn=e(pt).rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_top").build(),Xn=e(pt).rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_bottom").build(),Ln=e(pt).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_right").build(),at={paths:{path44:{type:"path",points:[{x:-.22,y:.1},{x:-.45,y:.1}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.45,y:.1},{x:.22,y:.1}],color:"primary",fill:!1},"path44-0-7":{type:"path",points:[{x:.12,y:.1},{x:.04,y:.1}],color:"primary",fill:!1},"path44-5":{type:"path",points:[{x:0,y:-.03},{x:0,y:-.25}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.12,y:.23},{x:.12,y:-.02}],color:"primary",fill:!0},"path2-88":{type:"path",points:[{x:.04,y:.22},{x:.04,y:-.02}],color:"primary",fill:!0},"path2-88-5":{type:"path",points:[{x:-.05,y:.22},{x:-.05,y:-.02}],color:"primary",fill:!0},"path2-88-5-1":{type:"path",points:[{x:.04,y:.22},{x:-.05,y:.22}],color:"primary",fill:!0},"path2-88-5-1-6":{type:"path",points:[{x:.04,y:-.02},{x:-.05,y:-.02}],color:"primary",fill:!0},"path2-8":{type:"path",points:[{x:-.12,y:.23},{x:-.12,y:-.02}],color:"primary",fill:!0},"path8704-1":{type:"path",points:[{x:-.13,y:-.03},{x:-.13,y:-.03},{x:-.14,y:-.02},{x:-.16,y:-.01},{x:-.17,y:0},{x:-.18,y:.01},{x:-.19,y:.02},{x:-.2,y:.03},{x:-.2,y:.04},{x:-.21,y:.05},{x:-.21,y:.06},{x:-.22,y:.07},{x:-.22,y:.08},{x:-.22,y:.09},{x:-.22,y:.1},{x:-.22,y:.11},{x:-.22,y:.12},{x:-.22,y:.13},{x:-.21,y:.14},{x:-.21,y:.15},{x:-.21,y:.15},{x:-.2,y:.16},{x:-.19,y:.17},{x:-.19,y:.18},{x:-.18,y:.19},{x:-.17,y:.2},{x:-.17,y:.2},{x:-.16,y:.21},{x:-.15,y:.22},{x:-.14,y:.22},{x:-.13,y:.23},{x:-.13,y:.23},{x:-.13,y:.23}],color:"primary",fill:!1},"path8704-1-7":{type:"path",points:[{x:.12,y:-.03},{x:.12,y:-.03},{x:.14,y:-.02},{x:.15,y:-.01},{x:.17,y:0},{x:.18,y:.01},{x:.19,y:.02},{x:.2,y:.03},{x:.2,y:.04},{x:.21,y:.05},{x:.21,y:.06},{x:.22,y:.07},{x:.22,y:.08},{x:.22,y:.09},{x:.22,y:.1},{x:.22,y:.11},{x:.22,y:.12},{x:.22,y:.13},{x:.21,y:.14},{x:.21,y:.15},{x:.2,y:.15},{x:.2,y:.16},{x:.19,y:.17},{x:.19,y:.18},{x:.18,y:.19},{x:.17,y:.2},{x:.17,y:.2},{x:.16,y:.21},{x:.15,y:.21},{x:.14,y:.22},{x:.13,y:.23},{x:.12,y:.23},{x:.12,y:.23}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.02,y:.28}},refblocks:{bottom1:{x:0,y:-.25},left1:{x:-.45,y:.1},right1:{x:.45,y:.1}},bounds:{minX:-.47,maxX:.47,minY:-.28,maxY:.28,width:.95,height:.56,centerX:0,centerY:0},circles:{}},Vn=e(at).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_left").build(),jn=e(at).rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_top").build(),kn=e(at).rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_bottom").build(),zn=e(at).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_right").build(),yt={paths:{path44:{type:"path",points:[{x:-.22,y:.1},{x:-.45,y:.1}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.45,y:.1},{x:.22,y:.1}],color:"primary",fill:!1},"path44-5":{type:"path",points:[{x:0,y:-.03},{x:0,y:-.25}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.12,y:.23},{x:.12,y:-.02}],color:"primary",fill:!0},"path2-88":{type:"path",points:[{x:.04,y:.22},{x:.04,y:-.02}],color:"primary",fill:!0},"path2-88-5":{type:"path",points:[{x:-.05,y:.22},{x:-.05,y:-.02}],color:"primary",fill:!0},"path2-88-5-1":{type:"path",points:[{x:.04,y:.22},{x:-.05,y:.22}],color:"primary",fill:!0},"path2-88-5-1-6":{type:"path",points:[{x:.04,y:-.02},{x:-.05,y:-.02}],color:"primary",fill:!0},"path2-8":{type:"path",points:[{x:-.12,y:.23},{x:-.12,y:-.02}],color:"primary",fill:!0},"path8704-1":{type:"path",points:[{x:-.13,y:-.03},{x:-.13,y:-.03},{x:-.14,y:-.02},{x:-.16,y:-.01},{x:-.17,y:0},{x:-.18,y:.01},{x:-.19,y:.02},{x:-.2,y:.03},{x:-.2,y:.04},{x:-.21,y:.05},{x:-.21,y:.06},{x:-.22,y:.07},{x:-.22,y:.08},{x:-.22,y:.09},{x:-.22,y:.1},{x:-.22,y:.11},{x:-.22,y:.12},{x:-.22,y:.13},{x:-.21,y:.14},{x:-.21,y:.15},{x:-.21,y:.15},{x:-.2,y:.16},{x:-.19,y:.17},{x:-.19,y:.18},{x:-.18,y:.19},{x:-.17,y:.2},{x:-.17,y:.2},{x:-.16,y:.21},{x:-.15,y:.22},{x:-.14,y:.22},{x:-.13,y:.23},{x:-.13,y:.23},{x:-.13,y:.23}],color:"primary",fill:!1},"path8704-1-7":{type:"path",points:[{x:.12,y:-.03},{x:.12,y:-.03},{x:.14,y:-.02},{x:.15,y:-.01},{x:.17,y:0},{x:.18,y:.01},{x:.19,y:.02},{x:.2,y:.03},{x:.2,y:.04},{x:.21,y:.05},{x:.21,y:.06},{x:.22,y:.07},{x:.22,y:.08},{x:.22,y:.09},{x:.22,y:.1},{x:.22,y:.11},{x:.22,y:.12},{x:.22,y:.13},{x:.21,y:.14},{x:.21,y:.15},{x:.2,y:.15},{x:.2,y:.16},{x:.19,y:.17},{x:.19,y:.18},{x:.18,y:.19},{x:.17,y:.2},{x:.17,y:.2},{x:.16,y:.21},{x:.15,y:.21},{x:.14,y:.22},{x:.13,y:.23},{x:.12,y:.23},{x:.12,y:.23}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.02,y:.28}},refblocks:{bottom1:{x:0,y:-.25},left1:{x:-.45,y:.1},right1:{x:.45,y:.1}},bounds:{minX:-.47,maxX:.47,minY:-.28,maxY:.28,width:.95,height:.56,centerX:0,centerY:0},circles:{}},On=e(yt).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_left").build(),Jn=e(yt).rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_top").build(),$n=e(yt).rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_bottom").build(),Mn=e(yt).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_right").build(),Cn={paths:{path1:{type:"path",points:[{x:-.37,y:.03},{x:-.13,y:.03}],color:"primary",fill:!1},"path-1-3":{type:"path",points:[{x:-.07,y:.03},{x:.11,y:-.03}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.1,y:-.06},{x:.37,y:-.06}],color:"primary",fill:!1},path3:{type:"path",points:[{x:.12,y:.17},{x:.37,y:.17}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:0,y:.37},bottom1:{type:"text",text:"{VAL}",x:0,y:-.37}},refblocks:{left1:{x:-.37,y:.03},right1:{x:.37,y:-.06},right2:{x:.37,y:.17}},bounds:{minX:-.4,maxX:.4,minY:-.4,maxY:.4,width:.79,height:.79,centerX:0,centerY:0},circles:{"circle-3":{type:"circle",x:.08,y:-.07,radius:.02,color:"primary",fill:!1},"circle-1":{type:"circle",x:-.1,y:.03,radius:.02,color:"primary",fill:!1},"circle-2":{type:"circle",x:.08,y:.17,radius:.02,color:"primary",fill:!1}}},xt=e(Cn).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right2",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_bottom").build(),Ki=r(xt,"down"),tl=Ki.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),el=Ki.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");tl.anchor="middle_bottom";el.anchor="middle_top";tl.x=.44;tl.y+=.28;el.y-=.28;el.x=.44;Nn=Ki,rl=r(xt,"left"),ol=rl.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),il=rl.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");ol.anchor="middle_bottom";il.anchor="middle_top";ol.x=0;ol.y+=.625;il.y-=.695;il.x=0;In=rl,ll=r(xt,"up"),pl=ll.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),al=ll.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");pl.anchor="middle_bottom";al.anchor="middle_top";pl.x=.4;pl.y+=.28;al.y-=.28;al.x=.4;Bn=ll,qn={paths:{path1:{type:"path",points:[{x:-.37,y:.03},{x:-.13,y:.03}],color:"primary",fill:!1},"path-1-3":{type:"path",points:[{x:-.07,y:.03},{x:.11,y:.14}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.1,y:-.06},{x:.37,y:-.06}],color:"primary",fill:!1},path3:{type:"path",points:[{x:.12,y:.17},{x:.37,y:.17}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:0,y:.4},bottom1:{type:"text",text:"{VAL}",x:0,y:-.4}},refblocks:{left1:{x:-.37,y:.03},right1:{x:.37,y:-.06},right3:{x:.37,y:.17}},bounds:{minX:-.4,maxX:.4,minY:-.4,maxY:.4,width:.79,height:.79,centerX:0,centerY:0},circles:{"circle-3":{type:"circle",x:.08,y:-.07,radius:.02,color:"primary",fill:!1},"circle-1":{type:"circle",x:-.1,y:.03,radius:.02,color:"primary",fill:!1},"circle-2":{type:"circle",x:.08,y:.17,radius:.02,color:"primary",fill:!1}}},st=e(qn).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right3",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_bottom").build(),yl=r(st,"down"),xl=yl.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),sl=yl.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");xl.anchor="middle_bottom";sl.anchor="middle_top";xl.x=.44;xl.y+=.28;sl.y-=.28;sl.x=.44;Dn=yl,ml=r(st,"left"),nl=ml.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),fl=ml.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");nl.anchor="middle_bottom";fl.anchor="middle_top";nl.x=0;nl.y+=.625;fl.y-=.695;fl.x=0;Gn=ml,cl=r(st,"up"),hl=cl.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),dl=cl.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");hl.anchor="middle_bottom";dl.anchor="middle_top";hl.x=.4;hl.y+=.28;dl.y-=.28;dl.x=.4;Un=cl,Lt={paths:{path11:{type:"path",points:[{x:-.38,y:0},{x:-.12,y:-.01}],color:"primary",fill:!1},"path11-0":{type:"path",points:[{x:-.07,y:0},{x:.11,y:.05}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.12,y:-.01},{x:.38,y:0}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:0,y:.31},bottom1:{type:"text",text:"{VAL}",x:0,y:-.28}},refblocks:{left1:{x:-.12,y:-.01},left2:{x:-.38,y:0},right1:{x:.12,y:-.01},right2:{x:.38,y:0}},bounds:{minX:-.4,maxX:.4,minY:-.25,maxY:.25,width:.81,height:.5,centerX:0,centerY:0},circles:{"circle-2":{type:"circle",x:.1,y:0,radius:.02,color:"primary",fill:!1},"circle-1":{type:"circle",x:-.1,y:0,radius:.02,color:"primary",fill:!1}}};delete Lt.refblocks.left1;delete Lt.refblocks.right1;Lt.bounds.width+=.2;mt=e(Lt).changeTextAnchor("{VAL}","middle_top").labelPort("left2",["1"]).labelPort("right2",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),bl=r(mt,"down"),_l=bl.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),gl=bl.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");_l.anchor="middle_bottom";gl.anchor="middle_top";_l.x=.3;_l.y+=.265;gl.y-=.265;gl.x=.3;Wn=bl,ul=r(mt,"left"),vl=ul.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),wl=ul.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");vl.anchor="middle_bottom";wl.anchor="middle_top";vl.x=0;vl.y+=.57;wl.y-=.57;wl.x=0;Hn=ul,Al=r(mt,"up"),Pl=Al.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),Sl=Al.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Pl.anchor="middle_bottom";Sl.anchor="middle_top";Pl.x=.3;Pl.y+=.265;Sl.y-=.265;Sl.x=.3;Zn=Al,Vt={paths:{path11:{type:"path",points:[{x:-.38,y:0},{x:-.12,y:-.01}],color:"primary",fill:!1},"path11-0":{type:"path",points:[{x:-.07,y:.01},{x:.1,y:.14}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.12,y:-.01},{x:.38,y:0}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:0,y:.25},bottom1:{type:"text",text:"{VAL}",x:0,y:-.25}},refblocks:{left1:{x:-.12,y:-.01},left2:{x:-.38,y:0},right1:{x:.12,y:-.01},right2:{x:.38,y:0}},bounds:{minX:-.4,maxX:.4,minY:-.25,maxY:.25,width:.81,height:.5,centerX:0,centerY:0},circles:{"circle-2":{type:"circle",x:.1,y:0,radius:.02,color:"primary",fill:!1},"circle-1":{type:"circle",x:-.1,y:0,radius:.02,color:"primary",fill:!1}}};delete Vt.refblocks.left1;delete Vt.refblocks.right1;Vt.bounds.width+=.2;nt=e(Vt).changeTextAnchor("{VAL}","middle_top").labelPort("left2",["1"]).labelPort("right2",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),Rl=r(nt,"down"),Fl=Rl.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),Tl=Rl.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Fl.anchor="middle_bottom";Tl.anchor="middle_top";Fl.x=.3;Fl.y+=.265;Tl.y-=.265;Tl.x=.3;Qn=Rl,El=r(nt,"left"),Yl=El.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),Xl=El.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Yl.anchor="middle_bottom";Xl.anchor="middle_top";Yl.x=0;Yl.y+=.57;Xl.y-=.57;Xl.x=0;Kn=El,Ll=r(nt,"up"),Vl=Ll.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),jl=Ll.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Vl.anchor="middle_bottom";jl.anchor="middle_top";Vl.x=.3;Vl.y+=.265;jl.y-=.265;jl.x=.3;t1=Ll,ft={paths:{path44:{type:"path",points:[{x:-.16845120000000047,y:.02621170000000017},{x:-.4458008,y:.02709619999999968}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.4458008,y:.026971799999999657},{x:.1677968999999997,y:.027926399999999685}],color:"primary",fill:!1},"path8704-1":{type:"path",points:[{x:-.0040837000000002455,y:-.13467459999999964},{x:-.0040837000000002455,y:-.13467459999999964},{x:-.017668143940740948,y:-.1311205263185182},{x:-.03043520885925943,y:-.12727072121481456},{x:-.04240966440000013,y:-.1231399985999998},{x:-.05361628020740751,y:-.11874317238518502},{x:-.064079825925926,y:-.11409505648148131},{x:-.07382507120000005,y:-.10921046479999987},{x:-.0828767856740741,y:-.10410421125185171},{x:-.0912597389925926,y:-.09879110974814802},{x:-.09899870079999995,y:-.0932859741999998},{x:-.10611844074074069,y:-.08760361851851838},{x:-.11264372845925916,y:-.0817588566148146},{x:-.11859933359999993,y:-.07576650239999982},{x:-.12401002580740728,y:-.06964136978518495},{x:-.12890057472592584,y:-.06339827268148127},{x:-.13329574999999985,y:-.05705202499999972},{x:-.13722032127407394,y:-.05061744065185156},{x:-.14069905819259243,y:-.04410933354814783},{x:-.14375673039999987,y:-.03754251759999966},{x:-.14641810754074058,y:-.030931806718518143},{x:-.1487079592592591,y:-.0242920148148144},{x:-.15065105519999983,y:-.017637955799999563},{x:-.15227216500740723,y:-.01098444358518472},{x:-.15359605832592574,y:-.004346292081480994},{x:-.1546475047999998,y:.00226168480000051},{x:-.15545127407407386,y:.008824673148148676},{x:-.1560321357925924,y:.015327859051852397},{x:-.1564148595999998,y:.02175642860000056},{x:-.1566242151407405,y:.028095567881482052},{x:-.15668497205925902,y:.03433046298518576},{x:-.15662189999999976,y:.04044630000000058},{x:-.15662189999999976,y:.0404463000000006},{x:-.15662189999999976,y:.0404463000000006},{x:-.15622857394444417,y:.04717166472222282},{x:-.1553217675555553,y:.05388046444444503},{x:-.15392183849999977,y:.060558907500000585},{x:-.1520491444444442,y:.0671932022222228},{x:-.1497240430555553,y:.07376955694444502},{x:-.14696689199999974,y:.08027418000000058},{x:-.14379804894444415,y:.0866932797222228},{x:-.1402378715555553,y:.09301306444444506},{x:-.13630671749999965,y:.09921974250000057},{x:-.13202494444444415,y:.10529952222222282},{x:-.12741291005555522,y:.11123861194444501},{x:-.1224909719999997,y:.1170232200000006},{x:-.11727948794444407,y:.12263955472222278},{x:-.11179881555555524,y:.12807382444444504},{x:-.10606931249999965,y:.13331223750000057},{x:-.1001113364444441,y:.13834100222222284},{x:-.09394524505555521,y:.14314632694444504},{x:-.08759139599999967,y:.14771442000000062},{x:-.08107014694444413,y:.15203148972222283},{x:-.07440185555555523,y:.15608374444444503},{x:-.0676068794999997,y:.15985739250000058},{x:-.06070557644444415,y:.16333864222222283},{x:-.05371830405555529,y:.16651370194444504},{x:-.04666541999999976,y:.1693687800000006},{x:-.03956728194444424,y:.1718900847222228},{x:-.03244424755555539,y:.17406382444444501},{x:-.025316674499999876,y:.17587620750000055},{x:-.01820492044444437,y:.17731344222222278},{x:-.01112934305555553,y:.178361736944445},{x:-.004110300000000034,y:.17900730000000054},{x:-.004110300000000011,y:.17900730000000054}],color:"primary",fill:!1},"path8704-1-9":{type:"path",points:[{x:.004158700000000071,y:-.1355885000000001},{x:.004158700000000071,y:-.1355885000000001},{x:.017743143940740766,y:-.1320344263185187},{x:.03051020885925925,y:-.12818462121481505},{x:.042484664399999955,y:-.12405389860000024},{x:.053691280207407335,y:-.11965707238518546},{x:.0641548259259258,y:-.11500895648148178},{x:.07390007119999986,y:-.1101243648000003},{x:.0829517856740739,y:-.10501811125185218},{x:.0913347389925924,y:-.09970500974814848},{x:.09907370079999973,y:-.09419987420000027},{x:.10619344074074046,y:-.08851751851851883},{x:.11271872845925893,y:-.08267275661481507},{x:.11867433359999968,y:-.07668040240000029},{x:.12408502580740703,y:-.0705552697851854},{x:.12897557472592555,y:-.06431217268148172},{x:.13337074999999957,y:-.05796592500000018},{x:.13729532127407365,y:-.05153134065185202},{x:.14077405819259214,y:-.045023233548148286},{x:.14383173039999952,y:-.038456417600000126},{x:.14649310754074024,y:-.03184570671851861},{x:.14878295925925875,y:-.02520591481481487},{x:.1507260551999995,y:-.01855185580000003},{x:.15234716500740686,y:-.011898343585185192},{x:.15367105832592537,y:-.005260192081481464},{x:.15472250479999944,y:.001347784800000043},{x:.1555262740740735,y:.007910773148148207},{x:.156107135792592,y:.01441395905185193},{x:.1564898595999994,y:.020842528600000094},{x:.15669921514074014,y:.02718166788148159},{x:.15675997205925862,y:.03341656298518529},{x:.15669689999999936,y:.03953240000000011},{x:.15669689999999936,y:.039532400000000134},{x:.15669689999999936,y:.039532400000000134},{x:.1563035739444438,y:.04625776472222235},{x:.15539676755555493,y:.05296656444444457},{x:.15399683849999934,y:.05964500750000013},{x:.1521241444444438,y:.06627930222222234},{x:.14979904305555491,y:.07285565694444456},{x:.14704189199999937,y:.07936028000000013},{x:.1438730489444438,y:.08577937972222234},{x:.1403128715555549,y:.09209916444444458},{x:.13638171749999925,y:.0983058425000001},{x:.13209994444444376,y:.10438562222222235},{x:.12748791005555482,y:.11032471194444453},{x:.12256597199999929,y:.11610932000000013},{x:.1173544879444437,y:.1217256547222223},{x:.11187381555555485,y:.12715992444444457},{x:.10614431249999925,y:.1323983375000001},{x:.10018633644444369,y:.13742710222222235},{x:.09402024505555481,y:.14223242694444457},{x:.08766639599999927,y:.14680052000000016},{x:.08114514694444372,y:.15111758972222236},{x:.07447685555555483,y:.15516984444444457},{x:.06768187949999929,y:.15894349250000012},{x:.06078057644444377,y:.16242474222222236},{x:.053793304055554894,y:.16559980194444457},{x:.046740419999999366,y:.16845488000000014},{x:.039642281944443844,y:.17097618472222234},{x:.03251924755555499,y:.17314992444444455},{x:.02539167449999948,y:.17496230750000008},{x:.018279920444443973,y:.17639954222222232},{x:.011204343055555134,y:.17744783694444452},{x:.004185299999999637,y:.17809340000000007},{x:.004185299999999614,y:.17809340000000007}],color:"primary",fill:!1},path4:{type:"path",points:[{x:-.08039130000000005,y:.0179576999999993},{x:-.08039130000000005,y:.09650599999999931}],color:"primary",fill:!0},"path4-5":{type:"path",points:[{x:.01494479999999987,y:-.055216500000000224},{x:.01494479999999987,y:.09691909999999937}],color:"primary",fill:!0},"path4-5-8":{type:"path",points:[{x:.06871169999999927,y:-.056870000000000864},{x:.06871169999999927,y:.018784499999999538}],color:"primary",fill:!0},"path4-1":{type:"path",points:[{x:-.08179359999999969,y:.09650570000000003},{x:.015771699999999722,y:.09650570000000003}],color:"primary",fill:!0},"path4-1-6":{type:"path",points:[{x:.0117995999999998,y:-.05594970000000088},{x:.06843709999999925,y:-.05594970000000088}],color:"primary",fill:!0},"rect1577-4":{type:"path",points:[{x:-.17162450000000073,y:.11125030000000025},{x:-.2688274000000015,y:.11125030000000025},{x:-.2688274000000015,y:.11469129999999961},{x:-.17162450000000073,y:.11469129999999961}],color:"primary",fill:!0},"rect1577-4-7":{type:"path",points:[{x:-.2184661999999995,y:.16159429999999997},{x:-.2184661999999995,y:.06439139999999943},{x:-.22190719999999908,y:.06439139999999943},{x:-.22190719999999908,y:.16159429999999997}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:-.0024445000000006267,y:.23933980000000044},bottom1:{type:"text",text:"{VAL}",x:.00341719999999901,y:-.23933980000000066}},refblocks:{left1:{x:-.4458008,y:.02709619999999968},right1:{x:.4458008,y:.026971799999999657}},bounds:{minX:-.473959241,maxX:.473959241,minY:-.23933980000000066,maxY:.23933980000000044,width:.947918482,height:.4786796000000011,centerX:0,centerY:-11102230246251565e-32},circles:{}},e1=e(ft).rotateRightFacingSymbol("down").labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{REF}","middle_left",{x:.02,y:.2}).changeTextAnchor("{VAL}","middle_left",{x:.5,y:-.2}).build(),r1=e(ft).rotateRightFacingSymbol("left").labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{REF}","middle_bottom",{x:0,y:.45}).changeTextAnchor("{VAL}","middle_top",{x:0,y:-.55}).build(),o1=e(ft).rotateRightFacingSymbol("right").labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),i1=e(ft).rotateRightFacingSymbol("up").labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{VAL}","middle_left",{x:.02,y:-.2}).changeTextAnchor("{REF}","middle_left",{x:.5,y:.2}).build(),kl={paths:{path40:{type:"path",points:[{x:.14,y:.04},{x:-.12,y:-.09}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.12,y:.18},{x:.14,y:.04}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.12,y:-.09},{x:-.12,y:.18}],color:"primary",fill:!1},path43:{type:"path",points:[{x:.14,y:.18},{x:.14,y:-.09}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.12,y:.04},{x:-.52,y:.04}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.52,y:.04},{x:.15,y:.04}],color:"primary",fill:!1},"path43-5":{type:"path",points:[{x:.19,y:-.09},{x:.15,y:-.09}],color:"primary",fill:!1},"path43-5-2":{type:"path",points:[{x:.19,y:-.14},{x:.19,y:-.09}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.01,y:.27},bottom1:{type:"text",text:"{VAL}",x:0,y:-.27}},refblocks:{left1:{x:-.52,y:.04},right1:{x:.52,y:.04}},bounds:{minX:-.55,maxX:.55,minY:-.27,maxY:.27,width:1.09,height:.55,centerX:0,centerY:0},circles:{}},{paths:MX,texts:CX,bounds:NX,refblocks:IX,circles:BX}=kl,U0=e(kl).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),l1=r(U0),p1={paths:{path11:{type:"path",points:[{x:-.54,y:0},{x:-.3,y:0}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:0},{x:.54,y:0}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.18,y:-.36},bottom1:{type:"text",text:"{VAL}",x:-.01,y:.43},left1:{type:"text",text:"RPM",x:0,y:-.02}},refblocks:{left1:{x:-.54,y:0},right1:{x:.54,y:0}},bounds:{minX:-.53,maxX:.53,minY:0,maxY:0,width:1.06,height:1,centerX:0,centerY:0},circles:{path1:{type:"circle",x:-.01,y:-.01,radius:.29,color:"primary",fill:!1}}},{paths:I9,texts:B9,bounds:W0,refblocks:a1,circles:q9}=p1,jt=s({primitives:[...Object.values(I9),...Object.values(q9),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"},{...B9.left1,y:.01,anchor:"center",fontSize:.2}],ports:[{...a1.left1,labels:["1"]},{...a1.right1,labels:["2"]}],size:{width:W0.width,height:W0.height},center:{x:W0.centerX,y:W0.centerY}}),{5:D9,...G9}=jt.primitives;y1=r({...jt,primitives:Object.values(G9).filter(U9)}),x1={...y1,primitives:[...y1.primitives,D9]},ct=s({primitives:[{type:"path",points:[{x:-.2,y:0},{x:0,y:0}],color:"primary",fill:!1},{type:"path",points:Array.from({length:8},(t5,o4)=>{let i3=Math.PI/2-o4*Math.PI/7,l2=.1;return{x:.1-l2*Math.cos(i3),y:l2*Math.sin(i3)}}),color:"primary",fill:!1},{type:"text",text:"{REF}",x:.125,y:0,anchor:"middle_left"}],ports:[{x:-.2,y:0,labels:["1"]}],center:{x:0,y:0}}),m1=r(ct,"down"),s1=m1.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}");s1&&(s1.anchor="middle_top");n1=m1,f1=r(ct,"left"),h1=r(ct,"up"),c1=h1.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}");c1&&(c1.anchor="middle_bottom");d1=h1,b1={paths:{path40:{type:"path",points:[{x:.44,y:.04},{x:.19,y:-.09}],color:"primary",fill:!1},path41:{type:"path",points:[{x:.19,y:.18},{x:.44,y:.04}],color:"primary",fill:!1},path42:{type:"path",points:[{x:.19,y:-.09},{x:.19,y:.18}],color:"primary",fill:!1},path44:{type:"path",points:[{x:.19,y:.04},{x:-.11,y:.04}],color:"primary",fill:!1},path45:{type:"path",points:[{x:-.43,y:.22},{x:-.11,y:.04}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.01,y:.27},bottom1:{type:"text",text:"{VAL}",x:0,y:-.27}},refblocks:{right1:{x:-.43,y:.22}},bounds:{minX:-.55,maxX:.55,minY:-.27,maxY:.27,width:1.09,height:.55,centerX:0,centerY:0},circles:{}},wt=e(b1).labelPort("right1",["1"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),zl=r(wt,"up"),Ol=zl.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),Jl=zl.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Ol.anchor="middle_bottom";Jl.anchor="middle_top";Ol.x=.4;Ol.y+=.2;Jl.y-=.3;Jl.x=.4;H0=zl,$l=v(H0),Ml=$l.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),Cl=$l.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Ml.anchor="middle_bottom";Cl.anchor="middle_top";Ml.x=.35;Ml.y+=.4;Cl.y-=.4;Cl.x=.35;_1=$l,Nl=r(wt,"left"),Il=Nl.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),Bl=Nl.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Il.anchor="middle_bottom";Bl.anchor="middle_top";Il.x=0;Il.y+=.5;Bl.y-=.6;Bl.x=0;g1=Nl,ql={paths:{path11:{type:"path",points:[{x:-.54,y:.04},{x:-.11,y:.04}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.1,y:.04},{x:.54,y:.04}],color:"primary",fill:!1},"path11-0":{type:"path",points:[{x:-.09,y:-.15},{x:-.09,y:.26}],color:"primary",fill:!1},"path11-0-3":{type:"path",points:[{x:.09,y:-.15},{x:.09,y:.26}],color:"primary",fill:!1},"path11-0-9":{type:"path",points:[{x:-.08,y:.06},{x:-.08,y:-.15},{x:.09,y:-.05},{x:-.08,y:.06}],color:"primary",fill:!0},"path11-0-9-0":{type:"path",points:[{x:.08,y:.26},{x:.08,y:.05},{x:-.09,y:.15},{x:.07,y:.26}],color:"primary",fill:!0},"path12-2":{type:"path",points:[{x:.09,y:-.06},{x:.27,y:-.17}],color:"primary",fill:!1},"path12-2-9":{type:"path",points:[{x:.27,y:-.18},{x:.27,y:-.31}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:.01,y:.42},bottom1:{type:"text",text:"{VAL}",x:-.03,y:-.42}},refblocks:{bottom1:{x:.27,y:-.31},left1:{x:-.54,y:.04},right1:{x:.54,y:.04}},bounds:{minX:-.57,maxX:.57,minY:-.42,maxY:.42,width:1.14,height:.83,centerX:0,centerY:0},circles:{path1:{type:"circle",x:0,y:.05,radius:.29,color:"primary",fill:!1}}},{paths:EL,texts:YL,bounds:XL,refblocks:LL,circles:VL}=ql,Z0=e(ql).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).labelPort("bottom1",["3"]).changeTextAnchor("{REF}","middle_bottom").build(),u1=r(Z0),v1=u1.primitives.filter(t5=>t5.type==="text"),Z9=v1.find(t5=>t5.text==="{REF}"),Q9=v1.find(t5=>t5.text==="{VAL}");Z9.y=0;Q9.y=0;w1=u1,A1={paths:{path40:{type:"path",points:[{x:.14,y:.04},{x:-.12,y:-.09}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.12,y:.18},{x:.14,y:.04}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.12,y:-.09},{x:-.12,y:.18}],color:"primary",fill:!1},path43:{type:"path",points:[{x:.14,y:.18},{x:.14,y:-.09}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.12,y:.04},{x:-.52,y:.04}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.52,y:.04},{x:.15,y:.04}],color:"primary",fill:!1},"path43-8":{type:"path",points:[{x:.14,y:.18},{x:.08,y:.18}],color:"primary",fill:!1},"path43-8-8":{type:"path",points:[{x:.14,y:-.09},{x:.08,y:-.09}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.01,y:.27},bottom1:{type:"text",text:"{VAL}",x:0,y:-.27}},refblocks:{left1:{x:-.52,y:.04},right1:{x:.52,y:.04}},bounds:{minX:-.55,maxX:.55,minY:-.27,maxY:.27,width:1.09,height:.55,centerX:0,centerY:0},circles:{}},{paths:tb,texts:P1,bounds:Q0,refblocks:S1,circles:eb}=A1,K0=s({primitives:[...Object.values(tb),...Object.values(eb),{...P1.top1,anchor:"middle_bottom"},{...P1.bottom1,anchor:"middle_top"}],ports:[{...S1.left1,labels:["1"]},{...S1.right1,labels:["2"]}],size:{width:Q0.width,height:Q0.height},center:{x:Q0.centerX,y:Q0.centerY}}),Dl=r(K0),rb=Dl.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),ob=Dl.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");rb.anchor="middle_left";ob.anchor="middle_right";R1=Dl,F1={paths:{path11:{type:"path",points:[{x:-.34,y:.22},{x:-.02,y:.01}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.23,y:.13},{x:.23,y:.4}],color:"primary",fill:!1},"path12-2":{type:"path",points:[{x:.23,y:-.08},{x:.23,y:-.35}],color:"primary",fill:!1},"path11-0":{type:"path",points:[{x:-.01,y:-.18},{x:-.01,y:.23}],color:"primary",fill:!1},"path11-0-3":{type:"path",points:[{x:.23,y:.12},{x:-.01,y:.12}],color:"primary",fill:!1},"path11-0-9":{type:"path",points:[{x:-.11,y:.13},{x:-.17,y:.04},{x:-.06,y:.03},{x:-.11,y:.13}],color:"primary",fill:!0},"path11-0-3-8":{type:"path",points:[{x:.23,y:-.08},{x:-.01,y:-.08}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.2,y:.39},bottom1:{type:"text",text:"{VAL}",x:-.03,y:-.42}},refblocks:{top1:{x:.23,y:.4},bottom1:{x:.23,y:-.35},left1:{x:-.34,y:.22}},bounds:{minX:-.37,maxX:.37,minY:-.42,maxY:.42,width:.74,height:.85,centerX:0,centerY:0},circles:{path1:{type:"circle",x:.08,y:.01,radius:.29,color:"primary",fill:!1}}},{paths:lb,texts:T1,bounds:tr,refblocks:Gl,circles:pb}=F1,er=s({primitives:[...Object.values(lb),...Object.values(pb),{...T1.top1,anchor:"middle_left"},{...T1.bottom1,anchor:"middle_right"}],ports:[{...Gl.top1,labels:["1"]},{...Gl.bottom1,labels:["2"]},{...Gl.left1,labels:["3"]}],size:{width:tr.width,height:tr.height},center:{x:tr.centerX,y:tr.centerY}}),E1=r(er),Y1=E1.primitives.filter(t5=>t5.type==="text"),ab=Y1.find(t5=>t5.text==="{REF}");ab.y=.1;X1=Y1.find(t5=>t5.text==="{VAL}");X1.y=.1;X1.x=-.4;L1=E1,V1={paths:{capsule_outer:{type:"path",points:[{x:-.44,y:.34},{x:-.45,y:.39},{x:-.46,y:.42},{x:-.49,y:.44},{x:-.52,y:.46},{x:-.56,y:.46},{x:-.6,y:.46},{x:-.63,y:.44},{x:-.65,y:.42},{x:-.67,y:.39},{x:-.68,y:.34},{x:-.68,y:-.34},{x:-.67,y:-.39},{x:-.65,y:-.42},{x:-.63,y:-.44},{x:-.6,y:-.45},{x:-.56,y:-.46},{x:-.52,y:-.45},{x:-.49,y:-.44},{x:-.46,y:-.42},{x:-.45,y:-.39},{x:-.44,y:-.34},{x:-.44,y:.34}],color:"primary",fill:!1},capsule_inner:{type:"path",points:[{x:-.51,y:.28},{x:-.52,y:.32},{x:-.53,y:.34},{x:-.56,y:.35},{x:-.57,y:.35},{x:-.58,y:.34},{x:-.6,y:.32},{x:-.61,y:.28},{x:-.61,y:-.28},{x:-.6,y:-.32},{x:-.58,y:-.34},{x:-.57,y:-.35},{x:-.56,y:-.35},{x:-.53,y:-.34},{x:-.52,y:-.32},{x:-.51,y:-.28},{x:-.51,y:.28}],color:"primary",fill:!0},usb_vertical:{type:"path",points:[{x:.1,y:-.4},{x:.1,y:.4}],color:"primary",fill:!1},usb_left_branch:{type:"path",points:[{x:.1,y:-.1},{x:-.03,y:.05},{x:-.03,y:.15}],color:"primary",fill:!1},usb_right_branch:{type:"path",points:[{x:.1,y:0},{x:.25,y:.15},{x:.25,y:.25}],color:"primary",fill:!1},usb_arrow:{type:"path",points:[{x:.05,y:.4},{x:.1,y:.5},{x:.15,y:.4},{x:.05,y:.4}],color:"primary",fill:!0},usb_square:{type:"path",points:[{x:.2,y:.25},{x:.3,y:.25},{x:.3,y:.35},{x:.2,y:.35},{x:.2,y:.25}],color:"primary",fill:!0}},circles:{usb_base:{type:"circle",x:.1,y:-.4,radius:.07,color:"primary",fill:!0},usb_tip_circle:{type:"circle",x:-.03,y:.15,radius:.04,color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:-.25,y:.7}},refblocks:{},bounds:{minX:-.75,maxX:.35,minY:-.6,maxY:.75,width:1.1,height:1.35,centerX:-.2,centerY:.08}},j1=e(V1).changeTextAnchor("{REF}","middle_bottom").build(),k1={paths:{path11:{type:"path",points:[{x:-.54,y:0},{x:-.3,y:0}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:0},{x:.54,y:0}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.18,y:-.36},bottom1:{type:"text",text:"{VAL}",x:-.01,y:.43},left1:{type:"text",text:"Var",x:-.19,y:.07}},refblocks:{left1:{x:-.54,y:0},right1:{x:.54,y:0}},bounds:{minX:-.53,maxX:.53,minY:0,maxY:0,width:1.06,height:1,centerX:0,centerY:0},circles:{path1:{type:"circle",x:-.01,y:-.01,radius:.29,color:"primary",fill:!1}}},{paths:sb,texts:Ul,bounds:rr,refblocks:z1,circles:mb}=k1,or=s({primitives:[...Object.values(sb),...Object.values(mb),{...Ul.top1,x:0,y:-.3594553499999995,anchor:"middle_top"},{...Ul.bottom1,x:0,y:.35,anchor:"middle_bottom"},{...Ul.left1,x:-.02,y:.01,fontSize:.2,anchor:"center"}],ports:[{...z1.left1,labels:["1"]},{...z1.right1,labels:["2"]}],size:{width:rr.width,height:rr.height},center:{x:rr.centerX,y:rr.centerY}}),O1=r(or),J1={paths:{path40:{type:"path",points:[{x:.08,y:.04},{x:-.18,y:-.09}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.18,y:.18},{x:.08,y:.04}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.18,y:-.09},{x:-.18,y:.18}],color:"primary",fill:!1},path43:{type:"path",points:[{x:.09,y:.17},{x:.1,y:-.09}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.2,y:.04},{x:-.52,y:.04}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.52,y:.04},{x:.21,y:.04}],color:"primary",fill:!1},"path43-6":{type:"path",points:[{x:.19,y:.17},{x:.19,y:-.09}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.01,y:.27},bottom1:{type:"text",text:"{VAL}",x:0,y:-.27}},refblocks:{left1:{x:-.52,y:.04},right1:{x:.52,y:.04}},bounds:{minX:-.55,maxX:.55,minY:-.27,maxY:.27,width:1.09,height:.55,centerX:0,centerY:0},circles:{}},{paths:fb,texts:$1,bounds:ir,refblocks:M1,circles:cb}=J1,lr=s({primitives:[...Object.values(fb),...Object.values(cb),{...$1.top1,anchor:"middle_bottom"},{...$1.bottom1,anchor:"middle_top"}],ports:[{...M1.left1,labels:["1"]},{...M1.right1,labels:["2"]}],size:{width:ir.width,height:ir.height},center:{x:ir.centerX,y:ir.centerY}}),Wl=r(lr),hb=Wl.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),db=Wl.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");hb.anchor="middle_left";db.anchor="middle_right";C1=Wl,N1={paths:{path5:{type:"path",points:[{x:-.54,y:0},{x:-.26,y:0}],color:"primary",fill:!1},path6:{type:"path",points:[{x:.27,y:0},{x:.54,y:.01}],color:"primary",fill:!1},path7:{type:"path",points:[{x:.27,y:-.23},{x:-.26,y:.24}],color:"primary",fill:!1},path8:{type:"path",points:[{x:.38,y:-.23},{x:.27,y:-.23}],color:"primary",fill:!1},path9:{type:"path",points:[{x:0,y:.14},{x:.27,y:.14},{x:.27,y:-.13},{x:-.26,y:-.13},{x:-.26,y:.14},{x:0,y:.14}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.06,y:.25},bottom1:{type:"text",text:"{VAL}",x:.01,y:-.25}},refblocks:{left1:{x:-.54,y:0},right1:{x:.54,y:.01}},bounds:{minX:-.57,maxX:.57,minY:-.25,maxY:.25,width:1.13,height:.5,centerX:0,centerY:0},circles:{}},{paths:_b,texts:I1,bounds:pr,refblocks:B1}=N1,ar=s({primitives:[...Object.values(_b),{...I1.top1,anchor:"middle_left"},{...I1.bottom1,anchor:"middle_right"}],ports:[{...B1.left1,labels:["1","-"]},{...B1.right1,labels:["2","+"]}],size:{width:pr.width,height:pr.height},center:{x:pr.centerX,y:pr.centerY}}),q1=r(ar),D1={paths:{path11:{type:"path",points:[{x:-.54,y:0},{x:-.3,y:0}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:0},{x:.54,y:0}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.18,y:-.36},bottom1:{type:"text",text:"{VAL}",x:-.01,y:.43},left1:{type:"text",text:"Var",x:0,y:-.02}},refblocks:{left1:{x:-.54,y:0},right1:{x:.54,y:0}},bounds:{minX:-.53,maxX:.53,minY:0,maxY:0,width:1.06,height:1,centerX:0,centerY:0},circles:{path1:{type:"circle",x:-.01,y:-.01,radius:.29,color:"primary",fill:!1}}},{paths:ub,texts:vb,bounds:yr,refblocks:G1,circles:wb}=D1,kt=s({primitives:[...Object.values(ub),...Object.values(wb),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"},{...vb.left1,anchor:"center",y:.02,fontSize:.2}],ports:[{...G1.left1,labels:["1"]},{...G1.right1,labels:["2"]}],size:{width:yr.width,height:yr.height},center:{x:yr.centerX,y:yr.centerY}}),{5:Ab,...Pb}=kt.primitives;U1=r({...kt,primitives:Object.values(Pb).filter(Sb)}),W1={...U1,primitives:[...U1.primitives,Ab]},ht={paths:{"path28-2":{type:"path",points:[{x:.19,y:0},{x:0,y:.09}],color:"primary",fill:!1},"path28-2-6":{type:"path",points:[{x:.19,y:0},{x:0,y:-.09}],color:"primary",fill:!1},"path29-3":{type:"path",points:[{x:.19,y:0},{x:-.23,y:0}],color:"primary",fill:!1}},texts:{right1:{type:"text",text:"{REF}",x:.25,y:0}},refblocks:{left1:{x:-.23,y:0}},bounds:{minX:-.25,maxX:.25,minY:-.09,maxY:.09,width:.5,height:.19,centerX:0,centerY:0},circles:{}};Fb=e(ht).rotateRightFacingSymbol("down").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_top").build(),H1=X(Fb,{width:.24,height:.23}),Tb=e(ht).rotateRightFacingSymbol("left").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_right").build(),Z1=X(Tb,{width:.23,height:.24}),Eb=e(ht).rotateRightFacingSymbol("right").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_left").build(),Q1=X(Eb,{width:.23,height:.24}),Yb=e(ht).rotateRightFacingSymbol("up").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_bottom").build(),K1=X(Yb,{width:.24,height:.23}),Hl={paths:{path11:{type:"path",points:[{x:-.54,y:.03},{x:-.3,y:.03}],color:"primary",fill:!1},"path11-5-5":{type:"path",points:[{x:.1,y:.13},{x:0,y:-.06},{x:-.11,y:.13}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:.03},{x:.54,y:.03}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.02,y:.4},bottom1:{type:"text",text:"{VAL}",x:-.01,y:-.4}},refblocks:{left1:{x:-.54,y:.03},right1:{x:.54,y:.03}},bounds:{minX:-.57,maxX:.57,minY:-.4,maxY:.4,width:1.14,height:.8,centerX:0,centerY:0},circles:{path1:{type:"circle",x:0,y:.04,radius:.29,color:"primary",fill:!1}}},{paths:ZV,texts:QV,bounds:KV,circles:tj,refblocks:ej}=Hl,xr=e(Hl).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),tf=r(xr),ef={paths:{path11:{type:"path",points:[{x:-.54,y:0},{x:-.3,y:0}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:0},{x:.54,y:0}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.18,y:-.36},bottom1:{type:"text",text:"{VAL}",x:-.01,y:.43},left1:{type:"text",text:"Wh",x:0,y:-.02}},refblocks:{left1:{x:-.54,y:0},right1:{x:.54,y:0}},bounds:{minX:-.53,maxX:.53,minY:0,maxY:0,width:1.06,height:1,centerX:0,centerY:0},circles:{path1:{type:"circle",x:-.01,y:-.01,radius:.29,color:"primary",fill:!1}}},{paths:Vb,texts:jb,bounds:sr,refblocks:rf,circles:kb}=ef,zt=s({primitives:[...Object.values(Vb),...Object.values(kb),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"},{...jb.left1,anchor:"center",y:.01,fontSize:.2}],ports:[{...rf.left1,labels:["1"]},{...rf.right1,labels:["2"]}],size:{width:sr.width,height:sr.height},center:{x:sr.centerX,y:sr.centerY}}),{5:zb,...Ob}=zt.primitives;of=r({...zt,primitives:Object.values(Ob).filter(Jb)}),lf={...of,primitives:[...of.primitives,zb]},pf={paths:{path11:{type:"path",points:[{x:-.54,y:0},{x:-.3,y:0}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:0},{x:.54,y:0}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.18,y:-.36},bottom1:{type:"text",text:"{VAL}",x:-.01,y:.43},left1:{type:"text",text:"W",x:0,y:-.02}},refblocks:{left1:{x:-.54,y:0},right1:{x:.54,y:0}},bounds:{minX:-.53,maxX:.53,minY:0,maxY:0,width:1.06,height:1,centerX:0,centerY:0},circles:{path1:{type:"circle",x:-.01,y:-.01,radius:.29,color:"primary",fill:!1}}},{paths:Mb,texts:Cb,bounds:mr,refblocks:af,circles:Nb}=pf,Ot=s({primitives:[...Object.values(Mb),...Object.values(Nb),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"},{...Cb.left1,anchor:"center",y:.01,fontSize:.3}],ports:[{...af.left1,labels:["1"]},{...af.right1,labels:["2"]}],size:{width:mr.width,height:mr.height},center:{x:mr.centerX,y:mr.centerY}}),{5:Ib,...Bb}=Ot.primitives;yf=r({...Ot,primitives:Object.values(Bb).filter(qb)}),xf={...yf,primitives:[...yf.primitives,Ib]},sf={paths:{path40:{type:"path",points:[{x:.14,y:.04},{x:-.12,y:-.09}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.12,y:.18},{x:.14,y:.04}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.12,y:-.09},{x:-.12,y:.18}],color:"primary",fill:!1},path43:{type:"path",points:[{x:.14,y:.18},{x:.14,y:-.09}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.12,y:.04},{x:-.52,y:.04}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.52,y:.04},{x:.15,y:.04}],color:"primary",fill:!1},"path43-8":{type:"path",points:[{x:.14,y:.18},{x:.08,y:.18}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.01,y:.27},bottom1:{type:"text",text:"{VAL}",x:0,y:-.27}},refblocks:{left1:{x:-.52,y:.04},right1:{x:.52,y:.04}},bounds:{minX:-.55,maxX:.55,minY:-.27,maxY:.27,width:1.09,height:.55,centerX:0,centerY:0},circles:{}},{paths:Gb,texts:mf,bounds:nr,refblocks:nf,circles:Ub}=sf,fr=s({primitives:[...Object.values(Gb),...Object.values(Ub),{...mf.top1,anchor:"middle_bottom"},{...mf.bottom1,anchor:"middle_top"}],ports:[{...nf.left1,labels:["1"]},{...nf.right1,labels:["2"]}],size:{width:nr.width,height:nr.height},center:{x:nr.centerX,y:nr.centerY}}),Zl=r(fr),Wb=Zl.primitives.find(t5=>t5.type==="text"&&t5.text==="{REF}"),Hb=Zl.primitives.find(t5=>t5.type==="text"&&t5.text==="{VAL}");Wb.anchor="middle_left";Hb.anchor="middle_right";ff=Zl,cf={ac_voltmeter_down:op,ac_voltmeter_horz:lp,ac_voltmeter_left:ap,ac_voltmeter_right:xp,ac_voltmeter_up:mp,ac_voltmeter_vert:fp2,avalanche_diode_down:hp,avalanche_diode_horz:dp,avalanche_diode_left:_p,avalanche_diode_right:gp,avalanche_diode_up:vp,avalanche_diode_vert:Ap,backward_diode_down:Sp,backward_diode_left:Qt,backward_diode_right:Tp,backward_diode_up:Ep,battery_horz:ee,battery_vert:Vp,boxresistor_down:zp,boxresistor_left:$p,boxresistor_right:Np,boxresistor_small_down:Bp,boxresistor_small_left:Dp,boxresistor_small_right:Up,boxresistor_small_up:Hp,boxresistor_up:Kp,bridged_ground_down:ra,bridged_ground_left:la,bridged_ground_right:pe,bridged_ground_up:ya,capacitor_down:sa,capacitor_left:ma,capacitor_polarized_down:fa,capacitor_polarized_left:ca,capacitor_polarized_right:da,capacitor_polarized_up:_a,capacitor_right:ga,capacitor_up:va,constant_current_diode_down:Aa,constant_current_diode_horz:Pa,constant_current_diode_left:Ra,constant_current_diode_right:Fa,constant_current_diode_up:Ea,constant_current_diode_vert:Xa,crystal_4pin_down:La,crystal_4pin_left:Va,crystal_4pin_right:ja,crystal_4pin_up:ka,crystal_down:Oa,crystal_left:Ja,crystal_right:$a,crystal_up:Ca,current_source_down:Na,current_source_left:Ia,current_source_right:Ba,current_source_up:qa,darlington_pair_transistor_down:Da,darlington_pair_transistor_horz:Ga,darlington_pair_transistor_left:Ua,darlington_pair_transistor_right:Wa,darlington_pair_transistor_up:Ha,darlington_pair_transistor_vert:Za,dc_ammeter_horz:Tt,dc_ammeter_vert:ey,dc_voltmeter_down:oy,dc_voltmeter_horz:ly,dc_voltmeter_left:ay,dc_voltmeter_right:xy,dc_voltmeter_up:my,dc_voltmeter_vert:fy,diac_down:cy,diac_horz:hy,diac_left:dy,diac_right:by,diac_up:_y,diac_vert:gy,digital_ground_down:vy,digital_ground_left:Ay,digital_ground_right:Sy,digital_ground_up:Fy,diode_down:Ey,diode_left:Yy,diode_right:C,diode_up:Xy,dpdt_normally_closed_switch_down:Vy,dpdt_normally_closed_switch_left:jy,dpdt_normally_closed_switch_right:N,dpdt_normally_closed_switch_up:ky,dpdt_switch_down:Oy,dpdt_switch_left:Jy,dpdt_switch_right:I,dpdt_switch_up:$y,dpst_normally_closed_switch_down:Cy,dpst_normally_closed_switch_left:Ny,dpst_normally_closed_switch_right:B,dpst_normally_closed_switch_up:Iy,dpst_switch_down:qy,dpst_switch_left:Dy,dpst_switch_right:q,dpst_switch_up:Gy,ferrite_bead_down:Wy,ferrite_bead_left:Hy,ferrite_bead_right:Le,ferrite_bead_up:Xe,filled_diode_down:Qy,filled_diode_horz:tx,filled_diode_left:rx,filled_diode_right:ix,filled_diode_up:px,filled_diode_vert:yx,frequency_meter_horz:Et,frequency_meter_vert:nx,fuse_horz:Ce,fuse_vert:hx,ground_down:dx,ground_horz:bx,ground_left:_x,ground_right:gx,ground_up:ux,ground_vert:vx,gunn_diode_horz:wx,gunn_diode_vert:Ax,icled_down:Sx,icled_left:Rx,icled_right:D,icled_up:Fx,igbt_transistor_horz:Ne,igbt_transistor_vert:Yx,illuminated_push_button_normally_open_horz:Ie,illuminated_push_button_normally_open_vert:jx,inductor_down:Jx,inductor_left:$x,inductor_right:ut,inductor_up:qe,laser_diode_down:Mx,laser_diode_left:Cx,laser_diode_right:G,laser_diode_up:Nx,led_down:Dx,led_left:Gx,led_right:vt,led_up:Ge,light_dependent_resistor_horz:We,light_dependent_resistor_vert:Kx,mosfet_depletion_normally_on_horz:Ze,mosfet_depletion_normally_on_vert:os,mushroom_head_normally_open_momentary_horz:Ke,mushroom_head_normally_open_momentary_vert:as,n_channel_d_mosfet_transistor_horz:r0,n_channel_d_mosfet_transistor_vert:ns,n_channel_e_mosfet_transistor_horz:i0,n_channel_e_mosfet_transistor_vert:bs,njfet_transistor_horz:p0,njfet_transistor_vert:ws,not_connected_down:Ss,not_connected_left:Rs,not_connected_right:U,not_connected_up:Fs,npn_bipolar_transistor_down:Ts,npn_bipolar_transistor_horz:Es,npn_bipolar_transistor_left:Ys,npn_bipolar_transistor_right:Xs,npn_bipolar_transistor_up:Ls,npn_bipolar_transistor_vert:Vs,opamp_no_power_down:ks,opamp_no_power_left:zs,opamp_no_power_right:W,opamp_no_power_up:Os,opamp_with_power_down:$s,opamp_with_power_left:Ms,opamp_with_power_right:H,opamp_with_power_up:Cs,p_channel_d_mosfet_transistor_horz:f0,p_channel_d_mosfet_transistor_vert:Ds,p_channel_e_mosfet_transistor_horz:h0,p_channel_e_mosfet_transistor_vert:Zs,photodiode_horz:d0,photodiode_vert:em,pjfet_transistor_horz:_0,pjfet_transistor_vert:pm,pnp_bipolar_transistor_down:am,pnp_bipolar_transistor_horz:ym,pnp_bipolar_transistor_left:xm,pnp_bipolar_transistor_right:sm,pnp_bipolar_transistor_up:mm2,pnp_bipolar_transistor_vert:nm,potentiometer_horz:S0,potentiometer_vert:dm,potentiometer2_down:um,potentiometer2_left:vm,potentiometer2_right:Z,potentiometer2_up:wm,potentiometer3_down:Am,potentiometer3_left:Pm,potentiometer3_right:Sm,potentiometer3_up:Rm,power_factor_meter_horz:X0,power_factor_meter_vert:Ym,push_button_normally_closed_momentary_horz:V0,push_button_normally_closed_momentary_vert:jm,push_button_normally_open_momentary_horz:k0,push_button_normally_open_momentary_vert:Jm,rail_down:Mm,rail_left:Nm,rail_right:Bm,rail_up:Dm,rectifier_diode_horz:J0,rectifier_diode_vert:Wm,resistor_down:Zm,resistor_left:Km,resistor_right:en,resistor_up:on,resonator_down:pn,resonator_horz:D0,resonator_left:an,resonator_right:et,resonator_up:yn,resonator_vert:xn,schottky_diode_down:mn,schottky_diode_left:nn,schottky_diode_right:rt,schottky_diode_up:fn,silicon_controlled_rectifier_horz:G0,silicon_controlled_rectifier_vert:dn,solderjumper2_bridged12_down:bn,solderjumper2_bridged12_left:_n,solderjumper2_bridged12_right:gn,solderjumper2_bridged12_up:un,solderjumper2_down:vn,solderjumper2_left:wn,solderjumper2_right:An,solderjumper2_up:Pn,solderjumper3_bridged12_down:Sn,solderjumper3_bridged12_left:Rn,solderjumper3_bridged12_right:Fn,solderjumper3_bridged12_up:Tn,solderjumper3_bridged123_down:En,solderjumper3_bridged123_left:Yn,solderjumper3_bridged123_right:Xn,solderjumper3_bridged123_up:Ln,solderjumper3_bridged23_down:Vn,solderjumper3_bridged23_left:jn,solderjumper3_bridged23_right:kn,solderjumper3_bridged23_up:zn,solderjumper3_down:On,solderjumper3_left:Jn,solderjumper3_right:$n,solderjumper3_up:Mn,spdt_normally_closed_switch_down:Nn,spdt_normally_closed_switch_left:In,spdt_normally_closed_switch_right:xt,spdt_normally_closed_switch_up:Bn,spdt_switch_down:Dn,spdt_switch_left:Gn,spdt_switch_right:st,spdt_switch_up:Un,spst_normally_closed_switch_down:Wn,spst_normally_closed_switch_left:Hn,spst_normally_closed_switch_right:mt,spst_normally_closed_switch_up:Zn,spst_switch_down:Qn,spst_switch_left:Kn,spst_switch_right:nt,spst_switch_up:t1,square_wave_down:e1,square_wave_left:r1,square_wave_right:o1,square_wave_up:i1,step_recovery_diode_horz:U0,step_recovery_diode_vert:l1,tachometer_horz:jt,tachometer_vert:x1,testpoint_down:n1,testpoint_left:f1,testpoint_right:ct,testpoint_up:d1,tilted_ground_down:_1,tilted_ground_left:g1,tilted_ground_right:wt,tilted_ground_up:H0,triac_horz:Z0,triac_vert:w1,tunnel_diode_horz:K0,tunnel_diode_vert:R1,unijunction_transistor_horz:er,unijunction_transistor_vert:L1,usbc:j1,var_meter_horz:or,var_meter_vert:O1,varactor_diode_horz:lr,varactor_diode_vert:C1,varistor_horz:ar,varistor_vert:q1,varmeter_horz:kt,varmeter_vert:W1,vcc_down:H1,vcc_left:Z1,vcc_right:Q1,vcc_up:K1,volt_meter_horz:xr,volt_meter_vert:tf,watt_hour_meter_horz:zt,watt_hour_meter_vert:lf,wattmeter_horz:Ot,wattmeter_vert:xf,zener_diode_horz:fr,zener_diode_vert:ff},GM=Object.fromEntries(Object.keys(cf).map(t5=>[t5,t5]))}});var require_boolbase=__commonJS({"node_modules/boolbase/index.js"(exports,module){"use strict";module.exports={trueFunc:function(){return!0},falseFunc:function(){return!1}}}});function applyToPoint2(matrix2,point6){return Array.isArray(point6)?[matrix2.a*point6[0]+matrix2.c*point6[1]+matrix2.e,matrix2.b*point6[0]+matrix2.d*point6[1]+matrix2.f]:{x:matrix2.a*point6.x+matrix2.c*point6.y+matrix2.e,y:matrix2.b*point6.x+matrix2.d*point6.y+matrix2.f}}var init_applyToPoint=__esm({"node_modules/transformation-matrix/src/applyToPoint.js"(){"use strict"}});var init_fromObject=__esm({"node_modules/transformation-matrix/src/fromObject.js"(){"use strict"}});var init_fromString=__esm({"node_modules/transformation-matrix/src/fromString.js"(){"use strict"}});var init_identity=__esm({"node_modules/transformation-matrix/src/identity.js"(){"use strict"}});var init_inverse=__esm({"node_modules/transformation-matrix/src/inverse.js"(){"use strict"}});function isUndefined2(val){return typeof val>"u"}var init_utils=__esm({"node_modules/transformation-matrix/src/utils.js"(){"use strict"}});var init_isAffineMatrix=__esm({"node_modules/transformation-matrix/src/isAffineMatrix.js"(){"use strict";init_utils()}});function translate2(tx2,ty2=0){return{a:1,c:0,e:tx2,b:0,d:1,f:ty2}}var init_translate=__esm({"node_modules/transformation-matrix/src/translate.js"(){"use strict"}});function transform2(...matrices){matrices=Array.isArray(matrices[0])?matrices[0]:matrices;let multiply=(m12,m22)=>({a:m12.a*m22.a+m12.c*m22.b,c:m12.a*m22.c+m12.c*m22.d,e:m12.a*m22.e+m12.c*m22.f+m12.e,b:m12.b*m22.a+m12.d*m22.b,d:m12.b*m22.c+m12.d*m22.d,f:m12.b*m22.e+m12.d*m22.f+m12.f});switch(matrices.length){case 0:throw new Error("no matrices provided");case 1:return matrices[0];case 2:return multiply(matrices[0],matrices[1]);default:{let[m12,m22,...rest]=matrices,m3=multiply(m12,m22);return transform2(m3,...rest)}}}function compose2(...matrices){return transform2(...matrices)}var init_transform=__esm({"node_modules/transformation-matrix/src/transform.js"(){"use strict"}});function rotate2(angle,cx2,cy2){let cosAngle=cos2(angle),sinAngle=sin2(angle),rotationMatrix={a:cosAngle,c:-sinAngle,e:0,b:sinAngle,d:cosAngle,f:0};return isUndefined2(cx2)||isUndefined2(cy2)?rotationMatrix:transform2([translate2(cx2,cy2),rotationMatrix,translate2(-cx2,-cy2)])}function rotateDEG2(angle,cx2=void 0,cy2=void 0){return rotate2(angle*PI2/180,cx2,cy2)}var cos2,sin2,PI2,init_rotate=__esm({"node_modules/transformation-matrix/src/rotate.js"(){"use strict";init_utils();init_translate();init_transform();({cos:cos2,sin:sin2,PI:PI2}=Math)}});function scale2(sx2,sy2=void 0,cx2=void 0,cy2=void 0){isUndefined2(sy2)&&(sy2=sx2);let scaleMatrix={a:sx2,c:0,e:0,b:0,d:sy2,f:0};return isUndefined2(cx2)||isUndefined2(cy2)?scaleMatrix:transform2([translate2(cx2,cy2),scaleMatrix,translate2(-cx2,-cy2)])}var init_scale=__esm({"node_modules/transformation-matrix/src/scale.js"(){"use strict";init_utils();init_translate();init_transform()}});var init_shear=__esm({"node_modules/transformation-matrix/src/shear.js"(){"use strict"}});var tan2,init_skew=__esm({"node_modules/transformation-matrix/src/skew.js"(){"use strict";({tan:tan2}=Math)}});var init_toString=__esm({"node_modules/transformation-matrix/src/toString.js"(){"use strict"}});var init_smoothMatrix=__esm({"node_modules/transformation-matrix/src/smoothMatrix.js"(){"use strict"}});var init_fromTriangles=__esm({"node_modules/transformation-matrix/src/fromTriangles.js"(){"use strict";init_inverse();init_transform();init_smoothMatrix()}});var init_fromDefinition=__esm({"node_modules/transformation-matrix/src/fromDefinition.js"(){"use strict";init_fromObject();init_translate();init_scale();init_rotate();init_skew();init_shear()}});var init_fromTransformAttribute_autogenerated=__esm({"node_modules/transformation-matrix/src/fromTransformAttribute.autogenerated.js"(){"use strict"}});var init_fromTransformAttribute=__esm({"node_modules/transformation-matrix/src/fromTransformAttribute.js"(){"use strict";init_fromTransformAttribute_autogenerated()}});function decomposeTSR2(matrix2,flipX=!1,flipY2=!1){flipX?flipY2?matrix2=compose2(matrix2,scale2(-1,-1)):matrix2=compose2(matrix2,scale2(1,-1)):flipY2&&(matrix2=compose2(matrix2,scale2(-1,1)));let a2=matrix2.a,b3=matrix2.b,c3=matrix2.c,d3=matrix2.d,scaleX,scaleY,rotation4;if(a2!==0||c3!==0){let hypotAc=Math.hypot(a2,c3);scaleX=hypotAc,scaleY=(a2*d3-b3*c3)/hypotAc;let acos=Math.acos(a2/hypotAc);rotation4=c3>0?-acos:acos}else if(b3!==0||d3!==0){let hypotBd=Math.hypot(b3,d3);scaleX=(a2*d3-b3*c3)/hypotBd,scaleY=hypotBd;let acos=Math.acos(b3/hypotBd);rotation4=Math.PI/2+(d3>0?-acos:acos)}else scaleX=0,scaleY=0,rotation4=0;return flipY2&&(scaleX=-scaleX),flipX&&(scaleY=-scaleY),{translate:{tx:matrix2.e,ty:matrix2.f},scale:{sx:scaleX,sy:scaleY},rotation:{angle:rotation4}}}var init_decompose=__esm({"node_modules/transformation-matrix/src/decompose.js"(){"use strict";init_scale();init_transform()}});var init_flip=__esm({"node_modules/transformation-matrix/src/flip.js"(){"use strict"}});var init_fromMovingPoints=__esm({"node_modules/transformation-matrix/src/fromMovingPoints.js"(){"use strict";init_translate();init_applyToPoint();init_rotate();init_scale();init_transform()}});var init_src=__esm({"node_modules/transformation-matrix/src/index.js"(){"use strict";init_applyToPoint();init_fromObject();init_fromString();init_identity();init_inverse();init_isAffineMatrix();init_rotate();init_scale();init_shear();init_skew();init_toString();init_transform();init_translate();init_fromTriangles();init_smoothMatrix();init_fromDefinition();init_fromTransformAttribute();init_decompose();init_flip();init_fromMovingPoints()}});var init_parsel=__esm({"node_modules/parsel-js/dist/parsel.js"(){"use strict"}});var require_performance_now=__commonJS({"node_modules/performance-now/lib/performance-now.js"(exports,module){"use strict";(function(){var getNanoSeconds,hrtime,loadTime,moduleLoadTime,nodeLoadTime,upTime;typeof performance<"u"&&performance!==null&&performance.now?module.exports=function(){return performance.now()}:typeof process<"u"&&process!==null&&process.hrtime?(module.exports=function(){return(getNanoSeconds()-nodeLoadTime)/1e6},hrtime=process.hrtime,getNanoSeconds=function(){var hr3;return hr3=hrtime(),hr3[0]*1e9+hr3[1]},moduleLoadTime=getNanoSeconds(),upTime=process.uptime()*1e9,nodeLoadTime=moduleLoadTime-upTime):Date.now?(module.exports=function(){return Date.now()-loadTime},loadTime=Date.now()):(module.exports=function(){return new Date().getTime()-loadTime},loadTime=new Date().getTime())}).call(exports)}});var init_chunk_GIGMPRPV=__esm({"node_modules/circuit-json-to-connectivity-map/node_modules/@tscircuit/math-utils/dist/chunk-GIGMPRPV.js"(){"use strict"}});var init_chunk_LL3GOPYX=__esm({"node_modules/circuit-json-to-connectivity-map/node_modules/@tscircuit/math-utils/dist/chunk-LL3GOPYX.js"(){"use strict"}});function doesLineIntersectLine([a12,a2],[b12,b22],{lineThickness=0}={}){return lineThickness===0?doSegmentsIntersect(a12,a2,b12,b22):segmentsDistance(a12,a2,b12,b22)<=lineThickness}function doSegmentsIntersect(p12,q12,p2,q22){let o12=orientation(p12,q12,p2),o22=orientation(p12,q12,q22),o32=orientation(p2,q22,p12),o4=orientation(p2,q22,q12);return!!(o12!==o22&&o32!==o4||o12===0&&onSegment(p12,p2,q12)||o22===0&&onSegment(p12,q22,q12)||o32===0&&onSegment(p2,p12,q22)||o4===0&&onSegment(p2,q12,q22))}function orientation(p2,q4,r4){let val=(q4.y-p2.y)*(r4.x-q4.x)-(q4.x-p2.x)*(r4.y-q4.y);return val===0?0:val>0?1:2}function onSegment(p2,q4,r4){return q4.x<=Math.max(p2.x,r4.x)&&q4.x>=Math.min(p2.x,r4.x)&&q4.y<=Math.max(p2.y,r4.y)&&q4.y>=Math.min(p2.y,r4.y)}function segmentsDistance(a12,a2,b12,b22){if(a12.x===a2.x&&a12.y===a2.y)return pointToSegmentDistance(a12,b12,b22);if(b12.x===b22.x&&b12.y===b22.y)return pointToSegmentDistance(b12,a12,a2);if(doSegmentsIntersect(a12,a2,b12,b22))return 0;let distances=[pointToSegmentDistance(a12,b12,b22),pointToSegmentDistance(a2,b12,b22),pointToSegmentDistance(b12,a12,a2),pointToSegmentDistance(b22,a12,a2)];return Math.min(...distances)}function pointToSegmentDistance(p2,v4,w4){let l2=(w4.x-v4.x)**2+(w4.y-v4.y)**2;if(l2===0)return distance2(p2,v4);let t5=((p2.x-v4.x)*(w4.x-v4.x)+(p2.y-v4.y)*(w4.y-v4.y))/l2;t5=Math.max(0,Math.min(1,t5));let projection={x:v4.x+t5*(w4.x-v4.x),y:v4.y+t5*(w4.y-v4.y)};return distance2(p2,projection)}function distance2(p12,p2){let dx2=p12.x-p2.x,dy2=p12.y-p2.y;return Math.sqrt(dx2*dx2+dy2*dy2)}var init_chunk_CHQOCSFB=__esm({"node_modules/circuit-json-to-connectivity-map/node_modules/@tscircuit/math-utils/dist/chunk-CHQOCSFB.js"(){"use strict"}});var init_chunk_MHHTZHOJ=__esm({"node_modules/circuit-json-to-connectivity-map/node_modules/@tscircuit/math-utils/dist/chunk-MHHTZHOJ.js"(){"use strict"}});var init_dist3=__esm({"node_modules/circuit-json-to-connectivity-map/node_modules/@tscircuit/math-utils/dist/index.js"(){"use strict";init_chunk_GIGMPRPV();init_chunk_LL3GOPYX();init_chunk_CHQOCSFB();init_chunk_MHHTZHOJ()}});function findConnectedNetworks(connections){let networks=new Map,netCounter=0;function getOrCreateNetwork(nodeId){for(let[,network]of networks)if(network.has(nodeId))return network;let newNetwork=new Set;return networks.set(`connectivity_net${netCounter++}`,newNetwork),newNetwork}for(let connection of connections){let network=null;for(let nodeId of connection){if(!network)network=getOrCreateNetwork(nodeId);else if(!network.has(nodeId)){let existingNetwork=getOrCreateNetwork(nodeId);if(existingNetwork!==network){for(let node of existingNetwork)network.add(node);networks.delete(Array.from(networks.entries()).find(([,net])=>net===existingNetwork)[0])}}network.add(nodeId)}}return Object.fromEntries(Array.from(networks.entries()).map(([netId,connectedNodes])=>[netId,Array.from(connectedNodes)]))}var ConnectivityMap,getFullConnectivityMapFromCircuitJson,PcbConnectivityMap,init_dist4=__esm({"node_modules/circuit-json-to-connectivity-map/dist/index.js"(){"use strict";init_dist3();ConnectivityMap=class{constructor(netMap){__publicField(this,"netMap");__publicField(this,"idToNetMap");this.netMap=netMap,this.idToNetMap={};for(let[netId,ids]of Object.entries(netMap))for(let id2 of ids)this.idToNetMap[id2]=netId}addConnections(connections){for(let connection of connections){let existingNets=new Set;for(let id2 of connection){let existingNetId=this.idToNetMap[id2];existingNetId&&existingNets.add(existingNetId)}let targetNetId;if(existingNets.size===0)targetNetId=`connectivity_net${Object.keys(this.netMap).length}`,this.netMap[targetNetId]=[];else if(existingNets.size===1)targetNetId=existingNets.values().next().value??`connectivity_net${Object.keys(this.netMap).length}`;else{targetNetId=existingNets.values().next().value??`connectivity_net${Object.keys(this.netMap).length}`;for(let netId of existingNets)if(netId!==targetNetId){this.netMap[targetNetId].push(...this.netMap[netId]),this.netMap[netId]=this.netMap[targetNetId];for(let id2 of this.netMap[targetNetId])this.idToNetMap[id2]=targetNetId}}for(let id2 of connection)this.netMap[targetNetId].includes(id2)||this.netMap[targetNetId].push(id2),this.idToNetMap[id2]=targetNetId}}getIdsConnectedToNet(netId){return this.netMap[netId]||[]}getNetConnectedToId(id2){return this.idToNetMap[id2]}areIdsConnected(id1,id2){if(id1===id2)return!0;let netId1=this.getNetConnectedToId(id1);if(!netId1)return!1;let netId2=this.getNetConnectedToId(id2);return netId2?netId1===netId2||netId2===id1||netId2===id1:!1}areAllIdsConnected(ids){let netId=this.getNetConnectedToId(ids[0]);for(let id2 of ids){let nextNetId=this.getNetConnectedToId(id2);if(nextNetId===void 0||nextNetId!==netId)return!1}return!0}},getFullConnectivityMapFromCircuitJson=circuitJson=>{let connections=[];for(let element of circuitJson)if(element.type==="source_trace")connections.push([element.source_trace_id,...element.connected_source_port_ids??[],...element.connected_source_net_ids??[]].filter(Boolean));else if(element.type==="pcb_port"){let{pcb_port_id,source_port_id}=element;source_port_id&&pcb_port_id&&connections.push([source_port_id,pcb_port_id])}else if(element.type==="pcb_smtpad"){let{pcb_smtpad_id,pcb_port_id}=element;pcb_port_id&&pcb_smtpad_id&&connections.push([pcb_smtpad_id,pcb_port_id])}else if(element.type==="pcb_plated_hole"){let{pcb_plated_hole_id,pcb_port_id}=element;pcb_port_id&&pcb_plated_hole_id&&connections.push([pcb_plated_hole_id,pcb_port_id])}else if(element.type==="pcb_trace"){let{pcb_trace_id,source_trace_id}=element,route=Array.isArray(element.route)?element.route.filter(rp2=>rp2&&rp2.route_type==="wire"):[];if(source_trace_id&&pcb_trace_id&&connections.push([pcb_trace_id,source_trace_id]),Array.isArray(route)){let startId=route.find(rp2=>rp2?.start_pcb_port_id)?.start_pcb_port_id,endId=route.find(rp2=>rp2?.end_pcb_port_id)?.end_pcb_port_id;startId&&pcb_trace_id&&endId&&connections.push([startId,pcb_trace_id,endId])}}else if(element.type==="pcb_via"){let{pcb_via_id,pcb_trace_id}=element;pcb_trace_id&&pcb_via_id&&connections.push([pcb_via_id,pcb_trace_id])}else if(element.type==="source_component"&&element.internally_connected_source_port_ids)for(let portGroup of element.internally_connected_source_port_ids)connections.push(portGroup);let netMap=findConnectedNetworks(connections);return new ConnectivityMap(netMap)},PcbConnectivityMap=class{constructor(circuitJson){__publicField(this,"circuitJson");__publicField(this,"traceIdToElm");__publicField(this,"portIdToElm");__publicField(this,"connMap");this.circuitJson=circuitJson||[],this.traceIdToElm=new Map,this.portIdToElm=new Map,circuitJson?(this._buildTraceMap(),this._buildPortMap(),this.connMap=this._buildTraceConnectivityMap()):this.connMap=new ConnectivityMap({})}_buildPortMap(){for(let element of this.circuitJson)element.type==="pcb_port"&&this.portIdToElm.set(element.pcb_port_id,element)}_buildTraceMap(){for(let element of this.circuitJson)element.type==="pcb_trace"&&this.traceIdToElm.set(element.pcb_trace_id,element)}_buildTraceConnectivityMap(){let connections=[],traceIds=Array.from(this.traceIdToElm.keys());for(let i3=0;i3<traceIds.length;i3++)for(let j3=i3+1;j3<traceIds.length;j3++){let trace1=this.traceIdToElm.get(traceIds[i3]),trace2=this.traceIdToElm.get(traceIds[j3]);this._arePcbTracesConnected(trace1,trace2)&&connections.push([traceIds[i3],traceIds[j3]])}for(let port of this.portIdToElm.values())for(let trace of this.traceIdToElm.values())for(let rp2 of trace.route)rp2.route_type==="wire"&&(rp2.start_pcb_port_id===port.pcb_port_id?connections.push([port.pcb_port_id,trace.pcb_trace_id]):rp2.end_pcb_port_id===port.pcb_port_id&&connections.push([trace.pcb_trace_id,port.pcb_port_id]));return new ConnectivityMap(findConnectedNetworks(connections))}addTrace(trace){this.traceIdToElm.set(trace.pcb_trace_id,trace);let connections=[];for(let rp2 of trace.route)rp2.route_type==="wire"&&(rp2.start_pcb_port_id&&connections.push([rp2.start_pcb_port_id,trace.pcb_trace_id]),rp2.end_pcb_port_id&&connections.push([rp2.end_pcb_port_id,trace.pcb_trace_id]));this.connMap.addConnections(connections)}_arePcbTracesConnected(trace1,trace2){for(let i3=0;i3<trace1.route.length-1;i3++){let segment1A=trace1.route[i3],segment1B=trace1.route[i3+1];if(segment1A.route_type==="wire"&&segment1B.route_type==="wire")for(let j3=0;j3<trace2.route.length-1;j3++){let segment2A=trace2.route[j3],segment2B=trace2.route[j3+1];if(segment2A.route_type!=="wire"||segment2B.route_type!=="wire")continue;if(doesLineIntersectLine([segment1A,segment1B],[segment2A,segment2B],{lineThickness:(segment1A.width+segment2A.width)/2}))return!0}}return!1}areTracesConnected(traceId1,traceId2){return this.connMap.areIdsConnected(traceId1,traceId2)}getAllTracesConnectedToTrace(traceId){let netId=this.connMap.getNetConnectedToId(traceId);return netId?this.connMap.getIdsConnectedToNet(netId).filter(id2=>this.traceIdToElm.has(id2)).map(id2=>this.traceIdToElm.get(id2)):[]}getAllTracesConnectedToPort(portId){let netId=this.connMap.getNetConnectedToId(portId);return netId?this.connMap.getIdsConnectedToNet(netId).filter(id2=>this.traceIdToElm.has(id2)).map(id2=>this.traceIdToElm.get(id2)):[]}}}});var calculateElbowBends,calculateElbow,init_dist5=__esm({"node_modules/calculate-elbow/dist/index.js"(){"use strict";calculateElbowBends=(p12,p2,overshootAmount)=>{let result=[{x:p12.x,y:p12.y}],midX=(p12.x+p2.x)/2,midY=(p12.y+p2.y)/2,p2Target={x:p2.x,y:p2.y};switch(p2.facingDirection){case"x+":p2Target.x+=overshootAmount;break;case"x-":p2Target.x-=overshootAmount;break;case"y+":p2Target.y+=overshootAmount;break;case"y-":p2Target.y-=overshootAmount;break}let startDir=p12.facingDirection??"none",endDir=p2.facingDirection??"none",push=pt3=>{let last=result[result.length-1];(last.x!==pt3.x||last.y!==pt3.y)&&result.push(pt3)},yAligned=Math.abs(p12.y-p2.y)<=Math.max(1e-6,overshootAmount*.1),xAligned=Math.abs(p12.x-p2.x)<=Math.max(1e-6,overshootAmount*.1);if(startDir==="none"&&endDir==="none")push({x:midX,y:p12.y}),push({x:midX,y:p2.y});else if(startDir==="x+"&&endDir==="y+")p12.x>p2.x&&p12.y<p2.y?(push({x:p12.x+overshootAmount,y:p12.y}),push({x:p12.x+overshootAmount,y:p2.y+overshootAmount}),push({x:p2.x,y:p2.y+overshootAmount})):!xAligned&&!yAligned&&p12.x<p2.x&&p12.y>p2.y?push({x:p2.x,y:p12.y}):xAligned?(push({x:p12.x+overshootAmount,y:p12.y}),push({x:p12.x+overshootAmount,y:p2.y+overshootAmount}),push({x:p2.x,y:p2.y+overshootAmount})):p12.x<p2.x?(push({x:midX,y:p12.y}),push({x:midX,y:p2Target.y}),push({x:p2.x,y:p2Target.y})):p12.y<=p2.y+overshootAmount?(push({x:p12.x+overshootAmount,y:p12.y}),push({x:p12.x+overshootAmount,y:p12.y+overshootAmount}),push({x:p2.x,y:p12.y+overshootAmount}),push({x:p2.x,y:p2.y})):(push({x:p12.x+overshootAmount,y:p12.y}),push({x:p12.x+overshootAmount,y:(p12.y+p2.y)/2}),push({x:p2.x,y:(p12.y+p2.y)/2}));else if(startDir==="x+"&&endDir==="x+"&&!yAligned){let commonX=Math.max(p12.x+overshootAmount,p2Target.x);push({x:commonX,y:p12.y}),push({x:commonX,y:p2.y})}else if(startDir==="x+"&&endDir==="x+"&&yAligned)push({x:p12.x+overshootAmount,y:p12.y}),push({x:p12.x+overshootAmount,y:p12.y+overshootAmount}),push({x:p2.x+overshootAmount,y:p12.y+overshootAmount}),push({x:p2.x+overshootAmount,y:p2.y});else if(startDir==="x+"&&endDir==="y-")if(xAligned&&p12.y<=p2.y)push({x:p12.x+overshootAmount,y:p12.y}),push({x:p12.x+overshootAmount,y:midY}),push({x:p2.x,y:midY});else if(xAligned&&p12.y>p2.y)push({x:p12.x+overshootAmount,y:p12.y}),push({x:p12.x+overshootAmount,y:p2.y-overshootAmount}),push({x:p2.x,y:p2.y-overshootAmount});else if(p12.x<p2.x&&p12.y<p2.y)push({x:p2.x,y:p12.y});else if(p12.x>p2.x&&p12.y<p2.y){let p1OvershootX=p12.x+overshootAmount;push({x:p1OvershootX,y:p12.y}),push({x:p1OvershootX,y:midY}),push({x:p2.x,y:midY})}else if(p12.x>p2.x&&p12.y>p2.y){let p1OvershootX=p12.x+overshootAmount;push({x:p1OvershootX,y:p12.y}),push({x:p1OvershootX,y:p2Target.y}),push({x:p2.x,y:p2Target.y})}else p12.y===p2.y?(push({x:p12.x+overshootAmount,y:p12.y}),push({x:p12.x+overshootAmount,y:p12.y-overshootAmount}),push({x:p2.x,y:p12.y-overshootAmount})):(push({x:midX,y:p12.y}),push({x:midX,y:p2Target.y}),push({x:p2.x,y:p2Target.y}));else if(startDir==="x+"&&endDir==="x-"&&p12.x+overshootAmount>=p2.x-overshootAmount&&!yAligned){let p1OvershootX=p12.x+overshootAmount;push({x:p1OvershootX,y:p12.y}),push({x:p1OvershootX,y:midY}),push({x:p2Target.x,y:midY}),push({x:p2Target.x,y:p2Target.y})}else startDir==="x+"&&endDir==="x-"&&yAligned&&p2.x>p12.x||(startDir==="x+"&&endDir==="x-"&&yAligned?(push({x:p12.x+overshootAmount,y:p12.y}),push({x:p12.x+overshootAmount,y:p12.y+overshootAmount}),push({x:p2.x-overshootAmount,y:p12.y+overshootAmount}),push({x:p2.x-overshootAmount,y:p12.y})):(startDir==="x+"&&push({x:p12.x+overshootAmount,y:p12.y}),push({x:midX,y:result[result.length-1].y}),push({x:midX,y:p2Target.y}),push({x:p2Target.x,y:p2Target.y})));return push({x:p2.x,y:p2.y}),result},calculateElbow=(point1,point23,options={})=>{let p12=point1,p2=point23,orderFlipped=!1;(p12.x>p2.x||p12.x===p2.x&&p12.y>p2.y)&&(orderFlipped=!0,[p12,p2]=[p2,p12]);let mirrorX=p12.facingDirection==="x-",mirrorY=p12.facingDirection==="y-",mirrorPoint=pt3=>{let x3=mirrorX?p12.x-(pt3.x-p12.x):pt3.x,y3=mirrorY?p12.y-(pt3.y-p12.y):pt3.y,facing=pt3.facingDirection;return mirrorX&&(facing==="x+"?facing="x-":facing==="x-"&&(facing="x+")),mirrorY&&(facing==="y+"?facing="y-":facing==="y-"&&(facing="y+")),{x:x3,y:y3,facingDirection:facing}},rotateCW=(pt3,centre)=>{let dx2=pt3.x-centre.x,dy2=pt3.y-centre.y,x3=centre.x+dy2,y3=centre.y-dx2,facing=pt3.facingDirection;switch(facing){case"x+":facing="y-";break;case"y-":facing="x-";break;case"x-":facing="y+";break;case"y+":facing="x+";break}return{x:x3,y:y3,facingDirection:facing}},rotateCCW=(pt3,centre)=>{let dx2=pt3.x-centre.x,dy2=pt3.y-centre.y;return{x:centre.x-dy2,y:centre.y+dx2}},mp1=mirrorX||mirrorY?mirrorPoint(p12):p12,mp2=mirrorX||mirrorY?mirrorPoint(p2):p2,rp1=mp1,rp2=mp2,rotated=!1;mp1.facingDirection==="y+"&&(rotated=!0,rp1={...mp1,facingDirection:"x+"},rp2=rotateCW(mp2,mp1));let overshootAmount=options?.overshoot??.1*Math.max(Math.abs(rp1.x-rp2.x),Math.abs(rp1.y-rp2.y)),result=calculateElbowBends(rp1,rp2,overshootAmount);return rotated&&(result=result.map(pt3=>rotateCCW(pt3,rp1))),(mirrorX||mirrorY)&&(result=result.map(({x:x3,y:y3})=>({x:mirrorX?p12.x-(x3-p12.x):x3,y:mirrorY?p12.y-(y3-p12.y):y3}))),orderFlipped?result.reverse():result}}});function connect(map,a2,b3){if(!a2||!b3)return;let setA=map.get(a2);setA||(setA=new Set,map.set(a2,setA)),setA.add(b3);let setB=map.get(b3);setB||(setB=new Set,map.set(b3,setB)),setB.add(a2)}function buildSubtree(soup,opts){if(!opts.subcircuit_id&&!opts.source_group_id)return[...soup];let idMap=new Map;for(let elm of soup){let idVal=elm[`${elm.type}_id`];typeof idVal=="string"&&idMap.set(idVal,elm)}let adj=new Map;for(let elm of soup){let entries=Object.entries(elm);for(let[key,val]of entries)if(key!=="parent_source_group_id"){if(key.endsWith("_id")&&typeof val=="string"){let other=idMap.get(val);connect(adj,elm,other)}else if(key.endsWith("_ids")&&Array.isArray(val)){for(let v4 of val)if(typeof v4=="string"){let other=idMap.get(v4);connect(adj,elm,other)}}}}let queue=[],included=new Set;for(let elm of soup)(opts.subcircuit_id&&elm.subcircuit_id===opts.subcircuit_id||opts.source_group_id&&(elm.source_group_id===opts.source_group_id||Array.isArray(elm.member_source_group_ids)&&elm.member_source_group_ids.includes(opts.source_group_id)))&&(queue.push(elm),included.add(elm));for(;queue.length>0;){let elm=queue.shift(),neighbors=adj.get(elm);if(neighbors)for(let n3 of neighbors)included.has(n3)||(included.add(n3),queue.push(n3))}return soup.filter(e4=>included.has(e4))}function createIdKey(element){let type=element.type;return`${type}:${element[`${type}_id`]}`}function getReadableNameForPcbTrace(soup,pcb_trace_id){let pcbTrace=cju(soup).pcb_trace.get(pcb_trace_id);if(!pcbTrace)return`trace[${pcb_trace_id}]`;let connectedPcbPortIds=pcbTrace.route.flatMap(point6=>[point6.start_pcb_port_id,point6.end_pcb_port_id]).filter(Boolean);if(connectedPcbPortIds.length===0)return`trace[${pcb_trace_id}]`;function getComponentAndPortInfo(pcb_port_id){let pcbPort=cju(soup).pcb_port.get(pcb_port_id);if(!pcbPort)return null;let pcbComponent=pcbPort.pcb_component_id?cju(soup).pcb_component.get(pcbPort.pcb_component_id):void 0;if(!pcbComponent)return null;let sourceComponent=cju(soup).source_component.get(pcbComponent.source_component_id);if(!sourceComponent)return null;let sourcePort=cju(soup).source_port.get(pcbPort.source_port_id),portHint=sourcePort?.port_hints?sourcePort.port_hints[1]:"";return{componentName:sourceComponent.name,portHint}}return`trace[${connectedPcbPortIds.map(portId=>{let info=getComponentAndPortInfo(portId);return info?`.${info.componentName} > port.${info.portHint}`:`port[${portId}]`}).join(", ")}]`}function getReadableNameForPcbSmtpad(soup,pcb_smtpad_id){let pcbSmtpad=cju(soup).pcb_smtpad.get(pcb_smtpad_id);return!pcbSmtpad||!pcbSmtpad.pcb_port_id?`smtpad[${pcb_smtpad_id}]`:getReadableNameForPcbPort(soup,pcbSmtpad.pcb_port_id)}function stringHash(str){let hash=0;if(str.length==0)return hash;for(var i3=0;i3<str.length;i3++){var char=str.charCodeAt(i3);hash=(hash<<5)-hash+char,hash=hash&hash}return Math.abs(hash)}function getMinimumFlexContainer(children,options={}){if(children.length===0)return{width:0,height:0};let direction2=options.direction??"row",columnGap=options.columnGap??0,rowGap=options.rowGap??0;if(direction2==="row"||direction2==="row-reverse"){let width=children.reduce((sum,c3)=>sum+c3.width,0)+columnGap*Math.max(0,children.length-1),height=children.reduce((max,c3)=>Math.max(max,c3.height),0);return{width,height}}else{let height=children.reduce((sum,c3)=>sum+c3.height,0)+rowGap*Math.max(0,children.length-1);return{width:children.reduce((max,c3)=>Math.max(max,c3.width),0),height}}}var cju,su2,cju_default,cjuIndexed,rotateClockwise,rotateCounterClockwise,rotateDirection,oppositeSide,transformSchematicElement,transformSchematicElements,transformPCBElement,transformPCBElements,getElementId,getElementById2,getReadableNameForPcbPort,getReadableNameForElement,getBoundsOfPcbElements,nice_color_palettes,getDebugLayoutObject,isTruthy,findBoundsAndCenter,getPrimaryId,repositionPcbComponentTo,findAllDescendantGroupIds,repositionPcbGroupTo,repositionSchematicComponentTo,findAllDescendantGroupIds2,repositionSchematicGroupTo,getCircuitJsonTree,init_dist6=__esm({"node_modules/@tscircuit/circuit-json-util/dist/index.js"(){"use strict";init_dist();init_dist();init_src();init_parsel();init_src();init_src();init_src();init_src();cju=((circuitJsonInput,options={})=>{let circuitJson=circuitJsonInput,internalStore=circuitJson._internal_store;if(!internalStore){internalStore={counts:{},editCount:0},circuitJson._internal_store=internalStore;for(let elm of circuitJson){let type=elm.type,idVal=elm[`${type}_id`];if(!idVal)continue;let idNum=Number.parseInt(idVal.split("_").pop());Number.isNaN(idNum)||(internalStore.counts[type]=Math.max(internalStore.counts[type]??0,idNum))}}return new Proxy({},{get:(proxy_target,prop)=>{if(prop==="toArray")return()=>(circuitJson.editCount=internalStore.editCount,circuitJson);if(prop==="editCount")return internalStore.editCount;if(prop==="subtree")return opts=>cju(buildSubtree(circuitJson,opts),options);let component_type=prop;return{get:id2=>circuitJson.find(e4=>e4.type===component_type&&e4[`${component_type}_id`]===id2),getUsing:using=>{let keys=Object.keys(using);if(keys.length!==1)throw new Error("getUsing requires exactly one key, e.g. { pcb_component_id }");let join_key=keys[0],join_type=join_key.replace("_id",""),joiner=circuitJson.find(e4=>e4.type===join_type&&e4[join_key]===using[join_key]);return joiner?circuitJson.find(e4=>e4.type===component_type&&e4[`${component_type}_id`]===joiner[`${component_type}_id`]):null},getWhere:where=>{let keys=Object.keys(where);return circuitJson.find(e4=>e4.type===component_type&&keys.every(key=>e4[key]===where[key]))},list:where=>{let keys=where?Object.keys(where):[];return circuitJson.filter(e4=>e4.type===component_type&&keys.every(key=>e4[key]===where[key]))},insert:elm=>{var _a359;(_a359=internalStore.counts)[component_type]??(_a359[component_type]=-1),internalStore.counts[component_type]++;let index=internalStore.counts[component_type],newElm={type:component_type,[`${component_type}_id`]:`${component_type}_${index}`,...elm};return options.validateInserts&&(dist_exports[component_type]??any_soup_element).parse(newElm),circuitJson.push(newElm),internalStore.editCount++,newElm},delete:id2=>{let elm=circuitJson.find(e4=>e4[`${component_type}_id`]===id2);elm&&(circuitJson.splice(circuitJson.indexOf(elm),1),internalStore.editCount++)},update:(id2,newProps)=>{let elm=circuitJson.find(e4=>e4.type===component_type&&e4[`${component_type}_id`]===id2);return elm?(Object.assign(elm,newProps),internalStore.editCount++,elm):null},select:selector=>{if(component_type==="source_component")return circuitJson.find(e4=>e4.type==="source_component"&&e4.name===selector.replace(/\./g,""));if(component_type==="pcb_port"||component_type==="source_port"||component_type==="schematic_port"){let[component_name,port_selector]=selector.replace(/\./g,"").split(/[\s\>]+/),source_component=circuitJson.find(e4=>e4.type==="source_component"&&e4.name===component_name);if(!source_component)return null;let source_port2=circuitJson.find(e4=>e4.type==="source_port"&&e4.source_component_id===source_component.source_component_id&&(e4.name===port_selector||(e4.port_hints??[]).includes(port_selector)));if(!source_port2)return null;if(component_type==="source_port")return source_port2;if(component_type==="pcb_port")return circuitJson.find(e4=>e4.type==="pcb_port"&&e4.source_port_id===source_port2.source_port_id);if(component_type==="schematic_port")return circuitJson.find(e4=>e4.type==="schematic_port"&&e4.source_port_id===source_port2.source_port_id)}}}}})});cju.unparsed=cju;su2=cju,cju_default=cju;cjuIndexed=((soup,options={})=>{let internalStore=soup._internal_store_indexed;if(!internalStore){internalStore={counts:{},editCount:0,indexes:{}};for(let elm of soup){let type=elm.type,idVal=elm[`${type}_id`];if(!idVal)continue;let idNum=Number.parseInt(idVal.split("_").pop()||"");Number.isNaN(idNum)||(internalStore.counts[type]=Math.max(internalStore.counts[type]??0,idNum))}let indexConfig=options.indexConfig||{},indexes=internalStore.indexes;if(indexConfig.byId&&(indexes.byId=new Map),indexConfig.byType&&(indexes.byType=new Map),indexConfig.byRelation&&(indexes.byRelation=new Map),indexConfig.bySubcircuit&&(indexes.bySubcircuit=new Map),indexConfig.byCustomField&&indexConfig.byCustomField.length>0){indexes.byCustomField=new Map;for(let field of indexConfig.byCustomField)indexes.byCustomField.set(field,new Map)}for(let element of soup){if(indexConfig.byId){let idKey=createIdKey(element);indexes.byId.set(idKey,element)}if(indexConfig.byType){let elementsOfType=indexes.byType.get(element.type)||[];elementsOfType.push(element),indexes.byType.set(element.type,elementsOfType)}if(indexConfig.byRelation){let elementEntries=Object.entries(element);for(let[key,value]of elementEntries)if(key.endsWith("_id")&&key!==`${element.type}_id`&&typeof value=="string"){let relationTypeMap=indexes.byRelation.get(key)||new Map,relatedElements=relationTypeMap.get(value)||[];relatedElements.push(element),relationTypeMap.set(value,relatedElements),indexes.byRelation.set(key,relationTypeMap)}}if(indexConfig.bySubcircuit&&"subcircuit_id"in element){let subcircuitId=element.subcircuit_id;if(subcircuitId&&typeof subcircuitId=="string"){let subcircuitElements=indexes.bySubcircuit.get(subcircuitId)||[];subcircuitElements.push(element),indexes.bySubcircuit.set(subcircuitId,subcircuitElements)}}if(indexConfig.byCustomField&&indexes.byCustomField){for(let field of indexConfig.byCustomField)if(field in element){let fieldValue=element[field];if(fieldValue!==void 0&&(typeof fieldValue=="string"||typeof fieldValue=="number")){let fieldValueStr=String(fieldValue),fieldMap=indexes.byCustomField.get(field),elementsWithFieldValue=fieldMap.get(fieldValueStr)||[];elementsWithFieldValue.push(element),fieldMap.set(fieldValueStr,elementsWithFieldValue)}}}}soup._internal_store_indexed=internalStore}return new Proxy({},{get:(proxy_target,prop)=>{if(prop==="toArray")return()=>(soup.editCount=internalStore.editCount,soup);if(prop==="editCount")return internalStore.editCount;let component_type=prop;return{get:id2=>{let indexConfig=options.indexConfig||{};return indexConfig.byId&&internalStore.indexes.byId?internalStore.indexes.byId.get(`${component_type}:${id2}`)||null:indexConfig.byType&&internalStore.indexes.byType?(internalStore.indexes.byType.get(component_type)||[]).find(e4=>e4[`${component_type}_id`]===id2)||null:soup.find(e4=>e4.type===component_type&&e4[`${component_type}_id`]===id2)||null},getUsing:using=>{let indexConfig=options.indexConfig||{},keys=Object.keys(using);if(keys.length!==1)throw new Error("getUsing requires exactly one key, e.g. { pcb_component_id }");let join_key=keys[0],join_type=join_key.replace("_id","");if(indexConfig.byRelation&&internalStore.indexes.byRelation){let relationMap=internalStore.indexes.byRelation.get(join_key);if(relationMap){let joiner2=(relationMap.get(using[join_key])||[]).find(e4=>e4.type===join_type);if(!joiner2)return null;let joinerId=joiner2[`${component_type}_id`];return indexConfig.byId&&internalStore.indexes.byId?internalStore.indexes.byId.get(`${component_type}:${joinerId}`)||null:indexConfig.byType&&internalStore.indexes.byType?(internalStore.indexes.byType.get(component_type)||[]).find(e4=>e4[`${component_type}_id`]===joinerId)||null:soup.find(e4=>e4.type===component_type&&e4[`${component_type}_id`]===joinerId)||null}}let joiner=soup.find(e4=>e4.type===join_type&&e4[join_key]===using[join_key]);return joiner&&soup.find(e4=>e4.type===component_type&&e4[`${component_type}_id`]===joiner[`${component_type}_id`])||null},getWhere:where=>{let indexConfig=options.indexConfig||{},keys=Object.keys(where);if(keys.length===1&&indexConfig.byCustomField&&internalStore.indexes.byCustomField){let field=keys[0],fieldMap=internalStore.indexes.byCustomField.get(field);if(fieldMap){let fieldValue=String(where[field]);return(fieldMap.get(fieldValue)||[]).find(e4=>e4.type===component_type)||null}}if("subcircuit_id"in where&&indexConfig.bySubcircuit&&internalStore.indexes.bySubcircuit){let subcircuitId=where.subcircuit_id;return(internalStore.indexes.bySubcircuit.get(subcircuitId)||[]).find(e4=>e4.type===component_type&&keys.every(key=>e4[key]===where[key]))||null}return indexConfig.byType&&internalStore.indexes.byType?(internalStore.indexes.byType.get(component_type)||[]).find(e4=>keys.every(key=>e4[key]===where[key]))||null:soup.find(e4=>e4.type===component_type&&keys.every(key=>e4[key]===where[key]))||null},list:where=>{let indexConfig=options.indexConfig||{},keys=where?Object.keys(where):[];if(keys.length===0&&indexConfig.byType&&internalStore.indexes.byType)return internalStore.indexes.byType.get(component_type)||[];if(keys.length===1&&keys[0]==="subcircuit_id"&&indexConfig.bySubcircuit&&internalStore.indexes.bySubcircuit){let subcircuitId=where.subcircuit_id;return(internalStore.indexes.bySubcircuit.get(subcircuitId)||[]).filter(e4=>e4.type===component_type)}let elementsToFilter;return indexConfig.byType&&internalStore.indexes.byType?elementsToFilter=internalStore.indexes.byType.get(component_type)||[]:elementsToFilter=soup.filter(e4=>e4.type===component_type),keys.length>0?elementsToFilter.filter(e4=>keys.every(key=>e4[key]===where[key])):elementsToFilter},insert:elm=>{var _a359;(_a359=internalStore.counts)[component_type]??(_a359[component_type]=-1),internalStore.counts[component_type]++;let index=internalStore.counts[component_type],newElm={type:component_type,[`${component_type}_id`]:`${component_type}_${index}`,...elm};options.validateInserts&&(dist_exports[component_type]??any_soup_element).parse(newElm),soup.push(newElm),internalStore.editCount++;let indexConfig=options.indexConfig||{};if(indexConfig.byId&&internalStore.indexes.byId){let idKey=createIdKey(newElm);internalStore.indexes.byId.set(idKey,newElm)}if(indexConfig.byType&&internalStore.indexes.byType){let elementsOfType=internalStore.indexes.byType.get(component_type)||[];elementsOfType.push(newElm),internalStore.indexes.byType.set(component_type,elementsOfType)}if(indexConfig.byRelation&&internalStore.indexes.byRelation){let elementEntries=Object.entries(newElm);for(let[key,value]of elementEntries)if(key.endsWith("_id")&&key!==`${newElm.type}_id`&&typeof value=="string"){let relationTypeMap=internalStore.indexes.byRelation.get(key)||new Map,relatedElements=relationTypeMap.get(value)||[];relatedElements.push(newElm),relationTypeMap.set(value,relatedElements),internalStore.indexes.byRelation.set(key,relationTypeMap)}}if(indexConfig.bySubcircuit&&internalStore.indexes.bySubcircuit&&"subcircuit_id"in newElm){let subcircuitId=newElm.subcircuit_id;if(subcircuitId&&typeof subcircuitId=="string"){let subcircuitElements=internalStore.indexes.bySubcircuit.get(subcircuitId)||[];subcircuitElements.push(newElm),internalStore.indexes.bySubcircuit.set(subcircuitId,subcircuitElements)}}if(indexConfig.byCustomField&&internalStore.indexes.byCustomField){for(let field of indexConfig.byCustomField)if(field in newElm){let fieldValue=newElm[field];if(fieldValue!==void 0&&(typeof fieldValue=="string"||typeof fieldValue=="number")){let fieldValueStr=String(fieldValue),fieldMap=internalStore.indexes.byCustomField.get(field),elementsWithFieldValue=fieldMap.get(fieldValueStr)||[];elementsWithFieldValue.push(newElm),fieldMap.set(fieldValueStr,elementsWithFieldValue)}}}return newElm},delete:id2=>{let indexConfig=options.indexConfig||{},elm;if(indexConfig.byId&&internalStore.indexes.byId?elm=internalStore.indexes.byId.get(`${component_type}:${id2}`):indexConfig.byType&&internalStore.indexes.byType?elm=(internalStore.indexes.byType.get(component_type)||[]).find(e4=>e4[`${component_type}_id`]===id2):elm=soup.find(e4=>e4[`${component_type}_id`]===id2),!elm)return;let elmIndex=soup.indexOf(elm);if(elmIndex>=0&&(soup.splice(elmIndex,1),internalStore.editCount++),indexConfig.byId&&internalStore.indexes.byId){let idKey=createIdKey(elm);internalStore.indexes.byId.delete(idKey)}if(indexConfig.byType&&internalStore.indexes.byType){let filteredElements=(internalStore.indexes.byType.get(component_type)||[]).filter(e4=>e4[`${component_type}_id`]!==id2);internalStore.indexes.byType.set(component_type,filteredElements)}if(indexConfig.byRelation&&internalStore.indexes.byRelation)for(let[relationKey,relationMap]of internalStore.indexes.byRelation.entries())for(let[relationValue,elements]of relationMap.entries()){let updatedElements=elements.filter(e4=>e4!==elm);updatedElements.length===0?relationMap.delete(relationValue):relationMap.set(relationValue,updatedElements)}if(indexConfig.bySubcircuit&&internalStore.indexes.bySubcircuit&&"subcircuit_id"in elm){let subcircuitId=elm.subcircuit_id;if(subcircuitId){let updatedElements=(internalStore.indexes.bySubcircuit.get(subcircuitId)||[]).filter(e4=>e4!==elm);updatedElements.length===0?internalStore.indexes.bySubcircuit.delete(subcircuitId):internalStore.indexes.bySubcircuit.set(subcircuitId,updatedElements)}}if(indexConfig.byCustomField&&internalStore.indexes.byCustomField)for(let fieldMap of internalStore.indexes.byCustomField.values())for(let[fieldValue,elements]of fieldMap.entries()){let updatedElements=elements.filter(e4=>e4!==elm);updatedElements.length===0?fieldMap.delete(fieldValue):fieldMap.set(fieldValue,updatedElements)}},update:(id2,newProps)=>{let indexConfig=options.indexConfig||{},elm;if(indexConfig.byId&&internalStore.indexes.byId?elm=internalStore.indexes.byId.get(`${component_type}:${id2}`):indexConfig.byType&&internalStore.indexes.byType?elm=(internalStore.indexes.byType.get(component_type)||[]).find(e4=>e4[`${component_type}_id`]===id2):elm=soup.find(e4=>e4.type===component_type&&e4[`${component_type}_id`]===id2),!elm)return null;if(indexConfig.byRelation&&internalStore.indexes.byRelation){let elementEntries=Object.entries(elm);for(let[key,value]of elementEntries)if(key.endsWith("_id")&&key!==`${elm.type}_id`&&typeof value=="string"&&key in newProps&&newProps[key]!==value){let relationTypeMap=internalStore.indexes.byRelation.get(key);if(relationTypeMap){let updatedElements=(relationTypeMap.get(value)||[]).filter(e4=>e4!==elm);updatedElements.length===0?relationTypeMap.delete(value):relationTypeMap.set(value,updatedElements)}}}if(indexConfig.bySubcircuit&&internalStore.indexes.bySubcircuit&&"subcircuit_id"in elm&&"subcircuit_id"in newProps){let oldSubcircuitId=elm.subcircuit_id,newSubcircuitId=newProps.subcircuit_id;if(oldSubcircuitId!==newSubcircuitId){let updatedElements=(internalStore.indexes.bySubcircuit.get(oldSubcircuitId)||[]).filter(e4=>e4!==elm);updatedElements.length===0?internalStore.indexes.bySubcircuit.delete(oldSubcircuitId):internalStore.indexes.bySubcircuit.set(oldSubcircuitId,updatedElements)}}if(indexConfig.byCustomField&&internalStore.indexes.byCustomField){for(let field of indexConfig.byCustomField)if(field in elm&&field in newProps&&elm[field]!==newProps[field]){let fieldMap=internalStore.indexes.byCustomField.get(field);if(fieldMap){let oldValue=String(elm[field]),updatedElements=(fieldMap.get(oldValue)||[]).filter(e4=>e4!==elm);updatedElements.length===0?fieldMap.delete(oldValue):fieldMap.set(oldValue,updatedElements)}}}if(Object.assign(elm,newProps),internalStore.editCount++,indexConfig.byRelation&&internalStore.indexes.byRelation){let elementEntries=Object.entries(elm);for(let[key,value]of elementEntries)if(key.endsWith("_id")&&key!==`${elm.type}_id`&&typeof value=="string"&&key in newProps){let relationTypeMap=internalStore.indexes.byRelation.get(key)||new Map,relatedElements=relationTypeMap.get(value)||[];relatedElements.includes(elm)||(relatedElements.push(elm),relationTypeMap.set(value,relatedElements),internalStore.indexes.byRelation.set(key,relationTypeMap))}}if(indexConfig.bySubcircuit&&internalStore.indexes.bySubcircuit&&"subcircuit_id"in elm&&"subcircuit_id"in newProps){let subcircuitId=elm.subcircuit_id;if(subcircuitId&&typeof subcircuitId=="string"){let subcircuitElements=internalStore.indexes.bySubcircuit.get(subcircuitId)||[];subcircuitElements.includes(elm)||(subcircuitElements.push(elm),internalStore.indexes.bySubcircuit.set(subcircuitId,subcircuitElements))}}if(indexConfig.byCustomField&&internalStore.indexes.byCustomField){for(let field of indexConfig.byCustomField)if(field in elm&&field in newProps){let fieldValue=elm[field];if(fieldValue!==void 0&&(typeof fieldValue=="string"||typeof fieldValue=="number")){let fieldValueStr=String(fieldValue),fieldMap=internalStore.indexes.byCustomField.get(field),elementsWithFieldValue=fieldMap.get(fieldValueStr)||[];elementsWithFieldValue.includes(elm)||(elementsWithFieldValue.push(elm),fieldMap.set(fieldValueStr,elementsWithFieldValue))}}}return elm},select:selector=>{if(component_type==="source_component")return soup.find(e4=>e4.type==="source_component"&&e4.name===selector.replace(/\./g,""))||null;if(component_type==="pcb_port"||component_type==="source_port"||component_type==="schematic_port"){let[component_name,port_selector]=selector.replace(/\./g,"").split(/[\s\>]+/),source_component=soup.find(e4=>e4.type==="source_component"&&e4.name===component_name);if(!source_component)return null;let source_port2=soup.find(e4=>e4.type==="source_port"&&e4.source_component_id===source_component.source_component_id&&(e4.name===port_selector||(e4.port_hints??[]).includes(port_selector)));if(!source_port2)return null;if(component_type==="source_port")return source_port2;if(component_type==="pcb_port")return soup.find(e4=>e4.type==="pcb_port"&&e4.source_port_id===source_port2.source_port_id)||null;if(component_type==="schematic_port")return soup.find(e4=>e4.type==="schematic_port"&&e4.source_port_id===source_port2.source_port_id)||null}return null}}}})});cjuIndexed.unparsed=cjuIndexed;rotateClockwise=direction2=>{if(direction2==="up")return"right";if(direction2==="right")return"down";if(direction2==="down")return"left";if(direction2==="left")return"up";throw new Error(`Invalid direction: ${direction2}`)},rotateCounterClockwise=direction2=>{if(direction2==="up")return"left";if(direction2==="left")return"down";if(direction2==="down")return"right";if(direction2==="right")return"up";throw new Error(`Invalid direction: ${direction2}`)},rotateDirection=(direction2,num90DegreeClockwiseTurns)=>{for(;num90DegreeClockwiseTurns>0;)direction2=rotateClockwise(direction2),num90DegreeClockwiseTurns--;for(;num90DegreeClockwiseTurns<0;)direction2=rotateCounterClockwise(direction2),num90DegreeClockwiseTurns++;return direction2},oppositeSide=sideOrDir=>{if(sideOrDir==="top"||sideOrDir==="up")return"bottom";if(sideOrDir==="bottom"||sideOrDir==="down")return"top";if(sideOrDir==="left")return"right";if(sideOrDir==="right")return"left";throw new Error(`Invalid sideOrDir: ${sideOrDir}`)},transformSchematicElement=(elm,matrix2)=>{if(elm.type==="schematic_component")elm.center=applyToPoint2(matrix2,elm.center);else if(elm.type==="schematic_port")elm.center=applyToPoint2(matrix2,elm.center),elm.facing_direction&&(elm.facing_direction=rotateDirection(elm.facing_direction,-(Math.atan2(matrix2.b,matrix2.a)/Math.PI)*2));else if(elm.type==="schematic_text")elm.position=applyToPoint2(matrix2,elm.position);else if(elm.type==="schematic_trace"){let anyElm=elm;anyElm.route=(anyElm.route??[]).map(rp2=>{let tp=applyToPoint2(matrix2,rp2);return rp2.x=tp.x,rp2.y=tp.y,rp2}),Array.isArray(anyElm.junctions)&&(anyElm.junctions=anyElm.junctions.map(j3=>{let tp=applyToPoint2(matrix2,j3);return j3.x=tp.x,j3.y=tp.y,j3})),Array.isArray(anyElm.edges)&&(anyElm.edges=anyElm.edges.map(e4=>(e4.from=applyToPoint2(matrix2,e4.from),e4.to=applyToPoint2(matrix2,e4.to),e4)))}else if(elm.type==="schematic_box"){let{x:x3,y:y3}=applyToPoint2(matrix2,{x:elm.x,y:elm.y});elm.x=x3,elm.y=y3}else if(elm.type==="schematic_line"){let{x:x12,y:y12}=applyToPoint2(matrix2,{x:elm.x1,y:elm.y1}),{x:x22,y:y22}=applyToPoint2(matrix2,{x:elm.x2,y:elm.y2});elm.x1=x12,elm.y1=y12,elm.x2=x22,elm.y2=y22}return elm},transformSchematicElements=(elms,matrix2)=>elms.map(elm=>transformSchematicElement(elm,matrix2)),transformPCBElement=(elm,matrix2)=>{let tsr=decomposeTSR2(matrix2),flipPadWidthHeight=Math.round(tsr.rotation.angle/(Math.PI/2))%2===1;if(elm.type==="pcb_plated_hole"||elm.type==="pcb_hole"||elm.type==="pcb_via"||elm.type==="pcb_smtpad"||elm.type==="pcb_port"){let{x:x3,y:y3}=applyToPoint2(matrix2,{x:Number(elm.x),y:Number(elm.y)});elm.x=x3,elm.y=y3,elm.type==="pcb_smtpad"&&elm.shape==="polygon"&&Array.isArray(elm.points)&&(elm.points=elm.points.map(point6=>{let tp=applyToPoint2(matrix2,{x:point6.x,y:point6.y});return{x:tp.x,y:tp.y}}))}else if(elm.type==="pcb_keepout"||elm.type==="pcb_board")elm.center=applyToPoint2(matrix2,elm.center);else if(elm.type==="pcb_silkscreen_text"||elm.type==="pcb_fabrication_note_text")elm.anchor_position=applyToPoint2(matrix2,elm.anchor_position);else if(elm.type==="pcb_silkscreen_circle"||elm.type==="pcb_silkscreen_rect")elm.center=applyToPoint2(matrix2,elm.center);else if(elm.type==="pcb_component")elm.center=applyToPoint2(matrix2,elm.center),elm.rotation=elm.rotation+tsr.rotation.angle/Math.PI*180,elm.rotation=elm.rotation%360,flipPadWidthHeight&&([elm.width,elm.height]=[elm.height,elm.width]);else if(elm.type==="pcb_silkscreen_path"||elm.type==="pcb_trace"||elm.type==="pcb_fabrication_note_path")elm.route=elm.route.map(rp2=>{let tp=applyToPoint2(matrix2,rp2);return rp2.x=tp.x,rp2.y=tp.y,rp2});else if(elm.type==="pcb_silkscreen_line"){let p12={x:elm.x1,y:elm.y1},p2={x:elm.x2,y:elm.y2},p1t=applyToPoint2(matrix2,p12),p2t=applyToPoint2(matrix2,p2);elm.x1=p1t.x,elm.y1=p1t.y,elm.x2=p2t.x,elm.y2=p2t.y}else if(elm.type==="cad_component"){let newPos=applyToPoint2(matrix2,{x:elm.position.x,y:elm.position.y});elm.position.x=newPos.x,elm.position.y=newPos.y}return elm},transformPCBElements=(elms,matrix2)=>{let tsr=decomposeTSR2(matrix2),quarterTurns=Math.round(tsr.rotation.angle/(Math.PI/2)),flipPadWidthHeight=Math.abs(quarterTurns)%2===1,transformedElms=elms.map(elm=>transformPCBElement(elm,matrix2));return flipPadWidthHeight&&(transformedElms=transformedElms.map(elm=>(elm.type==="pcb_smtpad"&&elm.shape==="rect"&&([elm.width,elm.height]=[elm.height,elm.width]),elm))),transformedElms},getElementId=elm=>{let type=elm.type;return elm[`${type}_id`]},getElementById2=(soup,id2)=>soup.find(elm=>getElementId(elm)===id2)??null;getReadableNameForPcbPort=(soup,pcb_port_id)=>{let pcbPort=cju(soup).pcb_port.get(pcb_port_id);if(!pcbPort)return`pcb_port[#${pcb_port_id}]`;let pcbComponent=pcbPort.pcb_component_id?cju(soup).pcb_component.get(pcbPort.pcb_component_id):void 0;if(!pcbComponent)return`pcb_port[#${pcb_port_id}]`;let sourceComponent=cju(soup).source_component.get(pcbComponent.source_component_id);if(!sourceComponent)return`pcb_port[#${pcb_port_id}]`;let sourcePort=cju(soup).source_port.get(pcbPort.source_port_id);if(!sourcePort)return`pcb_port[#${pcb_port_id}]`;let padIdentifier;return sourcePort?.port_hints&&sourcePort.port_hints.length>0||sourcePort.port_hints&&sourcePort.port_hints.length>0?padIdentifier=sourcePort.port_hints[0]:padIdentifier=pcb_port_id,`pcb_port[.${sourceComponent.name} > .${padIdentifier}]`};getReadableNameForElement=(soup,elm)=>{if(typeof elm=="string"){let elmObj=getElementById2(soup,elm);return elmObj||`${elm}`,getReadableNameForElement(soup,elmObj)}switch(elm.type){case"pcb_port":return getReadableNameForPcbPort(soup,elm.pcb_port_id);case"pcb_smtpad":return getReadableNameForPcbSmtpad(soup,elm.pcb_smtpad_id);case"pcb_trace":return getReadableNameForPcbTrace(soup,elm.pcb_trace_id);case"source_component":return`source_component[${elm.name}]`;default:return`${elm.type}[#${getElementId(elm)}]`}},getBoundsOfPcbElements=elements=>{let minX=Number.POSITIVE_INFINITY,minY=Number.POSITIVE_INFINITY,maxX=Number.NEGATIVE_INFINITY,maxY=Number.NEGATIVE_INFINITY;for(let elm of elements){if(!elm.type.startsWith("pcb_"))continue;if(elm.type==="pcb_smtpad"&&elm.shape==="polygon"&&Array.isArray(elm.points)){for(let point6 of elm.points)minX=Math.min(minX,point6.x),minY=Math.min(minY,point6.y),maxX=Math.max(maxX,point6.x),maxY=Math.max(maxY,point6.y);continue}let centerX,centerY,width,height;if("x"in elm&&"y"in elm&&(centerX=Number(elm.x),centerY=Number(elm.y)),"outer_diameter"in elm&&(width=Number(elm.outer_diameter),height=Number(elm.outer_diameter)),"width"in elm&&(width=Number(elm.width)),"height"in elm&&(height=Number(elm.height)),"center"in elm&&(centerX=elm.center.x,centerY=elm.center.y),centerX!==void 0&&centerY!==void 0)minX=Math.min(minX,centerX),minY=Math.min(minY,centerY),maxX=Math.max(maxX,centerX),maxY=Math.max(maxY,centerY),width!==void 0&&height!==void 0&&(minX=Math.min(minX,centerX-width/2),minY=Math.min(minY,centerY-height/2),maxX=Math.max(maxX,centerX+width/2),maxY=Math.max(maxY,centerY+height/2)),"radius"in elm&&(minX=Math.min(minX,centerX-elm.radius),minY=Math.min(minY,centerY-elm.radius),maxX=Math.max(maxX,centerX+elm.radius),maxY=Math.max(maxY,centerY+elm.radius));else if(elm.type==="pcb_trace")for(let point6 of elm.route)minX=Math.min(minX,point6.x),minY=Math.min(minY,point6.y),maxX=Math.max(maxX,point6.x),maxY=Math.max(maxY,point6.y)}return{minX,minY,maxX,maxY}};nice_color_palettes=[["#69d2e7","#a7dbd8","#e0e4cc","#f38630","#fa6900"],["#fe4365","#fc9d9a","#f9cdad","#c8c8a9","#83af9b"],["#ecd078","#d95b43","#c02942","#542437","#53777a"],["#556270","#4ecdc4","#c7f464","#ff6b6b","#c44d58"],["#774f38","#e08e79","#f1d4af","#ece5ce","#c5e0dc"],["#e8ddcb","#cdb380","#036564","#033649","#031634"],["#490a3d","#bd1550","#e97f02","#f8ca00","#8a9b0f"],["#594f4f","#547980","#45ada8","#9de0ad","#e5fcc2"],["#00a0b0","#6a4a3c","#cc333f","#eb6841","#edc951"],["#e94e77","#d68189","#c6a49a","#c6e5d9","#f4ead5"],["#3fb8af","#7fc7af","#dad8a7","#ff9e9d","#ff3d7f"],["#d9ceb2","#948c75","#d5ded9","#7a6a53","#99b2b7"],["#ffffff","#cbe86b","#f2e9e1","#1c140d","#cbe86b"],["#efffcd","#dce9be","#555152","#2e2633","#99173c"],["#343838","#005f6b","#008c9e","#00b4cc","#00dffc"],["#413e4a","#73626e","#b38184","#f0b49e","#f7e4be"],["#ff4e50","#fc913a","#f9d423","#ede574","#e1f5c4"],["#99b898","#fecea8","#ff847c","#e84a5f","#2a363b"],["#655643","#80bca3","#f6f7bd","#e6ac27","#bf4d28"],["#00a8c6","#40c0cb","#f9f2e7","#aee239","#8fbe00"],["#351330","#424254","#64908a","#e8caa4","#cc2a41"],["#554236","#f77825","#d3ce3d","#f1efa5","#60b99a"],["#5d4157","#838689","#a8caba","#cad7b2","#ebe3aa"],["#8c2318","#5e8c6a","#88a65e","#bfb35a","#f2c45a"],["#fad089","#ff9c5b","#f5634a","#ed303c","#3b8183"],["#ff4242","#f4fad2","#d4ee5e","#e1edb9","#f0f2eb"],["#f8b195","#f67280","#c06c84","#6c5b7b","#355c7d"],["#d1e751","#ffffff","#000000","#4dbce9","#26ade4"],["#1b676b","#519548","#88c425","#bef202","#eafde6"],["#5e412f","#fcebb6","#78c0a8","#f07818","#f0a830"],["#bcbdac","#cfbe27","#f27435","#f02475","#3b2d38"],["#452632","#91204d","#e4844a","#e8bf56","#e2f7ce"],["#eee6ab","#c5bc8e","#696758","#45484b","#36393b"],["#f0d8a8","#3d1c00","#86b8b1","#f2d694","#fa2a00"],["#2a044a","#0b2e59","#0d6759","#7ab317","#a0c55f"],["#f04155","#ff823a","#f2f26f","#fff7bd","#95cfb7"],["#b9d7d9","#668284","#2a2829","#493736","#7b3b3b"],["#bbbb88","#ccc68d","#eedd99","#eec290","#eeaa88"],["#b3cc57","#ecf081","#ffbe40","#ef746f","#ab3e5b"],["#a3a948","#edb92e","#f85931","#ce1836","#009989"],["#300030","#480048","#601848","#c04848","#f07241"],["#67917a","#170409","#b8af03","#ccbf82","#e33258"],["#aab3ab","#c4cbb7","#ebefc9","#eee0b7","#e8caaf"],["#e8d5b7","#0e2430","#fc3a51","#f5b349","#e8d5b9"],["#ab526b","#bca297","#c5ceae","#f0e2a4","#f4ebc3"],["#607848","#789048","#c0d860","#f0f0d8","#604848"],["#b6d8c0","#c8d9bf","#dadabd","#ecdbbc","#fedcba"],["#a8e6ce","#dcedc2","#ffd3b5","#ffaaa6","#ff8c94"],["#3e4147","#fffedf","#dfba69","#5a2e2e","#2a2c31"],["#fc354c","#29221f","#13747d","#0abfbc","#fcf7c5"],["#cc0c39","#e6781e","#c8cf02","#f8fcc1","#1693a7"],["#1c2130","#028f76","#b3e099","#ffeaad","#d14334"],["#a7c5bd","#e5ddcb","#eb7b59","#cf4647","#524656"],["#dad6ca","#1bb0ce","#4f8699","#6a5e72","#563444"],["#5c323e","#a82743","#e15e32","#c0d23e","#e5f04c"],["#edebe6","#d6e1c7","#94c7b6","#403b33","#d3643b"],["#fdf1cc","#c6d6b8","#987f69","#e3ad40","#fcd036"],["#230f2b","#f21d41","#ebebbc","#bce3c5","#82b3ae"],["#b9d3b0","#81bda4","#b28774","#f88f79","#f6aa93"],["#3a111c","#574951","#83988e","#bcdea5","#e6f9bc"],["#5e3929","#cd8c52","#b7d1a3","#dee8be","#fcf7d3"],["#1c0113","#6b0103","#a30006","#c21a01","#f03c02"],["#000000","#9f111b","#b11623","#292c37","#cccccc"],["#382f32","#ffeaf2","#fcd9e5","#fbc5d8","#f1396d"],["#e3dfba","#c8d6bf","#93ccc6","#6cbdb5","#1a1f1e"],["#f6f6f6","#e8e8e8","#333333","#990100","#b90504"],["#1b325f","#9cc4e4","#e9f2f9","#3a89c9","#f26c4f"],["#a1dbb2","#fee5ad","#faca66","#f7a541","#f45d4c"],["#c1b398","#605951","#fbeec2","#61a6ab","#accec0"],["#5e9fa3","#dcd1b4","#fab87f","#f87e7b","#b05574"],["#951f2b","#f5f4d7","#e0dfb1","#a5a36c","#535233"],["#8dccad","#988864","#fea6a2","#f9d6ac","#ffe9af"],["#2d2d29","#215a6d","#3ca2a2","#92c7a3","#dfece6"],["#413d3d","#040004","#c8ff00","#fa023c","#4b000f"],["#eff3cd","#b2d5ba","#61ada0","#248f8d","#605063"],["#ffefd3","#fffee4","#d0ecea","#9fd6d2","#8b7a5e"],["#cfffdd","#b4dec1","#5c5863","#a85163","#ff1f4c"],["#9dc9ac","#fffec7","#f56218","#ff9d2e","#919167"],["#4e395d","#827085","#8ebe94","#ccfc8e","#dc5b3e"],["#a8a7a7","#cc527a","#e8175d","#474747","#363636"],["#f8edd1","#d88a8a","#474843","#9d9d93","#c5cfc6"],["#046d8b","#309292","#2fb8ac","#93a42a","#ecbe13"],["#f38a8a","#55443d","#a0cab5","#cde9ca","#f1edd0"],["#a70267","#f10c49","#fb6b41","#f6d86b","#339194"],["#ff003c","#ff8a00","#fabe28","#88c100","#00c176"],["#ffedbf","#f7803c","#f54828","#2e0d23","#f8e4c1"],["#4e4d4a","#353432","#94ba65","#2790b0","#2b4e72"],["#0ca5b0","#4e3f30","#fefeeb","#f8f4e4","#a5b3aa"],["#4d3b3b","#de6262","#ffb88c","#ffd0b3","#f5e0d3"],["#fffbb7","#a6f6af","#66b6ab","#5b7c8d","#4f2958"],["#edf6ee","#d1c089","#b3204d","#412e28","#151101"],["#9d7e79","#ccac95","#9a947c","#748b83","#5b756c"],["#fcfef5","#e9ffe1","#cdcfb7","#d6e6c3","#fafbe3"],["#9cddc8","#bfd8ad","#ddd9ab","#f7af63","#633d2e"],["#30261c","#403831","#36544f","#1f5f61","#0b8185"],["#aaff00","#ffaa00","#ff00aa","#aa00ff","#00aaff"],["#d1313d","#e5625c","#f9bf76","#8eb2c5","#615375"],["#ffe181","#eee9e5","#fad3b2","#ffba7f","#ff9c97"],["#73c8a9","#dee1b6","#e1b866","#bd5532","#373b44"],["#805841","#dcf7f3","#fffcdd","#ffd8d8","#f5a2a2"]],getDebugLayoutObject=lo3=>{let{x:x3,y:y3,width,height}={...lo3,...lo3.size,...lo3.center,...lo3.position};if(lo3.x1!==void 0&&lo3.x2!==void 0&&lo3.y1!==void 0&&lo3.y2!==void 0&&(x3=(lo3.x1+lo3.x2)/2,y3=(lo3.y1+lo3.y2)/2,width=Math.abs(lo3.x1-lo3.x2),height=Math.abs(lo3.y1-lo3.y2)),lo3.points&&Array.isArray(lo3.points)&&lo3.points.length>0){let xCoords=lo3.points.map(point6=>point6.x),yCoords=lo3.points.map(point6=>point6.y),minX=Math.min(...xCoords),maxX=Math.max(...xCoords),minY=Math.min(...yCoords),maxY=Math.max(...yCoords);x3=(minX+maxX)/2,y3=(minY+maxY)/2,width=maxX-minX,height=maxY-minY}let title=lo3.text||lo3.name||lo3.source?.text||lo3.source?.name||"?",content=lo3;return x3===void 0||y3===void 0?null:(width===void 0&&"outer_diameter"in lo3&&(width=lo3.outer_diameter,height=lo3.outer_diameter),(width===void 0||height===void 0)&&(width=.1,height=.1),{x:x3,y:y3,width,height,title,content,bg_color:nice_color_palettes[stringHash(lo3.type||title)%nice_color_palettes.length]?.[4]??"#f00"})},isTruthy=value=>!!value,findBoundsAndCenter=elements=>{let debugObjects=elements.filter(elm=>elm.type.startsWith("pcb_")||elm.type.startsWith("schematic_")).concat(elements.filter(elm=>elm.type==="pcb_trace"||elm.type==="schematic_trace").flatMap(elm=>elm.route)).map(elm=>getDebugLayoutObject(elm)).filter(isTruthy);if(debugObjects.length===0)return{center:{x:0,y:0},width:0,height:0};let minX=debugObjects[0].x-debugObjects[0].width/2,maxX=debugObjects[0].x+debugObjects[0].width/2,minY=debugObjects[0].y-debugObjects[0].height/2,maxY=debugObjects[0].y+debugObjects[0].height/2;for(let obj of debugObjects.slice(1))minX=Math.min(minX,obj.x-obj.width/2),maxX=Math.max(maxX,obj.x+obj.width/2),minY=Math.min(minY,obj.y-obj.height/2),maxY=Math.max(maxY,obj.y+obj.height/2);let width=maxX-minX,height=maxY-minY;return{center:{x:minX+width/2,y:minY+height/2},width,height}},getPrimaryId=element=>element[`${element.type}_id`],repositionPcbComponentTo=(circuitJson,pcb_component_id,newCenter)=>{let pcbComponent=circuitJson.find(e4=>e4.type==="pcb_component"&&e4.pcb_component_id===pcb_component_id);if(!pcbComponent)return;let currentCenter="center"in pcbComponent?pcbComponent.center:{x:pcbComponent.x,y:pcbComponent.y},dx2=newCenter.x-currentCenter.x,dy2=newCenter.y-currentCenter.y,portIds=circuitJson.filter(e4=>e4.type==="pcb_port"&&e4.pcb_component_id===pcb_component_id).map(e4=>e4.pcb_port_id),elementsToMove=circuitJson.filter(elm=>{if(elm===pcbComponent)return!0;let anyElm=elm;return!!(anyElm.pcb_component_id===pcb_component_id||Array.isArray(anyElm.pcb_component_ids)&&anyElm.pcb_component_ids.includes(pcb_component_id)||anyElm.pcb_port_id&&portIds.includes(anyElm.pcb_port_id)||Array.isArray(anyElm.pcb_port_ids)&&anyElm.pcb_port_ids.some(id2=>portIds.includes(id2))||anyElm.start_pcb_port_id&&portIds.includes(anyElm.start_pcb_port_id)||anyElm.end_pcb_port_id&&portIds.includes(anyElm.end_pcb_port_id)||Array.isArray(anyElm.route)&&anyElm.route.some(pt3=>pt3.start_pcb_port_id&&portIds.includes(pt3.start_pcb_port_id)||pt3.end_pcb_port_id&&portIds.includes(pt3.end_pcb_port_id)))}),matrix2=translate2(dx2,dy2);transformPCBElements(elementsToMove,matrix2)},findAllDescendantGroupIds=(circuitJson,parentGroupId)=>{let childGroupIds=[],directChildren=circuitJson.filter(elm=>elm.type==="source_group"&&elm.parent_source_group_id===parentGroupId).map(elm=>elm.source_group_id);childGroupIds.push(...directChildren);for(let childId of directChildren)childGroupIds.push(...findAllDescendantGroupIds(circuitJson,childId));return childGroupIds},repositionPcbGroupTo=(circuitJson,source_group_id,newCenter)=>{let allGroupIds=[source_group_id,...findAllDescendantGroupIds(circuitJson,source_group_id)],allGroupElements=new Set;for(let groupId of allGroupIds)buildSubtree(circuitJson,{source_group_id:groupId}).forEach(elm=>allGroupElements.add(elm));let portIds=Array.from(allGroupElements).filter(e4=>e4.type==="pcb_port").map(e4=>e4.pcb_port_id);circuitJson.filter(elm=>{if(elm.type!=="pcb_trace"||allGroupElements.has(elm))return!1;let anyElm=elm;return!!(anyElm.start_pcb_port_id&&portIds.includes(anyElm.start_pcb_port_id)||anyElm.end_pcb_port_id&&portIds.includes(anyElm.end_pcb_port_id)||Array.isArray(anyElm.route)&&anyElm.route.some(pt3=>pt3.start_pcb_port_id&&portIds.includes(pt3.start_pcb_port_id)||pt3.end_pcb_port_id&&portIds.includes(pt3.end_pcb_port_id)))}).forEach(trace=>allGroupElements.add(trace));let pcbElements=Array.from(allGroupElements).filter(elm=>elm.type.startsWith("pcb_"));if(pcbElements.length===0)return;let{center:currentCenter}=findBoundsAndCenter(pcbElements),dx2=newCenter.x-currentCenter.x,dy2=newCenter.y-currentCenter.y,matrix2=translate2(dx2,dy2);transformPCBElements(pcbElements,matrix2)},repositionSchematicComponentTo=(circuitJson,schematic_component_id,newCenter)=>{let schematicComponent=circuitJson.find(e4=>e4.type==="schematic_component"&&e4.schematic_component_id===schematic_component_id);if(!schematicComponent)return;let currentCenter="center"in schematicComponent?schematicComponent.center:{x:schematicComponent.x,y:schematicComponent.y},dx2=newCenter.x-currentCenter.x,dy2=newCenter.y-currentCenter.y,portIds=circuitJson.filter(e4=>e4.type==="schematic_port"&&e4.schematic_component_id===schematic_component_id).map(e4=>e4.schematic_port_id),elementsToMove=circuitJson.filter(elm=>{if(elm===schematicComponent)return!0;let anyElm=elm;return!!(anyElm.schematic_component_id===schematic_component_id||Array.isArray(anyElm.schematic_component_ids)&&anyElm.schematic_component_ids.includes(schematic_component_id)||anyElm.schematic_port_id&&portIds.includes(anyElm.schematic_port_id)||Array.isArray(anyElm.schematic_port_ids)&&anyElm.schematic_port_ids.some(id2=>portIds.includes(id2))||anyElm.start_schematic_port_id&&portIds.includes(anyElm.start_schematic_port_id)||anyElm.end_schematic_port_id&&portIds.includes(anyElm.end_schematic_port_id)||Array.isArray(anyElm.route)&&anyElm.route.some(pt3=>pt3.start_schematic_port_id&&portIds.includes(pt3.start_schematic_port_id)||pt3.end_schematic_port_id&&portIds.includes(pt3.end_schematic_port_id)))}),matrix2=translate2(dx2,dy2);transformSchematicElements(elementsToMove,matrix2)},findAllDescendantGroupIds2=(circuitJson,parentGroupId)=>{let childGroupIds=[],directChildren=circuitJson.filter(elm=>elm.type==="source_group"&&elm.parent_source_group_id===parentGroupId).map(elm=>elm.source_group_id);childGroupIds.push(...directChildren);for(let childId of directChildren)childGroupIds.push(...findAllDescendantGroupIds2(circuitJson,childId));return childGroupIds},repositionSchematicGroupTo=(circuitJson,source_group_id,newCenter)=>{let allGroupIds=[source_group_id,...findAllDescendantGroupIds2(circuitJson,source_group_id)],allGroupElements=new Set;for(let groupId of allGroupIds)buildSubtree(circuitJson,{source_group_id:groupId}).forEach(elm=>allGroupElements.add(elm));let portIds=Array.from(allGroupElements).filter(e4=>e4.type==="schematic_port").map(e4=>e4.schematic_port_id);circuitJson.filter(elm=>{if(elm.type!=="schematic_trace"||allGroupElements.has(elm))return!1;let anyElm=elm;return!!(anyElm.start_schematic_port_id&&portIds.includes(anyElm.start_schematic_port_id)||anyElm.end_schematic_port_id&&portIds.includes(anyElm.end_schematic_port_id)||Array.isArray(anyElm.route)&&anyElm.route.some(pt3=>pt3.start_schematic_port_id&&portIds.includes(pt3.start_schematic_port_id)||pt3.end_schematic_port_id&&portIds.includes(pt3.end_schematic_port_id)))}).forEach(trace=>allGroupElements.add(trace));let schematicElements=Array.from(allGroupElements).filter(elm=>elm.type.startsWith("schematic_"));if(schematicElements.length===0)return;let{center:currentCenter}=findBoundsAndCenter(schematicElements),dx2=newCenter.x-currentCenter.x,dy2=newCenter.y-currentCenter.y,matrix2=translate2(dx2,dy2);transformSchematicElements(schematicElements,matrix2)},getCircuitJsonTree=(circuitJson,opts)=>{let groupChildMap=new Map,existingGroupIds=new Set;for(let elm of circuitJson)elm.type==="source_group"&&existingGroupIds.add(elm.source_group_id);let orphanedGroups=[];for(let elm of circuitJson)if(elm.type==="source_group"&&elm.parent_source_group_id){let parentId=elm.parent_source_group_id,childId=elm.source_group_id;if(!existingGroupIds.has(parentId))orphanedGroups.push(childId),groupChildMap.has(childId)||groupChildMap.set(childId,[]);else{let children=groupChildMap.get(parentId)??[];children.push(childId),groupChildMap.set(parentId,children),groupChildMap.has(childId)||groupChildMap.set(childId,[])}}for(let elm of circuitJson)elm.type==="source_group"&&!groupChildMap.has(elm.source_group_id)&&groupChildMap.set(elm.source_group_id,[]);let groupNodes=new Map,getNextGroupId=()=>{for(let[parentId,children]of groupChildMap)if(!groupNodes.has(parentId)&&children.every(childId=>groupNodes.has(childId)))return parentId;return null},lastGroupId=null;for(;;){let nextGroupId=getNextGroupId();if(!nextGroupId)break;let node={nodeType:"group",sourceGroup:circuitJson.find(elm=>elm.type==="source_group"&&elm.source_group_id===nextGroupId),otherChildElements:[],childNodes:[...groupChildMap.get(nextGroupId)?.map(childId=>groupNodes.get(childId))??[],...circuitJson.filter(elm=>elm.type==="source_component"&&elm.source_group_id===nextGroupId).map(elm=>({nodeType:"component",sourceComponent:elm,childNodes:[],otherChildElements:[...circuitJson.filter(e4=>e4.type==="pcb_component"&&e4.source_component_id===elm.source_component_id)]}))]};groupNodes.set(nextGroupId,node),lastGroupId=nextGroupId}if(!lastGroupId)return console.warn("No groups were processed, returning tree without sourceGroup"),{nodeType:"group",childNodes:[],otherChildElements:circuitJson};let rootGroupId=null;return opts&&opts.source_group_id!==void 0?rootGroupId=opts.source_group_id:orphanedGroups.length>0?rootGroupId=orphanedGroups[0]:rootGroupId=lastGroupId,rootGroupId?groupNodes.get(rootGroupId):(console.warn("No valid root group found, returning tree without sourceGroup"),{nodeType:"group",childNodes:[],otherChildElements:circuitJson})}}});var require_object_hash=__commonJS({"node_modules/object-hash/dist/object_hash.js"(exports,module){"use strict";(function(e4){var t5;typeof exports=="object"?module.exports=e4():typeof define=="function"&&define.amd?define(e4):(typeof window<"u"?t5=window:typeof global<"u"?t5=global:typeof self<"u"&&(t5=self),t5.objectHash=e4())})(function(){return(function r4(o4,i3,u4){function s3(n3,e5){if(!i3[n3]){if(!o4[n3]){var t5=typeof __require=="function"&&__require;if(!e5&&t5)return t5(n3,!0);if(a2)return a2(n3,!0);throw new Error("Cannot find module '"+n3+"'")}e5=i3[n3]={exports:{}},o4[n3][0].call(e5.exports,function(e6){var t7=o4[n3][1][e6];return s3(t7||e6)},e5,e5.exports,r4,o4,i3,u4)}return i3[n3].exports}for(var a2=typeof __require=="function"&&__require,e4=0;e4<u4.length;e4++)s3(u4[e4]);return s3})({1:[function(w4,b3,m3){(function(e4,n3,s3,c3,d3,h2,p2,g4,y3){"use strict";var r4=w4("crypto");function t5(e5,t7){t7=u4(e5,t7);var n4;return(n4=t7.algorithm!=="passthrough"?r4.createHash(t7.algorithm):new l2).write===void 0&&(n4.write=n4.update,n4.end=n4.update),f2(t7,n4).dispatch(e5),n4.update||n4.end(""),n4.digest?n4.digest(t7.encoding==="buffer"?void 0:t7.encoding):(e5=n4.read(),t7.encoding!=="buffer"?e5.toString(t7.encoding):e5)}(m3=b3.exports=t5).sha1=function(e5){return t5(e5)},m3.keys=function(e5){return t5(e5,{excludeValues:!0,algorithm:"sha1",encoding:"hex"})},m3.MD5=function(e5){return t5(e5,{algorithm:"md5",encoding:"hex"})},m3.keysMD5=function(e5){return t5(e5,{algorithm:"md5",encoding:"hex",excludeValues:!0})};var o4=r4.getHashes?r4.getHashes().slice():["sha1","md5"],i3=(o4.push("passthrough"),["buffer","hex","binary","base64"]);function u4(e5,t7){var n4={};if(n4.algorithm=(t7=t7||{}).algorithm||"sha1",n4.encoding=t7.encoding||"hex",n4.excludeValues=!!t7.excludeValues,n4.algorithm=n4.algorithm.toLowerCase(),n4.encoding=n4.encoding.toLowerCase(),n4.ignoreUnknown=t7.ignoreUnknown===!0,n4.respectType=t7.respectType!==!1,n4.respectFunctionNames=t7.respectFunctionNames!==!1,n4.respectFunctionProperties=t7.respectFunctionProperties!==!1,n4.unorderedArrays=t7.unorderedArrays===!0,n4.unorderedSets=t7.unorderedSets!==!1,n4.unorderedObjects=t7.unorderedObjects!==!1,n4.replacer=t7.replacer||void 0,n4.excludeKeys=t7.excludeKeys||void 0,e5===void 0)throw new Error("Object argument required.");for(var r6=0;r6<o4.length;++r6)o4[r6].toLowerCase()===n4.algorithm.toLowerCase()&&(n4.algorithm=o4[r6]);if(o4.indexOf(n4.algorithm)===-1)throw new Error('Algorithm "'+n4.algorithm+'" not supported. supported values: '+o4.join(", "));if(i3.indexOf(n4.encoding)===-1&&n4.algorithm!=="passthrough")throw new Error('Encoding "'+n4.encoding+'" not supported. supported values: '+i3.join(", "));return n4}function a2(e5){if(typeof e5=="function")return/^function\s+\w*\s*\(\s*\)\s*{\s+\[native code\]\s+}$/i.exec(Function.prototype.toString.call(e5))!=null}function f2(o5,t7,i4){i4=i4||[];function u5(e5){return t7.update?t7.update(e5,"utf8"):t7.write(e5,"utf8")}return{dispatch:function(e5){return this["_"+((e5=o5.replacer?o5.replacer(e5):e5)===null?"null":typeof e5)](e5)},_object:function(t8){var n4,e5=Object.prototype.toString.call(t8),r6=/\[object (.*)\]/i.exec(e5);if(r6=(r6=r6?r6[1]:"unknown:["+e5+"]").toLowerCase(),0<=(e5=i4.indexOf(t8)))return this.dispatch("[CIRCULAR:"+e5+"]");if(i4.push(t8),s3!==void 0&&s3.isBuffer&&s3.isBuffer(t8))return u5("buffer:"),u5(t8);if(r6==="object"||r6==="function"||r6==="asyncfunction")return e5=Object.keys(t8),o5.unorderedObjects&&(e5=e5.sort()),o5.respectType===!1||a2(t8)||e5.splice(0,0,"prototype","__proto__","constructor"),o5.excludeKeys&&(e5=e5.filter(function(e6){return!o5.excludeKeys(e6)})),u5("object:"+e5.length+":"),n4=this,e5.forEach(function(e6){n4.dispatch(e6),u5(":"),o5.excludeValues||n4.dispatch(t8[e6]),u5(",")});if(!this["_"+r6]){if(o5.ignoreUnknown)return u5("["+r6+"]");throw new Error('Unknown object type "'+r6+'"')}this["_"+r6](t8)},_array:function(e5,t8){t8=t8!==void 0?t8:o5.unorderedArrays!==!1;var n4=this;if(u5("array:"+e5.length+":"),!t8||e5.length<=1)return e5.forEach(function(e6){return n4.dispatch(e6)});var r6=[],t8=e5.map(function(e6){var t10=new l2,n5=i4.slice();return f2(o5,t10,n5).dispatch(e6),r6=r6.concat(n5.slice(i4.length)),t10.read().toString()});return i4=i4.concat(r6),t8.sort(),this._array(t8,!1)},_date:function(e5){return u5("date:"+e5.toJSON())},_symbol:function(e5){return u5("symbol:"+e5.toString())},_error:function(e5){return u5("error:"+e5.toString())},_boolean:function(e5){return u5("bool:"+e5.toString())},_string:function(e5){u5("string:"+e5.length+":"),u5(e5.toString())},_function:function(e5){u5("fn:"),a2(e5)?this.dispatch("[native]"):this.dispatch(e5.toString()),o5.respectFunctionNames!==!1&&this.dispatch("function-name:"+String(e5.name)),o5.respectFunctionProperties&&this._object(e5)},_number:function(e5){return u5("number:"+e5.toString())},_xml:function(e5){return u5("xml:"+e5.toString())},_null:function(){return u5("Null")},_undefined:function(){return u5("Undefined")},_regexp:function(e5){return u5("regex:"+e5.toString())},_uint8array:function(e5){return u5("uint8array:"),this.dispatch(Array.prototype.slice.call(e5))},_uint8clampedarray:function(e5){return u5("uint8clampedarray:"),this.dispatch(Array.prototype.slice.call(e5))},_int8array:function(e5){return u5("int8array:"),this.dispatch(Array.prototype.slice.call(e5))},_uint16array:function(e5){return u5("uint16array:"),this.dispatch(Array.prototype.slice.call(e5))},_int16array:function(e5){return u5("int16array:"),this.dispatch(Array.prototype.slice.call(e5))},_uint32array:function(e5){return u5("uint32array:"),this.dispatch(Array.prototype.slice.call(e5))},_int32array:function(e5){return u5("int32array:"),this.dispatch(Array.prototype.slice.call(e5))},_float32array:function(e5){return u5("float32array:"),this.dispatch(Array.prototype.slice.call(e5))},_float64array:function(e5){return u5("float64array:"),this.dispatch(Array.prototype.slice.call(e5))},_arraybuffer:function(e5){return u5("arraybuffer:"),this.dispatch(new Uint8Array(e5))},_url:function(e5){return u5("url:"+e5.toString())},_map:function(e5){return u5("map:"),e5=Array.from(e5),this._array(e5,o5.unorderedSets!==!1)},_set:function(e5){return u5("set:"),e5=Array.from(e5),this._array(e5,o5.unorderedSets!==!1)},_file:function(e5){return u5("file:"),this.dispatch([e5.name,e5.size,e5.type,e5.lastModfied])},_blob:function(){if(o5.ignoreUnknown)return u5("[blob]");throw Error(`Hashing Blob objects is currently not supported
211
211
  (see https://github.com/puleos/object-hash/issues/26)
212
212
  Use "options.replacer" or "options.ignoreUnknown"
213
213
  `)},_domwindow:function(){return u5("domwindow")},_bigint:function(e5){return u5("bigint:"+e5.toString())},_process:function(){return u5("process")},_timer:function(){return u5("timer")},_pipe:function(){return u5("pipe")},_tcp:function(){return u5("tcp")},_udp:function(){return u5("udp")},_tty:function(){return u5("tty")},_statwatcher:function(){return u5("statwatcher")},_securecontext:function(){return u5("securecontext")},_connection:function(){return u5("connection")},_zlib:function(){return u5("zlib")},_context:function(){return u5("context")},_nodescript:function(){return u5("nodescript")},_httpparser:function(){return u5("httpparser")},_dataview:function(){return u5("dataview")},_signal:function(){return u5("signal")},_fsevent:function(){return u5("fsevent")},_tlswrap:function(){return u5("tlswrap")}}}function l2(){return{buf:"",write:function(e5){this.buf+=e5},end:function(e5){this.buf+=e5},read:function(){return this.buf}}}m3.writeToStream=function(e5,t7,n4){return n4===void 0&&(n4=t7,t7={}),f2(t7=u4(e5,t7),n4).dispatch(e5)}}).call(this,w4("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},w4("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/fake_9a5aa49d.js","/")},{buffer:3,crypto:5,lYpoI2:11}],2:[function(e4,t5,f2){(function(e5,t7,n3,r4,o4,i3,u4,s3,a2){(function(e6){"use strict";var a3=typeof Uint8Array<"u"?Uint8Array:Array,t8=43,n4=47,r6=48,o5=97,i4=65,u5=45,s4=95;function f4(e7){return e7=e7.charCodeAt(0),e7===t8||e7===u5?62:e7===n4||e7===s4?63:e7<r6?-1:e7<r6+10?e7-r6+26+26:e7<i4+26?e7-i4:e7<o5+26?e7-o5+26:void 0}e6.toByteArray=function(e7){var t10,n5;if(0<e7.length%4)throw new Error("Invalid string. Length must be a multiple of 4");var r7=e7.length,r7=e7.charAt(r7-2)==="="?2:e7.charAt(r7-1)==="="?1:0,o6=new a3(3*e7.length/4-r7),i5=0<r7?e7.length-4:e7.length,u6=0;function s5(e8){o6[u6++]=e8}for(t10=0;t10<i5;t10+=4,0)s5((16711680&(n5=f4(e7.charAt(t10))<<18|f4(e7.charAt(t10+1))<<12|f4(e7.charAt(t10+2))<<6|f4(e7.charAt(t10+3))))>>16),s5((65280&n5)>>8),s5(255&n5);return r7==2?s5(255&(n5=f4(e7.charAt(t10))<<2|f4(e7.charAt(t10+1))>>4)):r7==1&&(s5((n5=f4(e7.charAt(t10))<<10|f4(e7.charAt(t10+1))<<4|f4(e7.charAt(t10+2))>>2)>>8&255),s5(255&n5)),o6},e6.fromByteArray=function(e7){var t10,n5,r7,o6,i5=e7.length%3,u6="";function s5(e8){return"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(e8)}for(t10=0,r7=e7.length-i5;t10<r7;t10+=3)n5=(e7[t10]<<16)+(e7[t10+1]<<8)+e7[t10+2],u6+=s5((o6=n5)>>18&63)+s5(o6>>12&63)+s5(o6>>6&63)+s5(63&o6);switch(i5){case 1:u6=(u6+=s5((n5=e7[e7.length-1])>>2))+s5(n5<<4&63)+"==";break;case 2:u6=(u6=(u6+=s5((n5=(e7[e7.length-2]<<8)+e7[e7.length-1])>>10))+s5(n5>>4&63))+s5(n5<<2&63)+"="}return u6}})(f2===void 0?this.base64js={}:f2)}).call(this,e4("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},e4("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/base64-js/lib/b64.js","/node_modules/gulp-browserify/node_modules/base64-js/lib")},{buffer:3,lYpoI2:11}],3:[function(O4,e4,H3){(function(e5,n3,f2,r4,h2,p2,g4,y3,w4){var a2=O4("base64-js"),i3=O4("ieee754");function f2(e6,t7,n4){if(!(this instanceof f2))return new f2(e6,t7,n4);var r6,o5,i4,u5,s4=typeof e6;if(t7==="base64"&&s4=="string")for(e6=(u5=e6).trim?u5.trim():u5.replace(/^\s+|\s+$/g,"");e6.length%4!=0;)e6+="=";if(s4=="number")r6=j3(e6);else if(s4=="string")r6=f2.byteLength(e6,t7);else{if(s4!="object")throw new Error("First argument needs to be a number, array or string.");r6=j3(e6.length)}if(f2._useTypedArrays?o5=f2._augment(new Uint8Array(r6)):((o5=this).length=r6,o5._isBuffer=!0),f2._useTypedArrays&&typeof e6.byteLength=="number")o5._set(e6);else if(C3(u5=e6)||f2.isBuffer(u5)||u5&&typeof u5=="object"&&typeof u5.length=="number")for(i4=0;i4<r6;i4++)f2.isBuffer(e6)?o5[i4]=e6.readUInt8(i4):o5[i4]=e6[i4];else if(s4=="string")o5.write(e6,0,t7);else if(s4=="number"&&!f2._useTypedArrays&&!n4)for(i4=0;i4<r6;i4++)o5[i4]=0;return o5}function b3(e6,t7,n4,r6){return f2._charsWritten=c3((function(e7){for(var t8=[],n5=0;n5<e7.length;n5++)t8.push(255&e7.charCodeAt(n5));return t8})(t7),e6,n4,r6)}function m3(e6,t7,n4,r6){return f2._charsWritten=c3((function(e7){for(var t8,n5,r7=[],o5=0;o5<e7.length;o5++)n5=e7.charCodeAt(o5),t8=n5>>8,n5=n5%256,r7.push(n5),r7.push(t8);return r7})(t7),e6,n4,r6)}function v4(e6,t7,n4){var r6="";n4=Math.min(e6.length,n4);for(var o5=t7;o5<n4;o5++)r6+=String.fromCharCode(e6[o5]);return r6}function o4(e6,t7,n4,r6){r6||(d3(typeof n4=="boolean","missing or invalid endian"),d3(t7!=null,"missing offset"),d3(t7+1<e6.length,"Trying to read beyond buffer length"));var o5,r6=e6.length;if(!(r6<=t7))return n4?(o5=e6[t7],t7+1<r6&&(o5|=e6[t7+1]<<8)):(o5=e6[t7]<<8,t7+1<r6&&(o5|=e6[t7+1])),o5}function u4(e6,t7,n4,r6){r6||(d3(typeof n4=="boolean","missing or invalid endian"),d3(t7!=null,"missing offset"),d3(t7+3<e6.length,"Trying to read beyond buffer length"));var o5,r6=e6.length;if(!(r6<=t7))return n4?(t7+2<r6&&(o5=e6[t7+2]<<16),t7+1<r6&&(o5|=e6[t7+1]<<8),o5|=e6[t7],t7+3<r6&&(o5+=e6[t7+3]<<24>>>0)):(t7+1<r6&&(o5=e6[t7+1]<<16),t7+2<r6&&(o5|=e6[t7+2]<<8),t7+3<r6&&(o5|=e6[t7+3]),o5+=e6[t7]<<24>>>0),o5}function _4(e6,t7,n4,r6){if(r6||(d3(typeof n4=="boolean","missing or invalid endian"),d3(t7!=null,"missing offset"),d3(t7+1<e6.length,"Trying to read beyond buffer length")),!(e6.length<=t7))return r6=o4(e6,t7,n4,!0),32768&r6?-1*(65535-r6+1):r6}function E3(e6,t7,n4,r6){if(r6||(d3(typeof n4=="boolean","missing or invalid endian"),d3(t7!=null,"missing offset"),d3(t7+3<e6.length,"Trying to read beyond buffer length")),!(e6.length<=t7))return r6=u4(e6,t7,n4,!0),2147483648&r6?-1*(4294967295-r6+1):r6}function I4(e6,t7,n4,r6){return r6||(d3(typeof n4=="boolean","missing or invalid endian"),d3(t7+3<e6.length,"Trying to read beyond buffer length")),i3.read(e6,t7,n4,23,4)}function A4(e6,t7,n4,r6){return r6||(d3(typeof n4=="boolean","missing or invalid endian"),d3(t7+7<e6.length,"Trying to read beyond buffer length")),i3.read(e6,t7,n4,52,8)}function s3(e6,t7,n4,r6,o5){if(o5||(d3(t7!=null,"missing value"),d3(typeof r6=="boolean","missing or invalid endian"),d3(n4!=null,"missing offset"),d3(n4+1<e6.length,"trying to write beyond buffer length"),Y4(t7,65535)),o5=e6.length,!(o5<=n4))for(var i4=0,u5=Math.min(o5-n4,2);i4<u5;i4++)e6[n4+i4]=(t7&255<<8*(r6?i4:1-i4))>>>8*(r6?i4:1-i4)}function l2(e6,t7,n4,r6,o5){if(o5||(d3(t7!=null,"missing value"),d3(typeof r6=="boolean","missing or invalid endian"),d3(n4!=null,"missing offset"),d3(n4+3<e6.length,"trying to write beyond buffer length"),Y4(t7,4294967295)),o5=e6.length,!(o5<=n4))for(var i4=0,u5=Math.min(o5-n4,4);i4<u5;i4++)e6[n4+i4]=t7>>>8*(r6?i4:3-i4)&255}function B3(e6,t7,n4,r6,o5){o5||(d3(t7!=null,"missing value"),d3(typeof r6=="boolean","missing or invalid endian"),d3(n4!=null,"missing offset"),d3(n4+1<e6.length,"Trying to write beyond buffer length"),F4(t7,32767,-32768)),e6.length<=n4||s3(e6,0<=t7?t7:65535+t7+1,n4,r6,o5)}function L3(e6,t7,n4,r6,o5){o5||(d3(t7!=null,"missing value"),d3(typeof r6=="boolean","missing or invalid endian"),d3(n4!=null,"missing offset"),d3(n4+3<e6.length,"Trying to write beyond buffer length"),F4(t7,2147483647,-2147483648)),e6.length<=n4||l2(e6,0<=t7?t7:4294967295+t7+1,n4,r6,o5)}function U5(e6,t7,n4,r6,o5){o5||(d3(t7!=null,"missing value"),d3(typeof r6=="boolean","missing or invalid endian"),d3(n4!=null,"missing offset"),d3(n4+3<e6.length,"Trying to write beyond buffer length"),D4(t7,34028234663852886e22,-34028234663852886e22)),e6.length<=n4||i3.write(e6,t7,n4,r6,23,4)}function x3(e6,t7,n4,r6,o5){o5||(d3(t7!=null,"missing value"),d3(typeof r6=="boolean","missing or invalid endian"),d3(n4!=null,"missing offset"),d3(n4+7<e6.length,"Trying to write beyond buffer length"),D4(t7,17976931348623157e292,-17976931348623157e292)),e6.length<=n4||i3.write(e6,t7,n4,r6,52,8)}H3.Buffer=f2,H3.SlowBuffer=f2,H3.INSPECT_MAX_BYTES=50,f2.poolSize=8192,f2._useTypedArrays=(function(){try{var e6=new ArrayBuffer(0),t7=new Uint8Array(e6);return t7.foo=function(){return 42},t7.foo()===42&&typeof t7.subarray=="function"}catch{return!1}})(),f2.isEncoding=function(e6){switch(String(e6).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},f2.isBuffer=function(e6){return!(e6==null||!e6._isBuffer)},f2.byteLength=function(e6,t7){var n4;switch(e6+="",t7||"utf8"){case"hex":n4=e6.length/2;break;case"utf8":case"utf-8":n4=T5(e6).length;break;case"ascii":case"binary":case"raw":n4=e6.length;break;case"base64":n4=M5(e6).length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":n4=2*e6.length;break;default:throw new Error("Unknown encoding")}return n4},f2.concat=function(e6,t7){if(d3(C3(e6),`Usage: Buffer.concat(list, [totalLength])
@@ -612,7 +612,7 @@ ${error.stack}`),asyncEffect.complete=!0,"root"in this&&this.root&&this.root.emi
612
612
  `||ch2==="\r"){i3++;continue}if(isDigit(ch2)||ch2==="."&&i3+1<expr.length&&isDigit(expr[i3+1])){let start=i3;for(i3++;i3<expr.length;){let c3=expr[i3];if(isDigit(c3)||c3===".")i3++;else break}let numberText=expr.slice(start,i3),num=Number(numberText);if(Number.isNaN(num))throw new Error(`Invalid number: "${numberText}"`);let unitStart=i3;for(;i3<expr.length&&/[A-Za-z]/.test(expr[i3]);)i3++;if(i3>unitStart){let unitText=expr.slice(unitStart,i3),factor=units[unitText];if(factor==null)throw new Error(`Unknown unit: "${unitText}"`);num*=factor}tokens.push({type:"number",value:num});continue}if(isIdentStart(ch2)){let start=i3;for(i3++;i3<expr.length&&isIdentChar(expr[i3]);)i3++;let ident=expr.slice(start,i3);tokens.push({type:"identifier",value:ident});continue}if(ch2==="("||ch2===")"){tokens.push({type:"paren",value:ch2}),i3++;continue}if(ch2==="+"||ch2==="-"||ch2==="*"||ch2==="/"){tokens.push({type:"operator",value:ch2}),i3++;continue}throw new Error(`Unexpected character "${ch2}" in expression "${expr}"`)}return tokens}function parseExpression(tokens,vars){let index=0,peek=()=>tokens[index],consume=()=>tokens[index++],parsePrimary=()=>{let token=peek();if(!token)throw new Error("Unexpected end of expression");if(token.type==="number")return consume(),token.value;if(token.type==="identifier"){consume();let value=vars[token.value];if(value==null)throw new Error(`Unknown variable: "${token.value}"`);return value}if(token.type==="paren"&&token.value==="("){consume();let value=parseExpr(),next2=peek();if(!next2||next2.type!=="paren"||next2.value!==")")throw new Error('Expected ")"');return consume(),value}throw new Error(`Unexpected token "${token.value}"`)},parseFactor=()=>{let token=peek();if(token&&token.type==="operator"&&(token.value==="+"||token.value==="-")){consume();let value=parseFactor();return token.value==="+"?value:-value}return parsePrimary()},parseTerm=()=>{let value=parseFactor();for(;;){let token=peek();if(!token||token.type!=="operator"||token.value!=="*"&&token.value!=="/")break;consume();let rhs=parseFactor();token.value==="*"?value*=rhs:value/=rhs}return value},parseExpr=()=>{let value=parseTerm();for(;;){let token=peek();if(!token||token.type!=="operator"||token.value!=="+"&&token.value!=="-")break;consume();let rhs=parseTerm();token.value==="+"?value+=rhs:value-=rhs}return value},result=parseExpr();if(index<tokens.length){let leftover=tokens.slice(index).map(t5=>"value"in t5?t5.value:"?").join(" ");throw new Error(`Unexpected tokens at end of expression: ${leftover}`)}return result}var cssSelectPrimitiveComponentAdapter={isTag:node=>!0,getParent:node=>node.parent,getChildren:node=>node.children,getName:node=>node.lowercaseComponentName,getAttributeValue:(node,name)=>{if(name==="class"&&"getNameAndAliases"in node)return node.getNameAndAliases().join(" ");if(name==="name"&&node._parsedProps?.name)return node._parsedProps.name;if(node._parsedProps&&name in node._parsedProps){let value=node._parsedProps[name];return typeof value=="string"?value:value!=null?String(value):null}if(name in node){let value=node[name];return typeof value=="string"?value:value!=null?String(value):null}let reverseMap=node._attributeLowerToCamelNameMap;if(reverseMap){let camelCaseName=reverseMap[name];if(camelCaseName&&camelCaseName in node){let value=node[camelCaseName];return typeof value=="string"?value:value!=null?String(value):null}}return null},hasAttrib:(node,name)=>{if(name==="class")return!!node._parsedProps?.name;if(node._parsedProps&&name in node._parsedProps||name in node)return!0;let reverseMap=node._attributeLowerToCamelNameMap;if(reverseMap){let camelCaseName=reverseMap[name];if(camelCaseName&&camelCaseName in node)return!0}return!1},getSiblings:node=>node.parent?node.parent.children:[],prevElementSibling:node=>{if(!node.parent)return null;let siblings=node.parent.children,idx=siblings.indexOf(node);return idx>0?siblings[idx-1]:null},getText:()=>"",removeSubsets:nodes=>nodes.filter((node,i3)=>!nodes.some((other,j3)=>i3!==j3&&other!==node&&other.getDescendants().includes(node))),existsOne:(test,nodes)=>nodes.some(test),findAll:(test,nodes)=>{let result=[],recurse=node=>{test(node)&&result.push(node);for(let child of node.children)recurse(child)};for(let node of nodes)recurse(node);return result},findOne:(test,nodes)=>{for(let node of nodes){if(test(node))return node;let children=node.children;if(children.length>0){let result=cssSelectPrimitiveComponentAdapter.findOne(test,children);if(result)return result}}return null},equals:(a2,b3)=>a2._renderId===b3._renderId,isHovered:elem=>!1,isVisited:elem=>!1,isActive:elem=>!1},cssSelectPrimitiveComponentAdapterWithoutSubcircuits={...cssSelectPrimitiveComponentAdapter,getChildren:node=>node.children.filter(c3=>!c3.isSubcircuit)},cssSelectPrimitiveComponentAdapterOnlySubcircuits={...cssSelectPrimitiveComponentAdapter,getChildren:node=>node.children.filter(c3=>c3.isSubcircuit)},buildPlusMinusNetErrorMessage=(selector,component)=>{let netName=selector.split("net.")[1]?.split(/[ >]/)[0]??selector;return`Net names cannot contain "+" or "-" (component "${component?.componentName??"Unknown component"}" received "${netName}" via "${selector}"). Try using underscores instead, e.g. VCC_P`},preprocessSelector=(selector,component)=>{if(/net\.[^\s>]*\./.test(selector))throw new Error('Net names cannot contain a period, try using "sel.net..." to autocomplete with conventional net names, e.g. V3_3');if(/net\.[^\s>]*[+-]/.test(selector))throw new Error(buildPlusMinusNetErrorMessage(selector,component));if(/net\.[0-9]/.test(selector)){let match2=selector.match(/net\.([^ >]+)/),netName=match2?match2[1]:"";throw new Error(`Net name "${netName}" cannot start with a number, try using a prefix like "VBUS1"`)}return selector.replace(/ pin(?=[\d.])/g," port").replace(/ subcircuit\./g," group[isSubcircuit=true]").replace(/([^ ])\>([^ ])/g,"$1 > $2").replace(/(^|[ >])(?!pin\.)(?!port\.)(?!net\.)([A-Z][A-Za-z0-9_-]*)\.([A-Za-z0-9_-]+)/g,(_4,sep,name,pin)=>{let pinPart=/^\d+$/.test(pin)?`pin${pin}`:pin;return`${sep}.${name} > .${pinPart}`}).trim()},cssSelectOptionsInsideSubcircuit={adapter:cssSelectPrimitiveComponentAdapterWithoutSubcircuits,cacheResults:!0},PrimitiveComponent2=class extends Renderable{constructor(props){super(props);__publicField(this,"parent",null);__publicField(this,"children");__publicField(this,"childrenPendingRemoval");__publicField(this,"props");__publicField(this,"_parsedProps");__publicField(this,"externallyAddedAliases");__publicField(this,"isPrimitiveContainer",!1);__publicField(this,"canHaveTextChildren",!1);__publicField(this,"source_group_id",null);__publicField(this,"source_component_id",null);__publicField(this,"schematic_component_id",null);__publicField(this,"pcb_component_id",null);__publicField(this,"cad_component_id",null);__publicField(this,"fallbackUnassignedName");__publicField(this,"_cachedSelectAllQueries",new Map);__publicField(this,"_cachedSelectOneQueries",new Map);this.children=[],this.childrenPendingRemoval=[],this.props=props??{},this.externallyAddedAliases=[];let parsePropsResult=("partial"in this.config.zodProps?this.config.zodProps.partial({name:!0}):this.config.zodProps).safeParse(props??{});if(parsePropsResult.success)this._parsedProps=parsePropsResult.data;else throw new InvalidProps(this.lowercaseComponentName,this.props,parsePropsResult.error.format())}get config(){return{componentName:"",zodProps:external_exports.object({}).passthrough()}}get componentName(){return this.config.componentName}getInheritedProperty(propertyName){let current2=this;for(;current2;){if(current2._parsedProps&&propertyName in current2._parsedProps)return current2._parsedProps[propertyName];current2=current2.parent}if(this.root?.platform&&propertyName in this.root.platform)return this.root.platform[propertyName]}getInheritedMergedProperty(propertyName){let parentPropertyObject=this.parent?.getInheritedMergedProperty?.(propertyName),myPropertyObject=this._parsedProps?.[propertyName];return{...parentPropertyObject,...myPropertyObject}}get lowercaseComponentName(){return this.componentName.toLowerCase()}get isSubcircuit(){return!!this.props.subcircuit||this.lowercaseComponentName==="group"&&this?.parent?.isRoot}get isGroup(){return this.lowercaseComponentName==="group"}get name(){return this._parsedProps.name??this.fallbackUnassignedName}setProps(props){let newProps=this.config.zodProps.parse({...this.props,...props}),oldProps=this.props;this.props=newProps,this._parsedProps=this.config.zodProps.parse(props),this.onPropsChange({oldProps,newProps,changedProps:Object.keys(props)}),this.parent?.onChildChanged?.(this)}_getPcbRotationBeforeLayout(){let{pcbRotation}=this.props;return typeof pcbRotation=="string"?parseFloat(pcbRotation):pcbRotation??null}getResolvedPcbPositionProp(){return{pcbX:this._resolvePcbCoordinate(this._parsedProps.pcbX,"pcbX"),pcbY:this._resolvePcbCoordinate(this._parsedProps.pcbY,"pcbY")}}_resolvePcbCoordinate(rawValue,axis,options={}){if(rawValue==null)return 0;if(typeof rawValue=="number")return rawValue;if(typeof rawValue!="string")throw new Error(`Invalid ${axis} value for ${this.componentName}: ${String(rawValue)}`);let allowBoardVariables=options.allowBoardVariables??this._isNormalComponent===!0,includesBoardVariable=rawValue.includes("board."),knownVariables={};if(allowBoardVariables){let board=this._getBoard(),boardVariables=board?._getBoardCalcVariables()??{};if(includesBoardVariable&&!board)throw new Error(`Cannot resolve ${axis} for ${this.componentName}: no board found for board.* variables`);if(includesBoardVariable&&board&&Object.keys(boardVariables).length===0)throw new Error("Cannot do calculations based on board size when the board is auto-sized");Object.assign(knownVariables,boardVariables)}try{return evaluateCalcString(rawValue,{knownVariables})}catch(error){let message=error instanceof Error?error.message:String(error);throw new Error(`Invalid ${axis} value for ${this.componentName}: ${message}`)}}computePcbPropsTransform(){let rotation4=this._getPcbRotationBeforeLayout()??0,{pcbX,pcbY}=this.getResolvedPcbPositionProp();return compose(translate(pcbX,pcbY),rotate(rotation4*Math.PI/180))}_computePcbGlobalTransformBeforeLayout(){let manualPlacement=this.getSubcircuit()._getPcbManualPlacementForComponent(this);if(manualPlacement&&this.props.pcbX===void 0&&this.props.pcbY===void 0){let rotation4=this._getPcbRotationBeforeLayout()??0;return compose(this.parent?._computePcbGlobalTransformBeforeLayout()??identity(),compose(translate(manualPlacement.x,manualPlacement.y),rotate(rotation4*Math.PI/180)))}if(this.isPcbPrimitive){let primitiveContainer=this.getPrimitiveContainer();if(primitiveContainer&&primitiveContainer._parsedProps.layer==="bottom")return compose(this.parent?._computePcbGlobalTransformBeforeLayout()??identity(),flipY(),this.computePcbPropsTransform())}return compose(this.parent?._computePcbGlobalTransformBeforeLayout()??identity(),this.computePcbPropsTransform())}getPrimitiveContainer(){return this.isPrimitiveContainer?this:this.parent?.getPrimitiveContainer?.()??null}getParentNormalComponent(){let current2=this.parent;for(;current2;){if(current2.isPrimitiveContainer&&current2.doInitialPcbComponentRender)return current2;current2=current2.parent}return null}emitSolderMaskMarginWarning(isCoveredWithSolderMask,solderMaskMargin){if(isCoveredWithSolderMask&&solderMaskMargin!==void 0){let parentNormalComponent=this.getParentNormalComponent();parentNormalComponent?.source_component_id&&this.root.db.source_property_ignored_warning.insert({source_component_id:parentNormalComponent.source_component_id,property_name:"solderMaskMargin",message:"solderMaskMargin is set but coveredWithSolderMask is true. When a component is fully covered with solder mask, a margin doesn't apply.",error_type:"source_property_ignored_warning"})}}_getPcbCircuitJsonBounds(){return{center:{x:0,y:0},bounds:{left:0,top:0,right:0,bottom:0},width:0,height:0}}_getPcbPrimitiveFlippedHelpers(){let container=this.getPrimitiveContainer(),isFlipped=container?container._parsedProps.layer==="bottom":!1;return{isFlipped,maybeFlipLayer:layer=>isFlipped?layer==="top"?"bottom":"top":layer}}_setPositionFromLayout(newCenter){throw new Error(`_setPositionFromLayout not implemented for ${this.componentName}`)}computeSchematicPropsTransform(){let{_parsedProps:props}=this;return compose(translate(props.schX??0,props.schY??0))}computeSchematicGlobalTransform(){let manualPlacementTransform=this._getSchematicGlobalManualPlacementTransform(this);return manualPlacementTransform||compose(this.parent?.computeSchematicGlobalTransform?.()??identity(),this.computeSchematicPropsTransform())}_getSchematicSymbolName(){let{_parsedProps:props}=this,base_symbol_name=this.config.schematicSymbolName,orientationRotationMap={horizontal:0,pos_left:0,neg_right:0,pos_right:180,neg_left:180,pos_top:270,neg_bottom:90,vertical:270,pos_bottom:90,neg_top:90},normalizedRotation=props.schOrientation!==void 0?orientationRotationMap[props.schOrientation]:props.schRotation;if(normalizedRotation===void 0&&(normalizedRotation=0),normalizedRotation=normalizedRotation%360,normalizedRotation<0&&(normalizedRotation+=360),props.schRotation!==void 0&&normalizedRotation%90!==0)throw new Error(`Schematic rotation ${props.schRotation} is not supported for ${this.componentName}`);let symbol_name_horz=`${base_symbol_name}_horz`,symbol_name_vert=`${base_symbol_name}_vert`,symbol_name_up=`${base_symbol_name}_up`,symbol_name_down=`${base_symbol_name}_down`,symbol_name_left=`${base_symbol_name}_left`,symbol_name_right=`${base_symbol_name}_right`;if(symbol_name_right in cf&&normalizedRotation===0)return symbol_name_right;if(symbol_name_up in cf&&normalizedRotation===90)return symbol_name_up;if(symbol_name_left in cf&&normalizedRotation===180)return symbol_name_left;if(symbol_name_down in cf&&normalizedRotation===270)return symbol_name_down;if(symbol_name_horz in cf&&(normalizedRotation===0||normalizedRotation===180))return symbol_name_horz;if(symbol_name_vert in cf&&(normalizedRotation===90||normalizedRotation===270))return symbol_name_vert;if(base_symbol_name in cf)return base_symbol_name}_getSchematicSymbolNameOrThrow(){let symbol_name=this._getSchematicSymbolName();if(!symbol_name)throw new Error(`No schematic symbol found (given: "${this.config.schematicSymbolName}")`);return symbol_name}getSchematicSymbol(){let symbol_name=this._getSchematicSymbolName();return symbol_name?cf[symbol_name]??null:null}_getPcbManualPlacementForComponent(component){if(!this.isSubcircuit)return null;let manualEdits=this.props.manualEdits;if(!manualEdits)return null;let placementConfigPositions=manualEdits?.pcb_placements;if(!placementConfigPositions)return null;for(let position2 of placementConfigPositions)if(isMatchingSelector(component,position2.selector)||component.props.name===position2.selector)return applyToPoint(this._computePcbGlobalTransformBeforeLayout(),position2.center);return null}_getSchematicManualPlacementForComponent(component){if(!this.isSubcircuit)return null;let manualEdits=this.props.manualEdits;if(!manualEdits)return null;let placementConfigPositions=manualEdits.schematic_placements;if(!placementConfigPositions)return null;for(let position2 of placementConfigPositions)if(isMatchingSelector(component,position2.selector)||component.props.name===position2.selector)return applyToPoint(this.computeSchematicGlobalTransform(),position2.center);return null}_getSchematicGlobalManualPlacementTransform(component){let manualEdits=this.getSubcircuit()?._parsedProps.manualEdits;if(!manualEdits)return null;for(let position2 of manualEdits.schematic_placements??[])if((isMatchingSelector(component,position2.selector)||component.props.name===position2.selector)&&position2.relative_to==="group_center")return compose(this.parent?._computePcbGlobalTransformBeforeLayout()??identity(),translate(position2.center.x,position2.center.y));return null}_getGlobalPcbPositionBeforeLayout(){return applyToPoint(this._computePcbGlobalTransformBeforeLayout(),{x:0,y:0})}_getGlobalSchematicPositionBeforeLayout(){return applyToPoint(this.computeSchematicGlobalTransform(),{x:0,y:0})}_getBoard(){let current2=this;for(;current2;){let maybePrimitive=current2;if(maybePrimitive.componentName==="Board")return maybePrimitive;current2=current2.parent??null}return this.root?._getBoard()}get root(){return this.parent?.root??null}onAddToParent(parent){this.parent=parent}onPropsChange(params){}onChildChanged(child){this.parent?.onChildChanged?.(child)}add(component){let textContent2=component.__text;if(typeof textContent2=="string"){if(this.canHaveTextChildren||textContent2.trim()==="")return;throw new Error(`Invalid JSX Element: Expected a React component but received text "${textContent2}"`)}if(Object.keys(component).length!==0){if(component.lowercaseComponentName==="panel")throw new Error("<panel> must be a root-level element");if(!component.onAddToParent)throw new Error(`Invalid JSX Element: Expected a React component but received "${JSON.stringify(component)}"`);component.onAddToParent(this),component.parent=this,this.children.push(component)}}addAll(components){for(let component of components)this.add(component)}remove(component){this.children=this.children.filter(c3=>c3!==component),this.childrenPendingRemoval.push(component),component.shouldBeRemoved=!0}getSubcircuitSelector(){let name=this.name,endPart=name?`${this.lowercaseComponentName}.${name}`:this.lowercaseComponentName;return!this.parent||this.parent.isSubcircuit?endPart:`${this.parent.getSubcircuitSelector()} > ${endPart}`}getFullPathSelector(){let name=this.name,endPart=name?`${this.lowercaseComponentName}.${name}`:this.lowercaseComponentName,parentSelector=this.parent?.getFullPathSelector?.();return parentSelector?`${parentSelector} > ${endPart}`:endPart}getNameAndAliases(){return[this.name,...this._parsedProps.portHints??[]].filter(Boolean)}isMatchingNameOrAlias(name){return this.getNameAndAliases().includes(name)}isMatchingAnyOf(aliases2){return this.getNameAndAliases().some(a2=>aliases2.map(a22=>a22.toString()).includes(a2))}getPcbSize(){throw new Error(`getPcbSize not implemented for ${this.componentName}`)}doesSelectorMatch(selector){let myTypeNames=[this.componentName,this.lowercaseComponentName],myClassNames=[this.name].filter(Boolean),parts=selector.trim().split(/\> /)[0],firstPart=parts[0];return parts.length>1?!1:!!(selector==="*"||selector[0]==="#"&&selector.slice(1)===this.props.id||selector[0]==="."&&myClassNames.includes(selector.slice(1))||/^[a-zA-Z0-9_]/.test(firstPart)&&myTypeNames.includes(firstPart))}getSubcircuit(){if(this.isSubcircuit)return this;let group=this.parent?.getSubcircuit?.();if(!group)throw new Error("Component is not inside an opaque group (no board?)");return group}getGroup(){return this.isGroup?this:this.parent?.getGroup?.()??null}doInitialAssignNameToUnnamedComponents(){this._parsedProps.name||(this.fallbackUnassignedName=this.getSubcircuit().getNextAvailableName(this))}doInitialOptimizeSelectorCache(){if(!this.isSubcircuit)return;let ports=this.selectAll("port");for(let port of ports){let parentAliases=(port.getParentNormalComponent?.()??port.parent)?.getNameAndAliases(),portAliases=port.getNameAndAliases();if(parentAliases)for(let parentAlias of parentAliases)for(let portAlias of portAliases){let selectors=[`.${parentAlias} > .${portAlias}`,`.${parentAlias} .${portAlias}`];for(let selector of selectors){let ar3=this._cachedSelectAllQueries.get(selector);ar3?ar3.push(port):this._cachedSelectAllQueries.set(selector,[port])}}}for(let[selector,ports2]of this._cachedSelectAllQueries.entries())ports2.length===1&&this._cachedSelectOneQueries.set(selector,ports2[0])}selectAll(selectorRaw){if(this._cachedSelectAllQueries.has(selectorRaw))return this._cachedSelectAllQueries.get(selectorRaw);let selector=preprocessSelector(selectorRaw,this),result=selectAll(selector,this,cssSelectOptionsInsideSubcircuit);if(result.length>0)return this._cachedSelectAllQueries.set(selectorRaw,result),result;let[firstpart,...rest]=selector.split(" "),subcircuit=selectOne(firstpart,this,{adapter:cssSelectPrimitiveComponentAdapterOnlySubcircuits});if(!subcircuit)return[];let result2=subcircuit.selectAll(rest.join(" "));return this._cachedSelectAllQueries.set(selectorRaw,result2),result2}selectOne(selectorRaw,options){if(this._cachedSelectOneQueries.has(selectorRaw))return this._cachedSelectOneQueries.get(selectorRaw);let selector=preprocessSelector(selectorRaw,this);options?.port&&(options.type="port");let result=null;if(options?.type&&(result=selectAll(selector,this,cssSelectOptionsInsideSubcircuit).find(n3=>n3.lowercaseComponentName===options.type)),result??(result=selectOne(selector,this,cssSelectOptionsInsideSubcircuit)),result)return this._cachedSelectOneQueries.set(selectorRaw,result),result;let[firstpart,...rest]=selector.split(" "),subcircuit=selectOne(firstpart,this,{adapter:cssSelectPrimitiveComponentAdapterOnlySubcircuits});return subcircuit?(result=subcircuit.selectOne(rest.join(" "),options),this._cachedSelectOneQueries.set(selectorRaw,result),result):null}getAvailablePcbLayers(){if(this.isPcbPrimitive){let{maybeFlipLayer}=this._getPcbPrimitiveFlippedHelpers();return"layer"in this._parsedProps||this.componentName==="SmtPad"?[maybeFlipLayer(this._parsedProps.layer??"top")]:"layers"in this._parsedProps?this._parsedProps.layers:this.componentName==="PlatedHole"?[...this.root?._getBoard()?.allLayers??["top","bottom"]]:[]}return[]}getDescendants(){let descendants=[];for(let child of this.children)descendants.push(child),descendants.push(...child.getDescendants());return descendants}getSelectableDescendants(){let descendants=[];for(let child of this.children)child.isSubcircuit?descendants.push(child):(descendants.push(child),descendants.push(...child.getSelectableDescendants()));return descendants}_getPinCount(){return 0}_getSchematicBoxDimensions(){return null}_getSchematicBoxComponentDimensions(){if(this.getSchematicSymbol()||!this.config.shouldRenderAsSchematicBox)return null;let{_parsedProps:props}=this;return{schWidth:props.schWidth,schHeight:props.schHeight}}renderError(message){if(typeof message=="string")return super.renderError(message);switch(message.type){case"pcb_placement_error":this.root?.db.pcb_placement_error.insert(message);break;case"pcb_via_clearance_error":this.root?.db.pcb_via_clearance_error.insert(message);break;case"pcb_trace_error":this.root?.db.pcb_trace_error.insert(message);break;case"pcb_manual_edit_conflict_warning":this.root?.db.pcb_manual_edit_conflict_warning.insert(message);break;default:this.root?.db.pcb_placement_error.insert(message)}}getString(){let{lowercaseComponentName:cname,_parsedProps:props,parent}=this;return props?.pinNumber!==void 0&&parent?.props?.name&&props?.name?`<${cname}#${this._renderId}(pin:${props.pinNumber} .${parent?.props.name}>.${props.name}) />`:parent?.props?.name&&props?.name?`<${cname}#${this._renderId}(.${parent?.props.name}>.${props?.name}) />`:props?.from&&props?.to?`<${cname}#${this._renderId}(from:${props.from} to:${props?.to}) />`:props?.name?`<${cname}#${this._renderId} name=".${props?.name}" />`:props?.portHints?`<${cname}#${this._renderId}(${props.portHints.map(ph2=>`.${ph2}`).join(", ")}) />`:`<${cname}#${this._renderId} />`}get[Symbol.toStringTag](){return this.getString()}[Symbol.for("nodejs.util.inspect.custom")](){return this.getString()}},ErrorPlaceholderComponent=class extends PrimitiveComponent2{constructor(props,error){super(props);let resolveCoordinate=(value,axis)=>{if(typeof value=="number")return value;if(typeof value=="string")try{return this._resolvePcbCoordinate(value,axis,{allowBoardVariables:!1})}catch{return 0}return 0};this._parsedProps={...props,error,type:props.type||"unknown",component_name:props.name,error_type:"source_failed_to_create_component_error",message:error instanceof Error?error.message:String(error),pcbX:resolveCoordinate(props.pcbX,"pcbX"),pcbY:resolveCoordinate(props.pcbY,"pcbY"),schX:props.schX,schY:props.schY}}get config(){return{componentName:"ErrorPlaceholder",zodProps:external_exports.object({}).passthrough()}}doInitialSourceRender(){if(this.root?.db){let pcbPosition2=this._getGlobalPcbPositionBeforeLayout(),schematicPosition=this._getGlobalSchematicPositionBeforeLayout();this.root.db.source_failed_to_create_component_error.insert({component_name:this._parsedProps.component_name,error_type:"source_failed_to_create_component_error",message:`Could not create ${this._parsedProps.componentType??"component"}${this._parsedProps.name?` "${this._parsedProps.name}"`:""}. ${this._parsedProps.error?.formattedError?._errors?.join("; ")||this._parsedProps.message}`,pcb_center:pcbPosition2,schematic_center:schematicPosition})}}};function createErrorPlaceholderComponent(props,error){return new ErrorPlaceholderComponent(props,error)}function prepare(object,state2){let instance=object;return instance.__tsci={...state2},object}var hostConfig={supportsMutation:!0,createInstance(type,props){let target=catalogue[type];if(!target)throw Object.keys(catalogue).length===0?new Error("No components registered in catalogue, did you forget to import lib/register-catalogue in your test file?"):new Error(`Unsupported component type "${type}". No element with this name is registered in the @tscircuit/core catalogue. Check for typos or see https://docs.tscircuit.com/category/built-in-elements for a list of valid components. To add your own component, see docs/CREATING_NEW_COMPONENTS.md`);try{return prepare(new target(props),{})}catch(error){return createErrorPlaceholderComponent({...props,componentType:type},error)}},createTextInstance(text){return{__text:text}},appendInitialChild(parentInstance,child){parentInstance.add(child)},appendChild(parentInstance,child){parentInstance.add(child)},appendChildToContainer(container,child){container.add(child)},finalizeInitialChildren(){return!1},prepareUpdate(){return null},shouldSetTextContent(){return!1},getRootHostContext(){return{}},getChildHostContext(){return{}},prepareForCommit(){return null},resetAfterCommit(){},commitMount(){},commitUpdate(){},removeChild(){},clearContainer(){},supportsPersistence:!1,getPublicInstance(instance){return instance},preparePortalMount(containerInfo){throw new Error("Function not implemented.")},scheduleTimeout(fn3,delay){throw new Error("Function not implemented.")},cancelTimeout(id2){throw new Error("Function not implemented.")},noTimeout:void 0,isPrimaryRenderer:!1,getInstanceFromNode(node){throw new Error("Function not implemented.")},beforeActiveInstanceBlur(){throw new Error("Function not implemented.")},afterActiveInstanceBlur(){throw new Error("Function not implemented.")},prepareScopeUpdate:(scopeInstance,instance)=>{throw new Error("Function not implemented.")},getInstanceFromScope:scopeInstance=>{throw new Error("Function not implemented.")},detachDeletedInstance:node=>{throw new Error("Function not implemented.")},getCurrentEventPriority:()=>import_constants.DefaultEventPriority,getCurrentUpdatePriority:()=>import_constants.DefaultEventPriority,resolveUpdatePriority:()=>import_constants.DefaultEventPriority,setCurrentUpdatePriority:()=>{},maySuspendCommit:()=>!1,supportsHydration:!1},reconciler=(0,import_react_reconciler.default)(hostConfig),createInstanceFromReactElement=reactElm=>{let rootContainer={children:[],props:{name:"$root"},add(instance){instance.parent=this,this.children.push(instance)},computePcbGlobalTransform(){return identity()}},containerErrors=[],container=reconciler.createContainer(rootContainer,0,null,!1,null,"tsci",error=>{console.log("Error in createContainer"),console.error(error),containerErrors.push(error)},null);if(reconciler.updateContainerSync(reactElm,container,null,()=>{}),reconciler.flushSyncWork(),containerErrors.length>0)throw containerErrors[0];let rootInstance=reconciler.getPublicRootInstance(container);return rootInstance||rootContainer.children[0]},parsePinNumberFromLabelsOrThrow=(pinNumberOrLabel,pinLabels)=>{if(typeof pinNumberOrLabel=="number")return pinNumberOrLabel;if(pinNumberOrLabel.startsWith("pin"))return Number(pinNumberOrLabel.slice(3));if(!pinLabels)throw new Error(`No pin labels provided and pin number or label is not a number: "${pinNumberOrLabel}"`);for(let pinNumberKey in pinLabels)if((Array.isArray(pinLabels[pinNumberKey])?pinLabels[pinNumberKey]:[pinLabels[pinNumberKey]]).includes(pinNumberOrLabel))return Number(pinNumberKey.replace("pin",""));throw new Error(`No pin labels provided and pin number or label is not a number: "${pinNumberOrLabel}"`)},underscorifyPinStyles=(pinStyles,pinLabels)=>{if(!pinStyles)return;let underscorePinStyles={},mergedStyles={};for(let[pinNameOrLabel,pinStyle]of Object.entries(pinStyles)){let pinNumber=parsePinNumberFromLabelsOrThrow(pinNameOrLabel,pinLabels);mergedStyles[pinNumber]={...mergedStyles[pinNumber],...pinStyle}}for(let[pinNumber,pinStyle]of Object.entries(mergedStyles)){let pinKey=`pin${pinNumber}`;underscorePinStyles[pinKey]={bottom_margin:pinStyle.bottomMargin,left_margin:pinStyle.leftMargin,right_margin:pinStyle.rightMargin,top_margin:pinStyle.topMargin}}return underscorePinStyles},underscorifyPortArrangement=portArrangement=>{if(portArrangement){if("leftSide"in portArrangement||"rightSide"in portArrangement||"topSide"in portArrangement||"bottomSide"in portArrangement)return{left_side:portArrangement.leftSide,right_side:portArrangement.rightSide,top_side:portArrangement.topSide,bottom_side:portArrangement.bottomSide};if("leftPinCount"in portArrangement||"rightPinCount"in portArrangement||"topPinCount"in portArrangement||"bottomPinCount"in portArrangement)return{left_size:portArrangement.leftPinCount,right_size:portArrangement.rightPinCount,top_size:portArrangement.topPinCount,bottom_size:portArrangement.bottomPinCount};if("leftSize"in portArrangement||"rightSize"in portArrangement||"topSize"in portArrangement||"bottomSize"in portArrangement)return{left_size:portArrangement.leftSize,right_size:portArrangement.rightSize,top_size:portArrangement.topSize,bottom_size:portArrangement.bottomSize}}};function pairs2(arr){let result=[];for(let i3=0;i3<arr.length-1;i3++)result.push([arr[i3],arr[i3+1]]);return result}var netProps2=external_exports.object({name:external_exports.string().refine(val=>!/[+-]/.test(val),val=>({message:`Net names cannot contain "+" or "-" (component "Net" received "${val}"). Try using underscores instead, e.g. VCC_P`}))}),Net=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"source_net_id");__publicField(this,"subcircuit_connectivity_map_key",null)}get config(){return{componentName:"Net",zodProps:netProps2}}getPortSelector(){return`net.${this.props.name}`}doInitialSourceRender(){let{db:db2}=this.root,{_parsedProps:props}=this,isGround=props.name.startsWith("GND"),isPositiveVoltageSource=props.name.startsWith("V"),net=db2.source_net.insert({name:props.name,member_source_group_ids:[],is_ground:isGround,is_power:isPositiveVoltageSource,is_positive_voltage_source:isPositiveVoltageSource});this.source_net_id=net.source_net_id}doInitialSourceParentAttachment(){let subcircuit=this.getSubcircuit();if(!subcircuit)return;let{db:db2}=this.root;db2.source_net.update(this.source_net_id,{subcircuit_id:subcircuit.subcircuit_id})}getAllConnectedPorts(){let allPorts=this.getSubcircuit().selectAll("port"),connectedPorts=[];for(let port of allPorts){let traces=port._getDirectlyConnectedTraces();for(let trace of traces)if(trace._isExplicitlyConnectedToNet(this)){connectedPorts.push(port);break}}return connectedPorts}_getAllDirectlyConnectedTraces(){let allTraces=this.getSubcircuit().selectAll("trace"),connectedTraces=[];for(let trace of allTraces)trace._isExplicitlyConnectedToNet(this)&&connectedTraces.push(trace);return connectedTraces}doInitialPcbRouteNetIslands(){if(this.root?.pcbDisabled||this.getSubcircuit()._parsedProps.routingDisabled||this.getSubcircuit()._getAutorouterConfig().groupMode!=="sequential-trace")return;let{db:db2}=this.root,{_parsedProps:props}=this,traces=this._getAllDirectlyConnectedTraces().filter(trace=>(trace._portsRoutedOnPcb?.length??0)>0),islands=[];for(let trace of traces){let tracePorts=trace._portsRoutedOnPcb,traceIsland=islands.find(island=>tracePorts.some(port=>island.ports.includes(port)));if(!traceIsland){islands.push({ports:[...tracePorts],traces:[trace]});continue}traceIsland.traces.push(trace),traceIsland.ports.push(...tracePorts)}if(islands.length===0)return;let islandPairs=pairs2(islands);for(let[A4,B3]of islandPairs){let Apositions=A4.ports.map(port=>port._getGlobalPcbPositionBeforeLayout()),Bpositions=B3.ports.map(port=>port._getGlobalPcbPositionBeforeLayout()),closestDist=1/0,closestPair=[-1,-1];for(let i3=0;i3<Apositions.length;i3++){let Apos=Apositions[i3];for(let j3=0;j3<Bpositions.length;j3++){let Bpos=Bpositions[j3],dist=Math.sqrt((Apos.x-Bpos.x)**2+(Apos.y-Bpos.y)**2);dist<closestDist&&(closestDist=dist,closestPair=[i3,j3])}}let Aport=A4.ports[closestPair[0]],Bport=B3.ports[closestPair[1]],pcbElements=db2.toArray().filter(elm=>elm.type==="pcb_smtpad"||elm.type==="pcb_trace"||elm.type==="pcb_plated_hole"||elm.type==="pcb_hole"||elm.type==="source_port"||elm.type==="pcb_port"),{solution}=autoroute2(pcbElements.concat([{type:"source_trace",source_trace_id:"__net_trace_tmp",connected_source_port_ids:[Aport.source_port_id,Bport.source_port_id]}])),trace=solution[0];if(!trace){this.renderError({pcb_trace_error_id:"",pcb_trace_id:"__net_trace_tmp",pcb_component_ids:[Aport.pcb_component_id,Bport.pcb_component_id].filter(Boolean),pcb_port_ids:[Aport.pcb_port_id,Bport.pcb_port_id].filter(Boolean),type:"pcb_trace_error",error_type:"pcb_trace_error",message:`Failed to route net islands for "${this.getString()}"`,source_trace_id:"__net_trace_tmp"});return}db2.pcb_trace.insert(trace)}}renderError(message){if(typeof message=="string")return super.renderError(message);this.root?.db.pcb_trace_error.insert(message)}},createNetsFromProps=(component,props)=>{for(let prop of props)if(typeof prop=="string"&&prop.startsWith("net.")){if(/net\.[^\s>]*\./.test(prop))throw new Error('Net names cannot contain a period, try using "sel.net..." to autocomplete with conventional net names, e.g. V3_3');if(/net\.[^\s>]*[+-]/.test(prop)){let netName=prop.split("net.")[1],message=`Net names cannot contain "+" or "-" (component "${component.componentName}" received "${netName}" via "${prop}"). Try using underscores instead, e.g. VCC_P`;throw new Error(message)}if(/net\.[0-9]/.test(prop)){let netName=prop.split("net.")[1];throw new Error(`Net name "${netName}" cannot start with a number, try using a prefix like "VBUS1"`)}let subcircuit=component.getSubcircuit();if(!subcircuit.selectOne(prop)){let net=new Net({name:prop.split("net.")[1]});subcircuit.add(net)}}},SmtPad=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"pcb_smtpad_id",null);__publicField(this,"matchedPort",null);__publicField(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SmtPad",zodProps:smtPadProps}}getPcbSize(){let{_parsedProps:props}=this;if(props.shape==="circle")return{width:props.radius*2,height:props.radius*2};if(props.shape==="rect")return{width:props.width,height:props.height};if(props.shape==="rotated_rect"){let angleRad=(props.ccwRotation??0)*Math.PI/180,cosAngle=Math.cos(angleRad),sinAngle=Math.sin(angleRad),width=Math.abs(props.width*cosAngle)+Math.abs(props.height*sinAngle),height=Math.abs(props.width*sinAngle)+Math.abs(props.height*cosAngle);return{width,height}}if(props.shape==="polygon"){let points=props.points,xs3=points.map(p2=>p2.x),ys3=points.map(p2=>p2.y),minX=Math.min(...xs3),maxX=Math.max(...xs3),minY=Math.min(...ys3),maxY=Math.max(...ys3);return{width:maxX-minX,height:maxY-minY}}if(props.shape==="pill")return{width:props.width,height:props.height};throw new Error(`getPcbSize for shape "${props.shape}" not implemented for ${this.componentName}`)}doInitialPortMatching(){let parentPorts=this.getPrimitiveContainer()?.selectAll("port");if(this.props.portHints){for(let port of parentPorts)if(port.isMatchingAnyOf(this.props.portHints)){this.matchedPort=port,port.registerMatch(this);return}}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,isCoveredWithSolderMask=props.coveredWithSolderMask??!1,shouldCreateSolderPaste=!isCoveredWithSolderMask,soldermaskMargin=props.solderMaskMargin;this.emitSolderMaskMarginWarning(isCoveredWithSolderMask,soldermaskMargin);let subcircuit=this.getSubcircuit(),position2=this._getGlobalPcbPositionBeforeLayout(),globalTransform=this._computePcbGlobalTransformBeforeLayout(),normalizedRotationDegrees=(decomposeTSR(this._computePcbGlobalTransformBeforeLayout()).rotation.angle*180/Math.PI%360+360)%360,rotationTolerance=.01,isAxisAligned=Math.abs(normalizedRotationDegrees)<rotationTolerance||Math.abs(normalizedRotationDegrees-180)<rotationTolerance||Math.abs(normalizedRotationDegrees-360)<rotationTolerance,isRotated90Degrees=Math.abs(normalizedRotationDegrees-90)<rotationTolerance||Math.abs(normalizedRotationDegrees-270)<rotationTolerance,finalRotationDegrees=Math.abs(normalizedRotationDegrees-360)<rotationTolerance?0:normalizedRotationDegrees,transformRotationBeforeFlip=finalRotationDegrees,{maybeFlipLayer,isFlipped}=this._getPcbPrimitiveFlippedHelpers();isFlipped&&(finalRotationDegrees=(360-finalRotationDegrees+360)%360);let portHints2=props.portHints?.map(ph2=>ph2.toString())??[],pcb_smtpad2=null,pcb_component_id=this.parent?.pcb_component_id??this.getPrimitiveContainer()?.pcb_component_id;if(props.shape==="circle")pcb_smtpad2=db2.pcb_smtpad.insert({pcb_component_id,pcb_port_id:this.matchedPort?.pcb_port_id,layer:maybeFlipLayer(props.layer??"top"),shape:"circle",radius:props.radius,port_hints:portHints2,is_covered_with_solder_mask:isCoveredWithSolderMask,soldermask_margin:soldermaskMargin,x:position2.x,y:position2.y,subcircuit_id:subcircuit?.subcircuit_id??void 0}),shouldCreateSolderPaste&&db2.pcb_solder_paste.insert({layer:pcb_smtpad2.layer,shape:"circle",radius:pcb_smtpad2.radius*.7,x:pcb_smtpad2.x,y:pcb_smtpad2.y,pcb_component_id:pcb_smtpad2.pcb_component_id,pcb_smtpad_id:pcb_smtpad2.pcb_smtpad_id,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0});else if(props.shape==="rect")!isAxisAligned&&!isRotated90Degrees?pcb_smtpad2=db2.pcb_smtpad.insert({pcb_component_id,pcb_port_id:this.matchedPort?.pcb_port_id,layer:maybeFlipLayer(props.layer??"top"),shape:"rotated_rect",width:props.width,height:props.height,corner_radius:props.cornerRadius??void 0,x:position2.x,y:position2.y,ccw_rotation:finalRotationDegrees,port_hints:portHints2,is_covered_with_solder_mask:isCoveredWithSolderMask,soldermask_margin:soldermaskMargin,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0}):pcb_smtpad2=db2.pcb_smtpad.insert({pcb_component_id,pcb_port_id:this.matchedPort?.pcb_port_id,layer:maybeFlipLayer(props.layer??"top"),shape:"rect",width:isRotated90Degrees?props.height:props.width,height:isRotated90Degrees?props.width:props.height,corner_radius:props.cornerRadius??void 0,port_hints:portHints2,is_covered_with_solder_mask:isCoveredWithSolderMask,soldermask_margin:soldermaskMargin,x:position2.x,y:position2.y,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0}),shouldCreateSolderPaste&&(pcb_smtpad2.shape==="rect"?db2.pcb_solder_paste.insert({layer:maybeFlipLayer(props.layer??"top"),shape:"rect",width:pcb_smtpad2.width*.7,height:pcb_smtpad2.height*.7,x:pcb_smtpad2.x,y:pcb_smtpad2.y,pcb_component_id:pcb_smtpad2.pcb_component_id,pcb_smtpad_id:pcb_smtpad2.pcb_smtpad_id,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0}):pcb_smtpad2.shape==="rotated_rect"&&db2.pcb_solder_paste.insert({layer:maybeFlipLayer(props.layer??"top"),shape:"rotated_rect",width:pcb_smtpad2.width*.7,height:pcb_smtpad2.height*.7,x:pcb_smtpad2.x,y:pcb_smtpad2.y,ccw_rotation:pcb_smtpad2.ccw_rotation,pcb_component_id:pcb_smtpad2.pcb_component_id,pcb_smtpad_id:pcb_smtpad2.pcb_smtpad_id,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0}));else if(props.shape==="rotated_rect"){let baseRotation=props.ccwRotation??0,combinedRotationBeforeFlip=(transformRotationBeforeFlip+baseRotation+360)%360,padRotation=isFlipped?(360-combinedRotationBeforeFlip+360)%360:combinedRotationBeforeFlip;pcb_smtpad2=db2.pcb_smtpad.insert({pcb_component_id,pcb_port_id:this.matchedPort?.pcb_port_id,layer:maybeFlipLayer(props.layer??"top"),shape:"rotated_rect",width:props.width,height:props.height,corner_radius:props.cornerRadius??void 0,x:position2.x,y:position2.y,ccw_rotation:padRotation,port_hints:portHints2,is_covered_with_solder_mask:isCoveredWithSolderMask,soldermask_margin:soldermaskMargin,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0}),shouldCreateSolderPaste&&db2.pcb_solder_paste.insert({layer:maybeFlipLayer(props.layer??"top"),shape:"rotated_rect",width:pcb_smtpad2.width*.7,height:pcb_smtpad2.height*.7,x:position2.x,y:position2.y,ccw_rotation:padRotation,pcb_component_id,pcb_smtpad_id:pcb_smtpad2.pcb_smtpad_id,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0})}else if(props.shape==="polygon"){let transformedPoints=props.points.map(point23=>{let transformed=applyToPoint(globalTransform,{x:distance.parse(point23.x),y:distance.parse(point23.y)});return{x:transformed.x,y:transformed.y}});pcb_smtpad2=db2.pcb_smtpad.insert({pcb_component_id,pcb_port_id:this.matchedPort?.pcb_port_id,layer:maybeFlipLayer(props.layer??"top"),shape:"polygon",points:transformedPoints,port_hints:portHints2,is_covered_with_solder_mask:isCoveredWithSolderMask,soldermask_margin:soldermaskMargin,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0})}else props.shape==="pill"&&(pcb_smtpad2=db2.pcb_smtpad.insert({pcb_component_id,pcb_port_id:this.matchedPort?.pcb_port_id,layer:maybeFlipLayer(props.layer??"top"),shape:"pill",x:position2.x,y:position2.y,radius:props.radius,height:props.height,width:props.width,port_hints:portHints2,is_covered_with_solder_mask:isCoveredWithSolderMask,soldermask_margin:soldermaskMargin,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0}));pcb_smtpad2&&(this.pcb_smtpad_id=pcb_smtpad2.pcb_smtpad_id)}doInitialPcbPortAttachment(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root;db2.pcb_smtpad.update(this.pcb_smtpad_id,{pcb_port_id:this.matchedPort?.pcb_port_id})}_getPcbCircuitJsonBounds(){let{db:db2}=this.root,smtpad2=db2.pcb_smtpad.get(this.pcb_smtpad_id);if(smtpad2.shape==="rect")return{center:{x:smtpad2.x,y:smtpad2.y},bounds:{left:smtpad2.x-smtpad2.width/2,top:smtpad2.y+smtpad2.height/2,right:smtpad2.x+smtpad2.width/2,bottom:smtpad2.y-smtpad2.height/2},width:smtpad2.width,height:smtpad2.height};if(smtpad2.shape==="rotated_rect"){let angleRad=smtpad2.ccw_rotation*Math.PI/180,cosAngle=Math.cos(angleRad),sinAngle=Math.sin(angleRad),w22=smtpad2.width/2,h2=smtpad2.height/2,xExtent=Math.abs(w22*cosAngle)+Math.abs(h2*sinAngle),yExtent=Math.abs(w22*sinAngle)+Math.abs(h2*cosAngle);return{center:{x:smtpad2.x,y:smtpad2.y},bounds:{left:smtpad2.x-xExtent,right:smtpad2.x+xExtent,top:smtpad2.y-yExtent,bottom:smtpad2.y+yExtent},width:xExtent*2,height:yExtent*2}}if(smtpad2.shape==="circle")return{center:{x:smtpad2.x,y:smtpad2.y},bounds:{left:smtpad2.x-smtpad2.radius,top:smtpad2.y-smtpad2.radius,right:smtpad2.x+smtpad2.radius,bottom:smtpad2.y+smtpad2.radius},width:smtpad2.radius*2,height:smtpad2.radius*2};if(smtpad2.shape==="polygon"){let points=smtpad2.points,xs3=points.map(p2=>p2.x),ys3=points.map(p2=>p2.y),minX=Math.min(...xs3),maxX=Math.max(...xs3),minY=Math.min(...ys3),maxY=Math.max(...ys3);return{center:{x:(minX+maxX)/2,y:(minY+maxY)/2},bounds:{left:minX,top:maxY,right:maxX,bottom:minY},width:maxX-minX,height:maxY-minY}}if(smtpad2.shape==="pill"){let halfWidth=smtpad2.width/2,halfHeight=smtpad2.height/2;return{center:{x:smtpad2.x,y:smtpad2.y},bounds:{left:smtpad2.x-halfWidth,top:smtpad2.y-halfHeight,right:smtpad2.x+halfWidth,bottom:smtpad2.y+halfHeight},width:smtpad2.width,height:smtpad2.height}}throw new Error(`circuitJson bounds calculation not implemented for shape "${smtpad2.shape}"`)}_setPositionFromLayout(newCenter){let{db:db2}=this.root;db2.pcb_smtpad.update(this.pcb_smtpad_id,{x:newCenter.x,y:newCenter.y});let solderPaste=db2.pcb_solder_paste.list().find(elm=>elm.pcb_smtpad_id===this.pcb_smtpad_id);solderPaste&&db2.pcb_solder_paste.update(solderPaste.pcb_solder_paste_id,{x:newCenter.x,y:newCenter.y}),this.matchedPort?._setPositionFromLayout(newCenter)}_moveCircuitJsonElements({deltaX,deltaY}){if(this.root?.pcbDisabled)return;let{db:db2}=this.root;if(!this.pcb_smtpad_id)return;let pad2=db2.pcb_smtpad.get(this.pcb_smtpad_id);if(pad2.shape==="rect"||pad2.shape==="circle"||pad2.shape==="rotated_rect"||pad2.shape==="pill")this._setPositionFromLayout({x:pad2.x+deltaX,y:pad2.y+deltaY});else if(pad2.shape==="polygon"){db2.pcb_smtpad.update(this.pcb_smtpad_id,{points:pad2.points.map(p2=>({x:p2.x+deltaX,y:p2.y+deltaY}))});let newCenter={x:this._getPcbCircuitJsonBounds().center.x+deltaX/2,y:this._getPcbCircuitJsonBounds().center.y+deltaY/2};this.matchedPort?._setPositionFromLayout(newCenter)}}},SilkscreenPath=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"pcb_silkscreen_path_id",null);__publicField(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenPath",zodProps:silkscreenPathProps}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,{maybeFlipLayer}=this._getPcbPrimitiveFlippedHelpers(),layer=maybeFlipLayer(props.layer??"top");if(layer!=="top"&&layer!=="bottom")throw new Error(`Invalid layer "${layer}" for SilkscreenPath. Must be "top" or "bottom".`);let transform5=this._computePcbGlobalTransformBeforeLayout(),subcircuit=this.getSubcircuit(),pcb_component_id=this.parent?.pcb_component_id??this.getPrimitiveContainer()?.pcb_component_id,pcb_silkscreen_path2=db2.pcb_silkscreen_path.insert({pcb_component_id,layer,route:props.route.map(p2=>{let transformedPosition=applyToPoint(transform5,{x:p2.x,y:p2.y});return{...p2,x:transformedPosition.x,y:transformedPosition.y}}),stroke_width:props.strokeWidth??.1,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0});this.pcb_silkscreen_path_id=pcb_silkscreen_path2.pcb_silkscreen_path_id}_setPositionFromLayout(newCenter){let{db:db2}=this.root,{_parsedProps:props}=this,currentPath=db2.pcb_silkscreen_path.get(this.pcb_silkscreen_path_id);if(!currentPath)return;let currentCenterX=0,currentCenterY=0;for(let point23 of currentPath.route)currentCenterX+=point23.x,currentCenterY+=point23.y;currentCenterX/=currentPath.route.length,currentCenterY/=currentPath.route.length;let offsetX=newCenter.x-currentCenterX,offsetY=newCenter.y-currentCenterY,newRoute=currentPath.route.map(point23=>({...point23,x:point23.x+offsetX,y:point23.y+offsetY}));db2.pcb_silkscreen_path.update(this.pcb_silkscreen_path_id,{route:newRoute})}_moveCircuitJsonElements({deltaX,deltaY}){if(this.root?.pcbDisabled)return;let{db:db2}=this.root;if(!this.pcb_silkscreen_path_id)return;let path=db2.pcb_silkscreen_path.get(this.pcb_silkscreen_path_id);path&&db2.pcb_silkscreen_path.update(this.pcb_silkscreen_path_id,{route:path.route.map(p2=>({...p2,x:p2.x+deltaX,y:p2.y+deltaY}))})}getPcbSize(){let{_parsedProps:props}=this;if(!props.route||props.route.length===0)return{width:0,height:0};let minX=1/0,maxX=-1/0,minY=1/0,maxY=-1/0;for(let point23 of props.route)minX=Math.min(minX,point23.x),maxX=Math.max(maxX,point23.x),minY=Math.min(minY,point23.y),maxY=Math.max(maxY,point23.y);return{width:maxX-minX,height:maxY-minY}}},pcbTraceProps2=external_exports.object({route:external_exports.array(pcb_trace_route_point),source_trace_id:external_exports.string().optional()}),PcbTrace=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"pcb_trace_id",null);__publicField(this,"isPcbPrimitive",!0)}get config(){return{componentName:"PcbTrace",zodProps:pcbTraceProps2}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,container=this.getPrimitiveContainer(),subcircuit=this.getSubcircuit(),{maybeFlipLayer}=this._getPcbPrimitiveFlippedHelpers(),parentTransform=this._computePcbGlobalTransformBeforeLayout(),transformedRoute=props.route.map(point23=>{let{x:x3,y:y3,...restOfPoint}=point23,transformedPoint=applyToPoint(parentTransform,{x:x3,y:y3});return point23.route_type==="wire"&&point23.layer?{...transformedPoint,...restOfPoint,layer:maybeFlipLayer(point23.layer)}:{...transformedPoint,...restOfPoint}}),pcb_trace2=db2.pcb_trace.insert({pcb_component_id:container.pcb_component_id,source_trace_id:props.source_trace_id,route:transformedRoute,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0});this.pcb_trace_id=pcb_trace2.pcb_trace_id}getPcbSize(){let{_parsedProps:props}=this;if(!props.route||props.route.length===0)return{width:0,height:0};let minX=1/0,maxX=-1/0,minY=1/0,maxY=-1/0;for(let point23 of props.route)minX=Math.min(minX,point23.x),maxX=Math.max(maxX,point23.x),minY=Math.min(minY,point23.y),maxY=Math.max(maxY,point23.y),point23.route_type==="wire"&&(minX=Math.min(minX,point23.x-point23.width/2),maxX=Math.max(maxX,point23.x+point23.width/2),minY=Math.min(minY,point23.y-point23.width/2),maxY=Math.max(maxY,point23.y+point23.width/2));return minX===1/0||maxX===-1/0||minY===1/0||maxY===-1/0?{width:0,height:0}:{width:maxX-minX,height:maxY-minY}}},PlatedHole=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"pcb_plated_hole_id",null);__publicField(this,"matchedPort",null);__publicField(this,"isPcbPrimitive",!0)}get config(){return{componentName:"PlatedHole",zodProps:platedHoleProps}}getAvailablePcbLayers(){return["top","inner1","inner2","bottom"]}getPcbSize(){let{_parsedProps:props}=this;if(props.shape==="circle")return{width:props.outerDiameter,height:props.outerDiameter};if(props.shape==="oval"||props.shape==="pill")return{width:props.outerWidth,height:props.outerHeight};if(props.shape==="circular_hole_with_rect_pad")return{width:props.rectPadWidth,height:props.rectPadHeight};if(props.shape==="pill_hole_with_rect_pad")return{width:props.rectPadWidth,height:props.rectPadHeight};if(props.shape==="hole_with_polygon_pad"){if(!props.padOutline||props.padOutline.length===0)throw new Error("padOutline is required for hole_with_polygon_pad shape");let xs3=props.padOutline.map(p2=>typeof p2.x=="number"?p2.x:parseFloat(String(p2.x))),ys3=props.padOutline.map(p2=>typeof p2.y=="number"?p2.y:parseFloat(String(p2.y))),minX=Math.min(...xs3),maxX=Math.max(...xs3),minY=Math.min(...ys3),maxY=Math.max(...ys3);return{width:maxX-minX,height:maxY-minY}}throw new Error(`getPcbSize for shape "${props.shape}" not implemented for ${this.componentName}`)}_getPcbCircuitJsonBounds(){let{db:db2}=this.root,platedHole=db2.pcb_plated_hole.get(this.pcb_plated_hole_id),size2=this.getPcbSize();return{center:{x:platedHole.x,y:platedHole.y},bounds:{left:platedHole.x-size2.width/2,top:platedHole.y+size2.height/2,right:platedHole.x+size2.width/2,bottom:platedHole.y-size2.height/2},width:size2.width,height:size2.height}}_setPositionFromLayout(newCenter){let{db:db2}=this.root;db2.pcb_plated_hole.update(this.pcb_plated_hole_id,{x:newCenter.x,y:newCenter.y}),this.matchedPort?._setPositionFromLayout(newCenter)}doInitialPortMatching(){let parentPorts=this.getPrimitiveContainer()?.selectAll("port");if(this.props.portHints){for(let port of parentPorts)if(port.isMatchingAnyOf(this.props.portHints)){this.matchedPort=port,port.registerMatch(this);return}}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,position2=this._getGlobalPcbPositionBeforeLayout(),pcb_component_id=this.parent?.pcb_component_id??this.getPrimitiveContainer()?.pcb_component_id,subcircuit=this.getSubcircuit(),soldermaskMargin=props.solderMaskMargin,isCoveredWithSolderMask=props.coveredWithSolderMask??!1;if(this.emitSolderMaskMarginWarning(isCoveredWithSolderMask,soldermaskMargin),props.shape==="circle"){let pcb_plated_hole2=db2.pcb_plated_hole.insert({pcb_component_id,pcb_port_id:this.matchedPort?.pcb_port_id,outer_diameter:props.outerDiameter,hole_diameter:props.holeDiameter,shape:"circle",port_hints:this.getNameAndAliases(),x:position2.x,y:position2.y,layers:["top","bottom"],soldermask_margin:soldermaskMargin,is_covered_with_solder_mask:isCoveredWithSolderMask,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0});this.pcb_plated_hole_id=pcb_plated_hole2.pcb_plated_hole_id,db2.pcb_solder_paste.insert({layer:"top",shape:"circle",radius:props.outerDiameter/2,x:position2.x,y:position2.y,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0}),db2.pcb_solder_paste.insert({layer:"bottom",shape:"circle",radius:props.outerDiameter/2,x:position2.x,y:position2.y,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0})}else if(props.shape==="pill"&&props.rectPad){let pcb_plated_hole2=db2.pcb_plated_hole.insert({pcb_component_id,pcb_port_id:this.matchedPort?.pcb_port_id,outer_width:props.outerWidth,outer_height:props.outerHeight,hole_width:props.holeWidth,hole_height:props.holeHeight,shape:"rotated_pill_hole_with_rect_pad",type:"pcb_plated_hole",port_hints:this.getNameAndAliases(),pcb_plated_hole_id:this.pcb_plated_hole_id,x:position2.x,y:position2.y,layers:["top","bottom"],soldermask_margin:soldermaskMargin,is_covered_with_solder_mask:isCoveredWithSolderMask,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0,hole_shape:"rotated_pill",pad_shape:"rect",hole_ccw_rotation:props.pcbRotation??0,rect_ccw_rotation:props.pcbRotation??0,rect_pad_width:props.outerWidth,rect_pad_height:props.outerHeight,hole_offset_x:props.holeOffsetX,hole_offset_y:props.holeOffsetY});this.pcb_plated_hole_id=pcb_plated_hole2.pcb_plated_hole_id}else if(props.shape==="pill"||props.shape==="oval"){let pcb_plated_hole2=db2.pcb_plated_hole.insert({pcb_component_id,pcb_port_id:this.matchedPort?.pcb_port_id,outer_width:props.outerWidth,outer_height:props.outerHeight,hole_width:props.holeWidth,hole_height:props.holeHeight,shape:props.shape,port_hints:this.getNameAndAliases(),x:position2.x,y:position2.y,layers:["top","bottom"],soldermask_margin:soldermaskMargin,is_covered_with_solder_mask:isCoveredWithSolderMask,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0,ccw_rotation:props.pcbRotation??0});this.pcb_plated_hole_id=pcb_plated_hole2.pcb_plated_hole_id,db2.pcb_solder_paste.insert({layer:"top",shape:props.shape,width:props.outerWidth,height:props.outerHeight,x:position2.x,y:position2.y,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0}),db2.pcb_solder_paste.insert({layer:"bottom",shape:props.shape,width:props.outerWidth,height:props.outerHeight,x:position2.x,y:position2.y,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0})}else if(props.shape==="circular_hole_with_rect_pad"){let pcb_plated_hole2=db2.pcb_plated_hole.insert({pcb_component_id,pcb_port_id:this.matchedPort?.pcb_port_id,hole_diameter:props.holeDiameter,rect_pad_width:props.rectPadWidth,rect_pad_height:props.rectPadHeight,shape:"circular_hole_with_rect_pad",port_hints:this.getNameAndAliases(),x:position2.x,y:position2.y,layers:["top","bottom"],soldermask_margin:soldermaskMargin,is_covered_with_solder_mask:isCoveredWithSolderMask,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0,hole_offset_x:props.holeOffsetX,hole_offset_y:props.holeOffsetY,rect_border_radius:props.rectBorderRadius??0});this.pcb_plated_hole_id=pcb_plated_hole2.pcb_plated_hole_id}else if(props.shape==="pill_hole_with_rect_pad"){let pcb_plated_hole2=db2.pcb_plated_hole.insert({pcb_component_id,pcb_port_id:this.matchedPort?.pcb_port_id,hole_width:props.holeWidth,hole_height:props.holeHeight,rect_pad_width:props.rectPadWidth,rect_pad_height:props.rectPadHeight,hole_offset_x:props.holeOffsetX,hole_offset_y:props.holeOffsetY,shape:"pill_hole_with_rect_pad",port_hints:this.getNameAndAliases(),x:position2.x,y:position2.y,layers:["top","bottom"],soldermask_margin:soldermaskMargin,is_covered_with_solder_mask:isCoveredWithSolderMask,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0});this.pcb_plated_hole_id=pcb_plated_hole2.pcb_plated_hole_id}else if(props.shape==="hole_with_polygon_pad"){let padOutline=(props.padOutline||[]).map(point23=>{let x3=typeof point23.x=="number"?point23.x:parseFloat(String(point23.x)),y3=typeof point23.y=="number"?point23.y:parseFloat(String(point23.y));return{x:x3,y:y3}}),pcb_plated_hole2=db2.pcb_plated_hole.insert({pcb_component_id,pcb_port_id:this.matchedPort?.pcb_port_id,shape:"hole_with_polygon_pad",hole_shape:props.holeShape||"circle",hole_diameter:props.holeDiameter,hole_width:props.holeWidth,hole_height:props.holeHeight,pad_outline:padOutline,hole_offset_x:typeof props.holeOffsetX=="number"?props.holeOffsetX:parseFloat(String(props.holeOffsetX||0)),hole_offset_y:typeof props.holeOffsetY=="number"?props.holeOffsetY:parseFloat(String(props.holeOffsetY||0)),port_hints:this.getNameAndAliases(),x:position2.x,y:position2.y,layers:["top","bottom"],soldermask_margin:soldermaskMargin,is_covered_with_solder_mask:isCoveredWithSolderMask,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0});this.pcb_plated_hole_id=pcb_plated_hole2.pcb_plated_hole_id}}doInitialPcbPortAttachment(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root;db2.pcb_plated_hole.update(this.pcb_plated_hole_id,{pcb_port_id:this.matchedPort?.pcb_port_id})}_moveCircuitJsonElements({deltaX,deltaY}){if(this.root?.pcbDisabled)return;let{db:db2}=this.root;if(!this.pcb_plated_hole_id)return;let hole=db2.pcb_plated_hole.get(this.pcb_plated_hole_id);if(hole){let newCenter={x:hole.x+deltaX,y:hole.y+deltaY};this._setPositionFromLayout(newCenter)}}},Keepout=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"pcb_keepout_id",null);__publicField(this,"isPcbPrimitive",!0)}get config(){return{componentName:"Keepout",zodProps:pcbKeepoutProps}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let subcircuit=this.getSubcircuit(),{db:db2}=this.root,{_parsedProps:props}=this,position2=this._getGlobalPcbPositionBeforeLayout(),decomposedMat=decomposeTSR(this._computePcbGlobalTransformBeforeLayout()),isRotated90=Math.abs(decomposedMat.rotation.angle*(180/Math.PI)-90)%180<.01,pcb_keepout2=null;props.shape==="circle"?pcb_keepout2=db2.pcb_keepout.insert({layers:["top"],shape:"circle",radius:props.radius,center:{x:position2.x,y:position2.y},subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:subcircuit?.getGroup()?.pcb_group_id??void 0}):props.shape==="rect"&&(pcb_keepout2=db2.pcb_keepout.insert({layers:["top"],shape:"rect",...isRotated90?{width:props.height,height:props.width}:{width:props.width,height:props.height},center:{x:position2.x,y:position2.y},subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:subcircuit?.getGroup()?.pcb_group_id??void 0})),pcb_keepout2&&(this.pcb_keepout_id=pcb_keepout2.pcb_keepout_id)}},Hole=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"pcb_hole_id",null);__publicField(this,"isPcbPrimitive",!0)}get config(){return{componentName:"Hole",zodProps:holeProps}}getPcbSize(){let{_parsedProps:props}=this,isPill=props.shape==="pill",isRect=props.shape==="rect";return isPill?{width:props.width,height:props.height}:isRect?{width:props.width,height:props.height}:{width:props.diameter,height:props.diameter}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,subcircuit=this.getSubcircuit(),position2=this._getGlobalPcbPositionBeforeLayout(),soldermaskMargin=props.solderMaskMargin,isCoveredWithSolderMask=props.coveredWithSolderMask??!1,pcb_component_id=this.parent?.pcb_component_id??this.getPrimitiveContainer()?.pcb_component_id;if(this.emitSolderMaskMarginWarning(isCoveredWithSolderMask,soldermaskMargin),props.shape==="pill")if(props.pcbRotation&&props.pcbRotation!==0){let inserted_hole=db2.pcb_hole.insert({pcb_component_id,type:"pcb_hole",hole_shape:"rotated_pill",hole_width:props.width,hole_height:props.height,x:position2.x,y:position2.y,ccw_rotation:props.pcbRotation,soldermask_margin:soldermaskMargin,is_covered_with_solder_mask:isCoveredWithSolderMask,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:subcircuit?.getGroup()?.pcb_group_id??void 0});this.pcb_hole_id=inserted_hole.pcb_hole_id}else{let inserted_hole=db2.pcb_hole.insert({pcb_component_id,type:"pcb_hole",hole_shape:"pill",hole_width:props.width,hole_height:props.height,x:position2.x,y:position2.y,soldermask_margin:soldermaskMargin,is_covered_with_solder_mask:isCoveredWithSolderMask,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:subcircuit?.getGroup()?.pcb_group_id??void 0});this.pcb_hole_id=inserted_hole.pcb_hole_id}else if(props.shape==="rect"){let inserted_hole=db2.pcb_hole.insert({pcb_component_id,type:"pcb_hole",hole_shape:"rect",hole_width:props.width,hole_height:props.height,x:position2.x,y:position2.y,soldermask_margin:soldermaskMargin,is_covered_with_solder_mask:isCoveredWithSolderMask,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:subcircuit?.getGroup()?.pcb_group_id??void 0});this.pcb_hole_id=inserted_hole.pcb_hole_id}else{let inserted_hole=db2.pcb_hole.insert({pcb_component_id,type:"pcb_hole",hole_shape:"circle",hole_diameter:props.diameter,x:position2.x,y:position2.y,soldermask_margin:soldermaskMargin,is_covered_with_solder_mask:isCoveredWithSolderMask,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:subcircuit?.getGroup()?.pcb_group_id??void 0});this.pcb_hole_id=inserted_hole.pcb_hole_id}}_getPcbCircuitJsonBounds(){let{db:db2}=this.root,hole=db2.pcb_hole.get(this.pcb_hole_id),size2=this.getPcbSize();return{center:{x:hole.x,y:hole.y},bounds:{left:hole.x-size2.width/2,top:hole.y-size2.height/2,right:hole.x+size2.width/2,bottom:hole.y+size2.height/2},width:size2.width,height:size2.height}}_setPositionFromLayout(newCenter){let{db:db2}=this.root;db2.pcb_hole.update(this.pcb_hole_id,{x:newCenter.x,y:newCenter.y})}_moveCircuitJsonElements({deltaX,deltaY}){if(this.root?.pcbDisabled)return;let{db:db2}=this.root;if(!this.pcb_hole_id)return;let hole=db2.pcb_hole.get(this.pcb_hole_id);hole&&db2.pcb_hole.update(this.pcb_hole_id,{x:hole.x+deltaX,y:hole.y+deltaY})}};function normalizeTextForCircuitJson(text){return text.replace(/\\n/g,`
613
613
  `)}var SilkscreenText=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"pcb_silkscreen_text_ids",[]);__publicField(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenText",zodProps:silkscreenTextProps}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,container=this.getPrimitiveContainer(),position2=this._getGlobalPcbPositionBeforeLayout(),{maybeFlipLayer,isFlipped}=this._getPcbPrimitiveFlippedHelpers(),subcircuit=this.getSubcircuit(),rotation4=0;if(props.pcbRotation!==void 0&&props.pcbRotation!==0)rotation4=props.pcbRotation;else{let globalTransform=this._computePcbGlobalTransformBeforeLayout();rotation4=decomposeTSR(globalTransform).rotation.angle*180/Math.PI}isFlipped&&(rotation4=(rotation4+180)%360);let uniqueLayers=new Set(props.layers);props.layer&&uniqueLayers.add(props.layer);let targetLayers=uniqueLayers.size>0?Array.from(uniqueLayers):["top"],fontSize=props.fontSize??this.getInheritedProperty("pcbStyle")?.silkscreenFontSize??1;for(let layer of targetLayers){let pcb_silkscreen_text2=db2.pcb_silkscreen_text.insert({anchor_alignment:props.anchorAlignment,anchor_position:{x:position2.x,y:position2.y},font:props.font??"tscircuit2024",font_size:fontSize,layer:maybeFlipLayer(layer),text:normalizeTextForCircuitJson(props.text??""),ccw_rotation:rotation4,pcb_component_id:container.pcb_component_id,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0});this.pcb_silkscreen_text_ids.push(pcb_silkscreen_text2.pcb_silkscreen_text_id)}}getPcbSize(){let{_parsedProps:props}=this,fontSize=props.fontSize??this.getInheritedProperty("pcbStyle")?.silkscreenFontSize??1,textWidth=(props.text??"").length*fontSize,textHeight=fontSize;return{width:textWidth*fontSize,height:textHeight*fontSize}}_moveCircuitJsonElements({deltaX,deltaY}){if(this.root?.pcbDisabled)return;let{db:db2}=this.root;for(let id2 of this.pcb_silkscreen_text_ids){let text=db2.pcb_silkscreen_text.get(id2);text&&db2.pcb_silkscreen_text.update(id2,{anchor_position:{x:text.anchor_position.x+deltaX,y:text.anchor_position.y+deltaY}})}}},Cutout=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"pcb_cutout_id",null);__publicField(this,"isPcbPrimitive",!0)}get config(){return{componentName:"Cutout",zodProps:cutoutProps}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,subcircuit=this.getSubcircuit(),pcb_group_id=this.getGroup()?.pcb_group_id??void 0,globalPosition=this._getGlobalPcbPositionBeforeLayout(),parentRotation=this.getPrimitiveContainer()?._parsedProps.pcbRotation??0,inserted_pcb_cutout;if(props.shape==="rect"){let rotationDeg=typeof parentRotation=="string"?parseInt(parentRotation.replace("deg",""),10):parentRotation,isRotated90=Math.abs(rotationDeg%180)===90,rectData={shape:"rect",center:globalPosition,width:isRotated90?props.height:props.width,height:isRotated90?props.width:props.height,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id};inserted_pcb_cutout=db2.pcb_cutout.insert(rectData)}else if(props.shape==="circle"){let circleData={shape:"circle",center:globalPosition,radius:props.radius,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id};inserted_pcb_cutout=db2.pcb_cutout.insert(circleData)}else if(props.shape==="polygon"){let transform5=this._computePcbGlobalTransformBeforeLayout(),polygonData={shape:"polygon",points:props.points.map(p2=>applyToPoint(transform5,p2)),subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id};inserted_pcb_cutout=db2.pcb_cutout.insert(polygonData)}inserted_pcb_cutout&&(this.pcb_cutout_id=inserted_pcb_cutout.pcb_cutout_id)}getPcbSize(){let{_parsedProps:props}=this;if(props.shape==="rect")return{width:props.width,height:props.height};if(props.shape==="circle")return{width:props.radius*2,height:props.radius*2};if(props.shape==="polygon"){if(props.points.length===0)return{width:0,height:0};let minX=1/0,maxX=-1/0,minY=1/0,maxY=-1/0;for(let point23 of props.points)minX=Math.min(minX,point23.x),maxX=Math.max(maxX,point23.x),minY=Math.min(minY,point23.y),maxY=Math.max(maxY,point23.y);return{width:maxX-minX,height:maxY-minY}}return{width:0,height:0}}_getPcbCircuitJsonBounds(){if(!this.pcb_cutout_id)return super._getPcbCircuitJsonBounds();let{db:db2}=this.root,cutout=db2.pcb_cutout.get(this.pcb_cutout_id);if(!cutout)return super._getPcbCircuitJsonBounds();if(cutout.shape==="rect")return{center:cutout.center,bounds:{left:cutout.center.x-cutout.width/2,top:cutout.center.y+cutout.height/2,right:cutout.center.x+cutout.width/2,bottom:cutout.center.y-cutout.height/2},width:cutout.width,height:cutout.height};if(cutout.shape==="circle")return{center:cutout.center,bounds:{left:cutout.center.x-cutout.radius,top:cutout.center.y+cutout.radius,right:cutout.center.x+cutout.radius,bottom:cutout.center.y-cutout.radius},width:cutout.radius*2,height:cutout.radius*2};if(cutout.shape==="polygon"){if(cutout.points.length===0)return super._getPcbCircuitJsonBounds();let minX=1/0,maxX=-1/0,minY=1/0,maxY=-1/0;for(let point23 of cutout.points)minX=Math.min(minX,point23.x),maxX=Math.max(maxX,point23.x),minY=Math.min(minY,point23.y),maxY=Math.max(maxY,point23.y);return{center:{x:(minX+maxX)/2,y:(minY+maxY)/2},bounds:{left:minX,top:maxY,right:maxX,bottom:minY},width:maxX-minX,height:maxY-minY}}return super._getPcbCircuitJsonBounds()}_setPositionFromLayout(newCenter){if(!this.pcb_cutout_id)return;let{db:db2}=this.root,cutout=db2.pcb_cutout.get(this.pcb_cutout_id);if(cutout){if(cutout.shape==="rect"||cutout.shape==="circle")db2.pcb_cutout.update(this.pcb_cutout_id,{...cutout,center:newCenter});else if(cutout.shape==="polygon"){let oldCenter=this._getPcbCircuitJsonBounds().center,dx2=newCenter.x-oldCenter.x,dy2=newCenter.y-oldCenter.y,newPoints=cutout.points.map(p2=>({x:p2.x+dx2,y:p2.y+dy2}));db2.pcb_cutout.update(this.pcb_cutout_id,{...cutout,points:newPoints})}}}_moveCircuitJsonElements({deltaX,deltaY}){if(!this.pcb_cutout_id)return;let{db:db2}=this.root,cutout=db2.pcb_cutout.get(this.pcb_cutout_id);cutout&&(cutout.shape==="rect"||cutout.shape==="circle"?db2.pcb_cutout.update(this.pcb_cutout_id,{center:{x:cutout.center.x+deltaX,y:cutout.center.y+deltaY}}):cutout.shape==="polygon"&&db2.pcb_cutout.update(this.pcb_cutout_id,{points:cutout.points.map(p2=>({x:p2.x+deltaX,y:p2.y+deltaY}))}))}},createPinrowSilkscreenText=({elm,pinLabels,layer,readableRotation,anchorAlignment})=>{let pinNum=elm.text.replace(/[{}]/g,"").toLowerCase(),label=pinNum;if(Array.isArray(pinLabels)){let index=parseInt(pinNum.replace(/[^\d]/g,""),10)-1;label=String(pinLabels[index]??pinNum)}else typeof pinLabels=="object"&&(label=String(pinLabels[pinNum]??pinNum));return new SilkscreenText({anchorAlignment:anchorAlignment||"center",text:label??pinNum,layer:layer||"top",fontSize:elm.font_size+.2,pcbX:isNaN(elm.anchor_position.x)?0:elm.anchor_position.x,pcbY:elm.anchor_position.y,pcbRotation:readableRotation??0})},calculateCcwRotation=(componentRotationStr,elementCcwRotation)=>{let componentAngle=parseInt(componentRotationStr||"0",10),totalRotation;return elementCcwRotation!=null?totalRotation=elementCcwRotation-componentAngle:totalRotation=componentAngle,(totalRotation%360+360)%360},createComponentsFromCircuitJson=({componentName,componentRotation,footprinterString,pinLabels,pcbPinLabels},circuitJson)=>{let components=[];for(let elm of circuitJson)if(elm.type==="pcb_smtpad"&&elm.shape==="rect")components.push(new SmtPad({pcbX:elm.x,pcbY:elm.y,layer:elm.layer,shape:"rect",height:elm.height,width:elm.width,portHints:elm.port_hints,rectBorderRadius:elm.rect_border_radius}));else if(elm.type==="pcb_smtpad"&&elm.shape==="circle")components.push(new SmtPad({pcbX:elm.x,pcbY:elm.y,layer:elm.layer,shape:"circle",radius:elm.radius,portHints:elm.port_hints}));else if(elm.type==="pcb_smtpad"&&elm.shape==="pill")components.push(new SmtPad({shape:"pill",height:elm.height,width:elm.width,radius:elm.radius,portHints:elm.port_hints,pcbX:elm.x,pcbY:elm.y,layer:elm.layer}));else if(elm.type==="pcb_silkscreen_path")components.push(new SilkscreenPath({layer:elm.layer,route:elm.route,strokeWidth:elm.stroke_width}));else if(elm.type==="pcb_plated_hole")elm.shape==="circle"?components.push(new PlatedHole({pcbX:elm.x,pcbY:elm.y,shape:"circle",holeDiameter:elm.hole_diameter,outerDiameter:elm.outer_diameter,portHints:elm.port_hints})):elm.shape==="circular_hole_with_rect_pad"?components.push(new PlatedHole({pcbX:elm.x,pcbY:elm.y,shape:"circular_hole_with_rect_pad",holeDiameter:elm.hole_diameter,rectPadHeight:elm.rect_pad_height,rectPadWidth:elm.rect_pad_width,portHints:elm.port_hints,rectBorderRadius:elm.rect_border_radius,holeOffsetX:elm.hole_offset_x,holeOffsetY:elm.hole_offset_y})):elm.shape==="pill"||elm.shape==="oval"?components.push(new PlatedHole({pcbX:elm.x,pcbY:elm.y,shape:elm.shape,holeWidth:elm.hole_width,holeHeight:elm.hole_height,outerWidth:elm.outer_width,outerHeight:elm.outer_height,portHints:elm.port_hints})):elm.shape==="pill_hole_with_rect_pad"?components.push(new PlatedHole({pcbX:elm.x,pcbY:elm.y,shape:"pill_hole_with_rect_pad",holeShape:"pill",padShape:"rect",holeWidth:elm.hole_width,holeHeight:elm.hole_height,rectPadWidth:elm.rect_pad_width,rectPadHeight:elm.rect_pad_height,portHints:elm.port_hints,holeOffsetX:elm.hole_offset_x,holeOffsetY:elm.hole_offset_y})):elm.shape==="hole_with_polygon_pad"&&components.push(new PlatedHole({pcbX:elm.x,pcbY:elm.y,shape:"hole_with_polygon_pad",holeShape:elm.hole_shape||"circle",holeDiameter:elm.hole_diameter,holeWidth:elm.hole_width,holeHeight:elm.hole_height,padOutline:elm.pad_outline||[],holeOffsetX:elm.hole_offset_x,holeOffsetY:elm.hole_offset_y,portHints:elm.port_hints}));else if(elm.type==="pcb_keepout"&&elm.shape==="circle")components.push(new Keepout({pcbX:elm.center.x,pcbY:elm.center.y,shape:"circle",radius:elm.radius}));else if(elm.type==="pcb_keepout"&&elm.shape==="rect")components.push(new Keepout({pcbX:elm.center.x,pcbY:elm.center.y,shape:"rect",width:elm.width,height:elm.height}));else if(elm.type==="pcb_hole"&&elm.hole_shape==="circle")components.push(new Hole({pcbX:elm.x,pcbY:elm.y,diameter:elm.hole_diameter}));else if(elm.type==="pcb_hole"&&elm.hole_shape==="rect")components.push(new Hole({pcbX:elm.x,pcbY:elm.y,shape:"rect",width:elm.hole_width,height:elm.hole_height}));else if(elm.type==="pcb_hole"&&elm.hole_shape==="pill")components.push(new Hole({pcbX:elm.x,pcbY:elm.y,shape:"pill",width:elm.hole_width,height:elm.hole_height}));else if(elm.type==="pcb_hole"&&elm.hole_shape==="rotated_pill")components.push(new Hole({pcbX:elm.x,pcbY:elm.y,shape:"pill",width:elm.hole_width,height:elm.hole_height,pcbRotation:elm.ccw_rotation}));else if(elm.type==="pcb_cutout")elm.shape==="rect"?components.push(new Cutout({pcbX:elm.center.x,pcbY:elm.center.y,shape:"rect",width:elm.width,height:elm.height})):elm.shape==="circle"?components.push(new Cutout({pcbX:elm.center.x,pcbY:elm.center.y,shape:"circle",radius:elm.radius})):elm.shape==="polygon"&&components.push(new Cutout({shape:"polygon",points:elm.points}));else if(elm.type==="pcb_silkscreen_text"){let ccwRotation=calculateCcwRotation(componentRotation,elm.ccw_rotation);footprinterString?.includes("pinrow")&&elm.text.includes("PIN")?components.push(createPinrowSilkscreenText({elm,pinLabels:pcbPinLabels??pinLabels??{},layer:elm.layer,readableRotation:ccwRotation,anchorAlignment:elm.anchor_alignment})):components.push(new SilkscreenText({anchorAlignment:elm.anchor_alignment||"center",text:componentName||elm.text,fontSize:elm.font_size+.2,pcbX:Number.isNaN(elm.anchor_position.x)?0:elm.anchor_position.x,pcbY:elm.anchor_position.y,pcbRotation:ccwRotation??0}))}else elm.type==="pcb_trace"&&components.push(new PcbTrace({route:elm.route}));return components};function getBoundsOfPcbComponents(components){let minX=1/0,minY=1/0,maxX=-1/0,maxY=-1/0,hasValidComponents=!1;for(let child of components)if(child.isPcbPrimitive&&!child.componentName.startsWith("Silkscreen")){let{x:x3,y:y3}=child._getGlobalPcbPositionBeforeLayout(),{width:width2,height:height2}=child.getPcbSize();minX=Math.min(minX,x3-width2/2),minY=Math.min(minY,y3-height2/2),maxX=Math.max(maxX,x3+width2/2),maxY=Math.max(maxY,y3+height2/2),hasValidComponents=!0}else if(child.children.length>0){let childBounds=getBoundsOfPcbComponents(child.children);(childBounds.width>0||childBounds.height>0)&&(minX=Math.min(minX,childBounds.minX),minY=Math.min(minY,childBounds.minY),maxX=Math.max(maxX,childBounds.maxX),maxY=Math.max(maxY,childBounds.maxY),hasValidComponents=!0)}if(!hasValidComponents)return{minX:0,minY:0,maxX:0,maxY:0,width:0,height:0};let width=maxX-minX,height=maxY-minY;return width<0&&(width=0),height<0&&(height=0),{minX,minY,maxX,maxY,width,height}}function normalizeAngle(angle){let normalized=angle%360;return normalized<0?normalized+360:normalized}function isAngleBetween(angle,start,end,direction2){return direction2==="counterclockwise"?end>=start?angle>=start&&angle<=end:angle>=start||angle<=end:end<=start?angle<=start&&angle>=end:angle<=start||angle>=end}function getArcBounds(elm){let center2=elm.center,radius=elm.radius,startAngle=elm.start_angle_degrees,endAngle=elm.end_angle_degrees,direction2=elm.direction??"counterclockwise";if(!center2||typeof center2.x!="number"||typeof center2.y!="number"||typeof radius!="number"||typeof startAngle!="number"||typeof endAngle!="number")return null;let start=normalizeAngle(startAngle),end=normalizeAngle(endAngle),consideredAngles=new Set([start,end]),cardinalAngles=[0,90,180,270];for(let cardinal of cardinalAngles)isAngleBetween(cardinal,start,end,direction2)&&consideredAngles.add(cardinal);let minX=1/0,minY=1/0,maxX=-1/0,maxY=-1/0;for(let angle of consideredAngles){let radians=angle*Math.PI/180,x3=center2.x+radius*Math.cos(radians),y3=center2.y+radius*Math.sin(radians);minX=Math.min(minX,x3),maxX=Math.max(maxX,x3),minY=Math.min(minY,y3),maxY=Math.max(maxY,y3)}return!Number.isFinite(minX)||!Number.isFinite(minY)?null:{minX,maxX,minY,maxY}}function getBoundsForSchematic(db2){let minX=1/0,minY=1/0,maxX=-1/0,maxY=-1/0;for(let elm of db2){let cx2,cy2,w4,h2;if(elm.type==="schematic_component")cx2=elm.center?.x,cy2=elm.center?.y,w4=elm.size?.width,h2=elm.size?.height;else if(elm.type==="schematic_box")cx2=elm.x,cy2=elm.y,w4=elm.width,h2=elm.height;else if(elm.type==="schematic_port")cx2=elm.center?.x,cy2=elm.center?.y,w4=.2,h2=.2;else if(elm.type==="schematic_text")cx2=elm.position?.x,cy2=elm.position?.y,w4=(elm.text?.length??0)*.1,h2=.2;else if(elm.type==="schematic_line"){let x12=elm.x1??0,y12=elm.y1??0,x22=elm.x2??0,y22=elm.y2??0;cx2=(x12+x22)/2,cy2=(y12+y22)/2,w4=Math.abs(x22-x12),h2=Math.abs(y22-y12)}else if(elm.type==="schematic_rect")cx2=elm.center?.x,cy2=elm.center?.y,w4=elm.width,h2=elm.height;else if(elm.type==="schematic_circle"){cx2=elm.center?.x,cy2=elm.center?.y;let radius=elm.radius;typeof radius=="number"&&(w4=radius*2,h2=radius*2)}else if(elm.type==="schematic_arc"){let bounds=getArcBounds(elm);bounds&&(minX=Math.min(minX,bounds.minX),maxX=Math.max(maxX,bounds.maxX),minY=Math.min(minY,bounds.minY),maxY=Math.max(maxY,bounds.maxY));continue}typeof cx2=="number"&&typeof cy2=="number"&&typeof w4=="number"&&typeof h2=="number"&&(minX=Math.min(minX,cx2-w4/2),maxX=Math.max(maxX,cx2+w4/2),minY=Math.min(minY,cy2-h2/2),maxY=Math.max(maxY,cy2+h2/2))}return{minX,maxX,minY,maxY}}function getRelativeDirection(pointA,pointB){let dx2=pointB.x-pointA.x,dy2=pointB.y-pointA.y;return Math.abs(dx2)>Math.abs(dy2)?dx2>=0?"right":"left":dy2>=0?"up":"down"}var areAllPcbPrimitivesOverlapping=pcbPrimitives=>{if(pcbPrimitives.length<=1)return!0;let bounds=pcbPrimitives.map(p2=>{let circuitBounds=p2._getPcbCircuitJsonBounds();return{left:circuitBounds.bounds.left,right:circuitBounds.bounds.right,top:circuitBounds.bounds.top,bottom:circuitBounds.bounds.bottom}}),overlaps=Array(bounds.length).fill(!1).map(()=>Array(bounds.length).fill(!1));for(let i3=0;i3<bounds.length;i3++)for(let j3=i3+1;j3<bounds.length;j3++){let a2=bounds[i3],b3=bounds[j3];overlaps[i3][j3]=overlaps[j3][i3]=!(a2.right<b3.left||a2.left>b3.right||a2.bottom>b3.top||a2.top<b3.bottom)}let visited=new Set,dfs=node=>{visited.add(node);for(let i3=0;i3<bounds.length;i3++)overlaps[node][i3]&&!visited.has(i3)&&dfs(i3)};return dfs(0),visited.size===bounds.length},getCenterOfPcbPrimitives=pcbPrimitives=>{if(pcbPrimitives.length===0)throw new Error("Cannot get center of empty PCB primitives array");let positions=pcbPrimitives.map(p2=>p2._getPcbCircuitJsonBounds().center).filter(Boolean),sumX=positions.reduce((sum,pos)=>sum+pos.x,0),sumY=positions.reduce((sum,pos)=>sum+pos.y,0);return{x:sumX/positions.length,y:sumY/positions.length}},portProps2=external_exports.object({name:external_exports.string().optional(),pinNumber:external_exports.number().optional(),aliases:external_exports.array(external_exports.string()).optional(),layer:external_exports.string().optional(),layers:external_exports.array(external_exports.string()).optional(),schX:external_exports.number().optional(),schY:external_exports.number().optional(),direction:external_exports.enum(["up","down","left","right"]).optional(),connectsTo:external_exports.union([external_exports.string(),external_exports.array(external_exports.string())]).optional()}),Port=class extends PrimitiveComponent2{constructor(props,opts={}){if(!props.name&&props.pinNumber!==void 0&&(props.name=`pin${props.pinNumber}`),!props.name)throw new Error("Port must have a name or a pinNumber");super(props);__publicField(this,"source_port_id",null);__publicField(this,"pcb_port_id",null);__publicField(this,"schematic_port_id",null);__publicField(this,"schematicSymbolPortDef",null);__publicField(this,"matchedComponents");__publicField(this,"facingDirection",null);__publicField(this,"originDescription",null);opts.originDescription&&(this.originDescription=opts.originDescription),this.matchedComponents=[]}get config(){return{componentName:"Port",zodProps:portProps2}}isGroupPort(){return this.parent?.componentName==="Group"}isComponentPort(){return!this.isGroupPort()}_getConnectedPortsFromConnectsTo(){let{_parsedProps:props}=this,connectsTo=props.connectsTo;if(!connectsTo)return[];let connectedPorts=[],connectsToArray=Array.isArray(connectsTo)?connectsTo:[connectsTo];for(let connection of connectsToArray){let port=this.getSubcircuit().selectOne(connection,{type:"port"});port&&connectedPorts.push(port)}return connectedPorts}_isBoardPinoutFromAttributes(){let parent=this.parent;if(parent?._parsedProps?.pinAttributes){let pinAttributes=parent._parsedProps.pinAttributes;for(let alias of this.getNameAndAliases())if(pinAttributes[alias]?.includeInBoardPinout)return!0}}_getGlobalPcbPositionBeforeLayout(){let matchedPcbElm=this.matchedComponents.find(c3=>c3.isPcbPrimitive),parentComponent=this.parent;if(parentComponent&&!parentComponent.props.footprint)throw new Error(`${parentComponent.componentName} "${parentComponent.props.name}" does not have a footprint. Add a footprint prop, e.g. <${parentComponent.componentName.toLowerCase()} footprint="..." />`);if(!matchedPcbElm)throw new Error(`Port ${this} has no matching PCB primitives. This often means the footprint's pads lack matching port hints.`);return matchedPcbElm?._getGlobalPcbPositionBeforeLayout()??{x:0,y:0}}_getPcbCircuitJsonBounds(){if(!this.pcb_port_id)return super._getPcbCircuitJsonBounds();let{db:db2}=this.root,pcb_port2=db2.pcb_port.get(this.pcb_port_id);return{center:{x:pcb_port2.x,y:pcb_port2.y},bounds:{left:0,top:0,right:0,bottom:0},width:0,height:0}}_getGlobalPcbPositionAfterLayout(){return this._getPcbCircuitJsonBounds().center}_getPortsInternallyConnectedToThisPort(){let parent=this.parent;if(!parent||!parent._getInternallyConnectedPins)return[];let internallyConnectedPorts=parent._getInternallyConnectedPins();for(let ports of internallyConnectedPorts)if(ports.some(port=>port===this))return ports;return[]}_hasSchematicPort(){let{schX,schY}=this._parsedProps;if(schX!==void 0&&schY!==void 0)return!0;let parentNormalComponent=this.getParentNormalComponent();if(parentNormalComponent?.getSchematicSymbol())return!!(this.schematicSymbolPortDef||this._getPortsInternallyConnectedToThisPort().some(p2=>p2.schematicSymbolPortDef));let parentBoxDim=parentNormalComponent?._getSchematicBoxDimensions();return!!(parentBoxDim&&this.props.pinNumber!==void 0&&parentBoxDim.getPortPositionByPinNumber(this.props.pinNumber))}_getGlobalSchematicPositionBeforeLayout(){let{schX,schY}=this._parsedProps;if(schX!==void 0&&schY!==void 0)return{x:schX,y:schY};let parentNormalComponent=this.getParentNormalComponent(),symbol=parentNormalComponent?.getSchematicSymbol();if(symbol){let schematicSymbolPortDef=this.schematicSymbolPortDef;if(!schematicSymbolPortDef&&(schematicSymbolPortDef=this._getPortsInternallyConnectedToThisPort().find(p2=>p2.schematicSymbolPortDef)?.schematicSymbolPortDef??null,!schematicSymbolPortDef))throw new Error(`Couldn't find schematicSymbolPortDef for port ${this.getString()}, searched internally connected ports and none had a schematicSymbolPortDef. Why are we trying to get the schematic position of this port?`);let transform5=compose(parentNormalComponent.computeSchematicGlobalTransform(),translate(-symbol.center.x,-symbol.center.y));return applyToPoint(transform5,schematicSymbolPortDef)}let parentBoxDim=parentNormalComponent?._getSchematicBoxDimensions();if(parentBoxDim&&this.props.pinNumber!==void 0){let localPortPosition=parentBoxDim.getPortPositionByPinNumber(this.props.pinNumber);if(!localPortPosition)throw new Error(`Couldn't find position for schematic_port for port ${this.getString()} inside of the schematic box`);return applyToPoint(parentNormalComponent.computeSchematicGlobalTransform(),localPortPosition)}throw new Error(`Couldn't find position for schematic_port for port ${this.getString()}`)}_getGlobalSchematicPositionAfterLayout(){let{db:db2}=this.root;if(!this.schematic_port_id)throw new Error(`Can't get schematic port position after layout for "${this.getString()}", no schematic_port_id`);let schematic_port2=db2.schematic_port.get(this.schematic_port_id);if(!schematic_port2)throw new Error(`Schematic port not found when trying to get post-layout position: ${this.schematic_port_id}`);return schematic_port2.center}registerMatch(component){this.matchedComponents.push(component)}getNameAndAliases(){let{_parsedProps:props}=this;return Array.from(new Set([...props.name?[props.name]:[],...props.aliases??[],...typeof props.pinNumber=="number"?[`pin${props.pinNumber}`,props.pinNumber.toString()]:[],...this.externallyAddedAliases??[]]))}_getMatchingPinAttributes(){let pinAttributes=this.parent?._parsedProps?.pinAttributes;if(!pinAttributes)return[];let matches=[];for(let alias of this.getNameAndAliases()){let attributes2=pinAttributes[alias];attributes2&&matches.push(attributes2)}return matches}_shouldIncludeInBoardPinout(){return this._getMatchingPinAttributes().some(attributes2=>attributes2.includeInBoardPinout===!0)}isMatchingPort(port){return this.isMatchingAnyOf(port.getNameAndAliases())}getPortSelector(){return`.${(this.getParentNormalComponent()??this.parent)?.props.name} > port.${this.props.name}`}getAvailablePcbLayers(){let{layer,layers}=this._parsedProps;return layers||(layer?[layer]:Array.from(new Set(this.matchedComponents.flatMap(c3=>c3.getAvailablePcbLayers()))))}_getDirectlyConnectedTraces(){return this.getSubcircuit().selectAll("trace").filter(trace=>!trace._couldNotFindPort).filter(trace=>trace._isExplicitlyConnectedToPort(this))}doInitialSourceRender(){let{db:db2}=this.root,{_parsedProps:props}=this,port_hints=this.getNameAndAliases(),parentNormalComponent=this.getParentNormalComponent(),source_component_id=(this.parent?.source_component_id?this.parent:parentNormalComponent)?.source_component_id??null,pinAttributes=this._getMatchingPinAttributes(),portAttributesFromParent={};for(let attributes2 of pinAttributes)attributes2.mustBeConnected!==void 0&&(portAttributesFromParent.must_be_connected=attributes2.mustBeConnected);let source_port2=db2.source_port.insert({name:props.name,pin_number:props.pinNumber,port_hints,source_component_id,subcircuit_id:this.getSubcircuit()?.subcircuit_id,...portAttributesFromParent});this.source_port_id=source_port2.source_port_id}doInitialSourceParentAttachment(){let{db:db2}=this.root,parentNormalComponent=this.getParentNormalComponent(),parentWithSourceId=this.parent?.source_component_id?this.parent:parentNormalComponent;if(this.isGroupPort()){db2.source_port.update(this.source_port_id,{source_component_id:null,subcircuit_id:this.getSubcircuit()?.subcircuit_id});return}if(!parentWithSourceId?.source_component_id)throw new Error(`${this.getString()} has no parent source component (parent: ${this.parent?.getString()})`);db2.source_port.update(this.source_port_id,{source_component_id:parentWithSourceId.source_component_id,subcircuit_id:this.getSubcircuit()?.subcircuit_id}),this.source_component_id=parentWithSourceId.source_component_id}doInitialPcbPortRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,{matchedComponents}=this;if(this.isGroupPort()){let connectedPorts=this._getConnectedPortsFromConnectsTo();if(connectedPorts.length===0)return;let connectedPort=connectedPorts[0];if(!connectedPort.pcb_port_id)return;let connectedPcbPort=db2.pcb_port.get(connectedPort.pcb_port_id),matchCenter2={x:connectedPcbPort.x,y:connectedPcbPort.y},subcircuit=this.getSubcircuit(),pcb_port2=db2.pcb_port.insert({pcb_component_id:void 0,layers:connectedPort.getAvailablePcbLayers(),subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0,...matchCenter2,source_port_id:this.source_port_id,is_board_pinout:!1});this.pcb_port_id=pcb_port2.pcb_port_id;return}let parentNormalComponent=this.getParentNormalComponent(),parentWithPcbComponentId=this.parent?.pcb_component_id?this.parent:parentNormalComponent;if(!parentWithPcbComponentId?.pcb_component_id)throw new Error(`${this.getString()} has no parent pcb component, cannot render pcb_port (parent: ${this.parent?.getString()}, parentNormalComponent: ${parentNormalComponent?.getString()})`);let pcbMatches=matchedComponents.filter(c3=>c3.isPcbPrimitive);if(pcbMatches.length===0)return;let matchCenter=null;if(pcbMatches.length===1&&(matchCenter=pcbMatches[0]._getPcbCircuitJsonBounds().center),pcbMatches.length>1){if(!areAllPcbPrimitivesOverlapping(pcbMatches))throw new Error(`${this.getString()} has multiple non-overlapping pcb matches, unclear how to place pcb_port: ${pcbMatches.map(c3=>c3.getString()).join(", ")}. (Note: tscircuit core does not currently allow you to specify internally connected pcb primitives with the same port hints, try giving them different port hints and specifying they are connected externally- or file an issue)`);matchCenter=getCenterOfPcbPrimitives(pcbMatches)}if(matchCenter){let subcircuit=this.getSubcircuit(),isBoardPinout=this._shouldIncludeInBoardPinout(),pcb_port2=db2.pcb_port.insert({pcb_component_id:parentWithPcbComponentId.pcb_component_id,layers:this.getAvailablePcbLayers(),subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0,...isBoardPinout?{is_board_pinout:!0}:{},...matchCenter,source_port_id:this.source_port_id,is_board_pinout:this._isBoardPinoutFromAttributes()});this.pcb_port_id=pcb_port2.pcb_port_id}else{let pcbMatch=pcbMatches[0];throw new Error(`${pcbMatch.getString()} does not have a center or _getGlobalPcbPositionBeforeLayout method (needed for pcb_port placement)`)}}updatePcbPortRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root;if(this.pcb_port_id)return;if(this.isGroupPort()){let connectedPorts=this._getConnectedPortsFromConnectsTo();if(connectedPorts.length===0)return;let connectedPort=connectedPorts[0];if(!connectedPort.pcb_port_id)return;let connectedPcbPort=db2.pcb_port.get(connectedPort.pcb_port_id),matchCenter2={x:connectedPcbPort.x,y:connectedPcbPort.y},subcircuit2=this.getSubcircuit(),pcb_port22=db2.pcb_port.insert({pcb_component_id:void 0,layers:connectedPort.getAvailablePcbLayers(),subcircuit_id:subcircuit2?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0,...matchCenter2,source_port_id:this.source_port_id,is_board_pinout:!1});this.pcb_port_id=pcb_port22.pcb_port_id;return}let pcbMatches=this.matchedComponents.filter(c3=>c3.isPcbPrimitive);if(pcbMatches.length===0)return;let matchCenter=null;if(pcbMatches.length===1&&(matchCenter=pcbMatches[0]._getPcbCircuitJsonBounds().center),pcbMatches.length>1)try{areAllPcbPrimitivesOverlapping(pcbMatches)&&(matchCenter=getCenterOfPcbPrimitives(pcbMatches))}catch{}if(!matchCenter)return;let parentNormalComponent=this.getParentNormalComponent(),parentWithPcbComponentId=this.parent?.pcb_component_id?this.parent:parentNormalComponent,subcircuit=this.getSubcircuit(),isBoardPinout=this._shouldIncludeInBoardPinout(),pcb_port2=db2.pcb_port.insert({pcb_component_id:parentWithPcbComponentId?.pcb_component_id,layers:this.getAvailablePcbLayers(),subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0,...isBoardPinout?{is_board_pinout:!0}:{},...matchCenter,source_port_id:this.source_port_id,is_board_pinout:this._isBoardPinoutFromAttributes()});this.pcb_port_id=pcb_port2.pcb_port_id}_getBestDisplayPinLabel(){let{db:db2}=this.root,sourcePort=db2.source_port.get(this.source_port_id),labelHints=[];for(let portHint of sourcePort?.port_hints??[])portHint.match(/^(pin)?\d+$/)||portHint.match(/^(left|right)/)&&!sourcePort?.name.match(/^(left|right)/)||labelHints.push(portHint);if(this.getParentNormalComponent()?.props?.showPinAliases&&labelHints.length>0)return labelHints.join("/");if(labelHints.length>0)return labelHints[0]}doInitialSchematicPortRender(){let{db:db2}=this.root,{_parsedProps:props}=this,{schX,schY}=props,container=schX!==void 0&&schY!==void 0?this.getParentNormalComponent():this.getPrimitiveContainer();if(!container||!this._hasSchematicPort())return;let containerCenter=container._getGlobalSchematicPositionBeforeLayout(),portCenter=this._getGlobalSchematicPositionBeforeLayout(),localPortInfo=null,containerDims=container._getSchematicBoxDimensions();containerDims&&props.pinNumber!==void 0&&(localPortInfo=containerDims.getPortPositionByPinNumber(props.pinNumber)),this.getSubcircuit().props._schDebugObjectsEnabled&&db2.schematic_debug_object.insert({shape:"rect",center:portCenter,size:{width:.1,height:.1},label:"obstacle"}),localPortInfo?.side?this.facingDirection={left:"left",right:"right",top:"up",bottom:"down"}[localPortInfo.side]:this.facingDirection=getRelativeDirection(containerCenter,portCenter);let bestDisplayPinLabel=this._getBestDisplayPinLabel(),schematicPortInsertProps={type:"schematic_port",schematic_component_id:this.getParentNormalComponent()?.schematic_component_id,center:portCenter,source_port_id:this.source_port_id,facing_direction:this.facingDirection,distance_from_component_edge:.4,side_of_component:localPortInfo?.side,pin_number:props.pinNumber,true_ccw_index:localPortInfo?.trueIndex,display_pin_label:bestDisplayPinLabel,is_connected:!1};for(let attributes2 of this._getMatchingPinAttributes())attributes2.requiresPower&&(schematicPortInsertProps.has_input_arrow=!0),attributes2.providesPower&&(schematicPortInsertProps.has_output_arrow=!0);let schematic_port2=db2.schematic_port.insert(schematicPortInsertProps);this.schematic_port_id=schematic_port2.schematic_port_id}_getSubcircuitConnectivityKey(){return this.root?.db.source_port.get(this.source_port_id)?.subcircuit_connectivity_map_key}_setPositionFromLayout(newCenter){let{db:db2}=this.root;this.pcb_port_id&&db2.pcb_port.update(this.pcb_port_id,{x:newCenter.x,y:newCenter.y})}_hasMatchedPcbPrimitive(){return this.matchedComponents.some(c3=>c3.isPcbPrimitive)}_getNetLabelText(){return`${this.parent?.props.name}_${this.props.name}`}},getPinNumberFromLabels=labels=>{let pinNumber=labels.find(p2=>/^(pin)?\d+$/.test(p2));return pinNumber?Number.parseInt(pinNumber.replace(/^pin/,"")):null};function getPortFromHints(hints,opts){let pinNumber=getPinNumberFromLabels(hints);if(!pinNumber)return null;let aliases2=[...hints.filter(p2=>p2.toString()!==pinNumber.toString()&&p2!==`pin${pinNumber}`),...opts?.additionalAliases?.[`pin${pinNumber}`]??[]];return new Port({pinNumber,aliases:aliases2})}var hasExplicitPinMapping=pa3=>{for(let side of["leftSide","rightSide","topSide","bottomSide"])if(side in pa3&&typeof pa3[side]=="number")throw new Error(`A number was specified for "${side}", you probably meant to use "size" not "side"`);return"leftSide"in pa3||"rightSide"in pa3||"topSide"in pa3||"bottomSide"in pa3},getSizeOfSidesFromPortArrangement=pa3=>{if(hasExplicitPinMapping(pa3))return{leftSize:pa3.leftSide?.pins.length??0,rightSize:pa3.rightSide?.pins.length??0,topSize:pa3.topSide?.pins.length??0,bottomSize:pa3.bottomSide?.pins.length??0};let{leftSize=0,rightSize=0,topSize=0,bottomSize=0}=pa3;return{leftSize,rightSize,topSize,bottomSize}},DEFAULT_SCHEMATIC_BOX_PADDING_MM=.4;function isExplicitPinMappingArrangement(arrangement){let a2=arrangement;return a2.leftSide!==void 0||a2.rightSide!==void 0||a2.topSide!==void 0||a2.bottomSide!==void 0}var getAllDimensionsForSchematicBox=params=>{let portDistanceFromEdge=params.portDistanceFromEdge??.4,sidePinCounts=params.schPortArrangement?getSizeOfSidesFromPortArrangement(params.schPortArrangement):null,sideLengths={left:0,right:0,top:0,bottom:0},pinCount=params.pinCount??null;if(pinCount===null)if(sidePinCounts)pinCount=sidePinCounts.leftSize+sidePinCounts.rightSize+sidePinCounts.topSize;else throw new Error("Could not determine pin count for the schematic box");if(pinCount&&!sidePinCounts){let rightSize=Math.floor(pinCount/2);sidePinCounts={leftSize:pinCount-rightSize,rightSize,topSize:0,bottomSize:0}}sidePinCounts||(sidePinCounts={leftSize:0,rightSize:0,topSize:0,bottomSize:0});let getPinNumberUsingSideIndex=({side,sideIndex,truePinIndex:truePinIndex2})=>{if(!params.schPortArrangement||!isExplicitPinMappingArrangement(params.schPortArrangement))return truePinIndex2+1;let normalCcwDirection={left:"top-to-bottom",bottom:"left-to-right",right:"bottom-to-top",top:"right-to-left"}[side],directionAlongSide=params.schPortArrangement?.[`${side}Side`]?.direction??normalCcwDirection,pinsDefinitionForSide=params.schPortArrangement?.[`${side}Side`]?.pins,sideIndexWithDirectionCorrection=sideIndex;return directionAlongSide!==normalCcwDirection&&(sideIndexWithDirectionCorrection=pinsDefinitionForSide.length-sideIndex-1),parsePinNumberFromLabelsOrThrow(pinsDefinitionForSide[sideIndexWithDirectionCorrection],params.pinLabels)},orderedTruePorts=[],currentDistanceFromEdge=0,truePinIndex=0;for(let sideIndex=0;sideIndex<sidePinCounts.leftSize;sideIndex++){let pinNumber=getPinNumberUsingSideIndex({side:"left",sideIndex,truePinIndex}),pinStyle=params.numericSchPinStyle?.[`pin${pinNumber}`]??params.numericSchPinStyle?.[pinNumber];pinStyle?.topMargin&&(currentDistanceFromEdge+=pinStyle.topMargin),orderedTruePorts.push({trueIndex:truePinIndex,pinNumber,side:"left",distanceFromOrthogonalEdge:currentDistanceFromEdge}),pinStyle?.bottomMargin&&(currentDistanceFromEdge+=pinStyle.bottomMargin),sideIndex===sidePinCounts.leftSize-1?sideLengths.left=currentDistanceFromEdge:currentDistanceFromEdge+=params.schPinSpacing,truePinIndex++}currentDistanceFromEdge=0;for(let sideIndex=0;sideIndex<sidePinCounts.bottomSize;sideIndex++){let pinNumber=getPinNumberUsingSideIndex({side:"bottom",sideIndex,truePinIndex}),pinStyle=params.numericSchPinStyle?.[`pin${pinNumber}`]??params.numericSchPinStyle?.[pinNumber];pinStyle?.leftMargin&&(currentDistanceFromEdge+=pinStyle.leftMargin),orderedTruePorts.push({trueIndex:truePinIndex,pinNumber,side:"bottom",distanceFromOrthogonalEdge:currentDistanceFromEdge}),pinStyle?.rightMargin&&(currentDistanceFromEdge+=pinStyle.rightMargin),sideIndex===sidePinCounts.bottomSize-1?sideLengths.bottom=currentDistanceFromEdge:currentDistanceFromEdge+=params.schPinSpacing,truePinIndex++}currentDistanceFromEdge=0;for(let sideIndex=0;sideIndex<sidePinCounts.rightSize;sideIndex++){let pinNumber=getPinNumberUsingSideIndex({side:"right",sideIndex,truePinIndex}),pinStyle=params.numericSchPinStyle?.[`pin${pinNumber}`]??params.numericSchPinStyle?.[pinNumber];pinStyle?.bottomMargin&&(currentDistanceFromEdge+=pinStyle.bottomMargin),orderedTruePorts.push({trueIndex:truePinIndex,pinNumber,side:"right",distanceFromOrthogonalEdge:currentDistanceFromEdge}),pinStyle?.topMargin&&(currentDistanceFromEdge+=pinStyle.topMargin),sideIndex===sidePinCounts.rightSize-1?sideLengths.right=currentDistanceFromEdge:currentDistanceFromEdge+=params.schPinSpacing,truePinIndex++}currentDistanceFromEdge=0;for(let sideIndex=0;sideIndex<sidePinCounts.topSize;sideIndex++){let pinNumber=getPinNumberUsingSideIndex({side:"top",sideIndex,truePinIndex}),pinStyle=params.numericSchPinStyle?.[`pin${pinNumber}`]??params.numericSchPinStyle?.[pinNumber];pinStyle?.rightMargin&&(currentDistanceFromEdge+=pinStyle.rightMargin),orderedTruePorts.push({trueIndex:truePinIndex,pinNumber,side:"top",distanceFromOrthogonalEdge:currentDistanceFromEdge}),pinStyle?.leftMargin&&(currentDistanceFromEdge+=pinStyle.leftMargin),sideIndex===sidePinCounts.topSize-1?sideLengths.top=currentDistanceFromEdge:currentDistanceFromEdge+=params.schPinSpacing,truePinIndex++}let resolvedSchWidth=params.schWidth;if(resolvedSchWidth===void 0){resolvedSchWidth=Math.max(sideLengths.top+DEFAULT_SCHEMATIC_BOX_PADDING_MM,sideLengths.bottom+DEFAULT_SCHEMATIC_BOX_PADDING_MM),params.pinLabels&&orderedTruePorts.filter(p2=>p2.side==="left"||p2.side==="right").some(p2=>params.pinLabels?.[`pin${p2.pinNumber}`]||params.pinLabels?.[p2.pinNumber])&&(resolvedSchWidth=Math.max(resolvedSchWidth,.5));let labelWidth=params.pinLabels?Math.max(...Object.values(params.pinLabels).map(label=>label.length*.1)):0,LABEL_PADDING=labelWidth>0?1.1:0;resolvedSchWidth=Math.max(resolvedSchWidth,labelWidth+LABEL_PADDING)}let schHeight=params.schHeight;schHeight||(schHeight=Math.max(sideLengths.left+DEFAULT_SCHEMATIC_BOX_PADDING_MM,sideLengths.right+DEFAULT_SCHEMATIC_BOX_PADDING_MM));let trueEdgePositions={left:{x:-resolvedSchWidth/2-portDistanceFromEdge,y:sideLengths.left/2},bottom:{x:-sideLengths.bottom/2,y:-schHeight/2-portDistanceFromEdge},right:{x:resolvedSchWidth/2+portDistanceFromEdge,y:-sideLengths.right/2},top:{x:sideLengths.top/2,y:schHeight/2+portDistanceFromEdge}},trueEdgeTraversalDirections={left:{x:0,y:-1},right:{x:0,y:1},top:{x:-1,y:0},bottom:{x:1,y:0}},truePortsWithPositions=orderedTruePorts.map(p2=>{let{distanceFromOrthogonalEdge,side}=p2,edgePos=trueEdgePositions[side],edgeDir=trueEdgeTraversalDirections[side];return{x:edgePos.x+distanceFromOrthogonalEdge*edgeDir.x,y:edgePos.y+distanceFromOrthogonalEdge*edgeDir.y,...p2}});return{getPortPositionByPinNumber(pinNumber){let port=truePortsWithPositions.find(p2=>p2.pinNumber.toString()===pinNumber.toString());return port||null},getSize(){return{width:resolvedSchWidth,height:schHeight}},getSizeIncludingPins(){return{width:resolvedSchWidth+(sidePinCounts.leftSize||sidePinCounts.rightSize?.4:0),height:schHeight+(sidePinCounts.topSize||sidePinCounts.bottomSize?.4:0)}},pinCount}},debug22=(0,import_debug8.default)("tscircuit:core:footprint"),Footprint=class extends PrimitiveComponent2{get config(){return{componentName:"Footprint",zodProps:footprintProps}}doInitialPcbFootprintLayout(){if(this.root?.pcbDisabled)return;let constraints=this.children.filter(child=>child.componentName==="Constraint");if(constraints.length===0)return;let{isFlipped}=this._getPcbPrimitiveFlippedHelpers(),maybeFlipLeftRight=props=>isFlipped&&"left"in props&&"right"in props?{...props,left:props.right,right:props.left}:props,involvedComponents=constraints.flatMap(constraint=>constraint._getAllReferencedComponents().componentsWithSelectors).map(({component,selector,componentSelector,edge})=>({component,selector,componentSelector,edge,bounds:component._getPcbCircuitJsonBounds()}));if(involvedComponents.some(c3=>c3.edge))throw new Error("edge constraints not implemented yet for footprint layout, contributions welcome!");function getComponentDetails(selector){return involvedComponents.find(({selector:s3})=>s3===selector)}let solver=new Solver,kVars={};function getKVar(name){return name in kVars||(kVars[name]=new Variable(name),solver.addEditVariable(kVars[name],Strength.weak)),kVars[name]}for(let{selector,bounds:bounds2}of involvedComponents){let kvx=getKVar(`${selector}_x`),kvy=getKVar(`${selector}_y`);solver.suggestValue(kvx,bounds2.center.x),solver.suggestValue(kvy,bounds2.center.y)}for(let constraint of constraints){let props=constraint._parsedProps;if("xDist"in props){let{xDist,left,right,edgeToEdge,centerToCenter}=maybeFlipLeftRight(props),leftVar=getKVar(`${left}_x`),rightVar=getKVar(`${right}_x`),leftBounds=getComponentDetails(left)?.bounds,rightBounds=getComponentDetails(right)?.bounds;if(centerToCenter){let expr=new Expression(rightVar,[-1,leftVar]);solver.addConstraint(new Constraint(expr,Operator.Eq,props.xDist,Strength.required))}else if(edgeToEdge){let expr=new Expression(rightVar,-rightBounds.width/2,[-1,leftVar],-leftBounds.width/2);solver.addConstraint(new Constraint(expr,Operator.Eq,props.xDist,Strength.required))}}else if("yDist"in props){let{yDist,top,bottom,edgeToEdge,centerToCenter}=props,topVar=getKVar(`${top}_y`),bottomVar=getKVar(`${bottom}_y`),topBounds=getComponentDetails(top)?.bounds,bottomBounds=getComponentDetails(bottom)?.bounds;if(centerToCenter){let expr=new Expression(topVar,[-1,bottomVar]);solver.addConstraint(new Constraint(expr,Operator.Eq,props.yDist,Strength.required))}else if(edgeToEdge){let expr=new Expression(topVar,topBounds.height/2,[-1,bottomVar],-bottomBounds.height/2);solver.addConstraint(new Constraint(expr,Operator.Eq,props.yDist,Strength.required))}}else if("sameY"in props){let{for:selectors}=props;if(selectors.length<2)continue;let vars=selectors.map(selector=>getKVar(`${selector}_y`)),expr=new Expression(...vars.slice(1));solver.addConstraint(new Constraint(expr,Operator.Eq,vars[0],Strength.required))}else if("sameX"in props){let{for:selectors}=props;if(selectors.length<2)continue;let vars=selectors.map(selector=>getKVar(`${selector}_x`)),expr=new Expression(...vars.slice(1));solver.addConstraint(new Constraint(expr,Operator.Eq,vars[0],Strength.required))}}solver.updateVariables(),debug22.enabled&&(console.log("Solution to layout constraints:"),console.table(Object.entries(kVars).map(([key,kvar])=>({var:key,val:kvar.value()}))));let bounds={left:1/0,right:-1/0,top:-1/0,bottom:1/0};for(let{selector,bounds:{width,height}}of involvedComponents){let kvx=getKVar(`${selector}_x`),kvy=getKVar(`${selector}_y`),newLeft=kvx.value()-width/2,newRight=kvx.value()+width/2,newTop=kvy.value()+height/2,newBottom=kvy.value()-height/2;bounds.left=Math.min(bounds.left,newLeft),bounds.right=Math.max(bounds.right,newRight),bounds.top=Math.max(bounds.top,newTop),bounds.bottom=Math.min(bounds.bottom,newBottom)}let globalOffset={x:-(bounds.right+bounds.left)/2,y:-(bounds.top+bounds.bottom)/2},containerPos=this.getPrimitiveContainer()._getGlobalPcbPositionBeforeLayout();globalOffset.x+=containerPos.x,globalOffset.y+=containerPos.y;for(let{component,selector}of involvedComponents){let kvx=getKVar(`${selector}_x`),kvy=getKVar(`${selector}_y`);component._setPositionFromLayout({x:kvx.value()+globalOffset.x,y:kvy.value()+globalOffset.y})}}},getFileExtension=filename=>{if(!filename)return null;let fragmentMatch=filename.match(/#ext=(\w+)$/);if(fragmentMatch)return fragmentMatch[1].toLowerCase();let sanitized=filename.split("?")[0].split("#")[0],lastSegment=sanitized.split("/").pop()??sanitized;return lastSegment.includes(".")?lastSegment.split(".").pop()?.toLowerCase()??null:null},joinUrlPath=(base,path)=>{let trimmedBase=base.replace(/\/+$/,""),trimmedPath=path.replace(/^\/+/,"");return`${trimmedBase}/${trimmedPath}`},constructAssetUrl=(targetUrl,baseUrl)=>{if(!baseUrl||!targetUrl.startsWith("/"))return targetUrl;try{let baseUrlObj=new URL(baseUrl);return baseUrlObj.pathname!=="/"&&targetUrl.startsWith(baseUrlObj.pathname)?new URL(targetUrl,baseUrlObj.origin).toString():joinUrlPath(baseUrl,targetUrl)}catch{return targetUrl}},rotation2=external_exports.union([external_exports.number(),external_exports.string()]),rotation3=external_exports.object({x:rotation2,y:rotation2,z:rotation2}),CadModel=class extends PrimitiveComponent2{get config(){return{componentName:"CadModel",zodProps:cadmodelProps}}doInitialCadModelRender(){let parent=this._findParentWithPcbComponent();if(!parent||!parent.pcb_component_id)return;let{db:db2}=this.root,{boardThickness=0}=this.root?._getBoard()??{},bounds=parent._getPcbCircuitJsonBounds(),pcb_component2=db2.pcb_component.get(parent.pcb_component_id),props=this._parsedProps;if(!props||typeof props.modelUrl!="string"&&typeof props.stepUrl!="string")return;let parentTransform=parent._computePcbGlobalTransformBeforeLayout(),accumulatedRotation=decomposeTSR(parentTransform).rotation.angle*180/Math.PI,rotationOffset=rotation3.parse({x:0,y:0,z:0});if(typeof props.rotationOffset=="number")rotationOffset.z=Number(props.rotationOffset);else if(typeof props.rotationOffset=="object"){let parsed=rotation3.parse(props.rotationOffset);rotationOffset.x=Number(parsed.x),rotationOffset.y=Number(parsed.y),rotationOffset.z=Number(parsed.z)}let{pcbX,pcbY}=this.getResolvedPcbPositionProp(),positionOffset=point32.parse({x:pcbX,y:pcbY,z:props.pcbZ??0,...typeof props.positionOffset=="object"?props.positionOffset:{}}),zOffsetFromSurface=props.zOffsetFromSurface!==void 0?distance.parse(props.zOffsetFromSurface):0,layer=parent.props.layer==="bottom"?"bottom":"top",ext=props.modelUrl?getFileExtension(props.modelUrl):void 0,modelUrlWithoutExtFragment=props.modelUrl?.replace(/#ext=\w+$/,""),urlProps={};if(ext==="stl"?urlProps.model_stl_url=this._addCachebustToModelUrl(modelUrlWithoutExtFragment):ext==="obj"?urlProps.model_obj_url=this._addCachebustToModelUrl(modelUrlWithoutExtFragment):ext==="gltf"?urlProps.model_gltf_url=this._addCachebustToModelUrl(modelUrlWithoutExtFragment):ext==="glb"?urlProps.model_glb_url=this._addCachebustToModelUrl(modelUrlWithoutExtFragment):ext==="step"||ext==="stp"?urlProps.model_step_url=this._addCachebustToModelUrl(modelUrlWithoutExtFragment):ext==="wrl"||ext==="vrml"?urlProps.model_wrl_url=this._addCachebustToModelUrl(modelUrlWithoutExtFragment):urlProps.model_stl_url=this._addCachebustToModelUrl(modelUrlWithoutExtFragment),props.stepUrl){let transformed=this._addCachebustToModelUrl(props.stepUrl);transformed&&(urlProps.model_step_url=transformed)}let cad=db2.cad_component.insert({position:{x:bounds.center.x+Number(positionOffset.x),y:bounds.center.y+Number(positionOffset.y),z:(layer==="bottom"?-boardThickness/2:boardThickness/2)+(layer==="bottom"?-zOffsetFromSurface:zOffsetFromSurface)+Number(positionOffset.z)},rotation:{x:Number(rotationOffset.x),y:(layer==="top"?0:180)+Number(rotationOffset.y),z:layer==="bottom"?-(accumulatedRotation+Number(rotationOffset.z))+180:accumulatedRotation+Number(rotationOffset.z)},pcb_component_id:parent.pcb_component_id,source_component_id:parent.source_component_id,model_unit_to_mm_scale_factor:typeof props.modelUnitToMmScale=="number"?props.modelUnitToMmScale:void 0,show_as_translucent_model:parent._parsedProps.showAsTranslucentModel,...urlProps});this.cad_component_id=cad.cad_component_id}_findParentWithPcbComponent(){let p2=this.parent;for(;p2&&!p2.pcb_component_id;)p2=p2.parent;return p2}_addCachebustToModelUrl(url){if(!url)return url;let baseUrl=this.root?.platform?.projectBaseUrl,transformedUrl=constructAssetUrl(url,baseUrl);if(!transformedUrl.includes("modelcdn.tscircuit.com"))return transformedUrl;let origin=this.root?.getClientOrigin()??"";return`${transformedUrl}${transformedUrl.includes("?")?"&":"?"}cachebust_origin=${encodeURIComponent(origin)}`}},CadAssembly=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"isPrimitiveContainer",!0)}get config(){return{componentName:"CadAssembly",zodProps:cadassemblyProps}}},getNumericSchPinStyle=(pinStyles,pinLabels)=>{if(!pinStyles)return;let numericPinStyles={};for(let[pinNameOrLabel,pinStyle]of Object.entries(pinStyles)){let pinNumber=parsePinNumberFromLabelsOrThrow(pinNameOrLabel,pinLabels),pinStyleWithSideFirst={leftMargin:pinStyle.marginLeft??pinStyle.leftMargin,rightMargin:pinStyle.marginRight??pinStyle.rightMargin,topMargin:pinStyle.marginTop??pinStyle.topMargin,bottomMargin:pinStyle.marginBottom??pinStyle.bottomMargin};numericPinStyles[`pin${pinNumber}`]={...numericPinStyles[`pin${pinNumber}`],...pinStyleWithSideFirst}}return numericPinStyles},DirectLineRouter=class{constructor({input:input2}){__publicField(this,"input");this.input=input2}solveAndMapToTraces(){let traces=[];for(let connection of this.input.connections){if(connection.pointsToConnect.length!==2)continue;let[start,end]=connection.pointsToConnect,trace={type:"pcb_trace",pcb_trace_id:"",connection_name:connection.name,route:[{route_type:"wire",x:start.x,y:start.y,layer:"top",width:.1},{route_type:"wire",x:end.x,y:end.y,layer:"top",width:.1}]};traces.push(trace)}return traces}},computeObstacleBounds=obstacles=>{let minX=Math.min(...obstacles.map(o4=>o4.center.x)),maxX=Math.max(...obstacles.map(o4=>o4.center.x)),minY=Math.min(...obstacles.map(o4=>o4.center.y)),maxY=Math.max(...obstacles.map(o4=>o4.center.y));return{minX,maxX,minY,maxY}},LAYER_SELECTION_PREFERENCE=["top","bottom","inner1","inner2"],findPossibleTraceLayerCombinations=(hints,layer_path=[])=>{let candidates=[];if(layer_path.length===0){let starting_layers=hints[0].layers;for(let layer of starting_layers)candidates.push(...findPossibleTraceLayerCombinations(hints.slice(1),[layer]));return candidates}if(hints.length===0)return[];let current_hint=hints[0],is_possibly_via=current_hint.via||current_hint.optional_via,last_layer=layer_path[layer_path.length-1];if(hints.length===1){let last_hint=current_hint;return last_hint.layers&&is_possibly_via?last_hint.layers.map(layer=>({layer_path:[...layer_path,layer]})):last_hint.layers?.includes(last_layer)?[{layer_path:[...layer_path,last_layer]}]:[]}if(!is_possibly_via)return current_hint.layers&&!current_hint.layers.includes(last_layer)?[]:findPossibleTraceLayerCombinations(hints.slice(1),layer_path.concat([last_layer]));let candidate_next_layers=(current_hint.optional_via?LAYER_SELECTION_PREFERENCE:LAYER_SELECTION_PREFERENCE.filter(layer=>layer!==last_layer)).filter(layer=>!current_hint.layers||current_hint.layers?.includes(layer));for(let candidate_next_layer of candidate_next_layers)candidates.push(...findPossibleTraceLayerCombinations(hints.slice(1),layer_path.concat(candidate_next_layer)));return candidates};function getDominantDirection(edge){let delta={x:edge.to.x-edge.from.x,y:edge.to.y-edge.from.y},absX=Math.abs(delta.x),absY=Math.abs(delta.y);return absX>absY?delta.x>0?"right":"left":delta.y>0?"down":"up"}function pdist(a2,b3){return Math.hypot(a2.x-b3.x,a2.y-b3.y)}var mergeRoutes=routes=>{if(routes.length===1)return routes[0];if(routes.some(r4=>r4.length===0))throw new Error("Cannot merge routes with zero length");let merged=[],first_route_fp=routes[0][0],first_route_lp=routes[0][routes[0].length-1],second_route_fp=routes[1][0],second_route_lp=routes[1][routes[1].length-1],best_reverse_dist=Math.min(pdist(first_route_fp,second_route_fp),pdist(first_route_fp,second_route_lp)),best_normal_dist=Math.min(pdist(first_route_lp,second_route_fp),pdist(first_route_lp,second_route_lp));best_reverse_dist<best_normal_dist?merged.push(...routes[0].reverse()):merged.push(...routes[0]);for(let i3=1;i3<routes.length;i3++){let last_merged_point=merged[merged.length-1],next_route=routes[i3],next_first_point=next_route[0],next_last_point=next_route[next_route.length-1],distance_to_first=pdist(last_merged_point,next_first_point),distance_to_last=pdist(last_merged_point,next_last_point);distance_to_first<distance_to_last?merged.push(...next_route):merged.push(...next_route.reverse())}for(let i3=1;i3<merged.length-1;i3++){let lastPoint=merged[i3-1],currentPoint=merged[i3];lastPoint.route_type==="wire"&&currentPoint.route_type==="wire"&&lastPoint.layer!==currentPoint.layer&&merged.splice(i3,0,{x:lastPoint.x,y:lastPoint.y,from_layer:lastPoint.layer,to_layer:currentPoint.layer,route_type:"via"})}return merged},getDistance=(a2,b3)=>{let aPos="_getGlobalPcbPositionBeforeLayout"in a2?a2._getGlobalPcbPositionBeforeLayout():a2,bPos="_getGlobalPcbPositionBeforeLayout"in b3?b3._getGlobalPcbPositionBeforeLayout():b3;return Math.sqrt((aPos.x-bPos.x)**2+(aPos.y-bPos.y)**2)};function getClosest(point23,candidates){if(candidates.length===0)throw new Error("No candidates given to getClosest method");let closest=candidates[0],closestDist=1/0;for(let candidate of candidates){let dist=getDistance(point23,candidate);dist<closestDist&&(closest=candidate,closestDist=dist)}return closest}var countComplexElements=(junctions,edges)=>{let count=0;count+=junctions.length??0,count+=edges.filter(edge=>edge.is_crossing).length;for(let i3=1;i3<edges.length;i3++){let prev=edges[i3-1],curr=edges[i3],prevVertical=Math.abs(prev.from.x-prev.to.x)<.01,currVertical=Math.abs(curr.from.x-curr.to.x)<.01;prevVertical!==currVertical&&count++}return count},getEnteringEdgeFromDirection=direction2=>({up:"bottom",down:"top",left:"right",right:"left"})[direction2]??null,getStubEdges=({firstEdge,firstEdgePort,firstDominantDirection,lastEdge,lastEdgePort,lastDominantDirection})=>{if(firstEdge&&firstEdgePort)return getStubEdges({lastEdge:{from:firstEdge.to,to:firstEdge.from},lastEdgePort:firstEdgePort,lastDominantDirection:firstDominantDirection}).reverse().map(e4=>({from:e4.to,to:e4.from}));let edges=[];if(lastEdge&&lastEdgePort){let intermediatePoint={x:lastEdge.to.x,y:lastEdge.to.y};lastDominantDirection==="left"||lastDominantDirection==="right"?(intermediatePoint.x=lastEdgePort.position.x,edges.push({from:lastEdge.to,to:{...intermediatePoint}}),edges.push({from:intermediatePoint,to:{...lastEdgePort.position}})):(intermediatePoint.y=lastEdgePort.position.y,edges.push({from:lastEdge.to,to:{...intermediatePoint}}),edges.push({from:intermediatePoint,to:{...lastEdgePort.position}}))}return edges=edges.filter(e4=>distance4(e4.from,e4.to)>.01),edges};function tryNow(fn3){try{return[fn3(),null]}catch(e4){return[null,e4]}}var getMaxLengthFromConnectedCapacitors=(ports,{db:db2})=>{let capacitorMaxLengths=ports.map(port=>{let sourcePort=db2.source_port.get(port.source_port_id);if(!sourcePort?.source_component_id)return null;let sourceComponent=db2.source_component.get(sourcePort.source_component_id);return sourceComponent?.ftype==="simple_capacitor"?sourceComponent.max_decoupling_trace_length:null}).filter(length7=>length7!==null);if(capacitorMaxLengths.length!==0)return Math.min(...capacitorMaxLengths)};function getTraceDisplayName({ports,nets}){if(ports.length>=2)return`${ports[0]?.selector} to ${ports[1]?.selector}`;if(ports.length===1&&nets.length===1)return`${ports[0]?.selector} to net.${nets[0]._parsedProps.name}`}var isRouteOutsideBoard=(mergedRoute,{db:db2})=>{let pcbBoard=db2.pcb_board.list()[0];if(pcbBoard.outline){let boardOutline=pcbBoard.outline,isInsidePolygon=(point23,polygon2)=>{let inside2=!1;for(let i3=0,j3=polygon2.length-1;i3<polygon2.length;j3=i3++){let xi3=polygon2[i3].x,yi3=polygon2[i3].y,xj=polygon2[j3].x,yj=polygon2[j3].y;yi3>point23.y!=yj>point23.y&&point23.x<(xj-xi3)*(point23.y-yi3)/(yj-yi3)+xi3&&(inside2=!inside2)}return inside2};return mergedRoute.some(point23=>!isInsidePolygon(point23,boardOutline))}let boardWidth=pcbBoard.width,boardHeight=pcbBoard.height,boardCenterX=pcbBoard.center.x,boardCenterY=pcbBoard.center.y;return mergedRoute.some(point23=>point23.x<boardCenterX-boardWidth/2||point23.y<boardCenterY-boardHeight/2||point23.x>boardCenterX+boardWidth/2||point23.y>boardCenterY+boardHeight/2)},isCloseTo2=(a2,b3)=>Math.abs(a2-b3)<1e-4,getObstaclesFromRoute2=(route,source_trace_id,{viaDiameter=.5}={})=>{let obstacles=[];for(let i3=0;i3<route.length-1;i3++){let[start,end]=[route[i3],route[i3+1]],prev=i3-1>=0?route[i3-1]:null,isHorz=isCloseTo2(start.y,end.y),isVert=isCloseTo2(start.x,end.x);if(!isHorz&&!isVert)throw new Error(`getObstaclesFromTrace currently only supports horizontal and vertical traces (not diagonals) Conflicting trace: ${source_trace_id}, start: (${start.x}, ${start.y}), end: (${end.x}, ${end.y})`);let obstacle={type:"rect",layers:[start.layer],center:{x:(start.x+end.x)/2,y:(start.y+end.y)/2},width:isHorz?Math.abs(start.x-end.x):.1,height:isVert?Math.abs(start.y-end.y):.1,connectedTo:[source_trace_id]};if(obstacles.push(obstacle),prev&&prev.layer===start.layer&&start.layer!==end.layer){let via={type:"rect",layers:[start.layer,end.layer],center:{x:start.x,y:start.y},connectedTo:[source_trace_id],width:viaDiameter,height:viaDiameter};obstacles.push(via)}}return obstacles};function generateApproximatingRects2(rotatedRect,numRects=2){let{center:center2,width,height,rotation:rotation4}=rotatedRect,rects=[],angleRad=rotation4*Math.PI/180,cosAngle=Math.cos(angleRad),sinAngle=Math.sin(angleRad),normalizedRotation=(rotation4%360+360)%360;if(height<=width?normalizedRotation>=45&&normalizedRotation<135||normalizedRotation>=225&&normalizedRotation<315:normalizedRotation>=135&&normalizedRotation<225||normalizedRotation>=315||normalizedRotation<45){let sliceWidth=width/numRects;for(let i3=0;i3<numRects;i3++){let x3=(i3-numRects/2+.5)*sliceWidth,rotatedX=-x3*cosAngle,rotatedY=-x3*sinAngle,coverageWidth=sliceWidth*1.1,coverageHeight=Math.abs(height*cosAngle)+Math.abs(sliceWidth*sinAngle);rects.push({center:{x:center2.x+rotatedX,y:center2.y+rotatedY},width:coverageWidth,height:coverageHeight})}}else{let sliceHeight=height/numRects;for(let i3=0;i3<numRects;i3++){let y3=(i3-numRects/2+.5)*sliceHeight,rotatedX=-y3*sinAngle,rotatedY=y3*cosAngle,coverageWidth=Math.abs(width*cosAngle)+Math.abs(sliceHeight*sinAngle),coverageHeight=sliceHeight*1.1;rects.push({center:{x:center2.x+rotatedX,y:center2.y+rotatedY},width:coverageWidth,height:coverageHeight})}}return rects}function fillPolygonWithRects(polygon2,options={}){if(polygon2.length<3)return[];let{rectHeight=.1}=options,rects=[],yCoords=polygon2.map(p2=>p2.y),minY=Math.min(...yCoords),maxY=Math.max(...yCoords);for(let y3=minY;y3<maxY;y3+=rectHeight){let scanlineY=y3+rectHeight/2,intersections=[];for(let i3=0;i3<polygon2.length;i3++){let p12=polygon2[i3],p2=polygon2[(i3+1)%polygon2.length];if(p12.y<=scanlineY&&p2.y>scanlineY||p2.y<=scanlineY&&p12.y>scanlineY){let x3=(scanlineY-p12.y)*(p2.x-p12.x)/(p2.y-p12.y)+p12.x;intersections.push(x3)}}intersections.sort((a2,b3)=>a2-b3);for(let i3=0;i3<intersections.length;i3+=2)if(i3+1<intersections.length){let x12=intersections[i3],width=intersections[i3+1]-x12;width>1e-6&&rects.push({center:{x:x12+width/2,y:scanlineY},width,height:rectHeight})}}return rects}function fillCircleWithRects(circle2,options={}){let{center:center2,radius}=circle2,{rectHeight=.1}=options,rects=[],numSlices=Math.ceil(radius*2/rectHeight);for(let i3=0;i3<numSlices;i3++){let y3=center2.y-radius+(i3+.5)*rectHeight,dy2=y3-center2.y,halfWidth=Math.sqrt(radius*radius-dy2*dy2);halfWidth>0&&rects.push({center:{x:center2.x,y:y3},width:halfWidth*2,height:rectHeight})}return rects}var EVERY_LAYER2=["top","inner1","inner2","bottom"],getObstaclesFromCircuitJson2=(soup,connMap)=>{let withNetId=idList=>connMap?idList.concat(idList.map(id2=>connMap?.getNetConnectedToId(id2)).filter(Boolean)):idList,obstacles=[];for(let element of soup)if(element.type==="pcb_smtpad"){if(element.shape==="circle")obstacles.push({type:"oval",layers:[element.layer],center:{x:element.x,y:element.y},width:element.radius*2,height:element.radius*2,connectedTo:withNetId([element.pcb_smtpad_id])});else if(element.shape==="rect")obstacles.push({type:"rect",layers:[element.layer],center:{x:element.x,y:element.y},width:element.width,height:element.height,connectedTo:withNetId([element.pcb_smtpad_id])});else if(element.shape==="rotated_rect"){let rotatedRect={center:{x:element.x,y:element.y},width:element.width,height:element.height,rotation:element.ccw_rotation},approximatingRects=generateApproximatingRects2(rotatedRect);for(let rect of approximatingRects)obstacles.push({type:"rect",layers:[element.layer],center:rect.center,width:rect.width,height:rect.height,connectedTo:withNetId([element.pcb_smtpad_id])})}}else if(element.type==="pcb_keepout")element.shape==="circle"?obstacles.push({type:"oval",layers:element.layers,center:{x:element.center.x,y:element.center.y},width:element.radius*2,height:element.radius*2,connectedTo:[]}):element.shape==="rect"&&obstacles.push({type:"rect",layers:element.layers,center:{x:element.center.x,y:element.center.y},width:element.width,height:element.height,connectedTo:[]});else if(element.type==="pcb_cutout"){if(element.shape==="rect")obstacles.push({type:"rect",layers:EVERY_LAYER2,center:{x:element.center.x,y:element.center.y},width:element.width,height:element.height,connectedTo:[]});else if(element.shape==="circle"){let approximatingRects=fillCircleWithRects({center:element.center,radius:element.radius},{rectHeight:.6});for(let rect of approximatingRects)obstacles.push({type:"rect",layers:EVERY_LAYER2,center:rect.center,width:rect.width,height:rect.height,connectedTo:[]})}else if(element.shape==="polygon"){let approximatingRects=fillPolygonWithRects(element.points,{rectHeight:.6});for(let rect of approximatingRects)obstacles.push({type:"rect",layers:EVERY_LAYER2,center:rect.center,width:rect.width,height:rect.height,connectedTo:[]})}}else if(element.type==="pcb_hole")element.hole_shape==="oval"?obstacles.push({type:"oval",center:{x:element.x,y:element.y},width:element.hole_width,height:element.hole_height,connectedTo:[]}):element.hole_shape==="rect"?obstacles.push({type:"rect",layers:EVERY_LAYER2,center:{x:element.x,y:element.y},width:element.hole_width,height:element.hole_height,connectedTo:[]}):element.hole_shape==="square"?obstacles.push({type:"rect",layers:EVERY_LAYER2,center:{x:element.x,y:element.y},width:element.hole_diameter,height:element.hole_diameter,connectedTo:[]}):(element.hole_shape==="round"||element.hole_shape==="circle")&&obstacles.push({type:"rect",layers:EVERY_LAYER2,center:{x:element.x,y:element.y},width:element.hole_diameter,height:element.hole_diameter,connectedTo:[]});else if(element.type==="pcb_plated_hole"){if(element.shape==="circle")obstacles.push({type:"oval",layers:EVERY_LAYER2,center:{x:element.x,y:element.y},width:element.outer_diameter,height:element.outer_diameter,connectedTo:withNetId([element.pcb_plated_hole_id])});else if(element.shape==="circular_hole_with_rect_pad")obstacles.push({type:"rect",layers:EVERY_LAYER2,center:{x:element.x,y:element.y},width:element.rect_pad_width,height:element.rect_pad_height,connectedTo:withNetId([element.pcb_plated_hole_id])});else if(element.shape==="oval"||element.shape==="pill")obstacles.push({type:"oval",layers:EVERY_LAYER2,center:{x:element.x,y:element.y},width:element.outer_width,height:element.outer_height,connectedTo:withNetId([element.pcb_plated_hole_id])});else if(element.shape==="hole_with_polygon_pad"&&"pad_outline"in element&&element.pad_outline&&element.pad_outline.length>0){let xs3=element.pad_outline.map(p2=>element.x+p2.x),ys3=element.pad_outline.map(p2=>element.y+p2.y),minX=Math.min(...xs3),maxX=Math.max(...xs3),minY=Math.min(...ys3),maxY=Math.max(...ys3),centerX=(minX+maxX)/2,centerY=(minY+maxY)/2;obstacles.push({type:"rect",layers:EVERY_LAYER2,center:{x:centerX,y:centerY},width:maxX-minX,height:maxY-minY,connectedTo:withNetId([element.pcb_plated_hole_id])})}}else if(element.type==="pcb_trace"){let traceObstacles=getObstaclesFromRoute2(element.route.map(rp2=>({x:rp2.x,y:rp2.y,layer:"layer"in rp2?rp2.layer:rp2.from_layer})),element.source_trace_id);obstacles.push(...traceObstacles)}else if(element.type==="pcb_via"){let netIsAssignable=!!(element.net_is_assignable??element.netIsAssignable);obstacles.push({type:"rect",layers:element.layers,center:{x:element.x,y:element.y},connectedTo:[],width:element.outer_diameter,height:element.outer_diameter,netIsAssignable:netIsAssignable||void 0})}return obstacles},computeSchematicNetLabelCenter=({anchor_position,anchor_side,text,font_size=.18})=>{let charWidth=.1*(font_size/.18),width=text.length*charWidth,height=font_size,center2={...anchor_position};switch(anchor_side){case"right":center2.x-=width/2;break;case"left":center2.x+=width/2;break;case"top":center2.y-=height/2;break;case"bottom":center2.y+=height/2;break}return center2},getOtherSchematicTraces=({db:db2,source_trace_id,sameNetOnly,differentNetOnly})=>{!sameNetOnly&&!differentNetOnly&&(differentNetOnly=!0);let mySourceTrace=db2.source_trace.get(source_trace_id),traces=[];for(let otherSchematicTrace of db2.schematic_trace.list()){if(otherSchematicTrace.source_trace_id===source_trace_id)continue;let isSameNet=db2.source_trace.get(otherSchematicTrace.source_trace_id)?.subcircuit_connectivity_map_key===mySourceTrace.subcircuit_connectivity_map_key;differentNetOnly&&isSameNet||sameNetOnly&&!isSameNet||traces.push(otherSchematicTrace)}return traces},createSchematicTraceCrossingSegments=({edges:inputEdges,otherEdges})=>{let edges=[...inputEdges];for(let i3=0;i3<edges.length;i3++){if(i3>2e3)throw new Error("Over 2000 iterations spent inside createSchematicTraceCrossingSegments, you have triggered an infinite loop, please report this!");let edge=edges[i3],edgeOrientation=Math.abs(edge.from.x-edge.to.x)<.01?"vertical":edge.from.y===edge.to.y?"horizontal":"not-orthogonal";if(edgeOrientation==="not-orthogonal")continue;let otherEdgesIntersections=[];for(let otherEdge of otherEdges){let otherOrientation=otherEdge.from.x===otherEdge.to.x?"vertical":otherEdge.from.y===otherEdge.to.y?"horizontal":"not-orthogonal";if(otherOrientation==="not-orthogonal"||edgeOrientation===otherOrientation)continue;if(doesLineIntersectLine2([edge.from,edge.to],[otherEdge.from,otherEdge.to],{lineThickness:.01})){let intersectX=edgeOrientation==="vertical"?edge.from.x:otherEdge.from.x,intersectY=edgeOrientation==="vertical"?otherEdge.from.y:edge.from.y,crossingPoint2={x:intersectX,y:intersectY};otherEdgesIntersections.push({otherEdge,crossingPoint:crossingPoint2,distanceFromEdgeFrom:distance4(edge.from,crossingPoint2)})}}if(otherEdgesIntersections.length===0)continue;let closestIntersection=otherEdgesIntersections[0];for(let intersection of otherEdgesIntersections)intersection.distanceFromEdgeFrom<closestIntersection.distanceFromEdgeFrom&&(closestIntersection=intersection);let crossingPoint=closestIntersection.crossingPoint,crossingSegmentLength=.075;if(crossingPoint.x===edge.from.x&&crossingPoint.y===edge.from.y)continue;let crossingUnitVec=getUnitVectorFromPointAToB2(edge.from,crossingPoint),beforeCrossing={x:crossingPoint.x-crossingUnitVec.x*crossingSegmentLength/2,y:crossingPoint.y-crossingUnitVec.y*crossingSegmentLength/2},afterCrossing={x:crossingPoint.x+crossingUnitVec.x*crossingSegmentLength/2,y:crossingPoint.y+crossingUnitVec.y*crossingSegmentLength/2},overshot=distance4(afterCrossing,edge.to)<crossingSegmentLength,newEdges=[{from:edge.from,to:beforeCrossing},{from:beforeCrossing,to:afterCrossing,is_crossing:!0},{from:afterCrossing,to:edge.to}];edges.splice(i3,1,...newEdges),i3+=newEdges.length-2,overshot&&i3++}return edges},TOLERANCE=.001,isPointWithinEdge=(point23,edge)=>{let minX=Math.min(edge.from.x,edge.to.x),maxX=Math.max(edge.from.x,edge.to.x),minY=Math.min(edge.from.y,edge.to.y),maxY=Math.max(edge.from.y,edge.to.y);return point23.x>=minX&&point23.x<=maxX&&point23.y>=minY&&point23.y<=maxY},getEdgeOrientation=edge=>{let isVertical3=Math.abs(edge.from.x-edge.to.x)<TOLERANCE,isHorizontal2=Math.abs(edge.from.y-edge.to.y)<TOLERANCE;return isVertical3?"vertical":isHorizontal2?"horizontal":"diagonal"},getIntersectionPoint=(edge1,edge2)=>{let orientation1=getEdgeOrientation(edge1),orientation22=getEdgeOrientation(edge2);if(orientation1===orientation22)return null;if(orientation1==="vertical"&&orientation22==="horizontal"||orientation1==="horizontal"&&orientation22==="vertical"){let verticalEdge=orientation1==="vertical"?edge1:edge2,horizontalEdge=orientation1==="horizontal"?edge1:edge2,x22=verticalEdge.from.x,y22=horizontalEdge.from.y,intersection2={x:x22,y:y22};return isPointWithinEdge(intersection2,edge1)&&isPointWithinEdge(intersection2,edge2)?intersection2:null}if(orientation1==="vertical"||orientation22==="vertical"){let verticalEdge=orientation1==="vertical"?edge1:edge2,diagonalEdge=orientation1==="vertical"?edge2:edge1,x22=verticalEdge.from.x,m3=(diagonalEdge.to.y-diagonalEdge.from.y)/(diagonalEdge.to.x-diagonalEdge.from.x),b3=diagonalEdge.from.y-m3*diagonalEdge.from.x,y22=m3*x22+b3,intersection2={x:x22,y:y22};return isPointWithinEdge(intersection2,edge1)&&isPointWithinEdge(intersection2,edge2)?intersection2:null}let m12=(edge1.to.y-edge1.from.y)/(edge1.to.x-edge1.from.x),b12=edge1.from.y-m12*edge1.from.x,m22=(edge2.to.y-edge2.from.y)/(edge2.to.x-edge2.from.x),b22=edge2.from.y-m22*edge2.from.x;if(Math.abs(m12-m22)<TOLERANCE)return null;let x3=(b22-b12)/(m12-m22),y3=m12*x3+b12,intersection={x:x3,y:y3};return isPointWithinEdge(intersection,edge1)&&isPointWithinEdge(intersection,edge2)?intersection:null},createSchematicTraceJunctions=({edges:myEdges,db:db2,source_trace_id})=>{let otherEdges=getOtherSchematicTraces({db:db2,source_trace_id,sameNetOnly:!0}).flatMap(t5=>t5.edges),junctions=new Map;for(let myEdge of myEdges)for(let otherEdge of otherEdges){let intersection=getIntersectionPoint(myEdge,otherEdge);if(intersection){let key=`${intersection.x.toFixed(6)},${intersection.y.toFixed(6)}`;junctions.has(key)||junctions.set(key,intersection)}}return Array.from(junctions.values())};function getObstaclesFromBounds(bounds,opts={}){let{minX,maxX,minY,maxY}=bounds,PADDING=opts.padding??1;if(!isFinite(minX)||!isFinite(maxX)||!isFinite(minY)||!isFinite(maxY))return[];let left=minX-PADDING,right=maxX+PADDING,top=maxY+PADDING,bottom=minY-PADDING,thickness=.01;return[{type:"rect",layers:["top"],center:{x:(left+right)/2,y:top},width:right-left,height:thickness,connectedTo:[]},{type:"rect",layers:["top"],center:{x:(left+right)/2,y:bottom},width:right-left,height:thickness,connectedTo:[]},{type:"rect",layers:["top"],center:{x:left,y:(top+bottom)/2},width:thickness,height:top-bottom,connectedTo:[]},{type:"rect",layers:["top"],center:{x:right,y:(top+bottom)/2},width:thickness,height:top-bottom,connectedTo:[]}]}var getSchematicObstaclesForTrace=trace=>{let db2=trace.root.db,connectedPorts=trace._findConnectedPorts().ports??[],connectedPortIds=new Set(connectedPorts.map(p2=>p2.schematic_port_id)),obstacles=[];for(let elm of db2.toArray()){if(elm.type==="schematic_component"){let isSymbol3=!!elm.symbol_name,dominateAxis=elm.size.width>elm.size.height?"horz":"vert";obstacles.push({type:"rect",layers:["top"],center:elm.center,width:elm.size.width+(isSymbol3&&dominateAxis==="horz"?-.5:0),height:elm.size.height+(isSymbol3&&dominateAxis==="vert"?-.5:0),connectedTo:[]})}if(elm.type==="schematic_port"){if(connectedPortIds.has(elm.schematic_port_id))continue;let dirVec=elm.facing_direction?getUnitVectorFromDirection2(elm.facing_direction):{x:0,y:0};obstacles.push({type:"rect",layers:["top"],center:{x:elm.center.x-dirVec.x*.1,y:elm.center.y-dirVec.y*.1},width:.1+Math.abs(dirVec.x)*.3,height:.1+Math.abs(dirVec.y)*.3,connectedTo:[]})}elm.type==="schematic_text"&&obstacles.push({type:"rect",layers:["top"],center:elm.position,width:(elm.text?.length??0)*.1,height:.2,connectedTo:[]}),elm.type==="schematic_box"&&obstacles.push({type:"rect",layers:["top"],center:{x:elm.x,y:elm.y},width:elm.width,height:elm.height,connectedTo:[]})}let bounds=getBoundsForSchematic(db2.toArray());return obstacles.push(...getObstaclesFromBounds(bounds,{padding:1})),obstacles},pushEdgesOfSchematicTraceToPreventOverlap=({edges,db:db2,source_trace_id})=>{let mySourceTrace=db2.source_trace.get(source_trace_id),otherEdges=getOtherSchematicTraces({db:db2,source_trace_id,differentNetOnly:!0}).flatMap(t5=>t5.edges),edgeOrientation=edge=>{let{from,to:to3}=edge;return from.x===to3.x?"vertical":"horizontal"};for(let mySegment of edges){let mySegmentOrientation=edgeOrientation(mySegment),findOverlappingParallelSegment=()=>otherEdges.find(otherEdge=>edgeOrientation(otherEdge)===mySegmentOrientation&&doesLineIntersectLine2([mySegment.from,mySegment.to],[otherEdge.from,otherEdge.to],{lineThickness:.05})),overlappingParallelSegmentFromOtherTrace=findOverlappingParallelSegment();for(;overlappingParallelSegmentFromOtherTrace;)mySegmentOrientation==="horizontal"?(mySegment.from.y+=.1,mySegment.to.y+=.1):(mySegment.from.x+=.1,mySegment.to.x+=.1),overlappingParallelSegmentFromOtherTrace=findOverlappingParallelSegment()}},convertFacingDirectionToElbowDirection=facingDirection=>{switch(facingDirection){case"up":return"y+";case"down":return"y-";case"left":return"x-";case"right":return"x+";default:}},autorouterVersion=package_default.version??"unknown",AutorouterError=class extends Error{constructor(message){super(`${message} (capacity-autorouter@${autorouterVersion})`),this.name="AutorouterError"}},TraceConnectionError=class extends Error{constructor(errorData){super(errorData.message),this.errorData=errorData,this.name="TraceConnectionError"}},Trace_doInitialSchematicTraceRender=trace=>{if(trace.root?._featureMspSchematicTraceRouting||trace._couldNotFindPort||trace.root?.schematicDisabled)return;let{db:db2}=trace.root,{_parsedProps:props,parent}=trace;if(!parent)throw new Error("Trace has no parent");let allPortsFound,connectedPorts;try{let result=trace._findConnectedPorts();allPortsFound=result.allPortsFound,connectedPorts=result.portsWithSelectors??[]}catch(error){if(error instanceof TraceConnectionError){db2.source_trace_not_connected_error.insert({...error.errorData,error_type:"source_trace_not_connected_error"});return}throw error}let{netsWithSelectors}=trace._findConnectedNets();if(!allPortsFound)return;let portPairKey=connectedPorts.map(p2=>p2.port.schematic_port_id).sort().join(","),board=trace.root?._getBoard();if(board?._connectedSchematicPortPairs&&board._connectedSchematicPortPairs.has(portPairKey))return;let connection={name:trace.source_trace_id,pointsToConnect:[]},obstacles=getSchematicObstaclesForTrace(trace),portsWithPosition=connectedPorts.filter(({port})=>port.schematic_port_id!==null).map(({port})=>({port,position:port._getGlobalSchematicPositionAfterLayout(),schematic_port_id:port.schematic_port_id??void 0,facingDirection:port.facingDirection}));if(portsWithPosition.length===1&&netsWithSelectors.length===1){let net=netsWithSelectors[0].net,{port,position:anchorPos}=portsWithPosition[0],connectedNetLabel=trace.getSubcircuit().selectAll("netlabel").find(nl2=>{let conn=nl2._parsedProps.connection??nl2._parsedProps.connectsTo;return conn?Array.isArray(conn)?conn.some(selector=>trace.getSubcircuit().selectOne(selector,{port:!0})===port):trace.getSubcircuit().selectOne(conn,{port:!0})===port:!1});if(!connectedNetLabel){let dbNetLabel=db2.schematic_net_label.getWhere({source_trace_id:trace.source_trace_id});dbNetLabel&&(connectedNetLabel=dbNetLabel)}if(connectedNetLabel){let labelPos="_getGlobalSchematicPositionBeforeLayout"in connectedNetLabel?connectedNetLabel._getGlobalSchematicPositionBeforeLayout():connectedNetLabel.anchor_position,edges2=[];anchorPos.x===labelPos.x||anchorPos.y===labelPos.y?edges2.push({from:anchorPos,to:labelPos}):(edges2.push({from:anchorPos,to:{x:labelPos.x,y:anchorPos.y}}),edges2.push({from:{x:labelPos.x,y:anchorPos.y},to:labelPos}));let dbTrace2=db2.schematic_trace.insert({source_trace_id:trace.source_trace_id,edges:edges2,junctions:[],subcircuit_connectivity_map_key:trace.subcircuit_connectivity_map_key??void 0});trace.schematic_trace_id=dbTrace2.schematic_trace_id;return}if(trace.props.schDisplayLabel){let side2=getEnteringEdgeFromDirection(port.facingDirection)??"bottom";db2.schematic_net_label.insert({text:trace.props.schDisplayLabel,source_net_id:net.source_net_id,anchor_position:anchorPos,center:computeSchematicNetLabelCenter({anchor_position:anchorPos,anchor_side:side2,text:trace.props.schDisplayLabel}),anchor_side:side2});return}let side=getEnteringEdgeFromDirection(port.facingDirection)??"bottom",netLabel=db2.schematic_net_label.insert({text:net._parsedProps.name,source_net_id:net.source_net_id,anchor_position:anchorPos,center:computeSchematicNetLabelCenter({anchor_position:anchorPos,anchor_side:side,text:net._parsedProps.name}),anchor_side:side});return}if(trace.props.schDisplayLabel&&("from"in trace.props&&"to"in trace.props||"path"in trace.props)){trace._doInitialSchematicTraceRenderWithDisplayLabel();return}if(portsWithPosition.length<2)return;let edges=(()=>{let elbowEdges=[];for(let i3=0;i3<portsWithPosition.length-1;i3++){let start=portsWithPosition[i3],end=portsWithPosition[i3+1],path=calculateElbow({x:start.position.x,y:start.position.y,facingDirection:convertFacingDirectionToElbowDirection(start.facingDirection)},{x:end.position.x,y:end.position.y,facingDirection:convertFacingDirectionToElbowDirection(end.facingDirection)});for(let j3=0;j3<path.length-1;j3++)elbowEdges.push({from:path[j3],to:path[j3+1]})}let doesSegmentIntersectRect2=(edge,rect)=>{let halfW=rect.width/2,halfH=rect.height/2,left=rect.center.x-halfW,right=rect.center.x+halfW,top=rect.center.y-halfH,bottom=rect.center.y+halfH,inRect=p2=>p2.x>=left&&p2.x<=right&&p2.y>=top&&p2.y<=bottom;return inRect(edge.from)||inRect(edge.to)?!0:[[{x:left,y:top},{x:right,y:top}],[{x:right,y:top},{x:right,y:bottom}],[{x:right,y:bottom},{x:left,y:bottom}],[{x:left,y:bottom},{x:left,y:top}]].some(r4=>doesLineIntersectLine2([edge.from,edge.to],r4,{lineThickness:0}))};for(let edge of elbowEdges)for(let obstacle of obstacles)if(doesSegmentIntersectRect2(edge,obstacle))return null;return elbowEdges})();edges&&edges.length===0&&(edges=null),connection.pointsToConnect=portsWithPosition.map(({position:position2})=>({...position2,layer:"top"}));let bounds=computeObstacleBounds(obstacles),BOUNDS_MARGIN=2,simpleRouteJsonInput={minTraceWidth:.1,obstacles,connections:[connection],bounds:{minX:bounds.minX-BOUNDS_MARGIN,maxX:bounds.maxX+BOUNDS_MARGIN,minY:bounds.minY-BOUNDS_MARGIN,maxY:bounds.maxY+BOUNDS_MARGIN},layerCount:1},Autorouter=MultilayerIjump,skipOtherTraceInteraction=!1;if(trace.getSubcircuit().props._schDirectLineRoutingEnabled&&(Autorouter=DirectLineRouter,skipOtherTraceInteraction=!0),!edges){let results=new Autorouter({input:simpleRouteJsonInput,MAX_ITERATIONS:100,OBSTACLE_MARGIN:.1,isRemovePathLoopsEnabled:!0,isShortenPathWithShortcutsEnabled:!0,marginsWithCosts:[{margin:1,enterCost:0,travelCostFactor:1},{margin:.3,enterCost:0,travelCostFactor:1},{margin:.2,enterCost:0,travelCostFactor:2},{margin:.1,enterCost:0,travelCostFactor:3}]}).solveAndMapToTraces();if(results.length===0){if(trace._isSymbolToChipConnection()||trace._isSymbolToSymbolConnection()||trace._isChipToChipConnection()){trace._doInitialSchematicTraceRenderWithDisplayLabel();return}results=new DirectLineRouter({input:simpleRouteJsonInput}).solveAndMapToTraces(),skipOtherTraceInteraction=!0}let[{route}]=results;edges=[];let wireAndViaRoutes=route.filter(r4=>r4.route_type==="wire"||r4.route_type==="via");for(let i3=0;i3<wireAndViaRoutes.length-1;i3++)edges.push({from:wireAndViaRoutes[i3],to:wireAndViaRoutes[i3+1]})}let source_trace_id=trace.source_trace_id,junctions=[];if(!skipOtherTraceInteraction){pushEdgesOfSchematicTraceToPreventOverlap({edges,db:db2,source_trace_id});let otherEdges=getOtherSchematicTraces({db:db2,source_trace_id,differentNetOnly:!0}).flatMap(t5=>t5.edges);edges=createSchematicTraceCrossingSegments({edges,otherEdges}),junctions=createSchematicTraceJunctions({edges,db:db2,source_trace_id:trace.source_trace_id})}if(!edges||edges.length===0)return;let lastEdge=edges[edges.length-1],lastEdgePort=portsWithPosition[portsWithPosition.length-1],lastDominantDirection=getDominantDirection(lastEdge);edges.push(...getStubEdges({lastEdge,lastEdgePort,lastDominantDirection}));let firstEdge=edges[0],firstEdgePort=portsWithPosition[0],firstDominantDirection=getDominantDirection(firstEdge);if(edges.unshift(...getStubEdges({firstEdge,firstEdgePort,firstDominantDirection})),!trace.source_trace_id)throw new Error("Missing source_trace_id for schematic trace insertion.");if(trace.getSubcircuit()._parsedProps.schTraceAutoLabelEnabled&&countComplexElements(junctions,edges)>=5&&(trace._isSymbolToChipConnection()||trace._isSymbolToSymbolConnection()||trace._isChipToChipConnection())){trace._doInitialSchematicTraceRenderWithDisplayLabel();return}let dbTrace=db2.schematic_trace.insert({source_trace_id:trace.source_trace_id,edges,junctions,subcircuit_connectivity_map_key:trace.subcircuit_connectivity_map_key??void 0});trace.schematic_trace_id=dbTrace.schematic_trace_id;for(let{port}of connectedPorts)port.schematic_port_id&&db2.schematic_port.update(port.schematic_port_id,{is_connected:!0});board?._connectedSchematicPortPairs&&board._connectedSchematicPortPairs.add(portPairKey)};function getTraceLength(route){let totalLength=0;for(let i3=0;i3<route.length;i3++){let point23=route[i3];if(point23.route_type==="wire"){let nextPoint=route[i3+1];if(nextPoint){let dx2=nextPoint.x-point23.x,dy2=nextPoint.y-point23.y;totalLength+=Math.sqrt(dx2*dx2+dy2*dy2)}}else point23.route_type==="via"&&(totalLength+=1.6)}return totalLength}var DEFAULT_VIA_HOLE_DIAMETER=.3,DEFAULT_VIA_PAD_DIAMETER=.6,parseDistance=(value,fallback)=>{if(value===void 0)return fallback;if(typeof value=="number")return value;let parsed=parseFloat(value);return Number.isFinite(parsed)?parsed:fallback},getViaDiameterDefaults=pcbStyle2=>({holeDiameter:parseDistance(pcbStyle2?.viaHoleDiameter,DEFAULT_VIA_HOLE_DIAMETER),padDiameter:parseDistance(pcbStyle2?.viaPadDiameter,DEFAULT_VIA_PAD_DIAMETER)}),getViaDiameterDefaultsWithOverrides=(overrides,pcbStyle2)=>{let defaults=getViaDiameterDefaults(pcbStyle2);return{holeDiameter:overrides.holeDiameter??defaults.holeDiameter,padDiameter:overrides.padDiameter??defaults.padDiameter}},portToObjective=port=>({...port._getGlobalPcbPositionAfterLayout(),layers:port.getAvailablePcbLayers()}),SHOULD_USE_SINGLE_LAYER_ROUTING=!1;function Trace_doInitialPcbTraceRender(trace){if(trace.root?.pcbDisabled)return;let{db:db2}=trace.root,{_parsedProps:props,parent}=trace,subcircuit=trace.getSubcircuit();if(!parent)throw new Error("Trace has no parent");if(subcircuit._parsedProps.routingDisabled)return;let cachedRoute=subcircuit._parsedProps.pcbRouteCache?.pcbTraces;if(cachedRoute){let pcb_trace22=db2.pcb_trace.insert({route:cachedRoute.flatMap(trace2=>trace2.route),source_trace_id:trace.source_trace_id,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:trace.getGroup()?.pcb_group_id??void 0});trace.pcb_trace_id=pcb_trace22.pcb_trace_id;return}if(props.pcbPath&&props.pcbPath.length>0||props.pcbStraightLine||!subcircuit._shouldUseTraceByTraceRouting())return;let{allPortsFound,ports}=trace._findConnectedPorts(),portsConnectedOnPcbViaNet=[];if(!allPortsFound)return;let portsWithoutMatchedPcbPrimitive=[];for(let port of ports)port._hasMatchedPcbPrimitive()||portsWithoutMatchedPcbPrimitive.push(port);if(portsWithoutMatchedPcbPrimitive.length>0){db2.pcb_trace_error.insert({error_type:"pcb_trace_error",source_trace_id:trace.source_trace_id,message:`Some ports did not have a matching PCB primitive (e.g. a pad or plated hole), this can happen if a footprint is missing. As a result, ${trace} wasn't routed. Missing ports: ${portsWithoutMatchedPcbPrimitive.map(p2=>p2.getString()).join(", ")}`,pcb_trace_id:trace.pcb_trace_id,pcb_component_ids:[],pcb_port_ids:portsWithoutMatchedPcbPrimitive.map(p2=>p2.pcb_port_id).filter(Boolean)});return}let nets=trace._findConnectedNets().netsWithSelectors;if(ports.length===0&&nets.length===2){trace.renderError("Trace connects two nets, we haven't implemented a way to route this yet");return}else if(ports.length===1&&nets.length===1){let port=ports[0],otherPortsInNet=nets[0].net.getAllConnectedPorts().filter(p2=>p2!==port);if(otherPortsInNet.length===0){console.log("Nothing to connect this port to, the net is empty. TODO should emit a warning!");return}let closestPortInNet=getClosest(port,otherPortsInNet);portsConnectedOnPcbViaNet.push(closestPortInNet),ports.push(closestPortInNet)}else if(ports.length>1&&nets.length>=1){trace.renderError("Trace has more than one port and one or more nets, we don't currently support this type of complex trace routing");return}let hints=ports.flatMap(port=>port.matchedComponents.filter(c3=>c3.componentName==="TraceHint")),pcbRouteHints=(trace._parsedProps.pcbRouteHints??[]).concat(hints.flatMap(h2=>h2.getPcbRouteHints()));if(ports.length>2){trace.renderError(`Trace has more than two ports (${ports.map(p2=>p2.getString()).join(", ")}), routing between more than two ports for a single trace is not implemented`);return}if(trace.getSubcircuit().selectAll("trace").filter(trace2=>trace2.renderPhaseStates.PcbTraceRender.initialized).some(trace2=>trace2._portsRoutedOnPcb.length===ports.length&&trace2._portsRoutedOnPcb.every(portRoutedByOtherTrace=>ports.includes(portRoutedByOtherTrace))))return;let orderedRouteObjectives=[];pcbRouteHints.length===0?orderedRouteObjectives=[portToObjective(ports[0]),portToObjective(ports[1])]:orderedRouteObjectives=[portToObjective(ports[0]),...pcbRouteHints,portToObjective(ports[1])];let candidateLayerCombinations=findPossibleTraceLayerCombinations(orderedRouteObjectives);if(SHOULD_USE_SINGLE_LAYER_ROUTING&&candidateLayerCombinations.length===0){trace.renderError(`Could not find a common layer (using hints) for trace ${trace.getString()}`);return}let connMap=getFullConnectivityMapFromCircuitJson(trace.root.db.toArray()),[obstacles,errGettingObstacles]=tryNow(()=>getObstaclesFromCircuitJson2(trace.root.db.toArray()));if(errGettingObstacles){trace.renderError({type:"pcb_trace_error",error_type:"pcb_trace_error",pcb_trace_error_id:trace.pcb_trace_id,message:`Error getting obstacles for autorouting: ${errGettingObstacles.message}`,source_trace_id:trace.source_trace_id,center:{x:0,y:0},pcb_port_ids:ports.map(p2=>p2.pcb_port_id),pcb_trace_id:trace.pcb_trace_id,pcb_component_ids:[]});return}for(let obstacle of obstacles)if(obstacle.connectedTo.length>0){let netId=connMap.getNetConnectedToId(obstacle.connectedTo[0]);netId&&obstacle.connectedTo.push(netId)}let orderedRoutePoints=[];if(candidateLayerCombinations.length===0)orderedRoutePoints=orderedRouteObjectives;else{let candidateLayerSelections=candidateLayerCombinations[0].layer_path;orderedRoutePoints=orderedRouteObjectives.map((t5,idx)=>t5.via?{...t5,via_to_layer:candidateLayerSelections[idx]}:{...t5,layers:[candidateLayerSelections[idx]]})}orderedRoutePoints[0].pcb_port_id=ports[0].pcb_port_id,orderedRoutePoints[orderedRoutePoints.length-1].pcb_port_id=ports[1].pcb_port_id;let routes=[];for(let[a2,b3]of pairs2(orderedRoutePoints)){let dominantLayer="via_to_layer"in a2?a2.via_to_layer:null,BOUNDS_MARGIN=2,aLayer="layers"in a2&&a2.layers.length===1?a2.layers[0]:dominantLayer??"top",bLayer="layers"in b3&&b3.layers.length===1?b3.layers[0]:dominantLayer??"top",pcbPortA="pcb_port_id"in a2?a2.pcb_port_id:null,pcbPortB="pcb_port_id"in b3?b3.pcb_port_id:null,minTraceWidth=trace._getExplicitTraceThickness()??trace.getSubcircuit()._parsedProps.minTraceWidth??.16,ijump=new MultilayerIjump({OBSTACLE_MARGIN:minTraceWidth*2,isRemovePathLoopsEnabled:!0,optimizeWithGoalBoxes:!!(pcbPortA&&pcbPortB),connMap,input:{obstacles,minTraceWidth,connections:[{name:trace.source_trace_id,pointsToConnect:[{...a2,layer:aLayer,pcb_port_id:pcbPortA},{...b3,layer:bLayer,pcb_port_id:pcbPortB}]}],layerCount:trace.getSubcircuit()._getSubcircuitLayerCount(),bounds:{minX:Math.min(a2.x,b3.x)-BOUNDS_MARGIN,maxX:Math.max(a2.x,b3.x)+BOUNDS_MARGIN,minY:Math.min(a2.y,b3.y)-BOUNDS_MARGIN,maxY:Math.max(a2.y,b3.y)+BOUNDS_MARGIN}}}),traces=null;try{traces=ijump.solveAndMapToTraces()}catch(e4){trace.renderError({type:"pcb_trace_error",pcb_trace_error_id:trace.source_trace_id,error_type:"pcb_trace_error",message:`error solving route: ${e4.message}`,source_trace_id:trace.pcb_trace_id,center:{x:(a2.x+b3.x)/2,y:(a2.y+b3.y)/2},pcb_port_ids:ports.map(p2=>p2.pcb_port_id),pcb_trace_id:trace.pcb_trace_id,pcb_component_ids:ports.map(p2=>p2.pcb_component_id)})}if(!traces)return;if(traces.length===0){trace.renderError({type:"pcb_trace_error",error_type:"pcb_trace_error",pcb_trace_error_id:trace.pcb_trace_id,message:`Could not find a route for ${trace}`,source_trace_id:trace.source_trace_id,center:{x:(a2.x+b3.x)/2,y:(a2.y+b3.y)/2},pcb_port_ids:ports.map(p2=>p2.pcb_port_id),pcb_trace_id:trace.pcb_trace_id,pcb_component_ids:ports.map(p2=>p2.pcb_component_id)});return}let[autoroutedTrace]=traces;dominantLayer&&(autoroutedTrace.route=autoroutedTrace.route.map(p2=>(p2.route_type==="wire"&&!p2.layer&&(p2.layer=dominantLayer),p2))),pcbPortA&&autoroutedTrace.route[0].route_type==="wire"&&(autoroutedTrace.route[0].start_pcb_port_id=pcbPortA);let lastRoutePoint=autoroutedTrace.route[autoroutedTrace.route.length-1];pcbPortB&&lastRoutePoint.route_type==="wire"&&(lastRoutePoint.end_pcb_port_id=pcbPortB),routes.push(autoroutedTrace.route)}let mergedRoute=mergeRoutes(routes),traceLength=getTraceLength(mergedRoute),pcbStyle2=trace.getInheritedMergedProperty("pcbStyle"),{holeDiameter,padDiameter}=getViaDiameterDefaults(pcbStyle2),pcb_trace2=db2.pcb_trace.insert({route:mergedRoute,source_trace_id:trace.source_trace_id,subcircuit_id:trace.getSubcircuit()?.subcircuit_id,trace_length:traceLength});trace._portsRoutedOnPcb=ports,trace.pcb_trace_id=pcb_trace2.pcb_trace_id;for(let point23 of mergedRoute)point23.route_type==="via"&&db2.pcb_via.insert({pcb_trace_id:pcb_trace2.pcb_trace_id,x:point23.x,y:point23.y,hole_diameter:holeDiameter,outer_diameter:padDiameter,layers:[point23.from_layer,point23.to_layer],from_layer:point23.from_layer,to_layer:point23.to_layer});trace._insertErrorIfTraceIsOutsideBoard(mergedRoute,ports)}function computeLineRectIntersection(params){let{lineStart,lineEnd,rectCenter,rectWidth,rectHeight}=params,left=rectCenter.x-rectWidth/2,right=rectCenter.x+rectWidth/2,top=rectCenter.y+rectHeight/2,bottom=rectCenter.y-rectHeight/2,dx2=lineEnd.x-lineStart.x,dy2=lineEnd.y-lineStart.y,intersections=[];if(dx2!==0){let t5=(left-lineStart.x)/dx2;if(t5>=0&&t5<=1){let y3=lineStart.y+t5*dy2;y3>=bottom&&y3<=top&&intersections.push({x:left,y:y3,t:t5})}}if(dx2!==0){let t5=(right-lineStart.x)/dx2;if(t5>=0&&t5<=1){let y3=lineStart.y+t5*dy2;y3>=bottom&&y3<=top&&intersections.push({x:right,y:y3,t:t5})}}if(dy2!==0){let t5=(bottom-lineStart.y)/dy2;if(t5>=0&&t5<=1){let x3=lineStart.x+t5*dx2;x3>=left&&x3<=right&&intersections.push({x:x3,y:bottom,t:t5})}}if(dy2!==0){let t5=(top-lineStart.y)/dy2;if(t5>=0&&t5<=1){let x3=lineStart.x+t5*dx2;x3>=left&&x3<=right&&intersections.push({x:x3,y:top,t:t5})}}return intersections.length===0?null:(intersections.sort((a2,b3)=>a2.t-b3.t),{x:intersections[0].x,y:intersections[0].y})}function computeLineCircleIntersection(params){let{lineStart,lineEnd,circleCenter,circleRadius}=params,x12=lineStart.x-circleCenter.x,y12=lineStart.y-circleCenter.y,x22=lineEnd.x-circleCenter.x,y22=lineEnd.y-circleCenter.y,dx2=x22-x12,dy2=y22-y12,a2=dx2*dx2+dy2*dy2,b3=2*(x12*dx2+y12*dy2),c3=x12*x12+y12*y12-circleRadius*circleRadius,discriminant=b3*b3-4*a2*c3;if(discriminant<0)return null;let sqrtDisc=Math.sqrt(discriminant),t12=(-b3-sqrtDisc)/(2*a2),t22=(-b3+sqrtDisc)/(2*a2),t5=null;return t12>=0&&t12<=1?t5=t12:t22>=0&&t22<=1&&(t5=t22),t5===null?null:{x:lineStart.x+t5*dx2,y:lineStart.y+t5*dy2}}function clipTraceEndAtPad(params){let{traceStart,traceEnd,traceWidth,port}=params,pcbPrimitive=port.matchedComponents.find(c3=>c3.isPcbPrimitive);if(!pcbPrimitive)return traceEnd;let padBounds=pcbPrimitive._getPcbCircuitJsonBounds(),padWidth=padBounds.width,padHeight=padBounds.height,padCenter=padBounds.center,smallestPadDimension=Math.min(padWidth,padHeight);if(traceWidth<=smallestPadDimension/2)return traceEnd;let clippedPoint=null;if(pcbPrimitive.componentName==="SmtPad"){let smtPad=pcbPrimitive,padShape=smtPad._parsedProps.shape;if(padShape==="circle"){let radius=smtPad._parsedProps.radius;clippedPoint=computeLineCircleIntersection({lineStart:traceStart,lineEnd:traceEnd,circleCenter:padCenter,circleRadius:radius})}else(padShape==="rect"||padShape==="rotated_rect"||padShape==="pill"||padShape==="polygon")&&(clippedPoint=computeLineRectIntersection({lineStart:traceStart,lineEnd:traceEnd,rectCenter:padCenter,rectWidth:padWidth,rectHeight:padHeight}))}else if(pcbPrimitive.componentName==="PlatedHole"){let platedHole=pcbPrimitive;if(platedHole._parsedProps.shape==="circle"){let outerDiameter=platedHole._parsedProps.outerDiameter;clippedPoint=computeLineCircleIntersection({lineStart:traceStart,lineEnd:traceEnd,circleCenter:padCenter,circleRadius:outerDiameter/2})}else clippedPoint=computeLineRectIntersection({lineStart:traceStart,lineEnd:traceEnd,rectCenter:padCenter,rectWidth:padWidth,rectHeight:padHeight})}return clippedPoint??traceEnd}function Trace_doInitialPcbManualTraceRender(trace){if(trace.root?.pcbDisabled)return;let{db:db2}=trace.root,{_parsedProps:props}=trace,subcircuit=trace.getSubcircuit(),hasPcbPath=props.pcbPath!==void 0,wantsStraightLine=!!props.pcbStraightLine;if(!hasPcbPath&&!wantsStraightLine)return;let{allPortsFound,ports,portsWithSelectors}=trace._findConnectedPorts();if(!allPortsFound)return;let portsWithoutMatchedPcbPrimitive=[];for(let port of ports)port._hasMatchedPcbPrimitive()||portsWithoutMatchedPcbPrimitive.push(port);if(portsWithoutMatchedPcbPrimitive.length>0){db2.pcb_trace_error.insert({error_type:"pcb_trace_error",source_trace_id:trace.source_trace_id,message:`Some ports did not have a matching PCB primitive (e.g. a pad or plated hole), this can happen if a footprint is missing. As a result, ${trace} wasn't routed. Missing ports: ${portsWithoutMatchedPcbPrimitive.map(p2=>p2.getString()).join(", ")}`,pcb_trace_id:trace.pcb_trace_id,pcb_component_ids:[],pcb_port_ids:portsWithoutMatchedPcbPrimitive.map(p2=>p2.pcb_port_id).filter(Boolean)});return}let width=trace._getExplicitTraceThickness()??trace.getSubcircuit()._parsedProps.minTraceWidth??.16;if(wantsStraightLine&&!hasPcbPath){if(!ports||ports.length<2){trace.renderError("pcbStraightLine requires exactly two connected ports");return}let[startPort,endPort]=ports,startLayers=startPort.getAvailablePcbLayers(),endLayers=endPort.getAvailablePcbLayers(),layer2=startLayers.find(layer3=>endLayers.includes(layer3))??startLayers[0]??endLayers[0]??"top",startPos=startPort._getGlobalPcbPositionAfterLayout(),endPos=endPort._getGlobalPcbPositionAfterLayout(),clippedStartPos=clipTraceEndAtPad({traceStart:endPos,traceEnd:startPos,traceWidth:width,port:startPort}),clippedEndPos=clipTraceEndAtPad({traceStart:startPos,traceEnd:endPos,traceWidth:width,port:endPort}),route2=[{route_type:"wire",x:clippedStartPos.x,y:clippedStartPos.y,width,layer:layer2,start_pcb_port_id:startPort.pcb_port_id},{route_type:"wire",x:clippedEndPos.x,y:clippedEndPos.y,width,layer:layer2,end_pcb_port_id:endPort.pcb_port_id}],traceLength2=getTraceLength(route2),pcb_trace22=db2.pcb_trace.insert({route:route2,source_trace_id:trace.source_trace_id,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:trace.getGroup()?.pcb_group_id??void 0,trace_length:traceLength2});trace._portsRoutedOnPcb=ports,trace.pcb_trace_id=pcb_trace22.pcb_trace_id,trace._insertErrorIfTraceIsOutsideBoard(route2,ports);return}if(!props.pcbPath)return;let anchorPort;props.pcbPathRelativeTo&&(anchorPort=portsWithSelectors.find(p2=>p2.selector===props.pcbPathRelativeTo)?.port,anchorPort||(anchorPort=trace.getSubcircuit().selectOne(props.pcbPathRelativeTo))),anchorPort||(anchorPort=ports[0]);let otherPort=ports.find(p2=>p2!==anchorPort)??ports[1],layer=anchorPort.getAvailablePcbLayers()[0]||"top",anchorPos=anchorPort._getGlobalPcbPositionAfterLayout(),otherPos=otherPort._getGlobalPcbPositionAfterLayout(),route=[];route.push({route_type:"wire",x:anchorPos.x,y:anchorPos.y,width,layer,start_pcb_port_id:anchorPort.pcb_port_id});let transform5=anchorPort?._computePcbGlobalTransformBeforeLayout?.()||identity();for(let pt3 of props.pcbPath){let coordinates,isGlobalPosition=!1;if(typeof pt3=="string"){let resolvedPort=trace.getSubcircuit().selectOne(pt3,{type:"port"});if(!resolvedPort){db2.pcb_trace_error.insert({error_type:"pcb_trace_error",source_trace_id:trace.source_trace_id,message:`Could not resolve pcbPath selector "${pt3}" for ${trace}`,pcb_trace_id:trace.pcb_trace_id,pcb_component_ids:[],pcb_port_ids:[]});continue}let portPos=resolvedPort._getGlobalPcbPositionAfterLayout();coordinates={x:portPos.x,y:portPos.y},isGlobalPosition=!0}else coordinates={x:pt3.x,y:pt3.y},isGlobalPosition=!1;let finalCoordinates=isGlobalPosition?coordinates:applyToPoint(transform5,coordinates);route.push({route_type:"wire",x:finalCoordinates.x,y:finalCoordinates.y,width,layer})}route.push({route_type:"wire",x:otherPos.x,y:otherPos.y,width,layer,end_pcb_port_id:otherPort.pcb_port_id});let traceLength=getTraceLength(route),pcb_trace2=db2.pcb_trace.insert({route,source_trace_id:trace.source_trace_id,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:trace.getGroup()?.pcb_group_id??void 0,trace_length:traceLength});trace._portsRoutedOnPcb=ports,trace.pcb_trace_id=pcb_trace2.pcb_trace_id,trace._insertErrorIfTraceIsOutsideBoard(route,ports)}function Trace__doInitialSchematicTraceRenderWithDisplayLabel(trace){if(trace.root?.schematicDisabled)return;let{db:db2}=trace.root,{_parsedProps:props,parent}=trace;if(!parent)throw new Error("Trace has no parent");let{allPortsFound,portsWithSelectors:connectedPorts}=trace._findConnectedPorts();if(!allPortsFound)return;let portsWithPosition=connectedPorts.map(({port})=>({port,position:port._getGlobalSchematicPositionAfterLayout(),schematic_port_id:port.schematic_port_id,facingDirection:port.facingDirection}));if(portsWithPosition.length<2)throw new Error("Expected at least two ports in portsWithPosition.");let fromPortName,toPortName,fromAnchorPos=portsWithPosition[0].position,fromPort=portsWithPosition[0].port;if("path"in trace.props){if(trace.props.path.length!==2)throw new Error("Invalid 'path': Must contain exactly two elements.");[fromPortName,toPortName]=trace.props.path}else{if(!("from"in trace.props&&"to"in trace.props))throw new Error("Missing 'from' or 'to' properties in props.");fromPortName=trace.props.from,toPortName=trace.props.to}if(!fromPort.source_port_id)throw new Error(`Missing source_port_id for the 'from' port (${fromPortName}).`);let toAnchorPos=portsWithPosition[1].position,toPort=portsWithPosition[1].port;if(!toPort.source_port_id)throw new Error(`Missing source_port_id for the 'to' port (${toPortName}).`);let existingFromNetLabel=db2.schematic_net_label.list().find(label=>label.source_net_id===fromPort.source_port_id),existingToNetLabel=db2.schematic_net_label.list().find(label=>label.source_net_id===toPort.source_port_id),[firstPort,secondPort]=connectedPorts.map(({port})=>port),pinFullName=firstPort.parent?.config.shouldRenderAsSchematicBox?`${firstPort?.parent?.props.name}_${firstPort?.props.name}`:`${secondPort?.parent?.props.name}_${secondPort?.props.name}`,netLabelText=trace.props.schDisplayLabel??pinFullName;if(existingFromNetLabel&&existingFromNetLabel.text!==netLabelText&&(existingFromNetLabel.text=`${netLabelText} / ${existingFromNetLabel.text}`),existingToNetLabel&&existingToNetLabel?.text!==netLabelText&&(existingToNetLabel.text=`${netLabelText} / ${existingToNetLabel.text}`),!existingToNetLabel){let toSide=getEnteringEdgeFromDirection(toPort.facingDirection)??"bottom";db2.schematic_net_label.insert({text:trace.props.schDisplayLabel??pinFullName,source_net_id:toPort.source_port_id,anchor_position:toAnchorPos,center:computeSchematicNetLabelCenter({anchor_position:toAnchorPos,anchor_side:toSide,text:trace.props.schDisplayLabel??pinFullName}),anchor_side:toSide})}if(!existingFromNetLabel){let fromSide=getEnteringEdgeFromDirection(fromPort.facingDirection)??"bottom";db2.schematic_net_label.insert({text:trace.props.schDisplayLabel??pinFullName,source_net_id:fromPort.source_port_id,anchor_position:fromAnchorPos,center:computeSchematicNetLabelCenter({anchor_position:fromAnchorPos,anchor_side:fromSide,text:trace.props.schDisplayLabel??pinFullName}),anchor_side:fromSide})}}function Trace__findConnectedPorts(trace){let{_parsedProps:props,parent}=trace;if(!parent)throw new Error("Trace has no parent");let portsWithSelectors=trace.getTracePortPathSelectors().map(selector=>({selector,port:trace.getSubcircuit().selectOne(selector,{type:"port"})??null}));for(let{selector,port}of portsWithSelectors)if(!port){let parentSelector,portToken,dotIndex=selector.lastIndexOf(".");if(dotIndex!==-1&&dotIndex>selector.lastIndexOf(" "))parentSelector=selector.slice(0,dotIndex),portToken=selector.slice(dotIndex+1);else{let match2=selector.match(/^(.*[ >])?([^ >]+)$/);parentSelector=match2?.[1]?.trim()??"",portToken=match2?.[2]??selector}let targetComponent=parentSelector?trace.getSubcircuit().selectOne(parentSelector):null;if(!targetComponent&&parentSelector&&!/[.#\[]/.test(parentSelector)&&(targetComponent=trace.getSubcircuit().selectOne(`.${parentSelector}`)),!targetComponent){let errorMessage2=parentSelector?`Could not find port for selector "${selector}". Component "${parentSelector}" not found`:`Could not find port for selector "${selector}"`,subcircuit2=trace.getSubcircuit(),sourceGroup2=subcircuit2.getGroup();throw new TraceConnectionError({error_type:"source_trace_not_connected_error",message:errorMessage2,subcircuit_id:subcircuit2.subcircuit_id??void 0,source_group_id:sourceGroup2?.source_group_id??void 0,source_trace_id:trace.source_trace_id??void 0,selectors_not_found:[selector]})}let ports=targetComponent.children.filter(c3=>c3.componentName==="Port"),portLabel=portToken.includes(".")?portToken.split(".").pop()??"":portToken,portNames=ports.flatMap(c3=>c3.getNameAndAliases()),hasCustomLabels=portNames.some(n3=>!/^(pin\d+|\d+)$/.test(n3)),labelList=Array.from(new Set(portNames)).join(", "),detail;ports.length===0?detail="It has no ports":hasCustomLabels?detail=`It has [${labelList}]`:detail=`It has ${ports.length} pins and no pinLabels (consider adding pinLabels)`;let errorMessage=`Could not find port for selector "${selector}". Component "${targetComponent.props.name??parentSelector}" found, but does not have pin "${portLabel}". ${detail}`,subcircuit=trace.getSubcircuit(),sourceGroup=subcircuit.getGroup();throw new TraceConnectionError({error_type:"source_trace_not_connected_error",message:errorMessage,subcircuit_id:subcircuit.subcircuit_id??void 0,source_group_id:sourceGroup?.source_group_id??void 0,source_trace_id:trace.source_trace_id??void 0,selectors_not_found:[selector]})}return portsWithSelectors.some(p2=>!p2.port)?{allPortsFound:!1}:{allPortsFound:!0,portsWithSelectors,ports:portsWithSelectors.map(({port})=>port)}}var Trace3=class extends PrimitiveComponent2{constructor(props){super(props);__publicField(this,"source_trace_id",null);__publicField(this,"pcb_trace_id",null);__publicField(this,"schematic_trace_id",null);__publicField(this,"_portsRoutedOnPcb");__publicField(this,"subcircuit_connectivity_map_key",null);__publicField(this,"_traceConnectionHash",null);__publicField(this,"_couldNotFindPort");this._portsRoutedOnPcb=[]}_getExplicitTraceThickness(){return this._parsedProps.thickness??this._parsedProps.width}get config(){return{zodProps:traceProps,componentName:"Trace"}}_getTracePortOrNetSelectorListFromProps(){return"from"in this.props&&"to"in this.props?[typeof this.props.from=="string"?this.props.from:this.props.from.getPortSelector(),typeof this.props.to=="string"?this.props.to:this.props.to.getPortSelector()]:"path"in this.props?this.props.path.map(p2=>typeof p2=="string"?p2:p2.getPortSelector()):[]}getTracePortPathSelectors(){return this._getTracePortOrNetSelectorListFromProps().filter(selector=>!selector.includes("net."))}getTracePathNetSelectors(){return this._getTracePortOrNetSelectorListFromProps().filter(selector=>selector.includes("net."))}_findConnectedPorts(){return Trace__findConnectedPorts(this)}_resolveNet(selector){let direct=this.getSubcircuit().selectOne(selector,{type:"net"});if(direct)return direct;let match2=selector.match(/^net\.(.+)$/),netName=match2?match2[1]:null;if(!netName)return null;let board=this.root?._getBoard();return board?board.getDescendants().find(d3=>d3.componentName==="Net"&&d3._parsedProps.name===netName)||null:(this.renderError(`Could not find a <board> ancestor for ${this}, so net "${selector}" cannot be resolved`),null)}_findConnectedNets(){let netsWithSelectors=this.getTracePathNetSelectors().map(selector=>({selector,net:this._resolveNet(selector)})),undefinedNets=netsWithSelectors.filter(n3=>!n3.net);return undefinedNets.length>0&&this.renderError(`Could not find net for selector "${undefinedNets[0].selector}" inside ${this}`),{netsWithSelectors,nets:netsWithSelectors.map(n3=>n3.net)}}_getAllTracesConnectedToSameNet(){let traces=this.getSubcircuit().selectAll("trace"),myNets=this._findConnectedNets().nets,myPorts=this._findConnectedPorts().ports??[];return traces.filter(t5=>{if(t5===this)return!1;let tNets=t5._findConnectedNets().nets,tPorts=t5._findConnectedPorts().ports??[];return tNets.some(n3=>myNets.includes(n3))||tPorts.some(p2=>myPorts.includes(p2))})}_isExplicitlyConnectedToPort(port){let{allPortsFound,portsWithSelectors:portsWithMetadata}=this._findConnectedPorts();return allPortsFound?portsWithMetadata.map(p2=>p2.port).includes(port):!1}_isExplicitlyConnectedToNet(net){return this._findConnectedNets().nets.includes(net)}doInitialCreateNetsFromProps(){createNetsFromProps(this,this.getTracePathNetSelectors())}_computeTraceConnectionHash(){let{allPortsFound,ports}=this._findConnectedPorts();return!allPortsFound||!ports?null:[...ports].sort((a2,b3)=>(a2.pcb_port_id||"").localeCompare(b3.pcb_port_id||"")).map(p2=>p2.pcb_port_id).join(",")}doInitialSourceTraceRender(){let{db:db2}=this.root,{_parsedProps:props,parent}=this;if(!parent){this.renderError("Trace has no parent");return}let allPortsFound,ports;try{let result=this._findConnectedPorts();allPortsFound=result.allPortsFound,ports=result.portsWithSelectors??[]}catch(error){if(error instanceof TraceConnectionError){db2.source_trace_not_connected_error.insert({...error.errorData,error_type:"source_trace_not_connected_error"}),this._couldNotFindPort=!0;return}throw error}if(!allPortsFound)return;this._traceConnectionHash=this._computeTraceConnectionHash();let existingTrace=db2.source_trace.list().find(t5=>t5.subcircuit_connectivity_map_key===this.subcircuit_connectivity_map_key&&t5.connected_source_port_ids.sort().join(",")===this._traceConnectionHash);if(existingTrace){this.source_trace_id=existingTrace.source_trace_id;return}let nets=this._findConnectedNets().nets,displayName=getTraceDisplayName({ports,nets}),trace=db2.source_trace.insert({connected_source_port_ids:ports.map(p2=>p2.port.source_port_id),connected_source_net_ids:nets.map(n3=>n3.source_net_id),subcircuit_id:this.getSubcircuit()?.subcircuit_id,max_length:getMaxLengthFromConnectedCapacitors(ports.map(p2=>p2.port),{db:db2})??props.maxLength,display_name:displayName,min_trace_thickness:this._getExplicitTraceThickness()});this.source_trace_id=trace.source_trace_id}_insertErrorIfTraceIsOutsideBoard(mergedRoute,ports){let{db:db2}=this.root;isRouteOutsideBoard(mergedRoute,{db:db2})&&db2.pcb_trace_error.insert({error_type:"pcb_trace_error",source_trace_id:this.source_trace_id,message:`Trace ${this.getString()} routed outside the board boundaries.`,pcb_trace_id:this.pcb_trace_id,pcb_component_ids:[],pcb_port_ids:ports.map(p2=>p2.pcb_port_id)})}doInitialPcbManualTraceRender(){Trace_doInitialPcbManualTraceRender(this)}doInitialPcbTraceRender(){Trace_doInitialPcbTraceRender(this)}_doInitialSchematicTraceRenderWithDisplayLabel(){Trace__doInitialSchematicTraceRenderWithDisplayLabel(this)}_isSymbolToChipConnection(){let{allPortsFound,ports}=this._findConnectedPorts();if(!allPortsFound||ports.length!==2)return!1;let[port1,port2]=ports;if(!port1?.parent||!port2?.parent)return!1;let isPort1Chip=port1.parent.config.shouldRenderAsSchematicBox,isPort2Chip=port2.parent.config.shouldRenderAsSchematicBox;return isPort1Chip&&!isPort2Chip||!isPort1Chip&&isPort2Chip}_isSymbolToSymbolConnection(){let{allPortsFound,ports}=this._findConnectedPorts();if(!allPortsFound||ports.length!==2)return!1;let[port1,port2]=ports;if(!port1?.parent||!port2?.parent)return!1;let isPort1Symbol=!port1.parent.config.shouldRenderAsSchematicBox,isPort2Symbol=!port2.parent.config.shouldRenderAsSchematicBox;return isPort1Symbol&&isPort2Symbol}_isChipToChipConnection(){let{allPortsFound,ports}=this._findConnectedPorts();if(!allPortsFound||ports.length!==2)return!1;let[port1,port2]=ports;if(!port1?.parent||!port2?.parent)return!1;let isPort1Chip=port1.parent.config.shouldRenderAsSchematicBox,isPort2Chip=port2.parent.config.shouldRenderAsSchematicBox;return isPort1Chip&&isPort2Chip}doInitialSchematicTraceRender(){Trace_doInitialSchematicTraceRender(this)}},NormalComponent__getMinimumFlexContainerSize=component=>{let{db:db2}=component.root;if(component.pcb_component_id){let pcbComponent=db2.pcb_component.get(component.pcb_component_id);return pcbComponent?{width:pcbComponent.width,height:pcbComponent.height}:null}if(component.pcb_group_id){let pcbGroup=db2.pcb_group.get(component.pcb_group_id);if(!pcbGroup)return null;if(pcbGroup.outline&&pcbGroup.outline.length>0){let bounds=getBoundsFromPoints(pcbGroup.outline);return bounds?{width:bounds.maxX-bounds.minX,height:bounds.maxY-bounds.minY}:null}return{width:pcbGroup.width??0,height:pcbGroup.height??0}}return null},NormalComponent__repositionOnPcb=(component,position2)=>{let{db:db2}=component.root,allCircuitJson=db2.toArray();if(component.pcb_component_id){repositionPcbComponentTo(allCircuitJson,component.pcb_component_id,position2);return}if(component.source_group_id){repositionPcbGroupTo(allCircuitJson,component.source_group_id,position2);return}throw new Error(`Cannot reposition component ${component.getString()}: no pcb_component_id or source_group_id`)},NormalComponent_doInitialSourceDesignRuleChecks=component=>{let{db:db2}=component.root;if(!component.source_component_id)return;let ports=component.selectAll("port"),traces=db2.source_trace.list(),connected=new Set;for(let trace of traces)for(let id2 of trace.connected_source_port_ids)connected.add(id2);let internalGroups=component._getInternallyConnectedPins();for(let group of internalGroups)if(group.some(p2=>p2.source_port_id&&connected.has(p2.source_port_id)))for(let p2 of group)p2.source_port_id&&connected.add(p2.source_port_id);for(let port of ports)port.source_port_id&&shouldCheckPortForMissingTrace(component,port)&&(connected.has(port.source_port_id)||db2.source_pin_missing_trace_warning.insert({message:`Port ${port.getNameAndAliases()[0]} on ${component.props.name} is missing a trace`,source_component_id:component.source_component_id,source_port_id:port.source_port_id,subcircuit_id:component.getSubcircuit().subcircuit_id??void 0,warning_type:"source_pin_missing_trace_warning"}))},shouldCheckPortForMissingTrace=(component,port)=>{if(component.config.componentName==="Interconnect")return!1;if(component.config.componentName==="Chip"){let pinAttributes=component.props.pinAttributes;if(!pinAttributes)return!1;for(let alias of port.getNameAndAliases()){let attrs=pinAttributes[alias];if(attrs?.requiresPower||attrs?.requiresGround||attrs?.requiresVoltage!==void 0)return!0}return!1}return!0};function getPcbTextBounds(text){let fontSize=text.font_size,textWidth=text.text.length*fontSize*.6,textHeight=fontSize,anchorAlignment=text.anchor_alignment||"center",centerX=text.anchor_position.x,centerY=text.anchor_position.y;switch(anchorAlignment){case"top_left":centerX=text.anchor_position.x+textWidth/2,centerY=text.anchor_position.y+textHeight/2;break;case"top_center":centerX=text.anchor_position.x,centerY=text.anchor_position.y+textHeight/2;break;case"top_right":centerX=text.anchor_position.x-textWidth/2,centerY=text.anchor_position.y+textHeight/2;break;case"center_left":centerX=text.anchor_position.x+textWidth/2,centerY=text.anchor_position.y;break;case"center":centerX=text.anchor_position.x,centerY=text.anchor_position.y;break;case"center_right":centerX=text.anchor_position.x-textWidth/2,centerY=text.anchor_position.y;break;case"bottom_left":centerX=text.anchor_position.x+textWidth/2,centerY=text.anchor_position.y-textHeight/2;break;case"bottom_center":centerX=text.anchor_position.x,centerY=text.anchor_position.y-textHeight/2;break;case"bottom_right":centerX=text.anchor_position.x-textWidth/2,centerY=text.anchor_position.y-textHeight/2;break;default:centerX=text.anchor_position.x,centerY=text.anchor_position.y;break}return{x:centerX-textWidth/2,y:centerY-textHeight/2,width:textWidth,height:textHeight}}function NormalComponent_doInitialSilkscreenOverlapAdjustment(component){if(!component._adjustSilkscreenTextAutomatically||component.root?.pcbDisabled||!component.pcb_component_id)return;let{db:db2}=component.root,componentCenter=component._getPcbCircuitJsonBounds().center,silkscreenTexts=db2.pcb_silkscreen_text.list({pcb_component_id:component.pcb_component_id}).filter(text=>text.text===component.name);if(silkscreenTexts.length===0)return;let obstacleBounds=component.getSubcircuit().selectAll("[_isNormalComponent=true]").filter(comp=>comp!==component&&comp.pcb_component_id).map(comp=>{let bounds=comp._getPcbCircuitJsonBounds(),box2={center:bounds.center,width:bounds.width,height:bounds.height};return getBoundingBox2(box2)});for(let silkscreenText of silkscreenTexts){let currentPosition=silkscreenText.anchor_position,textBounds=getPcbTextBounds(silkscreenText),textBox={center:{x:textBounds.x+textBounds.width/2,y:textBounds.y+textBounds.height/2},width:textBounds.width,height:textBounds.height},textBoundsBox=getBoundingBox2(textBox);if(!obstacleBounds.some(obstacle=>doBoundsOverlap(textBoundsBox,obstacle)))continue;let flippedX=2*componentCenter.x-currentPosition.x,flippedY=2*componentCenter.y-currentPosition.y,flippedTextBox={center:{x:flippedX,y:flippedY},width:textBounds.width,height:textBounds.height},flippedTextBounds=getBoundingBox2(flippedTextBox);obstacleBounds.some(obstacle=>doBoundsOverlap(flippedTextBounds,obstacle))||db2.pcb_silkscreen_text.update(silkscreenText.pcb_silkscreen_text_id,{anchor_position:{x:flippedX,y:flippedY}})}}function filterPinLabels(pinLabels){if(!pinLabels)return{validPinLabels:pinLabels,invalidPinLabelsMessages:[]};let validPinLabels={},invalidPinLabelsMessages=[];for(let[pin,labelOrLabels]of Object.entries(pinLabels)){let labels=Array.isArray(labelOrLabels)?labelOrLabels.slice():[labelOrLabels],validLabels=[];for(let label of labels)isValidPinLabel(pin,label)?validLabels.push(label):invalidPinLabelsMessages.push(`Invalid pin label: ${pin} = '${label}' - excluding from component. Please use a valid pin label.`);validLabels.length>0&&(validPinLabels[pin]=Array.isArray(labelOrLabels)?validLabels:validLabels[0])}return{validPinLabels:Object.keys(validPinLabels).length>0?validPinLabels:void 0,invalidPinLabelsMessages}}function isValidPinLabel(pin,label){try{let testProps={name:"test",footprint:"test",pinLabels:{[pin]:label}};return chipProps.safeParse(testProps).success}catch{return!1}}var isHttpUrl=s3=>s3.startsWith("http://")||s3.startsWith("https://"),parseLibraryFootprintRef=s3=>{if(isHttpUrl(s3))return null;let idx=s3.indexOf(":");if(idx<=0)return null;let footprintLib=s3.slice(0,idx),footprintName=s3.slice(idx+1);return!footprintLib||!footprintName?null:{footprintLib,footprintName}},isStaticAssetPath=s3=>s3.startsWith("/"),resolveStaticFileImportDebug=(0,import_debug9.default)("tscircuit:core:resolveStaticFileImport");async function resolveStaticFileImport(path,platform){if(!path)return path;let resolver=platform?.resolveProjectStaticFileImportUrl;if(resolver&&path.startsWith("/"))try{let resolved=await resolver(path);if(resolved)return resolved}catch(error){resolveStaticFileImportDebug("failed to resolve static file via platform resolver",error)}return constructAssetUrl(path,platform?.projectBaseUrl)}function NormalComponent_doInitialPcbFootprintStringRender(component,queueAsyncEffect){let{footprint}=component.props;if(footprint??(footprint=component._getImpliedFootprintString?.()),!footprint)return;let{pcbRotation,pinLabels,pcbPinLabels}=component.props,fileExtension=getFileExtension(String(footprint)),footprintParser=fileExtension?component.root?.platform?.footprintFileParserMap?.[fileExtension]:null;if(typeof footprint=="string"&&(isHttpUrl(footprint)||isStaticAssetPath(footprint))&&footprintParser){if(component._hasStartedFootprintUrlLoad)return;component._hasStartedFootprintUrlLoad=!0,queueAsyncEffect("load-footprint-from-platform-file-parser",async()=>{let footprintUrl=isHttpUrl(footprint)?footprint:await resolveStaticFileImport(footprint,component.root?.platform);try{let result=await footprintParser.loadFromUrl(footprintUrl),fpComponents=createComponentsFromCircuitJson({componentName:component.name,componentRotation:pcbRotation,footprinterString:footprintUrl,pinLabels,pcbPinLabels},result.footprintCircuitJson);component.addAll(fpComponents),component._markDirty("InitializePortsFromChildren")}catch(err){let db2=component.root?.db;if(db2&&component.source_component_id&&component.pcb_component_id){let subcircuit=component.getSubcircuit(),errorMsg=`${component.getString()} failed to load footprint "${footprintUrl}": `+(err instanceof Error?err.message:String(err)),errorObj=external_footprint_load_error.parse({type:"external_footprint_load_error",message:errorMsg,pcb_component_id:component.pcb_component_id,source_component_id:component.source_component_id,subcircuit_id:subcircuit.subcircuit_id??void 0,pcb_group_id:component.getGroup()?.pcb_group_id??void 0,footprinter_string:footprintUrl});db2.external_footprint_load_error.insert(errorObj)}throw err}});return}if(typeof footprint=="string"&&isHttpUrl(footprint)){if(component._hasStartedFootprintUrlLoad)return;component._hasStartedFootprintUrlLoad=!0;let url=footprint;queueAsyncEffect("load-footprint-url",async()=>{try{let res2=await fetch(url);if(!res2.ok)throw new Error(`Failed to fetch footprint: ${res2.status}`);let soup=await res2.json(),fpComponents=createComponentsFromCircuitJson({componentName:component.name,componentRotation:pcbRotation,footprinterString:url,pinLabels,pcbPinLabels},soup);component.addAll(fpComponents),component._markDirty("InitializePortsFromChildren")}catch(err){let db2=component.root?.db;if(db2&&component.source_component_id&&component.pcb_component_id){let subcircuit=component.getSubcircuit(),errorMsg=`${component.getString()} failed to load external footprint "${url}": `+(err instanceof Error?err.message:String(err)),errorObj=external_footprint_load_error.parse({type:"external_footprint_load_error",message:errorMsg,pcb_component_id:component.pcb_component_id,source_component_id:component.source_component_id,subcircuit_id:subcircuit.subcircuit_id??void 0,pcb_group_id:component.getGroup()?.pcb_group_id??void 0,footprinter_string:url});db2.external_footprint_load_error.insert(errorObj)}throw err}});return}if(typeof footprint=="string"){let libRef=parseLibraryFootprintRef(footprint);if(!libRef||component._hasStartedFootprintUrlLoad)return;component._hasStartedFootprintUrlLoad=!0;let libMap=component.root?.platform?.footprintLibraryMap?.[libRef.footprintLib],resolverFn;if(typeof libMap=="function"&&(resolverFn=libMap),!resolverFn)return;let resolvedPcbStyle=component.getInheritedMergedProperty("pcbStyle");queueAsyncEffect("load-lib-footprint",async()=>{try{let result=await resolverFn(libRef.footprintName,{resolvedPcbStyle}),circuitJson=null;if(Array.isArray(result)?circuitJson=result:Array.isArray(result.footprintCircuitJson)&&(circuitJson=result.footprintCircuitJson),!circuitJson)return;let fpComponents=createComponentsFromCircuitJson({componentName:component.name,componentRotation:pcbRotation,footprinterString:footprint,pinLabels,pcbPinLabels},circuitJson);component.addAll(fpComponents),!Array.isArray(result)&&result.cadModel&&(component._asyncFootprintCadModel=result.cadModel);for(let child of component.children)child.componentName==="Port"&&child._markDirty?.("PcbPortRender");component._markDirty("InitializePortsFromChildren")}catch(err){let db2=component.root?.db;if(db2&&component.source_component_id&&component.pcb_component_id){let subcircuit=component.getSubcircuit(),errorMsg=`${component.getString()} failed to load external footprint "${footprint}": `+(err instanceof Error?err.message:String(err)),errorObj=external_footprint_load_error.parse({type:"external_footprint_load_error",message:errorMsg,pcb_component_id:component.pcb_component_id,source_component_id:component.source_component_id,subcircuit_id:subcircuit.subcircuit_id??void 0,pcb_group_id:component.getGroup()?.pcb_group_id??void 0,footprinter_string:footprint});db2.external_footprint_load_error.insert(errorObj)}throw err}});return}if(!(0,import_react3.isValidElement)(footprint)&&footprint.componentName==="Footprint"&&component.add(footprint),Array.isArray(footprint)&&!(0,import_react3.isValidElement)(footprint)&&footprint.length>0){try{let fpComponents=createComponentsFromCircuitJson({componentName:component.name,componentRotation:pcbRotation,footprinterString:"",pinLabels,pcbPinLabels},footprint);component.addAll(fpComponents)}catch(err){let db2=component.root?.db;if(db2&&component.source_component_id&&component.pcb_component_id){let subcircuit=component.getSubcircuit(),errorMsg=`${component.getString()} failed to load json footprint: `+(err instanceof Error?err.message:String(err)),errorObj=circuit_json_footprint_load_error.parse({type:"circuit_json_footprint_load_error",message:errorMsg,pcb_component_id:component.pcb_component_id,source_component_id:component.source_component_id,subcircuit_id:subcircuit.subcircuit_id??void 0,pcb_group_id:component.getGroup()?.pcb_group_id??void 0});db2.circuit_json_footprint_load_error.insert(errorObj)}throw err}return}}function NormalComponent_doInitialPcbComponentAnchorAlignment(component){if(component.root?.pcbDisabled||!component.pcb_component_id)return;let{pcbX,pcbY}=component._parsedProps,pcbPositionAnchor=component.props?.pcbPositionAnchor;if(!pcbPositionAnchor||pcbX===void 0&&pcbY===void 0)return;let bounds=getBoundsOfPcbComponents(component.children);if(bounds.width===0||bounds.height===0)return;let currentCenter={...{x:(bounds.minX+bounds.maxX)/2,y:(bounds.minY+bounds.maxY)/2}},anchorPos=null;if(new Set(["center","top_left","top_center","top_right","center_left","center_right","bottom_left","bottom_center","bottom_right"]).has(pcbPositionAnchor)){let b3={left:bounds.minX,right:bounds.maxX,top:bounds.minY,bottom:bounds.maxY};switch(pcbPositionAnchor){case"center":anchorPos=currentCenter;break;case"top_left":anchorPos={x:b3.left,y:b3.top};break;case"top_center":anchorPos={x:currentCenter.x,y:b3.top};break;case"top_right":anchorPos={x:b3.right,y:b3.top};break;case"center_left":anchorPos={x:b3.left,y:currentCenter.y};break;case"center_right":anchorPos={x:b3.right,y:currentCenter.y};break;case"bottom_left":anchorPos={x:b3.left,y:b3.bottom};break;case"bottom_center":anchorPos={x:currentCenter.x,y:b3.bottom};break;case"bottom_right":anchorPos={x:b3.right,y:b3.bottom};break}}else try{let port=component.portMap[pcbPositionAnchor];port&&(anchorPos=port._getGlobalPcbPositionBeforeLayout())}catch{}if(!anchorPos)return;let newCenter={...currentCenter};pcbX!==void 0&&(newCenter.x+=pcbX-anchorPos.x),pcbY!==void 0&&(newCenter.y+=pcbY-anchorPos.y),(Math.abs(newCenter.x-currentCenter.x)>1e-6||Math.abs(newCenter.y-currentCenter.y)>1e-6)&&component._repositionOnPcb(newCenter)}var debug32=(0,import_debug5.default)("tscircuit:core"),rotation32=external_exports.object({x:rotation,y:rotation,z:rotation}),NormalComponent3=class extends PrimitiveComponent2{constructor(props){let filteredProps={...props},invalidPinLabelsMessages=[];if(filteredProps.pinLabels&&!Array.isArray(filteredProps.pinLabels)){let{validPinLabels,invalidPinLabelsMessages:messages}=filterPinLabels(filteredProps.pinLabels);filteredProps.pinLabels=validPinLabels,invalidPinLabelsMessages=messages}super(filteredProps);__publicField(this,"reactSubtrees",[]);__publicField(this,"_impliedFootprint");__publicField(this,"isPrimitiveContainer",!0);__publicField(this,"_isNormalComponent",!0);__publicField(this,"_attributeLowerToCamelNameMap",{_isnormalcomponent:"_isNormalComponent"});__publicField(this,"_asyncSupplierPartNumbers");__publicField(this,"_asyncFootprintCadModel");__publicField(this,"_isCadModelChild");__publicField(this,"pcb_missing_footprint_error_id");__publicField(this,"_hasStartedFootprintUrlLoad",!1);__publicField(this,"_invalidPinLabelMessages",[]);__publicField(this,"_adjustSilkscreenTextAutomatically",!1);this._invalidPinLabelMessages=invalidPinLabelsMessages,this._addChildrenFromStringFootprint(),this.initPorts()}get defaultInternallyConnectedPinNames(){return[]}get internallyConnectedPinNames(){return(this._parsedProps.internallyConnectedPins??this.defaultInternallyConnectedPinNames).map(pinGroup=>pinGroup.map(pin=>typeof pin=="number"?`pin${pin}`:pin))}doInitialSourceNameDuplicateComponentRemoval(){if(!this.name)return;let root=this.root;if(this.getSubcircuit().selectAll(`.${this.name}`).filter(component=>component!==this&&component._isNormalComponent&&component.renderPhaseStates?.SourceNameDuplicateComponentRemoval?.initialized).length>0){let pcbPosition2=this._getGlobalPcbPositionBeforeLayout(),schematicPosition=this._getGlobalSchematicPositionBeforeLayout();root.db.source_failed_to_create_component_error.insert({component_name:this.name,error_type:"source_failed_to_create_component_error",message:`Cannot create component "${this.name}": A component with the same name already exists`,pcb_center:pcbPosition2,schematic_center:schematicPosition}),this.shouldBeRemoved=!0;let childrenToRemove=[...this.children];for(let child of childrenToRemove)this.remove(child)}}initPorts(opts={}){if(this.root?.schematicDisabled)return;let{config}=this,portsToCreate=[],schPortArrangement=this._getSchematicPortArrangement();if(schPortArrangement&&!this._parsedProps.pinLabels){for(let side in schPortArrangement){let pins=schPortArrangement[side].pins;if(Array.isArray(pins))for(let pinNumberOrLabel of pins){let pinNumber=parsePinNumberFromLabelsOrThrow(pinNumberOrLabel,this._parsedProps.pinLabels);portsToCreate.push(new Port({pinNumber,aliases:opts.additionalAliases?.[`pin${pinNumber}`]??[]},{originDescription:`schPortArrangement:${side}`}))}}let sides=["left","right","top","bottom"],pinNum=1;for(let side of sides){let size2=schPortArrangement[`${side}Size`];for(let i3=0;i3<size2;i3++)portsToCreate.push(new Port({pinNumber:pinNum++,aliases:opts.additionalAliases?.[`pin${pinNum}`]??[]},{originDescription:`schPortArrangement:${side}`}))}}let pinLabels=this._parsedProps.pinLabels;if(pinLabels)for(let[pinNumber,label]of Object.entries(pinLabels)){pinNumber=pinNumber.replace("pin","");let existingPort=portsToCreate.find(p2=>p2._parsedProps.pinNumber===Number(pinNumber)),primaryLabel=Array.isArray(label)?label[0]:label,otherLabels=Array.isArray(label)?label.slice(1):[];existingPort?(existingPort.externallyAddedAliases.push(primaryLabel,...otherLabels),existingPort.props.name=primaryLabel):(existingPort=new Port({pinNumber:parseInt(pinNumber),name:primaryLabel,aliases:[...otherLabels,...opts.additionalAliases?.[`pin${parseInt(pinNumber)}`]??[]]},{originDescription:`pinLabels:pin${pinNumber}`}),portsToCreate.push(existingPort))}if(config.schematicSymbolName&&!opts.ignoreSymbolPorts){let sym=cf[this._getSchematicSymbolNameOrThrow()];if(!sym)return;for(let symPort of sym.ports){let pinNumber=getPinNumberFromLabels(symPort.labels);if(!pinNumber)continue;let existingPort=portsToCreate.find(p2=>p2._parsedProps.pinNumber===Number(pinNumber));if(existingPort)existingPort.schematicSymbolPortDef=symPort;else{let port=getPortFromHints(symPort.labels.concat(opts.additionalAliases?.[`pin${pinNumber}`]??[]));port&&(port.originDescription=`schematicSymbol:labels[0]:${symPort.labels[0]}`,port.schematicSymbolPortDef=symPort,portsToCreate.push(port))}}this.addAll(portsToCreate)}if(!this._getSchematicPortArrangement()){let portsFromFootprint=this.getPortsFromFootprint(opts);for(let port of portsFromFootprint)portsToCreate.some(p2=>p2.isMatchingAnyOf(port.getNameAndAliases()))||portsToCreate.push(port)}let requiredPinCount=opts.pinCount??this._getPinCount()??0;for(let pn3=1;pn3<=requiredPinCount;pn3++){if(portsToCreate.find(p2=>p2._parsedProps.pinNumber===pn3))continue;if(!schPortArrangement){portsToCreate.push(new Port({pinNumber:pn3,aliases:opts.additionalAliases?.[`pin${pn3}`]??[]}));continue}let explicitlyListedPinNumbersInSchPortArrangement=[...schPortArrangement.leftSide?.pins??[],...schPortArrangement.rightSide?.pins??[],...schPortArrangement.topSide?.pins??[],...schPortArrangement.bottomSide?.pins??[]].map(pn22=>parsePinNumberFromLabelsOrThrow(pn22,this._parsedProps.pinLabels));["leftSize","rightSize","topSize","bottomSize","leftPinCount","rightPinCount","topPinCount","bottomPinCount"].some(key=>key in schPortArrangement)&&(explicitlyListedPinNumbersInSchPortArrangement=Array.from({length:this._getPinCount()},(_4,i3)=>i3+1)),explicitlyListedPinNumbersInSchPortArrangement.includes(pn3)&&portsToCreate.push(new Port({pinNumber:pn3,aliases:opts.additionalAliases?.[`pin${pn3}`]??[]},{originDescription:`notOtherwiseAddedButDeducedFromPinCount:${pn3}`}))}portsToCreate.length>0&&this.addAll(portsToCreate)}_getImpliedFootprintString(){return null}_addChildrenFromStringFootprint(){let{pcbRotation,pinLabels,pcbPinLabels}=this.props,{footprint}=this.props;if(footprint??(footprint=this._getImpliedFootprintString?.()),!!footprint&&typeof footprint=="string"){if(isHttpUrl(footprint)||isStaticAssetPath(footprint)||parseLibraryFootprintRef(footprint))return;let fpSoup=fp.string(footprint).soup(),fpComponents=createComponentsFromCircuitJson({componentName:this.name??this.componentName,componentRotation:pcbRotation,footprinterString:footprint,pinLabels,pcbPinLabels},fpSoup);this.addAll(fpComponents)}}get portMap(){return new Proxy({},{get:(target,prop)=>{let port=this.children.find(c3=>c3.componentName==="Port"&&c3.isMatchingNameOrAlias(prop));if(!port)throw new Error(`There was an issue finding the port "${prop.toString()}" inside of a ${this.componentName} component with name: "${this.props.name}". This is a bug in @tscircuit/core`);return port}})}getInstanceForReactElement(element){for(let subtree of this.reactSubtrees)if(subtree.element===element)return subtree.component;return null}doInitialSourceRender(){let ftype=this.config.sourceFtype;if(!ftype)return;let{db:db2}=this.root,{_parsedProps:props}=this,source_component=db2.source_component.insert({ftype,name:this.name,manufacturer_part_number:props.manufacturerPartNumber??props.mfn,supplier_part_numbers:props.supplierPartNumbers});this.source_component_id=source_component.source_component_id}doInitialSchematicComponentRender(){if(this.root?.schematicDisabled)return;let{db:db2}=this.root;if(this._invalidPinLabelMessages?.length&&this.root?.db)for(let message of this._invalidPinLabelMessages){let property_name="pinLabels",match2=message.match(/^Invalid pin label:\s*([^=]+)=\s*'([^']+)'/);match2&&(property_name=`pinLabels['${match2[2]}']`),this.root.db.source_property_ignored_warning.insert({source_component_id:this.source_component_id,property_name,message,error_type:"source_property_ignored_warning"})}let{schematicSymbolName}=this.config,{_parsedProps:props}=this;props.symbol&&(0,import_react2.isValidElement)(props.symbol)?this._doInitialSchematicComponentRenderWithReactSymbol(props.symbol):schematicSymbolName?this._doInitialSchematicComponentRenderWithSymbol():this._getSchematicBoxDimensions()&&this._doInitialSchematicComponentRenderWithSchematicBoxDimensions();let manualPlacement=this.getSubcircuit()?._getSchematicManualPlacementForComponent(this);if(this.schematic_component_id&&(this.props.schX!==void 0||this.props.schY!==void 0)&&manualPlacement){if(!this.schematic_component_id)return;let warning=schematic_manual_edit_conflict_warning.parse({type:"schematic_manual_edit_conflict_warning",schematic_manual_edit_conflict_warning_id:`schematic_manual_edit_conflict_${this.source_component_id}`,message:`${this.getString()} has both manual placement and prop coordinates. schX and schY will be used. Remove schX/schY or clear the manual placement.`,schematic_component_id:this.schematic_component_id,source_component_id:this.source_component_id,subcircuit_id:this.getSubcircuit()?.subcircuit_id});db2.schematic_manual_edit_conflict_warning.insert(warning)}}_getSchematicSymbolDisplayValue(){}_getInternallyConnectedPins(){if(this.internallyConnectedPinNames.length===0)return[];let internallyConnectedPorts=[];for(let netPortNames of this.internallyConnectedPinNames){let ports=[];for(let portName of netPortNames)ports.push(this.portMap[portName]);internallyConnectedPorts.push(ports)}return internallyConnectedPorts}_doInitialSchematicComponentRenderWithSymbol(){if(this.root?.schematicDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,symbol_name=this._getSchematicSymbolNameOrThrow(),symbol=cf[symbol_name],center2=this._getGlobalSchematicPositionBeforeLayout();if(symbol){let schematic_component2=db2.schematic_component.insert({center:center2,size:symbol.size,source_component_id:this.source_component_id,is_box_with_pins:!0,symbol_name,symbol_display_value:this._getSchematicSymbolDisplayValue()});this.schematic_component_id=schematic_component2.schematic_component_id}}_doInitialSchematicComponentRenderWithReactSymbol(symbolElement){if(this.root?.schematicDisabled)return;let{db:db2}=this.root,center2=this._getGlobalSchematicPositionBeforeLayout(),schematic_component2=db2.schematic_component.insert({center:center2,size:{width:0,height:0},source_component_id:this.source_component_id,symbol_display_value:this._getSchematicSymbolDisplayValue(),is_box_with_pins:!1});this.schematic_component_id=schematic_component2.schematic_component_id}_doInitialSchematicComponentRenderWithSchematicBoxDimensions(){if(this.root?.schematicDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,dimensions=this._getSchematicBoxDimensions(),primaryPortLabels={};if(Array.isArray(props.pinLabels))props.pinLabels.forEach((label,index)=>{primaryPortLabels[String(index+1)]=label});else for(let[port,label]of Object.entries(props.pinLabels??{}))primaryPortLabels[port]=Array.isArray(label)?label[0]:label;let center2=this._getGlobalSchematicPositionBeforeLayout(),schPortArrangement=this._getSchematicPortArrangement(),schematic_component2=db2.schematic_component.insert({center:center2,rotation:props.schRotation??0,size:dimensions.getSize(),port_arrangement:underscorifyPortArrangement(schPortArrangement),pin_spacing:props.schPinSpacing??.2,pin_styles:underscorifyPinStyles(props.schPinStyle,props.pinLabels),port_labels:primaryPortLabels,source_component_id:this.source_component_id}),hasTopOrBottomPins=schPortArrangement?.topSide!==void 0||schPortArrangement?.bottomSide!==void 0,schematic_box_width=dimensions?.getSize().width,schematic_box_height=dimensions?.getSize().height,manufacturer_part_number_schematic_text=db2.schematic_text.insert({text:props.manufacturerPartNumber??"",schematic_component_id:schematic_component2.schematic_component_id,anchor:"left",rotation:0,position:{x:hasTopOrBottomPins?center2.x+(schematic_box_width??0)/2+.1:center2.x-(schematic_box_width??0)/2,y:hasTopOrBottomPins?center2.y+(schematic_box_height??0)/2+.35:center2.y-(schematic_box_height??0)/2-.13},color:"#006464",font_size:.18}),component_name_text=db2.schematic_text.insert({text:props.name??"",schematic_component_id:schematic_component2.schematic_component_id,anchor:"left",rotation:0,position:{x:hasTopOrBottomPins?center2.x+(schematic_box_width??0)/2+.1:center2.x-(schematic_box_width??0)/2,y:hasTopOrBottomPins?center2.y+(schematic_box_height??0)/2+.55:center2.y+(schematic_box_height??0)/2+.13},color:"#006464",font_size:.18});this.schematic_component_id=schematic_component2.schematic_component_id}doInitialPcbComponentRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,subcircuit=this.getSubcircuit(),componentLayer=props.layer??"top";if(componentLayer!=="top"&&componentLayer!=="bottom"){let error=pcb_component_invalid_layer_error.parse({type:"pcb_component_invalid_layer_error",message:`Component cannot be placed on layer '${componentLayer}'. Components can only be placed on 'top' or 'bottom' layers.`,source_component_id:this.source_component_id,layer:componentLayer,subcircuit_id:subcircuit.subcircuit_id??void 0});db2.pcb_component_invalid_layer_error.insert(error)}let globalTransform=this._computePcbGlobalTransformBeforeLayout(),accumulatedRotation=decomposeTSR(globalTransform).rotation.angle*180/Math.PI,pcb_component2=db2.pcb_component.insert({center:this._getGlobalPcbPositionBeforeLayout(),width:0,height:0,layer:componentLayer==="top"||componentLayer==="bottom"?componentLayer:"top",rotation:props.pcbRotation??accumulatedRotation,source_component_id:this.source_component_id,subcircuit_id:subcircuit.subcircuit_id??void 0,do_not_place:props.doNotPlace??!1,obstructs_within_bounds:props.obstructsWithinBounds??!0});if(!(props.footprint??this._getImpliedFootprintString())&&!this.isGroup){let footprint_error=db2.pcb_missing_footprint_error.insert({message:`No footprint found for component: ${this.getString()}`,source_component_id:`${this.source_component_id}`,error_type:"pcb_missing_footprint_error"});this.pcb_missing_footprint_error_id=footprint_error.pcb_missing_footprint_error_id}this.pcb_component_id=pcb_component2.pcb_component_id;let manualPlacement=this.getSubcircuit()._getPcbManualPlacementForComponent(this);if((this.props.pcbX!==void 0||this.props.pcbY!==void 0)&&manualPlacement){let warning=pcb_manual_edit_conflict_warning.parse({type:"pcb_manual_edit_conflict_warning",pcb_manual_edit_conflict_warning_id:`pcb_manual_edit_conflict_${this.source_component_id}`,message:`${this.getString()} has both manual placement and prop coordinates. pcbX and pcbY will be used. Remove pcbX/pcbY or clear the manual placement.`,pcb_component_id:this.pcb_component_id,source_component_id:this.source_component_id,subcircuit_id:subcircuit.subcircuit_id??void 0});db2.pcb_manual_edit_conflict_warning.insert(warning)}}doInitialPcbComponentSizeCalculation(){if(this.root?.pcbDisabled||!this.pcb_component_id)return;let{db:db2}=this.root,{_parsedProps:props}=this,bounds=getBoundsOfPcbComponents(this.children);if(bounds.width===0||bounds.height===0)return;let center2={x:(bounds.minX+bounds.maxX)/2,y:(bounds.minY+bounds.maxY)/2};db2.pcb_component.update(this.pcb_component_id,{center:center2,width:bounds.width,height:bounds.height})}updatePcbComponentSizeCalculation(){this.doInitialPcbComponentSizeCalculation()}doInitialSchematicComponentSizeCalculation(){if(this.root?.schematicDisabled||!this.schematic_component_id)return;let{db:db2}=this.root;if(!db2.schematic_component.get(this.schematic_component_id))return;let schematicElements=[],collectSchematicPrimitives=children=>{for(let child of children){if(child.isSchematicPrimitive&&child.componentName==="SchematicLine"){let line2=db2.schematic_line.get(child.schematic_line_id);line2&&schematicElements.push(line2)}if(child.isSchematicPrimitive&&child.componentName==="SchematicRect"){let rect=db2.schematic_rect.get(child.schematic_rect_id);rect&&schematicElements.push(rect)}if(child.isSchematicPrimitive&&child.componentName==="SchematicCircle"){let circle2=db2.schematic_circle.get(child.schematic_circle_id);circle2&&schematicElements.push(circle2)}if(child.isSchematicPrimitive&&child.componentName==="SchematicArc"){let arc2=db2.schematic_arc.get(child.schematic_arc_id);arc2&&schematicElements.push(arc2)}if(child.isSchematicPrimitive&&child.componentName==="SchematicText"){let text=db2.schematic_text.get(child.schematic_text_id);text&&schematicElements.push(text)}child.children&&child.children.length>0&&collectSchematicPrimitives(child.children)}};if(collectSchematicPrimitives(this.children),schematicElements.length===0)return;let bounds=getBoundsForSchematic(schematicElements),width=Math.abs(bounds.maxX-bounds.minX),height=Math.abs(bounds.maxY-bounds.minY);if(width===0&&height===0)return;let centerX=(bounds.minX+bounds.maxX)/2,centerY=(bounds.minY+bounds.maxY)/2;db2.schematic_component.update(this.schematic_component_id,{center:{x:centerX,y:centerY},size:{width,height}})}updateSchematicComponentSizeCalculation(){this.doInitialSchematicComponentSizeCalculation()}doInitialPcbComponentAnchorAlignment(){NormalComponent_doInitialPcbComponentAnchorAlignment(this)}updatePcbComponentAnchorAlignment(){this.doInitialPcbComponentAnchorAlignment()}_renderReactSubtree(element){let component=createInstanceFromReactElement(element);return{element,component}}doInitialInitializePortsFromChildren(){this.initPorts()}doInitialReactSubtreesRender(){let fpElm=this.props.footprint;(0,import_react2.isValidElement)(fpElm)&&(this.children.some(c3=>c3.componentName==="Footprint")||this.add(fpElm));let symElm=this.props.symbol;(0,import_react2.isValidElement)(symElm)&&(this.children.some(c3=>c3.componentName==="Symbol")||this.add(symElm));let cmElm=this.props.cadModel;if((0,import_react2.isValidElement)(cmElm)){this._isCadModelChild=!0;let hasCadAssemblyChild=this.children.some(c3=>c3.componentName==="CadAssembly"),hasCadModelChild=this.children.some(c3=>c3.componentName==="CadModel");!hasCadAssemblyChild&&!hasCadModelChild&&this.add(cmElm)}}doInitialPcbFootprintStringRender(){NormalComponent_doInitialPcbFootprintStringRender(this,(name,effect)=>this._queueAsyncEffect(name,effect))}_hasExistingPortExactly(port1){return this.children.filter(c3=>c3.componentName==="Port").some(port2=>{let aliases1=port1.getNameAndAliases(),aliases2=port2.getNameAndAliases();return aliases1.length===aliases2.length&&aliases1.every(alias=>aliases2.includes(alias))})}add(componentOrElm){let component;if((0,import_react2.isValidElement)(componentOrElm)){let subtree=this._renderReactSubtree(componentOrElm);this.reactSubtrees.push(subtree),component=subtree.component}else component=componentOrElm;if(component.componentName==="Port"){if(this._hasExistingPortExactly(component))return;let conflictingPort=this.children.filter(c3=>c3.componentName==="Port").find(p2=>p2.isMatchingAnyOf(component.getNameAndAliases()));conflictingPort&&debug32(`Similar ports added. Port 1: ${conflictingPort}, Port 2: ${component}`)}super.add(component)}getPortsFromFootprint(opts){let{footprint}=this.props;if((!footprint||(0,import_react2.isValidElement)(footprint))&&(footprint=this.children.find(c3=>c3.componentName==="Footprint")),typeof footprint=="string"){if(isHttpUrl(footprint))return[];if(isStaticAssetPath(footprint))return[];if(parseLibraryFootprintRef(footprint))return[];let fpSoup=fp.string(footprint).soup(),newPorts2=[];for(let elm of fpSoup)if("port_hints"in elm&&elm.port_hints){let newPort=getPortFromHints(elm.port_hints,opts);if(!newPort)continue;newPort.originDescription=`footprint:string:${footprint}:port_hints[0]:${elm.port_hints[0]}`,newPorts2.push(newPort)}return newPorts2}if(!(0,import_react2.isValidElement)(footprint)&&footprint&&footprint.componentName==="Footprint"){let fp22=footprint,pinNumber=1,newPorts2=[];for(let fpChild of fp22.children){if(!fpChild.props.portHints)continue;let portHintsList=fpChild.props.portHints;portHintsList.some(hint=>hint.startsWith("pin"))||(portHintsList=[...portHintsList,`pin${pinNumber}`]),pinNumber++;let newPort=getPortFromHints(portHintsList);newPort&&(newPort.originDescription=`footprint:${footprint}`,newPorts2.push(newPort))}return newPorts2}let newPorts=[];if(!footprint){for(let child of this.children)if(child.props.portHints&&child.isPcbPrimitive){let port=getPortFromHints(child.props.portHints);port&&newPorts.push(port)}}return newPorts}getPortsFromSchematicSymbol(){if(this.root?.schematicDisabled)return[];let{config}=this;if(!config.schematicSymbolName)return[];let symbol=cf[config.schematicSymbolName];if(!symbol)return[];let newPorts=[];for(let symbolPort of symbol.ports){let port=getPortFromHints(symbolPort.labels);port&&(port.schematicSymbolPortDef=symbolPort,newPorts.push(port))}return newPorts}doInitialCreateNetsFromProps(){this._createNetsFromProps(this._getNetsFromConnectionsProp())}_getNetsFromConnectionsProp(){let{_parsedProps:props}=this,propsWithConnections=[];if(props.connections)for(let[pinName,target]of Object.entries(props.connections)){let targets=Array.isArray(target)?target:[target];for(let targetPath of targets)propsWithConnections.push(String(targetPath))}return propsWithConnections}_createNetsFromProps(propsWithConnections){createNetsFromProps(this,propsWithConnections)}_getPcbCircuitJsonBounds(){let{db:db2}=this.root;if(!this.pcb_component_id)return super._getPcbCircuitJsonBounds();let pcb_component2=db2.pcb_component.get(this.pcb_component_id);return{center:{x:pcb_component2.center.x,y:pcb_component2.center.y},bounds:{left:pcb_component2.center.x-pcb_component2.width/2,top:pcb_component2.center.y-pcb_component2.height/2,right:pcb_component2.center.x+pcb_component2.width/2,bottom:pcb_component2.center.y+pcb_component2.height/2},width:pcb_component2.width,height:pcb_component2.height}}_getPinCountFromSchematicPortArrangement(){let schPortArrangement=this._getSchematicPortArrangement();if(!schPortArrangement)return 0;if(!isExplicitPinMappingArrangement(schPortArrangement))return(schPortArrangement.leftSize??schPortArrangement.leftPinCount??0)+(schPortArrangement.rightSize??schPortArrangement.rightPinCount??0)+(schPortArrangement.topSize??schPortArrangement.topPinCount??0)+(schPortArrangement.bottomSize??schPortArrangement.bottomPinCount??0);let{leftSide,rightSide,topSide,bottomSide}=schPortArrangement;return Math.max(...leftSide?.pins??[],...rightSide?.pins??[],...topSide?.pins??[],...bottomSide?.pins??[])}_getPinCount(){if(this._getSchematicPortArrangement())return this._getPinCountFromSchematicPortArrangement();let portsFromFootprint=this.getPortsFromFootprint();if(portsFromFootprint.length>0)return portsFromFootprint.length;let{pinLabels}=this._parsedProps;if(pinLabels){if(Array.isArray(pinLabels))return pinLabels.length;let pinNumbers=Object.keys(pinLabels).map(k4=>k4.startsWith("pin")?parseInt(k4.slice(3)):parseInt(k4)).filter(n3=>!Number.isNaN(n3));return pinNumbers.length>0?Math.max(...pinNumbers):Object.keys(pinLabels).length}return 0}_getSchematicPortArrangement(){return this._parsedProps.schPinArrangement??this._parsedProps.schPortArrangement}_getPinLabelsFromPorts(){let ports=this.selectAll("port"),pinLabels={};for(let port of ports){let pinNumber=port.props.pinNumber;if(pinNumber!==void 0){let bestLabel=port._getBestDisplayPinLabel();bestLabel&&(pinLabels[`pin${pinNumber}`]=bestLabel)}}return pinLabels}_getSchematicBoxDimensions(){if(this.getSchematicSymbol()||!this.config.shouldRenderAsSchematicBox)return null;let{_parsedProps:props}=this,pinCount=this._getPinCount(),pinSpacing=props.schPinSpacing??.2,allPinLabels={...this._getPinLabelsFromPorts(),...props.pinLabels};return getAllDimensionsForSchematicBox({schWidth:props.schWidth,schHeight:props.schHeight,schPinSpacing:pinSpacing,numericSchPinStyle:getNumericSchPinStyle(props.schPinStyle,allPinLabels),pinCount,schPortArrangement:this._getSchematicPortArrangement(),pinLabels:allPinLabels})}getFootprinterString(){return typeof this._parsedProps.footprint=="string"?this._parsedProps.footprint:null}doInitialCadModelRender(){if(this._isCadModelChild||this.props.doNotPlace)return;let{db:db2}=this.root,{boardThickness=0}=this.root?._getBoard()??{},cadModelProp2=this._parsedProps.cadModel,cadModel=cadModelProp2===void 0?this._asyncFootprintCadModel:cadModelProp2,footprint=this.getFootprinterString()??this._getImpliedFootprintString();if(!this.pcb_component_id||!cadModel&&!footprint||cadModel===null)return;let bounds=this._getPcbCircuitJsonBounds();if(typeof cadModel=="string")throw new Error("String cadModel not yet implemented");let rotationOffset=rotation32.parse({x:0,y:0,z:typeof cadModel?.rotationOffset=="number"?cadModel.rotationOffset:0,...typeof cadModel?.rotationOffset=="object"?cadModel.rotationOffset??{}:{}}),positionOffset=point3.parse({x:0,y:0,z:0,...typeof cadModel?.positionOffset=="object"?cadModel.positionOffset:{}}),zOffsetFromSurface=cadModel&&typeof cadModel=="object"&&"zOffsetFromSurface"in cadModel&&cadModel.zOffsetFromSurface!==void 0?distance.parse(cadModel.zOffsetFromSurface):0,computedLayer=this.props.layer==="bottom"?"bottom":"top",globalTransform=this._computePcbGlobalTransformBeforeLayout(),totalRotation=decomposeTSR(globalTransform).rotation.angle*180/Math.PI,isBottomLayer=computedLayer==="bottom",rotationWithOffset=totalRotation+(rotationOffset.z??0),cadRotationZ=normalizeDegrees(rotationWithOffset),cad_model=db2.cad_component.insert({position:{x:bounds.center.x+positionOffset.x,y:bounds.center.y+positionOffset.y,z:(computedLayer==="bottom"?-boardThickness/2:boardThickness/2)+(computedLayer==="bottom"?-zOffsetFromSurface:zOffsetFromSurface)+positionOffset.z},rotation:{x:rotationOffset.x,y:rotationOffset.y+(isBottomLayer?180:0),z:normalizeDegrees(isBottomLayer?-cadRotationZ:cadRotationZ)},pcb_component_id:this.pcb_component_id,source_component_id:this.source_component_id,model_stl_url:"stlUrl"in(cadModel??{})?this._addCachebustToModelUrl(cadModel.stlUrl):void 0,model_obj_url:"objUrl"in(cadModel??{})?this._addCachebustToModelUrl(cadModel.objUrl):void 0,model_mtl_url:"mtlUrl"in(cadModel??{})?this._addCachebustToModelUrl(cadModel.mtlUrl):void 0,model_gltf_url:"gltfUrl"in(cadModel??{})?this._addCachebustToModelUrl(cadModel.gltfUrl):void 0,model_glb_url:"glbUrl"in(cadModel??{})?this._addCachebustToModelUrl(cadModel.glbUrl):void 0,model_step_url:"stepUrl"in(cadModel??{})?this._addCachebustToModelUrl(cadModel.stepUrl):void 0,model_wrl_url:"wrlUrl"in(cadModel??{})?this._addCachebustToModelUrl(cadModel.wrlUrl):void 0,model_jscad:"jscad"in(cadModel??{})?cadModel.jscad:void 0,model_unit_to_mm_scale_factor:typeof cadModel?.modelUnitToMmScale=="number"?cadModel.modelUnitToMmScale:void 0,footprinter_string:typeof footprint=="string"&&!cadModel?footprint:void 0,show_as_translucent_model:this._parsedProps.showAsTranslucentModel});this.cad_component_id=cad_model.cad_component_id}_addCachebustToModelUrl(url){if(!url||!url.includes("modelcdn.tscircuit.com"))return url;let origin=this.root?.getClientOrigin()??"";return`${url}${url.includes("?")?"&":"?"}cachebust_origin=${encodeURIComponent(origin)}`}_getPartsEngineCacheKey(source_component,footprinterString){return JSON.stringify({ftype:source_component.ftype,name:source_component.name,manufacturer_part_number:source_component.manufacturer_part_number,footprinterString})}async _getSupplierPartNumbers(partsEngine2,source_component,footprinterString){if(this.props.doNotPlace)return{};let cacheEngine=this.root?.platform?.localCacheEngine,cacheKey=this._getPartsEngineCacheKey(source_component,footprinterString);if(cacheEngine){let cached=await cacheEngine.getItem(cacheKey);if(cached)try{return JSON.parse(cached)}catch{}}let result=await Promise.resolve(partsEngine2.findPart({sourceComponent:source_component,footprinterString}));if(typeof result=="string"){if(result.includes("<!DOCTYPE")||result.includes("<html"))throw new Error(`Failed to fetch supplier part numbers: Received HTML response instead of JSON. Response starts with: ${result.substring(0,100)}`);if(result==="Not found")return{};throw new Error(`Invalid supplier part numbers format: Expected object but got string: "${result}"`)}if(!result||Array.isArray(result)||typeof result!="object"){let actualType=result===null?"null":Array.isArray(result)?"array":typeof result;throw new Error(`Invalid supplier part numbers format: Expected object but got ${actualType}`)}let supplierPartNumbers=result;if(cacheEngine)try{await cacheEngine.setItem(cacheKey,JSON.stringify(supplierPartNumbers))}catch{}return supplierPartNumbers}doInitialPartsEngineRender(){if(this.props.doNotPlace||this.getInheritedProperty("bomDisabled"))return;let partsEngine2=this.getInheritedProperty("partsEngine");if(!partsEngine2)return;let{db:db2}=this.root,source_component=db2.source_component.get(this.source_component_id);if(!source_component||source_component.supplier_part_numbers)return;let footprinterString;this.props.footprint&&typeof this.props.footprint=="string"&&(footprinterString=this.props.footprint);let supplierPartNumbersMaybePromise=this._getSupplierPartNumbers(partsEngine2,source_component,footprinterString);if(!(supplierPartNumbersMaybePromise instanceof Promise)){db2.source_component.update(this.source_component_id,{supplier_part_numbers:supplierPartNumbersMaybePromise});return}this._queueAsyncEffect("get-supplier-part-numbers",async()=>{await supplierPartNumbersMaybePromise.then(supplierPartNumbers=>{this._asyncSupplierPartNumbers=supplierPartNumbers,this._markDirty("PartsEngineRender")}).catch(error=>{this._asyncSupplierPartNumbers={};let errorObj=unknown_error_finding_part.parse({type:"unknown_error_finding_part",message:`Failed to fetch supplier part numbers for ${this.getString()}: ${error.message}`,source_component_id:this.source_component_id,subcircuit_id:this.getSubcircuit()?.subcircuit_id});db2.unknown_error_finding_part.insert(errorObj),this._markDirty("PartsEngineRender")})})}updatePartsEngineRender(){if(this.props.doNotPlace||this.getInheritedProperty("bomDisabled"))return;let{db:db2}=this.root,source_component=db2.source_component.get(this.source_component_id);if(source_component&&!source_component.supplier_part_numbers&&this._asyncSupplierPartNumbers){db2.source_component.update(this.source_component_id,{supplier_part_numbers:this._asyncSupplierPartNumbers});return}}doInitialAssignFallbackProps(){let{_parsedProps:props}=this;props.connections&&!this.name&&(this.fallbackUnassignedName=this.getSubcircuit().getNextAvailableName(this))}doInitialCreateTracesFromProps(){this._createTracesFromConnectionsProp()}_createTracesFromConnectionsProp(){let{_parsedProps:props}=this;if(props.connections)for(let[pinName,target]of Object.entries(props.connections)){let targets=Array.isArray(target)?target:[target];for(let targetPath of targets)this.add(new Trace3({from:`.${this.name} > .${pinName}`,to:String(targetPath)}))}}doInitialSourceDesignRuleChecks(){NormalComponent_doInitialSourceDesignRuleChecks(this)}doInitialPcbLayout(){if(this.root?.pcbDisabled||!this.pcb_component_id)return;let{db:db2}=this.root,props=this._parsedProps;if(!(props.pcbX!==void 0||props.pcbY!==void 0))return;let sourceComponent=db2.source_component.get(this.source_component_id),positionedRelativeToGroupId=sourceComponent?.source_group_id?db2.pcb_group.getWhere({source_group_id:sourceComponent.source_group_id})?.pcb_group_id:void 0,positionedRelativeToBoardId=positionedRelativeToGroupId?void 0:this._getBoard()?.pcb_board_id??void 0;db2.pcb_component.update(this.pcb_component_id,{position_mode:"relative_to_group_anchor",positioned_relative_to_pcb_group_id:positionedRelativeToGroupId,positioned_relative_to_pcb_board_id:positionedRelativeToBoardId,display_offset_x:props.pcbX,display_offset_y:props.pcbY})}_getMinimumFlexContainerSize(){return NormalComponent__getMinimumFlexContainerSize(this)}_repositionOnPcb(position2){return NormalComponent__repositionOnPcb(this,position2)}doInitialSilkscreenOverlapAdjustment(){return NormalComponent_doInitialSilkscreenOverlapAdjustment(this)}isRelativelyPositioned(){return this._parsedProps.pcbX!==void 0||this._parsedProps.pcbY!==void 0}},getBoardCenterFromAnchor=({boardAnchorPosition,boardAnchorAlignment,width,height})=>{let{x:ax2,y:ay2}=boardAnchorPosition,cx2=ax2,cy2=ay2;switch(boardAnchorAlignment){case"top_left":cx2=ax2+width/2,cy2=ay2-height/2;break;case"top_right":cx2=ax2-width/2,cy2=ay2-height/2;break;case"bottom_left":cx2=ax2+width/2,cy2=ay2+height/2;break;case"bottom_right":cx2=ax2-width/2,cy2=ay2+height/2;break;case"top":cx2=ax2,cy2=ay2-height/2;break;case"bottom":cx2=ax2,cy2=ay2+height/2;break;case"left":cx2=ax2+width/2,cy2=ay2;break;case"right":cx2=ax2-width/2,cy2=ay2;break;default:break}return{x:cx2,y:cy2}},SOLVERS={PackSolver2,AutoroutingPipelineSolver:Zo2,AssignableAutoroutingPipeline2:hr2,AssignableAutoroutingPipeline3:Na2,AutoroutingPipeline1_OriginalUnravel:zi2,CopperPourPipelineSolver},TscircuitAutorouter=class{constructor(input2,options={}){__publicField(this,"input");__publicField(this,"isRouting",!1);__publicField(this,"solver");__publicField(this,"eventHandlers",{complete:[],error:[],progress:[]});__publicField(this,"cycleCount",0);__publicField(this,"stepDelay");__publicField(this,"timeoutId");this.input=input2;let{capacityDepth,targetMinCapacity,stepDelay=0,useAssignableSolver=!1,useAutoJumperSolver=!1,autorouterVersion:autorouterVersion2,onSolverStarted}=options,solverName;autorouterVersion2==="v1"?solverName="AutoroutingPipeline1_OriginalUnravel":useAutoJumperSolver?solverName="AssignableAutoroutingPipeline3":useAssignableSolver?solverName="AssignableAutoroutingPipeline2":solverName="AutoroutingPipelineSolver";let SolverClass=SOLVERS[solverName];this.solver=new SolverClass(input2,{capacityDepth,targetMinCapacity,cacheProvider:null}),onSolverStarted?.({solverName,solverParams:{input:input2,options:{capacityDepth,targetMinCapacity,cacheProvider:null}}}),this.stepDelay=stepDelay}start(){this.isRouting||(this.isRouting=!0,this.cycleCount=0,this.runCycleAndQueueNextCycle())}runCycleAndQueueNextCycle(){if(this.isRouting)try{if(this.solver.solved||this.solver.failed){this.solver.failed?this.emitEvent({type:"error",error:new AutorouterError(this.solver.error||"Routing failed")}):this.emitEvent({type:"complete",traces:this.solver.getOutputSimpleRouteJson().traces||[]}),this.isRouting=!1;return}let startTime=Date.now(),startIterations=this.solver.iterations;for(;Date.now()-startTime<250&&!this.solver.failed&&!this.solver.solved;)this.solver.step();let iterationsPerSecond=(this.solver.iterations-startIterations)/(Date.now()-startTime)*1e3;this.cycleCount++;let debugGraphics=this.solver?.preview()||void 0,progress=this.solver.progress;this.emitEvent({type:"progress",steps:this.cycleCount,iterationsPerSecond,progress,phase:this.solver.getCurrentPhase(),debugGraphics}),this.stepDelay>0?this.timeoutId=setTimeout(()=>this.runCycleAndQueueNextCycle(),this.stepDelay):this.timeoutId=setTimeout(()=>this.runCycleAndQueueNextCycle(),0)}catch(error){this.emitEvent({type:"error",error:error instanceof Error?new AutorouterError(error.message):new AutorouterError(String(error))}),this.isRouting=!1}}stop(){this.isRouting&&(this.isRouting=!1,this.timeoutId!==void 0&&(clearTimeout(this.timeoutId),this.timeoutId=void 0))}on(event,callback){event==="complete"?this.eventHandlers.complete.push(callback):event==="error"?this.eventHandlers.error.push(callback):event==="progress"&&this.eventHandlers.progress.push(callback)}emitEvent(event){if(event.type==="complete")for(let handler of this.eventHandlers.complete)handler(event);else if(event.type==="error")for(let handler of this.eventHandlers.error)handler(event);else if(event.type==="progress")for(let handler of this.eventHandlers.progress)handler(event)}solveSync(){if(this.solver.solve(),this.solver.failed)throw new AutorouterError(this.solver.error||"Routing failed");return this.solver.getOutputSimpleRouteJson().traces||[]}getConnectedOffboardObstacles(){return"getConnectedOffboardObstacles"in this.solver?this.solver.getConnectedOffboardObstacles():{}}},TraceHint=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"matchedPort",null)}get config(){return{componentName:"TraceHint",zodProps:traceHintProps}}doInitialPortMatching(){let{db:db2}=this.root,{_parsedProps:props,parent}=this;if(!parent)return;if(parent.componentName==="Trace"){this.renderError(`Port inference inside trace is not yet supported (${this})`);return}if(!parent)throw new Error("TraceHint has no parent");if(!props.for){this.renderError(`TraceHint has no for property (${this})`);return}let port=parent.selectOne(props.for,{type:"port"});port||this.renderError(`${this} could not find port for selector "${props.for}"`),this.matchedPort=port,port.registerMatch(this)}getPcbRouteHints(){let{_parsedProps:props}=this,offsets=props.offset?[props.offset]:props.offsets;if(!offsets)return[];let globalTransform=this._computePcbGlobalTransformBeforeLayout();return offsets.map(offset=>({...applyToPoint(globalTransform,offset),via:offset.via,to_layer:offset.to_layer,trace_width:offset.trace_width}))}doInitialPcbTraceHintRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this;db2.pcb_trace_hint.insert({pcb_component_id:this.matchedPort?.pcb_component_id,pcb_port_id:this.matchedPort?.pcb_port_id,route:this.getPcbRouteHints()})}},applyPcbEditEventsToManualEditsFile=({circuitJson,editEvents,manualEditsFile})=>{let updatedManualEditsFile={...manualEditsFile,pcb_placements:[...manualEditsFile.pcb_placements??[]]};for(let editEvent of editEvents)if(editEvent.edit_event_type==="edit_pcb_component_location"){let{pcb_component_id,new_center}=editEvent,pcb_component2=su2(circuitJson).pcb_component.get(pcb_component_id);if(!pcb_component2)continue;let source_component=su2(circuitJson).source_component.get(pcb_component2.source_component_id);if(!source_component)continue;let existingPlacementIndex=updatedManualEditsFile.pcb_placements?.findIndex(p2=>p2.selector===source_component.name),newPlacement={selector:source_component.name,center:new_center,relative_to:"group_center"};existingPlacementIndex>=0?updatedManualEditsFile.pcb_placements[existingPlacementIndex]=newPlacement:updatedManualEditsFile.pcb_placements.push(newPlacement)}return updatedManualEditsFile},applySchematicEditEventsToManualEditsFile=({circuitJson,editEvents,manualEditsFile})=>{let updatedManualEditsFile={...manualEditsFile,schematic_placements:[...manualEditsFile.schematic_placements??[]]};for(let editEvent of editEvents)if(editEvent.edit_event_type==="edit_schematic_component_location"){let{schematic_component_id,new_center}=editEvent,schematic_component2=su2(circuitJson).schematic_component.get(schematic_component_id);if(!schematic_component2||!schematic_component2.source_component_id)continue;let source_component=su2(circuitJson).source_component.get(schematic_component2.source_component_id);if(!source_component)continue;let existingPlacementIndex=updatedManualEditsFile.schematic_placements?.findIndex(p2=>p2.selector===source_component.name),newPlacement={selector:source_component.name,center:new_center,relative_to:"group_center"};existingPlacementIndex>=0?updatedManualEditsFile.schematic_placements[existingPlacementIndex]=newPlacement:updatedManualEditsFile.schematic_placements.push(newPlacement)}return updatedManualEditsFile},applyEditEventsToManualEditsFile=({circuitJson,editEvents,manualEditsFile})=>{let schematicEditEvents=editEvents.filter(event=>event.edit_event_type==="edit_schematic_component_location"),pcbEditEvents=editEvents.filter(event=>event.edit_event_type==="edit_pcb_component_location"),updatedManualEditsFile=manualEditsFile;return schematicEditEvents.length>0&&(updatedManualEditsFile=applySchematicEditEventsToManualEditsFile({circuitJson,editEvents:schematicEditEvents,manualEditsFile:updatedManualEditsFile})),pcbEditEvents.length>0&&(updatedManualEditsFile=applyPcbEditEventsToManualEditsFile({circuitJson,editEvents:pcbEditEvents,manualEditsFile:updatedManualEditsFile})),updatedManualEditsFile},applyTraceHintEditEvent=(circuitJson,edit_event)=>{if(su2(circuitJson).pcb_trace_hint.get(edit_event.pcb_trace_hint_id))circuitJson=circuitJson.map(e4=>e4.pcb_trace_hint_id===edit_event.pcb_trace_hint_id?{...e4,route:edit_event.route}:e4);else{let pcbPort=su2(circuitJson).pcb_port.get(edit_event.pcb_port_id);circuitJson=circuitJson.filter(e4=>!(e4.type==="pcb_trace_hint"&&e4.pcb_port_id===edit_event.pcb_port_id)).concat([{type:"pcb_trace_hint",pcb_trace_hint_id:edit_event.pcb_trace_hint_id,route:edit_event.route,pcb_port_id:edit_event.pcb_port_id,pcb_component_id:pcbPort?.pcb_component_id}])}return circuitJson},applyEditEvents=({circuitJson,editEvents})=>{circuitJson=JSON.parse(JSON.stringify(circuitJson));for(let editEvent of editEvents)if(editEvent.edit_event_type==="edit_pcb_component_location"){let component=circuitJson.find(e4=>e4.type==="pcb_component"&&e4.pcb_component_id===editEvent.pcb_component_id);if((!component||component.center.x!==editEvent.new_center.x||component.center.y!==editEvent.new_center.y)&&editEvent.original_center){let mat=translate(editEvent.new_center.x-editEvent.original_center.x,editEvent.new_center.y-editEvent.original_center.y);circuitJson=circuitJson.map(e4=>e4.pcb_component_id!==editEvent.pcb_component_id?e4:transformPCBElement(e4,mat))}}else editEvent.edit_event_type==="edit_schematic_component_location"?circuitJson=circuitJson.map(e4=>e4.type==="schematic_component"&&e4.schematic_component_id===editEvent.schematic_component_id?{...e4,center:editEvent.new_center}:e4):editEvent.edit_event_type==="edit_pcb_trace_hint"&&(circuitJson=applyTraceHintEditEvent(circuitJson,editEvent));return circuitJson},getDescendantSubcircuitIds=(db2,root_subcircuit_id)=>{let groups=db2.source_group.list(),result=[],findDescendants=parentId=>{let children=groups.filter(group=>group.parent_subcircuit_id===parentId);for(let child of children)child.subcircuit_id&&(result.push(child.subcircuit_id),findDescendants(child.subcircuit_id))};return findDescendants(root_subcircuit_id),result},getSimpleRouteJsonFromCircuitJson=({db:db2,circuitJson,subcircuit_id,minTraceWidth=.1,nominalTraceWidth})=>{if(!db2&&circuitJson&&(db2=su2(circuitJson)),!db2)throw new Error("db or circuitJson is required");let traceHints=db2.pcb_trace_hint.list(),relevantSubcircuitIds=subcircuit_id?new Set([subcircuit_id]):null;if(subcircuit_id){let descendantSubcircuitIds=getDescendantSubcircuitIds(db2,subcircuit_id);for(let id2 of descendantSubcircuitIds)relevantSubcircuitIds.add(id2)}let subcircuitElements=(circuitJson??db2.toArray()).filter(e4=>!subcircuit_id||"subcircuit_id"in e4&&relevantSubcircuitIds.has(e4.subcircuit_id)),board=null;if(subcircuit_id){let source_group_id=subcircuit_id.replace(/^subcircuit_/,""),source_board2=db2.source_board.getWhere({source_group_id});source_board2&&(board=db2.pcb_board.getWhere({source_board_id:source_board2.source_board_id}))}board||(board=db2.pcb_board.list()[0]),db2=su2(subcircuitElements);let connMap=getFullConnectivityMapFromCircuitJson(subcircuitElements),obstacles=getObstaclesFromCircuitJson2([...db2.pcb_component.list(),...db2.pcb_smtpad.list(),...db2.pcb_plated_hole.list(),...db2.pcb_hole.list(),...db2.pcb_via.list(),...db2.pcb_cutout.list()].filter(e4=>!subcircuit_id||relevantSubcircuitIds?.has(e4.subcircuit_id)),connMap);for(let obstacle of obstacles){let additionalIds=obstacle.connectedTo.flatMap(id2=>connMap.getIdsConnectedToNet(id2));obstacle.connectedTo.push(...additionalIds)}let internalConnections=db2.source_component_internal_connection.list(),sourcePortIdToInternalConnectionId=new Map;for(let ic2 of internalConnections)for(let sourcePortId of ic2.source_port_ids)sourcePortIdToInternalConnectionId.set(sourcePortId,ic2.source_component_internal_connection_id);let pcbElementIdToSourcePortId=new Map;for(let pcbPort of db2.pcb_port.list())if(pcbPort.source_port_id){let smtpad2=db2.pcb_smtpad.getWhere({pcb_port_id:pcbPort.pcb_port_id});smtpad2&&pcbElementIdToSourcePortId.set(smtpad2.pcb_smtpad_id,pcbPort.source_port_id);let platedHole=db2.pcb_plated_hole.getWhere({pcb_port_id:pcbPort.pcb_port_id});platedHole&&pcbElementIdToSourcePortId.set(platedHole.pcb_plated_hole_id,pcbPort.source_port_id)}for(let obstacle of obstacles)for(let connectedId of obstacle.connectedTo){let sourcePortId=pcbElementIdToSourcePortId.get(connectedId);if(sourcePortId){let internalConnectionId=sourcePortIdToInternalConnectionId.get(sourcePortId);if(internalConnectionId){obstacle.offBoardConnectsTo=[internalConnectionId],obstacle.netIsAssignable=!0;break}}}let allPoints=obstacles.flatMap(o4=>[{x:o4.center.x-o4.width/2,y:o4.center.y-o4.height/2},{x:o4.center.x+o4.width/2,y:o4.center.y+o4.height/2}]).concat(board?.outline??[]),bounds;if(board&&!board.outline?bounds={minX:board.center.x-board.width/2,maxX:board.center.x+board.width/2,minY:board.center.y-board.height/2,maxY:board.center.y+board.height/2}:bounds={minX:Math.min(...allPoints.map(p2=>p2.x))-1,maxX:Math.max(...allPoints.map(p2=>p2.x))+1,minY:Math.min(...allPoints.map(p2=>p2.y))-1,maxY:Math.max(...allPoints.map(p2=>p2.y))+1},subcircuit_id){let group=db2.pcb_group.getWhere({subcircuit_id});if(group?.width&&group.height){let groupBounds={minX:group.center.x-group.width/2,maxX:group.center.x+group.width/2,minY:group.center.y-group.height/2,maxY:group.center.y+group.height/2};bounds={minX:Math.min(bounds.minX,groupBounds.minX),maxX:Math.max(bounds.maxX,groupBounds.maxX),minY:Math.min(bounds.minY,groupBounds.minY),maxY:Math.max(bounds.maxY,groupBounds.maxY)}}}let routedTraceIds=new Set(db2.pcb_trace.list().map(t5=>t5.source_trace_id).filter(id2=>!!id2)),directTraceConnections=db2.source_trace.list().filter(trace=>!routedTraceIds.has(trace.source_trace_id)).map(trace=>{let connectedPorts=trace.connected_source_port_ids.map(id2=>{let source_port2=db2.source_port.get(id2),pcb_port2=db2.pcb_port.getWhere({source_port_id:id2});return{...source_port2,...pcb_port2}});if(connectedPorts.length<2)return null;let[portA,portB]=connectedPorts;if(portA.x===void 0||portA.y===void 0)return console.error(`(source_port_id: ${portA.source_port_id}) for trace ${trace.source_trace_id} does not have x/y coordinates. Skipping this trace.`),null;if(portB.x===void 0||portB.y===void 0)return console.error(`(source_port_id: ${portB.source_port_id}) for trace ${trace.source_trace_id} does not have x/y coordinates. Skipping this trace.`),null;let layerA=portA.layers?.[0]??"top",layerB=portB.layers?.[0]??"top",matchingHints=traceHints.filter(hint=>hint.pcb_port_id===portA.pcb_port_id||hint.pcb_port_id===portB.pcb_port_id),hintPoints=[];for(let hint of matchingHints){let layer=db2.pcb_port.get(hint.pcb_port_id)?.layers?.[0]??"top";for(let pt3 of hint.route)hintPoints.push({x:pt3.x,y:pt3.y,layer})}return{name:trace.source_trace_id??connMap.getNetConnectedToId(trace.source_trace_id)??"",source_trace_id:trace.source_trace_id,width:trace.min_trace_thickness,pointsToConnect:[{x:portA.x,y:portA.y,layer:layerA,pointId:portA.pcb_port_id,pcb_port_id:portA.pcb_port_id},...hintPoints,{x:portB.x,y:portB.y,layer:layerB,pointId:portB.pcb_port_id,pcb_port_id:portB.pcb_port_id}]}}).filter(c3=>c3!==null),directTraceConnectionsById=new Map(directTraceConnections.map(c3=>[c3.source_trace_id,c3])),source_nets=db2.source_net.list().filter(e4=>!subcircuit_id||relevantSubcircuitIds?.has(e4.subcircuit_id)),connectionsFromNets=[];for(let net of source_nets){let connectedSourceTraces=db2.source_trace.list().filter(st2=>st2.connected_source_net_ids?.includes(net.source_net_id));connectionsFromNets.push({name:net.source_net_id??connMap.getNetConnectedToId(net.source_net_id),pointsToConnect:connectedSourceTraces.flatMap(st2=>db2.pcb_port.list().filter(p2=>st2.connected_source_port_ids.includes(p2.source_port_id)).map(p2=>({x:p2.x,y:p2.y,layer:p2.layers?.[0]??"top",pointId:p2.pcb_port_id,pcb_port_id:p2.pcb_port_id})))})}let breakoutPoints=db2.pcb_breakout_point.list().filter(bp2=>!subcircuit_id||relevantSubcircuitIds?.has(bp2.subcircuit_id)),connectionsFromBreakoutPoints=[],breakoutTraceConnectionsById=new Map;for(let bp2 of breakoutPoints){let pt3={x:bp2.x,y:bp2.y,layer:"top"};if(bp2.source_trace_id){let conn=directTraceConnectionsById.get(bp2.source_trace_id)??breakoutTraceConnectionsById.get(bp2.source_trace_id);if(conn)conn.pointsToConnect.push(pt3);else{let newConn={name:bp2.source_trace_id,source_trace_id:bp2.source_trace_id,pointsToConnect:[pt3]};connectionsFromBreakoutPoints.push(newConn),breakoutTraceConnectionsById.set(bp2.source_trace_id,newConn)}}else if(bp2.source_net_id){let conn=connectionsFromNets.find(c3=>c3.name===bp2.source_net_id);conn?conn.pointsToConnect.push(pt3):connectionsFromBreakoutPoints.push({name:bp2.source_net_id,pointsToConnect:[pt3]})}else if(bp2.source_port_id){let pcb_port2=db2.pcb_port.getWhere({source_port_id:bp2.source_port_id});pcb_port2&&connectionsFromBreakoutPoints.push({name:bp2.source_port_id,source_trace_id:void 0,pointsToConnect:[{x:pcb_port2.x,y:pcb_port2.y,layer:pcb_port2.layers?.[0]??"top",pointId:pcb_port2.pcb_port_id,pcb_port_id:pcb_port2.pcb_port_id},pt3]})}}let allConns=[...directTraceConnections,...connectionsFromNets,...connectionsFromBreakoutPoints],pointIdToConn=new Map;for(let conn of allConns)for(let pt3 of conn.pointsToConnect)pt3.pointId&&pointIdToConn.set(pt3.pointId,conn);let existingTraces=db2.pcb_trace.list().filter(t5=>!subcircuit_id||relevantSubcircuitIds?.has(t5.subcircuit_id));for(let tr3 of existingTraces){let tracePortIds=new Set;for(let seg of tr3.route)seg.start_pcb_port_id&&tracePortIds.add(seg.start_pcb_port_id),seg.end_pcb_port_id&&tracePortIds.add(seg.end_pcb_port_id);if(tracePortIds.size<2)continue;let firstId=tracePortIds.values().next().value;if(!firstId)continue;let conn=pointIdToConn.get(firstId);conn&&[...tracePortIds].every(pid=>pointIdToConn.get(pid)===conn)&&(conn.externallyConnectedPointIds??(conn.externallyConnectedPointIds=[]),conn.externallyConnectedPointIds.push([...tracePortIds]))}return{simpleRouteJson:{bounds,obstacles,connections:allConns,layerCount:board?.num_layers??2,minTraceWidth,nominalTraceWidth,outline:board?.outline?.map(point23=>({...point23}))},connMap}},getPhaseTimingsFromRenderEvents=renderEvents=>{let phaseTimings={};if(!renderEvents)return phaseTimings;for(let renderPhase of orderedRenderPhases)phaseTimings[renderPhase]=0;let startEvents=new Map;for(let event of renderEvents){let[,,phase,eventType]=event.type.split(":");if(eventType==="start"){startEvents.set(`${phase}:${event.renderId}`,event);continue}if(eventType==="end"){let startEvent=startEvents.get(`${phase}:${event.renderId}`);if(startEvent){let duration=event.createdAt-startEvent.createdAt;phaseTimings[phase]=(phaseTimings[phase]||0)+duration}}}return phaseTimings},normalizePinLabels=inputPinLabels=>{let unqInputPinLabels=inputPinLabels.map(labels=>[...new Set(labels)]),result=unqInputPinLabels.map(()=>[]),desiredNumbers=unqInputPinLabels.map(()=>null);for(let i3=0;i3<unqInputPinLabels.length;i3++)for(let label of unqInputPinLabels[i3])if(/^\d+$/.test(label)){desiredNumbers[i3]=Number.parseInt(label);break}let highestPinNumber=0,alreadyAcceptedDesiredNumbers=new Set;for(let i3=0;i3<desiredNumbers.length;i3++){let desiredNumber=desiredNumbers[i3];if(desiredNumber===null||desiredNumber<1)continue;if(!alreadyAcceptedDesiredNumbers.has(desiredNumber)){alreadyAcceptedDesiredNumbers.add(desiredNumber),result[i3].push(`pin${desiredNumber}`),highestPinNumber=Math.max(highestPinNumber,desiredNumber);continue}let existingAltsForPin=0;for(let label of result[i3])label.startsWith(`pin${desiredNumber}_alt`)&&existingAltsForPin++;result[i3].push(`pin${desiredNumber}_alt${existingAltsForPin+1}`)}for(let i3=0;i3<result.length;i3++)result[i3][0]?.includes("_alt")&&(highestPinNumber++,result[i3].unshift(`pin${highestPinNumber}`));for(let i3=0;i3<result.length;i3++)result[i3].length===0&&(highestPinNumber++,result[i3].push(`pin${highestPinNumber}`));let totalLabelCounts={};for(let inputLabels of unqInputPinLabels)for(let label of inputLabels)/^\d+$/.test(label)||(totalLabelCounts[label]=(totalLabelCounts[label]??0)+1);let incrementalLabelCounts={};for(let i3=0;i3<unqInputPinLabels.length;i3++){let inputLabels=unqInputPinLabels[i3];for(let label of inputLabels)/^\d+$/.test(label)||(totalLabelCounts[label]===1?result[i3].push(label):(incrementalLabelCounts[label]=(incrementalLabelCounts[label]??0)+1,result[i3].push(`${label}${incrementalLabelCounts[label]}`)))}return result};function updateSchematicPrimitivesForLayoutShift({db:db2,schematicComponentId,deltaX,deltaY}){let rects=db2.schematic_rect.list({schematic_component_id:schematicComponentId});for(let rect of rects)rect.center.x+=deltaX,rect.center.y+=deltaY;let lines=db2.schematic_line.list({schematic_component_id:schematicComponentId});for(let line2 of lines)line2.x1+=deltaX,line2.y1+=deltaY,line2.x2+=deltaX,line2.y2+=deltaY;let circles=db2.schematic_circle.list({schematic_component_id:schematicComponentId});for(let circle2 of circles)circle2.center.x+=deltaX,circle2.center.y+=deltaY;let arcs=db2.schematic_arc.list({schematic_component_id:schematicComponentId});for(let arc2 of arcs)arc2.center.x+=deltaX,arc2.center.y+=deltaY}var debug42=(0,import_debug11.default)("Group_doInitialSchematicLayoutMatchAdapt");function Group_doInitialSchematicLayoutMatchAdapt(group){let{db:db2}=group.root,subtreeCircuitJson=buildSubtree(db2.toArray(),{source_group_id:group.source_group_id}),bpcGraphBeforeGeneratedNetLabels=convertCircuitJsonToBpc(subtreeCircuitJson);debug42.enabled&&global?.debugGraphics&&global.debugGraphics?.push(getGraphicsForBpcGraph(bpcGraphBeforeGeneratedNetLabels,{title:`floatingBpcGraph-${group.name}`}));let floatingGraph=convertCircuitJsonToBpc(subtreeCircuitJson),floatingGraphNoNotConnected={boxes:floatingGraph.boxes,pins:floatingGraph.pins.map(p2=>({...p2,color:p2.color.replace("not_connected","normal")}))},{result:laidOutBpcGraph}=layoutSchematicGraphVariants([{variantName:"default",floatingGraph},{variantName:"noNotConnected",floatingGraph:floatingGraphNoNotConnected}],{singletonKeys:["vcc/2","gnd/2"],centerPinColors:["netlabel_center","component_center"],floatingBoxIdsWithMutablePinOffsets:new Set(floatingGraph.boxes.filter(box2=>floatingGraph.pins.filter(p2=>p2.boxId===box2.boxId).filter(bp2=>!bp2.color.includes("center")).length<=2).map(b3=>b3.boxId)),corpus:{}});debug42.enabled&&global?.debugGraphics&&global.debugGraphics?.push(getGraphicsForBpcGraph(laidOutBpcGraph,{title:`laidOutBpcGraph-${group.name}`}));let groupOffset=group._getGlobalSchematicPositionBeforeLayout();for(let box2 of laidOutBpcGraph.boxes){if(!box2.center)continue;let schematic_component2=db2.schematic_component.get(box2.boxId);if(schematic_component2){let newCenter={x:box2.center.x+groupOffset.x,y:box2.center.y+groupOffset.y},ports=db2.schematic_port.list({schematic_component_id:schematic_component2.schematic_component_id}),texts=db2.schematic_text.list({schematic_component_id:schematic_component2.schematic_component_id}),positionDelta={x:newCenter.x-schematic_component2.center.x,y:newCenter.y-schematic_component2.center.y};for(let port of ports)port.center.x+=positionDelta.x,port.center.y+=positionDelta.y;for(let text of texts)text.position.x+=positionDelta.x,text.position.y+=positionDelta.y;updateSchematicPrimitivesForLayoutShift({db:db2,schematicComponentId:schematic_component2.schematic_component_id,deltaX:positionDelta.x,deltaY:positionDelta.y}),schematic_component2.center=newCenter;continue}let schematic_net_label2=db2.schematic_net_label.get(box2.boxId);if(schematic_net_label2){let pin=laidOutBpcGraph.pins.find(p2=>p2.boxId===box2.boxId&&p2.color==="netlabel_center");if(!pin)throw new Error(`No pin found for net label: ${box2.boxId}`);let finalCenter={x:box2.center.x+groupOffset.x,y:box2.center.y+groupOffset.y};schematic_net_label2.center=finalCenter,schematic_net_label2.anchor_position={x:finalCenter.x+pin.offset.x,y:finalCenter.y+pin.offset.y};continue}console.error(`No schematic element found for box: ${box2.boxId}. This is a bug in the matchAdapt binding with @tscircuit/core`)}}var debug52=(0,import_debug12.default)("Group_doInitialSchematicLayoutMatchpack");function facingDirectionToSide(facingDirection){switch(facingDirection){case"up":return"y+";case"down":return"y-";case"left":return"x-";case"right":return"x+";default:return"y+"}}function rotateDirection2(direction2,degrees){let directions=["right","up","left","down"],currentIndex=directions.indexOf(direction2);if(currentIndex===-1)return direction2;let steps=Math.round(degrees/90),newIndex=(currentIndex+steps)%4;return directions[newIndex<0?newIndex+4:newIndex]}function convertTreeToInputProblem(tree,db2,group){let problem={chipMap:{},chipPinMap:{},netMap:{},pinStrongConnMap:{},netConnMap:{},chipGap:.6,decouplingCapsGap:.4,partitionGap:1.2};debug52(`[${group.name}] Processing ${tree.childNodes.length} child nodes for input problem`),tree.childNodes.forEach((child,index)=>{if(debug52(`[${group.name}] Processing child ${index}: nodeType=${child.nodeType}`),child.nodeType==="component"?debug52(`[${group.name}] - Component: ${child.sourceComponent?.name}`):child.nodeType==="group"&&debug52(`[${group.name}] - Group: ${child.sourceGroup?.name}`),child.nodeType==="component"&&child.sourceComponent){let chipId=child.sourceComponent.name||`chip_${index}`,schematicComponent=db2.schematic_component.getWhere({source_component_id:child.sourceComponent.source_component_id});if(!schematicComponent)return;let component=group.children.find(groupChild=>groupChild.source_component_id===child.sourceComponent?.source_component_id),availableRotations=[0,90,180,270];component?._parsedProps?.schOrientation&&(availableRotations=[0]),component?._parsedProps?.schRotation!==void 0&&(availableRotations=[0]),component?._parsedProps?.facingDirection&&(availableRotations=[0]),component?._parsedProps?.schFacingDirection&&(availableRotations=[0]),component?.componentName==="Chip"&&(availableRotations=[0]);let marginLeft=component?._parsedProps?.schMarginLeft??component?._parsedProps?.schMarginX??0,marginRight=component?._parsedProps?.schMarginRight??component?._parsedProps?.schMarginX??0,marginTop=component?._parsedProps?.schMarginTop??component?._parsedProps?.schMarginY??0,marginBottom=component?._parsedProps?.schMarginBottom??component?._parsedProps?.schMarginY??0;component?.config.shouldRenderAsSchematicBox&&(marginTop+=.4,marginBottom+=.4);let marginXShift=(marginRight-marginLeft)/2,marginYShift=(marginTop-marginBottom)/2;problem.chipMap[chipId]={chipId,pins:[],size:{x:(schematicComponent.size?.width||1)+marginLeft+marginRight,y:(schematicComponent.size?.height||1)+marginTop+marginBottom},availableRotations};let ports=db2.schematic_port.list({schematic_component_id:schematicComponent.schematic_component_id});for(let port of ports){let sourcePort=db2.source_port.get(port.source_port_id);if(!sourcePort)continue;let pinId=`${chipId}.${sourcePort.pin_number||sourcePort.name||port.schematic_port_id}`;problem.chipMap[chipId].pins.push(pinId);let side=facingDirectionToSide(port.facing_direction);problem.chipPinMap[pinId]={pinId,offset:{x:(port.center?.x||0)-(schematicComponent.center.x||0)+marginXShift,y:(port.center?.y||0)-(schematicComponent.center.y||0)+marginYShift},side}}}else if(child.nodeType==="group"&&child.sourceGroup){let groupId=child.sourceGroup.name||`group_${index}`;debug52(`[${group.name}] Processing nested group: ${groupId}`);let schematicGroup=db2.schematic_group?.getWhere?.({source_group_id:child.sourceGroup.source_group_id}),groupInstance=group.children.find(groupChild=>groupChild.source_group_id===child.sourceGroup?.source_group_id);if(debug52(`[${group.name}] Found schematic_group for ${groupId}:`,schematicGroup),schematicGroup){debug52(`[${group.name}] Treating group ${groupId} as composite chip`);let groupComponents=db2.schematic_component.list({schematic_group_id:schematicGroup.schematic_group_id});debug52(`[${group.name}] Group ${groupId} has ${groupComponents.length} components:`,groupComponents.map(c3=>c3.source_component_id));let minX=1/0,maxX=-1/0,minY=1/0,maxY=-1/0,hasValidBounds=!1;for(let comp of groupComponents)if(comp.center&&comp.size){hasValidBounds=!0;let halfWidth=comp.size.width/2,halfHeight=comp.size.height/2;minX=Math.min(minX,comp.center.x-halfWidth),maxX=Math.max(maxX,comp.center.x+halfWidth),minY=Math.min(minY,comp.center.y-halfHeight),maxY=Math.max(maxY,comp.center.y+halfHeight)}let marginLeft=groupInstance?._parsedProps?.schMarginLeft??groupInstance?._parsedProps?.schMarginX??0,marginRight=groupInstance?._parsedProps?.schMarginRight??groupInstance?._parsedProps?.schMarginX??0,marginTop=groupInstance?._parsedProps?.schMarginTop??groupInstance?._parsedProps?.schMarginY??0,marginBottom=groupInstance?._parsedProps?.schMarginBottom??groupInstance?._parsedProps?.schMarginY??0,marginXShift=(marginRight-marginLeft)/2,marginYShift=(marginTop-marginBottom)/2,groupWidth=(hasValidBounds?maxX-minX:2)+marginLeft+marginRight,groupHeight=(hasValidBounds?maxY-minY:2)+marginTop+marginBottom;debug52(`[${group.name}] Group ${groupId} computed size: ${groupWidth} x ${groupHeight}`);let groupPins=[];for(let comp of groupComponents){let ports=db2.schematic_port.list({schematic_component_id:comp.schematic_component_id});for(let port of ports){let sourcePort=db2.source_port.get(port.source_port_id);if(!sourcePort)continue;let pinId=`${groupId}.${sourcePort.pin_number||sourcePort.name||port.schematic_port_id}`;groupPins.push(pinId);let groupCenter=schematicGroup.center||{x:0,y:0},side=facingDirectionToSide(port.facing_direction);problem.chipPinMap[pinId]={pinId,offset:{x:(port.center?.x||0)-groupCenter.x+marginXShift,y:(port.center?.y||0)-groupCenter.y+marginYShift},side}}}debug52(`[${group.name}] Group ${groupId} has ${groupPins.length} pins:`,groupPins),problem.chipMap[groupId]={chipId:groupId,pins:groupPins,size:{x:groupWidth,y:groupHeight}},debug52(`[${group.name}] Added group ${groupId} to chipMap`)}else debug52(`[${group.name}] Warning: No schematic_group found for group ${groupId}`)}}),debug52(`[${group.name}] Creating connections using connectivity keys`);let connectivityGroups=new Map;for(let[chipId,chip]of Object.entries(problem.chipMap))for(let pinId of chip.pins){let pinNumber=pinId.split(".").pop(),treeNode=tree.childNodes.find(child=>child.nodeType==="component"&&child.sourceComponent?child.sourceComponent.name===chipId:child.nodeType==="group"&&child.sourceGroup?`group_${tree.childNodes.indexOf(child)}`===chipId:!1);if(treeNode?.nodeType==="group"&&treeNode.sourceGroup){let schematicGroup=db2.schematic_group?.getWhere?.({source_group_id:treeNode.sourceGroup.source_group_id});if(schematicGroup){let groupComponents=db2.schematic_component.list({schematic_group_id:schematicGroup.schematic_group_id});for(let comp of groupComponents){let sourcePorts=db2.source_port.list({source_component_id:comp.source_component_id});for(let sourcePort of sourcePorts){let portNumber=sourcePort.pin_number||sourcePort.name;if(String(portNumber)===String(pinNumber))if(sourcePort.subcircuit_connectivity_map_key){let connectivityKey=sourcePort.subcircuit_connectivity_map_key;connectivityGroups.has(connectivityKey)||connectivityGroups.set(connectivityKey,[]),connectivityGroups.get(connectivityKey).push(pinId),debug52(`[${group.name}] \u2713 Pin ${pinId} has connectivity key: ${connectivityKey}`)}else debug52(`[${group.name}] Pin ${pinId} has no connectivity key`)}}}}else if(treeNode?.nodeType==="component"&&treeNode.sourceComponent){let sourcePorts=db2.source_port.list({source_component_id:treeNode.sourceComponent.source_component_id});for(let sourcePort of sourcePorts){let portNumber=sourcePort.pin_number||sourcePort.name;if(String(portNumber)===String(pinNumber)&&sourcePort.subcircuit_connectivity_map_key){let connectivityKey=sourcePort.subcircuit_connectivity_map_key;connectivityGroups.has(connectivityKey)||connectivityGroups.set(connectivityKey,[]),connectivityGroups.get(connectivityKey).push(pinId),debug52(`[${group.name}] Pin ${pinId} has connectivity key: ${connectivityKey}`)}}}}debug52(`[${group.name}] Found ${connectivityGroups.size} connectivity groups:`,Array.from(connectivityGroups.entries()).map(([key,pins])=>({key,pins})));for(let[connectivityKey,pins]of connectivityGroups)if(pins.length>=2){let tracesWithThisKey=db2.source_trace.list().filter(trace=>trace.subcircuit_connectivity_map_key===connectivityKey),hasNetConnections=tracesWithThisKey.some(trace=>trace.connected_source_net_ids&&trace.connected_source_net_ids.length>0),hasDirectConnections=tracesWithThisKey.some(trace=>trace.connected_source_port_ids&&trace.connected_source_port_ids.length>=2);if(debug52(`[${group.name}] Connectivity ${connectivityKey}: hasNetConnections=${hasNetConnections}, hasDirectConnections=${hasDirectConnections}`),hasDirectConnections){for(let trace of tracesWithThisKey)if(trace.connected_source_port_ids&&trace.connected_source_port_ids.length>=2){let directlyConnectedPins=[];for(let portId of trace.connected_source_port_ids)for(let pinId of pins){let pinNumber=pinId.split(".").pop(),sourcePort=db2.source_port.get(portId);if(sourcePort&&String(sourcePort.pin_number||sourcePort.name)===String(pinNumber)){let chipId=pinId.split(".")[0],treeNode=tree.childNodes.find(child=>child.nodeType==="component"&&child.sourceComponent?child.sourceComponent.name===chipId:child.nodeType==="group"&&child.sourceGroup?`group_${tree.childNodes.indexOf(child)}`===chipId:!1);treeNode?.nodeType==="component"&&treeNode.sourceComponent&&db2.source_port.list({source_component_id:treeNode.sourceComponent.source_component_id}).some(p2=>p2.source_port_id===portId)&&directlyConnectedPins.push(pinId)}}for(let i3=0;i3<directlyConnectedPins.length;i3++)for(let j3=i3+1;j3<directlyConnectedPins.length;j3++){let pin1=directlyConnectedPins[i3],pin2=directlyConnectedPins[j3];problem.pinStrongConnMap[`${pin1}-${pin2}`]=!0,problem.pinStrongConnMap[`${pin2}-${pin1}`]=!0,debug52(`[${group.name}] Created strong connection: ${pin1} <-> ${pin2}`)}}}if(hasNetConnections){let source_net2=db2.source_net.getWhere({subcircuit_connectivity_map_key:connectivityKey}),isGround=source_net2?.is_ground??!1,isPositiveVoltageSource=source_net2?.is_power??!1;problem.netMap[connectivityKey]={netId:connectivityKey,isGround,isPositiveVoltageSource};for(let pinId of pins)problem.netConnMap[`${pinId}-${connectivityKey}`]=!0;debug52(`[${group.name}] Created net ${connectivityKey} with ${pins.length} pins:`,pins)}}return problem}function Group_doInitialSchematicLayoutMatchPack(group){let{db:db2}=group.root,tree=getCircuitJsonTree(db2.toArray(),{source_group_id:group.source_group_id});if(debug52(`[${group.name}] Starting matchpack layout with ${tree.childNodes.length} children`),debug52(`[${group.name}] Tree structure:`,JSON.stringify(tree,null,2)),tree.childNodes.length<=1){debug52(`[${group.name}] Only ${tree.childNodes.length} children, skipping layout`);return}debug52("Converting circuit tree to InputProblem...");let inputProblem=convertTreeToInputProblem(tree,db2,group);debug52.enabled&&group.root?.emit("debug:logOutput",{type:"debug:logOutput",name:`matchpack-input-problem-${group.name}`,content:JSON.stringify(inputProblem,null,2)});let solver=new LayoutPipelineSolver(inputProblem);if(debug52("Starting LayoutPipelineSolver..."),debug52.enabled&&global?.debugGraphics){let initialViz=solver.visualize();global.debugGraphics.push({...initialViz,title:`matchpack-initial-${group.name}`})}if(solver.solve(),debug52(`Solver completed in ${solver.iterations} iterations`),debug52(`Solved: ${solver.solved}, Failed: ${solver.failed}`),solver.failed)throw debug52(`Solver failed with error: ${solver.error}`),new Error(`Matchpack layout solver failed: ${solver.error}`);let outputLayout=solver.getOutputLayout();if(debug52("OutputLayout:",JSON.stringify(outputLayout,null,2)),debug52("Solver completed successfully:",!solver.failed),debug52.enabled&&global?.debugGraphics){let finalViz=solver.visualize();global.debugGraphics.push({...finalViz,title:`matchpack-final-${group.name}`})}let overlaps=solver.checkForOverlaps(outputLayout);if(overlaps.length>0){debug52(`Warning: Found ${overlaps.length} overlapping components:`);for(let overlap of overlaps)debug52(` ${overlap.chip1} overlaps ${overlap.chip2} (area: ${overlap.overlapArea})`)}let groupOffset=group._getGlobalSchematicPositionBeforeLayout();debug52(`Group offset: x=${groupOffset.x}, y=${groupOffset.y}`),debug52(`Applying layout results for ${Object.keys(outputLayout.chipPlacements).length} chip placements`);for(let[chipId,placement]of Object.entries(outputLayout.chipPlacements)){debug52(`Processing placement for chip: ${chipId} at (${placement.x}, ${placement.y})`);let treeNode=tree.childNodes.find(child=>{if(child.nodeType==="component"&&child.sourceComponent){let matches=child.sourceComponent.name===chipId;return debug52(` Checking component ${child.sourceComponent.name}: matches=${matches}`),matches}if(child.nodeType==="group"&&child.sourceGroup){let groupName=child.sourceGroup.name,expectedChipId=`group_${tree.childNodes.indexOf(child)}`,matches=expectedChipId===chipId;return debug52(` Checking group ${groupName} (expected chipId: ${expectedChipId}): matches=${matches}`),matches}return!1});if(!treeNode){debug52(`Warning: No tree node found for chip: ${chipId}`),debug52("Available tree nodes:",tree.childNodes.map((child,idx)=>({type:child.nodeType,name:child.nodeType==="component"?child.sourceComponent?.name:child.sourceGroup?.name,expectedChipId:child.nodeType==="group"?`group_${idx}`:child.sourceComponent?.name})));continue}let newCenter={x:placement.x+groupOffset.x,y:placement.y+groupOffset.y};if(treeNode.nodeType==="component"&&treeNode.sourceComponent){let schematicComponent=db2.schematic_component.getWhere({source_component_id:treeNode.sourceComponent.source_component_id});if(schematicComponent){debug52(`Moving component ${chipId} to (${newCenter.x}, ${newCenter.y})`);let ports=db2.schematic_port.list({schematic_component_id:schematicComponent.schematic_component_id}),texts=db2.schematic_text.list({schematic_component_id:schematicComponent.schematic_component_id}),positionDelta={x:newCenter.x-schematicComponent.center.x,y:newCenter.y-schematicComponent.center.y};for(let port of ports)port.center.x+=positionDelta.x,port.center.y+=positionDelta.y;for(let text of texts)text.position.x+=positionDelta.x,text.position.y+=positionDelta.y;if(updateSchematicPrimitivesForLayoutShift({db:db2,schematicComponentId:schematicComponent.schematic_component_id,deltaX:positionDelta.x,deltaY:positionDelta.y}),schematicComponent.center=newCenter,placement.ccwRotationDegrees!==0){debug52(`Component ${chipId} has rotation: ${placement.ccwRotationDegrees}\xB0`);let angleRad=placement.ccwRotationDegrees*Math.PI/180,cos4=Math.cos(angleRad),sin4=Math.sin(angleRad);for(let port of ports){let dx2=port.center.x-newCenter.x,dy2=port.center.y-newCenter.y,rotatedDx=dx2*cos4-dy2*sin4,rotatedDy=dx2*sin4+dy2*cos4;port.center.x=newCenter.x+rotatedDx,port.center.y=newCenter.y+rotatedDy;let originalDirection=port.facing_direction||"right";port.facing_direction=rotateDirection2(originalDirection,placement.ccwRotationDegrees),port.side_of_component=(port.facing_direction==="up"?"top":port.facing_direction==="down"?"bottom":port.facing_direction)||port.side_of_component}for(let text of texts){let dx2=text.position.x-newCenter.x,dy2=text.position.y-newCenter.y,rotatedDx=dx2*cos4-dy2*sin4,rotatedDy=dx2*sin4+dy2*cos4;text.position.x=newCenter.x+rotatedDx,text.position.y=newCenter.y+rotatedDy}if(schematicComponent.symbol_name){let schematicSymbolDirection=schematicComponent.symbol_name.match(/_(right|left|up|down)$/);schematicSymbolDirection&&(schematicComponent.symbol_name=schematicComponent.symbol_name.replace(schematicSymbolDirection[0],`_${rotateDirection2(schematicSymbolDirection[1],placement.ccwRotationDegrees)}`))}}}}else if(treeNode.nodeType==="group"&&treeNode.sourceGroup){let schematicGroup=db2.schematic_group?.getWhere?.({source_group_id:treeNode.sourceGroup.source_group_id});if(schematicGroup){debug52(`Moving group ${chipId} to (${newCenter.x}, ${newCenter.y}) from (${schematicGroup.center?.x}, ${schematicGroup.center?.y})`);let groupComponents=db2.schematic_component.list({schematic_group_id:schematicGroup.schematic_group_id});debug52(`Group ${chipId} has ${groupComponents.length} components to move`);let oldCenter=schematicGroup.center||{x:0,y:0},positionDelta={x:newCenter.x-oldCenter.x,y:newCenter.y-oldCenter.y};debug52(`Position delta for group ${chipId}: (${positionDelta.x}, ${positionDelta.y})`);for(let component of groupComponents)if(component.center){let oldComponentCenter={...component.center};component.center.x+=positionDelta.x,component.center.y+=positionDelta.y,debug52(`Moved component ${component.source_component_id} from (${oldComponentCenter.x}, ${oldComponentCenter.y}) to (${component.center.x}, ${component.center.y})`);let ports=db2.schematic_port.list({schematic_component_id:component.schematic_component_id}),texts=db2.schematic_text.list({schematic_component_id:component.schematic_component_id});for(let port of ports)port.center&&(port.center.x+=positionDelta.x,port.center.y+=positionDelta.y);for(let text of texts)text.position&&(text.position.x+=positionDelta.x,text.position.y+=positionDelta.y)}schematicGroup.center=newCenter,debug52(`Updated group ${chipId} center to (${newCenter.x}, ${newCenter.y})`)}}}debug52("Matchpack layout completed successfully")}function Group_doInitialSourceAddConnectivityMapKey(group){if(!group.isSubcircuit)return;let{db:db2}=group.root,traces=group.selectAll("trace"),vias=group.selectAll("via"),nets=group.selectAll("net"),connMap=new ConnectivityMap({});connMap.addConnections(traces.map(t5=>{let source_trace2=db2.source_trace.get(t5.source_trace_id);return source_trace2?[source_trace2.source_trace_id,...source_trace2.connected_source_port_ids,...source_trace2.connected_source_net_ids]:null}).filter(c3=>c3!==null));let sourceNets=db2.source_net.list().filter(net=>net.subcircuit_id===group.subcircuit_id);for(let sourceNet of sourceNets)connMap.addConnections([[sourceNet.source_net_id]]);let{name:subcircuitName}=group._parsedProps;for(let trace of traces){if(!trace.source_trace_id)continue;let connNetId=connMap.getNetConnectedToId(trace.source_trace_id);connNetId&&(trace.subcircuit_connectivity_map_key=`${subcircuitName??`unnamedsubcircuit${group._renderId}`}_${connNetId}`,db2.source_trace.update(trace.source_trace_id,{subcircuit_connectivity_map_key:trace.subcircuit_connectivity_map_key}))}let allSourcePortIds=new Set;for(let trace of traces){if(!trace.source_trace_id)continue;let source_trace2=db2.source_trace.get(trace.source_trace_id);if(source_trace2)for(let id2 of source_trace2.connected_source_port_ids)allSourcePortIds.add(id2)}for(let portId of allSourcePortIds){let connNetId=connMap.getNetConnectedToId(portId);if(!connNetId)continue;let connectivityMapKey=`${subcircuitName??`unnamedsubcircuit${group._renderId}`}_${connNetId}`;db2.source_port.update(portId,{subcircuit_connectivity_map_key:connectivityMapKey})}let allSourceNetIds=new Set;for(let trace of traces){if(!trace.source_trace_id)continue;let source_trace2=db2.source_trace.get(trace.source_trace_id);if(source_trace2)for(let source_net_id of source_trace2.connected_source_net_ids)allSourceNetIds.add(source_net_id)}for(let sourceNet of sourceNets)allSourceNetIds.add(sourceNet.source_net_id);for(let netId of allSourceNetIds){let connNetId=connMap.getNetConnectedToId(netId);if(!connNetId)continue;let connectivityMapKey=`${subcircuitName??`unnamedsubcircuit${group._renderId}`}_${connNetId}`;db2.source_net.update(netId,{subcircuit_connectivity_map_key:connectivityMapKey});let netInstance=nets.find(n3=>n3.source_net_id===netId);netInstance&&(netInstance.subcircuit_connectivity_map_key=connectivityMapKey)}for(let via of vias){let connectedNetOrTrace=via._getConnectedNetOrTrace();connectedNetOrTrace&&connectedNetOrTrace.subcircuit_connectivity_map_key&&(via.subcircuit_connectivity_map_key=connectedNetOrTrace.subcircuit_connectivity_map_key)}}function Group_doInitialSchematicLayoutGrid(group){let{db:db2}=group.root,props=group._parsedProps,schematicChildren=group.children.filter(child=>{let isExplicitlyPositioned=child._parsedProps?.schX!==void 0||child._parsedProps?.schY!==void 0;return child.schematic_component_id&&!isExplicitlyPositioned});if(schematicChildren.length===0)return;let maxCellWidth=0,maxCellHeight=0;for(let child of schematicChildren){let schComp=db2.schematic_component.get(child.schematic_component_id);schComp?.size&&(maxCellWidth=Math.max(maxCellWidth,schComp.size.width),maxCellHeight=Math.max(maxCellHeight,schComp.size.height))}maxCellWidth===0&&schematicChildren.length>0&&(maxCellWidth=1),maxCellHeight===0&&schematicChildren.length>0&&(maxCellHeight=1);let gridColsOption=props.gridCols,gridRowsOption,gridGapOption=props.gridGap,gridRowGapOption=props.gridRowGap,gridColumnGapOption=props.gridColumnGap;props.schLayout?.grid&&(gridColsOption=props.schLayout.grid.cols??gridColsOption,gridRowsOption=props.schLayout.grid.rows,gridGapOption=props.schLayout.gridGap??gridGapOption,gridRowGapOption=props.schLayout.gridRowGap??gridRowGapOption,gridColumnGapOption=props.schLayout.gridColumnGap??gridColumnGapOption);let numCols,numRows;gridColsOption!==void 0&&gridRowsOption!==void 0?(numCols=gridColsOption,numRows=gridRowsOption):gridColsOption!==void 0?(numCols=gridColsOption,numRows=Math.ceil(schematicChildren.length/numCols)):gridRowsOption!==void 0?(numRows=gridRowsOption,numCols=Math.ceil(schematicChildren.length/numRows)):(numCols=Math.ceil(Math.sqrt(schematicChildren.length)),numRows=Math.ceil(schematicChildren.length/numCols)),numCols===0&&schematicChildren.length>0&&(numCols=1),numRows===0&&schematicChildren.length>0&&(numRows=schematicChildren.length);let gridGapX,gridGapY,parseGap=val=>{if(val!==void 0)return typeof val=="number"?val:length.parse(val)};if(gridRowGapOption!==void 0||gridColumnGapOption!==void 0){let fallbackX=typeof gridGapOption=="object"&&gridGapOption!==null?gridGapOption.x:gridGapOption,fallbackY=typeof gridGapOption=="object"&&gridGapOption!==null?gridGapOption.y:gridGapOption;gridGapX=parseGap(gridColumnGapOption??fallbackX)??1,gridGapY=parseGap(gridRowGapOption??fallbackY)??1}else if(typeof gridGapOption=="number")gridGapX=gridGapOption,gridGapY=gridGapOption;else if(typeof gridGapOption=="string"){let parsed=length.parse(gridGapOption);gridGapX=parsed,gridGapY=parsed}else if(typeof gridGapOption=="object"&&gridGapOption!==null){let xRaw=gridGapOption.x,yRaw=gridGapOption.y;gridGapX=typeof xRaw=="number"?xRaw:length.parse(xRaw??"0mm"),gridGapY=typeof yRaw=="number"?yRaw:length.parse(yRaw??"0mm")}else gridGapX=1,gridGapY=1;let totalGridWidth=numCols*maxCellWidth+Math.max(0,numCols-1)*gridGapX,totalGridHeight=numRows*maxCellHeight+Math.max(0,numRows-1)*gridGapY,groupCenter=group._getGlobalSchematicPositionBeforeLayout(),firstCellCenterX=groupCenter.x-totalGridWidth/2+maxCellWidth/2,firstCellCenterY=groupCenter.y+totalGridHeight/2-maxCellHeight/2;for(let i3=0;i3<schematicChildren.length;i3++){let child=schematicChildren[i3];if(!child.schematic_component_id)continue;let row=Math.floor(i3/numCols),col=i3%numCols;if(row>=numRows||col>=numCols){console.warn(`Schematic grid layout: Child ${child.getString()} at index ${i3} (row ${row}, col ${col}) exceeds specified grid dimensions (${numRows}x${numCols}). Skipping placement.`);continue}let targetCellCenterX=firstCellCenterX+col*(maxCellWidth+gridGapX),targetCellCenterY=firstCellCenterY-row*(maxCellHeight+gridGapY),schComp=db2.schematic_component.get(child.schematic_component_id);if(schComp){let oldChildCenter=schComp.center,newChildCenter={x:targetCellCenterX,y:targetCellCenterY};db2.schematic_component.update(child.schematic_component_id,{center:newChildCenter});let deltaX=newChildCenter.x-oldChildCenter.x,deltaY=newChildCenter.y-oldChildCenter.y,schPorts=db2.schematic_port.list({schematic_component_id:child.schematic_component_id});for(let port of schPorts)db2.schematic_port.update(port.schematic_port_id,{center:{x:port.center.x+deltaX,y:port.center.y+deltaY}});let schTexts=db2.schematic_text.list({schematic_component_id:child.schematic_component_id});for(let text of schTexts)db2.schematic_text.update(text.schematic_text_id,{position:{x:text.position.x+deltaX,y:text.position.y+deltaY}});updateSchematicPrimitivesForLayoutShift({db:db2,schematicComponentId:child.schematic_component_id,deltaX,deltaY})}}group.schematic_group_id&&db2.schematic_group.update(group.schematic_group_id,{width:totalGridWidth,height:totalGridHeight,center:groupCenter})}var getSizeOfTreeNodeChild=(db2,child)=>{let{sourceComponent,sourceGroup}=child;if(child.nodeType==="component"){let schComponent=db2.schematic_component.getWhere({source_component_id:sourceComponent?.source_component_id});return schComponent?.size?{width:schComponent.size.width,height:schComponent.size.height}:null}if(child.nodeType==="group"){let schGroup=db2.schematic_group.getWhere({source_group_id:sourceGroup?.source_group_id});if(schGroup?.width&&schGroup?.height)return{width:schGroup.width,height:schGroup.height};let groupComponents=db2.schematic_component.list({schematic_group_id:schGroup?.schematic_group_id}),minX=1/0,maxX=-1/0,minY=1/0,maxY=-1/0;for(let comp of groupComponents)if(comp.center&&comp.size){let halfWidth=comp.size.width/2,halfHeight=comp.size.height/2;minX=Math.min(minX,comp.center.x-halfWidth),maxX=Math.max(maxX,comp.center.x+halfWidth),minY=Math.min(minY,comp.center.y-halfHeight),maxY=Math.max(maxY,comp.center.y+halfHeight)}let groupWidth=maxX-minX,groupHeight=maxY-minY;return{width:groupWidth,height:groupHeight}}return null},Group_doInitialSchematicLayoutFlex=group=>{let{db:db2}=group.root,props=group._parsedProps,tree=getCircuitJsonTree(db2.toArray(),{source_group_id:group.source_group_id}),rawJustify=props.schJustifyContent??props.justifyContent,rawAlign=props.schAlignItems??props.alignItems,rawGap=props.schFlexGap??props.schGap??props.gap,direction2=props.schFlexDirection??"row",justifyContent={start:"flex-start",end:"flex-end","flex-start":"flex-start","flex-end":"flex-end",stretch:"space-between","space-between":"space-between","space-around":"space-around","space-evenly":"space-evenly",center:"center"}[rawJustify??"space-between"],alignItems={start:"flex-start",end:"flex-end","flex-start":"flex-start","flex-end":"flex-end",stretch:"stretch",center:"center"}[rawAlign??"center"];if(!justifyContent)throw new Error(`Invalid justifyContent value: "${rawJustify}"`);if(!alignItems)throw new Error(`Invalid alignItems value: "${rawAlign}"`);let rowGap=0,columnGap=0;typeof rawGap=="object"?(rowGap=rawGap.y??0,columnGap=rawGap.x??0):typeof rawGap=="number"?(rowGap=rawGap,columnGap=rawGap):typeof rawGap=="string"&&(rowGap=length.parse(rawGap),columnGap=length.parse(rawGap));let minFlexContainer,width=props.width??props.schWidth??void 0,height=props.height??props.schHeight??void 0;(width===void 0||height===void 0)&&(minFlexContainer=getMinimumFlexContainer(tree.childNodes.map(child=>getSizeOfTreeNodeChild(db2,child)).filter(size2=>size2!==null),{alignItems,justifyContent,direction:direction2,rowGap,columnGap}),width=minFlexContainer.width,height=minFlexContainer.height);let flexBox=new RootFlexBox(width,height,{alignItems,justifyContent,direction:direction2,rowGap,columnGap});for(let child of tree.childNodes){let size2=getSizeOfTreeNodeChild(db2,child);flexBox.addChild({metadata:child,width:size2?.width??0,height:size2?.height??0,flexBasis:size2?direction2==="row"?size2.width:size2.height:void 0})}flexBox.build();let bounds={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,width:0,height:0};for(let child of flexBox.children)bounds.minX=Math.min(bounds.minX,child.position.x),bounds.minY=Math.min(bounds.minY,child.position.y),bounds.maxX=Math.max(bounds.maxX,child.position.x+child.size.width),bounds.maxY=Math.max(bounds.maxY,child.position.y+child.size.height);bounds.width=bounds.maxX-bounds.minX,bounds.height=bounds.maxY-bounds.minY;let offset={x:-(bounds.maxX+bounds.minX)/2,y:-(bounds.maxY+bounds.minY)/2},allCircuitJson=db2.toArray();for(let child of flexBox.children){let{sourceComponent,sourceGroup}=child.metadata;if(sourceComponent){let schComponent=db2.schematic_component.getWhere({source_component_id:sourceComponent.source_component_id});if(!schComponent)continue;repositionSchematicComponentTo(allCircuitJson,schComponent.schematic_component_id,{x:child.position.x+child.size.width/2+offset.x,y:child.position.y+child.size.height/2+offset.y})}if(sourceGroup){if(!db2.schematic_group.getWhere({source_group_id:sourceGroup.source_group_id}))continue;repositionSchematicGroupTo(allCircuitJson,sourceGroup.source_group_id,{x:child.position.x+child.size.width/2+offset.x,y:child.position.y+child.size.height/2+offset.y})}}group.schematic_group_id&&db2.schematic_group.update(group.schematic_group_id,{width:bounds.width,height:bounds.height})},MIN_GAP=1;function Group_doInitialPcbLayoutGrid(group){let{db:db2}=group.root,props=group._parsedProps,pcbChildren=getPcbChildren(group);if(pcbChildren.length===0)return;let childDimensions=calculateChildDimensions({db:db2,pcbChildren}),gridConfig=parseGridConfiguration(props),gridLayout=createGridLayout({props,pcbChildren,childDimensions,gridConfig}),cssGrid=createCssGrid({pcbChildren,childDimensions,gridLayout,gridConfig}),{itemCoordinates}=cssGrid.layout();positionChildren({db:db2,group,pcbChildren,itemCoordinates,gridLayout}),updateGroupDimensions({db:db2,group,props,gridLayout})}function getPcbChildren(group){return group.children.filter(child=>child.pcb_component_id||child.pcb_group_id)}function calculateChildDimensions(params){let{db:db2,pcbChildren}=params,maxWidth=0,maxHeight=0;for(let child of pcbChildren){let width=0,height=0;if(child.pcb_group_id){let pcbGroup=db2.pcb_group.get(child.pcb_group_id);width=pcbGroup?.width??0,height=pcbGroup?.height??0}else if(child.pcb_component_id){let pcbComp=db2.pcb_component.get(child.pcb_component_id);width=pcbComp?.width??0,height=pcbComp?.height??0}maxWidth=Math.max(maxWidth,width),maxHeight=Math.max(maxHeight,height)}return{width:maxWidth,height:maxHeight}}function parseGridConfiguration(props){let cols=props.pcbGridCols??props.gridCols??props.pcbLayout?.grid?.cols,rows=props.pcbGridRows??props.pcbLayout?.grid?.rows,templateColumns=props.pcbGridTemplateColumns,templateRows=props.pcbGridTemplateRows,parseGap=gapValue=>gapValue===void 0?MIN_GAP:typeof gapValue=="number"?gapValue:length.parse(gapValue),gridGapOption=props.pcbGridGap??props.gridGap??props.pcbLayout?.gridGap,rowGapOption=props.pcbGridRowGap??props.gridRowGap??props.pcbLayout?.gridRowGap,colGapOption=props.pcbGridColumnGap??props.gridColumnGap??props.pcbLayout?.gridColumnGap,gapX=MIN_GAP,gapY=MIN_GAP;if(rowGapOption!==void 0||colGapOption!==void 0){let fallbackX=typeof gridGapOption=="object"?gridGapOption?.x:gridGapOption,fallbackY=typeof gridGapOption=="object"?gridGapOption?.y:gridGapOption;gapX=parseGap(colGapOption??fallbackX),gapY=parseGap(rowGapOption??fallbackY)}else if(typeof gridGapOption=="object"&&gridGapOption!==null)gapX=parseGap(gridGapOption.x),gapY=parseGap(gridGapOption.y);else{let gap=parseGap(gridGapOption);gapX=gap,gapY=gap}return{cols,rows,gapX,gapY,templateColumns,templateRows}}function createGridLayout(params){let{props,pcbChildren,childDimensions,gridConfig}=params;return props.pcbGridTemplateColumns||props.pcbGridTemplateRows?createTemplateBasedLayout({props,gridConfig,pcbChildren,childDimensions}):createDefaultLayout({gridConfig,pcbChildren,childDimensions})}function createTemplateBasedLayout(params){let{props,gridConfig,pcbChildren,childDimensions}=params,gridTemplateColumns=props.pcbGridTemplateColumns??"",gridTemplateRows=props.pcbGridTemplateRows??"",extractRepeatCount=template=>{let match2=template.match(/repeat\((\d+),/);return match2?parseInt(match2[1]):Math.ceil(Math.sqrt(pcbChildren.length))},numCols=props.pcbGridTemplateColumns?extractRepeatCount(gridTemplateColumns):Math.ceil(Math.sqrt(pcbChildren.length)),numRows=props.pcbGridTemplateRows?extractRepeatCount(gridTemplateRows):Math.ceil(pcbChildren.length/numCols),containerWidth=numCols*childDimensions.width+Math.max(0,numCols-1)*gridConfig.gapX,containerHeight=numRows*childDimensions.height+Math.max(0,numRows-1)*gridConfig.gapY;return{gridTemplateColumns,gridTemplateRows,containerWidth,containerHeight}}function createDefaultLayout(params){let{gridConfig,pcbChildren,childDimensions}=params,numCols,numRows;gridConfig.cols!==void 0&&gridConfig.rows!==void 0?(numCols=gridConfig.cols,numRows=gridConfig.rows):gridConfig.cols!==void 0?(numCols=gridConfig.cols,numRows=Math.ceil(pcbChildren.length/numCols)):gridConfig.rows!==void 0?(numRows=gridConfig.rows,numCols=Math.ceil(pcbChildren.length/numRows)):(numCols=Math.ceil(Math.sqrt(pcbChildren.length)),numRows=Math.ceil(pcbChildren.length/numCols)),numCols=Math.max(1,numCols),numRows=Math.max(1,numRows);let containerWidth=numCols*childDimensions.width+Math.max(0,numCols-1)*gridConfig.gapX,containerHeight=numRows*childDimensions.height+Math.max(0,numRows-1)*gridConfig.gapY,gridTemplateColumns=`repeat(${numCols}, ${childDimensions.width}px)`,gridTemplateRows=`repeat(${numRows}, ${childDimensions.height}px)`;return{gridTemplateColumns,gridTemplateRows,containerWidth,containerHeight}}function createCssGrid(params){let{pcbChildren,childDimensions,gridLayout,gridConfig}=params,gridChildren=pcbChildren.map((child,index)=>({key:child.getString()||`child-${index}`,contentWidth:childDimensions.width,contentHeight:childDimensions.height}));return new CssGrid({containerWidth:gridLayout.containerWidth,containerHeight:gridLayout.containerHeight,gridTemplateColumns:gridLayout.gridTemplateColumns,gridTemplateRows:gridLayout.gridTemplateRows,gap:[gridConfig.gapY,gridConfig.gapX],children:gridChildren})}function positionChildren(params){let{db:db2,group,pcbChildren,itemCoordinates,gridLayout}=params,groupCenter=group._getGlobalPcbPositionBeforeLayout(),allCircuitJson=db2.toArray();for(let i3=0;i3<pcbChildren.length;i3++){let child=pcbChildren[i3],childKey=child.getString()||`child-${i3}`,coordinates=itemCoordinates[childKey];if(!coordinates){console.warn(`PCB grid layout: No coordinates found for child ${childKey}`);continue}let targetX=groupCenter.x-gridLayout.containerWidth/2+coordinates.x+coordinates.width/2,targetY=groupCenter.y+gridLayout.containerHeight/2-coordinates.y-coordinates.height/2;if(child.pcb_component_id)repositionPcbComponentTo(allCircuitJson,child.pcb_component_id,{x:targetX,y:targetY});else{let groupChild=child;groupChild.pcb_group_id&&groupChild.source_group_id&&repositionPcbGroupTo(allCircuitJson,groupChild.source_group_id,{x:targetX,y:targetY})}}}function updateGroupDimensions(params){let{db:db2,group,props,gridLayout}=params;if(group.pcb_group_id){let groupCenter=group._getGlobalPcbPositionBeforeLayout();db2.pcb_group.update(group.pcb_group_id,{width:props.width??gridLayout.containerWidth,height:props.height??gridLayout.containerHeight,center:groupCenter})}}function getPresetAutoroutingConfig(autorouterConfig2){let defaults={serverUrl:"https://registry-api.tscircuit.com",serverMode:"job",serverCacheEnabled:!0};if(typeof autorouterConfig2=="object"&&!autorouterConfig2.preset)return{local:!(autorouterConfig2.serverUrl||autorouterConfig2.serverMode||autorouterConfig2.serverCacheEnabled),...defaults,...autorouterConfig2};let preset=typeof autorouterConfig2=="object"?autorouterConfig2.preset:autorouterConfig2,providedConfig=typeof autorouterConfig2=="object"?autorouterConfig2:{};switch(typeof preset=="string"?preset.replace(/_/g,"-"):preset){case"auto-local":return{local:!0,groupMode:"subcircuit"};case"sequential-trace":return{local:!0,groupMode:"sequential-trace"};case"subcircuit":return{local:!0,groupMode:"subcircuit"};case"auto-cloud":{let{preset:_preset,local:_local,groupMode:_groupMode,...rest}=providedConfig;return{local:!1,groupMode:"subcircuit",...defaults,...rest}}case"laser-prefab":{let{preset:_preset,local:_local,groupMode:_groupMode,...rest}=providedConfig;return{local:!0,groupMode:"subcircuit",preset:"laser_prefab",...rest}}case"auto-jumper":{let{preset:_preset,local:_local,groupMode:_groupMode,...rest}=providedConfig;return{local:!0,groupMode:"subcircuit",preset:"auto_jumper",...rest}}default:return{local:!0,groupMode:"subcircuit"}}}var applyComponentConstraintClusters=(group,packInput)=>{let constraints=group.children.filter(c3=>c3.componentName==="Constraint"&&c3._parsedProps.pcb),clusterByRoot=new Map,parent={},find2=x3=>(parent[x3]!==x3&&(parent[x3]=find2(parent[x3])),parent[x3]),union2=(a2,b3)=>{let ra3=find2(a2),rb2=find2(b3);ra3!==rb2&&(parent[rb2]=ra3)},makeSet=x3=>{x3 in parent||(parent[x3]=x3)},getIdFromSelector=sel2=>{let name=sel2.startsWith(".")?sel2.slice(1):sel2;return group.children.find(c3=>c3.name===name)?.pcb_component_id??void 0};for(let constraint of constraints){let props=constraint._parsedProps;if("left"in props&&"right"in props){let a2=getIdFromSelector(props.left),b3=getIdFromSelector(props.right);a2&&b3&&(makeSet(a2),makeSet(b3),union2(a2,b3))}else if("top"in props&&"bottom"in props){let a2=getIdFromSelector(props.top),b3=getIdFromSelector(props.bottom);a2&&b3&&(makeSet(a2),makeSet(b3),union2(a2,b3))}else if("for"in props&&Array.isArray(props.for)){let ids=props.for.map(s3=>getIdFromSelector(s3)).filter(s3=>!!s3);for(let id2 of ids)makeSet(id2);for(let i3=1;i3<ids.length;i3++)union2(ids[0],ids[i3])}}for(let id2 of Object.keys(parent)){let rootId=find2(id2);clusterByRoot.has(rootId)||clusterByRoot.set(rootId,{componentIds:[],constraints:[]}),clusterByRoot.get(rootId).componentIds.push(id2)}for(let constraint of constraints){let props=constraint._parsedProps,compId;if("left"in props?compId=getIdFromSelector(props.left):"top"in props?compId=getIdFromSelector(props.top):"for"in props&&(compId=getIdFromSelector(props.for[0])),!compId)continue;let root=find2(compId);clusterByRoot.get(root)?.constraints.push(constraint)}let clusterMap={},packCompById=Object.fromEntries(packInput.components.map(c3=>[c3.componentId,c3]));for(let[rootId,info]of clusterByRoot.entries()){if(info.componentIds.length<=1)continue;let solver=new Solver,kVars={},getVar=(id2,axis)=>{let key=`${id2}_${axis}`;return kVars[key]||(kVars[key]=new Variable(key)),kVars[key]},anchor=info.componentIds[0];solver.addConstraint(new Constraint(getVar(anchor,"x"),Operator.Eq,0,Strength.required)),solver.addConstraint(new Constraint(getVar(anchor,"y"),Operator.Eq,0,Strength.required));for(let constraint of info.constraints){let props=constraint._parsedProps;if("xDist"in props){let left=getIdFromSelector(props.left),right=getIdFromSelector(props.right);left&&right&&solver.addConstraint(new Constraint(new Expression(getVar(right,"x"),[-1,getVar(left,"x")]),Operator.Eq,props.xDist,Strength.required))}else if("yDist"in props){let top=getIdFromSelector(props.top),bottom=getIdFromSelector(props.bottom);top&&bottom&&solver.addConstraint(new Constraint(new Expression(getVar(top,"y"),[-1,getVar(bottom,"y")]),Operator.Eq,props.yDist,Strength.required))}else if("sameX"in props&&Array.isArray(props.for)){let ids=props.for.map(s3=>getIdFromSelector(s3)).filter(s3=>!!s3);if(ids.length>1){let base=getVar(ids[0],"x");for(let i3=1;i3<ids.length;i3++)solver.addConstraint(new Constraint(new Expression(getVar(ids[i3],"x"),[-1,base]),Operator.Eq,0,Strength.required))}}else if("sameY"in props&&Array.isArray(props.for)){let ids=props.for.map(s3=>getIdFromSelector(s3)).filter(s3=>!!s3);if(ids.length>1){let base=getVar(ids[0],"y");for(let i3=1;i3<ids.length;i3++)solver.addConstraint(new Constraint(new Expression(getVar(ids[i3],"y"),[-1,base]),Operator.Eq,0,Strength.required))}}}solver.updateVariables();let positions={};for(let id2 of info.componentIds)positions[id2]={x:getVar(id2,"x").value(),y:getVar(id2,"y").value()};let minX=1/0,minY=1/0,maxX=-1/0,maxY=-1/0;for(let id2 of info.componentIds){let comp=packCompById[id2],pos=positions[id2];if(comp)for(let pad2 of comp.pads){let ax2=pos.x+pad2.offset.x,ay2=pos.y+pad2.offset.y;minX=Math.min(minX,ax2-pad2.size.x/2),maxX=Math.max(maxX,ax2+pad2.size.x/2),minY=Math.min(minY,ay2-pad2.size.y/2),maxY=Math.max(maxY,ay2+pad2.size.y/2)}}let clusterCenter={x:(minX+maxX)/2,y:(minY+maxY)/2},mergedPads=[],relCenters={};for(let id2 of info.componentIds){let comp=packCompById[id2],pos=positions[id2];if(comp){relCenters[id2]={x:pos.x-clusterCenter.x,y:pos.y-clusterCenter.y};for(let pad2 of comp.pads)mergedPads.push({padId:pad2.padId,networkId:pad2.networkId,type:pad2.type,size:pad2.size,offset:{x:pos.x+pad2.offset.x-clusterCenter.x,y:pos.y+pad2.offset.y-clusterCenter.y}})}}packInput.components=packInput.components.filter(c3=>!info.componentIds.includes(c3.componentId)),packInput.components.push({componentId:info.componentIds[0],pads:mergedPads,availableRotationDegrees:[0]}),info.relativeCenters=relCenters,clusterMap[info.componentIds[0]]=info}return clusterMap},updateCadRotation=({db:db2,pcbComponentId,rotationDegrees,layer})=>{if(rotationDegrees==null||!db2?.cad_component?.list)return;let cadComponent=db2.cad_component.getWhere({pcb_component_id:pcbComponentId});if(!cadComponent)return;let delta=layer?.toLowerCase?.()==="bottom"?-rotationDegrees:rotationDegrees,currentRotationZ=cadComponent.rotation?.z??0,nextRotation={...cadComponent.rotation??{x:0,y:0,z:0},z:normalizeDegrees(currentRotationZ+delta)};db2.cad_component.update(cadComponent.cad_component_id,{rotation:nextRotation}),cadComponent.rotation=nextRotation},isDescendantGroup=(db2,groupId,ancestorId)=>{if(groupId===ancestorId)return!0;let group=db2.source_group.get(groupId);return!group||!group.parent_source_group_id?!1:isDescendantGroup(db2,group.parent_source_group_id,ancestorId)},applyPackOutput=(group,packOutput,clusterMap)=>{let{db:db2}=group.root;for(let packedComponent of packOutput.components){let{center:center2,componentId,ccwRotationOffset,ccwRotationDegrees}=packedComponent,cluster=clusterMap[componentId];if(cluster){let rotationDegrees2=ccwRotationDegrees??ccwRotationOffset??0,angleRad=rotationDegrees2*Math.PI/180;for(let memberId of cluster.componentIds){let rel=cluster.relativeCenters[memberId];if(!rel)continue;db2.pcb_component.update(memberId,{position_mode:"packed"});let rotatedRel={x:rel.x*Math.cos(angleRad)-rel.y*Math.sin(angleRad),y:rel.x*Math.sin(angleRad)+rel.y*Math.cos(angleRad)},member=db2.pcb_component.get(memberId);if(!member)continue;let originalCenter2=member.center,transformMatrix2=compose(group._computePcbGlobalTransformBeforeLayout(),translate(center2.x+rotatedRel.x,center2.y+rotatedRel.y),rotate(angleRad),translate(-originalCenter2.x,-originalCenter2.y)),related=db2.toArray().filter(elm=>"pcb_component_id"in elm&&elm.pcb_component_id===memberId);transformPCBElements(related,transformMatrix2),updateCadRotation({db:db2,pcbComponentId:memberId,rotationDegrees:rotationDegrees2,layer:member.layer})}continue}let pcbComponent=db2.pcb_component.get(componentId);if(pcbComponent){db2.pcb_component.update(componentId,{position_mode:"packed"});let currentGroupId=group.source_group_id,componentGroupId=db2.source_component.get(pcbComponent.source_component_id)?.source_group_id;if(componentGroupId!==void 0&&!isDescendantGroup(db2,componentGroupId,currentGroupId))continue;let originalCenter2=pcbComponent.center,rotationDegrees2=ccwRotationDegrees??ccwRotationOffset??0,transformMatrix2=compose(group._computePcbGlobalTransformBeforeLayout(),translate(center2.x,center2.y),rotate(rotationDegrees2*Math.PI/180),translate(-originalCenter2.x,-originalCenter2.y)),related=db2.toArray().filter(elm=>"pcb_component_id"in elm&&elm.pcb_component_id===componentId);transformPCBElements(related,transformMatrix2),updateCadRotation({db:db2,pcbComponentId:componentId,rotationDegrees:rotationDegrees2,layer:pcbComponent.layer});continue}let pcbGroup=db2.pcb_group.list().find(g4=>g4.source_group_id===componentId);if(!pcbGroup)continue;let originalCenter=pcbGroup.center,rotationDegrees=ccwRotationDegrees??ccwRotationOffset??0,transformMatrix=compose(group._computePcbGlobalTransformBeforeLayout(),translate(center2.x,center2.y),rotate(rotationDegrees*Math.PI/180),translate(-originalCenter.x,-originalCenter.y)),relatedElements=db2.toArray().filter(elm=>{if("source_group_id"in elm&&elm.source_group_id&&(elm.source_group_id===componentId||isDescendantGroup(db2,elm.source_group_id,componentId)))return!0;if("source_component_id"in elm&&elm.source_component_id){let sourceComponent=db2.source_component.get(elm.source_component_id);if(sourceComponent?.source_group_id&&(sourceComponent.source_group_id===componentId||isDescendantGroup(db2,sourceComponent.source_group_id,componentId)))return!0}if("pcb_component_id"in elm&&elm.pcb_component_id){let pcbComp=db2.pcb_component.get(elm.pcb_component_id);if(pcbComp?.source_component_id){let sourceComp=db2.source_component.get(pcbComp.source_component_id);if(sourceComp?.source_group_id&&(sourceComp.source_group_id===componentId||isDescendantGroup(db2,sourceComp.source_group_id,componentId)))return!0}}return!1});for(let elm of relatedElements)elm.type==="pcb_component"&&db2.pcb_component.update(elm.pcb_component_id,{position_mode:"packed"});transformPCBElements(relatedElements,transformMatrix),db2.pcb_group.update(pcbGroup.pcb_group_id,{center:center2})}},DEFAULT_MIN_GAP="1mm",debug6=(0,import_debug13.default)("Group_doInitialPcbLayoutPack"),Group_doInitialPcbLayoutPack=group=>{let{db:db2}=group.root,{_parsedProps:props}=group;group.root?.emit("packing:start",{subcircuit_id:group.subcircuit_id,componentDisplayName:group.getString()});let{packOrderStrategy,packPlacementStrategy,gap:gapProp,pcbGap,pcbPackGap}=props,gap=pcbPackGap??pcbGap??gapProp,gapMm=length.parse(gap??DEFAULT_MIN_GAP),chipMarginsMap={},staticPcbComponentIds=new Set,collectMargins=comp=>{if(comp?.pcb_component_id&&comp?._parsedProps){let props2=comp._parsedProps,left=length.parse(props2.pcbMarginLeft??props2.pcbMarginX??0),right=length.parse(props2.pcbMarginRight??props2.pcbMarginX??0),top=length.parse(props2.pcbMarginTop??props2.pcbMarginY??0),bottom=length.parse(props2.pcbMarginBottom??props2.pcbMarginY??0);(left||right||top||bottom)&&(chipMarginsMap[comp.pcb_component_id]={left,right,top,bottom})}comp?.children&&comp.children.forEach(collectMargins)};collectMargins(group);let excludedPcbGroupIds=new Set;for(let child of group.children){let childIsGroupOrNormalComponent=child;childIsGroupOrNormalComponent._isNormalComponent&&childIsGroupOrNormalComponent.isRelativelyPositioned?.()&&(childIsGroupOrNormalComponent.pcb_component_id&&staticPcbComponentIds.add(childIsGroupOrNormalComponent.pcb_component_id),childIsGroupOrNormalComponent.pcb_group_id&&excludedPcbGroupIds.add(childIsGroupOrNormalComponent.pcb_group_id))}let isDescendantGroup2=(db22,groupId,ancestorId)=>{if(groupId===ancestorId)return!0;let group2=db22.source_group.get(groupId);return!group2||!group2.parent_source_group_id?!1:isDescendantGroup2(db22,group2.parent_source_group_id,ancestorId)};if(excludedPcbGroupIds.size>0)for(let element of db2.toArray()){if(element.type!=="pcb_component")continue;let sourceComponent=db2.source_component.get(element.source_component_id);if(sourceComponent?.source_group_id)for(let groupId of excludedPcbGroupIds)isDescendantGroup2(db2,sourceComponent.source_group_id,groupId)&&staticPcbComponentIds.add(element.pcb_component_id)}let filteredCircuitJson=db2.toArray(),bounds;if(props.width!==void 0&&props.height!==void 0){let widthMm=length.parse(props.width),heightMm=length.parse(props.height);bounds={minX:-widthMm/2,maxX:widthMm/2,minY:-heightMm/2,maxY:heightMm/2}}let packInput={...convertPackOutputToPackInput(convertCircuitJsonToPackOutput(filteredCircuitJson,{source_group_id:group.source_group_id,chipMarginsMap,staticPcbComponentIds:Array.from(staticPcbComponentIds)})),orderStrategy:packOrderStrategy??"largest_to_smallest",placementStrategy:packPlacementStrategy??"minimum_sum_squared_distance_to_network",minGap:gapMm,bounds},clusterMap=applyComponentConstraintClusters(group,packInput);debug6.enabled&&(group.root?.emit("debug:logOutput",{type:"debug:logOutput",name:`packInput-circuitjson-${group.name}`,content:JSON.stringify(db2.toArray())}),group.root?.emit("debug:logOutput",{type:"debug:logOutput",name:`packInput-${group.name}`,content:packInput}));let packOutput;try{let solver=new PackSolver2(packInput);group.root?.emit("solver:started",{type:"solver:started",solverName:"PackSolver2",solverParams:solver.getConstructorParams(),componentName:group.getString()}),solver.solve(),packOutput={...packInput,components:solver.packedComponents}}catch(error){throw group.root?.emit("packing:error",{subcircuit_id:group.subcircuit_id,componentDisplayName:group.getString(),error:{message:error instanceof Error?error.message:String(error)}}),error}if(debug6.enabled&&global?.debugGraphics){let graphics=getGraphicsFromPackOutput(packOutput);graphics.title=`packOutput-${group.name}`,global.debugGraphics?.push(graphics)}applyPackOutput(group,packOutput,clusterMap),group.root?.emit("packing:end",{subcircuit_id:group.subcircuit_id,componentDisplayName:group.getString()})},Group_doInitialPcbLayoutFlex=group=>{let{db:db2}=group.root,{_parsedProps:props}=group,pcbChildren=group.children.filter(c3=>c3.pcb_component_id||c3.pcb_group_id);if(pcbChildren.some(child=>{let childProps=child._parsedProps;return childProps?.pcbX!==void 0||childProps?.pcbY!==void 0}))return;let rawJustify=props.pcbJustifyContent??props.justifyContent,rawAlign=props.pcbAlignItems??props.alignItems,rawGap=props.pcbFlexGap??props.pcbGap??props.gap,direction2=props.pcbFlexDirection??"row",justifyContent={start:"flex-start",end:"flex-end","flex-start":"flex-start","flex-end":"flex-end",stretch:"space-between","space-between":"space-between","space-around":"space-around","space-evenly":"space-evenly",center:"center"}[rawJustify??"space-between"],alignItems={start:"flex-start",end:"flex-end","flex-start":"flex-start","flex-end":"flex-end",stretch:"stretch",center:"center"}[rawAlign??"center"];if(!justifyContent)throw new Error(`Invalid justifyContent value: "${rawJustify}"`);if(!alignItems)throw new Error(`Invalid alignItems value: "${rawAlign}"`);let rowGap=0,columnGap=0;typeof rawGap=="object"?(rowGap=rawGap.y??0,columnGap=rawGap.x??0):typeof rawGap=="number"?(rowGap=rawGap,columnGap=rawGap):typeof rawGap=="string"&&(rowGap=length.parse(rawGap),columnGap=length.parse(rawGap));let minFlexContainer,width=props.width??props.pcbWidth??void 0,height=props.height??props.pcbHeight??void 0;(width===void 0||height===void 0)&&(minFlexContainer=getMinimumFlexContainer(pcbChildren.map(child=>child._getMinimumFlexContainerSize()).filter(size2=>size2!==null),{alignItems,justifyContent,direction:direction2,rowGap,columnGap}),width=minFlexContainer.width,height=minFlexContainer.height);let flexBox=new RootFlexBox(width,height,{alignItems,justifyContent,direction:direction2,rowGap,columnGap});for(let child of pcbChildren){let size2=child._getMinimumFlexContainerSize();flexBox.addChild({metadata:child,width:size2?.width??0,height:size2?.height??0,flexBasis:size2?direction2==="row"?size2.width:size2.height:void 0})}flexBox.build();let bounds={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,width:0,height:0};for(let child of flexBox.children)bounds.minX=Math.min(bounds.minX,child.position.x),bounds.minY=Math.min(bounds.minY,child.position.y),bounds.maxX=Math.max(bounds.maxX,child.position.x+child.size.width),bounds.maxY=Math.max(bounds.maxY,child.position.y+child.size.height);bounds.width=bounds.maxX-bounds.minX,bounds.height=bounds.maxY-bounds.minY;let groupCenter=group._getGlobalPcbPositionBeforeLayout(),offset={x:groupCenter.x-(bounds.maxX+bounds.minX)/2,y:groupCenter.y-(bounds.maxY+bounds.minY)/2};for(let child of flexBox.children)child.metadata._repositionOnPcb({x:child.position.x+child.size.width/2+offset.x,y:child.position.y+child.size.height/2+offset.y});db2.pcb_group.update(group.pcb_group_id,{width:bounds.width,height:bounds.height,center:groupCenter})},createSourceTracesFromOffboardConnections=({db:db2,connectedOffboardObstacles,simpleRouteJson,subcircuit_id})=>{if(Object.keys(connectedOffboardObstacles).length===0)return;let pcbElementIdToSourcePortId=new Map;for(let pcbPort of db2.pcb_port.list())if(pcbPort.source_port_id){let smtpad2=db2.pcb_smtpad.getWhere({pcb_port_id:pcbPort.pcb_port_id});smtpad2&&pcbElementIdToSourcePortId.set(smtpad2.pcb_smtpad_id,pcbPort.source_port_id);let platedHole=db2.pcb_plated_hole.getWhere({pcb_port_id:pcbPort.pcb_port_id});platedHole&&pcbElementIdToSourcePortId.set(platedHole.pcb_plated_hole_id,pcbPort.source_port_id)}let obstacleById=new Map;for(let obstacle of simpleRouteJson.obstacles)obstacle.obstacleId&&obstacleById.set(obstacle.obstacleId,obstacle);let connectionGroups=new Map;for(let[obstacleId,rootConnectionName]of Object.entries(connectedOffboardObstacles))connectionGroups.has(rootConnectionName)||connectionGroups.set(rootConnectionName,[]),connectionGroups.get(rootConnectionName).push(obstacleId);for(let[rootConnectionName,obstacleIds]of connectionGroups){let sourcePortIds=new Set;for(let obstacleId of obstacleIds){let obstacle=obstacleById.get(obstacleId);if(obstacle)for(let connectedId of obstacle.connectedTo){let sourcePortId=pcbElementIdToSourcePortId.get(connectedId);sourcePortId&&sourcePortIds.add(sourcePortId)}}if(sourcePortIds.size<2)continue;let sourcePortIdArray=Array.from(sourcePortIds);db2.source_trace.list().some(trace=>{let tracePortIds=new Set(trace.connected_source_port_ids);return sourcePortIdArray.every(id2=>tracePortIds.has(id2))})||db2.source_trace.insert({connected_source_port_ids:sourcePortIdArray,connected_source_net_ids:[],subcircuit_id:subcircuit_id??void 0,display_name:`offboard_${rootConnectionName}`})}};function createSchematicTraceSolverInputProblem(group){let{db:db2}=group.root,sckToSourceNet=new Map,sckToUserNetId=new Map,allScks=new Set,displayLabelTraces=group.selectAll("trace").filter(t5=>t5._parsedProps?.schDisplayLabel),childGroups=group.selectAll("group"),allSchematicGroupIds=[group.schematic_group_id,...childGroups.map(a2=>a2.schematic_group_id)],schematicComponents=db2.schematic_component.list().filter(a2=>allSchematicGroupIds.includes(a2.schematic_group_id)),chips=[],pinIdToSchematicPortId=new Map,schematicPortIdToPinId=new Map;for(let schematicComponent of schematicComponents){let chipId=schematicComponent.schematic_component_id,pins=[],sourceComponent=db2.source_component.getWhere({source_component_id:schematicComponent.source_component_id}),schematicPorts=db2.schematic_port.list({schematic_component_id:schematicComponent.schematic_component_id});for(let schematicPort of schematicPorts){let pinId=`${sourceComponent?.name??schematicComponent.schematic_component_id}.${schematicPort.pin_number}`;pinIdToSchematicPortId.set(pinId,schematicPort.schematic_port_id),schematicPortIdToPinId.set(schematicPort.schematic_port_id,pinId)}for(let schematicPort of schematicPorts){let pinId=schematicPortIdToPinId.get(schematicPort.schematic_port_id);pins.push({pinId,x:schematicPort.center.x,y:schematicPort.center.y})}chips.push({chipId,center:schematicComponent.center,width:schematicComponent.size.width,height:schematicComponent.size.height,pins})}let allSourceAndSchematicPortIdsInScope=new Set,schPortIdToSourcePortId=new Map,sourcePortIdToSchPortId=new Map,userNetIdToSck=new Map;for(let sc2 of schematicComponents){let ports=db2.schematic_port.list({schematic_component_id:sc2.schematic_component_id});for(let sp2 of ports)allSourceAndSchematicPortIdsInScope.add(sp2.schematic_port_id),sp2.source_port_id&&(schPortIdToSourcePortId.set(sp2.schematic_port_id,sp2.source_port_id),sourcePortIdToSchPortId.set(sp2.source_port_id,sp2.schematic_port_id))}let allowedSubcircuitIds=new Set;group.subcircuit_id&&allowedSubcircuitIds.add(group.subcircuit_id);for(let cg of childGroups)cg.subcircuit_id&&allowedSubcircuitIds.add(cg.subcircuit_id);let externalNetIds=db2.source_trace.list().filter(st2=>{if(st2.subcircuit_id===group.subcircuit_id)return!0;for(let source_port_id of st2.connected_source_port_ids)if(sourcePortIdToSchPortId.has(source_port_id))return!0;return!1}).flatMap(st2=>st2.connected_source_net_ids);for(let netId of externalNetIds){let net=db2.source_net.get(netId);net?.subcircuit_id&&allowedSubcircuitIds.add(net.subcircuit_id)}let directConnections=[],pairKeyToSourceTraceId=new Map;for(let st2 of db2.source_trace.list()){if(st2.subcircuit_id&&!allowedSubcircuitIds.has(st2.subcircuit_id))continue;let connected=(st2.connected_source_port_ids??[]).map(srcId=>sourcePortIdToSchPortId.get(srcId)).filter(sourcePortId=>!!sourcePortId&&allSourceAndSchematicPortIdsInScope.has(sourcePortId));if(connected.length>=2){let[a2,b3]=connected.slice(0,2),pairKey=[a2,b3].sort().join("::");if(!pairKeyToSourceTraceId.has(pairKey)){pairKeyToSourceTraceId.set(pairKey,st2.source_trace_id);let userNetId=st2.display_name??st2.source_trace_id;st2.subcircuit_connectivity_map_key&&(allScks.add(st2.subcircuit_connectivity_map_key),userNetIdToSck.set(userNetId,st2.subcircuit_connectivity_map_key),sckToUserNetId.set(st2.subcircuit_connectivity_map_key,userNetId)),directConnections.push({pinIds:[a2,b3].map(id2=>schematicPortIdToPinId.get(id2)),netId:userNetId})}}}let netConnections=[];for(let net of db2.source_net.list().filter(n3=>!n3.subcircuit_id||allowedSubcircuitIds.has(n3.subcircuit_id)))net.subcircuit_connectivity_map_key&&(allScks.add(net.subcircuit_connectivity_map_key),sckToSourceNet.set(net.subcircuit_connectivity_map_key,net));let sckToPinIds=new Map;for(let[schId,srcPortId]of schPortIdToSourcePortId){let sp2=db2.source_port.get(srcPortId);if(!sp2?.subcircuit_connectivity_map_key)continue;let sck=sp2.subcircuit_connectivity_map_key;allScks.add(sck),sckToPinIds.has(sck)||sckToPinIds.set(sck,[]),sckToPinIds.get(sck).push(schId)}for(let[subcircuitConnectivityKey,schematicPortIds]of sckToPinIds){let sourceNet=sckToSourceNet.get(subcircuitConnectivityKey);if(sourceNet&&schematicPortIds.length>=2){let userNetId=String(sourceNet.name||sourceNet.source_net_id||subcircuitConnectivityKey);userNetIdToSck.set(userNetId,subcircuitConnectivityKey),sckToUserNetId.set(subcircuitConnectivityKey,userNetId);let charWidth=.1*(.18/.18),netLabelWidth=Number((String(userNetId).length*charWidth).toFixed(2));netConnections.push({netId:userNetId,pinIds:schematicPortIds.map(portId=>schematicPortIdToPinId.get(portId)),netLabelWidth})}}let availableNetLabelOrientations=(()=>{let netToAllowedOrientations={},presentNetIds=new Set(netConnections.map(nc2=>nc2.netId));for(let net of db2.source_net.list().filter(n3=>!n3.subcircuit_id||allowedSubcircuitIds.has(n3.subcircuit_id)))net.name&&presentNetIds.has(net.name)&&(net.is_ground||net.name.toLowerCase().startsWith("gnd")?netToAllowedOrientations[net.name]=["y-"]:net.is_power||net.name.toLowerCase().startsWith("v")?netToAllowedOrientations[net.name]=["y+"]:netToAllowedOrientations[net.name]=["x-","x+"]);return netToAllowedOrientations})();return{inputProblem:{chips,directConnections,netConnections,availableNetLabelOrientations,maxMspPairDistance:group._parsedProps.schMaxTraceDistance??2.4},pinIdToSchematicPortId,pairKeyToSourceTraceId,sckToSourceNet,sckToUserNetId,userNetIdToSck,allSourceAndSchematicPortIdsInScope,schPortIdToSourcePortId,displayLabelTraces,allScks}}var TOL=1e-6;function isHorizontalEdge(edge){let dx2=Math.abs(edge.to.x-edge.from.x),dy2=Math.abs(edge.to.y-edge.from.y);return dx2>=dy2}function length6(a2,b3){return Math.hypot(b3.x-a2.x,b3.y-a2.y)}function pointAt(a2,b3,t5){return{x:a2.x+(b3.x-a2.x)*t5,y:a2.y+(b3.y-a2.y)*t5}}function paramAlong(a2,b3,p2){let L3=length6(a2,b3);if(L3<TOL)return 0;let t5=((p2.x-a2.x)*(b3.x-a2.x)+(p2.y-a2.y)*(b3.y-a2.y))/((b3.x-a2.x)*(b3.x-a2.x)+(b3.y-a2.y)*(b3.y-a2.y));return Math.max(0,Math.min(1,t5))*L3}function cross2(ax2,ay2,bx2,by2){return ax2*by2-ay2*bx2}function segmentIntersection(p12,p2,q12,q22){let r4={x:p2.x-p12.x,y:p2.y-p12.y},s3={x:q22.x-q12.x,y:q22.y-q12.y},rxs=cross2(r4.x,r4.y,s3.x,s3.y),q_p={x:q12.x-p12.x,y:q12.y-p12.y},q_pxr=cross2(q_p.x,q_p.y,r4.x,r4.y);if(Math.abs(rxs)<TOL&&Math.abs(q_pxr)<TOL||Math.abs(rxs)<TOL&&Math.abs(q_pxr)>=TOL)return null;let t5=cross2(q_p.x,q_p.y,s3.x,s3.y)/rxs,u4=cross2(q_p.x,q_p.y,r4.x,r4.y)/rxs;return t5<-TOL||t5>1+TOL||u4<-TOL||u4>1+TOL?null:{x:p12.x+t5*r4.x,y:p12.y+t5*r4.y}}function mergeIntervals(intervals,tol=TOL){if(intervals.length===0)return intervals;intervals.sort((a2,b3)=>a2.start-b3.start);let merged=[],cur={...intervals[0]};for(let i3=1;i3<intervals.length;i3++){let nxt=intervals[i3];nxt.start<=cur.end+tol?cur.end=Math.max(cur.end,nxt.end):(merged.push(cur),cur={...nxt})}return merged.push(cur),merged}function splitEdgeByCrossings(edge,crossingDistances,crossLen){let L3=length6(edge.from,edge.to);if(L3<TOL||crossingDistances.length===0)return[edge];let half=crossLen/2,rawIntervals=crossingDistances.map(d3=>({start:Math.max(0,d3-half),end:Math.min(L3,d3+half)})).filter(iv=>iv.end-iv.start>TOL),intervals=mergeIntervals(rawIntervals),result=[],cursor=0,dir={x:edge.to.x-edge.from.x,y:edge.to.y-edge.from.y},addSeg=(d02,d12,isCrossing)=>{if(d12-d02<=TOL)return;let t02=d02/L3,t12=d12/L3;result.push({from:pointAt(edge.from,edge.to,t02),to:pointAt(edge.from,edge.to,t12),...isCrossing?{is_crossing:!0}:{}})};for(let iv of intervals)iv.start-cursor>TOL&&addSeg(cursor,iv.start,!1),addSeg(iv.start,iv.end,!0),cursor=iv.end;return L3-cursor>TOL&&addSeg(cursor,L3,!1),result.length>0?result:[edge]}function computeCrossings(traces,opts={}){let crossLen=opts.crossSegmentLength??.075,tol=opts.tolerance??TOL,crossingsByEdge=new Map,keyOf=ref=>`${ref.traceIdx}:${ref.edgeIdx}`,getEdge=ref=>traces[ref.traceIdx].edges[ref.edgeIdx];for(let ti3=0;ti3<traces.length;ti3++){let A4=traces[ti3];for(let ei3=0;ei3<A4.edges.length;ei3++){let eA=A4.edges[ei3];for(let tj2=ti3;tj2<traces.length;tj2++){let B3=traces[tj2];for(let ej2=tj2===ti3?ei3+1:0;ej2<B3.edges.length;ej2++){let eB=B3.edges[ej2],P4=segmentIntersection(eA.from,eA.to,eB.from,eB.to);if(!P4)continue;let LA=length6(eA.from,eA.to),LB=length6(eB.from,eB.to);if(LA<tol||LB<tol)continue;let dA=paramAlong(eA.from,eA.to,P4),dB=paramAlong(eB.from,eB.to,P4),nearEndpointA=dA<=tol||Math.abs(LA-dA)<=tol||Number.isNaN(dA),nearEndpointB=dB<=tol||Math.abs(LB-dB)<=tol||Number.isNaN(dB);if(!nearEndpointA&&!nearEndpointB){let aIsHorizontal=isHorizontalEdge(eA),bIsHorizontal=isHorizontalEdge(eB),assignToA;if(aIsHorizontal!==bIsHorizontal)assignToA=aIsHorizontal;else{let ax2=Math.abs(eA.to.x-eA.from.x),ay2=Math.abs(eA.to.y-eA.from.y),bx2=Math.abs(eB.to.x-eB.from.x),by2=Math.abs(eB.to.y-eB.from.y),aScore=ax2-ay2,bScore=bx2-by2;assignToA=aScore===bScore?!0:aScore>bScore}let chosenKey=keyOf({traceIdx:assignToA?ti3:tj2,edgeIdx:assignToA?ei3:ej2}),chosenList=crossingsByEdge.get(chosenKey)??[];chosenList.push(assignToA?dA:dB),crossingsByEdge.set(chosenKey,chosenList)}}}}}let out=traces.map(t5=>({source_trace_id:t5.source_trace_id,edges:[]}));for(let ti3=0;ti3<traces.length;ti3++){let trace=traces[ti3];for(let ei3=0;ei3<trace.edges.length;ei3++){let eRefKey=keyOf({traceIdx:ti3,edgeIdx:ei3}),splittingDistances=crossingsByEdge.get(eRefKey)??[];if(splittingDistances.length===0){out[ti3].edges.push(trace.edges[ei3]);continue}let uniqueSorted=Array.from(new Set(splittingDistances.map(d3=>Number(d3.toFixed(6))))).sort((a2,b3)=>a2-b3),split=splitEdgeByCrossings(trace.edges[ei3],uniqueSorted,crossLen);out[ti3].edges.push(...split)}}return out}var TOL2=1e-6;function nearlyEqual(a2,b3,tol=TOL2){return Math.abs(a2-b3)<=tol}function pointEq(a2,b3,tol=TOL2){return nearlyEqual(a2.x,b3.x,tol)&&nearlyEqual(a2.y,b3.y,tol)}function onSegment4(p2,a2,b3,tol=TOL2){let minX=Math.min(a2.x,b3.x)-tol,maxX=Math.max(a2.x,b3.x)+tol,minY=Math.min(a2.y,b3.y)-tol,maxY=Math.max(a2.y,b3.y)+tol;return p2.x<minX||p2.x>maxX||p2.y<minY||p2.y>maxY?!1:Math.abs((b3.x-a2.x)*(p2.y-a2.y)-(b3.y-a2.y)*(p2.x-a2.x))<=tol}function dedupePoints(points,tol=TOL2){let map=new Map;for(let p2 of points){let key=`${p2.x.toFixed(6)},${p2.y.toFixed(6)}`;map.has(key)||map.set(key,p2)}return Array.from(map.values())}function edgeVec(e4){return{x:e4.to.x-e4.from.x,y:e4.to.y-e4.from.y}}function isParallel(e12,e22,tol=TOL2){let v12=edgeVec(e12),v22=edgeVec(e22),L12=Math.hypot(v12.x,v12.y),L22=Math.hypot(v22.x,v22.y);if(L12<tol||L22<tol)return!0;let cross22=v12.x*v22.y-v12.y*v22.x;return Math.abs(cross22)<=tol*L12*L22}function incidentEdgesAtPoint(trace,p2,tol=TOL2){return trace.edges.filter(e4=>pointEq(e4.from,p2,tol)||pointEq(e4.to,p2,tol))}function nearestEndpointOnTrace(trace,p2,tol=TOL2){for(let e4 of trace.edges){if(pointEq(e4.from,p2,tol))return e4.from;if(pointEq(e4.to,p2,tol))return e4.to}return null}function edgeDirectionFromPoint(e4,p2,tol=TOL2){let other=pointEq(e4.from,p2,tol)||nearlyEqual(e4.from.x,p2.x,tol)&&nearlyEqual(e4.from.y,p2.y,tol)?e4.to:e4.from,dx2=other.x-p2.x,dy2=other.y-p2.y;return Math.abs(dx2)<tol&&Math.abs(dy2)<tol?null:Math.abs(dx2)>=Math.abs(dy2)?dx2>=0?"right":"left":dy2>=0?"up":"down"}function getCornerOrientationAtPoint(trace,p2,tol=TOL2){let incident=incidentEdgesAtPoint(trace,p2,tol);if(incident.length<2)return null;let dirs=incident.map(e4=>edgeDirectionFromPoint(e4,p2,tol)),hasUp=dirs.includes("up"),hasDown=dirs.includes("down"),hasLeft=dirs.includes("left"),hasRight=dirs.includes("right"),vertical=hasUp?"up":hasDown?"down":null,horizontal=hasRight?"right":hasLeft?"left":null;return vertical&&horizontal?`${vertical}-${horizontal}`:null}function computeJunctions(traces,opts={}){let tol=opts.tolerance??TOL2,result={};for(let t5 of traces)result[t5.source_trace_id]=[];let endpointsByTrace=traces.map(t5=>{let pts=[];for(let e4 of t5.edges)pts.push(e4.from,e4.to);return dedupePoints(pts,tol)});for(let i3=0;i3<traces.length;i3++){let A4=traces[i3],AEnds=endpointsByTrace[i3];for(let j3=i3+1;j3<traces.length;j3++){let B3=traces[j3],BEnds=endpointsByTrace[j3];for(let pa3 of AEnds)for(let pb2 of BEnds)if(pointEq(pa3,pb2,tol)){let aEdgesAtP=incidentEdgesAtPoint(A4,pa3,tol),bEdgesAtP=incidentEdgesAtPoint(B3,pb2,tol),hasCorner=aEdgesAtP.some(eA=>bEdgesAtP.some(eB=>!isParallel(eA,eB,tol))),aCorner=getCornerOrientationAtPoint(A4,pa3,tol),bCorner=getCornerOrientationAtPoint(B3,pb2,tol);hasCorner&&!(aCorner!==null&&bCorner!==null&&aCorner===bCorner)&&(result[A4.source_trace_id].push(pa3),A4.source_trace_id!==B3.source_trace_id&&result[B3.source_trace_id].push(pb2))}for(let pa3 of AEnds)for(let eB of B3.edges)if(onSegment4(pa3,eB.from,eB.to,tol)){let hasCorner=incidentEdgesAtPoint(A4,pa3,tol).some(eA=>!isParallel(eA,eB,tol)),aCorner=getCornerOrientationAtPoint(A4,pa3,tol),bEndpointNearPa=nearestEndpointOnTrace(B3,pa3,tol*1e3),bCorner=bEndpointNearPa?getCornerOrientationAtPoint(B3,bEndpointNearPa,tol):null;hasCorner&&!(aCorner!==null&&bCorner!==null&&aCorner===bCorner)&&(result[A4.source_trace_id].push(pa3),A4.source_trace_id!==B3.source_trace_id&&result[B3.source_trace_id].push(pa3))}for(let pb2 of BEnds)for(let eA of A4.edges)if(onSegment4(pb2,eA.from,eA.to,tol)){let hasCorner=incidentEdgesAtPoint(B3,pb2,tol).some(eB=>!isParallel(eA,eB,tol)),bCorner=getCornerOrientationAtPoint(B3,pb2,tol),aEndpointNearPb=nearestEndpointOnTrace(A4,pb2,tol*1e3),aCorner=aEndpointNearPb?getCornerOrientationAtPoint(A4,aEndpointNearPb,tol):null;hasCorner&&!(aCorner!==null&&bCorner!==null&&aCorner===bCorner)&&(result[B3.source_trace_id].push(pb2),A4.source_trace_id!==B3.source_trace_id&&result[A4.source_trace_id].push(pb2))}}}for(let id2 of Object.keys(result))result[id2]=dedupePoints(result[id2],tol);return result}var debug7=(0,import_debug15.default)("Group_doInitialSchematicTraceRender");function applyTracesFromSolverOutput(args){let{group,solver,pinIdToSchematicPortId,userNetIdToSck}=args,{db:db2}=group.root,traces=solver.traceCleanupSolver?.getOutput().traces??solver.traceLabelOverlapAvoidanceSolver?.getOutput().traces??solver.schematicTraceLinesSolver?.solvedTracePaths,pendingTraces=[];debug7(`Traces inside SchematicTraceSolver output: ${(traces??[]).length}`);for(let solvedTracePath of traces??[]){let points=solvedTracePath?.tracePath;if(!Array.isArray(points)||points.length<2){debug7(`Skipping trace ${solvedTracePath?.pinIds.join(",")} because it has less than 2 points`);continue}let edges=[];for(let i3=0;i3<points.length-1;i3++)edges.push({from:{x:points[i3].x,y:points[i3].y},to:{x:points[i3+1].x,y:points[i3+1].y}});let source_trace_id=null,subcircuit_connectivity_map_key;if(Array.isArray(solvedTracePath?.pins)&&solvedTracePath.pins.length===2){let pA=pinIdToSchematicPortId.get(solvedTracePath.pins[0]?.pinId),pB=pinIdToSchematicPortId.get(solvedTracePath.pins[1]?.pinId);if(pA&&pB){for(let schPid of[pA,pB])db2.schematic_port.get(schPid)&&db2.schematic_port.update(schPid,{is_connected:!0});subcircuit_connectivity_map_key=userNetIdToSck.get(String(solvedTracePath.userNetId))}}source_trace_id||(source_trace_id=`solver_${solvedTracePath?.mspPairId}`,subcircuit_connectivity_map_key=userNetIdToSck.get(String(solvedTracePath.userNetId))),pendingTraces.push({source_trace_id,edges,subcircuit_connectivity_map_key})}debug7(`Applying ${pendingTraces.length} traces from SchematicTraceSolver output`);let withCrossings=computeCrossings(pendingTraces.map(t5=>({source_trace_id:t5.source_trace_id,edges:t5.edges}))),junctionsById=computeJunctions(withCrossings);for(let t5 of withCrossings)db2.schematic_trace.insert({source_trace_id:t5.source_trace_id,edges:t5.edges,junctions:junctionsById[t5.source_trace_id]??[],subcircuit_connectivity_map_key:pendingTraces.find(p2=>p2.source_trace_id===t5.source_trace_id)?.subcircuit_connectivity_map_key})}var oppositeSide2=input2=>{switch(input2){case"x+":return"left";case"x-":return"right";case"y+":return"bottom";case"y-":return"top";case"left":return"right";case"top":return"bottom";case"right":return"left";case"bottom":return"top"}},getNetNameFromPorts=ports=>{for(let port of ports){let traces=port._getDirectlyConnectedTraces();for(let trace of traces){let displayLabel=trace._parsedProps.schDisplayLabel;if(displayLabel)return{name:displayLabel,wasAssignedDisplayLabel:!0}}}return{name:ports.map(p2=>p2._getNetLabelText()).join("/"),wasAssignedDisplayLabel:!1}},debug8=(0,import_debug16.default)("Group_doInitialSchematicTraceRender");function applyNetLabelPlacements(args){let{group,solver,sckToSourceNet,allScks,allSourceAndSchematicPortIdsInScope,schPortIdToSourcePortId,userNetIdToSck,pinIdToSchematicPortId,schematicPortIdsWithPreExistingNetLabels,schematicPortIdsWithRoutedTraces}=args,{db:db2}=group.root,netLabelPlacements=solver.netLabelPlacementSolver?.netLabelPlacements??solver.traceLabelOverlapAvoidanceSolver?.getOutput().netLabelPlacements??[],globalConnMap=solver.mspConnectionPairSolver.globalConnMap;for(let placement of netLabelPlacements){debug8(`processing placement: ${placement.netId}`);let placementUserNetId=globalConnMap.getIdsConnectedToNet(placement.globalConnNetId).find(id2=>userNetIdToSck.get(id2)),placementSck=userNetIdToSck.get(placementUserNetId),anchor_position=placement.anchorPoint,orientation4=placement.orientation,anchor_side=oppositeSide2(orientation4),sourceNet=placementSck?sckToSourceNet.get(placementSck):void 0,schPortIds=placement.pinIds.map(pinId=>pinIdToSchematicPortId.get(pinId));if(schPortIds.some(schPortId=>schematicPortIdsWithPreExistingNetLabels.has(schPortId))){debug8(`skipping net label placement for "${placement.netId}" REASON:schematic port has pre-existing net label`);continue}if(sourceNet){let text2=sourceNet.name,center22=computeSchematicNetLabelCenter({anchor_position,anchor_side,text:text2});db2.schematic_net_label.insert({text:text2,anchor_position,center:center22,anchor_side,...sourceNet?.source_net_id?{source_net_id:sourceNet.source_net_id}:{}});continue}let ports=group.selectAll("port").filter(p2=>p2._getSubcircuitConnectivityKey()===placementSck),{name:text,wasAssignedDisplayLabel}=getNetNameFromPorts(ports);if(!wasAssignedDisplayLabel&&schPortIds.some(schPortId=>schematicPortIdsWithRoutedTraces.has(schPortId))){debug8(`skipping net label placement for "${placement.netId}" REASON:schematic port has routed traces and no display label`);continue}let center2=computeSchematicNetLabelCenter({anchor_position,anchor_side,text});db2.schematic_net_label.insert({text,anchor_position,center:center2,anchor_side})}}var insertNetLabelsForPortsMissingTrace=({allSourceAndSchematicPortIdsInScope,group,schPortIdToSourcePortId,sckToSourceNet:connKeyToNet,pinIdToSchematicPortId,schematicPortIdsWithPreExistingNetLabels})=>{let{db:db2}=group.root;for(let schOrSrcPortId of Array.from(allSourceAndSchematicPortIdsInScope)){let schPort=db2.schematic_port.get(schOrSrcPortId);if(!schPort||schPort.is_connected)continue;let srcPortId=schPortIdToSourcePortId.get(schOrSrcPortId);if(!srcPortId)continue;let key=db2.source_port.get(srcPortId)?.subcircuit_connectivity_map_key;if(!key)continue;let sourceNet=connKeyToNet.get(key);if(!sourceNet||db2.schematic_net_label.list().some(nl2=>Math.abs(nl2.anchor_position.x-schPort.center.x)<.1&&Math.abs(nl2.anchor_position.y-schPort.center.y)<.1?sourceNet.source_net_id&&nl2.source_net_id?nl2.source_net_id===sourceNet.source_net_id:nl2.text===(sourceNet.name||key):!1))continue;let text=sourceNet.name||sourceNet.source_net_id||key,side=getEnteringEdgeFromDirection(schPort.facing_direction||"right")||"right",center2=computeSchematicNetLabelCenter({anchor_position:schPort.center,anchor_side:side,text});db2.schematic_net_label.insert({text,anchor_position:schPort.center,center:center2,anchor_side:side,...sourceNet.source_net_id?{source_net_id:sourceNet.source_net_id}:{}})}},getSchematicPortIdsWithAssignedNetLabels=group=>{let schematicPortIdsWithNetLabels=new Set,netLabels=group.selectAll("netlabel");for(let netLabel of netLabels){let netLabelPorts=netLabel._getConnectedPorts();for(let port of netLabelPorts)port.schematic_port_id&&schematicPortIdsWithNetLabels.add(port.schematic_port_id)}return schematicPortIdsWithNetLabels},getSchematicPortIdsWithRoutedTraces=({solver,pinIdToSchematicPortId})=>{let solvedTraces=solver.schematicTraceLinesSolver.solvedTracePaths,schematicPortIdsWithRoutedTraces=new Set;for(let solvedTrace of solvedTraces)for(let pinId of solvedTrace.pinIds){let schPortId=pinIdToSchematicPortId.get(pinId);schPortId&&schematicPortIdsWithRoutedTraces.add(schPortId)}return schematicPortIdsWithRoutedTraces},debug9=(0,import_debug14.default)("Group_doInitialSchematicTraceRender"),Group_doInitialSchematicTraceRender=group=>{if(!group.root?._featureMspSchematicTraceRouting||!group.isSubcircuit||group.root?.schematicDisabled)return;let{inputProblem,pinIdToSchematicPortId,pairKeyToSourceTraceId,sckToSourceNet,allSourceAndSchematicPortIdsInScope,schPortIdToSourcePortId,displayLabelTraces,allScks,userNetIdToSck}=createSchematicTraceSolverInputProblem(group),schematicPortIdsWithPreExistingNetLabels=getSchematicPortIdsWithAssignedNetLabels(group);debug9.enabled&&group.root?.emit("debug:logOutput",{type:"debug:logOutput",name:"group-trace-render-input-problem",content:JSON.stringify(inputProblem,null,2)});let solver=new SchematicTracePipelineSolver(inputProblem);solver.solve();let schematicPortIdsWithRoutedTraces=getSchematicPortIdsWithRoutedTraces({solver,pinIdToSchematicPortId});applyTracesFromSolverOutput({group,solver,pinIdToSchematicPortId,userNetIdToSck}),applyNetLabelPlacements({group,solver,sckToSourceNet,allSourceAndSchematicPortIdsInScope,schPortIdToSourcePortId,pinIdToSchematicPortId,allScks,userNetIdToSck,schematicPortIdsWithPreExistingNetLabels,schematicPortIdsWithRoutedTraces}),insertNetLabelsForPortsMissingTrace({group,allSourceAndSchematicPortIdsInScope,schPortIdToSourcePortId,sckToSourceNet,pinIdToSchematicPortId,schematicPortIdsWithPreExistingNetLabels})},getSpiceyEngine=()=>({async simulate(spiceString){let simulation_experiment_id="spice-experiment-1",{circuit:parsedCircuit,tran}=simulate(spiceString);return{simulationResultCircuitJson:spiceyTranToVGraphs(tran,parsedCircuit,simulation_experiment_id)}}}),SIMULATION_COLOR_PALETTE=["rgb(132, 0, 0)","rgb(194, 194, 0)","rgb(194, 0, 194)","rgb(194, 0, 0)","rgb(0, 132, 132)","rgb(0, 132, 0)","rgb(0, 0, 132)","rgb(132, 132, 132)","rgb(132, 0, 132)","rgb(194, 194, 194)","rgb(132, 0, 132)","rgb(132, 0, 0)","rgb(132, 132, 0)","rgb(194, 194, 194)","rgb(0, 0, 132)","rgb(0, 132, 0)"],idToColorMap=new Map,colorIndex=0;function getSimulationColorForId(id2){if(idToColorMap.has(id2))return idToColorMap.get(id2);let color=SIMULATION_COLOR_PALETTE[colorIndex];return colorIndex=(colorIndex+1)%SIMULATION_COLOR_PALETTE.length,idToColorMap.set(id2,color),color}function resetSimulationColorState(){idToColorMap.clear(),colorIndex=0}var debug10=(0,import_debug17.default)("tscircuit:core:Group_doInitialSimulationSpiceEngineRender");function Group_doInitialSimulationSpiceEngineRender(group){if(!group.isSubcircuit)return;let{root}=group;if(!root)return;let analogSims=group.selectAll("analogsimulation");if(analogSims.length===0)return;let voltageProbes=group.selectAll("voltageprobe");resetSimulationColorState();let spiceEngineMap={...root.platform?.spiceEngineMap};spiceEngineMap.spicey||(spiceEngineMap.spicey=getSpiceyEngine());let circuitJson=root.db.toArray(),spiceString,spiceNetlist;try{spiceNetlist=circuitJsonToSpice(circuitJson),spiceString=spiceNetlist.toSpiceString(),debug10(`Generated SPICE string:
614
614
  ${spiceString}`)}catch(error){debug10(`Failed to convert circuit JSON to SPICE: ${error}`);return}for(let analogSim of analogSims){let engineName=analogSim._parsedProps.spiceEngine??"spicey",spiceEngine2=spiceEngineMap[engineName];if(!spiceEngine2)throw new Error(`SPICE engine "${engineName}" not found in platform config. Available engines: ${JSON.stringify(Object.keys(spiceEngineMap).filter(k4=>k4!=="spicey"))}`);let effectId=`spice-simulation-${engineName}-${analogSim.source_component_id}`;debug10(`Queueing simulation for spice engine: ${engineName} (id: ${effectId})`),group._queueAsyncEffect(effectId,async()=>{try{debug10(`Running simulation with engine: ${engineName}`);let result=await spiceEngine2.simulate(spiceString);debug10(`Simulation completed, received ${result.simulationResultCircuitJson.length} elements`);let simulationExperiment=root.db.simulation_experiment.list()[0];if(!simulationExperiment){debug10("No simulation experiment found, skipping result insertion");return}for(let element of result.simulationResultCircuitJson){if(element.type==="simulation_transient_voltage_graph"){element.simulation_experiment_id=simulationExperiment.simulation_experiment_id;let probeMatch=voltageProbes.find(p2=>p2.finalProbeName===element.name);probeMatch&&(element.color=probeMatch.color)}let elementType=element.type;elementType&&root.db[elementType]?(root.db[elementType].insert(element),debug10(`Inserted ${elementType} into database`)):(debug10(`Warning: Unknown element type ${elementType}, adding to raw db`),root.db._addElement(element))}group._markDirty("SimulationSpiceEngineRender")}catch(error){debug10(`Simulation failed for engine ${engineName}: ${error}`);let simulationExperiment=root.db.simulation_experiment.list()[0];root.db.simulation_unknown_experiment_error.insert({simulation_experiment_id:simulationExperiment?.simulation_experiment_id,error_type:"simulation_unknown_experiment_error",message:error instanceof Error?error.message:String(error)})}})}}function Group_doInitialPcbComponentAnchorAlignment(group){if(group.root?.pcbDisabled||!group.pcb_group_id)return;let pcbPositionAnchor=group._parsedProps?.pcbPositionAnchor;if(!pcbPositionAnchor)return;let targetPosition=group._getGlobalPcbPositionBeforeLayout(),{pcbX,pcbY}=group._parsedProps;if(pcbX===void 0&&pcbY===void 0)return;let{db:db2}=group.root,pcbGroup=db2.pcb_group.get(group.pcb_group_id);if(!pcbGroup)return;let width=pcbGroup.width,height=pcbGroup.height,{center:center2}=pcbGroup;if(pcbGroup.outline&&pcbGroup.outline.length>0){let bounds2=getBoundsFromPoints(pcbGroup.outline);bounds2&&(width=bounds2.maxX-bounds2.minX,height=bounds2.maxY-bounds2.minY)}if(!width||!height)return;let bounds={left:center2.x-width/2,right:center2.x+width/2,top:center2.y+height/2,bottom:center2.y-height/2},currentCenter={...center2},anchorPos=null;if(new Set(["center","top_left","top_center","top_right","center_left","center_right","bottom_left","bottom_center","bottom_right"]).has(pcbPositionAnchor))switch(pcbPositionAnchor){case"center":anchorPos=currentCenter;break;case"top_left":anchorPos={x:bounds.left,y:bounds.top};break;case"top_center":anchorPos={x:currentCenter.x,y:bounds.top};break;case"top_right":anchorPos={x:bounds.right,y:bounds.top};break;case"center_left":anchorPos={x:bounds.left,y:currentCenter.y};break;case"center_right":anchorPos={x:bounds.right,y:currentCenter.y};break;case"bottom_left":anchorPos={x:bounds.left,y:bounds.bottom};break;case"bottom_center":anchorPos={x:currentCenter.x,y:bounds.bottom};break;case"bottom_right":anchorPos={x:bounds.right,y:bounds.bottom};break}if(!anchorPos)return;let newCenter={...currentCenter};targetPosition.x!==void 0&&(newCenter.x+=targetPosition.x-anchorPos.x),targetPosition.y!==void 0&&(newCenter.y+=targetPosition.y-anchorPos.y),(Math.abs(newCenter.x-currentCenter.x)>1e-6||Math.abs(newCenter.y-currentCenter.y)>1e-6)&&(group._repositionOnPcb(newCenter),db2.pcb_group.update(group.pcb_group_id,{center:newCenter})),db2.pcb_group.update(group.pcb_group_id,{anchor_position:targetPosition,anchor_alignment:pcbPositionAnchor,display_offset_x:pcbX,display_offset_y:pcbY})}function computeCenterFromAnchorPosition(anchorPosition,ctx){let{width,height,pcbAnchorAlignment}=ctx;if(!pcbAnchorAlignment)return anchorPosition;let alignment=pcbAnchorAlignment;if(typeof width!="number"||typeof height!="number")return console.log("width or height is not a number"),anchorPosition;let ax2=anchorPosition.x,ay2=anchorPosition.y;switch(alignment){case"top_left":return{x:ax2+width/2,y:ay2-height/2};case"top_center":return{x:ax2,y:ay2-height/2};case"top_right":return{x:ax2-width/2,y:ay2-height/2};case"center_left":return{x:ax2+width/2,y:ay2};case"center_right":return{x:ax2-width/2,y:ay2};case"bottom_left":return{x:ax2+width/2,y:ay2+height/2};case"bottom_center":return{x:ax2,y:ay2+height/2};case"bottom_right":return{x:ax2-width/2,y:ay2+height/2};default:return anchorPosition}}function groupPadsByInternalConnection(pads,orientation4){let groups=[];for(let pad2 of pads){let key=orientation4==="vertical"?pad2.center.y:pad2.center.x,foundGroup=!1;for(let group of groups){let groupKey=orientation4==="vertical"?group[0].center.y:group[0].center.x;if(Math.abs(key-groupKey)<.01){group.push(pad2),foundGroup=!0;break}}foundGroup||groups.push([pad2])}return groups.filter(g4=>g4.length>=2)}function insertAutoplacedJumpers(params){let{db:db2,output_jumpers,subcircuit_id}=params;for(let jumperIndex=0;jumperIndex<output_jumpers.length;jumperIndex++){let jumper=output_jumpers[jumperIndex],sourceComponent=db2.source_component.insert({ftype:"simple_chip",name:`__autoplaced_jumper_${jumperIndex}`,supplier_part_numbers:{}}),rotation4=jumper.orientation==="horizontal"?0:90,firstPadLayer=jumper.pads[0]?.layer||jumper.pads[0]?.layers?.[0]||"top",pcbComponent=db2.pcb_component.insert({source_component_id:sourceComponent.source_component_id,center:jumper.center,rotation:rotation4,layer:firstPadLayer,width:jumper.width||0,height:jumper.height||0,obstructs_within_bounds:!1}),padData=[];for(let padIndex=0;padIndex<jumper.pads.length;padIndex++){let pad2=jumper.pads[padIndex],pinNumber=padIndex+1,sourcePort=db2.source_port.insert({source_component_id:sourceComponent.source_component_id,name:`pin${pinNumber}`,pin_number:pinNumber}),padLayer=pad2.layer||pad2.layers?.[0]||"top",pcbPort=db2.pcb_port.insert({pcb_component_id:pcbComponent.pcb_component_id,source_port_id:sourcePort.source_port_id,x:pad2.center.x,y:pad2.center.y,layers:[padLayer]}),pcbSmtpad=db2.pcb_smtpad.insert({pcb_component_id:pcbComponent.pcb_component_id,pcb_port_id:pcbPort.pcb_port_id,shape:"rect",x:pad2.center.x,y:pad2.center.y,width:pad2.width,height:pad2.height,layer:padLayer});padData.push({pad:pad2,sourcePortId:sourcePort.source_port_id,pcbSmtpadId:pcbSmtpad.pcb_smtpad_id})}let internalGroups=groupPadsByInternalConnection(jumper.pads,jumper.orientation);for(let group of internalGroups){let sourcePortIds=[];for(let groupPad of group){let padInfo=padData.find(p2=>Math.abs(p2.pad.center.x-groupPad.center.x)<.01&&Math.abs(p2.pad.center.y-groupPad.center.y)<.01);padInfo&&sourcePortIds.push(padInfo.sourcePortId)}sourcePortIds.length>=2&&db2.source_component_internal_connection.insert({source_component_id:sourceComponent.source_component_id,subcircuit_id:subcircuit_id??void 0,source_port_ids:sourcePortIds})}}}function splitPcbTracesOnJumperSegments(route){let jumperRoutes=route.filter(p2=>p2.route_type==="jumper"),wireAndViaRoutes=route.filter(p2=>p2.route_type!=="jumper");if(jumperRoutes.length===0)return null;let splitRanges=[];for(let jumperRoute of jumperRoutes){let jumperStart=jumperRoute.start,jumperEnd=jumperRoute.end,startIdx=-1,endIdx=-1,minStartDist=1/0,minEndDist=1/0;for(let i3=0;i3<wireAndViaRoutes.length;i3++){let p2=wireAndViaRoutes[i3];if(p2.route_type!=="wire")continue;let distToStart=Math.hypot(p2.x-jumperStart.x,p2.y-jumperStart.y),distToEnd=Math.hypot(p2.x-jumperEnd.x,p2.y-jumperEnd.y);distToStart<minStartDist&&(minStartDist=distToStart,startIdx=i3),distToEnd<minEndDist&&(minEndDist=distToEnd,endIdx=i3)}startIdx>endIdx&&([startIdx,endIdx]=[endIdx,startIdx]),startIdx>=0&&endIdx>=0&&startIdx!==endIdx&&splitRanges.push({startIdx,endIdx})}splitRanges.sort((a2,b3)=>a2.startIdx-b3.startIdx);let segments=[],currentStart=0;for(let range2 of splitRanges)currentStart<range2.startIdx&&segments.push(wireAndViaRoutes.slice(currentStart,range2.startIdx+1)),currentStart=range2.endIdx;return currentStart<wireAndViaRoutes.length&&segments.push(wireAndViaRoutes.slice(currentStart)),segments}function getJumperPadInfos(db2){let padInfos=[],jumperSmtpads=db2.pcb_smtpad.list().filter(pad2=>{let component=db2.pcb_component.get(pad2.pcb_component_id);return component?db2.source_component.get(component.source_component_id)?.name?.startsWith("__autoplaced_jumper"):!1});for(let smtpad2 of jumperSmtpads)if(smtpad2.shape!=="polygon"&&smtpad2.pcb_port_id){if(smtpad2.shape==="rect"||smtpad2.shape==="rotated_rect"){let halfWidth=smtpad2.width/2,halfHeight=smtpad2.height/2;padInfos.push({pcb_port_id:smtpad2.pcb_port_id,x:smtpad2.x,y:smtpad2.y,minX:smtpad2.x-halfWidth,maxX:smtpad2.x+halfWidth,minY:smtpad2.y-halfHeight,maxY:smtpad2.y+halfHeight})}else if(smtpad2.shape==="circle"){let radius=smtpad2.radius;padInfos.push({pcb_port_id:smtpad2.pcb_port_id,x:smtpad2.x,y:smtpad2.y,minX:smtpad2.x-radius,maxX:smtpad2.x+radius,minY:smtpad2.y-radius,maxY:smtpad2.y+radius})}}return padInfos}function findJumperPortAtPosition(padInfos,x3,y3,tolerance=.01){for(let pad2 of padInfos)if(Math.abs(pad2.x-x3)<tolerance&&Math.abs(pad2.y-y3)<tolerance)return pad2.pcb_port_id}function findJumperPortContainingPoint(padInfos,x3,y3){for(let pad2 of padInfos)if(x3>=pad2.minX&&x3<=pad2.maxX&&y3>=pad2.minY&&y3<=pad2.maxY)return pad2}function splitRouteAtJumperPads(route,padInfos){if(route.length===0||padInfos.length===0)return[route];let segments=[],currentSegment=[];for(let i3=0;i3<route.length;i3++){let point23=route[i3];if(currentSegment.push(point23),point23.route_type==="wire"&&i3>0&&i3<route.length-1){let padInfo=findJumperPortContainingPoint(padInfos,point23.x,point23.y);if(padInfo){point23.end_pcb_port_id||(point23.end_pcb_port_id=padInfo.pcb_port_id),segments.push(currentSegment);let newStartPoint={...point23};delete newStartPoint.end_pcb_port_id,newStartPoint.start_pcb_port_id||(newStartPoint.start_pcb_port_id=padInfo.pcb_port_id),currentSegment=[newStartPoint]}}}return currentSegment.length>0&&segments.push(currentSegment),segments}function addPortIdsToTracesAtJumperPads(segments,db2){let padInfos=getJumperPadInfos(db2);if(padInfos.length===0)return segments;let result=[];for(let segment2 of segments){let subSegments=splitRouteAtJumperPads(segment2,padInfos);for(let subSegment of subSegments)if(subSegment.length>0){let firstPoint=subSegment[0],lastPoint=subSegment[subSegment.length-1];if(firstPoint.route_type==="wire"&&!firstPoint.start_pcb_port_id){let portId=findJumperPortAtPosition(padInfos,firstPoint.x,firstPoint.y);portId&&(firstPoint.start_pcb_port_id=portId)}if(lastPoint.route_type==="wire"&&!lastPoint.end_pcb_port_id){let portId=findJumperPortAtPosition(padInfos,lastPoint.x,lastPoint.y);portId&&(lastPoint.end_pcb_port_id=portId)}result.push(subSegment)}}return result}var Group6=class extends NormalComponent3{constructor(){super(...arguments);__publicField(this,"pcb_group_id",null);__publicField(this,"schematic_group_id",null);__publicField(this,"subcircuit_id",null);__publicField(this,"_hasStartedAsyncAutorouting",!1);__publicField(this,"_asyncAutoroutingResult",null);__publicField(this,"unnamedElementCounter",{})}get config(){return{zodProps:groupProps,componentName:"Group"}}doInitialSourceGroupRender(){let{db:db2}=this.root,hasExplicitName=typeof this._parsedProps.name=="string"&&this._parsedProps.name.length>0,source_group2=db2.source_group.insert({name:this.name,is_subcircuit:this.isSubcircuit,was_automatically_named:!hasExplicitName});this.source_group_id=source_group2.source_group_id,this.isSubcircuit&&(this.subcircuit_id=`subcircuit_${source_group2.source_group_id}`,db2.source_group.update(source_group2.source_group_id,{subcircuit_id:this.subcircuit_id}))}doInitialSourceRender(){let{db:db2}=this.root;for(let child of this.children)db2.source_component.update(child.source_component_id,{source_group_id:this.source_group_id})}doInitialSourceParentAttachment(){let{db:db2}=this.root,parentGroup=this.parent?.getGroup?.();if(parentGroup?.source_group_id&&db2.source_group.update(this.source_group_id,{parent_source_group_id:parentGroup.source_group_id}),!this.isSubcircuit)return;let parent_subcircuit_id=this.parent?.getSubcircuit?.()?.subcircuit_id;parent_subcircuit_id&&db2.source_group.update(this.source_group_id,{parent_subcircuit_id})}doInitialPcbComponentRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,groupProps2=props,hasOutline=groupProps2.outline&&groupProps2.outline.length>0,numericOutline=hasOutline?groupProps2.outline.map(point23=>({x:distance.parse(point23.x),y:distance.parse(point23.y)})):void 0,ctx=this.props,anchorPosition=this._getGlobalPcbPositionBeforeLayout(),center2=computeCenterFromAnchorPosition(anchorPosition,ctx),pcb_group2=db2.pcb_group.insert({is_subcircuit:this.isSubcircuit,subcircuit_id:this.subcircuit_id??this.getSubcircuit()?.subcircuit_id,name:this.name,anchor_position:anchorPosition,center:center2,...hasOutline?{outline:numericOutline}:{width:0,height:0},pcb_component_ids:[],source_group_id:this.source_group_id,autorouter_configuration:props.autorouter?{trace_clearance:props.autorouter.traceClearance}:void 0,anchor_alignment:props.pcbAnchorAlignment??null});this.pcb_group_id=pcb_group2.pcb_group_id;for(let child of this.children)db2.pcb_component.update(child.pcb_component_id,{pcb_group_id:pcb_group2.pcb_group_id})}doInitialPcbPrimitiveRender(){this.calculatePcbGroupBounds()}calculatePcbGroupBounds(){if(!this.pcb_group_id||this.root?.pcbDisabled)return;let{db:db2}=this.root,props=this._parsedProps,hasOutline=props.outline&&props.outline.length>0,hasExplicitPositioning=this._parsedProps.pcbX!==void 0||this._parsedProps.pcbY!==void 0;if(hasOutline){let numericOutline=props.outline.map(point23=>({x:distance.parse(point23.x),y:distance.parse(point23.y)})),outlineBounds=getBoundsFromPoints(numericOutline);if(!outlineBounds)return;let centerX2=(outlineBounds.minX+outlineBounds.maxX)/2,centerY2=(outlineBounds.minY+outlineBounds.maxY)/2,center22=hasExplicitPositioning?db2.pcb_group.get(this.pcb_group_id)?.center??{x:centerX2,y:centerY2}:{x:centerX2,y:centerY2};db2.pcb_group.update(this.pcb_group_id,{center:center22});return}let bounds=getBoundsOfPcbComponents(this.children),width=bounds.width,height=bounds.height,centerX=(bounds.minX+bounds.maxX)/2,centerY=(bounds.minY+bounds.maxY)/2;if(this.isSubcircuit){let{padLeft,padRight,padTop,padBottom}=this._resolvePcbPadding();width+=padLeft+padRight,height+=padTop+padBottom,centerX+=(padRight-padLeft)/2,centerY+=(padTop-padBottom)/2}let center2=hasExplicitPositioning?db2.pcb_group.get(this.pcb_group_id)?.center??{x:centerX,y:centerY}:{x:centerX,y:centerY};db2.pcb_group.update(this.pcb_group_id,{width:Number(props.width??width),height:Number(props.height??height),center:center2})}updatePcbPrimitiveRender(){this.calculatePcbGroupBounds()}getNextAvailableName(elm){var _a359,_b2;return(_a359=this.unnamedElementCounter)[_b2=elm.lowercaseComponentName]??(_a359[_b2]=1),`unnamed_${elm.lowercaseComponentName}${this.unnamedElementCounter[elm.lowercaseComponentName]++}`}_resolvePcbPadding(){let props=this._parsedProps,layout=props.pcbLayout,getPaddingValue=key=>{let layoutValue=layout?.[key],propsValue=props[key];if(typeof layoutValue=="number")return layoutValue;if(typeof propsValue=="number")return propsValue},generalPadding=getPaddingValue("padding")??0,paddingX=getPaddingValue("paddingX"),paddingY=getPaddingValue("paddingY"),padLeft=getPaddingValue("paddingLeft")??paddingX??generalPadding,padRight=getPaddingValue("paddingRight")??paddingX??generalPadding,padTop=getPaddingValue("paddingTop")??paddingY??generalPadding,padBottom=getPaddingValue("paddingBottom")??paddingY??generalPadding;return{padLeft,padRight,padTop,padBottom}}doInitialCreateTraceHintsFromProps(){let{_parsedProps:props}=this,{db:db2}=this.root,groupProps2=props;if(!this.isSubcircuit)return;let manualTraceHints=groupProps2.manualEdits?.manual_trace_hints;if(manualTraceHints)for(let manualTraceHint of manualTraceHints)this.add(new TraceHint({for:manualTraceHint.pcb_port_selector,offsets:manualTraceHint.offsets}))}doInitialSourceAddConnectivityMapKey(){Group_doInitialSourceAddConnectivityMapKey(this)}_areChildSubcircuitsRouted(){let subcircuitChildren=this.selectAll("group").filter(g4=>g4.isSubcircuit);for(let subcircuitChild of subcircuitChildren)if(subcircuitChild._shouldRouteAsync()&&!subcircuitChild._asyncAutoroutingResult)return!1;return!0}_shouldRouteAsync(){let autorouter=this._getAutorouterConfig();return autorouter.groupMode==="sequential-trace"?!1:!!(autorouter.local&&autorouter.groupMode==="subcircuit"||!autorouter.local)}_hasTracesToRoute(){let debug112=(0,import_debug10.default)("tscircuit:core:_hasTracesToRoute"),traces=this.selectAll("trace");return debug112(`[${this.getString()}] has ${traces.length} traces to route`),traces.length>0}async _runEffectMakeHttpAutoroutingRequest(){let{db:db2}=this.root,debug112=(0,import_debug10.default)("tscircuit:core:_runEffectMakeHttpAutoroutingRequest"),props=this._parsedProps,autorouterConfig2=this._getAutorouterConfig(),serverUrl=autorouterConfig2.serverUrl,serverMode=autorouterConfig2.serverMode,fetchWithDebug=(url,options)=>(debug112("fetching",url),options.headers&&(options.headers["Tscircuit-Core-Version"]=this.root?.getCoreVersion()),fetch(url,options)),pcbAndSourceCircuitJson=this.root.db.toArray().filter(element=>element.type.startsWith("source_")||element.type.startsWith("pcb_"));if(serverMode==="solve-endpoint"){if(this.props.autorouter?.inputFormat==="simplified"){let{autorouting_result:autorouting_result2}=await fetchWithDebug(`${serverUrl}/autorouting/solve`,{method:"POST",body:JSON.stringify({input_simple_route_json:getSimpleRouteJsonFromCircuitJson({db:db2,minTraceWidth:this.props.autorouter?.minTraceWidth??.15,nominalTraceWidth:this.props.nominalTraceWidth,subcircuit_id:this.subcircuit_id}).simpleRouteJson,subcircuit_id:this.subcircuit_id}),headers:{"Content-Type":"application/json"}}).then(r4=>r4.json());this._asyncAutoroutingResult=autorouting_result2,this._markDirty("PcbTraceRender");return}let{autorouting_result}=await fetchWithDebug(`${serverUrl}/autorouting/solve`,{method:"POST",body:JSON.stringify({input_circuit_json:pcbAndSourceCircuitJson,subcircuit_id:this.subcircuit_id}),headers:{"Content-Type":"application/json"}}).then(r4=>r4.json());this._asyncAutoroutingResult=autorouting_result,this._markDirty("PcbTraceRender");return}let{autorouting_job}=await fetchWithDebug(`${serverUrl}/autorouting/jobs/create`,{method:"POST",body:JSON.stringify({input_circuit_json:pcbAndSourceCircuitJson,provider:"freerouting",autostart:!0,display_name:this.root?.name,subcircuit_id:this.subcircuit_id,server_cache_enabled:autorouterConfig2.serverCacheEnabled}),headers:{"Content-Type":"application/json"}}).then(r4=>r4.json());for(;;){let{autorouting_job:job}=await fetchWithDebug(`${serverUrl}/autorouting/jobs/get`,{method:"POST",body:JSON.stringify({autorouting_job_id:autorouting_job.autorouting_job_id}),headers:{"Content-Type":"application/json"}}).then(r4=>r4.json());if(job.is_finished){let{autorouting_job_output}=await fetchWithDebug(`${serverUrl}/autorouting/jobs/get_output`,{method:"POST",body:JSON.stringify({autorouting_job_id:autorouting_job.autorouting_job_id}),headers:{"Content-Type":"application/json"}}).then(r4=>r4.json());this._asyncAutoroutingResult={output_pcb_traces:autorouting_job_output.output_pcb_traces},this._markDirty("PcbTraceRender");break}if(job.has_error){let err=new AutorouterError(`Autorouting job failed: ${JSON.stringify(job.error)}`);throw db2.pcb_autorouting_error.insert({pcb_error_id:autorouting_job.autorouting_job_id,error_type:"pcb_autorouting_error",message:err.message}),err}await new Promise(resolve=>setTimeout(resolve,100))}}async _runLocalAutorouting(){let{db:db2}=this.root,props=this._parsedProps,debug112=(0,import_debug10.default)("tscircuit:core:_runLocalAutorouting");debug112(`[${this.getString()}] starting local autorouting`);let autorouterConfig2=this._getAutorouterConfig(),isLaserPrefabPreset=this._isLaserPrefabAutorouter(autorouterConfig2),isAutoJumperPreset=this._isAutoJumperAutorouter(autorouterConfig2),isSingleLayerBoard=this._getSubcircuitLayerCount()===1,{simpleRouteJson}=getSimpleRouteJsonFromCircuitJson({db:db2,minTraceWidth:this.props.autorouter?.minTraceWidth??.15,nominalTraceWidth:this.props.nominalTraceWidth,subcircuit_id:this.subcircuit_id});if(isAutoJumperPreset&&(simpleRouteJson.allowJumpers=!0),debug112.enabled&&global.debugOutputArray?.push({name:`simpleroutejson-${this.props.name}.json`,obj:simpleRouteJson}),debug112.enabled){let graphicsObject=sn2(simpleRouteJson);graphicsObject.title=`autorouting-${this.props.name}`,global.debugGraphics?.push(graphicsObject)}this.root?.emit("autorouting:start",{subcircuit_id:this.subcircuit_id,componentDisplayName:this.getString(),simpleRouteJson});let autorouter;if(autorouterConfig2.algorithmFn)autorouter=await autorouterConfig2.algorithmFn(simpleRouteJson);else{let autorouterVersion2=this.props.autorouterVersion;autorouter=new TscircuitAutorouter(simpleRouteJson,{capacityDepth:this.props.autorouter?.capacityDepth,targetMinCapacity:this.props.autorouter?.targetMinCapacity,useAssignableSolver:isLaserPrefabPreset||isSingleLayerBoard,useAutoJumperSolver:isAutoJumperPreset,autorouterVersion:autorouterVersion2,onSolverStarted:({solverName,solverParams})=>this.root?.emit("solver:started",{type:"solver:started",solverName,solverParams,componentName:this.getString()})})}let routingPromise=new Promise((resolve,reject)=>{autorouter.on("complete",event=>{debug112(`[${this.getString()}] local autorouting complete`),resolve(event.traces)}),autorouter.on("error",event=>{debug112(`[${this.getString()}] local autorouting error: ${event.error.message}`),reject(event.error)})});autorouter.on("progress",event=>{this.root?.emit("autorouting:progress",{subcircuit_id:this.subcircuit_id,componentDisplayName:this.getString(),...event})}),autorouter.start();try{let traces=await routingPromise;if(autorouter.getConnectedOffboardObstacles){let connectedOffboardObstacles=autorouter.getConnectedOffboardObstacles();createSourceTracesFromOffboardConnections({db:db2,connectedOffboardObstacles,simpleRouteJson,subcircuit_id:this.subcircuit_id})}let outputJumpers=[],solver=autorouter.solver;solver?.getOutputJumpers&&(outputJumpers=solver.getOutputJumpers()||[]),this._asyncAutoroutingResult={output_pcb_traces:traces,output_jumpers:outputJumpers},this._markDirty("PcbTraceRender")}catch(error){let{db:db22}=this.root;throw db22.pcb_autorouting_error.insert({pcb_error_id:`pcb_autorouter_error_subcircuit_${this.subcircuit_id}`,error_type:"pcb_autorouting_error",message:error instanceof Error?error.message:String(error)}),this.root?.emit("autorouting:error",{subcircuit_id:this.subcircuit_id,componentDisplayName:this.getString(),error:{message:error instanceof Error?error.message:String(error)},simpleRouteJson}),error}finally{autorouter.stop()}}_startAsyncAutorouting(){this._hasStartedAsyncAutorouting||(this._hasStartedAsyncAutorouting=!0,this._getAutorouterConfig().local?this._queueAsyncEffect("capacity-mesh-autorouting",async()=>this._runLocalAutorouting()):this._queueAsyncEffect("make-http-autorouting-request",async()=>this._runEffectMakeHttpAutoroutingRequest()))}doInitialPcbTraceRender(){let debug112=(0,import_debug10.default)("tscircuit:core:doInitialPcbTraceRender");if(this.isSubcircuit&&!this.root?.pcbDisabled&&!this.getInheritedProperty("routingDisabled")&&!this._shouldUseTraceByTraceRouting()){if(!this._areChildSubcircuitsRouted()){debug112(`[${this.getString()}] child subcircuits are not routed, skipping async autorouting until subcircuits routed`);return}debug112(`[${this.getString()}] no child subcircuits to wait for, initiating async routing`),this._hasTracesToRoute()&&this._startAsyncAutorouting()}}doInitialSchematicTraceRender(){Group_doInitialSchematicTraceRender(this)}updatePcbTraceRender(){let debug112=(0,import_debug10.default)("tscircuit:core:updatePcbTraceRender");if(debug112(`[${this.getString()}] updating...`),!this.isSubcircuit)return;if(this._shouldRouteAsync()&&this._hasTracesToRoute()&&!this._hasStartedAsyncAutorouting){this._areChildSubcircuitsRouted()&&(debug112(`[${this.getString()}] child subcircuits are now routed, starting async autorouting`),this._startAsyncAutorouting());return}if(!this._asyncAutoroutingResult||this._shouldUseTraceByTraceRouting())return;let{db:db2}=this.root;if(this._asyncAutoroutingResult.output_simple_route_json){debug112(`[${this.getString()}] updating PCB traces from simple route json (${this._asyncAutoroutingResult.output_simple_route_json.traces?.length} traces)`),this._updatePcbTraceRenderFromSimpleRouteJson();return}if(this._asyncAutoroutingResult.output_pcb_traces){debug112(`[${this.getString()}] updating PCB traces from ${this._asyncAutoroutingResult.output_pcb_traces.length} traces`),this._updatePcbTraceRenderFromPcbTraces();return}}_updatePcbTraceRenderFromSimpleRouteJson(){let{db:db2}=this.root,{traces:routedTraces}=this._asyncAutoroutingResult.output_simple_route_json;if(routedTraces)for(let routedTrace of routedTraces){let pcb_trace2=db2.pcb_trace.insert({subcircuit_id:this.subcircuit_id,route:routedTrace.route})}}_updatePcbTraceRenderFromPcbTraces(){let{output_pcb_traces,output_jumpers}=this._asyncAutoroutingResult;if(!output_pcb_traces)return;let{db:db2}=this.root,pcbStyle2=this.getInheritedMergedProperty("pcbStyle"),{holeDiameter,padDiameter}=getViaDiameterDefaults(pcbStyle2);output_jumpers&&output_jumpers.length>0&&insertAutoplacedJumpers({db:db2,output_jumpers,subcircuit_id:this.subcircuit_id});for(let pcb_trace2 of output_pcb_traces){if(pcb_trace2.type!=="pcb_trace")continue;if(pcb_trace2.subcircuit_id=this.subcircuit_id,pcb_trace2.connection_name){let sourceTraceId=pcb_trace2.connection_name;pcb_trace2.source_trace_id=sourceTraceId}let segments=splitPcbTracesOnJumperSegments(pcb_trace2.route);segments===null&&(segments=[pcb_trace2.route]);let processedSegments=addPortIdsToTracesAtJumperPads(segments,db2);for(let segment2 of processedSegments)segment2.length>0&&db2.pcb_trace.insert({...pcb_trace2,route:segment2})}for(let pcb_trace2 of output_pcb_traces)if(pcb_trace2.type!=="pcb_via"&&pcb_trace2.type==="pcb_trace")for(let point23 of pcb_trace2.route)point23.route_type==="via"&&db2.pcb_via.insert({pcb_trace_id:pcb_trace2.pcb_trace_id,x:point23.x,y:point23.y,hole_diameter:holeDiameter,outer_diameter:padDiameter,layers:[point23.from_layer,point23.to_layer],from_layer:point23.from_layer,to_layer:point23.to_layer})}doInitialSchematicComponentRender(){if(this.root?.schematicDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,schematic_group2=db2.schematic_group.insert({is_subcircuit:this.isSubcircuit,subcircuit_id:this.subcircuit_id,name:this.name,center:this._getGlobalSchematicPositionBeforeLayout(),width:0,height:0,schematic_component_ids:[],source_group_id:this.source_group_id});this.schematic_group_id=schematic_group2.schematic_group_id;for(let child of this.children)child.schematic_component_id&&db2.schematic_component.update(child.schematic_component_id,{schematic_group_id:schematic_group2.schematic_group_id})}_getSchematicLayoutMode(){let props=this._parsedProps;if(props.schLayout?.layoutMode==="none"||props.schLayout?.layoutMode==="relative")return"relative";if(props.schLayout?.matchAdapt)return"match-adapt";if(props.schLayout?.flex)return"flex";if(props.schLayout?.grid)return"grid";if(props.schMatchAdapt)return"match-adapt";if(props.schFlex)return"flex";if(props.schGrid)return"grid";if(props.matchAdapt)return"match-adapt";if(props.flex)return"flex";if(props.grid)return"grid";if(props.relative||props.schRelative)return"relative";let anyChildHasSchCoords=this.children.some(child=>{let cProps=child._parsedProps;return cProps?.schX!==void 0||cProps?.schY!==void 0}),hasManualEdits=(props.manualEdits?.schematic_placements?.length??0)>0;return!anyChildHasSchCoords&&!hasManualEdits?"match-adapt":"relative"}doInitialSchematicLayout(){let schematicLayoutMode=this._getSchematicLayoutMode();schematicLayoutMode==="match-adapt"&&this._doInitialSchematicLayoutMatchpack(),schematicLayoutMode==="grid"&&this._doInitialSchematicLayoutGrid(),schematicLayoutMode==="flex"&&this._doInitialSchematicLayoutFlex(),this._insertSchematicBorder()}_doInitialSchematicLayoutMatchAdapt(){Group_doInitialSchematicLayoutMatchAdapt(this)}_doInitialSchematicLayoutMatchpack(){Group_doInitialSchematicLayoutMatchPack(this)}_doInitialSchematicLayoutGrid(){Group_doInitialSchematicLayoutGrid(this)}_doInitialSchematicLayoutFlex(){Group_doInitialSchematicLayoutFlex(this)}_getPcbLayoutMode(){let props=this._parsedProps;if(props.pcbRelative)return"none";if(props.pcbLayout?.matchAdapt)return"match-adapt";if(props.pcbLayout?.flex)return"flex";if(props.pcbLayout?.grid)return"grid";if(props.pcbLayout?.pack)return"pack";if(props.pcbFlex)return"flex";if(props.pcbGrid)return"grid";if(props.pcbPack||props.pack)return"pack";if(props.matchAdapt)return"match-adapt";if(props.flex)return"flex";if(props.grid)return"grid";let groupHasCoords=props.pcbX!==void 0||props.pcbY!==void 0,hasManualEdits=(props.manualEdits?.pcb_placements?.length??0)>0,unpositionedDirectChildrenCount=this.children.reduce((count,child)=>{if(!child.pcb_component_id&&!child.pcb_group_id)return count;let childProps=child._parsedProps,hasCoords=childProps?.pcbX!==void 0||childProps?.pcbY!==void 0;return count+(hasCoords?0:1)},0);return!hasManualEdits&&unpositionedDirectChildrenCount>1?"pack":"none"}doInitialPcbLayout(){if(this.root?.pcbDisabled)return;if(this.pcb_group_id){let{db:db2}=this.root,props=this._parsedProps;if(props.pcbX!==void 0||props.pcbY!==void 0){let parentGroup=this.parent?.getGroup?.(),pcbParentGroupId=parentGroup?.pcb_group_id?db2.pcb_group.get(parentGroup.pcb_group_id)?.pcb_group_id:void 0,positionedRelativeToBoardId=pcbParentGroupId?void 0:this._getBoard()?.pcb_board_id??void 0;db2.pcb_group.update(this.pcb_group_id,{position_mode:"relative_to_group_anchor",positioned_relative_to_pcb_group_id:pcbParentGroupId,positioned_relative_to_pcb_board_id:positionedRelativeToBoardId,display_offset_x:props.pcbX,display_offset_y:props.pcbY})}}let pcbLayoutMode=this._getPcbLayoutMode();pcbLayoutMode==="grid"?this._doInitialPcbLayoutGrid():pcbLayoutMode==="pack"?this._doInitialPcbLayoutPack():pcbLayoutMode==="flex"&&this._doInitialPcbLayoutFlex()}_doInitialPcbLayoutGrid(){Group_doInitialPcbLayoutGrid(this)}_doInitialPcbLayoutPack(){Group_doInitialPcbLayoutPack(this)}_doInitialPcbLayoutFlex(){Group_doInitialPcbLayoutFlex(this)}_insertSchematicBorder(){if(this.root?.schematicDisabled)return;let{db:db2}=this.root,props=this._parsedProps;if(!props.border)return;let width=typeof props.schWidth=="number"?props.schWidth:void 0,height=typeof props.schHeight=="number"?props.schHeight:void 0,paddingGeneral=typeof props.schPadding=="number"?props.schPadding:0,paddingLeft=typeof props.schPaddingLeft=="number"?props.schPaddingLeft:paddingGeneral,paddingRight=typeof props.schPaddingRight=="number"?props.schPaddingRight:paddingGeneral,paddingTop=typeof props.schPaddingTop=="number"?props.schPaddingTop:paddingGeneral,paddingBottom=typeof props.schPaddingBottom=="number"?props.schPaddingBottom:paddingGeneral,schematicGroup=this.schematic_group_id?db2.schematic_group.get(this.schematic_group_id):null;if(schematicGroup&&(width===void 0&&typeof schematicGroup.width=="number"&&(width=schematicGroup.width),height===void 0&&typeof schematicGroup.height=="number"&&(height=schematicGroup.height)),width===void 0||height===void 0)return;let center2=schematicGroup?.center??this._getGlobalSchematicPositionBeforeLayout(),left=center2.x-width/2-paddingLeft,bottom=center2.y-height/2-paddingBottom,finalWidth=width+paddingLeft+paddingRight,finalHeight=height+paddingTop+paddingBottom;db2.schematic_box.insert({width:finalWidth,height:finalHeight,x:left,y:bottom,is_dashed:props.border?.dashed??!1})}_determineSideFromPosition(port,component){if(!port.center||!component.center)return"left";let dx2=port.center.x-component.center.x,dy2=port.center.y-component.center.y;return Math.abs(dx2)>Math.abs(dy2)?dx2>0?"right":"left":dy2>0?"bottom":"top"}_calculateSchematicBounds(boxes){if(boxes.length===0)return{minX:0,maxX:0,minY:0,maxY:0};let minX=1/0,maxX=-1/0,minY=1/0,maxY=-1/0;for(let box2 of boxes)minX=Math.min(minX,box2.centerX),maxX=Math.max(maxX,box2.centerX),minY=Math.min(minY,box2.centerY),maxY=Math.max(maxY,box2.centerY);let padding=2;return{minX:minX-padding,maxX:maxX+padding,minY:minY-padding,maxY:maxY+padding}}_getAutorouterConfig(){let autorouter=this._parsedProps.autorouter||this.getInheritedProperty("autorouter");return getPresetAutoroutingConfig(autorouter)}_isLaserPrefabAutorouter(autorouterConfig2=this._getAutorouterConfig()){let autorouterProp2=this.props.autorouter,normalize3=value=>value?.replace(/-/g,"_")??value;return autorouterConfig2.preset==="laser_prefab"?!0:typeof autorouterProp2=="string"?normalize3(autorouterProp2)==="laser_prefab":typeof autorouterProp2=="object"&&autorouterProp2?normalize3(autorouterProp2.preset)==="laser_prefab":!1}_isAutoJumperAutorouter(autorouterConfig2=this._getAutorouterConfig()){let autorouterProp2=this.props.autorouter,normalize3=value=>value?.replace(/-/g,"_")??value;return autorouterConfig2.preset==="auto_jumper"?!0:typeof autorouterProp2=="string"?normalize3(autorouterProp2)==="auto_jumper":typeof autorouterProp2=="object"&&autorouterProp2?normalize3(autorouterProp2.preset)==="auto_jumper":!1}_getSubcircuitLayerCount(){let layers=this.getInheritedProperty("layers");return typeof layers=="number"?layers:2}_shouldUseTraceByTraceRouting(){return this._getAutorouterConfig().groupMode==="sequential-trace"}doInitialPcbDesignRuleChecks(){if(this.root?.pcbDisabled||this.getInheritedProperty("routingDisabled"))return;let{db:db2}=this.root;if(this.isSubcircuit){let subcircuitComponentsByName=new Map;for(let child of this.children)if(!child.isSubcircuit&&child._parsedProps.name){let components=subcircuitComponentsByName.get(child._parsedProps.name)||[];components.push(child),subcircuitComponentsByName.set(child._parsedProps.name,components)}for(let[name,components]of subcircuitComponentsByName.entries())components.length>1&&db2.pcb_trace_error.insert({error_type:"pcb_trace_error",message:`Multiple components found with name "${name}" in subcircuit "${this.name||"unnamed"}". Component names must be unique within a subcircuit.`,source_trace_id:"",pcb_trace_id:"",pcb_component_ids:components.map(c3=>c3.pcb_component_id).filter(Boolean),pcb_port_ids:[]})}}doInitialSchematicReplaceNetLabelsWithSymbols(){if(this.root?.schematicDisabled||!this.isSubcircuit)return;let{db:db2}=this.root,subtree=db2;for(let nl2 of subtree.schematic_net_label.list()){let net=subtree.source_net.get(nl2.source_net_id),text=nl2.text||net?.name||"";if(nl2.anchor_side==="top"&&/^gnd/i.test(text)){subtree.schematic_net_label.update(nl2.schematic_net_label_id,{symbol_name:"rail_down"});continue}nl2.anchor_side==="bottom"&&/^v/i.test(text)&&subtree.schematic_net_label.update(nl2.schematic_net_label_id,{symbol_name:"rail_up"})}}doInitialSimulationSpiceEngineRender(){Group_doInitialSimulationSpiceEngineRender(this)}doInitialPcbComponentAnchorAlignment(){Group_doInitialPcbComponentAnchorAlignment(this)}updatePcbComponentAnchorAlignment(){this.doInitialPcbComponentAnchorAlignment()}_getMinimumFlexContainerSize(){return super._getMinimumFlexContainerSize()}_repositionOnPcb(position2){return super._repositionOnPcb(position2)}};function inflatePcbBoard(pcbBoard,inflatorContext){let{subcircuit}=inflatorContext;if(subcircuit.lowercaseComponentName==="board"||subcircuit.parent?.lowercaseComponentName==="board")return;let boardProps2={name:"inflated_board"};pcbBoard.width&&(boardProps2.width=pcbBoard.width),pcbBoard.height&&(boardProps2.height=pcbBoard.height),pcbBoard.center&&(boardProps2.pcbX=pcbBoard.center.x,boardProps2.pcbY=pcbBoard.center.y),pcbBoard.outline&&(boardProps2.outline=pcbBoard.outline),pcbBoard.thickness&&(boardProps2.thickness=pcbBoard.thickness),pcbBoard.material&&(boardProps2.material=pcbBoard.material);let board=new Board(boardProps2);return board.pcb_board_id=pcbBoard.pcb_board_id,subcircuit.add(board),board}var stringProxy=new Proxy({},{get:(target,prop)=>prop}),FTYPE=stringProxy,SCHEMATIC_COMPONENT_OUTLINE_COLOR="rgba(132, 0, 0)",SCHEMATIC_COMPONENT_OUTLINE_STROKE_WIDTH=.12,Capacitor=class extends NormalComponent3{constructor(){super(...arguments);__publicField(this,"_adjustSilkscreenTextAutomatically",!0)}get config(){return{componentName:"Capacitor",schematicSymbolName:this.props.polarized?"capacitor_polarized":this.props.symbolName??"capacitor",zodProps:capacitorProps,sourceFtype:FTYPE.simple_capacitor}}initPorts(){typeof this.props.footprint=="string"?super.initPorts({additionalAliases:{pin1:["anode","pos"],pin2:["cathode","neg"]}}):super.initPorts()}_getSchematicSymbolDisplayValue(){let inputCapacitance=this.props.capacitance,capacitanceDisplay=typeof inputCapacitance=="string"?inputCapacitance:`${formatSiUnit(this._parsedProps.capacitance)}F`;return this._parsedProps.schShowRatings&&this._parsedProps.maxVoltageRating?`${capacitanceDisplay}/${formatSiUnit(this._parsedProps.maxVoltageRating)}V`:capacitanceDisplay}doInitialCreateNetsFromProps(){this._createNetsFromProps([this.props.decouplingFor,this.props.decouplingTo,...this._getNetsFromConnectionsProp()])}doInitialCreateTracesFromProps(){this.props.decouplingFor&&this.props.decouplingTo&&(this.add(new Trace3({from:`${this.getSubcircuitSelector()} > port.1`,to:this.props.decouplingFor})),this.add(new Trace3({from:`${this.getSubcircuitSelector()} > port.2`,to:this.props.decouplingTo}))),this._createTracesFromConnectionsProp()}doInitialSourceRender(){let{db:db2}=this.root,{_parsedProps:props}=this,source_component=db2.source_component.insert({ftype:"simple_capacitor",name:this.name,manufacturer_part_number:props.manufacturerPartNumber??props.mfn,supplier_part_numbers:props.supplierPartNumbers,capacitance:props.capacitance,max_voltage_rating:props.maxVoltageRating,max_decoupling_trace_length:props.maxDecouplingTraceLength,display_capacitance:this._getSchematicSymbolDisplayValue(),are_pins_interchangeable:!props.polarized});this.source_component_id=source_component.source_component_id}},inflatePcbComponent=(pcbElm,inflatorContext)=>{let{injectionDb,normalComponent}=inflatorContext;if(!normalComponent)return;let componentCenter=pcbElm.center||{x:0,y:0},componentRotation=pcbElm.rotation||0,absoluteToComponentRelativeTransform=inverse(compose(translate(componentCenter.x,componentCenter.y),rotate(componentRotation*Math.PI/180))),relativeElements=injectionDb.toArray().filter(elm=>"pcb_component_id"in elm&&elm.pcb_component_id===pcbElm.pcb_component_id),clonedRelativeElements=structuredClone(relativeElements);transformPCBElements(clonedRelativeElements,absoluteToComponentRelativeTransform);let components=createComponentsFromCircuitJson({componentName:normalComponent.name,componentRotation:"0deg"},clonedRelativeElements);normalComponent.addAll(components)};function inflateSourceCapacitor(sourceElm,inflatorContext){let{injectionDb,subcircuit,groupsMap}=inflatorContext,pcbElm=injectionDb.pcb_component.getWhere({source_component_id:sourceElm.source_component_id}),cadElm=injectionDb.cad_component.getWhere({source_component_id:sourceElm.source_component_id}),capacitor=new Capacitor({name:sourceElm.name,capacitance:sourceElm.capacitance,layer:pcbElm?.layer,pcbX:pcbElm?.center?.x,pcbY:pcbElm?.center?.y,pcbRotation:pcbElm?.rotation,doNotPlace:pcbElm?.do_not_place,obstructsWithinBounds:pcbElm?.obstructs_within_bounds});pcbElm&&inflatePcbComponent(pcbElm,{...inflatorContext,normalComponent:capacitor}),sourceElm.source_group_id&&groupsMap?.has(sourceElm.source_group_id)?groupsMap.get(sourceElm.source_group_id).add(capacitor):subcircuit.add(capacitor)}var Chip=class extends NormalComponent3{constructor(props){super(props);__publicField(this,"schematicBoxDimensions",null)}get config(){return{componentName:"Chip",zodProps:chipProps,shouldRenderAsSchematicBox:!0}}initPorts(opts={}){super.initPorts(opts);let{_parsedProps:props}=this,{pcbX,pcbY}=this.getResolvedPcbPositionProp();if(props.externallyConnectedPins){let requiredPorts=new Set;for(let[pin1,pin2]of props.externallyConnectedPins)requiredPorts.add(pin1),requiredPorts.add(pin2);for(let pinIdentifier of requiredPorts)if(!this.children.find(child=>child instanceof Port&&child.isMatchingAnyOf([pinIdentifier]))){let pinMatch=pinIdentifier.match(/^pin(\d+)$/);if(pinMatch){let pinNumber=parseInt(pinMatch[1]);this.add(new Port({pinNumber,aliases:[pinIdentifier]}))}else this.add(new Port({name:pinIdentifier,aliases:[pinIdentifier]}))}}}doInitialSchematicComponentRender(){let{_parsedProps:props}=this;props?.noSchematicRepresentation!==!0&&super.doInitialSchematicComponentRender()}doInitialSourceRender(){let{db:db2}=this.root,{_parsedProps:props}=this,{pcbX,pcbY}=this.getResolvedPcbPositionProp(),source_component=db2.source_component.insert({ftype:"simple_chip",name:this.name,manufacturer_part_number:props.manufacturerPartNumber,supplier_part_numbers:props.supplierPartNumbers});this.source_component_id=source_component.source_component_id}doInitialPcbComponentRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,{pcbX,pcbY}=this.getResolvedPcbPositionProp(),componentLayer=props.layer??"top";if(componentLayer!=="top"&&componentLayer!=="bottom"){let subcircuit=this.getSubcircuit(),error=pcb_component_invalid_layer_error.parse({type:"pcb_component_invalid_layer_error",message:`Component cannot be placed on layer '${componentLayer}'. Components can only be placed on 'top' or 'bottom' layers.`,source_component_id:this.source_component_id,layer:componentLayer,subcircuit_id:subcircuit.subcircuit_id??void 0});db2.pcb_component_invalid_layer_error.insert(error)}let pcb_component2=db2.pcb_component.insert({center:{x:pcbX,y:pcbY},width:2,height:3,layer:componentLayer==="top"||componentLayer==="bottom"?componentLayer:"top",rotation:props.pcbRotation??0,source_component_id:this.source_component_id,subcircuit_id:this.getSubcircuit().subcircuit_id??void 0,do_not_place:props.doNotPlace??!1,obstructs_within_bounds:props.obstructsWithinBounds??!0});this.pcb_component_id=pcb_component2.pcb_component_id}doInitialCreateTracesFromProps(){let{_parsedProps:props}=this;if(props.externallyConnectedPins)for(let[pin1,pin2]of props.externallyConnectedPins)this.add(new Trace3({from:`${this.getSubcircuitSelector()} > port.${pin1}`,to:`${this.getSubcircuitSelector()} > port.${pin2}`}));this._createTracesFromConnectionsProp()}doInitialSimulationRender(){let{db:db2}=this.root,{pinAttributes}=this.props;if(!pinAttributes)return;let powerPort=null,groundPort=null,voltage2,ports=this.selectAll("port");for(let port of ports)for(let alias of port.getNameAndAliases())if(pinAttributes[alias]){let attributes2=pinAttributes[alias];attributes2.providesPower&&(powerPort=port,voltage2=attributes2.providesVoltage),attributes2.providesGround&&(groundPort=port)}if(!powerPort||!groundPort||voltage2===void 0)return;let powerSourcePort=db2.source_port.get(powerPort.source_port_id);if(!powerSourcePort?.subcircuit_connectivity_map_key)return;let groundSourcePort=db2.source_port.get(groundPort.source_port_id);if(!groundSourcePort?.subcircuit_connectivity_map_key)return;let powerNet=db2.source_net.getWhere({subcircuit_connectivity_map_key:powerSourcePort.subcircuit_connectivity_map_key}),groundNet=db2.source_net.getWhere({subcircuit_connectivity_map_key:groundSourcePort.subcircuit_connectivity_map_key});!powerNet||!groundNet||db2.simulation_voltage_source.insert({type:"simulation_voltage_source",positive_source_port_id:powerPort.source_port_id,positive_source_net_id:powerNet.source_net_id,negative_source_port_id:groundPort.source_port_id,negative_source_net_id:groundNet.source_net_id,voltage:voltage2})}},mapInternallyConnectedSourcePortIdsToPinLabels=(sourcePortIds,inflatorContext)=>{if(!sourcePortIds||sourcePortIds.length===0)return;let{injectionDb}=inflatorContext,mapped=sourcePortIds.map(group=>group.map(sourcePortId=>{let port=injectionDb.source_port.get(sourcePortId);return port?port.pin_number!==void 0&&port.pin_number!==null?`pin${port.pin_number}`:port.name:null}).filter(value=>value!==null)).filter(group=>group.length>0);return mapped.length>0?mapped:void 0},inflateSourceChip=(sourceElm,inflatorContext)=>{let{injectionDb,subcircuit,groupsMap}=inflatorContext,pcbElm=injectionDb.pcb_component.getWhere({source_component_id:sourceElm.source_component_id}),schematicElm=injectionDb.schematic_component.getWhere({source_component_id:sourceElm.source_component_id}),cadElm=injectionDb.cad_component.getWhere({source_component_id:sourceElm.source_component_id}),internallyConnectedPins=mapInternallyConnectedSourcePortIdsToPinLabels(sourceElm.internally_connected_source_port_ids,inflatorContext),chip=new Chip({name:sourceElm.name,manufacturerPartNumber:sourceElm.manufacturer_part_number,supplierPartNumbers:sourceElm.supplier_part_numbers??void 0,pinLabels:schematicElm?.port_labels??void 0,schWidth:schematicElm?.size?.width,schHeight:schematicElm?.size?.height,schPinSpacing:schematicElm?.pin_spacing,schX:schematicElm?.center?.x,schY:schematicElm?.center?.y,layer:pcbElm?.layer,pcbX:pcbElm?.center?.x,pcbY:pcbElm?.center?.y,pcbRotation:pcbElm?.rotation,doNotPlace:pcbElm?.do_not_place,obstructsWithinBounds:pcbElm?.obstructs_within_bounds,internallyConnectedPins}),footprint=cadElm?.footprinter_string??null;footprint&&(Object.assign(chip.props,{footprint}),Object.assign(chip._parsedProps,{footprint}),cadElm||chip._addChildrenFromStringFootprint?.()),pcbElm&&inflatePcbComponent(pcbElm,{...inflatorContext,normalComponent:chip}),sourceElm.source_group_id&&groupsMap?.has(sourceElm.source_group_id)?groupsMap.get(sourceElm.source_group_id).add(chip):subcircuit.add(chip)},Diode=class extends NormalComponent3{constructor(){super(...arguments);__publicField(this,"pos",this.portMap.pin1);__publicField(this,"anode",this.portMap.pin1);__publicField(this,"neg",this.portMap.pin2);__publicField(this,"cathode",this.portMap.pin2)}get config(){let symbolMap={schottky:"schottky_diode",avalanche:"avalanche_diode",zener:"zener_diode",photodiode:"photodiode"},variantSymbol=this.props.schottky?"schottky":this.props.avalanche?"avalanche":this.props.zener?"zener":this.props.photo?"photodiode":null;return{schematicSymbolName:variantSymbol?symbolMap[variantSymbol]:this.props.symbolName??"diode",componentName:"Diode",zodProps:diodeProps,sourceFtype:"simple_diode"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}doInitialSourceRender(){let{db:db2}=this.root,{_parsedProps:props}=this,source_component=db2.source_component.insert({ftype:"simple_diode",name:this.name,manufacturer_part_number:props.manufacturerPartNumber??props.mfn,supplier_part_numbers:props.supplierPartNumbers,are_pins_interchangeable:!1});this.source_component_id=source_component.source_component_id}};function inflateSourceDiode(sourceElm,inflatorContext){let{injectionDb,subcircuit,groupsMap}=inflatorContext,pcbElm=injectionDb.pcb_component.getWhere({source_component_id:sourceElm.source_component_id}),cadElm=injectionDb.cad_component.getWhere({source_component_id:sourceElm.source_component_id}),diode2=new Diode({name:sourceElm.name,layer:pcbElm?.layer,pcbX:pcbElm?.center?.x,pcbY:pcbElm?.center?.y,pcbRotation:pcbElm?.rotation,doNotPlace:pcbElm?.do_not_place,obstructsWithinBounds:pcbElm?.obstructs_within_bounds});pcbElm&&inflatePcbComponent(pcbElm,{...inflatorContext,normalComponent:diode2}),sourceElm.source_group_id&&groupsMap?.has(sourceElm.source_group_id)?groupsMap.get(sourceElm.source_group_id).add(diode2):subcircuit.add(diode2)}function inflateSourceGroup(sourceGroup,inflatorContext){let{subcircuit,groupsMap}=inflatorContext,group=new Group6({name:sourceGroup.name??`inflated_group_${sourceGroup.source_group_id}`});return group.source_group_id=sourceGroup.source_group_id,groupsMap&&groupsMap.set(sourceGroup.source_group_id,group),sourceGroup.parent_source_group_id&&groupsMap?.has(sourceGroup.parent_source_group_id)?groupsMap.get(sourceGroup.parent_source_group_id).add(group):subcircuit.add(group),group}var Inductor=class extends NormalComponent3{constructor(){super(...arguments);__publicField(this,"_adjustSilkscreenTextAutomatically",!0)}get config(){return{componentName:"Inductor",schematicSymbolName:this.props.symbolName??"inductor",zodProps:inductorProps,sourceFtype:FTYPE.simple_inductor}}_getSchematicSymbolDisplayValue(){return`${formatSiUnit(this._parsedProps.inductance)}H`}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}doInitialSourceRender(){let{db:db2}=this.root,{_parsedProps:props}=this,source_component=db2.source_component.insert({name:this.name,ftype:FTYPE.simple_inductor,inductance:this.props.inductance,display_inductance:this._getSchematicSymbolDisplayValue(),supplier_part_numbers:props.supplierPartNumbers,are_pins_interchangeable:!0});this.source_component_id=source_component.source_component_id}};function inflateSourceInductor(sourceElm,inflatorContext){let{injectionDb,subcircuit,groupsMap}=inflatorContext,pcbElm=injectionDb.pcb_component.getWhere({source_component_id:sourceElm.source_component_id}),cadElm=injectionDb.cad_component.getWhere({source_component_id:sourceElm.source_component_id}),inductor=new Inductor({name:sourceElm.name,inductance:sourceElm.inductance,layer:pcbElm?.layer,pcbX:pcbElm?.center?.x,pcbY:pcbElm?.center?.y,pcbRotation:pcbElm?.rotation,doNotPlace:pcbElm?.do_not_place,obstructsWithinBounds:pcbElm?.obstructs_within_bounds});pcbElm&&inflatePcbComponent(pcbElm,{...inflatorContext,normalComponent:inductor}),sourceElm.source_group_id&&groupsMap?.has(sourceElm.source_group_id)?groupsMap.get(sourceElm.source_group_id).add(inductor):subcircuit.add(inductor)}function inflateSourcePort(sourcePort,inflatorContext){let{injectionDb,subcircuit}=inflatorContext;if(sourcePort.source_component_id!==null)return;let pcbPortFromInjection=injectionDb.pcb_port.getWhere({source_port_id:sourcePort.source_port_id}),port=new Port({name:sourcePort.name,pinNumber:sourcePort.pin_number});subcircuit.add(port),port.source_port_id=sourcePort.source_port_id;let root=subcircuit.root;if(root&&pcbPortFromInjection){let{db:db2}=root,pcb_port2=db2.pcb_port.insert({pcb_component_id:void 0,layers:pcbPortFromInjection.layers,subcircuit_id:subcircuit.subcircuit_id??void 0,pcb_group_id:subcircuit.getGroup()?.pcb_group_id??void 0,x:pcbPortFromInjection.x,y:pcbPortFromInjection.y,source_port_id:sourcePort.source_port_id,is_board_pinout:!1});port.pcb_port_id=pcb_port2.pcb_port_id}}var Resistor=class extends NormalComponent3{constructor(){super(...arguments);__publicField(this,"_adjustSilkscreenTextAutomatically",!0)}get config(){return{componentName:"Resistor",schematicSymbolName:this.props.symbolName??"boxresistor",zodProps:resistorProps,sourceFtype:"simple_resistor"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}_getSchematicSymbolDisplayValue(){return`${formatSiUnit(this._parsedProps.resistance)}\u03A9`}doInitialCreateNetsFromProps(){this._createNetsFromProps([this.props.pullupFor,this.props.pullupTo,this.props.pulldownFor,this.props.pulldownTo,...this._getNetsFromConnectionsProp()])}doInitialCreateTracesFromProps(){this.props.pullupFor&&this.props.pullupTo&&(this.add(new Trace3({from:`${this.getSubcircuitSelector()} > port.1`,to:this.props.pullupFor})),this.add(new Trace3({from:`${this.getSubcircuitSelector()} > port.2`,to:this.props.pullupTo}))),this.props.pulldownFor&&this.props.pulldownTo&&(this.add(new Trace3({from:`${this.getSubcircuitSelector()} > port.1`,to:this.props.pulldownFor})),this.add(new Trace3({from:`${this.getSubcircuitSelector()} > port.2`,to:this.props.pulldownTo}))),this._createTracesFromConnectionsProp()}doInitialSourceRender(){let{db:db2}=this.root,{_parsedProps:props}=this,source_component=db2.source_component.insert({ftype:"simple_resistor",name:this.name,manufacturer_part_number:props.manufacturerPartNumber??props.mfn,supplier_part_numbers:props.supplierPartNumbers,resistance:props.resistance,display_resistance:this._getSchematicSymbolDisplayValue(),are_pins_interchangeable:!0});this.source_component_id=source_component.source_component_id}};function inflateSourceResistor(sourceElm,inflatorContext){let{injectionDb,subcircuit,groupsMap}=inflatorContext,pcbElm=injectionDb.pcb_component.getWhere({source_component_id:sourceElm.source_component_id}),cadElm=injectionDb.cad_component.getWhere({source_component_id:sourceElm.source_component_id}),resistor=new Resistor({name:sourceElm.name,resistance:sourceElm.resistance,layer:pcbElm?.layer,pcbX:pcbElm?.center?.x,pcbY:pcbElm?.center?.y,pcbRotation:pcbElm?.rotation,doNotPlace:pcbElm?.do_not_place,obstructsWithinBounds:pcbElm?.obstructs_within_bounds});pcbElm&&inflatePcbComponent(pcbElm,{...inflatorContext,normalComponent:resistor}),sourceElm.source_group_id&&groupsMap?.has(sourceElm.source_group_id)?groupsMap.get(sourceElm.source_group_id).add(resistor):subcircuit.add(resistor)}var getSelectorPath=(component,inflatorContext)=>{let{injectionDb,subcircuit,groupsMap}=inflatorContext,path_parts=[],currentGroupId=component.source_group_id;for(;currentGroupId&&currentGroupId!==subcircuit.source_group_id;){let sourceGroup=injectionDb.source_group.get(currentGroupId),groupInstance=groupsMap?.get(currentGroupId);if(!sourceGroup||!groupInstance)break;let groupName=groupInstance.props.name??groupInstance.fallbackUnassignedName;path_parts.unshift(`.${groupName}`),currentGroupId=sourceGroup.parent_source_group_id}return path_parts.push(`.${component.name}`),path_parts.join(" > ")};function inflateSourceTrace(sourceTrace,inflatorContext){let{injectionDb,subcircuit}=inflatorContext,connectedSelectors=[];for(let sourcePortId of sourceTrace.connected_source_port_ids){let sourcePort=injectionDb.source_port.get(sourcePortId);if(!sourcePort)continue;let selector;if(sourcePort.source_component_id){let sourceComponent=injectionDb.source_component.get(sourcePort.source_component_id);sourceComponent&&(selector=`${getSelectorPath({name:sourceComponent.name,source_group_id:sourceComponent.source_group_id},inflatorContext)} > .${sourcePort.name}`)}else selector=`.${sourcePort.name}`;selector&&connectedSelectors.push(selector)}for(let sourceNetId of sourceTrace.connected_source_net_ids){let sourceNet=injectionDb.source_net.get(sourceNetId);sourceNet&&connectedSelectors.push(`net.${sourceNet.name}`)}if(connectedSelectors.length<2)return;let trace=new Trace3({path:connectedSelectors});trace.source_trace_id=sourceTrace.source_trace_id,subcircuit.add(trace)}var Transistor=class extends NormalComponent3{constructor(){super(...arguments);__publicField(this,"emitter",this.portMap.pin1);__publicField(this,"collector",this.portMap.pin2);__publicField(this,"base",this.portMap.pin3)}get config(){let baseSymbolName=this.props.type==="npn"?"npn_bipolar_transistor":"pnp_bipolar_transistor";return{componentName:"Transistor",schematicSymbolName:this.props.symbolName??baseSymbolName,zodProps:transistorProps,sourceFtype:"simple_transistor",shouldRenderAsSchematicBox:!1}}initPorts(){let pinAliases={pin1:["collector","c"],pin2:["emitter","e"],pin3:["base","b"]};super.initPorts({pinCount:3,additionalAliases:pinAliases})}doInitialCreateNetsFromProps(){this._createNetsFromProps([...this._getNetsFromConnectionsProp()])}doInitialCreateTracesFromProps(){this._createTracesFromConnectionsProp()}doInitialSourceRender(){let{db:db2}=this.root,{_parsedProps:props}=this,source_component=db2.source_component.insert({ftype:"simple_transistor",name:this.name,transistor_type:props.type});this.source_component_id=source_component.source_component_id}};function inflateSourceTransistor(sourceElm,inflatorContext){let{injectionDb,subcircuit,groupsMap}=inflatorContext,pcbElm=injectionDb.pcb_component.getWhere({source_component_id:sourceElm.source_component_id}),cadElm=injectionDb.cad_component.getWhere({source_component_id:sourceElm.source_component_id}),transistor=new Transistor({name:sourceElm.name,type:sourceElm.transistor_type,layer:pcbElm?.layer,pcbX:pcbElm?.center?.x,pcbY:pcbElm?.center?.y,pcbRotation:pcbElm?.rotation,doNotPlace:pcbElm?.do_not_place,obstructsWithinBounds:pcbElm?.obstructs_within_bounds});pcbElm&&inflatePcbComponent(pcbElm,{...inflatorContext,normalComponent:transistor}),sourceElm.source_group_id&&groupsMap?.has(sourceElm.source_group_id)?groupsMap.get(sourceElm.source_group_id).add(transistor):subcircuit.add(transistor)}var inflateCircuitJson=(target,circuitJson,children)=>{if(!circuitJson)return;let injectionDb=cju_default(circuitJson);if(circuitJson&&children?.length>0)throw new Error("Component cannot have both circuitJson and children");let inflationCtx={injectionDb,subcircuit:target,groupsMap:new Map},sourceGroups=injectionDb.source_group.list();for(let sourceGroup of sourceGroups)inflateSourceGroup(sourceGroup,inflationCtx);let pcbBoards=injectionDb.pcb_board.list();for(let pcbBoard of pcbBoards)inflatePcbBoard(pcbBoard,inflationCtx);let sourceComponents=injectionDb.source_component.list();for(let sourceComponent of sourceComponents)switch(sourceComponent.ftype){case"simple_resistor":inflateSourceResistor(sourceComponent,inflationCtx);break;case"simple_capacitor":inflateSourceCapacitor(sourceComponent,inflationCtx);break;case"simple_inductor":inflateSourceInductor(sourceComponent,inflationCtx);break;case"simple_diode":inflateSourceDiode(sourceComponent,inflationCtx);break;case"simple_chip":inflateSourceChip(sourceComponent,inflationCtx);break;case"simple_transistor":inflateSourceTransistor(sourceComponent,inflationCtx);break;default:throw new Error(`No inflator implemented for source component ftype: "${sourceComponent.ftype}"`)}let sourcePorts=injectionDb.source_port.list();for(let sourcePort of sourcePorts)inflateSourcePort(sourcePort,inflationCtx);let sourceTraces=injectionDb.source_trace.list();for(let sourceTrace of sourceTraces)inflateSourceTrace(sourceTrace,inflationCtx)},MIN_EFFECTIVE_BORDER_RADIUS_MM=.01,getRoundedRectOutline=(width,height,radius)=>{let w22=width/2,h2=height/2,r4=Math.min(radius,w22,h2);if(r4<MIN_EFFECTIVE_BORDER_RADIUS_MM)return[{x:-w22,y:-h2},{x:w22,y:-h2},{x:w22,y:h2},{x:-w22,y:h2}];let segments=Math.max(1,Math.ceil(Math.PI/2*r4/.1)),step=Math.PI/2/segments,outline=[];outline.push({x:-w22+r4,y:-h2}),outline.push({x:w22-r4,y:-h2});for(let i3=1;i3<=segments;i3++){let theta=-Math.PI/2+i3*step;outline.push({x:w22-r4+r4*Math.cos(theta),y:-h2+r4+r4*Math.sin(theta)})}outline.push({x:w22,y:h2-r4});for(let i3=1;i3<=segments;i3++){let theta=0+i3*step;outline.push({x:w22-r4+r4*Math.cos(theta),y:h2-r4+r4*Math.sin(theta)})}outline.push({x:-w22+r4,y:h2});for(let i3=1;i3<=segments;i3++){let theta=Math.PI/2+i3*step;outline.push({x:-w22+r4+r4*Math.cos(theta),y:h2-r4+r4*Math.sin(theta)})}outline.push({x:-w22,y:-h2+r4});for(let i3=1;i3<=segments;i3++){let theta=Math.PI+i3*step;outline.push({x:-w22+r4+r4*Math.cos(theta),y:-h2+r4+r4*Math.sin(theta)})}return outline},Board=class extends Group6{constructor(){super(...arguments);__publicField(this,"pcb_board_id",null);__publicField(this,"source_board_id",null);__publicField(this,"_drcChecksComplete",!1);__publicField(this,"_connectedSchematicPortPairs",new Set)}get isSubcircuit(){return!0}get isGroup(){return!0}get config(){return{componentName:"Board",zodProps:boardProps}}get boardThickness(){return this._parsedProps.thickness??1.4}get allLayers(){let layerCount=this._parsedProps.layers??2;return layerCount===1?["top"]:layerCount===4?["top","bottom","inner1","inner2"]:["top","bottom"]}_getSubcircuitLayerCount(){return this._parsedProps.layers??2}_getBoardCalcVariables(){let{_parsedProps:props}=this;if((props.width==null||props.height==null)&&!props.outline)return{};let dbBoard=this.pcb_board_id?this.root?.db.pcb_board.get(this.pcb_board_id):null,width=dbBoard?.width??props.width,height=dbBoard?.height??props.height;if((width==null||height==null)&&props.outline?.length){let outlineBounds=getBoundsFromPoints(props.outline);outlineBounds&&(width??(width=outlineBounds.maxX-outlineBounds.minX),height??(height=outlineBounds.maxY-outlineBounds.minY))}let{pcbX,pcbY}=this.getResolvedPcbPositionProp(),center2=dbBoard?.center??{x:pcbX+(props.outlineOffsetX??0),y:pcbY+(props.outlineOffsetY??0)},resolvedWidth=width??0,resolvedHeight=height??0;return{"board.minx":center2.x-resolvedWidth/2,"board.maxx":center2.x+resolvedWidth/2,"board.miny":center2.y-resolvedHeight/2,"board.maxy":center2.y+resolvedHeight/2}}doInitialPcbBoardAutoSize(){if(this.root?.pcbDisabled||!this.pcb_board_id)return;let{db:db2}=this.root,{_parsedProps:props}=this,globalPos=this._getGlobalPcbPositionBeforeLayout(),pcbBoard=db2.pcb_board.get(this.pcb_board_id);if(pcbBoard?.width&&pcbBoard?.height||pcbBoard?.outline&&pcbBoard.outline.length>0)return;let minX=1/0,minY=1/0,maxX=-1/0,maxY=-1/0,descendantIds=getDescendantSubcircuitIds(db2,this.subcircuit_id),allowedSubcircuitIds=new Set([this.subcircuit_id,...descendantIds]),allPcbComponents=db2.pcb_component.list().filter(c3=>c3.subcircuit_id&&allowedSubcircuitIds.has(c3.subcircuit_id)),allPcbGroups=db2.pcb_group.list().filter(g4=>g4.subcircuit_id&&allowedSubcircuitIds.has(g4.subcircuit_id)),hasComponents=!1,updateBounds=(center22,width,height)=>{width===0||height===0||(hasComponents=!0,minX=Math.min(minX,center22.x-width/2),minY=Math.min(minY,center22.y-height/2),maxX=Math.max(maxX,center22.x+width/2),maxY=Math.max(maxY,center22.y+height/2))};for(let pcbComponent of allPcbComponents)updateBounds(pcbComponent.center,pcbComponent.width,pcbComponent.height);for(let pcbGroup of allPcbGroups){let width=pcbGroup.width??0,height=pcbGroup.height??0;if(pcbGroup.outline&&pcbGroup.outline.length>0){let bounds=getBoundsFromPoints(pcbGroup.outline);bounds&&(width=bounds.maxX-bounds.minX,height=bounds.maxY-bounds.minY)}updateBounds(pcbGroup.center,width,height)}if(props.boardAnchorPosition){let{x:x3,y:y3}=props.boardAnchorPosition;minX=Math.min(minX,x3),minY=Math.min(minY,y3),maxX=Math.max(maxX,x3),maxY=Math.max(maxY,y3)}let padding=2,computedWidth=hasComponents?maxX-minX+padding*2:0,computedHeight=hasComponents?maxY-minY+padding*2:0,center2={x:hasComponents?(minX+maxX)/2+(props.outlineOffsetX??0):(props.outlineOffsetX??0)+globalPos.x,y:hasComponents?(minY+maxY)/2+(props.outlineOffsetY??0):(props.outlineOffsetY??0)+globalPos.y},finalWidth=props.width??computedWidth,finalHeight=props.height??computedHeight,outline=props.outline;!outline&&props.borderRadius!=null&&finalWidth>0&&finalHeight>0&&(outline=getRoundedRectOutline(finalWidth,finalHeight,props.borderRadius));let update={width:finalWidth,height:finalHeight,center:center2};outline&&(update.outline=outline.map(point23=>({x:point23.x+(props.outlineOffsetX??0),y:point23.y+(props.outlineOffsetY??0)}))),db2.pcb_board.update(this.pcb_board_id,update)}updatePcbBoardAutoSize(){this.doInitialPcbBoardAutoSize()}_addBoardInformationToSilkscreen(){let platform=this.root?.platform;if(!platform?.printBoardInformationToSilkscreen)return;let pcbBoard=this.root.db.pcb_board.get(this.pcb_board_id);if(!pcbBoard)return;let boardInformation=[];if(platform.projectName&&boardInformation.push(platform.projectName),platform.version&&boardInformation.push(`v${platform.version}`),platform.url&&boardInformation.push(platform.url),boardInformation.length===0)return;let text=boardInformation.join(`
615
- `),position2={x:pcbBoard.center.x+pcbBoard.width/2-.25,y:pcbBoard.center.y-pcbBoard.height/2+1};this.root.db.pcb_silkscreen_text.insert({pcb_component_id:this.pcb_board_id,layer:"top",font:"tscircuit2024",font_size:.45,text,ccw_rotation:0,anchor_alignment:"bottom_right",anchor_position:position2})}doInitialSourceRender(){let nestedBoard=this.getDescendants().find(d3=>d3.lowercaseComponentName==="board");if(nestedBoard)throw new Error(`Nested boards are not supported: found board "${nestedBoard.name}" inside board "${this.name}"`);super.doInitialSourceRender();let{db:db2}=this.root,source_board2=db2.source_board.insert({source_group_id:this.source_group_id,title:this.props.title||this.props.name});this.source_board_id=source_board2.source_board_id}doInitialInflateSubcircuitCircuitJson(){let{circuitJson,children}=this._parsedProps;inflateCircuitJson(this,circuitJson,children)}doInitialPcbComponentRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,pcbBoardFromCircuitJson=props.circuitJson?.find(elm=>elm.type==="pcb_board"),computedWidth=props.width??pcbBoardFromCircuitJson?.width??0,computedHeight=props.height??pcbBoardFromCircuitJson?.height??0,globalPos=this._getGlobalPcbPositionBeforeLayout(),center2={x:globalPos.x+(props.outlineOffsetX??0),y:globalPos.y+(props.outlineOffsetY??0)},{boardAnchorPosition,boardAnchorAlignment}=props;if(boardAnchorPosition&&(center2=getBoardCenterFromAnchor({boardAnchorPosition,boardAnchorAlignment:boardAnchorAlignment??"center",width:computedWidth,height:computedHeight})),props.outline){let xValues=props.outline.map(point23=>point23.x),yValues=props.outline.map(point23=>point23.y),minX=Math.min(...xValues),maxX=Math.max(...xValues),minY=Math.min(...yValues),maxY=Math.max(...yValues);computedWidth=maxX-minX,computedHeight=maxY-minY}let outline=props.outline;!outline&&props.borderRadius!=null&&computedWidth>0&&computedHeight>0&&(outline=getRoundedRectOutline(computedWidth,computedHeight,props.borderRadius));let pcb_board2=db2.pcb_board.insert({source_board_id:this.source_board_id,center:center2,thickness:this.boardThickness,num_layers:this.allLayers.length,width:computedWidth,height:computedHeight,outline:outline?.map(point23=>({x:point23.x+(props.outlineOffsetX??0),y:point23.y+(props.outlineOffsetY??0)})),material:props.material});this.pcb_board_id=pcb_board2.pcb_board_id,this._addBoardInformationToSilkscreen()}removePcbComponentRender(){let{db:db2}=this.root;this.pcb_board_id&&(db2.pcb_board.delete(this.pcb_board_id),this.pcb_board_id=null)}doInitialPcbDesignRuleChecks(){this.root?.pcbDisabled||this.getInheritedProperty("routingDisabled")||super.doInitialPcbDesignRuleChecks()}updatePcbDesignRuleChecks(){if(this.root?.pcbDisabled||this.getInheritedProperty("routingDisabled"))return;let{db:db2}=this.root;if(!this._areChildSubcircuitsRouted()||this._drcChecksComplete)return;this._drcChecksComplete=!0;let errors=checkEachPcbTraceNonOverlapping(db2.toArray());for(let error of errors)db2.pcb_trace_error.insert(error);let pcbPortNotConnectedErrors=checkEachPcbPortConnectedToPcbTraces(db2.toArray());for(let error of pcbPortNotConnectedErrors)db2.pcb_port_not_connected_error.insert(error);let pcbComponentOutsideErrors=checkPcbComponentsOutOfBoard(db2.toArray());for(let error of pcbComponentOutsideErrors)db2.pcb_component_outside_board_error.insert(error);let pcbTracesOutOfBoardErrors=checkPcbTracesOutOfBoard(db2.toArray());for(let error of pcbTracesOutOfBoardErrors)db2.pcb_trace_error.insert(error);let differentNetViaErrors=checkDifferentNetViaSpacing(db2.toArray());for(let error of differentNetViaErrors)db2.pcb_via_clearance_error.insert(error);let sameNetViaErrors=checkSameNetViaSpacing(db2.toArray());for(let error of sameNetViaErrors)db2.pcb_via_clearance_error.insert(error);let pcbComponentOverlapErrors=checkPcbComponentOverlap(db2.toArray());for(let error of pcbComponentOverlapErrors)db2.pcb_footprint_overlap_error.insert(error);let sourcePinMustBeConnectedErrors=checkPinMustBeConnected(db2.toArray());for(let error of sourcePinMustBeConnectedErrors)db2.source_pin_must_be_connected_error.insert(error)}_emitRenderLifecycleEvent(phase,startOrEnd){super._emitRenderLifecycleEvent(phase,startOrEnd),startOrEnd==="start"&&this.root?.emit("board:renderPhaseStarted",{renderId:this._renderId,phase})}_repositionOnPcb(position2){let{db:db2}=this.root,pcbBoard=this.pcb_board_id?db2.pcb_board.get(this.pcb_board_id):null,oldPos=pcbBoard?.center;if(!oldPos){this.pcb_board_id&&db2.pcb_board.update(this.pcb_board_id,{center:position2});return}let deltaX=position2.x-oldPos.x,deltaY=position2.y-oldPos.y;if(!(Math.abs(deltaX)<1e-6&&Math.abs(deltaY)<1e-6)){for(let child of this.children)if(child instanceof NormalComponent3){let childOldCenter;if(child.pcb_component_id){let comp=db2.pcb_component.get(child.pcb_component_id);comp&&(childOldCenter=comp.center)}else if(child instanceof Group6&&child.pcb_group_id){let group=db2.pcb_group.get(child.pcb_group_id);group&&(childOldCenter=group.center)}childOldCenter&&child._repositionOnPcb({x:childOldCenter.x+deltaX,y:childOldCenter.y+deltaY})}else child.isPcbPrimitive&&"_moveCircuitJsonElements"in child&&typeof child._moveCircuitJsonElements=="function"&&child._moveCircuitJsonElements({deltaX,deltaY});if(this.pcb_board_id&&(db2.pcb_board.update(this.pcb_board_id,{center:position2}),pcbBoard?.outline)){let outlineBounds=getBoundsFromPoints(pcbBoard.outline);if(outlineBounds){let oldOutlineCenter={x:(outlineBounds.minX+outlineBounds.maxX)/2,y:(outlineBounds.minY+outlineBounds.maxY)/2},outlineDeltaX=position2.x-oldOutlineCenter.x,outlineDeltaY=position2.y-oldOutlineCenter.y,newOutline=pcbBoard.outline.map(p2=>({x:p2.x+outlineDeltaX,y:p2.y+outlineDeltaY}));db2.pcb_board.update(this.pcb_board_id,{outline:newOutline})}}}}},DEFAULT_TAB_LENGTH=5,DEFAULT_TAB_WIDTH=2,generateCutoutsAndMousebitesForOutline=(outline,options)=>{let{gapLength,cutoutWidth,mouseBites,mouseBiteHoleDiameter,mouseBiteHoleSpacing}=options,tabCutouts=[],mouseBiteHoles=[];if(outline.length<2)return{tabCutouts,mouseBiteHoles};let outlinePolygon=new Polygon$1(outline.map(p2=>point4(p2.x,p2.y))),is_ccw;if(outline.length>2){let p02=point4(outline[0].x,outline[0].y),p12=point4(outline[1].x,outline[1].y),segmentDir=vector$1(p02,p12).normalize(),normalToLeft=segmentDir.rotate(Math.PI/2),testPoint=p02.translate(segmentDir.multiply(segment(p02,p12).length/2)).translate(normalToLeft.multiply(.01));is_ccw=outlinePolygon.contains(testPoint)}else is_ccw=outlinePolygon.area()>0;for(let i3=0;i3<outline.length;i3++){let p1_=outline[i3],p2_=outline[(i3+1)%outline.length];if(!p1_||!p2_)continue;let p12=point4(p1_.x,p1_.y),p2=point4(p2_.x,p2_.y),segment2=segment(p12,p2),segmentLength=segment2.length;if(segmentLength<1e-6)continue;let segmentVec=vector$1(p12,p2),segmentDir=segmentVec.normalize(),normalVec=segmentDir.rotate(Math.PI/2),testPoint=segment2.middle().translate(normalVec.multiply(.01));outlinePolygon.contains(testPoint)&&(normalVec=normalVec.multiply(-1));let numBitesInGap=2,totalBitesLength=numBitesInGap*mouseBiteHoleDiameter+(numBitesInGap-1)*mouseBiteHoleSpacing,effectiveGapLength;mouseBites?effectiveGapLength=totalBitesLength:effectiveGapLength=gapLength,effectiveGapLength=Math.min(effectiveGapLength,segmentLength*.9);let gapStartDist=(segmentLength-effectiveGapLength)/2,gapEndDist=gapStartDist+effectiveGapLength;if(mouseBites){let holeAndSpacing=mouseBiteHoleDiameter+mouseBiteHoleSpacing;if(effectiveGapLength>=totalBitesLength&&holeAndSpacing>0){let firstBiteCenterOffsetInGap=(effectiveGapLength-totalBitesLength)/2+mouseBiteHoleDiameter/2,firstBiteDistFromP1=gapStartDist+firstBiteCenterOffsetInGap;for(let k4=0;k4<numBitesInGap;k4++){let biteDist=firstBiteDistFromP1+k4*holeAndSpacing,pos=p12.translate(segmentDir.multiply(biteDist));mouseBiteHoles.push({x:pos.x,y:pos.y})}}}let p_prev_=outline[(i3-1+outline.length)%outline.length],p_next_=outline[(i3+2)%outline.length],start_ext=0,end_ext=0;if(p_prev_&&p_next_){let vec_in_p1=vector$1(point4(p_prev_.x,p_prev_.y),p12),p1_cross=vec_in_p1.cross(segmentVec),is_p1_convex=is_ccw?p1_cross>1e-9:p1_cross<-1e-9,vec_out_p2=vector$1(p2,point4(p_next_.x,p_next_.y)),p2_cross=segmentVec.cross(vec_out_p2),is_p2_convex=is_ccw?p2_cross>1e-9:p2_cross<-1e-9;if(is_p1_convex){let angle=vec_in_p1.angleTo(segmentVec);angle>Math.PI&&(angle=2*Math.PI-angle),start_ext=cutoutWidth*Math.tan(angle/2)}else start_ext=0;if(is_p2_convex){let angle=segmentVec.angleTo(vec_out_p2);angle>Math.PI&&(angle=2*Math.PI-angle),end_ext=cutoutWidth*Math.tan(angle/2)}else end_ext=0}let cutoutParts=[{start:0-start_ext,end:gapStartDist},{start:gapEndDist,end:segmentLength+end_ext}],extrusion=normalVec.multiply(cutoutWidth);for(let part of cutoutParts){let partLength=part.end-part.start;if(partLength<1e-6)continue;let center2=p12.translate(segmentDir.multiply(part.start+partLength/2)).translate(extrusion.multiply(.5)),width=partLength,height=cutoutWidth,rotationDeg=segmentDir.slope*180/Math.PI;tabCutouts.push({type:"pcb_cutout",shape:"rect",center:{x:center2.x,y:center2.y},width,height,rotation:rotationDeg,corner_radius:cutoutWidth/2})}}return{tabCutouts,mouseBiteHoles}};function generatePanelTabsAndMouseBites(boards,options){let finalTabCutouts=[],allMouseBites=[],{tabWidth,tabLength,mouseBites:useMouseBites}=options,processedBoards=boards.map(board=>{if((!board.outline||board.outline.length===0)&&board.width&&board.height){let w22=board.width/2,h2=board.height/2;return{...board,outline:[{x:board.center.x-w22,y:board.center.y-h2},{x:board.center.x+w22,y:board.center.y-h2},{x:board.center.x+w22,y:board.center.y+h2},{x:board.center.x-w22,y:board.center.y+h2}]}}return board});for(let board of processedBoards)if(board.outline&&board.outline.length>0){let mouseBiteDiameter2=tabWidth*.45,mouseBiteSpacing=mouseBiteDiameter2*.1,generated=generateCutoutsAndMousebitesForOutline(board.outline,{gapLength:tabLength,cutoutWidth:tabWidth,mouseBites:useMouseBites,mouseBiteHoleDiameter:mouseBiteDiameter2,mouseBiteHoleSpacing:mouseBiteSpacing});finalTabCutouts.push(...generated.tabCutouts),allMouseBites.push(...generated.mouseBiteHoles)}let tabCutouts=finalTabCutouts.map((tab,index)=>({...tab,pcb_cutout_id:`panel_tab_${index}`})),mouseBiteDiameter=tabWidth*.45,mouseBiteHoles=allMouseBites.map((bite,index)=>({type:"pcb_hole",pcb_hole_id:`panel_mouse_bite_${index}`,hole_shape:"circle",hole_diameter:mouseBiteDiameter,x:bite.x,y:bite.y}));return{tabCutouts,mouseBiteHoles}}var packBoardsIntoGrid=({boards,db:db2,row,col,cellWidth,cellHeight,boardGap})=>{let boardsWithDims=boards.map(board=>{let pcbBoard=db2.pcb_board.get(board.pcb_board_id);return!pcbBoard||pcbBoard.width===void 0||pcbBoard.height===void 0?null:{board,width:pcbBoard.width,height:pcbBoard.height}}).filter(b3=>b3!==null);if(boardsWithDims.length===0)return{positions:[],gridWidth:0,gridHeight:0};let explicitRow=row,cols=col??Math.ceil(explicitRow?boardsWithDims.length/explicitRow:Math.sqrt(boardsWithDims.length)),rows=explicitRow??Math.ceil(boardsWithDims.length/cols),colWidths=Array(cols).fill(0),rowHeights=Array(rows).fill(0);boardsWithDims.forEach((b3,i3)=>{let col2=i3%cols,row2=Math.floor(i3/cols);row2<rowHeights.length&&b3.height>rowHeights[row2]&&(rowHeights[row2]=b3.height),col2<colWidths.length&&b3.width>colWidths[col2]&&(colWidths[col2]=b3.width)});let minCellWidth=cellWidth?distance.parse(cellWidth):0,minCellHeight=cellHeight?distance.parse(cellHeight):0;for(let i3=0;i3<colWidths.length;i3++)colWidths[i3]=Math.max(colWidths[i3],minCellWidth);for(let i3=0;i3<rowHeights.length;i3++)rowHeights[i3]=Math.max(rowHeights[i3],minCellHeight);let totalGridWidth=colWidths.reduce((a2,b3)=>a2+b3,0)+(cols>1?(cols-1)*boardGap:0),totalGridHeight=rowHeights.reduce((a2,b3)=>a2+b3,0)+(rows>1?(rows-1)*boardGap:0),startX=-totalGridWidth/2,rowYOffsets=[-totalGridHeight/2];for(let i3=1;i3<rows;i3++)rowYOffsets.push(rowYOffsets[i3-1]+rowHeights[i3-1]+boardGap);let colXOffsets=[startX];for(let i3=1;i3<cols;i3++)colXOffsets.push(colXOffsets[i3-1]+colWidths[i3-1]+boardGap);let positions=[];return boardsWithDims.forEach((b3,i3)=>{let col2=i3%cols,row2=Math.floor(i3/cols);if(row2>=rowYOffsets.length||col2>=colXOffsets.length)return;let cellX=colXOffsets[col2],cellY=rowYOffsets[row2],cellWidth2=colWidths[col2],cellHeight2=rowHeights[row2],boardX=cellX+cellWidth2/2,boardY=cellY+cellHeight2/2;positions.push({board:b3.board,pos:{x:boardX,y:boardY}})}),{positions,gridWidth:totalGridWidth,gridHeight:totalGridHeight}},Panel=class extends Group6{constructor(){super(...arguments);__publicField(this,"pcb_panel_id",null);__publicField(this,"_tabsAndMouseBitesGenerated",!1)}get config(){return{componentName:"Panel",zodProps:panelProps}}get isGroup(){return!0}get isSubcircuit(){return!0}add(component){if(component.lowercaseComponentName!=="board")throw new Error("<panel> can only contain <board> elements");super.add(component)}doInitialPanelLayout(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,childBoardInstances=this.children.filter(c3=>c3 instanceof Board),hasAnyPositionedBoards=childBoardInstances.some(b3=>b3.props.pcbX!==void 0||b3.props.pcbY!==void 0),unpositionedBoards=childBoardInstances.filter(b3=>b3.props.pcbX===void 0&&b3.props.pcbY===void 0);if(unpositionedBoards.length>0&&!hasAnyPositionedBoards){let tabWidth=this._parsedProps.tabWidth??DEFAULT_TAB_WIDTH,boardGap=this._parsedProps.boardGap??tabWidth,{positions,gridWidth,gridHeight}=packBoardsIntoGrid({boards:unpositionedBoards,db:db2,row:this._parsedProps.row,col:this._parsedProps.col,cellWidth:this._parsedProps.cellWidth,cellHeight:this._parsedProps.cellHeight,boardGap}),panelGlobalPos=this._getGlobalPcbPositionBeforeLayout();for(let{board,pos}of positions){let absoluteX=panelGlobalPos.x+pos.x,absoluteY=panelGlobalPos.y+pos.y;board._repositionOnPcb({x:absoluteX,y:absoluteY}),db2.pcb_board.update(board.pcb_board_id,{center:{x:absoluteX,y:absoluteY},position_mode:"relative_to_panel_anchor",display_offset_x:`${pos.x}mm`,display_offset_y:`${pos.y}mm`})}let hasExplicitWidth=this._parsedProps.width!==void 0,hasExplicitHeight=this._parsedProps.height!==void 0;if(hasExplicitWidth&&hasExplicitHeight)db2.pcb_panel.update(this.pcb_panel_id,{width:distance.parse(this._parsedProps.width),height:distance.parse(this._parsedProps.height)});else if(gridWidth>0||gridHeight>0){let{edgePadding:edgePaddingProp,edgePaddingLeft:edgePaddingLeftProp,edgePaddingRight:edgePaddingRightProp,edgePaddingTop:edgePaddingTopProp,edgePaddingBottom:edgePaddingBottomProp}=this._parsedProps,edgePadding=distance.parse(edgePaddingProp??5),edgePaddingLeft=distance.parse(edgePaddingLeftProp??edgePadding),edgePaddingRight=distance.parse(edgePaddingRightProp??edgePadding),edgePaddingTop=distance.parse(edgePaddingTopProp??edgePadding),edgePaddingBottom=distance.parse(edgePaddingBottomProp??edgePadding);db2.pcb_panel.update(this.pcb_panel_id,{width:hasExplicitWidth?distance.parse(this._parsedProps.width):gridWidth+edgePaddingLeft+edgePaddingRight,height:hasExplicitHeight?distance.parse(this._parsedProps.height):gridHeight+edgePaddingTop+edgePaddingBottom})}}else{let panelGlobalPos=this._getGlobalPcbPositionBeforeLayout();for(let board of childBoardInstances){let boardDb=db2.pcb_board.get(board.pcb_board_id);if(!boardDb)continue;let relativeX=boardDb.center.x-panelGlobalPos.x,relativeY=boardDb.center.y-panelGlobalPos.y;db2.pcb_board.update(board.pcb_board_id,{position_mode:"relative_to_panel_anchor",display_offset_x:`${relativeX}mm`,display_offset_y:`${relativeY}mm`})}}if(this._tabsAndMouseBitesGenerated)return;let props=this._parsedProps;if((props.panelizationMethod??"none")!=="none"){let childBoardIds=childBoardInstances.map(c3=>c3.pcb_board_id).filter(id2=>!!id2),boardsInPanel=db2.pcb_board.list().filter(b3=>childBoardIds.includes(b3.pcb_board_id));if(boardsInPanel.length===0)return;let tabWidth=props.tabWidth??DEFAULT_TAB_WIDTH,boardGap=props.boardGap??tabWidth,{tabCutouts,mouseBiteHoles}=generatePanelTabsAndMouseBites(boardsInPanel,{boardGap,tabWidth,tabLength:props.tabLength??DEFAULT_TAB_LENGTH,mouseBites:props.mouseBites??!0});for(let tabCutout of tabCutouts)db2.pcb_cutout.insert(tabCutout);for(let mouseBiteHole of mouseBiteHoles)db2.pcb_hole.insert(mouseBiteHole)}this._tabsAndMouseBitesGenerated=!0}runRenderCycle(){if(!this.children.some(child=>child.componentName==="Board"))throw new Error("<panel> must contain at least one <board>");super.runRenderCycle()}doInitialPcbComponentRender(){if(super.doInitialPcbComponentRender(),this.root?.pcbDisabled)return;let{db:db2}=this.root,props=this._parsedProps,inserted=db2.pcb_panel.insert({width:props.width!==void 0?distance.parse(props.width):0,height:props.height!==void 0?distance.parse(props.height):0,center:this._getGlobalPcbPositionBeforeLayout(),covered_with_solder_mask:!(props.noSolderMask??!1)});this.pcb_panel_id=inserted.pcb_panel_id}updatePcbComponentRender(){if(this.root?.pcbDisabled||!this.pcb_panel_id)return;let{db:db2}=this.root,props=this._parsedProps,currentPanel=db2.pcb_panel.get(this.pcb_panel_id);db2.pcb_panel.update(this.pcb_panel_id,{width:props.width!==void 0?distance.parse(props.width):currentPanel?.width,height:props.height!==void 0?distance.parse(props.height):currentPanel?.height,center:this._getGlobalPcbPositionBeforeLayout(),covered_with_solder_mask:!(props.noSolderMask??!1)})}removePcbComponentRender(){this.pcb_panel_id&&(this.root?.db.pcb_panel.delete(this.pcb_panel_id),this.pcb_panel_id=null)}},Pinout=class extends Chip{constructor(props){super(props)}get config(){return{...super.config,componentName:"Pinout",zodProps:pinoutProps}}doInitialSourceRender(){let{db:db2}=this.root,{_parsedProps:props}=this,source_component=db2.source_component.insert({ftype:"simple_pinout",name:this.name,manufacturer_part_number:props.manufacturerPartNumber,supplier_part_numbers:props.supplierPartNumbers});this.source_component_id=source_component.source_component_id}},Fuse=class extends NormalComponent3{get config(){return{componentName:"fuse",schematicSymbolName:this.props.symbolName??"fuse",zodProps:fuseProps,sourceFtype:FTYPE.simple_fuse}}_getSchematicSymbolDisplayValue(){let rawCurrent=this._parsedProps.currentRating,rawVoltage=this._parsedProps.voltageRating,current2=typeof rawCurrent=="string"?parseFloat(rawCurrent):rawCurrent,voltage2=typeof rawVoltage=="string"?parseFloat(rawVoltage):rawVoltage;return`${formatSiUnit(current2)}A / ${formatSiUnit(voltage2)}V`}doInitialSourceRender(){let{db:db2}=this.root,{_parsedProps:props}=this,currentRating=typeof props.currentRating=="string"?parseFloat(props.currentRating):props.currentRating,voltageRating=typeof props.voltageRating=="string"?parseFloat(props.voltageRating):props.voltageRating,source_component=db2.source_component.insert({name:this.name,ftype:FTYPE.simple_fuse,current_rating_amps:currentRating,voltage_rating_volts:voltageRating,display_current_rating:`${formatSiUnit(currentRating)}A`,display_voltage_rating:`${formatSiUnit(voltageRating)}V`});this.source_component_id=source_component.source_component_id}},Jumper=class extends NormalComponent3{constructor(){super(...arguments);__publicField(this,"schematicDimensions",null)}get config(){return{schematicSymbolName:void 0,componentName:"Jumper",zodProps:jumperProps,shouldRenderAsSchematicBox:!0}}_getSchematicPortArrangement(){let arrangement=super._getSchematicPortArrangement();if(arrangement&&Object.keys(arrangement).length>0)return arrangement;let pinCount=this._parsedProps.pinCount??(Array.isArray(this._parsedProps.pinLabels)?this._parsedProps.pinLabels.length:this._parsedProps.pinLabels?Object.keys(this._parsedProps.pinLabels).length:this.getPortsFromFootprint().length),direction2=this._parsedProps.schDirection??"right";return{leftSize:direction2==="left"?pinCount:0,rightSize:direction2==="right"?pinCount:0}}doInitialSourceRender(){let{db:db2}=this.root,{_parsedProps:props}=this,{pcbX,pcbY}=this.getResolvedPcbPositionProp(),source_component=db2.source_component.insert({ftype:"simple_chip",name:this.name,manufacturer_part_number:props.manufacturerPartNumber,supplier_part_numbers:props.supplierPartNumbers,are_pins_interchangeable:!0});this.source_component_id=source_component.source_component_id}doInitialPcbComponentRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,{pcbX,pcbY}=this.getResolvedPcbPositionProp(),pcb_component2=db2.pcb_component.insert({center:{x:pcbX,y:pcbY},width:2,height:3,layer:props.layer??"top",rotation:props.pcbRotation??0,source_component_id:this.source_component_id,subcircuit_id:this.getSubcircuit().subcircuit_id??void 0,do_not_place:props.doNotPlace??!1,obstructs_within_bounds:props.obstructsWithinBounds??!0});this.pcb_component_id=pcb_component2.pcb_component_id}doInitialPcbTraceRender(){let{db:db2}=this.root,pcb_ports=db2.pcb_port.list({pcb_component_id:this.pcb_component_id}),pinLabelToPortId={};for(let i3=0;i3<pcb_ports.length;i3++){let port=pcb_ports[i3],sourcePort=db2.source_port.get(port.source_port_id),pinLabel="";if(typeof sourcePort?.pin_number=="number")pinLabel=sourcePort.pin_number.toString();else if(Array.isArray(sourcePort?.port_hints)){let matchedHint=sourcePort.port_hints.find(h2=>/^(pin)?\d+$/.test(h2));matchedHint&&(/^pin\d+$/.test(matchedHint)?pinLabel=matchedHint.replace(/^pin/,""):pinLabel=matchedHint)}pinLabelToPortId[pinLabel]=port.pcb_port_id}let traces=db2.pcb_trace.list({pcb_component_id:this.pcb_component_id}),updatePortId=portId=>{if(portId&&typeof portId=="string"&&portId.startsWith("{PIN")){let pin=portId.replace("{PIN","").replace("}","");return pinLabelToPortId[pin]||portId}return portId};for(let trace of traces)if(trace.route)for(let segment2 of trace.route)segment2.route_type==="wire"&&(segment2.start_pcb_port_id=updatePortId(segment2.start_pcb_port_id),segment2.end_pcb_port_id=updatePortId(segment2.end_pcb_port_id))}},INTERCONNECT_STANDARD_FOOTPRINTS={"0402":"0402","0603":"0603","0805":"0805",1206:"1206"},Interconnect=class extends NormalComponent3{get config(){return{componentName:"Interconnect",zodProps:interconnectProps,shouldRenderAsSchematicBox:!0,sourceFtype:"interconnect"}}get defaultInternallyConnectedPinNames(){let{standard}=this._parsedProps;return standard&&INTERCONNECT_STANDARD_FOOTPRINTS[standard]?[["pin1","pin2"]]:[]}_getImpliedFootprintString(){let{standard}=this._parsedProps;return standard?INTERCONNECT_STANDARD_FOOTPRINTS[standard]??null:null}doInitialSourceRender(){let{db:db2}=this.root,source_component=db2.source_component.insert({ftype:"interconnect",name:this.name,are_pins_interchangeable:!0});this.source_component_id=source_component.source_component_id}doInitialSourceParentAttachment(){let{db:db2}=this.root,internallyConnectedPorts=this._getInternallyConnectedPins();for(let ports of internallyConnectedPorts){let sourcePortIds=ports.map(port=>port.source_port_id).filter(id2=>id2!==null);sourcePortIds.length>=2&&db2.source_component_internal_connection.insert({source_component_id:this.source_component_id,subcircuit_id:this.getSubcircuit()?.subcircuit_id,source_port_ids:sourcePortIds})}}},SolderJumper=class extends NormalComponent3{constructor(){super(...arguments);__publicField(this,"schematicDimensions",null)}_getPinNumberFromBridgedPinName(pinName){return this.selectOne(`port.${pinName}`,{type:"port"})?._parsedProps.pinNumber??null}get defaultInternallyConnectedPinNames(){if(this._parsedProps.bridged){let pins=this.children.filter(c3=>c3.componentName==="Port").map(p2=>p2.name);return pins.length>0?[pins]:[]}return this._parsedProps.bridgedPins??[]}get config(){let props=this._parsedProps??this.props,resolvedPinCount=props.pinCount;if(props.pinCount==null&&!props.footprint&&(resolvedPinCount=2),props.pinCount==null){let nums=(props.bridgedPins??[]).flat().map(p_str=>this._getPinNumberFromBridgedPinName(p_str)).filter(n3=>n3!==null),maxPinFromBridged=nums.length>0?Math.max(...nums):0,pinCountFromLabels=props.pinLabels?Object.keys(props.pinLabels).length:0,finalPinCount=Math.max(maxPinFromBridged,pinCountFromLabels);(finalPinCount===2||finalPinCount===3)&&(resolvedPinCount=finalPinCount),resolvedPinCount==null&&props.footprint&&[2,3].includes(this.getPortsFromFootprint().length)&&(resolvedPinCount=this.getPortsFromFootprint().length)}let symbolName="";resolvedPinCount?symbolName+=`solderjumper${resolvedPinCount}`:symbolName="solderjumper";let bridgedPinNumbers=[];return Array.isArray(props.bridgedPins)&&props.bridgedPins.length>0?bridgedPinNumbers=Array.from(new Set(props.bridgedPins.flat().map(pinName=>this._getPinNumberFromBridgedPinName(pinName)).filter(n3=>n3!==null))).sort((a2,b3)=>a2-b3):props.bridged&&resolvedPinCount&&(bridgedPinNumbers=Array.from({length:resolvedPinCount},(_4,i3)=>i3+1)),bridgedPinNumbers.length>0&&(symbolName+=`_bridged${bridgedPinNumbers.join("")}`),{schematicSymbolName:props.symbolName??symbolName,componentName:"SolderJumper",zodProps:solderjumperProps,shouldRenderAsSchematicBox:!0}}_getSchematicPortArrangement(){let arrangement=super._getSchematicPortArrangement();if(arrangement&&Object.keys(arrangement).length>0)return arrangement;let pinCount=this._parsedProps.pinCount??(Array.isArray(this._parsedProps.pinLabels)?this._parsedProps.pinLabels.length:this._parsedProps.pinLabels?Object.keys(this._parsedProps.pinLabels).length:this.getPortsFromFootprint().length);pinCount==null&&!this._parsedProps.footprint&&(pinCount=2);let direction2=this._parsedProps.schDirection??"right";return{leftSize:direction2==="left"?pinCount:0,rightSize:direction2==="right"?pinCount:0}}doInitialSourceRender(){let{db:db2}=this.root,{_parsedProps:props}=this,{pcbX,pcbY}=this.getResolvedPcbPositionProp(),source_component=db2.source_component.insert({ftype:"simple_chip",name:this.name,manufacturer_part_number:props.manufacturerPartNumber,supplier_part_numbers:props.supplierPartNumbers,are_pins_interchangeable:!0});this.source_component_id=source_component.source_component_id}doInitialPcbComponentRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,{pcbX,pcbY}=this.getResolvedPcbPositionProp(),pcb_component2=db2.pcb_component.insert({center:{x:pcbX,y:pcbY},width:2,height:3,layer:props.layer??"top",rotation:props.pcbRotation??0,source_component_id:this.source_component_id,subcircuit_id:this.getSubcircuit().subcircuit_id??void 0,do_not_place:props.doNotPlace??!1,obstructs_within_bounds:props.obstructsWithinBounds??!0});this.pcb_component_id=pcb_component2.pcb_component_id}doInitialPcbTraceRender(){let{db:db2}=this.root,pcb_ports=db2.pcb_port.list({pcb_component_id:this.pcb_component_id}),pinLabelToPortId={};for(let i3=0;i3<pcb_ports.length;i3++){let port=pcb_ports[i3],sourcePort=db2.source_port.get(port.source_port_id),pinLabel="";if(typeof sourcePort?.pin_number=="number")pinLabel=sourcePort.pin_number.toString();else if(Array.isArray(sourcePort?.port_hints)){let matchedHint=sourcePort.port_hints.find(h2=>/^(pin)?\d+$/.test(h2));matchedHint&&(/^pin\d+$/.test(matchedHint)?pinLabel=matchedHint.replace(/^pin/,""):pinLabel=matchedHint)}pinLabelToPortId[pinLabel]=port.pcb_port_id}let traces=db2.pcb_trace.list({pcb_component_id:this.pcb_component_id}),updatePortId=portId=>{if(portId&&typeof portId=="string"&&portId.startsWith("{PIN")){let pin=portId.replace("{PIN","").replace("}","");return pinLabelToPortId[pin]||portId}return portId};for(let trace of traces)if(trace.route)for(let segment2 of trace.route)segment2.route_type==="wire"&&(segment2.start_pcb_port_id=updatePortId(segment2.start_pcb_port_id),segment2.end_pcb_port_id=updatePortId(segment2.end_pcb_port_id))}},Led=class extends NormalComponent3{constructor(){super(...arguments);__publicField(this,"pos",this.portMap.pin1);__publicField(this,"anode",this.portMap.pin1);__publicField(this,"neg",this.portMap.pin2);__publicField(this,"cathode",this.portMap.pin2)}get config(){let symbolMap={laser:"laser_diode"},variantSymbol=this.props.laser?"laser":null;return{schematicSymbolName:variantSymbol?symbolMap[variantSymbol]:this.props.symbolName??"led",componentName:"Led",zodProps:ledProps,sourceFtype:"simple_led"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}_getSchematicSymbolDisplayValue(){return this._parsedProps.schDisplayValue||this._parsedProps.color||void 0}getFootprinterString(){let baseFootprint=super.getFootprinterString();return baseFootprint&&this.props.color?`${baseFootprint}_color(${this.props.color})`:baseFootprint}doInitialSourceRender(){let{db:db2}=this.root,{_parsedProps:props}=this,source_component=db2.source_component.insert({ftype:"simple_led",name:this.name,wave_length:props.wavelength,color:props.color,symbol_display_value:this._getSchematicSymbolDisplayValue(),manufacturer_part_number:props.manufacturerPartNumber??props.mfn,supplier_part_numbers:props.supplierPartNumbers,are_pins_interchangeable:!1});this.source_component_id=source_component.source_component_id}},PowerSource=class extends NormalComponent3{constructor(){super(...arguments);__publicField(this,"pos",this.portMap.pin1);__publicField(this,"positive",this.portMap.pin1);__publicField(this,"neg",this.portMap.pin2);__publicField(this,"negative",this.portMap.pin2)}get config(){return{schematicSymbolName:this.props.symbolName??"power_factor_meter_horz",componentName:"PowerSource",zodProps:powerSourceProps,sourceFtype:"simple_power_source"}}initPorts(){this.add(new Port({name:"pin1",pinNumber:1,aliases:["positive","pos"]})),this.add(new Port({name:"pin2",pinNumber:2,aliases:["negative","neg"]}))}doInitialSourceRender(){let{db:db2}=this.root,{_parsedProps:props}=this,source_component=db2.source_component.insert({ftype:"simple_power_source",name:this.name,voltage:props.voltage,supplier_part_numbers:props.supplierPartNumbers,are_pins_interchangeable:!1});this.source_component_id=source_component.source_component_id}},VoltageSource=class extends NormalComponent3{constructor(){super(...arguments);__publicField(this,"terminal1",this.portMap.terminal1);__publicField(this,"terminal2",this.portMap.terminal2)}get config(){return{componentName:"VoltageSource",schematicSymbolName:this.props.waveShape==="square"?"square_wave":"ac_voltmeter",zodProps:voltageSourceProps,sourceFtype:"simple_voltage_source"}}runRenderPhaseForChildren(phase){if(!phase.startsWith("Pcb"))for(let child of this.children)child.runRenderPhaseForChildren(phase),child.runRenderPhase(phase)}doInitialPcbComponentRender(){}initPorts(){super.initPorts({additionalAliases:{pin1:["terminal1"],pin2:["terminal2"]}})}_getSchematicSymbolDisplayValue(){let{voltage:voltage2,frequency:frequency2}=this._parsedProps,parts=[];return voltage2!==void 0&&parts.push(`${formatSiUnit(voltage2)}V`),frequency2!==void 0&&parts.push(`${formatSiUnit(frequency2)}Hz`),parts.length>0?parts.join(" "):void 0}doInitialSourceRender(){let{db:db2}=this.root,{_parsedProps:props}=this,source_component=db2.source_component.insert({ftype:"simple_voltage_source",name:this.name,voltage:props.voltage,frequency:props.frequency,peak_to_peak_voltage:props.peakToPeakVoltage,wave_shape:props.waveShape,phase:props.phase,duty_cycle:props.dutyCycle,supplier_part_numbers:props.supplierPartNumbers,are_pins_interchangeable:!0});this.source_component_id=source_component.source_component_id}doInitialSimulationRender(){let{db:db2}=this.root,{_parsedProps:props}=this,terminal1Port=this.portMap.terminal1,terminal2Port=this.portMap.terminal2;db2.simulation_voltage_source.insert({type:"simulation_voltage_source",is_dc_source:!1,terminal1_source_port_id:terminal1Port.source_port_id,terminal2_source_port_id:terminal2Port.source_port_id,voltage:props.voltage,frequency:props.frequency,peak_to_peak_voltage:props.peakToPeakVoltage,wave_shape:props.waveShape,phase:props.phase,duty_cycle:props.dutyCycle})}},CurrentSource=class extends NormalComponent3{constructor(){super(...arguments);__publicField(this,"pos",this.portMap.pos);__publicField(this,"neg",this.portMap.neg)}get config(){return{componentName:"CurrentSource",schematicSymbolName:"current_source",zodProps:currentSourceProps,sourceFtype:"simple_current_source"}}runRenderPhaseForChildren(phase){if(!phase.startsWith("Pcb"))for(let child of this.children)child.runRenderPhaseForChildren(phase),child.runRenderPhase(phase)}doInitialPcbComponentRender(){}initPorts(){super.initPorts({additionalAliases:{pin1:["pos"],pin2:["neg"]}})}_getSchematicSymbolDisplayValue(){let{current:current2,frequency:frequency2,peakToPeakCurrent}=this._parsedProps,parts=[];return current2!==void 0&&parts.push(`${formatSiUnit(current2)}A`),peakToPeakCurrent!==void 0&&parts.push(`${formatSiUnit(peakToPeakCurrent)}A p-p`),frequency2!==void 0&&parts.push(`${formatSiUnit(frequency2)}Hz`),parts.length>0?parts.join(" "):void 0}doInitialSourceRender(){let{db:db2}=this.root,{_parsedProps:props}=this,source_component=db2.source_component.insert({ftype:"simple_current_source",name:this.name,current:props.current,frequency:props.frequency,peak_to_peak_current:props.peakToPeakCurrent,wave_shape:props.waveShape,phase:props.phase,duty_cycle:props.dutyCycle,supplier_part_numbers:props.supplierPartNumbers,are_pins_interchangeable:!0});this.source_component_id=source_component.source_component_id}doInitialSimulationRender(){let{db:db2}=this.root,{_parsedProps:props}=this,isAc=props.frequency!==void 0||props.peakToPeakCurrent!==void 0||props.waveShape!==void 0,posPort=this.portMap.pos,negPort=this.portMap.neg;if(isAc)db2.simulation_current_source.insert({type:"simulation_current_source",is_dc_source:!1,terminal1_source_port_id:posPort.source_port_id,terminal2_source_port_id:negPort.source_port_id,current:props.current,frequency:props.frequency,peak_to_peak_current:props.peakToPeakCurrent,wave_shape:props.waveShape,phase:props.phase,duty_cycle:props.dutyCycle});else{if(props.current===void 0)return;db2.simulation_current_source.insert({type:"simulation_current_source",is_dc_source:!0,positive_source_port_id:posPort.source_port_id,negative_source_port_id:negPort.source_port_id,current:props.current})}}},edgeSpecifiers=["leftedge","rightedge","topedge","bottomedge","center"],Constraint3=class extends PrimitiveComponent2{get config(){return{componentName:"Constraint",zodProps:constraintProps}}constructor(props){if(super(props),("xdist"in props||"ydist"in props)&&!("edgeToEdge"in props)&&!("centerToCenter"in props))throw new Error(`edgeToEdge, centerToCenter must be set for xDist or yDist for ${this}`);if("for"in props&&props.for.length<2)throw new Error(`"for" must have at least two selectors for ${this}`)}_getAllReferencedComponents(){let componentsWithSelectors=[],container=this.getPrimitiveContainer();function addComponentFromSelector(selector){let maybeEdge=selector.split(" ").pop(),edge=edgeSpecifiers.includes(maybeEdge)?maybeEdge:void 0,componentSelector=edge?selector.replace(` ${edge}`,""):selector,component=container.selectOne(componentSelector,{pcbPrimitive:!0});component&&componentsWithSelectors.push({selector,component,componentSelector,edge})}for(let key of["left","right","top","bottom"])key in this._parsedProps&&addComponentFromSelector(this._parsedProps[key]);if("for"in this._parsedProps)for(let selector of this._parsedProps.for)addComponentFromSelector(selector);return{componentsWithSelectors}}},FabricationNoteRect=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"fabrication_note_rect_id",null);__publicField(this,"isPcbPrimitive",!0)}get config(){return{componentName:"FabricationNoteRect",zodProps:fabricationNoteRectProps}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,{pcbX,pcbY}=this.getResolvedPcbPositionProp(),{maybeFlipLayer}=this._getPcbPrimitiveFlippedHelpers(),layer=maybeFlipLayer(props.layer??"top");if(layer!=="top"&&layer!=="bottom")throw new Error(`Invalid layer "${layer}" for FabricationNoteRect. Must be "top" or "bottom".`);let pcb_component_id=this.parent?.pcb_component_id??this.getPrimitiveContainer()?.pcb_component_id,subcircuit=this.getSubcircuit(),hasStroke=props.hasStroke??(props.strokeWidth!==void 0&&props.strokeWidth!==null),fabrication_note_rect=db2.pcb_fabrication_note_rect.insert({pcb_component_id,layer,color:props.color,center:{x:pcbX,y:pcbY},width:props.width,height:props.height,stroke_width:props.strokeWidth??1,is_filled:props.isFilled??!1,has_stroke:hasStroke,is_stroke_dashed:props.isStrokeDashed??!1,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0,corner_radius:props.cornerRadius??void 0});this.fabrication_note_rect_id=fabrication_note_rect.pcb_fabrication_note_rect_id}getPcbSize(){let{_parsedProps:props}=this;return{width:props.width,height:props.height}}_moveCircuitJsonElements({deltaX,deltaY}){if(this.root?.pcbDisabled)return;let{db:db2}=this.root;if(!this.fabrication_note_rect_id)return;let rect=db2.pcb_fabrication_note_rect.get(this.fabrication_note_rect_id);rect&&db2.pcb_fabrication_note_rect.update(this.fabrication_note_rect_id,{center:{x:rect.center.x+deltaX,y:rect.center.y+deltaY}})}},FabricationNotePath=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"fabrication_note_path_id",null);__publicField(this,"isPcbPrimitive",!0)}get config(){return{componentName:"FabricationNotePath",zodProps:fabricationNotePathProps}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,subcircuit=this.getSubcircuit(),{_parsedProps:props}=this,layer=props.layer??"top";if(layer!=="top"&&layer!=="bottom")throw new Error(`Invalid layer "${layer}" for SilkscreenPath. Must be "top" or "bottom".`);let transform5=this._computePcbGlobalTransformBeforeLayout(),pcb_component_id=this.parent?.pcb_component_id??this.getPrimitiveContainer()?.pcb_component_id,fabrication_note_path=db2.pcb_fabrication_note_path.insert({pcb_component_id,layer,color:props.color,route:props.route.map(p2=>{let transformedPosition=applyToPoint(transform5,{x:p2.x,y:p2.y});return{...p2,x:transformedPosition.x,y:transformedPosition.y}}),stroke_width:props.strokeWidth??.1,subcircuit_id:subcircuit?.subcircuit_id??void 0});this.fabrication_note_path_id=fabrication_note_path.pcb_fabrication_note_path_id}getPcbSize(){let{_parsedProps:props}=this;if(props.route.length===0)return{width:0,height:0};let xs3=props.route.map(point23=>typeof point23.x=="string"?parseFloat(point23.x):point23.x),ys3=props.route.map(point23=>typeof point23.y=="string"?parseFloat(point23.y):point23.y),minX=Math.min(...xs3),maxX=Math.max(...xs3),minY=Math.min(...ys3),maxY=Math.max(...ys3);return{width:maxX-minX,height:maxY-minY}}_moveCircuitJsonElements({deltaX,deltaY}){if(this.root?.pcbDisabled)return;let{db:db2}=this.root;if(!this.fabrication_note_path_id)return;let path=db2.pcb_fabrication_note_path.get(this.fabrication_note_path_id);path&&db2.pcb_fabrication_note_path.update(this.fabrication_note_path_id,{route:path.route.map(p2=>({...p2,x:p2.x+deltaX,y:p2.y+deltaY}))})}},FabricationNoteText=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"pcb_fabrication_note_text_id",null);__publicField(this,"isPcbPrimitive",!0)}get config(){return{componentName:"FabricationNoteText",zodProps:fabricationNoteTextProps}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,{pcbX,pcbY}=this.getResolvedPcbPositionProp(),container=this.getPrimitiveContainer(),subcircuit=this.getSubcircuit(),pcb_fabrication_note_text2=db2.pcb_fabrication_note_text.insert({anchor_alignment:props.anchorAlignment,anchor_position:{x:pcbX,y:pcbY},font:props.font??"tscircuit2024",font_size:props.fontSize??1,layer:"top",color:props.color,text:normalizeTextForCircuitJson(props.text??""),pcb_component_id:container.pcb_component_id,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0});this.pcb_fabrication_note_text_id=pcb_fabrication_note_text2.pcb_fabrication_note_text_id}getPcbSize(){let{_parsedProps:props}=this,fontSize=typeof props.fontSize=="string"?parseFloat(props.fontSize):props.fontSize??1,charWidth=fontSize*.6;return{width:(props.text??"").length*charWidth,height:fontSize}}_moveCircuitJsonElements({deltaX,deltaY}){if(this.root?.pcbDisabled)return;let{db:db2}=this.root;if(this.pcb_fabrication_note_text_id){let text=db2.pcb_fabrication_note_text.get(this.pcb_fabrication_note_text_id);text&&db2.pcb_fabrication_note_text.update(this.pcb_fabrication_note_text_id,{anchor_position:{x:text.anchor_position.x+deltaX,y:text.anchor_position.y+deltaY}})}}},FabricationNoteDimension=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"fabrication_note_dimension_id",null);__publicField(this,"isPcbPrimitive",!0)}get config(){return{componentName:"FabricationNoteDimension",zodProps:fabricationNoteDimensionProps}}_resolvePoint(input2,transform5){if(typeof input2=="string"){let target=this.getSubcircuit().selectOne(input2);return target?target._getGlobalPcbPositionBeforeLayout():(this.renderError(`FabricationNoteDimension could not find selector "${input2}"`),applyToPoint(transform5,{x:0,y:0}))}let numericX=typeof input2.x=="string"?parseFloat(input2.x):input2.x,numericY=typeof input2.y=="string"?parseFloat(input2.y):input2.y;return applyToPoint(transform5,{x:numericX,y:numericY})}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,transform5=this._computePcbGlobalTransformBeforeLayout(),from=this._resolvePoint(props.from,transform5),to3=this._resolvePoint(props.to,transform5),subcircuit=this.getSubcircuit(),group=this.getGroup(),{maybeFlipLayer}=this._getPcbPrimitiveFlippedHelpers(),layer=maybeFlipLayer(props.layer??"top");if(layer!=="top"&&layer!=="bottom")throw new Error(`Invalid layer "${layer}" for FabricationNoteDimension. Must be "top" or "bottom".`);let pcb_component_id=this.parent?.pcb_component_id??this.getPrimitiveContainer()?.pcb_component_id,text=props.text??this._formatDistanceText({from,to:to3,units:props.units??"mm"}),fabrication_note_dimension=db2.pcb_fabrication_note_dimension.insert({pcb_component_id,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:group?.pcb_group_id??void 0,layer,from,to:to3,text,offset:props.offset,font:props.font??"tscircuit2024",font_size:props.fontSize??1,color:props.color,arrow_size:props.arrowSize??1});this.fabrication_note_dimension_id=fabrication_note_dimension.pcb_fabrication_note_dimension_id}_moveCircuitJsonElements({deltaX,deltaY}){if(this.root?.pcbDisabled)return;let{db:db2}=this.root;if(!this.fabrication_note_dimension_id)return;let dimension=db2.pcb_fabrication_note_dimension.get(this.fabrication_note_dimension_id);dimension&&db2.pcb_fabrication_note_dimension.update(this.fabrication_note_dimension_id,{from:{x:dimension.from.x+deltaX,y:dimension.from.y+deltaY},to:{x:dimension.to.x+deltaX,y:dimension.to.y+deltaY}})}getPcbSize(){let transform5=this._computePcbGlobalTransformBeforeLayout(),from=this._resolvePoint(this._parsedProps.from,transform5),to3=this._resolvePoint(this._parsedProps.to,transform5);return{width:Math.abs(to3.x-from.x),height:Math.abs(to3.y-from.y)}}_formatDistanceText({from,to:to3,units}){let dx2=to3.x-from.x,dy2=to3.y-from.y,distanceInMillimeters=Math.sqrt(dx2*dx2+dy2*dy2),distanceInUnits=units==="in"?distanceInMillimeters/25.4:distanceInMillimeters,roundedDistance=Math.round(distanceInUnits);if(Math.abs(distanceInUnits-roundedDistance)<1e-9)return`${roundedDistance}${units}`;let decimalPlaces=units==="in"?3:2;return`${units==="in"?Number(distanceInUnits.toFixed(decimalPlaces)).toString():distanceInUnits.toFixed(decimalPlaces)}${units}`}},PcbNoteLine=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"pcb_note_line_id",null);__publicField(this,"isPcbPrimitive",!0)}get config(){return{componentName:"PcbNoteLine",zodProps:pcbNoteLineProps}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,subcircuit=this.getSubcircuit(),group=this.getGroup(),transform5=this._computePcbGlobalTransformBeforeLayout(),start=applyToPoint(transform5,{x:props.x1,y:props.y1}),end=applyToPoint(transform5,{x:props.x2,y:props.y2}),pcb_component_id=this.parent?.pcb_component_id??this.getPrimitiveContainer()?.pcb_component_id??void 0,pcb_note_line2=db2.pcb_note_line.insert({pcb_component_id,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:group?.pcb_group_id??void 0,x1:start.x,y1:start.y,x2:end.x,y2:end.y,stroke_width:props.strokeWidth??.1,color:props.color,is_dashed:props.isDashed});this.pcb_note_line_id=pcb_note_line2.pcb_note_line_id}getPcbSize(){let{_parsedProps:props}=this;return{width:Math.abs(props.x2-props.x1),height:Math.abs(props.y2-props.y1)}}_moveCircuitJsonElements({deltaX,deltaY}){if(this.root?.pcbDisabled)return;let{db:db2}=this.root;if(!this.pcb_note_line_id)return;let line2=db2.pcb_note_line.get(this.pcb_note_line_id);line2&&db2.pcb_note_line.update(this.pcb_note_line_id,{x1:line2.x1+deltaX,y1:line2.y1+deltaY,x2:line2.x2+deltaX,y2:line2.y2+deltaY})}},PcbNoteRect=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"pcb_note_rect_id",null);__publicField(this,"isPcbPrimitive",!0)}get config(){return{componentName:"PcbNoteRect",zodProps:pcbNoteRectProps}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,transform5=this._computePcbGlobalTransformBeforeLayout(),center2=applyToPoint(transform5,{x:0,y:0}),subcircuit=this.getSubcircuit(),group=this.getGroup(),pcb_component_id=this.parent?.pcb_component_id??this.getPrimitiveContainer()?.pcb_component_id??void 0,pcb_note_rect2=db2.pcb_note_rect.insert({pcb_component_id,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:group?.pcb_group_id??void 0,center:center2,width:props.width,height:props.height,stroke_width:props.strokeWidth??.1,is_filled:props.isFilled??!1,has_stroke:props.hasStroke??!0,is_stroke_dashed:props.isStrokeDashed??!1,color:props.color,corner_radius:props.cornerRadius??void 0});this.pcb_note_rect_id=pcb_note_rect2.pcb_note_rect_id}getPcbSize(){let{_parsedProps:props}=this,width=typeof props.width=="string"?parseFloat(props.width):props.width,height=typeof props.height=="string"?parseFloat(props.height):props.height;return{width,height}}_moveCircuitJsonElements({deltaX,deltaY}){if(this.root?.pcbDisabled)return;let{db:db2}=this.root;if(!this.pcb_note_rect_id)return;let rect=db2.pcb_note_rect.get(this.pcb_note_rect_id);rect&&db2.pcb_note_rect.update(this.pcb_note_rect_id,{center:{x:rect.center.x+deltaX,y:rect.center.y+deltaY}})}},PcbNoteText=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"pcb_note_text_id",null);__publicField(this,"isPcbPrimitive",!0)}get config(){return{componentName:"PcbNoteText",zodProps:pcbNoteTextProps}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,transform5=this._computePcbGlobalTransformBeforeLayout(),anchorPosition=applyToPoint(transform5,{x:0,y:0}),subcircuit=this.getSubcircuit(),group=this.getGroup(),pcb_component_id=this.parent?.pcb_component_id??this.getPrimitiveContainer()?.pcb_component_id??void 0,pcb_note_text2=db2.pcb_note_text.insert({pcb_component_id,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:group?.pcb_group_id??void 0,font:props.font??"tscircuit2024",font_size:props.fontSize??1,text:normalizeTextForCircuitJson(props.text),anchor_position:anchorPosition,anchor_alignment:props.anchorAlignment??"center",color:props.color});this.pcb_note_text_id=pcb_note_text2.pcb_note_text_id}getPcbSize(){let{_parsedProps:props}=this,fontSize=typeof props.fontSize=="string"?parseFloat(props.fontSize):props.fontSize??1,charWidth=fontSize*.6;return{width:props.text.length*charWidth,height:fontSize}}_moveCircuitJsonElements({deltaX,deltaY}){if(this.root?.pcbDisabled)return;let{db:db2}=this.root;if(!this.pcb_note_text_id)return;let text=db2.pcb_note_text.get(this.pcb_note_text_id);text&&db2.pcb_note_text.update(this.pcb_note_text_id,{anchor_position:{x:text.anchor_position.x+deltaX,y:text.anchor_position.y+deltaY}})}},PcbNotePath=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"pcb_note_path_id",null);__publicField(this,"isPcbPrimitive",!0)}get config(){return{componentName:"PcbNotePath",zodProps:pcbNotePathProps}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,transform5=this._computePcbGlobalTransformBeforeLayout(),subcircuit=this.getSubcircuit(),group=this.getGroup(),pcb_component_id=this.parent?.pcb_component_id??this.getPrimitiveContainer()?.pcb_component_id??void 0,transformedRoute=props.route.map(point23=>{let{x:x3,y:y3,...rest}=point23,numericX=typeof x3=="string"?parseFloat(x3):x3,numericY=typeof y3=="string"?parseFloat(y3):y3,transformed=applyToPoint(transform5,{x:numericX,y:numericY});return{...rest,x:transformed.x,y:transformed.y}}),pcb_note_path2=db2.pcb_note_path.insert({pcb_component_id,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:group?.pcb_group_id??void 0,route:transformedRoute,stroke_width:props.strokeWidth??.1,color:props.color});this.pcb_note_path_id=pcb_note_path2.pcb_note_path_id}getPcbSize(){let{_parsedProps:props}=this;if(props.route.length===0)return{width:0,height:0};let xs3=props.route.map(point23=>typeof point23.x=="string"?parseFloat(point23.x):point23.x),ys3=props.route.map(point23=>typeof point23.y=="string"?parseFloat(point23.y):point23.y),minX=Math.min(...xs3),maxX=Math.max(...xs3),minY=Math.min(...ys3),maxY=Math.max(...ys3);return{width:maxX-minX,height:maxY-minY}}_moveCircuitJsonElements({deltaX,deltaY}){if(this.root?.pcbDisabled)return;let{db:db2}=this.root;if(!this.pcb_note_path_id)return;let path=db2.pcb_note_path.get(this.pcb_note_path_id);path&&db2.pcb_note_path.update(this.pcb_note_path_id,{route:path.route.map(p2=>({...p2,x:p2.x+deltaX,y:p2.y+deltaY}))})}},PcbNoteDimension=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"pcb_note_dimension_id",null);__publicField(this,"isPcbPrimitive",!0)}get config(){return{componentName:"PcbNoteDimension",zodProps:pcbNoteDimensionProps}}_resolvePoint(input2,transform5){if(typeof input2=="string"){let target=this.getSubcircuit().selectOne(`.${input2}`);return target?target._getGlobalPcbPositionBeforeLayout():(this.renderError(`PcbNoteDimension could not find selector "${input2}"`),applyToPoint(transform5,{x:0,y:0}))}let numericX=typeof input2.x=="string"?parseFloat(input2.x):input2.x,numericY=typeof input2.y=="string"?parseFloat(input2.y):input2.y;return applyToPoint(transform5,{x:numericX,y:numericY})}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,transform5=this._computePcbGlobalTransformBeforeLayout(),from=this._resolvePoint(props.from,transform5),to3=this._resolvePoint(props.to,transform5),subcircuit=this.getSubcircuit(),group=this.getGroup(),pcb_component_id=this.parent?.pcb_component_id??this.getPrimitiveContainer()?.pcb_component_id??void 0,text=props.text??this._formatDistanceText({from,to:to3,units:props.units??"mm"}),pcb_note_dimension2=db2.pcb_note_dimension.insert({pcb_component_id,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:group?.pcb_group_id??void 0,from,to:to3,text,font:props.font??"tscircuit2024",font_size:props.fontSize??1,color:props.color,arrow_size:props.arrowSize??1});this.pcb_note_dimension_id=pcb_note_dimension2.pcb_note_dimension_id}getPcbSize(){let transform5=this._computePcbGlobalTransformBeforeLayout(),from=this._resolvePoint(this._parsedProps.from,transform5),to3=this._resolvePoint(this._parsedProps.to,transform5);return{width:Math.abs(to3.x-from.x),height:Math.abs(to3.y-from.y)}}_formatDistanceText({from,to:to3,units}){let dx2=to3.x-from.x,dy2=to3.y-from.y,distanceInMillimeters=Math.sqrt(dx2*dx2+dy2*dy2),distanceInUnits=units==="in"?distanceInMillimeters/25.4:distanceInMillimeters,roundedDistance=Math.round(distanceInUnits);if(Math.abs(distanceInUnits-roundedDistance)<1e-9)return`${roundedDistance}${units}`;let decimalPlaces=units==="in"?3:2;return`${units==="in"?Number(distanceInUnits.toFixed(decimalPlaces)).toString():distanceInUnits.toFixed(decimalPlaces)}${units}`}_moveCircuitJsonElements({deltaX,deltaY}){if(this.root?.pcbDisabled)return;let{db:db2}=this.root;if(!this.pcb_note_dimension_id)return;let dimension=db2.pcb_note_dimension.get(this.pcb_note_dimension_id);dimension&&db2.pcb_note_dimension.update(this.pcb_note_dimension_id,{from:{x:dimension.from.x+deltaX,y:dimension.from.y+deltaY},to:{x:dimension.to.x+deltaX,y:dimension.to.y+deltaY}})}},Subcircuit=class extends Group6{constructor(props){super({...props,subcircuit:!0})}doInitialInflateSubcircuitCircuitJson(){let{circuitJson,children}=this._parsedProps;inflateCircuitJson(this,circuitJson,children)}},Breakout=class extends Group6{constructor(props){super({...props,subcircuit:!0})}doInitialPcbPrimitiveRender(){if(super.doInitialPcbPrimitiveRender(),this.root?.pcbDisabled)return;let{db:db2}=this.root,props=this._parsedProps;if(!this.pcb_group_id)return;let pcb_group2=db2.pcb_group.get(this.pcb_group_id),padLeft=props.paddingLeft??props.padding??0,padRight=props.paddingRight??props.padding??0,padTop=props.paddingTop??props.padding??0,padBottom=props.paddingBottom??props.padding??0;db2.pcb_group.update(this.pcb_group_id,{width:(pcb_group2.width??0)+padLeft+padRight,height:(pcb_group2.height??0)+padTop+padBottom,center:{x:pcb_group2.center.x+(padRight-padLeft)/2,y:pcb_group2.center.y+(padTop-padBottom)/2}})}},BreakoutPoint=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"pcb_breakout_point_id",null);__publicField(this,"matchedPort",null);__publicField(this,"matchedNet",null);__publicField(this,"isPcbPrimitive",!0)}get config(){return{componentName:"BreakoutPoint",zodProps:breakoutPointProps}}_matchConnection(){let{connection}=this._parsedProps,subcircuit=this.getSubcircuit();subcircuit&&(this.matchedPort=subcircuit.selectOne(connection,{type:"port"}),this.matchedPort||(this.matchedNet=subcircuit.selectOne(connection,{type:"net"})),!this.matchedPort&&!this.matchedNet&&this.renderError(`Could not find connection target "${connection}"`))}_getSourceTraceIdForPort(port){let{db:db2}=this.root;return db2.source_trace.list().find(st2=>st2.connected_source_port_ids.includes(port.source_port_id))?.source_trace_id}_getSourceNetIdForPort(port){let{db:db2}=this.root;return db2.source_trace.list().find(st2=>st2.connected_source_port_ids.includes(port.source_port_id))?.connected_source_net_ids[0]}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root;this._matchConnection();let{pcbX,pcbY}=this.getResolvedPcbPositionProp(),group=this.parent?.getGroup(),subcircuit=this.getSubcircuit();if(!group||!group.pcb_group_id)return;let pcb_breakout_point2=db2.pcb_breakout_point.insert({pcb_group_id:group.pcb_group_id,subcircuit_id:subcircuit?.subcircuit_id??void 0,source_port_id:this.matchedPort?.source_port_id??void 0,source_trace_id:this.matchedPort?this._getSourceTraceIdForPort(this.matchedPort):void 0,source_net_id:this.matchedNet?this.matchedNet.source_net_id:this.matchedPort?this._getSourceNetIdForPort(this.matchedPort):void 0,x:pcbX,y:pcbY});this.pcb_breakout_point_id=pcb_breakout_point2.pcb_breakout_point_id}_getPcbCircuitJsonBounds(){let{pcbX,pcbY}=this.getResolvedPcbPositionProp();return{center:{x:pcbX,y:pcbY},bounds:{left:pcbX,top:pcbY,right:pcbX,bottom:pcbY},width:0,height:0}}_setPositionFromLayout(newCenter){let{db:db2}=this.root;this.pcb_breakout_point_id&&db2.pcb_breakout_point.update(this.pcb_breakout_point_id,{x:newCenter.x,y:newCenter.y})}_moveCircuitJsonElements({deltaX,deltaY}){if(this.root?.pcbDisabled)return;let{db:db2}=this.root;if(!this.pcb_breakout_point_id)return;let point23=db2.pcb_breakout_point.get(this.pcb_breakout_point_id);point23&&db2.pcb_breakout_point.update(this.pcb_breakout_point_id,{x:point23.x+deltaX,y:point23.y+deltaY})}getPcbSize(){return{width:0,height:0}}},NetLabel=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"source_net_label_id")}get config(){return{componentName:"NetLabel",zodProps:netLabelProps}}_getAnchorSide(){let{_parsedProps:props}=this;if(props.anchorSide)return props.anchorSide;if(!this._resolveConnectsTo())return"right";let anchorPos=this._getGlobalSchematicPositionBeforeLayout(),connectedPorts=this._getConnectedPorts();if(connectedPorts.length===0)return"right";let connectedPortPosition=connectedPorts[0]._getGlobalSchematicPositionBeforeLayout(),dx2=connectedPortPosition.x-anchorPos.x,dy2=connectedPortPosition.y-anchorPos.y;if(Math.abs(dx2)>Math.abs(dy2)){if(dx2>0)return"right";if(dx2<0)return"left"}else{if(dy2>0)return"top";if(dy2<0)return"bottom"}return"right"}_getConnectedPorts(){let connectsTo=this._resolveConnectsTo();if(!connectsTo)return[];let connectedPorts=[];for(let connection of connectsTo){let port=this.getSubcircuit().selectOne(connection);port&&connectedPorts.push(port)}return connectedPorts}computeSchematicPropsTransform(){let{_parsedProps:props}=this;if(props.schX===void 0&&props.schY===void 0){let connectedPorts=this._getConnectedPorts();if(connectedPorts.length>0){let portPos=connectedPorts[0]._getGlobalSchematicPositionBeforeLayout(),parentCenter=applyToPoint(this.parent?.computeSchematicGlobalTransform?.()??identity(),{x:0,y:0});return translate(portPos.x-parentCenter.x,portPos.y-parentCenter.y)}}return super.computeSchematicPropsTransform()}doInitialSchematicPrimitiveRender(){if(this.root?.schematicDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,anchorPos=this._getGlobalSchematicPositionBeforeLayout(),net=this.getSubcircuit().selectOne(`net.${this._getNetName()}`),anchorSide=props.anchorSide??"right",center2=computeSchematicNetLabelCenter({anchor_position:anchorPos,anchor_side:anchorSide,text:props.net}),netLabel=db2.schematic_net_label.insert({text:props.net,source_net_id:net.source_net_id,anchor_position:anchorPos,center:center2,anchor_side:this._getAnchorSide()});this.source_net_label_id=netLabel.source_net_id}_resolveConnectsTo(){let{_parsedProps:props}=this,connectsTo=props.connectsTo??props.connection;if(Array.isArray(connectsTo))return connectsTo;if(typeof connectsTo=="string")return[connectsTo]}_getNetName(){let{_parsedProps:props}=this;return props.net}doInitialCreateNetsFromProps(){let{_parsedProps:props}=this;props.net&&createNetsFromProps(this,[`net.${props.net}`])}doInitialCreateTracesFromNetLabels(){if(this.root?.schematicDisabled)return;let connectsTo=this._resolveConnectsTo();if(connectsTo)for(let connection of connectsTo)this.add(new Trace3({from:connection,to:`net.${this._getNetName()}`}))}doInitialSchematicTraceRender(){if(!this.root?._featureMspSchematicTraceRouting||this.root?.schematicDisabled)return;let{db:db2}=this.root,connectsTo=this._resolveConnectsTo();if(!connectsTo||connectsTo.length===0)return;let anchorPos=this._getGlobalSchematicPositionBeforeLayout(),anchorSide=this._getAnchorSide(),anchorFacing={left:"x-",right:"x+",top:"y+",bottom:"y-"}[anchorSide],net=this.getSubcircuit().selectOne(`net.${this._getNetName()}`);for(let connection of connectsTo){let port=this.getSubcircuit().selectOne(connection,{type:"port"});if(!port||!port.schematic_port_id)continue;let existingTraceForThisConnection=!1;if(net?.source_net_id){let candidateSourceTrace=db2.source_trace.list().find(st2=>st2.connected_source_net_ids?.includes(net.source_net_id)&&st2.connected_source_port_ids?.includes(port.source_port_id??""));if(candidateSourceTrace&&(existingTraceForThisConnection=db2.schematic_trace.list().some(t5=>t5.source_trace_id===candidateSourceTrace.source_trace_id)),existingTraceForThisConnection)continue}let portPos=port._getGlobalSchematicPositionAfterLayout(),portFacing=convertFacingDirectionToElbowDirection(port.facingDirection??"right")??"x+",path=calculateElbow({x:portPos.x,y:portPos.y,facingDirection:portFacing},{x:anchorPos.x,y:anchorPos.y,facingDirection:anchorFacing});if(!Array.isArray(path)||path.length<2)continue;let edges=[];for(let i3=0;i3<path.length-1;i3++)edges.push({from:{x:path[i3].x,y:path[i3].y},to:{x:path[i3+1].x,y:path[i3+1].y}});let source_trace_id,subcircuit_connectivity_map_key;if(net?.source_net_id&&port.source_port_id){let st2=db2.source_trace.list().find(s3=>s3.connected_source_net_ids?.includes(net.source_net_id)&&s3.connected_source_port_ids?.includes(port.source_port_id));source_trace_id=st2?.source_trace_id,subcircuit_connectivity_map_key=st2?.subcircuit_connectivity_map_key||db2.source_net.get(net.source_net_id)?.subcircuit_connectivity_map_key}db2.schematic_trace.insert({source_trace_id,edges,junctions:[],subcircuit_connectivity_map_key}),db2.schematic_port.update(port.schematic_port_id,{is_connected:!0})}}},SilkscreenCircle=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"pcb_silkscreen_circle_id",null);__publicField(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenCircle",zodProps:silkscreenCircleProps}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,{pcbX,pcbY}=this.getResolvedPcbPositionProp(),{maybeFlipLayer}=this._getPcbPrimitiveFlippedHelpers(),layer=maybeFlipLayer(props.layer??"top");if(layer!=="top"&&layer!=="bottom")throw new Error(`Invalid layer "${layer}" for SilkscreenCircle. Must be "top" or "bottom".`);let transform5=this._computePcbGlobalTransformBeforeLayout(),subcircuit=this.getSubcircuit(),pcb_component_id=this.parent?.pcb_component_id??this.getPrimitiveContainer()?.pcb_component_id,pcb_silkscreen_circle2=db2.pcb_silkscreen_circle.insert({pcb_component_id,layer,center:{x:pcbX,y:pcbY},radius:props.radius,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0,stroke_width:props.strokeWidth??.1});this.pcb_silkscreen_circle_id=pcb_silkscreen_circle2.pcb_silkscreen_circle_id}getPcbSize(){let{_parsedProps:props}=this,diameter=props.radius*2;return{width:diameter,height:diameter}}_moveCircuitJsonElements({deltaX,deltaY}){if(this.root?.pcbDisabled)return;let{db:db2}=this.root;if(!this.pcb_silkscreen_circle_id)return;let circle2=db2.pcb_silkscreen_circle.get(this.pcb_silkscreen_circle_id);circle2&&db2.pcb_silkscreen_circle.update(this.pcb_silkscreen_circle_id,{center:{x:circle2.center.x+deltaX,y:circle2.center.y+deltaY}})}},SilkscreenRect=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"pcb_silkscreen_rect_id",null);__publicField(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenRect",zodProps:silkscreenRectProps}}_isRotated90Degrees(){let globalTransform=this._computePcbGlobalTransformBeforeLayout(),normalizedRotationDegrees=(decomposeTSR(globalTransform).rotation.angle*180/Math.PI%360+360)%360,rotationTolerance=.01;return Math.abs(normalizedRotationDegrees-90)<rotationTolerance||Math.abs(normalizedRotationDegrees-270)<rotationTolerance}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,{maybeFlipLayer}=this._getPcbPrimitiveFlippedHelpers(),layer=maybeFlipLayer(props.layer??"top");if(layer!=="top"&&layer!=="bottom")throw new Error(`Invalid layer "${layer}" for SilkscreenRect. Must be "top" or "bottom".`);let subcircuit=this.getSubcircuit(),position2=this._getGlobalPcbPositionBeforeLayout(),isRotated90Degrees=this._isRotated90Degrees(),finalWidth=isRotated90Degrees?props.height:props.width,finalHeight=isRotated90Degrees?props.width:props.height,pcb_component_id=this.parent?.pcb_component_id??this.getPrimitiveContainer()?.pcb_component_id,pcb_silkscreen_rect2=db2.pcb_silkscreen_rect.insert({pcb_component_id,layer,center:{x:position2.x,y:position2.y},width:finalWidth,height:finalHeight,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:this?.getGroup()?.pcb_group_id??void 0,stroke_width:props.strokeWidth??.1,is_filled:props.filled??!1,corner_radius:props.cornerRadius??void 0});this.pcb_silkscreen_rect_id=pcb_silkscreen_rect2.pcb_silkscreen_rect_id}getPcbSize(){let{_parsedProps:props}=this;return this._isRotated90Degrees()?{width:props.height,height:props.width}:{width:props.width,height:props.height}}_moveCircuitJsonElements({deltaX,deltaY}){if(this.root?.pcbDisabled)return;let{db:db2}=this.root;if(!this.pcb_silkscreen_rect_id)return;let rect=db2.pcb_silkscreen_rect.get(this.pcb_silkscreen_rect_id);rect&&db2.pcb_silkscreen_rect.update(this.pcb_silkscreen_rect_id,{center:{x:rect.center.x+deltaX,y:rect.center.y+deltaY}})}},SilkscreenLine=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"pcb_silkscreen_line_id",null);__publicField(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenLine",zodProps:silkscreenLineProps}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,{maybeFlipLayer}=this._getPcbPrimitiveFlippedHelpers(),layer=maybeFlipLayer(props.layer??"top");if(layer!=="top"&&layer!=="bottom")throw new Error(`Invalid layer "${layer}" for SilkscreenLine. Must be "top" or "bottom".`);let subcircuit=this.getSubcircuit(),pcb_component_id=this.parent?.pcb_component_id??this.getPrimitiveContainer()?.pcb_component_id,pcb_silkscreen_line2=db2.pcb_silkscreen_line.insert({pcb_component_id,layer,x1:props.x1,y1:props.y1,x2:props.x2,y2:props.y2,stroke_width:props.strokeWidth??.1,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:subcircuit?.getGroup()?.pcb_group_id??void 0});this.pcb_silkscreen_line_id=pcb_silkscreen_line2.pcb_silkscreen_line_id}getPcbSize(){let{_parsedProps:props}=this,width=Math.abs(props.x2-props.x1),height=Math.abs(props.y2-props.y1);return{width,height}}_moveCircuitJsonElements({deltaX,deltaY}){if(this.root?.pcbDisabled)return;let{db:db2}=this.root;if(!this.pcb_silkscreen_line_id)return;let line2=db2.pcb_silkscreen_line.get(this.pcb_silkscreen_line_id);line2&&db2.pcb_silkscreen_line.update(this.pcb_silkscreen_line_id,{x1:line2.x1+deltaX,y1:line2.y1+deltaY,x2:line2.x2+deltaX,y2:line2.y2+deltaY})}},Fiducial=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"pcb_smtpad_id",null);__publicField(this,"isPcbPrimitive",!0)}get config(){return{componentName:"Fiducial",zodProps:fiducialProps,sourceFtype:"simple_fiducial"}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,position2=this._getGlobalPcbPositionBeforeLayout(),{maybeFlipLayer}=this._getPcbPrimitiveFlippedHelpers(),pcb_component_id=this.parent?.pcb_component_id??this.getPrimitiveContainer()?.pcb_component_id,pcb_smtpad2=db2.pcb_smtpad.insert({pcb_component_id,layer:maybeFlipLayer(props.layer||"top"),shape:"circle",x:position2.x,y:position2.y,radius:distance.parse(props.padDiameter)/2,soldermask_margin:props.soldermaskPullback?distance.parse(props.soldermaskPullback):distance.parse(props.padDiameter)/2,is_covered_with_solder_mask:!0});this.pcb_smtpad_id=pcb_smtpad2.pcb_smtpad_id}getPcbSize(){let{_parsedProps:props}=this,d3=distance.parse(props.padDiameter);return{width:d3,height:d3}}_setPositionFromLayout(newCenter){if(!this.pcb_smtpad_id)return;let{db:db2}=this.root;db2.pcb_smtpad.update(this.pcb_smtpad_id,{x:newCenter.x,y:newCenter.y})}_moveCircuitJsonElements({deltaX,deltaY}){if(this.root?.pcbDisabled)return;let{db:db2}=this.root;if(!this.pcb_smtpad_id)return;let pad2=db2.pcb_smtpad.get(this.pcb_smtpad_id);pad2&&(pad2.shape==="rect"||pad2.shape==="circle"||pad2.shape==="rotated_rect"||pad2.shape==="pill"?this._setPositionFromLayout({x:pad2.x+deltaX,y:pad2.y+deltaY}):pad2.shape==="polygon"&&db2.pcb_smtpad.update(this.pcb_smtpad_id,{points:pad2.points.map(p2=>({x:p2.x+deltaX,y:p2.y+deltaY}))}))}},Via=class extends PrimitiveComponent2{constructor(props){super(props);__publicField(this,"pcb_via_id",null);__publicField(this,"matchedPort",null);__publicField(this,"isPcbPrimitive",!0);__publicField(this,"source_manually_placed_via_id",null);__publicField(this,"subcircuit_connectivity_map_key",null);let layers=this._getLayers();this._parsedProps.layers=layers,this.initPorts()}get config(){return{componentName:"Via",zodProps:viaProps}}getAvailablePcbLayers(){return["top","inner1","inner2","bottom"]}_getResolvedViaDiameters(pcbStyle2){return getViaDiameterDefaultsWithOverrides({holeDiameter:this._parsedProps.holeDiameter,padDiameter:this._parsedProps.outerDiameter},pcbStyle2)}getPcbSize(){let pcbStyle2=this.getInheritedMergedProperty("pcbStyle"),{padDiameter}=this._getResolvedViaDiameters(pcbStyle2);return{width:padDiameter,height:padDiameter}}_getPcbCircuitJsonBounds(){let{db:db2}=this.root,via=db2.pcb_via.get(this.pcb_via_id),size2=this.getPcbSize();return{center:{x:via.x,y:via.y},bounds:{left:via.x-size2.width/2,top:via.y-size2.height/2,right:via.x+size2.width/2,bottom:via.y+size2.height/2},width:size2.width,height:size2.height}}_setPositionFromLayout(newCenter){let{db:db2}=this.root;db2.pcb_via.update(this.pcb_via_id,{x:newCenter.x,y:newCenter.y})}_getLayers(){let{fromLayer="top",toLayer="bottom"}=this._parsedProps;return fromLayer===toLayer?[fromLayer]:[fromLayer,toLayer]}initPorts(){let layers=this._parsedProps.layers;for(let layer of layers){let port2=new Port({name:layer,layer});port2.registerMatch(this),this.add(port2)}let port=new Port({name:"pin1"});port.registerMatch(this),this.add(port)}_getConnectedNetOrTrace(){let connectsTo=this._parsedProps.connectsTo;if(!connectsTo)return null;let subcircuit=this.getSubcircuit(),selectors=Array.isArray(connectsTo)?connectsTo:[connectsTo];for(let selector of selectors)if(selector.startsWith("net.")){let net=subcircuit.selectOne(selector,{type:"net"});if(net)return net}return null}doInitialPcbComponentRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,pcbStyle2=this.getInheritedMergedProperty("pcbStyle"),{padDiameter}=this._getResolvedViaDiameters(pcbStyle2),position2=this._getGlobalPcbPositionBeforeLayout(),subcircuit=this.getSubcircuit(),pcb_component2=db2.pcb_component.insert({center:position2,width:padDiameter,height:padDiameter,layer:this._parsedProps.fromLayer??"top",rotation:0,source_component_id:this.source_component_id,subcircuit_id:subcircuit?.subcircuit_id??void 0,obstructs_within_bounds:!0});this.pcb_component_id=pcb_component2.pcb_component_id}doInitialSourceRender(){let{db:db2}=this.root,{_parsedProps:props}=this,group=this.getGroup(),subcircuit=this.getSubcircuit(),source_via=db2.source_manually_placed_via.insert({source_group_id:group?.source_group_id,source_net_id:props.net??"",subcircuit_id:subcircuit?.subcircuit_id??void 0});this.source_component_id=source_via.source_manually_placed_via_id}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,pcbStyle2=this.getInheritedMergedProperty("pcbStyle"),{holeDiameter,padDiameter}=this._getResolvedViaDiameters(pcbStyle2),position2=this._getGlobalPcbPositionBeforeLayout(),subcircuit=this.getSubcircuit(),pcb_via2=db2.pcb_via.insert({x:position2.x,y:position2.y,hole_diameter:holeDiameter,outer_diameter:padDiameter,layers:["bottom","top"],from_layer:this._parsedProps.fromLayer||"bottom",to_layer:this._parsedProps.toLayer||"top",subcircuit_id:subcircuit?.subcircuit_id??void 0,subcircuit_connectivity_map_key:this.subcircuit_connectivity_map_key??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0,net_is_assignable:this._parsedProps.netIsAssignable??void 0});this.pcb_via_id=pcb_via2.pcb_via_id}},CopperPour=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"isPcbPrimitive",!0)}get config(){return{componentName:"CopperPour",zodProps:copperPourProps}}getPcbSize(){return{width:0,height:0}}doInitialCreateNetsFromProps(){let{_parsedProps:props}=this;createNetsFromProps(this,[props.connectsTo])}doInitialPcbCopperPourRender(){this.root?.pcbDisabled||this._queueAsyncEffect("PcbCopperPourRender",async()=>{let{db:db2}=this.root,{_parsedProps:props}=this,net=this.getSubcircuit().selectOne(props.connectsTo);if(!net||!net.source_net_id){this.renderError(`Net "${props.connectsTo}" not found for copper pour`);return}let subcircuit=this.getSubcircuit(),sourceNet=db2.toArray().filter(elm=>elm.type==="source_net"&&elm.name===net.name)[0]||"",clearance=props.clearance??.2,inputProblem=convertCircuitJsonToInputProblem(db2.toArray(),{layer:props.layer,pour_connectivity_key:sourceNet.subcircuit_connectivity_map_key||"",pad_margin:props.padMargin??clearance,trace_margin:props.traceMargin??clearance,board_edge_margin:props.boardEdgeMargin??clearance,cutout_margin:props.cutoutMargin??clearance}),solver=new CopperPourPipelineSolver(inputProblem);this.root.emit("solver:started",{solverName:"CopperPourPipelineSolver",solverParams:inputProblem,componentName:this.props.name});let{brep_shapes}=solver.getOutput(),coveredWithSolderMask=props.coveredWithSolderMask??!1;for(let brep_shape2 of brep_shapes)db2.pcb_copper_pour.insert({shape:"brep",layer:props.layer,brep_shape:brep_shape2,source_net_id:net.source_net_id,subcircuit_id:subcircuit?.subcircuit_id??void 0,covered_with_solder_mask:coveredWithSolderMask})})}},CopperText=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"isPcbPrimitive",!0);__publicField(this,"pcb_copper_text_id",null)}get config(){return{componentName:"CopperText",zodProps:copperTextProps}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,container=this.getPrimitiveContainer(),position2=this._getGlobalPcbPositionBeforeLayout(),subcircuit=this.getSubcircuit(),pcb_copper_text2=db2.pcb_copper_text.insert({anchor_alignment:props.anchorAlignment,anchor_position:{x:position2.x,y:position2.y},font:"tscircuit2024",font_size:props.fontSize,layer:props.layer??"top",text:normalizeTextForCircuitJson(props.text),ccw_rotation:props.pcbRotation,is_mirrored:props.mirrored,is_knockout:props.knockout,pcb_component_id:container.pcb_component_id,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0});this.pcb_copper_text_id=pcb_copper_text2.pcb_copper_text_id}getPcbSize(){let{_parsedProps:props}=this,fontSize=props.fontSize??1,textWidth=(props.text??"").length*fontSize,textHeight=fontSize;return{width:textWidth*fontSize,height:textHeight*fontSize}}_moveCircuitJsonElements({deltaX,deltaY}){if(this.root?.pcbDisabled)return;let{db:db2}=this.root;if(!this.pcb_copper_text_id)return;let text=db2.pcb_copper_text.get(this.pcb_copper_text_id);text&&db2.pcb_copper_text.update(this.pcb_copper_text_id,{anchor_position:{x:text.anchor_position.x+deltaX,y:text.anchor_position.y+deltaY}})}},Battery=class extends NormalComponent3{get config(){return{componentName:"Battery",schematicSymbolName:this.props.symbolName??"battery",zodProps:batteryProps,sourceFtype:"simple_power_source"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}doInitialSourceRender(){let{db:db2}=this.root,{_parsedProps:props}=this,source_component=db2.source_component.insert({name:this.name,ftype:"simple_power_source",capacity:props.capacity,supplier_part_numbers:props.supplierPartNumbers,are_pins_interchangeable:!1});this.source_component_id=source_component.source_component_id}},PinHeader=class extends NormalComponent3{_getPcbRotationBeforeLayout(){let orientationRotation=this.props.pcbOrientation==="vertical"?-90:0;return(super._getPcbRotationBeforeLayout()??0)+orientationRotation}get config(){return{componentName:"PinHeader",zodProps:pinHeaderProps,shouldRenderAsSchematicBox:!0}}_getImpliedFootprintString(){let pinCount=this._parsedProps.pinCount??(Array.isArray(this._parsedProps.pinLabels)?this._parsedProps.pinLabels.length:this._parsedProps.pinLabels?Object.keys(this._parsedProps.pinLabels).length:0),holeDiameter=this._parsedProps.holeDiameter,platedDiameter=this._parsedProps.platedDiameter,pitch=this._parsedProps.pitch,showSilkscreenPinLabels=this._parsedProps.showSilkscreenPinLabels,rows=this._parsedProps.doubleRow?2:1;if(pinCount>0){let footprintString;if(pitch)!holeDiameter&&!platedDiameter?footprintString=`pinrow${pinCount}_p${pitch}`:footprintString=`pinrow${pinCount}_p${pitch}_id${holeDiameter}_od${platedDiameter}`;else if(!holeDiameter&&!platedDiameter)footprintString=`pinrow${pinCount}`;else return null;return showSilkscreenPinLabels!==!0&&(footprintString+="_nopinlabels"),rows>1&&(footprintString+=`_rows${rows}`),footprintString}return null}initPorts(){let pinCount=this._parsedProps.pinCount??(Array.isArray(this._parsedProps.pinLabels)?this._parsedProps.pinLabels.length:this._parsedProps.pinLabels?Object.keys(this._parsedProps.pinLabels).length:1);for(let i3=1;i3<=pinCount;i3++){let rawLabel=Array.isArray(this._parsedProps.pinLabels)?this._parsedProps.pinLabels[i3-1]:this._parsedProps.pinLabels?.[`pin${i3}`];if(rawLabel){let primaryLabel=Array.isArray(rawLabel)?rawLabel[0]:rawLabel,otherLabels=Array.isArray(rawLabel)?rawLabel.slice(1):[];this.add(new Port({pinNumber:i3,name:primaryLabel,aliases:[`pin${i3}`,...otherLabels]}))}else this.add(new Port({pinNumber:i3,name:`pin${i3}`}))}}_getSchematicPortArrangement(){let pinCount=this._parsedProps.pinCount??1,facingDirection=this._parsedProps.schFacingDirection??this._parsedProps.facingDirection??"right",schPinArrangement=this._parsedProps.schPinArrangement;return facingDirection==="left"?{leftSide:{direction:schPinArrangement?.leftSide?.direction??"top-to-bottom",pins:schPinArrangement?.leftSide?.pins??Array.from({length:pinCount},(_4,i3)=>`pin${i3+1}`)}}:{rightSide:{direction:schPinArrangement?.rightSide?.direction??"top-to-bottom",pins:schPinArrangement?.rightSide?.pins??Array.from({length:pinCount},(_4,i3)=>`pin${i3+1}`)}}}doInitialSourceRender(){let{db:db2}=this.root,{_parsedProps:props}=this,source_component=db2.source_component.insert({ftype:"simple_pin_header",name:this.name,supplier_part_numbers:props.supplierPartNumbers,pin_count:props.pinCount,gender:props.gender,are_pins_interchangeable:!0});this.source_component_id=source_component.source_component_id}};function getResonatorSymbolName(variant){switch(variant){case"two_ground_pins":return"crystal_4pin";case"ground_pin":return"resonator";case"no_ground":return"crystal";default:return"crystal"}}var Resonator=class extends NormalComponent3{get config(){return{componentName:"Resonator",schematicSymbolName:this.props.symbolName??getResonatorSymbolName(this.props.pinVariant),zodProps:resonatorProps,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){let{db:db2}=this.root,{_parsedProps:props}=this,pinVariant=props.pinVariant||"no_ground",source_component=db2.source_component.insert({ftype:"simple_resonator",name:this.name,frequency:props.frequency,load_capacitance:props.loadCapacitance,supplier_part_numbers:props.supplierPartNumbers,pin_variant:pinVariant,are_pins_interchangeable:pinVariant==="no_ground"||pinVariant==="ground_pin"});this.source_component_id=source_component.source_component_id}_getSchematicSymbolDisplayValue(){let freqDisplay=`${formatSiUnit(this._parsedProps.frequency)}Hz`;return this._parsedProps.loadCapacitance?`${freqDisplay} / ${formatSiUnit(this._parsedProps.loadCapacitance)}F`:freqDisplay}};function getPotentiometerSymbolName(variant){switch(variant){case"three_pin":return"potentiometer3";case"two_pin":return"potentiometer2";default:return"potentiometer2"}}var Potentiometer=class extends NormalComponent3{get config(){return{componentName:"Potentiometer",schematicSymbolName:this.props.symbolName??getPotentiometerSymbolName(this.props.pinVariant),zodProps:potentiometerProps,shouldRenderAsSchematicBox:!1}}_getSchematicSymbolDisplayValue(){return`${formatSiUnit(this._parsedProps.maxResistance)}\u03A9`}doInitialSourceRender(){let{db:db2}=this.root,{_parsedProps:props}=this,pinVariant=props.pinVariant||"two_pin",source_component=db2.source_component.insert({ftype:"simple_potentiometer",name:this.name,max_resistance:props.maxResistance,pin_variant:pinVariant,are_pins_interchangeable:pinVariant==="two_pin"});this.source_component_id=source_component.source_component_id}},PushButton=class extends NormalComponent3{get config(){return{componentName:"PushButton",schematicSymbolName:this.props.symbolName??"push_button_normally_open_momentary",zodProps:pushButtonProps,sourceFtype:FTYPE.simple_push_button}}get defaultInternallyConnectedPinNames(){return[]}initPorts(){super.initPorts({pinCount:2,ignoreSymbolPorts:!0});let symbol=cf[this._getSchematicSymbolNameOrThrow()],symPort1=symbol.ports.find(p2=>p2.labels.includes("1")),symPort2=symbol.ports.find(p2=>p2.labels.includes("2")),ports=this.selectAll("port"),pin1Port=ports.find(p2=>p2.props.pinNumber===1),pin2Port=ports.find(p2=>p2.props.pinNumber===2),pin3Port=ports.find(p2=>p2.props.pinNumber===3),pin4Port=ports.find(p2=>p2.props.pinNumber===4),{internallyConnectedPins}=this._parsedProps;pin1Port.schematicSymbolPortDef=symPort1,(!internallyConnectedPins||internallyConnectedPins.length===0)&&(pin2Port.schematicSymbolPortDef=symPort2);for(let[pn3,port]of[[2,pin2Port],[3,pin3Port],[4,pin4Port]]){let internallyConnectedRow=internallyConnectedPins?.find(([pin1,pin2])=>pin1===`pin${pn3}`||pin2===`pin${pn3}`);if(!internallyConnectedRow){port.schematicSymbolPortDef=symPort2;break}(internallyConnectedRow?.[0]===`pin${pn3}`?internallyConnectedRow[1]:internallyConnectedRow?.[0])!=="pin1"&&(port.schematicSymbolPortDef=symPort2)}}doInitialSourceRender(){let{db:db2}=this.root,{_parsedProps:props}=this,source_component=db2.source_component.insert({name:this.name,ftype:FTYPE.simple_push_button,supplier_part_numbers:props.supplierPartNumbers,are_pins_interchangeable:!0});this.source_component_id=source_component.source_component_id}},Crystal=class extends NormalComponent3{get config(){return{schematicSymbolName:this.props.symbolName??(this.props.pinVariant==="four_pin"?"crystal_4pin":"crystal"),componentName:"Crystal",zodProps:crystalProps,sourceFtype:"simple_crystal"}}initPorts(){let additionalAliases=this.props.pinVariant==="four_pin"?{pin1:["left1","1"],pin2:["top1","2","gnd1"],pin3:["right1","3"],pin4:["bottom1","4","gnd2"]}:{pin1:["pos","left"],pin2:["neg","right"]};super.initPorts({additionalAliases})}_getSchematicSymbolDisplayValue(){let freqDisplay=`${formatSiUnit(this._parsedProps.frequency)}Hz`;return this._parsedProps.loadCapacitance?`${freqDisplay} / ${formatSiUnit(this._parsedProps.loadCapacitance)}F`:freqDisplay}doInitialSourceRender(){let{db:db2}=this.root,{_parsedProps:props}=this,source_component=db2.source_component.insert({name:this.name,ftype:"simple_crystal",frequency:props.frequency,load_capacitance:props.loadCapacitance,pin_variant:props.pinVariant||"two_pin",are_pins_interchangeable:(props.pinVariant||"two_pin")==="two_pin"});this.source_component_id=source_component.source_component_id}},Mosfet=class extends NormalComponent3{get config(){let mosfetMode=this.props.mosfetMode==="depletion"?"d":"e",baseSymbolName=`${this.props.channelType}_channel_${mosfetMode}_mosfet_transistor`;return{componentName:"Mosfet",schematicSymbolName:this.props.symbolName??baseSymbolName,zodProps:mosfetProps,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){let{db:db2}=this.root,{_parsedProps:props}=this,source_component=db2.source_component.insert({ftype:"simple_mosfet",name:this.name,mosfet_mode:props.mosfetMode,channel_type:props.channelType});this.source_component_id=source_component.source_component_id}},OpAmp=class extends NormalComponent3{constructor(){super(...arguments);__publicField(this,"inverting_input",this.portMap.inverting_input);__publicField(this,"non_inverting_input",this.portMap.non_inverting_input);__publicField(this,"output",this.portMap.output);__publicField(this,"positive_supply",this.portMap.positive_supply);__publicField(this,"negative_supply",this.portMap.negative_supply)}get config(){let hasPowerConnections=this.props.connections?.positive_supply||this.props.connections?.negative_supply;return{componentName:"OpAmp",schematicSymbolName:this.props.symbolName?this.props.symbolName:hasPowerConnections?"opamp_with_power":"opamp_no_power",zodProps:opampProps,sourceFtype:"simple_op_amp"}}initPorts(){super.initPorts({pinCount:5,additionalAliases:{pin1:["non_inverting_input"],pin2:["inverting_input"],pin3:["output"],pin4:["positive_supply","vcc","vdd"],pin5:["negative_supply","vee","vss","gnd"]}})}doInitialSourceRender(){let{db:db2}=this.root,{_parsedProps:props}=this,source_component=db2.source_component.insert({ftype:"simple_op_amp",name:this.name,supplier_part_numbers:props.supplierPartNumbers});this.source_component_id=source_component.source_component_id}doInitialSimulationRender(){let{db:db2}=this.root,invertingInputPort=this.portMap.inverting_input,nonInvertingInputPort=this.portMap.non_inverting_input,outputPort=this.portMap.output,positiveSupplyPort=this.portMap.positive_supply,negativeSupplyPort=this.portMap.negative_supply;!invertingInputPort?.source_port_id||!nonInvertingInputPort?.source_port_id||!outputPort?.source_port_id||!positiveSupplyPort?.source_port_id||!negativeSupplyPort?.source_port_id||db2.simulation_op_amp.insert({type:"simulation_op_amp",source_component_id:this.source_component_id,inverting_input_source_port_id:invertingInputPort.source_port_id,non_inverting_input_source_port_id:nonInvertingInputPort.source_port_id,output_source_port_id:outputPort.source_port_id,positive_supply_source_port_id:positiveSupplyPort.source_port_id,negative_supply_source_port_id:negativeSupplyPort.source_port_id})}};function hasSimProps(props){return props.simSwitchFrequency!==void 0||props.simCloseAt!==void 0||props.simOpenAt!==void 0||props.simStartClosed!==void 0||props.simStartOpen!==void 0}var Switch=class extends NormalComponent3{_getSwitchType(){let props=this._parsedProps;return props?props.dpdt?"dpdt":props.spst?"spst":props.spdt?"spdt":props.dpst?"dpst":props.type??"spst":"spst"}get config(){let switchType=this._getSwitchType(),isNormallyClosed=this._parsedProps?.isNormallyClosed??!1,symbolMap={spst:isNormallyClosed?"spst_normally_closed_switch":"spst_switch",spdt:isNormallyClosed?"spdt_normally_closed_switch":"spdt_switch",dpst:isNormallyClosed?"dpst_normally_closed_switch":"dpst_switch",dpdt:isNormallyClosed?"dpdt_normally_closed_switch":"dpdt_switch"};return{componentName:"Switch",schematicSymbolName:this.props.symbolName??symbolMap[switchType],zodProps:switchProps,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){let{db:db2}=this.root,props=this._parsedProps??{},source_component=db2.source_component.insert({ftype:"simple_switch",name:this.name,are_pins_interchangeable:this._getSwitchType()==="spst"});this.source_component_id=source_component.source_component_id}doInitialSimulationRender(){let{_parsedProps:props}=this;if(!hasSimProps(props))return;let{db:db2}=this.root,simulationSwitch={type:"simulation_switch",source_component_id:this.source_component_id||""};props.simSwitchFrequency!==void 0&&(simulationSwitch.switching_frequency=frequency.parse(props.simSwitchFrequency)),props.simCloseAt!==void 0&&(simulationSwitch.closes_at=ms.parse(props.simCloseAt)),props.simOpenAt!==void 0&&(simulationSwitch.opens_at=ms.parse(props.simOpenAt)),props.simStartOpen!==void 0&&(simulationSwitch.starts_closed=!props.simStartOpen),props.simStartClosed!==void 0&&(simulationSwitch.starts_closed=props.simStartClosed),db2.simulation_switch.insert(simulationSwitch)}},TESTPOINT_DEFAULTS={HOLE_DIAMETER:.5,SMT_CIRCLE_DIAMETER:1.2,SMT_RECT_SIZE:2},TestPoint=class extends NormalComponent3{get config(){return{componentName:"TestPoint",schematicSymbolName:this.props.symbolName??"testpoint",zodProps:testpointProps,sourceFtype:FTYPE.simple_test_point}}_getPropsWithDefaults(){let{padShape,holeDiameter,footprintVariant,padDiameter,width,height}=this._parsedProps;return!footprintVariant&&holeDiameter&&(footprintVariant="through_hole"),footprintVariant??(footprintVariant="through_hole"),padShape??(padShape="circle"),footprintVariant==="pad"?padShape==="circle"?padDiameter??(padDiameter=TESTPOINT_DEFAULTS.SMT_CIRCLE_DIAMETER):padShape==="rect"&&(width??(width=TESTPOINT_DEFAULTS.SMT_RECT_SIZE),height??(height=width)):footprintVariant==="through_hole"&&(holeDiameter??(holeDiameter=TESTPOINT_DEFAULTS.HOLE_DIAMETER)),{padShape,holeDiameter,footprintVariant,padDiameter,width,height}}_getImpliedFootprintString(){let{padShape,holeDiameter,footprintVariant,padDiameter,width,height}=this._getPropsWithDefaults();if(footprintVariant==="through_hole")return`platedhole_d${holeDiameter}`;if(footprintVariant==="pad"){if(padShape==="circle")return`smtpad_circle_d${padDiameter}`;if(padShape==="rect")return`smtpad_rect_w${width}_h${height}`}throw new Error(`Footprint variant "${footprintVariant}" with pad shape "${padShape}" not implemented`)}doInitialSourceRender(){let{db:db2}=this.root,{_parsedProps:props}=this,{padShape,holeDiameter,footprintVariant,padDiameter,width,height}=this._getPropsWithDefaults(),source_component=db2.source_component.insert({ftype:FTYPE.simple_test_point,name:this.name,supplier_part_numbers:props.supplierPartNumbers,footprint_variant:footprintVariant,pad_shape:padShape,pad_diameter:padDiameter,hole_diameter:holeDiameter,width,height,are_pins_interchangeable:!0});this.source_component_id=source_component.source_component_id}},SchematicText=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"isSchematicPrimitive",!0)}get config(){return{componentName:"SchematicText",zodProps:schematicTextProps}}doInitialSchematicPrimitiveRender(){if(this.root?.schematicDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,globalPos=this._getGlobalSchematicPositionBeforeLayout();db2.schematic_text.insert({anchor:props.anchor??"center",text:normalizeTextForCircuitJson(props.text),font_size:props.fontSize,color:props.color||"#000000",position:{x:globalPos.x,y:globalPos.y},rotation:props.schRotation??0})}},SchematicLine=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"isSchematicPrimitive",!0);__publicField(this,"schematic_line_id")}get config(){return{componentName:"SchematicLine",zodProps:schematicLineProps}}doInitialSchematicPrimitiveRender(){if(this.root?.schematicDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,globalPos=this._getGlobalSchematicPositionBeforeLayout(),schematic_component_id=this.getPrimitiveContainer()?.parent?.schematic_component_id,schematic_line2=db2.schematic_line.insert({schematic_component_id,x1:props.x1+globalPos.x,y1:props.y1+globalPos.y,x2:props.x2+globalPos.x,y2:props.y2+globalPos.y,stroke_width:props.strokeWidth??SCHEMATIC_COMPONENT_OUTLINE_STROKE_WIDTH,color:props.color??SCHEMATIC_COMPONENT_OUTLINE_COLOR,is_dashed:!1,subcircuit_id:this.getSubcircuit().subcircuit_id??void 0});this.schematic_line_id=schematic_line2.schematic_line_id}},SchematicRect=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"isSchematicPrimitive",!0);__publicField(this,"schematic_rect_id")}get config(){return{componentName:"SchematicRect",zodProps:schematicRectProps}}doInitialSchematicPrimitiveRender(){if(this.root?.schematicDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,globalPos=this._getGlobalSchematicPositionBeforeLayout(),schematic_component_id=this.getPrimitiveContainer()?.parent?.schematic_component_id,schematic_rect2=db2.schematic_rect.insert({center:{x:globalPos.x,y:globalPos.y},width:props.width,height:props.height,stroke_width:props.strokeWidth??SCHEMATIC_COMPONENT_OUTLINE_STROKE_WIDTH,color:props.color??SCHEMATIC_COMPONENT_OUTLINE_COLOR,is_filled:props.isFilled,schematic_component_id,is_dashed:props.isDashed,rotation:props.rotation??0,subcircuit_id:this.getSubcircuit().subcircuit_id??void 0});this.schematic_rect_id=schematic_rect2.schematic_rect_id}},SchematicArc=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"isSchematicPrimitive",!0);__publicField(this,"schematic_arc_id")}get config(){return{componentName:"SchematicArc",zodProps:schematicArcProps}}doInitialSchematicPrimitiveRender(){if(this.root?.schematicDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,globalPos=this._getGlobalSchematicPositionBeforeLayout(),schematic_component_id=this.getPrimitiveContainer()?.parent?.schematic_component_id,schematic_arc2=db2.schematic_arc.insert({schematic_component_id,center:{x:props.center.x+globalPos.x,y:props.center.y+globalPos.y},radius:props.radius,start_angle_degrees:props.startAngleDegrees,end_angle_degrees:props.endAngleDegrees,direction:props.direction,stroke_width:props.strokeWidth??SCHEMATIC_COMPONENT_OUTLINE_STROKE_WIDTH,color:props.color??SCHEMATIC_COMPONENT_OUTLINE_COLOR,is_dashed:props.isDashed,subcircuit_id:this.getSubcircuit().subcircuit_id??void 0});this.schematic_arc_id=schematic_arc2.schematic_arc_id}},SchematicCircle=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"isSchematicPrimitive",!0);__publicField(this,"schematic_circle_id")}get config(){return{componentName:"SchematicCircle",zodProps:schematicCircleProps}}doInitialSchematicPrimitiveRender(){if(this.root?.schematicDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,globalPos=this._getGlobalSchematicPositionBeforeLayout(),schematic_component_id=this.getPrimitiveContainer()?.parent?.schematic_component_id,schematic_circle2=db2.schematic_circle.insert({schematic_component_id,center:{x:props.center.x+globalPos.x,y:props.center.y+globalPos.y},radius:props.radius,stroke_width:props.strokeWidth??SCHEMATIC_COMPONENT_OUTLINE_STROKE_WIDTH,color:props.color??SCHEMATIC_COMPONENT_OUTLINE_COLOR,is_filled:props.isFilled,fill_color:props.fillColor,is_dashed:props.isDashed,subcircuit_id:this.getSubcircuit().subcircuit_id??void 0});this.schematic_circle_id=schematic_circle2.schematic_circle_id}};function getTitleAnchorAndPosition({anchor,x:x3,y:y3,width,height,isInside}){switch(anchor){case"top_left":return{x:x3,y:y3+height,textAnchor:isInside?"top_left":"bottom_left"};case"top_center":return{x:x3+width/2,y:y3+height,textAnchor:isInside?"top_center":"bottom_center"};case"top_right":return{x:x3+width,y:y3+height,textAnchor:isInside?"top_right":"bottom_right"};case"center_left":return{x:x3,y:y3+height/2,textAnchor:isInside?"center_left":"center_right"};case"center":return{x:x3+width/2,y:y3+height/2,textAnchor:"center"};case"center_right":return{x:x3+width,y:y3+height/2,textAnchor:isInside?"center_right":"center_left"};case"bottom_left":return{x:x3,y:y3,textAnchor:isInside?"bottom_left":"top_left"};case"bottom_center":return{x:x3+width/2,y:y3,textAnchor:isInside?"bottom_center":"top_center"};case"bottom_right":return{x:x3+width,y:y3,textAnchor:isInside?"bottom_right":"top_right"};default:return{x:x3+width/2,y:y3+height,textAnchor:"center"}}}var SchematicBox=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"isSchematicPrimitive",!0)}get config(){return{componentName:"SchematicBox",zodProps:schematicBoxProps,shouldRenderAsSchematicBox:!0}}doInitialSchematicPrimitiveRender(){if(this.root?.schematicDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,basePadding=.6,generalPadding=typeof props.padding=="number"?props.padding:0,paddingTop=typeof props.paddingTop=="number"?props.paddingTop:generalPadding,paddingBottom=typeof props.paddingBottom=="number"?props.paddingBottom:generalPadding,paddingLeft=typeof props.paddingLeft=="number"?props.paddingLeft:generalPadding,paddingRight=typeof props.paddingRight=="number"?props.paddingRight:generalPadding,hasOverlay=props.overlay&&props.overlay.length>0,hasFixedSize=typeof props.width=="number"&&typeof props.height=="number",width,height,x3,y3,centerX,centerY;if(hasOverlay){let portsWithPosition=props.overlay.map(selector=>({selector,port:this.getSubcircuit().selectOne(selector,{type:"port"})})).filter(({port})=>port!=null).map(({port})=>({position:port._getGlobalSchematicPositionAfterLayout()}));if(portsWithPosition.length===0)return;let xs3=portsWithPosition.map(p2=>p2.position.x),ys3=portsWithPosition.map(p2=>p2.position.y),minX=Math.min(...xs3),maxX=Math.max(...xs3),minY=Math.min(...ys3),maxY=Math.max(...ys3),rawWidth=maxX-minX,rawHeight=maxY-minY,defaultHorizontalPadding=rawWidth===0?basePadding:0,defaultVerticalPadding=rawHeight===0?basePadding:0,finalPaddingLeft=paddingLeft+defaultHorizontalPadding/2,finalPaddingRight=paddingRight+defaultHorizontalPadding/2,finalPaddingTop=paddingTop+defaultVerticalPadding/2,finalPaddingBottom=paddingBottom+defaultVerticalPadding/2,left=minX-finalPaddingLeft,right=maxX+finalPaddingRight,top=minY-finalPaddingBottom,bottom=maxY+finalPaddingTop;width=right-left,height=bottom-top,x3=left+(props.schX??0),y3=top+(props.schY??0),centerX=x3+width/2,centerY=y3+height/2}else if(hasFixedSize){width=props.width,height=props.height;let center2=this._getGlobalSchematicPositionBeforeLayout();centerX=center2.x,centerY=center2.y,x3=centerX-width/2,y3=centerY-height/2}else return;if(db2.schematic_box.insert({height,width,x:x3,y:y3,is_dashed:props.strokeStyle==="dashed"}),props.title){let isInside=props.titleInside,TITLE_PADDING=.1,anchor=props.titleAlignment,anchorPos=getTitleAnchorAndPosition({anchor,x:x3,y:y3,width,height,isInside}),titleOffsetY,titleOffsetX,textAnchor=anchorPos.textAnchor;isInside?(titleOffsetY=anchor.includes("top")?-TITLE_PADDING:anchor.includes("bottom")?TITLE_PADDING:0,titleOffsetX=anchor.includes("left")?TITLE_PADDING:anchor.includes("right")?-TITLE_PADDING:0):(titleOffsetY=anchor.includes("top")?TITLE_PADDING:anchor.includes("bottom")?-TITLE_PADDING:0,titleOffsetX=anchor.includes("center_left")?-TITLE_PADDING:anchor.includes("center_right")?TITLE_PADDING:0);let titleX=anchorPos.x+titleOffsetX,titleY=anchorPos.y+titleOffsetY;db2.schematic_text.insert({anchor:textAnchor,text:props.title,font_size:props.titleFontSize??.18,color:props.titleColor??"#000000",position:{x:titleX,y:titleY},rotation:0})}}},SchematicTable=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"isSchematicPrimitive",!0);__publicField(this,"schematic_table_id",null)}get config(){return{componentName:"SchematicTable",zodProps:schematicTableProps}}doInitialSchematicPrimitiveRender(){if(this.root?.schematicDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,rows=this.children.filter(c3=>c3.componentName==="SchematicRow");if(rows.length===0)return;let grid4=[],maxCols=0;for(let row of rows){let cells=row.children.filter(c3=>c3.componentName==="SchematicCell");maxCols=Math.max(maxCols,cells.length)}for(let i3=0;i3<rows.length;i3++)grid4[i3]=[];for(let i3=0;i3<rows.length;i3++){let cells=rows[i3].children.filter(c3=>c3.componentName==="SchematicCell"),k4=0;for(let j3=0;j3<cells.length;j3++){for(;grid4[i3][k4];)k4++;let cell=cells[j3],colSpan=cell._parsedProps.colSpan??1,rowSpan=cell._parsedProps.rowSpan??1;for(let r4=0;r4<rowSpan;r4++)for(let c3=0;c3<colSpan;c3++)grid4[i3+r4]||(grid4[i3+r4]=[]),grid4[i3+r4][k4+c3]=cell;k4+=colSpan}}maxCols=Math.max(0,...grid4.map(r4=>r4.length));let rowHeights=rows.map((row,i3)=>row._parsedProps.height??1),colWidths=Array.from({length:maxCols},(_4,j3)=>{let maxWidth=0;for(let i3=0;i3<rows.length;i3++){let cell=grid4[i3]?.[j3];if(cell){let text=cell._parsedProps.text??cell._parsedProps.children,cellWidth=cell._parsedProps.width??(text?.length??2)*.5;cellWidth>maxWidth&&(maxWidth=cellWidth)}}return maxWidth||10}),anchorPos=this._getGlobalSchematicPositionBeforeLayout(),table=db2.schematic_table.insert({anchor_position:anchorPos,column_widths:colWidths,row_heights:rowHeights,cell_padding:props.cellPadding,border_width:props.borderWidth,anchor:props.anchor,subcircuit_id:this.getSubcircuit()?.subcircuit_id||"",schematic_component_id:this.parent?.schematic_component_id||""});this.schematic_table_id=table.schematic_table_id;let processedCells=new Set,yOffset=0;for(let i3=0;i3<rows.length;i3++){let xOffset=0;for(let j3=0;j3<maxCols;j3++){let cell=grid4[i3]?.[j3];if(cell&&!processedCells.has(cell)){processedCells.add(cell);let cellProps=cell._parsedProps,rowSpan=cellProps.rowSpan??1,colSpan=cellProps.colSpan??1,cellWidth=0;for(let c3=0;c3<colSpan;c3++)cellWidth+=colWidths[j3+c3];let cellHeight=0;for(let r4=0;r4<rowSpan;r4++)cellHeight+=rowHeights[i3+r4];db2.schematic_table_cell.insert({schematic_table_id:this.schematic_table_id,start_row_index:i3,end_row_index:i3+rowSpan-1,start_column_index:j3,end_column_index:j3+colSpan-1,text:cellProps.text??cellProps.children,center:{x:anchorPos.x+xOffset+cellWidth/2,y:anchorPos.y-yOffset-cellHeight/2},width:cellWidth,height:cellHeight,horizontal_align:cellProps.horizontalAlign,vertical_align:cellProps.verticalAlign,font_size:cellProps.fontSize??props.fontSize,subcircuit_id:this.getSubcircuit()?.subcircuit_id||""})}colWidths[j3]&&(xOffset+=colWidths[j3])}yOffset+=rowHeights[i3]}}},SchematicRow=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"isSchematicPrimitive",!0)}get config(){return{componentName:"SchematicRow",zodProps:schematicRowProps}}},SchematicCell=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"isSchematicPrimitive",!0);__publicField(this,"canHaveTextChildren",!0)}get config(){return{componentName:"SchematicCell",zodProps:schematicCellProps}}},SymbolComponent=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"isPrimitiveContainer",!0)}get config(){return{componentName:"Symbol",zodProps:symbolProps}}},AnalogSimulation=class extends PrimitiveComponent2{get config(){return{componentName:"AnalogSimulation",zodProps:analogSimulationProps}}doInitialSimulationRender(){let{db:db2}=this.root,{duration,timePerStep}=this._parsedProps,durationMs=duration||10,timePerStepMs=timePerStep||.01;db2.simulation_experiment.insert({name:"spice_transient_analysis",experiment_type:"spice_transient_analysis",end_time_ms:durationMs,time_per_step:timePerStepMs})}};function getLabelBounds(probePosition,labelText,alignment,labelOffset=.3){let labelWidth=Math.max(labelText.length*.1,.3),labelHeightWithPadding=.25+.2,anchorX=probePosition.x,anchorY=probePosition.y,offsetMultiplier=labelOffset+labelWidth/2;alignment.includes("top")?anchorY+=offsetMultiplier:alignment.includes("bottom")&&(anchorY-=offsetMultiplier),alignment.includes("right")?anchorX+=offsetMultiplier:alignment.includes("left")&&(anchorX-=offsetMultiplier);let minX,maxX,minY,maxY;return alignment.includes("left")?(minX=anchorX,maxX=anchorX+labelWidth):alignment.includes("right")?(minX=anchorX-labelWidth,maxX=anchorX):(minX=anchorX-labelWidth/2,maxX=anchorX+labelWidth/2),alignment.includes("top")?(minY=anchorY-labelHeightWithPadding,maxY=anchorY):alignment.includes("bottom")?(minY=anchorY,maxY=anchorY+labelHeightWithPadding):(minY=anchorY-labelHeightWithPadding/2,maxY=anchorY+labelHeightWithPadding/2),{minX,maxX,minY,maxY}}function getElementBounds(elm){let cx2,cy2,w4,h2;if(elm.type==="schematic_component")cx2=elm.center?.x,cy2=elm.center?.y,w4=elm.size?.width,h2=elm.size?.height;else if(elm.type==="schematic_text")cx2=elm.position?.x,cy2=elm.position?.y,w4=(elm.text?.length??0)*.1,h2=.2;else return null;return typeof cx2=="number"&&typeof cy2=="number"&&typeof w4=="number"&&typeof h2=="number"?{minX:cx2-w4/2,maxX:cx2+w4/2,minY:cy2-h2/2,maxY:cy2+h2/2}:null}function getOverlapArea(a2,b3){if(!doBoundsOverlap(a2,b3))return 0;let overlapWidth=Math.min(a2.maxX,b3.maxX)-Math.max(a2.minX,b3.minX),overlapHeight=Math.min(a2.maxY,b3.maxY)-Math.max(a2.minY,b3.minY);return overlapWidth*overlapHeight}function selectBestLabelAlignment({probePosition,labelText,schematicElements,defaultAlignment="top_right"}){let orderedAlignments=[defaultAlignment,...["top_right","top_left","bottom_right","bottom_left","top_center","bottom_center","center_right","center_left"].filter(a2=>a2!==defaultAlignment)],bestAlignment=defaultAlignment,minOverlapArea=1/0;for(let alignment of orderedAlignments){let labelBounds=getLabelBounds(probePosition,labelText,alignment),totalOverlapArea=0;for(let element of schematicElements){let elementBounds=getElementBounds(element);elementBounds&&(totalOverlapArea+=getOverlapArea(labelBounds,elementBounds))}if(totalOverlapArea===0)return alignment;totalOverlapArea<minOverlapArea&&(minOverlapArea=totalOverlapArea,bestAlignment=alignment)}return bestAlignment}var VoltageProbe=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"simulation_voltage_probe_id",null);__publicField(this,"schematic_voltage_probe_id",null);__publicField(this,"finalProbeName",null);__publicField(this,"color",null)}get config(){return{componentName:"VoltageProbe",zodProps:voltageProbeProps}}doInitialSimulationRender(){let{db:db2}=this.root,{connectsTo,name,referenceTo,color}=this._parsedProps,subcircuit=this.getSubcircuit();if(!subcircuit){this.renderError("VoltageProbe must be inside a subcircuit");return}let targets=Array.isArray(connectsTo)?connectsTo:[connectsTo];if(targets.length!==1){this.renderError("VoltageProbe must connect to exactly one port or net");return}let targetSelector=targets[0],port=subcircuit.selectOne(targetSelector,{type:"port"}),net=port?null:subcircuit.selectOne(targetSelector,{type:"net"});if(net&&net.componentName!=="Net"){this.renderError(`VoltageProbe connection target "${targetSelector}" resolved to a non-net component "${net.componentName}".`);return}if(!port&&!net){this.renderError(`VoltageProbe could not find connection target "${targetSelector}"`);return}let connectedId=port?.source_port_id??net?.source_net_id;if(!connectedId){this.renderError("Could not identify connected source for VoltageProbe");return}let referencePort=null,referenceNet=null;if(referenceTo){let referenceTargets=Array.isArray(referenceTo)?referenceTo:[referenceTo];if(referenceTargets.length!==1){this.renderError("VoltageProbe must reference exactly one port or net");return}let referenceSelector=referenceTargets[0];if(referencePort=subcircuit.selectOne(referenceSelector,{type:"port"}),referenceNet=referencePort?null:subcircuit.selectOne(referenceSelector,{type:"net"}),referenceNet&&referenceNet.componentName!=="Net"){this.renderError(`VoltageProbe reference target "${referenceSelector}" resolved to a non-net component "${referenceNet.componentName}".`);return}if(!referencePort&&!referenceNet){this.renderError(`VoltageProbe could not find reference target "${referenceSelector}"`);return}}this.color=color??getSimulationColorForId(connectedId);let finalName=name;finalName||(finalName=targets[0].split(" > ").map(s3=>s3.replace(/^\./,"")).join(".")),this.finalProbeName=finalName??null;let{simulation_voltage_probe_id}=db2.simulation_voltage_probe.insert({name:finalName,signal_input_source_port_id:port?.source_port_id??void 0,signal_input_source_net_id:net?.source_net_id??void 0,reference_input_source_port_id:referencePort?.source_port_id??void 0,reference_input_source_net_id:referenceNet?.source_net_id??void 0,subcircuit_id:subcircuit.subcircuit_id||void 0,color:this.color});this.simulation_voltage_probe_id=simulation_voltage_probe_id}doInitialSchematicReplaceNetLabelsWithSymbols(){if(this.root?.schematicDisabled)return;let{db:db2}=this.root,{connectsTo,name}=this._parsedProps,subcircuit=this.getSubcircuit();if(!subcircuit)return;let targets=Array.isArray(connectsTo)?connectsTo:[connectsTo];if(targets.length!==1)return;let targetSelector=targets[0],port=subcircuit.selectOne(targetSelector,{type:"port"});if(!port||!port.schematic_port_id)return;let position2=port._getGlobalSchematicPositionAfterLayout(),targetTraceId=null;for(let trace of db2.schematic_trace.list()){for(let edge of trace.edges)if(Math.abs(edge.from.x-position2.x)<1e-6&&Math.abs(edge.from.y-position2.y)<1e-6||Math.abs(edge.to.x-position2.x)<1e-6&&Math.abs(edge.to.y-position2.y)<1e-6){targetTraceId=trace.schematic_trace_id;break}if(targetTraceId)break}if(!targetTraceId)return;let probeName=this.finalProbeName,labelAlignment=selectBestLabelAlignment({probePosition:position2,labelText:probeName,schematicElements:[...db2.schematic_component.list(),...db2.schematic_text.list()],defaultAlignment:"top_right"}),schematic_voltage_probe2=db2.schematic_voltage_probe.insert({name:probeName,position:position2,schematic_trace_id:targetTraceId,subcircuit_id:subcircuit.subcircuit_id||void 0,color:this.color??void 0,label_alignment:labelAlignment});this.schematic_voltage_probe_id=schematic_voltage_probe2.schematic_voltage_probe_id}},package_default3={name:"@tscircuit/core",type:"module",version:"0.0.966",types:"dist/index.d.ts",main:"dist/index.js",module:"dist/index.js",exports:{".":{import:"./dist/index.js",types:"./dist/index.d.ts"}},files:["dist"],repository:{type:"git",url:"https://github.com/tscircuit/core"},scripts:{build:"tsup-node index.ts --format esm --dts",format:"biome format . --write","measure-bundle":"howfat -r table .","pkg-pr-new-release":"bunx pkg-pr-new publish --comment=off --peerDeps","smoke-test:dist":"bun run scripts/smoke-tests/test-dist-simple-circuit.tsx","build:benchmarking":"bun build --experimental-html ./benchmarking/website/index.html --outdir ./benchmarking-dist","build:benchmarking:watch":`chokidar "./{benchmarking,lib}/**/*.{ts,tsx}" -c 'bun build --experimental-html ./benchmarking/website/index.html --outdir ./benchmarking-dist'`,"start:benchmarking":'concurrently "bun run build:benchmarking:watch" "live-server ./benchmarking-dist"',"generate-test-plan":"bun run scripts/generate-test-plan.ts"},devDependencies:{"@biomejs/biome":"^1.8.3","@resvg/resvg-js":"^2.6.2","@tscircuit/capacity-autorouter":"^0.0.252","@tscircuit/checks":"^0.0.87","@tscircuit/circuit-json-util":"^0.0.73","@tscircuit/common":"^0.0.20","@tscircuit/copper-pour-solver":"^0.0.14","@tscircuit/footprinter":"^0.0.288","@tscircuit/infgrid-ijump-astar":"^0.0.35","@tscircuit/log-soup":"^1.0.2","@tscircuit/matchpack":"^0.0.16","@tscircuit/math-utils":"^0.0.29","@tscircuit/miniflex":"^0.0.4","@tscircuit/ngspice-spice-engine":"^0.0.8","@tscircuit/props":"^0.0.442","@tscircuit/schematic-match-adapt":"^0.0.16","@tscircuit/schematic-trace-solver":"^v0.0.45","@tscircuit/solver-utils":"^0.0.3","@types/bun":"^1.2.16","@types/debug":"^4.1.12","@types/react":"^19.1.8","@types/react-dom":"^19.1.6","@types/react-reconciler":"^0.28.9","bpc-graph":"^0.0.57","bun-match-svg":"0.0.12","calculate-elbow":"^0.0.12","chokidar-cli":"^3.0.0","circuit-json":"^0.0.350","circuit-json-to-bpc":"^0.0.13","circuit-json-to-connectivity-map":"^0.0.23","circuit-json-to-gltf":"^0.0.31","circuit-json-to-simple-3d":"^0.0.9","circuit-json-to-spice":"^0.0.33","circuit-to-svg":"^0.0.313",concurrently:"^9.1.2","connectivity-map":"^1.0.0",debug:"^4.3.6","eecircuit-engine":"^1.5.6",flatbush:"^4.5.0","graphics-debug":"^0.0.60",howfat:"^0.3.8","live-server":"^1.2.2","looks-same":"^9.0.1",minicssgrid:"^0.0.9","pkg-pr-new":"^0.0.37",poppygl:"^0.0.16",react:"^19.1.0","react-dom":"^19.1.0","schematic-symbols":"^0.0.206",spicey:"^0.0.14","ts-expect":"^1.3.0",tsup:"^8.2.4","@tscircuit/soup-util":"^0.0.41"},peerDependencies:{"@tscircuit/capacity-autorouter":"*","@tscircuit/checks":"*","@tscircuit/circuit-json-util":"*","@tscircuit/footprinter":"*","@tscircuit/infgrid-ijump-astar":"*","@tscircuit/math-utils":"*","@tscircuit/props":"*","@tscircuit/schematic-match-adapt":"*","circuit-json-to-bpc":"*","bpc-graph":"*","@tscircuit/matchpack":"*","circuit-json":"*","circuit-json-to-connectivity-map":"*","schematic-symbols":"*",typescript:"^5.0.0"},dependencies:{"@flatten-js/core":"^1.6.2","@lume/kiwi":"^0.4.3","calculate-packing":"0.0.68","css-select":"5.1.0","format-si-unit":"^0.0.3",nanoid:"^5.0.7","performance-now":"^2.1.0","react-reconciler":"^0.32.0","transformation-matrix":"^2.16.1",zod:"^3.25.67"}},RootCircuit=class{constructor({platform,projectUrl}={}){__publicField(this,"firstChild",null);__publicField(this,"children");__publicField(this,"db");__publicField(this,"root",null);__publicField(this,"isRoot",!0);__publicField(this,"_schematicDisabledOverride");__publicField(this,"pcbDisabled",!1);__publicField(this,"pcbRoutingDisabled",!1);__publicField(this,"_featureMspSchematicTraceRouting",!0);__publicField(this,"name");__publicField(this,"platform");__publicField(this,"projectUrl");__publicField(this,"_hasRenderedAtleastOnce",!1);__publicField(this,"_eventListeners",{});this.children=[],this.db=su2([]),this.root=this,this.platform=platform,this.projectUrl=projectUrl,this.pcbDisabled=platform?.pcbDisabled??!1}get schematicDisabled(){return this._schematicDisabledOverride!==void 0?this._schematicDisabledOverride:this._getBoard()?._parsedProps?.schematicDisabled??!1}set schematicDisabled(value){this._schematicDisabledOverride=value}add(componentOrElm){let component;(0,import_react4.isValidElement)(componentOrElm)?component=createInstanceFromReactElement(componentOrElm):component=componentOrElm,this.children.push(component)}setPlatform(platform){this.platform={...this.platform,...platform}}_getBoard(){let directBoard=this.children.find(c3=>c3.componentName==="Board");if(directBoard)return directBoard}_guessRootComponent(){if(this.firstChild)return;if(this.children.length===0)throw new Error("Not able to guess root component: RootCircuit has no children (use circuit.add(...))");let panels=this.children.filter(child=>child.lowercaseComponentName==="panel");if(panels.length>1)throw new Error("Only one <panel> is allowed per circuit");if(panels.length===1){if(this.children.length!==1)throw new Error("<panel> must be the root element of the circuit");this.firstChild=panels[0];return}if(this.children.length===1&&this.children[0].isGroup){this.firstChild=this.children[0];return}let group=new Group6({subcircuit:!0});group.parent=this,group.addAll(this.children),this.children=[group],this.firstChild=group}render(){this.firstChild||this._guessRootComponent();let{firstChild,db:db2}=this;if(!firstChild)throw new Error("RootCircuit has no root component");firstChild.parent=this,firstChild.runRenderCycle(),this._hasRenderedAtleastOnce=!0}async renderUntilSettled(){for(this.db.source_project_metadata.list()?.[0]||this.db.source_project_metadata.insert({software_used_string:`@tscircuit/core@${this.getCoreVersion()}`,...this.projectUrl?{project_url:this.projectUrl}:{}}),this.render();this._hasIncompleteAsyncEffects();)await new Promise(resolve=>setTimeout(resolve,100)),this.render();this.emit("renderComplete")}_hasIncompleteAsyncEffects(){return this.children.some(child=>child._hasIncompleteAsyncEffects())}getCircuitJson(){return this._hasRenderedAtleastOnce||this.render(),this.db.toArray()}toJson(){return this.getCircuitJson()}async getSvg(options){let circuitToSvg=await Promise.resolve().then(()=>(init_dist8(),dist_exports3)).catch(e4=>{throw new Error(`To use circuit.getSvg, you must install the "circuit-to-svg" package.
615
+ `),position2={x:pcbBoard.center.x+pcbBoard.width/2-.25,y:pcbBoard.center.y-pcbBoard.height/2+1};this.root.db.pcb_silkscreen_text.insert({pcb_component_id:this.pcb_board_id,layer:"top",font:"tscircuit2024",font_size:.45,text,ccw_rotation:0,anchor_alignment:"bottom_right",anchor_position:position2})}doInitialSourceRender(){let nestedBoard=this.getDescendants().find(d3=>d3.lowercaseComponentName==="board");if(nestedBoard)throw new Error(`Nested boards are not supported: found board "${nestedBoard.name}" inside board "${this.name}"`);super.doInitialSourceRender();let{db:db2}=this.root,source_board2=db2.source_board.insert({source_group_id:this.source_group_id,title:this.props.title||this.props.name});this.source_board_id=source_board2.source_board_id}doInitialInflateSubcircuitCircuitJson(){let{circuitJson,children}=this._parsedProps;inflateCircuitJson(this,circuitJson,children)}doInitialPcbComponentRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,pcbBoardFromCircuitJson=props.circuitJson?.find(elm=>elm.type==="pcb_board"),computedWidth=props.width??pcbBoardFromCircuitJson?.width??0,computedHeight=props.height??pcbBoardFromCircuitJson?.height??0,globalPos=this._getGlobalPcbPositionBeforeLayout(),center2={x:globalPos.x+(props.outlineOffsetX??0),y:globalPos.y+(props.outlineOffsetY??0)},{boardAnchorPosition,boardAnchorAlignment}=props;if(boardAnchorPosition&&(center2=getBoardCenterFromAnchor({boardAnchorPosition,boardAnchorAlignment:boardAnchorAlignment??"center",width:computedWidth,height:computedHeight})),props.outline){let xValues=props.outline.map(point23=>point23.x),yValues=props.outline.map(point23=>point23.y),minX=Math.min(...xValues),maxX=Math.max(...xValues),minY=Math.min(...yValues),maxY=Math.max(...yValues);computedWidth=maxX-minX,computedHeight=maxY-minY}let outline=props.outline;!outline&&props.borderRadius!=null&&computedWidth>0&&computedHeight>0&&(outline=getRoundedRectOutline(computedWidth,computedHeight,props.borderRadius));let pcb_board2=db2.pcb_board.insert({source_board_id:this.source_board_id,center:center2,thickness:this.boardThickness,num_layers:this.allLayers.length,width:computedWidth,height:computedHeight,outline:outline?.map(point23=>({x:point23.x+(props.outlineOffsetX??0),y:point23.y+(props.outlineOffsetY??0)})),material:props.material});this.pcb_board_id=pcb_board2.pcb_board_id,this._addBoardInformationToSilkscreen()}removePcbComponentRender(){let{db:db2}=this.root;this.pcb_board_id&&(db2.pcb_board.delete(this.pcb_board_id),this.pcb_board_id=null)}doInitialPcbDesignRuleChecks(){this.root?.pcbDisabled||this.getInheritedProperty("routingDisabled")||super.doInitialPcbDesignRuleChecks()}updatePcbDesignRuleChecks(){if(this.root?.pcbDisabled||this.getInheritedProperty("routingDisabled"))return;let{db:db2}=this.root;if(!this._areChildSubcircuitsRouted()||this._drcChecksComplete)return;this._drcChecksComplete=!0;let errors=checkEachPcbTraceNonOverlapping(db2.toArray());for(let error of errors)db2.pcb_trace_error.insert(error);let pcbPortNotConnectedErrors=checkEachPcbPortConnectedToPcbTraces(db2.toArray());for(let error of pcbPortNotConnectedErrors)db2.pcb_port_not_connected_error.insert(error);let pcbComponentOutsideErrors=checkPcbComponentsOutOfBoard(db2.toArray());for(let error of pcbComponentOutsideErrors)db2.pcb_component_outside_board_error.insert(error);let pcbTracesOutOfBoardErrors=checkPcbTracesOutOfBoard(db2.toArray());for(let error of pcbTracesOutOfBoardErrors)db2.pcb_trace_error.insert(error);let differentNetViaErrors=checkDifferentNetViaSpacing(db2.toArray());for(let error of differentNetViaErrors)db2.pcb_via_clearance_error.insert(error);let sameNetViaErrors=checkSameNetViaSpacing(db2.toArray());for(let error of sameNetViaErrors)db2.pcb_via_clearance_error.insert(error);let pcbComponentOverlapErrors=checkPcbComponentOverlap(db2.toArray());for(let error of pcbComponentOverlapErrors)db2.pcb_footprint_overlap_error.insert(error);let sourcePinMustBeConnectedErrors=checkPinMustBeConnected(db2.toArray());for(let error of sourcePinMustBeConnectedErrors)db2.source_pin_must_be_connected_error.insert(error)}_emitRenderLifecycleEvent(phase,startOrEnd){super._emitRenderLifecycleEvent(phase,startOrEnd),startOrEnd==="start"&&this.root?.emit("board:renderPhaseStarted",{renderId:this._renderId,phase})}_repositionOnPcb(position2){let{db:db2}=this.root,pcbBoard=this.pcb_board_id?db2.pcb_board.get(this.pcb_board_id):null,oldPos=pcbBoard?.center;if(!oldPos){this.pcb_board_id&&db2.pcb_board.update(this.pcb_board_id,{center:position2});return}let deltaX=position2.x-oldPos.x,deltaY=position2.y-oldPos.y;if(!(Math.abs(deltaX)<1e-6&&Math.abs(deltaY)<1e-6)){for(let child of this.children)if(child instanceof NormalComponent3){let childOldCenter;if(child.pcb_component_id){let comp=db2.pcb_component.get(child.pcb_component_id);comp&&(childOldCenter=comp.center)}else if(child instanceof Group6&&child.pcb_group_id){let group=db2.pcb_group.get(child.pcb_group_id);group&&(childOldCenter=group.center)}childOldCenter&&child._repositionOnPcb({x:childOldCenter.x+deltaX,y:childOldCenter.y+deltaY})}else child.isPcbPrimitive&&"_moveCircuitJsonElements"in child&&typeof child._moveCircuitJsonElements=="function"&&child._moveCircuitJsonElements({deltaX,deltaY});if(this.pcb_board_id&&(db2.pcb_board.update(this.pcb_board_id,{center:position2}),pcbBoard?.outline)){let outlineBounds=getBoundsFromPoints(pcbBoard.outline);if(outlineBounds){let oldOutlineCenter={x:(outlineBounds.minX+outlineBounds.maxX)/2,y:(outlineBounds.minY+outlineBounds.maxY)/2},outlineDeltaX=position2.x-oldOutlineCenter.x,outlineDeltaY=position2.y-oldOutlineCenter.y,newOutline=pcbBoard.outline.map(p2=>({x:p2.x+outlineDeltaX,y:p2.y+outlineDeltaY}));db2.pcb_board.update(this.pcb_board_id,{outline:newOutline})}}}}},DEFAULT_TAB_LENGTH=5,DEFAULT_TAB_WIDTH=2,generateCutoutsAndMousebitesForOutline=(outline,options)=>{let{gapLength,cutoutWidth,mouseBites,mouseBiteHoleDiameter,mouseBiteHoleSpacing}=options,tabCutouts=[],mouseBiteHoles=[];if(outline.length<2)return{tabCutouts,mouseBiteHoles};let outlinePolygon=new Polygon$1(outline.map(p2=>point4(p2.x,p2.y))),is_ccw;if(outline.length>2){let p02=point4(outline[0].x,outline[0].y),p12=point4(outline[1].x,outline[1].y),segmentDir=vector$1(p02,p12).normalize(),normalToLeft=segmentDir.rotate(Math.PI/2),testPoint=p02.translate(segmentDir.multiply(segment(p02,p12).length/2)).translate(normalToLeft.multiply(.01));is_ccw=outlinePolygon.contains(testPoint)}else is_ccw=outlinePolygon.area()>0;for(let i3=0;i3<outline.length;i3++){let p1_=outline[i3],p2_=outline[(i3+1)%outline.length];if(!p1_||!p2_)continue;let p12=point4(p1_.x,p1_.y),p2=point4(p2_.x,p2_.y),segment2=segment(p12,p2),segmentLength=segment2.length;if(segmentLength<1e-6)continue;let segmentVec=vector$1(p12,p2),segmentDir=segmentVec.normalize(),normalVec=segmentDir.rotate(Math.PI/2),testPoint=segment2.middle().translate(normalVec.multiply(.01));outlinePolygon.contains(testPoint)&&(normalVec=normalVec.multiply(-1));let numBitesInGap=2,totalBitesLength=numBitesInGap*mouseBiteHoleDiameter+(numBitesInGap-1)*mouseBiteHoleSpacing,effectiveGapLength;mouseBites?effectiveGapLength=totalBitesLength:effectiveGapLength=gapLength,effectiveGapLength=Math.min(effectiveGapLength,segmentLength*.9);let gapStartDist=(segmentLength-effectiveGapLength)/2,gapEndDist=gapStartDist+effectiveGapLength;if(mouseBites){let holeAndSpacing=mouseBiteHoleDiameter+mouseBiteHoleSpacing;if(effectiveGapLength>=totalBitesLength&&holeAndSpacing>0){let firstBiteCenterOffsetInGap=(effectiveGapLength-totalBitesLength)/2+mouseBiteHoleDiameter/2,firstBiteDistFromP1=gapStartDist+firstBiteCenterOffsetInGap;for(let k4=0;k4<numBitesInGap;k4++){let biteDist=firstBiteDistFromP1+k4*holeAndSpacing,pos=p12.translate(segmentDir.multiply(biteDist));mouseBiteHoles.push({x:pos.x,y:pos.y})}}}let p_prev_=outline[(i3-1+outline.length)%outline.length],p_next_=outline[(i3+2)%outline.length],start_ext=0,end_ext=0;if(p_prev_&&p_next_){let vec_in_p1=vector$1(point4(p_prev_.x,p_prev_.y),p12),p1_cross=vec_in_p1.cross(segmentVec),is_p1_convex=is_ccw?p1_cross>1e-9:p1_cross<-1e-9,vec_out_p2=vector$1(p2,point4(p_next_.x,p_next_.y)),p2_cross=segmentVec.cross(vec_out_p2),is_p2_convex=is_ccw?p2_cross>1e-9:p2_cross<-1e-9;if(is_p1_convex){let angle=vec_in_p1.angleTo(segmentVec);angle>Math.PI&&(angle=2*Math.PI-angle),start_ext=cutoutWidth*Math.tan(angle/2)}else start_ext=0;if(is_p2_convex){let angle=segmentVec.angleTo(vec_out_p2);angle>Math.PI&&(angle=2*Math.PI-angle),end_ext=cutoutWidth*Math.tan(angle/2)}else end_ext=0}let cutoutParts=[{start:0-start_ext,end:gapStartDist},{start:gapEndDist,end:segmentLength+end_ext}],extrusion=normalVec.multiply(cutoutWidth);for(let part of cutoutParts){let partLength=part.end-part.start;if(partLength<1e-6)continue;let center2=p12.translate(segmentDir.multiply(part.start+partLength/2)).translate(extrusion.multiply(.5)),width=partLength,height=cutoutWidth,rotationDeg=segmentDir.slope*180/Math.PI;tabCutouts.push({type:"pcb_cutout",shape:"rect",center:{x:center2.x,y:center2.y},width,height,rotation:rotationDeg,corner_radius:cutoutWidth/2})}}return{tabCutouts,mouseBiteHoles}};function generatePanelTabsAndMouseBites(boards,options){let finalTabCutouts=[],allMouseBites=[],{tabWidth,tabLength,mouseBites:useMouseBites}=options,processedBoards=boards.map(board=>{if((!board.outline||board.outline.length===0)&&board.width&&board.height){let w22=board.width/2,h2=board.height/2;return{...board,outline:[{x:board.center.x-w22,y:board.center.y-h2},{x:board.center.x+w22,y:board.center.y-h2},{x:board.center.x+w22,y:board.center.y+h2},{x:board.center.x-w22,y:board.center.y+h2}]}}return board});for(let board of processedBoards)if(board.outline&&board.outline.length>0){let mouseBiteDiameter2=tabWidth*.45,mouseBiteSpacing=mouseBiteDiameter2*.1,generated=generateCutoutsAndMousebitesForOutline(board.outline,{gapLength:tabLength,cutoutWidth:tabWidth,mouseBites:useMouseBites,mouseBiteHoleDiameter:mouseBiteDiameter2,mouseBiteHoleSpacing:mouseBiteSpacing});finalTabCutouts.push(...generated.tabCutouts),allMouseBites.push(...generated.mouseBiteHoles)}let tabCutouts=finalTabCutouts.map((tab,index)=>({...tab,pcb_cutout_id:`panel_tab_${index}`})),mouseBiteDiameter=tabWidth*.45,mouseBiteHoles=allMouseBites.map((bite,index)=>({type:"pcb_hole",pcb_hole_id:`panel_mouse_bite_${index}`,hole_shape:"circle",hole_diameter:mouseBiteDiameter,x:bite.x,y:bite.y}));return{tabCutouts,mouseBiteHoles}}var packBoardsIntoGrid=({boards,db:db2,row,col,cellWidth,cellHeight,boardGap})=>{let boardsWithDims=boards.map(board=>{let pcbBoard=db2.pcb_board.get(board.pcb_board_id);return!pcbBoard||pcbBoard.width===void 0||pcbBoard.height===void 0?null:{board,width:pcbBoard.width,height:pcbBoard.height}}).filter(b3=>b3!==null);if(boardsWithDims.length===0)return{positions:[],gridWidth:0,gridHeight:0};let explicitRow=row,cols=col??Math.ceil(explicitRow?boardsWithDims.length/explicitRow:Math.sqrt(boardsWithDims.length)),rows=explicitRow??Math.ceil(boardsWithDims.length/cols),colWidths=Array(cols).fill(0),rowHeights=Array(rows).fill(0);boardsWithDims.forEach((b3,i3)=>{let col2=i3%cols,row2=Math.floor(i3/cols);row2<rowHeights.length&&b3.height>rowHeights[row2]&&(rowHeights[row2]=b3.height),col2<colWidths.length&&b3.width>colWidths[col2]&&(colWidths[col2]=b3.width)});let minCellWidth=cellWidth?distance.parse(cellWidth):0,minCellHeight=cellHeight?distance.parse(cellHeight):0;for(let i3=0;i3<colWidths.length;i3++)colWidths[i3]=Math.max(colWidths[i3],minCellWidth);for(let i3=0;i3<rowHeights.length;i3++)rowHeights[i3]=Math.max(rowHeights[i3],minCellHeight);let totalGridWidth=colWidths.reduce((a2,b3)=>a2+b3,0)+(cols>1?(cols-1)*boardGap:0),totalGridHeight=rowHeights.reduce((a2,b3)=>a2+b3,0)+(rows>1?(rows-1)*boardGap:0),startX=-totalGridWidth/2,rowYOffsets=[-totalGridHeight/2];for(let i3=1;i3<rows;i3++)rowYOffsets.push(rowYOffsets[i3-1]+rowHeights[i3-1]+boardGap);let colXOffsets=[startX];for(let i3=1;i3<cols;i3++)colXOffsets.push(colXOffsets[i3-1]+colWidths[i3-1]+boardGap);let positions=[];return boardsWithDims.forEach((b3,i3)=>{let col2=i3%cols,row2=Math.floor(i3/cols);if(row2>=rowYOffsets.length||col2>=colXOffsets.length)return;let cellX=colXOffsets[col2],cellY=rowYOffsets[row2],cellWidth2=colWidths[col2],cellHeight2=rowHeights[row2],boardX=cellX+cellWidth2/2,boardY=cellY+cellHeight2/2;positions.push({board:b3.board,pos:{x:boardX,y:boardY}})}),{positions,gridWidth:totalGridWidth,gridHeight:totalGridHeight}},Panel=class extends Group6{constructor(){super(...arguments);__publicField(this,"pcb_panel_id",null);__publicField(this,"_tabsAndMouseBitesGenerated",!1)}get config(){return{componentName:"Panel",zodProps:panelProps}}get isGroup(){return!0}get isSubcircuit(){return!0}add(component){if(component.lowercaseComponentName!=="board")throw new Error("<panel> can only contain <board> elements");super.add(component)}doInitialPanelLayout(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,childBoardInstances=this.children.filter(c3=>c3 instanceof Board),hasAnyPositionedBoards=childBoardInstances.some(b3=>b3.props.pcbX!==void 0||b3.props.pcbY!==void 0),unpositionedBoards=childBoardInstances.filter(b3=>b3.props.pcbX===void 0&&b3.props.pcbY===void 0);if(unpositionedBoards.length>0&&!hasAnyPositionedBoards){let tabWidth=this._parsedProps.tabWidth??DEFAULT_TAB_WIDTH,boardGap=this._parsedProps.boardGap??tabWidth,{positions,gridWidth,gridHeight}=packBoardsIntoGrid({boards:unpositionedBoards,db:db2,row:this._parsedProps.row,col:this._parsedProps.col,cellWidth:this._parsedProps.cellWidth,cellHeight:this._parsedProps.cellHeight,boardGap}),panelGlobalPos=this._getGlobalPcbPositionBeforeLayout();for(let{board,pos}of positions){let absoluteX=panelGlobalPos.x+pos.x,absoluteY=panelGlobalPos.y+pos.y;board._repositionOnPcb({x:absoluteX,y:absoluteY}),db2.pcb_board.update(board.pcb_board_id,{center:{x:absoluteX,y:absoluteY},position_mode:"relative_to_panel_anchor",display_offset_x:`${pos.x}mm`,display_offset_y:`${pos.y}mm`})}let hasExplicitWidth=this._parsedProps.width!==void 0,hasExplicitHeight=this._parsedProps.height!==void 0;if(hasExplicitWidth&&hasExplicitHeight)db2.pcb_panel.update(this.pcb_panel_id,{width:distance.parse(this._parsedProps.width),height:distance.parse(this._parsedProps.height)});else if(gridWidth>0||gridHeight>0){let{edgePadding:edgePaddingProp,edgePaddingLeft:edgePaddingLeftProp,edgePaddingRight:edgePaddingRightProp,edgePaddingTop:edgePaddingTopProp,edgePaddingBottom:edgePaddingBottomProp}=this._parsedProps,edgePadding=distance.parse(edgePaddingProp??5),edgePaddingLeft=distance.parse(edgePaddingLeftProp??edgePadding),edgePaddingRight=distance.parse(edgePaddingRightProp??edgePadding),edgePaddingTop=distance.parse(edgePaddingTopProp??edgePadding),edgePaddingBottom=distance.parse(edgePaddingBottomProp??edgePadding);db2.pcb_panel.update(this.pcb_panel_id,{width:hasExplicitWidth?distance.parse(this._parsedProps.width):gridWidth+edgePaddingLeft+edgePaddingRight,height:hasExplicitHeight?distance.parse(this._parsedProps.height):gridHeight+edgePaddingTop+edgePaddingBottom})}}else{let panelGlobalPos=this._getGlobalPcbPositionBeforeLayout();for(let board of childBoardInstances){let boardDb=db2.pcb_board.get(board.pcb_board_id);if(!boardDb)continue;let relativeX=boardDb.center.x-panelGlobalPos.x,relativeY=boardDb.center.y-panelGlobalPos.y;db2.pcb_board.update(board.pcb_board_id,{position_mode:"relative_to_panel_anchor",display_offset_x:`${relativeX}mm`,display_offset_y:`${relativeY}mm`})}}if(this._tabsAndMouseBitesGenerated)return;let props=this._parsedProps;if((props.panelizationMethod??"none")!=="none"){let childBoardIds=childBoardInstances.map(c3=>c3.pcb_board_id).filter(id2=>!!id2),boardsInPanel=db2.pcb_board.list().filter(b3=>childBoardIds.includes(b3.pcb_board_id));if(boardsInPanel.length===0)return;let tabWidth=props.tabWidth??DEFAULT_TAB_WIDTH,boardGap=props.boardGap??tabWidth,{tabCutouts,mouseBiteHoles}=generatePanelTabsAndMouseBites(boardsInPanel,{boardGap,tabWidth,tabLength:props.tabLength??DEFAULT_TAB_LENGTH,mouseBites:props.mouseBites??!0});for(let tabCutout of tabCutouts)db2.pcb_cutout.insert(tabCutout);for(let mouseBiteHole of mouseBiteHoles)db2.pcb_hole.insert(mouseBiteHole)}this._tabsAndMouseBitesGenerated=!0}runRenderCycle(){if(!this.children.some(child=>child.componentName==="Board"))throw new Error("<panel> must contain at least one <board>");super.runRenderCycle()}doInitialPcbComponentRender(){if(super.doInitialPcbComponentRender(),this.root?.pcbDisabled)return;let{db:db2}=this.root,props=this._parsedProps,inserted=db2.pcb_panel.insert({width:props.width!==void 0?distance.parse(props.width):0,height:props.height!==void 0?distance.parse(props.height):0,center:this._getGlobalPcbPositionBeforeLayout(),covered_with_solder_mask:!(props.noSolderMask??!1)});this.pcb_panel_id=inserted.pcb_panel_id}updatePcbComponentRender(){if(this.root?.pcbDisabled||!this.pcb_panel_id)return;let{db:db2}=this.root,props=this._parsedProps,currentPanel=db2.pcb_panel.get(this.pcb_panel_id);db2.pcb_panel.update(this.pcb_panel_id,{width:props.width!==void 0?distance.parse(props.width):currentPanel?.width,height:props.height!==void 0?distance.parse(props.height):currentPanel?.height,center:this._getGlobalPcbPositionBeforeLayout(),covered_with_solder_mask:!(props.noSolderMask??!1)})}removePcbComponentRender(){this.pcb_panel_id&&(this.root?.db.pcb_panel.delete(this.pcb_panel_id),this.pcb_panel_id=null)}},Pinout=class extends Chip{constructor(props){super(props)}get config(){return{...super.config,componentName:"Pinout",zodProps:pinoutProps}}doInitialSourceRender(){let{db:db2}=this.root,{_parsedProps:props}=this,source_component=db2.source_component.insert({ftype:"simple_pinout",name:this.name,manufacturer_part_number:props.manufacturerPartNumber,supplier_part_numbers:props.supplierPartNumbers});this.source_component_id=source_component.source_component_id}},Fuse=class extends NormalComponent3{get config(){return{componentName:"fuse",schematicSymbolName:this.props.symbolName??"fuse",zodProps:fuseProps,sourceFtype:FTYPE.simple_fuse}}_getSchematicSymbolDisplayValue(){let rawCurrent=this._parsedProps.currentRating,rawVoltage=this._parsedProps.voltageRating,current2=typeof rawCurrent=="string"?parseFloat(rawCurrent):rawCurrent,voltage2=typeof rawVoltage=="string"?parseFloat(rawVoltage):rawVoltage;return`${formatSiUnit(current2)}A / ${formatSiUnit(voltage2)}V`}doInitialSourceRender(){let{db:db2}=this.root,{_parsedProps:props}=this,currentRating=typeof props.currentRating=="string"?parseFloat(props.currentRating):props.currentRating,voltageRating=typeof props.voltageRating=="string"?parseFloat(props.voltageRating):props.voltageRating,source_component=db2.source_component.insert({name:this.name,ftype:FTYPE.simple_fuse,current_rating_amps:currentRating,voltage_rating_volts:voltageRating,display_current_rating:`${formatSiUnit(currentRating)}A`,display_voltage_rating:`${formatSiUnit(voltageRating)}V`});this.source_component_id=source_component.source_component_id}},Jumper=class extends NormalComponent3{constructor(){super(...arguments);__publicField(this,"schematicDimensions",null)}get config(){return{schematicSymbolName:void 0,componentName:"Jumper",zodProps:jumperProps,shouldRenderAsSchematicBox:!0}}_getSchematicPortArrangement(){let arrangement=super._getSchematicPortArrangement();if(arrangement&&Object.keys(arrangement).length>0)return arrangement;let pinCount=this._parsedProps.pinCount??(Array.isArray(this._parsedProps.pinLabels)?this._parsedProps.pinLabels.length:this._parsedProps.pinLabels?Object.keys(this._parsedProps.pinLabels).length:this.getPortsFromFootprint().length),direction2=this._parsedProps.schDirection??"right";return{leftSize:direction2==="left"?pinCount:0,rightSize:direction2==="right"?pinCount:0}}doInitialSourceRender(){let{db:db2}=this.root,{_parsedProps:props}=this,{pcbX,pcbY}=this.getResolvedPcbPositionProp(),source_component=db2.source_component.insert({ftype:"simple_chip",name:this.name,manufacturer_part_number:props.manufacturerPartNumber,supplier_part_numbers:props.supplierPartNumbers,are_pins_interchangeable:!0});this.source_component_id=source_component.source_component_id}doInitialPcbComponentRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,{pcbX,pcbY}=this.getResolvedPcbPositionProp(),pcb_component2=db2.pcb_component.insert({center:{x:pcbX,y:pcbY},width:2,height:3,layer:props.layer??"top",rotation:props.pcbRotation??0,source_component_id:this.source_component_id,subcircuit_id:this.getSubcircuit().subcircuit_id??void 0,do_not_place:props.doNotPlace??!1,obstructs_within_bounds:props.obstructsWithinBounds??!0});this.pcb_component_id=pcb_component2.pcb_component_id}doInitialPcbTraceRender(){let{db:db2}=this.root,pcb_ports=db2.pcb_port.list({pcb_component_id:this.pcb_component_id}),pinLabelToPortId={};for(let i3=0;i3<pcb_ports.length;i3++){let port=pcb_ports[i3],sourcePort=db2.source_port.get(port.source_port_id),pinLabel="";if(typeof sourcePort?.pin_number=="number")pinLabel=sourcePort.pin_number.toString();else if(Array.isArray(sourcePort?.port_hints)){let matchedHint=sourcePort.port_hints.find(h2=>/^(pin)?\d+$/.test(h2));matchedHint&&(/^pin\d+$/.test(matchedHint)?pinLabel=matchedHint.replace(/^pin/,""):pinLabel=matchedHint)}pinLabelToPortId[pinLabel]=port.pcb_port_id}let traces=db2.pcb_trace.list({pcb_component_id:this.pcb_component_id}),updatePortId=portId=>{if(portId&&typeof portId=="string"&&portId.startsWith("{PIN")){let pin=portId.replace("{PIN","").replace("}","");return pinLabelToPortId[pin]||portId}return portId};for(let trace of traces)if(trace.route)for(let segment2 of trace.route)segment2.route_type==="wire"&&(segment2.start_pcb_port_id=updatePortId(segment2.start_pcb_port_id),segment2.end_pcb_port_id=updatePortId(segment2.end_pcb_port_id))}},INTERCONNECT_STANDARD_FOOTPRINTS={"0402":"0402","0603":"0603","0805":"0805",1206:"1206"},Interconnect=class extends NormalComponent3{get config(){return{componentName:"Interconnect",zodProps:interconnectProps,shouldRenderAsSchematicBox:!0,sourceFtype:"interconnect"}}get defaultInternallyConnectedPinNames(){let{standard}=this._parsedProps;return standard&&INTERCONNECT_STANDARD_FOOTPRINTS[standard]?[["pin1","pin2"]]:[]}_getImpliedFootprintString(){let{standard}=this._parsedProps;return standard?INTERCONNECT_STANDARD_FOOTPRINTS[standard]??null:null}doInitialSourceRender(){let{db:db2}=this.root,source_component=db2.source_component.insert({ftype:"interconnect",name:this.name,are_pins_interchangeable:!0});this.source_component_id=source_component.source_component_id}doInitialSourceParentAttachment(){let{db:db2}=this.root,internallyConnectedPorts=this._getInternallyConnectedPins();for(let ports of internallyConnectedPorts){let sourcePortIds=ports.map(port=>port.source_port_id).filter(id2=>id2!==null);sourcePortIds.length>=2&&db2.source_component_internal_connection.insert({source_component_id:this.source_component_id,subcircuit_id:this.getSubcircuit()?.subcircuit_id,source_port_ids:sourcePortIds})}}},SolderJumper=class extends NormalComponent3{constructor(){super(...arguments);__publicField(this,"schematicDimensions",null)}_getPinNumberFromBridgedPinName(pinName){return this.selectOne(`port.${pinName}`,{type:"port"})?._parsedProps.pinNumber??null}get defaultInternallyConnectedPinNames(){if(this._parsedProps.bridged){let pins=this.children.filter(c3=>c3.componentName==="Port").map(p2=>p2.name);return pins.length>0?[pins]:[]}return this._parsedProps.bridgedPins??[]}get config(){let props=this._parsedProps??this.props,resolvedPinCount=props.pinCount;if(props.pinCount==null&&!props.footprint&&(resolvedPinCount=2),props.pinCount==null){let nums=(props.bridgedPins??[]).flat().map(p_str=>this._getPinNumberFromBridgedPinName(p_str)).filter(n3=>n3!==null),maxPinFromBridged=nums.length>0?Math.max(...nums):0,pinCountFromLabels=props.pinLabels?Object.keys(props.pinLabels).length:0,finalPinCount=Math.max(maxPinFromBridged,pinCountFromLabels);(finalPinCount===2||finalPinCount===3)&&(resolvedPinCount=finalPinCount),resolvedPinCount==null&&props.footprint&&[2,3].includes(this.getPortsFromFootprint().length)&&(resolvedPinCount=this.getPortsFromFootprint().length)}let symbolName="";resolvedPinCount?symbolName+=`solderjumper${resolvedPinCount}`:symbolName="solderjumper";let bridgedPinNumbers=[];return Array.isArray(props.bridgedPins)&&props.bridgedPins.length>0?bridgedPinNumbers=Array.from(new Set(props.bridgedPins.flat().map(pinName=>this._getPinNumberFromBridgedPinName(pinName)).filter(n3=>n3!==null))).sort((a2,b3)=>a2-b3):props.bridged&&resolvedPinCount&&(bridgedPinNumbers=Array.from({length:resolvedPinCount},(_4,i3)=>i3+1)),bridgedPinNumbers.length>0&&(symbolName+=`_bridged${bridgedPinNumbers.join("")}`),{schematicSymbolName:props.symbolName??symbolName,componentName:"SolderJumper",zodProps:solderjumperProps,shouldRenderAsSchematicBox:!0}}_getSchematicPortArrangement(){let arrangement=super._getSchematicPortArrangement();if(arrangement&&Object.keys(arrangement).length>0)return arrangement;let pinCount=this._parsedProps.pinCount??(Array.isArray(this._parsedProps.pinLabels)?this._parsedProps.pinLabels.length:this._parsedProps.pinLabels?Object.keys(this._parsedProps.pinLabels).length:this.getPortsFromFootprint().length);pinCount==null&&!this._parsedProps.footprint&&(pinCount=2);let direction2=this._parsedProps.schDirection??"right";return{leftSize:direction2==="left"?pinCount:0,rightSize:direction2==="right"?pinCount:0}}doInitialSourceRender(){let{db:db2}=this.root,{_parsedProps:props}=this,{pcbX,pcbY}=this.getResolvedPcbPositionProp(),source_component=db2.source_component.insert({ftype:"simple_chip",name:this.name,manufacturer_part_number:props.manufacturerPartNumber,supplier_part_numbers:props.supplierPartNumbers,are_pins_interchangeable:!0});this.source_component_id=source_component.source_component_id}doInitialPcbComponentRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,{pcbX,pcbY}=this.getResolvedPcbPositionProp(),pcb_component2=db2.pcb_component.insert({center:{x:pcbX,y:pcbY},width:2,height:3,layer:props.layer??"top",rotation:props.pcbRotation??0,source_component_id:this.source_component_id,subcircuit_id:this.getSubcircuit().subcircuit_id??void 0,do_not_place:props.doNotPlace??!1,obstructs_within_bounds:props.obstructsWithinBounds??!0});this.pcb_component_id=pcb_component2.pcb_component_id}doInitialPcbTraceRender(){let{db:db2}=this.root,pcb_ports=db2.pcb_port.list({pcb_component_id:this.pcb_component_id}),pinLabelToPortId={};for(let i3=0;i3<pcb_ports.length;i3++){let port=pcb_ports[i3],sourcePort=db2.source_port.get(port.source_port_id),pinLabel="";if(typeof sourcePort?.pin_number=="number")pinLabel=sourcePort.pin_number.toString();else if(Array.isArray(sourcePort?.port_hints)){let matchedHint=sourcePort.port_hints.find(h2=>/^(pin)?\d+$/.test(h2));matchedHint&&(/^pin\d+$/.test(matchedHint)?pinLabel=matchedHint.replace(/^pin/,""):pinLabel=matchedHint)}pinLabelToPortId[pinLabel]=port.pcb_port_id}let traces=db2.pcb_trace.list({pcb_component_id:this.pcb_component_id}),updatePortId=portId=>{if(portId&&typeof portId=="string"&&portId.startsWith("{PIN")){let pin=portId.replace("{PIN","").replace("}","");return pinLabelToPortId[pin]||portId}return portId};for(let trace of traces)if(trace.route)for(let segment2 of trace.route)segment2.route_type==="wire"&&(segment2.start_pcb_port_id=updatePortId(segment2.start_pcb_port_id),segment2.end_pcb_port_id=updatePortId(segment2.end_pcb_port_id))}},Led=class extends NormalComponent3{constructor(){super(...arguments);__publicField(this,"pos",this.portMap.pin1);__publicField(this,"anode",this.portMap.pin1);__publicField(this,"neg",this.portMap.pin2);__publicField(this,"cathode",this.portMap.pin2)}get config(){let symbolMap={laser:"laser_diode"},variantSymbol=this.props.laser?"laser":null;return{schematicSymbolName:variantSymbol?symbolMap[variantSymbol]:this.props.symbolName??"led",componentName:"Led",zodProps:ledProps,sourceFtype:"simple_led"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}_getSchematicSymbolDisplayValue(){return this._parsedProps.schDisplayValue||this._parsedProps.color||void 0}getFootprinterString(){let baseFootprint=super.getFootprinterString();return baseFootprint&&this.props.color?`${baseFootprint}_color(${this.props.color})`:baseFootprint}doInitialSourceRender(){let{db:db2}=this.root,{_parsedProps:props}=this,source_component=db2.source_component.insert({ftype:"simple_led",name:this.name,wave_length:props.wavelength,color:props.color,symbol_display_value:this._getSchematicSymbolDisplayValue(),manufacturer_part_number:props.manufacturerPartNumber??props.mfn,supplier_part_numbers:props.supplierPartNumbers,are_pins_interchangeable:!1});this.source_component_id=source_component.source_component_id}},PowerSource=class extends NormalComponent3{constructor(){super(...arguments);__publicField(this,"pos",this.portMap.pin1);__publicField(this,"positive",this.portMap.pin1);__publicField(this,"neg",this.portMap.pin2);__publicField(this,"negative",this.portMap.pin2)}get config(){return{schematicSymbolName:this.props.symbolName??"power_factor_meter_horz",componentName:"PowerSource",zodProps:powerSourceProps,sourceFtype:"simple_power_source"}}initPorts(){this.add(new Port({name:"pin1",pinNumber:1,aliases:["positive","pos"]})),this.add(new Port({name:"pin2",pinNumber:2,aliases:["negative","neg"]}))}doInitialSourceRender(){let{db:db2}=this.root,{_parsedProps:props}=this,source_component=db2.source_component.insert({ftype:"simple_power_source",name:this.name,voltage:props.voltage,supplier_part_numbers:props.supplierPartNumbers,are_pins_interchangeable:!1});this.source_component_id=source_component.source_component_id}},VoltageSource=class extends NormalComponent3{constructor(){super(...arguments);__publicField(this,"terminal1",this.portMap.terminal1);__publicField(this,"terminal2",this.portMap.terminal2)}get config(){return{componentName:"VoltageSource",schematicSymbolName:this.props.waveShape==="square"?"square_wave":"ac_voltmeter",zodProps:voltageSourceProps,sourceFtype:"simple_voltage_source"}}runRenderPhaseForChildren(phase){if(!phase.startsWith("Pcb"))for(let child of this.children)child.runRenderPhaseForChildren(phase),child.runRenderPhase(phase)}doInitialPcbComponentRender(){}initPorts(){super.initPorts({additionalAliases:{pin1:["terminal1"],pin2:["terminal2"]}})}_getSchematicSymbolDisplayValue(){let{voltage:voltage2,frequency:frequency2}=this._parsedProps,parts=[];return voltage2!==void 0&&parts.push(`${formatSiUnit(voltage2)}V`),frequency2!==void 0&&parts.push(`${formatSiUnit(frequency2)}Hz`),parts.length>0?parts.join(" "):void 0}doInitialSourceRender(){let{db:db2}=this.root,{_parsedProps:props}=this,source_component=db2.source_component.insert({ftype:"simple_voltage_source",name:this.name,voltage:props.voltage,frequency:props.frequency,peak_to_peak_voltage:props.peakToPeakVoltage,wave_shape:props.waveShape,phase:props.phase,duty_cycle:props.dutyCycle,supplier_part_numbers:props.supplierPartNumbers,are_pins_interchangeable:!0});this.source_component_id=source_component.source_component_id}doInitialSimulationRender(){let{db:db2}=this.root,{_parsedProps:props}=this,terminal1Port=this.portMap.terminal1,terminal2Port=this.portMap.terminal2;db2.simulation_voltage_source.insert({type:"simulation_voltage_source",is_dc_source:!1,terminal1_source_port_id:terminal1Port.source_port_id,terminal2_source_port_id:terminal2Port.source_port_id,voltage:props.voltage,frequency:props.frequency,peak_to_peak_voltage:props.peakToPeakVoltage,wave_shape:props.waveShape,phase:props.phase,duty_cycle:props.dutyCycle})}},CurrentSource=class extends NormalComponent3{constructor(){super(...arguments);__publicField(this,"pos",this.portMap.pos);__publicField(this,"neg",this.portMap.neg)}get config(){return{componentName:"CurrentSource",schematicSymbolName:"current_source",zodProps:currentSourceProps,sourceFtype:"simple_current_source"}}runRenderPhaseForChildren(phase){if(!phase.startsWith("Pcb"))for(let child of this.children)child.runRenderPhaseForChildren(phase),child.runRenderPhase(phase)}doInitialPcbComponentRender(){}initPorts(){super.initPorts({additionalAliases:{pin1:["pos"],pin2:["neg"]}})}_getSchematicSymbolDisplayValue(){let{current:current2,frequency:frequency2,peakToPeakCurrent}=this._parsedProps,parts=[];return current2!==void 0&&parts.push(`${formatSiUnit(current2)}A`),peakToPeakCurrent!==void 0&&parts.push(`${formatSiUnit(peakToPeakCurrent)}A p-p`),frequency2!==void 0&&parts.push(`${formatSiUnit(frequency2)}Hz`),parts.length>0?parts.join(" "):void 0}doInitialSourceRender(){let{db:db2}=this.root,{_parsedProps:props}=this,source_component=db2.source_component.insert({ftype:"simple_current_source",name:this.name,current:props.current,frequency:props.frequency,peak_to_peak_current:props.peakToPeakCurrent,wave_shape:props.waveShape,phase:props.phase,duty_cycle:props.dutyCycle,supplier_part_numbers:props.supplierPartNumbers,are_pins_interchangeable:!0});this.source_component_id=source_component.source_component_id}doInitialSimulationRender(){let{db:db2}=this.root,{_parsedProps:props}=this,isAc=props.frequency!==void 0||props.peakToPeakCurrent!==void 0||props.waveShape!==void 0,posPort=this.portMap.pos,negPort=this.portMap.neg;if(isAc)db2.simulation_current_source.insert({type:"simulation_current_source",is_dc_source:!1,terminal1_source_port_id:posPort.source_port_id,terminal2_source_port_id:negPort.source_port_id,current:props.current,frequency:props.frequency,peak_to_peak_current:props.peakToPeakCurrent,wave_shape:props.waveShape,phase:props.phase,duty_cycle:props.dutyCycle});else{if(props.current===void 0)return;db2.simulation_current_source.insert({type:"simulation_current_source",is_dc_source:!0,positive_source_port_id:posPort.source_port_id,negative_source_port_id:negPort.source_port_id,current:props.current})}}},edgeSpecifiers=["leftedge","rightedge","topedge","bottomedge","center"],Constraint3=class extends PrimitiveComponent2{get config(){return{componentName:"Constraint",zodProps:constraintProps}}constructor(props){if(super(props),("xdist"in props||"ydist"in props)&&!("edgeToEdge"in props)&&!("centerToCenter"in props))throw new Error(`edgeToEdge, centerToCenter must be set for xDist or yDist for ${this}`);if("for"in props&&props.for.length<2)throw new Error(`"for" must have at least two selectors for ${this}`)}_getAllReferencedComponents(){let componentsWithSelectors=[],container=this.getPrimitiveContainer();function addComponentFromSelector(selector){let maybeEdge=selector.split(" ").pop(),edge=edgeSpecifiers.includes(maybeEdge)?maybeEdge:void 0,componentSelector=edge?selector.replace(` ${edge}`,""):selector,component=container.selectOne(componentSelector,{pcbPrimitive:!0});component&&componentsWithSelectors.push({selector,component,componentSelector,edge})}for(let key of["left","right","top","bottom"])key in this._parsedProps&&addComponentFromSelector(this._parsedProps[key]);if("for"in this._parsedProps)for(let selector of this._parsedProps.for)addComponentFromSelector(selector);return{componentsWithSelectors}}},FabricationNoteRect=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"fabrication_note_rect_id",null);__publicField(this,"isPcbPrimitive",!0)}get config(){return{componentName:"FabricationNoteRect",zodProps:fabricationNoteRectProps}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,{pcbX,pcbY}=this.getResolvedPcbPositionProp(),{maybeFlipLayer}=this._getPcbPrimitiveFlippedHelpers(),layer=maybeFlipLayer(props.layer??"top");if(layer!=="top"&&layer!=="bottom")throw new Error(`Invalid layer "${layer}" for FabricationNoteRect. Must be "top" or "bottom".`);let pcb_component_id=this.parent?.pcb_component_id??this.getPrimitiveContainer()?.pcb_component_id,subcircuit=this.getSubcircuit(),hasStroke=props.hasStroke??(props.strokeWidth!==void 0&&props.strokeWidth!==null),fabrication_note_rect=db2.pcb_fabrication_note_rect.insert({pcb_component_id,layer,color:props.color,center:{x:pcbX,y:pcbY},width:props.width,height:props.height,stroke_width:props.strokeWidth??1,is_filled:props.isFilled??!1,has_stroke:hasStroke,is_stroke_dashed:props.isStrokeDashed??!1,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0,corner_radius:props.cornerRadius??void 0});this.fabrication_note_rect_id=fabrication_note_rect.pcb_fabrication_note_rect_id}getPcbSize(){let{_parsedProps:props}=this;return{width:props.width,height:props.height}}_moveCircuitJsonElements({deltaX,deltaY}){if(this.root?.pcbDisabled)return;let{db:db2}=this.root;if(!this.fabrication_note_rect_id)return;let rect=db2.pcb_fabrication_note_rect.get(this.fabrication_note_rect_id);rect&&db2.pcb_fabrication_note_rect.update(this.fabrication_note_rect_id,{center:{x:rect.center.x+deltaX,y:rect.center.y+deltaY}})}},FabricationNotePath=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"fabrication_note_path_id",null);__publicField(this,"isPcbPrimitive",!0)}get config(){return{componentName:"FabricationNotePath",zodProps:fabricationNotePathProps}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,subcircuit=this.getSubcircuit(),{_parsedProps:props}=this,layer=props.layer??"top";if(layer!=="top"&&layer!=="bottom")throw new Error(`Invalid layer "${layer}" for SilkscreenPath. Must be "top" or "bottom".`);let transform5=this._computePcbGlobalTransformBeforeLayout(),pcb_component_id=this.parent?.pcb_component_id??this.getPrimitiveContainer()?.pcb_component_id,fabrication_note_path=db2.pcb_fabrication_note_path.insert({pcb_component_id,layer,color:props.color,route:props.route.map(p2=>{let transformedPosition=applyToPoint(transform5,{x:p2.x,y:p2.y});return{...p2,x:transformedPosition.x,y:transformedPosition.y}}),stroke_width:props.strokeWidth??.1,subcircuit_id:subcircuit?.subcircuit_id??void 0});this.fabrication_note_path_id=fabrication_note_path.pcb_fabrication_note_path_id}getPcbSize(){let{_parsedProps:props}=this;if(props.route.length===0)return{width:0,height:0};let xs3=props.route.map(point23=>typeof point23.x=="string"?parseFloat(point23.x):point23.x),ys3=props.route.map(point23=>typeof point23.y=="string"?parseFloat(point23.y):point23.y),minX=Math.min(...xs3),maxX=Math.max(...xs3),minY=Math.min(...ys3),maxY=Math.max(...ys3);return{width:maxX-minX,height:maxY-minY}}_moveCircuitJsonElements({deltaX,deltaY}){if(this.root?.pcbDisabled)return;let{db:db2}=this.root;if(!this.fabrication_note_path_id)return;let path=db2.pcb_fabrication_note_path.get(this.fabrication_note_path_id);path&&db2.pcb_fabrication_note_path.update(this.fabrication_note_path_id,{route:path.route.map(p2=>({...p2,x:p2.x+deltaX,y:p2.y+deltaY}))})}},FabricationNoteText=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"pcb_fabrication_note_text_id",null);__publicField(this,"isPcbPrimitive",!0)}get config(){return{componentName:"FabricationNoteText",zodProps:fabricationNoteTextProps}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,{pcbX,pcbY}=this.getResolvedPcbPositionProp(),container=this.getPrimitiveContainer(),subcircuit=this.getSubcircuit(),pcb_fabrication_note_text2=db2.pcb_fabrication_note_text.insert({anchor_alignment:props.anchorAlignment,anchor_position:{x:pcbX,y:pcbY},font:props.font??"tscircuit2024",font_size:props.fontSize??1,layer:"top",color:props.color,text:normalizeTextForCircuitJson(props.text??""),pcb_component_id:container.pcb_component_id,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0});this.pcb_fabrication_note_text_id=pcb_fabrication_note_text2.pcb_fabrication_note_text_id}getPcbSize(){let{_parsedProps:props}=this,fontSize=typeof props.fontSize=="string"?parseFloat(props.fontSize):props.fontSize??1,charWidth=fontSize*.6;return{width:(props.text??"").length*charWidth,height:fontSize}}_moveCircuitJsonElements({deltaX,deltaY}){if(this.root?.pcbDisabled)return;let{db:db2}=this.root;if(this.pcb_fabrication_note_text_id){let text=db2.pcb_fabrication_note_text.get(this.pcb_fabrication_note_text_id);text&&db2.pcb_fabrication_note_text.update(this.pcb_fabrication_note_text_id,{anchor_position:{x:text.anchor_position.x+deltaX,y:text.anchor_position.y+deltaY}})}}},FabricationNoteDimension=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"fabrication_note_dimension_id",null);__publicField(this,"isPcbPrimitive",!0)}get config(){return{componentName:"FabricationNoteDimension",zodProps:fabricationNoteDimensionProps}}_resolvePoint(input2,transform5){if(typeof input2=="string"){let target=this.getSubcircuit().selectOne(input2);return target?target._getGlobalPcbPositionBeforeLayout():(this.renderError(`FabricationNoteDimension could not find selector "${input2}"`),applyToPoint(transform5,{x:0,y:0}))}let numericX=typeof input2.x=="string"?parseFloat(input2.x):input2.x,numericY=typeof input2.y=="string"?parseFloat(input2.y):input2.y;return applyToPoint(transform5,{x:numericX,y:numericY})}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,transform5=this._computePcbGlobalTransformBeforeLayout(),from=this._resolvePoint(props.from,transform5),to3=this._resolvePoint(props.to,transform5),subcircuit=this.getSubcircuit(),group=this.getGroup(),{maybeFlipLayer}=this._getPcbPrimitiveFlippedHelpers(),layer=maybeFlipLayer(props.layer??"top");if(layer!=="top"&&layer!=="bottom")throw new Error(`Invalid layer "${layer}" for FabricationNoteDimension. Must be "top" or "bottom".`);let pcb_component_id=this.parent?.pcb_component_id??this.getPrimitiveContainer()?.pcb_component_id,text=props.text??this._formatDistanceText({from,to:to3,units:props.units??"mm"}),fabrication_note_dimension=db2.pcb_fabrication_note_dimension.insert({pcb_component_id,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:group?.pcb_group_id??void 0,layer,from,to:to3,text,offset:props.offset,font:props.font??"tscircuit2024",font_size:props.fontSize??1,color:props.color,arrow_size:props.arrowSize??1});this.fabrication_note_dimension_id=fabrication_note_dimension.pcb_fabrication_note_dimension_id}_moveCircuitJsonElements({deltaX,deltaY}){if(this.root?.pcbDisabled)return;let{db:db2}=this.root;if(!this.fabrication_note_dimension_id)return;let dimension=db2.pcb_fabrication_note_dimension.get(this.fabrication_note_dimension_id);dimension&&db2.pcb_fabrication_note_dimension.update(this.fabrication_note_dimension_id,{from:{x:dimension.from.x+deltaX,y:dimension.from.y+deltaY},to:{x:dimension.to.x+deltaX,y:dimension.to.y+deltaY}})}getPcbSize(){let transform5=this._computePcbGlobalTransformBeforeLayout(),from=this._resolvePoint(this._parsedProps.from,transform5),to3=this._resolvePoint(this._parsedProps.to,transform5);return{width:Math.abs(to3.x-from.x),height:Math.abs(to3.y-from.y)}}_formatDistanceText({from,to:to3,units}){let dx2=to3.x-from.x,dy2=to3.y-from.y,distanceInMillimeters=Math.sqrt(dx2*dx2+dy2*dy2),distanceInUnits=units==="in"?distanceInMillimeters/25.4:distanceInMillimeters,roundedDistance=Math.round(distanceInUnits);if(Math.abs(distanceInUnits-roundedDistance)<1e-9)return`${roundedDistance}${units}`;let decimalPlaces=units==="in"?3:2;return`${units==="in"?Number(distanceInUnits.toFixed(decimalPlaces)).toString():distanceInUnits.toFixed(decimalPlaces)}${units}`}},PcbNoteLine=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"pcb_note_line_id",null);__publicField(this,"isPcbPrimitive",!0)}get config(){return{componentName:"PcbNoteLine",zodProps:pcbNoteLineProps}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,subcircuit=this.getSubcircuit(),group=this.getGroup(),transform5=this._computePcbGlobalTransformBeforeLayout(),start=applyToPoint(transform5,{x:props.x1,y:props.y1}),end=applyToPoint(transform5,{x:props.x2,y:props.y2}),pcb_component_id=this.parent?.pcb_component_id??this.getPrimitiveContainer()?.pcb_component_id??void 0,pcb_note_line2=db2.pcb_note_line.insert({pcb_component_id,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:group?.pcb_group_id??void 0,x1:start.x,y1:start.y,x2:end.x,y2:end.y,stroke_width:props.strokeWidth??.1,color:props.color,is_dashed:props.isDashed});this.pcb_note_line_id=pcb_note_line2.pcb_note_line_id}getPcbSize(){let{_parsedProps:props}=this;return{width:Math.abs(props.x2-props.x1),height:Math.abs(props.y2-props.y1)}}_moveCircuitJsonElements({deltaX,deltaY}){if(this.root?.pcbDisabled)return;let{db:db2}=this.root;if(!this.pcb_note_line_id)return;let line2=db2.pcb_note_line.get(this.pcb_note_line_id);line2&&db2.pcb_note_line.update(this.pcb_note_line_id,{x1:line2.x1+deltaX,y1:line2.y1+deltaY,x2:line2.x2+deltaX,y2:line2.y2+deltaY})}},PcbNoteRect=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"pcb_note_rect_id",null);__publicField(this,"isPcbPrimitive",!0)}get config(){return{componentName:"PcbNoteRect",zodProps:pcbNoteRectProps}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,transform5=this._computePcbGlobalTransformBeforeLayout(),center2=applyToPoint(transform5,{x:0,y:0}),subcircuit=this.getSubcircuit(),group=this.getGroup(),pcb_component_id=this.parent?.pcb_component_id??this.getPrimitiveContainer()?.pcb_component_id??void 0,pcb_note_rect2=db2.pcb_note_rect.insert({pcb_component_id,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:group?.pcb_group_id??void 0,center:center2,width:props.width,height:props.height,stroke_width:props.strokeWidth??.1,is_filled:props.isFilled??!1,has_stroke:props.hasStroke??!0,is_stroke_dashed:props.isStrokeDashed??!1,color:props.color,corner_radius:props.cornerRadius??void 0});this.pcb_note_rect_id=pcb_note_rect2.pcb_note_rect_id}getPcbSize(){let{_parsedProps:props}=this,width=typeof props.width=="string"?parseFloat(props.width):props.width,height=typeof props.height=="string"?parseFloat(props.height):props.height;return{width,height}}_moveCircuitJsonElements({deltaX,deltaY}){if(this.root?.pcbDisabled)return;let{db:db2}=this.root;if(!this.pcb_note_rect_id)return;let rect=db2.pcb_note_rect.get(this.pcb_note_rect_id);rect&&db2.pcb_note_rect.update(this.pcb_note_rect_id,{center:{x:rect.center.x+deltaX,y:rect.center.y+deltaY}})}},PcbNoteText=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"pcb_note_text_id",null);__publicField(this,"isPcbPrimitive",!0)}get config(){return{componentName:"PcbNoteText",zodProps:pcbNoteTextProps}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,transform5=this._computePcbGlobalTransformBeforeLayout(),anchorPosition=applyToPoint(transform5,{x:0,y:0}),subcircuit=this.getSubcircuit(),group=this.getGroup(),pcb_component_id=this.parent?.pcb_component_id??this.getPrimitiveContainer()?.pcb_component_id??void 0,pcb_note_text2=db2.pcb_note_text.insert({pcb_component_id,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:group?.pcb_group_id??void 0,font:props.font??"tscircuit2024",font_size:props.fontSize??1,text:normalizeTextForCircuitJson(props.text),anchor_position:anchorPosition,anchor_alignment:props.anchorAlignment??"center",color:props.color});this.pcb_note_text_id=pcb_note_text2.pcb_note_text_id}getPcbSize(){let{_parsedProps:props}=this,fontSize=typeof props.fontSize=="string"?parseFloat(props.fontSize):props.fontSize??1,charWidth=fontSize*.6;return{width:props.text.length*charWidth,height:fontSize}}_moveCircuitJsonElements({deltaX,deltaY}){if(this.root?.pcbDisabled)return;let{db:db2}=this.root;if(!this.pcb_note_text_id)return;let text=db2.pcb_note_text.get(this.pcb_note_text_id);text&&db2.pcb_note_text.update(this.pcb_note_text_id,{anchor_position:{x:text.anchor_position.x+deltaX,y:text.anchor_position.y+deltaY}})}},PcbNotePath=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"pcb_note_path_id",null);__publicField(this,"isPcbPrimitive",!0)}get config(){return{componentName:"PcbNotePath",zodProps:pcbNotePathProps}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,transform5=this._computePcbGlobalTransformBeforeLayout(),subcircuit=this.getSubcircuit(),group=this.getGroup(),pcb_component_id=this.parent?.pcb_component_id??this.getPrimitiveContainer()?.pcb_component_id??void 0,transformedRoute=props.route.map(point23=>{let{x:x3,y:y3,...rest}=point23,numericX=typeof x3=="string"?parseFloat(x3):x3,numericY=typeof y3=="string"?parseFloat(y3):y3,transformed=applyToPoint(transform5,{x:numericX,y:numericY});return{...rest,x:transformed.x,y:transformed.y}}),pcb_note_path2=db2.pcb_note_path.insert({pcb_component_id,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:group?.pcb_group_id??void 0,route:transformedRoute,stroke_width:props.strokeWidth??.1,color:props.color});this.pcb_note_path_id=pcb_note_path2.pcb_note_path_id}getPcbSize(){let{_parsedProps:props}=this;if(props.route.length===0)return{width:0,height:0};let xs3=props.route.map(point23=>typeof point23.x=="string"?parseFloat(point23.x):point23.x),ys3=props.route.map(point23=>typeof point23.y=="string"?parseFloat(point23.y):point23.y),minX=Math.min(...xs3),maxX=Math.max(...xs3),minY=Math.min(...ys3),maxY=Math.max(...ys3);return{width:maxX-minX,height:maxY-minY}}_moveCircuitJsonElements({deltaX,deltaY}){if(this.root?.pcbDisabled)return;let{db:db2}=this.root;if(!this.pcb_note_path_id)return;let path=db2.pcb_note_path.get(this.pcb_note_path_id);path&&db2.pcb_note_path.update(this.pcb_note_path_id,{route:path.route.map(p2=>({...p2,x:p2.x+deltaX,y:p2.y+deltaY}))})}},PcbNoteDimension=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"pcb_note_dimension_id",null);__publicField(this,"isPcbPrimitive",!0)}get config(){return{componentName:"PcbNoteDimension",zodProps:pcbNoteDimensionProps}}_resolvePoint(input2,transform5){if(typeof input2=="string"){let target=this.getSubcircuit().selectOne(`.${input2}`);return target?target._getGlobalPcbPositionBeforeLayout():(this.renderError(`PcbNoteDimension could not find selector "${input2}"`),applyToPoint(transform5,{x:0,y:0}))}let numericX=typeof input2.x=="string"?parseFloat(input2.x):input2.x,numericY=typeof input2.y=="string"?parseFloat(input2.y):input2.y;return applyToPoint(transform5,{x:numericX,y:numericY})}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,transform5=this._computePcbGlobalTransformBeforeLayout(),from=this._resolvePoint(props.from,transform5),to3=this._resolvePoint(props.to,transform5),subcircuit=this.getSubcircuit(),group=this.getGroup(),pcb_component_id=this.parent?.pcb_component_id??this.getPrimitiveContainer()?.pcb_component_id??void 0,text=props.text??this._formatDistanceText({from,to:to3,units:props.units??"mm"}),pcb_note_dimension2=db2.pcb_note_dimension.insert({pcb_component_id,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:group?.pcb_group_id??void 0,from,to:to3,text,font:props.font??"tscircuit2024",font_size:props.fontSize??1,color:props.color,arrow_size:props.arrowSize??1});this.pcb_note_dimension_id=pcb_note_dimension2.pcb_note_dimension_id}getPcbSize(){let transform5=this._computePcbGlobalTransformBeforeLayout(),from=this._resolvePoint(this._parsedProps.from,transform5),to3=this._resolvePoint(this._parsedProps.to,transform5);return{width:Math.abs(to3.x-from.x),height:Math.abs(to3.y-from.y)}}_formatDistanceText({from,to:to3,units}){let dx2=to3.x-from.x,dy2=to3.y-from.y,distanceInMillimeters=Math.sqrt(dx2*dx2+dy2*dy2),distanceInUnits=units==="in"?distanceInMillimeters/25.4:distanceInMillimeters,roundedDistance=Math.round(distanceInUnits);if(Math.abs(distanceInUnits-roundedDistance)<1e-9)return`${roundedDistance}${units}`;let decimalPlaces=units==="in"?3:2;return`${units==="in"?Number(distanceInUnits.toFixed(decimalPlaces)).toString():distanceInUnits.toFixed(decimalPlaces)}${units}`}_moveCircuitJsonElements({deltaX,deltaY}){if(this.root?.pcbDisabled)return;let{db:db2}=this.root;if(!this.pcb_note_dimension_id)return;let dimension=db2.pcb_note_dimension.get(this.pcb_note_dimension_id);dimension&&db2.pcb_note_dimension.update(this.pcb_note_dimension_id,{from:{x:dimension.from.x+deltaX,y:dimension.from.y+deltaY},to:{x:dimension.to.x+deltaX,y:dimension.to.y+deltaY}})}},Subcircuit=class extends Group6{constructor(props){super({...props,subcircuit:!0})}doInitialInflateSubcircuitCircuitJson(){let{circuitJson,children}=this._parsedProps;inflateCircuitJson(this,circuitJson,children)}},Breakout=class extends Group6{constructor(props){super({...props,subcircuit:!0})}doInitialPcbPrimitiveRender(){if(super.doInitialPcbPrimitiveRender(),this.root?.pcbDisabled)return;let{db:db2}=this.root,props=this._parsedProps;if(!this.pcb_group_id)return;let pcb_group2=db2.pcb_group.get(this.pcb_group_id),padLeft=props.paddingLeft??props.padding??0,padRight=props.paddingRight??props.padding??0,padTop=props.paddingTop??props.padding??0,padBottom=props.paddingBottom??props.padding??0;db2.pcb_group.update(this.pcb_group_id,{width:(pcb_group2.width??0)+padLeft+padRight,height:(pcb_group2.height??0)+padTop+padBottom,center:{x:pcb_group2.center.x+(padRight-padLeft)/2,y:pcb_group2.center.y+(padTop-padBottom)/2}})}},BreakoutPoint=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"pcb_breakout_point_id",null);__publicField(this,"matchedPort",null);__publicField(this,"matchedNet",null);__publicField(this,"isPcbPrimitive",!0)}get config(){return{componentName:"BreakoutPoint",zodProps:breakoutPointProps}}_matchConnection(){let{connection}=this._parsedProps,subcircuit=this.getSubcircuit();subcircuit&&(this.matchedPort=subcircuit.selectOne(connection,{type:"port"}),this.matchedPort||(this.matchedNet=subcircuit.selectOne(connection,{type:"net"})),!this.matchedPort&&!this.matchedNet&&this.renderError(`Could not find connection target "${connection}"`))}_getSourceTraceIdForPort(port){let{db:db2}=this.root;return db2.source_trace.list().find(st2=>st2.connected_source_port_ids.includes(port.source_port_id))?.source_trace_id}_getSourceNetIdForPort(port){let{db:db2}=this.root;return db2.source_trace.list().find(st2=>st2.connected_source_port_ids.includes(port.source_port_id))?.connected_source_net_ids[0]}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root;this._matchConnection();let{pcbX,pcbY}=this.getResolvedPcbPositionProp(),group=this.parent?.getGroup(),subcircuit=this.getSubcircuit();if(!group||!group.pcb_group_id)return;let pcb_breakout_point2=db2.pcb_breakout_point.insert({pcb_group_id:group.pcb_group_id,subcircuit_id:subcircuit?.subcircuit_id??void 0,source_port_id:this.matchedPort?.source_port_id??void 0,source_trace_id:this.matchedPort?this._getSourceTraceIdForPort(this.matchedPort):void 0,source_net_id:this.matchedNet?this.matchedNet.source_net_id:this.matchedPort?this._getSourceNetIdForPort(this.matchedPort):void 0,x:pcbX,y:pcbY});this.pcb_breakout_point_id=pcb_breakout_point2.pcb_breakout_point_id}_getPcbCircuitJsonBounds(){let{pcbX,pcbY}=this.getResolvedPcbPositionProp();return{center:{x:pcbX,y:pcbY},bounds:{left:pcbX,top:pcbY,right:pcbX,bottom:pcbY},width:0,height:0}}_setPositionFromLayout(newCenter){let{db:db2}=this.root;this.pcb_breakout_point_id&&db2.pcb_breakout_point.update(this.pcb_breakout_point_id,{x:newCenter.x,y:newCenter.y})}_moveCircuitJsonElements({deltaX,deltaY}){if(this.root?.pcbDisabled)return;let{db:db2}=this.root;if(!this.pcb_breakout_point_id)return;let point23=db2.pcb_breakout_point.get(this.pcb_breakout_point_id);point23&&db2.pcb_breakout_point.update(this.pcb_breakout_point_id,{x:point23.x+deltaX,y:point23.y+deltaY})}getPcbSize(){return{width:0,height:0}}},NetLabel=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"source_net_label_id")}get config(){return{componentName:"NetLabel",zodProps:netLabelProps}}_getAnchorSide(){let{_parsedProps:props}=this;if(props.anchorSide)return props.anchorSide;if(!this._resolveConnectsTo())return"right";let anchorPos=this._getGlobalSchematicPositionBeforeLayout(),connectedPorts=this._getConnectedPorts();if(connectedPorts.length===0)return"right";let connectedPortPosition=connectedPorts[0]._getGlobalSchematicPositionBeforeLayout(),dx2=connectedPortPosition.x-anchorPos.x,dy2=connectedPortPosition.y-anchorPos.y;if(Math.abs(dx2)>Math.abs(dy2)){if(dx2>0)return"right";if(dx2<0)return"left"}else{if(dy2>0)return"top";if(dy2<0)return"bottom"}return"right"}_getConnectedPorts(){let connectsTo=this._resolveConnectsTo();if(!connectsTo)return[];let connectedPorts=[];for(let connection of connectsTo){let port=this.getSubcircuit().selectOne(connection);port&&connectedPorts.push(port)}return connectedPorts}computeSchematicPropsTransform(){let{_parsedProps:props}=this;if(props.schX===void 0&&props.schY===void 0){let connectedPorts=this._getConnectedPorts();if(connectedPorts.length>0){let portPos=connectedPorts[0]._getGlobalSchematicPositionBeforeLayout(),parentCenter=applyToPoint(this.parent?.computeSchematicGlobalTransform?.()??identity(),{x:0,y:0});return translate(portPos.x-parentCenter.x,portPos.y-parentCenter.y)}}return super.computeSchematicPropsTransform()}doInitialSchematicPrimitiveRender(){if(this.root?.schematicDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,anchorPos=this._getGlobalSchematicPositionBeforeLayout(),net=this.getSubcircuit().selectOne(`net.${this._getNetName()}`),anchorSide=props.anchorSide??"right",center2=computeSchematicNetLabelCenter({anchor_position:anchorPos,anchor_side:anchorSide,text:props.net}),netLabel=db2.schematic_net_label.insert({text:props.net,source_net_id:net.source_net_id,anchor_position:anchorPos,center:center2,anchor_side:this._getAnchorSide()});this.source_net_label_id=netLabel.source_net_id}_resolveConnectsTo(){let{_parsedProps:props}=this,connectsTo=props.connectsTo??props.connection;if(Array.isArray(connectsTo))return connectsTo;if(typeof connectsTo=="string")return[connectsTo]}_getNetName(){let{_parsedProps:props}=this;return props.net}doInitialCreateNetsFromProps(){let{_parsedProps:props}=this;props.net&&createNetsFromProps(this,[`net.${props.net}`])}doInitialCreateTracesFromNetLabels(){if(this.root?.schematicDisabled)return;let connectsTo=this._resolveConnectsTo();if(connectsTo)for(let connection of connectsTo)this.add(new Trace3({from:connection,to:`net.${this._getNetName()}`}))}doInitialSchematicTraceRender(){if(!this.root?._featureMspSchematicTraceRouting||this.root?.schematicDisabled)return;let{db:db2}=this.root,connectsTo=this._resolveConnectsTo();if(!connectsTo||connectsTo.length===0)return;let anchorPos=this._getGlobalSchematicPositionBeforeLayout(),anchorSide=this._getAnchorSide(),anchorFacing={left:"x-",right:"x+",top:"y+",bottom:"y-"}[anchorSide],net=this.getSubcircuit().selectOne(`net.${this._getNetName()}`);for(let connection of connectsTo){let port=this.getSubcircuit().selectOne(connection,{type:"port"});if(!port||!port.schematic_port_id)continue;let existingTraceForThisConnection=!1;if(net?.source_net_id){let candidateSourceTrace=db2.source_trace.list().find(st2=>st2.connected_source_net_ids?.includes(net.source_net_id)&&st2.connected_source_port_ids?.includes(port.source_port_id??""));if(candidateSourceTrace&&(existingTraceForThisConnection=db2.schematic_trace.list().some(t5=>t5.source_trace_id===candidateSourceTrace.source_trace_id)),existingTraceForThisConnection)continue}let portPos=port._getGlobalSchematicPositionAfterLayout(),portFacing=convertFacingDirectionToElbowDirection(port.facingDirection??"right")??"x+",path=calculateElbow({x:portPos.x,y:portPos.y,facingDirection:portFacing},{x:anchorPos.x,y:anchorPos.y,facingDirection:anchorFacing});if(!Array.isArray(path)||path.length<2)continue;let edges=[];for(let i3=0;i3<path.length-1;i3++)edges.push({from:{x:path[i3].x,y:path[i3].y},to:{x:path[i3+1].x,y:path[i3+1].y}});let source_trace_id,subcircuit_connectivity_map_key;if(net?.source_net_id&&port.source_port_id){let st2=db2.source_trace.list().find(s3=>s3.connected_source_net_ids?.includes(net.source_net_id)&&s3.connected_source_port_ids?.includes(port.source_port_id));source_trace_id=st2?.source_trace_id,subcircuit_connectivity_map_key=st2?.subcircuit_connectivity_map_key||db2.source_net.get(net.source_net_id)?.subcircuit_connectivity_map_key}db2.schematic_trace.insert({source_trace_id,edges,junctions:[],subcircuit_connectivity_map_key}),db2.schematic_port.update(port.schematic_port_id,{is_connected:!0})}}},SilkscreenCircle=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"pcb_silkscreen_circle_id",null);__publicField(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenCircle",zodProps:silkscreenCircleProps}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,{pcbX,pcbY}=this.getResolvedPcbPositionProp(),{maybeFlipLayer}=this._getPcbPrimitiveFlippedHelpers(),layer=maybeFlipLayer(props.layer??"top");if(layer!=="top"&&layer!=="bottom")throw new Error(`Invalid layer "${layer}" for SilkscreenCircle. Must be "top" or "bottom".`);let transform5=this._computePcbGlobalTransformBeforeLayout(),subcircuit=this.getSubcircuit(),pcb_component_id=this.parent?.pcb_component_id??this.getPrimitiveContainer()?.pcb_component_id,pcb_silkscreen_circle2=db2.pcb_silkscreen_circle.insert({pcb_component_id,layer,center:{x:pcbX,y:pcbY},radius:props.radius,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0,stroke_width:props.strokeWidth??.1});this.pcb_silkscreen_circle_id=pcb_silkscreen_circle2.pcb_silkscreen_circle_id}getPcbSize(){let{_parsedProps:props}=this,diameter=props.radius*2;return{width:diameter,height:diameter}}_moveCircuitJsonElements({deltaX,deltaY}){if(this.root?.pcbDisabled)return;let{db:db2}=this.root;if(!this.pcb_silkscreen_circle_id)return;let circle2=db2.pcb_silkscreen_circle.get(this.pcb_silkscreen_circle_id);circle2&&db2.pcb_silkscreen_circle.update(this.pcb_silkscreen_circle_id,{center:{x:circle2.center.x+deltaX,y:circle2.center.y+deltaY}})}},SilkscreenRect=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"pcb_silkscreen_rect_id",null);__publicField(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenRect",zodProps:silkscreenRectProps}}_isRotated90Degrees(){let globalTransform=this._computePcbGlobalTransformBeforeLayout(),normalizedRotationDegrees=(decomposeTSR(globalTransform).rotation.angle*180/Math.PI%360+360)%360,rotationTolerance=.01;return Math.abs(normalizedRotationDegrees-90)<rotationTolerance||Math.abs(normalizedRotationDegrees-270)<rotationTolerance}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,{maybeFlipLayer}=this._getPcbPrimitiveFlippedHelpers(),layer=maybeFlipLayer(props.layer??"top");if(layer!=="top"&&layer!=="bottom")throw new Error(`Invalid layer "${layer}" for SilkscreenRect. Must be "top" or "bottom".`);let subcircuit=this.getSubcircuit(),position2=this._getGlobalPcbPositionBeforeLayout(),isRotated90Degrees=this._isRotated90Degrees(),finalWidth=isRotated90Degrees?props.height:props.width,finalHeight=isRotated90Degrees?props.width:props.height,pcb_component_id=this.parent?.pcb_component_id??this.getPrimitiveContainer()?.pcb_component_id,pcb_silkscreen_rect2=db2.pcb_silkscreen_rect.insert({pcb_component_id,layer,center:{x:position2.x,y:position2.y},width:finalWidth,height:finalHeight,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:this?.getGroup()?.pcb_group_id??void 0,stroke_width:props.strokeWidth??.1,is_filled:props.filled??!1,corner_radius:props.cornerRadius??void 0});this.pcb_silkscreen_rect_id=pcb_silkscreen_rect2.pcb_silkscreen_rect_id}getPcbSize(){let{_parsedProps:props}=this;return this._isRotated90Degrees()?{width:props.height,height:props.width}:{width:props.width,height:props.height}}_moveCircuitJsonElements({deltaX,deltaY}){if(this.root?.pcbDisabled)return;let{db:db2}=this.root;if(!this.pcb_silkscreen_rect_id)return;let rect=db2.pcb_silkscreen_rect.get(this.pcb_silkscreen_rect_id);rect&&db2.pcb_silkscreen_rect.update(this.pcb_silkscreen_rect_id,{center:{x:rect.center.x+deltaX,y:rect.center.y+deltaY}})}},SilkscreenLine=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"pcb_silkscreen_line_id",null);__publicField(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenLine",zodProps:silkscreenLineProps}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,{maybeFlipLayer}=this._getPcbPrimitiveFlippedHelpers(),layer=maybeFlipLayer(props.layer??"top");if(layer!=="top"&&layer!=="bottom")throw new Error(`Invalid layer "${layer}" for SilkscreenLine. Must be "top" or "bottom".`);let subcircuit=this.getSubcircuit(),pcb_component_id=this.parent?.pcb_component_id??this.getPrimitiveContainer()?.pcb_component_id,pcb_silkscreen_line2=db2.pcb_silkscreen_line.insert({pcb_component_id,layer,x1:props.x1,y1:props.y1,x2:props.x2,y2:props.y2,stroke_width:props.strokeWidth??.1,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:subcircuit?.getGroup()?.pcb_group_id??void 0});this.pcb_silkscreen_line_id=pcb_silkscreen_line2.pcb_silkscreen_line_id}getPcbSize(){let{_parsedProps:props}=this,width=Math.abs(props.x2-props.x1),height=Math.abs(props.y2-props.y1);return{width,height}}_moveCircuitJsonElements({deltaX,deltaY}){if(this.root?.pcbDisabled)return;let{db:db2}=this.root;if(!this.pcb_silkscreen_line_id)return;let line2=db2.pcb_silkscreen_line.get(this.pcb_silkscreen_line_id);line2&&db2.pcb_silkscreen_line.update(this.pcb_silkscreen_line_id,{x1:line2.x1+deltaX,y1:line2.y1+deltaY,x2:line2.x2+deltaX,y2:line2.y2+deltaY})}},Fiducial=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"pcb_smtpad_id",null);__publicField(this,"isPcbPrimitive",!0)}get config(){return{componentName:"Fiducial",zodProps:fiducialProps,sourceFtype:"simple_fiducial"}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,position2=this._getGlobalPcbPositionBeforeLayout(),{maybeFlipLayer}=this._getPcbPrimitiveFlippedHelpers(),pcb_component_id=this.parent?.pcb_component_id??this.getPrimitiveContainer()?.pcb_component_id,pcb_smtpad2=db2.pcb_smtpad.insert({pcb_component_id,layer:maybeFlipLayer(props.layer||"top"),shape:"circle",x:position2.x,y:position2.y,radius:distance.parse(props.padDiameter)/2,soldermask_margin:props.soldermaskPullback?distance.parse(props.soldermaskPullback):distance.parse(props.padDiameter)/2,is_covered_with_solder_mask:!0});this.pcb_smtpad_id=pcb_smtpad2.pcb_smtpad_id}getPcbSize(){let{_parsedProps:props}=this,d3=distance.parse(props.padDiameter);return{width:d3,height:d3}}_setPositionFromLayout(newCenter){if(!this.pcb_smtpad_id)return;let{db:db2}=this.root;db2.pcb_smtpad.update(this.pcb_smtpad_id,{x:newCenter.x,y:newCenter.y})}_moveCircuitJsonElements({deltaX,deltaY}){if(this.root?.pcbDisabled)return;let{db:db2}=this.root;if(!this.pcb_smtpad_id)return;let pad2=db2.pcb_smtpad.get(this.pcb_smtpad_id);pad2&&(pad2.shape==="rect"||pad2.shape==="circle"||pad2.shape==="rotated_rect"||pad2.shape==="pill"?this._setPositionFromLayout({x:pad2.x+deltaX,y:pad2.y+deltaY}):pad2.shape==="polygon"&&db2.pcb_smtpad.update(this.pcb_smtpad_id,{points:pad2.points.map(p2=>({x:p2.x+deltaX,y:p2.y+deltaY}))}))}},Via=class extends PrimitiveComponent2{constructor(props){super(props);__publicField(this,"pcb_via_id",null);__publicField(this,"matchedPort",null);__publicField(this,"isPcbPrimitive",!0);__publicField(this,"source_manually_placed_via_id",null);__publicField(this,"subcircuit_connectivity_map_key",null);let layers=this._getLayers();this._parsedProps.layers=layers,this.initPorts()}get config(){return{componentName:"Via",zodProps:viaProps}}getAvailablePcbLayers(){return["top","inner1","inner2","bottom"]}_getResolvedViaDiameters(pcbStyle2){return getViaDiameterDefaultsWithOverrides({holeDiameter:this._parsedProps.holeDiameter,padDiameter:this._parsedProps.outerDiameter},pcbStyle2)}getPcbSize(){let pcbStyle2=this.getInheritedMergedProperty("pcbStyle"),{padDiameter}=this._getResolvedViaDiameters(pcbStyle2);return{width:padDiameter,height:padDiameter}}_getPcbCircuitJsonBounds(){let{db:db2}=this.root,via=db2.pcb_via.get(this.pcb_via_id),size2=this.getPcbSize();return{center:{x:via.x,y:via.y},bounds:{left:via.x-size2.width/2,top:via.y-size2.height/2,right:via.x+size2.width/2,bottom:via.y+size2.height/2},width:size2.width,height:size2.height}}_setPositionFromLayout(newCenter){let{db:db2}=this.root;db2.pcb_via.update(this.pcb_via_id,{x:newCenter.x,y:newCenter.y})}_getLayers(){let{fromLayer="top",toLayer="bottom"}=this._parsedProps;return fromLayer===toLayer?[fromLayer]:[fromLayer,toLayer]}initPorts(){let layers=this._parsedProps.layers;for(let layer of layers){let port2=new Port({name:layer,layer});port2.registerMatch(this),this.add(port2)}let port=new Port({name:"pin1"});port.registerMatch(this),this.add(port)}_getConnectedNetOrTrace(){let connectsTo=this._parsedProps.connectsTo;if(!connectsTo)return null;let subcircuit=this.getSubcircuit(),selectors=Array.isArray(connectsTo)?connectsTo:[connectsTo];for(let selector of selectors)if(selector.startsWith("net.")){let net=subcircuit.selectOne(selector,{type:"net"});if(net)return net}return null}doInitialPcbComponentRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,pcbStyle2=this.getInheritedMergedProperty("pcbStyle"),{padDiameter}=this._getResolvedViaDiameters(pcbStyle2),position2=this._getGlobalPcbPositionBeforeLayout(),subcircuit=this.getSubcircuit(),pcb_component2=db2.pcb_component.insert({center:position2,width:padDiameter,height:padDiameter,layer:this._parsedProps.fromLayer??"top",rotation:0,source_component_id:this.source_component_id,subcircuit_id:subcircuit?.subcircuit_id??void 0,obstructs_within_bounds:!0});this.pcb_component_id=pcb_component2.pcb_component_id}doInitialSourceRender(){let{db:db2}=this.root,{_parsedProps:props}=this,group=this.getGroup(),subcircuit=this.getSubcircuit(),source_via=db2.source_manually_placed_via.insert({source_group_id:group?.source_group_id,source_net_id:props.net??"",subcircuit_id:subcircuit?.subcircuit_id??void 0});this.source_component_id=source_via.source_manually_placed_via_id}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,pcbStyle2=this.getInheritedMergedProperty("pcbStyle"),{holeDiameter,padDiameter}=this._getResolvedViaDiameters(pcbStyle2),position2=this._getGlobalPcbPositionBeforeLayout(),subcircuit=this.getSubcircuit(),pcb_via2=db2.pcb_via.insert({x:position2.x,y:position2.y,hole_diameter:holeDiameter,outer_diameter:padDiameter,layers:["bottom","top"],from_layer:this._parsedProps.fromLayer||"bottom",to_layer:this._parsedProps.toLayer||"top",subcircuit_id:subcircuit?.subcircuit_id??void 0,subcircuit_connectivity_map_key:this.subcircuit_connectivity_map_key??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0,net_is_assignable:this._parsedProps.netIsAssignable??void 0});this.pcb_via_id=pcb_via2.pcb_via_id}},CopperPour=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"isPcbPrimitive",!0)}get config(){return{componentName:"CopperPour",zodProps:copperPourProps}}getPcbSize(){return{width:0,height:0}}doInitialCreateNetsFromProps(){let{_parsedProps:props}=this;createNetsFromProps(this,[props.connectsTo])}doInitialPcbCopperPourRender(){this.root?.pcbDisabled||this._queueAsyncEffect("PcbCopperPourRender",async()=>{let{db:db2}=this.root,{_parsedProps:props}=this,net=this.getSubcircuit().selectOne(props.connectsTo);if(!net||!net.source_net_id){this.renderError(`Net "${props.connectsTo}" not found for copper pour`);return}let subcircuit=this.getSubcircuit(),sourceNet=db2.toArray().filter(elm=>elm.type==="source_net"&&elm.name===net.name)[0]||"",clearance=props.clearance??.2,inputProblem=convertCircuitJsonToInputProblem(db2.toArray(),{layer:props.layer,pour_connectivity_key:sourceNet.subcircuit_connectivity_map_key||"",pad_margin:props.padMargin??clearance,trace_margin:props.traceMargin??clearance,board_edge_margin:props.boardEdgeMargin??clearance,cutout_margin:props.cutoutMargin??clearance}),solver=new CopperPourPipelineSolver(inputProblem);this.root.emit("solver:started",{solverName:"CopperPourPipelineSolver",solverParams:inputProblem,componentName:this.props.name});let{brep_shapes}=solver.getOutput(),coveredWithSolderMask=props.coveredWithSolderMask??!1;for(let brep_shape2 of brep_shapes)db2.pcb_copper_pour.insert({shape:"brep",layer:props.layer,brep_shape:brep_shape2,source_net_id:net.source_net_id,subcircuit_id:subcircuit?.subcircuit_id??void 0,covered_with_solder_mask:coveredWithSolderMask})})}},CopperText=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"isPcbPrimitive",!0);__publicField(this,"pcb_copper_text_id",null)}get config(){return{componentName:"CopperText",zodProps:copperTextProps}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,container=this.getPrimitiveContainer(),position2=this._getGlobalPcbPositionBeforeLayout(),subcircuit=this.getSubcircuit(),pcb_copper_text2=db2.pcb_copper_text.insert({anchor_alignment:props.anchorAlignment,anchor_position:{x:position2.x,y:position2.y},font:"tscircuit2024",font_size:props.fontSize,layer:props.layer??"top",text:normalizeTextForCircuitJson(props.text),ccw_rotation:props.pcbRotation,is_mirrored:props.mirrored,is_knockout:props.knockout,pcb_component_id:container.pcb_component_id,subcircuit_id:subcircuit?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0});this.pcb_copper_text_id=pcb_copper_text2.pcb_copper_text_id}getPcbSize(){let{_parsedProps:props}=this,fontSize=props.fontSize??1,textWidth=(props.text??"").length*fontSize,textHeight=fontSize;return{width:textWidth*fontSize,height:textHeight*fontSize}}_moveCircuitJsonElements({deltaX,deltaY}){if(this.root?.pcbDisabled)return;let{db:db2}=this.root;if(!this.pcb_copper_text_id)return;let text=db2.pcb_copper_text.get(this.pcb_copper_text_id);text&&db2.pcb_copper_text.update(this.pcb_copper_text_id,{anchor_position:{x:text.anchor_position.x+deltaX,y:text.anchor_position.y+deltaY}})}},Battery=class extends NormalComponent3{get config(){return{componentName:"Battery",schematicSymbolName:this.props.symbolName??"battery",zodProps:batteryProps,sourceFtype:"simple_power_source"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}doInitialSourceRender(){let{db:db2}=this.root,{_parsedProps:props}=this,source_component=db2.source_component.insert({name:this.name,ftype:"simple_power_source",capacity:props.capacity,supplier_part_numbers:props.supplierPartNumbers,are_pins_interchangeable:!1});this.source_component_id=source_component.source_component_id}},PinHeader=class extends NormalComponent3{_getPcbRotationBeforeLayout(){let orientationRotation=this.props.pcbOrientation==="vertical"?-90:0;return(super._getPcbRotationBeforeLayout()??0)+orientationRotation}get config(){return{componentName:"PinHeader",zodProps:pinHeaderProps,shouldRenderAsSchematicBox:!0}}_getImpliedFootprintString(){let pinCount=this._parsedProps.pinCount??(Array.isArray(this._parsedProps.pinLabels)?this._parsedProps.pinLabels.length:this._parsedProps.pinLabels?Object.keys(this._parsedProps.pinLabels).length:0),holeDiameter=this._parsedProps.holeDiameter,platedDiameter=this._parsedProps.platedDiameter,pitch=this._parsedProps.pitch,showSilkscreenPinLabels=this._parsedProps.showSilkscreenPinLabels,rows=this._parsedProps.doubleRow?2:1;if(pinCount>0){let footprintString;if(pitch)!holeDiameter&&!platedDiameter?footprintString=`pinrow${pinCount}_p${pitch}`:footprintString=`pinrow${pinCount}_p${pitch}_id${holeDiameter}_od${platedDiameter}`;else if(!holeDiameter&&!platedDiameter)footprintString=`pinrow${pinCount}`;else return null;return showSilkscreenPinLabels!==!0&&(footprintString+="_nopinlabels"),rows>1&&(footprintString+=`_rows${rows}`),footprintString}return null}initPorts(){let pinCount=this._parsedProps.pinCount??(Array.isArray(this._parsedProps.pinLabels)?this._parsedProps.pinLabels.length:this._parsedProps.pinLabels?Object.keys(this._parsedProps.pinLabels).length:1);for(let i3=1;i3<=pinCount;i3++){let rawLabel=Array.isArray(this._parsedProps.pinLabels)?this._parsedProps.pinLabels[i3-1]:this._parsedProps.pinLabels?.[`pin${i3}`];if(rawLabel){let primaryLabel=Array.isArray(rawLabel)?rawLabel[0]:rawLabel,otherLabels=Array.isArray(rawLabel)?rawLabel.slice(1):[];this.add(new Port({pinNumber:i3,name:primaryLabel,aliases:[`pin${i3}`,...otherLabels]}))}else this.add(new Port({pinNumber:i3,name:`pin${i3}`}))}}_getSchematicPortArrangement(){let pinCount=this._parsedProps.pinCount??1,facingDirection=this._parsedProps.schFacingDirection??this._parsedProps.facingDirection??"right",schPinArrangement=this._parsedProps.schPinArrangement;return facingDirection==="left"?{leftSide:{direction:schPinArrangement?.leftSide?.direction??"top-to-bottom",pins:schPinArrangement?.leftSide?.pins??Array.from({length:pinCount},(_4,i3)=>`pin${i3+1}`)}}:{rightSide:{direction:schPinArrangement?.rightSide?.direction??"top-to-bottom",pins:schPinArrangement?.rightSide?.pins??Array.from({length:pinCount},(_4,i3)=>`pin${i3+1}`)}}}doInitialSourceRender(){let{db:db2}=this.root,{_parsedProps:props}=this,source_component=db2.source_component.insert({ftype:"simple_pin_header",name:this.name,supplier_part_numbers:props.supplierPartNumbers,pin_count:props.pinCount,gender:props.gender,are_pins_interchangeable:!0});this.source_component_id=source_component.source_component_id}};function getResonatorSymbolName(variant){switch(variant){case"two_ground_pins":return"crystal_4pin";case"ground_pin":return"resonator";case"no_ground":return"crystal";default:return"crystal"}}var Resonator=class extends NormalComponent3{get config(){return{componentName:"Resonator",schematicSymbolName:this.props.symbolName??getResonatorSymbolName(this.props.pinVariant),zodProps:resonatorProps,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){let{db:db2}=this.root,{_parsedProps:props}=this,pinVariant=props.pinVariant||"no_ground",source_component=db2.source_component.insert({ftype:"simple_resonator",name:this.name,frequency:props.frequency,load_capacitance:props.loadCapacitance,supplier_part_numbers:props.supplierPartNumbers,pin_variant:pinVariant,are_pins_interchangeable:pinVariant==="no_ground"||pinVariant==="ground_pin"});this.source_component_id=source_component.source_component_id}_getSchematicSymbolDisplayValue(){let freqDisplay=`${formatSiUnit(this._parsedProps.frequency)}Hz`;return this._parsedProps.loadCapacitance?`${freqDisplay} / ${formatSiUnit(this._parsedProps.loadCapacitance)}F`:freqDisplay}};function getPotentiometerSymbolName(variant){switch(variant){case"three_pin":return"potentiometer3";case"two_pin":return"potentiometer2";default:return"potentiometer2"}}var Potentiometer=class extends NormalComponent3{get config(){return{componentName:"Potentiometer",schematicSymbolName:this.props.symbolName??getPotentiometerSymbolName(this.props.pinVariant),zodProps:potentiometerProps,shouldRenderAsSchematicBox:!1}}_getSchematicSymbolDisplayValue(){return`${formatSiUnit(this._parsedProps.maxResistance)}\u03A9`}doInitialSourceRender(){let{db:db2}=this.root,{_parsedProps:props}=this,pinVariant=props.pinVariant||"two_pin",source_component=db2.source_component.insert({ftype:"simple_potentiometer",name:this.name,max_resistance:props.maxResistance,pin_variant:pinVariant,are_pins_interchangeable:pinVariant==="two_pin"});this.source_component_id=source_component.source_component_id}},PushButton=class extends NormalComponent3{get config(){return{componentName:"PushButton",schematicSymbolName:this.props.symbolName??"push_button_normally_open_momentary",zodProps:pushButtonProps,sourceFtype:FTYPE.simple_push_button}}get defaultInternallyConnectedPinNames(){return[]}initPorts(){super.initPorts({pinCount:2,ignoreSymbolPorts:!0});let symbol=cf[this._getSchematicSymbolNameOrThrow()],symPort1=symbol.ports.find(p2=>p2.labels.includes("1")),symPort2=symbol.ports.find(p2=>p2.labels.includes("2")),ports=this.selectAll("port"),pin1Port=ports.find(p2=>p2.props.pinNumber===1),pin2Port=ports.find(p2=>p2.props.pinNumber===2),pin3Port=ports.find(p2=>p2.props.pinNumber===3),pin4Port=ports.find(p2=>p2.props.pinNumber===4),{internallyConnectedPins}=this._parsedProps;pin1Port.schematicSymbolPortDef=symPort1,(!internallyConnectedPins||internallyConnectedPins.length===0)&&(pin2Port.schematicSymbolPortDef=symPort2);for(let[pn3,port]of[[2,pin2Port],[3,pin3Port],[4,pin4Port]]){let internallyConnectedRow=internallyConnectedPins?.find(([pin1,pin2])=>pin1===`pin${pn3}`||pin2===`pin${pn3}`);if(!internallyConnectedRow){port.schematicSymbolPortDef=symPort2;break}(internallyConnectedRow?.[0]===`pin${pn3}`?internallyConnectedRow[1]:internallyConnectedRow?.[0])!=="pin1"&&(port.schematicSymbolPortDef=symPort2)}}doInitialSourceRender(){let{db:db2}=this.root,{_parsedProps:props}=this,source_component=db2.source_component.insert({name:this.name,ftype:FTYPE.simple_push_button,supplier_part_numbers:props.supplierPartNumbers,are_pins_interchangeable:!0});this.source_component_id=source_component.source_component_id}},Crystal=class extends NormalComponent3{get config(){return{schematicSymbolName:this.props.symbolName??(this.props.pinVariant==="four_pin"?"crystal_4pin":"crystal"),componentName:"Crystal",zodProps:crystalProps,sourceFtype:"simple_crystal"}}initPorts(){let additionalAliases=this.props.pinVariant==="four_pin"?{pin1:["left1","1"],pin2:["top1","2","gnd1"],pin3:["right1","3"],pin4:["bottom1","4","gnd2"]}:{pin1:["pos","left"],pin2:["neg","right"]};super.initPorts({additionalAliases})}_getSchematicSymbolDisplayValue(){let freqDisplay=`${formatSiUnit(this._parsedProps.frequency)}Hz`;return this._parsedProps.loadCapacitance?`${freqDisplay} / ${formatSiUnit(this._parsedProps.loadCapacitance)}F`:freqDisplay}doInitialSourceRender(){let{db:db2}=this.root,{_parsedProps:props}=this,source_component=db2.source_component.insert({name:this.name,ftype:"simple_crystal",frequency:props.frequency,load_capacitance:props.loadCapacitance,pin_variant:props.pinVariant||"two_pin",are_pins_interchangeable:(props.pinVariant||"two_pin")==="two_pin"});this.source_component_id=source_component.source_component_id}},Mosfet=class extends NormalComponent3{get config(){let mosfetMode=this.props.mosfetMode==="depletion"?"d":"e",baseSymbolName=`${this.props.channelType}_channel_${mosfetMode}_mosfet_transistor`;return{componentName:"Mosfet",schematicSymbolName:this.props.symbolName??baseSymbolName,zodProps:mosfetProps,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){let{db:db2}=this.root,{_parsedProps:props}=this,source_component=db2.source_component.insert({ftype:"simple_mosfet",name:this.name,mosfet_mode:props.mosfetMode,channel_type:props.channelType});this.source_component_id=source_component.source_component_id}},OpAmp=class extends NormalComponent3{constructor(){super(...arguments);__publicField(this,"inverting_input",this.portMap.inverting_input);__publicField(this,"non_inverting_input",this.portMap.non_inverting_input);__publicField(this,"output",this.portMap.output);__publicField(this,"positive_supply",this.portMap.positive_supply);__publicField(this,"negative_supply",this.portMap.negative_supply)}get config(){let hasPowerConnections=this.props.connections?.positive_supply||this.props.connections?.negative_supply;return{componentName:"OpAmp",schematicSymbolName:this.props.symbolName?this.props.symbolName:hasPowerConnections?"opamp_with_power":"opamp_no_power",zodProps:opampProps,sourceFtype:"simple_op_amp"}}initPorts(){super.initPorts({pinCount:5,additionalAliases:{pin1:["non_inverting_input"],pin2:["inverting_input"],pin3:["output"],pin4:["positive_supply","vcc","vdd"],pin5:["negative_supply","vee","vss","gnd"]}})}doInitialSourceRender(){let{db:db2}=this.root,{_parsedProps:props}=this,source_component=db2.source_component.insert({ftype:"simple_op_amp",name:this.name,supplier_part_numbers:props.supplierPartNumbers});this.source_component_id=source_component.source_component_id}doInitialSimulationRender(){let{db:db2}=this.root,invertingInputPort=this.portMap.inverting_input,nonInvertingInputPort=this.portMap.non_inverting_input,outputPort=this.portMap.output,positiveSupplyPort=this.portMap.positive_supply,negativeSupplyPort=this.portMap.negative_supply;!invertingInputPort?.source_port_id||!nonInvertingInputPort?.source_port_id||!outputPort?.source_port_id||!positiveSupplyPort?.source_port_id||!negativeSupplyPort?.source_port_id||db2.simulation_op_amp.insert({type:"simulation_op_amp",source_component_id:this.source_component_id,inverting_input_source_port_id:invertingInputPort.source_port_id,non_inverting_input_source_port_id:nonInvertingInputPort.source_port_id,output_source_port_id:outputPort.source_port_id,positive_supply_source_port_id:positiveSupplyPort.source_port_id,negative_supply_source_port_id:negativeSupplyPort.source_port_id})}};function hasSimProps(props){return props.simSwitchFrequency!==void 0||props.simCloseAt!==void 0||props.simOpenAt!==void 0||props.simStartClosed!==void 0||props.simStartOpen!==void 0}var Switch=class extends NormalComponent3{_getSwitchType(){let props=this._parsedProps;return props?props.dpdt?"dpdt":props.spst?"spst":props.spdt?"spdt":props.dpst?"dpst":props.type??"spst":"spst"}get config(){let switchType=this._getSwitchType(),isNormallyClosed=this._parsedProps?.isNormallyClosed??!1,symbolMap={spst:isNormallyClosed?"spst_normally_closed_switch":"spst_switch",spdt:isNormallyClosed?"spdt_normally_closed_switch":"spdt_switch",dpst:isNormallyClosed?"dpst_normally_closed_switch":"dpst_switch",dpdt:isNormallyClosed?"dpdt_normally_closed_switch":"dpdt_switch"};return{componentName:"Switch",schematicSymbolName:this.props.symbolName??symbolMap[switchType],zodProps:switchProps,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){let{db:db2}=this.root,props=this._parsedProps??{},source_component=db2.source_component.insert({ftype:"simple_switch",name:this.name,are_pins_interchangeable:this._getSwitchType()==="spst"});this.source_component_id=source_component.source_component_id}doInitialSimulationRender(){let{_parsedProps:props}=this;if(!hasSimProps(props))return;let{db:db2}=this.root,simulationSwitch={type:"simulation_switch",source_component_id:this.source_component_id||""};props.simSwitchFrequency!==void 0&&(simulationSwitch.switching_frequency=frequency.parse(props.simSwitchFrequency)),props.simCloseAt!==void 0&&(simulationSwitch.closes_at=ms.parse(props.simCloseAt)),props.simOpenAt!==void 0&&(simulationSwitch.opens_at=ms.parse(props.simOpenAt)),props.simStartOpen!==void 0&&(simulationSwitch.starts_closed=!props.simStartOpen),props.simStartClosed!==void 0&&(simulationSwitch.starts_closed=props.simStartClosed),db2.simulation_switch.insert(simulationSwitch)}},TESTPOINT_DEFAULTS={HOLE_DIAMETER:.5,SMT_CIRCLE_DIAMETER:1.2,SMT_RECT_SIZE:2},TestPoint=class extends NormalComponent3{get config(){return{componentName:"TestPoint",schematicSymbolName:this.props.symbolName??"testpoint",zodProps:testpointProps,sourceFtype:FTYPE.simple_test_point}}_getPropsWithDefaults(){let{padShape,holeDiameter,footprintVariant,padDiameter,width,height}=this._parsedProps;return!footprintVariant&&holeDiameter&&(footprintVariant="through_hole"),footprintVariant??(footprintVariant="through_hole"),padShape??(padShape="circle"),footprintVariant==="pad"?padShape==="circle"?padDiameter??(padDiameter=TESTPOINT_DEFAULTS.SMT_CIRCLE_DIAMETER):padShape==="rect"&&(width??(width=TESTPOINT_DEFAULTS.SMT_RECT_SIZE),height??(height=width)):footprintVariant==="through_hole"&&(holeDiameter??(holeDiameter=TESTPOINT_DEFAULTS.HOLE_DIAMETER)),{padShape,holeDiameter,footprintVariant,padDiameter,width,height}}_getImpliedFootprintString(){let{padShape,holeDiameter,footprintVariant,padDiameter,width,height}=this._getPropsWithDefaults();if(footprintVariant==="through_hole")return`platedhole_d${holeDiameter}`;if(footprintVariant==="pad"){if(padShape==="circle")return`smtpad_circle_d${padDiameter}`;if(padShape==="rect")return`smtpad_rect_w${width}_h${height}`}throw new Error(`Footprint variant "${footprintVariant}" with pad shape "${padShape}" not implemented`)}doInitialSourceRender(){let{db:db2}=this.root,{_parsedProps:props}=this,{padShape,holeDiameter,footprintVariant,padDiameter,width,height}=this._getPropsWithDefaults(),source_component=db2.source_component.insert({ftype:FTYPE.simple_test_point,name:this.name,supplier_part_numbers:props.supplierPartNumbers,footprint_variant:footprintVariant,pad_shape:padShape,pad_diameter:padDiameter,hole_diameter:holeDiameter,width,height,are_pins_interchangeable:!0});this.source_component_id=source_component.source_component_id}},SchematicText=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"isSchematicPrimitive",!0)}get config(){return{componentName:"SchematicText",zodProps:schematicTextProps}}doInitialSchematicPrimitiveRender(){if(this.root?.schematicDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,globalPos=this._getGlobalSchematicPositionBeforeLayout();db2.schematic_text.insert({anchor:props.anchor??"center",text:normalizeTextForCircuitJson(props.text),font_size:props.fontSize,color:props.color||"#000000",position:{x:globalPos.x,y:globalPos.y},rotation:props.schRotation??0})}},SchematicLine=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"isSchematicPrimitive",!0);__publicField(this,"schematic_line_id")}get config(){return{componentName:"SchematicLine",zodProps:schematicLineProps}}doInitialSchematicPrimitiveRender(){if(this.root?.schematicDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,globalPos=this._getGlobalSchematicPositionBeforeLayout(),schematic_component_id=this.getPrimitiveContainer()?.parent?.schematic_component_id,schematic_line2=db2.schematic_line.insert({schematic_component_id,x1:props.x1+globalPos.x,y1:props.y1+globalPos.y,x2:props.x2+globalPos.x,y2:props.y2+globalPos.y,stroke_width:props.strokeWidth??SCHEMATIC_COMPONENT_OUTLINE_STROKE_WIDTH,color:props.color??SCHEMATIC_COMPONENT_OUTLINE_COLOR,is_dashed:!1,subcircuit_id:this.getSubcircuit().subcircuit_id??void 0});this.schematic_line_id=schematic_line2.schematic_line_id}},SchematicRect=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"isSchematicPrimitive",!0);__publicField(this,"schematic_rect_id")}get config(){return{componentName:"SchematicRect",zodProps:schematicRectProps}}doInitialSchematicPrimitiveRender(){if(this.root?.schematicDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,globalPos=this._getGlobalSchematicPositionBeforeLayout(),schematic_component_id=this.getPrimitiveContainer()?.parent?.schematic_component_id,schematic_rect2=db2.schematic_rect.insert({center:{x:globalPos.x,y:globalPos.y},width:props.width,height:props.height,stroke_width:props.strokeWidth??SCHEMATIC_COMPONENT_OUTLINE_STROKE_WIDTH,color:props.color??SCHEMATIC_COMPONENT_OUTLINE_COLOR,is_filled:props.isFilled,schematic_component_id,is_dashed:props.isDashed,rotation:props.rotation??0,subcircuit_id:this.getSubcircuit().subcircuit_id??void 0});this.schematic_rect_id=schematic_rect2.schematic_rect_id}},SchematicArc=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"isSchematicPrimitive",!0);__publicField(this,"schematic_arc_id")}get config(){return{componentName:"SchematicArc",zodProps:schematicArcProps}}doInitialSchematicPrimitiveRender(){if(this.root?.schematicDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,globalPos=this._getGlobalSchematicPositionBeforeLayout(),schematic_component_id=this.getPrimitiveContainer()?.parent?.schematic_component_id,schematic_arc2=db2.schematic_arc.insert({schematic_component_id,center:{x:props.center.x+globalPos.x,y:props.center.y+globalPos.y},radius:props.radius,start_angle_degrees:props.startAngleDegrees,end_angle_degrees:props.endAngleDegrees,direction:props.direction,stroke_width:props.strokeWidth??SCHEMATIC_COMPONENT_OUTLINE_STROKE_WIDTH,color:props.color??SCHEMATIC_COMPONENT_OUTLINE_COLOR,is_dashed:props.isDashed,subcircuit_id:this.getSubcircuit().subcircuit_id??void 0});this.schematic_arc_id=schematic_arc2.schematic_arc_id}},SchematicCircle=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"isSchematicPrimitive",!0);__publicField(this,"schematic_circle_id")}get config(){return{componentName:"SchematicCircle",zodProps:schematicCircleProps}}doInitialSchematicPrimitiveRender(){if(this.root?.schematicDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,globalPos=this._getGlobalSchematicPositionBeforeLayout(),schematic_component_id=this.getPrimitiveContainer()?.parent?.schematic_component_id,schematic_circle2=db2.schematic_circle.insert({schematic_component_id,center:{x:props.center.x+globalPos.x,y:props.center.y+globalPos.y},radius:props.radius,stroke_width:props.strokeWidth??SCHEMATIC_COMPONENT_OUTLINE_STROKE_WIDTH,color:props.color??SCHEMATIC_COMPONENT_OUTLINE_COLOR,is_filled:props.isFilled,fill_color:props.fillColor,is_dashed:props.isDashed,subcircuit_id:this.getSubcircuit().subcircuit_id??void 0});this.schematic_circle_id=schematic_circle2.schematic_circle_id}};function getTitleAnchorAndPosition({anchor,x:x3,y:y3,width,height,isInside}){switch(anchor){case"top_left":return{x:x3,y:y3+height,textAnchor:isInside?"top_left":"bottom_left"};case"top_center":return{x:x3+width/2,y:y3+height,textAnchor:isInside?"top_center":"bottom_center"};case"top_right":return{x:x3+width,y:y3+height,textAnchor:isInside?"top_right":"bottom_right"};case"center_left":return{x:x3,y:y3+height/2,textAnchor:isInside?"center_left":"center_right"};case"center":return{x:x3+width/2,y:y3+height/2,textAnchor:"center"};case"center_right":return{x:x3+width,y:y3+height/2,textAnchor:isInside?"center_right":"center_left"};case"bottom_left":return{x:x3,y:y3,textAnchor:isInside?"bottom_left":"top_left"};case"bottom_center":return{x:x3+width/2,y:y3,textAnchor:isInside?"bottom_center":"top_center"};case"bottom_right":return{x:x3+width,y:y3,textAnchor:isInside?"bottom_right":"top_right"};default:return{x:x3+width/2,y:y3+height,textAnchor:"center"}}}var SchematicBox=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"isSchematicPrimitive",!0)}get config(){return{componentName:"SchematicBox",zodProps:schematicBoxProps,shouldRenderAsSchematicBox:!0}}doInitialSchematicPrimitiveRender(){if(this.root?.schematicDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,basePadding=.6,generalPadding=typeof props.padding=="number"?props.padding:0,paddingTop=typeof props.paddingTop=="number"?props.paddingTop:generalPadding,paddingBottom=typeof props.paddingBottom=="number"?props.paddingBottom:generalPadding,paddingLeft=typeof props.paddingLeft=="number"?props.paddingLeft:generalPadding,paddingRight=typeof props.paddingRight=="number"?props.paddingRight:generalPadding,hasOverlay=props.overlay&&props.overlay.length>0,hasFixedSize=typeof props.width=="number"&&typeof props.height=="number",width,height,x3,y3,centerX,centerY;if(hasOverlay){let portsWithPosition=props.overlay.map(selector=>({selector,port:this.getSubcircuit().selectOne(selector,{type:"port"})})).filter(({port})=>port!=null).map(({port})=>({position:port._getGlobalSchematicPositionAfterLayout()}));if(portsWithPosition.length===0)return;let xs3=portsWithPosition.map(p2=>p2.position.x),ys3=portsWithPosition.map(p2=>p2.position.y),minX=Math.min(...xs3),maxX=Math.max(...xs3),minY=Math.min(...ys3),maxY=Math.max(...ys3),rawWidth=maxX-minX,rawHeight=maxY-minY,defaultHorizontalPadding=rawWidth===0?basePadding:0,defaultVerticalPadding=rawHeight===0?basePadding:0,finalPaddingLeft=paddingLeft+defaultHorizontalPadding/2,finalPaddingRight=paddingRight+defaultHorizontalPadding/2,finalPaddingTop=paddingTop+defaultVerticalPadding/2,finalPaddingBottom=paddingBottom+defaultVerticalPadding/2,left=minX-finalPaddingLeft,right=maxX+finalPaddingRight,top=minY-finalPaddingBottom,bottom=maxY+finalPaddingTop;width=right-left,height=bottom-top,x3=left+(props.schX??0),y3=top+(props.schY??0),centerX=x3+width/2,centerY=y3+height/2}else if(hasFixedSize){width=props.width,height=props.height;let center2=this._getGlobalSchematicPositionBeforeLayout();centerX=center2.x,centerY=center2.y,x3=centerX-width/2,y3=centerY-height/2}else return;if(db2.schematic_box.insert({height,width,x:x3,y:y3,is_dashed:props.strokeStyle==="dashed"}),props.title){let isInside=props.titleInside,TITLE_PADDING=.1,anchor=props.titleAlignment,anchorPos=getTitleAnchorAndPosition({anchor,x:x3,y:y3,width,height,isInside}),titleOffsetY,titleOffsetX,textAnchor=anchorPos.textAnchor;isInside?(titleOffsetY=anchor.includes("top")?-TITLE_PADDING:anchor.includes("bottom")?TITLE_PADDING:0,titleOffsetX=anchor.includes("left")?TITLE_PADDING:anchor.includes("right")?-TITLE_PADDING:0):(titleOffsetY=anchor.includes("top")?TITLE_PADDING:anchor.includes("bottom")?-TITLE_PADDING:0,titleOffsetX=anchor.includes("center_left")?-TITLE_PADDING:anchor.includes("center_right")?TITLE_PADDING:0);let titleX=anchorPos.x+titleOffsetX,titleY=anchorPos.y+titleOffsetY;db2.schematic_text.insert({anchor:textAnchor,text:props.title,font_size:props.titleFontSize??.18,color:props.titleColor??"#000000",position:{x:titleX,y:titleY},rotation:0})}}},SchematicTable=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"isSchematicPrimitive",!0);__publicField(this,"schematic_table_id",null)}get config(){return{componentName:"SchematicTable",zodProps:schematicTableProps}}doInitialSchematicPrimitiveRender(){if(this.root?.schematicDisabled)return;let{db:db2}=this.root,{_parsedProps:props}=this,rows=this.children.filter(c3=>c3.componentName==="SchematicRow");if(rows.length===0)return;let grid4=[],maxCols=0;for(let row of rows){let cells=row.children.filter(c3=>c3.componentName==="SchematicCell");maxCols=Math.max(maxCols,cells.length)}for(let i3=0;i3<rows.length;i3++)grid4[i3]=[];for(let i3=0;i3<rows.length;i3++){let cells=rows[i3].children.filter(c3=>c3.componentName==="SchematicCell"),k4=0;for(let j3=0;j3<cells.length;j3++){for(;grid4[i3][k4];)k4++;let cell=cells[j3],colSpan=cell._parsedProps.colSpan??1,rowSpan=cell._parsedProps.rowSpan??1;for(let r4=0;r4<rowSpan;r4++)for(let c3=0;c3<colSpan;c3++)grid4[i3+r4]||(grid4[i3+r4]=[]),grid4[i3+r4][k4+c3]=cell;k4+=colSpan}}maxCols=Math.max(0,...grid4.map(r4=>r4.length));let rowHeights=rows.map((row,i3)=>row._parsedProps.height??1),colWidths=Array.from({length:maxCols},(_4,j3)=>{let maxWidth=0;for(let i3=0;i3<rows.length;i3++){let cell=grid4[i3]?.[j3];if(cell){let text=cell._parsedProps.text??cell._parsedProps.children,cellWidth=cell._parsedProps.width??(text?.length??2)*.5;cellWidth>maxWidth&&(maxWidth=cellWidth)}}return maxWidth||10}),anchorPos=this._getGlobalSchematicPositionBeforeLayout(),table=db2.schematic_table.insert({anchor_position:anchorPos,column_widths:colWidths,row_heights:rowHeights,cell_padding:props.cellPadding,border_width:props.borderWidth,anchor:props.anchor,subcircuit_id:this.getSubcircuit()?.subcircuit_id||"",schematic_component_id:this.parent?.schematic_component_id||""});this.schematic_table_id=table.schematic_table_id;let processedCells=new Set,yOffset=0;for(let i3=0;i3<rows.length;i3++){let xOffset=0;for(let j3=0;j3<maxCols;j3++){let cell=grid4[i3]?.[j3];if(cell&&!processedCells.has(cell)){processedCells.add(cell);let cellProps=cell._parsedProps,rowSpan=cellProps.rowSpan??1,colSpan=cellProps.colSpan??1,cellWidth=0;for(let c3=0;c3<colSpan;c3++)cellWidth+=colWidths[j3+c3];let cellHeight=0;for(let r4=0;r4<rowSpan;r4++)cellHeight+=rowHeights[i3+r4];db2.schematic_table_cell.insert({schematic_table_id:this.schematic_table_id,start_row_index:i3,end_row_index:i3+rowSpan-1,start_column_index:j3,end_column_index:j3+colSpan-1,text:cellProps.text??cellProps.children,center:{x:anchorPos.x+xOffset+cellWidth/2,y:anchorPos.y-yOffset-cellHeight/2},width:cellWidth,height:cellHeight,horizontal_align:cellProps.horizontalAlign,vertical_align:cellProps.verticalAlign,font_size:cellProps.fontSize??props.fontSize,subcircuit_id:this.getSubcircuit()?.subcircuit_id||""})}colWidths[j3]&&(xOffset+=colWidths[j3])}yOffset+=rowHeights[i3]}}},SchematicRow=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"isSchematicPrimitive",!0)}get config(){return{componentName:"SchematicRow",zodProps:schematicRowProps}}},SchematicCell=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"isSchematicPrimitive",!0);__publicField(this,"canHaveTextChildren",!0)}get config(){return{componentName:"SchematicCell",zodProps:schematicCellProps}}},SymbolComponent=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"isPrimitiveContainer",!0)}get config(){return{componentName:"Symbol",zodProps:symbolProps}}},AnalogSimulation=class extends PrimitiveComponent2{get config(){return{componentName:"AnalogSimulation",zodProps:analogSimulationProps}}doInitialSimulationRender(){let{db:db2}=this.root,{duration,timePerStep}=this._parsedProps,durationMs=duration||10,timePerStepMs=timePerStep||.01;db2.simulation_experiment.insert({name:"spice_transient_analysis",experiment_type:"spice_transient_analysis",end_time_ms:durationMs,time_per_step:timePerStepMs})}};function getLabelBounds(probePosition,labelText,alignment,labelOffset=.3){let labelWidth=Math.max(labelText.length*.1,.3),labelHeightWithPadding=.25+.2,anchorX=probePosition.x,anchorY=probePosition.y,offsetMultiplier=labelOffset+labelWidth/2;alignment.includes("top")?anchorY+=offsetMultiplier:alignment.includes("bottom")&&(anchorY-=offsetMultiplier),alignment.includes("right")?anchorX+=offsetMultiplier:alignment.includes("left")&&(anchorX-=offsetMultiplier);let minX,maxX,minY,maxY;return alignment.includes("left")?(minX=anchorX,maxX=anchorX+labelWidth):alignment.includes("right")?(minX=anchorX-labelWidth,maxX=anchorX):(minX=anchorX-labelWidth/2,maxX=anchorX+labelWidth/2),alignment.includes("top")?(minY=anchorY-labelHeightWithPadding,maxY=anchorY):alignment.includes("bottom")?(minY=anchorY,maxY=anchorY+labelHeightWithPadding):(minY=anchorY-labelHeightWithPadding/2,maxY=anchorY+labelHeightWithPadding/2),{minX,maxX,minY,maxY}}function getElementBounds(elm){let cx2,cy2,w4,h2;if(elm.type==="schematic_component")cx2=elm.center?.x,cy2=elm.center?.y,w4=elm.size?.width,h2=elm.size?.height;else if(elm.type==="schematic_text")cx2=elm.position?.x,cy2=elm.position?.y,w4=(elm.text?.length??0)*.1,h2=.2;else return null;return typeof cx2=="number"&&typeof cy2=="number"&&typeof w4=="number"&&typeof h2=="number"?{minX:cx2-w4/2,maxX:cx2+w4/2,minY:cy2-h2/2,maxY:cy2+h2/2}:null}function getOverlapArea(a2,b3){if(!doBoundsOverlap(a2,b3))return 0;let overlapWidth=Math.min(a2.maxX,b3.maxX)-Math.max(a2.minX,b3.minX),overlapHeight=Math.min(a2.maxY,b3.maxY)-Math.max(a2.minY,b3.minY);return overlapWidth*overlapHeight}function selectBestLabelAlignment({probePosition,labelText,schematicElements,defaultAlignment="top_right"}){let orderedAlignments=[defaultAlignment,...["top_right","top_left","bottom_right","bottom_left","top_center","bottom_center","center_right","center_left"].filter(a2=>a2!==defaultAlignment)],bestAlignment=defaultAlignment,minOverlapArea=1/0;for(let alignment of orderedAlignments){let labelBounds=getLabelBounds(probePosition,labelText,alignment),totalOverlapArea=0;for(let element of schematicElements){let elementBounds=getElementBounds(element);elementBounds&&(totalOverlapArea+=getOverlapArea(labelBounds,elementBounds))}if(totalOverlapArea===0)return alignment;totalOverlapArea<minOverlapArea&&(minOverlapArea=totalOverlapArea,bestAlignment=alignment)}return bestAlignment}var VoltageProbe=class extends PrimitiveComponent2{constructor(){super(...arguments);__publicField(this,"simulation_voltage_probe_id",null);__publicField(this,"schematic_voltage_probe_id",null);__publicField(this,"finalProbeName",null);__publicField(this,"color",null)}get config(){return{componentName:"VoltageProbe",zodProps:voltageProbeProps}}doInitialSimulationRender(){let{db:db2}=this.root,{connectsTo,name,referenceTo,color}=this._parsedProps,subcircuit=this.getSubcircuit();if(!subcircuit){this.renderError("VoltageProbe must be inside a subcircuit");return}let targets=Array.isArray(connectsTo)?connectsTo:[connectsTo];if(targets.length!==1){this.renderError("VoltageProbe must connect to exactly one port or net");return}let targetSelector=targets[0],port=subcircuit.selectOne(targetSelector,{type:"port"}),net=port?null:subcircuit.selectOne(targetSelector,{type:"net"});if(net&&net.componentName!=="Net"){this.renderError(`VoltageProbe connection target "${targetSelector}" resolved to a non-net component "${net.componentName}".`);return}if(!port&&!net){this.renderError(`VoltageProbe could not find connection target "${targetSelector}"`);return}let connectedId=port?.source_port_id??net?.source_net_id;if(!connectedId){this.renderError("Could not identify connected source for VoltageProbe");return}let referencePort=null,referenceNet=null;if(referenceTo){let referenceTargets=Array.isArray(referenceTo)?referenceTo:[referenceTo];if(referenceTargets.length!==1){this.renderError("VoltageProbe must reference exactly one port or net");return}let referenceSelector=referenceTargets[0];if(referencePort=subcircuit.selectOne(referenceSelector,{type:"port"}),referenceNet=referencePort?null:subcircuit.selectOne(referenceSelector,{type:"net"}),referenceNet&&referenceNet.componentName!=="Net"){this.renderError(`VoltageProbe reference target "${referenceSelector}" resolved to a non-net component "${referenceNet.componentName}".`);return}if(!referencePort&&!referenceNet){this.renderError(`VoltageProbe could not find reference target "${referenceSelector}"`);return}}this.color=color??getSimulationColorForId(connectedId);let finalName=name;finalName||(finalName=targets[0].split(" > ").map(s3=>s3.replace(/^\./,"")).join(".")),this.finalProbeName=finalName??null;let{simulation_voltage_probe_id}=db2.simulation_voltage_probe.insert({name:finalName,signal_input_source_port_id:port?.source_port_id??void 0,signal_input_source_net_id:net?.source_net_id??void 0,reference_input_source_port_id:referencePort?.source_port_id??void 0,reference_input_source_net_id:referenceNet?.source_net_id??void 0,subcircuit_id:subcircuit.subcircuit_id||void 0,color:this.color});this.simulation_voltage_probe_id=simulation_voltage_probe_id}doInitialSchematicReplaceNetLabelsWithSymbols(){if(this.root?.schematicDisabled)return;let{db:db2}=this.root,{connectsTo,name}=this._parsedProps,subcircuit=this.getSubcircuit();if(!subcircuit)return;let targets=Array.isArray(connectsTo)?connectsTo:[connectsTo];if(targets.length!==1)return;let targetSelector=targets[0],port=subcircuit.selectOne(targetSelector,{type:"port"});if(!port||!port.schematic_port_id)return;let position2=port._getGlobalSchematicPositionAfterLayout(),targetTraceId=null;for(let trace of db2.schematic_trace.list()){for(let edge of trace.edges)if(Math.abs(edge.from.x-position2.x)<1e-6&&Math.abs(edge.from.y-position2.y)<1e-6||Math.abs(edge.to.x-position2.x)<1e-6&&Math.abs(edge.to.y-position2.y)<1e-6){targetTraceId=trace.schematic_trace_id;break}if(targetTraceId)break}if(!targetTraceId)return;let probeName=this.finalProbeName,labelAlignment=selectBestLabelAlignment({probePosition:position2,labelText:probeName,schematicElements:[...db2.schematic_component.list(),...db2.schematic_text.list()],defaultAlignment:"top_right"}),schematic_voltage_probe2=db2.schematic_voltage_probe.insert({name:probeName,position:position2,schematic_trace_id:targetTraceId,subcircuit_id:subcircuit.subcircuit_id||void 0,color:this.color??void 0,label_alignment:labelAlignment});this.schematic_voltage_probe_id=schematic_voltage_probe2.schematic_voltage_probe_id}},package_default3={name:"@tscircuit/core",type:"module",version:"0.0.967",types:"dist/index.d.ts",main:"dist/index.js",module:"dist/index.js",exports:{".":{import:"./dist/index.js",types:"./dist/index.d.ts"}},files:["dist"],repository:{type:"git",url:"https://github.com/tscircuit/core"},scripts:{build:"tsup-node index.ts --format esm --dts",format:"biome format . --write","measure-bundle":"howfat -r table .","pkg-pr-new-release":"bunx pkg-pr-new publish --comment=off --peerDeps","smoke-test:dist":"bun run scripts/smoke-tests/test-dist-simple-circuit.tsx","build:benchmarking":"bun build --experimental-html ./benchmarking/website/index.html --outdir ./benchmarking-dist","build:benchmarking:watch":`chokidar "./{benchmarking,lib}/**/*.{ts,tsx}" -c 'bun build --experimental-html ./benchmarking/website/index.html --outdir ./benchmarking-dist'`,"start:benchmarking":'concurrently "bun run build:benchmarking:watch" "live-server ./benchmarking-dist"',"generate-test-plan":"bun run scripts/generate-test-plan.ts"},devDependencies:{"@biomejs/biome":"^1.8.3","@resvg/resvg-js":"^2.6.2","@tscircuit/capacity-autorouter":"^0.0.252","@tscircuit/checks":"^0.0.87","@tscircuit/circuit-json-util":"^0.0.75","@tscircuit/common":"^0.0.20","@tscircuit/copper-pour-solver":"^0.0.14","@tscircuit/footprinter":"^0.0.288","@tscircuit/infgrid-ijump-astar":"^0.0.35","@tscircuit/log-soup":"^1.0.2","@tscircuit/matchpack":"^0.0.16","@tscircuit/math-utils":"^0.0.29","@tscircuit/miniflex":"^0.0.4","@tscircuit/ngspice-spice-engine":"^0.0.8","@tscircuit/props":"^0.0.442","@tscircuit/schematic-match-adapt":"^0.0.16","@tscircuit/schematic-trace-solver":"^v0.0.45","@tscircuit/solver-utils":"^0.0.3","@types/bun":"^1.2.16","@types/debug":"^4.1.12","@types/react":"^19.1.8","@types/react-dom":"^19.1.6","@types/react-reconciler":"^0.28.9","bpc-graph":"^0.0.57","bun-match-svg":"0.0.12","calculate-elbow":"^0.0.12","chokidar-cli":"^3.0.0","circuit-json":"^0.0.350","circuit-json-to-bpc":"^0.0.13","circuit-json-to-connectivity-map":"^0.0.23","circuit-json-to-gltf":"^0.0.31","circuit-json-to-simple-3d":"^0.0.9","circuit-json-to-spice":"^0.0.33","circuit-to-svg":"^0.0.313",concurrently:"^9.1.2","connectivity-map":"^1.0.0",debug:"^4.3.6","eecircuit-engine":"^1.5.6",flatbush:"^4.5.0","graphics-debug":"^0.0.60",howfat:"^0.3.8","live-server":"^1.2.2","looks-same":"^9.0.1",minicssgrid:"^0.0.9","pkg-pr-new":"^0.0.37",poppygl:"^0.0.16",react:"^19.1.0","react-dom":"^19.1.0","schematic-symbols":"^0.0.206",spicey:"^0.0.14","ts-expect":"^1.3.0",tsup:"^8.2.4","@tscircuit/soup-util":"^0.0.41"},peerDependencies:{"@tscircuit/capacity-autorouter":"*","@tscircuit/checks":"*","@tscircuit/circuit-json-util":"*","@tscircuit/footprinter":"*","@tscircuit/infgrid-ijump-astar":"*","@tscircuit/math-utils":"*","@tscircuit/props":"*","@tscircuit/schematic-match-adapt":"*","circuit-json-to-bpc":"*","bpc-graph":"*","@tscircuit/matchpack":"*","circuit-json":"*","circuit-json-to-connectivity-map":"*","schematic-symbols":"*",typescript:"^5.0.0"},dependencies:{"@flatten-js/core":"^1.6.2","@lume/kiwi":"^0.4.3","calculate-packing":"0.0.68","css-select":"5.1.0","format-si-unit":"^0.0.3",nanoid:"^5.0.7","performance-now":"^2.1.0","react-reconciler":"^0.32.0","transformation-matrix":"^2.16.1",zod:"^3.25.67"}},RootCircuit=class{constructor({platform,projectUrl}={}){__publicField(this,"firstChild",null);__publicField(this,"children");__publicField(this,"db");__publicField(this,"root",null);__publicField(this,"isRoot",!0);__publicField(this,"_schematicDisabledOverride");__publicField(this,"pcbDisabled",!1);__publicField(this,"pcbRoutingDisabled",!1);__publicField(this,"_featureMspSchematicTraceRouting",!0);__publicField(this,"name");__publicField(this,"platform");__publicField(this,"projectUrl");__publicField(this,"_hasRenderedAtleastOnce",!1);__publicField(this,"_eventListeners",{});this.children=[],this.db=su2([]),this.root=this,this.platform=platform,this.projectUrl=projectUrl,this.pcbDisabled=platform?.pcbDisabled??!1}get schematicDisabled(){return this._schematicDisabledOverride!==void 0?this._schematicDisabledOverride:this._getBoard()?._parsedProps?.schematicDisabled??!1}set schematicDisabled(value){this._schematicDisabledOverride=value}add(componentOrElm){let component;(0,import_react4.isValidElement)(componentOrElm)?component=createInstanceFromReactElement(componentOrElm):component=componentOrElm,this.children.push(component)}setPlatform(platform){this.platform={...this.platform,...platform}}_getBoard(){let directBoard=this.children.find(c3=>c3.componentName==="Board");if(directBoard)return directBoard}_guessRootComponent(){if(this.firstChild)return;if(this.children.length===0)throw new Error("Not able to guess root component: RootCircuit has no children (use circuit.add(...))");let panels=this.children.filter(child=>child.lowercaseComponentName==="panel");if(panels.length>1)throw new Error("Only one <panel> is allowed per circuit");if(panels.length===1){if(this.children.length!==1)throw new Error("<panel> must be the root element of the circuit");this.firstChild=panels[0];return}if(this.children.length===1&&this.children[0].isGroup){this.firstChild=this.children[0];return}let group=new Group6({subcircuit:!0});group.parent=this,group.addAll(this.children),this.children=[group],this.firstChild=group}render(){this.firstChild||this._guessRootComponent();let{firstChild,db:db2}=this;if(!firstChild)throw new Error("RootCircuit has no root component");firstChild.parent=this,firstChild.runRenderCycle(),this._hasRenderedAtleastOnce=!0}async renderUntilSettled(){for(this.db.source_project_metadata.list()?.[0]||this.db.source_project_metadata.insert({software_used_string:`@tscircuit/core@${this.getCoreVersion()}`,...this.projectUrl?{project_url:this.projectUrl}:{}}),this.render();this._hasIncompleteAsyncEffects();)await new Promise(resolve=>setTimeout(resolve,100)),this.render();this.emit("renderComplete")}_hasIncompleteAsyncEffects(){return this.children.some(child=>child._hasIncompleteAsyncEffects())}getCircuitJson(){return this._hasRenderedAtleastOnce||this.render(),this.db.toArray()}toJson(){return this.getCircuitJson()}async getSvg(options){let circuitToSvg=await Promise.resolve().then(()=>(init_dist8(),dist_exports3)).catch(e4=>{throw new Error(`To use circuit.getSvg, you must install the "circuit-to-svg" package.
616
616
 
617
617
  "${e4.message}"`)});if(options.view==="pcb")return circuitToSvg.convertCircuitJsonToPcbSvg(this.getCircuitJson());if(options.view==="schematic")return circuitToSvg.convertCircuitJsonToSchematicSvg(this.getCircuitJson());throw new Error(`Invalid view: ${options.view}`)}getCoreVersion(){let[major,minor,patch]=package_default3.version.split(".").map(Number);return`${major}.${minor}.${patch+1}`}async preview(previewNameOrOpts){let previewOpts=typeof previewNameOrOpts=="object"?previewNameOrOpts:{previewName:previewNameOrOpts};throw new Error("project.preview is not yet implemented")}computeSchematicGlobalTransform(){return identity()}_computePcbGlobalTransformBeforeLayout(){return identity()}selectAll(selector){return this._guessRootComponent(),this.firstChild?.selectAll(selector)??[]}selectOne(selector,opts){return this._guessRootComponent(),this.firstChild?.selectOne(selector,opts)??null}emit(event,...args){if(this._eventListeners[event])for(let listener of this._eventListeners[event])listener(...args)}on(event,listener){this._eventListeners[event]||(this._eventListeners[event]=[]),this._eventListeners[event].push(listener)}removeListener(event,listener){this._eventListeners[event]&&(this._eventListeners[event]=this._eventListeners[event].filter(l2=>l2!==listener))}enableDebug(debug112){typeof debug112=="string"?import_debug18.default.enable(debug112):(debug112===null||debug112===!1)&&import_debug18.default.disable()}getClientOrigin(){return typeof window<"u"&&window.location?window.location.origin:typeof self<"u"&&self.location?self.location.origin:""}},Project=RootCircuit,Circuit=RootCircuit,useRenderedCircuit=reactElements=>{let[isLoading,setIsLoading]=import_react5.default.useState(!0),[error,setError]=import_react5.default.useState(null),[circuit,setCircuit]=import_react5.default.useState(),[circuitJson,setCircuitJson]=import_react5.default.useState();return import_react5.default.useEffect(()=>{setIsLoading(!0),setError(null),reactElements&&setTimeout(()=>{try{let circuit2=new RootCircuit;circuit2.add(reactElements),setCircuit(circuit2),setCircuitJson(circuit2.toJson())}catch(error2){setError(error2)}setIsLoading(!1)},1)},[reactElements]),{isLoading,error,circuit,circuitJson}},createUseComponent=(Component2,pins)=>(name,props)=>{let pinLabelsFlatArray=[];Array.isArray(pins)?pinLabelsFlatArray.push(...pins.flat()):typeof pins=="object"&&pinLabelsFlatArray.push(...Object.values(pins).flat(),...Object.keys(pins));let R4=props2=>{if(props2?.name&&props2.name!==name)throw new Error(`Component name mismatch. Hook name: ${name}, Component prop name: ${props2.name}`);let combinedProps={...props,...props2,name},tracesToCreate=[];for(let portLabel of pinLabelsFlatArray)if(combinedProps[portLabel]){let from=`.${name} > .${portLabel}`,to3=combinedProps[portLabel];tracesToCreate.push({from,to:to3}),delete combinedProps[portLabel]}return(0,import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment,{children:[(0,import_jsx_runtime.jsx)(Component2,{...combinedProps}),tracesToCreate.map((trace,i3)=>(0,import_jsx_runtime.jsx)("trace",{...trace},i3))]})};for(let port of pinLabelsFlatArray)R4[port]=`.${name} > .${port}`;return R4},useCapacitor=createUseComponent(props=>(0,import_jsx_runtime2.jsx)("capacitor",{...props}),capacitorPins),useChip=pinLabels=>createUseComponent(props=>(0,import_jsx_runtime3.jsx)("chip",{pinLabels,...props}),pinLabels),useDiode=createUseComponent(props=>(0,import_jsx_runtime4.jsx)("diode",{...props}),diodePins),useLed=createUseComponent(props=>(0,import_jsx_runtime5.jsx)("led",{...props}),ledPins),useResistor=createUseComponent(props=>(0,import_jsx_runtime6.jsx)("resistor",{...props}),resistorPins),sel=new Proxy(refdes=>new Proxy({},{get:(_4,pin)=>`.${refdes} > .${pin}`}),{get:(_4,prop1)=>{let fn3=(...args)=>{let chipFnOrPinType=args[0];return new Proxy({},{get:(_22,pinName)=>`.${prop1} > .${pinName}`})};return new Proxy(fn3,{get:(_22,prop2)=>prop1==="net"?`net.${prop2}`:prop1==="subcircuit"?new Proxy({},{get:(_32,prop3)=>new Proxy({},{get:(_42,prop4)=>`subcircuit.${prop2} > .${prop3} > .${prop4}`})}):`.${prop1} > .${prop2}`,apply:(target,_22,args)=>prop1==="net"?new Proxy({},{get:(_32,netName)=>`net.${netName}`}):new Proxy({},{get:(_32,pinOrSubComponentName)=>{let pinResult=`.${prop1} > .${pinOrSubComponentName}`;return["U","J","CN"].some(p2=>prop1.startsWith(p2))?pinResult:new Proxy(new String(pinResult),{get:(_42,nestedProp)=>typeof nestedProp=="symbol"||nestedProp==="toString"?()=>pinResult:`.${prop1} > .${pinOrSubComponentName} > .${nestedProp}`})}})})}});extendCatalogue(components_exports);extendCatalogue({Bug:Chip});var React=__toESM(require_react(),1),ReactJsxRuntime=__toESM(require_jsx_runtime(),1);var getFootprinterStringFromKicad=kicadFootprint=>{let match2=kicadFootprint.match(/:[RC]_(\d{4})_/);if(match2||(match2=kicadFootprint.match(/:(SOIC-\d+|SOT-\d+|SOD-\d+|SSOP-\d+|TSSOP-\d+|QFP-\d+|QFN-\d+)/),match2))return match2[1]};var getJlcPackageFromFootprinterString=footprinterString=>footprinterString.includes("cap")?footprinterString.replace(/cap/g,""):footprinterString;var getJlcpcbPackageName=footprint=>{if(footprint){if(footprint.startsWith("kicad:")){let footprinterString=getFootprinterStringFromKicad(footprint);return footprinterString?getJlcPackageFromFootprinterString(footprinterString):footprint}return getJlcPackageFromFootprinterString(footprint)}};var cache=new Map,getJlcPartsCached=async(name,params)=>{let paramString=new URLSearchParams({...params,json:"true"}).toString();if(cache.has(paramString))return cache.get(paramString);let responseJson=await(await fetch(`https://jlcsearch.tscircuit.com/${name}/list?${paramString}`)).json();return cache.set(paramString,responseJson),responseJson},withBasicPartPreference=parts=>parts?[...parts].sort((a2,b3)=>Number(b3.is_basic??!1)-Number(a2.is_basic??!1)):[],jlcPartsEngine={findPart:async({sourceComponent,footprinterString})=>{let jlcpcbPackage=getJlcpcbPackageName(footprinterString);if(sourceComponent.type==="source_component"&&sourceComponent.ftype==="simple_resistor"){let{resistors}=await getJlcPartsCached("resistors",{resistance:sourceComponent.resistance,package:jlcpcbPackage});return{jlcpcb:withBasicPartPreference(resistors).map(r4=>`C${r4.lcsc}`).slice(0,3)}}else if(sourceComponent.type==="source_component"&&sourceComponent.ftype==="simple_capacitor"){let{capacitors}=await getJlcPartsCached("capacitors",{capacitance:sourceComponent.capacitance,package:jlcpcbPackage});return{jlcpcb:withBasicPartPreference(capacitors).map(c3=>`C${c3.lcsc}`).slice(0,3)}}else if(sourceComponent.type==="source_component"&&sourceComponent.ftype==="simple_pin_header"){let pitch;footprinterString?.includes("_p")&&(pitch=Number(footprinterString.split("_p")[1]));let{headers}=await getJlcPartsCached("headers",pitch?{pitch,num_pins:sourceComponent.pin_count,gender:sourceComponent.gender}:{num_pins:sourceComponent.pin_count,gender:sourceComponent.gender});return{jlcpcb:withBasicPartPreference(headers).map(h2=>`C${h2.lcsc}`).slice(0,3)}}else if(sourceComponent.type==="source_component"&&sourceComponent.ftype==="simple_potentiometer"){let{potentiometers}=await getJlcPartsCached("potentiometers",{resistance:sourceComponent.max_resistance,package:jlcpcbPackage});return{jlcpcb:withBasicPartPreference(potentiometers).map(p2=>`C${p2.lcsc}`).slice(0,3)}}else if(sourceComponent.type==="source_component"&&sourceComponent.ftype==="simple_diode"){let{diodes}=await getJlcPartsCached("diodes",{package:jlcpcbPackage});return{jlcpcb:withBasicPartPreference(diodes).map(d3=>`C${d3.lcsc}`).slice(0,3)}}else if(sourceComponent.type==="source_component"&&sourceComponent.ftype==="simple_chip"){let{chips}=await getJlcPartsCached("chips",{package:jlcpcbPackage});return{jlcpcb:withBasicPartPreference(chips).map(c3=>`C${c3.lcsc}`).slice(0,3)}}else if(sourceComponent.type==="source_component"&&sourceComponent.ftype==="simple_transistor"){let{transistors}=await getJlcPartsCached("transistors",{package:jlcpcbPackage,transistor_type:sourceComponent.transistor_type});return{jlcpcb:withBasicPartPreference(transistors).map(t5=>`C${t5.lcsc}`).slice(0,3)}}else if(sourceComponent.type==="source_component"&&sourceComponent.ftype==="simple_power_source"){let{power_sources}=await getJlcPartsCached("power_sources",{voltage:sourceComponent.voltage,package:jlcpcbPackage});return{jlcpcb:withBasicPartPreference(power_sources).map(p2=>`C${p2.lcsc}`).slice(0,3)}}else if(sourceComponent.type==="source_component"&&sourceComponent.ftype==="simple_inductor"){let{inductors}=await getJlcPartsCached("inductors",{inductance:sourceComponent.inductance,package:jlcpcbPackage});return{jlcpcb:withBasicPartPreference(inductors).map(i3=>`C${i3.lcsc}`).slice(0,3)}}else if(sourceComponent.type==="source_component"&&sourceComponent.ftype==="simple_crystal"){let{crystals}=await getJlcPartsCached("crystals",{frequency:sourceComponent.frequency,load_capacitance:sourceComponent.load_capacitance,package:jlcpcbPackage});return{jlcpcb:withBasicPartPreference(crystals).map(c3=>`C${c3.lcsc}`).slice(0,3)}}else if(sourceComponent.type==="source_component"&&sourceComponent.ftype==="simple_mosfet"){let{mosfets}=await getJlcPartsCached("mosfets",{package:jlcpcbPackage,mosfet_mode:sourceComponent.mosfet_mode,channel_type:sourceComponent.channel_type});return{jlcpcb:withBasicPartPreference(mosfets).map(m3=>`C${m3.lcsc}`).slice(0,3)}}else if(sourceComponent.type==="source_component"&&sourceComponent.ftype==="simple_resonator"){let{resonators}=await getJlcPartsCached("resonators",{frequency:sourceComponent.frequency,package:jlcpcbPackage});return{jlcpcb:withBasicPartPreference(resonators).map(r4=>`C${r4.lcsc}`).slice(0,3)}}else if(sourceComponent.type==="source_component"&&sourceComponent.ftype==="simple_switch"){let{switches}=await getJlcPartsCached("switches",{switch_type:sourceComponent.type,package:jlcpcbPackage});return{jlcpcb:withBasicPartPreference(switches).map(s3=>`C${s3.lcsc}`).slice(0,3)}}else if(sourceComponent.type==="source_component"&&sourceComponent.ftype==="simple_led"){let{leds}=await getJlcPartsCached("leds",{package:jlcpcbPackage});return{jlcpcb:withBasicPartPreference(leds).map(l2=>`C${l2.lcsc}`).slice(0,3)}}else if(sourceComponent.type==="source_component"&&sourceComponent.ftype==="simple_fuse"){let{fuses}=await getJlcPartsCached("fuses",{package:jlcpcbPackage});return{jlcpcb:withBasicPartPreference(fuses).map(l2=>`C${l2.lcsc}`).slice(0,3)}}return{}}};var import_s_expression=__toESM(require_s_expression(),1);init_zod();var import_debug19=__toESM(require_browser(),1),import_debug20=__toESM(require_browser(),1),point22=external_exports.tuple([external_exports.coerce.number(),external_exports.coerce.number()]),point33=external_exports.tuple([external_exports.number(),external_exports.number(),external_exports.number()]),point5=external_exports.union([point22,point33]),fp_poly_arc_segment_def=external_exports.object({kind:external_exports.literal("arc"),start:point22,mid:point22,end:point22}),fp_poly_point_def=external_exports.union([point22,fp_poly_arc_segment_def]),attributes_def=external_exports.object({at:point5,size:point22,layer:external_exports.string(),layers:external_exports.array(external_exports.string()),roundrect_rratio:external_exports.number(),uuid:external_exports.string()}).partial(),property_def=external_exports.object({key:external_exports.string(),val:external_exports.string(),attributes:attributes_def}),drill_def=external_exports.object({oval:external_exports.boolean().default(!1),width:external_exports.number().optional(),height:external_exports.number().optional(),offset:point22.optional()}),hole_def=external_exports.object({name:external_exports.string(),pad_type:external_exports.enum(["thru_hole","smd","np_thru_hole","connect"]),pad_shape:external_exports.enum(["roundrect","circle","rect","oval","trapezoid","custom"]),at:point5,drill:external_exports.union([external_exports.number(),external_exports.array(external_exports.any()),drill_def]).transform(a2=>typeof a2=="number"?{oval:!1,width:a2,height:a2}:"oval"in a2?a2:a2.length===2?{oval:!1,width:Number.parseFloat(a2[0]),height:Number.parseFloat(a2[0]),offset:point22.parse(a2[1].slice(1))}:a2.length===3||a2.length===4?{oval:a2[0]==="oval",width:Number.parseFloat(a2[1]),height:Number.parseFloat(a2[2]),offset:a2[3]?point22.parse(a2[3].slice(1)):void 0}:a2).pipe(drill_def),size:external_exports.union([external_exports.array(external_exports.number()).length(2).transform(([w4,h2])=>({width:w4,height:h2})),external_exports.object({width:external_exports.number(),height:external_exports.number()})]),layers:external_exports.array(external_exports.string()).optional(),roundrect_rratio:external_exports.number().optional(),uuid:external_exports.string().optional()}),pad_def2=external_exports.object({name:external_exports.string(),pad_type:external_exports.enum(["thru_hole","smd","np_thru_hole","connect"]),pad_shape:external_exports.enum(["roundrect","circle","rect","oval","trapezoid","custom"]),at:point5,size:point22,drill:external_exports.union([external_exports.number(),external_exports.array(external_exports.any()),drill_def]).transform(a2=>typeof a2=="number"?{oval:!1,width:a2,height:a2}:"oval"in a2?a2:a2.length===2?{oval:!1,width:Number.parseFloat(a2[0]),height:Number.parseFloat(a2[0]),offset:point22.parse(a2[1].slice(1))}:a2.length===3||a2.length===4?{oval:a2[0]==="oval",width:Number.parseFloat(a2[1]),height:Number.parseFloat(a2[2]),offset:a2[3]?point22.parse(a2[3].slice(1)):void 0}:a2).pipe(drill_def).optional(),layers:external_exports.array(external_exports.string()).optional(),roundrect_rratio:external_exports.number().optional(),chamfer_ratio:external_exports.number().optional(),solder_paste_margin:external_exports.number().optional(),solder_paste_margin_ratio:external_exports.number().optional(),clearance:external_exports.number().optional(),zone_connection:external_exports.union([external_exports.literal(0).describe("Pad is not connect to zone"),external_exports.literal(1).describe("Pad is connected to zone using thermal relief"),external_exports.literal(2).describe("Pad is connected to zone using solid fill")]).optional(),thermal_width:external_exports.number().optional(),thermal_gap:external_exports.number().optional(),uuid:external_exports.string().optional()}),effects_def=external_exports.object({font:external_exports.object({size:point22,thickness:external_exports.number().optional()})}).partial(),fp_text_def=external_exports.object({fp_text_type:external_exports.literal("user"),text:external_exports.string(),at:point5,layer:external_exports.string(),uuid:external_exports.string().optional(),effects:effects_def.partial()}),fp_arc_def=external_exports.object({start:point22,mid:point22,end:point22,stroke:external_exports.object({width:external_exports.number(),type:external_exports.string()}),layer:external_exports.string(),uuid:external_exports.string().optional()}),fp_circle_def=external_exports.object({center:point22,end:point22,stroke:external_exports.object({width:external_exports.number(),type:external_exports.string()}),fill:external_exports.string().optional(),layer:external_exports.string(),uuid:external_exports.string().optional()}),fp_poly_def=external_exports.object({pts:external_exports.array(fp_poly_point_def),stroke:external_exports.object({width:external_exports.number(),type:external_exports.string()}).optional(),width:external_exports.number().optional(),layer:external_exports.string(),uuid:external_exports.string().optional(),fill:external_exports.string().optional()}).transform(data=>({...data,width:void 0,stroke:data.stroke??{width:data.width}})),fp_line=external_exports.object({start:point22,end:point22,stroke:external_exports.object({width:external_exports.number(),type:external_exports.string()}).optional(),width:external_exports.number().optional(),layer:external_exports.string(),uuid:external_exports.string().optional()}).transform(data=>({...data,width:void 0,stroke:data.stroke??{width:data.width}})),kicad_mod_json_def=external_exports.object({footprint_name:external_exports.string(),version:external_exports.string().optional(),generator:external_exports.string().optional(),generator_version:external_exports.string().optional(),layer:external_exports.string(),descr:external_exports.string().default(""),tags:external_exports.array(external_exports.string()).optional(),properties:external_exports.array(property_def),fp_lines:external_exports.array(fp_line),fp_texts:external_exports.array(fp_text_def),fp_arcs:external_exports.array(fp_arc_def),fp_circles:external_exports.array(fp_circle_def).optional(),fp_polys:external_exports.array(fp_poly_def).optional(),pads:external_exports.array(pad_def2),holes:external_exports.array(hole_def).optional()}),formatAttr=(val,attrKey)=>{if(attrKey==="effects"&&Array.isArray(val)){let effectsObj={};for(let elm of val)if(elm[0]==="font"){let fontObj={};for(let fontElm of elm.slice(1))fontElm.length===2?fontObj[fontElm[0].valueOf()]=Number.parseFloat(fontElm[1].valueOf()):fontObj[fontElm[0].valueOf()]=fontElm.slice(1).map(n3=>Number.parseFloat(n3.valueOf()));effectsObj.font=fontObj}return effects_def.parse(effectsObj)}if(attrKey==="pts")return val.map(segment2=>{let segmentType=segment2[0]?.valueOf?.()??segment2[0];if(segmentType==="xy")return segment2.slice(1).map(n3=>Number.parseFloat(n3.valueOf()));if(segmentType==="arc"){let arcObj={kind:"arc"};for(let arcAttr of segment2.slice(1)){let key=arcAttr[0].valueOf();arcObj[key]=arcAttr.slice(1).map(n3=>Number.parseFloat(n3.valueOf()))}return arcObj}return segment2});if(attrKey==="stroke"){let strokeObj={};for(let strokeElm of val){let strokePropKey=strokeElm[0].valueOf();strokeObj[strokePropKey]=formatAttr(strokeElm.slice(1),strokePropKey)}return strokeObj}return attrKey==="at"||attrKey==="size"||attrKey==="start"||attrKey==="mid"||attrKey==="end"?(Array.isArray(val)?val:[val]).map(n3=>n3?.valueOf?.()??n3).filter(v4=>typeof v4=="number"||typeof v4=="string"&&/^[-+]?\d*\.?\d+(e[-+]?\d+)?$/i.test(v4)).map(v4=>typeof v4=="number"?v4:Number.parseFloat(v4)):attrKey==="tags"?val.map(n3=>n3.valueOf()):attrKey==="generator_version"||attrKey==="version"?val[0].valueOf():val.length===2?val.valueOf():attrKey==="uuid"?Array.isArray(val)?val[0].valueOf():val.valueOf():/^[\d\.]+$/.test(val)&&!Number.isNaN(Number.parseFloat(val))?Number.parseFloat(val):Array.isArray(val)&&val.length===1?val[0].valueOf():Array.isArray(val)?val.map(s3=>s3.valueOf()):val},getAttr=(s3,key)=>{for(let elm of s3)if(Array.isArray(elm)&&elm[0]===key)return formatAttr(elm.slice(1),key)},debug11=(0,import_debug19.default)("kicad-mod-converter"),parseKicadModToKicadJson=fileContent=>{let kicadSExpr=(0,import_s_expression.default)(fileContent),footprintName=kicadSExpr[1].valueOf(),topLevelAttributes={},simpleTopLevelAttributes=Object.entries(kicad_mod_json_def.shape).filter(([attributeKey,def])=>def._def.typeName==="ZodString"||attributeKey==="tags").map(([attributeKey])=>attributeKey);for(let kicadSExprRow of kicadSExpr.slice(2)){if(!simpleTopLevelAttributes.includes(kicadSExprRow[0]))continue;let key=kicadSExprRow[0].valueOf(),val=formatAttr(kicadSExprRow.slice(1),key);topLevelAttributes[key]=val}let properties=kicadSExpr.slice(2).filter(row=>row[0]==="property").map(row=>{let key=row[1].valueOf(),val=row[2].valueOf(),attributes2=attributes_def.parse(row.slice(3).reduce((acc,attrAr)=>{let attrKey=attrAr[0].valueOf();return acc[attrKey]=formatAttr(attrAr.slice(1),attrKey),acc},{}));return{key,val,attributes:attributes2}}),padRows=kicadSExpr.slice(2).filter(row=>row[0]==="pad"),pads=[];for(let row of padRows){let at3=getAttr(row,"at"),size2=getAttr(row,"size"),drill=getAttr(row,"drill"),layers=getAttr(row,"layers");if(Array.isArray(layers)?layers=layers.map(layer=>layer.valueOf()):typeof layers=="string"?layers=[layers]:layers||(layers=[]),!layers.includes("F.Cu")){debug11(`Skipping pad without F.Cu layer: layers=${layers.join(", ")}`);continue}let roundrect_rratio=getAttr(row,"roundrect_rratio"),uuid=getAttr(row,"uuid"),padRaw={name:row[1].valueOf(),pad_type:row[2].valueOf(),pad_shape:row[3].valueOf(),at:at3,drill,size:size2,layers,roundrect_rratio,uuid};debug11(`attempting to parse pad: ${JSON.stringify(padRaw,null," ")}`),pads.push(pad_def2.parse(padRaw))}let fp_texts_rows=kicadSExpr.slice(2).filter(row=>row[0]==="fp_text"),fp_texts=[];for(let fp_text_row of fp_texts_rows){let text=fp_text_row[2].valueOf(),at3=getAttr(fp_text_row,"at"),layer=getAttr(fp_text_row,"layer"),uuid=getAttr(fp_text_row,"uuid"),effects=getAttr(fp_text_row,"effects");fp_texts.push({fp_text_type:"user",text,at:at3,layer,uuid,effects})}let fp_lines=[],fp_lines_rows=kicadSExpr.slice(2).filter(row=>row[0]==="fp_line");for(let fp_line_row of fp_lines_rows){let start=getAttr(fp_line_row,"start"),end=getAttr(fp_line_row,"end"),stroke=getAttr(fp_line_row,"stroke"),layer=getAttr(fp_line_row,"layer"),uuid=getAttr(fp_line_row,"uuid");fp_lines.push({start,end,stroke,layer,uuid})}let fp_arcs=[],fp_arcs_rows=kicadSExpr.slice(2).filter(row=>row[0]==="fp_arc");for(let fp_arc_row of fp_arcs_rows){let start=getAttr(fp_arc_row,"start"),mid=getAttr(fp_arc_row,"mid"),end=getAttr(fp_arc_row,"end"),stroke=getAttr(fp_arc_row,"stroke"),layer=getAttr(fp_arc_row,"layer"),uuid=getAttr(fp_arc_row,"uuid");!start||!end||!mid||!stroke||!layer||fp_arcs.push({start,mid,end,stroke,layer,uuid})}let fp_circles=[],fp_circles_rows=kicadSExpr.slice(2).filter(row=>row[0]==="fp_circle");for(let fp_circle_row of fp_circles_rows){let center2=getAttr(fp_circle_row,"center"),end=getAttr(fp_circle_row,"end"),stroke=getAttr(fp_circle_row,"stroke"),fill=getAttr(fp_circle_row,"fill"),layer=getAttr(fp_circle_row,"layer"),uuid=getAttr(fp_circle_row,"uuid");!center2||!end||!stroke||!layer||fp_circles.push({center:center2,end,stroke,fill,layer,uuid})}let fp_polys=[],fp_polys_rows=kicadSExpr.slice(2).filter(row=>row[0]==="fp_poly");for(let fp_poly_row of fp_polys_rows){let pts=getAttr(fp_poly_row,"pts"),stroke=getAttr(fp_poly_row,"stroke"),width=getAttr(fp_poly_row,"width"),layer=getAttr(fp_poly_row,"layer"),uuid=getAttr(fp_poly_row,"uuid"),fill=getAttr(fp_poly_row,"fill"),normalizedStroke=stroke;!normalizedStroke&&typeof width=="number"?normalizedStroke={width,type:"solid"}:normalizedStroke&&typeof normalizedStroke=="object"&&typeof width=="number"&&normalizedStroke.width===void 0&&(normalizedStroke={...normalizedStroke,width}),fp_polys.push({pts,stroke:normalizedStroke,layer,uuid,fill})}let holes=[];for(let row of kicadSExpr.slice(2)){if(row[0]!=="pad"||row[2]?.valueOf?.()!=="thru_hole")continue;let name=row[1]?.valueOf?.(),pad_type=row[2]?.valueOf?.(),pad_shape=row[3]?.valueOf?.(),at3=getAttr(row,"at"),drill=getAttr(row,"drill"),size2=getAttr(row,"size");Array.isArray(size2)&&(size2[0]==="size"&&(size2=size2.slice(1)),size2={width:Number(size2[0]),height:Number(size2[1])});let uuid=getAttr(row,"uuid"),roundrect_rratio=getAttr(row,"roundrect_rratio"),layers=getAttr(row,"layers");Array.isArray(layers)?layers=layers.map(layer=>layer.valueOf()):typeof layers=="string"?layers=[layers]:layers||(layers=[]);let holeRaw={name,pad_type,pad_shape,at:at3,drill,size:size2,layers,roundrect_rratio,uuid};debug11(`attempting to parse holes: ${JSON.stringify(holeRaw,null,2)}`),holes.push(hole_def.parse(holeRaw))}return kicad_mod_json_def.parse({footprint_name:footprintName,...topLevelAttributes,properties,fp_lines,fp_texts,fp_arcs,fp_circles,pads,holes,fp_polys})},TWO_PI=Math.PI*2,normalizeAngle2=angle=>{let result=angle%TWO_PI;return result<0&&(result+=TWO_PI),result},directedAngleCCW=(start,target)=>{let startNorm=normalizeAngle2(start),delta=normalizeAngle2(target)-startNorm;return delta<0&&(delta+=TWO_PI),delta};function calculateCenter(start,mid,end){let mid1={x:(start.x+mid.x)/2,y:(start.y+mid.y)/2},mid2={x:(mid.x+end.x)/2,y:(mid.y+end.y)/2},slope1=-(start.x-mid.x)/(start.y-mid.y),slope2=-(mid.x-end.x)/(mid.y-end.y),centerX=(mid1.y-mid2.y+slope2*mid2.x-slope1*mid1.x)/(slope2-slope1),centerY=mid1.y+slope1*(centerX-mid1.x);return{x:centerX,y:centerY}}function calculateRadius(center2,point42){return Math.sqrt((center2.x-point42.x)**2+(center2.y-point42.y)**2)}function calculateAngle(center2,point42){return Math.atan2(point42.y-center2.y,point42.x-center2.x)}var getArcLength=(start,mid,end)=>{let center2=calculateCenter(start,mid,end),radius=calculateRadius(center2,start),angleStart=calculateAngle(center2,start),angleMid=calculateAngle(center2,mid),angleEnd=calculateAngle(center2,end),ccwToMid=directedAngleCCW(angleStart,angleMid),ccwToEnd=directedAngleCCW(angleStart,angleEnd),angleDelta=ccwToEnd;return ccwToMid>ccwToEnd&&(angleDelta=ccwToEnd-TWO_PI),Math.abs(radius*angleDelta)};function generateArcPath(start,mid,end,numPoints){let center2=calculateCenter(start,mid,end),radius=calculateRadius(center2,start),angleStart=calculateAngle(center2,start),angleMid=calculateAngle(center2,mid),angleEnd=calculateAngle(center2,end),ccwToMid=directedAngleCCW(angleStart,angleMid),ccwToEnd=directedAngleCCW(angleStart,angleEnd),angleDelta=ccwToEnd;ccwToMid>ccwToEnd&&(angleDelta=ccwToEnd-TWO_PI);let path=[];for(let i3=0;i3<=numPoints;i3++){let angle=angleStart+i3/numPoints*angleDelta,x3=center2.x+radius*Math.cos(angle),y3=center2.y+radius*Math.sin(angle);path.push({x:x3,y:y3})}return path}var makePoint=p2=>Array.isArray(p2)?{x:p2[0],y:p2[1]}:p2,pointsEqual=(p12,p2,tolerance=1e-4)=>Math.abs(p12.x-p2.x)<tolerance&&Math.abs(p12.y-p2.y)<tolerance,findClosedPolygons=segments=>{let polygons=[],used=new Set;for(let i3=0;i3<segments.length;i3++){if(used.has(i3))continue;let polygon2=[segments[i3]];used.add(i3);let currentEnd=segments[i3].end,foundNext=!0;for(;foundNext;){if(foundNext=!1,polygon2.length>1&&pointsEqual(currentEnd,polygon2[0].start)){polygons.push(polygon2);break}for(let j3=0;j3<segments.length;j3++)if(!used.has(j3)){if(pointsEqual(currentEnd,segments[j3].start)){polygon2.push(segments[j3]),used.add(j3),currentEnd=segments[j3].end,foundNext=!0;break}else if(pointsEqual(currentEnd,segments[j3].end)){segments[j3].type==="arc"?polygon2.push({...segments[j3],reversed:!0}):polygon2.push({...segments[j3],start:segments[j3].end,end:segments[j3].start}),used.add(j3),currentEnd=segments[j3].start,foundNext=!0;break}}if(!foundNext){for(let k4=polygon2.length-1;k4>=0;k4--){let idx=segments.indexOf(polygon2[k4]);idx!==-1&&used.delete(idx)}break}}}return polygons},polygonToPoints=polygon2=>{let points=[];for(let segment2 of polygon2)if(segment2.type==="line")points.push(segment2.start);else if(segment2.type==="arc"&&segment2.mid){let arcLength=getArcLength(segment2.start,segment2.mid,segment2.end),numPoints=Math.max(3,Math.ceil(arcLength)),arcPoints=generateArcPath(segment2.start,segment2.mid,segment2.end,numPoints);segment2.reversed&&(arcPoints=arcPoints.reverse()),points.push(...arcPoints.slice(0,-1))}return points};function getSilkscreenFontSizeFromFpTexts(fp_texts){if(!Array.isArray(fp_texts))return null;let refText=fp_texts.find(t5=>t5.layer?.toLowerCase()==="f.silks"&&(t5.text?.includes("${REFERENCE}")||t5.fp_text_type?.toLowerCase()==="reference"||t5.text?.match(/^R\d+|C\d+|U\d+/))),fallbackText=refText||fp_texts.find(t5=>t5.layer?.toLowerCase()==="f.fab"&&(t5.text?.includes("${REFERENCE}")||t5.fp_text_type?.toLowerCase()==="reference")),target=refText||fallbackText;if(!target?.effects?.font?.size)return null;let[width,height]=target.effects.font.size;return height??width??1}var degToRad=deg=>deg*Math.PI/180,rotatePoint3=(x3,y3,deg)=>{let r4=degToRad(deg),cos4=Math.cos(r4),sin4=Math.sin(r4);return{x:x3*cos4-y3*sin4,y:x3*sin4+y3*cos4}},getAxisAlignedRectFromPoints=points=>{let uniquePoints=[...new Map(points.map(p2=>[`${p2.x},${p2.y}`,p2])).values()];if(uniquePoints.length!==4)return null;let xs3=uniquePoints.map(p2=>p2.x),ys3=uniquePoints.map(p2=>p2.y),uniqueXs=[...new Set(xs3)],uniqueYs=[...new Set(ys3)];if(uniqueXs.length!==2||uniqueYs.length!==2)return null;let[minX,maxX]=uniqueXs.sort((a2,b3)=>a2-b3),[minY,maxY]=uniqueYs.sort((a2,b3)=>a2-b3);return minX===void 0||maxX===void 0||minY===void 0||maxY===void 0?null:{x:(minX+maxX)/2,y:(minY+maxY)/2,width:maxX-minX,height:maxY-minY}},fpPolyHasFill=fill=>{if(!fill)return!1;let normalized=fill.toLowerCase();return normalized!=="no"&&normalized!=="none"&&normalized!=="outline"},getRotationDeg=at3=>at3&&Array.isArray(at3)&&at3.length>=3&&typeof at3[2]=="number"?at3[2]:0,isNinetyLike=deg=>{let n3=(deg%360+360)%360;return n3===90||n3===270},normalizePortName=name=>{if(name!=null)return`${name}`},getPinNumber=name=>{let normalized=normalizePortName(name),parsed=normalized!==void 0?Number(normalized):NaN;return Number.isFinite(parsed)?parsed:void 0},debug23=(0,import_debug20.default)("kicad-mod-converter"),convertKicadLayerToTscircuitLayer=kicadLayer=>{switch(kicadLayer.toLowerCase()){case"f.cu":case"f.fab":case"f.silks":case"edge.cuts":return"top";case"b.cu":case"b.fab":case"b.silks":return"bottom"}},convertKicadJsonToTsCircuitSoup=async kicadJson=>{let{fp_lines,fp_texts,fp_arcs,fp_circles,pads,properties,holes,fp_polys}=kicadJson,circuitJson=[];circuitJson.push({type:"source_component",source_component_id:"source_component_0",supplier_part_numbers:{}}),circuitJson.push({type:"schematic_component",schematic_component_id:"schematic_component_0",source_component_id:"source_component_0",center:{x:0,y:0},rotation:0,size:{width:0,height:0}});let portNames=new Set,portNameToPinNumber=new Map;for(let pad2 of pads){let portName=normalizePortName(pad2.name);if(portName){portNames.add(portName);let pinNumber=getPinNumber(pad2.name);pinNumber!==void 0&&portNameToPinNumber.set(portName,pinNumber)}}if(holes)for(let hole of holes){let portName=normalizePortName(hole.name);if(portName){portNames.add(portName);let pinNumber=getPinNumber(hole.name);pinNumber!==void 0&&portNameToPinNumber.set(portName,pinNumber)}}let sourcePortId=0,portNameToSourcePortId=new Map;for(let portName of portNames){let source_port_id=`source_port_${sourcePortId++}`;portNameToSourcePortId.set(portName,source_port_id);let pinNumber=portNameToPinNumber.get(portName);circuitJson.push({type:"source_port",source_port_id,source_component_id:"source_component_0",name:portName,port_hints:[portName],pin_number:pinNumber,pin_label:pinNumber!==void 0?`pin${pinNumber}`:void 0}),circuitJson.push({type:"schematic_port",schematic_port_id:`schematic_port_${sourcePortId++}`,source_port_id,schematic_component_id:"schematic_component_0",center:{x:0,y:0}})}let minX=Number.POSITIVE_INFINITY,maxX=Number.NEGATIVE_INFINITY,minY=Number.POSITIVE_INFINITY,maxY=Number.NEGATIVE_INFINITY;for(let pad2 of pads){let x3=pad2.at[0],y3=-pad2.at[1],w4=pad2.size[0],h2=pad2.size[1];minX=Math.min(minX,x3-w4/2),maxX=Math.max(maxX,x3+w4/2),minY=Math.min(minY,y3-h2/2),maxY=Math.max(maxY,y3+h2/2)}let pcb_component_id="pcb_component_0";circuitJson.push({type:"pcb_component",source_component_id:"source_component_0",pcb_component_id,layer:"top",center:{x:0,y:0},rotation:0,width:Number.isFinite(minX)?maxX-minX:0,height:Number.isFinite(minY)?maxY-minY:0});let pcbPortId=0,portNameToPcbPortId=new Map;for(let portName of portNames){let pcb_port_id=`pcb_port_${pcbPortId++}`,source_port_id=portNameToSourcePortId.get(portName);portNameToPcbPortId.set(portName,pcb_port_id);let x3=0,y3=0,layers=["top","bottom"],pad2=pads.find(p2=>normalizePortName(p2.name)===portName);if(pad2)x3=pad2.at[0],y3=-pad2.at[1],layers=pad2.layers?pad2.layers.map(l2=>convertKicadLayerToTscircuitLayer(l2)).filter(Boolean):["top","bottom"];else if(holes){let hole=holes.find(h2=>normalizePortName(h2.name)===portName);hole&&(x3=hole.at[0],y3=-hole.at[1],layers=hole.layers?hole.layers.map(l2=>convertKicadLayerToTscircuitLayer(l2)).filter(Boolean):["top","bottom"])}circuitJson.push({type:"pcb_port",pcb_port_id,source_port_id,pcb_component_id,x:x3,y:y3,layers})}let smtpadId=0,platedHoleId=0,holeId=0;for(let pad2 of pads){let portName=normalizePortName(pad2.name),pinNumber=portName?portNameToPinNumber.get(portName):void 0;if(pad2.pad_type==="smd"){let rotation4=getRotationDeg(pad2.at),width=isNinetyLike(rotation4)?pad2.size[1]:pad2.size[0],height=isNinetyLike(rotation4)?pad2.size[0]:pad2.size[1],pcb_port_id=portName?portNameToPcbPortId.get(portName):void 0,pinLabel=pinNumber!==void 0?`pin${pinNumber}`:void 0;circuitJson.push({type:"pcb_smtpad",pcb_smtpad_id:`pcb_smtpad_${smtpadId++}`,shape:"rect",x:pad2.at[0],y:-pad2.at[1],width,height,layer:convertKicadLayerToTscircuitLayer(pad2.layers?.[0]??"F.Cu"),pcb_component_id,port_hints:pinLabel?[pinLabel]:portName?[portName]:[],pcb_port_id,pin_number:pinNumber,pin_label:pinLabel})}else if(pad2.pad_type==="thru_hole"){if(pad2.pad_shape==="rect"){let rotation4=getRotationDeg(pad2.at),width=isNinetyLike(rotation4)?pad2.size[1]:pad2.size[0],height=isNinetyLike(rotation4)?pad2.size[0]:pad2.size[1],offX=pad2.drill?.offset?.[0]??0,offY=pad2.drill?.offset?.[1]??0,rotOff=rotatePoint3(offX,offY,rotation4),pcb_port_id=portName?portNameToPcbPortId.get(portName):void 0,pinLabel=pinNumber!==void 0?`pin${pinNumber}`:void 0;circuitJson.push({type:"pcb_plated_hole",pcb_plated_hole_id:`pcb_plated_hole_${platedHoleId++}`,shape:"circular_hole_with_rect_pad",hole_shape:"circle",pad_shape:"rect",x:pad2.at[0],y:-pad2.at[1],hole_offset_x:-rotOff.x,hole_offset_y:-rotOff.y,hole_diameter:pad2.drill?.width,rect_pad_width:width,rect_pad_height:height,layers:["top","bottom"],pcb_component_id,port_hints:pinLabel?[pinLabel]:portName?[portName]:[],pcb_port_id,pin_number:pinNumber,pin_label:pinLabel})}else if(pad2.pad_shape==="circle"){let pcb_port_id=portName?portNameToPcbPortId.get(portName):void 0,pinLabel=pinNumber!==void 0?`pin${pinNumber}`:void 0;circuitJson.push({type:"pcb_plated_hole",pcb_plated_hole_id:`pcb_plated_hole_${platedHoleId++}`,shape:"circle",x:pad2.at[0],y:-pad2.at[1],outer_diameter:pad2.size[0],hole_diameter:pad2.drill?.width,layers:["top","bottom"],pcb_component_id,port_hints:pinLabel?[pinLabel]:portName?[portName]:[],pcb_port_id,pin_number:pinNumber,pin_label:pinLabel})}else if(pad2.pad_shape==="oval"){let pcb_port_id=portName?portNameToPcbPortId.get(portName):void 0,pinLabel=pinNumber!==void 0?`pin${pinNumber}`:void 0;circuitJson.push({type:"pcb_plated_hole",pcb_plated_hole_id:`pcb_plated_hole_${platedHoleId++}`,shape:"pill",x:pad2.at[0],y:-pad2.at[1],outer_width:pad2.size[0],outer_height:pad2.size[1],hole_width:pad2.drill?.width,hole_height:pad2.drill?.height,layers:["top","bottom"],pcb_component_id,port_hints:pinLabel?[pinLabel]:portName?[portName]:[],pcb_port_id,pin_number:pinNumber,pin_label:pinLabel})}}else pad2.pad_type==="np_thru_hole"&&circuitJson.push({type:"pcb_hole",pcb_hole_id:`pcb_hole_${holeId++}`,x:pad2.at[0],y:-pad2.at[1],hole_diameter:pad2.drill?.width,pcb_component_id})}if(holes)for(let hole of holes){let portName=normalizePortName(hole.name),pinNumber=portName?portNameToPinNumber.get(portName):void 0,hasCuLayer=hole.layers?.some(l2=>l2.endsWith(".Cu")||l2==="*.Cu"),rotation4=getRotationDeg(hole.at),offX=hole.drill?.offset?.[0]??0,offY=hole.drill?.offset?.[1]??0,rotOff=rotatePoint3(offX,offY,rotation4),x3=hole.at[0]+rotOff.x,y3=-(hole.at[1]+rotOff.y),holeDiameter=hole.drill?.width??0,outerDiameter=hole.size?.width??holeDiameter,rr3=hole.roundrect_rratio??0,rectBorderRadius=rr3>0?Math.min(isNinetyLike(rotation4)?hole.size?.height??outerDiameter:hole.size?.width??outerDiameter,isNinetyLike(rotation4)?hole.size?.width??outerDiameter:hole.size?.height??outerDiameter)/2*rr3:0;if(hasCuLayer)if(hole.pad_shape==="rect"){let pcb_port_id=portName?portNameToPcbPortId.get(portName):void 0;circuitJson.push({type:"pcb_plated_hole",pcb_plated_hole_id:`pcb_plated_hole_${platedHoleId++}`,shape:"circular_hole_with_rect_pad",hole_shape:"circle",pad_shape:"rect",x:hole.at[0],y:-hole.at[1],hole_offset_x:-rotOff.x,hole_offset_y:-rotOff.y,hole_diameter:holeDiameter,rect_pad_width:isNinetyLike(rotation4)?hole.size?.height??outerDiameter:hole.size?.width??outerDiameter,rect_pad_height:isNinetyLike(rotation4)?hole.size?.width??outerDiameter:hole.size?.height??outerDiameter,rect_border_radius:rectBorderRadius,port_hints:pinNumber!==void 0?[`pin${pinNumber}`]:portName?[portName]:[],layers:["top","bottom"],pcb_component_id,pcb_port_id,pin_number:pinNumber,pin_label:pinNumber!==void 0?`pin${pinNumber}`:void 0})}else if(hole.pad_shape==="oval"){let pcb_port_id=portName?portNameToPcbPortId.get(portName):void 0;circuitJson.push({type:"pcb_plated_hole",pcb_plated_hole_id:`pcb_plated_hole_${platedHoleId++}`,shape:"pill",x:x3,y:y3,outer_width:isNinetyLike(rotation4)?hole.size?.height??outerDiameter:hole.size?.width??outerDiameter,outer_height:isNinetyLike(rotation4)?hole.size?.width??outerDiameter:hole.size?.height??outerDiameter,hole_width:isNinetyLike(rotation4)?hole.drill?.height??holeDiameter:hole.drill?.width??holeDiameter,hole_height:isNinetyLike(rotation4)?hole.drill?.width??holeDiameter:hole.drill?.height??holeDiameter,port_hints:pinNumber!==void 0?[`pin${pinNumber}`]:portName?[portName]:[],layers:["top","bottom"],pcb_component_id,pcb_port_id,pin_number:pinNumber,pin_label:pinNumber!==void 0?`pin${pinNumber}`:void 0})}else if(hole.pad_shape==="roundrect"){let pcb_port_id=portName?portNameToPcbPortId.get(portName):void 0,offX2=hole.drill?.offset?.[0]??0,offY2=hole.drill?.offset?.[1]??0,rotOff2=rotatePoint3(offX2,offY2,rotation4),width=isNinetyLike(rotation4)?hole.size?.height??outerDiameter:hole.size?.width??outerDiameter,height=isNinetyLike(rotation4)?hole.size?.width??outerDiameter:hole.size?.height??outerDiameter;circuitJson.push({type:"pcb_plated_hole",pcb_plated_hole_id:`pcb_plated_hole_${platedHoleId++}`,shape:"circular_hole_with_rect_pad",hole_shape:"circle",pad_shape:"rect",x:x3,y:y3,hole_offset_x:-rotOff2.x,hole_offset_y:rotOff2.y,hole_diameter:holeDiameter,rect_pad_width:width,rect_pad_height:height,rect_border_radius:rectBorderRadius,port_hints:pinNumber!==void 0?[`pin${pinNumber}`]:portName?[portName]:[],layers:["top","bottom"],pcb_component_id,pcb_port_id,pin_number:pinNumber,pin_label:pinNumber!==void 0?`pin${pinNumber}`:void 0})}else{let pcb_port_id=portName?portNameToPcbPortId.get(portName):void 0;circuitJson.push({type:"pcb_plated_hole",pcb_plated_hole_id:`pcb_plated_hole_${platedHoleId++}`,shape:"circle",x:x3,y:y3,outer_diameter:outerDiameter,hole_diameter:holeDiameter,port_hints:pinNumber!==void 0?[`pin${pinNumber}`]:portName?[portName]:[],layers:["top","bottom"],pcb_component_id,pcb_port_id,pin_number:pinNumber,pin_label:pinNumber!==void 0?`pin${pinNumber}`:void 0})}else circuitJson.push({type:"pcb_hole",pcb_hole_id:`pcb_hole_${holeId++}`,x:x3,y:y3,hole_diameter:outerDiameter,hole_shape:"circle",pcb_component_id})}let edgeCutSegments=[];for(let fp_line2 of fp_lines)fp_line2.layer.toLowerCase()==="edge.cuts"&&edgeCutSegments.push({type:"line",start:{x:fp_line2.start[0],y:fp_line2.start[1]},end:{x:fp_line2.end[0],y:fp_line2.end[1]},strokeWidth:fp_line2.stroke.width});for(let fp_arc of fp_arcs)fp_arc.layer.toLowerCase()==="edge.cuts"&&edgeCutSegments.push({type:"arc",start:{x:fp_arc.start[0],y:fp_arc.start[1]},mid:{x:fp_arc.mid[0],y:fp_arc.mid[1]},end:{x:fp_arc.end[0],y:fp_arc.end[1]},strokeWidth:fp_arc.stroke.width});let closedPolygons=findClosedPolygons(edgeCutSegments),cutoutId=0;for(let polygon2 of closedPolygons){let points=polygonToPoints(polygon2);points.length>=3&&circuitJson.push({type:"pcb_cutout",pcb_cutout_id:`pcb_cutout_${cutoutId++}`,shape:"polygon",points:points.map(p2=>({x:p2.x,y:-p2.y})),pcb_component_id})}let traceId=0,silkPathId=0,fabPathId=0,noteLineId=0;for(let fp_line2 of fp_lines){let route=[{x:fp_line2.start[0],y:-fp_line2.start[1]},{x:fp_line2.end[0],y:-fp_line2.end[1]}],lowerLayer=fp_line2.layer.toLowerCase();lowerLayer==="f.cu"?circuitJson.push({type:"pcb_trace",pcb_trace_id:`pcb_trace_${traceId++}`,pcb_component_id,layer:convertKicadLayerToTscircuitLayer(fp_line2.layer),route,thickness:fp_line2.stroke.width}):lowerLayer==="f.silks"?circuitJson.push({type:"pcb_silkscreen_path",pcb_silkscreen_path_id:`pcb_silkscreen_path_${silkPathId++}`,pcb_component_id,layer:"top",route,stroke_width:fp_line2.stroke.width}):lowerLayer==="edge.cuts"?debug23("Skipping Edge.Cuts fp_line (converted to pcb_cutout)",fp_line2.layer):lowerLayer==="f.fab"?circuitJson.push({type:"pcb_fabrication_note_path",fabrication_note_path_id:`fabrication_note_path_${fabPathId++}`,pcb_component_id,layer:"top",route,stroke_width:fp_line2.stroke.width,port_hints:[]}):lowerLayer.startsWith("user.")?circuitJson.push({type:"pcb_note_line",pcb_note_line_id:`pcb_note_line_${noteLineId++}`,pcb_component_id,x1:fp_line2.start[0],y1:-fp_line2.start[1],x2:fp_line2.end[0],y2:-fp_line2.end[1],stroke_width:fp_line2.stroke.width}):debug23("Unhandled layer for fp_line",fp_line2.layer)}if(fp_polys)for(let fp_poly of fp_polys){let route=[],pushRoutePoint=point42=>{!Number.isFinite(point42.x)||!Number.isFinite(point42.y)||route.push(point42)};for(let segment2 of fp_poly.pts){if(Array.isArray(segment2)){pushRoutePoint({x:segment2[0],y:-segment2[1]});continue}if(segment2&&typeof segment2=="object"&&"kind"in segment2){if(segment2.kind==="arc"){let start=makePoint(segment2.start),mid=makePoint(segment2.mid),end=makePoint(segment2.end),arcLength=getArcLength(start,mid,end),numPoints=Math.max(8,Math.ceil(arcLength)),adjustedNumPoints=Math.max(2,Math.ceil(arcLength/.1)),arcPoints=generateArcPath(start,mid,end,adjustedNumPoints).map(p2=>({x:p2.x,y:-p2.y}));for(let point42 of arcPoints)pushRoutePoint(point42)}continue}}let routePoints=route,polygonPoints=routePoints.length>2&&routePoints[0].x===routePoints[routePoints.length-1].x&&routePoints[0].y===routePoints[routePoints.length-1].y?routePoints.slice(0,-1):routePoints;if(routePoints.length===0)continue;let strokeWidth=fp_poly.stroke?.width??0;if(fp_poly.layer.endsWith(".Cu")){let rect=getAxisAlignedRectFromPoints(polygonPoints);rect?circuitJson.push({type:"pcb_smtpad",pcb_smtpad_id:`pcb_smtpad_${smtpadId++}`,shape:"rect",x:rect.x,y:rect.y,width:rect.width,height:rect.height,layer:convertKicadLayerToTscircuitLayer(fp_poly.layer),pcb_component_id}):fpPolyHasFill(fp_poly.fill)?polygonPoints.length>=3?circuitJson.push({type:"pcb_smtpad",pcb_smtpad_id:`pcb_smtpad_${smtpadId++}`,shape:"polygon",points:polygonPoints,layer:convertKicadLayerToTscircuitLayer(fp_poly.layer),pcb_component_id}):polygonPoints.length>=2&&circuitJson.push({type:"pcb_trace",pcb_trace_id:`pcb_trace_${traceId++}`,pcb_component_id,layer:convertKicadLayerToTscircuitLayer(fp_poly.layer),route:polygonPoints,thickness:strokeWidth}):polygonPoints.length>=2&&circuitJson.push({type:"pcb_trace",pcb_trace_id:`pcb_trace_${traceId++}`,pcb_component_id,layer:convertKicadLayerToTscircuitLayer(fp_poly.layer),route:polygonPoints,thickness:strokeWidth})}else fp_poly.layer.endsWith(".SilkS")?circuitJson.push({type:"pcb_silkscreen_path",pcb_silkscreen_path_id:`pcb_silkscreen_path_${silkPathId++}`,pcb_component_id,layer:convertKicadLayerToTscircuitLayer(fp_poly.layer),route:routePoints,stroke_width:strokeWidth}):fp_poly.layer.endsWith(".Fab")?circuitJson.push({type:"pcb_fabrication_note_path",fabrication_note_path_id:`fabrication_note_path_${fabPathId++}`,pcb_component_id,layer:convertKicadLayerToTscircuitLayer(fp_poly.layer),route:polygonPoints,stroke_width:strokeWidth,port_hints:[]}):debug23("Unhandled layer for fp_poly",fp_poly.layer)}let notePathId=0;for(let fp_arc of fp_arcs){let lowerLayer=fp_arc.layer.toLowerCase();if(lowerLayer==="edge.cuts"){debug23("Skipping Edge.Cuts fp_arc (converted to pcb_cutout)",fp_arc.layer);continue}let start=makePoint(fp_arc.start),mid=makePoint(fp_arc.mid),end=makePoint(fp_arc.end),arcLength=getArcLength(start,mid,end),arcPoints=generateArcPath(start,mid,end,Math.ceil(arcLength));if(lowerLayer.startsWith("user.")){circuitJson.push({type:"pcb_note_path",pcb_note_path_id:`pcb_note_path_${notePathId++}`,pcb_component_id,route:arcPoints.map(p2=>({x:p2.x,y:-p2.y})),stroke_width:fp_arc.stroke.width});continue}let tscircuitLayer=convertKicadLayerToTscircuitLayer(fp_arc.layer);if(!tscircuitLayer){debug23("Unable to convert layer for fp_arc",fp_arc.layer);continue}circuitJson.push({type:"pcb_silkscreen_path",pcb_silkscreen_path_id:`pcb_silkscreen_path_${silkPathId++}`,layer:tscircuitLayer,pcb_component_id,route:arcPoints.map(p2=>({x:p2.x,y:-p2.y})),stroke_width:fp_arc.stroke.width})}if(fp_circles)for(let fp_circle of fp_circles){let lowerLayer=fp_circle.layer.toLowerCase(),center2=makePoint(fp_circle.center),endPoint=makePoint(fp_circle.end),radius=Math.sqrt((endPoint.x-center2.x)**2+(endPoint.y-center2.y)**2),numPoints=Math.max(16,Math.ceil(2*Math.PI*radius)),circlePoints=[];for(let i3=0;i3<=numPoints;i3++){let angle=i3/numPoints*2*Math.PI;circlePoints.push({x:center2.x+radius*Math.cos(angle),y:center2.y+radius*Math.sin(angle)})}lowerLayer.startsWith("user.")&&circuitJson.push({type:"pcb_note_path",pcb_note_path_id:`pcb_note_path_${notePathId++}`,pcb_component_id,route:circlePoints.map(p2=>({x:p2.x,y:-p2.y})),stroke_width:fp_circle.stroke.width})}for(let fp_text of fp_texts){let layerRef=convertKicadLayerToTscircuitLayer(fp_text.layer);fp_text.layer.endsWith(".SilkS")?circuitJson.push({type:"pcb_silkscreen_text",layer:layerRef,font:"tscircuit2024",font_size:fp_text.effects?.font?.size[0]??1,pcb_component_id,anchor_position:{x:fp_text.at[0],y:-fp_text.at[1]},anchor_alignment:"center",text:fp_text.text}):fp_text.layer.endsWith(".Fab")?circuitJson.push({type:"pcb_fabrication_note_text",layer:layerRef,font:"tscircuit2024",font_size:fp_text.effects?.font?.size[0]??1,pcb_component_id,anchor_position:{x:fp_text.at[0],y:-fp_text.at[1]},anchor_alignment:"center",text:fp_text.text}):debug23("Unhandled layer for fp_text",fp_text.layer)}let refProp=properties.find(prop=>prop.key==="Reference"),valProp=properties.find(prop=>prop.key==="Value"),propFabTexts=[refProp,valProp].filter(p2=>p2&&!!p2.val);for(let propFab of propFabTexts){let at3=propFab.attributes.at;if(!at3)continue;let isFabLayer=propFab.attributes.layer?.toLowerCase()?.endsWith(".fab"),font_size=getSilkscreenFontSizeFromFpTexts(fp_texts);circuitJson.push({type:isFabLayer?"pcb_fabrication_note_text":"pcb_silkscreen_text",layer:"top",font:"tscircuit2024",font_size,pcb_component_id,anchor_position:{x:at3[0],y:-at3[1]},anchor_alignment:"center",text:propFab.val})}return circuitJson},parseKicadModToCircuitJson=async kicadMod=>{let kicadJson=parseKicadModToKicadJson(kicadMod);return await convertKicadJsonToTsCircuitSoup(kicadJson)};var dynamicallyLoadDependencyWithCdnBackup=async packageName=>{try{return(await import(packageName)).default}catch{console.log(`Failed to load ${packageName} locally, trying CDN fallback...`);try{let res2=await fetch(`https://cdn.jsdelivr.net/npm/${packageName}/+esm`);if(!res2.ok)throw new Error(`Failed to fetch ${packageName} from CDN: ${res2.statusText}`);let code=await res2.text(),blob=new Blob([code],{type:"application/javascript"}),url=URL.createObjectURL(blob);try{let{default:loadedModule}=await import(url);return loadedModule}finally{URL.revokeObjectURL(url)}}catch(cdnError){throw console.error(`CDN fallback for ${packageName} also failed:`,cdnError),cdnError}}};var KICAD_FOOTPRINT_CACHE_URL="https://kicad-mod-cache.tscircuit.com",ngspiceEngineCache=null,getPlatformConfig=()=>({partsEngine:jlcPartsEngine,spiceEngineMap:{ngspice:{simulate:async spice=>{if(!ngspiceEngineCache){let createNgspiceSpiceEngine=await dynamicallyLoadDependencyWithCdnBackup("@tscircuit/ngspice-spice-engine").catch(error=>{throw new Error("Could not load ngspice engine from local node_modules or CDN fallback.",{cause:error})});createNgspiceSpiceEngine&&(ngspiceEngineCache=await createNgspiceSpiceEngine())}if(!ngspiceEngineCache)throw new Error("Could not load ngspice engine from local node_modules or CDN fallback.");return ngspiceEngineCache.simulate(spice)}}},footprintLibraryMap:{kicad:async footprintName=>{let baseUrl=`${KICAD_FOOTPRINT_CACHE_URL}/${footprintName}`,circuitJsonUrl=`${baseUrl}.circuit.json`,raw=await(await fetch(circuitJsonUrl)).json(),filtered=Array.isArray(raw)?raw.filter(el2=>el2?.type==="pcb_silkscreen_text"?el2?.text==="REF**":!0):raw,wrlUrl=`${baseUrl}.wrl`;return{footprintCircuitJson:filtered,cadModel:{wrlUrl,modelUnitToMmScale:2.54}}}},footprintFileParserMap:{kicad_mod:{loadFromUrl:async url=>{let kicadContent=await fetch(url).then(res2=>res2.text()),kicadJson=await parseKicadModToCircuitJson(kicadContent);return{footprintCircuitJson:Array.isArray(kicadJson)?kicadJson:[kicadJson]}}}}});var tslib_es6_exports={};__export(tslib_es6_exports,{__addDisposableResource:()=>__addDisposableResource,__assign:()=>__assign,__asyncDelegator:()=>__asyncDelegator,__asyncGenerator:()=>__asyncGenerator,__asyncValues:()=>__asyncValues,__await:()=>__await,__awaiter:()=>__awaiter,__classPrivateFieldGet:()=>__classPrivateFieldGet,__classPrivateFieldIn:()=>__classPrivateFieldIn,__classPrivateFieldSet:()=>__classPrivateFieldSet,__createBinding:()=>__createBinding,__decorate:()=>__decorate,__disposeResources:()=>__disposeResources,__esDecorate:()=>__esDecorate,__exportStar:()=>__exportStar,__extends:()=>__extends,__generator:()=>__generator,__importDefault:()=>__importDefault,__importStar:()=>__importStar,__makeTemplateObject:()=>__makeTemplateObject,__metadata:()=>__metadata,__param:()=>__param,__propKey:()=>__propKey,__read:()=>__read,__rest:()=>__rest,__rewriteRelativeImportExtension:()=>__rewriteRelativeImportExtension,__runInitializers:()=>__runInitializers,__setFunctionName:()=>__setFunctionName,__spread:()=>__spread,__spreadArray:()=>__spreadArray,__spreadArrays:()=>__spreadArrays,__values:()=>__values,default:()=>tslib_es6_default});var extendStatics=function(d3,b3){return extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d4,b4){d4.__proto__=b4}||function(d4,b4){for(var p2 in b4)Object.prototype.hasOwnProperty.call(b4,p2)&&(d4[p2]=b4[p2])},extendStatics(d3,b3)};function __extends(d3,b3){if(typeof b3!="function"&&b3!==null)throw new TypeError("Class extends value "+String(b3)+" is not a constructor or null");extendStatics(d3,b3);function __(){this.constructor=d3}d3.prototype=b3===null?Object.create(b3):(__.prototype=b3.prototype,new __)}var __assign=function(){return __assign=Object.assign||function(t5){for(var s3,i3=1,n3=arguments.length;i3<n3;i3++){s3=arguments[i3];for(var p2 in s3)Object.prototype.hasOwnProperty.call(s3,p2)&&(t5[p2]=s3[p2])}return t5},__assign.apply(this,arguments)};function __rest(s3,e4){var t5={};for(var p2 in s3)Object.prototype.hasOwnProperty.call(s3,p2)&&e4.indexOf(p2)<0&&(t5[p2]=s3[p2]);if(s3!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i3=0,p2=Object.getOwnPropertySymbols(s3);i3<p2.length;i3++)e4.indexOf(p2[i3])<0&&Object.prototype.propertyIsEnumerable.call(s3,p2[i3])&&(t5[p2[i3]]=s3[p2[i3]]);return t5}function __decorate(decorators,target,key,desc){var c3=arguments.length,r4=c3<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d3;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r4=Reflect.decorate(decorators,target,key,desc);else for(var i3=decorators.length-1;i3>=0;i3--)(d3=decorators[i3])&&(r4=(c3<3?d3(r4):c3>3?d3(target,key,r4):d3(target,key))||r4);return c3>3&&r4&&Object.defineProperty(target,key,r4),r4}function __param(paramIndex,decorator){return function(target,key){decorator(target,key,paramIndex)}}function __esDecorate(ctor,descriptorIn,decorators,contextIn,initializers,extraInitializers){function accept(f2){if(f2!==void 0&&typeof f2!="function")throw new TypeError("Function expected");return f2}for(var kind=contextIn.kind,key=kind==="getter"?"get":kind==="setter"?"set":"value",target=!descriptorIn&&ctor?contextIn.static?ctor:ctor.prototype:null,descriptor=descriptorIn||(target?Object.getOwnPropertyDescriptor(target,contextIn.name):{}),_4,done=!1,i3=decorators.length-1;i3>=0;i3--){var context={};for(var p2 in contextIn)context[p2]=p2==="access"?{}:contextIn[p2];for(var p2 in contextIn.access)context.access[p2]=contextIn.access[p2];context.addInitializer=function(f2){if(done)throw new TypeError("Cannot add initializers after decoration has completed");extraInitializers.push(accept(f2||null))};var result=(0,decorators[i3])(kind==="accessor"?{get:descriptor.get,set:descriptor.set}:descriptor[key],context);if(kind==="accessor"){if(result===void 0)continue;if(result===null||typeof result!="object")throw new TypeError("Object expected");(_4=accept(result.get))&&(descriptor.get=_4),(_4=accept(result.set))&&(descriptor.set=_4),(_4=accept(result.init))&&initializers.unshift(_4)}else(_4=accept(result))&&(kind==="field"?initializers.unshift(_4):descriptor[key]=_4)}target&&Object.defineProperty(target,contextIn.name,descriptor),done=!0}function __runInitializers(thisArg,initializers,value){for(var useValue=arguments.length>2,i3=0;i3<initializers.length;i3++)value=useValue?initializers[i3].call(thisArg,value):initializers[i3].call(thisArg);return useValue?value:void 0}function __propKey(x3){return typeof x3=="symbol"?x3:"".concat(x3)}function __setFunctionName(f2,name,prefix){return typeof name=="symbol"&&(name=name.description?"[".concat(name.description,"]"):""),Object.defineProperty(f2,"name",{configurable:!0,value:prefix?"".concat(prefix," ",name):name})}function __metadata(metadataKey,metadataValue){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(metadataKey,metadataValue)}function __awaiter(thisArg,_arguments,P4,generator){function adopt(value){return value instanceof P4?value:new P4(function(resolve){resolve(value)})}return new(P4||(P4=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e4){reject(e4)}}function rejected(value){try{step(generator.throw(value))}catch(e4){reject(e4)}}function step(result){result.done?resolve(result.value):adopt(result.value).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())})}function __generator(thisArg,body){var _4={label:0,sent:function(){if(t5[0]&1)throw t5[1];return t5[1]},trys:[],ops:[]},f2,y3,t5,g4=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return g4.next=verb(0),g4.throw=verb(1),g4.return=verb(2),typeof Symbol=="function"&&(g4[Symbol.iterator]=function(){return this}),g4;function verb(n3){return function(v4){return step([n3,v4])}}function step(op2){if(f2)throw new TypeError("Generator is already executing.");for(;g4&&(g4=0,op2[0]&&(_4=0)),_4;)try{if(f2=1,y3&&(t5=op2[0]&2?y3.return:op2[0]?y3.throw||((t5=y3.return)&&t5.call(y3),0):y3.next)&&!(t5=t5.call(y3,op2[1])).done)return t5;switch(y3=0,t5&&(op2=[op2[0]&2,t5.value]),op2[0]){case 0:case 1:t5=op2;break;case 4:return _4.label++,{value:op2[1],done:!1};case 5:_4.label++,y3=op2[1],op2=[0];continue;case 7:op2=_4.ops.pop(),_4.trys.pop();continue;default:if(t5=_4.trys,!(t5=t5.length>0&&t5[t5.length-1])&&(op2[0]===6||op2[0]===2)){_4=0;continue}if(op2[0]===3&&(!t5||op2[1]>t5[0]&&op2[1]<t5[3])){_4.label=op2[1];break}if(op2[0]===6&&_4.label<t5[1]){_4.label=t5[1],t5=op2;break}if(t5&&_4.label<t5[2]){_4.label=t5[2],_4.ops.push(op2);break}t5[2]&&_4.ops.pop(),_4.trys.pop();continue}op2=body.call(thisArg,_4)}catch(e4){op2=[6,e4],y3=0}finally{f2=t5=0}if(op2[0]&5)throw op2[1];return{value:op2[0]?op2[1]:void 0,done:!0}}}var __createBinding=Object.create?(function(o4,m3,k4,k22){k22===void 0&&(k22=k4);var desc=Object.getOwnPropertyDescriptor(m3,k4);(!desc||("get"in desc?!m3.__esModule:desc.writable||desc.configurable))&&(desc={enumerable:!0,get:function(){return m3[k4]}}),Object.defineProperty(o4,k22,desc)}):(function(o4,m3,k4,k22){k22===void 0&&(k22=k4),o4[k22]=m3[k4]});function __exportStar(m3,o4){for(var p2 in m3)p2!=="default"&&!Object.prototype.hasOwnProperty.call(o4,p2)&&__createBinding(o4,m3,p2)}function __values(o4){var s3=typeof Symbol=="function"&&Symbol.iterator,m3=s3&&o4[s3],i3=0;if(m3)return m3.call(o4);if(o4&&typeof o4.length=="number")return{next:function(){return o4&&i3>=o4.length&&(o4=void 0),{value:o4&&o4[i3++],done:!o4}}};throw new TypeError(s3?"Object is not iterable.":"Symbol.iterator is not defined.")}function __read(o4,n3){var m3=typeof Symbol=="function"&&o4[Symbol.iterator];if(!m3)return o4;var i3=m3.call(o4),r4,ar3=[],e4;try{for(;(n3===void 0||n3-- >0)&&!(r4=i3.next()).done;)ar3.push(r4.value)}catch(error){e4={error}}finally{try{r4&&!r4.done&&(m3=i3.return)&&m3.call(i3)}finally{if(e4)throw e4.error}}return ar3}function __spread(){for(var ar3=[],i3=0;i3<arguments.length;i3++)ar3=ar3.concat(__read(arguments[i3]));return ar3}function __spreadArrays(){for(var s3=0,i3=0,il2=arguments.length;i3<il2;i3++)s3+=arguments[i3].length;for(var r4=Array(s3),k4=0,i3=0;i3<il2;i3++)for(var a2=arguments[i3],j3=0,jl2=a2.length;j3<jl2;j3++,k4++)r4[k4]=a2[j3];return r4}function __spreadArray(to3,from,pack2){if(pack2||arguments.length===2)for(var i3=0,l2=from.length,ar3;i3<l2;i3++)(ar3||!(i3 in from))&&(ar3||(ar3=Array.prototype.slice.call(from,0,i3)),ar3[i3]=from[i3]);return to3.concat(ar3||Array.prototype.slice.call(from))}function __await(v4){return this instanceof __await?(this.v=v4,this):new __await(v4)}function __asyncGenerator(thisArg,_arguments,generator){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var g4=generator.apply(thisArg,_arguments||[]),i3,q4=[];return i3=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),verb("next"),verb("throw"),verb("return",awaitReturn),i3[Symbol.asyncIterator]=function(){return this},i3;function awaitReturn(f2){return function(v4){return Promise.resolve(v4).then(f2,reject)}}function verb(n3,f2){g4[n3]&&(i3[n3]=function(v4){return new Promise(function(a2,b3){q4.push([n3,v4,a2,b3])>1||resume(n3,v4)})},f2&&(i3[n3]=f2(i3[n3])))}function resume(n3,v4){try{step(g4[n3](v4))}catch(e4){settle(q4[0][3],e4)}}function step(r4){r4.value instanceof __await?Promise.resolve(r4.value.v).then(fulfill,reject):settle(q4[0][2],r4)}function fulfill(value){resume("next",value)}function reject(value){resume("throw",value)}function settle(f2,v4){f2(v4),q4.shift(),q4.length&&resume(q4[0][0],q4[0][1])}}function __asyncDelegator(o4){var i3,p2;return i3={},verb("next"),verb("throw",function(e4){throw e4}),verb("return"),i3[Symbol.iterator]=function(){return this},i3;function verb(n3,f2){i3[n3]=o4[n3]?function(v4){return(p2=!p2)?{value:__await(o4[n3](v4)),done:!1}:f2?f2(v4):v4}:f2}}function __asyncValues(o4){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var m3=o4[Symbol.asyncIterator],i3;return m3?m3.call(o4):(o4=typeof __values=="function"?__values(o4):o4[Symbol.iterator](),i3={},verb("next"),verb("throw"),verb("return"),i3[Symbol.asyncIterator]=function(){return this},i3);function verb(n3){i3[n3]=o4[n3]&&function(v4){return new Promise(function(resolve,reject){v4=o4[n3](v4),settle(resolve,reject,v4.done,v4.value)})}}function settle(resolve,reject,d3,v4){Promise.resolve(v4).then(function(v6){resolve({value:v6,done:d3})},reject)}}function __makeTemplateObject(cooked,raw){return Object.defineProperty?Object.defineProperty(cooked,"raw",{value:raw}):cooked.raw=raw,cooked}var __setModuleDefault=Object.create?(function(o4,v4){Object.defineProperty(o4,"default",{enumerable:!0,value:v4})}):function(o4,v4){o4.default=v4},ownKeys=function(o4){return ownKeys=Object.getOwnPropertyNames||function(o5){var ar3=[];for(var k4 in o5)Object.prototype.hasOwnProperty.call(o5,k4)&&(ar3[ar3.length]=k4);return ar3},ownKeys(o4)};function __importStar(mod){if(mod&&mod.__esModule)return mod;var result={};if(mod!=null)for(var k4=ownKeys(mod),i3=0;i3<k4.length;i3++)k4[i3]!=="default"&&__createBinding(result,mod,k4[i3]);return __setModuleDefault(result,mod),result}function __importDefault(mod){return mod&&mod.__esModule?mod:{default:mod}}function __classPrivateFieldGet(receiver,state2,kind,f2){if(kind==="a"&&!f2)throw new TypeError("Private accessor was defined without a getter");if(typeof state2=="function"?receiver!==state2||!f2:!state2.has(receiver))throw new TypeError("Cannot read private member from an object whose class did not declare it");return kind==="m"?f2:kind==="a"?f2.call(receiver):f2?f2.value:state2.get(receiver)}function __classPrivateFieldSet(receiver,state2,value,kind,f2){if(kind==="m")throw new TypeError("Private method is not writable");if(kind==="a"&&!f2)throw new TypeError("Private accessor was defined without a setter");if(typeof state2=="function"?receiver!==state2||!f2:!state2.has(receiver))throw new TypeError("Cannot write private member to an object whose class did not declare it");return kind==="a"?f2.call(receiver,value):f2?f2.value=value:state2.set(receiver,value),value}function __classPrivateFieldIn(state2,receiver){if(receiver===null||typeof receiver!="object"&&typeof receiver!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof state2=="function"?receiver===state2:state2.has(receiver)}function __addDisposableResource(env,value,async){if(value!=null){if(typeof value!="object"&&typeof value!="function")throw new TypeError("Object expected.");var dispose,inner;if(async){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");dispose=value[Symbol.asyncDispose]}if(dispose===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");dispose=value[Symbol.dispose],async&&(inner=dispose)}if(typeof dispose!="function")throw new TypeError("Object not disposable.");inner&&(dispose=function(){try{inner.call(this)}catch(e4){return Promise.reject(e4)}}),env.stack.push({value,dispose,async})}else async&&env.stack.push({async:!0});return value}var _SuppressedError=typeof SuppressedError=="function"?SuppressedError:function(error,suppressed,message){var e4=new Error(message);return e4.name="SuppressedError",e4.error=error,e4.suppressed=suppressed,e4};function __disposeResources(env){function fail(e4){env.error=env.hasError?new _SuppressedError(e4,env.error,"An error was suppressed during disposal."):e4,env.hasError=!0}var r4,s3=0;function next2(){for(;r4=env.stack.pop();)try{if(!r4.async&&s3===1)return s3=0,env.stack.push(r4),Promise.resolve().then(next2);if(r4.dispose){var result=r4.dispose.call(r4.value);if(r4.async)return s3|=2,Promise.resolve(result).then(next2,function(e4){return fail(e4),next2()})}else s3|=1}catch(e4){fail(e4)}if(s3===1)return env.hasError?Promise.reject(env.error):Promise.resolve();if(env.hasError)throw env.error}return next2()}function __rewriteRelativeImportExtension(path,preserveJsx){return typeof path=="string"&&/^\.\.?\//.test(path)?path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(m3,tsx,d3,ext,cm2){return tsx?preserveJsx?".jsx":".js":d3&&(!ext||!cm2)?m3:d3+ext+"."+cm2.toLowerCase()+"js"}):path}var tslib_es6_default={__extends,__assign,__rest,__decorate,__param,__esDecorate,__runInitializers,__propKey,__setFunctionName,__metadata,__awaiter,__generator,__createBinding,__exportStar,__values,__read,__spread,__spreadArrays,__spreadArray,__await,__asyncGenerator,__asyncDelegator,__asyncValues,__makeTemplateObject,__importStar,__importDefault,__classPrivateFieldGet,__classPrivateFieldSet,__classPrivateFieldIn,__addDisposableResource,__disposeResources,__rewriteRelativeImportExtension};var import_debug21=__toESM(require_browser(),1),debug12=(0,import_debug21.default)("tsci:eval:execution-context");function createExecutionContext(webWorkerConfiguration,opts={}){globalThis.React=React;let basePlatform=opts.platform||getPlatformConfig(),platform=opts.projectConfig?{...basePlatform,...opts.projectConfig}:basePlatform;platform.partsEngineDisabled&&(platform.partsEngine=void 0);let circuit=new RootCircuit({platform});opts.name&&(circuit.name=opts.name),opts.debugNamespace&&circuit.enableDebug(opts.debugNamespace);let logs=[];return{fsMap:{},entrypoint:"",logger:{info:message=>{logs.push({msg:message})},getLogs:()=>logs,stringifyLogs:()=>logs.map(log=>log.msg).join(`
618
618
  `)},preSuppliedImports:{"@tscircuit/core":dist_exports4,tscircuit:dist_exports4,"@tscircuit/math-utils":dist_exports2,react:React,"react/jsx-runtime":ReactJsxRuntime,debug:import_debug21.default,tslib:tslib_es6_exports,"@tscircuit/props":{}},circuit,tsConfig:null,importStack:[],currentlyImporting:new Set,...webWorkerConfiguration}}function normalizeFilePath(filePath){let normFilePath=filePath;return normFilePath=normFilePath.replace(/\\/g,"/"),normFilePath=normFilePath.trim(),normFilePath.startsWith("./")&&(normFilePath=normFilePath.slice(2)),normFilePath.startsWith("/")&&(normFilePath=normFilePath.slice(1)),normFilePath}function normalizeFsMap(fsMap){let normalizedFsMap={};for(let[fsPath,fileContent]of Object.entries(fsMap))normalizedFsMap[normalizeFilePath(fsPath)]=fileContent;return normalizedFsMap}function dirname(path){if(!path)return".";let cleanPath=path.replace(/\\/g,"/").replace(/\/+$/,"");return cleanPath.indexOf("/")===-1?".":cleanPath.substring(0,cleanPath.lastIndexOf("/"))||"/"}function resolveRelativePath(importPath,cwd){if(importPath.startsWith("../")){let parentDir=dirname(cwd);return resolveRelativePath(importPath.slice(3),parentDir)}return importPath.startsWith("./")?resolveRelativePath(importPath.slice(2),cwd):importPath.startsWith("/")?importPath.slice(1):`${cwd}/${importPath}`}function getTsConfig(fsMapOrAllFilePaths){if(Array.isArray(fsMapOrAllFilePaths))return null;let tsconfigContent=fsMapOrAllFilePaths["tsconfig.json"];if(!tsconfigContent)return null;try{let sanitizedContent=tsconfigContent.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g,"");return JSON.parse(sanitizedContent)}catch(e4){throw new Error(`Failed to parse tsconfig.json: ${e4.message}`)}}function resolveWithTsconfigPaths(opts){let{importPath,normalizedFilePathMap,extensions,tsConfig,tsconfigDir}=opts,paths=tsConfig?.compilerOptions?.paths;if(!paths)return null;let baseUrl=tsConfig?.compilerOptions?.baseUrl||".",tryResolveCandidate=candidate=>{let normalizedCandidate=normalizeFilePath(candidate);if(normalizedFilePathMap.has(normalizedCandidate))return normalizedFilePathMap.get(normalizedCandidate);for(let ext of extensions){let withExt=`${normalizedCandidate}.${ext}`;if(normalizedFilePathMap.has(withExt))return normalizedFilePathMap.get(withExt)}return null};for(let[alias,targets]of Object.entries(paths))if(alias.includes("*")){let[prefix,suffix]=alias.split("*");if(!importPath.startsWith(prefix)||!importPath.endsWith(suffix||""))continue;let starMatch=importPath.slice(prefix.length,importPath.length-(suffix?suffix.length:0));for(let target of targets){let replaced=target.replace("*",starMatch),candidate=baseUrl&&!replaced.startsWith("./")&&!replaced.startsWith("/")?`${baseUrl}/${replaced}`:replaced,resolved=tryResolveCandidate(candidate);if(resolved)return resolved}}else{if(importPath!==alias)continue;for(let target of targets){let candidate=baseUrl&&!target.startsWith("./")&&!target.startsWith("/")?`${baseUrl}/${target}`:target,resolved=tryResolveCandidate(candidate);if(resolved)return resolved}}let resolvedPathFromBaseUrl=resolveWithBaseUrl({importPath,normalizedFilePathMap,extensions,tsConfig,tsconfigDir});return resolvedPathFromBaseUrl||null}function resolveWithBaseUrl(opts){let{importPath,normalizedFilePathMap,extensions,tsConfig,tsconfigDir}=opts,baseUrl=tsConfig?.compilerOptions?.baseUrl;if(!baseUrl)return null;let filePathToResolve=`${tsconfigDir||"."}/${baseUrl}/${importPath}`;filePathToResolve=filePathToResolve.replace(/\/+/g,"/"),filePathToResolve=filePathToResolve.replace(/\/\.\//g,"/");let normalizedFilePath=normalizeFilePath(filePathToResolve);if(normalizedFilePathMap.has(normalizedFilePath))return normalizedFilePathMap.get(normalizedFilePath);for(let ext of extensions){let withExt=`${normalizedFilePath}.${ext}`;if(normalizedFilePathMap.has(withExt))return normalizedFilePathMap.get(withExt)}return null}function matchesTsconfigPathPattern(importPath,tsConfig){let paths=tsConfig?.compilerOptions?.paths;if(!paths)return!1;for(let[alias]of Object.entries(paths))if(alias.includes("*")){let[prefix,suffix]=alias.split("*");if(importPath.startsWith(prefix)&&importPath.endsWith(suffix||""))return!0}else if(importPath===alias)return!0;return!1}var FILE_EXTENSIONS=["tsx","ts","json","js","jsx","obj","gltf","glb","stl","step","stp"],resolveFilePath=(unknownFilePath,fsMapOrAllFilePaths,cwd,opts={})=>{let tsConfig=opts.tsConfig??null,isRelativeImport=unknownFilePath.startsWith("./")||unknownFilePath.startsWith("../"),hasBaseUrl=!!tsConfig?.compilerOptions?.baseUrl,resolvedPath=cwd&&(isRelativeImport||!hasBaseUrl)?resolveRelativePath(unknownFilePath,cwd):unknownFilePath,filePaths=new Set(Array.isArray(fsMapOrAllFilePaths)?fsMapOrAllFilePaths:Object.keys(fsMapOrAllFilePaths));if(filePaths.has(resolvedPath))return resolvedPath;let normalizedFilePathMap=new Map;for(let filePath of filePaths)normalizedFilePathMap.set(normalizeFilePath(filePath),filePath);let normalizedResolvedPath=normalizeFilePath(resolvedPath);if(isRelativeImport||!hasBaseUrl){if(normalizedFilePathMap.has(normalizedResolvedPath))return normalizedFilePathMap.get(normalizedResolvedPath);for(let ext of FILE_EXTENSIONS){let possibleFilePath=`${normalizedResolvedPath}.${ext}`;if(normalizedFilePathMap.has(possibleFilePath))return normalizedFilePathMap.get(possibleFilePath)}}if(!isRelativeImport){let resolvedPathFromPaths=resolveWithTsconfigPaths({importPath:unknownFilePath,normalizedFilePathMap,extensions:FILE_EXTENSIONS,tsConfig,tsconfigDir:opts.tsconfigDir});if(resolvedPathFromPaths)return resolvedPathFromPaths;let resolvedPathFromBaseUrl=resolveWithBaseUrl({importPath:unknownFilePath,normalizedFilePathMap,extensions:FILE_EXTENSIONS,tsConfig,tsconfigDir:opts.tsconfigDir});if(resolvedPathFromBaseUrl)return resolvedPathFromBaseUrl}if(!isRelativeImport&&!hasBaseUrl){let normalizedUnknownFilePath=normalizeFilePath(unknownFilePath);if(normalizedFilePathMap.has(normalizedUnknownFilePath))return normalizedFilePathMap.get(normalizedUnknownFilePath);for(let ext of FILE_EXTENSIONS){let possibleFilePath=`${normalizedUnknownFilePath}.${ext}`;if(normalizedFilePathMap.has(possibleFilePath))return normalizedFilePathMap.get(possibleFilePath)}}return null},resolveFilePathOrThrow=(unknownFilePath,fsMapOrAllFilePaths,cwd,opts={})=>{let resolvedFilePath=resolveFilePath(unknownFilePath,fsMapOrAllFilePaths,cwd,opts);if(!resolvedFilePath)throw new Error(`File not found "${unknownFilePath}", available paths: