@tscircuit/eval 0.0.296 → 0.0.297

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.
@@ -14,7 +14,7 @@ No matching component was found for:
14
14
  `+m+` |
15
15
  `+d.line+" | "+y+`
16
16
  `+m+" | "+zq("",l.column-1," ")+zq("",E,"^")}else e+=`
17
- at `+x}return e};G6.buildMessage=function(n,e){var a={literal:function(y){return'"'+l(y.text)+'"'},class:function(y){var b=y.parts.map(function(E){return Array.isArray(E)?d(E[0])+"-"+d(E[1]):d(E)});return"["+(y.inverted?"^":"")+b.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(y){return y.description}};function s(y){return y.charCodeAt(0).toString(16).toUpperCase()}function l(y){return y.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(b){return"\\x0"+s(b)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(b){return"\\x"+s(b)})}function d(y){return y.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(b){return"\\x0"+s(b)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(b){return"\\x"+s(b)})}function x(y){return a[y.type](y)}function f(y){var b=y.map(x),E,A;if(b.sort(),b.length>0){for(E=1,A=1;E<b.length;E++)b[E-1]!==b[E]&&(b[A]=b[E],A++);b.length=A}switch(b.length){case 1:return b[0];case 2:return b[0]+" or "+b[1];default:return b.slice(0,-1).join(", ")+", or "+b[b.length-1]}}function m(y){return y?'"'+l(y)+'"':"end of input"}return"Expected "+f(n)+" but "+m(e)+" found."};q4t=(n,e="right")=>{switch(e){case"down":switch(n){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(n){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(n){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 n}return n},X6=(n,e)=>{let{primitives:a,center:s,ports:l,size:d}=n,x=V6({a:1,b:0,c:0,d:-1,e:0,f:2*s.y}),f=a.map(y=>{switch(y={...y},y.type){case"path":return{...y,points:y.points.map(w=>du(x,w))};case"text":let b=du(x,{x:y.x,y:y.y}),E={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{...y,x:b.x,y:b.y,anchor:E[y.anchor]};case"circle":case"box":let A=du(x,{x:y.x,y:y.y});return{...y,x:A.x,y:A.y}}}),m=l.map(y=>({...y,...du(x,y)}));return{primitives:f,center:s,ports:m,size:d,...e}},gb=(n,e)=>{let{primitives:a,center:s,ports:l,size:d}=n,x=V6({a:-1,b:0,c:0,d:1,e:0,f:2*s.x}),f=a.map(y=>{switch(y={...y},y.type){case"path":return{...y,points:y.points.map(w=>du(x,w))};case"text":let b=du(x,{x:y.x,y:y.y}),E={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{...y,x:b.x,y:b.y,anchor:E[y.anchor]};case"circle":case"box":let A=du(x,{x:y.x,y:y.y});return{...y,x:A.x,y:A.y}}}),m=l.map(y=>({...y,...du(x,y)}));return{primitives:f,center:s,ports:m,size:d,...e}},hU=(n,e)=>{let{newOrientation:a,overrides:s}=e,l={up:Math.PI/2,right:0,down:-Math.PI/2,left:-Math.PI},d=$4t(a?l[a]:Math.PI/2,n.center.x,n.center.y),{primitives:x,center:f,size:m,ports:y}=n,b=x.map(w=>{switch(w={...w},w.type){case"path":return{...w,points:w.points.map(G=>du(d,G))};case"text":let B=du(d,{x:w.x,y:w.y});return w.anchor=q4t(w.anchor,a??"right"),{...w,x:B.x,y:B.y};case"circle":let I=du(d,{x:w.x,y:w.y});return{...w,x:I.x,y:I.y};case"box":let q=du(d,{x:w.x,y:w.y});return{...w,x:q.x,y:q.y,width:w.height,height:w.width}}}),E=y.map(w=>({...w,...du(d,w)})),A=fU(b);return{primitives:b,center:f,ports:E,size:{width:A.maxX-A.minX,height:A.maxY-A.minY},...s}},ur=(n,e="down",a={})=>hU(n,{newOrientation:e,overrides:a}),U4t=class{constructor(n){X(this,"symbol");this.symbol=JSON.parse(JSON.stringify(n)),this.symbol.size=this.computeSize()}changeTextAnchor(n,e,a){return this.symbol={...this.symbol,primitives:this.symbol.primitives.map(s=>s.type==="text"&&s.text===n?{...s,anchor:e,...a?{x:s.x+a.x,y:s.y+a.y}:{}}:s)},this}labelPort(n,e){return this.symbol={...this.symbol,ports:this.symbol.ports.map(a=>a.labels.includes(n)?{...a,labels:e}:a)},this}rotateRightFacingSymbol(n){return this.symbol=hU(this.symbol,{newOrientation:n}),this}computeSize(){let n=fU(this.symbol.primitives);return{width:n.maxX-n.minX,height:n.maxY-n.minY}}build(){return{...this.symbol,size:this.computeSize()}}},Ft=n=>{let e=n.primitives??[...Object.values(n.paths??{}),...Object.values(n.texts??{}),...Object.values(n.circles??{}),...Object.values(n.rects??{})],a=n.ports??Object.entries(n.refblocks).flatMap(([l,d])=>[{...d,labels:[l]}]),s=n.center??{x:n.bounds.centerX,y:n.bounds.centerY};return a.length===2&&(s={x:(a[0].x+a[1].x)/2,y:(a[0].y+a[1].y)/2}),new U4t({...n,primitives:e,ports:a,center:s})},Xm={paths:{path11:{type:"path",points:[{x:-.53,y:.04},{x:-.3,y:.04}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:.04},{x:.53,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:V4t,texts:CQt,bounds:t4,refblocks:u3e,circles:G4t}=Xm,X4t=Ft({primitives:[...Object.values(V4t),...Object.values(G4t),{type:"text",text:"{REF}",x:-.15,y:.3894553499999995},{type:"text",text:"{VAL}",x:.15,y:.3894553499999995}],ports:[{...u3e.left1,labels:["1"]},{...u3e.right1,labels:["2"]}],size:{width:t4.width,height:t4.height},center:{x:t4.centerX,y:t4.centerY}}).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:Y4t,texts:_Qt,bounds:r4,refblocks:c3e,circles:H4t}=Xm,W4t=Ft({primitives:[...Object.values(Y4t),...Object.values(H4t),{type:"text",text:"{REF}",x:-0,y:.4094553499999995},{type:"text",text:"{VAL}",x:0,y:-.4094553499999995}],ports:[{...c3e.left1,labels:["1"]},{...c3e.right1,labels:["2"]}],size:{width:r4.width,height:r4.height},center:{x:r4.centerX,y:r4.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:K4t,texts:AQt,bounds:n4,refblocks:l3e,circles:J4t}=Xm,Z4t=Ft({primitives:[...Object.values(K4t),...Object.values(J4t),{type:"text",text:"{REF}",x:-0,y:-.3094553499999995},{type:"text",text:"{VAL}",x:0,y:.4094553499999995}],ports:[{...l3e.left1,labels:["1"]},{...l3e.right1,labels:["2"]}],size:{width:n4.width,height:n4.height},center:{x:n4.centerX,y:n4.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:Q4t,texts:RQt,bounds:a4,refblocks:d3e,circles:e6t}=Xm,t6t=Ft({primitives:[...Object.values(Q4t),...Object.values(e6t),{type:"text",text:"{REF}",x:-0,y:.4094553499999995},{type:"text",text:"{VAL}",x:0,y:-.4094553499999995}],ports:[{...d3e.left1,labels:["1"]},{...d3e.right1,labels:["2"]}],size:{width:a4.width,height:a4.height},center:{x:a4.centerX,y:a4.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:r6t,texts:SQt,bounds:s4,refblocks:p3e,circles:n6t}=Xm,a6t=Ft({primitives:[...Object.values(r6t),...Object.values(n6t),{type:"text",text:"{REF}",x:.15,y:-.2894553499999995},{type:"text",text:"{VAL}",x:-.15,y:-.2894553499999995}],ports:[{...p3e.left1,labels:["1"]},{...p3e.right1,labels:["2"]}],size:{width:s4.width,height:s4.height},center:{x:s4.centerX,y:s4.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:s6t,texts:wQt,bounds:i4,refblocks:x3e,circles:i6t}=Xm,o6t=Ft({primitives:[...Object.values(s6t),...Object.values(i6t),{type:"text",text:"{REF}",x:.15,y:-.2894553499999995},{type:"text",text:"{VAL}",x:-.15,y:-.2894553499999995}],ports:[{...x3e.left1,labels:["1"]},{...x3e.right1,labels:["2"]}],size:{width:i4.width,height:i4.height},center:{x:i4.centerX,y:i4.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),Ym={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:u6t,texts:BQt,bounds:o4,refblocks:f3e,circles:c6t}=Ym,l6t=Ft({primitives:[...Object.values(u6t),...Object.values(c6t),{type:"text",text:"{REF}",x:-.15,y:.3294553499999995},{type:"text",text:"{VAL}",x:.15,y:.3294553499999995}],ports:[{...f3e.left1,labels:["1"]},{...f3e.right1,labels:["2"]}],size:{width:o4.width,height:o4.height},center:{x:o4.centerX,y:o4.centerY}}).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),d6t=Ft(Ym).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1","neg"]).labelPort("right1",["2","pos"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:p6t,texts:TQt,bounds:u4,refblocks:h3e,circles:x6t}=Ym,f6t=Ft({primitives:[...Object.values(p6t),...Object.values(x6t),{type:"text",text:"{REF}",x:-0,y:-.2294553499999995},{type:"text",text:"{VAL}",x:0,y:.3294553499999995}],ports:[{...h3e.left1,labels:["1"]},{...h3e.right1,labels:["2"]}],size:{width:u4.width,height:u4.height},center:{x:u4.centerX,y:u4.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),h6t=Ft(Ym).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1","neg"]).labelPort("right1",["2","pos"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:m6t,texts:PQt,bounds:c4,refblocks:m3e,circles:g6t}=Ym,y6t=Ft({primitives:[...Object.values(m6t),...Object.values(g6t),{type:"text",text:"{REF}",x:.15,y:-.2294553499999995},{type:"text",text:"{VAL}",x:-.15,y:-.2294553499999995}],ports:[{...m3e.left1,labels:["1"]},{...m3e.right1,labels:["2"]}],size:{width:c4.width,height:c4.height},center:{x:c4.centerX,y:c4.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:D6t,texts:IQt,bounds:l4,refblocks:g3e,circles:b6t}=Ym,F6t=Ft({primitives:[...Object.values(D6t),...Object.values(b6t),{type:"text",text:"{REF}",x:.15,y:-.2294553499999995},{type:"text",text:"{VAL}",x:-.15,y:-.2294553499999995}],ports:[{...g3e.left1,labels:["1"]},{...g3e.right1,labels:["2"]}],size:{width:l4.width,height:l4.height},center:{x:l4.centerX,y:l4.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),Y6={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:E6t,texts:jQt,bounds:d4,refblocks:y3e,circles:v6t}=Y6,C6t=Ft({primitives:[...Object.values(E6t),...Object.values(v6t),{type:"text",text:"{REF}",x:-.16,y:.2294553499999995},{type:"text",text:"{VAL}",x:.16,y:.2294553499999995}],ports:[{...y3e.left1,labels:["1"]},{...y3e.right1,labels:["2"]}],size:{width:d4.width,height:d4.height},center:{x:d4.centerX,y:d4.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").build(),{paths:_6t,texts:NQt,bounds:p4,refblocks:D3e,circles:A6t}=Y6,gve=Ft({primitives:[...Object.values(_6t),...Object.values(A6t),{type:"text",text:"{REF}",x:-1118e-7,y:-.18},{type:"text",text:"{VAL}",x:1118e-7,y:.2738453}],ports:[{...D3e.left1,labels:["1"]},{...D3e.right1,labels:["2"]}],size:{width:p4.width,height:p4.height},center:{x:p4.centerX,y:p4.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("left").labelPort("left1",["2"]).labelPort("right1",["1"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:R6t,texts:kQt,bounds:x4,refblocks:b3e,circles:S6t}=Y6,w6t=Ft({primitives:[...Object.values(R6t),...Object.values(S6t),{type:"text",text:"{REF}",x:-.0050250999999996715,y:.27384529999999985,anchor:"middle_left"},{type:"text",text:"{VAL}",x:-.00011179999999999524,y:-.27384530000000007,anchor:"middle_left"}],ports:[{...b3e.left1,labels:["1"]},{...b3e.right1,labels:["2"]}],size:{width:x4.width,height:x4.height},center:{x:x4.centerX,y:x4.centerY}}).changeTextAnchor("{VAL}","middle_top").labelPort("right1",["2"]).labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:MQt,texts:OQt,bounds:LQt,refblocks:$Qt,circles:zQt}=Y6,mU=ur(gve,"down"),gU=mU.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),yU=mU.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");gU.anchor="middle_left";yU.anchor="middle_left";gU.x=.25;gU.y+=.21;yU.y-=.21;yU.x=.25;B6t=mU;T6t={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:-.44,y:.03}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.44,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:P6t,texts:F3e,bounds:f4,refblocks:E3e,circles:I6t}=T6t,yve=ea({primitives:[...Object.values(P6t),...Object.values(I6t),{...F3e.top1,anchor:"middle_bottom"},{...F3e.bottom1,anchor:"middle_top"}],ports:[{...E3e.left1,labels:["1"]},{...E3e.right1,labels:["2"]}],size:{width:f4.width,height:f4.height},center:{x:f4.centerX,y:f4.centerY}}),j6t=hU(yve,{newOrientation:"up"}),H6={paths:{path1:{type:"path",points:[{x:-.51,y:.05},{x:-.25,y:.05}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.28,y:.05},{x:.55,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:N6t,texts:qQt,bounds:v3e,refblocks:C3e,circles:k6t}=H6,M6t=Ft({primitives:[...Object.values(N6t),...Object.values(k6t),{type:"text",text:"{REF}",x:-.16,y:.2294553499999995},{type:"text",text:"{VAL}",x:.16,y:.2294553499999995}],ports:[{...C3e.left1,labels:["1"]},{...C3e.right1,labels:["2"]}],center:{x:v3e.centerX,y:v3e.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").build(),{paths:O6t,texts:UQt,bounds:_3e,refblocks:A3e,circles:L6t}=H6,$6t=Ft({primitives:[...Object.values(O6t),...Object.values(L6t),{type:"text",text:"{REF}",x:0,y:-.1994553499999995},{type:"text",text:"{VAL}",x:0,y:.2694553499999995}],ports:[{...A3e.left1,labels:["1"]},{...A3e.right1,labels:["2"]}],center:{x:_3e.centerX,y:_3e.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:z6t,texts:VQt,bounds:R3e,refblocks:S3e,circles:q6t}=H6,U6t=Ft({primitives:[...Object.values(z6t),...Object.values(q6t),{type:"text",text:"{REF}",x:0,y:.2294553499999995},{type:"text",text:"{VAL}",x:0,y:-.1594553499999995}],ports:[{...S3e.left1,labels:["1"]},{...S3e.right1,labels:["2"]}],center:{x:R3e.centerX,y:R3e.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),W6={paths:{path2:{type:"path",points:[{x:.15,y:-.01},{x:.56,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:-.56,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:V6t,texts:GQt,bounds:h4,refblocks:w3e,circles:G6t}=W6,X6t=Ft({primitives:[...Object.values(V6t),...Object.values(G6t),{type:"text",text:"{REF}",x:-.2,y:.1404553499999995},{type:"text",text:"{VAL}",x:.2,y:.1494553499999995}],ports:[{...w3e.left1,labels:["1"]},{...w3e.right1,labels:["2"]}],size:{width:h4.width,height:h4.height},center:{x:h4.centerX,y:h4.centerY}}).rotateRightFacingSymbol("down").labelPort("left",["1"]).labelPort("right",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:Y6t,texts:XQt,bounds:m4,refblocks:B3e,circles:H6t}=W6,W6t=Ft({primitives:[...Object.values(Y6t),...Object.values(H6t),{type:"text",text:"{REF}",x:0,y:-.2294553499999995},{type:"text",text:"{VAL}",x:0,y:.1704553499999995}],ports:[{...B3e.left1,labels:["1"]},{...B3e.right1,labels:["2"]}],size:{width:m4.width,height:m4.height},center:{x:m4.centerX,y:m4.centerY}}).rotateRightFacingSymbol("left").labelPort("left",["1"]).labelPort("right",["2"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),{paths:K6t,texts:YQt,bounds:g4,refblocks:T3e,circles:J6t}=W6,Z6t=Ft({primitives:[...Object.values(K6t),...Object.values(J6t),{type:"text",text:"{REF}",x:0,y:.2294553499999995},{type:"text",text:"{VAL}",x:0,y:-.1704553499999995}],ports:[{...T3e.left1,labels:["1"]},{...T3e.right1,labels:["2"]}],size:{width:g4.width,height:g4.height},center:{x:g4.centerX,y:g4.centerY}}).rotateRightFacingSymbol("right").labelPort("left",["1"]).labelPort("right",["2"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),{paths:Q6t,texts:HQt,bounds:y4,refblocks:P3e,circles:eRt}=W6,tRt=Ft({primitives:[...Object.values(Q6t),...Object.values(eRt),{type:"text",text:"{REF}",x:.2,y:-.1404553499999995},{type:"text",text:"{VAL}",x:-.2,y:-.1494553499999995}],ports:[{...P3e.left1,labels:["1"]},{...P3e.right1,labels:["2"]}],size:{width:y4.width,height:y4.height},center:{x:y4.centerX,y:y4.centerY}}).rotateRightFacingSymbol("up").labelPort("left",["1"]).labelPort("right",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:rRt,texts:WQt,bounds:I3e,refblocks:j3e,circles:nRt}=H6,aRt=Ft({primitives:[...Object.values(rRt),...Object.values(nRt),{type:"text",text:"{REF}",x:.16,y:-.2294553499999995},{type:"text",text:"{VAL}",x:-.16,y:-.2294553499999995}],ports:[{...j3e.left1,labels:["1"]},{...j3e.right1,labels:["2"]}],center:{x:I3e.centerX,y:I3e.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").build(),DU={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:sRt,texts:KQt,bounds:N3e,refblocks:k3e,circles:iRt}=DU,oRt=Ft({primitives:[...Object.values(sRt),...Object.values(iRt),{type:"text",text:"{REF}",x:0,y:.2594553499999995}],ports:[{...k3e.left1,labels:["1"]},{...k3e.right1,labels:["2"]}],center:{x:N3e.centerX,y:N3e.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").build(),{paths:uRt,texts:JQt,bounds:M3e,refblocks:O3e,circles:cRt}=DU,Dve=Ft({primitives:[...Object.values(uRt),...Object.values(cRt),{type:"text",text:"{REF}",x:0,y:.2594553499999995}],ports:[{...O3e.left1,labels:["1"]},{...O3e.right1,labels:["2"]}],center:{x:M3e.centerX,y:M3e.centerY}}).rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),lRt=gb(Dve),{paths:dRt,texts:ZQt,bounds:L3e,refblocks:$3e,circles:pRt}=DU,xRt=Ft({primitives:[...Object.values(dRt),...Object.values(pRt),{type:"text",text:"{REF}",x:0,y:.2594553499999995}],ports:[{...$3e.left1,labels:["1"]},{...$3e.right1,labels:["2"]}],center:{x:L3e.centerX,y:L3e.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_right").build(),K6={paths:{path27:{type:"path",points:[{x:.52,y:.02},{x:.07,y:.02}],color:"primary",fill:!1},path28:{type:"path",points:[{x:-.09,y:.02},{x:-.54,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:fRt,texts:QQt,bounds:D4,refblocks:z3e,circles:hRt}=K6,mRt=Ft({primitives:[...Object.values(fRt),...Object.values(hRt),{type:"text",text:"{REF}",x:-.2,y:.2094553499999995},{type:"text",text:"{VAL}",x:.2,y:.2094553499999995}],ports:[{...z3e.left1,labels:["1"]},{...z3e.right1,labels:["2"]}],size:{width:D4.width,height:D4.height},center:{x:D4.centerX,y:D4.centerY}}).changeTextAnchor("{VAL}","top_left").rotateRightFacingSymbol("down").labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{REF}","bottom_left").build(),gRt=Ft(K6).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["2","neg"]).labelPort("right1",["1","pos"]).changeTextAnchor("{REF}","middle_bottom").build(),J6={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:yRt,texts:eer,bounds:b4,refblocks:q3e,circles:DRt}=J6,bRt=Ft({primitives:[...Object.values(yRt),...Object.values(DRt),{type:"text",text:"{REF}",x:.1,y:-.2094553499999995},{type:"text",text:"{VAL}",x:-.2,y:-.2094553499999995}],ports:[{...q3e.left1,labels:["2","neg"]},{...q3e.right1,labels:["1","pos"]}],size:{width:b4.width,height:b4.height},center:{x:b4.centerX,y:b4.centerY}}).changeTextAnchor("{VAL}","top_left").rotateRightFacingSymbol("up").changeTextAnchor("{REF}","bottom_left").build(),FRt=Ft(J6).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["2","neg"]).labelPort("right1",["1","pos"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:ERt,texts:ter,bounds:F4,refblocks:U3e,circles:vRt}=J6,CRt=Ft({primitives:[...Object.values(ERt),...Object.values(vRt),{type:"text",text:"{REF}",x:0,y:-.4094553499999995},{type:"text",text:"{VAL}",x:-0,y:.4094553499999995}],ports:[{...U3e.left1,labels:["2","neg"]},{...U3e.right1,labels:["1","pos"]}],size:{width:F4.width,height:F4.height},center:{x:F4.centerX,y:F4.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("left").changeTextAnchor("{REF}","middle_bottom").build(),{paths:_Rt,texts:rer,bounds:E4,refblocks:V3e,circles:ARt}=J6,RRt=Ft({primitives:[...Object.values(_Rt),...Object.values(ARt),{type:"text",text:"{REF}",x:-.2,y:.2094553499999995},{type:"text",text:"{VAL}",x:.3,y:.2094553499999995}],ports:[{...V3e.left1,labels:["2","neg"]},{...V3e.right1,labels:["1","pos"]}],size:{width:E4.width,height:E4.height},center:{x:E4.centerX,y:E4.centerY}}).changeTextAnchor("{VAL}","top_left").rotateRightFacingSymbol("down").changeTextAnchor("{REF}","bottom_left").build(),SRt=Ft(K6).rotateRightFacingSymbol("right").changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:wRt,texts:ner,bounds:v4,refblocks:G3e,circles:BRt}=K6,TRt=Ft({primitives:[...Object.values(wRt),...Object.values(BRt),{type:"text",text:"{REF}",x:.2,y:-.2094553499999995},{type:"text",text:"{VAL}",x:-.2,y:-.2094553499999995}],ports:[{...G3e.left1,labels:["1"]},{...G3e.right1,labels:["2"]}],size:{width:v4.width,height:v4.height},center:{x:v4.centerX,y:v4.centerY}}).changeTextAnchor("{VAL}","top_left").rotateRightFacingSymbol("up").labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{REF}","bottom_left").build(),Hm={paths:{path11:{type:"path",points:[{x:-.53,y:.03},{x:-.3,y:.03}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:.03},{x:.53,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:PRt,texts:aer,bounds:C4,refblocks:X3e,circles:IRt}=Hm,jRt=Ft({primitives:[...Object.values(PRt),...Object.values(IRt),{type:"text",text:"{REF}",x:-.15,y:.3894553499999995},{type:"text",text:"{VAL}",x:.15,y:.3894553499999995}],ports:[{...X3e.left1,labels:["1"]},{...X3e.right1,labels:["2"]}],size:{width:C4.width,height:C4.height},center:{x:C4.centerX,y:C4.centerY}}).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),NRt=Ft(Hm).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:kRt,texts:ser,bounds:_4,refblocks:Y3e,circles:MRt}=Hm,ORt=Ft({primitives:[...Object.values(kRt),...Object.values(MRt),{type:"text",text:"{REF}",x:-0,y:-.2894553499999995},{type:"text",text:"{VAL}",x:0,y:.3894553499999995}],ports:[{...Y3e.left1,labels:["1"]},{...Y3e.right1,labels:["2"]}],size:{width:_4.width,height:_4.height},center:{x:_4.centerX,y:_4.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),LRt=Ft(Hm).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1","neg"]).labelPort("right1",["2","pos"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:$Rt,texts:ier,bounds:A4,refblocks:H3e,circles:zRt}=Hm,qRt=Ft({primitives:[...Object.values($Rt),...Object.values(zRt),{type:"text",text:"{REF}",x:.15,y:-.2894553499999995},{type:"text",text:"{VAL}",x:-.15,y:-.2894553499999995}],ports:[{...H3e.left1,labels:["1"]},{...H3e.right1,labels:["2"]}],size:{width:A4.width,height:A4.height},center:{x:A4.centerX,y:A4.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:URt,texts:oer,bounds:R4,refblocks:W3e,circles:VRt}=Hm,GRt=Ft({primitives:[...Object.values(URt),...Object.values(VRt),{type:"text",text:"{REF}",x:.15,y:-.2894553499999995},{type:"text",text:"{VAL}",x:-.15,y:-.2894553499999995}],ports:[{...W3e.left1,labels:["1"]},{...W3e.right1,labels:["2"]}],size:{width:R4.width,height:R4.height},center:{x:R4.centerX,y:R4.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),Z6={paths:{path27:{type:"path",points:[{x:.52,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:.69},{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:-.72},{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:XRt,texts:uer,bounds:S4,refblocks:w4,circles:YRt}=Z6,HRt=Ft({primitives:[...Object.values(XRt),...Object.values(YRt),{type:"text",text:"{REF}",x:-.4,y:.4094554499999995},{type:"text",text:"{VAL}",x:.4,y:.4094553499999995}],ports:[{...w4.left1,labels:["1"]},{...w4.right1,labels:["3"]},{...w4.bottom1,labels:["2"]},{...w4.top1,labels:["4"]}],size:{width:S4.width,height:S4.height},center:{x:S4.centerX,y:S4.centerY}}).rotateRightFacingSymbol("down").changeTextAnchor("{REF}","bottom_left").changeTextAnchor("{VAL}","top_left").build(),WRt=Ft(Z6).labelPort("top1",["2","gnd1"]).labelPort("bottom1",["4","gnd2"]).labelPort("left1",["3"]).labelPort("right1",["1"]).changeTextAnchor("{REF}","bottom_left").changeTextAnchor("{VAL}","top_left").build(),KRt=Ft(Z6).labelPort("top1",["4","gnd1"]).labelPort("bottom1",["2","gnd2"]).labelPort("left1",["1"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","bottom_left").changeTextAnchor("{VAL}","top_left").build(),{paths:JRt,texts:cer,bounds:B4,refblocks:T4,circles:ZRt}=Z6,QRt=Ft({primitives:[...Object.values(JRt),...Object.values(ZRt),{type:"text",text:"{VAL}",x:-.4,y:-.4094554499999995},{type:"text",text:"{REF}",x:.4,y:-.4094553499999995}],ports:[{...T4.left1,labels:["1"]},{...T4.right1,labels:["3"]},{...T4.bottom1,labels:["2"]},{...T4.top1,labels:["4"]}],size:{width:B4.width,height:B4.height},center:{x:B4.centerX,y:B4.centerY}}).rotateRightFacingSymbol("up").changeTextAnchor("{REF}","bottom_left").changeTextAnchor("{VAL}","top_left").build(),Q6={paths:{path27:{type:"path",points:[{x:.52,y:-.01},{x:.13,y:-.01}],color:"primary",fill:!1},path28:{type:"path",points:[{x:-.14,y:-.01},{x:-.54,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:e5t,texts:ler,bounds:P4,refblocks:K3e,circles:t5t}=Q6,r5t=Ft({primitives:[...Object.values(e5t),...Object.values(t5t),{type:"text",text:"{REF}",x:-.3,y:.3094553499999995},{type:"text",text:"{VAL}",x:.3,y:.3094553499999995}],ports:[{...K3e.left1,labels:["1"]},{...K3e.right1,labels:["2"]}],size:{width:P4.width,height:P4.height},center:{x:P4.centerX,y:P4.centerY}}).changeTextAnchor("{VAL}","top_left").rotateRightFacingSymbol("down").labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{REF}","bottom_left").build(),n5t=Ft(Q6).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["2","neg"]).labelPort("right1",["1","pos"]).changeTextAnchor("{REF}","middle_bottom").build(),a5t=Ft(Q6).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:s5t,texts:der,bounds:I4,refblocks:J3e,circles:i5t}=Q6,o5t=Ft({primitives:[...Object.values(s5t),...Object.values(i5t),{type:"text",text:"{REF}",x:.3,y:-.3094553499999995},{type:"text",text:"{VAL}",x:-.3,y:-.3094553499999995}],ports:[{...J3e.left1,labels:["1"]},{...J3e.right1,labels:["2"]}],size:{width:I4.width,height:I4.height},center:{x:I4.centerX,y:I4.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("up").labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{REF}","bottom_left").build(),Wm={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.15}],color:"primary",fill:!1},"path12-1-5-3":{type:"path",points:[{x:2.23,y:-1.96},{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}}},u5t=Ft(Wm).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(),c5t=Ft(Wm).rotateRightFacingSymbol("right").labelPort("right2",["1"]).labelPort("right1",["2"]).labelPort("right3",["3"]).changeTextAnchor("{VAL}","middle_right").changeTextAnchor("{REF}","middle_right").build(),l5t=Ft(Wm).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(),d5t=Ft(Wm).rotateRightFacingSymbol("right").labelPort("right2",["1"]).labelPort("right1",["2"]).labelPort("right3",["3"]).changeTextAnchor("{VAL}","middle_right").changeTextAnchor("{REF}","middle_right").build(),p5t=Ft(Wm).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(),x5t=Ft(Wm).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(),f5t={paths:{path11:{type:"path",points:[{x:-.53,y:0},{x:-.3,y:0}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:0},{x:.53,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:h5t,texts:m5t,bounds:j4,refblocks:Z3e,circles:g5t}=f5t,bU=ea({primitives:[...Object.values(h5t),...Object.values(g5t),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"},{...m5t.left1,x:0,y:.01,anchor:"center",fontSize:.3}],ports:[{...Z3e.left1,labels:["1"]},{...Z3e.right1,labels:["2"]}],size:{width:j4.width,height:j4.height},center:{x:j4.centerX,y:j4.centerY}});({6:pU,2:xU,...b5t}=bU.primitives);y5t(xU)&&xU.points.map(n=>{n.y+=.05});D5t(pU)&&(pU.y+=.025);Q3e=ur({...bU,primitives:Object.values(b5t).filter(F5t)}),E5t={...Q3e,primitives:[...Q3e.primitives,pU,xU]},Km={paths:{path11:{type:"path",points:[{x:-.53,y:.04},{x:-.3,y:.04}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:.04},{x:.53,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:v5t,texts:per,bounds:N4,refblocks:eEe,circles:C5t}=Km,_5t=Ft({primitives:[...Object.values(v5t),...Object.values(C5t),{type:"text",text:"{REF}",x:-.15,y:.3894553499999995},{type:"text",text:"{VAL}",x:.15,y:.3894553499999995}],ports:[{...eEe.left1,labels:["1"]},{...eEe.right1,labels:["2"]}],size:{width:N4.width,height:N4.height},center:{x:N4.centerX,y:N4.centerY}}).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:A5t,texts:xer,bounds:k4,refblocks:tEe,circles:R5t}=Km,S5t=Ft({primitives:[...Object.values(A5t),...Object.values(R5t),{type:"text",text:"{REF}",x:-0,y:.3894553499999995},{type:"text",text:"{VAL}",x:0,y:-.3294553499999995}],ports:[{...tEe.left1,labels:["1"]},{...tEe.right1,labels:["2"]}],size:{width:k4.width,height:k4.height},center:{x:k4.centerX,y:k4.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:w5t,texts:fer,bounds:M4,refblocks:rEe,circles:B5t}=Km,T5t=Ft({primitives:[...Object.values(w5t),...Object.values(B5t),{type:"text",text:"{REF}",x:-0,y:-.3294553499999995},{type:"text",text:"{VAL}",x:0,y:.4294553499999995}],ports:[{...rEe.left1,labels:["1"]},{...rEe.right1,labels:["2"]}],size:{width:M4.width,height:M4.height},center:{x:M4.centerX,y:M4.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:P5t,texts:her,bounds:O4,refblocks:nEe,circles:I5t}=Km,j5t=Ft({primitives:[...Object.values(P5t),...Object.values(I5t),{type:"text",text:"{REF}",x:-0,y:.3894553499999995},{type:"text",text:"{VAL}",x:0,y:-.3294553499999995}],ports:[{...nEe.left1,labels:["1"]},{...nEe.right1,labels:["2"]}],size:{width:O4.width,height:O4.height},center:{x:O4.centerX,y:O4.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:N5t,texts:mer,bounds:L4,refblocks:aEe,circles:k5t}=Km,M5t=Ft({primitives:[...Object.values(N5t),...Object.values(k5t),{type:"text",text:"{REF}",x:.15,y:-.2894553499999995},{type:"text",text:"{VAL}",x:-.15,y:-.2894553499999995}],ports:[{...aEe.left1,labels:["1"]},{...aEe.right1,labels:["2"]}],size:{width:L4.width,height:L4.height},center:{x:L4.centerX,y:L4.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:O5t,texts:ger,bounds:$4,refblocks:sEe,circles:L5t}=Km,$5t=Ft({primitives:[...Object.values(O5t),...Object.values(L5t),{type:"text",text:"{REF}",x:.15,y:-.2894553499999995},{type:"text",text:"{VAL}",x:-.15,y:-.2894553499999995}],ports:[{...sEe.left1,labels:["1"]},{...sEe.right1,labels:["2"]}],size:{width:$4.width,height:$4.height},center:{x:$4.centerX,y:$4.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),Jm={paths:{path11:{type:"path",points:[{x:-.52,y:.04},{x:-.11,y:.04}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.1,y:.04},{x:.52,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}}},z5t=Ft(Jm).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(),q5t=Ft(Jm).rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom",{x:0,y:.1}).changeTextAnchor("{VAL}","middle_top").build(),U5t=Ft(Jm).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(),V5t=Ft(Jm).rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom",{x:0,y:.1}).changeTextAnchor("{VAL}","middle_top").build(),G5t=Ft(Jm).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(),X5t=Ft(Jm).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(),Y5t={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:{}},eR=Ft(Y5t).labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),H5t=ur(eR,"down"),W5t=ur(eR,"left"),K5t=ur(eR,"up"),J5t={paths:{path1:{type:"path",points:[{x:-.35,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:.35,y:.13}],color:"primary",fill:!1},path3:{type:"path",points:[{x:.12,y:.36},{x:.36,y:.36}],color:"primary",fill:!1},path4:{type:"path",points:[{x:-.35,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:.35,y:-.27}],color:"primary",fill:!1},path6:{type:"path",points:[{x:.12,y:-.04},{x:.36,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}}},tR=Ft(J5t).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(),FU=ur(tR,"down"),EU=FU.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),vU=FU.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");EU.anchor="middle_bottom";vU.anchor="middle_top";EU.x=0;EU.y+=.537;vU.y-=.5375;vU.x=0;Z5t=FU,CU=ur(tR,"left"),_U=CU.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),AU=CU.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");_U.anchor="middle_bottom";AU.anchor="middle_top";_U.x=0;_U.y+=1;AU.y-=1;AU.x=0;Q5t=CU,RU=ur(tR,"up"),SU=RU.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),wU=RU.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");SU.anchor="middle_bottom";wU.anchor="middle_top";SU.x=0;SU.y+=.537;wU.y-=.5375;wU.x=0;eSt=RU,tSt={paths:{path1:{type:"path",points:[{x:-.35,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:.35,y:.13}],color:"primary",fill:!1},path3:{type:"path",points:[{x:.12,y:.36},{x:.36,y:.36}],color:"primary",fill:!1},path4:{type:"path",points:[{x:-.35,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:.35,y:-.27}],color:"primary",fill:!1},path6:{type:"path",points:[{x:.12,y:-.04},{x:.36,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}}},rR=Ft(tSt).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(),BU=ur(rR,"down"),TU=BU.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),PU=BU.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");TU.anchor="middle_bottom";PU.anchor="middle_top";TU.x=0;TU.y+=.565;PU.y-=.555;PU.x=0;rSt=BU,IU=ur(rR,"left"),jU=IU.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),NU=IU.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");jU.anchor="middle_bottom";NU.anchor="middle_top";jU.x=0;jU.y+=1.09;NU.y-=1.09;NU.x=0;nSt=IU,kU=ur(rR,"up"),MU=kU.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),OU=kU.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");MU.anchor="middle_bottom";OU.anchor="middle_top";MU.x=0;MU.y+=.565;OU.y-=.555;OU.x=0;aSt=kU,sSt={paths:{path11:{type:"path",points:[{x:-.36,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:.37,y:.06}],color:"primary",fill:!1},"path11-5":{type:"path",points:[{x:-.36,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:.37,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}}},nR=Ft(sSt).labelPort("left1",["1"]).labelPort("right1",["2"]).labelPort("right3",["4"]).labelPort("left3",["3"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),LU=ur(nR,"down"),$U=LU.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),zU=LU.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");$U.anchor="middle_bottom";zU.anchor="middle_top";$U.x=.4;$U.y+=.265;zU.y-=.265;zU.x=.4;iSt=LU,qU=ur(nR,"left"),UU=qU.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),VU=qU.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");UU.anchor="middle_bottom";VU.anchor="middle_top";UU.x=0;UU.y+=.67;VU.y-=.67;VU.x=0;oSt=qU,GU=ur(nR,"up"),XU=GU.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),YU=GU.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");XU.anchor="middle_bottom";YU.anchor="middle_top";XU.x=.46;XU.y+=.265;YU.y-=.265;YU.x=.46;uSt=GU,cSt={paths:{path11:{type:"path",points:[{x:-.36,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:.37,y:.06}],color:"primary",fill:!1},"path11-5":{type:"path",points:[{x:-.36,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:.37,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}}},aR=Ft(cSt).labelPort("left1",["1"]).labelPort("right1",["2"]).labelPort("right3",["4"]).labelPort("left3",["3"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),HU=ur(aR,"down"),WU=HU.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),KU=HU.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");WU.anchor="middle_bottom";KU.anchor="middle_top";WU.x=.4;WU.y+=.295;KU.y-=.295;KU.x=.42;lSt=HU,JU=ur(aR,"left"),ZU=JU.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),QU=JU.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");ZU.anchor="middle_bottom";QU.anchor="middle_top";ZU.x=0;ZU.y+=.795;QU.y-=.795;QU.x=0;dSt=JU,eV=ur(aR,"up"),tV=eV.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),rV=eV.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");tV.anchor="middle_bottom";rV.anchor="middle_top";tV.x=.46;tV.y+=.315;rV.y-=.315;rV.x=.46;pSt=eV,bve={paths:{path5:{type:"path",points:[{x:-.42,y:0},{x:-.16,y:0}],color:"primary",fill:!1},path6:{type:"path",points:[{x:.17,y:0},{x:.43,y:0}],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:xSt,texts:yer,bounds:z4,refblocks:iEe,circles:fSt}=bve,Fve=Ft({primitives:[...Object.values(xSt),...Object.values(fSt),{type:"text",text:"{REF}",x:.18,y:-.3204553499999995},{type:"text",text:"{VAL}",x:-.25,y:-.3294553499999995}],ports:[{...iEe.left1,labels:["1"]},{...iEe.right1,labels:["2"]}],size:{width:z4.width,height:z4.height},center:{x:z4.centerX,y:z4.centerY}}).rotateRightFacingSymbol("up").labelPort("left",["1"]).labelPort("right",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),nV=X6(Fve),aV=nV.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),sV=nV.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");aV.anchor="middle_left";sV.anchor="middle_left";aV.y+=.4;aV.x=.32;sV.y-=.45;sV.x=.32;hSt=nV,Eve=Ft(bve).labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),mSt=gb(Eve),Zm={paths:{path11:{type:"path",points:[{x:-.54,y:.04},{x:-.22,y:.04}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.14,y:.05},{x:.46,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:gSt,texts:Der,bounds:q4,refblocks:oEe,circles:ySt}=Zm,DSt=Ft({primitives:[...Object.values(gSt),...Object.values(ySt),{type:"text",text:"{REF}",x:-.15,y:.3294553499999995},{type:"text",text:"{VAL}",x:.15,y:.3294553499999995}],ports:[{...oEe.left1,labels:["1"]},{...oEe.right1,labels:["2"]}],size:{width:q4.width,height:q4.height},center:{x:q4.centerX,y:q4.centerY}}).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:bSt,texts:ber,bounds:U4,refblocks:uEe,circles:FSt}=Zm,ESt=Ft({primitives:[...Object.values(bSt),...Object.values(FSt),{type:"text",text:"{REF}",x:-0,y:.4094553499999995},{type:"text",text:"{VAL}",x:0,y:-.4094553499999995}],ports:[{...uEe.left1,labels:["1"]},{...uEe.right1,labels:["2"]}],size:{width:U4.width,height:U4.height},center:{x:U4.centerX,y:U4.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:vSt,texts:Fer,bounds:V4,refblocks:cEe,circles:CSt}=Zm,_St=Ft({primitives:[...Object.values(vSt),...Object.values(CSt),{type:"text",text:"{REF}",x:-0,y:-.3094553499999995},{type:"text",text:"{VAL}",x:0,y:.4094553499999995}],ports:[{...cEe.left1,labels:["1"]},{...cEe.right1,labels:["2"]}],size:{width:V4.width,height:V4.height},center:{x:V4.centerX,y:V4.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:ASt,texts:Eer,bounds:G4,refblocks:lEe,circles:RSt}=Zm,SSt=Ft({primitives:[...Object.values(ASt),...Object.values(RSt),{type:"text",text:"{REF}",x:-0,y:.4094553499999995},{type:"text",text:"{VAL}",x:0,y:-.4094553499999995}],ports:[{...lEe.left1,labels:["1"]},{...lEe.right1,labels:["2"]}],size:{width:G4.width,height:G4.height},center:{x:G4.centerX,y:G4.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:wSt,texts:ver,bounds:X4,refblocks:dEe,circles:BSt}=Zm,TSt=Ft({primitives:[...Object.values(wSt),...Object.values(BSt),{type:"text",text:"{REF}",x:.15,y:-.2894553499999995},{type:"text",text:"{VAL}",x:-.15,y:-.2894553499999995}],ports:[{...dEe.left1,labels:["1"]},{...dEe.right1,labels:["2"]}],size:{width:X4.width,height:X4.height},center:{x:X4.centerX,y:X4.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:PSt,texts:Cer,bounds:Y4,refblocks:pEe,circles:ISt}=Zm,jSt=Ft({primitives:[...Object.values(PSt),...Object.values(ISt),{type:"text",text:"{REF}",x:.15,y:-.2894553499999995},{type:"text",text:"{VAL}",x:-.15,y:-.2894553499999995}],ports:[{...pEe.left1,labels:["1"]},{...pEe.right1,labels:["2"]}],size:{width:Y4.width,height:Y4.height},center:{x:Y4.centerX,y:Y4.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),NSt={paths:{path11:{type:"path",points:[{x:-.53,y:0},{x:-.3,y:0}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:0},{x:.53,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:kSt,texts:MSt,bounds:H4,refblocks:xEe,circles:OSt}=NSt,iV=ea({primitives:[...Object.values(kSt),...Object.values(OSt),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"},{...MSt.left1,x:0,y:.01,anchor:"center",fontSize:.2}],ports:[{...xEe.left1,labels:["1"]},{...xEe.right1,labels:["2"]}],size:{width:H4.width,height:H4.height},center:{x:H4.centerX,y:H4.centerY}}),{5:LSt,...$St}=iV.primitives;fEe=ur({...iV,primitives:Object.values($St).filter(zSt)}),qSt={...fEe,primitives:[...fEe.primitives,LSt]},USt={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:VSt,texts:GSt,bounds:W4,refblocks:hEe}=USt,vve=ea({primitives:[...Object.values(VSt),{...GSt.top1,anchor:"middle_bottom"},{type:"text",text:"{VAL}",x:0,y:-.2,anchor:"middle_top"}],ports:[{...hEe.left1,labels:["1"]},{...hEe.right1,labels:["2"]}],size:{width:W4.width,height:W4.height},center:{x:W4.centerX,y:W4.centerY}}),XSt=ur(vve),Qm={paths:{path1:{type:"path",points:[{x:-.29,y:0},{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:{}},YSt=Ft(Qm).rotateRightFacingSymbol("down").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_top").build(),HSt=Ft(Qm).rotateRightFacingSymbol("right").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_left").build(),WSt=Ft(Qm).rotateRightFacingSymbol("left").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_right").build(),KSt=Ft(Qm).rotateRightFacingSymbol("right").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_left").build(),JSt=Ft(Qm).rotateRightFacingSymbol("up").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_bottom").build(),ZSt=Ft(Qm).rotateRightFacingSymbol("up").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_bottom").build(),sR={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:QSt,texts:_er,bounds:mEe,refblocks:ewt}=sR,twt=Ft({primitives:[...Object.values(QSt),{type:"text",text:"{REF}",x:-.14,y:0}],ports:[{...ewt.left1,labels:["1"]}],center:{x:mEe.centerX,y:mEe.centerY}}).rotateRightFacingSymbol("down").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:rwt,texts:Aer,bounds:gEe,refblocks:nwt,circles:awt}=sR,swt=Ft({primitives:[...Object.values(rwt),...Object.values(awt),{type:"text",text:"{REF}",x:-.14,y:-0}],ports:[{...nwt.left1,labels:["1"]}],center:{x:gEe.centerX,y:gEe.centerY}}).rotateRightFacingSymbol("left").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_left").build(),{paths:iwt,texts:Rer,bounds:yEe,refblocks:owt,circles:uwt}=sR,cwt=Ft({primitives:[...Object.values(iwt),...Object.values(uwt),{type:"text",text:"{REF}",x:-.13,y:0}],ports:[{...owt.left1,labels:["1"]}],center:{x:yEe.centerX,y:yEe.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_right").build(),{paths:lwt,texts:Ser,bounds:DEe,refblocks:dwt,circles:pwt}=sR,xwt=Ft({primitives:[...Object.values(lwt),...Object.values(pwt),{type:"text",text:"{REF}",x:-.14,y:-0}],ports:[{...dwt.left1,labels:["1"]}],center:{x:DEe.centerX,y:DEe.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_top").build(),oV={paths:{path11:{type:"path",points:[{x:-.5,y:.04},{x:-.18,y:.04}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.19,y:.04},{x:.51,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:wer,texts:Ber,bounds:Ter,refblocks:Per,circles:Ier}=oV,fwt=Ft(oV).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),hwt=Ft(oV).rotateRightFacingSymbol("down").changeTextAnchor("{VAL}","middle_right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").build(),mwt={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:{}},iR=Ft(mwt).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(),gwt=ur(iR,"down"),ywt=gb(iR),uV=ur(iR,"up"),cV=uV.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),lV=uV.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");cV.anchor="middle_left";lV.anchor="middle_left";cV.y+=.21;cV.x=.44;lV.y-=.21;lV.x=.44;Dwt=uV,bwt={paths:{path11:{type:"path",points:[{x:-.39,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:-.54}],color:"primary",fill:!1},"path12-1":{type:"path",points:[{x:.28,y:.54},{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}}},Cve=Ft(bwt).changeTextAnchor("{VAL}","middle_right").labelPort("left1",["3"]).labelPort("top1",["2"]).labelPort("bottom1",["1"]).changeTextAnchor("{REF}","middle_right").build(),dV=ur(Cve),pV=dV.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),_ve=dV.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");pV.anchor="middle_left";_ve.anchor="middle_right";pV.x=.45;pV.y+=.065;_ve.y+=.065;Fwt=dV,Ewt={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:-.49,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:.49,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}}},Ave=Ft(Ewt).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),Rve=ur(Ave),Sve=Rve.primitives.filter(n=>n.type==="text"),xV=Sve.find(n=>n.text==="{VAL}");xV.x=-.35;xV.y=0;xV.anchor="middle_right";fV=Sve.find(n=>n.text==="{REF}");fV.y=0;fV.x=.35;fV.anchor="middle_left";vwt=Rve,Cwt={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:-.53,y:-.02}],color:"primary",fill:!1},"path8706-5":{type:"path",points:[{x:.53,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:_wt,texts:bEe,bounds:K4,refblocks:FEe,circles:Awt}=Cwt,hV=ea({primitives:[...Object.values(_wt),...Object.values(Awt),{...bEe.top1,anchor:"middle_bottom"},{...bEe.bottom1,anchor:"middle_top"}],ports:[{...FEe.left1,labels:["1"]},{...FEe.right1,labels:["2"]}],size:{width:K4.width,height:K4.height},center:{x:K4.centerX,y:K4.centerY}}),wve=ur(hV,"up"),Rwt=X6(wve),Swt=gb(hV),Bve={paths:{path11:{type:"path",points:[{x:-.53,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:.53,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}}};Bve.bounds.width+=.2;oR=Ft(Bve).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),mV=ur(oR,"down"),gV=mV.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),yV=mV.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");gV.anchor="middle_left";yV.anchor="middle_left";gV.y+=.9;gV.x=.3;yV.y-=.1;yV.x=.3;wwt=mV,DV=ur(oR,"left"),bV=DV.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),FV=DV.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");bV.anchor="middle_left";FV.anchor="middle_left";bV.y+=.71;bV.x=.44;FV.y-=.71;FV.x=.44;Bwt=DV,EV=ur(oR,"up"),vV=EV.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),CV=EV.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");vV.anchor="middle_left";CV.anchor="middle_left";vV.y+=.1;vV.x=.3;CV.y-=.71;CV.x=.3;Twt=EV,Pwt={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:.53,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:-.53,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:Iwt,texts:EEe,bounds:J4,refblocks:vEe,circles:jwt}=Pwt,_V=ea({primitives:[...Object.values(Iwt),...Object.values(jwt),{...EEe.bottom1,anchor:"middle_top"},{...EEe.right1,anchor:"middle_bottom"}],ports:[{...vEe.left1,labels:["1"]},{...vEe.right1,labels:["2"]}],size:{width:J4.width,height:J4.height},center:{x:J4.centerX,y:J4.centerY}}),AV=ur(_V,"up"),RV=AV.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),SV=AV.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");RV.anchor="middle_left";SV.anchor="middle_left";RV.y+=.21;RV.x=.21;SV.y-=.21;SV.x=.21;Tve=AV,wV=X6(Tve),BV=wV.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),TV=wV.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");BV.anchor="middle_left";TV.anchor="middle_left";BV.y+=.4;BV.x=.2;TV.y-=.41;TV.x=.2;Nwt=wV,kwt=gb(_V),Mwt={paths:{path11:{type:"path",points:[{x:-.51,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:.51,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:Owt,texts:CEe,bounds:Z4,refblocks:_Ee,circles:Lwt}=Mwt,Pve=ea({primitives:[...Object.values(Owt),...Object.values(Lwt),{...CEe.top1,anchor:"middle_left",x:0},{...CEe.bottom1,anchor:"middle_left",x:0}],ports:[{..._Ee.left1,labels:["1"]},{..._Ee.right1,labels:["2"]}],size:{width:Z4.width,height:Z4.height},center:{x:Z4.centerX,y:Z4.centerY}}),Ive=ur(Pve),jve=Ive.primitives.filter(n=>n.type==="text"),PV=jve.find(n=>n.text==="{VAL}");PV.x=-.35;PV.y=0;PV.anchor="middle_right";IV=jve.find(n=>n.text==="{REF}");IV.y=0;IV.x=.35;IV.anchor="middle_left";$wt=Ive,zwt={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:.53},{x:.12,y:.18}],color:"primary",fill:!1},path215:{type:"path",points:[{x:.12,y:-.53},{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:qwt,texts:AEe,bounds:Q4,refblocks:qq}=zwt,Nve=ea({primitives:[...Object.values(qwt),{...AEe.right1,anchor:"middle_left"},{...AEe.right2,anchor:"middle_left"}],ports:[{...qq.top1,labels:["1"]},{...qq.bottom1,labels:["2"]},{...qq.left1,labels:["3"]}],size:{width:Q4.width+.4,height:Q4.height},center:{x:Q4.centerX+.2,y:Q4.centerY}}),jV=ur(Nve),kve=jV.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),NV=jV.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");kve.anchor="middle_top";NV.anchor="middle_top";kve.x=NV.x;NV.y+=.15;Uwt=jV,Vwt={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:-.49,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:.49,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:Gwt,texts:REe,bounds:e6,refblocks:SEe,circles:Xwt}=Vwt,Mve=ea({primitives:[...Object.values(Gwt),...Object.values(Xwt),{...REe.top1,anchor:"middle_bottom",x:0},{...REe.bottom1,anchor:"middle_top",x:0}],ports:[{...SEe.left1,labels:["1"]},{...SEe.right1,labels:["2"]}],size:{width:e6.width,height:e6.height},center:{x:e6.centerX+.006,y:e6.centerY+.06}}),kV=ur(Mve),mb=kV.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),U6=kV.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");mb.anchor="middle_left";U6.anchor="middle_right";mb.x=mb.x-.03;mb.y=mb.y;U6.x=U6.x;U6.y=0;Ywt=kV,Hwt={paths:{path11:{type:"path",points:[{x:-.39,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:.53},{x:.3,y:.11}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:.31,y:-.53},{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:Wwt,texts:wEe,bounds:t6,refblocks:Uq,circles:Kwt}=Hwt,Ove=ea({primitives:[...Object.values(Wwt),...Object.values(Kwt),{...wEe.top1,anchor:"middle_right",x:0},{...wEe.bottom1,anchor:"middle_right",x:0}],ports:[{...Uq.top1,labels:["1","drain"]},{...Uq.bottom1,labels:["2","source"]},{...Uq.left1,labels:["3","gate"]}],size:{width:t6.width,height:t6.height},center:{x:t6.centerX,y:t6.centerY}}),Lve=ur(Ove),$ve=Lve.primitives.filter(n=>n.type==="text"),MV=$ve.find(n=>n.text==="{VAL}");MV.x=-.35;MV.y=0;MV.anchor="middle_right";OV=$ve.find(n=>n.text==="{REF}");OV.y=0;OV.x=.35;OV.anchor="middle_left";Jwt=Lve,Zwt={paths:{path11:{type:"path",points:[{x:-.39,y:-.1},{x:.05,y:-.11}],color:"primary",fill:!1},"path12-1":{type:"path",points:[{x:.3,y:.53},{x:.3,y:.11}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:.31,y:-.53},{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:Qwt,texts:BEe,bounds:r6,refblocks:Vq,circles:e9t}=Zwt,zve=ea({primitives:[...Object.values(Qwt),...Object.values(e9t),{...BEe.top1,anchor:"middle_right",x:0},{...BEe.bottom1,anchor:"middle_right",x:0}],ports:[{...Vq.top1,labels:["1","drain"]},{...Vq.bottom1,labels:["2","source"]},{...Vq.left1,labels:["3","gate"]}],size:{width:r6.width,height:r6.height},center:{x:r6.centerX,y:r6.centerY}}),qve=ur(zve),Uve=qve.primitives.filter(n=>n.type==="text"),LV=Uve.find(n=>n.text==="{VAL}");LV.x=-.35;LV.y=0;LV.anchor="middle_right";$V=Uve.find(n=>n.text==="{REF}");$V.y=0;$V.x=.35;$V.anchor="middle_left";t9t=qve,r9t={paths:{path11:{type:"path",points:[{x:-.39,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:.53},{x:.28,y:.11}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:.29,y:-.53},{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:n9t,texts:TEe,bounds:n6,refblocks:Gq,circles:a9t}=r9t,Vve=ea({primitives:[...Object.values(n9t),...Object.values(a9t),{...TEe.top1,anchor:"middle_right",x:0},{...TEe.bottom1,anchor:"middle_right",x:0}],ports:[{...Gq.top1,labels:["1","drain"]},{...Gq.bottom1,labels:["2","source"]},{...Gq.left1,labels:["3","gate"]}],size:{width:n6.width,height:n6.height},center:{x:n6.centerX,y:n6.centerY}}),Gve=ur(Vve),Xve=Gve.primitives.filter(n=>n.type==="text"),zV=Xve.find(n=>n.text==="{VAL}");zV.x=-.35;zV.y=0;zV.anchor="middle_right";qV=Xve.find(n=>n.text==="{REF}");qV.y=0;qV.x=.35;qV.anchor="middle_left";s9t=Gve,i9t={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:o9t,bounds:PEe,refblocks:u9t}=i9t,uR=Ft({primitives:[...Object.values(o9t)],ports:[{...u9t.left1,labels:["1"]}],center:{x:PEe.centerX,y:PEe.centerY}}).rotateRightFacingSymbol("right").labelPort("left1",["1"]).build(),c9t=ur(uR,"down"),l9t=ur(uR,"left"),d9t=ur(uR,"up"),Jf={paths:{path11:{type:"path",points:[{x:-.39,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:.54}],color:"primary",fill:!1},"path12-1-5-3":{type:"path",points:[{x:.29,y:-.54},{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:p9t,texts:jer,bounds:a6,refblocks:Xq,circles:x9t}=Jf,f9t=Ft({primitives:[...Object.values(p9t),...Object.values(x9t),{type:"text",text:"{REF}",x:-.1,y:.3094553499999995},{type:"text",text:"{VAL}",x:-.1,y:-.3094553499999995}],ports:[{...Xq.top1,labels:["1","collector"]},{...Xq.bottom1,labels:["2","emitter"]},{...Xq.left1,labels:["3","base"]}],size:{width:a6.width,height:a6.height},center:{x:a6.centerX,y:a6.centerY}}).rotateRightFacingSymbol("right").changeTextAnchor("{REF}","middle_right").changeTextAnchor("{VAL}","middle_right").build(),{paths:Ner,texts:ker,bounds:Mer,refblocks:Oer,circles:Ler}=Jf,h9t=Ft(Jf).rotateRightFacingSymbol("up").changeTextAnchor("{VAL}","middle_left").labelPort("left1",["3","base"]).labelPort("top1",["1","collector"]).labelPort("bottom1",["2","emitter"]).changeTextAnchor("{REF}","middle_right").build(),{paths:m9t,texts:$er,bounds:s6,refblocks:Yq,circles:g9t}=Jf,y9t=Ft({primitives:[...Object.values(m9t),...Object.values(g9t),{type:"text",text:"{REF}",x:-.1,y:-.3094553499999995},{type:"text",text:"{VAL}",x:-.1,y:.3094553499999995}],ports:[{...Yq.top1,labels:["1","collector"]},{...Yq.bottom1,labels:["2","emitter"]},{...Yq.left1,labels:["3","base"]}],size:{width:s6.width,height:s6.height},center:{x:s6.centerX,y:s6.centerY}}).rotateRightFacingSymbol("down").changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_bottom").build(),{paths:D9t,texts:zer,bounds:i6,refblocks:Hq,circles:b9t}=Jf,F9t=Ft({primitives:[...Object.values(D9t),...Object.values(b9t),{type:"text",text:"{REF}",x:-.1,y:-.3094553499999995},{type:"text",text:"{VAL}",x:-.1,y:.3094553499999995}],ports:[{...Hq.top1,labels:["1","collector"]},{...Hq.bottom1,labels:["2","emitter"]},{...Hq.left1,labels:["3","base"]}],size:{width:i6.width,height:i6.height},center:{x:i6.centerX,y:i6.centerY}}).rotateRightFacingSymbol("up").changeTextAnchor("{REF}","middle_top").changeTextAnchor("{VAL}","middle_top").build(),{paths:E9t,texts:qer,bounds:o6,refblocks:Wq,circles:v9t}=Jf,C9t=Ft({primitives:[...Object.values(E9t),...Object.values(v9t),{type:"text",text:"{REF}",x:-.1,y:-.3094553499999995},{type:"text",text:"{VAL}",x:-.1,y:.3094553499999995}],ports:[{...Wq.top1,labels:["1","collector"]},{...Wq.bottom1,labels:["2","emitter"]},{...Wq.left1,labels:["3","base"]}],size:{width:o6.width,height:o6.height},center:{x:o6.centerX,y:o6.centerY}}).rotateRightFacingSymbol("left").changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:_9t,texts:Uer,bounds:u6,refblocks:Kq,circles:A9t}=Jf,R9t=Ft({primitives:[...Object.values(_9t),...Object.values(A9t),{type:"text",text:"{REF}",x:-.1,y:-.3094553499999995},{type:"text",text:"{VAL}",x:-.1,y:.3094553499999995}],ports:[{...Kq.top1,labels:["1","collector"]},{...Kq.bottom1,labels:["2","emitter"]},{...Kq.left1,labels:["3","base"]}],size:{width:u6.width,height:u6.height},center:{x:u6.centerX,y:u6.centerY}}).rotateRightFacingSymbol("left").changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),S9t={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:-.58,y:.18}],color:"primary",fill:!1},path45:{type:"path",points:[{x:-.32,y:-.09},{x:-.58,y:-.09}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.42,y:.04},{x:.15,y:.04}],color:"primary",fill:!1},"rect1577-3":{type:"path",points:[{x:-.2,y:.18},{x:-.27,y:.18}],color:"primary",fill:!0},"rect1577-4":{type:"path",points:[{x:-.2,y:-.09},{x:-.27,y:-.09}],color:"primary",fill:!0},"rect1577-4-7":{type:"path",points:[{x:-.23,y:-.05},{x:-.23,y:-.12}],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:{}},cR=Ft(S9t).labelPort("left1",["1","inp1"]).labelPort("left2",["2","inp2"]).labelPort("right1",["3","out"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),w9t=ur(cR,"down"),B9t=ur(cR,"left"),T9t=ur(cR,"up"),P9t={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:-.58,y:.18}],color:"primary",fill:!1},path45:{type:"path",points:[{x:-.32,y:-.09},{x:-.58,y:-.09}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.42,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:-.2,y:.18},{x:-.27,y:.18}],color:"primary",fill:!0},"rect1577-4":{type:"path",points:[{x:-.2,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:{}},lR=Ft(P9t).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(),I9t=ur(lR,"down"),j9t=ur(lR,"left"),N9t=ur(lR,"up"),k9t={paths:{path11:{type:"path",points:[{x:-.39,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:.53},{x:.3,y:.11}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:.31,y:-.53},{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:M9t,texts:IEe,bounds:c6,refblocks:Jq,circles:O9t}=k9t,Yve=ea({primitives:[...Object.values(M9t),...Object.values(O9t),{...IEe.top1,anchor:"middle_right",x:0},{...IEe.bottom1,anchor:"middle_right",x:0}],ports:[{...Jq.top1,labels:["1","drain"]},{...Jq.bottom1,labels:["2","source"]},{...Jq.left1,labels:["3","gate"]}],size:{width:c6.width,height:c6.height},center:{x:c6.centerX,y:c6.centerY}}),Hve=ur(Yve),Wve=Hve.primitives.filter(n=>n.type==="text"),UV=Wve.find(n=>n.text==="{VAL}");UV.x=-.35;UV.y=0;UV.anchor="middle_right";VV=Wve.find(n=>n.text==="{REF}");VV.y=0;VV.x=.35;VV.anchor="middle_left";L9t=Hve,$9t={paths:{path11:{type:"path",points:[{x:-.39,y:-.1},{x:.05,y:-.11}],color:"primary",fill:!1},"path12-1":{type:"path",points:[{x:.3,y:.53},{x:.3,y:.11}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:.31,y:-.53},{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:z9t,texts:jEe,bounds:l6,refblocks:Zq,circles:q9t}=$9t,Kve=ea({primitives:[...Object.values(z9t),...Object.values(q9t),{...jEe.top1,anchor:"middle_right",x:0},{...jEe.bottom1,anchor:"middle_right",x:0}],ports:[{...Zq.top1,labels:["1","drain"]},{...Zq.bottom1,labels:["2","source"]},{...Zq.left1,labels:["3","gate"]}],size:{width:l6.width,height:l6.height},center:{x:l6.centerX,y:l6.centerY}}),Jve=ur(Kve),Zve=Jve.primitives.filter(n=>n.type==="text"),GV=Zve.find(n=>n.text==="{VAL}");GV.x=-.35;GV.y=0;GV.anchor="middle_right";XV=Zve.find(n=>n.text==="{REF}");XV.y=0;XV.x=.35;XV.anchor="middle_left";U9t=Jve,V9t={paths:{path11:{type:"path",points:[{x:-.53,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:.53,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}}},Qve=Ft(V9t).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),eCe=ur(Qve),G9t=eCe.primitives.filter(n=>n.type==="text"),tCe=G9t.find(n=>n.text==="{REF}");tCe.y=0;tCe.anchor="middle_left";X9t=eCe,Y9t={paths:{path11:{type:"path",points:[{x:-.39,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:.53},{x:.28,y:.11}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:.29,y:-.53},{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:H9t,texts:NEe,bounds:d6,refblocks:Qq,circles:W9t}=Y9t,rCe=ea({primitives:[...Object.values(H9t),...Object.values(W9t),{...NEe.top1,anchor:"middle_right",x:0},{...NEe.bottom1,anchor:"middle_right"}],ports:[{...Qq.top1,labels:["1","drain"]},{...Qq.bottom1,labels:["2","source"]},{...Qq.left1,labels:["3","gate"]}],size:{width:d6.width,height:d6.height},center:{x:d6.centerX,y:d6.centerY}}),nCe=ur(rCe),aCe=nCe.primitives.filter(n=>n.type==="text"),YV=aCe.find(n=>n.text==="{VAL}");YV.x=-.35;YV.y=0;YV.anchor="middle_right";HV=aCe.find(n=>n.text==="{REF}");HV.y=0;HV.x=.35;HV.anchor="middle_left";K9t=nCe,Zf={paths:{path11:{type:"path",points:[{x:-.39,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:.54}],color:"primary",fill:!1},"path12-1-5-3":{type:"path",points:[{x:.29,y:-.54},{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:J9t,texts:Ver,bounds:p6,refblocks:eU,circles:Z9t}=Zf,Q9t=Ft({primitives:[...Object.values(J9t),...Object.values(Z9t),{type:"text",text:"{REF}",x:-.1,y:.3094553499999995},{type:"text",text:"{VAL}",x:-.1,y:-.3094553499999995}],ports:[{...eU.top1,labels:["1","collector"]},{...eU.bottom1,labels:["2","emitter"]},{...eU.left1,labels:["3","base"]}],size:{width:p6.width,height:p6.height},center:{x:p6.centerX,y:p6.centerY}}).rotateRightFacingSymbol("right").changeTextAnchor("{REF}","middle_right").changeTextAnchor("{VAL}","middle_right").build(),{paths:Ger,texts:Xer,bounds:Yer,refblocks:Her,circles:Wer}=Zf,eBt=Ft(Zf).rotateRightFacingSymbol("up").changeTextAnchor("{VAL}","middle_left").labelPort("left1",["3","base"]).labelPort("top1",["1","collector"]).labelPort("bottom1",["2","emitter"]).changeTextAnchor("{REF}","middle_right").build(),{paths:tBt,texts:Ker,bounds:x6,refblocks:tU,circles:rBt}=Zf,nBt=Ft({primitives:[...Object.values(tBt),...Object.values(rBt),{type:"text",text:"{REF}",x:-.1,y:-.3094553499999995},{type:"text",text:"{VAL}",x:-.1,y:.3094553499999995}],ports:[{...tU.top1,labels:["1","collector"]},{...tU.bottom1,labels:["2","emitter"]},{...tU.left1,labels:["3","base"]}],size:{width:x6.width,height:x6.height},center:{x:x6.centerX,y:x6.centerY}}).rotateRightFacingSymbol("down").changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_bottom").build(),{paths:aBt,texts:Jer,bounds:f6,refblocks:rU,circles:sBt}=Zf,iBt=Ft({primitives:[...Object.values(aBt),...Object.values(sBt),{type:"text",text:"{REF}",x:-.1,y:-.3094553499999995},{type:"text",text:"{VAL}",x:-.1,y:.3094553499999995}],ports:[{...rU.top1,labels:["1","collector"]},{...rU.bottom1,labels:["2","emitter"]},{...rU.left1,labels:["3","base"]}],size:{width:f6.width,height:f6.height},center:{x:f6.centerX,y:f6.centerY}}).rotateRightFacingSymbol("up").changeTextAnchor("{REF}","middle_top").changeTextAnchor("{VAL}","middle_top").build(),{paths:oBt,texts:Zer,bounds:h6,refblocks:nU,circles:uBt}=Zf,cBt=Ft({primitives:[...Object.values(oBt),...Object.values(uBt),{type:"text",text:"{REF}",x:-.1,y:-.3094553499999995},{type:"text",text:"{VAL}",x:-.1,y:.3094553499999995}],ports:[{...nU.top1,labels:["1","collector"]},{...nU.bottom1,labels:["2","emitter"]},{...nU.left1,labels:["3","base"]}],size:{width:h6.width,height:h6.height},center:{x:h6.centerX,y:h6.centerY}}).rotateRightFacingSymbol("left").changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:lBt,texts:Qer,bounds:m6,refblocks:aU,circles:dBt}=Zf,pBt=Ft({primitives:[...Object.values(lBt),...Object.values(dBt),{type:"text",text:"{REF}",x:-.1,y:-.3094553499999995},{type:"text",text:"{VAL}",x:-.1,y:.3094553499999995}],ports:[{...aU.top1,labels:["1","collector"]},{...aU.bottom1,labels:["2","emitter"]},{...aU.left1,labels:["3","base"]}],size:{width:m6.width,height:m6.height},center:{x:m6.centerX,y:m6.centerY}}).rotateRightFacingSymbol("left").changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),xBt={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:-.51,y:.01}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:-.01,y:.51},{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:.5,y:.01},{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:.01,y:-.51}],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:fBt,texts:kEe,bounds:g6,refblocks:MEe}=xBt,sCe=ea({primitives:[...Object.values(fBt),{...kEe.bottom1,y:.35,anchor:"middle_top"},{...kEe.top1,anchor:"middle_left"}],ports:[{...MEe.left1,labels:["1"]},{...MEe.right1,labels:["2"]}],size:{width:g6.width+.05,height:g6.height},center:{x:g6.centerX,y:g6.centerY}}),hBt=ur(sCe),mBt=hBt,gBt={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:yBt,texts:OEe,bounds:y6,refblocks:LEe}=gBt,dR=ea({primitives:[...Object.values(yBt),{...OEe.bottom1,x:0,y:-.35,anchor:"middle_top"},{...OEe.top1,x:0,y:.35,anchor:"middle_bottom"}],ports:[{...LEe.left1,labels:["1"]},{...LEe.right1,labels:["2"]}],size:{width:y6.width+.05,height:y6.height},center:{x:y6.centerX,y:y6.centerY}}),WV=ur(dR,"down"),KV=WV.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),JV=WV.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");KV.anchor="middle_left";JV.anchor="middle_left";KV.y+=.31;KV.x=.34;JV.y-=.31;JV.x=.34;DBt=WV,ZV=ur(dR,"left"),QV=ZV.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),eG=ZV.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");QV.anchor="middle_bottom";eG.anchor="middle_top";QV.y+=.73;QV.x=0;eG.y-=.7;eG.x=0;bBt=ZV,tG=ur(dR,"up"),rG=tG.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),nG=tG.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");rG.anchor="middle_left";nG.anchor="middle_left";rG.y+=.21;rG.x=.34;nG.y-=.21;nG.x=.34;FBt=tG,pR={paths:{path1:{type:"path",points:[{x:-.4,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:.4,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:EBt,texts:etr,bounds:D6,refblocks:sU,circles:vBt}=pR,CBt=Ft({primitives:[...Object.values(EBt),...Object.values(vBt),{type:"text",text:"{REF}",x:-.15,y:.2394553499999995},{type:"text",text:"{VAL}",x:.15,y:.2394553499999995}],ports:[{...sU.left,labels:["1"]},{...sU.right,labels:["2"]},{...sU.bottom,labels:["3"]}],size:{width:D6.width,height:D6.height},center:{x:D6.centerX,y:D6.centerY}}).rotateRightFacingSymbol("down").labelPort("left",["1"]).labelPort("right",["2"]).labelPort("bottom",["3"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:_Bt,texts:ttr,bounds:b6,refblocks:iU,circles:ABt}=pR,RBt=Ft({primitives:[...Object.values(_Bt),...Object.values(ABt),{type:"text",text:"{REF}",x:-.3,y:-.3894553499999995},{type:"text",text:"{VAL}",x:-.3,y:.3194553499999995}],ports:[{...iU.left,labels:["1"]},{...iU.right,labels:["2"]},{...iU.bottom,labels:["3"]}],size:{width:b6.width,height:b6.height},center:{x:b6.centerX,y:b6.centerY}}).rotateRightFacingSymbol("left").labelPort("left",["1"]).labelPort("right",["2"]).labelPort("bottom",["3"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),SBt=Ft(pR).labelPort("left",["1"]).labelPort("right",["2"]).labelPort("bottom",["3"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),{paths:wBt,texts:rtr,bounds:F6,refblocks:oU,circles:BBt}=pR,TBt=Ft({primitives:[...Object.values(wBt),...Object.values(BBt),{type:"text",text:"{REF}",x:.3,y:-.2894553499999995},{type:"text",text:"{VAL}",x:-.3,y:-.2894553499999995}],ports:[{...oU.left,labels:["1"]},{...oU.right,labels:["2"]},{...oU.bottom,labels:["3"]}],size:{width:F6.width,height:F6.height},center:{x:F6.centerX,y:F6.centerY}}).rotateRightFacingSymbol("up").labelPort("left",["1"]).labelPort("right",["2"]).labelPort("bottom",["3"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),PBt={paths:{path11:{type:"path",points:[{x:-.53,y:.03},{x:-.3,y:.03}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:.03},{x:.53,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:IBt,texts:ntr,bounds:E6,refblocks:$Ee,circles:jBt}=PBt,iCe=ea({primitives:[...Object.values(IBt),...Object.values(jBt),{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:[{...$Ee.left1,labels:["1"]},{...$Ee.right1,labels:["2"]}],size:{width:E6.width,height:E6.height},center:{x:E6.centerX,y:E6.centerY}}),oCe=ur(iCe),aG=oCe.primitives.filter(n=>n.type==="text"),sG=aG.find(n=>n.text==="{REF}"),iG=aG.find(n=>n.text==="{VAL}"),oG=aG.find(n=>n.text==="COS \u03C6");sG.x=.35;sG.y=0;sG.anchor="middle_left";iG.anchor="middle_right";iG.x=-.35;iG.y=0;oG.x=0;oG.y=0;oG.anchor="center";NBt=oCe,kBt={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:-.49,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:.49,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:MBt,texts:zEe,bounds:v6,refblocks:qEe,circles:OBt}=kBt,uCe=ea({primitives:[...Object.values(MBt),...Object.values(OBt),{...zEe.top1,anchor:"middle_left"},{...zEe.bottom1,anchor:"middle_left"}],ports:[{...qEe.left1,labels:["1"]},{...qEe.right1,labels:["2"]}],size:{width:v6.width,height:v6.height},center:{x:v6.centerX,y:v6.centerY}}),LBt=ur(uCe,"up"),$Bt={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:-.49,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:.49,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:zBt,texts:UEe,bounds:C6,refblocks:VEe,circles:qBt}=$Bt,cCe=ea({primitives:[...Object.values(zBt),...Object.values(qBt),{...UEe.top1,anchor:"middle_left"},{...UEe.bottom1,anchor:"middle_left"}],ports:[{...VEe.left1,labels:["1"]},{...VEe.right1,labels:["2"]}],size:{width:C6.width,height:C6.height},center:{x:C6.centerX,y:C6.centerY}}),UBt=ur(cCe,"up"),VBt={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:-.51,y:-.01}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:-.01,y:-.51},{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:.5,y:-.01},{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:.01,y:.51}],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:GBt,texts:GEe,bounds:_6,refblocks:A6,circles:XBt}=VBt,lCe=ea({primitives:[...Object.values(GBt),...Object.values(XBt),{...GEe.top1,anchor:"middle_right"},{...GEe.bottom1,anchor:"middle_right"}],ports:[{...A6.top1,labels:["1"]},{...A6.bottom1,labels:["2"]},{...A6.left1,labels:["3"]},{...A6.right1,labels:["4"]}],size:{width:_6.width,height:_6.height},center:{x:_6.centerX,y:_6.centerY}}),uG=ur(lCe),YBt=uG.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),HBt=uG.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");YBt.anchor="middle_left";HBt.anchor="middle_right";WBt=uG,xR={paths:{path27:{type:"path",points:[{x:.46,y:.04},{x:.21,y:.04}],color:"primary",fill:!1},"path27-0":{type:"path",points:[{x:-.21,y:.04},{x:-.46,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:KBt,texts:atr,bounds:R6,refblocks:XEe,circles:JBt}=xR,ZBt=Ft({primitives:[...Object.values(KBt),...Object.values(JBt),{type:"text",text:"{REF}",x:-.2,y:.2194553499999995},{type:"text",text:"{VAL}",x:.2,y:.2194553499999995}],ports:[{...XEe.left1,labels:["1"]},{...XEe.right1,labels:["2"]}],size:{width:R6.width,height:R6.height},center:{x:R6.centerX,y:R6.centerY}}).rotateRightFacingSymbol("down").labelPort("left",["1"]).labelPort("right",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:QBt,texts:str,bounds:S6,refblocks:YEe,circles:e7t}=xR,t7t=Ft({primitives:[...Object.values(QBt),...Object.values(e7t),{type:"text",text:"{REF}",x:0,y:-.1704553499999995},{type:"text",text:"{VAL}",x:0,y:.2294553499999995}],ports:[{...YEe.left1,labels:["1"]},{...YEe.right1,labels:["2"]}],size:{width:S6.width,height:S6.height},center:{x:S6.centerX,y:S6.centerY}}).rotateRightFacingSymbol("left").labelPort("left",["1"]).labelPort("right",["2"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),{paths:r7t,texts:itr,bounds:w6,refblocks:HEe,circles:n7t}=xR,a7t=Ft({primitives:[...Object.values(r7t),...Object.values(n7t),{type:"text",text:"{REF}",x:0,y:.2294553499999995},{type:"text",text:"{VAL}",x:0,y:-.1704553499999995}],ports:[{...HEe.left1,labels:["1"]},{...HEe.right1,labels:["2"]}],size:{width:w6.width,height:w6.height},center:{x:w6.centerX,y:w6.centerY}}).rotateRightFacingSymbol("right").labelPort("left",["1"]).labelPort("right",["2"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),{paths:s7t,texts:otr,bounds:B6,refblocks:WEe,circles:i7t}=xR,o7t=Ft({primitives:[...Object.values(s7t),...Object.values(i7t),{type:"text",text:"{REF}",x:.2,y:-.1404553499999995},{type:"text",text:"{VAL}",x:-.2,y:-.1494553499999995}],ports:[{...WEe.left1,labels:["1"]},{...WEe.right1,labels:["2"]}],size:{width:B6.width,height:B6.height},center:{x:B6.centerX,y:B6.centerY}}).rotateRightFacingSymbol("up").labelPort("left",["1"]).labelPort("right",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),dCe={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:-.75,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:u7t,texts:KEe,bounds:T6,refblocks:uU,circles:c7t}=dCe,fR=ea({primitives:[...Object.values(u7t),...Object.values(c7t),{...KEe.top1,anchor:"middle_bottom"},{...KEe.bottom1,anchor:"middle_top"}],ports:[{...uU.left1,labels:["1"]},{...uU.right1,labels:["2"]},{...uU.right2,labels:["3"]}],size:{width:T6.width,height:T6.height},center:{x:T6.centerX,y:T6.centerY}}),cG=ur(fR,"down"),lG=cG.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),dG=cG.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");lG.anchor="middle_bottom";dG.anchor="middle_top";lG.y+=.3;lG.x+=.101;dG.y-=.49999;dG.x+=1.19999;l7t=cG,{paths:d7t,texts:utr,bounds:P6,refblocks:cU,circles:p7t}=dCe,pCe=ea({primitives:[...Object.values(d7t),...Object.values(p7t),{type:"text",text:"{REF}",x:.01596175000000022,y:-.5308501500000009,anchor:"middle_top"},{type:"text",text:"{VAL}",x:.013116750000000454,y:.5408501499999989,anchor:"middle_bottom"}],ports:[{...cU.left1,labels:["1"]},{...cU.right1,labels:["2"]},{...cU.right2,labels:["3"]}],size:{width:P6.width,height:P6.height},center:{x:P6.centerX,y:P6.centerY}}),pG=ur(fR,"left"),xG=pG.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),fG=pG.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");xG.anchor="middle_bottom";fG.anchor="middle_top";xG.y+=.99;xG.x-=0;fG.y-=1.10999;fG.x=0;x7t=pG,hG=ur(fR,"up"),mG=hG.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),gG=hG.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");mG.anchor="middle_bottom";gG.anchor="middle_top";mG.y+=.499;mG.x=.62;gG.y-=.29999;gG.x+=.1;f7t=hG,h7t=ur(pCe),m7t={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:{}},hR=Ft(m7t).labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{VAL}","middle_top").changeTextAnchor("{REF}","middle_bottom").build(),yG=ur(hR,"down"),DG=yG.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),bG=yG.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");DG.anchor="middle_left";bG.anchor="middle_left";DG.y+=.3;DG.x=.3;bG.y-=.3;bG.x=.3;g7t=yG,FG=ur(hR,"left"),EG=FG.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),vG=FG.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");EG.anchor="middle_bottom";vG.anchor="middle_top";EG.y+=.5;EG.x=0;vG.y-=.55;vG.x=0;y7t=FG,CG=ur(hR,"up"),_G=CG.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),AG=CG.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");_G.anchor="middle_left";AG.anchor="middle_left";_G.y+=.3;_G.x=.3;AG.y-=.3;AG.x=.3;D7t=CG,xCe={paths:{path11:{type:"path",points:[{x:-.5,y:.04},{x:-.18,y:.04}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.19,y:.05},{x:.51,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:-.33}],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:ctr,texts:ltr,bounds:dtr,refblocks:ptr,circles:xtr}=xCe,fCe=Ft(xCe).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).labelPort("bottom1",["3"]).changeTextAnchor("{REF}","middle_bottom").build(),hCe=ur(fCe),b7t=hCe.primitives.filter(n=>n.type==="text"),mCe=b7t.find(n=>n.text==="{REF}");mCe.y=0;mCe.anchor="middle_left";F7t=hCe,mR={paths:{path44:{type:"path",points:[{x:-.18,y:-.03},{x:-.44,y:-.03}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.44,y:-.02},{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:{}},E7t=Ft(mR).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").build(),v7t=Ft(mR).rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_top").build(),C7t=Ft(mR).rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),_7t=Ft(mR).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_right").build(),gR={paths:{path44:{type:"path",points:[{x:-.18,y:-.03},{x:-.44,y:-.03}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.44,y:-.02},{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:{}},A7t=Ft(gR).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").build(),R7t=Ft(gR).rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_top").build(),S7t=Ft(gR).rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),w7t=Ft(gR).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_right").build(),yR={paths:{path44:{type:"path",points:[{x:-.22,y:.1},{x:-.44,y:.1}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.44,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:{}},B7t=Ft(yR).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_left").build(),T7t=Ft(yR).rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_top").build(),P7t=Ft(yR).rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_bottom").build(),I7t=Ft(yR).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_right").build(),DR={paths:{path44:{type:"path",points:[{x:-.22,y:.1},{x:-.44,y:.1}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.44,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:{}},j7t=Ft(DR).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_left").build(),N7t=Ft(DR).rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_top").build(),k7t=Ft(DR).rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_bottom").build(),M7t=Ft(DR).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_right").build(),bR={paths:{path44:{type:"path",points:[{x:-.22,y:.1},{x:-.44,y:.1}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.44,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:{}},O7t=Ft(bR).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_left").build(),L7t=Ft(bR).rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_top").build(),$7t=Ft(bR).rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_bottom").build(),z7t=Ft(bR).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_right").build(),FR={paths:{path44:{type:"path",points:[{x:-.22,y:.1},{x:-.44,y:.1}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.44,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:{}},q7t=Ft(FR).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_left").build(),U7t=Ft(FR).rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_top").build(),V7t=Ft(FR).rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_bottom").build(),G7t=Ft(FR).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_right").build(),X7t={paths:{path1:{type:"path",points:[{x:-.35,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:.35,y:-.06}],color:"primary",fill:!1},path3:{type:"path",points:[{x:.12,y:.17},{x:.36,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}}},ER=Ft(X7t).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right2",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_bottom").build(),RG=ur(ER,"down"),SG=RG.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),wG=RG.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");SG.anchor="middle_bottom";wG.anchor="middle_top";SG.x=.44;SG.y+=.28;wG.y-=.28;wG.x=.44;Y7t=RG,BG=ur(ER,"left"),TG=BG.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),PG=BG.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");TG.anchor="middle_bottom";PG.anchor="middle_top";TG.x=0;TG.y+=.625;PG.y-=.695;PG.x=0;H7t=BG,IG=ur(ER,"up"),jG=IG.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),NG=IG.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");jG.anchor="middle_bottom";NG.anchor="middle_top";jG.x=.4;jG.y+=.28;NG.y-=.28;NG.x=.4;W7t=IG,K7t={paths:{path1:{type:"path",points:[{x:-.35,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:.35,y:-.06}],color:"primary",fill:!1},path3:{type:"path",points:[{x:.12,y:.17},{x:.36,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}}},vR=Ft(K7t).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right3",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_bottom").build(),kG=ur(vR,"down"),MG=kG.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),OG=kG.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");MG.anchor="middle_bottom";OG.anchor="middle_top";MG.x=.44;MG.y+=.28;OG.y-=.28;OG.x=.44;J7t=kG,LG=ur(vR,"left"),$G=LG.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),zG=LG.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");$G.anchor="middle_bottom";zG.anchor="middle_top";$G.x=0;$G.y+=.625;zG.y-=.695;zG.x=0;Z7t=LG,qG=ur(vR,"up"),UG=qG.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),VG=qG.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");UG.anchor="middle_bottom";VG.anchor="middle_top";UG.x=.4;UG.y+=.28;VG.y-=.28;VG.x=.4;Q7t=qG,CR={paths:{path11:{type:"path",points:[{x:-.36,y:0},{x:-.14,y:0}],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:.13,y:0},{x:.37,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 CR.refblocks.left1;delete CR.refblocks.right1;CR.bounds.width+=.2;_R=Ft(CR).changeTextAnchor("{VAL}","middle_top").labelPort("left2",["1"]).labelPort("right2",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),GG=ur(_R,"down"),XG=GG.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),YG=GG.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");XG.anchor="middle_bottom";YG.anchor="middle_top";XG.x=.3;XG.y+=.265;YG.y-=.265;YG.x=.3;eTt=GG,HG=ur(_R,"left"),WG=HG.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),KG=HG.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");WG.anchor="middle_bottom";KG.anchor="middle_top";WG.x=0;WG.y+=.57;KG.y-=.57;KG.x=0;tTt=HG,JG=ur(_R,"up"),ZG=JG.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),QG=JG.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");ZG.anchor="middle_bottom";QG.anchor="middle_top";ZG.x=.3;ZG.y+=.265;QG.y-=.265;QG.x=.3;rTt=JG,AR={paths:{path11:{type:"path",points:[{x:-.36,y:0},{x:-.14,y:0}],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:.13,y:0},{x:.37,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 AR.refblocks.left1;delete AR.refblocks.right1;AR.bounds.width+=.2;RR=Ft(AR).changeTextAnchor("{VAL}","middle_top").labelPort("left2",["1"]).labelPort("right2",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),eX=ur(RR,"down"),tX=eX.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),rX=eX.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");tX.anchor="middle_bottom";rX.anchor="middle_top";tX.x=.3;tX.y+=.265;rX.y-=.265;rX.x=.3;nTt=eX,nX=ur(RR,"left"),aX=nX.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),sX=nX.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");aX.anchor="middle_bottom";sX.anchor="middle_top";aX.x=0;aX.y+=.57;sX.y-=.57;sX.x=0;aTt=nX,iX=ur(RR,"up"),oX=iX.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),uX=iX.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");oX.anchor="middle_bottom";uX.anchor="middle_top";oX.x=.3;oX.y+=.265;uX.y-=.265;uX.x=.3;sTt=iX,SR={paths:{path44:{type:"path",points:[{x:-.16845120000000047,y:.02621170000000017},{x:-.4403295000000007,y:.02621170000000017}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.43977860000000035,y:.027926399999999685},{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:{}},iTt=Ft(SR).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(),oTt=Ft(SR).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(),uTt=Ft(SR).rotateRightFacingSymbol("right").labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),cTt=Ft(SR).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(),gCe={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:ftr,texts:htr,bounds:mtr,refblocks:gtr,circles:ytr}=gCe,yCe=Ft(gCe).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),lTt=ur(yCe),dTt={paths:{path11:{type:"path",points:[{x:-.53,y:0},{x:-.3,y:0}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:0},{x:.53,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:pTt,texts:xTt,bounds:I6,refblocks:JEe,circles:fTt}=dTt,cX=ea({primitives:[...Object.values(pTt),...Object.values(fTt),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"},{...xTt.left1,y:.01,anchor:"center",fontSize:.2}],ports:[{...JEe.left1,labels:["1"]},{...JEe.right1,labels:["2"]}],size:{width:I6.width,height:I6.height},center:{x:I6.centerX,y:I6.centerY}}),{5:hTt,...mTt}=cX.primitives;ZEe=ur({...cX,primitives:Object.values(mTt).filter(gTt)}),yTt={...ZEe,primitives:[...ZEe.primitives,hTt]},wR=ea({primitives:[{type:"path",points:[{x:-.2,y:0},{x:0,y:0}],color:"primary",fill:!1},{type:"path",points:Array.from({length:8},(n,e)=>{let a=Math.PI/2-e*Math.PI/7,s=.1;return{x:.1-s*Math.cos(a),y:s*Math.sin(a)}}),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}}),DCe=ur(wR,"down"),QEe=DCe.primitives.find(n=>n.type==="text"&&n.text==="{REF}");QEe&&(QEe.anchor="middle_top");DTt=DCe,bTt=ur(wR,"left"),bCe=ur(wR,"up"),eve=bCe.primitives.find(n=>n.type==="text"&&n.text==="{REF}");eve&&(eve.anchor="middle_bottom");FTt=bCe,ETt={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:-.4,y:.2},{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:{}},lX=Ft(ETt).labelPort("right1",["1"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),dX=ur(lX,"up"),pX=dX.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),xX=dX.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");pX.anchor="middle_bottom";xX.anchor="middle_top";pX.x=.4;pX.y+=.2;xX.y-=.3;xX.x=.4;FCe=dX,fX=X6(FCe),hX=fX.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),mX=fX.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");hX.anchor="middle_bottom";mX.anchor="middle_top";hX.x=.35;hX.y+=.4;mX.y-=.4;mX.x=.35;vTt=fX,gX=ur(lX,"left"),yX=gX.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),DX=gX.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");yX.anchor="middle_bottom";DX.anchor="middle_top";yX.x=0;yX.y+=.5;DX.y-=.6;DX.x=0;CTt=gX,ECe={paths:{path11:{type:"path",points:[{x:-.52,y:.04},{x:-.11,y:.04}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.1,y:.04},{x:.52,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:-.3}],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:Dtr,texts:btr,bounds:Ftr,refblocks:Etr,circles:vtr}=ECe,vCe=Ft(ECe).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).labelPort("bottom1",["3"]).changeTextAnchor("{REF}","middle_bottom").build(),CCe=ur(vCe),_Ce=CCe.primitives.filter(n=>n.type==="text"),_Tt=_Ce.find(n=>n.text==="{REF}"),ATt=_Ce.find(n=>n.text==="{VAL}");_Tt.y=0;ATt.y=0;RTt=CCe,STt={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:wTt,texts:tve,bounds:j6,refblocks:rve,circles:BTt}=STt,ACe=ea({primitives:[...Object.values(wTt),...Object.values(BTt),{...tve.top1,anchor:"middle_bottom"},{...tve.bottom1,anchor:"middle_top"}],ports:[{...rve.left1,labels:["1"]},{...rve.right1,labels:["2"]}],size:{width:j6.width,height:j6.height},center:{x:j6.centerX,y:j6.centerY}}),bX=ur(ACe),TTt=bX.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),PTt=bX.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");TTt.anchor="middle_left";PTt.anchor="middle_right";ITt=bX,jTt={paths:{path11:{type:"path",points:[{x:-.33,y:.21},{x:-.02,y:.01}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.23,y:.13},{x:.23,y:.38}],color:"primary",fill:!1},"path12-2":{type:"path",points:[{x:.23,y:-.08},{x:.23,y:-.33}],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:NTt,texts:nve,bounds:N6,refblocks:lU,circles:kTt}=jTt,RCe=ea({primitives:[...Object.values(NTt),...Object.values(kTt),{...nve.top1,anchor:"middle_left"},{...nve.bottom1,anchor:"middle_right"}],ports:[{...lU.top1,labels:["1"]},{...lU.bottom1,labels:["2"]},{...lU.left1,labels:["3"]}],size:{width:N6.width,height:N6.height},center:{x:N6.centerX,y:N6.centerY}}),SCe=ur(RCe),wCe=SCe.primitives.filter(n=>n.type==="text"),MTt=wCe.find(n=>n.text==="{REF}");MTt.y=.1;BCe=wCe.find(n=>n.text==="{VAL}");BCe.y=.1;BCe.x=-.4;OTt=SCe,LTt={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}},$Tt=Ft(LTt).changeTextAnchor("{REF}","middle_bottom").build(),zTt={paths:{path11:{type:"path",points:[{x:-.53,y:0},{x:-.3,y:0}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:0},{x:.53,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:qTt,texts:dU,bounds:k6,refblocks:ave,circles:UTt}=zTt,TCe=ea({primitives:[...Object.values(qTt),...Object.values(UTt),{...dU.top1,x:0,y:-.3594553499999995,anchor:"middle_top"},{...dU.bottom1,x:0,y:.35,anchor:"middle_bottom"},{...dU.left1,x:-.02,y:.01,fontSize:.2,anchor:"center"}],ports:[{...ave.left1,labels:["1"]},{...ave.right1,labels:["2"]}],size:{width:k6.width,height:k6.height},center:{x:k6.centerX,y:k6.centerY}}),VTt=ur(TCe),GTt={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:.53,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:XTt,texts:sve,bounds:M6,refblocks:ive,circles:YTt}=GTt,PCe=ea({primitives:[...Object.values(XTt),...Object.values(YTt),{...sve.top1,anchor:"middle_bottom"},{...sve.bottom1,anchor:"middle_top"}],ports:[{...ive.left1,labels:["1"]},{...ive.right1,labels:["2"]}],size:{width:M6.width,height:M6.height},center:{x:M6.centerX,y:M6.centerY}}),FX=ur(PCe),HTt=FX.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),WTt=FX.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");HTt.anchor="middle_left";WTt.anchor="middle_right";KTt=FX,JTt={paths:{path5:{type:"path",points:[{x:-.52,y:0},{x:-.26,y:0}],color:"primary",fill:!1},path6:{type:"path",points:[{x:.27,y:0},{x:.53,y:0}],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:ZTt,texts:ove,bounds:O6,refblocks:uve}=JTt,ICe=ea({primitives:[...Object.values(ZTt),{...ove.top1,anchor:"middle_left"},{...ove.bottom1,anchor:"middle_right"}],ports:[{...uve.left1,labels:["1","-"]},{...uve.right1,labels:["2","+"]}],size:{width:O6.width,height:O6.height},center:{x:O6.centerX,y:O6.centerY}}),QTt=ur(ICe),ePt={paths:{path11:{type:"path",points:[{x:-.53,y:0},{x:-.3,y:0}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:0},{x:.53,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:tPt,texts:rPt,bounds:L6,refblocks:cve,circles:nPt}=ePt,EX=ea({primitives:[...Object.values(tPt),...Object.values(nPt),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"},{...rPt.left1,anchor:"center",y:.02,fontSize:.2}],ports:[{...cve.left1,labels:["1"]},{...cve.right1,labels:["2"]}],size:{width:L6.width,height:L6.height},center:{x:L6.centerX,y:L6.centerY}}),{5:aPt,...sPt}=EX.primitives;lve=ur({...EX,primitives:Object.values(sPt).filter(iPt)}),oPt={...lve,primitives:[...lve.primitives,aPt]},BR={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:-.22,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:{}},uPt=Ft(BR).rotateRightFacingSymbol("down").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_top").build(),cPt=Ft(BR).rotateRightFacingSymbol("left").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_right").build(),lPt=Ft(BR).rotateRightFacingSymbol("right").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_left").build(),dPt=Ft(BR).rotateRightFacingSymbol("up").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_bottom").build(),jCe={paths:{path11:{type:"path",points:[{x:-.53,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:.53,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:Ctr,texts:_tr,bounds:Atr,circles:Rtr,refblocks:Str}=jCe,NCe=Ft(jCe).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),pPt=ur(NCe),xPt={paths:{path11:{type:"path",points:[{x:-.53,y:0},{x:-.3,y:0}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:0},{x:.53,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:fPt,texts:hPt,bounds:$6,refblocks:dve,circles:mPt}=xPt,vX=ea({primitives:[...Object.values(fPt),...Object.values(mPt),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"},{...hPt.left1,anchor:"center",y:.01,fontSize:.2}],ports:[{...dve.left1,labels:["1"]},{...dve.right1,labels:["2"]}],size:{width:$6.width,height:$6.height},center:{x:$6.centerX,y:$6.centerY}}),{5:gPt,...yPt}=vX.primitives;pve=ur({...vX,primitives:Object.values(yPt).filter(DPt)}),bPt={...pve,primitives:[...pve.primitives,gPt]},FPt={paths:{path11:{type:"path",points:[{x:-.53,y:0},{x:-.3,y:0}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:0},{x:.53,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:EPt,texts:vPt,bounds:z6,refblocks:xve,circles:CPt}=FPt,CX=ea({primitives:[...Object.values(EPt),...Object.values(CPt),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"},{...vPt.left1,anchor:"center",y:.01,fontSize:.3}],ports:[{...xve.left1,labels:["1"]},{...xve.right1,labels:["2"]}],size:{width:z6.width,height:z6.height},center:{x:z6.centerX,y:z6.centerY}}),{5:_Pt,...APt}=CX.primitives;fve=ur({...CX,primitives:Object.values(APt).filter(RPt)}),SPt={...fve,primitives:[...fve.primitives,_Pt]},wPt={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:BPt,texts:hve,bounds:q6,refblocks:mve,circles:TPt}=wPt,kCe=ea({primitives:[...Object.values(BPt),...Object.values(TPt),{...hve.top1,anchor:"middle_bottom"},{...hve.bottom1,anchor:"middle_top"}],ports:[{...mve.left1,labels:["1"]},{...mve.right1,labels:["2"]}],size:{width:q6.width,height:q6.height},center:{x:q6.centerX,y:q6.centerY}}),_X=ur(kCe),PPt=_X.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),IPt=_X.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");PPt.anchor="middle_left";IPt.anchor="middle_right";jPt=_X,Ts={ac_voltmeter_down:X4t,ac_voltmeter_horz:W4t,ac_voltmeter_left:Z4t,ac_voltmeter_right:t6t,ac_voltmeter_up:a6t,ac_voltmeter_vert:o6t,avalanche_diode_down:l6t,avalanche_diode_horz:d6t,avalanche_diode_left:f6t,avalanche_diode_right:h6t,avalanche_diode_up:y6t,avalanche_diode_vert:F6t,backward_diode_down:C6t,backward_diode_left:gve,backward_diode_right:w6t,backward_diode_up:B6t,battery_horz:yve,battery_vert:j6t,boxresistor_down:M6t,boxresistor_left:$6t,boxresistor_right:U6t,boxresistor_small_down:X6t,boxresistor_small_left:W6t,boxresistor_small_right:Z6t,boxresistor_small_up:tRt,boxresistor_up:aRt,bridged_ground_down:oRt,bridged_ground_left:lRt,bridged_ground_right:Dve,bridged_ground_up:xRt,capacitor_down:mRt,capacitor_left:gRt,capacitor_polarized_down:bRt,capacitor_polarized_left:FRt,capacitor_polarized_right:CRt,capacitor_polarized_up:RRt,capacitor_right:SRt,capacitor_up:TRt,constant_current_diode_down:jRt,constant_current_diode_horz:NRt,constant_current_diode_left:ORt,constant_current_diode_right:LRt,constant_current_diode_up:qRt,constant_current_diode_vert:GRt,crystal_4pin_down:HRt,crystal_4pin_left:WRt,crystal_4pin_right:KRt,crystal_4pin_up:QRt,crystal_down:r5t,crystal_left:n5t,crystal_right:a5t,crystal_up:o5t,darlington_pair_transistor_down:u5t,darlington_pair_transistor_horz:c5t,darlington_pair_transistor_left:l5t,darlington_pair_transistor_right:d5t,darlington_pair_transistor_up:p5t,darlington_pair_transistor_vert:x5t,dc_ammeter_horz:bU,dc_ammeter_vert:E5t,dc_voltmeter_down:_5t,dc_voltmeter_horz:S5t,dc_voltmeter_left:T5t,dc_voltmeter_right:j5t,dc_voltmeter_up:M5t,dc_voltmeter_vert:$5t,diac_down:z5t,diac_horz:q5t,diac_left:U5t,diac_right:V5t,diac_up:G5t,diac_vert:X5t,diode_down:H5t,diode_left:W5t,diode_right:eR,diode_up:K5t,dpdt_normally_closed_switch_down:Z5t,dpdt_normally_closed_switch_left:Q5t,dpdt_normally_closed_switch_right:tR,dpdt_normally_closed_switch_up:eSt,dpdt_switch_down:rSt,dpdt_switch_left:nSt,dpdt_switch_right:rR,dpdt_switch_up:aSt,dpst_normally_closed_switch_down:iSt,dpst_normally_closed_switch_left:oSt,dpst_normally_closed_switch_right:nR,dpst_normally_closed_switch_up:uSt,dpst_switch_down:lSt,dpst_switch_left:dSt,dpst_switch_right:aR,dpst_switch_up:pSt,ferrite_bead_down:hSt,ferrite_bead_left:mSt,ferrite_bead_right:Eve,ferrite_bead_up:Fve,filled_diode_down:DSt,filled_diode_horz:ESt,filled_diode_left:_St,filled_diode_right:SSt,filled_diode_up:TSt,filled_diode_vert:jSt,frequency_meter_horz:iV,frequency_meter_vert:qSt,fuse_horz:vve,fuse_vert:XSt,ground_down:YSt,ground_horz:HSt,ground_left:WSt,ground_right:KSt,ground_up:JSt,ground_vert:ZSt,ground2_down:twt,ground2_left:swt,ground2_right:cwt,ground2_up:xwt,gunn_diode_horz:fwt,gunn_diode_vert:hwt,icled_down:gwt,icled_left:ywt,icled_right:iR,icled_up:Dwt,igbt_transistor_horz:Cve,igbt_transistor_vert:Fwt,illuminated_push_button_normally_open_horz:Ave,illuminated_push_button_normally_open_vert:vwt,inductor_down:Rwt,inductor_left:Swt,inductor_right:hV,inductor_up:wve,laser_diode_down:wwt,laser_diode_left:Bwt,laser_diode_right:oR,laser_diode_up:Twt,led_down:Nwt,led_left:kwt,led_right:_V,led_up:Tve,light_dependent_resistor_horz:Pve,light_dependent_resistor_vert:$wt,mosfet_depletion_normally_on_horz:Nve,mosfet_depletion_normally_on_vert:Uwt,mushroom_head_normally_open_momentary_horz:Mve,mushroom_head_normally_open_momentary_vert:Ywt,n_channel_d_mosfet_transistor_horz:Ove,n_channel_d_mosfet_transistor_vert:Jwt,n_channel_e_mosfet_transistor_horz:zve,n_channel_e_mosfet_transistor_vert:t9t,njfet_transistor_horz:Vve,njfet_transistor_vert:s9t,not_connected_down:c9t,not_connected_left:l9t,not_connected_right:uR,not_connected_up:d9t,npn_bipolar_transistor_down:f9t,npn_bipolar_transistor_horz:h9t,npn_bipolar_transistor_left:y9t,npn_bipolar_transistor_right:F9t,npn_bipolar_transistor_up:C9t,npn_bipolar_transistor_vert:R9t,opamp_no_power_down:w9t,opamp_no_power_left:B9t,opamp_no_power_right:cR,opamp_no_power_up:T9t,opamp_with_power_down:I9t,opamp_with_power_left:j9t,opamp_with_power_right:lR,opamp_with_power_up:N9t,p_channel_d_mosfet_transistor_horz:Yve,p_channel_d_mosfet_transistor_vert:L9t,p_channel_e_mosfet_transistor_horz:Kve,p_channel_e_mosfet_transistor_vert:U9t,photodiode_horz:Qve,photodiode_vert:X9t,pjfet_transistor_horz:rCe,pjfet_transistor_vert:K9t,pnp_bipolar_transistor_down:Q9t,pnp_bipolar_transistor_horz:eBt,pnp_bipolar_transistor_left:nBt,pnp_bipolar_transistor_right:iBt,pnp_bipolar_transistor_up:cBt,pnp_bipolar_transistor_vert:pBt,potentiometer_horz:sCe,potentiometer_vert:mBt,potentiometer2_down:DBt,potentiometer2_left:bBt,potentiometer2_right:dR,potentiometer2_up:FBt,potentiometer3_down:CBt,potentiometer3_left:RBt,potentiometer3_right:SBt,potentiometer3_up:TBt,power_factor_meter_horz:iCe,power_factor_meter_vert:NBt,push_button_normally_closed_momentary_horz:uCe,push_button_normally_closed_momentary_vert:LBt,push_button_normally_open_momentary_horz:cCe,push_button_normally_open_momentary_vert:UBt,rectifier_diode_horz:lCe,rectifier_diode_vert:WBt,resistor_down:ZBt,resistor_left:t7t,resistor_right:a7t,resistor_up:o7t,resonator_down:l7t,resonator_horz:pCe,resonator_left:x7t,resonator_right:fR,resonator_up:f7t,resonator_vert:h7t,schottky_diode_down:g7t,schottky_diode_left:y7t,schottky_diode_right:hR,schottky_diode_up:D7t,silicon_controlled_rectifier_horz:fCe,silicon_controlled_rectifier_vert:F7t,solderjumper2_bridged12_down:E7t,solderjumper2_bridged12_left:v7t,solderjumper2_bridged12_right:C7t,solderjumper2_bridged12_up:_7t,solderjumper2_down:A7t,solderjumper2_left:R7t,solderjumper2_right:S7t,solderjumper2_up:w7t,solderjumper3_bridged12_down:B7t,solderjumper3_bridged12_left:T7t,solderjumper3_bridged12_right:P7t,solderjumper3_bridged12_up:I7t,solderjumper3_bridged123_down:j7t,solderjumper3_bridged123_left:N7t,solderjumper3_bridged123_right:k7t,solderjumper3_bridged123_up:M7t,solderjumper3_bridged23_down:O7t,solderjumper3_bridged23_left:L7t,solderjumper3_bridged23_right:$7t,solderjumper3_bridged23_up:z7t,solderjumper3_down:q7t,solderjumper3_left:U7t,solderjumper3_right:V7t,solderjumper3_up:G7t,spdt_normally_closed_switch_down:Y7t,spdt_normally_closed_switch_left:H7t,spdt_normally_closed_switch_right:ER,spdt_normally_closed_switch_up:W7t,spdt_switch_down:J7t,spdt_switch_left:Z7t,spdt_switch_right:vR,spdt_switch_up:Q7t,spst_normally_closed_switch_down:eTt,spst_normally_closed_switch_left:tTt,spst_normally_closed_switch_right:_R,spst_normally_closed_switch_up:rTt,spst_switch_down:nTt,spst_switch_left:aTt,spst_switch_right:RR,spst_switch_up:sTt,square_wave_down:iTt,square_wave_left:oTt,square_wave_right:uTt,square_wave_up:cTt,step_recovery_diode_horz:yCe,step_recovery_diode_vert:lTt,tachometer_horz:cX,tachometer_vert:yTt,testpoint_down:DTt,testpoint_left:bTt,testpoint_right:wR,testpoint_up:FTt,tilted_ground_down:vTt,tilted_ground_left:CTt,tilted_ground_right:lX,tilted_ground_up:FCe,triac_horz:vCe,triac_vert:RTt,tunnel_diode_horz:ACe,tunnel_diode_vert:ITt,unijunction_transistor_horz:RCe,unijunction_transistor_vert:OTt,usbc:$Tt,var_meter_horz:TCe,var_meter_vert:VTt,varactor_diode_horz:PCe,varactor_diode_vert:KTt,varistor_horz:ICe,varistor_vert:QTt,varmeter_horz:EX,varmeter_vert:oPt,vcc_down:uPt,vcc_left:cPt,vcc_right:lPt,vcc_up:dPt,volt_meter_horz:NCe,volt_meter_vert:pPt,watt_hour_meter_horz:vX,watt_hour_meter_vert:bPt,wattmeter_horz:CX,wattmeter_vert:SPt,zener_diode_horz:kCe,zener_diode_vert:jPt},wtr=Object.fromEntries(Object.keys(Ts).map(n=>[n,n]))});var e1=on((Grr,m_e)=>{"use strict";m_e.exports={trueFunc:function(){return!0},falseFunc:function(){return!1}}});function Ja(n,e){return Array.isArray(e)?[n.a*e[0]+n.c*e[1]+n.e,n.b*e[0]+n.d*e[1]+n.f]:{x:n.a*e.x+n.c*e.y+n.e,y:n.b*e.x+n.d*e.y+n.f}}var ZX=Sr(()=>{"use strict"});var QX=Sr(()=>{"use strict"});var N_e=Sr(()=>{"use strict"});var k_e=Sr(()=>{"use strict"});var eY=Sr(()=>{"use strict"});function Rb(n){return typeof n>"u"}var YR=Sr(()=>{"use strict"});var M_e=Sr(()=>{"use strict";YR()});function Yi(n,e=0){return{a:1,c:0,e:n,b:0,d:1,f:e}}var rg=Sr(()=>{"use strict"});function ng(...n){n=Array.isArray(n[0])?n[0]:n;let e=(a,s)=>({a:a.a*s.a+a.c*s.b,c:a.a*s.c+a.c*s.d,e:a.a*s.e+a.c*s.f+a.e,b:a.b*s.a+a.d*s.b,d:a.b*s.c+a.d*s.d,f:a.b*s.e+a.d*s.f+a.f});switch(n.length){case 0:throw new Error("no matrices provided");case 1:return n[0];case 2:return e(n[0],n[1]);default:{let[a,s,...l]=n,d=e(a,s);return ng(d,...l)}}}function r1(...n){return ng(...n)}var n1=Sr(()=>{"use strict"});var Knr,Jnr,Znr,HR=Sr(()=>{"use strict";YR();rg();n1();({cos:Knr,sin:Jnr,PI:Znr}=Math)});function Np(n,e=void 0,a=void 0,s=void 0){Rb(e)&&(e=n);let l={a:n,c:0,e:0,b:0,d:e,f:0};return Rb(a)||Rb(s)?l:ng([Yi(a,s),l,Yi(-a,-s)])}var Sb=Sr(()=>{"use strict";YR();rg();n1()});var tY=Sr(()=>{"use strict"});var sar,rY=Sr(()=>{"use strict";({tan:sar}=Math)});var O_e=Sr(()=>{"use strict"});var nY=Sr(()=>{"use strict"});var L_e=Sr(()=>{"use strict";eY();n1();nY()});var $_e=Sr(()=>{"use strict";QX();rg();Sb();HR();rY();tY()});var z_e=Sr(()=>{"use strict"});var q_e=Sr(()=>{"use strict";z_e()});function WR(n,e=!1,a=!1){e?a?n=r1(n,Np(-1,-1)):n=r1(n,Np(1,-1)):a&&(n=r1(n,Np(-1,1)));let s=n.a,l=n.b,d=n.c,x=n.d,f,m,y;if(s!==0||d!==0){let b=Math.hypot(s,d);f=b,m=(s*x-l*d)/b;let E=Math.acos(s/b);y=d>0?-E:E}else if(l!==0||x!==0){let b=Math.hypot(l,x);f=(s*x-l*d)/b,m=b;let E=Math.acos(l/b);y=Math.PI/2+(x>0?-E:E)}else f=0,m=0,y=0;return a&&(f=-f),e&&(m=-m),{translate:{tx:n.e,ty:n.f},scale:{sx:f,sy:m},rotation:{angle:y}}}var U_e=Sr(()=>{"use strict";Sb();n1()});var V_e=Sr(()=>{"use strict"});var G_e=Sr(()=>{"use strict";rg();ZX();HR();Sb();n1()});var Ql=Sr(()=>{"use strict";ZX();QX();N_e();k_e();eY();M_e();HR();Sb();tY();rY();O_e();n1();rg();L_e();nY();$_e();q_e();U_e();V_e();G_e()});var aY=Sr(()=>{"use strict"});var W_e=on((H_e,wb)=>{"use strict";(function(){var n,e,a,s,l,d;typeof performance<"u"&&performance!==null&&performance.now?wb.exports=function(){return performance.now()}:typeof process<"u"&&process!==null&&process.hrtime?(wb.exports=function(){return(n()-l)/1e6},e=process.hrtime,n=function(){var x;return x=e(),x[0]*1e9+x[1]},s=n(),d=process.uptime()*1e9,l=s-d):Date.now?(wb.exports=function(){return Date.now()-a},a=Date.now()):(wb.exports=function(){return new Date().getTime()-a},a=new Date().getTime())}).call(H_e)});var K_e=Sr(()=>{"use strict"});var J_e=Sr(()=>{"use strict"});function oY([n,e],[a,s],{lineThickness:l=0}={}){return l===0?uY(n,e,a,s):WIt(n,e,a,s)<=l}function uY(n,e,a,s){let l=Bb(n,e,a),d=Bb(n,e,s),x=Bb(a,s,n),f=Bb(a,s,e);return!!(l!==d&&x!==f||l===0&&Tb(n,a,e)||d===0&&Tb(n,s,e)||x===0&&Tb(a,n,s)||f===0&&Tb(a,e,s))}function Bb(n,e,a){let s=(e.y-n.y)*(a.x-e.x)-(e.x-n.x)*(a.y-e.y);return s===0?0:s>0?1:2}function Tb(n,e,a){return e.x<=Math.max(n.x,a.x)&&e.x>=Math.min(n.x,a.x)&&e.y<=Math.max(n.y,a.y)&&e.y>=Math.min(n.y,a.y)}function WIt(n,e,a,s){if(n.x===e.x&&n.y===e.y)return a1(n,a,s);if(a.x===s.x&&a.y===s.y)return a1(a,n,e);if(uY(n,e,a,s))return 0;let l=[a1(n,a,s),a1(e,a,s),a1(a,n,e),a1(s,n,e)];return Math.min(...l)}function a1(n,e,a){let s=(a.x-e.x)**2+(a.y-e.y)**2;if(s===0)return iY(n,e);let l=((n.x-e.x)*(a.x-e.x)+(n.y-e.y)*(a.y-e.y))/s;l=Math.max(0,Math.min(1,l));let d={x:e.x+l*(a.x-e.x),y:e.y+l*(a.y-e.y)};return iY(n,d)}function iY(n,e){let a=n.x-e.x,s=n.y-e.y;return Math.sqrt(a*a+s*s)}var Z_e=Sr(()=>{"use strict"});var Q_e=Sr(()=>{"use strict"});var e8e=Sr(()=>{"use strict";K_e();J_e();Z_e();Q_e()});function t8e(n){let e=new Map,a=0;function s(l){for(let[,x]of e)if(x.has(l))return x;let d=new Set;return e.set(`connectivity_net${a++}`,d),d}for(let l of n){let d=null;for(let x of l){if(!d)d=s(x);else if(!d.has(x)){let f=s(x);if(f!==d){for(let m of f)d.add(m);e.delete(Array.from(e.entries()).find(([,m])=>m===f)[0])}}d.add(x)}}return Object.fromEntries(Array.from(e.entries()).map(([l,d])=>[l,Array.from(d)]))}var Pb,Ku,KR,Ko=Sr(()=>{"use strict";e8e();Pb=class{constructor(n){X(this,"netMap");X(this,"idToNetMap");this.netMap=n,this.idToNetMap={};for(let[e,a]of Object.entries(n))for(let s of a)this.idToNetMap[s]=e}addConnections(n){for(let e of n){let a=new Set;for(let l of e){let d=this.idToNetMap[l];d&&a.add(d)}let s;if(a.size===0)s=`connectivity_net${Object.keys(this.netMap).length}`,this.netMap[s]=[];else if(a.size===1)s=a.values().next().value??`connectivity_net${Object.keys(this.netMap).length}`;else{s=a.values().next().value??`connectivity_net${Object.keys(this.netMap).length}`;for(let l of a)if(l!==s){this.netMap[s].push(...this.netMap[l]),this.netMap[l]=this.netMap[s];for(let d of this.netMap[s])this.idToNetMap[d]=s}}for(let l of e)this.netMap[s].includes(l)||this.netMap[s].push(l),this.idToNetMap[l]=s}}getIdsConnectedToNet(n){return this.netMap[n]||[]}getNetConnectedToId(n){return this.idToNetMap[n]}areIdsConnected(n,e){if(n===e)return!0;let a=this.getNetConnectedToId(n);if(!a)return!1;let s=this.getNetConnectedToId(e);return s?a===s||s===n||s===n:!1}areAllIdsConnected(n){let e=this.getNetConnectedToId(n[0]);for(let a of n){let s=this.getNetConnectedToId(a);if(s===void 0||s!==e)return!1}return!0}},Ku=n=>{let e=[];for(let s of n)if(s.type==="source_trace")e.push([s.source_trace_id,...s.connected_source_port_ids??[],...s.connected_source_net_ids??[]].filter(Boolean));else if(s.type==="pcb_port"){let{pcb_port_id:l,source_port_id:d}=s;d&&l&&e.push([d,l])}else if(s.type==="pcb_smtpad"){let{pcb_smtpad_id:l,pcb_port_id:d}=s;d&&l&&e.push([l,d])}else if(s.type==="pcb_plated_hole"){let{pcb_plated_hole_id:l,pcb_port_id:d}=s;d&&l&&e.push([l,d])}else if(s.type==="pcb_trace"){let{pcb_trace_id:l,source_trace_id:d}=s,x=Array.isArray(s.route)?s.route.filter(f=>f&&f.route_type==="wire"):[];if(d&&l&&e.push([l,d]),Array.isArray(x)){let f=x.find(y=>y&&y.start_pcb_port_id)?.start_pcb_port_id,m=x.find(y=>y&&y.end_pcb_port_id)?.end_pcb_port_id;f&&l&&m&&e.push([f,l,m])}}else if(s.type==="pcb_via"){let{pcb_via_id:l,pcb_trace_id:d}=s;d&&l&&e.push([l,d])}else if(s.type==="source_component"&&s.internally_connected_source_port_ids)for(let l of s.internally_connected_source_port_ids)e.push(l);let a=t8e(e);return new Pb(a)},KR=class{constructor(n){X(this,"circuitJson");X(this,"traceIdToElm");X(this,"portIdToElm");X(this,"connMap");this.circuitJson=n||[],this.traceIdToElm=new Map,this.portIdToElm=new Map,n?(this._buildTraceMap(),this._buildPortMap(),this.connMap=this._buildTraceConnectivityMap()):this.connMap=new Pb({})}_buildPortMap(){for(let n of this.circuitJson)n.type==="pcb_port"&&this.portIdToElm.set(n.pcb_port_id,n)}_buildTraceMap(){for(let n of this.circuitJson)n.type==="pcb_trace"&&this.traceIdToElm.set(n.pcb_trace_id,n)}_buildTraceConnectivityMap(){let n=[],e=Array.from(this.traceIdToElm.keys());for(let a=0;a<e.length;a++)for(let s=a+1;s<e.length;s++){let l=this.traceIdToElm.get(e[a]),d=this.traceIdToElm.get(e[s]);this._arePcbTracesConnected(l,d)&&n.push([e[a],e[s]])}for(let a of this.portIdToElm.values())for(let s of this.traceIdToElm.values())for(let l of s.route)l.route_type==="wire"&&(l.start_pcb_port_id===a.pcb_port_id?n.push([a.pcb_port_id,s.pcb_trace_id]):l.end_pcb_port_id===a.pcb_port_id&&n.push([s.pcb_trace_id,a.pcb_port_id]));return new Pb(t8e(n))}addTrace(n){this.traceIdToElm.set(n.pcb_trace_id,n);let e=[];for(let a of n.route)a.route_type==="wire"&&(a.start_pcb_port_id&&e.push([a.start_pcb_port_id,n.pcb_trace_id]),a.end_pcb_port_id&&e.push([a.end_pcb_port_id,n.pcb_trace_id]));this.connMap.addConnections(e)}_arePcbTracesConnected(n,e){for(let a=0;a<n.route.length-1;a++){let s=n.route[a],l=n.route[a+1];if(s.route_type==="wire"&&l.route_type==="wire")for(let d=0;d<e.route.length-1;d++){let x=e.route[d],f=e.route[d+1];if(x.route_type!=="wire"||f.route_type!=="wire")continue;if(oY([s,l],[x,f],{lineThickness:(s.width+x.width)/2}))return!0}}return!1}areTracesConnected(n,e){return this.connMap.areIdsConnected(n,e)}getAllTracesConnectedToTrace(n){let e=this.connMap.getNetConnectedToId(n);return e?this.connMap.getIdsConnectedToNet(e).filter(a=>this.traceIdToElm.has(a)).map(a=>this.traceIdToElm.get(a)):[]}getAllTracesConnectedToPort(n){let e=this.connMap.getNetConnectedToId(n);return e?this.connMap.getIdsConnectedToNet(e).filter(a=>this.traceIdToElm.has(a)).map(a=>this.traceIdToElm.get(a)):[]}}});function PAe(n,e,a){if(!e||!a)return;let s=n.get(e);s||(s=new Set,n.set(e,s)),s.add(a);let l=n.get(a);l||(l=new Set,n.set(a,l)),l.add(e)}function qb(n,e){if(!e.subcircuit_id&&!e.source_group_id)return[...n];let a=new Map;for(let x of n){let f=x[`${x.type}_id`];typeof f=="string"&&a.set(f,x)}let s=new Map;for(let x of n){let f=Object.entries(x);for(let[m,y]of f)if(m!=="parent_source_group_id"){if(m.endsWith("_id")&&typeof y=="string"){let b=a.get(y);PAe(s,x,b)}else if(m.endsWith("_ids")&&Array.isArray(y)){for(let b of y)if(typeof b=="string"){let E=a.get(b);PAe(s,x,E)}}}}let l=[],d=new Set;for(let x of n)(e.subcircuit_id&&x.subcircuit_id===e.subcircuit_id||e.source_group_id&&(x.source_group_id===e.source_group_id||Array.isArray(x.member_source_group_ids)&&x.member_source_group_ids.includes(e.source_group_id)))&&(l.push(x),d.add(x));for(;l.length>0;){let x=l.shift(),f=s.get(x);if(f)for(let m of f)d.has(m)||(d.add(m),l.push(m))}return n.filter(x=>d.has(x))}function DY(n){let e=n.type;return`${e}:${n[`${e}_id`]}`}function bNt(n,e){let a=Do(n).pcb_trace.get(e);if(!a)return`trace[${e}]`;let s=a.route.flatMap(x=>[x.start_pcb_port_id,x.end_pcb_port_id]).filter(Boolean);if(s.length===0)return`trace[${e}]`;function l(x){let f=Do(n).pcb_port.get(x);if(!f)return null;let m=Do(n).pcb_component.get(f.pcb_component_id);if(!m)return null;let y=Do(n).source_component.get(m.source_component_id);if(!y)return null;let b=Do(n).source_port.get(f.source_port_id),E=b?.port_hints?b.port_hints[1]:"";return{componentName:y.name,portHint:E}}return`trace[${s.map(x=>{let f=l(x);return f?`.${f.componentName} > port.${f.portHint}`:`port[${x}]`}).join(", ")}]`}function FNt(n,e){let a=Do(n).pcb_smtpad.get(e);return!a||!a.pcb_port_id?`smtpad[${e}]`:FY(n,a.pcb_port_id)}function ENt(n){let e=0;if(n.length==0)return e;for(var a=0;a<n.length;a++){var s=n.charCodeAt(a);e=(e<<5)-e+s,e=e&e}return Math.abs(e)}function y5(n,e={}){if(n.length===0)return{width:0,height:0};let a=e.direction??"row",s=e.columnGap??0,l=e.rowGap??0;if(a==="row"||a==="row-reverse"){let f=n.reduce((y,b)=>y+b.width,0)+s*Math.max(0,n.length-1),m=n.reduce((y,b)=>Math.max(y,b.height),0);return{width:f,height:m}}else{let f=n.reduce((y,b)=>y+b.height,0)+l*Math.max(0,n.length-1);return{width:n.reduce((y,b)=>Math.max(y,b.width),0),height:f}}}var Do,ua,ka,IAe,hNt,mNt,gNt,NAe,yNt,kAe,bY,Ub,MAe,DNt,FY,Vb,OAe,jAe,vNt,CNt,LAe,h5,m5,$Ae,g5,zAe,qAe,UAe,og,na=Sr(()=>{"use strict";Yt();Yt();Ql();aY();Ql();Ql();Ql();Ql();Do=((n,e={})=>{let a=n,s=a._internal_store;if(!s){s={counts:{},editCount:0},a._internal_store=s;for(let d of a){let x=d.type,f=d[`${x}_id`];if(!f)continue;let m=Number.parseInt(f.split("_").pop());Number.isNaN(m)||(s.counts[x]=Math.max(s.counts[x]??0,m))}}return new Proxy({},{get:(d,x)=>{if(x==="toArray")return()=>(a.editCount=s.editCount,a);if(x==="editCount")return s.editCount;if(x==="subtree")return m=>Do(qb(a,m),e);let f=x;return{get:m=>a.find(y=>y.type===f&&y[`${f}_id`]===m),getUsing:m=>{let y=Object.keys(m);if(y.length!==1)throw new Error("getUsing requires exactly one key, e.g. { pcb_component_id }");let b=y[0],E=b.replace("_id",""),A=a.find(w=>w.type===E&&w[b]===m[b]);return A?a.find(w=>w.type===f&&w[`${f}_id`]===A[`${f}_id`]):null},getWhere:m=>{let y=Object.keys(m);return a.find(b=>b.type===f&&y.every(E=>b[E]===m[E]))},list:m=>{let y=m?Object.keys(m):[];return a.filter(b=>b.type===f&&y.every(E=>b[E]===m[E]))},insert:m=>{var E;(E=s.counts)[f]??(E[f]=-1),s.counts[f]++;let y=s.counts[f],b={type:f,[`${f}_id`]:`${f}_${y}`,...m};return e.validateInserts&&(Xf[f]??Gf).parse(b),a.push(b),s.editCount++,b},delete:m=>{let y=a.find(b=>b[`${f}_id`]===m);y&&(a.splice(a.indexOf(y),1),s.editCount++)},update:(m,y)=>{let b=a.find(E=>E.type===f&&E[`${f}_id`]===m);return b?(Object.assign(b,y),s.editCount++,b):null},select:m=>{if(f==="source_component")return a.find(y=>y.type==="source_component"&&y.name===m.replace(/\./g,""));if(f==="pcb_port"||f==="source_port"||f==="schematic_port"){let[y,b]=m.replace(/\./g,"").split(/[\s\>]+/),E=a.find(w=>w.type==="source_component"&&w.name===y);if(!E)return null;let A=a.find(w=>w.type==="source_port"&&w.source_component_id===E.source_component_id&&(w.name===b||(w.port_hints??[]).includes(b)));if(!A)return null;if(f==="source_port")return A;if(f==="pcb_port")return a.find(w=>w.type==="pcb_port"&&w.source_port_id===A.source_port_id);if(f==="schematic_port")return a.find(w=>w.type==="schematic_port"&&w.source_port_id===A.source_port_id)}}}}})});Do.unparsed=Do;ua=Do,ka=Do;IAe=((n,e={})=>{let a=n._internal_store_indexed;if(!a){a={counts:{},editCount:0,indexes:{}};for(let x of n){let f=x.type,m=x[`${f}_id`];if(!m)continue;let y=Number.parseInt(m.split("_").pop()||"");Number.isNaN(y)||(a.counts[f]=Math.max(a.counts[f]??0,y))}let l=e.indexConfig||{},d=a.indexes;if(l.byId&&(d.byId=new Map),l.byType&&(d.byType=new Map),l.byRelation&&(d.byRelation=new Map),l.bySubcircuit&&(d.bySubcircuit=new Map),l.byCustomField&&l.byCustomField.length>0){d.byCustomField=new Map;for(let x of l.byCustomField)d.byCustomField.set(x,new Map)}for(let x of n){if(l.byId){let f=DY(x);d.byId.set(f,x)}if(l.byType){let f=d.byType.get(x.type)||[];f.push(x),d.byType.set(x.type,f)}if(l.byRelation){let f=Object.entries(x);for(let[m,y]of f)if(m.endsWith("_id")&&m!==`${x.type}_id`&&typeof y=="string"){let b=d.byRelation.get(m)||new Map,E=b.get(y)||[];E.push(x),b.set(y,E),d.byRelation.set(m,b)}}if(l.bySubcircuit&&"subcircuit_id"in x){let f=x.subcircuit_id;if(f&&typeof f=="string"){let m=d.bySubcircuit.get(f)||[];m.push(x),d.bySubcircuit.set(f,m)}}if(l.byCustomField&&d.byCustomField){for(let f of l.byCustomField)if(f in x){let m=x[f];if(m!==void 0&&(typeof m=="string"||typeof m=="number")){let y=String(m),b=d.byCustomField.get(f),E=b.get(y)||[];E.push(x),b.set(y,E)}}}}n._internal_store_indexed=a}return new Proxy({},{get:(l,d)=>{if(d==="toArray")return()=>(n.editCount=a.editCount,n);if(d==="editCount")return a.editCount;let x=d;return{get:f=>{let m=e.indexConfig||{};return m.byId&&a.indexes.byId?a.indexes.byId.get(`${x}:${f}`)||null:m.byType&&a.indexes.byType?(a.indexes.byType.get(x)||[]).find(b=>b[`${x}_id`]===f)||null:n.find(y=>y.type===x&&y[`${x}_id`]===f)||null},getUsing:f=>{let m=e.indexConfig||{},y=Object.keys(f);if(y.length!==1)throw new Error("getUsing requires exactly one key, e.g. { pcb_component_id }");let b=y[0],E=b.replace("_id","");if(m.byRelation&&a.indexes.byRelation){let w=a.indexes.byRelation.get(b);if(w){let I=(w.get(f[b])||[]).find(G=>G.type===E);if(!I)return null;let q=I[`${x}_id`];return m.byId&&a.indexes.byId?a.indexes.byId.get(`${x}:${q}`)||null:m.byType&&a.indexes.byType?(a.indexes.byType.get(x)||[]).find(j=>j[`${x}_id`]===q)||null:n.find(G=>G.type===x&&G[`${x}_id`]===q)||null}}let A=n.find(w=>w.type===E&&w[b]===f[b]);return A&&n.find(w=>w.type===x&&w[`${x}_id`]===A[`${x}_id`])||null},getWhere:f=>{let m=e.indexConfig||{},y=Object.keys(f);if(y.length===1&&m.byCustomField&&a.indexes.byCustomField){let b=y[0],E=a.indexes.byCustomField.get(b);if(E){let A=String(f[b]);return(E.get(A)||[]).find(B=>B.type===x)||null}}if("subcircuit_id"in f&&m.bySubcircuit&&a.indexes.bySubcircuit){let b=f.subcircuit_id;return(a.indexes.bySubcircuit.get(b)||[]).find(A=>A.type===x&&y.every(w=>A[w]===f[w]))||null}return m.byType&&a.indexes.byType?(a.indexes.byType.get(x)||[]).find(E=>y.every(A=>E[A]===f[A]))||null:n.find(b=>b.type===x&&y.every(E=>b[E]===f[E]))||null},list:f=>{let m=e.indexConfig||{},y=f?Object.keys(f):[];if(y.length===0&&m.byType&&a.indexes.byType)return a.indexes.byType.get(x)||[];if(y.length===1&&y[0]==="subcircuit_id"&&m.bySubcircuit&&a.indexes.bySubcircuit){let E=f.subcircuit_id;return(a.indexes.bySubcircuit.get(E)||[]).filter(w=>w.type===x)}let b;return m.byType&&a.indexes.byType?b=a.indexes.byType.get(x)||[]:b=n.filter(E=>E.type===x),y.length>0?b.filter(E=>y.every(A=>E[A]===f[A])):b},insert:f=>{var E;(E=a.counts)[x]??(E[x]=-1),a.counts[x]++;let m=a.counts[x],y={type:x,[`${x}_id`]:`${x}_${m}`,...f};e.validateInserts&&(Xf[x]??Gf).parse(y),n.push(y),a.editCount++;let b=e.indexConfig||{};if(b.byId&&a.indexes.byId){let A=DY(y);a.indexes.byId.set(A,y)}if(b.byType&&a.indexes.byType){let A=a.indexes.byType.get(x)||[];A.push(y),a.indexes.byType.set(x,A)}if(b.byRelation&&a.indexes.byRelation){let A=Object.entries(y);for(let[w,B]of A)if(w.endsWith("_id")&&w!==`${y.type}_id`&&typeof B=="string"){let I=a.indexes.byRelation.get(w)||new Map,q=I.get(B)||[];q.push(y),I.set(B,q),a.indexes.byRelation.set(w,I)}}if(b.bySubcircuit&&a.indexes.bySubcircuit&&"subcircuit_id"in y){let A=y.subcircuit_id;if(A&&typeof A=="string"){let w=a.indexes.bySubcircuit.get(A)||[];w.push(y),a.indexes.bySubcircuit.set(A,w)}}if(b.byCustomField&&a.indexes.byCustomField){for(let A of b.byCustomField)if(A in y){let w=y[A];if(w!==void 0&&(typeof w=="string"||typeof w=="number")){let B=String(w),I=a.indexes.byCustomField.get(A),q=I.get(B)||[];q.push(y),I.set(B,q)}}}return y},delete:f=>{let m=e.indexConfig||{},y;if(m.byId&&a.indexes.byId?y=a.indexes.byId.get(`${x}:${f}`):m.byType&&a.indexes.byType?y=(a.indexes.byType.get(x)||[]).find(A=>A[`${x}_id`]===f):y=n.find(E=>E[`${x}_id`]===f),!y)return;let b=n.indexOf(y);if(b>=0&&(n.splice(b,1),a.editCount++),m.byId&&a.indexes.byId){let E=DY(y);a.indexes.byId.delete(E)}if(m.byType&&a.indexes.byType){let A=(a.indexes.byType.get(x)||[]).filter(w=>w[`${x}_id`]!==f);a.indexes.byType.set(x,A)}if(m.byRelation&&a.indexes.byRelation)for(let[E,A]of a.indexes.byRelation.entries())for(let[w,B]of A.entries()){let I=B.filter(q=>q!==y);I.length===0?A.delete(w):A.set(w,I)}if(m.bySubcircuit&&a.indexes.bySubcircuit&&"subcircuit_id"in y){let E=y.subcircuit_id;if(E){let w=(a.indexes.bySubcircuit.get(E)||[]).filter(B=>B!==y);w.length===0?a.indexes.bySubcircuit.delete(E):a.indexes.bySubcircuit.set(E,w)}}if(m.byCustomField&&a.indexes.byCustomField)for(let E of a.indexes.byCustomField.values())for(let[A,w]of E.entries()){let B=w.filter(I=>I!==y);B.length===0?E.delete(A):E.set(A,B)}},update:(f,m)=>{let y=e.indexConfig||{},b;if(y.byId&&a.indexes.byId?b=a.indexes.byId.get(`${x}:${f}`):y.byType&&a.indexes.byType?b=(a.indexes.byType.get(x)||[]).find(A=>A[`${x}_id`]===f):b=n.find(E=>E.type===x&&E[`${x}_id`]===f),!b)return null;if(y.byRelation&&a.indexes.byRelation){let E=Object.entries(b);for(let[A,w]of E)if(A.endsWith("_id")&&A!==`${b.type}_id`&&typeof w=="string"&&A in m&&m[A]!==w){let B=a.indexes.byRelation.get(A);if(B){let q=(B.get(w)||[]).filter(G=>G!==b);q.length===0?B.delete(w):B.set(w,q)}}}if(y.bySubcircuit&&a.indexes.bySubcircuit&&"subcircuit_id"in b&&"subcircuit_id"in m){let E=b.subcircuit_id,A=m.subcircuit_id;if(E!==A){let B=(a.indexes.bySubcircuit.get(E)||[]).filter(I=>I!==b);B.length===0?a.indexes.bySubcircuit.delete(E):a.indexes.bySubcircuit.set(E,B)}}if(y.byCustomField&&a.indexes.byCustomField){for(let E of y.byCustomField)if(E in b&&E in m&&b[E]!==m[E]){let A=a.indexes.byCustomField.get(E);if(A){let w=String(b[E]),I=(A.get(w)||[]).filter(q=>q!==b);I.length===0?A.delete(w):A.set(w,I)}}}if(Object.assign(b,m),a.editCount++,y.byRelation&&a.indexes.byRelation){let E=Object.entries(b);for(let[A,w]of E)if(A.endsWith("_id")&&A!==`${b.type}_id`&&typeof w=="string"&&A in m){let B=a.indexes.byRelation.get(A)||new Map,I=B.get(w)||[];I.includes(b)||(I.push(b),B.set(w,I),a.indexes.byRelation.set(A,B))}}if(y.bySubcircuit&&a.indexes.bySubcircuit&&"subcircuit_id"in b&&"subcircuit_id"in m){let E=b.subcircuit_id;if(E&&typeof E=="string"){let A=a.indexes.bySubcircuit.get(E)||[];A.includes(b)||(A.push(b),a.indexes.bySubcircuit.set(E,A))}}if(y.byCustomField&&a.indexes.byCustomField){for(let E of y.byCustomField)if(E in b&&E in m){let A=b[E];if(A!==void 0&&(typeof A=="string"||typeof A=="number")){let w=String(A),B=a.indexes.byCustomField.get(E),I=B.get(w)||[];I.includes(b)||(I.push(b),B.set(w,I))}}}return b},select:f=>{if(x==="source_component")return n.find(m=>m.type==="source_component"&&m.name===f.replace(/\./g,""))||null;if(x==="pcb_port"||x==="source_port"||x==="schematic_port"){let[m,y]=f.replace(/\./g,"").split(/[\s\>]+/),b=n.find(A=>A.type==="source_component"&&A.name===m);if(!b)return null;let E=n.find(A=>A.type==="source_port"&&A.source_component_id===b.source_component_id&&(A.name===y||(A.port_hints??[]).includes(y)));if(!E)return null;if(x==="source_port")return E;if(x==="pcb_port")return n.find(A=>A.type==="pcb_port"&&A.source_port_id===E.source_port_id)||null;if(x==="schematic_port")return n.find(A=>A.type==="schematic_port"&&A.source_port_id===E.source_port_id)||null}return null}}}})});IAe.unparsed=IAe;hNt=n=>{if(n==="up")return"right";if(n==="right")return"down";if(n==="down")return"left";if(n==="left")return"up";throw new Error(`Invalid direction: ${n}`)},mNt=n=>{if(n==="up")return"left";if(n==="left")return"down";if(n==="down")return"right";if(n==="right")return"up";throw new Error(`Invalid direction: ${n}`)},gNt=(n,e)=>{for(;e>0;)n=hNt(n),e--;for(;e<0;)n=mNt(n),e++;return n},NAe=n=>{if(n==="top"||n==="up")return"bottom";if(n==="bottom"||n==="down")return"top";if(n==="left")return"right";if(n==="right")return"left";throw new Error(`Invalid sideOrDir: ${n}`)},yNt=(n,e)=>{if(n.type==="schematic_component")n.center=Ja(e,n.center);else if(n.type==="schematic_port")n.center=Ja(e,n.center),n.facing_direction&&(n.facing_direction=gNt(n.facing_direction,-(Math.atan2(e.b,e.a)/Math.PI)*2));else if(n.type==="schematic_text")n.position=Ja(e,n.position);else if(n.type==="schematic_trace"){let a=n;a.route=(a.route??[]).map(s=>{let l=Ja(e,s);return s.x=l.x,s.y=l.y,s}),Array.isArray(a.junctions)&&(a.junctions=a.junctions.map(s=>{let l=Ja(e,s);return s.x=l.x,s.y=l.y,s})),Array.isArray(a.edges)&&(a.edges=a.edges.map(s=>(s.from=Ja(e,s.from),s.to=Ja(e,s.to),s)))}else if(n.type==="schematic_box"){let{x:a,y:s}=Ja(e,{x:n.x,y:n.y});n.x=a,n.y=s}else if(n.type==="schematic_line"){let{x:a,y:s}=Ja(e,{x:n.x1,y:n.y1}),{x:l,y:d}=Ja(e,{x:n.x2,y:n.y2});n.x1=a,n.y1=s,n.x2=l,n.y2=d}return n},kAe=(n,e)=>n.map(a=>yNt(a,e)),bY=(n,e)=>{let a=WR(e),s=Math.round(a.rotation.angle/(Math.PI/2))%2===1;if(n.type==="pcb_plated_hole"||n.type==="pcb_hole"||n.type==="pcb_via"||n.type==="pcb_smtpad"||n.type==="pcb_port"){let{x:l,y:d}=Ja(e,{x:Number(n.x),y:Number(n.y)});n.x=l,n.y=d}else if(n.type==="pcb_keepout"||n.type==="pcb_board")n.center=Ja(e,n.center);else if(n.type==="pcb_silkscreen_text"||n.type==="pcb_fabrication_note_text")n.anchor_position=Ja(e,n.anchor_position);else if(n.type==="pcb_silkscreen_circle"||n.type==="pcb_silkscreen_rect")n.center=Ja(e,n.center);else if(n.type==="pcb_component")n.center=Ja(e,n.center),n.rotation=n.rotation+a.rotation.angle/Math.PI*180,n.rotation=n.rotation%360,s&&([n.width,n.height]=[n.height,n.width]);else if(n.type==="pcb_silkscreen_path"||n.type==="pcb_trace"||n.type==="pcb_fabrication_note_path")n.route=n.route.map(l=>{let d=Ja(e,l);return l.x=d.x,l.y=d.y,l});else if(n.type==="pcb_silkscreen_line"){let l={x:n.x1,y:n.y1},d={x:n.x2,y:n.y2},x=Ja(e,l),f=Ja(e,d);n.x1=x.x,n.y1=x.y,n.x2=f.x,n.y2=f.y}else if(n.type==="cad_component"){let l=Ja(e,{x:n.position.x,y:n.position.y});n.position.x=l.x,n.position.y=l.y}return n},Ub=(n,e)=>{let a=WR(e),s=Math.round(a.rotation.angle/(Math.PI/2))%2===1,l=n.map(d=>bY(d,e));return s&&(l=l.map(d=>(d.type==="pcb_smtpad"&&d.shape==="rect"&&([d.width,d.height]=[d.height,d.width]),d))),l},MAe=n=>{let e=n.type;return n[`${e}_id`]},DNt=(n,e)=>n.find(a=>MAe(a)===e)??null;FY=(n,e)=>{let a=Do(n).pcb_port.get(e);if(!a)return`pcb_port[#${e}]`;let s=Do(n).pcb_component.get(a?.pcb_component_id);if(!s)return`pcb_port[#${e}]`;let l=Do(n).source_component.get(s.source_component_id);if(!l)return`pcb_port[#${e}]`;let d=Do(n).source_port.get(a.source_port_id);if(!d)return`pcb_port[#${e}]`;let x;return d?.port_hints&&d.port_hints.length>0||d.port_hints&&d.port_hints.length>0?x=d.port_hints[0]:x=e,`pcb_port[.${l.name} > .${x}]`};Vb=(n,e)=>{if(typeof e=="string"){let a=DNt(n,e);return a||`${e}`,Vb(n,a)}switch(e.type){case"pcb_port":return FY(n,e.pcb_port_id);case"pcb_smtpad":return FNt(n,e.pcb_smtpad_id);case"pcb_trace":return bNt(n,e.pcb_trace_id);case"source_component":return`source_component[${e.name}]`;default:return`${e.type}[#${MAe(e)}]`}},OAe=n=>{let e=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY;for(let d of n){if(!d.type.startsWith("pcb_"))continue;let x,f,m,y;if("x"in d&&"y"in d&&(x=Number(d.x),f=Number(d.y)),"outer_diameter"in d&&(m=Number(d.outer_diameter),y=Number(d.outer_diameter)),"width"in d&&(m=Number(d.width)),"height"in d&&(y=Number(d.height)),"center"in d&&(x=d.center.x,f=d.center.y),x!==void 0&&f!==void 0)e=Math.min(e,x),a=Math.min(a,f),s=Math.max(s,x),l=Math.max(l,f),m!==void 0&&y!==void 0&&(e=Math.min(e,x-m/2),a=Math.min(a,f-y/2),s=Math.max(s,x+m/2),l=Math.max(l,f+y/2)),"radius"in d&&(e=Math.min(e,x-d.radius),a=Math.min(a,f-d.radius),s=Math.max(s,x+d.radius),l=Math.max(l,f+d.radius));else if(d.type==="pcb_trace")for(let b of d.route)e=Math.min(e,b.x),a=Math.min(a,b.y),s=Math.max(s,b.x),l=Math.max(l,b.y)}return{minX:e,minY:a,maxX:s,maxY:l}};jAe=[["#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"]],vNt=n=>{let{x:e,y:a,width:s,height:l}={...n,...n.size,...n.center,...n.position};if(n.x1!==void 0&&n.x2!==void 0&&n.y1!==void 0&&n.y2!==void 0&&(e=(n.x1+n.x2)/2,a=(n.y1+n.y2)/2,s=Math.abs(n.x1-n.x2),l=Math.abs(n.y1-n.y2)),n.points&&Array.isArray(n.points)&&n.points.length>0){let f=n.points.map(w=>w.x),m=n.points.map(w=>w.y),y=Math.min(...f),b=Math.max(...f),E=Math.min(...m),A=Math.max(...m);e=(y+b)/2,a=(E+A)/2,s=b-y,l=A-E}let d=n.text||n.name||n.source?.text||n.source?.name||"?",x=n;return e===void 0||a===void 0?null:(s===void 0&&"outer_diameter"in n&&(s=n.outer_diameter,l=n.outer_diameter),(s===void 0||l===void 0)&&(s=.1,l=.1),{x:e,y:a,width:s,height:l,title:d,content:x,bg_color:jAe[ENt(n.type||d)%jAe.length]?.[4]??"#f00"})},CNt=n=>!!n,LAe=n=>{let e=n.filter(y=>y.type.startsWith("pcb_")||y.type.startsWith("schematic_")).concat(n.filter(y=>y.type==="pcb_trace"||y.type==="schematic_trace").flatMap(y=>y.route)).map(y=>vNt(y)).filter(CNt);if(e.length===0)return{center:{x:0,y:0},width:0,height:0};let a=e[0].x-e[0].width/2,s=e[0].x+e[0].width/2,l=e[0].y-e[0].height/2,d=e[0].y+e[0].height/2;for(let y of e.slice(1))a=Math.min(a,y.x-y.width/2),s=Math.max(s,y.x+y.width/2),l=Math.min(l,y.y-y.height/2),d=Math.max(d,y.y+y.height/2);let x=s-a,f=d-l;return{center:{x:a+x/2,y:l+f/2},width:x,height:f}},h5=n=>n[`${n.type}_id`],m5=(n,e,a)=>{let s=n.find(b=>b.type==="pcb_component"&&b.pcb_component_id===e);if(!s)return;let l="center"in s?s.center:{x:s.x,y:s.y},d=a.x-l.x,x=a.y-l.y,f=n.filter(b=>b.type==="pcb_port"&&b.pcb_component_id===e).map(b=>b.pcb_port_id),m=n.filter(b=>{if(b===s)return!0;let E=b;return!!(E.pcb_component_id===e||Array.isArray(E.pcb_component_ids)&&E.pcb_component_ids.includes(e)||E.pcb_port_id&&f.includes(E.pcb_port_id)||Array.isArray(E.pcb_port_ids)&&E.pcb_port_ids.some(A=>f.includes(A))||E.start_pcb_port_id&&f.includes(E.start_pcb_port_id)||E.end_pcb_port_id&&f.includes(E.end_pcb_port_id)||Array.isArray(E.route)&&E.route.some(A=>A.start_pcb_port_id&&f.includes(A.start_pcb_port_id)||A.end_pcb_port_id&&f.includes(A.end_pcb_port_id)))}),y=Yi(d,x);Ub(m,y)},$Ae=(n,e)=>{let a=[],s=n.filter(l=>l.type==="source_group"&&l.parent_source_group_id===e).map(l=>l.source_group_id);a.push(...s);for(let l of s)a.push(...$Ae(n,l));return a},g5=(n,e,a)=>{let s=[e,...$Ae(n,e)],l=new Set;for(let A of s)qb(n,{source_group_id:A}).forEach(B=>l.add(B));let d=Array.from(l).filter(A=>A.type==="pcb_port").map(A=>A.pcb_port_id);n.filter(A=>{if(A.type!=="pcb_trace"||l.has(A))return!1;let w=A;return!!(w.start_pcb_port_id&&d.includes(w.start_pcb_port_id)||w.end_pcb_port_id&&d.includes(w.end_pcb_port_id)||Array.isArray(w.route)&&w.route.some(B=>B.start_pcb_port_id&&d.includes(B.start_pcb_port_id)||B.end_pcb_port_id&&d.includes(B.end_pcb_port_id)))}).forEach(A=>l.add(A));let f=Array.from(l).filter(A=>A.type.startsWith("pcb_"));if(f.length===0)return;let{center:m}=LAe(f),y=a.x-m.x,b=a.y-m.y,E=Yi(y,b);Ub(f,E)},zAe=(n,e,a)=>{let s=n.find(b=>b.type==="schematic_component"&&b.schematic_component_id===e);if(!s)return;let l="center"in s?s.center:{x:s.x,y:s.y},d=a.x-l.x,x=a.y-l.y,f=n.filter(b=>b.type==="schematic_port"&&b.schematic_component_id===e).map(b=>b.schematic_port_id),m=n.filter(b=>{if(b===s)return!0;let E=b;return!!(E.schematic_component_id===e||Array.isArray(E.schematic_component_ids)&&E.schematic_component_ids.includes(e)||E.schematic_port_id&&f.includes(E.schematic_port_id)||Array.isArray(E.schematic_port_ids)&&E.schematic_port_ids.some(A=>f.includes(A))||E.start_schematic_port_id&&f.includes(E.start_schematic_port_id)||E.end_schematic_port_id&&f.includes(E.end_schematic_port_id)||Array.isArray(E.route)&&E.route.some(A=>A.start_schematic_port_id&&f.includes(A.start_schematic_port_id)||A.end_schematic_port_id&&f.includes(A.end_schematic_port_id)))}),y=Yi(d,x);kAe(m,y)},qAe=(n,e)=>{let a=[],s=n.filter(l=>l.type==="source_group"&&l.parent_source_group_id===e).map(l=>l.source_group_id);a.push(...s);for(let l of s)a.push(...qAe(n,l));return a},UAe=(n,e,a)=>{let s=[e,...qAe(n,e)],l=new Set;for(let A of s)qb(n,{source_group_id:A}).forEach(B=>l.add(B));let d=Array.from(l).filter(A=>A.type==="schematic_port").map(A=>A.schematic_port_id);n.filter(A=>{if(A.type!=="schematic_trace"||l.has(A))return!1;let w=A;return!!(w.start_schematic_port_id&&d.includes(w.start_schematic_port_id)||w.end_schematic_port_id&&d.includes(w.end_schematic_port_id)||Array.isArray(w.route)&&w.route.some(B=>B.start_schematic_port_id&&d.includes(B.start_schematic_port_id)||B.end_schematic_port_id&&d.includes(B.end_schematic_port_id)))}).forEach(A=>l.add(A));let f=Array.from(l).filter(A=>A.type.startsWith("schematic_"));if(f.length===0)return;let{center:m}=LAe(f),y=a.x-m.x,b=a.y-m.y,E=Yi(y,b);kAe(f,E)},og=(n,e)=>{let a=new Map,s=new Set;for(let y of n)y.type==="source_group"&&s.add(y.source_group_id);let l=[];for(let y of n)if(y.type==="source_group"&&y.parent_source_group_id){let b=y.parent_source_group_id,E=y.source_group_id;if(!s.has(b))l.push(E),a.has(E)||a.set(E,[]);else{let A=a.get(b)??[];A.push(E),a.set(b,A),a.has(E)||a.set(E,[])}}for(let y of n)y.type==="source_group"&&!a.has(y.source_group_id)&&a.set(y.source_group_id,[]);let d=new Map,x=()=>{for(let[y,b]of a)if(!d.has(y)&&b.every(E=>d.has(E)))return y;return null},f=null;for(;;){let y=x();if(!y)break;let E={nodeType:"group",sourceGroup:n.find(A=>A.type==="source_group"&&A.source_group_id===y),otherChildElements:[],childNodes:[...a.get(y)?.map(A=>d.get(A))??[],...n.filter(A=>A.type==="source_component"&&A.source_group_id===y).map(A=>({nodeType:"component",sourceComponent:A,childNodes:[],otherChildElements:[...n.filter(w=>w.type==="pcb_component"&&w.source_component_id===A.source_component_id)]}))]};d.set(y,E),f=y}if(!f)return console.warn("No groups were processed, returning tree without sourceGroup"),{nodeType:"group",childNodes:[],otherChildElements:n};let m=null;return e&&e.source_group_id!==void 0?m=e.source_group_id:l.length>0?m=l[0]:m=f,m?d.get(m):(console.warn("No valid root group found, returning tree without sourceGroup"),{nodeType:"group",childNodes:[],otherChildElements:n})}});var EY=on((VAe,GAe)=>{"use strict";(function(n){var e;typeof VAe=="object"?GAe.exports=n():typeof define=="function"&&define.amd?define(n):(typeof window<"u"?e=window:typeof global<"u"?e=global:typeof self<"u"&&(e=self),e.objectHash=n())})(function(){return(function n(e,a,s){function l(f,m){if(!a[f]){if(!e[f]){var y=typeof ib=="function"&&ib;if(!m&&y)return y(f,!0);if(d)return d(f,!0);throw new Error("Cannot find module '"+f+"'")}m=a[f]={exports:{}},e[f][0].call(m.exports,function(b){var E=e[f][1][b];return l(E||b)},m,m.exports,n,e,a,s)}return a[f].exports}for(var d=typeof ib=="function"&&ib,x=0;x<s.length;x++)l(s[x]);return l})({1:[function(n,e,a){(function(s,l,d,x,f,m,y,b,E){"use strict";var A=n("crypto");function w(V,te){te=q(V,te);var N;return(N=te.algorithm!=="passthrough"?A.createHash(te.algorithm):new O).write===void 0&&(N.write=N.update,N.end=N.update),j(te,N).dispatch(V),N.update||N.end(""),N.digest?N.digest(te.encoding==="buffer"?void 0:te.encoding):(V=N.read(),te.encoding!=="buffer"?V.toString(te.encoding):V)}(a=e.exports=w).sha1=function(V){return w(V)},a.keys=function(V){return w(V,{excludeValues:!0,algorithm:"sha1",encoding:"hex"})},a.MD5=function(V){return w(V,{algorithm:"md5",encoding:"hex"})},a.keysMD5=function(V){return w(V,{algorithm:"md5",encoding:"hex",excludeValues:!0})};var B=A.getHashes?A.getHashes().slice():["sha1","md5"],I=(B.push("passthrough"),["buffer","hex","binary","base64"]);function q(V,te){var N={};if(N.algorithm=(te=te||{}).algorithm||"sha1",N.encoding=te.encoding||"hex",N.excludeValues=!!te.excludeValues,N.algorithm=N.algorithm.toLowerCase(),N.encoding=N.encoding.toLowerCase(),N.ignoreUnknown=te.ignoreUnknown===!0,N.respectType=te.respectType!==!1,N.respectFunctionNames=te.respectFunctionNames!==!1,N.respectFunctionProperties=te.respectFunctionProperties!==!1,N.unorderedArrays=te.unorderedArrays===!0,N.unorderedSets=te.unorderedSets!==!1,N.unorderedObjects=te.unorderedObjects!==!1,N.replacer=te.replacer||void 0,N.excludeKeys=te.excludeKeys||void 0,V===void 0)throw new Error("Object argument required.");for(var se=0;se<B.length;++se)B[se].toLowerCase()===N.algorithm.toLowerCase()&&(N.algorithm=B[se]);if(B.indexOf(N.algorithm)===-1)throw new Error('Algorithm "'+N.algorithm+'" not supported. supported values: '+B.join(", "));if(I.indexOf(N.encoding)===-1&&N.algorithm!=="passthrough")throw new Error('Encoding "'+N.encoding+'" not supported. supported values: '+I.join(", "));return N}function G(V){if(typeof V=="function")return/^function\s+\w*\s*\(\s*\)\s*{\s+\[native code\]\s+}$/i.exec(Function.prototype.toString.call(V))!=null}function j(V,te,N){N=N||[];function se($){return te.update?te.update($,"utf8"):te.write($,"utf8")}return{dispatch:function($){return this["_"+(($=V.replacer?V.replacer($):$)===null?"null":typeof $)]($)},_object:function($){var W,Q=Object.prototype.toString.call($),le=/\[object (.*)\]/i.exec(Q);if(le=(le=le?le[1]:"unknown:["+Q+"]").toLowerCase(),0<=(Q=N.indexOf($)))return this.dispatch("[CIRCULAR:"+Q+"]");if(N.push($),d!==void 0&&d.isBuffer&&d.isBuffer($))return se("buffer:"),se($);if(le==="object"||le==="function"||le==="asyncfunction")return Q=Object.keys($),V.unorderedObjects&&(Q=Q.sort()),V.respectType===!1||G($)||Q.splice(0,0,"prototype","__proto__","constructor"),V.excludeKeys&&(Q=Q.filter(function(z){return!V.excludeKeys(z)})),se("object:"+Q.length+":"),W=this,Q.forEach(function(z){W.dispatch(z),se(":"),V.excludeValues||W.dispatch($[z]),se(",")});if(!this["_"+le]){if(V.ignoreUnknown)return se("["+le+"]");throw new Error('Unknown object type "'+le+'"')}this["_"+le]($)},_array:function($,z){z=z!==void 0?z:V.unorderedArrays!==!1;var Q=this;if(se("array:"+$.length+":"),!z||$.length<=1)return $.forEach(function(pe){return Q.dispatch(pe)});var le=[],z=$.map(function(pe){var xe=new O,Ae=N.slice();return j(V,xe,Ae).dispatch(pe),le=le.concat(Ae.slice(N.length)),xe.read().toString()});return N=N.concat(le),z.sort(),this._array(z,!1)},_date:function($){return se("date:"+$.toJSON())},_symbol:function($){return se("symbol:"+$.toString())},_error:function($){return se("error:"+$.toString())},_boolean:function($){return se("bool:"+$.toString())},_string:function($){se("string:"+$.length+":"),se($.toString())},_function:function($){se("fn:"),G($)?this.dispatch("[native]"):this.dispatch($.toString()),V.respectFunctionNames!==!1&&this.dispatch("function-name:"+String($.name)),V.respectFunctionProperties&&this._object($)},_number:function($){return se("number:"+$.toString())},_xml:function($){return se("xml:"+$.toString())},_null:function(){return se("Null")},_undefined:function(){return se("Undefined")},_regexp:function($){return se("regex:"+$.toString())},_uint8array:function($){return se("uint8array:"),this.dispatch(Array.prototype.slice.call($))},_uint8clampedarray:function($){return se("uint8clampedarray:"),this.dispatch(Array.prototype.slice.call($))},_int8array:function($){return se("int8array:"),this.dispatch(Array.prototype.slice.call($))},_uint16array:function($){return se("uint16array:"),this.dispatch(Array.prototype.slice.call($))},_int16array:function($){return se("int16array:"),this.dispatch(Array.prototype.slice.call($))},_uint32array:function($){return se("uint32array:"),this.dispatch(Array.prototype.slice.call($))},_int32array:function($){return se("int32array:"),this.dispatch(Array.prototype.slice.call($))},_float32array:function($){return se("float32array:"),this.dispatch(Array.prototype.slice.call($))},_float64array:function($){return se("float64array:"),this.dispatch(Array.prototype.slice.call($))},_arraybuffer:function($){return se("arraybuffer:"),this.dispatch(new Uint8Array($))},_url:function($){return se("url:"+$.toString())},_map:function($){return se("map:"),$=Array.from($),this._array($,V.unorderedSets!==!1)},_set:function($){return se("set:"),$=Array.from($),this._array($,V.unorderedSets!==!1)},_file:function($){return se("file:"),this.dispatch([$.name,$.size,$.type,$.lastModfied])},_blob:function(){if(V.ignoreUnknown)return se("[blob]");throw Error(`Hashing Blob objects is currently not supported
17
+ at `+x}return e};G6.buildMessage=function(n,e){var a={literal:function(y){return'"'+l(y.text)+'"'},class:function(y){var b=y.parts.map(function(E){return Array.isArray(E)?d(E[0])+"-"+d(E[1]):d(E)});return"["+(y.inverted?"^":"")+b.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(y){return y.description}};function s(y){return y.charCodeAt(0).toString(16).toUpperCase()}function l(y){return y.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(b){return"\\x0"+s(b)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(b){return"\\x"+s(b)})}function d(y){return y.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(b){return"\\x0"+s(b)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(b){return"\\x"+s(b)})}function x(y){return a[y.type](y)}function f(y){var b=y.map(x),E,A;if(b.sort(),b.length>0){for(E=1,A=1;E<b.length;E++)b[E-1]!==b[E]&&(b[A]=b[E],A++);b.length=A}switch(b.length){case 1:return b[0];case 2:return b[0]+" or "+b[1];default:return b.slice(0,-1).join(", ")+", or "+b[b.length-1]}}function m(y){return y?'"'+l(y)+'"':"end of input"}return"Expected "+f(n)+" but "+m(e)+" found."};q4t=(n,e="right")=>{switch(e){case"down":switch(n){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(n){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(n){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 n}return n},X6=(n,e)=>{let{primitives:a,center:s,ports:l,size:d}=n,x=V6({a:1,b:0,c:0,d:-1,e:0,f:2*s.y}),f=a.map(y=>{switch(y={...y},y.type){case"path":return{...y,points:y.points.map(w=>du(x,w))};case"text":let b=du(x,{x:y.x,y:y.y}),E={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{...y,x:b.x,y:b.y,anchor:E[y.anchor]};case"circle":case"box":let A=du(x,{x:y.x,y:y.y});return{...y,x:A.x,y:A.y}}}),m=l.map(y=>({...y,...du(x,y)}));return{primitives:f,center:s,ports:m,size:d,...e}},gb=(n,e)=>{let{primitives:a,center:s,ports:l,size:d}=n,x=V6({a:-1,b:0,c:0,d:1,e:0,f:2*s.x}),f=a.map(y=>{switch(y={...y},y.type){case"path":return{...y,points:y.points.map(w=>du(x,w))};case"text":let b=du(x,{x:y.x,y:y.y}),E={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{...y,x:b.x,y:b.y,anchor:E[y.anchor]};case"circle":case"box":let A=du(x,{x:y.x,y:y.y});return{...y,x:A.x,y:A.y}}}),m=l.map(y=>({...y,...du(x,y)}));return{primitives:f,center:s,ports:m,size:d,...e}},hU=(n,e)=>{let{newOrientation:a,overrides:s}=e,l={up:Math.PI/2,right:0,down:-Math.PI/2,left:-Math.PI},d=$4t(a?l[a]:Math.PI/2,n.center.x,n.center.y),{primitives:x,center:f,size:m,ports:y}=n,b=x.map(w=>{switch(w={...w},w.type){case"path":return{...w,points:w.points.map(G=>du(d,G))};case"text":let B=du(d,{x:w.x,y:w.y});return w.anchor=q4t(w.anchor,a??"right"),{...w,x:B.x,y:B.y};case"circle":let I=du(d,{x:w.x,y:w.y});return{...w,x:I.x,y:I.y};case"box":let q=du(d,{x:w.x,y:w.y});return{...w,x:q.x,y:q.y,width:w.height,height:w.width}}}),E=y.map(w=>({...w,...du(d,w)})),A=fU(b);return{primitives:b,center:f,ports:E,size:{width:A.maxX-A.minX,height:A.maxY-A.minY},...s}},ur=(n,e="down",a={})=>hU(n,{newOrientation:e,overrides:a}),U4t=class{constructor(n){X(this,"symbol");this.symbol=JSON.parse(JSON.stringify(n)),this.symbol.size=this.computeSize()}changeTextAnchor(n,e,a){return this.symbol={...this.symbol,primitives:this.symbol.primitives.map(s=>s.type==="text"&&s.text===n?{...s,anchor:e,...a?{x:s.x+a.x,y:s.y+a.y}:{}}:s)},this}labelPort(n,e){return this.symbol={...this.symbol,ports:this.symbol.ports.map(a=>a.labels.includes(n)?{...a,labels:e}:a)},this}rotateRightFacingSymbol(n){return this.symbol=hU(this.symbol,{newOrientation:n}),this}computeSize(){let n=fU(this.symbol.primitives);return{width:n.maxX-n.minX,height:n.maxY-n.minY}}build(){return{...this.symbol,size:this.computeSize()}}},Ft=n=>{let e=n.primitives??[...Object.values(n.paths??{}),...Object.values(n.texts??{}),...Object.values(n.circles??{}),...Object.values(n.rects??{})],a=n.ports??Object.entries(n.refblocks).flatMap(([l,d])=>[{...d,labels:[l]}]),s=n.center??{x:n.bounds.centerX,y:n.bounds.centerY};return a.length===2&&(s={x:(a[0].x+a[1].x)/2,y:(a[0].y+a[1].y)/2}),new U4t({...n,primitives:e,ports:a,center:s})},Xm={paths:{path11:{type:"path",points:[{x:-.53,y:.04},{x:-.3,y:.04}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:.04},{x:.53,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:V4t,texts:CQt,bounds:t4,refblocks:u3e,circles:G4t}=Xm,X4t=Ft({primitives:[...Object.values(V4t),...Object.values(G4t),{type:"text",text:"{REF}",x:-.15,y:.3894553499999995},{type:"text",text:"{VAL}",x:.15,y:.3894553499999995}],ports:[{...u3e.left1,labels:["1"]},{...u3e.right1,labels:["2"]}],size:{width:t4.width,height:t4.height},center:{x:t4.centerX,y:t4.centerY}}).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:Y4t,texts:_Qt,bounds:r4,refblocks:c3e,circles:H4t}=Xm,W4t=Ft({primitives:[...Object.values(Y4t),...Object.values(H4t),{type:"text",text:"{REF}",x:-0,y:.4094553499999995},{type:"text",text:"{VAL}",x:0,y:-.4094553499999995}],ports:[{...c3e.left1,labels:["1"]},{...c3e.right1,labels:["2"]}],size:{width:r4.width,height:r4.height},center:{x:r4.centerX,y:r4.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:K4t,texts:AQt,bounds:n4,refblocks:l3e,circles:J4t}=Xm,Z4t=Ft({primitives:[...Object.values(K4t),...Object.values(J4t),{type:"text",text:"{REF}",x:-0,y:-.3094553499999995},{type:"text",text:"{VAL}",x:0,y:.4094553499999995}],ports:[{...l3e.left1,labels:["1"]},{...l3e.right1,labels:["2"]}],size:{width:n4.width,height:n4.height},center:{x:n4.centerX,y:n4.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:Q4t,texts:RQt,bounds:a4,refblocks:d3e,circles:e6t}=Xm,t6t=Ft({primitives:[...Object.values(Q4t),...Object.values(e6t),{type:"text",text:"{REF}",x:-0,y:.4094553499999995},{type:"text",text:"{VAL}",x:0,y:-.4094553499999995}],ports:[{...d3e.left1,labels:["1"]},{...d3e.right1,labels:["2"]}],size:{width:a4.width,height:a4.height},center:{x:a4.centerX,y:a4.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:r6t,texts:SQt,bounds:s4,refblocks:p3e,circles:n6t}=Xm,a6t=Ft({primitives:[...Object.values(r6t),...Object.values(n6t),{type:"text",text:"{REF}",x:.15,y:-.2894553499999995},{type:"text",text:"{VAL}",x:-.15,y:-.2894553499999995}],ports:[{...p3e.left1,labels:["1"]},{...p3e.right1,labels:["2"]}],size:{width:s4.width,height:s4.height},center:{x:s4.centerX,y:s4.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:s6t,texts:wQt,bounds:i4,refblocks:x3e,circles:i6t}=Xm,o6t=Ft({primitives:[...Object.values(s6t),...Object.values(i6t),{type:"text",text:"{REF}",x:.15,y:-.2894553499999995},{type:"text",text:"{VAL}",x:-.15,y:-.2894553499999995}],ports:[{...x3e.left1,labels:["1"]},{...x3e.right1,labels:["2"]}],size:{width:i4.width,height:i4.height},center:{x:i4.centerX,y:i4.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),Ym={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:u6t,texts:BQt,bounds:o4,refblocks:f3e,circles:c6t}=Ym,l6t=Ft({primitives:[...Object.values(u6t),...Object.values(c6t),{type:"text",text:"{REF}",x:-.15,y:.3294553499999995},{type:"text",text:"{VAL}",x:.15,y:.3294553499999995}],ports:[{...f3e.left1,labels:["1"]},{...f3e.right1,labels:["2"]}],size:{width:o4.width,height:o4.height},center:{x:o4.centerX,y:o4.centerY}}).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),d6t=Ft(Ym).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1","neg"]).labelPort("right1",["2","pos"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:p6t,texts:TQt,bounds:u4,refblocks:h3e,circles:x6t}=Ym,f6t=Ft({primitives:[...Object.values(p6t),...Object.values(x6t),{type:"text",text:"{REF}",x:-0,y:-.2294553499999995},{type:"text",text:"{VAL}",x:0,y:.3294553499999995}],ports:[{...h3e.left1,labels:["1"]},{...h3e.right1,labels:["2"]}],size:{width:u4.width,height:u4.height},center:{x:u4.centerX,y:u4.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),h6t=Ft(Ym).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1","neg"]).labelPort("right1",["2","pos"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:m6t,texts:PQt,bounds:c4,refblocks:m3e,circles:g6t}=Ym,y6t=Ft({primitives:[...Object.values(m6t),...Object.values(g6t),{type:"text",text:"{REF}",x:.15,y:-.2294553499999995},{type:"text",text:"{VAL}",x:-.15,y:-.2294553499999995}],ports:[{...m3e.left1,labels:["1"]},{...m3e.right1,labels:["2"]}],size:{width:c4.width,height:c4.height},center:{x:c4.centerX,y:c4.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:D6t,texts:IQt,bounds:l4,refblocks:g3e,circles:b6t}=Ym,F6t=Ft({primitives:[...Object.values(D6t),...Object.values(b6t),{type:"text",text:"{REF}",x:.15,y:-.2294553499999995},{type:"text",text:"{VAL}",x:-.15,y:-.2294553499999995}],ports:[{...g3e.left1,labels:["1"]},{...g3e.right1,labels:["2"]}],size:{width:l4.width,height:l4.height},center:{x:l4.centerX,y:l4.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),Y6={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:E6t,texts:jQt,bounds:d4,refblocks:y3e,circles:v6t}=Y6,C6t=Ft({primitives:[...Object.values(E6t),...Object.values(v6t),{type:"text",text:"{REF}",x:-.16,y:.2294553499999995},{type:"text",text:"{VAL}",x:.16,y:.2294553499999995}],ports:[{...y3e.left1,labels:["1"]},{...y3e.right1,labels:["2"]}],size:{width:d4.width,height:d4.height},center:{x:d4.centerX,y:d4.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").build(),{paths:_6t,texts:NQt,bounds:p4,refblocks:D3e,circles:A6t}=Y6,gve=Ft({primitives:[...Object.values(_6t),...Object.values(A6t),{type:"text",text:"{REF}",x:-1118e-7,y:-.18},{type:"text",text:"{VAL}",x:1118e-7,y:.2738453}],ports:[{...D3e.left1,labels:["1"]},{...D3e.right1,labels:["2"]}],size:{width:p4.width,height:p4.height},center:{x:p4.centerX,y:p4.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("left").labelPort("left1",["2"]).labelPort("right1",["1"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:R6t,texts:kQt,bounds:x4,refblocks:b3e,circles:S6t}=Y6,w6t=Ft({primitives:[...Object.values(R6t),...Object.values(S6t),{type:"text",text:"{REF}",x:-.0050250999999996715,y:.27384529999999985,anchor:"middle_left"},{type:"text",text:"{VAL}",x:-.00011179999999999524,y:-.27384530000000007,anchor:"middle_left"}],ports:[{...b3e.left1,labels:["1"]},{...b3e.right1,labels:["2"]}],size:{width:x4.width,height:x4.height},center:{x:x4.centerX,y:x4.centerY}}).changeTextAnchor("{VAL}","middle_top").labelPort("right1",["2"]).labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:MQt,texts:OQt,bounds:LQt,refblocks:$Qt,circles:zQt}=Y6,mU=ur(gve,"down"),gU=mU.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),yU=mU.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");gU.anchor="middle_left";yU.anchor="middle_left";gU.x=.25;gU.y+=.21;yU.y-=.21;yU.x=.25;B6t=mU;T6t={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:-.44,y:.03}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.44,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:P6t,texts:F3e,bounds:f4,refblocks:E3e,circles:I6t}=T6t,yve=ea({primitives:[...Object.values(P6t),...Object.values(I6t),{...F3e.top1,anchor:"middle_bottom"},{...F3e.bottom1,anchor:"middle_top"}],ports:[{...E3e.left1,labels:["1"]},{...E3e.right1,labels:["2"]}],size:{width:f4.width,height:f4.height},center:{x:f4.centerX,y:f4.centerY}}),j6t=hU(yve,{newOrientation:"up"}),H6={paths:{path1:{type:"path",points:[{x:-.51,y:.05},{x:-.25,y:.05}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.28,y:.05},{x:.55,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:N6t,texts:qQt,bounds:v3e,refblocks:C3e,circles:k6t}=H6,M6t=Ft({primitives:[...Object.values(N6t),...Object.values(k6t),{type:"text",text:"{REF}",x:-.16,y:.2294553499999995},{type:"text",text:"{VAL}",x:.16,y:.2294553499999995}],ports:[{...C3e.left1,labels:["1"]},{...C3e.right1,labels:["2"]}],center:{x:v3e.centerX,y:v3e.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").build(),{paths:O6t,texts:UQt,bounds:_3e,refblocks:A3e,circles:L6t}=H6,$6t=Ft({primitives:[...Object.values(O6t),...Object.values(L6t),{type:"text",text:"{REF}",x:0,y:-.1994553499999995},{type:"text",text:"{VAL}",x:0,y:.2694553499999995}],ports:[{...A3e.left1,labels:["1"]},{...A3e.right1,labels:["2"]}],center:{x:_3e.centerX,y:_3e.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:z6t,texts:VQt,bounds:R3e,refblocks:S3e,circles:q6t}=H6,U6t=Ft({primitives:[...Object.values(z6t),...Object.values(q6t),{type:"text",text:"{REF}",x:0,y:.2294553499999995},{type:"text",text:"{VAL}",x:0,y:-.1594553499999995}],ports:[{...S3e.left1,labels:["1"]},{...S3e.right1,labels:["2"]}],center:{x:R3e.centerX,y:R3e.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),W6={paths:{path2:{type:"path",points:[{x:.15,y:-.01},{x:.56,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:-.56,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:V6t,texts:GQt,bounds:h4,refblocks:w3e,circles:G6t}=W6,X6t=Ft({primitives:[...Object.values(V6t),...Object.values(G6t),{type:"text",text:"{REF}",x:-.2,y:.1404553499999995},{type:"text",text:"{VAL}",x:.2,y:.1494553499999995}],ports:[{...w3e.left1,labels:["1"]},{...w3e.right1,labels:["2"]}],size:{width:h4.width,height:h4.height},center:{x:h4.centerX,y:h4.centerY}}).rotateRightFacingSymbol("down").labelPort("left",["1"]).labelPort("right",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:Y6t,texts:XQt,bounds:m4,refblocks:B3e,circles:H6t}=W6,W6t=Ft({primitives:[...Object.values(Y6t),...Object.values(H6t),{type:"text",text:"{REF}",x:0,y:-.2294553499999995},{type:"text",text:"{VAL}",x:0,y:.1704553499999995}],ports:[{...B3e.left1,labels:["1"]},{...B3e.right1,labels:["2"]}],size:{width:m4.width,height:m4.height},center:{x:m4.centerX,y:m4.centerY}}).rotateRightFacingSymbol("left").labelPort("left",["1"]).labelPort("right",["2"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),{paths:K6t,texts:YQt,bounds:g4,refblocks:T3e,circles:J6t}=W6,Z6t=Ft({primitives:[...Object.values(K6t),...Object.values(J6t),{type:"text",text:"{REF}",x:0,y:.2294553499999995},{type:"text",text:"{VAL}",x:0,y:-.1704553499999995}],ports:[{...T3e.left1,labels:["1"]},{...T3e.right1,labels:["2"]}],size:{width:g4.width,height:g4.height},center:{x:g4.centerX,y:g4.centerY}}).rotateRightFacingSymbol("right").labelPort("left",["1"]).labelPort("right",["2"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),{paths:Q6t,texts:HQt,bounds:y4,refblocks:P3e,circles:eRt}=W6,tRt=Ft({primitives:[...Object.values(Q6t),...Object.values(eRt),{type:"text",text:"{REF}",x:.2,y:-.1404553499999995},{type:"text",text:"{VAL}",x:-.2,y:-.1494553499999995}],ports:[{...P3e.left1,labels:["1"]},{...P3e.right1,labels:["2"]}],size:{width:y4.width,height:y4.height},center:{x:y4.centerX,y:y4.centerY}}).rotateRightFacingSymbol("up").labelPort("left",["1"]).labelPort("right",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:rRt,texts:WQt,bounds:I3e,refblocks:j3e,circles:nRt}=H6,aRt=Ft({primitives:[...Object.values(rRt),...Object.values(nRt),{type:"text",text:"{REF}",x:.16,y:-.2294553499999995},{type:"text",text:"{VAL}",x:-.16,y:-.2294553499999995}],ports:[{...j3e.left1,labels:["1"]},{...j3e.right1,labels:["2"]}],center:{x:I3e.centerX,y:I3e.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").build(),DU={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:sRt,texts:KQt,bounds:N3e,refblocks:k3e,circles:iRt}=DU,oRt=Ft({primitives:[...Object.values(sRt),...Object.values(iRt),{type:"text",text:"{REF}",x:0,y:.2594553499999995}],ports:[{...k3e.left1,labels:["1"]},{...k3e.right1,labels:["2"]}],center:{x:N3e.centerX,y:N3e.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").build(),{paths:uRt,texts:JQt,bounds:M3e,refblocks:O3e,circles:cRt}=DU,Dve=Ft({primitives:[...Object.values(uRt),...Object.values(cRt),{type:"text",text:"{REF}",x:0,y:.2594553499999995}],ports:[{...O3e.left1,labels:["1"]},{...O3e.right1,labels:["2"]}],center:{x:M3e.centerX,y:M3e.centerY}}).rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),lRt=gb(Dve),{paths:dRt,texts:ZQt,bounds:L3e,refblocks:$3e,circles:pRt}=DU,xRt=Ft({primitives:[...Object.values(dRt),...Object.values(pRt),{type:"text",text:"{REF}",x:0,y:.2594553499999995}],ports:[{...$3e.left1,labels:["1"]},{...$3e.right1,labels:["2"]}],center:{x:L3e.centerX,y:L3e.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_right").build(),K6={paths:{path27:{type:"path",points:[{x:.52,y:.02},{x:.07,y:.02}],color:"primary",fill:!1},path28:{type:"path",points:[{x:-.09,y:.02},{x:-.54,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:fRt,texts:QQt,bounds:D4,refblocks:z3e,circles:hRt}=K6,mRt=Ft({primitives:[...Object.values(fRt),...Object.values(hRt),{type:"text",text:"{REF}",x:-.2,y:.2094553499999995},{type:"text",text:"{VAL}",x:.2,y:.2094553499999995}],ports:[{...z3e.left1,labels:["1"]},{...z3e.right1,labels:["2"]}],size:{width:D4.width,height:D4.height},center:{x:D4.centerX,y:D4.centerY}}).changeTextAnchor("{VAL}","top_left").rotateRightFacingSymbol("down").labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{REF}","bottom_left").build(),gRt=Ft(K6).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["2","neg"]).labelPort("right1",["1","pos"]).changeTextAnchor("{REF}","middle_bottom").build(),J6={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:yRt,texts:eer,bounds:b4,refblocks:q3e,circles:DRt}=J6,bRt=Ft({primitives:[...Object.values(yRt),...Object.values(DRt),{type:"text",text:"{REF}",x:.1,y:-.2094553499999995},{type:"text",text:"{VAL}",x:-.2,y:-.2094553499999995}],ports:[{...q3e.left1,labels:["2","neg"]},{...q3e.right1,labels:["1","pos"]}],size:{width:b4.width,height:b4.height},center:{x:b4.centerX,y:b4.centerY}}).changeTextAnchor("{VAL}","top_left").rotateRightFacingSymbol("up").changeTextAnchor("{REF}","bottom_left").build(),FRt=Ft(J6).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["2","neg"]).labelPort("right1",["1","pos"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:ERt,texts:ter,bounds:F4,refblocks:U3e,circles:vRt}=J6,CRt=Ft({primitives:[...Object.values(ERt),...Object.values(vRt),{type:"text",text:"{REF}",x:0,y:-.4094553499999995},{type:"text",text:"{VAL}",x:-0,y:.4094553499999995}],ports:[{...U3e.left1,labels:["2","neg"]},{...U3e.right1,labels:["1","pos"]}],size:{width:F4.width,height:F4.height},center:{x:F4.centerX,y:F4.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("left").changeTextAnchor("{REF}","middle_bottom").build(),{paths:_Rt,texts:rer,bounds:E4,refblocks:V3e,circles:ARt}=J6,RRt=Ft({primitives:[...Object.values(_Rt),...Object.values(ARt),{type:"text",text:"{REF}",x:-.2,y:.2094553499999995},{type:"text",text:"{VAL}",x:.3,y:.2094553499999995}],ports:[{...V3e.left1,labels:["2","neg"]},{...V3e.right1,labels:["1","pos"]}],size:{width:E4.width,height:E4.height},center:{x:E4.centerX,y:E4.centerY}}).changeTextAnchor("{VAL}","top_left").rotateRightFacingSymbol("down").changeTextAnchor("{REF}","bottom_left").build(),SRt=Ft(K6).rotateRightFacingSymbol("right").changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:wRt,texts:ner,bounds:v4,refblocks:G3e,circles:BRt}=K6,TRt=Ft({primitives:[...Object.values(wRt),...Object.values(BRt),{type:"text",text:"{REF}",x:.2,y:-.2094553499999995},{type:"text",text:"{VAL}",x:-.2,y:-.2094553499999995}],ports:[{...G3e.left1,labels:["1"]},{...G3e.right1,labels:["2"]}],size:{width:v4.width,height:v4.height},center:{x:v4.centerX,y:v4.centerY}}).changeTextAnchor("{VAL}","top_left").rotateRightFacingSymbol("up").labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{REF}","bottom_left").build(),Hm={paths:{path11:{type:"path",points:[{x:-.53,y:.03},{x:-.3,y:.03}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:.03},{x:.53,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:PRt,texts:aer,bounds:C4,refblocks:X3e,circles:IRt}=Hm,jRt=Ft({primitives:[...Object.values(PRt),...Object.values(IRt),{type:"text",text:"{REF}",x:-.15,y:.3894553499999995},{type:"text",text:"{VAL}",x:.15,y:.3894553499999995}],ports:[{...X3e.left1,labels:["1"]},{...X3e.right1,labels:["2"]}],size:{width:C4.width,height:C4.height},center:{x:C4.centerX,y:C4.centerY}}).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),NRt=Ft(Hm).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:kRt,texts:ser,bounds:_4,refblocks:Y3e,circles:MRt}=Hm,ORt=Ft({primitives:[...Object.values(kRt),...Object.values(MRt),{type:"text",text:"{REF}",x:-0,y:-.2894553499999995},{type:"text",text:"{VAL}",x:0,y:.3894553499999995}],ports:[{...Y3e.left1,labels:["1"]},{...Y3e.right1,labels:["2"]}],size:{width:_4.width,height:_4.height},center:{x:_4.centerX,y:_4.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),LRt=Ft(Hm).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1","neg"]).labelPort("right1",["2","pos"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:$Rt,texts:ier,bounds:A4,refblocks:H3e,circles:zRt}=Hm,qRt=Ft({primitives:[...Object.values($Rt),...Object.values(zRt),{type:"text",text:"{REF}",x:.15,y:-.2894553499999995},{type:"text",text:"{VAL}",x:-.15,y:-.2894553499999995}],ports:[{...H3e.left1,labels:["1"]},{...H3e.right1,labels:["2"]}],size:{width:A4.width,height:A4.height},center:{x:A4.centerX,y:A4.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:URt,texts:oer,bounds:R4,refblocks:W3e,circles:VRt}=Hm,GRt=Ft({primitives:[...Object.values(URt),...Object.values(VRt),{type:"text",text:"{REF}",x:.15,y:-.2894553499999995},{type:"text",text:"{VAL}",x:-.15,y:-.2894553499999995}],ports:[{...W3e.left1,labels:["1"]},{...W3e.right1,labels:["2"]}],size:{width:R4.width,height:R4.height},center:{x:R4.centerX,y:R4.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),Z6={paths:{path27:{type:"path",points:[{x:.52,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:.69},{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:-.72},{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:XRt,texts:uer,bounds:S4,refblocks:w4,circles:YRt}=Z6,HRt=Ft({primitives:[...Object.values(XRt),...Object.values(YRt),{type:"text",text:"{REF}",x:-.4,y:.4094554499999995},{type:"text",text:"{VAL}",x:.4,y:.4094553499999995}],ports:[{...w4.left1,labels:["1"]},{...w4.right1,labels:["3"]},{...w4.bottom1,labels:["2"]},{...w4.top1,labels:["4"]}],size:{width:S4.width,height:S4.height},center:{x:S4.centerX,y:S4.centerY}}).rotateRightFacingSymbol("down").changeTextAnchor("{REF}","bottom_left").changeTextAnchor("{VAL}","top_left").build(),WRt=Ft(Z6).labelPort("top1",["2","gnd1"]).labelPort("bottom1",["4","gnd2"]).labelPort("left1",["3"]).labelPort("right1",["1"]).changeTextAnchor("{REF}","bottom_left").changeTextAnchor("{VAL}","top_left").build(),KRt=Ft(Z6).labelPort("top1",["4","gnd1"]).labelPort("bottom1",["2","gnd2"]).labelPort("left1",["1"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","bottom_left").changeTextAnchor("{VAL}","top_left").build(),{paths:JRt,texts:cer,bounds:B4,refblocks:T4,circles:ZRt}=Z6,QRt=Ft({primitives:[...Object.values(JRt),...Object.values(ZRt),{type:"text",text:"{VAL}",x:-.4,y:-.4094554499999995},{type:"text",text:"{REF}",x:.4,y:-.4094553499999995}],ports:[{...T4.left1,labels:["1"]},{...T4.right1,labels:["3"]},{...T4.bottom1,labels:["2"]},{...T4.top1,labels:["4"]}],size:{width:B4.width,height:B4.height},center:{x:B4.centerX,y:B4.centerY}}).rotateRightFacingSymbol("up").changeTextAnchor("{REF}","bottom_left").changeTextAnchor("{VAL}","top_left").build(),Q6={paths:{path27:{type:"path",points:[{x:.52,y:-.01},{x:.13,y:-.01}],color:"primary",fill:!1},path28:{type:"path",points:[{x:-.14,y:-.01},{x:-.54,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:e5t,texts:ler,bounds:P4,refblocks:K3e,circles:t5t}=Q6,r5t=Ft({primitives:[...Object.values(e5t),...Object.values(t5t),{type:"text",text:"{REF}",x:-.3,y:.3094553499999995},{type:"text",text:"{VAL}",x:.3,y:.3094553499999995}],ports:[{...K3e.left1,labels:["1"]},{...K3e.right1,labels:["2"]}],size:{width:P4.width,height:P4.height},center:{x:P4.centerX,y:P4.centerY}}).changeTextAnchor("{VAL}","top_left").rotateRightFacingSymbol("down").labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{REF}","bottom_left").build(),n5t=Ft(Q6).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["2","neg"]).labelPort("right1",["1","pos"]).changeTextAnchor("{REF}","middle_bottom").build(),a5t=Ft(Q6).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:s5t,texts:der,bounds:I4,refblocks:J3e,circles:i5t}=Q6,o5t=Ft({primitives:[...Object.values(s5t),...Object.values(i5t),{type:"text",text:"{REF}",x:.3,y:-.3094553499999995},{type:"text",text:"{VAL}",x:-.3,y:-.3094553499999995}],ports:[{...J3e.left1,labels:["1"]},{...J3e.right1,labels:["2"]}],size:{width:I4.width,height:I4.height},center:{x:I4.centerX,y:I4.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("up").labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{REF}","bottom_left").build(),Wm={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.15}],color:"primary",fill:!1},"path12-1-5-3":{type:"path",points:[{x:2.23,y:-1.96},{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}}},u5t=Ft(Wm).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(),c5t=Ft(Wm).rotateRightFacingSymbol("right").labelPort("right2",["1"]).labelPort("right1",["2"]).labelPort("right3",["3"]).changeTextAnchor("{VAL}","middle_right").changeTextAnchor("{REF}","middle_right").build(),l5t=Ft(Wm).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(),d5t=Ft(Wm).rotateRightFacingSymbol("right").labelPort("right2",["1"]).labelPort("right1",["2"]).labelPort("right3",["3"]).changeTextAnchor("{VAL}","middle_right").changeTextAnchor("{REF}","middle_right").build(),p5t=Ft(Wm).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(),x5t=Ft(Wm).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(),f5t={paths:{path11:{type:"path",points:[{x:-.53,y:0},{x:-.3,y:0}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:0},{x:.53,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:h5t,texts:m5t,bounds:j4,refblocks:Z3e,circles:g5t}=f5t,bU=ea({primitives:[...Object.values(h5t),...Object.values(g5t),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"},{...m5t.left1,x:0,y:.01,anchor:"center",fontSize:.3}],ports:[{...Z3e.left1,labels:["1"]},{...Z3e.right1,labels:["2"]}],size:{width:j4.width,height:j4.height},center:{x:j4.centerX,y:j4.centerY}});({6:pU,2:xU,...b5t}=bU.primitives);y5t(xU)&&xU.points.map(n=>{n.y+=.05});D5t(pU)&&(pU.y+=.025);Q3e=ur({...bU,primitives:Object.values(b5t).filter(F5t)}),E5t={...Q3e,primitives:[...Q3e.primitives,pU,xU]},Km={paths:{path11:{type:"path",points:[{x:-.53,y:.04},{x:-.3,y:.04}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:.04},{x:.53,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:v5t,texts:per,bounds:N4,refblocks:eEe,circles:C5t}=Km,_5t=Ft({primitives:[...Object.values(v5t),...Object.values(C5t),{type:"text",text:"{REF}",x:-.15,y:.3894553499999995},{type:"text",text:"{VAL}",x:.15,y:.3894553499999995}],ports:[{...eEe.left1,labels:["1"]},{...eEe.right1,labels:["2"]}],size:{width:N4.width,height:N4.height},center:{x:N4.centerX,y:N4.centerY}}).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:A5t,texts:xer,bounds:k4,refblocks:tEe,circles:R5t}=Km,S5t=Ft({primitives:[...Object.values(A5t),...Object.values(R5t),{type:"text",text:"{REF}",x:-0,y:.3894553499999995},{type:"text",text:"{VAL}",x:0,y:-.3294553499999995}],ports:[{...tEe.left1,labels:["1"]},{...tEe.right1,labels:["2"]}],size:{width:k4.width,height:k4.height},center:{x:k4.centerX,y:k4.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:w5t,texts:fer,bounds:M4,refblocks:rEe,circles:B5t}=Km,T5t=Ft({primitives:[...Object.values(w5t),...Object.values(B5t),{type:"text",text:"{REF}",x:-0,y:-.3294553499999995},{type:"text",text:"{VAL}",x:0,y:.4294553499999995}],ports:[{...rEe.left1,labels:["1"]},{...rEe.right1,labels:["2"]}],size:{width:M4.width,height:M4.height},center:{x:M4.centerX,y:M4.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:P5t,texts:her,bounds:O4,refblocks:nEe,circles:I5t}=Km,j5t=Ft({primitives:[...Object.values(P5t),...Object.values(I5t),{type:"text",text:"{REF}",x:-0,y:.3894553499999995},{type:"text",text:"{VAL}",x:0,y:-.3294553499999995}],ports:[{...nEe.left1,labels:["1"]},{...nEe.right1,labels:["2"]}],size:{width:O4.width,height:O4.height},center:{x:O4.centerX,y:O4.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:N5t,texts:mer,bounds:L4,refblocks:aEe,circles:k5t}=Km,M5t=Ft({primitives:[...Object.values(N5t),...Object.values(k5t),{type:"text",text:"{REF}",x:.15,y:-.2894553499999995},{type:"text",text:"{VAL}",x:-.15,y:-.2894553499999995}],ports:[{...aEe.left1,labels:["1"]},{...aEe.right1,labels:["2"]}],size:{width:L4.width,height:L4.height},center:{x:L4.centerX,y:L4.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:O5t,texts:ger,bounds:$4,refblocks:sEe,circles:L5t}=Km,$5t=Ft({primitives:[...Object.values(O5t),...Object.values(L5t),{type:"text",text:"{REF}",x:.15,y:-.2894553499999995},{type:"text",text:"{VAL}",x:-.15,y:-.2894553499999995}],ports:[{...sEe.left1,labels:["1"]},{...sEe.right1,labels:["2"]}],size:{width:$4.width,height:$4.height},center:{x:$4.centerX,y:$4.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),Jm={paths:{path11:{type:"path",points:[{x:-.52,y:.04},{x:-.11,y:.04}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.1,y:.04},{x:.52,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}}},z5t=Ft(Jm).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(),q5t=Ft(Jm).rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom",{x:0,y:.1}).changeTextAnchor("{VAL}","middle_top").build(),U5t=Ft(Jm).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(),V5t=Ft(Jm).rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom",{x:0,y:.1}).changeTextAnchor("{VAL}","middle_top").build(),G5t=Ft(Jm).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(),X5t=Ft(Jm).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(),Y5t={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:{}},eR=Ft(Y5t).labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),H5t=ur(eR,"down"),W5t=ur(eR,"left"),K5t=ur(eR,"up"),J5t={paths:{path1:{type:"path",points:[{x:-.35,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:.35,y:.13}],color:"primary",fill:!1},path3:{type:"path",points:[{x:.12,y:.36},{x:.36,y:.36}],color:"primary",fill:!1},path4:{type:"path",points:[{x:-.35,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:.35,y:-.27}],color:"primary",fill:!1},path6:{type:"path",points:[{x:.12,y:-.04},{x:.36,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}}},tR=Ft(J5t).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(),FU=ur(tR,"down"),EU=FU.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),vU=FU.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");EU.anchor="middle_bottom";vU.anchor="middle_top";EU.x=0;EU.y+=.537;vU.y-=.5375;vU.x=0;Z5t=FU,CU=ur(tR,"left"),_U=CU.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),AU=CU.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");_U.anchor="middle_bottom";AU.anchor="middle_top";_U.x=0;_U.y+=1;AU.y-=1;AU.x=0;Q5t=CU,RU=ur(tR,"up"),SU=RU.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),wU=RU.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");SU.anchor="middle_bottom";wU.anchor="middle_top";SU.x=0;SU.y+=.537;wU.y-=.5375;wU.x=0;eSt=RU,tSt={paths:{path1:{type:"path",points:[{x:-.35,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:.35,y:.13}],color:"primary",fill:!1},path3:{type:"path",points:[{x:.12,y:.36},{x:.36,y:.36}],color:"primary",fill:!1},path4:{type:"path",points:[{x:-.35,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:.35,y:-.27}],color:"primary",fill:!1},path6:{type:"path",points:[{x:.12,y:-.04},{x:.36,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}}},rR=Ft(tSt).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(),BU=ur(rR,"down"),TU=BU.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),PU=BU.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");TU.anchor="middle_bottom";PU.anchor="middle_top";TU.x=0;TU.y+=.565;PU.y-=.555;PU.x=0;rSt=BU,IU=ur(rR,"left"),jU=IU.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),NU=IU.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");jU.anchor="middle_bottom";NU.anchor="middle_top";jU.x=0;jU.y+=1.09;NU.y-=1.09;NU.x=0;nSt=IU,kU=ur(rR,"up"),MU=kU.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),OU=kU.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");MU.anchor="middle_bottom";OU.anchor="middle_top";MU.x=0;MU.y+=.565;OU.y-=.555;OU.x=0;aSt=kU,sSt={paths:{path11:{type:"path",points:[{x:-.36,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:.37,y:.06}],color:"primary",fill:!1},"path11-5":{type:"path",points:[{x:-.36,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:.37,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}}},nR=Ft(sSt).labelPort("left1",["1"]).labelPort("right1",["2"]).labelPort("right3",["4"]).labelPort("left3",["3"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),LU=ur(nR,"down"),$U=LU.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),zU=LU.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");$U.anchor="middle_bottom";zU.anchor="middle_top";$U.x=.4;$U.y+=.265;zU.y-=.265;zU.x=.4;iSt=LU,qU=ur(nR,"left"),UU=qU.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),VU=qU.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");UU.anchor="middle_bottom";VU.anchor="middle_top";UU.x=0;UU.y+=.67;VU.y-=.67;VU.x=0;oSt=qU,GU=ur(nR,"up"),XU=GU.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),YU=GU.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");XU.anchor="middle_bottom";YU.anchor="middle_top";XU.x=.46;XU.y+=.265;YU.y-=.265;YU.x=.46;uSt=GU,cSt={paths:{path11:{type:"path",points:[{x:-.36,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:.37,y:.06}],color:"primary",fill:!1},"path11-5":{type:"path",points:[{x:-.36,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:.37,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}}},aR=Ft(cSt).labelPort("left1",["1"]).labelPort("right1",["2"]).labelPort("right3",["4"]).labelPort("left3",["3"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),HU=ur(aR,"down"),WU=HU.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),KU=HU.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");WU.anchor="middle_bottom";KU.anchor="middle_top";WU.x=.4;WU.y+=.295;KU.y-=.295;KU.x=.42;lSt=HU,JU=ur(aR,"left"),ZU=JU.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),QU=JU.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");ZU.anchor="middle_bottom";QU.anchor="middle_top";ZU.x=0;ZU.y+=.795;QU.y-=.795;QU.x=0;dSt=JU,eV=ur(aR,"up"),tV=eV.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),rV=eV.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");tV.anchor="middle_bottom";rV.anchor="middle_top";tV.x=.46;tV.y+=.315;rV.y-=.315;rV.x=.46;pSt=eV,bve={paths:{path5:{type:"path",points:[{x:-.42,y:0},{x:-.16,y:0}],color:"primary",fill:!1},path6:{type:"path",points:[{x:.17,y:0},{x:.43,y:0}],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:xSt,texts:yer,bounds:z4,refblocks:iEe,circles:fSt}=bve,Fve=Ft({primitives:[...Object.values(xSt),...Object.values(fSt),{type:"text",text:"{REF}",x:.18,y:-.3204553499999995},{type:"text",text:"{VAL}",x:-.25,y:-.3294553499999995}],ports:[{...iEe.left1,labels:["1"]},{...iEe.right1,labels:["2"]}],size:{width:z4.width,height:z4.height},center:{x:z4.centerX,y:z4.centerY}}).rotateRightFacingSymbol("up").labelPort("left",["1"]).labelPort("right",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),nV=X6(Fve),aV=nV.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),sV=nV.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");aV.anchor="middle_left";sV.anchor="middle_left";aV.y+=.4;aV.x=.32;sV.y-=.45;sV.x=.32;hSt=nV,Eve=Ft(bve).labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),mSt=gb(Eve),Zm={paths:{path11:{type:"path",points:[{x:-.54,y:.04},{x:-.22,y:.04}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.14,y:.05},{x:.46,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:gSt,texts:Der,bounds:q4,refblocks:oEe,circles:ySt}=Zm,DSt=Ft({primitives:[...Object.values(gSt),...Object.values(ySt),{type:"text",text:"{REF}",x:-.15,y:.3294553499999995},{type:"text",text:"{VAL}",x:.15,y:.3294553499999995}],ports:[{...oEe.left1,labels:["1"]},{...oEe.right1,labels:["2"]}],size:{width:q4.width,height:q4.height},center:{x:q4.centerX,y:q4.centerY}}).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:bSt,texts:ber,bounds:U4,refblocks:uEe,circles:FSt}=Zm,ESt=Ft({primitives:[...Object.values(bSt),...Object.values(FSt),{type:"text",text:"{REF}",x:-0,y:.4094553499999995},{type:"text",text:"{VAL}",x:0,y:-.4094553499999995}],ports:[{...uEe.left1,labels:["1"]},{...uEe.right1,labels:["2"]}],size:{width:U4.width,height:U4.height},center:{x:U4.centerX,y:U4.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:vSt,texts:Fer,bounds:V4,refblocks:cEe,circles:CSt}=Zm,_St=Ft({primitives:[...Object.values(vSt),...Object.values(CSt),{type:"text",text:"{REF}",x:-0,y:-.3094553499999995},{type:"text",text:"{VAL}",x:0,y:.4094553499999995}],ports:[{...cEe.left1,labels:["1"]},{...cEe.right1,labels:["2"]}],size:{width:V4.width,height:V4.height},center:{x:V4.centerX,y:V4.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:ASt,texts:Eer,bounds:G4,refblocks:lEe,circles:RSt}=Zm,SSt=Ft({primitives:[...Object.values(ASt),...Object.values(RSt),{type:"text",text:"{REF}",x:-0,y:.4094553499999995},{type:"text",text:"{VAL}",x:0,y:-.4094553499999995}],ports:[{...lEe.left1,labels:["1"]},{...lEe.right1,labels:["2"]}],size:{width:G4.width,height:G4.height},center:{x:G4.centerX,y:G4.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:wSt,texts:ver,bounds:X4,refblocks:dEe,circles:BSt}=Zm,TSt=Ft({primitives:[...Object.values(wSt),...Object.values(BSt),{type:"text",text:"{REF}",x:.15,y:-.2894553499999995},{type:"text",text:"{VAL}",x:-.15,y:-.2894553499999995}],ports:[{...dEe.left1,labels:["1"]},{...dEe.right1,labels:["2"]}],size:{width:X4.width,height:X4.height},center:{x:X4.centerX,y:X4.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:PSt,texts:Cer,bounds:Y4,refblocks:pEe,circles:ISt}=Zm,jSt=Ft({primitives:[...Object.values(PSt),...Object.values(ISt),{type:"text",text:"{REF}",x:.15,y:-.2894553499999995},{type:"text",text:"{VAL}",x:-.15,y:-.2894553499999995}],ports:[{...pEe.left1,labels:["1"]},{...pEe.right1,labels:["2"]}],size:{width:Y4.width,height:Y4.height},center:{x:Y4.centerX,y:Y4.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),NSt={paths:{path11:{type:"path",points:[{x:-.53,y:0},{x:-.3,y:0}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:0},{x:.53,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:kSt,texts:MSt,bounds:H4,refblocks:xEe,circles:OSt}=NSt,iV=ea({primitives:[...Object.values(kSt),...Object.values(OSt),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"},{...MSt.left1,x:0,y:.01,anchor:"center",fontSize:.2}],ports:[{...xEe.left1,labels:["1"]},{...xEe.right1,labels:["2"]}],size:{width:H4.width,height:H4.height},center:{x:H4.centerX,y:H4.centerY}}),{5:LSt,...$St}=iV.primitives;fEe=ur({...iV,primitives:Object.values($St).filter(zSt)}),qSt={...fEe,primitives:[...fEe.primitives,LSt]},USt={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:VSt,texts:GSt,bounds:W4,refblocks:hEe}=USt,vve=ea({primitives:[...Object.values(VSt),{...GSt.top1,anchor:"middle_bottom"},{type:"text",text:"{VAL}",x:0,y:-.2,anchor:"middle_top"}],ports:[{...hEe.left1,labels:["1"]},{...hEe.right1,labels:["2"]}],size:{width:W4.width,height:W4.height},center:{x:W4.centerX,y:W4.centerY}}),XSt=ur(vve),Qm={paths:{path1:{type:"path",points:[{x:-.29,y:0},{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:{}},YSt=Ft(Qm).rotateRightFacingSymbol("down").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_top").build(),HSt=Ft(Qm).rotateRightFacingSymbol("right").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_left").build(),WSt=Ft(Qm).rotateRightFacingSymbol("left").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_right").build(),KSt=Ft(Qm).rotateRightFacingSymbol("right").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_left").build(),JSt=Ft(Qm).rotateRightFacingSymbol("up").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_bottom").build(),ZSt=Ft(Qm).rotateRightFacingSymbol("up").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_bottom").build(),sR={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:QSt,texts:_er,bounds:mEe,refblocks:ewt}=sR,twt=Ft({primitives:[...Object.values(QSt),{type:"text",text:"{REF}",x:-.14,y:0}],ports:[{...ewt.left1,labels:["1"]}],center:{x:mEe.centerX,y:mEe.centerY}}).rotateRightFacingSymbol("down").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:rwt,texts:Aer,bounds:gEe,refblocks:nwt,circles:awt}=sR,swt=Ft({primitives:[...Object.values(rwt),...Object.values(awt),{type:"text",text:"{REF}",x:-.14,y:-0}],ports:[{...nwt.left1,labels:["1"]}],center:{x:gEe.centerX,y:gEe.centerY}}).rotateRightFacingSymbol("left").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_left").build(),{paths:iwt,texts:Rer,bounds:yEe,refblocks:owt,circles:uwt}=sR,cwt=Ft({primitives:[...Object.values(iwt),...Object.values(uwt),{type:"text",text:"{REF}",x:-.13,y:0}],ports:[{...owt.left1,labels:["1"]}],center:{x:yEe.centerX,y:yEe.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_right").build(),{paths:lwt,texts:Ser,bounds:DEe,refblocks:dwt,circles:pwt}=sR,xwt=Ft({primitives:[...Object.values(lwt),...Object.values(pwt),{type:"text",text:"{REF}",x:-.14,y:-0}],ports:[{...dwt.left1,labels:["1"]}],center:{x:DEe.centerX,y:DEe.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_top").build(),oV={paths:{path11:{type:"path",points:[{x:-.5,y:.04},{x:-.18,y:.04}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.19,y:.04},{x:.51,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:wer,texts:Ber,bounds:Ter,refblocks:Per,circles:Ier}=oV,fwt=Ft(oV).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),hwt=Ft(oV).rotateRightFacingSymbol("down").changeTextAnchor("{VAL}","middle_right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").build(),mwt={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:{}},iR=Ft(mwt).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(),gwt=ur(iR,"down"),ywt=gb(iR),uV=ur(iR,"up"),cV=uV.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),lV=uV.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");cV.anchor="middle_left";lV.anchor="middle_left";cV.y+=.21;cV.x=.44;lV.y-=.21;lV.x=.44;Dwt=uV,bwt={paths:{path11:{type:"path",points:[{x:-.39,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:-.54}],color:"primary",fill:!1},"path12-1":{type:"path",points:[{x:.28,y:.54},{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}}},Cve=Ft(bwt).changeTextAnchor("{VAL}","middle_right").labelPort("left1",["3"]).labelPort("top1",["2"]).labelPort("bottom1",["1"]).changeTextAnchor("{REF}","middle_right").build(),dV=ur(Cve),pV=dV.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),_ve=dV.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");pV.anchor="middle_left";_ve.anchor="middle_right";pV.x=.45;pV.y+=.065;_ve.y+=.065;Fwt=dV,Ewt={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:-.49,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:.49,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}}},Ave=Ft(Ewt).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),Rve=ur(Ave),Sve=Rve.primitives.filter(n=>n.type==="text"),xV=Sve.find(n=>n.text==="{VAL}");xV.x=-.35;xV.y=0;xV.anchor="middle_right";fV=Sve.find(n=>n.text==="{REF}");fV.y=0;fV.x=.35;fV.anchor="middle_left";vwt=Rve,Cwt={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:-.53,y:-.02}],color:"primary",fill:!1},"path8706-5":{type:"path",points:[{x:.53,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:_wt,texts:bEe,bounds:K4,refblocks:FEe,circles:Awt}=Cwt,hV=ea({primitives:[...Object.values(_wt),...Object.values(Awt),{...bEe.top1,anchor:"middle_bottom"},{...bEe.bottom1,anchor:"middle_top"}],ports:[{...FEe.left1,labels:["1"]},{...FEe.right1,labels:["2"]}],size:{width:K4.width,height:K4.height},center:{x:K4.centerX,y:K4.centerY}}),wve=ur(hV,"up"),Rwt=X6(wve),Swt=gb(hV),Bve={paths:{path11:{type:"path",points:[{x:-.53,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:.53,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}}};Bve.bounds.width+=.2;oR=Ft(Bve).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),mV=ur(oR,"down"),gV=mV.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),yV=mV.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");gV.anchor="middle_left";yV.anchor="middle_left";gV.y+=.9;gV.x=.3;yV.y-=.1;yV.x=.3;wwt=mV,DV=ur(oR,"left"),bV=DV.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),FV=DV.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");bV.anchor="middle_left";FV.anchor="middle_left";bV.y+=.71;bV.x=.44;FV.y-=.71;FV.x=.44;Bwt=DV,EV=ur(oR,"up"),vV=EV.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),CV=EV.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");vV.anchor="middle_left";CV.anchor="middle_left";vV.y+=.1;vV.x=.3;CV.y-=.71;CV.x=.3;Twt=EV,Pwt={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:.53,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:-.53,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:Iwt,texts:EEe,bounds:J4,refblocks:vEe,circles:jwt}=Pwt,_V=ea({primitives:[...Object.values(Iwt),...Object.values(jwt),{...EEe.bottom1,anchor:"middle_top"},{...EEe.right1,anchor:"middle_bottom"}],ports:[{...vEe.left1,labels:["1"]},{...vEe.right1,labels:["2"]}],size:{width:J4.width,height:J4.height},center:{x:J4.centerX,y:J4.centerY}}),AV=ur(_V,"up"),RV=AV.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),SV=AV.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");RV.anchor="middle_left";SV.anchor="middle_left";RV.y+=.21;RV.x=.21;SV.y-=.21;SV.x=.21;Tve=AV,wV=X6(Tve),BV=wV.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),TV=wV.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");BV.anchor="middle_left";TV.anchor="middle_left";BV.y+=.4;BV.x=.2;TV.y-=.41;TV.x=.2;Nwt=wV,kwt=gb(_V),Mwt={paths:{path11:{type:"path",points:[{x:-.51,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:.51,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:Owt,texts:CEe,bounds:Z4,refblocks:_Ee,circles:Lwt}=Mwt,Pve=ea({primitives:[...Object.values(Owt),...Object.values(Lwt),{...CEe.top1,anchor:"middle_left",x:0},{...CEe.bottom1,anchor:"middle_left",x:0}],ports:[{..._Ee.left1,labels:["1"]},{..._Ee.right1,labels:["2"]}],size:{width:Z4.width,height:Z4.height},center:{x:Z4.centerX,y:Z4.centerY}}),Ive=ur(Pve),jve=Ive.primitives.filter(n=>n.type==="text"),PV=jve.find(n=>n.text==="{VAL}");PV.x=-.35;PV.y=0;PV.anchor="middle_right";IV=jve.find(n=>n.text==="{REF}");IV.y=0;IV.x=.35;IV.anchor="middle_left";$wt=Ive,zwt={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:.53},{x:.12,y:.18}],color:"primary",fill:!1},path215:{type:"path",points:[{x:.12,y:-.53},{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:qwt,texts:AEe,bounds:Q4,refblocks:qq}=zwt,Nve=ea({primitives:[...Object.values(qwt),{...AEe.right1,anchor:"middle_left"},{...AEe.right2,anchor:"middle_left"}],ports:[{...qq.top1,labels:["1"]},{...qq.bottom1,labels:["2"]},{...qq.left1,labels:["3"]}],size:{width:Q4.width+.4,height:Q4.height},center:{x:Q4.centerX+.2,y:Q4.centerY}}),jV=ur(Nve),kve=jV.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),NV=jV.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");kve.anchor="middle_top";NV.anchor="middle_top";kve.x=NV.x;NV.y+=.15;Uwt=jV,Vwt={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:-.49,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:.49,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:Gwt,texts:REe,bounds:e6,refblocks:SEe,circles:Xwt}=Vwt,Mve=ea({primitives:[...Object.values(Gwt),...Object.values(Xwt),{...REe.top1,anchor:"middle_bottom",x:0},{...REe.bottom1,anchor:"middle_top",x:0}],ports:[{...SEe.left1,labels:["1"]},{...SEe.right1,labels:["2"]}],size:{width:e6.width,height:e6.height},center:{x:e6.centerX+.006,y:e6.centerY+.06}}),kV=ur(Mve),mb=kV.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),U6=kV.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");mb.anchor="middle_left";U6.anchor="middle_right";mb.x=mb.x-.03;mb.y=mb.y;U6.x=U6.x;U6.y=0;Ywt=kV,Hwt={paths:{path11:{type:"path",points:[{x:-.39,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:.53},{x:.3,y:.11}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:.31,y:-.53},{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:Wwt,texts:wEe,bounds:t6,refblocks:Uq,circles:Kwt}=Hwt,Ove=ea({primitives:[...Object.values(Wwt),...Object.values(Kwt),{...wEe.top1,anchor:"middle_right",x:0},{...wEe.bottom1,anchor:"middle_right",x:0}],ports:[{...Uq.top1,labels:["1","drain"]},{...Uq.bottom1,labels:["2","source"]},{...Uq.left1,labels:["3","gate"]}],size:{width:t6.width,height:t6.height},center:{x:t6.centerX,y:t6.centerY}}),Lve=ur(Ove),$ve=Lve.primitives.filter(n=>n.type==="text"),MV=$ve.find(n=>n.text==="{VAL}");MV.x=-.35;MV.y=0;MV.anchor="middle_right";OV=$ve.find(n=>n.text==="{REF}");OV.y=0;OV.x=.35;OV.anchor="middle_left";Jwt=Lve,Zwt={paths:{path11:{type:"path",points:[{x:-.39,y:-.1},{x:.05,y:-.11}],color:"primary",fill:!1},"path12-1":{type:"path",points:[{x:.3,y:.53},{x:.3,y:.11}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:.31,y:-.53},{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:Qwt,texts:BEe,bounds:r6,refblocks:Vq,circles:e9t}=Zwt,zve=ea({primitives:[...Object.values(Qwt),...Object.values(e9t),{...BEe.top1,anchor:"middle_right",x:0},{...BEe.bottom1,anchor:"middle_right",x:0}],ports:[{...Vq.top1,labels:["1","drain"]},{...Vq.bottom1,labels:["2","source"]},{...Vq.left1,labels:["3","gate"]}],size:{width:r6.width,height:r6.height},center:{x:r6.centerX,y:r6.centerY}}),qve=ur(zve),Uve=qve.primitives.filter(n=>n.type==="text"),LV=Uve.find(n=>n.text==="{VAL}");LV.x=-.35;LV.y=0;LV.anchor="middle_right";$V=Uve.find(n=>n.text==="{REF}");$V.y=0;$V.x=.35;$V.anchor="middle_left";t9t=qve,r9t={paths:{path11:{type:"path",points:[{x:-.39,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:.53},{x:.28,y:.11}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:.29,y:-.53},{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:n9t,texts:TEe,bounds:n6,refblocks:Gq,circles:a9t}=r9t,Vve=ea({primitives:[...Object.values(n9t),...Object.values(a9t),{...TEe.top1,anchor:"middle_right",x:0},{...TEe.bottom1,anchor:"middle_right",x:0}],ports:[{...Gq.top1,labels:["1","drain"]},{...Gq.bottom1,labels:["2","source"]},{...Gq.left1,labels:["3","gate"]}],size:{width:n6.width,height:n6.height},center:{x:n6.centerX,y:n6.centerY}}),Gve=ur(Vve),Xve=Gve.primitives.filter(n=>n.type==="text"),zV=Xve.find(n=>n.text==="{VAL}");zV.x=-.35;zV.y=0;zV.anchor="middle_right";qV=Xve.find(n=>n.text==="{REF}");qV.y=0;qV.x=.35;qV.anchor="middle_left";s9t=Gve,i9t={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:o9t,bounds:PEe,refblocks:u9t}=i9t,uR=Ft({primitives:[...Object.values(o9t)],ports:[{...u9t.left1,labels:["1"]}],center:{x:PEe.centerX,y:PEe.centerY}}).rotateRightFacingSymbol("right").labelPort("left1",["1"]).build(),c9t=ur(uR,"down"),l9t=ur(uR,"left"),d9t=ur(uR,"up"),Jf={paths:{path11:{type:"path",points:[{x:-.39,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:.54}],color:"primary",fill:!1},"path12-1-5-3":{type:"path",points:[{x:.29,y:-.54},{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:p9t,texts:jer,bounds:a6,refblocks:Xq,circles:x9t}=Jf,f9t=Ft({primitives:[...Object.values(p9t),...Object.values(x9t),{type:"text",text:"{REF}",x:-.1,y:.3094553499999995},{type:"text",text:"{VAL}",x:-.1,y:-.3094553499999995}],ports:[{...Xq.top1,labels:["1","collector"]},{...Xq.bottom1,labels:["2","emitter"]},{...Xq.left1,labels:["3","base"]}],size:{width:a6.width,height:a6.height},center:{x:a6.centerX,y:a6.centerY}}).rotateRightFacingSymbol("right").changeTextAnchor("{REF}","middle_right").changeTextAnchor("{VAL}","middle_right").build(),{paths:Ner,texts:ker,bounds:Mer,refblocks:Oer,circles:Ler}=Jf,h9t=Ft(Jf).rotateRightFacingSymbol("up").changeTextAnchor("{VAL}","middle_left").labelPort("left1",["3","base"]).labelPort("top1",["1","collector"]).labelPort("bottom1",["2","emitter"]).changeTextAnchor("{REF}","middle_right").build(),{paths:m9t,texts:$er,bounds:s6,refblocks:Yq,circles:g9t}=Jf,y9t=Ft({primitives:[...Object.values(m9t),...Object.values(g9t),{type:"text",text:"{REF}",x:-.1,y:-.3094553499999995},{type:"text",text:"{VAL}",x:-.1,y:.3094553499999995}],ports:[{...Yq.top1,labels:["1","collector"]},{...Yq.bottom1,labels:["2","emitter"]},{...Yq.left1,labels:["3","base"]}],size:{width:s6.width,height:s6.height},center:{x:s6.centerX,y:s6.centerY}}).rotateRightFacingSymbol("down").changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_bottom").build(),{paths:D9t,texts:zer,bounds:i6,refblocks:Hq,circles:b9t}=Jf,F9t=Ft({primitives:[...Object.values(D9t),...Object.values(b9t),{type:"text",text:"{REF}",x:-.1,y:-.3094553499999995},{type:"text",text:"{VAL}",x:-.1,y:.3094553499999995}],ports:[{...Hq.top1,labels:["1","collector"]},{...Hq.bottom1,labels:["2","emitter"]},{...Hq.left1,labels:["3","base"]}],size:{width:i6.width,height:i6.height},center:{x:i6.centerX,y:i6.centerY}}).rotateRightFacingSymbol("up").changeTextAnchor("{REF}","middle_top").changeTextAnchor("{VAL}","middle_top").build(),{paths:E9t,texts:qer,bounds:o6,refblocks:Wq,circles:v9t}=Jf,C9t=Ft({primitives:[...Object.values(E9t),...Object.values(v9t),{type:"text",text:"{REF}",x:-.1,y:-.3094553499999995},{type:"text",text:"{VAL}",x:-.1,y:.3094553499999995}],ports:[{...Wq.top1,labels:["1","collector"]},{...Wq.bottom1,labels:["2","emitter"]},{...Wq.left1,labels:["3","base"]}],size:{width:o6.width,height:o6.height},center:{x:o6.centerX,y:o6.centerY}}).rotateRightFacingSymbol("left").changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:_9t,texts:Uer,bounds:u6,refblocks:Kq,circles:A9t}=Jf,R9t=Ft({primitives:[...Object.values(_9t),...Object.values(A9t),{type:"text",text:"{REF}",x:-.1,y:-.3094553499999995},{type:"text",text:"{VAL}",x:-.1,y:.3094553499999995}],ports:[{...Kq.top1,labels:["1","collector"]},{...Kq.bottom1,labels:["2","emitter"]},{...Kq.left1,labels:["3","base"]}],size:{width:u6.width,height:u6.height},center:{x:u6.centerX,y:u6.centerY}}).rotateRightFacingSymbol("left").changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),S9t={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:-.58,y:.18}],color:"primary",fill:!1},path45:{type:"path",points:[{x:-.32,y:-.09},{x:-.58,y:-.09}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.42,y:.04},{x:.15,y:.04}],color:"primary",fill:!1},"rect1577-3":{type:"path",points:[{x:-.2,y:.18},{x:-.27,y:.18}],color:"primary",fill:!0},"rect1577-4":{type:"path",points:[{x:-.2,y:-.09},{x:-.27,y:-.09}],color:"primary",fill:!0},"rect1577-4-7":{type:"path",points:[{x:-.23,y:-.05},{x:-.23,y:-.12}],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:{}},cR=Ft(S9t).labelPort("left1",["1","inp1"]).labelPort("left2",["2","inp2"]).labelPort("right1",["3","out"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),w9t=ur(cR,"down"),B9t=ur(cR,"left"),T9t=ur(cR,"up"),P9t={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:-.58,y:.18}],color:"primary",fill:!1},path45:{type:"path",points:[{x:-.32,y:-.09},{x:-.58,y:-.09}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.42,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:-.2,y:.18},{x:-.27,y:.18}],color:"primary",fill:!0},"rect1577-4":{type:"path",points:[{x:-.2,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:{}},lR=Ft(P9t).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(),I9t=ur(lR,"down"),j9t=ur(lR,"left"),N9t=ur(lR,"up"),k9t={paths:{path11:{type:"path",points:[{x:-.39,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:.53},{x:.3,y:.11}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:.31,y:-.53},{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:M9t,texts:IEe,bounds:c6,refblocks:Jq,circles:O9t}=k9t,Yve=ea({primitives:[...Object.values(M9t),...Object.values(O9t),{...IEe.top1,anchor:"middle_right",x:0},{...IEe.bottom1,anchor:"middle_right",x:0}],ports:[{...Jq.top1,labels:["1","drain"]},{...Jq.bottom1,labels:["2","source"]},{...Jq.left1,labels:["3","gate"]}],size:{width:c6.width,height:c6.height},center:{x:c6.centerX,y:c6.centerY}}),Hve=ur(Yve),Wve=Hve.primitives.filter(n=>n.type==="text"),UV=Wve.find(n=>n.text==="{VAL}");UV.x=-.35;UV.y=0;UV.anchor="middle_right";VV=Wve.find(n=>n.text==="{REF}");VV.y=0;VV.x=.35;VV.anchor="middle_left";L9t=Hve,$9t={paths:{path11:{type:"path",points:[{x:-.39,y:-.1},{x:.05,y:-.11}],color:"primary",fill:!1},"path12-1":{type:"path",points:[{x:.3,y:.53},{x:.3,y:.11}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:.31,y:-.53},{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:z9t,texts:jEe,bounds:l6,refblocks:Zq,circles:q9t}=$9t,Kve=ea({primitives:[...Object.values(z9t),...Object.values(q9t),{...jEe.top1,anchor:"middle_right",x:0},{...jEe.bottom1,anchor:"middle_right",x:0}],ports:[{...Zq.top1,labels:["1","drain"]},{...Zq.bottom1,labels:["2","source"]},{...Zq.left1,labels:["3","gate"]}],size:{width:l6.width,height:l6.height},center:{x:l6.centerX,y:l6.centerY}}),Jve=ur(Kve),Zve=Jve.primitives.filter(n=>n.type==="text"),GV=Zve.find(n=>n.text==="{VAL}");GV.x=-.35;GV.y=0;GV.anchor="middle_right";XV=Zve.find(n=>n.text==="{REF}");XV.y=0;XV.x=.35;XV.anchor="middle_left";U9t=Jve,V9t={paths:{path11:{type:"path",points:[{x:-.53,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:.53,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}}},Qve=Ft(V9t).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),eCe=ur(Qve),G9t=eCe.primitives.filter(n=>n.type==="text"),tCe=G9t.find(n=>n.text==="{REF}");tCe.y=0;tCe.anchor="middle_left";X9t=eCe,Y9t={paths:{path11:{type:"path",points:[{x:-.39,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:.53},{x:.28,y:.11}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:.29,y:-.53},{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:H9t,texts:NEe,bounds:d6,refblocks:Qq,circles:W9t}=Y9t,rCe=ea({primitives:[...Object.values(H9t),...Object.values(W9t),{...NEe.top1,anchor:"middle_right",x:0},{...NEe.bottom1,anchor:"middle_right"}],ports:[{...Qq.top1,labels:["1","drain"]},{...Qq.bottom1,labels:["2","source"]},{...Qq.left1,labels:["3","gate"]}],size:{width:d6.width,height:d6.height},center:{x:d6.centerX,y:d6.centerY}}),nCe=ur(rCe),aCe=nCe.primitives.filter(n=>n.type==="text"),YV=aCe.find(n=>n.text==="{VAL}");YV.x=-.35;YV.y=0;YV.anchor="middle_right";HV=aCe.find(n=>n.text==="{REF}");HV.y=0;HV.x=.35;HV.anchor="middle_left";K9t=nCe,Zf={paths:{path11:{type:"path",points:[{x:-.39,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:.54}],color:"primary",fill:!1},"path12-1-5-3":{type:"path",points:[{x:.29,y:-.54},{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:J9t,texts:Ver,bounds:p6,refblocks:eU,circles:Z9t}=Zf,Q9t=Ft({primitives:[...Object.values(J9t),...Object.values(Z9t),{type:"text",text:"{REF}",x:-.1,y:.3094553499999995},{type:"text",text:"{VAL}",x:-.1,y:-.3094553499999995}],ports:[{...eU.top1,labels:["1","collector"]},{...eU.bottom1,labels:["2","emitter"]},{...eU.left1,labels:["3","base"]}],size:{width:p6.width,height:p6.height},center:{x:p6.centerX,y:p6.centerY}}).rotateRightFacingSymbol("right").changeTextAnchor("{REF}","middle_right").changeTextAnchor("{VAL}","middle_right").build(),{paths:Ger,texts:Xer,bounds:Yer,refblocks:Her,circles:Wer}=Zf,eBt=Ft(Zf).rotateRightFacingSymbol("up").changeTextAnchor("{VAL}","middle_left").labelPort("left1",["3","base"]).labelPort("top1",["1","collector"]).labelPort("bottom1",["2","emitter"]).changeTextAnchor("{REF}","middle_right").build(),{paths:tBt,texts:Ker,bounds:x6,refblocks:tU,circles:rBt}=Zf,nBt=Ft({primitives:[...Object.values(tBt),...Object.values(rBt),{type:"text",text:"{REF}",x:-.1,y:-.3094553499999995},{type:"text",text:"{VAL}",x:-.1,y:.3094553499999995}],ports:[{...tU.top1,labels:["1","collector"]},{...tU.bottom1,labels:["2","emitter"]},{...tU.left1,labels:["3","base"]}],size:{width:x6.width,height:x6.height},center:{x:x6.centerX,y:x6.centerY}}).rotateRightFacingSymbol("down").changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_bottom").build(),{paths:aBt,texts:Jer,bounds:f6,refblocks:rU,circles:sBt}=Zf,iBt=Ft({primitives:[...Object.values(aBt),...Object.values(sBt),{type:"text",text:"{REF}",x:-.1,y:-.3094553499999995},{type:"text",text:"{VAL}",x:-.1,y:.3094553499999995}],ports:[{...rU.top1,labels:["1","collector"]},{...rU.bottom1,labels:["2","emitter"]},{...rU.left1,labels:["3","base"]}],size:{width:f6.width,height:f6.height},center:{x:f6.centerX,y:f6.centerY}}).rotateRightFacingSymbol("up").changeTextAnchor("{REF}","middle_top").changeTextAnchor("{VAL}","middle_top").build(),{paths:oBt,texts:Zer,bounds:h6,refblocks:nU,circles:uBt}=Zf,cBt=Ft({primitives:[...Object.values(oBt),...Object.values(uBt),{type:"text",text:"{REF}",x:-.1,y:-.3094553499999995},{type:"text",text:"{VAL}",x:-.1,y:.3094553499999995}],ports:[{...nU.top1,labels:["1","collector"]},{...nU.bottom1,labels:["2","emitter"]},{...nU.left1,labels:["3","base"]}],size:{width:h6.width,height:h6.height},center:{x:h6.centerX,y:h6.centerY}}).rotateRightFacingSymbol("left").changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:lBt,texts:Qer,bounds:m6,refblocks:aU,circles:dBt}=Zf,pBt=Ft({primitives:[...Object.values(lBt),...Object.values(dBt),{type:"text",text:"{REF}",x:-.1,y:-.3094553499999995},{type:"text",text:"{VAL}",x:-.1,y:.3094553499999995}],ports:[{...aU.top1,labels:["1","collector"]},{...aU.bottom1,labels:["2","emitter"]},{...aU.left1,labels:["3","base"]}],size:{width:m6.width,height:m6.height},center:{x:m6.centerX,y:m6.centerY}}).rotateRightFacingSymbol("left").changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),xBt={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:-.51,y:.01}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:-.01,y:.51},{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:.5,y:.01},{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:.01,y:-.51}],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:fBt,texts:kEe,bounds:g6,refblocks:MEe}=xBt,sCe=ea({primitives:[...Object.values(fBt),{...kEe.bottom1,y:.35,anchor:"middle_top"},{...kEe.top1,anchor:"middle_left"}],ports:[{...MEe.left1,labels:["1"]},{...MEe.right1,labels:["2"]}],size:{width:g6.width+.05,height:g6.height},center:{x:g6.centerX,y:g6.centerY}}),hBt=ur(sCe),mBt=hBt,gBt={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:yBt,texts:OEe,bounds:y6,refblocks:LEe}=gBt,dR=ea({primitives:[...Object.values(yBt),{...OEe.bottom1,x:0,y:-.35,anchor:"middle_top"},{...OEe.top1,x:0,y:.35,anchor:"middle_bottom"}],ports:[{...LEe.left1,labels:["1"]},{...LEe.right1,labels:["2"]}],size:{width:y6.width+.05,height:y6.height},center:{x:y6.centerX,y:y6.centerY}}),WV=ur(dR,"down"),KV=WV.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),JV=WV.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");KV.anchor="middle_left";JV.anchor="middle_left";KV.y+=.31;KV.x=.34;JV.y-=.31;JV.x=.34;DBt=WV,ZV=ur(dR,"left"),QV=ZV.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),eG=ZV.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");QV.anchor="middle_bottom";eG.anchor="middle_top";QV.y+=.73;QV.x=0;eG.y-=.7;eG.x=0;bBt=ZV,tG=ur(dR,"up"),rG=tG.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),nG=tG.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");rG.anchor="middle_left";nG.anchor="middle_left";rG.y+=.21;rG.x=.34;nG.y-=.21;nG.x=.34;FBt=tG,pR={paths:{path1:{type:"path",points:[{x:-.4,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:.4,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:EBt,texts:etr,bounds:D6,refblocks:sU,circles:vBt}=pR,CBt=Ft({primitives:[...Object.values(EBt),...Object.values(vBt),{type:"text",text:"{REF}",x:-.15,y:.2394553499999995},{type:"text",text:"{VAL}",x:.15,y:.2394553499999995}],ports:[{...sU.left,labels:["1"]},{...sU.right,labels:["2"]},{...sU.bottom,labels:["3"]}],size:{width:D6.width,height:D6.height},center:{x:D6.centerX,y:D6.centerY}}).rotateRightFacingSymbol("down").labelPort("left",["1"]).labelPort("right",["2"]).labelPort("bottom",["3"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:_Bt,texts:ttr,bounds:b6,refblocks:iU,circles:ABt}=pR,RBt=Ft({primitives:[...Object.values(_Bt),...Object.values(ABt),{type:"text",text:"{REF}",x:-.3,y:-.3894553499999995},{type:"text",text:"{VAL}",x:-.3,y:.3194553499999995}],ports:[{...iU.left,labels:["1"]},{...iU.right,labels:["2"]},{...iU.bottom,labels:["3"]}],size:{width:b6.width,height:b6.height},center:{x:b6.centerX,y:b6.centerY}}).rotateRightFacingSymbol("left").labelPort("left",["1"]).labelPort("right",["2"]).labelPort("bottom",["3"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),SBt=Ft(pR).labelPort("left",["1"]).labelPort("right",["2"]).labelPort("bottom",["3"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),{paths:wBt,texts:rtr,bounds:F6,refblocks:oU,circles:BBt}=pR,TBt=Ft({primitives:[...Object.values(wBt),...Object.values(BBt),{type:"text",text:"{REF}",x:.3,y:-.2894553499999995},{type:"text",text:"{VAL}",x:-.3,y:-.2894553499999995}],ports:[{...oU.left,labels:["1"]},{...oU.right,labels:["2"]},{...oU.bottom,labels:["3"]}],size:{width:F6.width,height:F6.height},center:{x:F6.centerX,y:F6.centerY}}).rotateRightFacingSymbol("up").labelPort("left",["1"]).labelPort("right",["2"]).labelPort("bottom",["3"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),PBt={paths:{path11:{type:"path",points:[{x:-.53,y:.03},{x:-.3,y:.03}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:.03},{x:.53,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:IBt,texts:ntr,bounds:E6,refblocks:$Ee,circles:jBt}=PBt,iCe=ea({primitives:[...Object.values(IBt),...Object.values(jBt),{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:[{...$Ee.left1,labels:["1"]},{...$Ee.right1,labels:["2"]}],size:{width:E6.width,height:E6.height},center:{x:E6.centerX,y:E6.centerY}}),oCe=ur(iCe),aG=oCe.primitives.filter(n=>n.type==="text"),sG=aG.find(n=>n.text==="{REF}"),iG=aG.find(n=>n.text==="{VAL}"),oG=aG.find(n=>n.text==="COS \u03C6");sG.x=.35;sG.y=0;sG.anchor="middle_left";iG.anchor="middle_right";iG.x=-.35;iG.y=0;oG.x=0;oG.y=0;oG.anchor="center";NBt=oCe,kBt={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:-.49,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:.49,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:MBt,texts:zEe,bounds:v6,refblocks:qEe,circles:OBt}=kBt,uCe=ea({primitives:[...Object.values(MBt),...Object.values(OBt),{...zEe.top1,anchor:"middle_left"},{...zEe.bottom1,anchor:"middle_left"}],ports:[{...qEe.left1,labels:["1"]},{...qEe.right1,labels:["2"]}],size:{width:v6.width,height:v6.height},center:{x:v6.centerX,y:v6.centerY}}),LBt=ur(uCe,"up"),$Bt={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:-.49,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:.49,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:zBt,texts:UEe,bounds:C6,refblocks:VEe,circles:qBt}=$Bt,cCe=ea({primitives:[...Object.values(zBt),...Object.values(qBt),{...UEe.top1,anchor:"middle_left"},{...UEe.bottom1,anchor:"middle_left"}],ports:[{...VEe.left1,labels:["1"]},{...VEe.right1,labels:["2"]}],size:{width:C6.width,height:C6.height},center:{x:C6.centerX,y:C6.centerY}}),UBt=ur(cCe,"up"),VBt={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:-.51,y:-.01}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:-.01,y:-.51},{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:.5,y:-.01},{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:.01,y:.51}],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:GBt,texts:GEe,bounds:_6,refblocks:A6,circles:XBt}=VBt,lCe=ea({primitives:[...Object.values(GBt),...Object.values(XBt),{...GEe.top1,anchor:"middle_right"},{...GEe.bottom1,anchor:"middle_right"}],ports:[{...A6.top1,labels:["1"]},{...A6.bottom1,labels:["2"]},{...A6.left1,labels:["3"]},{...A6.right1,labels:["4"]}],size:{width:_6.width,height:_6.height},center:{x:_6.centerX,y:_6.centerY}}),uG=ur(lCe),YBt=uG.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),HBt=uG.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");YBt.anchor="middle_left";HBt.anchor="middle_right";WBt=uG,xR={paths:{path27:{type:"path",points:[{x:.46,y:.04},{x:.21,y:.04}],color:"primary",fill:!1},"path27-0":{type:"path",points:[{x:-.21,y:.04},{x:-.46,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:KBt,texts:atr,bounds:R6,refblocks:XEe,circles:JBt}=xR,ZBt=Ft({primitives:[...Object.values(KBt),...Object.values(JBt),{type:"text",text:"{REF}",x:-.2,y:.2194553499999995},{type:"text",text:"{VAL}",x:.2,y:.2194553499999995}],ports:[{...XEe.left1,labels:["1"]},{...XEe.right1,labels:["2"]}],size:{width:R6.width,height:R6.height},center:{x:R6.centerX,y:R6.centerY}}).rotateRightFacingSymbol("down").labelPort("left",["1"]).labelPort("right",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:QBt,texts:str,bounds:S6,refblocks:YEe,circles:e7t}=xR,t7t=Ft({primitives:[...Object.values(QBt),...Object.values(e7t),{type:"text",text:"{REF}",x:0,y:-.1704553499999995},{type:"text",text:"{VAL}",x:0,y:.2294553499999995}],ports:[{...YEe.left1,labels:["1"]},{...YEe.right1,labels:["2"]}],size:{width:S6.width,height:S6.height},center:{x:S6.centerX,y:S6.centerY}}).rotateRightFacingSymbol("left").labelPort("left",["1"]).labelPort("right",["2"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),{paths:r7t,texts:itr,bounds:w6,refblocks:HEe,circles:n7t}=xR,a7t=Ft({primitives:[...Object.values(r7t),...Object.values(n7t),{type:"text",text:"{REF}",x:0,y:.2294553499999995},{type:"text",text:"{VAL}",x:0,y:-.1704553499999995}],ports:[{...HEe.left1,labels:["1"]},{...HEe.right1,labels:["2"]}],size:{width:w6.width,height:w6.height},center:{x:w6.centerX,y:w6.centerY}}).rotateRightFacingSymbol("right").labelPort("left",["1"]).labelPort("right",["2"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),{paths:s7t,texts:otr,bounds:B6,refblocks:WEe,circles:i7t}=xR,o7t=Ft({primitives:[...Object.values(s7t),...Object.values(i7t),{type:"text",text:"{REF}",x:.2,y:-.1404553499999995},{type:"text",text:"{VAL}",x:-.2,y:-.1494553499999995}],ports:[{...WEe.left1,labels:["1"]},{...WEe.right1,labels:["2"]}],size:{width:B6.width,height:B6.height},center:{x:B6.centerX,y:B6.centerY}}).rotateRightFacingSymbol("up").labelPort("left",["1"]).labelPort("right",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),dCe={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:-.75,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:u7t,texts:KEe,bounds:T6,refblocks:uU,circles:c7t}=dCe,fR=ea({primitives:[...Object.values(u7t),...Object.values(c7t),{...KEe.top1,anchor:"middle_bottom"},{...KEe.bottom1,anchor:"middle_top"}],ports:[{...uU.left1,labels:["1"]},{...uU.right1,labels:["2"]},{...uU.right2,labels:["3"]}],size:{width:T6.width,height:T6.height},center:{x:T6.centerX,y:T6.centerY}}),cG=ur(fR,"down"),lG=cG.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),dG=cG.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");lG.anchor="middle_bottom";dG.anchor="middle_top";lG.y+=.3;lG.x+=.101;dG.y-=.49999;dG.x+=1.19999;l7t=cG,{paths:d7t,texts:utr,bounds:P6,refblocks:cU,circles:p7t}=dCe,pCe=ea({primitives:[...Object.values(d7t),...Object.values(p7t),{type:"text",text:"{REF}",x:.01596175000000022,y:-.5308501500000009,anchor:"middle_top"},{type:"text",text:"{VAL}",x:.013116750000000454,y:.5408501499999989,anchor:"middle_bottom"}],ports:[{...cU.left1,labels:["1"]},{...cU.right1,labels:["2"]},{...cU.right2,labels:["3"]}],size:{width:P6.width,height:P6.height},center:{x:P6.centerX,y:P6.centerY}}),pG=ur(fR,"left"),xG=pG.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),fG=pG.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");xG.anchor="middle_bottom";fG.anchor="middle_top";xG.y+=.99;xG.x-=0;fG.y-=1.10999;fG.x=0;x7t=pG,hG=ur(fR,"up"),mG=hG.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),gG=hG.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");mG.anchor="middle_bottom";gG.anchor="middle_top";mG.y+=.499;mG.x=.62;gG.y-=.29999;gG.x+=.1;f7t=hG,h7t=ur(pCe),m7t={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:{}},hR=Ft(m7t).labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{VAL}","middle_top").changeTextAnchor("{REF}","middle_bottom").build(),yG=ur(hR,"down"),DG=yG.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),bG=yG.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");DG.anchor="middle_left";bG.anchor="middle_left";DG.y+=.3;DG.x=.3;bG.y-=.3;bG.x=.3;g7t=yG,FG=ur(hR,"left"),EG=FG.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),vG=FG.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");EG.anchor="middle_bottom";vG.anchor="middle_top";EG.y+=.5;EG.x=0;vG.y-=.55;vG.x=0;y7t=FG,CG=ur(hR,"up"),_G=CG.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),AG=CG.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");_G.anchor="middle_left";AG.anchor="middle_left";_G.y+=.3;_G.x=.3;AG.y-=.3;AG.x=.3;D7t=CG,xCe={paths:{path11:{type:"path",points:[{x:-.5,y:.04},{x:-.18,y:.04}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.19,y:.05},{x:.51,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:-.33}],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:ctr,texts:ltr,bounds:dtr,refblocks:ptr,circles:xtr}=xCe,fCe=Ft(xCe).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).labelPort("bottom1",["3"]).changeTextAnchor("{REF}","middle_bottom").build(),hCe=ur(fCe),b7t=hCe.primitives.filter(n=>n.type==="text"),mCe=b7t.find(n=>n.text==="{REF}");mCe.y=0;mCe.anchor="middle_left";F7t=hCe,mR={paths:{path44:{type:"path",points:[{x:-.18,y:-.03},{x:-.44,y:-.03}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.44,y:-.02},{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:{}},E7t=Ft(mR).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").build(),v7t=Ft(mR).rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_top").build(),C7t=Ft(mR).rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),_7t=Ft(mR).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_right").build(),gR={paths:{path44:{type:"path",points:[{x:-.18,y:-.03},{x:-.44,y:-.03}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.44,y:-.02},{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:{}},A7t=Ft(gR).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").build(),R7t=Ft(gR).rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_top").build(),S7t=Ft(gR).rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),w7t=Ft(gR).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_right").build(),yR={paths:{path44:{type:"path",points:[{x:-.22,y:.1},{x:-.44,y:.1}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.44,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:{}},B7t=Ft(yR).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_left").build(),T7t=Ft(yR).rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_top").build(),P7t=Ft(yR).rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_bottom").build(),I7t=Ft(yR).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_right").build(),DR={paths:{path44:{type:"path",points:[{x:-.22,y:.1},{x:-.44,y:.1}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.44,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:{}},j7t=Ft(DR).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_left").build(),N7t=Ft(DR).rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_top").build(),k7t=Ft(DR).rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_bottom").build(),M7t=Ft(DR).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_right").build(),bR={paths:{path44:{type:"path",points:[{x:-.22,y:.1},{x:-.44,y:.1}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.44,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:{}},O7t=Ft(bR).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_left").build(),L7t=Ft(bR).rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_top").build(),$7t=Ft(bR).rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_bottom").build(),z7t=Ft(bR).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_right").build(),FR={paths:{path44:{type:"path",points:[{x:-.22,y:.1},{x:-.44,y:.1}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.44,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:{}},q7t=Ft(FR).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_left").build(),U7t=Ft(FR).rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_top").build(),V7t=Ft(FR).rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_bottom").build(),G7t=Ft(FR).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("bottom1",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_right").build(),X7t={paths:{path1:{type:"path",points:[{x:-.35,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:.35,y:-.06}],color:"primary",fill:!1},path3:{type:"path",points:[{x:.12,y:.17},{x:.36,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}}},ER=Ft(X7t).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right2",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_bottom").build(),RG=ur(ER,"down"),SG=RG.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),wG=RG.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");SG.anchor="middle_bottom";wG.anchor="middle_top";SG.x=.44;SG.y+=.28;wG.y-=.28;wG.x=.44;Y7t=RG,BG=ur(ER,"left"),TG=BG.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),PG=BG.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");TG.anchor="middle_bottom";PG.anchor="middle_top";TG.x=0;TG.y+=.625;PG.y-=.695;PG.x=0;H7t=BG,IG=ur(ER,"up"),jG=IG.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),NG=IG.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");jG.anchor="middle_bottom";NG.anchor="middle_top";jG.x=.4;jG.y+=.28;NG.y-=.28;NG.x=.4;W7t=IG,K7t={paths:{path1:{type:"path",points:[{x:-.35,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:.35,y:-.06}],color:"primary",fill:!1},path3:{type:"path",points:[{x:.12,y:.17},{x:.36,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}}},vR=Ft(K7t).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right3",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_bottom").build(),kG=ur(vR,"down"),MG=kG.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),OG=kG.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");MG.anchor="middle_bottom";OG.anchor="middle_top";MG.x=.44;MG.y+=.28;OG.y-=.28;OG.x=.44;J7t=kG,LG=ur(vR,"left"),$G=LG.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),zG=LG.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");$G.anchor="middle_bottom";zG.anchor="middle_top";$G.x=0;$G.y+=.625;zG.y-=.695;zG.x=0;Z7t=LG,qG=ur(vR,"up"),UG=qG.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),VG=qG.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");UG.anchor="middle_bottom";VG.anchor="middle_top";UG.x=.4;UG.y+=.28;VG.y-=.28;VG.x=.4;Q7t=qG,CR={paths:{path11:{type:"path",points:[{x:-.36,y:0},{x:-.14,y:0}],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:.13,y:0},{x:.37,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 CR.refblocks.left1;delete CR.refblocks.right1;CR.bounds.width+=.2;_R=Ft(CR).changeTextAnchor("{VAL}","middle_top").labelPort("left2",["1"]).labelPort("right2",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),GG=ur(_R,"down"),XG=GG.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),YG=GG.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");XG.anchor="middle_bottom";YG.anchor="middle_top";XG.x=.3;XG.y+=.265;YG.y-=.265;YG.x=.3;eTt=GG,HG=ur(_R,"left"),WG=HG.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),KG=HG.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");WG.anchor="middle_bottom";KG.anchor="middle_top";WG.x=0;WG.y+=.57;KG.y-=.57;KG.x=0;tTt=HG,JG=ur(_R,"up"),ZG=JG.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),QG=JG.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");ZG.anchor="middle_bottom";QG.anchor="middle_top";ZG.x=.3;ZG.y+=.265;QG.y-=.265;QG.x=.3;rTt=JG,AR={paths:{path11:{type:"path",points:[{x:-.36,y:0},{x:-.14,y:0}],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:.13,y:0},{x:.37,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 AR.refblocks.left1;delete AR.refblocks.right1;AR.bounds.width+=.2;RR=Ft(AR).changeTextAnchor("{VAL}","middle_top").labelPort("left2",["1"]).labelPort("right2",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),eX=ur(RR,"down"),tX=eX.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),rX=eX.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");tX.anchor="middle_bottom";rX.anchor="middle_top";tX.x=.3;tX.y+=.265;rX.y-=.265;rX.x=.3;nTt=eX,nX=ur(RR,"left"),aX=nX.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),sX=nX.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");aX.anchor="middle_bottom";sX.anchor="middle_top";aX.x=0;aX.y+=.57;sX.y-=.57;sX.x=0;aTt=nX,iX=ur(RR,"up"),oX=iX.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),uX=iX.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");oX.anchor="middle_bottom";uX.anchor="middle_top";oX.x=.3;oX.y+=.265;uX.y-=.265;uX.x=.3;sTt=iX,SR={paths:{path44:{type:"path",points:[{x:-.16845120000000047,y:.02621170000000017},{x:-.4403295000000007,y:.02621170000000017}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.43977860000000035,y:.027926399999999685},{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:{}},iTt=Ft(SR).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(),oTt=Ft(SR).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(),uTt=Ft(SR).rotateRightFacingSymbol("right").labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),cTt=Ft(SR).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(),gCe={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:ftr,texts:htr,bounds:mtr,refblocks:gtr,circles:ytr}=gCe,yCe=Ft(gCe).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),lTt=ur(yCe),dTt={paths:{path11:{type:"path",points:[{x:-.53,y:0},{x:-.3,y:0}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:0},{x:.53,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:pTt,texts:xTt,bounds:I6,refblocks:JEe,circles:fTt}=dTt,cX=ea({primitives:[...Object.values(pTt),...Object.values(fTt),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"},{...xTt.left1,y:.01,anchor:"center",fontSize:.2}],ports:[{...JEe.left1,labels:["1"]},{...JEe.right1,labels:["2"]}],size:{width:I6.width,height:I6.height},center:{x:I6.centerX,y:I6.centerY}}),{5:hTt,...mTt}=cX.primitives;ZEe=ur({...cX,primitives:Object.values(mTt).filter(gTt)}),yTt={...ZEe,primitives:[...ZEe.primitives,hTt]},wR=ea({primitives:[{type:"path",points:[{x:-.2,y:0},{x:0,y:0}],color:"primary",fill:!1},{type:"path",points:Array.from({length:8},(n,e)=>{let a=Math.PI/2-e*Math.PI/7,s=.1;return{x:.1-s*Math.cos(a),y:s*Math.sin(a)}}),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}}),DCe=ur(wR,"down"),QEe=DCe.primitives.find(n=>n.type==="text"&&n.text==="{REF}");QEe&&(QEe.anchor="middle_top");DTt=DCe,bTt=ur(wR,"left"),bCe=ur(wR,"up"),eve=bCe.primitives.find(n=>n.type==="text"&&n.text==="{REF}");eve&&(eve.anchor="middle_bottom");FTt=bCe,ETt={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:-.4,y:.2},{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:{}},lX=Ft(ETt).labelPort("right1",["1"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),dX=ur(lX,"up"),pX=dX.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),xX=dX.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");pX.anchor="middle_bottom";xX.anchor="middle_top";pX.x=.4;pX.y+=.2;xX.y-=.3;xX.x=.4;FCe=dX,fX=X6(FCe),hX=fX.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),mX=fX.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");hX.anchor="middle_bottom";mX.anchor="middle_top";hX.x=.35;hX.y+=.4;mX.y-=.4;mX.x=.35;vTt=fX,gX=ur(lX,"left"),yX=gX.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),DX=gX.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");yX.anchor="middle_bottom";DX.anchor="middle_top";yX.x=0;yX.y+=.5;DX.y-=.6;DX.x=0;CTt=gX,ECe={paths:{path11:{type:"path",points:[{x:-.52,y:.04},{x:-.11,y:.04}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.1,y:.04},{x:.52,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:-.3}],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:Dtr,texts:btr,bounds:Ftr,refblocks:Etr,circles:vtr}=ECe,vCe=Ft(ECe).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).labelPort("bottom1",["3"]).changeTextAnchor("{REF}","middle_bottom").build(),CCe=ur(vCe),_Ce=CCe.primitives.filter(n=>n.type==="text"),_Tt=_Ce.find(n=>n.text==="{REF}"),ATt=_Ce.find(n=>n.text==="{VAL}");_Tt.y=0;ATt.y=0;RTt=CCe,STt={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:wTt,texts:tve,bounds:j6,refblocks:rve,circles:BTt}=STt,ACe=ea({primitives:[...Object.values(wTt),...Object.values(BTt),{...tve.top1,anchor:"middle_bottom"},{...tve.bottom1,anchor:"middle_top"}],ports:[{...rve.left1,labels:["1"]},{...rve.right1,labels:["2"]}],size:{width:j6.width,height:j6.height},center:{x:j6.centerX,y:j6.centerY}}),bX=ur(ACe),TTt=bX.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),PTt=bX.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");TTt.anchor="middle_left";PTt.anchor="middle_right";ITt=bX,jTt={paths:{path11:{type:"path",points:[{x:-.33,y:.21},{x:-.02,y:.01}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.23,y:.13},{x:.23,y:.38}],color:"primary",fill:!1},"path12-2":{type:"path",points:[{x:.23,y:-.08},{x:.23,y:-.33}],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:NTt,texts:nve,bounds:N6,refblocks:lU,circles:kTt}=jTt,RCe=ea({primitives:[...Object.values(NTt),...Object.values(kTt),{...nve.top1,anchor:"middle_left"},{...nve.bottom1,anchor:"middle_right"}],ports:[{...lU.top1,labels:["1"]},{...lU.bottom1,labels:["2"]},{...lU.left1,labels:["3"]}],size:{width:N6.width,height:N6.height},center:{x:N6.centerX,y:N6.centerY}}),SCe=ur(RCe),wCe=SCe.primitives.filter(n=>n.type==="text"),MTt=wCe.find(n=>n.text==="{REF}");MTt.y=.1;BCe=wCe.find(n=>n.text==="{VAL}");BCe.y=.1;BCe.x=-.4;OTt=SCe,LTt={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}},$Tt=Ft(LTt).changeTextAnchor("{REF}","middle_bottom").build(),zTt={paths:{path11:{type:"path",points:[{x:-.53,y:0},{x:-.3,y:0}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:0},{x:.53,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:qTt,texts:dU,bounds:k6,refblocks:ave,circles:UTt}=zTt,TCe=ea({primitives:[...Object.values(qTt),...Object.values(UTt),{...dU.top1,x:0,y:-.3594553499999995,anchor:"middle_top"},{...dU.bottom1,x:0,y:.35,anchor:"middle_bottom"},{...dU.left1,x:-.02,y:.01,fontSize:.2,anchor:"center"}],ports:[{...ave.left1,labels:["1"]},{...ave.right1,labels:["2"]}],size:{width:k6.width,height:k6.height},center:{x:k6.centerX,y:k6.centerY}}),VTt=ur(TCe),GTt={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:.53,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:XTt,texts:sve,bounds:M6,refblocks:ive,circles:YTt}=GTt,PCe=ea({primitives:[...Object.values(XTt),...Object.values(YTt),{...sve.top1,anchor:"middle_bottom"},{...sve.bottom1,anchor:"middle_top"}],ports:[{...ive.left1,labels:["1"]},{...ive.right1,labels:["2"]}],size:{width:M6.width,height:M6.height},center:{x:M6.centerX,y:M6.centerY}}),FX=ur(PCe),HTt=FX.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),WTt=FX.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");HTt.anchor="middle_left";WTt.anchor="middle_right";KTt=FX,JTt={paths:{path5:{type:"path",points:[{x:-.52,y:0},{x:-.26,y:0}],color:"primary",fill:!1},path6:{type:"path",points:[{x:.27,y:0},{x:.53,y:0}],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:ZTt,texts:ove,bounds:O6,refblocks:uve}=JTt,ICe=ea({primitives:[...Object.values(ZTt),{...ove.top1,anchor:"middle_left"},{...ove.bottom1,anchor:"middle_right"}],ports:[{...uve.left1,labels:["1","-"]},{...uve.right1,labels:["2","+"]}],size:{width:O6.width,height:O6.height},center:{x:O6.centerX,y:O6.centerY}}),QTt=ur(ICe),ePt={paths:{path11:{type:"path",points:[{x:-.53,y:0},{x:-.3,y:0}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:0},{x:.53,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:tPt,texts:rPt,bounds:L6,refblocks:cve,circles:nPt}=ePt,EX=ea({primitives:[...Object.values(tPt),...Object.values(nPt),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"},{...rPt.left1,anchor:"center",y:.02,fontSize:.2}],ports:[{...cve.left1,labels:["1"]},{...cve.right1,labels:["2"]}],size:{width:L6.width,height:L6.height},center:{x:L6.centerX,y:L6.centerY}}),{5:aPt,...sPt}=EX.primitives;lve=ur({...EX,primitives:Object.values(sPt).filter(iPt)}),oPt={...lve,primitives:[...lve.primitives,aPt]},BR={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:-.22,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:{}},uPt=Ft(BR).rotateRightFacingSymbol("down").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_top").build(),cPt=Ft(BR).rotateRightFacingSymbol("left").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_right").build(),lPt=Ft(BR).rotateRightFacingSymbol("right").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_left").build(),dPt=Ft(BR).rotateRightFacingSymbol("up").labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_bottom").build(),jCe={paths:{path11:{type:"path",points:[{x:-.53,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:.53,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:Ctr,texts:_tr,bounds:Atr,circles:Rtr,refblocks:Str}=jCe,NCe=Ft(jCe).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),pPt=ur(NCe),xPt={paths:{path11:{type:"path",points:[{x:-.53,y:0},{x:-.3,y:0}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:0},{x:.53,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:fPt,texts:hPt,bounds:$6,refblocks:dve,circles:mPt}=xPt,vX=ea({primitives:[...Object.values(fPt),...Object.values(mPt),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"},{...hPt.left1,anchor:"center",y:.01,fontSize:.2}],ports:[{...dve.left1,labels:["1"]},{...dve.right1,labels:["2"]}],size:{width:$6.width,height:$6.height},center:{x:$6.centerX,y:$6.centerY}}),{5:gPt,...yPt}=vX.primitives;pve=ur({...vX,primitives:Object.values(yPt).filter(DPt)}),bPt={...pve,primitives:[...pve.primitives,gPt]},FPt={paths:{path11:{type:"path",points:[{x:-.53,y:0},{x:-.3,y:0}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:0},{x:.53,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:EPt,texts:vPt,bounds:z6,refblocks:xve,circles:CPt}=FPt,CX=ea({primitives:[...Object.values(EPt),...Object.values(CPt),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"},{...vPt.left1,anchor:"center",y:.01,fontSize:.3}],ports:[{...xve.left1,labels:["1"]},{...xve.right1,labels:["2"]}],size:{width:z6.width,height:z6.height},center:{x:z6.centerX,y:z6.centerY}}),{5:_Pt,...APt}=CX.primitives;fve=ur({...CX,primitives:Object.values(APt).filter(RPt)}),SPt={...fve,primitives:[...fve.primitives,_Pt]},wPt={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:BPt,texts:hve,bounds:q6,refblocks:mve,circles:TPt}=wPt,kCe=ea({primitives:[...Object.values(BPt),...Object.values(TPt),{...hve.top1,anchor:"middle_bottom"},{...hve.bottom1,anchor:"middle_top"}],ports:[{...mve.left1,labels:["1"]},{...mve.right1,labels:["2"]}],size:{width:q6.width,height:q6.height},center:{x:q6.centerX,y:q6.centerY}}),_X=ur(kCe),PPt=_X.primitives.find(n=>n.type==="text"&&n.text==="{REF}"),IPt=_X.primitives.find(n=>n.type==="text"&&n.text==="{VAL}");PPt.anchor="middle_left";IPt.anchor="middle_right";jPt=_X,Ts={ac_voltmeter_down:X4t,ac_voltmeter_horz:W4t,ac_voltmeter_left:Z4t,ac_voltmeter_right:t6t,ac_voltmeter_up:a6t,ac_voltmeter_vert:o6t,avalanche_diode_down:l6t,avalanche_diode_horz:d6t,avalanche_diode_left:f6t,avalanche_diode_right:h6t,avalanche_diode_up:y6t,avalanche_diode_vert:F6t,backward_diode_down:C6t,backward_diode_left:gve,backward_diode_right:w6t,backward_diode_up:B6t,battery_horz:yve,battery_vert:j6t,boxresistor_down:M6t,boxresistor_left:$6t,boxresistor_right:U6t,boxresistor_small_down:X6t,boxresistor_small_left:W6t,boxresistor_small_right:Z6t,boxresistor_small_up:tRt,boxresistor_up:aRt,bridged_ground_down:oRt,bridged_ground_left:lRt,bridged_ground_right:Dve,bridged_ground_up:xRt,capacitor_down:mRt,capacitor_left:gRt,capacitor_polarized_down:bRt,capacitor_polarized_left:FRt,capacitor_polarized_right:CRt,capacitor_polarized_up:RRt,capacitor_right:SRt,capacitor_up:TRt,constant_current_diode_down:jRt,constant_current_diode_horz:NRt,constant_current_diode_left:ORt,constant_current_diode_right:LRt,constant_current_diode_up:qRt,constant_current_diode_vert:GRt,crystal_4pin_down:HRt,crystal_4pin_left:WRt,crystal_4pin_right:KRt,crystal_4pin_up:QRt,crystal_down:r5t,crystal_left:n5t,crystal_right:a5t,crystal_up:o5t,darlington_pair_transistor_down:u5t,darlington_pair_transistor_horz:c5t,darlington_pair_transistor_left:l5t,darlington_pair_transistor_right:d5t,darlington_pair_transistor_up:p5t,darlington_pair_transistor_vert:x5t,dc_ammeter_horz:bU,dc_ammeter_vert:E5t,dc_voltmeter_down:_5t,dc_voltmeter_horz:S5t,dc_voltmeter_left:T5t,dc_voltmeter_right:j5t,dc_voltmeter_up:M5t,dc_voltmeter_vert:$5t,diac_down:z5t,diac_horz:q5t,diac_left:U5t,diac_right:V5t,diac_up:G5t,diac_vert:X5t,diode_down:H5t,diode_left:W5t,diode_right:eR,diode_up:K5t,dpdt_normally_closed_switch_down:Z5t,dpdt_normally_closed_switch_left:Q5t,dpdt_normally_closed_switch_right:tR,dpdt_normally_closed_switch_up:eSt,dpdt_switch_down:rSt,dpdt_switch_left:nSt,dpdt_switch_right:rR,dpdt_switch_up:aSt,dpst_normally_closed_switch_down:iSt,dpst_normally_closed_switch_left:oSt,dpst_normally_closed_switch_right:nR,dpst_normally_closed_switch_up:uSt,dpst_switch_down:lSt,dpst_switch_left:dSt,dpst_switch_right:aR,dpst_switch_up:pSt,ferrite_bead_down:hSt,ferrite_bead_left:mSt,ferrite_bead_right:Eve,ferrite_bead_up:Fve,filled_diode_down:DSt,filled_diode_horz:ESt,filled_diode_left:_St,filled_diode_right:SSt,filled_diode_up:TSt,filled_diode_vert:jSt,frequency_meter_horz:iV,frequency_meter_vert:qSt,fuse_horz:vve,fuse_vert:XSt,ground_down:YSt,ground_horz:HSt,ground_left:WSt,ground_right:KSt,ground_up:JSt,ground_vert:ZSt,ground2_down:twt,ground2_left:swt,ground2_right:cwt,ground2_up:xwt,gunn_diode_horz:fwt,gunn_diode_vert:hwt,icled_down:gwt,icled_left:ywt,icled_right:iR,icled_up:Dwt,igbt_transistor_horz:Cve,igbt_transistor_vert:Fwt,illuminated_push_button_normally_open_horz:Ave,illuminated_push_button_normally_open_vert:vwt,inductor_down:Rwt,inductor_left:Swt,inductor_right:hV,inductor_up:wve,laser_diode_down:wwt,laser_diode_left:Bwt,laser_diode_right:oR,laser_diode_up:Twt,led_down:Nwt,led_left:kwt,led_right:_V,led_up:Tve,light_dependent_resistor_horz:Pve,light_dependent_resistor_vert:$wt,mosfet_depletion_normally_on_horz:Nve,mosfet_depletion_normally_on_vert:Uwt,mushroom_head_normally_open_momentary_horz:Mve,mushroom_head_normally_open_momentary_vert:Ywt,n_channel_d_mosfet_transistor_horz:Ove,n_channel_d_mosfet_transistor_vert:Jwt,n_channel_e_mosfet_transistor_horz:zve,n_channel_e_mosfet_transistor_vert:t9t,njfet_transistor_horz:Vve,njfet_transistor_vert:s9t,not_connected_down:c9t,not_connected_left:l9t,not_connected_right:uR,not_connected_up:d9t,npn_bipolar_transistor_down:f9t,npn_bipolar_transistor_horz:h9t,npn_bipolar_transistor_left:y9t,npn_bipolar_transistor_right:F9t,npn_bipolar_transistor_up:C9t,npn_bipolar_transistor_vert:R9t,opamp_no_power_down:w9t,opamp_no_power_left:B9t,opamp_no_power_right:cR,opamp_no_power_up:T9t,opamp_with_power_down:I9t,opamp_with_power_left:j9t,opamp_with_power_right:lR,opamp_with_power_up:N9t,p_channel_d_mosfet_transistor_horz:Yve,p_channel_d_mosfet_transistor_vert:L9t,p_channel_e_mosfet_transistor_horz:Kve,p_channel_e_mosfet_transistor_vert:U9t,photodiode_horz:Qve,photodiode_vert:X9t,pjfet_transistor_horz:rCe,pjfet_transistor_vert:K9t,pnp_bipolar_transistor_down:Q9t,pnp_bipolar_transistor_horz:eBt,pnp_bipolar_transistor_left:nBt,pnp_bipolar_transistor_right:iBt,pnp_bipolar_transistor_up:cBt,pnp_bipolar_transistor_vert:pBt,potentiometer_horz:sCe,potentiometer_vert:mBt,potentiometer2_down:DBt,potentiometer2_left:bBt,potentiometer2_right:dR,potentiometer2_up:FBt,potentiometer3_down:CBt,potentiometer3_left:RBt,potentiometer3_right:SBt,potentiometer3_up:TBt,power_factor_meter_horz:iCe,power_factor_meter_vert:NBt,push_button_normally_closed_momentary_horz:uCe,push_button_normally_closed_momentary_vert:LBt,push_button_normally_open_momentary_horz:cCe,push_button_normally_open_momentary_vert:UBt,rectifier_diode_horz:lCe,rectifier_diode_vert:WBt,resistor_down:ZBt,resistor_left:t7t,resistor_right:a7t,resistor_up:o7t,resonator_down:l7t,resonator_horz:pCe,resonator_left:x7t,resonator_right:fR,resonator_up:f7t,resonator_vert:h7t,schottky_diode_down:g7t,schottky_diode_left:y7t,schottky_diode_right:hR,schottky_diode_up:D7t,silicon_controlled_rectifier_horz:fCe,silicon_controlled_rectifier_vert:F7t,solderjumper2_bridged12_down:E7t,solderjumper2_bridged12_left:v7t,solderjumper2_bridged12_right:C7t,solderjumper2_bridged12_up:_7t,solderjumper2_down:A7t,solderjumper2_left:R7t,solderjumper2_right:S7t,solderjumper2_up:w7t,solderjumper3_bridged12_down:B7t,solderjumper3_bridged12_left:T7t,solderjumper3_bridged12_right:P7t,solderjumper3_bridged12_up:I7t,solderjumper3_bridged123_down:j7t,solderjumper3_bridged123_left:N7t,solderjumper3_bridged123_right:k7t,solderjumper3_bridged123_up:M7t,solderjumper3_bridged23_down:O7t,solderjumper3_bridged23_left:L7t,solderjumper3_bridged23_right:$7t,solderjumper3_bridged23_up:z7t,solderjumper3_down:q7t,solderjumper3_left:U7t,solderjumper3_right:V7t,solderjumper3_up:G7t,spdt_normally_closed_switch_down:Y7t,spdt_normally_closed_switch_left:H7t,spdt_normally_closed_switch_right:ER,spdt_normally_closed_switch_up:W7t,spdt_switch_down:J7t,spdt_switch_left:Z7t,spdt_switch_right:vR,spdt_switch_up:Q7t,spst_normally_closed_switch_down:eTt,spst_normally_closed_switch_left:tTt,spst_normally_closed_switch_right:_R,spst_normally_closed_switch_up:rTt,spst_switch_down:nTt,spst_switch_left:aTt,spst_switch_right:RR,spst_switch_up:sTt,square_wave_down:iTt,square_wave_left:oTt,square_wave_right:uTt,square_wave_up:cTt,step_recovery_diode_horz:yCe,step_recovery_diode_vert:lTt,tachometer_horz:cX,tachometer_vert:yTt,testpoint_down:DTt,testpoint_left:bTt,testpoint_right:wR,testpoint_up:FTt,tilted_ground_down:vTt,tilted_ground_left:CTt,tilted_ground_right:lX,tilted_ground_up:FCe,triac_horz:vCe,triac_vert:RTt,tunnel_diode_horz:ACe,tunnel_diode_vert:ITt,unijunction_transistor_horz:RCe,unijunction_transistor_vert:OTt,usbc:$Tt,var_meter_horz:TCe,var_meter_vert:VTt,varactor_diode_horz:PCe,varactor_diode_vert:KTt,varistor_horz:ICe,varistor_vert:QTt,varmeter_horz:EX,varmeter_vert:oPt,vcc_down:uPt,vcc_left:cPt,vcc_right:lPt,vcc_up:dPt,volt_meter_horz:NCe,volt_meter_vert:pPt,watt_hour_meter_horz:vX,watt_hour_meter_vert:bPt,wattmeter_horz:CX,wattmeter_vert:SPt,zener_diode_horz:kCe,zener_diode_vert:jPt},wtr=Object.fromEntries(Object.keys(Ts).map(n=>[n,n]))});var e1=on((Grr,m_e)=>{"use strict";m_e.exports={trueFunc:function(){return!0},falseFunc:function(){return!1}}});function Ja(n,e){return Array.isArray(e)?[n.a*e[0]+n.c*e[1]+n.e,n.b*e[0]+n.d*e[1]+n.f]:{x:n.a*e.x+n.c*e.y+n.e,y:n.b*e.x+n.d*e.y+n.f}}var ZX=Sr(()=>{"use strict"});var QX=Sr(()=>{"use strict"});var N_e=Sr(()=>{"use strict"});var k_e=Sr(()=>{"use strict"});var eY=Sr(()=>{"use strict"});function Rb(n){return typeof n>"u"}var YR=Sr(()=>{"use strict"});var M_e=Sr(()=>{"use strict";YR()});function Yi(n,e=0){return{a:1,c:0,e:n,b:0,d:1,f:e}}var rg=Sr(()=>{"use strict"});function ng(...n){n=Array.isArray(n[0])?n[0]:n;let e=(a,s)=>({a:a.a*s.a+a.c*s.b,c:a.a*s.c+a.c*s.d,e:a.a*s.e+a.c*s.f+a.e,b:a.b*s.a+a.d*s.b,d:a.b*s.c+a.d*s.d,f:a.b*s.e+a.d*s.f+a.f});switch(n.length){case 0:throw new Error("no matrices provided");case 1:return n[0];case 2:return e(n[0],n[1]);default:{let[a,s,...l]=n,d=e(a,s);return ng(d,...l)}}}function r1(...n){return ng(...n)}var n1=Sr(()=>{"use strict"});var Knr,Jnr,Znr,HR=Sr(()=>{"use strict";YR();rg();n1();({cos:Knr,sin:Jnr,PI:Znr}=Math)});function Np(n,e=void 0,a=void 0,s=void 0){Rb(e)&&(e=n);let l={a:n,c:0,e:0,b:0,d:e,f:0};return Rb(a)||Rb(s)?l:ng([Yi(a,s),l,Yi(-a,-s)])}var Sb=Sr(()=>{"use strict";YR();rg();n1()});var tY=Sr(()=>{"use strict"});var sar,rY=Sr(()=>{"use strict";({tan:sar}=Math)});var O_e=Sr(()=>{"use strict"});var nY=Sr(()=>{"use strict"});var L_e=Sr(()=>{"use strict";eY();n1();nY()});var $_e=Sr(()=>{"use strict";QX();rg();Sb();HR();rY();tY()});var z_e=Sr(()=>{"use strict"});var q_e=Sr(()=>{"use strict";z_e()});function WR(n,e=!1,a=!1){e?a?n=r1(n,Np(-1,-1)):n=r1(n,Np(1,-1)):a&&(n=r1(n,Np(-1,1)));let s=n.a,l=n.b,d=n.c,x=n.d,f,m,y;if(s!==0||d!==0){let b=Math.hypot(s,d);f=b,m=(s*x-l*d)/b;let E=Math.acos(s/b);y=d>0?-E:E}else if(l!==0||x!==0){let b=Math.hypot(l,x);f=(s*x-l*d)/b,m=b;let E=Math.acos(l/b);y=Math.PI/2+(x>0?-E:E)}else f=0,m=0,y=0;return a&&(f=-f),e&&(m=-m),{translate:{tx:n.e,ty:n.f},scale:{sx:f,sy:m},rotation:{angle:y}}}var U_e=Sr(()=>{"use strict";Sb();n1()});var V_e=Sr(()=>{"use strict"});var G_e=Sr(()=>{"use strict";rg();ZX();HR();Sb();n1()});var Ql=Sr(()=>{"use strict";ZX();QX();N_e();k_e();eY();M_e();HR();Sb();tY();rY();O_e();n1();rg();L_e();nY();$_e();q_e();U_e();V_e();G_e()});var aY=Sr(()=>{"use strict"});var W_e=on((H_e,wb)=>{"use strict";(function(){var n,e,a,s,l,d;typeof performance<"u"&&performance!==null&&performance.now?wb.exports=function(){return performance.now()}:typeof process<"u"&&process!==null&&process.hrtime?(wb.exports=function(){return(n()-l)/1e6},e=process.hrtime,n=function(){var x;return x=e(),x[0]*1e9+x[1]},s=n(),d=process.uptime()*1e9,l=s-d):Date.now?(wb.exports=function(){return Date.now()-a},a=Date.now()):(wb.exports=function(){return new Date().getTime()-a},a=new Date().getTime())}).call(H_e)});var K_e=Sr(()=>{"use strict"});var J_e=Sr(()=>{"use strict"});function oY([n,e],[a,s],{lineThickness:l=0}={}){return l===0?uY(n,e,a,s):WIt(n,e,a,s)<=l}function uY(n,e,a,s){let l=Bb(n,e,a),d=Bb(n,e,s),x=Bb(a,s,n),f=Bb(a,s,e);return!!(l!==d&&x!==f||l===0&&Tb(n,a,e)||d===0&&Tb(n,s,e)||x===0&&Tb(a,n,s)||f===0&&Tb(a,e,s))}function Bb(n,e,a){let s=(e.y-n.y)*(a.x-e.x)-(e.x-n.x)*(a.y-e.y);return s===0?0:s>0?1:2}function Tb(n,e,a){return e.x<=Math.max(n.x,a.x)&&e.x>=Math.min(n.x,a.x)&&e.y<=Math.max(n.y,a.y)&&e.y>=Math.min(n.y,a.y)}function WIt(n,e,a,s){if(n.x===e.x&&n.y===e.y)return a1(n,a,s);if(a.x===s.x&&a.y===s.y)return a1(a,n,e);if(uY(n,e,a,s))return 0;let l=[a1(n,a,s),a1(e,a,s),a1(a,n,e),a1(s,n,e)];return Math.min(...l)}function a1(n,e,a){let s=(a.x-e.x)**2+(a.y-e.y)**2;if(s===0)return iY(n,e);let l=((n.x-e.x)*(a.x-e.x)+(n.y-e.y)*(a.y-e.y))/s;l=Math.max(0,Math.min(1,l));let d={x:e.x+l*(a.x-e.x),y:e.y+l*(a.y-e.y)};return iY(n,d)}function iY(n,e){let a=n.x-e.x,s=n.y-e.y;return Math.sqrt(a*a+s*s)}var Z_e=Sr(()=>{"use strict"});var Q_e=Sr(()=>{"use strict"});var e8e=Sr(()=>{"use strict";K_e();J_e();Z_e();Q_e()});function t8e(n){let e=new Map,a=0;function s(l){for(let[,x]of e)if(x.has(l))return x;let d=new Set;return e.set(`connectivity_net${a++}`,d),d}for(let l of n){let d=null;for(let x of l){if(!d)d=s(x);else if(!d.has(x)){let f=s(x);if(f!==d){for(let m of f)d.add(m);e.delete(Array.from(e.entries()).find(([,m])=>m===f)[0])}}d.add(x)}}return Object.fromEntries(Array.from(e.entries()).map(([l,d])=>[l,Array.from(d)]))}var Pb,Ku,KR,Ko=Sr(()=>{"use strict";e8e();Pb=class{constructor(n){X(this,"netMap");X(this,"idToNetMap");this.netMap=n,this.idToNetMap={};for(let[e,a]of Object.entries(n))for(let s of a)this.idToNetMap[s]=e}addConnections(n){for(let e of n){let a=new Set;for(let l of e){let d=this.idToNetMap[l];d&&a.add(d)}let s;if(a.size===0)s=`connectivity_net${Object.keys(this.netMap).length}`,this.netMap[s]=[];else if(a.size===1)s=a.values().next().value??`connectivity_net${Object.keys(this.netMap).length}`;else{s=a.values().next().value??`connectivity_net${Object.keys(this.netMap).length}`;for(let l of a)if(l!==s){this.netMap[s].push(...this.netMap[l]),this.netMap[l]=this.netMap[s];for(let d of this.netMap[s])this.idToNetMap[d]=s}}for(let l of e)this.netMap[s].includes(l)||this.netMap[s].push(l),this.idToNetMap[l]=s}}getIdsConnectedToNet(n){return this.netMap[n]||[]}getNetConnectedToId(n){return this.idToNetMap[n]}areIdsConnected(n,e){if(n===e)return!0;let a=this.getNetConnectedToId(n);if(!a)return!1;let s=this.getNetConnectedToId(e);return s?a===s||s===n||s===n:!1}areAllIdsConnected(n){let e=this.getNetConnectedToId(n[0]);for(let a of n){let s=this.getNetConnectedToId(a);if(s===void 0||s!==e)return!1}return!0}},Ku=n=>{let e=[];for(let s of n)if(s.type==="source_trace")e.push([s.source_trace_id,...s.connected_source_port_ids??[],...s.connected_source_net_ids??[]].filter(Boolean));else if(s.type==="pcb_port"){let{pcb_port_id:l,source_port_id:d}=s;d&&l&&e.push([d,l])}else if(s.type==="pcb_smtpad"){let{pcb_smtpad_id:l,pcb_port_id:d}=s;d&&l&&e.push([l,d])}else if(s.type==="pcb_plated_hole"){let{pcb_plated_hole_id:l,pcb_port_id:d}=s;d&&l&&e.push([l,d])}else if(s.type==="pcb_trace"){let{pcb_trace_id:l,source_trace_id:d}=s,x=Array.isArray(s.route)?s.route.filter(f=>f&&f.route_type==="wire"):[];if(d&&l&&e.push([l,d]),Array.isArray(x)){let f=x.find(y=>y&&y.start_pcb_port_id)?.start_pcb_port_id,m=x.find(y=>y&&y.end_pcb_port_id)?.end_pcb_port_id;f&&l&&m&&e.push([f,l,m])}}else if(s.type==="pcb_via"){let{pcb_via_id:l,pcb_trace_id:d}=s;d&&l&&e.push([l,d])}else if(s.type==="source_component"&&s.internally_connected_source_port_ids)for(let l of s.internally_connected_source_port_ids)e.push(l);let a=t8e(e);return new Pb(a)},KR=class{constructor(n){X(this,"circuitJson");X(this,"traceIdToElm");X(this,"portIdToElm");X(this,"connMap");this.circuitJson=n||[],this.traceIdToElm=new Map,this.portIdToElm=new Map,n?(this._buildTraceMap(),this._buildPortMap(),this.connMap=this._buildTraceConnectivityMap()):this.connMap=new Pb({})}_buildPortMap(){for(let n of this.circuitJson)n.type==="pcb_port"&&this.portIdToElm.set(n.pcb_port_id,n)}_buildTraceMap(){for(let n of this.circuitJson)n.type==="pcb_trace"&&this.traceIdToElm.set(n.pcb_trace_id,n)}_buildTraceConnectivityMap(){let n=[],e=Array.from(this.traceIdToElm.keys());for(let a=0;a<e.length;a++)for(let s=a+1;s<e.length;s++){let l=this.traceIdToElm.get(e[a]),d=this.traceIdToElm.get(e[s]);this._arePcbTracesConnected(l,d)&&n.push([e[a],e[s]])}for(let a of this.portIdToElm.values())for(let s of this.traceIdToElm.values())for(let l of s.route)l.route_type==="wire"&&(l.start_pcb_port_id===a.pcb_port_id?n.push([a.pcb_port_id,s.pcb_trace_id]):l.end_pcb_port_id===a.pcb_port_id&&n.push([s.pcb_trace_id,a.pcb_port_id]));return new Pb(t8e(n))}addTrace(n){this.traceIdToElm.set(n.pcb_trace_id,n);let e=[];for(let a of n.route)a.route_type==="wire"&&(a.start_pcb_port_id&&e.push([a.start_pcb_port_id,n.pcb_trace_id]),a.end_pcb_port_id&&e.push([a.end_pcb_port_id,n.pcb_trace_id]));this.connMap.addConnections(e)}_arePcbTracesConnected(n,e){for(let a=0;a<n.route.length-1;a++){let s=n.route[a],l=n.route[a+1];if(s.route_type==="wire"&&l.route_type==="wire")for(let d=0;d<e.route.length-1;d++){let x=e.route[d],f=e.route[d+1];if(x.route_type!=="wire"||f.route_type!=="wire")continue;if(oY([s,l],[x,f],{lineThickness:(s.width+x.width)/2}))return!0}}return!1}areTracesConnected(n,e){return this.connMap.areIdsConnected(n,e)}getAllTracesConnectedToTrace(n){let e=this.connMap.getNetConnectedToId(n);return e?this.connMap.getIdsConnectedToNet(e).filter(a=>this.traceIdToElm.has(a)).map(a=>this.traceIdToElm.get(a)):[]}getAllTracesConnectedToPort(n){let e=this.connMap.getNetConnectedToId(n);return e?this.connMap.getIdsConnectedToNet(e).filter(a=>this.traceIdToElm.has(a)).map(a=>this.traceIdToElm.get(a)):[]}}});function PAe(n,e,a){if(!e||!a)return;let s=n.get(e);s||(s=new Set,n.set(e,s)),s.add(a);let l=n.get(a);l||(l=new Set,n.set(a,l)),l.add(e)}function qb(n,e){if(!e.subcircuit_id&&!e.source_group_id)return[...n];let a=new Map;for(let x of n){let f=x[`${x.type}_id`];typeof f=="string"&&a.set(f,x)}let s=new Map;for(let x of n){let f=Object.entries(x);for(let[m,y]of f)if(m!=="parent_source_group_id"){if(m.endsWith("_id")&&typeof y=="string"){let b=a.get(y);PAe(s,x,b)}else if(m.endsWith("_ids")&&Array.isArray(y)){for(let b of y)if(typeof b=="string"){let E=a.get(b);PAe(s,x,E)}}}}let l=[],d=new Set;for(let x of n)(e.subcircuit_id&&x.subcircuit_id===e.subcircuit_id||e.source_group_id&&(x.source_group_id===e.source_group_id||Array.isArray(x.member_source_group_ids)&&x.member_source_group_ids.includes(e.source_group_id)))&&(l.push(x),d.add(x));for(;l.length>0;){let x=l.shift(),f=s.get(x);if(f)for(let m of f)d.has(m)||(d.add(m),l.push(m))}return n.filter(x=>d.has(x))}function DY(n){let e=n.type;return`${e}:${n[`${e}_id`]}`}function bNt(n,e){let a=Do(n).pcb_trace.get(e);if(!a)return`trace[${e}]`;let s=a.route.flatMap(x=>[x.start_pcb_port_id,x.end_pcb_port_id]).filter(Boolean);if(s.length===0)return`trace[${e}]`;function l(x){let f=Do(n).pcb_port.get(x);if(!f)return null;let m=Do(n).pcb_component.get(f.pcb_component_id);if(!m)return null;let y=Do(n).source_component.get(m.source_component_id);if(!y)return null;let b=Do(n).source_port.get(f.source_port_id),E=b?.port_hints?b.port_hints[1]:"";return{componentName:y.name,portHint:E}}return`trace[${s.map(x=>{let f=l(x);return f?`.${f.componentName} > port.${f.portHint}`:`port[${x}]`}).join(", ")}]`}function FNt(n,e){let a=Do(n).pcb_smtpad.get(e);return!a||!a.pcb_port_id?`smtpad[${e}]`:FY(n,a.pcb_port_id)}function ENt(n){let e=0;if(n.length==0)return e;for(var a=0;a<n.length;a++){var s=n.charCodeAt(a);e=(e<<5)-e+s,e=e&e}return Math.abs(e)}function y5(n,e={}){if(n.length===0)return{width:0,height:0};let a=e.direction??"row",s=e.columnGap??0,l=e.rowGap??0;if(a==="row"||a==="row-reverse"){let f=n.reduce((y,b)=>y+b.width,0)+s*Math.max(0,n.length-1),m=n.reduce((y,b)=>Math.max(y,b.height),0);return{width:f,height:m}}else{let f=n.reduce((y,b)=>y+b.height,0)+l*Math.max(0,n.length-1);return{width:n.reduce((y,b)=>Math.max(y,b.width),0),height:f}}}var Do,ua,ka,IAe,hNt,mNt,gNt,NAe,yNt,kAe,bY,Ub,MAe,DNt,FY,Vb,OAe,jAe,vNt,CNt,LAe,h5,m5,$Ae,g5,zAe,qAe,UAe,og,na=Sr(()=>{"use strict";Yt();Yt();Ql();aY();Ql();Ql();Ql();Ql();Do=((n,e={})=>{let a=n,s=a._internal_store;if(!s){s={counts:{},editCount:0},a._internal_store=s;for(let d of a){let x=d.type,f=d[`${x}_id`];if(!f)continue;let m=Number.parseInt(f.split("_").pop());Number.isNaN(m)||(s.counts[x]=Math.max(s.counts[x]??0,m))}}return new Proxy({},{get:(d,x)=>{if(x==="toArray")return()=>(a.editCount=s.editCount,a);if(x==="editCount")return s.editCount;if(x==="subtree")return m=>Do(qb(a,m),e);let f=x;return{get:m=>a.find(y=>y.type===f&&y[`${f}_id`]===m),getUsing:m=>{let y=Object.keys(m);if(y.length!==1)throw new Error("getUsing requires exactly one key, e.g. { pcb_component_id }");let b=y[0],E=b.replace("_id",""),A=a.find(w=>w.type===E&&w[b]===m[b]);return A?a.find(w=>w.type===f&&w[`${f}_id`]===A[`${f}_id`]):null},getWhere:m=>{let y=Object.keys(m);return a.find(b=>b.type===f&&y.every(E=>b[E]===m[E]))},list:m=>{let y=m?Object.keys(m):[];return a.filter(b=>b.type===f&&y.every(E=>b[E]===m[E]))},insert:m=>{var E;(E=s.counts)[f]??(E[f]=-1),s.counts[f]++;let y=s.counts[f],b={type:f,[`${f}_id`]:`${f}_${y}`,...m};return e.validateInserts&&(Xf[f]??Gf).parse(b),a.push(b),s.editCount++,b},delete:m=>{let y=a.find(b=>b[`${f}_id`]===m);y&&(a.splice(a.indexOf(y),1),s.editCount++)},update:(m,y)=>{let b=a.find(E=>E.type===f&&E[`${f}_id`]===m);return b?(Object.assign(b,y),s.editCount++,b):null},select:m=>{if(f==="source_component")return a.find(y=>y.type==="source_component"&&y.name===m.replace(/\./g,""));if(f==="pcb_port"||f==="source_port"||f==="schematic_port"){let[y,b]=m.replace(/\./g,"").split(/[\s\>]+/),E=a.find(w=>w.type==="source_component"&&w.name===y);if(!E)return null;let A=a.find(w=>w.type==="source_port"&&w.source_component_id===E.source_component_id&&(w.name===b||(w.port_hints??[]).includes(b)));if(!A)return null;if(f==="source_port")return A;if(f==="pcb_port")return a.find(w=>w.type==="pcb_port"&&w.source_port_id===A.source_port_id);if(f==="schematic_port")return a.find(w=>w.type==="schematic_port"&&w.source_port_id===A.source_port_id)}}}}})});Do.unparsed=Do;ua=Do,ka=Do;IAe=((n,e={})=>{let a=n._internal_store_indexed;if(!a){a={counts:{},editCount:0,indexes:{}};for(let x of n){let f=x.type,m=x[`${f}_id`];if(!m)continue;let y=Number.parseInt(m.split("_").pop()||"");Number.isNaN(y)||(a.counts[f]=Math.max(a.counts[f]??0,y))}let l=e.indexConfig||{},d=a.indexes;if(l.byId&&(d.byId=new Map),l.byType&&(d.byType=new Map),l.byRelation&&(d.byRelation=new Map),l.bySubcircuit&&(d.bySubcircuit=new Map),l.byCustomField&&l.byCustomField.length>0){d.byCustomField=new Map;for(let x of l.byCustomField)d.byCustomField.set(x,new Map)}for(let x of n){if(l.byId){let f=DY(x);d.byId.set(f,x)}if(l.byType){let f=d.byType.get(x.type)||[];f.push(x),d.byType.set(x.type,f)}if(l.byRelation){let f=Object.entries(x);for(let[m,y]of f)if(m.endsWith("_id")&&m!==`${x.type}_id`&&typeof y=="string"){let b=d.byRelation.get(m)||new Map,E=b.get(y)||[];E.push(x),b.set(y,E),d.byRelation.set(m,b)}}if(l.bySubcircuit&&"subcircuit_id"in x){let f=x.subcircuit_id;if(f&&typeof f=="string"){let m=d.bySubcircuit.get(f)||[];m.push(x),d.bySubcircuit.set(f,m)}}if(l.byCustomField&&d.byCustomField){for(let f of l.byCustomField)if(f in x){let m=x[f];if(m!==void 0&&(typeof m=="string"||typeof m=="number")){let y=String(m),b=d.byCustomField.get(f),E=b.get(y)||[];E.push(x),b.set(y,E)}}}}n._internal_store_indexed=a}return new Proxy({},{get:(l,d)=>{if(d==="toArray")return()=>(n.editCount=a.editCount,n);if(d==="editCount")return a.editCount;let x=d;return{get:f=>{let m=e.indexConfig||{};return m.byId&&a.indexes.byId?a.indexes.byId.get(`${x}:${f}`)||null:m.byType&&a.indexes.byType?(a.indexes.byType.get(x)||[]).find(b=>b[`${x}_id`]===f)||null:n.find(y=>y.type===x&&y[`${x}_id`]===f)||null},getUsing:f=>{let m=e.indexConfig||{},y=Object.keys(f);if(y.length!==1)throw new Error("getUsing requires exactly one key, e.g. { pcb_component_id }");let b=y[0],E=b.replace("_id","");if(m.byRelation&&a.indexes.byRelation){let w=a.indexes.byRelation.get(b);if(w){let I=(w.get(f[b])||[]).find(G=>G.type===E);if(!I)return null;let q=I[`${x}_id`];return m.byId&&a.indexes.byId?a.indexes.byId.get(`${x}:${q}`)||null:m.byType&&a.indexes.byType?(a.indexes.byType.get(x)||[]).find(j=>j[`${x}_id`]===q)||null:n.find(G=>G.type===x&&G[`${x}_id`]===q)||null}}let A=n.find(w=>w.type===E&&w[b]===f[b]);return A&&n.find(w=>w.type===x&&w[`${x}_id`]===A[`${x}_id`])||null},getWhere:f=>{let m=e.indexConfig||{},y=Object.keys(f);if(y.length===1&&m.byCustomField&&a.indexes.byCustomField){let b=y[0],E=a.indexes.byCustomField.get(b);if(E){let A=String(f[b]);return(E.get(A)||[]).find(B=>B.type===x)||null}}if("subcircuit_id"in f&&m.bySubcircuit&&a.indexes.bySubcircuit){let b=f.subcircuit_id;return(a.indexes.bySubcircuit.get(b)||[]).find(A=>A.type===x&&y.every(w=>A[w]===f[w]))||null}return m.byType&&a.indexes.byType?(a.indexes.byType.get(x)||[]).find(E=>y.every(A=>E[A]===f[A]))||null:n.find(b=>b.type===x&&y.every(E=>b[E]===f[E]))||null},list:f=>{let m=e.indexConfig||{},y=f?Object.keys(f):[];if(y.length===0&&m.byType&&a.indexes.byType)return a.indexes.byType.get(x)||[];if(y.length===1&&y[0]==="subcircuit_id"&&m.bySubcircuit&&a.indexes.bySubcircuit){let E=f.subcircuit_id;return(a.indexes.bySubcircuit.get(E)||[]).filter(w=>w.type===x)}let b;return m.byType&&a.indexes.byType?b=a.indexes.byType.get(x)||[]:b=n.filter(E=>E.type===x),y.length>0?b.filter(E=>y.every(A=>E[A]===f[A])):b},insert:f=>{var E;(E=a.counts)[x]??(E[x]=-1),a.counts[x]++;let m=a.counts[x],y={type:x,[`${x}_id`]:`${x}_${m}`,...f};e.validateInserts&&(Xf[x]??Gf).parse(y),n.push(y),a.editCount++;let b=e.indexConfig||{};if(b.byId&&a.indexes.byId){let A=DY(y);a.indexes.byId.set(A,y)}if(b.byType&&a.indexes.byType){let A=a.indexes.byType.get(x)||[];A.push(y),a.indexes.byType.set(x,A)}if(b.byRelation&&a.indexes.byRelation){let A=Object.entries(y);for(let[w,B]of A)if(w.endsWith("_id")&&w!==`${y.type}_id`&&typeof B=="string"){let I=a.indexes.byRelation.get(w)||new Map,q=I.get(B)||[];q.push(y),I.set(B,q),a.indexes.byRelation.set(w,I)}}if(b.bySubcircuit&&a.indexes.bySubcircuit&&"subcircuit_id"in y){let A=y.subcircuit_id;if(A&&typeof A=="string"){let w=a.indexes.bySubcircuit.get(A)||[];w.push(y),a.indexes.bySubcircuit.set(A,w)}}if(b.byCustomField&&a.indexes.byCustomField){for(let A of b.byCustomField)if(A in y){let w=y[A];if(w!==void 0&&(typeof w=="string"||typeof w=="number")){let B=String(w),I=a.indexes.byCustomField.get(A),q=I.get(B)||[];q.push(y),I.set(B,q)}}}return y},delete:f=>{let m=e.indexConfig||{},y;if(m.byId&&a.indexes.byId?y=a.indexes.byId.get(`${x}:${f}`):m.byType&&a.indexes.byType?y=(a.indexes.byType.get(x)||[]).find(A=>A[`${x}_id`]===f):y=n.find(E=>E[`${x}_id`]===f),!y)return;let b=n.indexOf(y);if(b>=0&&(n.splice(b,1),a.editCount++),m.byId&&a.indexes.byId){let E=DY(y);a.indexes.byId.delete(E)}if(m.byType&&a.indexes.byType){let A=(a.indexes.byType.get(x)||[]).filter(w=>w[`${x}_id`]!==f);a.indexes.byType.set(x,A)}if(m.byRelation&&a.indexes.byRelation)for(let[E,A]of a.indexes.byRelation.entries())for(let[w,B]of A.entries()){let I=B.filter(q=>q!==y);I.length===0?A.delete(w):A.set(w,I)}if(m.bySubcircuit&&a.indexes.bySubcircuit&&"subcircuit_id"in y){let E=y.subcircuit_id;if(E){let w=(a.indexes.bySubcircuit.get(E)||[]).filter(B=>B!==y);w.length===0?a.indexes.bySubcircuit.delete(E):a.indexes.bySubcircuit.set(E,w)}}if(m.byCustomField&&a.indexes.byCustomField)for(let E of a.indexes.byCustomField.values())for(let[A,w]of E.entries()){let B=w.filter(I=>I!==y);B.length===0?E.delete(A):E.set(A,B)}},update:(f,m)=>{let y=e.indexConfig||{},b;if(y.byId&&a.indexes.byId?b=a.indexes.byId.get(`${x}:${f}`):y.byType&&a.indexes.byType?b=(a.indexes.byType.get(x)||[]).find(A=>A[`${x}_id`]===f):b=n.find(E=>E.type===x&&E[`${x}_id`]===f),!b)return null;if(y.byRelation&&a.indexes.byRelation){let E=Object.entries(b);for(let[A,w]of E)if(A.endsWith("_id")&&A!==`${b.type}_id`&&typeof w=="string"&&A in m&&m[A]!==w){let B=a.indexes.byRelation.get(A);if(B){let q=(B.get(w)||[]).filter(G=>G!==b);q.length===0?B.delete(w):B.set(w,q)}}}if(y.bySubcircuit&&a.indexes.bySubcircuit&&"subcircuit_id"in b&&"subcircuit_id"in m){let E=b.subcircuit_id,A=m.subcircuit_id;if(E!==A){let B=(a.indexes.bySubcircuit.get(E)||[]).filter(I=>I!==b);B.length===0?a.indexes.bySubcircuit.delete(E):a.indexes.bySubcircuit.set(E,B)}}if(y.byCustomField&&a.indexes.byCustomField){for(let E of y.byCustomField)if(E in b&&E in m&&b[E]!==m[E]){let A=a.indexes.byCustomField.get(E);if(A){let w=String(b[E]),I=(A.get(w)||[]).filter(q=>q!==b);I.length===0?A.delete(w):A.set(w,I)}}}if(Object.assign(b,m),a.editCount++,y.byRelation&&a.indexes.byRelation){let E=Object.entries(b);for(let[A,w]of E)if(A.endsWith("_id")&&A!==`${b.type}_id`&&typeof w=="string"&&A in m){let B=a.indexes.byRelation.get(A)||new Map,I=B.get(w)||[];I.includes(b)||(I.push(b),B.set(w,I),a.indexes.byRelation.set(A,B))}}if(y.bySubcircuit&&a.indexes.bySubcircuit&&"subcircuit_id"in b&&"subcircuit_id"in m){let E=b.subcircuit_id;if(E&&typeof E=="string"){let A=a.indexes.bySubcircuit.get(E)||[];A.includes(b)||(A.push(b),a.indexes.bySubcircuit.set(E,A))}}if(y.byCustomField&&a.indexes.byCustomField){for(let E of y.byCustomField)if(E in b&&E in m){let A=b[E];if(A!==void 0&&(typeof A=="string"||typeof A=="number")){let w=String(A),B=a.indexes.byCustomField.get(E),I=B.get(w)||[];I.includes(b)||(I.push(b),B.set(w,I))}}}return b},select:f=>{if(x==="source_component")return n.find(m=>m.type==="source_component"&&m.name===f.replace(/\./g,""))||null;if(x==="pcb_port"||x==="source_port"||x==="schematic_port"){let[m,y]=f.replace(/\./g,"").split(/[\s\>]+/),b=n.find(A=>A.type==="source_component"&&A.name===m);if(!b)return null;let E=n.find(A=>A.type==="source_port"&&A.source_component_id===b.source_component_id&&(A.name===y||(A.port_hints??[]).includes(y)));if(!E)return null;if(x==="source_port")return E;if(x==="pcb_port")return n.find(A=>A.type==="pcb_port"&&A.source_port_id===E.source_port_id)||null;if(x==="schematic_port")return n.find(A=>A.type==="schematic_port"&&A.source_port_id===E.source_port_id)||null}return null}}}})});IAe.unparsed=IAe;hNt=n=>{if(n==="up")return"right";if(n==="right")return"down";if(n==="down")return"left";if(n==="left")return"up";throw new Error(`Invalid direction: ${n}`)},mNt=n=>{if(n==="up")return"left";if(n==="left")return"down";if(n==="down")return"right";if(n==="right")return"up";throw new Error(`Invalid direction: ${n}`)},gNt=(n,e)=>{for(;e>0;)n=hNt(n),e--;for(;e<0;)n=mNt(n),e++;return n},NAe=n=>{if(n==="top"||n==="up")return"bottom";if(n==="bottom"||n==="down")return"top";if(n==="left")return"right";if(n==="right")return"left";throw new Error(`Invalid sideOrDir: ${n}`)},yNt=(n,e)=>{if(n.type==="schematic_component")n.center=Ja(e,n.center);else if(n.type==="schematic_port")n.center=Ja(e,n.center),n.facing_direction&&(n.facing_direction=gNt(n.facing_direction,-(Math.atan2(e.b,e.a)/Math.PI)*2));else if(n.type==="schematic_text")n.position=Ja(e,n.position);else if(n.type==="schematic_trace"){let a=n;a.route=(a.route??[]).map(s=>{let l=Ja(e,s);return s.x=l.x,s.y=l.y,s}),Array.isArray(a.junctions)&&(a.junctions=a.junctions.map(s=>{let l=Ja(e,s);return s.x=l.x,s.y=l.y,s})),Array.isArray(a.edges)&&(a.edges=a.edges.map(s=>(s.from=Ja(e,s.from),s.to=Ja(e,s.to),s)))}else if(n.type==="schematic_box"){let{x:a,y:s}=Ja(e,{x:n.x,y:n.y});n.x=a,n.y=s}else if(n.type==="schematic_line"){let{x:a,y:s}=Ja(e,{x:n.x1,y:n.y1}),{x:l,y:d}=Ja(e,{x:n.x2,y:n.y2});n.x1=a,n.y1=s,n.x2=l,n.y2=d}return n},kAe=(n,e)=>n.map(a=>yNt(a,e)),bY=(n,e)=>{let a=WR(e),s=Math.round(a.rotation.angle/(Math.PI/2))%2===1;if(n.type==="pcb_plated_hole"||n.type==="pcb_hole"||n.type==="pcb_via"||n.type==="pcb_smtpad"||n.type==="pcb_port"){let{x:l,y:d}=Ja(e,{x:Number(n.x),y:Number(n.y)});n.x=l,n.y=d}else if(n.type==="pcb_keepout"||n.type==="pcb_board")n.center=Ja(e,n.center);else if(n.type==="pcb_silkscreen_text"||n.type==="pcb_fabrication_note_text")n.anchor_position=Ja(e,n.anchor_position);else if(n.type==="pcb_silkscreen_circle"||n.type==="pcb_silkscreen_rect")n.center=Ja(e,n.center);else if(n.type==="pcb_component")n.center=Ja(e,n.center),n.rotation=n.rotation+a.rotation.angle/Math.PI*180,n.rotation=n.rotation%360,s&&([n.width,n.height]=[n.height,n.width]);else if(n.type==="pcb_silkscreen_path"||n.type==="pcb_trace"||n.type==="pcb_fabrication_note_path")n.route=n.route.map(l=>{let d=Ja(e,l);return l.x=d.x,l.y=d.y,l});else if(n.type==="pcb_silkscreen_line"){let l={x:n.x1,y:n.y1},d={x:n.x2,y:n.y2},x=Ja(e,l),f=Ja(e,d);n.x1=x.x,n.y1=x.y,n.x2=f.x,n.y2=f.y}else if(n.type==="cad_component"){let l=Ja(e,{x:n.position.x,y:n.position.y});n.position.x=l.x,n.position.y=l.y}return n},Ub=(n,e)=>{let a=WR(e),s=Math.round(a.rotation.angle/(Math.PI/2)),l=Math.abs(s)%2===1,d=n.map(x=>bY(x,e));return l&&(d=d.map(x=>(x.type==="pcb_smtpad"&&x.shape==="rect"&&([x.width,x.height]=[x.height,x.width]),x))),d},MAe=n=>{let e=n.type;return n[`${e}_id`]},DNt=(n,e)=>n.find(a=>MAe(a)===e)??null;FY=(n,e)=>{let a=Do(n).pcb_port.get(e);if(!a)return`pcb_port[#${e}]`;let s=Do(n).pcb_component.get(a?.pcb_component_id);if(!s)return`pcb_port[#${e}]`;let l=Do(n).source_component.get(s.source_component_id);if(!l)return`pcb_port[#${e}]`;let d=Do(n).source_port.get(a.source_port_id);if(!d)return`pcb_port[#${e}]`;let x;return d?.port_hints&&d.port_hints.length>0||d.port_hints&&d.port_hints.length>0?x=d.port_hints[0]:x=e,`pcb_port[.${l.name} > .${x}]`};Vb=(n,e)=>{if(typeof e=="string"){let a=DNt(n,e);return a||`${e}`,Vb(n,a)}switch(e.type){case"pcb_port":return FY(n,e.pcb_port_id);case"pcb_smtpad":return FNt(n,e.pcb_smtpad_id);case"pcb_trace":return bNt(n,e.pcb_trace_id);case"source_component":return`source_component[${e.name}]`;default:return`${e.type}[#${MAe(e)}]`}},OAe=n=>{let e=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY;for(let d of n){if(!d.type.startsWith("pcb_"))continue;let x,f,m,y;if("x"in d&&"y"in d&&(x=Number(d.x),f=Number(d.y)),"outer_diameter"in d&&(m=Number(d.outer_diameter),y=Number(d.outer_diameter)),"width"in d&&(m=Number(d.width)),"height"in d&&(y=Number(d.height)),"center"in d&&(x=d.center.x,f=d.center.y),x!==void 0&&f!==void 0)e=Math.min(e,x),a=Math.min(a,f),s=Math.max(s,x),l=Math.max(l,f),m!==void 0&&y!==void 0&&(e=Math.min(e,x-m/2),a=Math.min(a,f-y/2),s=Math.max(s,x+m/2),l=Math.max(l,f+y/2)),"radius"in d&&(e=Math.min(e,x-d.radius),a=Math.min(a,f-d.radius),s=Math.max(s,x+d.radius),l=Math.max(l,f+d.radius));else if(d.type==="pcb_trace")for(let b of d.route)e=Math.min(e,b.x),a=Math.min(a,b.y),s=Math.max(s,b.x),l=Math.max(l,b.y)}return{minX:e,minY:a,maxX:s,maxY:l}};jAe=[["#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"]],vNt=n=>{let{x:e,y:a,width:s,height:l}={...n,...n.size,...n.center,...n.position};if(n.x1!==void 0&&n.x2!==void 0&&n.y1!==void 0&&n.y2!==void 0&&(e=(n.x1+n.x2)/2,a=(n.y1+n.y2)/2,s=Math.abs(n.x1-n.x2),l=Math.abs(n.y1-n.y2)),n.points&&Array.isArray(n.points)&&n.points.length>0){let f=n.points.map(w=>w.x),m=n.points.map(w=>w.y),y=Math.min(...f),b=Math.max(...f),E=Math.min(...m),A=Math.max(...m);e=(y+b)/2,a=(E+A)/2,s=b-y,l=A-E}let d=n.text||n.name||n.source?.text||n.source?.name||"?",x=n;return e===void 0||a===void 0?null:(s===void 0&&"outer_diameter"in n&&(s=n.outer_diameter,l=n.outer_diameter),(s===void 0||l===void 0)&&(s=.1,l=.1),{x:e,y:a,width:s,height:l,title:d,content:x,bg_color:jAe[ENt(n.type||d)%jAe.length]?.[4]??"#f00"})},CNt=n=>!!n,LAe=n=>{let e=n.filter(y=>y.type.startsWith("pcb_")||y.type.startsWith("schematic_")).concat(n.filter(y=>y.type==="pcb_trace"||y.type==="schematic_trace").flatMap(y=>y.route)).map(y=>vNt(y)).filter(CNt);if(e.length===0)return{center:{x:0,y:0},width:0,height:0};let a=e[0].x-e[0].width/2,s=e[0].x+e[0].width/2,l=e[0].y-e[0].height/2,d=e[0].y+e[0].height/2;for(let y of e.slice(1))a=Math.min(a,y.x-y.width/2),s=Math.max(s,y.x+y.width/2),l=Math.min(l,y.y-y.height/2),d=Math.max(d,y.y+y.height/2);let x=s-a,f=d-l;return{center:{x:a+x/2,y:l+f/2},width:x,height:f}},h5=n=>n[`${n.type}_id`],m5=(n,e,a)=>{let s=n.find(b=>b.type==="pcb_component"&&b.pcb_component_id===e);if(!s)return;let l="center"in s?s.center:{x:s.x,y:s.y},d=a.x-l.x,x=a.y-l.y,f=n.filter(b=>b.type==="pcb_port"&&b.pcb_component_id===e).map(b=>b.pcb_port_id),m=n.filter(b=>{if(b===s)return!0;let E=b;return!!(E.pcb_component_id===e||Array.isArray(E.pcb_component_ids)&&E.pcb_component_ids.includes(e)||E.pcb_port_id&&f.includes(E.pcb_port_id)||Array.isArray(E.pcb_port_ids)&&E.pcb_port_ids.some(A=>f.includes(A))||E.start_pcb_port_id&&f.includes(E.start_pcb_port_id)||E.end_pcb_port_id&&f.includes(E.end_pcb_port_id)||Array.isArray(E.route)&&E.route.some(A=>A.start_pcb_port_id&&f.includes(A.start_pcb_port_id)||A.end_pcb_port_id&&f.includes(A.end_pcb_port_id)))}),y=Yi(d,x);Ub(m,y)},$Ae=(n,e)=>{let a=[],s=n.filter(l=>l.type==="source_group"&&l.parent_source_group_id===e).map(l=>l.source_group_id);a.push(...s);for(let l of s)a.push(...$Ae(n,l));return a},g5=(n,e,a)=>{let s=[e,...$Ae(n,e)],l=new Set;for(let A of s)qb(n,{source_group_id:A}).forEach(B=>l.add(B));let d=Array.from(l).filter(A=>A.type==="pcb_port").map(A=>A.pcb_port_id);n.filter(A=>{if(A.type!=="pcb_trace"||l.has(A))return!1;let w=A;return!!(w.start_pcb_port_id&&d.includes(w.start_pcb_port_id)||w.end_pcb_port_id&&d.includes(w.end_pcb_port_id)||Array.isArray(w.route)&&w.route.some(B=>B.start_pcb_port_id&&d.includes(B.start_pcb_port_id)||B.end_pcb_port_id&&d.includes(B.end_pcb_port_id)))}).forEach(A=>l.add(A));let f=Array.from(l).filter(A=>A.type.startsWith("pcb_"));if(f.length===0)return;let{center:m}=LAe(f),y=a.x-m.x,b=a.y-m.y,E=Yi(y,b);Ub(f,E)},zAe=(n,e,a)=>{let s=n.find(b=>b.type==="schematic_component"&&b.schematic_component_id===e);if(!s)return;let l="center"in s?s.center:{x:s.x,y:s.y},d=a.x-l.x,x=a.y-l.y,f=n.filter(b=>b.type==="schematic_port"&&b.schematic_component_id===e).map(b=>b.schematic_port_id),m=n.filter(b=>{if(b===s)return!0;let E=b;return!!(E.schematic_component_id===e||Array.isArray(E.schematic_component_ids)&&E.schematic_component_ids.includes(e)||E.schematic_port_id&&f.includes(E.schematic_port_id)||Array.isArray(E.schematic_port_ids)&&E.schematic_port_ids.some(A=>f.includes(A))||E.start_schematic_port_id&&f.includes(E.start_schematic_port_id)||E.end_schematic_port_id&&f.includes(E.end_schematic_port_id)||Array.isArray(E.route)&&E.route.some(A=>A.start_schematic_port_id&&f.includes(A.start_schematic_port_id)||A.end_schematic_port_id&&f.includes(A.end_schematic_port_id)))}),y=Yi(d,x);kAe(m,y)},qAe=(n,e)=>{let a=[],s=n.filter(l=>l.type==="source_group"&&l.parent_source_group_id===e).map(l=>l.source_group_id);a.push(...s);for(let l of s)a.push(...qAe(n,l));return a},UAe=(n,e,a)=>{let s=[e,...qAe(n,e)],l=new Set;for(let A of s)qb(n,{source_group_id:A}).forEach(B=>l.add(B));let d=Array.from(l).filter(A=>A.type==="schematic_port").map(A=>A.schematic_port_id);n.filter(A=>{if(A.type!=="schematic_trace"||l.has(A))return!1;let w=A;return!!(w.start_schematic_port_id&&d.includes(w.start_schematic_port_id)||w.end_schematic_port_id&&d.includes(w.end_schematic_port_id)||Array.isArray(w.route)&&w.route.some(B=>B.start_schematic_port_id&&d.includes(B.start_schematic_port_id)||B.end_schematic_port_id&&d.includes(B.end_schematic_port_id)))}).forEach(A=>l.add(A));let f=Array.from(l).filter(A=>A.type.startsWith("schematic_"));if(f.length===0)return;let{center:m}=LAe(f),y=a.x-m.x,b=a.y-m.y,E=Yi(y,b);kAe(f,E)},og=(n,e)=>{let a=new Map,s=new Set;for(let y of n)y.type==="source_group"&&s.add(y.source_group_id);let l=[];for(let y of n)if(y.type==="source_group"&&y.parent_source_group_id){let b=y.parent_source_group_id,E=y.source_group_id;if(!s.has(b))l.push(E),a.has(E)||a.set(E,[]);else{let A=a.get(b)??[];A.push(E),a.set(b,A),a.has(E)||a.set(E,[])}}for(let y of n)y.type==="source_group"&&!a.has(y.source_group_id)&&a.set(y.source_group_id,[]);let d=new Map,x=()=>{for(let[y,b]of a)if(!d.has(y)&&b.every(E=>d.has(E)))return y;return null},f=null;for(;;){let y=x();if(!y)break;let E={nodeType:"group",sourceGroup:n.find(A=>A.type==="source_group"&&A.source_group_id===y),otherChildElements:[],childNodes:[...a.get(y)?.map(A=>d.get(A))??[],...n.filter(A=>A.type==="source_component"&&A.source_group_id===y).map(A=>({nodeType:"component",sourceComponent:A,childNodes:[],otherChildElements:[...n.filter(w=>w.type==="pcb_component"&&w.source_component_id===A.source_component_id)]}))]};d.set(y,E),f=y}if(!f)return console.warn("No groups were processed, returning tree without sourceGroup"),{nodeType:"group",childNodes:[],otherChildElements:n};let m=null;return e&&e.source_group_id!==void 0?m=e.source_group_id:l.length>0?m=l[0]:m=f,m?d.get(m):(console.warn("No valid root group found, returning tree without sourceGroup"),{nodeType:"group",childNodes:[],otherChildElements:n})}});var EY=on((VAe,GAe)=>{"use strict";(function(n){var e;typeof VAe=="object"?GAe.exports=n():typeof define=="function"&&define.amd?define(n):(typeof window<"u"?e=window:typeof global<"u"?e=global:typeof self<"u"&&(e=self),e.objectHash=n())})(function(){return(function n(e,a,s){function l(f,m){if(!a[f]){if(!e[f]){var y=typeof ib=="function"&&ib;if(!m&&y)return y(f,!0);if(d)return d(f,!0);throw new Error("Cannot find module '"+f+"'")}m=a[f]={exports:{}},e[f][0].call(m.exports,function(b){var E=e[f][1][b];return l(E||b)},m,m.exports,n,e,a,s)}return a[f].exports}for(var d=typeof ib=="function"&&ib,x=0;x<s.length;x++)l(s[x]);return l})({1:[function(n,e,a){(function(s,l,d,x,f,m,y,b,E){"use strict";var A=n("crypto");function w(V,te){te=q(V,te);var N;return(N=te.algorithm!=="passthrough"?A.createHash(te.algorithm):new O).write===void 0&&(N.write=N.update,N.end=N.update),j(te,N).dispatch(V),N.update||N.end(""),N.digest?N.digest(te.encoding==="buffer"?void 0:te.encoding):(V=N.read(),te.encoding!=="buffer"?V.toString(te.encoding):V)}(a=e.exports=w).sha1=function(V){return w(V)},a.keys=function(V){return w(V,{excludeValues:!0,algorithm:"sha1",encoding:"hex"})},a.MD5=function(V){return w(V,{algorithm:"md5",encoding:"hex"})},a.keysMD5=function(V){return w(V,{algorithm:"md5",encoding:"hex",excludeValues:!0})};var B=A.getHashes?A.getHashes().slice():["sha1","md5"],I=(B.push("passthrough"),["buffer","hex","binary","base64"]);function q(V,te){var N={};if(N.algorithm=(te=te||{}).algorithm||"sha1",N.encoding=te.encoding||"hex",N.excludeValues=!!te.excludeValues,N.algorithm=N.algorithm.toLowerCase(),N.encoding=N.encoding.toLowerCase(),N.ignoreUnknown=te.ignoreUnknown===!0,N.respectType=te.respectType!==!1,N.respectFunctionNames=te.respectFunctionNames!==!1,N.respectFunctionProperties=te.respectFunctionProperties!==!1,N.unorderedArrays=te.unorderedArrays===!0,N.unorderedSets=te.unorderedSets!==!1,N.unorderedObjects=te.unorderedObjects!==!1,N.replacer=te.replacer||void 0,N.excludeKeys=te.excludeKeys||void 0,V===void 0)throw new Error("Object argument required.");for(var se=0;se<B.length;++se)B[se].toLowerCase()===N.algorithm.toLowerCase()&&(N.algorithm=B[se]);if(B.indexOf(N.algorithm)===-1)throw new Error('Algorithm "'+N.algorithm+'" not supported. supported values: '+B.join(", "));if(I.indexOf(N.encoding)===-1&&N.algorithm!=="passthrough")throw new Error('Encoding "'+N.encoding+'" not supported. supported values: '+I.join(", "));return N}function G(V){if(typeof V=="function")return/^function\s+\w*\s*\(\s*\)\s*{\s+\[native code\]\s+}$/i.exec(Function.prototype.toString.call(V))!=null}function j(V,te,N){N=N||[];function se($){return te.update?te.update($,"utf8"):te.write($,"utf8")}return{dispatch:function($){return this["_"+(($=V.replacer?V.replacer($):$)===null?"null":typeof $)]($)},_object:function($){var W,Q=Object.prototype.toString.call($),le=/\[object (.*)\]/i.exec(Q);if(le=(le=le?le[1]:"unknown:["+Q+"]").toLowerCase(),0<=(Q=N.indexOf($)))return this.dispatch("[CIRCULAR:"+Q+"]");if(N.push($),d!==void 0&&d.isBuffer&&d.isBuffer($))return se("buffer:"),se($);if(le==="object"||le==="function"||le==="asyncfunction")return Q=Object.keys($),V.unorderedObjects&&(Q=Q.sort()),V.respectType===!1||G($)||Q.splice(0,0,"prototype","__proto__","constructor"),V.excludeKeys&&(Q=Q.filter(function(z){return!V.excludeKeys(z)})),se("object:"+Q.length+":"),W=this,Q.forEach(function(z){W.dispatch(z),se(":"),V.excludeValues||W.dispatch($[z]),se(",")});if(!this["_"+le]){if(V.ignoreUnknown)return se("["+le+"]");throw new Error('Unknown object type "'+le+'"')}this["_"+le]($)},_array:function($,z){z=z!==void 0?z:V.unorderedArrays!==!1;var Q=this;if(se("array:"+$.length+":"),!z||$.length<=1)return $.forEach(function(pe){return Q.dispatch(pe)});var le=[],z=$.map(function(pe){var xe=new O,Ae=N.slice();return j(V,xe,Ae).dispatch(pe),le=le.concat(Ae.slice(N.length)),xe.read().toString()});return N=N.concat(le),z.sort(),this._array(z,!1)},_date:function($){return se("date:"+$.toJSON())},_symbol:function($){return se("symbol:"+$.toString())},_error:function($){return se("error:"+$.toString())},_boolean:function($){return se("bool:"+$.toString())},_string:function($){se("string:"+$.length+":"),se($.toString())},_function:function($){se("fn:"),G($)?this.dispatch("[native]"):this.dispatch($.toString()),V.respectFunctionNames!==!1&&this.dispatch("function-name:"+String($.name)),V.respectFunctionProperties&&this._object($)},_number:function($){return se("number:"+$.toString())},_xml:function($){return se("xml:"+$.toString())},_null:function(){return se("Null")},_undefined:function(){return se("Undefined")},_regexp:function($){return se("regex:"+$.toString())},_uint8array:function($){return se("uint8array:"),this.dispatch(Array.prototype.slice.call($))},_uint8clampedarray:function($){return se("uint8clampedarray:"),this.dispatch(Array.prototype.slice.call($))},_int8array:function($){return se("int8array:"),this.dispatch(Array.prototype.slice.call($))},_uint16array:function($){return se("uint16array:"),this.dispatch(Array.prototype.slice.call($))},_int16array:function($){return se("int16array:"),this.dispatch(Array.prototype.slice.call($))},_uint32array:function($){return se("uint32array:"),this.dispatch(Array.prototype.slice.call($))},_int32array:function($){return se("int32array:"),this.dispatch(Array.prototype.slice.call($))},_float32array:function($){return se("float32array:"),this.dispatch(Array.prototype.slice.call($))},_float64array:function($){return se("float64array:"),this.dispatch(Array.prototype.slice.call($))},_arraybuffer:function($){return se("arraybuffer:"),this.dispatch(new Uint8Array($))},_url:function($){return se("url:"+$.toString())},_map:function($){return se("map:"),$=Array.from($),this._array($,V.unorderedSets!==!1)},_set:function($){return se("set:"),$=Array.from($),this._array($,V.unorderedSets!==!1)},_file:function($){return se("file:"),this.dispatch([$.name,$.size,$.type,$.lastModfied])},_blob:function(){if(V.ignoreUnknown)return se("[blob]");throw Error(`Hashing Blob objects is currently not supported
18
18
  (see https://github.com/puleos/object-hash/issues/26)
19
19
  Use "options.replacer" or "options.ignoreUnknown"
20
20
  `)},_domwindow:function(){return se("domwindow")},_bigint:function($){return se("bigint:"+$.toString())},_process:function(){return se("process")},_timer:function(){return se("timer")},_pipe:function(){return se("pipe")},_tcp:function(){return se("tcp")},_udp:function(){return se("udp")},_tty:function(){return se("tty")},_statwatcher:function(){return se("statwatcher")},_securecontext:function(){return se("securecontext")},_connection:function(){return se("connection")},_zlib:function(){return se("zlib")},_context:function(){return se("context")},_nodescript:function(){return se("nodescript")},_httpparser:function(){return se("httpparser")},_dataview:function(){return se("dataview")},_signal:function(){return se("signal")},_fsevent:function(){return se("fsevent")},_tlswrap:function(){return se("tlswrap")}}}function O(){return{buf:"",write:function(V){this.buf+=V},end:function(V){this.buf+=V},read:function(){return this.buf}}}a.writeToStream=function(V,te,N){return N===void 0&&(N=te,te={}),j(te=q(V,te),N).dispatch(V)}}).call(this,n("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},n("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/fake_9a5aa49d.js","/")},{buffer:3,crypto:5,lYpoI2:11}],2:[function(n,e,a){(function(s,l,d,x,f,m,y,b,E){(function(A){"use strict";var w=typeof Uint8Array<"u"?Uint8Array:Array,B=43,I=47,q=48,G=97,j=65,O=45,V=95;function te(N){return N=N.charCodeAt(0),N===B||N===O?62:N===I||N===V?63:N<q?-1:N<q+10?N-q+26+26:N<j+26?N-j:N<G+26?N-G+26:void 0}A.toByteArray=function(N){var se,$;if(0<N.length%4)throw new Error("Invalid string. Length must be a multiple of 4");var W=N.length,W=N.charAt(W-2)==="="?2:N.charAt(W-1)==="="?1:0,Q=new w(3*N.length/4-W),le=0<W?N.length-4:N.length,z=0;function pe(xe){Q[z++]=xe}for(se=0;se<le;se+=4,0)pe((16711680&($=te(N.charAt(se))<<18|te(N.charAt(se+1))<<12|te(N.charAt(se+2))<<6|te(N.charAt(se+3))))>>16),pe((65280&$)>>8),pe(255&$);return W==2?pe(255&($=te(N.charAt(se))<<2|te(N.charAt(se+1))>>4)):W==1&&(pe(($=te(N.charAt(se))<<10|te(N.charAt(se+1))<<4|te(N.charAt(se+2))>>2)>>8&255),pe(255&$)),Q},A.fromByteArray=function(N){var se,$,W,Q,le=N.length%3,z="";function pe(xe){return"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(xe)}for(se=0,W=N.length-le;se<W;se+=3)$=(N[se]<<16)+(N[se+1]<<8)+N[se+2],z+=pe((Q=$)>>18&63)+pe(Q>>12&63)+pe(Q>>6&63)+pe(63&Q);switch(le){case 1:z=(z+=pe(($=N[N.length-1])>>2))+pe($<<4&63)+"==";break;case 2:z=(z=(z+=pe(($=(N[N.length-2]<<8)+N[N.length-1])>>10))+pe($>>4&63))+pe($<<2&63)+"="}return z}})(a===void 0?this.base64js={}:a)}).call(this,n("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},n("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(n,e,a){(function(s,l,B,x,f,m,y,b,E){var A=n("base64-js"),w=n("ieee754");function B(ve,je,Se){if(!(this instanceof B))return new B(ve,je,Se);var nt,Dt,vt,Wt,wr=typeof ve;if(je==="base64"&&wr=="string")for(ve=(Wt=ve).trim?Wt.trim():Wt.replace(/^\s+|\s+$/g,"");ve.length%4!=0;)ve+="=";if(wr=="number")nt=Ie(ve);else if(wr=="string")nt=B.byteLength(ve,je);else{if(wr!="object")throw new Error("First argument needs to be a number, array or string.");nt=Ie(ve.length)}if(B._useTypedArrays?Dt=B._augment(new Uint8Array(nt)):((Dt=this).length=nt,Dt._isBuffer=!0),B._useTypedArrays&&typeof ve.byteLength=="number")Dt._set(ve);else if(Le(Wt=ve)||B.isBuffer(Wt)||Wt&&typeof Wt=="object"&&typeof Wt.length=="number")for(vt=0;vt<nt;vt++)B.isBuffer(ve)?Dt[vt]=ve.readUInt8(vt):Dt[vt]=ve[vt];else if(wr=="string")Dt.write(ve,0,je);else if(wr=="number"&&!B._useTypedArrays&&!Se)for(vt=0;vt<nt;vt++)Dt[vt]=0;return Dt}function I(ve,je,Se,nt){return B._charsWritten=Qe((function(Dt){for(var vt=[],Wt=0;Wt<Dt.length;Wt++)vt.push(255&Dt.charCodeAt(Wt));return vt})(je),ve,Se,nt)}function q(ve,je,Se,nt){return B._charsWritten=Qe((function(Dt){for(var vt,Wt,wr=[],Yr=0;Yr<Dt.length;Yr++)Wt=Dt.charCodeAt(Yr),vt=Wt>>8,Wt=Wt%256,wr.push(Wt),wr.push(vt);return wr})(je),ve,Se,nt)}function G(ve,je,Se){var nt="";Se=Math.min(ve.length,Se);for(var Dt=je;Dt<Se;Dt++)nt+=String.fromCharCode(ve[Dt]);return nt}function j(ve,je,Se,vt){vt||(yt(typeof Se=="boolean","missing or invalid endian"),yt(je!=null,"missing offset"),yt(je+1<ve.length,"Trying to read beyond buffer length"));var Dt,vt=ve.length;if(!(vt<=je))return Se?(Dt=ve[je],je+1<vt&&(Dt|=ve[je+1]<<8)):(Dt=ve[je]<<8,je+1<vt&&(Dt|=ve[je+1])),Dt}function O(ve,je,Se,vt){vt||(yt(typeof Se=="boolean","missing or invalid endian"),yt(je!=null,"missing offset"),yt(je+3<ve.length,"Trying to read beyond buffer length"));var Dt,vt=ve.length;if(!(vt<=je))return Se?(je+2<vt&&(Dt=ve[je+2]<<16),je+1<vt&&(Dt|=ve[je+1]<<8),Dt|=ve[je],je+3<vt&&(Dt+=ve[je+3]<<24>>>0)):(je+1<vt&&(Dt=ve[je+1]<<16),je+2<vt&&(Dt|=ve[je+2]<<8),je+3<vt&&(Dt|=ve[je+3]),Dt+=ve[je]<<24>>>0),Dt}function V(ve,je,Se,nt){if(nt||(yt(typeof Se=="boolean","missing or invalid endian"),yt(je!=null,"missing offset"),yt(je+1<ve.length,"Trying to read beyond buffer length")),!(ve.length<=je))return nt=j(ve,je,Se,!0),32768&nt?-1*(65535-nt+1):nt}function te(ve,je,Se,nt){if(nt||(yt(typeof Se=="boolean","missing or invalid endian"),yt(je!=null,"missing offset"),yt(je+3<ve.length,"Trying to read beyond buffer length")),!(ve.length<=je))return nt=O(ve,je,Se,!0),2147483648&nt?-1*(4294967295-nt+1):nt}function N(ve,je,Se,nt){return nt||(yt(typeof Se=="boolean","missing or invalid endian"),yt(je+3<ve.length,"Trying to read beyond buffer length")),w.read(ve,je,Se,23,4)}function se(ve,je,Se,nt){return nt||(yt(typeof Se=="boolean","missing or invalid endian"),yt(je+7<ve.length,"Trying to read beyond buffer length")),w.read(ve,je,Se,52,8)}function $(ve,je,Se,nt,Dt){if(Dt||(yt(je!=null,"missing value"),yt(typeof nt=="boolean","missing or invalid endian"),yt(Se!=null,"missing offset"),yt(Se+1<ve.length,"trying to write beyond buffer length"),Pt(je,65535)),Dt=ve.length,!(Dt<=Se))for(var vt=0,Wt=Math.min(Dt-Se,2);vt<Wt;vt++)ve[Se+vt]=(je&255<<8*(nt?vt:1-vt))>>>8*(nt?vt:1-vt)}function W(ve,je,Se,nt,Dt){if(Dt||(yt(je!=null,"missing value"),yt(typeof nt=="boolean","missing or invalid endian"),yt(Se!=null,"missing offset"),yt(Se+3<ve.length,"trying to write beyond buffer length"),Pt(je,4294967295)),Dt=ve.length,!(Dt<=Se))for(var vt=0,Wt=Math.min(Dt-Se,4);vt<Wt;vt++)ve[Se+vt]=je>>>8*(nt?vt:3-vt)&255}function Q(ve,je,Se,nt,Dt){Dt||(yt(je!=null,"missing value"),yt(typeof nt=="boolean","missing or invalid endian"),yt(Se!=null,"missing offset"),yt(Se+1<ve.length,"Trying to write beyond buffer length"),Ht(je,32767,-32768)),ve.length<=Se||$(ve,0<=je?je:65535+je+1,Se,nt,Dt)}function le(ve,je,Se,nt,Dt){Dt||(yt(je!=null,"missing value"),yt(typeof nt=="boolean","missing or invalid endian"),yt(Se!=null,"missing offset"),yt(Se+3<ve.length,"Trying to write beyond buffer length"),Ht(je,2147483647,-2147483648)),ve.length<=Se||W(ve,0<=je?je:4294967295+je+1,Se,nt,Dt)}function z(ve,je,Se,nt,Dt){Dt||(yt(je!=null,"missing value"),yt(typeof nt=="boolean","missing or invalid endian"),yt(Se!=null,"missing offset"),yt(Se+3<ve.length,"Trying to write beyond buffer length"),ar(je,34028234663852886e22,-34028234663852886e22)),ve.length<=Se||w.write(ve,je,Se,nt,23,4)}function pe(ve,je,Se,nt,Dt){Dt||(yt(je!=null,"missing value"),yt(typeof nt=="boolean","missing or invalid endian"),yt(Se!=null,"missing offset"),yt(Se+7<ve.length,"Trying to write beyond buffer length"),ar(je,17976931348623157e292,-17976931348623157e292)),ve.length<=Se||w.write(ve,je,Se,nt,52,8)}a.Buffer=B,a.SlowBuffer=B,a.INSPECT_MAX_BYTES=50,B.poolSize=8192,B._useTypedArrays=(function(){try{var ve=new ArrayBuffer(0),je=new Uint8Array(ve);return je.foo=function(){return 42},je.foo()===42&&typeof je.subarray=="function"}catch{return!1}})(),B.isEncoding=function(ve){switch(String(ve).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}},B.isBuffer=function(ve){return!(ve==null||!ve._isBuffer)},B.byteLength=function(ve,je){var Se;switch(ve+="",je||"utf8"){case"hex":Se=ve.length/2;break;case"utf8":case"utf-8":Se=rt(ve).length;break;case"ascii":case"binary":case"raw":Se=ve.length;break;case"base64":Se=et(ve).length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":Se=2*ve.length;break;default:throw new Error("Unknown encoding")}return Se},B.concat=function(ve,je){if(yt(Le(ve),`Usage: Buffer.concat(list, [totalLength])
@@ -1074,8 +1074,8 @@ You passed in: '`+this.raw_options[d]+"'");return m},a.prototype._is_valid_selec
1074
1074
  `).replace(/(\s*<!--)/g,`
1075
1075
  $1`).replace(/>(\s*)(?=<!--\s*\/)/g,"> ")}}}),sd=class{constructor(){X(this,"MAX_ITERATIONS",1e5);X(this,"solved",!1);X(this,"failed",!1);X(this,"iterations",0);X(this,"progress",0);X(this,"error",null);X(this,"activeSubSolver");X(this,"failedSubSolvers");X(this,"timeToSolve");X(this,"stats",{})}step(){if(!this.solved&&!this.failed){this.iterations++;try{this._step()}catch(n){throw this.error=`${this.constructor.name} error: ${n}`,this.failed=!0,n}!this.solved&&this.iterations>this.MAX_ITERATIONS&&this.tryFinalAcceptance(),!this.solved&&this.iterations>this.MAX_ITERATIONS&&(this.error=`${this.constructor.name} ran out of iterations`,this.failed=!0),"computeProgress"in this&&(this.progress=this.computeProgress())}}_step(){}getConstructorParams(){throw new Error("getConstructorParams not implemented")}solve(){let n=Date.now();for(;!this.solved&&!this.failed;)this.step();let e=Date.now();this.timeToSolve=e-n}visualize(){return{lines:[],points:[],rects:[],circles:[]}}tryFinalAcceptance(){}preview(){return{lines:[],points:[],rects:[],circles:[]}}},P5e=class{constructor(n){X(this,"netMap");X(this,"idToNetMap");this.netMap=n,this.idToNetMap={};for(let[e,a]of Object.entries(n))for(let s of a)this.idToNetMap[s]=e}addConnections(n){for(let e of n){let a=new Set;for(let l of e){let d=this.idToNetMap[l];d&&a.add(d)}let s;if(a.size===0)s=`connectivity_net${Object.keys(this.netMap).length}`,this.netMap[s]=[];else if(a.size===1)s=a.values().next().value??`connectivity_net${Object.keys(this.netMap).length}`;else{s=a.values().next().value??`connectivity_net${Object.keys(this.netMap).length}`;for(let l of a)if(l!==s){let d=this.netMap[s],x=this.netMap[l];if(d&&x){d.push(...x),this.netMap[l]=d;for(let f of d)this.idToNetMap[f]=s}}}for(let l of e){let d=this.netMap[s];d&&!d.includes(l)&&d.push(l),this.idToNetMap[l]=s}}}getIdsConnectedToNet(n){return this.netMap[n]||[]}getNetConnectedToId(n){return this.idToNetMap[n]}areIdsConnected(n,e){if(n===e)return!0;let a=this.getNetConnectedToId(n);if(!a)return!1;let s=this.getNetConnectedToId(e);return s?a===s||s===n||s===n:!1}areAllIdsConnected(n){if(n.length===0)return!0;let e=this.getNetConnectedToId(n[0]);if(!e)return!1;for(let a of n){let s=this.getNetConnectedToId(a);if(s===void 0||s!==e)return!1}return!0}},Z5e=n=>{let e=new P5e({});for(let s of n.directConnections)e.addConnections([s.netId?[s.netId,...s.pinIds]:s.pinIds]);let a=new P5e(e.netMap);for(let s of n.netConnections)a.addConnections([[s.netId,...s.pinIds]]);return{directConnMap:e,netConnMap:a}};function Iqt(n,e={}){let a=n.length,s=e?.maxDistance??Number.POSITIVE_INFINITY;if(a<=1)return[];{let b=new Set;for(let E of n){if(b.has(E.pinId))throw new Error(`Duplicate pinId detected: "${E.pinId}"`);b.add(E.pinId)}}let l=(b,E)=>Math.abs(b.x-E.x)+Math.abs(b.y-E.y),d=new Array(a).fill(!1),x=new Array(a).fill(Number.POSITIVE_INFINITY),f=new Array(a).fill(-1),m=0;for(let b=1;b<a;b++)n[b].pinId<n[m].pinId&&(m=b);x[m]=0;let y=[];for(let b=0;b<a;b++){let E=-1,A=Number.POSITIVE_INFINITY,w="";for(let B=0;B<a;B++)if(!d[B]){let I=x[B];(I<A||I===A&&(w===""||n[B].pinId<w))&&(A=I,w=n[B].pinId,E=B)}d[E]=!0,f[E]!==-1&&y.push([n[E].pinId,n[f[E]].pinId]);for(let B=0;B<a;B++)if(!d[B]){let I=l(n[E],n[B]),q=I>s?Number.POSITIVE_INFINITY:I;(q<x[B]||q===x[B]&&n[E].pinId<n[f[B]]?.pinId)&&(x[B]=q,f[B]=E)}}return y}var Lc=(n,e=1)=>`hsl(${n.split("").reduce((s,l)=>s*31+l.charCodeAt(0),0)%360}, 100%, 50%, ${e})`,Q5e=(n,e)=>{let{x:a,y:s}=n,{center:l,width:d,height:x}=e,f=l.y+x/2,m=l.y-x/2,y=l.x+d/2,b=l.x-d/2,E=f-s,A=s-m,w=y-a,B=a-b,I=Math.min(E,A,w,B);return I===E?"y+":I===A?"y-":I===w?"x+":"x-"},Qp=(n,e={})=>{let{connectionAlpha:a=.8,chipAlpha:s=.8}=e,l={lines:[],points:[],rects:[]},d=new Map;for(let x of n.chips)for(let f of x.pins)d.set(f.pinId,f);for(let x of n.chips){l.rects.push({label:x.chipId,center:x.center,width:x.width,height:x.height,fill:Lc(x.chipId,s)});for(let f of x.pins)l.points.push({label:`${f.pinId}
1076
1076
  ${f._facingDirection??Q5e(f,x)}`,x:f.x,y:f.y,color:Lc(f.pinId,.8)})}for(let x of n.directConnections){let[f,m]=x.pinIds,y=d.get(f),b=d.get(m);l.lines.push({points:[{x:y.x,y:y.y},{x:b.x,y:b.y}],strokeColor:Lc(x.netId??`${f}-${m}`,a)})}for(let x of n.netConnections){let f=x.pinIds.map(m=>d.get(m));for(let m=0;m<f.length-1;m++)for(let y=m+1;y<f.length;y++){let b=f[m],E=f[y];l.lines.push({points:[{x:b.x,y:b.y},{x:E.x,y:E.y}],strokeColor:Lc(x.netId,a),strokeDash:"4 2"})}}return l},jqt=class extends sd{constructor({inputProblem:e}){super();X(this,"inputProblem");X(this,"mspConnectionPairs",[]);X(this,"dcConnMap");X(this,"globalConnMap");X(this,"queuedDcNetIds");X(this,"chipMap");X(this,"maxMspPairDistance");X(this,"pinMap");X(this,"userNetIdByPinId");this.inputProblem=e,this.maxMspPairDistance=e.maxMspPairDistance??1;let{directConnMap:a,netConnMap:s}=Z5e(e);this.dcConnMap=a,this.globalConnMap=s,this.pinMap={};for(let l of e.chips)for(let d of l.pins)this.pinMap[d.pinId]={...d,chipId:l.chipId};this.chipMap={};for(let l of e.chips)this.chipMap[l.chipId]=l;this.userNetIdByPinId={};for(let l of e.directConnections)if(l.netId){let[d,x]=l.pinIds;this.userNetIdByPinId[d]=l.netId,this.userNetIdByPinId[x]=l.netId}for(let l of e.netConnections)for(let d of l.pinIds)this.userNetIdByPinId[d]=l.netId;this.queuedDcNetIds=Object.keys(s.netMap)}getConstructorParams(){return{inputProblem:this.inputProblem}}_step(){if(this.queuedDcNetIds.length===0){this.solved=!0;return}let e=this.queuedDcNetIds.shift(),s=this.globalConnMap.getIdsConnectedToNet(e).filter(d=>!!this.pinMap[d]);if(s.length<=1)return;if(s.length===2){let[d,x]=s,f=this.pinMap[d],m=this.pinMap[x];if(Math.abs(f.x-m.x)+Math.abs(f.y-m.y)>this.maxMspPairDistance)return;let b=this.globalConnMap.getNetConnectedToId(d),E=this.userNetIdByPinId[d]??this.userNetIdByPinId[x];this.mspConnectionPairs.push({mspPairId:`${d}-${x}`,dcConnNetId:e,globalConnNetId:b,userNetId:E,pins:[f,m]});return}let l=Iqt(s.map(d=>this.pinMap[d]).filter(Boolean),{maxDistance:this.maxMspPairDistance});for(let[d,x]of l){let f=this.globalConnMap.getNetConnectedToId(d),m=this.userNetIdByPinId[d]??this.userNetIdByPinId[x];this.mspConnectionPairs.push({mspPairId:`${d}-${x}`,dcConnNetId:e,globalConnNetId:f,userNetId:m,pins:[this.pinMap[d],this.pinMap[x]]})}}visualize(){let e=Qp(this.inputProblem,{chipAlpha:.1,connectionAlpha:.1});for(let a of this.mspConnectionPairs)e.lines.push({points:[{x:a.pins[0].x,y:a.pins[0].y},{x:a.pins[1].x,y:a.pins[1].y}],strokeColor:Lc(a.mspPairId,.75)});return e}},Nqt=.6,kqt=1,{cos:fpr,sin:hpr,PI:mpr}=Math,{tan:gpr}=Math,ypr=cW(mqt()),Dpr=cW(yqt()),bpr=cW(Pqt(),1);function fW(n){let e=[...n.points||[],...(n.lines||[]).flatMap(a=>a.points),...(n.rects||[]).flatMap(a=>{let s=a.width/2,l=a.height/2;return[{x:a.center.x-s,y:a.center.y-l},{x:a.center.x+s,y:a.center.y-l},{x:a.center.x-s,y:a.center.y+l},{x:a.center.x+s,y:a.center.y+l}]}),...(n.circles||[]).flatMap(a=>[{x:a.center.x-a.radius,y:a.center.y},{x:a.center.x+a.radius,y:a.center.y},{x:a.center.x,y:a.center.y-a.radius},{x:a.center.x,y:a.center.y+a.radius}]),...(n.texts||[]).flatMap(a=>{let s=a.fontSize??12,l=a.text.length*s*Nqt,d=s*kqt,x=a.anchorSide??"center",f={top_left:{dx:0,dy:0},top_center:{dx:-l/2,dy:0},top_right:{dx:-l,dy:0},center_left:{dx:0,dy:-d/2},center:{dx:-l/2,dy:-d/2},center_right:{dx:-l,dy:-d/2},bottom_left:{dx:0,dy:-d},bottom_center:{dx:-l/2,dy:-d},bottom_right:{dx:-l,dy:-d}},{dx:m,dy:y}=f[x],b=a.x+m,E=a.y+y;return[{x:b,y:E},{x:b+l,y:E+d}]})];return e.length===0?{minX:-1,maxX:1,minY:-1,maxY:1}:e.reduce((a,s)=>({minX:Math.min(a.minX,s.x),maxX:Math.max(a.maxX,s.x),minY:Math.min(a.minY,s.y),maxY:Math.max(a.maxY,s.y)}),{minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0})}var Mqt=class{constructor(){this.ids=[],this.values=[],this.length=0}clear(){this.length=0}push(n,e){let a=this.length++;for(;a>0;){let s=a-1>>1,l=this.values[s];if(e>=l)break;this.ids[a]=this.ids[s],this.values[a]=l,a=s}this.ids[a]=n,this.values[a]=e}pop(){if(this.length===0)return;let n=this.ids,e=this.values,a=n[0],s=--this.length;if(s>0){let l=n[s],d=e[s],x=0,f=s>>1;for(;x<f;){let m=(x<<1)+1,y=m+1,b=m+(+(y<s)&+(e[y]<e[m]));if(e[b]>=d)break;n[x]=n[b],e[x]=e[b],x=b}n[x]=l,e[x]=d}return a}peek(){return this.length>0?this.ids[0]:void 0}peekValue(){return this.length>0?this.values[0]:void 0}shrink(){this.ids.length=this.values.length=this.length}},I5e=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],oW=3,Oqt=class eSe{static from(e,a=0){if(a%8!==0)throw new Error("byteOffset must be 8-byte aligned.");if(!e||e.byteLength===void 0||e.buffer)throw new Error("Data must be an instance of ArrayBuffer or SharedArrayBuffer.");let[s,l]=new Uint8Array(e,a+0,2);if(s!==251)throw new Error("Data does not appear to be in a Flatbush format.");let d=l>>4;if(d!==oW)throw new Error(`Got v${d} data when expected v${oW}.`);let x=I5e[l&15];if(!x)throw new Error("Unrecognized array type.");let[f]=new Uint16Array(e,a+2,1),[m]=new Uint32Array(e,a+4,1);return new eSe(m,f,x,void 0,e,a)}constructor(e,a=16,s=Float64Array,l=ArrayBuffer,d,x=0){if(e===void 0)throw new Error("Missing required argument: numItems.");if(isNaN(e)||e<=0)throw new Error(`Unexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+a,2),65535),this.byteOffset=x;let f=e,m=f;this._levelBounds=[f*4];do f=Math.ceil(f/this.nodeSize),m+=f,this._levelBounds.push(m*4);while(f!==1);this.ArrayType=s,this.IndexArrayType=m<16384?Uint16Array:Uint32Array;let y=I5e.indexOf(s),b=m*4*s.BYTES_PER_ELEMENT;if(y<0)throw new Error(`Unexpected typed array class: ${s}.`);if(d)this.data=d,this._boxes=new s(d,x+8,m*4),this._indices=new this.IndexArrayType(d,x+8+b,m),this._pos=m*4,this.minX=this._boxes[this._pos-4],this.minY=this._boxes[this._pos-3],this.maxX=this._boxes[this._pos-2],this.maxY=this._boxes[this._pos-1];else{let E=this.data=new l(8+b+m*this.IndexArrayType.BYTES_PER_ELEMENT);this._boxes=new s(E,8,m*4),this._indices=new this.IndexArrayType(E,8+b,m),this._pos=0,this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,new Uint8Array(E,0,2).set([251,(oW<<4)+y]),new Uint16Array(E,2,1)[0]=a,new Uint32Array(E,4,1)[0]=e}this._queue=new Mqt}add(e,a,s=e,l=a){let d=this._pos>>2,x=this._boxes;return this._indices[d]=d,x[this._pos++]=e,x[this._pos++]=a,x[this._pos++]=s,x[this._pos++]=l,e<this.minX&&(this.minX=e),a<this.minY&&(this.minY=a),s>this.maxX&&(this.maxX=s),l>this.maxY&&(this.maxY=l),d}finish(){if(this._pos>>2!==this.numItems)throw new Error(`Added ${this._pos>>2} items when expected ${this.numItems}.`);let e=this._boxes;if(this.numItems<=this.nodeSize){e[this._pos++]=this.minX,e[this._pos++]=this.minY,e[this._pos++]=this.maxX,e[this._pos++]=this.maxY;return}let a=this.maxX-this.minX||1,s=this.maxY-this.minY||1,l=new Uint32Array(this.numItems),d=65535;for(let x=0,f=0;x<this.numItems;x++){let m=e[f++],y=e[f++],b=e[f++],E=e[f++],A=Math.floor(d*((m+b)/2-this.minX)/a),w=Math.floor(d*((y+E)/2-this.minY)/s);l[x]=$qt(A,w)}uW(l,e,this._indices,0,this.numItems-1,this.nodeSize);for(let x=0,f=0;x<this._levelBounds.length-1;x++){let m=this._levelBounds[x];for(;f<m;){let y=f,b=e[f++],E=e[f++],A=e[f++],w=e[f++];for(let B=1;B<this.nodeSize&&f<m;B++)b=Math.min(b,e[f++]),E=Math.min(E,e[f++]),A=Math.max(A,e[f++]),w=Math.max(w,e[f++]);this._indices[this._pos>>2]=y,e[this._pos++]=b,e[this._pos++]=E,e[this._pos++]=A,e[this._pos++]=w}}}search(e,a,s,l,d){if(this._pos!==this._boxes.length)throw new Error("Data not yet indexed - call index.finish().");let x=this._boxes.length-4,f=[],m=[];for(;x!==void 0;){let y=Math.min(x+this.nodeSize*4,j5e(x,this._levelBounds));for(let b=x;b<y;b+=4){let E=this._boxes[b];if(s<E)continue;let A=this._boxes[b+1];if(l<A)continue;let w=this._boxes[b+2];if(e>w)continue;let B=this._boxes[b+3];if(a>B)continue;let I=this._indices[b>>2]|0;x>=this.numItems*4?f.push(I):(d===void 0||d(I,E,A,w,B))&&m.push(I)}x=f.pop()}return m}neighbors(e,a,s=1/0,l=1/0,d){if(this._pos!==this._boxes.length)throw new Error("Data not yet indexed - call index.finish().");let x=this._boxes.length-4,f=this._queue,m=[],y=l*l;e:for(;x!==void 0;){let b=Math.min(x+this.nodeSize*4,j5e(x,this._levelBounds));for(let E=x;E<b;E+=4){let A=this._indices[E>>2]|0,w=this._boxes[E],B=this._boxes[E+1],I=this._boxes[E+2],q=this._boxes[E+3],G=e<w?w-e:e>I?e-I:0,j=a<B?B-a:a>q?a-q:0,O=G*G+j*j;O>y||(x>=this.numItems*4?f.push(A<<1,O):(d===void 0||d(A))&&f.push((A<<1)+1,O))}for(;f.length&&f.peek()&1;)if(f.peekValue()>y||(m.push(f.pop()>>1),m.length===s))break e;x=f.length?f.pop()>>1:void 0}return f.clear(),m}};function j5e(n,e){let a=0,s=e.length-1;for(;a<s;){let l=a+s>>1;e[l]>n?s=l:a=l+1}return e[a]}function uW(n,e,a,s,l,d){if(Math.floor(s/d)>=Math.floor(l/d))return;let x=n[s],f=n[s+l>>1],m=n[l],y=m,b=Math.max(x,f);m>b?y=b:b===x?y=Math.max(f,m):b===f&&(y=Math.max(x,m));let E=s-1,A=l+1;for(;;){do E++;while(n[E]<y);do A--;while(n[A]>y);if(E>=A)break;Lqt(n,e,a,E,A)}uW(n,e,a,s,A,d),uW(n,e,a,A+1,l,d)}function Lqt(n,e,a,s,l){let d=n[s];n[s]=n[l],n[l]=d;let x=4*s,f=4*l,m=e[x],y=e[x+1],b=e[x+2],E=e[x+3];e[x]=e[f],e[x+1]=e[f+1],e[x+2]=e[f+2],e[x+3]=e[f+3],e[f]=m,e[f+1]=y,e[f+2]=b,e[f+3]=E;let A=a[s];a[s]=a[l],a[l]=A}function $qt(n,e){let a=n^e,s=65535^a,l=65535^(n|e),d=n&(e^65535),x=a|s>>1,f=a>>1^a,m=l>>1^s&d>>1^l,y=a&l>>1^d>>1^d;a=x,s=f,l=m,d=y,x=a&a>>2^s&s>>2,f=a&s>>2^s&(a^s)>>2,m^=a&l>>2^s&d>>2,y^=s&l>>2^(a^s)&d>>2,a=x,s=f,l=m,d=y,x=a&a>>4^s&s>>4,f=a&s>>4^s&(a^s)>>4,m^=a&l>>4^s&d>>4,y^=s&l>>4^(a^s)&d>>4,a=x,s=f,l=m,d=y,m^=a&l>>8^s&d>>8,y^=s&l>>8^(a^s)&d>>8,a=m^m>>1,s=y^y>>1;let b=n^e,E=s|65535^(b|a);return b=(b|b<<8)&16711935,b=(b|b<<4)&252645135,b=(b|b<<2)&858993459,b=(b|b<<1)&1431655765,E=(E|E<<8)&16711935,E=(E|E<<4)&252645135,E=(E|E<<2)&858993459,E=(E|E<<1)&1431655765,(E<<1|b)>>>0}function C1(n){let e=n.width/2,a=n.height/2;return{minX:n.center.x-e,maxX:n.center.x+e,minY:n.center.y-a,maxY:n.center.y+a}}var tSe=class{constructor(n){X(this,"chips");X(this,"spatialIndex");X(this,"spatialIndexIdToChip");this.chips=n.map(e=>({...e,bounds:C1(e),spatialIndexId:null})),this.spatialIndexIdToChip=new Map,this.spatialIndex=new Oqt(n.length);for(let e of this.chips)e.spatialIndexId=this.spatialIndex.add(e.bounds.minX,e.bounds.minY,e.bounds.maxX,e.bounds.maxY),this.spatialIndexIdToChip.set(e.spatialIndexId,e);this.spatialIndex.finish()}getChipsInBounds(n){return this.spatialIndex.search(n.minX,n.minY,n.maxX,n.maxY).map(a=>this.spatialIndexIdToChip.get(a))}doesOrthogonalLineIntersectChip(n,e={}){let a=e.excludeChipIds??[],[s,l]=n,{x:d,y:x}=s,{x:f,y:m}=l;return this.getChipsInBounds({minX:Math.min(d,f),minY:Math.min(x,m),maxX:Math.max(d,f),maxY:Math.max(x,m)}).filter(b=>!a.includes(b.chipId)).length>0}},zqt=(n,e,a)=>{let s=[{x:n.x,y:n.y}],l=(n.x+e.x)/2,d=(n.y+e.y)/2,x={x:e.x,y:e.y};switch(e.facingDirection){case"x+":x.x+=a;break;case"x-":x.x-=a;break;case"y+":x.y+=a;break;case"y-":x.y-=a;break}let f=n.facingDirection??"none",m=e.facingDirection??"none",y=A=>{let w=s[s.length-1];(w.x!==A.x||w.y!==A.y)&&s.push(A)},b=Math.abs(n.y-e.y)<=Math.max(1e-6,a*.1),E=Math.abs(n.x-e.x)<=Math.max(1e-6,a*.1);if(f==="none"&&m==="none")y({x:l,y:n.y}),y({x:l,y:e.y});else if(f==="x+"&&m==="y+")n.x>e.x&&n.y<e.y?(y({x:n.x+a,y:n.y}),y({x:n.x+a,y:e.y+a}),y({x:e.x,y:e.y+a})):n.x<e.x&&n.y>e.y?y({x:e.x,y:n.y}):E?(y({x:n.x+a,y:n.y}),y({x:n.x+a,y:e.y+a}),y({x:e.x,y:e.y+a})):n.x<e.x?(y({x:l,y:n.y}),y({x:l,y:x.y}),y({x:e.x,y:x.y})):n.y<=e.y+a?(y({x:n.x+a,y:n.y}),y({x:n.x+a,y:n.y+a}),y({x:e.x,y:n.y+a}),y({x:e.x,y:e.y})):(y({x:n.x+a,y:n.y}),y({x:n.x+a,y:(n.y+e.y)/2}),y({x:e.x,y:(n.y+e.y)/2}));else if(f==="x+"&&m==="x+"&&!b){let A=Math.max(n.x+a,x.x);y({x:A,y:n.y}),y({x:A,y:e.y})}else if(f==="x+"&&m==="x+"&&b)y({x:n.x+a,y:n.y}),y({x:n.x+a,y:n.y+a}),y({x:e.x+a,y:n.y+a}),y({x:e.x+a,y:e.y});else if(f==="x+"&&m==="y-")if(E&&n.y<=e.y)y({x:n.x+a,y:n.y}),y({x:n.x+a,y:d}),y({x:e.x,y:d});else if(E&&n.y>e.y)y({x:n.x+a,y:n.y}),y({x:n.x+a,y:e.y-a}),y({x:e.x,y:e.y-a});else if(n.x<e.x&&n.y<e.y)y({x:e.x,y:n.y});else if(n.x>e.x&&n.y<e.y){let A=n.x+a;y({x:A,y:n.y}),y({x:A,y:d}),y({x:e.x,y:d})}else if(n.x>e.x&&n.y>e.y){let A=n.x+a;y({x:A,y:n.y}),y({x:A,y:x.y}),y({x:e.x,y:x.y})}else n.y===e.y?(y({x:n.x+a,y:n.y}),y({x:n.x+a,y:n.y-a}),y({x:e.x,y:n.y-a})):(y({x:l,y:n.y}),y({x:l,y:x.y}),y({x:e.x,y:x.y}));else if(f==="x+"&&m==="x-"&&n.x+a>=e.x-a&&e.y!==n.y){let A=n.x+a;y({x:A,y:n.y}),y({x:A,y:d}),y({x:x.x,y:d}),y({x:x.x,y:x.y})}else f==="x+"&&m==="x-"&&e.y===n.y&&e.x>n.x||(f==="x+"&&m==="x-"&&e.y===n.y?(y({x:n.x+a,y:n.y}),y({x:n.x+a,y:n.y+a}),y({x:e.x-a,y:n.y+a}),y({x:e.x-a,y:n.y})):(f==="x+"&&y({x:n.x+a,y:n.y}),y({x:l,y:s[s.length-1].y}),y({x:l,y:x.y}),y({x:x.x,y:x.y})));return y({x:e.x,y:e.y}),s},qqt=(n,e,a={})=>{let s=n,l=e,d=!1;(s.x>l.x||s.x===l.x&&s.y>l.y)&&(d=!0,[s,l]=[l,s]);let x=s.facingDirection==="x-",f=s.facingDirection==="y-",m=j=>{let O=x?s.x-(j.x-s.x):j.x,V=f?s.y-(j.y-s.y):j.y,te=j.facingDirection;return x&&(te==="x+"?te="x-":te==="x-"&&(te="x+")),f&&(te==="y+"?te="y-":te==="y-"&&(te="y+")),{x:O,y:V,facingDirection:te}},y=(j,O)=>{let V=j.x-O.x,te=j.y-O.y,N=O.x+te,se=O.y-V,$=j.facingDirection;switch($){case"x+":$="y-";break;case"y-":$="x-";break;case"x-":$="y+";break;case"y+":$="x+";break}return{x:N,y:se,facingDirection:$}},b=(j,O)=>{let V=j.x-O.x,te=j.y-O.y;return{x:O.x-te,y:O.y+V}},E=x||f?m(s):s,A=x||f?m(l):l,w=E,B=A,I=!1;E.facingDirection==="y+"&&(I=!0,w={...E,facingDirection:"x+"},B=y(A,E));let q=a?.overshoot??.1*Math.max(Math.abs(w.x-B.x),Math.abs(w.y-B.y)),G=zqt(w,B,q);return I&&(G=G.map(j=>b(j,w))),(x||f)&&(G=G.map(({x:j,y:O})=>({x:x?s.x-(j-s.x):j,y:f?s.y-(O-s.y):O}))),d?G.reverse():G},Uqt=n=>{switch(n){case"x+":return{x:1,y:0};case"x-":return{x:-1,y:0};case"y+":return{x:0,y:1};case"y-":return{x:0,y:-1}}throw new Error(`Invalid facing direction: ${n}`)},v1=1e-6,Sg=1e-6,Vqt=(n,e)=>Math.abs(n.x-e.x)<v1||Math.abs(n.y-e.y)<v1,Gqt=(n,e)=>{let a=Math.abs(n.x-e.x),s=Math.abs(n.y-e.y);if(a<v1&&s>=v1)return"vertical";if(s<v1&&a>=v1)return"horizontal";throw new Error("Non-orthogonal or degenerate segment detected.")},N5e=n=>{if(n.length<2)throw new Error("Polyline must have at least two points.");for(let e=0;e<n.length-1;e++){let a=n[e],s=n[e+1];if(!Vqt(a,s))throw new Error("Polyline contains a non-orthogonal segment.");if(Math.abs(a.x-s.x)+Math.abs(a.y-s.y)<Sg)throw new Error("Polyline contains a near-zero length segment.")}},Xqt=(n,e=v1)=>{let a=n.slice().sort((l,d)=>l-d),s=[];for(let l of a)(s.length===0||Math.abs(l-s[s.length-1])>e)&&s.push(l);return s},k5e=(n,e=9)=>n.map(a=>`${a.x.toFixed(e)},${a.y.toFixed(e)}`).join("|"),Yqt=(n,e=Sg)=>{if(n.length===0)return[];let a=[{...n[0]}];for(let s=1;s<n.length;s++){let l=n[s],d=a[a.length-1];Math.abs(l.x-d.x)+Math.abs(l.y-d.y)>e&&a.push({...l})}return a},Hqt=(n,e,a)=>{let s=[];for(let l of e)n==="x"?l.orientation==="vertical"&&typeof l.x=="number"&&s.push(l.x):l.orientation==="horizontal"&&typeof l.y=="number"&&s.push(l.y);return s.push(a),Xqt(s)},Wqt=(n,e,a)=>Gqt(e,a)==="horizontal"?{axis:"y",facing:n.y<=e.y?"y+":"y-"}:{axis:"x",facing:n.x<=e.x?"x+":"x-"},Kqt=n=>n.length===0?[[]]:n.reduce((e,a)=>e.flatMap(s=>a.map(l=>[...s,l])),[[]]),Jqt=({baseElbow:n,guidelines:e})=>{let a=Yqt(n);N5e(a);let s=a.length;if(s-1<5)return{elbowVariants:[a.map(B=>({...B}))],movableSegments:[]};let d=2,x=s-4,f=[],m=[],y=[],b=[];for(let B=d;B<=x;B++){let I=a[B-1],q=a[B],G=a[B+1],j=a[B+2],{axis:O,facing:V}=Wqt(I,q,G);f.push({start:{...q},end:{...G},freedom:V,dir:Uqt(V)}),m.push(B),y.push(O);let te=O==="x"?q.x:q.y,se=Hqt(O,e,te).filter($=>{if(O==="y"){let W=Math.abs(I.y-$),Q=Math.abs(j.y-$);return W>Sg&&Q>Sg}else{let W=Math.abs(I.x-$),Q=Math.abs(j.x-$);return W>Sg&&Q>Sg}});b.push(se)}let E=Kqt(b),A=new Set,w=[];{let B=k5e(a);A.add(B),w.push(a.map(I=>({...I})))}for(let B of E){if(B.length===0)continue;let I=a.map(G=>({...G}));for(let G=0;G<m.length;G++){let j=m[G],O=y[G],V=B[G];typeof V!="number"||Number.isNaN(V)||(O==="y"?(I[j]={...I[j],y:V},I[j+1]={...I[j+1],y:V}):(I[j]={...I[j],x:V},I[j+1]={...I[j+1],x:V}))}try{N5e(I)}catch{continue}let q=k5e(I);A.has(q)||(A.add(q),w.push(I))}return{elbowVariants:w,movableSegments:f}},rSe=({guidelines:n,graphics:e})=>{let a=fW(e),s=a.maxX-a.minX,l=a.maxY-a.minY;a.minX-=s*.3,a.maxX+=s*.3,a.minY-=l*.3,a.maxY+=l*.3;for(let d of n)d.orientation==="horizontal"&&e.lines.push({points:[{x:a.minX,y:d.y},{x:a.maxX,y:d.y}],strokeColor:"rgba(0, 0, 0, 0.5)",strokeDash:"2 2"}),d.orientation==="vertical"&&e.lines.push({points:[{x:d.x,y:a.minY},{x:d.x,y:a.maxY}],strokeColor:"rgba(0, 0, 0, 0.5)",strokeDash:"2 2"});return e},Zqt=class extends sd{constructor(e){super();X(this,"pins");X(this,"inputProblem");X(this,"guidelines");X(this,"chipMap");X(this,"movableSegments");X(this,"baseElbow");X(this,"allCandidatePaths");X(this,"queuedCandidatePaths");X(this,"chipObstacleSpatialIndex");X(this,"solvedTracePath",null);this.pins=e.pins,this.inputProblem=e.inputProblem,this.guidelines=e.guidelines,this.chipMap=e.chipMap,this.chipObstacleSpatialIndex=this.inputProblem._chipObstacleSpatialIndex||new tSe(this.inputProblem.chips),this.inputProblem._chipObstacleSpatialIndex||(this.inputProblem._chipObstacleSpatialIndex=this.chipObstacleSpatialIndex);for(let f of this.pins)if(!f._facingDirection){let m=this.chipMap[f.chipId];f._facingDirection=Q5e(f,m)}let[a,s]=this.pins;this.baseElbow=qqt({x:a.x,y:a.y,facingDirection:a._facingDirection},{x:s.x,y:s.y,facingDirection:s._facingDirection},{overshoot:.2});let{elbowVariants:l,movableSegments:d}=Jqt({baseElbow:this.baseElbow,guidelines:this.guidelines});this.movableSegments=d;let x=f=>{let m=0;for(let y=0;y<f.length-1;y++){let b=f[y+1].x-f[y].x,E=f[y+1].y-f[y].y;m+=Math.sqrt(b*b+E*E)}return m};this.allCandidatePaths=[this.baseElbow,...l],this.queuedCandidatePaths=[...this.allCandidatePaths].sort((f,m)=>x(f)-x(m))}getConstructorParams(){return{chipMap:this.chipMap,pins:this.pins,guidelines:this.guidelines,inputProblem:this.inputProblem}}_step(){if(this.queuedCandidatePaths.length===0){this.failed=!0,this.error="No more candidate elbows, everything had collisions";return}let e=this.queuedCandidatePaths.shift();for(let a=0;a<e.length-1;a++){let s=e[a],l=e[a+1],d=[],x=this.pins.some(b=>Math.abs(b.x-s.x)<1e-10&&Math.abs(b.y-s.y)<1e-10),f=this.pins.some(b=>Math.abs(b.x-l.x)<1e-10&&Math.abs(b.y-l.y)<1e-10);if(x){let b=this.pins.find(E=>Math.abs(E.x-s.x)<1e-10&&Math.abs(E.y-s.y)<1e-10);if(b){let E=C1(this.chipMap[b.chipId]),A=l.x-s.x,w=l.y-s.y,B=1e-9,I=Math.abs(s.x-E.minX)<1e-9,q=Math.abs(s.x-E.maxX)<1e-9,G=Math.abs(s.y-E.minY)<1e-9,j=Math.abs(s.y-E.maxY)<1e-9;if(I&&A>B||q&&A<-B||G&&w>B||j&&w<-B)return;d.includes(b.chipId)||d.push(b.chipId)}}if(f){let b=this.pins.find(E=>Math.abs(E.x-l.x)<1e-10&&Math.abs(E.y-l.y)<1e-10);if(b){let E=C1(this.chipMap[b.chipId]),A=s.x-l.x,w=s.y-l.y,B=1e-9,I=Math.abs(l.x-E.minX)<1e-9,q=Math.abs(l.x-E.maxX)<1e-9,G=Math.abs(l.y-E.minY)<1e-9,j=Math.abs(l.y-E.maxY)<1e-9;if(I&&A>B||q&&A<-B||G&&w>B||j&&w<-B)return;d.includes(b.chipId)||d.push(b.chipId)}}let m={excludeChipIds:d};if(this.chipObstacleSpatialIndex.doesOrthogonalLineIntersectChip([s,l],m))return}this.solvedTracePath=e,this.solved=!0}visualize(){let e=Qp(this.inputProblem,{chipAlpha:.1,connectionAlpha:.1}),a=fW(e),s=a.maxX-a.minX,l=a.maxY-a.minY;rSe({guidelines:this.guidelines,graphics:e});for(let{start:d,end:x,dir:f}of this.movableSegments){let m={x:(d.x+x.x)/2,y:(d.y+x.y)/2},y=Math.sqrt((d.x-x.x)**2+(d.y-x.y)**2);e.lines.push({points:[d,m,x],strokeColor:"rgba(0,0,255,0.5)",strokeDash:"2 2"}),e.lines.push({points:[m,{x:m.x+f.x*y*.1,y:m.y+f.y*y*.1}],strokeColor:"rgba(0,0,255,0.5)",strokeDash:"2 2"})}if(!this.solvedTracePath){this.queuedCandidatePaths.length>0&&e.lines.push({points:this.queuedCandidatePaths[0],strokeColor:"orange",strokeWidth:s*.005});for(let d=1;d<this.queuedCandidatePaths.length;d++){let x=this.queuedCandidatePaths[d],f=d/this.queuedCandidatePaths.length;e.lines.push({points:x.map(m=>({x:m.x+f*s*.005,y:m.y+f*l*.005})),strokeColor:Lc(`${x.reduce((m,y)=>`${m},${y.x},${y.y}`,"")}`,.5),strokeDash:"8 8"})}}return this.solvedTracePath&&e.lines.push({points:this.solvedTracePath,strokeColor:"green"}),e}},Qqt=class extends sd{constructor(e){super();X(this,"inputProblem");X(this,"guidelines");X(this,"mspConnectionPairs");X(this,"dcConnMap");X(this,"globalConnMap");X(this,"queuedConnectionPairs");X(this,"chipMap");X(this,"currentConnectionPair",null);X(this,"solvedTracePaths",[]);X(this,"failedConnectionPairs",[]);this.inputProblem=e.inputProblem,this.mspConnectionPairs=e.mspConnectionPairs,this.dcConnMap=e.dcConnMap,this.globalConnMap=e.globalConnMap,this.guidelines=e.guidelines,this.chipMap=e.chipMap,this.queuedConnectionPairs=[...this.mspConnectionPairs]}getConstructorParams(){return{inputProblem:this.inputProblem,chipMap:this.chipMap,mspConnectionPairs:this.mspConnectionPairs,dcConnMap:this.dcConnMap,globalConnMap:this.globalConnMap,guidelines:this.guidelines}}_step(){if(this.activeSubSolver?.solved&&(this.solvedTracePaths.push({...this.currentConnectionPair,tracePath:this.activeSubSolver.solvedTracePath,mspConnectionPairIds:[this.currentConnectionPair.mspPairId],pinIds:[this.currentConnectionPair.pins[0].pinId,this.currentConnectionPair.pins[1].pinId]}),this.activeSubSolver=null,this.currentConnectionPair=null),this.activeSubSolver?.failed&&(this.currentConnectionPair&&this.failedConnectionPairs.push({...this.currentConnectionPair,error:this.activeSubSolver.error||void 0}),this.activeSubSolver=null,this.currentConnectionPair=null),this.activeSubSolver){this.activeSubSolver.step();return}let e=this.queuedConnectionPairs.shift();if(this.currentConnectionPair=e,!e){this.solved=!0;return}let{pins:a}=e;this.activeSubSolver=new Zqt({inputProblem:this.inputProblem,pins:a,chipMap:this.chipMap,guidelines:this.guidelines})}visualize(){if(this.activeSubSolver)return this.activeSubSolver.visualize();let e=Qp(this.inputProblem,{chipAlpha:.1,connectionAlpha:.1});rSe({guidelines:this.guidelines,graphics:e});for(let{mspPairId:a,tracePath:s}of this.solvedTracePaths)e.lines.push({points:s,strokeWidth:.005,strokeColor:"green"});for(let a of this.failedConnectionPairs)e.lines.push({points:[{x:a.pins[0].x,y:a.pins[0].y},{x:a.pins[1].x,y:a.pins[1].y}],strokeColor:"red",strokeDash:"4 2",strokeWidth:.004});return e}},eUt=class extends sd{constructor(e){super();X(this,"overlappingTraceSegments");X(this,"traceNetIslands");X(this,"SHIFT_DISTANCE",.1);X(this,"correctedTraceMap",{});this.overlappingTraceSegments=e.overlappingTraceSegments,this.traceNetIslands=e.traceNetIslands;for(let{connNetId:a,pathsWithOverlap:s}of this.overlappingTraceSegments)for(let{solvedTracePathIndex:l,traceSegmentIndex:d}of s){let x=this.traceNetIslands[a][l].mspPairId;this.correctedTraceMap[x]=this.traceNetIslands[a][l]}}_step(){let a=this.overlappingTraceSegments.map((d,x)=>{let f=Math.floor(x/2)+1;return(x%2===0?-f:f)*this.SHIFT_DISTANCE}),s=(d,x)=>Math.abs(d-x)<1e-6,l=(d,x)=>!!d&&!!x&&s(d.x,x.x)&&s(d.y,x.y);this.overlappingTraceSegments.forEach((d,x)=>{let f=a[x],m=new Map;for(let y of d.pathsWithOverlap)m.has(y.solvedTracePathIndex)||m.set(y.solvedTracePathIndex,new Set),m.get(y.solvedTracePathIndex).add(y.traceSegmentIndex);for(let[y,b]of m){let E=this.traceNetIslands[d.connNetId][y],A=this.correctedTraceMap[E.mspPairId]??E,w=A.tracePath.map(j=>({...j})),B=Array.from(b).sort((j,O)=>j-O),I=new Set,q=new Set;for(let j of B){if(j<0||j>=w.length-1||j===0||j===w.length-2)continue;let O=w[j],V=w[j+1],te=Math.abs(O.x-V.x)<1e-6,N=Math.abs(O.y-V.y)<1e-6;!te&&!N||(te?(I.has(j)||(O.x+=f,I.add(j)),I.has(j+1)||(V.x+=f,I.add(j+1))):N&&(q.has(j)||(O.y+=f,q.add(j)),q.has(j+1)||(V.y+=f,q.add(j+1))))}let G=[];for(let j of w)(G.length===0||!l(G[G.length-1],j))&&G.push(j);this.correctedTraceMap[E.mspPairId]={...A,tracePath:G}}}),this.solved=!0}visualize(){let e={lines:[],points:[],rects:[],circles:[]};for(let a of this.overlappingTraceSegments)for(let{solvedTracePathIndex:s,traceSegmentIndex:l}of a.pathsWithOverlap){let d=this.traceNetIslands[a.connNetId][s],x=d.tracePath[l],f=d.tracePath[l+1];e.lines.push({points:[x,f],strokeColor:"red",strokeWidth:.006})}for(let a of Object.values(this.correctedTraceMap))e.lines.push({points:a.tracePath,strokeColor:"blue",strokeDash:"4 2",strokeWidth:.004});return e}},tUt=class extends sd{constructor(e){super();X(this,"inputProblem");X(this,"inputTracePaths");X(this,"globalConnMap");X(this,"traceNetIslands",{});X(this,"correctedTraceMap",{});this.inputProblem=e.inputProblem,this.inputTracePaths=e.inputTracePaths,this.globalConnMap=e.globalConnMap;for(let a of this.inputTracePaths){let{mspPairId:s}=a;this.correctedTraceMap[s]=a}this.traceNetIslands=this.computeTraceNetIslands()}getConstructorParams(){return{inputProblem:this.inputProblem,inputTracePaths:this.inputTracePaths,globalConnMap:this.globalConnMap}}computeTraceNetIslands(){let e={};for(let a of this.inputTracePaths){let s=this.correctedTraceMap[a.mspPairId]??a,l=s.globalConnNetId;e[l]||(e[l]=[]),e[l].push(s)}return e}findNextOverlapIssue(){let a=Object.keys(this.traceNetIslands);for(let s=0;s<a.length;s++)for(let l=s+1;l<a.length;l++){let d=a[s],x=a[l],f=this.traceNetIslands[d]||[],m=this.traceNetIslands[x]||[],y=[],b=[],E=new Set,A=new Set,w=(B,I,q,G)=>{let j=Math.min(B,I),O=Math.max(B,I),V=Math.min(q,G),te=Math.max(q,G);return Math.min(O,te)-Math.max(j,V)>1e-6};for(let B=0;B<f.length;B++){let q=f[B].tracePath;for(let G=0;G<q.length-1;G++){let j=q[G],O=q[G+1],V=Math.abs(j.x-O.x)<1e-6,te=Math.abs(j.y-O.y)<1e-6;if(!(!V&&!te))for(let N=0;N<m.length;N++){let $=m[N].tracePath;for(let W=0;W<$.length-1;W++){let Q=$[W],le=$[W+1],z=Math.abs(Q.x-le.x)<1e-6,pe=Math.abs(Q.y-le.y)<1e-6;if(!(!z&&!pe)){if(V&&z){if(Math.abs(j.x-Q.x)<1e-6&&w(j.y,O.y,Q.y,le.y)){let xe=`${B}:${G}`,Ae=`${N}:${W}`;E.has(xe)||(y.push({solvedTracePathIndex:B,traceSegmentIndex:G}),E.add(xe)),A.has(Ae)||(b.push({solvedTracePathIndex:N,traceSegmentIndex:W}),A.add(Ae))}}else if(te&&pe&&Math.abs(j.y-Q.y)<1e-6&&w(j.x,O.x,Q.x,le.x)){let xe=`${B}:${G}`,Ae=`${N}:${W}`;E.has(xe)||(y.push({solvedTracePathIndex:B,traceSegmentIndex:G}),E.add(xe)),A.has(Ae)||(b.push({solvedTracePathIndex:N,traceSegmentIndex:W}),A.add(Ae))}}}}}}if(y.length>0&&b.length>0)return{overlappingTraceSegments:[{connNetId:d,pathsWithOverlap:y},{connNetId:x,pathsWithOverlap:b}]}}return null}_step(){if(this.activeSubSolver?.solved){for(let[s,l]of Object.entries(this.activeSubSolver.correctedTraceMap))this.correctedTraceMap[s]=l;this.activeSubSolver=null,this.traceNetIslands=this.computeTraceNetIslands()}if(this.activeSubSolver){this.activeSubSolver.step();return}let e=this.findNextOverlapIssue();if(e===null){this.solved=!0;return}let{overlappingTraceSegments:a}=e;this.activeSubSolver=new eUt({overlappingTraceSegments:a,traceNetIslands:this.traceNetIslands})}visualize(){if(this.activeSubSolver)return this.activeSubSolver.visualize();let e=Qp(this.inputProblem);for(let a of Object.values(this.correctedTraceMap))e.lines.push({points:a.tracePath,strokeColor:"purple",strokeWidth:.005});return e}},M5e=.4,O5e=.2;function nSe(n){return n==="y+"||n==="y-"?{width:O5e,height:M5e}:{width:M5e,height:O5e}}function aSe(n,e,a,s){switch(e){case"x+":return{x:n.x+a/2,y:n.y};case"x-":return{x:n.x-a/2,y:n.y};case"y+":return{x:n.x,y:n.y+s/2};case"y-":return{x:n.x,y:n.y-s/2}}}function sSe(n,e,a){return{minX:n.x-e/2,minY:n.y-a/2,maxX:n.x+e/2,maxY:n.y+a/2}}function rUt(n,e,a,s=1e-9){let l=Math.abs(n.x-e.x)<s,d=Math.abs(n.y-e.y)<s;if(!l&&!d)return!1;if(l){let x=n.x;if(x<a.minX-s||x>a.maxX+s)return!1;let f=Math.min(n.y,e.y),m=Math.max(n.y,e.y);return Math.min(m,a.maxY)-Math.max(f,a.minY)>s}else{let x=n.y;if(x<a.minY-s||x>a.maxY+s)return!1;let f=Math.min(n.x,e.x),m=Math.max(n.x,e.x);return Math.min(m,a.maxX)-Math.max(f,a.minX)>s}}function iSe(n,e,a,s){for(let[l,d]of Object.entries(e)){let x=d.tracePath;for(let f=0;f<x.length-1;f++)if(!(l===a&&f===s)&&rUt(x[f],x[f+1],n))return!0}return!1}function L5e(n){let e=0,a=n.tracePath;for(let s=0;s<a.length-1;s++)e+=Math.abs(a[s+1].x-a[s].x)+Math.abs(a[s+1].y-a[s].y);return e}function oSe(n){let{inputProblem:e,inputTraceMap:a,globalConnNetId:s,fallbackTrace:l,mspConnectionPairIds:d}=n,x=Object.fromEntries(e.chips.map(A=>[A.chipId,A])),f=Object.values(a).filter(A=>A.globalConnNetId===s);if(d&&d.length>0){let A=new Set(d);f=f.filter(w=>w.mspConnectionPairIds.some(B=>A.has(B)))}let m=new Set;for(let A of f)m.add(A.pins[0].chipId),m.add(A.pins[1].chipId);let y=null,b=-1;for(let A of m){let B=x[A]?.pins?.length??0;B>b&&(b=B,y=A)}let E=y==null?[]:f.filter(A=>A.pins[0].chipId===y||A.pins[1].chipId===y);return E.length>0?E.reduce((A,w)=>L5e(A)>=L5e(w)?A:w):l}function nUt(n,e){return[{x:n.x,y:n.y},{x:(n.x+e.x)/2,y:(n.y+e.y)/2},{x:e.x,y:e.y}]}function aUt(n){let{inputProblem:e,inputTraceMap:a,chipObstacleSpatialIndex:s,overlappingSameNetTraceGroup:l,availableOrientations:d}=n,x=l.portOnlyPinId;if(!x)return{placement:null,testedCandidates:[],error:"No portOnlyPinId provided"};let f=null;for(let A of e.chips){let w=A.pins.find(B=>B.pinId===x);if(w){f={x:w.x,y:w.y};break}}if(!f)return{placement:null,testedCandidates:[],error:`Port-only pin not found: ${x}`};let m=d.length>0?d:["x+","x-","y+","y-"],y={x:f.x,y:f.y},b=A=>A==="x+"?{x:1,y:0}:A==="x-"?{x:-1,y:0}:A==="y+"?{x:0,y:1}:{x:0,y:-1},E=[];for(let A of m){let{width:w,height:B}=nSe(A),I=aSe(y,A,w,B),q=b(A),G=.001,j={x:I.x+q.x*G,y:I.y+q.y*G},O=sSe(j,w,B);if(s.getChipsInBounds(O).length>0){E.push({center:j,width:w,height:B,bounds:O,anchor:y,orientation:A,status:"chip-collision",hostSegIndex:-1});continue}if(iSe(O,a,"",-1)){E.push({center:j,width:w,height:B,bounds:O,anchor:y,orientation:A,status:"trace-collision",hostSegIndex:-1});continue}return E.push({center:j,width:w,height:B,bounds:O,anchor:y,orientation:A,status:"ok",hostSegIndex:-1}),{placement:{globalConnNetId:l.globalConnNetId,dcConnNetId:void 0,netId:l.netId,mspConnectionPairIds:[],pinIds:[x],orientation:A,anchorPoint:y,width:w,height:B,center:j},testedCandidates:E}}return{placement:null,testedCandidates:E,error:"Could not place net label at port without collisions"}}function sUt(n){let e=Qp(n.inputProblem),a=n.overlappingSameNetTraceGroup.globalConnNetId,s=oSe({inputProblem:n.inputProblem,inputTraceMap:n.inputTraceMap,globalConnNetId:a,fallbackTrace:n.overlappingSameNetTraceGroup.overlappingTraces}),l=Lc(a,.9),d=Lc(a,.5);for(let x of Object.values(n.inputTraceMap)){if(x.globalConnNetId!==a)continue;let f=s?x.mspPairId===s.mspPairId:!1;e.lines.push({points:x.tracePath,strokeColor:f?l:d,strokeWidth:f?.006:.003,strokeDash:f?void 0:"4 2"})}for(let x of n.testedCandidates){let f=x.status==="ok"?"rgba(0, 180, 0, 0.25)":x.status==="chip-collision"?"rgba(220, 0, 0, 0.25)":x.status==="trace-collision"?"rgba(220, 140, 0, 0.25)":"rgba(120, 120, 120, 0.15)",m=x.status==="ok"?"green":x.status==="chip-collision"?"red":x.status==="trace-collision"?"orange":"gray";e.rects.push({center:{x:(x.bounds.minX+x.bounds.maxX)/2,y:(x.bounds.minY+x.bounds.maxY)/2},width:x.width,height:x.height,fill:f,strokeColor:m}),e.points.push({x:x.anchor.x,y:x.anchor.y,color:m})}if(n.netLabelPlacement){let x=n.netLabelPlacement;e.rects.push({center:x.center,width:x.width,height:x.height,fill:"rgba(0, 128, 255, 0.35)",strokeColor:"blue"}),e.points.push({x:x.anchorPoint.x,y:x.anchorPoint.y,color:"blue"})}return e}var $5e=class extends sd{constructor(e){super();X(this,"inputProblem");X(this,"inputTraceMap");X(this,"overlappingSameNetTraceGroup");X(this,"availableOrientations");X(this,"chipObstacleSpatialIndex");X(this,"netLabelPlacement",null);X(this,"testedCandidates",[]);this.inputProblem=e.inputProblem,this.inputTraceMap=e.inputTraceMap,this.overlappingSameNetTraceGroup=e.overlappingSameNetTraceGroup,this.availableOrientations=e.availableOrientations,this.chipObstacleSpatialIndex=e.inputProblem._chipObstacleSpatialIndex??new tSe(e.inputProblem.chips)}_step(){if(this.netLabelPlacement){this.solved=!0;return}if(this.overlappingSameNetTraceGroup.portOnlyPinId){let A=aUt({inputProblem:this.inputProblem,inputTraceMap:this.inputTraceMap,chipObstacleSpatialIndex:this.chipObstacleSpatialIndex,overlappingSameNetTraceGroup:this.overlappingSameNetTraceGroup,availableOrientations:this.availableOrientations});if(this.testedCandidates.push(...A.testedCandidates),A.placement){this.netLabelPlacement=A.placement,this.solved=!0;return}this.failed=!0,this.error=A.error??"Could not place net label at port without collisions";return}let e=this.overlappingSameNetTraceGroup.globalConnNetId,a=oSe({inputProblem:this.inputProblem,inputTraceMap:this.inputTraceMap,globalConnNetId:e,fallbackTrace:this.overlappingSameNetTraceGroup.overlappingTraces,mspConnectionPairIds:this.overlappingSameNetTraceGroup.mspConnectionPairIds});if(!a){this.failed=!0,this.error="No host trace found for net label placement";return}let s=new Set(this.overlappingSameNetTraceGroup.mspConnectionPairIds??[]),l=Object.values(this.inputTraceMap).filter(A=>A.globalConnNetId===e&&(s.size===0||A.mspConnectionPairIds.some(w=>s.has(w)))),d=this.availableOrientations.length===1?[a,...l.filter(A=>A.mspPairId!==a.mspPairId)]:[a],x=this.availableOrientations.length>0?this.availableOrientations:["x+","x-","y+","y-"],f=this.availableOrientations.length===1,m=(A,w)=>{switch(A){case"y+":return w.y;case"y-":return-w.y;case"x+":return w.x;case"x-":return-w.x}},y=null,b=-1/0,E=1e-6;for(let A of d){let w=A.tracePath.slice();for(let B=0;B<w.length-1;B++){let I=w[B],q=w[B+1],G=Math.abs(I.y-q.y)<E,j=Math.abs(I.x-q.x)<E;if(!G&&!j)continue;let O=G?["y+","y-"]:["x+","x-"],V=x.filter(N=>O.includes(N));if(V.length===0)continue;let te=nUt(I,q);for(let N of te)for(let se of V){let{width:$,height:W}=nSe(se),Q=aSe(N,se,$,W),le=se==="x+"?{x:1,y:0}:se==="x-"?{x:-1,y:0}:se==="y+"?{x:0,y:1}:{x:0,y:-1},z=1e-4,pe={x:Q.x+le.x*z,y:Q.y+le.y*z},xe=sSe(pe,$,W);if(this.chipObstacleSpatialIndex.getChipsInBounds(xe).length>0){this.testedCandidates.push({center:pe,width:$,height:W,bounds:xe,anchor:N,orientation:se,status:"chip-collision",hostSegIndex:B});continue}if(iSe(xe,this.inputTraceMap,A.mspPairId,B)){this.testedCandidates.push({center:pe,width:$,height:W,bounds:xe,anchor:N,orientation:se,status:"trace-collision",hostSegIndex:B});continue}if(this.testedCandidates.push({center:pe,width:$,height:W,bounds:xe,anchor:N,orientation:se,status:"ok",hostSegIndex:B}),f){let Ie=m(se,N);Ie>b+1e-9&&(b=Ie,y={anchor:N,orientation:se,width:$,height:W,center:Q,hostSegIndex:B,dcConnNetId:A.dcConnNetId,mspPairId:A.mspPairId,pinIds:[A.pins[0].pinId,A.pins[1].pinId]});continue}this.netLabelPlacement={globalConnNetId:this.overlappingSameNetTraceGroup.globalConnNetId,dcConnNetId:A.dcConnNetId,netId:this.overlappingSameNetTraceGroup.netId,mspConnectionPairIds:[A.mspPairId],pinIds:[A.pins[0].pinId,A.pins[1].pinId],orientation:se,anchorPoint:N,width:$,height:W,center:Q},this.solved=!0;return}}}if(f&&y){this.netLabelPlacement={globalConnNetId:this.overlappingSameNetTraceGroup.globalConnNetId,dcConnNetId:y.dcConnNetId,netId:this.overlappingSameNetTraceGroup.netId,mspConnectionPairIds:[y.mspPairId],pinIds:y.pinIds,orientation:y.orientation,anchorPoint:y.anchor,width:y.width,height:y.height,center:y.center},this.solved=!0;return}this.failed=!0,this.error="Could not place net label without collisions"}visualize(){return sUt(this)}},iUt=class extends sd{constructor(e){super();X(this,"inputProblem");X(this,"inputTraceMap");X(this,"overlappingSameNetTraceGroups");X(this,"queuedOverlappingSameNetTraceGroups");X(this,"netLabelPlacements",[]);X(this,"currentGroup",null);X(this,"triedAnyOrientationFallbackForCurrentGroup",!1);this.inputProblem=e.inputProblem,this.inputTraceMap=e.inputTraceMap,this.overlappingSameNetTraceGroups=this.computeOverlappingSameNetTraceGroups(),this.queuedOverlappingSameNetTraceGroups=[...this.overlappingSameNetTraceGroups]}computeOverlappingSameNetTraceGroups(){let e={};for(let d of Object.values(this.inputTraceMap)){let x=d.globalConnNetId;e[x]||(e[x]=[]),e[x].push(d)}let{netConnMap:a}=Z5e(this.inputProblem),s={};for(let d of this.inputProblem.directConnections)if(d.netId){let[x,f]=d.pinIds;s[x]=d.netId,s[f]=d.netId}for(let d of this.inputProblem.netConnections)for(let x of d.pinIds)s[x]=d.netId;let l=[];for(let d of Object.keys(a.netMap)){let x=a.getIdsConnectedToNet(d),f={};for(let y of x)f[y]=new Set;for(let y of e[d]??[]){let b=y.pins[0].pinId,E=y.pins[1].pinId;f[b]&&f[E]&&(f[b].add(E),f[E].add(b))}let m=new Set;for(let y of x){if(m.has(y))continue;let b=[y],E=new Set;for(m.add(y);b.length>0;){let w=b.pop();E.add(w);for(let B of f[w]??[])m.has(B)||(m.add(B),b.push(B))}let A=(e[d]??[]).filter(w=>E.has(w.pins[0].pinId)&&E.has(w.pins[1].pinId));if(A.length>0){let w=j=>{let O=0,V=j.tracePath;for(let te=0;te<V.length-1;te++)O+=Math.abs(V[te+1].x-V[te].x)+Math.abs(V[te+1].y-V[te].y);return O},B=A[0],I=w(B);for(let j=1;j<A.length;j++){let O=w(A[j]);O>I&&(B=A[j],I=O)}let q=A.find(j=>j.userNetId!=null)?.userNetId;if(!q){for(let j of E)if(s[j]){q=s[j];break}}let G=Array.from(new Set(A.flatMap(j=>j.mspConnectionPairIds??[j.mspPairId])));l.push({globalConnNetId:d,netId:q,overlappingTraces:B,mspConnectionPairIds:G})}else for(let w of E){let B=s[w];B&&l.push({globalConnNetId:d,netId:B,portOnlyPinId:w})}}}return l}_step(){if(this.activeSubSolver?.solved){this.netLabelPlacements.push(this.activeSubSolver.netLabelPlacement),this.activeSubSolver=null,this.currentGroup=null,this.triedAnyOrientationFallbackForCurrentGroup=!1;return}if(this.activeSubSolver?.failed){let s=["x+","x-","y+","y-"],l=this.activeSubSolver.availableOrientations,d=l.length===4&&s.every(x=>l.includes(x));if(!this.triedAnyOrientationFallbackForCurrentGroup&&!d&&this.currentGroup){this.triedAnyOrientationFallbackForCurrentGroup=!0,this.activeSubSolver=new $5e({inputProblem:this.inputProblem,inputTraceMap:this.inputTraceMap,overlappingSameNetTraceGroup:this.currentGroup,availableOrientations:s});return}this.failed=!0,this.error=this.activeSubSolver.error;return}if(this.activeSubSolver){this.activeSubSolver.step();return}let e=this.queuedOverlappingSameNetTraceGroups.shift();if(!e){this.solved=!0;return}let a=e.netId??e.globalConnNetId;this.currentGroup=e,this.triedAnyOrientationFallbackForCurrentGroup=!1,this.activeSubSolver=new $5e({inputProblem:this.inputProblem,inputTraceMap:this.inputTraceMap,overlappingSameNetTraceGroup:e,availableOrientations:this.inputProblem.availableNetLabelOrientations[a]??["x+","x-","y+","y-"]})}visualize(){if(this.activeSubSolver)return this.activeSubSolver.visualize();let e=Qp(this.inputProblem);for(let a of Object.values(this.inputTraceMap))e.lines.push({points:a.tracePath,strokeColor:"purple",strokeWidth:.005});for(let a of this.netLabelPlacements)e.rects.push({center:a.center,width:a.width,height:a.height,fill:Lc(a.globalConnNetId,.35),strokeColor:Lc(a.globalConnNetId,.9)}),e.points.push({x:a.anchorPoint.x,y:a.anchorPoint.y,color:Lc(a.globalConnNetId,.9)});return e}},oUt=n=>(function*(){for(let e=0;e<n.length;e++)for(let a=0;a<n.length;a++)e!==a&&(yield[n[e],n[a]])})();function uUt(n,e){if(n.maxY<=e.minY)return(n.maxY+e.minY)/2;if(e.maxY<=n.minY)return(e.maxY+n.minY)/2;let a=Math.max(n.minY,e.minY),s=Math.min(n.maxY,e.maxY);return(a+s)/2}function cUt(n,e){if(n.maxX<=e.minX)return(n.maxX+e.minX)/2;if(e.maxX<=n.minX)return(e.maxX+n.minX)/2;let a=Math.max(n.minX,e.minX),s=Math.min(n.maxX,e.maxX);return(a+s)/2}var lUt=n=>{let e={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0};for(let a of n.chips){let s=C1(a);e.minX=Math.min(e.minX,s.minX),e.maxX=Math.max(e.maxX,s.maxX),e.minY=Math.min(e.minY,s.minY),e.maxY=Math.max(e.maxY,s.maxY)}return e},CS=.1,dUt=class extends sd{constructor(e){super();X(this,"inputProblem");X(this,"guidelines");X(this,"chipPairsGenerator");X(this,"usedXGuidelines");X(this,"usedYGuidelines");this.inputProblem=e.inputProblem;let a=lUt(this.inputProblem);this.guidelines=[{orientation:"horizontal",y:a.minY-CS,x:void 0},{orientation:"horizontal",y:a.maxY+CS,x:void 0},{orientation:"vertical",y:void 0,x:a.minX-CS},{orientation:"vertical",y:void 0,x:a.maxX+CS}],this.chipPairsGenerator=oUt(this.inputProblem.chips),this.usedXGuidelines=new Set,this.usedYGuidelines=new Set}getConstructorParams(){return{inputProblem:this.inputProblem}}_step(){let{done:e,value:a}=this.chipPairsGenerator.next();if(e){this.solved=!0;return}let[s,l]=a,d=C1(s),x=C1(l),f=uUt(d,x),m=cUt(d,x);this.usedYGuidelines.has(f)||(this.usedYGuidelines.add(f),this.guidelines.push({orientation:"horizontal",y:f,x:void 0})),this.usedXGuidelines.has(m)||(this.usedXGuidelines.add(m),this.guidelines.push({orientation:"vertical",y:void 0,x:m}))}visualize(){let e=Qp(this.inputProblem),a=fW(e),s=a.maxX-a.minX,l=a.maxY-a.minY;a.minX-=s*.3,a.maxX+=s*.3,a.minY-=l*.3,a.maxY+=l*.3;for(let d of this.guidelines)d.orientation==="horizontal"&&e.lines.push({points:[{x:a.minX,y:d.y},{x:a.maxX,y:d.y}],strokeColor:"rgba(0, 0, 0, 0.5)",strokeDash:"2 2"}),d.orientation==="vertical"&&e.lines.push({points:[{x:d.x,y:a.minY},{x:d.x,y:a.maxY}],strokeColor:"rgba(0, 0, 0, 0.5)",strokeDash:"2 2"});return e}},pUt=n=>{for(let e of n.chips){let a=C1(e);for(let s of e.pins){if(!(s.x>a.minX&&s.x<a.maxX&&s.y>a.minY&&s.y<a.maxY))continue;let d=s.x-a.minX,x=a.maxX-s.x,f=s.y-a.minY,m=a.maxY-s.y,y=Math.min(d,x,f,m);y===d?s.x=a.minX:y===x?s.x=a.maxX:y===f?s.y=a.minY:s.y=a.maxY,s._facingDirection=void 0}}},xUt=n=>{for(let e of n.chips){let a=e.width/2,s=e.height/2,l=0,d=0;for(let m of e.pins){let y=Math.abs(m.x-e.center.x),b=Math.abs(m.y-e.center.y);y>l&&(l=y),b>d&&(d=b)}let x=Math.max(a,l),f=Math.max(s,d);if(x>a||f>s){e.width=x*2,e.height=f*2;for(let m of e.pins)m._facingDirection=void 0}}};function RF(n,e,a,s={}){return{solverName:n,solverClass:e,getConstructorParams:a,onSolved:s.onSolved}}var uSe=class extends sd{constructor(e){super();X(this,"mspConnectionPairSolver");X(this,"guidelinesSolver");X(this,"schematicTraceLinesSolver");X(this,"traceOverlapShiftSolver");X(this,"netLabelPlacementSolver");X(this,"startTimeOfPhase");X(this,"endTimeOfPhase");X(this,"timeSpentOnPhase");X(this,"firstIterationOfPhase");X(this,"inputProblem");X(this,"pipelineDef",[RF("mspConnectionPairSolver",jqt,()=>[{inputProblem:this.inputProblem}],{onSolved:e=>{}}),RF("guidelinesSolver",dUt,()=>[{inputProblem:this.inputProblem}],{onSolved:e=>{}}),RF("schematicTraceLinesSolver",Qqt,()=>[{mspConnectionPairs:this.mspConnectionPairSolver.mspConnectionPairs,dcConnMap:this.mspConnectionPairSolver.dcConnMap,globalConnMap:this.mspConnectionPairSolver.globalConnMap,inputProblem:this.inputProblem,guidelines:this.guidelinesSolver.guidelines,chipMap:this.mspConnectionPairSolver.chipMap}],{onSolved:e=>{}}),RF("traceOverlapShiftSolver",tUt,()=>[{inputProblem:this.inputProblem,inputTracePaths:this.schematicTraceLinesSolver.solvedTracePaths,globalConnMap:this.mspConnectionPairSolver.globalConnMap}],{onSolved:e=>{}}),RF("netLabelPlacementSolver",iUt,()=>[{inputProblem:this.inputProblem,inputTraceMap:this.traceOverlapShiftSolver?.correctedTraceMap??Object.fromEntries(this.schematicTraceLinesSolver.solvedTracePaths.map(e=>[e.mspPairId,e]))}],{onSolved:e=>{}})]);X(this,"currentPipelineStepIndex",0);this.inputProblem=this.cloneAndCorrectInputProblem(e),this.MAX_ITERATIONS=1e6,this.startTimeOfPhase={},this.endTimeOfPhase={},this.timeSpentOnPhase={},this.firstIterationOfPhase={}}getConstructorParams(){return this.inputProblem}cloneAndCorrectInputProblem(e){let a=structuredClone({...e,_chipObstacleSpatialIndex:void 0});return xUt(a),pUt(a),a}_step(){let e=this.pipelineDef[this.currentPipelineStepIndex];if(!e){this.solved=!0;return}if(this.activeSubSolver){this.activeSubSolver.step(),this.activeSubSolver.solved?(this.endTimeOfPhase[e.solverName]=performance.now(),this.timeSpentOnPhase[e.solverName]=this.endTimeOfPhase[e.solverName]-this.startTimeOfPhase[e.solverName],e.onSolved?.(this),this.activeSubSolver=null,this.currentPipelineStepIndex++):this.activeSubSolver.failed&&(this.error=this.activeSubSolver?.error,this.failed=!0,this.activeSubSolver=null);return}let a=e.getConstructorParams(this);this.activeSubSolver=new e.solverClass(...a),this[e.solverName]=this.activeSubSolver,this.timeSpentOnPhase[e.solverName]=0,this.startTimeOfPhase[e.solverName]=performance.now(),this.firstIterationOfPhase[e.solverName]=this.iterations}solveUntilPhase(e){for(;this.getCurrentPhase().toLowerCase()!==e.toLowerCase();)this.step()}getCurrentPhase(){return this.pipelineDef[this.currentPipelineStepIndex]?.solverName??"none"}visualize(){if(!this.solved&&this.activeSubSolver)return this.activeSubSolver.visualize();let e=[Qp(this.inputProblem),...this.pipelineDef.map(a=>this[a.solverName]?.visualize()).filter(Boolean).map((a,s)=>{for(let l of a.rects??[])l.step=s;for(let l of a.points??[])l.step=s;for(let l of a.circles??[])l.step=s;for(let l of a.texts??[])l.step=s;for(let l of a.lines??[])l.step=s;return a})];return e.length===1?e[0]:{points:e.flatMap(a=>a.points||[]),rects:e.flatMap(a=>a.rects||[]),lines:e.flatMap(a=>a.lines||[]),circles:e.flatMap(a=>a.circles||[]),texts:e.flatMap(a=>a.texts||[])}}preview(){return this.activeSubSolver?this.activeSubSolver.preview():super.preview()}};var jwe=Xr(zs(),1);var Nwe=Xr(zs(),1);Ko();na();Ko();na();na();Yt();na();na();Ko();na();function cSe(n,e,a,s){return Math.sqrt((a-n)**2+(s-e)**2)}var fUt=n=>{let e=n.filter(d=>d.type==="pcb_port"),a=n.filter(d=>d.type==="pcb_smtpad"),s=n.filter(d=>d.type==="pcb_trace");function l(d,x={}){let f=x.traceWidth||0,m=e.find(y=>cSe(y.x,y.y,d.x,d.y)<.01);if(m)return m.pcb_port_id;if(x.isFirstOrLastPoint){let y=a.find(b=>{if(b.shape==="rect")return Math.abs(d.x-b.x)<b.width/2+f/2&&Math.abs(d.y-b.y)<b.height/2+f/2;if(b.shape==="circle")return cSe(d.x,d.y,b.x,b.y)<b.radius});if(y)return y.pcb_port_id??null}return null}for(let d of s)for(let x=0;x<d.route.length;x++){let f=d.route[x],m=x===0||x===d.route.length-1;if(f.route_type==="wire"){if(!f.start_pcb_port_id&&x===0){let y=l(f,{isFirstOrLastPoint:m,traceWidth:f.width});y&&(f.start_pcb_port_id=y)}if(!f.end_pcb_port_id&&x===d.route.length-1){let y=l(f,{isFirstOrLastPoint:m,traceWidth:f.width});y&&(f.end_pcb_port_id=y)}}}};function dSe(n){fUt(n);let e=n.filter(x=>x.type==="source_trace"),a=n.filter(x=>x.type==="pcb_port"),s=[],l=Ku(n),d=new Map;for(let x of a)d.set(x.source_port_id,x);for(let x of e){let f=x.connected_source_port_ids;if(f.length<2)continue;let m=[],y=[];for(let B of f){let I=d.get(B);I?m.push(I):y.push(B)}if(m.length<2)continue;let b=m[0],E=l.getNetConnectedToId(b.pcb_port_id);l.getIdsConnectedToNet(E).filter(B=>n.some(I=>I.type==="pcb_trace"&&("pcb_trace_id"in I&&I.pcb_trace_id===B||"route_id"in I&&I.route_id===B))).length===0&&new Set(m.map(I=>I.pcb_component_id)).size>1&&s.push({type:"pcb_port_not_connected_error",message:`pcb_port_not_connected_error: Pcb ports [${m.map(I=>I.pcb_port_id).join(", ")}] are not connected together through the same net.`,error_type:"pcb_port_not_connected_error",pcb_port_ids:m.map(I=>I.pcb_port_id),pcb_component_ids:m.map(I=>I.pcb_component_id),pcb_port_not_connected_error_id:`pcb_port_not_connected_error_trace_${x.source_trace_id}`})}return s}var hUt=class{constructor({objects:n,getBounds:e,getId:a,CELL_SIZE:s}){X(this,"buckets");X(this,"objectsById");X(this,"getBounds");X(this,"getId");X(this,"CELL_SIZE",.4);X(this,"_idCounter",0);this.buckets=new Map,this.objectsById=new Map,this.getBounds=e,this.getId=a??(()=>this._getNextId()),this.CELL_SIZE=s??this.CELL_SIZE;for(let l of n)this.addObject(l)}_getNextId(){return`${this._idCounter++}`}addObject(n){let e=this.getBounds(n),a=this.getId(n),s={...n,spatialIndexId:a};this.objectsById.set(a,s);let l=Math.floor(e.minX/this.CELL_SIZE),d=Math.floor(e.minY/this.CELL_SIZE),x=Math.floor(e.maxX/this.CELL_SIZE),f=Math.floor(e.maxY/this.CELL_SIZE);for(let m=l;m<=x;m++)for(let y=d;y<=f;y++){let b=`${m}x${y}`,E=this.buckets.get(b);E?E.push(s):this.buckets.set(b,[s])}}removeObject(n){let e=this.objectsById.get(n);if(!e)return!1;this.objectsById.delete(n);let a=this.getBounds(e),s=Math.floor(a.minX/this.CELL_SIZE),l=Math.floor(a.minY/this.CELL_SIZE),d=Math.floor(a.maxX/this.CELL_SIZE),x=Math.floor(a.maxY/this.CELL_SIZE);for(let f=s;f<=d;f++)for(let m=l;m<=x;m++){let y=`${f}x${m}`,b=this.buckets.get(y);if(b){let E=b.findIndex(A=>A.spatialIndexId===n);E!==-1&&(b.splice(E,1),b.length===0&&this.buckets.delete(y))}}return!0}getBucketKey(n,e){return`${Math.floor(n/this.CELL_SIZE)}x${Math.floor(e/this.CELL_SIZE)}`}getObjectsInBounds(n,e=0){let a=[],s=new Set,l=Math.floor((n.minX-e)/this.CELL_SIZE),d=Math.floor((n.minY-e)/this.CELL_SIZE),x=Math.floor((n.maxX+e)/this.CELL_SIZE),f=Math.floor((n.maxY+e)/this.CELL_SIZE);for(let m=l;m<=x;m++)for(let y=d;y<=f;y++){let b=`${m}x${y}`,E=this.buckets.get(b)||[];for(let A of E){let w=A.spatialIndexId;s.has(w)||(s.add(w),a.push(A))}}return a}},SF=n=>n.type==="pcb_trace_segment"?{minX:Math.min(n.x1,n.x2),minY:Math.min(n.y1,n.y2),maxX:Math.max(n.x1,n.x2),maxY:Math.max(n.y1,n.y2)}:OAe([n]),hW=.1,mUt=.15;var mW=.005;function gUt(n){let e=new Set;for(let a of n.route)a.route_type==="wire"&&(a.start_pcb_port_id&&e.add(a.start_pcb_port_id),a.end_pcb_port_id&&e.add(a.end_pcb_port_id));return Array.from(e)}function gW(n){let e=new Set;for(let a of n)for(let s of gUt(a))e.add(s);return Array.from(e)}var yUt=(n,e)=>{let a={x:n.x1,y:n.y1},s={x:n.x2,y:n.y2},l={x:e.x1,y:e.y1},d={x:e.x2,y:e.y2},x={x:s.x-a.x,y:s.y-a.y},f={x:d.x-l.x,y:d.y-l.y},m=x.x*x.x+x.y*x.y,y=f.x*f.x+f.y*f.y;if(m===0||y===0){if(m===0&&y===0)return{x:(a.x+l.x)/2,y:(a.y+l.y)/2};if(m===0){let le=rl(((a.x-l.x)*f.x+(a.y-l.y)*f.y)/y,0,1),z={x:l.x+le*f.x,y:l.y+le*f.y};return{x:(a.x+z.x)/2,y:(a.y+z.y)/2}}let W=rl(((l.x-a.x)*x.x+(l.y-a.y)*x.y)/m,0,1),Q={x:a.x+W*x.x,y:a.y+W*x.y};return{x:(Q.x+l.x)/2,y:(Q.y+l.y)/2}}let b={x:a.x-l.x,y:a.y-l.y},E=x.x*x.x+x.y*x.y,A=x.x*f.x+x.y*f.y,w=x.x*b.x+x.y*b.y,B=f.x*f.x+f.y*f.y,I=f.x*b.x+f.y*b.y,q=E*B-A*A;if(q<1e-10)return DUt(a,s,l,d,x,f,m,y);let G=(A*I-B*w)/q,j=(E*I-A*w)/q;G=rl(G,0,1),j=rl(j,0,1),j=(G*A+I)/B,j=rl(j,0,1),G=(j*A-w)/E,G=rl(G,0,1);let O={x:a.x+G*x.x,y:a.y+G*x.y},V={x:l.x+j*f.x,y:l.y+j*f.y},te=O.x-V.x,N=O.y-V.y,se=Math.sqrt(te*te+N*N);return{x:(O.x+V.x)/2,y:(O.y+V.y)/2}},DUt=(n,e,a,s,l,d,x,f)=>{let m=((a.x-n.x)*l.x+(a.y-n.y)*l.y)/x;m=rl(m,0,1);let y={x:n.x+m*l.x,y:n.y+m*l.y},b=((s.x-n.x)*l.x+(s.y-n.y)*l.y)/x;b=rl(b,0,1);let E={x:n.x+b*l.x,y:n.y+b*l.y},A=((n.x-a.x)*d.x+(n.y-a.y)*d.y)/f;A=rl(A,0,1);let w={x:a.x+A*d.x,y:a.y+A*d.y},B=((e.x-a.x)*d.x+(e.y-a.y)*d.y)/f;B=rl(B,0,1);let I={x:a.x+B*d.x,y:a.y+B*d.y},G=[{pointA:y,pointB:a,distance:Math.sqrt((y.x-a.x)**2+(y.y-a.y)**2)},{pointA:E,pointB:s,distance:Math.sqrt((E.x-s.x)**2+(E.y-s.y)**2)},{pointA:n,pointB:w,distance:Math.sqrt((n.x-w.x)**2+(n.y-w.y)**2)},{pointA:e,pointB:I,distance:Math.sqrt((e.x-I.x)**2+(e.y-I.y)**2)}].reduce((j,O)=>O.distance<j.distance?O:j);return{x:(G.pointA.x+G.pointB.x)/2,y:(G.pointA.y+G.pointB.y)/2}},rl=(n,e,a)=>Math.max(e,Math.min(a,n)),bUt=n=>{if(n.type==="pcb_via"||n.type==="pcb_plated_hole"&&n.shape==="circle")return n.outer_diameter/2;if(n.type==="pcb_hole"&&n.hole_shape==="circle")return n.hole_diameter/2;if(n.type==="pcb_smtpad"&&n.shape==="circle")return n.radius;throw new Error(`Could not determine radius of element: ${JSON.stringify(n)}`)},lSe=(n,e)=>{let a={x:n.x1,y:n.y1},s={x:n.x2,y:n.y2},l=e.minX,d=e.minY,x=e.maxX,f=e.maxY;if(a.x===s.x&&a.y===s.y){let $=Math.max(l,Math.min(x,a.x)),W=Math.max(d,Math.min(f,a.y));return $===a.x&&W===a.y?{x:a.x,y:a.y}:{x:$,y:W}}let m=s.x-a.x,y=s.y-a.y,b=m!==0?(l-a.x)/m:Number.NEGATIVE_INFINITY,E=m!==0?(x-a.x)/m:Number.POSITIVE_INFINITY,A=y!==0?(d-a.y)/y:Number.NEGATIVE_INFINITY,w=y!==0?(f-a.y)/y:Number.POSITIVE_INFINITY,B=Math.max(Math.min(b,E),Math.min(A,w)),I=Math.min(Math.max(b,E),Math.max(A,w));if(B<=I&&I>=0&&B<=1){let $=Math.max(0,Math.min(1,B));return{x:a.x+$*m,y:a.y+$*y}}let q={x:Math.max(l,Math.min(x,a.x)),y:Math.max(d,Math.min(f,a.y))},G={x:Math.max(l,Math.min(x,s.x)),y:Math.max(d,Math.min(f,s.y))},j=(q.x-a.x)**2+(q.y-a.y)**2,O=(G.x-s.x)**2+(G.y-s.y)**2,V=[{start:{x:l,y:d},end:{x,y:d}},{start:{x,y:d},end:{x,y:f}},{start:{x,y:f},end:{x:l,y:f}},{start:{x:l,y:f},end:{x:l,y:d}}],te=Math.min(j,O),N=j<=O?q:G,se=($,W,Q)=>Math.max(W,Math.min(Q,$));for(let $ of V){let W={x:s.x-a.x,y:s.y-a.y},Q={x:$.end.x-$.start.x,y:$.end.y-$.start.y},le={x:a.x-$.start.x,y:a.y-$.start.y},z=W.x*W.x+W.y*W.y,pe=W.x*Q.x+W.y*Q.y,xe=W.x*le.x+W.y*le.y,Ae=Q.x*Q.x+Q.y*Q.y,Ie=Q.x*le.x+Q.y*le.y,Le=z*Ae-pe*pe;if(Math.abs(Le)<1e-10)continue;let dt=(pe*Ie-Ae*xe)/Le,rt=(z*Ie-pe*xe)/Le;dt=se(dt,0,1),rt=se(rt,0,1);let et={x:a.x+dt*W.x,y:a.y+dt*W.y},Qe={x:$.start.x+rt*Q.x,y:$.start.y+rt*Q.y},Mt=et.x-Qe.x,Pt=et.y-Qe.y,Ht=Mt*Mt+Pt*Pt;Ht<te&&(te=Ht,N={x:(et.x+Qe.x)/2,y:(et.y+Qe.y)/2})}return N};function FUt(n){return n.type==="pcb_trace_segment"?[n.layer]:n.type==="pcb_smtpad"?[n.layer]:n.type==="pcb_plated_hole"?Array.isArray(n.layers)?n.layers:[...Om]:n.type==="pcb_hole"?[...Om]:n.type==="pcb_via"?Array.isArray(n.layers)?n.layers:[...Om]:n.type==="pcb_keepout"?Array.isArray(n.layers)?n.layers:[]:[]}function pSe(n,{connMap:e}={}){let a=[];e??(e=Ku(n));let l=ka(n).pcb_trace.list().flatMap(B=>{let I=[];for(let q=0;q<B.route.length-1;q++){let G=B.route[q],j=B.route[q+1];G.route_type==="wire"&&j.route_type==="wire"&&G.layer===j.layer&&I.push({type:"pcb_trace_segment",pcb_trace_id:B.pcb_trace_id,_pcbTrace:B,thickness:"width"in G?G.width:"width"in j?j.width:mUt,layer:G.layer,x1:G.x,y1:G.y,x2:j.x,y2:j.y})}return I}),d=ka(n).pcb_smtpad.list(),x=ka(n).pcb_plated_hole.list(),f=ka(n).pcb_hole.list(),m=ka(n).pcb_via.list(),y=ka(n).pcb_keepout.list(),b=[...l,...d,...x,...f,...m,...y],E=new hUt({objects:b,getBounds:SF}),A=B=>Vb(n,B),w=new Set;for(let B of l){let I=hW,q=SF(B),G=E.getObjectsInBounds(q,I+B.thickness/2);if(!(B.x1===B.x2&&B.y1===B.y2))for(let j of G){if(!FUt(j).includes(B.layer))continue;if(j.type==="pcb_trace_segment"){let N=j;if(B.layer!==N.layer||e.areIdsConnected(B.pcb_trace_id,N.pcb_trace_id))continue;let se=l5({x:B.x1,y:B.y1},{x:B.x2,y:B.y2},{x:N.x1,y:N.y1},{x:N.x2,y:N.y2})-B.thickness/2-N.thickness/2;if(se>hW-mW)continue;let $=`overlap_${B.pcb_trace_id}_${N.pcb_trace_id}`,W=`overlap_${N.pcb_trace_id}_${B.pcb_trace_id}`;if(w.has($)||w.has(W))continue;w.add($),a.push({type:"pcb_trace_error",error_type:"pcb_trace_error",message:`PCB trace ${A(B.pcb_trace_id)} overlaps with ${A(N.pcb_trace_id)} ${se<0?"(accidental contact)":`(gap: ${se.toFixed(3)}mm)`}`,pcb_trace_id:B.pcb_trace_id,source_trace_id:"",pcb_trace_error_id:$,pcb_component_ids:[],center:yUt(B,N),pcb_port_ids:gW([B._pcbTrace,N._pcbTrace])});continue}let O=h5(j);if(e.areIdsConnected(B.pcb_trace_id,"pcb_trace_id"in j?j.pcb_trace_id:O))continue;if(j.type==="pcb_via"||j.type==="pcb_plated_hole"&&j.shape==="circle"||j.type==="pcb_hole"||j.type==="pcb_smtpad"&&j.shape==="circle"){let N=bUt(j),$=d5({x:B.x1,y:B.y1},{x:B.x2,y:B.y2},{x:j.x,y:j.y,radius:N})-B.thickness/2;if($>hW-mW)continue;let W=`overlap_${B.pcb_trace_id}_${O}`;if(w.has(W))continue;w.add(W),a.push({type:"pcb_trace_error",error_type:"pcb_trace_error",message:`PCB trace ${A(B.pcb_trace_id)} overlaps with ${j.type} "${A(h5(j))}" ${$<0?"(accidental contact)":`(gap: ${$.toFixed(3)}mm)`}`,pcb_trace_id:B.pcb_trace_id,center:lSe(B,SF(j)),source_trace_id:"",pcb_trace_error_id:W,pcb_component_ids:["pcb_component_id"in j?j.pcb_component_id:void 0].filter(Boolean),pcb_port_ids:[...gW([B._pcbTrace]),"pcb_port_id"in j?j.pcb_port_id:void 0].filter(Boolean)})}let te=zb({x:B.x1,y:B.y1},{x:B.x2,y:B.y2},SF(j))-B.thickness/2;if(te+mW<I){let N=`overlap_${B.pcb_trace_id}_${O}`;if(w.has(N))continue;w.add(N),a.push({type:"pcb_trace_error",error_type:"pcb_trace_error",message:`PCB trace ${A(B.pcb_trace_id)} overlaps with ${j.type} "${A(h5(j))}" ${te<0?"(accidental contact)":`(gap: ${te.toFixed(3)}mm)`}`,pcb_trace_id:B.pcb_trace_id,source_trace_id:"",pcb_trace_error_id:N,pcb_component_ids:["pcb_component_id"in j?j.pcb_component_id:void 0].filter(Boolean),center:lSe(B,SF(j)),pcb_port_ids:[...gW([B._pcbTrace]),"pcb_port_id"in j?j.pcb_port_id:void 0].filter(Boolean)})}}}return a}var yW=[{value:1e12,symbol:"T"},{value:1e9,symbol:"G"},{value:1e6,symbol:"M"},{value:1e3,symbol:"k"},{value:1,symbol:""},{value:.001,symbol:"m"},{value:1e-6,symbol:"\xB5"},{value:1e-9,symbol:"n"},{value:1e-12,symbol:"p"}];function Is(n){if(n==null)return"";if(n===0)return"0";let e=Math.abs(n),a=yW.find(d=>{let x=e/d.value;return x>=1&&x<1e3})||yW[yW.length-1],l=(n/a.value).toPrecision(3);return l.includes(".")&&!/\.0+$/.test(l)&&(l=l.replace(/0+$/,"")),l=l.replace(/\.0+$/,""),`${l}${a.symbol}`}Yt();He();Wl();na();var D9e=Xr(z0(),1);var Lg=Xr(z0(),1),Egr=Xr(z0(),1);var B1=Xr(_1(),1);var b9e=Xr(_1(),1),F9e=Xr(_1(),1);var E9e=Xr(_1(),1);var v9e=Xr(_1(),1);var C9e=Xr(_1(),1),_9e=Xr(z0(),1);var UVt=Object.defineProperty,VVt=(n,e)=>{for(var a in e)UVt(n,a,{get:e[a],enumerable:!0})},hwe={};VVt(hwe,{Battery:()=>n9e,Board:()=>kwe,Breakout:()=>Kwe,BreakoutPoint:()=>Jwe,Capacitor:()=>Mwe,Chip:()=>HW,Constraint:()=>Xwe,Crystal:()=>c9e,Cutout:()=>$F,Diode:()=>Owe,FabricationNotePath:()=>Ywe,FabricationNoteText:()=>Hwe,Footprint:()=>_we,Fuse:()=>Lwe,Group:()=>zg,Hole:()=>VW,Inductor:()=>i9e,Jumper:()=>$we,Keepout:()=>qS,Led:()=>qwe,Mosfet:()=>d9e,Net:()=>$W,NetLabel:()=>Zwe,NormalComponent:()=>Za,PcbTrace:()=>UW,PinHeader:()=>a9e,PlatedHole:()=>zS,Port:()=>Fo,Potentiometer:()=>o9e,PowerSource:()=>Uwe,PrimitiveComponent:()=>ga,PushButton:()=>u9e,Renderable:()=>OW,Resistor:()=>Gwe,Resonator:()=>s9e,SchematicBox:()=>h9e,SchematicCell:()=>y9e,SchematicRow:()=>g9e,SchematicTable:()=>m9e,SchematicText:()=>f9e,SilkscreenCircle:()=>Qwe,SilkscreenLine:()=>t9e,SilkscreenPath:()=>qW,SilkscreenRect:()=>e9e,SilkscreenText:()=>XS,SmtPad:()=>$S,SolderJumper:()=>zwe,Subcircuit:()=>Wwe,Switch:()=>p9e,TestPoint:()=>x9e,Trace:()=>zc,TraceHint:()=>YW,Transistor:()=>l9e,Via:()=>r9e,VoltageSource:()=>Vwe});var GVt=(0,ywe.default)("tscircuit:renderable"),ud=["ReactSubtreesRender","PcbFootprintStringRender","InitializePortsFromChildren","CreateNetsFromProps","AssignFallbackProps","CreateTracesFromProps","CreateTracesFromNetLabels","CreateTraceHintsFromProps","SourceGroupRender","AssignNameToUnnamedComponents","SourceRender","SourceParentAttachment","PortMatching","OptimizeSelectorCache","SourceTraceRender","SourceAddConnectivityMapKey","SourceDesignRuleChecks","SimulationRender","SchematicComponentRender","SchematicPortRender","SchematicPrimitiveRender","SchematicLayout","SchematicTraceRender","SchematicReplaceNetLabelsWithSymbols","PcbComponentRender","PcbPrimitiveRender","PcbFootprintLayout","PcbPortRender","PcbPortAttachment","PcbComponentSizeCalculation","PcbLayout","PcbBoardAutoSize","PcbTraceHintRender","PcbManualTraceRender","PcbTraceRender","PcbRouteNetIslands","PcbDesignRuleChecks","CadModelRender","PartsEngineRender"],XVt=0,OW=class{constructor(n){X(this,"renderPhaseStates");X(this,"shouldBeRemoved",!1);X(this,"children");X(this,"isPcbPrimitive",!1);X(this,"isSchematicPrimitive",!1);X(this,"_renderId");X(this,"_currentRenderPhase",null);X(this,"_asyncEffects",[]);X(this,"parent",null);this._renderId=`${XVt++}`,this.children=[],this.renderPhaseStates={};for(let e of ud)this.renderPhaseStates[e]={initialized:!1,dirty:!1}}_markDirty(n){this.renderPhaseStates[n].dirty=!0;let e=ud.indexOf(n);for(let a=e+1;a<ud.length;a++)this.renderPhaseStates[ud[a]].dirty=!0;this.parent?._markDirty&&this.parent._markDirty(n)}_queueAsyncEffect(n,e){let a={promise:e(),phase:this._currentRenderPhase,effectName:n,complete:!1};this._asyncEffects.push(a),"root"in this&&this.root&&this.root.emit("asyncEffect:start",{effectName:n,componentDisplayName:this.getString(),phase:a.phase}),a.promise.then(()=>{a.complete=!0,"root"in this&&this.root&&this.root.emit("asyncEffect:end",{effectName:n,componentDisplayName:this.getString(),phase:a.phase})}).catch(s=>{console.error(`Async effect error in ${a.phase} "${n}":
1077
- ${s.stack}`),a.complete=!0,"root"in this&&this.root&&this.root.emit("asyncEffect:end",{effectName:n,componentDisplayName:this.getString(),phase:a.phase,error:s.toString()})})}_emitRenderLifecycleEvent(n,e){GVt(`${n}:${e} ${this.getString()}`);let a=`renderable:renderLifecycle:${n}:${e}`,s={renderId:this._renderId,componentDisplayName:this.getString(),type:a};"root"in this&&this.root&&(this.root.emit(a,s),this.root.emit("renderable:renderLifecycle:anyEvent",{...s,type:a}))}getString(){return this.constructor.name}_hasIncompleteAsyncEffects(){return this._asyncEffects.some(n=>!n.complete)}getCurrentRenderPhase(){return this._currentRenderPhase}getRenderGraph(){return{id:this._renderId,currentPhase:this._currentRenderPhase,renderPhaseStates:this.renderPhaseStates,shouldBeRemoved:this.shouldBeRemoved,children:this.children.map(n=>n.getRenderGraph())}}runRenderCycle(){for(let n of ud)this.runRenderPhaseForChildren(n),this.runRenderPhase(n)}runRenderPhase(n){this._currentRenderPhase=n;let e=this.renderPhaseStates[n],a=e.initialized,s=e.dirty;if(!a&&this.shouldBeRemoved)return;if(this.shouldBeRemoved&&a){this._emitRenderLifecycleEvent(n,"start"),this?.[`remove${n}`]?.(),e.initialized=!1,e.dirty=!1,this._emitRenderLifecycleEvent(n,"end");return}let l=ud.indexOf(n)-1;if(l>=0){let d=ud[l];if(this._asyncEffects.filter(f=>f.phase===d).some(f=>!f.complete))return}if(this._emitRenderLifecycleEvent(n,"start"),a){s&&(this?.[`update${n}`]?.(),e.dirty=!1),this._emitRenderLifecycleEvent(n,"end");return}e.dirty=!1,this?.[`doInitial${n}`]?.(),e.initialized=!0,this._emitRenderLifecycleEvent(n,"end")}runRenderPhaseForChildren(n){for(let e of this.children)e.runRenderPhaseForChildren(n),e.runRenderPhase(n)}renderError(n){throw typeof n=="string"?new Error(n):new Error(JSON.stringify(n,null,2))}},LS={},Dwe=n=>{let e=Object.fromEntries(Object.entries(n).map(([a,s])=>[a.toLowerCase(),s]));Object.assign(LS,n),Object.assign(LS,e)},YVt=class extends Error{constructor(n,e,a){let s,l=Object.keys(a).filter(m=>m!=="_errors"),d=[],x=e.pinLabels;if(x)for(let[m,y]of Object.entries(x)){let b=Array.isArray(y)?y:[y];for(let E of b)typeof E=="string"&&(E.startsWith(" ")||E.endsWith(" "))&&d.push(`pinLabels.${m} ("${E}" has leading or trailing spaces)`)}let f=l.map(m=>m==="pinLabels"&&d.length>0?d.join(", "):a[m]._errors[0]?`${m} (${a[m]._errors[0]})`:`${m} (${JSON.stringify(a[m])})`).join(", ");"name"in e?s=`Invalid props for ${n} "${e.name}": ${f}`:"footprint"in e&&typeof e.footprint=="string"?s=`Invalid props for ${n} (unnamed ${e.footprint} component): ${f}`:s=`Invalid props for ${n} (unnamed): ${f}`,super(s),this.componentName=n,this.originalProps=e,this.formattedError=a}};function SW(n,e){let a=e.match(/^#(\w+)/);if(a)return n.props.id===a[1];let s=e.match(/^\.(\w+)/);if(s)return n.isMatchingNameOrAlias(s[1]);let[l,...d]=e.split(/(?=[#.[])/);return l==="pin"&&(l="port"),l&&l!=="*"&&n.lowercaseComponentName!==l.toLowerCase()?!1:d.every(x=>{if(x.startsWith("#"))return n.props.id===x.slice(1);if(x.startsWith("."))return n.isMatchingNameOrAlias(x.slice(1));let f=x.match(/\[(\w+)=['"]?(.+?)['"]?\]/);if(!f)return!0;let[,m,y]=f;return n.props[m].toString()===y})}var LW={isTag:n=>!0,getParent:n=>n.parent,getChildren:n=>n.children,getName:n=>n.lowercaseComponentName,getAttributeValue:(n,e)=>{if(e==="class"&&"getNameAndAliases"in n)return n.getNameAndAliases().join(" ");if(e==="name"&&n._parsedProps?.name)return n._parsedProps.name;if(n._parsedProps&&e in n._parsedProps){let a=n._parsedProps[e];return typeof a=="string"?a:a!=null?String(a):null}return null},hasAttrib:(n,e)=>e==="class"?!!n._parsedProps?.name:n._parsedProps&&e in n._parsedProps,getSiblings:n=>n.parent?n.parent.children:[],prevElementSibling:n=>{if(!n.parent)return null;let e=n.parent.children,a=e.indexOf(n);return a>0?e[a-1]:null},getText:()=>"",removeSubsets:n=>n.filter((e,a)=>!n.some((s,l)=>a!==l&&s!==e&&s.getDescendants().includes(e))),existsOne:(n,e)=>e.some(n),findAll:(n,e)=>{let a=[],s=l=>{n(l)&&a.push(l);for(let d of l.children)s(d)};for(let l of e)s(l);return a},findOne:(n,e)=>{for(let a of e){if(n(a))return a;let s=a.children;if(s.length>0){let l=LW.findOne(n,s);if(l)return l}}return null},equals:(n,e)=>n._renderId===e._renderId,isHovered:n=>!1,isVisited:n=>!1,isActive:n=>!1},HVt={...LW,getChildren:n=>n.children.filter(e=>!e.isSubcircuit)},WSe={...LW,getChildren:n=>n.children.filter(e=>e.isSubcircuit)},KSe=n=>{if(/net\.[^\s>]*\./.test(n))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(n))throw new Error('Net names cannot contain "+" or "-", try using underscores instead, e.g. VCC_P');if(/net\.[0-9]/.test(n)){let e=n.match(/net\.([^ >]+)/),a=e?e[1]:"";throw new Error(`Net name "${a}" cannot start with a number, try using a prefix like "VBUS1"`)}return n.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,(e,a,s,l)=>{let d=/^\d+$/.test(l)?`pin${l}`:l;return`${a}.${s} > .${d}`}).trim()},wW={adapter:HVt,cacheResults:!0},ga=class extends OW{constructor(e){super(e);X(this,"parent",null);X(this,"children");X(this,"childrenPendingRemoval");X(this,"props");X(this,"_parsedProps");X(this,"externallyAddedAliases");X(this,"isPrimitiveContainer",!1);X(this,"canHaveTextChildren",!1);X(this,"source_group_id",null);X(this,"source_component_id",null);X(this,"schematic_component_id",null);X(this,"pcb_component_id",null);X(this,"cad_component_id",null);X(this,"fallbackUnassignedName");X(this,"_cachedSelectAllQueries",new Map);X(this,"_cachedSelectOneQueries",new Map);this.children=[],this.childrenPendingRemoval=[],this.props=e??{},this.externallyAddedAliases=[];let s=("partial"in this.config.zodProps?this.config.zodProps.partial({name:!0}):this.config.zodProps).safeParse(e??{});if(s.success)this._parsedProps=s.data;else throw new YVt(this.lowercaseComponentName,this.props,s.error.format())}get config(){return{componentName:"",zodProps:C.object({}).passthrough()}}get componentName(){return this.config.componentName}getInheritedProperty(e){let a=this;for(;a;){if(a._parsedProps&&e in a._parsedProps)return a._parsedProps[e];a=a.parent}if(this.root?.platform&&e in this.root.platform)return this.root.platform[e]}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(e){let a=this.config.zodProps.parse({...this.props,...e}),s=this.props;this.props=a,this._parsedProps=this.config.zodProps.parse(e),this.onPropsChange({oldProps:s,newProps:a,changedProps:Object.keys(e)}),this.parent?.onChildChanged?.(this)}computePcbPropsTransform(){let{_parsedProps:e}=this;return Bs(ja(e.pcbX??0,e.pcbY??0),Kf((e.pcbRotation??0)*Math.PI/180))}_computePcbGlobalTransformBeforeLayout(){let{_parsedProps:e}=this,a=this.getSubcircuit()._getPcbManualPlacementForComponent(this);if(a&&this.props.pcbX===void 0&&this.props.pcbY===void 0)return Bs(this.parent?._computePcbGlobalTransformBeforeLayout()??go(),Bs(ja(a.x,a.y),Kf((e.pcbRotation??0)*Math.PI/180)));if(this.isPcbPrimitive){let s=this.getPrimitiveContainer();if(s){let l=s._parsedProps.layer==="bottom",d=s._getGlobalPcbPositionBeforeLayout();if(l){let x=Bs(ja(d.x,d.y),$q(),ja(-d.x,-d.y));return Bs(this.parent?._computePcbGlobalTransformBeforeLayout()??go(),$q(),this.computePcbPropsTransform())}}}return Bs(this.parent?._computePcbGlobalTransformBeforeLayout()??go(),this.computePcbPropsTransform())}getPrimitiveContainer(){return this.isPrimitiveContainer?this:this.parent?.getPrimitiveContainer?.()??null}_getPcbCircuitJsonBounds(){return{center:{x:0,y:0},bounds:{left:0,top:0,right:0,bottom:0},width:0,height:0}}_getPcbPrimitiveFlippedHelpers(){let e=this.getPrimitiveContainer(),a=e?e._parsedProps.layer==="bottom":!1;return{isFlipped:a,maybeFlipLayer:l=>a?l==="top"?"bottom":"top":l}}_setPositionFromLayout(e){throw new Error(`_setPositionFromLayout not implemented for ${this.componentName}`)}computeSchematicPropsTransform(){let{_parsedProps:e}=this;return Bs(ja(e.schX??0,e.schY??0))}computeSchematicGlobalTransform(){let e=this._getSchematicGlobalManualPlacementTransform(this);return e||Bs(this.parent?.computeSchematicGlobalTransform?.()??go(),this.computeSchematicPropsTransform())}_getSchematicSymbolName(){let{_parsedProps:e}=this,a=this.config.schematicSymbolName,s={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},l=e.schOrientation!==void 0?s[e.schOrientation]:e.schRotation;if(l===void 0&&(l=0),l=l%360,l<0&&(l+=360),e.schRotation!==void 0&&l%90!==0)throw new Error(`Schematic rotation ${e.schRotation} is not supported for ${this.componentName}`);let d=`${a}_horz`,x=`${a}_vert`,f=`${a}_up`,m=`${a}_down`,y=`${a}_left`,b=`${a}_right`;if(b in Ts&&l===0)return b;if(f in Ts&&l===90)return f;if(y in Ts&&l===180)return y;if(m in Ts&&l===270)return m;if(d in Ts&&(l===0||l===180))return d;if(x in Ts&&(l===90||l===270))return x;if(a in Ts)return a}_getSchematicSymbolNameOrThrow(){let e=this._getSchematicSymbolName();if(!e)throw new Error(`No schematic symbol found (given: "${this.config.schematicSymbolName}")`);return e}getSchematicSymbol(){let e=this._getSchematicSymbolName();return e?Ts[e]??null:null}_getPcbManualPlacementForComponent(e){if(!this.isSubcircuit)return null;let a=this.props.manualEdits;if(!a)return null;let s=a?.pcb_placements;if(!s)return null;for(let l of s)if(SW(e,l.selector)||e.props.name===l.selector)return vs(this._computePcbGlobalTransformBeforeLayout(),l.center);return null}_getSchematicManualPlacementForComponent(e){if(!this.isSubcircuit)return null;let a=this.props.manualEdits;if(!a)return null;let s=a.schematic_placements;if(!s)return null;for(let l of s)if(SW(e,l.selector)||e.props.name===l.selector)return vs(this.computeSchematicGlobalTransform(),l.center);return null}_getSchematicGlobalManualPlacementTransform(e){let a=this.getSubcircuit()?._parsedProps.manualEdits;if(!a)return null;for(let s of a.schematic_placements??[])if((SW(e,s.selector)||e.props.name===s.selector)&&s.relative_to==="group_center")return Bs(this.parent?._computePcbGlobalTransformBeforeLayout()??go(),ja(s.center.x,s.center.y));return null}_getGlobalPcbPositionBeforeLayout(){return vs(this._computePcbGlobalTransformBeforeLayout(),{x:0,y:0})}_getGlobalSchematicPositionBeforeLayout(){return vs(this.computeSchematicGlobalTransform(),{x:0,y:0})}get root(){return this.parent?.root??null}onAddToParent(e){this.parent=e}onPropsChange(e){}onChildChanged(e){this.parent?.onChildChanged?.(e)}add(e){let a=e.__text;if(typeof a=="string"){if(this.canHaveTextChildren||a.trim()==="")return;throw new Error(`Invalid JSX Element: Expected a React component but received text "${a}"`)}if(Object.keys(e).length!==0){if(this.lowercaseComponentName==="board"&&e.lowercaseComponentName==="board")throw new Error("Nested boards are not supported");if(!e.onAddToParent)throw new Error(`Invalid JSX Element: Expected a React component but received "${JSON.stringify(e)}"`);e.onAddToParent(this),e.parent=this,this.children.push(e)}}addAll(e){for(let a of e)this.add(a)}remove(e){this.children=this.children.filter(a=>a!==e),this.childrenPendingRemoval.push(e),e.shouldBeRemoved=!0}getSubcircuitSelector(){let e=this.name,a=e?`${this.lowercaseComponentName}.${e}`:this.lowercaseComponentName;return!this.parent||this.parent.isSubcircuit?a:`${this.parent.getSubcircuitSelector()} > ${a}`}getFullPathSelector(){let e=this.name,a=e?`${this.lowercaseComponentName}.${e}`:this.lowercaseComponentName,s=this.parent?.getFullPathSelector?.();return s?`${s} > ${a}`:a}getNameAndAliases(){return[this.name,...this._parsedProps.portHints??[]].filter(Boolean)}isMatchingNameOrAlias(e){return this.getNameAndAliases().includes(e)}isMatchingAnyOf(e){return this.getNameAndAliases().some(a=>e.map(s=>s.toString()).includes(a))}getPcbSize(){throw new Error(`getPcbSize not implemented for ${this.componentName}`)}doesSelectorMatch(e){let a=[this.componentName,this.lowercaseComponentName],s=[this.name].filter(Boolean),l=e.trim().split(/\> /)[0],d=l[0];return l.length>1?!1:!!(e==="*"||e[0]==="#"&&e.slice(1)===this.props.id||e[0]==="."&&s.includes(e.slice(1))||/^[a-zA-Z0-9_]/.test(d)&&a.includes(d))}getSubcircuit(){if(this.isSubcircuit)return this;let e=this.parent?.getSubcircuit?.();if(!e)throw new Error("Component is not inside an opaque group (no board?)");return e}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 e=this.selectAll("port");for(let a of e){let s=a.parent?.getNameAndAliases(),l=a.getNameAndAliases();if(s)for(let d of s)for(let x of l){let f=[`.${d} > .${x}`,`.${d} .${x}`];for(let m of f){let y=this._cachedSelectAllQueries.get(m);y?y.push(a):this._cachedSelectAllQueries.set(m,[a])}}}for(let[a,s]of this._cachedSelectAllQueries.entries())s.length===1&&this._cachedSelectOneQueries.set(a,s[0])}selectAll(e){if(this._cachedSelectAllQueries.has(e))return this._cachedSelectAllQueries.get(e);let a=KSe(e),s=JX(a,this,wW);if(s.length>0)return this._cachedSelectAllQueries.set(e,s),s;let[l,...d]=a.split(" "),x=XR(l,this,{adapter:WSe});if(!x)return[];let f=x.selectAll(d.join(" "));return this._cachedSelectAllQueries.set(e,f),f}selectOne(e,a){if(this._cachedSelectOneQueries.has(e))return this._cachedSelectOneQueries.get(e);let s=KSe(e);a?.port&&(a.type="port");let l=null;if(a?.type&&(l=JX(s,this,wW).find(y=>y.lowercaseComponentName===a.type)),l??(l=XR(s,this,wW)),l)return this._cachedSelectOneQueries.set(e,l),l;let[d,...x]=s.split(" "),f=XR(d,this,{adapter:WSe});return f?(l=f.selectOne(x.join(" "),a),this._cachedSelectOneQueries.set(e,l),l):null}getAvailablePcbLayers(){if(this.isPcbPrimitive){let{maybeFlipLayer:e}=this._getPcbPrimitiveFlippedHelpers();return"layer"in this._parsedProps||this.componentName==="SmtPad"?[e(this._parsedProps.layer??"top")]:"layers"in this._parsedProps?this._parsedProps.layers:this.componentName==="PlatedHole"?this.root?._getBoard()?.allLayers??["top","bottom"]:[]}return[]}getDescendants(){let e=[];for(let a of this.children)e.push(a),e.push(...a.getDescendants());return e}getSelectableDescendants(){let e=[];for(let a of this.children)a.isSubcircuit?e.push(a):(e.push(a),e.push(...a.getSelectableDescendants()));return e}_getPinCount(){return 0}_getSchematicBoxDimensions(){return null}_getSchematicBoxComponentDimensions(){if(this.getSchematicSymbol()||!this.config.shouldRenderAsSchematicBox)return null;let{_parsedProps:e}=this;return{schWidth:e.schWidth,schHeight:e.schHeight}}renderError(e){if(typeof e=="string")return super.renderError(e);this.root?.db.pcb_placement_error.insert(e)}getString(){let{lowercaseComponentName:e,_parsedProps:a,parent:s}=this;return a?.pinNumber!==void 0&&s?.props?.name&&a?.name?`<${e}#${this._renderId}(pin:${a.pinNumber} .${s?.props.name}>.${a.name}) />`:s?.props?.name&&a?.name?`<${e}#${this._renderId}(.${s?.props.name}>.${a?.name}) />`:a?.from&&a?.to?`<${e}#${this._renderId}(from:${a.from} to:${a?.to}) />`:a?.name?`<${e}#${this._renderId} name=".${a?.name}" />`:a?.portHints?`<${e}#${this._renderId}(${a.portHints.map(l=>`.${l}`).join(", ")}) />`:`<${e}#${this._renderId} />`}get[Symbol.toStringTag](){return this.getString()}[Symbol.for("nodejs.util.inspect.custom")](){return this.getString()}},WVt=class extends ga{constructor(n,e){super(n),this._parsedProps={...n,error:e,type:n.type||"unknown",component_name:n.name,error_type:"source_failed_to_create_component_error",message:e instanceof Error?e.message:String(e),pcbX:n.pcbX,pcbY:n.pcbY,schX:n.schX,schY:n.schY}}get config(){return{componentName:"ErrorPlaceholder",zodProps:C.object({}).passthrough()}}doInitialSourceRender(){if(this.root?.db){let n=this._getGlobalPcbPositionBeforeLayout(),e=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:n,schematic_center:e})}}};function KVt(n,e){return new WVt(n,e)}function JVt(n,e){let a=n;return a.__tsci={...e},n}var ZVt={supportsMutation:!0,createInstance(n,e){let a=LS[n];if(!a)throw Object.keys(LS).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 "${n}". 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 JVt(new a(e),{})}catch(s){return KVt({...e,componentType:n},s)}},createTextInstance(n){return{__text:n}},appendInitialChild(n,e){n.add(e)},appendChild(n,e){n.add(e)},appendChildToContainer(n,e){n.add(e)},finalizeInitialChildren(){return!1},prepareUpdate(){return null},shouldSetTextContent(){return!1},getRootHostContext(){return{}},getChildHostContext(){return{}},prepareForCommit(){return null},resetAfterCommit(){},commitMount(){},commitUpdate(){},removeChild(){},clearContainer(){},supportsPersistence:!1,getPublicInstance(n){return n},preparePortalMount(n){throw new Error("Function not implemented.")},scheduleTimeout(n,e){throw new Error("Function not implemented.")},cancelTimeout(n){throw new Error("Function not implemented.")},noTimeout:void 0,isPrimaryRenderer:!1,getInstanceFromNode(n){throw new Error("Function not implemented.")},beforeActiveInstanceBlur(){throw new Error("Function not implemented.")},afterActiveInstanceBlur(){throw new Error("Function not implemented.")},prepareScopeUpdate:(n,e)=>{throw new Error("Function not implemented.")},getInstanceFromScope:n=>{throw new Error("Function not implemented.")},detachDeletedInstance:n=>{throw new Error("Function not implemented.")},getCurrentEventPriority:()=>MS.DefaultEventPriority,getCurrentUpdatePriority:()=>MS.DefaultEventPriority,resolveUpdatePriority:()=>MS.DefaultEventPriority,setCurrentUpdatePriority:()=>{},maySuspendCommit:()=>!1,supportsHydration:!1},jS=(0,gwe.default)(ZVt),bwe=n=>{let e={children:[],props:{name:"$root"},add(d){d.parent=this,this.children.push(d)},computePcbGlobalTransform(){return go()}},a=[],s=jS.createContainer(e,0,null,!1,null,"tsci",d=>{console.log("Error in createContainer"),console.error(d),a.push(d)},null);if(jS.updateContainerSync(n,s,null,()=>{}),jS.flushSyncWork(),a.length>0)throw a[0];let l=jS.getPublicRootInstance(s);return l||e.children[0]},zF=(n,e)=>{if(typeof n=="number")return n;if(n.startsWith("pin"))return Number(n.slice(3));if(!e)throw new Error(`No pin labels provided and pin number or label is not a number: "${n}"`);for(let a in e)if((Array.isArray(e[a])?e[a]:[e[a]]).includes(n))return Number(a.replace("pin",""));throw new Error(`No pin labels provided and pin number or label is not a number: "${n}"`)},QVt=(n,e)=>{if(!n)return;let a={},s={};for(let[l,d]of Object.entries(n)){let x=zF(l,e);s[x]={...s[x],...d}}for(let[l,d]of Object.entries(s)){let x=`pin${l}`;a[x]={bottom_margin:d.bottomMargin,left_margin:d.leftMargin,right_margin:d.rightMargin,top_margin:d.topMargin}}return a},eGt=n=>{if(n){if("leftSide"in n||"rightSide"in n||"topSide"in n||"bottomSide"in n)return{left_side:n.leftSide,right_side:n.rightSide,top_side:n.topSide,bottom_side:n.bottomSide};if("leftPinCount"in n||"rightPinCount"in n||"topPinCount"in n||"bottomPinCount"in n)return{left_size:n.leftPinCount,right_size:n.rightPinCount,top_size:n.topPinCount,bottom_size:n.bottomPinCount};if("leftSize"in n||"rightSize"in n||"topSize"in n||"bottomSize"in n)return{left_size:n.leftSize,right_size:n.rightSize,top_size:n.topSize,bottom_size:n.bottomSize}}};function Fwe(n){let e=[];for(let a=0;a<n.length-1;a++)e.push([n[a],n[a+1]]);return e}var tGt=C.object({name:C.string().refine(n=>!/[+-]/.test(n),'Net names cannot contain "+" or "-", try using underscores instead, e.g. VCC_P')}),$W=class extends ga{constructor(){super(...arguments);X(this,"source_net_id")}get config(){return{componentName:"Net",zodProps:tGt}}getPortSelector(){return`net.${this.props.name}`}doInitialSourceRender(){let{db:e}=this.root,{_parsedProps:a}=this,s=e.source_net.insert({name:a.name,member_source_group_ids:[]});this.source_net_id=s.source_net_id}doInitialSourceParentAttachment(){let e=this.getSubcircuit();if(!e)return;let{db:a}=this.root;a.source_net.update(this.source_net_id,{subcircuit_id:e.subcircuit_id})}getAllConnectedPorts(){let e=this.getSubcircuit().selectAll("port"),a=[];for(let s of e){let l=s._getDirectlyConnectedTraces();for(let d of l)if(d._isExplicitlyConnectedToNet(this)){a.push(s);break}}return a}_getAllDirectlyConnectedTraces(){let e=this.getSubcircuit().selectAll("trace"),a=[];for(let s of e)s._isExplicitlyConnectedToNet(this)&&a.push(s);return a}doInitialPcbRouteNetIslands(){if(this.root?.pcbDisabled||this.getSubcircuit()._parsedProps.routingDisabled||this.getSubcircuit()._getAutorouterConfig().groupMode!=="sequential-trace")return;let{db:e}=this.root,{_parsedProps:a}=this,s=this._getAllDirectlyConnectedTraces().filter(x=>(x._portsRoutedOnPcb?.length??0)>0),l=[];for(let x of s){let f=x._portsRoutedOnPcb,m=l.find(y=>f.some(b=>y.ports.includes(b)));if(!m){l.push({ports:[...f],traces:[x]});continue}m.traces.push(x),m.ports.push(...f)}if(l.length===0)return;let d=Fwe(l);for(let[x,f]of d){let m=x.ports.map(G=>G._getGlobalPcbPositionBeforeLayout()),y=f.ports.map(G=>G._getGlobalPcbPositionBeforeLayout()),b=1/0,E=[-1,-1];for(let G=0;G<m.length;G++){let j=m[G];for(let O=0;O<y.length;O++){let V=y[O],te=Math.sqrt((j.x-V.x)**2+(j.y-V.y)**2);te<b&&(b=te,E=[G,O])}}let A=x.ports[E[0]],w=f.ports[E[1]],B=e.toArray().filter(G=>G.type==="pcb_smtpad"||G.type==="pcb_trace"||G.type==="pcb_plated_hole"||G.type==="pcb_hole"||G.type==="source_port"||G.type==="pcb_port"),{solution:I}=b8e(B.concat([{type:"source_trace",source_trace_id:"__net_trace_tmp",connected_source_port_ids:[A.source_port_id,w.source_port_id]}])),q=I[0];if(!q){this.renderError({pcb_trace_error_id:"",pcb_trace_id:"__net_trace_tmp",pcb_component_ids:[A.pcb_component_id,w.pcb_component_id].filter(Boolean),pcb_port_ids:[A.pcb_port_id,w.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}e.pcb_trace.insert(q)}}renderError(e){if(typeof e=="string")return super.renderError(e);this.root?.db.pcb_trace_error.insert(e)}},zW=(n,e)=>{for(let a of e)if(typeof a=="string"&&a.startsWith("net.")){if(/net\.[^\s>]*\./.test(a))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(a))throw new Error('Net names cannot contain "+" or "-", try using underscores instead, e.g. VCC_P');if(/net\.[0-9]/.test(a)){let l=a.split("net.")[1];throw new Error(`Net name "${l}" cannot start with a number, try using a prefix like "VBUS1"`)}let s=n.getSubcircuit();if(!s.selectOne(a)){let l=new $W({name:a.split("net.")[1]});s.add(l)}}},$S=class extends ga{constructor(){super(...arguments);X(this,"pcb_smtpad_id",null);X(this,"matchedPort",null);X(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SmtPad",zodProps:U8e}}getPcbSize(){let{_parsedProps:e}=this;if(e.shape==="circle")return{width:e.radius*2,height:e.radius*2};if(e.shape==="rect")return{width:e.width,height:e.height};if(e.shape==="polygon"){let a=e.points,s=a.map(y=>y.x),l=a.map(y=>y.y),d=Math.min(...s),x=Math.max(...s),f=Math.min(...l),m=Math.max(...l);return{width:x-d,height:m-f}}throw new Error(`getPcbSize for shape "${e.shape}" not implemented for ${this.componentName}`)}doInitialPortMatching(){let e=this.getPrimitiveContainer()?.selectAll("port");if(this.props.portHints){for(let a of e)if(a.isMatchingAnyOf(this.props.portHints)){this.matchedPort=a,a.registerMatch(this);return}}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this;if(!a.portHints)return;let s=this.getPrimitiveContainer(),l=this.getSubcircuit(),d=this._getGlobalPcbPositionBeforeLayout(),x=s?._getGlobalPcbPositionBeforeLayout(),f=e4(this._computePcbGlobalTransformBeforeLayout()),m=Math.abs(f.rotation.angle*(180/Math.PI)-90)%180<.01,{maybeFlipLayer:y}=this._getPcbPrimitiveFlippedHelpers(),b=s?._parsedProps.pcbRotation??0,E=null,A=this.parent?.pcb_component_id??this.getPrimitiveContainer()?.pcb_component_id;a.shape==="circle"?(E=e.pcb_smtpad.insert({pcb_component_id:A,pcb_port_id:this.matchedPort?.pcb_port_id,layer:y(a.layer??"top"),shape:"circle",radius:a.radius,port_hints:a.portHints.map(w=>w.toString()),x:d.x,y:d.y,subcircuit_id:l?.subcircuit_id??void 0}),e.pcb_solder_paste.insert({layer:E.layer,shape:"circle",radius:E.radius*.7,x:E.x,y:E.y,pcb_component_id:E.pcb_component_id,pcb_smtpad_id:E.pcb_smtpad_id,subcircuit_id:l?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0})):a.shape==="rect"?(E=b===0||m?e.pcb_smtpad.insert({pcb_component_id:A,pcb_port_id:this.matchedPort?.pcb_port_id,layer:y(a.layer??"top"),shape:"rect",width:m?a.height:a.width,height:m?a.width:a.height,port_hints:a.portHints.map(w=>w.toString()),x:d.x,y:d.y,subcircuit_id:l?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0}):e.pcb_smtpad.insert({pcb_component_id:A,layer:y(a.layer??"top"),shape:"rotated_rect",width:a.width,height:a.height,x:d.x,y:d.y,ccw_rotation:b,port_hints:a.portHints.map(w=>w.toString()),subcircuit_id:l?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0}),E.shape==="rect"&&e.pcb_solder_paste.insert({layer:y(a.layer??"top"),shape:"rect",width:E.width*.7,height:E.height*.7,x:E.x,y:E.y,pcb_component_id:E.pcb_component_id,pcb_smtpad_id:E.pcb_smtpad_id,subcircuit_id:l?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0}),E.shape==="rotated_rect"&&e.pcb_solder_paste.insert({layer:y(a.layer??"top"),shape:"rotated_rect",width:E.width*.7,height:E.height*.7,x:E.x,y:E.y,ccw_rotation:b,pcb_component_id:E.pcb_component_id,pcb_smtpad_id:E.pcb_smtpad_id,subcircuit_id:l?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0})):a.shape==="polygon"&&(E=e.pcb_smtpad.insert({pcb_component_id:A,pcb_port_id:this.matchedPort?.pcb_port_id,layer:y(a.layer??"top"),shape:"polygon",points:a.points.map(w=>({x:w.x+d.x,y:w.y+d.y})),port_hints:a.portHints.map(w=>w.toString()),subcircuit_id:l?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0})),E&&(this.pcb_smtpad_id=E.pcb_smtpad_id)}doInitialPcbPortAttachment(){if(this.root?.pcbDisabled)return;let{db:e}=this.root;e.pcb_smtpad.update(this.pcb_smtpad_id,{pcb_port_id:this.matchedPort?.pcb_port_id})}_getPcbCircuitJsonBounds(){let{db:e}=this.root,a=e.pcb_smtpad.get(this.pcb_smtpad_id);if(a.shape==="rect")return{center:{x:a.x,y:a.y},bounds:{left:a.x-a.width/2,top:a.y+a.height/2,right:a.x+a.width/2,bottom:a.y-a.height/2},width:a.width,height:a.height};if(a.shape==="rotated_rect"){let s=a.ccw_rotation*Math.PI/180,l=Math.cos(s),d=Math.sin(s),x=a.width/2,f=a.height/2,m=Math.abs(x*l)+Math.abs(f*d),y=Math.abs(x*d)+Math.abs(f*l);return{center:{x:a.x,y:a.y},bounds:{left:a.x-m,right:a.x+m,top:a.y-y,bottom:a.y+y},width:m*2,height:y*2}}if(a.shape==="circle")return{center:{x:a.x,y:a.y},bounds:{left:a.x-a.radius,top:a.y-a.radius,right:a.x+a.radius,bottom:a.y+a.radius},width:a.radius*2,height:a.radius*2};if(a.shape==="polygon"){let s=a.points,l=s.map(b=>b.x),d=s.map(b=>b.y),x=Math.min(...l),f=Math.max(...l),m=Math.min(...d),y=Math.max(...d);return{center:{x:(x+f)/2,y:(m+y)/2},bounds:{left:x,top:y,right:f,bottom:m},width:f-x,height:y-m}}throw new Error(`circuitJson bounds calculation not implemented for shape "${a.shape}"`)}_setPositionFromLayout(e){let{db:a}=this.root;a.pcb_smtpad.update(this.pcb_smtpad_id,{x:e.x,y:e.y});let s=a.pcb_solder_paste.list().find(l=>l.pcb_smtpad_id===this.pcb_smtpad_id);a.pcb_solder_paste.update(s?.pcb_solder_paste_id,{x:e.x,y:e.y}),this.matchedPort?._setPositionFromLayout(e)}},qW=class extends ga{constructor(){super(...arguments);X(this,"pcb_silkscreen_path_id",null);X(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenPath",zodProps:yAe}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,{maybeFlipLayer:s}=this._getPcbPrimitiveFlippedHelpers(),l=s(a.layer??"top");if(l!=="top"&&l!=="bottom")throw new Error(`Invalid layer "${l}" for SilkscreenPath. Must be "top" or "bottom".`);let d=this._computePcbGlobalTransformBeforeLayout(),x=this.getSubcircuit(),f=this.parent?.pcb_component_id??this.getPrimitiveContainer()?.pcb_component_id,m=e.pcb_silkscreen_path.insert({pcb_component_id:f,layer:l,route:a.route.map(y=>{let b=vs(d,{x:y.x,y:y.y});return{...y,x:b.x,y:b.y}}),stroke_width:a.strokeWidth??.1,subcircuit_id:x?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0});this.pcb_silkscreen_path_id=m.pcb_silkscreen_path_id}_setPositionFromLayout(e){let{db:a}=this.root,{_parsedProps:s}=this,l=a.pcb_silkscreen_path.get(this.pcb_silkscreen_path_id);if(!l)return;let d=0,x=0;for(let b of l.route)d+=b.x,x+=b.y;d/=l.route.length,x/=l.route.length;let f=e.x-d,m=e.y-x,y=l.route.map(b=>({...b,x:b.x+f,y:b.y+m}));a.pcb_silkscreen_path.update(this.pcb_silkscreen_path_id,{route:y})}getPcbSize(){let{_parsedProps:e}=this;if(!e.route||e.route.length===0)return{width:0,height:0};let a=1/0,s=-1/0,l=1/0,d=-1/0;for(let x of e.route)a=Math.min(a,x.x),s=Math.max(s,x.x),l=Math.min(l,x.y),d=Math.max(d,x.y);return{width:s-a,height:d-l}}},rGt=C.object({route:C.array(LA),source_trace_id:C.string().optional()}),UW=class extends ga{constructor(){super(...arguments);X(this,"pcb_trace_id",null);X(this,"isPcbPrimitive",!0)}get config(){return{componentName:"PcbTrace",zodProps:rGt}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,s=this.getPrimitiveContainer(),l=this.getSubcircuit(),{maybeFlipLayer:d}=this._getPcbPrimitiveFlippedHelpers(),x=this._computePcbGlobalTransformBeforeLayout(),f=a.route.map(y=>{let{x:b,y:E,...A}=y,w=vs(x,{x:b,y:E});return y.route_type==="wire"&&y.layer?{...w,...A,layer:d(y.layer)}:{...w,...A}}),m=e.pcb_trace.insert({pcb_component_id:s.pcb_component_id,source_trace_id:a.source_trace_id,route:f,subcircuit_id:l?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0});this.pcb_trace_id=m.pcb_trace_id}getPcbSize(){let{_parsedProps:e}=this;if(!e.route||e.route.length===0)return{width:0,height:0};let a=1/0,s=-1/0,l=1/0,d=-1/0;for(let x of e.route)a=Math.min(a,x.x),s=Math.max(s,x.x),l=Math.min(l,x.y),d=Math.max(d,x.y),x.route_type==="wire"&&(a=Math.min(a,x.x-x.width/2),s=Math.max(s,x.x+x.width/2),l=Math.min(l,x.y-x.width/2),d=Math.max(d,x.y+x.width/2));return a===1/0||s===-1/0||l===1/0||d===-1/0?{width:0,height:0}:{width:s-a,height:d-l}}},zS=class extends ga{constructor(){super(...arguments);X(this,"pcb_plated_hole_id",null);X(this,"matchedPort",null);X(this,"isPcbPrimitive",!0)}get config(){return{componentName:"PlatedHole",zodProps:I8e}}getAvailablePcbLayers(){return["top","inner1","inner2","bottom"]}getPcbSize(){let{_parsedProps:e}=this;if(e.shape==="circle")return{width:e.outerDiameter,height:e.outerDiameter};if(e.shape==="oval"||e.shape==="pill")return{width:e.outerWidth,height:e.outerHeight};if(e.shape==="circular_hole_with_rect_pad")return{width:e.rectPadWidth,height:e.rectPadHeight};if(e.shape==="pill_hole_with_rect_pad")return{width:e.rectPadWidth,height:e.rectPadHeight};throw new Error(`getPcbSize for shape "${e.shape}" not implemented for ${this.componentName}`)}_getPcbCircuitJsonBounds(){let{db:e}=this.root,a=e.pcb_plated_hole.get(this.pcb_plated_hole_id),s=this.getPcbSize();return{center:{x:a.x,y:a.y},bounds:{left:a.x-s.width/2,top:a.y+s.height/2,right:a.x+s.width/2,bottom:a.y-s.height/2},width:s.width,height:s.height}}_setPositionFromLayout(e){let{db:a}=this.root;a.pcb_plated_hole.update(this.pcb_plated_hole_id,{x:e.x,y:e.y}),this.matchedPort?._setPositionFromLayout(e)}doInitialPortMatching(){let e=this.getPrimitiveContainer()?.selectAll("port");if(this.props.portHints){for(let a of e)if(a.isMatchingAnyOf(this.props.portHints)){this.matchedPort=a,a.registerMatch(this);return}}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,s=this._getGlobalPcbPositionBeforeLayout(),l=this.parent?.pcb_component_id??this.getPrimitiveContainer()?.pcb_component_id,d=this.getSubcircuit();if(a.shape==="circle"){let x=e.pcb_plated_hole.insert({pcb_component_id:l,pcb_port_id:this.matchedPort?.pcb_port_id,outer_diameter:a.outerDiameter,hole_diameter:a.holeDiameter,shape:"circle",port_hints:this.getNameAndAliases(),x:s.x,y:s.y,layers:["top","bottom"],subcircuit_id:d?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0});this.pcb_plated_hole_id=x.pcb_plated_hole_id,e.pcb_solder_paste.insert({layer:"top",shape:"circle",radius:a.outerDiameter/2,x:s.x,y:s.y,subcircuit_id:d?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0}),e.pcb_solder_paste.insert({layer:"bottom",shape:"circle",radius:a.outerDiameter/2,x:s.x,y:s.y,subcircuit_id:d?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0})}else if(a.shape==="pill"&&a.rectPad){let x=e.pcb_plated_hole.insert({pcb_component_id:l,pcb_port_id:this.matchedPort?.pcb_port_id,outer_width:a.outerWidth,outer_height:a.outerHeight,hole_width:a.holeWidth,hole_height:a.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:s.x,y:s.y,layers:["top","bottom"],subcircuit_id:d?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0,hole_shape:"rotated_pill",pad_shape:"rect",hole_ccw_rotation:a.pcbRotation??0,rect_ccw_rotation:a.pcbRotation??0,rect_pad_width:a.outerWidth,rect_pad_height:a.outerHeight});this.pcb_plated_hole_id=x.pcb_plated_hole_id}else if(a.shape==="pill"||a.shape==="oval"){let x=e.pcb_plated_hole.insert({pcb_component_id:l,pcb_port_id:this.matchedPort?.pcb_port_id,outer_width:a.outerWidth,outer_height:a.outerHeight,hole_width:a.holeWidth,hole_height:a.holeHeight,shape:a.shape,port_hints:this.getNameAndAliases(),x:s.x,y:s.y,layers:["top","bottom"],subcircuit_id:d?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0});this.pcb_plated_hole_id=x.pcb_plated_hole_id,e.pcb_solder_paste.insert({layer:"top",shape:a.shape,width:a.outerWidth,height:a.outerHeight,x:s.x,y:s.y,subcircuit_id:d?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0}),e.pcb_solder_paste.insert({layer:"bottom",shape:a.shape,width:a.outerWidth,height:a.outerHeight,x:s.x,y:s.y,subcircuit_id:d?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0})}else if(a.shape==="circular_hole_with_rect_pad"){let x=e.pcb_plated_hole.insert({pcb_component_id:l,pcb_port_id:this.matchedPort?.pcb_port_id,hole_diameter:a.holeDiameter,rect_pad_width:a.rectPadWidth,rect_pad_height:a.rectPadHeight,shape:"circular_hole_with_rect_pad",port_hints:this.getNameAndAliases(),x:s.x,y:s.y,layers:["top","bottom"],subcircuit_id:d?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0});this.pcb_plated_hole_id=x.pcb_plated_hole_id}else if(a.shape==="pill_hole_with_rect_pad"){let x=e.pcb_plated_hole.insert({pcb_component_id:l,pcb_port_id:this.matchedPort?.pcb_port_id,hole_width:a.holeWidth,hole_height:a.holeHeight,rect_pad_width:a.rectPadWidth,rect_pad_height:a.rectPadHeight,shape:"pill_hole_with_rect_pad",port_hints:this.getNameAndAliases(),x:s.x,y:s.y,layers:["top","bottom"],subcircuit_id:d?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0});this.pcb_plated_hole_id=x.pcb_plated_hole_id}}doInitialPcbPortAttachment(){if(this.root?.pcbDisabled)return;let{db:e}=this.root;e.pcb_plated_hole.update(this.pcb_plated_hole_id,{pcb_port_id:this.matchedPort?.pcb_port_id})}},qS=class extends ga{constructor(){super(...arguments);X(this,"pcb_keepout_id",null);X(this,"isPcbPrimitive",!0)}get config(){return{componentName:"Keepout",zodProps:lAe}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let e=this.getSubcircuit(),{db:a}=this.root,{_parsedProps:s}=this,l=this._getGlobalPcbPositionBeforeLayout(),d=e4(this._computePcbGlobalTransformBeforeLayout()),x=Math.abs(d.rotation.angle*(180/Math.PI)-90)%180<.01,f=null;s.shape==="circle"?f=a.pcb_keepout.insert({layers:["top"],shape:"circle",radius:s.radius,center:{x:l.x,y:l.y},subcircuit_id:e?.subcircuit_id??void 0,pcb_group_id:e?.getGroup()?.pcb_group_id??void 0}):s.shape==="rect"&&(f=a.pcb_keepout.insert({layers:["top"],shape:"rect",...x?{width:s.height,height:s.width}:{width:s.width,height:s.height},center:{x:l.x,y:l.y},subcircuit_id:e?.subcircuit_id??void 0,pcb_group_id:e?.getGroup()?.pcb_group_id??void 0})),f&&(this.pcb_keepout_id=f.pcb_keepout_id)}},VW=class extends ga{constructor(){super(...arguments);X(this,"pcb_hole_id",null);X(this,"isPcbPrimitive",!0)}get config(){return{componentName:"Hole",zodProps:V8e}}getPcbSize(){let{_parsedProps:e}=this;return{width:e.diameter,height:e.diameter}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,s=this.getSubcircuit(),l=this._getGlobalPcbPositionBeforeLayout(),d=e.pcb_hole.insert({hole_shape:"circle",hole_diameter:a.diameter,x:l.x,y:l.y,subcircuit_id:s?.subcircuit_id??void 0,pcb_group_id:s?.getGroup()?.pcb_group_id??void 0});this.pcb_hole_id=d.pcb_hole_id}_getPcbCircuitJsonBounds(){let{db:e}=this.root,a=e.pcb_hole.get(this.pcb_hole_id),s=this.getPcbSize();return{center:{x:a.x,y:a.y},bounds:{left:a.x-s.width/2,top:a.y-s.height/2,right:a.x+s.width/2,bottom:a.y+s.height/2},width:s.width,height:s.height}}_setPositionFromLayout(e){let{db:a}=this.root;a.pcb_hole.update(this.pcb_hole_id,{x:e.x,y:e.y})}},XS=class extends ga{constructor(){super(...arguments);X(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenText",zodProps:gAe}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,s=this.getPrimitiveContainer(),l=this._getGlobalPcbPositionBeforeLayout(),{maybeFlipLayer:d}=this._getPcbPrimitiveFlippedHelpers(),x=this.getSubcircuit(),f=new Set(a.layers);a.layer&&f.add(a.layer);let m=f.size>0?Array.from(f):["top"];for(let y of m)e.pcb_silkscreen_text.insert({anchor_alignment:a.anchorAlignment,anchor_position:{x:l.x,y:l.y},font:a.font??"tscircuit2024",font_size:a.fontSize??1,layer:d(y),text:a.text??"",ccw_rotation:a.pcbRotation,pcb_component_id:s.pcb_component_id,subcircuit_id:x?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0})}getPcbSize(){let{_parsedProps:e}=this,a=e.fontSize??1,l=(e.text??"").length*a,d=a;return{width:l*a,height:d*a}}},$F=class extends ga{constructor(){super(...arguments);X(this,"pcb_cutout_id",null);X(this,"isPcbPrimitive",!0)}get config(){return{componentName:"Cutout",zodProps:q8e}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,s=this.getSubcircuit(),l=this.getGroup()?.pcb_group_id??void 0,d=this._getGlobalPcbPositionBeforeLayout(),f=this.getPrimitiveContainer()?._parsedProps.pcbRotation??0,m;if(a.shape==="rect"){let y=typeof f=="string"?parseInt(f.replace("deg",""),10):f,b=Math.abs(y%180)===90,E={shape:"rect",center:d,width:b?a.height:a.width,height:b?a.width:a.height,subcircuit_id:s?.subcircuit_id??void 0,pcb_group_id:l};m=e.pcb_cutout.insert(E)}else if(a.shape==="circle"){let y={shape:"circle",center:d,radius:a.radius,subcircuit_id:s?.subcircuit_id??void 0,pcb_group_id:l};m=e.pcb_cutout.insert(y)}else if(a.shape==="polygon"){let y=this._computePcbGlobalTransformBeforeLayout(),E={shape:"polygon",points:a.points.map(A=>vs(y,A)),subcircuit_id:s?.subcircuit_id??void 0,pcb_group_id:l};m=e.pcb_cutout.insert(E)}m&&(this.pcb_cutout_id=m.pcb_cutout_id)}getPcbSize(){let{_parsedProps:e}=this;if(e.shape==="rect")return{width:e.width,height:e.height};if(e.shape==="circle")return{width:e.radius*2,height:e.radius*2};if(e.shape==="polygon"){if(e.points.length===0)return{width:0,height:0};let a=1/0,s=-1/0,l=1/0,d=-1/0;for(let x of e.points)a=Math.min(a,x.x),s=Math.max(s,x.x),l=Math.min(l,x.y),d=Math.max(d,x.y);return{width:s-a,height:d-l}}return{width:0,height:0}}_getPcbCircuitJsonBounds(){if(!this.pcb_cutout_id)return super._getPcbCircuitJsonBounds();let{db:e}=this.root,a=e.pcb_cutout.get(this.pcb_cutout_id);if(!a)return super._getPcbCircuitJsonBounds();if(a.shape==="rect")return{center:a.center,bounds:{left:a.center.x-a.width/2,top:a.center.y+a.height/2,right:a.center.x+a.width/2,bottom:a.center.y-a.height/2},width:a.width,height:a.height};if(a.shape==="circle")return{center:a.center,bounds:{left:a.center.x-a.radius,top:a.center.y+a.radius,right:a.center.x+a.radius,bottom:a.center.y-a.radius},width:a.radius*2,height:a.radius*2};if(a.shape==="polygon"){if(a.points.length===0)return super._getPcbCircuitJsonBounds();let s=1/0,l=-1/0,d=1/0,x=-1/0;for(let f of a.points)s=Math.min(s,f.x),l=Math.max(l,f.x),d=Math.min(d,f.y),x=Math.max(x,f.y);return{center:{x:(s+l)/2,y:(d+x)/2},bounds:{left:s,top:x,right:l,bottom:d},width:l-s,height:x-d}}return super._getPcbCircuitJsonBounds()}_setPositionFromLayout(e){if(!this.pcb_cutout_id)return;let{db:a}=this.root,s=a.pcb_cutout.get(this.pcb_cutout_id);if(s){if(s.shape==="rect"||s.shape==="circle")a.pcb_cutout.update(this.pcb_cutout_id,{...s,center:e});else if(s.shape==="polygon"){let l=this._getPcbCircuitJsonBounds().center,d=e.x-l.x,x=e.y-l.y,f=s.points.map(m=>({x:m.x+d,y:m.y+x}));a.pcb_cutout.update(this.pcb_cutout_id,{...s,points:f})}}}},nGt=({elm:n,pinLabels:e,layer:a,readableRotation:s,anchorAlignment:l})=>{let d=n.text.replace(/[{}]/g,"").toLowerCase(),x=d;if(Array.isArray(e)){let f=parseInt(d.replace(/[^\d]/g,""),10)-1;x=String(e[f]??d)}else typeof e=="object"&&(x=String(e[d]??d));return new XS({anchorAlignment:l||"center",text:x??d,layer:a||"top",fontSize:n.font_size+.2,pcbX:isNaN(n.anchor_position.x)?0:n.anchor_position.x,pcbY:n.anchor_position.y,pcbRotation:s??0})},aGt=(n,e)=>((-parseInt(n||"0",10)+(e??0))%360+360)%360,JSe=({componentName:n,componentRotation:e,footprint:a,pinLabels:s,pcbPinLabels:l},d)=>{let x=[];for(let f of d)if(f.type==="pcb_smtpad"&&f.shape==="rect")x.push(new $S({pcbX:f.x,pcbY:f.y,layer:f.layer,shape:"rect",height:f.height,width:f.width,portHints:f.port_hints}));else if(f.type==="pcb_smtpad"&&f.shape==="circle")x.push(new $S({pcbX:f.x,pcbY:f.y,layer:f.layer,shape:"circle",radius:f.radius,portHints:f.port_hints}));else if(f.type==="pcb_silkscreen_path")x.push(new qW({layer:f.layer,route:f.route,strokeWidth:f.stroke_width}));else if(f.type==="pcb_plated_hole")f.shape==="circle"?x.push(new zS({pcbX:f.x,pcbY:f.y,shape:"circle",holeDiameter:f.hole_diameter,outerDiameter:f.outer_diameter,portHints:f.port_hints})):f.shape==="circular_hole_with_rect_pad"&&x.push(new zS({pcbX:f.x,pcbY:f.y,shape:"circular_hole_with_rect_pad",holeDiameter:f.hole_diameter,rectPadHeight:f.rect_pad_height,rectPadWidth:f.rect_pad_width,portHints:f.port_hints}));else if(f.type==="pcb_keepout"&&f.shape==="circle")x.push(new qS({pcbX:f.center.x,pcbY:f.center.y,shape:"circle",radius:f.radius}));else if(f.type==="pcb_keepout"&&f.shape==="rect")x.push(new qS({pcbX:f.center.x,pcbY:f.center.y,shape:"rect",width:f.width,height:f.height}));else if(f.type==="pcb_hole"&&f.hole_shape==="circle")x.push(new VW({pcbX:f.x,pcbY:f.y,diameter:f.hole_diameter}));else if(f.type==="pcb_cutout")f.shape==="rect"?x.push(new $F({pcbX:f.center.x,pcbY:f.center.y,shape:"rect",width:f.width,height:f.height})):f.shape==="circle"?x.push(new $F({pcbX:f.center.x,pcbY:f.center.y,shape:"circle",radius:f.radius})):f.shape==="polygon"&&x.push(new $F({shape:"polygon",points:f.points}));else if(f.type==="pcb_silkscreen_text"){let m=aGt(e,f.ccw_rotation);a.includes("pinrow")&&f.text.includes("PIN")?x.push(nGt({elm:f,pinLabels:l??s,layer:f.layer,readableRotation:m,anchorAlignment:f.anchor_alignment})):x.push(new XS({anchorAlignment:f.anchor_alignment||"center",text:n,fontSize:f.font_size+.2,pcbX:Number.isNaN(f.anchor_position.x)?0:f.anchor_position.x,pcbY:f.anchor_position.y,pcbRotation:m??0}))}else f.type==="pcb_trace"&&x.push(new UW({route:f.route}));return x};function GW(n){let e=1/0,a=1/0,s=-1/0,l=-1/0,d=!1;for(let m of n)if(m.isPcbPrimitive&&!m.componentName.startsWith("Silkscreen")){let{x:y,y:b}=m._getGlobalPcbPositionBeforeLayout(),{width:E,height:A}=m.getPcbSize();e=Math.min(e,y-E/2),a=Math.min(a,b-A/2),s=Math.max(s,y+E/2),l=Math.max(l,b+A/2),d=!0}else if(m.children.length>0){let y=GW(m.children);(y.width>0||y.height>0)&&(e=Math.min(e,y.minX),a=Math.min(a,y.minY),s=Math.max(s,y.maxX),l=Math.max(l,y.maxY),d=!0)}if(!d)return{minX:0,minY:0,maxX:0,maxY:0,width:0,height:0};let x=s-e,f=l-a;return x<0&&(x=0),f<0&&(f=0),{minX:e,minY:a,maxX:s,maxY:l,width:x,height:f}}function sGt(n,e){let a=e.x-n.x,s=e.y-n.y;return Math.abs(a)>Math.abs(s)?a>=0?"right":"left":s>=0?"up":"down"}var iGt=n=>{if(n.length<=1)return!0;let e=n.map(d=>{let x=d._getPcbCircuitJsonBounds();return{left:x.bounds.left,right:x.bounds.right,top:x.bounds.top,bottom:x.bounds.bottom}}),a=Array(e.length).fill(!1).map(()=>Array(e.length).fill(!1));for(let d=0;d<e.length;d++)for(let x=d+1;x<e.length;x++){let f=e[d],m=e[x];a[d][x]=a[x][d]=!(f.right<m.left||f.left>m.right||f.bottom>m.top||f.top<m.bottom)}let s=new Set,l=d=>{s.add(d);for(let x=0;x<e.length;x++)a[d][x]&&!s.has(x)&&l(x)};return l(0),s.size===e.length},oGt=n=>{if(n.length===0)throw new Error("Cannot get center of empty PCB primitives array");let e=n.map(l=>l._getPcbCircuitJsonBounds().center).filter(Boolean),a=e.reduce((l,d)=>l+d.x,0),s=e.reduce((l,d)=>l+d.y,0);return{x:a/e.length,y:s/e.length}},uGt=C.object({name:C.string().optional(),pinNumber:C.number().optional(),aliases:C.array(C.string()).optional()}),Fo=class extends ga{constructor(e,a={}){if(!e.name&&e.pinNumber!==void 0&&(e.name=`pin${e.pinNumber}`),!e.name)throw new Error("Port must have a name or a pinNumber");super(e);X(this,"source_port_id",null);X(this,"pcb_port_id",null);X(this,"schematic_port_id",null);X(this,"schematicSymbolPortDef",null);X(this,"matchedComponents");X(this,"facingDirection",null);X(this,"originDescription",null);a.originDescription&&(this.originDescription=a.originDescription),this.matchedComponents=[]}get config(){return{componentName:"Port",zodProps:uGt}}_getGlobalPcbPositionBeforeLayout(){let e=this.matchedComponents.find(s=>s.isPcbPrimitive),a=this.parent;if(a&&!a.props.footprint)throw new Error(`${a.componentName} "${a.props.name}" does not have a footprint. Add a footprint prop, e.g. <${a.componentName.toLowerCase()} footprint="..." />`);if(!e)throw new Error(`Port ${this} has no matching PCB primitives. This often means the footprint's pads lack matching port hints.`);return e?._getGlobalPcbPositionBeforeLayout()??{x:0,y:0}}_getPcbCircuitJsonBounds(){if(!this.pcb_port_id)return super._getPcbCircuitJsonBounds();let{db:e}=this.root,a=e.pcb_port.get(this.pcb_port_id);return{center:{x:a.x,y:a.y},bounds:{left:0,top:0,right:0,bottom:0},width:0,height:0}}_getGlobalPcbPositionAfterLayout(){return this._getPcbCircuitJsonBounds().center}_getPortsInternallyConnectedToThisPort(){let e=this.parent;if(!e||!e._getInternallyConnectedPins)return[];let a=e._getInternallyConnectedPins();for(let s of a)if(s.some(l=>l===this))return s;return[]}_hasSchematicPort(){if(this.parent?.getSchematicSymbol())return!!(this.schematicSymbolPortDef||this._getPortsInternallyConnectedToThisPort().some(l=>l.schematicSymbolPortDef));let a=this?.parent?._getSchematicBoxDimensions();return!!(a&&this.props.pinNumber!==void 0&&a.getPortPositionByPinNumber(this.props.pinNumber))}_getGlobalSchematicPositionBeforeLayout(){let e=this.parent?.getSchematicSymbol();if(e){let s=this.schematicSymbolPortDef;if(!s&&(s=this._getPortsInternallyConnectedToThisPort().find(d=>d.schematicSymbolPortDef)?.schematicSymbolPortDef??null,!s))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 l=Bs(this.parent.computeSchematicGlobalTransform(),ja(-e.center.x,-e.center.y));return vs(l,s)}let a=this?.parent?._getSchematicBoxDimensions();if(a&&this.props.pinNumber!==void 0){let s=a.getPortPositionByPinNumber(this.props.pinNumber);if(!s)throw new Error(`Couldn't find position for schematic_port for port ${this.getString()} inside of the schematic box`);return vs(this.parent.computeSchematicGlobalTransform(),s)}throw new Error(`Couldn't find position for schematic_port for port ${this.getString()}`)}_getGlobalSchematicPositionAfterLayout(){let{db:e}=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 a=e.schematic_port.get(this.schematic_port_id);if(!a)throw new Error(`Schematic port not found when trying to get post-layout position: ${this.schematic_port_id}`);return a.center}registerMatch(e){this.matchedComponents.push(e)}getNameAndAliases(){let{_parsedProps:e}=this;return Array.from(new Set([...e.name?[e.name]:[],...e.aliases??[],...typeof e.pinNumber=="number"?[`pin${e.pinNumber}`,e.pinNumber.toString()]:[],...this.externallyAddedAliases??[]]))}isMatchingPort(e){return this.isMatchingAnyOf(e.getNameAndAliases())}getPortSelector(){return`.${this.parent?.props.name} > port.${this.props.name}`}getAvailablePcbLayers(){return Array.from(new Set(this.matchedComponents.flatMap(e=>e.getAvailablePcbLayers())))}_getDirectlyConnectedTraces(){return this.getSubcircuit().selectAll("trace").filter(s=>!s._couldNotFindPort).filter(s=>s._isExplicitlyConnectedToPort(this))}doInitialSourceRender(){let{db:e}=this.root,{_parsedProps:a}=this,s=this.getNameAndAliases(),l=e.source_port.insert({name:a.name,pin_number:a.pinNumber,port_hints:s,source_component_id:this.parent?.source_component_id,subcircuit_id:this.getSubcircuit()?.subcircuit_id});this.source_port_id=l.source_port_id}doInitialSourceParentAttachment(){let{db:e}=this.root;if(!this.parent?.source_component_id)throw new Error(`${this.getString()} has no parent source component (parent: ${this.parent?.getString()})`);e.source_port.update(this.source_port_id,{source_component_id:this.parent?.source_component_id,subcircuit_id:this.getSubcircuit()?.subcircuit_id}),this.source_component_id=this.parent?.source_component_id}doInitialPcbPortRender(){if(this.root?.pcbDisabled)return;let{db:e}=this.root,{matchedComponents:a}=this;if(!this.parent?.pcb_component_id)throw new Error(`${this.getString()} has no parent pcb component, cannot render pcb_port (parent: ${this.parent?.getString()})`);let s=a.filter(d=>d.isPcbPrimitive);if(s.length===0)return;let l=null;if(s.length===1&&(l=s[0]._getPcbCircuitJsonBounds().center),s.length>1){if(!iGt(s))throw new Error(`${this.getString()} has multiple non-overlapping pcb matches, unclear how to place pcb_port: ${s.map(d=>d.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)`);l=oGt(s)}if(l){let d=this.getSubcircuit(),x=e.pcb_port.insert({pcb_component_id:this.parent?.pcb_component_id,layers:this.getAvailablePcbLayers(),subcircuit_id:d?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0,...l,source_port_id:this.source_port_id});this.pcb_port_id=x.pcb_port_id}else{let d=s[0];throw new Error(`${d.getString()} does not have a center or _getGlobalPcbPositionBeforeLayout method (needed for pcb_port placement)`)}}doInitialSchematicPortRender(){let{db:e}=this.root,{_parsedProps:a}=this,s=this.getPrimitiveContainer();if(!s||!this._hasSchematicPort())return;let l=s._getGlobalSchematicPositionBeforeLayout(),d=this._getGlobalSchematicPositionBeforeLayout(),x=null,f=s._getSchematicBoxDimensions();f&&a.pinNumber!==void 0&&(x=f.getPortPositionByPinNumber(a.pinNumber)),this.getSubcircuit().props._schDebugObjectsEnabled&&e.schematic_debug_object.insert({shape:"rect",center:d,size:{width:.1,height:.1},label:"obstacle"}),x?.side?this.facingDirection={left:"left",right:"right",top:"up",bottom:"down"}[x.side]:this.facingDirection=sGt(l,d);let m=e.source_port.get(this.source_port_id),y=[];for(let w of m?.port_hints??[])w.match(/^(pin)?\d+$/)||w.match(/^(left|right)/)&&!m?.name.match(/^(left|right)/)||y.push(w);let b;this.parent?.props?.showPinAliases&&y.length>0?b=y.join("/"):y.length>0&&(b=y[0]);let A=e.schematic_port.insert({schematic_component_id:this.parent?.schematic_component_id,center:d,source_port_id:this.source_port_id,facing_direction:this.facingDirection,distance_from_component_edge:.4,side_of_component:x?.side,pin_number:a.pinNumber,true_ccw_index:x?.trueIndex,display_pin_label:b,is_connected:!1});this.schematic_port_id=A.schematic_port_id}_getSubcircuitConnectivityKey(){return this.root?.db.source_port.get(this.source_port_id)?.subcircuit_connectivity_map_key}_setPositionFromLayout(e){let{db:a}=this.root;this.pcb_port_id&&a.pcb_port.update(this.pcb_port_id,{x:e.x,y:e.y})}_hasMatchedPcbPrimitive(){return this.matchedComponents.some(e=>e.isPcbPrimitive)}_getNetLabelText(){return`${this.parent?.props.name}_${this.props.name}`}},Ewe=n=>{let e=n.find(a=>/^(pin)?\d+$/.test(a));return e?Number.parseInt(e.replace(/^pin/,"")):null};function kF(n,e){let a=Ewe(n);if(!a)return null;let l=[...n.filter(d=>d.toString()!==a.toString()&&d!==`pin${a}`),...e?.additionalAliases?.[`pin${a}`]??[]];return new Fo({pinNumber:a,aliases:l})}var cGt=n=>{for(let e of["leftSide","rightSide","topSide","bottomSide"])if(e in n&&typeof n[e]=="number")throw new Error(`A number was specified for "${e}", you probably meant to use "size" not "side"`);return"leftSide"in n||"rightSide"in n||"topSide"in n||"bottomSide"in n},lGt=n=>{if(cGt(n))return{leftSize:n.leftSide?.pins.length??0,rightSize:n.rightSide?.pins.length??0,topSize:n.topSide?.pins.length??0,bottomSize:n.bottomSide?.pins.length??0};let{leftSize:e=0,rightSize:a=0,topSize:s=0,bottomSize:l=0}=n;return{leftSize:e,rightSize:a,topSize:s,bottomSize:l}};function vwe(n){let e=n;return e.leftSide!==void 0||e.rightSide!==void 0||e.topSide!==void 0||e.bottomSide!==void 0}var dGt=n=>{let e=n.portDistanceFromEdge??.4,a=n.schPortArrangement?lGt(n.schPortArrangement):null,s={left:0,right:0,top:0,bottom:0},l=n.pinCount??null;if(l===null)if(a)l=a.leftSize+a.rightSize+a.topSize;else throw new Error("Could not determine pin count for the schematic box");if(l&&!a){let B=Math.floor(l/2);a={leftSize:l-B,rightSize:B,topSize:0,bottomSize:0}}a||(a={leftSize:0,rightSize:0,topSize:0,bottomSize:0});let d=({side:B,sideIndex:I,truePinIndex:q})=>{if(!n.schPortArrangement||!vwe(n.schPortArrangement))return q+1;let G={left:"top-to-bottom",bottom:"left-to-right",right:"bottom-to-top",top:"right-to-left"}[B],j=n.schPortArrangement?.[`${B}Side`]?.direction??G,O=n.schPortArrangement?.[`${B}Side`]?.pins,V=I;return j!==G&&(V=O.length-I-1),zF(O[V],n.pinLabels)},x=[],f=0,m=0;for(let B=0;B<a.leftSize;B++){let I=d({side:"left",sideIndex:B,truePinIndex:m}),q=n.numericSchPinStyle?.[`pin${I}`]??n.numericSchPinStyle?.[I];q?.topMargin&&(f+=q.topMargin),x.push({trueIndex:m,pinNumber:I,side:"left",distanceFromOrthogonalEdge:f}),q?.bottomMargin&&(f+=q.bottomMargin),B===a.leftSize-1?s.left=f:f+=n.schPinSpacing,m++}f=0;for(let B=0;B<a.bottomSize;B++){let I=d({side:"bottom",sideIndex:B,truePinIndex:m}),q=n.numericSchPinStyle?.[`pin${I}`]??n.numericSchPinStyle?.[I];q?.leftMargin&&(f+=q.leftMargin),x.push({trueIndex:m,pinNumber:I,side:"bottom",distanceFromOrthogonalEdge:f}),q?.rightMargin&&(f+=q.rightMargin),B===a.bottomSize-1?s.bottom=f:f+=n.schPinSpacing,m++}f=0;for(let B=0;B<a.rightSize;B++){let I=d({side:"right",sideIndex:B,truePinIndex:m}),q=n.numericSchPinStyle?.[`pin${I}`]??n.numericSchPinStyle?.[I];q?.bottomMargin&&(f+=q.bottomMargin),x.push({trueIndex:m,pinNumber:I,side:"right",distanceFromOrthogonalEdge:f}),q?.topMargin&&(f+=q.topMargin),B===a.rightSize-1?s.right=f:f+=n.schPinSpacing,m++}f=0;for(let B=0;B<a.topSize;B++){let I=d({side:"top",sideIndex:B,truePinIndex:m}),q=n.numericSchPinStyle?.[`pin${I}`]??n.numericSchPinStyle?.[I];q?.rightMargin&&(f+=q.rightMargin),x.push({trueIndex:m,pinNumber:I,side:"top",distanceFromOrthogonalEdge:f}),q?.leftMargin&&(f+=q.leftMargin),B===a.topSize-1?s.top=f:f+=n.schPinSpacing,m++}let y=n.schWidth;if(y===void 0){y=Math.max(s.top+n.schPinSpacing*2,s.bottom+n.schPinSpacing*2);let B=n.pinLabels?Math.max(...Object.values(n.pinLabels).map(q=>q.length*.1)):0,I=B>0?1.1:0;y=Math.max(y,B+I)}let b=n.schHeight;b||(b=Math.max(s.left+n.schPinSpacing*2,s.right+n.schPinSpacing*2));let E={left:{x:-y/2-e,y:s.left/2},bottom:{x:-s.bottom/2,y:-b/2-e},right:{x:y/2+e,y:-s.right/2},top:{x:s.top/2,y:b/2+e}},A={left:{x:0,y:-1},right:{x:0,y:1},top:{x:-1,y:0},bottom:{x:1,y:0}},w=x.map(B=>{let{distanceFromOrthogonalEdge:I,side:q}=B,G=E[q],j=A[q];return{x:G.x+I*j.x,y:G.y+I*j.y,...B}});return{getPortPositionByPinNumber(B){let I=w.find(q=>q.pinNumber.toString()===B.toString());return I||null},getSize(){return{width:y,height:b}},getSizeIncludingPins(){return{width:y+(a.leftSize||a.rightSize?.4:0),height:b+(a.topSize||a.bottomSize?.4:0)}},pinCount:l}},pGt=(0,Cwe.default)("tscircuit:core:footprint"),_we=class extends ga{get config(){return{componentName:"Footprint",zodProps:X8e}}doInitialPcbFootprintLayout(){if(this.root?.pcbDisabled)return;let n=this.children.filter(E=>E.componentName==="Constraint");if(n.length===0)return;let{isFlipped:e}=this._getPcbPrimitiveFlippedHelpers(),a=E=>e&&"left"in E&&"right"in E?{...E,left:E.right,right:E.left}:E,s=n.flatMap(E=>E._getAllReferencedComponents().componentsWithSelectors).map(({component:E,selector:A,componentSelector:w,edge:B})=>({component:E,selector:A,componentSelector:w,edge:B,bounds:E._getPcbCircuitJsonBounds()}));if(s.some(E=>E.edge))throw new Error("edge constraints not implemented yet for footprint layout, contributions welcome!");function l(E){return s.find(({selector:A})=>A===E)}let d=new o5,x={};function f(E){return E in x||(x[E]=new o1(E),d.addEditVariable(x[E],qs.weak)),x[E]}for(let{selector:E,bounds:A}of s){let w=f(`${E}_x`),B=f(`${E}_y`);d.suggestValue(w,A.center.x),d.suggestValue(B,A.center.y)}for(let E of n){let A=E._parsedProps;if("xDist"in A){let{xDist:w,left:B,right:I,edgeToEdge:q,centerToCenter:G}=a(A),j=f(`${B}_x`),O=f(`${I}_x`),V=l(B)?.bounds,te=l(I)?.bounds;if(G){let N=new Ps(O,[-1,j]);d.addConstraint(new Zu(N,yo.Eq,A.xDist,qs.required))}else if(q){let N=new Ps(O,-te.width/2,[-1,j],-V.width/2);d.addConstraint(new Zu(N,yo.Eq,A.xDist,qs.required))}}else if("yDist"in A){let{yDist:w,top:B,bottom:I,edgeToEdge:q,centerToCenter:G}=A,j=f(`${B}_y`),O=f(`${I}_y`),V=l(B)?.bounds,te=l(I)?.bounds;if(G){let N=new Ps(j,[-1,O]);d.addConstraint(new Zu(N,yo.Eq,A.yDist,qs.required))}else if(q){let N=new Ps(j,V.height/2,[-1,O],-te.height/2);d.addConstraint(new Zu(N,yo.Eq,A.yDist,qs.required))}}else if("sameY"in A){let{for:w}=A;if(w.length<2)continue;let B=w.map(q=>f(`${q}_y`)),I=new Ps(...B.slice(1));d.addConstraint(new Zu(I,yo.Eq,B[0],qs.required))}else if("sameX"in A){let{for:w}=A;if(w.length<2)continue;let B=w.map(q=>f(`${q}_x`)),I=new Ps(...B.slice(1));d.addConstraint(new Zu(I,yo.Eq,B[0],qs.required))}}d.updateVariables(),pGt.enabled&&(console.log("Solution to layout constraints:"),console.table(Object.entries(x).map(([E,A])=>({var:E,val:A.value()}))));let m={left:1/0,right:-1/0,top:-1/0,bottom:1/0};for(let{selector:E,bounds:{width:A,height:w}}of s){let B=f(`${E}_x`),I=f(`${E}_y`),q=B.value()-A/2,G=B.value()+A/2,j=I.value()+w/2,O=I.value()-w/2;m.left=Math.min(m.left,q),m.right=Math.max(m.right,G),m.top=Math.max(m.top,j),m.bottom=Math.min(m.bottom,O)}let y={x:-(m.right+m.left)/2,y:-(m.top+m.bottom)/2},b=this.getPrimitiveContainer()._getGlobalPcbPositionBeforeLayout();y.x+=b.x,y.y+=b.y;for(let{component:E,selector:A}of s){let w=f(`${A}_x`),B=f(`${A}_y`);E._setPositionFromLayout({x:w.value()+y.x,y:B.value()+y.y})}}},xGt=(n,e)=>{if(!n)return;let a={};for(let[s,l]of Object.entries(n)){let d=zF(s,e),x={leftMargin:l.marginLeft??l.leftMargin,rightMargin:l.marginRight??l.rightMargin,topMargin:l.marginTop??l.topMargin,bottomMargin:l.marginBottom??l.bottomMargin};a[`pin${d}`]={...a[`pin${d}`],...x}}return a},ZSe=class{constructor({input:n}){X(this,"input");this.input=n}solveAndMapToTraces(){let n=[];for(let e of this.input.connections){if(e.pointsToConnect.length!==2)continue;let[a,s]=e.pointsToConnect,l={type:"pcb_trace",pcb_trace_id:"",connection_name:e.name,route:[{route_type:"wire",x:a.x,y:a.y,layer:"top",width:.1},{route_type:"wire",x:s.x,y:s.y,layer:"top",width:.1}]};n.push(l)}return n}},fGt=n=>{let e=Math.min(...n.map(d=>d.center.x)),a=Math.max(...n.map(d=>d.center.x)),s=Math.min(...n.map(d=>d.center.y)),l=Math.max(...n.map(d=>d.center.y));return{minX:e,maxX:a,minY:s,maxY:l}},QSe=["top","bottom","inner1","inner2"],OS=(n,e=[])=>{let a=[];if(e.length===0){let f=n[0].layers;for(let m of f)a.push(...OS(n.slice(1),[m]));return a}if(n.length===0)return[];let s=n[0],l=s.via||s.optional_via,d=e[e.length-1];if(n.length===1){let f=s;return f.layers&&l?f.layers.map(m=>({layer_path:[...e,m]})):f.layers?.includes(d)?[{layer_path:[...e,d]}]:[]}if(!l)return s.layers&&!s.layers.includes(d)?[]:OS(n.slice(1),e.concat([d]));let x=(s.optional_via?QSe:QSe.filter(f=>f!==d)).filter(f=>!s.layers||s.layers?.includes(f));for(let f of x)a.push(...OS(n.slice(1),e.concat(f)));return a};function ewe(n){let e={x:n.to.x-n.from.x,y:n.to.y-n.from.y},a=Math.abs(e.x),s=Math.abs(e.y);return a>s?e.x>0?"right":"left":e.y>0?"down":"up"}function Ng(n,e){return Math.hypot(n.x-e.x,n.y-e.y)}var hGt=n=>{if(n.length===1)return n[0];if(n.some(m=>m.length===0))throw new Error("Cannot merge routes with zero length");let e=[],a=n[0][0],s=n[0][n[0].length-1],l=n[1][0],d=n[1][n[1].length-1],x=Math.min(Ng(a,l),Ng(a,d)),f=Math.min(Ng(s,l),Ng(s,d));x<f?e.push(...n[0].reverse()):e.push(...n[0]);for(let m=1;m<n.length;m++){let y=e[e.length-1],b=n[m],E=b[0],A=b[b.length-1],w=Ng(y,E),B=Ng(y,A);w<B?e.push(...b):e.push(...b.reverse())}for(let m=1;m<e.length-1;m++){let y=e[m-1],b=e[m];y.route_type==="wire"&&b.route_type==="wire"&&y.layer!==b.layer&&e.splice(m,0,{x:y.x,y:y.y,from_layer:y.layer,to_layer:b.layer,route_type:"via"})}return e},mGt=(n,e)=>{let a="_getGlobalPcbPositionBeforeLayout"in n?n._getGlobalPcbPositionBeforeLayout():n,s="_getGlobalPcbPositionBeforeLayout"in e?e._getGlobalPcbPositionBeforeLayout():e;return Math.sqrt((a.x-s.x)**2+(a.y-s.y)**2)};function gGt(n,e){if(e.length===0)throw new Error("No candidates given to getClosest method");let a=e[0],s=1/0;for(let l of e){let d=mGt(n,l);d<s&&(a=l,s=d)}return a}var yGt=(n,e)=>{let a=0;a+=n.length??0,a+=e.filter(s=>s.is_crossing).length;for(let s=1;s<e.length;s++){let l=e[s-1],d=e[s],x=Math.abs(l.from.x-l.to.x)<.01,f=Math.abs(d.from.x-d.to.x)<.01;x!==f&&a++}return a},qF=n=>({up:"bottom",down:"top",left:"right",right:"left"})[n]??null,jW=({firstEdge:n,firstEdgePort:e,firstDominantDirection:a,lastEdge:s,lastEdgePort:l,lastDominantDirection:d})=>{if(n&&e)return jW({lastEdge:{from:n.to,to:n.from},lastEdgePort:e,lastDominantDirection:a}).reverse().map(f=>({from:f.to,to:f.from}));let x=[];if(s&&l){let f={x:s.to.x,y:s.to.y};d==="left"||d==="right"?(f.x=l.position.x,x.push({from:s.to,to:{...f}}),x.push({from:f,to:{...l.position}})):(f.y=l.position.y,x.push({from:s.to,to:{...f}}),x.push({from:f,to:{...l.position}}))}return x=x.filter(f=>_i(f.from,f.to)>.01),x};function DGt(n){try{return[n(),null]}catch(e){return[null,e]}}var bGt=(n,{db:e})=>{let a=n.map(s=>{let l=e.source_port.get(s.source_port_id);if(!l?.source_component_id)return null;let d=e.source_component.get(l.source_component_id);return d?.ftype==="simple_capacitor"?d.max_decoupling_trace_length:null}).filter(s=>s!==null);if(a.length!==0)return Math.min(...a)};function FGt({ports:n,nets:e}){if(n.length>=2)return`${n[0]?.selector} to ${n[1]?.selector}`;if(n.length===1&&e.length===1)return`${n[0]?.selector} to net.${e[0]._parsedProps.name}`}var EGt=(n,{db:e})=>{let a=e.pcb_board.list()[0];if(a.outline){let m=a.outline,y=(b,E)=>{let A=!1;for(let w=0,B=E.length-1;w<E.length;B=w++){let I=E[w].x,q=E[w].y,G=E[B].x,j=E[B].y;q>b.y!=j>b.y&&b.x<(G-I)*(b.y-q)/(j-q)+I&&(A=!A)}return A};return n.some(b=>!y(b,m))}let s=a.width,l=a.height,d=a.center.x,x=a.center.y;return n.some(m=>m.x<d-s/2||m.y<x-l/2||m.x>d+s/2||m.y>x+l/2)},twe=(n,e)=>Math.abs(n-e)<1e-4,vGt=(n,e,{viaDiameter:a=.5}={})=>{let s=[];for(let l=0;l<n.length-1;l++){let[d,x]=[n[l],n[l+1]],f=l-1>=0?n[l-1]:null,m=twe(d.y,x.y),y=twe(d.x,x.x);if(!m&&!y)throw new Error(`getObstaclesFromTrace currently only supports horizontal and vertical traces (not diagonals) Conflicting trace: ${e}, start: (${d.x}, ${d.y}), end: (${x.x}, ${x.y})`);let b={type:"rect",layers:[d.layer],center:{x:(d.x+x.x)/2,y:(d.y+x.y)/2},width:m?Math.abs(d.x-x.x):.1,height:y?Math.abs(d.y-x.y):.1,connectedTo:[e]};if(s.push(b),f&&f.layer===d.layer&&d.layer!==x.layer){let E={type:"rect",layers:[d.layer,x.layer],center:{x:d.x,y:d.y},connectedTo:[e],width:a,height:a};s.push(E)}}return s};function CGt(n,e=4){let{center:a,width:s,height:l,rotation:d}=n,x=[],f=d*Math.PI/180,m=Math.cos(f),y=Math.sin(f),b=(d%360+360)%360;if(l<=s?b>=45&&b<135||b>=225&&b<315:b>=135&&b<225||b>=315||b<45){let A=s/e;for(let w=0;w<e;w++){let B=(w-e/2+.5)*A,I=-B*m,q=-B*y,G=A*1.1,j=Math.abs(l*m)+Math.abs(A*y);x.push({center:{x:a.x+I,y:a.y+q},width:G,height:j})}}else{let A=l/e;for(let w=0;w<e;w++){let B=(w-e/2+.5)*A,I=-B*y,q=B*m,G=Math.abs(s*m)+Math.abs(A*y),j=A*1.1;x.push({center:{x:a.x+I,y:a.y+q},width:G,height:j})}}return x}function _Gt(n,e={}){if(n.length<3)return[];let{rectHeight:a=.1}=e,s=[],l=n.map(f=>f.y),d=Math.min(...l),x=Math.max(...l);for(let f=d;f<x;f+=a){let m=f+a/2,y=[];for(let b=0;b<n.length;b++){let E=n[b],A=n[(b+1)%n.length];if(E.y<=m&&A.y>m||A.y<=m&&E.y>m){let w=(m-E.y)*(A.x-E.x)/(A.y-E.y)+E.x;y.push(w)}}y.sort((b,E)=>b-E);for(let b=0;b<y.length;b+=2)if(b+1<y.length){let E=y[b],w=y[b+1]-E;w>1e-6&&s.push({center:{x:E+w/2,y:m},width:w,height:a})}}return s}function AGt(n,e={}){let{center:a,radius:s}=n,{rectHeight:l=.1}=e,d=[],x=Math.ceil(s*2/l);for(let f=0;f<x;f++){let m=a.y-s+(f+.5)*l,y=m-a.y,b=Math.sqrt(s*s-y*y);b>0&&d.push({center:{x:a.x,y:m},width:b*2,height:l})}return d}var rx=["top","inner1","inner2","bottom"],Awe=(n,e)=>{let a=l=>e?l.concat(l.map(d=>e?.getNetConnectedToId(d)).filter(Boolean)):l,s=[];for(let l of n)if(l.type==="pcb_smtpad"){if(l.shape==="circle")s.push({type:"oval",layers:[l.layer],center:{x:l.x,y:l.y},width:l.radius*2,height:l.radius*2,connectedTo:a([l.pcb_smtpad_id])});else if(l.shape==="rect")s.push({type:"rect",layers:[l.layer],center:{x:l.x,y:l.y},width:l.width,height:l.height,connectedTo:a([l.pcb_smtpad_id])});else if(l.shape==="rotated_rect"){let d={center:{x:l.x,y:l.y},width:l.width,height:l.height,rotation:l.ccw_rotation},x=CGt(d);for(let f of x)s.push({type:"rect",layers:[l.layer],center:f.center,width:f.width,height:f.height,connectedTo:a([l.pcb_smtpad_id])})}}else if(l.type==="pcb_keepout")l.shape==="circle"?s.push({type:"oval",layers:l.layers,center:{x:l.center.x,y:l.center.y},width:l.radius*2,height:l.radius*2,connectedTo:[]}):l.shape==="rect"&&s.push({type:"rect",layers:l.layers,center:{x:l.center.x,y:l.center.y},width:l.width,height:l.height,connectedTo:[]});else if(l.type==="pcb_cutout"){if(l.shape==="rect")s.push({type:"rect",layers:rx,center:{x:l.center.x,y:l.center.y},width:l.width,height:l.height,connectedTo:[]});else if(l.shape==="circle"){let d=AGt({center:l.center,radius:l.radius},{rectHeight:.6});for(let x of d)s.push({type:"rect",layers:rx,center:x.center,width:x.width,height:x.height,connectedTo:[]})}else if(l.shape==="polygon"){let d=_Gt(l.points,{rectHeight:.6});for(let x of d)s.push({type:"rect",layers:rx,center:x.center,width:x.width,height:x.height,connectedTo:[]})}}else if(l.type==="pcb_hole")l.hole_shape==="oval"?s.push({type:"oval",center:{x:l.x,y:l.y},width:l.hole_width,height:l.hole_height,connectedTo:[]}):l.hole_shape==="square"?s.push({type:"rect",layers:rx,center:{x:l.x,y:l.y},width:l.hole_diameter,height:l.hole_diameter,connectedTo:[]}):(l.hole_shape==="round"||l.hole_shape==="circle")&&s.push({type:"rect",layers:rx,center:{x:l.x,y:l.y},width:l.hole_diameter,height:l.hole_diameter,connectedTo:[]});else if(l.type==="pcb_plated_hole")l.shape==="circle"?s.push({type:"oval",layers:rx,center:{x:l.x,y:l.y},width:l.outer_diameter,height:l.outer_diameter,connectedTo:a([l.pcb_plated_hole_id])}):l.shape==="circular_hole_with_rect_pad"?s.push({type:"rect",layers:rx,center:{x:l.x,y:l.y},width:l.rect_pad_width,height:l.rect_pad_height,connectedTo:a([l.pcb_plated_hole_id])}):(l.shape==="oval"||l.shape==="pill")&&s.push({type:"oval",layers:rx,center:{x:l.x,y:l.y},width:l.outer_width,height:l.outer_height,connectedTo:a([l.pcb_plated_hole_id])});else if(l.type==="pcb_trace"){let d=vGt(l.route.map(x=>({x:x.x,y:x.y,layer:"layer"in x?x.layer:x.from_layer})),l.source_trace_id);s.push(...d)}else l.type==="pcb_via"&&s.push({type:"rect",layers:l.layers,center:{x:l.x,y:l.y},connectedTo:[],width:l.outer_diameter,height:l.outer_diameter});return s},nx=({anchor_position:n,anchor_side:e,text:a,font_size:s=.18})=>{let l=.1*(s/.18),d=a.length*l,x=s,f={...n};switch(e){case"right":f.x-=d/2;break;case"left":f.x+=d/2;break;case"top":f.y-=x/2;break;case"bottom":f.y+=x/2;break}return f},XW=({db:n,source_trace_id:e,sameNetOnly:a,differentNetOnly:s})=>{!a&&!s&&(s=!0);let l=n.source_trace.get(e),d=[];for(let x of n.schematic_trace.list()){if(x.source_trace_id===e)continue;let m=n.source_trace.get(x.source_trace_id)?.subcircuit_connectivity_map_key===l.subcircuit_connectivity_map_key;s&&m||a&&!m||d.push(x)}return d},RGt=({edges:n,otherEdges:e})=>{let a=[...n];for(let s=0;s<a.length;s++){if(s>2e3)throw new Error("Over 2000 iterations spent inside createSchematicTraceCrossingSegments, you have triggered an infinite loop, please report this!");let l=a[s],d=Math.abs(l.from.x-l.to.x)<.01?"vertical":l.from.y===l.to.y?"horizontal":"not-orthogonal";if(d==="not-orthogonal")continue;let x=[];for(let I of e){let q=I.from.x===I.to.x?"vertical":I.from.y===I.to.y?"horizontal":"not-orthogonal";if(q==="not-orthogonal"||d===q)continue;if(Lp([l.from,l.to],[I.from,I.to],{lineThickness:.01})){let j=d==="vertical"?l.from.x:I.from.x,O=d==="vertical"?I.from.y:l.from.y,V={x:j,y:O};x.push({otherEdge:I,crossingPoint:V,distanceFromEdgeFrom:_i(l.from,V)})}}if(x.length===0)continue;let f=x[0];for(let I of x)I.distanceFromEdgeFrom<f.distanceFromEdgeFrom&&(f=I);let m=f.crossingPoint,y=.075;if(m.x===l.from.x&&m.y===l.from.y)continue;let b=p5(l.from,m),E={x:m.x-b.x*y/2,y:m.y-b.y*y/2},A={x:m.x+b.x*y/2,y:m.y+b.y*y/2},w=_i(A,l.to)<y,B=[{from:l.from,to:E},{from:E,to:A,is_crossing:!0},{from:A,to:l.to}];a.splice(s,1,...B),s+=B.length-2,w&&s++}return a},NW=.001,kg=(n,e)=>{let a=Math.min(e.from.x,e.to.x),s=Math.max(e.from.x,e.to.x),l=Math.min(e.from.y,e.to.y),d=Math.max(e.from.y,e.to.y);return n.x>=a&&n.x<=s&&n.y>=l&&n.y<=d},rwe=n=>{let e=Math.abs(n.from.x-n.to.x)<NW,a=Math.abs(n.from.y-n.to.y)<NW;return e?"vertical":a?"horizontal":"diagonal"},SGt=(n,e)=>{let a=rwe(n),s=rwe(e);if(a===s)return null;if(a==="vertical"&&s==="horizontal"||a==="horizontal"&&s==="vertical"){let E=a==="vertical"?n:e,A=a==="horizontal"?n:e,w=E.from.x,B=A.from.y,I={x:w,y:B};return kg(I,n)&&kg(I,e)?I:null}if(a==="vertical"||s==="vertical"){let E=a==="vertical"?n:e,A=a==="vertical"?e:n,w=E.from.x,B=(A.to.y-A.from.y)/(A.to.x-A.from.x),I=A.from.y-B*A.from.x,q=B*w+I,G={x:w,y:q};return kg(G,n)&&kg(G,e)?G:null}let l=(n.to.y-n.from.y)/(n.to.x-n.from.x),d=n.from.y-l*n.from.x,x=(e.to.y-e.from.y)/(e.to.x-e.from.x),f=e.from.y-x*e.from.x;if(Math.abs(l-x)<NW)return null;let m=(f-d)/(l-x),y=l*m+d,b={x:m,y};return kg(b,n)&&kg(b,e)?b:null},wGt=({edges:n,db:e,source_trace_id:a})=>{let s=XW({db:e,source_trace_id:a,sameNetOnly:!0}).flatMap(d=>d.edges),l=new Map;for(let d of n)for(let x of s){let f=SGt(d,x);if(f){let m=`${f.x.toFixed(6)},${f.y.toFixed(6)}`;l.has(m)||l.set(m,f)}}return Array.from(l.values())};function BGt(n){let e=1/0,a=1/0,s=-1/0,l=-1/0;for(let d of n){let x,f,m,y;d.type==="schematic_component"?(x=d.center?.x,f=d.center?.y,m=d.size?.width,y=d.size?.height):d.type==="schematic_box"?(x=d.x,f=d.y,m=d.width,y=d.height):d.type==="schematic_port"?(x=d.center?.x,f=d.center?.y,m=.2,y=.2):d.type==="schematic_text"&&(x=d.position?.x,f=d.position?.y,m=(d.text?.length??0)*.1,y=.2),typeof x=="number"&&typeof f=="number"&&typeof m=="number"&&typeof y=="number"&&(e=Math.min(e,x-m/2),s=Math.max(s,x+m/2),a=Math.min(a,f-y/2),l=Math.max(l,f+y/2))}return{minX:e,maxX:s,minY:a,maxY:l}}function TGt(n,e={}){let{minX:a,maxX:s,minY:l,maxY:d}=n,x=e.padding??1;if(!isFinite(a)||!isFinite(s)||!isFinite(l)||!isFinite(d))return[];let f=a-x,m=s+x,y=d+x,b=l-x,E=.01;return[{type:"rect",layers:["top"],center:{x:(f+m)/2,y},width:m-f,height:E,connectedTo:[]},{type:"rect",layers:["top"],center:{x:(f+m)/2,y:b},width:m-f,height:E,connectedTo:[]},{type:"rect",layers:["top"],center:{x:f,y:(y+b)/2},width:E,height:y-b,connectedTo:[]},{type:"rect",layers:["top"],center:{x:m,y:(y+b)/2},width:E,height:y-b,connectedTo:[]}]}var PGt=n=>{let e=n.root.db,a=n._findConnectedPorts().ports??[],s=new Set(a.map(x=>x.schematic_port_id)),l=[];for(let x of e.toArray()){if(x.type==="schematic_component"){let f=!!x.symbol_name,m=x.size.width>x.size.height?"horz":"vert";l.push({type:"rect",layers:["top"],center:x.center,width:x.size.width+(f&&m==="horz"?-.5:0),height:x.size.height+(f&&m==="vert"?-.5:0),connectedTo:[]})}if(x.type==="schematic_port"){if(s.has(x.schematic_port_id))continue;let f=x.facing_direction?x5(x.facing_direction):{x:0,y:0};l.push({type:"rect",layers:["top"],center:{x:x.center.x-f.x*.1,y:x.center.y-f.y*.1},width:.1+Math.abs(f.x)*.3,height:.1+Math.abs(f.y)*.3,connectedTo:[]})}x.type==="schematic_text"&&l.push({type:"rect",layers:["top"],center:x.position,width:(x.text?.length??0)*.1,height:.2,connectedTo:[]}),x.type==="schematic_box"&&l.push({type:"rect",layers:["top"],center:{x:x.x,y:x.y},width:x.width,height:x.height,connectedTo:[]})}let d=BGt(e.toArray());return l.push(...TGt(d,{padding:1})),l},IGt=({edges:n,db:e,source_trace_id:a})=>{let s=e.source_trace.get(a),l=XW({db:e,source_trace_id:a,differentNetOnly:!0}).flatMap(x=>x.edges),d=x=>{let{from:f,to:m}=x;return f.x===m.x?"vertical":"horizontal"};for(let x of n){let f=d(x),m=()=>l.find(b=>d(b)===f&&Lp([x.from,x.to],[b.from,b.to],{lineThickness:.05})),y=m();for(;y;)f==="horizontal"?(x.from.y+=.1,x.to.y+=.1):(x.from.x+=.1,x.to.x+=.1),y=m()}},kW=n=>{switch(n){case"up":return"y+";case"down":return"y-";case"left":return"x-";case"right":return"x+";default:}},jGt=TAe.version??"unknown",MF=class extends Error{constructor(n){super(`${n} (capacity-autorouter@${jGt})`),this.name="AutorouterError"}},US=class extends Error{constructor(n){super(n.message),this.errorData=n,this.name="TraceConnectionError"}},NGt=n=>{if(n.root?._featureMspSchematicTraceRouting||n._couldNotFindPort||n.root?.schematicDisabled)return;let{db:e}=n.root,{_parsedProps:a,parent:s}=n;if(!s)throw new Error("Trace has no parent");let l,d;try{let xe=n._findConnectedPorts();l=xe.allPortsFound,d=xe.portsWithSelectors??[]}catch(xe){if(xe instanceof US){e.source_trace_not_connected_error.insert({...xe.errorData,error_type:"source_trace_not_connected_error"});return}throw xe}let{netsWithSelectors:x}=n._findConnectedNets();if(!l)return;let m=d.map(xe=>xe.port.schematic_port_id).sort().join(","),y=n.root?._getBoard();if(y?._connectedSchematicPortPairs&&y._connectedSchematicPortPairs.has(m))return;let b={name:n.source_trace_id,pointsToConnect:[]},E=PGt(n),A=d.filter(({port:xe})=>xe.schematic_port_id!==null).map(({port:xe})=>({port:xe,position:xe._getGlobalSchematicPositionAfterLayout(),schematic_port_id:xe.schematic_port_id??void 0,facingDirection:xe.facingDirection}));if(A.length===1&&x.length===1){let xe=x[0].net,{port:Ae,position:Ie}=A[0],Le=n.getSubcircuit().selectAll("netlabel").find(et=>{let Qe=et._parsedProps.connection??et._parsedProps.connectsTo;return Qe?Array.isArray(Qe)?Qe.some(Pt=>n.getSubcircuit().selectOne(Pt,{port:!0})===Ae):n.getSubcircuit().selectOne(Qe,{port:!0})===Ae:!1});if(!Le){let et=e.schematic_net_label.getWhere({source_trace_id:n.source_trace_id});et&&(Le=et)}if(Le){let et="_getGlobalSchematicPositionBeforeLayout"in Le?Le._getGlobalSchematicPositionBeforeLayout():Le.anchor_position,Qe=[];Ie.x===et.x||Ie.y===et.y?Qe.push({from:Ie,to:et}):(Qe.push({from:Ie,to:{x:et.x,y:Ie.y}}),Qe.push({from:{x:et.x,y:Ie.y},to:et}));let Mt=e.schematic_trace.insert({source_trace_id:n.source_trace_id,edges:Qe,junctions:[]});n.schematic_trace_id=Mt.schematic_trace_id;return}if(n.props.schDisplayLabel){let et=qF(Ae.facingDirection)??"bottom";e.schematic_net_label.insert({text:n.props.schDisplayLabel,source_net_id:xe.source_net_id,anchor_position:Ie,center:nx({anchor_position:Ie,anchor_side:et,text:n.props.schDisplayLabel}),anchor_side:et});return}let dt=qF(Ae.facingDirection)??"bottom",rt=e.schematic_net_label.insert({text:xe._parsedProps.name,source_net_id:xe.source_net_id,anchor_position:Ie,center:nx({anchor_position:Ie,anchor_side:dt,text:xe._parsedProps.name}),anchor_side:dt});return}if(n.props.schDisplayLabel&&("from"in n.props&&"to"in n.props||"path"in n.props)){n._doInitialSchematicTraceRenderWithDisplayLabel();return}if(A.length<2)return;let I=(()=>{let xe=[];for(let Ie=0;Ie<A.length-1;Ie++){let Le=A[Ie],dt=A[Ie+1],rt=f5({x:Le.position.x,y:Le.position.y,facingDirection:kW(Le.facingDirection)},{x:dt.position.x,y:dt.position.y,facingDirection:kW(dt.facingDirection)});for(let et=0;et<rt.length-1;et++)xe.push({from:rt[et],to:rt[et+1]})}let Ae=(Ie,Le)=>{let dt=Le.width/2,rt=Le.height/2,et=Le.center.x-dt,Qe=Le.center.x+dt,Mt=Le.center.y-rt,Pt=Le.center.y+rt,Ht=yt=>yt.x>=et&&yt.x<=Qe&&yt.y>=Mt&&yt.y<=Pt;return Ht(Ie.from)||Ht(Ie.to)?!0:[[{x:et,y:Mt},{x:Qe,y:Mt}],[{x:Qe,y:Mt},{x:Qe,y:Pt}],[{x:Qe,y:Pt},{x:et,y:Pt}],[{x:et,y:Pt},{x:et,y:Mt}]].some(yt=>Lp([Ie.from,Ie.to],yt,{lineThickness:0}))};for(let Ie of xe)for(let Le of E)if(Ae(Ie,Le))return null;return xe})();I&&I.length===0&&(I=null),b.pointsToConnect=A.map(({position:xe})=>({...xe,layer:"top"}));let q=fGt(E),G=2,j={minTraceWidth:.1,obstacles:E,connections:[b],bounds:{minX:q.minX-G,maxX:q.maxX+G,minY:q.minY-G,maxY:q.maxY+G},layerCount:1},O=ZR,V=!1;if(n.getSubcircuit().props._schDirectLineRoutingEnabled&&(O=ZSe,V=!0),!I){let Ae=new O({input:j,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(Ae.length===0){if(n._isSymbolToChipConnection()||n._isSymbolToSymbolConnection()||n._isChipToChipConnection()){n._doInitialSchematicTraceRenderWithDisplayLabel();return}Ae=new ZSe({input:j}).solveAndMapToTraces(),V=!0}let[{route:Ie}]=Ae;I=[];for(let Le=0;Le<Ie.length-1;Le++)I.push({from:Ie[Le],to:Ie[Le+1]})}let te=n.source_trace_id,N=[];if(!V){IGt({edges:I,db:e,source_trace_id:te});let xe=XW({db:e,source_trace_id:te,differentNetOnly:!0}).flatMap(Ae=>Ae.edges);I=RGt({edges:I,otherEdges:xe}),N=wGt({edges:I,db:e,source_trace_id:n.source_trace_id})}if(!I||I.length===0)return;let se=I[I.length-1],$=A[A.length-1],W=ewe(se);I.push(...jW({lastEdge:se,lastEdgePort:$,lastDominantDirection:W}));let Q=I[0],le=A[0],z=ewe(Q);if(I.unshift(...jW({firstEdge:Q,firstEdgePort:le,firstDominantDirection:z})),!n.source_trace_id)throw new Error("Missing source_trace_id for schematic trace insertion.");if(n.getSubcircuit()._parsedProps.schTraceAutoLabelEnabled&&yGt(N,I)>=5&&(n._isSymbolToChipConnection()||n._isSymbolToSymbolConnection()||n._isChipToChipConnection())){n._doInitialSchematicTraceRenderWithDisplayLabel();return}let pe=e.schematic_trace.insert({source_trace_id:n.source_trace_id,edges:I,junctions:N});n.schematic_trace_id=pe.schematic_trace_id;for(let{port:xe}of d)xe.schematic_port_id&&e.schematic_port.update(xe.schematic_port_id,{is_connected:!0});y?._connectedSchematicPortPairs&&y._connectedSchematicPortPairs.add(m)};function Rwe(n){let e=0;for(let a=0;a<n.length;a++){let s=n[a];if(s.route_type==="wire"){let l=n[a+1];if(l){let d=l.x-s.x,x=l.y-s.y;e+=Math.sqrt(d*d+x*x)}}else s.route_type==="via"&&(e+=1.6)}return e}var NS=n=>({...n._getGlobalPcbPositionAfterLayout(),layers:n.getAvailablePcbLayers()}),kGt=!1;function MGt(n){if(n.root?.pcbDisabled)return;let{db:e}=n.root,{_parsedProps:a,parent:s}=n,l=n.getSubcircuit();if(!s)throw new Error("Trace has no parent");if(l._parsedProps.routingDisabled)return;let d=l._parsedProps.pcbRouteCache?.pcbTraces;if(d){let W=e.pcb_trace.insert({route:d.flatMap(Q=>Q.route),source_trace_id:n.source_trace_id,subcircuit_id:l?.subcircuit_id??void 0,pcb_group_id:n.getGroup()?.pcb_group_id??void 0});n.pcb_trace_id=W.pcb_trace_id;return}if(a.pcbPath&&a.pcbPath.length>0||!l._shouldUseTraceByTraceRouting())return;let{allPortsFound:x,ports:f}=n._findConnectedPorts(),m=[];if(!x)return;let y=[];for(let W of f)W._hasMatchedPcbPrimitive()||y.push(W);if(y.length>0){e.pcb_trace_error.insert({error_type:"pcb_trace_error",source_trace_id:n.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, ${n} wasn't routed. Missing ports: ${y.map(W=>W.getString()).join(", ")}`,pcb_trace_id:n.pcb_trace_id,pcb_component_ids:[],pcb_port_ids:y.map(W=>W.pcb_port_id).filter(Boolean)});return}let b=n._findConnectedNets().netsWithSelectors;if(f.length===0&&b.length===2){n.renderError("Trace connects two nets, we haven't implemented a way to route this yet");return}else if(f.length===1&&b.length===1){let W=f[0],le=b[0].net.getAllConnectedPorts().filter(pe=>pe!==W);if(le.length===0){console.log("Nothing to connect this port to, the net is empty. TODO should emit a warning!");return}let z=gGt(W,le);m.push(z),f.push(z)}else if(f.length>1&&b.length>=1){n.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 E=f.flatMap(W=>W.matchedComponents.filter(Q=>Q.componentName==="TraceHint")),A=(n._parsedProps.pcbRouteHints??[]).concat(E.flatMap(W=>W.getPcbRouteHints()));if(f.length>2){n.renderError(`Trace has more than two ports (${f.map(W=>W.getString()).join(", ")}), routing between more than two ports for a single trace is not implemented`);return}if(n.getSubcircuit().selectAll("trace").filter(W=>W.renderPhaseStates.PcbTraceRender.initialized).some(W=>W._portsRoutedOnPcb.length===f.length&&W._portsRoutedOnPcb.every(Q=>f.includes(Q))))return;let I=[];A.length===0?I=[NS(f[0]),NS(f[1])]:I=[NS(f[0]),...A,NS(f[1])];let q=OS(I);if(kGt&&q.length===0){n.renderError(`Could not find a common layer (using hints) for trace ${n.getString()}`);return}let G=Ku(n.root.db.toArray()),[j,O]=DGt(()=>Awe(n.root.db.toArray()));if(O){n.renderError({type:"pcb_trace_error",error_type:"pcb_trace_error",pcb_trace_error_id:n.pcb_trace_id,message:`Error getting obstacles for autorouting: ${O.message}`,source_trace_id:n.source_trace_id,center:{x:0,y:0},pcb_port_ids:f.map(W=>W.pcb_port_id),pcb_trace_id:n.pcb_trace_id,pcb_component_ids:[]});return}for(let W of j)if(W.connectedTo.length>0){let le=G.getNetConnectedToId(W.connectedTo[0]);le&&W.connectedTo.push(le)}let V=[];if(q.length===0)V=I;else{let W=q[0].layer_path;V=I.map((Q,le)=>Q.via?{...Q,via_to_layer:W[le]}:{...Q,layers:[W[le]]})}V[0].pcb_port_id=f[0].pcb_port_id,V[V.length-1].pcb_port_id=f[1].pcb_port_id;let te=[];for(let[W,Q]of Fwe(V)){let le="via_to_layer"in W?W.via_to_layer:null,z=2,pe="layers"in W&&W.layers.length===1?W.layers[0]:le??"top",xe="layers"in Q&&Q.layers.length===1?Q.layers[0]:le??"top",Ae="pcb_port_id"in W?W.pcb_port_id:null,Ie="pcb_port_id"in Q?Q.pcb_port_id:null,Le=n.getSubcircuit()._parsedProps.minTraceWidth??.16,dt=new ZR({OBSTACLE_MARGIN:Le*2,isRemovePathLoopsEnabled:!0,optimizeWithGoalBoxes:!!(Ae&&Ie),connMap:G,input:{obstacles:j,minTraceWidth:Le,connections:[{name:n.source_trace_id,pointsToConnect:[{...W,layer:pe,pcb_port_id:Ae},{...Q,layer:xe,pcb_port_id:Ie}]}],layerCount:n.getSubcircuit()._getSubcircuitLayerCount(),bounds:{minX:Math.min(W.x,Q.x)-z,maxX:Math.max(W.x,Q.x)+z,minY:Math.min(W.y,Q.y)-z,maxY:Math.max(W.y,Q.y)+z}}}),rt=null;try{rt=dt.solveAndMapToTraces()}catch(Mt){n.renderError({type:"pcb_trace_error",pcb_trace_error_id:n.source_trace_id,error_type:"pcb_trace_error",message:`error solving route: ${Mt.message}`,source_trace_id:n.pcb_trace_id,center:{x:(W.x+Q.x)/2,y:(W.y+Q.y)/2},pcb_port_ids:f.map(Pt=>Pt.pcb_port_id),pcb_trace_id:n.pcb_trace_id,pcb_component_ids:f.map(Pt=>Pt.pcb_component_id)})}if(!rt)return;if(rt.length===0){n.renderError({type:"pcb_trace_error",error_type:"pcb_trace_error",pcb_trace_error_id:n.pcb_trace_id,message:`Could not find a route for ${n}`,source_trace_id:n.source_trace_id,center:{x:(W.x+Q.x)/2,y:(W.y+Q.y)/2},pcb_port_ids:f.map(Mt=>Mt.pcb_port_id),pcb_trace_id:n.pcb_trace_id,pcb_component_ids:f.map(Mt=>Mt.pcb_component_id)});return}let[et]=rt;le&&(et.route=et.route.map(Mt=>(Mt.route_type==="wire"&&!Mt.layer&&(Mt.layer=le),Mt))),Ae&&et.route[0].route_type==="wire"&&(et.route[0].start_pcb_port_id=Ae);let Qe=et.route[et.route.length-1];Ie&&Qe.route_type==="wire"&&(Qe.end_pcb_port_id=Ie),te.push(et.route)}let N=hGt(te),se=Rwe(N),$=e.pcb_trace.insert({route:N,source_trace_id:n.source_trace_id,subcircuit_id:n.getSubcircuit()?.subcircuit_id,trace_length:se});n._portsRoutedOnPcb=f,n.pcb_trace_id=$.pcb_trace_id;for(let W of N)W.route_type==="via"&&e.pcb_via.insert({pcb_trace_id:$.pcb_trace_id,x:W.x,y:W.y,hole_diameter:.3,outer_diameter:.6,layers:[W.from_layer,W.to_layer],from_layer:W.from_layer,to_layer:W.to_layer});n._insertErrorIfTraceIsOutsideBoard(N,f)}function OGt(n){if(n.root?.pcbDisabled)return;let{db:e}=n.root,{_parsedProps:a}=n,s=n.getSubcircuit();if(!a.pcbPath||a.pcbPath.length===0)return;let{allPortsFound:l,ports:d,portsWithSelectors:x}=n._findConnectedPorts();if(!l)return;let f=[];for(let G of d)G._hasMatchedPcbPrimitive()||f.push(G);if(f.length>0){e.pcb_trace_error.insert({error_type:"pcb_trace_error",source_trace_id:n.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, ${n} wasn't routed. Missing ports: ${f.map(G=>G.getString()).join(", ")}`,pcb_trace_id:n.pcb_trace_id,pcb_component_ids:[],pcb_port_ids:f.map(G=>G.pcb_port_id).filter(Boolean)});return}let m;a.pcbPathRelativeTo&&(m=x.find(G=>G.selector===a.pcbPathRelativeTo)?.port,m||(m=n.getSubcircuit().selectOne(a.pcbPathRelativeTo))),m||(m=d[0]);let y=d.find(G=>G!==m)??d[1],b=m.getAvailablePcbLayers()[0]||"top",E=a.thickness??n.getSubcircuit()._parsedProps.minTraceWidth??.16,A=m._getGlobalPcbPositionAfterLayout(),w=y._getGlobalPcbPositionAfterLayout(),B=[];B.push({route_type:"wire",x:A.x,y:A.y,width:E,layer:b,start_pcb_port_id:m.pcb_port_id});for(let G of a.pcbPath)B.push({route_type:"wire",x:A.x+G.x,y:A.y+G.y,width:E,layer:b});B.push({route_type:"wire",x:w.x,y:w.y,width:E,layer:b,end_pcb_port_id:y.pcb_port_id});let I=Rwe(B),q=e.pcb_trace.insert({route:B,source_trace_id:n.source_trace_id,subcircuit_id:s?.subcircuit_id??void 0,pcb_group_id:n.getGroup()?.pcb_group_id??void 0,trace_length:I});n._portsRoutedOnPcb=d,n.pcb_trace_id=q.pcb_trace_id,n._insertErrorIfTraceIsOutsideBoard(B,d)}function LGt(n){if(n.root?.schematicDisabled)return;let{db:e}=n.root,{_parsedProps:a,parent:s}=n;if(!s)throw new Error("Trace has no parent");let{allPortsFound:l,portsWithSelectors:d}=n._findConnectedPorts();if(!l)return;let x=d.map(({port:V})=>({port:V,position:V._getGlobalSchematicPositionAfterLayout(),schematic_port_id:V.schematic_port_id,facingDirection:V.facingDirection}));if(x.length<2)throw new Error("Expected at least two ports in portsWithPosition.");let f,m,y=x[0].position,b=x[0].port;if("path"in n.props){if(n.props.path.length!==2)throw new Error("Invalid 'path': Must contain exactly two elements.");[f,m]=n.props.path}else{if(!("from"in n.props&&"to"in n.props))throw new Error("Missing 'from' or 'to' properties in props.");f=n.props.from,m=n.props.to}if(!b.source_port_id)throw new Error(`Missing source_port_id for the 'from' port (${f}).`);let E=x[1].position,A=x[1].port;if(!A.source_port_id)throw new Error(`Missing source_port_id for the 'to' port (${m}).`);let w=e.schematic_net_label.list().find(V=>V.source_net_id===b.source_port_id),B=e.schematic_net_label.list().find(V=>V.source_net_id===A.source_port_id),[I,q]=d.map(({port:V})=>V),j=I.parent?.config.shouldRenderAsSchematicBox?`${I?.parent?.props.name}_${I?.props.name}`:`${q?.parent?.props.name}_${q?.props.name}`,O=n.props.schDisplayLabel??j;if(w&&w.text!==O&&(w.text=`${O} / ${w.text}`),B&&B?.text!==O&&(B.text=`${O} / ${B.text}`),!B){let V=qF(A.facingDirection)??"bottom";e.schematic_net_label.insert({text:n.props.schDisplayLabel??j,source_net_id:A.source_port_id,anchor_position:E,center:nx({anchor_position:E,anchor_side:V,text:n.props.schDisplayLabel??j}),anchor_side:V})}if(!w){let V=qF(b.facingDirection)??"bottom";e.schematic_net_label.insert({text:n.props.schDisplayLabel??j,source_net_id:b.source_port_id,anchor_position:y,center:nx({anchor_position:y,anchor_side:V,text:n.props.schDisplayLabel??j}),anchor_side:V})}}function $Gt(n){let{_parsedProps:e,parent:a}=n;if(!a)throw new Error("Trace has no parent");let l=n.getTracePortPathSelectors().map(d=>({selector:d,port:n.getSubcircuit().selectOne(d,{type:"port"})??null}));for(let{selector:d,port:x}of l)if(!x){let f,m,y=d.lastIndexOf(".");if(y!==-1&&y>d.lastIndexOf(" "))f=d.slice(0,y),m=d.slice(y+1);else{let V=d.match(/^(.*[ >])?([^ >]+)$/);f=V?.[1]?.trim()??"",m=V?.[2]??d}let b=f?n.getSubcircuit().selectOne(f):null;if(!b&&f&&!/[.#\[]/.test(f)&&(b=n.getSubcircuit().selectOne(`.${f}`)),!b){let V=f?`Could not find port for selector "${d}". Component "${f}" not found`:`Could not find port for selector "${d}"`,te=n.getSubcircuit(),N=te.getGroup();throw new US({error_type:"source_trace_not_connected_error",message:V,subcircuit_id:te.subcircuit_id??void 0,source_group_id:N?.source_group_id??void 0,source_trace_id:n.source_trace_id??void 0,selectors_not_found:[d]})}let E=b.children.filter(V=>V.componentName==="Port"),A=m.includes(".")?m.split(".").pop()??"":m,w=E.flatMap(V=>V.getNameAndAliases()),B=w.some(V=>!/^(pin\d+|\d+)$/.test(V)),I=Array.from(new Set(w)).join(", "),q;E.length===0?q="It has no ports":B?q=`It has [${I}]`:q=`It has ${E.length} pins and no pinLabels (consider adding pinLabels)`;let G=`Could not find port for selector "${d}". Component "${b.props.name??f}" found, but does not have pin "${A}". ${q}`,j=n.getSubcircuit(),O=j.getGroup();throw new US({error_type:"source_trace_not_connected_error",message:G,subcircuit_id:j.subcircuit_id??void 0,source_group_id:O?.source_group_id??void 0,source_trace_id:n.source_trace_id??void 0,selectors_not_found:[d]})}return l.some(d=>!d.port)?{allPortsFound:!1}:{allPortsFound:!0,portsWithSelectors:l,ports:l.map(({port:d})=>d)}}var zc=class extends ga{constructor(e){super(e);X(this,"source_trace_id",null);X(this,"pcb_trace_id",null);X(this,"schematic_trace_id",null);X(this,"_portsRoutedOnPcb");X(this,"subcircuit_connectivity_map_key",null);X(this,"_traceConnectionHash",null);X(this,"_couldNotFindPort");this._portsRoutedOnPcb=[]}get config(){return{zodProps:G8e,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(e=>typeof e=="string"?e:e.getPortSelector()):[]}getTracePortPathSelectors(){return this._getTracePortOrNetSelectorListFromProps().filter(e=>!e.includes("net."))}getTracePathNetSelectors(){return this._getTracePortOrNetSelectorListFromProps().filter(e=>e.includes("net."))}_findConnectedPorts(){return $Gt(this)}_resolveNet(e){let a=this.getSubcircuit().selectOne(e,{type:"net"});if(a)return a;let s=e.match(/^net\.(.+)$/),l=s?s[1]:null;return l&&this.root._getBoard().getDescendants().find(x=>x.componentName==="Net"&&x._parsedProps.name===l)||null}_findConnectedNets(){let e=this.getTracePathNetSelectors().map(s=>({selector:s,net:this._resolveNet(s)})),a=e.filter(s=>!s.net);return a.length>0&&this.renderError(`Could not find net for selector "${a[0].selector}" inside ${this}`),{netsWithSelectors:e,nets:e.map(s=>s.net)}}_getAllTracesConnectedToSameNet(){let e=this.getSubcircuit().selectAll("trace"),a=this._findConnectedNets().nets,s=this._findConnectedPorts().ports??[];return e.filter(l=>{if(l===this)return!1;let d=l._findConnectedNets().nets,x=l._findConnectedPorts().ports??[];return d.some(f=>a.includes(f))||x.some(f=>s.includes(f))})}_isExplicitlyConnectedToPort(e){let{allPortsFound:a,portsWithSelectors:s}=this._findConnectedPorts();return a?s.map(d=>d.port).includes(e):!1}_isExplicitlyConnectedToNet(e){return this._findConnectedNets().nets.includes(e)}doInitialCreateNetsFromProps(){zW(this,this.getTracePathNetSelectors())}_computeTraceConnectionHash(){let{allPortsFound:e,ports:a}=this._findConnectedPorts();return!e||!a?null:[...a].sort((d,x)=>(d.pcb_port_id||"").localeCompare(x.pcb_port_id||"")).map(d=>d.pcb_port_id).join(",")}doInitialSourceTraceRender(){let{db:e}=this.root,{_parsedProps:a,parent:s}=this;if(!s){this.renderError("Trace has no parent");return}let l,d;try{let E=this._findConnectedPorts();l=E.allPortsFound,d=E.portsWithSelectors??[]}catch(E){if(E instanceof US){e.source_trace_not_connected_error.insert({...E.errorData,error_type:"source_trace_not_connected_error"}),this._couldNotFindPort=!0;return}throw E}if(!l)return;this._traceConnectionHash=this._computeTraceConnectionHash();let f=e.source_trace.list().find(E=>E.subcircuit_connectivity_map_key===this.subcircuit_connectivity_map_key&&E.connected_source_port_ids.sort().join(",")===this._traceConnectionHash);if(f){this.source_trace_id=f.source_trace_id;return}let m=this._findConnectedNets().nets,y=FGt({ports:d,nets:m}),b=e.source_trace.insert({connected_source_port_ids:d.map(E=>E.port.source_port_id),connected_source_net_ids:m.map(E=>E.source_net_id),subcircuit_id:this.getSubcircuit()?.subcircuit_id,max_length:bGt(d.map(E=>E.port),{db:e})??a.maxLength,display_name:y,min_trace_thickness:a.thickness});this.source_trace_id=b.source_trace_id}_insertErrorIfTraceIsOutsideBoard(e,a){let{db:s}=this.root;EGt(e,{db:s})&&s.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:a.map(d=>d.pcb_port_id)})}doInitialPcbManualTraceRender(){OGt(this)}doInitialPcbTraceRender(){MGt(this)}_doInitialSchematicTraceRenderWithDisplayLabel(){LGt(this)}_isSymbolToChipConnection(){let{allPortsFound:e,ports:a}=this._findConnectedPorts();if(!e||a.length!==2)return!1;let[s,l]=a;if(!s?.parent||!l?.parent)return!1;let d=s.parent.config.shouldRenderAsSchematicBox,x=l.parent.config.shouldRenderAsSchematicBox;return d&&!x||!d&&x}_isSymbolToSymbolConnection(){let{allPortsFound:e,ports:a}=this._findConnectedPorts();if(!e||a.length!==2)return!1;let[s,l]=a;if(!s?.parent||!l?.parent)return!1;let d=!s.parent.config.shouldRenderAsSchematicBox,x=!l.parent.config.shouldRenderAsSchematicBox;return d&&x}_isChipToChipConnection(){let{allPortsFound:e,ports:a}=this._findConnectedPorts();if(!e||a.length!==2)return!1;let[s,l]=a;if(!s?.parent||!l?.parent)return!1;let d=s.parent.config.shouldRenderAsSchematicBox,x=l.parent.config.shouldRenderAsSchematicBox;return d&&x}doInitialSchematicTraceRender(){NGt(this)}},zGt=n=>{let{db:e}=n.root;if(n.pcb_component_id){let a=e.pcb_component.get(n.pcb_component_id);return a?{width:a.width,height:a.height}:null}if(n.pcb_group_id){let a=e.pcb_group.get(n.pcb_group_id);return a?{width:a.width,height:a.height}:null}return null},qGt=(n,e)=>{let{db:a}=n.root,s=a.toArray();if(n.pcb_component_id){m5(s,n.pcb_component_id,e);return}if(n.source_group_id){g5(s,n.source_group_id,e);return}throw new Error(`Cannot reposition component ${n.getString()}: no pcb_component_id or source_group_id`)},UGt=n=>{let{db:e}=n.root;if(!n.source_component_id)return;let a=n.selectAll("port"),s=e.source_trace.list(),l=new Set;for(let x of s)for(let f of x.connected_source_port_ids)l.add(f);let d=n._getInternallyConnectedPins();for(let x of d)if(x.some(f=>f.source_port_id&&l.has(f.source_port_id)))for(let f of x)f.source_port_id&&l.add(f.source_port_id);for(let x of a)x.source_port_id&&VGt(n,x)&&(l.has(x.source_port_id)||e.source_pin_missing_trace_warning.insert({message:`Port ${x.getNameAndAliases()[0]} on ${n.props.name} is missing a trace`,source_component_id:n.source_component_id,source_port_id:x.source_port_id,subcircuit_id:n.getSubcircuit().subcircuit_id??void 0,warning_type:"source_pin_missing_trace_warning"}))},VGt=(n,e)=>{if(n.config.componentName==="Chip"){let a=n.props.pinAttributes;if(!a)return!1;for(let s of e.getNameAndAliases()){let l=a[s];if(l?.requiresPower||l?.requiresGround||l?.requiresVoltage!==void 0)return!0}return!1}return!0},GGt=(0,mwe.default)("tscircuit:core"),XGt=C.object({x:Ia,y:Ia,z:Ia}),Za=class extends ga{constructor(e){super(e);X(this,"reactSubtrees",[]);X(this,"_impliedFootprint");X(this,"isPrimitiveContainer",!0);X(this,"_asyncSupplierPartNumbers");X(this,"pcb_missing_footprint_error_id");X(this,"_hasStartedFootprintUrlLoad",!1);this._addChildrenFromStringFootprint(),this.initPorts()}get defaultInternallyConnectedPinNames(){return[]}get internallyConnectedPinNames(){return(this._parsedProps.internallyConnectedPins??this.defaultInternallyConnectedPinNames).map(a=>a.map(s=>typeof s=="number"?`pin${s}`:s))}initPorts(e={}){if(this.root?.schematicDisabled)return;let{config:a}=this,s=[],l=this._getSchematicPortArrangement();if(l&&!this._parsedProps.pinLabels){for(let y in l){let b=l[y].pins;if(Array.isArray(b))for(let E of b){let A=zF(E,this._parsedProps.pinLabels);s.push(new Fo({pinNumber:A,aliases:e.additionalAliases?.[`pin${A}`]??[]},{originDescription:`schPortArrangement:${y}`}))}}let f=["left","right","top","bottom"],m=1;for(let y of f){let b=l[`${y}Size`];for(let E=0;E<b;E++)s.push(new Fo({pinNumber:m++,aliases:e.additionalAliases?.[`pin${m}`]??[]},{originDescription:`schPortArrangement:${y}`}))}}let d=this._parsedProps.pinLabels;if(d)for(let[f,m]of Object.entries(d)){f=f.replace("pin","");let y=s.find(A=>A._parsedProps.pinNumber===Number(f)),b=Array.isArray(m)?m[0]:m,E=Array.isArray(m)?m.slice(1):[];y?(y.externallyAddedAliases.push(b,...E),y.props.name=b):(y=new Fo({pinNumber:parseInt(f),name:b,aliases:[...E,...e.additionalAliases?.[`pin${parseInt(f)}`]??[]]},{originDescription:`pinLabels:pin${f}`}),s.push(y))}if(a.schematicSymbolName&&!e.ignoreSymbolPorts){let f=Ts[this._getSchematicSymbolNameOrThrow()];if(!f)return;for(let m of f.ports){let y=Ewe(m.labels);if(!y)continue;let b=s.find(E=>E._parsedProps.pinNumber===Number(y));if(b)b.schematicSymbolPortDef=m;else{let E=kF(m.labels.concat(e.additionalAliases?.[`pin${y}`]??[]));E&&(E.originDescription=`schematicSymbol:labels[0]:${m.labels[0]}`,E.schematicSymbolPortDef=m,s.push(E))}}this.addAll(s)}if(!this._getSchematicPortArrangement()){let f=this.getPortsFromFootprint(e);for(let m of f)s.some(y=>y.isMatchingAnyOf(m.getNameAndAliases()))||s.push(m)}let x=e.pinCount??this._getPinCount()??0;for(let f=1;f<=x;f++){if(s.find(y=>y._parsedProps.pinNumber===f))continue;if(!l){s.push(new Fo({pinNumber:f,aliases:e.additionalAliases?.[`pin${f}`]??[]}));continue}let m=[...l.leftSide?.pins??[],...l.rightSide?.pins??[],...l.topSide?.pins??[],...l.bottomSide?.pins??[]].map(y=>zF(y,this._parsedProps.pinLabels));["leftSize","rightSize","topSize","bottomSize","leftPinCount","rightPinCount","topPinCount","bottomPinCount"].some(y=>y in l)&&(m=Array.from({length:this._getPinCount()},(y,b)=>b+1)),m.includes(f)&&s.push(new Fo({pinNumber:f,aliases:e.additionalAliases?.[`pin${f}`]??[]},{originDescription:`notOtherwiseAddedButDeducedFromPinCount:${f}`}))}s.length>0&&this.addAll(s)}_getImpliedFootprintString(){return null}_isFootprintUrl(e){return e.startsWith("http://")||e.startsWith("https://")}_addChildrenFromStringFootprint(){let{pcbRotation:e,pinLabels:a,pcbPinLabels:s}=this.props,{footprint:l}=this.props;if(l??(l=this._getImpliedFootprintString?.()),!!l&&typeof l=="string"){if(this._isFootprintUrl(l))return;let d=Bq.string(l).soup(),x=JSe({componentName:this.name??this.componentName,componentRotation:e,footprint:l,pinLabels:a,pcbPinLabels:s},d);this.addAll(x)}}get portMap(){return new Proxy({},{get:(e,a)=>{let s=this.children.find(l=>l.componentName==="Port"&&l.isMatchingNameOrAlias(a));if(!s)throw new Error(`There was an issue finding the port "${a.toString()}" inside of a ${this.componentName} component with name: "${this.props.name}". This is a bug in @tscircuit/core`);return s}})}getInstanceForReactElement(e){for(let a of this.reactSubtrees)if(a.element===e)return a.component;return null}doInitialSourceRender(){let e=this.config.sourceFtype;if(!e)return;let{db:a}=this.root,{_parsedProps:s}=this,l=a.source_component.insert({ftype:e,name:this.name,manufacturer_part_number:s.manufacturerPartNumber??s.mfn,supplier_part_numbers:s.supplierPartNumbers});this.source_component_id=l.source_component_id}doInitialSchematicComponentRender(){if(this.root?.schematicDisabled)return;let{db:e}=this.root,{schematicSymbolName:a}=this.config;a?this._doInitialSchematicComponentRenderWithSymbol():this._getSchematicBoxDimensions()&&this._doInitialSchematicComponentRenderWithSchematicBoxDimensions();let s=this.getSubcircuit()?._getSchematicManualPlacementForComponent(this);if(this.schematic_component_id&&(this.props.schX!==void 0||this.props.schY!==void 0)&&s){if(!this.schematic_component_id)return;let l=OA.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});e.schematic_manual_edit_conflict_warning.insert(l)}}_getSchematicSymbolDisplayValue(){}_getInternallyConnectedPins(){if(this.internallyConnectedPinNames.length===0)return[];let e=[];for(let a of this.internallyConnectedPinNames){let s=[];for(let l of a)s.push(this.portMap[l]);e.push(s)}return e}_doInitialSchematicComponentRenderWithSymbol(){if(this.root?.schematicDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,s=this._getSchematicSymbolNameOrThrow(),l=Ts[s],d=this._getGlobalSchematicPositionBeforeLayout();if(l){let x=e.schematic_component.insert({center:d,size:l.size,source_component_id:this.source_component_id,symbol_name:s,symbol_display_value:this._getSchematicSymbolDisplayValue()});this.schematic_component_id=x.schematic_component_id}}_doInitialSchematicComponentRenderWithSchematicBoxDimensions(){if(this.root?.schematicDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,s=this._getSchematicBoxDimensions(),l={};if(Array.isArray(a.pinLabels))a.pinLabels.forEach((w,B)=>{l[String(B+1)]=w});else for(let[w,B]of Object.entries(a.pinLabels??{}))l[w]=Array.isArray(B)?B[0]:B;let d=this._getGlobalSchematicPositionBeforeLayout(),x=this._getSchematicPortArrangement(),f=e.schematic_component.insert({center:d,rotation:a.schRotation??0,size:s.getSize(),port_arrangement:eGt(x),pin_spacing:a.schPinSpacing??.2,pin_styles:QVt(a.schPinStyle,a.pinLabels),port_labels:l,source_component_id:this.source_component_id}),m=x?.topSide!==void 0||x?.bottomSide!==void 0,y=s?.getSize().width,b=s?.getSize().height,E=e.schematic_text.insert({text:a.manufacturerPartNumber??"",schematic_component_id:f.schematic_component_id,anchor:"left",rotation:0,position:{x:m?d.x+(y??0)/2+.1:d.x-(y??0)/2,y:m?d.y+(b??0)/2+.35:d.y-(b??0)/2-.13},color:"#006464",font_size:.18}),A=e.schematic_text.insert({text:a.name??"",schematic_component_id:f.schematic_component_id,anchor:"left",rotation:0,position:{x:m?d.x+(y??0)/2+.1:d.x-(y??0)/2,y:m?d.y+(b??0)/2+.55:d.y+(b??0)/2+.13},color:"#006464",font_size:.18});this.schematic_component_id=f.schematic_component_id}doInitialPcbComponentRender(){if(this.root?.pcbDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,s=this.getSubcircuit(),l=e.pcb_component.insert({center:this._getGlobalPcbPositionBeforeLayout(),width:0,height:0,layer:a.layer??"top",rotation:a.pcbRotation??0,source_component_id:this.source_component_id,subcircuit_id:s.subcircuit_id??void 0});if(!(a.footprint??this._getImpliedFootprintString())&&!this.isGroup){let f=e.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=f.pcb_missing_footprint_error_id}this.pcb_component_id=l.pcb_component_id;let x=this.getSubcircuit()._getPcbManualPlacementForComponent(this);if((this.props.pcbX!==void 0||this.props.pcbY!==void 0)&&x){let f=$A.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:s.subcircuit_id??void 0});e.pcb_manual_edit_conflict_warning.insert(f)}}doInitialPcbComponentSizeCalculation(){if(this.root?.pcbDisabled||!this.pcb_component_id)return;let{db:e}=this.root,{_parsedProps:a}=this,s=GW(this.children);if(s.width===0||s.height===0)return;let l={x:(s.minX+s.maxX)/2,y:(s.minY+s.maxY)/2};e.pcb_component.update(this.pcb_component_id,{center:l,width:s.width,height:s.height})}_renderReactSubtree(e){return{element:e,component:bwe(e)}}doInitialInitializePortsFromChildren(){this.initPorts()}doInitialReactSubtreesRender(){}doInitialPcbFootprintStringRender(){let{footprint:e}=this.props;if(e??(e=this._getImpliedFootprintString?.()),!e)return;let{pcbRotation:a,pinLabels:s,pcbPinLabels:l}=this.props;if(typeof e=="string"&&this._isFootprintUrl(e)){if(this._hasStartedFootprintUrlLoad)return;this._hasStartedFootprintUrlLoad=!0;let d=e;this._queueAsyncEffect("load-footprint-url",async()=>{let f=await(await fetch(d)).json(),m=JSe({componentName:this.name,componentRotation:a,footprint:d,pinLabels:s,pcbPinLabels:l},f);this.addAll(m),this._markDirty("InitializePortsFromChildren")});return}if((0,w1.isValidElement)(e)){if(this.reactSubtrees.some(x=>x.element===e))return;let d=this._renderReactSubtree(e);this.reactSubtrees.push(d),this.add(d.component);return}!(0,w1.isValidElement)(e)&&e.componentName==="Footprint"&&this.add(e)}_hasExistingPortExactly(e){return this.children.filter(s=>s.componentName==="Port").some(s=>{let l=e.getNameAndAliases(),d=s.getNameAndAliases();return l.length===d.length&&l.every(x=>d.includes(x))})}add(e){let a;if((0,w1.isValidElement)(e)){let s=this._renderReactSubtree(e);this.reactSubtrees.push(s),a=s.component}else a=e;if(a.componentName==="Port"){if(this._hasExistingPortExactly(a))return;let l=this.children.filter(d=>d.componentName==="Port").find(d=>d.isMatchingAnyOf(a.getNameAndAliases()));l&&GGt(`Similar ports added. Port 1: ${l}, Port 2: ${a}`)}super.add(a)}getPortsFromFootprint(e){let{footprint:a}=this.props;if((!a||(0,w1.isValidElement)(a))&&(a=this.children.find(l=>l.componentName==="Footprint")),typeof a=="string"){if(this._isFootprintUrl(a))return[];let l=Bq.string(a).soup(),d=[];for(let x of l)if("port_hints"in x&&x.port_hints){let f=kF(x.port_hints,e);if(!f)continue;f.originDescription=`footprint:string:${a}:port_hints[0]:${x.port_hints[0]}`,d.push(f)}return d}if(!(0,w1.isValidElement)(a)&&a&&a.componentName==="Footprint"){let l=a,d=1,x=[];for(let f of l.children){if(!f.props.portHints)continue;let m=f.props.portHints;m.some(E=>E.startsWith("pin"))||(m=[...m,`pin${d}`]),d++;let b=kF(m);b&&(b.originDescription=`footprint:${a}`,x.push(b))}return x}let s=[];if(!a){for(let l of this.children)if(l.props.portHints&&l.isPcbPrimitive){let d=kF(l.props.portHints);d&&s.push(d)}}return s}getPortsFromSchematicSymbol(){if(this.root?.schematicDisabled)return[];let{config:e}=this;if(!e.schematicSymbolName)return[];let a=Ts[e.schematicSymbolName];if(!a)return[];let s=[];for(let l of a.ports){let d=kF(l.labels);d&&(d.schematicSymbolPortDef=l,s.push(d))}return s}doInitialCreateNetsFromProps(){this._createNetsFromProps(this._getNetsFromConnectionsProp())}_getNetsFromConnectionsProp(){let{_parsedProps:e}=this,a=[];if(e.connections)for(let[s,l]of Object.entries(e.connections)){let d=Array.isArray(l)?l:[l];for(let x of d)a.push(x)}return a}_createNetsFromProps(e){zW(this,e)}_getPcbCircuitJsonBounds(){let{db:e}=this.root;if(!this.pcb_component_id)return super._getPcbCircuitJsonBounds();let a=e.pcb_component.get(this.pcb_component_id);return{center:{x:a.center.x,y:a.center.y},bounds:{left:a.center.x-a.width/2,top:a.center.y-a.height/2,right:a.center.x+a.width/2,bottom:a.center.y+a.height/2},width:a.width,height:a.height}}_getPinCountFromSchematicPortArrangement(){let e=this._getSchematicPortArrangement();if(!e)return 0;if(!vwe(e))return(e.leftSize??e.leftPinCount??0)+(e.rightSize??e.rightPinCount??0)+(e.topSize??e.topPinCount??0)+(e.bottomSize??e.bottomPinCount??0);let{leftSide:s,rightSide:l,topSide:d,bottomSide:x}=e;return Math.max(...s?.pins??[],...l?.pins??[],...d?.pins??[],...x?.pins??[])}_getPinCount(){if(this._getSchematicPortArrangement())return this._getPinCountFromSchematicPortArrangement();let a=this.getPortsFromFootprint();if(a.length>0)return a.length;let{pinLabels:s}=this._parsedProps;if(s){if(Array.isArray(s))return s.length;let l=Object.keys(s).map(d=>d.startsWith("pin")?parseInt(d.slice(3)):parseInt(d)).filter(d=>!Number.isNaN(d));return l.length>0?Math.max(...l):Object.keys(s).length}return 0}_getSchematicPortArrangement(){return this._parsedProps.schPinArrangement??this._parsedProps.schPortArrangement}_getSchematicBoxDimensions(){if(this.getSchematicSymbol()||!this.config.shouldRenderAsSchematicBox)return null;let{_parsedProps:e}=this,a=this._getPinCount(),s=e.schPinSpacing??.2;return dGt({schWidth:e.schWidth,schHeight:e.schHeight,schPinSpacing:s,numericSchPinStyle:xGt(e.schPinStyle,e.pinLabels),pinCount:a,schPortArrangement:this._getSchematicPortArrangement(),pinLabels:e.pinLabels})}doInitialCadModelRender(){let{db:e}=this.root,{boardThickness:a=0}=this.root?._getBoard()??{},s=this._parsedProps.cadModel,l=this.props.footprint??this._getImpliedFootprintString();if(!this.pcb_component_id||!s&&!l||s===null)return;let d=this._getPcbCircuitJsonBounds(),x=e.pcb_component.get(this.pcb_component_id);if(typeof s=="string")throw new Error("String cadModel not yet implemented");let f=XGt.parse({x:0,y:0,z:typeof s?.rotationOffset=="number"?s.rotationOffset:0,...typeof s?.rotationOffset=="object"?s.rotationOffset??{}:{}}),m=Uf.parse({x:0,y:0,z:0,...typeof s?.positionOffset=="object"?s.positionOffset:{}}),y=this.props.layer==="bottom"?"bottom":"top",b=e.cad_component.insert({position:{x:d.center.x+m.x,y:d.center.y+m.y,z:(y==="bottom"?-a/2:a/2)+m.z},rotation:{x:f.x,y:(y==="top"?0:180)+f.y,z:y==="bottom"?-((x?.rotation??0)+f.z)+180:(x?.rotation??0)+f.z},pcb_component_id:this.pcb_component_id,source_component_id:this.source_component_id,model_stl_url:"stlUrl"in(s??{})?this._addCachebustToModelUrl(s.stlUrl):void 0,model_obj_url:"objUrl"in(s??{})?this._addCachebustToModelUrl(s.objUrl):void 0,model_jscad:"jscad"in(s??{})?s.jscad:void 0,footprinter_string:typeof l=="string"&&!s?l:void 0})}_addCachebustToModelUrl(e){if(!e||!e.includes("modelcdn.tscircuit.com"))return e;let a=this.root?.getClientOrigin()??"";return`${e}${e.includes("?")?"&":"?"}cachebust_origin=${encodeURIComponent(a)}`}_getPartsEngineCacheKey(e,a){return JSON.stringify({ftype:e.ftype,name:e.name,manufacturer_part_number:e.manufacturer_part_number,footprinterString:a})}async _getSupplierPartNumbers(e,a,s){if(this.props.doNotPlace)return{};let l=this.root?.platform?.localCacheEngine,d=this._getPartsEngineCacheKey(a,s);if(l){let m=await l.getItem(d);if(m)try{return JSON.parse(m)}catch{}}let x=await Promise.resolve(e.findPart({sourceComponent:a,footprinterString:s})),f=x==="Not found"?{}:x;if(l)try{await l.setItem(d,JSON.stringify(f))}catch{}return f}doInitialPartsEngineRender(){if(this.props.doNotPlace)return;let e=this.getInheritedProperty("partsEngine");if(!e)return;let{db:a}=this.root,s=a.source_component.get(this.source_component_id);if(!s||s.supplier_part_numbers)return;let l;this.props.footprint&&typeof this.props.footprint=="string"&&(l=this.props.footprint);let d=this._getSupplierPartNumbers(e,s,l);if(!(d instanceof Promise)){a.source_component.update(this.source_component_id,{supplier_part_numbers:d});return}this._queueAsyncEffect("get-supplier-part-numbers",async()=>{this._asyncSupplierPartNumbers=await d,this._markDirty("PartsEngineRender")})}updatePartsEngineRender(){if(this.props.doNotPlace)return;let{db:e}=this.root,a=e.source_component.get(this.source_component_id);if(a&&!a.supplier_part_numbers&&this._asyncSupplierPartNumbers){e.source_component.update(this.source_component_id,{supplier_part_numbers:this._asyncSupplierPartNumbers});return}}doInitialAssignFallbackProps(){let{_parsedProps:e}=this;e.connections&&!this.name&&(this.fallbackUnassignedName=this.getSubcircuit().getNextAvailableName(this))}doInitialCreateTracesFromProps(){this._createTracesFromConnectionsProp()}_createTracesFromConnectionsProp(){let{_parsedProps:e}=this;if(e.connections)for(let[a,s]of Object.entries(e.connections)){let l=Array.isArray(s)?s:[s];for(let d of l)this.add(new zc({from:`${this.getSubcircuitSelector()} > port.${a}`,to:d}))}}doInitialSourceDesignRuleChecks(){UGt(this)}_getMinimumFlexContainerSize(){return zGt(this)}_repositionOnPcb(e){return qGt(this,e)}},YGt=class{constructor(n,e={}){X(this,"input");X(this,"isRouting",!1);X(this,"solver");X(this,"eventHandlers",{complete:[],error:[],progress:[]});X(this,"cycleCount",0);X(this,"stepDelay");X(this,"timeoutId");this.input=n;let{capacityDepth:a,targetMinCapacity:s,stepDelay:l=0}=e;this.solver=new O4e(n,{capacityDepth:a,targetMinCapacity:s,cacheProvider:null}),this.stepDelay=l}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 MF(this.solver.error||"Routing failed")}):this.emitEvent({type:"complete",traces:this.solver.getOutputSimpleRouteJson().traces||[]}),this.isRouting=!1;return}let n=Date.now(),e=this.solver.iterations;for(;Date.now()-n<250&&!this.solver.failed&&!this.solver.solved;)this.solver.step();let a=(this.solver.iterations-e)/(Date.now()-n)*1e3;this.cycleCount++;let s=this.solver?.preview()||void 0,l=this.solver.progress;this.emitEvent({type:"progress",steps:this.cycleCount,iterationsPerSecond:a,progress:l,phase:this.solver.getCurrentPhase(),debugGraphics:s}),this.stepDelay>0?this.timeoutId=setTimeout(()=>this.runCycleAndQueueNextCycle(),this.stepDelay):this.timeoutId=setTimeout(()=>this.runCycleAndQueueNextCycle(),0)}catch(n){this.emitEvent({type:"error",error:n instanceof Error?new MF(n.message):new MF(String(n))}),this.isRouting=!1}}stop(){this.isRouting&&(this.isRouting=!1,this.timeoutId!==void 0&&(clearTimeout(this.timeoutId),this.timeoutId=void 0))}on(n,e){n==="complete"?this.eventHandlers.complete.push(e):n==="error"?this.eventHandlers.error.push(e):n==="progress"&&this.eventHandlers.progress.push(e)}emitEvent(n){if(n.type==="complete")for(let e of this.eventHandlers.complete)e(n);else if(n.type==="error")for(let e of this.eventHandlers.error)e(n);else if(n.type==="progress")for(let e of this.eventHandlers.progress)e(n)}solveSync(){if(this.solver.solve(),this.solver.failed)throw new MF(this.solver.error||"Routing failed");return this.solver.getOutputSimpleRouteJson().traces||[]}},YW=class extends ga{constructor(){super(...arguments);X(this,"matchedPort",null)}get config(){return{componentName:"TraceHint",zodProps:EAe}}doInitialPortMatching(){let{db:e}=this.root,{_parsedProps:a,parent:s}=this;if(!s)return;if(s.componentName==="Trace"){this.renderError(`Port inference inside trace is not yet supported (${this})`);return}if(!s)throw new Error("TraceHint has no parent");if(!a.for){this.renderError(`TraceHint has no for property (${this})`);return}let l=s.selectOne(a.for,{type:"port"});l||this.renderError(`${this} could not find port for selector "${a.for}"`),this.matchedPort=l,l.registerMatch(this)}getPcbRouteHints(){let{_parsedProps:e}=this,a=e.offset?[e.offset]:e.offsets;if(!a)return[];let s=this._computePcbGlobalTransformBeforeLayout();return a.map(l=>({...vs(s,l),via:l.via,to_layer:l.to_layer,trace_width:l.trace_width}))}doInitialPcbTraceHintRender(){if(this.root?.pcbDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this;e.pcb_trace_hint.insert({pcb_component_id:this.matchedPort?.pcb_component_id,pcb_port_id:this.matchedPort?.pcb_port_id,route:this.getPcbRouteHints()})}},Swe=({circuitJson:n,editEvents:e,manualEditsFile:a})=>{let s={...a,pcb_placements:[...a.pcb_placements??[]]};for(let l of e)if(l.edit_event_type==="edit_pcb_component_location"){let{pcb_component_id:d,new_center:x}=l,f=ua(n).pcb_component.get(d);if(!f)continue;let m=ua(n).source_component.get(f.source_component_id);if(!m)continue;let y=s.pcb_placements?.findIndex(E=>E.selector===m.name),b={selector:m.name,center:x,relative_to:"group_center"};y>=0?s.pcb_placements[y]=b:s.pcb_placements.push(b)}return s},wwe=({circuitJson:n,editEvents:e,manualEditsFile:a})=>{let s={...a,schematic_placements:[...a.schematic_placements??[]]};for(let l of e)if(l.edit_event_type==="edit_schematic_component_location"){let{schematic_component_id:d,new_center:x}=l,f=ua(n).schematic_component.get(d);if(!f)continue;let m=ua(n).source_component.get(f.source_component_id);if(!m)continue;let y=s.schematic_placements?.findIndex(E=>E.selector===m.name),b={selector:m.name,center:x,relative_to:"group_center"};y>=0?s.schematic_placements[y]=b:s.schematic_placements.push(b)}return s},HGt=({circuitJson:n,editEvents:e,manualEditsFile:a})=>{let s=e.filter(x=>x.edit_event_type==="edit_schematic_component_location"),l=e.filter(x=>x.edit_event_type==="edit_pcb_component_location"),d=a;return s.length>0&&(d=wwe({circuitJson:n,editEvents:s,manualEditsFile:d})),l.length>0&&(d=Swe({circuitJson:n,editEvents:l,manualEditsFile:d})),d},WGt=(n,e)=>{if(ua(n).pcb_trace_hint.get(e.pcb_trace_hint_id))n=n.map(s=>s.pcb_trace_hint_id===e.pcb_trace_hint_id?{...s,route:e.route}:s);else{let s=ua(n).pcb_port.get(e.pcb_port_id);n=n.filter(l=>!(l.type==="pcb_trace_hint"&&l.pcb_port_id===e.pcb_port_id)).concat([{type:"pcb_trace_hint",pcb_trace_hint_id:e.pcb_trace_hint_id,route:e.route,pcb_port_id:e.pcb_port_id,pcb_component_id:s?.pcb_component_id}])}return n},KGt=({circuitJson:n,editEvents:e})=>{n=JSON.parse(JSON.stringify(n));for(let a of e)if(a.edit_event_type==="edit_pcb_component_location"){let s=n.find(d=>d.type==="pcb_component"&&d.pcb_component_id===a.pcb_component_id);if((!s||s.center.x!==a.new_center.x||s.center.y!==a.new_center.y)&&a.original_center){let d=ja(a.new_center.x-a.original_center.x,a.new_center.y-a.original_center.y);n=n.map(x=>x.pcb_component_id!==a.pcb_component_id?x:bY(x,d))}}else a.edit_event_type==="edit_schematic_component_location"?n=n.map(s=>s.type==="schematic_component"&&s.schematic_component_id===a.schematic_component_id?{...s,center:a.new_center}:s):a.edit_event_type==="edit_pcb_trace_hint"&&(n=WGt(n,a));return n},Bwe=(n,e)=>{let a=n.source_group.list(),s=[],l=d=>{let x=a.filter(f=>f.parent_subcircuit_id===d);for(let f of x)f.subcircuit_id&&(s.push(f.subcircuit_id),l(f.subcircuit_id))};return l(e),s},MW=({db:n,circuitJson:e,subcircuit_id:a,minTraceWidth:s=.1})=>{if(!n&&e&&(n=ua(e)),!n)throw new Error("db or circuitJson is required");let l=n.pcb_trace_hint.list(),d=a?new Set([a]):null;if(a){let N=Bwe(n,a);for(let se of N)d.add(se)}let x=(e??n.toArray()).filter(N=>!a||"subcircuit_id"in N&&d.has(N.subcircuit_id)),f=n.pcb_board.list()[0];n=ua(x);let m=Ku(x),y=Awe([...n.pcb_component.list(),...n.pcb_smtpad.list(),...n.pcb_plated_hole.list(),...n.pcb_hole.list(),...n.pcb_via.list(),...n.pcb_cutout.list()].filter(N=>!a||d?.has(N.subcircuit_id)),m);for(let N of y){let se=N.connectedTo.flatMap($=>m.getIdsConnectedToNet($));N.connectedTo.push(...se)}let b=y.flatMap(N=>[{x:N.center.x-N.width/2,y:N.center.y-N.height/2},{x:N.center.x+N.width/2,y:N.center.y+N.height/2}]),E;if(f?E={minX:f.center.x-f.width/2,maxX:f.center.x+f.width/2,minY:f.center.y-f.height/2,maxY:f.center.y+f.height/2}:E={minX:Math.min(...b.map(N=>N.x))-1,maxX:Math.max(...b.map(N=>N.x))+1,minY:Math.min(...b.map(N=>N.y))-1,maxY:Math.max(...b.map(N=>N.y))+1},a){let N=n.pcb_group.getWhere({subcircuit_id:a});if(N){let se={minX:N.center.x-N.width/2,maxX:N.center.x+N.width/2,minY:N.center.y-N.height/2,maxY:N.center.y+N.height/2};E={minX:Math.min(E.minX,se.minX),maxX:Math.max(E.maxX,se.maxX),minY:Math.min(E.minY,se.minY),maxY:Math.max(E.maxY,se.maxY)}}}let A=n.source_trace.list().map(N=>{let se=N.connected_source_port_ids.map(xe=>{let Ae=n.source_port.get(xe),Ie=n.pcb_port.getWhere({source_port_id:xe});return{...Ae,...Ie}});if(se.length<2)return null;let[$,W]=se,Q=$.layers?.[0]??"top",le=W.layers?.[0]??"top",z=l.filter(xe=>xe.pcb_port_id===$.pcb_port_id||xe.pcb_port_id===W.pcb_port_id),pe=[];for(let xe of z){let Ie=n.pcb_port.get(xe.pcb_port_id)?.layers?.[0]??"top";for(let Le of xe.route)pe.push({x:Le.x,y:Le.y,layer:Ie})}return{name:N.source_trace_id??m.getNetConnectedToId(N.source_trace_id)??"",source_trace_id:N.source_trace_id,pointsToConnect:[{x:$.x,y:$.y,layer:Q,pointId:$.pcb_port_id,pcb_port_id:$.pcb_port_id},...pe,{x:W.x,y:W.y,layer:le,pointId:W.pcb_port_id,pcb_port_id:W.pcb_port_id}]}}).filter(N=>N!==null),w=new Map(A.map(N=>[N.source_trace_id,N])),B=n.source_net.list().filter(N=>!a||d?.has(N.subcircuit_id)),I=[];for(let N of B){let se=n.source_trace.list().filter($=>$.connected_source_net_ids?.includes(N.source_net_id));I.push({name:N.source_net_id??m.getNetConnectedToId(N.source_net_id),pointsToConnect:se.flatMap($=>n.pcb_port.list().filter(Q=>$.connected_source_port_ids.includes(Q.source_port_id)).map(Q=>({x:Q.x,y:Q.y,layer:Q.layers?.[0]??"top",pointId:Q.pcb_port_id,pcb_port_id:Q.pcb_port_id})))})}let q=n.pcb_breakout_point.list().filter(N=>!a||d?.has(N.subcircuit_id)),G=[],j=new Map;for(let N of q){let se={x:N.x,y:N.y,layer:"top"};if(N.source_trace_id){let $=w.get(N.source_trace_id)??j.get(N.source_trace_id);if($)$.pointsToConnect.push(se);else{let W={name:N.source_trace_id,source_trace_id:N.source_trace_id,pointsToConnect:[se]};G.push(W),j.set(N.source_trace_id,W)}}else if(N.source_net_id){let $=I.find(W=>W.name===N.source_net_id);$?$.pointsToConnect.push(se):G.push({name:N.source_net_id,pointsToConnect:[se]})}else if(N.source_port_id){let $=n.pcb_port.getWhere({source_port_id:N.source_port_id});$&&G.push({name:N.source_port_id,source_trace_id:void 0,pointsToConnect:[{x:$.x,y:$.y,layer:$.layers?.[0]??"top",pointId:$.pcb_port_id,pcb_port_id:$.pcb_port_id},se]})}}let O=[...A,...I,...G],V=new Map;for(let N of O)for(let se of N.pointsToConnect)se.pointId&&V.set(se.pointId,N);let te=n.pcb_trace.list().filter(N=>!a||d?.has(N.subcircuit_id));for(let N of te){let se=new Set;for(let Q of N.route)Q.start_pcb_port_id&&se.add(Q.start_pcb_port_id),Q.end_pcb_port_id&&se.add(Q.end_pcb_port_id);if(se.size<2)continue;let $=se.values().next().value;if(!$)continue;let W=V.get($);W&&[...se].every(Q=>V.get(Q)===W)&&(W.externallyConnectedPointIds??(W.externallyConnectedPointIds=[]),W.externallyConnectedPointIds.push([...se]))}return{simpleRouteJson:{bounds:E,obstacles:y,connections:O,layerCount:f?.num_layers??2,minTraceWidth:s},connMap:m}},JGt=n=>{let e={};if(!n)return e;for(let s of ud)e[s]=0;let a=new Map;for(let s of n){let[,,l,d]=s.type.split(":");if(d==="start"){a.set(`${l}:${s.renderId}`,s);continue}if(d==="end"){let x=a.get(`${l}:${s.renderId}`);if(x){let f=s.createdAt-x.createdAt;e[l]=(e[l]||0)+f}}}return e},ZGt=n=>{let e=n.map(m=>[...new Set(m)]),a=e.map(()=>[]),s=e.map(()=>null);for(let m=0;m<e.length;m++)for(let y of e[m])if(/^\d+$/.test(y)){s[m]=Number.parseInt(y);break}let l=0,d=new Set;for(let m=0;m<s.length;m++){let y=s[m];if(y===null||y<1)continue;if(!d.has(y)){d.add(y),a[m].push(`pin${y}`),l=Math.max(l,y);continue}let b=0;for(let E of a[m])E.startsWith(`pin${y}_alt`)&&b++;a[m].push(`pin${y}_alt${b+1}`)}for(let m=0;m<a.length;m++)a[m][0]?.includes("_alt")&&(l++,a[m].unshift(`pin${l}`));for(let m=0;m<a.length;m++)a[m].length===0&&(l++,a[m].push(`pin${l}`));let x={};for(let m of e)for(let y of m)/^\d+$/.test(y)||(x[y]=(x[y]??0)+1);let f={};for(let m=0;m<e.length;m++){let y=e[m];for(let b of y)/^\d+$/.test(b)||(x[b]===1?a[m].push(b):(f[b]=(f[b]??0)+1,a[m].push(`${b}${f[b]}`)))}return a},nwe=(0,Twe.default)("Group_doInitialSchematicLayoutMatchAdapt");function QGt(n){let{db:e}=n.root,a=qb(e.toArray(),{source_group_id:n.source_group_id}),s=JY(a);nwe.enabled&&global.debugGraphics?.push(Hp(s,{title:`floatingBpcGraph-${n.name}`}));let l=JY(a),d={boxes:l.boxes,pins:l.pins.map(m=>({...m,color:m.color.replace("not_connected","normal")}))},{result:x}=xRe([{variantName:"default",floatingGraph:l},{variantName:"noNotConnected",floatingGraph:d}],{singletonKeys:["vcc/2","gnd/2"],centerPinColors:["netlabel_center","component_center"],floatingBoxIdsWithMutablePinOffsets:new Set(l.boxes.filter(m=>l.pins.filter(E=>E.boxId===m.boxId).filter(E=>!E.color.includes("center")).length<=2).map(m=>m.boxId)),corpus:{}});nwe.enabled&&global.debugGraphics?.push(Hp(x,{title:`laidOutBpcGraph-${n.name}`}));let f=n._getGlobalSchematicPositionBeforeLayout();for(let m of x.boxes){if(!m.center)continue;let y=e.schematic_component.get(m.boxId);if(y){let E={x:m.center.x+f.x,y:m.center.y+f.y},A=e.schematic_port.list({schematic_component_id:y.schematic_component_id}),w=e.schematic_text.list({schematic_component_id:y.schematic_component_id}),B={x:E.x-y.center.x,y:E.y-y.center.y};for(let I of A)I.center.x+=B.x,I.center.y+=B.y;for(let I of w)I.position.x+=B.x,I.position.y+=B.y;y.center=E;continue}let b=e.schematic_net_label.get(m.boxId);if(b){let E=x.pins.find(w=>w.boxId===m.boxId&&w.color==="netlabel_center");if(!E)throw new Error(`No pin found for net label: ${m.boxId}`);let A={x:m.center.x+f.x,y:m.center.y+f.y};b.center=A,b.anchor_position={x:A.x+E.offset.x,y:A.y+E.offset.y};continue}console.error(`No schematic element found for box: ${m.boxId}. This is a bug in the matchAdapt binding with @tscircuit/core`)}}var an=(0,Pwe.default)("Group_doInitialSchematicLayoutMatchpack");function awe(n){switch(n){case"up":return"y+";case"down":return"y-";case"left":return"x-";case"right":return"x+";default:return"y+"}}function swe(n,e){let a=["up","right","down","left"],s=a.indexOf(n);if(s===-1)return n;let l=Math.round(e/90),d=(s+l)%4;return a[d<0?d+4:d]}function eXt(n,e,a){let s={chipMap:{},chipPinMap:{},netMap:{},pinStrongConnMap:{},netConnMap:{},chipGap:.6,partitionGap:1.2};an(`[${a.name}] Processing ${n.childNodes.length} child nodes for input problem`),n.childNodes.forEach((d,x)=>{if(an(`[${a.name}] Processing child ${x}: nodeType=${d.nodeType}`),d.nodeType==="component"?an(`[${a.name}] - Component: ${d.sourceComponent?.name}`):d.nodeType==="group"&&an(`[${a.name}] - Group: ${d.sourceGroup?.name}`),d.nodeType==="component"&&d.sourceComponent){let f=d.sourceComponent.name||`chip_${x}`,m=e.schematic_component.getWhere({source_component_id:d.sourceComponent.source_component_id});if(!m)return;let y=a.children.find(A=>A.source_component_id===d.sourceComponent?.source_component_id),b=[0,90,180,270];y?._parsedProps?.schOrientation&&(b=[0]),y?._parsedProps?.schRotation!==void 0&&(b=[0]),s.chipMap[f]={chipId:f,pins:[],size:{x:m.size?.width||1,y:m.size?.height||1},availableRotations:b};let E=e.schematic_port.list({schematic_component_id:m.schematic_component_id});for(let A of E){let w=e.source_port.get(A.source_port_id);if(!w)continue;let B=`${f}.${w.pin_number||w.name||A.schematic_port_id}`;s.chipMap[f].pins.push(B);let I=awe(A.facing_direction);s.chipPinMap[B]={pinId:B,offset:{x:(A.center?.x||0)-(m.center.x||0),y:(A.center?.y||0)-(m.center.y||0)},side:I}}}else if(d.nodeType==="group"&&d.sourceGroup){let f=d.sourceGroup.name||`group_${x}`;an(`[${a.name}] Processing nested group: ${f}`);let m=e.schematic_group?.getWhere?.({source_group_id:d.sourceGroup.source_group_id});if(an(`[${a.name}] Found schematic_group for ${f}:`,m),m){an(`[${a.name}] Treating group ${f} as composite chip`);let y=e.schematic_component.list({schematic_group_id:m.schematic_group_id});an(`[${a.name}] Group ${f} has ${y.length} components:`,y.map(j=>j.source_component_id));let b=1/0,E=-1/0,A=1/0,w=-1/0,B=!1;for(let j of y)if(j.center&&j.size){B=!0;let O=j.size.width/2,V=j.size.height/2;b=Math.min(b,j.center.x-O),E=Math.max(E,j.center.x+O),A=Math.min(A,j.center.y-V),w=Math.max(w,j.center.y+V)}let I=B?E-b:2,q=B?w-A:2;an(`[${a.name}] Group ${f} computed size: ${I} x ${q}`);let G=[];for(let j of y){let O=e.schematic_port.list({schematic_component_id:j.schematic_component_id});for(let V of O){let te=e.source_port.get(V.source_port_id);if(!te)continue;let N=`${f}.${te.pin_number||te.name||V.schematic_port_id}`;G.push(N);let se=m.center||{x:0,y:0},$=awe(V.facing_direction);s.chipPinMap[N]={pinId:N,offset:{x:(V.center?.x||0)-se.x,y:(V.center?.y||0)-se.y},side:$}}}an(`[${a.name}] Group ${f} has ${G.length} pins:`,G),s.chipMap[f]={chipId:f,pins:G,size:{x:I,y:q}},an(`[${a.name}] Added group ${f} to chipMap`)}else an(`[${a.name}] Warning: No schematic_group found for group ${f}`)}}),an(`[${a.name}] Creating connections using connectivity keys`);let l=new Map;for(let[d,x]of Object.entries(s.chipMap))for(let f of x.pins){let m=f.split(".").pop(),y=n.childNodes.find(b=>b.nodeType==="component"&&b.sourceComponent?b.sourceComponent.name===d:b.nodeType==="group"&&b.sourceGroup?`group_${n.childNodes.indexOf(b)}`===d:!1);if(y?.nodeType==="group"&&y.sourceGroup){let b=e.schematic_group?.getWhere?.({source_group_id:y.sourceGroup.source_group_id});if(b){let E=e.schematic_component.list({schematic_group_id:b.schematic_group_id});for(let A of E){let w=e.source_port.list({source_component_id:A.source_component_id});for(let B of w){let I=B.pin_number||B.name;if(String(I)===String(m))if(B.subcircuit_connectivity_map_key){let q=B.subcircuit_connectivity_map_key;l.has(q)||l.set(q,[]),l.get(q).push(f),an(`[${a.name}] \u2713 Pin ${f} has connectivity key: ${q}`)}else an(`[${a.name}] Pin ${f} has no connectivity key`)}}}}else if(y?.nodeType==="component"&&y.sourceComponent){let b=e.source_port.list({source_component_id:y.sourceComponent.source_component_id});for(let E of b){let A=E.pin_number||E.name;if(String(A)===String(m)&&E.subcircuit_connectivity_map_key){let w=E.subcircuit_connectivity_map_key;l.has(w)||l.set(w,[]),l.get(w).push(f),an(`[${a.name}] Pin ${f} has connectivity key: ${w}`)}}}}an(`[${a.name}] Found ${l.size} connectivity groups:`,Array.from(l.entries()).map(([d,x])=>({key:d,pins:x})));for(let[d,x]of l)if(x.length>=2){let f=e.source_trace.list().filter(b=>b.subcircuit_connectivity_map_key===d),m=f.some(b=>b.connected_source_net_ids&&b.connected_source_net_ids.length>0),y=f.some(b=>b.connected_source_port_ids&&b.connected_source_port_ids.length>=2);if(an(`[${a.name}] Connectivity ${d}: hasNetConnections=${m}, hasDirectConnections=${y}`),y){for(let b of f)if(b.connected_source_port_ids&&b.connected_source_port_ids.length>=2){let E=[];for(let A of b.connected_source_port_ids)for(let w of x){let B=w.split(".").pop(),I=e.source_port.get(A);if(I&&String(I.pin_number||I.name)===String(B)){let q=w.split(".")[0],G=n.childNodes.find(j=>j.nodeType==="component"&&j.sourceComponent?j.sourceComponent.name===q:j.nodeType==="group"&&j.sourceGroup?`group_${n.childNodes.indexOf(j)}`===q:!1);G?.nodeType==="component"&&G.sourceComponent&&e.source_port.list({source_component_id:G.sourceComponent.source_component_id}).some(O=>O.source_port_id===A)&&E.push(w)}}for(let A=0;A<E.length;A++)for(let w=A+1;w<E.length;w++){let B=E[A],I=E[w];s.pinStrongConnMap[`${B}-${I}`]=!0,s.pinStrongConnMap[`${I}-${B}`]=!0,an(`[${a.name}] Created strong connection: ${B} <-> ${I}`)}}}if(m){s.netMap[d]={netId:d};for(let b of x)s.netConnMap[`${b}-${d}`]=!0;an(`[${a.name}] Created net ${d} with ${x.length} pins:`,x)}}return s}function tXt(n){let{db:e}=n.root,a=og(e.toArray(),{source_group_id:n.source_group_id});if(an(`[${n.name}] Starting matchpack layout with ${a.childNodes.length} children`),an(`[${n.name}] Tree structure:`,JSON.stringify(a,null,2)),a.childNodes.length<=1){an(`[${n.name}] Only ${a.childNodes.length} children, skipping layout`);return}an("Converting circuit tree to InputProblem...");let s=eXt(a,e,n);an("InputProblem:",JSON.stringify(s,null,2));let l=new F5e(s);if(an("Starting LayoutPipelineSolver..."),an.enabled&&global.debugGraphics){let m=l.visualize();global.debugGraphics.push({...m,title:`matchpack-initial-${n.name}`})}if(l.solve(),an(`Solver completed in ${l.iterations} iterations`),an(`Solved: ${l.solved}, Failed: ${l.failed}`),l.failed)throw an(`Solver failed with error: ${l.error}`),new Error(`Matchpack layout solver failed: ${l.error}`);let d=l.getOutputLayout();if(an("OutputLayout:",JSON.stringify(d,null,2)),an("Solver completed successfully:",!l.failed),an.enabled&&global.debugGraphics){let m=l.visualize();global.debugGraphics.push({...m,title:`matchpack-final-${n.name}`})}let x=l.checkForOverlaps(d);if(x.length>0){an(`Warning: Found ${x.length} overlapping components:`);for(let m of x)an(` ${m.chip1} overlaps ${m.chip2} (area: ${m.overlapArea})`)}let f=n._getGlobalSchematicPositionBeforeLayout();an(`Group offset: x=${f.x}, y=${f.y}`),an(`Applying layout results for ${Object.keys(d.chipPlacements).length} chip placements`);for(let[m,y]of Object.entries(d.chipPlacements)){an(`Processing placement for chip: ${m} at (${y.x}, ${y.y})`);let b=a.childNodes.find(A=>{if(A.nodeType==="component"&&A.sourceComponent){let w=A.sourceComponent.name===m;return an(` Checking component ${A.sourceComponent.name}: matches=${w}`),w}if(A.nodeType==="group"&&A.sourceGroup){let w=A.sourceGroup.name,B=`group_${a.childNodes.indexOf(A)}`,I=B===m;return an(` Checking group ${w} (expected chipId: ${B}): matches=${I}`),I}return!1});if(!b){an(`Warning: No tree node found for chip: ${m}`),an("Available tree nodes:",a.childNodes.map((A,w)=>({type:A.nodeType,name:A.nodeType==="component"?A.sourceComponent?.name:A.sourceGroup?.name,expectedChipId:A.nodeType==="group"?`group_${w}`:A.sourceComponent?.name})));continue}let E={x:y.x+f.x,y:y.y+f.y};if(b.nodeType==="component"&&b.sourceComponent){let A=e.schematic_component.getWhere({source_component_id:b.sourceComponent.source_component_id});if(A){an(`Moving component ${m} to (${E.x}, ${E.y})`);let w=e.schematic_port.list({schematic_component_id:A.schematic_component_id}),B=e.schematic_text.list({schematic_component_id:A.schematic_component_id}),I={x:E.x-A.center.x,y:E.y-A.center.y};for(let q of w)q.center.x+=I.x,q.center.y+=I.y;for(let q of B)q.position.x+=I.x,q.position.y+=I.y;if(A.center=E,y.ccwRotationDegrees!==0){an(`Component ${m} has rotation: ${y.ccwRotationDegrees}\xB0`);let q=y.ccwRotationDegrees*Math.PI/180,G=Math.cos(q),j=Math.sin(q);for(let O of w){let V=O.center.x-E.x,te=O.center.y-E.y,N=V*G-te*j,se=V*j+te*G;O.center.x=E.x+N,O.center.y=E.y+se;let $=O.facing_direction||"right";O.facing_direction=swe($,y.ccwRotationDegrees)}for(let O of B){let V=O.position.x-E.x,te=O.position.y-E.y,N=V*G-te*j,se=V*j+te*G;O.position.x=E.x+N,O.position.y=E.y+se}if(A.symbol_name){let O=A.symbol_name.match(/_(right|left|up|down)$/);O&&(A.symbol_name=A.symbol_name.replace(O[0],`_${swe(O[1],y.ccwRotationDegrees)}`))}}}}else if(b.nodeType==="group"&&b.sourceGroup){let A=e.schematic_group?.getWhere?.({source_group_id:b.sourceGroup.source_group_id});if(A){an(`Moving group ${m} to (${E.x}, ${E.y}) from (${A.center?.x}, ${A.center?.y})`);let w=e.schematic_component.list({schematic_group_id:A.schematic_group_id});an(`Group ${m} has ${w.length} components to move`);let B=A.center||{x:0,y:0},I={x:E.x-B.x,y:E.y-B.y};an(`Position delta for group ${m}: (${I.x}, ${I.y})`);for(let q of w)if(q.center){let G={...q.center};q.center.x+=I.x,q.center.y+=I.y,an(`Moved component ${q.source_component_id} from (${G.x}, ${G.y}) to (${q.center.x}, ${q.center.y})`);let j=e.schematic_port.list({schematic_component_id:q.schematic_component_id}),O=e.schematic_text.list({schematic_component_id:q.schematic_component_id});for(let V of j)V.center&&(V.center.x+=I.x,V.center.y+=I.y);for(let V of O)V.position&&(V.position.x+=I.x,V.position.y+=I.y)}A.center=E,an(`Updated group ${m} center to (${E.x}, ${E.y})`)}}}an("Matchpack layout completed successfully")}function rXt(n){if(!n.isSubcircuit)return;let{db:e}=n.root,a=n.selectAll("trace"),s=new Pb({});s.addConnections(a.map(f=>{let m=e.source_trace.get(f.source_trace_id);return m?[m.source_trace_id,...m.connected_source_port_ids,...m.connected_source_net_ids]:null}).filter(f=>f!==null));let{name:l}=n._parsedProps;for(let f of a){if(!f.source_trace_id)continue;let m=s.getNetConnectedToId(f.source_trace_id);m&&(f.subcircuit_connectivity_map_key=`${l??`unnamedsubcircuit${n._renderId}`}_${m}`,e.source_trace.update(f.source_trace_id,{subcircuit_connectivity_map_key:f.subcircuit_connectivity_map_key}))}let d=new Set;for(let f of a){if(!f.source_trace_id)continue;let m=e.source_trace.get(f.source_trace_id);if(m)for(let y of m.connected_source_port_ids)d.add(y)}for(let f of d){let m=s.getNetConnectedToId(f);if(!m)continue;let y=`${l??`unnamedsubcircuit${n._renderId}`}_${m}`;e.source_port.update(f,{subcircuit_connectivity_map_key:y})}let x=new Set;for(let f of a){if(!f.source_trace_id)continue;let m=e.source_trace.get(f.source_trace_id);if(m)for(let y of m.connected_source_net_ids)x.add(y)}for(let f of x){let m=s.getNetConnectedToId(f);if(!m)continue;let y=`${l??`unnamedsubcircuit${n._renderId}`}_${m}`;e.source_net.update(f,{subcircuit_connectivity_map_key:y})}}function nXt(n){let{db:e}=n.root,a=n._parsedProps,s=n.children.filter(te=>te.schematic_component_id);if(s.length===0)return;let l=0,d=0;for(let te of s){let N=e.schematic_component.get(te.schematic_component_id);N?.size&&(l=Math.max(l,N.size.width),d=Math.max(d,N.size.height))}l===0&&s.length>0&&(l=1),d===0&&s.length>0&&(d=1);let x=a.gridCols,f,m=a.gridGap,y=a.gridRowGap,b=a.gridColumnGap;a.schLayout?.grid&&(x=a.schLayout.grid.cols??x,f=a.schLayout.grid.rows,m=a.schLayout.gridGap??m,y=a.schLayout.gridRowGap??y,b=a.schLayout.gridColumnGap??b);let E,A;x!==void 0&&f!==void 0?(E=x,A=f):x!==void 0?(E=x,A=Math.ceil(s.length/E)):f!==void 0?(A=f,E=Math.ceil(s.length/A)):(E=Math.ceil(Math.sqrt(s.length)),A=Math.ceil(s.length/E)),E===0&&s.length>0&&(E=1),A===0&&s.length>0&&(A=s.length);let w,B,I=te=>{if(te!==void 0)return typeof te=="number"?te:me.parse(te)};if(y!==void 0||b!==void 0){let te=typeof m=="object"&&m!==null?m.x:m,N=typeof m=="object"&&m!==null?m.y:m;w=I(b??te)??1,B=I(y??N)??1}else if(typeof m=="number")w=m,B=m;else if(typeof m=="string"){let te=me.parse(m);w=te,B=te}else if(typeof m=="object"&&m!==null){let te=m.x,N=m.y;w=typeof te=="number"?te:me.parse(te??"0mm"),B=typeof N=="number"?N:me.parse(N??"0mm")}else w=1,B=1;let q=E*l+Math.max(0,E-1)*w,G=A*d+Math.max(0,A-1)*B,j=n._getGlobalSchematicPositionBeforeLayout(),O=j.x-q/2+l/2,V=j.y+G/2-d/2;for(let te=0;te<s.length;te++){let N=s[te];if(!N.schematic_component_id)continue;let se=Math.floor(te/E),$=te%E;if(se>=A||$>=E){console.warn(`Schematic grid layout: Child ${N.getString()} at index ${te} (row ${se}, col ${$}) exceeds specified grid dimensions (${A}x${E}). Skipping placement.`);continue}let W=O+$*(l+w),Q=V-se*(d+B),le=e.schematic_component.get(N.schematic_component_id);if(le){let z=le.center,pe={x:W,y:Q};e.schematic_component.update(N.schematic_component_id,{center:pe});let xe=pe.x-z.x,Ae=pe.y-z.y,Ie=e.schematic_port.list({schematic_component_id:N.schematic_component_id});for(let dt of Ie)e.schematic_port.update(dt.schematic_port_id,{center:{x:dt.center.x+xe,y:dt.center.y+Ae}});let Le=e.schematic_text.list({schematic_component_id:N.schematic_component_id});for(let dt of Le)e.schematic_text.update(dt.schematic_text_id,{position:{x:dt.position.x+xe,y:dt.position.y+Ae}})}}n.schematic_group_id&&e.schematic_group.update(n.schematic_group_id,{width:q,height:G,center:j})}var iwe=(n,e)=>{let{sourceComponent:a,sourceGroup:s}=e;if(e.nodeType==="component"){let l=n.schematic_component.getWhere({source_component_id:a?.source_component_id});return l?.size?{width:l.size.width,height:l.size.height}:null}if(e.nodeType==="group"){let l=n.schematic_group.getWhere({source_group_id:s?.source_group_id});if(l?.width&&l?.height)return{width:l.width,height:l.height};let d=n.schematic_component.list({schematic_group_id:l?.schematic_group_id}),x=1/0,f=-1/0,m=1/0,y=-1/0;for(let A of d)if(A.center&&A.size){let w=A.size.width/2,B=A.size.height/2;x=Math.min(x,A.center.x-w),f=Math.max(f,A.center.x+w),m=Math.min(m,A.center.y-B),y=Math.max(y,A.center.y+B)}let b=f-x,E=y-m;return{width:b,height:E}}return null},aXt=n=>{let{db:e}=n.root,a=n._parsedProps,s=og(e.toArray(),{source_group_id:n.source_group_id}),l=a.schJustifyContent??a.justifyContent,d=a.schAlignItems??a.alignItems,x=a.schFlexGap??a.schGap??a.gap,f=a.schFlexDirection??"row",m={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"}[l??"space-between"],y={start:"flex-start",end:"flex-end","flex-start":"flex-start","flex-end":"flex-end",stretch:"stretch",center:"center"}[d??"center"];if(!m)throw new Error(`Invalid justifyContent value: "${l}"`);if(!y)throw new Error(`Invalid alignItems value: "${d}"`);let b=0,E=0;typeof x=="object"?(b=x.y??0,E=x.x??0):typeof x=="number"?(b=x,E=x):typeof x=="string"&&(b=me.parse(x),E=me.parse(x));let A,w=a.width??a.schWidth??void 0,B=a.height??a.schHeight??void 0;(w===void 0||B===void 0)&&(A=y5(s.childNodes.map(V=>iwe(e,V)).filter(V=>V!==null),{alignItems:y,justifyContent:m,direction:f,rowGap:b,columnGap:E}),w=A.width,B=A.height);let q=new bS(w,B,{alignItems:y,justifyContent:m,direction:f,rowGap:b,columnGap:E});for(let V of s.childNodes){let te=iwe(e,V);q.addChild({metadata:V,width:te?.width??0,height:te?.height??0,flexBasis:te?f==="row"?te.width:te.height:void 0})}q.build();let G={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,width:0,height:0};for(let V of q.children)G.minX=Math.min(G.minX,V.position.x),G.minY=Math.min(G.minY,V.position.y),G.maxX=Math.max(G.maxX,V.position.x+V.size.width),G.maxY=Math.max(G.maxY,V.position.y+V.size.height);G.width=G.maxX-G.minX,G.height=G.maxY-G.minY;let j={x:-(G.maxX+G.minX)/2,y:-(G.maxY+G.minY)/2},O=e.toArray();for(let V of q.children){let{sourceComponent:te,sourceGroup:N}=V.metadata;if(te){let se=e.schematic_component.getWhere({source_component_id:te.source_component_id});if(!se)continue;zAe(O,se.schematic_component_id,{x:V.position.x+V.size.width/2+j.x,y:V.position.y+V.size.height/2+j.y})}if(N){if(!e.schematic_group.getWhere({source_group_id:N.source_group_id}))continue;UAe(O,N.source_group_id,{x:V.position.x+V.size.width/2+j.x,y:V.position.y+V.size.height/2+j.y})}}n.schematic_group_id&&e.schematic_group.update(n.schematic_group_id,{width:G.width,height:G.height})},BW=1;function sXt(n){let{db:e}=n.root,a=n._parsedProps,s=iXt(n);if(s.length===0)return;let l=oXt({db:e,pcbChildren:s}),d=uXt(a),x=cXt({props:a,pcbChildren:s,childDimensions:l,gridConfig:d}),f=pXt({pcbChildren:s,childDimensions:l,gridLayout:x,gridConfig:d}),{itemCoordinates:m}=f.layout();xXt({db:e,group:n,pcbChildren:s,itemCoordinates:m,gridLayout:x}),fXt({db:e,group:n,props:a,gridLayout:x})}function iXt(n){return n.children.filter(e=>e.pcb_component_id||e.pcb_group_id)}function oXt(n){let{db:e,pcbChildren:a}=n,s=0,l=0;for(let d of a){let x=0,f=0;if(d.pcb_group_id){let m=e.pcb_group.get(d.pcb_group_id);x=m?.width??0,f=m?.height??0}else if(d.pcb_component_id){let m=e.pcb_component.get(d.pcb_component_id);x=m?.width??0,f=m?.height??0}s=Math.max(s,x),l=Math.max(l,f)}return{width:s,height:l}}function uXt(n){let e=n.pcbGridCols??n.gridCols??n.pcbLayout?.grid?.cols,a=n.pcbGridRows??n.pcbLayout?.grid?.rows,s=n.pcbGridTemplateColumns,l=n.pcbGridTemplateRows,d=E=>E===void 0?BW:typeof E=="number"?E:me.parse(E),x=n.pcbGridGap??n.gridGap??n.pcbLayout?.gridGap,f=n.pcbGridRowGap??n.gridRowGap??n.pcbLayout?.gridRowGap,m=n.pcbGridColumnGap??n.gridColumnGap??n.pcbLayout?.gridColumnGap,y=BW,b=BW;if(f!==void 0||m!==void 0){let E=typeof x=="object"?x?.x:x,A=typeof x=="object"?x?.y:x;y=d(m??E),b=d(f??A)}else if(typeof x=="object"&&x!==null)y=d(x.x),b=d(x.y);else{let E=d(x);y=E,b=E}return{cols:e,rows:a,gapX:y,gapY:b,templateColumns:s,templateRows:l}}function cXt(n){let{props:e,pcbChildren:a,childDimensions:s,gridConfig:l}=n;return e.pcbGridTemplateColumns||e.pcbGridTemplateRows?lXt({props:e,gridConfig:l,pcbChildren:a,childDimensions:s}):dXt({gridConfig:l,pcbChildren:a,childDimensions:s})}function lXt(n){let{props:e,gridConfig:a,pcbChildren:s,childDimensions:l}=n,d=e.pcbGridTemplateColumns??"",x=e.pcbGridTemplateRows??"",f=A=>{let w=A.match(/repeat\((\d+),/);return w?parseInt(w[1]):Math.ceil(Math.sqrt(s.length))},m=e.pcbGridTemplateColumns?f(d):Math.ceil(Math.sqrt(s.length)),y=e.pcbGridTemplateRows?f(x):Math.ceil(s.length/m),b=m*l.width+Math.max(0,m-1)*a.gapX,E=y*l.height+Math.max(0,y-1)*a.gapY;return{gridTemplateColumns:d,gridTemplateRows:x,containerWidth:b,containerHeight:E}}function dXt(n){let{gridConfig:e,pcbChildren:a,childDimensions:s}=n,l,d;e.cols!==void 0&&e.rows!==void 0?(l=e.cols,d=e.rows):e.cols!==void 0?(l=e.cols,d=Math.ceil(a.length/l)):e.rows!==void 0?(d=e.rows,l=Math.ceil(a.length/d)):(l=Math.ceil(Math.sqrt(a.length)),d=Math.ceil(a.length/l)),l=Math.max(1,l),d=Math.max(1,d);let x=l*s.width+Math.max(0,l-1)*e.gapX,f=d*s.height+Math.max(0,d-1)*e.gapY,m=`repeat(${l}, ${s.width}px)`,y=`repeat(${d}, ${s.height}px)`;return{gridTemplateColumns:m,gridTemplateRows:y,containerWidth:x,containerHeight:f}}function pXt(n){let{pcbChildren:e,childDimensions:a,gridLayout:s,gridConfig:l}=n,d=e.map((x,f)=>({key:x.getString()||`child-${f}`,contentWidth:a.width,contentHeight:a.height}));return new B5e({containerWidth:s.containerWidth,containerHeight:s.containerHeight,gridTemplateColumns:s.gridTemplateColumns,gridTemplateRows:s.gridTemplateRows,gap:[l.gapY,l.gapX],children:d})}function xXt(n){let{db:e,group:a,pcbChildren:s,itemCoordinates:l,gridLayout:d}=n,x=a._getGlobalPcbPositionBeforeLayout(),f=e.toArray();for(let m=0;m<s.length;m++){let y=s[m],b=y.getString()||`child-${m}`,E=l[b];if(!E){console.warn(`PCB grid layout: No coordinates found for child ${b}`);continue}let A=x.x-d.containerWidth/2+E.x+E.width/2,w=x.y+d.containerHeight/2-E.y-E.height/2;if(y.pcb_component_id)m5(f,y.pcb_component_id,{x:A,y:w});else{let B=y;B.pcb_group_id&&B.source_group_id&&g5(f,B.source_group_id,{x:A,y:w})}}}function fXt(n){let{db:e,group:a,props:s,gridLayout:l}=n;if(a.pcb_group_id){let d=a._getGlobalPcbPositionBeforeLayout();e.pcb_group.update(a.pcb_group_id,{width:s.width??l.containerWidth,height:s.height??l.containerHeight,center:d})}}function hXt(n){let e={serverUrl:"https://registry-api.tscircuit.com",serverMode:"job",serverCacheEnabled:!0};if(typeof n=="object"&&!n.preset)return{local:!(n.serverUrl||n.serverMode||n.serverCacheEnabled),...e,...n};let a=typeof n=="object"?n.preset:n,s=typeof n=="object"?n:{};switch(a){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:l,local:d,groupMode:x,...f}=s;return{local:!1,groupMode:"subcircuit",...e,...f}}default:return{local:!0,groupMode:"subcircuit"}}}var mXt="1mm",owe=(0,Iwe.default)("Group_doInitialPcbLayoutPack"),OF=(n,e,a)=>{if(e===a)return!0;let s=n.source_group.get(e);return!s||!s.parent_source_group_id?!1:OF(n,s.parent_source_group_id,a)},gXt=n=>{let{db:e}=n.root,{_parsedProps:a}=n,{packOrderStrategy:s,packPlacementStrategy:l,gap:d,pcbGap:x,pcbPackGap:f}=a,m=f??x??d,y=me.parse(m??mXt),b={...D5e(y5e(e.toArray(),{source_group_id:n.source_group_id,shouldAddInnerObstacles:!0})),orderStrategy:s??"largest_to_smallest",placementStrategy:l??"minimum_sum_squared_distance_to_network",minGap:y};owe.enabled&&(global.debugOutputs?.add(`packInput-circuitjson-${n.name}`,JSON.stringify(e.toArray())),global.debugOutputs?.add(`packInput-${n.name}`,b));let E=gS(b);if(owe.enabled){let A=mS(E);A.title=`packOutput-${n.name}`,global.debugGraphics?.push(A)}for(let A of E.components){let{center:w,componentId:B,ccwRotationOffset:I,ccwRotationDegrees:q}=A,G=e.pcb_component.get(B);if(G){let se=n.source_group_id,W=e.source_component.get(G.source_component_id)?.source_group_id;if(W!==void 0&&!OF(e,W,se))continue;let Q=G.center,le=q??I??0,z=Bs(n._computePcbGlobalTransformBeforeLayout(),ja(w.x,w.y),Kf(le*Math.PI/180),ja(-Q.x,-Q.y)),pe=e.toArray().filter(xe=>"pcb_component_id"in xe&&xe.pcb_component_id===B);Ub(pe,z);continue}let j=e.pcb_group.list().find(se=>se.source_group_id===B);if(!j)continue;let O=j.center,V=q??I??0,te=Bs(n._computePcbGlobalTransformBeforeLayout(),ja(w.x,w.y),Kf(V*Math.PI/180),ja(-O.x,-O.y)),N=e.toArray().filter(se=>{if("source_group_id"in se&&se.source_group_id&&(se.source_group_id===B||OF(e,se.source_group_id,B)))return!0;if("source_component_id"in se&&se.source_component_id){let $=e.source_component.get(se.source_component_id);if($?.source_group_id&&($.source_group_id===B||OF(e,$.source_group_id,B)))return!0}if("pcb_component_id"in se&&se.pcb_component_id){let $=e.pcb_component.get(se.pcb_component_id);if($?.source_component_id){let W=e.source_component.get($.source_component_id);if(W?.source_group_id&&(W.source_group_id===B||OF(e,W.source_group_id,B)))return!0}}return!1});Ub(N,te),e.pcb_group.update(j.pcb_group_id,{center:w})}},yXt=n=>{let{db:e}=n.root,{_parsedProps:a}=n,s=n.children.filter(te=>te.pcb_component_id||te.pcb_group_id);if(s.some(te=>{let N=te._parsedProps;return N?.pcbX!==void 0||N?.pcbY!==void 0}))return;let d=a.pcbJustifyContent??a.justifyContent,x=a.pcbAlignItems??a.alignItems,f=a.pcbFlexGap??a.pcbGap??a.gap,m=a.pcbFlexDirection??"row",y={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"}[d??"space-between"],b={start:"flex-start",end:"flex-end","flex-start":"flex-start","flex-end":"flex-end",stretch:"stretch",center:"center"}[x??"center"];if(!y)throw new Error(`Invalid justifyContent value: "${d}"`);if(!b)throw new Error(`Invalid alignItems value: "${x}"`);let E=0,A=0;typeof f=="object"?(E=f.y??0,A=f.x??0):typeof f=="number"?(E=f,A=f):typeof f=="string"&&(E=me.parse(f),A=me.parse(f));let w,B=a.width??a.pcbWidth??void 0,I=a.height??a.pcbHeight??void 0;(B===void 0||I===void 0)&&(w=y5(s.map(te=>te._getMinimumFlexContainerSize()).filter(te=>te!==null),{alignItems:b,justifyContent:y,direction:m,rowGap:E,columnGap:A}),B=w.width,I=w.height);let G=new bS(B,I,{alignItems:b,justifyContent:y,direction:m,rowGap:E,columnGap:A});for(let te of s){let N=te._getMinimumFlexContainerSize();G.addChild({metadata:te,width:N?.width??0,height:N?.height??0,flexBasis:N?m==="row"?N.width:N.height:void 0})}G.build();let j={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,width:0,height:0};for(let te of G.children)j.minX=Math.min(j.minX,te.position.x),j.minY=Math.min(j.minY,te.position.y),j.maxX=Math.max(j.maxX,te.position.x+te.size.width),j.maxY=Math.max(j.maxY,te.position.y+te.size.height);j.width=j.maxX-j.minX,j.height=j.maxY-j.minY;let O=n._getGlobalPcbPositionBeforeLayout(),V={x:O.x-(j.maxX+j.minX)/2,y:O.y-(j.maxY+j.minY)/2};for(let te of G.children)te.metadata._repositionOnPcb({x:te.position.x+te.size.width/2+V.x,y:te.position.y+te.size.height/2+V.y});e.pcb_group.update(n.pcb_group_id,{width:j.width,height:j.height,center:O})};function DXt(n){let{db:e}=n.root,a=new Map,s=new Map,l=new Set,x=n.selectAll("trace").filter(le=>le._parsedProps?.schDisplayLabel),f=new Set(x.map(le=>le.source_trace_id).filter(le=>!!le)),m=n.selectAll("group"),y=[n.schematic_group_id,...m.map(le=>le.schematic_group_id)],b=e.schematic_component.list().filter(le=>y.includes(le.schematic_group_id)),E=[],A=new Map,w=new Map;for(let le of b){let z=le.schematic_component_id,pe=[],xe=e.source_component.getWhere({source_component_id:le.source_component_id}),Ae=e.schematic_port.list({schematic_component_id:le.schematic_component_id});for(let Ie of Ae){let Le=`${xe?.name??le.schematic_component_id}.${Ie.pin_number}`;A.set(Le,Ie.schematic_port_id),w.set(Ie.schematic_port_id,Le)}for(let Ie of Ae){let Le=w.get(Ie.schematic_port_id);pe.push({pinId:Le,x:Ie.center.x,y:Ie.center.y})}E.push({chipId:z,center:le.center,width:le.size.width,height:le.size.height,pins:pe})}let B=new Set,I=new Map,q=new Map,G=new Map;for(let le of b){let z=e.schematic_port.list({schematic_component_id:le.schematic_component_id});for(let pe of z)B.add(pe.schematic_port_id),pe.source_port_id&&(I.set(pe.schematic_port_id,pe.source_port_id),q.set(pe.source_port_id,pe.schematic_port_id))}let j=new Set;n.subcircuit_id&&j.add(n.subcircuit_id);for(let le of m)le.subcircuit_id&&j.add(le.subcircuit_id);let V=e.source_trace.list().filter(le=>{if(le.subcircuit_id===n.subcircuit_id)return!0;for(let z of le.connected_source_port_ids)if(q.has(z))return!0;return!1}).flatMap(le=>le.connected_source_net_ids);for(let le of V){let z=e.source_net.get(le);z?.subcircuit_id&&j.add(z.subcircuit_id)}let te=[],N=new Map;for(let le of e.source_trace.list()){if(le.subcircuit_id&&!j.has(le.subcircuit_id))continue;let z=(le.connected_source_port_ids??[]).map(pe=>q.get(pe)).filter(pe=>!!pe&&B.has(pe));if(z.length>=2){let[pe,xe]=z.slice(0,2),Ae=[pe,xe].sort().join("::");if(!N.has(Ae)){N.set(Ae,le.source_trace_id);let Ie=le.display_name??le.source_trace_id;le.subcircuit_connectivity_map_key&&(l.add(le.subcircuit_connectivity_map_key),G.set(Ie,le.subcircuit_connectivity_map_key),s.set(le.subcircuit_connectivity_map_key,Ie)),te.push({pinIds:[pe,xe].map(Le=>w.get(Le)),netId:Ie})}}}let se=[];for(let le of e.source_net.list().filter(z=>!z.subcircuit_id||j.has(z.subcircuit_id)))le.subcircuit_connectivity_map_key&&(l.add(le.subcircuit_connectivity_map_key),a.set(le.subcircuit_connectivity_map_key,le));let $=new Map;for(let[le,z]of I){let pe=e.source_port.get(z);if(!pe?.subcircuit_connectivity_map_key)continue;let xe=pe.subcircuit_connectivity_map_key;l.add(xe),$.has(xe)||$.set(xe,[]),$.get(xe).push(le)}for(let[le,z]of $){let pe=a.get(le);if(pe&&z.length>=2){let xe=String(pe.name||pe.source_net_id||le);G.set(xe,le),s.set(le,xe),se.push({netId:xe,pinIds:z.map(Ae=>w.get(Ae))})}}let W=(()=>{let le={},z=new Set(se.map(pe=>pe.netId));for(let pe of e.source_net.list().filter(xe=>!xe.subcircuit_id||j.has(xe.subcircuit_id)))pe.name&&z.has(pe.name)&&(pe.is_ground||pe.name.startsWith("GND")?le[pe.name]=["y-"]:/^V/.test(pe.name)&&(le[pe.name]=["y+"]));return le})();return{inputProblem:{chips:E,directConnections:te,netConnections:se,availableNetLabelOrientations:W,maxMspPairDistance:n._parsedProps.schMaxTraceDistance??5},pinIdToSchematicPortId:A,pairKeyToSourceTraceId:N,sckToSourceNet:a,sckToUserNetId:s,userNetIdToSck:G,allSourceAndSchematicPortIdsInScope:B,schPortIdToSourcePortId:I,displayLabelTraces:x,allScks:l}}var Ki=1e-6;function uwe(n){let e=Math.abs(n.to.x-n.from.x),a=Math.abs(n.to.y-n.from.y);return e>=a}function VS(n,e){return Math.hypot(e.x-n.x,e.y-n.y)}function cwe(n,e,a){return{x:n.x+(e.x-n.x)*a,y:n.y+(e.y-n.y)*a}}function lwe(n,e,a){let s=VS(n,e);if(s<Ki)return 0;let l=((a.x-n.x)*(e.x-n.x)+(a.y-n.y)*(e.y-n.y))/((e.x-n.x)*(e.x-n.x)+(e.y-n.y)*(e.y-n.y));return Math.max(0,Math.min(1,l))*s}function kS(n,e,a,s){return n*s-e*a}function bXt(n,e,a,s){let l={x:e.x-n.x,y:e.y-n.y},d={x:s.x-a.x,y:s.y-a.y},x=kS(l.x,l.y,d.x,d.y),f={x:a.x-n.x,y:a.y-n.y},m=kS(f.x,f.y,l.x,l.y);if(Math.abs(x)<Ki&&Math.abs(m)<Ki||Math.abs(x)<Ki&&Math.abs(m)>=Ki)return null;let y=kS(f.x,f.y,d.x,d.y)/x,b=kS(f.x,f.y,l.x,l.y)/x;return y<-Ki||y>1+Ki||b<-Ki||b>1+Ki?null:{x:n.x+y*l.x,y:n.y+y*l.y}}function FXt(n,e=Ki){if(n.length===0)return n;n.sort((l,d)=>l.start-d.start);let a=[],s={...n[0]};for(let l=1;l<n.length;l++){let d=n[l];d.start<=s.end+e?s.end=Math.max(s.end,d.end):(a.push(s),s={...d})}return a.push(s),a}function EXt(n,e,a){let s=VS(n.from,n.to);if(s<Ki||e.length===0)return[n];let l=a/2,d=e.map(E=>({start:Math.max(0,E-l),end:Math.min(s,E+l)})).filter(E=>E.end-E.start>Ki),x=FXt(d),f=[],m=0,y={x:n.to.x-n.from.x,y:n.to.y-n.from.y},b=(E,A,w)=>{if(A-E<=Ki)return;let B=E/s,I=A/s;f.push({from:cwe(n.from,n.to,B),to:cwe(n.from,n.to,I),...w?{is_crossing:!0}:{}})};for(let E of x)E.start-m>Ki&&b(m,E.start,!1),b(E.start,E.end,!0),m=E.end;return s-m>Ki&&b(m,s,!1),f.length>0?f:[n]}function vXt(n,e={}){let a=e.crossSegmentLength??.075,s=e.tolerance??Ki,l=new Map,d=m=>`${m.traceIdx}:${m.edgeIdx}`,x=m=>n[m.traceIdx].edges[m.edgeIdx];for(let m=0;m<n.length;m++){let y=n[m];for(let b=0;b<y.edges.length;b++){let E=y.edges[b];for(let A=m;A<n.length;A++){let w=n[A];for(let B=A===m?b+1:0;B<w.edges.length;B++){let I=w.edges[B],q=bXt(E.from,E.to,I.from,I.to);if(!q)continue;let G=VS(E.from,E.to),j=VS(I.from,I.to);if(G<s||j<s)continue;let O=lwe(E.from,E.to,q),V=lwe(I.from,I.to,q),te=O<=s||Math.abs(G-O)<=s||Number.isNaN(O),N=V<=s||Math.abs(j-V)<=s||Number.isNaN(V);if(!te&&!N){let se=uwe(E),$=uwe(I),W;if(se!==$)W=se;else{let z=Math.abs(E.to.x-E.from.x),pe=Math.abs(E.to.y-E.from.y),xe=Math.abs(I.to.x-I.from.x),Ae=Math.abs(I.to.y-I.from.y),Ie=z-pe,Le=xe-Ae;W=Ie===Le?!0:Ie>Le}let Q=d({traceIdx:W?m:A,edgeIdx:W?b:B}),le=l.get(Q)??[];le.push(W?O:V),l.set(Q,le)}}}}}let f=n.map(m=>({id:m.id,edges:[]}));for(let m=0;m<n.length;m++){let y=n[m];for(let b=0;b<y.edges.length;b++){let E=d({traceIdx:m,edgeIdx:b}),A=l.get(E)??[];if(A.length===0){f[m].edges.push(y.edges[b]);continue}let w=Array.from(new Set(A.map(I=>Number(I.toFixed(6))))).sort((I,q)=>I-q),B=EXt(y.edges[b],w,a);f[m].edges.push(...B)}}return f}var nl=1e-6;function GS(n,e,a=nl){return Math.abs(n-e)<=a}function $g(n,e,a=nl){return GS(n.x,e.x,a)&&GS(n.y,e.y,a)}function dwe(n,e,a,s=nl){let l=Math.min(e.x,a.x)-s,d=Math.max(e.x,a.x)+s,x=Math.min(e.y,a.y)-s,f=Math.max(e.y,a.y)+s;return n.x<l||n.x>d||n.y<x||n.y>f?!1:Math.abs((a.x-e.x)*(n.y-e.y)-(a.y-e.y)*(n.x-e.x))<=s}function pwe(n,e=nl){let a=new Map;for(let s of n){let l=`${s.x.toFixed(6)},${s.y.toFixed(6)}`;a.has(l)||a.set(l,s)}return Array.from(a.values())}function xwe(n){return{x:n.to.x-n.from.x,y:n.to.y-n.from.y}}function TW(n,e,a=nl){let s=xwe(n),l=xwe(e),d=Math.hypot(s.x,s.y),x=Math.hypot(l.x,l.y);if(d<a||x<a)return!0;let f=s.x*l.y-s.y*l.x;return Math.abs(f)<=a*d*x}function LF(n,e,a=nl){return n.edges.filter(s=>$g(s.from,e,a)||$g(s.to,e,a))}function fwe(n,e,a=nl){for(let s of n.edges){if($g(s.from,e,a))return s.from;if($g(s.to,e,a))return s.to}return null}function CXt(n,e,a=nl){let s=$g(n.from,e,a)||GS(n.from.x,e.x,a)&&GS(n.from.y,e.y,a)?n.to:n.from,l=s.x-e.x,d=s.y-e.y;return Math.abs(l)<a&&Math.abs(d)<a?null:Math.abs(l)>=Math.abs(d)?l>=0?"right":"left":d>=0?"up":"down"}function Mg(n,e,a=nl){let s=LF(n,e,a);if(s.length<2)return null;let l=s.map(E=>CXt(E,e,a)),d=l.includes("up"),x=l.includes("down"),f=l.includes("left"),m=l.includes("right"),y=d?"up":x?"down":null,b=m?"right":f?"left":null;return y&&b?`${y}-${b}`:null}function _Xt(n,e={}){let a=e.tolerance??nl,s={};for(let d of n)s[d.id]=[];let l=n.map(d=>{let x=[];for(let f of d.edges)x.push(f.from,f.to);return pwe(x,a)});for(let d=0;d<n.length;d++){let x=n[d],f=l[d];for(let m=d+1;m<n.length;m++){let y=n[m],b=l[m];for(let E of f)for(let A of b)if($g(E,A,a)){let w=LF(x,E,a),B=LF(y,A,a),I=w.some(O=>B.some(V=>!TW(O,V,a))),q=Mg(x,E,a),G=Mg(y,A,a);I&&!(q!==null&&G!==null&&q===G)&&(s[x.id].push(E),x.id!==y.id&&s[y.id].push(A))}for(let E of f)for(let A of y.edges)if(dwe(E,A.from,A.to,a)){let B=LF(x,E,a).some(O=>!TW(O,A,a)),I=Mg(x,E,a),q=fwe(y,E,a*1e3),G=q?Mg(y,q,a):null;B&&!(I!==null&&G!==null&&I===G)&&(s[x.id].push(E),x.id!==y.id&&s[y.id].push(E))}for(let E of b)for(let A of x.edges)if(dwe(E,A.from,A.to,a)){let B=LF(y,E,a).some(O=>!TW(A,O,a)),I=Mg(y,E,a),q=fwe(x,E,a*1e3),G=q?Mg(x,q,a):null;B&&!(G!==null&&I!==null&&G===I)&&(s[y.id].push(E),x.id!==y.id&&s[x.id].push(E))}}}for(let d of Object.keys(s))s[d]=pwe(s[d],a);return s}function AXt(n){let{group:e,solver:a,pinIdToSchematicPortId:s,pairKeyToSourceTraceId:l}=n,{db:d}=e.root,x=a.traceOverlapShiftSolver?.correctedTraceMap,f=[];for(let b of Object.values(x??{})){let E=b?.tracePath;if(!Array.isArray(E)||E.length<2)continue;let A=[];for(let B=0;B<E.length-1;B++)A.push({from:{x:E[B].x,y:E[B].y},to:{x:E[B+1].x,y:E[B+1].y}});let w=null;if(Array.isArray(b?.pins)&&b.pins.length===2){let B=s.get(b.pins[0]?.pinId),I=s.get(b.pins[1]?.pinId);if(B&&I){let q=[B,I].sort().join("::");w=l.get(q)||`solver_${b.mspPairId||q}`;for(let G of[B,I])d.schematic_port.get(G)&&d.schematic_port.update(G,{is_connected:!0})}}w||(w=`solver_${b?.mspPairId}`),f.push({id:w,edges:A})}let m=vXt(f.map(b=>({id:b.id,edges:b.edges}))),y=_Xt(m);for(let b of m)d.schematic_trace.insert({source_trace_id:b.id,edges:b.edges,junctions:y[b.id]??[]})}var RXt=n=>{switch(n){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"}},SXt=n=>{for(let a of n){let s=a._getDirectlyConnectedTraces();for(let l of s){let d=l._parsedProps.schDisplayLabel;if(d)return{name:d,wasAssignedDisplayLabel:!0}}}return{name:n.map(a=>a._getNetLabelText()).join("/"),wasAssignedDisplayLabel:!1}},PW=(0,Nwe.default)("Group_doInitialSchematicTraceRender");function wXt(n){let{group:e,solver:a,sckToSourceNet:s,allScks:l,allSourceAndSchematicPortIdsInScope:d,schPortIdToSourcePortId:x,userNetIdToSck:f,pinIdToSchematicPortId:m,schematicPortIdsWithPreExistingNetLabels:y,schematicPortIdsWithRoutedTraces:b}=n,{db:E}=e.root,A=a.netLabelPlacementSolver?.netLabelPlacements??[],w=a.mspConnectionPairSolver.globalConnMap;for(let B of A){PW(`processing placement: ${B.netId}`);let I=w.getIdsConnectedToNet(B.globalConnNetId).find(Q=>f.get(Q)),q=f.get(I),G=B.anchorPoint,j=B.orientation,O=RXt(j),V=q?s.get(q):void 0,te=B.pinIds.map(Q=>m.get(Q));if(te.some(Q=>y.has(Q))){PW(`skipping net label placement for "${B.netId}" REASON:schematic port has pre-existing net label`);continue}if(V){let Q=V.name,le=nx({anchor_position:G,anchor_side:O,text:Q});E.schematic_net_label.insert({text:Q,anchor_position:G,center:le,anchor_side:O,...V?.source_net_id?{source_net_id:V.source_net_id}:{}});continue}let N=e.selectAll("port").filter(Q=>Q._getSubcircuitConnectivityKey()===q),{name:se,wasAssignedDisplayLabel:$}=SXt(N);if(!$&&te.some(Q=>b.has(Q))){PW(`skipping net label placement for "${B.netId}" REASON:schematic port has routed traces and no display label`);continue}let W=nx({anchor_position:G,anchor_side:O,text:se});E.schematic_net_label.insert({text:se,anchor_position:G,center:W,anchor_side:O})}}var BXt=({allSourceAndSchematicPortIdsInScope:n,group:e,schPortIdToSourcePortId:a,sckToSourceNet:s,pinIdToSchematicPortId:l,schematicPortIdsWithPreExistingNetLabels:d})=>{let{db:x}=e.root;for(let f of Array.from(n)){let m=x.schematic_port.get(f);if(!m||m.is_connected)continue;let y=a.get(f);if(!y)continue;let E=x.source_port.get(y)?.subcircuit_connectivity_map_key;if(!E)continue;let A=s.get(E);if(!A||x.schematic_net_label.list().some(G=>Math.abs(G.anchor_position.x-m.center.x)<.1&&Math.abs(G.anchor_position.y-m.center.y)<.1?A.source_net_id&&G.source_net_id?G.source_net_id===A.source_net_id:G.text===(A.name||E):!1))continue;let B=A.name||A.source_net_id||E,I=qF(m.facing_direction||"right")||"right",q=nx({anchor_position:m.center,anchor_side:I,text:B});x.schematic_net_label.insert({text:B,anchor_position:m.center,center:q,anchor_side:I,...A.source_net_id?{source_net_id:A.source_net_id}:{}})}},TXt=n=>{let e=new Set,a=n.selectAll("netlabel");for(let s of a){let l=s._getConnectedPorts();for(let d of l)d.schematic_port_id&&e.add(d.schematic_port_id)}return e},PXt=({solver:n,pinIdToSchematicPortId:e})=>{let a=n.schematicTraceLinesSolver.solvedTracePaths,s=new Set;for(let l of a)for(let d of l.pinIds){let x=e.get(d);x&&s.add(x)}return s},IXt=(0,jwe.default)("Group_doInitialSchematicTraceRender"),jXt=n=>{if(!n.root?._featureMspSchematicTraceRouting||!n.isSubcircuit||n.root?.schematicDisabled)return;let{inputProblem:e,pinIdToSchematicPortId:a,pairKeyToSourceTraceId:s,sckToSourceNet:l,allSourceAndSchematicPortIdsInScope:d,schPortIdToSourcePortId:x,displayLabelTraces:f,allScks:m,userNetIdToSck:y}=DXt(n),b=TXt(n);IXt.enabled&&globalThis.debugOutputs?.add("group-trace-render-input-problem",JSON.stringify(e,null,2));let E=new uSe(e);E.solve();let A=PXt({solver:E,pinIdToSchematicPortId:a});AXt({group:n,solver:E,pinIdToSchematicPortId:a,pairKeyToSourceTraceId:s}),wXt({group:n,solver:E,sckToSourceNet:l,allSourceAndSchematicPortIdsInScope:d,schPortIdToSourcePortId:x,pinIdToSchematicPortId:a,allScks:m,userNetIdToSck:y,schematicPortIdsWithPreExistingNetLabels:b,schematicPortIdsWithRoutedTraces:A}),BXt({group:n,allSourceAndSchematicPortIdsInScope:d,schPortIdToSourcePortId:x,sckToSourceNet:l,pinIdToSchematicPortId:a,schematicPortIdsWithPreExistingNetLabels:b})},zg=class extends Za{constructor(){super(...arguments);X(this,"pcb_group_id",null);X(this,"schematic_group_id",null);X(this,"subcircuit_id",null);X(this,"_hasStartedAsyncAutorouting",!1);X(this,"_asyncAutoroutingResult",null);X(this,"unnamedElementCounter",{})}get config(){return{zodProps:B8e,componentName:"Group"}}doInitialSourceGroupRender(){let{db:e}=this.root,a=e.source_group.insert({name:this.name,is_subcircuit:this.isSubcircuit});this.source_group_id=a.source_group_id,this.isSubcircuit&&(this.subcircuit_id=`subcircuit_${a.source_group_id}`,e.source_group.update(a.source_group_id,{subcircuit_id:this.subcircuit_id}))}doInitialSourceRender(){let{db:e}=this.root;for(let a of this.children)e.source_component.update(a.source_component_id,{source_group_id:this.source_group_id})}doInitialSourceParentAttachment(){let{db:e}=this.root,a=this.parent?.getGroup?.();if(a?.source_group_id&&e.source_group.update(this.source_group_id,{parent_source_group_id:a.source_group_id}),!this.isSubcircuit)return;let s=this.parent?.getSubcircuit?.()?.subcircuit_id;s&&e.source_group.update(this.source_group_id,{parent_subcircuit_id:s})}doInitialPcbComponentRender(){if(this.root?.pcbDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,s=e.pcb_group.insert({is_subcircuit:this.isSubcircuit,subcircuit_id:this.subcircuit_id??this.getSubcircuit()?.subcircuit_id,name:this.name,center:this._getGlobalPcbPositionBeforeLayout(),width:0,height:0,pcb_component_ids:[],source_group_id:this.source_group_id,autorouter_configuration:a.autorouter?{trace_clearance:a.autorouter.traceClearance}:void 0});this.pcb_group_id=s.pcb_group_id;for(let l of this.children)e.pcb_component.update(l.pcb_component_id,{pcb_group_id:s.pcb_group_id})}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:e}=this.root,a=this._parsedProps,s=GW(this.children);if(this.pcb_group_id){let l=s.width,d=s.height,x=(s.minX+s.maxX)/2,f=(s.minY+s.maxY)/2;if(this.isSubcircuit){let{padLeft:b,padRight:E,padTop:A,padBottom:w}=this._resolvePcbPadding();l+=b+E,d+=A+w,x+=(E-b)/2,f+=(A-w)/2}let y=this._parsedProps.pcbX!==void 0||this._parsedProps.pcbY!==void 0?e.pcb_group.get(this.pcb_group_id)?.center??{x,y:f}:{x,y:f};e.pcb_group.update(this.pcb_group_id,{width:Number(a.width??l),height:Number(a.height??d),center:y})}}getNextAvailableName(e){var a,s;return(a=this.unnamedElementCounter)[s=e.lowercaseComponentName]??(a[s]=1),`unnamed_${e.lowercaseComponentName}${this.unnamedElementCounter[e.lowercaseComponentName]++}`}_resolvePcbPadding(){let e=this._parsedProps,a=e.pcbLayout,s=E=>{let A=a?.[E],w=e[E];if(typeof A=="number")return A;if(typeof w=="number")return w},l=s("padding")??0,d=s("paddingX"),x=s("paddingY"),f=s("paddingLeft")??d??l,m=s("paddingRight")??d??l,y=s("paddingTop")??x??l,b=s("paddingBottom")??x??l;return{padLeft:f,padRight:m,padTop:y,padBottom:b}}doInitialCreateTraceHintsFromProps(){let{_parsedProps:e}=this,{db:a}=this.root,s=e;if(!this.isSubcircuit)return;let l=s.manualEdits?.manual_trace_hints;if(l)for(let d of l)this.add(new YW({for:d.pcb_port_selector,offsets:d.offsets}))}doInitialSourceAddConnectivityMapKey(){rXt(this)}_areChildSubcircuitsRouted(){let e=this.selectAll("group").filter(a=>a.isSubcircuit);for(let a of e)if(a._shouldRouteAsync()&&!a._asyncAutoroutingResult)return!1;return!0}_shouldRouteAsync(){let e=this._getAutorouterConfig();return e.groupMode==="sequential-trace"?!1:!!(e.local&&e.groupMode==="subcircuit"||!e.local)}_hasTracesToRoute(){let e=(0,Og.default)("tscircuit:core:_hasTracesToRoute"),a=this.selectAll("trace");return e(`[${this.getString()}] has ${a.length} traces to route`),a.length>0}async _runEffectMakeHttpAutoroutingRequest(){let{db:e}=this.root,a=(0,Og.default)("tscircuit:core:_runEffectMakeHttpAutoroutingRequest"),s=this._parsedProps,l=this._getAutorouterConfig(),d=l.serverUrl,x=l.serverMode,f=(b,E)=>(a("fetching",b),E.headers&&(E.headers["Tscircuit-Core-Version"]=this.root?.getCoreVersion()),fetch(b,E)),m=this.root.db.toArray().filter(b=>b.type.startsWith("source_")||b.type.startsWith("pcb_"));if(x==="solve-endpoint"){if(this.props.autorouter?.inputFormat==="simplified"){let{autorouting_result:E}=await f(`${d}/autorouting/solve`,{method:"POST",body:JSON.stringify({input_simple_route_json:MW({db:e,minTraceWidth:this.props.autorouter?.minTraceWidth??.15,subcircuit_id:this.subcircuit_id}).simpleRouteJson,subcircuit_id:this.subcircuit_id}),headers:{"Content-Type":"application/json"}}).then(A=>A.json());this._asyncAutoroutingResult=E,this._markDirty("PcbTraceRender");return}let{autorouting_result:b}=await f(`${d}/autorouting/solve`,{method:"POST",body:JSON.stringify({input_circuit_json:m,subcircuit_id:this.subcircuit_id}),headers:{"Content-Type":"application/json"}}).then(E=>E.json());this._asyncAutoroutingResult=b,this._markDirty("PcbTraceRender");return}let{autorouting_job:y}=await f(`${d}/autorouting/jobs/create`,{method:"POST",body:JSON.stringify({input_circuit_json:m,provider:"freerouting",autostart:!0,display_name:this.root?.name,subcircuit_id:this.subcircuit_id,server_cache_enabled:l.serverCacheEnabled}),headers:{"Content-Type":"application/json"}}).then(b=>b.json());for(;;){let{autorouting_job:b}=await f(`${d}/autorouting/jobs/get`,{method:"POST",body:JSON.stringify({autorouting_job_id:y.autorouting_job_id}),headers:{"Content-Type":"application/json"}}).then(E=>E.json());if(b.is_finished){let{autorouting_job_output:E}=await f(`${d}/autorouting/jobs/get_output`,{method:"POST",body:JSON.stringify({autorouting_job_id:y.autorouting_job_id}),headers:{"Content-Type":"application/json"}}).then(A=>A.json());this._asyncAutoroutingResult={output_pcb_traces:E.output_pcb_traces},this._markDirty("PcbTraceRender");break}if(b.has_error){let E=new MF(`Autorouting job failed: ${JSON.stringify(b.error)}`);throw e.pcb_autorouting_error.insert({pcb_error_id:y.autorouting_job_id,error_type:"pcb_autorouting_error",message:E.message}),E}await new Promise(E=>setTimeout(E,100))}}async _runLocalAutorouting(){let{db:e}=this.root,a=this._parsedProps,s=(0,Og.default)("tscircuit:core:_runLocalAutorouting");s(`[${this.getString()}] starting local autorouting`);let l=this._getAutorouterConfig(),{simpleRouteJson:d}=MW({db:e,minTraceWidth:this.props.autorouter?.minTraceWidth??.15,subcircuit_id:this.subcircuit_id});if(s.enabled){let m=YY(d);m.title=`autorouting-${this.props.name}`,global.debugGraphics?.push(m)}this.root?.emit("autorouting:start",{subcircuit_id:this.subcircuit_id,componentDisplayName:this.getString(),simpleRouteJson:d});let x;l.algorithmFn?x=await l.algorithmFn(d):x=new YGt(d,{capacityDepth:this.props.autorouter?.capacityDepth,targetMinCapacity:this.props.autorouter?.targetMinCapacity});let f=new Promise((m,y)=>{x.on("complete",b=>{s(`[${this.getString()}] local autorouting complete`),m(b.traces)}),x.on("error",b=>{s(`[${this.getString()}] local autorouting error: ${b.error.message}`),y(b.error)})});x.on("progress",m=>{this.root?.emit("autorouting:progress",{subcircuit_id:this.subcircuit_id,componentDisplayName:this.getString(),...m})}),x.start();try{let m=await f;this._asyncAutoroutingResult={output_pcb_traces:m},this._markDirty("PcbTraceRender")}catch(m){let{db:y}=this.root;throw y.pcb_autorouting_error.insert({pcb_error_id:`pcb_autorouter_error_subcircuit_${this.subcircuit_id}`,error_type:"pcb_autorouting_error",message:m instanceof Error?m.message:String(m)}),this.root?.emit("autorouting:error",{subcircuit_id:this.subcircuit_id,componentDisplayName:this.getString(),error:{message:m instanceof Error?m.message:String(m)},simpleRouteJson:d}),m}finally{x.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 e=(0,Og.default)("tscircuit:core:doInitialPcbTraceRender");if(this.isSubcircuit&&!this.root?.pcbDisabled&&!this.getInheritedProperty("routingDisabled")&&!this._shouldUseTraceByTraceRouting()){if(!this._areChildSubcircuitsRouted()){e(`[${this.getString()}] child subcircuits are not routed, skipping async autorouting until subcircuits routed`);return}e(`[${this.getString()}] no child subcircuits to wait for, initiating async routing`),this._hasTracesToRoute()&&this._startAsyncAutorouting()}}doInitialSchematicTraceRender(){jXt(this)}updatePcbTraceRender(){let e=(0,Og.default)("tscircuit:core:updatePcbTraceRender");if(e(`[${this.getString()}] updating...`),!this.isSubcircuit)return;if(this._shouldRouteAsync()&&this._hasTracesToRoute()&&!this._hasStartedAsyncAutorouting){this._areChildSubcircuitsRouted()&&(e(`[${this.getString()}] child subcircuits are now routed, starting async autorouting`),this._startAsyncAutorouting());return}if(!this._asyncAutoroutingResult||this._shouldUseTraceByTraceRouting())return;let{db:a}=this.root;if(this._asyncAutoroutingResult.output_simple_route_json){e(`[${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){e(`[${this.getString()}] updating PCB traces from ${this._asyncAutoroutingResult.output_pcb_traces.length} traces`),this._updatePcbTraceRenderFromPcbTraces();return}}_updatePcbTraceRenderFromSimpleRouteJson(){let{db:e}=this.root,{traces:a}=this._asyncAutoroutingResult.output_simple_route_json;if(a)for(let s of a){let l=e.pcb_trace.insert({subcircuit_id:this.subcircuit_id,route:s.route})}}_updatePcbTraceRenderFromPcbTraces(){let{output_pcb_traces:e}=this._asyncAutoroutingResult;if(!e)return;let{db:a}=this.root;for(let s of e)if(s.type==="pcb_trace"){if(s.subcircuit_id=this.subcircuit_id,s.connection_name){let l=s.connection_name;s.source_trace_id=l}a.pcb_trace.insert(s)}for(let s of e)if(s.type!=="pcb_via"&&s.type==="pcb_trace")for(let l of s.route)l.route_type==="via"&&a.pcb_via.insert({pcb_trace_id:s.pcb_trace_id,x:l.x,y:l.y,hole_diameter:.3,outer_diameter:.6,layers:[l.from_layer,l.to_layer],from_layer:l.from_layer,to_layer:l.to_layer})}doInitialSchematicComponentRender(){if(this.root?.schematicDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,s=e.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=s.schematic_group_id;for(let l of this.children)l.schematic_component_id&&e.schematic_component.update(l.schematic_component_id,{schematic_group_id:s.schematic_group_id})}_getSchematicLayoutMode(){let e=this._parsedProps;if(e.schLayout?.layoutMode==="none"||e.schLayout?.layoutMode==="relative")return"relative";if(e.schLayout?.matchAdapt)return"match-adapt";if(e.schLayout?.flex)return"flex";if(e.schLayout?.grid)return"grid";if(e.schMatchAdapt)return"match-adapt";if(e.schFlex)return"flex";if(e.schGrid)return"grid";if(e.matchAdapt)return"match-adapt";if(e.flex)return"flex";if(e.grid)return"grid";if(e.relative||e.schRelative)return"relative";let a=this.children.some(l=>{let d=l._parsedProps;return d?.schX!==void 0||d?.schY!==void 0}),s=(e.manualEdits?.schematic_placements?.length??0)>0;return!a&&!s?"match-adapt":"relative"}doInitialSchematicLayout(){let e=this._getSchematicLayoutMode();e==="match-adapt"&&this._doInitialSchematicLayoutMatchpack(),e==="grid"&&this._doInitialSchematicLayoutGrid(),e==="flex"&&this._doInitialSchematicLayoutFlex(),this._insertSchematicBorder()}_doInitialSchematicLayoutMatchAdapt(){QGt(this)}_doInitialSchematicLayoutMatchpack(){tXt(this)}_doInitialSchematicLayoutGrid(){nXt(this)}_doInitialSchematicLayoutFlex(){aXt(this)}_getPcbLayoutMode(){let e=this._parsedProps;if(e.pcbLayout?.matchAdapt)return"match-adapt";if(e.pcbLayout?.flex)return"flex";if(e.pcbLayout?.grid)return"grid";if(e.pcbLayout?.pack)return"pack";if(e.pcbFlex)return"flex";if(e.pcbGrid)return"grid";if(e.pcbPack||e.pack)return"pack";if(e.matchAdapt)return"match-adapt";if(e.flex)return"flex";if(e.grid)return"grid";let a=e.pcbX!==void 0||e.pcbY!==void 0,s=(e.manualEdits?.pcb_placements?.length??0)>0;if(this.children.some(x=>{let f=x._parsedProps;return f?.pcbX!==void 0||f?.pcbY!==void 0}))return"none";let d=this.children.reduce((x,f)=>{let m=f._parsedProps,y=m?.pcbX!==void 0||m?.pcbY!==void 0;return x+(y?0:1)},0);return!a&&!s&&d>1?"pack":"none"}doInitialPcbLayout(){let e=this._getPcbLayoutMode();e==="grid"?this._doInitialPcbLayoutGrid():e==="pack"?this._doInitialPcbLayoutPack():e==="flex"&&this._doInitialPcbLayoutFlex()}_doInitialPcbLayoutGrid(){sXt(this)}_doInitialPcbLayoutPack(){gXt(this)}_doInitialPcbLayoutFlex(){yXt(this)}_insertSchematicBorder(){if(this.root?.schematicDisabled)return;let{db:e}=this.root,a=this._parsedProps;if(!a.border)return;let s=typeof a.schWidth=="number"?a.schWidth:void 0,l=typeof a.schHeight=="number"?a.schHeight:void 0,d=typeof a.schPadding=="number"?a.schPadding:0,x=typeof a.schPaddingLeft=="number"?a.schPaddingLeft:d,f=typeof a.schPaddingRight=="number"?a.schPaddingRight:d,m=typeof a.schPaddingTop=="number"?a.schPaddingTop:d,y=typeof a.schPaddingBottom=="number"?a.schPaddingBottom:d,b=this.schematic_group_id?e.schematic_group.get(this.schematic_group_id):null;if(b&&(s===void 0&&typeof b.width=="number"&&(s=b.width),l===void 0&&typeof b.height=="number"&&(l=b.height)),s===void 0||l===void 0)return;let E=b?.center??this._getGlobalSchematicPositionBeforeLayout(),A=E.x-s/2-x,w=E.y-l/2-y,B=s+x+f,I=l+m+y;e.schematic_box.insert({width:B,height:I,x:A,y:w,is_dashed:a.border?.dashed??!1})}_determineSideFromPosition(e,a){if(!e.center||!a.center)return"left";let s=e.center.x-a.center.x,l=e.center.y-a.center.y;return Math.abs(s)>Math.abs(l)?s>0?"right":"left":l>0?"bottom":"top"}_calculateSchematicBounds(e){if(e.length===0)return{minX:0,maxX:0,minY:0,maxY:0};let a=1/0,s=-1/0,l=1/0,d=-1/0;for(let f of e)a=Math.min(a,f.centerX),s=Math.max(s,f.centerX),l=Math.min(l,f.centerY),d=Math.max(d,f.centerY);let x=2;return{minX:a-x,maxX:s+x,minY:l-x,maxY:d+x}}_getAutorouterConfig(){let e=this._parsedProps.autorouter||this.getInheritedProperty("autorouter");return hXt(e)}_getSubcircuitLayerCount(){let e=this.getInheritedProperty("layers");return typeof e=="number"?e:2}_shouldUseTraceByTraceRouting(){return this._getAutorouterConfig().groupMode==="sequential-trace"}doInitialPcbDesignRuleChecks(){if(this.root?.pcbDisabled||this.getInheritedProperty("routingDisabled"))return;let{db:e}=this.root;if(this.isSubcircuit){let a=new Map;for(let s of this.children)if(!s.isSubcircuit&&s._parsedProps.name){let l=a.get(s._parsedProps.name)||[];l.push(s),a.set(s._parsedProps.name,l)}for(let[s,l]of a.entries())l.length>1&&e.pcb_trace_error.insert({error_type:"pcb_trace_error",message:`Multiple components found with name "${s}" in subcircuit "${this.name||"unnamed"}". Component names must be unique within a subcircuit.`,source_trace_id:"",pcb_trace_id:"",pcb_component_ids:l.map(d=>d.pcb_component_id).filter(Boolean),pcb_port_ids:[]})}}doInitialSchematicReplaceNetLabelsWithSymbols(){if(this.root?.schematicDisabled||!this.isSubcircuit)return;let{db:e}=this.root,a=e;for(let s of a.schematic_net_label.list()){let l=a.source_net.get(s.source_net_id),d=s.text||l?.name||"";if(s.anchor_side==="top"&&/^gnd/i.test(d)){a.schematic_net_label.update(s.schematic_net_label_id,{symbol_name:"ground_down"});continue}s.anchor_side==="bottom"&&/^v/i.test(d)&&a.schematic_net_label.update(s.schematic_net_label_id,{symbol_name:"vcc_up"})}}_getMinimumFlexContainerSize(){return super._getMinimumFlexContainerSize()}_repositionOnPcb(e){return super._repositionOnPcb(e)}},kwe=class extends zg{constructor(){super(...arguments);X(this,"pcb_board_id",null);X(this,"_drcChecksComplete",!1);X(this,"_connectedSchematicPortPairs",new Set)}get isSubcircuit(){return!0}get isGroup(){return!0}get config(){return{componentName:"Board",zodProps:fY}}get boardThickness(){let{_parsedProps:e}=this;return 1.4}get allLayers(){return(this._parsedProps.layers??2)===4?["top","bottom","inner1","inner2"]:["top","bottom"]}_getSubcircuitLayerCount(){return this._parsedProps.layers??2}doInitialPcbBoardAutoSize(){if(this.root?.pcbDisabled||!this.pcb_board_id)return;let{db:e}=this.root,{_parsedProps:a}=this;if(a.width&&a.height)return;let s=1/0,l=1/0,d=-1/0,x=-1/0,f=Bwe(e,this.subcircuit_id),m=new Set([this.subcircuit_id,...f]),y=e.pcb_component.list().filter(O=>O.subcircuit_id&&m.has(O.subcircuit_id)),b=e.pcb_group.list().filter(O=>O.subcircuit_id&&m.has(O.subcircuit_id)),E=!1,A=(O,V,te)=>{V===0||te===0||(E=!0,s=Math.min(s,O.x-V/2),l=Math.min(l,O.y-te/2),d=Math.max(d,O.x+V/2),x=Math.max(x,O.y+te/2))};for(let O of y)A(O.center,O.width,O.height);for(let O of b)A(O.center,O.width,O.height);let w=2,B=E?d-s+w*2:0,I=E?x-l+w*2:0,q={x:E?(s+d)/2+(a.outlineOffsetX??0):a.outlineOffsetX??0,y:E?(l+x)/2+(a.outlineOffsetY??0):a.outlineOffsetY??0},G=a.width??B,j=a.height??I;e.pcb_board.update(this.pcb_board_id,{width:G,height:j,center:q})}_addBoardInformationToSilkscreen(){let e=this.root?.platform;if(!e?.printBoardInformationToSilkscreen)return;let a=this.root.db.pcb_board.get(this.pcb_board_id);if(!a)return;let s=[];if(e.projectName&&s.push(e.projectName),e.version&&s.push(`v${e.version}`),e.url&&s.push(e.url),s.length===0)return;let l=s.join(`
1078
- `),f={x:a.center.x+a.width/2-.25,y:a.center.y-a.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:l,ccw_rotation:0,anchor_alignment:"bottom_right",anchor_position:f})}doInitialPcbComponentRender(){if(this.root?.pcbDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,s=a.width??0,l=a.height??0,d={x:(a.pcbX??0)+(a.outlineOffsetX??0),y:(a.pcbY??0)+(a.outlineOffsetY??0)};if(a.outline){let f=a.outline.map(w=>w.x),m=a.outline.map(w=>w.y),y=Math.min(...f),b=Math.max(...f),E=Math.min(...m),A=Math.max(...m);s=b-y,l=A-E,d={x:(y+b)/2+(a.outlineOffsetX??0),y:(E+A)/2+(a.outlineOffsetY??0)}}let x=e.pcb_board.insert({center:d,thickness:this.boardThickness,num_layers:this.allLayers.length,width:s,height:l,outline:a.outline?.map(f=>({x:f.x+(a.outlineOffsetX??0),y:f.y+(a.outlineOffsetY??0)})),material:a.material});this.pcb_board_id=x.pcb_board_id,this._addBoardInformationToSilkscreen()}removePcbComponentRender(){let{db:e}=this.root;this.pcb_board_id&&(e.pcb_board.delete(this.pcb_board_id),this.pcb_board_id=null)}_computePcbGlobalTransformBeforeLayout(){return go()}doInitialPcbDesignRuleChecks(){this.root?.pcbDisabled||this.getInheritedProperty("routingDisabled")||super.doInitialPcbDesignRuleChecks()}updatePcbDesignRuleChecks(){if(this.root?.pcbDisabled||this.getInheritedProperty("routingDisabled"))return;let{db:e}=this.root;if(!this._areChildSubcircuitsRouted()||this._drcChecksComplete)return;this._drcChecksComplete=!0;let a=pSe(e.toArray());for(let l of a)e.pcb_trace_error.insert(l);let s=dSe(e.toArray());for(let l of s)e.pcb_port_not_connected_error.insert(l)}_emitRenderLifecycleEvent(e,a){super._emitRenderLifecycleEvent(e,a),a==="start"&&this.root?.emit("board:renderPhaseStarted",{renderId:this._renderId,phase:e})}},NXt=new Proxy({},{get:(n,e)=>e}),cd=NXt,Mwe=class extends Za{get config(){return{componentName:"Capacitor",schematicSymbolName:this.props.polarized?"capacitor_polarized":this.props.symbolName??"capacitor",zodProps:L8e,sourceFtype:cd.simple_capacitor}}initPorts(){typeof this.props.footprint=="string"?super.initPorts({additionalAliases:{pin1:["anode","pos"],pin2:["cathode","neg"]}}):super.initPorts()}_getSchematicSymbolDisplayValue(){let n=this.props.capacitance,e=typeof n=="string"?n:`${Is(this._parsedProps.capacitance)}F`;return this._parsedProps.schShowRatings&&this._parsedProps.maxVoltageRating?`${e}/${Is(this._parsedProps.maxVoltageRating)}V`:e}doInitialCreateNetsFromProps(){this._createNetsFromProps([this.props.decouplingFor,this.props.decouplingTo,...this._getNetsFromConnectionsProp()])}doInitialCreateTracesFromProps(){this.props.decouplingFor&&this.props.decouplingTo&&(this.add(new zc({from:`${this.getSubcircuitSelector()} > port.1`,to:this.props.decouplingFor})),this.add(new zc({from:`${this.getSubcircuitSelector()} > port.2`,to:this.props.decouplingTo}))),this._createTracesFromConnectionsProp()}doInitialSourceRender(){let{db:n}=this.root,{_parsedProps:e}=this,a=n.source_component.insert({ftype:"simple_capacitor",name:this.name,manufacturer_part_number:e.manufacturerPartNumber??e.mfn,supplier_part_numbers:e.supplierPartNumbers,capacitance:e.capacitance,max_voltage_rating:e.maxVoltageRating,max_decoupling_trace_length:e.maxDecouplingTraceLength,display_capacitance:this._getSchematicSymbolDisplayValue(),are_pins_interchangeable:!e.polarized});this.source_component_id=a.source_component_id}};function kXt(n){if(!n)return{validPinLabels:n,invalidPinLabelsMessages:[]};let e={},a=[];for(let[s,l]of Object.entries(n)){let d=Array.isArray(l)?l.slice():[l],x=[];for(let f of d)MXt(s,f)?x.push(f):a.push(`Invalid pin label: ${s} = '${f}' - excluding from component. Please use a valid pin label.`);x.length>0&&(e[s]=Array.isArray(l)?x:x[0])}return{validPinLabels:Object.keys(e).length>0?e:void 0,invalidPinLabelsMessages:a}}function MXt(n,e){try{let a={name:"test",footprint:"test",pinLabels:{[n]:e}};return Lb.safeParse(a).success}catch{return!1}}var HW=class extends Za{constructor(e){let a={...e},s=[];if(a.pinLabels){let{validPinLabels:l,invalidPinLabelsMessages:d}=kXt(a.pinLabels);a.pinLabels=l,s=d}super(a);X(this,"schematicBoxDimensions",null);X(this,"_invalidPinLabelMessages",[]);this._invalidPinLabelMessages=s}get config(){return{componentName:"Chip",zodProps:Lb,shouldRenderAsSchematicBox:!0}}initPorts(e={}){super.initPorts(e);let{_parsedProps:a}=this;if(a.externallyConnectedPins){let s=new Set;for(let[l,d]of a.externallyConnectedPins)s.add(l),s.add(d);for(let l of s)if(!this.children.find(x=>x instanceof Fo&&x.isMatchingAnyOf([l]))){let x=l.match(/^pin(\d+)$/);if(x){let f=parseInt(x[1]);this.add(new Fo({pinNumber:f,aliases:[l]}))}else this.add(new Fo({name:l,aliases:[l]}))}}}doInitialSchematicComponentRender(){let{_parsedProps:e}=this;if(e?.noSchematicRepresentation!==!0){if(this._invalidPinLabelMessages?.length&&this.root?.db)for(let a of this._invalidPinLabelMessages){let s="pinLabels",l=a.match(/^Invalid pin label:\s*([^=]+)=\s*'([^']+)'/);l&&(s=`pinLabels['${l[2]}']`),this.root.db.source_property_ignored_warning.insert({source_component_id:this.source_component_id,property_name:s,message:a,error_type:"source_property_ignored_warning"})}super.doInitialSchematicComponentRender()}}doInitialSourceRender(){let{db:e}=this.root,{_parsedProps:a}=this,s=e.source_component.insert({ftype:"simple_chip",name:this.name,manufacturer_part_number:a.manufacturerPartNumber,supplier_part_numbers:a.supplierPartNumbers});this.source_component_id=s.source_component_id}doInitialPcbComponentRender(){if(this.root?.pcbDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,s=e.pcb_component.insert({center:{x:a.pcbX??0,y:a.pcbY??0},width:2,height:3,layer:a.layer??"top",rotation:a.pcbRotation??0,source_component_id:this.source_component_id,subcircuit_id:this.getSubcircuit().subcircuit_id??void 0});this.pcb_component_id=s.pcb_component_id}doInitialCreateTracesFromProps(){let{_parsedProps:e}=this;if(e.externallyConnectedPins)for(let[a,s]of e.externallyConnectedPins)this.add(new zc({from:`${this.getSubcircuitSelector()} > port.${a}`,to:`${this.getSubcircuitSelector()} > port.${s}`}));this._createTracesFromConnectionsProp()}doInitialSimulationRender(){let{db:e}=this.root,{pinAttributes:a}=this.props;if(!a)return;let s=null,l=null,d,x=this.selectAll("port");for(let E of x)for(let A of E.getNameAndAliases())if(a[A]){let w=a[A];w.providesPower&&(s=E,d=w.providesVoltage),w.providesGround&&(l=E)}if(!s||!l||d===void 0)return;let f=e.source_port.get(s.source_port_id);if(!f?.subcircuit_connectivity_map_key)return;let m=e.source_port.get(l.source_port_id);if(!m?.subcircuit_connectivity_map_key)return;let y=e.source_net.getWhere({subcircuit_connectivity_map_key:f.subcircuit_connectivity_map_key}),b=e.source_net.getWhere({subcircuit_connectivity_map_key:m.subcircuit_connectivity_map_key});!y||!b||e.simulation_voltage_source.insert({type:"simulation_voltage_source",positive_source_port_id:s.source_port_id,positive_source_net_id:y.source_net_id,negative_source_port_id:l.source_port_id,negative_source_net_id:b.source_net_id,voltage:d})}},Owe=class extends Za{constructor(){super(...arguments);X(this,"pos",this.portMap.pin1);X(this,"anode",this.portMap.pin1);X(this,"neg",this.portMap.pin2);X(this,"cathode",this.portMap.pin2)}get config(){let e={schottky:"schottky_diode",avalanche:"avalanche_diode",zener:"zener_diode",photodiode:"photodiode"},a=this.props.schottky?"schottky":this.props.avalanche?"avalanche":this.props.zener?"zener":this.props.photo?"photodiode":null;return{schematicSymbolName:a?e[a]:this.props.symbolName??"diode",componentName:"Diode",zodProps:eAe,sourceFtype:"simple_diode"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}doInitialSourceRender(){let{db:e}=this.root,{_parsedProps:a}=this,s=e.source_component.insert({ftype:"simple_diode",name:this.name,manufacturer_part_number:a.manufacturerPartNumber??a.mfn,supplier_part_numbers:a.supplierPartNumbers,are_pins_interchangeable:!1});this.source_component_id=s.source_component_id}},Lwe=class extends Za{get config(){return{componentName:"fuse",schematicSymbolName:this.props.symbolName??"fuse",zodProps:P8e,sourceFtype:cd.simple_fuse}}_getSchematicSymbolDisplayValue(){let n=this._parsedProps.currentRating,e=this._parsedProps.voltageRating,a=typeof n=="string"?parseFloat(n):n,s=typeof e=="string"?parseFloat(e):e;return`${Is(a)}A / ${Is(s)}V`}doInitialSourceRender(){let{db:n}=this.root,{_parsedProps:e}=this,a=typeof e.currentRating=="string"?parseFloat(e.currentRating):e.currentRating,s=typeof e.voltageRating=="string"?parseFloat(e.voltageRating):e.voltageRating,l=n.source_component.insert({name:this.name,ftype:cd.simple_fuse,current_rating_amps:a,voltage_rating_volts:s,display_current_rating:`${Is(a)}A`,display_voltage_rating:`${Is(s)}V`});this.source_component_id=l.source_component_id}},$we=class extends Za{constructor(){super(...arguments);X(this,"schematicDimensions",null)}get config(){return{schematicSymbolName:void 0,componentName:"Jumper",zodProps:mY,shouldRenderAsSchematicBox:!0}}_getSchematicPortArrangement(){let e=super._getSchematicPortArrangement();if(e&&Object.keys(e).length>0)return e;let a=this._parsedProps.pinCount??(Array.isArray(this._parsedProps.pinLabels)?this._parsedProps.pinLabels.length:this._parsedProps.pinLabels?Object.keys(this._parsedProps.pinLabels).length:this.getPortsFromFootprint().length),s=this._parsedProps.schDirection??"right";return{leftSize:s==="left"?a:0,rightSize:s==="right"?a:0}}doInitialSourceRender(){let{db:e}=this.root,{_parsedProps:a}=this,s=e.source_component.insert({ftype:"simple_chip",name:this.name,manufacturer_part_number:a.manufacturerPartNumber,supplier_part_numbers:a.supplierPartNumbers,are_pins_interchangeable:!0});this.source_component_id=s.source_component_id}doInitialPcbComponentRender(){if(this.root?.pcbDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,s=e.pcb_component.insert({center:{x:a.pcbX??0,y:a.pcbY??0},width:2,height:3,layer:a.layer??"top",rotation:a.pcbRotation??0,source_component_id:this.source_component_id,subcircuit_id:this.getSubcircuit().subcircuit_id??void 0});this.pcb_component_id=s.pcb_component_id}doInitialPcbTraceRender(){let{db:e}=this.root,a=e.pcb_port.list({pcb_component_id:this.pcb_component_id}),s={};for(let x=0;x<a.length;x++){let f=a[x],m=e.source_port.get(f.source_port_id),y="";if(typeof m?.pin_number=="number")y=m.pin_number.toString();else if(Array.isArray(m?.port_hints)){let b=m.port_hints.find(E=>/^(pin)?\d+$/.test(E));b&&(/^pin\d+$/.test(b)?y=b.replace(/^pin/,""):y=b)}s[y]=f.pcb_port_id}let l=e.pcb_trace.list({pcb_component_id:this.pcb_component_id}),d=x=>{if(x&&typeof x=="string"&&x.startsWith("{PIN")){let f=x.replace("{PIN","").replace("}","");return s[f]||x}return x};for(let x of l)if(x.route)for(let f of x.route)f.route_type==="wire"&&(f.start_pcb_port_id=d(f.start_pcb_port_id),f.end_pcb_port_id=d(f.end_pcb_port_id))}},zwe=class extends Za{constructor(){super(...arguments);X(this,"schematicDimensions",null)}_getPinNumberFromBridgedPinName(e){return this.selectOne(`port.${e}`,{type:"port"})?._parsedProps.pinNumber??null}get defaultInternallyConnectedPinNames(){if(this._parsedProps.bridged){let e=this.children.filter(a=>a.componentName==="Port").map(a=>a.name);return e.length>0?[e]:[]}return this._parsedProps.bridgedPins??[]}get config(){let e=this._parsedProps??this.props,a=e.pinCount;if(e.pinCount==null&&!e.footprint&&(a=2),e.pinCount==null){let d=(e.bridgedPins??[]).flat().map(y=>this._getPinNumberFromBridgedPinName(y)).filter(y=>y!==null),x=d.length>0?Math.max(...d):0,f=e.pinLabels?Object.keys(e.pinLabels).length:0,m=Math.max(x,f);(m===2||m===3)&&(a=m),a==null&&e.footprint&&[2,3].includes(this.getPortsFromFootprint().length)&&(a=this.getPortsFromFootprint().length)}let s="";a?s+=`solderjumper${a}`:s="solderjumper";let l=[];return Array.isArray(e.bridgedPins)&&e.bridgedPins.length>0?l=Array.from(new Set(e.bridgedPins.flat().map(d=>this._getPinNumberFromBridgedPinName(d)).filter(d=>d!==null))).sort((d,x)=>d-x):e.bridged&&a&&(l=Array.from({length:a},(d,x)=>x+1)),l.length>0&&(s+=`_bridged${l.join("")}`),{schematicSymbolName:e.symbolName??s,componentName:"SolderJumper",zodProps:T8e,shouldRenderAsSchematicBox:!0}}_getSchematicPortArrangement(){let e=super._getSchematicPortArrangement();if(e&&Object.keys(e).length>0)return e;let a=this._parsedProps.pinCount??(Array.isArray(this._parsedProps.pinLabels)?this._parsedProps.pinLabels.length:this._parsedProps.pinLabels?Object.keys(this._parsedProps.pinLabels).length:this.getPortsFromFootprint().length);a==null&&!this._parsedProps.footprint&&(a=2);let s=this._parsedProps.schDirection??"right";return{leftSize:s==="left"?a:0,rightSize:s==="right"?a:0}}doInitialSourceRender(){let{db:e}=this.root,{_parsedProps:a}=this,s=e.source_component.insert({ftype:"simple_chip",name:this.name,manufacturer_part_number:a.manufacturerPartNumber,supplier_part_numbers:a.supplierPartNumbers,are_pins_interchangeable:!0});this.source_component_id=s.source_component_id}doInitialPcbComponentRender(){if(this.root?.pcbDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,s=e.pcb_component.insert({center:{x:a.pcbX??0,y:a.pcbY??0},width:2,height:3,layer:a.layer??"top",rotation:a.pcbRotation??0,source_component_id:this.source_component_id,subcircuit_id:this.getSubcircuit().subcircuit_id??void 0});this.pcb_component_id=s.pcb_component_id}doInitialPcbTraceRender(){let{db:e}=this.root,a=e.pcb_port.list({pcb_component_id:this.pcb_component_id}),s={};for(let x=0;x<a.length;x++){let f=a[x],m=e.source_port.get(f.source_port_id),y="";if(typeof m?.pin_number=="number")y=m.pin_number.toString();else if(Array.isArray(m?.port_hints)){let b=m.port_hints.find(E=>/^(pin)?\d+$/.test(E));b&&(/^pin\d+$/.test(b)?y=b.replace(/^pin/,""):y=b)}s[y]=f.pcb_port_id}let l=e.pcb_trace.list({pcb_component_id:this.pcb_component_id}),d=x=>{if(x&&typeof x=="string"&&x.startsWith("{PIN")){let f=x.replace("{PIN","").replace("}","");return s[f]||x}return x};for(let x of l)if(x.route)for(let f of x.route)f.route_type==="wire"&&(f.start_pcb_port_id=d(f.start_pcb_port_id),f.end_pcb_port_id=d(f.end_pcb_port_id))}},qwe=class extends Za{constructor(){super(...arguments);X(this,"pos",this.portMap.pin1);X(this,"anode",this.portMap.pin1);X(this,"neg",this.portMap.pin2);X(this,"cathode",this.portMap.pin2)}get config(){let e={laser:"laser_diode"},a=this.props.laser?"laser":null;return{schematicSymbolName:a?e[a]:this.props.symbolName??"led",componentName:"Led",zodProps:rAe,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}doInitialSourceRender(){let{db:e}=this.root,{_parsedProps:a}=this,s=e.source_component.insert({ftype:"simple_led",name:this.name,wave_length:a.wavelength,color:a.color,symbol_display_value:this._getSchematicSymbolDisplayValue(),manufacturer_part_number:a.manufacturerPartNumber??a.mfn,supplier_part_numbers:a.supplierPartNumbers,are_pins_interchangeable:!1});this.source_component_id=s.source_component_id}},Uwe=class extends Za{constructor(){super(...arguments);X(this,"pos",this.portMap.pin1);X(this,"positive",this.portMap.pin1);X(this,"neg",this.portMap.pin2);X(this,"negative",this.portMap.pin2)}get config(){return{schematicSymbolName:this.props.symbolName??"power_factor_meter_horz",componentName:"PowerSource",zodProps:dAe,sourceFtype:"simple_power_source"}}initPorts(){this.add(new Fo({name:"pin1",pinNumber:1,aliases:["positive","pos"]})),this.add(new Fo({name:"pin2",pinNumber:2,aliases:["negative","neg"]}))}doInitialSourceRender(){let{db:e}=this.root,{_parsedProps:a}=this,s=e.source_component.insert({ftype:"simple_power_source",name:this.name,voltage:a.voltage,supplier_part_numbers:a.supplierPartNumbers,are_pins_interchangeable:!1});this.source_component_id=s.source_component_id}},OXt=ps.extend({voltage:vi.optional(),frequency:Nc.optional(),peakToPeakVoltage:vi.optional(),waveShape:C.enum(["sinewave","square","triangle","sawtooth"]).optional(),phase:Ia.optional(),dutyCycle:C.number().optional()}),Vwe=class extends Za{constructor(){super(...arguments);X(this,"terminal1",this.portMap.terminal1);X(this,"terminal2",this.portMap.terminal2)}get config(){return{componentName:"VoltageSource",schematicSymbolName:this.props.waveShape==="square"?"square_wave":"ac_voltmeter",zodProps:OXt,sourceFtype:"simple_voltage_source"}}runRenderPhaseForChildren(e){if(!e.startsWith("Pcb"))for(let a of this.children)a.runRenderPhaseForChildren(e),a.runRenderPhase(e)}doInitialPcbComponentRender(){}initPorts(){super.initPorts({additionalAliases:{pin1:["terminal1"],pin2:["terminal2"]}})}doInitialSourceRender(){let{db:e}=this.root,{_parsedProps:a}=this,s=e.source_component.insert({ftype:"simple_voltage_source",name:this.name,voltage:a.voltage,frequency:a.frequency,peak_to_peak_voltage:a.peakToPeakVoltage,wave_shape:a.waveShape,phase:a.phase,duty_cycle:a.dutyCycle,supplier_part_numbers:a.supplierPartNumbers,are_pins_interchangeable:!0});this.source_component_id=s.source_component_id}doInitialSimulationRender(){let{db:e}=this.root,{_parsedProps:a}=this,s=this.portMap.terminal1,l=this.portMap.terminal2;e.simulation_voltage_source.insert({type:"simulation_voltage_source",is_dc_source:!1,terminal1_source_port_id:s.source_port_id,terminal2_source_port_id:l.source_port_id,voltage:a.voltage,frequency:a.frequency,peak_to_peak_voltage:a.peakToPeakVoltage,wave_shape:a.waveShape,phase:a.phase,duty_cycle:a.dutyCycle})}},Gwe=class extends Za{get config(){return{componentName:"Resistor",schematicSymbolName:this.props.symbolName??"boxresistor",zodProps:j8e,sourceFtype:"simple_resistor"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}_getSchematicSymbolDisplayValue(){return`${Is(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 zc({from:`${this.getSubcircuitSelector()} > port.1`,to:this.props.pullupFor})),this.add(new zc({from:`${this.getSubcircuitSelector()} > port.2`,to:this.props.pullupTo}))),this.props.pulldownFor&&this.props.pulldownTo&&(this.add(new zc({from:`${this.getSubcircuitSelector()} > port.1`,to:this.props.pulldownFor})),this.add(new zc({from:`${this.getSubcircuitSelector()} > port.2`,to:this.props.pulldownTo}))),this._createTracesFromConnectionsProp()}doInitialSourceRender(){let{db:n}=this.root,{_parsedProps:e}=this,a=n.source_component.insert({ftype:"simple_resistor",name:this.name,manufacturer_part_number:e.manufacturerPartNumber??e.mfn,supplier_part_numbers:e.supplierPartNumbers,resistance:e.resistance,display_resistance:this._getSchematicSymbolDisplayValue(),are_pins_interchangeable:!0});this.source_component_id=a.source_component_id}},LXt=["leftedge","rightedge","topedge","bottomedge","center"],Xwe=class extends ga{get config(){return{componentName:"Constraint",zodProps:z8e}}constructor(n){if(super(n),("xdist"in n||"ydist"in n)&&!("edgeToEdge"in n)&&!("centerToCenter"in n))throw new Error(`edgeToEdge, centerToCenter must be set for xDist or yDist for ${this}`);if("for"in n&&n.for.length<2)throw new Error(`"for" must have at least two selectors for ${this}`)}_getAllReferencedComponents(){let n=[],e=this.getPrimitiveContainer();function a(s){let l=s.split(" ").pop(),d=LXt.includes(l)?l:void 0,x=d?s.replace(` ${d}`,""):s,f=e.selectOne(x,{pcbPrimitive:!0});f&&n.push({selector:s,component:f,componentSelector:x,edge:d})}for(let s of["left","right","top","bottom"])s in this._parsedProps&&a(this._parsedProps[s]);if("for"in this._parsedProps)for(let s of this._parsedProps.for)a(s);return{componentsWithSelectors:n}}},Ywe=class extends ga{constructor(){super(...arguments);X(this,"fabrication_note_path_id",null)}get config(){return{componentName:"FabricationNotePath",zodProps:iAe}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:e}=this.root,a=this.getSubcircuit(),{_parsedProps:s}=this,l=s.layer??"top";if(l!=="top"&&l!=="bottom")throw new Error(`Invalid layer "${l}" for SilkscreenPath. Must be "top" or "bottom".`);let d=this._computePcbGlobalTransformBeforeLayout(),x=this.parent?.pcb_component_id??this.getPrimitiveContainer()?.pcb_component_id,f=e.pcb_fabrication_note_path.insert({pcb_component_id:x,layer:l,color:s.color,route:s.route.map(m=>{let y=vs(d,{x:m.x,y:m.y});return{...m,x:y.x,y:y.y}}),stroke_width:s.strokeWidth??.1,subcircuit_id:a?.subcircuit_id??void 0});this.fabrication_note_path_id=f.pcb_fabrication_note_path_id}},Hwe=class extends ga{get config(){return{componentName:"FabricationNoteText",zodProps:sAe}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:n}=this.root,{_parsedProps:e}=this,a=this.getPrimitiveContainer(),s=this.getSubcircuit();n.pcb_fabrication_note_text.insert({anchor_alignment:e.anchorAlignment,anchor_position:{x:e.pcbX??0,y:e.pcbY??0},font:e.font??"tscircuit2024",font_size:e.fontSize??1,layer:"top",color:e.color,text:e.text??"",pcb_component_id:a.pcb_component_id,subcircuit_id:s?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0})}},Wwe=class extends zg{constructor(n){super({...n,subcircuit:!0})}},Kwe=class extends zg{constructor(n){super({...n,subcircuit:!0})}doInitialPcbPrimitiveRender(){if(super.doInitialPcbPrimitiveRender(),this.root?.pcbDisabled)return;let{db:n}=this.root,e=this._parsedProps;if(!this.pcb_group_id)return;let a=n.pcb_group.get(this.pcb_group_id),s=e.paddingLeft??e.padding??0,l=e.paddingRight??e.padding??0,d=e.paddingTop??e.padding??0,x=e.paddingBottom??e.padding??0;n.pcb_group.update(this.pcb_group_id,{width:a.width+s+l,height:a.height+d+x,center:{x:a.center.x+(l-s)/2,y:a.center.y+(d-x)/2}})}},Jwe=class extends ga{constructor(){super(...arguments);X(this,"pcb_breakout_point_id",null);X(this,"matchedPort",null);X(this,"matchedNet",null);X(this,"isPcbPrimitive",!0)}get config(){return{componentName:"BreakoutPoint",zodProps:cAe}}_matchConnection(){let{connection:e}=this._parsedProps,a=this.getSubcircuit();a&&(this.matchedPort=a.selectOne(e,{type:"port"}),this.matchedPort||(this.matchedNet=a.selectOne(e,{type:"net"})),!this.matchedPort&&!this.matchedNet&&this.renderError(`Could not find connection target "${e}"`))}_getSourceTraceIdForPort(e){let{db:a}=this.root;return a.source_trace.list().find(l=>l.connected_source_port_ids.includes(e.source_port_id))?.source_trace_id}_getSourceNetIdForPort(e){let{db:a}=this.root;return a.source_trace.list().find(l=>l.connected_source_port_ids.includes(e.source_port_id))?.connected_source_net_ids[0]}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:e}=this.root;this._matchConnection();let{pcbX:a=0,pcbY:s=0}=this._parsedProps,l=this.parent?.getGroup(),d=this.getSubcircuit();if(!l||!l.pcb_group_id)return;let x=e.pcb_breakout_point.insert({pcb_group_id:l.pcb_group_id,subcircuit_id:d?.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:a,y:s});this.pcb_breakout_point_id=x.pcb_breakout_point_id}_getPcbCircuitJsonBounds(){let{pcbX:e=0,pcbY:a=0}=this._parsedProps;return{center:{x:e,y:a},bounds:{left:e,top:a,right:e,bottom:a},width:0,height:0}}_setPositionFromLayout(e){let{db:a}=this.root;this.pcb_breakout_point_id&&a.pcb_breakout_point.update(this.pcb_breakout_point_id,{x:e.x,y:e.y})}getPcbSize(){return{width:0,height:0}}},Zwe=class extends ga{constructor(){super(...arguments);X(this,"source_net_label_id")}get config(){return{componentName:"NetLabel",zodProps:W8e}}_getAnchorSide(){let{_parsedProps:e}=this;if(e.anchorSide)return e.anchorSide;if(!this._resolveConnectsTo())return"right";let s=this._getGlobalSchematicPositionBeforeLayout(),l=this._getConnectedPorts();if(l.length===0)return"right";let d=l[0]._getGlobalSchematicPositionBeforeLayout(),x=d.x-s.x,f=d.y-s.y;if(Math.abs(x)>Math.abs(f)){if(x>0)return"right";if(x<0)return"left"}else{if(f>0)return"top";if(f<0)return"bottom"}return"right"}_getConnectedPorts(){let e=this._resolveConnectsTo();if(!e)return[];let a=[];for(let s of e){let l=this.getSubcircuit().selectOne(s);l&&a.push(l)}return a}computeSchematicPropsTransform(){let{_parsedProps:e}=this;if(e.schX===void 0&&e.schY===void 0){let a=this._getConnectedPorts();if(a.length>0){let s=a[0]._getGlobalSchematicPositionBeforeLayout(),l=vs(this.parent?.computeSchematicGlobalTransform?.()??go(),{x:0,y:0});return ja(s.x-l.x,s.y-l.y)}}return super.computeSchematicPropsTransform()}doInitialSchematicPrimitiveRender(){if(this.root?.schematicDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,s=this._getGlobalSchematicPositionBeforeLayout(),l=this.getSubcircuit().selectOne(`net.${this._getNetName()}`),d=a.anchorSide??"right",x=nx({anchor_position:s,anchor_side:d,text:a.net}),f=e.schematic_net_label.insert({text:a.net,source_net_id:l.source_net_id,anchor_position:s,center:x,anchor_side:this._getAnchorSide()});this.source_net_label_id=f.source_net_id}_resolveConnectsTo(){let{_parsedProps:e}=this,a=e.connectsTo??e.connection;if(Array.isArray(a))return a;if(typeof a=="string")return[a]}_getNetName(){let{_parsedProps:e}=this;return e.net}doInitialCreateNetsFromProps(){let{_parsedProps:e}=this;e.net&&zW(this,[`net.${e.net}`])}doInitialCreateTracesFromNetLabels(){if(this.root?.schematicDisabled)return;let e=this._resolveConnectsTo();if(e)for(let a of e)this.add(new zc({from:a,to:`net.${this._getNetName()}`}))}doInitialSchematicTraceRender(){if(!this.root?._featureMspSchematicTraceRouting||this.root?.schematicDisabled)return;let{db:e}=this.root,a=this._resolveConnectsTo();if(!a||a.length===0)return;let s=this._getGlobalSchematicPositionBeforeLayout(),l=this._getAnchorSide(),x={left:"x-",right:"x+",top:"y+",bottom:"y-"}[l],f=this.getSubcircuit().selectOne(`net.${this._getNetName()}`);for(let m of a){let y=this.getSubcircuit().selectOne(m,{type:"port"});if(!y||!y.schematic_port_id)continue;let b=!1;if(f?.source_net_id){let q=e.source_trace.list().find(G=>G.connected_source_net_ids?.includes(f.source_net_id)&&G.connected_source_port_ids?.includes(y.source_port_id??""));if(q&&(b=e.schematic_trace.list().some(G=>G.source_trace_id===q.source_trace_id)),b)continue}let E=y._getGlobalSchematicPositionAfterLayout(),A=kW(y.facingDirection??"right")??"x+",w=f5({x:E.x,y:E.y,facingDirection:A},{x:s.x,y:s.y,facingDirection:x});if(!Array.isArray(w)||w.length<2)continue;let B=[];for(let q=0;q<w.length-1;q++)B.push({from:{x:w[q].x,y:w[q].y},to:{x:w[q+1].x,y:w[q+1].y}});let I;f?.source_net_id&&y.source_port_id&&(I=e.source_trace.list().find(G=>G.connected_source_net_ids?.includes(f.source_net_id)&&G.connected_source_port_ids?.includes(y.source_port_id))?.source_trace_id),e.schematic_trace.insert({source_trace_id:I,edges:B,junctions:[]}),e.schematic_port.update(y.schematic_port_id,{is_connected:!0})}}},Qwe=class extends ga{constructor(){super(...arguments);X(this,"pcb_silkscreen_circle_id",null);X(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenCircle",zodProps:FAe}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,{maybeFlipLayer:s}=this._getPcbPrimitiveFlippedHelpers(),l=s(a.layer??"top");if(l!=="top"&&l!=="bottom")throw new Error(`Invalid layer "${l}" for SilkscreenCircle. Must be "top" or "bottom".`);let d=this._computePcbGlobalTransformBeforeLayout(),x=this.getSubcircuit(),f=this.parent?.pcb_component_id??this.getPrimitiveContainer()?.pcb_component_id,m=e.pcb_silkscreen_circle.insert({pcb_component_id:f,layer:l,center:{x:a.pcbX??0,y:a.pcbY??0},radius:a.radius,subcircuit_id:x?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0,stroke_width:a.strokeWidth??.1});this.pcb_silkscreen_circle_id=m.pcb_silkscreen_circle_id}getPcbSize(){let{_parsedProps:e}=this,a=e.radius*2;return{width:a,height:a}}},e9e=class extends ga{constructor(){super(...arguments);X(this,"pcb_silkscreen_rect_id",null);X(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenRect",zodProps:bAe}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,{maybeFlipLayer:s}=this._getPcbPrimitiveFlippedHelpers(),l=s(a.layer??"top");if(l!=="top"&&l!=="bottom")throw new Error(`Invalid layer "${l}" for SilkscreenRect. Must be "top" or "bottom".`);let d=this.getSubcircuit(),x=this.parent?.pcb_component_id??this.getPrimitiveContainer()?.pcb_component_id,f=e.pcb_silkscreen_rect.insert({pcb_component_id:x,layer:l,center:{x:a.pcbX??0,y:a.pcbY??0},width:a.width,height:a.height,subcircuit_id:d?.subcircuit_id??void 0,pcb_group_id:this?.getGroup()?.pcb_group_id??void 0,stroke_width:a.strokeWidth??.1});this.pcb_silkscreen_rect_id=f.pcb_silkscreen_rect_id}getPcbSize(){let{_parsedProps:e}=this;return{width:e.width,height:e.height}}},t9e=class extends ga{constructor(){super(...arguments);X(this,"pcb_silkscreen_line_id",null);X(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenLine",zodProps:DAe}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,{maybeFlipLayer:s}=this._getPcbPrimitiveFlippedHelpers(),l=s(a.layer??"top");if(l!=="top"&&l!=="bottom")throw new Error(`Invalid layer "${l}" for SilkscreenLine. Must be "top" or "bottom".`);let d=this.getSubcircuit(),x=this.parent?.pcb_component_id??this.getPrimitiveContainer()?.pcb_component_id,f=e.pcb_silkscreen_line.insert({pcb_component_id:x,layer:l,x1:a.x1,y1:a.y1,x2:a.x2,y2:a.y2,stroke_width:a.strokeWidth??.1,subcircuit_id:d?.subcircuit_id??void 0,pcb_group_id:d?.getGroup()?.pcb_group_id??void 0});this.pcb_silkscreen_line_id=f.pcb_silkscreen_line_id}getPcbSize(){let{_parsedProps:e}=this,a=Math.abs(e.x2-e.x1),s=Math.abs(e.y2-e.y1);return{width:a,height:s}}},r9e=class extends ga{constructor(){super(...arguments);X(this,"pcb_via_id",null);X(this,"matchedPort",null);X(this,"isPcbPrimitive",!0)}get config(){return{componentName:"Via",zodProps:oAe}}getAvailablePcbLayers(){return["top","inner1","inner2","bottom"]}getPcbSize(){let{_parsedProps:e}=this;return{width:e.outerDiameter,height:e.outerDiameter}}_getPcbCircuitJsonBounds(){let{db:e}=this.root,a=e.pcb_via.get(this.pcb_via_id),s=this.getPcbSize();return{center:{x:a.x,y:a.y},bounds:{left:a.x-s.width/2,top:a.y-s.height/2,right:a.x+s.width/2,bottom:a.y+s.height/2},width:s.width,height:s.height}}_setPositionFromLayout(e){let{db:a}=this.root;a.pcb_via.update(this.pcb_via_id,{x:e.x,y:e.y})}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,s=this._getGlobalPcbPositionBeforeLayout(),l=this.getSubcircuit(),d=e.pcb_via.insert({x:s.x,y:s.y,hole_diameter:a.holeDiameter,outer_diameter:a.outerDiameter,layers:["bottom","top"],from_layer:a.fromLayer||"bottom",to_layer:a.toLayer||"top",subcircuit_id:l?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0});this.pcb_via_id=d.pcb_via_id}},n9e=class extends Za{get config(){return{componentName:"Battery",schematicSymbolName:this.props.symbolName??"battery",zodProps:Y8e,sourceFtype:"simple_power_source"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}doInitialSourceRender(){let{db:n}=this.root,{_parsedProps:e}=this,a=n.source_component.insert({name:this.name,ftype:"simple_power_source",capacity:e.capacity,supplier_part_numbers:e.supplierPartNumbers,are_pins_interchangeable:!1});this.source_component_id=a.source_component_id}},a9e=class extends Za{get config(){return{componentName:"PinHeader",zodProps:H8e,shouldRenderAsSchematicBox:!0}}_getImpliedFootprintString(){let n=this._parsedProps.pinCount??(Array.isArray(this._parsedProps.pinLabels)?this._parsedProps.pinLabels.length:this._parsedProps.pinLabels?Object.keys(this._parsedProps.pinLabels).length:0),e=this._parsedProps.holeDiameter,a=this._parsedProps.platedDiameter,s=this._parsedProps.pitch,l=this._parsedProps.showSilkscreenPinLabels;if(n>0){let d;if(s)!e&&!a?d=`pinrow${n}_p${s}`:d=`pinrow${n}_p${s}_id${e}_od${a}`;else if(!e&&!a)d=`pinrow${n}`;else return null;return l!==!0&&(d+="_nopinlabels"),d}return null}initPorts(){let n=this._parsedProps.pinCount??(Array.isArray(this._parsedProps.pinLabels)?this._parsedProps.pinLabels.length:this._parsedProps.pinLabels?Object.keys(this._parsedProps.pinLabels).length:1);for(let e=1;e<=n;e++){let a=Array.isArray(this._parsedProps.pinLabels)?this._parsedProps.pinLabels[e-1]:this._parsedProps.pinLabels?.[`pin${e}`];if(a){let s=Array.isArray(a)?a[0]:a,l=Array.isArray(a)?a.slice(1):[];this.add(new Fo({pinNumber:e,name:s,aliases:[`pin${e}`,...l]}))}else this.add(new Fo({pinNumber:e,name:`pin${e}`}))}}_getSchematicPortArrangement(){let n=this._parsedProps.pinCount??1,e=this._parsedProps.schFacingDirection??this._parsedProps.facingDirection??"right",a=this._parsedProps.schPinArrangement;return e==="left"?{leftSide:{direction:a?.leftSide?.direction??"top-to-bottom",pins:a?.leftSide?.pins??Array.from({length:n},(s,l)=>`pin${l+1}`)}}:{rightSide:{direction:a?.rightSide?.direction??"top-to-bottom",pins:a?.rightSide?.pins??Array.from({length:n},(s,l)=>`pin${l+1}`)}}}doInitialSourceRender(){let{db:n}=this.root,{_parsedProps:e}=this,a=n.source_component.insert({ftype:"simple_pin_header",name:this.name,supplier_part_numbers:e.supplierPartNumbers,pin_count:e.pinCount,gender:e.gender,are_pins_interchangeable:!0});this.source_component_id=a.source_component_id}};function $Xt(n){switch(n){case"two_ground_pins":return"crystal_4pin";case"ground_pin":return"resonator";case"no_ground":return"crystal";default:return"crystal"}}var s9e=class extends Za{get config(){return{componentName:"Resonator",schematicSymbolName:this.props.symbolName??$Xt(this.props.pinVariant),zodProps:O8e,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){let{db:n}=this.root,{_parsedProps:e}=this,a=e.pinVariant||"no_ground",s=n.source_component.insert({ftype:"simple_resonator",name:this.name,frequency:e.frequency,load_capacitance:e.loadCapacitance,supplier_part_numbers:e.supplierPartNumbers,pin_variant:a,are_pins_interchangeable:a==="no_ground"||a==="ground_pin"});this.source_component_id=s.source_component_id}_getSchematicSymbolDisplayValue(){let n=`${Is(this._parsedProps.frequency)}Hz`;return this._parsedProps.loadCapacitance?`${n} / ${Is(this._parsedProps.loadCapacitance)}F`:n}},i9e=class extends Za{get config(){return{componentName:"Inductor",schematicSymbolName:this.props.symbolName??"inductor",zodProps:Q8e,sourceFtype:cd.simple_inductor}}_getSchematicSymbolDisplayValue(){return`${Is(this._parsedProps.inductance)}H`}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}doInitialSourceRender(){let{db:n}=this.root,{_parsedProps:e}=this,a=n.source_component.insert({name:this.name,ftype:cd.simple_inductor,inductance:e.inductance,supplier_part_numbers:e.supplierPartNumbers,are_pins_interchangeable:!0});this.source_component_id=a.source_component_id}};function zXt(n){switch(n){case"three_pin":return"potentiometer3";case"two_pin":return"potentiometer2";default:return"potentiometer2"}}var o9e=class extends Za{get config(){return{componentName:"Potentiometer",schematicSymbolName:this.props.symbolName??zXt(this.props.pinVariant),zodProps:k8e,shouldRenderAsSchematicBox:!1}}_getSchematicSymbolDisplayValue(){return`${Is(this._parsedProps.maxResistance)}\u03A9`}doInitialSourceRender(){let{db:n}=this.root,{_parsedProps:e}=this,a=e.pinVariant||"two_pin",s=n.source_component.insert({ftype:"simple_potentiometer",name:this.name,max_resistance:e.maxResistance,pin_variant:a,are_pins_interchangeable:a==="two_pin"});this.source_component_id=s.source_component_id}},u9e=class extends Za{get config(){return{componentName:"PushButton",schematicSymbolName:this.props.symbolName??"push_button_normally_open_momentary",zodProps:K8e,sourceFtype:cd.simple_push_button}}get defaultInternallyConnectedPinNames(){return[]}initPorts(){super.initPorts({pinCount:2,ignoreSymbolPorts:!0});let n=Ts[this._getSchematicSymbolNameOrThrow()],e=n.ports.find(y=>y.labels.includes("1")),a=n.ports.find(y=>y.labels.includes("2")),s=this.selectAll("port"),l=s.find(y=>y.props.pinNumber===1),d=s.find(y=>y.props.pinNumber===2),x=s.find(y=>y.props.pinNumber===3),f=s.find(y=>y.props.pinNumber===4),{internallyConnectedPins:m}=this._parsedProps;l.schematicSymbolPortDef=e,(!m||m.length===0)&&(d.schematicSymbolPortDef=a);for(let[y,b]of[[2,d],[3,x],[4,f]]){let E=m?.find(([w,B])=>w===`pin${y}`||B===`pin${y}`);if(!E){b.schematicSymbolPortDef=a;break}(E?.[0]===`pin${y}`?E[1]:E?.[0])!=="pin1"&&(b.schematicSymbolPortDef=a)}}doInitialSourceRender(){let{db:n}=this.root,{_parsedProps:e}=this,a=n.source_component.insert({name:this.name,ftype:cd.simple_push_button,supplier_part_numbers:e.supplierPartNumbers,are_pins_interchangeable:!0});this.source_component_id=a.source_component_id}},c9e=class extends Za{get config(){return{schematicSymbolName:this.props.symbolName??(this.props.pinVariant==="four_pin"?"crystal_4pin":"crystal"),componentName:"Crystal",zodProps:M8e,sourceFtype:"simple_crystal"}}initPorts(){let n=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:n})}_getSchematicSymbolDisplayValue(){let n=`${Is(this._parsedProps.frequency)}Hz`;return this._parsedProps.loadCapacitance?`${n} / ${Is(this._parsedProps.loadCapacitance)}F`:n}doInitialSourceRender(){let{db:n}=this.root,{_parsedProps:e}=this,a=n.source_component.insert({name:this.name,ftype:"simple_crystal",frequency:e.frequency,load_capacitance:e.loadCapacitance,pin_variant:e.pinVariant||"two_pin",are_pins_interchangeable:(e.pinVariant||"two_pin")==="two_pin"});this.source_component_id=a.source_component_id}},l9e=class extends Za{constructor(){super(...arguments);X(this,"emitter",this.portMap.pin1);X(this,"collector",this.portMap.pin2);X(this,"base",this.portMap.pin3)}get config(){let e=this.props.type==="npn"?"npn_bipolar_transistor":"pnp_bipolar_transistor";return{componentName:"Transistor",schematicSymbolName:this.props.symbolName??e,zodProps:J8e,sourceFtype:"simple_transistor",shouldRenderAsSchematicBox:!1}}initPorts(){let e={pin1:["collector","c"],pin2:["emitter","e"],pin3:["base","b"]};super.initPorts({pinCount:3,additionalAliases:e})}doInitialCreateNetsFromProps(){this._createNetsFromProps([...this._getNetsFromConnectionsProp()])}doInitialCreateTracesFromProps(){this._createTracesFromConnectionsProp()}doInitialSourceRender(){let{db:e}=this.root,{_parsedProps:a}=this,s=e.source_component.insert({ftype:"simple_transistor",name:this.name,transistor_type:a.type});this.source_component_id=s.source_component_id}},d9e=class extends Za{get config(){let n=this.props.mosfetMode==="depletion"?"d":"e",a=`${this.props.channelType}_channel_${n}_mosfet_transistor`;return{componentName:"Mosfet",schematicSymbolName:this.props.symbolName??a,zodProps:Z8e,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){let{db:n}=this.root,{_parsedProps:e}=this,a=n.source_component.insert({ftype:"simple_mosfet",name:this.name,mosfet_mode:e.mosfetMode,channel_type:e.channelType});this.source_component_id=a.source_component_id}},p9e=class extends Za{_getSwitchType(){let{spst:n,spdt:e,dpst:a,dpdt:s,type:l}=this._parsedProps??{};return s?"dpdt":n?"spst":e?"spdt":a?"dpst":l??"spst"}get config(){let n=this._getSwitchType(),{isNormallyClosed:e}=this._parsedProps??{},s={spst:e?"spst_normally_closed_switch":"spst_switch",spdt:e?"spdt_normally_closed_switch":"spdt_switch",dpst:e?"dpst_normally_closed_switch":"dpst_switch",dpdt:e?"dpdt_normally_closed_switch":"dpdt_switch"}[n]??"spst_switch";return{componentName:"Switch",schematicSymbolName:this.props.symbolName??s,zodProps:aAe,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){let{db:n}=this.root,{_parsedProps:e}=this,a=n.source_component.insert({ftype:"simple_switch",name:this.name,switch_type:e.type,is_normally_closed:e.isNormallyClosed??!1,are_pins_interchangeable:this._getSwitchType()==="spst"});this.source_component_id=a.source_component_id}},IW={HOLE_DIAMETER:.5,SMT_CIRCLE_DIAMETER:1.2,SMT_RECT_SIZE:2},x9e=class extends Za{get config(){return{componentName:"TestPoint",schematicSymbolName:this.props.symbolName??"testpoint",zodProps:uAe,sourceFtype:cd.simple_test_point}}_getPropsWithDefaults(){let{padShape:n,holeDiameter:e,footprintVariant:a,padDiameter:s,width:l,height:d}=this._parsedProps;return!a&&e&&(a="through_hole"),a??(a="through_hole"),n??(n="circle"),a==="pad"?n==="circle"?s??(s=IW.SMT_CIRCLE_DIAMETER):n==="rect"&&(l??(l=IW.SMT_RECT_SIZE),d??(d=l)):a==="through_hole"&&(e??(e=IW.HOLE_DIAMETER)),{padShape:n,holeDiameter:e,footprintVariant:a,padDiameter:s,width:l,height:d}}_getImpliedFootprintString(){let{padShape:n,holeDiameter:e,footprintVariant:a,padDiameter:s,width:l,height:d}=this._getPropsWithDefaults();if(a==="through_hole")return`platedhole_d${e}`;if(a==="pad"){if(n==="circle")return`smtpad_circle_d${s}`;if(n==="rect")return`smtpad_rect_w${l}_h${d}`}throw new Error(`Footprint variant "${a}" with pad shape "${n}" not implemented`)}doInitialSourceRender(){let{db:n}=this.root,{_parsedProps:e}=this,{padShape:a,holeDiameter:s,footprintVariant:l,padDiameter:d,width:x,height:f}=this._getPropsWithDefaults(),m=n.source_component.insert({ftype:cd.simple_test_point,name:this.name,supplier_part_numbers:e.supplierPartNumbers,footprint_variant:l,pad_shape:a,pad_diameter:d,hole_diameter:s,width:x,height:f,are_pins_interchangeable:!0});this.source_component_id=m.source_component_id}},f9e=class extends ga{constructor(){super(...arguments);X(this,"isSchematicPrimitive",!0)}get config(){return{componentName:"SchematicText",zodProps:xAe}}doInitialSchematicPrimitiveRender(){if(this.root?.schematicDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,s=this._getGlobalSchematicPositionBeforeLayout();e.schematic_text.insert({anchor:a.anchor??"center",text:a.text,font_size:a.fontSize,color:a.color||"#000000",position:{x:s.x,y:s.y},rotation:a.schRotation??0})}};function qXt({anchor:n,x:e,y:a,width:s,height:l,isInside:d}){switch(n){case"top_left":return{x:e,y:a+l,textAnchor:d?"top_left":"bottom_left"};case"top_center":return{x:e+s/2,y:a+l,textAnchor:d?"top_center":"bottom_center"};case"top_right":return{x:e+s,y:a+l,textAnchor:d?"top_right":"bottom_right"};case"center_left":return{x:e,y:a+l/2,textAnchor:d?"center_left":"center_right"};case"center":return{x:e+s/2,y:a+l/2,textAnchor:"center"};case"center_right":return{x:e+s,y:a+l/2,textAnchor:d?"center_right":"center_left"};case"bottom_left":return{x:e,y:a,textAnchor:d?"bottom_left":"top_left"};case"bottom_center":return{x:e+s/2,y:a,textAnchor:d?"bottom_center":"top_center"};case"bottom_right":return{x:e+s,y:a,textAnchor:d?"bottom_right":"top_right"};default:return{x:e+s/2,y:a+l,textAnchor:"center"}}}var h9e=class extends ga{constructor(){super(...arguments);X(this,"isSchematicPrimitive",!0)}get config(){return{componentName:"SchematicBox",zodProps:pAe,shouldRenderAsSchematicBox:!0}}doInitialSchematicPrimitiveRender(){if(this.root?.schematicDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,s=.6,l=typeof a.padding=="number"?a.padding:0,d=typeof a.paddingTop=="number"?a.paddingTop:l,x=typeof a.paddingBottom=="number"?a.paddingBottom:l,f=typeof a.paddingLeft=="number"?a.paddingLeft:l,m=typeof a.paddingRight=="number"?a.paddingRight:l,y=a.overlay&&a.overlay.length>0,b=typeof a.width=="number"&&typeof a.height=="number",E,A,w,B,I,q;if(y){let j=a.overlay.map(Qe=>({selector:Qe,port:this.getSubcircuit().selectOne(Qe,{type:"port"})})).filter(({port:Qe})=>Qe!=null).map(({port:Qe})=>({position:Qe._getGlobalSchematicPositionAfterLayout()}));if(j.length===0)return;let O=j.map(Qe=>Qe.position.x),V=j.map(Qe=>Qe.position.y),te=Math.min(...O),N=Math.max(...O),se=Math.min(...V),$=Math.max(...V),W=N-te,Q=$-se,le=W===0?s:0,z=Q===0?s:0,pe=f+le/2,xe=m+le/2,Ae=d+z/2,Ie=x+z/2,Le=te-pe,dt=N+xe,rt=se-Ie,et=$+Ae;E=dt-Le,A=et-rt,w=Le+(a.schX??0),B=rt+(a.schY??0),I=w+E/2,q=B+A/2}else if(b){E=a.width,A=a.height;let G=this._getGlobalSchematicPositionBeforeLayout();I=G.x,q=G.y,w=I-E/2,B=q-A/2}else return;if(e.schematic_box.insert({height:A,width:E,x:w,y:B,is_dashed:a.strokeStyle==="dashed"}),a.title){let G=a.titleInside,j=.1,O=a.titleAlignment,V=qXt({anchor:O,x:w,y:B,width:E,height:A,isInside:G}),te,N,se=V.textAnchor;G?(te=O.includes("top")?-j:O.includes("bottom")?j:0,N=O.includes("left")?j:O.includes("right")?-j:0):(te=O.includes("top")?j:O.includes("bottom")?-j:0,N=O.includes("center_left")?-j:O.includes("center_right")?j:0);let $=V.x+N,W=V.y+te;e.schematic_text.insert({anchor:se,text:a.title,font_size:a.titleFontSize??.18,color:a.titleColor??"#000000",position:{x:$,y:W},rotation:0})}}},m9e=class extends ga{constructor(){super(...arguments);X(this,"isSchematicPrimitive",!0);X(this,"schematic_table_id",null)}get config(){return{componentName:"SchematicTable",zodProps:fAe}}doInitialSchematicPrimitiveRender(){if(this.root?.schematicDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,s=this.children.filter(A=>A.componentName==="SchematicRow");if(s.length===0)return;let l=[],d=0;for(let A of s){let w=A.children.filter(B=>B.componentName==="SchematicCell");d=Math.max(d,w.length)}for(let A=0;A<s.length;A++)l[A]=[];for(let A=0;A<s.length;A++){let B=s[A].children.filter(q=>q.componentName==="SchematicCell"),I=0;for(let q=0;q<B.length;q++){for(;l[A][I];)I++;let G=B[q],j=G._parsedProps.colSpan??1,O=G._parsedProps.rowSpan??1;for(let V=0;V<O;V++)for(let te=0;te<j;te++)l[A+V]||(l[A+V]=[]),l[A+V][I+te]=G;I+=j}}d=Math.max(0,...l.map(A=>A.length));let x=s.map((A,w)=>A._parsedProps.height??1),f=Array.from({length:d},(A,w)=>{let B=0;for(let I=0;I<s.length;I++){let q=l[I]?.[w];if(q){let G=q._parsedProps.text??q._parsedProps.children,j=q._parsedProps.width??(G?.length??2)*.5;j>B&&(B=j)}}return B||10}),m=this._getGlobalSchematicPositionBeforeLayout(),y=e.schematic_table.insert({anchor_position:m,column_widths:f,row_heights:x,cell_padding:a.cellPadding,border_width:a.borderWidth,anchor:a.anchor,subcircuit_id:this.getSubcircuit()?.subcircuit_id||"",schematic_component_id:this.parent?.schematic_component_id||""});this.schematic_table_id=y.schematic_table_id;let b=new Set,E=0;for(let A=0;A<s.length;A++){let w=0;for(let B=0;B<d;B++){let I=l[A]?.[B];if(I&&!b.has(I)){b.add(I);let q=I._parsedProps,G=q.rowSpan??1,j=q.colSpan??1,O=0;for(let te=0;te<j;te++)O+=f[B+te];let V=0;for(let te=0;te<G;te++)V+=x[A+te];e.schematic_table_cell.insert({schematic_table_id:this.schematic_table_id,start_row_index:A,end_row_index:A+G-1,start_column_index:B,end_column_index:B+j-1,text:q.text??q.children,center:{x:m.x+w+O/2,y:m.y-E-V/2},width:O,height:V,horizontal_align:q.horizontalAlign,vertical_align:q.verticalAlign,font_size:q.fontSize??a.fontSize,subcircuit_id:this.getSubcircuit()?.subcircuit_id||""})}f[B]&&(w+=f[B])}E+=x[A]}}},g9e=class extends ga{constructor(){super(...arguments);X(this,"isSchematicPrimitive",!0)}get config(){return{componentName:"SchematicRow",zodProps:hAe}}},y9e=class extends ga{constructor(){super(...arguments);X(this,"isSchematicPrimitive",!0);X(this,"canHaveTextChildren",!0)}get config(){return{componentName:"SchematicCell",zodProps:mAe}}},UXt={name:"@tscircuit/core",type:"module",version:"0.0.671",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"'},devDependencies:{"@biomejs/biome":"^1.8.3","@tscircuit/capacity-autorouter":"^0.0.100","@tscircuit/checks":"^0.0.71","@tscircuit/circuit-json-util":"^0.0.65","@tscircuit/footprinter":"^0.0.208","@tscircuit/import-snippet":"^0.0.4","@tscircuit/infgrid-ijump-astar":"^0.0.33","@tscircuit/log-soup":"^1.0.2","@tscircuit/matchpack":"^0.0.9","@tscircuit/math-utils":"^0.0.18","@tscircuit/miniflex":"^0.0.4","@tscircuit/props":"0.0.289","@tscircuit/schematic-autolayout":"^0.0.6","@tscircuit/schematic-match-adapt":"^0.0.16","@tscircuit/schematic-trace-solver":"^0.0.23","@tscircuit/simple-3d-svg":"^0.0.38","@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.9","chokidar-cli":"^3.0.0","circuit-json":"^0.0.236","circuit-json-to-bpc":"^0.0.13","circuit-json-to-connectivity-map":"^0.0.22","circuit-json-to-simple-3d":"^0.0.6","circuit-to-svg":"^0.0.174",concurrently:"^9.1.2","connectivity-map":"^1.0.0",debug:"^4.3.6","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",react:"^19.1.0","react-dom":"^19.1.0","schematic-symbols":"^0.0.195","ts-expect":"^1.3.0",tsup:"^8.2.4"},peerDependencies:{"@tscircuit/capacity-autorouter":"*","@tscircuit/checks":"*","@tscircuit/circuit-json-util":"*","@tscircuit/footprinter":"*","@tscircuit/infgrid-ijump-astar":"*","@tscircuit/math-utils":"*","@tscircuit/props":"*","@tscircuit/schematic-autolayout":"*","@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.29","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"}},qg=class{constructor({platform:n,projectUrl:e}={}){X(this,"firstChild",null);X(this,"children");X(this,"db");X(this,"root",null);X(this,"isRoot",!0);X(this,"schematicDisabled",!1);X(this,"pcbDisabled",!1);X(this,"pcbRoutingDisabled",!1);X(this,"_featureMspSchematicTraceRouting",!0);X(this,"name");X(this,"platform");X(this,"projectUrl");X(this,"_hasRenderedAtleastOnce",!1);X(this,"_eventListeners",{});this.children=[],this.db=ua([]),this.root=this,this.platform=n,this.projectUrl=e,this.pcbDisabled=n?.pcbDisabled??!1}add(n){let e;(0,D9e.isValidElement)(n)?e=bwe(n):e=n,this.children.push(e)}_getBoard(){return this.children.find(n=>n.componentName==="Board")}_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(...))");if(this.children.length===1&&this.children[0].isGroup){this.firstChild=this.children[0];return}let n=new zg({subcircuit:!0});n.parent=this,n.addAll(this.children),this.children=[n],this.firstChild=n}render(){this.firstChild||this._guessRootComponent();let{firstChild:n,db:e}=this;if(!n)throw new Error("RootCircuit has no root component");n.parent=this,n.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(e=>setTimeout(e,100)),this.render();this.emit("renderComplete")}_hasIncompleteAsyncEffects(){return this.children.some(n=>n._hasIncompleteAsyncEffects()?!0:n.children.some(e=>e._hasIncompleteAsyncEffects()))}getCircuitJson(){return this._hasRenderedAtleastOnce||this.render(),this.db.toArray()}toJson(){return this.getCircuitJson()}async getSvg(n){let e=await Promise.resolve().then(()=>(HSe(),YSe)).catch(a=>{throw new Error(`To use circuit.getSvg, you must install the "circuit-to-svg" package.
1077
+ ${s.stack}`),a.complete=!0,"root"in this&&this.root&&this.root.emit("asyncEffect:end",{effectName:n,componentDisplayName:this.getString(),phase:a.phase,error:s.toString()})})}_emitRenderLifecycleEvent(n,e){GVt(`${n}:${e} ${this.getString()}`);let a=`renderable:renderLifecycle:${n}:${e}`,s={renderId:this._renderId,componentDisplayName:this.getString(),type:a};"root"in this&&this.root&&(this.root.emit(a,s),this.root.emit("renderable:renderLifecycle:anyEvent",{...s,type:a}))}getString(){return this.constructor.name}_hasIncompleteAsyncEffects(){return this._asyncEffects.some(n=>!n.complete)}getCurrentRenderPhase(){return this._currentRenderPhase}getRenderGraph(){return{id:this._renderId,currentPhase:this._currentRenderPhase,renderPhaseStates:this.renderPhaseStates,shouldBeRemoved:this.shouldBeRemoved,children:this.children.map(n=>n.getRenderGraph())}}runRenderCycle(){for(let n of ud)this.runRenderPhaseForChildren(n),this.runRenderPhase(n)}runRenderPhase(n){this._currentRenderPhase=n;let e=this.renderPhaseStates[n],a=e.initialized,s=e.dirty;if(!a&&this.shouldBeRemoved)return;if(this.shouldBeRemoved&&a){this._emitRenderLifecycleEvent(n,"start"),this?.[`remove${n}`]?.(),e.initialized=!1,e.dirty=!1,this._emitRenderLifecycleEvent(n,"end");return}let l=ud.indexOf(n)-1;if(l>=0){let d=ud[l];if(this._asyncEffects.filter(f=>f.phase===d).some(f=>!f.complete))return}if(this._emitRenderLifecycleEvent(n,"start"),a){s&&(this?.[`update${n}`]?.(),e.dirty=!1),this._emitRenderLifecycleEvent(n,"end");return}e.dirty=!1,this?.[`doInitial${n}`]?.(),e.initialized=!0,this._emitRenderLifecycleEvent(n,"end")}runRenderPhaseForChildren(n){for(let e of this.children)e.runRenderPhaseForChildren(n),e.runRenderPhase(n)}renderError(n){throw typeof n=="string"?new Error(n):new Error(JSON.stringify(n,null,2))}},LS={},Dwe=n=>{let e=Object.fromEntries(Object.entries(n).map(([a,s])=>[a.toLowerCase(),s]));Object.assign(LS,n),Object.assign(LS,e)},YVt=class extends Error{constructor(n,e,a){let s,l=Object.keys(a).filter(m=>m!=="_errors"),d=[],x=e.pinLabels;if(x)for(let[m,y]of Object.entries(x)){let b=Array.isArray(y)?y:[y];for(let E of b)typeof E=="string"&&(E.startsWith(" ")||E.endsWith(" "))&&d.push(`pinLabels.${m} ("${E}" has leading or trailing spaces)`)}let f=l.map(m=>m==="pinLabels"&&d.length>0?d.join(", "):a[m]._errors[0]?`${m} (${a[m]._errors[0]})`:`${m} (${JSON.stringify(a[m])})`).join(", ");"name"in e?s=`Invalid props for ${n} "${e.name}": ${f}`:"footprint"in e&&typeof e.footprint=="string"?s=`Invalid props for ${n} (unnamed ${e.footprint} component): ${f}`:s=`Invalid props for ${n} (unnamed): ${f}`,super(s),this.componentName=n,this.originalProps=e,this.formattedError=a}};function SW(n,e){let a=e.match(/^#(\w+)/);if(a)return n.props.id===a[1];let s=e.match(/^\.(\w+)/);if(s)return n.isMatchingNameOrAlias(s[1]);let[l,...d]=e.split(/(?=[#.[])/);return l==="pin"&&(l="port"),l&&l!=="*"&&n.lowercaseComponentName!==l.toLowerCase()?!1:d.every(x=>{if(x.startsWith("#"))return n.props.id===x.slice(1);if(x.startsWith("."))return n.isMatchingNameOrAlias(x.slice(1));let f=x.match(/\[(\w+)=['"]?(.+?)['"]?\]/);if(!f)return!0;let[,m,y]=f;return n.props[m].toString()===y})}var LW={isTag:n=>!0,getParent:n=>n.parent,getChildren:n=>n.children,getName:n=>n.lowercaseComponentName,getAttributeValue:(n,e)=>{if(e==="class"&&"getNameAndAliases"in n)return n.getNameAndAliases().join(" ");if(e==="name"&&n._parsedProps?.name)return n._parsedProps.name;if(n._parsedProps&&e in n._parsedProps){let a=n._parsedProps[e];return typeof a=="string"?a:a!=null?String(a):null}return null},hasAttrib:(n,e)=>e==="class"?!!n._parsedProps?.name:n._parsedProps&&e in n._parsedProps,getSiblings:n=>n.parent?n.parent.children:[],prevElementSibling:n=>{if(!n.parent)return null;let e=n.parent.children,a=e.indexOf(n);return a>0?e[a-1]:null},getText:()=>"",removeSubsets:n=>n.filter((e,a)=>!n.some((s,l)=>a!==l&&s!==e&&s.getDescendants().includes(e))),existsOne:(n,e)=>e.some(n),findAll:(n,e)=>{let a=[],s=l=>{n(l)&&a.push(l);for(let d of l.children)s(d)};for(let l of e)s(l);return a},findOne:(n,e)=>{for(let a of e){if(n(a))return a;let s=a.children;if(s.length>0){let l=LW.findOne(n,s);if(l)return l}}return null},equals:(n,e)=>n._renderId===e._renderId,isHovered:n=>!1,isVisited:n=>!1,isActive:n=>!1},HVt={...LW,getChildren:n=>n.children.filter(e=>!e.isSubcircuit)},WSe={...LW,getChildren:n=>n.children.filter(e=>e.isSubcircuit)},KSe=n=>{if(/net\.[^\s>]*\./.test(n))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(n))throw new Error('Net names cannot contain "+" or "-", try using underscores instead, e.g. VCC_P');if(/net\.[0-9]/.test(n)){let e=n.match(/net\.([^ >]+)/),a=e?e[1]:"";throw new Error(`Net name "${a}" cannot start with a number, try using a prefix like "VBUS1"`)}return n.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,(e,a,s,l)=>{let d=/^\d+$/.test(l)?`pin${l}`:l;return`${a}.${s} > .${d}`}).trim()},wW={adapter:HVt,cacheResults:!0},ga=class extends OW{constructor(e){super(e);X(this,"parent",null);X(this,"children");X(this,"childrenPendingRemoval");X(this,"props");X(this,"_parsedProps");X(this,"externallyAddedAliases");X(this,"isPrimitiveContainer",!1);X(this,"canHaveTextChildren",!1);X(this,"source_group_id",null);X(this,"source_component_id",null);X(this,"schematic_component_id",null);X(this,"pcb_component_id",null);X(this,"cad_component_id",null);X(this,"fallbackUnassignedName");X(this,"_cachedSelectAllQueries",new Map);X(this,"_cachedSelectOneQueries",new Map);this.children=[],this.childrenPendingRemoval=[],this.props=e??{},this.externallyAddedAliases=[];let s=("partial"in this.config.zodProps?this.config.zodProps.partial({name:!0}):this.config.zodProps).safeParse(e??{});if(s.success)this._parsedProps=s.data;else throw new YVt(this.lowercaseComponentName,this.props,s.error.format())}get config(){return{componentName:"",zodProps:C.object({}).passthrough()}}get componentName(){return this.config.componentName}getInheritedProperty(e){let a=this;for(;a;){if(a._parsedProps&&e in a._parsedProps)return a._parsedProps[e];a=a.parent}if(this.root?.platform&&e in this.root.platform)return this.root.platform[e]}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(e){let a=this.config.zodProps.parse({...this.props,...e}),s=this.props;this.props=a,this._parsedProps=this.config.zodProps.parse(e),this.onPropsChange({oldProps:s,newProps:a,changedProps:Object.keys(e)}),this.parent?.onChildChanged?.(this)}computePcbPropsTransform(){let{_parsedProps:e}=this;return Bs(ja(e.pcbX??0,e.pcbY??0),Kf((e.pcbRotation??0)*Math.PI/180))}_computePcbGlobalTransformBeforeLayout(){let{_parsedProps:e}=this,a=this.getSubcircuit()._getPcbManualPlacementForComponent(this);if(a&&this.props.pcbX===void 0&&this.props.pcbY===void 0)return Bs(this.parent?._computePcbGlobalTransformBeforeLayout()??go(),Bs(ja(a.x,a.y),Kf((e.pcbRotation??0)*Math.PI/180)));if(this.isPcbPrimitive){let s=this.getPrimitiveContainer();if(s){let l=s._parsedProps.layer==="bottom",d=s._getGlobalPcbPositionBeforeLayout();if(l){let x=Bs(ja(d.x,d.y),$q(),ja(-d.x,-d.y));return Bs(this.parent?._computePcbGlobalTransformBeforeLayout()??go(),$q(),this.computePcbPropsTransform())}}}return Bs(this.parent?._computePcbGlobalTransformBeforeLayout()??go(),this.computePcbPropsTransform())}getPrimitiveContainer(){return this.isPrimitiveContainer?this:this.parent?.getPrimitiveContainer?.()??null}_getPcbCircuitJsonBounds(){return{center:{x:0,y:0},bounds:{left:0,top:0,right:0,bottom:0},width:0,height:0}}_getPcbPrimitiveFlippedHelpers(){let e=this.getPrimitiveContainer(),a=e?e._parsedProps.layer==="bottom":!1;return{isFlipped:a,maybeFlipLayer:l=>a?l==="top"?"bottom":"top":l}}_setPositionFromLayout(e){throw new Error(`_setPositionFromLayout not implemented for ${this.componentName}`)}computeSchematicPropsTransform(){let{_parsedProps:e}=this;return Bs(ja(e.schX??0,e.schY??0))}computeSchematicGlobalTransform(){let e=this._getSchematicGlobalManualPlacementTransform(this);return e||Bs(this.parent?.computeSchematicGlobalTransform?.()??go(),this.computeSchematicPropsTransform())}_getSchematicSymbolName(){let{_parsedProps:e}=this,a=this.config.schematicSymbolName,s={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},l=e.schOrientation!==void 0?s[e.schOrientation]:e.schRotation;if(l===void 0&&(l=0),l=l%360,l<0&&(l+=360),e.schRotation!==void 0&&l%90!==0)throw new Error(`Schematic rotation ${e.schRotation} is not supported for ${this.componentName}`);let d=`${a}_horz`,x=`${a}_vert`,f=`${a}_up`,m=`${a}_down`,y=`${a}_left`,b=`${a}_right`;if(b in Ts&&l===0)return b;if(f in Ts&&l===90)return f;if(y in Ts&&l===180)return y;if(m in Ts&&l===270)return m;if(d in Ts&&(l===0||l===180))return d;if(x in Ts&&(l===90||l===270))return x;if(a in Ts)return a}_getSchematicSymbolNameOrThrow(){let e=this._getSchematicSymbolName();if(!e)throw new Error(`No schematic symbol found (given: "${this.config.schematicSymbolName}")`);return e}getSchematicSymbol(){let e=this._getSchematicSymbolName();return e?Ts[e]??null:null}_getPcbManualPlacementForComponent(e){if(!this.isSubcircuit)return null;let a=this.props.manualEdits;if(!a)return null;let s=a?.pcb_placements;if(!s)return null;for(let l of s)if(SW(e,l.selector)||e.props.name===l.selector)return vs(this._computePcbGlobalTransformBeforeLayout(),l.center);return null}_getSchematicManualPlacementForComponent(e){if(!this.isSubcircuit)return null;let a=this.props.manualEdits;if(!a)return null;let s=a.schematic_placements;if(!s)return null;for(let l of s)if(SW(e,l.selector)||e.props.name===l.selector)return vs(this.computeSchematicGlobalTransform(),l.center);return null}_getSchematicGlobalManualPlacementTransform(e){let a=this.getSubcircuit()?._parsedProps.manualEdits;if(!a)return null;for(let s of a.schematic_placements??[])if((SW(e,s.selector)||e.props.name===s.selector)&&s.relative_to==="group_center")return Bs(this.parent?._computePcbGlobalTransformBeforeLayout()??go(),ja(s.center.x,s.center.y));return null}_getGlobalPcbPositionBeforeLayout(){return vs(this._computePcbGlobalTransformBeforeLayout(),{x:0,y:0})}_getGlobalSchematicPositionBeforeLayout(){return vs(this.computeSchematicGlobalTransform(),{x:0,y:0})}get root(){return this.parent?.root??null}onAddToParent(e){this.parent=e}onPropsChange(e){}onChildChanged(e){this.parent?.onChildChanged?.(e)}add(e){let a=e.__text;if(typeof a=="string"){if(this.canHaveTextChildren||a.trim()==="")return;throw new Error(`Invalid JSX Element: Expected a React component but received text "${a}"`)}if(Object.keys(e).length!==0){if(this.lowercaseComponentName==="board"&&e.lowercaseComponentName==="board")throw new Error("Nested boards are not supported");if(!e.onAddToParent)throw new Error(`Invalid JSX Element: Expected a React component but received "${JSON.stringify(e)}"`);e.onAddToParent(this),e.parent=this,this.children.push(e)}}addAll(e){for(let a of e)this.add(a)}remove(e){this.children=this.children.filter(a=>a!==e),this.childrenPendingRemoval.push(e),e.shouldBeRemoved=!0}getSubcircuitSelector(){let e=this.name,a=e?`${this.lowercaseComponentName}.${e}`:this.lowercaseComponentName;return!this.parent||this.parent.isSubcircuit?a:`${this.parent.getSubcircuitSelector()} > ${a}`}getFullPathSelector(){let e=this.name,a=e?`${this.lowercaseComponentName}.${e}`:this.lowercaseComponentName,s=this.parent?.getFullPathSelector?.();return s?`${s} > ${a}`:a}getNameAndAliases(){return[this.name,...this._parsedProps.portHints??[]].filter(Boolean)}isMatchingNameOrAlias(e){return this.getNameAndAliases().includes(e)}isMatchingAnyOf(e){return this.getNameAndAliases().some(a=>e.map(s=>s.toString()).includes(a))}getPcbSize(){throw new Error(`getPcbSize not implemented for ${this.componentName}`)}doesSelectorMatch(e){let a=[this.componentName,this.lowercaseComponentName],s=[this.name].filter(Boolean),l=e.trim().split(/\> /)[0],d=l[0];return l.length>1?!1:!!(e==="*"||e[0]==="#"&&e.slice(1)===this.props.id||e[0]==="."&&s.includes(e.slice(1))||/^[a-zA-Z0-9_]/.test(d)&&a.includes(d))}getSubcircuit(){if(this.isSubcircuit)return this;let e=this.parent?.getSubcircuit?.();if(!e)throw new Error("Component is not inside an opaque group (no board?)");return e}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 e=this.selectAll("port");for(let a of e){let s=a.parent?.getNameAndAliases(),l=a.getNameAndAliases();if(s)for(let d of s)for(let x of l){let f=[`.${d} > .${x}`,`.${d} .${x}`];for(let m of f){let y=this._cachedSelectAllQueries.get(m);y?y.push(a):this._cachedSelectAllQueries.set(m,[a])}}}for(let[a,s]of this._cachedSelectAllQueries.entries())s.length===1&&this._cachedSelectOneQueries.set(a,s[0])}selectAll(e){if(this._cachedSelectAllQueries.has(e))return this._cachedSelectAllQueries.get(e);let a=KSe(e),s=JX(a,this,wW);if(s.length>0)return this._cachedSelectAllQueries.set(e,s),s;let[l,...d]=a.split(" "),x=XR(l,this,{adapter:WSe});if(!x)return[];let f=x.selectAll(d.join(" "));return this._cachedSelectAllQueries.set(e,f),f}selectOne(e,a){if(this._cachedSelectOneQueries.has(e))return this._cachedSelectOneQueries.get(e);let s=KSe(e);a?.port&&(a.type="port");let l=null;if(a?.type&&(l=JX(s,this,wW).find(y=>y.lowercaseComponentName===a.type)),l??(l=XR(s,this,wW)),l)return this._cachedSelectOneQueries.set(e,l),l;let[d,...x]=s.split(" "),f=XR(d,this,{adapter:WSe});return f?(l=f.selectOne(x.join(" "),a),this._cachedSelectOneQueries.set(e,l),l):null}getAvailablePcbLayers(){if(this.isPcbPrimitive){let{maybeFlipLayer:e}=this._getPcbPrimitiveFlippedHelpers();return"layer"in this._parsedProps||this.componentName==="SmtPad"?[e(this._parsedProps.layer??"top")]:"layers"in this._parsedProps?this._parsedProps.layers:this.componentName==="PlatedHole"?this.root?._getBoard()?.allLayers??["top","bottom"]:[]}return[]}getDescendants(){let e=[];for(let a of this.children)e.push(a),e.push(...a.getDescendants());return e}getSelectableDescendants(){let e=[];for(let a of this.children)a.isSubcircuit?e.push(a):(e.push(a),e.push(...a.getSelectableDescendants()));return e}_getPinCount(){return 0}_getSchematicBoxDimensions(){return null}_getSchematicBoxComponentDimensions(){if(this.getSchematicSymbol()||!this.config.shouldRenderAsSchematicBox)return null;let{_parsedProps:e}=this;return{schWidth:e.schWidth,schHeight:e.schHeight}}renderError(e){if(typeof e=="string")return super.renderError(e);this.root?.db.pcb_placement_error.insert(e)}getString(){let{lowercaseComponentName:e,_parsedProps:a,parent:s}=this;return a?.pinNumber!==void 0&&s?.props?.name&&a?.name?`<${e}#${this._renderId}(pin:${a.pinNumber} .${s?.props.name}>.${a.name}) />`:s?.props?.name&&a?.name?`<${e}#${this._renderId}(.${s?.props.name}>.${a?.name}) />`:a?.from&&a?.to?`<${e}#${this._renderId}(from:${a.from} to:${a?.to}) />`:a?.name?`<${e}#${this._renderId} name=".${a?.name}" />`:a?.portHints?`<${e}#${this._renderId}(${a.portHints.map(l=>`.${l}`).join(", ")}) />`:`<${e}#${this._renderId} />`}get[Symbol.toStringTag](){return this.getString()}[Symbol.for("nodejs.util.inspect.custom")](){return this.getString()}},WVt=class extends ga{constructor(n,e){super(n),this._parsedProps={...n,error:e,type:n.type||"unknown",component_name:n.name,error_type:"source_failed_to_create_component_error",message:e instanceof Error?e.message:String(e),pcbX:n.pcbX,pcbY:n.pcbY,schX:n.schX,schY:n.schY}}get config(){return{componentName:"ErrorPlaceholder",zodProps:C.object({}).passthrough()}}doInitialSourceRender(){if(this.root?.db){let n=this._getGlobalPcbPositionBeforeLayout(),e=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:n,schematic_center:e})}}};function KVt(n,e){return new WVt(n,e)}function JVt(n,e){let a=n;return a.__tsci={...e},n}var ZVt={supportsMutation:!0,createInstance(n,e){let a=LS[n];if(!a)throw Object.keys(LS).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 "${n}". 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 JVt(new a(e),{})}catch(s){return KVt({...e,componentType:n},s)}},createTextInstance(n){return{__text:n}},appendInitialChild(n,e){n.add(e)},appendChild(n,e){n.add(e)},appendChildToContainer(n,e){n.add(e)},finalizeInitialChildren(){return!1},prepareUpdate(){return null},shouldSetTextContent(){return!1},getRootHostContext(){return{}},getChildHostContext(){return{}},prepareForCommit(){return null},resetAfterCommit(){},commitMount(){},commitUpdate(){},removeChild(){},clearContainer(){},supportsPersistence:!1,getPublicInstance(n){return n},preparePortalMount(n){throw new Error("Function not implemented.")},scheduleTimeout(n,e){throw new Error("Function not implemented.")},cancelTimeout(n){throw new Error("Function not implemented.")},noTimeout:void 0,isPrimaryRenderer:!1,getInstanceFromNode(n){throw new Error("Function not implemented.")},beforeActiveInstanceBlur(){throw new Error("Function not implemented.")},afterActiveInstanceBlur(){throw new Error("Function not implemented.")},prepareScopeUpdate:(n,e)=>{throw new Error("Function not implemented.")},getInstanceFromScope:n=>{throw new Error("Function not implemented.")},detachDeletedInstance:n=>{throw new Error("Function not implemented.")},getCurrentEventPriority:()=>MS.DefaultEventPriority,getCurrentUpdatePriority:()=>MS.DefaultEventPriority,resolveUpdatePriority:()=>MS.DefaultEventPriority,setCurrentUpdatePriority:()=>{},maySuspendCommit:()=>!1,supportsHydration:!1},jS=(0,gwe.default)(ZVt),bwe=n=>{let e={children:[],props:{name:"$root"},add(d){d.parent=this,this.children.push(d)},computePcbGlobalTransform(){return go()}},a=[],s=jS.createContainer(e,0,null,!1,null,"tsci",d=>{console.log("Error in createContainer"),console.error(d),a.push(d)},null);if(jS.updateContainerSync(n,s,null,()=>{}),jS.flushSyncWork(),a.length>0)throw a[0];let l=jS.getPublicRootInstance(s);return l||e.children[0]},zF=(n,e)=>{if(typeof n=="number")return n;if(n.startsWith("pin"))return Number(n.slice(3));if(!e)throw new Error(`No pin labels provided and pin number or label is not a number: "${n}"`);for(let a in e)if((Array.isArray(e[a])?e[a]:[e[a]]).includes(n))return Number(a.replace("pin",""));throw new Error(`No pin labels provided and pin number or label is not a number: "${n}"`)},QVt=(n,e)=>{if(!n)return;let a={},s={};for(let[l,d]of Object.entries(n)){let x=zF(l,e);s[x]={...s[x],...d}}for(let[l,d]of Object.entries(s)){let x=`pin${l}`;a[x]={bottom_margin:d.bottomMargin,left_margin:d.leftMargin,right_margin:d.rightMargin,top_margin:d.topMargin}}return a},eGt=n=>{if(n){if("leftSide"in n||"rightSide"in n||"topSide"in n||"bottomSide"in n)return{left_side:n.leftSide,right_side:n.rightSide,top_side:n.topSide,bottom_side:n.bottomSide};if("leftPinCount"in n||"rightPinCount"in n||"topPinCount"in n||"bottomPinCount"in n)return{left_size:n.leftPinCount,right_size:n.rightPinCount,top_size:n.topPinCount,bottom_size:n.bottomPinCount};if("leftSize"in n||"rightSize"in n||"topSize"in n||"bottomSize"in n)return{left_size:n.leftSize,right_size:n.rightSize,top_size:n.topSize,bottom_size:n.bottomSize}}};function Fwe(n){let e=[];for(let a=0;a<n.length-1;a++)e.push([n[a],n[a+1]]);return e}var tGt=C.object({name:C.string().refine(n=>!/[+-]/.test(n),'Net names cannot contain "+" or "-", try using underscores instead, e.g. VCC_P')}),$W=class extends ga{constructor(){super(...arguments);X(this,"source_net_id")}get config(){return{componentName:"Net",zodProps:tGt}}getPortSelector(){return`net.${this.props.name}`}doInitialSourceRender(){let{db:e}=this.root,{_parsedProps:a}=this,s=e.source_net.insert({name:a.name,member_source_group_ids:[]});this.source_net_id=s.source_net_id}doInitialSourceParentAttachment(){let e=this.getSubcircuit();if(!e)return;let{db:a}=this.root;a.source_net.update(this.source_net_id,{subcircuit_id:e.subcircuit_id})}getAllConnectedPorts(){let e=this.getSubcircuit().selectAll("port"),a=[];for(let s of e){let l=s._getDirectlyConnectedTraces();for(let d of l)if(d._isExplicitlyConnectedToNet(this)){a.push(s);break}}return a}_getAllDirectlyConnectedTraces(){let e=this.getSubcircuit().selectAll("trace"),a=[];for(let s of e)s._isExplicitlyConnectedToNet(this)&&a.push(s);return a}doInitialPcbRouteNetIslands(){if(this.root?.pcbDisabled||this.getSubcircuit()._parsedProps.routingDisabled||this.getSubcircuit()._getAutorouterConfig().groupMode!=="sequential-trace")return;let{db:e}=this.root,{_parsedProps:a}=this,s=this._getAllDirectlyConnectedTraces().filter(x=>(x._portsRoutedOnPcb?.length??0)>0),l=[];for(let x of s){let f=x._portsRoutedOnPcb,m=l.find(y=>f.some(b=>y.ports.includes(b)));if(!m){l.push({ports:[...f],traces:[x]});continue}m.traces.push(x),m.ports.push(...f)}if(l.length===0)return;let d=Fwe(l);for(let[x,f]of d){let m=x.ports.map(G=>G._getGlobalPcbPositionBeforeLayout()),y=f.ports.map(G=>G._getGlobalPcbPositionBeforeLayout()),b=1/0,E=[-1,-1];for(let G=0;G<m.length;G++){let j=m[G];for(let O=0;O<y.length;O++){let V=y[O],te=Math.sqrt((j.x-V.x)**2+(j.y-V.y)**2);te<b&&(b=te,E=[G,O])}}let A=x.ports[E[0]],w=f.ports[E[1]],B=e.toArray().filter(G=>G.type==="pcb_smtpad"||G.type==="pcb_trace"||G.type==="pcb_plated_hole"||G.type==="pcb_hole"||G.type==="source_port"||G.type==="pcb_port"),{solution:I}=b8e(B.concat([{type:"source_trace",source_trace_id:"__net_trace_tmp",connected_source_port_ids:[A.source_port_id,w.source_port_id]}])),q=I[0];if(!q){this.renderError({pcb_trace_error_id:"",pcb_trace_id:"__net_trace_tmp",pcb_component_ids:[A.pcb_component_id,w.pcb_component_id].filter(Boolean),pcb_port_ids:[A.pcb_port_id,w.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}e.pcb_trace.insert(q)}}renderError(e){if(typeof e=="string")return super.renderError(e);this.root?.db.pcb_trace_error.insert(e)}},zW=(n,e)=>{for(let a of e)if(typeof a=="string"&&a.startsWith("net.")){if(/net\.[^\s>]*\./.test(a))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(a))throw new Error('Net names cannot contain "+" or "-", try using underscores instead, e.g. VCC_P');if(/net\.[0-9]/.test(a)){let l=a.split("net.")[1];throw new Error(`Net name "${l}" cannot start with a number, try using a prefix like "VBUS1"`)}let s=n.getSubcircuit();if(!s.selectOne(a)){let l=new $W({name:a.split("net.")[1]});s.add(l)}}},$S=class extends ga{constructor(){super(...arguments);X(this,"pcb_smtpad_id",null);X(this,"matchedPort",null);X(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SmtPad",zodProps:U8e}}getPcbSize(){let{_parsedProps:e}=this;if(e.shape==="circle")return{width:e.radius*2,height:e.radius*2};if(e.shape==="rect")return{width:e.width,height:e.height};if(e.shape==="polygon"){let a=e.points,s=a.map(y=>y.x),l=a.map(y=>y.y),d=Math.min(...s),x=Math.max(...s),f=Math.min(...l),m=Math.max(...l);return{width:x-d,height:m-f}}throw new Error(`getPcbSize for shape "${e.shape}" not implemented for ${this.componentName}`)}doInitialPortMatching(){let e=this.getPrimitiveContainer()?.selectAll("port");if(this.props.portHints){for(let a of e)if(a.isMatchingAnyOf(this.props.portHints)){this.matchedPort=a,a.registerMatch(this);return}}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this;if(!a.portHints)return;let s=this.getPrimitiveContainer(),l=this.getSubcircuit(),d=this._getGlobalPcbPositionBeforeLayout(),x=s?._getGlobalPcbPositionBeforeLayout(),f=e4(this._computePcbGlobalTransformBeforeLayout()),m=Math.abs(f.rotation.angle*(180/Math.PI)-90)%180<.01,{maybeFlipLayer:y}=this._getPcbPrimitiveFlippedHelpers(),b=s?._parsedProps.pcbRotation??0,E=null,A=this.parent?.pcb_component_id??this.getPrimitiveContainer()?.pcb_component_id;a.shape==="circle"?(E=e.pcb_smtpad.insert({pcb_component_id:A,pcb_port_id:this.matchedPort?.pcb_port_id,layer:y(a.layer??"top"),shape:"circle",radius:a.radius,port_hints:a.portHints.map(w=>w.toString()),x:d.x,y:d.y,subcircuit_id:l?.subcircuit_id??void 0}),e.pcb_solder_paste.insert({layer:E.layer,shape:"circle",radius:E.radius*.7,x:E.x,y:E.y,pcb_component_id:E.pcb_component_id,pcb_smtpad_id:E.pcb_smtpad_id,subcircuit_id:l?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0})):a.shape==="rect"?(E=b===0||m?e.pcb_smtpad.insert({pcb_component_id:A,pcb_port_id:this.matchedPort?.pcb_port_id,layer:y(a.layer??"top"),shape:"rect",width:m?a.height:a.width,height:m?a.width:a.height,port_hints:a.portHints.map(w=>w.toString()),x:d.x,y:d.y,subcircuit_id:l?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0}):e.pcb_smtpad.insert({pcb_component_id:A,layer:y(a.layer??"top"),shape:"rotated_rect",width:a.width,height:a.height,x:d.x,y:d.y,ccw_rotation:b,port_hints:a.portHints.map(w=>w.toString()),subcircuit_id:l?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0}),E.shape==="rect"&&e.pcb_solder_paste.insert({layer:y(a.layer??"top"),shape:"rect",width:E.width*.7,height:E.height*.7,x:E.x,y:E.y,pcb_component_id:E.pcb_component_id,pcb_smtpad_id:E.pcb_smtpad_id,subcircuit_id:l?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0}),E.shape==="rotated_rect"&&e.pcb_solder_paste.insert({layer:y(a.layer??"top"),shape:"rotated_rect",width:E.width*.7,height:E.height*.7,x:E.x,y:E.y,ccw_rotation:b,pcb_component_id:E.pcb_component_id,pcb_smtpad_id:E.pcb_smtpad_id,subcircuit_id:l?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0})):a.shape==="polygon"&&(E=e.pcb_smtpad.insert({pcb_component_id:A,pcb_port_id:this.matchedPort?.pcb_port_id,layer:y(a.layer??"top"),shape:"polygon",points:a.points.map(w=>({x:w.x+d.x,y:w.y+d.y})),port_hints:a.portHints.map(w=>w.toString()),subcircuit_id:l?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0})),E&&(this.pcb_smtpad_id=E.pcb_smtpad_id)}doInitialPcbPortAttachment(){if(this.root?.pcbDisabled)return;let{db:e}=this.root;e.pcb_smtpad.update(this.pcb_smtpad_id,{pcb_port_id:this.matchedPort?.pcb_port_id})}_getPcbCircuitJsonBounds(){let{db:e}=this.root,a=e.pcb_smtpad.get(this.pcb_smtpad_id);if(a.shape==="rect")return{center:{x:a.x,y:a.y},bounds:{left:a.x-a.width/2,top:a.y+a.height/2,right:a.x+a.width/2,bottom:a.y-a.height/2},width:a.width,height:a.height};if(a.shape==="rotated_rect"){let s=a.ccw_rotation*Math.PI/180,l=Math.cos(s),d=Math.sin(s),x=a.width/2,f=a.height/2,m=Math.abs(x*l)+Math.abs(f*d),y=Math.abs(x*d)+Math.abs(f*l);return{center:{x:a.x,y:a.y},bounds:{left:a.x-m,right:a.x+m,top:a.y-y,bottom:a.y+y},width:m*2,height:y*2}}if(a.shape==="circle")return{center:{x:a.x,y:a.y},bounds:{left:a.x-a.radius,top:a.y-a.radius,right:a.x+a.radius,bottom:a.y+a.radius},width:a.radius*2,height:a.radius*2};if(a.shape==="polygon"){let s=a.points,l=s.map(b=>b.x),d=s.map(b=>b.y),x=Math.min(...l),f=Math.max(...l),m=Math.min(...d),y=Math.max(...d);return{center:{x:(x+f)/2,y:(m+y)/2},bounds:{left:x,top:y,right:f,bottom:m},width:f-x,height:y-m}}throw new Error(`circuitJson bounds calculation not implemented for shape "${a.shape}"`)}_setPositionFromLayout(e){let{db:a}=this.root;a.pcb_smtpad.update(this.pcb_smtpad_id,{x:e.x,y:e.y});let s=a.pcb_solder_paste.list().find(l=>l.pcb_smtpad_id===this.pcb_smtpad_id);a.pcb_solder_paste.update(s?.pcb_solder_paste_id,{x:e.x,y:e.y}),this.matchedPort?._setPositionFromLayout(e)}},qW=class extends ga{constructor(){super(...arguments);X(this,"pcb_silkscreen_path_id",null);X(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenPath",zodProps:yAe}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,{maybeFlipLayer:s}=this._getPcbPrimitiveFlippedHelpers(),l=s(a.layer??"top");if(l!=="top"&&l!=="bottom")throw new Error(`Invalid layer "${l}" for SilkscreenPath. Must be "top" or "bottom".`);let d=this._computePcbGlobalTransformBeforeLayout(),x=this.getSubcircuit(),f=this.parent?.pcb_component_id??this.getPrimitiveContainer()?.pcb_component_id,m=e.pcb_silkscreen_path.insert({pcb_component_id:f,layer:l,route:a.route.map(y=>{let b=vs(d,{x:y.x,y:y.y});return{...y,x:b.x,y:b.y}}),stroke_width:a.strokeWidth??.1,subcircuit_id:x?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0});this.pcb_silkscreen_path_id=m.pcb_silkscreen_path_id}_setPositionFromLayout(e){let{db:a}=this.root,{_parsedProps:s}=this,l=a.pcb_silkscreen_path.get(this.pcb_silkscreen_path_id);if(!l)return;let d=0,x=0;for(let b of l.route)d+=b.x,x+=b.y;d/=l.route.length,x/=l.route.length;let f=e.x-d,m=e.y-x,y=l.route.map(b=>({...b,x:b.x+f,y:b.y+m}));a.pcb_silkscreen_path.update(this.pcb_silkscreen_path_id,{route:y})}getPcbSize(){let{_parsedProps:e}=this;if(!e.route||e.route.length===0)return{width:0,height:0};let a=1/0,s=-1/0,l=1/0,d=-1/0;for(let x of e.route)a=Math.min(a,x.x),s=Math.max(s,x.x),l=Math.min(l,x.y),d=Math.max(d,x.y);return{width:s-a,height:d-l}}},rGt=C.object({route:C.array(LA),source_trace_id:C.string().optional()}),UW=class extends ga{constructor(){super(...arguments);X(this,"pcb_trace_id",null);X(this,"isPcbPrimitive",!0)}get config(){return{componentName:"PcbTrace",zodProps:rGt}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,s=this.getPrimitiveContainer(),l=this.getSubcircuit(),{maybeFlipLayer:d}=this._getPcbPrimitiveFlippedHelpers(),x=this._computePcbGlobalTransformBeforeLayout(),f=a.route.map(y=>{let{x:b,y:E,...A}=y,w=vs(x,{x:b,y:E});return y.route_type==="wire"&&y.layer?{...w,...A,layer:d(y.layer)}:{...w,...A}}),m=e.pcb_trace.insert({pcb_component_id:s.pcb_component_id,source_trace_id:a.source_trace_id,route:f,subcircuit_id:l?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0});this.pcb_trace_id=m.pcb_trace_id}getPcbSize(){let{_parsedProps:e}=this;if(!e.route||e.route.length===0)return{width:0,height:0};let a=1/0,s=-1/0,l=1/0,d=-1/0;for(let x of e.route)a=Math.min(a,x.x),s=Math.max(s,x.x),l=Math.min(l,x.y),d=Math.max(d,x.y),x.route_type==="wire"&&(a=Math.min(a,x.x-x.width/2),s=Math.max(s,x.x+x.width/2),l=Math.min(l,x.y-x.width/2),d=Math.max(d,x.y+x.width/2));return a===1/0||s===-1/0||l===1/0||d===-1/0?{width:0,height:0}:{width:s-a,height:d-l}}},zS=class extends ga{constructor(){super(...arguments);X(this,"pcb_plated_hole_id",null);X(this,"matchedPort",null);X(this,"isPcbPrimitive",!0)}get config(){return{componentName:"PlatedHole",zodProps:I8e}}getAvailablePcbLayers(){return["top","inner1","inner2","bottom"]}getPcbSize(){let{_parsedProps:e}=this;if(e.shape==="circle")return{width:e.outerDiameter,height:e.outerDiameter};if(e.shape==="oval"||e.shape==="pill")return{width:e.outerWidth,height:e.outerHeight};if(e.shape==="circular_hole_with_rect_pad")return{width:e.rectPadWidth,height:e.rectPadHeight};if(e.shape==="pill_hole_with_rect_pad")return{width:e.rectPadWidth,height:e.rectPadHeight};throw new Error(`getPcbSize for shape "${e.shape}" not implemented for ${this.componentName}`)}_getPcbCircuitJsonBounds(){let{db:e}=this.root,a=e.pcb_plated_hole.get(this.pcb_plated_hole_id),s=this.getPcbSize();return{center:{x:a.x,y:a.y},bounds:{left:a.x-s.width/2,top:a.y+s.height/2,right:a.x+s.width/2,bottom:a.y-s.height/2},width:s.width,height:s.height}}_setPositionFromLayout(e){let{db:a}=this.root;a.pcb_plated_hole.update(this.pcb_plated_hole_id,{x:e.x,y:e.y}),this.matchedPort?._setPositionFromLayout(e)}doInitialPortMatching(){let e=this.getPrimitiveContainer()?.selectAll("port");if(this.props.portHints){for(let a of e)if(a.isMatchingAnyOf(this.props.portHints)){this.matchedPort=a,a.registerMatch(this);return}}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,s=this._getGlobalPcbPositionBeforeLayout(),l=this.parent?.pcb_component_id??this.getPrimitiveContainer()?.pcb_component_id,d=this.getSubcircuit();if(a.shape==="circle"){let x=e.pcb_plated_hole.insert({pcb_component_id:l,pcb_port_id:this.matchedPort?.pcb_port_id,outer_diameter:a.outerDiameter,hole_diameter:a.holeDiameter,shape:"circle",port_hints:this.getNameAndAliases(),x:s.x,y:s.y,layers:["top","bottom"],subcircuit_id:d?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0});this.pcb_plated_hole_id=x.pcb_plated_hole_id,e.pcb_solder_paste.insert({layer:"top",shape:"circle",radius:a.outerDiameter/2,x:s.x,y:s.y,subcircuit_id:d?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0}),e.pcb_solder_paste.insert({layer:"bottom",shape:"circle",radius:a.outerDiameter/2,x:s.x,y:s.y,subcircuit_id:d?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0})}else if(a.shape==="pill"&&a.rectPad){let x=e.pcb_plated_hole.insert({pcb_component_id:l,pcb_port_id:this.matchedPort?.pcb_port_id,outer_width:a.outerWidth,outer_height:a.outerHeight,hole_width:a.holeWidth,hole_height:a.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:s.x,y:s.y,layers:["top","bottom"],subcircuit_id:d?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0,hole_shape:"rotated_pill",pad_shape:"rect",hole_ccw_rotation:a.pcbRotation??0,rect_ccw_rotation:a.pcbRotation??0,rect_pad_width:a.outerWidth,rect_pad_height:a.outerHeight});this.pcb_plated_hole_id=x.pcb_plated_hole_id}else if(a.shape==="pill"||a.shape==="oval"){let x=e.pcb_plated_hole.insert({pcb_component_id:l,pcb_port_id:this.matchedPort?.pcb_port_id,outer_width:a.outerWidth,outer_height:a.outerHeight,hole_width:a.holeWidth,hole_height:a.holeHeight,shape:a.shape,port_hints:this.getNameAndAliases(),x:s.x,y:s.y,layers:["top","bottom"],subcircuit_id:d?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0});this.pcb_plated_hole_id=x.pcb_plated_hole_id,e.pcb_solder_paste.insert({layer:"top",shape:a.shape,width:a.outerWidth,height:a.outerHeight,x:s.x,y:s.y,subcircuit_id:d?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0}),e.pcb_solder_paste.insert({layer:"bottom",shape:a.shape,width:a.outerWidth,height:a.outerHeight,x:s.x,y:s.y,subcircuit_id:d?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0})}else if(a.shape==="circular_hole_with_rect_pad"){let x=e.pcb_plated_hole.insert({pcb_component_id:l,pcb_port_id:this.matchedPort?.pcb_port_id,hole_diameter:a.holeDiameter,rect_pad_width:a.rectPadWidth,rect_pad_height:a.rectPadHeight,shape:"circular_hole_with_rect_pad",port_hints:this.getNameAndAliases(),x:s.x,y:s.y,layers:["top","bottom"],subcircuit_id:d?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0});this.pcb_plated_hole_id=x.pcb_plated_hole_id}else if(a.shape==="pill_hole_with_rect_pad"){let x=e.pcb_plated_hole.insert({pcb_component_id:l,pcb_port_id:this.matchedPort?.pcb_port_id,hole_width:a.holeWidth,hole_height:a.holeHeight,rect_pad_width:a.rectPadWidth,rect_pad_height:a.rectPadHeight,shape:"pill_hole_with_rect_pad",port_hints:this.getNameAndAliases(),x:s.x,y:s.y,layers:["top","bottom"],subcircuit_id:d?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0});this.pcb_plated_hole_id=x.pcb_plated_hole_id}}doInitialPcbPortAttachment(){if(this.root?.pcbDisabled)return;let{db:e}=this.root;e.pcb_plated_hole.update(this.pcb_plated_hole_id,{pcb_port_id:this.matchedPort?.pcb_port_id})}},qS=class extends ga{constructor(){super(...arguments);X(this,"pcb_keepout_id",null);X(this,"isPcbPrimitive",!0)}get config(){return{componentName:"Keepout",zodProps:lAe}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let e=this.getSubcircuit(),{db:a}=this.root,{_parsedProps:s}=this,l=this._getGlobalPcbPositionBeforeLayout(),d=e4(this._computePcbGlobalTransformBeforeLayout()),x=Math.abs(d.rotation.angle*(180/Math.PI)-90)%180<.01,f=null;s.shape==="circle"?f=a.pcb_keepout.insert({layers:["top"],shape:"circle",radius:s.radius,center:{x:l.x,y:l.y},subcircuit_id:e?.subcircuit_id??void 0,pcb_group_id:e?.getGroup()?.pcb_group_id??void 0}):s.shape==="rect"&&(f=a.pcb_keepout.insert({layers:["top"],shape:"rect",...x?{width:s.height,height:s.width}:{width:s.width,height:s.height},center:{x:l.x,y:l.y},subcircuit_id:e?.subcircuit_id??void 0,pcb_group_id:e?.getGroup()?.pcb_group_id??void 0})),f&&(this.pcb_keepout_id=f.pcb_keepout_id)}},VW=class extends ga{constructor(){super(...arguments);X(this,"pcb_hole_id",null);X(this,"isPcbPrimitive",!0)}get config(){return{componentName:"Hole",zodProps:V8e}}getPcbSize(){let{_parsedProps:e}=this;return{width:e.diameter,height:e.diameter}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,s=this.getSubcircuit(),l=this._getGlobalPcbPositionBeforeLayout(),d=e.pcb_hole.insert({hole_shape:"circle",hole_diameter:a.diameter,x:l.x,y:l.y,subcircuit_id:s?.subcircuit_id??void 0,pcb_group_id:s?.getGroup()?.pcb_group_id??void 0});this.pcb_hole_id=d.pcb_hole_id}_getPcbCircuitJsonBounds(){let{db:e}=this.root,a=e.pcb_hole.get(this.pcb_hole_id),s=this.getPcbSize();return{center:{x:a.x,y:a.y},bounds:{left:a.x-s.width/2,top:a.y-s.height/2,right:a.x+s.width/2,bottom:a.y+s.height/2},width:s.width,height:s.height}}_setPositionFromLayout(e){let{db:a}=this.root;a.pcb_hole.update(this.pcb_hole_id,{x:e.x,y:e.y})}},XS=class extends ga{constructor(){super(...arguments);X(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenText",zodProps:gAe}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,s=this.getPrimitiveContainer(),l=this._getGlobalPcbPositionBeforeLayout(),{maybeFlipLayer:d}=this._getPcbPrimitiveFlippedHelpers(),x=this.getSubcircuit(),f=new Set(a.layers);a.layer&&f.add(a.layer);let m=f.size>0?Array.from(f):["top"];for(let y of m)e.pcb_silkscreen_text.insert({anchor_alignment:a.anchorAlignment,anchor_position:{x:l.x,y:l.y},font:a.font??"tscircuit2024",font_size:a.fontSize??1,layer:d(y),text:a.text??"",ccw_rotation:a.pcbRotation,pcb_component_id:s.pcb_component_id,subcircuit_id:x?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0})}getPcbSize(){let{_parsedProps:e}=this,a=e.fontSize??1,l=(e.text??"").length*a,d=a;return{width:l*a,height:d*a}}},$F=class extends ga{constructor(){super(...arguments);X(this,"pcb_cutout_id",null);X(this,"isPcbPrimitive",!0)}get config(){return{componentName:"Cutout",zodProps:q8e}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,s=this.getSubcircuit(),l=this.getGroup()?.pcb_group_id??void 0,d=this._getGlobalPcbPositionBeforeLayout(),f=this.getPrimitiveContainer()?._parsedProps.pcbRotation??0,m;if(a.shape==="rect"){let y=typeof f=="string"?parseInt(f.replace("deg",""),10):f,b=Math.abs(y%180)===90,E={shape:"rect",center:d,width:b?a.height:a.width,height:b?a.width:a.height,subcircuit_id:s?.subcircuit_id??void 0,pcb_group_id:l};m=e.pcb_cutout.insert(E)}else if(a.shape==="circle"){let y={shape:"circle",center:d,radius:a.radius,subcircuit_id:s?.subcircuit_id??void 0,pcb_group_id:l};m=e.pcb_cutout.insert(y)}else if(a.shape==="polygon"){let y=this._computePcbGlobalTransformBeforeLayout(),E={shape:"polygon",points:a.points.map(A=>vs(y,A)),subcircuit_id:s?.subcircuit_id??void 0,pcb_group_id:l};m=e.pcb_cutout.insert(E)}m&&(this.pcb_cutout_id=m.pcb_cutout_id)}getPcbSize(){let{_parsedProps:e}=this;if(e.shape==="rect")return{width:e.width,height:e.height};if(e.shape==="circle")return{width:e.radius*2,height:e.radius*2};if(e.shape==="polygon"){if(e.points.length===0)return{width:0,height:0};let a=1/0,s=-1/0,l=1/0,d=-1/0;for(let x of e.points)a=Math.min(a,x.x),s=Math.max(s,x.x),l=Math.min(l,x.y),d=Math.max(d,x.y);return{width:s-a,height:d-l}}return{width:0,height:0}}_getPcbCircuitJsonBounds(){if(!this.pcb_cutout_id)return super._getPcbCircuitJsonBounds();let{db:e}=this.root,a=e.pcb_cutout.get(this.pcb_cutout_id);if(!a)return super._getPcbCircuitJsonBounds();if(a.shape==="rect")return{center:a.center,bounds:{left:a.center.x-a.width/2,top:a.center.y+a.height/2,right:a.center.x+a.width/2,bottom:a.center.y-a.height/2},width:a.width,height:a.height};if(a.shape==="circle")return{center:a.center,bounds:{left:a.center.x-a.radius,top:a.center.y+a.radius,right:a.center.x+a.radius,bottom:a.center.y-a.radius},width:a.radius*2,height:a.radius*2};if(a.shape==="polygon"){if(a.points.length===0)return super._getPcbCircuitJsonBounds();let s=1/0,l=-1/0,d=1/0,x=-1/0;for(let f of a.points)s=Math.min(s,f.x),l=Math.max(l,f.x),d=Math.min(d,f.y),x=Math.max(x,f.y);return{center:{x:(s+l)/2,y:(d+x)/2},bounds:{left:s,top:x,right:l,bottom:d},width:l-s,height:x-d}}return super._getPcbCircuitJsonBounds()}_setPositionFromLayout(e){if(!this.pcb_cutout_id)return;let{db:a}=this.root,s=a.pcb_cutout.get(this.pcb_cutout_id);if(s){if(s.shape==="rect"||s.shape==="circle")a.pcb_cutout.update(this.pcb_cutout_id,{...s,center:e});else if(s.shape==="polygon"){let l=this._getPcbCircuitJsonBounds().center,d=e.x-l.x,x=e.y-l.y,f=s.points.map(m=>({x:m.x+d,y:m.y+x}));a.pcb_cutout.update(this.pcb_cutout_id,{...s,points:f})}}}},nGt=({elm:n,pinLabels:e,layer:a,readableRotation:s,anchorAlignment:l})=>{let d=n.text.replace(/[{}]/g,"").toLowerCase(),x=d;if(Array.isArray(e)){let f=parseInt(d.replace(/[^\d]/g,""),10)-1;x=String(e[f]??d)}else typeof e=="object"&&(x=String(e[d]??d));return new XS({anchorAlignment:l||"center",text:x??d,layer:a||"top",fontSize:n.font_size+.2,pcbX:isNaN(n.anchor_position.x)?0:n.anchor_position.x,pcbY:n.anchor_position.y,pcbRotation:s??0})},aGt=(n,e)=>((-parseInt(n||"0",10)+(e??0))%360+360)%360,JSe=({componentName:n,componentRotation:e,footprint:a,pinLabels:s,pcbPinLabels:l},d)=>{let x=[];for(let f of d)if(f.type==="pcb_smtpad"&&f.shape==="rect")x.push(new $S({pcbX:f.x,pcbY:f.y,layer:f.layer,shape:"rect",height:f.height,width:f.width,portHints:f.port_hints}));else if(f.type==="pcb_smtpad"&&f.shape==="circle")x.push(new $S({pcbX:f.x,pcbY:f.y,layer:f.layer,shape:"circle",radius:f.radius,portHints:f.port_hints}));else if(f.type==="pcb_silkscreen_path")x.push(new qW({layer:f.layer,route:f.route,strokeWidth:f.stroke_width}));else if(f.type==="pcb_plated_hole")f.shape==="circle"?x.push(new zS({pcbX:f.x,pcbY:f.y,shape:"circle",holeDiameter:f.hole_diameter,outerDiameter:f.outer_diameter,portHints:f.port_hints})):f.shape==="circular_hole_with_rect_pad"&&x.push(new zS({pcbX:f.x,pcbY:f.y,shape:"circular_hole_with_rect_pad",holeDiameter:f.hole_diameter,rectPadHeight:f.rect_pad_height,rectPadWidth:f.rect_pad_width,portHints:f.port_hints}));else if(f.type==="pcb_keepout"&&f.shape==="circle")x.push(new qS({pcbX:f.center.x,pcbY:f.center.y,shape:"circle",radius:f.radius}));else if(f.type==="pcb_keepout"&&f.shape==="rect")x.push(new qS({pcbX:f.center.x,pcbY:f.center.y,shape:"rect",width:f.width,height:f.height}));else if(f.type==="pcb_hole"&&f.hole_shape==="circle")x.push(new VW({pcbX:f.x,pcbY:f.y,diameter:f.hole_diameter}));else if(f.type==="pcb_cutout")f.shape==="rect"?x.push(new $F({pcbX:f.center.x,pcbY:f.center.y,shape:"rect",width:f.width,height:f.height})):f.shape==="circle"?x.push(new $F({pcbX:f.center.x,pcbY:f.center.y,shape:"circle",radius:f.radius})):f.shape==="polygon"&&x.push(new $F({shape:"polygon",points:f.points}));else if(f.type==="pcb_silkscreen_text"){let m=aGt(e,f.ccw_rotation);a.includes("pinrow")&&f.text.includes("PIN")?x.push(nGt({elm:f,pinLabels:l??s,layer:f.layer,readableRotation:m,anchorAlignment:f.anchor_alignment})):x.push(new XS({anchorAlignment:f.anchor_alignment||"center",text:n,fontSize:f.font_size+.2,pcbX:Number.isNaN(f.anchor_position.x)?0:f.anchor_position.x,pcbY:f.anchor_position.y,pcbRotation:m??0}))}else f.type==="pcb_trace"&&x.push(new UW({route:f.route}));return x};function GW(n){let e=1/0,a=1/0,s=-1/0,l=-1/0,d=!1;for(let m of n)if(m.isPcbPrimitive&&!m.componentName.startsWith("Silkscreen")){let{x:y,y:b}=m._getGlobalPcbPositionBeforeLayout(),{width:E,height:A}=m.getPcbSize();e=Math.min(e,y-E/2),a=Math.min(a,b-A/2),s=Math.max(s,y+E/2),l=Math.max(l,b+A/2),d=!0}else if(m.children.length>0){let y=GW(m.children);(y.width>0||y.height>0)&&(e=Math.min(e,y.minX),a=Math.min(a,y.minY),s=Math.max(s,y.maxX),l=Math.max(l,y.maxY),d=!0)}if(!d)return{minX:0,minY:0,maxX:0,maxY:0,width:0,height:0};let x=s-e,f=l-a;return x<0&&(x=0),f<0&&(f=0),{minX:e,minY:a,maxX:s,maxY:l,width:x,height:f}}function sGt(n,e){let a=e.x-n.x,s=e.y-n.y;return Math.abs(a)>Math.abs(s)?a>=0?"right":"left":s>=0?"up":"down"}var iGt=n=>{if(n.length<=1)return!0;let e=n.map(d=>{let x=d._getPcbCircuitJsonBounds();return{left:x.bounds.left,right:x.bounds.right,top:x.bounds.top,bottom:x.bounds.bottom}}),a=Array(e.length).fill(!1).map(()=>Array(e.length).fill(!1));for(let d=0;d<e.length;d++)for(let x=d+1;x<e.length;x++){let f=e[d],m=e[x];a[d][x]=a[x][d]=!(f.right<m.left||f.left>m.right||f.bottom>m.top||f.top<m.bottom)}let s=new Set,l=d=>{s.add(d);for(let x=0;x<e.length;x++)a[d][x]&&!s.has(x)&&l(x)};return l(0),s.size===e.length},oGt=n=>{if(n.length===0)throw new Error("Cannot get center of empty PCB primitives array");let e=n.map(l=>l._getPcbCircuitJsonBounds().center).filter(Boolean),a=e.reduce((l,d)=>l+d.x,0),s=e.reduce((l,d)=>l+d.y,0);return{x:a/e.length,y:s/e.length}},uGt=C.object({name:C.string().optional(),pinNumber:C.number().optional(),aliases:C.array(C.string()).optional()}),Fo=class extends ga{constructor(e,a={}){if(!e.name&&e.pinNumber!==void 0&&(e.name=`pin${e.pinNumber}`),!e.name)throw new Error("Port must have a name or a pinNumber");super(e);X(this,"source_port_id",null);X(this,"pcb_port_id",null);X(this,"schematic_port_id",null);X(this,"schematicSymbolPortDef",null);X(this,"matchedComponents");X(this,"facingDirection",null);X(this,"originDescription",null);a.originDescription&&(this.originDescription=a.originDescription),this.matchedComponents=[]}get config(){return{componentName:"Port",zodProps:uGt}}_getGlobalPcbPositionBeforeLayout(){let e=this.matchedComponents.find(s=>s.isPcbPrimitive),a=this.parent;if(a&&!a.props.footprint)throw new Error(`${a.componentName} "${a.props.name}" does not have a footprint. Add a footprint prop, e.g. <${a.componentName.toLowerCase()} footprint="..." />`);if(!e)throw new Error(`Port ${this} has no matching PCB primitives. This often means the footprint's pads lack matching port hints.`);return e?._getGlobalPcbPositionBeforeLayout()??{x:0,y:0}}_getPcbCircuitJsonBounds(){if(!this.pcb_port_id)return super._getPcbCircuitJsonBounds();let{db:e}=this.root,a=e.pcb_port.get(this.pcb_port_id);return{center:{x:a.x,y:a.y},bounds:{left:0,top:0,right:0,bottom:0},width:0,height:0}}_getGlobalPcbPositionAfterLayout(){return this._getPcbCircuitJsonBounds().center}_getPortsInternallyConnectedToThisPort(){let e=this.parent;if(!e||!e._getInternallyConnectedPins)return[];let a=e._getInternallyConnectedPins();for(let s of a)if(s.some(l=>l===this))return s;return[]}_hasSchematicPort(){if(this.parent?.getSchematicSymbol())return!!(this.schematicSymbolPortDef||this._getPortsInternallyConnectedToThisPort().some(l=>l.schematicSymbolPortDef));let a=this?.parent?._getSchematicBoxDimensions();return!!(a&&this.props.pinNumber!==void 0&&a.getPortPositionByPinNumber(this.props.pinNumber))}_getGlobalSchematicPositionBeforeLayout(){let e=this.parent?.getSchematicSymbol();if(e){let s=this.schematicSymbolPortDef;if(!s&&(s=this._getPortsInternallyConnectedToThisPort().find(d=>d.schematicSymbolPortDef)?.schematicSymbolPortDef??null,!s))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 l=Bs(this.parent.computeSchematicGlobalTransform(),ja(-e.center.x,-e.center.y));return vs(l,s)}let a=this?.parent?._getSchematicBoxDimensions();if(a&&this.props.pinNumber!==void 0){let s=a.getPortPositionByPinNumber(this.props.pinNumber);if(!s)throw new Error(`Couldn't find position for schematic_port for port ${this.getString()} inside of the schematic box`);return vs(this.parent.computeSchematicGlobalTransform(),s)}throw new Error(`Couldn't find position for schematic_port for port ${this.getString()}`)}_getGlobalSchematicPositionAfterLayout(){let{db:e}=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 a=e.schematic_port.get(this.schematic_port_id);if(!a)throw new Error(`Schematic port not found when trying to get post-layout position: ${this.schematic_port_id}`);return a.center}registerMatch(e){this.matchedComponents.push(e)}getNameAndAliases(){let{_parsedProps:e}=this;return Array.from(new Set([...e.name?[e.name]:[],...e.aliases??[],...typeof e.pinNumber=="number"?[`pin${e.pinNumber}`,e.pinNumber.toString()]:[],...this.externallyAddedAliases??[]]))}isMatchingPort(e){return this.isMatchingAnyOf(e.getNameAndAliases())}getPortSelector(){return`.${this.parent?.props.name} > port.${this.props.name}`}getAvailablePcbLayers(){return Array.from(new Set(this.matchedComponents.flatMap(e=>e.getAvailablePcbLayers())))}_getDirectlyConnectedTraces(){return this.getSubcircuit().selectAll("trace").filter(s=>!s._couldNotFindPort).filter(s=>s._isExplicitlyConnectedToPort(this))}doInitialSourceRender(){let{db:e}=this.root,{_parsedProps:a}=this,s=this.getNameAndAliases(),l=e.source_port.insert({name:a.name,pin_number:a.pinNumber,port_hints:s,source_component_id:this.parent?.source_component_id,subcircuit_id:this.getSubcircuit()?.subcircuit_id});this.source_port_id=l.source_port_id}doInitialSourceParentAttachment(){let{db:e}=this.root;if(!this.parent?.source_component_id)throw new Error(`${this.getString()} has no parent source component (parent: ${this.parent?.getString()})`);e.source_port.update(this.source_port_id,{source_component_id:this.parent?.source_component_id,subcircuit_id:this.getSubcircuit()?.subcircuit_id}),this.source_component_id=this.parent?.source_component_id}doInitialPcbPortRender(){if(this.root?.pcbDisabled)return;let{db:e}=this.root,{matchedComponents:a}=this;if(!this.parent?.pcb_component_id)throw new Error(`${this.getString()} has no parent pcb component, cannot render pcb_port (parent: ${this.parent?.getString()})`);let s=a.filter(d=>d.isPcbPrimitive);if(s.length===0)return;let l=null;if(s.length===1&&(l=s[0]._getPcbCircuitJsonBounds().center),s.length>1){if(!iGt(s))throw new Error(`${this.getString()} has multiple non-overlapping pcb matches, unclear how to place pcb_port: ${s.map(d=>d.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)`);l=oGt(s)}if(l){let d=this.getSubcircuit(),x=e.pcb_port.insert({pcb_component_id:this.parent?.pcb_component_id,layers:this.getAvailablePcbLayers(),subcircuit_id:d?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0,...l,source_port_id:this.source_port_id});this.pcb_port_id=x.pcb_port_id}else{let d=s[0];throw new Error(`${d.getString()} does not have a center or _getGlobalPcbPositionBeforeLayout method (needed for pcb_port placement)`)}}doInitialSchematicPortRender(){let{db:e}=this.root,{_parsedProps:a}=this,s=this.getPrimitiveContainer();if(!s||!this._hasSchematicPort())return;let l=s._getGlobalSchematicPositionBeforeLayout(),d=this._getGlobalSchematicPositionBeforeLayout(),x=null,f=s._getSchematicBoxDimensions();f&&a.pinNumber!==void 0&&(x=f.getPortPositionByPinNumber(a.pinNumber)),this.getSubcircuit().props._schDebugObjectsEnabled&&e.schematic_debug_object.insert({shape:"rect",center:d,size:{width:.1,height:.1},label:"obstacle"}),x?.side?this.facingDirection={left:"left",right:"right",top:"up",bottom:"down"}[x.side]:this.facingDirection=sGt(l,d);let m=e.source_port.get(this.source_port_id),y=[];for(let w of m?.port_hints??[])w.match(/^(pin)?\d+$/)||w.match(/^(left|right)/)&&!m?.name.match(/^(left|right)/)||y.push(w);let b;this.parent?.props?.showPinAliases&&y.length>0?b=y.join("/"):y.length>0&&(b=y[0]);let A=e.schematic_port.insert({schematic_component_id:this.parent?.schematic_component_id,center:d,source_port_id:this.source_port_id,facing_direction:this.facingDirection,distance_from_component_edge:.4,side_of_component:x?.side,pin_number:a.pinNumber,true_ccw_index:x?.trueIndex,display_pin_label:b,is_connected:!1});this.schematic_port_id=A.schematic_port_id}_getSubcircuitConnectivityKey(){return this.root?.db.source_port.get(this.source_port_id)?.subcircuit_connectivity_map_key}_setPositionFromLayout(e){let{db:a}=this.root;this.pcb_port_id&&a.pcb_port.update(this.pcb_port_id,{x:e.x,y:e.y})}_hasMatchedPcbPrimitive(){return this.matchedComponents.some(e=>e.isPcbPrimitive)}_getNetLabelText(){return`${this.parent?.props.name}_${this.props.name}`}},Ewe=n=>{let e=n.find(a=>/^(pin)?\d+$/.test(a));return e?Number.parseInt(e.replace(/^pin/,"")):null};function kF(n,e){let a=Ewe(n);if(!a)return null;let l=[...n.filter(d=>d.toString()!==a.toString()&&d!==`pin${a}`),...e?.additionalAliases?.[`pin${a}`]??[]];return new Fo({pinNumber:a,aliases:l})}var cGt=n=>{for(let e of["leftSide","rightSide","topSide","bottomSide"])if(e in n&&typeof n[e]=="number")throw new Error(`A number was specified for "${e}", you probably meant to use "size" not "side"`);return"leftSide"in n||"rightSide"in n||"topSide"in n||"bottomSide"in n},lGt=n=>{if(cGt(n))return{leftSize:n.leftSide?.pins.length??0,rightSize:n.rightSide?.pins.length??0,topSize:n.topSide?.pins.length??0,bottomSize:n.bottomSide?.pins.length??0};let{leftSize:e=0,rightSize:a=0,topSize:s=0,bottomSize:l=0}=n;return{leftSize:e,rightSize:a,topSize:s,bottomSize:l}};function vwe(n){let e=n;return e.leftSide!==void 0||e.rightSide!==void 0||e.topSide!==void 0||e.bottomSide!==void 0}var dGt=n=>{let e=n.portDistanceFromEdge??.4,a=n.schPortArrangement?lGt(n.schPortArrangement):null,s={left:0,right:0,top:0,bottom:0},l=n.pinCount??null;if(l===null)if(a)l=a.leftSize+a.rightSize+a.topSize;else throw new Error("Could not determine pin count for the schematic box");if(l&&!a){let B=Math.floor(l/2);a={leftSize:l-B,rightSize:B,topSize:0,bottomSize:0}}a||(a={leftSize:0,rightSize:0,topSize:0,bottomSize:0});let d=({side:B,sideIndex:I,truePinIndex:q})=>{if(!n.schPortArrangement||!vwe(n.schPortArrangement))return q+1;let G={left:"top-to-bottom",bottom:"left-to-right",right:"bottom-to-top",top:"right-to-left"}[B],j=n.schPortArrangement?.[`${B}Side`]?.direction??G,O=n.schPortArrangement?.[`${B}Side`]?.pins,V=I;return j!==G&&(V=O.length-I-1),zF(O[V],n.pinLabels)},x=[],f=0,m=0;for(let B=0;B<a.leftSize;B++){let I=d({side:"left",sideIndex:B,truePinIndex:m}),q=n.numericSchPinStyle?.[`pin${I}`]??n.numericSchPinStyle?.[I];q?.topMargin&&(f+=q.topMargin),x.push({trueIndex:m,pinNumber:I,side:"left",distanceFromOrthogonalEdge:f}),q?.bottomMargin&&(f+=q.bottomMargin),B===a.leftSize-1?s.left=f:f+=n.schPinSpacing,m++}f=0;for(let B=0;B<a.bottomSize;B++){let I=d({side:"bottom",sideIndex:B,truePinIndex:m}),q=n.numericSchPinStyle?.[`pin${I}`]??n.numericSchPinStyle?.[I];q?.leftMargin&&(f+=q.leftMargin),x.push({trueIndex:m,pinNumber:I,side:"bottom",distanceFromOrthogonalEdge:f}),q?.rightMargin&&(f+=q.rightMargin),B===a.bottomSize-1?s.bottom=f:f+=n.schPinSpacing,m++}f=0;for(let B=0;B<a.rightSize;B++){let I=d({side:"right",sideIndex:B,truePinIndex:m}),q=n.numericSchPinStyle?.[`pin${I}`]??n.numericSchPinStyle?.[I];q?.bottomMargin&&(f+=q.bottomMargin),x.push({trueIndex:m,pinNumber:I,side:"right",distanceFromOrthogonalEdge:f}),q?.topMargin&&(f+=q.topMargin),B===a.rightSize-1?s.right=f:f+=n.schPinSpacing,m++}f=0;for(let B=0;B<a.topSize;B++){let I=d({side:"top",sideIndex:B,truePinIndex:m}),q=n.numericSchPinStyle?.[`pin${I}`]??n.numericSchPinStyle?.[I];q?.rightMargin&&(f+=q.rightMargin),x.push({trueIndex:m,pinNumber:I,side:"top",distanceFromOrthogonalEdge:f}),q?.leftMargin&&(f+=q.leftMargin),B===a.topSize-1?s.top=f:f+=n.schPinSpacing,m++}let y=n.schWidth;if(y===void 0){y=Math.max(s.top+n.schPinSpacing*2,s.bottom+n.schPinSpacing*2);let B=n.pinLabels?Math.max(...Object.values(n.pinLabels).map(q=>q.length*.1)):0,I=B>0?1.1:0;y=Math.max(y,B+I)}let b=n.schHeight;b||(b=Math.max(s.left+n.schPinSpacing*2,s.right+n.schPinSpacing*2));let E={left:{x:-y/2-e,y:s.left/2},bottom:{x:-s.bottom/2,y:-b/2-e},right:{x:y/2+e,y:-s.right/2},top:{x:s.top/2,y:b/2+e}},A={left:{x:0,y:-1},right:{x:0,y:1},top:{x:-1,y:0},bottom:{x:1,y:0}},w=x.map(B=>{let{distanceFromOrthogonalEdge:I,side:q}=B,G=E[q],j=A[q];return{x:G.x+I*j.x,y:G.y+I*j.y,...B}});return{getPortPositionByPinNumber(B){let I=w.find(q=>q.pinNumber.toString()===B.toString());return I||null},getSize(){return{width:y,height:b}},getSizeIncludingPins(){return{width:y+(a.leftSize||a.rightSize?.4:0),height:b+(a.topSize||a.bottomSize?.4:0)}},pinCount:l}},pGt=(0,Cwe.default)("tscircuit:core:footprint"),_we=class extends ga{get config(){return{componentName:"Footprint",zodProps:X8e}}doInitialPcbFootprintLayout(){if(this.root?.pcbDisabled)return;let n=this.children.filter(E=>E.componentName==="Constraint");if(n.length===0)return;let{isFlipped:e}=this._getPcbPrimitiveFlippedHelpers(),a=E=>e&&"left"in E&&"right"in E?{...E,left:E.right,right:E.left}:E,s=n.flatMap(E=>E._getAllReferencedComponents().componentsWithSelectors).map(({component:E,selector:A,componentSelector:w,edge:B})=>({component:E,selector:A,componentSelector:w,edge:B,bounds:E._getPcbCircuitJsonBounds()}));if(s.some(E=>E.edge))throw new Error("edge constraints not implemented yet for footprint layout, contributions welcome!");function l(E){return s.find(({selector:A})=>A===E)}let d=new o5,x={};function f(E){return E in x||(x[E]=new o1(E),d.addEditVariable(x[E],qs.weak)),x[E]}for(let{selector:E,bounds:A}of s){let w=f(`${E}_x`),B=f(`${E}_y`);d.suggestValue(w,A.center.x),d.suggestValue(B,A.center.y)}for(let E of n){let A=E._parsedProps;if("xDist"in A){let{xDist:w,left:B,right:I,edgeToEdge:q,centerToCenter:G}=a(A),j=f(`${B}_x`),O=f(`${I}_x`),V=l(B)?.bounds,te=l(I)?.bounds;if(G){let N=new Ps(O,[-1,j]);d.addConstraint(new Zu(N,yo.Eq,A.xDist,qs.required))}else if(q){let N=new Ps(O,-te.width/2,[-1,j],-V.width/2);d.addConstraint(new Zu(N,yo.Eq,A.xDist,qs.required))}}else if("yDist"in A){let{yDist:w,top:B,bottom:I,edgeToEdge:q,centerToCenter:G}=A,j=f(`${B}_y`),O=f(`${I}_y`),V=l(B)?.bounds,te=l(I)?.bounds;if(G){let N=new Ps(j,[-1,O]);d.addConstraint(new Zu(N,yo.Eq,A.yDist,qs.required))}else if(q){let N=new Ps(j,V.height/2,[-1,O],-te.height/2);d.addConstraint(new Zu(N,yo.Eq,A.yDist,qs.required))}}else if("sameY"in A){let{for:w}=A;if(w.length<2)continue;let B=w.map(q=>f(`${q}_y`)),I=new Ps(...B.slice(1));d.addConstraint(new Zu(I,yo.Eq,B[0],qs.required))}else if("sameX"in A){let{for:w}=A;if(w.length<2)continue;let B=w.map(q=>f(`${q}_x`)),I=new Ps(...B.slice(1));d.addConstraint(new Zu(I,yo.Eq,B[0],qs.required))}}d.updateVariables(),pGt.enabled&&(console.log("Solution to layout constraints:"),console.table(Object.entries(x).map(([E,A])=>({var:E,val:A.value()}))));let m={left:1/0,right:-1/0,top:-1/0,bottom:1/0};for(let{selector:E,bounds:{width:A,height:w}}of s){let B=f(`${E}_x`),I=f(`${E}_y`),q=B.value()-A/2,G=B.value()+A/2,j=I.value()+w/2,O=I.value()-w/2;m.left=Math.min(m.left,q),m.right=Math.max(m.right,G),m.top=Math.max(m.top,j),m.bottom=Math.min(m.bottom,O)}let y={x:-(m.right+m.left)/2,y:-(m.top+m.bottom)/2},b=this.getPrimitiveContainer()._getGlobalPcbPositionBeforeLayout();y.x+=b.x,y.y+=b.y;for(let{component:E,selector:A}of s){let w=f(`${A}_x`),B=f(`${A}_y`);E._setPositionFromLayout({x:w.value()+y.x,y:B.value()+y.y})}}},xGt=(n,e)=>{if(!n)return;let a={};for(let[s,l]of Object.entries(n)){let d=zF(s,e),x={leftMargin:l.marginLeft??l.leftMargin,rightMargin:l.marginRight??l.rightMargin,topMargin:l.marginTop??l.topMargin,bottomMargin:l.marginBottom??l.bottomMargin};a[`pin${d}`]={...a[`pin${d}`],...x}}return a},ZSe=class{constructor({input:n}){X(this,"input");this.input=n}solveAndMapToTraces(){let n=[];for(let e of this.input.connections){if(e.pointsToConnect.length!==2)continue;let[a,s]=e.pointsToConnect,l={type:"pcb_trace",pcb_trace_id:"",connection_name:e.name,route:[{route_type:"wire",x:a.x,y:a.y,layer:"top",width:.1},{route_type:"wire",x:s.x,y:s.y,layer:"top",width:.1}]};n.push(l)}return n}},fGt=n=>{let e=Math.min(...n.map(d=>d.center.x)),a=Math.max(...n.map(d=>d.center.x)),s=Math.min(...n.map(d=>d.center.y)),l=Math.max(...n.map(d=>d.center.y));return{minX:e,maxX:a,minY:s,maxY:l}},QSe=["top","bottom","inner1","inner2"],OS=(n,e=[])=>{let a=[];if(e.length===0){let f=n[0].layers;for(let m of f)a.push(...OS(n.slice(1),[m]));return a}if(n.length===0)return[];let s=n[0],l=s.via||s.optional_via,d=e[e.length-1];if(n.length===1){let f=s;return f.layers&&l?f.layers.map(m=>({layer_path:[...e,m]})):f.layers?.includes(d)?[{layer_path:[...e,d]}]:[]}if(!l)return s.layers&&!s.layers.includes(d)?[]:OS(n.slice(1),e.concat([d]));let x=(s.optional_via?QSe:QSe.filter(f=>f!==d)).filter(f=>!s.layers||s.layers?.includes(f));for(let f of x)a.push(...OS(n.slice(1),e.concat(f)));return a};function ewe(n){let e={x:n.to.x-n.from.x,y:n.to.y-n.from.y},a=Math.abs(e.x),s=Math.abs(e.y);return a>s?e.x>0?"right":"left":e.y>0?"down":"up"}function Ng(n,e){return Math.hypot(n.x-e.x,n.y-e.y)}var hGt=n=>{if(n.length===1)return n[0];if(n.some(m=>m.length===0))throw new Error("Cannot merge routes with zero length");let e=[],a=n[0][0],s=n[0][n[0].length-1],l=n[1][0],d=n[1][n[1].length-1],x=Math.min(Ng(a,l),Ng(a,d)),f=Math.min(Ng(s,l),Ng(s,d));x<f?e.push(...n[0].reverse()):e.push(...n[0]);for(let m=1;m<n.length;m++){let y=e[e.length-1],b=n[m],E=b[0],A=b[b.length-1],w=Ng(y,E),B=Ng(y,A);w<B?e.push(...b):e.push(...b.reverse())}for(let m=1;m<e.length-1;m++){let y=e[m-1],b=e[m];y.route_type==="wire"&&b.route_type==="wire"&&y.layer!==b.layer&&e.splice(m,0,{x:y.x,y:y.y,from_layer:y.layer,to_layer:b.layer,route_type:"via"})}return e},mGt=(n,e)=>{let a="_getGlobalPcbPositionBeforeLayout"in n?n._getGlobalPcbPositionBeforeLayout():n,s="_getGlobalPcbPositionBeforeLayout"in e?e._getGlobalPcbPositionBeforeLayout():e;return Math.sqrt((a.x-s.x)**2+(a.y-s.y)**2)};function gGt(n,e){if(e.length===0)throw new Error("No candidates given to getClosest method");let a=e[0],s=1/0;for(let l of e){let d=mGt(n,l);d<s&&(a=l,s=d)}return a}var yGt=(n,e)=>{let a=0;a+=n.length??0,a+=e.filter(s=>s.is_crossing).length;for(let s=1;s<e.length;s++){let l=e[s-1],d=e[s],x=Math.abs(l.from.x-l.to.x)<.01,f=Math.abs(d.from.x-d.to.x)<.01;x!==f&&a++}return a},qF=n=>({up:"bottom",down:"top",left:"right",right:"left"})[n]??null,jW=({firstEdge:n,firstEdgePort:e,firstDominantDirection:a,lastEdge:s,lastEdgePort:l,lastDominantDirection:d})=>{if(n&&e)return jW({lastEdge:{from:n.to,to:n.from},lastEdgePort:e,lastDominantDirection:a}).reverse().map(f=>({from:f.to,to:f.from}));let x=[];if(s&&l){let f={x:s.to.x,y:s.to.y};d==="left"||d==="right"?(f.x=l.position.x,x.push({from:s.to,to:{...f}}),x.push({from:f,to:{...l.position}})):(f.y=l.position.y,x.push({from:s.to,to:{...f}}),x.push({from:f,to:{...l.position}}))}return x=x.filter(f=>_i(f.from,f.to)>.01),x};function DGt(n){try{return[n(),null]}catch(e){return[null,e]}}var bGt=(n,{db:e})=>{let a=n.map(s=>{let l=e.source_port.get(s.source_port_id);if(!l?.source_component_id)return null;let d=e.source_component.get(l.source_component_id);return d?.ftype==="simple_capacitor"?d.max_decoupling_trace_length:null}).filter(s=>s!==null);if(a.length!==0)return Math.min(...a)};function FGt({ports:n,nets:e}){if(n.length>=2)return`${n[0]?.selector} to ${n[1]?.selector}`;if(n.length===1&&e.length===1)return`${n[0]?.selector} to net.${e[0]._parsedProps.name}`}var EGt=(n,{db:e})=>{let a=e.pcb_board.list()[0];if(a.outline){let m=a.outline,y=(b,E)=>{let A=!1;for(let w=0,B=E.length-1;w<E.length;B=w++){let I=E[w].x,q=E[w].y,G=E[B].x,j=E[B].y;q>b.y!=j>b.y&&b.x<(G-I)*(b.y-q)/(j-q)+I&&(A=!A)}return A};return n.some(b=>!y(b,m))}let s=a.width,l=a.height,d=a.center.x,x=a.center.y;return n.some(m=>m.x<d-s/2||m.y<x-l/2||m.x>d+s/2||m.y>x+l/2)},twe=(n,e)=>Math.abs(n-e)<1e-4,vGt=(n,e,{viaDiameter:a=.5}={})=>{let s=[];for(let l=0;l<n.length-1;l++){let[d,x]=[n[l],n[l+1]],f=l-1>=0?n[l-1]:null,m=twe(d.y,x.y),y=twe(d.x,x.x);if(!m&&!y)throw new Error(`getObstaclesFromTrace currently only supports horizontal and vertical traces (not diagonals) Conflicting trace: ${e}, start: (${d.x}, ${d.y}), end: (${x.x}, ${x.y})`);let b={type:"rect",layers:[d.layer],center:{x:(d.x+x.x)/2,y:(d.y+x.y)/2},width:m?Math.abs(d.x-x.x):.1,height:y?Math.abs(d.y-x.y):.1,connectedTo:[e]};if(s.push(b),f&&f.layer===d.layer&&d.layer!==x.layer){let E={type:"rect",layers:[d.layer,x.layer],center:{x:d.x,y:d.y},connectedTo:[e],width:a,height:a};s.push(E)}}return s};function CGt(n,e=4){let{center:a,width:s,height:l,rotation:d}=n,x=[],f=d*Math.PI/180,m=Math.cos(f),y=Math.sin(f),b=(d%360+360)%360;if(l<=s?b>=45&&b<135||b>=225&&b<315:b>=135&&b<225||b>=315||b<45){let A=s/e;for(let w=0;w<e;w++){let B=(w-e/2+.5)*A,I=-B*m,q=-B*y,G=A*1.1,j=Math.abs(l*m)+Math.abs(A*y);x.push({center:{x:a.x+I,y:a.y+q},width:G,height:j})}}else{let A=l/e;for(let w=0;w<e;w++){let B=(w-e/2+.5)*A,I=-B*y,q=B*m,G=Math.abs(s*m)+Math.abs(A*y),j=A*1.1;x.push({center:{x:a.x+I,y:a.y+q},width:G,height:j})}}return x}function _Gt(n,e={}){if(n.length<3)return[];let{rectHeight:a=.1}=e,s=[],l=n.map(f=>f.y),d=Math.min(...l),x=Math.max(...l);for(let f=d;f<x;f+=a){let m=f+a/2,y=[];for(let b=0;b<n.length;b++){let E=n[b],A=n[(b+1)%n.length];if(E.y<=m&&A.y>m||A.y<=m&&E.y>m){let w=(m-E.y)*(A.x-E.x)/(A.y-E.y)+E.x;y.push(w)}}y.sort((b,E)=>b-E);for(let b=0;b<y.length;b+=2)if(b+1<y.length){let E=y[b],w=y[b+1]-E;w>1e-6&&s.push({center:{x:E+w/2,y:m},width:w,height:a})}}return s}function AGt(n,e={}){let{center:a,radius:s}=n,{rectHeight:l=.1}=e,d=[],x=Math.ceil(s*2/l);for(let f=0;f<x;f++){let m=a.y-s+(f+.5)*l,y=m-a.y,b=Math.sqrt(s*s-y*y);b>0&&d.push({center:{x:a.x,y:m},width:b*2,height:l})}return d}var rx=["top","inner1","inner2","bottom"],Awe=(n,e)=>{let a=l=>e?l.concat(l.map(d=>e?.getNetConnectedToId(d)).filter(Boolean)):l,s=[];for(let l of n)if(l.type==="pcb_smtpad"){if(l.shape==="circle")s.push({type:"oval",layers:[l.layer],center:{x:l.x,y:l.y},width:l.radius*2,height:l.radius*2,connectedTo:a([l.pcb_smtpad_id])});else if(l.shape==="rect")s.push({type:"rect",layers:[l.layer],center:{x:l.x,y:l.y},width:l.width,height:l.height,connectedTo:a([l.pcb_smtpad_id])});else if(l.shape==="rotated_rect"){let d={center:{x:l.x,y:l.y},width:l.width,height:l.height,rotation:l.ccw_rotation},x=CGt(d);for(let f of x)s.push({type:"rect",layers:[l.layer],center:f.center,width:f.width,height:f.height,connectedTo:a([l.pcb_smtpad_id])})}}else if(l.type==="pcb_keepout")l.shape==="circle"?s.push({type:"oval",layers:l.layers,center:{x:l.center.x,y:l.center.y},width:l.radius*2,height:l.radius*2,connectedTo:[]}):l.shape==="rect"&&s.push({type:"rect",layers:l.layers,center:{x:l.center.x,y:l.center.y},width:l.width,height:l.height,connectedTo:[]});else if(l.type==="pcb_cutout"){if(l.shape==="rect")s.push({type:"rect",layers:rx,center:{x:l.center.x,y:l.center.y},width:l.width,height:l.height,connectedTo:[]});else if(l.shape==="circle"){let d=AGt({center:l.center,radius:l.radius},{rectHeight:.6});for(let x of d)s.push({type:"rect",layers:rx,center:x.center,width:x.width,height:x.height,connectedTo:[]})}else if(l.shape==="polygon"){let d=_Gt(l.points,{rectHeight:.6});for(let x of d)s.push({type:"rect",layers:rx,center:x.center,width:x.width,height:x.height,connectedTo:[]})}}else if(l.type==="pcb_hole")l.hole_shape==="oval"?s.push({type:"oval",center:{x:l.x,y:l.y},width:l.hole_width,height:l.hole_height,connectedTo:[]}):l.hole_shape==="square"?s.push({type:"rect",layers:rx,center:{x:l.x,y:l.y},width:l.hole_diameter,height:l.hole_diameter,connectedTo:[]}):(l.hole_shape==="round"||l.hole_shape==="circle")&&s.push({type:"rect",layers:rx,center:{x:l.x,y:l.y},width:l.hole_diameter,height:l.hole_diameter,connectedTo:[]});else if(l.type==="pcb_plated_hole")l.shape==="circle"?s.push({type:"oval",layers:rx,center:{x:l.x,y:l.y},width:l.outer_diameter,height:l.outer_diameter,connectedTo:a([l.pcb_plated_hole_id])}):l.shape==="circular_hole_with_rect_pad"?s.push({type:"rect",layers:rx,center:{x:l.x,y:l.y},width:l.rect_pad_width,height:l.rect_pad_height,connectedTo:a([l.pcb_plated_hole_id])}):(l.shape==="oval"||l.shape==="pill")&&s.push({type:"oval",layers:rx,center:{x:l.x,y:l.y},width:l.outer_width,height:l.outer_height,connectedTo:a([l.pcb_plated_hole_id])});else if(l.type==="pcb_trace"){let d=vGt(l.route.map(x=>({x:x.x,y:x.y,layer:"layer"in x?x.layer:x.from_layer})),l.source_trace_id);s.push(...d)}else l.type==="pcb_via"&&s.push({type:"rect",layers:l.layers,center:{x:l.x,y:l.y},connectedTo:[],width:l.outer_diameter,height:l.outer_diameter});return s},nx=({anchor_position:n,anchor_side:e,text:a,font_size:s=.18})=>{let l=.1*(s/.18),d=a.length*l,x=s,f={...n};switch(e){case"right":f.x-=d/2;break;case"left":f.x+=d/2;break;case"top":f.y-=x/2;break;case"bottom":f.y+=x/2;break}return f},XW=({db:n,source_trace_id:e,sameNetOnly:a,differentNetOnly:s})=>{!a&&!s&&(s=!0);let l=n.source_trace.get(e),d=[];for(let x of n.schematic_trace.list()){if(x.source_trace_id===e)continue;let m=n.source_trace.get(x.source_trace_id)?.subcircuit_connectivity_map_key===l.subcircuit_connectivity_map_key;s&&m||a&&!m||d.push(x)}return d},RGt=({edges:n,otherEdges:e})=>{let a=[...n];for(let s=0;s<a.length;s++){if(s>2e3)throw new Error("Over 2000 iterations spent inside createSchematicTraceCrossingSegments, you have triggered an infinite loop, please report this!");let l=a[s],d=Math.abs(l.from.x-l.to.x)<.01?"vertical":l.from.y===l.to.y?"horizontal":"not-orthogonal";if(d==="not-orthogonal")continue;let x=[];for(let I of e){let q=I.from.x===I.to.x?"vertical":I.from.y===I.to.y?"horizontal":"not-orthogonal";if(q==="not-orthogonal"||d===q)continue;if(Lp([l.from,l.to],[I.from,I.to],{lineThickness:.01})){let j=d==="vertical"?l.from.x:I.from.x,O=d==="vertical"?I.from.y:l.from.y,V={x:j,y:O};x.push({otherEdge:I,crossingPoint:V,distanceFromEdgeFrom:_i(l.from,V)})}}if(x.length===0)continue;let f=x[0];for(let I of x)I.distanceFromEdgeFrom<f.distanceFromEdgeFrom&&(f=I);let m=f.crossingPoint,y=.075;if(m.x===l.from.x&&m.y===l.from.y)continue;let b=p5(l.from,m),E={x:m.x-b.x*y/2,y:m.y-b.y*y/2},A={x:m.x+b.x*y/2,y:m.y+b.y*y/2},w=_i(A,l.to)<y,B=[{from:l.from,to:E},{from:E,to:A,is_crossing:!0},{from:A,to:l.to}];a.splice(s,1,...B),s+=B.length-2,w&&s++}return a},NW=.001,kg=(n,e)=>{let a=Math.min(e.from.x,e.to.x),s=Math.max(e.from.x,e.to.x),l=Math.min(e.from.y,e.to.y),d=Math.max(e.from.y,e.to.y);return n.x>=a&&n.x<=s&&n.y>=l&&n.y<=d},rwe=n=>{let e=Math.abs(n.from.x-n.to.x)<NW,a=Math.abs(n.from.y-n.to.y)<NW;return e?"vertical":a?"horizontal":"diagonal"},SGt=(n,e)=>{let a=rwe(n),s=rwe(e);if(a===s)return null;if(a==="vertical"&&s==="horizontal"||a==="horizontal"&&s==="vertical"){let E=a==="vertical"?n:e,A=a==="horizontal"?n:e,w=E.from.x,B=A.from.y,I={x:w,y:B};return kg(I,n)&&kg(I,e)?I:null}if(a==="vertical"||s==="vertical"){let E=a==="vertical"?n:e,A=a==="vertical"?e:n,w=E.from.x,B=(A.to.y-A.from.y)/(A.to.x-A.from.x),I=A.from.y-B*A.from.x,q=B*w+I,G={x:w,y:q};return kg(G,n)&&kg(G,e)?G:null}let l=(n.to.y-n.from.y)/(n.to.x-n.from.x),d=n.from.y-l*n.from.x,x=(e.to.y-e.from.y)/(e.to.x-e.from.x),f=e.from.y-x*e.from.x;if(Math.abs(l-x)<NW)return null;let m=(f-d)/(l-x),y=l*m+d,b={x:m,y};return kg(b,n)&&kg(b,e)?b:null},wGt=({edges:n,db:e,source_trace_id:a})=>{let s=XW({db:e,source_trace_id:a,sameNetOnly:!0}).flatMap(d=>d.edges),l=new Map;for(let d of n)for(let x of s){let f=SGt(d,x);if(f){let m=`${f.x.toFixed(6)},${f.y.toFixed(6)}`;l.has(m)||l.set(m,f)}}return Array.from(l.values())};function BGt(n){let e=1/0,a=1/0,s=-1/0,l=-1/0;for(let d of n){let x,f,m,y;d.type==="schematic_component"?(x=d.center?.x,f=d.center?.y,m=d.size?.width,y=d.size?.height):d.type==="schematic_box"?(x=d.x,f=d.y,m=d.width,y=d.height):d.type==="schematic_port"?(x=d.center?.x,f=d.center?.y,m=.2,y=.2):d.type==="schematic_text"&&(x=d.position?.x,f=d.position?.y,m=(d.text?.length??0)*.1,y=.2),typeof x=="number"&&typeof f=="number"&&typeof m=="number"&&typeof y=="number"&&(e=Math.min(e,x-m/2),s=Math.max(s,x+m/2),a=Math.min(a,f-y/2),l=Math.max(l,f+y/2))}return{minX:e,maxX:s,minY:a,maxY:l}}function TGt(n,e={}){let{minX:a,maxX:s,minY:l,maxY:d}=n,x=e.padding??1;if(!isFinite(a)||!isFinite(s)||!isFinite(l)||!isFinite(d))return[];let f=a-x,m=s+x,y=d+x,b=l-x,E=.01;return[{type:"rect",layers:["top"],center:{x:(f+m)/2,y},width:m-f,height:E,connectedTo:[]},{type:"rect",layers:["top"],center:{x:(f+m)/2,y:b},width:m-f,height:E,connectedTo:[]},{type:"rect",layers:["top"],center:{x:f,y:(y+b)/2},width:E,height:y-b,connectedTo:[]},{type:"rect",layers:["top"],center:{x:m,y:(y+b)/2},width:E,height:y-b,connectedTo:[]}]}var PGt=n=>{let e=n.root.db,a=n._findConnectedPorts().ports??[],s=new Set(a.map(x=>x.schematic_port_id)),l=[];for(let x of e.toArray()){if(x.type==="schematic_component"){let f=!!x.symbol_name,m=x.size.width>x.size.height?"horz":"vert";l.push({type:"rect",layers:["top"],center:x.center,width:x.size.width+(f&&m==="horz"?-.5:0),height:x.size.height+(f&&m==="vert"?-.5:0),connectedTo:[]})}if(x.type==="schematic_port"){if(s.has(x.schematic_port_id))continue;let f=x.facing_direction?x5(x.facing_direction):{x:0,y:0};l.push({type:"rect",layers:["top"],center:{x:x.center.x-f.x*.1,y:x.center.y-f.y*.1},width:.1+Math.abs(f.x)*.3,height:.1+Math.abs(f.y)*.3,connectedTo:[]})}x.type==="schematic_text"&&l.push({type:"rect",layers:["top"],center:x.position,width:(x.text?.length??0)*.1,height:.2,connectedTo:[]}),x.type==="schematic_box"&&l.push({type:"rect",layers:["top"],center:{x:x.x,y:x.y},width:x.width,height:x.height,connectedTo:[]})}let d=BGt(e.toArray());return l.push(...TGt(d,{padding:1})),l},IGt=({edges:n,db:e,source_trace_id:a})=>{let s=e.source_trace.get(a),l=XW({db:e,source_trace_id:a,differentNetOnly:!0}).flatMap(x=>x.edges),d=x=>{let{from:f,to:m}=x;return f.x===m.x?"vertical":"horizontal"};for(let x of n){let f=d(x),m=()=>l.find(b=>d(b)===f&&Lp([x.from,x.to],[b.from,b.to],{lineThickness:.05})),y=m();for(;y;)f==="horizontal"?(x.from.y+=.1,x.to.y+=.1):(x.from.x+=.1,x.to.x+=.1),y=m()}},kW=n=>{switch(n){case"up":return"y+";case"down":return"y-";case"left":return"x-";case"right":return"x+";default:}},jGt=TAe.version??"unknown",MF=class extends Error{constructor(n){super(`${n} (capacity-autorouter@${jGt})`),this.name="AutorouterError"}},US=class extends Error{constructor(n){super(n.message),this.errorData=n,this.name="TraceConnectionError"}},NGt=n=>{if(n.root?._featureMspSchematicTraceRouting||n._couldNotFindPort||n.root?.schematicDisabled)return;let{db:e}=n.root,{_parsedProps:a,parent:s}=n;if(!s)throw new Error("Trace has no parent");let l,d;try{let xe=n._findConnectedPorts();l=xe.allPortsFound,d=xe.portsWithSelectors??[]}catch(xe){if(xe instanceof US){e.source_trace_not_connected_error.insert({...xe.errorData,error_type:"source_trace_not_connected_error"});return}throw xe}let{netsWithSelectors:x}=n._findConnectedNets();if(!l)return;let m=d.map(xe=>xe.port.schematic_port_id).sort().join(","),y=n.root?._getBoard();if(y?._connectedSchematicPortPairs&&y._connectedSchematicPortPairs.has(m))return;let b={name:n.source_trace_id,pointsToConnect:[]},E=PGt(n),A=d.filter(({port:xe})=>xe.schematic_port_id!==null).map(({port:xe})=>({port:xe,position:xe._getGlobalSchematicPositionAfterLayout(),schematic_port_id:xe.schematic_port_id??void 0,facingDirection:xe.facingDirection}));if(A.length===1&&x.length===1){let xe=x[0].net,{port:Ae,position:Ie}=A[0],Le=n.getSubcircuit().selectAll("netlabel").find(et=>{let Qe=et._parsedProps.connection??et._parsedProps.connectsTo;return Qe?Array.isArray(Qe)?Qe.some(Pt=>n.getSubcircuit().selectOne(Pt,{port:!0})===Ae):n.getSubcircuit().selectOne(Qe,{port:!0})===Ae:!1});if(!Le){let et=e.schematic_net_label.getWhere({source_trace_id:n.source_trace_id});et&&(Le=et)}if(Le){let et="_getGlobalSchematicPositionBeforeLayout"in Le?Le._getGlobalSchematicPositionBeforeLayout():Le.anchor_position,Qe=[];Ie.x===et.x||Ie.y===et.y?Qe.push({from:Ie,to:et}):(Qe.push({from:Ie,to:{x:et.x,y:Ie.y}}),Qe.push({from:{x:et.x,y:Ie.y},to:et}));let Mt=e.schematic_trace.insert({source_trace_id:n.source_trace_id,edges:Qe,junctions:[]});n.schematic_trace_id=Mt.schematic_trace_id;return}if(n.props.schDisplayLabel){let et=qF(Ae.facingDirection)??"bottom";e.schematic_net_label.insert({text:n.props.schDisplayLabel,source_net_id:xe.source_net_id,anchor_position:Ie,center:nx({anchor_position:Ie,anchor_side:et,text:n.props.schDisplayLabel}),anchor_side:et});return}let dt=qF(Ae.facingDirection)??"bottom",rt=e.schematic_net_label.insert({text:xe._parsedProps.name,source_net_id:xe.source_net_id,anchor_position:Ie,center:nx({anchor_position:Ie,anchor_side:dt,text:xe._parsedProps.name}),anchor_side:dt});return}if(n.props.schDisplayLabel&&("from"in n.props&&"to"in n.props||"path"in n.props)){n._doInitialSchematicTraceRenderWithDisplayLabel();return}if(A.length<2)return;let I=(()=>{let xe=[];for(let Ie=0;Ie<A.length-1;Ie++){let Le=A[Ie],dt=A[Ie+1],rt=f5({x:Le.position.x,y:Le.position.y,facingDirection:kW(Le.facingDirection)},{x:dt.position.x,y:dt.position.y,facingDirection:kW(dt.facingDirection)});for(let et=0;et<rt.length-1;et++)xe.push({from:rt[et],to:rt[et+1]})}let Ae=(Ie,Le)=>{let dt=Le.width/2,rt=Le.height/2,et=Le.center.x-dt,Qe=Le.center.x+dt,Mt=Le.center.y-rt,Pt=Le.center.y+rt,Ht=yt=>yt.x>=et&&yt.x<=Qe&&yt.y>=Mt&&yt.y<=Pt;return Ht(Ie.from)||Ht(Ie.to)?!0:[[{x:et,y:Mt},{x:Qe,y:Mt}],[{x:Qe,y:Mt},{x:Qe,y:Pt}],[{x:Qe,y:Pt},{x:et,y:Pt}],[{x:et,y:Pt},{x:et,y:Mt}]].some(yt=>Lp([Ie.from,Ie.to],yt,{lineThickness:0}))};for(let Ie of xe)for(let Le of E)if(Ae(Ie,Le))return null;return xe})();I&&I.length===0&&(I=null),b.pointsToConnect=A.map(({position:xe})=>({...xe,layer:"top"}));let q=fGt(E),G=2,j={minTraceWidth:.1,obstacles:E,connections:[b],bounds:{minX:q.minX-G,maxX:q.maxX+G,minY:q.minY-G,maxY:q.maxY+G},layerCount:1},O=ZR,V=!1;if(n.getSubcircuit().props._schDirectLineRoutingEnabled&&(O=ZSe,V=!0),!I){let Ae=new O({input:j,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(Ae.length===0){if(n._isSymbolToChipConnection()||n._isSymbolToSymbolConnection()||n._isChipToChipConnection()){n._doInitialSchematicTraceRenderWithDisplayLabel();return}Ae=new ZSe({input:j}).solveAndMapToTraces(),V=!0}let[{route:Ie}]=Ae;I=[];for(let Le=0;Le<Ie.length-1;Le++)I.push({from:Ie[Le],to:Ie[Le+1]})}let te=n.source_trace_id,N=[];if(!V){IGt({edges:I,db:e,source_trace_id:te});let xe=XW({db:e,source_trace_id:te,differentNetOnly:!0}).flatMap(Ae=>Ae.edges);I=RGt({edges:I,otherEdges:xe}),N=wGt({edges:I,db:e,source_trace_id:n.source_trace_id})}if(!I||I.length===0)return;let se=I[I.length-1],$=A[A.length-1],W=ewe(se);I.push(...jW({lastEdge:se,lastEdgePort:$,lastDominantDirection:W}));let Q=I[0],le=A[0],z=ewe(Q);if(I.unshift(...jW({firstEdge:Q,firstEdgePort:le,firstDominantDirection:z})),!n.source_trace_id)throw new Error("Missing source_trace_id for schematic trace insertion.");if(n.getSubcircuit()._parsedProps.schTraceAutoLabelEnabled&&yGt(N,I)>=5&&(n._isSymbolToChipConnection()||n._isSymbolToSymbolConnection()||n._isChipToChipConnection())){n._doInitialSchematicTraceRenderWithDisplayLabel();return}let pe=e.schematic_trace.insert({source_trace_id:n.source_trace_id,edges:I,junctions:N});n.schematic_trace_id=pe.schematic_trace_id;for(let{port:xe}of d)xe.schematic_port_id&&e.schematic_port.update(xe.schematic_port_id,{is_connected:!0});y?._connectedSchematicPortPairs&&y._connectedSchematicPortPairs.add(m)};function Rwe(n){let e=0;for(let a=0;a<n.length;a++){let s=n[a];if(s.route_type==="wire"){let l=n[a+1];if(l){let d=l.x-s.x,x=l.y-s.y;e+=Math.sqrt(d*d+x*x)}}else s.route_type==="via"&&(e+=1.6)}return e}var NS=n=>({...n._getGlobalPcbPositionAfterLayout(),layers:n.getAvailablePcbLayers()}),kGt=!1;function MGt(n){if(n.root?.pcbDisabled)return;let{db:e}=n.root,{_parsedProps:a,parent:s}=n,l=n.getSubcircuit();if(!s)throw new Error("Trace has no parent");if(l._parsedProps.routingDisabled)return;let d=l._parsedProps.pcbRouteCache?.pcbTraces;if(d){let W=e.pcb_trace.insert({route:d.flatMap(Q=>Q.route),source_trace_id:n.source_trace_id,subcircuit_id:l?.subcircuit_id??void 0,pcb_group_id:n.getGroup()?.pcb_group_id??void 0});n.pcb_trace_id=W.pcb_trace_id;return}if(a.pcbPath&&a.pcbPath.length>0||!l._shouldUseTraceByTraceRouting())return;let{allPortsFound:x,ports:f}=n._findConnectedPorts(),m=[];if(!x)return;let y=[];for(let W of f)W._hasMatchedPcbPrimitive()||y.push(W);if(y.length>0){e.pcb_trace_error.insert({error_type:"pcb_trace_error",source_trace_id:n.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, ${n} wasn't routed. Missing ports: ${y.map(W=>W.getString()).join(", ")}`,pcb_trace_id:n.pcb_trace_id,pcb_component_ids:[],pcb_port_ids:y.map(W=>W.pcb_port_id).filter(Boolean)});return}let b=n._findConnectedNets().netsWithSelectors;if(f.length===0&&b.length===2){n.renderError("Trace connects two nets, we haven't implemented a way to route this yet");return}else if(f.length===1&&b.length===1){let W=f[0],le=b[0].net.getAllConnectedPorts().filter(pe=>pe!==W);if(le.length===0){console.log("Nothing to connect this port to, the net is empty. TODO should emit a warning!");return}let z=gGt(W,le);m.push(z),f.push(z)}else if(f.length>1&&b.length>=1){n.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 E=f.flatMap(W=>W.matchedComponents.filter(Q=>Q.componentName==="TraceHint")),A=(n._parsedProps.pcbRouteHints??[]).concat(E.flatMap(W=>W.getPcbRouteHints()));if(f.length>2){n.renderError(`Trace has more than two ports (${f.map(W=>W.getString()).join(", ")}), routing between more than two ports for a single trace is not implemented`);return}if(n.getSubcircuit().selectAll("trace").filter(W=>W.renderPhaseStates.PcbTraceRender.initialized).some(W=>W._portsRoutedOnPcb.length===f.length&&W._portsRoutedOnPcb.every(Q=>f.includes(Q))))return;let I=[];A.length===0?I=[NS(f[0]),NS(f[1])]:I=[NS(f[0]),...A,NS(f[1])];let q=OS(I);if(kGt&&q.length===0){n.renderError(`Could not find a common layer (using hints) for trace ${n.getString()}`);return}let G=Ku(n.root.db.toArray()),[j,O]=DGt(()=>Awe(n.root.db.toArray()));if(O){n.renderError({type:"pcb_trace_error",error_type:"pcb_trace_error",pcb_trace_error_id:n.pcb_trace_id,message:`Error getting obstacles for autorouting: ${O.message}`,source_trace_id:n.source_trace_id,center:{x:0,y:0},pcb_port_ids:f.map(W=>W.pcb_port_id),pcb_trace_id:n.pcb_trace_id,pcb_component_ids:[]});return}for(let W of j)if(W.connectedTo.length>0){let le=G.getNetConnectedToId(W.connectedTo[0]);le&&W.connectedTo.push(le)}let V=[];if(q.length===0)V=I;else{let W=q[0].layer_path;V=I.map((Q,le)=>Q.via?{...Q,via_to_layer:W[le]}:{...Q,layers:[W[le]]})}V[0].pcb_port_id=f[0].pcb_port_id,V[V.length-1].pcb_port_id=f[1].pcb_port_id;let te=[];for(let[W,Q]of Fwe(V)){let le="via_to_layer"in W?W.via_to_layer:null,z=2,pe="layers"in W&&W.layers.length===1?W.layers[0]:le??"top",xe="layers"in Q&&Q.layers.length===1?Q.layers[0]:le??"top",Ae="pcb_port_id"in W?W.pcb_port_id:null,Ie="pcb_port_id"in Q?Q.pcb_port_id:null,Le=n.getSubcircuit()._parsedProps.minTraceWidth??.16,dt=new ZR({OBSTACLE_MARGIN:Le*2,isRemovePathLoopsEnabled:!0,optimizeWithGoalBoxes:!!(Ae&&Ie),connMap:G,input:{obstacles:j,minTraceWidth:Le,connections:[{name:n.source_trace_id,pointsToConnect:[{...W,layer:pe,pcb_port_id:Ae},{...Q,layer:xe,pcb_port_id:Ie}]}],layerCount:n.getSubcircuit()._getSubcircuitLayerCount(),bounds:{minX:Math.min(W.x,Q.x)-z,maxX:Math.max(W.x,Q.x)+z,minY:Math.min(W.y,Q.y)-z,maxY:Math.max(W.y,Q.y)+z}}}),rt=null;try{rt=dt.solveAndMapToTraces()}catch(Mt){n.renderError({type:"pcb_trace_error",pcb_trace_error_id:n.source_trace_id,error_type:"pcb_trace_error",message:`error solving route: ${Mt.message}`,source_trace_id:n.pcb_trace_id,center:{x:(W.x+Q.x)/2,y:(W.y+Q.y)/2},pcb_port_ids:f.map(Pt=>Pt.pcb_port_id),pcb_trace_id:n.pcb_trace_id,pcb_component_ids:f.map(Pt=>Pt.pcb_component_id)})}if(!rt)return;if(rt.length===0){n.renderError({type:"pcb_trace_error",error_type:"pcb_trace_error",pcb_trace_error_id:n.pcb_trace_id,message:`Could not find a route for ${n}`,source_trace_id:n.source_trace_id,center:{x:(W.x+Q.x)/2,y:(W.y+Q.y)/2},pcb_port_ids:f.map(Mt=>Mt.pcb_port_id),pcb_trace_id:n.pcb_trace_id,pcb_component_ids:f.map(Mt=>Mt.pcb_component_id)});return}let[et]=rt;le&&(et.route=et.route.map(Mt=>(Mt.route_type==="wire"&&!Mt.layer&&(Mt.layer=le),Mt))),Ae&&et.route[0].route_type==="wire"&&(et.route[0].start_pcb_port_id=Ae);let Qe=et.route[et.route.length-1];Ie&&Qe.route_type==="wire"&&(Qe.end_pcb_port_id=Ie),te.push(et.route)}let N=hGt(te),se=Rwe(N),$=e.pcb_trace.insert({route:N,source_trace_id:n.source_trace_id,subcircuit_id:n.getSubcircuit()?.subcircuit_id,trace_length:se});n._portsRoutedOnPcb=f,n.pcb_trace_id=$.pcb_trace_id;for(let W of N)W.route_type==="via"&&e.pcb_via.insert({pcb_trace_id:$.pcb_trace_id,x:W.x,y:W.y,hole_diameter:.3,outer_diameter:.6,layers:[W.from_layer,W.to_layer],from_layer:W.from_layer,to_layer:W.to_layer});n._insertErrorIfTraceIsOutsideBoard(N,f)}function OGt(n){if(n.root?.pcbDisabled)return;let{db:e}=n.root,{_parsedProps:a}=n,s=n.getSubcircuit();if(!a.pcbPath||a.pcbPath.length===0)return;let{allPortsFound:l,ports:d,portsWithSelectors:x}=n._findConnectedPorts();if(!l)return;let f=[];for(let G of d)G._hasMatchedPcbPrimitive()||f.push(G);if(f.length>0){e.pcb_trace_error.insert({error_type:"pcb_trace_error",source_trace_id:n.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, ${n} wasn't routed. Missing ports: ${f.map(G=>G.getString()).join(", ")}`,pcb_trace_id:n.pcb_trace_id,pcb_component_ids:[],pcb_port_ids:f.map(G=>G.pcb_port_id).filter(Boolean)});return}let m;a.pcbPathRelativeTo&&(m=x.find(G=>G.selector===a.pcbPathRelativeTo)?.port,m||(m=n.getSubcircuit().selectOne(a.pcbPathRelativeTo))),m||(m=d[0]);let y=d.find(G=>G!==m)??d[1],b=m.getAvailablePcbLayers()[0]||"top",E=a.thickness??n.getSubcircuit()._parsedProps.minTraceWidth??.16,A=m._getGlobalPcbPositionAfterLayout(),w=y._getGlobalPcbPositionAfterLayout(),B=[];B.push({route_type:"wire",x:A.x,y:A.y,width:E,layer:b,start_pcb_port_id:m.pcb_port_id});for(let G of a.pcbPath)B.push({route_type:"wire",x:A.x+G.x,y:A.y+G.y,width:E,layer:b});B.push({route_type:"wire",x:w.x,y:w.y,width:E,layer:b,end_pcb_port_id:y.pcb_port_id});let I=Rwe(B),q=e.pcb_trace.insert({route:B,source_trace_id:n.source_trace_id,subcircuit_id:s?.subcircuit_id??void 0,pcb_group_id:n.getGroup()?.pcb_group_id??void 0,trace_length:I});n._portsRoutedOnPcb=d,n.pcb_trace_id=q.pcb_trace_id,n._insertErrorIfTraceIsOutsideBoard(B,d)}function LGt(n){if(n.root?.schematicDisabled)return;let{db:e}=n.root,{_parsedProps:a,parent:s}=n;if(!s)throw new Error("Trace has no parent");let{allPortsFound:l,portsWithSelectors:d}=n._findConnectedPorts();if(!l)return;let x=d.map(({port:V})=>({port:V,position:V._getGlobalSchematicPositionAfterLayout(),schematic_port_id:V.schematic_port_id,facingDirection:V.facingDirection}));if(x.length<2)throw new Error("Expected at least two ports in portsWithPosition.");let f,m,y=x[0].position,b=x[0].port;if("path"in n.props){if(n.props.path.length!==2)throw new Error("Invalid 'path': Must contain exactly two elements.");[f,m]=n.props.path}else{if(!("from"in n.props&&"to"in n.props))throw new Error("Missing 'from' or 'to' properties in props.");f=n.props.from,m=n.props.to}if(!b.source_port_id)throw new Error(`Missing source_port_id for the 'from' port (${f}).`);let E=x[1].position,A=x[1].port;if(!A.source_port_id)throw new Error(`Missing source_port_id for the 'to' port (${m}).`);let w=e.schematic_net_label.list().find(V=>V.source_net_id===b.source_port_id),B=e.schematic_net_label.list().find(V=>V.source_net_id===A.source_port_id),[I,q]=d.map(({port:V})=>V),j=I.parent?.config.shouldRenderAsSchematicBox?`${I?.parent?.props.name}_${I?.props.name}`:`${q?.parent?.props.name}_${q?.props.name}`,O=n.props.schDisplayLabel??j;if(w&&w.text!==O&&(w.text=`${O} / ${w.text}`),B&&B?.text!==O&&(B.text=`${O} / ${B.text}`),!B){let V=qF(A.facingDirection)??"bottom";e.schematic_net_label.insert({text:n.props.schDisplayLabel??j,source_net_id:A.source_port_id,anchor_position:E,center:nx({anchor_position:E,anchor_side:V,text:n.props.schDisplayLabel??j}),anchor_side:V})}if(!w){let V=qF(b.facingDirection)??"bottom";e.schematic_net_label.insert({text:n.props.schDisplayLabel??j,source_net_id:b.source_port_id,anchor_position:y,center:nx({anchor_position:y,anchor_side:V,text:n.props.schDisplayLabel??j}),anchor_side:V})}}function $Gt(n){let{_parsedProps:e,parent:a}=n;if(!a)throw new Error("Trace has no parent");let l=n.getTracePortPathSelectors().map(d=>({selector:d,port:n.getSubcircuit().selectOne(d,{type:"port"})??null}));for(let{selector:d,port:x}of l)if(!x){let f,m,y=d.lastIndexOf(".");if(y!==-1&&y>d.lastIndexOf(" "))f=d.slice(0,y),m=d.slice(y+1);else{let V=d.match(/^(.*[ >])?([^ >]+)$/);f=V?.[1]?.trim()??"",m=V?.[2]??d}let b=f?n.getSubcircuit().selectOne(f):null;if(!b&&f&&!/[.#\[]/.test(f)&&(b=n.getSubcircuit().selectOne(`.${f}`)),!b){let V=f?`Could not find port for selector "${d}". Component "${f}" not found`:`Could not find port for selector "${d}"`,te=n.getSubcircuit(),N=te.getGroup();throw new US({error_type:"source_trace_not_connected_error",message:V,subcircuit_id:te.subcircuit_id??void 0,source_group_id:N?.source_group_id??void 0,source_trace_id:n.source_trace_id??void 0,selectors_not_found:[d]})}let E=b.children.filter(V=>V.componentName==="Port"),A=m.includes(".")?m.split(".").pop()??"":m,w=E.flatMap(V=>V.getNameAndAliases()),B=w.some(V=>!/^(pin\d+|\d+)$/.test(V)),I=Array.from(new Set(w)).join(", "),q;E.length===0?q="It has no ports":B?q=`It has [${I}]`:q=`It has ${E.length} pins and no pinLabels (consider adding pinLabels)`;let G=`Could not find port for selector "${d}". Component "${b.props.name??f}" found, but does not have pin "${A}". ${q}`,j=n.getSubcircuit(),O=j.getGroup();throw new US({error_type:"source_trace_not_connected_error",message:G,subcircuit_id:j.subcircuit_id??void 0,source_group_id:O?.source_group_id??void 0,source_trace_id:n.source_trace_id??void 0,selectors_not_found:[d]})}return l.some(d=>!d.port)?{allPortsFound:!1}:{allPortsFound:!0,portsWithSelectors:l,ports:l.map(({port:d})=>d)}}var zc=class extends ga{constructor(e){super(e);X(this,"source_trace_id",null);X(this,"pcb_trace_id",null);X(this,"schematic_trace_id",null);X(this,"_portsRoutedOnPcb");X(this,"subcircuit_connectivity_map_key",null);X(this,"_traceConnectionHash",null);X(this,"_couldNotFindPort");this._portsRoutedOnPcb=[]}get config(){return{zodProps:G8e,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(e=>typeof e=="string"?e:e.getPortSelector()):[]}getTracePortPathSelectors(){return this._getTracePortOrNetSelectorListFromProps().filter(e=>!e.includes("net."))}getTracePathNetSelectors(){return this._getTracePortOrNetSelectorListFromProps().filter(e=>e.includes("net."))}_findConnectedPorts(){return $Gt(this)}_resolveNet(e){let a=this.getSubcircuit().selectOne(e,{type:"net"});if(a)return a;let s=e.match(/^net\.(.+)$/),l=s?s[1]:null;return l&&this.root._getBoard().getDescendants().find(x=>x.componentName==="Net"&&x._parsedProps.name===l)||null}_findConnectedNets(){let e=this.getTracePathNetSelectors().map(s=>({selector:s,net:this._resolveNet(s)})),a=e.filter(s=>!s.net);return a.length>0&&this.renderError(`Could not find net for selector "${a[0].selector}" inside ${this}`),{netsWithSelectors:e,nets:e.map(s=>s.net)}}_getAllTracesConnectedToSameNet(){let e=this.getSubcircuit().selectAll("trace"),a=this._findConnectedNets().nets,s=this._findConnectedPorts().ports??[];return e.filter(l=>{if(l===this)return!1;let d=l._findConnectedNets().nets,x=l._findConnectedPorts().ports??[];return d.some(f=>a.includes(f))||x.some(f=>s.includes(f))})}_isExplicitlyConnectedToPort(e){let{allPortsFound:a,portsWithSelectors:s}=this._findConnectedPorts();return a?s.map(d=>d.port).includes(e):!1}_isExplicitlyConnectedToNet(e){return this._findConnectedNets().nets.includes(e)}doInitialCreateNetsFromProps(){zW(this,this.getTracePathNetSelectors())}_computeTraceConnectionHash(){let{allPortsFound:e,ports:a}=this._findConnectedPorts();return!e||!a?null:[...a].sort((d,x)=>(d.pcb_port_id||"").localeCompare(x.pcb_port_id||"")).map(d=>d.pcb_port_id).join(",")}doInitialSourceTraceRender(){let{db:e}=this.root,{_parsedProps:a,parent:s}=this;if(!s){this.renderError("Trace has no parent");return}let l,d;try{let E=this._findConnectedPorts();l=E.allPortsFound,d=E.portsWithSelectors??[]}catch(E){if(E instanceof US){e.source_trace_not_connected_error.insert({...E.errorData,error_type:"source_trace_not_connected_error"}),this._couldNotFindPort=!0;return}throw E}if(!l)return;this._traceConnectionHash=this._computeTraceConnectionHash();let f=e.source_trace.list().find(E=>E.subcircuit_connectivity_map_key===this.subcircuit_connectivity_map_key&&E.connected_source_port_ids.sort().join(",")===this._traceConnectionHash);if(f){this.source_trace_id=f.source_trace_id;return}let m=this._findConnectedNets().nets,y=FGt({ports:d,nets:m}),b=e.source_trace.insert({connected_source_port_ids:d.map(E=>E.port.source_port_id),connected_source_net_ids:m.map(E=>E.source_net_id),subcircuit_id:this.getSubcircuit()?.subcircuit_id,max_length:bGt(d.map(E=>E.port),{db:e})??a.maxLength,display_name:y,min_trace_thickness:a.thickness});this.source_trace_id=b.source_trace_id}_insertErrorIfTraceIsOutsideBoard(e,a){let{db:s}=this.root;EGt(e,{db:s})&&s.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:a.map(d=>d.pcb_port_id)})}doInitialPcbManualTraceRender(){OGt(this)}doInitialPcbTraceRender(){MGt(this)}_doInitialSchematicTraceRenderWithDisplayLabel(){LGt(this)}_isSymbolToChipConnection(){let{allPortsFound:e,ports:a}=this._findConnectedPorts();if(!e||a.length!==2)return!1;let[s,l]=a;if(!s?.parent||!l?.parent)return!1;let d=s.parent.config.shouldRenderAsSchematicBox,x=l.parent.config.shouldRenderAsSchematicBox;return d&&!x||!d&&x}_isSymbolToSymbolConnection(){let{allPortsFound:e,ports:a}=this._findConnectedPorts();if(!e||a.length!==2)return!1;let[s,l]=a;if(!s?.parent||!l?.parent)return!1;let d=!s.parent.config.shouldRenderAsSchematicBox,x=!l.parent.config.shouldRenderAsSchematicBox;return d&&x}_isChipToChipConnection(){let{allPortsFound:e,ports:a}=this._findConnectedPorts();if(!e||a.length!==2)return!1;let[s,l]=a;if(!s?.parent||!l?.parent)return!1;let d=s.parent.config.shouldRenderAsSchematicBox,x=l.parent.config.shouldRenderAsSchematicBox;return d&&x}doInitialSchematicTraceRender(){NGt(this)}},zGt=n=>{let{db:e}=n.root;if(n.pcb_component_id){let a=e.pcb_component.get(n.pcb_component_id);return a?{width:a.width,height:a.height}:null}if(n.pcb_group_id){let a=e.pcb_group.get(n.pcb_group_id);return a?{width:a.width,height:a.height}:null}return null},qGt=(n,e)=>{let{db:a}=n.root,s=a.toArray();if(n.pcb_component_id){m5(s,n.pcb_component_id,e);return}if(n.source_group_id){g5(s,n.source_group_id,e);return}throw new Error(`Cannot reposition component ${n.getString()}: no pcb_component_id or source_group_id`)},UGt=n=>{let{db:e}=n.root;if(!n.source_component_id)return;let a=n.selectAll("port"),s=e.source_trace.list(),l=new Set;for(let x of s)for(let f of x.connected_source_port_ids)l.add(f);let d=n._getInternallyConnectedPins();for(let x of d)if(x.some(f=>f.source_port_id&&l.has(f.source_port_id)))for(let f of x)f.source_port_id&&l.add(f.source_port_id);for(let x of a)x.source_port_id&&VGt(n,x)&&(l.has(x.source_port_id)||e.source_pin_missing_trace_warning.insert({message:`Port ${x.getNameAndAliases()[0]} on ${n.props.name} is missing a trace`,source_component_id:n.source_component_id,source_port_id:x.source_port_id,subcircuit_id:n.getSubcircuit().subcircuit_id??void 0,warning_type:"source_pin_missing_trace_warning"}))},VGt=(n,e)=>{if(n.config.componentName==="Chip"){let a=n.props.pinAttributes;if(!a)return!1;for(let s of e.getNameAndAliases()){let l=a[s];if(l?.requiresPower||l?.requiresGround||l?.requiresVoltage!==void 0)return!0}return!1}return!0},GGt=(0,mwe.default)("tscircuit:core"),XGt=C.object({x:Ia,y:Ia,z:Ia}),Za=class extends ga{constructor(e){super(e);X(this,"reactSubtrees",[]);X(this,"_impliedFootprint");X(this,"isPrimitiveContainer",!0);X(this,"_asyncSupplierPartNumbers");X(this,"pcb_missing_footprint_error_id");X(this,"_hasStartedFootprintUrlLoad",!1);this._addChildrenFromStringFootprint(),this.initPorts()}get defaultInternallyConnectedPinNames(){return[]}get internallyConnectedPinNames(){return(this._parsedProps.internallyConnectedPins??this.defaultInternallyConnectedPinNames).map(a=>a.map(s=>typeof s=="number"?`pin${s}`:s))}initPorts(e={}){if(this.root?.schematicDisabled)return;let{config:a}=this,s=[],l=this._getSchematicPortArrangement();if(l&&!this._parsedProps.pinLabels){for(let y in l){let b=l[y].pins;if(Array.isArray(b))for(let E of b){let A=zF(E,this._parsedProps.pinLabels);s.push(new Fo({pinNumber:A,aliases:e.additionalAliases?.[`pin${A}`]??[]},{originDescription:`schPortArrangement:${y}`}))}}let f=["left","right","top","bottom"],m=1;for(let y of f){let b=l[`${y}Size`];for(let E=0;E<b;E++)s.push(new Fo({pinNumber:m++,aliases:e.additionalAliases?.[`pin${m}`]??[]},{originDescription:`schPortArrangement:${y}`}))}}let d=this._parsedProps.pinLabels;if(d)for(let[f,m]of Object.entries(d)){f=f.replace("pin","");let y=s.find(A=>A._parsedProps.pinNumber===Number(f)),b=Array.isArray(m)?m[0]:m,E=Array.isArray(m)?m.slice(1):[];y?(y.externallyAddedAliases.push(b,...E),y.props.name=b):(y=new Fo({pinNumber:parseInt(f),name:b,aliases:[...E,...e.additionalAliases?.[`pin${parseInt(f)}`]??[]]},{originDescription:`pinLabels:pin${f}`}),s.push(y))}if(a.schematicSymbolName&&!e.ignoreSymbolPorts){let f=Ts[this._getSchematicSymbolNameOrThrow()];if(!f)return;for(let m of f.ports){let y=Ewe(m.labels);if(!y)continue;let b=s.find(E=>E._parsedProps.pinNumber===Number(y));if(b)b.schematicSymbolPortDef=m;else{let E=kF(m.labels.concat(e.additionalAliases?.[`pin${y}`]??[]));E&&(E.originDescription=`schematicSymbol:labels[0]:${m.labels[0]}`,E.schematicSymbolPortDef=m,s.push(E))}}this.addAll(s)}if(!this._getSchematicPortArrangement()){let f=this.getPortsFromFootprint(e);for(let m of f)s.some(y=>y.isMatchingAnyOf(m.getNameAndAliases()))||s.push(m)}let x=e.pinCount??this._getPinCount()??0;for(let f=1;f<=x;f++){if(s.find(y=>y._parsedProps.pinNumber===f))continue;if(!l){s.push(new Fo({pinNumber:f,aliases:e.additionalAliases?.[`pin${f}`]??[]}));continue}let m=[...l.leftSide?.pins??[],...l.rightSide?.pins??[],...l.topSide?.pins??[],...l.bottomSide?.pins??[]].map(y=>zF(y,this._parsedProps.pinLabels));["leftSize","rightSize","topSize","bottomSize","leftPinCount","rightPinCount","topPinCount","bottomPinCount"].some(y=>y in l)&&(m=Array.from({length:this._getPinCount()},(y,b)=>b+1)),m.includes(f)&&s.push(new Fo({pinNumber:f,aliases:e.additionalAliases?.[`pin${f}`]??[]},{originDescription:`notOtherwiseAddedButDeducedFromPinCount:${f}`}))}s.length>0&&this.addAll(s)}_getImpliedFootprintString(){return null}_isFootprintUrl(e){return e.startsWith("http://")||e.startsWith("https://")}_addChildrenFromStringFootprint(){let{pcbRotation:e,pinLabels:a,pcbPinLabels:s}=this.props,{footprint:l}=this.props;if(l??(l=this._getImpliedFootprintString?.()),!!l&&typeof l=="string"){if(this._isFootprintUrl(l))return;let d=Bq.string(l).soup(),x=JSe({componentName:this.name??this.componentName,componentRotation:e,footprint:l,pinLabels:a,pcbPinLabels:s},d);this.addAll(x)}}get portMap(){return new Proxy({},{get:(e,a)=>{let s=this.children.find(l=>l.componentName==="Port"&&l.isMatchingNameOrAlias(a));if(!s)throw new Error(`There was an issue finding the port "${a.toString()}" inside of a ${this.componentName} component with name: "${this.props.name}". This is a bug in @tscircuit/core`);return s}})}getInstanceForReactElement(e){for(let a of this.reactSubtrees)if(a.element===e)return a.component;return null}doInitialSourceRender(){let e=this.config.sourceFtype;if(!e)return;let{db:a}=this.root,{_parsedProps:s}=this,l=a.source_component.insert({ftype:e,name:this.name,manufacturer_part_number:s.manufacturerPartNumber??s.mfn,supplier_part_numbers:s.supplierPartNumbers});this.source_component_id=l.source_component_id}doInitialSchematicComponentRender(){if(this.root?.schematicDisabled)return;let{db:e}=this.root,{schematicSymbolName:a}=this.config;a?this._doInitialSchematicComponentRenderWithSymbol():this._getSchematicBoxDimensions()&&this._doInitialSchematicComponentRenderWithSchematicBoxDimensions();let s=this.getSubcircuit()?._getSchematicManualPlacementForComponent(this);if(this.schematic_component_id&&(this.props.schX!==void 0||this.props.schY!==void 0)&&s){if(!this.schematic_component_id)return;let l=OA.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});e.schematic_manual_edit_conflict_warning.insert(l)}}_getSchematicSymbolDisplayValue(){}_getInternallyConnectedPins(){if(this.internallyConnectedPinNames.length===0)return[];let e=[];for(let a of this.internallyConnectedPinNames){let s=[];for(let l of a)s.push(this.portMap[l]);e.push(s)}return e}_doInitialSchematicComponentRenderWithSymbol(){if(this.root?.schematicDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,s=this._getSchematicSymbolNameOrThrow(),l=Ts[s],d=this._getGlobalSchematicPositionBeforeLayout();if(l){let x=e.schematic_component.insert({center:d,size:l.size,source_component_id:this.source_component_id,symbol_name:s,symbol_display_value:this._getSchematicSymbolDisplayValue()});this.schematic_component_id=x.schematic_component_id}}_doInitialSchematicComponentRenderWithSchematicBoxDimensions(){if(this.root?.schematicDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,s=this._getSchematicBoxDimensions(),l={};if(Array.isArray(a.pinLabels))a.pinLabels.forEach((w,B)=>{l[String(B+1)]=w});else for(let[w,B]of Object.entries(a.pinLabels??{}))l[w]=Array.isArray(B)?B[0]:B;let d=this._getGlobalSchematicPositionBeforeLayout(),x=this._getSchematicPortArrangement(),f=e.schematic_component.insert({center:d,rotation:a.schRotation??0,size:s.getSize(),port_arrangement:eGt(x),pin_spacing:a.schPinSpacing??.2,pin_styles:QVt(a.schPinStyle,a.pinLabels),port_labels:l,source_component_id:this.source_component_id}),m=x?.topSide!==void 0||x?.bottomSide!==void 0,y=s?.getSize().width,b=s?.getSize().height,E=e.schematic_text.insert({text:a.manufacturerPartNumber??"",schematic_component_id:f.schematic_component_id,anchor:"left",rotation:0,position:{x:m?d.x+(y??0)/2+.1:d.x-(y??0)/2,y:m?d.y+(b??0)/2+.35:d.y-(b??0)/2-.13},color:"#006464",font_size:.18}),A=e.schematic_text.insert({text:a.name??"",schematic_component_id:f.schematic_component_id,anchor:"left",rotation:0,position:{x:m?d.x+(y??0)/2+.1:d.x-(y??0)/2,y:m?d.y+(b??0)/2+.55:d.y+(b??0)/2+.13},color:"#006464",font_size:.18});this.schematic_component_id=f.schematic_component_id}doInitialPcbComponentRender(){if(this.root?.pcbDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,s=this.getSubcircuit(),l=e.pcb_component.insert({center:this._getGlobalPcbPositionBeforeLayout(),width:0,height:0,layer:a.layer??"top",rotation:a.pcbRotation??0,source_component_id:this.source_component_id,subcircuit_id:s.subcircuit_id??void 0});if(!(a.footprint??this._getImpliedFootprintString())&&!this.isGroup){let f=e.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=f.pcb_missing_footprint_error_id}this.pcb_component_id=l.pcb_component_id;let x=this.getSubcircuit()._getPcbManualPlacementForComponent(this);if((this.props.pcbX!==void 0||this.props.pcbY!==void 0)&&x){let f=$A.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:s.subcircuit_id??void 0});e.pcb_manual_edit_conflict_warning.insert(f)}}doInitialPcbComponentSizeCalculation(){if(this.root?.pcbDisabled||!this.pcb_component_id)return;let{db:e}=this.root,{_parsedProps:a}=this,s=GW(this.children);if(s.width===0||s.height===0)return;let l={x:(s.minX+s.maxX)/2,y:(s.minY+s.maxY)/2};e.pcb_component.update(this.pcb_component_id,{center:l,width:s.width,height:s.height})}_renderReactSubtree(e){return{element:e,component:bwe(e)}}doInitialInitializePortsFromChildren(){this.initPorts()}doInitialReactSubtreesRender(){}doInitialPcbFootprintStringRender(){let{footprint:e}=this.props;if(e??(e=this._getImpliedFootprintString?.()),!e)return;let{pcbRotation:a,pinLabels:s,pcbPinLabels:l}=this.props;if(typeof e=="string"&&this._isFootprintUrl(e)){if(this._hasStartedFootprintUrlLoad)return;this._hasStartedFootprintUrlLoad=!0;let d=e;this._queueAsyncEffect("load-footprint-url",async()=>{let f=await(await fetch(d)).json(),m=JSe({componentName:this.name,componentRotation:a,footprint:d,pinLabels:s,pcbPinLabels:l},f);this.addAll(m),this._markDirty("InitializePortsFromChildren")});return}if((0,w1.isValidElement)(e)){if(this.reactSubtrees.some(x=>x.element===e))return;let d=this._renderReactSubtree(e);this.reactSubtrees.push(d),this.add(d.component);return}!(0,w1.isValidElement)(e)&&e.componentName==="Footprint"&&this.add(e)}_hasExistingPortExactly(e){return this.children.filter(s=>s.componentName==="Port").some(s=>{let l=e.getNameAndAliases(),d=s.getNameAndAliases();return l.length===d.length&&l.every(x=>d.includes(x))})}add(e){let a;if((0,w1.isValidElement)(e)){let s=this._renderReactSubtree(e);this.reactSubtrees.push(s),a=s.component}else a=e;if(a.componentName==="Port"){if(this._hasExistingPortExactly(a))return;let l=this.children.filter(d=>d.componentName==="Port").find(d=>d.isMatchingAnyOf(a.getNameAndAliases()));l&&GGt(`Similar ports added. Port 1: ${l}, Port 2: ${a}`)}super.add(a)}getPortsFromFootprint(e){let{footprint:a}=this.props;if((!a||(0,w1.isValidElement)(a))&&(a=this.children.find(l=>l.componentName==="Footprint")),typeof a=="string"){if(this._isFootprintUrl(a))return[];let l=Bq.string(a).soup(),d=[];for(let x of l)if("port_hints"in x&&x.port_hints){let f=kF(x.port_hints,e);if(!f)continue;f.originDescription=`footprint:string:${a}:port_hints[0]:${x.port_hints[0]}`,d.push(f)}return d}if(!(0,w1.isValidElement)(a)&&a&&a.componentName==="Footprint"){let l=a,d=1,x=[];for(let f of l.children){if(!f.props.portHints)continue;let m=f.props.portHints;m.some(E=>E.startsWith("pin"))||(m=[...m,`pin${d}`]),d++;let b=kF(m);b&&(b.originDescription=`footprint:${a}`,x.push(b))}return x}let s=[];if(!a){for(let l of this.children)if(l.props.portHints&&l.isPcbPrimitive){let d=kF(l.props.portHints);d&&s.push(d)}}return s}getPortsFromSchematicSymbol(){if(this.root?.schematicDisabled)return[];let{config:e}=this;if(!e.schematicSymbolName)return[];let a=Ts[e.schematicSymbolName];if(!a)return[];let s=[];for(let l of a.ports){let d=kF(l.labels);d&&(d.schematicSymbolPortDef=l,s.push(d))}return s}doInitialCreateNetsFromProps(){this._createNetsFromProps(this._getNetsFromConnectionsProp())}_getNetsFromConnectionsProp(){let{_parsedProps:e}=this,a=[];if(e.connections)for(let[s,l]of Object.entries(e.connections)){let d=Array.isArray(l)?l:[l];for(let x of d)a.push(x)}return a}_createNetsFromProps(e){zW(this,e)}_getPcbCircuitJsonBounds(){let{db:e}=this.root;if(!this.pcb_component_id)return super._getPcbCircuitJsonBounds();let a=e.pcb_component.get(this.pcb_component_id);return{center:{x:a.center.x,y:a.center.y},bounds:{left:a.center.x-a.width/2,top:a.center.y-a.height/2,right:a.center.x+a.width/2,bottom:a.center.y+a.height/2},width:a.width,height:a.height}}_getPinCountFromSchematicPortArrangement(){let e=this._getSchematicPortArrangement();if(!e)return 0;if(!vwe(e))return(e.leftSize??e.leftPinCount??0)+(e.rightSize??e.rightPinCount??0)+(e.topSize??e.topPinCount??0)+(e.bottomSize??e.bottomPinCount??0);let{leftSide:s,rightSide:l,topSide:d,bottomSide:x}=e;return Math.max(...s?.pins??[],...l?.pins??[],...d?.pins??[],...x?.pins??[])}_getPinCount(){if(this._getSchematicPortArrangement())return this._getPinCountFromSchematicPortArrangement();let a=this.getPortsFromFootprint();if(a.length>0)return a.length;let{pinLabels:s}=this._parsedProps;if(s){if(Array.isArray(s))return s.length;let l=Object.keys(s).map(d=>d.startsWith("pin")?parseInt(d.slice(3)):parseInt(d)).filter(d=>!Number.isNaN(d));return l.length>0?Math.max(...l):Object.keys(s).length}return 0}_getSchematicPortArrangement(){return this._parsedProps.schPinArrangement??this._parsedProps.schPortArrangement}_getSchematicBoxDimensions(){if(this.getSchematicSymbol()||!this.config.shouldRenderAsSchematicBox)return null;let{_parsedProps:e}=this,a=this._getPinCount(),s=e.schPinSpacing??.2;return dGt({schWidth:e.schWidth,schHeight:e.schHeight,schPinSpacing:s,numericSchPinStyle:xGt(e.schPinStyle,e.pinLabels),pinCount:a,schPortArrangement:this._getSchematicPortArrangement(),pinLabels:e.pinLabels})}doInitialCadModelRender(){let{db:e}=this.root,{boardThickness:a=0}=this.root?._getBoard()??{},s=this._parsedProps.cadModel,l=this.props.footprint??this._getImpliedFootprintString();if(!this.pcb_component_id||!s&&!l||s===null)return;let d=this._getPcbCircuitJsonBounds(),x=e.pcb_component.get(this.pcb_component_id);if(typeof s=="string")throw new Error("String cadModel not yet implemented");let f=XGt.parse({x:0,y:0,z:typeof s?.rotationOffset=="number"?s.rotationOffset:0,...typeof s?.rotationOffset=="object"?s.rotationOffset??{}:{}}),m=Uf.parse({x:0,y:0,z:0,...typeof s?.positionOffset=="object"?s.positionOffset:{}}),y=this.props.layer==="bottom"?"bottom":"top",b=e.cad_component.insert({position:{x:d.center.x+m.x,y:d.center.y+m.y,z:(y==="bottom"?-a/2:a/2)+m.z},rotation:{x:f.x,y:(y==="top"?0:180)+f.y,z:y==="bottom"?-((x?.rotation??0)+f.z)+180:(x?.rotation??0)+f.z},pcb_component_id:this.pcb_component_id,source_component_id:this.source_component_id,model_stl_url:"stlUrl"in(s??{})?this._addCachebustToModelUrl(s.stlUrl):void 0,model_obj_url:"objUrl"in(s??{})?this._addCachebustToModelUrl(s.objUrl):void 0,model_jscad:"jscad"in(s??{})?s.jscad:void 0,footprinter_string:typeof l=="string"&&!s?l:void 0})}_addCachebustToModelUrl(e){if(!e||!e.includes("modelcdn.tscircuit.com"))return e;let a=this.root?.getClientOrigin()??"";return`${e}${e.includes("?")?"&":"?"}cachebust_origin=${encodeURIComponent(a)}`}_getPartsEngineCacheKey(e,a){return JSON.stringify({ftype:e.ftype,name:e.name,manufacturer_part_number:e.manufacturer_part_number,footprinterString:a})}async _getSupplierPartNumbers(e,a,s){if(this.props.doNotPlace)return{};let l=this.root?.platform?.localCacheEngine,d=this._getPartsEngineCacheKey(a,s);if(l){let m=await l.getItem(d);if(m)try{return JSON.parse(m)}catch{}}let x=await Promise.resolve(e.findPart({sourceComponent:a,footprinterString:s})),f=x==="Not found"?{}:x;if(l)try{await l.setItem(d,JSON.stringify(f))}catch{}return f}doInitialPartsEngineRender(){if(this.props.doNotPlace)return;let e=this.getInheritedProperty("partsEngine");if(!e)return;let{db:a}=this.root,s=a.source_component.get(this.source_component_id);if(!s||s.supplier_part_numbers)return;let l;this.props.footprint&&typeof this.props.footprint=="string"&&(l=this.props.footprint);let d=this._getSupplierPartNumbers(e,s,l);if(!(d instanceof Promise)){a.source_component.update(this.source_component_id,{supplier_part_numbers:d});return}this._queueAsyncEffect("get-supplier-part-numbers",async()=>{this._asyncSupplierPartNumbers=await d,this._markDirty("PartsEngineRender")})}updatePartsEngineRender(){if(this.props.doNotPlace)return;let{db:e}=this.root,a=e.source_component.get(this.source_component_id);if(a&&!a.supplier_part_numbers&&this._asyncSupplierPartNumbers){e.source_component.update(this.source_component_id,{supplier_part_numbers:this._asyncSupplierPartNumbers});return}}doInitialAssignFallbackProps(){let{_parsedProps:e}=this;e.connections&&!this.name&&(this.fallbackUnassignedName=this.getSubcircuit().getNextAvailableName(this))}doInitialCreateTracesFromProps(){this._createTracesFromConnectionsProp()}_createTracesFromConnectionsProp(){let{_parsedProps:e}=this;if(e.connections)for(let[a,s]of Object.entries(e.connections)){let l=Array.isArray(s)?s:[s];for(let d of l)this.add(new zc({from:`${this.getSubcircuitSelector()} > port.${a}`,to:d}))}}doInitialSourceDesignRuleChecks(){UGt(this)}_getMinimumFlexContainerSize(){return zGt(this)}_repositionOnPcb(e){return qGt(this,e)}},YGt=class{constructor(n,e={}){X(this,"input");X(this,"isRouting",!1);X(this,"solver");X(this,"eventHandlers",{complete:[],error:[],progress:[]});X(this,"cycleCount",0);X(this,"stepDelay");X(this,"timeoutId");this.input=n;let{capacityDepth:a,targetMinCapacity:s,stepDelay:l=0}=e;this.solver=new O4e(n,{capacityDepth:a,targetMinCapacity:s,cacheProvider:null}),this.stepDelay=l}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 MF(this.solver.error||"Routing failed")}):this.emitEvent({type:"complete",traces:this.solver.getOutputSimpleRouteJson().traces||[]}),this.isRouting=!1;return}let n=Date.now(),e=this.solver.iterations;for(;Date.now()-n<250&&!this.solver.failed&&!this.solver.solved;)this.solver.step();let a=(this.solver.iterations-e)/(Date.now()-n)*1e3;this.cycleCount++;let s=this.solver?.preview()||void 0,l=this.solver.progress;this.emitEvent({type:"progress",steps:this.cycleCount,iterationsPerSecond:a,progress:l,phase:this.solver.getCurrentPhase(),debugGraphics:s}),this.stepDelay>0?this.timeoutId=setTimeout(()=>this.runCycleAndQueueNextCycle(),this.stepDelay):this.timeoutId=setTimeout(()=>this.runCycleAndQueueNextCycle(),0)}catch(n){this.emitEvent({type:"error",error:n instanceof Error?new MF(n.message):new MF(String(n))}),this.isRouting=!1}}stop(){this.isRouting&&(this.isRouting=!1,this.timeoutId!==void 0&&(clearTimeout(this.timeoutId),this.timeoutId=void 0))}on(n,e){n==="complete"?this.eventHandlers.complete.push(e):n==="error"?this.eventHandlers.error.push(e):n==="progress"&&this.eventHandlers.progress.push(e)}emitEvent(n){if(n.type==="complete")for(let e of this.eventHandlers.complete)e(n);else if(n.type==="error")for(let e of this.eventHandlers.error)e(n);else if(n.type==="progress")for(let e of this.eventHandlers.progress)e(n)}solveSync(){if(this.solver.solve(),this.solver.failed)throw new MF(this.solver.error||"Routing failed");return this.solver.getOutputSimpleRouteJson().traces||[]}},YW=class extends ga{constructor(){super(...arguments);X(this,"matchedPort",null)}get config(){return{componentName:"TraceHint",zodProps:EAe}}doInitialPortMatching(){let{db:e}=this.root,{_parsedProps:a,parent:s}=this;if(!s)return;if(s.componentName==="Trace"){this.renderError(`Port inference inside trace is not yet supported (${this})`);return}if(!s)throw new Error("TraceHint has no parent");if(!a.for){this.renderError(`TraceHint has no for property (${this})`);return}let l=s.selectOne(a.for,{type:"port"});l||this.renderError(`${this} could not find port for selector "${a.for}"`),this.matchedPort=l,l.registerMatch(this)}getPcbRouteHints(){let{_parsedProps:e}=this,a=e.offset?[e.offset]:e.offsets;if(!a)return[];let s=this._computePcbGlobalTransformBeforeLayout();return a.map(l=>({...vs(s,l),via:l.via,to_layer:l.to_layer,trace_width:l.trace_width}))}doInitialPcbTraceHintRender(){if(this.root?.pcbDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this;e.pcb_trace_hint.insert({pcb_component_id:this.matchedPort?.pcb_component_id,pcb_port_id:this.matchedPort?.pcb_port_id,route:this.getPcbRouteHints()})}},Swe=({circuitJson:n,editEvents:e,manualEditsFile:a})=>{let s={...a,pcb_placements:[...a.pcb_placements??[]]};for(let l of e)if(l.edit_event_type==="edit_pcb_component_location"){let{pcb_component_id:d,new_center:x}=l,f=ua(n).pcb_component.get(d);if(!f)continue;let m=ua(n).source_component.get(f.source_component_id);if(!m)continue;let y=s.pcb_placements?.findIndex(E=>E.selector===m.name),b={selector:m.name,center:x,relative_to:"group_center"};y>=0?s.pcb_placements[y]=b:s.pcb_placements.push(b)}return s},wwe=({circuitJson:n,editEvents:e,manualEditsFile:a})=>{let s={...a,schematic_placements:[...a.schematic_placements??[]]};for(let l of e)if(l.edit_event_type==="edit_schematic_component_location"){let{schematic_component_id:d,new_center:x}=l,f=ua(n).schematic_component.get(d);if(!f)continue;let m=ua(n).source_component.get(f.source_component_id);if(!m)continue;let y=s.schematic_placements?.findIndex(E=>E.selector===m.name),b={selector:m.name,center:x,relative_to:"group_center"};y>=0?s.schematic_placements[y]=b:s.schematic_placements.push(b)}return s},HGt=({circuitJson:n,editEvents:e,manualEditsFile:a})=>{let s=e.filter(x=>x.edit_event_type==="edit_schematic_component_location"),l=e.filter(x=>x.edit_event_type==="edit_pcb_component_location"),d=a;return s.length>0&&(d=wwe({circuitJson:n,editEvents:s,manualEditsFile:d})),l.length>0&&(d=Swe({circuitJson:n,editEvents:l,manualEditsFile:d})),d},WGt=(n,e)=>{if(ua(n).pcb_trace_hint.get(e.pcb_trace_hint_id))n=n.map(s=>s.pcb_trace_hint_id===e.pcb_trace_hint_id?{...s,route:e.route}:s);else{let s=ua(n).pcb_port.get(e.pcb_port_id);n=n.filter(l=>!(l.type==="pcb_trace_hint"&&l.pcb_port_id===e.pcb_port_id)).concat([{type:"pcb_trace_hint",pcb_trace_hint_id:e.pcb_trace_hint_id,route:e.route,pcb_port_id:e.pcb_port_id,pcb_component_id:s?.pcb_component_id}])}return n},KGt=({circuitJson:n,editEvents:e})=>{n=JSON.parse(JSON.stringify(n));for(let a of e)if(a.edit_event_type==="edit_pcb_component_location"){let s=n.find(d=>d.type==="pcb_component"&&d.pcb_component_id===a.pcb_component_id);if((!s||s.center.x!==a.new_center.x||s.center.y!==a.new_center.y)&&a.original_center){let d=ja(a.new_center.x-a.original_center.x,a.new_center.y-a.original_center.y);n=n.map(x=>x.pcb_component_id!==a.pcb_component_id?x:bY(x,d))}}else a.edit_event_type==="edit_schematic_component_location"?n=n.map(s=>s.type==="schematic_component"&&s.schematic_component_id===a.schematic_component_id?{...s,center:a.new_center}:s):a.edit_event_type==="edit_pcb_trace_hint"&&(n=WGt(n,a));return n},Bwe=(n,e)=>{let a=n.source_group.list(),s=[],l=d=>{let x=a.filter(f=>f.parent_subcircuit_id===d);for(let f of x)f.subcircuit_id&&(s.push(f.subcircuit_id),l(f.subcircuit_id))};return l(e),s},MW=({db:n,circuitJson:e,subcircuit_id:a,minTraceWidth:s=.1})=>{if(!n&&e&&(n=ua(e)),!n)throw new Error("db or circuitJson is required");let l=n.pcb_trace_hint.list(),d=a?new Set([a]):null;if(a){let N=Bwe(n,a);for(let se of N)d.add(se)}let x=(e??n.toArray()).filter(N=>!a||"subcircuit_id"in N&&d.has(N.subcircuit_id)),f=n.pcb_board.list()[0];n=ua(x);let m=Ku(x),y=Awe([...n.pcb_component.list(),...n.pcb_smtpad.list(),...n.pcb_plated_hole.list(),...n.pcb_hole.list(),...n.pcb_via.list(),...n.pcb_cutout.list()].filter(N=>!a||d?.has(N.subcircuit_id)),m);for(let N of y){let se=N.connectedTo.flatMap($=>m.getIdsConnectedToNet($));N.connectedTo.push(...se)}let b=y.flatMap(N=>[{x:N.center.x-N.width/2,y:N.center.y-N.height/2},{x:N.center.x+N.width/2,y:N.center.y+N.height/2}]),E;if(f?E={minX:f.center.x-f.width/2,maxX:f.center.x+f.width/2,minY:f.center.y-f.height/2,maxY:f.center.y+f.height/2}:E={minX:Math.min(...b.map(N=>N.x))-1,maxX:Math.max(...b.map(N=>N.x))+1,minY:Math.min(...b.map(N=>N.y))-1,maxY:Math.max(...b.map(N=>N.y))+1},a){let N=n.pcb_group.getWhere({subcircuit_id:a});if(N){let se={minX:N.center.x-N.width/2,maxX:N.center.x+N.width/2,minY:N.center.y-N.height/2,maxY:N.center.y+N.height/2};E={minX:Math.min(E.minX,se.minX),maxX:Math.max(E.maxX,se.maxX),minY:Math.min(E.minY,se.minY),maxY:Math.max(E.maxY,se.maxY)}}}let A=n.source_trace.list().map(N=>{let se=N.connected_source_port_ids.map(xe=>{let Ae=n.source_port.get(xe),Ie=n.pcb_port.getWhere({source_port_id:xe});return{...Ae,...Ie}});if(se.length<2)return null;let[$,W]=se,Q=$.layers?.[0]??"top",le=W.layers?.[0]??"top",z=l.filter(xe=>xe.pcb_port_id===$.pcb_port_id||xe.pcb_port_id===W.pcb_port_id),pe=[];for(let xe of z){let Ie=n.pcb_port.get(xe.pcb_port_id)?.layers?.[0]??"top";for(let Le of xe.route)pe.push({x:Le.x,y:Le.y,layer:Ie})}return{name:N.source_trace_id??m.getNetConnectedToId(N.source_trace_id)??"",source_trace_id:N.source_trace_id,pointsToConnect:[{x:$.x,y:$.y,layer:Q,pointId:$.pcb_port_id,pcb_port_id:$.pcb_port_id},...pe,{x:W.x,y:W.y,layer:le,pointId:W.pcb_port_id,pcb_port_id:W.pcb_port_id}]}}).filter(N=>N!==null),w=new Map(A.map(N=>[N.source_trace_id,N])),B=n.source_net.list().filter(N=>!a||d?.has(N.subcircuit_id)),I=[];for(let N of B){let se=n.source_trace.list().filter($=>$.connected_source_net_ids?.includes(N.source_net_id));I.push({name:N.source_net_id??m.getNetConnectedToId(N.source_net_id),pointsToConnect:se.flatMap($=>n.pcb_port.list().filter(Q=>$.connected_source_port_ids.includes(Q.source_port_id)).map(Q=>({x:Q.x,y:Q.y,layer:Q.layers?.[0]??"top",pointId:Q.pcb_port_id,pcb_port_id:Q.pcb_port_id})))})}let q=n.pcb_breakout_point.list().filter(N=>!a||d?.has(N.subcircuit_id)),G=[],j=new Map;for(let N of q){let se={x:N.x,y:N.y,layer:"top"};if(N.source_trace_id){let $=w.get(N.source_trace_id)??j.get(N.source_trace_id);if($)$.pointsToConnect.push(se);else{let W={name:N.source_trace_id,source_trace_id:N.source_trace_id,pointsToConnect:[se]};G.push(W),j.set(N.source_trace_id,W)}}else if(N.source_net_id){let $=I.find(W=>W.name===N.source_net_id);$?$.pointsToConnect.push(se):G.push({name:N.source_net_id,pointsToConnect:[se]})}else if(N.source_port_id){let $=n.pcb_port.getWhere({source_port_id:N.source_port_id});$&&G.push({name:N.source_port_id,source_trace_id:void 0,pointsToConnect:[{x:$.x,y:$.y,layer:$.layers?.[0]??"top",pointId:$.pcb_port_id,pcb_port_id:$.pcb_port_id},se]})}}let O=[...A,...I,...G],V=new Map;for(let N of O)for(let se of N.pointsToConnect)se.pointId&&V.set(se.pointId,N);let te=n.pcb_trace.list().filter(N=>!a||d?.has(N.subcircuit_id));for(let N of te){let se=new Set;for(let Q of N.route)Q.start_pcb_port_id&&se.add(Q.start_pcb_port_id),Q.end_pcb_port_id&&se.add(Q.end_pcb_port_id);if(se.size<2)continue;let $=se.values().next().value;if(!$)continue;let W=V.get($);W&&[...se].every(Q=>V.get(Q)===W)&&(W.externallyConnectedPointIds??(W.externallyConnectedPointIds=[]),W.externallyConnectedPointIds.push([...se]))}return{simpleRouteJson:{bounds:E,obstacles:y,connections:O,layerCount:f?.num_layers??2,minTraceWidth:s},connMap:m}},JGt=n=>{let e={};if(!n)return e;for(let s of ud)e[s]=0;let a=new Map;for(let s of n){let[,,l,d]=s.type.split(":");if(d==="start"){a.set(`${l}:${s.renderId}`,s);continue}if(d==="end"){let x=a.get(`${l}:${s.renderId}`);if(x){let f=s.createdAt-x.createdAt;e[l]=(e[l]||0)+f}}}return e},ZGt=n=>{let e=n.map(m=>[...new Set(m)]),a=e.map(()=>[]),s=e.map(()=>null);for(let m=0;m<e.length;m++)for(let y of e[m])if(/^\d+$/.test(y)){s[m]=Number.parseInt(y);break}let l=0,d=new Set;for(let m=0;m<s.length;m++){let y=s[m];if(y===null||y<1)continue;if(!d.has(y)){d.add(y),a[m].push(`pin${y}`),l=Math.max(l,y);continue}let b=0;for(let E of a[m])E.startsWith(`pin${y}_alt`)&&b++;a[m].push(`pin${y}_alt${b+1}`)}for(let m=0;m<a.length;m++)a[m][0]?.includes("_alt")&&(l++,a[m].unshift(`pin${l}`));for(let m=0;m<a.length;m++)a[m].length===0&&(l++,a[m].push(`pin${l}`));let x={};for(let m of e)for(let y of m)/^\d+$/.test(y)||(x[y]=(x[y]??0)+1);let f={};for(let m=0;m<e.length;m++){let y=e[m];for(let b of y)/^\d+$/.test(b)||(x[b]===1?a[m].push(b):(f[b]=(f[b]??0)+1,a[m].push(`${b}${f[b]}`)))}return a},nwe=(0,Twe.default)("Group_doInitialSchematicLayoutMatchAdapt");function QGt(n){let{db:e}=n.root,a=qb(e.toArray(),{source_group_id:n.source_group_id}),s=JY(a);nwe.enabled&&global.debugGraphics?.push(Hp(s,{title:`floatingBpcGraph-${n.name}`}));let l=JY(a),d={boxes:l.boxes,pins:l.pins.map(m=>({...m,color:m.color.replace("not_connected","normal")}))},{result:x}=xRe([{variantName:"default",floatingGraph:l},{variantName:"noNotConnected",floatingGraph:d}],{singletonKeys:["vcc/2","gnd/2"],centerPinColors:["netlabel_center","component_center"],floatingBoxIdsWithMutablePinOffsets:new Set(l.boxes.filter(m=>l.pins.filter(E=>E.boxId===m.boxId).filter(E=>!E.color.includes("center")).length<=2).map(m=>m.boxId)),corpus:{}});nwe.enabled&&global.debugGraphics?.push(Hp(x,{title:`laidOutBpcGraph-${n.name}`}));let f=n._getGlobalSchematicPositionBeforeLayout();for(let m of x.boxes){if(!m.center)continue;let y=e.schematic_component.get(m.boxId);if(y){let E={x:m.center.x+f.x,y:m.center.y+f.y},A=e.schematic_port.list({schematic_component_id:y.schematic_component_id}),w=e.schematic_text.list({schematic_component_id:y.schematic_component_id}),B={x:E.x-y.center.x,y:E.y-y.center.y};for(let I of A)I.center.x+=B.x,I.center.y+=B.y;for(let I of w)I.position.x+=B.x,I.position.y+=B.y;y.center=E;continue}let b=e.schematic_net_label.get(m.boxId);if(b){let E=x.pins.find(w=>w.boxId===m.boxId&&w.color==="netlabel_center");if(!E)throw new Error(`No pin found for net label: ${m.boxId}`);let A={x:m.center.x+f.x,y:m.center.y+f.y};b.center=A,b.anchor_position={x:A.x+E.offset.x,y:A.y+E.offset.y};continue}console.error(`No schematic element found for box: ${m.boxId}. This is a bug in the matchAdapt binding with @tscircuit/core`)}}var an=(0,Pwe.default)("Group_doInitialSchematicLayoutMatchpack");function awe(n){switch(n){case"up":return"y+";case"down":return"y-";case"left":return"x-";case"right":return"x+";default:return"y+"}}function swe(n,e){let a=["up","right","down","left"],s=a.indexOf(n);if(s===-1)return n;let l=Math.round(e/90),d=(s+l)%4;return a[d<0?d+4:d]}function eXt(n,e,a){let s={chipMap:{},chipPinMap:{},netMap:{},pinStrongConnMap:{},netConnMap:{},chipGap:.6,partitionGap:1.2};an(`[${a.name}] Processing ${n.childNodes.length} child nodes for input problem`),n.childNodes.forEach((d,x)=>{if(an(`[${a.name}] Processing child ${x}: nodeType=${d.nodeType}`),d.nodeType==="component"?an(`[${a.name}] - Component: ${d.sourceComponent?.name}`):d.nodeType==="group"&&an(`[${a.name}] - Group: ${d.sourceGroup?.name}`),d.nodeType==="component"&&d.sourceComponent){let f=d.sourceComponent.name||`chip_${x}`,m=e.schematic_component.getWhere({source_component_id:d.sourceComponent.source_component_id});if(!m)return;let y=a.children.find(A=>A.source_component_id===d.sourceComponent?.source_component_id),b=[0,90,180,270];y?._parsedProps?.schOrientation&&(b=[0]),y?._parsedProps?.schRotation!==void 0&&(b=[0]),s.chipMap[f]={chipId:f,pins:[],size:{x:m.size?.width||1,y:m.size?.height||1},availableRotations:b};let E=e.schematic_port.list({schematic_component_id:m.schematic_component_id});for(let A of E){let w=e.source_port.get(A.source_port_id);if(!w)continue;let B=`${f}.${w.pin_number||w.name||A.schematic_port_id}`;s.chipMap[f].pins.push(B);let I=awe(A.facing_direction);s.chipPinMap[B]={pinId:B,offset:{x:(A.center?.x||0)-(m.center.x||0),y:(A.center?.y||0)-(m.center.y||0)},side:I}}}else if(d.nodeType==="group"&&d.sourceGroup){let f=d.sourceGroup.name||`group_${x}`;an(`[${a.name}] Processing nested group: ${f}`);let m=e.schematic_group?.getWhere?.({source_group_id:d.sourceGroup.source_group_id});if(an(`[${a.name}] Found schematic_group for ${f}:`,m),m){an(`[${a.name}] Treating group ${f} as composite chip`);let y=e.schematic_component.list({schematic_group_id:m.schematic_group_id});an(`[${a.name}] Group ${f} has ${y.length} components:`,y.map(j=>j.source_component_id));let b=1/0,E=-1/0,A=1/0,w=-1/0,B=!1;for(let j of y)if(j.center&&j.size){B=!0;let O=j.size.width/2,V=j.size.height/2;b=Math.min(b,j.center.x-O),E=Math.max(E,j.center.x+O),A=Math.min(A,j.center.y-V),w=Math.max(w,j.center.y+V)}let I=B?E-b:2,q=B?w-A:2;an(`[${a.name}] Group ${f} computed size: ${I} x ${q}`);let G=[];for(let j of y){let O=e.schematic_port.list({schematic_component_id:j.schematic_component_id});for(let V of O){let te=e.source_port.get(V.source_port_id);if(!te)continue;let N=`${f}.${te.pin_number||te.name||V.schematic_port_id}`;G.push(N);let se=m.center||{x:0,y:0},$=awe(V.facing_direction);s.chipPinMap[N]={pinId:N,offset:{x:(V.center?.x||0)-se.x,y:(V.center?.y||0)-se.y},side:$}}}an(`[${a.name}] Group ${f} has ${G.length} pins:`,G),s.chipMap[f]={chipId:f,pins:G,size:{x:I,y:q}},an(`[${a.name}] Added group ${f} to chipMap`)}else an(`[${a.name}] Warning: No schematic_group found for group ${f}`)}}),an(`[${a.name}] Creating connections using connectivity keys`);let l=new Map;for(let[d,x]of Object.entries(s.chipMap))for(let f of x.pins){let m=f.split(".").pop(),y=n.childNodes.find(b=>b.nodeType==="component"&&b.sourceComponent?b.sourceComponent.name===d:b.nodeType==="group"&&b.sourceGroup?`group_${n.childNodes.indexOf(b)}`===d:!1);if(y?.nodeType==="group"&&y.sourceGroup){let b=e.schematic_group?.getWhere?.({source_group_id:y.sourceGroup.source_group_id});if(b){let E=e.schematic_component.list({schematic_group_id:b.schematic_group_id});for(let A of E){let w=e.source_port.list({source_component_id:A.source_component_id});for(let B of w){let I=B.pin_number||B.name;if(String(I)===String(m))if(B.subcircuit_connectivity_map_key){let q=B.subcircuit_connectivity_map_key;l.has(q)||l.set(q,[]),l.get(q).push(f),an(`[${a.name}] \u2713 Pin ${f} has connectivity key: ${q}`)}else an(`[${a.name}] Pin ${f} has no connectivity key`)}}}}else if(y?.nodeType==="component"&&y.sourceComponent){let b=e.source_port.list({source_component_id:y.sourceComponent.source_component_id});for(let E of b){let A=E.pin_number||E.name;if(String(A)===String(m)&&E.subcircuit_connectivity_map_key){let w=E.subcircuit_connectivity_map_key;l.has(w)||l.set(w,[]),l.get(w).push(f),an(`[${a.name}] Pin ${f} has connectivity key: ${w}`)}}}}an(`[${a.name}] Found ${l.size} connectivity groups:`,Array.from(l.entries()).map(([d,x])=>({key:d,pins:x})));for(let[d,x]of l)if(x.length>=2){let f=e.source_trace.list().filter(b=>b.subcircuit_connectivity_map_key===d),m=f.some(b=>b.connected_source_net_ids&&b.connected_source_net_ids.length>0),y=f.some(b=>b.connected_source_port_ids&&b.connected_source_port_ids.length>=2);if(an(`[${a.name}] Connectivity ${d}: hasNetConnections=${m}, hasDirectConnections=${y}`),y){for(let b of f)if(b.connected_source_port_ids&&b.connected_source_port_ids.length>=2){let E=[];for(let A of b.connected_source_port_ids)for(let w of x){let B=w.split(".").pop(),I=e.source_port.get(A);if(I&&String(I.pin_number||I.name)===String(B)){let q=w.split(".")[0],G=n.childNodes.find(j=>j.nodeType==="component"&&j.sourceComponent?j.sourceComponent.name===q:j.nodeType==="group"&&j.sourceGroup?`group_${n.childNodes.indexOf(j)}`===q:!1);G?.nodeType==="component"&&G.sourceComponent&&e.source_port.list({source_component_id:G.sourceComponent.source_component_id}).some(O=>O.source_port_id===A)&&E.push(w)}}for(let A=0;A<E.length;A++)for(let w=A+1;w<E.length;w++){let B=E[A],I=E[w];s.pinStrongConnMap[`${B}-${I}`]=!0,s.pinStrongConnMap[`${I}-${B}`]=!0,an(`[${a.name}] Created strong connection: ${B} <-> ${I}`)}}}if(m){s.netMap[d]={netId:d};for(let b of x)s.netConnMap[`${b}-${d}`]=!0;an(`[${a.name}] Created net ${d} with ${x.length} pins:`,x)}}return s}function tXt(n){let{db:e}=n.root,a=og(e.toArray(),{source_group_id:n.source_group_id});if(an(`[${n.name}] Starting matchpack layout with ${a.childNodes.length} children`),an(`[${n.name}] Tree structure:`,JSON.stringify(a,null,2)),a.childNodes.length<=1){an(`[${n.name}] Only ${a.childNodes.length} children, skipping layout`);return}an("Converting circuit tree to InputProblem...");let s=eXt(a,e,n);an("InputProblem:",JSON.stringify(s,null,2));let l=new F5e(s);if(an("Starting LayoutPipelineSolver..."),an.enabled&&global.debugGraphics){let m=l.visualize();global.debugGraphics.push({...m,title:`matchpack-initial-${n.name}`})}if(l.solve(),an(`Solver completed in ${l.iterations} iterations`),an(`Solved: ${l.solved}, Failed: ${l.failed}`),l.failed)throw an(`Solver failed with error: ${l.error}`),new Error(`Matchpack layout solver failed: ${l.error}`);let d=l.getOutputLayout();if(an("OutputLayout:",JSON.stringify(d,null,2)),an("Solver completed successfully:",!l.failed),an.enabled&&global.debugGraphics){let m=l.visualize();global.debugGraphics.push({...m,title:`matchpack-final-${n.name}`})}let x=l.checkForOverlaps(d);if(x.length>0){an(`Warning: Found ${x.length} overlapping components:`);for(let m of x)an(` ${m.chip1} overlaps ${m.chip2} (area: ${m.overlapArea})`)}let f=n._getGlobalSchematicPositionBeforeLayout();an(`Group offset: x=${f.x}, y=${f.y}`),an(`Applying layout results for ${Object.keys(d.chipPlacements).length} chip placements`);for(let[m,y]of Object.entries(d.chipPlacements)){an(`Processing placement for chip: ${m} at (${y.x}, ${y.y})`);let b=a.childNodes.find(A=>{if(A.nodeType==="component"&&A.sourceComponent){let w=A.sourceComponent.name===m;return an(` Checking component ${A.sourceComponent.name}: matches=${w}`),w}if(A.nodeType==="group"&&A.sourceGroup){let w=A.sourceGroup.name,B=`group_${a.childNodes.indexOf(A)}`,I=B===m;return an(` Checking group ${w} (expected chipId: ${B}): matches=${I}`),I}return!1});if(!b){an(`Warning: No tree node found for chip: ${m}`),an("Available tree nodes:",a.childNodes.map((A,w)=>({type:A.nodeType,name:A.nodeType==="component"?A.sourceComponent?.name:A.sourceGroup?.name,expectedChipId:A.nodeType==="group"?`group_${w}`:A.sourceComponent?.name})));continue}let E={x:y.x+f.x,y:y.y+f.y};if(b.nodeType==="component"&&b.sourceComponent){let A=e.schematic_component.getWhere({source_component_id:b.sourceComponent.source_component_id});if(A){an(`Moving component ${m} to (${E.x}, ${E.y})`);let w=e.schematic_port.list({schematic_component_id:A.schematic_component_id}),B=e.schematic_text.list({schematic_component_id:A.schematic_component_id}),I={x:E.x-A.center.x,y:E.y-A.center.y};for(let q of w)q.center.x+=I.x,q.center.y+=I.y;for(let q of B)q.position.x+=I.x,q.position.y+=I.y;if(A.center=E,y.ccwRotationDegrees!==0){an(`Component ${m} has rotation: ${y.ccwRotationDegrees}\xB0`);let q=y.ccwRotationDegrees*Math.PI/180,G=Math.cos(q),j=Math.sin(q);for(let O of w){let V=O.center.x-E.x,te=O.center.y-E.y,N=V*G-te*j,se=V*j+te*G;O.center.x=E.x+N,O.center.y=E.y+se;let $=O.facing_direction||"right";O.facing_direction=swe($,y.ccwRotationDegrees)}for(let O of B){let V=O.position.x-E.x,te=O.position.y-E.y,N=V*G-te*j,se=V*j+te*G;O.position.x=E.x+N,O.position.y=E.y+se}if(A.symbol_name){let O=A.symbol_name.match(/_(right|left|up|down)$/);O&&(A.symbol_name=A.symbol_name.replace(O[0],`_${swe(O[1],y.ccwRotationDegrees)}`))}}}}else if(b.nodeType==="group"&&b.sourceGroup){let A=e.schematic_group?.getWhere?.({source_group_id:b.sourceGroup.source_group_id});if(A){an(`Moving group ${m} to (${E.x}, ${E.y}) from (${A.center?.x}, ${A.center?.y})`);let w=e.schematic_component.list({schematic_group_id:A.schematic_group_id});an(`Group ${m} has ${w.length} components to move`);let B=A.center||{x:0,y:0},I={x:E.x-B.x,y:E.y-B.y};an(`Position delta for group ${m}: (${I.x}, ${I.y})`);for(let q of w)if(q.center){let G={...q.center};q.center.x+=I.x,q.center.y+=I.y,an(`Moved component ${q.source_component_id} from (${G.x}, ${G.y}) to (${q.center.x}, ${q.center.y})`);let j=e.schematic_port.list({schematic_component_id:q.schematic_component_id}),O=e.schematic_text.list({schematic_component_id:q.schematic_component_id});for(let V of j)V.center&&(V.center.x+=I.x,V.center.y+=I.y);for(let V of O)V.position&&(V.position.x+=I.x,V.position.y+=I.y)}A.center=E,an(`Updated group ${m} center to (${E.x}, ${E.y})`)}}}an("Matchpack layout completed successfully")}function rXt(n){if(!n.isSubcircuit)return;let{db:e}=n.root,a=n.selectAll("trace"),s=new Pb({});s.addConnections(a.map(f=>{let m=e.source_trace.get(f.source_trace_id);return m?[m.source_trace_id,...m.connected_source_port_ids,...m.connected_source_net_ids]:null}).filter(f=>f!==null));let{name:l}=n._parsedProps;for(let f of a){if(!f.source_trace_id)continue;let m=s.getNetConnectedToId(f.source_trace_id);m&&(f.subcircuit_connectivity_map_key=`${l??`unnamedsubcircuit${n._renderId}`}_${m}`,e.source_trace.update(f.source_trace_id,{subcircuit_connectivity_map_key:f.subcircuit_connectivity_map_key}))}let d=new Set;for(let f of a){if(!f.source_trace_id)continue;let m=e.source_trace.get(f.source_trace_id);if(m)for(let y of m.connected_source_port_ids)d.add(y)}for(let f of d){let m=s.getNetConnectedToId(f);if(!m)continue;let y=`${l??`unnamedsubcircuit${n._renderId}`}_${m}`;e.source_port.update(f,{subcircuit_connectivity_map_key:y})}let x=new Set;for(let f of a){if(!f.source_trace_id)continue;let m=e.source_trace.get(f.source_trace_id);if(m)for(let y of m.connected_source_net_ids)x.add(y)}for(let f of x){let m=s.getNetConnectedToId(f);if(!m)continue;let y=`${l??`unnamedsubcircuit${n._renderId}`}_${m}`;e.source_net.update(f,{subcircuit_connectivity_map_key:y})}}function nXt(n){let{db:e}=n.root,a=n._parsedProps,s=n.children.filter(te=>{let N=te._parsedProps?.schX!==void 0||te._parsedProps?.schY!==void 0;return te.schematic_component_id&&!N});if(s.length===0)return;let l=0,d=0;for(let te of s){let N=e.schematic_component.get(te.schematic_component_id);N?.size&&(l=Math.max(l,N.size.width),d=Math.max(d,N.size.height))}l===0&&s.length>0&&(l=1),d===0&&s.length>0&&(d=1);let x=a.gridCols,f,m=a.gridGap,y=a.gridRowGap,b=a.gridColumnGap;a.schLayout?.grid&&(x=a.schLayout.grid.cols??x,f=a.schLayout.grid.rows,m=a.schLayout.gridGap??m,y=a.schLayout.gridRowGap??y,b=a.schLayout.gridColumnGap??b);let E,A;x!==void 0&&f!==void 0?(E=x,A=f):x!==void 0?(E=x,A=Math.ceil(s.length/E)):f!==void 0?(A=f,E=Math.ceil(s.length/A)):(E=Math.ceil(Math.sqrt(s.length)),A=Math.ceil(s.length/E)),E===0&&s.length>0&&(E=1),A===0&&s.length>0&&(A=s.length);let w,B,I=te=>{if(te!==void 0)return typeof te=="number"?te:me.parse(te)};if(y!==void 0||b!==void 0){let te=typeof m=="object"&&m!==null?m.x:m,N=typeof m=="object"&&m!==null?m.y:m;w=I(b??te)??1,B=I(y??N)??1}else if(typeof m=="number")w=m,B=m;else if(typeof m=="string"){let te=me.parse(m);w=te,B=te}else if(typeof m=="object"&&m!==null){let te=m.x,N=m.y;w=typeof te=="number"?te:me.parse(te??"0mm"),B=typeof N=="number"?N:me.parse(N??"0mm")}else w=1,B=1;let q=E*l+Math.max(0,E-1)*w,G=A*d+Math.max(0,A-1)*B,j=n._getGlobalSchematicPositionBeforeLayout(),O=j.x-q/2+l/2,V=j.y+G/2-d/2;for(let te=0;te<s.length;te++){let N=s[te];if(!N.schematic_component_id)continue;let se=Math.floor(te/E),$=te%E;if(se>=A||$>=E){console.warn(`Schematic grid layout: Child ${N.getString()} at index ${te} (row ${se}, col ${$}) exceeds specified grid dimensions (${A}x${E}). Skipping placement.`);continue}let W=O+$*(l+w),Q=V-se*(d+B),le=e.schematic_component.get(N.schematic_component_id);if(le){let z=le.center,pe={x:W,y:Q};e.schematic_component.update(N.schematic_component_id,{center:pe});let xe=pe.x-z.x,Ae=pe.y-z.y,Ie=e.schematic_port.list({schematic_component_id:N.schematic_component_id});for(let dt of Ie)e.schematic_port.update(dt.schematic_port_id,{center:{x:dt.center.x+xe,y:dt.center.y+Ae}});let Le=e.schematic_text.list({schematic_component_id:N.schematic_component_id});for(let dt of Le)e.schematic_text.update(dt.schematic_text_id,{position:{x:dt.position.x+xe,y:dt.position.y+Ae}})}}n.schematic_group_id&&e.schematic_group.update(n.schematic_group_id,{width:q,height:G,center:j})}var iwe=(n,e)=>{let{sourceComponent:a,sourceGroup:s}=e;if(e.nodeType==="component"){let l=n.schematic_component.getWhere({source_component_id:a?.source_component_id});return l?.size?{width:l.size.width,height:l.size.height}:null}if(e.nodeType==="group"){let l=n.schematic_group.getWhere({source_group_id:s?.source_group_id});if(l?.width&&l?.height)return{width:l.width,height:l.height};let d=n.schematic_component.list({schematic_group_id:l?.schematic_group_id}),x=1/0,f=-1/0,m=1/0,y=-1/0;for(let A of d)if(A.center&&A.size){let w=A.size.width/2,B=A.size.height/2;x=Math.min(x,A.center.x-w),f=Math.max(f,A.center.x+w),m=Math.min(m,A.center.y-B),y=Math.max(y,A.center.y+B)}let b=f-x,E=y-m;return{width:b,height:E}}return null},aXt=n=>{let{db:e}=n.root,a=n._parsedProps,s=og(e.toArray(),{source_group_id:n.source_group_id}),l=a.schJustifyContent??a.justifyContent,d=a.schAlignItems??a.alignItems,x=a.schFlexGap??a.schGap??a.gap,f=a.schFlexDirection??"row",m={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"}[l??"space-between"],y={start:"flex-start",end:"flex-end","flex-start":"flex-start","flex-end":"flex-end",stretch:"stretch",center:"center"}[d??"center"];if(!m)throw new Error(`Invalid justifyContent value: "${l}"`);if(!y)throw new Error(`Invalid alignItems value: "${d}"`);let b=0,E=0;typeof x=="object"?(b=x.y??0,E=x.x??0):typeof x=="number"?(b=x,E=x):typeof x=="string"&&(b=me.parse(x),E=me.parse(x));let A,w=a.width??a.schWidth??void 0,B=a.height??a.schHeight??void 0;(w===void 0||B===void 0)&&(A=y5(s.childNodes.map(V=>iwe(e,V)).filter(V=>V!==null),{alignItems:y,justifyContent:m,direction:f,rowGap:b,columnGap:E}),w=A.width,B=A.height);let q=new bS(w,B,{alignItems:y,justifyContent:m,direction:f,rowGap:b,columnGap:E});for(let V of s.childNodes){let te=iwe(e,V);q.addChild({metadata:V,width:te?.width??0,height:te?.height??0,flexBasis:te?f==="row"?te.width:te.height:void 0})}q.build();let G={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,width:0,height:0};for(let V of q.children)G.minX=Math.min(G.minX,V.position.x),G.minY=Math.min(G.minY,V.position.y),G.maxX=Math.max(G.maxX,V.position.x+V.size.width),G.maxY=Math.max(G.maxY,V.position.y+V.size.height);G.width=G.maxX-G.minX,G.height=G.maxY-G.minY;let j={x:-(G.maxX+G.minX)/2,y:-(G.maxY+G.minY)/2},O=e.toArray();for(let V of q.children){let{sourceComponent:te,sourceGroup:N}=V.metadata;if(te){let se=e.schematic_component.getWhere({source_component_id:te.source_component_id});if(!se)continue;zAe(O,se.schematic_component_id,{x:V.position.x+V.size.width/2+j.x,y:V.position.y+V.size.height/2+j.y})}if(N){if(!e.schematic_group.getWhere({source_group_id:N.source_group_id}))continue;UAe(O,N.source_group_id,{x:V.position.x+V.size.width/2+j.x,y:V.position.y+V.size.height/2+j.y})}}n.schematic_group_id&&e.schematic_group.update(n.schematic_group_id,{width:G.width,height:G.height})},BW=1;function sXt(n){let{db:e}=n.root,a=n._parsedProps,s=iXt(n);if(s.length===0)return;let l=oXt({db:e,pcbChildren:s}),d=uXt(a),x=cXt({props:a,pcbChildren:s,childDimensions:l,gridConfig:d}),f=pXt({pcbChildren:s,childDimensions:l,gridLayout:x,gridConfig:d}),{itemCoordinates:m}=f.layout();xXt({db:e,group:n,pcbChildren:s,itemCoordinates:m,gridLayout:x}),fXt({db:e,group:n,props:a,gridLayout:x})}function iXt(n){return n.children.filter(e=>e.pcb_component_id||e.pcb_group_id)}function oXt(n){let{db:e,pcbChildren:a}=n,s=0,l=0;for(let d of a){let x=0,f=0;if(d.pcb_group_id){let m=e.pcb_group.get(d.pcb_group_id);x=m?.width??0,f=m?.height??0}else if(d.pcb_component_id){let m=e.pcb_component.get(d.pcb_component_id);x=m?.width??0,f=m?.height??0}s=Math.max(s,x),l=Math.max(l,f)}return{width:s,height:l}}function uXt(n){let e=n.pcbGridCols??n.gridCols??n.pcbLayout?.grid?.cols,a=n.pcbGridRows??n.pcbLayout?.grid?.rows,s=n.pcbGridTemplateColumns,l=n.pcbGridTemplateRows,d=E=>E===void 0?BW:typeof E=="number"?E:me.parse(E),x=n.pcbGridGap??n.gridGap??n.pcbLayout?.gridGap,f=n.pcbGridRowGap??n.gridRowGap??n.pcbLayout?.gridRowGap,m=n.pcbGridColumnGap??n.gridColumnGap??n.pcbLayout?.gridColumnGap,y=BW,b=BW;if(f!==void 0||m!==void 0){let E=typeof x=="object"?x?.x:x,A=typeof x=="object"?x?.y:x;y=d(m??E),b=d(f??A)}else if(typeof x=="object"&&x!==null)y=d(x.x),b=d(x.y);else{let E=d(x);y=E,b=E}return{cols:e,rows:a,gapX:y,gapY:b,templateColumns:s,templateRows:l}}function cXt(n){let{props:e,pcbChildren:a,childDimensions:s,gridConfig:l}=n;return e.pcbGridTemplateColumns||e.pcbGridTemplateRows?lXt({props:e,gridConfig:l,pcbChildren:a,childDimensions:s}):dXt({gridConfig:l,pcbChildren:a,childDimensions:s})}function lXt(n){let{props:e,gridConfig:a,pcbChildren:s,childDimensions:l}=n,d=e.pcbGridTemplateColumns??"",x=e.pcbGridTemplateRows??"",f=A=>{let w=A.match(/repeat\((\d+),/);return w?parseInt(w[1]):Math.ceil(Math.sqrt(s.length))},m=e.pcbGridTemplateColumns?f(d):Math.ceil(Math.sqrt(s.length)),y=e.pcbGridTemplateRows?f(x):Math.ceil(s.length/m),b=m*l.width+Math.max(0,m-1)*a.gapX,E=y*l.height+Math.max(0,y-1)*a.gapY;return{gridTemplateColumns:d,gridTemplateRows:x,containerWidth:b,containerHeight:E}}function dXt(n){let{gridConfig:e,pcbChildren:a,childDimensions:s}=n,l,d;e.cols!==void 0&&e.rows!==void 0?(l=e.cols,d=e.rows):e.cols!==void 0?(l=e.cols,d=Math.ceil(a.length/l)):e.rows!==void 0?(d=e.rows,l=Math.ceil(a.length/d)):(l=Math.ceil(Math.sqrt(a.length)),d=Math.ceil(a.length/l)),l=Math.max(1,l),d=Math.max(1,d);let x=l*s.width+Math.max(0,l-1)*e.gapX,f=d*s.height+Math.max(0,d-1)*e.gapY,m=`repeat(${l}, ${s.width}px)`,y=`repeat(${d}, ${s.height}px)`;return{gridTemplateColumns:m,gridTemplateRows:y,containerWidth:x,containerHeight:f}}function pXt(n){let{pcbChildren:e,childDimensions:a,gridLayout:s,gridConfig:l}=n,d=e.map((x,f)=>({key:x.getString()||`child-${f}`,contentWidth:a.width,contentHeight:a.height}));return new B5e({containerWidth:s.containerWidth,containerHeight:s.containerHeight,gridTemplateColumns:s.gridTemplateColumns,gridTemplateRows:s.gridTemplateRows,gap:[l.gapY,l.gapX],children:d})}function xXt(n){let{db:e,group:a,pcbChildren:s,itemCoordinates:l,gridLayout:d}=n,x=a._getGlobalPcbPositionBeforeLayout(),f=e.toArray();for(let m=0;m<s.length;m++){let y=s[m],b=y.getString()||`child-${m}`,E=l[b];if(!E){console.warn(`PCB grid layout: No coordinates found for child ${b}`);continue}let A=x.x-d.containerWidth/2+E.x+E.width/2,w=x.y+d.containerHeight/2-E.y-E.height/2;if(y.pcb_component_id)m5(f,y.pcb_component_id,{x:A,y:w});else{let B=y;B.pcb_group_id&&B.source_group_id&&g5(f,B.source_group_id,{x:A,y:w})}}}function fXt(n){let{db:e,group:a,props:s,gridLayout:l}=n;if(a.pcb_group_id){let d=a._getGlobalPcbPositionBeforeLayout();e.pcb_group.update(a.pcb_group_id,{width:s.width??l.containerWidth,height:s.height??l.containerHeight,center:d})}}function hXt(n){let e={serverUrl:"https://registry-api.tscircuit.com",serverMode:"job",serverCacheEnabled:!0};if(typeof n=="object"&&!n.preset)return{local:!(n.serverUrl||n.serverMode||n.serverCacheEnabled),...e,...n};let a=typeof n=="object"?n.preset:n,s=typeof n=="object"?n:{};switch(a){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:l,local:d,groupMode:x,...f}=s;return{local:!1,groupMode:"subcircuit",...e,...f}}default:return{local:!0,groupMode:"subcircuit"}}}var mXt="1mm",owe=(0,Iwe.default)("Group_doInitialPcbLayoutPack"),OF=(n,e,a)=>{if(e===a)return!0;let s=n.source_group.get(e);return!s||!s.parent_source_group_id?!1:OF(n,s.parent_source_group_id,a)},gXt=n=>{let{db:e}=n.root,{_parsedProps:a}=n,{packOrderStrategy:s,packPlacementStrategy:l,gap:d,pcbGap:x,pcbPackGap:f}=a,m=f??x??d,y=me.parse(m??mXt),b={...D5e(y5e(e.toArray(),{source_group_id:n.source_group_id,shouldAddInnerObstacles:!0})),orderStrategy:s??"largest_to_smallest",placementStrategy:l??"minimum_sum_squared_distance_to_network",minGap:y};owe.enabled&&(global.debugOutputs?.add(`packInput-circuitjson-${n.name}`,JSON.stringify(e.toArray())),global.debugOutputs?.add(`packInput-${n.name}`,b));let E=gS(b);if(owe.enabled){let A=mS(E);A.title=`packOutput-${n.name}`,global.debugGraphics?.push(A)}for(let A of E.components){let{center:w,componentId:B,ccwRotationOffset:I,ccwRotationDegrees:q}=A,G=e.pcb_component.get(B);if(G){let se=n.source_group_id,W=e.source_component.get(G.source_component_id)?.source_group_id;if(W!==void 0&&!OF(e,W,se))continue;let Q=G.center,le=q??I??0,z=Bs(n._computePcbGlobalTransformBeforeLayout(),ja(w.x,w.y),Kf(le*Math.PI/180),ja(-Q.x,-Q.y)),pe=e.toArray().filter(xe=>"pcb_component_id"in xe&&xe.pcb_component_id===B);Ub(pe,z);continue}let j=e.pcb_group.list().find(se=>se.source_group_id===B);if(!j)continue;let O=j.center,V=q??I??0,te=Bs(n._computePcbGlobalTransformBeforeLayout(),ja(w.x,w.y),Kf(V*Math.PI/180),ja(-O.x,-O.y)),N=e.toArray().filter(se=>{if("source_group_id"in se&&se.source_group_id&&(se.source_group_id===B||OF(e,se.source_group_id,B)))return!0;if("source_component_id"in se&&se.source_component_id){let $=e.source_component.get(se.source_component_id);if($?.source_group_id&&($.source_group_id===B||OF(e,$.source_group_id,B)))return!0}if("pcb_component_id"in se&&se.pcb_component_id){let $=e.pcb_component.get(se.pcb_component_id);if($?.source_component_id){let W=e.source_component.get($.source_component_id);if(W?.source_group_id&&(W.source_group_id===B||OF(e,W.source_group_id,B)))return!0}}return!1});Ub(N,te),e.pcb_group.update(j.pcb_group_id,{center:w})}},yXt=n=>{let{db:e}=n.root,{_parsedProps:a}=n,s=n.children.filter(te=>te.pcb_component_id||te.pcb_group_id);if(s.some(te=>{let N=te._parsedProps;return N?.pcbX!==void 0||N?.pcbY!==void 0}))return;let d=a.pcbJustifyContent??a.justifyContent,x=a.pcbAlignItems??a.alignItems,f=a.pcbFlexGap??a.pcbGap??a.gap,m=a.pcbFlexDirection??"row",y={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"}[d??"space-between"],b={start:"flex-start",end:"flex-end","flex-start":"flex-start","flex-end":"flex-end",stretch:"stretch",center:"center"}[x??"center"];if(!y)throw new Error(`Invalid justifyContent value: "${d}"`);if(!b)throw new Error(`Invalid alignItems value: "${x}"`);let E=0,A=0;typeof f=="object"?(E=f.y??0,A=f.x??0):typeof f=="number"?(E=f,A=f):typeof f=="string"&&(E=me.parse(f),A=me.parse(f));let w,B=a.width??a.pcbWidth??void 0,I=a.height??a.pcbHeight??void 0;(B===void 0||I===void 0)&&(w=y5(s.map(te=>te._getMinimumFlexContainerSize()).filter(te=>te!==null),{alignItems:b,justifyContent:y,direction:m,rowGap:E,columnGap:A}),B=w.width,I=w.height);let G=new bS(B,I,{alignItems:b,justifyContent:y,direction:m,rowGap:E,columnGap:A});for(let te of s){let N=te._getMinimumFlexContainerSize();G.addChild({metadata:te,width:N?.width??0,height:N?.height??0,flexBasis:N?m==="row"?N.width:N.height:void 0})}G.build();let j={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,width:0,height:0};for(let te of G.children)j.minX=Math.min(j.minX,te.position.x),j.minY=Math.min(j.minY,te.position.y),j.maxX=Math.max(j.maxX,te.position.x+te.size.width),j.maxY=Math.max(j.maxY,te.position.y+te.size.height);j.width=j.maxX-j.minX,j.height=j.maxY-j.minY;let O=n._getGlobalPcbPositionBeforeLayout(),V={x:O.x-(j.maxX+j.minX)/2,y:O.y-(j.maxY+j.minY)/2};for(let te of G.children)te.metadata._repositionOnPcb({x:te.position.x+te.size.width/2+V.x,y:te.position.y+te.size.height/2+V.y});e.pcb_group.update(n.pcb_group_id,{width:j.width,height:j.height,center:O})};function DXt(n){let{db:e}=n.root,a=new Map,s=new Map,l=new Set,x=n.selectAll("trace").filter(le=>le._parsedProps?.schDisplayLabel),f=new Set(x.map(le=>le.source_trace_id).filter(le=>!!le)),m=n.selectAll("group"),y=[n.schematic_group_id,...m.map(le=>le.schematic_group_id)],b=e.schematic_component.list().filter(le=>y.includes(le.schematic_group_id)),E=[],A=new Map,w=new Map;for(let le of b){let z=le.schematic_component_id,pe=[],xe=e.source_component.getWhere({source_component_id:le.source_component_id}),Ae=e.schematic_port.list({schematic_component_id:le.schematic_component_id});for(let Ie of Ae){let Le=`${xe?.name??le.schematic_component_id}.${Ie.pin_number}`;A.set(Le,Ie.schematic_port_id),w.set(Ie.schematic_port_id,Le)}for(let Ie of Ae){let Le=w.get(Ie.schematic_port_id);pe.push({pinId:Le,x:Ie.center.x,y:Ie.center.y})}E.push({chipId:z,center:le.center,width:le.size.width,height:le.size.height,pins:pe})}let B=new Set,I=new Map,q=new Map,G=new Map;for(let le of b){let z=e.schematic_port.list({schematic_component_id:le.schematic_component_id});for(let pe of z)B.add(pe.schematic_port_id),pe.source_port_id&&(I.set(pe.schematic_port_id,pe.source_port_id),q.set(pe.source_port_id,pe.schematic_port_id))}let j=new Set;n.subcircuit_id&&j.add(n.subcircuit_id);for(let le of m)le.subcircuit_id&&j.add(le.subcircuit_id);let V=e.source_trace.list().filter(le=>{if(le.subcircuit_id===n.subcircuit_id)return!0;for(let z of le.connected_source_port_ids)if(q.has(z))return!0;return!1}).flatMap(le=>le.connected_source_net_ids);for(let le of V){let z=e.source_net.get(le);z?.subcircuit_id&&j.add(z.subcircuit_id)}let te=[],N=new Map;for(let le of e.source_trace.list()){if(le.subcircuit_id&&!j.has(le.subcircuit_id))continue;let z=(le.connected_source_port_ids??[]).map(pe=>q.get(pe)).filter(pe=>!!pe&&B.has(pe));if(z.length>=2){let[pe,xe]=z.slice(0,2),Ae=[pe,xe].sort().join("::");if(!N.has(Ae)){N.set(Ae,le.source_trace_id);let Ie=le.display_name??le.source_trace_id;le.subcircuit_connectivity_map_key&&(l.add(le.subcircuit_connectivity_map_key),G.set(Ie,le.subcircuit_connectivity_map_key),s.set(le.subcircuit_connectivity_map_key,Ie)),te.push({pinIds:[pe,xe].map(Le=>w.get(Le)),netId:Ie})}}}let se=[];for(let le of e.source_net.list().filter(z=>!z.subcircuit_id||j.has(z.subcircuit_id)))le.subcircuit_connectivity_map_key&&(l.add(le.subcircuit_connectivity_map_key),a.set(le.subcircuit_connectivity_map_key,le));let $=new Map;for(let[le,z]of I){let pe=e.source_port.get(z);if(!pe?.subcircuit_connectivity_map_key)continue;let xe=pe.subcircuit_connectivity_map_key;l.add(xe),$.has(xe)||$.set(xe,[]),$.get(xe).push(le)}for(let[le,z]of $){let pe=a.get(le);if(pe&&z.length>=2){let xe=String(pe.name||pe.source_net_id||le);G.set(xe,le),s.set(le,xe),se.push({netId:xe,pinIds:z.map(Ae=>w.get(Ae))})}}let W=(()=>{let le={},z=new Set(se.map(pe=>pe.netId));for(let pe of e.source_net.list().filter(xe=>!xe.subcircuit_id||j.has(xe.subcircuit_id)))pe.name&&z.has(pe.name)&&(pe.is_ground||pe.name.startsWith("GND")?le[pe.name]=["y-"]:/^V/.test(pe.name)&&(le[pe.name]=["y+"]));return le})();return{inputProblem:{chips:E,directConnections:te,netConnections:se,availableNetLabelOrientations:W,maxMspPairDistance:n._parsedProps.schMaxTraceDistance??5},pinIdToSchematicPortId:A,pairKeyToSourceTraceId:N,sckToSourceNet:a,sckToUserNetId:s,userNetIdToSck:G,allSourceAndSchematicPortIdsInScope:B,schPortIdToSourcePortId:I,displayLabelTraces:x,allScks:l}}var Ki=1e-6;function uwe(n){let e=Math.abs(n.to.x-n.from.x),a=Math.abs(n.to.y-n.from.y);return e>=a}function VS(n,e){return Math.hypot(e.x-n.x,e.y-n.y)}function cwe(n,e,a){return{x:n.x+(e.x-n.x)*a,y:n.y+(e.y-n.y)*a}}function lwe(n,e,a){let s=VS(n,e);if(s<Ki)return 0;let l=((a.x-n.x)*(e.x-n.x)+(a.y-n.y)*(e.y-n.y))/((e.x-n.x)*(e.x-n.x)+(e.y-n.y)*(e.y-n.y));return Math.max(0,Math.min(1,l))*s}function kS(n,e,a,s){return n*s-e*a}function bXt(n,e,a,s){let l={x:e.x-n.x,y:e.y-n.y},d={x:s.x-a.x,y:s.y-a.y},x=kS(l.x,l.y,d.x,d.y),f={x:a.x-n.x,y:a.y-n.y},m=kS(f.x,f.y,l.x,l.y);if(Math.abs(x)<Ki&&Math.abs(m)<Ki||Math.abs(x)<Ki&&Math.abs(m)>=Ki)return null;let y=kS(f.x,f.y,d.x,d.y)/x,b=kS(f.x,f.y,l.x,l.y)/x;return y<-Ki||y>1+Ki||b<-Ki||b>1+Ki?null:{x:n.x+y*l.x,y:n.y+y*l.y}}function FXt(n,e=Ki){if(n.length===0)return n;n.sort((l,d)=>l.start-d.start);let a=[],s={...n[0]};for(let l=1;l<n.length;l++){let d=n[l];d.start<=s.end+e?s.end=Math.max(s.end,d.end):(a.push(s),s={...d})}return a.push(s),a}function EXt(n,e,a){let s=VS(n.from,n.to);if(s<Ki||e.length===0)return[n];let l=a/2,d=e.map(E=>({start:Math.max(0,E-l),end:Math.min(s,E+l)})).filter(E=>E.end-E.start>Ki),x=FXt(d),f=[],m=0,y={x:n.to.x-n.from.x,y:n.to.y-n.from.y},b=(E,A,w)=>{if(A-E<=Ki)return;let B=E/s,I=A/s;f.push({from:cwe(n.from,n.to,B),to:cwe(n.from,n.to,I),...w?{is_crossing:!0}:{}})};for(let E of x)E.start-m>Ki&&b(m,E.start,!1),b(E.start,E.end,!0),m=E.end;return s-m>Ki&&b(m,s,!1),f.length>0?f:[n]}function vXt(n,e={}){let a=e.crossSegmentLength??.075,s=e.tolerance??Ki,l=new Map,d=m=>`${m.traceIdx}:${m.edgeIdx}`,x=m=>n[m.traceIdx].edges[m.edgeIdx];for(let m=0;m<n.length;m++){let y=n[m];for(let b=0;b<y.edges.length;b++){let E=y.edges[b];for(let A=m;A<n.length;A++){let w=n[A];for(let B=A===m?b+1:0;B<w.edges.length;B++){let I=w.edges[B],q=bXt(E.from,E.to,I.from,I.to);if(!q)continue;let G=VS(E.from,E.to),j=VS(I.from,I.to);if(G<s||j<s)continue;let O=lwe(E.from,E.to,q),V=lwe(I.from,I.to,q),te=O<=s||Math.abs(G-O)<=s||Number.isNaN(O),N=V<=s||Math.abs(j-V)<=s||Number.isNaN(V);if(!te&&!N){let se=uwe(E),$=uwe(I),W;if(se!==$)W=se;else{let z=Math.abs(E.to.x-E.from.x),pe=Math.abs(E.to.y-E.from.y),xe=Math.abs(I.to.x-I.from.x),Ae=Math.abs(I.to.y-I.from.y),Ie=z-pe,Le=xe-Ae;W=Ie===Le?!0:Ie>Le}let Q=d({traceIdx:W?m:A,edgeIdx:W?b:B}),le=l.get(Q)??[];le.push(W?O:V),l.set(Q,le)}}}}}let f=n.map(m=>({id:m.id,edges:[]}));for(let m=0;m<n.length;m++){let y=n[m];for(let b=0;b<y.edges.length;b++){let E=d({traceIdx:m,edgeIdx:b}),A=l.get(E)??[];if(A.length===0){f[m].edges.push(y.edges[b]);continue}let w=Array.from(new Set(A.map(I=>Number(I.toFixed(6))))).sort((I,q)=>I-q),B=EXt(y.edges[b],w,a);f[m].edges.push(...B)}}return f}var nl=1e-6;function GS(n,e,a=nl){return Math.abs(n-e)<=a}function $g(n,e,a=nl){return GS(n.x,e.x,a)&&GS(n.y,e.y,a)}function dwe(n,e,a,s=nl){let l=Math.min(e.x,a.x)-s,d=Math.max(e.x,a.x)+s,x=Math.min(e.y,a.y)-s,f=Math.max(e.y,a.y)+s;return n.x<l||n.x>d||n.y<x||n.y>f?!1:Math.abs((a.x-e.x)*(n.y-e.y)-(a.y-e.y)*(n.x-e.x))<=s}function pwe(n,e=nl){let a=new Map;for(let s of n){let l=`${s.x.toFixed(6)},${s.y.toFixed(6)}`;a.has(l)||a.set(l,s)}return Array.from(a.values())}function xwe(n){return{x:n.to.x-n.from.x,y:n.to.y-n.from.y}}function TW(n,e,a=nl){let s=xwe(n),l=xwe(e),d=Math.hypot(s.x,s.y),x=Math.hypot(l.x,l.y);if(d<a||x<a)return!0;let f=s.x*l.y-s.y*l.x;return Math.abs(f)<=a*d*x}function LF(n,e,a=nl){return n.edges.filter(s=>$g(s.from,e,a)||$g(s.to,e,a))}function fwe(n,e,a=nl){for(let s of n.edges){if($g(s.from,e,a))return s.from;if($g(s.to,e,a))return s.to}return null}function CXt(n,e,a=nl){let s=$g(n.from,e,a)||GS(n.from.x,e.x,a)&&GS(n.from.y,e.y,a)?n.to:n.from,l=s.x-e.x,d=s.y-e.y;return Math.abs(l)<a&&Math.abs(d)<a?null:Math.abs(l)>=Math.abs(d)?l>=0?"right":"left":d>=0?"up":"down"}function Mg(n,e,a=nl){let s=LF(n,e,a);if(s.length<2)return null;let l=s.map(E=>CXt(E,e,a)),d=l.includes("up"),x=l.includes("down"),f=l.includes("left"),m=l.includes("right"),y=d?"up":x?"down":null,b=m?"right":f?"left":null;return y&&b?`${y}-${b}`:null}function _Xt(n,e={}){let a=e.tolerance??nl,s={};for(let d of n)s[d.id]=[];let l=n.map(d=>{let x=[];for(let f of d.edges)x.push(f.from,f.to);return pwe(x,a)});for(let d=0;d<n.length;d++){let x=n[d],f=l[d];for(let m=d+1;m<n.length;m++){let y=n[m],b=l[m];for(let E of f)for(let A of b)if($g(E,A,a)){let w=LF(x,E,a),B=LF(y,A,a),I=w.some(O=>B.some(V=>!TW(O,V,a))),q=Mg(x,E,a),G=Mg(y,A,a);I&&!(q!==null&&G!==null&&q===G)&&(s[x.id].push(E),x.id!==y.id&&s[y.id].push(A))}for(let E of f)for(let A of y.edges)if(dwe(E,A.from,A.to,a)){let B=LF(x,E,a).some(O=>!TW(O,A,a)),I=Mg(x,E,a),q=fwe(y,E,a*1e3),G=q?Mg(y,q,a):null;B&&!(I!==null&&G!==null&&I===G)&&(s[x.id].push(E),x.id!==y.id&&s[y.id].push(E))}for(let E of b)for(let A of x.edges)if(dwe(E,A.from,A.to,a)){let B=LF(y,E,a).some(O=>!TW(A,O,a)),I=Mg(y,E,a),q=fwe(x,E,a*1e3),G=q?Mg(x,q,a):null;B&&!(G!==null&&I!==null&&G===I)&&(s[y.id].push(E),x.id!==y.id&&s[x.id].push(E))}}}for(let d of Object.keys(s))s[d]=pwe(s[d],a);return s}function AXt(n){let{group:e,solver:a,pinIdToSchematicPortId:s,pairKeyToSourceTraceId:l}=n,{db:d}=e.root,x=a.traceOverlapShiftSolver?.correctedTraceMap,f=[];for(let b of Object.values(x??{})){let E=b?.tracePath;if(!Array.isArray(E)||E.length<2)continue;let A=[];for(let B=0;B<E.length-1;B++)A.push({from:{x:E[B].x,y:E[B].y},to:{x:E[B+1].x,y:E[B+1].y}});let w=null;if(Array.isArray(b?.pins)&&b.pins.length===2){let B=s.get(b.pins[0]?.pinId),I=s.get(b.pins[1]?.pinId);if(B&&I){let q=[B,I].sort().join("::");w=l.get(q)||`solver_${b.mspPairId||q}`;for(let G of[B,I])d.schematic_port.get(G)&&d.schematic_port.update(G,{is_connected:!0})}}w||(w=`solver_${b?.mspPairId}`),f.push({id:w,edges:A})}let m=vXt(f.map(b=>({id:b.id,edges:b.edges}))),y=_Xt(m);for(let b of m)d.schematic_trace.insert({source_trace_id:b.id,edges:b.edges,junctions:y[b.id]??[]})}var RXt=n=>{switch(n){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"}},SXt=n=>{for(let a of n){let s=a._getDirectlyConnectedTraces();for(let l of s){let d=l._parsedProps.schDisplayLabel;if(d)return{name:d,wasAssignedDisplayLabel:!0}}}return{name:n.map(a=>a._getNetLabelText()).join("/"),wasAssignedDisplayLabel:!1}},PW=(0,Nwe.default)("Group_doInitialSchematicTraceRender");function wXt(n){let{group:e,solver:a,sckToSourceNet:s,allScks:l,allSourceAndSchematicPortIdsInScope:d,schPortIdToSourcePortId:x,userNetIdToSck:f,pinIdToSchematicPortId:m,schematicPortIdsWithPreExistingNetLabels:y,schematicPortIdsWithRoutedTraces:b}=n,{db:E}=e.root,A=a.netLabelPlacementSolver?.netLabelPlacements??[],w=a.mspConnectionPairSolver.globalConnMap;for(let B of A){PW(`processing placement: ${B.netId}`);let I=w.getIdsConnectedToNet(B.globalConnNetId).find(Q=>f.get(Q)),q=f.get(I),G=B.anchorPoint,j=B.orientation,O=RXt(j),V=q?s.get(q):void 0,te=B.pinIds.map(Q=>m.get(Q));if(te.some(Q=>y.has(Q))){PW(`skipping net label placement for "${B.netId}" REASON:schematic port has pre-existing net label`);continue}if(V){let Q=V.name,le=nx({anchor_position:G,anchor_side:O,text:Q});E.schematic_net_label.insert({text:Q,anchor_position:G,center:le,anchor_side:O,...V?.source_net_id?{source_net_id:V.source_net_id}:{}});continue}let N=e.selectAll("port").filter(Q=>Q._getSubcircuitConnectivityKey()===q),{name:se,wasAssignedDisplayLabel:$}=SXt(N);if(!$&&te.some(Q=>b.has(Q))){PW(`skipping net label placement for "${B.netId}" REASON:schematic port has routed traces and no display label`);continue}let W=nx({anchor_position:G,anchor_side:O,text:se});E.schematic_net_label.insert({text:se,anchor_position:G,center:W,anchor_side:O})}}var BXt=({allSourceAndSchematicPortIdsInScope:n,group:e,schPortIdToSourcePortId:a,sckToSourceNet:s,pinIdToSchematicPortId:l,schematicPortIdsWithPreExistingNetLabels:d})=>{let{db:x}=e.root;for(let f of Array.from(n)){let m=x.schematic_port.get(f);if(!m||m.is_connected)continue;let y=a.get(f);if(!y)continue;let E=x.source_port.get(y)?.subcircuit_connectivity_map_key;if(!E)continue;let A=s.get(E);if(!A||x.schematic_net_label.list().some(G=>Math.abs(G.anchor_position.x-m.center.x)<.1&&Math.abs(G.anchor_position.y-m.center.y)<.1?A.source_net_id&&G.source_net_id?G.source_net_id===A.source_net_id:G.text===(A.name||E):!1))continue;let B=A.name||A.source_net_id||E,I=qF(m.facing_direction||"right")||"right",q=nx({anchor_position:m.center,anchor_side:I,text:B});x.schematic_net_label.insert({text:B,anchor_position:m.center,center:q,anchor_side:I,...A.source_net_id?{source_net_id:A.source_net_id}:{}})}},TXt=n=>{let e=new Set,a=n.selectAll("netlabel");for(let s of a){let l=s._getConnectedPorts();for(let d of l)d.schematic_port_id&&e.add(d.schematic_port_id)}return e},PXt=({solver:n,pinIdToSchematicPortId:e})=>{let a=n.schematicTraceLinesSolver.solvedTracePaths,s=new Set;for(let l of a)for(let d of l.pinIds){let x=e.get(d);x&&s.add(x)}return s},IXt=(0,jwe.default)("Group_doInitialSchematicTraceRender"),jXt=n=>{if(!n.root?._featureMspSchematicTraceRouting||!n.isSubcircuit||n.root?.schematicDisabled)return;let{inputProblem:e,pinIdToSchematicPortId:a,pairKeyToSourceTraceId:s,sckToSourceNet:l,allSourceAndSchematicPortIdsInScope:d,schPortIdToSourcePortId:x,displayLabelTraces:f,allScks:m,userNetIdToSck:y}=DXt(n),b=TXt(n);IXt.enabled&&globalThis.debugOutputs?.add("group-trace-render-input-problem",JSON.stringify(e,null,2));let E=new uSe(e);E.solve();let A=PXt({solver:E,pinIdToSchematicPortId:a});AXt({group:n,solver:E,pinIdToSchematicPortId:a,pairKeyToSourceTraceId:s}),wXt({group:n,solver:E,sckToSourceNet:l,allSourceAndSchematicPortIdsInScope:d,schPortIdToSourcePortId:x,pinIdToSchematicPortId:a,allScks:m,userNetIdToSck:y,schematicPortIdsWithPreExistingNetLabels:b,schematicPortIdsWithRoutedTraces:A}),BXt({group:n,allSourceAndSchematicPortIdsInScope:d,schPortIdToSourcePortId:x,sckToSourceNet:l,pinIdToSchematicPortId:a,schematicPortIdsWithPreExistingNetLabels:b})},zg=class extends Za{constructor(){super(...arguments);X(this,"pcb_group_id",null);X(this,"schematic_group_id",null);X(this,"subcircuit_id",null);X(this,"_hasStartedAsyncAutorouting",!1);X(this,"_asyncAutoroutingResult",null);X(this,"unnamedElementCounter",{})}get config(){return{zodProps:B8e,componentName:"Group"}}doInitialSourceGroupRender(){let{db:e}=this.root,a=e.source_group.insert({name:this.name,is_subcircuit:this.isSubcircuit});this.source_group_id=a.source_group_id,this.isSubcircuit&&(this.subcircuit_id=`subcircuit_${a.source_group_id}`,e.source_group.update(a.source_group_id,{subcircuit_id:this.subcircuit_id}))}doInitialSourceRender(){let{db:e}=this.root;for(let a of this.children)e.source_component.update(a.source_component_id,{source_group_id:this.source_group_id})}doInitialSourceParentAttachment(){let{db:e}=this.root,a=this.parent?.getGroup?.();if(a?.source_group_id&&e.source_group.update(this.source_group_id,{parent_source_group_id:a.source_group_id}),!this.isSubcircuit)return;let s=this.parent?.getSubcircuit?.()?.subcircuit_id;s&&e.source_group.update(this.source_group_id,{parent_subcircuit_id:s})}doInitialPcbComponentRender(){if(this.root?.pcbDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,s=e.pcb_group.insert({is_subcircuit:this.isSubcircuit,subcircuit_id:this.subcircuit_id??this.getSubcircuit()?.subcircuit_id,name:this.name,center:this._getGlobalPcbPositionBeforeLayout(),width:0,height:0,pcb_component_ids:[],source_group_id:this.source_group_id,autorouter_configuration:a.autorouter?{trace_clearance:a.autorouter.traceClearance}:void 0});this.pcb_group_id=s.pcb_group_id;for(let l of this.children)e.pcb_component.update(l.pcb_component_id,{pcb_group_id:s.pcb_group_id})}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:e}=this.root,a=this._parsedProps,s=GW(this.children);if(this.pcb_group_id){let l=s.width,d=s.height,x=(s.minX+s.maxX)/2,f=(s.minY+s.maxY)/2;if(this.isSubcircuit){let{padLeft:b,padRight:E,padTop:A,padBottom:w}=this._resolvePcbPadding();l+=b+E,d+=A+w,x+=(E-b)/2,f+=(A-w)/2}let y=this._parsedProps.pcbX!==void 0||this._parsedProps.pcbY!==void 0?e.pcb_group.get(this.pcb_group_id)?.center??{x,y:f}:{x,y:f};e.pcb_group.update(this.pcb_group_id,{width:Number(a.width??l),height:Number(a.height??d),center:y})}}getNextAvailableName(e){var a,s;return(a=this.unnamedElementCounter)[s=e.lowercaseComponentName]??(a[s]=1),`unnamed_${e.lowercaseComponentName}${this.unnamedElementCounter[e.lowercaseComponentName]++}`}_resolvePcbPadding(){let e=this._parsedProps,a=e.pcbLayout,s=E=>{let A=a?.[E],w=e[E];if(typeof A=="number")return A;if(typeof w=="number")return w},l=s("padding")??0,d=s("paddingX"),x=s("paddingY"),f=s("paddingLeft")??d??l,m=s("paddingRight")??d??l,y=s("paddingTop")??x??l,b=s("paddingBottom")??x??l;return{padLeft:f,padRight:m,padTop:y,padBottom:b}}doInitialCreateTraceHintsFromProps(){let{_parsedProps:e}=this,{db:a}=this.root,s=e;if(!this.isSubcircuit)return;let l=s.manualEdits?.manual_trace_hints;if(l)for(let d of l)this.add(new YW({for:d.pcb_port_selector,offsets:d.offsets}))}doInitialSourceAddConnectivityMapKey(){rXt(this)}_areChildSubcircuitsRouted(){let e=this.selectAll("group").filter(a=>a.isSubcircuit);for(let a of e)if(a._shouldRouteAsync()&&!a._asyncAutoroutingResult)return!1;return!0}_shouldRouteAsync(){let e=this._getAutorouterConfig();return e.groupMode==="sequential-trace"?!1:!!(e.local&&e.groupMode==="subcircuit"||!e.local)}_hasTracesToRoute(){let e=(0,Og.default)("tscircuit:core:_hasTracesToRoute"),a=this.selectAll("trace");return e(`[${this.getString()}] has ${a.length} traces to route`),a.length>0}async _runEffectMakeHttpAutoroutingRequest(){let{db:e}=this.root,a=(0,Og.default)("tscircuit:core:_runEffectMakeHttpAutoroutingRequest"),s=this._parsedProps,l=this._getAutorouterConfig(),d=l.serverUrl,x=l.serverMode,f=(b,E)=>(a("fetching",b),E.headers&&(E.headers["Tscircuit-Core-Version"]=this.root?.getCoreVersion()),fetch(b,E)),m=this.root.db.toArray().filter(b=>b.type.startsWith("source_")||b.type.startsWith("pcb_"));if(x==="solve-endpoint"){if(this.props.autorouter?.inputFormat==="simplified"){let{autorouting_result:E}=await f(`${d}/autorouting/solve`,{method:"POST",body:JSON.stringify({input_simple_route_json:MW({db:e,minTraceWidth:this.props.autorouter?.minTraceWidth??.15,subcircuit_id:this.subcircuit_id}).simpleRouteJson,subcircuit_id:this.subcircuit_id}),headers:{"Content-Type":"application/json"}}).then(A=>A.json());this._asyncAutoroutingResult=E,this._markDirty("PcbTraceRender");return}let{autorouting_result:b}=await f(`${d}/autorouting/solve`,{method:"POST",body:JSON.stringify({input_circuit_json:m,subcircuit_id:this.subcircuit_id}),headers:{"Content-Type":"application/json"}}).then(E=>E.json());this._asyncAutoroutingResult=b,this._markDirty("PcbTraceRender");return}let{autorouting_job:y}=await f(`${d}/autorouting/jobs/create`,{method:"POST",body:JSON.stringify({input_circuit_json:m,provider:"freerouting",autostart:!0,display_name:this.root?.name,subcircuit_id:this.subcircuit_id,server_cache_enabled:l.serverCacheEnabled}),headers:{"Content-Type":"application/json"}}).then(b=>b.json());for(;;){let{autorouting_job:b}=await f(`${d}/autorouting/jobs/get`,{method:"POST",body:JSON.stringify({autorouting_job_id:y.autorouting_job_id}),headers:{"Content-Type":"application/json"}}).then(E=>E.json());if(b.is_finished){let{autorouting_job_output:E}=await f(`${d}/autorouting/jobs/get_output`,{method:"POST",body:JSON.stringify({autorouting_job_id:y.autorouting_job_id}),headers:{"Content-Type":"application/json"}}).then(A=>A.json());this._asyncAutoroutingResult={output_pcb_traces:E.output_pcb_traces},this._markDirty("PcbTraceRender");break}if(b.has_error){let E=new MF(`Autorouting job failed: ${JSON.stringify(b.error)}`);throw e.pcb_autorouting_error.insert({pcb_error_id:y.autorouting_job_id,error_type:"pcb_autorouting_error",message:E.message}),E}await new Promise(E=>setTimeout(E,100))}}async _runLocalAutorouting(){let{db:e}=this.root,a=this._parsedProps,s=(0,Og.default)("tscircuit:core:_runLocalAutorouting");s(`[${this.getString()}] starting local autorouting`);let l=this._getAutorouterConfig(),{simpleRouteJson:d}=MW({db:e,minTraceWidth:this.props.autorouter?.minTraceWidth??.15,subcircuit_id:this.subcircuit_id});if(s.enabled){let m=YY(d);m.title=`autorouting-${this.props.name}`,global.debugGraphics?.push(m)}this.root?.emit("autorouting:start",{subcircuit_id:this.subcircuit_id,componentDisplayName:this.getString(),simpleRouteJson:d});let x;l.algorithmFn?x=await l.algorithmFn(d):x=new YGt(d,{capacityDepth:this.props.autorouter?.capacityDepth,targetMinCapacity:this.props.autorouter?.targetMinCapacity});let f=new Promise((m,y)=>{x.on("complete",b=>{s(`[${this.getString()}] local autorouting complete`),m(b.traces)}),x.on("error",b=>{s(`[${this.getString()}] local autorouting error: ${b.error.message}`),y(b.error)})});x.on("progress",m=>{this.root?.emit("autorouting:progress",{subcircuit_id:this.subcircuit_id,componentDisplayName:this.getString(),...m})}),x.start();try{let m=await f;this._asyncAutoroutingResult={output_pcb_traces:m},this._markDirty("PcbTraceRender")}catch(m){let{db:y}=this.root;throw y.pcb_autorouting_error.insert({pcb_error_id:`pcb_autorouter_error_subcircuit_${this.subcircuit_id}`,error_type:"pcb_autorouting_error",message:m instanceof Error?m.message:String(m)}),this.root?.emit("autorouting:error",{subcircuit_id:this.subcircuit_id,componentDisplayName:this.getString(),error:{message:m instanceof Error?m.message:String(m)},simpleRouteJson:d}),m}finally{x.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 e=(0,Og.default)("tscircuit:core:doInitialPcbTraceRender");if(this.isSubcircuit&&!this.root?.pcbDisabled&&!this.getInheritedProperty("routingDisabled")&&!this._shouldUseTraceByTraceRouting()){if(!this._areChildSubcircuitsRouted()){e(`[${this.getString()}] child subcircuits are not routed, skipping async autorouting until subcircuits routed`);return}e(`[${this.getString()}] no child subcircuits to wait for, initiating async routing`),this._hasTracesToRoute()&&this._startAsyncAutorouting()}}doInitialSchematicTraceRender(){jXt(this)}updatePcbTraceRender(){let e=(0,Og.default)("tscircuit:core:updatePcbTraceRender");if(e(`[${this.getString()}] updating...`),!this.isSubcircuit)return;if(this._shouldRouteAsync()&&this._hasTracesToRoute()&&!this._hasStartedAsyncAutorouting){this._areChildSubcircuitsRouted()&&(e(`[${this.getString()}] child subcircuits are now routed, starting async autorouting`),this._startAsyncAutorouting());return}if(!this._asyncAutoroutingResult||this._shouldUseTraceByTraceRouting())return;let{db:a}=this.root;if(this._asyncAutoroutingResult.output_simple_route_json){e(`[${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){e(`[${this.getString()}] updating PCB traces from ${this._asyncAutoroutingResult.output_pcb_traces.length} traces`),this._updatePcbTraceRenderFromPcbTraces();return}}_updatePcbTraceRenderFromSimpleRouteJson(){let{db:e}=this.root,{traces:a}=this._asyncAutoroutingResult.output_simple_route_json;if(a)for(let s of a){let l=e.pcb_trace.insert({subcircuit_id:this.subcircuit_id,route:s.route})}}_updatePcbTraceRenderFromPcbTraces(){let{output_pcb_traces:e}=this._asyncAutoroutingResult;if(!e)return;let{db:a}=this.root;for(let s of e)if(s.type==="pcb_trace"){if(s.subcircuit_id=this.subcircuit_id,s.connection_name){let l=s.connection_name;s.source_trace_id=l}a.pcb_trace.insert(s)}for(let s of e)if(s.type!=="pcb_via"&&s.type==="pcb_trace")for(let l of s.route)l.route_type==="via"&&a.pcb_via.insert({pcb_trace_id:s.pcb_trace_id,x:l.x,y:l.y,hole_diameter:.3,outer_diameter:.6,layers:[l.from_layer,l.to_layer],from_layer:l.from_layer,to_layer:l.to_layer})}doInitialSchematicComponentRender(){if(this.root?.schematicDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,s=e.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=s.schematic_group_id;for(let l of this.children)l.schematic_component_id&&e.schematic_component.update(l.schematic_component_id,{schematic_group_id:s.schematic_group_id})}_getSchematicLayoutMode(){let e=this._parsedProps;if(e.schLayout?.layoutMode==="none"||e.schLayout?.layoutMode==="relative")return"relative";if(e.schLayout?.matchAdapt)return"match-adapt";if(e.schLayout?.flex)return"flex";if(e.schLayout?.grid)return"grid";if(e.schMatchAdapt)return"match-adapt";if(e.schFlex)return"flex";if(e.schGrid)return"grid";if(e.matchAdapt)return"match-adapt";if(e.flex)return"flex";if(e.grid)return"grid";if(e.relative||e.schRelative)return"relative";let a=this.children.some(l=>{let d=l._parsedProps;return d?.schX!==void 0||d?.schY!==void 0}),s=(e.manualEdits?.schematic_placements?.length??0)>0;return!a&&!s?"match-adapt":"relative"}doInitialSchematicLayout(){let e=this._getSchematicLayoutMode();e==="match-adapt"&&this._doInitialSchematicLayoutMatchpack(),e==="grid"&&this._doInitialSchematicLayoutGrid(),e==="flex"&&this._doInitialSchematicLayoutFlex(),this._insertSchematicBorder()}_doInitialSchematicLayoutMatchAdapt(){QGt(this)}_doInitialSchematicLayoutMatchpack(){tXt(this)}_doInitialSchematicLayoutGrid(){nXt(this)}_doInitialSchematicLayoutFlex(){aXt(this)}_getPcbLayoutMode(){let e=this._parsedProps;if(e.pcbLayout?.matchAdapt)return"match-adapt";if(e.pcbLayout?.flex)return"flex";if(e.pcbLayout?.grid)return"grid";if(e.pcbLayout?.pack)return"pack";if(e.pcbFlex)return"flex";if(e.pcbGrid)return"grid";if(e.pcbPack||e.pack)return"pack";if(e.matchAdapt)return"match-adapt";if(e.flex)return"flex";if(e.grid)return"grid";let a=e.pcbX!==void 0||e.pcbY!==void 0,s=(e.manualEdits?.pcb_placements?.length??0)>0;if(this.children.some(x=>{let f=x._parsedProps;return f?.pcbX!==void 0||f?.pcbY!==void 0}))return"none";let d=this.children.reduce((x,f)=>{let m=f._parsedProps,y=m?.pcbX!==void 0||m?.pcbY!==void 0;return x+(y?0:1)},0);return!a&&!s&&d>1?"pack":"none"}doInitialPcbLayout(){let e=this._getPcbLayoutMode();e==="grid"?this._doInitialPcbLayoutGrid():e==="pack"?this._doInitialPcbLayoutPack():e==="flex"&&this._doInitialPcbLayoutFlex()}_doInitialPcbLayoutGrid(){sXt(this)}_doInitialPcbLayoutPack(){gXt(this)}_doInitialPcbLayoutFlex(){yXt(this)}_insertSchematicBorder(){if(this.root?.schematicDisabled)return;let{db:e}=this.root,a=this._parsedProps;if(!a.border)return;let s=typeof a.schWidth=="number"?a.schWidth:void 0,l=typeof a.schHeight=="number"?a.schHeight:void 0,d=typeof a.schPadding=="number"?a.schPadding:0,x=typeof a.schPaddingLeft=="number"?a.schPaddingLeft:d,f=typeof a.schPaddingRight=="number"?a.schPaddingRight:d,m=typeof a.schPaddingTop=="number"?a.schPaddingTop:d,y=typeof a.schPaddingBottom=="number"?a.schPaddingBottom:d,b=this.schematic_group_id?e.schematic_group.get(this.schematic_group_id):null;if(b&&(s===void 0&&typeof b.width=="number"&&(s=b.width),l===void 0&&typeof b.height=="number"&&(l=b.height)),s===void 0||l===void 0)return;let E=b?.center??this._getGlobalSchematicPositionBeforeLayout(),A=E.x-s/2-x,w=E.y-l/2-y,B=s+x+f,I=l+m+y;e.schematic_box.insert({width:B,height:I,x:A,y:w,is_dashed:a.border?.dashed??!1})}_determineSideFromPosition(e,a){if(!e.center||!a.center)return"left";let s=e.center.x-a.center.x,l=e.center.y-a.center.y;return Math.abs(s)>Math.abs(l)?s>0?"right":"left":l>0?"bottom":"top"}_calculateSchematicBounds(e){if(e.length===0)return{minX:0,maxX:0,minY:0,maxY:0};let a=1/0,s=-1/0,l=1/0,d=-1/0;for(let f of e)a=Math.min(a,f.centerX),s=Math.max(s,f.centerX),l=Math.min(l,f.centerY),d=Math.max(d,f.centerY);let x=2;return{minX:a-x,maxX:s+x,minY:l-x,maxY:d+x}}_getAutorouterConfig(){let e=this._parsedProps.autorouter||this.getInheritedProperty("autorouter");return hXt(e)}_getSubcircuitLayerCount(){let e=this.getInheritedProperty("layers");return typeof e=="number"?e:2}_shouldUseTraceByTraceRouting(){return this._getAutorouterConfig().groupMode==="sequential-trace"}doInitialPcbDesignRuleChecks(){if(this.root?.pcbDisabled||this.getInheritedProperty("routingDisabled"))return;let{db:e}=this.root;if(this.isSubcircuit){let a=new Map;for(let s of this.children)if(!s.isSubcircuit&&s._parsedProps.name){let l=a.get(s._parsedProps.name)||[];l.push(s),a.set(s._parsedProps.name,l)}for(let[s,l]of a.entries())l.length>1&&e.pcb_trace_error.insert({error_type:"pcb_trace_error",message:`Multiple components found with name "${s}" in subcircuit "${this.name||"unnamed"}". Component names must be unique within a subcircuit.`,source_trace_id:"",pcb_trace_id:"",pcb_component_ids:l.map(d=>d.pcb_component_id).filter(Boolean),pcb_port_ids:[]})}}doInitialSchematicReplaceNetLabelsWithSymbols(){if(this.root?.schematicDisabled||!this.isSubcircuit)return;let{db:e}=this.root,a=e;for(let s of a.schematic_net_label.list()){let l=a.source_net.get(s.source_net_id),d=s.text||l?.name||"";if(s.anchor_side==="top"&&/^gnd/i.test(d)){a.schematic_net_label.update(s.schematic_net_label_id,{symbol_name:"ground_down"});continue}s.anchor_side==="bottom"&&/^v/i.test(d)&&a.schematic_net_label.update(s.schematic_net_label_id,{symbol_name:"vcc_up"})}}_getMinimumFlexContainerSize(){return super._getMinimumFlexContainerSize()}_repositionOnPcb(e){return super._repositionOnPcb(e)}},kwe=class extends zg{constructor(){super(...arguments);X(this,"pcb_board_id",null);X(this,"_drcChecksComplete",!1);X(this,"_connectedSchematicPortPairs",new Set)}get isSubcircuit(){return!0}get isGroup(){return!0}get config(){return{componentName:"Board",zodProps:fY}}get boardThickness(){let{_parsedProps:e}=this;return 1.4}get allLayers(){return(this._parsedProps.layers??2)===4?["top","bottom","inner1","inner2"]:["top","bottom"]}_getSubcircuitLayerCount(){return this._parsedProps.layers??2}doInitialPcbBoardAutoSize(){if(this.root?.pcbDisabled||!this.pcb_board_id)return;let{db:e}=this.root,{_parsedProps:a}=this;if(a.width&&a.height)return;let s=1/0,l=1/0,d=-1/0,x=-1/0,f=Bwe(e,this.subcircuit_id),m=new Set([this.subcircuit_id,...f]),y=e.pcb_component.list().filter(O=>O.subcircuit_id&&m.has(O.subcircuit_id)),b=e.pcb_group.list().filter(O=>O.subcircuit_id&&m.has(O.subcircuit_id)),E=!1,A=(O,V,te)=>{V===0||te===0||(E=!0,s=Math.min(s,O.x-V/2),l=Math.min(l,O.y-te/2),d=Math.max(d,O.x+V/2),x=Math.max(x,O.y+te/2))};for(let O of y)A(O.center,O.width,O.height);for(let O of b)A(O.center,O.width,O.height);let w=2,B=E?d-s+w*2:0,I=E?x-l+w*2:0,q={x:E?(s+d)/2+(a.outlineOffsetX??0):a.outlineOffsetX??0,y:E?(l+x)/2+(a.outlineOffsetY??0):a.outlineOffsetY??0},G=a.width??B,j=a.height??I;e.pcb_board.update(this.pcb_board_id,{width:G,height:j,center:q})}_addBoardInformationToSilkscreen(){let e=this.root?.platform;if(!e?.printBoardInformationToSilkscreen)return;let a=this.root.db.pcb_board.get(this.pcb_board_id);if(!a)return;let s=[];if(e.projectName&&s.push(e.projectName),e.version&&s.push(`v${e.version}`),e.url&&s.push(e.url),s.length===0)return;let l=s.join(`
1078
+ `),f={x:a.center.x+a.width/2-.25,y:a.center.y-a.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:l,ccw_rotation:0,anchor_alignment:"bottom_right",anchor_position:f})}doInitialPcbComponentRender(){if(this.root?.pcbDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,s=a.width??0,l=a.height??0,d={x:(a.pcbX??0)+(a.outlineOffsetX??0),y:(a.pcbY??0)+(a.outlineOffsetY??0)};if(a.outline){let f=a.outline.map(w=>w.x),m=a.outline.map(w=>w.y),y=Math.min(...f),b=Math.max(...f),E=Math.min(...m),A=Math.max(...m);s=b-y,l=A-E,d={x:(y+b)/2+(a.outlineOffsetX??0),y:(E+A)/2+(a.outlineOffsetY??0)}}let x=e.pcb_board.insert({center:d,thickness:this.boardThickness,num_layers:this.allLayers.length,width:s,height:l,outline:a.outline?.map(f=>({x:f.x+(a.outlineOffsetX??0),y:f.y+(a.outlineOffsetY??0)})),material:a.material});this.pcb_board_id=x.pcb_board_id,this._addBoardInformationToSilkscreen()}removePcbComponentRender(){let{db:e}=this.root;this.pcb_board_id&&(e.pcb_board.delete(this.pcb_board_id),this.pcb_board_id=null)}_computePcbGlobalTransformBeforeLayout(){return go()}doInitialPcbDesignRuleChecks(){this.root?.pcbDisabled||this.getInheritedProperty("routingDisabled")||super.doInitialPcbDesignRuleChecks()}updatePcbDesignRuleChecks(){if(this.root?.pcbDisabled||this.getInheritedProperty("routingDisabled"))return;let{db:e}=this.root;if(!this._areChildSubcircuitsRouted()||this._drcChecksComplete)return;this._drcChecksComplete=!0;let a=pSe(e.toArray());for(let l of a)e.pcb_trace_error.insert(l);let s=dSe(e.toArray());for(let l of s)e.pcb_port_not_connected_error.insert(l)}_emitRenderLifecycleEvent(e,a){super._emitRenderLifecycleEvent(e,a),a==="start"&&this.root?.emit("board:renderPhaseStarted",{renderId:this._renderId,phase:e})}},NXt=new Proxy({},{get:(n,e)=>e}),cd=NXt,Mwe=class extends Za{get config(){return{componentName:"Capacitor",schematicSymbolName:this.props.polarized?"capacitor_polarized":this.props.symbolName??"capacitor",zodProps:L8e,sourceFtype:cd.simple_capacitor}}initPorts(){typeof this.props.footprint=="string"?super.initPorts({additionalAliases:{pin1:["anode","pos"],pin2:["cathode","neg"]}}):super.initPorts()}_getSchematicSymbolDisplayValue(){let n=this.props.capacitance,e=typeof n=="string"?n:`${Is(this._parsedProps.capacitance)}F`;return this._parsedProps.schShowRatings&&this._parsedProps.maxVoltageRating?`${e}/${Is(this._parsedProps.maxVoltageRating)}V`:e}doInitialCreateNetsFromProps(){this._createNetsFromProps([this.props.decouplingFor,this.props.decouplingTo,...this._getNetsFromConnectionsProp()])}doInitialCreateTracesFromProps(){this.props.decouplingFor&&this.props.decouplingTo&&(this.add(new zc({from:`${this.getSubcircuitSelector()} > port.1`,to:this.props.decouplingFor})),this.add(new zc({from:`${this.getSubcircuitSelector()} > port.2`,to:this.props.decouplingTo}))),this._createTracesFromConnectionsProp()}doInitialSourceRender(){let{db:n}=this.root,{_parsedProps:e}=this,a=n.source_component.insert({ftype:"simple_capacitor",name:this.name,manufacturer_part_number:e.manufacturerPartNumber??e.mfn,supplier_part_numbers:e.supplierPartNumbers,capacitance:e.capacitance,max_voltage_rating:e.maxVoltageRating,max_decoupling_trace_length:e.maxDecouplingTraceLength,display_capacitance:this._getSchematicSymbolDisplayValue(),are_pins_interchangeable:!e.polarized});this.source_component_id=a.source_component_id}};function kXt(n){if(!n)return{validPinLabels:n,invalidPinLabelsMessages:[]};let e={},a=[];for(let[s,l]of Object.entries(n)){let d=Array.isArray(l)?l.slice():[l],x=[];for(let f of d)MXt(s,f)?x.push(f):a.push(`Invalid pin label: ${s} = '${f}' - excluding from component. Please use a valid pin label.`);x.length>0&&(e[s]=Array.isArray(l)?x:x[0])}return{validPinLabels:Object.keys(e).length>0?e:void 0,invalidPinLabelsMessages:a}}function MXt(n,e){try{let a={name:"test",footprint:"test",pinLabels:{[n]:e}};return Lb.safeParse(a).success}catch{return!1}}var HW=class extends Za{constructor(e){let a={...e},s=[];if(a.pinLabels){let{validPinLabels:l,invalidPinLabelsMessages:d}=kXt(a.pinLabels);a.pinLabels=l,s=d}super(a);X(this,"schematicBoxDimensions",null);X(this,"_invalidPinLabelMessages",[]);this._invalidPinLabelMessages=s}get config(){return{componentName:"Chip",zodProps:Lb,shouldRenderAsSchematicBox:!0}}initPorts(e={}){super.initPorts(e);let{_parsedProps:a}=this;if(a.externallyConnectedPins){let s=new Set;for(let[l,d]of a.externallyConnectedPins)s.add(l),s.add(d);for(let l of s)if(!this.children.find(x=>x instanceof Fo&&x.isMatchingAnyOf([l]))){let x=l.match(/^pin(\d+)$/);if(x){let f=parseInt(x[1]);this.add(new Fo({pinNumber:f,aliases:[l]}))}else this.add(new Fo({name:l,aliases:[l]}))}}}doInitialSchematicComponentRender(){let{_parsedProps:e}=this;if(e?.noSchematicRepresentation!==!0){if(this._invalidPinLabelMessages?.length&&this.root?.db)for(let a of this._invalidPinLabelMessages){let s="pinLabels",l=a.match(/^Invalid pin label:\s*([^=]+)=\s*'([^']+)'/);l&&(s=`pinLabels['${l[2]}']`),this.root.db.source_property_ignored_warning.insert({source_component_id:this.source_component_id,property_name:s,message:a,error_type:"source_property_ignored_warning"})}super.doInitialSchematicComponentRender()}}doInitialSourceRender(){let{db:e}=this.root,{_parsedProps:a}=this,s=e.source_component.insert({ftype:"simple_chip",name:this.name,manufacturer_part_number:a.manufacturerPartNumber,supplier_part_numbers:a.supplierPartNumbers});this.source_component_id=s.source_component_id}doInitialPcbComponentRender(){if(this.root?.pcbDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,s=e.pcb_component.insert({center:{x:a.pcbX??0,y:a.pcbY??0},width:2,height:3,layer:a.layer??"top",rotation:a.pcbRotation??0,source_component_id:this.source_component_id,subcircuit_id:this.getSubcircuit().subcircuit_id??void 0});this.pcb_component_id=s.pcb_component_id}doInitialCreateTracesFromProps(){let{_parsedProps:e}=this;if(e.externallyConnectedPins)for(let[a,s]of e.externallyConnectedPins)this.add(new zc({from:`${this.getSubcircuitSelector()} > port.${a}`,to:`${this.getSubcircuitSelector()} > port.${s}`}));this._createTracesFromConnectionsProp()}doInitialSimulationRender(){let{db:e}=this.root,{pinAttributes:a}=this.props;if(!a)return;let s=null,l=null,d,x=this.selectAll("port");for(let E of x)for(let A of E.getNameAndAliases())if(a[A]){let w=a[A];w.providesPower&&(s=E,d=w.providesVoltage),w.providesGround&&(l=E)}if(!s||!l||d===void 0)return;let f=e.source_port.get(s.source_port_id);if(!f?.subcircuit_connectivity_map_key)return;let m=e.source_port.get(l.source_port_id);if(!m?.subcircuit_connectivity_map_key)return;let y=e.source_net.getWhere({subcircuit_connectivity_map_key:f.subcircuit_connectivity_map_key}),b=e.source_net.getWhere({subcircuit_connectivity_map_key:m.subcircuit_connectivity_map_key});!y||!b||e.simulation_voltage_source.insert({type:"simulation_voltage_source",positive_source_port_id:s.source_port_id,positive_source_net_id:y.source_net_id,negative_source_port_id:l.source_port_id,negative_source_net_id:b.source_net_id,voltage:d})}},Owe=class extends Za{constructor(){super(...arguments);X(this,"pos",this.portMap.pin1);X(this,"anode",this.portMap.pin1);X(this,"neg",this.portMap.pin2);X(this,"cathode",this.portMap.pin2)}get config(){let e={schottky:"schottky_diode",avalanche:"avalanche_diode",zener:"zener_diode",photodiode:"photodiode"},a=this.props.schottky?"schottky":this.props.avalanche?"avalanche":this.props.zener?"zener":this.props.photo?"photodiode":null;return{schematicSymbolName:a?e[a]:this.props.symbolName??"diode",componentName:"Diode",zodProps:eAe,sourceFtype:"simple_diode"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}doInitialSourceRender(){let{db:e}=this.root,{_parsedProps:a}=this,s=e.source_component.insert({ftype:"simple_diode",name:this.name,manufacturer_part_number:a.manufacturerPartNumber??a.mfn,supplier_part_numbers:a.supplierPartNumbers,are_pins_interchangeable:!1});this.source_component_id=s.source_component_id}},Lwe=class extends Za{get config(){return{componentName:"fuse",schematicSymbolName:this.props.symbolName??"fuse",zodProps:P8e,sourceFtype:cd.simple_fuse}}_getSchematicSymbolDisplayValue(){let n=this._parsedProps.currentRating,e=this._parsedProps.voltageRating,a=typeof n=="string"?parseFloat(n):n,s=typeof e=="string"?parseFloat(e):e;return`${Is(a)}A / ${Is(s)}V`}doInitialSourceRender(){let{db:n}=this.root,{_parsedProps:e}=this,a=typeof e.currentRating=="string"?parseFloat(e.currentRating):e.currentRating,s=typeof e.voltageRating=="string"?parseFloat(e.voltageRating):e.voltageRating,l=n.source_component.insert({name:this.name,ftype:cd.simple_fuse,current_rating_amps:a,voltage_rating_volts:s,display_current_rating:`${Is(a)}A`,display_voltage_rating:`${Is(s)}V`});this.source_component_id=l.source_component_id}},$we=class extends Za{constructor(){super(...arguments);X(this,"schematicDimensions",null)}get config(){return{schematicSymbolName:void 0,componentName:"Jumper",zodProps:mY,shouldRenderAsSchematicBox:!0}}_getSchematicPortArrangement(){let e=super._getSchematicPortArrangement();if(e&&Object.keys(e).length>0)return e;let a=this._parsedProps.pinCount??(Array.isArray(this._parsedProps.pinLabels)?this._parsedProps.pinLabels.length:this._parsedProps.pinLabels?Object.keys(this._parsedProps.pinLabels).length:this.getPortsFromFootprint().length),s=this._parsedProps.schDirection??"right";return{leftSize:s==="left"?a:0,rightSize:s==="right"?a:0}}doInitialSourceRender(){let{db:e}=this.root,{_parsedProps:a}=this,s=e.source_component.insert({ftype:"simple_chip",name:this.name,manufacturer_part_number:a.manufacturerPartNumber,supplier_part_numbers:a.supplierPartNumbers,are_pins_interchangeable:!0});this.source_component_id=s.source_component_id}doInitialPcbComponentRender(){if(this.root?.pcbDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,s=e.pcb_component.insert({center:{x:a.pcbX??0,y:a.pcbY??0},width:2,height:3,layer:a.layer??"top",rotation:a.pcbRotation??0,source_component_id:this.source_component_id,subcircuit_id:this.getSubcircuit().subcircuit_id??void 0});this.pcb_component_id=s.pcb_component_id}doInitialPcbTraceRender(){let{db:e}=this.root,a=e.pcb_port.list({pcb_component_id:this.pcb_component_id}),s={};for(let x=0;x<a.length;x++){let f=a[x],m=e.source_port.get(f.source_port_id),y="";if(typeof m?.pin_number=="number")y=m.pin_number.toString();else if(Array.isArray(m?.port_hints)){let b=m.port_hints.find(E=>/^(pin)?\d+$/.test(E));b&&(/^pin\d+$/.test(b)?y=b.replace(/^pin/,""):y=b)}s[y]=f.pcb_port_id}let l=e.pcb_trace.list({pcb_component_id:this.pcb_component_id}),d=x=>{if(x&&typeof x=="string"&&x.startsWith("{PIN")){let f=x.replace("{PIN","").replace("}","");return s[f]||x}return x};for(let x of l)if(x.route)for(let f of x.route)f.route_type==="wire"&&(f.start_pcb_port_id=d(f.start_pcb_port_id),f.end_pcb_port_id=d(f.end_pcb_port_id))}},zwe=class extends Za{constructor(){super(...arguments);X(this,"schematicDimensions",null)}_getPinNumberFromBridgedPinName(e){return this.selectOne(`port.${e}`,{type:"port"})?._parsedProps.pinNumber??null}get defaultInternallyConnectedPinNames(){if(this._parsedProps.bridged){let e=this.children.filter(a=>a.componentName==="Port").map(a=>a.name);return e.length>0?[e]:[]}return this._parsedProps.bridgedPins??[]}get config(){let e=this._parsedProps??this.props,a=e.pinCount;if(e.pinCount==null&&!e.footprint&&(a=2),e.pinCount==null){let d=(e.bridgedPins??[]).flat().map(y=>this._getPinNumberFromBridgedPinName(y)).filter(y=>y!==null),x=d.length>0?Math.max(...d):0,f=e.pinLabels?Object.keys(e.pinLabels).length:0,m=Math.max(x,f);(m===2||m===3)&&(a=m),a==null&&e.footprint&&[2,3].includes(this.getPortsFromFootprint().length)&&(a=this.getPortsFromFootprint().length)}let s="";a?s+=`solderjumper${a}`:s="solderjumper";let l=[];return Array.isArray(e.bridgedPins)&&e.bridgedPins.length>0?l=Array.from(new Set(e.bridgedPins.flat().map(d=>this._getPinNumberFromBridgedPinName(d)).filter(d=>d!==null))).sort((d,x)=>d-x):e.bridged&&a&&(l=Array.from({length:a},(d,x)=>x+1)),l.length>0&&(s+=`_bridged${l.join("")}`),{schematicSymbolName:e.symbolName??s,componentName:"SolderJumper",zodProps:T8e,shouldRenderAsSchematicBox:!0}}_getSchematicPortArrangement(){let e=super._getSchematicPortArrangement();if(e&&Object.keys(e).length>0)return e;let a=this._parsedProps.pinCount??(Array.isArray(this._parsedProps.pinLabels)?this._parsedProps.pinLabels.length:this._parsedProps.pinLabels?Object.keys(this._parsedProps.pinLabels).length:this.getPortsFromFootprint().length);a==null&&!this._parsedProps.footprint&&(a=2);let s=this._parsedProps.schDirection??"right";return{leftSize:s==="left"?a:0,rightSize:s==="right"?a:0}}doInitialSourceRender(){let{db:e}=this.root,{_parsedProps:a}=this,s=e.source_component.insert({ftype:"simple_chip",name:this.name,manufacturer_part_number:a.manufacturerPartNumber,supplier_part_numbers:a.supplierPartNumbers,are_pins_interchangeable:!0});this.source_component_id=s.source_component_id}doInitialPcbComponentRender(){if(this.root?.pcbDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,s=e.pcb_component.insert({center:{x:a.pcbX??0,y:a.pcbY??0},width:2,height:3,layer:a.layer??"top",rotation:a.pcbRotation??0,source_component_id:this.source_component_id,subcircuit_id:this.getSubcircuit().subcircuit_id??void 0});this.pcb_component_id=s.pcb_component_id}doInitialPcbTraceRender(){let{db:e}=this.root,a=e.pcb_port.list({pcb_component_id:this.pcb_component_id}),s={};for(let x=0;x<a.length;x++){let f=a[x],m=e.source_port.get(f.source_port_id),y="";if(typeof m?.pin_number=="number")y=m.pin_number.toString();else if(Array.isArray(m?.port_hints)){let b=m.port_hints.find(E=>/^(pin)?\d+$/.test(E));b&&(/^pin\d+$/.test(b)?y=b.replace(/^pin/,""):y=b)}s[y]=f.pcb_port_id}let l=e.pcb_trace.list({pcb_component_id:this.pcb_component_id}),d=x=>{if(x&&typeof x=="string"&&x.startsWith("{PIN")){let f=x.replace("{PIN","").replace("}","");return s[f]||x}return x};for(let x of l)if(x.route)for(let f of x.route)f.route_type==="wire"&&(f.start_pcb_port_id=d(f.start_pcb_port_id),f.end_pcb_port_id=d(f.end_pcb_port_id))}},qwe=class extends Za{constructor(){super(...arguments);X(this,"pos",this.portMap.pin1);X(this,"anode",this.portMap.pin1);X(this,"neg",this.portMap.pin2);X(this,"cathode",this.portMap.pin2)}get config(){let e={laser:"laser_diode"},a=this.props.laser?"laser":null;return{schematicSymbolName:a?e[a]:this.props.symbolName??"led",componentName:"Led",zodProps:rAe,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}doInitialSourceRender(){let{db:e}=this.root,{_parsedProps:a}=this,s=e.source_component.insert({ftype:"simple_led",name:this.name,wave_length:a.wavelength,color:a.color,symbol_display_value:this._getSchematicSymbolDisplayValue(),manufacturer_part_number:a.manufacturerPartNumber??a.mfn,supplier_part_numbers:a.supplierPartNumbers,are_pins_interchangeable:!1});this.source_component_id=s.source_component_id}},Uwe=class extends Za{constructor(){super(...arguments);X(this,"pos",this.portMap.pin1);X(this,"positive",this.portMap.pin1);X(this,"neg",this.portMap.pin2);X(this,"negative",this.portMap.pin2)}get config(){return{schematicSymbolName:this.props.symbolName??"power_factor_meter_horz",componentName:"PowerSource",zodProps:dAe,sourceFtype:"simple_power_source"}}initPorts(){this.add(new Fo({name:"pin1",pinNumber:1,aliases:["positive","pos"]})),this.add(new Fo({name:"pin2",pinNumber:2,aliases:["negative","neg"]}))}doInitialSourceRender(){let{db:e}=this.root,{_parsedProps:a}=this,s=e.source_component.insert({ftype:"simple_power_source",name:this.name,voltage:a.voltage,supplier_part_numbers:a.supplierPartNumbers,are_pins_interchangeable:!1});this.source_component_id=s.source_component_id}},OXt=ps.extend({voltage:vi.optional(),frequency:Nc.optional(),peakToPeakVoltage:vi.optional(),waveShape:C.enum(["sinewave","square","triangle","sawtooth"]).optional(),phase:Ia.optional(),dutyCycle:C.number().optional()}),Vwe=class extends Za{constructor(){super(...arguments);X(this,"terminal1",this.portMap.terminal1);X(this,"terminal2",this.portMap.terminal2)}get config(){return{componentName:"VoltageSource",schematicSymbolName:this.props.waveShape==="square"?"square_wave":"ac_voltmeter",zodProps:OXt,sourceFtype:"simple_voltage_source"}}runRenderPhaseForChildren(e){if(!e.startsWith("Pcb"))for(let a of this.children)a.runRenderPhaseForChildren(e),a.runRenderPhase(e)}doInitialPcbComponentRender(){}initPorts(){super.initPorts({additionalAliases:{pin1:["terminal1"],pin2:["terminal2"]}})}doInitialSourceRender(){let{db:e}=this.root,{_parsedProps:a}=this,s=e.source_component.insert({ftype:"simple_voltage_source",name:this.name,voltage:a.voltage,frequency:a.frequency,peak_to_peak_voltage:a.peakToPeakVoltage,wave_shape:a.waveShape,phase:a.phase,duty_cycle:a.dutyCycle,supplier_part_numbers:a.supplierPartNumbers,are_pins_interchangeable:!0});this.source_component_id=s.source_component_id}doInitialSimulationRender(){let{db:e}=this.root,{_parsedProps:a}=this,s=this.portMap.terminal1,l=this.portMap.terminal2;e.simulation_voltage_source.insert({type:"simulation_voltage_source",is_dc_source:!1,terminal1_source_port_id:s.source_port_id,terminal2_source_port_id:l.source_port_id,voltage:a.voltage,frequency:a.frequency,peak_to_peak_voltage:a.peakToPeakVoltage,wave_shape:a.waveShape,phase:a.phase,duty_cycle:a.dutyCycle})}},Gwe=class extends Za{get config(){return{componentName:"Resistor",schematicSymbolName:this.props.symbolName??"boxresistor",zodProps:j8e,sourceFtype:"simple_resistor"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}_getSchematicSymbolDisplayValue(){return`${Is(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 zc({from:`${this.getSubcircuitSelector()} > port.1`,to:this.props.pullupFor})),this.add(new zc({from:`${this.getSubcircuitSelector()} > port.2`,to:this.props.pullupTo}))),this.props.pulldownFor&&this.props.pulldownTo&&(this.add(new zc({from:`${this.getSubcircuitSelector()} > port.1`,to:this.props.pulldownFor})),this.add(new zc({from:`${this.getSubcircuitSelector()} > port.2`,to:this.props.pulldownTo}))),this._createTracesFromConnectionsProp()}doInitialSourceRender(){let{db:n}=this.root,{_parsedProps:e}=this,a=n.source_component.insert({ftype:"simple_resistor",name:this.name,manufacturer_part_number:e.manufacturerPartNumber??e.mfn,supplier_part_numbers:e.supplierPartNumbers,resistance:e.resistance,display_resistance:this._getSchematicSymbolDisplayValue(),are_pins_interchangeable:!0});this.source_component_id=a.source_component_id}},LXt=["leftedge","rightedge","topedge","bottomedge","center"],Xwe=class extends ga{get config(){return{componentName:"Constraint",zodProps:z8e}}constructor(n){if(super(n),("xdist"in n||"ydist"in n)&&!("edgeToEdge"in n)&&!("centerToCenter"in n))throw new Error(`edgeToEdge, centerToCenter must be set for xDist or yDist for ${this}`);if("for"in n&&n.for.length<2)throw new Error(`"for" must have at least two selectors for ${this}`)}_getAllReferencedComponents(){let n=[],e=this.getPrimitiveContainer();function a(s){let l=s.split(" ").pop(),d=LXt.includes(l)?l:void 0,x=d?s.replace(` ${d}`,""):s,f=e.selectOne(x,{pcbPrimitive:!0});f&&n.push({selector:s,component:f,componentSelector:x,edge:d})}for(let s of["left","right","top","bottom"])s in this._parsedProps&&a(this._parsedProps[s]);if("for"in this._parsedProps)for(let s of this._parsedProps.for)a(s);return{componentsWithSelectors:n}}},Ywe=class extends ga{constructor(){super(...arguments);X(this,"fabrication_note_path_id",null)}get config(){return{componentName:"FabricationNotePath",zodProps:iAe}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:e}=this.root,a=this.getSubcircuit(),{_parsedProps:s}=this,l=s.layer??"top";if(l!=="top"&&l!=="bottom")throw new Error(`Invalid layer "${l}" for SilkscreenPath. Must be "top" or "bottom".`);let d=this._computePcbGlobalTransformBeforeLayout(),x=this.parent?.pcb_component_id??this.getPrimitiveContainer()?.pcb_component_id,f=e.pcb_fabrication_note_path.insert({pcb_component_id:x,layer:l,color:s.color,route:s.route.map(m=>{let y=vs(d,{x:m.x,y:m.y});return{...m,x:y.x,y:y.y}}),stroke_width:s.strokeWidth??.1,subcircuit_id:a?.subcircuit_id??void 0});this.fabrication_note_path_id=f.pcb_fabrication_note_path_id}},Hwe=class extends ga{get config(){return{componentName:"FabricationNoteText",zodProps:sAe}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:n}=this.root,{_parsedProps:e}=this,a=this.getPrimitiveContainer(),s=this.getSubcircuit();n.pcb_fabrication_note_text.insert({anchor_alignment:e.anchorAlignment,anchor_position:{x:e.pcbX??0,y:e.pcbY??0},font:e.font??"tscircuit2024",font_size:e.fontSize??1,layer:"top",color:e.color,text:e.text??"",pcb_component_id:a.pcb_component_id,subcircuit_id:s?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0})}},Wwe=class extends zg{constructor(n){super({...n,subcircuit:!0})}},Kwe=class extends zg{constructor(n){super({...n,subcircuit:!0})}doInitialPcbPrimitiveRender(){if(super.doInitialPcbPrimitiveRender(),this.root?.pcbDisabled)return;let{db:n}=this.root,e=this._parsedProps;if(!this.pcb_group_id)return;let a=n.pcb_group.get(this.pcb_group_id),s=e.paddingLeft??e.padding??0,l=e.paddingRight??e.padding??0,d=e.paddingTop??e.padding??0,x=e.paddingBottom??e.padding??0;n.pcb_group.update(this.pcb_group_id,{width:a.width+s+l,height:a.height+d+x,center:{x:a.center.x+(l-s)/2,y:a.center.y+(d-x)/2}})}},Jwe=class extends ga{constructor(){super(...arguments);X(this,"pcb_breakout_point_id",null);X(this,"matchedPort",null);X(this,"matchedNet",null);X(this,"isPcbPrimitive",!0)}get config(){return{componentName:"BreakoutPoint",zodProps:cAe}}_matchConnection(){let{connection:e}=this._parsedProps,a=this.getSubcircuit();a&&(this.matchedPort=a.selectOne(e,{type:"port"}),this.matchedPort||(this.matchedNet=a.selectOne(e,{type:"net"})),!this.matchedPort&&!this.matchedNet&&this.renderError(`Could not find connection target "${e}"`))}_getSourceTraceIdForPort(e){let{db:a}=this.root;return a.source_trace.list().find(l=>l.connected_source_port_ids.includes(e.source_port_id))?.source_trace_id}_getSourceNetIdForPort(e){let{db:a}=this.root;return a.source_trace.list().find(l=>l.connected_source_port_ids.includes(e.source_port_id))?.connected_source_net_ids[0]}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:e}=this.root;this._matchConnection();let{pcbX:a=0,pcbY:s=0}=this._parsedProps,l=this.parent?.getGroup(),d=this.getSubcircuit();if(!l||!l.pcb_group_id)return;let x=e.pcb_breakout_point.insert({pcb_group_id:l.pcb_group_id,subcircuit_id:d?.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:a,y:s});this.pcb_breakout_point_id=x.pcb_breakout_point_id}_getPcbCircuitJsonBounds(){let{pcbX:e=0,pcbY:a=0}=this._parsedProps;return{center:{x:e,y:a},bounds:{left:e,top:a,right:e,bottom:a},width:0,height:0}}_setPositionFromLayout(e){let{db:a}=this.root;this.pcb_breakout_point_id&&a.pcb_breakout_point.update(this.pcb_breakout_point_id,{x:e.x,y:e.y})}getPcbSize(){return{width:0,height:0}}},Zwe=class extends ga{constructor(){super(...arguments);X(this,"source_net_label_id")}get config(){return{componentName:"NetLabel",zodProps:W8e}}_getAnchorSide(){let{_parsedProps:e}=this;if(e.anchorSide)return e.anchorSide;if(!this._resolveConnectsTo())return"right";let s=this._getGlobalSchematicPositionBeforeLayout(),l=this._getConnectedPorts();if(l.length===0)return"right";let d=l[0]._getGlobalSchematicPositionBeforeLayout(),x=d.x-s.x,f=d.y-s.y;if(Math.abs(x)>Math.abs(f)){if(x>0)return"right";if(x<0)return"left"}else{if(f>0)return"top";if(f<0)return"bottom"}return"right"}_getConnectedPorts(){let e=this._resolveConnectsTo();if(!e)return[];let a=[];for(let s of e){let l=this.getSubcircuit().selectOne(s);l&&a.push(l)}return a}computeSchematicPropsTransform(){let{_parsedProps:e}=this;if(e.schX===void 0&&e.schY===void 0){let a=this._getConnectedPorts();if(a.length>0){let s=a[0]._getGlobalSchematicPositionBeforeLayout(),l=vs(this.parent?.computeSchematicGlobalTransform?.()??go(),{x:0,y:0});return ja(s.x-l.x,s.y-l.y)}}return super.computeSchematicPropsTransform()}doInitialSchematicPrimitiveRender(){if(this.root?.schematicDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,s=this._getGlobalSchematicPositionBeforeLayout(),l=this.getSubcircuit().selectOne(`net.${this._getNetName()}`),d=a.anchorSide??"right",x=nx({anchor_position:s,anchor_side:d,text:a.net}),f=e.schematic_net_label.insert({text:a.net,source_net_id:l.source_net_id,anchor_position:s,center:x,anchor_side:this._getAnchorSide()});this.source_net_label_id=f.source_net_id}_resolveConnectsTo(){let{_parsedProps:e}=this,a=e.connectsTo??e.connection;if(Array.isArray(a))return a;if(typeof a=="string")return[a]}_getNetName(){let{_parsedProps:e}=this;return e.net}doInitialCreateNetsFromProps(){let{_parsedProps:e}=this;e.net&&zW(this,[`net.${e.net}`])}doInitialCreateTracesFromNetLabels(){if(this.root?.schematicDisabled)return;let e=this._resolveConnectsTo();if(e)for(let a of e)this.add(new zc({from:a,to:`net.${this._getNetName()}`}))}doInitialSchematicTraceRender(){if(!this.root?._featureMspSchematicTraceRouting||this.root?.schematicDisabled)return;let{db:e}=this.root,a=this._resolveConnectsTo();if(!a||a.length===0)return;let s=this._getGlobalSchematicPositionBeforeLayout(),l=this._getAnchorSide(),x={left:"x-",right:"x+",top:"y+",bottom:"y-"}[l],f=this.getSubcircuit().selectOne(`net.${this._getNetName()}`);for(let m of a){let y=this.getSubcircuit().selectOne(m,{type:"port"});if(!y||!y.schematic_port_id)continue;let b=!1;if(f?.source_net_id){let q=e.source_trace.list().find(G=>G.connected_source_net_ids?.includes(f.source_net_id)&&G.connected_source_port_ids?.includes(y.source_port_id??""));if(q&&(b=e.schematic_trace.list().some(G=>G.source_trace_id===q.source_trace_id)),b)continue}let E=y._getGlobalSchematicPositionAfterLayout(),A=kW(y.facingDirection??"right")??"x+",w=f5({x:E.x,y:E.y,facingDirection:A},{x:s.x,y:s.y,facingDirection:x});if(!Array.isArray(w)||w.length<2)continue;let B=[];for(let q=0;q<w.length-1;q++)B.push({from:{x:w[q].x,y:w[q].y},to:{x:w[q+1].x,y:w[q+1].y}});let I;f?.source_net_id&&y.source_port_id&&(I=e.source_trace.list().find(G=>G.connected_source_net_ids?.includes(f.source_net_id)&&G.connected_source_port_ids?.includes(y.source_port_id))?.source_trace_id),e.schematic_trace.insert({source_trace_id:I,edges:B,junctions:[]}),e.schematic_port.update(y.schematic_port_id,{is_connected:!0})}}},Qwe=class extends ga{constructor(){super(...arguments);X(this,"pcb_silkscreen_circle_id",null);X(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenCircle",zodProps:FAe}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,{maybeFlipLayer:s}=this._getPcbPrimitiveFlippedHelpers(),l=s(a.layer??"top");if(l!=="top"&&l!=="bottom")throw new Error(`Invalid layer "${l}" for SilkscreenCircle. Must be "top" or "bottom".`);let d=this._computePcbGlobalTransformBeforeLayout(),x=this.getSubcircuit(),f=this.parent?.pcb_component_id??this.getPrimitiveContainer()?.pcb_component_id,m=e.pcb_silkscreen_circle.insert({pcb_component_id:f,layer:l,center:{x:a.pcbX??0,y:a.pcbY??0},radius:a.radius,subcircuit_id:x?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0,stroke_width:a.strokeWidth??.1});this.pcb_silkscreen_circle_id=m.pcb_silkscreen_circle_id}getPcbSize(){let{_parsedProps:e}=this,a=e.radius*2;return{width:a,height:a}}},e9e=class extends ga{constructor(){super(...arguments);X(this,"pcb_silkscreen_rect_id",null);X(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenRect",zodProps:bAe}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,{maybeFlipLayer:s}=this._getPcbPrimitiveFlippedHelpers(),l=s(a.layer??"top");if(l!=="top"&&l!=="bottom")throw new Error(`Invalid layer "${l}" for SilkscreenRect. Must be "top" or "bottom".`);let d=this.getSubcircuit(),x=this.parent?.pcb_component_id??this.getPrimitiveContainer()?.pcb_component_id,f=e.pcb_silkscreen_rect.insert({pcb_component_id:x,layer:l,center:{x:a.pcbX??0,y:a.pcbY??0},width:a.width,height:a.height,subcircuit_id:d?.subcircuit_id??void 0,pcb_group_id:this?.getGroup()?.pcb_group_id??void 0,stroke_width:a.strokeWidth??.1});this.pcb_silkscreen_rect_id=f.pcb_silkscreen_rect_id}getPcbSize(){let{_parsedProps:e}=this;return{width:e.width,height:e.height}}},t9e=class extends ga{constructor(){super(...arguments);X(this,"pcb_silkscreen_line_id",null);X(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenLine",zodProps:DAe}}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,{maybeFlipLayer:s}=this._getPcbPrimitiveFlippedHelpers(),l=s(a.layer??"top");if(l!=="top"&&l!=="bottom")throw new Error(`Invalid layer "${l}" for SilkscreenLine. Must be "top" or "bottom".`);let d=this.getSubcircuit(),x=this.parent?.pcb_component_id??this.getPrimitiveContainer()?.pcb_component_id,f=e.pcb_silkscreen_line.insert({pcb_component_id:x,layer:l,x1:a.x1,y1:a.y1,x2:a.x2,y2:a.y2,stroke_width:a.strokeWidth??.1,subcircuit_id:d?.subcircuit_id??void 0,pcb_group_id:d?.getGroup()?.pcb_group_id??void 0});this.pcb_silkscreen_line_id=f.pcb_silkscreen_line_id}getPcbSize(){let{_parsedProps:e}=this,a=Math.abs(e.x2-e.x1),s=Math.abs(e.y2-e.y1);return{width:a,height:s}}},r9e=class extends ga{constructor(){super(...arguments);X(this,"pcb_via_id",null);X(this,"matchedPort",null);X(this,"isPcbPrimitive",!0)}get config(){return{componentName:"Via",zodProps:oAe}}getAvailablePcbLayers(){return["top","inner1","inner2","bottom"]}getPcbSize(){let{_parsedProps:e}=this;return{width:e.outerDiameter,height:e.outerDiameter}}_getPcbCircuitJsonBounds(){let{db:e}=this.root,a=e.pcb_via.get(this.pcb_via_id),s=this.getPcbSize();return{center:{x:a.x,y:a.y},bounds:{left:a.x-s.width/2,top:a.y-s.height/2,right:a.x+s.width/2,bottom:a.y+s.height/2},width:s.width,height:s.height}}_setPositionFromLayout(e){let{db:a}=this.root;a.pcb_via.update(this.pcb_via_id,{x:e.x,y:e.y})}doInitialPcbPrimitiveRender(){if(this.root?.pcbDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,s=this._getGlobalPcbPositionBeforeLayout(),l=this.getSubcircuit(),d=e.pcb_via.insert({x:s.x,y:s.y,hole_diameter:a.holeDiameter,outer_diameter:a.outerDiameter,layers:["bottom","top"],from_layer:a.fromLayer||"bottom",to_layer:a.toLayer||"top",subcircuit_id:l?.subcircuit_id??void 0,pcb_group_id:this.getGroup()?.pcb_group_id??void 0});this.pcb_via_id=d.pcb_via_id}},n9e=class extends Za{get config(){return{componentName:"Battery",schematicSymbolName:this.props.symbolName??"battery",zodProps:Y8e,sourceFtype:"simple_power_source"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}doInitialSourceRender(){let{db:n}=this.root,{_parsedProps:e}=this,a=n.source_component.insert({name:this.name,ftype:"simple_power_source",capacity:e.capacity,supplier_part_numbers:e.supplierPartNumbers,are_pins_interchangeable:!1});this.source_component_id=a.source_component_id}},a9e=class extends Za{get config(){return{componentName:"PinHeader",zodProps:H8e,shouldRenderAsSchematicBox:!0}}_getImpliedFootprintString(){let n=this._parsedProps.pinCount??(Array.isArray(this._parsedProps.pinLabels)?this._parsedProps.pinLabels.length:this._parsedProps.pinLabels?Object.keys(this._parsedProps.pinLabels).length:0),e=this._parsedProps.holeDiameter,a=this._parsedProps.platedDiameter,s=this._parsedProps.pitch,l=this._parsedProps.showSilkscreenPinLabels;if(n>0){let d;if(s)!e&&!a?d=`pinrow${n}_p${s}`:d=`pinrow${n}_p${s}_id${e}_od${a}`;else if(!e&&!a)d=`pinrow${n}`;else return null;return l!==!0&&(d+="_nopinlabels"),d}return null}initPorts(){let n=this._parsedProps.pinCount??(Array.isArray(this._parsedProps.pinLabels)?this._parsedProps.pinLabels.length:this._parsedProps.pinLabels?Object.keys(this._parsedProps.pinLabels).length:1);for(let e=1;e<=n;e++){let a=Array.isArray(this._parsedProps.pinLabels)?this._parsedProps.pinLabels[e-1]:this._parsedProps.pinLabels?.[`pin${e}`];if(a){let s=Array.isArray(a)?a[0]:a,l=Array.isArray(a)?a.slice(1):[];this.add(new Fo({pinNumber:e,name:s,aliases:[`pin${e}`,...l]}))}else this.add(new Fo({pinNumber:e,name:`pin${e}`}))}}_getSchematicPortArrangement(){let n=this._parsedProps.pinCount??1,e=this._parsedProps.schFacingDirection??this._parsedProps.facingDirection??"right",a=this._parsedProps.schPinArrangement;return e==="left"?{leftSide:{direction:a?.leftSide?.direction??"top-to-bottom",pins:a?.leftSide?.pins??Array.from({length:n},(s,l)=>`pin${l+1}`)}}:{rightSide:{direction:a?.rightSide?.direction??"top-to-bottom",pins:a?.rightSide?.pins??Array.from({length:n},(s,l)=>`pin${l+1}`)}}}doInitialSourceRender(){let{db:n}=this.root,{_parsedProps:e}=this,a=n.source_component.insert({ftype:"simple_pin_header",name:this.name,supplier_part_numbers:e.supplierPartNumbers,pin_count:e.pinCount,gender:e.gender,are_pins_interchangeable:!0});this.source_component_id=a.source_component_id}};function $Xt(n){switch(n){case"two_ground_pins":return"crystal_4pin";case"ground_pin":return"resonator";case"no_ground":return"crystal";default:return"crystal"}}var s9e=class extends Za{get config(){return{componentName:"Resonator",schematicSymbolName:this.props.symbolName??$Xt(this.props.pinVariant),zodProps:O8e,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){let{db:n}=this.root,{_parsedProps:e}=this,a=e.pinVariant||"no_ground",s=n.source_component.insert({ftype:"simple_resonator",name:this.name,frequency:e.frequency,load_capacitance:e.loadCapacitance,supplier_part_numbers:e.supplierPartNumbers,pin_variant:a,are_pins_interchangeable:a==="no_ground"||a==="ground_pin"});this.source_component_id=s.source_component_id}_getSchematicSymbolDisplayValue(){let n=`${Is(this._parsedProps.frequency)}Hz`;return this._parsedProps.loadCapacitance?`${n} / ${Is(this._parsedProps.loadCapacitance)}F`:n}},i9e=class extends Za{get config(){return{componentName:"Inductor",schematicSymbolName:this.props.symbolName??"inductor",zodProps:Q8e,sourceFtype:cd.simple_inductor}}_getSchematicSymbolDisplayValue(){return`${Is(this._parsedProps.inductance)}H`}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}doInitialSourceRender(){let{db:n}=this.root,{_parsedProps:e}=this,a=n.source_component.insert({name:this.name,ftype:cd.simple_inductor,inductance:e.inductance,supplier_part_numbers:e.supplierPartNumbers,are_pins_interchangeable:!0});this.source_component_id=a.source_component_id}};function zXt(n){switch(n){case"three_pin":return"potentiometer3";case"two_pin":return"potentiometer2";default:return"potentiometer2"}}var o9e=class extends Za{get config(){return{componentName:"Potentiometer",schematicSymbolName:this.props.symbolName??zXt(this.props.pinVariant),zodProps:k8e,shouldRenderAsSchematicBox:!1}}_getSchematicSymbolDisplayValue(){return`${Is(this._parsedProps.maxResistance)}\u03A9`}doInitialSourceRender(){let{db:n}=this.root,{_parsedProps:e}=this,a=e.pinVariant||"two_pin",s=n.source_component.insert({ftype:"simple_potentiometer",name:this.name,max_resistance:e.maxResistance,pin_variant:a,are_pins_interchangeable:a==="two_pin"});this.source_component_id=s.source_component_id}},u9e=class extends Za{get config(){return{componentName:"PushButton",schematicSymbolName:this.props.symbolName??"push_button_normally_open_momentary",zodProps:K8e,sourceFtype:cd.simple_push_button}}get defaultInternallyConnectedPinNames(){return[]}initPorts(){super.initPorts({pinCount:2,ignoreSymbolPorts:!0});let n=Ts[this._getSchematicSymbolNameOrThrow()],e=n.ports.find(y=>y.labels.includes("1")),a=n.ports.find(y=>y.labels.includes("2")),s=this.selectAll("port"),l=s.find(y=>y.props.pinNumber===1),d=s.find(y=>y.props.pinNumber===2),x=s.find(y=>y.props.pinNumber===3),f=s.find(y=>y.props.pinNumber===4),{internallyConnectedPins:m}=this._parsedProps;l.schematicSymbolPortDef=e,(!m||m.length===0)&&(d.schematicSymbolPortDef=a);for(let[y,b]of[[2,d],[3,x],[4,f]]){let E=m?.find(([w,B])=>w===`pin${y}`||B===`pin${y}`);if(!E){b.schematicSymbolPortDef=a;break}(E?.[0]===`pin${y}`?E[1]:E?.[0])!=="pin1"&&(b.schematicSymbolPortDef=a)}}doInitialSourceRender(){let{db:n}=this.root,{_parsedProps:e}=this,a=n.source_component.insert({name:this.name,ftype:cd.simple_push_button,supplier_part_numbers:e.supplierPartNumbers,are_pins_interchangeable:!0});this.source_component_id=a.source_component_id}},c9e=class extends Za{get config(){return{schematicSymbolName:this.props.symbolName??(this.props.pinVariant==="four_pin"?"crystal_4pin":"crystal"),componentName:"Crystal",zodProps:M8e,sourceFtype:"simple_crystal"}}initPorts(){let n=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:n})}_getSchematicSymbolDisplayValue(){let n=`${Is(this._parsedProps.frequency)}Hz`;return this._parsedProps.loadCapacitance?`${n} / ${Is(this._parsedProps.loadCapacitance)}F`:n}doInitialSourceRender(){let{db:n}=this.root,{_parsedProps:e}=this,a=n.source_component.insert({name:this.name,ftype:"simple_crystal",frequency:e.frequency,load_capacitance:e.loadCapacitance,pin_variant:e.pinVariant||"two_pin",are_pins_interchangeable:(e.pinVariant||"two_pin")==="two_pin"});this.source_component_id=a.source_component_id}},l9e=class extends Za{constructor(){super(...arguments);X(this,"emitter",this.portMap.pin1);X(this,"collector",this.portMap.pin2);X(this,"base",this.portMap.pin3)}get config(){let e=this.props.type==="npn"?"npn_bipolar_transistor":"pnp_bipolar_transistor";return{componentName:"Transistor",schematicSymbolName:this.props.symbolName??e,zodProps:J8e,sourceFtype:"simple_transistor",shouldRenderAsSchematicBox:!1}}initPorts(){let e={pin1:["collector","c"],pin2:["emitter","e"],pin3:["base","b"]};super.initPorts({pinCount:3,additionalAliases:e})}doInitialCreateNetsFromProps(){this._createNetsFromProps([...this._getNetsFromConnectionsProp()])}doInitialCreateTracesFromProps(){this._createTracesFromConnectionsProp()}doInitialSourceRender(){let{db:e}=this.root,{_parsedProps:a}=this,s=e.source_component.insert({ftype:"simple_transistor",name:this.name,transistor_type:a.type});this.source_component_id=s.source_component_id}},d9e=class extends Za{get config(){let n=this.props.mosfetMode==="depletion"?"d":"e",a=`${this.props.channelType}_channel_${n}_mosfet_transistor`;return{componentName:"Mosfet",schematicSymbolName:this.props.symbolName??a,zodProps:Z8e,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){let{db:n}=this.root,{_parsedProps:e}=this,a=n.source_component.insert({ftype:"simple_mosfet",name:this.name,mosfet_mode:e.mosfetMode,channel_type:e.channelType});this.source_component_id=a.source_component_id}},p9e=class extends Za{_getSwitchType(){let{spst:n,spdt:e,dpst:a,dpdt:s,type:l}=this._parsedProps??{};return s?"dpdt":n?"spst":e?"spdt":a?"dpst":l??"spst"}get config(){let n=this._getSwitchType(),{isNormallyClosed:e}=this._parsedProps??{},s={spst:e?"spst_normally_closed_switch":"spst_switch",spdt:e?"spdt_normally_closed_switch":"spdt_switch",dpst:e?"dpst_normally_closed_switch":"dpst_switch",dpdt:e?"dpdt_normally_closed_switch":"dpdt_switch"}[n]??"spst_switch";return{componentName:"Switch",schematicSymbolName:this.props.symbolName??s,zodProps:aAe,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){let{db:n}=this.root,{_parsedProps:e}=this,a=n.source_component.insert({ftype:"simple_switch",name:this.name,switch_type:e.type,is_normally_closed:e.isNormallyClosed??!1,are_pins_interchangeable:this._getSwitchType()==="spst"});this.source_component_id=a.source_component_id}},IW={HOLE_DIAMETER:.5,SMT_CIRCLE_DIAMETER:1.2,SMT_RECT_SIZE:2},x9e=class extends Za{get config(){return{componentName:"TestPoint",schematicSymbolName:this.props.symbolName??"testpoint",zodProps:uAe,sourceFtype:cd.simple_test_point}}_getPropsWithDefaults(){let{padShape:n,holeDiameter:e,footprintVariant:a,padDiameter:s,width:l,height:d}=this._parsedProps;return!a&&e&&(a="through_hole"),a??(a="through_hole"),n??(n="circle"),a==="pad"?n==="circle"?s??(s=IW.SMT_CIRCLE_DIAMETER):n==="rect"&&(l??(l=IW.SMT_RECT_SIZE),d??(d=l)):a==="through_hole"&&(e??(e=IW.HOLE_DIAMETER)),{padShape:n,holeDiameter:e,footprintVariant:a,padDiameter:s,width:l,height:d}}_getImpliedFootprintString(){let{padShape:n,holeDiameter:e,footprintVariant:a,padDiameter:s,width:l,height:d}=this._getPropsWithDefaults();if(a==="through_hole")return`platedhole_d${e}`;if(a==="pad"){if(n==="circle")return`smtpad_circle_d${s}`;if(n==="rect")return`smtpad_rect_w${l}_h${d}`}throw new Error(`Footprint variant "${a}" with pad shape "${n}" not implemented`)}doInitialSourceRender(){let{db:n}=this.root,{_parsedProps:e}=this,{padShape:a,holeDiameter:s,footprintVariant:l,padDiameter:d,width:x,height:f}=this._getPropsWithDefaults(),m=n.source_component.insert({ftype:cd.simple_test_point,name:this.name,supplier_part_numbers:e.supplierPartNumbers,footprint_variant:l,pad_shape:a,pad_diameter:d,hole_diameter:s,width:x,height:f,are_pins_interchangeable:!0});this.source_component_id=m.source_component_id}},f9e=class extends ga{constructor(){super(...arguments);X(this,"isSchematicPrimitive",!0)}get config(){return{componentName:"SchematicText",zodProps:xAe}}doInitialSchematicPrimitiveRender(){if(this.root?.schematicDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,s=this._getGlobalSchematicPositionBeforeLayout();e.schematic_text.insert({anchor:a.anchor??"center",text:a.text,font_size:a.fontSize,color:a.color||"#000000",position:{x:s.x,y:s.y},rotation:a.schRotation??0})}};function qXt({anchor:n,x:e,y:a,width:s,height:l,isInside:d}){switch(n){case"top_left":return{x:e,y:a+l,textAnchor:d?"top_left":"bottom_left"};case"top_center":return{x:e+s/2,y:a+l,textAnchor:d?"top_center":"bottom_center"};case"top_right":return{x:e+s,y:a+l,textAnchor:d?"top_right":"bottom_right"};case"center_left":return{x:e,y:a+l/2,textAnchor:d?"center_left":"center_right"};case"center":return{x:e+s/2,y:a+l/2,textAnchor:"center"};case"center_right":return{x:e+s,y:a+l/2,textAnchor:d?"center_right":"center_left"};case"bottom_left":return{x:e,y:a,textAnchor:d?"bottom_left":"top_left"};case"bottom_center":return{x:e+s/2,y:a,textAnchor:d?"bottom_center":"top_center"};case"bottom_right":return{x:e+s,y:a,textAnchor:d?"bottom_right":"top_right"};default:return{x:e+s/2,y:a+l,textAnchor:"center"}}}var h9e=class extends ga{constructor(){super(...arguments);X(this,"isSchematicPrimitive",!0)}get config(){return{componentName:"SchematicBox",zodProps:pAe,shouldRenderAsSchematicBox:!0}}doInitialSchematicPrimitiveRender(){if(this.root?.schematicDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,s=.6,l=typeof a.padding=="number"?a.padding:0,d=typeof a.paddingTop=="number"?a.paddingTop:l,x=typeof a.paddingBottom=="number"?a.paddingBottom:l,f=typeof a.paddingLeft=="number"?a.paddingLeft:l,m=typeof a.paddingRight=="number"?a.paddingRight:l,y=a.overlay&&a.overlay.length>0,b=typeof a.width=="number"&&typeof a.height=="number",E,A,w,B,I,q;if(y){let j=a.overlay.map(Qe=>({selector:Qe,port:this.getSubcircuit().selectOne(Qe,{type:"port"})})).filter(({port:Qe})=>Qe!=null).map(({port:Qe})=>({position:Qe._getGlobalSchematicPositionAfterLayout()}));if(j.length===0)return;let O=j.map(Qe=>Qe.position.x),V=j.map(Qe=>Qe.position.y),te=Math.min(...O),N=Math.max(...O),se=Math.min(...V),$=Math.max(...V),W=N-te,Q=$-se,le=W===0?s:0,z=Q===0?s:0,pe=f+le/2,xe=m+le/2,Ae=d+z/2,Ie=x+z/2,Le=te-pe,dt=N+xe,rt=se-Ie,et=$+Ae;E=dt-Le,A=et-rt,w=Le+(a.schX??0),B=rt+(a.schY??0),I=w+E/2,q=B+A/2}else if(b){E=a.width,A=a.height;let G=this._getGlobalSchematicPositionBeforeLayout();I=G.x,q=G.y,w=I-E/2,B=q-A/2}else return;if(e.schematic_box.insert({height:A,width:E,x:w,y:B,is_dashed:a.strokeStyle==="dashed"}),a.title){let G=a.titleInside,j=.1,O=a.titleAlignment,V=qXt({anchor:O,x:w,y:B,width:E,height:A,isInside:G}),te,N,se=V.textAnchor;G?(te=O.includes("top")?-j:O.includes("bottom")?j:0,N=O.includes("left")?j:O.includes("right")?-j:0):(te=O.includes("top")?j:O.includes("bottom")?-j:0,N=O.includes("center_left")?-j:O.includes("center_right")?j:0);let $=V.x+N,W=V.y+te;e.schematic_text.insert({anchor:se,text:a.title,font_size:a.titleFontSize??.18,color:a.titleColor??"#000000",position:{x:$,y:W},rotation:0})}}},m9e=class extends ga{constructor(){super(...arguments);X(this,"isSchematicPrimitive",!0);X(this,"schematic_table_id",null)}get config(){return{componentName:"SchematicTable",zodProps:fAe}}doInitialSchematicPrimitiveRender(){if(this.root?.schematicDisabled)return;let{db:e}=this.root,{_parsedProps:a}=this,s=this.children.filter(A=>A.componentName==="SchematicRow");if(s.length===0)return;let l=[],d=0;for(let A of s){let w=A.children.filter(B=>B.componentName==="SchematicCell");d=Math.max(d,w.length)}for(let A=0;A<s.length;A++)l[A]=[];for(let A=0;A<s.length;A++){let B=s[A].children.filter(q=>q.componentName==="SchematicCell"),I=0;for(let q=0;q<B.length;q++){for(;l[A][I];)I++;let G=B[q],j=G._parsedProps.colSpan??1,O=G._parsedProps.rowSpan??1;for(let V=0;V<O;V++)for(let te=0;te<j;te++)l[A+V]||(l[A+V]=[]),l[A+V][I+te]=G;I+=j}}d=Math.max(0,...l.map(A=>A.length));let x=s.map((A,w)=>A._parsedProps.height??1),f=Array.from({length:d},(A,w)=>{let B=0;for(let I=0;I<s.length;I++){let q=l[I]?.[w];if(q){let G=q._parsedProps.text??q._parsedProps.children,j=q._parsedProps.width??(G?.length??2)*.5;j>B&&(B=j)}}return B||10}),m=this._getGlobalSchematicPositionBeforeLayout(),y=e.schematic_table.insert({anchor_position:m,column_widths:f,row_heights:x,cell_padding:a.cellPadding,border_width:a.borderWidth,anchor:a.anchor,subcircuit_id:this.getSubcircuit()?.subcircuit_id||"",schematic_component_id:this.parent?.schematic_component_id||""});this.schematic_table_id=y.schematic_table_id;let b=new Set,E=0;for(let A=0;A<s.length;A++){let w=0;for(let B=0;B<d;B++){let I=l[A]?.[B];if(I&&!b.has(I)){b.add(I);let q=I._parsedProps,G=q.rowSpan??1,j=q.colSpan??1,O=0;for(let te=0;te<j;te++)O+=f[B+te];let V=0;for(let te=0;te<G;te++)V+=x[A+te];e.schematic_table_cell.insert({schematic_table_id:this.schematic_table_id,start_row_index:A,end_row_index:A+G-1,start_column_index:B,end_column_index:B+j-1,text:q.text??q.children,center:{x:m.x+w+O/2,y:m.y-E-V/2},width:O,height:V,horizontal_align:q.horizontalAlign,vertical_align:q.verticalAlign,font_size:q.fontSize??a.fontSize,subcircuit_id:this.getSubcircuit()?.subcircuit_id||""})}f[B]&&(w+=f[B])}E+=x[A]}}},g9e=class extends ga{constructor(){super(...arguments);X(this,"isSchematicPrimitive",!0)}get config(){return{componentName:"SchematicRow",zodProps:hAe}}},y9e=class extends ga{constructor(){super(...arguments);X(this,"isSchematicPrimitive",!0);X(this,"canHaveTextChildren",!0)}get config(){return{componentName:"SchematicCell",zodProps:mAe}}},UXt={name:"@tscircuit/core",type:"module",version:"0.0.673",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"'},devDependencies:{"@biomejs/biome":"^1.8.3","@tscircuit/capacity-autorouter":"^0.0.100","@tscircuit/checks":"^0.0.71","@tscircuit/circuit-json-util":"^0.0.67","@tscircuit/footprinter":"^0.0.208","@tscircuit/import-snippet":"^0.0.4","@tscircuit/infgrid-ijump-astar":"^0.0.33","@tscircuit/log-soup":"^1.0.2","@tscircuit/matchpack":"^0.0.9","@tscircuit/math-utils":"^0.0.18","@tscircuit/miniflex":"^0.0.4","@tscircuit/props":"0.0.289","@tscircuit/schematic-autolayout":"^0.0.6","@tscircuit/schematic-match-adapt":"^0.0.16","@tscircuit/schematic-trace-solver":"^0.0.23","@tscircuit/simple-3d-svg":"^0.0.38","@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.9","chokidar-cli":"^3.0.0","circuit-json":"^0.0.236","circuit-json-to-bpc":"^0.0.13","circuit-json-to-connectivity-map":"^0.0.22","circuit-json-to-simple-3d":"^0.0.6","circuit-to-svg":"^0.0.174",concurrently:"^9.1.2","connectivity-map":"^1.0.0",debug:"^4.3.6","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",react:"^19.1.0","react-dom":"^19.1.0","schematic-symbols":"^0.0.195","ts-expect":"^1.3.0",tsup:"^8.2.4"},peerDependencies:{"@tscircuit/capacity-autorouter":"*","@tscircuit/checks":"*","@tscircuit/circuit-json-util":"*","@tscircuit/footprinter":"*","@tscircuit/infgrid-ijump-astar":"*","@tscircuit/math-utils":"*","@tscircuit/props":"*","@tscircuit/schematic-autolayout":"*","@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.29","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"}},qg=class{constructor({platform:n,projectUrl:e}={}){X(this,"firstChild",null);X(this,"children");X(this,"db");X(this,"root",null);X(this,"isRoot",!0);X(this,"schematicDisabled",!1);X(this,"pcbDisabled",!1);X(this,"pcbRoutingDisabled",!1);X(this,"_featureMspSchematicTraceRouting",!0);X(this,"name");X(this,"platform");X(this,"projectUrl");X(this,"_hasRenderedAtleastOnce",!1);X(this,"_eventListeners",{});this.children=[],this.db=ua([]),this.root=this,this.platform=n,this.projectUrl=e,this.pcbDisabled=n?.pcbDisabled??!1}add(n){let e;(0,D9e.isValidElement)(n)?e=bwe(n):e=n,this.children.push(e)}_getBoard(){return this.children.find(n=>n.componentName==="Board")}_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(...))");if(this.children.length===1&&this.children[0].isGroup){this.firstChild=this.children[0];return}let n=new zg({subcircuit:!0});n.parent=this,n.addAll(this.children),this.children=[n],this.firstChild=n}render(){this.firstChild||this._guessRootComponent();let{firstChild:n,db:e}=this;if(!n)throw new Error("RootCircuit has no root component");n.parent=this,n.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(e=>setTimeout(e,100)),this.render();this.emit("renderComplete")}_hasIncompleteAsyncEffects(){return this.children.some(n=>n._hasIncompleteAsyncEffects()?!0:n.children.some(e=>e._hasIncompleteAsyncEffects()))}getCircuitJson(){return this._hasRenderedAtleastOnce||this.render(),this.db.toArray()}toJson(){return this.getCircuitJson()}async getSvg(n){let e=await Promise.resolve().then(()=>(HSe(),YSe)).catch(a=>{throw new Error(`To use circuit.getSvg, you must install the "circuit-to-svg" package.
1079
1079
 
1080
1080
  "${a.message}"`)});if(n.view==="pcb")return e.convertCircuitJsonToPcbSvg(this.getCircuitJson());if(n.view==="schematic")return e.convertCircuitJsonToSchematicSvg(this.getCircuitJson());throw new Error(`Invalid view: ${n.view}`)}getCoreVersion(){let[n,e,a]=UXt.version.split(".").map(Number);return`${n}.${e}.${a+1}`}async preview(n){let e=typeof n=="object"?n:{previewName:n};throw new Error("project.preview is not yet implemented")}computeSchematicGlobalTransform(){return go()}_computePcbGlobalTransformBeforeLayout(){return go()}selectAll(n){return this._guessRootComponent(),this.firstChild?.selectAll(n)??[]}selectOne(n,e){return this._guessRootComponent(),this.firstChild?.selectOne(n,e)??null}emit(n,...e){if(this._eventListeners[n])for(let a of this._eventListeners[n])a(...e)}on(n,e){this._eventListeners[n]||(this._eventListeners[n]=[]),this._eventListeners[n].push(e)}removeListener(n,e){this._eventListeners[n]&&(this._eventListeners[n]=this._eventListeners[n].filter(a=>a!==e))}getClientOrigin(){return typeof window<"u"&&window.location?window.location.origin:typeof self<"u"&&self.location?self.location.origin:""}},VXt=qg,GXt=qg,XXt=n=>{let[e,a]=Lg.default.useState(!0),[s,l]=Lg.default.useState(null),[d,x]=Lg.default.useState(),[f,m]=Lg.default.useState();return Lg.default.useEffect(()=>{a(!0),l(null),n&&setTimeout(()=>{try{let y=new qg;y.add(n),x(y),m(y.toJson())}catch(y){l(y)}a(!1)},1)},[n]),{isLoading:e,error:s,circuit:d,circuitJson:f}},Ug=(n,e)=>(a,s)=>{let l=[];Array.isArray(e)?l.push(...e.flat()):typeof e=="object"&&l.push(...Object.values(e).flat(),...Object.keys(e));let d=x=>{if(x?.name&&x.name!==a)throw new Error(`Component name mismatch. Hook name: ${a}, Component prop name: ${x.name}`);let f={...s,...x,name:a},m=[];for(let y of l)if(f[y]){let b=`.${a} > .${y}`,E=f[y];m.push({from:b,to:E}),delete f[y]}return(0,B1.jsxs)(B1.Fragment,{children:[(0,B1.jsx)(n,{...f}),m.map((y,b)=>(0,B1.jsx)("trace",{...y},b))]})};for(let x of l)d[x]=`.${a} > .${x}`;return d},YXt=Ug(n=>(0,b9e.jsx)("capacitor",{...n}),$8e),HXt=n=>Ug(e=>(0,F9e.jsx)("chip",{pinLabels:n,...e}),n),WXt=Ug(n=>(0,E9e.jsx)("diode",{...n}),tAe),KXt=Ug(n=>(0,v9e.jsx)("led",{...n}),nAe),JXt=Ug(n=>(0,C9e.jsx)("resistor",{...n}),N8e),ZXt=new Proxy(n=>new Proxy({},{get:(e,a)=>`.${n} > .${a}`}),{get:(n,e)=>{let a=(...s)=>{let l=s[0];return new Proxy({},{get:(d,x)=>`.${e} > .${x}`})};return new Proxy(a,{get:(s,l)=>e==="net"?`net.${l}`:e==="subcircuit"?new Proxy({},{get:(d,x)=>new Proxy({},{get:(f,m)=>`subcircuit.${l} > .${x} > .${m}`})}):`.${e} > .${l}`,apply:(s,l,d)=>e==="net"?new Proxy({},{get:(x,f)=>`net.${f}`}):new Proxy({},{get:(x,f)=>{let m=`.${e} > .${f}`;return["U","J","CN"].some(b=>e.startsWith(b))?m:new Proxy(new String(m),{get:(b,E)=>typeof E=="symbol"||E==="toString"?()=>m:`.${e} > .${f} > .${E}`})}})})}});Dwe(hwe);Dwe({Bug:HW});var S9e=Xr(z0(),1);var WW=new Map,Eo=async(n,e)=>{let a=new URLSearchParams({...e,json:"true"}).toString();if(WW.has(a))return WW.get(a);let l=await(await fetch(`https://jlcsearch.tscircuit.com/${n}/list?${a}`)).json();return WW.set(a,l),l},A9e={findPart:async({sourceComponent:n,footprinterString:e})=>{if(n.type==="source_component"&&n.ftype==="simple_resistor"){let{resistors:a}=await Eo("resistors",{resistance:n.display_resistance??n.resistance,package:e});return{jlcpcb:(a??[]).map(s=>`C${s.lcsc}`).slice(0,3)}}else if(n.type==="source_component"&&n.ftype==="simple_capacitor"){e?.includes("cap")&&(e=e.replace("cap",""));let{capacitors:a}=await Eo("capacitors",{capacitance:n.display_capacitance??n.capacitance,package:e});return{jlcpcb:(a??[]).map(s=>`C${s.lcsc}`).slice(0,3)}}else if(n.type==="source_component"&&n.ftype==="simple_pin_header"){let a;e?.includes("_p")&&(a=Number(e.split("_p")[1]));let{headers:s}=await Eo("headers",a?{pitch:a,num_pins:n.pin_count,gender:n.gender}:{num_pins:n.pin_count,gender:n.gender});return{jlcpcb:(s??[]).map(l=>`C${l.lcsc}`).slice(0,3)}}else if(n.type==="source_component"&&n.ftype==="simple_potentiometer"){let{potentiometers:a}=await Eo("potentiometers",{resistance:n.max_resistance,package:e});return{jlcpcb:(a??[]).map(s=>`C${s.lcsc}`).slice(0,3)}}else if(n.type==="source_component"&&n.ftype==="simple_diode"){let{diodes:a}=await Eo("diodes",{package:e});return{jlcpcb:(a??[]).map(s=>`C${s.lcsc}`).slice(0,3)}}else if(n.type==="source_component"&&n.ftype==="simple_chip"){let{chips:a}=await Eo("chips",{package:e});return{jlcpcb:(a??[]).map(s=>`C${s.lcsc}`).slice(0,3)}}else if(n.type==="source_component"&&n.ftype==="simple_transistor"){let{transistors:a}=await Eo("transistors",{package:e,transistor_type:n.transistor_type});return{jlcpcb:(a??[]).map(s=>`C${s.lcsc}`).slice(0,3)}}else if(n.type==="source_component"&&n.ftype==="simple_power_source"){let{power_sources:a}=await Eo("power_sources",{voltage:n.voltage,package:e});return{jlcpcb:(a??[]).map(s=>`C${s.lcsc}`).slice(0,3)}}else if(n.type==="source_component"&&n.ftype==="simple_inductor"){let{inductors:a}=await Eo("inductors",{inductance:n.inductance,package:e});return{jlcpcb:(a??[]).map(s=>`C${s.lcsc}`).slice(0,3)}}else if(n.type==="source_component"&&n.ftype==="simple_crystal"){let{crystals:a}=await Eo("crystals",{frequency:n.frequency,load_capacitance:n.load_capacitance,package:e});return{jlcpcb:(a??[]).map(s=>`C${s.lcsc}`).slice(0,3)}}else if(n.type==="source_component"&&n.ftype==="simple_mosfet"){let{mosfets:a}=await Eo("mosfets",{package:e,mosfet_mode:n.mosfet_mode,channel_type:n.channel_type});return{jlcpcb:(a??[]).map(s=>`C${s.lcsc}`).slice(0,3)}}else if(n.type==="source_component"&&n.ftype==="simple_resonator"){let{resonators:a}=await Eo("resonators",{frequency:n.frequency,package:e});return{jlcpcb:(a??[]).map(s=>`C${s.lcsc}`).slice(0,3)}}else if(n.type==="source_component"&&n.ftype==="simple_switch"){let{switches:a}=await Eo("switches",{switch_type:n.type,package:e});return{jlcpcb:(a??[]).map(s=>`C${s.lcsc}`).slice(0,3)}}else if(n.type==="source_component"&&n.ftype==="simple_led"){let{leds:a}=await Eo("leds",{package:e});return{jlcpcb:(a??[]).map(s=>`C${s.lcsc}`).slice(0,3)}}else if(n.type==="source_component"&&n.ftype==="simple_fuse"){let{fuses:a}=await Eo("fuses",{package:e});return{jlcpcb:(a??[]).map(s=>`C${s.lcsc}`).slice(0,3)}}return{}}};var R9e=()=>({partsEngine:A9e});var w9e=Xr(zs(),1),Vyr=(0,w9e.default)("tsci:eval:execution-context");function HS(n,e={}){globalThis.React=S9e;let a=new qg({platform:e.platform||R9e()});return e.name&&(a.name=e.name),{fsMap:{},entrypoint:"",preSuppliedImports:{"@tscircuit/core":YS,tscircuit:YS,"@tscircuit/math-utils":yY,react:S9e,"@tscircuit/props":{}},circuit:a,...n}}function UF(n){let e=n;return e=e.replace(/\\/g,"/"),e=e.trim(),e.startsWith("./")&&(e=e.slice(2)),e.startsWith("/")&&(e=e.slice(1)),e}function B9e(n){let e={};for(let[a,s]of Object.entries(n))e[UF(a)]=s;return e}function ld(n){if(!n)return".";let a=n.replace(/\\/g,"/").replace(/\/+$/,"");return a.indexOf("/")===-1?".":a.substring(0,a.lastIndexOf("/"))||"/"}function KW(n,e){if(n.startsWith("../")){let a=ld(e);return KW(n.slice(3),a)}return n.startsWith("./")?KW(n.slice(2),e):n.startsWith("/")?n.slice(1):`${e}/${n}`}var VF=(n,e,a)=>{let s=a?KW(n,a):n,l=new Set(Array.isArray(e)?e:Object.keys(e));if(l.has(s))return s;let d=new Map;for(let m of l)d.set(UF(m),m);let x=UF(s);if(d.has(x))return d.get(x);let f=["tsx","ts","json","js","jsx"];for(let m of f){let y=`${x}.${m}`;if(d.has(y))return d.get(y)}if(!n.startsWith("./")&&!n.startsWith("../")){let m=UF(n);if(d.has(m))return d.get(m);for(let y of f){let b=`${m}.${y}`;if(d.has(b))return d.get(b)}}return null},WS=(n,e)=>{let a=VF(n,e);if(!a)throw new Error(`File not found "${n}", available paths:
1081
1081