@tscircuit/runframe 0.0.189 → 0.0.191
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/standalone-preview.min.js +3 -3
- package/dist/standalone.min.js +156 -156
- package/package.json +3 -3
|
@@ -635,10 +635,10 @@ Check the render method of %s.`,yn(Jt)||"Unknown"));var pe=gd(I,X);pe.payload={e
|
|
|
635
635
|
at `+o}return e},U8.buildMessage=function(r,e){var t={literal:function(c){return'"'+i(c.text)+'"'},class:function(c){var u=c.parts.map(function(h){return Array.isArray(h)?a(h[0])+"-"+a(h[1]):a(h)});return"["+(c.inverted?"^":"")+u.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(c){return c.description}};function n(c){return c.charCodeAt(0).toString(16).toUpperCase()}function i(c){return c.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(u){return"\\x0"+n(u)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(u){return"\\x"+n(u)})}function a(c){return c.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(u){return"\\x0"+n(u)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(u){return"\\x"+n(u)})}function o(c){return t[c.type](c)}function s(c){var u=c.map(o),h,g;if(u.sort(),u.length>0){for(h=1,g=1;h<u.length;h++)u[h-1]!==u[h]&&(u[g]=u[h],g++);u.length=g}switch(u.length){case 1:return u[0];case 2:return u[0]+" or "+u[1];default:return u.slice(0,-1).join(", ")+", or "+u[u.length-1]}}function l(c){return c?'"'+i(c)+'"':"end of input"}return"Expected "+s(r)+" but "+l(e)+" found."};function wIe(r,e){e=e!==void 0?e:{};var t={},n=e.grammarSource,i={transformList:Yt},a=Yt,o="matrix",s="(",l=")",c="translate",u="scale",h="rotate",g="skewX",_="skewY",b=",",T=".",C=/^[eE]/,A=/^[+\-]/,L=/^[0-9]/,U=/^[ \t\r\n]/,j=gn("matrix",!1),Z=gn("(",!1),ee=gn(")",!1),$=gn("translate",!1),oe=gn("scale",!1),ae=gn("rotate",!1),ce=gn("skewX",!1),me=gn("skewY",!1),_e=gn(",",!1),Se=Sr("fractionalConstant"),Ae=gn(".",!1),ze=qn(["e","E"],!1,!1),Ne=qn(["+","-"],!1,!1),Oe=qn([["0","9"]],!1,!1),Le=qn([" "," ","\r",`
|
|
636
636
|
`],!1,!1),Ie=function(on){return on},je=function(on,hr){return on.concat(hr)},Ue=function(on,hr,Jr,Kr,Wa,nn){return[{type:"matrix",a:on,b:hr,c:Jr,d:Kr,e:Wa,f:nn}]},Fe=function(on,hr){var Jr={type:"translate",tx:on};return hr&&(Jr.ty=hr),[Jr]},it=function(on,hr){var Jr={type:"scale",sx:on};return hr&&(Jr.sy=hr),[Jr]},ct=function(on,hr){var Jr={type:"rotate",angle:on};return hr&&(Jr.cx=hr[0],Jr.cy=hr[1]),[Jr]},ft=function(on){return[{type:"skewX",angle:on}]},Nt=function(on){return[{type:"skewY",angle:on}]},Rt=function(on){return parseFloat(on.join(""))},Wt=function(on){return parseInt(on.join(""))},en=function(on){return on},Gn=function(on,hr){return[on,hr]},Sn=function(on){return on.join("")},hn=function(on,hr){return[on,hr||null].join("")},_n=function(on,hr){return[on,hr].join("")},Gt=function(on,hr){return[on?on.join(""):null,".",hr.join("")].join("")},sr=function(on){return on.join("")},Jn=function(on,hr){return["e",on,hr.join("")].join("")},an=0,nr=[{line:1,column:1}],zr=0,or=[],xt=0,wt;if("startRule"in e){if(!(e.startRule in i))throw new Error(`Can't start parsing from rule "`+e.startRule+'".');a=i[e.startRule]}function gn(on,hr){return{type:"literal",text:on,ignoreCase:hr}}function qn(on,hr,Jr){return{type:"class",parts:on,inverted:hr,ignoreCase:Jr}}function ar(){return{type:"end"}}function Sr(on){return{type:"other",description:on}}function Rr(on){var hr=nr[on],Jr;if(hr)return hr;for(Jr=on-1;!nr[Jr];)Jr--;for(hr=nr[Jr],hr={line:hr.line,column:hr.column};Jr<on;)r.charCodeAt(Jr)===10?(hr.line++,hr.column=1):hr.column++,Jr++;return nr[on]=hr,hr}function Nr(on,hr,Jr){var Kr=Rr(on),Wa=Rr(hr),nn={source:n,start:{offset:on,line:Kr.line,column:Kr.column},end:{offset:hr,line:Wa.line,column:Wa.column}};return nn}function Fr(on){an<zr||(an>zr&&(zr=an,or=[]),or.push(on))}function ji(on,hr,Jr){return new U8(U8.buildMessage(on,hr),on,hr,Jr)}function Yt(){var on,hr,Jr,Kr,Wa;for(on=an,hr=[],Jr=oa();Jr!==t;)hr.push(Jr),Jr=oa();for(Jr=On(),Jr===t&&(Jr=null),Kr=[],Wa=oa();Wa!==t;)Kr.push(Wa),Wa=oa();return on=Ie(Jr),on}function On(){var on,hr,Jr,Kr;if(on=an,hr=$n(),hr!==t){if(Jr=[],Kr=vr(),Kr!==t)for(;Kr!==t;)Jr.push(Kr),Kr=vr();else Jr=t;Jr!==t?(Kr=On(),Kr!==t?on=je(hr,Kr):(an=on,on=t)):(an=on,on=t)}else an=on,on=t;return on===t&&(on=$n()),on}function $n(){var on;return on=Yn(),on===t&&(on=Hn(),on===t&&(on=sn(),on===t&&(on=yn(),on===t&&(on=xn(),on===t&&(on=Ot()))))),on}function Yn(){var on,hr,Jr,Kr,Wa,nn,It,Ln,Dr,Ii,Ca,ia,Pt,Pn,ir,Vn,kn,Yr;if(on=an,r.substr(an,6)===o?(hr=o,an+=6):(hr=t,xt===0&&Fr(j)),hr!==t){for(Jr=[],Kr=oa();Kr!==t;)Jr.push(Kr),Kr=oa();if(r.charCodeAt(an)===40?(Kr=s,an++):(Kr=t,xt===0&&Fr(Z)),Kr!==t){for(Wa=[],nn=oa();nn!==t;)Wa.push(nn),nn=oa();if(nn=mn(),nn!==t)if(It=vr(),It!==t)if(Ln=mn(),Ln!==t)if(Dr=vr(),Dr!==t)if(Ii=mn(),Ii!==t)if(Ca=vr(),Ca!==t)if(ia=mn(),ia!==t)if(Pt=vr(),Pt!==t)if(Pn=mn(),Pn!==t)if(ir=vr(),ir!==t)if(Vn=mn(),Vn!==t){for(kn=[],Yr=oa();Yr!==t;)kn.push(Yr),Yr=oa();r.charCodeAt(an)===41?(Yr=l,an++):(Yr=t,xt===0&&Fr(ee)),Yr!==t?on=Ue(nn,Ln,Ii,ia,Pn,Vn):(an=on,on=t)}else an=on,on=t;else an=on,on=t;else an=on,on=t;else an=on,on=t;else an=on,on=t;else an=on,on=t;else an=on,on=t;else an=on,on=t;else an=on,on=t;else an=on,on=t;else an=on,on=t}else an=on,on=t}else an=on,on=t;return on}function Hn(){var on,hr,Jr,Kr,Wa,nn,It,Ln,Dr;if(on=an,r.substr(an,9)===c?(hr=c,an+=9):(hr=t,xt===0&&Fr($)),hr!==t){for(Jr=[],Kr=oa();Kr!==t;)Jr.push(Kr),Kr=oa();if(r.charCodeAt(an)===40?(Kr=s,an++):(Kr=t,xt===0&&Fr(Z)),Kr!==t){for(Wa=[],nn=oa();nn!==t;)Wa.push(nn),nn=oa();if(nn=mn(),nn!==t){for(It=cn(),It===t&&(It=null),Ln=[],Dr=oa();Dr!==t;)Ln.push(Dr),Dr=oa();r.charCodeAt(an)===41?(Dr=l,an++):(Dr=t,xt===0&&Fr(ee)),Dr!==t?on=Fe(nn,It):(an=on,on=t)}else an=on,on=t}else an=on,on=t}else an=on,on=t;return on}function sn(){var on,hr,Jr,Kr,Wa,nn,It,Ln,Dr;if(on=an,r.substr(an,5)===u?(hr=u,an+=5):(hr=t,xt===0&&Fr(oe)),hr!==t){for(Jr=[],Kr=oa();Kr!==t;)Jr.push(Kr),Kr=oa();if(r.charCodeAt(an)===40?(Kr=s,an++):(Kr=t,xt===0&&Fr(Z)),Kr!==t){for(Wa=[],nn=oa();nn!==t;)Wa.push(nn),nn=oa();if(nn=mn(),nn!==t){for(It=cn(),It===t&&(It=null),Ln=[],Dr=oa();Dr!==t;)Ln.push(Dr),Dr=oa();r.charCodeAt(an)===41?(Dr=l,an++):(Dr=t,xt===0&&Fr(ee)),Dr!==t?on=it(nn,It):(an=on,on=t)}else an=on,on=t}else an=on,on=t}else an=on,on=t;return on}function yn(){var on,hr,Jr,Kr,Wa,nn,It,Ln,Dr;if(on=an,r.substr(an,6)===h?(hr=h,an+=6):(hr=t,xt===0&&Fr(ae)),hr!==t){for(Jr=[],Kr=oa();Kr!==t;)Jr.push(Kr),Kr=oa();if(r.charCodeAt(an)===40?(Kr=s,an++):(Kr=t,xt===0&&Fr(Z)),Kr!==t){for(Wa=[],nn=oa();nn!==t;)Wa.push(nn),nn=oa();if(nn=mn(),nn!==t){for(It=Xn(),It===t&&(It=null),Ln=[],Dr=oa();Dr!==t;)Ln.push(Dr),Dr=oa();r.charCodeAt(an)===41?(Dr=l,an++):(Dr=t,xt===0&&Fr(ee)),Dr!==t?on=ct(nn,It):(an=on,on=t)}else an=on,on=t}else an=on,on=t}else an=on,on=t;return on}function xn(){var on,hr,Jr,Kr,Wa,nn,It,Ln;if(on=an,r.substr(an,5)===g?(hr=g,an+=5):(hr=t,xt===0&&Fr(ce)),hr!==t){for(Jr=[],Kr=oa();Kr!==t;)Jr.push(Kr),Kr=oa();if(r.charCodeAt(an)===40?(Kr=s,an++):(Kr=t,xt===0&&Fr(Z)),Kr!==t){for(Wa=[],nn=oa();nn!==t;)Wa.push(nn),nn=oa();if(nn=mn(),nn!==t){for(It=[],Ln=oa();Ln!==t;)It.push(Ln),Ln=oa();r.charCodeAt(an)===41?(Ln=l,an++):(Ln=t,xt===0&&Fr(ee)),Ln!==t?on=ft(nn):(an=on,on=t)}else an=on,on=t}else an=on,on=t}else an=on,on=t;return on}function Ot(){var on,hr,Jr,Kr,Wa,nn,It,Ln;if(on=an,r.substr(an,5)===_?(hr=_,an+=5):(hr=t,xt===0&&Fr(me)),hr!==t){for(Jr=[],Kr=oa();Kr!==t;)Jr.push(Kr),Kr=oa();if(r.charCodeAt(an)===40?(Kr=s,an++):(Kr=t,xt===0&&Fr(Z)),Kr!==t){for(Wa=[],nn=oa();nn!==t;)Wa.push(nn),nn=oa();if(nn=mn(),nn!==t){for(It=[],Ln=oa();Ln!==t;)It.push(Ln),Ln=oa();r.charCodeAt(an)===41?(Ln=l,an++):(Ln=t,xt===0&&Fr(ee)),Ln!==t?on=Nt(nn):(an=on,on=t)}else an=on,on=t}else an=on,on=t}else an=on,on=t;return on}function mn(){var on,hr,Jr,Kr;return on=an,hr=an,Jr=Ba(),Jr===t&&(Jr=null),Kr=Ua(),Kr!==t?(Jr=[Jr,Kr],hr=Jr):(an=hr,hr=t),hr!==t&&(hr=Rt(hr)),on=hr,on===t&&(on=an,hr=an,Jr=Ba(),Jr===t&&(Jr=null),Kr=Ar(),Kr!==t?(Jr=[Jr,Kr],hr=Jr):(an=hr,hr=t),hr!==t&&(hr=Wt(hr)),on=hr),on}function cn(){var on,hr,Jr;return on=an,hr=vr(),hr!==t?(Jr=mn(),Jr!==t?on=en(Jr):(an=on,on=t)):(an=on,on=t),on}function Xn(){var on,hr,Jr,Kr,Wa;return on=an,hr=vr(),hr!==t?(Jr=mn(),Jr!==t?(Kr=vr(),Kr!==t?(Wa=mn(),Wa!==t?on=Gn(Jr,Wa):(an=on,on=t)):(an=on,on=t)):(an=on,on=t)):(an=on,on=t),on}function vr(){var on,hr,Jr,Kr,Wa;if(on=an,hr=[],Jr=oa(),Jr!==t)for(;Jr!==t;)hr.push(Jr),Jr=oa();else hr=t;if(hr!==t){for(Jr=Zr(),Jr===t&&(Jr=null),Kr=[],Wa=oa();Wa!==t;)Kr.push(Wa),Wa=oa();hr=[hr,Jr,Kr],on=hr}else an=on,on=t;if(on===t)if(on=an,hr=Zr(),hr!==t){for(Jr=[],Kr=oa();Kr!==t;)Jr.push(Kr),Kr=oa();hr=[hr,Jr],on=hr}else an=on,on=t;return on}function Zr(){var on;return r.charCodeAt(an)===44?(on=b,an++):(on=t,xt===0&&Fr(_e)),on}function Ar(){var on,hr;return on=an,hr=wa(),hr!==t&&(hr=Sn(hr)),on=hr,on}function Ua(){var on,hr,Jr;return on=an,hr=Ir(),hr!==t?(Jr=$i(),Jr===t&&(Jr=null),on=hn(hr,Jr)):(an=on,on=t),on===t&&(on=an,hr=wa(),hr!==t?(Jr=$i(),Jr!==t?on=_n(hr,Jr):(an=on,on=t)):(an=on,on=t)),on}function Ir(){var on,hr,Jr,Kr;return xt++,on=an,hr=wa(),hr===t&&(hr=null),r.charCodeAt(an)===46?(Jr=T,an++):(Jr=t,xt===0&&Fr(Ae)),Jr!==t?(Kr=wa(),Kr!==t?on=Gt(hr,Kr):(an=on,on=t)):(an=on,on=t),on===t&&(on=an,hr=wa(),hr!==t?(r.charCodeAt(an)===46?(Jr=T,an++):(Jr=t,xt===0&&Fr(Ae)),Jr!==t?on=sr(hr):(an=on,on=t)):(an=on,on=t)),xt--,on===t&&(hr=t,xt===0&&Fr(Se)),on}function $i(){var on,hr,Jr,Kr;return on=an,C.test(r.charAt(an))?(hr=r.charAt(an),an++):(hr=t,xt===0&&Fr(ze)),hr!==t?(Jr=Ba(),Jr===t&&(Jr=null),Kr=wa(),Kr!==t?on=Jn(Jr,Kr):(an=on,on=t)):(an=on,on=t),on}function Ba(){var on;return A.test(r.charAt(an))?(on=r.charAt(an),an++):(on=t,xt===0&&Fr(Ne)),on}function wa(){var on,hr;if(on=[],hr=Va(),hr!==t)for(;hr!==t;)on.push(hr),hr=Va();else on=t;return on}function Va(){var on;return L.test(r.charAt(an))?(on=r.charAt(an),an++):(on=t,xt===0&&Fr(Oe)),on}function oa(){var on;return U.test(r.charAt(an))?(on=r.charAt(an),an++):(on=t,xt===0&&Fr(Le)),on}if(wt=a(),wt!==t&&an===r.length)return wt;throw wt!==t&&an<r.length&&Fr(ar()),ji(or,zr<r.length?r.charAt(zr):null,zr<r.length?Nr(zr,zr+1):Nr(zr,zr))}function TIe(r){return wIe(r)}function gF(r,e=!1,t=!1){e?t?r=oh(r,_2(-1,-1)):r=oh(r,_2(1,-1)):t&&(r=oh(r,_2(-1,1)));const n=r.a,i=r.b,a=r.c,o=r.d;let s,l,c;if(n!==0||a!==0){const u=Math.hypot(n,a);s=u,l=(n*o-i*a)/u;const h=Math.acos(n/u);c=a>0?-h:h}else if(i!==0||o!==0){const u=Math.hypot(i,o);s=(n*o-i*a)/u,l=u;const h=Math.acos(i/u);c=Math.PI/2+(o>0?-h:h)}else s=0,l=0,c=0;return t&&(s=-s),e&&(l=-l),{translate:{tx:r.e,ty:r.f},scale:{sx:s,sy:l},rotation:{angle:c}}}function MIe(){return{a:1,c:0,e:0,b:0,d:-1,f:0}}function _F(){return{a:-1,c:0,e:0,b:0,d:1,f:0}}function CIe(){return{a:-1,c:0,e:0,b:0,d:-1,f:0}}function Eae(r,e){const t=e.x-r.x,n=e.y-r.y;return rv(t,n)}function RIe(r,e,t,n){const i=Eae(r,t),a=ui(i,e),o=t,s=n,l=Math.atan2(s.y-o.y,s.x-o.x)-Math.atan2(a.y-o.y,a.x-o.x),c=l3(l,o.x,o.y),u=Math.sqrt(Math.pow(a.x-o.x,2)+Math.pow(a.y-o.y,2)),g=Math.sqrt(Math.pow(s.x-o.x,2)+Math.pow(s.y-o.y,2))/u,_=_2(g,g,o.x,o.y);return oh([i,_,c])}const AIe=Object.freeze(Object.defineProperty({__proto__:null,applyToPoint:ui,applyToPoints:pIe,compose:oh,decomposeTSR:gF,flipOrigin:CIe,flipX:MIe,flipY:_F,fromDefinition:SIe,fromObject:vae,fromOneMovingPoint:Eae,fromString:pF,fromTransformAttribute:TIe,fromTriangles:Sae,fromTwoMovingPoints:RIe,identity:C_,inverse:Tb,isAffineMatrix:yIe,rotate:l3,rotateDEG:mF,scale:_2,shear:yae,skew:_ae,skewDEG:vF,smoothMatrix:bae,toCSS:bIe,toSVG:xae,toString:kS,transform:Mb,translate:rv},Symbol.toStringTag,{value:"Module"}));function xF(r){if(r.length===0)return{minX:0,maxX:0,minY:0,maxY:0};let e=1/0,t=-1/0,n=1/0,i=-1/0;const a=o=>{e=Math.min(e,o.x),t=Math.max(t,o.x),n=Math.min(n,o.y),i=Math.max(i,o.y)};return r.forEach(o=>{switch(o.type){case"path":o.points.forEach(a);break;case"text":a({x:o.x,y:o.y});break;case"circle":{const{x:s,y:l,radius:c}=o;a({x:s-c,y:l-c}),a({x:s+c,y:l+c});break}case"box":{const{x:s,y:l,width:c,height:u}=o,h=c/2,g=u/2;a({x:s-h,y:l-g}),a({x:s+h,y:l+g});break}}}),{minX:e,maxX:t,minY:n,maxY:i}}function am(r){let e=r.size;if(!e){const t=xF(r.primitives);e={width:t.maxX-t.minX,height:t.maxY-t.minY}}return{...r,size:e}}var DIe={paths:{path11:{type:"path",points:[{x:-.5274831500000005,y:.03018695000000049},{x:-.30105415000000013,y:.03018695000000049}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.2932119499999999,y:.03018695000000049},{x:.5339524499999997,y:.03018695000000049}],color:"primary",fill:!1},"path11-5-5":{type:"path",points:[{x:.09765764999999949,y:.12845085000000034},{x:-.0011297500000011507,y:-.06303624999999946},{x:-.10778645000000164,y:.12845085000000034}],color:"primary",fill:!1},path17:{type:"path",points:[{x:-.002934749999999875,y:-.13606674999999946},{x:.06869635000000063,y:-.11019914999999947}],color:"primary",fill:!1},path18:{type:"path",points:[{x:.06869635000000063,y:-.11019914999999947},{x:.1403274500000009,y:-.13606674999999946}],color:"primary",fill:!1},path19:{type:"path",points:[{x:-.1461968499999997,y:-.13606674999999946},{x:-.07456574999999921,y:-.11019914999999947}],color:"primary",fill:!1},path20:{type:"path",points:[{x:-.07456575000000054,y:-.11019914999999947},{x:-.0029346500000002607,y:-.13606674999999946}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.17328624999999942,y:.39216264999999995},bottom1:{type:"text",text:"{VAL}",x:-.00661455000000033,y:-.40216264999999995}},refblocks:{left1:{x:-.5413984499999998,y:.029334149999999948},right1:{x:.54139845,y:.030330549999999734}},bounds:{minX:-.5695568909999997,maxX:.569556891,minY:-.5021626499999999,maxY:.39216264999999995,width:1.1391137819999997,height:.5443252999999999,centerX:11102230246251565e-32,centerY:.05499999999999999},circles:{path1:{type:"circle",x:-.0037626500000000895,y:.03731525000000002,radius:.28854213,color:"primary",fill:!1}}},{paths:PIe,bounds:_R,refblocks:wae,circles:NIe}=DIe,Tae=am({primitives:[...Object.values(PIe),...Object.values(NIe),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"}],ports:[{...wae.left1,labels:["1"]},{...wae.right1,labels:["2"]}],size:{width:_R.width,height:_R.height},center:{x:_R.centerX,y:_R.centerY}}),LIe=(r,e="right")=>{switch(e){case"down":switch(r){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(r){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(r){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 r}return r},OIe=(r,e)=>{const{primitives:t,center:n,ports:i,size:a}=r,o=Mb({a:1,b:0,c:0,d:-1,e:0,f:2*n.y}),s=t.map(c=>{switch(c={...c},c.type){case"path":return{...c,points:c.points.map(_=>ui(o,_))};case"text":const u=ui(o,{x:c.x,y:c.y}),h={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{...c,x:u.x,y:u.y,anchor:h[c.anchor]};case"circle":case"box":const g=ui(o,{x:c.x,y:c.y});return{...c,x:g.x,y:g.y}}}),l=i.map(c=>({...c,...ui(o,c)}));return{primitives:s,center:n,ports:l,size:a,...e}},bF=(r,e)=>{const{primitives:t,center:n,ports:i,size:a}=r,o=Mb({a:-1,b:0,c:0,d:1,e:0,f:2*n.x}),s=t.map(c=>{switch(c={...c},c.type){case"path":return{...c,points:c.points.map(_=>ui(o,_))};case"text":const u=ui(o,{x:c.x,y:c.y}),h={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{...c,x:u.x,y:u.y,anchor:h[c.anchor]};case"circle":case"box":const g=ui(o,{x:c.x,y:c.y});return{...c,x:g.x,y:g.y}}}),l=i.map(c=>({...c,...ui(o,c)}));return{primitives:s,center:n,ports:l,size:a,...e}},mT=(r,e)=>{const{newOrientation:t,overrides:n}=e,i={up:Math.PI/2,right:0,down:-Math.PI/2,left:-Math.PI},a=l3(t?i[t]:Math.PI/2,r.center.x,r.center.y),{primitives:o,center:s,size:l,ports:c}=r,u=o.map(_=>{switch(_={..._},_.type){case"path":return{..._,points:_.points.map(A=>ui(a,A))};case"text":const b=ui(a,{x:_.x,y:_.y});return _.anchor=LIe(_.anchor,t??"right"),{..._,x:b.x,y:b.y};case"circle":const T=ui(a,{x:_.x,y:_.y});return{..._,x:T.x,y:T.y};case"box":const C=ui(a,{x:_.x,y:_.y});return{..._,x:C.x,y:C.y,width:_.height,height:_.width}}}),h=c.map(_=>({..._,...ui(a,_)})),g=xF(u);return{primitives:u,center:s,ports:h,size:{width:g.maxX-g.minX,height:g.maxY-g.minY},...n}},su=(r,e="down",t={})=>mT(r,{newOrientation:e,overrides:t}),UIe=mT(Tae,{newOrientation:"up"}),zIe=UIe,FIe={paths:{path40:{type:"path",points:[{x:.14458890000000002,y:.0390362999999998},{x:-.1199943999999995,y:-.09325540000000054}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.1199943999999995,y:.17132800000000015},{x:.14458890000000002,y:.0390362999999998}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.1199943999999995,y:-.09325539999999921},{x:-.1199943999999995,y:.17132800000000015}],color:"primary",fill:!1},path43:{type:"path",points:[{x:.14458890000000002,y:.17132800000000015},{x:.14458890000000002,y:-.09325539999999921}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.12219909999999956,y:.0390362999999998},{x:-.5168693999999996,y:.0390362999999998}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.5233797000000002,y:.03895110000000024},{x:.1496715999999998,y:.03895110000000024}],color:"primary",fill:!1},"path43-8":{type:"path",points:[{x:.14339119999999994,y:.17181090000000032},{x:.07768859999999966,y:.19542900000000052}],color:"primary",fill:!1},"path43-8-3":{type:"path",points:[{x:.21083259999999981,y:-.1180321000000002},{x:.14512999999999954,y:-.094414}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.0050250999999996715,y:.26884529999999995},bottom1:{type:"text",text:"{VAL}",x:-.00011179999999977319,y:-.27884529999999996}},refblocks:{left1:{x:-.5191471000000001,y:.03992070000000081},right1:{x:.5191470999999999,y:.03889609999999988}},bounds:{minX:-.5473055410000001,maxX:.5473055409999998,minY:-.37884529999999994,maxY:.26884529999999995,width:1.094611082,height:.2976905999999999,centerX:-11102230246251565e-32,centerY:.05499999999999999},circles:{}},{paths:IIe,texts:Mae,bounds:xR,refblocks:Cae,circles:kIe}=FIe,Rae=am({primitives:[...Object.values(IIe),...Object.values(kIe),{...Mae.top1,anchor:"middle_bottom"},{...Mae.bottom1,anchor:"middle_top"}],ports:[{...Cae.left1,labels:["1"]},{...Cae.right1,labels:["2"]}],size:{width:xR.width,height:xR.height},center:{x:xR.centerX,y:xR.centerY}}),BIe=mT(Rae,{newOrientation:"down"}),HIe=BIe,VIe={paths:{path43:{type:"path",points:[{x:-.05901489999999909,y:.18831315000000015},{x:-.05869489999999833,y:-.11814524999999954}],color:"primary",fill:!1},"path43-6":{type:"path",points:[{x:.015375000000000805,y:.12533125000000034},{x:.016669000000000933,y:-.05562075000000033}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.06443049999999961,y:.032673549999999496},{x:-.4368029,y:.032673549999999496}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.4350822999999997,y:.03438825000000034},{x:.028285099999999952,y:.03438825000000034}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.027835099999999446,y:.26564474999999943},bottom1:{type:"text",text:"{VAL}",x:-.028373699999999502,y:-.27564474999999966}},refblocks:{left1:{x:-.4458008,y:.033557849999999334},right1:{x:.4458008,y:.03343344999999931}},bounds:{minX:-.473959241,maxX:.473959241,minY:-.37564474999999964,maxY:.26564474999999943,width:.947918482,height:.2912894999999991,centerX:0,centerY:.055000000000000104},circles:{}},{paths:jIe,texts:Aae,bounds:bR,refblocks:Dae,circles:GIe}=VIe,Pae=am({primitives:[...Object.values(jIe),...Object.values(GIe),{...Aae.top1,anchor:"middle_bottom"},{...Aae.bottom1,anchor:"middle_top"}],ports:[{...Dae.left1,labels:["1"]},{...Dae.right1,labels:["2"]}],size:{width:bR.width,height:bR.height},center:{x:bR.centerX,y:bR.centerY}}),qIe=mT(Pae,{newOrientation:"up"}),SR={paths:{path1:{type:"path",points:[{x:-.511850799999999,y:.04616140000000257},{x:-.24726749999999953,y:.04616140000000257}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.2818991000000013,y:.04616140000000257},{x:.5464825000000006,y:.04616140000000257}],color:"primary",fill:!1},path3:{type:"path",points:[{x:.0173157000000006,y:.17845310000000225},{x:.2818990000000001,y:.17845310000000225},{x:.2818990000000001,y:-.0861302999999971},{x:-.24726770000000053,y:-.0861302999999971},{x:-.24726770000000053,y:.17845310000000225},{x:.017315699999998824,y:.17845310000000225}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.0014247999999992267,y:.2499980000000015},bottom1:{type:"text",text:"{VAL}",x:-.0004627999999997634,y:-.24999799999999972}},refblocks:{left1:{x:-.5337907000000002,y:.04580520000000021},right1:{x:.5337907000000004,y:.04525870000000154}},bounds:{minX:-.5619491410000002,maxX:.5619491410000004,minY:-.24999799999999972,maxY:.2499980000000015,width:1.1238982820000005,height:.4999960000000012,centerX:11102230246251565e-32,centerY:8881784197001252e-31},circles:{}},YIe=class{constructor(e){ni(this,"symbol");this.symbol=JSON.parse(JSON.stringify(e)),this.symbol.size=this.computeSize()}changeTextAnchor(e,t){return this.symbol={...this.symbol,primitives:this.symbol.primitives.map(n=>n.type==="text"&&n.text===e?{...n,anchor:t}:n)},this}labelPort(e,t){return this.symbol={...this.symbol,ports:this.symbol.ports.map(n=>n.labels.includes(e)?{...n,labels:t}:n)},this}rotateRightFacingSymbol(e){return this.symbol=mT(this.symbol,{newOrientation:e}),this}computeSize(){const e=xF(this.symbol.primitives);return{width:e.maxX-e.minX,height:e.maxY-e.minY}}build(){return{...this.symbol,size:this.computeSize()}}},kh=r=>new YIe({...r,primitives:r.primitives??[...Object.values(r.paths??{}),...Object.values(r.texts??{}),...Object.values(r.circles??{}),...Object.values(r.rects??{})],ports:r.ports??Object.entries(r.refblocks).flatMap(([e,t])=>[{...t,labels:[e]}]),center:r.center??{x:r.bounds.centerX,y:r.bounds.centerY}}),{paths:XIe,texts:ORt,bounds:Nae,refblocks:Lae,circles:WIe}=SR,$Ie=kh({primitives:[...Object.values(XIe),...Object.values(WIe),{type:"text",text:"{REF}",x:-.16,y:.2294553499999995},{type:"text",text:"{VAL}",x:.16,y:.2294553499999995}],ports:[{...Lae.left1,labels:["1"]},{...Lae.right1,labels:["2"]}],center:{x:Nae.centerX,y:Nae.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").build(),{paths:ZIe,texts:URt,bounds:Oae,refblocks:Uae,circles:QIe}=SR,KIe=kh({primitives:[...Object.values(ZIe),...Object.values(QIe),{type:"text",text:"{REF}",x:0,y:.2294553499999995},{type:"text",text:"{VAL}",x:0,y:-.1594553499999995}],ports:[{...Uae.left1,labels:["1"]},{...Uae.right1,labels:["2"]}],center:{x:Oae.centerX,y:Oae.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:JIe,texts:zRt,bounds:zae,refblocks:Fae,circles:eke}=SR,tke=kh({primitives:[...Object.values(JIe),...Object.values(eke),{type:"text",text:"{REF}",x:0,y:.2294553499999995},{type:"text",text:"{VAL}",x:0,y:-.1594553499999995}],ports:[{...Fae.left1,labels:["1"]},{...Fae.right1,labels:["2"]}],center:{x:zae.centerX,y:zae.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:nke,texts:FRt,bounds:Iae,refblocks:kae,circles:rke}=SR,ike=kh({primitives:[...Object.values(nke),...Object.values(rke),{type:"text",text:"{REF}",x:-.16,y:.2294553499999995},{type:"text",text:"{VAL}",x:.16,y:.2294553499999995}],ports:[{...kae.left1,labels:["1"]},{...kae.right1,labels:["2"]}],center:{x:Iae.centerX,y:Iae.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").build(),ER={paths:{path27:{type:"path",points:[{x:.5229378000000002,y:.017283050000003186},{x:.07314620000000005,y:.017283050000003186}],color:"primary",fill:!1},path28:{type:"path",points:[{x:-.0856037999999999,y:.017283050000003186},{x:-.5353954999999999,y:.017283050000003186}],color:"primary",fill:!1},path29:{type:"path",points:[{x:.0731461999999996,y:.2818663500000014},{x:.07314620000000005,y:-.24730024999999856}],color:"primary",fill:!1},path30:{type:"path",points:[{x:-.0856037999999999,y:.2818663500000014},{x:-.0856037999999999,y:-.24730024999999856}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.012864500000000056,y:.4200086500000033},bottom1:{type:"text",text:"{VAL}",x:-.003850500000000423,y:-.42000864999999976}},refblocks:{left1:{x:-.5512093000000005,y:.01638025000000276},right1:{x:.5512093,y:.016926950000001995}},bounds:{minX:-.5793677410000004,maxX:.579367741,minY:-.42000864999999976,maxY:.4200086500000033,width:1.1587354820000004,height:.8400173000000031,centerX:-2220446049250313e-31,centerY:17763568394002505e-31},circles:{}},{paths:ake,texts:IRt,bounds:wR,refblocks:Bae,circles:oke}=ER,ske=kh({primitives:[...Object.values(ake),...Object.values(oke),{type:"text",text:"{REF}",x:-.2,y:.2094553499999995},{type:"text",text:"{VAL}",x:.2,y:.2094553499999995}],ports:[{...Bae.left1,labels:["1"]},{...Bae.right1,labels:["2"]}],size:{width:wR.width,height:wR.height},center:{x:wR.centerX,y:wR.centerY}}).changeTextAnchor("{VAL}","top_left").rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","bottom_left").build(),lke=kh(ER).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["2"]).labelPort("right1",["1"]).changeTextAnchor("{REF}","middle_bottom").build(),SF={paths:{"path27-5":{type:"path",points:[{x:.4511331000000005,y:.017283050000003186},{x:.001333100000000531,y:.017283050000003186}],color:"primary",fill:!1},"path28-5":{type:"path",points:[{x:-.08560379999999945,y:.017283050000003186},{x:-.5353954999999995,y:.017283050000003186}],color:"primary",fill:!1},"path30-7":{type:"path",points:[{x:-.0024798999999995353,y:.28420285000000334},{x:-.0024798999999995353,y:-.247479349999999}],color:"primary",fill:!1},path8704:{type:"path",points:[{x:-.1433630999999993,y:-.24400714999999806},{x:-.1433630999999993,y:-.24400714999999806},{x:-.14262848833929928,y:-.24277205092349807},{x:-.1418975396743993,y:-.2415360290679981},{x:-.14117026348109932,y:-.24029908349449816},{x:-.14044666923519933,y:-.23906121326399818},{x:-.13972676641249931,y:-.2378224174374982},{x:-.1390105644887993,y:-.23658269507599822},{x:-.13829807293989932,y:-.2353420452404983},{x:-.13758930124159935,y:-.23410046699199832},{x:-.13688425886969938,y:-.23285795939149836},{x:-.13618295529999938,y:-.23161452149999842},{x:-.13548540000829937,y:-.23037015237849842},{x:-.13479160247039934,y:-.22912485108799843},{x:-.13410157216209936,y:-.22787861668949844},{x:-.1334153185591994,y:-.22663144824399842},{x:-.13273285113749936,y:-.22538334481249844},{x:-.13205417937279937,y:-.22413430545599844},{x:-.1313793127408994,y:-.2228843292354985},{x:-.1307082607175994,y:-.22163341521199847},{x:-.13004103277869938,y:-.2203815624464985},{x:-.1293776383999994,y:-.21912876999999853},{x:-.12871808705729942,y:-.21787503693349855},{x:-.12806238822639943,y:-.21662036230799855},{x:-.12741055138309942,y:-.21536474518449858},{x:-.12676258600319942,y:-.21410818462399858},{x:-.12611850156249946,y:-.21285067968749863},{x:-.12547830753679945,y:-.21159222943599865},{x:-.12484201340189946,y:-.21033283293049862},{x:-.12420962863359947,y:-.20907248923199864},{x:-.12358116270769948,y:-.20781119740149864},{x:-.12295662509999947,y:-.20654895649999866},{x:-.12233602528629947,y:-.20528576558849868},{x:-.12171937274239948,y:-.20402162372799865},{x:-.12110667694409948,y:-.20275652997949864},{x:-.12049794736719947,y:-.2014904834039986},{x:-.11989319348749948,y:-.20022348306249865},{x:-.11929242478079949,y:-.19895552801599864},{x:-.11869565072289952,y:-.19768661732549864},{x:-.11810288078959952,y:-.19641675005199866},{x:-.11751412445669952,y:-.19514592525649863},{x:-.1169293911999995,y:-.1938741419999986},{x:-.11634869049529953,y:-.19260139934349865},{x:-.11577203181839951,y:-.1913276963479986},{x:-.11519942464509951,y:-.1900530320744986},{x:-.11463087845119951,y:-.18877740558399858},{x:-.11406640271249952,y:-.1875008159374986},{x:-.11350600690479953,y:-.18622326219599858},{x:-.11294970050389953,y:-.18494474342049858},{x:-.11239749298559953,y:-.1836652586719986},{x:-.11184939382569953,y:-.18238480701149856},{x:-.11130541249999952,y:-.18110338749999852},{x:-.11076555848429954,y:-.17982099919849853},{x:-.11022984125439952,y:-.1785376411679985},{x:-.10969827028609953,y:-.1772533124694985},{x:-.10917085505519954,y:-.17596801216399852},{x:-.10864760503749954,y:-.17468173931249847},{x:-.10812852970879953,y:-.17339449297599843},{x:-.10761363854489954,y:-.17210627221549843},{x:-.10710294102159955,y:-.17081707609199845},{x:-.10659644661469955,y:-.16952690366649845},{x:-.10609416479999954,y:-.1682357539999984},{x:-.10559610505329955,y:-.1669436261534984},{x:-.10510227685039954,y:-.1656505191879984},{x:-.10461268966709955,y:-.16435643216449838},{x:-.10412735297919956,y:-.16306136414399838},{x:-.10364627626249956,y:-.16176531418749837},{x:-.10316946899279957,y:-.16046828135599833},{x:-.10269694064589956,y:-.15917026471049833},{x:-.10222870069759955,y:-.1578712633119983},{x:-.10176475862369955,y:-.1565712762214983},{x:-.10130512389999956,y:-.1552703024999983},{x:-.10084980600229956,y:-.15396834120849828},{x:-.10039881440639958,y:-.15266539140799829},{x:-.09995215858809957,y:-.15136145215949826},{x:-.09950984802319957,y:-.15005652252399826},{x:-.09907189218749957,y:-.14875060156249825},{x:-.09863830055679956,y:-.14744368833599825},{x:-.09820908260689958,y:-.14613578190549825},{x:-.09778424781359957,y:-.14482688133199823},{x:-.09736380565269957,y:-.1435169856764982},{x:-.09694776559999957,y:-.1422060939999982},{x:-.09653613713129958,y:-.1408942053634982},{x:-.09612892972239956,y:-.13958131882799818},{x:-.09572615284909958,y:-.13826743345449818},{x:-.09532781598719958,y:-.13695254830399817},{x:-.09493392861249958,y:-.13563666243749817},{x:-.09454450020079957,y:-.13431977491599817},{x:-.09415954022789956,y:-.13300188480049818},{x:-.09377905816959958,y:-.13168299115199816},{x:-.09340306350169958,y:-.13036309303149818},{x:-.09303156569999958,y:-.12904218949999818},{x:-.09266457424029959,y:-.12772027961849816},{x:-.09230209859839958,y:-.12639736244799815},{x:-.09194414825009957,y:-.12507343704949817},{x:-.09159073267119958,y:-.12374850248399819},{x:-.09124186133749958,y:-.12242255781249818},{x:-.09089754372479958,y:-.12109560209599818},{x:-.09055778930889957,y:-.11976763439549819},{x:-.09022260756559956,y:-.11843865377199818},{x:-.08989200797069956,y:-.11710865928649819},{x:-.08956599999999959,y:-.11577764999999829},{x:-.08956599999999959,y:-.11577764999999829},{x:-.08916166532269958,y:-.1141015840276983},{x:-.08876332646159957,y:-.11242441110159831},{x:-.08837097017289958,y:-.11074614170789834},{x:-.08798458321279957,y:-.10906678633279836},{x:-.08760415233749957,y:-.10738635546249836},{x:-.08722966430319957,y:-.10570485958319836},{x:-.08686110586609956,y:-.10402230918109837},{x:-.08649846378239957,y:-.10233871474239843},{x:-.0861417248082996,y:-.10065408675329846},{x:-.08579087569999959,y:-.09896843569999846},{x:-.08544590321369959,y:-.09728177206869845},{x:-.08510679410559958,y:-.09559410634559845},{x:-.08477353513189957,y:-.09390544901689848},{x:-.08444611304879956,y:-.09221581056879849},{x:-.08412451461249956,y:-.0905252014874985},{x:-.08380872657919955,y:-.0888336322591985},{x:-.08349873570509957,y:-.08714111337009853},{x:-.08319452874639957,y:-.08544765530639854},{x:-.08289609245929955,y:-.08375326855429854},{x:-.08260341359999955,y:-.08205796359999856},{x:-.08231647892469955,y:-.08036175092969856},{x:-.08203527518959956,y:-.07866464102959857},{x:-.08175978915089956,y:-.07696664438589859},{x:-.08149000756479956,y:-.07526777148479862},{x:-.08122591718749958,y:-.07356803281249863},{x:-.08096750477519957,y:-.07186743885519864},{x:-.08071475708409956,y:-.07016600009909864},{x:-.08046766087039958,y:-.06846372703039866},{x:-.08022620289029957,y:-.06676063013529866},{x:-.07999036989999955,y:-.06505671989999867},{x:-.07976014865569958,y:-.06335200681069868},{x:-.07953552591359955,y:-.061646501353598705},{x:-.07931648842989956,y:-.0599402140148987},{x:-.07910302296079955,y:-.0582331552807987},{x:-.07889511626249955,y:-.05652533563749871},{x:-.07869275509119955,y:-.05481676557119872},{x:-.07849592620309954,y:-.053107455568098726},{x:-.07830461635439954,y:-.05139741611439873},{x:-.07811881230129955,y:-.049686657696298736},{x:-.07793850079999953,y:-.04797519079999873},{x:-.07776366860669955,y:-.04626302591169874},{x:-.07759430247759955,y:-.04455017351759874},{x:-.07743038916889955,y:-.042836644103898744},{x:-.07727191543679954,y:-.04112244815679875},{x:-.07711886803749955,y:-.039407596162498754},{x:-.07697123372719955,y:-.03769209860719875},{x:-.07682899926209953,y:-.035975965977098755},{x:-.07669215139839955,y:-.03425920875839876},{x:-.07656067689229953,y:-.032541837437298764},{x:-.07643456249999953,y:-.03082386249999876},{x:-.07631379497769952,y:-.029105294432698766},{x:-.07619836108159952,y:-.02738614372159877},{x:-.07608824756789952,y:-.02566642085289876},{x:-.07598344119279953,y:-.023946136312798766},{x:-.07588392871249951,y:-.02222530058749876},{x:-.0757896968831995,y:-.020503924163198756},{x:-.07570073246109951,y:-.01878201752609876},{x:-.07561702220239952,y:-.017059591162398753},{x:-.07553855286329951,y:-.015336655558298754},{x:-.07546531119999951,y:-.01361322119999875},{x:-.07539728396869952,y:-.011889298573698748},{x:-.07533445792559951,y:-.010164898165598747},{x:-.07527681982689952,y:-.008440030461898743},{x:-.07522435642879952,y:-.006714705948798734},{x:-.07517705448749952,y:-.004988935112498731},{x:-.07513490075919951,y:-.0032627284391987255},{x:-.07509788200009951,y:-.0015360964150987165},{x:-.07506598496639952,y:.0001909504736012889},{x:-.0750391964142995,y:.0019184017407012956},{x:-.07501750309999951,y:.003646246900001303},{x:-.07500089177969951,y:.00537447546530131},{x:-.07498934920959952,y:.00710307695040132},{x:-.0749828621458995,y:.00883204086910133},{x:-.0749814173447995,y:.010561356735201338},{x:-.07498500156249951,y:.012291014062501347},{x:-.0749936015551995,y:.014021002364801359},{x:-.07500720407909953,y:.015751311155901372},{x:-.07502579589039951,y:.017481929949601384},{x:-.0750493637452995,y:.01921284825970139},{x:-.07507789439999951,y:.0209440556000014},{x:-.0751113746106995,y:.022675541484301412},{x:-.0751497911335995,y:.024407295426401427},{x:-.07519313072489951,y:.02613930694010145},{x:-.07524138014079951,y:.027871565539201462},{x:-.07529452613749951,y:.029604060737501478},{x:-.07535255547119951,y:.031336782048801484},{x:-.0754154548980995,y:.0330697189869015},{x:-.07548321117439952,y:.03480286106560152},{x:-.07555581105629952,y:.03653619779870154},{x:-.07563324129999952,y:.038269718700001565},{x:-.07571548866169951,y:.04000341328330158},{x:-.07580253989759951,y:.04173727106240159},{x:-.07589438176389952,y:.043471281551101616},{x:-.07599100101679952,y:.04520543426320164},{x:-.07609238441249952,y:.04693971871250166},{x:-.07619851870719953,y:.048674124412801674},{x:-.07630939065709953,y:.0504086408779017},{x:-.07642498701839952,y:.05214325762160172},{x:-.07654529454729952,y:.05387796415770175},{x:-.07667029999999952,y:.055612750000001654},{x:-.07667029999999952,y:.055612750000001654},{x:-.07680210846969952,y:.05708314936460168},{x:-.07693595411759954,y:.05855396299680169},{x:-.07707186730189955,y:.06002517220420173},{x:-.07720987838079954,y:.06149675829440175},{x:-.07735001771249954,y:.06296870257500178},{x:-.07749231565519954,y:.06444098635360178},{x:-.07763680256709955,y:.0659135909378018},{x:-.07778350880639956,y:.06738649763520185},{x:-.07793246473129956,y:.06885968775340187},{x:-.07808370069999958,y:.07033314260000188},{x:-.07823724707069958,y:.07180684348260188},{x:-.07839313420159956,y:.07328077170880191},{x:-.07855139245089958,y:.07475490858620194},{x:-.07871205217679958,y:.07622923542240194},{x:-.07887514373749958,y:.07770373352500196},{x:-.07904069749119959,y:.07917838420160196},{x:-.07920874379609959,y:.080653168759802},{x:-.07937931301039959,y:.082128068507202},{x:-.07955243549229958,y:.08360306475140203},{x:-.0797281415999996,y:.085078138800002},{x:-.0799064616916996,y:.08655327196060203},{x:-.08008742612559962,y:.08802844554080204},{x:-.08027106525989962,y:.08950364084820207},{x:-.08045740945279962,y:.09097883919040207},{x:-.08064648906249965,y:.0924540218750021},{x:-.08083833444719964,y:.0939291702096021},{x:-.08103297596509963,y:.09540426550180209},{x:-.08123044397439966,y:.09687928905920212},{x:-.08143076883329967,y:.09835422218940212},{x:-.08163398089999965,y:.09982904620000212},{x:-.08184011053269966,y:.10130374239860213},{x:-.08204918808959966,y:.10277829209280215},{x:-.08226124392889968,y:.10425267659020215},{x:-.08247630840879966,y:.10572687719840214},{x:-.08269441188749967,y:.10720087522500214},{x:-.08291558472319968,y:.10867465197760214},{x:-.0831398572740997,y:.11014818876380215},{x:-.08336725989839969,y:.11162146689120216},{x:-.0835978229542997,y:.11309446766740217},{x:-.0838315767999997,y:.11456717240000215},{x:-.08406855179369971,y:.11603956239660215},{x:-.0843087782935997,y:.11751161896480215},{x:-.08455228665789971,y:.11898332341220215},{x:-.0847991072447997,y:.12045465704640215},{x:-.08504927041249971,y:.12192560117500215},{x:-.0853028065191997,y:.12339613710560214},{x:-.08555974592309973,y:.12486624614580213},{x:-.08582011898239973,y:.12633590960320215},{x:-.08608395605529973,y:.12780510878540213},{x:-.08635128749999971,y:.1292738250000021},{x:-.08662214367469973,y:.1307420395546021},{x:-.08689655493759973,y:.1322097337568021},{x:-.08717455164689972,y:.13367688891420207},{x:-.08745616416079972,y:.13514348633440207},{x:-.08774142283749972,y:.13660950732500204},{x:-.08803035803519974,y:.13807493319360203},{x:-.08832300011209973,y:.13953974524780205},{x:-.08861937942639975,y:.14100392479520202},{x:-.08891952633629974,y:.14246745314340203},{x:-.08922347119999974,y:.14393031160000203},{x:-.08953124437569973,y:.145392481472602},{x:-.08984287622159975,y:.14685394406880198},{x:-.09015839709589976,y:.148314680696202},{x:-.09047783735679976,y:.149774672662402},{x:-.09080122736249976,y:.15123390127500197},{x:-.09112859747119977,y:.15269234784160193},{x:-.09145997804109976,y:.15414999366980195},{x:-.09179539943039977,y:.15560682006720195},{x:-.09213489199729977,y:.1570628083414019},{x:-.09247848609999976,y:.1585179398000019},{x:-.09282621209669975,y:.1599721957506019},{x:-.09317810034559978,y:.1614255575008019},{x:-.09353418120489977,y:.16287800635820185},{x:-.09389448503279976,y:.16432952363040182},{x:-.09425904218749978,y:.16578009062500182},{x:-.09462788302719977,y:.1672296886496018},{x:-.09500103791009978,y:.1686782990118018},{x:-.09537853719439979,y:.17012590301920177},{x:-.09576041123829979,y:.17157248197940175},{x:-.09614669039999979,y:.17301801720000176},{x:-.09653740503769978,y:.17446248998860173},{x:-.0969325855095998,y:.17590588165280172},{x:-.09733226217389979,y:.17734817350020168},{x:-.09773646538879979,y:.1787893468384017},{x:-.0981452255124998,y:.18022938297500168},{x:-.0985585729031998,y:.18166826321760166},{x:-.09897653791909979,y:.1831059688738016},{x:-.09939915091839979,y:.1845424812512016},{x:-.0998264422592998,y:.1859777816574016},{x:-.1002584422999998,y:.1874118514000016},{x:-.1006951813986998,y:.18884467178660155},{x:-.1011366899135998,y:.19027622412480152},{x:-.10158299820289979,y:.19170648972220153},{x:-.1020341366247998,y:.1931354498864015},{x:-.1024901355374998,y:.1945630859250015},{x:-.1029510252991998,y:.19598937914560147},{x:-.10341683626809982,y:.19741431085580147},{x:-.1038875988023998,y:.19883786236320142},{x:-.1043633432602998,y:.20026001497540138},{x:-.10484409999999977,y:.2016807500000013},{x:-.10484409999999977,y:.2016807500000013},{x:-.10512829034499978,y:.20251255364660126},{x:-.10541452131999979,y:.2033439212528012},{x:-.10570279283499981,y:.2041748478182012},{x:-.10599310479999982,y:.20500532834240115},{x:-.10628545712499982,y:.20583535782500112},{x:-.10657984971999983,y:.20666493126560112},{x:-.10687628249499985,y:.2074940436638011},{x:-.10717475535999986,y:.20832269001920106},{x:-.10747526822499989,y:.2091508653314011},{x:-.1077778209999999,y:.20997856460000103},{x:-.10808241359499988,y:.21080578282460102},{x:-.10838904591999989,y:.21163251500480096},{x:-.10869771788499989,y:.212458756140201},{x:-.10900842939999988,y:.21328450123040094},{x:-.10932118037499987,y:.21410974527500093},{x:-.10963597071999989,y:.21493448327360093},{x:-.10995280034499992,y:.21575871022580093},{x:-.1102716691599999,y:.2165824211312009},{x:-.1105925770749999,y:.21740561098940095},{x:-.11091552399999992,y:.21822827480000093},{x:-.1112405098449999,y:.2190504075626009},{x:-.11156753451999993,y:.21987200427680093},{x:-.11189659793499994,y:.22069305994220095},{x:-.11222769999999993,y:.22151356955840096},{x:-.11256084062499995,y:.222333528125001},{x:-.11289601971999996,y:.223152930641601},{x:-.11323323719499996,y:.223971772107801},{x:-.11357249295999995,y:.22479004752320103},{x:-.11391378692499997,y:.22560775188740104},{x:-.11425711899999995,y:.22642488020000104},{x:-.11460248909499995,y:.22724142746060105},{x:-.11494989711999995,y:.2280573886688011},{x:-.11529934298499996,y:.22887275882420108},{x:-.11565082659999995,y:.22968753292640107},{x:-.11600434787499994,y:.23050170597500114},{x:-.11635990671999996,y:.23131527296960114},{x:-.11671750304499996,y:.23212822890980117},{x:-.11707713675999995,y:.23294056879520117},{x:-.11743880777499995,y:.2337522876254012},{x:-.11780251599999993,y:.2345633804000012},{x:-.11816826134499994,y:.23537384211860124},{x:-.11853604371999993,y:.23618366778080127},{x:-.11890586303499992,y:.2369928523862013},{x:-.11927771919999992,y:.23780139093440128},{x:-.11965161212499995,y:.23860927842500138},{x:-.12002754171999992,y:.23941650985760138},{x:-.12040550789499993,y:.24022308023180142},{x:-.12078551055999992,y:.24102898454720142},{x:-.12116754962499991,y:.24183421780340145},{x:-.12155162499999989,y:.24263877500000142},{x:-.1219377365949999,y:.2434426511366015},{x:-.1223258843199999,y:.2442458412128015},{x:-.1227160680849999,y:.24504834022820154},{x:-.12310828779999988,y:.24585014318240156},{x:-.12350254337499987,y:.24665124507500158},{x:-.12389883471999988,y:.24745164090560162},{x:-.12429716174499987,y:.24825132567380165},{x:-.12469752435999987,y:.2490502943792017},{x:-.12509992247499988,y:.2498485420214017},{x:-.12550435599999984,y:.25064606360000175},{x:-.12591082484499985,y:.25144285411460177},{x:-.12631932891999986,y:.2522389085648018},{x:-.12672986813499987,y:.25303422195020187},{x:-.12714244239999986,y:.25382878927040187},{x:-.12755705162499986,y:.25462260552500193},{x:-.12797369571999986,y:.25541566571360197},{x:-.12839237459499983,y:.256207964835802},{x:-.12881308815999984,y:.256999497891202},{x:-.12923583632499985,y:.2577902598794021},{x:-.12966061899999984,y:.2585802458000021},{x:-.13008743609499984,y:.25936945065260214},{x:-.13051628751999986,y:.2601578694368022},{x:-.13094717318499982,y:.26094549715220217},{x:-.13138009299999984,y:.26173232879840225},{x:-.13181504687499984,y:.2625183593750023},{x:-.13225203471999986,y:.2633035838816023},{x:-.13269105644499984,y:.26408799731780236},{x:-.13313211195999985,y:.26487159468320237},{x:-.13357520117499982,y:.2656543709774024},{x:-.13402032399999986,y:.26643632120000244},{x:-.13446748034499983,y:.26721744035060246},{x:-.13491667011999983,y:.26799772342880246},{x:-.13536789323499984,y:.2687771654342025},{x:-.13582114959999986,y:.2695557613664026},{x:-.13627643912499987,y:.27033350622500263},{x:-.13673376171999985,y:.27111039500960266},{x:-.13719311729499983,y:.2718864227198026},{x:-.13765450575999985,y:.2726615843552027},{x:-.13811792702499986,y:.2734358749154028},{x:-.1385833809999999,y:.2742092894000028},{x:-.13905086759499988,y:.2749818228086028},{x:-.1395203867199999,y:.2757534701408028},{x:-.1399919382849999,y:.27652422639620283},{x:-.14046552219999991,y:.27729408657440285},{x:-.1409411383749999,y:.2780630456750029},{x:-.1414187867199999,y:.2788310986976029},{x:-.14189846714499993,y:.27959824064180294},{x:-.14238017955999993,y:.2803644665072029},{x:-.1428639238749999,y:.28112977129340294},{x:-.1433496999999999,y:.28189415000000295}],color:"primary",fill:!1},"rect1577-4":{type:"path",points:[{x:.26345180000000035,y:.2455934500000012},{x:.12298460000000011,y:.2455934500000012},{x:.12298460000000011,y:.2505664500000009},{x:.26345180000000035,y:.2505664500000009}],color:"primary",fill:!0},"rect1577-4-7":{type:"path",points:[{x:.19576130000000003,y:.31834525000000014},{x:.19576130000000003,y:.17787805000000034},{x:.1907882999999999,y:.17787805000000034},{x:.1907882999999999,y:.31834525000000014}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:-.012864499999999612,y:.4200086500000033},bottom1:{type:"text",text:"{VAL}",x:-.003850499999999979,y:-.42000864999999976}},refblocks:{left1:{x:-.5353954999999995,y:.016380250000000984},right1:{x:.4511331000000005,y:.016926950000001995}},bounds:{minX:-.579367741,maxX:.579367741,minY:-.42000864999999976,maxY:.4200086500000033,width:1.158735482,height:.8400173000000031,centerX:0,centerY:17763568394002505e-31},circles:{}},{paths:cke,texts:kRt,bounds:TR,refblocks:Hae,circles:uke}=SF,fke=kh({primitives:[...Object.values(cke),...Object.values(uke),{type:"text",text:"{REF}",x:-.2,y:.2094553499999995},{type:"text",text:"{VAL}",x:.3,y:.2094553499999995}],ports:[{...Hae.left1,labels:["1"]},{...Hae.right1,labels:["2"]}],size:{width:TR.width,height:TR.height},center:{x:TR.centerX,y:TR.centerY}}).changeTextAnchor("{VAL}","top_left").rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","bottom_left").build(),Vae=kh(SF).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),dke=kh(Vae).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_top").build(),{paths:hke,texts:BRt,bounds:MR,refblocks:jae,circles:pke}=SF,mke=kh({primitives:[...Object.values(hke),...Object.values(pke),{type:"text",text:"{REF}",x:.1,y:-.2094553499999995},{type:"text",text:"{VAL}",x:-.2,y:-.2094553499999995}],ports:[{...jae.left1,labels:["1"]},{...jae.right1,labels:["2"]}],size:{width:MR.width,height:MR.height},center:{x:MR.centerX,y:MR.centerY}}).changeTextAnchor("{VAL}","top_left").rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","bottom_left").build(),vke=kh(ER).rotateRightFacingSymbol("right").changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:yke,texts:HRt,bounds:CR,refblocks:Gae,circles:gke}=ER,_ke=kh({primitives:[...Object.values(yke),...Object.values(gke),{type:"text",text:"{REF}",x:.2,y:-.2094553499999995},{type:"text",text:"{VAL}",x:-.2,y:-.2094553499999995}],ports:[{...Gae.left1,labels:["1"]},{...Gae.right1,labels:["2"]}],size:{width:CR.width,height:CR.height},center:{x:CR.centerX,y:CR.centerY}}).changeTextAnchor("{VAL}","top_left").rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","bottom_left").build(),qae={paths:{path11:{type:"path",points:[{x:-.5274831500000005,y:.02897970000000072},{x:-.30105415000000013,y:.02897970000000072}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.2932119499999999,y:.02897970000000072},{x:.5339524499999997,y:.02897970000000072}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.2932119499999999,y:.2923763000000008},{x:.2932119499999999,y:-.23441689999999937}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.021208049999999812,y:.3692298999999999},bottom1:{type:"text",text:"{VAL}",x:-.00661455000000033,y:-.3692298999999999}},refblocks:{left1:{x:-.5413984499999998,y:.028126900000000177},right1:{x:.54139845,y:.029123299999999963}},bounds:{minX:-.5695568909999997,maxX:.569556891,minY:-.3692298999999999,maxY:.3692298999999999,width:1.1391137819999997,height:.7384597999999998,centerX:11102230246251565e-32,centerY:0},circles:{path1:{type:"circle",x:-.0037626500000000895,y:.03610800000000025,radius:.28854213,color:"primary",fill:!1}}},xke=kh(qae).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),bke=kh(qae).rotateRightFacingSymbol("down").changeTextAnchor("{VAL}","middle_right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").build(),Ske={paths:{path27:{type:"path",points:[{x:.52188525,y:-.010083950000000286},{x:.1314137500000001,y:-.010083950000000286}],color:"primary",fill:!1},path29:{type:"path",points:[{x:.12501034999999971,y:.25449935000000146},{x:.12501035000000016,y:-.2746672499999985}],color:"primary",fill:!1},"path29-2":{type:"path",points:[{x:.07157854999999946,y:.253778650000001},{x:.07157854999999991,y:-.27538794999999716}],color:"primary",fill:!1},path30:{type:"path",points:[{x:-.13957305000000053,y:.25449935000000146},{x:-.1395730500000001,y:-.2746672499999985}],color:"primary",fill:!1},"path29-5":{type:"path",points:[{x:-.08349325000000052,y:.25541165000000277},{x:-.08349325000000007,y:-.27375494999999894}],color:"primary",fill:!1},"path29-2-7":{type:"path",points:[{x:.07147894999999993,y:.2552525499999998},{x:-.0829032500000002,y:.2552525499999998}],color:"primary",fill:!1},"path29-2-7-6":{type:"path",points:[{x:.07107315000000014,y:-.27817384999999817},{x:-.08330905,y:-.27817384999999817}],color:"primary",fill:!1},path43:{type:"path",points:[{x:-.21327535000000042,y:.31803495000000304},{x:.19712464999999968,y:.31807695}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.003324649999999707,y:.694594949999999},{x:.003324649999999707,y:.3310069500000008},{x:.003324649999999707,y:.3209089500000015}],color:"primary",fill:!1},"path43-8":{type:"path",points:[{x:-.21327535000000042,y:.3180639499999991},{x:-.21327535000000042,y:.2498769499999991}],color:"primary",fill:!1},"path43-8-8":{type:"path",points:[{x:.19712464999999968,y:.31807695},{x:.19712464999999968,y:.24987695000000443}],color:"primary",fill:!1},"path43-9":{type:"path",points:[{x:.19226054999999942,y:-.3468980499999983},{x:-.21813945000000068,y:-.3469400500000006}],color:"primary",fill:!1},"path44-0-5":{type:"path",points:[{x:-.024339450000000262,y:-.7234580499999996},{x:-.024339450000000262,y:-.3598700499999996},{x:-.024339450000000262,y:-.34977205000000033}],color:"primary",fill:!1},"path43-8-1":{type:"path",points:[{x:.19226054999999942,y:-.3469270499999997},{x:.19226054999999942,y:-.2787400499999979}],color:"primary",fill:!1},"path43-8-8-9":{type:"path",points:[{x:-.21813955000000096,y:-.34694015},{x:-.21813955000000096,y:-.27874015000000085}],color:"primary",fill:!1},path28:{type:"path",points:[{x:-.14368304999999992,y:-.010083950000000286},{x:-.5364480500000002,y:-.010083950000000286}],color:"primary",fill:!1}},texts:{left1:{type:"text",text:"{REF}",x:-.38155925000000046,y:.09576035000000083},right1:{type:"text",text:"{VAL}",x:.3369813499999994,y:-.17868404999999754}},refblocks:{top1:{x:.0032092499999998303,y:.7114137500000002},bottom1:{x:-.02355145000000025,y:-.7114137500000002},left1:{x:-.5415391500000004,y:-.00607074999999746},right1:{x:.5415391499999997,y:-.012221549999997805}},bounds:{minX:-.5696975910000004,maxX:.5696975909999997,minY:-.7395721910000002,maxY:.7395721910000002,width:1.1393951820000001,height:1.4791443820000003,centerX:-33306690738754696e-32,centerY:0},circles:{}},Yae=kh(Ske).labelPort("top1",["2","gnd1"]).labelPort("bottom1",["4","gnd2"]).labelPort("left1",["1"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","bottom_right").changeTextAnchor("{VAL}","top_left").build(),Eke=kh(Yae).rotateRightFacingSymbol("up").changeTextAnchor("{REF}","top_right").changeTextAnchor("{VAL}","bottom_left").build(),Xae={paths:{path27:{type:"path",points:[{x:.5229378000000002,y:-.012283099999995883},{x:.13246630000000037,y:-.012283099999995883}],color:"primary",fill:!1},path28:{type:"path",points:[{x:-.14263049999999966,y:-.012283099999995883},{x:-.5353954999999999,y:-.012283099999995883}],color:"primary",fill:!1},path29:{type:"path",points:[{x:.12606289999999998,y:-.2768663999999976},{x:.12606290000000042,y:.2523002000000023}],color:"primary",fill:!1},"path29-2":{type:"path",points:[{x:.07263109999999973,y:-.27614569999999716},{x:.07263110000000017,y:.253020900000001}],color:"primary",fill:!1},path30:{type:"path",points:[{x:-.13852050000000027,y:-.2768663999999976},{x:-.13852049999999982,y:.2523002000000023}],color:"primary",fill:!1},"path29-5":{type:"path",points:[{x:-.08244070000000026,y:-.27777869999999893},{x:-.08244069999999981,y:.2513879000000028}],color:"primary",fill:!1},"path29-2-7":{type:"path",points:[{x:.07253150000000019,y:-.27761959999999597},{x:-.08185069999999994,y:-.27761959999999597}],color:"primary",fill:!1},"path29-2-7-6":{type:"path",points:[{x:.0721257000000004,y:.255806800000002},{x:-.08225649999999973,y:.255806800000002}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.012864500000000056,y:-.4150086999999978},bottom1:{type:"text",text:"{VAL}",x:-.003850500000000423,y:.4250087000000011}},refblocks:{left1:{x:-.5512093000000002,y:-.011380399999998403},right1:{x:.5512093,y:-.011926899999997076}},bounds:{minX:-.5793677410000002,maxX:.579367741,minY:-.5150086999999978,maxY:.4250087000000011,width:1.1587354820000002,height:1,centerX:-11102230246251565e-32,centerY:-.04499999999999832},circles:{}},wke=kh(Xae).changeTextAnchor("{VAL}","middle_bottom").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_top").build(),Tke=kh(Xae).rotateRightFacingSymbol("down").changeTextAnchor("{VAL}","middle_left").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_right").build(),EF={paths:{path11:{type:"path",points:[{x:1.9942486145,y:-1.6422072295000003},{x:2.0984258145,y:-1.6428272295000004}],color:"primary",fill:!1},"path40-0":{type:"path",points:[{x:2.1030704145000003,y:-1.4809259295000001},{x:2.1026604145,y:-1.8041042295}],color:"primary",fill:!1},"path40-0-5":{type:"path",points:[{x:2.2218770145,y:-1.4969414295},{x:2.1063461145,y:-1.5757354295000003}],color:"primary",fill:!1},"path40-0-5-0":{type:"path",points:[{x:2.2286252145,y:-1.7819395295000002},{x:2.1136540145000002,y:-1.7033263295}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:2.2273251145,y:-1.4948802295},{x:2.2284101145,y:-1.1518438295000002}],color:"primary",fill:!1},"path12-1-5-3":{type:"path",points:[{x:2.2276017145,y:-1.9567437295},{x:2.2281317145,y:-1.7888340295000003}],color:"primary",fill:!1},"arrow-2":{type:"path",points:[{x:2.1704797145,y:-1.6991380295000003},{x:2.1275815145,y:-1.7604028295000003},{x:2.1917009144999997,y:-1.7601828295000004},{x:2.1704797145,y:-1.6991380295000003}],color:"primary",fill:!0},path1:{type:"path",points:[{x:1.5978828145000001,y:-1.5020091295000002},{x:1.8597023145000002,y:-1.5035561295000002}],color:"primary",fill:!1},path2:{type:"path",points:[{x:1.8686937145000002,y:-1.3411936295000002},{x:1.8682837145,y:-1.6643719295000001}],color:"primary",fill:!1},path3:{type:"path",points:[{x:1.9875004145000004,y:-1.3572092295000002},{x:1.8719693145,y:-1.4360031295000002}],color:"primary",fill:!1},path4:{type:"path",points:[{x:1.9942486145,y:-1.6422072295000003},{x:1.8792773145000001,y:-1.5635940295000004}],color:"primary",fill:!1},"arrow-1":{type:"path",points:[{x:1.9361028144999999,y:-1.5594057295000003},{x:1.8932048145,y:-1.6206705295000003},{x:1.9573242144999998,y:-1.6204505295000005},{x:1.9361028144999999,y:-1.5594057295000003}],color:"primary",fill:!0},path9:{type:"path",points:[{x:1.9943087144999998,y:-1.3539494295000003},{x:2.2269582145,y:-1.3556534295000002}],color:"primary",fill:!1}},texts:{bottom1:{type:"text",text:"{VAL}",x:1.8805772145,y:-1.9423669295000003},right1:{type:"text",text:"{REF}",x:1.8845380145,y:-1.1387692295000003}},refblocks:{right1:{x:2.2278617145000004,y:-1.9651412295000004},right2:{x:1.5977076145000002,y:-1.5027827295000002},right3:{x:2.2278680145,y:-1.1403971295000002}},bounds:{minX:1.5810976555000003,maxX:2.3461148445,minY:-1.9817511885000003,maxY:-1.1237871705000002,width:.7650171889999999,height:.8579640180000001,centerX:1.9636062500000002,centerY:-1.5527691795000003},circles:{"path1-0":{type:"circle",x:2.0463372145000003,y:-1.5363384295000002,radius:.29977763,color:"primary",fill:!1}}},Mke=kh(EF).changeTextAnchor("{VAL}","middle_top").labelPort("right2",["1"]).labelPort("right3",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_bottom").build();EF.bounds.width+=.3;var Cke=kh(EF).rotateRightFacingSymbol("down").changeTextAnchor("{VAL}","middle_right").labelPort("right2",["1"]).labelPort("right3",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_left").build(),Rke={paths:{path11:{type:"path",points:[{x:-.5307178,y:0},{x:-.3042887999999997,y:0}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.2899773000000003,y:0},{x:.5307178000000001,y:0}],color:"primary",fill:!1},path2:{type:"path",points:[{x:-.12447409999999959,y:.0852510999999998},{x:.11626639999999999,y:.0852510999999998}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.17652089999999898,y:-.4472267999999995},bottom1:{type:"text",text:"{VAL}",x:-.009849199999999891,y:.3470985000000004},left1:{type:"text",text:"A",x:0,y:-.1}},refblocks:{left1:{x:-.5446330999999993,y:0},right1:{x:.5381638000000004,y:0}},bounds:{minX:-.5307178,maxX:.5307178000000001,minY:-.08525110000000002,maxY:.0852510999999998,width:1.0614356000000003,height:1,centerX:5551115123125783e-32,centerY:-11102230246251565e-32},circles:{path1:{type:"circle",x:0,y:0,radius:.28854213,color:"primary",fill:!1}}},{paths:Ake,texts:Dke,bounds:RR,refblocks:Wae,circles:Pke}=Rke,wF=am({primitives:[...Object.values(Ake),...Object.values(Pke),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"},{...Dke.left1,x:0,y:.01,anchor:"center",fontSize:.3}],ports:[{...Wae.left1,labels:["1"]},{...Wae.right1,labels:["2"]}],size:{width:RR.width,height:RR.height},center:{x:RR.centerX,y:RR.centerY}});function Nke(r){return typeof r=="object"&&r!==null&&r.type==="path"&&Array.isArray(r.points)&&typeof r.color=="string"}function Lke(r){return typeof r=="object"&&r!==null&&r.type==="text"&&typeof r.text=="string"&&typeof r.x=="number"&&typeof r.y=="number"&&typeof r.anchor=="string"}var{6:TF,2:MF,...Oke}=wF.primitives;Nke(MF)&&MF.points.map(r=>{r.y+=.05}),Lke(TF)&&(TF.y+=.025);function Uke(r){return typeof r=="object"}var $ae=su({...wF,primitives:Object.values(Oke).filter(Uke)}),zke={...$ae,primitives:[...$ae.primitives,TF,MF]},Fke={paths:{path11:{type:"path",points:[{x:-.5307178,y:0},{x:-.3042887999999997,y:0}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.2899773000000003,y:0},{x:.5307178000000001,y:0}],color:"primary",fill:!1},"path11-5-5":{type:"path",points:[{x:.09442299999999992,y:-.13438304999999984},{x:-.004364400000000712,y:.05710404999999996},{x:-.1110211000000012,y:-.13438304999999984}],color:"primary",fill:!1},path2:{type:"path",points:[{x:-.12447409999999959,y:.13438304999999984},{x:.11626639999999999,y:.13438304999999984}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.17652089999999898,y:-.39809484999999944},bottom1:{type:"text",text:"{VAL}",x:-.009849199999999891,y:.39623045000000046}},refblocks:{left1:{x:-.5446330999999993,y:0},right1:{x:.5381638000000004,y:0}},bounds:{minX:-.5307178,maxX:.5307178000000001,minY:-.13438304999999984,maxY:.13438304999999984,width:1.0614356000000003,height:1,centerX:0,centerY:0},circles:{path1:{type:"circle",x:0,y:0,radius:.28854213,color:"primary",fill:!1}}},{paths:Ike,texts:VRt,bounds:AR,refblocks:Zae,circles:kke}=Fke,CF=am({primitives:[...Object.values(Ike),...Object.values(kke),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"}],ports:[{...Zae.left1,labels:["1"]},{...Zae.right1,labels:["2"]}],size:{width:AR.width,height:AR.height},center:{x:AR.centerX,y:AR.centerY}}),{2:Bke,3:Hke,...Vke}=CF.primitives;function jke(r){return typeof r=="object"}var Qae=su({...CF,primitives:Object.values(Vke).filter(jke)}),Gke={...Qae,primitives:[...Qae.primitives,Bke,Hke]},qke={paths:{path11:{type:"path",points:[{x:-.5176700499999997,y:.041745050000000505},{x:-.10888805000000024,y:.041745050000000505}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.1031184499999993,y:.041745050000000505},{x:.5246894499999994,y:.041745050000000505}],color:"primary",fill:!1},"path11-0":{type:"path",points:[{x:-.09343985000000021,y:-.14620634999999882},{x:-.0930998500000002,y:.2583405500000009}],color:"primary",fill:!1},"path11-0-3":{type:"path",points:[{x:.08519034999999908,y:-.14503384999999902},{x:.08553034999999909,y:.2595130500000007}],color:"primary",fill:!1},"path11-0-9":{type:"path",points:[{x:-.08315755000000014,y:.055934450000000524},{x:-.08415755000000047,y:-.14678124999999964},{x:.08653524999999984,y:-.05104664999999953},{x:-.08126175000000035,y:.05647715000000031}],color:"primary",fill:!0},"path11-0-9-0":{type:"path",points:[{x:.07661224999999927,y:.256654450000001},{x:.07761224999999983,y:.05393885000000109},{x:-.0930805500000007,y:.1496734500000012},{x:.07471644999999949,y:.25719715000000143}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:-.0316381500000007,y:.41683614999999996},bottom1:{type:"text",text:"{VAL}",x:-.03022294999999975,y:-.41683614999999996}},refblocks:{left1:{x:-.54139845,y:.04089205000000051},right1:{x:.5413984499999995,y:.04188845000000008}},bounds:{minX:-.569556891,maxX:.5695568909999995,minY:-.41683614999999996,maxY:.41683614999999996,width:1.1391137819999995,height:.8336722999999999,centerX:-2220446049250313e-31,centerY:0},circles:{path1:{type:"circle",x:-.0037626500000003116,y:.048873150000000365,radius:.28854213,color:"primary",fill:!1}}},Kae=kh(qke).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),Jae=su(Kae),eoe=Jae.primitives.filter(r=>r.type==="text"),Yke=eoe.find(r=>r.text==="{REF}"),Xke=eoe.find(r=>r.text==="{VAL}");Yke.y=0,Xke.y=0;var Wke=Jae,$ke={paths:{path40:{type:"path",points:[{x:.14458890000000002,y:.04403629999999836},{x:-.1199943999999995,y:-.08825540000000132}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.1199943999999995,y:.1763280000000016},{x:.14458890000000002,y:.04403629999999836}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.1199943999999995,y:-.08825539999999776},{x:-.1199943999999995,y:.1763280000000016}],color:"primary",fill:!1},path43:{type:"path",points:[{x:.14458890000000002,y:.1763280000000016},{x:.14458890000000002,y:-.08825539999999776}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.12219909999999956,y:.04403629999999836},{x:-.5168693999999996,y:.04403629999999836}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.5233797,y:.04395110000000102},{x:.14967160000000002,y:.04395110000000102}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.0050250999999996715,y:.27384529999999785},bottom1:{type:"text",text:"{VAL}",x:-.00011179999999999524,y:-.2738453000000014}},refblocks:{left1:{x:-.5191471000000001,y:.0449206999999987},right1:{x:.5191471000000001,y:.043896100000001326}},bounds:{minX:-.5473055410000001,maxX:.5473055410000001,minY:-.2738453000000014,maxY:.27384529999999785,width:1.0946110820000001,height:.5476905999999993,centerX:0,centerY:-17763568394002505e-31},circles:{}},DR=kh($ke).labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),Zke=su(DR,"down"),Qke=su(DR,"left"),Kke=su(DR,"up"),Jke={paths:{path1:{type:"path",points:[{x:-.3543580999999998,y:.22373490000000018},{x:-.1279290999999998,y:.22373490000000018}],color:"primary",fill:!1},"path-1-3":{type:"path",points:[{x:-.11341659999999987,y:.2240546000000001},{x:.1031012,y:.354}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.10434800000000011,y:.127178},{x:.345089,y:.127178}],color:"primary",fill:!1},path3:{type:"path",points:[{x:.12008600000000014,y:.36383770000000015},{x:.360827,y:.36383770000000015}],color:"primary",fill:!1},path4:{type:"path",points:[{x:-.3543580999999998,y:-.17811849999999985},{x:-.1279290999999998,y:-.17811849999999985}],color:"primary",fill:!1},"path4-6":{type:"path",points:[{x:-.11341659999999987,y:-.1777987999999997},{x:.1031012,y:-.04780299999999982}],color:"primary",fill:!1},path5:{type:"path",points:[{x:.10434800000000011,y:-.2746754},{x:.345089,y:-.2746754}],color:"primary",fill:!1},path6:{type:"path",points:[{x:.12008600000000014,y:-.038015699999999875},{x:.360827,y:-.038015699999999875}],color:"primary",fill:!1},"path1-4-join":{type:"path",points:[{x:-.020896399999999815,y:-.10273049999999984},{x:-.025476399999999844,y:.2768100000000002}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.0862317999999998,y:.46447740000000026},bottom1:{type:"text",text:"{VAL}",x:-.0862317999999998,y:-.4244773999999998}},refblocks:{top1:{x:-.11569089999999993,y:.22373490000000018},top2:{x:.10744680000000018,y:.36383770000000015},top3:{x:.10744750000000014,y:.12717810000000007},bottom1:{x:-.11569089999999993,y:-.17811849999999985},bottom2:{x:.10744750000000014,y:-.2746754},left1:{x:-.3682734999999999,y:.22373490000000018},left2:{x:-.3682734999999999,y:-.17811849999999985},right1:{x:.36827350000000014,y:.36383770000000015},right2:{x:.36827350000000014,y:.12717810000000007},right3:{x:.36827350000000014,y:-.038015699999999875},right4:{x:.10744680000000018,y:-.038015699999999875},right5:{x:.36827350000000014,y:-.2746754}},bounds:{minX:-.3964319409999999,maxX:.3964319410000001,minY:-.4744773999999998,maxY:.5644774000000002,width:1,height:1.0389548,centerX:-11102230246251565e-32,centerY:.045000000000000207},circles:{}},{paths:eBe,texts:toe,bounds:PR,refblocks:z8,circles:tBe}=Jke,noe=am({primitives:[...Object.values(eBe),...Object.values(tBe),{...toe.top1,anchor:"middle_bottom"},{...toe.bottom1,anchor:"middle_top"}],ports:[{...z8.left1,labels:["1"]},{...z8.left2,labels:["4"]},{...z8.right1,labels:["3"]},{...z8.right2,labels:["2"]},{...z8.right3,labels:["6"]},{...z8.right5,labels:["5"]}],size:{width:PR.width,height:PR.height},center:{x:PR.centerX,y:PR.centerY}}),roe=su(noe),ioe=roe.primitives.filter(r=>r.type==="text"),RF=ioe.find(r=>r.text==="{VAL}");RF.anchor="middle_right",RF.x=-.37,RF.y=.12;var AF=ioe.find(r=>r.text==="{REF}");AF.anchor="middle_left",AF.x=.37,AF.y=.12;var nBe=roe,aoe={paths:{path11:{type:"path",points:[{x:-.3622268000000006,y:.06287995000000057},{x:-.1357978000000004,y:.06287995000000057}],color:"primary",fill:!1},"path11-0":{type:"path",points:[{x:-.12009950000000069,y:.061349450000000916},{x:.10307889999999986,y:.2010388500000011}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.12795640000000064,y:.06287995000000057},{x:.36869780000000096,y:.06287995000000057}],color:"primary",fill:!1},"path11-5":{type:"path",points:[{x:-.3622270999999999,y:-.16866424999999907},{x:-.1357980999999997,y:-.16866424999999907}],color:"primary",fill:!1},"path11-0-3":{type:"path",points:[{x:-.12009979999999998,y:-.17019474999999962},{x:.10307860000000058,y:-.03050534999999921}],color:"primary",fill:!1},"path12-0":{type:"path",points:[{x:.12795610000000002,y:-.16866424999999907},{x:.3686968000000006,y:-.16866424999999907}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.1958158999999995,y:.39716265000000006},bottom1:{type:"text",text:"{VAL}",x:-.029144200000000398,y:-.39716264999999984}},refblocks:{bottom1:{x:-.12356020000000001,y:-.17345394999999963},bottom2:{x:.1153169000000005,y:-.17345394999999963},left1:{x:-.37614279999999956,y:-.16951715000000012},left2:{x:-.12356020000000001,y:.05809054999999996},left3:{x:-.37614279999999956,y:.06202735000000037},right1:{x:.37614279999999933,y:-.16852074999999966},right2:{x:.1153169000000005,y:.05809054999999996},right3:{x:.37614279999999933,y:.06302374999999993}},bounds:{minX:-.40430124099999953,maxX:.4043012409999993,minY:-.39716264999999984,maxY:.39716265000000006,width:.8086024819999988,height:.7943252999999999,centerX:-11102230246251565e-32,centerY:11102230246251565e-32},circles:{}};aoe.bounds.width+=.2;var{paths:rBe,texts:ooe,bounds:NR,refblocks:LR,circles:iBe}=aoe,soe=am({primitives:[...Object.values(rBe),...Object.values(iBe),{...ooe.top1,anchor:"middle_bottom",x:0},{...ooe.bottom1,anchor:"middle_top",x:0}],ports:[{...LR.left1,labels:["1","left1"]},{...LR.left3,labels:["3","left3"]},{...LR.right1,labels:["2","right1"]},{...LR.right3,labels:["4","right3"]}],size:{width:NR.width,height:NR.height},center:{x:NR.centerX,y:NR.centerY}}),loe=su(soe),coe=loe.primitives.filter(r=>r.type==="text"),DF=coe.find(r=>r.text==="{VAL}");DF.anchor="middle_right",DF.x=-.35,DF.y=0;var PF=coe.find(r=>r.text==="{REF}");PF.anchor="middle_left",PF.x=.3,PF.y=0;var aBe=loe,oBe={paths:{path11:{type:"path",points:[{x:-.541495829500001,y:.044368009536419395},{x:-.21998262950000114,y:.044368009536419395}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.14450697049999905,y:.052237309536419474},{x:.46379767049999976,y:.052237309536419474}],color:"primary",fill:!1},"path12-6":{type:"path",points:[{x:.13965347050000032,y:-.14937819046358025},{x:.13854747050000027,y:.2538388095364199}],color:"primary",fill:!1},"path11-0-9":{type:"path",points:[{x:-.212703829500001,y:.2732984095364195},{x:-.2147708295000006,y:-.1493854904635803},{x:.13782137049999887,y:.050231709536419755},{x:-.2087893295000005,y:.27442980953642016}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:-.08906882950000083,y:.38011220953641867},bottom1:{type:"text",text:"{VAL}",x:-.0685314901614209,y:-.38011220953641844},right1:{type:"text",text:"",x:.5884896704999998,y:-.3288545904635811}},refblocks:{left1:{x:-.5603312294999999,y:.04351520953641885},right1:{x:.47524967049999955,y:.05238090953641872}},bounds:{minX:-.5884896704999999,maxX:.5884896704999998,minY:-.38011220953641844,maxY:.38011220953641867,width:1.1769793409999996,height:.7602244190728371,centerX:-5551115123125783e-32,centerY:11102230246251565e-32},circles:{}},uoe=kh(oBe).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),sBe=su(uoe),lBe={paths:{path11:{type:"path",points:[{x:-.5307178,y:0},{x:-.3042887999999997,y:0}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.2899773000000003,y:0},{x:.5307178000000001,y:0}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.17652089999999898,y:-.36197569999999946},bottom1:{type:"text",text:"{VAL}",x:-.009849199999999891,y:.43234960000000044},left1:{type:"text",text:"Hz",x:0,y:-.035}},refblocks:{left1:{x:-.5446330999999993,y:.000852800000000542},right1:{x:.5381638000000004,y:-.00014359999999924433}},bounds:{minX:-.5307178,maxX:.5307178000000001,minY:0,maxY:0,width:1.0614356000000003,height:1,centerX:5551115123125783e-32,centerY:0},circles:{path1:{type:"circle",x:-.006997299999999651,y:-.007128299999999532,radius:.28854213,color:"primary",fill:!1}}},{paths:cBe,texts:uBe,bounds:OR,refblocks:foe,circles:fBe}=lBe,NF=am({primitives:[...Object.values(cBe),...Object.values(fBe),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"},{...uBe.left1,x:0,y:.01,anchor:"center",fontSize:.2}],ports:[{...foe.left1,labels:["1"]},{...foe.right1,labels:["2"]}],size:{width:OR.width,height:OR.height},center:{x:OR.centerX,y:OR.centerY}}),{5:dBe,...hBe}=NF.primitives;function pBe(r){return typeof r=="object"}var doe=su({...NF,primitives:Object.values(hBe).filter(pBe)}),mBe={...doe,primitives:[...doe.primitives,dBe]},vBe={paths:{path10:{type:"path",points:[{x:-.5283037500000001,y:.036413650000000075},{x:.5300302500000003,y:.036413650000000075}],color:"primary",fill:!1},path14:{type:"path",points:[{x:.0008652499999994845,y:.16870534999999975},{x:.2654482499999995,y:.16870534999999975},{x:.2654482499999995,y:-.0958780499999996},{x:-.2637187499999998,y:-.0958780499999996},{x:-.2637187499999998,y:.16870534999999975},{x:.0008652499999994845,y:.16870534999999975}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.008263949999999909,y:.23591724999999997},bottom1:{type:"text",text:"{VAL}",x:-.1716539500000005,y:-.23591724999999997}},refblocks:{left1:{x:-.5345548500000001,y:.03946054999999937},right1:{x:.5345548500000001,y:.0352561499999986}},bounds:{minX:-.5627132910000001,maxX:.5627132910000001,minY:-.23591724999999997,maxY:.23591724999999997,width:1.1254265820000002,height:.47183449999999993,centerX:0,centerY:0},circles:{}},{paths:yBe,texts:gBe,bounds:UR,refblocks:hoe}=vBe,poe=am({primitives:[...Object.values(yBe),{...gBe.top1,anchor:"middle_bottom"},{type:"text",text:"{VAL}",x:0,y:-.2,anchor:"middle_top"}],ports:[{...hoe.left1,labels:["1"]},{...hoe.right1,labels:["2"]}],size:{width:UR.width,height:UR.height},center:{x:UR.centerX,y:UR.centerY}}),_Be=su(poe),xBe={paths:{path1:{type:"path",points:[{x:-.33997010000000016,y:.4545300000000001},{x:-.03997010000000012,y:.4545300000000001}],color:"primary",fill:!1},path2:{type:"path",points:[{x:-.02032289999999981,y:.25053000000000014},{x:-.020322900000000033,y:.65053}],color:"primary",fill:!1},path3:{type:"path",points:[{x:.050000000000000044,y:.3005300000000002},{x:.050000000000000044,y:.60053}],color:"primary",fill:!1},path4:{type:"path",points:[{x:.1499999999999997,y:.40053000000000005},{x:.1499999999999997,y:.5005300000000001}],color:"primary",fill:!1}},texts:{bottom1:{type:"text",text:"{REF}",x:-.44999999999999996,y:-.6505299999999998},right1:{type:"text",text:"{VAL}",x:.44999999999999973,y:.35053}},refblocks:{top1:{x:-.33997010000000016,y:.4545300000000001},top2:{x:.17000000000000015,y:.4535300000000002}},bounds:{minX:-.44999999999999996,maxX:.44999999999999973,minY:-.6505299999999998,maxY:.65053,width:.8999999999999997,height:1.3010599999999999,centerX:-11102230246251565e-32,centerY:11102230246251565e-32},circles:{}},{paths:bBe,circles:SBe,bounds:jRt,refblocks:EBe}=xBe,wBe=am({primitives:[...Object.values(bBe),...Object.values(SBe),{type:"text",text:"{REF}",x:-.1,y:.8,anchor:"middle_bottom"},{type:"text",text:"{VAL}",x:-.1,y:.1,anchor:"middle_top"}],ports:[{...EBe.top1,labels:["1"]}],size:{width:1,height:1},center:{x:0,y:.4}}),moe=wBe,TBe=kh(moe).rotateRightFacingSymbol("down").build(),voe={paths:{path11:{type:"path",points:[{x:-.49895505000000084,y:.035186950000000605},{x:-.177441850000001,y:.035186950000000605}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.18704774999999918,y:.043056250000000684},{x:.5063384499999999,y:.043056250000000684}],color:"primary",fill:!1},"path11-0-9":{type:"path",points:[{x:-.3067105499999998,y:.19836805000000046},{x:-.3084575500000002,y:-.10569684999999973},{x:-.01040014999999972,y:.03790115000000038},{x:-.3034011499999991,y:.1991819500000005}],color:"primary",fill:!0},"path11-0-9-5":{type:"path",points:[{x:.3324594500000002,y:.19920585000000046},{x:.33420945000000013,y:-.10485904999999973},{x:.03615254999999973,y:.03873895000000038},{x:.32915344999999974,y:.2000197500000005}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:.042716749999999415,y:.3158462499999999},bottom1:{type:"text",text:"{VAL}",x:.035355149999999336,y:-.3158462499999999}},refblocks:{left1:{x:-.5177904499999998,y:.03433415000000006},right1:{x:.5177904499999997,y:.04319984999999993}},bounds:{minX:-.5459488909999998,maxX:.5459488909999997,minY:-.3158462499999999,maxY:.3158462499999999,width:1.0918977819999993,height:.6316924999999998,centerX:-5551115123125783e-32,centerY:0},circles:{}},MBe=kh(voe).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),CBe=kh(voe).rotateRightFacingSymbol("down").changeTextAnchor("{VAL}","middle_right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").build(),RBe={paths:{path45:{type:"path",points:[{x:.13585750000000063,y:-.003696399999999045},{x:-.12872579999999934,y:-.13598810000000228}],color:"primary",fill:!1},"path1-8":{type:"path",points:[{x:.12763670000000094,y:-.003920199999999596},{x:.3,y:-.003920199999999596}],color:"primary",fill:!1},path46:{type:"path",points:[{x:-.12872579999999934,y:.12859530000000063},{x:.13585750000000063,y:-.003696399999999045}],color:"primary",fill:!1},path47:{type:"path",points:[{x:-.12872579999999934,y:-.13598810000000228},{x:-.12872579999999934,y:.12859530000000063}],color:"primary",fill:!1},path48:{type:"path",points:[{x:.13585750000000063,y:.12859530000000063},{x:.13585750000000063,y:-.13598810000000228}],color:"primary",fill:!1},path49:{type:"path",points:[{x:-.13076959999999938,y:-.003696399999999045},{x:-.3,y:-.003696399999999045}],color:"primary",fill:!1},path25:{type:"path",points:[{x:-.1557438999999996,y:.28545279999999806},{x:-.2530861999999994,y:.3023319999999998},{x:-.21878339999999952,y:.20956920000000068}],color:"primary",fill:!0},path78:{type:"path",points:[{x:-.08000449999999937,y:.16590799999999817},{x:-.09202799999999911,y:.1748410000000007},{x:-.2137844999999996,y:.26529680000000155},{x:-.2144144999999993,y:.2662468000000011}],color:"primary",fill:!1},"path25-0":{type:"path",points:[{x:.021722400000000697,y:.30658939999999646},{x:-.07561989999999952,y:.3234685999999982},{x:-.04131709999999922,y:.23070579999999907}],color:"primary",fill:!0},"path78-6":{type:"path",points:[{x:.09746180000000093,y:.18704459999999656},{x:.08543830000000074,y:.19597759999999909},{x:-.0363181999999993,y:.28643339999999995},{x:-.03694819999999943,y:.2873833999999995}],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:.1333},{x:-.5362092999999997,y:.1333}],color:"primary",fill:!1},"path48-2":{type:"path",points:[{x:-.3,y:-.1333},{x:-.5362092999999997,y:-.1333}],color:"primary",fill:!1},"path48-3":{type:"path",points:[{x:.3,y:-.1333},{x:.5362093000000003,y:-.1333}],color:"primary",fill:!1},"path48-4":{type:"path",points:[{x:.3,y:.1333},{x:.5362093000000003,y:.1333}],color:"primary",fill:!1}},texts:{bottom1:{type:"text",text:"{VAL}",x:0,y:-.43222},right1:{type:"text",text:"{REF}",x:0,y:.43222}},refblocks:{left1:{x:-.5362092999999997,y:.1333},left2:{x:-.5362092999999997,y:-.1333},right1:{x:.5362093000000003,y:-.1333},right2:{x:.5362093000000003,y:.1333}},bounds:{minX:-.5643677409999996,maxX:.5643677410000003,minY:-.3234685999999982,maxY:.3234685999999982,width:1.128735482,height:.6469371999999964,centerX:33306690738754696e-32,centerY:0},circles:{}},zR=kh(RBe).labelPort("left1",["1","DIN"]).labelPort("left2",["2","POWER"]).labelPort("right1",["4","GND"]).labelPort("right2",["3","DOUT"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),ABe=su(zR,"down"),DBe=bF(zR),LF=su(zR,"up"),PBe={...LF,primitives:LF.primitives.map(r=>r.type==="path"&&(r.points.length===3||r.points.length===4)?{...r,points:r.points.map(e=>({x:e.x,y:-e.y+2*LF.center.y}))}:r)},NBe=PBe,LBe={paths:{path11:{type:"path",points:[{x:-.3850944445000005,y:.0010025000000009054},{x:-.006525044499999799,y:-.0016204999999989145}],color:"primary",fill:!1},path40:{type:"path",points:[{x:.07415065550000066,y:.19027400000000116},{x:.07322065550000101,y:-.17787549999999852}],color:"primary",fill:!1},path42:{type:"path",points:[{x:.01002445549999953,y:-.12022799999999911},{x:.01002445549999953,y:.1443554000000009}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.28374995550000004,y:-.2462579999999992},{x:.2831499554999999,y:-.5425888999999995}],color:"primary",fill:!1},"path12-1":{type:"path",points:[{x:.28423665550000043,y:.5370061000000012},{x:.2836366555000003,y:.2678117000000011}],color:"primary",fill:!1},path15:{type:"path",points:[{x:.1731829554999995,y:-.2153930999999989},{x:.2780310554999992,y:-.23045039999999894},{x:.2324710554999987,y:-.14155709999999888}],color:"primary",fill:!0},path17:{type:"path",points:[{x:.07704605550000054,y:-.08544359999999895},{x:.2325688555000005,y:-.19774119999999895}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.07425025549999931,y:.11255990000000127},{x:.28369465549999884,y:.2606293000000013}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.006566644499999885,y:.35624680000000075},bottom1:{type:"text",text:"{VAL}",x:.020614555499999687,y:-.4202180999999998}},refblocks:{top1:{x:.2843894554999997,y:.5566011000000001},bottom1:{x:.2823318555000005,y:-.5566010999999997},left1:{x:-.3990097444999998,y:.00014970000000036343}},bounds:{minX:-.4271681854999998,maxX:.42716818549999985,minY:-.5847595409999997,maxY:.584759541,width:.8543363709999996,height:1.1695190819999999,centerX:27755575615628914e-33,centerY:16653345369377348e-32},circles:{path1:{type:"circle",x:.13862605549999985,y:.008130800000000438,radius:.28854213,color:"primary",fill:!1}}},yoe=kh(LBe).changeTextAnchor("{VAL}","middle_right").labelPort("left1",["3"]).labelPort("top1",["2"]).labelPort("bottom1",["1"]).changeTextAnchor("{REF}","middle_right").build(),OF=su(yoe),UF=OF.primitives.find(r=>r.type==="text"&&r.text==="{REF}"),goe=OF.primitives.find(r=>r.type==="text"&&r.text==="{VAL}");UF.anchor="middle_left",goe.anchor="middle_right",UF.x=.45,UF.y+=.065,goe.y+=.065;var OBe=OF,UBe={paths:{"path12-1-8-6-9":{type:"path",points:[{x:.023137150000000162,y:-.022408499999999165},{x:.023137150000000162,y:-.10240850000000101}],color:"primary",fill:!1},"path12-1-5-6":{type:"path",points:[{x:-.48740694999999956,y:-.18547949999999958},{x:-.1731006500000003,y:-.18547949999999958}],color:"primary",fill:!1},"path12-1-5-6-8":{type:"path",points:[{x:.023792949999999813,y:.17183650000000128},{x:.023792949999999813,y:.10518850000000057}],color:"primary",fill:!1},"path12-1-8-0":{type:"path",points:[{x:-.14922445000000018,y:-.032671500000001075},{x:.19549865000000022,y:-.18509050000000116}],color:"primary",fill:!1},"path12-1-0":{type:"path",points:[{x:.19549885000000078,y:-.18509050000000116},{x:.4881437499999999,y:-.18509050000000116}],color:"primary",fill:!1},"path12-1-8-6-9-4":{type:"path",points:[{x:.023137150000000162,y:.11939749999999982},{x:.023137150000000162,y:.017597499999999044}],color:"primary",fill:!1},"path12-1-8-6-9-4-3":{type:"path",points:[{x:.08312335000000015,y:.10724749999999972},{x:.08312335000000015,y:.050463500000001105}],color:"primary",fill:!1},"path12-1-8-6-9-4-3-1":{type:"path",points:[{x:-.03684904999999983,y:.10724749999999972},{x:-.03684904999999983,y:.050463500000001105}],color:"primary",fill:!1},"path12-1-8-6-9-4-4":{type:"path",points:[{x:.08312335000000015,y:.10724749999999972},{x:-.03684904999999983,y:.10724749999999972}],color:"primary",fill:!1},"path14-5":{type:"path",points:[{x:-.011640198644880861,y:.2824489119921765},{x:.01182744133211866,y:.25421423950368016},{x:.035295081309120846,y:.22597956701517674},{x:.05876272128612037,y:.19774489452667865}],color:"primary",fill:!0},"path14-5-3":{type:"path",points:[{x:-.011818241440559873,y:.19775449269853418},{x:.01171692178543804,y:.22592735480803405},{x:.03525208501144128,y:.25410021691753926},{x:.058787248237439194,y:.2822730790270338}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:.010987250000000337,y:.3808714999999978},bottom1:{type:"text",text:"{VAL}",x:.05578094999999994,y:-.3808714999999996}},refblocks:{left1:{x:-.4717985499999999,y:-.1854504999999982},right1:{x:.4717985499999999,y:-.18547650000000182}},bounds:{minX:-.4999569909999999,maxX:.4999569909999999,minY:-.3808714999999996,maxY:.3808714999999978,width:.9999139819999998,height:.7617429999999974,centerX:0,centerY:-8881784197001252e-31},circles:{path9:{type:"circle",x:.02379285000000042,y:.24000550000000054,radius:.059920847,color:"primary",fill:!1}}},_oe=kh(UBe).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),xoe=su(_oe),boe=xoe.primitives.filter(r=>r.type==="text"),zF=boe.find(r=>r.text==="{VAL}");zF.x=-.35,zF.y=0,zF.anchor="middle_right";var FF=boe.find(r=>r.text==="{REF}");FF.y=0,FF.x=.35,FF.anchor="middle_left";var zBe=xoe,FBe={paths:{path8698:{type:"path",points:[{x:-.20003504999999944,y:-.023826854587889912},{x:-.20252458999999945,y:-.018993393814014044},{x:-.20501412999999943,y:-.014174384106555204},{x:-.2075036699999995,y:-.009384187436300498},{x:-.20999320999999949,y:-.004636988132081332},{x:-.2124827499999995,y:5329457033053167e-20},{x:-.2149722899999995,y:.004673092344940186},{x:-.2174618299999995,y:.009209271428771242},{x:-.21995136999999956,y:.013649213595881985},{x:-.22244090999999955,y:.01798089395292432},{x:-.22493044999999956,y:.022192955076609913},{x:-.22741998999999957,y:.02627477703600152},{x:-.22990952999999958,y:.030216542867918667},{x:-.2323990699999996,y:.03400929910178016},{x:-.2348886099999996,y:.03764501096072756},{x:-.23737814999999962,y:.04111661189869628},{x:-.23986768999999963,y:.04441804716802203},{x:-.24235722999999965,y:.04754431114897349},{x:-.24484676999999966,y:.05049147821106258},{x:-.24733630999999967,y:.053256726915861724},{x:-.24982584999999968,y:.05583835741211009},{x:-.2523153899999997,y:.05823580191586174},{x:-.2548049299999997,y:.060449628211062575},{x:-.2572944699999997,y:.0624815361489735},{x:-.25978400999999973,y:.06433434716802203},{x:-.26227354999999974,y:.06601198689869628},{x:-.26476308999999976,y:.06751946096072757},{x:-.26725262999999977,y:.06886282410178016},{x:-.2697421699999998,y:.07004914286791866},{x:-.2722317099999998,y:.0710864520360015},{x:-.2747212499999998,y:.07198370507660991},{x:-.2772107899999998,y:.07275071895292433},{x:-.27970032999999983,y:.07339811359588198},{x:-.28218986999999984,y:.07393724642877124},{x:-.28467940999999986,y:.07438014234494018},{x:-.28716894999999987,y:.07473941957033053},{x:-.2896584899999999,y:.07502821186791866},{x:-.2921480299999999,y:.07526008756369952},{x:-.2946375699999999,y:.07544896589344477},{x:-.2971271099999999,y:.07560903118598594},{x:-.29961664999999993,y:.07575464541211008},{x:-.3021061874999999,y:.07560903118598594},{x:-.30459572499999993,y:.07544896589344477},{x:-.3070852624999999,y:.07526008756369951},{x:-.30957479999999993,y:.07502821186791866},{x:-.31206433749999984,y:.07473941957033052},{x:-.3145538749999998,y:.07438014234494018},{x:-.31704341249999984,y:.07393724642877124},{x:-.31953294999999987,y:.07339811359588198},{x:-.32202248749999984,y:.07275071895292431},{x:-.3245120249999998,y:.07198370507660991},{x:-.3270015624999998,y:.0710864520360015},{x:-.32949109999999976,y:.07004914286791866},{x:-.33198063749999984,y:.06886282410178016},{x:-.33447017499999976,y:.06751946096072757},{x:-.3369597124999998,y:.06601198689869628},{x:-.33944924999999976,y:.06433434716802203},{x:-.34193878749999973,y:.06248153614897349},{x:-.34442832499999976,y:.06044962821106258},{x:-.3469178624999997,y:.05823580191586174},{x:-.3494073999999997,y:.05583835741211009},{x:-.35189693749999973,y:.053256726915861724},{x:-.35438647499999965,y:.050491478211062576},{x:-.3568760124999997,y:.0475443111489735},{x:-.35936554999999964,y:.04441804716802203},{x:-.3618550874999996,y:.04111661189869628},{x:-.36434462499999964,y:.03764501096072756},{x:-.36683416249999967,y:.03400929910178016},{x:-.3693236999999996,y:.030216542867918673},{x:-.3718132374999996,y:.02627477703600152},{x:-.3743027749999996,y:.022192955076609917},{x:-.37679231249999956,y:.017980893952924324},{x:-.3792818499999996,y:.013649213595881985},{x:-.3817713874999995,y:.00920927142877125},{x:-.38426092499999953,y:.004673092344940191},{x:-.38675046249999956,y:5329457033053514e-20},{x:-.38923999999999953,y:-.004636988132081328},{x:-.39172953749999956,y:-.009384187436300498},{x:-.3942190749999995,y:-.014174384106555197},{x:-.3967086124999995,y:-.01899339381401404},{x:-.3991981499999995,y:-.023826854587889912}],color:"primary",fill:!1},path8700:{type:"path",points:[{x:-.000872049999999458,y:-.02382615458789039},{x:-.0033615874999994412,y:-.01899269131401453},{x:-.0058511249999994245,y:-.014173679106555696},{x:-.008340662499999407,y:-.009383479936300985},{x:-.010830199999999391,y:-.004636278132081827},{x:-.013319737499999373,y:5400707033003174e-20},{x:-.015809274999999356,y:.004673807344939683},{x:-.018298812499999338,y:.009209988928770731},{x:-.020788349999999324,y:.013649933595881476},{x:-.023277887499999306,y:.017981616452923805},{x:-.02576742499999929,y:.022193680076609393},{x:-.02825696249999927,y:.026275504536001},{x:-.030746499999999254,y:.030217272867918137},{x:-.03323603749999924,y:.034010031601779636},{x:-.03572557499999922,y:.03764574596072702},{x:-.038215112499999204,y:.04111734939869574},{x:-.04070464999999919,y:.04441878716802149},{x:-.04319418749999917,y:.04754505364897295},{x:-.045683724999999155,y:.05049222321106203},{x:-.048173262499999134,y:.05325747441586117},{x:-.05066279999999912,y:.055839107412109526},{x:-.053152337499999106,y:.05823655441586117},{x:-.055641874999999084,y:.06045038321106201},{x:-.05813141249999907,y:.06248229364897292},{x:-.06062094999999905,y:.06433510716802145},{x:-.06311048749999904,y:.0660127493986957},{x:-.06560002499999902,y:.06752022596072697},{x:-.068089562499999,y:.06886359160177957},{x:-.07057909999999898,y:.07004991286791806},{x:-.07306863749999896,y:.07108722453600091},{x:-.07555817499999895,y:.0719844800766093},{x:-.07804771249999894,y:.07275149645292371},{x:-.08053724999999892,y:.07339889359588138},{x:-.0830267874999989,y:.07393802892877062},{x:-.08551632499999888,y:.07438092734493956},{x:-.08800586249999887,y:.07474020707032991},{x:-.09049539999999885,y:.07502900186791804},{x:-.09298493749999884,y:.07526088006369888},{x:-.09547447499999881,y:.07544976089344414},{x:-.0979640124999988,y:.0756098286859853},{x:-.10045354999999878,y:.07575544541210943},{x:-.1029430899999988,y:.0756098286859853},{x:-.1054326299999988,y:.07544976089344414},{x:-.10792216999999882,y:.07526088006369887},{x:-.11041170999999883,y:.07502900186791804},{x:-.11290124999999884,y:.0747402070703299},{x:-.11539078999999886,y:.07438092734493956},{x:-.11788032999999885,y:.07393802892877062},{x:-.1203698699999989,y:.07339889359588138},{x:-.12285940999999889,y:.07275149645292371},{x:-.1253489499999989,y:.0719844800766093},{x:-.12783848999999892,y:.07108722453600091},{x:-.13032802999999893,y:.07004991286791806},{x:-.13281756999999894,y:.06886359160177957},{x:-.13530710999999895,y:.06752022596072697},{x:-.13779664999999897,y:.0660127493986957},{x:-.14028618999999898,y:.06433510716802145},{x:-.142775729999999,y:.06248229364897291},{x:-.145265269999999,y:.06045038321106202},{x:-.14775480999999901,y:.05823655441586117},{x:-.15024434999999903,y:.055839107412109526},{x:-.15273388999999904,y:.05325747441586117},{x:-.15522342999999905,y:.05049222321106202},{x:-.15771296999999906,y:.047545053648972956},{x:-.16020250999999908,y:.04441878716802149},{x:-.1626920499999991,y:.04111734939869574},{x:-.1651815899999991,y:.03764574596072702},{x:-.16767112999999914,y:.034010031601779636},{x:-.1701606699999991,y:.03021727286791814},{x:-.17265020999999914,y:.026275504536001},{x:-.17513974999999915,y:.022193680076609396},{x:-.17762928999999916,y:.017981616452923805},{x:-.1801188299999992,y:.013649933595881474},{x:-.18260836999999916,y:.00920998892877074},{x:-.1850979099999992,y:.0046738073449396865},{x:-.1875874499999992,y:5400707033003521e-20},{x:-.19007698999999922,y:-.004636278132081827},{x:-.19256652999999926,y:-.009383479936300985},{x:-.19505606999999922,y:-.01417367910655569},{x:-.19754560999999926,y:-.018992691314014522},{x:-.20003514999999927,y:-.02382615458789039}],color:"primary",fill:!1},path8702:{type:"path",points:[{x:.19829105000000036,y:-.02382615458789039},{x:.19580151000000035,y:-.01899269131401453},{x:.1933119700000003,y:-.014173679106555696},{x:.19082243000000035,y:-.009383479936300985},{x:.1883328900000003,y:-.004636278132081827},{x:.1858433500000003,y:5400707033003174e-20},{x:.18335381000000028,y:.004673807344939683},{x:.18086427000000024,y:.009209988928770731},{x:.1783747300000003,y:.013649933595881476},{x:.17588519000000025,y:.017981616452923805},{x:.17339565000000023,y:.022193680076609393},{x:.17090611000000022,y:.026275504536001},{x:.16841657000000018,y:.030217272867918137},{x:.16592703000000023,y:.034010031601779636},{x:.16343749000000019,y:.03764574596072702},{x:.16094795000000017,y:.04111734939869574},{x:.15845841000000016,y:.04441878716802149},{x:.15596887000000015,y:.04754505364897295},{x:.15347933000000014,y:.05049222321106203},{x:.15098979000000012,y:.05325747441586117},{x:.1485002500000001,y:.055839107412109526},{x:.1460107100000001,y:.05823655441586117},{x:.1435211700000001,y:.06045038321106201},{x:.14103163000000007,y:.06248229364897292},{x:.13854209000000006,y:.06433510716802145},{x:.13605255000000005,y:.0660127493986957},{x:.13356301000000004,y:.06752022596072697},{x:.13107347000000003,y:.06886359160177957},{x:.12858393,y:.07004991286791806},{x:.12609439,y:.07108722453600091},{x:.12360484999999999,y:.0719844800766093},{x:.12111530999999998,y:.07275149645292371},{x:.11862576999999996,y:.07339889359588138},{x:.11613622999999995,y:.07393802892877062},{x:.11364668999999994,y:.07438092734493956},{x:.11115714999999993,y:.07474020707032991},{x:.10866760999999991,y:.07502900186791804},{x:.1061780699999999,y:.07526088006369888},{x:.10368852999999989,y:.07544976089344414},{x:.10119898999999988,y:.0756098286859853},{x:.09870944999999987,y:.07575544541210943},{x:.09621991249999988,y:.0756098286859853},{x:.0937303749999999,y:.07544976089344414},{x:.09124083749999992,y:.07526088006369887},{x:.08875129999999994,y:.07502900186791804},{x:.08626176249999995,y:.0747402070703299},{x:.08377222499999996,y:.07438092734493956},{x:.08128268749999998,y:.07393802892877062},{x:.07879315,y:.07339889359588138},{x:.07630361250000002,y:.07275149645292371},{x:.07381407500000003,y:.0719844800766093},{x:.07132453750000005,y:.07108722453600091},{x:.06883500000000006,y:.07004991286791806},{x:.06634546250000009,y:.06886359160177957},{x:.0638559250000001,y:.06752022596072697},{x:.06136638750000012,y:.0660127493986957},{x:.05887685000000013,y:.06433510716802145},{x:.05638731250000015,y:.06248229364897291},{x:.053897775000000175,y:.06045038321106202},{x:.05140823750000019,y:.05823655441586117},{x:.048918700000000204,y:.055839107412109526},{x:.04642916250000022,y:.05325747441586117},{x:.04393962500000023,y:.05049222321106202},{x:.04145008750000026,y:.047545053648972956},{x:.038960550000000274,y:.04441878716802149},{x:.03647101250000029,y:.04111734939869574},{x:.0339814750000003,y:.03764574596072702},{x:.03149193750000032,y:.034010031601779636},{x:.02900240000000034,y:.03021727286791814},{x:.02651286250000036,y:.026275504536001},{x:.024023325000000373,y:.022193680076609396},{x:.021533787500000387,y:.017981616452923805},{x:.019044250000000405,y:.013649933595881474},{x:.016554712500000426,y:.00920998892877074},{x:.014065175000000442,y:.0046738073449396865},{x:.011575637500000457,y:5400707033003521e-20},{x:.009086100000000473,y:-.004636278132081827},{x:.006596562500000487,y:-.009383479936300985},{x:.004107025000000513,y:-.01417367910655569},{x:.0016174875000005274,y:-.018992691314014522},{x:-.000872049999999458,y:-.02382615458789039}],color:"primary",fill:!1},path8704:{type:"path",points:[{x:.39745405000000034,y:-.02382615458789039},{x:.3949645125000003,y:-.01899269131401453},{x:.39247497500000034,y:-.014173679106555696},{x:.3899854375000004,y:-.009383479936300985},{x:.38749590000000045,y:-.004636278132081827},{x:.3850063625000004,y:5400707033003174e-20},{x:.3825168250000004,y:.004673807344939683},{x:.3800272875000004,y:.009209988928770731},{x:.3775377500000005,y:.013649933595881476},{x:.37504821250000053,y:.017981616452923805},{x:.3725586750000005,y:.022193680076609393},{x:.3700691375000005,y:.026275504536001},{x:.3675796000000005,y:.030217272867918137},{x:.3650900625000006,y:.034010031601779636},{x:.3626005250000006,y:.03764574596072702},{x:.3601109875000006,y:.04111734939869574},{x:.35762145000000056,y:.04441878716802149},{x:.3551319125000006,y:.04754505364897295},{x:.3526423750000007,y:.05049222321106203},{x:.3501528375000007,y:.05325747441586117},{x:.3476633000000007,y:.055839107412109526},{x:.34517376250000065,y:.05823655441586117},{x:.34268422500000073,y:.06045038321106201},{x:.3401946875000007,y:.06248229364897292},{x:.3377051500000008,y:.06433510716802145},{x:.33521561250000076,y:.0660127493986957},{x:.33272607500000073,y:.06752022596072697},{x:.3302365375000008,y:.06886359160177957},{x:.3277470000000008,y:.07004991286791806},{x:.3252574625000008,y:.07108722453600091},{x:.32276792500000084,y:.0719844800766093},{x:.32027838750000087,y:.07275149645292371},{x:.3177888500000009,y:.07339889359588138},{x:.3152993125000009,y:.07393802892877062},{x:.3128097750000009,y:.07438092734493956},{x:.31032023750000093,y:.07474020707032991},{x:.30783070000000096,y:.07502900186791804},{x:.305341162500001,y:.07526088006369888},{x:.30285162500000096,y:.07544976089344414},{x:.300362087500001,y:.0756098286859853},{x:.297872550000001,y:.07575544541210943},{x:.29538301000000095,y:.0756098286859853},{x:.292893470000001,y:.07544976089344414},{x:.290403930000001,y:.07526088006369887},{x:.287914390000001,y:.07502900186791804},{x:.28542485000000095,y:.0747402070703299},{x:.2829353100000009,y:.07438092734493956},{x:.2804457700000009,y:.07393802892877062},{x:.2779562300000009,y:.07339889359588138},{x:.2754666900000009,y:.07275149645292371},{x:.2729771500000009,y:.0719844800766093},{x:.2704876100000009,y:.07108722453600091},{x:.26799807000000087,y:.07004991286791806},{x:.26550853000000085,y:.06886359160177957},{x:.26301899000000084,y:.06752022596072697},{x:.26052945000000083,y:.0660127493986957},{x:.2580399100000008,y:.06433510716802145},{x:.2555503700000008,y:.06248229364897291},{x:.2530608300000008,y:.06045038321106202},{x:.2505712900000008,y:.05823655441586117},{x:.24808175000000077,y:.055839107412109526},{x:.24559221000000075,y:.05325747441586117},{x:.24310267000000074,y:.05049222321106202},{x:.24061313000000073,y:.047545053648972956},{x:.23812359000000072,y:.04441878716802149},{x:.2356340500000007,y:.04111734939869574},{x:.2331445100000007,y:.03764574596072702},{x:.23065497000000068,y:.034010031601779636},{x:.22816543000000067,y:.03021727286791814},{x:.22567589000000066,y:.026275504536001},{x:.22318635000000064,y:.022193680076609396},{x:.22069681000000063,y:.017981616452923805},{x:.21820727000000062,y:.013649933595881474},{x:.2157177300000006,y:.00920998892877074},{x:.2132281900000006,y:.0046738073449396865},{x:.21073865000000058,y:5400707033003521e-20},{x:.20824911000000057,y:-.004636278132081827},{x:.20575957000000056,y:-.009383479936300985},{x:.20327003000000055,y:-.01417367910655569},{x:.20078049000000053,y:-.018992691314014522},{x:.19829095000000052,y:-.02382615458789039}],color:"primary",fill:!1},path8706:{type:"path",points:[{x:-.4023286499999996,y:-.022544054587890106},{x:-.5293590499999994,y:-.022544054587890106}],color:"primary",fill:!1},"path8706-5":{type:"path",points:[{x:.5261604500000003,y:-.027111054587890093},{x:.39913004999999946,y:-.027111054587890093}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.0040821499999992295,y:.22997364541210996},bottom1:{type:"text",text:"{VAL}",x:-.004252755294839927,y:-.22997364541210996}},refblocks:{left1:{x:-.5504428500000003,y:-.021272154587890446},right1:{x:.5504428500000005,y:-.026521254587889898}},bounds:{minX:-.5786012910000002,maxX:.5786012910000005,minY:-.22997364541210996,maxY:.22997364541210996,width:1.1572025820000007,height:.4599472908242199,centerX:11102230246251565e-32,centerY:0},circles:{}},{paths:IBe,texts:Soe,bounds:FR,refblocks:Eoe,circles:kBe}=FBe,IF=am({primitives:[...Object.values(IBe),...Object.values(kBe),{...Soe.top1,anchor:"middle_bottom"},{...Soe.bottom1,anchor:"middle_top"}],ports:[{...Eoe.left1,labels:["1"]},{...Eoe.right1,labels:["2"]}],size:{width:FR.width,height:FR.height},center:{x:FR.centerX,y:FR.centerY}}),woe=su(IF,"up"),BBe=OIe(woe),HBe=bF(IF),Toe={paths:{path11:{type:"path",points:[{x:-.5274831500000006,y:-.05991764999999982},{x:-.14891374999999996,y:-.06254064999999964}],color:"primary",fill:!1},path40:{type:"path",points:[{x:.13221874999999983,y:-.048856449999999496},{x:-.13236425000000063,y:-.18114814999999918}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.13236425000000063,y:.08343525000000018},{x:.13221874999999983,y:-.048856449999999496}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.13236425000000063,y:-.18114814999999984},{x:-.13236425000000063,y:.08343525000000018}],color:"primary",fill:!1},path43:{type:"path",points:[{x:.13221874999999983,y:.08343525000000018},{x:.13221874999999983,y:-.18114814999999984}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.13582535000000018,y:-.04942524999999942},{x:.533952450000001,y:-.059917649999999156}],color:"primary",fill:!1},"path25-0-9-8":{type:"path",points:[{x:-.02944535000000048,y:.39378525000000053},{x:-.05325954999999993,y:.4660362500000006},{x:-.07725114999999949,y:.39386225000000086}],color:"primary",fill:!0},"path78-6-5-5":{type:"path",points:[{x:-.05361965000000035,y:.27387525000000035},{x:-.053592050000000446,y:.2865022500000003},{x:-.05330205000000077,y:.41436425000000066},{x:-.05311205000000019,y:.4152642500000008}],color:"primary",fill:!1},"path25-0-9-8-2":{type:"path",points:[{x:.06865195000000024,y:.39378525000000053},{x:.044837750000000565,y:.4660362500000006},{x:.02084615000000123,y:.39386225000000086}],color:"primary",fill:!0},"path78-6-5-5-7":{type:"path",points:[{x:.044477650000000146,y:.27387525000000035},{x:.044505250000000274,y:.2865022500000003},{x:.04479524999999995,y:.41436425000000066},{x:.04498525000000053,y:.4152642500000008}],color:"primary",fill:!1},"path43-1":{type:"path",points:[{x:.03124844999999965,y:.05895145000000013},{x:.03124844999999965,y:-.16452955000000036}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:.25206924999999947,y:.3769550499999994},bottom1:{type:"text",text:"{VAL}",x:-.006614550000000552,y:-.4660362500000004}},refblocks:{left1:{x:-.54139845,y:-.060770450000000364},right1:{x:.5413984499999995,y:-.0597740500000008}},bounds:{minX:-.569556891,maxX:.5695568909999995,minY:-.4660362500000004,maxY:.4660362500000006,width:1.1391137819999995,height:.932072500000001,centerX:-2220446049250313e-31,centerY:11102230246251565e-32},circles:{path1:{type:"circle",x:-.0037626500000003116,y:-.05278935000000051,radius:.28854213,color:"primary",fill:!1}}};Toe.bounds.width+=.2;var Moe=kh(Toe).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),Coe=su(Moe),VBe=Coe.primitives.filter(r=>r.type==="text"),Roe=VBe.find(r=>r.text==="{VAL}");Roe.x=-.52,Roe.anchor="middle_right";var jBe=Coe,GBe={paths:{path45:{type:"path",points:[{x:.13585750000000063,y:-.003696399999999045},{x:-.12872579999999934,y:-.13598810000000228}],color:"primary",fill:!1},"path1-8":{type:"path",points:[{x:.12763670000000094,y:-.003920199999999596},{x:.5265564000000009,y:-.003920199999999596}],color:"primary",fill:!1},path46:{type:"path",points:[{x:-.12872579999999934,y:.12859530000000063},{x:.13585750000000063,y:-.003696399999999045}],color:"primary",fill:!1},path47:{type:"path",points:[{x:-.12872579999999934,y:-.13598810000000228},{x:-.12872579999999934,y:.12859530000000063}],color:"primary",fill:!1},path48:{type:"path",points:[{x:.13585750000000063,y:.12859530000000063},{x:.13585750000000063,y:-.13598810000000228}],color:"primary",fill:!1},path49:{type:"path",points:[{x:-.13076959999999938,y:-.003696399999999045},{x:-.5256007999999994,y:-.003696399999999045}],color:"primary",fill:!1},path25:{type:"path",points:[{x:-.1557438999999996,y:.28545279999999806},{x:-.2530861999999994,y:.3023319999999998},{x:-.21878339999999952,y:.20956920000000068}],color:"primary",fill:!0},path78:{type:"path",points:[{x:-.08000449999999937,y:.16590799999999817},{x:-.09202799999999911,y:.1748410000000007},{x:-.2137844999999996,y:.26529680000000155},{x:-.2144144999999993,y:.2662468000000011}],color:"primary",fill:!1},"path25-0":{type:"path",points:[{x:.021722400000000697,y:.30658939999999646},{x:-.07561989999999952,y:.3234685999999982},{x:-.04131709999999922,y:.23070579999999907}],color:"primary",fill:!0},"path78-6":{type:"path",points:[{x:.09746180000000093,y:.18704459999999656},{x:.08543830000000074,y:.19597759999999909},{x:-.0363181999999993,y:.28643339999999995},{x:-.03694819999999943,y:.2873833999999995}],color:"primary",fill:!1}},texts:{bottom1:{type:"text",text:"{VAL}",x:-.009561699999999451,y:-.3234685999999982},right1:{type:"text",text:"{REF}",x:.31464070000000044,y:.22386570000000106}},refblocks:{left1:{x:-.5362092999999997,y:-.004432900000001183},right1:{x:.5362093000000003,y:-.004886400000003732}},bounds:{minX:-.5643677409999996,maxX:.5643677410000003,minY:-.3234685999999982,maxY:.3234685999999982,width:1.128735482,height:.6469371999999964,centerX:33306690738754696e-32,centerY:0},circles:{}},{paths:qBe,texts:Aoe,bounds:IR,refblocks:Doe,circles:YBe}=GBe,kR=am({primitives:[...Object.values(qBe),...Object.values(YBe),{...Aoe.bottom1,anchor:"middle_top"},{...Aoe.right1,anchor:"middle_bottom"}],ports:[{...Doe.left1,labels:["1"]},{...Doe.right1,labels:["2"]}],size:{width:IR.width,height:IR.height},center:{x:IR.centerX,y:IR.centerY}}),XBe=su(kR,"down"),WBe=bF(kR),kF=su(kR,"up"),$Be={...kF,primitives:kF.primitives.map(r=>r.type==="path"&&(r.points.length===3||r.points.length===4)?{...r,points:r.points.map(e=>({x:e.x,y:-e.y+2*kF.center.y}))}:r)},ZBe=$Be,QBe={paths:{path11:{type:"path",points:[{x:-.5053201665812097,y:-.010839730805804138},{x:-.1829962316128657,y:-.010839730805804138}],color:"primary",fill:!1},"path11-2":{type:"path",points:[{x:-.1674747072814866,y:-.11471502212593476},{x:-.1674747072814866,y:.07736981415388478}],color:"primary",fill:!1},"path11-5":{type:"path",points:[{x:-.1674747072814866,y:-.11632056223474518},{x:.16018133830019532,y:-.11632056223474518}],color:"primary",fill:!1},"path11-5-5":{type:"path",points:[{x:-.1674747072814866,y:.07736981415388478},{x:.16018133830019532,y:.07736981415388478}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.17205869804197382,y:-.010839950577224311},{x:.5116721586832798,y:-.010839950577224311}],color:"primary",fill:!1},"path11-2-1":{type:"path",points:[{x:.16064490317338742,y:-.11622177498145403},{x:.16064490317338742,y:.07727135655772521}],color:"primary",fill:!1},"path25-0-9":{type:"path",points:[{x:-.40391896081308554,y:-.2111951150487743},{x:-.32538818309991635,y:-.1776462385858042},{x:-.33843942905204627,y:-.26928059146906413}],color:"primary",fill:!0},"path78-6-5":{type:"path",points:[{x:-.4470989190253618,y:-.3351265263866847},{x:-.4385525777085817,y:-.32468848279378437},{x:-.3520048317368336,y:-.21897414423109507},{x:-.3516268465799328,y:-.21798517284109487}],color:"primary",fill:!1},"path25-0-9-0":{type:"path",points:[{x:-.30220674110432255,y:-.3403193953841548},{x:-.22367596339115314,y:-.30677051892118534},{x:-.23672720934328306,y:-.3984048718044453}],color:"primary",fill:!0},"path78-6-5-9":{type:"path",points:[{x:-.3453866993165988,y:-.464250806722065},{x:-.3368403579998187,y:-.45381276312916397},{x:-.2502926120280704,y:-.34809842456647466},{x:-.24991462687116983,y:-.34710945317647446}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.1679477702432366,y:-.40859918889256375},bottom1:{type:"text",text:"{VAL}",x:-.006410773639930811,y:.464250806722065}},refblocks:{left1:{x:-.5247194309452994,y:-.009902515585214156},right1:{x:.5247194309452992,y:-.010997416799653603}},bounds:{minX:-.5520103866874645,maxX:.5520103866874643,minY:-.5085991888925637,maxY:.464250806722065,width:1.1040207733749288,height:.6228499956146287,centerX:-11102230246251565e-32,centerY:-.022174191085249373},circles:{path1:{type:"circle",x:-.003646732950281173,y:-.018672603986024328,radius:.2796529289238723,color:"primary",fill:!1}}},{paths:KBe,texts:Poe,bounds:BR,refblocks:Noe,circles:JBe}=QBe,Loe=am({primitives:[...Object.values(KBe),...Object.values(JBe),{...Poe.top1,anchor:"middle_left",x:0},{...Poe.bottom1,anchor:"middle_left",x:0}],ports:[{...Noe.left1,labels:["1"]},{...Noe.right1,labels:["2"]}],size:{width:BR.width,height:BR.height},center:{x:BR.centerX,y:BR.centerY}}),Ooe=su(Loe),Uoe=Ooe.primitives.filter(r=>r.type==="text"),BF=Uoe.find(r=>r.text==="{VAL}");BF.x=-.35,BF.y=0,BF.anchor="middle_right";var HF=Uoe.find(r=>r.text==="{REF}");HF.y=0,HF.x=.35,HF.anchor="middle_left";var eHe=Ooe,tHe={paths:{path208:{type:"path",points:[{x:.3843021704999998,y:.13154093999999894},{x:.5165938705000004,y:-.13304206000000107}],color:"primary",fill:!1},path209:{type:"path",points:[{x:.25201047050000014,y:-.13304206000000107},{x:.3843021704999998,y:.13154093999999894}],color:"primary",fill:!1},path210:{type:"path",points:[{x:.5165938705000004,y:-.13304206000000107},{x:.25201047050000014,y:-.13304206000000107}],color:"primary",fill:!1},path211:{type:"path",points:[{x:.25201047050000014,y:.13154093999999894},{x:.5165938705000004,y:.13154093999999894}],color:"primary",fill:!1},path212:{type:"path",points:[{x:.11971887050000074,y:-.39762406000000006},{x:.3843021704999998,y:-.39762406000000006}],color:"primary",fill:!1},path213:{type:"path",points:[{x:.3843021704999998,y:.39612494},{x:.11971887050000074,y:.39612494}],color:"primary",fill:!1},path214:{type:"path",points:[{x:.11971887050000074,y:.5284169399999996},{x:.11971887050000074,y:.18445994}],color:"primary",fill:!1},path215:{type:"path",points:[{x:.11971887050000074,y:-.5299150600000004},{x:.11971887050000074,y:-.0007480600000011606}],color:"primary",fill:!1},path216:{type:"path",points:[{x:.3843021704999998,y:-.39762469000000067},{x:.3843021704999998,y:.3961256399999993}],color:"primary",fill:!1},path217:{type:"path",points:[{x:-.1448644295000001,y:.2638359399999999},{x:-.1448644295000001,y:-.26533006000000015}],color:"primary",fill:!1},path218:{type:"path",points:[{x:-.22423942949999898,y:-.2653310599999994},{x:-.22423942949999898,y:.26383493999999885}],color:"primary",fill:!1},path219:{type:"path",points:[{x:-.5417394294999998,y:-.26533006000000015},{x:-.22423942949999898,y:-.2653320600000004}],color:"primary",fill:!1},path220:{type:"path",points:[{x:-.1448644295000001,y:-.18595506000000128},{x:.11971897050000013,y:-.18595506000000128}],color:"primary",fill:!1},path221:{type:"path",points:[{x:-.1448644295000001,y:.18446093999999924},{x:.11971897050000013,y:.18446093999999924}],color:"primary",fill:!1},path222:{type:"path",points:[{x:-.06548942950000036,y:-.0007480600000011606},{x:.11971887050000074,y:-.0007480600000011606}],color:"primary",fill:!1}},texts:{right1:{type:"text",text:"{VAL}",x:.5715500704999998,y:.02044358999999929},right2:{type:"text",text:"{REF}",x:.5701646705000005,y:.2085436499999993}},refblocks:{top1:{x:.12018067049999992,y:.5432738300000004},bottom1:{x:.11982247050000083,y:-.5432738300000004},left1:{x:-.5433916295000003,y:-.2663988600000007}},bounds:{minX:-.5715500705000003,maxX:.5715500704999998,minY:-.5714322710000004,maxY:.5714322710000004,width:1.1431001410000001,height:1.1428645420000008,centerX:-2220446049250313e-31,centerY:0},circles:{}},{paths:nHe,texts:zoe,bounds:HR,refblocks:VF}=tHe,Foe=am({primitives:[...Object.values(nHe),{...zoe.right1,anchor:"middle_left"},{...zoe.right2,anchor:"middle_left"}],ports:[{...VF.top1,labels:["1"]},{...VF.bottom1,labels:["2"]},{...VF.left1,labels:["3"]}],size:{width:HR.width+.4,height:HR.height},center:{x:HR.centerX+.2,y:HR.centerY}}),jF=su(Foe),Ioe=jF.primitives.find(r=>r.type==="text"&&r.text==="{REF}"),GF=jF.primitives.find(r=>r.type==="text"&&r.text==="{VAL}");Ioe.anchor="middle_top",GF.anchor="middle_top",Ioe.x=GF.x,GF.y+=.15;var rHe=jF,iHe={paths:{"path12-1-8-6-9":{type:"path",points:[{x:.005962250000000502,y:.06921149999999976},{x:.005962250000000502,y:-.005086499999999106}],color:"primary",fill:!1},"path12-1-5-6":{type:"path",points:[{x:-.48740705000000073,y:-.09299450000000142},{x:-.17310075000000058,y:-.09299450000000142}],color:"primary",fill:!1},"path12-1-8-0":{type:"path",points:[{x:-.16008695000000017,y:-.010660500000000184},{x:.1719709499999995,y:-.010660500000000184}],color:"primary",fill:!1},"path12-1-0":{type:"path",points:[{x:.1954987499999996,y:-.09260549999999945},{x:.4881436499999996,y:-.09260549999999945}],color:"primary",fill:!1},path2:{type:"path",points:[{x:-.09950044999999985,y:.05839450000000035},{x:-.09950104999999976,y:.06197449999999982},{x:-.09932044999999956,y:.06550449999999941},{x:-.09896044999999987,y:.0690104999999992},{x:-.09860045000000017,y:.07250049999999852},{x:-.09806045000000019,y:.07593049999999835},{x:-.09735344999999995,y:.07929949999999941},{x:-.09663345000000056,y:.08265950000000011},{x:-.09578045000000035,y:.08599949999999978},{x:-.09475245000000054,y:.08924949999999932},{x:-.09379245000000047,y:.09255949999999835},{x:-.09254545000000025,y:.09567949999999925},{x:-.09120844999999989,y:.09877950000000091},{x:-.08986644999999971,y:.10186950000000117},{x:-.08839545000000015,y:.10492949999999901},{x:-.08675845000000049,y:.10783949999999898},{x:-.08506245000000057,y:.11069950000000084},{x:-.08334244999999996,y:.11360950000000081},{x:-.08146945000000017,y:.11638949999999859},{x:-.0795824500000002,y:.11916949999999993},{x:-.07752845000000086,y:.12180949999999946},{x:-.07546944999999994,y:.12442949999999975},{x:-.07325945000000011,y:.12693950000000065},{x:-.07104145000000006,y:.129449499999998},{x:-.06867544999999975,y:.13182950000000027},{x:-.06628845000000005,y:.1341695000000005},{x:-.06379544999999975,y:.1364194999999988},{x:-.06114145000000004,y:.13848950000000038},{x:-.05848745000000033,y:.1405694999999998},{x:-.05584345000000024,y:.14261950000000034},{x:-.05306845000000049,y:.14449950000000022},{x:-.05029345000000074,y:.14639950000000113},{x:-.04738844999999969,y:.14811950000000174},{x:-.04437445000000029,y:.14969949999999876},{x:-.04134744999999995,y:.1513194999999996},{x:-.038316449999999946,y:.15275949999999838},{x:-.03515645000000056,y:.15407949999999992},{x:-.03204444999999989,y:.15536950000000083},{x:-.028770450000000558,y:.15655950000000018},{x:-.025468450000000864,y:.15757949999999887},{x:-.02213745000000067,y:.15863950000000138},{x:-.018790450000000014,y:.15942949999999811},{x:-.01536325000000005,y:.16012949999999826},{x:-.011980249999999693,y:.16082950000000018},{x:-.008442250000000762,y:.16141949999999916},{x:-.004890650000000107,y:.1617494999999991},{x:-.0013406500000003874,y:.16204949999999663},{x:.002252350000000014,y:.16214949999999817},{x:.005893849999999645,y:.16214949999999817},{x:.009534849999998762,y:.16214949999999817},{x:.013136849999999534,y:.16204949999999663},{x:.016683149999999536,y:.1617494999999991},{x:.020231149999998976,y:.1614494999999998},{x:.023727149999999142,y:.16104949999999896},{x:.02715474999999934,y:.16012949999999826},{x:.03057874999999921,y:.15952949999999966},{x:.03395574999999962,y:.15867949999999986},{x:.03725995000000015,y:.15758950000000027},{x:.0405679499999998,y:.15652949999999954},{x:.04379994999999948,y:.15541949999999893},{x:.04695294999999966,y:.15409950000000094},{x:.050101949999999285,y:.15280950000000004},{x:.053191949999999544,y:.1513194999999996},{x:.05617794999999948,y:.1497395000000008},{x:.05916694999999983,y:.14811950000000174},{x:.06206694999999929,y:.14639950000000113},{x:.06487294999999982,y:.1445595000000015},{x:.06767095000000012,y:.14269950000000264},{x:.07038294999999994,y:.14069950000000198},{x:.07299194999999958,y:.1385795000000023},{x:.07560095000000011,y:.13645950000000262},{x:.07809294999999938,y:.13420950000000254},{x:.08047994999999997,y:.13187950000000193},{x:.08287894999999956,y:.1295395000000017},{x:.08515495000000062,y:.12706950000000106},{x:.08729294999999926,y:.12451950000000167},{x:.08944594999999911,y:.12192950000000202},{x:.0914679499999993,y:.11930950000000173},{x:.09337295000000001,y:.1165295000000004},{x:.0971669499999992,y:.11101949999999938},{x:.10043494999999947,y:.10512450000000229},{x:.10311494999999926,y:.09890950000000132},{x:.10444094999999987,y:.09581950000000106},{x:.10564094999999973,y:.09262950000000103},{x:.10667494999999949,y:.08935950000000226},{x:.10769994999999977,y:.08610950000000273},{x:.1085699499999997,y:.08279950000000369},{x:.10927795000000007,y:.07942950000000337},{x:.10999794999999946,y:.07605950000000128},{x:.11051994999999959,y:.07262950000000146},{x:.11088394999999984,y:.06913950000000213},{x:.11124394999999954,y:.0656495000000028},{x:.11142394999999983,y:.062099500000002195},{x:.11142394999999983,y:.05854350000000075},{x:.10483595000000001,y:.05853049999999982},{x:.0982479500000002,y:.058516500000001415},{x:.09164495000000006,y:.058518500000001694},{x:.08505695000000024,y:.05850850000000207},{x:.078453950000001,y:.058509500000001324},{x:.07186595000000029,y:.058496500000000395},{x:.06526295000000104,y:.05849750000000142},{x:.058674950000001225,y:.058485499999999746},{x:.05208695000000052,y:.058473499999999845},{x:.04548395000000127,y:.058475500000000125},{x:.038895950000001456,y:.05846150000000172},{x:.03230795000000075,y:.058448499999999015},{x:.025704950000001503,y:.058453499999998826},{x:.019101950000001366,y:.05845449999999808},{x:.01251395000000155,y:.05844149999999715},{x:.005925950000001734,y:.058427499999998744},{x:-.0006560499999990199,y:.05842149999999968},{x:-.007240049999999165,y:.05841449999999959},{x:-.01382404999999931,y:.05840850000000053},{x:-.020406049999999176,y:.05840250000000147},{x:-.02699004999999932,y:.058394500000002125},{x:-.03357404999999947,y:.05838950000000409},{x:-.04015604999999933,y:.05838350000000503},{x:-.04674004999999948,y:.05837450000000466},{x:-.05332205000000023,y:.058368500000005596},{x:-.05990605000000038,y:.058360500000006255},{x:-.06649005000000052,y:.058355500000006444},{x:-.07307205000000039,y:.05834950000000738},{x:-.07965605000000053,y:.05834150000000804},{x:-.08624005000000068,y:.05833550000000898},{x:-.09282205000000143,y:.05833050000001094}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:.01254745000000046,y:.26612850000000243},bottom1:{type:"text",text:"{VAL}",x:-.16130964999999975,y:-.2661284999999989}},refblocks:{left1:{x:-.4717985499999999,y:-.09296750000000031},right1:{x:.4717985499999999,y:-.09299249999999937}},bounds:{minX:-.4999569909999999,maxX:.4999569909999999,minY:-.2661284999999989,maxY:.26612850000000243,width:.9999139819999998,height:.5322570000000013,centerX:0,centerY:17763568394002505e-31},circles:{}},{paths:aHe,texts:koe,bounds:VR,refblocks:Boe,circles:oHe}=iHe,Hoe=am({primitives:[...Object.values(aHe),...Object.values(oHe),{...koe.top1,anchor:"middle_bottom",x:0},{...koe.bottom1,anchor:"middle_top",x:0}],ports:[{...Boe.left1,labels:["1"]},{...Boe.right1,labels:["2"]}],size:{width:VR.width,height:VR.height},center:{x:VR.centerX+.006,y:VR.centerY+.06}}),qF=su(Hoe),vT=qF.primitives.find(r=>r.type==="text"&&r.text==="{REF}"),jR=qF.primitives.find(r=>r.type==="text"&&r.text==="{VAL}");vT.anchor="middle_left",jR.anchor="middle_right",vT.x=vT.x-.03,vT.y=vT.y,jR.x=jR.x,jR.y=0;var sHe=qF,lHe={paths:{path11:{type:"path",points:[{x:-.39274354450000026,y:-.10329954999999957},{x:.05111245549999932,y:-.1059225499999994}],color:"primary",fill:!1},path40:{type:"path",points:[{x:.09373835550000087,y:.18559775000000034},{x:.09280835550000122,y:-.18255174999999935}],color:"primary",fill:!1},"path12-1":{type:"path",points:[{x:.30382435550000064,y:.53233025},{x:.3032243555000005,y:.10600584999999985}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:.3108281555000003,y:-.5323308500000001},{x:.31142815550000025,y:-.005876249999999805}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.09383795549999951,y:.10788365000000044},{x:.31104975549999936,y:.10659565000000004}],color:"primary",fill:!1},"path2-5":{type:"path",points:[{x:.09383795549999951,y:-.10232114999999986},{x:.31104975549999936,y:-.10360915000000026}],color:"primary",fill:!1},path15:{type:"path",points:[{x:.27419885550000034,y:-.04077644999999963},{x:.27419885550000034,y:.030615650000000327},{x:.2024438555000001,y:-.004662050000000084},{x:.27419885550000034,y:-.04077644999999963}],color:"primary",fill:!0},"path2-0":{type:"path",points:[{x:.09383795549999951,y:-.004018049999999551},{x:.31104975549999936,y:-.005306049999999729}],color:"primary",fill:!1},"path12-1-0":{type:"path",points:[{x:.05171245550000081,y:.16715385000000005},{x:.05111245550000065,y:-.10592255000000006}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.13197254449999907,y:.36092494999999936},bottom1:{type:"text",text:"{VAL}",x:.05891105550000031,y:-.42489435000000064}},refblocks:{top1:{x:.30397715549999993,y:.5519248499999992},bottom1:{x:.31067575550000126,y:-.5519248499999994},left1:{x:-.41859744450000025,y:-.10250625000000024}},bounds:{minX:-.4467558855000002,maxX:.44675588550000006,minY:-.5800832909999993,maxY:.5800832909999992,width:.8935117710000002,height:1.1601665819999987,centerX:-8326672684688674e-32,centerY:-5551115123125783e-32},circles:{path1:{type:"circle",x:.15821375550000005,y:.003454549999999612,radius:.28854213,color:"primary",fill:!1}}},{paths:cHe,texts:Voe,bounds:GR,refblocks:YF,circles:uHe}=lHe,joe=am({primitives:[...Object.values(cHe),...Object.values(uHe),{...Voe.top1,anchor:"middle_right",x:0},{...Voe.bottom1,anchor:"middle_right",x:0}],ports:[{...YF.top1,labels:["1","drain"]},{...YF.bottom1,labels:["2","source"]},{...YF.left1,labels:["3","gate"]}],size:{width:GR.width,height:GR.height},center:{x:GR.centerX,y:GR.centerY}}),Goe=su(joe),qoe=Goe.primitives.filter(r=>r.type==="text"),XF=qoe.find(r=>r.text==="{VAL}");XF.x=-.35,XF.y=0,XF.anchor="middle_right";var WF=qoe.find(r=>r.text==="{REF}");WF.y=0,WF.x=.35,WF.anchor="middle_left";var fHe=Goe,dHe={paths:{path11:{type:"path",points:[{x:-.39274354450000026,y:-.10329954999999957},{x:.05111245549999932,y:-.1059225499999994}],color:"primary",fill:!1},"path12-1":{type:"path",points:[{x:.30382435550000064,y:.53233025},{x:.3032243555000005,y:.10600584999999985}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:.3108281555000003,y:-.5323308500000001},{x:.31142815550000025,y:-.005876249999999805}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.09383795549999951,y:.10788365000000044},{x:.31104975549999936,y:.10659565000000004}],color:"primary",fill:!1},"path2-8-3-7":{type:"path",points:[{x:.09448295549999952,y:.14677165000000048},{x:.09319295549999951,y:.06899565000000041}],color:"primary",fill:!1},"path2-5":{type:"path",points:[{x:.09383795549999951,y:-.10232114999999986},{x:.31104975549999936,y:-.10360915000000026}],color:"primary",fill:!1},"path2-8-3":{type:"path",points:[{x:.09440455549999993,y:-.07703174999999951},{x:.09311455549999992,y:-.15480774999999958}],color:"primary",fill:!1},"path2-8-3-2":{type:"path",points:[{x:.09448295549999952,y:.03486995000000048},{x:.09319295549999951,y:-.042906049999999585}],color:"primary",fill:!1},path15:{type:"path",points:[{x:.2741991554999996,y:-.040776550000000134},{x:.2741991554999996,y:.030615549999999825},{x:.2024441554999994,y:-.004662350000000037},{x:.2741991554999996,y:-.040776550000000134}],color:"primary",fill:!0},"path2-0":{type:"path",points:[{x:.09383795549999951,y:-.004018049999999551},{x:.31104975549999936,y:-.005306049999999729}],color:"primary",fill:!1},"path12-1-0":{type:"path",points:[{x:.05171245550000081,y:.10847375000000059},{x:.05111245550000065,y:-.1059225499999994}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.13197254449999907,y:.36092494999999936},bottom1:{type:"text",text:"{VAL}",x:.05891105550000031,y:-.42489435000000064}},refblocks:{top1:{x:.30397715549999993,y:.5519248499999992},bottom1:{x:.31067575550000126,y:-.5519248499999994},left1:{x:-.41859744450000025,y:-.10250625000000024}},bounds:{minX:-.4467558855000002,maxX:.44675588550000006,minY:-.5800832909999993,maxY:.5800832909999992,width:.8935117710000002,height:1.1601665819999987,centerX:-8326672684688674e-32,centerY:-5551115123125783e-32},circles:{path1:{type:"circle",x:.15821375550000005,y:.003454549999999612,radius:.28854213,color:"primary",fill:!1}}},{paths:hHe,texts:Yoe,bounds:qR,refblocks:$F,circles:pHe}=dHe,Xoe=am({primitives:[...Object.values(hHe),...Object.values(pHe),{...Yoe.top1,anchor:"middle_right",x:0},{...Yoe.bottom1,anchor:"middle_right",x:0}],ports:[{...$F.top1,labels:["1","drain"]},{...$F.bottom1,labels:["2","source"]},{...$F.left1,labels:["3","gate"]}],size:{width:qR.width,height:qR.height},center:{x:qR.centerX,y:qR.centerY}}),Woe=su(Xoe),$oe=Woe.primitives.filter(r=>r.type==="text"),ZF=$oe.find(r=>r.text==="{VAL}");ZF.x=-.35,ZF.y=0,ZF.anchor="middle_right";var QF=$oe.find(r=>r.text==="{REF}");QF.y=0,QF.x=.35,QF.anchor="middle_left";var mHe=Woe,vHe={paths:{path11:{type:"path",points:[{x:-.38509374449999945,y:-.00367374999999992},{x:.05876225550000025,y:-.00629674999999974}],color:"primary",fill:!1},path40:{type:"path",points:[{x:.07415065550000066,y:.18559775000000034},{x:.07322065550000101,y:-.18255174999999935}],color:"primary",fill:!1},"path12-1":{type:"path",points:[{x:.28423665550000043,y:.53233025},{x:.2836366555000003,y:.10600584999999985}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:.2912404555000001,y:-.5298821500000002},{x:.29184045550000004,y:-.10355795000000012}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.07425025549999931,y:.10788365000000044},{x:.29146205549999915,y:.10659565000000004}],color:"primary",fill:!1},"path2-5":{type:"path",points:[{x:.07425025549999931,y:-.10232114999999986},{x:.29146205549999915,y:-.10360915000000026}],color:"primary",fill:!1},path15:{type:"path",points:[{x:-.0829488445000004,y:.06153284999999986},{x:-.0829488445000004,y:-.06535114999999969},{x:.005945155500000077,y:-.0026521499999998532},{x:-.0829488445000004,y:.06153284999999986}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:-.15156024449999927,y:.36092494999999936},bottom1:{type:"text",text:"{VAL}",x:.0393233555000001,y:-.42489435000000064}},refblocks:{top1:{x:.2843894554999997,y:.5519248499999992},bottom1:{x:.29108805550000105,y:-.5519248499999994},left1:{x:-.3990097444999998,y:-.004526550000000462}},bounds:{minX:-.4271681854999998,maxX:.42716818549999985,minY:-.5800832909999993,maxY:.5800832909999992,width:.8543363709999996,height:1.1601665819999987,centerX:27755575615628914e-33,centerY:-5551115123125783e-32},circles:{path1:{type:"circle",x:.13862605549999985,y:.003454549999999612,radius:.28854213,color:"primary",fill:!1}}},{paths:yHe,texts:Zoe,bounds:YR,refblocks:KF,circles:gHe}=vHe,Qoe=am({primitives:[...Object.values(yHe),...Object.values(gHe),{...Zoe.top1,anchor:"middle_right",x:0},{...Zoe.bottom1,anchor:"middle_right",x:0}],ports:[{...KF.top1,labels:["1","drain"]},{...KF.bottom1,labels:["2","source"]},{...KF.left1,labels:["3","gate"]}],size:{width:YR.width,height:YR.height},center:{x:YR.centerX,y:YR.centerY}}),Koe=su(Qoe),Joe=Koe.primitives.filter(r=>r.type==="text"),JF=Joe.find(r=>r.text==="{VAL}");JF.x=-.35,JF.y=0,JF.anchor="middle_right";var eI=Joe.find(r=>r.text==="{REF}");eI.y=0,eI.x=.35,eI.anchor="middle_left";var _He=Koe,ese={paths:{path11:{type:"path",points:[{x:-.3850939444999988,y:-.0036735999999999436},{x:.0587620555000008,y:-.0062965999999997635}],color:"primary",fill:!1},"path40-0":{type:"path",points:[{x:.07400475550000118,y:.2689528999999997},{x:.07335475550000092,y:-.2789230000000007}],color:"primary",fill:!1},"path40-0-5":{type:"path",points:[{x:.2754149555000005,y:.24180210000000013},{x:.07955815550000045,y:.10822479999999968}],color:"primary",fill:!1},"path40-0-5-0":{type:"path",points:[{x:.2868554555000009,y:-.24134789999999984},{x:.09194705550000082,y:-.10807689999999992}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:.2851204555,y:.25311099999999964},{x:.2860204555000001,y:.5377640999999995}],color:"primary",fill:!1},"path12-1-5-3":{type:"path",points:[{x:.2851204555,y:-.5376890000000012},{x:.2860204555000001,y:-.25303590000000065}],color:"primary",fill:!1},path15:{type:"path",points:[{x:.1882816555000013,y:-.10097660000000008},{x:.11555775550000158,y:-.20483720000000027},{x:.22425775550000182,y:-.20446720000000007},{x:.1882816555000013,y:-.10097660000000008}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:-.07802354449999971,y:.3596647999999991},bottom1:{type:"text",text:"{VAL}",x:-.0679100444999996,y:-.4129789000000006}},refblocks:{top1:{x:.28556045550000064,y:.5519250999999994},bottom1:{x:.285560455500002,y:-.5519250999999992},left1:{x:-.3990097444999998,y:-.004526300000000871}},bounds:{minX:-.4271681854999998,maxX:.4271681855000001,minY:-.5800835409999991,maxY:.5800835409999994,width:.8543363709999998,height:1.1601670819999985,centerX:13877787807814457e-32,centerY:11102230246251565e-32},circles:{"path1-0":{type:"circle",x:.13862605550000007,y:.003454799999999203,radius:.28854213,color:"primary",fill:!1}}},tse=kh(ese).changeTextAnchor("{VAL}","middle_right").labelPort("left1",["3"]).labelPort("top1",["2"]).labelPort("bottom1",["1"]).changeTextAnchor("{REF}","middle_right").build(),xHe=su(tse),bHe=xHe.primitives.filter(r=>r.type==="text"),SHe=bHe.find(r=>r.text==="{REF}");SHe.anchor="middle_left";var EHe=kh(ese).rotateRightFacingSymbol("down").changeTextAnchor("{VAL}","middle_right").labelPort("left1",["3"]).labelPort("top1",["2"]).labelPort("bottom1",["1"]).changeTextAnchor("{REF}","middle_left").build(),wHe={paths:{path40:{type:"path",points:[{x:.14458890000000002,y:.0390362999999998},{x:-.3199943999999995,y:-.21132800000000015}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.3199943999999995,y:.31132800000000016},{x:.14458890000000002,y:.0390362999999998}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.3199943999999995,y:-.21132800000000015},{x:-.3199943999999995,y:.31132800000000016}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.3199943999999995,y:.1790362999999998},{x:-.58168694,y:.1790362999999998}],color:"primary",fill:!1},path45:{type:"path",points:[{x:-.3199943999999995,y:-.0890362999999998},{x:-.58168694,y:-.0890362999999998}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.4233797000000002,y:.03895110000000024},{x:.1496715999999998,y:.03895110000000024}],color:"primary",fill:!1},"rect1577-3":{type:"path",points:[{x:-.19898460000000012,y:.1790362999999998},{x:-.26995180000000035,y:.1790362999999998}],color:"primary",fill:!0},"rect1577-4":{type:"path",points:[{x:-.19898460000000012,y:-.0890362999999998},{x:-.26995180000000035,y:-.0890362999999998}],color:"primary",fill:!0},"rect1577-4-7":{type:"path",points:[{x:-.23480170000000036,y:-.05337805000000034},{x:-.23480170000000036,y:-.12434525000000014}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:-.0050250999999996715,y:.4188453},bottom1:{type:"text",text:"{VAL}",x:-.00011179999999977319,y:-.29994529999999997}},refblocks:{left1:{x:-.56868694,y:.1790362999999998},left2:{x:-.56868694,y:-.0890362999999998},right1:{x:.4291470999999999,y:.03889609999999988}},bounds:{minX:-.5473055410000001,maxX:.5473055409999998,minY:-.37884529999999994,maxY:.26884529999999995,width:1.094611082,height:.2976905999999999,centerX:-11102230246251565e-32,centerY:.05499999999999999},circles:{}},XR=kh(wHe).labelPort("left1",["1","inp1"]).labelPort("left2",["2","inp2"]).labelPort("right1",["3","out"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),THe=su(XR,"down"),MHe=su(XR,"left"),CHe=su(XR,"up"),RHe={paths:{path40:{type:"path",points:[{x:.14458890000000002,y:.0390362999999998},{x:-.3199943999999995,y:-.21132800000000015}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.3199943999999995,y:.31132800000000016},{x:.14458890000000002,y:.0390362999999998}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.3199943999999995,y:-.21132800000000015},{x:-.3199943999999995,y:.31132800000000016}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.3199943999999995,y:.1790362999999998},{x:-.58168694,y:.1790362999999998}],color:"primary",fill:!1},path45:{type:"path",points:[{x:-.3199943999999995,y:-.0890362999999998},{x:-.58168694,y:-.0890362999999998}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.4233797000000002,y:.03895110000000024},{x:.1496715999999998,y:.03895110000000024}],color:"primary",fill:!1},"path44-1":{type:"path",points:[{x:-.09945180000000035,y:.43895110000000026},{x:-.09945180000000035,y:.1790362999999998}],color:"primary",fill:!1},"path44-2":{type:"path",points:[{x:-.09345180000000035,y:-.3389511000000002},{x:-.09345180000000035,y:-.0890362999999998}],color:"primary",fill:!1},"rect1577-3":{type:"path",points:[{x:-.19898460000000012,y:.1790362999999998},{x:-.26995180000000035,y:.1790362999999998}],color:"primary",fill:!0},"rect1577-4":{type:"path",points:[{x:-.19898460000000012,y:-.0890362999999998},{x:-.26995180000000035,y:-.0890362999999998}],color:"primary",fill:!0},"rect1577-4-7":{type:"path",points:[{x:-.23485180000000036,y:.14405005000000035},{x:-.23485180000000036,y:.2150405000000014}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:.2502509999999967,y:.31884529999999994},bottom1:{type:"text",text:"{VAL}",x:.2502509999999967,y:-.23599529999999996}},refblocks:{left1:{x:-.56868694,y:.1790362999999998},left2:{x:-.56868694,y:-.0890362999999998},right1:{x:.4291470999999999,y:.03889609999999988},top2:{x:-.09945180000000035,y:.43895110000000026},bottom1:{x:-.09345180000000035,y:-.3389511000000002}},bounds:{minX:-.5473055410000001,maxX:.5473055409999998,minY:-.37884529999999994,maxY:.26884529999999995,width:1.094611082,height:.2976905999999999,centerX:-11102230246251565e-32,centerY:.05499999999999999},circles:{}},WR=kh(RHe).labelPort("left1",["1","inp1"]).labelPort("left2",["2","inp2"]).labelPort("right1",["3","out"]).labelPort("top2",["4","V+"]).labelPort("bottom1",["5","V-"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),AHe=su(WR,"down"),DHe=su(WR,"left"),PHe=su(WR,"up"),NHe={paths:{path11:{type:"path",points:[{x:-.39274354450000026,y:-.10329954999999957},{x:.05111245549999932,y:-.1059225499999994}],color:"primary",fill:!1},path40:{type:"path",points:[{x:.09373835550000087,y:.18559775000000034},{x:.09280835550000122,y:-.18255174999999935}],color:"primary",fill:!1},"path12-1":{type:"path",points:[{x:.30382435550000064,y:.53233025},{x:.3032243555000005,y:.10600584999999985}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:.3108281555000003,y:-.5323308500000001},{x:.31142815550000025,y:-.005876249999999805}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.09383795549999951,y:.10788365000000044},{x:.31104975549999936,y:.10659565000000004}],color:"primary",fill:!1},"path2-5":{type:"path",points:[{x:.09383795549999951,y:-.10232114999999986},{x:.31104975549999936,y:-.10360915000000026}],color:"primary",fill:!1},path15:{type:"path",points:[{x:.20244405549999955,y:.03061555000000049},{x:.20244405549999955,y:-.04077654999999947},{x:.2741990554999998,y:-.0054987499999992195},{x:.20244405549999955,y:.03061555000000049}],color:"primary",fill:!0},"path2-0":{type:"path",points:[{x:.09383795549999951,y:-.004018049999999551},{x:.31104975549999936,y:-.005306049999999729}],color:"primary",fill:!1},"path12-1-0":{type:"path",points:[{x:.05171245550000081,y:.16715385000000005},{x:.05111245550000065,y:-.10592255000000006}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.13197254449999907,y:.36092494999999936},bottom1:{type:"text",text:"{VAL}",x:.05891105550000031,y:-.42489435000000064}},refblocks:{top1:{x:.30397715549999993,y:.5519248499999992},bottom1:{x:.31067575550000126,y:-.5519248499999994},left1:{x:-.41859744450000025,y:-.10250625000000024}},bounds:{minX:-.4467558855000002,maxX:.44675588550000006,minY:-.5800832909999993,maxY:.5800832909999992,width:.8935117710000002,height:1.1601665819999987,centerX:-8326672684688674e-32,centerY:-5551115123125783e-32},circles:{path1:{type:"circle",x:.15821375550000005,y:.003454549999999612,radius:.28854213,color:"primary",fill:!1}}},{paths:LHe,texts:nse,bounds:$R,refblocks:tI,circles:OHe}=NHe,rse=am({primitives:[...Object.values(LHe),...Object.values(OHe),{...nse.top1,anchor:"middle_right",x:0},{...nse.bottom1,anchor:"middle_right",x:0}],ports:[{...tI.top1,labels:["1","drain"]},{...tI.bottom1,labels:["2","source"]},{...tI.left1,labels:["3","gate"]}],size:{width:$R.width,height:$R.height},center:{x:$R.centerX,y:$R.centerY}}),ise=su(rse),ase=ise.primitives.filter(r=>r.type==="text"),nI=ase.find(r=>r.text==="{VAL}");nI.x=-.35,nI.y=0,nI.anchor="middle_right";var rI=ase.find(r=>r.text==="{REF}");rI.y=0,rI.x=.35,rI.anchor="middle_left";var UHe=ise,zHe={paths:{path11:{type:"path",points:[{x:-.39274354450000026,y:-.10329954999999957},{x:.05111245549999932,y:-.1059225499999994}],color:"primary",fill:!1},"path12-1":{type:"path",points:[{x:.30382435550000064,y:.53233025},{x:.3032243555000005,y:.10600584999999985}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:.3108281555000003,y:-.5323308500000001},{x:.31142815550000025,y:-.005876249999999805}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.09383795549999951,y:.10788365000000044},{x:.31104975549999936,y:.10659565000000004}],color:"primary",fill:!1},"path2-8-3-7":{type:"path",points:[{x:.09448295549999952,y:.14677165000000048},{x:.09319295549999951,y:.06899565000000041}],color:"primary",fill:!1},"path2-5":{type:"path",points:[{x:.09383795549999951,y:-.10232114999999986},{x:.31104975549999936,y:-.10360915000000026}],color:"primary",fill:!1},"path2-8-3":{type:"path",points:[{x:.09440455549999993,y:-.07703174999999951},{x:.09311455549999992,y:-.15480774999999958}],color:"primary",fill:!1},"path2-8-3-2":{type:"path",points:[{x:.09448295549999952,y:.03486995000000048},{x:.09319295549999951,y:-.042906049999999585}],color:"primary",fill:!1},path15:{type:"path",points:[{x:.20244405549999955,y:.03061555000000049},{x:.20244405549999955,y:-.04077654999999947},{x:.2741990554999998,y:-.0054987499999992195},{x:.20244405549999955,y:.03061555000000049}],color:"primary",fill:!0},"path2-0":{type:"path",points:[{x:.09383795549999951,y:-.004018049999999551},{x:.31104975549999936,y:-.005306049999999729}],color:"primary",fill:!1},"path12-1-0":{type:"path",points:[{x:.05171245550000081,y:.10847375000000059},{x:.05111245550000065,y:-.1059225499999994}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.13197254449999907,y:.36092494999999936},bottom1:{type:"text",text:"{VAL}",x:.05891105550000031,y:-.42489435000000064}},refblocks:{top1:{x:.30397715549999993,y:.5519248499999992},bottom1:{x:.31067575550000126,y:-.5519248499999994},left1:{x:-.41859744450000025,y:-.10250625000000024}},bounds:{minX:-.4467558855000002,maxX:.44675588550000006,minY:-.5800832909999993,maxY:.5800832909999992,width:.8935117710000002,height:1.1601665819999987,centerX:-8326672684688674e-32,centerY:-5551115123125783e-32},circles:{path1:{type:"circle",x:.15821375550000005,y:.003454549999999612,radius:.28854213,color:"primary",fill:!1}}},{paths:FHe,texts:ose,bounds:ZR,refblocks:iI,circles:IHe}=zHe,sse=am({primitives:[...Object.values(FHe),...Object.values(IHe),{...ose.top1,anchor:"middle_right",x:0},{...ose.bottom1,anchor:"middle_right",x:0}],ports:[{...iI.top1,labels:["1","drain"]},{...iI.bottom1,labels:["2","source"]},{...iI.left1,labels:["3","gate"]}],size:{width:ZR.width,height:ZR.height},center:{x:ZR.centerX,y:ZR.centerY}}),lse=su(sse),cse=lse.primitives.filter(r=>r.type==="text"),aI=cse.find(r=>r.text==="{VAL}");aI.x=-.35,aI.y=0,aI.anchor="middle_right";var oI=cse.find(r=>r.text==="{REF}");oI.y=0,oI.x=.35,oI.anchor="middle_left";var kHe=lse,BHe={paths:{path11:{type:"path",points:[{x:-.5274831500000005,y:-.012413549999999773},{x:-.14891374999999973,y:-.015036549999999593}],color:"primary",fill:!1},path40:{type:"path",points:[{x:.13221874999999983,y:-.001352349999999447},{x:-.1323642500000004,y:-.13364404999999913}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.1323642500000004,y:.13093935000000023},{x:.13221874999999983,y:-.001352349999999447}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.1323642500000004,y:-.1336440499999998},{x:-.1323642500000004,y:.13093935000000023}],color:"primary",fill:!1},path43:{type:"path",points:[{x:.13221874999999983,y:.13093935000000023},{x:.13221874999999983,y:-.1336440499999998}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.1358253500000004,y:-.001921149999999372},{x:.533952450000001,y:-.012413549999999107}],color:"primary",fill:!1},"path25-0":{type:"path",points:[{x:.19839785000000076,y:.37576625000000075},{x:.16262485000000027,y:.28367475000000053},{x:.26033484999999956,y:.2989800500000006}],color:"primary",fill:!0},"path78-6":{type:"path",points:[{x:.3305468500000004,y:.4264014500000006},{x:.31941585000000017,y:.4163797500000006},{x:.20669285000000048,y:.3148875500000008},{x:.20564285000000115,y:.31448755000000084}],color:"primary",fill:!1},"path25-0-9":{type:"path",points:[{x:.34573984999999974,y:.3493283500000002},{x:.30996684999999946,y:.25723684999999996},{x:.40767644999999963,y:.27254215000000004}],color:"primary",fill:!0},"path78-6-5":{type:"path",points:[{x:.47788845000000046,y:.39996355000000006},{x:.46675745000000024,y:.38994185000000003},{x:.35403445000000033,y:.2884496500000002},{x:.352984450000001,y:.2880496500000005}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.10246254999999982,y:.34693914999999986},bottom1:{type:"text",text:"{VAL}",x:.0012544500000004621,y:-.4264014500000004}},refblocks:{left1:{x:-.5413984499999998,y:-.013266350000000315},right1:{x:.54139845,y:-.012269950000000529}},bounds:{minX:-.5695568909999997,maxX:.569556891,minY:-.4264014500000004,maxY:.4264014500000006,width:1.1391137819999997,height:.852802900000001,centerX:11102230246251565e-32,centerY:11102230246251565e-32},circles:{path1:{type:"circle",x:-.0037626500000000895,y:-.005285250000000241,radius:.28854213,color:"primary",fill:!1}}},use=kh(BHe).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),fse=su(use),HHe=fse.primitives.filter(r=>r.type==="text"),dse=HHe.find(r=>r.text==="{REF}");dse.y=0,dse.anchor="middle_left";var VHe=fse,jHe={paths:{path11:{type:"path",points:[{x:-.38509374449999945,y:-.00367374999999992},{x:.05876225550000025,y:-.00629674999999974}],color:"primary",fill:!1},path40:{type:"path",points:[{x:.07415065550000066,y:.18559775000000034},{x:.07322065550000101,y:-.18255174999999935}],color:"primary",fill:!1},"path12-1":{type:"path",points:[{x:.28423665550000043,y:.53233025},{x:.2836366555000003,y:.10600584999999985}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:.2912404555000001,y:-.5298821500000002},{x:.29184045550000004,y:-.10355795000000012}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.07425025549999931,y:.10788365000000044},{x:.29146205549999915,y:.10659565000000004}],color:"primary",fill:!1},"path2-5":{type:"path",points:[{x:.07425025549999931,y:-.10232114999999986},{x:.29146205549999915,y:-.10360915000000026}],color:"primary",fill:!1},path15:{type:"path",points:[{x:.005945155500000077,y:-.06535114999999969},{x:.005945155500000077,y:.06153284999999986},{x:-.0829488445000004,y:-.001166149999999977},{x:.005945155500000077,y:-.06535114999999969}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:-.15156024449999927,y:.36092494999999936},bottom1:{type:"text",text:"{VAL}",x:.0393233555000001,y:-.42489435000000064}},refblocks:{top1:{x:.2843894554999997,y:.5519248499999992},bottom1:{x:.29108805550000105,y:-.5519248499999994},left1:{x:-.3990097444999998,y:-.004526550000000462}},bounds:{minX:-.4271681854999998,maxX:.42716818549999985,minY:-.5800832909999993,maxY:.5800832909999992,width:.8543363709999996,height:1.1601665819999987,centerX:27755575615628914e-33,centerY:-5551115123125783e-32},circles:{path1:{type:"circle",x:.13862605549999985,y:.003454549999999612,radius:.28854213,color:"primary",fill:!1}}},{paths:GHe,texts:hse,bounds:QR,refblocks:sI,circles:qHe}=jHe,pse=am({primitives:[...Object.values(GHe),...Object.values(qHe),{...hse.top1,anchor:"middle_right",x:0},{...hse.bottom1,anchor:"middle_right"}],ports:[{...sI.top1,labels:["1","drain"]},{...sI.bottom1,labels:["2","source"]},{...sI.left1,labels:["3","gate"]}],size:{width:QR.width,height:QR.height},center:{x:QR.centerX,y:QR.centerY}}),mse=su(pse),vse=mse.primitives.filter(r=>r.type==="text"),lI=vse.find(r=>r.text==="{VAL}");lI.x=-.35,lI.y=0,lI.anchor="middle_right";var cI=vse.find(r=>r.text==="{REF}");cI.y=0,cI.x=.35,cI.anchor="middle_left";var YHe=mse,yse={paths:{path11:{type:"path",points:[{x:-.3850939444999988,y:-.0036735999999999436},{x:.0587620555000008,y:-.0062965999999997635}],color:"primary",fill:!1},"path40-0":{type:"path",points:[{x:.07400475550000118,y:.2689528999999997},{x:.07335475550000092,y:-.2789230000000007}],color:"primary",fill:!1},"path40-0-5":{type:"path",points:[{x:.2754149555000005,y:.24180210000000013},{x:.07955815550000045,y:.10822479999999968}],color:"primary",fill:!1},"path40-0-5-0":{type:"path",points:[{x:.2868554555000009,y:-.24134789999999984},{x:.09194705550000082,y:-.10807689999999992}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:.2851204555,y:.25311099999999964},{x:.2860204555000001,y:.5377640999999995}],color:"primary",fill:!1},"path12-1-5-3":{type:"path",points:[{x:.2851204555,y:-.5376890000000012},{x:.2860204555000001,y:-.25303590000000065}],color:"primary",fill:!1},path15:{type:"path",points:[{x:.15155145550000038,y:-.2268796000000004},{x:.2242753555000001,y:-.12301900000000021},{x:.11557535549999942,y:-.12338900000000042},{x:.15155145550000038,y:-.2268796000000004}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:-.08351674449999891,y:.37335419999999897},bottom1:{type:"text",text:"{VAL}",x:-.0679100444999996,y:-.4129789000000006}},refblocks:{top1:{x:.28556045550000064,y:.5519250999999994},bottom1:{x:.285560455500002,y:-.5519250999999992},left1:{x:-.3990097444999998,y:-.004526300000000871}},bounds:{minX:-.4271681854999998,maxX:.4271681855000001,minY:-.5800835409999991,maxY:.5800835409999994,width:.8543363709999998,height:1.1601670819999985,centerX:13877787807814457e-32,centerY:11102230246251565e-32},circles:{"path1-0":{type:"circle",x:.13862605550000007,y:.003454799999999203,radius:.28854213,color:"primary",fill:!1}}},gse=kh(yse).changeTextAnchor("{VAL}","middle_right").labelPort("left1",["3"]).labelPort("bottom1",["2"]).labelPort("top1",["1"]).changeTextAnchor("{REF}","middle_right").build(),XHe=su(gse),WHe=XHe.primitives.filter(r=>r.type==="text"),$He=WHe.find(r=>r.text==="{REF}");$He.anchor="middle_left";var ZHe=kh(yse).rotateRightFacingSymbol("down").changeTextAnchor("{VAL}","middle_right").labelPort("left1",["3"]).labelPort("bottom1",["2"]).labelPort("top1",["1"]).changeTextAnchor("{REF}","middle_left").build(),QHe={paths:{path40:{type:"path",points:[{x:-.19250837381256392,y:.32749349347032286},{x:-.25568957329611974,y:.13794979950157282}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.38205206778131373,y:.26431229398676837},{x:-.19250837381256392,y:.32749349347032286}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.2556895732961204,y:.13794979950157416},{x:-.38205206778131373,y:.26431229398676837}],color:"primary",fill:!1},path43:{type:"path",points:[{x:-.2556896210551609,y:.39067474071292196},{x:-.12932712656996737,y:.26431224622772653}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.3199237641156438,y:.2000781031672434},{x:-.5084145145074668,y:.011587352775420667}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:-.011560829633404435,y:.5083596562436202},{x:-.19004023433272543,y:.3298802515442989}],color:"primary",fill:!1},"path40-4":{type:"path",points:[{x:-.19250813152967883,y:-.3220463011874377},{x:-.38205182549842887,y:-.2588651017038819}],color:"primary",fill:!1},"path41-1":{type:"path",points:[{x:-.2556893310132333,y:-.13250260721868767},{x:-.19250813152967883,y:-.3220463011874377}],color:"primary",fill:!1},"path42-7":{type:"path",points:[{x:-.38205182549842753,y:-.258865101703881},{x:-.2556893310132333,y:-.13250260721868767}],color:"primary",fill:!1},"path43-1":{type:"path",points:[{x:-.12932688428707984,y:-.2588650539448407},{x:-.25568937877227516,y:-.38522754843003404}],color:"primary",fill:!1},"path44-8":{type:"path",points:[{x:-.3199235218327583,y:-.19463091088435758},{x:-.508414272224581,y:-.006140160492534852}],color:"primary",fill:!1},"path44-0-7":{type:"path",points:[{x:-.011641968756381349,y:-.5029938453665972},{x:-.1901213734557028,y:-.3245144406672762}],color:"primary",fill:!1},"path40-4-0":{type:"path",points:[{x:.322578868470321,y:.19315369881256328},{x:.13303517450157099,y:.2563348982961191}],color:"primary",fill:!1},"path41-1-2":{type:"path",points:[{x:.2593976689867663,y:.3826973927813131},{x:.322578868470321,y:.19315369881256328}],color:"primary",fill:!1},"path42-7-1":{type:"path",points:[{x:.13303517450157232,y:.2563348982961198},{x:.2593976689867663,y:.3826973927813131}],color:"primary",fill:!1},"path43-1-8":{type:"path",points:[{x:.38576011571292,y:.2563349460551603},{x:.2593976212277247,y:.12997245156996673}],color:"primary",fill:!1},"path44-8-7":{type:"path",points:[{x:.19516347816724133,y:.3205690891156432},{x:.006672727775418608,y:.509059839507466}],color:"primary",fill:!1},"path44-0-7-1":{type:"path",points:[{x:.5034450312436185,y:.012206154633403798},{x:.32496562654429706,y:.19068555933272457}],color:"primary",fill:!1},"path40-4-8":{type:"path",points:[{x:.3220220261874358,y:-.19326390652967795},{x:.25884082670387976,y:-.382807600498428}],color:"primary",fill:!1},"path41-1-4":{type:"path",points:[{x:.13247833221868577,y:-.25644510601323245},{x:.3220220261874358,y:-.19326390652967795}],color:"primary",fill:!1},"path42-7-0":{type:"path",points:[{x:.2588408267038793,y:-.38280760049842666},{x:.13247833221868577,y:-.25644510601323245}],color:"primary",fill:!1},"path43-1-0":{type:"path",points:[{x:.2588407789448386,y:-.13008265928707896},{x:.38520327343003213,y:-.2564451537722743}],color:"primary",fill:!1},"path44-8-9":{type:"path",points:[{x:.19460663588435567,y:-.3206792968327574},{x:.0061158854925329464,y:-.5091700472245801}],color:"primary",fill:!1},"path44-0-7-3":{type:"path",points:[{x:.5029695703665951,y:-.012397743756380697},{x:.3244901656672745,y:-.19087714845570192}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.2872803000000015,y:.4564494249999992},bottom1:{type:"text",text:"{VAL}",x:-.2872803000000015,y:-.4960514750000007}},refblocks:{top1:{x:.0005126999999993664,y:.5191475},bottom1:{x:-.0005123000000009093,y:-.5191475000000001},left1:{x:-.5191472999999998,y:.0005123250000014234},right1:{x:.5191473000000002,y:-.0005123749999977889}},bounds:{minX:-.5473057409999997,maxX:.5473057410000002,minY:-.5473059410000001,maxY:.547305941,width:1.094611482,height:1.0946118820000001,centerX:2220446049250313e-31,centerY:-5551115123125783e-32},circles:{}},{paths:KHe,texts:_se,bounds:KR,refblocks:xse}=QHe,bse=am({primitives:[...Object.values(KHe),{..._se.bottom1,y:.35,anchor:"middle_top"},{..._se.top1,anchor:"middle_left"}],ports:[{...xse.left1,labels:["1"]},{...xse.right1,labels:["2"]}],size:{width:KR.width+.05,height:KR.height},center:{x:KR.centerX,y:KR.centerY}}),JHe=su(bse),eVe=JHe,tVe={paths:{path18:{type:"path",points:[{x:-.53224045,y:-.0008545000000008685},{x:-.26765715000000023,y:-.0008545000000008685}],color:"primary",fill:!1},path19:{type:"path",points:[{x:.2615098499999995,y:-.0008545000000008685},{x:.5260934499999994,y:-.0008545000000008685}],color:"primary",fill:!1},path20:{type:"path",points:[{x:-.0030722500000006647,y:.1314371999999988},{x:.2615107499999998,y:.1314371999999988},{x:.2615107499999998,y:-.13314619999999877},{x:-.26765624999999993,y:-.13314619999999877},{x:-.26765624999999993,y:.1314371999999988},{x:-.0030722499999988884,y:.1314371999999988}],color:"primary",fill:!1},path23:{type:"path",points:[{x:.2782993499999993,y:-.2822274},{x:.17598844999999885,y:-.25486950000000164},{x:.25094144999999823,y:-.1799165000000027}],color:"primary",fill:!0},path24:{type:"path",points:[{x:.2882692499999995,y:-.2921307000000013},{x:.25467554999999953,y:-.16634940000000142},{x:.16229264999999948,y:-.25853690000000284}],color:"primary",fill:!0},path26:{type:"path",points:[{x:-.2985911500000009,y:.2921307000000013},{x:.22988164999999938,y:-.2328032000000011}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:.055041669999999154,y:.2009376800000009},bottom1:{type:"text",text:"{VAL}",x:-.10019643000000089,y:-.27857531999999985}},refblocks:{left1:{x:-.5346914500000006,y:-.0013439000000019519},right1:{x:.5346914500000004,y:-.001956599999999753}},bounds:{minX:-.5628498910000006,maxX:.5628498910000004,minY:-.2921307000000013,maxY:.2921307000000013,width:1.125699782000001,height:.5842614000000026,centerX:-11102230246251565e-32,centerY:0},circles:{}},{paths:nVe,texts:Sse,bounds:JR,refblocks:Ese}=tVe,wse=am({primitives:[...Object.values(nVe),{...Sse.bottom1,anchor:"middle_top"},{...Sse.top1,anchor:"middle_bottom"}],ports:[{...Ese.left1,labels:["1"]},{...Ese.right1,labels:["2"]}],size:{width:JR.width,height:JR.height},center:{x:JR.centerX,y:JR.centerY}}),Tse=su(wse),Mse=Tse.primitives.filter(r=>r.type==="text"),rVe=Mse.find(r=>r.text==="{VAL}");rVe.anchor="middle_right";var iVe=Mse.find(r=>r.text==="{REF}");iVe.anchor="middle_left";var aVe=Tse,oVe={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:{}},eA=kh(oVe).labelPort("left",["1"]).labelPort("right",["3"]).labelPort("bottom",["2"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),sVe=su(eA,"down"),lVe=su(eA,"left"),cVe=su(eA,"up"),uVe={paths:{path11:{type:"path",points:[{x:-.5274831500000005,y:.02812460000000061},{x:-.30105415000000013,y:.02812460000000061}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.2932119499999999,y:.02812460000000061},{x:.5339524499999997,y:.02812460000000061}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.16215344999999948,y:.39517610000000025},bottom1:{type:"text",text:"{VAL}",x:-.003375049999999602,y:-.39517610000000003},left1:{type:"text",text:"COS φ",x:-.1453603499999998,y:.013845600000000235}},refblocks:{left1:{x:-.5413984499999998,y:.027271800000000068},right1:{x:.54139845,y:.028268199999999855}},bounds:{minX:-.5695568909999997,maxX:.569556891,minY:-.39517610000000003,maxY:.39517610000000025,width:1.1391137819999997,height:.7903522000000003,centerX:11102230246251565e-32,centerY:11102230246251565e-32},circles:{path1:{type:"circle",x:-.0037626500000000895,y:.03525290000000014,radius:.28854213,color:"primary",fill:!1}}},{paths:fVe,texts:GRt,bounds:tA,refblocks:Cse,circles:dVe}=uVe,Rse=am({primitives:[...Object.values(fVe),...Object.values(dVe),{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 φ",x:0,y:.014279000000000375,anchor:"center"}],ports:[{...Cse.left1,labels:["1"]},{...Cse.right1,labels:["2"]}],size:{width:tA.width,height:tA.height},center:{x:tA.centerX,y:tA.centerY}}),Ase=su(Rse),uI=Ase.primitives.filter(r=>r.type==="text"),fI=uI.find(r=>r.text==="{REF}"),dI=uI.find(r=>r.text==="{VAL}"),hI=uI.find(r=>r.text==="COS φ");fI.x=.35,fI.y=0,fI.anchor="middle_left",dI.anchor="middle_right",dI.x=-.35,dI.y=0,hI.x=0,hI.y=0,hI.anchor="center";var hVe=Ase,pVe={paths:{"path12-1-8-6-9-9":{type:"path",points:[{x:.013196749999999646,y:.030446500000000043},{x:.013196749999999646,y:-.0859464999999986}],color:"primary",fill:!1},"path12-1-5-6-4":{type:"path",points:[{x:-.4867871500000014,y:-.0510704999999998},{x:-.17248085000000124,y:-.0510704999999998}],color:"primary",fill:!1},"path12-1-8-0-0":{type:"path",points:[{x:-.15916995000000078,y:-.0915204999999979},{x:.1810634499999999,y:-.0915204999999979}],color:"primary",fill:!1},"path12-1-0-1":{type:"path",points:[{x:.19611864999999984,y:-.05109549999999885},{x:.48876354999999894,y:-.05109549999999885}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:.007320949999999549,y:.22461850000000005},bottom1:{type:"text",text:"{VAL}",x:-.1606897500000004,y:-.22461849999999828}},refblocks:{left1:{x:-.47241845000000104,y:-.05104349999999869},right1:{x:.47241845000000016,y:-.051482499999998765}},bounds:{minX:-.500576891000001,maxX:.5005768910000001,minY:-.22461849999999828,maxY:.22461850000000005,width:1.0011537820000012,height:.44923699999999833,centerX:-4440892098500626e-31,centerY:8881784197001252e-31},circles:{"circle-2":{type:"circle",x:-.14387115000000072,y:-.05130149999999922,radius:.023193523,color:"primary",fill:!1},circle:{type:"circle",x:.16803074999999978,y:-.05007949999999717,radius:.023193523,color:"primary",fill:!1}}},{paths:mVe,texts:Dse,bounds:nA,refblocks:Pse,circles:vVe}=pVe,Nse=am({primitives:[...Object.values(mVe),...Object.values(vVe),{...Dse.top1,anchor:"middle_left"},{...Dse.bottom1,anchor:"middle_left"}],ports:[{...Pse.left1,labels:["1"]},{...Pse.right1,labels:["2"]}],size:{width:nA.width,height:nA.height},center:{x:nA.centerX,y:nA.centerY}}),yVe=su(Nse,"up"),gVe={paths:{"path12-1-8-6-9-9":{type:"path",points:[{x:-.04575882,y:.08981650000000013},{x:-.04575882,y:.039523500000001495}],color:"primary",fill:!1},"path12-1-8-7-9-9":{type:"path",points:[{x:-.04575882,y:.08981650000000013},{x:.06765231,y:.08981650000000013}],color:"primary",fill:!1},"path12-1-8-6-9-10":{type:"path",points:[{x:.06765231,y:.08981650000000013},{x:.06765231,y:.039523500000001495}],color:"primary",fill:!1},"path12-1-5-6-4":{type:"path",points:[{x:-.4867871500000014,y:-.0510704999999998},{x:-.17248085000000124,y:-.0510704999999998}],color:"primary",fill:!1},"path12-1-8-0-0":{type:"path",points:[{x:-.15916995000000078,y:.03984950000000042},{x:.1810634499999999,y:.03984950000000042}],color:"primary",fill:!1},"path12-1-0-1":{type:"path",points:[{x:.19611864999999984,y:-.05109549999999885},{x:.48876354999999894,y:-.05109549999999885}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:.007320949999999549,y:.29461850000000006},bottom1:{type:"text",text:"{VAL}",x:-.1606897500000004,y:-.22461849999999828}},refblocks:{left1:{x:-.47241845000000104,y:-.05104349999999869},right1:{x:.47241845000000016,y:-.051482499999998765}},bounds:{minX:-.500576891000001,maxX:.5005768910000001,minY:-.22461849999999828,maxY:.22461850000000005,width:1.0011537820000012,height:.44923699999999833,centerX:-4440892098500626e-31,centerY:8881784197001252e-31},circles:{"circle-2":{type:"circle",x:-.14387115000000072,y:-.05130149999999922,radius:.023193523,color:"primary",fill:!1},circle:{type:"circle",x:.16803074999999978,y:-.05007949999999717,radius:.023193523,color:"primary",fill:!1}}},{paths:_Ve,texts:Lse,bounds:rA,refblocks:Ose,circles:xVe}=gVe,Use=am({primitives:[...Object.values(_Ve),...Object.values(xVe),{...Lse.top1,anchor:"middle_left"},{...Lse.bottom1,anchor:"middle_left"}],ports:[{...Ose.left1,labels:["1"]},{...Ose.right1,labels:["2"]}],size:{width:rA.width,height:rA.height},center:{x:rA.centerX,y:rA.centerY}}),bVe=su(Use,"up"),SVe={paths:{path40:{type:"path",points:[{x:-.19250837381256392,y:-.32749349347032286},{x:-.25568957329611974,y:-.13794979950157282}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.38205206778131373,y:-.26431229398676837},{x:-.19250837381256392,y:-.32749349347032286}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.2556895732961204,y:-.13794979950157416},{x:-.38205206778131373,y:-.26431229398676837}],color:"primary",fill:!1},path43:{type:"path",points:[{x:-.2556896210551609,y:-.39067474071292196},{x:-.12932712656996737,y:-.26431224622772653}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.3199237641156438,y:-.2000781031672434},{x:-.5084145145074668,y:-.011587352775420667}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:-.011560829633404435,y:-.5083596562436202},{x:-.19004023433272543,y:-.3298802515442989}],color:"primary",fill:!1},"path40-4":{type:"path",points:[{x:-.19250813152967883,y:.3220463011874377},{x:-.38205182549842887,y:.2588651017038819}],color:"primary",fill:!1},"path41-1":{type:"path",points:[{x:-.2556893310132333,y:.13250260721868767},{x:-.19250813152967883,y:.3220463011874377}],color:"primary",fill:!1},"path42-7":{type:"path",points:[{x:-.38205182549842753,y:.258865101703881},{x:-.2556893310132333,y:.13250260721868767}],color:"primary",fill:!1},"path43-1":{type:"path",points:[{x:-.12932688428707984,y:.2588650539448407},{x:-.25568937877227516,y:.38522754843003404}],color:"primary",fill:!1},"path44-8":{type:"path",points:[{x:-.3199235218327583,y:.19463091088435758},{x:-.508414272224581,y:.006140160492534852}],color:"primary",fill:!1},"path44-0-7":{type:"path",points:[{x:-.011641968756381349,y:.5029938453665972},{x:-.1901213734557028,y:.3245144406672762}],color:"primary",fill:!1},"path40-4-0":{type:"path",points:[{x:.322578868470321,y:-.19315369881256328},{x:.13303517450157099,y:-.2563348982961191}],color:"primary",fill:!1},"path41-1-2":{type:"path",points:[{x:.2593976689867663,y:-.3826973927813131},{x:.322578868470321,y:-.19315369881256328}],color:"primary",fill:!1},"path42-7-1":{type:"path",points:[{x:.13303517450157232,y:-.2563348982961198},{x:.2593976689867663,y:-.3826973927813131}],color:"primary",fill:!1},"path43-1-8":{type:"path",points:[{x:.38576011571292,y:-.2563349460551603},{x:.2593976212277247,y:-.12997245156996673}],color:"primary",fill:!1},"path44-8-7":{type:"path",points:[{x:.19516347816724133,y:-.3205690891156432},{x:.006672727775418608,y:-.509059839507466}],color:"primary",fill:!1},"path44-0-7-1":{type:"path",points:[{x:.5034450312436185,y:-.012206154633403798},{x:.32496562654429706,y:-.19068555933272457}],color:"primary",fill:!1},"path40-4-8":{type:"path",points:[{x:.3220220261874358,y:.19326390652967795},{x:.25884082670387976,y:.382807600498428}],color:"primary",fill:!1},"path41-1-4":{type:"path",points:[{x:.13247833221868577,y:.25644510601323245},{x:.3220220261874358,y:.19326390652967795}],color:"primary",fill:!1},"path42-7-0":{type:"path",points:[{x:.2588408267038793,y:.38280760049842666},{x:.13247833221868577,y:.25644510601323245}],color:"primary",fill:!1},"path43-1-0":{type:"path",points:[{x:.2588407789448386,y:.13008265928707896},{x:.38520327343003213,y:.2564451537722743}],color:"primary",fill:!1},"path44-8-9":{type:"path",points:[{x:.19460663588435567,y:.3206792968327574},{x:.0061158854925329464,y:.5091700472245801}],color:"primary",fill:!1},"path44-0-7-3":{type:"path",points:[{x:.5029695703665951,y:.012397743756380697},{x:.3244901656672745,y:.19087714845570192}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.2872803000000015,y:-.4564494249999992},bottom1:{type:"text",text:"{VAL}",x:-.2872803000000015,y:.4960514750000007}},refblocks:{top1:{x:.0005126999999993664,y:-.5191475},bottom1:{x:-.0005123000000009093,y:.5191475000000001},left1:{x:-.5191472999999998,y:-.0005123250000014234},right1:{x:.5191473000000002,y:.0005123749999977889}},bounds:{minX:-.5473057409999997,maxX:.5473057410000002,minY:-.5564494249999992,maxY:.5473059410000001,width:1.094611482,height:1.1037553659999992,centerX:2220446049250313e-31,centerY:-.004571741999999546},circles:{}},{paths:EVe,texts:zse,bounds:iA,refblocks:aA,circles:wVe}=SVe,Fse=am({primitives:[...Object.values(EVe),...Object.values(wVe),{...zse.top1,anchor:"middle_right"},{...zse.bottom1,anchor:"middle_right"}],ports:[{...aA.top1,labels:["1"]},{...aA.bottom1,labels:["2"]},{...aA.left1,labels:["3"]},{...aA.right1,labels:["4"]}],size:{width:iA.width,height:iA.height},center:{x:iA.centerX,y:iA.centerY}}),pI=su(Fse),TVe=pI.primitives.find(r=>r.type==="text"&&r.text==="{REF}"),MVe=pI.primitives.find(r=>r.type==="text"&&r.text==="{VAL}");TVe.anchor="middle_left",MVe.anchor="middle_right";var CVe=pI,RVe={paths:{path27:{type:"path",points:[{x:.7635944500000007,y:-.2799544500000035},{x:.3138028500000005,y:-.2799544500000035}],color:"primary",fill:!1},path28:{type:"path",points:[{x:-.301017949999999,y:-.01524775000000389},{x:-.7508096499999994,y:-.01524775000000389}],color:"primary",fill:!1},path30:{type:"path",points:[{x:-.3010179499999994,y:.3480486499999973},{x:-.301017949999999,y:-.2798310500000021}],color:"primary",fill:!1},"path27-3":{type:"path",points:[{x:.7729788499999999,y:.3512451499999969},{x:.32318725000000015,y:.3512451499999969}],color:"primary",fill:!1},"path29-5":{type:"path",points:[{x:-.07279374999999932,y:-.27981925000000274},{x:-.2983350499999995,y:-.27981925000000274}],color:"primary",fill:!1},"path29-5-7":{type:"path",points:[{x:.33114835000000076,y:-.2798404500000018},{x:.10560705000000059,y:-.2798404500000018}],color:"primary",fill:!1},"path29-5-7-6":{type:"path",points:[{x:-.055820049999999455,y:-.1676584500000029},{x:-.055820049999999455,y:-.3931997500000026}],color:"primary",fill:!1},"path29-5-7-6-6":{type:"path",points:[{x:.09396265000000081,y:-.16768285000000382},{x:.09396265000000081,y:-.39322415000000355}],color:"primary",fill:!1},"path29-5-9":{type:"path",points:[{x:-.07296184999999955,y:.3513701499999957},{x:-.2985031499999997,y:.3513701499999957}],color:"primary",fill:!1},"path29-5-7-2":{type:"path",points:[{x:.33098025000000053,y:.35134894999999844},{x:.10543895000000036,y:.35134894999999844}],color:"primary",fill:!1},"path29-5-7-6-0":{type:"path",points:[{x:-.05598814999999968,y:.46353094999999733},{x:-.05598814999999968,y:.23798964999999583}],color:"primary",fill:!1},"path29-5-7-6-6-2":{type:"path",points:[{x:.09379455000000014,y:.4635065499999982},{x:.09379455000000014,y:.23796524999999846}],color:"primary",fill:!1},"path29-5-92":{type:"path",points:[{x:.3315317500000008,y:.12563884999999786},{x:.33153175000000035,y:.3511801499999976}],color:"primary",fill:!1},"path29-5-7-28":{type:"path",points:[{x:.3315105500000004,y:-.2783032500000022},{x:.3315105500000004,y:-.0527619500000025}],color:"primary",fill:!1},"path29-5-7-6-9":{type:"path",points:[{x:.44369255000000063,y:.10866514999999843},{x:.21815125000000046,y:.10866514999999843}],color:"primary",fill:!1},"path29-5-7-6-6-7":{type:"path",points:[{x:.4436681500000006,y:-.04111755000000272},{x:.21812685000000043,y:-.04111755000000272}],color:"primary",fill:!1},"path29-5-7-6-9-2":{type:"path",points:[{x:.44235445000000073,y:.07167004999999627},{x:.21681315000000057,y:.07167004999999627}],color:"primary",fill:!1},"path29-5-7-6-9-2-4":{type:"path",points:[{x:.4429695500000004,y:-.0025598500000008073},{x:.4430214500000007,y:.07134914999999609}],color:"primary",fill:!1},"path29-5-7-6-9-2-4-6":{type:"path",points:[{x:.21634305000000031,y:-.0035468500000046532},{x:.21639495000000064,y:.07036214999999935}],color:"primary",fill:!1},"path29-5-7-6-9-2-9":{type:"path",points:[{x:.4429537500000005,y:-.004130850000002795},{x:.21741245000000076,y:-.004130850000002795}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:.01596175000000022,y:.5358501499999981},bottom1:{type:"text",text:"{VAL}",x:.013116750000000454,y:-.5358501500000017}},refblocks:{left1:{x:-.7666234499999998,y:-.01615045000000137},right1:{x:.7572390499999999,y:-.28185235000000297},right2:{x:.7666234500000004,y:.3493472499999992}},bounds:{minX:-.7947818909999997,maxX:.7947818910000004,minY:-.5358501500000017,maxY:.5358501499999981,width:1.5895637820000001,height:1.0717002999999998,centerX:33306690738754696e-32,centerY:-17763568394002505e-31},circles:{}},{paths:AVe,texts:qRt,bounds:oA,refblocks:mI,circles:DVe}=RVe,Ise=am({primitives:[...Object.values(AVe),...Object.values(DVe),{type:"text",text:"{REF}",x:.01596175000000022,y:-.5308501500000009,anchor:"middle_top"},{type:"text",text:"{VAL}",x:.013116750000000454,y:.5408501499999989,anchor:"middle_bottom"}],ports:[{...mI.left1,labels:["1"]},{...mI.right1,labels:["2"]},{...mI.right2,labels:["3"]}],size:{width:oA.width,height:oA.height},center:{x:oA.centerX,y:oA.centerY}}),PVe=su(Ise),NVe={paths:{path40:{type:"path",points:[{x:.14458930000000048,y:.04403649999999937},{x:-.11999399999999905,y:-.0882552000000012}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.11999400000000038,y:.1763281999999997},{x:.14458929999999914,y:.04403649999999937}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.11999400000000038,y:-.0882552000000012},{x:-.11999400000000038,y:.17632819999999816}],color:"primary",fill:!1},path43:{type:"path",points:[{x:.1435300000000006,y:.17844679999999968},{x:.14458899999999986,y:-.08825519999999965}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.12219870000000044,y:.04403649999999937},{x:-.5168690000000005,y:.04403649999999937}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.5233800999999991,y:.043951299999999804},{x:.14967199999999892,y:.043951299999999804}],color:"primary",fill:!1},"path43-7":{type:"path",points:[{x:.2075533999999999,y:.17973149999999904},{x:.14341080000000028,y:.17864949999999946}],color:"primary",fill:!1},"path43-7-9":{type:"path",points:[{x:.2093444999999996,y:.1301679},{x:.20797049999999984,y:.17950350000000048}],color:"primary",fill:!1},"path43-7-2":{type:"path",points:[{x:.07978989999999953,y:-.09023340000000024},{x:.14313979999999948,y:-.09001340000000013}],color:"primary",fill:!1},"path43-7-9-3":{type:"path",points:[{x:.07764390000000043,y:-.04104850000000004},{x:.0790179000000002,y:-.09038410000000074}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.0050250999999994495,y:.27384530000000007},bottom1:{type:"text",text:"{VAL}",x:-.00011179999999977319,y:-.27384530000000007}},refblocks:{left1:{x:-.5191471,y:.044920799999999206},right1:{x:.5191470999999999,y:.04389609999999999}},bounds:{minX:-.547305541,maxX:.5473055409999998,minY:-.27384530000000007,maxY:.27384530000000007,width:1.0946110819999997,height:.5476906000000001,centerX:-5551115123125783e-32,centerY:0},circles:{}},kse=kh(NVe).labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{VAL}","middle_top").changeTextAnchor("{REF}","middle_bottom").build(),vI=su(kse),LVe=vI.primitives.find(r=>r.type==="text"&&r.text==="{REF}"),OVe=vI.primitives.find(r=>r.type==="text"&&r.text==="{VAL}");LVe.anchor="middle_left",OVe.anchor="middle_right";var UVe=vI,zVe={paths:{path11:{type:"path",points:[{x:-.49895505000000084,y:.04174485000000061},{x:-.177441850000001,y:.04174485000000061}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.18704774999999918,y:.04961415000000069},{x:.5063384499999999,y:.04961415000000069}],color:"primary",fill:!1},"path12-6":{type:"path",points:[{x:.18219425000000045,y:-.15200134999999904},{x:.1810882500000004,y:.2512156500000011}],color:"primary",fill:!1},"path12-2":{type:"path",points:[{x:.18646324999999986,y:.0047866500000004475},{x:.34602244999999954,y:-.13539324999999924}],color:"primary",fill:!1},"path12-2-9":{type:"path",points:[{x:.3463884499999992,y:-.14077354999999936},{x:.3447284499999994,y:-.3343437499999993}],color:"primary",fill:!1},"path11-0-9":{type:"path",points:[{x:-.17016305000000087,y:.2706752500000007},{x:-.17223005000000047,y:-.15200864999999908},{x:.180362149999999,y:.04760855000000097},{x:-.16624855000000038,y:.27180665000000137}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:-.22312565000000006,y:.38273545},bottom1:{type:"text",text:"{VAL}",x:.11142554999999987,y:-.38273544999999976}},refblocks:{bottom1:{x:.3445824499999999,y:-.34953845000000006},left1:{x:-.5177904499999998,y:.04089205000000007},right1:{x:.5177904499999997,y:.049757749999999934}},bounds:{minX:-.5459488909999998,maxX:.5459488909999997,minY:-.38273544999999976,maxY:.38273545,width:1.0918977819999993,height:.7654708999999997,centerX:-5551115123125783e-32,centerY:11102230246251565e-32},circles:{}},Bse=kh(zVe).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).labelPort("bottom1",["3"]).changeTextAnchor("{REF}","middle_bottom").build(),Hse=su(Bse),FVe=Hse.primitives.filter(r=>r.type==="text"),Vse=FVe.find(r=>r.text==="{REF}");Vse.y=0,Vse.anchor="middle_left";var IVe=Hse,jse={paths:{path1:{type:"path",points:[{x:-.3543583500000005,y:.03204385000000087},{x:-.12792935000000005,y:.03204385000000087}],color:"primary",fill:!1},"path-1-3":{type:"path",points:[{x:-.1133669500000003,y:.0321987500000005},{x:.11208324999999997,y:.14600155000000048}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.1043477500000003,y:-.0645130499999993},{x:.34508875000000017,y:-.0645130499999993}],color:"primary",fill:!1},path3:{type:"path",points:[{x:.12008575000000055,y:.17214665000000062},{x:.3608267500000004,y:.17214665000000062}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.17853294999999947,y:.39716265000000006},bottom1:{type:"text",text:"{VAL}",x:-.011861250000000378,y:-.39716264999999984}},refblocks:{top1:{x:.10744654999999947,y:.17214664999999973},left1:{x:-.3682737499999995,y:.03204385000000021},left2:{x:-.11569114999999996,y:.03204385000000021},right1:{x:.3682737499999995,y:-.06451304999999996},right2:{x:.10744725000000055,y:-.06451304999999996},right3:{x:.3682737499999995,y:.17214664999999973}},bounds:{minX:-.3964321909999995,maxX:.3964321909999995,minY:-.39716264999999984,maxY:.39716265000000006,width:.792864381999999,height:.7943252999999999,centerX:0,centerY:11102230246251565e-32},circles:{}};jse.bounds.width+=.2;var{paths:kVe,texts:Gse,bounds:sA,refblocks:yI,circles:BVe}=jse,qse=am({primitives:[...Object.values(kVe),...Object.values(BVe),{...Gse.top1,anchor:"middle_bottom",x:-.01},{...Gse.bottom1,anchor:"middle_top",x:-.01}],ports:[{...yI.left1,labels:["1"]},{...yI.right1,labels:["3"]},{...yI.right2,labels:["2"]}],size:{width:sA.width,height:sA.height},center:{x:sA.centerX,y:sA.centerY}}),Yse=su(qse),Xse=Yse.primitives.filter(r=>r.type==="text"),gI=Xse.find(r=>r.text==="{VAL}");gI.anchor="middle_right",gI.x=-.3,gI.y=0;var _I=Xse.find(r=>r.text==="{REF}");_I.anchor="middle_left",_I.x=.3,_I.y=0;var HVe=Yse,lA={paths:{path11:{type:"path",points:[{x:-.3622273500000006,y:-.0018583499999986763},{x:-.13579835000000018,y:-.0018583499999986763}],color:"primary",fill:!1},"path11-0":{type:"path",points:[{x:-.12010005000000046,y:-.0033888499999992217},{x:.10307834999999987,y:.13630055000000119}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.12795584999999932,y:-.0018583499999986763},{x:.3686967499999996,y:-.0018583499999986763}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.03688484999999986,y:.25026835000000003},bottom1:{type:"text",text:"{VAL}",x:-.02235315000000071,y:-.25026835000000003}},refblocks:{left1:{x:-.12356015000000009,y:-.006648049999999239},left2:{x:-.37614274999999964,y:-.002711249999999721},right1:{x:.11531695000000042,y:-.006648049999999239},right2:{x:.37614274999999964,y:-.0017148499999992683}},bounds:{minX:-.4043011909999996,maxX:.4043011909999996,minY:-.25026835000000003,maxY:.25026835000000003,width:.8086023819999992,height:.5005367000000001,centerX:0,centerY:0},circles:{}};delete lA.refblocks.left1,delete lA.refblocks.right1,lA.bounds.width+=.2;var Wse=kh(lA).changeTextAnchor("{VAL}","middle_top").labelPort("left2",["1"]).labelPort("right2",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),$se=su(Wse),Zse=$se.primitives.filter(r=>r.type==="text"),xI=Zse.find(r=>r.text==="{VAL}");xI.anchor="middle_right",xI.x=-.3,xI.y=0;var bI=Zse.find(r=>r.text==="{REF}");bI.anchor="middle_left",bI.x=.3,bI.y=0;var VVe=$se,jVe={paths:{path40:{type:"path",points:[{x:.14458890000000002,y:.04403629999999836},{x:-.1199943999999995,y:-.08825540000000132}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.1199943999999995,y:.1763280000000016},{x:.14458890000000002,y:.04403629999999836}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.1199943999999995,y:-.08825539999999776},{x:-.1199943999999995,y:.1763280000000016}],color:"primary",fill:!1},path43:{type:"path",points:[{x:.14458890000000002,y:.1763280000000016},{x:.14458890000000002,y:-.08825539999999776}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.12219909999999956,y:.04403629999999836},{x:-.5168693999999996,y:.04403629999999836}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.5233797,y:.04395110000000102},{x:.14967160000000002,y:.04395110000000102}],color:"primary",fill:!1},"path43-5":{type:"path",points:[{x:.19156529999999972,y:-.0884020999999997},{x:.14591529999999908,y:-.08876210000000029}],color:"primary",fill:!1},"path43-5-2":{type:"path",points:[{x:.19233440000000046,y:-.1355493999999986},{x:.19197439999999988,y:-.08989940000000018}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.0050250999999996715,y:.27384529999999785},bottom1:{type:"text",text:"{VAL}",x:-.00011179999999999524,y:-.2738453000000014}},refblocks:{left1:{x:-.5191471000000001,y:.0449206999999987},right1:{x:.5191471000000001,y:.043896100000001326}},bounds:{minX:-.5473055410000001,maxX:.5473055410000001,minY:-.2738453000000014,maxY:.27384529999999785,width:1.0946110820000001,height:.5476905999999993,centerX:0,centerY:-17763568394002505e-31},circles:{}},Qse=kh(jVe).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),GVe=su(Qse),qVe={paths:{path11:{type:"path",points:[{x:-.5307178,y:0},{x:-.3042887999999997,y:0}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.2899773000000003,y:0},{x:.5307178000000001,y:0}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.17652089999999898,y:-.36197569999999946},bottom1:{type:"text",text:"{VAL}",x:-.009849199999999891,y:.43234960000000044},left1:{type:"text",text:"RPM",x:0,y:-.025}},refblocks:{left1:{x:-.5446330999999993,y:.000852800000000542},right1:{x:.5381638000000004,y:-.00014359999999924433}},bounds:{minX:-.5307178,maxX:.5307178000000001,minY:0,maxY:0,width:1.0614356000000003,height:1,centerX:5551115123125783e-32,centerY:0},circles:{path1:{type:"circle",x:-.006997299999999651,y:-.007128299999999532,radius:.28854213,color:"primary",fill:!1}}},{paths:YVe,texts:XVe,bounds:cA,refblocks:Kse,circles:WVe}=qVe,SI=am({primitives:[...Object.values(YVe),...Object.values(WVe),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"},{...XVe.left1,y:.01,anchor:"center",fontSize:.2}],ports:[{...Kse.left1,labels:["1"]},{...Kse.right1,labels:["2"]}],size:{width:cA.width,height:cA.height},center:{x:cA.centerX,y:cA.centerY}}),{5:$Ve,...ZVe}=SI.primitives;function QVe(r){return typeof r=="object"}var Jse=su({...SI,primitives:Object.values(ZVe).filter(QVe)}),KVe={...Jse,primitives:[...Jse.primitives,$Ve]},JVe={paths:{path11:{type:"path",points:[{x:-.5176700499999997,y:.041745050000000505},{x:-.10888805000000024,y:.041745050000000505}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.1031184499999993,y:.041745050000000505},{x:.5246894499999994,y:.041745050000000505}],color:"primary",fill:!1},"path11-0":{type:"path",points:[{x:-.09343985000000021,y:-.14620634999999882},{x:-.0930998500000002,y:.2583405500000009}],color:"primary",fill:!1},"path11-0-3":{type:"path",points:[{x:.08519034999999908,y:-.14503384999999902},{x:.08553034999999909,y:.2595130500000007}],color:"primary",fill:!1},"path11-0-9":{type:"path",points:[{x:-.08315755000000014,y:.055934450000000524},{x:-.08415755000000047,y:-.14678124999999964},{x:.08653524999999984,y:-.05104664999999953},{x:-.08126175000000035,y:.05647715000000031}],color:"primary",fill:!0},"path11-0-9-0":{type:"path",points:[{x:.07661224999999927,y:.256654450000001},{x:.07761224999999983,y:.05393885000000109},{x:-.0930805500000007,y:.1496734500000012},{x:.07471644999999949,y:.25719715000000143}],color:"primary",fill:!0},"path12-2":{type:"path",points:[{x:.09001085000000009,y:-.05964874999999914},{x:.2707999499999998,y:-.1711147499999992}],color:"primary",fill:!1},"path12-2-9":{type:"path",points:[{x:.27291134999999955,y:-.17591894999999935},{x:.27124034999999935,y:-.30168314999999923}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:.0077081499999991365,y:.41683614999999996},bottom1:{type:"text",text:"{VAL}",x:-.03022294999999975,y:-.41683614999999996}},refblocks:{bottom1:{x:.27223905000000026,y:-.3087962499999999},left1:{x:-.54139845,y:.04089205000000051},right1:{x:.5413984499999995,y:.04188845000000008}},bounds:{minX:-.569556891,maxX:.5695568909999995,minY:-.41683614999999996,maxY:.41683614999999996,width:1.1391137819999995,height:.8336722999999999,centerX:-2220446049250313e-31,centerY:0},circles:{path1:{type:"circle",x:-.0037626500000003116,y:.048873150000000365,radius:.28854213,color:"primary",fill:!1}}},ele=kh(JVe).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).labelPort("bottom1",["3"]).changeTextAnchor("{REF}","middle_bottom").build(),tle=su(ele),nle=tle.primitives.filter(r=>r.type==="text"),eje=nle.find(r=>r.text==="{REF}"),tje=nle.find(r=>r.text==="{VAL}");eje.y=0,tje.y=0;var nje=tle,rje={paths:{path40:{type:"path",points:[{x:.14458890000000002,y:.04403629999999992},{x:-.1199943999999995,y:-.08825540000000043}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.1199943999999995,y:.17632800000000026},{x:.14458890000000002,y:.04403629999999992}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.1199943999999995,y:-.0882553999999991},{x:-.1199943999999995,y:.17632800000000026}],color:"primary",fill:!1},path43:{type:"path",points:[{x:.14458890000000002,y:.17632800000000026},{x:.14458890000000002,y:-.0882553999999991}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.12219909999999956,y:.04403629999999992},{x:-.5168693999999996,y:.04403629999999992}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.5233797000000002,y:.043951100000000354},{x:.1496715999999998,y:.043951100000000354}],color:"primary",fill:!1},"path43-8":{type:"path",points:[{x:.14339119999999994,y:.17681090000000044},{x:.07728679999999954,y:.17632089999999967}],color:"primary",fill:!1},"path43-8-8":{type:"path",points:[{x:.1446069000000001,y:-.08908179999999888},{x:.0785024999999997,y:-.08957179999999942}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.0050250999999996715,y:.27384530000000007},bottom1:{type:"text",text:"{VAL}",x:-.00011179999999977319,y:-.27384529999999985}},refblocks:{left1:{x:-.5191471000000001,y:.044920700000000924},right1:{x:.5191470999999999,y:.04389609999999999}},bounds:{minX:-.5473055410000001,maxX:.5473055409999998,minY:-.27384529999999985,maxY:.27384530000000007,width:1.094611082,height:.5476905999999999,centerX:-11102230246251565e-32,centerY:11102230246251565e-32},circles:{}},{paths:ije,texts:rle,bounds:uA,refblocks:ile,circles:aje}=rje,ale=am({primitives:[...Object.values(ije),...Object.values(aje),{...rle.top1,anchor:"middle_bottom"},{...rle.bottom1,anchor:"middle_top"}],ports:[{...ile.left1,labels:["1"]},{...ile.right1,labels:["2"]}],size:{width:uA.width,height:uA.height},center:{x:uA.centerX,y:uA.centerY}}),EI=su(ale),oje=EI.primitives.find(r=>r.type==="text"&&r.text==="{REF}"),sje=EI.primitives.find(r=>r.type==="text"&&r.text==="{VAL}");oje.anchor="middle_left",sje.anchor="middle_right";var lje=EI,cje={paths:{path11:{type:"path",points:[{x:-.3274461945,y:.20527883627037657},{x:-.021085194500000348,y:.007570136270376837}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.2331163055000003,y:.1251673362703769},{x:.2320633055000001,y:.3759855362703768}],color:"primary",fill:!1},"path12-2":{type:"path",points:[{x:.23221610549999938,y:-.0818845637296235},{x:.2311631054999992,y:-.33270276372962315}],color:"primary",fill:!1},"path11-0":{type:"path",points:[{x:-.013263894499999873,y:-.1792007637296229},{x:-.012923894499999866,y:.2253461362703768}],color:"primary",fill:!1},"path11-0-3":{type:"path",points:[{x:.23222970550000066,y:.12047013627037662},{x:-.011307094499999115,y:.11996013627037683}],color:"primary",fill:!1},"path11-0-9":{type:"path",points:[{x:-.1124341944999998,y:.131359936270377},{x:-.16993279449999954,y:.039004036270377185},{x:-.05822649449999928,y:.03212003627037707},{x:-.11133889449999979,y:.13104553627037707}],color:"primary",fill:!0},"path11-0-3-8":{type:"path",points:[{x:.23230320549999983,y:-.08329316372962325},{x:-.011233594499999944,y:-.07900616372962332}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.19541139450000045,y:.389088136270376},bottom1:{type:"text",text:"{VAL}",x:-.031363394499999364,y:-.42359956372962415}},refblocks:{top1:{x:.2317438004035266,y:.3954411227296242},bottom1:{x:.2308431668082036,y:-.35215823360635445},left1:{x:-.34055979449999985,y:.21512343627037622}},bounds:{minX:-.3687182354999998,maxX:.3687182354999999,minY:-.42359956372962415,maxY:.42359956372962415,width:.7374364709999996,height:.8471991274592483,centerX:27755575615628914e-33,centerY:0},circles:{path1:{type:"circle",x:.08017610549999987,y:.006746336270376352,radius:.28854213,color:"primary",fill:!1}}},{paths:uje,texts:ole,bounds:fA,refblocks:wI,circles:fje}=cje,sle=am({primitives:[...Object.values(uje),...Object.values(fje),{...ole.top1,anchor:"middle_left"},{...ole.bottom1,anchor:"middle_right"}],ports:[{...wI.top1,labels:["1"]},{...wI.bottom1,labels:["2"]},{...wI.left1,labels:["3"]}],size:{width:fA.width,height:fA.height},center:{x:fA.centerX,y:fA.centerY}}),lle=su(sle),cle=lle.primitives.filter(r=>r.type==="text"),dje=cle.find(r=>r.text==="{REF}");dje.y=.1;var ule=cle.find(r=>r.text==="{VAL}");ule.y=.1,ule.x=-.4;var hje=lle,pje={paths:{path11:{type:"path",points:[{x:-.5307178,y:0},{x:-.3042887999999997,y:0}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.2899773000000003,y:0},{x:.5307178000000001,y:0}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.17652089999999898,y:-.36197569999999946},bottom1:{type:"text",text:"{VAL}",x:-.009849199999999891,y:.43234960000000044},left1:{type:"text",text:"Var",x:-.19436529999999896,y:.07249430000000023}},refblocks:{left1:{x:-.5446330999999993,y:.000852800000000542},right1:{x:.5381638000000004,y:-.00014359999999924433}},bounds:{minX:-.5307178,maxX:.5307178000000001,minY:0,maxY:0,width:1.0614356000000003,height:1,centerX:5551115123125783e-32,centerY:0},circles:{path1:{type:"circle",x:-.006997299999999651,y:-.007128299999999532,radius:.28854213,color:"primary",fill:!1}}},{paths:mje,texts:TI,bounds:dA,refblocks:fle,circles:vje}=pje,dle=am({primitives:[...Object.values(mje),...Object.values(vje),{...TI.top1,x:0,y:-.3594553499999995,anchor:"middle_top"},{...TI.bottom1,x:0,y:.35,anchor:"middle_bottom"},{...TI.left1,x:-.02,y:.01,fontSize:.2,anchor:"center"}],ports:[{...fle.left1,labels:["1"]},{...fle.right1,labels:["2"]}],size:{width:dA.width,height:dA.height},center:{x:dA.centerX,y:dA.centerY}}),yje=su(dle),gje={paths:{path40:{type:"path",points:[{x:.08342510000000014,y:.04403649999999937},{x:-.18115819999999938,y:-.0882552000000012}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.1811582000000007,y:.1763281999999997},{x:.08342509999999881,y:.04403649999999937}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.1811582000000007,y:-.0882552000000012},{x:-.1811582000000007,y:.17632819999999816}],color:"primary",fill:!1},path43:{type:"path",points:[{x:.0949504999999995,y:.17485119999999976},{x:.09600949999999897,y:-.09185079999999957}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.1954338999999996,y:.04403649999999937},{x:-.5191807000000004,y:.04403649999999937}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.5253116,y:.043951299999999804},{x:.20527070000000047,y:.043951299999999804}],color:"primary",fill:!1},"path43-6":{type:"path",points:[{x:.1854899999999995,y:.1748848999999999},{x:.18654899999999874,y:-.09181709999999943}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.0050250999999994495,y:.27384530000000007},bottom1:{type:"text",text:"{VAL}",x:-.00011179999999977319,y:-.27384530000000007}},refblocks:{left1:{x:-.5191471,y:.044920799999999206},right1:{x:.5191470999999999,y:.04389609999999999}},bounds:{minX:-.547305541,maxX:.5473055409999998,minY:-.27384530000000007,maxY:.27384530000000007,width:1.0946110819999997,height:.5476906000000001,centerX:-5551115123125783e-32,centerY:0},circles:{}},{paths:_je,texts:hle,bounds:hA,refblocks:ple,circles:xje}=gje,mle=am({primitives:[...Object.values(_je),...Object.values(xje),{...hle.top1,anchor:"middle_bottom"},{...hle.bottom1,anchor:"middle_top"}],ports:[{...ple.left1,labels:["1"]},{...ple.right1,labels:["2"]}],size:{width:hA.width,height:hA.height},center:{x:hA.centerX,y:hA.centerY}}),MI=su(mle),bje=MI.primitives.find(r=>r.type==="text"&&r.text==="{REF}"),Sje=MI.primitives.find(r=>r.type==="text"&&r.text==="{VAL}");bje.anchor="middle_left",Sje.anchor="middle_right";var Eje=MI,wje={paths:{path5:{type:"path",points:[{x:-.5245830500000004,y:.004659100000001359},{x:-.25999975000000086,y:.004659100000001359}],color:"primary",fill:!1},path6:{type:"path",points:[{x:.2691672500000002,y:.004659100000001359},{x:.5337505499999997,y:.004659100000001359}],color:"primary",fill:!1},path7:{type:"path",points:[{x:.2691672500000002,y:-.23346590000000056},{x:-.25999974999999953,y:.2427841000000015}],color:"primary",fill:!1},path8:{type:"path",points:[{x:.37500025000000026,y:-.23346590000000056},{x:.2691672500000002,y:-.23346590000000056}],color:"primary",fill:!1},path9:{type:"path",points:[{x:.004585150000000482,y:.13695090000000043},{x:.26916815000000094,y:.13695090000000043},{x:.26916815000000094,y:-.1276325000000007},{x:-.2599988499999988,y:-.1276325000000007},{x:-.2599988499999988,y:.13695090000000043},{x:.004585150000001814,y:.13695090000000043}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.05849044999999986,y:.25166549999999965},bottom1:{type:"text",text:"{VAL}",x:.008507150000000685,y:-.25166549999999965}},refblocks:{left1:{x:-.5392315500000002,y:.002969399999999567},right1:{x:.5392315500000002,y:.005339799999999784}},bounds:{minX:-.5673899910000002,maxX:.5673899910000002,minY:-.25166549999999965,maxY:.25166549999999965,width:1.1347799820000004,height:.5033309999999993,centerX:0,centerY:0},circles:{}},{paths:Tje,texts:vle,bounds:pA,refblocks:yle}=wje,gle=am({primitives:[...Object.values(Tje),{...vle.top1,anchor:"middle_left"},{...vle.bottom1,anchor:"middle_right"}],ports:[{...yle.left1,labels:["1","-"]},{...yle.right1,labels:["2","+"]}],size:{width:pA.width,height:pA.height},center:{x:pA.centerX,y:pA.centerY}}),Mje=su(gle),Cje={paths:{path11:{type:"path",points:[{x:-.5307178,y:0},{x:-.3042887999999997,y:0}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.2899773000000003,y:0},{x:.5307178000000001,y:0}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.17652089999999898,y:-.36197569999999946},bottom1:{type:"text",text:"{VAL}",x:-.009849199999999891,y:.43234960000000044},left1:{type:"text",text:"Var",x:0,y:-.025}},refblocks:{left1:{x:-.5446330999999993,y:.000852800000000542},right1:{x:.5381638000000004,y:-.00014359999999924433}},bounds:{minX:-.5307178,maxX:.5307178000000001,minY:0,maxY:0,width:1.0614356000000003,height:1,centerX:5551115123125783e-32,centerY:0},circles:{path1:{type:"circle",x:-.006997299999999651,y:-.007128299999999532,radius:.28854213,color:"primary",fill:!1}}},{paths:Rje,texts:Aje,bounds:mA,refblocks:_le,circles:Dje}=Cje,CI=am({primitives:[...Object.values(Rje),...Object.values(Dje),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"},{...Aje.left1,anchor:"center",y:.02,fontSize:.2}],ports:[{..._le.left1,labels:["1"]},{..._le.right1,labels:["2"]}],size:{width:mA.width,height:mA.height},center:{x:mA.centerX,y:mA.centerY}}),{5:Pje,...Nje}=CI.primitives;function Lje(r){return typeof r=="object"}var xle=su({...CI,primitives:Object.values(Nje).filter(Lje)}),Oje={...xle,primitives:[...xle.primitives,Pje]},Uje={paths:{path11:{type:"path",points:[{x:-.5274831500000005,y:.031252300000000455},{x:-.30105415000000013,y:.031252300000000455}],color:"primary",fill:!1},"path11-5-5":{type:"path",points:[{x:.09765764999999949,y:.1295162000000003},{x:-.0011297500000011507,y:-.061970899999999496},{x:-.10778645000000164,y:.1295162000000003}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.2932119499999999,y:.031252300000000455},{x:.5339524499999997,y:.031252300000000455}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.021146249999999478,y:.4010973},bottom1:{type:"text",text:"{VAL}",x:-.00661455000000033,y:-.4010973}},refblocks:{left1:{x:-.5413984499999998,y:.030399499999999913},right1:{x:.54139845,y:.0313958999999997}},bounds:{minX:-.5695568909999997,maxX:.569556891,minY:-.4010973,maxY:.4010973,width:1.1391137819999997,height:.8021946,centerX:11102230246251565e-32,centerY:0},circles:{path1:{type:"circle",x:-.0037626500000000895,y:.03838059999999999,radius:.28854213,color:"primary",fill:!1}}},ble=kh(Uje).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),zje=su(ble),Fje={paths:{path11:{type:"path",points:[{x:-.5307178,y:0},{x:-.3042887999999997,y:0}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.2899773000000003,y:0},{x:.5307178000000001,y:0}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.17652089999999898,y:-.36197569999999946},bottom1:{type:"text",text:"{VAL}",x:-.009849199999999891,y:.43234960000000044},left1:{type:"text",text:"Wh",x:0,y:-.025}},refblocks:{left1:{x:-.5446330999999993,y:.000852800000000542},right1:{x:.5381638000000004,y:-.00014359999999924433}},bounds:{minX:-.5307178,maxX:.5307178000000001,minY:0,maxY:0,width:1.0614356000000003,height:1,centerX:5551115123125783e-32,centerY:0},circles:{path1:{type:"circle",x:-.006997299999999651,y:-.007128299999999532,radius:.28854213,color:"primary",fill:!1}}},{paths:Ije,texts:kje,bounds:vA,refblocks:Sle,circles:Bje}=Fje,RI=am({primitives:[...Object.values(Ije),...Object.values(Bje),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"},{...kje.left1,anchor:"center",y:.01,fontSize:.2}],ports:[{...Sle.left1,labels:["1"]},{...Sle.right1,labels:["2"]}],size:{width:vA.width,height:vA.height},center:{x:vA.centerX,y:vA.centerY}}),{5:Hje,...Vje}=RI.primitives;function jje(r){return typeof r=="object"}var Ele=su({...RI,primitives:Object.values(Vje).filter(jje)}),Gje={...Ele,primitives:[...Ele.primitives,Hje]},qje={paths:{path11:{type:"path",points:[{x:-.5307178,y:0},{x:-.3042887999999997,y:0}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.2899773000000003,y:0},{x:.5307178000000001,y:0}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.17652089999999898,y:-.36197569999999946},bottom1:{type:"text",text:"{VAL}",x:-.009849199999999891,y:.43234960000000044},left1:{type:"text",text:"W",x:0,y:-.025}},refblocks:{left1:{x:-.5446330999999993,y:.000852800000000542},right1:{x:.5381638000000004,y:-.00014359999999924433}},bounds:{minX:-.5307178,maxX:.5307178000000001,minY:0,maxY:0,width:1.0614356000000003,height:1,centerX:5551115123125783e-32,centerY:0},circles:{path1:{type:"circle",x:-.006997299999999651,y:-.007128299999999532,radius:.28854213,color:"primary",fill:!1}}},{paths:Yje,texts:Xje,bounds:yA,refblocks:wle,circles:Wje}=qje,AI=am({primitives:[...Object.values(Yje),...Object.values(Wje),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"},{...Xje.left1,anchor:"center",y:.01,fontSize:.3}],ports:[{...wle.left1,labels:["1"]},{...wle.right1,labels:["2"]}],size:{width:yA.width,height:yA.height},center:{x:yA.centerX,y:yA.centerY}}),{5:$je,...Zje}=AI.primitives;function Qje(r){return typeof r=="object"}var Tle=su({...AI,primitives:Object.values(Zje).filter(Qje)}),Kje={...Tle,primitives:[...Tle.primitives,$je]},Jje={paths:{path40:{type:"path",points:[{x:.14458890000000002,y:.04403629999999992},{x:-.1199943999999995,y:-.08825540000000043}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.1199943999999995,y:.17632800000000026},{x:.14458890000000002,y:.04403629999999992}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.1199943999999995,y:-.0882553999999991},{x:-.1199943999999995,y:.17632800000000026}],color:"primary",fill:!1},path43:{type:"path",points:[{x:.14458890000000002,y:.17632800000000026},{x:.14458890000000002,y:-.0882553999999991}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.12219909999999956,y:.04403629999999992},{x:-.5168693999999996,y:.04403629999999992}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.5233797000000002,y:.043951100000000354},{x:.1496715999999998,y:.043951100000000354}],color:"primary",fill:!1},"path43-8":{type:"path",points:[{x:.14339119999999994,y:.17681090000000044},{x:.07728679999999954,y:.17632089999999967}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.0050250999999996715,y:.27384530000000007},bottom1:{type:"text",text:"{VAL}",x:-.00011179999999977319,y:-.27384529999999985}},refblocks:{left1:{x:-.5191471000000001,y:.044920700000000924},right1:{x:.5191470999999999,y:.04389609999999999}},bounds:{minX:-.5473055410000001,maxX:.5473055409999998,minY:-.27384529999999985,maxY:.27384530000000007,width:1.094611082,height:.5476905999999999,centerX:-11102230246251565e-32,centerY:11102230246251565e-32},circles:{}},{paths:eGe,texts:Mle,bounds:gA,refblocks:Cle,circles:tGe}=Jje,Rle=am({primitives:[...Object.values(eGe),...Object.values(tGe),{...Mle.top1,anchor:"middle_bottom"},{...Mle.bottom1,anchor:"middle_top"}],ports:[{...Cle.left1,labels:["1"]},{...Cle.right1,labels:["2"]}],size:{width:gA.width,height:gA.height},center:{x:gA.centerX,y:gA.centerY}}),DI=su(Rle),nGe=DI.primitives.find(r=>r.type==="text"&&r.text==="{REF}"),rGe=DI.primitives.find(r=>r.type==="text"&&r.text==="{VAL}");nGe.anchor="middle_left",rGe.anchor="middle_right";var iGe=DI,w3={ac_voltmeter_horz:Tae,ac_voltmeter_vert:zIe,avalanche_diode_horz:Rae,avalanche_diode_vert:HIe,battery_horz:Pae,battery_vert:qIe,boxresistor_down:$Ie,boxresistor_left:KIe,boxresistor_right:tke,boxresistor_up:ike,capacitor_down:ske,capacitor_left:lke,capacitor_polarized_down:fke,capacitor_polarized_left:dke,capacitor_polarized_right:Vae,capacitor_polarized_up:mke,capacitor_right:vke,capacitor_up:_ke,constant_current_diode_horz:xke,constant_current_diode_vert:bke,crystal_4pin_horz:Yae,crystal_4pin_vert:Eke,crystal_horz:wke,crystal_vert:Tke,darlington_pair_transistor_horz:Mke,darlington_pair_transistor_vert:Cke,dc_ammeter_horz:wF,dc_ammeter_vert:zke,dc_voltmeter_horz:CF,dc_voltmeter_vert:Gke,diac_horz:Kae,diac_vert:Wke,diode_down:Zke,diode_left:Qke,diode_right:DR,diode_up:Kke,dpdt_switch_horz:noe,dpdt_switch_vert:nBe,dpst_switch_horz:soe,dpst_switch_vert:aBe,filled_diode_horz:uoe,filled_diode_vert:sBe,frequency_meter_horz:NF,frequency_meter_vert:mBe,fuse_horz:poe,fuse_vert:_Be,ground_horz:moe,ground_vert:TBe,gunn_diode_horz:MBe,gunn_diode_vert:CBe,icled_down:ABe,icled_left:DBe,icled_right:zR,icled_up:NBe,igbt_transistor_horz:yoe,igbt_transistor_vert:OBe,illuminated_push_button_normally_open_horz:_oe,illuminated_push_button_normally_open_vert:zBe,inductor_down:BBe,inductor_left:HBe,inductor_right:IF,inductor_up:woe,laser_diode_horz:Moe,laser_diode_vert:jBe,led_down:XBe,led_left:WBe,led_right:kR,led_up:ZBe,light_dependent_resistor_horz:Loe,light_dependent_resistor_vert:eHe,mosfet_depletion_normally_on_horz:Foe,mosfet_depletion_normally_on_vert:rHe,mushroom_head_normally_open_momentary_horz:Hoe,mushroom_head_normally_open_momentary_vert:sHe,n_channel_d_mosfet_transistor_horz:joe,n_channel_d_mosfet_transistor_vert:fHe,n_channel_e_mosfet_transistor_horz:Xoe,n_channel_e_mosfet_transistor_vert:mHe,njfet_transistor_horz:Qoe,njfet_transistor_vert:_He,npn_bipolar_transistor_horz:tse,npn_bipolar_transistor_vert:EHe,opamp_no_power_down:THe,opamp_no_power_left:MHe,opamp_no_power_right:XR,opamp_no_power_up:CHe,opamp_with_power_down:AHe,opamp_with_power_left:DHe,opamp_with_power_right:WR,opamp_with_power_up:PHe,p_channel_d_mosfet_transistor_horz:rse,p_channel_d_mosfet_transistor_vert:UHe,p_channel_e_mosfet_transistor_horz:sse,p_channel_e_mosfet_transistor_vert:kHe,photodiode_horz:use,photodiode_vert:VHe,pjfet_transistor_horz:pse,pjfet_transistor_vert:YHe,pnp_bipolar_transistor_horz:gse,pnp_bipolar_transistor_vert:ZHe,potentiometer_horz:bse,potentiometer_vert:eVe,potentiometer2_horz:wse,potentiometer2_vert:aVe,potentiometer3_down:sVe,potentiometer3_left:lVe,potentiometer3_right:eA,potentiometer3_up:cVe,power_factor_meter_horz:Rse,power_factor_meter_vert:hVe,push_button_normally_closed_momentary_horz:Nse,push_button_normally_closed_momentary_vert:yVe,push_button_normally_open_momentary_horz:Use,push_button_normally_open_momentary_vert:bVe,rectifier_diode_horz:Fse,rectifier_diode_vert:CVe,resonator_horz:Ise,resonator_vert:PVe,schottky_diode_horz:kse,schottky_diode_vert:UVe,silicon_controlled_rectifier_horz:Bse,silicon_controlled_rectifier_vert:IVe,SPDT_switch_horz:qse,SPDT_switch_vert:HVe,SPST_switch_horz:Wse,SPST_switch_vert:VVe,step_recovery_diode_horz:Qse,step_recovery_diode_vert:GVe,tachometer_horz:SI,tachometer_vert:KVe,triac_horz:ele,triac_vert:nje,tunnel_diode_horz:ale,tunnel_diode_vert:lje,unijunction_transistor_horz:sle,unijunction_transistor_vert:hje,var_meter_horz:dle,var_meter_vert:yje,varactor_diode_horz:mle,varactor_diode_vert:Eje,varistor_horz:gle,varistor_vert:Mje,varmeter_horz:CI,varmeter_vert:Oje,volt_meter_horz:ble,volt_meter_vert:zje,watt_hour_meter_horz:RI,watt_hour_meter_vert:Gje,wattmeter_horz:AI,wattmeter_vert:Kje,zener_diode_horz:Rle,zener_diode_vert:iGe};Object.fromEntries(Object.keys(w3).map(r=>[r,r]));var PI=(r,e={})=>{let t=r._internal_store;if(!t){t={counts:{}},r._internal_store=t;for(const i of r){const a=i.type,o=i[`${a}_id`];if(!o)continue;const s=Number.parseInt(o.split("_").pop());Number.isNaN(s)||(t.counts[a]=Math.max(t.counts[a]??0,s))}}return new Proxy({},{get:(i,a)=>a==="toArray"?()=>r:{get:o=>r.find(s=>s.type===a&&s[`${a}_id`]===o),getUsing:o=>{const s=Object.keys(o);if(s.length!==1)throw new Error("getUsing requires exactly one key, e.g. { pcb_component_id }");const l=s[0],c=l.replace("_id",""),u=r.find(h=>h.type===c&&h[l]===o[l]);return u?r.find(h=>h.type===a&&h[`${a}_id`]===u[`${a}_id`]):null},getWhere:o=>{const s=Object.keys(o);return r.find(l=>l.type===a&&s.every(c=>l[c]===o[c]))},list:o=>{const s=o?Object.keys(o):[];return r.filter(l=>l.type===a&&s.every(c=>l[c]===o[c]))},insert:o=>{var c;(c=t.counts)[a]??(c[a]=-1),t.counts[a]++;const s=t.counts[a],l={type:a,[`${a}_id`]:`${a}_${s}`,...o};return e.validateInserts&&(xie[a]??$z).parse(l),r.push(l),l},delete:o=>{const s=r.find(l=>l[`${a}_id`]===o);s&&r.splice(r.indexOf(s),1)},update:(o,s)=>{const l=r.find(c=>c.type===a&&c[`${a}_id`]===o);if(l)return Object.assign(l,s),l},select:o=>{if(a==="source_component")return r.find(s=>s.type==="source_component"&&s.name===o.replace(/\./g,""));if(a==="pcb_port"||a==="source_port"||a==="schematic_port"){const[s,l]=o.replace(/\./g,"").split(/[\s\>]+/),c=r.find(h=>h.type==="source_component"&&h.name===s);if(!c)return null;const u=r.find(h=>h.type==="source_port"&&h.source_component_id===c.source_component_id&&(h.name===l||(h.port_hints??[]).includes(l)));if(!u)return null;if(a==="source_port")return u;if(a==="pcb_port")return r.find(h=>h.type==="pcb_port"&&h.source_port_id===u.source_port_id);if(a==="schematic_port")return r.find(h=>h.type==="schematic_port"&&h.source_port_id===u.source_port_id)}}}})};PI.unparsed=PI;var $y=PI,BS={exports:{}},aGe=BS.exports,Ale;function oGe(){return Ale||(Ale=1,(function(){var r,e,t,n,i,a;typeof performance<"u"&&performance!==null&&performance.now?BS.exports=function(){return performance.now()}:typeof process<"u"&&process!==null&&process.hrtime?(BS.exports=function(){return(r()-i)/1e6},e=process.hrtime,r=function(){var o;return o=e(),o[0]*1e9+o[1]},n=r(),a=process.uptime()*1e9,i=n-a):Date.now?(BS.exports=function(){return Date.now()-t},t=Date.now()):(BS.exports=function(){return new Date().getTime()-t},t=new Date().getTime())}).call(aGe)),BS.exports}oGe();function sGe([r,e],[t,n],{lineThickness:i=0}={}){return i===0?Dle(r,e,t,n):lGe(r,e,t,n)<=i}function Dle(r,e,t,n){const i=_A(r,e,t),a=_A(r,e,n),o=_A(t,n,r),s=_A(t,n,e);return!!(i!==a&&o!==s||i===0&&xA(r,t,e)||a===0&&xA(r,n,e)||o===0&&xA(t,r,n)||s===0&&xA(t,e,n))}function _A(r,e,t){const n=(e.y-r.y)*(t.x-e.x)-(e.x-r.x)*(t.y-e.y);return n===0?0:n>0?1:2}function xA(r,e,t){return e.x<=Math.max(r.x,t.x)&&e.x>=Math.min(r.x,t.x)&&e.y<=Math.max(r.y,t.y)&&e.y>=Math.min(r.y,t.y)}function lGe(r,e,t,n){if(r.x===e.x&&r.y===e.y)return F8(r,t,n);if(t.x===n.x&&t.y===n.y)return F8(t,r,e);if(Dle(r,e,t,n))return 0;const i=[F8(r,t,n),F8(e,t,n),F8(t,r,e),F8(n,r,e)];return Math.min(...i)}function F8(r,e,t){const n=(t.x-e.x)**2+(t.y-e.y)**2;if(n===0)return Ple(r,e);let i=((r.x-e.x)*(t.x-e.x)+(r.y-e.y)*(t.y-e.y))/n;i=Math.max(0,Math.min(1,i));const a={x:e.x+i*(t.x-e.x),y:e.y+i*(t.y-e.y)};return Ple(r,a)}function Ple(r,e){const t=r.x-e.x,n=r.y-e.y;return Math.sqrt(t*t+n*n)}function Nle(r){const e=new Map;let t=0;function n(i){for(const[,o]of e)if(o.has(i))return o;const a=new Set;return e.set(`connectivity_net${t++}`,a),a}for(const i of r){let a=null;for(const o of i){if(!a)a=n(o);else if(!a.has(o)){const s=n(o);if(s!==a){for(const l of s)a.add(l);e.delete(Array.from(e.entries()).find(([,l])=>l===s)[0])}}a.add(o)}}return Object.fromEntries(Array.from(e.entries()).map(([i,a])=>[i,Array.from(a)]))}var bA=class{constructor(e){ni(this,"netMap");ni(this,"idToNetMap");this.netMap=e,this.idToNetMap={};for(const[t,n]of Object.entries(e))for(const i of n)this.idToNetMap[i]=t}addConnections(e){for(const t of e){const n=new Set;for(const a of t){const o=this.idToNetMap[a];o&&n.add(o)}let i;if(n.size===0)i=`connectivity_net${Object.keys(this.netMap).length}`,this.netMap[i]=[];else if(n.size===1)i=n.values().next().value??`connectivity_net${Object.keys(this.netMap).length}`;else{i=n.values().next().value??`connectivity_net${Object.keys(this.netMap).length}`;for(const a of n)if(a!==i){this.netMap[i].push(...this.netMap[a]),this.netMap[a]=this.netMap[i];for(const o of this.netMap[i])this.idToNetMap[o]=i}}for(const a of t)this.netMap[i].includes(a)||this.netMap[i].push(a),this.idToNetMap[a]=i}}getIdsConnectedToNet(e){return this.netMap[e]||[]}getNetConnectedToId(e){return this.idToNetMap[e]}areIdsConnected(e,t){const n=this.getNetConnectedToId(e),i=this.getNetConnectedToId(t);return n===i||i===e||i===e}areAllIdsConnected(e){const t=this.getNetConnectedToId(e[0]);for(const n of e){const i=this.getNetConnectedToId(n);if(i===void 0||i!==t)return!1}return!0}},Lle=r=>{const e=[];for(const n of r)if(n.type==="source_trace")e.push([n.source_trace_id,...n.connected_source_port_ids??[],...n.connected_source_net_ids??[]].filter(Boolean));else if(n.type==="pcb_port"){const{pcb_port_id:i,source_port_id:a}=n;a&&i&&e.push([a,i])}else if(n.type==="pcb_smtpad"){const{pcb_smtpad_id:i,pcb_port_id:a}=n;a&&i&&e.push([i,a])}else if(n.type==="pcb_plated_hole"){const{pcb_plated_hole_id:i,pcb_port_id:a}=n;a&&i&&e.push([i,a])}else if(n.type==="pcb_trace"){const{pcb_trace_id:i,source_trace_id:a}=n;a&&i&&e.push([i,a])}const t=Nle(e);return new bA(t)},Ole=class{constructor(r){ni(this,"circuitJson");ni(this,"traceIdToElm");ni(this,"portIdToElm");ni(this,"connMap");this.circuitJson=r||[],this.traceIdToElm=new Map,this.portIdToElm=new Map,r?(this._buildTraceMap(),this._buildPortMap(),this.connMap=this._buildTraceConnectivityMap()):this.connMap=new bA({})}_buildPortMap(){for(const r of this.circuitJson)r.type==="pcb_port"&&this.portIdToElm.set(r.pcb_port_id,r)}_buildTraceMap(){for(const r of this.circuitJson)r.type==="pcb_trace"&&this.traceIdToElm.set(r.pcb_trace_id,r)}_buildTraceConnectivityMap(){const r=[],e=Array.from(this.traceIdToElm.keys());for(let t=0;t<e.length;t++)for(let n=t+1;n<e.length;n++){const i=this.traceIdToElm.get(e[t]),a=this.traceIdToElm.get(e[n]);this._arePcbTracesConnected(i,a)&&r.push([e[t],e[n]])}for(const t of this.portIdToElm.values())for(const n of this.traceIdToElm.values())for(const i of n.route)i.route_type==="wire"&&(i.start_pcb_port_id===t.pcb_port_id?r.push([t.pcb_port_id,n.pcb_trace_id]):i.end_pcb_port_id===t.pcb_port_id&&r.push([n.pcb_trace_id,t.pcb_port_id]));return new bA(Nle(r))}addTrace(r){this.traceIdToElm.set(r.pcb_trace_id,r);const e=[];for(const t of r.route)t.route_type==="wire"&&(t.start_pcb_port_id&&e.push([t.start_pcb_port_id,r.pcb_trace_id]),t.end_pcb_port_id&&e.push([t.end_pcb_port_id,r.pcb_trace_id]));this.connMap.addConnections(e)}_arePcbTracesConnected(r,e){for(let t=0;t<r.route.length-1;t++){const n=r.route[t],i=r.route[t+1];if(n.route_type==="wire"&&i.route_type==="wire")for(let a=0;a<e.route.length-1;a++){const o=e.route[a],s=e.route[a+1];if(o.route_type!=="wire"||s.route_type!=="wire")continue;if(sGe([n,i],[o,s],{lineThickness:(n.width+o.width)/2}))return!0}}return!1}areTracesConnected(r,e){return this.connMap.areIdsConnected(r,e)}getAllTracesConnectedToTrace(r){const e=this.connMap.getNetConnectedToId(r);return e?this.connMap.getIdsConnectedToNet(e).filter(t=>this.traceIdToElm.has(t)).map(t=>this.traceIdToElm.get(t)):[]}getAllTracesConnectedToPort(r){const e=this.connMap.getNetConnectedToId(r);return e?this.connMap.getIdsConnectedToNet(e).filter(t=>this.traceIdToElm.has(t)).map(t=>this.traceIdToElm.get(t)):[]}};function Ule(r){const e=r.width/2,t=r.height/2;return{minX:r.center.x-e,maxX:r.center.x+e,minY:r.center.y-t,maxY:r.center.y+t}}function cGe(r,e){const t=Ule(r),n=Ule(e),i=Math.max(t.minX-n.maxX,n.minX-t.maxX,0),a=Math.max(t.minY-n.maxY,n.minY-t.maxY,0),o={x:0,y:0},s={x:0,y:0};return i===0&&a===0?{distance:0,pointA:r.center,pointB:e.center}:(o.x=SA(r.center.x,n.minX,n.maxX),o.y=SA(r.center.y,n.minY,n.maxY),s.x=SA(e.center.x,t.minX,t.maxX),s.y=SA(e.center.y,t.minY,t.maxY),{distance:Math.hypot(o.x-s.x,o.y-s.y),pointA:o,pointB:s})}function SA(r,e,t){return Math.max(e,Math.min(t,r))}function uGe(r,e){let t=Number.POSITIVE_INFINITY,n={x:0,y:0},i={x:0,y:0};for(const a of r)for(const o of e){const{distance:s,pointA:l,pointB:c}=cGe(a,o);s<t&&(t=s,n=l,i=c)}return{pointA:n,pointB:i,distance:t}}var HS=(r,e)=>Math.abs(r.x-e.x)+Math.abs(r.y-e.y),zle=(r,e)=>{const t=e.x-r.x,n=e.y-r.y;return Math.abs(t)>Math.abs(n)?{dx:Math.sign(t),dy:0}:{dx:0,dy:Math.sign(n)}},Fle=(r,e,t)=>Math.abs(r.x-e.x)*Math.abs(t.dx)+Math.abs(r.y-e.y)*Math.abs(t.dy),Ile=(r,e=.1)=>`${Math.round(r.x/e)},${Math.round(r.y/e)}`,kle=(r,e)=>Math.abs(r-e)<1e-4,Ble=(r,e,{viaDiameter:t=.5}={})=>{const n=[];for(let i=0;i<r.length-1;i++){const[a,o]=[r[i],r[i+1]],s=i-1>=0?r[i-1]:null,l=kle(a.y,o.y),c=kle(a.x,o.x);if(!l&&!c)throw new Error(`getObstaclesFromTrace currently only supports horizontal and vertical traces (not diagonals) Conflicting trace: ${e}, start: (${a.x}, ${a.y}), end: (${o.x}, ${o.y})`);const u={type:"rect",layers:[a.layer],center:{x:(a.x+o.x)/2,y:(a.y+o.y)/2},width:l?Math.abs(a.x-o.x):.1,height:c?Math.abs(a.y-o.y):.1,connectedTo:[e]};if(n.push(u),s&&s.layer===a.layer&&a.layer!==o.layer){const h={type:"rect",layers:[a.layer,o.layer],center:{x:a.x,y:a.y},connectedTo:[e],width:t,height:t};n.push(h)}}return n},Hle=class{constructor(r){ni(this,"obstacles");ni(this,"GRID_STEP",.1);this.obstacles=r.map(e=>({...e,left:e.center.x-e.width/2,right:e.center.x+e.width/2,top:e.center.y+e.height/2,bottom:e.center.y-e.height/2}))}getObstacleAt(r,e,t){t??(t=this.GRID_STEP);for(const n of this.obstacles){const i=n.width/2+t,a=n.height/2+t;if(r>=n.center.x-i&&r<=n.center.x+i&&e>=n.center.y-a&&e<=n.center.y+a)return n}return null}isObstacleAt(r,e,t){return this.getObstacleAt(r,e,t)!==null}getDirectionDistancesToNearestObstacle(r,e){const{GRID_STEP:t}=this,n={left:1/0,top:1/0,bottom:1/0,right:1/0};for(const i of this.obstacles)if(i.type==="rect"){const a=i.center.x-i.width/2-t,o=i.center.x+i.width/2+t,s=i.center.y+i.height/2+t,l=i.center.y-i.height/2-t;e>=l&&e<=s&&r>a&&(n.left=Math.min(n.left,r-o)),e>=l&&e<=s&&r<o&&(n.right=Math.min(n.right,a-r)),r>=a&&r<=o&&e<s&&(n.top=Math.min(n.top,l-e)),r>=a&&r<=o&&e>l&&(n.bottom=Math.min(n.bottom,e-s))}return n}getOrthoDirectionCollisionInfo(r,e,{margin:t=0}={}){const{x:n,y:i}=r,{dx:a,dy:o}=e;let s=1/0,l=null;for(const c of this.obstacles){const u=c.left-t,h=c.right+t,g=c.top+t,_=c.bottom-t;let b=null;a===1&&o===0?i>_&&i<g&&n<c.left&&(b=c.left-n):a===-1&&o===0?i>_&&i<g&&n>c.right&&(b=n-c.right):a===0&&o===1?n>u&&n<h&&i<c.bottom&&(b=c.bottom-i):a===0&&o===-1&&n>u&&n<h&&i>c.top&&(b=i-c.top),b!==null&&b<s&&(s=b,l=c)}return{dx:a,dy:o,wallDistance:s,obstacle:l}}getObstaclesOverlappingRegion(r){const e=[];for(const t of this.obstacles){const{left:n,right:i,top:a,bottom:o}=t;n<=r.maxX&&i>=r.minX&&a<=r.maxY&&o>=r.minY&&e.push(t)}return e}};function fGe(r){if(r.length<4)return r;const e=[{...r[0]}];let t=r[0].layer;for(let n=1;n<r.length;n++){const i={start:r[n-1],end:r[n]},a=r[n].route_type==="via"||r[n-1].route_type==="via";if(r[n].layer!==t||a){e.push({...r[n]}),t=r[n].layer;continue}let o=!1,s=null,l=-1;for(let u=0;u<e.length-1;u++){const h={start:e[u],end:e[u+1]};if(h.start.layer===i.start.layer&&h.start.layer===i.start.layer){const g=dGe(h,i);if(g){o=!0,s={...g,layer:t},l=u;break}}}o&&s&&(e.splice(l+1),e.push(s));const c=e[e.length-1];(c.x!==r[n].x||c.y!==r[n].y)&&e.push(r[n])}return e}function dGe(r,e){if(r.start.x===r.end.x&&e.start.x===e.end.x||r.start.y===r.end.y&&e.start.y===e.end.y)return null;let t;if(r.start.x===r.end.x){const n=r.start.x,i=e.start.y;t={...r.start,x:n,y:i}}else{const n=e.start.x,i=r.start.y;t={...r.start,x:n,y:i}}return Vle(t,r)&&Vle(t,e)?t:null}function Vle(r,e){return r.x>=Math.min(e.start.x,e.end.x)&&r.x<=Math.max(e.start.x,e.end.x)&&r.y>=Math.min(e.start.y,e.end.y)&&r.y<=Math.max(e.start.y,e.end.y)}function hGe(r){const e=[r[0]];for(let t=1;t<r.length-1;t++){const[n,i,a]=[r[t-1],r[t],r[t+1]];e.push(i),!(i.route_type!=="wire"||n.route_type!=="wire"||a.route_type!=="wire")&&n.layer===i.layer&&i.layer!==a.layer&&e.push({route_type:"via",from_layer:i.layer,to_layer:a.layer,x:i.x,y:i.y})}return e.push(r[r.length-1]),e}g2("autorouter:shortenPathWithShortcuts");function pGe(r,e){if(r.length<=2)return r;const t=[r[0]];for(let n=1;n<r.length;n++){const i={start:t[t.length-1],end:r[n]};let a=-1;const o=i.start.x===i.end.x,s=i.start.y===i.end.y;for(let l=n+1;l<r.length;l++){if(l<=a)continue;const c={start:r[l],end:r[l+1]};if(!c.end)continue;const u=c.start.x===c.end.x,h=c.start.y===c.end.y,g=o&&u,_=s&&h;if(_&&g||!(g||_))continue;let T=!1;const C=Math.min(i.start.x,i.end.x),A=Math.max(i.start.x,i.end.x),L=Math.min(c.start.x,c.end.x),U=Math.max(c.start.x,c.end.x),j=Math.min(i.start.y,i.end.y),Z=Math.max(i.start.y,i.end.y),ee=Math.min(c.start.y,c.end.y),$=Math.max(c.start.y,c.end.y);if(_?T=C<=U&&A>=L:g&&(T=j<=$&&Z>=ee),!T)continue;const oe=[],ae=t[t.length-1],ce=r[l+2];if(!ce)continue;_&&L<A&&ce.x===L&&oe.push({x:L,y:i.start.y,layer:i.start.layer}),_&&U>C&&ce.x===U&&oe.push({x:U,y:i.start.y,layer:i.start.layer}),g&&ee<Z&&ce.y===ee&&oe.push({x:i.start.x,y:ee,layer:i.start.layer}),g&&$>j&&ce.y===$&&oe.push({x:i.start.x,y:$,layer:i.start.layer});let me=null;for(const _e of oe)if(!(e(ae,_e)||e(ce,_e))){me=_e;break}if(me){t.push(me),n=l+1,a=l+1;break}}a===-1&&t.push(r[n])}return t[t.length-1]!==r[r.length-1]&&t.push(r[r.length-1]),t}var VS=g2("autorouting-dataset:astar"),jle=class{constructor(r){ni(this,"openSet",[]);ni(this,"closedSet",new Set);ni(this,"debug",!1);ni(this,"debugSolutions");ni(this,"debugMessage",null);ni(this,"debugTraceCount",0);ni(this,"input");ni(this,"obstacles");ni(this,"allObstacles");ni(this,"startNode");ni(this,"goalPoint");ni(this,"GRID_STEP");ni(this,"OBSTACLE_MARGIN");ni(this,"MAX_ITERATIONS");ni(this,"isRemovePathLoopsEnabled");ni(this,"isShortenPathWithShortcutsEnabled");ni(this,"GREEDY_MULTIPLIER",1.1);ni(this,"iterations",-1);this.input=r.input,this.allObstacles=r.input.obstacles,this.startNode=r.startNode,this.goalPoint=r.goalPoint?{l:0,...r.goalPoint}:void 0,this.GRID_STEP=r.GRID_STEP??.1,this.OBSTACLE_MARGIN=r.OBSTACLE_MARGIN??.15,this.MAX_ITERATIONS=r.MAX_ITERATIONS??100,this.debug=r.debug??VS.enabled,this.isRemovePathLoopsEnabled=r.isRemovePathLoopsEnabled??!1,this.isShortenPathWithShortcutsEnabled=r.isShortenPathWithShortcutsEnabled??!1,this.debug&&(VS.enabled=!0),VS.enabled&&(this.debugSolutions={},this.debugMessage="")}getNeighbors(r){return[]}isSameNode(r,e){return HS(r,e)<this.GRID_STEP}computeG(r,e){return r.g+HS(r,e)}computeH(r){return HS(r,this.goalPoint)}getNodeName(r){return Ile(r,this.GRID_STEP)}solveOneStep(){this.iterations+=1;const{openSet:r,closedSet:e,GRID_STEP:t,goalPoint:n}=this;r.sort((s,l)=>s.f-l.f);const i=r.shift();if(this.computeH(i)<=t*2)return{solved:!0,current:i,newNeighbors:[]};this.closedSet.add(this.getNodeName(i));let o=[];for(const s of this.getNeighbors(i)){if(e.has(this.getNodeName(s)))continue;const l=this.computeG(i,s),c=this.openSet.find(u=>this.isSameNode(u,s));if(!c||l<c.g){const u=this.computeH(s),h=l+u*this.GREEDY_MULTIPLIER,g={...s,g:l,h:u,f:h,obstacleHit:s.obstacleHit??void 0,manDistFromParent:HS(i,s),nodesInPath:i.nodesInPath+1,parent:i,enterMarginCost:s.enterMarginCost,travelMarginCostFactor:s.travelMarginCostFactor};r.push(g),o.push(g)}}return VS.enabled&&(r.sort((s,l)=>s.f-l.f),this.drawDebugSolution({current:i,newNeighbors:o})),{solved:!1,current:i,newNeighbors:o}}getStartNode(r){return{x:r.pointsToConnect[0].x,y:r.pointsToConnect[0].y,manDistFromParent:0,f:0,g:0,h:0,nodesInPath:0,parent:null}}layerToIndex(r){return 0}indexToLayer(r){return"top"}preprocessConnectionBeforeSolving(r){return r}solveConnection(r){if(r.pointsToConnect.length>2)throw new Error("GeneralizedAstarAutorouter doesn't currently support 2+ points in a connection");r=this.preprocessConnectionBeforeSolving(r);const{pointsToConnect:e}=r;for(this.iterations=0,this.closedSet=new Set,this.startNode=this.getStartNode(r),this.goalPoint={...e[e.length-1],l:this.layerToIndex(e[e.length-1].layer)},this.openSet=[this.startNode];this.iterations<this.MAX_ITERATIONS;){const{solved:t,current:n}=this.solveOneStep();if(t){let i=[],a=n;for(;a;){const o=a.l;i.unshift({x:a.x,y:a.y,layer:o!==void 0?this.indexToLayer(o):e[0].layer}),a=a.parent}return VS.enabled&&(this.debugMessage+=`t${this.debugTraceCount}: ${this.iterations} iterations
|
|
637
637
|
`),this.isRemovePathLoopsEnabled&&(i=fGe(i)),this.isShortenPathWithShortcutsEnabled&&(i=pGe(i,(o,s)=>{if(o.x===s.x&&o.y===s.y)return!1;const l=this.obstacles.getOrthoDirectionCollisionInfo({x:o.x,y:o.y,l:this.layerToIndex(o.layer)??0},{dx:Math.sign(s.x-o.x),dy:Math.sign(s.y-o.y),dl:0},{margin:.05}),c=Math.sqrt((o.x-s.x)**2+(o.y-s.y)**2);return l.wallDistance<c})),{solved:!0,route:i,connectionName:r.name}}if(this.openSet.length===0)break}return VS.enabled&&(this.debugMessage+=`t${this.debugTraceCount}: ${this.iterations} iterations (failed)
|
|
638
|
-
`),{solved:!1,connectionName:r.name}}createObstacleList({dominantLayer:r,connection:e,obstaclesFromTraces:t}){return new Hle(this.allObstacles.filter(n=>!n.connectedTo.includes(e.name)).filter(n=>n.layers.includes(r)).concat(t??[]))}postprocessConnectionSolveResult(r,e){return e}solve(){const r=[],e=[];this.debugTraceCount=0;for(const t of this.input.connections){const n=t.pointsToConnect[0].layer??"top";this.debugTraceCount+=1,this.obstacles=this.createObstacleList({dominantLayer:n,connection:t,obstaclesFromTraces:e});let i=this.solveConnection(t);i=this.postprocessConnectionSolveResult(t,i),r.push(i),VS.enabled&&this.drawDebugTraceObstacles(e),i.solved&&e.push(...Ble(i.route.map(a=>({x:a.x,y:a.y,layer:a.layer??n})),t.name))}return r}solveAndMapToTraces(){return this.solve().flatMap(e=>e.solved?[{type:"pcb_trace",pcb_trace_id:`pcb_trace_for_${e.connectionName}`,route:hGe(e.route.map(t=>({route_type:"wire",x:t.x,y:t.y,width:this.input.minTraceWidth,layer:t.layer})))}]:[])}getDebugGroup(){const r=`t${this.debugTraceCount}_iter[${this.iterations-1}]`;return this.iterations<30||this.iterations<100&&this.iterations%10===0||this.iterations<1e3&&this.iterations%100===0||!this.debugSolutions?r:null}drawDebugTraceObstacles(r){const{debugTraceCount:e,debugSolutions:t}=this;for(const n in t)n.startsWith(`t${e}_`)&&t[n].push(...r.map((i,a)=>({type:"pcb_smtpad",pcb_component_id:"",layer:i.layers[0],width:i.width,shape:"rect",x:i.center.x,y:i.center.y,pcb_smtpad_id:`trace_obstacle_${a}`,height:i.height})))}drawDebugSolution({current:r,newNeighbors:e}){const t=this.getDebugGroup();if(!t)return;const{openSet:n,debugTraceCount:i,debugSolutions:a}=this;a[t]??(a[t]=[]);const o=a[t];o.push({type:"pcb_fabrication_note_text",pcb_fabrication_note_text_id:`debug_note_${r.x}_${r.y}`,font:"tscircuit2024",font_size:.25,text:"X"+(r.l!==void 0?r.l:""),pcb_component_id:"",layer:"top",anchor_position:{x:r.x,y:r.y},anchor_alignment:"center"});for(let s=0;s<n.length;s++){const l=n[s];o.push({type:"pcb_fabrication_note_path",pcb_component_id:"",pcb_fabrication_note_path_id:`note_path_${l.x}_${l.y}`,layer:"top",route:[[0,.05],[.05,0],[0,-.05],[-.05,0],[0,.05]].map(([c,u])=>({x:l.x+c,y:l.y+u})),stroke_width:.01}),o.push({type:"pcb_fabrication_note_text",pcb_fabrication_note_text_id:`debug_note_${l.x}_${l.y}`,font:"tscircuit2024",font_size:.03,text:s.toString(),pcb_component_id:"",layer:"top",anchor_position:{x:l.x,y:l.y},anchor_alignment:"center"})}if(r.parent){const s=[];let l=r;for(;l;)s.unshift(l),l=l.parent;o.push({type:"pcb_fabrication_note_path",pcb_component_id:"",pcb_fabrication_note_path_id:`note_path_${r.x}_${r.y}`,layer:"top",route:s,stroke_width:.01})}}},mGe=g2("autorouting-dataset:infinite-grid-ijump-astar:get-distance-to-overcome-obstacle");function NI({node:r,travelDir:e,wallDir:t,obstacle:n,obstacles:i,obstaclesInRow:a=0,OBSTACLE_MARGIN:o=.15,SHOULD_DETECT_CONJOINED_OBSTACLES:s=!1,MAX_CONJOINED_OBSTACLES:l=20}){let c;if(e.dx===0?e.dy>0?c=n.center.y+n.height/2-r.y:c=r.y-(n.center.y-n.height/2):e.dx>0?c=n.center.x+n.width/2-r.x:c=r.x-(n.center.x-n.width/2),c+=o,s&&a<l){const u=i.getObstacleAt(r.x+e.dx*c+t.dx*(t.wallDistance+.001),r.y+e.dy*c+t.dy*(t.wallDistance+.001));if(u===n)return c;if(u&&u.type==="rect"){const h=e.dy===0,g=h?n.height:n.width;if((h?u.height:u.width)>g)return mGe("next obstacle on path is bigger, not trying to overcome it"),c;const b=NI({node:{x:r.x+e.dx*c,y:r.y+e.dy*c},travelDir:e,wallDir:t,obstacle:u,obstacles:i,obstaclesInRow:a+1,SHOULD_DETECT_CONJOINED_OBSTACLES:s,MAX_CONJOINED_OBSTACLES:l,OBSTACLE_MARGIN:o});c+=b}}return c}var vGe=class extends jle{constructor(){super(...arguments);ni(this,"MAX_ITERATIONS",200)}getNeighbors(e){const t=this.obstacles,n=this.goalPoint;let i;e.parent?i=zle(e.parent,e):i=zle(e,n);const a=[{dx:0,dy:1},{dx:1,dy:0},{dx:0,dy:-1},{dx:-1,dy:0}].filter(s=>{var l;return s.dx===i.dx*-1&&s.dy===i.dy*-1?!1:!(s.dx===i.dx&&s.dy===i.dy&&((l=e.parent)!=null&&l.obstacleHit))}).map(s=>t.getOrthoDirectionCollisionInfo(e,s,{margin:this.OBSTACLE_MARGIN})).filter(s=>s.wallDistance>=this.OBSTACLE_MARGIN),o=[];for(const s of a){let l=null;e!=null&&e.obstacleHit&&(l=NI({node:e,travelDir:s,wallDir:{...i,wallDistance:this.OBSTACLE_MARGIN},obstacle:e.obstacleHit,obstacles:t,OBSTACLE_MARGIN:this.OBSTACLE_MARGIN,SHOULD_DETECT_CONJOINED_OBSTACLES:!0}));const c=Fle(e,n,s),u=(s.dx===0||Math.sign(n.x-e.x)===s.dx)&&(s.dy===0||Math.sign(n.y-e.y)===s.dy);c<s.wallDistance&&c>0&&u?o.push({...s,travelDistance:c}):l!==null&&l<s.wallDistance?o.push({...s,travelDistance:l}):s.wallDistance!==1/0&&o.push({...s,travelDistance:s.wallDistance-this.OBSTACLE_MARGIN})}return o.filter(s=>!t.isObstacleAt(e.x+s.dx*s.travelDistance,e.y+s.dy*s.travelDistance)).map(s=>({x:e.x+s.dx*s.travelDistance,y:e.y+s.dy*s.travelDistance,obstacleHit:s.obstacle}))}};function yGe(r,e=4){const{center:t,width:n,height:i,rotation:a}=r,o=[],s=a*Math.PI/180,l=Math.cos(s),c=Math.sin(s),u=(a%360+360)%360;if(i<=n?u>=45&&u<135||u>=225&&u<315:u>=135&&u<225||u>=315||u<45){const g=n/e;for(let _=0;_<e;_++){const b=(_-e/2+.5)*g,T=-b*l,C=-b*c,A=g*1.1,L=Math.abs(i*l)+Math.abs(g*c);o.push({center:{x:t.x+T,y:t.y+C},width:A,height:L})}}else{const g=i/e;for(let _=0;_<e;_++){const b=(_-e/2+.5)*g,T=-b*c,C=b*l,A=Math.abs(n*l)+Math.abs(g*c),L=g*1.1;o.push({center:{x:t.x+T,y:t.y+C},width:A,height:L})}}return o}var EA=["top","inner1","inner2","bottom"],LI=(r,e)=>{const t=i=>e?i.concat(i.map(a=>e==null?void 0:e.getNetConnectedToId(a)).filter(Boolean)):i,n=[];for(const i of r)if(i.type==="pcb_smtpad"){if(i.shape==="circle")n.push({type:"oval",layers:[i.layer],center:{x:i.x,y:i.y},width:i.radius*2,height:i.radius*2,connectedTo:t([i.pcb_smtpad_id])});else if(i.shape==="rect")n.push({type:"rect",layers:[i.layer],center:{x:i.x,y:i.y},width:i.width,height:i.height,connectedTo:t([i.pcb_smtpad_id])});else if(i.shape==="rotated_rect"){const a={center:{x:i.x,y:i.y},width:i.width,height:i.height,rotation:i.ccw_rotation},o=yGe(a);for(const s of o)n.push({type:"rect",layers:[i.layer],center:s.center,width:s.width,height:s.height,connectedTo:t([i.pcb_smtpad_id])})}}else if(i.type==="pcb_keepout")i.shape==="circle"?n.push({type:"oval",layers:i.layers,center:{x:i.center.x,y:i.center.y},width:i.radius*2,height:i.radius*2,connectedTo:[]}):i.shape==="rect"&&n.push({type:"rect",layers:i.layers,center:{x:i.center.x,y:i.center.y},width:i.width,height:i.height,connectedTo:[]});else if(i.type==="pcb_hole")i.hole_shape==="oval"?n.push({type:"oval",center:{x:i.x,y:i.y},width:i.hole_width,height:i.hole_height,connectedTo:[]}):i.hole_shape==="square"?n.push({type:"rect",layers:EA,center:{x:i.x,y:i.y},width:i.hole_diameter,height:i.hole_diameter,connectedTo:[]}):(i.hole_shape==="round"||i.hole_shape==="circle")&&n.push({type:"rect",layers:EA,center:{x:i.x,y:i.y},width:i.hole_diameter,height:i.hole_diameter,connectedTo:[]});else if(i.type==="pcb_plated_hole")i.shape==="circle"?n.push({type:"oval",layers:EA,center:{x:i.x,y:i.y},width:i.outer_diameter,height:i.outer_diameter,connectedTo:t([i.pcb_plated_hole_id])}):(i.shape==="oval"||i.shape==="pill")&&n.push({type:"oval",layers:EA,center:{x:i.x,y:i.y},width:i.outer_width,height:i.outer_height,connectedTo:t([i.pcb_plated_hole_id])});else if(i.type==="pcb_trace"){const a=Ble(i.route.map(o=>({x:o.x,y:o.y,layer:"layer"in o?o.layer:o.from_layer})),i.source_trace_id);n.push(...a)}else i.type==="pcb_via"&&n.push({type:"rect",layers:i.layers,center:{x:i.x,y:i.y},connectedTo:[],width:i.outer_diameter,height:i.outer_diameter});return n};function Gle(r){const{pcbConnMap:e,goalElementId:t}=r;if(!t.startsWith("pcb_port_"))throw new Error(`Currently alternative goal boxes must have a goal id with prefix "pcb_port_" (got ${t})`);const n=e.getAllTracesConnectedToPort(t);return LI(n).map(i=>({...i,connectedTo:[t]}))}var qle=r=>{let{connection:e,pcbConnMap:t}=r;if(e.pointsToConnect.length!==2)throw new Error(`Connection must have exactly 2 points for alternative goal boxes (got ${e.pointsToConnect.length})`);const[n,i]=e.pointsToConnect;if(!n.pcb_port_id||!i.pcb_port_id)throw new Error(`Connection points must have pcb_port_id for alternative goal box calculation (got ${n.pcb_port_id} and ${i.pcb_port_id})`);const a=Gle({goalElementId:n.pcb_port_id,pcbConnMap:t}).concat([{center:n,width:.01,height:.01,connectedTo:[n.pcb_port_id],layers:[n.layer],type:"rect"}]),o=Gle({goalElementId:i.pcb_port_id,pcbConnMap:t}).concat([{center:i,width:.01,height:.01,connectedTo:[i.pcb_port_id],layers:[i.layer],type:"rect"}]);if(a.length<=1&&o.length<=1)return{...e,startPoint:n,endPoint:i,goalBoxes:[]};const s=uGe(a,o);let l,c,u;return a.length>=o.length?(l={...i,...s.pointB},c={...n,...s.pointA},u=a):(l={...n,...s.pointA},c={...i,...s.pointB},u=o),{startPoint:l,endPoint:c,goalBoxes:u,name:e.name,pointsToConnect:[l,c]}},gGe=(r,e={})=>{const t={minTraceWidth:.1};t.layerCount=e.layerCount??1,t.obstacles=LI(r,e.connMap),t.connections=[];for(const i of r)if(i.type==="source_trace"){let a={name:i.source_trace_id,pointsToConnect:i.connected_source_port_ids.map(o=>{var l;const s=$y(r).pcb_port.getWhere({source_port_id:o});if(!s)throw new Error(`Could not find pcb_port for source_port_id "${o}"`);return{x:s.x,y:s.y,layer:((l=s.layers)==null?void 0:l[0])??"top",pcb_port_id:s.pcb_port_id}})};if(e.optimizeWithGoalBoxes){const o=new Ole(r);a=qle({connection:a,pcbConnMap:o})}t.connections.push(a),_Ge(t.obstacles,a.pointsToConnect,a.name)}const n={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0};for(const i of t.obstacles)n.minX=Math.min(n.minX,i.center.x-i.width/2),n.maxX=Math.max(n.maxX,i.center.x+i.width/2),n.minY=Math.min(n.minY,i.center.y-i.height/2),n.maxY=Math.max(n.maxY,i.center.y+i.height/2);for(const i of t.connections)for(const a of i.pointsToConnect)n.minX=Math.min(n.minX,a.x),n.maxX=Math.max(n.maxX,a.x),n.minY=Math.min(n.minY,a.y),n.maxY=Math.max(n.maxY,a.y);return t.bounds=n,t},_Ge=(r,e,t)=>{for(const n of e)for(const i of r)xGe(n,i)&&i.connectedTo.push(t)};function xGe(r,e){const t=e.width/2,n=e.height/2;if(e.type==="rect")return r.x>=e.center.x-t&&r.x<=e.center.x+t&&r.y>=e.center.y-n&&r.y<=e.center.y+n;if(e.type==="oval"){const i=(r.x-e.center.x)/t,a=(r.y-e.center.y)/n;return i*i+a*a<=1}return!1}function Yle(r,e){const t=e.x>r.x?1:e.x<r.x?-1:0,n=e.y>r.y?1:e.y<r.y?-1:0,i=e.l>r.l?1:e.l<r.l?-1:0;return{dx:t,dy:n,dl:i}}var OI={1:["top"],2:["top","bottom"],4:["top","inner1","inner2","bottom"]},bGe=r=>OI[r];function Xle(r,e){const n=OI[r].indexOf(e);if(n===-1)throw new Error(`Invalid layer for getLayerIndex (for layerCount === ${r}): "${e}"`);return n}function SGe(r,e){const n=OI[r][e];if(!n)throw new Error(`Invalid index for indexToLayer (for layerCount === ${r}): "${e}"`);return n}var EGe=class extends Hle{constructor(e,t){super([]);ni(this,"obstacles");ni(this,"GRID_STEP",.1);ni(this,"layerCount");this.layerCount=e;const n=bGe(e);this.obstacles=t.flatMap(i=>i.layers.filter(a=>n.includes(a)).map(a=>({...i,left:i.center.x-i.width/2,right:i.center.x+i.width/2,top:i.center.y+i.height/2,bottom:i.center.y-i.height/2,l:Xle(e,a)})))}getObstacleAt(e,t,n,i){i??(i=this.GRID_STEP);for(const a of this.obstacles){if(a.l!==n)continue;const o=a.width/2+i,s=a.height/2+i;if(e>=a.center.x-o&&e<=a.center.x+o&&t>=a.center.y-s&&t<=a.center.y+s)return a}return null}isObstacleAt(e,t,n,i){return this.getObstacleAt(e,t,n,i)!==null}getDirectionDistancesToNearestObstacle3d(e,t,n){const{GRID_STEP:i}=this,a={left:1/0,top:1/0,bottom:1/0,right:1/0};for(const o of this.obstacles)if(o.l===n&&o.type==="rect"){const s=o.center.x-o.width/2-i,l=o.center.x+o.width/2+i,c=o.center.y+o.height/2+i,u=o.center.y-o.height/2-i;t>=u&&t<=c&&e>s&&(a.left=Math.min(a.left,e-l)),t>=u&&t<=c&&e<l&&(a.right=Math.min(a.right,s-e)),e>=s&&e<=l&&t<c&&(a.top=Math.min(a.top,u-t)),e>=s&&e<=l&&t>u&&(a.bottom=Math.min(a.bottom,t-c))}return a}getOrthoDirectionCollisionInfo(e,t,{margin:n=0}={}){const{x:i,y:a,l:o}=e,{dx:s,dy:l,dl:c}=t;let u=1/0,h=null;if(c!==0){const g=o+c;return this.isObstacleAt(i,a,g,n)?(u=1,h=this.getObstacleAt(i,a,g,n)):u=1,{dx:s,dy:l,dl:c,wallDistance:u,obstacle:h}}else{for(const g of this.obstacles){if(g.l!==o)continue;const _=g.left-n,b=g.right+n,T=g.top+n,C=g.bottom-n;let A=null;s===1&&l===0?a>C&&a<T&&i<g.left&&(A=g.left-i):s===-1&&l===0?a>C&&a<T&&i>g.right&&(A=i-g.right):s===0&&l===1?i>_&&i<b&&a<g.bottom&&(A=g.bottom-a):s===0&&l===-1&&i>_&&i<b&&a>g.top&&(A=a-g.top),A!==null&&A<u&&(u=A,h=g)}return{dx:s,dy:l,dl:0,wallDistance:u,obstacle:h}}}getObstaclesOverlappingRegion(e){const t=[];for(const n of this.obstacles){if(n.l!==e.l)continue;const{left:i,right:a,top:o,bottom:s}=n;i<=e.maxX&&a>=e.minX&&o>=e.minY&&s<=e.maxY&&t.push(n)}return t}},Wle=class extends jle{constructor(e){super(e);ni(this,"MAX_ITERATIONS",500);ni(this,"VIA_COST",4);ni(this,"VIA_DIAMETER",.5);ni(this,"allowLayerChange",!0);ni(this,"layerCount");ni(this,"obstacles");ni(this,"optimizeWithGoalBoxes");ni(this,"connMap");ni(this,"pcbConnMap");ni(this,"GOAL_RUSH_FACTOR",1.1);ni(this,"defaultGoalViaMargin",.5);ni(this,"marginsWithCosts");this.layerCount=e.input.layerCount??2,this.MAX_ITERATIONS=e.MAX_ITERATIONS??this.MAX_ITERATIONS,this.VIA_COST=e.VIA_COST??this.VIA_COST,this.connMap=e.connMap,this.pcbConnMap=e.pcbConnMap??new Ole,this.optimizeWithGoalBoxes=e.optimizeWithGoalBoxes??!1,this.obstacles=null,this.marginsWithCosts=e.marginsWithCosts??[{margin:1,enterCost:0,travelCostFactor:1},{margin:this.OBSTACLE_MARGIN,enterCost:10,travelCostFactor:2}]}get largestMargin(){return this.marginsWithCosts[0].margin}preprocessConnectionBeforeSolving(e){return this.optimizeWithGoalBoxes?qle({connection:e,pcbConnMap:this.pcbConnMap}):e}postprocessConnectionSolveResult(e,t){if(!t.solved)return t;if(this.optimizeWithGoalBoxes){const n=t.route.map(i=>({x:i.x,y:i.y,route_type:"wire",layer:i.layer,width:this.input.minTraceWidth}));n[0].start_pcb_port_id=e.pointsToConnect[0].pcb_port_id,n[n.length-1].end_pcb_port_id=e.pointsToConnect[1].pcb_port_id,this.pcbConnMap.addTrace({type:"pcb_trace",pcb_trace_id:`postprocess_trace_${Dz(8)}`,route:n})}return t}createObstacleList({dominantLayer:e,connection:t,obstaclesFromTraces:n}){const i=this.connMap?this.connMap.getNetConnectedToId(t.name):t.name;if(!i)throw new Error(`The connection.name "${t.name}" wasn't present in the full connectivity map`);return new EGe(this.layerCount,this.allObstacles.filter(a=>!a.connectedTo.includes(i)).concat(n??[]))}computeG(e,t){let n=e.g+HS(e,t)*(e.travelMarginCostFactor??1)+(t.enterMarginCost??0);return(t.l??e.l!==-1??-1)&&(n+=this.VIA_COST),n}computeH(e){const t=Math.abs(e.x-this.goalPoint.x),n=Math.abs(e.y-this.goalPoint.y),i=Math.abs(e.l-this.goalPoint.l);return(t+n)**this.GOAL_RUSH_FACTOR+i*this.VIA_COST}getStartNode(e){return{...super.getStartNode(e),l:this.layerToIndex(e.pointsToConnect[0].layer)}}layerToIndex(e){return Xle(this.layerCount,e)}indexToLayer(e){return SGe(this.layerCount,e)}getNodeName(e){return`${Ile(e,this.GRID_STEP)}-${e.l??0}`}hasSpaceForVia(e,t){return e.every(n=>this.obstacles.getObstaclesOverlappingRegion({minX:t.x-this.VIA_DIAMETER/2-this.OBSTACLE_MARGIN,minY:t.y-this.VIA_DIAMETER/2-this.OBSTACLE_MARGIN,maxX:t.x+this.VIA_DIAMETER/2+this.OBSTACLE_MARGIN,maxY:t.y+this.VIA_DIAMETER/2+this.OBSTACLE_MARGIN,l:n}).length===0)}getNeighborsSurroundingGoal(e){this.obstacles;const t=this.goalPoint,n=[],i=[{dx:1,dy:0,dl:0},{dx:-1,dy:0,dl:0},{dx:0,dy:1,dl:0},{dx:0,dy:-1,dl:0}],a=this.VIA_DIAMETER+this.OBSTACLE_MARGIN+this.defaultGoalViaMargin;for(const o of i){const s={x:e.x+o.dx*a,y:e.y+o.dy*a,l:e.l+o.dl,obstacleHit:null};this.hasSpaceForVia([e.l,t.l],s)&&n.push(s)}return n}getNeighbors(e){const t=this.obstacles,n=this.goalPoint,i=HS(e,n);if(i<=this.OBSTACLE_MARGIN)return this.getNeighborsSurroundingGoal(e);let a;e.parent?a=Yle(e.parent,e):a=Yle(e,n);const o=[{dx:0,dy:1,dl:0},{dx:1,dy:0,dl:0},{dx:0,dy:-1,dl:0},{dx:-1,dy:0,dl:0}],s=i>this.VIA_DIAMETER+this.OBSTACLE_MARGIN,l=HS(e,this.startNode)>this.VIA_DIAMETER+this.OBSTACLE_MARGIN;this.allowLayerChange&&s&&l&&(e.l<this.layerCount-1&&o.push({dx:0,dy:0,dl:1}),e.l>0&&o.push({dx:0,dy:0,dl:-1}));const c=o.filter(h=>{var g;return h.dx===a.dx*-1&&h.dy===a.dy*-1&&h.dl===a.dl*-1?!1:!(h.dx===a.dx&&h.dy===a.dy&&h.dl===a.dl&&((g=e.parent)!=null&&g.obstacleHit))}).map(h=>t.getOrthoDirectionCollisionInfo(e,h,{margin:this.OBSTACLE_MARGIN})).filter(h=>!(h.wallDistance<this.OBSTACLE_MARGIN)),u=[];for(const h of c){const g=h.dx===0&&h.dy===0&&h.dl===1,_=h.dx===0&&h.dy===0&&h.dl===-1;if((g||_)&&![e.l,e.l+h.dl].every(L=>t.getObstaclesOverlappingRegion({minX:e.x-this.VIA_DIAMETER/2-this.OBSTACLE_MARGIN,minY:e.y-this.VIA_DIAMETER/2-this.OBSTACLE_MARGIN,maxX:e.x+this.VIA_DIAMETER/2+this.OBSTACLE_MARGIN,maxY:e.y+this.VIA_DIAMETER/2+this.OBSTACLE_MARGIN,l:L}).length===0))continue;if(g){e.l<this.layerCount-1&&u.push({...h,travelDistance:0,enterMarginCost:0,travelMarginCostFactor:1});continue}if(_){e.l>0&&u.push({...h,travelDistance:0,enterMarginCost:0,travelMarginCostFactor:1});continue}let b=null;e!=null&&e.obstacleHit&&(b=NI({node:e,travelDir:h,wallDir:{...a,wallDistance:this.OBSTACLE_MARGIN},obstacle:e.obstacleHit,obstacles:t,OBSTACLE_MARGIN:this.OBSTACLE_MARGIN,SHOULD_DETECT_CONJOINED_OBSTACLES:!0}));const T=Fle(e,n,h),C=(h.dx===0||Math.sign(n.x-e.x)===h.dx)&&(h.dy===0||Math.sign(n.y-e.y)===h.dy);if(T<h.wallDistance&&T>0&&C){const A=e.l===n.l;let L=0;!A&&Math.abs(T-i)<this.GRID_STEP&&(L=this.VIA_DIAMETER+this.OBSTACLE_MARGIN+this.defaultGoalViaMargin),u.push({...h,travelDistance:T-L,enterMarginCost:0,travelMarginCostFactor:1})}else if(b!==null&&b<h.wallDistance){for(const{margin:A,enterCost:L,travelCostFactor:U}of this.marginsWithCosts)b-this.OBSTACLE_MARGIN+A*2<h.wallDistance&&u.push({...h,travelDistance:b-this.OBSTACLE_MARGIN+A,enterMarginCost:L,travelMarginCostFactor:U});if(h.wallDistance===1/0)u.push({...h,travelDistance:T,enterMarginCost:0,travelMarginCostFactor:1});else if(h.wallDistance>this.largestMargin)for(const{margin:A,enterCost:L,travelCostFactor:U}of this.marginsWithCosts)h.wallDistance>this.largestMargin+A&&u.push({...h,travelDistance:h.wallDistance-A,enterMarginCost:L,travelMarginCostFactor:U})}else if(h.wallDistance!==1/0)for(const{margin:A,enterCost:L,travelCostFactor:U}of this.marginsWithCosts)h.wallDistance>A&&u.push({...h,travelDistance:h.wallDistance-A,enterMarginCost:L,travelMarginCostFactor:U})}return u.map(h=>({x:e.x+h.dx*h.travelDistance,y:e.y+h.dy*h.travelDistance,l:e.l+h.dl,obstacleHit:h.obstacle,travelMarginCostFactor:h.travelMarginCostFactor,enterMarginCost:h.enterMarginCost}))}};function wGe(r){const e=gGe(r),t=new vGe({input:e});return{solution:t.solveAndMapToTraces(),debugSolutions:t.debugSolutions,debugMessage:t.debugMessage}}var $le=LI,TGe=ue.enum(["up","down","left","right"]);ue.enum(["top-to-bottom","left-to-right","bottom-to-top","right-to-left"]);var jS=ue.array(ue.string().or(ue.number())),Zle=ue.object({x:wi,y:wi,z:wi}),MGe=ue.object({x:ue.union([ue.number(),ue.string()]),y:ue.union([ue.number(),ue.string()]),z:ue.union([ue.number(),ue.string()])}),UI=ue.object({rotationOffset:ue.number().or(MGe).optional(),positionOffset:Zle.optional(),size:Zle.optional()}),CGe=UI.extend({stlUrl:ue.string()}),RGe=UI.extend({objUrl:ue.string(),mtlUrl:ue.string().optional()}),AGe=UI.extend({jscad:ue.record(ue.any())}),DGe=ue.union([ue.string(),CGe,RGe,AGe]),PGe=ue.custom(r=>!0),Rx=ue.object({pcbX:wi.optional(),pcbY:wi.optional(),pcbRotation:Z4.optional(),layer:My.optional()}),wA=ue.object({pcbX:wi.optional(),pcbY:wi.optional(),pcbRotation:Z4.optional(),schX:wi.optional(),schY:wi.optional(),schRotation:Z4.optional(),layer:My.optional(),footprint:PGe.optional()}),NGe=ue.object({supplierPartNumbers:ue.record(Oz,ue.array(ue.string())).optional()}),m5=wA.merge(NGe).extend({key:ue.any().optional(),name:ue.string(),cadModel:DGe.optional(),children:ue.any().optional(),symbolName:ue.string().optional()});wi.or(ue.enum(["2x","3x","4x"]));var TA=ue.object({pins:ue.array(ue.union([ue.number(),ue.string()])),direction:ue.union([ue.literal("top-to-bottom"),ue.literal("left-to-right"),ue.literal("bottom-to-top"),ue.literal("right-to-left")])}),zI=ue.object({leftSize:ue.number().optional().describe("@deprecated, use leftPinCount"),topSize:ue.number().optional().describe("@deprecated, use topPinCount"),rightSize:ue.number().optional().describe("@deprecated, use rightPinCount"),bottomSize:ue.number().optional().describe("@deprecated, use bottomPinCount"),leftPinCount:ue.number().optional(),rightPinCount:ue.number().optional(),topPinCount:ue.number().optional(),bottomPinCount:ue.number().optional(),leftSide:TA.optional(),rightSide:TA.optional(),topSide:TA.optional(),bottomSide:TA.optional()}),Qle=ue.record(ue.object({marginLeft:wi.optional(),marginRight:wi.optional(),marginTop:wi.optional(),marginBottom:wi.optional(),leftMargin:wi.optional(),rightMargin:wi.optional(),topMargin:wi.optional(),bottomMargin:wi.optional()})),Kle=ue.object({x:wi,y:wi}),FI=ue.object({edit_event_id:ue.string(),in_progress:ue.boolean().optional(),created_at:ue.number()}),LGe=FI.extend({pcb_edit_event_type:ue.literal("edit_component_location").describe("deprecated"),edit_event_type:ue.literal("edit_pcb_component_location"),pcb_component_id:ue.string(),original_center:ue.object({x:ue.number(),y:ue.number()}),new_center:ue.object({x:ue.number(),y:ue.number()})}),OGe=FI.extend({pcb_edit_event_type:ue.literal("edit_trace_hint").describe("deprecated"),edit_event_type:ue.literal("edit_pcb_trace_hint").optional(),pcb_port_id:ue.string(),pcb_trace_hint_id:ue.string().optional(),route:ue.array(ue.object({x:ue.number(),y:ue.number(),via:ue.boolean().optional()}))}),UGe=FI.extend({edit_event_type:ue.literal("edit_schematic_component_location"),schematic_component_id:ue.string(),original_center:ue.object({x:ue.number(),y:ue.number()}),new_center:ue.object({x:ue.number(),y:ue.number()})});ue.union([LGe,OGe,UGe]);var zGe=ue.object({selector:ue.string(),relative_to:ue.string().optional().default("group_center").describe("Can be a selector or 'group_center'"),center:L1}),FGe=ue.object({pcb_port_selector:ue.string(),offsets:ue.array(i4)}),IGe=ue.object({selector:ue.string(),relative_to:ue.string().optional().default("group_center").describe("Can be a selector or 'group_center'"),center:L1}),kGe=ue.object({pcb_placements:ue.array(zGe).optional(),manual_trace_hints:ue.array(FGe).optional(),schematic_placements:ue.array(IGe).optional()}),BGe=ue.object({serverUrl:ue.string().optional(),inputFormat:ue.enum(["simplified","circuit-json"]).optional(),serverMode:ue.enum(["job","solve-endpoint"]).optional(),serverCacheEnabled:ue.boolean().optional(),cache:ue.custom(r=>!0).optional(),groupMode:ue.enum(["sequential-trace","subcircuit"]).optional(),local:ue.boolean().optional()}),Jle=ue.union([BGe,ue.literal("sequential-trace"),ue.literal("subcircuit"),ue.literal("auto"),ue.literal("auto-local"),ue.literal("auto-cloud")]),ece=wA.extend({name:ue.string().optional(),children:ue.any().optional(),key:ue.any().optional()}),tce=ue.custom(r=>"findPart"in r),nce=ece.extend({layout:ue.custom(r=>!0).optional(),manualEdits:kGe.optional(),schAutoLayoutEnabled:ue.boolean().optional(),schTraceAutoLabelEnabled:ue.boolean().optional(),routingDisabled:ue.boolean().optional(),defaultTraceWidth:pr.optional(),minTraceWidth:pr.optional(),partsEngine:tce.optional(),pcbRouteCache:ue.custom(r=>!0).optional(),autorouter:Jle.optional()}),HGe=nce.extend({subcircuit:ue.literal(!0)}),VGe=ue.discriminatedUnion("subcircuit",[ece.extend({subcircuit:ue.literal(!1).optional()}),HGe]),jGe=nce.extend({width:wi.optional(),height:wi.optional(),outline:ue.array(Kle).optional(),outlineOffsetX:wi.optional(),outlineOffsetY:wi.optional()}),GGe=ue.string().or(ue.array(ue.string()).readonly()).or(ue.array(ue.string())),qGe=ue.record(ue.number().or(ue.string()),GGe);ue.record(ue.number().or(ue.string()),ue.string().or(ue.array(ue.string()).readonly()).or(ue.array(ue.string())));var YGe=m5.extend({manufacturerPartNumber:ue.string().optional(),pinLabels:ue.record(ue.number().or(ue.string()),ue.string().or(ue.array(ue.string()).readonly())).optional(),internallyConnectedPins:ue.array(ue.array(ue.string())).optional(),externallyConnectedPins:ue.array(ue.array(ue.string())).optional(),schPinArrangement:zI.optional(),schPortArrangement:zI.optional(),schPinStyle:Qle.optional(),schPinSpacing:wi.optional(),schWidth:wi.optional(),schHeight:wi.optional(),noSchematicRepresentation:ue.boolean().optional(),connections:qGe.optional()}),XGe=m5.extend({manufacturerPartNumber:ue.string().optional(),pinLabels:ue.record(ue.number().or(ue.string()),ue.string().or(ue.array(ue.string()))).optional(),schPinStyle:Qle.optional(),schPinSpacing:wi.optional(),schWidth:wi.optional(),schHeight:wi.optional(),schDirection:ue.enum(["left","right"]).optional(),schPortArrangement:zI.optional()}),WGe=ue.discriminatedUnion("shape",[Rx.omit({pcbRotation:!0,layer:!0}).extend({name:ue.string().optional(),shape:ue.literal("circle"),holeDiameter:wi,outerDiameter:wi,portHints:jS.optional()}),Rx.omit({pcbRotation:!0,layer:!0}).extend({name:ue.string().optional(),shape:ue.literal("oval"),outerWidth:wi,outerHeight:wi,innerWidth:wi,innerHeight:wi,portHints:jS.optional()}),Rx.omit({pcbRotation:!0,layer:!0}).extend({name:ue.string().optional(),shape:ue.literal("pill"),outerWidth:wi,outerHeight:wi,innerWidth:wi,innerHeight:wi,portHints:jS.optional()})]),$Ge=m5.extend({resistance:A8,pullupFor:ue.string().optional(),pullupTo:ue.string().optional(),pulldownFor:ue.string().optional(),pulldownTo:ue.string().optional()}),ZGe=m5.extend({maxResistance:A8,pinVariant:ue.enum(["two_pin","three_pin"]).optional()}),QGe=m5.extend({frequency:rR,loadCapacitance:D8,pinVariant:ue.enum(["two_pin","four_pin"]).optional()}),KGe=m5.extend({frequency:rR,loadCapacitance:D8,pinVariant:ue.enum(["no_ground","ground_pin","two_ground_pins"]).optional()}),JGe=m5.extend({capacitance:D8,maxVoltageRating:uT.optional(),schShowRatings:ue.boolean().optional().default(!1),polarized:ue.boolean().optional().default(!1),decouplingFor:ue.string().optional(),decouplingTo:ue.string().optional(),bypassFor:ue.string().optional(),bypassTo:ue.string().optional(),maxDecouplingTraceLength:ue.number().optional()});ue.object({name:ue.string()}),ue.object({name:ue.string().optional(),pcbOnly:ue.boolean().optional(),schOnly:ue.boolean().optional()});var eqe=ue.object({pcb:ue.literal(!0).optional(),xDist:wi,left:ue.string(),right:ue.string(),edgeToEdge:ue.literal(!0).optional(),centerToCenter:ue.literal(!0).optional()}),tqe=ue.object({pcb:ue.literal(!0).optional(),yDist:wi,top:ue.string(),bottom:ue.string(),edgeToEdge:ue.literal(!0).optional(),centerToCenter:ue.literal(!0).optional()}),nqe=ue.object({pcb:ue.literal(!0).optional(),sameY:ue.literal(!0).optional(),for:ue.array(ue.string())}),rqe=ue.object({pcb:ue.literal(!0).optional(),sameX:ue.literal(!0).optional(),for:ue.array(ue.string())}),iqe=ue.union([eqe,tqe,nqe,rqe]),aqe=Rx.omit({pcbRotation:!0}).extend({shape:ue.literal("rect"),width:wi,height:wi,portHints:jS.optional()}),oqe=Rx.omit({pcbRotation:!0}).extend({shape:ue.literal("rotated_rect"),width:wi,height:wi,ccwRotation:ue.number(),portHints:jS.optional()}),sqe=Rx.omit({pcbRotation:!0}).extend({shape:ue.literal("circle"),radius:wi,portHints:jS.optional()}),lqe=Rx.omit({pcbRotation:!0}).extend({shape:ue.literal("pill"),width:wi,height:wi,radius:wi,portHints:jS.optional()}),cqe=ue.union([sqe,aqe,oqe,lqe]),uqe=Rx.omit({pcbRotation:!0}).extend({shape:ue.literal("rect"),width:wi,height:wi}),fqe=Rx.omit({pcbRotation:!0}).extend({shape:ue.literal("circle"),radius:wi});ue.union([fqe,uqe]);var dqe=Rx.omit({pcbRotation:!0}).extend({name:ue.string().optional(),diameter:wi.optional(),radius:wi.optional()}).transform(r=>({...r,diameter:r.diameter??2*r.radius,radius:r.radius??r.diameter/2})),II=ue.union([ue.string(),ue.custom(r=>!!r.getPortSelector)]),rce=ue.object({key:ue.string().optional(),thickness:wi.optional(),schematicRouteHints:ue.array(Kle).optional(),pcbRouteHints:ue.array(i4).optional(),schDisplayLabel:ue.string().optional(),maxLength:wi.optional()}),hqe=ue.union([rce.extend({path:ue.array(II)}),rce.extend({from:II,to:II})]),pqe=ue.object({originalLayer:My.default("top").optional()}),mqe=ue.number().or(ue.string().endsWith("mAh")).transform(r=>{if(typeof r=="string"){const e=r.replace("mAh",""),t=Number.parseFloat(e);if(Number.isNaN(t))throw new Error("Invalid capacity");return t}return r}).describe("Battery capacity in mAh"),vqe=m5.extend({capacity:mqe.optional()}),yqe=m5.extend({pinCount:ue.number(),pitch:wi.optional(),schFacingDirection:ue.enum(["up","down","left","right"]).optional(),gender:ue.enum(["male","female"]).optional().default("male"),showSilkscreenPinLabels:ue.boolean().optional(),doubleRow:ue.boolean().optional(),holeDiameter:wi.optional(),platedDiameter:wi.optional(),pinLabels:ue.array(ue.string()).optional(),facingDirection:ue.enum(["left","right"]).optional()}),gqe=ue.object({net:ue.string().optional(),schX:wi.optional(),schY:wi.optional(),schRotation:Z4.optional(),anchorSide:ue.enum(["left","up","right","down"]).optional()}),_qe=m5.extend({internallyConnectedPins:ue.array(ue.array(ue.string())).optional()}),xqe=m5.extend({type:ue.enum(["npn","pnp","bjt","jfet","mosfet"])}),bqe=m5.extend({channelType:ue.enum(["n","p"]),mosfetMode:ue.enum(["enhancement","depletion"])}),Sqe=m5.extend({inductance:Nz}),Eqe=m5.extend({}),wqe=m5.extend({color:ue.string().optional()}),Tqe=m5.extend({type:ue.enum(["spst","spdt","dpst","dpdt"]).optional(),isNormallyClosed:ue.boolean().optional().default(!1),spst:ue.boolean().optional(),spdt:ue.boolean().optional(),dpst:ue.boolean().optional(),dpdt:ue.boolean().optional()}).transform(r=>{const e={...r};switch(e.dpdt?e.type="dpdt":e.spst?e.type="spst":e.spdt?e.type="spdt":e.dpst&&(e.type="dpst"),e.type){case"spdt":e.spdt=!0;break;case"spst":e.spst=!0;break;case"dpst":e.dpst=!0;break;case"dpdt":e.dpdt=!0;break}return e}),Mqe=Rx.extend({text:ue.string(),anchorAlignment:ue.enum(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),font:ue.enum(["tscircuit2024"]).optional(),fontSize:pr.optional(),color:ue.string().optional()}),Cqe=Rx.omit({pcbX:!0,pcbY:!0,pcbRotation:!0}).extend({route:ue.array(i4),strokeWidth:pr.optional(),color:ue.string().optional()});ue.object({layer:ue.string().optional(),thickness:wi.optional(),route:ue.array(i4)});var Rqe=wA.extend({fromLayer:My,toLayer:My,holeDiameter:wi,outerDiameter:wi}),Aqe=ue.union([Rx.omit({pcbRotation:!0}).extend({shape:ue.literal("circle"),radius:wi}),Rx.extend({shape:ue.literal("rect"),width:wi,height:wi})]),Dqe=m5.extend({voltage:uT});ue.object({schX:wi,schY:wi,width:wi,height:wi}),ue.object({x1:wi,y1:wi,x2:wi,y2:wi}),ue.object({schX:wi,schY:wi,text:ue.string()}),ue.object({points:ue.array(L1),isFilled:ue.boolean().optional().default(!1),fillColor:ue.enum(["red","blue"]).optional()});var Pqe=Rx.extend({text:ue.string(),anchorAlignment:ue.enum(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),font:ue.enum(["tscircuit2024"]).optional(),fontSize:pr.optional()}),Nqe=Rx.omit({pcbX:!0,pcbY:!0,pcbRotation:!0}).extend({route:ue.array(i4),strokeWidth:pr.optional()}),Lqe=Rx.omit({pcbX:!0,pcbY:!0,pcbRotation:!0}).extend({strokeWidth:wi,x1:wi,y1:wi,x2:wi,y2:wi}),Oqe=Rx.omit({pcbRotation:!0}).extend({isFilled:ue.boolean().optional(),isOutline:ue.boolean().optional(),strokeWidth:wi.optional(),width:wi,height:wi}),Uqe=Rx.omit({pcbRotation:!0}).extend({isFilled:ue.boolean().optional(),isOutline:ue.boolean().optional(),strokeWidth:wi.optional(),radius:wi}),ice=ue.object({x:wi,y:wi,via:ue.boolean().optional(),toLayer:My.optional()}),zqe=ue.object({for:ue.string().optional().describe("Selector for the port you're targeting, not required if you're inside a trace"),order:ue.number().optional(),offset:i4.or(ice).optional(),offsets:ue.array(i4).or(ue.array(ice)).optional(),traceWidth:ue.number().optional()});wA.extend({name:ue.string(),pinNumber:ue.number().optional(),aliases:ue.array(ue.string()).optional(),direction:TGe}),ue.object({partsEngine:tce.optional(),autorouter:Jle.optional(),registryApiUrl:ue.string().optional(),cloudAutorouterUrl:ue.string().optional()});function I8(){return new kI}class kI{constructor(){ni(this,"index",{});ni(this,"array",[])}size(){return this.array.length}empty(){return this.array.length===0}itemAt(e){return this.array[e]}contains(e){return this.index[e.id()]!==void 0}find(e){const t=this.index[e.id()];return t===void 0?void 0:this.array[t]}setDefault(e,t){const n=this.index[e.id()];if(n===void 0){const i=new MA(e,t());return this.index[e.id()]=this.array.length,this.array.push(i),i}else return this.array[n]}insert(e,t){const n=new MA(e,t),i=this.index[e.id()];return i===void 0?(this.index[e.id()]=this.array.length,this.array.push(n)):this.array[i]=n,n}erase(e){const t=this.index[e.id()];if(t===void 0)return;this.index[e.id()]=void 0;const n=this.array[t],i=this.array.pop();return n!==i&&(this.array[t]=i,this.index[i.first.id()]=t),n}copy(){const e=new kI;for(let t=0;t<this.array.length;t++){const n=this.array[t].copy();e.array[t]=n,e.index[n.first.id()]=t}return e}}class MA{constructor(e,t){ni(this,"first");ni(this,"second");this.first=e,this.second=t}copy(){return new MA(this.first,this.second)}}class BI{constructor(e=""){ni(this,"_name");ni(this,"_value",0);ni(this,"_context",null);ni(this,"_id",Fqe++);this._name=e}id(){return this._id}name(){return this._name}setName(e){this._name=e}context(){return this._context}setContext(e){this._context=e}value(){return this._value}setValue(e){this._value=e}plus(e){return new Ax(this,e)}minus(e){return new Ax(this,typeof e=="number"?-e:[-1,e])}multiply(e){return new Ax([e,this])}divide(e){return new Ax([1/e,this])}toJSON(){return{name:this._name,value:this._value}}toString(){return this._context+"["+this._name+":"+this._value+"]"}}let Fqe=0;class Ax{constructor(){ni(this,"_terms");ni(this,"_constant");let e=Iqe(arguments);this._terms=e.terms,this._constant=e.constant}terms(){return this._terms}constant(){return this._constant}value(){let e=this._constant;for(let t=0,n=this._terms.size();t<n;t++){let i=this._terms.itemAt(t);e+=i.first.value()*i.second}return e}plus(e){return new Ax(this,e)}minus(e){return new Ax(this,typeof e=="number"?-e:[-1,e])}multiply(e){return new Ax([e,this])}divide(e){return new Ax([1/e,this])}isConstant(){return this._terms.size()==0}toString(){let e=this._terms.array.map(function(t){return t.second+"*"+t.first.toString()}).join(" + ");return!this.isConstant()&&this._constant!==0&&(e+=" + "),e+=this._constant,e}}function Iqe(r){let e=0,t=()=>0,n=I8();for(let i=0,a=r.length;i<a;++i){let o=r[i];if(typeof o=="number")e+=o;else if(o instanceof BI)n.setDefault(o,t).second+=1;else if(o instanceof Ax){e+=o.constant();let s=o.terms();for(let l=0,c=s.size();l<c;l++){let u=s.itemAt(l);n.setDefault(u.first,t).second+=u.second}}else if(o instanceof Array){if(o.length!==2)throw new Error("array must have length 2");let s=o[0],l=o[1];if(typeof s!="number")throw new Error("array item 0 must be a number");if(l instanceof BI)n.setDefault(l,t).second+=s;else if(l instanceof Ax){e+=l.constant()*s;let c=l.terms();for(let u=0,h=c.size();u<h;u++){let g=c.itemAt(u);n.setDefault(g.first,t).second+=g.second*s}}else throw new Error("array item 1 must be a variable or expression")}else throw new Error("invalid Expression argument: "+o)}return{terms:n,constant:e}}const hb=class hb{static create(e,t,n,i=1){let a=0;return a+=Math.max(0,Math.min(1e3,e*i))*1e6,a+=Math.max(0,Math.min(1e3,t*i))*1e3,a+=Math.max(0,Math.min(1e3,n*i)),a}static clip(e){return Math.max(0,Math.min(hb.required,e))}};ni(hb,"required",hb.create(1e3,1e3,1e3)),ni(hb,"strong",hb.create(1,0,0)),ni(hb,"medium",hb.create(0,1,0)),ni(hb,"weak",hb.create(0,0,1));let X5=hb;var c3;(function(r){r[r.Le=0]="Le",r[r.Ge=1]="Ge",r[r.Eq=2]="Eq"})(c3||(c3={}));class K4{constructor(e,t,n,i=X5.required){ni(this,"_expression");ni(this,"_operator");ni(this,"_strength");ni(this,"_id",kqe++);this._operator=t,this._strength=X5.clip(i),n===void 0&&e instanceof Ax?this._expression=e:this._expression=e.minus(n)}id(){return this._id}expression(){return this._expression}op(){return this._operator}strength(){return this._strength}toString(){return this._expression.toString()+" "+["<=",">=","="][this._operator]+" 0 ("+this._strength.toString()+")"}}let kqe=0;class Bqe{constructor(){ni(this,"maxIterations",1e3);ni(this,"_cnMap",Hqe());ni(this,"_rowMap",Vqe());ni(this,"_varMap",jqe());ni(this,"_editMap",Gqe());ni(this,"_infeasibleRows",[]);ni(this,"_objective",new RA);ni(this,"_artificial",null);ni(this,"_idTick",0)}createConstraint(e,t,n,i=X5.required){let a=new K4(e,t,n,i);return this.addConstraint(a),a}addConstraint(e){if(this._cnMap.find(e)!==void 0)throw new Error("duplicate constraint");let n=this._createRow(e),i=n.row,a=n.tag,o=this._chooseSubject(i,a);if(o.type()===Bv.Invalid&&i.allDummies())if(CA(i.constant()))o=a.marker;else throw new Error("unsatisfiable constraint");if(o.type()===Bv.Invalid){if(!this._addWithArtificialVariable(i))throw new Error("unsatisfiable constraint")}else i.solveFor(o),this._substitute(o,i),this._rowMap.insert(o,i);this._cnMap.insert(e,a),this._optimize(this._objective)}removeConstraint(e){let t=this._cnMap.erase(e);if(t===void 0)throw new Error("unknown constraint");this._removeConstraintEffects(e,t.second);let n=t.second.marker,i=this._rowMap.erase(n);if(i===void 0){let a=this._getMarkerLeavingSymbol(n);if(a.type()===Bv.Invalid)throw new Error("failed to find leaving row");i=this._rowMap.erase(a),i.second.solveForEx(a,n),this._substitute(n,i.second)}this._optimize(this._objective)}hasConstraint(e){return this._cnMap.contains(e)}getConstraints(){return this._cnMap.array.map(({first:e})=>e)}addEditVariable(e,t){if(this._editMap.find(e)!==void 0)throw new Error("duplicate edit variable");if(t=X5.clip(t),t===X5.required)throw new Error("bad required strength");let i=new Ax(e),a=new K4(i,c3.Eq,void 0,t);this.addConstraint(a);let s={tag:this._cnMap.find(a).second,constraint:a,constant:0};this._editMap.insert(e,s)}removeEditVariable(e){let t=this._editMap.erase(e);if(t===void 0)throw new Error("unknown edit variable");this.removeConstraint(t.second.constraint)}hasEditVariable(e){return this._editMap.contains(e)}suggestValue(e,t){let n=this._editMap.find(e);if(n===void 0)throw new Error("unknown edit variable");let i=this._rowMap,a=n.second,o=t-a.constant;a.constant=t;let s=a.tag.marker,l=i.find(s);if(l!==void 0){l.second.add(-o)<0&&this._infeasibleRows.push(s),this._dualOptimize();return}let c=a.tag.other;if(l=i.find(c),l!==void 0){l.second.add(o)<0&&this._infeasibleRows.push(c),this._dualOptimize();return}for(let u=0,h=i.size();u<h;++u){let g=i.itemAt(u),_=g.second,b=_.coefficientFor(s);b!==0&&_.add(o*b)<0&&g.first.type()!==Bv.External&&this._infeasibleRows.push(g.first)}this._dualOptimize()}updateVariables(){let e=this._varMap,t=this._rowMap;for(let n=0,i=e.size();n<i;++n){let a=e.itemAt(n),o=t.find(a.second);o!==void 0?a.first.setValue(o.second.constant()):a.first.setValue(0)}}_getVarSymbol(e){let t=()=>this._makeSymbol(Bv.External);return this._varMap.setDefault(e,t).second}_createRow(e){let t=e.expression(),n=new RA(t.constant()),i=t.terms();for(let l=0,c=i.size();l<c;++l){let u=i.itemAt(l);if(!CA(u.second)){let h=this._getVarSymbol(u.first),g=this._rowMap.find(h);g!==void 0?n.insertRow(g.second,u.second):n.insertSymbol(h,u.second)}}let a=this._objective,o=e.strength(),s={marker:J4,other:J4};switch(e.op()){case c3.Le:case c3.Ge:{let l=e.op()===c3.Le?1:-1,c=this._makeSymbol(Bv.Slack);if(s.marker=c,n.insertSymbol(c,l),o<X5.required){let u=this._makeSymbol(Bv.Error);s.other=u,n.insertSymbol(u,-l),a.insertSymbol(u,o)}break}case c3.Eq:{if(o<X5.required){let l=this._makeSymbol(Bv.Error),c=this._makeSymbol(Bv.Error);s.marker=l,s.other=c,n.insertSymbol(l,-1),n.insertSymbol(c,1),a.insertSymbol(l,o),a.insertSymbol(c,o)}else{let l=this._makeSymbol(Bv.Dummy);s.marker=l,n.insertSymbol(l)}break}}return n.constant()<0&&n.reverseSign(),{row:n,tag:s}}_chooseSubject(e,t){let n=e.cells();for(let a=0,o=n.size();a<o;++a){let s=n.itemAt(a);if(s.first.type()===Bv.External)return s.first}let i=t.marker.type();return(i===Bv.Slack||i===Bv.Error)&&e.coefficientFor(t.marker)<0?t.marker:(i=t.other.type(),(i===Bv.Slack||i===Bv.Error)&&e.coefficientFor(t.other)<0?t.other:J4)}_addWithArtificialVariable(e){let t=this._makeSymbol(Bv.Slack);this._rowMap.insert(t,e.copy()),this._artificial=e.copy(),this._optimize(this._artificial);let n=CA(this._artificial.constant());this._artificial=null;let i=this._rowMap.erase(t);if(i!==void 0){let o=i.second;if(o.isConstant())return n;let s=this._anyPivotableSymbol(o);if(s.type()===Bv.Invalid)return!1;o.solveForEx(t,s),this._substitute(s,o),this._rowMap.insert(s,o)}let a=this._rowMap;for(let o=0,s=a.size();o<s;++o)a.itemAt(o).second.removeSymbol(t);return this._objective.removeSymbol(t),n}_substitute(e,t){let n=this._rowMap;for(let i=0,a=n.size();i<a;++i){let o=n.itemAt(i);o.second.substitute(e,t),o.second.constant()<0&&o.first.type()!==Bv.External&&this._infeasibleRows.push(o.first)}this._objective.substitute(e,t),this._artificial&&this._artificial.substitute(e,t)}_optimize(e){let t=0;for(;t<this.maxIterations;){let n=this._getEnteringSymbol(e);if(n.type()===Bv.Invalid)return;let i=this._getLeavingSymbol(n);if(i.type()===Bv.Invalid)throw new Error("the objective is unbounded");let a=this._rowMap.erase(i).second;a.solveForEx(i,n),this._substitute(n,a),this._rowMap.insert(n,a),t++}throw new Error("solver iterations exceeded")}_dualOptimize(){let e=this._rowMap,t=this._infeasibleRows;for(;t.length!==0;){let n=t.pop(),i=e.find(n);if(i!==void 0&&i.second.constant()<0){let a=this._getDualEnteringSymbol(i.second);if(a.type()===Bv.Invalid)throw new Error("dual optimize failed");let o=i.second;e.erase(n),o.solveForEx(n,a),this._substitute(a,o),e.insert(a,o)}}}_getEnteringSymbol(e){let t=e.cells();for(let n=0,i=t.size();n<i;++n){let a=t.itemAt(n),o=a.first;if(a.second<0&&o.type()!==Bv.Dummy)return o}return J4}_getDualEnteringSymbol(e){let t=Number.MAX_VALUE,n=J4,i=e.cells();for(let a=0,o=i.size();a<o;++a){let s=i.itemAt(a),l=s.first,c=s.second;if(c>0&&l.type()!==Bv.Dummy){let h=this._objective.coefficientFor(l)/c;h<t&&(t=h,n=l)}}return n}_getLeavingSymbol(e){let t=Number.MAX_VALUE,n=J4,i=this._rowMap;for(let a=0,o=i.size();a<o;++a){let s=i.itemAt(a),l=s.first;if(l.type()!==Bv.External){let c=s.second,u=c.coefficientFor(e);if(u<0){let h=-c.constant()/u;h<t&&(t=h,n=l)}}}return n}_getMarkerLeavingSymbol(e){let t=Number.MAX_VALUE,n=t,i=t,a=J4,o=a,s=a,l=a,c=this._rowMap;for(let u=0,h=c.size();u<h;++u){let g=c.itemAt(u),_=g.second,b=_.coefficientFor(e);if(b===0)continue;let T=g.first;if(T.type()===Bv.External)l=T;else if(b<0){let C=-_.constant()/b;C<n&&(n=C,o=T)}else{let C=_.constant()/b;C<i&&(i=C,s=T)}}return o!==a?o:s!==a?s:l}_removeConstraintEffects(e,t){t.marker.type()===Bv.Error&&this._removeMarkerEffects(t.marker,e.strength()),t.other.type()===Bv.Error&&this._removeMarkerEffects(t.other,e.strength())}_removeMarkerEffects(e,t){let n=this._rowMap.find(e);n!==void 0?this._objective.insertRow(n.second,-t):this._objective.insertSymbol(e,-t)}_anyPivotableSymbol(e){let t=e.cells();for(let n=0,i=t.size();n<i;++n){let a=t.itemAt(n),o=a.first.type();if(o===Bv.Slack||o===Bv.Error)return a.first}return J4}_makeSymbol(e){return new ace(e,this._idTick++)}}function CA(r){let e=1e-8;return r<0?-r<e:r<e}function Hqe(){return I8()}function Vqe(){return I8()}function jqe(){return I8()}function Gqe(){return I8()}var Bv;(function(r){r[r.Invalid=0]="Invalid",r[r.External=1]="External",r[r.Slack=2]="Slack",r[r.Error=3]="Error",r[r.Dummy=4]="Dummy"})(Bv||(Bv={}));let ace=class{constructor(e,t){ni(this,"_id");ni(this,"_type");this._id=t,this._type=e}id(){return this._id}type(){return this._type}},J4=new ace(Bv.Invalid,-1);class RA{constructor(e=0){ni(this,"_cellMap",I8());ni(this,"_constant");this._constant=e}cells(){return this._cellMap}constant(){return this._constant}isConstant(){return this._cellMap.empty()}allDummies(){let e=this._cellMap;for(let t=0,n=e.size();t<n;++t)if(e.itemAt(t).first.type()!==Bv.Dummy)return!1;return!0}copy(){let e=new RA(this._constant);return e._cellMap=this._cellMap.copy(),e}add(e){return this._constant+=e}insertSymbol(e,t=1){let n=this._cellMap.setDefault(e,()=>0);CA(n.second+=t)&&this._cellMap.erase(e)}insertRow(e,t=1){this._constant+=e._constant*t;let n=e._cellMap;for(let i=0,a=n.size();i<a;++i){let o=n.itemAt(i);this.insertSymbol(o.first,o.second*t)}}removeSymbol(e){this._cellMap.erase(e)}reverseSign(){this._constant=-this._constant;let e=this._cellMap;for(let t=0,n=e.size();t<n;++t){let i=e.itemAt(t);i.second=-i.second}}solveFor(e){let t=this._cellMap,i=-1/t.erase(e).second;this._constant*=i;for(let a=0,o=t.size();a<o;++a)t.itemAt(a).second*=i}solveForEx(e,t){this.insertSymbol(e,-1),this.solveFor(t)}coefficientFor(e){let t=this._cellMap.find(e);return t!==void 0?t.second:0}substitute(e,t){let n=this._cellMap.erase(e);n!==void 0&&this.insertRow(t,n.second)}}var oce=(r,e={})=>{let t=r._internal_store;if(!t){t={counts:{}},r._internal_store=t;for(const i of r){const a=i.type,o=i[`${a}_id`];if(!o)continue;const s=Number.parseInt(o.split("_").pop());Number.isNaN(s)||(t.counts[a]=Math.max(t.counts[a]??0,s))}}return new Proxy({},{get:(i,a)=>a==="toArray"?()=>r:{get:o=>r.find(s=>s.type===a&&s[`${a}_id`]===o),getUsing:o=>{const s=Object.keys(o);if(s.length!==1)throw new Error("getUsing requires exactly one key, e.g. { pcb_component_id }");const l=s[0],c=l.replace("_id",""),u=r.find(h=>h.type===c&&h[l]===o[l]);return u?r.find(h=>h.type===a&&h[`${a}_id`]===u[`${a}_id`]):null},getWhere:o=>{const s=Object.keys(o);return r.find(l=>l.type===a&&s.every(c=>l[c]===o[c]))},list:o=>{const s=o?Object.keys(o):[];return r.filter(l=>l.type===a&&s.every(c=>l[c]===o[c]))},insert:o=>{var c;(c=t.counts)[a]??(c[a]=-1),t.counts[a]++;const s=t.counts[a],l={type:a,[`${a}_id`]:`${a}_${s}`,...o};return e.validateInserts&&(xie[a]??$z).parse(l),r.push(l),l},delete:o=>{const s=r.find(l=>l[`${a}_id`]===o);s&&r.splice(r.indexOf(s),1)},update:(o,s)=>{const l=r.find(c=>c[`${a}_id`]===o);if(l)return Object.assign(l,s),l},select:o=>{if(a==="source_component")return r.find(s=>s.type==="source_component"&&s.name===o.replace(/\./g,""));if(a==="pcb_port"||a==="source_port"||a==="schematic_port"){const[s,l]=o.replace(/\./g,"").split(/[\s\>]+/),c=r.find(h=>h.type==="source_component"&&h.name===s);if(!c)return null;const u=r.find(h=>h.type==="source_port"&&h.source_component_id===c.source_component_id&&(h.name===l||(h.port_hints??[]).includes(l)));if(!u)return null;if(a==="source_port")return u;if(a==="pcb_port")return r.find(h=>h.type==="pcb_port"&&h.source_port_id===u.source_port_id);if(a==="schematic_port")return r.find(h=>h.type==="schematic_port"&&h.source_port_id===u.source_port_id)}}}})};oce.unparsed=oce;var qqe=r=>{if(r==="up")return"right";if(r==="right")return"down";if(r==="down")return"left";if(r==="left")return"up";throw new Error(`Invalid direction: ${r}`)},Yqe=r=>{if(r==="up")return"left";if(r==="left")return"down";if(r==="down")return"right";if(r==="right")return"up";throw new Error(`Invalid direction: ${r}`)},Xqe=(r,e)=>{for(;e>0;)r=qqe(r),e--;for(;e<0;)r=Yqe(r),e++;return r},Wqe=(r,e)=>{if(r.type==="schematic_component")r.center=ui(e,r.center);else if(r.type==="schematic_port")r.center=ui(e,r.center),r.facing_direction&&(r.facing_direction=Xqe(r.facing_direction,-(Math.atan2(e.b,e.a)/Math.PI)*2));else if(r.type==="schematic_text")r.position=ui(e,r.position);else if(r.type!=="schematic_trace"){if(r.type==="schematic_box"){const{x:t,y:n}=ui(e,{x:r.x,y:r.y});r.x=t,r.y=n}else if(r.type==="schematic_line"){const{x:t,y:n}=ui(e,{x:r.x1,y:r.y1}),{x:i,y:a}=ui(e,{x:r.x2,y:r.y2});r.x1=t,r.y1=n,r.x2=i,r.y2=a}}return r},$qe=(r,e)=>{const t=r;for(const n of e.boxes){const i=t.find(o=>o.type==="schematic_component"&&o.schematic_component_id===n.box_id),a=rv(n.x-i.center.x,n.y-i.center.y);for(const o of t)o.schematic_component_id===n.box_id&&Wqe(o,a)}return t},Zqe=r=>{const e=[],t=[],n=[],i={schematic_component:r.filter(a=>a.type==="schematic_component"),schematic_port:r.filter(a=>a.type==="schematic_port"),source_port:r.filter(a=>a.type==="source_port"),schematic_trace:r.filter(a=>a.type==="schematic_trace"),source_trace:r.filter(a=>a.type==="source_trace")};for(const a of i.schematic_component){const o=[],s=a.schematic_component_id;for(const c of i.schematic_port)c.schematic_component_id===a.schematic_component_id&&o.push({port_id:`${s}.${c.schematic_port_id}`,rx:c.center.x-a.center.x,ry:c.center.y-a.center.y});const l={box_id:s,x:a.center.x,y:a.center.y,ports:o};e.push(l)}for(const a of i.source_trace){const[o,s]=a.connected_source_port_ids,l=i.schematic_port.find(_=>_.source_port_id===o),c=i.schematic_port.find(_=>_.source_port_id===s);if(!l||!c)continue;const u=i.schematic_component.find(_=>_.schematic_component_id===l.schematic_component_id),h=i.schematic_component.find(_=>_.schematic_component_id===c.schematic_component_id);if(!u||!h)continue;const g={from:`${u.schematic_component_id}.${l.schematic_port_id}`,to:`${h.schematic_component_id}.${c.schematic_port_id}`};t.push(g)}return{boxes:e,connections:t,nets:n}};function Qqe(r){return r.connections.reduce((e,t)=>(e[t.from]=t.to,e[t.to]=t.from,e),{})}function Kqe(r,e){for(const t of["left","right"]){const n=r.filter(o=>o.side===t),i=n.map(o=>o.ascending_box_index).filter(o=>!isNaN(o)),a=Math.max(...i);for(const o of n)o.box_id!==e.box_id&&(o.y-=a/2*1.25)}}var Jqe=r=>{let e=r[0];for(const t of r)t.ports.length>e.ports.length&&(e=t);return e};function eYe(r,e,t,n){for(const i of["left","right"]){const a=r.filter(o=>o.side===i).sort((o,s)=>o.ascending_box_index-s.ascending_box_index);for(let o=0;o<a.length-1;o++){const[s,l]=[a[o],a[o+1]];if(s.ports.length===2&&l.ports.length===2){const[c,u]=s.ports,[h,g]=l.ports,[_,b]=[c,u].map(U=>e[U.port_id]),[T,C]=[h,g].map(U=>e[U.port_id]);let A=null;if((_===T||_===C)&&t.has(_)?A=_:(b===T||b===C)&&t.has(b)&&(A=b),!A)continue;const L=n.nets.find(U=>U.net_id===A);if(!L.is_ground&&!L.is_power)continue;L.is_ground&&a.slice(o+1).forEach(U=>{U.ascending_box_index-=1,U.y-=1}),L.is_power&&a.slice(o+1).forEach(U=>{U.ascending_box_index-=1,U.y-=1})}}}}function tYe(r,e){for(let t=0;t<r;t++){let n=0;for(const i of e)i.ascending_box_index===t&&(n+=1);if(n===0){r-=1;for(const i of e)i.ascending_box_index>t&&(i.ascending_box_index-=1)}}return r}function nYe(r,e,t,n){const i=Math.max(...r.map(a=>a.ascending_box_index).filter(a=>!isNaN(a)));for(const a of["left","right"])for(let o=0;o<=i;o++){const s=r.filter(b=>b.side===a).filter(b=>b.ascending_box_index===o);if(s.length===0)continue;const c=s.map(b=>e.connections.filter(T=>T.from.startsWith(b.box_id+".")||T.to.startsWith(b.box_id+".")).map(T=>T.from.startsWith(b.box_id+".")?T.to:T.from)).map(b=>b.filter(T=>t.has(T))),u=c.reduce((b,T)=>b.filter(C=>T.includes(C)),c[0]),h=u.map(b=>e.nets.find(T=>T.net_id===b)),_=(a==="left"?Math.max:Math.min)(...s.map(b=>b.x));for(const b of h){const T=o+(b!=null&&b.is_ground?-1:1),C=`${b==null?void 0:b.net_id}_${a==="left"?"L":"R"}_${o}`,A=b!=null&&b.is_ground?`${C}.top`:`${C}.bottom`,L={box_id:C,x:_,y:T,side:a,ascending_port_index:0,ascending_box_index:o,width:0,ports:[{port_id:A,rx:0,ry:b!=null&&b.is_ground?.1:-.1}]};r.push(L);for(const U of s){const j=n.filter(Z=>Z.from.startsWith(U.box_id+".")||Z.to.startsWith(U.box_id+"."));for(const Z of j)Z.from===b.net_id&&(Z.from=A),Z.to===b.net_id&&(Z.to=A)}}for(let b=0;b<s.length;b++){const T=s[b],C=c[b].filter(A=>!u.includes(A));for(const A of C){const L=e.nets.find($=>$.net_id===A),U=`${A}_${T.ascending_box_index}_${a==="left"?"L":"R"}_${b}`,j=`${U}.${L.is_ground?"top":"bottom"}`,Z={x:T.x,y:T.y+(L.is_ground?-1:1),side:a,ascending_port_index:0,ascending_box_index:T.ascending_box_index,box_id:U,ports:[{port_id:j,rx:0,ry:L.is_ground?.1:-.1}]};r.push(Z);const ee=n.find($=>$.from===A&&$.to.startsWith(T.box_id)||$.to===A&&$.from.startsWith(T.box_id));ee.from===A&&(ee.from=j),ee.to===A&&(ee.to=j)}}}return i}var sce=(r,e)=>{const t=l3(e*(Math.PI/180));r.ports.forEach(n=>{const i=ui(t,{x:n.rx,y:n.ry});n.rx=i.x,n.ry=i.y})},lce=r=>{const e=Math.sqrt(r.x**2+r.y**2);return{x:r.x/e,y:r.y/e}},rYe=r=>[0,90,180,270].map(t=>{const n={...r,ports:r.ports.map(i=>({...i}))};return sce(n,t),n.applied_rotation_deg=t,n}),iYe=r=>{const e=r.boxes.sort((t,n)=>t.y-n.y);for(const t of e)if(t.ports.length===2){const n=t.ports.map(o=>{var u;const s=r.connections.filter(h=>h.from===o.port_id||h.to===o.port_id).map(h=>h.from===o.port_id?h.to:h.from);if(s.length===0)return null;const l=e.filter(h=>s.some(g=>g.startsWith(h.box_id+"."))),c=(u=l.flatMap(h=>h.ports))==null?void 0:u.filter(h=>s.includes(h.port_id));for(const h of c){const g=l.find(_=>_.box_id===h.port_id.split(".")[0]);h.x=g.x+h.rx,h.y=g.y+h.ry}return{...o,connected_port:c[0],connected_ports:c}}).filter(Boolean);if(n.length===0)continue;const i=rYe({...t,ports:n});for(const o of i){o.natural_offset_sum_deg=0;for(const s of o.ports)for(const l of s.connected_ports){const c=lce({x:l.x-(o.x+s.rx),y:l.y-(o.y+s.ry)}),u=lce({x:s.rx,y:s.ry}),h=Math.sqrt((c.x-u.x)**2+(c.y-u.y)**2),g=c.x*u.x+c.y*u.y,_=c.x*u.y-c.y*u.x,b=Math.atan2(_,g)*(180/Math.PI);o.natural_offset_sum_deg+=Math.abs(b)/h}}const a=i.reduce((o,s)=>o.natural_offset_sum_deg<s.natural_offset_sum_deg?o:s);sce(t,a.applied_rotation_deg)}return r},aYe=r=>{const e=new Set(r.nets.map(l=>l.net_id)),t=Qqe(r),n=JSON.parse(JSON.stringify(r.boxes)),i=JSON.parse(JSON.stringify(r.connections));for(const l of n){l.x=0,l.y=0;let c=0,u=0;for(const h of l.ports)h.rx<c?c=h.rx:h.rx>u&&(u=h.rx);l.width=u-c}const a=Jqe(n);for(const l of a.ports)l.rx>0?l.side="right":l.rx<0&&(l.side="left");for(const l of n){if(l.box_id===a.box_id)continue;const c=a.ports.filter(g=>i.some(_=>_.from.startsWith(l.box_id)&&_.to===g.port_id||_.to.startsWith(l.box_id)&&_.from===g.port_id));if(c.length===0){l.side="left";continue}let u=0,h=0;for(const g of c)g.rx>0?h+=1:g.rx<0&&(u+=1);u>=h?l.side="left":l.side="right"}for(const l of["left","right"]){const c=a.ports.filter(u=>u.side===l);c.sort((u,h)=>u.ry-h.ry);for(const u of c)u.ascending_port_index=c.indexOf(u)}for(const l of n){if(l.box_id===a.box_id)continue;const c=r.connections.filter(h=>h.from.startsWith(l.box_id+".")||h.to.startsWith(l.box_id+".")).map(h=>h.from.startsWith(l.box_id+".")?h.to:h.from),u=a.ports.filter(h=>c.includes(h.port_id));u.length!==0&&(l.ascending_port_index=Math.min(...u.map(h=>h.ascending_port_index)),l.ascending_box_index=l.ascending_port_index)}let o=Math.max(0,...n.map(l=>l.ascending_box_index).filter(l=>!isNaN(l)));for(const l of n)l.box_id!==a.box_id&&l.ascending_box_index===void 0&&(o+=1,l.ascending_box_index=o);for(const l of["left","right"])tYe(o,n.filter(c=>c.side===l));for(const l of["left","right"]){let c=a.width*.75*(l==="left"?-1:1);for(let u=0;u<=o;u++){const h=n.filter(b=>b.side===l&&b.ascending_box_index===u),g=Math.max(...h.map(b=>b.width)),_=Math.max(.5,g)*(l==="left"?-1:1);c+=_;for(const b of h)b.box_id!==a.box_id&&(b.y=b.ascending_box_index*1.25,b.x=c);c+=_/2}}eYe(n,t,e,r),nYe(n,r,e,i),Kqe(n,a);const s={...r,connections:i,boxes:n};return iYe(s),s},oYe=(r,e)=>{const t={x:e.x-r.x,y:e.y-r.y},n=Math.sqrt(t.x**2+t.y**2);return{x:t.x/n,y:t.y/n}},sYe=r=>{switch(r){case"up":return{x:0,y:1};case"down":return{x:0,y:-1};case"left":return{x:-1,y:0};case"right":return{x:1,y:0}}};function cce([r,e],[t,n],{lineThickness:i=0}={}){return i===0?uce(r,e,t,n):lYe(r,e,t,n)<=i}function uce(r,e,t,n){const i=AA(r,e,t),a=AA(r,e,n),o=AA(t,n,r),s=AA(t,n,e);return!!(i!==a&&o!==s||i===0&&DA(r,t,e)||a===0&&DA(r,n,e)||o===0&&DA(t,r,n)||s===0&&DA(t,e,n))}function AA(r,e,t){const n=(e.y-r.y)*(t.x-e.x)-(e.x-r.x)*(t.y-e.y);return n===0?0:n>0?1:2}function DA(r,e,t){return e.x<=Math.max(r.x,t.x)&&e.x>=Math.min(r.x,t.x)&&e.y<=Math.max(r.y,t.y)&&e.y>=Math.min(r.y,t.y)}function lYe(r,e,t,n){if(r.x===e.x&&r.y===e.y)return k8(r,t,n);if(t.x===n.x&&t.y===n.y)return k8(t,r,e);if(uce(r,e,t,n))return 0;const i=[k8(r,t,n),k8(e,t,n),k8(t,r,e),k8(n,r,e)];return Math.min(...i)}function k8(r,e,t){const n=(t.x-e.x)**2+(t.y-e.y)**2;if(n===0)return yT(r,e);let i=((r.x-e.x)*(t.x-e.x)+(r.y-e.y)*(t.y-e.y))/n;i=Math.max(0,Math.min(1,i));const a={x:e.x+i*(t.x-e.x),y:e.y+i*(t.y-e.y)};return yT(r,a)}function yT(r,e){const t=r.x-e.x,n=r.y-e.y;return Math.sqrt(t*t+n*n)}var HI=[{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:"µ"},{value:1e-9,symbol:"n"},{value:1e-12,symbol:"p"}];function PA(r){if(r==null)return"";if(r===0)return"0";const e=Math.abs(r),t=HI.find(a=>{const o=e/a.value;return o>=1&&o<1e3})||HI[HI.length-1];let i=(r/t.value).toPrecision(3);return i.includes(".")&&!/\.0+$/.test(i)&&(i=i.replace(/0+$/,"")),i=i.replace(/\.0+$/,""),`${i}${t.symbol}`}var cYe=Object.defineProperty,uYe=(r,e)=>{for(var t in e)cYe(r,t,{get:e[t],enumerable:!0})},fce={};uYe(fce,{Battery:()=>dXe,Board:()=>NYe,Capacitor:()=>$Ye,Chip:()=>Ace,Constraint:()=>nXe,Crystal:()=>xXe,Diode:()=>ZYe,FabricationNotePath:()=>rXe,FabricationNoteText:()=>iXe,Footprint:()=>CYe,Group:()=>qI,Hole:()=>bce,Inductor:()=>vXe,Jumper:()=>QYe,Keepout:()=>GI,Led:()=>KYe,Mosfet:()=>SXe,Net:()=>yce,NetAlias:()=>oXe,NormalComponent:()=>Dx,PinHeader:()=>hXe,PlatedHole:()=>xce,Port:()=>l4,Potentiometer:()=>gXe,PowerSource:()=>JYe,PrimitiveComponent:()=>R_,PushButton:()=>_Xe,Renderable:()=>dce,Resistor:()=>eXe,Resonator:()=>mXe,SilkscreenCircle:()=>sXe,SilkscreenLine:()=>uXe,SilkscreenPath:()=>_ce,SilkscreenRect:()=>lXe,SilkscreenText:()=>cXe,SmtPad:()=>jI,Subcircuit:()=>aXe,Switch:()=>EXe,Trace:()=>qS,TraceHint:()=>Tce,Transistor:()=>bXe,Via:()=>fXe});var fYe=g2("tscircuit:renderable"),T3=["ReactSubtreesRender","InitializePortsFromChildren","CreateNetsFromProps","CreateTracesFromProps","CreateTraceHintsFromProps","SourceRender","SourceParentAttachment","PortMatching","SourceTraceRender","SourceAddConnectivityMapKey","SchematicComponentRender","SchematicPortRender","SchematicLayout","SchematicTraceRender","PcbComponentRender","PcbPrimitiveRender","PcbFootprintLayout","PcbPortRender","PcbPortAttachment","PcbLayout","PcbComponentSizeCalculation","PcbTraceRender","PcbTraceHintRender","PcbRouteNetIslands","CadModelRender","PartsEngineRender"],dYe=0,dce=class{constructor(r){ni(this,"renderPhaseStates");ni(this,"shouldBeRemoved",!1);ni(this,"children");ni(this,"isPcbPrimitive",!1);ni(this,"isSchematicPrimitive",!1);ni(this,"_renderId");ni(this,"_currentRenderPhase",null);ni(this,"_asyncEffects",[]);ni(this,"parent",null);this._renderId=`${dYe++}`,this.children=[],this.renderPhaseStates={};for(const e of T3)this.renderPhaseStates[e]={initialized:!1,dirty:!1}}_markDirty(r){var t;this.renderPhaseStates[r].dirty=!0;const e=T3.indexOf(r);for(let n=e+1;n<T3.length;n++)this.renderPhaseStates[T3[n]].dirty=!0;(t=this.parent)!=null&&t._markDirty&&this.parent._markDirty(r)}_queueAsyncEffect(r,e){const t={promise:e(),phase:this._currentRenderPhase,effectName:r,complete:!1};this._asyncEffects.push(t),"root"in this&&this.root&&this.root.emit("asyncEffect:start",{effectName:r,componentDisplayName:this.getString(),phase:t.phase}),t.promise.then(()=>{t.complete=!0,"root"in this&&this.root&&this.root.emit("asyncEffect:end",{effectName:r,componentDisplayName:this.getString(),phase:t.phase})}).catch(n=>{console.error(`Async effect error in ${t.phase} "${r}":
|
|
638
|
+
`),{solved:!1,connectionName:r.name}}createObstacleList({dominantLayer:r,connection:e,obstaclesFromTraces:t}){return new Hle(this.allObstacles.filter(n=>!n.connectedTo.includes(e.name)).filter(n=>n.layers.includes(r)).concat(t??[]))}postprocessConnectionSolveResult(r,e){return e}solve(){const r=[],e=[];this.debugTraceCount=0;for(const t of this.input.connections){const n=t.pointsToConnect[0].layer??"top";this.debugTraceCount+=1,this.obstacles=this.createObstacleList({dominantLayer:n,connection:t,obstaclesFromTraces:e});let i=this.solveConnection(t);i=this.postprocessConnectionSolveResult(t,i),r.push(i),VS.enabled&&this.drawDebugTraceObstacles(e),i.solved&&e.push(...Ble(i.route.map(a=>({x:a.x,y:a.y,layer:a.layer??n})),t.name))}return r}solveAndMapToTraces(){return this.solve().flatMap(e=>e.solved?[{type:"pcb_trace",pcb_trace_id:`pcb_trace_for_${e.connectionName}`,route:hGe(e.route.map(t=>({route_type:"wire",x:t.x,y:t.y,width:this.input.minTraceWidth,layer:t.layer})))}]:[])}getDebugGroup(){const r=`t${this.debugTraceCount}_iter[${this.iterations-1}]`;return this.iterations<30||this.iterations<100&&this.iterations%10===0||this.iterations<1e3&&this.iterations%100===0||!this.debugSolutions?r:null}drawDebugTraceObstacles(r){const{debugTraceCount:e,debugSolutions:t}=this;for(const n in t)n.startsWith(`t${e}_`)&&t[n].push(...r.map((i,a)=>({type:"pcb_smtpad",pcb_component_id:"",layer:i.layers[0],width:i.width,shape:"rect",x:i.center.x,y:i.center.y,pcb_smtpad_id:`trace_obstacle_${a}`,height:i.height})))}drawDebugSolution({current:r,newNeighbors:e}){const t=this.getDebugGroup();if(!t)return;const{openSet:n,debugTraceCount:i,debugSolutions:a}=this;a[t]??(a[t]=[]);const o=a[t];o.push({type:"pcb_fabrication_note_text",pcb_fabrication_note_text_id:`debug_note_${r.x}_${r.y}`,font:"tscircuit2024",font_size:.25,text:"X"+(r.l!==void 0?r.l:""),pcb_component_id:"",layer:"top",anchor_position:{x:r.x,y:r.y},anchor_alignment:"center"});for(let s=0;s<n.length;s++){const l=n[s];o.push({type:"pcb_fabrication_note_path",pcb_component_id:"",pcb_fabrication_note_path_id:`note_path_${l.x}_${l.y}`,layer:"top",route:[[0,.05],[.05,0],[0,-.05],[-.05,0],[0,.05]].map(([c,u])=>({x:l.x+c,y:l.y+u})),stroke_width:.01}),o.push({type:"pcb_fabrication_note_text",pcb_fabrication_note_text_id:`debug_note_${l.x}_${l.y}`,font:"tscircuit2024",font_size:.03,text:s.toString(),pcb_component_id:"",layer:"top",anchor_position:{x:l.x,y:l.y},anchor_alignment:"center"})}if(r.parent){const s=[];let l=r;for(;l;)s.unshift(l),l=l.parent;o.push({type:"pcb_fabrication_note_path",pcb_component_id:"",pcb_fabrication_note_path_id:`note_path_${r.x}_${r.y}`,layer:"top",route:s,stroke_width:.01})}}},mGe=g2("autorouting-dataset:infinite-grid-ijump-astar:get-distance-to-overcome-obstacle");function NI({node:r,travelDir:e,wallDir:t,obstacle:n,obstacles:i,obstaclesInRow:a=0,OBSTACLE_MARGIN:o=.15,SHOULD_DETECT_CONJOINED_OBSTACLES:s=!1,MAX_CONJOINED_OBSTACLES:l=20}){let c;if(e.dx===0?e.dy>0?c=n.center.y+n.height/2-r.y:c=r.y-(n.center.y-n.height/2):e.dx>0?c=n.center.x+n.width/2-r.x:c=r.x-(n.center.x-n.width/2),c+=o,s&&a<l){const u=i.getObstacleAt(r.x+e.dx*c+t.dx*(t.wallDistance+.001),r.y+e.dy*c+t.dy*(t.wallDistance+.001));if(u===n)return c;if(u&&u.type==="rect"){const h=e.dy===0,g=h?n.height:n.width;if((h?u.height:u.width)>g)return mGe("next obstacle on path is bigger, not trying to overcome it"),c;const b=NI({node:{x:r.x+e.dx*c,y:r.y+e.dy*c},travelDir:e,wallDir:t,obstacle:u,obstacles:i,obstaclesInRow:a+1,SHOULD_DETECT_CONJOINED_OBSTACLES:s,MAX_CONJOINED_OBSTACLES:l,OBSTACLE_MARGIN:o});c+=b}}return c}var vGe=class extends jle{constructor(){super(...arguments);ni(this,"MAX_ITERATIONS",200)}getNeighbors(e){const t=this.obstacles,n=this.goalPoint;let i;e.parent?i=zle(e.parent,e):i=zle(e,n);const a=[{dx:0,dy:1},{dx:1,dy:0},{dx:0,dy:-1},{dx:-1,dy:0}].filter(s=>{var l;return s.dx===i.dx*-1&&s.dy===i.dy*-1?!1:!(s.dx===i.dx&&s.dy===i.dy&&((l=e.parent)!=null&&l.obstacleHit))}).map(s=>t.getOrthoDirectionCollisionInfo(e,s,{margin:this.OBSTACLE_MARGIN})).filter(s=>s.wallDistance>=this.OBSTACLE_MARGIN),o=[];for(const s of a){let l=null;e!=null&&e.obstacleHit&&(l=NI({node:e,travelDir:s,wallDir:{...i,wallDistance:this.OBSTACLE_MARGIN},obstacle:e.obstacleHit,obstacles:t,OBSTACLE_MARGIN:this.OBSTACLE_MARGIN,SHOULD_DETECT_CONJOINED_OBSTACLES:!0}));const c=Fle(e,n,s),u=(s.dx===0||Math.sign(n.x-e.x)===s.dx)&&(s.dy===0||Math.sign(n.y-e.y)===s.dy);c<s.wallDistance&&c>0&&u?o.push({...s,travelDistance:c}):l!==null&&l<s.wallDistance?o.push({...s,travelDistance:l}):s.wallDistance!==1/0&&o.push({...s,travelDistance:s.wallDistance-this.OBSTACLE_MARGIN})}return o.filter(s=>!t.isObstacleAt(e.x+s.dx*s.travelDistance,e.y+s.dy*s.travelDistance)).map(s=>({x:e.x+s.dx*s.travelDistance,y:e.y+s.dy*s.travelDistance,obstacleHit:s.obstacle}))}};function yGe(r,e=4){const{center:t,width:n,height:i,rotation:a}=r,o=[],s=a*Math.PI/180,l=Math.cos(s),c=Math.sin(s),u=(a%360+360)%360;if(i<=n?u>=45&&u<135||u>=225&&u<315:u>=135&&u<225||u>=315||u<45){const g=n/e;for(let _=0;_<e;_++){const b=(_-e/2+.5)*g,T=-b*l,C=-b*c,A=g*1.1,L=Math.abs(i*l)+Math.abs(g*c);o.push({center:{x:t.x+T,y:t.y+C},width:A,height:L})}}else{const g=i/e;for(let _=0;_<e;_++){const b=(_-e/2+.5)*g,T=-b*c,C=b*l,A=Math.abs(n*l)+Math.abs(g*c),L=g*1.1;o.push({center:{x:t.x+T,y:t.y+C},width:A,height:L})}}return o}var EA=["top","inner1","inner2","bottom"],LI=(r,e)=>{const t=i=>e?i.concat(i.map(a=>e==null?void 0:e.getNetConnectedToId(a)).filter(Boolean)):i,n=[];for(const i of r)if(i.type==="pcb_smtpad"){if(i.shape==="circle")n.push({type:"oval",layers:[i.layer],center:{x:i.x,y:i.y},width:i.radius*2,height:i.radius*2,connectedTo:t([i.pcb_smtpad_id])});else if(i.shape==="rect")n.push({type:"rect",layers:[i.layer],center:{x:i.x,y:i.y},width:i.width,height:i.height,connectedTo:t([i.pcb_smtpad_id])});else if(i.shape==="rotated_rect"){const a={center:{x:i.x,y:i.y},width:i.width,height:i.height,rotation:i.ccw_rotation},o=yGe(a);for(const s of o)n.push({type:"rect",layers:[i.layer],center:s.center,width:s.width,height:s.height,connectedTo:t([i.pcb_smtpad_id])})}}else if(i.type==="pcb_keepout")i.shape==="circle"?n.push({type:"oval",layers:i.layers,center:{x:i.center.x,y:i.center.y},width:i.radius*2,height:i.radius*2,connectedTo:[]}):i.shape==="rect"&&n.push({type:"rect",layers:i.layers,center:{x:i.center.x,y:i.center.y},width:i.width,height:i.height,connectedTo:[]});else if(i.type==="pcb_hole")i.hole_shape==="oval"?n.push({type:"oval",center:{x:i.x,y:i.y},width:i.hole_width,height:i.hole_height,connectedTo:[]}):i.hole_shape==="square"?n.push({type:"rect",layers:EA,center:{x:i.x,y:i.y},width:i.hole_diameter,height:i.hole_diameter,connectedTo:[]}):(i.hole_shape==="round"||i.hole_shape==="circle")&&n.push({type:"rect",layers:EA,center:{x:i.x,y:i.y},width:i.hole_diameter,height:i.hole_diameter,connectedTo:[]});else if(i.type==="pcb_plated_hole")i.shape==="circle"?n.push({type:"oval",layers:EA,center:{x:i.x,y:i.y},width:i.outer_diameter,height:i.outer_diameter,connectedTo:t([i.pcb_plated_hole_id])}):(i.shape==="oval"||i.shape==="pill")&&n.push({type:"oval",layers:EA,center:{x:i.x,y:i.y},width:i.outer_width,height:i.outer_height,connectedTo:t([i.pcb_plated_hole_id])});else if(i.type==="pcb_trace"){const a=Ble(i.route.map(o=>({x:o.x,y:o.y,layer:"layer"in o?o.layer:o.from_layer})),i.source_trace_id);n.push(...a)}else i.type==="pcb_via"&&n.push({type:"rect",layers:i.layers,center:{x:i.x,y:i.y},connectedTo:[],width:i.outer_diameter,height:i.outer_diameter});return n};function Gle(r){const{pcbConnMap:e,goalElementId:t}=r;if(!t.startsWith("pcb_port_"))throw new Error(`Currently alternative goal boxes must have a goal id with prefix "pcb_port_" (got ${t})`);const n=e.getAllTracesConnectedToPort(t);return LI(n).map(i=>({...i,connectedTo:[t]}))}var qle=r=>{let{connection:e,pcbConnMap:t}=r;if(e.pointsToConnect.length!==2)throw new Error(`Connection must have exactly 2 points for alternative goal boxes (got ${e.pointsToConnect.length})`);const[n,i]=e.pointsToConnect;if(!n.pcb_port_id||!i.pcb_port_id)throw new Error(`Connection points must have pcb_port_id for alternative goal box calculation (got ${n.pcb_port_id} and ${i.pcb_port_id})`);const a=Gle({goalElementId:n.pcb_port_id,pcbConnMap:t}).concat([{center:n,width:.01,height:.01,connectedTo:[n.pcb_port_id],layers:[n.layer],type:"rect"}]),o=Gle({goalElementId:i.pcb_port_id,pcbConnMap:t}).concat([{center:i,width:.01,height:.01,connectedTo:[i.pcb_port_id],layers:[i.layer],type:"rect"}]);if(a.length<=1&&o.length<=1)return{...e,startPoint:n,endPoint:i,goalBoxes:[]};const s=uGe(a,o);let l,c,u;return a.length>=o.length?(l={...i,...s.pointB},c={...n,...s.pointA},u=a):(l={...n,...s.pointA},c={...i,...s.pointB},u=o),{startPoint:l,endPoint:c,goalBoxes:u,name:e.name,pointsToConnect:[l,c]}},gGe=(r,e={})=>{const t={minTraceWidth:.1};t.layerCount=e.layerCount??1,t.obstacles=LI(r,e.connMap),t.connections=[];for(const i of r)if(i.type==="source_trace"){let a={name:i.source_trace_id,pointsToConnect:i.connected_source_port_ids.map(o=>{var l;const s=$y(r).pcb_port.getWhere({source_port_id:o});if(!s)throw new Error(`Could not find pcb_port for source_port_id "${o}"`);return{x:s.x,y:s.y,layer:((l=s.layers)==null?void 0:l[0])??"top",pcb_port_id:s.pcb_port_id}})};if(e.optimizeWithGoalBoxes){const o=new Ole(r);a=qle({connection:a,pcbConnMap:o})}t.connections.push(a),_Ge(t.obstacles,a.pointsToConnect,a.name)}const n={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0};for(const i of t.obstacles)n.minX=Math.min(n.minX,i.center.x-i.width/2),n.maxX=Math.max(n.maxX,i.center.x+i.width/2),n.minY=Math.min(n.minY,i.center.y-i.height/2),n.maxY=Math.max(n.maxY,i.center.y+i.height/2);for(const i of t.connections)for(const a of i.pointsToConnect)n.minX=Math.min(n.minX,a.x),n.maxX=Math.max(n.maxX,a.x),n.minY=Math.min(n.minY,a.y),n.maxY=Math.max(n.maxY,a.y);return t.bounds=n,t},_Ge=(r,e,t)=>{for(const n of e)for(const i of r)xGe(n,i)&&i.connectedTo.push(t)};function xGe(r,e){const t=e.width/2,n=e.height/2;if(e.type==="rect")return r.x>=e.center.x-t&&r.x<=e.center.x+t&&r.y>=e.center.y-n&&r.y<=e.center.y+n;if(e.type==="oval"){const i=(r.x-e.center.x)/t,a=(r.y-e.center.y)/n;return i*i+a*a<=1}return!1}function Yle(r,e){const t=e.x>r.x?1:e.x<r.x?-1:0,n=e.y>r.y?1:e.y<r.y?-1:0,i=e.l>r.l?1:e.l<r.l?-1:0;return{dx:t,dy:n,dl:i}}var OI={1:["top"],2:["top","bottom"],4:["top","inner1","inner2","bottom"]},bGe=r=>OI[r];function Xle(r,e){const n=OI[r].indexOf(e);if(n===-1)throw new Error(`Invalid layer for getLayerIndex (for layerCount === ${r}): "${e}"`);return n}function SGe(r,e){const n=OI[r][e];if(!n)throw new Error(`Invalid index for indexToLayer (for layerCount === ${r}): "${e}"`);return n}var EGe=class extends Hle{constructor(e,t){super([]);ni(this,"obstacles");ni(this,"GRID_STEP",.1);ni(this,"layerCount");this.layerCount=e;const n=bGe(e);this.obstacles=t.flatMap(i=>i.layers.filter(a=>n.includes(a)).map(a=>({...i,left:i.center.x-i.width/2,right:i.center.x+i.width/2,top:i.center.y+i.height/2,bottom:i.center.y-i.height/2,l:Xle(e,a)})))}getObstacleAt(e,t,n,i){i??(i=this.GRID_STEP);for(const a of this.obstacles){if(a.l!==n)continue;const o=a.width/2+i,s=a.height/2+i;if(e>=a.center.x-o&&e<=a.center.x+o&&t>=a.center.y-s&&t<=a.center.y+s)return a}return null}isObstacleAt(e,t,n,i){return this.getObstacleAt(e,t,n,i)!==null}getDirectionDistancesToNearestObstacle3d(e,t,n){const{GRID_STEP:i}=this,a={left:1/0,top:1/0,bottom:1/0,right:1/0};for(const o of this.obstacles)if(o.l===n&&o.type==="rect"){const s=o.center.x-o.width/2-i,l=o.center.x+o.width/2+i,c=o.center.y+o.height/2+i,u=o.center.y-o.height/2-i;t>=u&&t<=c&&e>s&&(a.left=Math.min(a.left,e-l)),t>=u&&t<=c&&e<l&&(a.right=Math.min(a.right,s-e)),e>=s&&e<=l&&t<c&&(a.top=Math.min(a.top,u-t)),e>=s&&e<=l&&t>u&&(a.bottom=Math.min(a.bottom,t-c))}return a}getOrthoDirectionCollisionInfo(e,t,{margin:n=0}={}){const{x:i,y:a,l:o}=e,{dx:s,dy:l,dl:c}=t;let u=1/0,h=null;if(c!==0){const g=o+c;return this.isObstacleAt(i,a,g,n)?(u=1,h=this.getObstacleAt(i,a,g,n)):u=1,{dx:s,dy:l,dl:c,wallDistance:u,obstacle:h}}else{for(const g of this.obstacles){if(g.l!==o)continue;const _=g.left-n,b=g.right+n,T=g.top+n,C=g.bottom-n;let A=null;s===1&&l===0?a>C&&a<T&&i<g.left&&(A=g.left-i):s===-1&&l===0?a>C&&a<T&&i>g.right&&(A=i-g.right):s===0&&l===1?i>_&&i<b&&a<g.bottom&&(A=g.bottom-a):s===0&&l===-1&&i>_&&i<b&&a>g.top&&(A=a-g.top),A!==null&&A<u&&(u=A,h=g)}return{dx:s,dy:l,dl:0,wallDistance:u,obstacle:h}}}getObstaclesOverlappingRegion(e){const t=[];for(const n of this.obstacles){if(n.l!==e.l)continue;const{left:i,right:a,top:o,bottom:s}=n;i<=e.maxX&&a>=e.minX&&o>=e.minY&&s<=e.maxY&&t.push(n)}return t}},Wle=class extends jle{constructor(e){super(e);ni(this,"MAX_ITERATIONS",500);ni(this,"VIA_COST",4);ni(this,"VIA_DIAMETER",.5);ni(this,"allowLayerChange",!0);ni(this,"layerCount");ni(this,"obstacles");ni(this,"optimizeWithGoalBoxes");ni(this,"connMap");ni(this,"pcbConnMap");ni(this,"GOAL_RUSH_FACTOR",1.1);ni(this,"defaultGoalViaMargin",.5);ni(this,"marginsWithCosts");this.layerCount=e.input.layerCount??2,this.MAX_ITERATIONS=e.MAX_ITERATIONS??this.MAX_ITERATIONS,this.VIA_COST=e.VIA_COST??this.VIA_COST,this.connMap=e.connMap,this.pcbConnMap=e.pcbConnMap??new Ole,this.optimizeWithGoalBoxes=e.optimizeWithGoalBoxes??!1,this.obstacles=null,this.marginsWithCosts=e.marginsWithCosts??[{margin:1,enterCost:0,travelCostFactor:1},{margin:this.OBSTACLE_MARGIN,enterCost:10,travelCostFactor:2}]}get largestMargin(){return this.marginsWithCosts[0].margin}preprocessConnectionBeforeSolving(e){return this.optimizeWithGoalBoxes?qle({connection:e,pcbConnMap:this.pcbConnMap}):e}postprocessConnectionSolveResult(e,t){if(!t.solved)return t;if(this.optimizeWithGoalBoxes){const n=t.route.map(i=>({x:i.x,y:i.y,route_type:"wire",layer:i.layer,width:this.input.minTraceWidth}));n[0].start_pcb_port_id=e.pointsToConnect[0].pcb_port_id,n[n.length-1].end_pcb_port_id=e.pointsToConnect[1].pcb_port_id,this.pcbConnMap.addTrace({type:"pcb_trace",pcb_trace_id:`postprocess_trace_${Dz(8)}`,route:n})}return t}createObstacleList({dominantLayer:e,connection:t,obstaclesFromTraces:n}){const i=this.connMap?this.connMap.getNetConnectedToId(t.name):t.name;if(!i)throw new Error(`The connection.name "${t.name}" wasn't present in the full connectivity map`);return new EGe(this.layerCount,this.allObstacles.filter(a=>!a.connectedTo.includes(i)).concat(n??[]))}computeG(e,t){let n=e.g+HS(e,t)*(e.travelMarginCostFactor??1)+(t.enterMarginCost??0);return(t.l??e.l!==-1??-1)&&(n+=this.VIA_COST),n}computeH(e){const t=Math.abs(e.x-this.goalPoint.x),n=Math.abs(e.y-this.goalPoint.y),i=Math.abs(e.l-this.goalPoint.l);return(t+n)**this.GOAL_RUSH_FACTOR+i*this.VIA_COST}getStartNode(e){return{...super.getStartNode(e),l:this.layerToIndex(e.pointsToConnect[0].layer)}}layerToIndex(e){return Xle(this.layerCount,e)}indexToLayer(e){return SGe(this.layerCount,e)}getNodeName(e){return`${Ile(e,this.GRID_STEP)}-${e.l??0}`}hasSpaceForVia(e,t){return e.every(n=>this.obstacles.getObstaclesOverlappingRegion({minX:t.x-this.VIA_DIAMETER/2-this.OBSTACLE_MARGIN,minY:t.y-this.VIA_DIAMETER/2-this.OBSTACLE_MARGIN,maxX:t.x+this.VIA_DIAMETER/2+this.OBSTACLE_MARGIN,maxY:t.y+this.VIA_DIAMETER/2+this.OBSTACLE_MARGIN,l:n}).length===0)}getNeighborsSurroundingGoal(e){this.obstacles;const t=this.goalPoint,n=[],i=[{dx:1,dy:0,dl:0},{dx:-1,dy:0,dl:0},{dx:0,dy:1,dl:0},{dx:0,dy:-1,dl:0}],a=this.VIA_DIAMETER+this.OBSTACLE_MARGIN+this.defaultGoalViaMargin;for(const o of i){const s={x:e.x+o.dx*a,y:e.y+o.dy*a,l:e.l+o.dl,obstacleHit:null};this.hasSpaceForVia([e.l,t.l],s)&&n.push(s)}return n}getNeighbors(e){const t=this.obstacles,n=this.goalPoint,i=HS(e,n);if(i<=this.OBSTACLE_MARGIN)return this.getNeighborsSurroundingGoal(e);let a;e.parent?a=Yle(e.parent,e):a=Yle(e,n);const o=[{dx:0,dy:1,dl:0},{dx:1,dy:0,dl:0},{dx:0,dy:-1,dl:0},{dx:-1,dy:0,dl:0}],s=i>this.VIA_DIAMETER+this.OBSTACLE_MARGIN,l=HS(e,this.startNode)>this.VIA_DIAMETER+this.OBSTACLE_MARGIN;this.allowLayerChange&&s&&l&&(e.l<this.layerCount-1&&o.push({dx:0,dy:0,dl:1}),e.l>0&&o.push({dx:0,dy:0,dl:-1}));const c=o.filter(h=>{var g;return h.dx===a.dx*-1&&h.dy===a.dy*-1&&h.dl===a.dl*-1?!1:!(h.dx===a.dx&&h.dy===a.dy&&h.dl===a.dl&&((g=e.parent)!=null&&g.obstacleHit))}).map(h=>t.getOrthoDirectionCollisionInfo(e,h,{margin:this.OBSTACLE_MARGIN})).filter(h=>!(h.wallDistance<this.OBSTACLE_MARGIN)),u=[];for(const h of c){const g=h.dx===0&&h.dy===0&&h.dl===1,_=h.dx===0&&h.dy===0&&h.dl===-1;if((g||_)&&![e.l,e.l+h.dl].every(L=>t.getObstaclesOverlappingRegion({minX:e.x-this.VIA_DIAMETER/2-this.OBSTACLE_MARGIN,minY:e.y-this.VIA_DIAMETER/2-this.OBSTACLE_MARGIN,maxX:e.x+this.VIA_DIAMETER/2+this.OBSTACLE_MARGIN,maxY:e.y+this.VIA_DIAMETER/2+this.OBSTACLE_MARGIN,l:L}).length===0))continue;if(g){e.l<this.layerCount-1&&u.push({...h,travelDistance:0,enterMarginCost:0,travelMarginCostFactor:1});continue}if(_){e.l>0&&u.push({...h,travelDistance:0,enterMarginCost:0,travelMarginCostFactor:1});continue}let b=null;e!=null&&e.obstacleHit&&(b=NI({node:e,travelDir:h,wallDir:{...a,wallDistance:this.OBSTACLE_MARGIN},obstacle:e.obstacleHit,obstacles:t,OBSTACLE_MARGIN:this.OBSTACLE_MARGIN,SHOULD_DETECT_CONJOINED_OBSTACLES:!0}));const T=Fle(e,n,h),C=(h.dx===0||Math.sign(n.x-e.x)===h.dx)&&(h.dy===0||Math.sign(n.y-e.y)===h.dy);if(T<h.wallDistance&&T>0&&C){const A=e.l===n.l;let L=0;!A&&Math.abs(T-i)<this.GRID_STEP&&(L=this.VIA_DIAMETER+this.OBSTACLE_MARGIN+this.defaultGoalViaMargin),u.push({...h,travelDistance:T-L,enterMarginCost:0,travelMarginCostFactor:1})}else if(b!==null&&b<h.wallDistance){for(const{margin:A,enterCost:L,travelCostFactor:U}of this.marginsWithCosts)b-this.OBSTACLE_MARGIN+A*2<h.wallDistance&&u.push({...h,travelDistance:b-this.OBSTACLE_MARGIN+A,enterMarginCost:L,travelMarginCostFactor:U});if(h.wallDistance===1/0)u.push({...h,travelDistance:T,enterMarginCost:0,travelMarginCostFactor:1});else if(h.wallDistance>this.largestMargin)for(const{margin:A,enterCost:L,travelCostFactor:U}of this.marginsWithCosts)h.wallDistance>this.largestMargin+A&&u.push({...h,travelDistance:h.wallDistance-A,enterMarginCost:L,travelMarginCostFactor:U})}else if(h.wallDistance!==1/0)for(const{margin:A,enterCost:L,travelCostFactor:U}of this.marginsWithCosts)h.wallDistance>A&&u.push({...h,travelDistance:h.wallDistance-A,enterMarginCost:L,travelMarginCostFactor:U})}return u.map(h=>({x:e.x+h.dx*h.travelDistance,y:e.y+h.dy*h.travelDistance,l:e.l+h.dl,obstacleHit:h.obstacle,travelMarginCostFactor:h.travelMarginCostFactor,enterMarginCost:h.enterMarginCost}))}};function wGe(r){const e=gGe(r),t=new vGe({input:e});return{solution:t.solveAndMapToTraces(),debugSolutions:t.debugSolutions,debugMessage:t.debugMessage}}var $le=LI,TGe=ue.enum(["up","down","left","right"]);ue.enum(["top-to-bottom","left-to-right","bottom-to-top","right-to-left"]);var jS=ue.array(ue.string().or(ue.number())),Zle=ue.object({x:wi,y:wi,z:wi}),MGe=ue.object({x:ue.union([ue.number(),ue.string()]),y:ue.union([ue.number(),ue.string()]),z:ue.union([ue.number(),ue.string()])}),UI=ue.object({rotationOffset:ue.number().or(MGe).optional(),positionOffset:Zle.optional(),size:Zle.optional()}),CGe=UI.extend({stlUrl:ue.string()}),RGe=UI.extend({objUrl:ue.string(),mtlUrl:ue.string().optional()}),AGe=UI.extend({jscad:ue.record(ue.any())}),DGe=ue.union([ue.string(),CGe,RGe,AGe]),PGe=ue.custom(r=>!0),Rx=ue.object({pcbX:wi.optional(),pcbY:wi.optional(),pcbRotation:Z4.optional(),layer:My.optional()}),wA=ue.object({pcbX:wi.optional(),pcbY:wi.optional(),pcbRotation:Z4.optional(),schX:wi.optional(),schY:wi.optional(),schRotation:Z4.optional(),layer:My.optional(),footprint:PGe.optional()}),NGe=ue.object({supplierPartNumbers:ue.record(Oz,ue.array(ue.string())).optional()}),m5=wA.merge(NGe).extend({key:ue.any().optional(),name:ue.string(),cadModel:DGe.optional(),children:ue.any().optional(),symbolName:ue.string().optional()});wi.or(ue.enum(["2x","3x","4x"]));var TA=ue.object({pins:ue.array(ue.union([ue.number(),ue.string()])),direction:ue.union([ue.literal("top-to-bottom"),ue.literal("left-to-right"),ue.literal("bottom-to-top"),ue.literal("right-to-left")])}),zI=ue.object({leftSize:ue.number().optional().describe("@deprecated, use leftPinCount"),topSize:ue.number().optional().describe("@deprecated, use topPinCount"),rightSize:ue.number().optional().describe("@deprecated, use rightPinCount"),bottomSize:ue.number().optional().describe("@deprecated, use bottomPinCount"),leftPinCount:ue.number().optional(),rightPinCount:ue.number().optional(),topPinCount:ue.number().optional(),bottomPinCount:ue.number().optional(),leftSide:TA.optional(),rightSide:TA.optional(),topSide:TA.optional(),bottomSide:TA.optional()}),Qle=ue.record(ue.object({marginLeft:wi.optional(),marginRight:wi.optional(),marginTop:wi.optional(),marginBottom:wi.optional(),leftMargin:wi.optional(),rightMargin:wi.optional(),topMargin:wi.optional(),bottomMargin:wi.optional()})),Kle=ue.object({x:wi,y:wi}),FI=ue.object({edit_event_id:ue.string(),in_progress:ue.boolean().optional(),created_at:ue.number()}),LGe=FI.extend({pcb_edit_event_type:ue.literal("edit_component_location").describe("deprecated"),edit_event_type:ue.literal("edit_pcb_component_location"),pcb_component_id:ue.string(),original_center:ue.object({x:ue.number(),y:ue.number()}),new_center:ue.object({x:ue.number(),y:ue.number()})}),OGe=FI.extend({pcb_edit_event_type:ue.literal("edit_trace_hint").describe("deprecated"),edit_event_type:ue.literal("edit_pcb_trace_hint").optional(),pcb_port_id:ue.string(),pcb_trace_hint_id:ue.string().optional(),route:ue.array(ue.object({x:ue.number(),y:ue.number(),via:ue.boolean().optional()}))}),UGe=FI.extend({edit_event_type:ue.literal("edit_schematic_component_location"),schematic_component_id:ue.string(),original_center:ue.object({x:ue.number(),y:ue.number()}),new_center:ue.object({x:ue.number(),y:ue.number()})});ue.union([LGe,OGe,UGe]);var zGe=ue.object({selector:ue.string(),relative_to:ue.string().optional().default("group_center").describe("Can be a selector or 'group_center'"),center:L1}),FGe=ue.object({pcb_port_selector:ue.string(),offsets:ue.array(i4)}),IGe=ue.object({selector:ue.string(),relative_to:ue.string().optional().default("group_center").describe("Can be a selector or 'group_center'"),center:L1}),kGe=ue.object({pcb_placements:ue.array(zGe).optional(),manual_trace_hints:ue.array(FGe).optional(),schematic_placements:ue.array(IGe).optional()}),BGe=ue.object({serverUrl:ue.string().optional(),inputFormat:ue.enum(["simplified","circuit-json"]).optional(),serverMode:ue.enum(["job","solve-endpoint"]).optional(),serverCacheEnabled:ue.boolean().optional(),cache:ue.custom(r=>!0).optional(),groupMode:ue.enum(["sequential-trace","subcircuit"]).optional(),local:ue.boolean().optional()}),Jle=ue.union([BGe,ue.literal("sequential-trace"),ue.literal("subcircuit"),ue.literal("auto"),ue.literal("auto-local"),ue.literal("auto-cloud")]),ece=wA.extend({name:ue.string().optional(),children:ue.any().optional(),key:ue.any().optional()}),tce=ue.custom(r=>"findPart"in r),nce=ece.extend({layout:ue.custom(r=>!0).optional(),manualEdits:kGe.optional(),schAutoLayoutEnabled:ue.boolean().optional(),schTraceAutoLabelEnabled:ue.boolean().optional(),routingDisabled:ue.boolean().optional(),defaultTraceWidth:pr.optional(),minTraceWidth:pr.optional(),partsEngine:tce.optional(),pcbRouteCache:ue.custom(r=>!0).optional(),autorouter:Jle.optional()}),HGe=nce.extend({subcircuit:ue.literal(!0)}),VGe=ue.discriminatedUnion("subcircuit",[ece.extend({subcircuit:ue.literal(!1).optional()}),HGe]),jGe=nce.extend({width:wi.optional(),height:wi.optional(),outline:ue.array(Kle).optional(),outlineOffsetX:wi.optional(),outlineOffsetY:wi.optional()}),GGe=ue.string().or(ue.array(ue.string()).readonly()).or(ue.array(ue.string())),qGe=ue.record(ue.number().or(ue.string()),GGe);ue.record(ue.number().or(ue.string()),ue.string().or(ue.array(ue.string()).readonly()).or(ue.array(ue.string())));var YGe=m5.extend({manufacturerPartNumber:ue.string().optional(),pinLabels:ue.record(ue.number().or(ue.string()),ue.string().or(ue.array(ue.string()).readonly())).optional(),internallyConnectedPins:ue.array(ue.array(ue.string())).optional(),externallyConnectedPins:ue.array(ue.array(ue.string())).optional(),schPinArrangement:zI.optional(),schPortArrangement:zI.optional(),schPinStyle:Qle.optional(),schPinSpacing:wi.optional(),schWidth:wi.optional(),schHeight:wi.optional(),noSchematicRepresentation:ue.boolean().optional(),connections:qGe.optional()}),XGe=m5.extend({manufacturerPartNumber:ue.string().optional(),pinLabels:ue.record(ue.number().or(ue.string()),ue.string().or(ue.array(ue.string()))).optional(),schPinStyle:Qle.optional(),schPinSpacing:wi.optional(),schWidth:wi.optional(),schHeight:wi.optional(),schDirection:ue.enum(["left","right"]).optional(),schPortArrangement:zI.optional()}),WGe=ue.discriminatedUnion("shape",[Rx.omit({pcbRotation:!0,layer:!0}).extend({name:ue.string().optional(),shape:ue.literal("circle"),holeDiameter:wi,outerDiameter:wi,portHints:jS.optional()}),Rx.omit({pcbRotation:!0,layer:!0}).extend({name:ue.string().optional(),shape:ue.literal("oval"),outerWidth:wi,outerHeight:wi,innerWidth:wi,innerHeight:wi,portHints:jS.optional()}),Rx.omit({pcbRotation:!0,layer:!0}).extend({name:ue.string().optional(),shape:ue.literal("pill"),outerWidth:wi,outerHeight:wi,innerWidth:wi,innerHeight:wi,portHints:jS.optional()})]),$Ge=m5.extend({resistance:A8,pullupFor:ue.string().optional(),pullupTo:ue.string().optional(),pulldownFor:ue.string().optional(),pulldownTo:ue.string().optional()}),ZGe=m5.extend({maxResistance:A8,pinVariant:ue.enum(["two_pin","three_pin"]).optional()}),QGe=m5.extend({frequency:rR,loadCapacitance:D8,pinVariant:ue.enum(["two_pin","four_pin"]).optional()}),KGe=m5.extend({frequency:rR,loadCapacitance:D8,pinVariant:ue.enum(["no_ground","ground_pin","two_ground_pins"]).optional()}),JGe=m5.extend({capacitance:D8,maxVoltageRating:uT.optional(),schShowRatings:ue.boolean().optional().default(!1),polarized:ue.boolean().optional().default(!1),decouplingFor:ue.string().optional(),decouplingTo:ue.string().optional(),bypassFor:ue.string().optional(),bypassTo:ue.string().optional(),maxDecouplingTraceLength:ue.number().optional()});ue.object({name:ue.string()}),ue.object({name:ue.string().optional(),pcbOnly:ue.boolean().optional(),schOnly:ue.boolean().optional()});var eqe=ue.object({pcb:ue.literal(!0).optional(),xDist:wi,left:ue.string(),right:ue.string(),edgeToEdge:ue.literal(!0).optional(),centerToCenter:ue.literal(!0).optional()}),tqe=ue.object({pcb:ue.literal(!0).optional(),yDist:wi,top:ue.string(),bottom:ue.string(),edgeToEdge:ue.literal(!0).optional(),centerToCenter:ue.literal(!0).optional()}),nqe=ue.object({pcb:ue.literal(!0).optional(),sameY:ue.literal(!0).optional(),for:ue.array(ue.string())}),rqe=ue.object({pcb:ue.literal(!0).optional(),sameX:ue.literal(!0).optional(),for:ue.array(ue.string())}),iqe=ue.union([eqe,tqe,nqe,rqe]),aqe=Rx.omit({pcbRotation:!0}).extend({shape:ue.literal("rect"),width:wi,height:wi,portHints:jS.optional()}),oqe=Rx.omit({pcbRotation:!0}).extend({shape:ue.literal("rotated_rect"),width:wi,height:wi,ccwRotation:ue.number(),portHints:jS.optional()}),sqe=Rx.omit({pcbRotation:!0}).extend({shape:ue.literal("circle"),radius:wi,portHints:jS.optional()}),lqe=Rx.omit({pcbRotation:!0}).extend({shape:ue.literal("pill"),width:wi,height:wi,radius:wi,portHints:jS.optional()}),cqe=ue.union([sqe,aqe,oqe,lqe]),uqe=Rx.omit({pcbRotation:!0}).extend({shape:ue.literal("rect"),width:wi,height:wi}),fqe=Rx.omit({pcbRotation:!0}).extend({shape:ue.literal("circle"),radius:wi});ue.union([fqe,uqe]);var dqe=Rx.omit({pcbRotation:!0}).extend({name:ue.string().optional(),diameter:wi.optional(),radius:wi.optional()}).transform(r=>({...r,diameter:r.diameter??2*r.radius,radius:r.radius??r.diameter/2})),II=ue.union([ue.string(),ue.custom(r=>!!r.getPortSelector)]),rce=ue.object({key:ue.string().optional(),thickness:wi.optional(),schematicRouteHints:ue.array(Kle).optional(),pcbRouteHints:ue.array(i4).optional(),schDisplayLabel:ue.string().optional(),maxLength:wi.optional()}),hqe=ue.union([rce.extend({path:ue.array(II)}),rce.extend({from:II,to:II})]),pqe=ue.object({originalLayer:My.default("top").optional()}),mqe=ue.number().or(ue.string().endsWith("mAh")).transform(r=>{if(typeof r=="string"){const e=r.replace("mAh",""),t=Number.parseFloat(e);if(Number.isNaN(t))throw new Error("Invalid capacity");return t}return r}).describe("Battery capacity in mAh"),vqe=m5.extend({capacity:mqe.optional()}),yqe=m5.extend({pinCount:ue.number(),pitch:wi.optional(),schFacingDirection:ue.enum(["up","down","left","right"]).optional(),gender:ue.enum(["male","female"]).optional().default("male"),showSilkscreenPinLabels:ue.boolean().optional(),doubleRow:ue.boolean().optional(),holeDiameter:wi.optional(),platedDiameter:wi.optional(),pinLabels:ue.array(ue.string()).optional(),facingDirection:ue.enum(["left","right"]).optional()}),gqe=ue.object({net:ue.string().optional(),schX:wi.optional(),schY:wi.optional(),schRotation:Z4.optional(),anchorSide:ue.enum(["left","up","right","down"]).optional()}),_qe=m5.extend({internallyConnectedPins:ue.array(ue.array(ue.string())).optional()}),xqe=m5.extend({type:ue.enum(["npn","pnp","bjt","jfet","mosfet"])}),bqe=m5.extend({channelType:ue.enum(["n","p"]),mosfetMode:ue.enum(["enhancement","depletion"])}),Sqe=m5.extend({inductance:Nz}),Eqe=m5.extend({}),wqe=m5.extend({color:ue.string().optional()}),Tqe=m5.extend({type:ue.enum(["spst","spdt","dpst","dpdt"]).optional(),isNormallyClosed:ue.boolean().optional().default(!1),spst:ue.boolean().optional(),spdt:ue.boolean().optional(),dpst:ue.boolean().optional(),dpdt:ue.boolean().optional()}).transform(r=>{const e={...r};switch(e.dpdt?e.type="dpdt":e.spst?e.type="spst":e.spdt?e.type="spdt":e.dpst&&(e.type="dpst"),e.type){case"spdt":e.spdt=!0;break;case"spst":e.spst=!0;break;case"dpst":e.dpst=!0;break;case"dpdt":e.dpdt=!0;break}return e}),Mqe=Rx.extend({text:ue.string(),anchorAlignment:ue.enum(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),font:ue.enum(["tscircuit2024"]).optional(),fontSize:pr.optional(),color:ue.string().optional()}),Cqe=Rx.omit({pcbX:!0,pcbY:!0,pcbRotation:!0}).extend({route:ue.array(i4),strokeWidth:pr.optional(),color:ue.string().optional()});ue.object({layer:ue.string().optional(),thickness:wi.optional(),route:ue.array(i4)});var Rqe=wA.extend({fromLayer:My,toLayer:My,holeDiameter:wi,outerDiameter:wi}),Aqe=ue.union([Rx.omit({pcbRotation:!0}).extend({shape:ue.literal("circle"),radius:wi}),Rx.extend({shape:ue.literal("rect"),width:wi,height:wi})]),Dqe=m5.extend({voltage:uT});ue.object({schX:wi,schY:wi,width:wi,height:wi}),ue.object({x1:wi,y1:wi,x2:wi,y2:wi}),ue.object({schX:wi,schY:wi,text:ue.string()}),ue.object({points:ue.array(L1),isFilled:ue.boolean().optional().default(!1),fillColor:ue.enum(["red","blue"]).optional()});var Pqe=Rx.extend({text:ue.string(),anchorAlignment:ue.enum(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),font:ue.enum(["tscircuit2024"]).optional(),fontSize:pr.optional()}),Nqe=Rx.omit({pcbX:!0,pcbY:!0,pcbRotation:!0}).extend({route:ue.array(i4),strokeWidth:pr.optional()}),Lqe=Rx.omit({pcbX:!0,pcbY:!0,pcbRotation:!0}).extend({strokeWidth:wi,x1:wi,y1:wi,x2:wi,y2:wi}),Oqe=Rx.omit({pcbRotation:!0}).extend({isFilled:ue.boolean().optional(),isOutline:ue.boolean().optional(),strokeWidth:wi.optional(),width:wi,height:wi}),Uqe=Rx.omit({pcbRotation:!0}).extend({isFilled:ue.boolean().optional(),isOutline:ue.boolean().optional(),strokeWidth:wi.optional(),radius:wi}),ice=ue.object({x:wi,y:wi,via:ue.boolean().optional(),toLayer:My.optional()}),zqe=ue.object({for:ue.string().optional().describe("Selector for the port you're targeting, not required if you're inside a trace"),order:ue.number().optional(),offset:i4.or(ice).optional(),offsets:ue.array(i4).or(ue.array(ice)).optional(),traceWidth:ue.number().optional()});wA.extend({name:ue.string(),pinNumber:ue.number().optional(),aliases:ue.array(ue.string()).optional(),direction:TGe}),ue.object({partsEngine:tce.optional(),autorouter:Jle.optional(),registryApiUrl:ue.string().optional(),cloudAutorouterUrl:ue.string().optional()});function I8(){return new kI}class kI{constructor(){ni(this,"index",{});ni(this,"array",[])}size(){return this.array.length}empty(){return this.array.length===0}itemAt(e){return this.array[e]}contains(e){return this.index[e.id()]!==void 0}find(e){const t=this.index[e.id()];return t===void 0?void 0:this.array[t]}setDefault(e,t){const n=this.index[e.id()];if(n===void 0){const i=new MA(e,t());return this.index[e.id()]=this.array.length,this.array.push(i),i}else return this.array[n]}insert(e,t){const n=new MA(e,t),i=this.index[e.id()];return i===void 0?(this.index[e.id()]=this.array.length,this.array.push(n)):this.array[i]=n,n}erase(e){const t=this.index[e.id()];if(t===void 0)return;this.index[e.id()]=void 0;const n=this.array[t],i=this.array.pop();return n!==i&&(this.array[t]=i,this.index[i.first.id()]=t),n}copy(){const e=new kI;for(let t=0;t<this.array.length;t++){const n=this.array[t].copy();e.array[t]=n,e.index[n.first.id()]=t}return e}}class MA{constructor(e,t){ni(this,"first");ni(this,"second");this.first=e,this.second=t}copy(){return new MA(this.first,this.second)}}class BI{constructor(e=""){ni(this,"_name");ni(this,"_value",0);ni(this,"_context",null);ni(this,"_id",Fqe++);this._name=e}id(){return this._id}name(){return this._name}setName(e){this._name=e}context(){return this._context}setContext(e){this._context=e}value(){return this._value}setValue(e){this._value=e}plus(e){return new Ax(this,e)}minus(e){return new Ax(this,typeof e=="number"?-e:[-1,e])}multiply(e){return new Ax([e,this])}divide(e){return new Ax([1/e,this])}toJSON(){return{name:this._name,value:this._value}}toString(){return this._context+"["+this._name+":"+this._value+"]"}}let Fqe=0;class Ax{constructor(){ni(this,"_terms");ni(this,"_constant");let e=Iqe(arguments);this._terms=e.terms,this._constant=e.constant}terms(){return this._terms}constant(){return this._constant}value(){let e=this._constant;for(let t=0,n=this._terms.size();t<n;t++){let i=this._terms.itemAt(t);e+=i.first.value()*i.second}return e}plus(e){return new Ax(this,e)}minus(e){return new Ax(this,typeof e=="number"?-e:[-1,e])}multiply(e){return new Ax([e,this])}divide(e){return new Ax([1/e,this])}isConstant(){return this._terms.size()==0}toString(){let e=this._terms.array.map(function(t){return t.second+"*"+t.first.toString()}).join(" + ");return!this.isConstant()&&this._constant!==0&&(e+=" + "),e+=this._constant,e}}function Iqe(r){let e=0,t=()=>0,n=I8();for(let i=0,a=r.length;i<a;++i){let o=r[i];if(typeof o=="number")e+=o;else if(o instanceof BI)n.setDefault(o,t).second+=1;else if(o instanceof Ax){e+=o.constant();let s=o.terms();for(let l=0,c=s.size();l<c;l++){let u=s.itemAt(l);n.setDefault(u.first,t).second+=u.second}}else if(o instanceof Array){if(o.length!==2)throw new Error("array must have length 2");let s=o[0],l=o[1];if(typeof s!="number")throw new Error("array item 0 must be a number");if(l instanceof BI)n.setDefault(l,t).second+=s;else if(l instanceof Ax){e+=l.constant()*s;let c=l.terms();for(let u=0,h=c.size();u<h;u++){let g=c.itemAt(u);n.setDefault(g.first,t).second+=g.second*s}}else throw new Error("array item 1 must be a variable or expression")}else throw new Error("invalid Expression argument: "+o)}return{terms:n,constant:e}}const hb=class hb{static create(e,t,n,i=1){let a=0;return a+=Math.max(0,Math.min(1e3,e*i))*1e6,a+=Math.max(0,Math.min(1e3,t*i))*1e3,a+=Math.max(0,Math.min(1e3,n*i)),a}static clip(e){return Math.max(0,Math.min(hb.required,e))}};ni(hb,"required",hb.create(1e3,1e3,1e3)),ni(hb,"strong",hb.create(1,0,0)),ni(hb,"medium",hb.create(0,1,0)),ni(hb,"weak",hb.create(0,0,1));let X5=hb;var c3;(function(r){r[r.Le=0]="Le",r[r.Ge=1]="Ge",r[r.Eq=2]="Eq"})(c3||(c3={}));class K4{constructor(e,t,n,i=X5.required){ni(this,"_expression");ni(this,"_operator");ni(this,"_strength");ni(this,"_id",kqe++);this._operator=t,this._strength=X5.clip(i),n===void 0&&e instanceof Ax?this._expression=e:this._expression=e.minus(n)}id(){return this._id}expression(){return this._expression}op(){return this._operator}strength(){return this._strength}toString(){return this._expression.toString()+" "+["<=",">=","="][this._operator]+" 0 ("+this._strength.toString()+")"}}let kqe=0;class Bqe{constructor(){ni(this,"maxIterations",1e3);ni(this,"_cnMap",Hqe());ni(this,"_rowMap",Vqe());ni(this,"_varMap",jqe());ni(this,"_editMap",Gqe());ni(this,"_infeasibleRows",[]);ni(this,"_objective",new RA);ni(this,"_artificial",null);ni(this,"_idTick",0)}createConstraint(e,t,n,i=X5.required){let a=new K4(e,t,n,i);return this.addConstraint(a),a}addConstraint(e){if(this._cnMap.find(e)!==void 0)throw new Error("duplicate constraint");let n=this._createRow(e),i=n.row,a=n.tag,o=this._chooseSubject(i,a);if(o.type()===Bv.Invalid&&i.allDummies())if(CA(i.constant()))o=a.marker;else throw new Error("unsatisfiable constraint");if(o.type()===Bv.Invalid){if(!this._addWithArtificialVariable(i))throw new Error("unsatisfiable constraint")}else i.solveFor(o),this._substitute(o,i),this._rowMap.insert(o,i);this._cnMap.insert(e,a),this._optimize(this._objective)}removeConstraint(e){let t=this._cnMap.erase(e);if(t===void 0)throw new Error("unknown constraint");this._removeConstraintEffects(e,t.second);let n=t.second.marker,i=this._rowMap.erase(n);if(i===void 0){let a=this._getMarkerLeavingSymbol(n);if(a.type()===Bv.Invalid)throw new Error("failed to find leaving row");i=this._rowMap.erase(a),i.second.solveForEx(a,n),this._substitute(n,i.second)}this._optimize(this._objective)}hasConstraint(e){return this._cnMap.contains(e)}getConstraints(){return this._cnMap.array.map(({first:e})=>e)}addEditVariable(e,t){if(this._editMap.find(e)!==void 0)throw new Error("duplicate edit variable");if(t=X5.clip(t),t===X5.required)throw new Error("bad required strength");let i=new Ax(e),a=new K4(i,c3.Eq,void 0,t);this.addConstraint(a);let s={tag:this._cnMap.find(a).second,constraint:a,constant:0};this._editMap.insert(e,s)}removeEditVariable(e){let t=this._editMap.erase(e);if(t===void 0)throw new Error("unknown edit variable");this.removeConstraint(t.second.constraint)}hasEditVariable(e){return this._editMap.contains(e)}suggestValue(e,t){let n=this._editMap.find(e);if(n===void 0)throw new Error("unknown edit variable");let i=this._rowMap,a=n.second,o=t-a.constant;a.constant=t;let s=a.tag.marker,l=i.find(s);if(l!==void 0){l.second.add(-o)<0&&this._infeasibleRows.push(s),this._dualOptimize();return}let c=a.tag.other;if(l=i.find(c),l!==void 0){l.second.add(o)<0&&this._infeasibleRows.push(c),this._dualOptimize();return}for(let u=0,h=i.size();u<h;++u){let g=i.itemAt(u),_=g.second,b=_.coefficientFor(s);b!==0&&_.add(o*b)<0&&g.first.type()!==Bv.External&&this._infeasibleRows.push(g.first)}this._dualOptimize()}updateVariables(){let e=this._varMap,t=this._rowMap;for(let n=0,i=e.size();n<i;++n){let a=e.itemAt(n),o=t.find(a.second);o!==void 0?a.first.setValue(o.second.constant()):a.first.setValue(0)}}_getVarSymbol(e){let t=()=>this._makeSymbol(Bv.External);return this._varMap.setDefault(e,t).second}_createRow(e){let t=e.expression(),n=new RA(t.constant()),i=t.terms();for(let l=0,c=i.size();l<c;++l){let u=i.itemAt(l);if(!CA(u.second)){let h=this._getVarSymbol(u.first),g=this._rowMap.find(h);g!==void 0?n.insertRow(g.second,u.second):n.insertSymbol(h,u.second)}}let a=this._objective,o=e.strength(),s={marker:J4,other:J4};switch(e.op()){case c3.Le:case c3.Ge:{let l=e.op()===c3.Le?1:-1,c=this._makeSymbol(Bv.Slack);if(s.marker=c,n.insertSymbol(c,l),o<X5.required){let u=this._makeSymbol(Bv.Error);s.other=u,n.insertSymbol(u,-l),a.insertSymbol(u,o)}break}case c3.Eq:{if(o<X5.required){let l=this._makeSymbol(Bv.Error),c=this._makeSymbol(Bv.Error);s.marker=l,s.other=c,n.insertSymbol(l,-1),n.insertSymbol(c,1),a.insertSymbol(l,o),a.insertSymbol(c,o)}else{let l=this._makeSymbol(Bv.Dummy);s.marker=l,n.insertSymbol(l)}break}}return n.constant()<0&&n.reverseSign(),{row:n,tag:s}}_chooseSubject(e,t){let n=e.cells();for(let a=0,o=n.size();a<o;++a){let s=n.itemAt(a);if(s.first.type()===Bv.External)return s.first}let i=t.marker.type();return(i===Bv.Slack||i===Bv.Error)&&e.coefficientFor(t.marker)<0?t.marker:(i=t.other.type(),(i===Bv.Slack||i===Bv.Error)&&e.coefficientFor(t.other)<0?t.other:J4)}_addWithArtificialVariable(e){let t=this._makeSymbol(Bv.Slack);this._rowMap.insert(t,e.copy()),this._artificial=e.copy(),this._optimize(this._artificial);let n=CA(this._artificial.constant());this._artificial=null;let i=this._rowMap.erase(t);if(i!==void 0){let o=i.second;if(o.isConstant())return n;let s=this._anyPivotableSymbol(o);if(s.type()===Bv.Invalid)return!1;o.solveForEx(t,s),this._substitute(s,o),this._rowMap.insert(s,o)}let a=this._rowMap;for(let o=0,s=a.size();o<s;++o)a.itemAt(o).second.removeSymbol(t);return this._objective.removeSymbol(t),n}_substitute(e,t){let n=this._rowMap;for(let i=0,a=n.size();i<a;++i){let o=n.itemAt(i);o.second.substitute(e,t),o.second.constant()<0&&o.first.type()!==Bv.External&&this._infeasibleRows.push(o.first)}this._objective.substitute(e,t),this._artificial&&this._artificial.substitute(e,t)}_optimize(e){let t=0;for(;t<this.maxIterations;){let n=this._getEnteringSymbol(e);if(n.type()===Bv.Invalid)return;let i=this._getLeavingSymbol(n);if(i.type()===Bv.Invalid)throw new Error("the objective is unbounded");let a=this._rowMap.erase(i).second;a.solveForEx(i,n),this._substitute(n,a),this._rowMap.insert(n,a),t++}throw new Error("solver iterations exceeded")}_dualOptimize(){let e=this._rowMap,t=this._infeasibleRows;for(;t.length!==0;){let n=t.pop(),i=e.find(n);if(i!==void 0&&i.second.constant()<0){let a=this._getDualEnteringSymbol(i.second);if(a.type()===Bv.Invalid)throw new Error("dual optimize failed");let o=i.second;e.erase(n),o.solveForEx(n,a),this._substitute(a,o),e.insert(a,o)}}}_getEnteringSymbol(e){let t=e.cells();for(let n=0,i=t.size();n<i;++n){let a=t.itemAt(n),o=a.first;if(a.second<0&&o.type()!==Bv.Dummy)return o}return J4}_getDualEnteringSymbol(e){let t=Number.MAX_VALUE,n=J4,i=e.cells();for(let a=0,o=i.size();a<o;++a){let s=i.itemAt(a),l=s.first,c=s.second;if(c>0&&l.type()!==Bv.Dummy){let h=this._objective.coefficientFor(l)/c;h<t&&(t=h,n=l)}}return n}_getLeavingSymbol(e){let t=Number.MAX_VALUE,n=J4,i=this._rowMap;for(let a=0,o=i.size();a<o;++a){let s=i.itemAt(a),l=s.first;if(l.type()!==Bv.External){let c=s.second,u=c.coefficientFor(e);if(u<0){let h=-c.constant()/u;h<t&&(t=h,n=l)}}}return n}_getMarkerLeavingSymbol(e){let t=Number.MAX_VALUE,n=t,i=t,a=J4,o=a,s=a,l=a,c=this._rowMap;for(let u=0,h=c.size();u<h;++u){let g=c.itemAt(u),_=g.second,b=_.coefficientFor(e);if(b===0)continue;let T=g.first;if(T.type()===Bv.External)l=T;else if(b<0){let C=-_.constant()/b;C<n&&(n=C,o=T)}else{let C=_.constant()/b;C<i&&(i=C,s=T)}}return o!==a?o:s!==a?s:l}_removeConstraintEffects(e,t){t.marker.type()===Bv.Error&&this._removeMarkerEffects(t.marker,e.strength()),t.other.type()===Bv.Error&&this._removeMarkerEffects(t.other,e.strength())}_removeMarkerEffects(e,t){let n=this._rowMap.find(e);n!==void 0?this._objective.insertRow(n.second,-t):this._objective.insertSymbol(e,-t)}_anyPivotableSymbol(e){let t=e.cells();for(let n=0,i=t.size();n<i;++n){let a=t.itemAt(n),o=a.first.type();if(o===Bv.Slack||o===Bv.Error)return a.first}return J4}_makeSymbol(e){return new ace(e,this._idTick++)}}function CA(r){let e=1e-8;return r<0?-r<e:r<e}function Hqe(){return I8()}function Vqe(){return I8()}function jqe(){return I8()}function Gqe(){return I8()}var Bv;(function(r){r[r.Invalid=0]="Invalid",r[r.External=1]="External",r[r.Slack=2]="Slack",r[r.Error=3]="Error",r[r.Dummy=4]="Dummy"})(Bv||(Bv={}));let ace=class{constructor(e,t){ni(this,"_id");ni(this,"_type");this._id=t,this._type=e}id(){return this._id}type(){return this._type}},J4=new ace(Bv.Invalid,-1);class RA{constructor(e=0){ni(this,"_cellMap",I8());ni(this,"_constant");this._constant=e}cells(){return this._cellMap}constant(){return this._constant}isConstant(){return this._cellMap.empty()}allDummies(){let e=this._cellMap;for(let t=0,n=e.size();t<n;++t)if(e.itemAt(t).first.type()!==Bv.Dummy)return!1;return!0}copy(){let e=new RA(this._constant);return e._cellMap=this._cellMap.copy(),e}add(e){return this._constant+=e}insertSymbol(e,t=1){let n=this._cellMap.setDefault(e,()=>0);CA(n.second+=t)&&this._cellMap.erase(e)}insertRow(e,t=1){this._constant+=e._constant*t;let n=e._cellMap;for(let i=0,a=n.size();i<a;++i){let o=n.itemAt(i);this.insertSymbol(o.first,o.second*t)}}removeSymbol(e){this._cellMap.erase(e)}reverseSign(){this._constant=-this._constant;let e=this._cellMap;for(let t=0,n=e.size();t<n;++t){let i=e.itemAt(t);i.second=-i.second}}solveFor(e){let t=this._cellMap,i=-1/t.erase(e).second;this._constant*=i;for(let a=0,o=t.size();a<o;++a)t.itemAt(a).second*=i}solveForEx(e,t){this.insertSymbol(e,-1),this.solveFor(t)}coefficientFor(e){let t=this._cellMap.find(e);return t!==void 0?t.second:0}substitute(e,t){let n=this._cellMap.erase(e);n!==void 0&&this.insertRow(t,n.second)}}var oce=(r,e={})=>{let t=r._internal_store;if(!t){t={counts:{}},r._internal_store=t;for(const i of r){const a=i.type,o=i[`${a}_id`];if(!o)continue;const s=Number.parseInt(o.split("_").pop());Number.isNaN(s)||(t.counts[a]=Math.max(t.counts[a]??0,s))}}return new Proxy({},{get:(i,a)=>a==="toArray"?()=>r:{get:o=>r.find(s=>s.type===a&&s[`${a}_id`]===o),getUsing:o=>{const s=Object.keys(o);if(s.length!==1)throw new Error("getUsing requires exactly one key, e.g. { pcb_component_id }");const l=s[0],c=l.replace("_id",""),u=r.find(h=>h.type===c&&h[l]===o[l]);return u?r.find(h=>h.type===a&&h[`${a}_id`]===u[`${a}_id`]):null},getWhere:o=>{const s=Object.keys(o);return r.find(l=>l.type===a&&s.every(c=>l[c]===o[c]))},list:o=>{const s=o?Object.keys(o):[];return r.filter(l=>l.type===a&&s.every(c=>l[c]===o[c]))},insert:o=>{var c;(c=t.counts)[a]??(c[a]=-1),t.counts[a]++;const s=t.counts[a],l={type:a,[`${a}_id`]:`${a}_${s}`,...o};return e.validateInserts&&(xie[a]??$z).parse(l),r.push(l),l},delete:o=>{const s=r.find(l=>l[`${a}_id`]===o);s&&r.splice(r.indexOf(s),1)},update:(o,s)=>{const l=r.find(c=>c[`${a}_id`]===o);if(l)return Object.assign(l,s),l},select:o=>{if(a==="source_component")return r.find(s=>s.type==="source_component"&&s.name===o.replace(/\./g,""));if(a==="pcb_port"||a==="source_port"||a==="schematic_port"){const[s,l]=o.replace(/\./g,"").split(/[\s\>]+/),c=r.find(h=>h.type==="source_component"&&h.name===s);if(!c)return null;const u=r.find(h=>h.type==="source_port"&&h.source_component_id===c.source_component_id&&(h.name===l||(h.port_hints??[]).includes(l)));if(!u)return null;if(a==="source_port")return u;if(a==="pcb_port")return r.find(h=>h.type==="pcb_port"&&h.source_port_id===u.source_port_id);if(a==="schematic_port")return r.find(h=>h.type==="schematic_port"&&h.source_port_id===u.source_port_id)}}}})};oce.unparsed=oce;var qqe=r=>{if(r==="up")return"right";if(r==="right")return"down";if(r==="down")return"left";if(r==="left")return"up";throw new Error(`Invalid direction: ${r}`)},Yqe=r=>{if(r==="up")return"left";if(r==="left")return"down";if(r==="down")return"right";if(r==="right")return"up";throw new Error(`Invalid direction: ${r}`)},Xqe=(r,e)=>{for(;e>0;)r=qqe(r),e--;for(;e<0;)r=Yqe(r),e++;return r},Wqe=(r,e)=>{if(r.type==="schematic_component")r.center=ui(e,r.center);else if(r.type==="schematic_port")r.center=ui(e,r.center),r.facing_direction&&(r.facing_direction=Xqe(r.facing_direction,-(Math.atan2(e.b,e.a)/Math.PI)*2));else if(r.type==="schematic_text")r.position=ui(e,r.position);else if(r.type!=="schematic_trace"){if(r.type==="schematic_box"){const{x:t,y:n}=ui(e,{x:r.x,y:r.y});r.x=t,r.y=n}else if(r.type==="schematic_line"){const{x:t,y:n}=ui(e,{x:r.x1,y:r.y1}),{x:i,y:a}=ui(e,{x:r.x2,y:r.y2});r.x1=t,r.y1=n,r.x2=i,r.y2=a}}return r},$qe=(r,e)=>{const t=r;for(const n of e.boxes){const i=t.find(o=>o.type==="schematic_component"&&o.schematic_component_id===n.box_id),a=rv(n.x-i.center.x,n.y-i.center.y);for(const o of t)o.schematic_component_id===n.box_id&&Wqe(o,a)}return t},Zqe=r=>{const e=[],t=[],n=[],i={schematic_component:r.filter(a=>a.type==="schematic_component"),schematic_port:r.filter(a=>a.type==="schematic_port"),source_port:r.filter(a=>a.type==="source_port"),schematic_trace:r.filter(a=>a.type==="schematic_trace"),source_trace:r.filter(a=>a.type==="source_trace")};for(const a of i.schematic_component){const o=[],s=a.schematic_component_id;for(const c of i.schematic_port)c.schematic_component_id===a.schematic_component_id&&o.push({port_id:`${s}.${c.schematic_port_id}`,rx:c.center.x-a.center.x,ry:c.center.y-a.center.y});const l={box_id:s,x:a.center.x,y:a.center.y,ports:o};e.push(l)}for(const a of i.source_trace){const[o,s]=a.connected_source_port_ids,l=i.schematic_port.find(_=>_.source_port_id===o),c=i.schematic_port.find(_=>_.source_port_id===s);if(!l||!c)continue;const u=i.schematic_component.find(_=>_.schematic_component_id===l.schematic_component_id),h=i.schematic_component.find(_=>_.schematic_component_id===c.schematic_component_id);if(!u||!h)continue;const g={from:`${u.schematic_component_id}.${l.schematic_port_id}`,to:`${h.schematic_component_id}.${c.schematic_port_id}`};t.push(g)}return{boxes:e,connections:t,nets:n}};function Qqe(r){return r.connections.reduce((e,t)=>(e[t.from]=t.to,e[t.to]=t.from,e),{})}function Kqe(r,e){for(const t of["left","right"]){const n=r.filter(o=>o.side===t),i=n.map(o=>o.ascending_box_index).filter(o=>!isNaN(o)),a=Math.max(...i);for(const o of n)o.box_id!==e.box_id&&(o.y-=a/2*1.25)}}var Jqe=r=>{let e=r[0];for(const t of r)t.ports.length>e.ports.length&&(e=t);return e};function eYe(r,e,t,n){for(const i of["left","right"]){const a=r.filter(o=>o.side===i).sort((o,s)=>o.ascending_box_index-s.ascending_box_index);for(let o=0;o<a.length-1;o++){const[s,l]=[a[o],a[o+1]];if(s.ports.length===2&&l.ports.length===2){const[c,u]=s.ports,[h,g]=l.ports,[_,b]=[c,u].map(U=>e[U.port_id]),[T,C]=[h,g].map(U=>e[U.port_id]);let A=null;if((_===T||_===C)&&t.has(_)?A=_:(b===T||b===C)&&t.has(b)&&(A=b),!A)continue;const L=n.nets.find(U=>U.net_id===A);if(!L.is_ground&&!L.is_power)continue;L.is_ground&&a.slice(o+1).forEach(U=>{U.ascending_box_index-=1,U.y-=1}),L.is_power&&a.slice(o+1).forEach(U=>{U.ascending_box_index-=1,U.y-=1})}}}}function tYe(r,e){for(let t=0;t<r;t++){let n=0;for(const i of e)i.ascending_box_index===t&&(n+=1);if(n===0){r-=1;for(const i of e)i.ascending_box_index>t&&(i.ascending_box_index-=1)}}return r}function nYe(r,e,t,n){const i=Math.max(...r.map(a=>a.ascending_box_index).filter(a=>!isNaN(a)));for(const a of["left","right"])for(let o=0;o<=i;o++){const s=r.filter(b=>b.side===a).filter(b=>b.ascending_box_index===o);if(s.length===0)continue;const c=s.map(b=>e.connections.filter(T=>T.from.startsWith(b.box_id+".")||T.to.startsWith(b.box_id+".")).map(T=>T.from.startsWith(b.box_id+".")?T.to:T.from)).map(b=>b.filter(T=>t.has(T))),u=c.reduce((b,T)=>b.filter(C=>T.includes(C)),c[0]),h=u.map(b=>e.nets.find(T=>T.net_id===b)),_=(a==="left"?Math.max:Math.min)(...s.map(b=>b.x));for(const b of h){const T=o+(b!=null&&b.is_ground?-1:1),C=`${b==null?void 0:b.net_id}_${a==="left"?"L":"R"}_${o}`,A=b!=null&&b.is_ground?`${C}.top`:`${C}.bottom`,L={box_id:C,x:_,y:T,side:a,ascending_port_index:0,ascending_box_index:o,width:0,ports:[{port_id:A,rx:0,ry:b!=null&&b.is_ground?.1:-.1}]};r.push(L);for(const U of s){const j=n.filter(Z=>Z.from.startsWith(U.box_id+".")||Z.to.startsWith(U.box_id+"."));for(const Z of j)Z.from===b.net_id&&(Z.from=A),Z.to===b.net_id&&(Z.to=A)}}for(let b=0;b<s.length;b++){const T=s[b],C=c[b].filter(A=>!u.includes(A));for(const A of C){const L=e.nets.find($=>$.net_id===A),U=`${A}_${T.ascending_box_index}_${a==="left"?"L":"R"}_${b}`,j=`${U}.${L.is_ground?"top":"bottom"}`,Z={x:T.x,y:T.y+(L.is_ground?-1:1),side:a,ascending_port_index:0,ascending_box_index:T.ascending_box_index,box_id:U,ports:[{port_id:j,rx:0,ry:L.is_ground?.1:-.1}]};r.push(Z);const ee=n.find($=>$.from===A&&$.to.startsWith(T.box_id)||$.to===A&&$.from.startsWith(T.box_id));ee.from===A&&(ee.from=j),ee.to===A&&(ee.to=j)}}}return i}var sce=(r,e)=>{const t=l3(e*(Math.PI/180));r.ports.forEach(n=>{const i=ui(t,{x:n.rx,y:n.ry});n.rx=i.x,n.ry=i.y})},lce=r=>{const e=Math.sqrt(r.x**2+r.y**2);return{x:r.x/e,y:r.y/e}},rYe=r=>[0,90,180,270].map(t=>{const n={...r,ports:r.ports.map(i=>({...i}))};return sce(n,t),n.applied_rotation_deg=t,n}),iYe=r=>{const e=r.boxes.sort((t,n)=>t.y-n.y);for(const t of e)if(t.ports.length===2){const n=t.ports.map(o=>{var u;const s=r.connections.filter(h=>h.from===o.port_id||h.to===o.port_id).map(h=>h.from===o.port_id?h.to:h.from);if(s.length===0)return null;const l=e.filter(h=>s.some(g=>g.startsWith(h.box_id+"."))),c=(u=l.flatMap(h=>h.ports))==null?void 0:u.filter(h=>s.includes(h.port_id));for(const h of c){const g=l.find(_=>_.box_id===h.port_id.split(".")[0]);h.x=g.x+h.rx,h.y=g.y+h.ry}return{...o,connected_port:c[0],connected_ports:c}}).filter(Boolean);if(n.length===0)continue;const i=rYe({...t,ports:n});for(const o of i){o.natural_offset_sum_deg=0;for(const s of o.ports)for(const l of s.connected_ports){const c=lce({x:l.x-(o.x+s.rx),y:l.y-(o.y+s.ry)}),u=lce({x:s.rx,y:s.ry}),h=Math.sqrt((c.x-u.x)**2+(c.y-u.y)**2),g=c.x*u.x+c.y*u.y,_=c.x*u.y-c.y*u.x,b=Math.atan2(_,g)*(180/Math.PI);o.natural_offset_sum_deg+=Math.abs(b)/h}}const a=i.reduce((o,s)=>o.natural_offset_sum_deg<s.natural_offset_sum_deg?o:s);sce(t,a.applied_rotation_deg)}return r},aYe=r=>{const e=new Set(r.nets.map(l=>l.net_id)),t=Qqe(r),n=JSON.parse(JSON.stringify(r.boxes)),i=JSON.parse(JSON.stringify(r.connections));for(const l of n){l.x=0,l.y=0;let c=0,u=0;for(const h of l.ports)h.rx<c?c=h.rx:h.rx>u&&(u=h.rx);l.width=u-c}const a=Jqe(n);for(const l of a.ports)l.rx>0?l.side="right":l.rx<0&&(l.side="left");for(const l of n){if(l.box_id===a.box_id)continue;const c=a.ports.filter(g=>i.some(_=>_.from.startsWith(l.box_id)&&_.to===g.port_id||_.to.startsWith(l.box_id)&&_.from===g.port_id));if(c.length===0){l.side="left";continue}let u=0,h=0;for(const g of c)g.rx>0?h+=1:g.rx<0&&(u+=1);u>=h?l.side="left":l.side="right"}for(const l of["left","right"]){const c=a.ports.filter(u=>u.side===l);c.sort((u,h)=>u.ry-h.ry);for(const u of c)u.ascending_port_index=c.indexOf(u)}for(const l of n){if(l.box_id===a.box_id)continue;const c=r.connections.filter(h=>h.from.startsWith(l.box_id+".")||h.to.startsWith(l.box_id+".")).map(h=>h.from.startsWith(l.box_id+".")?h.to:h.from),u=a.ports.filter(h=>c.includes(h.port_id));u.length!==0&&(l.ascending_port_index=Math.min(...u.map(h=>h.ascending_port_index)),l.ascending_box_index=l.ascending_port_index)}let o=Math.max(0,...n.map(l=>l.ascending_box_index).filter(l=>!isNaN(l)));for(const l of n)l.box_id!==a.box_id&&l.ascending_box_index===void 0&&(o+=1,l.ascending_box_index=o);for(const l of["left","right"])tYe(o,n.filter(c=>c.side===l));for(const l of["left","right"]){let c=a.width*.75*(l==="left"?-1:1);for(let u=0;u<=o;u++){const h=n.filter(b=>b.side===l&&b.ascending_box_index===u),g=Math.max(...h.map(b=>b.width)),_=Math.max(.5,g)*(l==="left"?-1:1);c+=_;for(const b of h)b.box_id!==a.box_id&&(b.y=b.ascending_box_index*1.25,b.x=c);c+=_/2}}eYe(n,t,e,r),nYe(n,r,e,i),Kqe(n,a);const s={...r,connections:i,boxes:n};return iYe(s),s},oYe=(r,e)=>{const t={x:e.x-r.x,y:e.y-r.y},n=Math.sqrt(t.x**2+t.y**2);return{x:t.x/n,y:t.y/n}},sYe=r=>{switch(r){case"up":return{x:0,y:1};case"down":return{x:0,y:-1};case"left":return{x:-1,y:0};case"right":return{x:1,y:0}}};function cce([r,e],[t,n],{lineThickness:i=0}={}){return i===0?uce(r,e,t,n):lYe(r,e,t,n)<=i}function uce(r,e,t,n){const i=AA(r,e,t),a=AA(r,e,n),o=AA(t,n,r),s=AA(t,n,e);return!!(i!==a&&o!==s||i===0&&DA(r,t,e)||a===0&&DA(r,n,e)||o===0&&DA(t,r,n)||s===0&&DA(t,e,n))}function AA(r,e,t){const n=(e.y-r.y)*(t.x-e.x)-(e.x-r.x)*(t.y-e.y);return n===0?0:n>0?1:2}function DA(r,e,t){return e.x<=Math.max(r.x,t.x)&&e.x>=Math.min(r.x,t.x)&&e.y<=Math.max(r.y,t.y)&&e.y>=Math.min(r.y,t.y)}function lYe(r,e,t,n){if(r.x===e.x&&r.y===e.y)return k8(r,t,n);if(t.x===n.x&&t.y===n.y)return k8(t,r,e);if(uce(r,e,t,n))return 0;const i=[k8(r,t,n),k8(e,t,n),k8(t,r,e),k8(n,r,e)];return Math.min(...i)}function k8(r,e,t){const n=(t.x-e.x)**2+(t.y-e.y)**2;if(n===0)return yT(r,e);let i=((r.x-e.x)*(t.x-e.x)+(r.y-e.y)*(t.y-e.y))/n;i=Math.max(0,Math.min(1,i));const a={x:e.x+i*(t.x-e.x),y:e.y+i*(t.y-e.y)};return yT(r,a)}function yT(r,e){const t=r.x-e.x,n=r.y-e.y;return Math.sqrt(t*t+n*n)}var HI=[{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:"µ"},{value:1e-9,symbol:"n"},{value:1e-12,symbol:"p"}];function PA(r){if(r==null)return"";if(r===0)return"0";const e=Math.abs(r),t=HI.find(a=>{const o=e/a.value;return o>=1&&o<1e3})||HI[HI.length-1];let i=(r/t.value).toPrecision(3);return i.includes(".")&&!/\.0+$/.test(i)&&(i=i.replace(/0+$/,"")),i=i.replace(/\.0+$/,""),`${i}${t.symbol}`}var cYe=Object.defineProperty,uYe=(r,e)=>{for(var t in e)cYe(r,t,{get:e[t],enumerable:!0})},fce={};uYe(fce,{Battery:()=>dXe,Board:()=>NYe,Capacitor:()=>$Ye,Chip:()=>Ace,Constraint:()=>nXe,Crystal:()=>xXe,Diode:()=>ZYe,FabricationNotePath:()=>rXe,FabricationNoteText:()=>iXe,Footprint:()=>CYe,Group:()=>qI,Hole:()=>bce,Inductor:()=>vXe,Jumper:()=>QYe,Keepout:()=>GI,Led:()=>KYe,Mosfet:()=>SXe,Net:()=>yce,NetAlias:()=>oXe,NormalComponent:()=>Dx,PinHeader:()=>hXe,PlatedHole:()=>xce,Port:()=>l4,Potentiometer:()=>gXe,PowerSource:()=>JYe,PrimitiveComponent:()=>R_,PushButton:()=>_Xe,Renderable:()=>dce,Resistor:()=>eXe,Resonator:()=>mXe,SilkscreenCircle:()=>sXe,SilkscreenLine:()=>uXe,SilkscreenPath:()=>_ce,SilkscreenRect:()=>lXe,SilkscreenText:()=>cXe,SmtPad:()=>jI,Subcircuit:()=>aXe,Switch:()=>EXe,Trace:()=>qS,TraceHint:()=>Tce,Transistor:()=>bXe,Via:()=>fXe});var fYe=g2("tscircuit:renderable"),T3=["ReactSubtreesRender","InitializePortsFromChildren","CreateNetsFromProps","CreateTracesFromProps","CreateTraceHintsFromProps","SourceRender","SourceParentAttachment","PortMatching","SourceTraceRender","SourceAddConnectivityMapKey","SchematicComponentRender","SchematicPortRender","SchematicLayout","SchematicTraceRender","PcbComponentRender","PcbPrimitiveRender","PcbFootprintLayout","PcbPortRender","PcbPortAttachment","PcbLayout","PcbComponentSizeCalculation","PcbBoardAutoSize","PcbTraceRender","PcbTraceHintRender","PcbRouteNetIslands","CadModelRender","PartsEngineRender"],dYe=0,dce=class{constructor(r){ni(this,"renderPhaseStates");ni(this,"shouldBeRemoved",!1);ni(this,"children");ni(this,"isPcbPrimitive",!1);ni(this,"isSchematicPrimitive",!1);ni(this,"_renderId");ni(this,"_currentRenderPhase",null);ni(this,"_asyncEffects",[]);ni(this,"parent",null);this._renderId=`${dYe++}`,this.children=[],this.renderPhaseStates={};for(const e of T3)this.renderPhaseStates[e]={initialized:!1,dirty:!1}}_markDirty(r){var t;this.renderPhaseStates[r].dirty=!0;const e=T3.indexOf(r);for(let n=e+1;n<T3.length;n++)this.renderPhaseStates[T3[n]].dirty=!0;(t=this.parent)!=null&&t._markDirty&&this.parent._markDirty(r)}_queueAsyncEffect(r,e){const t={promise:e(),phase:this._currentRenderPhase,effectName:r,complete:!1};this._asyncEffects.push(t),"root"in this&&this.root&&this.root.emit("asyncEffect:start",{effectName:r,componentDisplayName:this.getString(),phase:t.phase}),t.promise.then(()=>{t.complete=!0,"root"in this&&this.root&&this.root.emit("asyncEffect:end",{effectName:r,componentDisplayName:this.getString(),phase:t.phase})}).catch(n=>{console.error(`Async effect error in ${t.phase} "${r}":
|
|
639
639
|
${n.stack}`),t.complete=!0,"root"in this&&this.root&&this.root.emit("asyncEffect:end",{effectName:r,componentDisplayName:this.getString(),phase:t.phase,error:n.toString()})})}_emitRenderLifecycleEvent(r,e){fYe(`${r}:${e} ${this.getString()}`);const t=`renderable:renderLifecycle:${r}:${e}`,n={renderId:this._renderId,componentDisplayName:this.getString(),type:t};"root"in this&&this.root&&(this.root.emit(t,n),this.root.emit("renderable:renderLifecycle:anyEvent",{...n,type:t}))}getString(){return this.constructor.name}_hasIncompleteAsyncEffects(){return this._asyncEffects.some(r=>!r.complete)}getCurrentRenderPhase(){return this._currentRenderPhase}getRenderGraph(){return{id:this._renderId,currentPhase:this._currentRenderPhase,renderPhaseStates:this.renderPhaseStates,shouldBeRemoved:this.shouldBeRemoved,children:this.children.map(r=>r.getRenderGraph())}}runRenderCycle(){for(const r of T3)this.runRenderPhaseForChildren(r),this.runRenderPhase(r)}runRenderPhase(r){var a,o,s;this._currentRenderPhase=r;const e=this.renderPhaseStates[r],t=e.initialized,n=e.dirty;if(!t&&this.shouldBeRemoved)return;if(this.shouldBeRemoved&&t){this._emitRenderLifecycleEvent(r,"start"),(a=this==null?void 0:this[`remove${r}`])==null||a.call(this),e.initialized=!1,e.dirty=!1,this._emitRenderLifecycleEvent(r,"end");return}const i=T3.indexOf(r)-1;if(i>=0){const l=T3[i];if(this._asyncEffects.filter(u=>u.phase===l).some(u=>!u.complete))return}if(this._emitRenderLifecycleEvent(r,"start"),t){n&&((o=this==null?void 0:this[`update${r}`])==null||o.call(this),e.dirty=!1),this._emitRenderLifecycleEvent(r,"end");return}e.dirty=!1,(s=this==null?void 0:this[`doInitial${r}`])==null||s.call(this),e.initialized=!0,this._emitRenderLifecycleEvent(r,"end")}runRenderPhaseForChildren(r){for(const e of this.children)e.runRenderPhaseForChildren(r),e.runRenderPhase(r)}renderError(r){throw typeof r=="string"?new Error(r):new Error(JSON.stringify(r,null,2))}},NA={},hce=r=>{const e=Object.fromEntries(Object.entries(r).map(([t,n])=>[t.toLowerCase(),n]));Object.assign(NA,r),Object.assign(NA,e)};function hYe(r,e){const t=r;return t.__tsci={...e},r}var pce={supportsMutation:!0,createInstance(r,e){const t=NA[r];if(!t)throw Object.keys(NA).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 (not registered in @tscircuit/core catalogue): "${r}" See CREATING_NEW_COMPONENTS.md`);return hYe(new t(e),{})},createTextInstance(){return{}},appendInitialChild(r,e){r.add(e)},appendChild(r,e){r.add(e)},appendChildToContainer(r,e){r.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(r){return r},preparePortalMount(r){throw new Error("Function not implemented.")},scheduleTimeout(r,e){throw new Error("Function not implemented.")},cancelTimeout(r){throw new Error("Function not implemented.")},noTimeout:void 0,isPrimaryRenderer:!1,getInstanceFromNode(r){throw new Error("Function not implemented.")},beforeActiveInstanceBlur(){throw new Error("Function not implemented.")},afterActiveInstanceBlur(){throw new Error("Function not implemented.")},prepareScopeUpdate:(r,e)=>{throw new Error("Function not implemented.")},getInstanceFromScope:r=>{throw new Error("Function not implemented.")},detachDeletedInstance:r=>{throw new Error("Function not implemented.")},getCurrentEventPriority:()=>hF.DefaultEventPriority,getCurrentUpdatePriority:()=>hF.DefaultEventPriority,resolveUpdatePriority:()=>hF.DefaultEventPriority,setCurrentUpdatePriority:()=>{},maySuspendCommit:()=>!1,supportsHydration:!1},GS;D0.version.startsWith("19.")?GS=aIe(pce):GS=uIe(pce);var mce=r=>{const e={children:[],props:{name:"$root"},add(a){a.parent=this,this.children.push(a)},computePcbGlobalTransform(){return C_()}},t=[],n=GS.createContainer(e,0,null,!1,null,"tsci",a=>{console.log("Error in createContainer"),console.error(a),t.push(a)},null);if(D0.version.startsWith("19.")?(GS.updateContainerSync(r,n,null,()=>{}),GS.flushSyncWork()):GS.updateContainer(r,n,null,()=>{}),t.length>0)throw t[0];const i=GS.getPublicRootInstance(n);return i||e.children[0]},gT=(r,e)=>{if(typeof r=="number")return r;if(r.startsWith("pin"))return Number(r.slice(3));if(!e)throw new Error(`No pin labels provided and pin number or label is not a number: "${r}"`);for(const t in e)if((Array.isArray(e[t])?e[t]:[e[t]]).includes(r))return Number(t.replace("pin",""));throw new Error(`No pin labels provided and pin number or label is not a number: "${r}"`)},pYe=(r,e)=>{if(!r)return;const t={},n={};for(const[i,a]of Object.entries(r)){const o=gT(i,e);n[o]={...n[o],...a}}for(const[i,a]of Object.entries(n)){const o=`pin${i}`;t[o]={bottom_margin:a.bottomMargin,left_margin:a.leftMargin,right_margin:a.rightMargin,top_margin:a.topMargin}}return t},mYe=r=>{if(r){if("leftSide"in r||"rightSide"in r||"topSide"in r||"bottomSide"in r)return{left_side:r.leftSide,right_side:r.rightSide,top_side:r.topSide,bottom_side:r.bottomSide};if("leftPinCount"in r||"rightPinCount"in r||"topPinCount"in r||"bottomPinCount"in r)return{left_size:r.leftPinCount,right_size:r.rightPinCount,top_size:r.topPinCount,bottom_size:r.bottomPinCount};if("leftSize"in r||"rightSize"in r||"topSize"in r||"bottomSize"in r)return{left_size:r.leftSize,right_size:r.rightSize,top_size:r.topSize,bottom_size:r.bottomSize}}},vYe=class extends Error{constructor(r,e,t){let n;const a=Object.keys(t).filter(o=>o!=="_errors").map(o=>t[o]._errors[0]?`${o} (${t[o]._errors[0]})`:`${o} (${JSON.stringify(t[o])})`).join(", ");"name"in e?n=`Invalid props for ${r} "${e.name}": ${a}`:"footprint"in e&&typeof e.footprint=="string"?n=`Invalid props for ${r} (unnamed ${e.footprint} component): ${a}`:n=`Invalid props for ${r} (unnamed): ${a}`,super(n),this.componentName=r,this.originalProps=e,this.formattedError=t}};function VI(r,e){const t=e.match(/^#(\w+)/);if(t)return r.props.id===t[1];const n=e.match(/^\.(\w+)/);if(n)return r.isMatchingNameOrAlias(n[1]);let[i,...a]=e.split(/(?=[#.[])/);return i==="pin"&&(i="port"),i&&i!=="*"&&r.lowercaseComponentName!==i.toLowerCase()?!1:a.every(o=>{if(o.startsWith("#"))return r.props.id===o.slice(1);if(o.startsWith("."))return r.isMatchingNameOrAlias(o.slice(1));const s=o.match(/\[(\w+)=['"]?(.+?)['"]?\]/);if(!s)return!0;const[,l,c]=s;return r.props[l].toString()===c})}var _T=g2("tscircuit:primitive-component:selectAll"),R_=class extends dce{constructor(e){super(e);ni(this,"parent",null);ni(this,"children");ni(this,"childrenPendingRemoval");ni(this,"props");ni(this,"_parsedProps");ni(this,"externallyAddedAliases");ni(this,"isPrimitiveContainer",!1);ni(this,"source_group_id",null);ni(this,"source_component_id",null);ni(this,"schematic_component_id",null);ni(this,"pcb_component_id",null);ni(this,"cad_component_id",null);this.children=[],this.childrenPendingRemoval=[],this.props=e??{},this.externallyAddedAliases=[];const t=this.config.zodProps.safeParse(e??{});if(t.success)this._parsedProps=t.data;else throw new vYe(this.lowercaseComponentName,this.props,t.error.format())}get config(){return{componentName:"",zodProps:ue.object({}).passthrough()}}get componentName(){return this.config.componentName}getInheritedProperty(e){let t=this;for(;t;){if(t._parsedProps&&e in t._parsedProps)return t._parsedProps[e];t=t.parent}}get lowercaseComponentName(){return this.componentName.toLowerCase()}get isSubcircuit(){var e;return!!this.props.subcircuit||this.lowercaseComponentName==="group"&&((e=this==null?void 0:this.parent)==null?void 0:e.isRoot)}get isGroup(){return this.lowercaseComponentName==="group"}setProps(e){var i,a;const t=this.config.zodProps.parse({...this.props,...e}),n=this.props;this.props=t,this._parsedProps=this.config.zodProps.parse(e),this.onPropsChange({oldProps:n,newProps:t,changedProps:Object.keys(e)}),(a=(i=this.parent)==null?void 0:i.onChildChanged)==null||a.call(i,this)}computePcbPropsTransform(){const{_parsedProps:e}=this;return oh(rv(e.pcbX??0,e.pcbY??0),l3((e.pcbRotation??0)*Math.PI/180))}_computePcbGlobalTransformBeforeLayout(){var n,i,a;const{_parsedProps:e}=this,t=this.getSubcircuit()._getPcbManualPlacementForComponent(this);if(t&&this.props.pcbX===void 0&&this.props.pcbY===void 0)return oh(((n=this.parent)==null?void 0:n._computePcbGlobalTransformBeforeLayout())??C_(),oh(rv(t.x,t.y),l3((e.pcbRotation??0)*Math.PI/180)));if(this.isPcbPrimitive){const o=this.getPrimitiveContainer();if(o){const s=o._parsedProps.layer==="bottom",l=o._getGlobalPcbPositionBeforeLayout();if(s)return oh(rv(l.x,l.y),_F(),rv(-l.x,-l.y)),oh(((i=this.parent)==null?void 0:i._computePcbGlobalTransformBeforeLayout())??C_(),_F(),this.computePcbPropsTransform())}}return oh(((a=this.parent)==null?void 0:a._computePcbGlobalTransformBeforeLayout())??C_(),this.computePcbPropsTransform())}getPrimitiveContainer(){var e,t;return this.isPrimitiveContainer?this:((t=(e=this.parent)==null?void 0:e.getPrimitiveContainer)==null?void 0:t.call(e))??null}_getPcbCircuitJsonBounds(){return{center:{x:0,y:0},bounds:{left:0,top:0,right:0,bottom:0},width:0,height:0}}_getPcbPrimitiveFlippedHelpers(){const e=this.getPrimitiveContainer(),t=e?e._parsedProps.layer==="bottom":!1;return{isFlipped:t,maybeFlipLayer:i=>t?i==="top"?"bottom":"top":i}}_setPositionFromLayout(e){throw new Error(`_setPositionFromLayout not implemented for ${this.componentName}`)}computeSchematicPropsTransform(){const{_parsedProps:e}=this;return oh(rv(e.schX??0,e.schY??0))}computeSchematicGlobalTransform(){var t,n;const e=this._getSchematicGlobalManualPlacementTransform(this);return e||oh(((n=(t=this.parent)==null?void 0:t.computeSchematicGlobalTransform)==null?void 0:n.call(t))??C_(),this.computeSchematicPropsTransform())}_getSchematicSymbolName(){const{_parsedProps:e}=this,t=this.config.schematicSymbolName;let n=e.schRotation;if(n===void 0&&(n=0),n=n%360,n<0&&(n+=360),e.schRotation!==void 0&&n%90!==0)throw new Error(`Schematic rotation ${e.schRotation} is not supported for ${this.componentName}`);const i=`${t}_horz`,a=`${t}_vert`,o=`${t}_up`,s=`${t}_down`,l=`${t}_left`,c=`${t}_right`;if(c in w3&&n===0)return c;if(o in w3&&n===90)return o;if(l in w3&&n===180)return l;if(s in w3&&n===270)return s;if(i in w3&&(n===0||n===180))return i;if(a in w3&&(n===90||n===270))return a;if(t in w3)return t}_getSchematicSymbolNameOrThrow(){const e=this._getSchematicSymbolName();if(!e)throw new Error(`No schematic symbol found (given: "${this.config.schematicSymbolName}")`);return e}getSchematicSymbol(){const e=this._getSchematicSymbolName();return e?w3[e]??null:null}_getPcbManualPlacementForComponent(e){var a;if(!this.isSubcircuit)return null;const t=this.props.layout,n=this.props.manualEdits;if(!t&&!n)return null;const i=((a=t==null?void 0:t.manual_pcb_placement_config)==null?void 0:a.positions)||(n==null?void 0:n.pcb_placements);if(!i)return null;for(const o of i)if(t&&VI(e,o.selector)||e.props.name===o.selector)return ui(this._computePcbGlobalTransformBeforeLayout(),o.center);return null}_getSchematicGlobalManualPlacementTransform(e){var n,i;const t=(n=this.getSubcircuit())==null?void 0:n._parsedProps.manualEdits;if(!t)return null;for(const a of t.schematic_placements??[])if((VI(e,a.selector)||e.props.name===a.selector)&&a.relative_to==="group_center")return oh(((i=this.parent)==null?void 0:i._computePcbGlobalTransformBeforeLayout())??C_(),rv(a.center.x,a.center.y));return null}_getGlobalPcbPositionBeforeLayout(){return ui(this._computePcbGlobalTransformBeforeLayout(),{x:0,y:0})}_getGlobalSchematicPositionBeforeLayout(){return ui(this.computeSchematicGlobalTransform(),{x:0,y:0})}get root(){var e;return((e=this.parent)==null?void 0:e.root)??null}onAddToParent(e){this.parent=e}onPropsChange(e){}onChildChanged(e){var t,n;(n=(t=this.parent)==null?void 0:t.onChildChanged)==null||n.call(t,e)}add(e){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(const t of e)this.add(t)}remove(e){this.children=this.children.filter(t=>t!==e),this.childrenPendingRemoval.push(e),e.shouldBeRemoved=!0}getSubcircuitSelector(){const e=this._parsedProps.name,t=e?`${this.lowercaseComponentName}.${e}`:this.lowercaseComponentName;return!this.parent||this.parent.isSubcircuit?t:`${this.parent.getSubcircuitSelector()} > ${t}`}getFullPathSelector(){var i,a;const e=this._parsedProps.name,t=e?`${this.lowercaseComponentName}.${e}`:this.lowercaseComponentName,n=(a=(i=this.parent)==null?void 0:i.getFullPathSelector)==null?void 0:a.call(i);return n?`${n} > ${t}`:t}getNameAndAliases(){return[this._parsedProps.name,...this._parsedProps.portHints??[]].filter(Boolean)}isMatchingNameOrAlias(e){return this.getNameAndAliases().includes(e)}isMatchingAnyOf(e){return this.getNameAndAliases().some(t=>e.map(n=>n.toString()).includes(t))}getPcbSize(){throw new Error(`getPcbSize not implemented for ${this.componentName}`)}doesSelectorMatch(e){const t=[this.componentName,this.lowercaseComponentName],n=[this._parsedProps.name].filter(Boolean),i=e.trim().split(/\> /)[0],a=i[0];return i.length>1?!1:!!(e==="*"||e[0]==="#"&&e.slice(1)===this.props.id||e[0]==="."&&n.includes(e.slice(1))||/^[a-zA-Z0-9_]/.test(a)&&t.includes(a))}getSubcircuit(){var t,n;if(this.isSubcircuit)return this;const e=(n=(t=this.parent)==null?void 0:t.getSubcircuit)==null?void 0:n.call(t);if(!e)throw new Error("Component is not inside an opaque group (no board?)");return e}getGroup(){var e,t;return this.isGroup?this:((t=(e=this.parent)==null?void 0:e.getGroup)==null?void 0:t.call(e))??null}selectAll(e){_T(`selectAll: "${e}"`);const t=e.trim().split(/\s+/);let n=t[0]===">"?this.children:this.getSelectableDescendants(),i=[],a=!1,o=-1;for(const s of t)if(o++,_T(`
|
|
640
640
|
|
|
641
|
-
iteration: ${o}`),_T(`part: "${t[o]}"`),_T(`currentSearch: [${n.map(l=>l.getString()).join(",")}]`),_T(`currentResults: [${i.map(l=>l.getString()).join(",")}]`),s===">")a=!0;else{const l=n.filter(u=>VI(u,s));n=l.flatMap(u=>a?u.children:u.getSelectableDescendants()),i=l,a=!1}return i}selectOne(e,t){var i;let n=(i=t==null?void 0:t.type)==null?void 0:i.toLowerCase();return t!=null&&t.port&&(n="port"),n?this.selectAll(e).find(a=>a.lowercaseComponentName===n)??null:t!=null&&t.pcbPrimitive?this.selectAll(e).find(a=>a.isPcbPrimitive)??null:t!=null&&t.schematicPrimitive?this.selectAll(e).find(a=>a.isSchematicPrimitive)??null:this.selectAll(e)[0]??null}getAvailablePcbLayers(){var e,t;if(this.isPcbPrimitive){const{maybeFlipLayer:n}=this._getPcbPrimitiveFlippedHelpers();return"layer"in this._parsedProps||this.componentName==="SmtPad"?[n(this._parsedProps.layer??"top")]:"layers"in this._parsedProps?this._parsedProps.layers:this.componentName==="PlatedHole"?((t=(e=this.root)==null?void 0:e._getBoard())==null?void 0:t.allLayers)??["top","bottom"]:[]}return[]}getDescendants(){const e=[];for(const t of this.children)e.push(t),e.push(...t.getDescendants());return e}getSelectableDescendants(){const e=[];for(const t of this.children)t.isSubcircuit?e.push(t):(e.push(t),e.push(...t.getSelectableDescendants()));return e}_getPinCount(){return 0}_getSchematicBoxDimensions(){return null}renderError(e){var t;if(typeof e=="string")return super.renderError(e);(t=this.root)==null||t.db.pcb_placement_error.insert(e)}getString(){var i,a;const{lowercaseComponentName:e,_parsedProps:t,parent:n}=this;return(t==null?void 0:t.pinNumber)!==void 0&&((i=n==null?void 0:n.props)!=null&&i.name)&&(t!=null&&t.name)?`<${e}#${this._renderId}(pin:${t.pinNumber} .${n==null?void 0:n.props.name}>.${t.name}) />`:(a=n==null?void 0:n.props)!=null&&a.name&&(t!=null&&t.name)?`<${e}#${this._renderId}(.${n==null?void 0:n.props.name}>.${t==null?void 0:t.name}) />`:t!=null&&t.from&&(t!=null&&t.to)?`<${e}#${this._renderId}(from:${t.from} to:${t==null?void 0:t.to}) />`:t!=null&&t.name?`<${e}#${this._renderId} name=".${t==null?void 0:t.name}" />`:t!=null&&t.portHints?`<${e}#${this._renderId}(${t.portHints.map(o=>`.${o}`).join(", ")}) />`:`<${e}#${this._renderId} />`}get[Symbol.toStringTag](){return this.getString()}[Symbol.for("nodejs.util.inspect.custom")](){return this.getString()}};function vce(r){const e=[];for(let t=0;t<r.length-1;t++)e.push([r[t],r[t+1]]);return e}var yYe=ue.object({name:ue.string()}),yce=class extends R_{constructor(){super(...arguments);ni(this,"source_net_id")}get config(){return{componentName:"Net",zodProps:yYe}}getPortSelector(){return`net.${this.props.name}`}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_net.insert({name:t.name,member_source_group_ids:[]});this.source_net_id=n.source_net_id}getAllConnectedPorts(){const e=this.getSubcircuit().selectAll("port"),t=[];for(const n of e){const i=n._getDirectlyConnectedTraces();for(const a of i)if(a._isExplicitlyConnectedToNet(this)){t.push(n);break}}return t}_getAllDirectlyConnectedTraces(){const e=this.getSubcircuit().selectAll("trace"),t=[];for(const n of e)n._isExplicitlyConnectedToNet(this)&&t.push(n);return t}doInitialPcbRouteNetIslands(){var a;if((a=this.root)!=null&&a.pcbDisabled||this.getSubcircuit()._parsedProps.routingDisabled)return;const{db:e}=this.root,t=this._getAllDirectlyConnectedTraces().filter(o=>{var s;return(((s=o._portsRoutedOnPcb)==null?void 0:s.length)??0)>0}),n=[];for(const o of t){const s=o._portsRoutedOnPcb,l=n.find(c=>s.some(u=>c.ports.includes(u)));if(!l){n.push({ports:[...s],traces:[o]});continue}l.traces.push(o),l.ports.push(...s)}if(n.length===0)return;const i=vce(n);for(const[o,s]of i){const l=o.ports.map(A=>A._getGlobalPcbPositionBeforeLayout()),c=s.ports.map(A=>A._getGlobalPcbPositionBeforeLayout());let u=1/0,h=[-1,-1];for(let A=0;A<l.length;A++){const L=l[A];for(let U=0;U<c.length;U++){const j=c[U],Z=Math.sqrt((L.x-j.x)**2+(L.y-j.y)**2);Z<u&&(u=Z,h=[A,U])}}const g=o.ports[h[0]],_=s.ports[h[1]],b=e.toArray().filter(A=>A.type==="pcb_smtpad"||A.type==="pcb_trace"||A.type==="pcb_plated_hole"||A.type==="pcb_hole"||A.type==="source_port"||A.type==="pcb_port"),{solution:T}=wGe(b.concat([{type:"source_trace",source_trace_id:"__net_trace_tmp",connected_source_port_ids:[g.source_port_id,_.source_port_id]}])),C=T[0];if(!C){this.renderError({pcb_trace_error_id:"",pcb_trace_id:"__net_trace_tmp",pcb_component_ids:[g.pcb_component_id,_.pcb_component_id].filter(Boolean),pcb_port_ids:[g.pcb_port_id,_.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(C)}}renderError(e){var t;if(typeof e=="string")return super.renderError(e);(t=this.root)==null||t.db.pcb_trace_error.insert(e)}},gce=(r,e)=>{for(const t of e)typeof t=="string"&&t.startsWith("net.")&&(r.getSubcircuit().selectOne(t)||r.getSubcircuit().add(new yce({name:t.split("net.")[1]})))},jI=class extends R_{constructor(){super(...arguments);ni(this,"pcb_smtpad_id",null);ni(this,"matchedPort",null);ni(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SmtPad",zodProps:cqe}}getPcbSize(){const{_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};throw new Error(`getPcbSize for shape "${e.shape}" not implemented for ${this.componentName}`)}doInitialPortMatching(){var t;const e=(t=this.getPrimitiveContainer())==null?void 0:t.selectAll("port");if(this.props.portHints){for(const n of e)if(n.isMatchingAnyOf(this.props.portHints)){this.matchedPort=n,n.registerMatch(this);return}}}doInitialPcbPrimitiveRender(){var g,_,b,T,C,A,L,U,j;if((g=this.root)!=null&&g.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this;if(!t.portHints)return;const n=this.getPrimitiveContainer(),i=this.getSubcircuit(),a=this._getGlobalPcbPositionBeforeLayout();n==null||n._getGlobalPcbPositionBeforeLayout();const o=gF(this._computePcbGlobalTransformBeforeLayout()),s=Math.abs(o.rotation.angle*(180/Math.PI)-90)%180<.01,{maybeFlipLayer:l}=this._getPcbPrimitiveFlippedHelpers(),c=(n==null?void 0:n._parsedProps.pcbRotation)??0;let u=null;const h=((_=this.parent)==null?void 0:_.pcb_component_id)??((b=this.getPrimitiveContainer())==null?void 0:b.pcb_component_id);t.shape==="circle"?(u=e.pcb_smtpad.insert({pcb_component_id:h,pcb_port_id:(T=this.matchedPort)==null?void 0:T.pcb_port_id,layer:l(t.layer??"top"),shape:"circle",radius:t.radius,port_hints:t.portHints.map(Z=>Z.toString()),x:a.x,y:a.y,subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0}),e.pcb_solder_paste.insert({layer:u.layer,shape:"circle",radius:u.radius*.7,x:u.x,y:u.y,pcb_component_id:u.pcb_component_id,pcb_smtpad_id:u.pcb_smtpad_id,subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0,pcb_group_id:((C=this.getGroup())==null?void 0:C.pcb_group_id)??void 0})):t.shape==="rect"&&(u=c===0||s?e.pcb_smtpad.insert({pcb_component_id:h,pcb_port_id:(A=this.matchedPort)==null?void 0:A.pcb_port_id,layer:l(t.layer??"top"),shape:"rect",width:s?t.height:t.width,height:s?t.width:t.height,port_hints:t.portHints.map(Z=>Z.toString()),x:a.x,y:a.y,subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0,pcb_group_id:((L=this.getGroup())==null?void 0:L.pcb_group_id)??void 0}):e.pcb_smtpad.insert({pcb_component_id:h,layer:t.layer??"top",shape:"rotated_rect",width:t.width,height:t.height,x:a.x,y:a.y,ccw_rotation:c,port_hints:t.portHints.map(Z=>Z.toString()),subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0,pcb_group_id:((U=this.getGroup())==null?void 0:U.pcb_group_id)??void 0}),u.shape==="rect"&&e.pcb_solder_paste.insert({layer:u.layer,shape:"rect",width:u.width*.7,height:u.height*.7,x:u.x,y:u.y,pcb_component_id:u.pcb_component_id,pcb_smtpad_id:u.pcb_smtpad_id,subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0,pcb_group_id:((j=this.getGroup())==null?void 0:j.pcb_group_id)??void 0})),u&&(this.pcb_smtpad_id=u.pcb_smtpad_id)}doInitialPcbPortAttachment(){var t,n;if((t=this.root)!=null&&t.pcbDisabled)return;const{db:e}=this.root;e.pcb_smtpad.update(this.pcb_smtpad_id,{pcb_port_id:(n=this.matchedPort)==null?void 0:n.pcb_port_id})}_getPcbCircuitJsonBounds(){const{db:e}=this.root,t=e.pcb_smtpad.get(this.pcb_smtpad_id);if(t.shape==="rect")return{center:{x:t.x,y:t.y},bounds:{left:t.x-t.width/2,top:t.y+t.height/2,right:t.x+t.width/2,bottom:t.y-t.height/2},width:t.width,height:t.height};if(t.shape==="rotated_rect"){const n=t.ccw_rotation*Math.PI/180,i=Math.cos(n),a=Math.sin(n),o=t.width/2,s=t.height/2,l=Math.abs(o*i)+Math.abs(s*a),c=Math.abs(o*a)+Math.abs(s*i);return{center:{x:t.x,y:t.y},bounds:{left:t.x-l,right:t.x+l,top:t.y-c,bottom:t.y+c},width:l*2,height:c*2}}if(t.shape==="circle")return{center:{x:t.x,y:t.y},bounds:{left:t.x-t.radius,top:t.y-t.radius,right:t.x+t.radius,bottom:t.y+t.radius},width:t.radius*2,height:t.radius*2};throw new Error(`circuitJson bounds calculation not implemented for shape "${t.shape}"`)}_setPositionFromLayout(e){var i;const{db:t}=this.root;t.pcb_smtpad.update(this.pcb_smtpad_id,{x:e.x,y:e.y});const n=t.pcb_solder_paste.list().find(a=>a.pcb_smtpad_id===this.pcb_smtpad_id);t.pcb_solder_paste.update(n==null?void 0:n.pcb_solder_paste_id,{x:e.x,y:e.y}),(i=this.matchedPort)==null||i._setPositionFromLayout(e)}},_ce=class extends R_{constructor(){super(...arguments);ni(this,"pcb_silkscreen_path_id",null)}get config(){return{componentName:"SilkscreenPath",zodProps:Nqe}}doInitialPcbPrimitiveRender(){var s,l,c;if((s=this.root)!=null&&s.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=t.layer??"top";if(n!=="top"&&n!=="bottom")throw new Error(`Invalid layer "${n}" for SilkscreenPath. Must be "top" or "bottom".`);const i=this._computePcbGlobalTransformBeforeLayout(),a=this.getSubcircuit(),o=e.pcb_silkscreen_path.insert({pcb_component_id:(l=this.parent)==null?void 0:l.pcb_component_id,layer:n,route:t.route.map(u=>{const h=ui(i,{x:u.x,y:u.y});return{...u,x:h.x,y:h.y}}),stroke_width:t.strokeWidth??.1,subcircuit_id:(a==null?void 0:a.subcircuit_id)??void 0,pcb_group_id:((c=this.getGroup())==null?void 0:c.pcb_group_id)??void 0});this.pcb_silkscreen_path_id=o.pcb_silkscreen_path_id}},xce=class extends R_{constructor(){super(...arguments);ni(this,"pcb_plated_hole_id",null);ni(this,"matchedPort",null);ni(this,"isPcbPrimitive",!0)}get config(){return{componentName:"PlatedHole",zodProps:WGe}}getAvailablePcbLayers(){return["top","inner1","inner2","bottom"]}getPcbSize(){const{_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};throw new Error(`getPcbSize for shape "${e.shape}" not implemented for ${this.componentName}`)}_getPcbCircuitJsonBounds(){const{db:e}=this.root,t=e.pcb_plated_hole.get(this.pcb_plated_hole_id),n=this.getPcbSize();return{center:{x:t.x,y:t.y},bounds:{left:t.x-n.width/2,top:t.y+n.height/2,right:t.x+n.width/2,bottom:t.y-n.height/2},width:n.width,height:n.height}}_setPositionFromLayout(e){var n;const{db:t}=this.root;t.pcb_plated_hole.update(this.pcb_plated_hole_id,{x:e.x,y:e.y}),(n=this.matchedPort)==null||n._setPositionFromLayout(e)}doInitialPortMatching(){var t;const e=(t=this.getPrimitiveContainer())==null?void 0:t.selectAll("port");if(this.props.portHints){for(const n of e)if(n.isMatchingAnyOf(this.props.portHints)){this.matchedPort=n,n.registerMatch(this);return}}}doInitialPcbPrimitiveRender(){var o,s,l,c,u,h,g;if((o=this.root)!=null&&o.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this._getGlobalPcbPositionBeforeLayout(),i=((s=this.parent)==null?void 0:s.pcb_component_id)??((l=this.getPrimitiveContainer())==null?void 0:l.pcb_component_id),a=this.getSubcircuit();if(t.shape==="circle"){const _=e.pcb_plated_hole.insert({pcb_component_id:i,pcb_port_id:(c=this.matchedPort)==null?void 0:c.pcb_port_id,outer_diameter:t.outerDiameter,hole_diameter:t.holeDiameter,shape:"circle",port_hints:this.getNameAndAliases(),x:n.x,y:n.y,layers:["top","bottom"],subcircuit_id:(a==null?void 0:a.subcircuit_id)??void 0,pcb_group_id:((u=this.getGroup())==null?void 0:u.pcb_group_id)??void 0});this.pcb_plated_hole_id=_.pcb_plated_hole_id}else if(t.shape==="pill"||t.shape==="oval"){const _=e.pcb_plated_hole.insert({pcb_component_id:i,pcb_port_id:(h=this.matchedPort)==null?void 0:h.pcb_port_id,outer_width:t.outerWidth,outer_height:t.outerHeight,hole_width:t.innerWidth,hole_height:t.innerHeight,shape:t.shape,port_hints:this.getNameAndAliases(),x:n.x,y:n.y,layers:["top","bottom"],subcircuit_id:(a==null?void 0:a.subcircuit_id)??void 0,pcb_group_id:((g=this.getGroup())==null?void 0:g.pcb_group_id)??void 0});this.pcb_plated_hole_id=_.pcb_plated_hole_id}}doInitialPcbPortAttachment(){var t,n;if((t=this.root)!=null&&t.pcbDisabled)return;const{db:e}=this.root;e.pcb_plated_hole.update(this.pcb_plated_hole_id,{pcb_port_id:(n=this.matchedPort)==null?void 0:n.pcb_port_id})}},GI=class extends R_{constructor(){super(...arguments);ni(this,"pcb_keepout_id",null);ni(this,"isPcbPrimitive",!0)}get config(){return{componentName:"Keepout",zodProps:Aqe}}doInitialPcbPrimitiveRender(){var l,c,u;if((l=this.root)!=null&&l.pcbDisabled)return;const e=this.getSubcircuit(),{db:t}=this.root,{_parsedProps:n}=this,i=this._getGlobalPcbPositionBeforeLayout(),a=gF(this._computePcbGlobalTransformBeforeLayout()),o=Math.abs(a.rotation.angle*(180/Math.PI)-90)%180<.01;let s=null;n.shape==="circle"?s=t.pcb_keepout.insert({layers:["top"],shape:"circle",radius:n.radius,center:{x:i.x,y:i.y},subcircuit_id:(e==null?void 0:e.subcircuit_id)??void 0,pcb_group_id:((c=e==null?void 0:e.getGroup())==null?void 0:c.pcb_group_id)??void 0}):n.shape==="rect"&&(s=t.pcb_keepout.insert({layers:["top"],shape:"rect",...o?{width:n.height,height:n.width}:{width:n.width,height:n.height},center:{x:i.x,y:i.y},subcircuit_id:(e==null?void 0:e.subcircuit_id)??void 0,pcb_group_id:((u=e==null?void 0:e.getGroup())==null?void 0:u.pcb_group_id)??void 0})),s&&(this.pcb_keepout_id=s.pcb_keepout_id)}},bce=class extends R_{constructor(){super(...arguments);ni(this,"pcb_hole_id",null);ni(this,"isPcbPrimitive",!0)}get config(){return{componentName:"Hole",zodProps:dqe}}getPcbSize(){const{_parsedProps:e}=this;return{width:e.diameter,height:e.diameter}}doInitialPcbPrimitiveRender(){var o,s;if((o=this.root)!=null&&o.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this.getSubcircuit(),i=this._getGlobalPcbPositionBeforeLayout(),a=e.pcb_hole.insert({hole_shape:"circle",hole_diameter:t.diameter,x:i.x,y:i.y,subcircuit_id:(n==null?void 0:n.subcircuit_id)??void 0,pcb_group_id:((s=n==null?void 0:n.getGroup())==null?void 0:s.pcb_group_id)??void 0});this.pcb_hole_id=a.pcb_hole_id}_getPcbCircuitJsonBounds(){const{db:e}=this.root,t=e.pcb_hole.get(this.pcb_hole_id),n=this.getPcbSize();return{center:{x:t.x,y:t.y},bounds:{left:t.x-n.width/2,top:t.y-n.height/2,right:t.x+n.width/2,bottom:t.y+n.height/2},width:n.width,height:n.height}}_setPositionFromLayout(e){const{db:t}=this.root;t.pcb_hole.update(this.pcb_hole_id,{x:e.x,y:e.y})}},gYe=r=>{const e=[];for(const t of r)t.type==="pcb_smtpad"&&t.shape==="rect"?e.push(new jI({pcbX:t.x,pcbY:t.y,layer:t.layer,shape:"rect",height:t.height,width:t.width,portHints:t.port_hints})):t.type==="pcb_smtpad"&&t.shape==="circle"?e.push(new jI({pcbX:t.x,pcbY:t.y,layer:t.layer,shape:"circle",radius:t.radius,portHints:t.port_hints})):t.type==="pcb_silkscreen_path"?e.push(new _ce({layer:t.layer,route:t.route,strokeWidth:t.stroke_width})):t.type==="pcb_plated_hole"&&t.shape==="circle"?t.shape==="circle"&&e.push(new xce({pcbX:t.x,pcbY:t.y,shape:"circle",holeDiameter:t.hole_diameter,outerDiameter:t.outer_diameter,portHints:t.port_hints})):t.type==="pcb_keepout"&&t.shape==="circle"?e.push(new GI({pcbX:t.center.x,pcbY:t.center.y,shape:"circle",radius:t.radius})):t.type==="pcb_keepout"&&t.shape==="rect"?e.push(new GI({pcbX:t.center.x,pcbY:t.center.y,shape:"rect",width:t.width,height:t.height})):t.type==="pcb_hole"&&t.hole_shape==="circle"&&e.push(new bce({pcbX:t.x,pcbY:t.y,diameter:t.hole_diameter}));return e};function Sce(r){let e=1/0,t=1/0,n=-1/0,i=-1/0;for(const s of r)if(s.isPcbPrimitive){const{x:l,y:c}=s._getGlobalPcbPositionBeforeLayout(),{width:u,height:h}=s.getPcbSize();e=Math.min(e,l-u/2),t=Math.min(t,c-h/2),n=Math.max(n,l+u/2),i=Math.max(i,c+h/2)}else if(s.componentName==="Footprint"){const l=Sce(s.children);e=Math.min(e,l.minX),t=Math.min(t,l.minY),n=Math.max(n,l.maxX),i=Math.max(i,l.maxY)}let a=n-e,o=i-t;return a<0&&(a=0),o<0&&(o=0),{minX:e,minY:t,maxX:n,maxY:i,width:a,height:o}}function _Ye(r,e){const t=e.x-r.x,n=e.y-r.y;return Math.abs(t)>Math.abs(n)?t>=0?"right":"left":n>=0?"up":"down"}var xYe=r=>{if(r.length<=1)return!0;const e=r.map(a=>{const o=a._getPcbCircuitJsonBounds();return{left:o.bounds.left,right:o.bounds.right,top:o.bounds.top,bottom:o.bounds.bottom}}),t=Array(e.length).fill(!1).map(()=>Array(e.length).fill(!1));for(let a=0;a<e.length;a++)for(let o=a+1;o<e.length;o++){const s=e[a],l=e[o];t[a][o]=t[o][a]=!(s.right<l.left||s.left>l.right||s.bottom>l.top||s.top<l.bottom)}const n=new Set,i=a=>{n.add(a);for(let o=0;o<e.length;o++)t[a][o]&&!n.has(o)&&i(o)};return i(0),n.size===e.length},bYe=r=>{if(r.length===0)throw new Error("Cannot get center of empty PCB primitives array");const e=r.map(i=>i._getPcbCircuitJsonBounds().center).filter(Boolean),t=e.reduce((i,a)=>i+a.x,0),n=e.reduce((i,a)=>i+a.y,0);return{x:t/e.length,y:n/e.length}},SYe=ue.object({name:ue.string().optional(),pinNumber:ue.number().optional(),aliases:ue.array(ue.string()).optional()}),l4=class extends R_{constructor(e,t={}){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);ni(this,"source_port_id",null);ni(this,"pcb_port_id",null);ni(this,"schematic_port_id",null);ni(this,"schematicSymbolPortDef",null);ni(this,"matchedComponents");ni(this,"facingDirection",null);ni(this,"originDescription",null);t.originDescription&&(this.originDescription=t.originDescription),this.matchedComponents=[]}get config(){return{componentName:"Port",zodProps:SYe}}_getGlobalPcbPositionBeforeLayout(){const e=this.matchedComponents.find(n=>n.isPcbPrimitive),t=this.parent;if(t&&!t.props.footprint)throw new Error(`${t.componentName} "${t.props.name}" does not have a footprint. Add a footprint prop, e.g. <${t.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==null?void 0:e._getGlobalPcbPositionBeforeLayout())??{x:0,y:0}}_getPcbCircuitJsonBounds(){if(!this.pcb_port_id)return super._getPcbCircuitJsonBounds();const{db:e}=this.root,t=e.pcb_port.get(this.pcb_port_id);return{center:{x:t.x,y:t.y},bounds:{left:0,top:0,right:0,bottom:0},width:0,height:0}}_getGlobalPcbPositionAfterLayout(){return this._getPcbCircuitJsonBounds().center}_getPortsInternallyConnectedToThisPort(){const e=this.parent;if(!e||!e._getInternallyConnectedPins)return[];const t=e._getInternallyConnectedPins();for(const n of t)if(n.some(i=>i===this))return n;return[]}_hasSchematicPort(){var n,i;if((n=this.parent)==null?void 0:n.getSchematicSymbol())return!!(this.schematicSymbolPortDef||this._getPortsInternallyConnectedToThisPort().some(o=>o.schematicSymbolPortDef));const t=(i=this==null?void 0:this.parent)==null?void 0:i._getSchematicBoxDimensions();return!!(t&&this.props.pinNumber!==void 0&&t.getPortPositionByPinNumber(this.props.pinNumber))}_getGlobalSchematicPositionBeforeLayout(){var n,i,a;const e=(n=this.parent)==null?void 0:n.getSchematicSymbol();if(e){let o=this.schematicSymbolPortDef;if(!o&&(o=((i=this._getPortsInternallyConnectedToThisPort().find(l=>l.schematicSymbolPortDef))==null?void 0:i.schematicSymbolPortDef)??null,!o))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?`);const s=oh(this.parent.computeSchematicGlobalTransform(),rv(-e.center.x,-e.center.y));return ui(s,o)}const t=(a=this==null?void 0:this.parent)==null?void 0:a._getSchematicBoxDimensions();if(t&&this.props.pinNumber!==void 0){const o=t.getPortPositionByPinNumber(this.props.pinNumber);if(!o)throw new Error(`Couldn't find position for schematic_port for port ${this.getString()} inside of the schematic box`);return ui(this.parent.computeSchematicGlobalTransform(),o)}throw new Error(`Couldn't find position for schematic_port for port ${this.getString()}`)}_getGlobalSchematicPositionAfterLayout(){const{db:e}=this.root;if(!this.schematic_port_id)throw new Error("Can't get schematic port position after layout, no schematic_port_id");const t=e.schematic_port.get(this.schematic_port_id);if(!t)throw new Error(`Schematic port not found when trying to get post-layout position: ${this.schematic_port_id}`);return t.center}registerMatch(e){this.matchedComponents.push(e)}getNameAndAliases(){const{_parsedProps:e}=this;return Array.from(new Set([...e.aliases??[],...e.name?[e.name]:[],...typeof e.pinNumber=="number"?[`pin${e.pinNumber}`,e.pinNumber.toString()]:[],...this.externallyAddedAliases??[]]))}isMatchingPort(e){return this.isMatchingAnyOf(e.getNameAndAliases())}getPortSelector(){var e;return`.${(e=this.parent)==null?void 0:e.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(n=>n._isExplicitlyConnectedToPort(this))}doInitialSourceRender(){var a,o;const{db:e}=this.root,{_parsedProps:t}=this,n=this.getNameAndAliases(),i=e.source_port.insert({name:t.name,pin_number:t.pinNumber,port_hints:n,source_component_id:(a=this.parent)==null?void 0:a.source_component_id,subcircuit_id:(o=this.getSubcircuit())==null?void 0:o.subcircuit_id});this.source_port_id=i.source_port_id}doInitialSourceParentAttachment(){var t,n,i,a;const{db:e}=this.root;if(!((t=this.parent)!=null&&t.source_component_id))throw new Error(`${this.getString()} has no parent source component (parent: ${(n=this.parent)==null?void 0:n.getString()})`);e.source_port.update(this.source_port_id,{source_component_id:(i=this.parent)==null?void 0:i.source_component_id}),this.source_component_id=(a=this.parent)==null?void 0:a.source_component_id}doInitialPcbPortRender(){var a,o,s,l,c;if((a=this.root)!=null&&a.pcbDisabled)return;const{db:e}=this.root,{matchedComponents:t}=this;if(!((o=this.parent)!=null&&o.pcb_component_id))throw new Error(`${this.getString()} has no parent pcb component, cannot render pcb_port (parent: ${(s=this.parent)==null?void 0:s.getString()})`);const n=t.filter(u=>u.isPcbPrimitive);if(n.length===0)return;let i=null;if(n.length===1&&(i=n[0]._getPcbCircuitJsonBounds().center),n.length>1){if(!xYe(n))throw new Error(`${this.getString()} has multiple non-overlapping pcb matches, unclear how to place pcb_port: ${n.map(u=>u.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)`);i=bYe(n)}if(i){const u=this.getSubcircuit(),h=e.pcb_port.insert({pcb_component_id:(l=this.parent)==null?void 0:l.pcb_component_id,layers:this.getAvailablePcbLayers(),subcircuit_id:(u==null?void 0:u.subcircuit_id)??void 0,pcb_group_id:((c=this.getGroup())==null?void 0:c.pcb_group_id)??void 0,...i,source_port_id:this.source_port_id});this.pcb_port_id=h.pcb_port_id}else{const u=n[0];throw new Error(`${u.getString()} does not have a center or _getGlobalPcbPositionBeforeLayout method (needed for pcb_port placement)`)}}doInitialSchematicPortRender(){var h;const{db:e}=this.root,{_parsedProps:t}=this,n=this.getPrimitiveContainer();if(!n||!this._hasSchematicPort())return;const i=n._getGlobalSchematicPositionBeforeLayout(),a=this._getGlobalSchematicPositionBeforeLayout();let o=null;const s=n._getSchematicBoxDimensions();s&&t.pinNumber!==void 0&&(o=s.getPortPositionByPinNumber(t.pinNumber)),this.getSubcircuit().props._schDebugObjectsEnabled&&e.schematic_debug_object.insert({shape:"rect",center:a,size:{width:.1,height:.1},label:"obstacle"}),o!=null&&o.side?this.facingDirection={left:"left",right:"right",top:"up",bottom:"down"}[o.side]:this.facingDirection=_Ye(i,a);const l=e.source_port.get(this.source_port_id);let c;for(const g of(l==null?void 0:l.port_hints)??[])g.match(/^(pin)?\d+$/)||(c=g);const u=e.schematic_port.insert({schematic_component_id:(h=this.parent)==null?void 0:h.schematic_component_id,center:a,source_port_id:this.source_port_id,facing_direction:this.facingDirection,distance_from_component_edge:.4,side_of_component:o==null?void 0:o.side,pin_number:t.pinNumber,true_ccw_index:o==null?void 0:o.trueIndex,display_pin_label:c});this.schematic_port_id=u.schematic_port_id}_setPositionFromLayout(e){const{db:t}=this.root;this.pcb_port_id&&t.pcb_port.update(this.pcb_port_id,{x:e.x,y:e.y})}_hasMatchedPcbPrimitive(){return this.matchedComponents.some(e=>e.isPcbPrimitive)}},Ece=r=>{const e=r.find(t=>/^(pin)?\d+$/.test(t));return e?Number.parseInt(e.replace(/^pin/,"")):null};function xT(r,e){var a;const t=Ece(r);if(!t)return null;const i=[...r.filter(o=>o.toString()!==t.toString()&&o!==`pin${t}`),...((a=e==null?void 0:e.additionalAliases)==null?void 0:a[`pin${t}`])??[]];return new l4({pinNumber:t,aliases:i})}var EYe=r=>{for(const e of["leftSide","rightSide","topSide","bottomSide"])if(e in r&&typeof r[e]=="number")throw new Error(`A number was specified for "${e}", you probably meant to use "size" not "side"`);return"leftSide"in r||"rightSide"in r||"topSide"in r||"bottomSide"in r},wYe=r=>{var a,o,s,l;if(EYe(r))return{leftSize:((a=r.leftSide)==null?void 0:a.pins.length)??0,rightSize:((o=r.rightSide)==null?void 0:o.pins.length)??0,topSize:((s=r.topSide)==null?void 0:s.pins.length)??0,bottomSize:((l=r.bottomSide)==null?void 0:l.pins.length)??0};const{leftSize:e=0,rightSize:t=0,topSize:n=0,bottomSize:i=0}=r;return{leftSize:e,rightSize:t,topSize:n,bottomSize:i}};function wce(r){return r.leftSide!==void 0}var TYe=r=>{var C,A,L,U,j,Z,ee,$;const e=r.portDistanceFromEdge??.4;let t=r.schPortArrangement?wYe(r.schPortArrangement):null;const n={left:0,right:0,top:0,bottom:0};let i=r.pinCount??null;if(i===null)if(t)i=t.leftSize+t.rightSize+t.topSize;else throw new Error("Could not determine pin count for the schematic box");if(i&&!t){const oe=Math.floor(i/2);t={leftSize:i-oe,rightSize:oe,topSize:0,bottomSize:0}}t||(t={leftSize:0,rightSize:0,topSize:0,bottomSize:0});const a=({side:oe,sideIndex:ae,truePinIndex:ce})=>{var ze,Ne,Oe,Le;if(!r.schPortArrangement||!wce(r.schPortArrangement))return ce+1;const me={left:"top-to-bottom",bottom:"left-to-right",right:"bottom-to-top",top:"right-to-left"}[oe],_e=((Ne=(ze=r.schPortArrangement)==null?void 0:ze[`${oe}Side`])==null?void 0:Ne.direction)??me,Se=(Le=(Oe=r.schPortArrangement)==null?void 0:Oe[`${oe}Side`])==null?void 0:Le.pins;let Ae=ae;return _e!==me&&(Ae=Se.length-ae-1),gT(Se[Ae],r.pinLabels)},o=[];let s=0,l=0;for(let oe=0;oe<t.leftSize;oe++){const ae=a({side:"left",sideIndex:oe,truePinIndex:l}),ce=((C=r.numericSchPinStyle)==null?void 0:C[`pin${ae}`])??((A=r.numericSchPinStyle)==null?void 0:A[ae]);ce!=null&&ce.topMargin&&(s+=ce.topMargin),o.push({trueIndex:l,pinNumber:ae,side:"left",distanceFromOrthogonalEdge:s}),ce!=null&&ce.bottomMargin&&(s+=ce.bottomMargin),oe===t.leftSize-1?n.left=s:s+=r.schPinSpacing,l++}s=0;for(let oe=0;oe<t.bottomSize;oe++){const ae=a({side:"bottom",sideIndex:oe,truePinIndex:l}),ce=((L=r.numericSchPinStyle)==null?void 0:L[`pin${ae}`])??((U=r.numericSchPinStyle)==null?void 0:U[ae]);ce!=null&&ce.leftMargin&&(s+=ce.leftMargin),o.push({trueIndex:l,pinNumber:ae,side:"bottom",distanceFromOrthogonalEdge:s}),ce!=null&&ce.rightMargin&&(s+=ce.rightMargin),oe===t.bottomSize-1?n.bottom=s:s+=r.schPinSpacing,l++}s=0;for(let oe=0;oe<t.rightSize;oe++){const ae=a({side:"right",sideIndex:oe,truePinIndex:l}),ce=((j=r.numericSchPinStyle)==null?void 0:j[`pin${ae}`])??((Z=r.numericSchPinStyle)==null?void 0:Z[ae]);ce!=null&&ce.bottomMargin&&(s+=ce.bottomMargin),o.push({trueIndex:l,pinNumber:ae,side:"right",distanceFromOrthogonalEdge:s}),ce!=null&&ce.topMargin&&(s+=ce.topMargin),oe===t.rightSize-1?n.right=s:s+=r.schPinSpacing,l++}s=0;for(let oe=0;oe<t.topSize;oe++){const ae=a({side:"top",sideIndex:oe,truePinIndex:l}),ce=((ee=r.numericSchPinStyle)==null?void 0:ee[`pin${ae}`])??(($=r.numericSchPinStyle)==null?void 0:$[ae]);ce!=null&&ce.rightMargin&&(s+=ce.rightMargin),o.push({trueIndex:l,pinNumber:ae,side:"top",distanceFromOrthogonalEdge:s}),ce!=null&&ce.leftMargin&&(s+=ce.leftMargin),oe===t.topSize-1?n.top=s:s+=r.schPinSpacing,l++}let c=r.schWidth;c||(c=Math.max(n.top+r.schPinSpacing*2,n.bottom+r.schPinSpacing*2));const u=r.pinLabels?Math.max(...Object.values(r.pinLabels).map(oe=>oe.length*.1)):0,h=u>0?1.1:0;c=Math.max(c,u+h);let g=r.schHeight;g||(g=Math.max(n.left+r.schPinSpacing*2,n.right+r.schPinSpacing*2));const _={left:{x:-c/2-e,y:n.left/2},bottom:{x:-n.bottom/2,y:-g/2-e},right:{x:c/2+e,y:-n.right/2},top:{x:n.top/2,y:g/2+e}},b={left:{x:0,y:-1},right:{x:0,y:1},top:{x:-1,y:0},bottom:{x:1,y:0}},T=o.map(oe=>{const{distanceFromOrthogonalEdge:ae,side:ce}=oe,me=_[ce],_e=b[ce];return{x:me.x+ae*_e.x,y:me.y+ae*_e.y,...oe}});return{getPortPositionByPinNumber(oe){const ae=T.find(ce=>ce.pinNumber.toString()===oe.toString());return ae||null},getSize(){return{width:c,height:g}},getSizeIncludingPins(){return{width:c+(t.leftSize||t.rightSize?.4:0),height:g+(t.topSize||t.bottomSize?.4:0)}},pinCount:i}},MYe=g2("tscircuit:core:footprint"),CYe=class extends R_{get config(){return{componentName:"Footprint",zodProps:pqe}}doInitialPcbFootprintLayout(){var h,g,_,b,T;if((h=this.root)!=null&&h.pcbDisabled)return;const r=this.children.filter(C=>C.componentName==="Constraint");if(r.length===0)return;const{isFlipped:e}=this._getPcbPrimitiveFlippedHelpers(),t=C=>e&&"left"in C&&"right"in C?{...C,left:C.right,right:C.left}:C,n=r.flatMap(C=>C._getAllReferencedComponents().componentsWithSelectors).map(({component:C,selector:A,componentSelector:L,edge:U})=>({component:C,selector:A,componentSelector:L,edge:U,bounds:C._getPcbCircuitJsonBounds()}));if(n.some(C=>C.edge))throw new Error("edge constraints not implemented yet for footprint layout, contributions welcome!");function i(C){return n.find(({selector:A})=>A===C)}const a=new Bqe,o={};function s(C){return C in o||(o[C]=new BI(C),a.addEditVariable(o[C],X5.weak)),o[C]}for(const{selector:C,bounds:A}of n){const L=s(`${C}_x`),U=s(`${C}_y`);a.suggestValue(L,A.center.x),a.suggestValue(U,A.center.y)}for(const C of r){const A=C._parsedProps;if("xDist"in A){const{xDist:L,left:U,right:j,edgeToEdge:Z,centerToCenter:ee}=t(A),$=s(`${U}_x`),oe=s(`${j}_x`),ae=(g=i(U))==null?void 0:g.bounds,ce=(_=i(j))==null?void 0:_.bounds;if(ee){const me=new Ax(oe,[-1,$]);a.addConstraint(new K4(me,c3.Eq,A.xDist,X5.required))}else if(Z){const me=new Ax(oe,-ce.width/2,[-1,$],-ae.width/2);a.addConstraint(new K4(me,c3.Eq,A.xDist,X5.required))}}else if("yDist"in A){const{yDist:L,top:U,bottom:j,edgeToEdge:Z,centerToCenter:ee}=A,$=s(`${U}_y`),oe=s(`${j}_y`),ae=(b=i(U))==null?void 0:b.bounds,ce=(T=i(j))==null?void 0:T.bounds;if(ee){const me=new Ax($,[-1,oe]);a.addConstraint(new K4(me,c3.Eq,A.yDist,X5.required))}else if(Z){const me=new Ax($,ae.height/2,[-1,oe],-ce.height/2);a.addConstraint(new K4(me,c3.Eq,A.yDist,X5.required))}}else if("sameY"in A){const{for:L}=A;if(L.length<2)continue;const U=L.map(Z=>s(`${Z}_y`)),j=new Ax(...U.slice(1));a.addConstraint(new K4(j,c3.Eq,U[0],X5.required))}else if("sameX"in A){const{for:L}=A;if(L.length<2)continue;const U=L.map(Z=>s(`${Z}_x`)),j=new Ax(...U.slice(1));a.addConstraint(new K4(j,c3.Eq,U[0],X5.required))}}a.updateVariables(),MYe.enabled&&(console.log("Solution to layout constraints:"),console.table(Object.entries(o).map(([C,A])=>({var:C,val:A.value()}))));const l={left:1/0,right:-1/0,top:-1/0,bottom:1/0};for(const{selector:C,bounds:{width:A,height:L}}of n){const U=s(`${C}_x`),j=s(`${C}_y`),Z=U.value()-A/2,ee=U.value()+A/2,$=j.value()+L/2,oe=j.value()-L/2;l.left=Math.min(l.left,Z),l.right=Math.max(l.right,ee),l.top=Math.max(l.top,$),l.bottom=Math.min(l.bottom,oe)}const c={x:-(l.right+l.left)/2,y:-(l.top+l.bottom)/2},u=this.getPrimitiveContainer()._getGlobalPcbPositionBeforeLayout();c.x+=u.x,c.y+=u.y;for(const{component:C,selector:A}of n){const L=s(`${A}_x`),U=s(`${A}_y`);C._setPositionFromLayout({x:L.value()+c.x,y:U.value()+c.y})}}},RYe=(r,e)=>{if(!r)return;const t={};for(const[n,i]of Object.entries(r)){const a=gT(n,e),o={leftMargin:i.marginLeft??i.leftMargin,rightMargin:i.marginRight??i.rightMargin,topMargin:i.marginTop??i.topMargin,bottomMargin:i.marginBottom??i.bottomMargin};t[`pin${a}`]={...t[`pin${a}`],...o}}return t},AYe=g2("tscircuit:core"),DYe=ue.object({x:L8,y:L8,z:L8}),Dx=class extends R_{constructor(e){super(e);ni(this,"reactSubtrees",[]);ni(this,"_impliedFootprint");ni(this,"isPrimitiveContainer",!0);ni(this,"_asyncSupplierPartNumbers");ni(this,"pcb_missing_footprint_error_id");this._addChildrenFromStringFootprint(),this.initPorts()}get defaultInternallyConnectedPinNames(){return[]}get internallyConnectedPinNames(){return this._parsedProps.internallyConnectedPins??this.defaultInternallyConnectedPinNames}initPorts(e={}){var o,s,l,c,u,h,g,_,b,T;if((o=this.root)!=null&&o.schematicDisabled)return;const{config:t}=this,n=[],i=this._getSchematicPortArrangement();if(i&&!this._parsedProps.pinLabels){for(const L in i){const U=i[L].pins;if(Array.isArray(U))for(const j of U){const Z=gT(j,this._parsedProps.pinLabels);n.push(new l4({pinNumber:Z,aliases:((s=e.additionalAliases)==null?void 0:s[`pin${Z}`])??[]},{originDescription:`schPortArrangement:${L}`}))}}const C=["left","right","top","bottom"];let A=1;for(const L of C){const U=i[`${L}Size`];for(let j=0;j<U;j++)n.push(new l4({pinNumber:A++,aliases:((l=e.additionalAliases)==null?void 0:l[`pin${A}`])??[]},{originDescription:`schPortArrangement:${L}`}))}}const a=this._parsedProps.pinLabels;if(a)for(let[C,A]of Object.entries(a)){C=C.replace("pin","");let L=n.find(Z=>Z._parsedProps.pinNumber===Number(C));const U=Array.isArray(A)?A[0]:A,j=Array.isArray(A)?A.slice(1):[];L?(L.externallyAddedAliases.push(U,...j),L.props.name=U):(L=new l4({pinNumber:parseInt(C),name:U,aliases:[...j,...((c=e.additionalAliases)==null?void 0:c[`pin${parseInt(C)}`])??[]]},{originDescription:`pinLabels:pin${C}`}),n.push(L))}if(t.schematicSymbolName){const C=w3[this._getSchematicSymbolNameOrThrow()];if(!C)return;for(const A of C.ports){const L=Ece(A.labels);if(!L)continue;const U=xT(A.labels.concat(((u=e.additionalAliases)==null?void 0:u[`pin${L}`])??[]));U&&(U.originDescription=`schematicSymbol:labels[0]:${A.labels[0]}`,U.schematicSymbolPortDef=A,n.push(U))}this.addAll(n)}if(!this._getSchematicPortArrangement()){const C=this.getPortsFromFootprint(e);for(const A of C)n.some(L=>L.isMatchingAnyOf(A.getNameAndAliases()))||n.push(A)}for(let C=1;C<=(e.pinCount??this._getPinCount());C++){if(!i||n.find(L=>L._parsedProps.pinNumber===C))continue;let A=[...((h=i.leftSide)==null?void 0:h.pins)??[],...((g=i.rightSide)==null?void 0:g.pins)??[],...((_=i.topSide)==null?void 0:_.pins)??[],...((b=i.bottomSide)==null?void 0:b.pins)??[]].map(L=>gT(L,this._parsedProps.pinLabels));["leftSize","rightSize","topSize","bottomSize","leftPinCount","rightPinCount","topPinCount","bottomPinCount"].some(L=>L in i)&&(A=Array.from({length:this._getPinCount()},(L,U)=>U+1)),A.includes(C)&&n.push(new l4({pinNumber:C,aliases:((T=e.additionalAliases)==null?void 0:T[`pin${C}`])??[]},{originDescription:`notOtherwiseAddedButDeducedFromPinCount:${C}`}))}n.length>0&&this.addAll(n)}_getImpliedFootprintString(){return null}_addChildrenFromStringFootprint(){var t;let{footprint:e}=this.props;if(e??(e=(t=this._getImpliedFootprintString)==null?void 0:t.call(this)),!!e&&typeof e=="string"){const n=Jz.string(e).soup(),i=gYe(n);this.addAll(i)}}get portMap(){return new Proxy({},{get:(e,t)=>{const n=this.children.find(i=>i.componentName==="Port"&&i.isMatchingNameOrAlias(t));if(!n)throw new Error(`There was an issue finding the port "${t.toString()}" inside of a ${this.componentName} component with name: "${this.props.name}". This is a bug in @tscircuit/core`);return n}})}getInstanceForReactElement(e){for(const t of this.reactSubtrees)if(t.element===e)return t.component;return null}doInitialSourceRender(){const e=this.config.sourceFtype;if(!e)return;const{db:t}=this.root,{_parsedProps:n}=this,i=t.source_component.insert({ftype:e,name:n.name,manufacturer_part_number:n.manufacturerPartNumber??n.mfn,supplier_part_numbers:n.supplierPartNumbers});this.source_component_id=i.source_component_id}doInitialSchematicComponentRender(){var n;if((n=this.root)!=null&&n.schematicDisabled)return;const{schematicSymbolName:e}=this.config;if(e)return this._doInitialSchematicComponentRenderWithSymbol();if(this._getSchematicBoxDimensions())return this._doInitialSchematicComponentRenderWithSchematicBoxDimensions()}_getSchematicSymbolDisplayValue(){}_getInternallyConnectedPins(){if(this.internallyConnectedPinNames.length===0)return[];const e=[];for(const t of this.internallyConnectedPinNames){const n=[];for(const i of t)n.push(this.portMap[i]);e.push(n)}return e}_doInitialSchematicComponentRenderWithSymbol(){var o;if((o=this.root)!=null&&o.schematicDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this._getSchematicSymbolNameOrThrow(),i=w3[n],a=this._getGlobalSchematicPositionBeforeLayout();if(i){const s=e.schematic_component.insert({center:a,rotation:t.schRotation??0,size:i.size,source_component_id:this.source_component_id,symbol_name:n,symbol_display_value:this._getSchematicSymbolDisplayValue()});this.schematic_component_id=s.schematic_component_id}}_doInitialSchematicComponentRenderWithSchematicBoxDimensions(){var h;if((h=this.root)!=null&&h.schematicDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this._getSchematicBoxDimensions(),i={};if(Array.isArray(t.pinLabels))t.pinLabels.forEach((g,_)=>{i[String(_+1)]=g});else for(const[g,_]of Object.entries(t.pinLabels??{}))i[g]=Array.isArray(_)?_[0]:_;const a=this._getGlobalSchematicPositionBeforeLayout(),o=this._getSchematicPortArrangement(),s=e.schematic_component.insert({center:a,rotation:t.schRotation??0,size:n.getSize(),port_arrangement:mYe(o),pin_spacing:t.schPinSpacing??.2,pin_styles:pYe(t.schPinStyle,t.pinLabels),port_labels:i,source_component_id:this.source_component_id}),l=(o==null?void 0:o.topSide)!==void 0||(o==null?void 0:o.bottomSide)!==void 0,c=n==null?void 0:n.getSize().width,u=n==null?void 0:n.getSize().height;e.schematic_text.insert({text:t.manufacturerPartNumber??"",schematic_component_id:s.schematic_component_id,anchor:"left",rotation:0,position:{x:l?a.x+(c??0)/2+.1:a.x-(c??0)/2,y:l?a.y+(u??0)/2+.35:a.y-(u??0)/2-.13},color:"#006464"}),e.schematic_text.insert({text:t.name??"",schematic_component_id:s.schematic_component_id,anchor:"left",rotation:0,position:{x:l?a.x+(c??0)/2+.1:a.x-(c??0)/2,y:l?a.y+(u??0)/2+.55:a.y+(u??0)/2+.13},color:"#006464"}),this.schematic_component_id=s.schematic_component_id}doInitialPcbComponentRender(){var o;if((o=this.root)!=null&&o.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this.getSubcircuit(),i=e.pcb_component.insert({center:this._getGlobalPcbPositionBeforeLayout(),width:0,height:0,layer:t.layer??"top",rotation:t.pcbRotation??0,source_component_id:this.source_component_id,subcircuit_id:n.subcircuit_id??void 0});if(!t.footprint&&!this.isGroup){const s=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=s.pcb_missing_footprint_error_id}this.pcb_component_id=i.pcb_component_id;const a=this.getSubcircuit()._getPcbManualPlacementForComponent(this);this.props.pcbX!==void 0&&this.props.pcbY!==void 0&&a&&this.renderError({type:"pcb_manual_edit_conflict_error",message:`${this.getString()} has both manual placement and explicit 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})}doInitialPcbComponentSizeCalculation(){var i;if((i=this.root)!=null&&i.pcbDisabled||!this.pcb_component_id)return;const{db:e}=this.root,t=Sce(this.children);if(t.width===0||t.height===0)return;const n={x:(t.minX+t.maxX)/2,y:(t.minY+t.maxY)/2};e.pcb_component.update(this.pcb_component_id,{center:n,width:t.width,height:t.height})}_renderReactSubtree(e){return{element:e,component:mce(e)}}doInitialInitializePortsFromChildren(){this.initPorts()}doInitialReactSubtreesRender(){if(Tt.isValidElement(this.props.footprint)){if(this.reactSubtrees.some(t=>t.element===this.props.footprint))return;const e=this._renderReactSubtree(this.props.footprint);this.reactSubtrees.push(e),this.add(e.component)}}_hasExistingPortExactly(e){return this.children.filter(n=>n.componentName==="Port").some(n=>{const i=e.getNameAndAliases(),a=n.getNameAndAliases();return i.length===a.length&&i.every(o=>a.includes(o))})}add(e){let t;if(Tt.isValidElement(e)){const n=this._renderReactSubtree(e);this.reactSubtrees.push(n),t=n.component}else t=e;if(t.componentName==="Port"){if(this._hasExistingPortExactly(t))return;const i=this.children.filter(a=>a.componentName==="Port").find(a=>a.isMatchingAnyOf(t.getNameAndAliases()));i&&AYe(`Similar ports added. Port 1: ${i}, Port 2: ${t}`)}super.add(t)}getPortsFromFootprint(e){let{footprint:t}=this.props;if((!t||Tt.isValidElement(t))&&(t=this.children.find(i=>i.componentName==="Footprint")),typeof t=="string"){const i=Jz.string(t).soup(),a=[];for(const o of i)if("port_hints"in o&&o.port_hints){const s=xT(o.port_hints,e);if(!s)continue;s.originDescription=`footprint:string:${t}:port_hints[0]:${o.port_hints[0]}`,a.push(s)}return a}if(!Tt.isValidElement(t)&&t&&t.componentName==="Footprint"){const i=t;let a=1;const o=[];for(const s of i.children){if(!s.props.portHints)continue;let l=s.props.portHints;l.some(h=>h.startsWith("pin"))||(l=[...l,`pin${a}`]),a++;const u=xT(l);u&&(u.originDescription=`footprint:${t}`,o.push(u))}return o}const n=[];if(!t){for(const i of this.children)if(i.props.portHints&&i.isPcbPrimitive){const a=xT(i.props.portHints);a&&n.push(a)}}return n}getPortsFromSchematicSymbol(){var i;if((i=this.root)!=null&&i.schematicDisabled)return[];const{config:e}=this;if(!e.schematicSymbolName)return[];const t=w3[e.schematicSymbolName];if(!t)return[];const n=[];for(const a of t.ports){const o=xT(a.labels);o&&(o.schematicSymbolPortDef=a,n.push(o))}return n}_createNetsFromProps(e){gce(this,e)}_getPcbCircuitJsonBounds(){const{db:e}=this.root;if(!this.pcb_component_id)return super._getPcbCircuitJsonBounds();const t=e.pcb_component.get(this.pcb_component_id);return{center:{x:t.center.x,y:t.center.y},bounds:{left:t.center.x-t.width/2,top:t.center.y-t.height/2,right:t.center.x+t.width/2,bottom:t.center.y+t.height/2},width:t.width,height:t.height}}_getPinCountFromSchematicPortArrangement(){const e=this._getSchematicPortArrangement();if(!e)return 0;if(!wce(e))return(e.leftSize??e.leftPinCount??0)+(e.rightSize??e.rightPinCount??0)+(e.topSize??e.topPinCount??0)+(e.bottomSize??e.bottomPinCount??0);const{leftSide:n,rightSide:i,topSide:a,bottomSide:o}=e;return Math.max(...(n==null?void 0:n.pins)??[],...(i==null?void 0:i.pins)??[],...(a==null?void 0:a.pins)??[],...(o==null?void 0:o.pins)??[])}_getPinCount(){return this._getSchematicPortArrangement()?this._getPinCountFromSchematicPortArrangement():this.getPortsFromFootprint().length}_getSchematicPortArrangement(){return this._parsedProps.schPinArrangement??this._parsedProps.schPortArrangement}_getSchematicBoxDimensions(){if(this.getSchematicSymbol()||!this.config.shouldRenderAsSchematicBox)return null;const{_parsedProps:e}=this,t=this._getPinCount(),n=e.schPinSpacing??.2;return TYe({schWidth:e.schWidth,schHeight:e.schHeight,schPinSpacing:n,numericSchPinStyle:RYe(e.schPinStyle,e.pinLabels),pinCount:t,schPortArrangement:this._getSchematicPortArrangement(),pinLabels:e.pinLabels})}doInitialCadModelRender(){var c;const{db:e}=this.root,{boardThickness:t=0}=((c=this.root)==null?void 0:c._getBoard())??{},n=this._parsedProps.cadModel;if(!this.pcb_component_id||!n&&!this.props.footprint)return;const i=this._getPcbCircuitJsonBounds(),a=e.pcb_component.get(this.pcb_component_id);if(typeof n=="string")throw new Error("String cadModel not yet implemented");const o=DYe.parse({x:0,y:0,z:typeof(n==null?void 0:n.rotationOffset)=="number"?n.rotationOffset:0,...typeof(n==null?void 0:n.rotationOffset)=="object"?n.rotationOffset??{}:{}}),s=hR.parse({x:0,y:0,z:0,...typeof(n==null?void 0:n.positionOffset)=="object"?n.positionOffset:{}}),l=this.props.layer==="bottom"?"bottom":"top";e.cad_component.insert({position:{x:i.center.x+s.x,y:i.center.y+s.y,z:(l==="bottom"?-t/2:t/2)+s.z},rotation:{x:o.x,y:(l==="top"?0:180)+o.y,z:((a==null?void 0:a.rotation)??0)+(l==="bottom"?180:0)+o.z},pcb_component_id:this.pcb_component_id,source_component_id:this.source_component_id,model_stl_url:"stlUrl"in(n??{})?this._addCachebustToModelUrl(n.stlUrl):void 0,model_obj_url:"objUrl"in(n??{})?this._addCachebustToModelUrl(n.objUrl):void 0,model_jscad:"jscad"in(n??{})?n.jscad:void 0,footprinter_string:typeof this.props.footprint=="string"&&!n?this.props.footprint:void 0})}_addCachebustToModelUrl(e){var n;if(!e||!e.includes("modelcdn.tscircuit.com"))return e;const t=((n=this.root)==null?void 0:n.getClientOrigin())??"";return`${e}${e.includes("?")?"&":"?"}cachebust_origin=${encodeURIComponent(t)}`}doInitialPartsEngineRender(){const e=this.getInheritedProperty("partsEngine");if(!e)return;const{db:t}=this.root,n=t.source_component.get(this.source_component_id);if(!n||n.supplier_part_numbers)return;let i;this.props.footprint&&typeof this.props.footprint=="string"&&(i=this.props.footprint);const a=e.findPart({sourceComponent:n,footprinterString:i});if(!(a instanceof Promise)){t.source_component.update(this.source_component_id,{supplier_part_numbers:a});return}this._queueAsyncEffect("get-supplier-part-numbers",async()=>{this._asyncSupplierPartNumbers=await a,this._markDirty("PartsEngineRender")})}updatePartsEngineRender(){const{db:e}=this.root,t=e.source_component.get(this.source_component_id);if(t&&!t.supplier_part_numbers&&this._asyncSupplierPartNumbers){e.source_component.update(this.source_component_id,{supplier_part_numbers:this._asyncSupplierPartNumbers});return}}},PYe=({db:r,traces:e,minTraceWidth:t=.1})=>{const i=$le([...r.pcb_component.list(),...r.pcb_smtpad.list(),...r.pcb_plated_hole.list()]).flatMap(s=>[{x:s.center.x-s.width/2,y:s.center.y-s.height/2},{x:s.center.x+s.width/2,y:s.center.y+s.height/2}]),a={minX:Math.min(...i.map(s=>s.x))-1,maxX:Math.max(...i.map(s=>s.x))+1,minY:Math.min(...i.map(s=>s.y))-1,maxY:Math.max(...i.map(s=>s.y))+1},o=e.map(s=>{const l=s._findConnectedPorts();return!l.allPortsFound||l.ports.length<2?null:{name:s.source_trace_id??"",pointsToConnect:l.ports.map(c=>{const u=c._getGlobalPcbPositionBeforeLayout();return{x:u.x,y:u.y,layer:c.getAvailablePcbLayers()[0]??"top"}})}}).filter(s=>s!==null);return{bounds:a,obstacles:[],connections:o,layerCount:2,minTraceWidth:t}},Tce=class extends R_{constructor(){super(...arguments);ni(this,"matchedPort",null)}get config(){return{componentName:"TraceHint",zodProps:zqe}}doInitialPortMatching(){this.root;const{_parsedProps:e,parent:t}=this;if(!t)return;if(t.componentName==="Trace"){this.renderError(`Port inference inside trace is not yet supported (${this})`);return}if(!t)throw new Error("TraceHint has no parent");if(!e.for){this.renderError(`TraceHint has no for property (${this})`);return}const n=t.selectOne(e.for,{type:"port"});n||this.renderError(`${this} could not find port for selector "${e.for}"`),this.matchedPort=n,n.registerMatch(this)}getPcbRouteHints(){const{_parsedProps:e}=this,t=e.offset?[e.offset]:e.offsets;if(!t)return[];const n=this._computePcbGlobalTransformBeforeLayout();return t.map(i=>({...ui(n,i),via:i.via,to_layer:i.to_layer,trace_width:i.trace_width}))}doInitialPcbTraceHintRender(){var t,n,i;if((t=this.root)!=null&&t.pcbDisabled)return;const{db:e}=this.root;e.pcb_trace_hint.insert({pcb_component_id:(n=this.matchedPort)==null?void 0:n.pcb_component_id,pcb_port_id:(i=this.matchedPort)==null?void 0:i.pcb_port_id,route:this.getPcbRouteHints()})}},qI=class extends Dx{constructor(){super(...arguments);ni(this,"pcb_group_id",null);ni(this,"subcircuit_id",null);ni(this,"_hasStartedAsyncAutorouting",!1);ni(this,"_asyncAutoroutingResult",null)}get config(){return{zodProps:VGe,componentName:"Group"}}doInitialSourceRender(){const{db:t}=this.root,n=t.source_group.insert({name:this._parsedProps.name,is_subcircuit:this.isSubcircuit});this.subcircuit_id=`subcircuit_${n.source_group_id}`,this.source_group_id=n.source_group_id,t.source_group.update(n.source_group_id,{subcircuit_id:this.subcircuit_id})}doInitialSourceParentAttachment(){var i,a,o;const{db:t}=this.root;if(!this.isSubcircuit)return;const n=(o=(a=(i=this.parent)==null?void 0:i.getSubcircuit)==null?void 0:a.call(i))==null?void 0:o.subcircuit_id;n&&t.source_group.update(this.source_group_id,{parent_subcircuit_id:n})}doInitialPcbComponentRender(){var i;if((i=this.root)!=null&&i.pcbDisabled)return;const{db:t}=this.root,n=t.pcb_group.insert({is_subcircuit:this.isSubcircuit,subcircuit_id:this.subcircuit_id,name:this._parsedProps.name,center:this._getGlobalPcbPositionBeforeLayout(),width:0,height:0,pcb_component_ids:[],source_group_id:this.source_group_id});this.pcb_group_id=n.pcb_group_id}doInitialCreateTraceHintsFromProps(){var a;const{_parsedProps:t}=this;this.root;const n=t;if(!this.isSubcircuit)return;const i=(a=n.layout)==null?void 0:a.manual_trace_hints;if(i)for(const o of i)this.add(new Tce({for:o.pcb_port_selector,offsets:o.offsets}))}_getSimpleRouteJsonFromPcbTraces(){const t=this.selectAll("trace"),{db:n}=this.root;return PYe({db:n,traces:t,minTraceWidth:this._parsedProps.minTraceWidth??.1})}doInitialSourceAddConnectivityMapKey(){if(!this.isSubcircuit)return;const{db:t}=this.root,n=this.selectAll("trace"),i=new bA({});i.addConnections(n.map(a=>{const o=t.source_trace.get(a.source_trace_id);return o?[o.source_trace_id,...o.connected_source_port_ids,...o.connected_source_net_ids]:null}).filter(a=>a!==null));for(const a of n){if(!a.source_trace_id)continue;const o=i.getNetConnectedToId(a.source_trace_id);if(!o)continue;const{name:s}=this._parsedProps;a.subcircuit_connectivity_map_key=`${s??`unnamedsubcircuit${this._renderId}`}_${o}`,t.source_trace.update(a.source_trace_id,{subcircuit_connectivity_map_key:a.subcircuit_connectivity_map_key})}}_areChildSubcircuitsRouted(){const t=this.selectAll("group").filter(n=>n.isSubcircuit);for(const n of t)if(n._shouldRouteAsync()&&!n._asyncAutoroutingResult)return!1;return!0}_shouldRouteAsync(){const t=this._getAutorouterConfig();return!(t.local||t.groupMode==="sequential-trace")}_hasTracesToRoute(){const t=g2("tscircuit:core:_hasTracesToRoute"),n=this.selectAll("trace");return t(`[${this.getString()}] has ${n.length} traces to route`),n.length>0}async _runEffectMakeHttpAutoroutingRequest(){var c,u;const t=g2("tscircuit:core:_runEffectMakeHttpAutoroutingRequest");this._parsedProps;const n=this._getAutorouterConfig(),i=n.serverUrl,a=n.serverMode,o=(h,g)=>(t("fetching",h),fetch(h,g)),s=this.root.db.toArray().filter(h=>h.type.startsWith("source_")||h.type.startsWith("pcb_"));if(a==="solve-endpoint"){if(((c=this.props.autorouter)==null?void 0:c.inputFormat)==="simplified"){const{autorouting_result:g}=await o(`${i}/autorouting/solve`,{method:"POST",body:JSON.stringify({input_simple_route_json:this._getSimpleRouteJsonFromPcbTraces(),subcircuit_id:this.subcircuit_id}),headers:{"Content-Type":"application/json"}}).then(_=>_.json());this._asyncAutoroutingResult=g,this._markDirty("PcbTraceRender");return}const{autorouting_result:h}=await o(`${i}/autorouting/solve`,{method:"POST",body:JSON.stringify({input_circuit_json:s,subcircuit_id:this.subcircuit_id}),headers:{"Content-Type":"application/json"}}).then(g=>g.json());this._asyncAutoroutingResult=h,this._markDirty("PcbTraceRender");return}const{autorouting_job:l}=await o(`${i}/autorouting/jobs/create`,{method:"POST",body:JSON.stringify({input_circuit_json:s,provider:"freerouting",autostart:!0,display_name:(u=this.root)==null?void 0:u.name,subcircuit_id:this.subcircuit_id,server_cache_enabled:n.serverCacheEnabled}),headers:{"Content-Type":"application/json"}}).then(h=>h.json());for(;;){const{autorouting_job:h}=await o(`${i}/autorouting/jobs/get`,{method:"POST",body:JSON.stringify({autorouting_job_id:l.autorouting_job_id}),headers:{"Content-Type":"application/json"}}).then(g=>g.json());if(h.is_finished){const{autorouting_job_output:g}=await o(`${i}/autorouting/jobs/get_output`,{method:"POST",body:JSON.stringify({autorouting_job_id:l.autorouting_job_id}),headers:{"Content-Type":"application/json"}}).then(_=>_.json());this._asyncAutoroutingResult={output_pcb_traces:g.output_pcb_traces},this._markDirty("PcbTraceRender");break}if(h.has_error)throw new Error(`Autorouting job failed: ${JSON.stringify(h.error)}`);await new Promise(g=>setTimeout(g,100))}}_startAsyncAutorouting(){this._hasStartedAsyncAutorouting=!0,this._queueAsyncEffect("make-http-autorouting-request",async()=>this._runEffectMakeHttpAutoroutingRequest())}doInitialPcbTraceRender(){var n;const t=g2("tscircuit:core:doInitialPcbTraceRender");if(this.isSubcircuit&&!((n=this.root)!=null&&n.pcbDisabled)&&!this.getInheritedProperty("routingDisabled")&&!this._shouldUseTraceByTraceRouting()){if(!this._areChildSubcircuitsRouted()){t(`[${this.getString()}] child subcircuits are not routed, skipping async autorouting until subcircuits routed`);return}t(`[${this.getString()}] no child subcircuits to wait for, initiating async routing`),this._hasTracesToRoute()&&this._startAsyncAutorouting()}}updatePcbTraceRender(){const t=g2("tscircuit:core:updatePcbTraceRender");if(this.isSubcircuit){if(this._shouldRouteAsync()&&this._hasTracesToRoute()&&!this._hasStartedAsyncAutorouting){this._areChildSubcircuitsRouted()&&(t(`[${this.getString()}] child subcircuits are now routed, starting async autorouting`),this._startAsyncAutorouting());return}if(this._asyncAutoroutingResult&&!this._shouldUseTraceByTraceRouting()){if(this.root,this._asyncAutoroutingResult.output_simple_route_json){this._updatePcbTraceRenderFromSimpleRouteJson();return}if(this._asyncAutoroutingResult.output_pcb_traces){this._updatePcbTraceRenderFromPcbTraces();return}}}}_updatePcbTraceRenderFromSimpleRouteJson(){const{db:t}=this.root,{traces:n}=this._asyncAutoroutingResult.output_simple_route_json;if(n){this.selectAll("trace");for(const i of n)t.pcb_trace.insert({route:i.route})}}_updatePcbTraceRenderFromPcbTraces(){const{output_pcb_traces:t}=this._asyncAutoroutingResult;if(!t)return;const{db:n}=this.root;for(const i of t)n.pcb_trace.insert(i)}doInitialSchematicLayout(){if(!this.isSubcircuit||!this._parsedProps.schAutoLayoutEnabled)return;const{db:n}=this.root,i=this.getDescendants(),a=[];for(const l of i)if("schematic_component_id"in l){const c=n.schematic_component.get(l.schematic_component_id);if(c){const u=n.schematic_port.list().filter(h=>h.schematic_component_id===c.schematic_component_id);a.push(...u)}}const o=Zqe(n.toArray()),s=aYe(o);$qe(n.toArray(),s)}_getAutorouterConfig(){const t={serverUrl:"https://registry-api.tscircuit.com",serverMode:"job",serverCacheEnabled:!1},n=this._parsedProps.autorouter??this.getInheritedProperty("autorouter");return typeof n=="object"?{local:!(n.serverUrl||n.serverMode||n.serverCacheEnabled),...t,...n}:n==="auto-local"?{local:!0}:n==="sequential-trace"?{local:!0,groupMode:"sequential-trace"}:{local:!0,groupMode:"sequential-trace"}}_shouldUseTraceByTraceRouting(){return this._getAutorouterConfig().groupMode==="sequential-trace"}},NYe=class extends qI{constructor(){super(...arguments);ni(this,"pcb_board_id",null)}get isSubcircuit(){return!0}get config(){return{componentName:"Board",zodProps:jGe}}get boardThickness(){return 1.4}get allLayers(){return["top","bottom","inner1","inner2"]}doInitialPcbComponentRender(){var o,s;if((o=this.root)!=null&&o.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this;if(!t.outline&&(!t.width||!t.height))throw new Error("Board width and height or an outline are required");let n=t.width,i=t.height;if(t.outline){const l=t.outline.map(b=>b.x),c=t.outline.map(b=>b.y),u=Math.min(...l),h=Math.max(...l),g=Math.min(...c),_=Math.max(...c);n=h-u,i=_-g}const a=e.pcb_board.insert({center:{x:(t.pcbX??0)+(t.outlineOffsetX??0),y:(t.pcbY??0)+(t.outlineOffsetY??0)},thickness:this.boardThickness,num_layers:this.allLayers.length,width:n,height:i,outline:(s=t.outline)==null?void 0:s.map(l=>({x:l.x+(t.outlineOffsetX??0),y:l.y+(t.outlineOffsetY??0)}))});this.pcb_board_id=a.pcb_board_id}removePcbComponentRender(){const{db:e}=this.root;this.pcb_board_id&&(e.pcb_board.delete(this.pcb_board_id),this.pcb_board_id=null)}_computePcbGlobalTransformBeforeLayout(){return C_()}},LYe=new Proxy({},{get:(r,e)=>e}),bT=LYe,Mce=class{constructor({input:r}){ni(this,"input");this.input=r}solveAndMapToTraces(){const r=[];for(const e of this.input.connections){if(e.pointsToConnect.length!==2)continue;const[t,n]=e.pointsToConnect,i={type:"pcb_trace",pcb_trace_id:"",route:[{route_type:"wire",x:t.x,y:t.y,layer:"top",width:.1},{route_type:"wire",x:n.x,y:n.y,layer:"top",width:.1}]};r.push(i)}return r}},OYe=r=>{const e=Math.min(...r.map(a=>a.center.x)),t=Math.max(...r.map(a=>a.center.x)),n=Math.min(...r.map(a=>a.center.y)),i=Math.max(...r.map(a=>a.center.y));return{minX:e,maxX:t,minY:n,maxY:i}},Cce=["top","bottom","inner1","inner2"],LA=(r,e=[])=>{var s;const t=[];if(e.length===0){const l=r[0].layers;for(const c of l)t.push(...LA(r.slice(1),[c]));return t}if(r.length===0)return[];const n=r[0],i=n.via||n.optional_via,a=e[e.length-1];if(r.length===1){const l=n;return l.layers&&i?l.layers.map(c=>({layer_path:[...e,c]})):(s=l.layers)!=null&&s.includes(a)?[{layer_path:[...e,a]}]:[]}if(!i)return n.layers&&!n.layers.includes(a)?[]:LA(r.slice(1),e.concat([a]));const o=(n.optional_via?Cce:Cce.filter(l=>l!==a)).filter(l=>{var c;return!n.layers||((c=n.layers)==null?void 0:c.includes(l))});for(const l of o)t.push(...LA(r.slice(1),e.concat(l)));return t};function Rce(r){const e={x:r.to.x-r.from.x,y:r.to.y-r.from.y},t=Math.abs(e.x),n=Math.abs(e.y);return t>n?e.x>0?"right":"left":e.y>0?"down":"up"}function B8(r,e){return Math.hypot(r.x-e.x,r.y-e.y)}var UYe=r=>{if(r.length===1)return r[0];if(r.some(l=>l.length===0))throw new Error("Cannot merge routes with zero length");const e=[],t=r[0][0],n=r[0][r[0].length-1],i=r[1][0],a=r[1][r[1].length-1],o=Math.min(B8(t,i),B8(t,a)),s=Math.min(B8(n,i),B8(n,a));o<s?e.push(...r[0].reverse()):e.push(...r[0]);for(let l=1;l<r.length;l++){const c=e[e.length-1],u=r[l],h=u[0],g=u[u.length-1],_=B8(c,h),b=B8(c,g);_<b?e.push(...u):e.push(...u.reverse())}for(let l=1;l<e.length-1;l++){const c=e[l-1],u=e[l];c.route_type==="wire"&&u.route_type==="wire"&&c.layer!==u.layer&&e.splice(l,0,{x:c.x,y:c.y,from_layer:c.layer,to_layer:u.layer,route_type:"via"})}return e},zYe=(r,e)=>{const t="_getGlobalPcbPositionBeforeLayout"in r?r._getGlobalPcbPositionBeforeLayout():r,n="_getGlobalPcbPositionBeforeLayout"in e?e._getGlobalPcbPositionBeforeLayout():e;return Math.sqrt((t.x-n.x)**2+(t.y-n.y)**2)};function FYe(r,e){if(e.length===0)throw new Error("No candidates given to getClosest method");let t=e[0],n=1/0;for(const i of e){const a=zYe(r,i);a<n&&(t=i,n=a)}return t}var IYe=(r,e)=>{let t=0;t+=r.length??0,t+=e.filter(n=>n.is_crossing).length;for(let n=1;n<e.length;n++){const i=e[n-1],a=e[n],o=Math.abs(i.from.x-i.to.x)<.01,s=Math.abs(a.from.x-a.to.x)<.01;o!==s&&t++}return t},YI=r=>({up:"bottom",down:"top",left:"right",right:"left"})[r]??null,XI=({firstEdge:r,firstEdgePort:e,firstDominantDirection:t,lastEdge:n,lastEdgePort:i,lastDominantDirection:a})=>{if(r&&e)return XI({lastEdge:{from:r.to,to:r.from},lastEdgePort:e,lastDominantDirection:t}).reverse().map(s=>({from:s.to,to:s.from}));let o=[];if(n&&i){const s={x:n.to.x,y:n.to.y};a==="left"||a==="right"?(s.x=i.position.x,o.push({from:n.to,to:{...s}}),o.push({from:s,to:{...i.position}})):(s.y=i.position.y,o.push({from:n.to,to:{...s}}),o.push({from:s,to:{...i.position}}))}return o=o.filter(s=>yT(s.from,s.to)>.01),o};function kYe(r){try{return[r(),null]}catch(e){return[null,e]}}function BYe(r){let e=0;for(let t=0;t<r.length;t++){const n=r[t];if(n.route_type==="wire"){const i=r[t+1];if(i){const a=i.x-n.x,o=i.y-n.y;e+=Math.sqrt(a*a+o*o)}}else n.route_type==="via"&&(e+=1.6)}return e}var HYe=r=>{var s,l;const e={left:{x:-.5,y:0},up:{x:.5,y:.5},right:{x:.5,y:0},down:{x:0,y:-.5}}[r.facingDirection],t=(s=r.parent)!=null&&s.config.shouldRenderAsSchematicBox?3:1,n=(l=r.parent)!=null&&l.config.shouldRenderAsSchematicBox&&(r.facingDirection==="left"||r.facingDirection==="right")?3:1,i=e.x,a=e.y,o=r.facingDirection==="up"?.5:0;return{schBoxVertOffset:t,schBoxHorzOffset:n,horzPortDirection:i,vertPortDirectionOffset:a,handleUp:o}},OA=({port:r,anchorPos:e,schDisplayLabel:t,source_trace_id:n},{db:i})=>{const a=HYe(r);i.schematic_net_label.insert({anchor_side:"top",center:{x:e.x+a.horzPortDirection*a.schBoxHorzOffset,y:e.y+a.vertPortDirectionOffset*a.schBoxVertOffset},source_net_id:r.source_port_id,text:t,anchor_position:{x:e.x+a.horzPortDirection*a.schBoxHorzOffset,y:e.y+a.vertPortDirectionOffset*a.schBoxVertOffset},symbol_name:"ground_horz"}),i.schematic_trace.insert({edges:[{from:{x:e.x,y:e.y},to:{x:e.x,y:e.y+a.handleUp*a.schBoxVertOffset}},{from:{x:e.x,y:e.y},to:{x:e.x+a.horzPortDirection*a.schBoxHorzOffset,y:e.y+a.vertPortDirectionOffset*a.schBoxVertOffset}}],junctions:[{x:e.x+a.horzPortDirection*a.schBoxHorzOffset,y:e.y+a.vertPortDirectionOffset*a.schBoxVertOffset}],source_trace_id:n})},WI=({db:r,source_trace_id:e,sameNetOnly:t,differentNetOnly:n})=>{!t&&!n&&(n=!0);const i=r.source_trace.get(e),a=[];for(const o of r.schematic_trace.list()){if(o.source_trace_id===e)continue;const s=r.source_trace.get(o.source_trace_id),l=(s==null?void 0:s.subcircuit_connectivity_map_key)===i.subcircuit_connectivity_map_key;n&&l||t&&!l||a.push(o)}return a},VYe=({edges:r,otherEdges:e})=>{const t=[...r];for(let n=0;n<t.length;n++){if(n>2e3)throw new Error("Over 2000 iterations spent inside createSchematicTraceCrossingSegments, you have triggered an infinite loop, please report this!");const i=t[n],a=Math.abs(i.from.x-i.to.x)<.01?"vertical":i.from.y===i.to.y?"horizontal":"not-orthogonal";if(a==="not-orthogonal")continue;const o=[];for(const T of e){const C=T.from.x===T.to.x?"vertical":T.from.y===T.to.y?"horizontal":"not-orthogonal";if(C==="not-orthogonal"||a===C)continue;if(cce([i.from,i.to],[T.from,T.to],{lineThickness:.01})){const L=a==="vertical"?i.from.x:T.from.x,U=a==="vertical"?T.from.y:i.from.y,j={x:L,y:U};o.push({otherEdge:T,crossingPoint:j,distanceFromEdgeFrom:yT(i.from,j)})}}if(o.length===0)continue;let s=o[0];for(const T of o)T.distanceFromEdgeFrom<s.distanceFromEdgeFrom&&(s=T);const l=s.crossingPoint,c=.075;if(l.x===i.from.x&&l.y===i.from.y)continue;const u=oYe(i.from,l),h={x:l.x-u.x*c/2,y:l.y-u.y*c/2},g={x:l.x+u.x*c/2,y:l.y+u.y*c/2},_=yT(g,i.to)<c,b=[{from:i.from,to:h},{from:h,to:g,is_crossing:!0},{from:g,to:i.to}];t.splice(n,1,...b),n+=b.length-2,_&&n++}return t},jYe=(r,e)=>{if(r.from.x===r.to.x&&e.from.x===e.to.x)return null;if(r.from.x===r.to.x){const u=r.from.x,h=(e.to.y-e.from.y)/(e.to.x-e.from.x),g=e.from.y-h*e.from.x,_=h*u+g;return u>=Math.min(e.from.x,e.to.x)&&u<=Math.max(e.from.x,e.to.x)&&_>=Math.min(e.from.y,e.to.y)&&_<=Math.max(e.from.y,e.to.y)?{x:u,y:_}:null}if(e.from.x===e.to.x){const u=e.from.x,h=(r.to.y-r.from.y)/(r.to.x-r.from.x),g=r.from.y-h*r.from.x,_=h*u+g;return u>=Math.min(r.from.x,r.to.x)&&u<=Math.max(r.from.x,r.to.x)&&_>=Math.min(r.from.y,r.to.y)&&_<=Math.max(r.from.y,r.to.y)?{x:u,y:_}:null}const t=(r.to.y-r.from.y)/(r.to.x-r.from.x),n=r.from.y-t*r.from.x,i=(e.to.y-e.from.y)/(e.to.x-e.from.x),a=e.from.y-i*e.from.x;if(t===i)return null;const o=(a-n)/(t-i),s=t*o+n,l=o>=Math.min(r.from.x,r.to.x)&&o<=Math.max(r.from.x,r.to.x)&&s>=Math.min(r.from.y,r.to.y)&&s<=Math.max(r.from.y,r.to.y),c=o>=Math.min(e.from.x,e.to.x)&&o<=Math.max(e.from.x,e.to.x)&&s>=Math.min(e.from.y,e.to.y)&&s<=Math.max(e.from.y,e.to.y);return l&&c?{x:o,y:s}:null},GYe=({edges:r,db:e,source_trace_id:t})=>{const n=WI({db:e,source_trace_id:t,sameNetOnly:!0}).flatMap(i=>i.edges);for(const i of r)for(const a of n){const o=jYe(i,a);if(o)return`${o.x}${o.y}`,[{x:o.x,y:o.y}]}return[]},qYe=(r,{db:e})=>{const t=r.map(n=>{const i=e.source_port.get(n.source_port_id);if(!(i!=null&&i.source_component_id))return null;const a=e.source_component.get(i.source_component_id);return(a==null?void 0:a.ftype)==="simple_capacitor"?a.max_decoupling_trace_length:null}).filter(n=>n!==null);if(t.length!==0)return Math.min(...t)},YYe=r=>{var a;const e=r.root.db,t=r._findConnectedPorts().ports??[],n=new Set(t.map(o=>o.schematic_port_id)),i=[];for(const o of e.toArray()){if(o.type==="schematic_component"){const s=!!o.symbol_name,l=o.size.width>o.size.height?"horz":"vert";i.push({type:"rect",layers:["top"],center:o.center,width:o.size.width+(s&&l==="horz"?-.5:0),height:o.size.height+(s&&l==="vert"?-.5:0),connectedTo:[]})}if(o.type==="schematic_port"){if(n.has(o.schematic_port_id))continue;const s=o.facing_direction?sYe(o.facing_direction):{x:0,y:0};i.push({type:"rect",layers:["top"],center:{x:o.center.x-s.x*.1,y:o.center.y-s.y*.1},width:.1+Math.abs(s.x)*.3,height:.1+Math.abs(s.y)*.3,connectedTo:[]})}o.type==="schematic_text"&&i.push({type:"rect",layers:["top"],center:o.position,width:(((a=o.text)==null?void 0:a.length)??0)*.1,height:.2,connectedTo:[]}),o.type==="schematic_box"&&i.push({type:"rect",layers:["top"],center:{x:o.x,y:o.y},width:o.width,height:o.height,connectedTo:[]})}return i};function XYe({ports:r,nets:e}){var t,n,i;if(r.length>=2)return`${(t=r[0])==null?void 0:t.selector} to ${(n=r[1])==null?void 0:n.selector}`;if(r.length===1&&e.length===1)return`${(i=r[0])==null?void 0:i.selector} to net.${e[0]._parsedProps.name}`}var WYe=({edges:r,db:e,source_trace_id:t})=>{e.source_trace.get(t);const n=WI({db:e,source_trace_id:t,differentNetOnly:!0}).flatMap(a=>a.edges),i=a=>{const{from:o,to:s}=a;return o.x===s.x?"vertical":"horizontal"};for(const a of r){const o=i(a),s=()=>n.find(c=>i(c)===o&&cce([a.from,a.to],[c.from,c.to],{lineThickness:.05}));let l=s();for(;l;)o==="horizontal"?(a.from.y+=.1,a.to.y+=.1):(a.from.x+=.1,a.to.x+=.1),l=s()}},UA=r=>({...r._getGlobalPcbPositionAfterLayout(),layers:r.getAvailablePcbLayers()}),qS=class extends R_{constructor(e){super(e);ni(this,"source_trace_id",null);ni(this,"pcb_trace_id",null);ni(this,"schematic_trace_id",null);ni(this,"_portsRoutedOnPcb");ni(this,"subcircuit_connectivity_map_key",null);this._portsRoutedOnPcb=[]}get config(){return{zodProps:hqe,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(){this.root;const{_parsedProps:e,parent:t}=this;if(!t)throw new Error("Trace has no parent");const i=this.getTracePortPathSelectors().map(a=>({selector:a,port:this.getSubcircuit().selectOne(a,{type:"port"})??null}));for(const{selector:a,port:o}of i)if(!o){const s=a.replace(/\>.*$/,""),l=this.getSubcircuit().selectOne(s);l?this.renderError(`Could not find port for selector "${a}" (did you forget to include the pin name?)
|
|
641
|
+
iteration: ${o}`),_T(`part: "${t[o]}"`),_T(`currentSearch: [${n.map(l=>l.getString()).join(",")}]`),_T(`currentResults: [${i.map(l=>l.getString()).join(",")}]`),s===">")a=!0;else{const l=n.filter(u=>VI(u,s));n=l.flatMap(u=>a?u.children:u.getSelectableDescendants()),i=l,a=!1}return i}selectOne(e,t){var i;let n=(i=t==null?void 0:t.type)==null?void 0:i.toLowerCase();return t!=null&&t.port&&(n="port"),n?this.selectAll(e).find(a=>a.lowercaseComponentName===n)??null:t!=null&&t.pcbPrimitive?this.selectAll(e).find(a=>a.isPcbPrimitive)??null:t!=null&&t.schematicPrimitive?this.selectAll(e).find(a=>a.isSchematicPrimitive)??null:this.selectAll(e)[0]??null}getAvailablePcbLayers(){var e,t;if(this.isPcbPrimitive){const{maybeFlipLayer:n}=this._getPcbPrimitiveFlippedHelpers();return"layer"in this._parsedProps||this.componentName==="SmtPad"?[n(this._parsedProps.layer??"top")]:"layers"in this._parsedProps?this._parsedProps.layers:this.componentName==="PlatedHole"?((t=(e=this.root)==null?void 0:e._getBoard())==null?void 0:t.allLayers)??["top","bottom"]:[]}return[]}getDescendants(){const e=[];for(const t of this.children)e.push(t),e.push(...t.getDescendants());return e}getSelectableDescendants(){const e=[];for(const t of this.children)t.isSubcircuit?e.push(t):(e.push(t),e.push(...t.getSelectableDescendants()));return e}_getPinCount(){return 0}_getSchematicBoxDimensions(){return null}renderError(e){var t;if(typeof e=="string")return super.renderError(e);(t=this.root)==null||t.db.pcb_placement_error.insert(e)}getString(){var i,a;const{lowercaseComponentName:e,_parsedProps:t,parent:n}=this;return(t==null?void 0:t.pinNumber)!==void 0&&((i=n==null?void 0:n.props)!=null&&i.name)&&(t!=null&&t.name)?`<${e}#${this._renderId}(pin:${t.pinNumber} .${n==null?void 0:n.props.name}>.${t.name}) />`:(a=n==null?void 0:n.props)!=null&&a.name&&(t!=null&&t.name)?`<${e}#${this._renderId}(.${n==null?void 0:n.props.name}>.${t==null?void 0:t.name}) />`:t!=null&&t.from&&(t!=null&&t.to)?`<${e}#${this._renderId}(from:${t.from} to:${t==null?void 0:t.to}) />`:t!=null&&t.name?`<${e}#${this._renderId} name=".${t==null?void 0:t.name}" />`:t!=null&&t.portHints?`<${e}#${this._renderId}(${t.portHints.map(o=>`.${o}`).join(", ")}) />`:`<${e}#${this._renderId} />`}get[Symbol.toStringTag](){return this.getString()}[Symbol.for("nodejs.util.inspect.custom")](){return this.getString()}};function vce(r){const e=[];for(let t=0;t<r.length-1;t++)e.push([r[t],r[t+1]]);return e}var yYe=ue.object({name:ue.string()}),yce=class extends R_{constructor(){super(...arguments);ni(this,"source_net_id")}get config(){return{componentName:"Net",zodProps:yYe}}getPortSelector(){return`net.${this.props.name}`}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_net.insert({name:t.name,member_source_group_ids:[]});this.source_net_id=n.source_net_id}getAllConnectedPorts(){const e=this.getSubcircuit().selectAll("port"),t=[];for(const n of e){const i=n._getDirectlyConnectedTraces();for(const a of i)if(a._isExplicitlyConnectedToNet(this)){t.push(n);break}}return t}_getAllDirectlyConnectedTraces(){const e=this.getSubcircuit().selectAll("trace"),t=[];for(const n of e)n._isExplicitlyConnectedToNet(this)&&t.push(n);return t}doInitialPcbRouteNetIslands(){var a;if((a=this.root)!=null&&a.pcbDisabled||this.getSubcircuit()._parsedProps.routingDisabled)return;const{db:e}=this.root,t=this._getAllDirectlyConnectedTraces().filter(o=>{var s;return(((s=o._portsRoutedOnPcb)==null?void 0:s.length)??0)>0}),n=[];for(const o of t){const s=o._portsRoutedOnPcb,l=n.find(c=>s.some(u=>c.ports.includes(u)));if(!l){n.push({ports:[...s],traces:[o]});continue}l.traces.push(o),l.ports.push(...s)}if(n.length===0)return;const i=vce(n);for(const[o,s]of i){const l=o.ports.map(A=>A._getGlobalPcbPositionBeforeLayout()),c=s.ports.map(A=>A._getGlobalPcbPositionBeforeLayout());let u=1/0,h=[-1,-1];for(let A=0;A<l.length;A++){const L=l[A];for(let U=0;U<c.length;U++){const j=c[U],Z=Math.sqrt((L.x-j.x)**2+(L.y-j.y)**2);Z<u&&(u=Z,h=[A,U])}}const g=o.ports[h[0]],_=s.ports[h[1]],b=e.toArray().filter(A=>A.type==="pcb_smtpad"||A.type==="pcb_trace"||A.type==="pcb_plated_hole"||A.type==="pcb_hole"||A.type==="source_port"||A.type==="pcb_port"),{solution:T}=wGe(b.concat([{type:"source_trace",source_trace_id:"__net_trace_tmp",connected_source_port_ids:[g.source_port_id,_.source_port_id]}])),C=T[0];if(!C){this.renderError({pcb_trace_error_id:"",pcb_trace_id:"__net_trace_tmp",pcb_component_ids:[g.pcb_component_id,_.pcb_component_id].filter(Boolean),pcb_port_ids:[g.pcb_port_id,_.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(C)}}renderError(e){var t;if(typeof e=="string")return super.renderError(e);(t=this.root)==null||t.db.pcb_trace_error.insert(e)}},gce=(r,e)=>{for(const t of e)typeof t=="string"&&t.startsWith("net.")&&(r.getSubcircuit().selectOne(t)||r.getSubcircuit().add(new yce({name:t.split("net.")[1]})))},jI=class extends R_{constructor(){super(...arguments);ni(this,"pcb_smtpad_id",null);ni(this,"matchedPort",null);ni(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SmtPad",zodProps:cqe}}getPcbSize(){const{_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};throw new Error(`getPcbSize for shape "${e.shape}" not implemented for ${this.componentName}`)}doInitialPortMatching(){var t;const e=(t=this.getPrimitiveContainer())==null?void 0:t.selectAll("port");if(this.props.portHints){for(const n of e)if(n.isMatchingAnyOf(this.props.portHints)){this.matchedPort=n,n.registerMatch(this);return}}}doInitialPcbPrimitiveRender(){var g,_,b,T,C,A,L,U,j;if((g=this.root)!=null&&g.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this;if(!t.portHints)return;const n=this.getPrimitiveContainer(),i=this.getSubcircuit(),a=this._getGlobalPcbPositionBeforeLayout();n==null||n._getGlobalPcbPositionBeforeLayout();const o=gF(this._computePcbGlobalTransformBeforeLayout()),s=Math.abs(o.rotation.angle*(180/Math.PI)-90)%180<.01,{maybeFlipLayer:l}=this._getPcbPrimitiveFlippedHelpers(),c=(n==null?void 0:n._parsedProps.pcbRotation)??0;let u=null;const h=((_=this.parent)==null?void 0:_.pcb_component_id)??((b=this.getPrimitiveContainer())==null?void 0:b.pcb_component_id);t.shape==="circle"?(u=e.pcb_smtpad.insert({pcb_component_id:h,pcb_port_id:(T=this.matchedPort)==null?void 0:T.pcb_port_id,layer:l(t.layer??"top"),shape:"circle",radius:t.radius,port_hints:t.portHints.map(Z=>Z.toString()),x:a.x,y:a.y,subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0}),e.pcb_solder_paste.insert({layer:u.layer,shape:"circle",radius:u.radius*.7,x:u.x,y:u.y,pcb_component_id:u.pcb_component_id,pcb_smtpad_id:u.pcb_smtpad_id,subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0,pcb_group_id:((C=this.getGroup())==null?void 0:C.pcb_group_id)??void 0})):t.shape==="rect"&&(u=c===0||s?e.pcb_smtpad.insert({pcb_component_id:h,pcb_port_id:(A=this.matchedPort)==null?void 0:A.pcb_port_id,layer:l(t.layer??"top"),shape:"rect",width:s?t.height:t.width,height:s?t.width:t.height,port_hints:t.portHints.map(Z=>Z.toString()),x:a.x,y:a.y,subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0,pcb_group_id:((L=this.getGroup())==null?void 0:L.pcb_group_id)??void 0}):e.pcb_smtpad.insert({pcb_component_id:h,layer:t.layer??"top",shape:"rotated_rect",width:t.width,height:t.height,x:a.x,y:a.y,ccw_rotation:c,port_hints:t.portHints.map(Z=>Z.toString()),subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0,pcb_group_id:((U=this.getGroup())==null?void 0:U.pcb_group_id)??void 0}),u.shape==="rect"&&e.pcb_solder_paste.insert({layer:u.layer,shape:"rect",width:u.width*.7,height:u.height*.7,x:u.x,y:u.y,pcb_component_id:u.pcb_component_id,pcb_smtpad_id:u.pcb_smtpad_id,subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0,pcb_group_id:((j=this.getGroup())==null?void 0:j.pcb_group_id)??void 0})),u&&(this.pcb_smtpad_id=u.pcb_smtpad_id)}doInitialPcbPortAttachment(){var t,n;if((t=this.root)!=null&&t.pcbDisabled)return;const{db:e}=this.root;e.pcb_smtpad.update(this.pcb_smtpad_id,{pcb_port_id:(n=this.matchedPort)==null?void 0:n.pcb_port_id})}_getPcbCircuitJsonBounds(){const{db:e}=this.root,t=e.pcb_smtpad.get(this.pcb_smtpad_id);if(t.shape==="rect")return{center:{x:t.x,y:t.y},bounds:{left:t.x-t.width/2,top:t.y+t.height/2,right:t.x+t.width/2,bottom:t.y-t.height/2},width:t.width,height:t.height};if(t.shape==="rotated_rect"){const n=t.ccw_rotation*Math.PI/180,i=Math.cos(n),a=Math.sin(n),o=t.width/2,s=t.height/2,l=Math.abs(o*i)+Math.abs(s*a),c=Math.abs(o*a)+Math.abs(s*i);return{center:{x:t.x,y:t.y},bounds:{left:t.x-l,right:t.x+l,top:t.y-c,bottom:t.y+c},width:l*2,height:c*2}}if(t.shape==="circle")return{center:{x:t.x,y:t.y},bounds:{left:t.x-t.radius,top:t.y-t.radius,right:t.x+t.radius,bottom:t.y+t.radius},width:t.radius*2,height:t.radius*2};throw new Error(`circuitJson bounds calculation not implemented for shape "${t.shape}"`)}_setPositionFromLayout(e){var i;const{db:t}=this.root;t.pcb_smtpad.update(this.pcb_smtpad_id,{x:e.x,y:e.y});const n=t.pcb_solder_paste.list().find(a=>a.pcb_smtpad_id===this.pcb_smtpad_id);t.pcb_solder_paste.update(n==null?void 0:n.pcb_solder_paste_id,{x:e.x,y:e.y}),(i=this.matchedPort)==null||i._setPositionFromLayout(e)}},_ce=class extends R_{constructor(){super(...arguments);ni(this,"pcb_silkscreen_path_id",null)}get config(){return{componentName:"SilkscreenPath",zodProps:Nqe}}doInitialPcbPrimitiveRender(){var s,l,c;if((s=this.root)!=null&&s.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=t.layer??"top";if(n!=="top"&&n!=="bottom")throw new Error(`Invalid layer "${n}" for SilkscreenPath. Must be "top" or "bottom".`);const i=this._computePcbGlobalTransformBeforeLayout(),a=this.getSubcircuit(),o=e.pcb_silkscreen_path.insert({pcb_component_id:(l=this.parent)==null?void 0:l.pcb_component_id,layer:n,route:t.route.map(u=>{const h=ui(i,{x:u.x,y:u.y});return{...u,x:h.x,y:h.y}}),stroke_width:t.strokeWidth??.1,subcircuit_id:(a==null?void 0:a.subcircuit_id)??void 0,pcb_group_id:((c=this.getGroup())==null?void 0:c.pcb_group_id)??void 0});this.pcb_silkscreen_path_id=o.pcb_silkscreen_path_id}},xce=class extends R_{constructor(){super(...arguments);ni(this,"pcb_plated_hole_id",null);ni(this,"matchedPort",null);ni(this,"isPcbPrimitive",!0)}get config(){return{componentName:"PlatedHole",zodProps:WGe}}getAvailablePcbLayers(){return["top","inner1","inner2","bottom"]}getPcbSize(){const{_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};throw new Error(`getPcbSize for shape "${e.shape}" not implemented for ${this.componentName}`)}_getPcbCircuitJsonBounds(){const{db:e}=this.root,t=e.pcb_plated_hole.get(this.pcb_plated_hole_id),n=this.getPcbSize();return{center:{x:t.x,y:t.y},bounds:{left:t.x-n.width/2,top:t.y+n.height/2,right:t.x+n.width/2,bottom:t.y-n.height/2},width:n.width,height:n.height}}_setPositionFromLayout(e){var n;const{db:t}=this.root;t.pcb_plated_hole.update(this.pcb_plated_hole_id,{x:e.x,y:e.y}),(n=this.matchedPort)==null||n._setPositionFromLayout(e)}doInitialPortMatching(){var t;const e=(t=this.getPrimitiveContainer())==null?void 0:t.selectAll("port");if(this.props.portHints){for(const n of e)if(n.isMatchingAnyOf(this.props.portHints)){this.matchedPort=n,n.registerMatch(this);return}}}doInitialPcbPrimitiveRender(){var o,s,l,c,u,h,g;if((o=this.root)!=null&&o.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this._getGlobalPcbPositionBeforeLayout(),i=((s=this.parent)==null?void 0:s.pcb_component_id)??((l=this.getPrimitiveContainer())==null?void 0:l.pcb_component_id),a=this.getSubcircuit();if(t.shape==="circle"){const _=e.pcb_plated_hole.insert({pcb_component_id:i,pcb_port_id:(c=this.matchedPort)==null?void 0:c.pcb_port_id,outer_diameter:t.outerDiameter,hole_diameter:t.holeDiameter,shape:"circle",port_hints:this.getNameAndAliases(),x:n.x,y:n.y,layers:["top","bottom"],subcircuit_id:(a==null?void 0:a.subcircuit_id)??void 0,pcb_group_id:((u=this.getGroup())==null?void 0:u.pcb_group_id)??void 0});this.pcb_plated_hole_id=_.pcb_plated_hole_id}else if(t.shape==="pill"||t.shape==="oval"){const _=e.pcb_plated_hole.insert({pcb_component_id:i,pcb_port_id:(h=this.matchedPort)==null?void 0:h.pcb_port_id,outer_width:t.outerWidth,outer_height:t.outerHeight,hole_width:t.innerWidth,hole_height:t.innerHeight,shape:t.shape,port_hints:this.getNameAndAliases(),x:n.x,y:n.y,layers:["top","bottom"],subcircuit_id:(a==null?void 0:a.subcircuit_id)??void 0,pcb_group_id:((g=this.getGroup())==null?void 0:g.pcb_group_id)??void 0});this.pcb_plated_hole_id=_.pcb_plated_hole_id}}doInitialPcbPortAttachment(){var t,n;if((t=this.root)!=null&&t.pcbDisabled)return;const{db:e}=this.root;e.pcb_plated_hole.update(this.pcb_plated_hole_id,{pcb_port_id:(n=this.matchedPort)==null?void 0:n.pcb_port_id})}},GI=class extends R_{constructor(){super(...arguments);ni(this,"pcb_keepout_id",null);ni(this,"isPcbPrimitive",!0)}get config(){return{componentName:"Keepout",zodProps:Aqe}}doInitialPcbPrimitiveRender(){var l,c,u;if((l=this.root)!=null&&l.pcbDisabled)return;const e=this.getSubcircuit(),{db:t}=this.root,{_parsedProps:n}=this,i=this._getGlobalPcbPositionBeforeLayout(),a=gF(this._computePcbGlobalTransformBeforeLayout()),o=Math.abs(a.rotation.angle*(180/Math.PI)-90)%180<.01;let s=null;n.shape==="circle"?s=t.pcb_keepout.insert({layers:["top"],shape:"circle",radius:n.radius,center:{x:i.x,y:i.y},subcircuit_id:(e==null?void 0:e.subcircuit_id)??void 0,pcb_group_id:((c=e==null?void 0:e.getGroup())==null?void 0:c.pcb_group_id)??void 0}):n.shape==="rect"&&(s=t.pcb_keepout.insert({layers:["top"],shape:"rect",...o?{width:n.height,height:n.width}:{width:n.width,height:n.height},center:{x:i.x,y:i.y},subcircuit_id:(e==null?void 0:e.subcircuit_id)??void 0,pcb_group_id:((u=e==null?void 0:e.getGroup())==null?void 0:u.pcb_group_id)??void 0})),s&&(this.pcb_keepout_id=s.pcb_keepout_id)}},bce=class extends R_{constructor(){super(...arguments);ni(this,"pcb_hole_id",null);ni(this,"isPcbPrimitive",!0)}get config(){return{componentName:"Hole",zodProps:dqe}}getPcbSize(){const{_parsedProps:e}=this;return{width:e.diameter,height:e.diameter}}doInitialPcbPrimitiveRender(){var o,s;if((o=this.root)!=null&&o.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this.getSubcircuit(),i=this._getGlobalPcbPositionBeforeLayout(),a=e.pcb_hole.insert({hole_shape:"circle",hole_diameter:t.diameter,x:i.x,y:i.y,subcircuit_id:(n==null?void 0:n.subcircuit_id)??void 0,pcb_group_id:((s=n==null?void 0:n.getGroup())==null?void 0:s.pcb_group_id)??void 0});this.pcb_hole_id=a.pcb_hole_id}_getPcbCircuitJsonBounds(){const{db:e}=this.root,t=e.pcb_hole.get(this.pcb_hole_id),n=this.getPcbSize();return{center:{x:t.x,y:t.y},bounds:{left:t.x-n.width/2,top:t.y-n.height/2,right:t.x+n.width/2,bottom:t.y+n.height/2},width:n.width,height:n.height}}_setPositionFromLayout(e){const{db:t}=this.root;t.pcb_hole.update(this.pcb_hole_id,{x:e.x,y:e.y})}},gYe=r=>{const e=[];for(const t of r)t.type==="pcb_smtpad"&&t.shape==="rect"?e.push(new jI({pcbX:t.x,pcbY:t.y,layer:t.layer,shape:"rect",height:t.height,width:t.width,portHints:t.port_hints})):t.type==="pcb_smtpad"&&t.shape==="circle"?e.push(new jI({pcbX:t.x,pcbY:t.y,layer:t.layer,shape:"circle",radius:t.radius,portHints:t.port_hints})):t.type==="pcb_silkscreen_path"?e.push(new _ce({layer:t.layer,route:t.route,strokeWidth:t.stroke_width})):t.type==="pcb_plated_hole"&&t.shape==="circle"?t.shape==="circle"&&e.push(new xce({pcbX:t.x,pcbY:t.y,shape:"circle",holeDiameter:t.hole_diameter,outerDiameter:t.outer_diameter,portHints:t.port_hints})):t.type==="pcb_keepout"&&t.shape==="circle"?e.push(new GI({pcbX:t.center.x,pcbY:t.center.y,shape:"circle",radius:t.radius})):t.type==="pcb_keepout"&&t.shape==="rect"?e.push(new GI({pcbX:t.center.x,pcbY:t.center.y,shape:"rect",width:t.width,height:t.height})):t.type==="pcb_hole"&&t.hole_shape==="circle"&&e.push(new bce({pcbX:t.x,pcbY:t.y,diameter:t.hole_diameter}));return e};function Sce(r){let e=1/0,t=1/0,n=-1/0,i=-1/0;for(const s of r)if(s.isPcbPrimitive){const{x:l,y:c}=s._getGlobalPcbPositionBeforeLayout(),{width:u,height:h}=s.getPcbSize();e=Math.min(e,l-u/2),t=Math.min(t,c-h/2),n=Math.max(n,l+u/2),i=Math.max(i,c+h/2)}else if(s.componentName==="Footprint"){const l=Sce(s.children);e=Math.min(e,l.minX),t=Math.min(t,l.minY),n=Math.max(n,l.maxX),i=Math.max(i,l.maxY)}let a=n-e,o=i-t;return a<0&&(a=0),o<0&&(o=0),{minX:e,minY:t,maxX:n,maxY:i,width:a,height:o}}function _Ye(r,e){const t=e.x-r.x,n=e.y-r.y;return Math.abs(t)>Math.abs(n)?t>=0?"right":"left":n>=0?"up":"down"}var xYe=r=>{if(r.length<=1)return!0;const e=r.map(a=>{const o=a._getPcbCircuitJsonBounds();return{left:o.bounds.left,right:o.bounds.right,top:o.bounds.top,bottom:o.bounds.bottom}}),t=Array(e.length).fill(!1).map(()=>Array(e.length).fill(!1));for(let a=0;a<e.length;a++)for(let o=a+1;o<e.length;o++){const s=e[a],l=e[o];t[a][o]=t[o][a]=!(s.right<l.left||s.left>l.right||s.bottom>l.top||s.top<l.bottom)}const n=new Set,i=a=>{n.add(a);for(let o=0;o<e.length;o++)t[a][o]&&!n.has(o)&&i(o)};return i(0),n.size===e.length},bYe=r=>{if(r.length===0)throw new Error("Cannot get center of empty PCB primitives array");const e=r.map(i=>i._getPcbCircuitJsonBounds().center).filter(Boolean),t=e.reduce((i,a)=>i+a.x,0),n=e.reduce((i,a)=>i+a.y,0);return{x:t/e.length,y:n/e.length}},SYe=ue.object({name:ue.string().optional(),pinNumber:ue.number().optional(),aliases:ue.array(ue.string()).optional()}),l4=class extends R_{constructor(e,t={}){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);ni(this,"source_port_id",null);ni(this,"pcb_port_id",null);ni(this,"schematic_port_id",null);ni(this,"schematicSymbolPortDef",null);ni(this,"matchedComponents");ni(this,"facingDirection",null);ni(this,"originDescription",null);t.originDescription&&(this.originDescription=t.originDescription),this.matchedComponents=[]}get config(){return{componentName:"Port",zodProps:SYe}}_getGlobalPcbPositionBeforeLayout(){const e=this.matchedComponents.find(n=>n.isPcbPrimitive),t=this.parent;if(t&&!t.props.footprint)throw new Error(`${t.componentName} "${t.props.name}" does not have a footprint. Add a footprint prop, e.g. <${t.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==null?void 0:e._getGlobalPcbPositionBeforeLayout())??{x:0,y:0}}_getPcbCircuitJsonBounds(){if(!this.pcb_port_id)return super._getPcbCircuitJsonBounds();const{db:e}=this.root,t=e.pcb_port.get(this.pcb_port_id);return{center:{x:t.x,y:t.y},bounds:{left:0,top:0,right:0,bottom:0},width:0,height:0}}_getGlobalPcbPositionAfterLayout(){return this._getPcbCircuitJsonBounds().center}_getPortsInternallyConnectedToThisPort(){const e=this.parent;if(!e||!e._getInternallyConnectedPins)return[];const t=e._getInternallyConnectedPins();for(const n of t)if(n.some(i=>i===this))return n;return[]}_hasSchematicPort(){var n,i;if((n=this.parent)==null?void 0:n.getSchematicSymbol())return!!(this.schematicSymbolPortDef||this._getPortsInternallyConnectedToThisPort().some(o=>o.schematicSymbolPortDef));const t=(i=this==null?void 0:this.parent)==null?void 0:i._getSchematicBoxDimensions();return!!(t&&this.props.pinNumber!==void 0&&t.getPortPositionByPinNumber(this.props.pinNumber))}_getGlobalSchematicPositionBeforeLayout(){var n,i,a;const e=(n=this.parent)==null?void 0:n.getSchematicSymbol();if(e){let o=this.schematicSymbolPortDef;if(!o&&(o=((i=this._getPortsInternallyConnectedToThisPort().find(l=>l.schematicSymbolPortDef))==null?void 0:i.schematicSymbolPortDef)??null,!o))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?`);const s=oh(this.parent.computeSchematicGlobalTransform(),rv(-e.center.x,-e.center.y));return ui(s,o)}const t=(a=this==null?void 0:this.parent)==null?void 0:a._getSchematicBoxDimensions();if(t&&this.props.pinNumber!==void 0){const o=t.getPortPositionByPinNumber(this.props.pinNumber);if(!o)throw new Error(`Couldn't find position for schematic_port for port ${this.getString()} inside of the schematic box`);return ui(this.parent.computeSchematicGlobalTransform(),o)}throw new Error(`Couldn't find position for schematic_port for port ${this.getString()}`)}_getGlobalSchematicPositionAfterLayout(){const{db:e}=this.root;if(!this.schematic_port_id)throw new Error("Can't get schematic port position after layout, no schematic_port_id");const t=e.schematic_port.get(this.schematic_port_id);if(!t)throw new Error(`Schematic port not found when trying to get post-layout position: ${this.schematic_port_id}`);return t.center}registerMatch(e){this.matchedComponents.push(e)}getNameAndAliases(){const{_parsedProps:e}=this;return Array.from(new Set([...e.aliases??[],...e.name?[e.name]:[],...typeof e.pinNumber=="number"?[`pin${e.pinNumber}`,e.pinNumber.toString()]:[],...this.externallyAddedAliases??[]]))}isMatchingPort(e){return this.isMatchingAnyOf(e.getNameAndAliases())}getPortSelector(){var e;return`.${(e=this.parent)==null?void 0:e.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(n=>n._isExplicitlyConnectedToPort(this))}doInitialSourceRender(){var a,o;const{db:e}=this.root,{_parsedProps:t}=this,n=this.getNameAndAliases(),i=e.source_port.insert({name:t.name,pin_number:t.pinNumber,port_hints:n,source_component_id:(a=this.parent)==null?void 0:a.source_component_id,subcircuit_id:(o=this.getSubcircuit())==null?void 0:o.subcircuit_id});this.source_port_id=i.source_port_id}doInitialSourceParentAttachment(){var t,n,i,a;const{db:e}=this.root;if(!((t=this.parent)!=null&&t.source_component_id))throw new Error(`${this.getString()} has no parent source component (parent: ${(n=this.parent)==null?void 0:n.getString()})`);e.source_port.update(this.source_port_id,{source_component_id:(i=this.parent)==null?void 0:i.source_component_id}),this.source_component_id=(a=this.parent)==null?void 0:a.source_component_id}doInitialPcbPortRender(){var a,o,s,l,c;if((a=this.root)!=null&&a.pcbDisabled)return;const{db:e}=this.root,{matchedComponents:t}=this;if(!((o=this.parent)!=null&&o.pcb_component_id))throw new Error(`${this.getString()} has no parent pcb component, cannot render pcb_port (parent: ${(s=this.parent)==null?void 0:s.getString()})`);const n=t.filter(u=>u.isPcbPrimitive);if(n.length===0)return;let i=null;if(n.length===1&&(i=n[0]._getPcbCircuitJsonBounds().center),n.length>1){if(!xYe(n))throw new Error(`${this.getString()} has multiple non-overlapping pcb matches, unclear how to place pcb_port: ${n.map(u=>u.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)`);i=bYe(n)}if(i){const u=this.getSubcircuit(),h=e.pcb_port.insert({pcb_component_id:(l=this.parent)==null?void 0:l.pcb_component_id,layers:this.getAvailablePcbLayers(),subcircuit_id:(u==null?void 0:u.subcircuit_id)??void 0,pcb_group_id:((c=this.getGroup())==null?void 0:c.pcb_group_id)??void 0,...i,source_port_id:this.source_port_id});this.pcb_port_id=h.pcb_port_id}else{const u=n[0];throw new Error(`${u.getString()} does not have a center or _getGlobalPcbPositionBeforeLayout method (needed for pcb_port placement)`)}}doInitialSchematicPortRender(){var h;const{db:e}=this.root,{_parsedProps:t}=this,n=this.getPrimitiveContainer();if(!n||!this._hasSchematicPort())return;const i=n._getGlobalSchematicPositionBeforeLayout(),a=this._getGlobalSchematicPositionBeforeLayout();let o=null;const s=n._getSchematicBoxDimensions();s&&t.pinNumber!==void 0&&(o=s.getPortPositionByPinNumber(t.pinNumber)),this.getSubcircuit().props._schDebugObjectsEnabled&&e.schematic_debug_object.insert({shape:"rect",center:a,size:{width:.1,height:.1},label:"obstacle"}),o!=null&&o.side?this.facingDirection={left:"left",right:"right",top:"up",bottom:"down"}[o.side]:this.facingDirection=_Ye(i,a);const l=e.source_port.get(this.source_port_id);let c;for(const g of(l==null?void 0:l.port_hints)??[])g.match(/^(pin)?\d+$/)||(c=g);const u=e.schematic_port.insert({schematic_component_id:(h=this.parent)==null?void 0:h.schematic_component_id,center:a,source_port_id:this.source_port_id,facing_direction:this.facingDirection,distance_from_component_edge:.4,side_of_component:o==null?void 0:o.side,pin_number:t.pinNumber,true_ccw_index:o==null?void 0:o.trueIndex,display_pin_label:c});this.schematic_port_id=u.schematic_port_id}_setPositionFromLayout(e){const{db:t}=this.root;this.pcb_port_id&&t.pcb_port.update(this.pcb_port_id,{x:e.x,y:e.y})}_hasMatchedPcbPrimitive(){return this.matchedComponents.some(e=>e.isPcbPrimitive)}},Ece=r=>{const e=r.find(t=>/^(pin)?\d+$/.test(t));return e?Number.parseInt(e.replace(/^pin/,"")):null};function xT(r,e){var a;const t=Ece(r);if(!t)return null;const i=[...r.filter(o=>o.toString()!==t.toString()&&o!==`pin${t}`),...((a=e==null?void 0:e.additionalAliases)==null?void 0:a[`pin${t}`])??[]];return new l4({pinNumber:t,aliases:i})}var EYe=r=>{for(const e of["leftSide","rightSide","topSide","bottomSide"])if(e in r&&typeof r[e]=="number")throw new Error(`A number was specified for "${e}", you probably meant to use "size" not "side"`);return"leftSide"in r||"rightSide"in r||"topSide"in r||"bottomSide"in r},wYe=r=>{var a,o,s,l;if(EYe(r))return{leftSize:((a=r.leftSide)==null?void 0:a.pins.length)??0,rightSize:((o=r.rightSide)==null?void 0:o.pins.length)??0,topSize:((s=r.topSide)==null?void 0:s.pins.length)??0,bottomSize:((l=r.bottomSide)==null?void 0:l.pins.length)??0};const{leftSize:e=0,rightSize:t=0,topSize:n=0,bottomSize:i=0}=r;return{leftSize:e,rightSize:t,topSize:n,bottomSize:i}};function wce(r){return r.leftSide!==void 0}var TYe=r=>{var C,A,L,U,j,Z,ee,$;const e=r.portDistanceFromEdge??.4;let t=r.schPortArrangement?wYe(r.schPortArrangement):null;const n={left:0,right:0,top:0,bottom:0};let i=r.pinCount??null;if(i===null)if(t)i=t.leftSize+t.rightSize+t.topSize;else throw new Error("Could not determine pin count for the schematic box");if(i&&!t){const oe=Math.floor(i/2);t={leftSize:i-oe,rightSize:oe,topSize:0,bottomSize:0}}t||(t={leftSize:0,rightSize:0,topSize:0,bottomSize:0});const a=({side:oe,sideIndex:ae,truePinIndex:ce})=>{var ze,Ne,Oe,Le;if(!r.schPortArrangement||!wce(r.schPortArrangement))return ce+1;const me={left:"top-to-bottom",bottom:"left-to-right",right:"bottom-to-top",top:"right-to-left"}[oe],_e=((Ne=(ze=r.schPortArrangement)==null?void 0:ze[`${oe}Side`])==null?void 0:Ne.direction)??me,Se=(Le=(Oe=r.schPortArrangement)==null?void 0:Oe[`${oe}Side`])==null?void 0:Le.pins;let Ae=ae;return _e!==me&&(Ae=Se.length-ae-1),gT(Se[Ae],r.pinLabels)},o=[];let s=0,l=0;for(let oe=0;oe<t.leftSize;oe++){const ae=a({side:"left",sideIndex:oe,truePinIndex:l}),ce=((C=r.numericSchPinStyle)==null?void 0:C[`pin${ae}`])??((A=r.numericSchPinStyle)==null?void 0:A[ae]);ce!=null&&ce.topMargin&&(s+=ce.topMargin),o.push({trueIndex:l,pinNumber:ae,side:"left",distanceFromOrthogonalEdge:s}),ce!=null&&ce.bottomMargin&&(s+=ce.bottomMargin),oe===t.leftSize-1?n.left=s:s+=r.schPinSpacing,l++}s=0;for(let oe=0;oe<t.bottomSize;oe++){const ae=a({side:"bottom",sideIndex:oe,truePinIndex:l}),ce=((L=r.numericSchPinStyle)==null?void 0:L[`pin${ae}`])??((U=r.numericSchPinStyle)==null?void 0:U[ae]);ce!=null&&ce.leftMargin&&(s+=ce.leftMargin),o.push({trueIndex:l,pinNumber:ae,side:"bottom",distanceFromOrthogonalEdge:s}),ce!=null&&ce.rightMargin&&(s+=ce.rightMargin),oe===t.bottomSize-1?n.bottom=s:s+=r.schPinSpacing,l++}s=0;for(let oe=0;oe<t.rightSize;oe++){const ae=a({side:"right",sideIndex:oe,truePinIndex:l}),ce=((j=r.numericSchPinStyle)==null?void 0:j[`pin${ae}`])??((Z=r.numericSchPinStyle)==null?void 0:Z[ae]);ce!=null&&ce.bottomMargin&&(s+=ce.bottomMargin),o.push({trueIndex:l,pinNumber:ae,side:"right",distanceFromOrthogonalEdge:s}),ce!=null&&ce.topMargin&&(s+=ce.topMargin),oe===t.rightSize-1?n.right=s:s+=r.schPinSpacing,l++}s=0;for(let oe=0;oe<t.topSize;oe++){const ae=a({side:"top",sideIndex:oe,truePinIndex:l}),ce=((ee=r.numericSchPinStyle)==null?void 0:ee[`pin${ae}`])??(($=r.numericSchPinStyle)==null?void 0:$[ae]);ce!=null&&ce.rightMargin&&(s+=ce.rightMargin),o.push({trueIndex:l,pinNumber:ae,side:"top",distanceFromOrthogonalEdge:s}),ce!=null&&ce.leftMargin&&(s+=ce.leftMargin),oe===t.topSize-1?n.top=s:s+=r.schPinSpacing,l++}let c=r.schWidth;c||(c=Math.max(n.top+r.schPinSpacing*2,n.bottom+r.schPinSpacing*2));const u=r.pinLabels?Math.max(...Object.values(r.pinLabels).map(oe=>oe.length*.1)):0,h=u>0?1.1:0;c=Math.max(c,u+h);let g=r.schHeight;g||(g=Math.max(n.left+r.schPinSpacing*2,n.right+r.schPinSpacing*2));const _={left:{x:-c/2-e,y:n.left/2},bottom:{x:-n.bottom/2,y:-g/2-e},right:{x:c/2+e,y:-n.right/2},top:{x:n.top/2,y:g/2+e}},b={left:{x:0,y:-1},right:{x:0,y:1},top:{x:-1,y:0},bottom:{x:1,y:0}},T=o.map(oe=>{const{distanceFromOrthogonalEdge:ae,side:ce}=oe,me=_[ce],_e=b[ce];return{x:me.x+ae*_e.x,y:me.y+ae*_e.y,...oe}});return{getPortPositionByPinNumber(oe){const ae=T.find(ce=>ce.pinNumber.toString()===oe.toString());return ae||null},getSize(){return{width:c,height:g}},getSizeIncludingPins(){return{width:c+(t.leftSize||t.rightSize?.4:0),height:g+(t.topSize||t.bottomSize?.4:0)}},pinCount:i}},MYe=g2("tscircuit:core:footprint"),CYe=class extends R_{get config(){return{componentName:"Footprint",zodProps:pqe}}doInitialPcbFootprintLayout(){var h,g,_,b,T;if((h=this.root)!=null&&h.pcbDisabled)return;const r=this.children.filter(C=>C.componentName==="Constraint");if(r.length===0)return;const{isFlipped:e}=this._getPcbPrimitiveFlippedHelpers(),t=C=>e&&"left"in C&&"right"in C?{...C,left:C.right,right:C.left}:C,n=r.flatMap(C=>C._getAllReferencedComponents().componentsWithSelectors).map(({component:C,selector:A,componentSelector:L,edge:U})=>({component:C,selector:A,componentSelector:L,edge:U,bounds:C._getPcbCircuitJsonBounds()}));if(n.some(C=>C.edge))throw new Error("edge constraints not implemented yet for footprint layout, contributions welcome!");function i(C){return n.find(({selector:A})=>A===C)}const a=new Bqe,o={};function s(C){return C in o||(o[C]=new BI(C),a.addEditVariable(o[C],X5.weak)),o[C]}for(const{selector:C,bounds:A}of n){const L=s(`${C}_x`),U=s(`${C}_y`);a.suggestValue(L,A.center.x),a.suggestValue(U,A.center.y)}for(const C of r){const A=C._parsedProps;if("xDist"in A){const{xDist:L,left:U,right:j,edgeToEdge:Z,centerToCenter:ee}=t(A),$=s(`${U}_x`),oe=s(`${j}_x`),ae=(g=i(U))==null?void 0:g.bounds,ce=(_=i(j))==null?void 0:_.bounds;if(ee){const me=new Ax(oe,[-1,$]);a.addConstraint(new K4(me,c3.Eq,A.xDist,X5.required))}else if(Z){const me=new Ax(oe,-ce.width/2,[-1,$],-ae.width/2);a.addConstraint(new K4(me,c3.Eq,A.xDist,X5.required))}}else if("yDist"in A){const{yDist:L,top:U,bottom:j,edgeToEdge:Z,centerToCenter:ee}=A,$=s(`${U}_y`),oe=s(`${j}_y`),ae=(b=i(U))==null?void 0:b.bounds,ce=(T=i(j))==null?void 0:T.bounds;if(ee){const me=new Ax($,[-1,oe]);a.addConstraint(new K4(me,c3.Eq,A.yDist,X5.required))}else if(Z){const me=new Ax($,ae.height/2,[-1,oe],-ce.height/2);a.addConstraint(new K4(me,c3.Eq,A.yDist,X5.required))}}else if("sameY"in A){const{for:L}=A;if(L.length<2)continue;const U=L.map(Z=>s(`${Z}_y`)),j=new Ax(...U.slice(1));a.addConstraint(new K4(j,c3.Eq,U[0],X5.required))}else if("sameX"in A){const{for:L}=A;if(L.length<2)continue;const U=L.map(Z=>s(`${Z}_x`)),j=new Ax(...U.slice(1));a.addConstraint(new K4(j,c3.Eq,U[0],X5.required))}}a.updateVariables(),MYe.enabled&&(console.log("Solution to layout constraints:"),console.table(Object.entries(o).map(([C,A])=>({var:C,val:A.value()}))));const l={left:1/0,right:-1/0,top:-1/0,bottom:1/0};for(const{selector:C,bounds:{width:A,height:L}}of n){const U=s(`${C}_x`),j=s(`${C}_y`),Z=U.value()-A/2,ee=U.value()+A/2,$=j.value()+L/2,oe=j.value()-L/2;l.left=Math.min(l.left,Z),l.right=Math.max(l.right,ee),l.top=Math.max(l.top,$),l.bottom=Math.min(l.bottom,oe)}const c={x:-(l.right+l.left)/2,y:-(l.top+l.bottom)/2},u=this.getPrimitiveContainer()._getGlobalPcbPositionBeforeLayout();c.x+=u.x,c.y+=u.y;for(const{component:C,selector:A}of n){const L=s(`${A}_x`),U=s(`${A}_y`);C._setPositionFromLayout({x:L.value()+c.x,y:U.value()+c.y})}}},RYe=(r,e)=>{if(!r)return;const t={};for(const[n,i]of Object.entries(r)){const a=gT(n,e),o={leftMargin:i.marginLeft??i.leftMargin,rightMargin:i.marginRight??i.rightMargin,topMargin:i.marginTop??i.topMargin,bottomMargin:i.marginBottom??i.bottomMargin};t[`pin${a}`]={...t[`pin${a}`],...o}}return t},AYe=g2("tscircuit:core"),DYe=ue.object({x:L8,y:L8,z:L8}),Dx=class extends R_{constructor(e){super(e);ni(this,"reactSubtrees",[]);ni(this,"_impliedFootprint");ni(this,"isPrimitiveContainer",!0);ni(this,"_asyncSupplierPartNumbers");ni(this,"pcb_missing_footprint_error_id");this._addChildrenFromStringFootprint(),this.initPorts()}get defaultInternallyConnectedPinNames(){return[]}get internallyConnectedPinNames(){return this._parsedProps.internallyConnectedPins??this.defaultInternallyConnectedPinNames}initPorts(e={}){var o,s,l,c,u,h,g,_,b,T;if((o=this.root)!=null&&o.schematicDisabled)return;const{config:t}=this,n=[],i=this._getSchematicPortArrangement();if(i&&!this._parsedProps.pinLabels){for(const L in i){const U=i[L].pins;if(Array.isArray(U))for(const j of U){const Z=gT(j,this._parsedProps.pinLabels);n.push(new l4({pinNumber:Z,aliases:((s=e.additionalAliases)==null?void 0:s[`pin${Z}`])??[]},{originDescription:`schPortArrangement:${L}`}))}}const C=["left","right","top","bottom"];let A=1;for(const L of C){const U=i[`${L}Size`];for(let j=0;j<U;j++)n.push(new l4({pinNumber:A++,aliases:((l=e.additionalAliases)==null?void 0:l[`pin${A}`])??[]},{originDescription:`schPortArrangement:${L}`}))}}const a=this._parsedProps.pinLabels;if(a)for(let[C,A]of Object.entries(a)){C=C.replace("pin","");let L=n.find(Z=>Z._parsedProps.pinNumber===Number(C));const U=Array.isArray(A)?A[0]:A,j=Array.isArray(A)?A.slice(1):[];L?(L.externallyAddedAliases.push(U,...j),L.props.name=U):(L=new l4({pinNumber:parseInt(C),name:U,aliases:[...j,...((c=e.additionalAliases)==null?void 0:c[`pin${parseInt(C)}`])??[]]},{originDescription:`pinLabels:pin${C}`}),n.push(L))}if(t.schematicSymbolName){const C=w3[this._getSchematicSymbolNameOrThrow()];if(!C)return;for(const A of C.ports){const L=Ece(A.labels);if(!L)continue;const U=xT(A.labels.concat(((u=e.additionalAliases)==null?void 0:u[`pin${L}`])??[]));U&&(U.originDescription=`schematicSymbol:labels[0]:${A.labels[0]}`,U.schematicSymbolPortDef=A,n.push(U))}this.addAll(n)}if(!this._getSchematicPortArrangement()){const C=this.getPortsFromFootprint(e);for(const A of C)n.some(L=>L.isMatchingAnyOf(A.getNameAndAliases()))||n.push(A)}for(let C=1;C<=(e.pinCount??this._getPinCount());C++){if(!i||n.find(L=>L._parsedProps.pinNumber===C))continue;let A=[...((h=i.leftSide)==null?void 0:h.pins)??[],...((g=i.rightSide)==null?void 0:g.pins)??[],...((_=i.topSide)==null?void 0:_.pins)??[],...((b=i.bottomSide)==null?void 0:b.pins)??[]].map(L=>gT(L,this._parsedProps.pinLabels));["leftSize","rightSize","topSize","bottomSize","leftPinCount","rightPinCount","topPinCount","bottomPinCount"].some(L=>L in i)&&(A=Array.from({length:this._getPinCount()},(L,U)=>U+1)),A.includes(C)&&n.push(new l4({pinNumber:C,aliases:((T=e.additionalAliases)==null?void 0:T[`pin${C}`])??[]},{originDescription:`notOtherwiseAddedButDeducedFromPinCount:${C}`}))}n.length>0&&this.addAll(n)}_getImpliedFootprintString(){return null}_addChildrenFromStringFootprint(){var t;let{footprint:e}=this.props;if(e??(e=(t=this._getImpliedFootprintString)==null?void 0:t.call(this)),!!e&&typeof e=="string"){const n=Jz.string(e).soup(),i=gYe(n);this.addAll(i)}}get portMap(){return new Proxy({},{get:(e,t)=>{const n=this.children.find(i=>i.componentName==="Port"&&i.isMatchingNameOrAlias(t));if(!n)throw new Error(`There was an issue finding the port "${t.toString()}" inside of a ${this.componentName} component with name: "${this.props.name}". This is a bug in @tscircuit/core`);return n}})}getInstanceForReactElement(e){for(const t of this.reactSubtrees)if(t.element===e)return t.component;return null}doInitialSourceRender(){const e=this.config.sourceFtype;if(!e)return;const{db:t}=this.root,{_parsedProps:n}=this,i=t.source_component.insert({ftype:e,name:n.name,manufacturer_part_number:n.manufacturerPartNumber??n.mfn,supplier_part_numbers:n.supplierPartNumbers});this.source_component_id=i.source_component_id}doInitialSchematicComponentRender(){var n;if((n=this.root)!=null&&n.schematicDisabled)return;const{schematicSymbolName:e}=this.config;if(e)return this._doInitialSchematicComponentRenderWithSymbol();if(this._getSchematicBoxDimensions())return this._doInitialSchematicComponentRenderWithSchematicBoxDimensions()}_getSchematicSymbolDisplayValue(){}_getInternallyConnectedPins(){if(this.internallyConnectedPinNames.length===0)return[];const e=[];for(const t of this.internallyConnectedPinNames){const n=[];for(const i of t)n.push(this.portMap[i]);e.push(n)}return e}_doInitialSchematicComponentRenderWithSymbol(){var o;if((o=this.root)!=null&&o.schematicDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this._getSchematicSymbolNameOrThrow(),i=w3[n],a=this._getGlobalSchematicPositionBeforeLayout();if(i){const s=e.schematic_component.insert({center:a,rotation:t.schRotation??0,size:i.size,source_component_id:this.source_component_id,symbol_name:n,symbol_display_value:this._getSchematicSymbolDisplayValue()});this.schematic_component_id=s.schematic_component_id}}_doInitialSchematicComponentRenderWithSchematicBoxDimensions(){var h;if((h=this.root)!=null&&h.schematicDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this._getSchematicBoxDimensions(),i={};if(Array.isArray(t.pinLabels))t.pinLabels.forEach((g,_)=>{i[String(_+1)]=g});else for(const[g,_]of Object.entries(t.pinLabels??{}))i[g]=Array.isArray(_)?_[0]:_;const a=this._getGlobalSchematicPositionBeforeLayout(),o=this._getSchematicPortArrangement(),s=e.schematic_component.insert({center:a,rotation:t.schRotation??0,size:n.getSize(),port_arrangement:mYe(o),pin_spacing:t.schPinSpacing??.2,pin_styles:pYe(t.schPinStyle,t.pinLabels),port_labels:i,source_component_id:this.source_component_id}),l=(o==null?void 0:o.topSide)!==void 0||(o==null?void 0:o.bottomSide)!==void 0,c=n==null?void 0:n.getSize().width,u=n==null?void 0:n.getSize().height;e.schematic_text.insert({text:t.manufacturerPartNumber??"",schematic_component_id:s.schematic_component_id,anchor:"left",rotation:0,position:{x:l?a.x+(c??0)/2+.1:a.x-(c??0)/2,y:l?a.y+(u??0)/2+.35:a.y-(u??0)/2-.13},color:"#006464"}),e.schematic_text.insert({text:t.name??"",schematic_component_id:s.schematic_component_id,anchor:"left",rotation:0,position:{x:l?a.x+(c??0)/2+.1:a.x-(c??0)/2,y:l?a.y+(u??0)/2+.55:a.y+(u??0)/2+.13},color:"#006464"}),this.schematic_component_id=s.schematic_component_id}doInitialPcbComponentRender(){var o;if((o=this.root)!=null&&o.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this.getSubcircuit(),i=e.pcb_component.insert({center:this._getGlobalPcbPositionBeforeLayout(),width:0,height:0,layer:t.layer??"top",rotation:t.pcbRotation??0,source_component_id:this.source_component_id,subcircuit_id:n.subcircuit_id??void 0});if(!t.footprint&&!this.isGroup){const s=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=s.pcb_missing_footprint_error_id}this.pcb_component_id=i.pcb_component_id;const a=this.getSubcircuit()._getPcbManualPlacementForComponent(this);this.props.pcbX!==void 0&&this.props.pcbY!==void 0&&a&&this.renderError({type:"pcb_manual_edit_conflict_error",message:`${this.getString()} has both manual placement and explicit 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})}doInitialPcbComponentSizeCalculation(){var i;if((i=this.root)!=null&&i.pcbDisabled||!this.pcb_component_id)return;const{db:e}=this.root,t=Sce(this.children);if(t.width===0||t.height===0)return;const n={x:(t.minX+t.maxX)/2,y:(t.minY+t.maxY)/2};e.pcb_component.update(this.pcb_component_id,{center:n,width:t.width,height:t.height})}_renderReactSubtree(e){return{element:e,component:mce(e)}}doInitialInitializePortsFromChildren(){this.initPorts()}doInitialReactSubtreesRender(){if(Tt.isValidElement(this.props.footprint)){if(this.reactSubtrees.some(t=>t.element===this.props.footprint))return;const e=this._renderReactSubtree(this.props.footprint);this.reactSubtrees.push(e),this.add(e.component)}}_hasExistingPortExactly(e){return this.children.filter(n=>n.componentName==="Port").some(n=>{const i=e.getNameAndAliases(),a=n.getNameAndAliases();return i.length===a.length&&i.every(o=>a.includes(o))})}add(e){let t;if(Tt.isValidElement(e)){const n=this._renderReactSubtree(e);this.reactSubtrees.push(n),t=n.component}else t=e;if(t.componentName==="Port"){if(this._hasExistingPortExactly(t))return;const i=this.children.filter(a=>a.componentName==="Port").find(a=>a.isMatchingAnyOf(t.getNameAndAliases()));i&&AYe(`Similar ports added. Port 1: ${i}, Port 2: ${t}`)}super.add(t)}getPortsFromFootprint(e){let{footprint:t}=this.props;if((!t||Tt.isValidElement(t))&&(t=this.children.find(i=>i.componentName==="Footprint")),typeof t=="string"){const i=Jz.string(t).soup(),a=[];for(const o of i)if("port_hints"in o&&o.port_hints){const s=xT(o.port_hints,e);if(!s)continue;s.originDescription=`footprint:string:${t}:port_hints[0]:${o.port_hints[0]}`,a.push(s)}return a}if(!Tt.isValidElement(t)&&t&&t.componentName==="Footprint"){const i=t;let a=1;const o=[];for(const s of i.children){if(!s.props.portHints)continue;let l=s.props.portHints;l.some(h=>h.startsWith("pin"))||(l=[...l,`pin${a}`]),a++;const u=xT(l);u&&(u.originDescription=`footprint:${t}`,o.push(u))}return o}const n=[];if(!t){for(const i of this.children)if(i.props.portHints&&i.isPcbPrimitive){const a=xT(i.props.portHints);a&&n.push(a)}}return n}getPortsFromSchematicSymbol(){var i;if((i=this.root)!=null&&i.schematicDisabled)return[];const{config:e}=this;if(!e.schematicSymbolName)return[];const t=w3[e.schematicSymbolName];if(!t)return[];const n=[];for(const a of t.ports){const o=xT(a.labels);o&&(o.schematicSymbolPortDef=a,n.push(o))}return n}_createNetsFromProps(e){gce(this,e)}_getPcbCircuitJsonBounds(){const{db:e}=this.root;if(!this.pcb_component_id)return super._getPcbCircuitJsonBounds();const t=e.pcb_component.get(this.pcb_component_id);return{center:{x:t.center.x,y:t.center.y},bounds:{left:t.center.x-t.width/2,top:t.center.y-t.height/2,right:t.center.x+t.width/2,bottom:t.center.y+t.height/2},width:t.width,height:t.height}}_getPinCountFromSchematicPortArrangement(){const e=this._getSchematicPortArrangement();if(!e)return 0;if(!wce(e))return(e.leftSize??e.leftPinCount??0)+(e.rightSize??e.rightPinCount??0)+(e.topSize??e.topPinCount??0)+(e.bottomSize??e.bottomPinCount??0);const{leftSide:n,rightSide:i,topSide:a,bottomSide:o}=e;return Math.max(...(n==null?void 0:n.pins)??[],...(i==null?void 0:i.pins)??[],...(a==null?void 0:a.pins)??[],...(o==null?void 0:o.pins)??[])}_getPinCount(){return this._getSchematicPortArrangement()?this._getPinCountFromSchematicPortArrangement():this.getPortsFromFootprint().length}_getSchematicPortArrangement(){return this._parsedProps.schPinArrangement??this._parsedProps.schPortArrangement}_getSchematicBoxDimensions(){if(this.getSchematicSymbol()||!this.config.shouldRenderAsSchematicBox)return null;const{_parsedProps:e}=this,t=this._getPinCount(),n=e.schPinSpacing??.2;return TYe({schWidth:e.schWidth,schHeight:e.schHeight,schPinSpacing:n,numericSchPinStyle:RYe(e.schPinStyle,e.pinLabels),pinCount:t,schPortArrangement:this._getSchematicPortArrangement(),pinLabels:e.pinLabels})}doInitialCadModelRender(){var c;const{db:e}=this.root,{boardThickness:t=0}=((c=this.root)==null?void 0:c._getBoard())??{},n=this._parsedProps.cadModel;if(!this.pcb_component_id||!n&&!this.props.footprint)return;const i=this._getPcbCircuitJsonBounds(),a=e.pcb_component.get(this.pcb_component_id);if(typeof n=="string")throw new Error("String cadModel not yet implemented");const o=DYe.parse({x:0,y:0,z:typeof(n==null?void 0:n.rotationOffset)=="number"?n.rotationOffset:0,...typeof(n==null?void 0:n.rotationOffset)=="object"?n.rotationOffset??{}:{}}),s=hR.parse({x:0,y:0,z:0,...typeof(n==null?void 0:n.positionOffset)=="object"?n.positionOffset:{}}),l=this.props.layer==="bottom"?"bottom":"top";e.cad_component.insert({position:{x:i.center.x+s.x,y:i.center.y+s.y,z:(l==="bottom"?-t/2:t/2)+s.z},rotation:{x:o.x,y:(l==="top"?0:180)+o.y,z:((a==null?void 0:a.rotation)??0)+(l==="bottom"?180:0)+o.z},pcb_component_id:this.pcb_component_id,source_component_id:this.source_component_id,model_stl_url:"stlUrl"in(n??{})?this._addCachebustToModelUrl(n.stlUrl):void 0,model_obj_url:"objUrl"in(n??{})?this._addCachebustToModelUrl(n.objUrl):void 0,model_jscad:"jscad"in(n??{})?n.jscad:void 0,footprinter_string:typeof this.props.footprint=="string"&&!n?this.props.footprint:void 0})}_addCachebustToModelUrl(e){var n;if(!e||!e.includes("modelcdn.tscircuit.com"))return e;const t=((n=this.root)==null?void 0:n.getClientOrigin())??"";return`${e}${e.includes("?")?"&":"?"}cachebust_origin=${encodeURIComponent(t)}`}doInitialPartsEngineRender(){const e=this.getInheritedProperty("partsEngine");if(!e)return;const{db:t}=this.root,n=t.source_component.get(this.source_component_id);if(!n||n.supplier_part_numbers)return;let i;this.props.footprint&&typeof this.props.footprint=="string"&&(i=this.props.footprint);const a=e.findPart({sourceComponent:n,footprinterString:i});if(!(a instanceof Promise)){t.source_component.update(this.source_component_id,{supplier_part_numbers:a});return}this._queueAsyncEffect("get-supplier-part-numbers",async()=>{this._asyncSupplierPartNumbers=await a,this._markDirty("PartsEngineRender")})}updatePartsEngineRender(){const{db:e}=this.root,t=e.source_component.get(this.source_component_id);if(t&&!t.supplier_part_numbers&&this._asyncSupplierPartNumbers){e.source_component.update(this.source_component_id,{supplier_part_numbers:this._asyncSupplierPartNumbers});return}}},PYe=({db:r,traces:e,minTraceWidth:t=.1})=>{const i=$le([...r.pcb_component.list(),...r.pcb_smtpad.list(),...r.pcb_plated_hole.list()]).flatMap(s=>[{x:s.center.x-s.width/2,y:s.center.y-s.height/2},{x:s.center.x+s.width/2,y:s.center.y+s.height/2}]),a={minX:Math.min(...i.map(s=>s.x))-1,maxX:Math.max(...i.map(s=>s.x))+1,minY:Math.min(...i.map(s=>s.y))-1,maxY:Math.max(...i.map(s=>s.y))+1},o=e.map(s=>{const l=s._findConnectedPorts();return!l.allPortsFound||l.ports.length<2?null:{name:s.source_trace_id??"",pointsToConnect:l.ports.map(c=>{const u=c._getGlobalPcbPositionBeforeLayout();return{x:u.x,y:u.y,layer:c.getAvailablePcbLayers()[0]??"top"}})}}).filter(s=>s!==null);return{bounds:a,obstacles:[],connections:o,layerCount:2,minTraceWidth:t}},Tce=class extends R_{constructor(){super(...arguments);ni(this,"matchedPort",null)}get config(){return{componentName:"TraceHint",zodProps:zqe}}doInitialPortMatching(){this.root;const{_parsedProps:e,parent:t}=this;if(!t)return;if(t.componentName==="Trace"){this.renderError(`Port inference inside trace is not yet supported (${this})`);return}if(!t)throw new Error("TraceHint has no parent");if(!e.for){this.renderError(`TraceHint has no for property (${this})`);return}const n=t.selectOne(e.for,{type:"port"});n||this.renderError(`${this} could not find port for selector "${e.for}"`),this.matchedPort=n,n.registerMatch(this)}getPcbRouteHints(){const{_parsedProps:e}=this,t=e.offset?[e.offset]:e.offsets;if(!t)return[];const n=this._computePcbGlobalTransformBeforeLayout();return t.map(i=>({...ui(n,i),via:i.via,to_layer:i.to_layer,trace_width:i.trace_width}))}doInitialPcbTraceHintRender(){var t,n,i;if((t=this.root)!=null&&t.pcbDisabled)return;const{db:e}=this.root;e.pcb_trace_hint.insert({pcb_component_id:(n=this.matchedPort)==null?void 0:n.pcb_component_id,pcb_port_id:(i=this.matchedPort)==null?void 0:i.pcb_port_id,route:this.getPcbRouteHints()})}},qI=class extends Dx{constructor(){super(...arguments);ni(this,"pcb_group_id",null);ni(this,"subcircuit_id",null);ni(this,"_hasStartedAsyncAutorouting",!1);ni(this,"_asyncAutoroutingResult",null)}get config(){return{zodProps:VGe,componentName:"Group"}}doInitialSourceRender(){const{db:t}=this.root,n=t.source_group.insert({name:this._parsedProps.name,is_subcircuit:this.isSubcircuit});this.subcircuit_id=`subcircuit_${n.source_group_id}`,this.source_group_id=n.source_group_id,t.source_group.update(n.source_group_id,{subcircuit_id:this.subcircuit_id})}doInitialSourceParentAttachment(){var i,a,o;const{db:t}=this.root;if(!this.isSubcircuit)return;const n=(o=(a=(i=this.parent)==null?void 0:i.getSubcircuit)==null?void 0:a.call(i))==null?void 0:o.subcircuit_id;n&&t.source_group.update(this.source_group_id,{parent_subcircuit_id:n})}doInitialPcbComponentRender(){var i;if((i=this.root)!=null&&i.pcbDisabled)return;const{db:t}=this.root,n=t.pcb_group.insert({is_subcircuit:this.isSubcircuit,subcircuit_id:this.subcircuit_id,name:this._parsedProps.name,center:this._getGlobalPcbPositionBeforeLayout(),width:0,height:0,pcb_component_ids:[],source_group_id:this.source_group_id});this.pcb_group_id=n.pcb_group_id}doInitialCreateTraceHintsFromProps(){var a;const{_parsedProps:t}=this;this.root;const n=t;if(!this.isSubcircuit)return;const i=(a=n.layout)==null?void 0:a.manual_trace_hints;if(i)for(const o of i)this.add(new Tce({for:o.pcb_port_selector,offsets:o.offsets}))}_getSimpleRouteJsonFromPcbTraces(){const t=this.selectAll("trace"),{db:n}=this.root;return PYe({db:n,traces:t,minTraceWidth:this._parsedProps.minTraceWidth??.1})}doInitialSourceAddConnectivityMapKey(){if(!this.isSubcircuit)return;const{db:t}=this.root,n=this.selectAll("trace"),i=new bA({});i.addConnections(n.map(a=>{const o=t.source_trace.get(a.source_trace_id);return o?[o.source_trace_id,...o.connected_source_port_ids,...o.connected_source_net_ids]:null}).filter(a=>a!==null));for(const a of n){if(!a.source_trace_id)continue;const o=i.getNetConnectedToId(a.source_trace_id);if(!o)continue;const{name:s}=this._parsedProps;a.subcircuit_connectivity_map_key=`${s??`unnamedsubcircuit${this._renderId}`}_${o}`,t.source_trace.update(a.source_trace_id,{subcircuit_connectivity_map_key:a.subcircuit_connectivity_map_key})}}_areChildSubcircuitsRouted(){const t=this.selectAll("group").filter(n=>n.isSubcircuit);for(const n of t)if(n._shouldRouteAsync()&&!n._asyncAutoroutingResult)return!1;return!0}_shouldRouteAsync(){const t=this._getAutorouterConfig();return!(t.local||t.groupMode==="sequential-trace")}_hasTracesToRoute(){const t=g2("tscircuit:core:_hasTracesToRoute"),n=this.selectAll("trace");return t(`[${this.getString()}] has ${n.length} traces to route`),n.length>0}async _runEffectMakeHttpAutoroutingRequest(){var c,u;const t=g2("tscircuit:core:_runEffectMakeHttpAutoroutingRequest");this._parsedProps;const n=this._getAutorouterConfig(),i=n.serverUrl,a=n.serverMode,o=(h,g)=>(t("fetching",h),fetch(h,g)),s=this.root.db.toArray().filter(h=>h.type.startsWith("source_")||h.type.startsWith("pcb_"));if(a==="solve-endpoint"){if(((c=this.props.autorouter)==null?void 0:c.inputFormat)==="simplified"){const{autorouting_result:g}=await o(`${i}/autorouting/solve`,{method:"POST",body:JSON.stringify({input_simple_route_json:this._getSimpleRouteJsonFromPcbTraces(),subcircuit_id:this.subcircuit_id}),headers:{"Content-Type":"application/json"}}).then(_=>_.json());this._asyncAutoroutingResult=g,this._markDirty("PcbTraceRender");return}const{autorouting_result:h}=await o(`${i}/autorouting/solve`,{method:"POST",body:JSON.stringify({input_circuit_json:s,subcircuit_id:this.subcircuit_id}),headers:{"Content-Type":"application/json"}}).then(g=>g.json());this._asyncAutoroutingResult=h,this._markDirty("PcbTraceRender");return}const{autorouting_job:l}=await o(`${i}/autorouting/jobs/create`,{method:"POST",body:JSON.stringify({input_circuit_json:s,provider:"freerouting",autostart:!0,display_name:(u=this.root)==null?void 0:u.name,subcircuit_id:this.subcircuit_id,server_cache_enabled:n.serverCacheEnabled}),headers:{"Content-Type":"application/json"}}).then(h=>h.json());for(;;){const{autorouting_job:h}=await o(`${i}/autorouting/jobs/get`,{method:"POST",body:JSON.stringify({autorouting_job_id:l.autorouting_job_id}),headers:{"Content-Type":"application/json"}}).then(g=>g.json());if(h.is_finished){const{autorouting_job_output:g}=await o(`${i}/autorouting/jobs/get_output`,{method:"POST",body:JSON.stringify({autorouting_job_id:l.autorouting_job_id}),headers:{"Content-Type":"application/json"}}).then(_=>_.json());this._asyncAutoroutingResult={output_pcb_traces:g.output_pcb_traces},this._markDirty("PcbTraceRender");break}if(h.has_error)throw new Error(`Autorouting job failed: ${JSON.stringify(h.error)}`);await new Promise(g=>setTimeout(g,100))}}_startAsyncAutorouting(){this._hasStartedAsyncAutorouting=!0,this._queueAsyncEffect("make-http-autorouting-request",async()=>this._runEffectMakeHttpAutoroutingRequest())}doInitialPcbTraceRender(){var n;const t=g2("tscircuit:core:doInitialPcbTraceRender");if(this.isSubcircuit&&!((n=this.root)!=null&&n.pcbDisabled)&&!this.getInheritedProperty("routingDisabled")&&!this._shouldUseTraceByTraceRouting()){if(!this._areChildSubcircuitsRouted()){t(`[${this.getString()}] child subcircuits are not routed, skipping async autorouting until subcircuits routed`);return}t(`[${this.getString()}] no child subcircuits to wait for, initiating async routing`),this._hasTracesToRoute()&&this._startAsyncAutorouting()}}updatePcbTraceRender(){const t=g2("tscircuit:core:updatePcbTraceRender");if(this.isSubcircuit){if(this._shouldRouteAsync()&&this._hasTracesToRoute()&&!this._hasStartedAsyncAutorouting){this._areChildSubcircuitsRouted()&&(t(`[${this.getString()}] child subcircuits are now routed, starting async autorouting`),this._startAsyncAutorouting());return}if(this._asyncAutoroutingResult&&!this._shouldUseTraceByTraceRouting()){if(this.root,this._asyncAutoroutingResult.output_simple_route_json){this._updatePcbTraceRenderFromSimpleRouteJson();return}if(this._asyncAutoroutingResult.output_pcb_traces){this._updatePcbTraceRenderFromPcbTraces();return}}}}_updatePcbTraceRenderFromSimpleRouteJson(){const{db:t}=this.root,{traces:n}=this._asyncAutoroutingResult.output_simple_route_json;if(n){this.selectAll("trace");for(const i of n)t.pcb_trace.insert({route:i.route})}}_updatePcbTraceRenderFromPcbTraces(){const{output_pcb_traces:t}=this._asyncAutoroutingResult;if(!t)return;const{db:n}=this.root;for(const i of t)n.pcb_trace.insert(i)}doInitialSchematicLayout(){if(!this.isSubcircuit||!this._parsedProps.schAutoLayoutEnabled)return;const{db:n}=this.root,i=this.getDescendants(),a=[];for(const l of i)if("schematic_component_id"in l){const c=n.schematic_component.get(l.schematic_component_id);if(c){const u=n.schematic_port.list().filter(h=>h.schematic_component_id===c.schematic_component_id);a.push(...u)}}const o=Zqe(n.toArray()),s=aYe(o);$qe(n.toArray(),s)}_getAutorouterConfig(){const t={serverUrl:"https://registry-api.tscircuit.com",serverMode:"job",serverCacheEnabled:!1},n=this._parsedProps.autorouter??this.getInheritedProperty("autorouter");return typeof n=="object"?{local:!(n.serverUrl||n.serverMode||n.serverCacheEnabled),...t,...n}:n==="auto-local"?{local:!0}:n==="sequential-trace"?{local:!0,groupMode:"sequential-trace"}:{local:!0,groupMode:"sequential-trace"}}_shouldUseTraceByTraceRouting(){return this._getAutorouterConfig().groupMode==="sequential-trace"}},NYe=class extends qI{constructor(){super(...arguments);ni(this,"pcb_board_id",null)}get isSubcircuit(){return!0}get config(){return{componentName:"Board",zodProps:jGe}}get boardThickness(){return 1.4}get allLayers(){return["top","bottom","inner1","inner2"]}doInitialPcbBoardAutoSize(){var h;if((h=this.root)!=null&&h.pcbDisabled||!this.pcb_board_id)return;const{db:e}=this.root,{_parsedProps:t}=this;if(t.width&&t.height)return;let n=1/0,i=1/0,a=-1/0,o=-1/0;for(const g of this.children){if(!g.pcb_component_id)continue;const _=e.pcb_component.get(g.pcb_component_id);if(!_)continue;const{width:b,height:T,center:C}=_;b===0||T===0||(n=Math.min(n,C.x-b/2),i=Math.min(i,C.y-T/2),a=Math.max(a,C.x+b/2),o=Math.max(o,C.y+T/2))}const s=2,l=a-n+s*2,c=o-i+s*2,u={x:(n+a)/2+(t.outlineOffsetX??0),y:(i+o)/2+(t.outlineOffsetY??0)};e.pcb_board.update(this.pcb_board_id,{width:l,height:c,center:u})}doInitialPcbComponentRender(){var o,s;if((o=this.root)!=null&&o.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this;let n=t.width??0,i=t.height??0;if(t.outline){const l=t.outline.map(b=>b.x),c=t.outline.map(b=>b.y),u=Math.min(...l),h=Math.max(...l),g=Math.min(...c),_=Math.max(...c);n=h-u,i=_-g}const a=e.pcb_board.insert({center:{x:(t.pcbX??0)+(t.outlineOffsetX??0),y:(t.pcbY??0)+(t.outlineOffsetY??0)},thickness:this.boardThickness,num_layers:this.allLayers.length,width:n,height:i,outline:(s=t.outline)==null?void 0:s.map(l=>({x:l.x+(t.outlineOffsetX??0),y:l.y+(t.outlineOffsetY??0)}))});this.pcb_board_id=a.pcb_board_id}removePcbComponentRender(){const{db:e}=this.root;this.pcb_board_id&&(e.pcb_board.delete(this.pcb_board_id),this.pcb_board_id=null)}_computePcbGlobalTransformBeforeLayout(){return C_()}},LYe=new Proxy({},{get:(r,e)=>e}),bT=LYe,Mce=class{constructor({input:r}){ni(this,"input");this.input=r}solveAndMapToTraces(){const r=[];for(const e of this.input.connections){if(e.pointsToConnect.length!==2)continue;const[t,n]=e.pointsToConnect,i={type:"pcb_trace",pcb_trace_id:"",route:[{route_type:"wire",x:t.x,y:t.y,layer:"top",width:.1},{route_type:"wire",x:n.x,y:n.y,layer:"top",width:.1}]};r.push(i)}return r}},OYe=r=>{const e=Math.min(...r.map(a=>a.center.x)),t=Math.max(...r.map(a=>a.center.x)),n=Math.min(...r.map(a=>a.center.y)),i=Math.max(...r.map(a=>a.center.y));return{minX:e,maxX:t,minY:n,maxY:i}},Cce=["top","bottom","inner1","inner2"],LA=(r,e=[])=>{var s;const t=[];if(e.length===0){const l=r[0].layers;for(const c of l)t.push(...LA(r.slice(1),[c]));return t}if(r.length===0)return[];const n=r[0],i=n.via||n.optional_via,a=e[e.length-1];if(r.length===1){const l=n;return l.layers&&i?l.layers.map(c=>({layer_path:[...e,c]})):(s=l.layers)!=null&&s.includes(a)?[{layer_path:[...e,a]}]:[]}if(!i)return n.layers&&!n.layers.includes(a)?[]:LA(r.slice(1),e.concat([a]));const o=(n.optional_via?Cce:Cce.filter(l=>l!==a)).filter(l=>{var c;return!n.layers||((c=n.layers)==null?void 0:c.includes(l))});for(const l of o)t.push(...LA(r.slice(1),e.concat(l)));return t};function Rce(r){const e={x:r.to.x-r.from.x,y:r.to.y-r.from.y},t=Math.abs(e.x),n=Math.abs(e.y);return t>n?e.x>0?"right":"left":e.y>0?"down":"up"}function B8(r,e){return Math.hypot(r.x-e.x,r.y-e.y)}var UYe=r=>{if(r.length===1)return r[0];if(r.some(l=>l.length===0))throw new Error("Cannot merge routes with zero length");const e=[],t=r[0][0],n=r[0][r[0].length-1],i=r[1][0],a=r[1][r[1].length-1],o=Math.min(B8(t,i),B8(t,a)),s=Math.min(B8(n,i),B8(n,a));o<s?e.push(...r[0].reverse()):e.push(...r[0]);for(let l=1;l<r.length;l++){const c=e[e.length-1],u=r[l],h=u[0],g=u[u.length-1],_=B8(c,h),b=B8(c,g);_<b?e.push(...u):e.push(...u.reverse())}for(let l=1;l<e.length-1;l++){const c=e[l-1],u=e[l];c.route_type==="wire"&&u.route_type==="wire"&&c.layer!==u.layer&&e.splice(l,0,{x:c.x,y:c.y,from_layer:c.layer,to_layer:u.layer,route_type:"via"})}return e},zYe=(r,e)=>{const t="_getGlobalPcbPositionBeforeLayout"in r?r._getGlobalPcbPositionBeforeLayout():r,n="_getGlobalPcbPositionBeforeLayout"in e?e._getGlobalPcbPositionBeforeLayout():e;return Math.sqrt((t.x-n.x)**2+(t.y-n.y)**2)};function FYe(r,e){if(e.length===0)throw new Error("No candidates given to getClosest method");let t=e[0],n=1/0;for(const i of e){const a=zYe(r,i);a<n&&(t=i,n=a)}return t}var IYe=(r,e)=>{let t=0;t+=r.length??0,t+=e.filter(n=>n.is_crossing).length;for(let n=1;n<e.length;n++){const i=e[n-1],a=e[n],o=Math.abs(i.from.x-i.to.x)<.01,s=Math.abs(a.from.x-a.to.x)<.01;o!==s&&t++}return t},YI=r=>({up:"bottom",down:"top",left:"right",right:"left"})[r]??null,XI=({firstEdge:r,firstEdgePort:e,firstDominantDirection:t,lastEdge:n,lastEdgePort:i,lastDominantDirection:a})=>{if(r&&e)return XI({lastEdge:{from:r.to,to:r.from},lastEdgePort:e,lastDominantDirection:t}).reverse().map(s=>({from:s.to,to:s.from}));let o=[];if(n&&i){const s={x:n.to.x,y:n.to.y};a==="left"||a==="right"?(s.x=i.position.x,o.push({from:n.to,to:{...s}}),o.push({from:s,to:{...i.position}})):(s.y=i.position.y,o.push({from:n.to,to:{...s}}),o.push({from:s,to:{...i.position}}))}return o=o.filter(s=>yT(s.from,s.to)>.01),o};function kYe(r){try{return[r(),null]}catch(e){return[null,e]}}function BYe(r){let e=0;for(let t=0;t<r.length;t++){const n=r[t];if(n.route_type==="wire"){const i=r[t+1];if(i){const a=i.x-n.x,o=i.y-n.y;e+=Math.sqrt(a*a+o*o)}}else n.route_type==="via"&&(e+=1.6)}return e}var HYe=r=>{var s,l;const e={left:{x:-.5,y:0},up:{x:.5,y:.5},right:{x:.5,y:0},down:{x:0,y:-.5}}[r.facingDirection],t=(s=r.parent)!=null&&s.config.shouldRenderAsSchematicBox?3:1,n=(l=r.parent)!=null&&l.config.shouldRenderAsSchematicBox&&(r.facingDirection==="left"||r.facingDirection==="right")?3:1,i=e.x,a=e.y,o=r.facingDirection==="up"?.5:0;return{schBoxVertOffset:t,schBoxHorzOffset:n,horzPortDirection:i,vertPortDirectionOffset:a,handleUp:o}},OA=({port:r,anchorPos:e,schDisplayLabel:t,source_trace_id:n},{db:i})=>{const a=HYe(r);i.schematic_net_label.insert({anchor_side:"top",center:{x:e.x+a.horzPortDirection*a.schBoxHorzOffset,y:e.y+a.vertPortDirectionOffset*a.schBoxVertOffset},source_net_id:r.source_port_id,text:t,anchor_position:{x:e.x+a.horzPortDirection*a.schBoxHorzOffset,y:e.y+a.vertPortDirectionOffset*a.schBoxVertOffset},symbol_name:"ground_horz"}),i.schematic_trace.insert({edges:[{from:{x:e.x,y:e.y},to:{x:e.x,y:e.y+a.handleUp*a.schBoxVertOffset}},{from:{x:e.x,y:e.y},to:{x:e.x+a.horzPortDirection*a.schBoxHorzOffset,y:e.y+a.vertPortDirectionOffset*a.schBoxVertOffset}}],junctions:[{x:e.x+a.horzPortDirection*a.schBoxHorzOffset,y:e.y+a.vertPortDirectionOffset*a.schBoxVertOffset}],source_trace_id:n})},WI=({db:r,source_trace_id:e,sameNetOnly:t,differentNetOnly:n})=>{!t&&!n&&(n=!0);const i=r.source_trace.get(e),a=[];for(const o of r.schematic_trace.list()){if(o.source_trace_id===e)continue;const s=r.source_trace.get(o.source_trace_id),l=(s==null?void 0:s.subcircuit_connectivity_map_key)===i.subcircuit_connectivity_map_key;n&&l||t&&!l||a.push(o)}return a},VYe=({edges:r,otherEdges:e})=>{const t=[...r];for(let n=0;n<t.length;n++){if(n>2e3)throw new Error("Over 2000 iterations spent inside createSchematicTraceCrossingSegments, you have triggered an infinite loop, please report this!");const i=t[n],a=Math.abs(i.from.x-i.to.x)<.01?"vertical":i.from.y===i.to.y?"horizontal":"not-orthogonal";if(a==="not-orthogonal")continue;const o=[];for(const T of e){const C=T.from.x===T.to.x?"vertical":T.from.y===T.to.y?"horizontal":"not-orthogonal";if(C==="not-orthogonal"||a===C)continue;if(cce([i.from,i.to],[T.from,T.to],{lineThickness:.01})){const L=a==="vertical"?i.from.x:T.from.x,U=a==="vertical"?T.from.y:i.from.y,j={x:L,y:U};o.push({otherEdge:T,crossingPoint:j,distanceFromEdgeFrom:yT(i.from,j)})}}if(o.length===0)continue;let s=o[0];for(const T of o)T.distanceFromEdgeFrom<s.distanceFromEdgeFrom&&(s=T);const l=s.crossingPoint,c=.075;if(l.x===i.from.x&&l.y===i.from.y)continue;const u=oYe(i.from,l),h={x:l.x-u.x*c/2,y:l.y-u.y*c/2},g={x:l.x+u.x*c/2,y:l.y+u.y*c/2},_=yT(g,i.to)<c,b=[{from:i.from,to:h},{from:h,to:g,is_crossing:!0},{from:g,to:i.to}];t.splice(n,1,...b),n+=b.length-2,_&&n++}return t},jYe=(r,e)=>{if(r.from.x===r.to.x&&e.from.x===e.to.x)return null;if(r.from.x===r.to.x){const u=r.from.x,h=(e.to.y-e.from.y)/(e.to.x-e.from.x),g=e.from.y-h*e.from.x,_=h*u+g;return u>=Math.min(e.from.x,e.to.x)&&u<=Math.max(e.from.x,e.to.x)&&_>=Math.min(e.from.y,e.to.y)&&_<=Math.max(e.from.y,e.to.y)?{x:u,y:_}:null}if(e.from.x===e.to.x){const u=e.from.x,h=(r.to.y-r.from.y)/(r.to.x-r.from.x),g=r.from.y-h*r.from.x,_=h*u+g;return u>=Math.min(r.from.x,r.to.x)&&u<=Math.max(r.from.x,r.to.x)&&_>=Math.min(r.from.y,r.to.y)&&_<=Math.max(r.from.y,r.to.y)?{x:u,y:_}:null}const t=(r.to.y-r.from.y)/(r.to.x-r.from.x),n=r.from.y-t*r.from.x,i=(e.to.y-e.from.y)/(e.to.x-e.from.x),a=e.from.y-i*e.from.x;if(t===i)return null;const o=(a-n)/(t-i),s=t*o+n,l=o>=Math.min(r.from.x,r.to.x)&&o<=Math.max(r.from.x,r.to.x)&&s>=Math.min(r.from.y,r.to.y)&&s<=Math.max(r.from.y,r.to.y),c=o>=Math.min(e.from.x,e.to.x)&&o<=Math.max(e.from.x,e.to.x)&&s>=Math.min(e.from.y,e.to.y)&&s<=Math.max(e.from.y,e.to.y);return l&&c?{x:o,y:s}:null},GYe=({edges:r,db:e,source_trace_id:t})=>{const n=WI({db:e,source_trace_id:t,sameNetOnly:!0}).flatMap(i=>i.edges);for(const i of r)for(const a of n){const o=jYe(i,a);if(o)return`${o.x}${o.y}`,[{x:o.x,y:o.y}]}return[]},qYe=(r,{db:e})=>{const t=r.map(n=>{const i=e.source_port.get(n.source_port_id);if(!(i!=null&&i.source_component_id))return null;const a=e.source_component.get(i.source_component_id);return(a==null?void 0:a.ftype)==="simple_capacitor"?a.max_decoupling_trace_length:null}).filter(n=>n!==null);if(t.length!==0)return Math.min(...t)},YYe=r=>{var a;const e=r.root.db,t=r._findConnectedPorts().ports??[],n=new Set(t.map(o=>o.schematic_port_id)),i=[];for(const o of e.toArray()){if(o.type==="schematic_component"){const s=!!o.symbol_name,l=o.size.width>o.size.height?"horz":"vert";i.push({type:"rect",layers:["top"],center:o.center,width:o.size.width+(s&&l==="horz"?-.5:0),height:o.size.height+(s&&l==="vert"?-.5:0),connectedTo:[]})}if(o.type==="schematic_port"){if(n.has(o.schematic_port_id))continue;const s=o.facing_direction?sYe(o.facing_direction):{x:0,y:0};i.push({type:"rect",layers:["top"],center:{x:o.center.x-s.x*.1,y:o.center.y-s.y*.1},width:.1+Math.abs(s.x)*.3,height:.1+Math.abs(s.y)*.3,connectedTo:[]})}o.type==="schematic_text"&&i.push({type:"rect",layers:["top"],center:o.position,width:(((a=o.text)==null?void 0:a.length)??0)*.1,height:.2,connectedTo:[]}),o.type==="schematic_box"&&i.push({type:"rect",layers:["top"],center:{x:o.x,y:o.y},width:o.width,height:o.height,connectedTo:[]})}return i};function XYe({ports:r,nets:e}){var t,n,i;if(r.length>=2)return`${(t=r[0])==null?void 0:t.selector} to ${(n=r[1])==null?void 0:n.selector}`;if(r.length===1&&e.length===1)return`${(i=r[0])==null?void 0:i.selector} to net.${e[0]._parsedProps.name}`}var WYe=({edges:r,db:e,source_trace_id:t})=>{e.source_trace.get(t);const n=WI({db:e,source_trace_id:t,differentNetOnly:!0}).flatMap(a=>a.edges),i=a=>{const{from:o,to:s}=a;return o.x===s.x?"vertical":"horizontal"};for(const a of r){const o=i(a),s=()=>n.find(c=>i(c)===o&&cce([a.from,a.to],[c.from,c.to],{lineThickness:.05}));let l=s();for(;l;)o==="horizontal"?(a.from.y+=.1,a.to.y+=.1):(a.from.x+=.1,a.to.x+=.1),l=s()}},UA=r=>({...r._getGlobalPcbPositionAfterLayout(),layers:r.getAvailablePcbLayers()}),qS=class extends R_{constructor(e){super(e);ni(this,"source_trace_id",null);ni(this,"pcb_trace_id",null);ni(this,"schematic_trace_id",null);ni(this,"_portsRoutedOnPcb");ni(this,"subcircuit_connectivity_map_key",null);this._portsRoutedOnPcb=[]}get config(){return{zodProps:hqe,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(){this.root;const{_parsedProps:e,parent:t}=this;if(!t)throw new Error("Trace has no parent");const i=this.getTracePortPathSelectors().map(a=>({selector:a,port:this.getSubcircuit().selectOne(a,{type:"port"})??null}));for(const{selector:a,port:o}of i)if(!o){const s=a.replace(/\>.*$/,""),l=this.getSubcircuit().selectOne(s);l?this.renderError(`Could not find port for selector "${a}" (did you forget to include the pin name?)
|
|
642
642
|
searched component ${l.getString()}, which has ports: ${l.children.filter(c=>c.componentName==="Port").map(c=>`${c.getString()}(${c.getNameAndAliases().join(",")})`).join(" & ")}`):this.renderError(`Could not find port for selector "${a}"`)}return i.some(a=>!a.port)?{allPortsFound:!1}:{allPortsFound:!0,portsWithSelectors:i,ports:i.map(({port:a})=>a)}}_findConnectedNets(){const e=this.getTracePathNetSelectors().map(n=>({selector:n,net:this.getSubcircuit().selectOne(n,{type:"net"})})),t=e.filter(n=>!n.net);return t.length>0&&this.renderError(`Could not find net for selector "${t[0].selector}" inside ${this}`),{netsWithSelectors:e,nets:e.map(n=>n.net)}}_getAllTracesConnectedToSameNet(){const e=this.getSubcircuit().selectAll("trace"),t=this._findConnectedNets().nets,n=this._findConnectedPorts().ports??[];return e.filter(i=>{if(i===this)return!1;const a=i._findConnectedNets().nets,o=i._findConnectedPorts().ports??[];return a.some(s=>t.includes(s))||o.some(s=>n.includes(s))})}_isExplicitlyConnectedToPort(e){const{allPortsFound:t,portsWithSelectors:n}=this._findConnectedPorts();return t?n.map(a=>a.port).includes(e):!1}_isExplicitlyConnectedToNet(e){return this._findConnectedNets().nets.includes(e)}doInitialCreateNetsFromProps(){gce(this,this.getTracePathNetSelectors())}doInitialSourceTraceRender(){var c;const{db:e}=this.root,{_parsedProps:t,parent:n}=this;if(!n){this.renderError("Trace has no parent");return}const{allPortsFound:i,portsWithSelectors:a}=this._findConnectedPorts();if(!i)return;const o=this._findConnectedNets().nets,s=XYe({ports:a,nets:o}),l=e.source_trace.insert({connected_source_port_ids:a.map(u=>u.port.source_port_id),connected_source_net_ids:o.map(u=>u.source_net_id),subcircuit_id:(c=this.getSubcircuit())==null?void 0:c.subcircuit_id,max_length:qYe(a.map(u=>u.port),{db:e})??t.maxLength,display_name:s});this.source_trace_id=l.source_trace_id}doInitialPcbTraceRender(){var oe,ae,ce,me;if((oe=this.root)!=null&&oe.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t,parent:n}=this,i=this.getSubcircuit();if(!n)throw new Error("Trace has no parent");if(i._parsedProps.routingDisabled)return;const a=(ae=i._parsedProps.pcbRouteCache)==null?void 0:ae.pcbTraces;if(a){const _e=e.pcb_trace.insert({route:a.flatMap(Se=>Se.route),source_trace_id:this.source_trace_id,subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0,pcb_group_id:((ce=this.getGroup())==null?void 0:ce.pcb_group_id)??void 0});this.pcb_trace_id=_e.pcb_trace_id;return}if(!i._shouldUseTraceByTraceRouting())return;const{allPortsFound:o,ports:s}=this._findConnectedPorts();if(!o)return;const l=[];for(const _e of s)_e._hasMatchedPcbPrimitive()||l.push(_e);if(l.length>0){e.pcb_trace_error.insert({error_type:"pcb_trace_error",source_trace_id:this.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, ${this} wasn't routed. Missing ports: ${l.map(_e=>_e.getString()).join(", ")}`,pcb_trace_id:this.pcb_trace_id,pcb_component_ids:[],pcb_port_ids:l.map(_e=>_e.pcb_port_id).filter(Boolean)});return}const c=this._findConnectedNets().netsWithSelectors;if(s.length===0&&c.length===2){this.renderError("Trace connects two nets, we haven't implemented a way to route this yet");return}else if(s.length===1&&c.length===1){const _e=s[0],Ae=c[0].net.getAllConnectedPorts().filter(Ne=>Ne!==_e);if(Ae.length===0){console.log("Nothing to connect this port to, the net is empty. TODO should emit a warning!");return}const ze=FYe(_e,Ae);s.push(ze)}else if(s.length>1&&c.length>=1){this.renderError("Trace has more than one port and one or more nets, we don't currently support this type of complex trace routing");return}const u=s.flatMap(_e=>_e.matchedComponents.filter(Se=>Se.componentName==="TraceHint")),h=(this._parsedProps.pcbRouteHints??[]).concat(u.flatMap(_e=>_e.getPcbRouteHints()));if(s.length>2){this.renderError(`Trace has more than two ports (${s.map(_e=>_e.getString()).join(", ")}), routing between more than two ports for a single trace is not implemented`);return}if(this.getSubcircuit().selectAll("trace").filter(_e=>_e.renderPhaseStates.PcbTraceRender.initialized).some(_e=>_e._portsRoutedOnPcb.length===s.length&&_e._portsRoutedOnPcb.every(Se=>s.includes(Se))))return;let b=[];h.length===0?b=[UA(s[0]),UA(s[1])]:b=[UA(s[0]),...h,UA(s[1])];const T=LA(b),C=Lle(this.root.db.toArray()),[A,L]=kYe(()=>$le(this.root.db.toArray()));if(L){this.renderError({type:"pcb_trace_error",error_type:"pcb_trace_error",pcb_trace_error_id:this.pcb_trace_id,message:`Error getting obstacles for autorouting: ${L.message}`,source_trace_id:this.source_trace_id,center:{x:0,y:0},pcb_port_ids:s.map(_e=>_e.pcb_port_id),pcb_trace_id:this.pcb_trace_id,pcb_component_ids:[]});return}for(const _e of A)if(_e.connectedTo.length>0){const Ae=C.getNetConnectedToId(_e.connectedTo[0]);Ae&&_e.connectedTo.push(Ae)}let U=[];if(T.length===0)U=b;else{const _e=T[0].layer_path;U=b.map((Se,Ae)=>Se.via?{...Se,via_to_layer:_e[Ae]}:{...Se,layers:[_e[Ae]]})}U[0].pcb_port_id=s[0].pcb_port_id,U[U.length-1].pcb_port_id=s[1].pcb_port_id;const j=[];for(const[_e,Se]of vce(U)){const Ae="via_to_layer"in _e?_e.via_to_layer:null,ze=2,Ne="layers"in _e&&_e.layers.length===1?_e.layers[0]:Ae??"top",Oe="layers"in Se&&Se.layers.length===1?Se.layers[0]:Ae??"top",Le="pcb_port_id"in _e?_e.pcb_port_id:null,Ie="pcb_port_id"in Se?Se.pcb_port_id:null,je=this.getSubcircuit()._parsedProps.minTraceWidth??.16,Ue=new Wle({OBSTACLE_MARGIN:je*2,isRemovePathLoopsEnabled:!0,optimizeWithGoalBoxes:!!(Le&&Ie),connMap:C,input:{obstacles:A,minTraceWidth:je,connections:[{name:this.source_trace_id,pointsToConnect:[{..._e,layer:Ne,pcb_port_id:Le},{...Se,layer:Oe,pcb_port_id:Ie}]}],layerCount:2,bounds:{minX:Math.min(_e.x,Se.x)-ze,maxX:Math.max(_e.x,Se.x)+ze,minY:Math.min(_e.y,Se.y)-ze,maxY:Math.max(_e.y,Se.y)+ze}}});let Fe=null;try{Fe=Ue.solveAndMapToTraces()}catch(ft){this.renderError({type:"pcb_trace_error",pcb_trace_error_id:this.source_trace_id,error_type:"pcb_trace_error",message:`error solving route: ${ft.message}`,source_trace_id:this.pcb_trace_id,center:{x:(_e.x+Se.x)/2,y:(_e.y+Se.y)/2},pcb_port_ids:s.map(Nt=>Nt.pcb_port_id),pcb_trace_id:this.pcb_trace_id,pcb_component_ids:s.map(Nt=>Nt.pcb_component_id)})}if(!Fe)return;if(Fe.length===0){this.renderError({type:"pcb_trace_error",error_type:"pcb_trace_error",pcb_trace_error_id:this.pcb_trace_id,message:`Could not find a route for ${this}`,source_trace_id:this.source_trace_id,center:{x:(_e.x+Se.x)/2,y:(_e.y+Se.y)/2},pcb_port_ids:s.map(ft=>ft.pcb_port_id),pcb_trace_id:this.pcb_trace_id,pcb_component_ids:s.map(ft=>ft.pcb_component_id)});return}const[it]=Fe;Ae&&(it.route=it.route.map(ft=>(ft.route_type==="wire"&&!ft.layer&&(ft.layer=Ae),ft))),Le&&it.route[0].route_type==="wire"&&(it.route[0].start_pcb_port_id=Le);const ct=it.route[it.route.length-1];Ie&&ct.route_type==="wire"&&(ct.end_pcb_port_id=Ie),j.push(it.route)}const Z=UYe(j),ee=BYe(Z),$=e.pcb_trace.insert({route:Z,source_trace_id:this.source_trace_id,subcircuit_id:(me=this.getSubcircuit())==null?void 0:me.subcircuit_id,trace_length:ee});this._portsRoutedOnPcb=s,this.pcb_trace_id=$.pcb_trace_id;for(const _e of Z)_e.route_type==="via"&&e.pcb_via.insert({pcb_trace_id:$.pcb_trace_id,x:_e.x,y:_e.y,hole_diameter:.3,outer_diameter:.6,layers:[_e.from_layer,_e.to_layer],from_layer:_e.from_layer,to_layer:_e.to_layer})}_doInitialSchematicTraceRenderWithDisplayLabel(){var j,Z,ee,$;if((j=this.root)!=null&&j.schematicDisabled)return;const{db:e}=this.root,{_parsedProps:t,parent:n}=this;if(!n)throw new Error("Trace has no parent");const{allPortsFound:i,portsWithSelectors:a}=this._findConnectedPorts();if(!i)return;const o=a.map(({port:oe})=>({port:oe,position:oe._getGlobalSchematicPositionAfterLayout(),schematic_port_id:oe.schematic_port_id,facingDirection:oe.facingDirection}));if(o.length<2)throw new Error("Expected at least two ports in portsWithPosition.");let s,l;const c=o[0].position,u=o[0].port;if("path"in this.props){if(this.props.path.length!==2)throw new Error("Invalid 'path': Must contain exactly two elements.");[s,l]=this.props.path}else{if(!("from"in this.props&&"to"in this.props))throw new Error("Missing 'from' or 'to' properties in props.");s=this.props.from,l=this.props.to}if(!u.source_port_id)throw new Error(`Missing source_port_id for the 'from' port (${s}).`);const h=o[1].position,g=o[1].port;if(!g.source_port_id)throw new Error(`Missing source_port_id for the 'to' port (${l}).`);const _=e.schematic_net_label.list().find(oe=>oe.source_net_id===u.source_port_id),b=e.schematic_net_label.list().find(oe=>oe.source_net_id===g.source_port_id),[T,C]=a.map(({port:oe})=>oe),L=((Z=T.parent)==null?void 0:Z.config.shouldRenderAsSchematicBox)?`${(ee=T==null?void 0:T.parent)==null?void 0:ee.props.name}_${T==null?void 0:T.props.name}`:`${($=C==null?void 0:C.parent)==null?void 0:$.props.name}_${C==null?void 0:C.props.name}`,U=this.props.schDisplayLabel??L;if(_&&_.text!==U&&(_.text=`${U} / ${_.text}`),b&&(b==null?void 0:b.text)!==U&&(b.text=`${U} / ${b.text}`),U!=null&&U.toLocaleLowerCase().includes("gnd")||U!=null&&U.toLocaleLowerCase().includes("ground")){!_&&!b?(OA({port:u,anchorPos:c,schDisplayLabel:this.props.schDisplayLabel,source_trace_id:this.source_trace_id},{db:e}),OA({port:g,anchorPos:h,schDisplayLabel:this.props.schDisplayLabel,source_trace_id:this.source_trace_id},{db:e})):_?b||OA({port:g,anchorPos:h,schDisplayLabel:this.props.schDisplayLabel,source_trace_id:this.source_trace_id},{db:e}):OA({port:u,anchorPos:c,schDisplayLabel:this.props.schDisplayLabel,source_trace_id:this.source_trace_id},{db:e});return}b||e.schematic_net_label.insert({text:this.props.schDisplayLabel??L,source_net_id:g.source_port_id,anchor_position:h,center:h,anchor_side:YI(g.facingDirection)??"bottom"}),_||e.schematic_net_label.insert({text:this.props.schDisplayLabel??L,source_net_id:u.source_port_id,anchor_position:c,center:c,anchor_side:YI(u.facingDirection)??"bottom"})}_isSymbolToChipConnection(){const{allPortsFound:e,ports:t}=this._findConnectedPorts();if(!e||t.length!==2)return!1;const[n,i]=t;if(!(n!=null&&n.parent)||!(i!=null&&i.parent))return!1;const a=n.parent.config.shouldRenderAsSchematicBox,o=i.parent.config.shouldRenderAsSchematicBox;return a&&!o||!a&&o}_isSymbolToSymbolConnection(){const{allPortsFound:e,ports:t}=this._findConnectedPorts();if(!e||t.length!==2)return!1;const[n,i]=t;if(!(n!=null&&n.parent)||!(i!=null&&i.parent))return!1;const a=!n.parent.config.shouldRenderAsSchematicBox,o=!i.parent.config.shouldRenderAsSchematicBox;return a&&o}_isChipToChipConnection(){const{allPortsFound:e,ports:t}=this._findConnectedPorts();if(!e||t.length!==2)return!1;const[n,i]=t;if(!(n!=null&&n.parent)||!(i!=null&&i.parent))return!1;const a=n.parent.config.shouldRenderAsSchematicBox,o=i.parent.config.shouldRenderAsSchematicBox;return a&&o}doInitialSchematicTraceRender(){var Se;if((Se=this.root)!=null&&Se.schematicDisabled)return;const{db:e}=this.root,{_parsedProps:t,parent:n}=this;if(!n)throw new Error("Trace has no parent");const{allPortsFound:i,portsWithSelectors:a}=this._findConnectedPorts(),{netsWithSelectors:o}=this._findConnectedNets();if(!i)return;if(this.props.schDisplayLabel&&("from"in this.props&&"to"in this.props||"path"in this.props)){this._doInitialSchematicTraceRenderWithDisplayLabel();return}const s={name:this.source_trace_id,pointsToConnect:[]},l=YYe(this),c=a.map(({port:Ae})=>({port:Ae,position:Ae._getGlobalSchematicPositionAfterLayout(),schematic_port_id:Ae.schematic_port_id??void 0,facingDirection:Ae.facingDirection}));if(c.length===1&&o.length===1){const Ae=o[0].net,{port:ze,position:Ne}=c[0];e.schematic_net_label.insert({text:Ae._parsedProps.name,source_net_id:Ae.source_net_id,anchor_position:Ne,center:Ne,anchor_side:YI(ze.facingDirection)??"bottom"});return}if(c.length<2)return;s.pointsToConnect=c.map(({position:Ae})=>({...Ae,layer:"top"}));const h=OYe(l),g=2,_={minTraceWidth:.1,obstacles:l,connections:[s],bounds:{minX:h.minX-g,maxX:h.maxX+g,minY:h.minY-g,maxY:h.maxY+g},layerCount:1};let b=Wle,T=!1;this.getSubcircuit().props._schDirectLineRoutingEnabled&&(b=Mce,T=!0);let A=new b({input:_,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(A.length===0){if(this._isSymbolToChipConnection()||this._isSymbolToSymbolConnection()||this._isChipToChipConnection()){this._doInitialSchematicTraceRenderWithDisplayLabel();return}A=new Mce({input:_}).solveAndMapToTraces(),T=!0}const[{route:L}]=A;let U=[];for(let Ae=0;Ae<L.length-1;Ae++)U.push({from:L[Ae],to:L[Ae+1]});const j=this.source_trace_id;let Z=[];if(!T){WYe({edges:U,db:e,source_trace_id:j});const Ae=WI({db:e,source_trace_id:j,differentNetOnly:!0}).flatMap(ze=>ze.edges);U=VYe({edges:U,otherEdges:Ae}),Z=GYe({edges:U,db:e,source_trace_id:this.source_trace_id})}const ee=U[U.length-1],$=c[c.length-1],oe=Rce(ee);U.push(...XI({lastEdge:ee,lastEdgePort:$,lastDominantDirection:oe}));const ae=U[0],ce=c[0],me=Rce(ae);if(U.unshift(...XI({firstEdge:ae,firstEdgePort:ce,firstDominantDirection:me})),!this.source_trace_id)throw new Error("Missing source_trace_id for schematic trace insertion.");if(this.getSubcircuit()._parsedProps.schTraceAutoLabelEnabled&&IYe(Z,U)>=5&&(this._isSymbolToChipConnection()||this._isSymbolToSymbolConnection()||this._isChipToChipConnection())){this._doInitialSchematicTraceRenderWithDisplayLabel();return}const _e=e.schematic_trace.insert({source_trace_id:this.source_trace_id,edges:U,junctions:Z});this.schematic_trace_id=_e.schematic_trace_id}},$Ye=class extends Dx{get config(){return{componentName:"Capacitor",schematicSymbolName:this.props.polarized?"capacitor_polarized":this.props.symbolName??"capacitor",zodProps:JGe,sourceFtype:bT.simple_capacitor}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}_getSchematicSymbolDisplayValue(){const r=`${PA(this._parsedProps.capacitance)}F`;return this._parsedProps.schShowRatings&&this._parsedProps.maxVoltageRating?`${r}/${PA(this._parsedProps.maxVoltageRating)}V`:r}doInitialCreateNetsFromProps(){this._createNetsFromProps([this.props.decouplingFor,this.props.decouplingTo])}doInitialCreateTracesFromProps(){this.props.decouplingFor&&this.props.decouplingTo&&(this.add(new qS({from:`${this.getSubcircuitSelector()} > port.1`,to:this.props.decouplingFor})),this.add(new qS({from:`${this.getSubcircuitSelector()} > port.2`,to:this.props.decouplingTo})))}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({ftype:"simple_capacitor",name:e.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()});this.source_component_id=t.source_component_id}},Ace=class extends Dx{constructor(){super(...arguments);ni(this,"schematicBoxDimensions",null)}get config(){return{componentName:"Chip",zodProps:YGe,shouldRenderAsSchematicBox:!0}}doInitialSchematicComponentRender(){const{_parsedProps:e}=this;(e==null?void 0:e.noSchematicRepresentation)!==!0&&super.doInitialSchematicComponentRender()}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({ftype:"simple_chip",name:t.name,manufacturer_part_number:t.manufacturerPartNumber,supplier_part_numbers:t.supplierPartNumbers});this.source_component_id=n.source_component_id}doInitialPcbComponentRender(){var i;if((i=this.root)!=null&&i.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=e.pcb_component.insert({center:{x:t.pcbX??0,y:t.pcbY??0},width:2,height:3,layer:t.layer??"top",rotation:t.pcbRotation??0,source_component_id:this.source_component_id,subcircuit_id:this.getSubcircuit().subcircuit_id??void 0});this.pcb_component_id=n.pcb_component_id}doInitialCreateTracesFromProps(){const{_parsedProps:e}=this;if(e.externallyConnectedPins)for(const[t,n]of e.externallyConnectedPins)this.add(new qS({from:`${this.getSubcircuitSelector()} > port.${t}`,to:`${this.getSubcircuitSelector()} > port.${n}`}));if(e.connections)for(const[t,n]of Object.entries(e.connections)){const i=Array.isArray(n)?n:[n];for(const a of i)this.add(new qS({from:`${this.getSubcircuitSelector()} > port.${t}`,to:a}))}}},ZYe=class extends Dx{constructor(){super(...arguments);ni(this,"pos",this.portMap.pin1);ni(this,"anode",this.portMap.pin1);ni(this,"neg",this.portMap.pin2);ni(this,"cathode",this.portMap.pin2)}get config(){return{schematicSymbolName:this.props.symbolName??"diode",componentName:"Diode",zodProps:Eqe,sourceFtype:"simple_diode"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}},QYe=class extends Dx{constructor(){super(...arguments);ni(this,"schematicDimensions",null)}get config(){return{componentName:"Jumper",zodProps:XGe,shouldRenderAsSchematicBox:!0}}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({ftype:"simple_chip",name:t.name,manufacturer_part_number:t.manufacturerPartNumber,supplier_part_numbers:t.supplierPartNumbers});this.source_component_id=n.source_component_id}doInitialPcbComponentRender(){var i;if((i=this.root)!=null&&i.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=e.pcb_component.insert({center:{x:t.pcbX??0,y:t.pcbY??0},width:2,height:3,layer:t.layer??"top",rotation:t.pcbRotation??0,source_component_id:this.source_component_id,subcircuit_id:this.getSubcircuit().subcircuit_id??void 0});this.pcb_component_id=n.pcb_component_id}},KYe=class extends Dx{constructor(){super(...arguments);ni(this,"pos",this.portMap.pin1);ni(this,"anode",this.portMap.pin1);ni(this,"neg",this.portMap.pin2);ni(this,"cathode",this.portMap.pin2)}get config(){return{componentName:"Led",schematicSymbolName:this.props.symbolName??"led",zodProps:wqe,sourceFtype:"simple_diode"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}},JYe=class extends Dx{constructor(){super(...arguments);ni(this,"pos",this.portMap.pin1);ni(this,"positive",this.portMap.pin1);ni(this,"neg",this.portMap.pin2);ni(this,"negative",this.portMap.pin2)}get config(){return{schematicSymbolName:this.props.symbolName??"power_factor_meter_horz",componentName:"PowerSource",zodProps:Dqe,sourceFtype:"simple_power_source"}}initPorts(){this.add(new l4({name:"pin1",pinNumber:1,aliases:["positive","pos"]})),this.add(new l4({name:"pin2",pinNumber:2,aliases:["negative","neg"]}))}},eXe=class extends Dx{get config(){return{componentName:"Resistor",schematicSymbolName:this.props.symbolName??"boxresistor",zodProps:$Ge,sourceFtype:"simple_resistor"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}_getSchematicSymbolDisplayValue(){return`${PA(this._parsedProps.resistance)}Ω`}doInitialCreateNetsFromProps(){this._createNetsFromProps([this.props.pullupFor,this.props.pullupTo])}doInitialCreateTracesFromProps(){this.props.pullupFor&&this.props.pullupTo&&(this.add(new qS({from:`${this.getSubcircuitSelector()} > port.1`,to:this.props.pullupFor})),this.add(new qS({from:`${this.getSubcircuitSelector()} > port.2`,to:this.props.pullupTo})))}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({ftype:"simple_resistor",name:e.name,manufacturer_part_number:e.manufacturerPartNumber??e.mfn,supplier_part_numbers:e.supplierPartNumbers,resistance:e.resistance,display_resistance:this._getSchematicSymbolDisplayValue()});this.source_component_id=t.source_component_id}},tXe=["leftedge","rightedge","topedge","bottomedge","center"],nXe=class extends R_{get config(){return{componentName:"Constraint",zodProps:iqe}}constructor(r){if(super(r),("xdist"in r||"ydist"in r)&&!("edgeToEdge"in r)&&!("centerToCenter"in r))throw new Error(`edgeToEdge, centerToCenter must be set for xDist or yDist for ${this}`);if("for"in r&&r.for.length<2)throw new Error(`"for" must have at least two selectors for ${this}`)}_getAllReferencedComponents(){const r=[],e=this.getPrimitiveContainer();function t(n){const i=n.split(" ").pop(),a=tXe.includes(i)?i:void 0,o=a?n.replace(` ${a}`,""):n,s=e.selectOne(o,{pcbPrimitive:!0});s&&r.push({selector:n,component:s,componentSelector:o,edge:a})}for(const n of["left","right","top","bottom"])n in this._parsedProps&&t(this._parsedProps[n]);if("for"in this._parsedProps)for(const n of this._parsedProps.for)t(n);return{componentsWithSelectors:r}}},rXe=class extends R_{constructor(){super(...arguments);ni(this,"fabrication_note_path_id",null)}get config(){return{componentName:"FabricationNotePath",zodProps:Cqe}}doInitialPcbPrimitiveRender(){var s,l;if((s=this.root)!=null&&s.pcbDisabled)return;const{db:e}=this.root,t=this.getSubcircuit(),{_parsedProps:n}=this,i=n.layer??"top";if(i!=="top"&&i!=="bottom")throw new Error(`Invalid layer "${i}" for SilkscreenPath. Must be "top" or "bottom".`);const a=this._computePcbGlobalTransformBeforeLayout(),o=e.pcb_fabrication_note_path.insert({pcb_component_id:(l=this.parent)==null?void 0:l.pcb_component_id,layer:i,color:n.color,route:n.route.map(c=>{const u=ui(a,{x:c.x,y:c.y});return{...c,x:u.x,y:u.y}}),stroke_width:n.strokeWidth??.1,subcircuit_id:(t==null?void 0:t.subcircuit_id)??void 0});this.fabrication_note_path_id=o.pcb_fabrication_note_path_id}},iXe=class extends R_{get config(){return{componentName:"FabricationNoteText",zodProps:Mqe}}doInitialPcbPrimitiveRender(){var i,a;if((i=this.root)!=null&&i.pcbDisabled)return;const{db:r}=this.root,{_parsedProps:e}=this,t=this.getPrimitiveContainer(),n=this.getSubcircuit();r.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:t.pcb_component_id,subcircuit_id:(n==null?void 0:n.subcircuit_id)??void 0,pcb_group_id:((a=this.getGroup())==null?void 0:a.pcb_group_id)??void 0})}},aXe=class extends qI{constructor(r){super({...r,subcircuit:!0})}},oXe=class extends R_{constructor(){super(...arguments);ni(this,"source_net_alias_id")}get config(){return{componentName:"NetAlias",zodProps:gqe}}doInitialSchematicComponentRender(){var a;if((a=this.root)!=null&&a.schematicDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n={x:t.schX??0,y:t.schY??0},i=e.schematic_net_label.insert({text:t.net,source_net_id:t.net,anchor_position:n,center:n,anchor_side:"bottom"});this.source_net_alias_id=i.source_net_id}},sXe=class extends R_{constructor(){super(...arguments);ni(this,"pcb_silkscreen_circle_id",null)}get config(){return{componentName:"SilkscreenCircle",zodProps:Uqe}}doInitialPcbPrimitiveRender(){var o,s,l;if((o=this.root)!=null&&o.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=t.layer??"top";if(n!=="top"&&n!=="bottom")throw new Error(`Invalid layer "${n}" for SilkscreenCircle. Must be "top" or "bottom".`);this._computePcbGlobalTransformBeforeLayout();const i=this.getSubcircuit(),a=e.pcb_silkscreen_circle.insert({pcb_component_id:(s=this.parent)==null?void 0:s.pcb_component_id,layer:n,center:{x:t.pcbX??0,y:t.pcbY??0},radius:t.radius,subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0,pcb_group_id:((l=this.getGroup())==null?void 0:l.pcb_group_id)??void 0});this.pcb_silkscreen_circle_id=a.pcb_silkscreen_circle_id}},lXe=class extends R_{constructor(){super(...arguments);ni(this,"pcb_silkscreen_rect_id",null)}get config(){return{componentName:"SilkscreenRect",zodProps:Oqe}}doInitialPcbPrimitiveRender(){var o,s,l;if((o=this.root)!=null&&o.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=t.layer??"top";if(n!=="top"&&n!=="bottom")throw new Error(`Invalid layer "${n}" for SilkscreenRect. Must be "top" or "bottom".`);const i=this.getSubcircuit(),a=e.pcb_silkscreen_rect.insert({pcb_component_id:(s=this.parent)==null?void 0:s.pcb_component_id,layer:n,center:{x:t.pcbX??0,y:t.pcbY??0},width:t.width,height:t.height,subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0,pcb_group_id:((l=this==null?void 0:this.getGroup())==null?void 0:l.pcb_group_id)??void 0});this.pcb_silkscreen_rect_id=a.pcb_silkscreen_rect_id}},cXe=class extends R_{constructor(){super(...arguments);ni(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenText",zodProps:Pqe}}doInitialPcbPrimitiveRender(){var s,l;if((s=this.root)!=null&&s.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this.getPrimitiveContainer(),i=this._getGlobalPcbPositionBeforeLayout(),{maybeFlipLayer:a}=this._getPcbPrimitiveFlippedHelpers(),o=this.getSubcircuit();e.pcb_silkscreen_text.insert({anchor_alignment:t.anchorAlignment,anchor_position:{x:i.x,y:i.y},font:t.font??"tscircuit2024",font_size:t.fontSize??1,layer:a(t.layer??"top"),text:t.text??"",ccw_rotation:t.pcbRotation,pcb_component_id:n.pcb_component_id,subcircuit_id:(o==null?void 0:o.subcircuit_id)??void 0,pcb_group_id:((l=this.getGroup())==null?void 0:l.pcb_group_id)??void 0})}getPcbSize(){const{_parsedProps:e}=this,t=e.fontSize??1,i=(e.text??"").length*t,a=t;return{width:i*t,height:a*t}}},uXe=class extends R_{constructor(){super(...arguments);ni(this,"pcb_silkscreen_line_id",null)}get config(){return{componentName:"SilkscreenLine",zodProps:Lqe}}doInitialPcbPrimitiveRender(){var o,s,l;if((o=this.root)!=null&&o.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=t.layer??"top";if(n!=="top"&&n!=="bottom")throw new Error(`Invalid layer "${n}" for SilkscreenLine. Must be "top" or "bottom".`);const i=this.getSubcircuit(),a=e.pcb_silkscreen_line.insert({pcb_component_id:(s=this.parent)==null?void 0:s.pcb_component_id,layer:n,x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke_width:t.strokeWidth??.1,subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0,pcb_group_id:((l=i==null?void 0:i.getGroup())==null?void 0:l.pcb_group_id)??void 0});this.pcb_silkscreen_line_id=a.pcb_silkscreen_line_id}},fXe=class extends R_{constructor(){super(...arguments);ni(this,"pcb_via_id",null);ni(this,"matchedPort",null);ni(this,"isPcbPrimitive",!0)}get config(){return{componentName:"Via",zodProps:Rqe}}getAvailablePcbLayers(){return["top","inner1","inner2","bottom"]}getPcbSize(){const{_parsedProps:e}=this;return{width:e.outerDiameter,height:e.outerDiameter}}_getPcbCircuitJsonBounds(){const{db:e}=this.root,t=e.pcb_via.get(this.pcb_via_id),n=this.getPcbSize();return{center:{x:t.x,y:t.y},bounds:{left:t.x-n.width/2,top:t.y-n.height/2,right:t.x+n.width/2,bottom:t.y+n.height/2},width:n.width,height:n.height}}_setPositionFromLayout(e){const{db:t}=this.root;t.pcb_via.update(this.pcb_via_id,{x:e.x,y:e.y})}doInitialPcbPrimitiveRender(){var o,s;if((o=this.root)!=null&&o.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this._getGlobalPcbPositionBeforeLayout(),i=this.getSubcircuit(),a=e.pcb_via.insert({x:n.x,y:n.y,hole_diameter:t.holeDiameter,outer_diameter:t.outerDiameter,layers:["bottom","top"],from_layer:t.fromLayer||"bottom",to_layer:t.toLayer||"top",subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0,pcb_group_id:((s=this.getGroup())==null?void 0:s.pcb_group_id)??void 0});this.pcb_via_id=a.pcb_via_id}},dXe=class extends Dx{get config(){return{componentName:"Battery",schematicSymbolName:this.props.symbolName??"battery",zodProps:vqe,sourceFtype:"simple_power_source"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({name:e.name,ftype:"simple_power_source",capacity:e.capacity,supplier_part_numbers:e.supplierPartNumbers});this.source_component_id=t.source_component_id}},hXe=class extends Dx{get config(){return{componentName:"PinHeader",zodProps:yqe,shouldRenderAsSchematicBox:!0}}_getImpliedFootprintString(){var i;const r=this._parsedProps.pinCount??((i=this._parsedProps.pinLabels)==null?void 0:i.length)??0,e=this._parsedProps.holeDiameter,t=this._parsedProps.platedDiameter,n=this._parsedProps.pitch;return r>0&&n?!e&&!t?`pinrow${r}_p${n}`:`pinrow${r}_p${n}_id${e}_od${t}`:null}initPorts(){var e;const r=this._parsedProps.pinCount??((e=this._parsedProps.pinLabels)==null?void 0:e.length)??1;for(let t=1;t<=r;t++)this.add(new l4({name:`pin${t}`,pinNumber:t,aliases:[]}))}_getSchematicPortArrangement(){const r=this._parsedProps.pinCount??1,e=this._parsedProps.facingDirection??"right";return{leftSize:e==="left"?r:0,rightSize:e==="right"?r:0}}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({ftype:"simple_pin_header",name:e.name,supplier_part_numbers:e.supplierPartNumbers,pin_count:e.pinCount,gender:e.gender});this.source_component_id=t.source_component_id}};function pXe(r){switch(r){case"two_ground_pins":return"crystal_4pin";case"ground_pin":return"resonator";case"no_ground":return"crystal";default:return"crystal"}}var mXe=class extends Dx{get config(){return{componentName:"Resonator",schematicSymbolName:this.props.symbolName??pXe(this.props.pinVariant),zodProps:KGe,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({ftype:"simple_resonator",name:e.name,frequency:e.frequency,load_capacitance:e.loadCapacitance,supplier_part_numbers:e.supplierPartNumbers,pin_variant:e.pinVariant||"no_ground"});this.source_component_id=t.source_component_id}},vXe=class extends Dx{get config(){return{componentName:"Inductor",schematicSymbolName:this.props.symbolName??"inductor",zodProps:Sqe,sourceFtype:bT.simple_inductor}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({name:e.name,ftype:bT.simple_inductor,inductance:e.inductance,supplier_part_numbers:e.supplierPartNumbers});this.source_component_id=t.source_component_id}};function yXe(r){switch(r){case"three_pin":return"potentiometer3";case"two_pin":return"potentiometer2";default:return"potentiometer2"}}var gXe=class extends Dx{get config(){return{componentName:"Potentiometer",schematicSymbolName:this.props.symbolName??yXe(this.props.pinVariant),zodProps:ZGe,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({ftype:"simple_potentiometer",name:e.name,max_resistance:e.maxResistance,pin_variant:e.pinVariant||"two_pin"});this.source_component_id=t.source_component_id}},_Xe=class extends Dx{get config(){return{componentName:"PushButton",schematicSymbolName:this.props.symbolName??"push_button_normally_open_momentary",zodProps:_qe,sourceFtype:bT.simple_push_button}}get defaultInternallyConnectedPinNames(){return[["pin1","pin4"],["pin2","pin3"]]}initPorts(){super.initPorts({pinCount:4,additionalAliases:{pin1:["side1"],pin3:["side2"]}})}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({name:e.name,ftype:bT.simple_push_button,supplier_part_numbers:e.supplierPartNumbers});this.source_component_id=t.source_component_id}},xXe=class extends Dx{get config(){return{schematicSymbolName:this.props.symbolName??(this.props.pinVariant==="four_pin"?"crystal_4pin":"crystal"),componentName:"Crystal",zodProps:QGe,sourceFtype:"simple_crystal"}}initPorts(){const r=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:r})}_getSchematicSymbolDisplayValue(){return`${PA(this._parsedProps.frequency)}Hz`}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({name:e.name,ftype:"simple_crystal",frequency:e.frequency,load_capacitance:e.loadCapacitance,pin_variant:e.pinVariant||"two_pin"});this.source_component_id=t.source_component_id}},bXe=class extends Dx{constructor(){super(...arguments);ni(this,"emitter",this.portMap.pin1);ni(this,"collector",this.portMap.pin2);ni(this,"base",this.portMap.pin3)}get config(){return{componentName:"Transistor",schematicSymbolName:this.props.type==="npn"?"npn_bipolar_transistor":"pnp_bipolar_transistor",zodProps:xqe,sourceFtype:"simple_transistor",shouldRenderAsSchematicBox:!1}}initPorts(){super.initPorts({pinCount:3,additionalAliases:{pin1:["emitter","e"],pin2:["collector","c"],pin3:["base","b"]}})}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({ftype:"simple_transistor",name:t.name,transistor_type:t.type});this.source_component_id=n.source_component_id}},SXe=class extends Dx{get config(){const r=this.props.mosfetMode==="depletion"?"d":"e";return{componentName:"Mosfet",schematicSymbolName:`${this.props.channelType}_channel_${r}_mosfet_transistor`,zodProps:bqe,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({ftype:"simple_mosfet",name:e.name,mosfet_mode:e.mosfetMode,channel_type:e.channelType});this.source_component_id=t.source_component_id}},EXe=class extends Dx{_getSwitchType(){const{spst:r,spdt:e,dpst:t,dpdt:n,type:i}=this._parsedProps??{};return n?"dpdt":r?"spst":e?"spdt":t?"dpst":i??"spst"}get config(){const r=this._getSwitchType();return{componentName:"Switch",schematicSymbolName:{spst:"SPST_switch",spdt:"SPDT_switch",dpst:"dpst_switch",dpdt:"dpdt_switch"}[r]??"SPST_switch",zodProps:Tqe,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({ftype:"simple_switch",name:e.name,switch_type:e.type,is_normally_closed:e.isNormallyClosed??!1});this.source_component_id=t.source_component_id}},Dce=class{constructor(){ni(this,"firstChild",null);ni(this,"children");ni(this,"db");ni(this,"root",null);ni(this,"isRoot",!0);ni(this,"schematicDisabled",!1);ni(this,"pcbDisabled",!1);ni(this,"pcbRoutingDisabled",!1);ni(this,"name");ni(this,"_hasRenderedAtleastOnce",!1);ni(this,"_eventListeners",{});this.children=[],this.db=$y([]),this.root=this}add(r){let e;Tt.isValidElement(r)?e=mce(r):e=r,this.children.push(e)}_getBoard(){return this.children.find(r=>r.componentName==="Board")}_guessRootComponent(){if(!this.firstChild){if(this.children.length===1){this.firstChild=this.children[0];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>0){const r=this.children.find(e=>e.componentName==="Board")??null;if(r){this.firstChild=r;return}}throw new Error("Not able to guess root component: RootCircuit has multiple children and no board")}}render(){this.firstChild||this._guessRootComponent();const{firstChild:r,db:e}=this;if(!r)throw new Error("RootCircuit has no root component");r.parent=this,r.runRenderCycle(),this._hasRenderedAtleastOnce=!0}async renderUntilSettled(){for(this.render();this._hasIncompleteAsyncEffects();)await new Promise(r=>setTimeout(r,100)),this.render()}_hasIncompleteAsyncEffects(){return this.children.some(r=>r._hasIncompleteAsyncEffects()?!0:r.children.some(e=>e._hasIncompleteAsyncEffects()))}getSoup(){return this._hasRenderedAtleastOnce||this.render(),this.db.toArray()}getCircuitJson(){return this.getSoup()}toJson(){return this.getSoup()}async getSvg(r){return(await Promise.resolve().then(()=>A8t).catch(t=>{throw new Error(`To use project.getSvg, you must install the "circuit-to-svg" package.
|
|
643
643
|
|
|
644
644
|
"${t.message}"`)})).convertCircuitJsonToPcbSvg(this.getCircuitJson())}async preview(r){throw new Error("project.preview is not yet implemented")}computeSchematicGlobalTransform(){return C_()}_computePcbGlobalTransformBeforeLayout(){return C_()}selectAll(r){var e;return this._guessRootComponent(),((e=this.firstChild)==null?void 0:e.selectAll(r))??[]}selectOne(r,e){var t;return this._guessRootComponent(),((t=this.firstChild)==null?void 0:t.selectOne(r,e))??null}emit(r,...e){if(this._eventListeners[r])for(const t of this._eventListeners[r])t(...e)}on(r,e){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(e)}getClientOrigin(){return typeof window<"u"?window.location.origin:typeof self<"u"?self.origin:""}},wXe=Dce,TXe=r=>{const[e,t]=D0.useState(!0),[n,i]=D0.useState(null),[a,o]=D0.useState(),[s,l]=D0.useState();return D0.useEffect(()=>{t(!0),i(null),r&&setTimeout(()=>{try{const c=new Dce;c.add(r),o(c),l(c.toJson())}catch(c){i(c)}t(!1)},1)},[r]),{isLoading:e,error:n,circuit:a,circuitJson:s}};new Proxy({},{get:(r,e)=>new Proxy({},{get:(t,n)=>e==="net"?`net.${n}`:`.${e} > .${n}`})}),hce(fce),hce({Bug:Ace});var $I,Pce;function N0(){if(Pce)return $I;Pce=1;const r=e=>e.reduce((t,n)=>Array.isArray(n)?t.concat(r(n)):t.concat(n),[]);return $I=r,$I}var ZI,Nce;function MXe(){return Nce||(Nce=1,ZI=e=>Object.assign({},e)),ZI}var QI,Lce;function CXe(){return Lce||(Lce=1,QI=(e,t,n)=>(e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e[3]=t[3]+n[3],e[4]=t[4]+n[4],e[5]=t[5]+n[5],e[6]=t[6]+n[6],e[7]=t[7]+n[7],e[8]=t[8]+n[8],e[9]=t[9]+n[9],e[10]=t[10]+n[10],e[11]=t[11]+n[11],e[12]=t[12]+n[12],e[13]=t[13]+n[13],e[14]=t[14]+n[14],e[15]=t[15]+n[15],e)),QI}var KI,Oce;function JI(){return Oce||(Oce=1,KI=()=>[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),KI}var ek,Uce;function RXe(){if(Uce)return ek;Uce=1;const r=JI();return ek=t=>{const n=r();return n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[4]=t[4],n[5]=t[5],n[6]=t[6],n[7]=t[7],n[8]=t[8],n[9]=t[9],n[10]=t[10],n[11]=t[11],n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15],n},ek}var tk,zce;function Fce(){return zce||(zce=1,tk=(e,t)=>(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e)),tk}var nk,Ice;function AXe(){return Ice||(Ice=1,nk=(e,t)=>{const n=t[0],i=t[1],a=t[2],o=t[3],s=t[4],l=t[5],c=t[6],u=t[7],h=t[8],g=t[9],_=t[10],b=t[11],T=t[12],C=t[13],A=t[14],L=t[15],U=n*l-i*s,j=n*c-a*s,Z=n*u-o*s,ee=i*c-a*l,$=i*u-o*l,oe=a*u-o*c,ae=h*C-g*T,ce=h*A-_*T,me=h*L-b*T,_e=g*A-_*C,Se=g*L-b*C,Ae=_*L-b*A;let ze=U*Ae-j*Se+Z*_e+ee*me-$*ce+oe*ae;return ze?(ze=1/ze,e[0]=(l*Ae-c*Se+u*_e)*ze,e[1]=(a*Se-i*Ae-o*_e)*ze,e[2]=(C*oe-A*$+L*ee)*ze,e[3]=(_*$-g*oe-b*ee)*ze,e[4]=(c*me-s*Ae-u*ce)*ze,e[5]=(n*Ae-a*me+o*ce)*ze,e[6]=(A*Z-T*oe-L*j)*ze,e[7]=(h*oe-_*Z+b*j)*ze,e[8]=(s*Se-l*me+u*ae)*ze,e[9]=(i*me-n*Se-o*ae)*ze,e[10]=(T*$-C*Z+L*U)*ze,e[11]=(g*Z-h*$-b*U)*ze,e[12]=(l*ce-s*_e-c*ae)*ze,e[13]=(n*_e-i*ce+a*ae)*ze,e[14]=(C*j-T*ee-A*U)*ze,e[15]=(h*ee-g*j+_*U)*ze,e):null}),nk}var rk,kce;function DXe(){return kce||(kce=1,rk=(e,t)=>e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]),rk}var ik,Bce;function Mm(){if(Bce)return ik;Bce=1;const r=1e5,e=1e-5,t=1e-13,n=Math.PI*2;return ik={EPS:e,NEPS:t,TAU:n,spatialResolution:r},ik}var ak,Hce;function v5(){if(Hce)return ak;Hce=1;const{NEPS:r}=Mm(),e=i=>Math.abs(i)<r?0:i;return ak={sin:i=>e(Math.sin(i)),cos:i=>e(Math.cos(i))},ak}var ok,Vce;function jce(){return Vce||(Vce=1,ok=e=>(e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e)),ok}var sk,Gce;function qce(){if(Gce)return sk;Gce=1;const{EPS:r}=Mm(),{sin:e,cos:t}=v5(),n=jce();return sk=(a,o,s)=>{let[l,c,u]=s;const h=l*l+c*c+u*u;if(Math.abs(h)<r)return n(a);const g=1/Math.sqrt(h);l*=g,c*=g,u*=g;const _=e(o),b=t(o),T=1-b;return a[0]=l*l*T+b,a[1]=c*l*T+u*_,a[2]=u*l*T-c*_,a[3]=0,a[4]=l*c*T-u*_,a[5]=c*c*T+b,a[6]=u*c*T+l*_,a[7]=0,a[8]=l*u*T+c*_,a[9]=c*u*T-l*_,a[10]=u*u*T+b,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a},sk}var lk,Yce;function PXe(){return Yce||(Yce=1,lk=(e,t)=>(e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e)),lk}var ck,Xce;function NXe(){if(Xce)return ck;Xce=1;const{sin:r,cos:e}=v5();return ck=(n,i,a,o)=>{const s=r(i),l=e(i),c=r(a),u=e(a),h=r(o),g=e(o);return n[0]=u*l,n[1]=u*s,n[2]=-c,n[3]=0,n[4]=h*c*l-g*s,n[5]=g*l+h*c*s,n[6]=h*u,n[7]=0,n[8]=h*s+g*c*l,n[9]=g*c*s-h*l,n[10]=g*u,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n},ck}var uk,Wce;function LXe(){return Wce||(Wce=1,uk=(e,t)=>(e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e)),uk}var fk,$ce;function OXe(){if($ce)return fk;$ce=1;const r=JI();return fk=(t,n,i,a,o,s,l,c,u,h,g,_,b,T,C,A)=>{const L=r();return L[0]=t,L[1]=n,L[2]=i,L[3]=a,L[4]=o,L[5]=s,L[6]=l,L[7]=c,L[8]=u,L[9]=h,L[10]=g,L[11]=_,L[12]=b,L[13]=T,L[14]=C,L[15]=A,L},fk}var dk,Zce;function Qce(){return Zce||(Zce=1,dk=(e,t)=>(e[0]=Math.abs(t[0]),e[1]=Math.abs(t[1]),e[2]=Math.abs(t[2]),e)),dk}var hk,Kce;function Jce(){return Kce||(Kce=1,hk=(e,t,n)=>(e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e)),hk}var pk,eue;function zA(){return eue||(eue=1,pk=(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2]),pk}var mk,tue;function UXe(){if(tue)return mk;tue=1;const r=zA();return mk=(t,n)=>{const i=t[0],a=t[1],o=t[2],s=n[0],l=n[1],c=n[2],u=Math.sqrt(i*i+a*a+o*o),h=Math.sqrt(s*s+l*l+c*c),g=u*h,_=g&&r(t,n)/g;return Math.acos(Math.min(Math.max(_,-1),1))},mk}var vk,nue;function FA(){return nue||(nue=1,vk=()=>[0,0,0]),vk}var yk,rue;function zXe(){if(rue)return yk;rue=1;const r=FA();return yk=t=>{const n=r();return n[0]=t[0],n[1]=t[1],n[2]=t[2],n},yk}var gk,iue;function aue(){return iue||(iue=1,gk=(e,t)=>(e[0]=t[0],e[1]=t[1],e[2]=t[2],e)),gk}var _k,oue;function ST(){return oue||(oue=1,_k=(e,t,n)=>{const i=t[0],a=t[1],o=t[2],s=n[0],l=n[1],c=n[2];return e[0]=a*c-o*l,e[1]=o*s-i*c,e[2]=i*l-a*s,e}),_k}var xk,sue;function lue(){return sue||(sue=1,xk=(e,t)=>{const n=t[0]-e[0],i=t[1]-e[1],a=t[2]-e[2];return Math.sqrt(n*n+i*i+a*a)}),xk}var bk,cue;function FXe(){return cue||(cue=1,bk=(e,t,n)=>(e[0]=t[0]/n[0],e[1]=t[1]/n[1],e[2]=t[2]/n[2],e)),bk}var Sk,uue;function IXe(){return uue||(uue=1,Sk=(e,t)=>e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]),Sk}var Ek,fue;function kXe(){return fue||(fue=1,Ek=(e,t)=>(e[0]=t,e[1]=t,e[2]=t,e)),Ek}var wk,due;function BXe(){if(due)return wk;due=1;const r=FA();return wk=(t,n,i)=>{const a=r();return a[0]=t,a[1]=n,a[2]=i,a},wk}var Tk,hue;function HXe(){return hue||(hue=1,Tk=(e,t,n=0)=>(e[0]=t[0],e[1]=t[1],e[2]=n,e)),Tk}var Mk,pue;function mue(){return pue||(pue=1,Mk=e=>{const t=e[0],n=e[1],i=e[2];return Math.sqrt(t*t+n*n+i*i)}),Mk}var Ck,vue;function VXe(){return vue||(vue=1,Ck=(e,t,n,i)=>(e[0]=t[0]+i*(n[0]-t[0]),e[1]=t[1]+i*(n[1]-t[1]),e[2]=t[2]+i*(n[2]-t[2]),e)),Ck}var Rk,yue;function gue(){return yue||(yue=1,Rk=(e,t,n)=>(e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e[2]=Math.max(t[2],n[2]),e)),Rk}var Ak,_ue;function xue(){return _ue||(_ue=1,Ak=(e,t,n)=>(e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e[2]=Math.min(t[2],n[2]),e)),Ak}var Dk,bue;function jXe(){return bue||(bue=1,Dk=(e,t,n)=>(e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e)),Dk}var Pk,Sue;function GXe(){return Sue||(Sue=1,Pk=(e,t)=>(e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e)),Pk}var Nk,Eue;function Lk(){return Eue||(Eue=1,Nk=(e,t)=>{const n=t[0],i=t[1],a=t[2];let o=n*n+i*i+a*a;return o>0&&(o=1/Math.sqrt(o)),e[0]=n*o,e[1]=i*o,e[2]=a*o,e}),Nk}var Ok,wue;function qXe(){if(wue)return Ok;wue=1;const r=Qce(),e=FA(),t=ST();return Ok=(i,a)=>{const o=r(e(),a),s=0+(o[0]<o[1]&&o[0]<o[2]),l=0+(o[1]<=o[0]&&o[1]<o[2]),c=0+(o[2]<=o[0]&&o[2]<=o[1]);return t(i,a,[s,l,c])},Ok}var Uk,Tue;function YXe(){return Tue||(Tue=1,Uk=(e,t,n,i)=>{const a=[],o=[];return a[0]=t[0]-n[0],a[1]=t[1]-n[1],a[2]=t[2]-n[2],o[0]=a[0],o[1]=a[1]*Math.cos(i)-a[2]*Math.sin(i),o[2]=a[1]*Math.sin(i)+a[2]*Math.cos(i),e[0]=o[0]+n[0],e[1]=o[1]+n[1],e[2]=o[2]+n[2],e}),Uk}var zk,Mue;function XXe(){return Mue||(Mue=1,zk=(e,t,n,i)=>{const a=[],o=[];return a[0]=t[0]-n[0],a[1]=t[1]-n[1],a[2]=t[2]-n[2],o[0]=a[2]*Math.sin(i)+a[0]*Math.cos(i),o[1]=a[1],o[2]=a[2]*Math.cos(i)-a[0]*Math.sin(i),e[0]=o[0]+n[0],e[1]=o[1]+n[1],e[2]=o[2]+n[2],e}),zk}var Fk,Cue;function WXe(){return Cue||(Cue=1,Fk=(e,t,n,i)=>{const a=[],o=[];return a[0]=t[0]-n[0],a[1]=t[1]-n[1],o[0]=a[0]*Math.cos(i)-a[1]*Math.sin(i),o[1]=a[0]*Math.sin(i)+a[1]*Math.cos(i),e[0]=o[0]+n[0],e[1]=o[1]+n[1],e[2]=t[2],e}),Fk}var Ik,Rue;function Aue(){return Rue||(Rue=1,Ik=(e,t,n)=>(e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e)),Ik}var kk,Due;function $Xe(){return Due||(Due=1,kk=(e,t,n)=>(e[0]=Math.round(t[0]/n)*n+0,e[1]=Math.round(t[1]/n)*n+0,e[2]=Math.round(t[2]/n)*n+0,e)),kk}var Bk,Pue;function Nue(){return Pue||(Pue=1,Bk=(e,t)=>{const n=t[0]-e[0],i=t[1]-e[1],a=t[2]-e[2];return n*n+i*i+a*a}),Bk}var Hk,Lue;function Oue(){return Lue||(Lue=1,Hk=e=>{const t=e[0],n=e[1],i=e[2];return t*t+n*n+i*i}),Hk}var Vk,Uue;function IA(){return Uue||(Uue=1,Vk=(e,t,n)=>(e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e)),Vk}var jk,zue;function ZXe(){return zue||(zue=1,jk=e=>`[${e[0].toFixed(7)}, ${e[1].toFixed(7)}, ${e[2].toFixed(7)}]`),jk}var Gk,Fue;function QXe(){return Fue||(Fue=1,Gk=(e,t,n)=>{const i=t[0],a=t[1],o=t[2];let s=n[3]*i+n[7]*a+n[11]*o+n[15];return s=s||1,e[0]=(n[0]*i+n[4]*a+n[8]*o+n[12])/s,e[1]=(n[1]*i+n[5]*a+n[9]*o+n[13])/s,e[2]=(n[2]*i+n[6]*a+n[10]*o+n[14])/s,e}),Gk}var qk,Iue;function Uu(){return Iue||(Iue=1,qk={abs:Qce(),add:Jce(),angle:UXe(),clone:zXe(),copy:aue(),create:FA(),cross:ST(),distance:lue(),divide:FXe(),dot:zA(),equals:IXe(),fromScalar:kXe(),fromValues:BXe(),fromVec2:HXe(),length:mue(),lerp:VXe(),max:gue(),min:xue(),multiply:jXe(),negate:GXe(),normalize:Lk(),orthogonal:qXe(),rotateX:YXe(),rotateY:XXe(),rotateZ:WXe(),scale:Aue(),snap:$Xe(),squaredDistance:Nue(),squaredLength:Oue(),subtract:IA(),toString:ZXe(),transform:QXe()}),qk}var Yk,kue;function KXe(){if(kue)return Yk;kue=1;const r=Uu(),e=qce();return Yk=(n,i,a)=>{const o=r.normalize(r.create(),i),s=r.normalize(r.create(),a),l=r.cross(r.create(),s,o),c=r.dot(s,o);if(c===-1)return e(n,Math.PI,r.orthogonal(l,o));const u=1/(1+c);return n[0]=l[0]*l[0]*u+c,n[1]=l[1]*l[0]*u-l[2],n[2]=l[2]*l[0]*u+l[1],n[3]=0,n[4]=l[0]*l[1]*u+l[2],n[5]=l[1]*l[1]*u+c,n[6]=l[2]*l[1]*u-l[0],n[7]=0,n[8]=l[0]*l[2]*u-l[1],n[9]=l[1]*l[2]*u+l[0],n[10]=l[2]*l[2]*u+c,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n},Yk}var Xk,Bue;function JXe(){if(Bue)return Xk;Bue=1;const{sin:r,cos:e}=v5();return Xk=(n,i)=>{const a=r(i),o=e(i);return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=o,n[6]=a,n[7]=0,n[8]=0,n[9]=-a,n[10]=o,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n},Xk}var Wk,Hue;function eWe(){if(Hue)return Wk;Hue=1;const{sin:r,cos:e}=v5();return Wk=(n,i)=>{const a=r(i),o=e(i);return n[0]=o,n[1]=0,n[2]=-a,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=a,n[9]=0,n[10]=o,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n},Wk}var $k,Vue;function tWe(){if(Vue)return $k;Vue=1;const{sin:r,cos:e}=v5();return $k=(n,i)=>{const a=r(i),o=e(i);return n[0]=o,n[1]=a,n[2]=0,n[3]=0,n[4]=-a,n[5]=o,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n},$k}var Zk,jue;function nWe(){return jue||(jue=1,Zk=e=>e[0]===1&&e[1]===0&&e[2]===0&&e[3]===0&&e[4]===0&&e[5]===1&&e[6]===0&&e[7]===0&&e[8]===0&&e[9]===0&&e[10]===1&&e[11]===0&&e[12]===0&&e[13]===0&&e[14]===0&&e[15]===1),Zk}var Qk,Gue;function rWe(){if(Gue)return Qk;Gue=1;const r=t=>e(t[1])&&e(t[2])&&e(t[3])&&e(t[4])&&e(t[6])&&e(t[7])&&e(t[8])&&e(t[9])&&e(t[11])&&t[15]===1,e=t=>Math.abs(t)<Number.EPSILON;return Qk=r,Qk}var Kk,que;function iWe(){return que||(que=1,Kk=e=>{const t=e[4]*e[9]-e[8]*e[5],n=e[8]*e[1]-e[0]*e[9],i=e[0]*e[5]-e[4]*e[1];return t*e[2]+n*e[6]+i*e[10]<0}),Kk}var Jk,Yue;function aWe(){return Yue||(Yue=1,Jk=(e,t)=>{const[n,i,a,o]=t;return e[0]=1-2*n*n,e[1]=-2*i*n,e[2]=-2*a*n,e[3]=0,e[4]=-2*n*i,e[5]=1-2*i*i,e[6]=-2*a*i,e[7]=0,e[8]=-2*n*a,e[9]=-2*i*a,e[10]=1-2*a*a,e[11]=0,e[12]=2*n*o,e[13]=2*i*o,e[14]=2*a*o,e[15]=1,e}),Jk}var eB,Xue;function oWe(){return Xue||(Xue=1,eB=(e,t,n)=>{const i=t[0],a=t[1],o=t[2],s=t[3],l=t[4],c=t[5],u=t[6],h=t[7],g=t[8],_=t[9],b=t[10],T=t[11],C=t[12],A=t[13],L=t[14],U=t[15];let j=n[0],Z=n[1],ee=n[2],$=n[3];return e[0]=j*i+Z*l+ee*g+$*C,e[1]=j*a+Z*c+ee*_+$*A,e[2]=j*o+Z*u+ee*b+$*L,e[3]=j*s+Z*h+ee*T+$*U,j=n[4],Z=n[5],ee=n[6],$=n[7],e[4]=j*i+Z*l+ee*g+$*C,e[5]=j*a+Z*c+ee*_+$*A,e[6]=j*o+Z*u+ee*b+$*L,e[7]=j*s+Z*h+ee*T+$*U,j=n[8],Z=n[9],ee=n[10],$=n[11],e[8]=j*i+Z*l+ee*g+$*C,e[9]=j*a+Z*c+ee*_+$*A,e[10]=j*o+Z*u+ee*b+$*L,e[11]=j*s+Z*h+ee*T+$*U,j=n[12],Z=n[13],ee=n[14],$=n[15],e[12]=j*i+Z*l+ee*g+$*C,e[13]=j*a+Z*c+ee*_+$*A,e[14]=j*o+Z*u+ee*b+$*L,e[15]=j*s+Z*h+ee*T+$*U,e}),eB}var tB,Wue;function sWe(){if(Wue)return tB;Wue=1;const{EPS:r}=Mm(),{sin:e,cos:t}=v5(),n=Fce();return tB=(a,o,s,l)=>{let[c,u,h]=l;const g=c*c+u*u+h*h;if(Math.abs(g)<r)return n(a,o);const _=1/Math.sqrt(g);c*=_,u*=_,h*=_;const b=e(s),T=t(s),C=1-T,A=o[0],L=o[1],U=o[2],j=o[3],Z=o[4],ee=o[5],$=o[6],oe=o[7],ae=o[8],ce=o[9],me=o[10],_e=o[11],Se=c*c*C+T,Ae=u*c*C+h*b,ze=h*c*C-u*b,Ne=c*u*C-h*b,Oe=u*u*C+T,Le=h*u*C+c*b,Ie=c*h*C+u*b,je=u*h*C-c*b,Ue=h*h*C+T;return a[0]=A*Se+Z*Ae+ae*ze,a[1]=L*Se+ee*Ae+ce*ze,a[2]=U*Se+$*Ae+me*ze,a[3]=j*Se+oe*Ae+_e*ze,a[4]=A*Ne+Z*Oe+ae*Le,a[5]=L*Ne+ee*Oe+ce*Le,a[6]=U*Ne+$*Oe+me*Le,a[7]=j*Ne+oe*Oe+_e*Le,a[8]=A*Ie+Z*je+ae*Ue,a[9]=L*Ie+ee*je+ce*Ue,a[10]=U*Ie+$*je+me*Ue,a[11]=j*Ie+oe*je+_e*Ue,o!==a&&(a[12]=o[12],a[13]=o[13],a[14]=o[14],a[15]=o[15]),a},tB}var nB,$ue;function lWe(){if($ue)return nB;$ue=1;const{sin:r,cos:e}=v5();return nB=(n,i,a)=>{const o=r(a),s=e(a),l=i[4],c=i[5],u=i[6],h=i[7],g=i[8],_=i[9],b=i[10],T=i[11];return i!==n&&(n[0]=i[0],n[1]=i[1],n[2]=i[2],n[3]=i[3],n[12]=i[12],n[13]=i[13],n[14]=i[14],n[15]=i[15]),n[4]=l*s+g*o,n[5]=c*s+_*o,n[6]=u*s+b*o,n[7]=h*s+T*o,n[8]=g*s-l*o,n[9]=_*s-c*o,n[10]=b*s-u*o,n[11]=T*s-h*o,n},nB}var rB,Zue;function cWe(){if(Zue)return rB;Zue=1;const{sin:r,cos:e}=v5();return rB=(n,i,a)=>{const o=r(a),s=e(a),l=i[0],c=i[1],u=i[2],h=i[3],g=i[8],_=i[9],b=i[10],T=i[11];return i!==n&&(n[4]=i[4],n[5]=i[5],n[6]=i[6],n[7]=i[7],n[12]=i[12],n[13]=i[13],n[14]=i[14],n[15]=i[15]),n[0]=l*s-g*o,n[1]=c*s-_*o,n[2]=u*s-b*o,n[3]=h*s-T*o,n[8]=l*o+g*s,n[9]=c*o+_*s,n[10]=u*o+b*s,n[11]=h*o+T*s,n},rB}var iB,Que;function uWe(){if(Que)return iB;Que=1;const{sin:r,cos:e}=v5();return iB=(n,i,a)=>{const o=r(a),s=e(a),l=i[0],c=i[1],u=i[2],h=i[3],g=i[4],_=i[5],b=i[6],T=i[7];return i!==n&&(n[8]=i[8],n[9]=i[9],n[10]=i[10],n[11]=i[11],n[12]=i[12],n[13]=i[13],n[14]=i[14],n[15]=i[15]),n[0]=l*s+g*o,n[1]=c*s+_*o,n[2]=u*s+b*o,n[3]=h*s+T*o,n[4]=g*s-l*o,n[5]=_*s-c*o,n[6]=b*s-u*o,n[7]=T*s-h*o,n},iB}var aB,Kue;function fWe(){return Kue||(Kue=1,aB=(e,t,n)=>{const i=n[0],a=n[1],o=n[2];return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e[4]=t[4]*a,e[5]=t[5]*a,e[6]=t[6]*a,e[7]=t[7]*a,e[8]=t[8]*o,e[9]=t[9]*o,e[10]=t[10]*o,e[11]=t[11]*o,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}),aB}var oB,Jue;function dWe(){return Jue||(Jue=1,oB=(e,t,n)=>(e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e[3]=t[3]-n[3],e[4]=t[4]-n[4],e[5]=t[5]-n[5],e[6]=t[6]-n[6],e[7]=t[7]-n[7],e[8]=t[8]-n[8],e[9]=t[9]-n[9],e[10]=t[10]-n[10],e[11]=t[11]-n[11],e[12]=t[12]-n[12],e[13]=t[13]-n[13],e[14]=t[14]-n[14],e[15]=t[15]-n[15],e)),oB}var sB,efe;function hWe(){return efe||(efe=1,sB=e=>e.map(t=>t.toFixed(7)).toString()),sB}var lB,tfe;function pWe(){return tfe||(tfe=1,lB=(e,t,n)=>{const i=n[0],a=n[1],o=n[2];let s,l,c,u,h,g,_,b,T,C,A,L;return t===e?(e[12]=t[0]*i+t[4]*a+t[8]*o+t[12],e[13]=t[1]*i+t[5]*a+t[9]*o+t[13],e[14]=t[2]*i+t[6]*a+t[10]*o+t[14],e[15]=t[3]*i+t[7]*a+t[11]*o+t[15]):(s=t[0],l=t[1],c=t[2],u=t[3],h=t[4],g=t[5],_=t[6],b=t[7],T=t[8],C=t[9],A=t[10],L=t[11],e[0]=s,e[1]=l,e[2]=c,e[3]=u,e[4]=h,e[5]=g,e[6]=_,e[7]=b,e[8]=T,e[9]=C,e[10]=A,e[11]=L,e[12]=s*i+h*a+T*o+t[12],e[13]=l*i+g*a+C*o+t[13],e[14]=c*i+_*a+A*o+t[14],e[15]=u*i+b*a+L*o+t[15]),e}),lB}var cB,nfe;function Cy(){return nfe||(nfe=1,cB={add:CXe(),clone:RXe(),copy:Fce(),create:JI(),invert:AXe(),equals:DXe(),fromRotation:qce(),fromScaling:PXe(),fromTaitBryanRotation:NXe(),fromTranslation:LXe(),fromValues:OXe(),fromVectorRotation:KXe(),fromXRotation:JXe(),fromYRotation:eWe(),fromZRotation:tWe(),identity:jce(),isIdentity:nWe(),isOnlyTransformScale:rWe(),isMirroring:iWe(),mirrorByPlane:aWe(),multiply:oWe(),rotate:sWe(),rotateX:lWe(),rotateY:cWe(),rotateZ:uWe(),scale:fWe(),subtract:dWe(),toString:hWe(),translate:pWe()}),cB}var uB,rfe;function kA(){if(rfe)return uB;rfe=1;const r=Cy();return uB=t=>(t===void 0&&(t=[]),{sides:t,transforms:r.create()}),uB}var fB,ife;function mWe(){return ife||(ife=1,fB=(e,t)=>(e[0]=Math.abs(t[0]),e[1]=Math.abs(t[1]),e)),fB}var dB,afe;function vWe(){return afe||(afe=1,dB=(e,t,n)=>(e[0]=t[0]+n[0],e[1]=t[1]+n[1],e)),dB}var hB,ofe;function pB(){return ofe||(ofe=1,hB=e=>Math.atan2(e[1],e[0])),hB}var mB,sfe;function yWe(){return sfe||(sfe=1,mB=pB()),mB}var vB,lfe;function gWe(){if(lfe)return vB;lfe=1;const r=pB();return vB=t=>r(t)*57.29577951308232,vB}var yB,cfe;function BA(){return cfe||(cfe=1,yB=()=>[0,0]),yB}var gB,ufe;function _We(){if(ufe)return gB;ufe=1;const r=BA();return gB=t=>{const n=r();return n[0]=t[0],n[1]=t[1],n},gB}var _B,ffe;function xWe(){return ffe||(ffe=1,_B=(e,t)=>(e[0]=t[0],e[1]=t[1],e)),_B}var xB,dfe;function bWe(){return dfe||(dfe=1,xB=(e,t,n)=>(e[0]=0,e[1]=0,e[2]=t[0]*n[1]-t[1]*n[0],e)),xB}var bB,hfe;function SWe(){return hfe||(hfe=1,bB=(e,t)=>{const n=t[0]-e[0],i=t[1]-e[1];return Math.sqrt(n*n+i*i)}),bB}var SB,pfe;function EWe(){return pfe||(pfe=1,SB=(e,t,n)=>(e[0]=t[0]/n[0],e[1]=t[1]/n[1],e)),SB}var EB,mfe;function wWe(){return mfe||(mfe=1,EB=(e,t)=>e[0]*t[0]+e[1]*t[1]),EB}var wB,vfe;function TWe(){return vfe||(vfe=1,wB=(e,t)=>e[0]===t[0]&&e[1]===t[1]),wB}var TB,yfe;function gfe(){if(yfe)return TB;yfe=1;const{sin:r,cos:e}=v5();return TB=(n,i)=>(n[0]=e(i),n[1]=r(i),n),TB}var MB,_fe;function MWe(){if(_fe)return MB;_fe=1;const r=gfe();return MB=(t,n)=>r(t,n*.017453292519943295),MB}var CB,xfe;function CWe(){return xfe||(xfe=1,CB=(e,t)=>(e[0]=t,e[1]=t,e)),CB}var RB,bfe;function RWe(){if(bfe)return RB;bfe=1;const r=BA();return RB=(t,n)=>{const i=r();return i[0]=t,i[1]=n,i},RB}var AB,Sfe;function AWe(){return Sfe||(Sfe=1,AB=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1])),AB}var DB,Efe;function DWe(){return Efe||(Efe=1,DB=(e,t,n,i)=>{const a=t[0],o=t[1];return e[0]=a+i*(n[0]-a),e[1]=o+i*(n[1]-o),e}),DB}var PB,wfe;function PWe(){return wfe||(wfe=1,PB=(e,t,n)=>(e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e)),PB}var NB,Tfe;function NWe(){return Tfe||(Tfe=1,NB=(e,t,n)=>(e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e)),NB}var LB,Mfe;function LWe(){return Mfe||(Mfe=1,LB=(e,t,n)=>(e[0]=t[0]*n[0],e[1]=t[1]*n[1],e)),LB}var OB,Cfe;function OWe(){return Cfe||(Cfe=1,OB=(e,t)=>(e[0]=-t[0],e[1]=-t[1],e)),OB}var UB,Rfe;function Afe(){return Rfe||(Rfe=1,UB=(e,t,n,i)=>{const a=t[0]-n[0],o=t[1]-n[1],s=Math.cos(i),l=Math.sin(i);return e[0]=a*s-o*l+n[0],e[1]=a*l+o*s+n[1],e}),UB}var zB,Dfe;function UWe(){if(Dfe)return zB;Dfe=1;const{TAU:r}=Mm(),e=BA(),t=Afe();return zB=(i,a)=>t(i,a,e(),r/4),zB}var FB,Pfe;function zWe(){return Pfe||(Pfe=1,FB=(e,t)=>{const n=t[0],i=t[1];let a=n*n+i*i;return a>0&&(a=1/Math.sqrt(a)),e[0]=n*a,e[1]=i*a,e}),FB}var IB,Nfe;function FWe(){return Nfe||(Nfe=1,IB=(e,t,n)=>(e[0]=t[0]*n,e[1]=t[1]*n,e)),IB}var kB,Lfe;function IWe(){return Lfe||(Lfe=1,kB=(e,t,n)=>(e[0]=Math.round(t[0]/n)*n+0,e[1]=Math.round(t[1]/n)*n+0,e)),kB}var BB,Ofe;function kWe(){return Ofe||(Ofe=1,BB=(e,t)=>{const n=t[0]-e[0],i=t[1]-e[1];return n*n+i*i}),BB}var HB,Ufe;function BWe(){return Ufe||(Ufe=1,HB=e=>{const t=e[0],n=e[1];return t*t+n*n}),HB}var VB,zfe;function HWe(){return zfe||(zfe=1,VB=(e,t,n)=>(e[0]=t[0]-n[0],e[1]=t[1]-n[1],e)),VB}var jB,Ffe;function VWe(){return Ffe||(Ffe=1,jB=e=>`[${e[0].toFixed(7)}, ${e[1].toFixed(7)}]`),jB}var GB,Ife;function jWe(){return Ife||(Ife=1,GB=(e,t,n)=>{const i=t[0],a=t[1];return e[0]=n[0]*i+n[4]*a+n[12],e[1]=n[1]*i+n[5]*a+n[13],e}),GB}var qB,kfe;function tp(){return kfe||(kfe=1,qB={abs:mWe(),add:vWe(),angle:yWe(),angleDegrees:gWe(),angleRadians:pB(),clone:_We(),copy:xWe(),create:BA(),cross:bWe(),distance:SWe(),divide:EWe(),dot:wWe(),equals:TWe(),fromAngleDegrees:MWe(),fromAngleRadians:gfe(),fromScalar:CWe(),fromValues:RWe(),length:AWe(),lerp:DWe(),max:PWe(),min:NWe(),multiply:LWe(),negate:OWe(),normal:UWe(),normalize:zWe(),rotate:Afe(),scale:FWe(),snap:IWe(),squaredDistance:kWe(),squaredLength:BWe(),subtract:HWe(),toString:VWe(),transform:jWe()}),qB}var YB,Bfe;function GWe(){if(Bfe)return YB;Bfe=1;const r=tp(),e=kA();return YB=n=>{if(!Array.isArray(n))throw new Error("the given points must be an array");let i=n.length;if(i<3)throw new Error("the given points must define a closed geometry with three or more points");r.equals(n[0],n[i-1])&&--i;const a=[];let o=n[i-1];for(let s=0;s<i;s++){const l=n[s];a.push([r.clone(o),r.clone(l)]),o=l}return e(a)},YB}var XB,Hfe;function qWe(){if(Hfe)return XB;Hfe=1;const r=Cy(),e=tp(),t=kA();return XB=i=>{if(i[0]!==0)throw new Error("invalid compact binary data");const a=t();a.transforms=r.clone(i.slice(1,17));for(let o=21;o<i.length;o+=4){const s=e.fromValues(i[o+0],i[o+1]),l=e.fromValues(i[o+2],i[o+3]);a.sides.push([s,l])}return i[17]>=0&&(a.color=[i[17],i[18],i[19],i[20]]),a},XB}var WB,Vfe;function jfe(){return Vfe||(Vfe=1,WB=e=>!!(e&&typeof e=="object"&&"sides"in e&&"transforms"in e&&Array.isArray(e.sides)&&"length"in e.transforms)),WB}var $B,Gfe;function YWe(){if(Gfe)return $B;Gfe=1;const r=Cy(),e=tp();return $B=n=>(r.isIdentity(n.transforms)||(n.sides=n.sides.map(i=>{const a=e.transform(e.create(),i[0],n.transforms),o=e.transform(e.create(),i[1],n.transforms);return[a,o]}),n.transforms=r.create()),n),$B}var ZB,qfe;function ET(){if(qfe)return ZB;qfe=1;const r=YWe();return ZB=t=>r(t).sides,ZB}var QB,Yfe;function Xfe(){if(Yfe)return QB;Yfe=1;const r=kA(),e=ET();return QB=n=>{const a=e(n).map(o=>[o[1],o[0]]);return a.reverse(),r(a)},QB}var KB,Wfe;function $fe(){if(Wfe)return KB;Wfe=1;const r=tp(),e=ET(),t=o=>{const s=new Map,l=c=>{const u=c.toString();return s.has(u)?s.get(u):(s.set(u,c),c)};return o.map(c=>c.map(l))},n=o=>{const s=new Map;return t(o).forEach(c=>{s.has(c[0])?s.get(c[0]).push(c):s.set(c[0],[c])}),s},i=o=>{const s=n(e(o)),l=[];for(;;){let c;for(const[g,_]of s){if(c=_.shift(),!c){s.delete(g);continue}break}if(c===void 0)break;const u=[],h=c[0];for(;;){u.push(c[0]);const g=c[1];if(g===h)break;const _=s.get(g);if(!_)throw new Error(`geometry is not closed at vertex ${g}`);const b=a(c,_);_.length===0&&s.delete(g),c=b}u.length>0&&u.push(u.shift()),l.push(u)}return s.clear(),l},a=(o,s)=>{if(s.length===1)return s.pop();const l=r.create(),c=r.angleDegrees(r.subtract(l,o[1],o[0]));let u,h;s.forEach((_,b)=>{let C=r.angleDegrees(r.subtract(l,_[1],_[0]))-c;C<-180&&(C+=360),C>=180&&(C-=360),(h===void 0||C>u)&&(h=b,u=C)});const g=s[h];return s.splice(h,1),g};return KB=i,KB}var JB,Zfe;function XWe(){if(Zfe)return JB;Zfe=1;const r=ET();return JB=t=>{const i=r(t).map(a=>a[0]);return i.length>0&&i.push(i.shift()),i},JB}var eH,Qfe;function WWe(){if(Qfe)return eH;Qfe=1;const r=tp(),e=ET();return eH=n=>{const i=e(n);let a="geom2 ("+i.length+` sides):
|
|
@@ -12840,7 +12840,7 @@ ${l.join(`
|
|
|
12840
12840
|
`)!==-1&&(r=r.replace(/\r\n/g,`
|
|
12841
12841
|
`)),r.indexOf(`\\
|
|
12842
12842
|
`)!==-1&&(r=r.replace(/\\\n/g,""));const t=r.split(`
|
|
12843
|
-
`);let n="",i="",a=0,o=[];const s=typeof"".trimLeft=="function";for(let u=0,h=t.length;u<h;u++)if(n=t[u],n=s?n.trimLeft():n.trim(),a=n.length,a!==0&&(i=n.charAt(0),i!=="#"))if(i==="v"){const g=n.split(/\s+/);switch(g[0]){case"v":e.vertices.push(parseFloat(g[1]),parseFloat(g[2]),parseFloat(g[3])),g.length>=7?e.colors.push(parseFloat(g[4]),parseFloat(g[5]),parseFloat(g[6])):e.colors.push(void 0,void 0,void 0);break;case"vn":e.normals.push(parseFloat(g[1]),parseFloat(g[2]),parseFloat(g[3]));break;case"vt":e.uvs.push(parseFloat(g[1]),parseFloat(g[2]));break}}else if(i==="f"){const _=n.substr(1).trim().split(/\s+/),b=[];for(let C=0,A=_.length;C<A;C++){const L=_[C];if(L.length>0){const U=L.split("/");b.push(U)}}const T=b[0];for(let C=1,A=b.length-1;C<A;C++){const L=b[C],U=b[C+1];e.addFace(T[0],L[0],U[0],T[1],L[1],U[1],T[2],L[2],U[2])}}else if(i==="l"){const g=n.substring(1).trim().split(" ");let _=[];const b=[];if(n.indexOf("/")===-1)_=g;else for(let T=0,C=g.length;T<C;T++){const A=g[T].split("/");A[0]!==""&&_.push(A[0]),A[1]!==""&&b.push(A[1])}e.addLineGeometry(_,b)}else if(i==="p"){const _=n.substr(1).trim().split(" ");e.addPointGeometry(_)}else if((o=Ogt.exec(n))!==null){const g=(" "+o[0].substr(1).trim()).substr(1);e.startObject(g)}else if(zgt.test(n))e.object.startMaterial(n.substring(7).trim(),e.materialLibraries);else if(Ugt.test(n))e.materialLibraries.push(n.substring(7).trim());else if(Fgt.test(n))console.warn('THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.');else if(i==="s"){if(o=n.split(" "),o.length>1){const _=o[1].trim().toLowerCase();e.object.smooth=_!=="0"&&_!=="off"}else e.object.smooth=!0;const g=e.object.currentMaterial();g&&(g.smooth=e.object.smooth)}else{if(n==="\0")continue;console.warn('THREE.OBJLoader: Unexpected line: "'+n+'"')}e.finalize();const l=new yE;if(l.materialLibraries=[].concat(e.materialLibraries),!(e.objects.length===1&&e.objects[0].geometry.vertices.length===0)===!0)for(let u=0,h=e.objects.length;u<h;u++){const g=e.objects[u],_=g.geometry,b=g.materials,T=_.type==="Line",C=_.type==="Points";let A=!1;if(_.vertices.length===0)continue;const L=new O0;L.setAttribute("position",new bc(_.vertices,3)),_.normals.length>0&&L.setAttribute("normal",new bc(_.normals,3)),_.colors.length>0&&(A=!0,L.setAttribute("color",new bc(_.colors,3))),_.hasUVIndices===!0&&L.setAttribute("uv",new bc(_.uvs,2));const U=[];for(let Z=0,ee=b.length;Z<ee;Z++){const $=b[Z],oe=$.name+"_"+$.smooth+"_"+A;let ae=e.materials[oe];if(this.materials!==null){if(ae=this.materials.create($.name),T&&ae&&!(ae instanceof Ux)){const ce=new Ux;t5.prototype.copy.call(ce,ae),ce.color.copy(ae.color),ae=ce}else if(C&&ae&&!(ae instanceof EE)){const ce=new EE({size:10,sizeAttenuation:!1});t5.prototype.copy.call(ce,ae),ce.color.copy(ae.color),ce.map=ae.map,ae=ce}}ae===void 0&&(T?ae=new Ux:C?ae=new EE({size:1,sizeAttenuation:!1}):ae=new rN,ae.name=$.name,ae.flatShading=!$.smooth,ae.vertexColors=A,e.materials[oe]=ae),U.push(ae)}let j;if(U.length>1){for(let Z=0,ee=b.length;Z<ee;Z++){const $=b[Z];L.addGroup($.groupStart,$.groupCount,Z)}T?j=new A3(L,U):C?j=new pM(L,U):j=new Zg(L,U)}else T?j=new A3(L,U[0]):C?j=new pM(L,U[0]):j=new Zg(L,U[0]);j.name=g.name,l.add(j)}else if(e.vertices.length>0){const u=new EE({size:1,sizeAttenuation:!1}),h=new O0;h.setAttribute("position",new bc(e.vertices,3)),e.colors.length>0&&e.colors[0]!==void 0&&(h.setAttribute("color",new bc(e.colors,3)),u.vertexColors=!0);const g=new pM(h,u);l.add(g)}return l}};function Bgt({stlUrl:r,mtlUrl:e,color:t,opacity:n=1}){const i=f$(Pgt,r),a=Tt.useRef();return gt.jsxs("mesh",{ref:a,children:[gt.jsx("primitive",{object:i,attach:"geometry"}),gt.jsx("meshStandardMaterial",{color:t,transparent:n!==1,opacity:n})]})}var Hgt={name:"@tscircuit/3d-viewer",version:"0.0.
|
|
12843
|
+
`);let n="",i="",a=0,o=[];const s=typeof"".trimLeft=="function";for(let u=0,h=t.length;u<h;u++)if(n=t[u],n=s?n.trimLeft():n.trim(),a=n.length,a!==0&&(i=n.charAt(0),i!=="#"))if(i==="v"){const g=n.split(/\s+/);switch(g[0]){case"v":e.vertices.push(parseFloat(g[1]),parseFloat(g[2]),parseFloat(g[3])),g.length>=7?e.colors.push(parseFloat(g[4]),parseFloat(g[5]),parseFloat(g[6])):e.colors.push(void 0,void 0,void 0);break;case"vn":e.normals.push(parseFloat(g[1]),parseFloat(g[2]),parseFloat(g[3]));break;case"vt":e.uvs.push(parseFloat(g[1]),parseFloat(g[2]));break}}else if(i==="f"){const _=n.substr(1).trim().split(/\s+/),b=[];for(let C=0,A=_.length;C<A;C++){const L=_[C];if(L.length>0){const U=L.split("/");b.push(U)}}const T=b[0];for(let C=1,A=b.length-1;C<A;C++){const L=b[C],U=b[C+1];e.addFace(T[0],L[0],U[0],T[1],L[1],U[1],T[2],L[2],U[2])}}else if(i==="l"){const g=n.substring(1).trim().split(" ");let _=[];const b=[];if(n.indexOf("/")===-1)_=g;else for(let T=0,C=g.length;T<C;T++){const A=g[T].split("/");A[0]!==""&&_.push(A[0]),A[1]!==""&&b.push(A[1])}e.addLineGeometry(_,b)}else if(i==="p"){const _=n.substr(1).trim().split(" ");e.addPointGeometry(_)}else if((o=Ogt.exec(n))!==null){const g=(" "+o[0].substr(1).trim()).substr(1);e.startObject(g)}else if(zgt.test(n))e.object.startMaterial(n.substring(7).trim(),e.materialLibraries);else if(Ugt.test(n))e.materialLibraries.push(n.substring(7).trim());else if(Fgt.test(n))console.warn('THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.');else if(i==="s"){if(o=n.split(" "),o.length>1){const _=o[1].trim().toLowerCase();e.object.smooth=_!=="0"&&_!=="off"}else e.object.smooth=!0;const g=e.object.currentMaterial();g&&(g.smooth=e.object.smooth)}else{if(n==="\0")continue;console.warn('THREE.OBJLoader: Unexpected line: "'+n+'"')}e.finalize();const l=new yE;if(l.materialLibraries=[].concat(e.materialLibraries),!(e.objects.length===1&&e.objects[0].geometry.vertices.length===0)===!0)for(let u=0,h=e.objects.length;u<h;u++){const g=e.objects[u],_=g.geometry,b=g.materials,T=_.type==="Line",C=_.type==="Points";let A=!1;if(_.vertices.length===0)continue;const L=new O0;L.setAttribute("position",new bc(_.vertices,3)),_.normals.length>0&&L.setAttribute("normal",new bc(_.normals,3)),_.colors.length>0&&(A=!0,L.setAttribute("color",new bc(_.colors,3))),_.hasUVIndices===!0&&L.setAttribute("uv",new bc(_.uvs,2));const U=[];for(let Z=0,ee=b.length;Z<ee;Z++){const $=b[Z],oe=$.name+"_"+$.smooth+"_"+A;let ae=e.materials[oe];if(this.materials!==null){if(ae=this.materials.create($.name),T&&ae&&!(ae instanceof Ux)){const ce=new Ux;t5.prototype.copy.call(ce,ae),ce.color.copy(ae.color),ae=ce}else if(C&&ae&&!(ae instanceof EE)){const ce=new EE({size:10,sizeAttenuation:!1});t5.prototype.copy.call(ce,ae),ce.color.copy(ae.color),ce.map=ae.map,ae=ce}}ae===void 0&&(T?ae=new Ux:C?ae=new EE({size:1,sizeAttenuation:!1}):ae=new rN,ae.name=$.name,ae.flatShading=!$.smooth,ae.vertexColors=A,e.materials[oe]=ae),U.push(ae)}let j;if(U.length>1){for(let Z=0,ee=b.length;Z<ee;Z++){const $=b[Z];L.addGroup($.groupStart,$.groupCount,Z)}T?j=new A3(L,U):C?j=new pM(L,U):j=new Zg(L,U)}else T?j=new A3(L,U[0]):C?j=new pM(L,U[0]):j=new Zg(L,U[0]);j.name=g.name,l.add(j)}else if(e.vertices.length>0){const u=new EE({size:1,sizeAttenuation:!1}),h=new O0;h.setAttribute("position",new bc(e.vertices,3)),e.colors.length>0&&e.colors[0]!==void 0&&(h.setAttribute("color",new bc(e.colors,3)),u.vertexColors=!0);const g=new pM(h,u);l.add(g)}return l}};function Bgt({stlUrl:r,mtlUrl:e,color:t,opacity:n=1}){const i=f$(Pgt,r),a=Tt.useRef();return gt.jsxs("mesh",{ref:a,children:[gt.jsx("primitive",{object:i,attach:"geometry"}),gt.jsx("meshStandardMaterial",{color:t,transparent:n!==1,opacity:n})]})}var Hgt={name:"@tscircuit/3d-viewer",version:"0.0.143",main:"./dist/index.js",module:"./dist/index.js",type:"module",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js"}},files:["dist"],scripts:{start:"bun run storybook","dev:old":"bunx --bun vite",build:"tsup ./src/index.tsx --platform neutral --format esm --dts",prepublish:"npm run build",preview:"vite preview",storybook:"storybook dev -p 6006","build-storybook":"storybook build","vercel-build":"bun run build-storybook",format:"biome format . --write","format:check":"biome format .","test:node-bundle":"node ./scripts/load-bundle-in-node.js"},dependencies:{"@jscad/regl-renderer":"^2.6.12","@jscad/stl-serializer":"^2.1.20","@react-three/drei":"^9.121.4","@react-three/fiber":"^8.17.14","@tscircuit/core":"^0.0.320","@tscircuit/props":"^0.0.152","@tscircuit/soup-util":"^0.0.41","jscad-electronics":"^0.0.25","jscad-fiber":"^0.0.77","jscad-planner":"^0.0.12",react:"^18.3.1","react-dom":"^18.3.1","react-use-gesture":"^9.1.3"},peerDependencies:{three:"*"},devDependencies:{"@biomejs/biome":"^1.9.4","@chromatic-com/storybook":"^1.9.0","@jscad/modeling":"^2.12.5","@storybook/addon-essentials":"^8.5.2","@storybook/addon-interactions":"^8.5.2","@storybook/addon-links":"^8.5.2","@storybook/addon-onboarding":"^8.5.2","@storybook/blocks":"^8.5.2","@storybook/builder-vite":"^8.5.2","@storybook/react":"^8.5.2","@storybook/react-vite":"^8.5.2","@storybook/test":"^8.5.2","@types/jsdom":"^21.1.7","@types/react":"^18.3.18","@types/react-dom":"^18.3.5","@types/three":"^0.165.0","@vitejs/plugin-react":"^4.3.4","bun-match-svg":"^0.0.9","bun-types":"^1.2.1","circuit-json":"^0.0.116","circuit-to-svg":"^0.0.91",debug:"^4.4.0",jsdom:"^26.0.0",semver:"^7.7.0",storybook:"^8.5.2","strip-ansi":"^7.1.0",tsup:"^8.3.6",typescript:"^5.7.3",vite:"^5.4.14","vite-tsconfig-paths":"^4.3.2"}};typeof window<"u"&&(window.TSCI_MAIN_CAMERA_ROTATION=new q2(0,0,0));function Vgt(r,e){const t=new g5().setFromEuler(new q2(r.x,r.y,r.z)),n=new Dn(0,0,1);return n.applyQuaternion(t),n.multiplyScalar(e)}var jgt=({})=>{const r=Tt.useRef();return Tt.useRef({lastRotation:new q2}),OM((e,t)=>{if(!r.current)return;const n=window.TSCI_MAIN_CAMERA_ROTATION,i=Vgt(n,2);e.camera.position.copy(i),e.camera.lookAt(0,0,0)}),gt.jsxs("mesh",{ref:r,rotation:[Math.PI/2,0,0],children:[gt.jsx("boxGeometry",{args:[1,1,1]}),gt.jsx("meshStandardMaterial",{color:"white"}),gt.jsx(IE,{position:[0,0,.51],fontSize:.25,color:"black",children:"Front"}),gt.jsx(IE,{position:[0,0,-.51],fontSize:.25,color:"black",rotation:[0,Math.PI,0],children:"Back"}),gt.jsx(IE,{position:[.51,0,0],fontSize:.25,color:"black",rotation:[0,Math.PI/2,0],children:"Right"}),gt.jsx(IE,{position:[-.51,0,0],fontSize:.25,color:"black",rotation:[0,-Math.PI/2,0],children:"Left"}),gt.jsx(IE,{position:[0,.51,0],fontSize:.25,color:"black",rotation:[-Math.PI/2,0,0],children:"Top"}),gt.jsx(IE,{position:[0,-.51,0],fontSize:.25,color:"black",rotation:[Math.PI/2,0,0],children:"Bottom"}),gt.jsx("lineSegments",{args:[new CW(new cS(1,1,1))],material:new Ux({color:0,linewidth:2})})]})},Ggt=()=>(OM(({camera:r})=>{window.TSCI_MAIN_CAMERA_ROTATION=r.rotation}),gt.jsx(gt.Fragment,{})),qgt=Tt.forwardRef(({children:r,hoveredComponent:e,initialCameraPosition:t=[5,5,5],autoRotateDisabled:n},i)=>gt.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[gt.jsx("div",{style:{position:"absolute",top:0,left:0,width:120,height:120},children:gt.jsxs(ixe,{camera:{up:[0,0,1],position:[1,1,1]},style:{zIndex:10},children:[gt.jsx("ambientLight",{intensity:Math.PI/2}),gt.jsx(jgt,{})]})}),gt.jsxs(ixe,{scene:{up:[0,0,1]},camera:{up:[0,0,1],position:t},children:[gt.jsx(Ggt,{}),gt.jsx(flt,{autoRotate:!n,autoRotateSpeed:1}),gt.jsx("ambientLight",{intensity:Math.PI/2}),gt.jsx("pointLight",{position:[-10,-10,10],decay:0,intensity:Math.PI/4}),gt.jsx(hlt,{rotation:[Math.PI/2,0,0],infiniteGrid:!0,cellSize:1,sectionSize:10}),gt.jsx("object3D",{ref:i,children:r}),e&>.jsx(sst,{position:e.mousePosition,style:{fontFamily:"sans-serif",transform:"translate3d(50%, 50%, 0)",backgroundColor:"white",padding:"5px",borderRadius:"3px",pointerEvents:"none",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},children:e.name})]}),gt.jsxs("div",{style:{position:"absolute",right:24,bottom:24,fontFamily:"sans-serif",color:"white",WebkitTextStroke:"0.5px rgba(0, 0, 0, 0.5)",fontSize:11},children:["@",Hgt.version]})]})),Ygt=r=>gt.jsx("group",{...r}),Xgt=({children:r,isHovered:e,onHover:t,position:n})=>{const i=Tt.useRef(null),a=Tt.useCallback(s=>{s.stopPropagation();try{const l=s.point||(s.intersections&&s.intersections.length>0?s.intersections[0].point:null)||(n?new Dn(...n):null);l?(i.current=l,t({mousePosition:[l.x,l.y,l.z]})):t({})}catch(l){console.warn("Hover event error:",l),t({})}},[n]),o=Tt.useCallback(s=>{s.stopPropagation(),i.current=null,t(null)},[t]);return gt.jsx(Ygt,{onPointerEnter:a,onPointerMove:a,onPointerLeave:o,children:r})},LL=Xgt;typeof window<"u"&&!window.TSCIRCUIT_OBJ_LOADER_CACHE&&(window.TSCIRCUIT_OBJ_LOADER_CACHE=new Map);function Wgt(r){const[e,t]=Tt.useState(null);return Tt.useEffect(()=>{if(!r)return;const n=window.TSCIRCUIT_OBJ_LOADER_CACHE;let i=!1;async function a(){var s;try{const c=await(await fetch(r)).text(),u=(s=c.match(/newmtl[\s\S]*?endmtl/g))==null?void 0:s.join(`
|
|
12844
12844
|
`).replace(/d 0\./g,"d 1."),h=c.replace(/newmtl[\s\S]*?endmtl/g,""),g=new Ngt;g.setMaterialOptions({invertTrProperty:!0});const _=g.parse(u.replace(/Kd\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/g,"Kd $2 $2 $2"),"test.mtl"),b=new kgt;return b.setMaterials(_),b.parse(h)}catch(l){return l}}function o(){if(n.has(r)){const l=n.get(r);return l.result?Promise.resolve(l.result.clone()):l.promise.then(c=>c.clone())}const s=a().then(l=>(l instanceof Error||n.set(r,{...n.get(r),result:l}),l));return n.set(r,{promise:s,result:null}),s}return o().then(s=>{i||t(s)}).catch(s=>{console.error(s)}),()=>{i=!0}},[r]),e}function $gt({url:r,position:e,rotation:t,onHover:n,isHovered:i}){const a=Wgt(r);return a?a instanceof Error?gt.jsx(LL,{isHovered:i,onHover:n,children:gt.jsxs("mesh",{position:e,children:[gt.jsx("boxGeometry",{args:[.5,.5,.5]}),gt.jsx("meshStandardMaterial",{transparent:!0,color:"red",opacity:.5}),gt.jsx("meshBasicMaterial",{color:"red"})]})}):gt.jsx(LL,{isHovered:i,onHover:n,children:gt.jsx("primitive",{rotation:t,position:e,object:a})}):gt.jsx(LL,{isHovered:i,onHover:n,children:gt.jsxs("mesh",{position:e,children:[gt.jsx("boxGeometry",{args:[.5,.5,.5]}),gt.jsx("meshStandardMaterial",{transparent:!0,color:"red",opacity:.25})]})})}var Zgt=t2(ZEe()),a8e=({jscadPlan:r,positionOffset:e,rotationOffset:t,onHover:n,isHovered:i})=>{const{threeGeom:a,material:o}=Tt.useMemo(()=>{const s=Yxe.executeJscadOperations(Zgt.default,r),l=fct(s),c=new nN({vertexColors:!0,side:u3});return{threeGeom:l,material:c}},[r]);return Tt.useMemo(()=>{if(i){const s=new yl(o.color.getHex());o.emissive.copy(s),o.emissive.setRGB(0,0,1),o.emissiveIntensity=.2}else o.emissiveIntensity=0},[i,o]),a?gt.jsx(LL,{isHovered:i,onHover:n,position:e,children:gt.jsx("mesh",{geometry:a,material:o,position:e,rotation:t})}):null},{createJSCADRoot:Qgt}=cct(Yxe.jscadPlanner),Kgt=({positionOffset:r,footprint:e,rotationOffset:t,onHover:n,isHovered:i})=>{const a=Tt.useMemo(()=>{if(!e)return null;const o=[];return Qgt(o).render(gt.jsx(Rpt,{footprint:e})),o},[e]);return a?gt.jsx(gt.Fragment,{children:a.map((o,s)=>gt.jsx(a8e,{positionOffset:r,rotationOffset:t,jscadPlan:o,onHover:n,isHovered:i},s))}):null},Jgt=(...r)=>r,e9t=({cad_component:r,onHover:e=()=>{},isHovered:t=!1})=>{const n=r.model_obj_url??r.model_stl_url,i=r.rotation?Jgt(r.rotation.x*Math.PI/180,r.rotation.y*Math.PI/180,r.rotation.z*Math.PI/180):void 0;if(n)return gt.jsx($gt,{url:n,position:r.position?[r.position.x,r.position.y,r.position.z]:void 0,rotation:i,onHover:e,isHovered:t},r.cad_component_id);if(r.model_jscad)return gt.jsx(a8e,{jscadPlan:r.model_jscad,rotationOffset:i,onHover:e,isHovered:t},r.cad_component_id);if(r.footprinter_string)return gt.jsx(Kgt,{positionOffset:r.position?[r.position.x,r.position.y,r.position.z]:void 0,rotationOffset:i,footprint:r.footprinter_string,onHover:e,isHovered:t})},t9t=class extends D0.Component{constructor(r){super(r),this.state={hasError:!1,error:null}}static getDerivedStateFromError(r){return{hasError:!0,error:r}}render(){return this.state.hasError&&this.state.error?this.props.fallback({error:this.state.error}):this.props.children}},n9t=({error:r,cad_component:e})=>{let t=[0,0,0];return e!=null&&e.position&&(t=[e.position.x,e.position.y,e.position.z],t=t.map(n=>Number.isNaN(n)?0:n)),gt.jsxs("group",{position:t,children:[gt.jsxs("mesh",{renderOrder:-99999,rotation:[Math.PI/4,Math.PI/4,0],ref:n=>{n&&(n.renderOrder=999999)},children:[gt.jsx("boxGeometry",{args:[.5,.5,.5]}),gt.jsx("meshStandardMaterial",{depthTest:!1,transparent:!0,color:"red",opacity:.5})]}),gt.jsxs(IE,{scale:[.1,.1,.1],color:"red",anchorX:"center",anchorY:"middle",depthOffset:-99999,children:[r.toString().slice(0,50),"..."]})]})},r9t=Tt.forwardRef(({soup:r,circuitJson:e,children:t,autoRotateDisabled:n},i)=>{e??(e=r);const[a,o]=Tt.useState(null);e??(e=_gt(t));const s=Tt.useMemo(()=>{if(!e)return[5,5,5];try{const g=$y(e).pcb_board.list()[0];if(!g)return[5,5,5];const{width:_,height:b}=g,T=Math.max(_,b);return[T/2,T/2,T]}catch(g){return console.error(g),[5,5,5]}},[e]),l=Tt.useMemo(()=>!e||!e.some(g=>g.type==="pcb_board")?null:Cgt(e),[e]),{stls:c,loading:u}=Agt(l);if(!e)return null;const h=$y(e).cad_component.list();return gt.jsxs(qgt,{ref:i,hoveredComponent:a,autoRotateDisabled:n,initialCameraPosition:s,children:[c.map(({stlUrl:g,color:_},b)=>gt.jsx(Bgt,{stlUrl:g,color:_,opacity:b===0?.95:1},g)),h.map(g=>gt.jsx(t9t,{fallback:({error:_})=>gt.jsx(n9t,{cad_component:g,error:_}),children:gt.jsx(e9t,{onHover:_=>{var T;if(_||o(null),!_.mousePosition)return;const b=(T=$y(e).source_component.getUsing({source_component_id:g.source_component_id}))==null?void 0:T.name;o({cad_component_id:g.cad_component_id,name:b??"<unknown>",mousePosition:_.mousePosition})},cad_component:g,isHovered:(a==null?void 0:a.cad_component_id)===g.cad_component_id},g.cad_component_id)},g.cad_component_id))]})}),i9t=t2(ggt());t2(ZEe()),(0,i9t.default)("tscircuit:3d-viewer:convert-circuit-json-to-3d-svg");const z7=r=>typeof r=="number"&&!isNaN(r),KE=r=>typeof r=="string",m3=r=>typeof r=="function",OL=r=>KE(r)||m3(r)?r:null,eK=r=>Tt.isValidElement(r)||KE(r)||m3(r)||z7(r);function a9t(r,e,t){t===void 0&&(t=300);const{scrollHeight:n,style:i}=r;requestAnimationFrame(()=>{i.minHeight="initial",i.height=n+"px",i.transition=`all ${t}ms`,requestAnimationFrame(()=>{i.height="0",i.padding="0",i.margin="0",setTimeout(e,t)})})}function UL(r){let{enter:e,exit:t,appendPosition:n=!1,collapse:i=!0,collapseDuration:a=300}=r;return function(o){let{children:s,position:l,preventExitTransition:c,done:u,nodeRef:h,isIn:g,playToast:_}=o;const b=n?`${e}--${l}`:e,T=n?`${t}--${l}`:t,C=Tt.useRef(0);return Tt.useLayoutEffect(()=>{const A=h.current,L=b.split(" "),U=j=>{j.target===h.current&&(_(),A.removeEventListener("animationend",U),A.removeEventListener("animationcancel",U),C.current===0&&j.type!=="animationcancel"&&A.classList.remove(...L))};A.classList.add(...L),A.addEventListener("animationend",U),A.addEventListener("animationcancel",U)},[]),Tt.useEffect(()=>{const A=h.current,L=()=>{A.removeEventListener("animationend",L),i?a9t(A,u,a):u()};g||(c?L():(C.current=1,A.className+=` ${T}`,A.addEventListener("animationend",L)))},[g]),D0.createElement(D0.Fragment,null,s)}}function o8e(r,e){return r!=null?{content:r.content,containerId:r.props.containerId,id:r.props.toastId,theme:r.props.theme,type:r.props.type,data:r.props.data||{},isLoading:r.props.isLoading,icon:r.props.icon,status:e}:{}}const w2=new Map;let F7=[];const tK=new Set,o9t=r=>tK.forEach(e=>e(r)),s8e=()=>w2.size>0;function l8e(r,e){var t;if(e)return!((t=w2.get(e))==null||!t.isToastActive(r));let n=!1;return w2.forEach(i=>{i.isToastActive(r)&&(n=!0)}),n}function c8e(r,e){eK(r)&&(s8e()||F7.push({content:r,options:e}),w2.forEach(t=>{t.buildToast(r,e)}))}function u8e(r,e){w2.forEach(t=>{e!=null&&e!=null&&e.containerId?(e==null?void 0:e.containerId)===t.id&&t.toggle(r,e==null?void 0:e.id):t.toggle(r,e==null?void 0:e.id)})}function s9t(r){const{subscribe:e,getSnapshot:t,setProps:n}=Tt.useRef(function(a){const o=a.containerId||1;return{subscribe(s){const l=function(u,h,g){let _=1,b=0,T=[],C=[],A=[],L=h;const U=new Map,j=new Set,Z=()=>{A=Array.from(U.values()),j.forEach(oe=>oe())},ee=oe=>{C=oe==null?[]:C.filter(ae=>ae!==oe),Z()},$=oe=>{const{toastId:ae,onOpen:ce,updateId:me,children:_e}=oe.props,Se=me==null;oe.staleId&&U.delete(oe.staleId),U.set(ae,oe),C=[...C,oe.props.toastId].filter(Ae=>Ae!==oe.staleId),Z(),g(o8e(oe,Se?"added":"updated")),Se&&m3(ce)&&ce(Tt.isValidElement(_e)&&_e.props)};return{id:u,props:L,observe:oe=>(j.add(oe),()=>j.delete(oe)),toggle:(oe,ae)=>{U.forEach(ce=>{ae!=null&&ae!==ce.props.toastId||m3(ce.toggle)&&ce.toggle(oe)})},removeToast:ee,toasts:U,clearQueue:()=>{b-=T.length,T=[]},buildToast:(oe,ae)=>{if((Fe=>{let{containerId:it,toastId:ct,updateId:ft}=Fe;const Nt=it?it!==u:u!==1,Rt=U.has(ct)&&ft==null;return Nt||Rt})(ae))return;const{toastId:ce,updateId:me,data:_e,staleId:Se,delay:Ae}=ae,ze=()=>{ee(ce)},Ne=me==null;Ne&&b++;const Oe={...L,style:L.toastStyle,key:_++,...Object.fromEntries(Object.entries(ae).filter(Fe=>{let[it,ct]=Fe;return ct!=null})),toastId:ce,updateId:me,data:_e,closeToast:ze,isIn:!1,className:OL(ae.className||L.toastClassName),bodyClassName:OL(ae.bodyClassName||L.bodyClassName),progressClassName:OL(ae.progressClassName||L.progressClassName),autoClose:!ae.isLoading&&(Le=ae.autoClose,Ie=L.autoClose,Le===!1||z7(Le)&&Le>0?Le:Ie),deleteToast(){const Fe=U.get(ce),{onClose:it,children:ct}=Fe.props;m3(it)&&it(Tt.isValidElement(ct)&&ct.props),g(o8e(Fe,"removed")),U.delete(ce),b--,b<0&&(b=0),T.length>0?$(T.shift()):Z()}};var Le,Ie;Oe.closeButton=L.closeButton,ae.closeButton===!1||eK(ae.closeButton)?Oe.closeButton=ae.closeButton:ae.closeButton===!0&&(Oe.closeButton=!eK(L.closeButton)||L.closeButton);let je=oe;Tt.isValidElement(oe)&&!KE(oe.type)?je=Tt.cloneElement(oe,{closeToast:ze,toastProps:Oe,data:_e}):m3(oe)&&(je=oe({closeToast:ze,toastProps:Oe,data:_e}));const Ue={content:je,props:Oe,staleId:Se};L.limit&&L.limit>0&&b>L.limit&&Ne?T.push(Ue):z7(Ae)?setTimeout(()=>{$(Ue)},Ae):$(Ue)},setProps(oe){L=oe},setToggle:(oe,ae)=>{U.get(oe).toggle=ae},isToastActive:oe=>C.some(ae=>ae===oe),getSnapshot:()=>A}}(o,a,o9t);w2.set(o,l);const c=l.observe(s);return F7.forEach(u=>c8e(u.content,u.options)),F7=[],()=>{c(),w2.delete(o)}},setProps(s){var l;(l=w2.get(o))==null||l.setProps(s)},getSnapshot(){var s;return(s=w2.get(o))==null?void 0:s.getSnapshot()}}}(r)).current;n(r);const i=Tt.useSyncExternalStore(e,t,t);return{getToastToRender:function(a){if(!i)return[];const o=new Map;return r.newestOnTop&&i.reverse(),i.forEach(s=>{const{position:l}=s.props;o.has(l)||o.set(l,[]),o.get(l).push(s)}),Array.from(o,s=>a(s[0],s[1]))},isToastActive:l8e,count:i==null?void 0:i.length}}function l9t(r){const[e,t]=Tt.useState(!1),[n,i]=Tt.useState(!1),a=Tt.useRef(null),o=Tt.useRef({start:0,delta:0,removalDistance:0,canCloseOnClick:!0,canDrag:!1,didMove:!1}).current,{autoClose:s,pauseOnHover:l,closeToast:c,onClick:u,closeOnClick:h}=r;var g,_;function b(){t(!0)}function T(){t(!1)}function C(U){const j=a.current;o.canDrag&&j&&(o.didMove=!0,e&&T(),o.delta=r.draggableDirection==="x"?U.clientX-o.start:U.clientY-o.start,o.start!==U.clientX&&(o.canCloseOnClick=!1),j.style.transform=`translate3d(${r.draggableDirection==="x"?`${o.delta}px, var(--y)`:`0, calc(${o.delta}px + var(--y))`},0)`,j.style.opacity=""+(1-Math.abs(o.delta/o.removalDistance)))}function A(){document.removeEventListener("pointermove",C),document.removeEventListener("pointerup",A);const U=a.current;if(o.canDrag&&o.didMove&&U){if(o.canDrag=!1,Math.abs(o.delta)>o.removalDistance)return i(!0),r.closeToast(),void r.collapseAll();U.style.transition="transform 0.2s, opacity 0.2s",U.style.removeProperty("transform"),U.style.removeProperty("opacity")}}(_=w2.get((g={id:r.toastId,containerId:r.containerId,fn:t}).containerId||1))==null||_.setToggle(g.id,g.fn),Tt.useEffect(()=>{if(r.pauseOnFocusLoss)return document.hasFocus()||T(),window.addEventListener("focus",b),window.addEventListener("blur",T),()=>{window.removeEventListener("focus",b),window.removeEventListener("blur",T)}},[r.pauseOnFocusLoss]);const L={onPointerDown:function(U){if(r.draggable===!0||r.draggable===U.pointerType){o.didMove=!1,document.addEventListener("pointermove",C),document.addEventListener("pointerup",A);const j=a.current;o.canCloseOnClick=!0,o.canDrag=!0,j.style.transition="none",r.draggableDirection==="x"?(o.start=U.clientX,o.removalDistance=j.offsetWidth*(r.draggablePercent/100)):(o.start=U.clientY,o.removalDistance=j.offsetHeight*(r.draggablePercent===80?1.5*r.draggablePercent:r.draggablePercent)/100)}},onPointerUp:function(U){const{top:j,bottom:Z,left:ee,right:$}=a.current.getBoundingClientRect();U.nativeEvent.type!=="touchend"&&r.pauseOnHover&&U.clientX>=ee&&U.clientX<=$&&U.clientY>=j&&U.clientY<=Z?T():b()}};return s&&l&&(L.onMouseEnter=T,r.stacked||(L.onMouseLeave=b)),h&&(L.onClick=U=>{u&&u(U),o.canCloseOnClick&&c()}),{playToast:b,pauseToast:T,isRunning:e,preventExitTransition:n,toastRef:a,eventHandlers:L}}function c9t(r){let{delay:e,isRunning:t,closeToast:n,type:i="default",hide:a,className:o,style:s,controlledProgress:l,progress:c,rtl:u,isIn:h,theme:g}=r;const _=a||l&&c===0,b={...s,animationDuration:`${e}ms`,animationPlayState:t?"running":"paused"};l&&(b.transform=`scaleX(${c})`);const T=xb("Toastify__progress-bar",l?"Toastify__progress-bar--controlled":"Toastify__progress-bar--animated",`Toastify__progress-bar-theme--${g}`,`Toastify__progress-bar--${i}`,{"Toastify__progress-bar--rtl":u}),C=m3(o)?o({rtl:u,type:i,defaultClassName:T}):xb(T,o),A={[l&&c>=1?"onTransitionEnd":"onAnimationEnd"]:l&&c<1?null:()=>{h&&n()}};return D0.createElement("div",{className:"Toastify__progress-bar--wrp","data-hidden":_},D0.createElement("div",{className:`Toastify__progress-bar--bg Toastify__progress-bar-theme--${g} Toastify__progress-bar--${i}`}),D0.createElement("div",{role:"progressbar","aria-hidden":_?"true":"false","aria-label":"notification timer",className:C,style:b,...A}))}let u9t=1;const f8e=()=>""+u9t++;function f9t(r){return r&&(KE(r.toastId)||z7(r.toastId))?r.toastId:f8e()}function I7(r,e){return c8e(r,e),e.toastId}function zL(r,e){return{...e,type:e&&e.type||r,toastId:f9t(e)}}function FL(r){return(e,t)=>I7(e,zL(r,t))}function Dy(r,e){return I7(r,zL("default",e))}Dy.loading=(r,e)=>I7(r,zL("default",{isLoading:!0,autoClose:!1,closeOnClick:!1,closeButton:!1,draggable:!1,...e})),Dy.promise=function(r,e,t){let n,{pending:i,error:a,success:o}=e;i&&(n=KE(i)?Dy.loading(i,t):Dy.loading(i.render,{...t,...i}));const s={isLoading:null,autoClose:null,closeOnClick:null,closeButton:null,draggable:null},l=(u,h,g)=>{if(h==null)return void Dy.dismiss(n);const _={type:u,...s,...t,data:g},b=KE(h)?{render:h}:h;return n?Dy.update(n,{..._,...b}):Dy(b.render,{..._,...b}),g},c=m3(r)?r():r;return c.then(u=>l("success",o,u)).catch(u=>l("error",a,u)),c},Dy.success=FL("success"),Dy.info=FL("info"),Dy.error=FL("error"),Dy.warning=FL("warning"),Dy.warn=Dy.warning,Dy.dark=(r,e)=>I7(r,zL("default",{theme:"dark",...e})),Dy.dismiss=function(r){(function(e){var t;if(s8e()){if(e==null||KE(t=e)||z7(t))w2.forEach(n=>{n.removeToast(e)});else if(e&&("containerId"in e||"id"in e)){const n=w2.get(e.containerId);n?n.removeToast(e.id):w2.forEach(i=>{i.removeToast(e.id)})}}else F7=F7.filter(n=>e!=null&&n.options.toastId!==e)})(r)},Dy.clearWaitingQueue=function(r){r===void 0&&(r={}),w2.forEach(e=>{!e.props.limit||r.containerId&&e.id!==r.containerId||e.clearQueue()})},Dy.isActive=l8e,Dy.update=function(r,e){e===void 0&&(e={});const t=((n,i)=>{var a;let{containerId:o}=i;return(a=w2.get(o||1))==null?void 0:a.toasts.get(n)})(r,e);if(t){const{props:n,content:i}=t,a={delay:100,...n,...e,toastId:e.toastId||r,updateId:f8e()};a.toastId!==r&&(a.staleId=r);const o=a.render||i;delete a.render,I7(o,a)}},Dy.done=r=>{Dy.update(r,{progress:1})},Dy.onChange=function(r){return tK.add(r),()=>{tK.delete(r)}},Dy.play=r=>u8e(!0,r),Dy.pause=r=>u8e(!1,r);const d9t=typeof window<"u"?Tt.useLayoutEffect:Tt.useEffect,IL=r=>{let{theme:e,type:t,isLoading:n,...i}=r;return D0.createElement("svg",{viewBox:"0 0 24 24",width:"100%",height:"100%",fill:e==="colored"?"currentColor":`var(--toastify-icon-color-${t})`,...i})},nK={info:function(r){return D0.createElement(IL,{...r},D0.createElement("path",{d:"M12 0a12 12 0 1012 12A12.013 12.013 0 0012 0zm.25 5a1.5 1.5 0 11-1.5 1.5 1.5 1.5 0 011.5-1.5zm2.25 13.5h-4a1 1 0 010-2h.75a.25.25 0 00.25-.25v-4.5a.25.25 0 00-.25-.25h-.75a1 1 0 010-2h1a2 2 0 012 2v4.75a.25.25 0 00.25.25h.75a1 1 0 110 2z"}))},warning:function(r){return D0.createElement(IL,{...r},D0.createElement("path",{d:"M23.32 17.191L15.438 2.184C14.728.833 13.416 0 11.996 0c-1.42 0-2.733.833-3.443 2.184L.533 17.448a4.744 4.744 0 000 4.368C1.243 23.167 2.555 24 3.975 24h16.05C22.22 24 24 22.044 24 19.632c0-.904-.251-1.746-.68-2.44zm-9.622 1.46c0 1.033-.724 1.823-1.698 1.823s-1.698-.79-1.698-1.822v-.043c0-1.028.724-1.822 1.698-1.822s1.698.79 1.698 1.822v.043zm.039-12.285l-.84 8.06c-.057.581-.408.943-.897.943-.49 0-.84-.367-.896-.942l-.84-8.065c-.057-.624.25-1.095.779-1.095h1.91c.528.005.84.476.784 1.1z"}))},success:function(r){return D0.createElement(IL,{...r},D0.createElement("path",{d:"M12 0a12 12 0 1012 12A12.014 12.014 0 0012 0zm6.927 8.2l-6.845 9.289a1.011 1.011 0 01-1.43.188l-4.888-3.908a1 1 0 111.25-1.562l4.076 3.261 6.227-8.451a1 1 0 111.61 1.183z"}))},error:function(r){return D0.createElement(IL,{...r},D0.createElement("path",{d:"M11.983 0a12.206 12.206 0 00-8.51 3.653A11.8 11.8 0 000 12.207 11.779 11.779 0 0011.8 24h.214A12.111 12.111 0 0024 11.791 11.766 11.766 0 0011.983 0zM10.5 16.542a1.476 1.476 0 011.449-1.53h.027a1.527 1.527 0 011.523 1.47 1.475 1.475 0 01-1.449 1.53h-.027a1.529 1.529 0 01-1.523-1.47zM11 12.5v-6a1 1 0 012 0v6a1 1 0 11-2 0z"}))},spinner:function(){return D0.createElement("div",{className:"Toastify__spinner"})}},h9t=r=>{const{isRunning:e,preventExitTransition:t,toastRef:n,eventHandlers:i,playToast:a}=l9t(r),{closeButton:o,children:s,autoClose:l,onClick:c,type:u,hideProgressBar:h,closeToast:g,transition:_,position:b,className:T,style:C,bodyClassName:A,bodyStyle:L,progressClassName:U,progressStyle:j,updateId:Z,role:ee,progress:$,rtl:oe,toastId:ae,deleteToast:ce,isIn:me,isLoading:_e,closeOnClick:Se,theme:Ae}=r,ze=xb("Toastify__toast",`Toastify__toast-theme--${Ae}`,`Toastify__toast--${u}`,{"Toastify__toast--rtl":oe},{"Toastify__toast--close-on-click":Se}),Ne=m3(T)?T({rtl:oe,position:b,type:u,defaultClassName:ze}):xb(ze,T),Oe=function(Ue){let{theme:Fe,type:it,isLoading:ct,icon:ft}=Ue,Nt=null;const Rt={theme:Fe,type:it};return ft===!1||(m3(ft)?Nt=ft({...Rt,isLoading:ct}):Tt.isValidElement(ft)?Nt=Tt.cloneElement(ft,Rt):ct?Nt=nK.spinner():(Wt=>Wt in nK)(it)&&(Nt=nK[it](Rt))),Nt}(r),Le=!!$||!l,Ie={closeToast:g,type:u,theme:Ae};let je=null;return o===!1||(je=m3(o)?o(Ie):Tt.isValidElement(o)?Tt.cloneElement(o,Ie):function(Ue){let{closeToast:Fe,theme:it,ariaLabel:ct="close"}=Ue;return D0.createElement("button",{className:`Toastify__close-button Toastify__close-button--${it}`,type:"button",onClick:ft=>{ft.stopPropagation(),Fe(ft)},"aria-label":ct},D0.createElement("svg",{"aria-hidden":"true",viewBox:"0 0 14 16"},D0.createElement("path",{fillRule:"evenodd",d:"M7.71 8.23l3.75 3.75-1.48 1.48-3.75-3.75-3.75 3.75L1 11.98l3.75-3.75L1 4.48 2.48 3l3.75 3.75L9.98 3l1.48 1.48-3.75 3.75z"})))}(Ie)),D0.createElement(_,{isIn:me,done:ce,position:b,preventExitTransition:t,nodeRef:n,playToast:a},D0.createElement("div",{id:ae,onClick:c,"data-in":me,className:Ne,...i,style:C,ref:n},D0.createElement("div",{...me&&{role:ee},className:m3(A)?A({type:u}):xb("Toastify__toast-body",A),style:L},Oe!=null&&D0.createElement("div",{className:xb("Toastify__toast-icon",{"Toastify--animate-icon Toastify__zoom-enter":!_e})},Oe),D0.createElement("div",null,s)),je,D0.createElement(c9t,{...Z&&!Le?{key:`pb-${Z}`}:{},rtl:oe,theme:Ae,delay:l,isRunning:e,isIn:me,closeToast:g,hide:h,type:u,style:j,className:U,controlledProgress:Le,progress:$||0})))},kL=function(r,e){return e===void 0&&(e=!1),{enter:`Toastify--animate Toastify__${r}-enter`,exit:`Toastify--animate Toastify__${r}-exit`,appendPosition:e}},p9t=UL(kL("bounce",!0));UL(kL("slide",!0)),UL(kL("zoom")),UL(kL("flip"));const m9t={position:"top-right",transition:p9t,autoClose:5e3,closeButton:!0,pauseOnHover:!0,pauseOnFocusLoss:!0,draggable:"touch",draggablePercent:80,draggableDirection:"x",role:"alert",theme:"light"};function v9t(r){let e={...m9t,...r};const t=r.stacked,[n,i]=Tt.useState(!0),a=Tt.useRef(null),{getToastToRender:o,isToastActive:s,count:l}=s9t(e),{className:c,style:u,rtl:h,containerId:g}=e;function _(T){const C=xb("Toastify__toast-container",`Toastify__toast-container--${T}`,{"Toastify__toast-container--rtl":h});return m3(c)?c({position:T,rtl:h,defaultClassName:C}):xb(C,OL(c))}function b(){t&&(i(!0),Dy.play())}return d9t(()=>{if(t){var T;const C=a.current.querySelectorAll('[data-in="true"]'),A=12,L=(T=e.position)==null?void 0:T.includes("top");let U=0,j=0;Array.from(C).reverse().forEach((Z,ee)=>{const $=Z;$.classList.add("Toastify__toast--stacked"),ee>0&&($.dataset.collapsed=`${n}`),$.dataset.pos||($.dataset.pos=L?"top":"bot");const oe=U*(n?.2:1)+(n?0:A*ee);$.style.setProperty("--y",`${L?oe:-1*oe}px`),$.style.setProperty("--g",`${A}`),$.style.setProperty("--s",""+(1-(n?j:0))),U+=$.offsetHeight,j+=.025})}},[n,l,t]),D0.createElement("div",{ref:a,className:"Toastify",id:g,onMouseEnter:()=>{t&&(i(!1),Dy.pause())},onMouseLeave:b},o((T,C)=>{const A=C.length?{...u}:{...u,pointerEvents:"none"};return D0.createElement("div",{className:_(T),style:A,key:`container-${T}`},C.map(L=>{let{content:U,props:j}=L;return D0.createElement(h9t,{...j,stacked:t,collapseAll:b,isIn:s(j.toastId,j.containerId),style:j.style,key:`toast-${j.key}`},U)}))}))}function y9t(){var r=':root{--toastify-color-light:#fff;--toastify-color-dark:#121212;--toastify-color-info:#3498db;--toastify-color-success:#07bc0c;--toastify-color-warning:#f1c40f;--toastify-color-error:#e74c3c;--toastify-color-transparent:hsla(0,0%,100%,.7);--toastify-icon-color-info:var(--toastify-color-info);--toastify-icon-color-success:var(--toastify-color-success);--toastify-icon-color-warning:var(--toastify-color-warning);--toastify-icon-color-error:var(--toastify-color-error);--toastify-toast-width:320px;--toastify-toast-offset:16px;--toastify-toast-top:max(var(--toastify-toast-offset),env(safe-area-inset-top));--toastify-toast-right:max(var(--toastify-toast-offset),env(safe-area-inset-right));--toastify-toast-left:max(var(--toastify-toast-offset),env(safe-area-inset-left));--toastify-toast-bottom:max(var(--toastify-toast-offset),env(safe-area-inset-bottom));--toastify-toast-background:#fff;--toastify-toast-min-height:64px;--toastify-toast-max-height:800px;--toastify-toast-bd-radius:6px;--toastify-font-family:sans-serif;--toastify-z-index:9999;--toastify-text-color-light:#757575;--toastify-text-color-dark:#fff;--toastify-text-color-info:#fff;--toastify-text-color-success:#fff;--toastify-text-color-warning:#fff;--toastify-text-color-error:#fff;--toastify-spinner-color:#616161;--toastify-spinner-color-empty-area:#e0e0e0;--toastify-color-progress-light:linear-gradient(90deg,#4cd964,#5ac8fa,#007aff,#34aadc,#5856d6,#ff2d55);--toastify-color-progress-dark:#bb86fc;--toastify-color-progress-info:var(--toastify-color-info);--toastify-color-progress-success:var(--toastify-color-success);--toastify-color-progress-warning:var(--toastify-color-warning);--toastify-color-progress-error:var(--toastify-color-error);--toastify-color-progress-bgo:0.2}.Toastify__toast-container{z-index:var(--toastify-z-index);-webkit-transform:translateZ(var(--toastify-z-index));position:fixed;padding:4px;width:var(--toastify-toast-width);box-sizing:border-box;color:#fff}.Toastify__toast-container--top-left{top:var(--toastify-toast-top);left:var(--toastify-toast-left)}.Toastify__toast-container--top-center{top:var(--toastify-toast-top);left:50%;transform:translateX(-50%)}.Toastify__toast-container--top-right{top:var(--toastify-toast-top);right:var(--toastify-toast-right)}.Toastify__toast-container--bottom-left{bottom:var(--toastify-toast-bottom);left:var(--toastify-toast-left)}.Toastify__toast-container--bottom-center{bottom:var(--toastify-toast-bottom);left:50%;transform:translateX(-50%)}.Toastify__toast-container--bottom-right{bottom:var(--toastify-toast-bottom);right:var(--toastify-toast-right)}@media only screen and (max-width:480px){.Toastify__toast-container{width:100vw;padding:0;left:env(safe-area-inset-left);margin:0}.Toastify__toast-container--top-center,.Toastify__toast-container--top-left,.Toastify__toast-container--top-right{top:env(safe-area-inset-top);transform:translateX(0)}.Toastify__toast-container--bottom-center,.Toastify__toast-container--bottom-left,.Toastify__toast-container--bottom-right{bottom:env(safe-area-inset-bottom);transform:translateX(0)}.Toastify__toast-container--rtl{right:env(safe-area-inset-right);left:auto}}.Toastify__toast{--y:0;position:relative;-ms-touch-action:none;touch-action:none;min-height:var(--toastify-toast-min-height);box-sizing:border-box;margin-bottom:1rem;padding:8px;border-radius:var(--toastify-toast-bd-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;max-height:var(--toastify-toast-max-height);font-family:var(--toastify-font-family);cursor:default;direction:ltr;z-index:0;overflow:hidden}.Toastify__toast--stacked{position:absolute;width:100%;transform:translate3d(0,var(--y),0) scale(var(--s));transition:transform .3s}.Toastify__toast--stacked[data-collapsed] .Toastify__close-button,.Toastify__toast--stacked[data-collapsed] .Toastify__toast-body{transition:opacity .1s}.Toastify__toast--stacked[data-collapsed=false]{overflow:visible}.Toastify__toast--stacked[data-collapsed=true]:not(:last-child)>*{opacity:0}.Toastify__toast--stacked:after{content:"";position:absolute;left:0;right:0;height:calc(var(--g) * 1px);bottom:100%}.Toastify__toast--stacked[data-pos=top]{top:0}.Toastify__toast--stacked[data-pos=bot]{bottom:0}.Toastify__toast--stacked[data-pos=bot].Toastify__toast--stacked:before{transform-origin:top}.Toastify__toast--stacked[data-pos=top].Toastify__toast--stacked:before{transform-origin:bottom}.Toastify__toast--stacked:before{content:"";position:absolute;left:0;right:0;bottom:0;height:100%;transform:scaleY(3);z-index:-1}.Toastify__toast--rtl{direction:rtl}.Toastify__toast--close-on-click{cursor:pointer}.Toastify__toast-body{margin:auto 0;-ms-flex:1 1 auto;flex:1 1 auto;padding:6px;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.Toastify__toast-body>div:last-child{word-break:break-word;-ms-flex:1;flex:1}.Toastify__toast-icon{-webkit-margin-end:10px;margin-inline-end:10px;width:20px;-ms-flex-negative:0;flex-shrink:0;display:-ms-flexbox;display:flex}.Toastify--animate{animation-fill-mode:both;animation-duration:.5s}.Toastify--animate-icon{animation-fill-mode:both;animation-duration:.3s}@media only screen and (max-width:480px){.Toastify__toast{margin-bottom:0;border-radius:0}}.Toastify__toast-theme--dark{background:var(--toastify-color-dark);color:var(--toastify-text-color-dark)}.Toastify__toast-theme--colored.Toastify__toast--default,.Toastify__toast-theme--light{background:var(--toastify-color-light);color:var(--toastify-text-color-light)}.Toastify__toast-theme--colored.Toastify__toast--info{color:var(--toastify-text-color-info);background:var(--toastify-color-info)}.Toastify__toast-theme--colored.Toastify__toast--success{color:var(--toastify-text-color-success);background:var(--toastify-color-success)}.Toastify__toast-theme--colored.Toastify__toast--warning{color:var(--toastify-text-color-warning);background:var(--toastify-color-warning)}.Toastify__toast-theme--colored.Toastify__toast--error{color:var(--toastify-text-color-error);background:var(--toastify-color-error)}.Toastify__progress-bar-theme--light{background:var(--toastify-color-progress-light)}.Toastify__progress-bar-theme--dark{background:var(--toastify-color-progress-dark)}.Toastify__progress-bar--info{background:var(--toastify-color-progress-info)}.Toastify__progress-bar--success{background:var(--toastify-color-progress-success)}.Toastify__progress-bar--warning{background:var(--toastify-color-progress-warning)}.Toastify__progress-bar--error{background:var(--toastify-color-progress-error)}.Toastify__progress-bar-theme--colored.Toastify__progress-bar--error,.Toastify__progress-bar-theme--colored.Toastify__progress-bar--info,.Toastify__progress-bar-theme--colored.Toastify__progress-bar--success,.Toastify__progress-bar-theme--colored.Toastify__progress-bar--warning{background:var(--toastify-color-transparent)}.Toastify__close-button{color:#fff;background:transparent;outline:none;border:none;padding:0;cursor:pointer;opacity:.7;transition:.3s ease;-ms-flex-item-align:start;align-self:flex-start;z-index:1}.Toastify__close-button--light{color:#000;opacity:.3}.Toastify__close-button>svg{fill:currentColor;height:16px;width:14px}.Toastify__close-button:focus,.Toastify__close-button:hover{opacity:1}@keyframes Toastify__trackProgress{0%{transform:scaleX(1)}to{transform:scaleX(0)}}.Toastify__progress-bar{position:absolute;bottom:0;left:0;width:100%;height:100%;z-index:var(--toastify-z-index);opacity:.7;transform-origin:left;border-bottom-left-radius:var(--toastify-toast-bd-radius)}.Toastify__progress-bar--animated{animation:Toastify__trackProgress linear 1 forwards}.Toastify__progress-bar--controlled{transition:transform .2s}.Toastify__progress-bar--rtl{right:0;left:auto;transform-origin:right;border-bottom-left-radius:0;border-bottom-right-radius:var(--toastify-toast-bd-radius)}.Toastify__progress-bar--wrp{position:absolute;bottom:0;left:0;width:100%;height:5px;border-bottom-left-radius:var(--toastify-toast-bd-radius)}.Toastify__progress-bar--wrp[data-hidden=true]{opacity:0}.Toastify__progress-bar--bg{opacity:var(--toastify-color-progress-bgo);width:100%;height:100%}.Toastify__spinner{width:20px;height:20px;box-sizing:border-box;border:2px solid;border-radius:100%;border-color:var(--toastify-spinner-color-empty-area);border-right-color:var(--toastify-spinner-color);animation:Toastify__spin .65s linear infinite}@keyframes Toastify__bounceInRight{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(3000px,0,0)}60%{opacity:1;transform:translate3d(-25px,0,0)}75%{transform:translate3d(10px,0,0)}90%{transform:translate3d(-5px,0,0)}to{transform:none}}@keyframes Toastify__bounceOutRight{20%{opacity:1;transform:translate3d(-20px,var(--y),0)}to{opacity:0;transform:translate3d(2000px,var(--y),0)}}@keyframes Toastify__bounceInLeft{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(-3000px,0,0)}60%{opacity:1;transform:translate3d(25px,0,0)}75%{transform:translate3d(-10px,0,0)}90%{transform:translate3d(5px,0,0)}to{transform:none}}@keyframes Toastify__bounceOutLeft{20%{opacity:1;transform:translate3d(20px,var(--y),0)}to{opacity:0;transform:translate3d(-2000px,var(--y),0)}}@keyframes Toastify__bounceInUp{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(0,3000px,0)}60%{opacity:1;transform:translate3d(0,-20px,0)}75%{transform:translate3d(0,10px,0)}90%{transform:translate3d(0,-5px,0)}to{transform:translateZ(0)}}@keyframes Toastify__bounceOutUp{20%{transform:translate3d(0,calc(var(--y) - 10px),0)}40%,45%{opacity:1;transform:translate3d(0,calc(var(--y) + 20px),0)}to{opacity:0;transform:translate3d(0,-2000px,0)}}@keyframes Toastify__bounceInDown{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(0,-3000px,0)}60%{opacity:1;transform:translate3d(0,25px,0)}75%{transform:translate3d(0,-10px,0)}90%{transform:translate3d(0,5px,0)}to{transform:none}}@keyframes Toastify__bounceOutDown{20%{transform:translate3d(0,calc(var(--y) - 10px),0)}40%,45%{opacity:1;transform:translate3d(0,calc(var(--y) + 20px),0)}to{opacity:0;transform:translate3d(0,2000px,0)}}.Toastify__bounce-enter--bottom-left,.Toastify__bounce-enter--top-left{animation-name:Toastify__bounceInLeft}.Toastify__bounce-enter--bottom-right,.Toastify__bounce-enter--top-right{animation-name:Toastify__bounceInRight}.Toastify__bounce-enter--top-center{animation-name:Toastify__bounceInDown}.Toastify__bounce-enter--bottom-center{animation-name:Toastify__bounceInUp}.Toastify__bounce-exit--bottom-left,.Toastify__bounce-exit--top-left{animation-name:Toastify__bounceOutLeft}.Toastify__bounce-exit--bottom-right,.Toastify__bounce-exit--top-right{animation-name:Toastify__bounceOutRight}.Toastify__bounce-exit--top-center{animation-name:Toastify__bounceOutUp}.Toastify__bounce-exit--bottom-center{animation-name:Toastify__bounceOutDown}@keyframes Toastify__zoomIn{0%{opacity:0;transform:scale3d(.3,.3,.3)}50%{opacity:1}}@keyframes Toastify__zoomOut{0%{opacity:1}50%{opacity:0;transform:translate3d(0,var(--y),0) scale3d(.3,.3,.3)}to{opacity:0}}.Toastify__zoom-enter{animation-name:Toastify__zoomIn}.Toastify__zoom-exit{animation-name:Toastify__zoomOut}@keyframes Toastify__flipIn{0%{transform:perspective(400px) rotateX(90deg);animation-timing-function:ease-in;opacity:0}40%{transform:perspective(400px) rotateX(-20deg);animation-timing-function:ease-in}60%{transform:perspective(400px) rotateX(10deg);opacity:1}80%{transform:perspective(400px) rotateX(-5deg)}to{transform:perspective(400px)}}@keyframes Toastify__flipOut{0%{transform:translate3d(0,var(--y),0) perspective(400px)}30%{transform:translate3d(0,var(--y),0) perspective(400px) rotateX(-20deg);opacity:1}to{transform:translate3d(0,var(--y),0) perspective(400px) rotateX(90deg);opacity:0}}.Toastify__flip-enter{animation-name:Toastify__flipIn}.Toastify__flip-exit{animation-name:Toastify__flipOut}@keyframes Toastify__slideInRight{0%{transform:translate3d(110%,0,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideInLeft{0%{transform:translate3d(-110%,0,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideInUp{0%{transform:translate3d(0,110%,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideInDown{0%{transform:translate3d(0,-110%,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideOutRight{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(110%,var(--y),0)}}@keyframes Toastify__slideOutLeft{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(-110%,var(--y),0)}}@keyframes Toastify__slideOutDown{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(0,500px,0)}}@keyframes Toastify__slideOutUp{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(0,-500px,0)}}.Toastify__slide-enter--bottom-left,.Toastify__slide-enter--top-left{animation-name:Toastify__slideInLeft}.Toastify__slide-enter--bottom-right,.Toastify__slide-enter--top-right{animation-name:Toastify__slideInRight}.Toastify__slide-enter--top-center{animation-name:Toastify__slideInDown}.Toastify__slide-enter--bottom-center{animation-name:Toastify__slideInUp}.Toastify__slide-exit--bottom-left,.Toastify__slide-exit--top-left{animation-name:Toastify__slideOutLeft;animation-timing-function:ease-in;animation-duration:.3s}.Toastify__slide-exit--bottom-right,.Toastify__slide-exit--top-right{animation-name:Toastify__slideOutRight;animation-timing-function:ease-in;animation-duration:.3s}.Toastify__slide-exit--top-center{animation-name:Toastify__slideOutUp;animation-timing-function:ease-in;animation-duration:.3s}.Toastify__slide-exit--bottom-center{animation-name:Toastify__slideOutDown;animation-timing-function:ease-in;animation-duration:.3s}@keyframes Toastify__spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}',e=document.createElement("style");e.innerText=r,document.head.appendChild(e)}const d8e=p8(AIe);var rK,h8e;function g9t(){if(h8e)return rK;h8e=1;var r=Object.defineProperty,e=Object.getOwnPropertyDescriptor,t=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,i=(C,A)=>{for(var L in A)r(C,L,{get:A[L],enumerable:!0})},a=(C,A,L,U)=>{if(A&&typeof A=="object"||typeof A=="function")for(let j of t(A))!n.call(C,j)&&j!==L&&r(C,j,{get:()=>A[j],enumerable:!(U=e(A,j))||U.enumerable});return C},o=C=>a(r({},"__esModule",{value:!0}),C),s={};i(s,{SuperGrid:()=>T,toMMSI:()=>b,toMeterSI:()=>_}),rK=o(s);var l=Mx(),c=d8e,u=sne(),h=(C,A,L)=>{const U=[];if(A<C)for(let j=C;j>=A;j-=Math.abs(L))U.push(j);else for(let j=C;j<=A;j+=Math.abs(L))U.push(j);return U};function g(C,A){return{x:Math.round(A.x/C)*C,y:Math.round(A.y/C)*C}}function _(C,A=1){return C<0?"-"+_(-C):C<1e-6?"0m":C>1e3?Math.floor(C/1e3)+"km":C>1&&A>1?Math.round(C)+"m":C>1&&A<=1?C.toFixed(Math.ceil(-Math.log10(A)))+"m":C<1&&A>=1/1e3?Math.round(C*1e3)+"mm":C<1&&A<1/1e3?(C*1e3).toFixed(Math.ceil(-Math.log10(A*1e3)))+"mm":""}function b(C,A=1){return _(C/1e3,A/1e3)}var T=C=>{var A;const L=(0,l.useRef)(null),[U,j]=(0,l.useState)({x:0,y:0}),{majorColor:Z="rgba(0,0,0,0.2)",minorColor:ee="rgba(0,0,0,0.1)",textColor:$=(A=C.majorColor)!=null?A:"rgba(0,0,0,0.5)",width:oe,height:ae,screenSpaceCellSize:ce=200,stringifyCoord:me=(ze,Ne,Oe)=>`${_(ze,Oe)}, ${_(Ne,Oe)}`}=C,_e=Math.ceil(oe/ce)+2,Se=Math.ceil(ae/ce)+2;(0,l.useEffect)(()=>{if(!L.current)return;const ze=L.current.getContext("2d");if(!ze)return;const Ne=ce/10**Math.floor(Math.log10(C.transform.a)),Oe=C.transform.d<0?-1:1,Ie=ce/10**Math.log10(C.transform.a)/Ne;function je(Gn,Sn,hn){const _n=Gn;let Gt,sr,Jn;for(Gt=Sn.x;Gt<=hn.x;Gt+=_n)sr=(0,c.applyToPoint)(C.transform,{x:Gt,y:Sn.y}),Jn=(0,c.applyToPoint)(C.transform,{x:Gt,y:hn.y}),ze.beginPath(),ze.moveTo(sr.x,sr.y),ze.lineTo(Jn.x,Jn.y),ze.stroke();const an=h(Sn.y,hn.y,_n*Oe);for(const nr of an)sr=(0,c.applyToPoint)(C.transform,{x:Sn.x,y:nr}),Jn=(0,c.applyToPoint)(C.transform,{x:hn.x,y:nr}),ze.beginPath(),ze.moveTo(sr.x,sr.y),ze.lineTo(Jn.x,Jn.y),ze.stroke()}function Ue(Gn,Sn,hn){const _n=Gn;let Gt;for(Gt=Sn.x;Gt<=hn.x;Gt+=_n)for(const sr of h(Sn.y,hn.y,_n*Oe)){const Jn=(0,c.applyToPoint)(C.transform,{x:Gt,y:sr});ze.fillStyle=$,ze.font="12px sans-serif",ze.fillText(me(Gt,sr,Gn),Jn.x+2,Jn.y-2)}}ze.clearRect(0,0,oe,ae);const Fe=(0,c.applyToPoint)((0,c.inverse)(C.transform),{x:0,y:0}),it={x:Math.floor((Fe.x-Ne)/Ne)*Ne,y:Math.floor((Fe.y-Ne)/Ne+(Oe==-1?2:0))*Ne},ct={x:it.x+Ne*_e,y:it.y+Ne*Se*Oe},Nt=Ne*5,Rt={x:Math.floor((Fe.x-Nt)/Nt)*Nt,y:Math.floor((Fe.y-Nt)/Nt+(Oe==-1?2:0))*Nt},Wt={x:Rt.x+Nt*_e,y:Rt.y+Nt*Se*Oe};ze.globalAlpha=1,ze.strokeStyle=Z,je(Ne,it,ct),Ue(Nt,Rt,Wt),ze.globalAlpha=1-Ie,je(Nt/10,Rt,Wt),ze.globalAlpha=1-Ie,ze.strokeStyle=ee,je(Ne/10,it,ct),ze.globalAlpha=Math.max(((1-Ie)*10-5)/5,0),Ue(Nt/10,Rt,Wt),ze.globalAlpha=1;const en=(0,c.applyToPoint)(C.transform,U);ze.font="12px sans-serif",ze.fillStyle=$,ze.fillText(me(U.x,U.y,Ne),en.x+2,en.y-2),ze.strokeStyle=Z,ze.strokeRect(en.x-5,en.y-5,10,10)},[L,C.transform,U,oe,ae]);const Ae=ze=>{if(!L.current)return;const Ne=ce/10/10**Math.floor(Math.log10(C.transform.a)),Oe=L.current.getBoundingClientRect(),Le=(0,c.applyToPoint)((0,c.inverse)(C.transform),{x:ze.clientX-Oe.left,y:ze.clientY-Oe.top}),Ie=g(Ne,Le);j(Ie)};return(0,u.jsx)("canvas",{onMouseUp:ze=>{ze.button===1&&Ae(ze)},onDoubleClick:Ae,ref:L,width:C.width,height:C.height})};return rK}var iK=g9t();function _9t(r,e,t){const n=(t.x-e.x)**2+(t.y-e.y)**2;if(n===0)return p8e(r,e);let i=((r.x-e.x)*(t.x-e.x)+(r.y-e.y)*(t.y-e.y))/n;i=Math.max(0,Math.min(1,i));const a={x:e.x+i*(t.x-e.x),y:e.y+i*(t.y-e.y)};return p8e(r,a)}function p8e(r,e){const t=r.x-e.x,n=r.y-e.y;return Math.sqrt(t*t+n*n)}var x9t=!1;function b9t(r){if(r.sheet)return r.sheet;for(var e=0;e<document.styleSheets.length;e++)if(document.styleSheets[e].ownerNode===r)return document.styleSheets[e]}function S9t(r){var e=document.createElement("style");return e.setAttribute("data-emotion",r.key),r.nonce!==void 0&&e.setAttribute("nonce",r.nonce),e.appendChild(document.createTextNode("")),e.setAttribute("data-s",""),e}var E9t=function(){function r(t){var n=this;this._insertTag=function(i){var a;n.tags.length===0?n.insertionPoint?a=n.insertionPoint.nextSibling:n.prepend?a=n.container.firstChild:a=n.before:a=n.tags[n.tags.length-1].nextSibling,n.container.insertBefore(i,a),n.tags.push(i)},this.isSpeedy=t.speedy===void 0?!x9t:t.speedy,this.tags=[],this.ctr=0,this.nonce=t.nonce,this.key=t.key,this.container=t.container,this.prepend=t.prepend,this.insertionPoint=t.insertionPoint,this.before=null}var e=r.prototype;return e.hydrate=function(n){n.forEach(this._insertTag)},e.insert=function(n){this.ctr%(this.isSpeedy?65e3:1)===0&&this._insertTag(S9t(this));var i=this.tags[this.tags.length-1];if(this.isSpeedy){var a=b9t(i);try{a.insertRule(n,a.cssRules.length)}catch{}}else i.appendChild(document.createTextNode(n));this.ctr++},e.flush=function(){this.tags.forEach(function(n){var i;return(i=n.parentNode)==null?void 0:i.removeChild(n)}),this.tags=[],this.ctr=0},r}(),r2="-ms-",BL="-moz-",x1="-webkit-",m8e="comm",aK="rule",oK="decl",w9t="@import",v8e="@keyframes",T9t="@layer",M9t=Math.abs,HL=String.fromCharCode,C9t=Object.assign;function R9t(r,e){return C5(r,0)^45?(((e<<2^C5(r,0))<<2^C5(r,1))<<2^C5(r,2))<<2^C5(r,3):0}function y8e(r){return r.trim()}function A9t(r,e){return(r=e.exec(r))?r[0]:r}function b1(r,e,t){return r.replace(e,t)}function sK(r,e){return r.indexOf(e)}function C5(r,e){return r.charCodeAt(e)|0}function k7(r,e,t){return r.slice(e,t)}function jb(r){return r.length}function lK(r){return r.length}function VL(r,e){return e.push(r),r}function D9t(r,e){return r.map(e).join("")}var jL=1,tw=1,g8e=0,K2=0,J_=0,nw="";function GL(r,e,t,n,i,a,o){return{value:r,root:e,parent:t,type:n,props:i,children:a,line:jL,column:tw,length:o,return:""}}function B7(r,e){return C9t(GL("",null,null,"",null,null,0),r,{length:-r.length},e)}function P9t(){return J_}function N9t(){return J_=K2>0?C5(nw,--K2):0,tw--,J_===10&&(tw=1,jL--),J_}function v3(){return J_=K2<g8e?C5(nw,K2++):0,tw++,J_===10&&(tw=1,jL++),J_}function Gb(){return C5(nw,K2)}function qL(){return K2}function H7(r,e){return k7(nw,r,e)}function V7(r){switch(r){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function _8e(r){return jL=tw=1,g8e=jb(nw=r),K2=0,[]}function x8e(r){return nw="",r}function YL(r){return y8e(H7(K2-1,cK(r===91?r+2:r===40?r+1:r)))}function L9t(r){for(;(J_=Gb())&&J_<33;)v3();return V7(r)>2||V7(J_)>3?"":" "}function O9t(r,e){for(;--e&&v3()&&!(J_<48||J_>102||J_>57&&J_<65||J_>70&&J_<97););return H7(r,qL()+(e<6&&Gb()==32&&v3()==32))}function cK(r){for(;v3();)switch(J_){case r:return K2;case 34:case 39:r!==34&&r!==39&&cK(J_);break;case 40:r===41&&cK(r);break;case 92:v3();break}return K2}function U9t(r,e){for(;v3()&&r+J_!==57;)if(r+J_===84&&Gb()===47)break;return"/*"+H7(e,K2-1)+"*"+HL(r===47?r:v3())}function z9t(r){for(;!V7(Gb());)v3();return H7(r,K2)}function F9t(r){return x8e(XL("",null,null,null,[""],r=_8e(r),0,[0],r))}function XL(r,e,t,n,i,a,o,s,l){for(var c=0,u=0,h=o,g=0,_=0,b=0,T=1,C=1,A=1,L=0,U="",j=i,Z=a,ee=n,$=U;C;)switch(b=L,L=v3()){case 40:if(b!=108&&C5($,h-1)==58){sK($+=b1(YL(L),"&","&\f"),"&\f")!=-1&&(A=-1);break}case 34:case 39:case 91:$+=YL(L);break;case 9:case 10:case 13:case 32:$+=L9t(b);break;case 92:$+=O9t(qL()-1,7);continue;case 47:switch(Gb()){case 42:case 47:VL(I9t(U9t(v3(),qL()),e,t),l);break;default:$+="/"}break;case 123*T:s[c++]=jb($)*A;case 125*T:case 59:case 0:switch(L){case 0:case 125:C=0;case 59+u:A==-1&&($=b1($,/\f/g,"")),_>0&&jb($)-h&&VL(_>32?S8e($+";",n,t,h-1):S8e(b1($," ","")+";",n,t,h-2),l);break;case 59:$+=";";default:if(VL(ee=b8e($,e,t,c,u,i,s,U,j=[],Z=[],h),a),L===123)if(u===0)XL($,e,ee,ee,j,a,h,s,Z);else switch(g===99&&C5($,3)===110?100:g){case 100:case 108:case 109:case 115:XL(r,ee,ee,n&&VL(b8e(r,ee,ee,0,0,i,s,U,i,j=[],h),Z),i,Z,h,s,n?j:Z);break;default:XL($,ee,ee,ee,[""],Z,0,s,Z)}}c=u=_=0,T=A=1,U=$="",h=o;break;case 58:h=1+jb($),_=b;default:if(T<1){if(L==123)--T;else if(L==125&&T++==0&&N9t()==125)continue}switch($+=HL(L),L*T){case 38:A=u>0?1:($+="\f",-1);break;case 44:s[c++]=(jb($)-1)*A,A=1;break;case 64:Gb()===45&&($+=YL(v3())),g=Gb(),u=h=jb(U=$+=z9t(qL())),L++;break;case 45:b===45&&jb($)==2&&(T=0)}}return a}function b8e(r,e,t,n,i,a,o,s,l,c,u){for(var h=i-1,g=i===0?a:[""],_=lK(g),b=0,T=0,C=0;b<n;++b)for(var A=0,L=k7(r,h+1,h=M9t(T=o[b])),U=r;A<_;++A)(U=y8e(T>0?g[A]+" "+L:b1(L,/&\f/g,g[A])))&&(l[C++]=U);return GL(r,e,t,i===0?aK:s,l,c,u)}function I9t(r,e,t){return GL(r,e,t,m8e,HL(P9t()),k7(r,2,-2),0)}function S8e(r,e,t,n){return GL(r,e,t,oK,k7(r,0,n),k7(r,n+1,-1),n)}function rw(r,e){for(var t="",n=lK(r),i=0;i<n;i++)t+=e(r[i],i,r,e)||"";return t}function k9t(r,e,t,n){switch(r.type){case T9t:if(r.children.length)break;case w9t:case oK:return r.return=r.return||r.value;case m8e:return"";case v8e:return r.return=r.value+"{"+rw(r.children,n)+"}";case aK:r.value=r.props.join(",")}return jb(t=rw(r.children,n))?r.return=r.value+"{"+t+"}":""}function B9t(r){var e=lK(r);return function(t,n,i,a){for(var o="",s=0;s<e;s++)o+=r[s](t,n,i,a)||"";return o}}function H9t(r){return function(e){e.root||(e=e.return)&&r(e)}}function V9t(r){var e=Object.create(null);return function(t){return e[t]===void 0&&(e[t]=r(t)),e[t]}}var j9t=function(e,t,n){for(var i=0,a=0;i=a,a=Gb(),i===38&&a===12&&(t[n]=1),!V7(a);)v3();return H7(e,K2)},G9t=function(e,t){var n=-1,i=44;do switch(V7(i)){case 0:i===38&&Gb()===12&&(t[n]=1),e[n]+=j9t(K2-1,t,n);break;case 2:e[n]+=YL(i);break;case 4:if(i===44){e[++n]=Gb()===58?"&\f":"",t[n]=e[n].length;break}default:e[n]+=HL(i)}while(i=v3());return e},q9t=function(e,t){return x8e(G9t(_8e(e),t))},E8e=new WeakMap,Y9t=function(e){if(!(e.type!=="rule"||!e.parent||e.length<1)){for(var t=e.value,n=e.parent,i=e.column===n.column&&e.line===n.line;n.type!=="rule";)if(n=n.parent,!n)return;if(!(e.props.length===1&&t.charCodeAt(0)!==58&&!E8e.get(n))&&!i){E8e.set(e,!0);for(var a=[],o=q9t(t,a),s=n.props,l=0,c=0;l<o.length;l++)for(var u=0;u<s.length;u++,c++)e.props[c]=a[l]?o[l].replace(/&\f/g,s[u]):s[u]+" "+o[l]}}},X9t=function(e){if(e.type==="decl"){var t=e.value;t.charCodeAt(0)===108&&t.charCodeAt(2)===98&&(e.return="",e.value="")}};function w8e(r,e){switch(R9t(r,e)){case 5103:return x1+"print-"+r+r;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return x1+r+r;case 5349:case 4246:case 4810:case 6968:case 2756:return x1+r+BL+r+r2+r+r;case 6828:case 4268:return x1+r+r2+r+r;case 6165:return x1+r+r2+"flex-"+r+r;case 5187:return x1+r+b1(r,/(\w+).+(:[^]+)/,x1+"box-$1$2"+r2+"flex-$1$2")+r;case 5443:return x1+r+r2+"flex-item-"+b1(r,/flex-|-self/,"")+r;case 4675:return x1+r+r2+"flex-line-pack"+b1(r,/align-content|flex-|-self/,"")+r;case 5548:return x1+r+r2+b1(r,"shrink","negative")+r;case 5292:return x1+r+r2+b1(r,"basis","preferred-size")+r;case 6060:return x1+"box-"+b1(r,"-grow","")+x1+r+r2+b1(r,"grow","positive")+r;case 4554:return x1+b1(r,/([^-])(transform)/g,"$1"+x1+"$2")+r;case 6187:return b1(b1(b1(r,/(zoom-|grab)/,x1+"$1"),/(image-set)/,x1+"$1"),r,"")+r;case 5495:case 3959:return b1(r,/(image-set\([^]*)/,x1+"$1$`$1");case 4968:return b1(b1(r,/(.+:)(flex-)?(.*)/,x1+"box-pack:$3"+r2+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+x1+r+r;case 4095:case 3583:case 4068:case 2532:return b1(r,/(.+)-inline(.+)/,x1+"$1$2")+r;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(jb(r)-1-e>6)switch(C5(r,e+1)){case 109:if(C5(r,e+4)!==45)break;case 102:return b1(r,/(.+:)(.+)-([^]+)/,"$1"+x1+"$2-$3$1"+BL+(C5(r,e+3)==108?"$3":"$2-$3"))+r;case 115:return~sK(r,"stretch")?w8e(b1(r,"stretch","fill-available"),e)+r:r}break;case 4949:if(C5(r,e+1)!==115)break;case 6444:switch(C5(r,jb(r)-3-(~sK(r,"!important")&&10))){case 107:return b1(r,":",":"+x1)+r;case 101:return b1(r,/(.+:)([^;!]+)(;|!.+)?/,"$1"+x1+(C5(r,14)===45?"inline-":"")+"box$3$1"+x1+"$2$3$1"+r2+"$2box$3")+r}break;case 5936:switch(C5(r,e+11)){case 114:return x1+r+r2+b1(r,/[svh]\w+-[tblr]{2}/,"tb")+r;case 108:return x1+r+r2+b1(r,/[svh]\w+-[tblr]{2}/,"tb-rl")+r;case 45:return x1+r+r2+b1(r,/[svh]\w+-[tblr]{2}/,"lr")+r}return x1+r+r2+r+r}return r}var W9t=function(e,t,n,i){if(e.length>-1&&!e.return)switch(e.type){case oK:e.return=w8e(e.value,e.length);break;case v8e:return rw([B7(e,{value:b1(e.value,"@","@"+x1)})],i);case aK:if(e.length)return D9t(e.props,function(a){switch(A9t(a,/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":return rw([B7(e,{props:[b1(a,/:(read-\w+)/,":"+BL+"$1")]})],i);case"::placeholder":return rw([B7(e,{props:[b1(a,/:(plac\w+)/,":"+x1+"input-$1")]}),B7(e,{props:[b1(a,/:(plac\w+)/,":"+BL+"$1")]}),B7(e,{props:[b1(a,/:(plac\w+)/,r2+"input-$1")]})],i)}return""})}},$9t=[W9t],Z9t=function(e){var t=e.key;if(t==="css"){var n=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(n,function(T){var C=T.getAttribute("data-emotion");C.indexOf(" ")!==-1&&(document.head.appendChild(T),T.setAttribute("data-s",""))})}var i=e.stylisPlugins||$9t,a={},o,s=[];o=e.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+t+' "]'),function(T){for(var C=T.getAttribute("data-emotion").split(" "),A=1;A<C.length;A++)a[C[A]]=!0;s.push(T)});var l,c=[Y9t,X9t];{var u,h=[k9t,H9t(function(T){u.insert(T)})],g=B9t(c.concat(i,h)),_=function(C){return rw(F9t(C),g)};l=function(C,A,L,U){u=L,_(C?C+"{"+A.styles+"}":A.styles),U&&(b.inserted[A.name]=!0)}}var b={key:t,sheet:new E9t({key:t,container:o,nonce:e.nonce,speedy:e.speedy,prepend:e.prepend,insertionPoint:e.insertionPoint}),nonce:e.nonce,inserted:a,registered:{},insert:l};return b.sheet.hydrate(s),b};function Q9t(r){for(var e=0,t,n=0,i=r.length;i>=4;++n,i-=4)t=r.charCodeAt(n)&255|(r.charCodeAt(++n)&255)<<8|(r.charCodeAt(++n)&255)<<16|(r.charCodeAt(++n)&255)<<24,t=(t&65535)*1540483477+((t>>>16)*59797<<16),t^=t>>>24,e=(t&65535)*1540483477+((t>>>16)*59797<<16)^(e&65535)*1540483477+((e>>>16)*59797<<16);switch(i){case 3:e^=(r.charCodeAt(n+2)&255)<<16;case 2:e^=(r.charCodeAt(n+1)&255)<<8;case 1:e^=r.charCodeAt(n)&255,e=(e&65535)*1540483477+((e>>>16)*59797<<16)}return e^=e>>>13,e=(e&65535)*1540483477+((e>>>16)*59797<<16),((e^e>>>15)>>>0).toString(36)}var K9t={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,scale:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1},J9t=!1,e_t=/[A-Z]|^ms/g,t_t=/_EMO_([^_]+?)_([^]*?)_EMO_/g,T8e=function(e){return e.charCodeAt(1)===45},M8e=function(e){return e!=null&&typeof e!="boolean"},uK=V9t(function(r){return T8e(r)?r:r.replace(e_t,"-$&").toLowerCase()}),C8e=function(e,t){switch(e){case"animation":case"animationName":if(typeof t=="string")return t.replace(t_t,function(n,i,a){return bS={name:i,styles:a,next:bS},i})}return K9t[e]!==1&&!T8e(e)&&typeof t=="number"&&t!==0?t+"px":t},n_t="Component selectors can only be used in conjunction with @emotion/babel-plugin, the swc Emotion plugin, or another Emotion-aware compiler transform.";function WL(r,e,t){if(t==null)return"";var n=t;if(n.__emotion_styles!==void 0)return n;switch(typeof t){case"boolean":return"";case"object":{var i=t;if(i.anim===1)return bS={name:i.name,styles:i.styles,next:bS},i.name;var a=t;if(a.styles!==void 0){var o=a.next;if(o!==void 0)for(;o!==void 0;)bS={name:o.name,styles:o.styles,next:bS},o=o.next;var s=a.styles+";";return s}return r_t(r,e,t)}}var l=t;if(e==null)return l;var c=e[l];return c!==void 0?c:l}function r_t(r,e,t){var n="";if(Array.isArray(t))for(var i=0;i<t.length;i++)n+=WL(r,e,t[i])+";";else for(var a in t){var o=t[a];if(typeof o!="object"){var s=o;e!=null&&e[s]!==void 0?n+=a+"{"+e[s]+"}":M8e(s)&&(n+=uK(a)+":"+C8e(a,s)+";")}else{if(a==="NO_COMPONENT_SELECTOR"&&J9t)throw new Error(n_t);if(Array.isArray(o)&&typeof o[0]=="string"&&(e==null||e[o[0]]===void 0))for(var l=0;l<o.length;l++)M8e(o[l])&&(n+=uK(a)+":"+C8e(a,o[l])+";");else{var c=WL(r,e,o);switch(a){case"animation":case"animationName":{n+=uK(a)+":"+c+";";break}default:n+=a+"{"+c+"}"}}}}return n}var R8e=/label:\s*([^\s;{]+)\s*(;|$)/g,bS;function fK(r,e,t){if(r.length===1&&typeof r[0]=="object"&&r[0]!==null&&r[0].styles!==void 0)return r[0];var n=!0,i="";bS=void 0;var a=r[0];if(a==null||a.raw===void 0)n=!1,i+=WL(t,e,a);else{var o=a;i+=o[0]}for(var s=1;s<r.length;s++)if(i+=WL(t,e,r[s]),n){var l=a;i+=l[s]}R8e.lastIndex=0;for(var c="",u;(u=R8e.exec(i))!==null;)c+="-"+u[1];var h=Q9t(i)+c;return{name:h,styles:i,next:bS}}function A8e(r,e,t){var n="";return t.split(" ").forEach(function(i){r[i]!==void 0?e.push(r[i]+";"):i&&(n+=i+" ")}),n}var i_t=function(e,t,n){var i=e.key+"-"+t.name;e.registered[i]===void 0&&(e.registered[i]=t.styles)},a_t=function(e,t,n){i_t(e,t);var i=e.key+"-"+t.name;if(e.inserted[t.name]===void 0){var a=t;do e.insert(t===a?"."+i:"",a,e.sheet,!0),a=a.next;while(a!==void 0)}};function D8e(r,e){if(r.inserted[e.name]===void 0)return r.insert("",e,r.sheet,!0)}function P8e(r,e,t){var n=[],i=A8e(r,n,t);return n.length<2?t:i+e(n)}var o_t=function(e){var t=Z9t(e);t.sheet.speedy=function(s){this.isSpeedy=s},t.compat=!0;var n=function(){for(var l=arguments.length,c=new Array(l),u=0;u<l;u++)c[u]=arguments[u];var h=fK(c,t.registered,void 0);return a_t(t,h),t.key+"-"+h.name},i=function(){for(var l=arguments.length,c=new Array(l),u=0;u<l;u++)c[u]=arguments[u];var h=fK(c,t.registered),g="animation-"+h.name;return D8e(t,{name:h.name,styles:"@keyframes "+g+"{"+h.styles+"}"}),g},a=function(){for(var l=arguments.length,c=new Array(l),u=0;u<l;u++)c[u]=arguments[u];var h=fK(c,t.registered);D8e(t,h)},o=function(){for(var l=arguments.length,c=new Array(l),u=0;u<l;u++)c[u]=arguments[u];return P8e(t.registered,n,s_t(c))};return{css:n,cx:o,injectGlobal:a,keyframes:i,hydrate:function(l){l.forEach(function(c){t.inserted[c]=!0})},flush:function(){t.registered={},t.inserted={},t.sheet.flush()},sheet:t.sheet,cache:t,getRegisteredStyles:A8e.bind(null,t.registered),merge:P8e.bind(null,t.registered,n)}},s_t=function r(e){for(var t="",n=0;n<e.length;n++){var i=e[n];if(i!=null){var a=void 0;switch(typeof i){case"boolean":break;case"object":{if(Array.isArray(i))a=r(i);else{a="";for(var o in i)i[o]&&o&&(a&&(a+=" "),a+=o)}break}default:a=i}a&&(t&&(t+=" "),t+=a)}}return t},l_t=o_t({key:"css"}),iw=l_t.css;function c_t(r){const e=new Map;let t=0;function n(i){for(const[,o]of e)if(o.has(i))return o;const a=new Set;return e.set(`connectivity_net${t++}`,a),a}for(const i of r){let a=null;for(const o of i){if(!a)a=n(o);else if(!a.has(o)){const s=n(o);if(s!==a){for(const l of s)a.add(l);e.delete(Array.from(e.entries()).find(([,l])=>l===s)[0])}}a.add(o)}}return Object.fromEntries(Array.from(e.entries()).map(([i,a])=>[i,Array.from(a)]))}var u_t=class{constructor(r){ni(this,"netMap");ni(this,"idToNetMap");this.netMap=r,this.idToNetMap={};for(const[e,t]of Object.entries(r))for(const n of t)this.idToNetMap[n]=e}addConnections(r){for(const e of r){const t=new Set;for(const i of e){const a=this.idToNetMap[i];a&&t.add(a)}let n;if(t.size===0)n=`connectivity_net${Object.keys(this.netMap).length}`,this.netMap[n]=[];else if(t.size===1)n=t.values().next().value??`connectivity_net${Object.keys(this.netMap).length}`;else{n=t.values().next().value??`connectivity_net${Object.keys(this.netMap).length}`;for(const i of t)if(i!==n){this.netMap[n].push(...this.netMap[i]),this.netMap[i]=this.netMap[n];for(const a of this.netMap[n])this.idToNetMap[a]=n}}for(const i of e)this.netMap[n].includes(i)||this.netMap[n].push(i),this.idToNetMap[i]=n}}getIdsConnectedToNet(r){return this.netMap[r]||[]}getNetConnectedToId(r){return this.idToNetMap[r]}areIdsConnected(r,e){const t=this.getNetConnectedToId(r),n=this.getNetConnectedToId(e);return t===n||n===r||n===r}areAllIdsConnected(r){const e=this.getNetConnectedToId(r[0]);for(const t of r){const n=this.getNetConnectedToId(t);if(n===void 0||n!==e)return!1}return!0}},N8e=r=>{const e=[];for(const n of r)if(n.type==="source_trace")e.push([n.source_trace_id,...n.connected_source_port_ids??[],...n.connected_source_net_ids??[]].filter(Boolean));else if(n.type==="pcb_port"){const{pcb_port_id:i,source_port_id:a}=n;a&&i&&e.push([a,i])}else if(n.type==="pcb_smtpad"){const{pcb_smtpad_id:i,pcb_port_id:a}=n;a&&i&&e.push([i,a])}else if(n.type==="pcb_plated_hole"){const{pcb_plated_hole_id:i,pcb_port_id:a}=n;a&&i&&e.push([i,a])}else if(n.type==="pcb_trace"){const{pcb_trace_id:i,source_trace_id:a}=n;a&&i&&e.push([i,a])}const t=c_t(e);return new u_t(t)},f_t=Object.defineProperty,d_t=(r,e)=>{for(var t in e)f_t(r,t,{get:e[t],enumerable:!0})},L8e={};d_t(L8e,{all_layers:()=>sO,any_circuit_element:()=>owe,any_soup_element:()=>swe,any_source_component:()=>i6e,battery_capacity:()=>e6e,cad_component:()=>awe,capacitance:()=>xK,current:()=>wxt,distance:()=>pc,frequency:()=>J8e,getZodPrefixedIdWithDefault:()=>i1,inductance:()=>K8e,layer_ref:()=>k9,layer_string:()=>FK,length:()=>s_,pcb_board:()=>G6e,pcb_component:()=>A6e,pcb_fabrication_note_path:()=>ewe,pcb_fabrication_note_text:()=>J6e,pcb_group:()=>iwe,pcb_hole:()=>N6e,pcb_hole_circle_or_square_shape:()=>Axt,pcb_hole_oval_shape:()=>Dxt,pcb_keepout:()=>twe,pcb_manual_edit_conflict_error:()=>rwe,pcb_missing_footprint_error:()=>nwe,pcb_placement_error:()=>q6e,pcb_plated_hole:()=>L6e,pcb_port:()=>O6e,pcb_port_not_matched_error:()=>V6e,pcb_route_hint:()=>C6e,pcb_route_hints:()=>Rxt,pcb_silkscreen_circle:()=>Q6e,pcb_silkscreen_line:()=>X6e,pcb_silkscreen_oval:()=>K6e,pcb_silkscreen_path:()=>W6e,pcb_silkscreen_rect:()=>Z6e,pcb_silkscreen_text:()=>$6e,pcb_smtpad:()=>U6e,pcb_solder_paste:()=>z6e,pcb_text:()=>F6e,pcb_trace:()=>B6e,pcb_trace_error:()=>H6e,pcb_trace_hint:()=>Y6e,pcb_trace_route_point:()=>kxt,pcb_trace_route_point_via:()=>k6e,pcb_trace_route_point_wire:()=>I6e,pcb_via:()=>j6e,point:()=>Qy,point3:()=>sC,port_arrangement:()=>p6e,position:()=>Mxt,position3:()=>Cxt,resistance:()=>rO,rotation:()=>iO,route_hint_point:()=>R6e,schematic_box:()=>c6e,schematic_component:()=>m6e,schematic_component_port_arrangement_by_sides:()=>h6e,schematic_component_port_arrangement_by_size:()=>d6e,schematic_debug_line:()=>E6e,schematic_debug_object:()=>T6e,schematic_debug_object_base:()=>oO,schematic_debug_point:()=>w6e,schematic_debug_rect:()=>S6e,schematic_error:()=>b6e,schematic_line:()=>v6e,schematic_net_label:()=>x6e,schematic_path:()=>u6e,schematic_pin_styles:()=>f6e,schematic_port:()=>_6e,schematic_text:()=>g6e,schematic_trace:()=>y6e,schematic_voltage_probe:()=>M6e,size:()=>SK,source_component_base:()=>R5,source_group:()=>s6e,source_led:()=>CK,source_net:()=>l6e,source_port:()=>a6e,source_simple_battery:()=>AK,source_simple_bug:()=>TK,source_simple_capacitor:()=>EK,source_simple_chip:()=>MK,source_simple_crystal:()=>r6e,source_simple_diode:()=>aO,source_simple_ground:()=>n6e,source_simple_inductor:()=>DK,source_simple_mosfet:()=>zK,source_simple_pin_header:()=>LK,source_simple_potentiometer:()=>NK,source_simple_power_source:()=>RK,source_simple_push_button:()=>PK,source_simple_resistor:()=>wK,source_simple_resonator:()=>OK,source_simple_transistor:()=>UK,source_trace:()=>o6e,supplier_name:()=>t6e,time:()=>Txt,visible_layer:()=>fw,voltage:()=>bK});var Sv;(function(r){r.assertEqual=i=>i;function e(i){}r.assertIs=e;function t(i){throw new Error}r.assertNever=t,r.arrayToEnum=i=>{const a={};for(const o of i)a[o]=o;return a},r.getValidEnumValues=i=>{const a=r.objectKeys(i).filter(s=>typeof i[i[s]]!="number"),o={};for(const s of a)o[s]=i[s];return r.objectValues(o)},r.objectValues=i=>r.objectKeys(i).map(function(a){return i[a]}),r.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const a=[];for(const o in i)Object.prototype.hasOwnProperty.call(i,o)&&a.push(o);return a},r.find=(i,a)=>{for(const o of i)if(a(o))return o},r.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,a=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(a)}r.joinValues=n,r.jsonStringifyReplacer=(i,a)=>typeof a=="bigint"?a.toString():a})(Sv||(Sv={}));var dK;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(dK||(dK={}));var Sc=Sv.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),P4=r=>{switch(typeof r){case"undefined":return Sc.undefined;case"string":return Sc.string;case"number":return isNaN(r)?Sc.nan:Sc.number;case"boolean":return Sc.boolean;case"function":return Sc.function;case"bigint":return Sc.bigint;case"symbol":return Sc.symbol;case"object":return Array.isArray(r)?Sc.array:r===null?Sc.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?Sc.promise:typeof Map<"u"&&r instanceof Map?Sc.map:typeof Set<"u"&&r instanceof Set?Sc.set:typeof Date<"u"&&r instanceof Date?Sc.date:Sc.object;default:return Sc.unknown}},os=Sv.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),h_t=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:"),sb=class MPe extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(a){return a.message},n={_errors:[]},i=a=>{for(const o of a.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)n._errors.push(t(o));else{let s=n,l=0;for(;l<o.path.length;){const c=o.path[l];l===o.path.length-1?(s[c]=s[c]||{_errors:[]},s[c]._errors.push(t(o))):s[c]=s[c]||{_errors:[]},s=s[c],l++}}};return i(this),n}static assert(e){if(!(e instanceof MPe))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Sv.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const i of this.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};sb.create=r=>new sb(r);var aw=(r,e)=>{let t;switch(r.code){case os.invalid_type:r.received===Sc.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case os.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Sv.jsonStringifyReplacer)}`;break;case os.unrecognized_keys:t=`Unrecognized key(s) in object: ${Sv.joinValues(r.keys,", ")}`;break;case os.invalid_union:t="Invalid input";break;case os.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Sv.joinValues(r.options)}`;break;case os.invalid_enum_value:t=`Invalid enum value. Expected ${Sv.joinValues(r.options)}, received '${r.received}'`;break;case os.invalid_arguments:t="Invalid function arguments";break;case os.invalid_return_type:t="Invalid function return type";break;case os.invalid_date:t="Invalid date";break;case os.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:Sv.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case os.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case os.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case os.custom:t="Invalid input";break;case os.invalid_intersection_types:t="Intersection results could not be merged";break;case os.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case os.not_finite:t="Number must be finite";break;default:t=e.defaultError,Sv.assertNever(r)}return{message:t}},O8e=aw;function p_t(r){O8e=r}function $L(){return O8e}var ZL=r=>{const{data:e,path:t,errorMaps:n,issueData:i}=r,a=[...t,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s="";const l=n.filter(c=>!!c).slice().reverse();for(const c of l)s=c(o,{data:e,defaultError:s}).message;return{...i,path:a,message:s}},m_t=[];function Fl(r,e){const t=$L(),n=ZL({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===aw?void 0:aw].filter(i=>!!i)});r.common.issues.push(n)}var J2=class CPe{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const i of t){if(i.status==="aborted")return F0;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const i of t){const a=await i.key,o=await i.value;n.push({key:a,value:o})}return CPe.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const i of t){const{key:a,value:o}=i;if(a.status==="aborted"||o.status==="aborted")return F0;a.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(n[a.value]=o.value)}return{status:e.value,value:n}}},F0=Object.freeze({status:"aborted"}),ow=r=>({status:"dirty",value:r}),T2=r=>({status:"valid",value:r}),hK=r=>r.status==="aborted",pK=r=>r.status==="dirty",JE=r=>r.status==="valid",j7=r=>typeof Promise<"u"&&r instanceof Promise;function QL(r,e,t,n){if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(r)}function U8e(r,e,t,n,i){if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(r,t),t}var Ku;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Ku||(Ku={}));var G7,q7,qb=class{constructor(r,e,t,n){this._cachedPath=[],this.parent=r,this.data=e,this._path=t,this._key=n}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},z8e=(r,e)=>{if(JE(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new sb(r.common.issues);return this._error=t,this._error}}};function xp(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:i}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(o,s)=>{var l,c;const{message:u}=r;return o.code==="invalid_enum_value"?{message:u??s.defaultError}:typeof s.data>"u"?{message:(l=u??n)!==null&&l!==void 0?l:s.defaultError}:o.code!=="invalid_type"?{message:s.defaultError}:{message:(c=u??t)!==null&&c!==void 0?c:s.defaultError}},description:i}}var Bp=class{get description(){return this._def.description}_getType(r){return P4(r.data)}_getOrReturnCtx(r,e){return e||{common:r.parent.common,data:r.data,parsedType:P4(r.data),schemaErrorMap:this._def.errorMap,path:r.path,parent:r.parent}}_processInputParams(r){return{status:new J2,ctx:{common:r.parent.common,data:r.data,parsedType:P4(r.data),schemaErrorMap:this._def.errorMap,path:r.path,parent:r.parent}}}_parseSync(r){const e=this._parse(r);if(j7(e))throw new Error("Synchronous parse encountered promise.");return e}_parseAsync(r){const e=this._parse(r);return Promise.resolve(e)}parse(r,e){const t=this.safeParse(r,e);if(t.success)return t.data;throw t.error}safeParse(r,e){var t;const n={common:{issues:[],async:(t=e==null?void 0:e.async)!==null&&t!==void 0?t:!1,contextualErrorMap:e==null?void 0:e.errorMap},path:(e==null?void 0:e.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:r,parsedType:P4(r)},i=this._parseSync({data:r,path:n.path,parent:n});return z8e(n,i)}"~validate"(r){var e,t;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:r,parsedType:P4(r)};if(!this["~standard"].async)try{const i=this._parseSync({data:r,path:[],parent:n});return JE(i)?{value:i.value}:{issues:n.common.issues}}catch(i){!((t=(e=i==null?void 0:i.message)===null||e===void 0?void 0:e.toLowerCase())===null||t===void 0)&&t.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:r,path:[],parent:n}).then(i=>JE(i)?{value:i.value}:{issues:n.common.issues})}async parseAsync(r,e){const t=await this.safeParseAsync(r,e);if(t.success)return t.data;throw t.error}async safeParseAsync(r,e){const t={common:{issues:[],contextualErrorMap:e==null?void 0:e.errorMap,async:!0},path:(e==null?void 0:e.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:r,parsedType:P4(r)},n=this._parse({data:r,path:t.path,parent:t}),i=await(j7(n)?n:Promise.resolve(n));return z8e(t,i)}refine(r,e){const t=n=>typeof e=="string"||typeof e>"u"?{message:e}:typeof e=="function"?e(n):e;return this._refinement((n,i)=>{const a=r(n),o=()=>i.addIssue({code:os.custom,...t(n)});return typeof Promise<"u"&&a instanceof Promise?a.then(s=>s?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(r,e){return this._refinement((t,n)=>r(t)?!0:(n.addIssue(typeof e=="function"?e(t,n):e),!1))}_refinement(r){return new lb({schema:this,typeName:x0.ZodEffects,effect:{type:"refinement",refinement:r}})}superRefine(r){return this._refinement(r)}constructor(r){this.spa=this.safeParseAsync,this._def=r,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return Yb.create(this,this._def)}nullable(){return ES.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return t8.create(this)}promise(){return uw.create(this,this._def)}or(r){return K7.create([this,r],this._def)}and(r){return J7.create(this,r,this._def)}transform(r){return new lb({...xp(this._def),schema:this,typeName:x0.ZodEffects,effect:{type:"transform",transform:r}})}default(r){const e=typeof r=="function"?r:()=>r;return new iC({...xp(this._def),innerType:this,defaultValue:e,typeName:x0.ZodDefault})}brand(){return new yK({typeName:x0.ZodBranded,type:this,...xp(this._def)})}catch(r){const e=typeof r=="function"?r:()=>r;return new aC({...xp(this._def),innerType:this,catchValue:e,typeName:x0.ZodCatch})}describe(r){const e=this.constructor;return new e({...this._def,description:r})}pipe(r){return gK.create(this,r)}readonly(){return oC.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},v_t=/^c[^\s-]{8,}$/i,y_t=/^[0-9a-z]+$/,g_t=/^[0-9A-HJKMNP-TV-Z]{26}$/i,__t=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,x_t=/^[a-z0-9_-]{21}$/i,b_t=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,S_t=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,E_t=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,w_t="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",mK,T_t=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,M_t=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,C_t=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,R_t=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,A_t=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,D_t=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,F8e="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",P_t=new RegExp(`^${F8e}$`);function I8e(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function N_t(r){return new RegExp(`^${I8e(r)}$`)}function k8e(r){let e=`${F8e}T${I8e(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function L_t(r,e){return!!((e==="v4"||!e)&&T_t.test(r)||(e==="v6"||!e)&&C_t.test(r))}function O_t(r,e){if(!b_t.test(r))return!1;try{const[t]=r.split("."),n=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),i=JSON.parse(atob(n));return!(typeof i!="object"||i===null||!i.typ||!i.alg||e&&i.alg!==e)}catch{return!1}}function U_t(r,e){return!!((e==="v4"||!e)&&M_t.test(r)||(e==="v6"||!e)&&R_t.test(r))}var sw=class kC extends Bp{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==Sc.string){const a=this._getOrReturnCtx(e);return Fl(a,{code:os.invalid_type,expected:Sc.string,received:a.parsedType}),F0}const n=new J2;let i;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(i=this._getOrReturnCtx(e,i),Fl(i,{code:os.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(i=this._getOrReturnCtx(e,i),Fl(i,{code:os.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){const o=e.data.length>a.value,s=e.data.length<a.value;(o||s)&&(i=this._getOrReturnCtx(e,i),o?Fl(i,{code:os.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):s&&Fl(i,{code:os.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")E_t.test(e.data)||(i=this._getOrReturnCtx(e,i),Fl(i,{validation:"email",code:os.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")mK||(mK=new RegExp(w_t,"u")),mK.test(e.data)||(i=this._getOrReturnCtx(e,i),Fl(i,{validation:"emoji",code:os.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")__t.test(e.data)||(i=this._getOrReturnCtx(e,i),Fl(i,{validation:"uuid",code:os.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")x_t.test(e.data)||(i=this._getOrReturnCtx(e,i),Fl(i,{validation:"nanoid",code:os.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")v_t.test(e.data)||(i=this._getOrReturnCtx(e,i),Fl(i,{validation:"cuid",code:os.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")y_t.test(e.data)||(i=this._getOrReturnCtx(e,i),Fl(i,{validation:"cuid2",code:os.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")g_t.test(e.data)||(i=this._getOrReturnCtx(e,i),Fl(i,{validation:"ulid",code:os.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),Fl(i,{validation:"url",code:os.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),Fl(i,{validation:"regex",code:os.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(i=this._getOrReturnCtx(e,i),Fl(i,{code:os.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(i=this._getOrReturnCtx(e,i),Fl(i,{code:os.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(i=this._getOrReturnCtx(e,i),Fl(i,{code:os.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?k8e(a).test(e.data)||(i=this._getOrReturnCtx(e,i),Fl(i,{code:os.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?P_t.test(e.data)||(i=this._getOrReturnCtx(e,i),Fl(i,{code:os.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?N_t(a).test(e.data)||(i=this._getOrReturnCtx(e,i),Fl(i,{code:os.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?S_t.test(e.data)||(i=this._getOrReturnCtx(e,i),Fl(i,{validation:"duration",code:os.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?L_t(e.data,a.version)||(i=this._getOrReturnCtx(e,i),Fl(i,{validation:"ip",code:os.invalid_string,message:a.message}),n.dirty()):a.kind==="jwt"?O_t(e.data,a.alg)||(i=this._getOrReturnCtx(e,i),Fl(i,{validation:"jwt",code:os.invalid_string,message:a.message}),n.dirty()):a.kind==="cidr"?U_t(e.data,a.version)||(i=this._getOrReturnCtx(e,i),Fl(i,{validation:"cidr",code:os.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?A_t.test(e.data)||(i=this._getOrReturnCtx(e,i),Fl(i,{validation:"base64",code:os.invalid_string,message:a.message}),n.dirty()):a.kind==="base64url"?D_t.test(e.data)||(i=this._getOrReturnCtx(e,i),Fl(i,{validation:"base64url",code:os.invalid_string,message:a.message}),n.dirty()):Sv.assertNever(a);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(i=>e.test(i),{validation:t,code:os.invalid_string,...Ku.errToObj(n)})}_addCheck(e){return new kC({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Ku.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Ku.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Ku.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Ku.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Ku.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Ku.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Ku.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Ku.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Ku.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...Ku.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...Ku.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Ku.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...Ku.errToObj(e)})}datetime(e){var t,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...Ku.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...Ku.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...Ku.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Ku.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...Ku.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Ku.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Ku.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Ku.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Ku.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Ku.errToObj(t)})}nonempty(e){return this.min(1,Ku.errToObj(e))}trim(){return new kC({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new kC({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new kC({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};sw.create=r=>{var e;return new sw({checks:[],typeName:x0.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...xp(r)})};function z_t(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=t>n?t:n,a=parseInt(r.toFixed(i).replace(".","")),o=parseInt(e.toFixed(i).replace(".",""));return a%o/Math.pow(10,i)}var Y7=class Zte extends Bp{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==Sc.number){const a=this._getOrReturnCtx(e);return Fl(a,{code:os.invalid_type,expected:Sc.number,received:a.parsedType}),F0}let n;const i=new J2;for(const a of this._def.checks)a.kind==="int"?Sv.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),Fl(n,{code:os.invalid_type,expected:"integer",received:"float",message:a.message}),i.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),Fl(n,{code:os.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),Fl(n,{code:os.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="multipleOf"?z_t(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),Fl(n,{code:os.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),Fl(n,{code:os.not_finite,message:a.message}),i.dirty()):Sv.assertNever(a);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Ku.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Ku.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Ku.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Ku.toString(t))}setLimit(e,t,n,i){return new Zte({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Ku.toString(i)}]})}_addCheck(e){return new Zte({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Ku.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Ku.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Ku.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Ku.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Ku.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Ku.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Ku.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Ku.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Ku.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Sv.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}};Y7.create=r=>new Y7({checks:[],typeName:x0.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...xp(r)});var X7=class Qte extends Bp{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==Sc.bigint)return this._getInvalidInput(e);let n;const i=new J2;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),Fl(n,{code:os.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),i.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),Fl(n,{code:os.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),i.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),Fl(n,{code:os.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):Sv.assertNever(a);return{status:i.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return Fl(t,{code:os.invalid_type,expected:Sc.bigint,received:t.parsedType}),F0}gte(e,t){return this.setLimit("min",e,!0,Ku.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Ku.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Ku.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Ku.toString(t))}setLimit(e,t,n,i){return new Qte({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Ku.toString(i)}]})}_addCheck(e){return new Qte({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Ku.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Ku.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Ku.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Ku.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Ku.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};X7.create=r=>{var e;return new X7({checks:[],typeName:x0.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...xp(r)})};var W7=class extends Bp{_parse(r){if(this._def.coerce&&(r.data=!!r.data),this._getType(r)!==Sc.boolean){const t=this._getOrReturnCtx(r);return Fl(t,{code:os.invalid_type,expected:Sc.boolean,received:t.parsedType}),F0}return T2(r.data)}};W7.create=r=>new W7({typeName:x0.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...xp(r)});var $7=class RPe extends Bp{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==Sc.date){const a=this._getOrReturnCtx(e);return Fl(a,{code:os.invalid_type,expected:Sc.date,received:a.parsedType}),F0}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return Fl(a,{code:os.invalid_date}),F0}const n=new J2;let i;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(i=this._getOrReturnCtx(e,i),Fl(i,{code:os.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(i=this._getOrReturnCtx(e,i),Fl(i,{code:os.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):Sv.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new RPe({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Ku.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Ku.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};$7.create=r=>new $7({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:x0.ZodDate,...xp(r)});var KL=class extends Bp{_parse(r){if(this._getType(r)!==Sc.symbol){const t=this._getOrReturnCtx(r);return Fl(t,{code:os.invalid_type,expected:Sc.symbol,received:t.parsedType}),F0}return T2(r.data)}};KL.create=r=>new KL({typeName:x0.ZodSymbol,...xp(r)});var Z7=class extends Bp{_parse(r){if(this._getType(r)!==Sc.undefined){const t=this._getOrReturnCtx(r);return Fl(t,{code:os.invalid_type,expected:Sc.undefined,received:t.parsedType}),F0}return T2(r.data)}};Z7.create=r=>new Z7({typeName:x0.ZodUndefined,...xp(r)});var Q7=class extends Bp{_parse(r){if(this._getType(r)!==Sc.null){const t=this._getOrReturnCtx(r);return Fl(t,{code:os.invalid_type,expected:Sc.null,received:t.parsedType}),F0}return T2(r.data)}};Q7.create=r=>new Q7({typeName:x0.ZodNull,...xp(r)});var lw=class extends Bp{constructor(){super(...arguments),this._any=!0}_parse(r){return T2(r.data)}};lw.create=r=>new lw({typeName:x0.ZodAny,...xp(r)});var e8=class extends Bp{constructor(){super(...arguments),this._unknown=!0}_parse(r){return T2(r.data)}};e8.create=r=>new e8({typeName:x0.ZodUnknown,...xp(r)});var N4=class extends Bp{_parse(r){const e=this._getOrReturnCtx(r);return Fl(e,{code:os.invalid_type,expected:Sc.never,received:e.parsedType}),F0}};N4.create=r=>new N4({typeName:x0.ZodNever,...xp(r)});var JL=class extends Bp{_parse(r){if(this._getType(r)!==Sc.undefined){const t=this._getOrReturnCtx(r);return Fl(t,{code:os.invalid_type,expected:Sc.void,received:t.parsedType}),F0}return T2(r.data)}};JL.create=r=>new JL({typeName:x0.ZodVoid,...xp(r)});var t8=class lz extends Bp{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==Sc.array)return Fl(t,{code:os.invalid_type,expected:Sc.array,received:t.parsedType}),F0;if(i.exactLength!==null){const o=t.data.length>i.exactLength.value,s=t.data.length<i.exactLength.value;(o||s)&&(Fl(t,{code:o?os.too_big:os.too_small,minimum:s?i.exactLength.value:void 0,maximum:o?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&(Fl(t,{code:os.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&(Fl(t,{code:os.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((o,s)=>i.type._parseAsync(new qb(t,o,t.path,s)))).then(o=>J2.mergeArray(n,o));const a=[...t.data].map((o,s)=>i.type._parseSync(new qb(t,o,t.path,s)));return J2.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new lz({...this._def,minLength:{value:e,message:Ku.toString(t)}})}max(e,t){return new lz({...this._def,maxLength:{value:e,message:Ku.toString(t)}})}length(e,t){return new lz({...this._def,exactLength:{value:e,message:Ku.toString(t)}})}nonempty(e){return this.min(1,e)}};t8.create=(r,e)=>new t8({type:r,minLength:null,maxLength:null,exactLength:null,typeName:x0.ZodArray,...xp(e)});function cw(r){if(r instanceof U3){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=Yb.create(cw(n))}return new U3({...r._def,shape:()=>e})}else return r instanceof t8?new t8({...r._def,type:cw(r.element)}):r instanceof Yb?Yb.create(cw(r.unwrap())):r instanceof ES?ES.create(cw(r.unwrap())):r instanceof SS?SS.create(r.items.map(e=>cw(e))):r}var U3=class _b extends Bp{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=Sv.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==Sc.object){const c=this._getOrReturnCtx(e);return Fl(c,{code:os.invalid_type,expected:Sc.object,received:c.parsedType}),F0}const{status:n,ctx:i}=this._processInputParams(e),{shape:a,keys:o}=this._getCached(),s=[];if(!(this._def.catchall instanceof N4&&this._def.unknownKeys==="strip"))for(const c in i.data)o.includes(c)||s.push(c);const l=[];for(const c of o){const u=a[c],h=i.data[c];l.push({key:{status:"valid",value:c},value:u._parse(new qb(i,h,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof N4){const c=this._def.unknownKeys;if(c==="passthrough")for(const u of s)l.push({key:{status:"valid",value:u},value:{status:"valid",value:i.data[u]}});else if(c==="strict")s.length>0&&(Fl(i,{code:os.unrecognized_keys,keys:s}),n.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const u of s){const h=i.data[u];l.push({key:{status:"valid",value:u},value:c._parse(new qb(i,h,i.path,u)),alwaysSet:u in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const c=[];for(const u of l){const h=await u.key,g=await u.value;c.push({key:h,value:g,alwaysSet:u.alwaysSet})}return c}).then(c=>J2.mergeObjectSync(n,c)):J2.mergeObjectSync(n,l)}get shape(){return this._def.shape()}strict(e){return Ku.errToObj,new _b({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var i,a,o,s;const l=(o=(a=(i=this._def).errorMap)===null||a===void 0?void 0:a.call(i,t,n).message)!==null&&o!==void 0?o:n.defaultError;return t.code==="unrecognized_keys"?{message:(s=Ku.errToObj(e).message)!==null&&s!==void 0?s:l}:{message:l}}}:{}})}strip(){return new _b({...this._def,unknownKeys:"strip"})}passthrough(){return new _b({...this._def,unknownKeys:"passthrough"})}extend(e){return new _b({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new _b({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:x0.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new _b({...this._def,catchall:e})}pick(e){const t={};return Sv.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new _b({...this._def,shape:()=>t})}omit(e){const t={};return Sv.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new _b({...this._def,shape:()=>t})}deepPartial(){return cw(this)}partial(e){const t={};return Sv.objectKeys(this.shape).forEach(n=>{const i=this.shape[n];e&&!e[n]?t[n]=i:t[n]=i.optional()}),new _b({...this._def,shape:()=>t})}required(e){const t={};return Sv.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof Yb;)a=a._def.innerType;t[n]=a}}),new _b({...this._def,shape:()=>t})}keyof(){return j8e(Sv.objectKeys(this.shape))}};U3.create=(r,e)=>new U3({shape:()=>r,unknownKeys:"strip",catchall:N4.create(),typeName:x0.ZodObject,...xp(e)}),U3.strictCreate=(r,e)=>new U3({shape:()=>r,unknownKeys:"strict",catchall:N4.create(),typeName:x0.ZodObject,...xp(e)}),U3.lazycreate=(r,e)=>new U3({shape:r,unknownKeys:"strip",catchall:N4.create(),typeName:x0.ZodObject,...xp(e)});var K7=class extends Bp{_parse(r){const{ctx:e}=this._processInputParams(r),t=this._def.options;function n(i){for(const o of i)if(o.result.status==="valid")return o.result;for(const o of i)if(o.result.status==="dirty")return e.common.issues.push(...o.ctx.common.issues),o.result;const a=i.map(o=>new sb(o.ctx.common.issues));return Fl(e,{code:os.invalid_union,unionErrors:a}),F0}if(e.common.async)return Promise.all(t.map(async i=>{const a={...e,common:{...e.common,issues:[]},parent:null};return{result:await i._parseAsync({data:e.data,path:e.path,parent:a}),ctx:a}})).then(n);{let i;const a=[];for(const s of t){const l={...e,common:{...e.common,issues:[]},parent:null},c=s._parseSync({data:e.data,path:e.path,parent:l});if(c.status==="valid")return c;c.status==="dirty"&&!i&&(i={result:c,ctx:l}),l.common.issues.length&&a.push(l.common.issues)}if(i)return e.common.issues.push(...i.ctx.common.issues),i.result;const o=a.map(s=>new sb(s));return Fl(e,{code:os.invalid_union,unionErrors:o}),F0}}get options(){return this._def.options}};K7.create=(r,e)=>new K7({options:r,typeName:x0.ZodUnion,...xp(e)});var L4=r=>r instanceof eC?L4(r.schema):r instanceof lb?L4(r.innerType()):r instanceof tC?[r.value]:r instanceof nC?r.options:r instanceof rC?Sv.objectValues(r.enum):r instanceof iC?L4(r._def.innerType):r instanceof Z7?[void 0]:r instanceof Q7?[null]:r instanceof Yb?[void 0,...L4(r.unwrap())]:r instanceof ES?[null,...L4(r.unwrap())]:r instanceof yK||r instanceof oC?L4(r.unwrap()):r instanceof aC?L4(r._def.innerType):[],B8e=class APe extends Bp{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==Sc.object)return Fl(t,{code:os.invalid_type,expected:Sc.object,received:t.parsedType}),F0;const n=this.discriminator,i=t.data[n],a=this.optionsMap.get(i);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(Fl(t,{code:os.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),F0)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const i=new Map;for(const a of t){const o=L4(a.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const s of o){if(i.has(s))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(s)}`);i.set(s,a)}}return new APe({typeName:x0.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...xp(n)})}};function vK(r,e){const t=P4(r),n=P4(e);if(r===e)return{valid:!0,data:r};if(t===Sc.object&&n===Sc.object){const i=Sv.objectKeys(e),a=Sv.objectKeys(r).filter(s=>i.indexOf(s)!==-1),o={...r,...e};for(const s of a){const l=vK(r[s],e[s]);if(!l.valid)return{valid:!1};o[s]=l.data}return{valid:!0,data:o}}else if(t===Sc.array&&n===Sc.array){if(r.length!==e.length)return{valid:!1};const i=[];for(let a=0;a<r.length;a++){const o=r[a],s=e[a],l=vK(o,s);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return t===Sc.date&&n===Sc.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}var J7=class extends Bp{_parse(r){const{status:e,ctx:t}=this._processInputParams(r),n=(i,a)=>{if(hK(i)||hK(a))return F0;const o=vK(i.value,a.value);return o.valid?((pK(i)||pK(a))&&e.dirty(),{status:e.value,value:o.data}):(Fl(t,{code:os.invalid_intersection_types}),F0)};return t.common.async?Promise.all([this._def.left._parseAsync({data:t.data,path:t.path,parent:t}),this._def.right._parseAsync({data:t.data,path:t.path,parent:t})]).then(([i,a])=>n(i,a)):n(this._def.left._parseSync({data:t.data,path:t.path,parent:t}),this._def.right._parseSync({data:t.data,path:t.path,parent:t}))}};J7.create=(r,e,t)=>new J7({left:r,right:e,typeName:x0.ZodIntersection,...xp(t)});var SS=class DPe extends Bp{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Sc.array)return Fl(n,{code:os.invalid_type,expected:Sc.array,received:n.parsedType}),F0;if(n.data.length<this._def.items.length)return Fl(n,{code:os.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),F0;!this._def.rest&&n.data.length>this._def.items.length&&(Fl(n,{code:os.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...n.data].map((o,s)=>{const l=this._def.items[s]||this._def.rest;return l?l._parse(new qb(n,o,n.path,s)):null}).filter(o=>!!o);return n.common.async?Promise.all(a).then(o=>J2.mergeArray(t,o)):J2.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new DPe({...this._def,rest:e})}};SS.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new SS({items:r,typeName:x0.ZodTuple,rest:null,...xp(e)})};var H8e=class Kte extends Bp{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Sc.object)return Fl(n,{code:os.invalid_type,expected:Sc.object,received:n.parsedType}),F0;const i=[],a=this._def.keyType,o=this._def.valueType;for(const s in n.data)i.push({key:a._parse(new qb(n,s,n.path,s)),value:o._parse(new qb(n,n.data[s],n.path,s)),alwaysSet:s in n.data});return n.common.async?J2.mergeObjectAsync(t,i):J2.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof Bp?new Kte({keyType:e,valueType:t,typeName:x0.ZodRecord,...xp(n)}):new Kte({keyType:sw.create(),valueType:e,typeName:x0.ZodRecord,...xp(t)})}},eO=class extends Bp{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(r){const{status:e,ctx:t}=this._processInputParams(r);if(t.parsedType!==Sc.map)return Fl(t,{code:os.invalid_type,expected:Sc.map,received:t.parsedType}),F0;const n=this._def.keyType,i=this._def.valueType,a=[...t.data.entries()].map(([o,s],l)=>({key:n._parse(new qb(t,o,t.path,[l,"key"])),value:i._parse(new qb(t,s,t.path,[l,"value"]))}));if(t.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const s of a){const l=await s.key,c=await s.value;if(l.status==="aborted"||c.status==="aborted")return F0;(l.status==="dirty"||c.status==="dirty")&&e.dirty(),o.set(l.value,c.value)}return{status:e.value,value:o}})}else{const o=new Map;for(const s of a){const l=s.key,c=s.value;if(l.status==="aborted"||c.status==="aborted")return F0;(l.status==="dirty"||c.status==="dirty")&&e.dirty(),o.set(l.value,c.value)}return{status:e.value,value:o}}}};eO.create=(r,e,t)=>new eO({valueType:e,keyType:r,typeName:x0.ZodMap,...xp(t)});var tO=class Jte extends Bp{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Sc.set)return Fl(n,{code:os.invalid_type,expected:Sc.set,received:n.parsedType}),F0;const i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(Fl(n,{code:os.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(Fl(n,{code:os.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());const a=this._def.valueType;function o(l){const c=new Set;for(const u of l){if(u.status==="aborted")return F0;u.status==="dirty"&&t.dirty(),c.add(u.value)}return{status:t.value,value:c}}const s=[...n.data.values()].map((l,c)=>a._parse(new qb(n,l,n.path,c)));return n.common.async?Promise.all(s).then(l=>o(l)):o(s)}min(e,t){return new Jte({...this._def,minSize:{value:e,message:Ku.toString(t)}})}max(e,t){return new Jte({...this._def,maxSize:{value:e,message:Ku.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};tO.create=(r,e)=>new tO({valueType:r,minSize:null,maxSize:null,typeName:x0.ZodSet,...xp(e)});var V8e=class cz extends Bp{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==Sc.function)return Fl(t,{code:os.invalid_type,expected:Sc.function,received:t.parsedType}),F0;function n(s,l){return ZL({data:s,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,$L(),aw].filter(c=>!!c),issueData:{code:os.invalid_arguments,argumentsError:l}})}function i(s,l){return ZL({data:s,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,$L(),aw].filter(c=>!!c),issueData:{code:os.invalid_return_type,returnTypeError:l}})}const a={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof uw){const s=this;return T2(async function(...l){const c=new sb([]),u=await s._def.args.parseAsync(l,a).catch(_=>{throw c.addIssue(n(l,_)),c}),h=await Reflect.apply(o,this,u);return await s._def.returns._def.type.parseAsync(h,a).catch(_=>{throw c.addIssue(i(h,_)),c})})}else{const s=this;return T2(function(...l){const c=s._def.args.safeParse(l,a);if(!c.success)throw new sb([n(l,c.error)]);const u=Reflect.apply(o,this,c.data),h=s._def.returns.safeParse(u,a);if(!h.success)throw new sb([i(u,h.error)]);return h.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new cz({...this._def,args:SS.create(e).rest(e8.create())})}returns(e){return new cz({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new cz({args:e||SS.create([]).rest(e8.create()),returns:t||e8.create(),typeName:x0.ZodFunction,...xp(n)})}},eC=class extends Bp{get schema(){return this._def.getter()}_parse(r){const{ctx:e}=this._processInputParams(r);return this._def.getter()._parse({data:e.data,path:e.path,parent:e})}};eC.create=(r,e)=>new eC({getter:r,typeName:x0.ZodLazy,...xp(e)});var tC=class extends Bp{_parse(r){if(r.data!==this._def.value){const e=this._getOrReturnCtx(r);return Fl(e,{received:e.data,code:os.invalid_literal,expected:this._def.value}),F0}return{status:"valid",value:r.data}}get value(){return this._def.value}};tC.create=(r,e)=>new tC({value:r,typeName:x0.ZodLiteral,...xp(e)});function j8e(r,e){return new nC({values:r,typeName:x0.ZodEnum,...xp(e)})}var nC=class ene extends Bp{constructor(){super(...arguments),G7.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return Fl(t,{expected:Sv.joinValues(n),received:t.parsedType,code:os.invalid_type}),F0}if(QL(this,G7)||U8e(this,G7,new Set(this._def.values)),!QL(this,G7).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return Fl(t,{received:t.data,code:os.invalid_enum_value,options:n}),F0}return T2(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return ene.create(e,{...this._def,...t})}exclude(e,t=this._def){return ene.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}};G7=new WeakMap,nC.create=j8e;var rC=class extends Bp{constructor(){super(...arguments),q7.set(this,void 0)}_parse(r){const e=Sv.getValidEnumValues(this._def.values),t=this._getOrReturnCtx(r);if(t.parsedType!==Sc.string&&t.parsedType!==Sc.number){const n=Sv.objectValues(e);return Fl(t,{expected:Sv.joinValues(n),received:t.parsedType,code:os.invalid_type}),F0}if(QL(this,q7)||U8e(this,q7,new Set(Sv.getValidEnumValues(this._def.values))),!QL(this,q7).has(r.data)){const n=Sv.objectValues(e);return Fl(t,{received:t.data,code:os.invalid_enum_value,options:n}),F0}return T2(r.data)}get enum(){return this._def.values}};q7=new WeakMap,rC.create=(r,e)=>new rC({values:r,typeName:x0.ZodNativeEnum,...xp(e)});var uw=class extends Bp{unwrap(){return this._def.type}_parse(r){const{ctx:e}=this._processInputParams(r);if(e.parsedType!==Sc.promise&&e.common.async===!1)return Fl(e,{code:os.invalid_type,expected:Sc.promise,received:e.parsedType}),F0;const t=e.parsedType===Sc.promise?e.data:Promise.resolve(e.data);return T2(t.then(n=>this._def.type.parseAsync(n,{path:e.path,errorMap:e.common.contextualErrorMap})))}};uw.create=(r,e)=>new uw({type:r,typeName:x0.ZodPromise,...xp(e)});var lb=class extends Bp{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===x0.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(r){const{status:e,ctx:t}=this._processInputParams(r),n=this._def.effect||null,i={addIssue:a=>{Fl(t,a),a.fatal?e.abort():e.dirty()},get path(){return t.path}};if(i.addIssue=i.addIssue.bind(i),n.type==="preprocess"){const a=n.transform(t.data,i);if(t.common.async)return Promise.resolve(a).then(async o=>{if(e.value==="aborted")return F0;const s=await this._def.schema._parseAsync({data:o,path:t.path,parent:t});return s.status==="aborted"?F0:s.status==="dirty"||e.value==="dirty"?ow(s.value):s});{if(e.value==="aborted")return F0;const o=this._def.schema._parseSync({data:a,path:t.path,parent:t});return o.status==="aborted"?F0:o.status==="dirty"||e.value==="dirty"?ow(o.value):o}}if(n.type==="refinement"){const a=o=>{const s=n.refinement(o,i);if(t.common.async)return Promise.resolve(s);if(s instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(t.common.async===!1){const o=this._def.schema._parseSync({data:t.data,path:t.path,parent:t});return o.status==="aborted"?F0:(o.status==="dirty"&&e.dirty(),a(o.value),{status:e.value,value:o.value})}else return this._def.schema._parseAsync({data:t.data,path:t.path,parent:t}).then(o=>o.status==="aborted"?F0:(o.status==="dirty"&&e.dirty(),a(o.value).then(()=>({status:e.value,value:o.value}))))}if(n.type==="transform")if(t.common.async===!1){const a=this._def.schema._parseSync({data:t.data,path:t.path,parent:t});if(!JE(a))return a;const o=n.transform(a.value,i);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:e.value,value:o}}else return this._def.schema._parseAsync({data:t.data,path:t.path,parent:t}).then(a=>JE(a)?Promise.resolve(n.transform(a.value,i)).then(o=>({status:e.value,value:o})):a);Sv.assertNever(n)}};lb.create=(r,e,t)=>new lb({schema:r,typeName:x0.ZodEffects,effect:e,...xp(t)}),lb.createWithPreprocess=(r,e,t)=>new lb({schema:e,effect:{type:"preprocess",transform:r},typeName:x0.ZodEffects,...xp(t)});var Yb=class extends Bp{_parse(r){return this._getType(r)===Sc.undefined?T2(void 0):this._def.innerType._parse(r)}unwrap(){return this._def.innerType}};Yb.create=(r,e)=>new Yb({innerType:r,typeName:x0.ZodOptional,...xp(e)});var ES=class extends Bp{_parse(r){return this._getType(r)===Sc.null?T2(null):this._def.innerType._parse(r)}unwrap(){return this._def.innerType}};ES.create=(r,e)=>new ES({innerType:r,typeName:x0.ZodNullable,...xp(e)});var iC=class extends Bp{_parse(r){const{ctx:e}=this._processInputParams(r);let t=e.data;return e.parsedType===Sc.undefined&&(t=this._def.defaultValue()),this._def.innerType._parse({data:t,path:e.path,parent:e})}removeDefault(){return this._def.innerType}};iC.create=(r,e)=>new iC({innerType:r,typeName:x0.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...xp(e)});var aC=class extends Bp{_parse(r){const{ctx:e}=this._processInputParams(r),t={...e,common:{...e.common,issues:[]}},n=this._def.innerType._parse({data:t.data,path:t.path,parent:{...t}});return j7(n)?n.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new sb(t.common.issues)},input:t.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new sb(t.common.issues)},input:t.data})}}removeCatch(){return this._def.innerType}};aC.create=(r,e)=>new aC({innerType:r,typeName:x0.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...xp(e)});var nO=class extends Bp{_parse(r){if(this._getType(r)!==Sc.nan){const t=this._getOrReturnCtx(r);return Fl(t,{code:os.invalid_type,expected:Sc.nan,received:t.parsedType}),F0}return{status:"valid",value:r.data}}};nO.create=r=>new nO({typeName:x0.ZodNaN,...xp(r)});var F_t=Symbol("zod_brand"),yK=class extends Bp{_parse(r){const{ctx:e}=this._processInputParams(r),t=e.data;return this._def.type._parse({data:t,path:e.path,parent:e})}unwrap(){return this._def.type}},gK=class PPe extends Bp{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?F0:a.status==="dirty"?(t.dirty(),ow(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{const i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?F0:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,t){return new PPe({in:e,out:t,typeName:x0.ZodPipeline})}},oC=class extends Bp{_parse(r){const e=this._def.innerType._parse(r),t=n=>(JE(n)&&(n.value=Object.freeze(n.value)),n);return j7(e)?e.then(n=>t(n)):t(e)}unwrap(){return this._def.innerType}};oC.create=(r,e)=>new oC({innerType:r,typeName:x0.ZodReadonly,...xp(e)});function G8e(r,e){const t=typeof r=="function"?r(e):typeof r=="string"?{message:r}:r;return typeof t=="string"?{message:t}:t}function q8e(r,e={},t){return r?lw.create().superRefine((n,i)=>{var a,o;const s=r(n);if(s instanceof Promise)return s.then(l=>{var c,u;if(!l){const h=G8e(e,n),g=(u=(c=h.fatal)!==null&&c!==void 0?c:t)!==null&&u!==void 0?u:!0;i.addIssue({code:"custom",...h,fatal:g})}});if(!s){const l=G8e(e,n),c=(o=(a=l.fatal)!==null&&a!==void 0?a:t)!==null&&o!==void 0?o:!0;i.addIssue({code:"custom",...l,fatal:c})}}):lw.create()}var I_t={object:U3.lazycreate},x0;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(x0||(x0={}));var k_t=(r,e={message:`Input not instance of ${r.name}`})=>q8e(t=>t instanceof r,e),Y8e=sw.create,X8e=Y7.create,B_t=nO.create,H_t=X7.create,W8e=W7.create,V_t=$7.create,j_t=KL.create,G_t=Z7.create,q_t=Q7.create,Y_t=lw.create,X_t=e8.create,W_t=N4.create,$_t=JL.create,Z_t=t8.create,Q_t=U3.create,K_t=U3.strictCreate,J_t=K7.create,ext=B8e.create,txt=J7.create,nxt=SS.create,rxt=H8e.create,ixt=eO.create,axt=tO.create,oxt=V8e.create,sxt=eC.create,lxt=tC.create,cxt=nC.create,uxt=rC.create,fxt=uw.create,$8e=lb.create,dxt=Yb.create,hxt=ES.create,pxt=lb.createWithPreprocess,mxt=gK.create,vxt=()=>Y8e().optional(),yxt=()=>X8e().optional(),gxt=()=>W8e().optional(),_xt={string:r=>sw.create({...r,coerce:!0}),number:r=>Y7.create({...r,coerce:!0}),boolean:r=>W7.create({...r,coerce:!0}),bigint:r=>X7.create({...r,coerce:!0}),date:r=>$7.create({...r,coerce:!0})},xxt=F0,Ft=Object.freeze({__proto__:null,defaultErrorMap:aw,setErrorMap:p_t,getErrorMap:$L,makeIssue:ZL,EMPTY_PATH:m_t,addIssueToContext:Fl,ParseStatus:J2,INVALID:F0,DIRTY:ow,OK:T2,isAborted:hK,isDirty:pK,isValid:JE,isAsync:j7,get util(){return Sv},get objectUtil(){return dK},ZodParsedType:Sc,getParsedType:P4,ZodType:Bp,datetimeRegex:k8e,ZodString:sw,ZodNumber:Y7,ZodBigInt:X7,ZodBoolean:W7,ZodDate:$7,ZodSymbol:KL,ZodUndefined:Z7,ZodNull:Q7,ZodAny:lw,ZodUnknown:e8,ZodNever:N4,ZodVoid:JL,ZodArray:t8,ZodObject:U3,ZodUnion:K7,ZodDiscriminatedUnion:B8e,ZodIntersection:J7,ZodTuple:SS,ZodRecord:H8e,ZodMap:eO,ZodSet:tO,ZodFunction:V8e,ZodLazy:eC,ZodLiteral:tC,ZodEnum:nC,ZodNativeEnum:rC,ZodPromise:uw,ZodEffects:lb,ZodTransformer:lb,ZodOptional:Yb,ZodNullable:ES,ZodDefault:iC,ZodCatch:aC,ZodNaN:nO,BRAND:F_t,ZodBranded:yK,ZodPipeline:gK,ZodReadonly:oC,custom:q8e,Schema:Bp,ZodSchema:Bp,late:I_t,get ZodFirstPartyTypeKind(){return x0},coerce:_xt,any:Y_t,array:Z_t,bigint:H_t,boolean:W8e,date:V_t,discriminatedUnion:ext,effect:$8e,enum:cxt,function:oxt,instanceof:k_t,intersection:txt,lazy:sxt,literal:lxt,map:ixt,nan:B_t,nativeEnum:uxt,never:W_t,null:q_t,nullable:hxt,number:X8e,object:Q_t,oboolean:gxt,onumber:yxt,optional:dxt,ostring:vxt,pipeline:mxt,preprocess:pxt,promise:fxt,record:rxt,set:axt,strictObject:K_t,string:Y8e,symbol:j_t,transformer:$8e,tuple:nxt,undefined:G_t,union:J_t,unknown:X_t,void:$_t,NEVER:xxt,ZodIssueCode:os,quotelessJson:h_t,ZodError:sb}),bxt="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",Sxt=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r|=0));for(;r--;)e+=bxt[t[r]&63];return e},Z8e={Hz:{baseUnit:"Hz",variants:{MHz:1e6,kHz:1e3,Hz:1}},g:{baseUnit:"g",variants:{kg:1e3,g:1}},Ω:{baseUnit:"Ω",variants:{mΩ:.001,Ω:1,kΩ:1e3,KΩ:1e3,MΩ:1e6,GΩ:1e9,TΩ:1e12}},V:{baseUnit:"V",variants:{mV:.001,V:1,kV:1e3,KV:1e3,MV:1e6,GV:1e9,TV:1e12}},A:{baseUnit:"A",variants:{µA:1e-6,mA:.001,ma:.001,A:1,kA:1e3,MA:1e6}},F:{baseUnit:"F",variants:{pF:1e-12,nF:1e-9,µF:1e-6,uF:1e-6,mF:.001,F:1}},ml:{baseUnit:"ml",variants:{ml:1,mL:1,l:1e3,L:1e3}},deg:{baseUnit:"deg",variants:{rad:180/Math.PI}},ms:{baseUnit:"ms",variants:{s:1e3}},mm:{baseUnit:"mm",variants:{nm:1e-6,µm:.001,um:.001,mm:1,cm:10,dm:100,m:1e3,km:1e6,in:25.4,ft:304.8,IN:25.4,FT:304.8,yd:914.4,mi:1609344,mil:.0254}}},_K=new Set;for(const[r,e]of Object.entries(Z8e)){_K.add(r);for(const t of Object.keys(e.variants))_K.add(t)}function Ext(r){for(const[e,t]of Object.entries(Z8e))if(r in t.variants)return{baseUnit:t.baseUnit,conversionFactor:t.variants[r]};return{baseUnit:r,conversionFactor:1}}var Q8e={tera:1e12,T:1e12,giga:1e9,G:1e9,mega:1e6,M:1e6,kilo:1e3,k:1e3,deci:.1,d:.1,centi:.01,c:.01,milli:.001,m:.001,micro:1e-6,u:1e-6,µ:1e-6,nano:1e-9,n:1e-9,pico:1e-12,p:1e-12},cb=r=>{var s;if(typeof r>"u")return{parsedUnit:null,unitOfValue:null,value:null};if(typeof r=="string"&&r.match(/^[\d\.]+$/))return{value:Number.parseFloat(r),parsedUnit:null,unitOfValue:null};if(typeof r=="number")return{value:r,parsedUnit:null,unitOfValue:null};if(typeof r=="object"&&"x"in r&&"y"in r){const{parsedUnit:l,unitOfValue:c}=cb(r.x);return{parsedUnit:l,unitOfValue:c,value:{x:cb(r.x).value,y:cb(r.y).value}}}const t=(s=r.toString().split("").reverse().join("").match(/[^\d\s]+/))==null?void 0:s[0];if(!t)throw new Error(`Could not determine unit: "${r}"`);const n=t.split("").reverse().join(""),i=r.slice(0,-n.length);if(n in Q8e&&!_K.has(n)){const l=Q8e[n];return{parsedUnit:null,unitOfValue:null,value:Number.parseFloat(i)*l}}const{baseUnit:a,conversionFactor:o}=Ext(n);return{parsedUnit:n,unitOfValue:a,value:o*Number.parseFloat(i)}},rO=Ft.string().or(Ft.number()).transform(r=>cb(r).value),xK=Ft.string().or(Ft.number()).transform(r=>cb(r).value),K8e=Ft.string().or(Ft.number()).transform(r=>cb(r).value),bK=Ft.string().or(Ft.number()).transform(r=>cb(r).value),s_=Ft.string().or(Ft.number()).transform(r=>cb(r).value),J8e=Ft.string().or(Ft.number()).transform(r=>cb(r).value),pc=s_,wxt=Ft.string().or(Ft.number()).transform(r=>cb(r).value),Txt=Ft.string().or(Ft.number()).transform(r=>cb(r).value),iO=Ft.string().or(Ft.number()).transform(r=>typeof r=="number"?r:r.endsWith("deg")?Number.parseFloat(r.split("deg")[0]):r.endsWith("rad")?Number.parseFloat(r.split("rad")[0])*180/Math.PI:Number.parseFloat(r)),e6e=Ft.number().or(Ft.string().endsWith("mAh")).transform(r=>{if(typeof r=="string"){const e=r.replace("mAh",""),t=Number.parseFloat(e);if(Number.isNaN(t))throw new Error("Invalid capacity");return t}return r}).describe("Battery capacity in mAh"),Qy=Ft.object({x:pc,y:pc}),Mxt=Qy,sC=Ft.object({x:pc,y:pc,z:pc}),Cxt=sC,SK=Ft.object({width:Ft.number(),height:Ft.number()}),i1=r=>Ft.string().optional().default(()=>`${r}_${Sxt(10)}`),t6e=Ft.enum(["jlcpcb","macrofab","pcbway","digikey","mouser","lcsc"]),R5=Ft.object({type:Ft.literal("source_component"),ftype:Ft.string().optional(),source_component_id:Ft.string(),name:Ft.string(),manufacturer_part_number:Ft.string().optional(),supplier_part_numbers:Ft.record(t6e,Ft.array(Ft.string())).optional(),display_value:Ft.string().optional()}),EK=R5.extend({ftype:Ft.literal("simple_capacitor"),capacitance:xK,display_capacitance:Ft.string().optional(),max_decoupling_trace_length:pc.optional()}),wK=R5.extend({ftype:Ft.literal("simple_resistor"),resistance:rO,display_resistance:Ft.string().optional()}),aO=R5.extend({ftype:Ft.literal("simple_diode")}),n6e=R5.extend({ftype:Ft.literal("simple_ground")}),TK=R5.extend({ftype:Ft.literal("simple_bug")}).describe("@deprecated"),MK=R5.extend({ftype:Ft.literal("simple_chip")}),CK=aO.extend({ftype:Ft.literal("led")}),RK=R5.extend({ftype:Ft.literal("simple_power_source"),voltage:bK}),AK=R5.extend({ftype:Ft.literal("simple_battery"),capacity:e6e}),DK=R5.extend({ftype:Ft.literal("simple_inductor"),inductance:K8e}),PK=R5.extend({ftype:Ft.literal("simple_push_button")}),NK=R5.extend({ftype:Ft.literal("simple_potentiometer"),max_resistance:rO}),r6e=R5.extend({ftype:Ft.literal("simple_crystal"),frequency:Ft.number().describe("Frequency in Hz"),load_capacitance:Ft.number().optional().describe("Load capacitance in pF")}),LK=R5.extend({ftype:Ft.literal("simple_pin_header"),pin_count:Ft.number(),gender:Ft.enum(["male","female"]).optional().default("male")}),OK=R5.extend({ftype:Ft.literal("simple_resonator"),load_capacitance:xK,equivalent_series_resistance:rO.optional(),frequency:J8e}),UK=R5.extend({ftype:Ft.literal("simple_transistor"),transistor_type:Ft.enum(["npn","pnp"])}),zK=R5.extend({ftype:Ft.literal("simple_mosfet"),channel_type:Ft.enum(["n","p"]),mosfet_mode:Ft.enum(["enhancement","depletion"])}),i6e=Ft.union([wK,EK,aO,n6e,MK,TK,CK,RK,AK,DK,PK,NK,r6e,LK,OK,UK,zK]),a6e=Ft.object({type:Ft.literal("source_port"),pin_number:Ft.number().optional(),port_hints:Ft.array(Ft.string()).optional(),name:Ft.string(),source_port_id:Ft.string(),source_component_id:Ft.string()}),o6e=Ft.object({type:Ft.literal("source_trace"),source_trace_id:Ft.string(),connected_source_port_ids:Ft.array(Ft.string()),connected_source_net_ids:Ft.array(Ft.string()),subcircuit_connectivity_map_key:Ft.string().optional(),max_length:Ft.number().optional(),display_name:Ft.string().optional()}),s6e=Ft.object({type:Ft.literal("source_group"),source_group_id:Ft.string(),name:Ft.string().optional()}),l6e=Ft.object({type:Ft.literal("source_net"),source_net_id:Ft.string(),name:Ft.string(),member_source_group_ids:Ft.array(Ft.string()),is_power:Ft.boolean().optional(),is_ground:Ft.boolean().optional(),is_digital_signal:Ft.boolean().optional(),is_analog_signal:Ft.boolean().optional(),trace_width:Ft.number().optional()}),c6e=Ft.object({type:Ft.literal("schematic_box"),schematic_component_id:Ft.string(),width:pc,height:pc,x:pc,y:pc}).describe("Draws a box on the schematic"),u6e=Ft.object({type:Ft.literal("schematic_path"),schematic_component_id:Ft.string(),fill_color:Ft.enum(["red","blue"]).optional(),is_filled:Ft.boolean().optional(),points:Ft.array(Qy)}),f6e=Ft.record(Ft.object({left_margin:s_.optional(),right_margin:s_.optional(),top_margin:s_.optional(),bottom_margin:s_.optional()})),d6e=Ft.object({left_size:Ft.number(),right_size:Ft.number(),top_size:Ft.number().optional(),bottom_size:Ft.number().optional()}),h6e=Ft.object({left_side:Ft.object({pins:Ft.array(Ft.number()),direction:Ft.enum(["top-to-bottom","bottom-to-top"]).optional()}).optional(),right_side:Ft.object({pins:Ft.array(Ft.number()),direction:Ft.enum(["top-to-bottom","bottom-to-top"]).optional()}).optional(),top_side:Ft.object({pins:Ft.array(Ft.number()),direction:Ft.enum(["left-to-right","right-to-left"]).optional()}).optional(),bottom_side:Ft.object({pins:Ft.array(Ft.number()),direction:Ft.enum(["left-to-right","right-to-left"]).optional()}).optional()}),p6e=Ft.union([d6e,h6e]),m6e=Ft.object({type:Ft.literal("schematic_component"),rotation:iO.default(0),size:SK,center:Qy,source_component_id:Ft.string(),schematic_component_id:Ft.string(),pin_spacing:s_.optional(),pin_styles:f6e.optional(),box_width:s_.optional(),symbol_name:Ft.string().optional(),port_arrangement:p6e.optional(),port_labels:Ft.record(Ft.string()).optional(),symbol_display_value:Ft.string().optional()}),v6e=Ft.object({type:Ft.literal("schematic_line"),schematic_component_id:Ft.string(),x1:pc,x2:pc,y1:pc,y2:pc}),y6e=Ft.object({type:Ft.literal("schematic_trace"),schematic_trace_id:Ft.string(),source_trace_id:Ft.string(),junctions:Ft.array(Ft.object({x:Ft.number(),y:Ft.number()})),edges:Ft.array(Ft.object({from:Ft.object({x:Ft.number(),y:Ft.number()}),to:Ft.object({x:Ft.number(),y:Ft.number()}),is_crossing:Ft.boolean().optional(),from_schematic_port_id:Ft.string().optional(),to_schematic_port_id:Ft.string().optional()}))}),g6e=Ft.object({type:Ft.literal("schematic_text"),schematic_component_id:Ft.string(),schematic_text_id:Ft.string(),text:Ft.string(),position:Ft.object({x:pc,y:pc}),rotation:Ft.number().default(0),anchor:Ft.enum(["center","left","right","top","bottom"]).default("center"),color:Ft.string().default("#000000")}),_6e=Ft.object({type:Ft.literal("schematic_port"),schematic_port_id:Ft.string(),source_port_id:Ft.string(),schematic_component_id:Ft.string().optional(),center:Qy,facing_direction:Ft.enum(["up","down","left","right"]).optional(),distance_from_component_edge:Ft.number().optional(),side_of_component:Ft.enum(["top","bottom","left","right"]).optional(),true_ccw_index:Ft.number().optional(),pin_number:Ft.number().optional(),display_pin_label:Ft.string().optional()}).describe("Defines a port on a schematic component"),x6e=Ft.object({type:Ft.literal("schematic_net_label"),source_net_id:Ft.string(),center:Qy,anchor_position:Qy.optional(),anchor_side:Ft.enum(["top","bottom","left","right"]),text:Ft.string(),symbol_name:Ft.string().optional()}),b6e=Ft.object({type:Ft.literal("schematic_error"),schematic_error_id:Ft.string(),error_type:Ft.literal("schematic_port_not_found"),message:Ft.string()}).describe("Defines a schematic error on the schematic"),oO=Ft.object({type:Ft.literal("schematic_debug_object"),label:Ft.string().optional()}),S6e=oO.extend({shape:Ft.literal("rect"),center:Qy,size:SK}),E6e=oO.extend({shape:Ft.literal("line"),start:Qy,end:Qy}),w6e=oO.extend({shape:Ft.literal("point"),center:Qy}),T6e=Ft.discriminatedUnion("shape",[S6e,E6e,w6e]),M6e=Ft.object({type:Ft.literal("schematic_voltage_probe"),schematic_voltage_probe_id:Ft.string(),position:Qy,schematic_trace_id:Ft.string(),voltage:bK.optional()}).describe("Defines a voltage probe measurement point on a schematic trace"),sO=["top","bottom","inner1","inner2","inner3","inner4","inner5","inner6"],FK=Ft.enum(sO),k9=FK.or(Ft.object({name:FK})).transform(r=>typeof r=="string"?r:r.name),fw=Ft.enum(["top","bottom"]),C6e=Ft.object({x:pc,y:pc,via:Ft.boolean().optional(),via_to_layer:k9.optional()}),Rxt=Ft.array(C6e),R6e=Ft.object({x:pc,y:pc,via:Ft.boolean().optional(),to_layer:k9.optional(),trace_width:pc.optional()}),A6e=Ft.object({type:Ft.literal("pcb_component"),pcb_component_id:i1("pcb_component"),source_component_id:Ft.string(),center:Qy,layer:k9,rotation:iO,width:s_,height:s_}).describe("Defines a component on the PCB"),D6e=Ft.object({type:Ft.literal("pcb_hole"),pcb_hole_id:i1("pcb_hole"),hole_shape:Ft.enum(["circle","square"]),hole_diameter:Ft.number(),x:pc,y:pc}),Axt=D6e.describe("Defines a circular or square hole on the PCB"),P6e=Ft.object({type:Ft.literal("pcb_hole"),pcb_hole_id:i1("pcb_hole"),hole_shape:Ft.literal("oval"),hole_width:Ft.number(),hole_height:Ft.number(),x:pc,y:pc}),Dxt=P6e.describe("Defines an oval hole on the PCB"),N6e=D6e.or(P6e),Pxt=Ft.object({type:Ft.literal("pcb_plated_hole"),shape:Ft.literal("circle"),outer_diameter:Ft.number(),hole_diameter:Ft.number(),x:pc,y:pc,layers:Ft.array(k9),port_hints:Ft.array(Ft.string()).optional(),pcb_component_id:Ft.string().optional(),pcb_port_id:Ft.string().optional(),pcb_plated_hole_id:i1("pcb_plated_hole")}),Nxt=Ft.object({type:Ft.literal("pcb_plated_hole"),shape:Ft.enum(["oval","pill"]),outer_width:Ft.number(),outer_height:Ft.number(),hole_width:Ft.number(),hole_height:Ft.number(),x:pc,y:pc,layers:Ft.array(k9),port_hints:Ft.array(Ft.string()).optional(),pcb_component_id:Ft.string().optional(),pcb_port_id:Ft.string().optional(),pcb_plated_hole_id:i1("pcb_plated_hole")}),Lxt=Ft.object({type:Ft.literal("pcb_plated_hole"),shape:Ft.literal("circular_hole_with_rect_pad"),hole_shape:Ft.literal("circle"),pad_shape:Ft.literal("rect"),hole_diameter:Ft.number(),rect_pad_width:Ft.number(),rect_pad_height:Ft.number(),x:pc,y:pc,layers:Ft.array(k9),port_hints:Ft.array(Ft.string()).optional(),pcb_component_id:Ft.string().optional(),pcb_port_id:Ft.string().optional(),pcb_plated_hole_id:i1("pcb_plated_hole")}),L6e=Ft.union([Pxt,Nxt,Lxt]),O6e=Ft.object({type:Ft.literal("pcb_port"),pcb_port_id:i1("pcb_port"),source_port_id:Ft.string(),pcb_component_id:Ft.string(),x:pc,y:pc,layers:Ft.array(k9)}).describe("Defines a port on the PCB"),Oxt=Ft.object({type:Ft.literal("pcb_smtpad"),shape:Ft.literal("circle"),pcb_smtpad_id:i1("pcb_smtpad"),x:pc,y:pc,radius:Ft.number(),layer:k9,port_hints:Ft.array(Ft.string()).optional(),pcb_component_id:Ft.string().optional(),pcb_port_id:Ft.string().optional()}),Uxt=Ft.object({type:Ft.literal("pcb_smtpad"),shape:Ft.literal("rect"),pcb_smtpad_id:i1("pcb_smtpad"),x:pc,y:pc,width:Ft.number(),height:Ft.number(),layer:k9,port_hints:Ft.array(Ft.string()).optional(),pcb_component_id:Ft.string().optional(),pcb_port_id:Ft.string().optional()}),zxt=Ft.object({type:Ft.literal("pcb_smtpad"),shape:Ft.literal("rotated_rect"),pcb_smtpad_id:i1("pcb_smtpad"),x:pc,y:pc,width:Ft.number(),height:Ft.number(),ccw_rotation:iO,layer:k9,port_hints:Ft.array(Ft.string()).optional(),pcb_component_id:Ft.string().optional(),pcb_port_id:Ft.string().optional()}),U6e=Ft.union([Oxt,Uxt,zxt]).describe("Defines an SMT pad on the PCB"),Fxt=Ft.object({type:Ft.literal("pcb_solder_paste"),shape:Ft.literal("circle"),pcb_solder_paste_id:i1("pcb_solder_paste"),x:pc,y:pc,radius:Ft.number(),layer:k9,pcb_component_id:Ft.string().optional(),pcb_smtpad_id:Ft.string().optional()}),Ixt=Ft.object({type:Ft.literal("pcb_solder_paste"),shape:Ft.literal("rect"),pcb_solder_paste_id:i1("pcb_solder_paste"),x:pc,y:pc,width:Ft.number(),height:Ft.number(),layer:k9,pcb_component_id:Ft.string().optional(),pcb_smtpad_id:Ft.string().optional()}),z6e=Ft.union([Fxt,Ixt]).describe("Defines solderpaste on the PCB"),F6e=Ft.object({type:Ft.literal("pcb_text"),pcb_text_id:i1("pcb_text"),text:Ft.string(),center:Qy,layer:k9,width:s_,height:s_,lines:Ft.number(),align:Ft.enum(["bottom-left"])}).describe("Defines text on the PCB"),I6e=Ft.object({route_type:Ft.literal("wire"),x:pc,y:pc,width:pc,start_pcb_port_id:Ft.string().optional(),end_pcb_port_id:Ft.string().optional(),layer:k9}),k6e=Ft.object({route_type:Ft.literal("via"),x:pc,y:pc,from_layer:Ft.string(),to_layer:Ft.string()}),kxt=Ft.union([I6e,k6e]),B6e=Ft.object({type:Ft.literal("pcb_trace"),source_trace_id:Ft.string().optional(),pcb_component_id:Ft.string().optional(),pcb_trace_id:i1("pcb_trace"),route_thickness_mode:Ft.enum(["constant","interpolated"]).default("constant").optional(),route_order_index:Ft.number().optional(),should_round_corners:Ft.boolean().optional(),trace_length:Ft.number().optional(),route:Ft.array(Ft.union([Ft.object({route_type:Ft.literal("wire"),x:pc,y:pc,width:pc,start_pcb_port_id:Ft.string().optional(),end_pcb_port_id:Ft.string().optional(),layer:k9}),Ft.object({route_type:Ft.literal("via"),x:pc,y:pc,from_layer:Ft.string(),to_layer:Ft.string()})]))}).describe("Defines a trace on the PCB"),H6e=Ft.object({type:Ft.literal("pcb_trace_error"),pcb_trace_error_id:i1("pcb_trace_error"),error_type:Ft.literal("pcb_trace_error"),message:Ft.string(),center:Qy.optional(),pcb_trace_id:Ft.string(),source_trace_id:Ft.string(),pcb_component_ids:Ft.array(Ft.string()),pcb_port_ids:Ft.array(Ft.string())}).describe("Defines a trace error on the PCB"),V6e=Ft.object({type:Ft.literal("pcb_port_not_matched_error"),pcb_error_id:i1("pcb_error"),message:Ft.string(),pcb_component_ids:Ft.array(Ft.string())}).describe("Defines a trace error on the PCB where a port is not matched"),j6e=Ft.object({type:Ft.literal("pcb_via"),pcb_via_id:i1("pcb_via"),x:pc,y:pc,outer_diameter:pc.default("0.6mm"),hole_diameter:pc.default("0.25mm"),from_layer:k9.optional(),to_layer:k9.optional(),layers:Ft.array(k9),pcb_trace_id:Ft.string().optional()}).describe("Defines a via on the PCB"),G6e=Ft.object({type:Ft.literal("pcb_board"),pcb_board_id:i1("pcb_board"),width:s_,height:s_,center:Qy,thickness:s_.optional().default(1.4),num_layers:Ft.number().optional().default(4),outline:Ft.array(Qy).optional()}).describe("Defines the board outline of the PCB"),q6e=Ft.object({type:Ft.literal("pcb_placement_error"),pcb_placement_error_id:i1("pcb_placement_error"),message:Ft.string()}).describe("Defines a placement error on the PCB"),Y6e=Ft.object({type:Ft.literal("pcb_trace_hint"),pcb_trace_hint_id:i1("pcb_trace_hint"),pcb_port_id:Ft.string(),pcb_component_id:Ft.string(),route:Ft.array(R6e)}).describe("A hint that can be used during generation of a PCB trace"),X6e=Ft.object({type:Ft.literal("pcb_silkscreen_line"),pcb_silkscreen_line_id:i1("pcb_silkscreen_line"),pcb_component_id:Ft.string(),stroke_width:pc.default("0.1mm"),x1:pc,y1:pc,x2:pc,y2:pc,layer:fw}).describe("Defines a silkscreen line on the PCB"),W6e=Ft.object({type:Ft.literal("pcb_silkscreen_path"),pcb_silkscreen_path_id:i1("pcb_silkscreen_path"),pcb_component_id:Ft.string(),layer:fw,route:Ft.array(Qy),stroke_width:s_}).describe("Defines a silkscreen path on the PCB"),$6e=Ft.object({type:Ft.literal("pcb_silkscreen_text"),pcb_silkscreen_text_id:i1("pcb_silkscreen_text"),font:Ft.literal("tscircuit2024").default("tscircuit2024"),font_size:pc.default("0.2mm"),pcb_component_id:Ft.string(),text:Ft.string(),ccw_rotation:Ft.number().optional(),layer:k9,is_mirrored:Ft.boolean().default(!1).optional(),anchor_position:Qy.default({x:0,y:0}),anchor_alignment:Ft.enum(["center","top_left","top_right","bottom_left","bottom_right"]).default("center")}).describe("Defines silkscreen text on the PCB"),Z6e=Ft.object({type:Ft.literal("pcb_silkscreen_rect"),pcb_silkscreen_rect_id:i1("pcb_silkscreen_rect"),pcb_component_id:Ft.string(),center:Qy,width:s_,height:s_,layer:k9}).describe("Defines a silkscreen rect on the PCB"),Q6e=Ft.object({type:Ft.literal("pcb_silkscreen_circle"),pcb_silkscreen_circle_id:i1("pcb_silkscreen_circle"),pcb_component_id:Ft.string(),center:Qy,radius:s_,layer:fw}).describe("Defines a silkscreen circle on the PCB"),K6e=Ft.object({type:Ft.literal("pcb_silkscreen_oval"),pcb_silkscreen_oval_id:i1("pcb_silkscreen_oval"),pcb_component_id:Ft.string(),center:Qy,radius_x:pc,radius_y:pc,layer:fw}).describe("Defines a silkscreen oval on the PCB"),J6e=Ft.object({type:Ft.literal("pcb_fabrication_note_text"),pcb_fabrication_note_text_id:i1("pcb_fabrication_note_text"),font:Ft.literal("tscircuit2024").default("tscircuit2024"),font_size:pc.default("1mm"),pcb_component_id:Ft.string(),text:Ft.string(),layer:fw,anchor_position:Qy.default({x:0,y:0}),anchor_alignment:Ft.enum(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:Ft.string().optional()}).describe("Defines a fabrication note in text on the PCB, useful for leaving notes for assemblers or fabricators"),ewe=Ft.object({type:Ft.literal("pcb_fabrication_note_path"),pcb_fabrication_note_path_id:i1("pcb_fabrication_note_path"),pcb_component_id:Ft.string(),layer:k9,route:Ft.array(Qy),stroke_width:s_,color:Ft.string().optional()}).describe("Defines a fabrication path on the PCB for fabricators or assemblers"),twe=Ft.object({type:Ft.literal("pcb_keepout"),shape:Ft.literal("rect"),center:Qy,width:pc,height:pc,pcb_keepout_id:Ft.string(),layers:Ft.array(Ft.string()),description:Ft.string().optional()}).or(Ft.object({type:Ft.literal("pcb_keepout"),shape:Ft.literal("circle"),center:Qy,radius:pc,pcb_keepout_id:Ft.string(),layers:Ft.array(Ft.string()),description:Ft.string().optional()})),nwe=Ft.object({type:Ft.literal("pcb_missing_footprint_error"),pcb_missing_footprint_error_id:i1("pcb_missing_footprint_error"),error_type:Ft.literal("pcb_missing_footprint_error"),source_component_id:Ft.string(),message:Ft.string()}).describe("Defines a missing footprint error on the PCB"),rwe=Ft.object({type:Ft.literal("pcb_manual_edit_conflict_error"),pcb_error_id:i1("pcb_manual_edit_conflict_error"),message:Ft.string(),pcb_component_id:Ft.string(),source_component_id:Ft.string()}).describe("Error emitted when a component has both manual placement and explicit pcbX/pcbY coordinates"),iwe=Ft.object({type:Ft.literal("pcb_group"),pcb_group_id:i1("pcb_group"),width:s_,height:s_,center:Qy,pcb_component_ids:Ft.array(Ft.string()),name:Ft.string().optional(),description:Ft.string().optional()}).describe("Defines a group of components on the PCB"),awe=Ft.object({type:Ft.literal("cad_component"),cad_component_id:Ft.string(),pcb_component_id:Ft.string(),source_component_id:Ft.string(),position:sC,rotation:sC.optional(),size:sC.optional(),layer:k9.optional(),footprinter_string:Ft.string().optional(),model_obj_url:Ft.string().optional(),model_stl_url:Ft.string().optional(),model_3mf_url:Ft.string().optional(),model_jscad:Ft.any().optional()}).describe("Defines a component on the PCB"),owe=Ft.union([o6e,a6e,i6e,CK,l6e,s6e,TK,MK,EK,aO,wK,RK,AK,DK,LK,OK,UK,zK,NK,PK,A6e,N6e,nwe,rwe,L6e,twe,O6e,F6e,B6e,j6e,U6e,z6e,G6e,iwe,Y6e,X6e,W6e,$6e,Z6e,Q6e,K6e,H6e,q6e,V6e,ewe,J6e,c6e,g6e,v6e,m6e,_6e,y6e,u6e,b6e,x6e,T6e,M6e,awe]),swe=owe,IK=(r,e={})=>{let t=r._internal_store;if(!t){t={counts:{}},r._internal_store=t;for(const i of r){const a=i.type,o=i[`${a}_id`];if(!o)continue;const s=Number.parseInt(o.split("_").pop());Number.isNaN(s)||(t.counts[a]=Math.max(t.counts[a]??0,s))}}return new Proxy({},{get:(i,a)=>a==="toArray"?()=>r:{get:o=>r.find(s=>s.type===a&&s[`${a}_id`]===o),getUsing:o=>{const s=Object.keys(o);if(s.length!==1)throw new Error("getUsing requires exactly one key, e.g. { pcb_component_id }");const l=s[0],c=l.replace("_id",""),u=r.find(h=>h.type===c&&h[l]===o[l]);return u?r.find(h=>h.type===a&&h[`${a}_id`]===u[`${a}_id`]):null},getWhere:o=>{const s=Object.keys(o);return r.find(l=>l.type===a&&s.every(c=>l[c]===o[c]))},list:o=>{const s=o?Object.keys(o):[];return r.filter(l=>l.type===a&&s.every(c=>l[c]===o[c]))},insert:o=>{var c;(c=t.counts)[a]??(c[a]=-1),t.counts[a]++;const s=t.counts[a],l={type:a,[`${a}_id`]:`${a}_${s}`,...o};return e.validateInserts&&(L8e[a]??swe).parse(l),r.push(l),l},delete:o=>{const s=r.find(l=>l[`${a}_id`]===o);s&&r.splice(r.indexOf(s),1)},update:(o,s)=>{const l=r.find(c=>c.type===a&&c[`${a}_id`]===o);if(l)return Object.assign(l,s),l},select:o=>{if(a==="source_component")return r.find(s=>s.type==="source_component"&&s.name===o.replace(/\./g,""));if(a==="pcb_port"||a==="source_port"||a==="schematic_port"){const[s,l]=o.replace(/\./g,"").split(/[\s\>]+/),c=r.find(h=>h.type==="source_component"&&h.name===s);if(!c)return null;const u=r.find(h=>h.type==="source_port"&&h.source_component_id===c.source_component_id&&(h.name===l||(h.port_hints??[]).includes(l)));if(!u)return null;if(a==="source_port")return u;if(a==="pcb_port")return r.find(h=>h.type==="pcb_port"&&h.source_port_id===u.source_port_id);if(a==="schematic_port")return r.find(h=>h.type==="schematic_port"&&h.source_port_id===u.source_port_id)}}}})};IK.unparsed=IK;var wS=IK,Bxt=(r,e)=>{if(r.type==="pcb_plated_hole"||r.type==="pcb_hole"||r.type==="pcb_via"||r.type==="pcb_smtpad"||r.type==="pcb_port"){const{x:t,y:n}=ui(e,{x:r.x,y:r.y});r.x=t,r.y=n}else if(r.type==="pcb_keepout"||r.type==="pcb_board")r.center=ui(e,r.center);else if(r.type==="pcb_silkscreen_text"||r.type==="pcb_fabrication_note_text")r.anchor_position=ui(e,r.anchor_position);else if(r.type==="pcb_silkscreen_circle"||r.type==="pcb_silkscreen_rect"||r.type==="pcb_component")r.center=ui(e,r.center);else if(r.type==="pcb_silkscreen_path"||r.type==="pcb_trace"||r.type==="pcb_fabrication_note_path")r.route=r.route.map(t=>{const n=ui(e,t);return t.x=n.x,t.y=n.y,t});else if(r.type==="pcb_silkscreen_line"){const t={x:r.x1,y:r.y1},n={x:r.x2,y:r.y2},i=ui(e,t),a=ui(e,n);r.x1=i.x,r.y1=i.y,r.x2=a.x,r.y2=a.y}else if(r.type==="cad_component"){const t=ui(e,{x:r.position.x,y:r.position.y});r.position.x=t.x,r.position.y=t.y}return r};function Hxt(r){let e=0;if(r.length==0)return e;for(var t=0;t<r.length;t++){var n=r.charCodeAt(t);e=(e<<5)-e+n,e=e&e}return Math.abs(e)}var lwe=[["#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"]],Vxt=r=>{var s,l,c;let{x:e,y:t,width:n,height:i}={...r,...r.size,...r.center,...r.position};r.x1!==void 0&&r.x2!==void 0&&r.y1!==void 0&&r.y2!==void 0&&(e=(r.x1+r.x2)/2,t=(r.y1+r.y2)/2,n=Math.abs(r.x1-r.x2),i=Math.abs(r.y1-r.y2));const a=r.text||r.name||((s=r.source)==null?void 0:s.text)||((l=r.source)==null?void 0:l.name)||"?",o=r;return e===void 0||t===void 0?null:(n===void 0&&"outer_diameter"in r&&(n=r.outer_diameter,i=r.outer_diameter),(n===void 0||i===void 0)&&(n=.1,i=.1),{x:e,y:t,width:n,height:i,title:a,content:o,bg_color:((c=lwe[Hxt(r.type||a)%lwe.length])==null?void 0:c[4])??"#f00"})},jxt=r=>!!r,Gxt=r=>{const e=r.filter(c=>c.type.startsWith("pcb_")).concat(r.filter(c=>c.type==="pcb_trace").flatMap(c=>c.route)).map(c=>Vxt(c)).filter(jxt);if(e.length===0)return{center:{x:0,y:0},width:0,height:0};let t=e[0].x-e[0].width/2,n=e[0].x+e[0].width/2,i=e[0].y-e[0].height/2,a=e[0].y+e[0].height/2;for(const c of e.slice(1))t=Math.min(t,c.x-c.width/2),n=Math.max(n,c.x+c.width/2),i=Math.min(i,c.y-c.height/2),a=Math.max(a,c.y+c.height/2);const o=n-t,s=a-i;return{center:{x:t+o/2,y:i+s/2},width:o,height:s}},qxt=(r={})=>mlt(e=>({selected_layer:"top",pcb_viewer_id:`pcb_viewer_${Math.random().toString().slice(2,10)}`,in_edit_mode:!1,in_move_footprint_mode:!1,in_draw_trace_mode:!1,is_moving_component:!1,is_drawing_trace:!1,is_mouse_over_container:!1,is_showing_multiple_traces_length:!1,is_showing_rats_nest:!1,...r,selectLayer:t=>e({selected_layer:t}),setEditMode:t=>e({in_edit_mode:t!=="off",in_move_footprint_mode:t==="move_footprint",in_draw_trace_mode:t==="draw_trace",is_moving_component:!1,is_drawing_trace:!1}),setIsShowingRatsNest:t=>e({is_showing_rats_nest:t}),setIsMovingComponent:t=>e({is_moving_component:t}),setIsDrawingTrace:t=>e({is_drawing_trace:t}),setIsMouseOverContainer:t=>e({is_mouse_over_container:t}),setIsShowingMultipleTracesLength:t=>e({is_showing_multiple_traces_length:t})})),i2=r=>{const e=Tt.useContext(cwe);return Clt(e,r)},cwe=Tt.createContext(null),Yxt=({children:r,initialState:e})=>{const t=Tt.useMemo(()=>qxt(e),[]);return gt.jsx(cwe.Provider,{value:t,children:r})},Xxt=(r,e)=>{if(r.find(n=>n.type==="pcb_trace_hint"&&n.pcb_trace_hint_id===e.pcb_trace_hint_id))r=r.map(n=>n.pcb_trace_hint_id===e.pcb_trace_hint_id?{...n,route:e.route}:n);else{const n=wS(r).pcb_port.get(e.pcb_port_id);r=r.filter(i=>!(i.type==="pcb_trace_hint"&&i.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:n==null?void 0:n.pcb_component_id}])}return r},Wxt=(r,e)=>{r=JSON.parse(JSON.stringify(r));for(const t of e)if(t.pcb_edit_event_type==="edit_component_location"){const n=rv(t.new_center.x-t.original_center.x,t.new_center.y-t.original_center.y);r=r.map(i=>i.pcb_component_id!==t.pcb_component_id?i:Bxt(i,n))}else t.pcb_edit_event_type==="edit_trace_hint"&&(r=Xxt(r,t));return r},$xt=()=>{const r=i2(t=>t.pcb_viewer_id),e=(t,n)=>Dy(t,{containerId:r,...n});return e.error=(t,n)=>Dy.error(t,{containerId:r,...n}),e.promise=Dy.promise,e},Zxt=()=>{Tt.useEffect(()=>{y9t()},[]);const r=i2(e=>e.pcb_viewer_id);return gt.jsx(v9t,{position:"top-center",containerId:r})},Qxt=function(){},uwe=typeof window<"u",Kxt=uwe?Tt.useLayoutEffect:Tt.useEffect,Jxt=Kxt,fwe={x:0,y:0,width:0,height:0,top:0,left:0,bottom:0,right:0};function e5t(){var r=Tt.useState(null),e=r[0],t=r[1],n=Tt.useState(fwe),i=n[0],a=n[1],o=Tt.useMemo(function(){return new window.ResizeObserver(function(s){if(s[0]){var l=s[0].contentRect,c=l.x,u=l.y,h=l.width,g=l.height,_=l.top,b=l.left,T=l.bottom,C=l.right;a({x:c,y:u,width:h,height:g,top:_,left:b,bottom:T,right:C})}})},[]);return Jxt(function(){if(e)return o.observe(e),function(){o.disconnect()}},[e]),[t,i]}var t5t=uwe&&typeof window.ResizeObserver<"u"?e5t:function(){return[Qxt,fwe]},n5t=(r={})=>{const e=Tt.useRef(null),[t,n]=Tt.useState(0),i=r.canvasElm??e.current,[a,o]=Tt.useState(r.initialTransform??C_()),[s,l]=Tt.useState(0),[c,u]=Tt.useReducer(C=>C+1,0),h=Tt.useCallback(C=>{r.onSetTransform&&r.onSetTransform(C),r.transform||o(C)},[r.onSetTransform,o]),g=Tt.useCallback(C=>{h(C),u()},[h]),_=r.transform??a,b=Tt.useCallback(()=>{n(Date.now())},[]);Tt.useEffect(()=>{const C=r.canvasElm??e.current;if(C&&!i){l(s+1);return}if(!C){const me=setTimeout(()=>{l(s+1)},100);return()=>clearTimeout(me)}let A=r.transform??a,L={x:0,y:0},U={x:0,y:0},j=!1;const Z=me=>({x:me.pageX-C.getBoundingClientRect().left-window.scrollX,y:me.pageY-C.getBoundingClientRect().top-window.scrollY});function ee(me){r.enabled!==!1&&(r.shouldDrag&&!r.shouldDrag(me)||(L=Z(me),!(Date.now()-t<100)&&(j=!0,me.preventDefault())))}function $(me){if(!j||r.enabled===!1||r.shouldDrag&&!r.shouldDrag(me))return;U=Z(me);const _e=oh(rv(U.x-L.x,U.y-L.y),A);h(_e),A=_e,j=!1}function oe(me){Z(me),!(!j||r.enabled===!1)&&(r.shouldDrag&&!r.shouldDrag(me)||(U=Z(me),h(oh(rv(U.x-L.x,U.y-L.y),A))))}function ae(me){if(r.enabled===!1||r.shouldDrag&&!r.shouldDrag(me))return;const _e=Z(me),Se=oh(rv(_e.x,_e.y),_2(1-me.deltaY/1e3,1-me.deltaY/1e3),rv(-_e.x,-_e.y),A);h(Se),A=Se,me.preventDefault()}function ce(me){if(!j||r.shouldDrag&&!r.shouldDrag(me))return;if(C){const Se=C.getBoundingClientRect();if(me.clientX>=Se.left+10&&me.clientX<=Se.right-10&&me.clientY>=Se.top+10&&me.clientY<=Se.bottom-10)return}j=!1,U=Z(me);const _e=oh(rv(U.x-L.x,U.y-L.y),A);h(_e),A=_e}return C.addEventListener("mousedown",ee),C.addEventListener("mouseup",$),window.addEventListener("mousemove",oe),C.addEventListener("mouseout",ce),C.addEventListener("wheel",ae),()=>{C.removeEventListener("mousedown",ee),C.removeEventListener("mouseup",$),window.removeEventListener("mousemove",oe),C.removeEventListener("mouseout",ce),C.removeEventListener("wheel",ae)}},[i,s,c,t,r.enabled,r.shouldDrag]);const T=Tt.useCallback(C=>ui(_,C),[_]);return{ref:e,transform:_,applyTransformToPoint:T,setTransform:g,cancelDrag:b}},r5t=n5t,r5={"3d_viewer":{background_bottom:"rgb(102, 102, 128)",background_top:"rgb(204, 204, 230)",board:"rgb(51, 43, 23)",copper:"rgb(179, 156, 0)",silkscreen_bottom:"rgb(230, 230, 230)",silkscreen_top:"rgb(230, 230, 230)",soldermask:"rgb(20, 51, 36)",solderpaste:"rgb(128, 128, 128)"},board:{anchor:"rgb(255, 38, 226)",aux_items:"rgb(255, 255, 255)",b_adhes:"rgb(0, 0, 132)",b_crtyd:"rgb(255, 38, 226)",b_fab:"rgb(88, 93, 132)",b_mask:"rgba(2, 255, 238, 0.400)",b_paste:"rgb(0, 194, 194)",b_silks:"rgb(232, 178, 167)",background:"rgb(0, 16, 35)",cmts_user:"rgb(89, 148, 220)",copper:{b:"rgb(77, 127, 196)",f:"rgb(200, 52, 52)",in1:"rgb(127, 200, 127)",in10:"rgb(237, 124, 51)",in11:"rgb(91, 195, 235)",in12:"rgb(247, 111, 142)",in13:"rgb(167, 165, 198)",in14:"rgb(40, 204, 217)",in15:"rgb(232, 178, 167)",in16:"rgb(242, 237, 161)",in17:"rgb(237, 124, 51)",in18:"rgb(91, 195, 235)",in19:"rgb(247, 111, 142)",in2:"rgb(206, 125, 44)",in20:"rgb(167, 165, 198)",in21:"rgb(40, 204, 217)",in22:"rgb(232, 178, 167)",in23:"rgb(242, 237, 161)",in24:"rgb(237, 124, 51)",in25:"rgb(91, 195, 235)",in26:"rgb(247, 111, 142)",in27:"rgb(167, 165, 198)",in28:"rgb(40, 204, 217)",in29:"rgb(232, 178, 167)",in3:"rgb(79, 203, 203)",in30:"rgb(242, 237, 161)",in4:"rgb(219, 98, 139)",in5:"rgb(167, 165, 198)",in6:"rgb(40, 204, 217)",in7:"rgb(232, 178, 167)",in8:"rgb(242, 237, 161)",in9:"rgb(141, 203, 129)"},cursor:"rgb(255, 255, 255)",drc:"rgb(194, 194, 194)",drc_error:"rgba(215, 91, 107, 0.800)",drc_exclusion:"rgb(255, 255, 255)",drc_warning:"rgba(255, 208, 66, 0.902)",dwgs_user:"rgb(194, 194, 194)",eco1_user:"rgb(180, 219, 210)",eco2_user:"rgb(216, 200, 82)",edge_cuts:"rgb(208, 210, 205)",f_adhes:"rgb(132, 0, 132)",f_crtyd:"rgb(255, 0, 245)",f_fab:"rgb(175, 175, 175)",f_mask:"rgba(216, 100, 255, 0.400)",f_paste:"rgba(180, 160, 154, 0.902)",f_silks:"rgb(242, 237, 161)",footprint_text_back:"rgb(0, 0, 132)",footprint_text_front:"rgb(194, 194, 194)",footprint_text_invisible:"rgb(132, 132, 132)",grid:"rgb(132, 132, 132)",grid_axes:"rgb(194, 194, 194)",margin:"rgb(255, 38, 226)",microvia:"rgb(0, 132, 132)",no_connect:"rgb(0, 0, 132)",pad_back:"rgb(77, 127, 196)",pad_front:"rgb(200, 52, 52)",pad_plated_hole:"rgb(194, 194, 0)",pad_through_hole:"rgb(227, 183, 46)",plated_hole:"rgb(26, 196, 210)",ratsnest:"rgba(245, 255, 213, 0.702)",select_overlay:"rgb(4, 255, 67)",through_via:"rgb(236, 236, 236)",user_1:"rgb(194, 194, 194)",user_2:"rgb(89, 148, 220)",user_3:"rgb(180, 219, 210)",user_4:"rgb(216, 200, 82)",user_5:"rgb(194, 194, 194)",user_6:"rgb(89, 148, 220)",user_7:"rgb(180, 219, 210)",user_8:"rgb(216, 200, 82)",user_9:"rgb(232, 178, 167)",via_blind_buried:"rgb(187, 151, 38)",via_hole:"rgb(227, 183, 46)",via_micro:"rgb(0, 132, 132)",via_through:"rgb(236, 236, 236)",worksheet:"rgb(200, 114, 171)"},gerbview:{axes:"rgb(0, 0, 132)",background:"rgb(0, 0, 0)",dcodes:"rgb(255, 255, 255)",grid:"rgb(132, 132, 132)",layers:["rgb(132, 0, 0)","rgb(194, 194, 0)","rgb(194, 0, 194)","rgb(194, 0, 0)","rgb(0, 132, 132)","rgb(0, 132, 0)","rgb(0, 0, 132)","rgb(132, 132, 132)","rgb(132, 0, 132)","rgb(194, 194, 194)","rgb(132, 0, 132)","rgb(132, 0, 0)","rgb(132, 132, 0)","rgb(194, 194, 194)","rgb(0, 0, 132)","rgb(0, 132, 0)","rgb(132, 0, 0)","rgb(194, 194, 0)","rgb(194, 0, 194)","rgb(194, 0, 0)","rgb(0, 132, 132)","rgb(0, 132, 0)","rgb(0, 0, 132)","rgb(132, 132, 132)","rgb(132, 0, 132)","rgb(194, 194, 194)","rgb(132, 0, 132)","rgb(132, 0, 0)","rgb(132, 132, 0)","rgb(194, 194, 194)","rgb(0, 0, 132)","rgb(0, 132, 0)","rgb(132, 0, 0)","rgb(194, 194, 0)","rgb(194, 0, 194)","rgb(194, 0, 0)","rgb(0, 132, 132)","rgb(0, 132, 0)","rgb(0, 0, 132)","rgb(132, 132, 132)","rgb(132, 0, 132)","rgb(194, 194, 194)","rgb(132, 0, 132)","rgb(132, 0, 0)","rgb(132, 132, 0)","rgb(194, 194, 194)","rgb(0, 0, 132)","rgb(0, 132, 0)","rgb(132, 0, 0)","rgb(194, 194, 0)","rgb(194, 0, 194)","rgb(194, 0, 0)","rgb(0, 132, 132)","rgb(0, 132, 0)","rgb(0, 0, 132)","rgb(132, 132, 132)","rgb(132, 0, 132)","rgb(194, 194, 194)","rgb(132, 0, 132)","rgb(132, 0, 0)"],negative_objects:"rgb(132, 132, 132)",worksheet:"rgb(0, 0, 132)"},palette:["rgb(132, 0, 0)","rgb(194, 194, 0)","rgb(194, 0, 194)","rgb(194, 0, 0)","rgb(0, 132, 132)","rgb(0, 132, 0)","rgb(0, 0, 132)","rgb(132, 132, 132)","rgb(132, 0, 132)","rgb(194, 194, 194)","rgb(132, 0, 132)","rgb(132, 0, 0)","rgb(132, 132, 0)","rgb(194, 194, 194)","rgb(0, 0, 132)","rgb(0, 132, 0)"],schematic:{anchor:"rgb(0, 0, 255)",aux_items:"rgb(0, 0, 0)",background:"rgb(33, 33, 33)",brightened:"rgb(204, 204, 204)",bus:"rgb(0, 96, 192)",bus_junction:"rgb(0, 96, 192)",component_body:"rgb(44, 44, 44)",component_outline:"rgb(192, 0, 0)",cursor:"rgb(224, 224, 224)",erc_error:"rgba(192, 48, 48, 0.800)",erc_warning:"rgba(192, 140, 0, 0.800)",fields:"rgb(128, 0, 160)",grid:"rgb(60, 60, 60)",grid_axes:"rgb(60, 60, 60)",hidden:"rgb(194, 194, 194)",junction:"rgb(0, 160, 0)",label_global:"rgb(0, 160, 224)",label_hier:"rgb(160, 160, 0)",label_local:"rgb(192, 192, 192)",net_name:"rgb(224, 224, 224)",no_connect:"rgb(97, 43, 224)",note:"rgb(192, 192, 0)",override_item_colors:!1,pin:"rgb(192, 0, 0)",pin_name:"rgb(192, 192, 192)",pin_number:"rgb(192, 0, 0)",reference:"rgb(192, 192, 192)",shadow:"rgba(102, 179, 255, 0.800)",sheet:"rgb(128, 0, 160)",sheet_background:"rgba(255, 255, 255, 0.000)",sheet_fields:"rgb(160, 160, 0)",sheet_filename:"rgb(160, 160, 0)",sheet_label:"rgb(160, 160, 0)",sheet_name:"rgb(0, 160, 204)",value:"rgb(192, 192, 192)",wire:"rgb(0, 160, 0)",worksheet:"rgb(192, 0, 0)"}},Xb=(r,e=1)=>{if(Math.abs(r.a)!==Math.abs(r.d))throw new Error("Cannot scale non-uniformly");return e*Math.abs(r.a)},ub={elementOverlay:30,dimensionOverlay:30,editTraceHintOverlay:30,errorOverlay:30,ratsNestOverlay:20,toolbarOverlay:20,topLayer:10},dw={red:"red",black:"black",green:"green",board:"rgb(255, 255, 255)",other:"#eee",top:r5.board.copper.f,inner1:r5.board.copper.in1,inner2:r5.board.copper.in2,inner4:r5.board.copper.in4,inner5:r5.board.copper.in5,inner6:r5.board.copper.in6,inner7:r5.board.copper.in7,inner8:r5.board.copper.in8,bottom:r5.board.copper.b,drill:r5.board.anchor,keepout:r5.board.background,tkeepout:r5.board.b_crtyd,tplace:r5.board.b_silks,top_silkscreen:r5.board.f_silks,bottom_silkscreen:r5.board.b_silks,top_fabrication:r5.board.f_fab,bottom_fabrication:r5.board.b_fab,...r5.board},i5t=["top","inner1","inner2","inner3","inner4","inner5","inner6","bottom"],a5t=class{constructor(r){ni(this,"canvasLayerMap");ni(this,"ctxLayerMap");ni(this,"aperture");ni(this,"transform");ni(this,"foregroundLayer","top");ni(this,"lastPoint");this.canvasLayerMap=r,this.ctxLayerMap=Object.fromEntries(Object.entries(r).map(([e,t])=>[e,t.getContext("2d")])),this.transform=C_(),this.transform.d*=-1,this.transform=oh(this.transform,rv(0,-500)),this.lastPoint={x:0,y:0},this.equip({})}clear(){for(const r of Object.values(this.ctxLayerMap))r.clearRect(0,0,r.canvas.width,r.canvas.height)}equip(r){this.aperture={fontSize:0,shape:"circle",mode:"add",size:0,color:"red",layer:"top",opacity:this.foregroundLayer===r.color?1:.5,...r}}drawMeshPattern(r,e,t,n,i,a=45){const o=this.getLayerCtx(),[s,l]=ui(this.transform,[r,e]),[c,u]=ui(this.transform,[r+t,e+n]),h=Xb(this.transform,i);o.lineWidth=1,o.strokeStyle=this.aperture.color;const g=_=>{const b=Math.sin(_),T=Math.cos(_),C=Math.sqrt(Math.pow(c-s,2)+Math.pow(u-l,2));for(let A=-C;A<=C;A+=h)o.beginPath(),o.moveTo(s+A*T-C*b,l+A*b+C*T),o.lineTo(s+A*T+C*b,l+A*b-C*T),o.stroke()};g(a*Math.PI/180),g((a+90)*Math.PI/180)}rect(r,e,t,n,i){const[a,o]=ui(this.transform,[r-t/2,e-n/2]),[s,l]=ui(this.transform,[r+t/2,e+n/2]);this.applyAperture();const c=this.getLayerCtx();i?(c.save(),c.beginPath(),c.rect(a,o,s-a,l-o),c.clip(),this.drawMeshPattern(r-t/2,e-n/2,t,n,.15),c.restore(),c.strokeRect(a,o,s-a,l-o)):c.fillRect(a,o,s-a,l-o)}rotatedRect(r,e,t,n,i,a){const o=this.getLayerCtx();this.applyAperture();const[s,l]=ui(this.transform,[r-t/2,e-n/2]),[c,u]=ui(this.transform,[r+t/2,e+n/2]);o.save();const[h,g]=ui(this.transform,[r,e]);o.translate(h,g);const _=360-i;i&&o.rotate(_*Math.PI/180),o.translate(-h,-g),a?(o.beginPath(),o.rect(s,l,c-s,u-l),o.clip(),this.drawMeshPattern(r-t/2,e-n/2,t,n,.15),o.strokeRect(s,l,c-s,u-l)):o.fillRect(s,l,c-s,u-l),o.restore()}circle(r,e,t,n){const i=Xb(this.transform,t),[a,o]=ui(this.transform,[r,e]);this.applyAperture();const s=this.getLayerCtx();n?(s.save(),s.beginPath(),s.arc(a,o,i,0,2*Math.PI),s.clip(),this.drawMeshPattern(r-t,e-t,t*2,t*2,.15),s.restore(),s.beginPath(),s.arc(a,o,i,0,2*Math.PI),s.stroke()):(s.beginPath(),s.arc(a,o,i,0,2*Math.PI),s.fill())}oval(r,e,t,n){const i=Xb(this.transform,t),a=Xb(this.transform,n),[o,s]=ui(this.transform,[r,e]);this.applyAperture();const l=this.getLayerCtx();l.beginPath(),l.ellipse(o,s,i,a,0,0,2*Math.PI),l.fill(),l.closePath()}pill(r,e,t,n){const[i,a]=ui(this.transform,[r-t/2,e+n/2]),o=Xb(this.transform,t),s=Xb(this.transform,n),l=Math.min(o,s)/2;this.applyAperture();const c=this.getLayerCtx();c.beginPath(),c.arc(i+l,a+l,l,Math.PI,Math.PI*1.5),c.arc(i+o-l,a+l,l,Math.PI*1.5,0),c.arc(i+o-l,a+s-l,l,0,Math.PI*.5),c.arc(i+l,a+s-l,l,Math.PI*.5,Math.PI),c.fill(),c.closePath()}polygon(r){if(r.length<3)return;this.applyAperture();const e=this.getLayerCtx(),t=r.map(i=>ui(this.transform,[i.x,i.y]));e.beginPath(),e.moveTo(t[0][0],t[0][1]);for(let i=1;i<t.length;i++)e.lineTo(t[i][0],t[i][1]);e.closePath(),e.fill();const n=Xb(this.transform,this.aperture.size);e.lineWidth=n,e.stroke()}debugText(r,e,t){const[n,i]=ui(this.transform,[e,t]);this.applyAperture();const a=this.getLayerCtx();a.font="10px sans-serif",a.fillText(r,n,i)}getLayerCtx(){const r=this.ctxLayerMap[this.aperture.layer];if(!r)throw new Error(`No context for layer "${this.aperture.layer}"`);return r}orderAndFadeLayers(){const{canvasLayerMap:r,foregroundLayer:e}=this,t=new Set([e,"drill","other","board"]);["drill","board",e,...i5t.filter(i=>i!==e)].forEach((i,a)=>{const o=r[i];o&&(o.style.zIndex=`${ub.topLayer-a}`,o.style.opacity=t.has(i)?"1":"0.5")})}applyAperture(){const{transform:r,aperture:e}=this;let{size:t,mode:n,color:i,fontSize:a,layer:o}=e;o in this.ctxLayerMap||(this.aperture.layer="other");const s=this.getLayerCtx();if(!s)throw new Error(`No context for layer "${this.foregroundLayer}"`);if(i||(i="undefined"),s.lineWidth=Xb(r,t),s.lineCap="round",n==="add"){let l=(i==null?void 0:i[0])==="#"||i!=null&&i.startsWith("rgb")?i:dw[i==null?void 0:i.toLowerCase()]?dw[i==null?void 0:i.toLowerCase()]:null;l===null&&(console.warn(`Color mapping for "${i}" not found`),l="white"),s.fillStyle=l,s.strokeStyle=l}else s.globalCompositeOperation="destination-out",s.fillStyle="rgba(0,0,0,1)",s.strokeStyle="rgba(0,0,0,1)";s.font=`${Xb(Tb(r),a)}px sans-serif`}moveTo(r,e){this.lastPoint={x:r,y:e}}lineTo(r,e){const[t,n]=ui(this.transform,[r,e]),{size:i,shape:a,mode:o}=this.aperture,s=Xb(this.transform,i);let{lastPoint:l}=this;const c=ui(this.transform,l);this.applyAperture();const u=this.getLayerCtx();a==="square"&&u.fillRect(c.x-s/2,c.y-s/2,s,s),u.beginPath(),u.moveTo(c.x,c.y),u.lineTo(t,n),u.stroke(),u.closePath(),a==="square"&&u.fillRect(t-s/2,n-s/2,s,s),this.lastPoint={x:r,y:e}}};function o5t(r){const{lines:e,anchorPoint:t,ccwRotation:n}=r;if(!n)return e;const i=n*Math.PI/180,a=l3(i),o=oh(rv(t.x,t.y),a,rv(-t.x,-t.y));return ui(o,t),e.map(s=>({...s,x1:ui(o,{x:s.x1,y:s.y1}).x,y1:ui(o,{x:s.x1,y:s.y1}).y,x2:ui(o,{x:s.x2,y:s.y2}).x,y2:ui(o,{x:s.x2,y:s.y2}).y}))}var dwe={0:"M0.4544564813877358 0L0.2723441540828736 0.03592830447352719L0.1086847233315459 0.14528754990019965L0.020630545837255005 0.3040632652221331L0 0.5395277421960205L0.049259221760993496 0.7369487828466779L0.18080513776237842 0.9005494166306564L0.37036887043974215 0.9872116270037247L0.5864663759301132 1L0.8148695622827444 0.9332890276148733L0.9326583645506394 0.8113052246023419L1 0.4031281830668562L0.833288960385582 0.09886798567812842L0.6801767918233781 0.02483708485091681L0.4544564813877358 0",1:"M 0.198 0.272 L 0.537 0 L 0.54 1",2:"M0.069593147751606 0.19461498231706575L0.1039380353319058 0.1224291500164194L0.20543361884368308 0.05510832064153169L0.3717712794432549 0.009452970962689482L0.4785344452623127 0L0.663238590738758 0.008714098643339864L0.8017933618843684 0.04769189395915288L0.8775637379550322 0.10746757678258442L0.9047778372591005 0.17693069668193287L0.9029710920770878 0.2231347105796246L0.8704496788008566 0.30047744598157516L0.7292906538577354 0.4508486051631194L0.3737955032119913 0.7369006417749693L0 1L1 1",3:"M0.03917438899874637 0.19855364635107545L0.15510940508963084 0.06745632622133718L0.37598645522339846 0L0.8486391893813088 0.0652271323161611L0.9782182415054349 0.21747394183735683L0.9213133780517754 0.3547560290117714L0.6504271515903481 0.4543436297681271L0.22975249764129613 0.48476611625264143L0.7659038682744629 0.5411919558122493L0.9258712987734741 0.6203185665660985L1 0.7458360609169667L0.8938813281118737 0.9059190913045964L0.6166890258875837 1L0.261528440153542 0.9874861530507921L0 0.8837289530851273",4:"M0.7328897338403042 0L0 0.6684672518568535L1 0.6684672518568535M0.7243346007604563 0.4530722484807562L0.7243346007604563 1",5:"M 0 0 L 0 0.4973 L 0.4262 0.4319 L 0.7305 0.4565 L 0.8516 0.5009 L 0.9357 0.5639 L 1 0.7356 L 0.9696 0.8248 L 0.8898 0.895 L 0.733 0.9602 L 0.5518 0.9945 L 0.3814 1 L 0.2379 0.9821 L 0.1219 0.947 L 0 0.8748 M 0 0 L 1 0",6:"M0.6964601700926856 0L0.3639239026215478 0.0743562375769351L0.1415931962925719 0.21735490179786915L0.009977939399608712 0.46336322325406004L0.00029622007592593224 0.7083131475173043L0.09408885043224748 0.8746809149767036L0.3379247445101846 0.9876686500961888L0.7109203869569624 1L0.9260852957913362 0.9103558029693921L1 0.7716571969091733L0.9824294723385016 0.6390635485705886L0.7446504992867332 0.4733643097729175L0.31028858071607296 0.47578021640899115L0.1208702146816024 0.5481452483973847L0 0.6616669755788906",7:"M0 0L1 0L0.9246479649697582 0.030539772727272752L0.8850302419354837 0.05075757575757579L0.7922946068548385 0.11079545454545457L0.7419268208165322 0.15213068181818185L0.6907258064516127 0.20202020202020204L0.6400666267641127 0.26122159090909086L0.5913243447580644 0.33049242424242414L0.5458740234374998 0.4105902777777778L0.5050907258064514 0.5022727272727272L0.4703495148689514 0.6062973484848484L0.43257456133442534 0.787133049242424L0.41612903225806447 1",8:"M0.5143001078924863 0L0.16007477667923162 0.10731570786949331L0.14924628550868277 0.3146018498698755L0.2939585848842112 0.41617921794558677L0.8648302624811545 0.5385163833653317L1 0.7775820770511038L0.8180842915260376 0.9505845566922285L0.41968938540525413 1L0.08062381919779889 0.882831681184498L0 0.6936376947135333L0.17150171673893433 0.5188652309607817L0.6529263782780712 0.4242818653203618L0.8650205888491803 0.29644027376796367L0.8702067371119496 0.09910067291661573L0.5143001078924863 0",9:"M1 0.25379591792994305L0.9514789771111742 0.11679361536614272L0.8702482473521467 0.05711741614054847L0.7327445265851579 0.015213872471965633L0.525248180711544 0L0.3292056884418538 0.012928195113745608L0.15997632037247655 0.058762870026191856L0.05266940041228321 0.12882439350476L0 0.2562067822770946L0.11316462894512366 0.4121335905917837L0.2403060136479954 0.4603365890068938L0.4097241967586011 0.4745978388276783L0.8642414300184816 0.420815170259988L0.9732054796346318 0.34537434075898393L1 0.25379591792994305M0.9647426784191072 0.35488595400360495L0.4756895081034974 1",A:"M0 1L0.4808333333333333 0L1 1M0.24250000000000002 0.6099439775910365L0.7341666666666666 0.6099439775910365",B:"M0 1L0 0.0117369978777208L0.30665717153513444 0L0.5874522807082946 0.03451403469442413L0.7766202217193218 0.15033936404895643L0.7471969743588041 0.31967962568332936L0.5246013359741988 0.4102978954282461L0.04378745314885416 0.44918617613783574L0.5112949594180156 0.469692928091109L0.8540266515643348 0.5552749498651879L1 0.6868463175009967L0.9880091196159324 0.8570018204672155L0.922301719975498 0.9321708046604659L0.7584266951758925 0.9932594737131338L0 1",C:"M1 0.23038928858890784L0.9328355511865092 0.12426412616785204L0.8096380839483327 0.04912601676267708L0.5763225801788256 0L0.4039037709527492 0.015028068281399815L0.2519579390951737 0.06533979308999706L0.10359458463139784 0.18146243506591617L0 0.4862728453971315L0.08129580872733055 0.792689266886982L0.20257034847159672 0.9160822255736587L0.3286572892798542 0.9738230826074175L0.5742878414421707 1L0.7883510303801312 0.9665431511195721L0.946851033994232 0.8689071500976585L1 0.7311049027121912",D:"M0 1L0.015604366822624637 0.020770988281483303L0.22564758265176144 0L0.3865476147957666 0.0024153386496795644L0.6479126635475078 0.051745644338731314L0.841191887805517 0.15827717679529366L0.9517008345536152 0.30172260586872185L0.9957536578687336 0.4504541551987709L1 0.5624359222498485L0.9798483279164735 0.6584121775234548L0.9386273319285215 0.7395945263504481L0.806292129480815 0.8624239259880274L0.6296239151398265 0.9406169638094516L0.3397492767598845 0.9954164354263132L0 1",E:"M0 0L0 1M0 0L1 0M0 0.5L0.7 0.5M0 1L1 1",F:"M0 0L0 1M0.011363636363636364 0.006802721088435374L1 0.006802721088435374M0.011363636363636364 0.4965986394557823L0.8409090909090909 0.4965986394557823",G:"M0.902666857540557 0.03860785012651126L0.6504261864675637 0L0.3838947267237336 0.015442305268228053L0.21293332876776194 0.07706794377239819L0.07799659974941617 0.1994951236187481L0 0.46380381528937314L0.04159964421546915 0.7502491408002389L0.13176692977834842 0.8535497868383203L0.2709176262273927 0.936767572377719L0.4386472596876406 0.9891638569283179L0.6145513562841309 1L0.7782254421419019 0.9585373611026471L0.9092650433859927 0.8540372997461425L1 0.5556012645283437L0.5583959277303046 0.55491741080559",H:"M0 0L0 1M0 0.4788732394366197L0.989010989010989 0.4788732394366197M1 0L1 1",I:"M0.5 0L0.5 1",J:"M0.9976457238788704 0L1 0.7396412315872798L0.9773931362096968 0.8322033314977973L0.9345115952458736 0.882296255506608L0.8743862896259549 0.9221331222466961L0.8024024079884948 0.9526431718061675L0.6443996712151668 0.9893997797356828L0.5035848940343224 1L0.3127211130319937 0.9877004749449337L0.17201910858386513 0.9539509911894274L0.10357419806379677 0.9212555066079295L0.053656568662899015 0.8816079295154184L0.020759483663648916 0.8360407488986785L0.003376206348523566 0.7855864537444934L0 0.7312775330396476",K:"M0 0L0 1M0.8787878787878788 0.06666666666666667L0 0.6148148148148148M0.3333333333333333 0.45925925925925926L1 0.9777777777777777",L:"M0 0L0 1L1 1",M:"M0 1L0 0L0.5 0.6512L1 0L1 1",N:"M0 1L0 0L1 1L0.9803729146221786 0",O:"M0.4718499217948183 1L0.2896765846490613 0.9606979309189402L0.12315162147934663 0.8411184486080473L0 0.4352399966492615L0.11730398524516283 0.13145645436014852L0.2612197451988078 0.04493357858878059L0.5104071592772554 0L0.7450113425917159 0.05393013710105273L0.882367950645524 0.15242300282020502L1 0.5224527406249126L0.9414597290654386 0.7560662329321755L0.8371289514446183 0.8910800547287298L0.6518259868433511 0.9830452628933628L0.4718499217948183 1",P:"M0 1L0 0.018871774228013626L0.29609603495819875 0L0.5609840637427541 0.011794858892508529L0.7332142696692472 0.04353904702296349L0.8102258645858864 0.0691965055027166L0.9330504315465442 0.14445061754775845L0.9876391714147118 0.22527816445836535L1 0.3434414070631638L0.9510549958116356 0.41772808046663146L0.8746646891596713 0.45879131862541683L0.7528523813396283 0.49171525113425024L0.5766919939969619 0.5153253033973054L0.33725744877712827 0.5284469008187558L0.025622667325582785 0.529905468802775",Q:"M0.4618887943546369 0.9755918167206952L0.28356128136544534 0.9372490397450218L0.12055179272160406 0.8205882753548176L0 0.4246165790405623L0.1148276047430244 0.12824784112887844L0.25570518844754375 0.043836831567190586L0.49963205786237674 0L0.7292835601228574 0.0526138004304122L0.8637404608452104 0.14870263423138746L0.9788892040030622 0.5097006183769648L0.9215847647858059 0.7376120297474734L0.8194564929275405 0.869330409436378L0.6380654214095985 0.9590509139448092L0.4618887943546369 0.9755918167206952M0.5824181120212351 0.6861805006946525L1 1",R:"M0 0.9928375167236815L0 0.02590227442068435L0.3611517274211098 0L0.6146286724700761 0.008660554424468435L0.7675462459194776 0.035269459580494614L0.831839975516866 0.056961676692569484L0.8847592491838954 0.08519560521497332L0.9238557535364527 0.120683646438422L0.9583303225312839 0.21691797435320384L0.955092470586235 0.3022616904894429L0.9198097669001631 0.3640573439322699L0.8564862239866702 0.40639258627024005L0.7691258543593579 0.43335506909190874L0.601775027203482 0.4539166070813109L0.023939064200217658 0.46997623755243123M0.5038084874863982 0.5108023922274467L1 1",S:"M0.8886929689221953 0.15146982162688968L0.7276173683050475 0.013780286031594946L0.34582323121005076 0L0.1318235250900008 0.09920162734298861L0.0444543935052531 0.2811287071349243L0.08064065829108809 0.3709571405906485L0.21603115127470426 0.4485505768228281L0.7525409135992945 0.5111160926769565L0.9330263665417677 0.5850732219351329L1 0.7129938124702524L0.9117772389978691 0.9130572743138187L0.6423187128058188 1L0.29586019579751677 0.9935291584506244L0.10638454191462794 0.9229845198431584L0 0.7570771288048773",T:"M0 0L1 0M0.5148514851485149 0L0.5148514851485149 1",U:"M0 0L0.0023103778751369115 0.5467447428390111L0.01823032542100219 0.6954785891481812L0.05895528135268338 0.8056480226151669L0.13703402031421133 0.8894445726483398L0.23918400876232196 0.9448524533417946L0.3917887458926616 0.9848674531975652L0.584341627875137 1L0.7194816196604602 0.9848501456716763L0.8303268115073934 0.9449411544119768L0.8966613970084885 0.898186315516197L0.9251437568455642 0.867453197565408L0.9687114937020809 0.7890904895145239L0.9890470974808324 0.6852857184065537L1 0.0014769088758762145",V:"M0 0L0.5348837209302325 1L1 0",W:"M0 0L0.23300090661831369 0.9873417721518988L0.49954669084315495 0.30081906180193585L0.7851314596554849 1L1 0.0215934475055845",X:"M0 0L0.9893617021276596 1M1 0L0.010638297872340425 1",Y:"M0 0L0.4860515021459227 0.44712562100780695M1 0.0014194464158977947L0.48927038626609437 0.44996451383960256L0.5075107296137339 1",Z:"M0 0L1 0L0 1L1 1",".":"M 0.49 1 L 0.41 1","*":"M 0.5 0.25 L 0.8 0.25 M 0.5 0.25 L 0.5927 0.4402 M 0.5 0.25 L 0.2573 0.3676 M 0.5 0.25 L 0.2573 0.1324 M 0.5 0.25 L 0.599 0.055","(":"M0.75 0L0.25 0.5L0.25 0.5L0.75 1",")":"M0.25 0L0.75 0.5L0.75 0.5L0.25 1","-":"M0 0.5L1 0.5","+":"M 0 0.5 L 1 0.5 M 0.5 0.125 L 0.5 0.875","=":"M0 0.25L1 0.25M0 0.75L1 0.75",_:"M0 1 L1 1","[":"M0.75 0L0.25 0L0.25 1L0.75 1","]":"M0.25 0L0.75 0L0.75 1L0.25 1","<":"M0.75 0L0.25 0.5L0.25 0.5L0.75 1",">":"M0.25 0L0.75 0.5L0.75 0.5L0.25 1","'":"M 0.5 0 L 0.5 0.5",'"':"M 0.25 0 L 0.25 0.5 M 0.75 0 L 0.75 0.5"},kK={};for(const r in dwe){kK[r]=[];const e=dwe[r].split("M").slice(1).map(t=>t.split("L").map(n=>n.trim().split(" ").map(parseFloat)));for(const t of e)for(let n=0;n<t.length-1;n++)kK[r].push({x1:t[n][0],y1:1-t[n][1],x2:t[n+1][0],y2:1-t[n+1][1]})}var hwe=.6,pwe=.2,s5t=r=>r.text.length*r.size*hwe+(r.text.length-1)*r.size*pwe,l5t=r=>{const e=r.size/8,t=r.size*hwe,n=r.size*pwe,i=[];for(let a=0;a<r.text.length;a++){const o=r.text[a],s=kK[o.toUpperCase()];if(s)for(const{x1:l,y1:c,x2:u,y2:h}of s)i.push({pcb_drawing_type:"line",x1:r.x+(t+n)*a+t*l,y1:r.y+r.size*c,x2:r.x+(t+n)*a+t*u,y2:r.y+r.size*h,width:e,layer:r.layer,unit:r.unit})}return i};function n8(r){return r.is_mouse_over||r.is_in_highlighted_net?s5e(dw[r.layer]).lighten(.5).rgb().toString():dw[r.layer]}var mwe=(r,e)=>{r.equip({size:e.zoomIndependent?e.width/r.transform.a:e.width,shape:e.squareCap?"square":"circle",color:n8(e),layer:e.layer}),r.moveTo(e.x1,e.y1),r.lineTo(e.x2,e.y2)},c5t=(r,e)=>{r.equip({fontSize:e.size,color:e.layer});let t={x:0,y:0};const n=s5t(e),i=e.size;e.align==="top_left"?t.y=-i:e.align==="bottom_right"?t.x=-n:e.align==="top_right"?(t.x=-n,t.y=-i):e.align==="center"&&(t.x=-n/2,t.y=-i/2),e.x??(e.x=0),e.y??(e.y=0);const a={x:e.x,y:e.y};let o=l5t({...e,x:e.x+t.x,y:e.y+t.y});if(e.ccw_rotation){const s={lines:o,anchorPoint:a,ccwRotation:e.ccw_rotation};o=o5t(s)}for(const s of o)mwe(r,s)},u5t=(r,e)=>{r.equip({color:n8(e),layer:e.layer}),r.rect(e.x,e.y,e.w,e.h,e.mesh_fill)},f5t=(r,e)=>{r.equip({color:n8(e),layer:e.layer}),r.rotatedRect(e.x,e.y,e.w,e.h,e.ccw_rotation)},d5t=(r,e)=>{r.equip({color:n8(e),layer:e.layer}),r.circle(e.x,e.y,e.r,e.mesh_fill)},h5t=(r,e)=>{r.equip({color:n8(e),layer:e.layer}),r.oval(e.x,e.y,e.rX,e.rY)},p5t=(r,e)=>{r.equip({color:n8(e),layer:e.layer}),r.pill(e.x,e.y,e.w,e.h)},m5t=(r,e)=>{r.equip({color:n8(e),layer:e.layer}),r.polygon(e.points)},v5t=(r,e)=>{var t;switch(e.pcb_drawing_type){case"line":return mwe(r,e);case"text":return c5t(r,e);case"rect":return((t=e._element)==null?void 0:t.shape)==="rotated_rect"?f5t(r,{...e,ccw_rotation:e._element.ccw_rotation,mesh_fill:e.mesh_fill}):u5t(r,e);case"circle":return d5t(r,e);case"oval":return h5t(r,e);case"pill":return p5t(r,e);case"polygon":return m5t(r,e)}},y5t=(r,e)=>{e.sort((t,n)=>{const i=["bottom","top","drill"];return i.indexOf(t.layer)-i.indexOf(n.layer)}),e.forEach(t=>v5t(r,t))},g5t=({primitives:r,transform:e,grid:t,width:n=500,height:i=500})=>{const a=Tt.useRef(),o=i2(s=>s.selected_layer);return Tt.useEffect(()=>{if(!a.current||Object.keys(a.current).length===0)return;const s=new a5t(a.current);e&&(s.transform=e),s.clear(),s.foregroundLayer=o,y5t(s,r),s.orderAndFadeLayers()},[r,e,o]),gt.jsxs("div",{style:{backgroundColor:"black",width:n,height:i,position:"relative"},children:[gt.jsx(iK.SuperGrid,{textColor:"rgba(0,255,0,0.8)",majorColor:"rgba(0,255,0,0.4)",minorColor:"rgba(0,255,0,0.2)",screenSpaceCellSize:200,width:n,height:i,transform:e,stringifyCoord:(s,l,c)=>`${iK.toMMSI(s,c)}, ${iK.toMMSI(l,c)}`}),sO.map(s=>s.replace(/-/g,"")).concat(["drill","other"]).map((s,l)=>gt.jsx("canvas",{ref:c=>{a.current??(a.current={}),a.current[s]=c},style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:n,height:i},s))]})};function _5t(r,e){if(r.length<2)throw new Error("Stroke must have at least two points");const t=r.map(h=>Array.isArray(h)?{x:h[0],y:h[1]}:h),n=[],i=[];function a(h,g){const _=g.x-h.x,b=g.y-h.y,T=Math.sqrt(_*_+b*b);return{x:-b/T,y:_/T}}function o(h,g,_,b){const T=b/2,C={x:h.x+g.x*T*_,y:h.y+g.y*T*_};_>0?n.push(C):i.unshift(C)}const s=a(t[0],t[1]),l=t[0].trace_width??e;o(t[0],s,1,l),o(t[0],s,-1,l);for(let h=1;h<t.length-1;h++){const g=t[h-1],_=t[h],b=t[h+1],T=a(g,_),C=a(_,b),A=T.x+C.x,L=T.y+C.y,U=Math.sqrt(A*A+L*L),j=_.trace_width??e;if(U/2>2*(j/2))o(_,T,1,j),o(_,C,1,j),o(_,T,-1,j),o(_,C,-1,j);else{const ee=1/U;o(_,{x:A*ee,y:L*ee},1,j),o(_,{x:A*ee,y:L*ee},-1,j)}}const c=a(t[t.length-2],t[t.length-1]),u=t[t.length-1].trace_width??e;return o(t[t.length-1],c,1,u),o(t[t.length-1],c,-1,u),[...n,...i]}var O1=0,x5t=(r,e)=>{var o;const t="pcb_component_id"in r?e.find(s=>s.type==="pcb_component"&&s.pcb_component_id===r.pcb_component_id):void 0,n=t&&"source_component_id"in t?e.find(s=>s.type==="source_component"&&s.source_component_id===t.source_component_id):void 0,i="source_port_id"in r?r.source_port_id:"pcb_port_id"in r?(o=wS(e).pcb_port.get(r.pcb_port_id))==null?void 0:o.source_port_id:void 0,a=i?e.find(s=>s.type==="source_port"&&s.source_port_id===i):void 0;switch(r.type){case"pcb_board":{const{width:s,height:l,center:c,outline:u}=r;return u&&u.length>2?u.map((h,g,_)=>({_pcb_drawing_object_id:`line_${O1++}`,pcb_drawing_type:"line",x1:h.x,y1:h.y,x2:g===_.length-1?_[0].x:_[g+1].x,y2:g===_.length-1?_[0].y:_[g+1].y,width:1,zoomIndependent:!0,layer:"board",_element:r})):[{_pcb_drawing_object_id:`line_${O1++}`,pcb_drawing_type:"line",x1:c.x-s/2,y1:c.y-l/2,x2:c.x+s/2,y2:c.y-l/2,width:1,zoomIndependent:!0,layer:"board",_element:r},{_pcb_drawing_object_id:`line_${O1++}`,pcb_drawing_type:"line",x1:c.x-s/2,y1:c.y+l/2,x2:c.x+s/2,y2:c.y+l/2,width:1,zoomIndependent:!0,layer:"board",_element:r},{_pcb_drawing_object_id:`line_${O1++}`,pcb_drawing_type:"line",x1:c.x-s/2,y1:c.y-l/2,x2:c.x-s/2,y2:c.y+l/2,width:1,zoomIndependent:!0,layer:"board",_element:r},{_pcb_drawing_object_id:`line_${O1++}`,pcb_drawing_type:"line",x1:c.x+s/2,y1:c.y-l/2,x2:c.x+s/2,y2:c.y+l/2,width:1,zoomIndependent:!0,layer:"board",_element:r}]}case"pcb_smtpad":{if(r.shape==="rect"||r.shape==="rotated_rect"){const{shape:s,x:l,y:c,width:u,height:h,layer:g}=r;return[{_pcb_drawing_object_id:`rect_${O1++}`,pcb_drawing_type:"rect",x:l,y:c,w:u,h,layer:g||"top",_element:r,_parent_pcb_component:t,_parent_source_component:n,_source_port:a}]}else if(r.shape==="circle"){const{x:s,y:l,radius:c,layer:u}=r;return[{_pcb_drawing_object_id:`circle_${O1++}`,pcb_drawing_type:"circle",x:s,y:l,r:c,layer:u||"top",_element:r,_parent_pcb_component:t,_parent_source_component:n,_source_port:a}]}return[]}case"pcb_hole":{if(r.hole_shape==="circle"||!r.hole_shape){const{x:s,y:l,hole_diameter:c}=r;return[{_pcb_drawing_object_id:`circle_${O1++}`,pcb_drawing_type:"circle",x:s,y:l,r:c/2,layer:"drill",_element:r,_parent_pcb_component:t,_parent_source_component:n}]}return[]}case"pcb_plated_hole":if(r.shape==="circle"){const{x:s,y:l,hole_diameter:c,outer_diameter:u}=r;return[{_pcb_drawing_object_id:`circle_${O1++}`,pcb_drawing_type:"circle",x:s,y:l,r:u/2,layer:"top",_element:r,_parent_pcb_component:t,_parent_source_component:n,_source_port:a},{_pcb_drawing_object_id:`circle_${O1++}`,pcb_drawing_type:"circle",x:s,y:l,r:c/2,layer:"drill",_element:r}]}else if(r.shape==="oval"){const{x:s,y:l,outer_height:c,outer_width:u,hole_height:h,hole_width:g}=r;return[{_pcb_drawing_object_id:`oval_${O1++}`,pcb_drawing_type:"oval",x:s,y:l,rX:u/2,rY:c/2,layer:"top",_element:r,_parent_pcb_component:t,_parent_source_component:n,_source_port:a},{_pcb_drawing_object_id:`oval_${O1++}`,_element:r,pcb_drawing_type:"oval",x:s,y:l,rX:g/2,rY:h/2,layer:"drill"}]}else if(r.shape==="pill"){const{x:s,y:l,outer_height:c,outer_width:u,hole_height:h,hole_width:g}=r;return[{_pcb_drawing_object_id:`pill_${O1++}`,pcb_drawing_type:"pill",x:s,y:l,w:u,h:c,layer:"top",_element:r,_parent_pcb_component:t,_parent_source_component:n,_source_port:a},{_pcb_drawing_object_id:`pill_${O1++}`,_element:r,pcb_drawing_type:"pill",x:s,y:l,w:g,h,layer:"drill"}]}else return[];case"pcb_keepout":if(r.shape==="circle"){const{center:s,radius:l}=r;return[{_pcb_drawing_object_id:`circle_${O1++}`,pcb_drawing_type:"circle",x:s.x,y:s.y,r:l,layer:"top",_element:r,_parent_pcb_component:t,_parent_source_component:n,mesh_fill:!0}]}else if(r.shape==="rect"){const{x:s,y:l,width:c,height:u}=r;return[{_pcb_drawing_object_id:`rect_${O1++}`,pcb_drawing_type:"rect",x:s,y:l,w:c,h:u,layer:"top",_element:r,_parent_pcb_component:t,_parent_source_component:n,mesh_fill:!0}]}case"pcb_trace":{const s=[];if(r.route_thickness_mode==="interpolated"){const u=r.route.map(g=>({x:g.x,y:g.y,trace_width:g.route_type==="wire"?g.width:.5})),h=_5t(u,.5);return s.push({_pcb_drawing_object_id:`polygon_${O1++}`,_element:r,pcb_drawing_type:"polygon",points:h,layer:r.route[0].layer}),r.route.forEach(g=>{g.route_type==="via"&&s.push({_pcb_drawing_object_id:`circle_${O1++}`,_element:r,pcb_drawing_type:"circle",x:g.x,y:g.y,radius:g.outer_diameter/2,fill:!0,layer:r.route.layer})}),s}let l=null,c=null;for(const u of r.route)u.route_type==="wire"&&(l!==null&&c!==null&&s.push({_pcb_drawing_object_id:`line_${O1++}`,_element:r,pcb_drawing_type:"line",x1:l,y1:c,x2:u.x,y2:u.y,width:u.width,squareCap:!1,layer:u.layer}),l=u.x,c=u.y);return s}case"pcb_via":{const{x:s,y:l,outer_diameter:c,hole_diameter:u,from_layer:h,to_layer:g}=r;return[{_pcb_drawing_object_id:`circle_${O1++}`,pcb_drawing_type:"circle",x:s,y:l,r:c/2,layer:h,_element:r,_parent_pcb_component:t,_parent_source_component:n},{_pcb_drawing_object_id:`circle_${O1++}`,_element:r,pcb_drawing_type:"circle",x:s,y:l,r:u/2,layer:"drill",_parent_pcb_component:t,_parent_source_component:n},{_pcb_drawing_object_id:`circle_${O1++}`,pcb_drawing_type:"circle",x:s,y:l,r:c/2,layer:g,_element:r,_parent_pcb_component:t,_parent_source_component:n}]}case"pcb_silkscreen_rect":return[{_pcb_drawing_object_id:`rect_${O1++}`,pcb_drawing_type:"rect",x:r.center.x,y:r.center.y,w:r.width,h:r.height,layer:r.layer==="bottom"?"bottom_silkscreen":"top_silkscreen"}];case"pcb_silkscreen_circle":return[{_pcb_drawing_object_id:`circle_${O1++}`,pcb_drawing_type:"circle",x:r.center.x,y:r.center.y,r:r.radius,layer:r.layer==="bottom"?"bottom_silkscreen":"top_silkscreen"}];case"pcb_silkscreen_oval":return[{_pcb_drawing_object_id:`oval_${O1++}`,pcb_drawing_type:"oval",x:r.center.x,y:r.center.y,rX:r.radius_x/2,rY:r.radius_y/2,layer:r.layer==="bottom"?"bottom_silkscreen":"top_silkscreen"}];case"pcb_silkscreen_pill":return[{_pcb_drawing_object_id:`pill_${O1++}`,pcb_drawing_type:"pill",x:r.center.x,y:r.center.y,w:r.width,h:r.height,layer:r.layer==="bottom"?"bottom_silkscreen":"top_silkscreen"}];case"pcb_silkscreen_line":return[{_pcb_drawing_object_id:`line_${O1++}`,pcb_drawing_type:"line",x1:r.x1,y1:r.y1,x2:r.x2,y2:r.y2,width:.1,squareCap:!1,layer:r.layer==="bottom"?"bottom_silkscreen":"top_silkscreen"}];case"pcb_fabrication_note_path":case"pcb_silkscreen_path":{const{pcb_component_id:s,route:l,type:c}=r;let u;return c==="pcb_silkscreen_path"?u=r.layer==="bottom"?"bottom_silkscreen":"top_silkscreen":c==="pcb_fabrication_note_path"&&(u="top_fabrication"),l.slice(0,-1).map((h,g)=>{const _=l[g+1];return{_pcb_drawing_object_id:`line_${O1++}`,pcb_drawing_type:"line",x1:h.x,y1:h.y,x2:_.x,y2:_.y,width:r.stroke_width??.1,squareCap:!1,layer:u,_element:r,_parent_pcb_component:t,_parent_source_component:n,_source_port:a}}).filter(Boolean)}case"pcb_silkscreen_text":return[{_pcb_drawing_object_id:`text_${O1++}`,pcb_drawing_type:"text",x:r.anchor_position.x,y:r.anchor_position.y,layer:r.layer==="bottom"?"bottom_silkscreen":"top_silkscreen",align:r.anchor_alignment??"center",text:r.text,size:r.font_size,ccw_rotation:r.ccw_rotation}];case"pcb_fabrication_note_text":return[{_pcb_drawing_object_id:`text_${O1++}`,pcb_drawing_type:"text",x:r.anchor_position.x,y:r.anchor_position.y,layer:r.layer==="bottom"?"bottom_fabrication":"top_fabrication",size:r.font_size,align:r.anchor_alignment??"center",text:r.text}]}return[]};function b5t({primitiveElement:r,elements:e}){let t=r.trace_length?`${r.trace_length.toFixed(3)}`:"";const n=wS(e).source_trace.get(r==null?void 0:r.source_trace_id);if(n!=null&&n.display_name&&(n!=null&&n.max_length?t+=` / ${n.max_length}mm `:t+=" mm ",t+=`(${n.display_name})`),!t)return null;const i=r.trace_length&&(n==null?void 0:n.max_length)&&r.trace_length>n.max_length;return{text:t,isOverLength:i}}function S5t(r){const{primitives:e,is_showing_multiple_traces_length:t,elements:n}=r,i=e.filter(l=>l._element.type==="pcb_trace"),a=n.filter(l=>l.type==="source_trace"),o=e.filter(l=>l._element.type!=="pcb_trace"),s=i.filter(l=>a.some(c=>l._element.type==="pcb_trace"&&l._element.source_trace_id===c.source_trace_id&&c.max_length!==void 0));if(!t)return[...o,...s];if(i.length>1){const l=i.reduce((c,u)=>{const h=c._element.trace_length;return u._element.trace_length<h?u:c},i[0]);return[...o,l]}return e}var E5t={position:"absolute",left:0,top:0,pointerEvents:"none",color:"red",fontFamily:"sans-serif",fontSize:12,textShadow:"0 0 2px black"},w5t=r=>{const{_element:e,_parent_pcb_component:t,_parent_source_component:n,_source_port:i}=r;switch(e.type){case"pcb_trace":return e.trace_length?`${e.trace_length.toFixed(3)}`:"";case"pcb_smtpad":case"pcb_plated_hole":{let a="";n&&"name"in n&&n.name&&(a+=`.${n.name} > `);const o=Array.from(new Set((e.port_hints??[]).concat((i==null?void 0:i.port_hints)??[]))).sort((s,l)=>l.localeCompare(s));return a+=o.map(s=>s.match(/^[0-9]+$/)?`port.${s}`:`.${s}`).join(", "),a}default:return""}},T5t={top:"red",bottom:"aqua"},M5t=({primitive:r,mousePos:e,elements:t})=>{var b;const[n,i]=Tt.useState(!1),a=r._element;Tt.useEffect(()=>{setTimeout(()=>{i(!0)},100)},[]);let[o,s,l,c]=[r.screen_x,r.screen_y,r.screen_w,r.screen_h];const u=r.same_space_index??0,h=26,g=T5t[(b=r==null?void 0:r._element)==null?void 0:b.layer]??"red";let _=0;if(a.type==="pcb_smtpad"&&(a==null?void 0:a.shape)==="rotated_rect"&&(_=a==null?void 0:a.ccw_rotation),a.type==="pcb_trace"){const C=b5t({primitiveElement:a,elements:t});if(!C)return null;const A=e.y-35;return gt.jsx("div",{style:{zIndex:ub.elementOverlay,position:"absolute",left:e.x,top:A,color:g,pointerEvents:"none",transform:"translateX(-50%)"},children:gt.jsx("div",{style:{backgroundColor:"#f2efcc",color:C.isOverLength?"red":"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",minWidth:"45px",textAlign:"center",whiteSpace:"nowrap"},children:C.text})})}return gt.jsx("div",{style:{zIndex:ub.elementOverlay,position:"absolute",left:o-l/2-8,top:s-c/2-8,width:l+16,height:c+16,color:g,transform:`rotate(${-_}deg)`,transformOrigin:"center center"},children:gt.jsx("div",{style:{width:n?`calc(100% + ${h*2*u}px)`:"100%",height:n?`calc(100% + ${h*2*u}px)`:"100%",marginLeft:n?`${-h*u}px`:0,marginTop:n?`${-h*u}px`:0,border:`1px solid ${g}`,opacity:n||u===0?1:0,transition:"width 0.2s, height 0.2s, margin-left 0.2s, margin-top 0.2s, opacity 0.2s"},children:gt.jsx("div",{style:{position:"absolute",bottom:c+20+h*u,marginRight:n?`${-h*u}px`:0,marginBottom:n?0:-h*u,transition:"margin-right 0.2s, margin-bottom 0.2s",backgroundColor:"#f2efcc",color:"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",transform:`rotate(${_}deg)`,minWidth:"45px",textAlign:"center"},children:w5t(r)})})})},C5t=({highlightedPrimitives:r,mousePos:e,elements:t})=>{const[n,i]=i2(s=>[s.is_moving_component,s.is_showing_multiple_traces_length]),a=r.some(s=>s._element.type==="pcb_smtpad")&&r.some(s=>s._element.type==="pcb_trace");let o=r;return a&&(o=o.filter(s=>s._element.type==="pcb_smtpad")),o=S5t({primitives:o,is_showing_multiple_traces_length:i,elements:t}),gt.jsx("div",{style:E5t,children:!n&&o.map((s,l)=>gt.jsx(M5t,{primitive:s,mousePos:e,elements:t},l))})};function R5t(r,e){return r.size!==e.size?!1:Array.from(r).every(t=>e.has(t))}var A5t=({elements:r,children:e,transform:t,primitives:n,onMouseHoverOverPrimitives:i})=>{const[a,o]=Tt.useState([]),[s,l]=Tt.useState({x:0,y:0}),c=Tt.useMemo(()=>{var h,g;const u=[];for(const _ of a){if(((h=_._element)==null?void 0:h.type)==="pcb_via"||((g=_._element)==null?void 0:g.type)==="pcb_component"||(_==null?void 0:_.layer)==="drill")continue;const b=ui(t,_),T="w"in _?_.w:"r"in _?_.r*2:0,C="h"in _?_.h:"r"in _?_.r*2:0,A={w:T*t.a,h:C*t.a},L=u.filter(U=>b.x===U.screen_x&&b.y===U.screen_y&&A.w===U.screen_w&&A.h===U.screen_h).length;u.push({..._,screen_x:b.x,screen_y:b.y,screen_w:A.w,screen_h:A.h,same_space_index:L})}return u},[a,t]);return gt.jsxs("div",{style:{position:"relative"},onMouseMove:u=>{var h;if(t){const g=u.currentTarget.getBoundingClientRect(),_=u.clientX-g.left,b=u.clientY-g.top;l({x:_,y:b});const T=ui(Tb(t),{x:_,y:b}),C=[];for(const A of n){if(!A._element)continue;if("x1"in A&&((h=A._element)==null?void 0:h.type)==="pcb_trace"){const j=_9t({x:T.x,y:T.y},{x:A.x1,y:A.y1},{x:A.x2,y:A.y2}),Z=A.width||.5,ee=Math.max(Z*25,2)/t.a;j<ee&&C.push(A);continue}if(!("x"in A&&"y"in A))continue;let L=0,U=0;if("w"in A&&"h"in A)L=A.w,U=A.h;else if("r"in A)L=A.r*2,U=A.r*2;else continue;Math.abs(A.x-T.x)<L/2&&Math.abs(A.y-T.y)<U/2&&C.push(A)}if(R5t(new Set(C.map(A=>A._pcb_drawing_object_id)),new Set(a.map(A=>A._pcb_drawing_object_id))))return;o(C),i(C)}},children:[e,gt.jsx(C5t,{elements:r,mousePos:s,highlightedPrimitives:c})]})},D5t=({children:r,transform:e,focusOnHover:t=!1})=>{e||(e=C_());const[n,i]=Tt.useState(!1),[a,o]=Tt.useState(!1),[s,l]=Tt.useState({x:0,y:0}),[c,u]=Tt.useState({x:0,y:0}),h=Tt.useRef({x:0,y:0}),g=Tt.useRef(null),_=g.current,b=_==null?void 0:_.getBoundingClientRect();Tt.useEffect(()=>{const L=g.current,U=ee=>{ee.key==="d"&&(l({x:h.current.x,y:h.current.y}),u({x:h.current.x,y:h.current.y}),i($=>!$),o(!0),ee.preventDefault()),ee.key==="Escape"&&(i(!1),o(!1))},j=()=>{L&&L.addEventListener("keydown",U)},Z=()=>{L&&L.removeEventListener("keydown",U)};return L&&(L.addEventListener("focus",j),L.addEventListener("blur",Z),L.addEventListener("mouseenter",j),L.addEventListener("mouseleave",Z)),()=>{L&&(L.removeEventListener("focus",j),L.removeEventListener("blur",Z),L.removeEventListener("mouseenter",j),L.removeEventListener("mouseleave",Z))}},[g]);const T=ui(e,s),C=ui(e,c),A={left:Math.min(T.x,C.x),right:Math.max(T.x,C.x),top:Math.min(T.y,C.y),bottom:Math.max(T.y,C.y),flipX:T.x>C.x,flipY:T.y>C.y,width:0,height:0};return A.width=A.right-A.left,A.height=A.bottom-A.top,gt.jsxs("div",{ref:g,tabIndex:0,style:{position:"relative"},onMouseEnter:()=>{t&&g.current&&g.current.focus()},onMouseLeave:()=>{g.current&&g.current.blur()},onMouseMove:L=>{const U=L.currentTarget.getBoundingClientRect(),j=L.clientX-U.left,Z=L.clientY-U.top,ee=ui(Tb(e),{x:j,y:Z});h.current.x=ee.x,h.current.y=ee.y,a&&u({x:ee.x,y:ee.y})},onMouseDown:()=>{a?o(!1):n&&i(!1)},children:[r,n&>.jsxs(gt.Fragment,{children:[gt.jsx("div",{style:{position:"absolute",left:A.left,width:A.width,textAlign:"center",top:T.y+2,color:"red",mixBlendMode:"difference",pointerEvents:"none",marginTop:A.flipY?0:-20,fontSize:12,fontFamily:"sans-serif",zIndex:ub.dimensionOverlay},children:Math.abs(s.x-c.x).toFixed(2)}),gt.jsx("div",{style:{position:"absolute",left:C.x,height:A.height,display:"flex",flexDirection:"column",justifyContent:"center",top:A.top,color:"red",pointerEvents:"none",mixBlendMode:"difference",fontSize:12,fontFamily:"sans-serif",zIndex:ub.dimensionOverlay},children:gt.jsx("div",{style:{marginLeft:A.flipX?"-100%":4,paddingRight:4},children:Math.abs(s.y-c.y).toFixed(2)})}),gt.jsxs("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:ub.dimensionOverlay},width:b.width,height:b.height,children:[gt.jsx("defs",{children:gt.jsx("marker",{id:"head",orient:"auto",markerWidth:"3",markerHeight:"4",refX:"2",refY:"2",children:gt.jsx("path",{d:"M0,0 V4 L2,2 Z",fill:"red"})})}),gt.jsx("line",{x1:T.x,y1:T.y,x2:C.x,y2:C.y,markerEnd:"url(#head)",strokeWidth:1.5,fill:"none",stroke:"red"}),gt.jsx("line",{x1:T.x,y1:T.y,x2:C.x,y2:T.y,strokeWidth:1.5,fill:"none",strokeDasharray:"2,2",stroke:"red"}),gt.jsx("line",{x1:C.x,y1:T.y,x2:C.x,y2:C.y,strokeWidth:1.5,fill:"none",strokeDasharray:"2,2",stroke:"red"})]}),gt.jsxs("div",{style:{right:0,bottom:0,position:"absolute",color:"red",fontFamily:"sans-serif",fontSize:12,margin:4},children:["(",s.x.toFixed(2),",",s.y.toFixed(2),")",gt.jsx("br",{}),"(",c.x.toFixed(2),",",c.y.toFixed(2),")",gt.jsx("br",{}),"dist:"," ",Math.sqrt((c.x-s.x)**2+(c.y-s.y)**2).toFixed(2)]})]})]})},P5t={name:"@tscircuit/pcb-viewer",version:"1.11.45",main:"dist/index.js",type:"module",repository:"tscircuit/pcb-viewer",license:"MIT",scripts:{start:"storybook dev -p 6006",build:"tsup ./src/index.tsx --platform browser --dts --sourcemap --format esm --outDir dist",yalc:"npm run build && yalc push",storybook:"storybook dev -p 6006","build-storybook":"storybook build",format:"biome format . --write","format:check":"biome format ."},files:["dist"],devDependencies:{"@biomejs/biome":"^1.9.4","@semantic-release/commit-analyzer":"^9.0.2","@semantic-release/git":"^10.0.1","@semantic-release/npm":"^9.0.1","@semantic-release/release-notes-generator":"^10.0.3","@storybook/nextjs":"^8.0.6","@storybook/react":"^8.0.6","@swc/core":"^1.4.12","@tscircuit/core":"0.0.274","@tscircuit/eagle-xml-converter":"^1.0.0","@tscircuit/props":"^0.0.151","@tscircuit/soup-util":"^0.0.41","@types/color":"^3.0.6","@types/node":"18.7.23","@types/react":"^18.3.3","circuit-json":"^0.0.128",next:"^14.1.4","pixi.js":"^8.6.6",react:"^18.2.0","react-dom":"^18.2.0","react-use":"^17.4.0",storybook:"^8.0.6",tsup:"^8.0.2","type-fest":"^3.0.0",typescript:"^5.4.4","use-mouse-matrix-transform":"^1.3.0",zod:"^3.23.5"},peerDependencies:{react:"*","@tscircuit/core":"*"},dependencies:{"@emotion/css":"^11.11.2","circuit-json-to-connectivity-map":"^0.0.18","@tscircuit/math-utils":"^0.0.10","circuit-to-svg":"^0.0.36",color:"^4.2.3","react-supergrid":"^1.0.10","react-toastify":"^10.0.5","transformation-matrix":"^2.13.0",zustand:"^4.5.2"}},TS=(r,e)=>{const t=i2(n=>n.is_mouse_over_container);Tt.useEffect(()=>{if(!r||typeof e!="function")return;const n=i=>{const a=r.split("+"),o=a.includes("ctrl"),s=a.includes("shift"),l=a.includes("alt"),c=a.includes("meta"),u=a[a.length-1];t&&(!o||i.ctrlKey)&&(!s||i.shiftKey)&&(!l||i.altKey)&&(!c||i.metaKey)&&i.key.toLowerCase()===u.toLowerCase()&&(i.preventDefault(),e())};return window.addEventListener("keydown",n),()=>{window.removeEventListener("keydown",n)}},[r,e])},N5t=({name:r,selected:e,onClick:t})=>gt.jsxs("div",{className:iw`
|
|
12845
12845
|
margin-top: 2px;
|
|
12846
12846
|
padding: 4px;
|