@tscircuit/runframe 0.0.997 → 0.0.999

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.
@@ -5080,7 +5080,7 @@ ${c.join(`
5080
5080
  ${y}polygon: ${m.polygon.vertices}
5081
5081
  `:c+=`
5082
5082
  `,m.children.length>0&&u.push(m.children)}return c}};e.exports=s}}),_rn=ft({"node_modules/@jscad/modeling/src/operations/booleans/trees/Tree.js"(t,e){var n=hrn(),i=mrn(),r=class{constructor(o){this.polygonTree=new i,this.rootnode=new n(null),o&&this.addPolygons(o)}invert(){this.polygonTree.invert(),this.rootnode.invert()}clipTo(o,s=!1){this.rootnode.clipTo(o,s)}allPolygons(){const o=[];return this.polygonTree.getPolygons(o),o}addPolygons(o){const s=new Array(o.length);for(let a=0;a<o.length;a++)s[a]=this.polygonTree.addChild(o[a]);this.rootnode.addPolygonTreeNodes(s)}clear(){this.polygonTree.clear()}toString(){return"Tree: "+this.polygonTree.toString("")}};e.exports=r}}),o0e=ft({"node_modules/@jscad/modeling/src/operations/booleans/trees/index.js"(t,e){e.exports={Tree:_rn()}}}),yrn=ft({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3Sub.js"(t,e){var n=ja(),i=r0e(),{Tree:r}=o0e(),o=(s,a)=>{if(!i(s,a))return n.create();const c=new r(n.toPolygons(s)),l=new r(n.toPolygons(a));c.invert(),l.clipTo(c),l.invert(),c.clipTo(l),l.clipTo(c),c.addPolygons(l.allPolygons()),c.invert();const u=c.allPolygons();return n.create(u)};e.exports=o}}),TYe=ft({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3.js"(t,e){var n=Ma(),i=MI(),r=yrn(),o=(...s)=>{s=n(s);let a=s.shift();return s.forEach(c=>{a=r(a,c)}),a=i(a),a};e.exports=o}}),grn=ft({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom2.js"(t,e){var n=Ma(),i=ja(),r=G4(),o=n0e(),s=i0e(),a=TYe(),c=(...l)=>{l=n(l);const u=l.map(f=>s({z0:-1,z1:1},f)),d=a(u),h=r(d);return o(h,i.toPolygons(d))};e.exports=c}}),brn=ft({"node_modules/@jscad/modeling/src/operations/booleans/intersect.js"(t,e){var n=Ma(),i=TI(),r=$a(),o=ja(),s=grn(),a=TYe(),c=(...l)=>{if(l=n(l),l.length===0)throw new Error("wrong number of arguments");if(!i(l))throw new Error("only intersect of the types are supported");const u=l[0];return r.isA(u)?s(l):o.isA(u)?a(l):u};e.exports=c}}),xrn=ft({"node_modules/@jscad/modeling/src/operations/booleans/scissionGeom3.js"(t,e){var n=Go(),i=G4(),r=ja(),o=l=>l.sort((u,d)=>u-d).filter((u,d,h)=>!d||u!==h[d-1]),s=(l,u,d)=>{const h=`${u}`,f=l.get(h);f===void 0?l.set(h,[d]):f.push(d)},a=(l,u)=>{const d=`${u}`;return l.get(d)},c=l=>{const u=i(l),d=r.toPolygons(l),h=d.length,f=new Map,m=n.create();d.forEach((w,T)=>{w.vertices.forEach(N=>{s(f,n.snap(m,N,u),T)})});const y=d.map(w=>{let T=[];return w.vertices.forEach(N=>{T=T.concat(a(f,n.snap(m,N,u)))}),{e:1,d:o(T)}});f.clear();let g=0;const b=y.length;for(let w=0;w<b;w++){const T=y[w];if(T.e>0){const N=new Array(h);N[w]=!0;do g=0,N.forEach((R,P)=>{const M=y[P];if(M.e>0){M.e=-1;for(let I=0;I<M.d.length;I++)N[M.d[I]]=!0;g++}});while(g>0);T.indexes=N}}const v=[];for(let w=0;w<b;w++)if(y[w].indexes){const T=[];y[w].indexes.forEach((N,R)=>T.push(d[R])),v.push(r.create(T))}return v};e.exports=c}}),vrn=ft({"node_modules/@jscad/modeling/src/operations/booleans/scission.js"(t,e){var n=Ma(),i=ja(),r=xrn(),o=(...s)=>{if(s=n(s),s.length===0)throw new Error("wrong number of arguments");const a=s.map(c=>i.isA(c)?r(c):c);return a.length===1?a[0]:a};e.exports=o}}),wrn=ft({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3Sub.js"(t,e){var n=ja(),i=r0e(),{Tree:r}=o0e(),o=(s,a)=>{if(!i(s,a))return n.clone(s);const c=new r(n.toPolygons(s)),l=new r(n.toPolygons(a));c.invert(),c.clipTo(l),l.clipTo(c,!0),c.addPolygons(l.allPolygons()),c.invert();const u=c.allPolygons();return n.create(u)};e.exports=o}}),MYe=ft({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3.js"(t,e){var n=Ma(),i=MI(),r=wrn(),o=(...s)=>{s=n(s);let a=s.shift();return s.forEach(c=>{a=r(a,c)}),a=i(a),a};e.exports=o}}),Srn=ft({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom2.js"(t,e){var n=Ma(),i=ja(),r=G4(),o=n0e(),s=i0e(),a=MYe(),c=(...l)=>{l=n(l);const u=l.map(f=>s({z0:-1,z1:1},f)),d=a(u),h=r(d);return o(h,i.toPolygons(d))};e.exports=c}}),Ern=ft({"node_modules/@jscad/modeling/src/operations/booleans/subtract.js"(t,e){var n=Ma(),i=TI(),r=$a(),o=ja(),s=Srn(),a=MYe(),c=(...l)=>{if(l=n(l),l.length===0)throw new Error("wrong number of arguments");if(!i(l))throw new Error("only subtract of the types are supported");const u=l[0];return r.isA(u)?s(l):o.isA(u)?a(l):u};e.exports=c}}),AYe=ft({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3Sub.js"(t,e){var n=ja(),i=r0e(),{Tree:r}=o0e(),o=(a,c)=>{if(!i(a,c))return s(a,c);const l=new r(n.toPolygons(a)),u=new r(n.toPolygons(c));l.clipTo(u,!1),u.clipTo(l),u.invert(),u.clipTo(l),u.invert();const d=l.allPolygons().concat(u.allPolygons());return n.create(d)},s=(a,c)=>{let l=n.toPolygons(a);return l=l.concat(n.toPolygons(c)),n.create(l)};e.exports=o}}),CYe=ft({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3.js"(t,e){var n=Ma(),i=MI(),r=AYe(),o=(...s)=>{s=n(s);let a;for(a=1;a<s.length;a+=2)s.push(r(s[a-1],s[a]));let c=s[a-1];return c=i(c),c};e.exports=o}}),RYe=ft({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom2.js"(t,e){var n=Ma(),i=ja(),r=G4(),o=n0e(),s=i0e(),a=CYe(),c=(...l)=>{l=n(l);const u=l.map(f=>s({z0:-1,z1:1},f)),d=a(u),h=r(d);return o(h,i.toPolygons(d))};e.exports=c}}),s0e=ft({"node_modules/@jscad/modeling/src/operations/booleans/union.js"(t,e){var n=Ma(),i=TI(),r=$a(),o=ja(),s=RYe(),a=CYe(),c=(...l)=>{if(l=n(l),l.length===0)throw new Error("wrong number of arguments");if(!i(l))throw new Error("only unions of the same type are supported");const u=l[0];return r.isA(u)?s(l):o.isA(u)?a(l):u};e.exports=c}}),Y$=ft({"node_modules/@jscad/modeling/src/operations/booleans/index.js"(t,e){e.exports={intersect:brn(),scission:vrn(),subtract:Ern(),union:s0e()}}}),q$=ft({"node_modules/@jscad/modeling/src/operations/expansions/offsetFromPoints.js"(t,e){var{EPS:n,TAU:i}=su(),r=rYe(),o=Zfe(),s=_c(),a=H$(),c=(l,u)=>{const d={delta:1,corners:"edge",closed:!1,segments:16};let{delta:h,corners:f,closed:m,segments:y}=Object.assign({},d,l);if(Math.abs(h)<n)return u;let g=l.closed?a(u):1;g===0&&(g=1);const b=g>0&&h>=0||g<0&&h<0;h=Math.abs(h);let v=null,w=[];const T=[],N=s.create(),R=u.length;for(let P=0;P<R;P++){const M=(P+1)%R,I=u[P],A=u[M];b?s.subtract(N,I,A):s.subtract(N,A,I),s.normal(N,N),s.normalize(N,N),s.scale(N,N,h);const $=s.add(s.create(),I,N),k=s.add(s.create(),A,N),V=[$,k];if(v!=null&&(m||!m&&M!==0)){const X=r(v[0],v[1],V[0],V[1]);X?(w.pop(),V[0]=X):T.push({c:I,s0:v,s1:V})}v=[$,k],!(M===0&&!m)&&(w.push(V[0]),w.push(V[1]))}if(m&&v!=null){const P=w[0],M=w[1],I=r(v[0],v[1],P,M);if(I)w[0]=I,w.pop();else{const A=u[0],$=[P,M];T.push({c:A,s0:v,s1:$})}}if(f==="edge"){const P=new Map;w.forEach((A,$)=>P.set(A,$));const M=o.create(),I=o.create();T.forEach(A=>{o.fromPoints(M,A.s0[0],A.s0[1]),o.fromPoints(I,A.s1[0],A.s1[1]);const $=o.intersectPointOfLines(M,I);if(Number.isFinite($[0])&&Number.isFinite($[1])){const k=A.s0[1],V=P.get(k);w[V]=$,w[(V+1)%w.length]=void 0}else{const k=A.s1[0],V=P.get(k);w[V]=void 0}}),w=w.filter(A=>A!==void 0)}if(f==="round"){let P=Math.floor(y/4);const M=s.create();T.forEach(I=>{let A=s.angle(s.subtract(M,I.s1[0],I.c));if(A-=s.angle(s.subtract(M,I.s0[1],I.c)),b&&A<0&&(A=A+Math.PI,A<0&&(A=A+Math.PI)),!b&&A>0&&(A=A-Math.PI,A>0&&(A=A-Math.PI)),A!==0){P=Math.floor(y*(Math.abs(A)/i));const $=A/P,k=s.angle(s.subtract(M,I.s0[1],I.c)),V=[];for(let X=1;X<P;X++){const W=k+$*X,K=s.fromAngleRadians(s.create(),W);s.scale(K,K,h),s.add(K,K,I.c),V.push(K)}if(V.length>0){const X=I.s0[1];let W=w.findIndex(K=>s.equals(X,K));W=(W+1)%w.length,w.splice(W,0,...V)}}else{const $=I.s1[0],k=w.findIndex(V=>s.equals($,V));w.splice(k,1)}})}return w};e.exports=c}}),Trn=ft({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom2.js"(t,e){var n=$a(),i=q$(),r=(o,s)=>{const a={delta:1,corners:"edge",segments:16},{delta:c,corners:l,segments:u}=Object.assign({},a,o);if(!(l==="edge"||l==="chamfer"||l==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const f=n.toOutlines(s).map(m=>(o={delta:c,corners:l,closed:!0,segments:u},i(o,m))).reduce((m,y)=>m.concat(n.toSides(n.fromPoints(y))),[]);return n.create(f)};e.exports=r}}),Mrn=ft({"node_modules/@jscad/modeling/src/operations/expansions/extrudePolygon.js"(t,e){var n=Af(),i=Go(),r=ja(),o=Bl(),s=(a,c)=>{i.dot(o.plane(c),a)>0&&(c=o.invert(c));const u=[c],d=o.transform(n.fromTranslation(n.create(),a),c),h=c.vertices.length;for(let f=0;f<h;f++){const m=f<h-1?f+1:0,y=o.create([c.vertices[f],d.vertices[f],d.vertices[m],c.vertices[m]]);u.push(y)}return u.push(o.invert(d)),r.create(u)};e.exports=s}}),Arn=ft({"node_modules/@jscad/modeling/src/operations/expansions/expandShell.js"(t,e){var{EPS:n,TAU:i}=su(),r=Af(),o=Go(),s=SYe(),a=ja(),c=Bl(),l=_Ye(),u=MI(),d=AYe(),h=Mrn(),f=(b,v,w)=>{const T=v.toString();if(b.has(T))b.get(T)[1].push(w);else{const N=[v,[w]];b.set(T,N)}},m=(b,v,w)=>{const T=v[0].toString(),N=v[1].toString(),R=T<N?`${T},${N}`:`${N},${T}`;if(b.has(R))b.get(R)[1].push(w);else{const P=[v,[w]];b.set(R,P)}},y=(b,v)=>{b.findIndex(T=>T===v)<0&&b.push(v)},g=(b,v)=>{const w={delta:1,segments:12},{delta:T,segments:N}=Object.assign({},w,b);let R=a.create();const P=new Map,M=new Map,I=o.create(),A=o.create();return a.toPolygons(v).forEach((k,V)=>{const X=o.scale(o.create(),c.plane(k),2*T),W=c.transform(r.fromTranslation(r.create(),o.scale(o.create(),X,-.5)),k),K=h(X,W);R=d(R,K);const te=k.vertices;for(let se=0;se<te.length;se++){f(P,te[se],c.plane(k));const de=(se+1)%te.length,be=[te[se],te[de]];m(M,be,c.plane(k))}}),M.forEach(k=>{const V=k[0],X=k[1],W=V[0],K=V[1],te=o.subtract(o.create(),K,W);o.normalize(te,te);const se=X[0],de=o.cross(o.create(),se,te);let be=[];for(let ke=0;ke<N;ke++)y(be,ke*i/N);for(let ke=0,ce=X.length;ke<ce;ke++){const we=X[ke],xe=o.dot(de,we),Ye=o.dot(se,we);let Je=Math.atan2(xe,Ye);Je<0&&(Je+=i),y(be,Je),Je=Math.atan2(-xe,-Ye),Je<0&&(Je+=i),y(be,Je)}be=be.sort(s);const re=be.length;let ue,he;const Me=[],Ie=[],De=[];for(let ke=-1;ke<re;ke++){const ce=be[ke<0?ke+re:ke],we=Math.sin(ce),xe=Math.cos(ce);o.scale(I,se,xe*T),o.scale(A,de,we*T),o.add(I,I,A);const Ye=o.add(o.create(),W,I),Je=o.add(o.create(),K,I);let st=!1;if(ke>=0&&o.distance(Ye,ue)<n&&(st=!0),!st){if(ke>=0){Me.push(Ye),Ie.push(Je);const Se=[he,Je,Ye,ue],ut=c.create(Se);De.push(ut)}ue=Ye,he=Je}}Ie.reverse(),De.push(c.create(Me)),De.push(c.create(Ie));const Ge=a.create(De);R=d(R,Ge)}),P.forEach(k=>{const V=k[0],X=k[1],W=X[0];let K=null,te=0;for(let re=1;re<X.length;re++){const ue=X[re],he=o.cross(I,W,ue),Me=o.length(he);Me>.05&&Me>te&&(te=Me,K=ue)}K||(K=o.orthogonal(I,W));const se=o.cross(I,W,K);o.normalize(se,se);const de=o.cross(A,se,W),be=l({center:[V[0],V[1],V[2]],radius:T,segments:N,axes:[W,se,de]});R=d(R,be)}),u(R)};e.exports=g}}),Crn=ft({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom3.js"(t,e){var n=ja(),i=s0e(),r=Arn(),o=(s,a)=>{const c={delta:1,corners:"round",segments:12},{delta:l,corners:u,segments:d}=Object.assign({},c,s);if(u!=="round")throw new Error('corners must be "round" for 3D geometries');if(n.toPolygons(a).length===0)throw new Error("the given geometry cannot be empty");s={delta:l,corners:u,segments:d};const f=r(s,a);return i(a,f)};e.exports=o}}),Rrn=ft({"node_modules/@jscad/modeling/src/operations/expansions/expandPath2.js"(t,e){var n=H$(),i=_c(),r=$a(),o=Hp(),s=q$(),a=u=>{let{external:d,internal:h}=u;n(d)<0?d=d.reverse():h=h.reverse();const f=o.fromPoints({closed:!0},d),m=o.fromPoints({closed:!0},h),y=r.toSides(r.fromPoints(o.toPoints(f))),g=r.toSides(r.fromPoints(o.toPoints(m)));return y.push(...g),r.create(y)},c=(u,d,h,f)=>{const{points:m,external:y,internal:g}=u,b=Math.floor(d/2),v=[],w=[];if(h==="round"&&b>0){const N=Math.PI/b,R=m[m.length-1],P=i.angle(i.subtract(i.create(),y[y.length-1],R)),M=m[0],I=i.angle(i.subtract(i.create(),g[0],M));for(let A=1;A<b;A++){let $=P+N*A,k=i.fromAngleRadians(i.create(),$);i.scale(k,k,f),i.add(k,k,R),v.push(k),$=I+N*A,k=i.fromAngleRadians(i.create(),$),i.scale(k,k,f),i.add(k,k,M),w.push(k)}}const T=[];return T.push(...y,...v,...g.reverse(),...w),r.fromPoints(T)},l=(u,d)=>{u=Object.assign({},{delta:1,corners:"edge",segments:16},u);const{delta:f,corners:m,segments:y}=u;if(f<=0)throw new Error("the given delta must be positive for paths");if(!(m==="edge"||m==="chamfer"||m==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const g=d.isClosed,b=o.toPoints(d);if(b.length===0)throw new Error("the given geometry cannot be empty");const v={points:b,external:s({delta:f,corners:m,segments:y,closed:g},b),internal:s({delta:-f,corners:m,segments:y,closed:g},b)};return d.isClosed?a(v):c(v,y,m,f)};e.exports=l}}),a0e=ft({"node_modules/@jscad/modeling/src/operations/expansions/expand.js"(t,e){var n=Ma(),i=$a(),r=ja(),o=Hp(),s=Trn(),a=Crn(),c=Rrn(),l=(u,...d)=>{if(d=n(d),d.length===0)throw new Error("wrong number of arguments");const h=d.map(f=>o.isA(f)?c(u,f):i.isA(f)?s(u,f):r.isA(f)?a(u,f):f);return h.length===1?h[0]:h};e.exports=l}}),Prn=ft({"node_modules/@jscad/modeling/src/operations/expansions/offsetGeom2.js"(t,e){var n=$a(),i=Gfe(),r=q$(),o=(s,a)=>{const c={delta:1,corners:"edge",segments:0},{delta:l,corners:u,segments:d}=Object.assign({},c,s);if(!(u==="edge"||u==="chamfer"||u==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const h=n.toOutlines(a),m=h.map(y=>(s={delta:h.reduce((v,w)=>v+i.arePointsInside(y,i.create(w)),0)%2===0?l:-l,corners:u,closed:!0,segments:d},r(s,y))).reduce((y,g)=>y.concat(n.toSides(n.fromPoints(g))),[]);return n.create(m)};e.exports=o}}),Irn=ft({"node_modules/@jscad/modeling/src/operations/expansions/offsetPath2.js"(t,e){var n=Hp(),i=q$(),r=(o,s)=>{const a={delta:1,corners:"edge",closed:s.isClosed,segments:16},{delta:c,corners:l,closed:u,segments:d}=Object.assign({},a,o);if(!(l==="edge"||l==="chamfer"||l==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');o={delta:c,corners:l,closed:u,segments:d};const h=i(o,n.toPoints(s));return n.fromPoints({closed:u},h)};e.exports=r}}),Nrn=ft({"node_modules/@jscad/modeling/src/operations/expansions/offset.js"(t,e){var n=Ma(),i=$a(),r=Hp(),o=Prn(),s=Irn(),a=(c,...l)=>{if(l=n(l),l.length===0)throw new Error("wrong number of arguments");const u=l.map(d=>r.isA(d)?s(c,d):i.isA(d)?o(c,d):d);return u.length===1?u[0]:u};e.exports=a}}),c0e=ft({"node_modules/@jscad/modeling/src/operations/expansions/index.js"(t,e){e.exports={expand:a0e(),offset:Nrn()}}}),X$=ft({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearGeom2.js"(t,e){var n=Af(),i=Go(),r=$a(),o=zA(),s=G$(),a=(c,l)=>{const u={offset:[0,0,1],twistAngle:0,twistSteps:12,repair:!0};let{offset:d,twistAngle:h,twistSteps:f,repair:m}=Object.assign({},u,c);if(f<1)throw new Error("twistSteps must be 1 or more");h===0&&(f=1);const y=i.clone(d),g=r.toSides(l);if(g.length===0)throw new Error("the given geometry cannot be empty");const b=o.fromSides(g);y[2]<0&&o.reverse(b,b);const v=n.create(),w=(T,N,R)=>{const P=N/f*h,M=i.scale(i.create(),y,N/f);return n.multiply(v,n.fromZRotation(v,P),n.fromTranslation(n.create(),M)),o.transform(v,R)};return c={numberOfSlices:f+1,capStart:!0,capEnd:!0,repair:m,callback:w},s(c,b)};e.exports=a}}),krn=ft({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearPath2.js"(t,e){var n=$a(),i=Hp(),r=X$(),o=(s,a)=>{if(!a.isClosed)throw new Error("extruded path must be closed");const c=i.toPoints(a),l=n.fromPoints(c);return r(s,l)};e.exports=o}}),Orn=ft({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinear.js"(t,e){var n=Ma(),i=$a(),r=Hp(),o=X$(),s=krn(),a=(c,...l)=>{const u={height:1,twistAngle:0,twistSteps:1,repair:!0},{height:d,twistAngle:h,twistSteps:f,repair:m}=Object.assign({},u,c);if(l=n(l),l.length===0)throw new Error("wrong number of arguments");c={offset:[0,0,d],twistAngle:h,twistSteps:f,repair:m};const y=l.map(g=>r.isA(g)?s(c,g):i.isA(g)?o(c,g):g);return y.length===1?y[0]:y};e.exports=a}}),Lrn=ft({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularPath2.js"(t,e){var n=Hp(),i=a0e(),r=X$(),o=(s,a)=>{const c={size:1,height:1},{size:l,height:u}=Object.assign({},c,s);if(s.delta=l,s.offset=[0,0,u],n.toPoints(a).length===0)throw new Error("the given geometry cannot be empty");const h=i(s,a);return r(s,h)};e.exports=o}}),Drn=ft({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularGeom2.js"(t,e){var{area:n}=vI(),i=$a(),r=Hp(),o=a0e(),s=X$(),a=(c,l)=>{const u={size:1,height:1},{size:d,height:h}=Object.assign({},u,c);c.delta=d,c.offset=[0,0,h];const f=i.toOutlines(l);if(f.length===0)throw new Error("the given geometry cannot be empty");const y=f.map(b=>(n(b)<0&&b.reverse(),o(c,r.fromPoints({closed:!0},b)))).reduce((b,v)=>b.concat(i.toSides(v)),[]),g=i.create(y);return s(c,g)};e.exports=a}}),zrn=ft({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangular.js"(t,e){var n=Ma(),i=$a(),r=Hp(),o=Lrn(),s=Drn(),a=(c,...l)=>{const u={size:1,height:1},{size:d,height:h}=Object.assign({},u,c);if(l=n(l),l.length===0)throw new Error("wrong number of arguments");if(d<=0)throw new Error("size must be positive");if(h<=0)throw new Error("height must be positive");const f=l.map(m=>r.isA(m)?o(c,m):i.isA(m)?s(c,m):m);return f.length===1?f[0]:f};e.exports=a}}),Frn=ft({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeHelical.js"(t,e){var{TAU:n}=su(),i=zA(),r=Af(),o=G$(),s=$a(),a=(c,l)=>{const u={angle:n,startAngle:0,pitch:10,endOffset:0,segmentsPerRotation:32},{angle:d,endOffset:h,segmentsPerRotation:f,startAngle:m}=Object.assign({},u,c);let y;if(!c.pitch&&c.height?y=c.height/(d/n):y=c.pitch?c.pitch:u.pitch,f<3)throw new Error("The number of segments per rotation needs to be at least 3.");const b=s.toSides(l);if(b.length===0)throw new Error("the given geometry cannot be empty");const v=b.filter(I=>I[0][0]>=0);let w=i.fromSides(b);v.length===0&&(w=i.reverse(w));const T=Math.round(f/n*Math.abs(d)),N=T>=2?T:2,R=r.create();let P;const M=(I,A,$)=>{const k=m+d/N*A,V=h/N*A,X=(k-m)/n*y;return r.multiply(R,r.fromTranslation(r.create(),[V,0,X*Math.sign(d)]),r.fromXRotation(r.create(),-n/4*Math.sign(d))),P=r.create(),r.multiply(P,r.fromZRotation(r.create(),k),R),i.transform(P,$)};return o({numberOfSlices:N+1,callback:M},w)};e.exports=a}}),Brn=ft({"node_modules/@jscad/modeling/src/operations/extrusions/project.js"(t,e){var n=Ma(),i=Wfe(),r=Rw(),o=Af(),s=$a(),a=ja(),c=Bl(),l=G4(),u=RYe(),d=(f,m)=>{const y=r.fromNormalAndPoint(r.create(),f.axis,f.origin);if(Number.isNaN(y[0])||Number.isNaN(y[1])||Number.isNaN(y[2])||Number.isNaN(y[3]))throw new Error("project: invalid axis or origin");const g=l(m),b=g*g*Math.sqrt(3)/4;if(g===0)return s.create();const v=a.toPolygons(m);let w=[];for(let N=0;N<v.length;N++){const R=v[N].vertices.map(I=>r.projectionOfPoint(y,I)),P=c.create(R),M=c.plane(P);i(y,M)&&(c.measureArea(P)<b||w.push(P))}if(!i(y,[0,0,1])){const N=o.fromVectorRotation(o.create(),y,[0,0,1]);w=w.map(R=>c.transform(N,R))}w=w.sort((N,R)=>c.measureArea(R)-c.measureArea(N));const T=w.map(N=>s.fromPoints(N.vertices));return u(T)},h=(f,...m)=>{const y={axis:[0,0,1],origin:[0,0,0]},{axis:g,origin:b}=Object.assign({},y,f);if(m=n(m),m.length===0)throw new Error("wrong number of arguments");f={axis:g,origin:b};const v=m.map(w=>a.isA(w)?d(f,w):w);return v.length===1?v[0]:v};e.exports=h}}),W$=ft({"node_modules/@jscad/modeling/src/operations/extrusions/index.js"(t,e){e.exports={extrudeFromSlices:G$(),extrudeLinear:Orn(),extrudeRectangular:zrn(),extrudeRotate:xYe(),extrudeHelical:Frn(),project:Brn(),slice:zA()}}}),l0e=ft({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints2.js"(t,e){var n=_c(),i=s=>{let a=n.fromValues(1/0,1/0);s.forEach(u=>{(u[1]<a[1]||u[1]===a[1]&&u[0]<a[0])&&(a=u)});const c=[];s.forEach(u=>{const d=o(u[1]-a[1],u[0]-a[0]),h=n.squaredDistance(u,a);c.push({point:u,angle:d,distSq:h})}),c.sort((u,d)=>u.angle!==d.angle?u.angle-d.angle:u.distSq-d.distSq);const l=[];return c.forEach(u=>{let d=l.length;for(;d>1&&r(l[d-2],l[d-1],u.point)<=Number.EPSILON;)l.pop(),d=l.length;l.push(u.point)}),l},r=(s,a,c)=>(a[0]-s[0])*(c[1]-s[1])-(a[1]-s[1])*(c[0]-s[0]),o=(s,a)=>s===0&&a===0?-1/0:-a/s;e.exports=i}}),u0e=ft({"node_modules/@jscad/modeling/src/operations/hulls/toUniquePoints.js"(t,e){var n=$a(),i=ja(),r=Hp(),o=s=>{const a=new Set,c=[],l=u=>{const d=u.toString();a.has(d)||(c.push(u),a.add(d))};return s.forEach(u=>{n.isA(u)?n.toPoints(u).forEach(l):i.isA(u)?i.toPoints(u).forEach(d=>d.forEach(l)):r.isA(u)&&r.toPoints(u).forEach(l)}),c};e.exports=o}}),Urn=ft({"node_modules/@jscad/modeling/src/operations/hulls/hullPath2.js"(t,e){var n=Ma(),i=Hp(),r=l0e(),o=u0e(),s=(...a)=>{a=n(a);const c=o(a),l=r(c);return i.fromPoints({closed:!0},l)};e.exports=s}}),$rn=ft({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom2.js"(t,e){var n=Ma(),i=$a(),r=l0e(),o=u0e(),s=(...a)=>{a=n(a);const c=o(a),l=r(c);return l.length<3?i.create():i.fromPoints(l)};e.exports=s}}),PYe=ft({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints3.js"(t,e){var n=Bl(),i=RGe(),r=o=>i(o,{skipTriangulation:!0}).map(c=>{const l=c.map(u=>o[u]);return n.create(l)});e.exports=r}}),jrn=ft({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom3.js"(t,e){var n=Ma(),i=ja(),r=u0e(),o=PYe(),s=(...a)=>{a=n(a);const c=r(a);return c.length===0?i.create():i.create(o(c))};e.exports=s}}),IYe=ft({"node_modules/@jscad/modeling/src/operations/hulls/hull.js"(t,e){var n=Ma(),i=TI(),r=$a(),o=ja(),s=Hp(),a=Urn(),c=$rn(),l=jrn(),u=(...d)=>{if(d=n(d),d.length===0)throw new Error("wrong number of arguments");if(!i(d))throw new Error("only hulls of the same type are supported");const h=d[0];return s.isA(h)?a(d):r.isA(h)?c(d):o.isA(h)?l(d):h};e.exports=u}}),Hrn=ft({"node_modules/@jscad/modeling/src/operations/hulls/hullChain.js"(t,e){var n=Ma(),i=s0e(),r=IYe(),o=(...s)=>{if(s=n(s),s.length<2)throw new Error("wrong number of arguments");const a=[];for(let c=1;c<s.length;c++)a.push(r(s[c-1],s[c]));return i(a)};e.exports=o}}),Vrn=ft({"node_modules/@jscad/modeling/src/operations/hulls/index.js"(t,e){e.exports={hull:IYe(),hullChain:Hrn(),hullPoints2:l0e(),hullPoints3:PYe()}}}),NYe=ft({"node_modules/@jscad/modeling/src/operations/modifiers/snapPolygons.js"(t,e){var n=Go(),i=Bl(),r=(s,a)=>{const c=Math.abs(i.measureArea(a));return Number.isFinite(c)&&c>s},o=(s,a)=>{let c=a.map(u=>{const d=u.vertices.map(m=>n.snap(n.create(),m,s)),h=[];for(let m=0;m<d.length;m++){const y=(m+1)%d.length;n.equals(d[m],d[y])||h.push(d[m])}const f=i.create(h);return u.color&&(f.color=u.color),f});const l=s*s*Math.sqrt(3)/4;return c=c.filter(u=>r(l,u)),c};e.exports=o}}),Grn=ft({"node_modules/@jscad/modeling/src/operations/modifiers/mergePolygons.js"(t,e){var n=Wfe(),i=Go(),r=Bl(),o=b=>{const v=r.toPoints(b),w=[];for(let T=0;T<v.length;T++){const N=(T+1)%v.length,R={v1:v[T],v2:v[N]};w.push(R)}for(let T=0;T<w.length;T++){const N=(T+1)%v.length;w[T].next=w[N],w[N].prev=w[T]}return w},s=(b,v)=>{const w=`${v.v1}:${v.v2}`;b.set(w,v)},a=(b,v)=>{const w=`${v.v1}:${v.v2}`;b.delete(w)},c=(b,v)=>{const w=`${v.v2}:${v.v1}`;return b.get(w)},l=(b,v,w)=>{let T=b.prev.v1,N=b.prev.v2,R=v.next.v2;const P=h(T,N,R,w);T=v.prev.v1,N=v.prev.v2,R=b.next.v2;const M=h(T,N,R,w);return[P,M]},u=i.create(),d=i.create(),h=(b,v,w,T)=>{const N=i.subtract(u,v,b),R=i.subtract(d,w,v);return i.cross(N,N,R),i.dot(N,T)},f=b=>{let v;const w=[];for(;b.next;){const T=b.next;w.push(b.v1),b.v1=null,b.v2=null,b.next=null,b.prev=null,b=T}return w.length>0&&(v=r.create(w)),v},m=b=>{if(b.length<2)return b;const v=b[0].plane,w=b.slice(),T=new Map;for(;w.length>0;){const R=w.shift(),P=o(R);for(let M=0;M<P.length;M++){const I=P[M],A=c(T,I);if(A){const $=l(I,A,v);if($[0]>=0&&$[1]>=0){const k=A.next,V=I.next;I.prev.next=A.next,I.next.prev=A.prev,A.prev.next=I.next,A.next.prev=I.prev,I.v1=null,I.v2=null,I.next=null,I.prev=null,a(T,A),A.v1=null,A.v2=null,A.next=null,A.prev=null;const X=(W,K,te)=>{const se={v1:te.v1,v2:K.v2,next:K.next,prev:te.prev};te.prev.next=se,K.next.prev=se,a(W,K),K.v1=null,K.v2=null,K.next=null,K.prev=null,a(W,te),te.v1=null,te.v2=null,te.next=null,te.prev=null};$[0]===0&&X(T,k,k.prev),$[1]===0&&X(T,V,V.prev)}}else I.next&&s(T,I)}}const N=[];return T.forEach(R=>{const P=f(R);P&&N.push(P)}),T.clear(),N},y=(b,v)=>Math.abs(b[3]-v[3])<15e-8?n(b,v):!1,g=(b,v)=>{const w=[];v.forEach(N=>{const R=w.find(P=>y(P[0],r.plane(N)));R?R[1].push(N):w.push([r.plane(N),[N]])});let T=[];return w.forEach(N=>{const R=N[1],P=m(R);T=T.concat(P)}),T};e.exports=g}}),Yrn=ft({"node_modules/@jscad/modeling/src/operations/modifiers/insertTjunctions.js"(t,e){var n=su(),i=Go(),r=Bl(),o=l=>`${l}`,s=(l,u,d,h,f,m)=>{const y=o(h),g=o(f),b=`${y}/${g}`,v=`${g}/${y}`;if(l.has(v))return a(l,u,d,f,h,null),null;const w={vertex0:h,vertex1:f,polygonindex:m};return l.has(b)?l.get(b).push(w):l.set(b,[w]),u.has(y)?u.get(y).push(b):u.set(y,[b]),d.has(g)?d.get(g).push(b):d.set(g,[b]),b},a=(l,u,d,h,f,m)=>{const y=o(h),g=o(f),b=`${y}/${g}`;let v=-1;const w=l.get(b);for(let T=0;T<w.length;T++){const N=w[T];let R=o(N.vertex0);if(R===y&&(R=o(N.vertex1),R===g&&!(m!==null&&N.polygonindex!==m))){v=T;break}}w.splice(v,1),w.length===0&&l.delete(b),v=u.get(y).indexOf(b),u.get(y).splice(v,1),u.get(y).length===0&&u.delete(y),v=d.get(g).indexOf(b),d.get(g).splice(v,1),d.get(g).length===0&&d.delete(g)},c=l=>{const u=new Map;for(let d=0;d<l.length;d++){const h=l[d],f=h.vertices.length;if(f>=3){let m=h.vertices[0],y=o(m);for(let g=0;g<f;g++){let b=g+1;b===f&&(b=0);const v=h.vertices[b],w=o(v),T=`${y}/${w}`,N=`${w}/${y}`;if(u.has(N)){const R=u.get(N);R.splice(-1,1),R.length===0&&u.delete(N)}else{const R={vertex0:m,vertex1:v,polygonindex:d};u.has(T)?u.get(T).push(R):u.set(T,[R])}m=v,y=w}}else console.warn("warning: invalid polygon found during insertTjunctions")}if(u.size>0){const d=new Map,h=new Map,f=new Map;for(const[y,g]of u)f.set(y,!0),g.forEach(b=>{const v=o(b.vertex0),w=o(b.vertex1);d.has(v)?d.get(v).push(y):d.set(v,[y]),h.has(w)?h.get(w).push(y):h.set(w,[y])});const m=l.slice(0);for(;u.size!==0;){for(const g of u.keys())f.set(g,!0);let y=!1;for(;;){const g=Array.from(f.keys());if(g.length===0)break;const b=g[0];let v=!0;if(u.has(b)){const T=u.get(b)[0];for(let N=0;N<2;N++){const R=N===0?T.vertex0:T.vertex1,P=N===0?T.vertex1:T.vertex0,M=o(R),I=o(P);let A=[];N===0?h.has(M)&&(A=h.get(M)):d.has(M)&&(A=d.get(M));for(let $=0;$<A.length;$++){const k=A[$],V=u.get(k)[0],X=N===0?V.vertex0:V.vertex1;if(N===0?V.vertex1:V.vertex0,o(X)===I){a(u,d,h,R,P,null),a(u,d,h,P,R,null),v=!1,N=2,y=!0;break}else{const K=R,te=P,se=X,de=i.subtract(i.create(),se,K),be=i.dot(i.subtract(i.create(),te,K),de)/i.dot(de,de);if(be>0&&be<1){const re=i.scale(i.create(),de,be);if(i.add(re,re,K),i.squaredDistance(re,te)<n.EPS*n.EPS){const he=V.polygonindex,Me=m[he],Ie=o(V.vertex1);let De=-1;for(let xe=0;xe<Me.vertices.length;xe++)if(o(Me.vertices[xe])===Ie){De=xe;break}const Ge=Me.vertices.slice(0);Ge.splice(De,0,P);const ke=r.create(Ge);m[he]=ke,a(u,d,h,V.vertex0,V.vertex1,he);const ce=s(u,d,h,V.vertex0,P,he),we=s(u,d,h,P,V.vertex1,he);ce!==null&&f.set(ce,!0),we!==null&&f.set(we,!0),v=!1,N=2,y=!0;break}}}}}}v&&f.delete(b)}if(!y)break}l=m}return u.clear(),l};e.exports=c}}),qrn=ft({"node_modules/@jscad/modeling/src/operations/modifiers/triangulatePolygons.js"(t,e){var n=Go(),i=Bl(),r=(s,a,c)=>{const l=a.vertices.length;if(l>3){if(l>4){const h=[0,0,0];a.vertices.forEach(f=>n.add(h,h,f)),n.snap(h,n.divide(h,h,[l,l,l]),s);for(let f=0;f<l;f++){const m=i.create([h,a.vertices[f],a.vertices[(f+1)%l]]);a.color&&(m.color=a.color),c.push(m)}return}const u=i.create([a.vertices[0],a.vertices[1],a.vertices[2]]),d=i.create([a.vertices[0],a.vertices[2],a.vertices[3]]);a.color&&(u.color=a.color,d.color=a.color),c.push(u,d);return}c.push(a)},o=(s,a)=>{const c=[];return a.forEach(l=>{r(s,l,c)}),c};e.exports=o}}),Xrn=ft({"node_modules/@jscad/modeling/src/operations/modifiers/generalize.js"(t,e){var n=Ma(),i=G4(),r=$a(),o=ja(),s=Hp(),a=NYe(),c=Grn(),l=Yrn(),u=qrn(),d=(y,g)=>g,h=(y,g)=>g,f=(y,g)=>{const b={snap:!1,simplify:!1,triangulate:!1},{snap:v,simplify:w,triangulate:T}=Object.assign({},b,y),N=i(g);let R=o.toPolygons(g);v&&(R=a(N,R)),w&&(R=c(N,R)),T&&(R=l(R),R=u(N,R));const P=Object.assign({},g);return P.polygons=R,P},m=(y,...g)=>{if(g=n(g),g.length===0)throw new Error("wrong number of arguments");const b=g.map(v=>{if(s.isA(v))return d(y,v);if(r.isA(v))return h(y,v);if(o.isA(v))return f(y,v);throw new Error("invalid geometry")});return b.length===1?b[0]:b};e.exports=m}}),Wrn=ft({"node_modules/@jscad/modeling/src/operations/modifiers/snap.js"(t,e){var n=Ma(),i=_c(),r=$a(),o=ja(),s=Hp(),a=G4(),c=NYe(),l=f=>{const m=a(f),g=s.toPoints(f).map(b=>i.snap(i.create(),b,m));return s.create(g)},u=f=>{const m=a(f);let g=r.toSides(f).map(b=>[i.snap(i.create(),b[0],m),i.snap(i.create(),b[1],m)]);return g=g.filter(b=>!i.equals(b[0],b[1])),r.create(g)},d=f=>{const m=a(f),y=o.toPolygons(f),g=c(m,y);return o.create(g)},h=(...f)=>{if(f=n(f),f.length===0)throw new Error("wrong number of arguments");const m=f.map(y=>s.isA(y)?l(y):r.isA(y)?u(y):o.isA(y)?d(y):y);return m.length===1?m[0]:m};e.exports=h}}),Zrn=ft({"node_modules/@jscad/modeling/src/operations/modifiers/index.js"(t,e){e.exports={generalize:Xrn(),snap:Wrn(),retessellate:MI()}}}),Krn=ft({"node_modules/@jscad/modeling/src/utils/padArrayToLength.js"(t,e){var n=(i,r,o)=>{for(i=i.slice();i.length<o;)i.push(r);return i};e.exports=n}}),Qrn=ft({"node_modules/@jscad/modeling/src/operations/transforms/align.js"(t,e){var n=Ma(),i=Krn(),r=Kfe(),{translate:o}=oM(),s=u=>{if(!Array.isArray(u.modes)||u.modes.length>3)throw new Error("align(): modes must be an array of length <= 3");if(u.modes=i(u.modes,"none",3),u.modes.filter(d=>["center","max","min","none"].includes(d)).length!==3)throw new Error('align(): all modes must be one of "center", "max" or "min"');if(!Array.isArray(u.relativeTo)||u.relativeTo.length>3)throw new Error("align(): relativeTo must be an array of length <= 3");if(u.relativeTo=i(u.relativeTo,0,3),u.relativeTo.filter(d=>Number.isFinite(d)||d==null).length!==3)throw new Error("align(): all relativeTo values must be a number, or null.");if(typeof u.grouped!="boolean")throw new Error("align(): grouped must be a boolean value.");return u},a=(u,d,h)=>{for(let f=0;f<3;f++)u[f]==null&&(d[f]==="center"?u[f]=(h[0][f]+h[1][f])/2:d[f]==="max"?u[f]=h[1][f]:d[f]==="min"&&(u[f]=h[0][f]));return u},c=(u,d,h)=>{const f=r(u),m=[0,0,0];for(let y=0;y<3;y++)d[y]==="center"?m[y]=h[y]-(f[0][y]+f[1][y])/2:d[y]==="max"?m[y]=h[y]-f[1][y]:d[y]==="min"&&(m[y]=h[y]-f[0][y]);return o(m,u)},l=(u,...d)=>{u=Object.assign({},{modes:["center","center","min"],relativeTo:[0,0,0],grouped:!1},u),u=s(u);let{modes:f,relativeTo:m,grouped:y}=u;if(d=n(d),d.length===0)throw new Error("align(): No geometries were provided to act upon");if(m.filter(g=>g==null).length){const g=r(d);m=a(m,f,g)}return y?d=c(d,f,m):d=d.map(g=>c(g,f,m)),d.length===1?d[0]:d};e.exports=l}}),Z$=ft({"node_modules/@jscad/modeling/src/operations/transforms/center.js"(t,e){var n=Ma(),i=$a(),r=ja(),o=Hp(),s=iM(),{translate:a}=oM(),c=(f,m)=>{const y={axes:[!0,!0,!0],relativeTo:[0,0,0]},{axes:g,relativeTo:b}=Object.assign({},y,f),v=s(m),w=[0,0,0];return g[0]&&(w[0]=b[0]-(v[0][0]+(v[1][0]-v[0][0])/2)),g[1]&&(w[1]=b[1]-(v[0][1]+(v[1][1]-v[0][1])/2)),g[2]&&(w[2]=b[2]-(v[0][2]+(v[1][2]-v[0][2])/2)),a(w,m)},l=(f,...m)=>{const y={axes:[!0,!0,!0],relativeTo:[0,0,0]},{axes:g,relativeTo:b}=Object.assign({},y,f);if(m=n(m),m.length===0)throw new Error("wrong number of arguments");if(b.length!==3)throw new Error("relativeTo must be an array of length 3");f={axes:g,relativeTo:b};const v=m.map(w=>o.isA(w)||i.isA(w)||r.isA(w)?c(f,w):w);return v.length===1?v[0]:v},u=(...f)=>l({axes:[!0,!1,!1]},f),d=(...f)=>l({axes:[!1,!0,!1]},f),h=(...f)=>l({axes:[!1,!1,!0]},f);e.exports={center:l,centerX:u,centerY:d,centerZ:h}}}),K$=ft({"node_modules/@jscad/modeling/src/operations/transforms/scale.js"(t,e){var n=Ma(),i=Af(),r=$a(),o=ja(),s=Hp(),a=(d,...h)=>{if(!Array.isArray(d))throw new Error("factors must be an array");if(h=n(h),h.length===0)throw new Error("wrong number of arguments");for(d=d.slice();d.length<3;)d.push(1);if(d[0]<=0||d[1]<=0||d[2]<=0)throw new Error("factors must be positive");const f=i.fromScaling(i.create(),d),m=h.map(y=>s.isA(y)?s.transform(f,y):r.isA(y)?r.transform(f,y):o.isA(y)?o.transform(f,y):y);return m.length===1?m[0]:m},c=(d,...h)=>a([d,1,1],h),l=(d,...h)=>a([1,d,1],h),u=(d,...h)=>a([1,1,d],h);e.exports={scale:a,scaleX:c,scaleY:l,scaleZ:u}}}),Jrn=ft({"node_modules/@jscad/modeling/src/operations/transforms/transform.js"(t,e){var n=Ma(),i=$a(),r=ja(),o=Hp(),s=(a,...c)=>{if(c=n(c),c.length===0)throw new Error("wrong number of arguments");const l=c.map(u=>o.isA(u)?o.transform(a,u):i.isA(u)?i.transform(a,u):r.isA(u)?r.transform(a,u):u);return l.length===1?l[0]:l};e.exports=s}}),Q$=ft({"node_modules/@jscad/modeling/src/operations/transforms/index.js"(t,e){e.exports={align:Qrn(),center:Z$().center,centerX:Z$().centerX,centerY:Z$().centerY,centerZ:Z$().centerZ,mirror:SI().mirror,mirrorX:SI().mirrorX,mirrorY:SI().mirrorY,mirrorZ:SI().mirrorZ,rotate:EI().rotate,rotateX:EI().rotateX,rotateY:EI().rotateY,rotateZ:EI().rotateZ,scale:K$().scale,scaleX:K$().scaleX,scaleY:K$().scaleY,scaleZ:K$().scaleZ,transform:Jrn(),translate:oM().translate,translateX:oM().translateX,translateY:oM().translateY,translateZ:oM().translateZ}}}),d0e=ft({"node_modules/@jscad/modeling/src/index.js"(t,e){e.exports={colors:xI(),curves:Wnn(),geometries:Yfe(),maths:xin(),measurements:Cin(),primitives:sM(),text:t0e(),utils:EYe(),booleans:Y$(),expansions:c0e(),extrusions:W$(),hulls:Vrn(),modifiers:Zrn(),transforms:Q$()}}}),eon=ft({"node_modules/ms/index.js"(t,e){var n=1e3,i=n*60,r=i*60,o=r*24,s=o*7,a=o*365.25;e.exports=function(h,f){f=f||{};var m=typeof h;if(m==="string"&&h.length>0)return c(h);if(m==="number"&&isFinite(h))return f.long?u(h):l(h);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(h))};function c(h){if(h=String(h),!(h.length>100)){var f=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(h);if(f){var m=parseFloat(f[1]),y=(f[2]||"ms").toLowerCase();switch(y){case"years":case"year":case"yrs":case"yr":case"y":return m*a;case"weeks":case"week":case"w":return m*s;case"days":case"day":case"d":return m*o;case"hours":case"hour":case"hrs":case"hr":case"h":return m*r;case"minutes":case"minute":case"mins":case"min":case"m":return m*i;case"seconds":case"second":case"secs":case"sec":case"s":return m*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return m;default:return}}}}function l(h){var f=Math.abs(h);return f>=o?Math.round(h/o)+"d":f>=r?Math.round(h/r)+"h":f>=i?Math.round(h/i)+"m":f>=n?Math.round(h/n)+"s":h+"ms"}function u(h){var f=Math.abs(h);return f>=o?d(h,f,o,"day"):f>=r?d(h,f,r,"hour"):f>=i?d(h,f,i,"minute"):f>=n?d(h,f,n,"second"):h+" ms"}function d(h,f,m,y){var g=f>=m*1.5;return Math.round(h/m)+" "+y+(g?"s":"")}}}),ton=ft({"node_modules/debug/src/common.js"(t,e){function n(i){o.debug=o,o.default=o,o.coerce=d,o.disable=l,o.enable=a,o.enabled=u,o.humanize=eon(),o.destroy=h,Object.keys(i).forEach(f=>{o[f]=i[f]}),o.names=[],o.skips=[],o.formatters={};function r(f){let m=0;for(let y=0;y<f.length;y++)m=(m<<5)-m+f.charCodeAt(y),m|=0;return o.colors[Math.abs(m)%o.colors.length]}o.selectColor=r;function o(f){let m,y=null,g,b;function v(...w){if(!v.enabled)return;const T=v,N=Number(new Date),R=N-(m||N);T.diff=R,T.prev=m,T.curr=N,m=N,w[0]=o.coerce(w[0]),typeof w[0]!="string"&&w.unshift("%O");let P=0;w[0]=w[0].replace(/%([a-zA-Z%])/g,(I,A)=>{if(I==="%%")return"%";P++;const $=o.formatters[A];if(typeof $=="function"){const k=w[P];I=$.call(T,k),w.splice(P,1),P--}return I}),o.formatArgs.call(T,w),(T.log||o.log).apply(T,w)}return v.namespace=f,v.useColors=o.useColors(),v.color=o.selectColor(f),v.extend=s,v.destroy=o.destroy,Object.defineProperty(v,"enabled",{enumerable:!0,configurable:!1,get:()=>y!==null?y:(g!==o.namespaces&&(g=o.namespaces,b=o.enabled(f)),b),set:w=>{y=w}}),typeof o.init=="function"&&o.init(v),v}function s(f,m){const y=o(this.namespace+(typeof m>"u"?":":m)+f);return y.log=this.log,y}function a(f){o.save(f),o.namespaces=f,o.names=[],o.skips=[];const m=(typeof f=="string"?f:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const y of m)y[0]==="-"?o.skips.push(y.slice(1)):o.names.push(y)}function c(f,m){let y=0,g=0,b=-1,v=0;for(;y<f.length;)if(g<m.length&&(m[g]===f[y]||m[g]==="*"))m[g]==="*"?(b=g,v=y,g++):(y++,g++);else if(b!==-1)g=b+1,v++,y=v;else return!1;for(;g<m.length&&m[g]==="*";)g++;return g===m.length}function l(){const f=[...o.names,...o.skips.map(m=>"-"+m)].join(",");return o.enable(""),f}function u(f){for(const m of o.skips)if(c(f,m))return!1;for(const m of o.names)if(c(f,m))return!0;return!1}function d(f){return f instanceof Error?f.stack||f.message:f}function h(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return o.enable(o.load()),o}e.exports=n}}),non=ft({"node_modules/debug/src/browser.js"(t,e){t.formatArgs=i,t.save=r,t.load=o,t.useColors=n,t.storage=s(),t.destroy=(()=>{let c=!1;return()=>{c||(c=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function n(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let c;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(c=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(c[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function i(c){if(c[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+c[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const l="color: "+this.color;c.splice(1,0,l,"color: inherit");let u=0,d=0;c[0].replace(/%[a-zA-Z%]/g,h=>{h!=="%%"&&(u++,h==="%c"&&(d=u))}),c.splice(d,0,l)}t.log=console.debug||console.log||(()=>{});function r(c){try{c?t.storage.setItem("debug",c):t.storage.removeItem("debug")}catch{}}function o(){let c;try{c=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch{}return!c&&typeof zfe<"u"&&"env"in zfe&&(c=zfe.env.DEBUG),c}function s(){try{return localStorage}catch{}}e.exports=ton()(t);var{formatters:a}=e.exports;a.j=function(c){try{return JSON.stringify(c)}catch(l){return"[UnexpectedJSONParseError]: "+l.message}}}}),kYe=Ee.createContext(null),Nx=()=>{const t=Ee.useContext(kYe);if(!t)throw new Error("useThree must be used within a ThreeProvider");return t},AI=(t,e=[])=>{const{addFrameListener:n,removeFrameListener:i}=Nx();ts.useEffect(()=>(n(t),()=>i(t)),[n,i,...e])},OYe=Ee.createContext(null),ion=()=>{const t=Ee.useContext(OYe);if(!t)throw new Error("useHover must be used within a HoverProvider");return t},ron=({children:t})=>{const{camera:e,renderer:n}=Nx(),[i,r]=Ee.useState([]),o=Ee.useMemo(()=>new jSt,[]),s=Ee.useMemo(()=>new Lo,[]),a=Ee.useRef(i);a.current=i;const c=Ee.useRef(null),l=Ee.useCallback(m=>{r(y=>[...y,m])},[]),u=Ee.useCallback(m=>{if(c.current){let y=!1,g=c.current.object;for(;g;){if(g===m){y=!0;break}g=g.parent}y&&(c.current.onUnhover(),c.current=null)}r(y=>y.filter(g=>g.object!==m))},[]),d=Ee.useCallback(m=>{let y=m;for(;y;){const g=a.current.find(b=>b.object===y);if(g)return g;y=y.parent}},[]),h=Ee.useCallback(m=>{if(!n.domElement)return;const y=n.domElement.getBoundingClientRect();s.x=(m.clientX-y.left)/y.width*2-1,s.y=-((m.clientY-y.top)/y.height)*2+1,o.setFromCamera(s,e);const g=a.current.map(v=>v.object);if(g.length===0){c.current&&(c.current.onUnhover(),c.current=null);return}const b=o.intersectObjects(g,!0);if(b.length>0){const v=b[0],w=d(v.object);if(w){const T={mousePosition:[v.point.x,v.point.y,v.point.z]};c.current!==w?(c.current?.onUnhover(),w.onHover(T),c.current=w):w.onHover(T)}else c.current&&(c.current.onUnhover(),c.current=null)}else c.current&&(c.current.onUnhover(),c.current=null)},[e,n,o,s,d]);Ee.useEffect(()=>{const m=n.domElement;return m.addEventListener("mousemove",h),()=>{m.removeEventListener("mousemove",h)}},[n,h]);const f=Ee.useMemo(()=>({addHoverable:l,removeHoverable:u}),[l,u]);return ye.jsx(OYe.Provider,{value:f,children:t})},oon=({children:t,object:e,onHover:n,onUnhover:i,isHovered:r})=>{const{addHoverable:o,removeHoverable:s}=ion();return Ee.useEffect(()=>e?(o({object:e,onHover:n,onUnhover:i}),()=>{s(e)}):void 0,[e,n,i,o,s]),ye.jsx(ye.Fragment,{children:t})},CI=oon;function son(t){return t.replace(/(DEF|USE)\s+([^\s]+)/g,(e,n,i)=>`${n} ${i.replace(/-/g,"_")}`)}async function aon(t){const e=await fetch(t);if(!e.ok)throw new Error(`Failed to fetch "${t}": ${e.status} ${e.statusText}`);const n=await e.text();return new Q3t().parse(son(n),t)}typeof window<"u"&&!window.TSCIRCUIT_OBJ_LOADER_CACHE&&(window.TSCIRCUIT_OBJ_LOADER_CACHE=new Map);function con(t){const[e,n]=Ee.useState(null);return Ee.useEffect(()=>{if(!t)return;const i=t.replace(/&cachebust_origin=$/,""),r=window.TSCIRCUIT_OBJ_LOADER_CACHE;let o=!1;async function s(){try{if(i.endsWith(".wrl"))return await aon(i);const c=await fetch(i);if(!c.ok)throw new Error(`Failed to fetch "${i}": ${c.status} ${c.statusText}`);const l=await c.text(),u=l.match(/newmtl[\s\S]*?endmtl/g),d=new a4t;if(u?.length){const h=u.join(`
5083
- `).replace(/d 0\./g,"d 1."),f=l.replace(/newmtl[\s\S]*?endmtl/g,"").replace(/^mtllib.*/gm,""),m=new W3t;m.setMaterialOptions({invertTrProperty:!0});const y=m.parse(h.replace(/Kd\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/g,"Kd $2 $2 $2"),"embedded.mtl");return d.setMaterials(y),d.parse(f)}return d.parse(l.replace(/^mtllib.*/gm,""))}catch(c){return c}}function a(){if(r.has(i)){const l=r.get(i);return l.result?Promise.resolve(l.result.clone()):l.promise.then(u=>u instanceof Error?u:u.clone())}const c=s().then(l=>(l instanceof Error||r.set(i,{...r.get(i),result:l}),l));return r.set(i,{promise:c,result:null}),c}return a().then(c=>{o||n(c)}).catch(c=>{console.error(c)}),()=>{o=!0}},[t]),e}function lon({url:t,position:e,rotation:n,onHover:i,onUnhover:r,isHovered:o,scale:s}){const a=con(t),{rootObject:c}=Nx(),l=Ee.useMemo(()=>a&&!(a instanceof Error)?a:new pd(new uw(.5,.5,.5),new N9({transparent:!0,color:"red",opacity:.25})),[a]);if(Ee.useEffect(()=>{if(!(!c||!l))return c.add(l),()=>{c.remove(l)}},[c,l]),Ee.useEffect(()=>{l&&(e&&(Array.isArray(e)?l.position.fromArray(e):l.position.copy(e)),n&&(Array.isArray(n)?l.rotation.fromArray(n):l.rotation.copy(n)),s!==void 0&&l.scale.setScalar(s))},[l,Array.isArray(e)?e[0]:e?.x,Array.isArray(e)?e[1]:e?.y,Array.isArray(e)?e[2]:e?.z,Array.isArray(n)?n[0]:n?.x,Array.isArray(n)?n[1]:n?.y,Array.isArray(n)?n[2]:n?.z,s]),a instanceof Error)throw a;return ye.jsx(CI,{isHovered:o,onHover:i,onUnhover:r,object:l})}function uon({gltfUrl:t,position:e,rotation:n,onHover:i,onUnhover:r,isHovered:o,scale:s}){const{rootObject:a}=Nx(),[c,l]=Ee.useState(null);return Ee.useEffect(()=>{if(!t)return;const u=new p3t;let d=!0;return u.load(t,h=>{d&&l(h.scene)},void 0,h=>{d&&console.error(`An error happened loading ${t}`,h)}),()=>{d=!1}},[t]),Ee.useEffect(()=>{c&&(e&&c.position.fromArray(e),n&&c.rotation.fromArray(n),s!==void 0&&c.scale.setScalar(s))},[c,e?.[0],e?.[1],e?.[2],n?.[0],n?.[1],n?.[2],s]),Ee.useEffect(()=>{if(!(!a||!c))return a.add(c),()=>{a.remove(c)}},[a,c]),Ee.useEffect(()=>{c&&c.traverse(u=>{u instanceof pd&&u.material instanceof N9&&(o?(u.material.emissive.setHex(255),u.material.emissiveIntensity=.2):u.material.emissiveIntensity=0)})},[o,c]),c?ye.jsx(CI,{isHovered:o,onHover:i,onUnhover:r,object:c}):null}var don=jp(uGe()),hon=jp(d0e()),LYe={in:25.4,inch:25.4,mil:.0254,mm:1,m:1e3,cm:10,ft:304.8,feet:304.8},dh=t=>{let e=typeof t=="number"?"mm":t.replace(/^[^a-zA-Z]+/g,"").toLowerCase();e||(e="mm");const n=typeof t=="number"?t:Number.parseFloat(t.split(e)[0]);if(e in LYe)return n*LYe[e];throw new Error(`Unsupported unit: ${e}`)},RI=dh,DYe={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,kohm: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}}},h0e=new Set;for(const[t,e]of Object.entries(DYe)){h0e.add(t);for(const n of Object.keys(e.variants))h0e.add(n)}function pon(t){for(const[e,n]of Object.entries(DYe))if(t in n.variants)return{baseUnit:n.baseUnit,conversionFactor:n.variants[t]};return{baseUnit:t,conversionFactor:1}}var zYe={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},m5=t=>{if(typeof t>"u")return{parsedUnit:null,unitOfValue:null,value:null};if(typeof t=="string"&&t.match(/^-?[\d\.]+$/))return{value:Number.parseFloat(t),parsedUnit:null,unitOfValue:null};if(typeof t=="number")return{value:t,parsedUnit:null,unitOfValue:null};if(typeof t=="object"&&"x"in t&&"y"in t){const{parsedUnit:a,unitOfValue:c}=m5(t.x);return{parsedUnit:a,unitOfValue:c,value:{x:m5(t.x).value,y:m5(t.y).value}}}const n=t.toString().split("").reverse().join("").match(/[^\d\s]+/)?.[0];if(!n)throw new Error(`Could not determine unit: "${t}"`);const i=n.split("").reverse().join(""),r=t.slice(0,-i.length);if(i in zYe&&!h0e.has(i)){const a=zYe[i];return{parsedUnit:null,unitOfValue:null,value:Number.parseFloat(r)*a}}const{baseUnit:o,conversionFactor:s}=pon(i);return{parsedUnit:i,unitOfValue:o,value:s*Number.parseFloat(r)}},p0e=B().or(Ue()).transform(t=>m5(t).value),FYe=B().or(Ue()).transform(t=>m5(t).value).transform(t=>Number.parseFloat(t.toPrecision(12))),fon=B().or(Ue()).transform(t=>m5(t).value),FA=B().or(Ue()).transform(t=>m5(t).value),_t=B().or(Ue()).transform(t=>m5(t).value),BYe=B().or(Ue()).transform(t=>m5(t).value),Di=_t;B().or(Ue()).transform(t=>m5(t).value),B().or(Ue()).transform(t=>m5(t).value);var n3=B().or(Ue()).transform(t=>typeof t=="number"?t:t.endsWith("deg")?Number.parseFloat(t.split("deg")[0]):t.endsWith("rad")?Number.parseFloat(t.split("rad")[0])*180/Math.PI:Number.parseFloat(t)),mon=Ue().or(B().endsWith("mAh")).transform(t=>{if(typeof t=="string"){const e=t.replace("mAh",""),n=Number.parseFloat(e);if(Number.isNaN(n))throw new Error("Invalid capacity");return n}return t}).describe("Battery capacity in mAh"),au=Ne({x:Di,y:Di}),f0e=Ne({x:Di,y:Di,z:Di}),UYe=Ne({width:Ue(),height:Ue()}),_on=t=>{const e="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";return Array.from({length:t},()=>e[Math.floor(Math.random()*e.length)]).join("")},Io=t=>B().optional().default(()=>`${t}_${_on(10)}`),m0e=dn(["top_left","top_center","top_right","center_left","center","center_right","bottom_left","bottom_center","bottom_right"]),yon=dn(["jlcpcb","macrofab","pcbway","digikey","mouser","lcsc"]),C1=Ne({type:Ce("source_component"),ftype:B().optional(),source_component_id:B(),name:B(),manufacturer_part_number:B().optional(),supplier_part_numbers:Us(yon,Ct(B())).optional(),display_value:B().optional(),are_pins_interchangeable:bt().optional(),internally_connected_source_port_ids:Ct(Ct(B())).optional(),source_group_id:B().optional(),subcircuit_id:B().optional()}),$Ye=C1.extend({ftype:Ce("simple_capacitor"),capacitance:FYe,max_voltage_rating:FA.optional(),display_capacitance:B().optional(),max_decoupling_trace_length:Di.optional()}),jYe=C1.extend({ftype:Ce("simple_resistor"),resistance:p0e,display_resistance:B().optional()}),_0e=C1.extend({ftype:Ce("simple_diode")}),HYe=_0e.extend({ftype:Ce("simple_led"),color:B().optional(),wavelength:B().optional()}),gon=C1.extend({ftype:Ce("simple_ground")}),VYe=C1.extend({ftype:Ce("simple_chip")}),GYe=C1.extend({ftype:Ce("simple_power_source"),voltage:FA}),bon=C1.extend({ftype:Ce("simple_fuse"),current_rating_amps:Ue().describe("Nominal current in amps the fuse is rated for"),voltage_rating_volts:Ue().describe("Voltage rating in volts, e.g. ±5V would be 5")}),YYe=C1.extend({ftype:Ce("simple_battery"),capacity:mon}),qYe=C1.extend({ftype:Ce("simple_inductor"),inductance:fon,max_current_rating:Ue().optional()}),XYe=C1.extend({ftype:Ce("simple_push_button")}),WYe=C1.extend({ftype:Ce("simple_potentiometer"),max_resistance:p0e}),xon=C1.extend({ftype:Ce("simple_crystal"),frequency:Ue().describe("Frequency in Hz"),load_capacitance:Ue().optional().describe("Load capacitance in pF")}),ZYe=C1.extend({ftype:Ce("simple_pin_header"),pin_count:Ue(),gender:dn(["male","female"]).optional().default("male")}),KYe=C1.extend({ftype:Ce("simple_pinout")}),QYe=C1.extend({ftype:Ce("simple_resonator"),load_capacitance:FYe,equivalent_series_resistance:p0e.optional(),frequency:BYe}),JYe=C1.extend({ftype:Ce("simple_transistor"),transistor_type:dn(["npn","pnp"])}),eqe=C1.extend({ftype:Ce("simple_test_point"),footprint_variant:dn(["pad","through_hole"]).optional(),pad_shape:dn(["rect","circle"]).optional(),pad_diameter:oi([Ue(),B()]).optional(),hole_diameter:oi([Ue(),B()]).optional(),width:oi([Ue(),B()]).optional(),height:oi([Ue(),B()]).optional()}),tqe=C1.extend({ftype:Ce("simple_mosfet"),channel_type:dn(["n","p"]),mosfet_mode:dn(["enhancement","depletion"])}),nqe=C1.extend({ftype:Ce("simple_switch")}),iqe=Ne({type:Ce("source_project_metadata"),name:B().optional(),software_used_string:B().optional(),project_url:B().optional(),created_at:B().datetime().optional()}),von=Ne({type:Ce("source_missing_property_error"),source_missing_property_error_id:Io("source_missing_property_error"),source_component_id:B(),property_name:B(),subcircuit_id:B().optional(),error_type:Ce("source_missing_property_error").default("source_missing_property_error"),message:B()}).describe("The source code is missing a property"),won=Ne({type:Ce("source_failed_to_create_component_error"),source_failed_to_create_component_error_id:Io("source_failed_to_create_component_error"),error_type:Ce("source_failed_to_create_component_error").default("source_failed_to_create_component_error"),component_name:B().optional(),subcircuit_id:B().optional(),parent_source_component_id:B().optional(),message:B(),pcb_center:Ne({x:Ue().optional(),y:Ue().optional()}).optional(),schematic_center:Ne({x:Ue().optional(),y:Ue().optional()}).optional()}).describe("Error emitted when a component fails to be constructed"),rqe=Ne({type:Ce("source_trace_not_connected_error"),source_trace_not_connected_error_id:Io("source_trace_not_connected_error"),error_type:Ce("source_trace_not_connected_error").default("source_trace_not_connected_error"),message:B(),subcircuit_id:B().optional(),source_group_id:B().optional(),source_trace_id:B().optional(),connected_source_port_ids:Ct(B()).optional(),selectors_not_found:Ct(B()).optional()}).describe("Occurs when a source trace selector does not match any ports"),Son=Ne({type:Ce("source_property_ignored_warning"),source_property_ignored_warning_id:Io("source_property_ignored_warning"),source_component_id:B(),property_name:B(),subcircuit_id:B().optional(),error_type:Ce("source_property_ignored_warning").default("source_property_ignored_warning"),message:B()}).describe("The source property was ignored"),oqe=Ne({type:Ce("source_pin_missing_trace_warning"),source_pin_missing_trace_warning_id:Io("source_pin_missing_trace_warning"),warning_type:Ce("source_pin_missing_trace_warning").default("source_pin_missing_trace_warning"),message:B(),source_component_id:B(),source_port_id:B(),subcircuit_id:B().optional()}).describe("Warning emitted when a source component pin is missing a trace connection"),Eon=oi([jYe,$Ye,_0e,HYe,gon,VYe,GYe,YYe,qYe,XYe,WYe,xon,ZYe,KYe,QYe,nqe,JYe,eqe,tqe,bon,iqe,von,won,rqe,Son,oqe]),Ton=Ne({type:Ce("source_port"),pin_number:Ue().optional(),port_hints:Ct(B()).optional(),name:B(),source_port_id:B(),source_component_id:B(),subcircuit_id:B().optional(),subcircuit_connectivity_map_key:B().optional()}),Mon=Ne({type:Ce("source_trace"),source_trace_id:B(),connected_source_port_ids:Ct(B()),connected_source_net_ids:Ct(B()),subcircuit_id:B().optional(),subcircuit_connectivity_map_key:B().optional(),max_length:Ue().optional(),min_trace_thickness:Ue().optional(),display_name:B().optional()}),Aon=Ne({type:Ce("source_group"),source_group_id:B(),subcircuit_id:B().optional(),parent_subcircuit_id:B().optional(),parent_source_group_id:B().optional(),is_subcircuit:bt().optional(),show_as_schematic_box:bt().optional(),name:B().optional()}),Con=Ne({type:Ce("source_net"),source_net_id:B(),name:B(),member_source_group_ids:Ct(B()),is_power:bt().optional(),is_ground:bt().optional(),is_digital_signal:bt().optional(),is_analog_signal:bt().optional(),is_positive_voltage_source:bt().optional(),trace_width:Ue().optional(),subcircuit_id:B().optional(),subcircuit_connectivity_map_key:B().optional()}),Ron=Ne({type:Ce("source_pcb_ground_plane"),source_pcb_ground_plane_id:B(),source_group_id:B(),source_net_id:B(),subcircuit_id:B().optional()}).describe("Defines a ground plane in the source domain"),Pon=["top","bottom","inner1","inner2","inner3","inner4","inner5","inner6"],sqe=dn(Pon),Dh=sqe.or(Ne({name:sqe})).transform(t=>typeof t=="string"?t:t.name),PI=dn(["top","bottom"]),Ion=Ne({type:Ce("source_manually_placed_via"),source_manually_placed_via_id:B(),source_group_id:B(),source_net_id:B(),subcircuit_id:B().optional(),source_trace_id:B().optional()}).describe("Defines a via that is manually placed in the source domain"),Non=Ne({type:Ce("schematic_box"),schematic_component_id:B().optional(),width:Di,height:Di,is_dashed:bt().default(!1),x:Di,y:Di,subcircuit_id:B().optional()}).describe("Draws a box on the schematic"),kon=Ne({type:Ce("schematic_path"),schematic_component_id:B(),fill_color:dn(["red","blue"]).optional(),is_filled:bt().optional(),points:Ct(au),subcircuit_id:B().optional()}),Oon=Us(Ne({left_margin:_t.optional(),right_margin:_t.optional(),top_margin:_t.optional(),bottom_margin:_t.optional()})),Lon=Ne({left_size:Ue(),right_size:Ue(),top_size:Ue().optional(),bottom_size:Ue().optional()}),Don=Ne({left_side:Ne({pins:Ct(Ue()),direction:dn(["top-to-bottom","bottom-to-top"]).optional()}).optional(),right_side:Ne({pins:Ct(Ue()),direction:dn(["top-to-bottom","bottom-to-top"]).optional()}).optional(),top_side:Ne({pins:Ct(Ue()),direction:dn(["left-to-right","right-to-left"]).optional()}).optional(),bottom_side:Ne({pins:Ct(Ue()),direction:dn(["left-to-right","right-to-left"]).optional()}).optional()}),zon=oi([Lon,Don]),Fon=Ne({type:Ce("schematic_component"),size:UYe,center:au,source_component_id:B().optional(),schematic_component_id:B(),pin_spacing:_t.optional(),pin_styles:Oon.optional(),box_width:_t.optional(),symbol_name:B().optional(),port_arrangement:zon.optional(),port_labels:Us(B()).optional(),symbol_display_value:B().optional(),subcircuit_id:B().optional(),schematic_group_id:B().optional(),is_schematic_group:bt().optional(),source_group_id:B().optional()}),Bon=Ne({type:Ce("schematic_line"),schematic_component_id:B(),x1:Di,x2:Di,y1:Di,y2:Di,subcircuit_id:B().optional()}),Uon=Ne({type:Ce("schematic_trace"),schematic_trace_id:B(),source_trace_id:B().optional(),junctions:Ct(Ne({x:Ue(),y:Ue()})),edges:Ct(Ne({from:Ne({x:Ue(),y:Ue()}),to:Ne({x:Ue(),y:Ue()}),is_crossing:bt().optional(),from_schematic_port_id:B().optional(),to_schematic_port_id:B().optional()})),subcircuit_id:B().optional(),subcircuit_connectivity_map_key:B().optional()}),$on=dn(["center","left","right","top","bottom"]),jon=Ne({type:Ce("schematic_text"),schematic_component_id:B().optional(),schematic_text_id:B(),text:B(),font_size:Ue().default(.18),position:Ne({x:Di,y:Di}),rotation:Ue().default(0),anchor:oi([$on.describe("legacy"),m0e]).default("center"),color:B().default("#000000"),subcircuit_id:B().optional()}),Hon=Ne({type:Ce("schematic_port"),schematic_port_id:B(),source_port_id:B(),schematic_component_id:B().optional(),center:au,facing_direction:dn(["up","down","left","right"]).optional(),distance_from_component_edge:Ue().optional(),side_of_component:dn(["top","bottom","left","right"]).optional(),true_ccw_index:Ue().optional(),pin_number:Ue().optional(),display_pin_label:B().optional(),subcircuit_id:B().optional(),is_connected:bt().optional(),has_input_arrow:bt().optional(),has_output_arrow:bt().optional()}).describe("Defines a port on a schematic component"),Von=Ne({type:Ce("schematic_net_label"),schematic_net_label_id:Io("schematic_net_label"),schematic_trace_id:B().optional(),source_trace_id:B().optional(),source_net_id:B(),center:au,anchor_position:au.optional(),anchor_side:dn(["top","bottom","left","right"]),text:B(),symbol_name:B().optional(),is_movable:bt().optional(),subcircuit_id:B().optional()}),Gon=Ne({type:Ce("schematic_error"),schematic_error_id:B(),error_type:Ce("schematic_port_not_found").default("schematic_port_not_found"),message:B(),subcircuit_id:B().optional()}).describe("Defines a schematic error on the schematic"),Yon=Ne({type:Ce("schematic_layout_error"),schematic_layout_error_id:Io("schematic_layout_error"),error_type:Ce("schematic_layout_error").default("schematic_layout_error"),message:B(),source_group_id:B(),schematic_group_id:B(),subcircuit_id:B().optional()}).describe("Error emitted when schematic layout fails for a group"),y0e=Ne({type:Ce("schematic_debug_object"),label:B().optional(),subcircuit_id:B().optional()}),qon=y0e.extend({shape:Ce("rect"),center:au,size:UYe}),Xon=y0e.extend({shape:Ce("line"),start:au,end:au}),Won=y0e.extend({shape:Ce("point"),center:au}),Zon=uy("shape",[qon,Xon,Won]),Kon=Ne({type:Ce("schematic_voltage_probe"),schematic_voltage_probe_id:B(),position:au,schematic_trace_id:B(),voltage:FA.optional(),subcircuit_id:B().optional()}).describe("Defines a voltage probe measurement point on a schematic trace"),Qon=Ne({type:Ce("schematic_manual_edit_conflict_warning"),schematic_manual_edit_conflict_warning_id:Io("schematic_manual_edit_conflict_warning"),warning_type:Ce("schematic_manual_edit_conflict_warning").default("schematic_manual_edit_conflict_warning"),message:B(),schematic_component_id:B(),schematic_group_id:B().optional(),subcircuit_id:B().optional(),source_component_id:B()}).describe("Warning emitted when a component has both manual placement and explicit schX/schY coordinates"),Jon=Ne({type:Ce("schematic_group"),schematic_group_id:Io("schematic_group"),source_group_id:B(),is_subcircuit:bt().optional(),subcircuit_id:B().optional(),width:_t,height:_t,center:au,schematic_component_ids:Ct(B()),show_as_schematic_box:bt().optional(),name:B().optional(),description:B().optional()}).describe("Defines a group of components on the schematic"),esn=Ne({type:Ce("schematic_table"),schematic_table_id:Io("schematic_table"),anchor_position:au,column_widths:Ct(Di),row_heights:Ct(Di),cell_padding:Di.optional(),border_width:Di.optional(),subcircuit_id:B().optional(),schematic_component_id:B().optional(),anchor:m0e.optional()}).describe("Defines a table on the schematic"),tsn=Ne({type:Ce("schematic_table_cell"),schematic_table_cell_id:Io("schematic_table_cell"),schematic_table_id:B(),start_row_index:Ue(),end_row_index:Ue(),start_column_index:Ue(),end_column_index:Ue(),text:B().optional(),center:au,width:Di,height:Di,horizontal_align:dn(["left","center","right"]).optional(),vertical_align:dn(["top","middle","bottom"]).optional(),font_size:Di.optional(),subcircuit_id:B().optional()}).describe("Defines a cell within a schematic_table"),nsn=Ne({x:Di,y:Di,bulge:Ue().optional()}),aqe=Ne({vertices:Ct(nsn)}),isn=Ne({outer_ring:aqe,inner_rings:Ct(aqe).default([])}),rsn=Ne({x:Di,y:Di,via:bt().optional(),via_to_layer:Dh.optional()});Ct(rsn);var osn=Ne({x:Di,y:Di,via:bt().optional(),to_layer:Dh.optional(),trace_width:Di.optional()}),ssn=Ne({type:Ce("pcb_component"),pcb_component_id:Io("pcb_component"),source_component_id:B(),center:au,layer:Dh,rotation:n3,width:_t,height:_t,subcircuit_id:B().optional(),pcb_group_id:B().optional()}).describe("Defines a component on the PCB"),cqe=Ne({type:Ce("pcb_hole"),pcb_hole_id:Io("pcb_hole"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),hole_shape:dn(["circle","square"]),hole_diameter:Ue(),x:Di,y:Di});cqe.describe("Defines a circular or square hole on the PCB");var lqe=Ne({type:Ce("pcb_hole"),pcb_hole_id:Io("pcb_hole"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),hole_shape:Ce("oval"),hole_width:Ue(),hole_height:Ue(),x:Di,y:Di});lqe.describe("Defines an oval hole on the PCB");var asn=cqe.or(lqe),csn=Ne({type:Ce("pcb_plated_hole"),shape:Ce("circle"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),outer_diameter:Ue(),hole_diameter:Ue(),x:Di,y:Di,layers:Ct(Dh),port_hints:Ct(B()).optional(),pcb_component_id:B().optional(),pcb_port_id:B().optional(),pcb_plated_hole_id:Io("pcb_plated_hole")}),lsn=Ne({type:Ce("pcb_plated_hole"),shape:dn(["oval","pill"]),pcb_group_id:B().optional(),subcircuit_id:B().optional(),outer_width:Ue(),outer_height:Ue(),hole_width:Ue(),hole_height:Ue(),x:Di,y:Di,ccw_rotation:n3,layers:Ct(Dh),port_hints:Ct(B()).optional(),pcb_component_id:B().optional(),pcb_port_id:B().optional(),pcb_plated_hole_id:Io("pcb_plated_hole")}),usn=Ne({type:Ce("pcb_plated_hole"),shape:Ce("circular_hole_with_rect_pad"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),hole_shape:Ce("circle"),pad_shape:Ce("rect"),hole_diameter:Ue(),rect_pad_width:Ue(),rect_pad_height:Ue(),rect_border_radius:Ue().optional(),hole_offset_x:Di.default(0),hole_offset_y:Di.default(0),x:Di,y:Di,layers:Ct(Dh),port_hints:Ct(B()).optional(),pcb_component_id:B().optional(),pcb_port_id:B().optional(),pcb_plated_hole_id:Io("pcb_plated_hole")}),dsn=Ne({type:Ce("pcb_plated_hole"),shape:Ce("pill_hole_with_rect_pad"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),hole_shape:Ce("pill"),pad_shape:Ce("rect"),hole_width:Ue(),hole_height:Ue(),rect_pad_width:Ue(),rect_pad_height:Ue(),rect_border_radius:Ue().optional(),x:Di,y:Di,layers:Ct(Dh),port_hints:Ct(B()).optional(),pcb_component_id:B().optional(),pcb_port_id:B().optional(),pcb_plated_hole_id:Io("pcb_plated_hole")}),hsn=Ne({type:Ce("pcb_plated_hole"),shape:Ce("rotated_pill_hole_with_rect_pad"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),hole_shape:Ce("rotated_pill"),pad_shape:Ce("rect"),hole_width:Ue(),hole_height:Ue(),hole_ccw_rotation:n3,rect_pad_width:Ue(),rect_pad_height:Ue(),rect_border_radius:Ue().optional(),rect_ccw_rotation:n3,x:Di,y:Di,layers:Ct(Dh),port_hints:Ct(B()).optional(),pcb_component_id:B().optional(),pcb_port_id:B().optional(),pcb_plated_hole_id:Io("pcb_plated_hole")}),psn=oi([csn,lsn,usn,dsn,hsn]),fsn=Ne({type:Ce("pcb_port"),pcb_port_id:Io("pcb_port"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),source_port_id:B(),pcb_component_id:B(),x:Di,y:Di,layers:Ct(Dh),is_board_pinout:bt().optional()}).describe("Defines a port on the PCB"),msn=Ne({type:Ce("pcb_smtpad"),shape:Ce("circle"),pcb_smtpad_id:Io("pcb_smtpad"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),x:Di,y:Di,radius:Ue(),layer:Dh,port_hints:Ct(B()).optional(),pcb_component_id:B().optional(),pcb_port_id:B().optional(),is_covered_with_solder_mask:bt().optional()}),_sn=Ne({type:Ce("pcb_smtpad"),shape:Ce("rect"),pcb_smtpad_id:Io("pcb_smtpad"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),x:Di,y:Di,width:Ue(),height:Ue(),rect_border_radius:Ue().optional(),layer:Dh,port_hints:Ct(B()).optional(),pcb_component_id:B().optional(),pcb_port_id:B().optional(),is_covered_with_solder_mask:bt().optional()}),ysn=Ne({type:Ce("pcb_smtpad"),shape:Ce("rotated_rect"),pcb_smtpad_id:Io("pcb_smtpad"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),x:Di,y:Di,width:Ue(),height:Ue(),rect_border_radius:Ue().optional(),ccw_rotation:n3,layer:Dh,port_hints:Ct(B()).optional(),pcb_component_id:B().optional(),pcb_port_id:B().optional(),is_covered_with_solder_mask:bt().optional()}),gsn=Ne({type:Ce("pcb_smtpad"),shape:Ce("pill"),pcb_smtpad_id:Io("pcb_smtpad"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),x:Di,y:Di,width:Ue(),height:Ue(),radius:Ue(),layer:Dh,port_hints:Ct(B()).optional(),pcb_component_id:B().optional(),pcb_port_id:B().optional(),is_covered_with_solder_mask:bt().optional()}),bsn=Ne({type:Ce("pcb_smtpad"),shape:Ce("rotated_pill"),pcb_smtpad_id:Io("pcb_smtpad"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),x:Di,y:Di,width:Ue(),height:Ue(),radius:Ue(),ccw_rotation:n3,layer:Dh,port_hints:Ct(B()).optional(),pcb_component_id:B().optional(),pcb_port_id:B().optional(),is_covered_with_solder_mask:bt().optional()}),xsn=Ne({type:Ce("pcb_smtpad"),shape:Ce("polygon"),pcb_smtpad_id:Io("pcb_smtpad"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),points:Ct(au),layer:Dh,port_hints:Ct(B()).optional(),pcb_component_id:B().optional(),pcb_port_id:B().optional(),is_covered_with_solder_mask:bt().optional()}),vsn=uy("shape",[msn,_sn,ysn,bsn,gsn,xsn]).describe("Defines an SMT pad on the PCB"),wsn=Ne({type:Ce("pcb_solder_paste"),shape:Ce("circle"),pcb_solder_paste_id:Io("pcb_solder_paste"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),x:Di,y:Di,radius:Ue(),layer:Dh,pcb_component_id:B().optional(),pcb_smtpad_id:B().optional()}),Ssn=Ne({type:Ce("pcb_solder_paste"),shape:Ce("rect"),pcb_solder_paste_id:Io("pcb_solder_paste"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),x:Di,y:Di,width:Ue(),height:Ue(),layer:Dh,pcb_component_id:B().optional(),pcb_smtpad_id:B().optional()}),Esn=Ne({type:Ce("pcb_solder_paste"),shape:Ce("pill"),pcb_solder_paste_id:Io("pcb_solder_paste"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),x:Di,y:Di,width:Ue(),height:Ue(),radius:Ue(),layer:Dh,pcb_component_id:B().optional(),pcb_smtpad_id:B().optional()}),Tsn=Ne({type:Ce("pcb_solder_paste"),shape:Ce("rotated_rect"),pcb_solder_paste_id:Io("pcb_solder_paste"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),x:Di,y:Di,width:Ue(),height:Ue(),ccw_rotation:Di,layer:Dh,pcb_component_id:B().optional(),pcb_smtpad_id:B().optional()}),Msn=Ne({type:Ce("pcb_solder_paste"),shape:Ce("oval"),pcb_solder_paste_id:Io("pcb_solder_paste"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),x:Di,y:Di,width:Ue(),height:Ue(),layer:Dh,pcb_component_id:B().optional(),pcb_smtpad_id:B().optional()}),Asn=oi([wsn,Ssn,Esn,Tsn,Msn]).describe("Defines solderpaste on the PCB"),Csn=Ne({type:Ce("pcb_text"),pcb_text_id:Io("pcb_text"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),text:B(),center:au,layer:Dh,width:_t,height:_t,lines:Ue(),align:dn(["bottom-left"])}).describe("Defines text on the PCB"),Rsn=Ne({route_type:Ce("wire"),x:Di,y:Di,width:Di,start_pcb_port_id:B().optional(),end_pcb_port_id:B().optional(),layer:Dh}),Psn=Ne({route_type:Ce("via"),x:Di,y:Di,hole_diameter:Di.optional(),outer_diameter:Di.optional(),from_layer:B(),to_layer:B()}),Isn=oi([Rsn,Psn]),Nsn=Ne({type:Ce("pcb_trace"),source_trace_id:B().optional(),pcb_component_id:B().optional(),pcb_trace_id:Io("pcb_trace"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),route_thickness_mode:dn(["constant","interpolated"]).default("constant").optional(),route_order_index:Ue().optional(),should_round_corners:bt().optional(),trace_length:Ue().optional(),route:Ct(Isn)}).describe("Defines a trace on the PCB"),ksn=Ne({type:Ce("pcb_trace_error"),pcb_trace_error_id:Io("pcb_trace_error"),error_type:Ce("pcb_trace_error").default("pcb_trace_error"),message:B(),center:au.optional(),pcb_trace_id:B(),source_trace_id:B(),pcb_component_ids:Ct(B()),pcb_port_ids:Ct(B()),subcircuit_id:B().optional()}).describe("Defines a trace error on the PCB"),Osn=Ne({type:Ce("pcb_trace_missing_error"),pcb_trace_missing_error_id:Io("pcb_trace_missing_error"),error_type:Ce("pcb_trace_missing_error").default("pcb_trace_missing_error"),message:B(),center:au.optional(),source_trace_id:B(),pcb_component_ids:Ct(B()),pcb_port_ids:Ct(B()),subcircuit_id:B().optional()}).describe("Defines an error when a source trace has no corresponding PCB trace"),Lsn=Ne({type:Ce("pcb_port_not_matched_error"),pcb_error_id:Io("pcb_error"),error_type:Ce("pcb_port_not_matched_error").default("pcb_port_not_matched_error"),message:B(),pcb_component_ids:Ct(B()),subcircuit_id:B().optional()}).describe("Defines a trace error on the PCB where a port is not matched"),Dsn=Ne({type:Ce("pcb_port_not_connected_error"),pcb_port_not_connected_error_id:Io("pcb_port_not_connected_error"),error_type:Ce("pcb_port_not_connected_error").default("pcb_port_not_connected_error"),message:B(),pcb_port_ids:Ct(B()),pcb_component_ids:Ct(B()),subcircuit_id:B().optional()}).describe("Defines an error when a pcb port is not connected to any trace"),zsn=Ne({type:Ce("pcb_via"),pcb_via_id:Io("pcb_via"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),x:Di,y:Di,outer_diameter:Di.default("0.6mm"),hole_diameter:Di.default("0.25mm"),from_layer:Dh.optional(),to_layer:Dh.optional(),layers:Ct(Dh),pcb_trace_id:B().optional()}).describe("Defines a via on the PCB"),Fsn=Ne({type:Ce("pcb_board"),pcb_board_id:Io("pcb_board"),is_subcircuit:bt().optional(),subcircuit_id:B().optional(),width:_t,height:_t,center:au,thickness:_t.optional().default(1.4),num_layers:Ue().optional().default(4),outline:Ct(au).optional(),material:dn(["fr4","fr1"]).default("fr4")}).describe("Defines the board outline of the PCB"),Bsn=Ne({type:Ce("pcb_placement_error"),pcb_placement_error_id:Io("pcb_placement_error"),error_type:Ce("pcb_placement_error").default("pcb_placement_error"),message:B(),subcircuit_id:B().optional()}).describe("Defines a placement error on the PCB"),Usn=Ne({type:Ce("pcb_trace_hint"),pcb_trace_hint_id:Io("pcb_trace_hint"),pcb_port_id:B(),pcb_component_id:B(),route:Ct(osn),subcircuit_id:B().optional()}).describe("A hint that can be used during generation of a PCB trace"),$sn=Ne({type:Ce("pcb_silkscreen_line"),pcb_silkscreen_line_id:Io("pcb_silkscreen_line"),pcb_component_id:B(),pcb_group_id:B().optional(),subcircuit_id:B().optional(),stroke_width:Di.default("0.1mm"),x1:Di,y1:Di,x2:Di,y2:Di,layer:PI}).describe("Defines a silkscreen line on the PCB"),jsn=Ne({type:Ce("pcb_silkscreen_path"),pcb_silkscreen_path_id:Io("pcb_silkscreen_path"),pcb_component_id:B(),pcb_group_id:B().optional(),subcircuit_id:B().optional(),layer:PI,route:Ct(au),stroke_width:_t}).describe("Defines a silkscreen path on the PCB"),Hsn=Ne({type:Ce("pcb_silkscreen_text"),pcb_silkscreen_text_id:Io("pcb_silkscreen_text"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),font:Ce("tscircuit2024").default("tscircuit2024"),font_size:Di.default("0.2mm"),pcb_component_id:B(),text:B(),is_knockout:bt().default(!1).optional(),knockout_padding:Ne({left:_t,top:_t,bottom:_t,right:_t}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:Ue().optional(),layer:Dh,is_mirrored:bt().default(!1).optional(),anchor_position:au.default({x:0,y:0}),anchor_alignment:m0e.default("center")}).describe("Defines silkscreen text on the PCB"),Vsn=Ne({type:Ce("pcb_silkscreen_rect"),pcb_silkscreen_rect_id:Io("pcb_silkscreen_rect"),pcb_component_id:B(),pcb_group_id:B().optional(),subcircuit_id:B().optional(),center:au,width:_t,height:_t,layer:Dh,stroke_width:_t.default("1mm"),is_filled:bt().default(!0).optional(),has_stroke:bt().optional(),is_stroke_dashed:bt().optional()}).describe("Defines a silkscreen rect on the PCB"),Gsn=Ne({type:Ce("pcb_silkscreen_circle"),pcb_silkscreen_circle_id:Io("pcb_silkscreen_circle"),pcb_component_id:B(),pcb_group_id:B().optional(),subcircuit_id:B().optional(),center:au,radius:_t,layer:PI,stroke_width:_t.default("1mm")}).describe("Defines a silkscreen circle on the PCB"),Ysn=Ne({type:Ce("pcb_silkscreen_oval"),pcb_silkscreen_oval_id:Io("pcb_silkscreen_oval"),pcb_component_id:B(),pcb_group_id:B().optional(),subcircuit_id:B().optional(),center:au,radius_x:Di,radius_y:Di,layer:PI}).describe("Defines a silkscreen oval on the PCB"),qsn=Ne({type:Ce("pcb_fabrication_note_text"),pcb_fabrication_note_text_id:Io("pcb_fabrication_note_text"),subcircuit_id:B().optional(),pcb_group_id:B().optional(),font:Ce("tscircuit2024").default("tscircuit2024"),font_size:Di.default("1mm"),pcb_component_id:B(),text:B(),layer:PI,anchor_position:au.default({x:0,y:0}),anchor_alignment:dn(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:B().optional()}).describe("Defines a fabrication note in text on the PCB, useful for leaving notes for assemblers or fabricators"),Xsn=Ne({type:Ce("pcb_fabrication_note_path"),pcb_fabrication_note_path_id:Io("pcb_fabrication_note_path"),pcb_component_id:B(),subcircuit_id:B().optional(),layer:Dh,route:Ct(au),stroke_width:_t,color:B().optional()}).describe("Defines a fabrication path on the PCB for fabricators or assemblers"),Wsn=Ne({type:Ce("pcb_footprint_overlap_error"),pcb_error_id:Io("pcb_error"),error_type:Ce("pcb_footprint_overlap_error").default("pcb_footprint_overlap_error"),message:B(),pcb_smtpad_ids:Ct(B()).optional(),pcb_plated_hole_ids:Ct(B()).optional(),pcb_hole_ids:Ct(B()).optional(),pcb_keepout_ids:Ct(B()).optional()}).describe("Error emitted when a pcb footprint overlaps with another element"),Zsn=Ne({type:Ce("pcb_keepout"),shape:Ce("rect"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),center:au,width:Di,height:Di,pcb_keepout_id:B(),layers:Ct(B()),description:B().optional()}).or(Ne({type:Ce("pcb_keepout"),shape:Ce("circle"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),center:au,radius:Di,pcb_keepout_id:B(),layers:Ct(B()),description:B().optional()})),g0e=Ne({type:Ce("pcb_cutout"),pcb_cutout_id:Io("pcb_cutout"),pcb_group_id:B().optional(),subcircuit_id:B().optional()}),Ksn=g0e.extend({shape:Ce("rect"),center:au,width:_t,height:_t,rotation:n3.optional()}),Qsn=g0e.extend({shape:Ce("circle"),center:au,radius:_t}),Jsn=g0e.extend({shape:Ce("polygon"),points:Ct(au)}),ean=uy("shape",[Ksn,Qsn,Jsn]).describe("Defines a cutout on the PCB, removing board material."),tan=Ne({type:Ce("pcb_missing_footprint_error"),pcb_missing_footprint_error_id:Io("pcb_missing_footprint_error"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),error_type:Ce("pcb_missing_footprint_error").default("pcb_missing_footprint_error"),source_component_id:B(),message:B()}).describe("Defines a missing footprint error on the PCB"),nan=Ne({type:Ce("external_footprint_load_error"),external_footprint_load_error_id:Io("external_footprint_load_error"),pcb_component_id:B(),source_component_id:B(),pcb_group_id:B().optional(),subcircuit_id:B().optional(),footprinter_string:B().optional(),error_type:Ce("external_footprint_load_error").default("external_footprint_load_error"),message:B()}).describe("Defines an error when an external footprint fails to load"),ian=Ne({type:Ce("pcb_group"),pcb_group_id:Io("pcb_group"),source_group_id:B(),is_subcircuit:bt().optional(),subcircuit_id:B().optional(),width:_t,height:_t,center:au,pcb_component_ids:Ct(B()),name:B().optional(),description:B().optional(),layout_mode:B().optional(),autorouter_configuration:Ne({trace_clearance:_t}).optional(),autorouter_used_string:B().optional()}).describe("Defines a group of components on the PCB"),ran=Ne({type:Ce("pcb_autorouting_error"),pcb_error_id:Io("pcb_autorouting_error"),error_type:Ce("pcb_autorouting_error").default("pcb_autorouting_error"),message:B(),subcircuit_id:B().optional()}).describe("The autorouting has failed to route a portion of the board"),oan=Ne({type:Ce("pcb_manual_edit_conflict_warning"),pcb_manual_edit_conflict_warning_id:Io("pcb_manual_edit_conflict_warning"),warning_type:Ce("pcb_manual_edit_conflict_warning").default("pcb_manual_edit_conflict_warning"),message:B(),pcb_component_id:B(),pcb_group_id:B().optional(),subcircuit_id:B().optional(),source_component_id:B()}).describe("Warning emitted when a component has both manual placement and explicit pcbX/pcbY coordinates"),san=Ne({type:Ce("pcb_breakout_point"),pcb_breakout_point_id:Io("pcb_breakout_point"),pcb_group_id:B(),subcircuit_id:B().optional(),source_trace_id:B().optional(),source_port_id:B().optional(),source_net_id:B().optional(),x:Di,y:Di}).describe("Defines a routing target within a pcb_group for a source_trace or source_net"),aan=Ne({type:Ce("pcb_ground_plane"),pcb_ground_plane_id:Io("pcb_ground_plane"),source_pcb_ground_plane_id:B(),source_net_id:B(),pcb_group_id:B().optional(),subcircuit_id:B().optional()}).describe("Defines a ground plane on the PCB"),can=Ne({type:Ce("pcb_ground_plane_region"),pcb_ground_plane_region_id:Io("pcb_ground_plane_region"),pcb_ground_plane_id:B(),pcb_group_id:B().optional(),subcircuit_id:B().optional(),layer:Dh,points:Ct(au)}).describe("Defines a polygon region of a ground plane"),lan=Ne({type:Ce("pcb_thermal_spoke"),pcb_thermal_spoke_id:Io("pcb_thermal_spoke"),pcb_ground_plane_id:B(),shape:B(),spoke_count:Ue(),spoke_thickness:Di,spoke_inner_diameter:Di,spoke_outer_diameter:Di,pcb_plated_hole_id:B().optional(),subcircuit_id:B().optional()}).describe("Pattern for connecting a ground plane to a plated hole"),b0e=Ne({type:Ce("pcb_copper_pour"),pcb_copper_pour_id:Io("pcb_copper_pour"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),layer:Dh,source_net_id:B().optional()}),uan=b0e.extend({shape:Ce("rect"),center:au,width:_t,height:_t,rotation:n3.optional()}),dan=b0e.extend({shape:Ce("brep"),brep_shape:isn}),han=b0e.extend({shape:Ce("polygon"),points:Ct(au)}),pan=uy("shape",[uan,dan,han]).describe("Defines a copper pour on the PCB."),fan=Ne({type:Ce("pcb_component_outside_board_error"),pcb_component_outside_board_error_id:Io("pcb_component_outside_board_error"),error_type:Ce("pcb_component_outside_board_error").default("pcb_component_outside_board_error"),message:B(),pcb_component_id:B(),pcb_board_id:B(),component_center:au,component_bounds:Ne({min_x:Ue(),max_x:Ue(),min_y:Ue(),max_y:Ue()}),subcircuit_id:B().optional(),source_component_id:B().optional()}).describe("Error emitted when a PCB component is placed outside the board boundaries"),man=Ne({type:Ce("cad_component"),cad_component_id:B(),pcb_component_id:B(),source_component_id:B(),position:f0e,rotation:f0e.optional(),size:f0e.optional(),layer:Dh.optional(),subcircuit_id:B().optional(),footprinter_string:B().optional(),model_obj_url:B().optional(),model_stl_url:B().optional(),model_3mf_url:B().optional(),model_gltf_url:B().optional(),model_glb_url:B().optional(),model_step_url:B().optional(),model_wrl_url:B().optional(),model_unit_to_mm_scale_factor:Ue().optional(),model_jscad:jd().optional()}).describe("Defines a component on the PCB"),_an=dn(["sinewave","square","triangle","sawtooth"]),yan=oi([B(),Ue()]).transform(t=>typeof t=="string"?t.endsWith("%")?parseFloat(t.slice(0,-1))/100:parseFloat(t):t).pipe(Ue().min(0,"Duty cycle must be non-negative").max(1,"Duty cycle cannot be greater than 100%")),gan=Ne({type:Ce("simulation_voltage_source"),simulation_voltage_source_id:Io("simulation_voltage_source"),is_dc_source:Ce(!0).optional().default(!0),positive_source_port_id:B().optional(),negative_source_port_id:B().optional(),positive_source_net_id:B().optional(),negative_source_net_id:B().optional(),voltage:FA}).describe("Defines a DC voltage source for simulation"),ban=Ne({type:Ce("simulation_voltage_source"),simulation_voltage_source_id:Io("simulation_voltage_source"),is_dc_source:Ce(!1),terminal1_source_port_id:B().optional(),terminal2_source_port_id:B().optional(),terminal1_source_net_id:B().optional(),terminal2_source_net_id:B().optional(),voltage:FA.optional(),frequency:BYe.optional(),peak_to_peak_voltage:FA.optional(),wave_shape:_an.optional(),phase:n3.optional(),duty_cycle:yan.optional()}).describe("Defines an AC voltage source for simulation"),xan=oi([gan,ban]).describe("Defines a voltage source for simulation");oi([Mon,Ton,Eon,Con,Aon,VYe,$Ye,_0e,HYe,jYe,GYe,YYe,qYe,ZYe,KYe,QYe,nqe,JYe,eqe,tqe,WYe,XYe,Ron,Ion,iqe,rqe,oqe,ssn,asn,tan,nan,oan,psn,Zsn,fsn,Csn,Nsn,zsn,vsn,Asn,Fsn,ian,Usn,$sn,jsn,Hsn,Vsn,Gsn,Ysn,ksn,Osn,Bsn,Lsn,Dsn,Xsn,qsn,ran,Wsn,san,ean,aan,can,lan,pan,fan,Non,jon,Bon,Fon,Hon,Uon,kon,Gon,Yon,Von,Zon,Kon,Qon,Jon,esn,tsn,man,xan]);var van=Object.defineProperty,wan=(t,e)=>{for(var n in e)van(t,n,{get:e[n],enumerable:!0})},i3={};wan(i3,{axial:()=>wcn,bga:()=>Oan,breakoutheaders:()=>Ncn,cap:()=>Ran,dfn:()=>icn,diode:()=>Can,dip:()=>Tan,electrolytic:()=>fdn,hc49:()=>Ocn,jst:()=>Fun,led:()=>Pan,lqfp:()=>Pcn,m2host:()=>Idn,melf:()=>qln,micromelf:()=>Kln,minimelf:()=>Bln,mlp:()=>jan,ms012:()=>ucn,ms013:()=>hcn,msop:()=>Xun,pad:()=>Lcn,pinrow:()=>scn,platedhole:()=>Mdn,potentiometer:()=>ddn,pushbutton:()=>Ecn,qfn:()=>Uan,qfp:()=>$an,quad:()=>II,res:()=>Ian,sma:()=>tun,smb:()=>lun,smbf:()=>_dn,smc:()=>pun,smf:()=>oun,smtpad:()=>Edn,sod110:()=>Uun,sod123:()=>gcn,sod123f:()=>yln,sod123fl:()=>vln,sod123w:()=>Kcn,sod128:()=>Rln,sod323:()=>tln,sod323f:()=>pln,sod323fl:()=>edn,sod323w:()=>Zun,sod523:()=>$cn,sod723:()=>Tln,sod80:()=>qcn,sod882:()=>lln,sod882d:()=>Hln,sod923:()=>oln,soic:()=>Dan,solderjumper:()=>odn,son:()=>rdn,sop8:()=>Gcn,sot:()=>Cdn,sot223:()=>yun,sot23:()=>Zan,sot23w:()=>Mun,sot25:()=>ecn,sot323:()=>xdn,sot363:()=>Xan,sot457:()=>cdn,sot563:()=>ccn,sot723:()=>fcn,sot89:()=>Lln,ssop:()=>Van,stampboard:()=>Mcn,stampreceiver:()=>Rcn,to220:()=>zln,to92:()=>Bcn,to92s:()=>Nun,tssop:()=>Yan,vssop:()=>Gun});var zo=(t,e,n)=>({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:"silkscreen_text_1",font:"tscircuit2024",font_size:n,pcb_component_id:"pcb_component_1",text:"{REF}",layer:"top",anchor_position:{x:t,y:e},anchor_alignment:"center"}),Aa=(t,e,n,i,r)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circle",x:e,y:n,hole_diameter:dh(i),outer_diameter:dh(r),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()]}),uqe=Array.from({length:9},(t,e)=>Math.cos(e/8*Math.PI-Math.PI)).map(t=>({x:t,y:-Math.sqrt(1-t**2)}));function Y4(t){return typeof t=="string"?t.trim().toLowerCase().endsWith("mil")?parseFloat(t)*.0254:parseFloat(t):Number(t)}var J$=oi([B(),Ue()]).transform(t=>Y4(t)),San=t=>Ne({fn:B(),num_pins:Ue().optional().default(6),wide:bt().optional(),narrow:bt().optional(),w:J$.optional(),p:J$.default(t.p??"2.54mm"),id:J$.optional(),od:J$.optional()}).transform(e=>(!e.id&&!e.od?Math.abs(e.p-1.27)<.01?(e.id=Y4("0.55mm"),e.od=Y4("0.95mm")):(e.id=Y4("1.0mm"),e.od=Y4("1.5mm")):e.id?e.od||(e.od=e.id*(1.5/1)):e.id=e.od*(1/1.5),e.w||(e.wide?e.w=Y4("600mil"):e.narrow?e.w=Y4("300mil"):e.w=Y4(t.w??"300mil")),e)),Ean=San({}),dqe=(t,e,n,i)=>{const r=t/2,o=e<=r,s=r-1,a=i,c=a*s;return o?{x:-n/2,y:c/2-(e-1)*a}:{x:n/2,y:-c/2+(e-r-1)*a}},Tan=t=>{const e=Ean.parse(t),n=[];for(let l=0;l<e.num_pins;l++){const{x:u,y:d}=dqe(e.num_pins,l+1,e.w,e.p??2.54);n.push(Aa(l+1,u,d,e.id??"0.8mm",e.od??"1mm"))}(e.num_pins/2-1)*e.p+e.od;const r=e.w-e.od-1,o=(e.num_pins/2-1)*e.p+e.od+.4,s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-r/2,y:-o/2},{x:-r/2,y:o/2},...uqe.map(({x:l,y:u})=>({x:l*r/6,y:u*r/6+o/2})),{x:r/2,y:o/2},{x:r/2,y:-o/2},{x:-r/2,y:-o/2}],type:"pcb_silkscreen_path",stroke_width:.1},a=[];for(let l=0;l<e.num_pins;l++){const u=l<e.num_pins/2,d=.6,{y:h}=dqe(e.num_pins,l+1,e.w,e.p??2.54),f=u?-e.w/2-e.od/2-d:e.w/2+e.od/2+d,m=h;a.push({type:"pcb_fabrication_note_text",pcb_fabrication_note_text_id:`pin_${l+1}`,layer:"top",pcb_component_id:`pin_${l+1}`,text:`{pin${l+1}}`,anchor_position:{x:f,y:m},font_size:.3,font:"tscircuit2024",anchor_alignment:"top_left"})}const c=zo(0,o/2+.5,.4);return{circuitJson:[...n,s,c,...a],parameters:e}},Dr=(t,e,n,i,r)=>({type:"pcb_smtpad",x:e,y:n,width:i,height:r,layer:"top",shape:"rect",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(o=>o.toString()):[t.toString()]}),hqe=[{imperial:"01005",metric:"0402",p_mm_min:.5,pw_mm_min:.4,ph_mm_min:.3,w_mm_min:.58,h_mm_min:.21},{imperial:"0504",metric:"1310",p_mm_min:1.1,pw_mm_min:.65,ph_mm_min:1.3,w_mm_min:.58,h_mm_min:.21},{imperial:"1812",metric:"4532",p_mm_min:4.275,pw_mm_min:1.125,ph_mm_min:3.4,w_mm_min:5.4,h_mm_min:3.4},{imperial:"0201",metric:"0603",p_mm_min:.66,pw_mm_min:.46,ph_mm_min:.4,w_mm_min:.9,h_mm_min:.3},{imperial:"0402",metric:"1005",p_mm_min:1.02,pw_mm_min:.54,ph_mm_min:.64,w_mm_min:1.56,h_mm_min:.64},{imperial:"0603",metric:"1608",p_mm_min:1.65,pw_mm_min:.8,ph_mm_min:.95,w_mm_min:2.45,h_mm_min:.95},{imperial:"0805",metric:"2012",p_mm_min:1.825,pw_mm_min:1.025,ph_mm_min:1.4,w_mm_min:2.8499999999999996,h_mm_min:1.4},{imperial:"1206",metric:"3216",p_mm_min:2.925,pw_mm_min:1.125,ph_mm_min:1.75,w_mm_min:4.05,h_mm_min:1.75},{imperial:"1210",metric:"3225",p_mm_min:2.925,pw_mm_min:1.125,ph_mm_min:2.65,w_mm_min:4.05,h_mm_min:2.65},{imperial:"2010",metric:"5025",p_mm_min:4.625,pw_mm_min:1.225,ph_mm_min:2.65,w_mm_min:5.85,h_mm_min:2.65},{imperial:"2512",metric:"6332",p_mm_min:5.925,pw_mm_min:1.225,ph_mm_min:3.35,w_mm_min:7.15,h_mm_min:3.35}],Man=Object.fromEntries(hqe.map(t=>[t.metric,t])),Aan=Object.fromEntries(hqe.map(t=>[t.imperial,t]));Ne({tht:bt(),p:_t.optional(),pw:_t.optional(),ph:_t.optional(),metric:Di.optional(),imperial:Di.optional(),w:_t.optional(),h:_t.optional(),textbottom:bt().optional()});var ej=t=>{let{tht:e,p:n,pw:i,ph:r,metric:o,imperial:s,w:a,h:c,textbottom:l}=t;if(typeof a=="string"&&(a=RI(a)),typeof c=="string"&&(c=RI(c)),typeof n=="string"&&(n=RI(n)),typeof i=="string"&&(i=RI(i)),typeof r=="string"&&(r=RI(r)),c!==void 0&&a!==void 0&&c>a)throw new Error("height cannot be greater than width (rotated footprint not yet implemented)");let u;if(o&&(u=Man[o]),s&&(u=Aan[s]),u&&(a=u.w_mm_min,c=u.h_mm_min,n=u.p_mm_min,i=u.pw_mm_min,r=u.ph_mm_min),n===void 0||i===void 0||r===void 0)throw new Error("Could not determine required pad dimensions (p, pw, ph)");const d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:n/2,y:r/2+.4},{x:-n/2-i/2-.2,y:r/2+.4},{x:-n/2-i/2-.2,y:-r/2-.4},{x:n/2,y:-r/2-.4}],stroke_width:.1,pcb_silkscreen_path_id:""},h=l?-r/2-.9:r/2+.9,f=zo(0,h,.2);return e?[Aa(1,-n/2,0,i,i*1/.8),Aa(2,n/2,0,i,i*1/.8),d,f]:[Dr(["1","left"],-n/2,0,i,r),Dr(["2","right"],n/2,0,i,r),d,f]},Can=t=>({circuitJson:ej(t),parameters:t}),Ran=t=>({circuitJson:ej(t),parameters:t}),Pan=t=>({circuitJson:ej(t),parameters:t}),Ian=t=>({circuitJson:ej(t),parameters:t}),pqe=(t,{x:e,y:n,radius:i})=>({type:"pcb_smtpad",x:e,y:n,radius:i,layer:"top",shape:"circle",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(r=>r.toString()):[t.toString()]}),fqe="ABCDEFGHIJKLMNOPQRSTUVWXYZ",mqe=B().transform(t=>{const[e,n]=t.split(/[x ]/);return{x:parseFloat(e),y:parseFloat(n)}}).pipe(Ne({x:Ue(),y:Ue()})),Nan=B().or(Ct(jd())).transform(t=>Array.isArray(t)?t:(t.startsWith("(")&&t.endsWith(")")&&(t=t.slice(1,-1)),t.split(",").map(e=>{const n=Number(e);return isNaN(n)?e:n}))).pipe(Ct(B().or(Ue()))),kan=Ne({fn:B(),num_pins:Ue().optional().default(64),grid:mqe.optional(),p:Di.default("0.8mm"),w:_t.optional(),h:_t.optional(),ball:_t.optional().describe("ball diameter"),pad:_t.optional().describe("pad width/height"),circularpads:bt().optional().describe("use circular pads"),tlorigin:bt().optional(),blorigin:bt().optional(),trorigin:bt().optional(),brorigin:bt().optional(),missing:Nan.default([])}).transform(t=>{let e="tl";if(t.blorigin&&(e="bl"),t.trorigin&&(e="tr"),t.brorigin&&(e="br"),!t.grid){const i=Math.ceil(Math.sqrt(t.num_pins));t.grid={x:i,y:i}}return t.missing&&(t.missing=t.missing.map(i=>{if(typeof i=="number")return i;if(i==="center")return"center";if(i==="topleft")return"topleft";const r=i.match(/([A-Z]+)(\d+)/);if(!r)return i;const o=fqe.indexOf(r[1]),s=Number.parseInt(r[2])-1;return o*t.grid.x+s+1})),{...t,origin:e}}),Oan=t=>{const e=kan.parse(t);let{num_pins:n,grid:i,p:r,w:o,h:s,ball:a,pad:c,missing:l}=e;a??=.75/1.27*r,c??=a*.8;const u=[],d=(l??[]).filter(N=>typeof N=="number"),h=i.x*i.y-n;if(l.length===0&&h>0&&(Math.sqrt(h)%1===0?l.push("center"):h===1&&l.push("topleft")),l?.includes("center")){const N=Math.floor(Math.sqrt(h)),R=Math.floor((i.x-N)/2),P=Math.floor((i.y-N)/2);for(let M=P;M<P+N;M++)for(let I=R;I<R+N;I++)d.push(M*i.x+I+1)}l?.includes("topleft")&&d.push(1);const f=new Set(d);let m=0;for(let N=0;N<i.y;N++)for(let R=0;R<i.x;R++){const P=(R-(i.x-1)/2)*r,M=(N-(i.y-1)/2)*r;let I=R,A=N;switch(e.origin){case"bl":I=R,A=i.y-1-N;break;case"br":I=i.x-1-R,A=i.y-1-N;break;case"tr":I=i.x-1-R,A=N;break}let $=A*i.x+I+1;if(f.has($)){m++;continue}$-=m;const k=[$,`${fqe[A]}${I+1}`];u.push(e.circularpads?pqe(k,{x:P,y:M,radius:c/2}):Dr(k,P,M,c,c))}const y=zo(0,i.y*r/2,.2),g=r/6;let b;const v=i.x*r/2,w=i.y*r/2;switch(e.origin){case"bl":b=[{x:-v,y:-w},{x:-v,y:-w-g},{x:-v-g,y:-w},{x:-v,y:-w}];break;case"br":b=[{x:v,y:-w},{x:v,y:-w-g},{x:v+g,y:-w},{x:v,y:-w}];break;case"tr":b=[{x:v,y:w},{x:v,y:w+g},{x:v+g,y:w},{x:v,y:w}];break;case"tl":default:b=[{x:-v,y:w},{x:-v,y:w+g},{x:-v-g,y:w},{x:-v,y:w}];break}const T={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_marker",route:b,stroke_width:.05};return{circuitJson:[...u,y,T],parameters:e}},tj=(t,e,n,i,r)=>({type:"pcb_smtpad",x:e,y:n,width:i,height:r,radius:r/2,layer:"top",shape:"pill",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(o=>o.toString()):[t.toString()]}),_5=t=>Ne({fn:B(),num_pins:Ue().optional().default(8),w:_t.default(_t.parse(t.w??"5.3mm")),p:_t.default(_t.parse(t.p??"1.27mm")),pw:_t.default(_t.parse(t.pw??"0.6mm")),pl:_t.default(_t.parse(t.pl??"1.0mm")),legsoutside:bt().optional().default(t.legsoutside??!1),pillpads:bt().optional().default(t.pillpads??!1)}).transform(e=>(!e.pw&&!e.pl?(e.pw=_t.parse("0.6mm"),e.pl=_t.parse("1.0mm")):e.pw?e.pl||(e.pl=e.pw*(1/.6)):e.pw=e.pl*(.6/1),e)),Lan=_5({}),x0e=t=>{t.widthincludeslegs!==void 0&&(t.legsoutside=!t.widthincludeslegs);const{num_pins:e,pn:n,w:i,p:r,pl:o,legsoutside:s}=t,a=e/2,c=n<=a,l=a-1,u=r,d=u*l,h=s?o/2:-o/2;return c?{x:-i/2-h,y:d/2-(n-1)*u}:{x:i/2+h,y:-d/2+(n-a-1)*u}},Dan=t=>{const e=Lan.parse(t);return{circuitJson:r3(e),parameters:e}},r3=t=>{const e=[];for(let a=0;a<t.num_pins;a++){const{x:c,y:l}=x0e({num_pins:t.num_pins,pn:a+1,w:t.w,p:t.p,pl:t.pl,legsoutside:t.legsoutside});t.pillpads?e.push(tj(a+1,c,l,t.pl,t.pw)):e.push(Dr(a+1,c,l,t.pl,t.pw))}const n=Math.min(1,t.p/2),i=t.w-(t.legsoutside?0:t.pl*2)-.2,r=(t.num_pins/2-1)*t.p+t.pw+n,o=zo(0,r/2+.4,r/12),s={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",stroke_width:.1,route:[{x:-i/2,y:-r/2},{x:-i/2,y:r/2},...uqe.map(({x:a,y:c})=>({x:a*i/6,y:c*i/6+r/2})),{x:i/2,y:r/2},{x:i/2,y:-r/2},{x:-i/2,y:-r/2}]};return[...e,s,o]},_qe=dn(["leftside","topside","rightside","bottomside","toppin","bottompin","leftpin","rightpin"]),zan=({num_pins:t,cw:e,ccw:n,startingpin:i})=>{const r=[],o=t/4;let s=1;const a={};for(const c of i??[])a[c]=!0;!a.leftside&&!a.topside&&!a.rightside&&!a.bottomside&&(a.leftside=!0),!a.bottompin&&!a.leftpin&&!a.rightpin&&!a.toppin&&(a.leftside?a.toppin=!0:a.topside?a.rightpin=!0:a.rightside?a.bottompin=!0:a.bottomside&&(a.leftpin=!0)),a.leftside&&a.toppin?s=1:a.leftside&&a.bottompin?s=o:a.bottomside&&a.leftpin?s=o+1:a.bottomside&&a.rightpin?s=o*2:a.rightside&&a.bottompin?s=o*2+1:a.rightside&&a.toppin?s=o*3:a.topside&&a.rightpin?s=o*3+1:a.topside&&a.leftpin&&(s=o*4),r.push(-1);for(let c=0;c<t;c++)r[s]=c+1,n||!e?(s++,s>t&&(s=1)):(s--,s<1&&(s=t));return r},v0e=Ne({fn:B(),cc:bt().default(!0).optional(),ccw:bt().default(!0).optional(),startingpin:B().or(Ct(_qe)).transform(t=>typeof t=="string"?t.slice(1,-1).split(","):t).pipe(Ct(_qe)).optional(),num_pins:Ue().optional().default(64),w:_t.optional(),h:_t.optional(),p:_t.default(_t.parse("0.5mm")),pw:_t.optional(),pl:_t.optional(),thermalpad:oi([Ce(!0),mqe]).optional(),legsoutside:bt().default(!1)}),w0e=t=>{t.w&&!t.h?t.h=t.w:!t.w&&t.h&&(t.w=t.h);const e=t.num_pins/4;if(!t.p&&!t.pw&&!t.pl&&t.w){const n=e+4;t.p=t.w/n}return!t.p&&t.w&&t.h&&t.pw&&t.pl&&(t.p=(t.w-t.pl*2)/(e-1)),!t.w&&!t.h&&t.p&&(t.w=t.p*(e+4),t.h=t.w),t.p&&!t.pw&&!t.pl?(t.pw=t.p/2,t.pl=t.p/2):t.pw?t.pl||(t.pl=t.pw*(1/.6)):t.pw=t.pl*(.6/1),t},yqe=v0e.transform(w0e),Fan=["left","bottom","right","top"],Ban=t=>{const{pin_count:e,pn:n,w:i,h:r,p:o,pl:s,legsoutside:a}=t,c=e/4,l=Fan[Math.floor((n-1)/c)],u=(n-1)%c,d=o*(c-1),h=o*(c-1),f=a?s/2:-s/2;switch(l){case"left":return{x:-i/2-f,y:h/2-u*o,o:"vert"};case"bottom":return{x:-d/2+u*o,y:-r/2-f,o:"horz"};case"right":return{x:i/2+f,y:-h/2+u*o,o:"vert"};case"top":return{x:d/2-u*o,y:r/2+f,o:"horz"};default:throw new Error("Invalid pin number")}},II=t=>{const e=yqe.parse(t),n=[],i=zan(e),r=e.num_pins/4;for(let a=0;a<e.num_pins;a++){const{x:c,y:l,o:u}=Ban({pin_count:e.num_pins,pn:a+1,w:e.w,h:e.h,p:e.p??.5,pl:e.pl,legsoutside:e.legsoutside});let d=e.pw,h=e.pl;u==="vert"&&([d,h]=[h,d]);const f=i[a+1];n.push(Dr(f,c,l,d,h))}if(e.thermalpad)if(typeof e.thermalpad=="boolean"){const a=e.p*(r-1)+e.pw,c=e.p*(r-1)+e.pw;n.push(Dr(["thermalpad"],0,0,a,c))}else n.push(Dr(["thermalpad"],0,0,e.thermalpad.x,e.thermalpad.y));const o=[];for(const[a,c,l]of[["top-left",-1,1],["bottom-left",-1,-1],["bottom-right",1,-1],["top-right",1,1]]){const u=e.w/2*c,d=e.h/2*l;let h="none",f=u,m=d;const y=e.pw*2;i[1]===1&&a==="top-left"?h="in1":i[r*4]===1&&a==="top-left"||i[r*3+1]===1&&a==="top-right"?h="in2":i[r*3]===1&&a==="top-right"||i[r]===1&&a==="bottom-left"?h="in1":i[r+1]===1&&a==="bottom-left"?h="in2":i[r*2]===1&&a==="bottom-right"?h="in1":i[r*2+1]===1&&a==="bottom-right"&&(h="in2");const g=h==="in1"?1:-1;if(e.legsoutside){const b=h==="in1"?e.pl/2:e.pw/2,v=h==="in1"?e.pw/2:e.pl/2;f+=b*c*g,m-=v*l*g}(h==="none"||e.legsoutside)&&o.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${a}`,route:[{x:u-y*c,y:d},{x:u,y:d},{x:u,y:d-y*l}],type:"pcb_silkscreen_path",stroke_width:.1}),(h==="in1"||h==="in2")&&!e.legsoutside&&o.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${a}_1`,route:[{x:u-y*c,y:d},{x:u-y*c/2,y:d}],type:"pcb_silkscreen_path",stroke_width:0},{layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${a}_2`,route:[{x:u,y:d-y*l/2},{x:u,y:d-y*l}],type:"pcb_silkscreen_path",stroke_width:.1}),(h==="in1"||h==="in2")&&o.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${a}_3`,route:[{x:f-.2*-c,y:m+.2*g},{x:f,y:m},{x:f+.2*g*-c,y:m+.2},{x:f-.2*-c,y:m+.2*g}],type:"pcb_silkscreen_path",stroke_width:.1})}const s=zo(0,e.h/2+(e.legsoutside?e.pl*1.2:.5),.3);return{circuitJson:[...n,...o,s],parameters:e}};v0e.extend({}).transform(w0e);var Uan=t=>(t.legsoutside=!1,II(t)),$an=t=>{t.legsoutside=!0;const e=yqe.parse(t);if(!t.p)switch(t.num_pins){case 44:case 64:t.p=.8;break;case 52:t.w===14?t.p=1:t.p=.65;break;case 208:t.p=.5;break}if(!t.pl)switch(t.num_pins){case 44:case 52:case 64:t.pl=2.25;break;case 208:t.pl=1.65;break;default:t.pl=e.pl*4;break}if(!t.pw)switch(t.num_pins){case 44:case 64:t.pw=.5;break;case 52:t.w===14?t.pw=.45:t.pw=.55;break;case 208:t.pw=.3;break;default:t.pw=e.pw;break}return II(t)};v0e.extend({}).transform(w0e);var jan=t=>(t.legsoutside=!1,t.thermalpad===void 0&&(t.thermalpad=!0),II(t)),Han=_5({w:"3.9mm",p:"1.27mm"}),Van=t=>{const e=Han.parse(t);return{circuitJson:r3(e),parameters:e}},Gan=_5({w:"7.1mm",p:"0.65mm",pl:"1.35mm",pw:"0.40mm",legsoutside:!0}),Yan=t=>{const e=Gan.parse(t);return{circuitJson:r3(e),parameters:e}},qan=_5({}),Xan=t=>{const e=qan.parse({fn:"sot363",num_pins:6,w:1.94,p:.65,pw:.3,pl:.7,legoutside:!0});return{circuitJson:r3(e),parameters:e}},gqe=Ne({fn:B(),num_pins:Ue().default(3),w:B().default("1.92mm"),h:B().default("2.74mm"),pl:B().default("0.8mm"),pw:B().default("0.764mm"),p:B().default("0.95mm"),string:B().optional()}),Wan=_5({p:"0.95mm",w:"1.6mm",legsoutside:!0}),Zan=t=>{const e=t.string?.match(/^sot23_(\d+)/),n=e?Number.parseInt(e[1],10):3;if(n===6||n===8){const r=Wan.parse({...t,num_pins:n});return{circuitJson:r3(r),parameters:r}}const i=gqe.parse({...t,num_pins:n});if(i.num_pins===3)return{circuitJson:Qan(i),parameters:i};if(i.num_pins===5)return{circuitJson:xqe(i),parameters:i};throw new Error("Invalid number of pins")},Kan=t=>{const{pn:e}=t;return e===1?{x:-1.7,y:0}:e===2?{x:1.7,y:-.95}:{x:1.7,y:.95}},Qan=t=>{const e=[];for(let i=0;i<t.num_pins;i++){const{x:r,y:o}=Kan({num_pins:t.num_pins,pn:i+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl)});e.push(Dr(i+1,r,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=zo(0,Number.parseInt(t.h),.3);return[...e,n]},bqe=t=>{const{p:e,h:n,pn:i}=t;if(i===1)return{x:-n/2-.5,y:e};if(i===2)return{x:-n/2-.5,y:0};if(i===3)return{x:-n/2-.5,y:-e};if(i===4)return{x:n/2+.5,y:-e};if(i===5)return{x:n/2+.5,y:e};throw new Error("Invalid pin number")},xqe=t=>{const e=[];for(let d=1;d<=t.num_pins;d++){const{x:h,y:f}=bqe({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:d});e.push(Dr(d,h,f,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=(t.num_pins+1)/2*Number.parseFloat(t.p),i=Number.parseFloat(t.h),r={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-n/3,y:i/2+Number.parseFloat(t.p)/1.3},{x:n/3,y:i/2+Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-n/3,y:-i/2-Number.parseFloat(t.p)/1.3},{x:n/3,y:-i/2-Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},s=zo(0,i+.3,.3),a=bqe({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:1});a.x=a.x-Number.parseFloat(t.pw)*1.5;const c=.7,l=.3,u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:a.x+c/2,y:a.y},{x:a.x-c/2,y:a.y+l/2},{x:a.x-c/2,y:a.y-l/2},{x:a.x+c/2,y:a.y}],stroke_width:.05};return[...e,s,r,o,u]},Jan=gqe.extend({}),ecn=t=>{const e=Jan.parse({...t,num_pins:5});return{circuitJson:xqe(e),parameters:e}},tcn=[{name:"top-left",dx:-1,dy:1},{name:"top-right",dx:1,dy:1},{name:"bottom-left",dx:-1,dy:-1},{name:"bottom-right",dx:1,dy:-1}],ncn=_5({}),icn=t=>{const e=ncn.parse(t),n=[];for(let d=0;d<e.num_pins;d++){const{x:h,y:f}=x0e({num_pins:e.num_pins,pn:d+1,w:e.w,p:e.p??1.27,pl:e.pl,widthincludeslegs:!0});n.push(Dr(d+1,h,f,e.pl??"1mm",e.pw??"0.6mm"))}const i=Math.min(1,e.p/2),r=e.w+i,o=(e.num_pins/2-1)*e.p+e.pw+i,s=[];for(const d of tcn){const{dx:h,dy:f}=d;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",route:[{x:h*r/2-h*e.p,y:f*o/2},{x:h*r/2,y:f*o/2},{x:h*r/2,y:f*o/2-f*e.p}],type:"pcb_silkscreen_path",stroke_width:.1})}const a=e.p/4,c=-r/2-a/2,l=o/2-e.p/2;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:c,y:l},{x:c-a,y:l+a},{x:c-a,y:l-a},{x:c,y:l}],stroke_width:.1});const u=zo(0,o/2+.4,o/12);return{circuitJson:[...n,u,...s],parameters:e}},nj=(t,e,n,i,r,o)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circular_hole_with_rect_pad",x:e,y:n,hole_diameter:dh(i),hole_shape:"circle",pad_shape:"rect",rect_pad_width:dh(r),rect_pad_height:dh(o),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()]}),S0e=({fs:t,pn:e,anchor_x:n,anchor_y:i,textalign:r="center",orthogonal:o=!1,verticallyinverted:s=!1,layer:a="top"})=>{let c=0;o&&s?c=270:s?c=180:o?c=90:c=0;let l="center";return r==="left"&&(s?l="center_right":l="center_left"),r==="right"&&(s?l="center_left":l="center_right"),a==="bottom"&&(l==="center_left"?l="center_right":l==="center_right"&&(l="center_left")),{type:"pcb_silkscreen_text",pcb_silkscreen_text_id:"silkscreen_text_1",font:"tscircuit2024",font_size:t,pcb_component_id:"pcb_component_1",text:`{PIN${e}}`,layer:a,anchor_position:{x:n,y:i},anchor_alignment:l,ccw_rotation:c}};function rcn({pinlabeltextalignleft:t,pinlabeltextalignright:e,pinlabelorthogonal:n}){let i="top";return n?i="left":i="top",t&&(n?i="bottom":i="right"),e&&(n?i="top":i="left"),i}var ocn=Ne({fn:B(),num_pins:Ue().optional().default(6),rows:oi([B(),Ue()]).transform(t=>Number(t)).optional().default(1).describe("number of rows"),p:_t.default("0.1in").describe("pitch"),id:_t.default("1.0mm").describe("inner diameter"),od:_t.default("1.5mm").describe("outer diameter"),male:bt().optional().describe("for male pin headers"),female:bt().optional().describe("for female pin headers"),pinlabeltextalignleft:bt().optional().default(!1),pinlabeltextaligncenter:bt().optional().default(!1),pinlabeltextalignright:bt().optional().default(!1),pinlabelverticallyinverted:bt().optional().default(!1),pinlabelorthogonal:bt().optional().default(!1),nosquareplating:bt().optional().default(!1).describe("do not use rectangular pad for pin 1"),nopinlabels:bt().optional().default(!1).describe("omit silkscreen pin labels"),doublesidedpinlabel:bt().optional().default(!1).describe("add silkscreen pins in top and bottom layers"),bottomsidepinlabel:bt().optional().default(!1).describe("place the silkscreen reference text on the bottom layer instead of top")}).transform(t=>{const e=rcn(t);return{...t,pinlabelAnchorSide:e,male:t.male??!t.female,female:t.female??!1}}).superRefine((t,e)=>{t.male&&t.female&&e.addIssue({code:zi.custom,message:"'male' and 'female' cannot both be true; it should be male or female.",path:["male","female"]})}),scn=t=>{const e=ocn.parse(t),{p:n,id:i,od:r,rows:o,num_pins:s,pinlabelAnchorSide:a,pinlabelverticallyinverted:c,pinlabelorthogonal:l,pinlabeltextalignleft:u,pinlabeltextalignright:d,nopinlabels:h,doublesidedpinlabel:f,bottomsidepinlabel:m}=e;let y="center";u?y="left":d&&(y="right");const g=[],b=Math.ceil(s/o),v=-n,w=({xoff:M,yoff:I,od:A,anchorSide:$})=>{let k=0,V=0;const X=A*.75;switch($){case"right":k=X;break;case"top":V=X;break;case"bottom":V=-X;break;case"left":k=-X;break}return{anchor_x:M+k,anchor_y:I+V}},T=(M,I,A)=>{M===1&&!e.nosquareplating?g.push(nj(M,I,A,i,r,r)):g.push(Aa(M,I,A,i,r));const{anchor_x:$,anchor_y:k}=w({xoff:I,yoff:A,od:r,anchorSide:a});h||(m?g.push(S0e({fs:r/5,pn:M,anchor_x:$,anchor_y:k,textalign:y,orthogonal:l,verticallyinverted:c,layer:"bottom"})):g.push(S0e({fs:r/5,pn:M,anchor_x:$,anchor_y:k,textalign:y,orthogonal:l,verticallyinverted:c,layer:"top"})),f&&g.push(S0e({fs:r/5,pn:M,anchor_x:$,anchor_y:k,textalign:y,orthogonal:l,verticallyinverted:c,layer:"bottom"})))},N=new Set,R=o>2&&b>2;if(o===1){const M=-((s-1)/2)*n;for(let I=0;I<s;I++){const A=I+1,$=M+I*n,k=`${$},0`;if(N.has(k))throw new Error(`Overlap at ${k}`);N.add(k),T(A,$,0)}}else if(R){const M=-((b-1)/2)*n;let I=1;for(let A=0;A<o&&I<=s;A++)for(let $=0;$<b&&I<=s;$++){const k=M+$*n,V=A*v,X=`${k},${V}`;if(N.has(X))throw new Error(`Overlap at ${X}`);N.add(X),T(I++,k,V)}}else{const M=-((b-1)/2)*n;let I=1,A=0,$=o-1,k=0,V=b-1;for(;I<=s&&A<=$&&k<=V;){for(let X=A;X<=$&&I<=s;X++){const W=M+k*n,K=X*v,te=`${W},${K}`;if(N.has(te))throw new Error(`Overlap at ${te}`);N.add(te),T(I++,W,K)}k++;for(let X=k;X<=V&&I<=s;X++){const W=M+X*n,K=$*v,te=`${W},${K}`;if(N.has(te))throw new Error(`Overlap at ${te}`);N.add(te),T(I++,W,K)}if($--,k<=V){for(let X=$;X>=A&&I<=s;X--){const W=M+V*n,K=X*v,te=`${W},${K}`;if(N.has(te))throw new Error(`Overlap at ${te}`);N.add(te),T(I++,W,K)}V--}if(A<=$){for(let X=V;X>=k&&I<=s;X--){const W=M+X*n,K=A*v,te=`${W},${K}`;if(N.has(te))throw new Error(`Overlap at ${te}`);N.add(te),T(I++,W,K)}A++}}if(I-1<s)throw new Error(`Missing pins: assigned ${I-1}, expected ${s}`)}const P=zo(0,n,.5);return{circuitJson:[...g,P],parameters:e}},acn=_5({}),ccn=t=>{const e=acn.parse({fn:"sot563",num_pins:6,w:1.94,p:.5,pw:.3,pl:.67,legoutside:!0});return{circuitJson:r3(e),parameters:e}},lcn=_5({p:"1.27mm",w:"3.9mm",legsoutside:!0}),ucn=t=>{const e=lcn.parse({...t,num_pins:8});return{circuitJson:r3(e),parameters:e}},dcn=_5({p:"1.27mm",w:"7.5mm",legsoutside:!0}),hcn=t=>{const e=dcn.parse({...t,num_pins:16});return{circuitJson:r3(e),parameters:e}},pcn=Ne({fn:B(),num_pins:Ce(3).default(3),w:B().default("1.2mm"),h:B().default("1.2mm"),pl:B().default("0.3mm"),pw:B().default("0.32mm")}),fcn=t=>{const e=pcn.parse(t),n=_cn(e),i=zo(.4,_t.parse(e.h),.2);return{circuitJson:[...n,i],parameters:e}},mcn=t=>{const{pn:e}=t;return e===1?{x:0,y:0}:e===2?{x:1,y:-.4}:{x:1,y:.4}},_cn=t=>{const e=[];for(let n=0;n<3;n++){const{x:i,y:r}=mcn({num_pins:t.num_pins,pn:n+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl)});e.push(Dr(n+1,i,r,Number.parseFloat(t.pl),n!==0?Number.parseFloat(t.pw):.42))}return e},ycn=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("2.36mm"),h:B().default("1.22mm"),pl:B().default("0.9mm"),pw:B().default("0.9mm"),p:B().default("4.19mm")}),gcn=t=>{const e=ycn.parse(t),n=zo(0,_t.parse(e.h)/4+.4,.3);return{circuitJson:xcn(e).concat(n),parameters:e}},bcn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},xcn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=bcn({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},vcn=Ne({fn:B(),p:_t.optional().default("2.54mm"),id:_t.optional().default("0.7mm"),od:_t.optional().default("1mm")}),wcn=t=>{const e=vcn.parse(t),{p:n,id:i,od:r}=e,o=[Aa(1,-n/2,0,i,r),Aa(2,n/2,0,i,r)],s={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/2+r+i/2,y:0},{x:n/2-r-i/2,y:0}],stroke_width:.1,pcb_silkscreen_path_id:""},a=zo(0,n/4,.5);return{circuitJson:[...o,s,a],parameters:e}},ij=(t,e={})=>({type:"pcb_silkscreen_path",layer:e.layer||"top",pcb_component_id:e.pcb_component_id||"",pcb_silkscreen_path_id:e.pcb_silkscreen_path_id||"",route:t,stroke_width:e.stroke_width||.1}),Scn=Ne({fn:Ce("pushbutton"),w:_t.default(4.5),h:_t.default(6.5),id:_t.default(1),od:_t.default(1.2)}),Ecn=t=>{const e=Scn.parse(t),n=e.w,i=e.h,r=e.id,o=[Aa(1,-n/2,i/2,r,r*1.5),Aa(2,-n/2,-i/2,r,r*1.5),Aa(3,n/2,-i/2,r,r*1.5),Aa(4,n/2,i/2,r,r*1.5)],s=[ij([{x:-n/2,y:-i/2},{x:-n/2,y:i/2}]),ij([{x:n/2,y:-i/2},{x:n/2,y:i/2}]),ij([{x:-n/2,y:0},{x:-n/5,y:0},{x:n/5*1/Math.sqrt(2),y:i/8}]),ij([{x:n/2,y:0},{x:n/5,y:0}])],a=zo(0,i/2+.4,.5);return{circuitJson:[...o,...s,a],parameters:e}},vqe=Ne({fn:B(),w:_t.default("22.58mm"),h:_t.optional(),left:_t.optional().default(20),right:_t.optional().default(20),top:_t.optional().default(2),bottom:_t.optional().default(2),p:_t.default(_t.parse("2.54mm")),pw:_t.default(_t.parse("1.6mm")),pl:_t.default(_t.parse("2.4mm")),innerhole:bt().default(!1),innerholeedgedistance:_t.default(_t.parse("1.61mm")),silkscreenlabels:bt().default(!1),silkscreenlabelmargin:_t.default(_t.parse("0.1mm"))}),Tcn=t=>{const e=vqe.parse(t);return e.left&&e.right?Math.max(e.left,e.right)*e.p:e.left?e.left*e.p:e.right?e.right*e.p:51},rj=(t,e,n)=>{let i=[];return n==="right"&&(i=[{x:t+1/2,y:e},{x:t-1/2,y:e+.6/2},{x:t-1/2,y:e-.6/2},{x:t+1/2,y:e}]),n==="left"&&(i=[{x:t-1/2,y:e},{x:t+1/2,y:e+.6/2},{x:t+1/2,y:e-.6/2},{x:t-1/2,y:e}]),n==="top"&&(i=[{x:t,y:e+1/2},{x:t-.6/2,y:e-1/2},{x:t+.6/2,y:e-1/2},{x:t,y:e+1/2}]),n==="bottom"&&(i=[{x:t,y:e-1/2},{x:t-.6/2,y:e+1/2},{x:t+.6/2,y:e+1/2},{x:t,y:e-1/2}]),i},Mcn=t=>{const e=vqe.parse(t),n=e.h??Tcn(e),i=[],r=[],o=[];let s=[];const a=1,c=a,l=e.left+e.right+(e.bottom??0)+(e.top??0),d=`pin${l}`.length*.7/2;if(e.right){const y=-((e.right-1)/2)*e.p;for(let g=0;g<e.right;g++){if(g===0&&!e.left&&!e.bottom&&!e.silkscreenlabels&&(s=rj(e.w/2-e.pl*1.4,y+g*e.p,"right")),i.push(Dr(g+1+e.left+(e.bottom??0),e.w/2-e.pl/2,y+g*e.p,e.pl,e.pw)),e.silkscreenlabels){const b=g+1+e.left+(e.bottom??0),v=`pin${b}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${b}`,pcb_component_id:"1",layer:"top",anchor_position:{x:e.w/2-e.pl-(d+e.silkscreenlabelmargin),y:y+g*e.p},text:v,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}e.innerhole&&(r.push(Aa(g+1+e.left+(e.bottom??0)+l,e.w/2,y+g*e.p,a,c)),r.push(Aa(g+1+e.left+(e.bottom??0)+l*2,e.w/2-e.innerholeedgedistance,y+g*e.p,a,c)))}}if(e.left){const y=(e.left-1)/2*e.p;for(let g=0;g<e.left;g++){if(g===0&&!e.silkscreenlabels&&(s=rj(-e.w/2+e.pl*1.4,y-g*e.p,"left")),i.push(Dr(g+1,-e.w/2+e.pl/2,y-g*e.p,e.pl,e.pw)),e.silkscreenlabels){const b=g+1,v=`pin${b}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${b}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-e.w/2+e.pl+(d+e.silkscreenlabelmargin),y:y-g*e.p},text:v,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}e.innerhole&&(r.push(Aa(g+1+l,-e.w/2,y-g*e.p,a,c)),r.push(Aa(g+1+l*2,-e.w/2+e.innerholeedgedistance,y-g*e.p,a,c)))}}if(e.top){const y=(e.top-1)/2*e.p;for(let g=0;g<e.top;g++){if(g===0&&!e.left&&!e.bottom&&!e.right&&!e.silkscreenlabels&&(s=rj(y-g*e.p,n/2-e.pl*1.4,"top")),i.push(Dr(g+1+e.left+e.right+(e.bottom??0),y-g*e.p,n/2-e.pl/2,e.pw,e.pl)),e.silkscreenlabels){const b=g+1+e.left+e.right+(e.bottom??0),v=`pin${b}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${b}`,pcb_component_id:"1",layer:"top",anchor_position:{x:y-g*e.p,y:n/2-e.pl-(d+e.silkscreenlabelmargin)},text:v,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:270})}e.innerhole&&(r.push(Aa(g+1+e.left+e.right+(e.bottom??0)+l,y-g*e.p,n/2,a,c)),r.push(Aa(g+1+e.left+e.right+(e.bottom??0)+l*2,y-g*e.p,n/2-e.innerholeedgedistance,a,c)))}}if(e.bottom){const y=-((e.bottom-1)/2)*e.p;for(let g=0;g<e.bottom;g++){if(g===0&&!e.left&&!e.silkscreenlabels&&(s=rj(y+g*e.p,-n/2+e.pl*1.4,"bottom")),i.push(Dr(g+1+e.left,y+g*e.p,-n/2+e.pl/2,e.pw,e.pl)),e.silkscreenlabels){const b=g+1+e.left,v=`pin${b}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${b}`,pcb_component_id:"1",layer:"top",anchor_position:{x:y+g*e.p,y:-n/2+e.pl+(d+e.silkscreenlabelmargin)},text:v,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:90})}e.innerhole&&(r.push(Aa(g+1+e.left+l,y+g*e.p,-n/2,a,c)),r.push(Aa(g+1+e.left+l*2,y+g*e.p,-n/2+e.innerholeedgedistance,a,c)))}}const h={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_triangle_1",pcb_component_id:"2",route:s,stroke_width:.1,layer:"top"},f={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-e.w/2,y:n/2},{x:e.w/2,y:n/2},{x:e.w/2,y:-n/2},{x:-e.w/2,y:-n/2},{x:-e.w/2,y:n/2}],stroke_width:.1,layer:"top"},m=zo(0,n/1.8,n/25);return{circuitJson:[...i,...r,...o,f,...e.silkscreenlabels?[]:[h],m],parameters:e}},wqe=Ne({fn:B(),w:_t.default("22.58mm"),h:_t.optional(),left:_t.optional().default(20),right:_t.optional().default(20),top:_t.optional().default(2),bottom:_t.optional().default(2),p:_t.default(_t.parse("2.54mm")),pw:_t.default(_t.parse("1.6mm")),pl:_t.default(_t.parse("3.2mm")),innerhole:bt().default(!1),innerholeedgedistance:_t.default(_t.parse("1.61mm"))}),Acn=t=>{const e=wqe.parse(t);return e.left&&e.right?Math.max(e.left,e.right)*e.p:e.left?e.left*e.p:e.right?e.right*e.p:51},Ccn=(t,e,n,i=1,r=.6)=>{const o=i/2,s=r/2;return{left:[{x:t+o,y:e},{x:t-o,y:e+s},{x:t-o,y:e-s},{x:t+o,y:e}],right:[{x:t-o,y:e},{x:t+o,y:e+s},{x:t+o,y:e-s},{x:t-o,y:e}],top:[{x:t,y:e-o},{x:t-s,y:e+o},{x:t+s,y:e+o},{x:t,y:e-o}],bottom:[{x:t,y:e+o},{x:t-s,y:e-o},{x:t+s,y:e-o},{x:t,y:e+o}]}[n]},Rcn=t=>{const e=wqe.parse(t),n=e.h??Acn(e),i=[],r=[],o=[],s=1,a=1.2,c=e.left+e.right+(e.bottom??0)+(e.top??0);let l=[],u=1;if(e.left){const m=(e.left-1)/2*e.p;for(let y=0;y<e.left;y++)y===0&&(l=Ccn(-e.w/2-e.pl/2,m-y*e.p,"left")),i.push(Dr(u,-e.w/2+e.pl/2,m-y*e.p,e.pl,e.pw)),r.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${u}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-e.w/2+e.pl/2-4.5,y:m-y*e.p},text:`pin${u}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),u++,e.innerhole&&o.push(Aa(u+c,-e.w/2+e.innerholeedgedistance,m-y*e.p,s,a))}if(e.bottom){const m=(e.bottom-1)/2*e.p;for(let y=e.bottom-1;y>=0;y--)i.push(Dr(u,m-y*e.p,-n/2+e.pl/2,e.pw,e.pl)),r.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${u}`,pcb_component_id:"1",layer:"top",anchor_position:{x:m-y*e.p,y:-n/2+e.pl/2-3.2},text:`pin${u}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),u++,e.innerhole&&o.push(Aa(u+c,m-y*e.p,-n/2+e.innerholeedgedistance,s,a))}if(e.right){const m=-((e.right-1)/2)*e.p;for(let y=0;y<e.right;y++)i.push(Dr(u,e.w/2-e.pl/2,m+y*e.p,e.pl,e.pw)),r.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${u}`,pcb_component_id:"1",layer:"top",anchor_position:{x:e.w/2-e.pl/2+3.7,y:m+y*e.p},text:`pin${u}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),u++,e.innerhole&&o.push(Aa(u+c,e.w/2-e.innerholeedgedistance,m+y*e.p,s,a))}if(e.top){const m=-((e.top-1)/2)*e.p;for(let y=e.top-1;y>=0;y--)i.push(Dr(u,m+y*e.p,n/2-e.pl/2,e.pw,e.pl)),r.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${u}`,pcb_component_id:"1",layer:"top",anchor_position:{x:m+y*e.p,y:n/2-e.pl/2+3.2},text:`pin${u}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),u++,e.innerhole&&o.push(Aa(u+c,m+y*e.p,n/2-e.innerholeedgedistance,s,a))}const d={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"1",pcb_component_id:"1",layer:"top",route:l,stroke_width:.1},h={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-e.w/2-e.pl/3,y:n/2+e.pl/3},{x:e.w/2+e.pl/3,y:n/2+e.pl/3},{x:e.w/2+e.pl/3,y:-n/2-e.pl/3},{x:-e.w/2-e.pl/3,y:-n/2-e.pl/3},{x:-e.w/2-e.pl/3,y:n/2+e.pl/3}],stroke_width:.1,layer:"top"},f=zo(0,n/1.8,n/25);return{circuitJson:[...o,...i,...r,h,d,f],parameters:e}},Pcn=t=>(t.legsoutside=!0,II(t)),Sqe=Ne({fn:B(),w:_t.default("10mm"),h:_t.optional(),left:_t.optional().default(20),right:_t.optional().default(20),top:_t.optional().default(0),bottom:_t.optional().default(0),p:_t.default(_t.parse("2.54mm")),id:_t.optional().default(_t.parse("1mm")),od:_t.optional().default(_t.parse("1.5mm"))}),Icn=t=>{const e=Sqe.parse(t);return e.left&&e.right?Math.max(e.left,e.right)*e.p:e.left?e.left*e.p:e.right?e.right*e.p:51},oj=(t,e,n,i=1,r=.6)=>{const o=i/2,s=r/2;return{left:[{x:t+o,y:e},{x:t-o,y:e+s},{x:t-o,y:e-s},{x:t+o,y:e}],right:[{x:t-o,y:e},{x:t+o,y:e+s},{x:t+o,y:e-s},{x:t-o,y:e}],top:[{x:t,y:e-o},{x:t-s,y:e+o},{x:t+s,y:e+o},{x:t,y:e-o}],bottom:[{x:t,y:e+o},{x:t-s,y:e-o},{x:t+s,y:e-o},{x:t,y:e+o}]}[n]},Ncn=t=>{const e=Sqe.parse(t),n=e.h??Icn(e),i=[],r=e.id,o=e.od;let s=[];if(e.right){const u=-((e.right-1)/2)*e.p;for(let d=0;d<e.right;d++)d===0&&!e.left&&!e.bottom&&(s=oj(e.w/2+o*1.4,u+d*e.p,"right")),i.push(Aa(d+1+e.left+(e.bottom??0),e.w/2,u+d*e.p,r,o))}if(e.left){const u=-((e.left-1)/2)*e.p;for(let d=0;d<e.left;d++)d===e.left-1&&(s=oj(-e.w/2-o*1.4,u+d*e.p,"left")),i.push(Aa(d+1,-e.w/2,u+d*e.p,r,o))}if(e.top){const u=-((e.top-1)/2)*e.p;for(let d=0;d<e.top;d++)d===e.top-1&&!e.left&&!e.bottom&&!e.right&&(s=oj(u+d*e.p,n/2+o*1.4,"top")),i.push(Aa(d+1+e.right+(e.bottom??0)+e.left,u+d*e.p,n/2,r,o))}if(e.bottom){const u=-((e.bottom-1)/2)*e.p;for(let d=0;d<e.bottom;d++)d===0&&!e.left&&(s=oj(u+d*e.p,-n/2-o*1.4,"bottom")),i.push(Aa(d+1+e.left,u+d*e.p,-n/2,r,o))}const a={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"1",pcb_component_id:"1",layer:"top",route:s,stroke_width:.1},c={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-e.w/2-o,y:n/2+o},{x:e.w/2+o,y:n/2+o},{x:e.w/2+o,y:-n/2-o},{x:-e.w/2-o,y:-n/2-o},{x:-e.w/2-o,y:n/2+o}],stroke_width:.1,layer:"top"},l=zo(0,n/1.7,n/25);return{circuitJson:[...i,c,l,a],parameters:e}},Eqe=(t,e,n,i)=>Array.from({length:25},(r,o)=>{const s=o/24*Math.PI-Math.PI/2;return{x:t+(i==="right"?1:-1)*Math.cos(s)*n,y:e+Math.sin(s)*n}}),kcn=Ne({fn:B(),p:_t.optional().default("4.88mm"),id:_t.optional().default("0.6mm"),od:_t.optional().default("1.2mm"),w:_t.optional().default("5.6mm"),h:_t.optional().default("3.5mm")}),Ocn=t=>{const e=kcn.parse(t),{p:n,id:i,od:r,w:o,h:s}=e,a=s/2,c=[Aa(1,-n/2,0,i,r),Aa(2,n/2,0,i,r)],l=Eqe(-o/2,0,a,"left"),u=Eqe(o/2,0,a,"right"),d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[...l,...l.slice(1).reverse(),{x:-o/2,y:-s/2},{x:o/2,y:-s/2},...u,{x:o/2,y:s/2},{x:-o/2,y:s/2}],stroke_width:.1,pcb_silkscreen_path_id:""},h=zo(0,n/4,.5);return{circuitJson:[...c,d,h],parameters:e}};Ne({w:_t,h:_t});var Lcn=t=>{const{w:e,h:n}=t,i=dh(e),r=dh(n);return{circuitJson:[Dr(1,0,0,i,r),zo(0,r/2+.5,.2)],parameters:t}},Dcn=Ne({fn:B(),num_pins:oi([Ce(3),Ce(2)]).default(3),p:B().default("1.27mm"),id:B().default("0.72mm"),od:B().default("0.95mm"),w:B().default("4.5mm"),h:B().default("4.5mm"),inline:bt().default(!1),string:B().optional()}),zcn=(t,e,n)=>Array.from({length:25},(i,r)=>{const o=r/24*Math.PI;return{x:t+Math.cos(o)*n,y:e+Math.sin(o)*n}}),Fcn=t=>{const{p:e,id:n,od:i,h:r}=t,o=Number.parseFloat(r)/2,s=Number.parseFloat(e);return[Aa(1,-s,o-s,n,i),Aa(2,s,o-s,n,i)]},Bcn=t=>{const e=t.string?.match(/^to92_(\d+)/),n=e?Number.parseInt(e[1],10):3,i=Dcn.parse({...t,num_pins:n}),{p:r,id:o,od:s,w:a,h:c,inline:l}=i,u=Number.parseFloat(c)/2,d=Number.parseFloat(r);let h=[];if(i.num_pins===3)h=l?[Aa(1,-d,u-d,o,s),Aa(2,0,u-d,o,s),Aa(3,d,u-d,o,s)]:[Aa(1,0,u,o,s),Aa(2,-d,u-d,o,s),Aa(3,d,u-d,o,s)];else if(i.num_pins===2)h=Fcn(i);else throw new Error("Invalid number of pins for TO-92");const f=Number.parseFloat(a)/2,m=zcn(0,u,f),y={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[...m,{x:-f,y:0},{x:f,y:0},m[0]],stroke_width:.1,pcb_silkscreen_path_id:""},g=zo(0,u+1,.5);return{circuitJson:[...h,y,g],parameters:i}},Ucn=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("2.15mm"),h:B().default("1.20mm"),pl:B().default("0.5mm"),pw:B().default("0.6mm"),p:B().default("1.4mm")}),$cn=t=>{const e=Ucn.parse(t),n=zo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Hcn(e).concat(i,n),parameters:e}},jcn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Hcn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=jcn({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Vcn=_5({}),Gcn=t=>{const e=Vcn.parse(t),n=[];for(let s=0;s<e.num_pins;s++){const{x:a,y:c}=x0e({num_pins:e.num_pins,pn:s+1,w:e.w,p:e.p??1.27,pl:e.pl,widthincludeslegs:!0});n.push(Dr(s+1,a,c,e.pl??"1.5mm",e.pw??"0.6mm"))}const i=(e.num_pins/2-1)*e.p+e.pw,r=zo(0,i/2-.5,i/12),o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:-e.w/3,y:i/2+.2},{x:e.w/3,y:i/2+.2}],stroke_width:.1};return{circuitJson:[...n,r,o],parameters:e}},Ycn=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("5.0mm"),h:B().default("2.30mm"),pl:B().default("1.25mm"),pw:B().default("2mm"),p:B().default("3.75mm")}),qcn=t=>{const e=Ycn.parse(t),n=zo(0,_t.parse(e.h)/2+1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2+.5,y:_t.parse(e.h)/2+.5},{x:-_t.parse(e.w)/2-.5,y:_t.parse(e.h)/2+.5},{x:-_t.parse(e.w)/2-.5,y:-_t.parse(e.h)/2-.5},{x:_t.parse(e.p)/2+.5,y:-_t.parse(e.h)/2-.5}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Wcn(e).concat(i,n),parameters:e}},Xcn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Wcn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=Xcn({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Zcn=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("4.4mm"),h:B().default("2.1mm"),pl:B().default("1.2mm"),pw:B().default("1.2mm"),p:B().default("2.9mm")}),Kcn=t=>{const e=Zcn.parse(t),n=zo(0,_t.parse(e.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Jcn(e).concat(i,n),parameters:e}},Qcn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Jcn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=Qcn({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},eln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("3.30mm"),h:B().default("1.80mm"),pl:B().default("0.60mm"),pw:B().default("0.45mm"),p:B().default("2.1mm")}),tln=t=>{const e=eln.parse(t),n=zo(0,_t.parse(e.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:iln(e).concat(i,n),parameters:e}},nln=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},iln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=nln({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},rln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("1.4mm"),h:B().default("0.9mm"),pl:B().default("0.35mm"),pw:B().default("0.25mm"),p:B().default("1.2mm")}),oln=t=>{const e=rln.parse(t),n=zo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2+.15,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.4,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.4,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2+.15,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:aln(e).concat(i,n),parameters:e}},sln=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},aln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=sln({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},cln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("1.3mm"),h:B().default("0.9mm"),pl:B().default("0.4mm"),pw:B().default("0.7mm"),p:B().default("0.7mm")}),lln=t=>{const e=cln.parse(t),n=zo(0,_t.parse(e.h)+.1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2+.2,y:_t.parse(e.h)/2+.2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2+.2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2-.2},{x:_t.parse(e.p)/2+.2,y:-_t.parse(e.h)/2-.2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:dln(e).concat(i,n),parameters:e}},uln=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},dln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=uln({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},hln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("3,05mm"),h:B().default("1.65mm"),pl:B().default("0.6mm"),pw:B().default("0.6mm"),pad_spacing:B().default("2.2mm")}),pln=t=>{const e=hln.parse(t),n=zo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.pad_spacing)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.pad_spacing)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:mln(e).concat(i,n),parameters:e}},fln=t=>{const{pn:e,pad_spacing:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},mln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=fln({pn:n,pad_spacing:Number.parseFloat(t.pad_spacing)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},_ln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("4.4mm"),h:B().default("2.1mm"),pl:B().default("1.2mm"),pw:B().default("1.2mm"),p:B().default("2.9mm")}),yln=t=>{const e=_ln.parse(t),n=zo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:bln(e).concat(i,n),parameters:e}},gln=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},bln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=gln({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},xln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("4.4mm"),h:B().default("2.1mm"),pl:B().default("0.91mm"),pw:B().default("1.22mm"),p:B().default("3.146mm")}),vln=t=>{const e=xln.parse(t),n=zo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Sln(e).concat(i,n),parameters:e}},wln=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Sln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=wln({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Eln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("1.80mm"),h:B().default("1.00mm"),pl:B().default("0.66mm"),pw:B().default("0.5mm"),p:B().default("0.8mm")}),Tln=t=>{const e=Eln.parse(t),n=zo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.1,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.1,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Aln(e).concat(i,n),parameters:e}},Mln=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Aln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=Mln({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Cln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("6.2mm"),h:B().default("3.4mm"),pl:B().default("1.4mm"),pw:B().default("2.1mm"),p:B().default("4.4mm")}),Rln=t=>{const e=Cln.parse(t),n=zo(0,_t.parse(e.h)/2+.4,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Iln(e).concat(i,n),parameters:e}},Pln=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Iln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=Pln({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Nln=Ne({fn:B(),num_pins:oi([Ce(3),Ce(5)]).default(3),w:B().default("4.80mm"),h:B().default("4.80mm"),pl:B().default("1.3mm"),pw:B().default("0.9mm"),p:B().default("1.5mm"),string:B().optional()}),kln=t=>{const e=[],n=Number.parseFloat(t.p),i=Number.parseFloat(t.pw),r=Number.parseFloat(t.w),o=Number.parseFloat(t.pl);e.push(Dr(1,-r/2,n,o,i),Dr(2,-r/2+(1.5-1.3)/2,0,1.5,i),Dr(3,-r/2,-n,o,i));const s=zo(0,0,.3),a=Number.parseFloat(t.w)/2-1,c=Number.parseFloat(t.h)/2,l={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-a,y:c},{x:a,y:c},{x:a,y:c/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},u={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-a,y:-c},{x:a,y:-c},{x:a,y:-c/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1};return[...e,l,u,s]},Oln=t=>{const e=[];Number.parseFloat(t.p),Number.parseFloat(t.pw),Number.parseFloat(t.w),e.push(Dr(1,-1.85,-1.5,1.5,.7),Dr(2,-1.85,1.5,1.5,.7),Dr(3,0,0,.8,2),Dr(4,1.85,-1.5,1.5,.7),Dr(5,1.85,1.5,1.5,.7));const n=zo(0,Number.parseFloat(t.h)/2+.5,.3),i=Number.parseFloat(t.w)/2-1,r=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:r},{x:i,y:r}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-r},{x:i,y:-r}],type:"pcb_silkscreen_path",stroke_width:.1};return[...e,o,s,n]},Lln=t=>{const e=t.string?.match(/^sot89_(\d+)/),n=e?Number.parseInt(e[1],10):3,i=Nln.parse({...t,num_pins:n});if(i.num_pins===3)return{circuitJson:kln(i),parameters:i};if(i.num_pins===5)return{circuitJson:Oln(i),parameters:i};throw new Error("Invalid number of pins for SOT89")},Dln=Ne({fn:B(),p:_t.optional().default("5.0mm"),id:_t.optional().default("1.0mm"),od:_t.optional().default("1.9mm"),w:_t.optional().default("13mm"),h:_t.optional().default("7mm"),num_pins:Ue().optional(),string:B().optional()}),zln=t=>{const e=Dln.parse(t),{fn:n,id:i,od:r,w:o,h:s,string:a}=e,c=Number.parseInt(a?.split("_")[1]??"3"),l=-1,u=o/2,d=s/2,h=2.5,f=o*.4,m=Math.max(h,f/(c-1)),y=Array.from({length:c},(N,R)=>{const P=c%2===0?(R-c/2+.5)*m:(R-Math.floor(c/2))*m;return Aa(R+1,P,l,i,r)}),g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-u,y:-d},{x:u,y:-d},{x:u,y:d},{x:-u,y:d},{x:-u,y:-d}],stroke_width:.1,pcb_silkscreen_path_id:""},b=-d+2*s/3,v={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-u,y:b},{x:u,y:b}],stroke_width:.1,pcb_silkscreen_path_id:""},w=[{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-o/6,y:b},{x:-o/6,y:d}],stroke_width:.1,pcb_silkscreen_path_id:""},{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:o/6,y:b},{x:o/6,y:d}],stroke_width:.1,pcb_silkscreen_path_id:""}],T=zo(0,s/2+.6,.5);return{circuitJson:[...y,g,v,...w,T],parameters:{...e,p:m}}},Fln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("5.40mm"),h:B().default("2.30mm"),pl:B().default("1.30mm"),pw:B().default("1.70mm"),p:B().default("3.5mm")}),Bln=t=>{const e=Fln.parse(t),n=zo(0,_t.parse(e.h)/2+.4,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:$ln(e).concat(i,n),parameters:e}},Uln=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},$ln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=Uln({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},jln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("1.90mm"),h:B().default("1.33mm"),pl:B().default("0.5mm"),pw:B().default("0.7mm"),p:B().default("0.8mm")}),Hln=t=>{const e=jln.parse(t),n=zo(0,_t.parse(e.h)+.1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2+.1,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2+.1,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Gln(e).concat(i,n),parameters:e}},Vln=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Gln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=Vln({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Yln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("7.0mm"),h:B().default("3.35mm"),pl:B().default("1.50mm"),pw:B().default("2.70mm"),p:B().default("4.8mm")}),qln=t=>{const e=Yln.parse(t),n=zo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Wln(e).concat(i,n),parameters:e}},Xln=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Wln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=Xln({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Zln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("3.0mm"),h:B().default("1.80mm"),pl:B().default("0.80mm"),pw:B().default("1.20mm"),p:B().default("1.6mm")}),Kln=t=>{const e=Zln.parse(t),n=zo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.1,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.1,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Jln(e).concat(i,n),parameters:e}},Qln=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Jln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=Qln({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},eun=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("7.10mm"),h:B().default("3.40mm"),pl:B().default("2.45mm"),pw:B().default("1.80mm"),p:B().default("4.05mm")}),tun=t=>{const e=eun.parse(t),n=zo(0,_t.parse(e.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.5,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.5,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:iun(e).concat(i,n),parameters:e}},nun=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},iun=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=nun({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},run=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("4.80mm"),h:B().default("2.10mm"),pl:B().default("1.30mm"),pw:B().default("1.40mm"),p:B().default("2.9mm")}),oun=t=>{const e=run.parse(t),n=zo(0,_t.parse(e.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:aun(e).concat(i,n),parameters:e}},sun=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},aun=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=sun({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},cun=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("7.30mm"),h:B().default("4.40mm"),pl:B().default("2.50mm"),pw:B().default("2.30mm"),p:B().default("4.30mm")}),lun=t=>{const e=cun.parse(t),n=zo(0,_t.parse(e.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.1,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.1,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:dun(e).concat(i,n),parameters:e}},uun=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},dun=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=uun({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},hun=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("10.70mm"),h:B().default("6.60mm"),pl:B().default("3.30mm"),pw:B().default("2.50mm"),p:B().default("6.80mm")}),pun=t=>{const e=hun.parse(t),n=zo(0,3,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2-.8},{x:-_t.parse(e.w)/2-.8,y:_t.parse(e.h)/2-.8},{x:-_t.parse(e.w)/2-.8,y:-_t.parse(e.h)/2+.8},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2+.8}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:mun(e).concat(i,n),parameters:e}},fun=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},mun=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=fun({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},_un=Ne({fn:B(),num_pins:Ue().default(4),w:B().default("8.50mm"),h:B().default("6.90mm"),pl:B().default("2mm"),pw:B().default("1.5mm"),p:B().default("2.30mm"),string:B().optional()}),yun=t=>{const e=t.string?.match(/^sot223_(\d+)/),n=e?Number.parseInt(e[1],10):4;if(n===8){const r=xun.parse({...t,num_pins:n});return{circuitJson:r3(r),parameters:r}}const i=_un.parse({...t,num_pins:n});if(i.num_pins===4)return{circuitJson:bun(i),parameters:i};if(i.num_pins===5)return{circuitJson:wun(i),parameters:i};if(i.num_pins===6)return{circuitJson:Eun(i),parameters:i};throw new Error("Invalid number of pins")},gun=t=>{const{pn:e,w:n,p:i}=t;return e===1?{x:-n/2+1.1,y:i}:e===2?{x:-n/2+1.1,y:0}:e===3?{x:-n/2+1.1,y:-i}:{x:n/2-1.1,y:0}},bun=t=>{const e=[];for(let a=0;a<t.num_pins;a++){const{x:c,y:l}=gun({num_pins:t.num_pins,pn:a+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)}),u=a===3?3.8:Number.parseFloat(t.pw);e.push(Dr(a+1,c,l,Number.parseFloat(t.pl),u))}const n=zo(0,0,.3),i=Number.parseFloat(t.w)/2-2.4,r=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:r},{x:i,y:r},{x:i,y:r/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-r},{x:i,y:-r},{x:i,y:-r/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1};return[...e,o,s,n]},xun=_5({p:"0.90mm",w:"2.8mm",legsoutside:!0}),vun=t=>{const{p:e,pn:n,w:i}=t;if(n===1)return{x:-i/2+1.2,y:e/2+e};if(n===2)return{x:-i/2+1.2,y:e/2};if(n===3)return{x:-i/2+1.2,y:-e/2};if(n===4)return{x:-i/2+1.2,y:-e/2-e};if(n===5)return{x:i/2-1,y:0};throw new Error("Invalid pin number")},wun=t=>{const e=[];for(let a=1;a<=t.num_pins;a++){const{x:c,y:l}=vun({h:Number.parseFloat(t.h),p:1.5,pn:a,w:Number.parseFloat(t.w)});let u=Number.parseFloat(t.pw),d=Number.parseFloat(t.pl);a===5?(u=3.4,d=1.8):(u=1,d=2.2),e.push(Dr(a,c,l,d,u))}const n=Number.parseFloat(t.w)/2-2.4,i=Number.parseFloat(t.h)/2,r={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-n,y:i},{x:n,y:i},{x:n,y:i/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-n,y:-i},{x:n,y:-i},{x:n,y:-i/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},s=zo(0,0,.3);return[...e,r,o,s]},Sun=t=>{const{p:e,pn:n,w:i}=t;if(n===1)return{x:-i/2+1.2,y:2*e};if(n===2)return{x:-i/2+1.2,y:e};if(n===3)return{x:-i/2+1.2,y:0};if(n===4)return{x:-i/2+1.2,y:-e};if(n===5)return{x:-i/2+1.2,y:-2*e};if(n===6)return{x:i/2-1.175,y:0};throw new Error("Invalid pin number")},Eun=t=>{const e=[];for(let a=1;a<=t.num_pins;a++){const{x:c,y:l}=Sun({h:Number.parseFloat(t.h),p:1.3,pn:a,w:8.7});let u=Number.parseFloat(t.pw),d=Number.parseFloat(t.pl);a===6?(u=3.4,d=2.15):(u=.6,d=2.2),e.push(Dr(a,c,l,d,u))}const n=Number.parseFloat(t.w)/2-2.4,i=Number.parseFloat(t.h)/2,r={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-n,y:i},{x:n,y:i},{x:n,y:i/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-n,y:-i},{x:n,y:-i},{x:n,y:-i/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},s=zo(0,0,.3);return[...e,r,o,s]},Tun=Ne({fn:B(),num_pins:Ue().default(3),w:B().default("3.40mm"),h:B().default("3.30mm"),pl:B().default("1mm"),pw:B().default("0.7mm"),p:B().default("1.2mm"),string:B().optional()}),Mun=t=>{const e=t.string?.match(/^sot23w_(\d+)/),n=e?Number.parseInt(e[1],3):3,i=Tun.parse({...t,num_pins:n});if(i.num_pins===3)return{circuitJson:Cun(i),parameters:i};throw new Error("Invalid number of pins")},Aun=t=>{const{pn:e,p:n}=t;return e===1?{x:-n,y:.95}:e===2?{x:-n,y:-.95}:{x:n,y:0}},Cun=t=>{const e=[];for(let a=0;a<t.num_pins;a++){const{x:c,y:l}=Aun({num_pins:t.num_pins,pn:a+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)});e.push(Dr(a+1,c,l,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=zo(0,Number.parseInt(t.h)/2+1,.3),i=Number.parseFloat(t.w)/2-1,r=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:r},{x:i+.3,y:r},{x:i+.3,y:r/2}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-r},{x:i+.3,y:-r},{x:i+.3,y:-r/2}],type:"pcb_silkscreen_path",stroke_width:.1};return[...e,o,s,n]},Run=Ne({fn:B(),num_pins:oi([Ce(3),Ce(2)]).default(3),p:B().default("1.27mm"),id:B().default("0.72mm"),od:B().default("0.95mm"),w:B().default("2.5mm"),h:B().default("4.2mm"),string:B().optional()}),Pun=t=>{const{p:e,id:n,od:i,w:r,h:o}=t,s=Number.parseFloat(o)/2,a=Number.parseFloat(e);return[Aa(1,-a,s-a,n,i),Aa(2,0,s-a,n,i),Aa(3,a,s-a,n,i)]},Iun=t=>{const{p:e,id:n,od:i,h:r}=t,o=Number.parseFloat(r)/2,s=Number.parseFloat(e);return[Aa(1,-s,o-s,n,i),Aa(2,s,o-s,n,i)]},Nun=t=>{const e=t.string?.match(/^to92s_(\d+)/),n=e?Number.parseInt(e[1],10):3,i=Run.parse({...t,num_pins:n});let r=[];if(i.num_pins===3)r=Pun(i);else if(i.num_pins===2)r=Iun(i);else throw new Error("Invalid number of pins for TO-92");const o=Number.parseFloat(i.h)/2,s=Number.parseFloat(i.p),a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-o,y:o-s},{x:-1.9,y:0},{x:1.9,y:0},{x:o,y:o-s},{x:1.5,y:Number.parseFloat(i.h)/2+.5},{x:-1.5,y:Number.parseFloat(i.h)/2+.5},{x:-o,y:o-s}],stroke_width:.1,pcb_silkscreen_path_id:""},c=zo(0,o+1,.5);return{circuitJson:[...r,a,c],parameters:i}},kun=Ne({fn:B(),p:_t.optional(),id:_t.optional(),pw:_t.optional(),pl:_t.optional(),w:_t.optional(),h:_t.optional(),sh:oi([bt(),B(),Ue()]).optional().transform(t=>{if(typeof t=="string"){const e=Number(t);return Number.isNaN(e)?!0:e}return t}).describe('JST SH (Surface-mount) connector family. SH stands for "Super High-density".'),ph:bt().optional().describe('JST PH (Through-hole) connector family. PH stands for "Pin Header".'),string:B().optional()}),Oun={ph:{p:_t.parse("2.2mm"),id:_t.parse("0.70mm"),pw:_t.parse("1.20mm"),pl:_t.parse("1.20mm"),w:_t.parse("6mm"),h:_t.parse("5mm")},sh:{p:_t.parse("1mm"),pw:_t.parse("0.6mm"),pl:_t.parse("1.55mm"),w:_t.parse("5.8mm"),h:_t.parse("7.8mm")}};function Lun(t){return t.sh?"sh":(t.ph,"ph")}function Dun(t,e,n,i,r,o){const s=[];if(t==="ph"){const a=n/2;s.push(nj(1,-a,2,i,r,o)),s.push(nj(2,a,2,i,r,o))}else{const a=-((e-1)/2)*n;for(let l=0;l<e;l++){const u=a+l*n;console.log("x si",u),s.push(Dr(l+1,u,-1.325,r,o))}const c=(e-1)/2*n+1.3;console.log("offset",c),s.push(Dr(e+1,-c,1.22,1.2,1.8)),s.push(Dr(e+2,c,1.22,1.2,1.8))}return s}function zun(t,e,n){return t==="ph"?{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-3,y:3},{x:3,y:3},{x:3,y:-2},{x:-3,y:-2},{x:-3,y:3}],stroke_width:.1,pcb_silkscreen_path_id:""}:{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[],stroke_width:.1,pcb_silkscreen_path_id:""}}var Fun=t=>{const e=kun.parse(t),n=Lun(e),i=Oun[n],r=e.p??i.p,o=e.id??i.id,s=e.pw??i.pw,a=e.pl??i.pl,c=e.w??i.w,l=e.h??i.h;let u=n==="sh"?4:2;if(n==="sh"){const y=(typeof t.string=="string"?t.string:"").match(/sh(\d+)/);if(y&&y[1]){const g=parseInt(y[1],10);Number.isNaN(g)||(u=g)}else typeof e.sh=="number"&&(u=e.sh)}const d=Dun(n,u,r,o,s,a),h=zun(n),f=zo(0,l/2+1,.5);return{circuitJson:[...d,h,f],parameters:{...e,p:r,id:o,pw:s,pl:a,w:c,h:l,num_pins:u,sh:n==="sh",ph:n==="ph"}}},Bun=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("3.30mm"),h:B().default("1.70mm"),pl:B().default("0.80mm"),pw:B().default("1mm"),p:B().default("1.90mm")}),Uun=t=>{const e=Bun.parse(t),n=zo(0,_t.parse(e.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:jun(e).concat(i,n),parameters:e}},$un=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},jun=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=$un({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Hun=t=>{switch(t){case 8:return{w:"3.06mm",h:"3.14mm",p:"0.65mm",pl:"1.6mm",pw:"0.5mm"};case 10:return{w:"3.10mm",h:"3.33mm",p:"0.5mm",pl:"1.45mm",pw:"0.3mm"};default:return{w:"3.06mm",h:"3.14mm",p:"0.65mm",pl:"1.6mm",pw:"0.5mm"}}},Vun=Ne({fn:B(),num_pins:oi([Ce(8),Ce(10)]).default(8),w:B().optional(),h:B().optional(),p:B().optional(),pl:B().optional(),pw:B().optional(),string:B().optional()}),Gun=t=>{const e=Vun.parse(t),n=Hun(e.num_pins),i=_t.parse(e.w||n.w),r=_t.parse(e.h||n.h),o=_t.parse(e.p||n.p),s=_t.parse(e.pl||n.pl),a=_t.parse(e.pw||n.pw),c=[],l=e.num_pins/2;for(let v=0;v<e.num_pins;v++){const{x:w,y:T}=Tqe(e.num_pins,v+1,i,o),N=v<l?v+1:e.num_pins-(v-l);c.push(Dr(N,w,T,s,a))}const u=i,d=r,h={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-u/2,y:d/2},{x:u/2,y:d/2}],stroke_width:.05,pcb_silkscreen_path_id:""},f={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-u/2,y:-d/2},{x:u/2,y:-d/2}],stroke_width:.05,pcb_silkscreen_path_id:""},m=Tqe(e.num_pins,1,u,o),y={x:m.x-.8,y:m.y},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:y.x-.4,y:y.y},{x:y.x-.7,y:y.y+.3},{x:y.x-.7,y:y.y-.3},{x:y.x-.4,y:y.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},b=zo(0,d/2+.5,.3);return{circuitJson:[...c,h,f,b,g],parameters:e}},Tqe=(t,e,n,i)=>{const r=t/2,o=(e-1)%r,s=e<=r?-1:1,a=(r-1)/2-o;return{x:s*_t.parse(t===8?"1.8mm":"2.2mm"),y:a*i}},Yun=t=>{switch(t){case 10:return{w:"3.10mm",h:"3.32mm",p:"0.5mm",pl:"1.63mm",pw:"0.33mm"};case 12:return{w:"3mm",h:"4mm",p:"0.65mm",pl:"0.88mm",pw:"0.4mm"};case 16:return{w:"3.10mm",h:"4mm",p:"0.5mm",pl:"0.88mm",pw:"0.3mm"};default:return{w:"3.10mm",h:"3.32mm",p:"0.65mm",pl:"1.63mm",pw:"0.4mm"}}},qun=Ne({fn:B(),num_pins:oi([Ce(8),Ce(10),Ce(12),Ce(16)]).default(8),w:B().optional(),h:B().optional(),p:B().optional(),pl:B().optional(),pw:B().optional(),string:B().optional()}),Mqe=(t,e,n,i)=>{const r=t/2,o=(e-1)%r,s=e<=r?-1:1,a=(r-1)/2-o;return{x:s*_t.parse("2mm"),y:a*i}},Xun=t=>{const e=qun.parse(t),n=Yun(e.num_pins),i=_t.parse(e.w||n.w),r=_t.parse(e.h||n.h),o=_t.parse(e.p||n.p),s=_t.parse(e.pl||n.pl),a=_t.parse(e.pw||n.pw),c=[];for(let b=0;b<e.num_pins;b++){const{x:v,y:w}=Mqe(e.num_pins,b+1,i,o);c.push(Dr(b+1,v,w,s,a))}const l=i,u=r,d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-l/2,y:u/2},{x:l/2,y:u/2}],stroke_width:.05,pcb_silkscreen_path_id:""},h={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-l/2,y:-u/2},{x:l/2,y:-u/2}],stroke_width:.05,pcb_silkscreen_path_id:""},f=Mqe(e.num_pins,1,l,o),m={x:f.x-.8,y:f.y},y={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:m.x-.4,y:m.y},{x:m.x-.7,y:m.y+.3},{x:m.x-.7,y:m.y-.3},{x:m.x-.4,y:m.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},g=zo(0,u/2+.5,.3);return{circuitJson:[...c,d,h,g,y],parameters:e}},Wun=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("3.8mm"),h:B().default("1.65mm"),pl:B().default("1.2mm"),pw:B().default("1.2mm"),pad_spacing:B().default("2.6mm")}),Zun=t=>{const e=Wun.parse(t),n=zo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.pad_spacing)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.pad_spacing)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Qun(e).concat(i,n),parameters:e}},Kun=t=>{const{pn:e,pad_spacing:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Qun=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=Kun({pn:n,pad_spacing:Number.parseFloat(t.pad_spacing)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Jun=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("3.20mm"),h:B().default("1.65mm"),pl:B().default("0.8mm"),pw:B().default("0.9mm"),pad_spacing:B().default("2.1mm")}),edn=t=>{const e=Jun.parse(t),n=zo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.pad_spacing)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.pad_spacing)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:ndn(e).concat(i,n),parameters:e}},tdn=t=>{const{pn:e,pad_spacing:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},ndn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=tdn({pn:n,pad_spacing:Number.parseFloat(t.pad_spacing)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},idn=Ne({fn:B(),num_pins:oi([Ce(6),Ce(8)]).default(8),w:B().default("3mm"),h:B().default("3mm"),p:B().default("0.5mm"),pl:B().default("0.52mm"),pw:B().default("0.35mm"),epw:B().default("1.40mm"),eph:B().default("1.60mm"),string:B().optional(),ep:bt().default(!1)}),rdn=t=>{t.string&&t.string.includes("_ep")&&(t.ep=!0);const e=t.string?.match(/^son_(\d+)/),n=e?Number.parseInt(e[1],10):t.num_pins||8,i=idn.parse({...t,num_pins:n}),r=_t.parse(i.w),o=_t.parse(i.h),s=_t.parse(i.p),a=_t.parse(i.pl),c=_t.parse(i.pw),l=_t.parse(i.epw),u=_t.parse(i.eph),d=[];for(let T=0;T<i.num_pins;T++){const{x:N,y:R}=Aqe(i.num_pins,T+1,r,s);d.push(Dr(T+1,N,R,a,c))}i.ep&&d.push(Dr(i.num_pins+1,0,0,l,u));const h=r,f=o,m={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-h/2,y:f/2},{x:h/2,y:f/2}],stroke_width:.05,pcb_silkscreen_path_id:""},y={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-h/2,y:-f/2},{x:h/2,y:-f/2}],stroke_width:.05,pcb_silkscreen_path_id:""},g=Aqe(i.num_pins,1,h,s),b={x:g.x-.4,y:g.y},v={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:b.x-.4,y:b.y},{x:b.x-.7,y:b.y+.3},{x:b.x-.7,y:b.y-.3},{x:b.x-.4,y:b.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},w=zo(0,f/2+.5,.3);return{circuitJson:[...d,m,y,w,v],parameters:i}},Aqe=(t,e,n,i)=>{const r=t/2,o=(e-1)%r,s=e<=r?-1:1,a=(r-1)/2-o;return{x:s*_t.parse("1.4mm"),y:a*i}},odn=t=>{const{num_pins:e,bridged:n,p:i=2.54,pw:r=1.5,ph:o=1.5}=t,s=_t.parse(i),a=_t.parse(r),c=_t.parse(o),l=Math.min(c/4,.5),u=[];for(let T=0;T<e;T++)u.push(Dr(T+1,T*s,0,a,c));let d=[];if(n){const T=n.split("").map(Number);if(T.length>1)for(let N=0;N<T.length-1;N++){const R=T[N],P=T[N+1];if(typeof R=="number"&&typeof P=="number"&&!isNaN(R)&&!isNaN(P)){const M=(R-1)*s,I=(P-1)*s,A=Math.sign(I-M),$=M+A*(a/2),k=I-A*(a/2);d.push({type:"pcb_trace",pcb_trace_id:"",route:[{start_pcb_port_id:`{PIN${R}}`,x:$,y:0,width:l,layer:"top",route_type:"wire"},{end_pcb_port_id:`{PIN${P}}`,x:k,y:0,width:l,layer:"top",route_type:"wire"}]})}}}const h=(e-1)*s+a+.7,f=c+1,m=(e-1)*s/2,y=0,g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"outline",route:[{x:m-h/2,y:y-f/2},{x:m+h/2,y:y-f/2},{x:m+h/2,y:y+f/2},{x:m-h/2,y:y+f/2},{x:m-h/2,y:y-f/2}],stroke_width:.15},v=y+f/2+.6,w=zo(m,v,.4);return{circuitJson:[...u,...d,g,w],parameters:t}},Cqe={fn:Ce("sot457"),num_pins:Ce(6).default(6),pillh:B().default("0.45mm"),pillw:B().default("1.45mm"),pl:B(),pw:B(),p:B(),wave:bt().optional(),reflow:bt().optional()},sdn=Ne({...Cqe,h:B().default("2.5mm"),w:B().default("2.7mm"),pl:B().default("0.8mm"),pw:B().default("0.55mm"),p:B().default("0.95mm")}),adn=Ne({...Cqe,h:B().default("3mm"),w:B().default("4mm"),pillr:B().default("0.225mm"),pl:B().default("1.45mm"),pw:B().default("1.5mm"),p:B().default("1.475mm")}).transform(t=>({...t,wave:t.wave??(t.reflow===void 0?!0:!t.reflow),reflow:t.reflow??(t.wave===void 0?!1:!t.wave)})),o3=t=>Number.parseFloat(t.replace("mm","")),Rqe=({pitch:t,width:e,pinNumber:n})=>{const o={1:{x:-e/2-.1,y:t},2:{x:-e/2-.1,y:0},3:{x:-e/2-.1,y:-t},4:{x:e/2+.1,y:-t},5:{x:e/2+.1,y:0},6:{x:e/2+.1,y:t}}[n];if(!o)throw new Error(`Invalid pin number: ${n}`);return o},Pqe=t=>{const e=[],n=o3(t.p),i=o3(t.pl),r=o3(t.pw),o=o3(t.w),s=o3(t.h);if(t.wave){const m={1:({padWidth:y,padHeight:g})=>Dr(1,-n,n,g,y),2:({padWidth:y,padHeight:g})=>Dr(2,-n,-n,g,y),3:({padWidth:y,padHeight:g})=>tj(3,-n,0,o3(t.pillw),o3(t.pillh)),4:({padWidth:y,padHeight:g})=>tj(4,n,0,o3(t.pillw),o3(t.pillh)),5:({padWidth:y,padHeight:g})=>Dr(5,n,n,g,y),6:({padWidth:y,padHeight:g})=>Dr(6,n,-n,g,y)};for(let y=1;y<=t.num_pins;y++){const g=m[y];g&&e.push(g({padWidth:i,padHeight:r}))}}else for(let m=1;m<=t.num_pins;m++){const{x:y,y:g}=Rqe({pitch:n,width:o,pinNumber:m});e.push(Dr(m,y,g,i,r))}const a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-o/3,y:s/2+n/1.3},{x:o/3,y:s/2+n/1.3}],stroke_width:.05},c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-o/3,y:-s/2-n/1.3},{x:o/3,y:-s/2-n/1.3}],stroke_width:.05},l=zo(0,s+.5,.3),u=Rqe({pitch:n,width:o,pinNumber:1}),d=t.wave?1:.5,h=t.wave?.7:.3;u.x-=t.wave?r:r*1.7;const f={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:u.x+d/2,y:u.y},{x:u.x-d/2,y:u.y+h/2},{x:u.x-d/2,y:u.y-h/2},{x:u.x+d/2,y:u.y}],stroke_width:.05};return[l,a,c,f,...e]},cdn=t=>{if(t.wave){const n=adn.parse({...t,fn:"sot457"});return{circuitJson:Pqe(n),parameters:n}}const e=sdn.parse(t);return{circuitJson:Pqe(e),parameters:e}},ldn=Ne({fn:B(),num_pins:oi([Ce(3),Ce(2)]).default(3),p:B().default("3.8mm"),id:B().default("1.25mm"),od:B().default("2.35mm"),ca:B().default("14mm").describe("Caliper axis (width or diameter of the potentiometer body or adjustment knob)"),w:B().default("5.35mm"),h:B().default("4mm"),string:B().optional()}),udn=t=>{const{p:e,id:n,od:i,h:r,ca:o}=t,s=Number.parseFloat(r),a=Number.parseFloat(o);return[Aa(1,0,a/4+.3,n,i),Aa(2,s,0,n,i),Aa(3,0,-a/4-.3,n,i)]},ddn=t=>{const e=t.string?.match(/^potentiometer_(\d+)/),n=e?Number.parseInt(e[1],10):3,i=ldn.parse({...t,num_pins:n});let r=[];i.num_pins===3&&(r=udn(i));const o=Number.parseFloat(i.ca)/2+.15,s=Number.parseFloat(i.w),a=Number.parseFloat(i.od)/2+.35,c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:o-1.75},{x:0,y:o},{x:s,y:o},{x:s,y:a}],stroke_width:.1,pcb_silkscreen_path_id:""},l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:s,y:-a},{x:s,y:-o},{x:0,y:-o},{x:0,y:-o+1.75}],stroke_width:.1,pcb_silkscreen_path_id:""},u=Number.parseFloat(i.w)/2,d=zo(u,o+1,.5);return{circuitJson:[...r,c,l,d],parameters:i}},hdn=Ne({fn:B(),p:_t.optional().default("7.5mm"),id:_t.optional().default("1mm"),od:_t.optional().default("2mm"),d:_t.optional().default("10.5mm")}),pdn=(t,e,n,i,r)=>{const o=[],s=[];for(let a=0;a<=50;a++){const c=a/50*Math.PI,l=t+Math.cos(c)*n,u=e+Math.sin(c)*n;l<t-i&&u>=e-r/2&&u<=e+r/2||o.push({x:l,y:u})}for(let a=0;a<=50;a++){const c=Math.PI+a/50*Math.PI,l=t+Math.cos(c)*n,u=e+Math.sin(c)*n;l<t-i&&u>=e-r/2&&u<=e+r/2||s.push({x:l,y:u})}return{topArc:o,bottomArc:s}},fdn=t=>{const e=hdn.parse(t),{p:n,id:i,od:r,d:o}=e,s=[Aa(1,-n/2,0,i,r),Aa(2,n/2,0,i,r)],{topArc:a,bottomArc:c}=pdn(0,0,o/2+.1,r/2,r),l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:a,stroke_width:.1,pcb_silkscreen_path_id:""},u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:c,stroke_width:.1,pcb_silkscreen_path_id:""},d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:o/2+.1},{x:0,y:-(o/2+.1)}],stroke_width:.1,pcb_silkscreen_path_id:""},h=-(o/2+.5),f=r/2+1.5,m=.5,y={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:h-m,y:f},{x:h+m,y:f}],stroke_width:.1,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:h,y:f-m},{x:h,y:f+m}],stroke_width:.1,pcb_silkscreen_path_id:""},b=zo(0,o/2+1,.5);return{circuitJson:[...s,l,u,d,y,g,b],parameters:e}},mdn=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("6.5mm"),h:B().default("3mm"),pl:B().default("1.75mm"),pw:B().default("2.40mm"),p:B().default("4.75mm")}),_dn=t=>{const e=mdn.parse(t),n=zo(0,_t.parse(e.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.3,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.3,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:gdn(e).concat(i,n),parameters:e}},ydn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},gdn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=ydn({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},bdn=Ne({fn:B(),num_pins:Ue().default(3),w:B().default("2.45mm"),h:B().default("2.40mm"),pl:B().default("0.45mm"),pw:B().default("0.70mm"),p:B().default("1mm"),string:B().optional()}),xdn=t=>{const e=t.string?.match(/^sot323_(\d+)/),n=e?Number.parseInt(e[1],3):3,i=bdn.parse({...t,num_pins:n});if(i.num_pins===3)return{circuitJson:wdn(i),parameters:i};throw new Error("Invalid number of pins")},vdn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n,y:.65}:e===2?{x:-n,y:-.65}:{x:n,y:0}},wdn=t=>{const e=[];for(let a=0;a<t.num_pins;a++){const{x:c,y:l}=vdn({num_pins:t.num_pins,pn:a+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)});e.push(Dr(a+1,c,l,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=zo(0,Number.parseInt(t.h)/2+1,.3),i=Number.parseFloat(t.w)/2-Number.parseFloat(t.pl),r=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:r+.3},{x:i,y:r+.3},{x:i,y:r/2}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-r-.3},{x:i,y:-r-.3},{x:i,y:-r/2}],type:"pcb_silkscreen_path",stroke_width:.1};return[...e,o,s,n]},Sdn=Ne({fn:B(),circle:bt().optional(),rect:bt().optional(),square:bt().optional(),pill:bt().optional(),d:_t.optional(),pd:_t.optional(),diameter:_t.optional(),r:_t.optional(),pr:_t.optional(),radius:_t.optional(),w:_t.optional(),pw:_t.optional(),width:_t.optional(),h:_t.optional(),ph:_t.optional(),height:_t.optional(),s:_t.optional(),size:_t.optional(),string:B().optional()}).transform(t=>{let e="rect";t.circle&&(e="circle"),t.square&&(e="square"),t.rect&&(e="rect"),t.pill&&(e="pill");let n,i,r;return e==="circle"?t.r!==void 0?n=dh(t.r):t.pr!==void 0?n=dh(t.pr):t.radius!==void 0?n=dh(t.radius):t.d!==void 0?n=dh(t.d)/2:t.pd!==void 0?n=dh(t.pd)/2:t.diameter!==void 0?n=dh(t.diameter)/2:n=dh("1mm")/2:(t.w!==void 0?i=dh(t.w):t.pw!==void 0?i=dh(t.pw):t.width!==void 0?i=dh(t.width):t.s!==void 0?i=dh(t.s):t.size!==void 0?i=dh(t.size):i=dh("1mm"),t.h!==void 0?r=dh(t.h):t.ph!==void 0?r=dh(t.ph):t.height!==void 0?r=dh(t.height):e==="square"||e==="rect"?r=i:r=dh("1mm")),{fn:t.fn,shape:e,radius:n,width:i,height:r}}),Edn=t=>{const e=Sdn.parse(t),{shape:n,radius:i,width:r,height:o}=e;let s,a;return n==="circle"?(s=pqe(1,{x:0,y:0,radius:i}),a=i+.5):n==="pill"?(s=tj(1,0,0,r,o),a=Math.max(r,o)/2+.5):(s=Dr(1,0,0,r,o),a=o/2+.5),{circuitJson:[s,zo(0,a,.2)],parameters:e}},Tdn=Ne({fn:B(),d:_t.optional(),hd:_t.optional(),r:_t.optional(),hr:_t.optional(),pd:_t.optional(),pr:_t.optional(),squarepad:bt().optional().default(!1)}).transform(t=>{let e;t.d!==void 0?e=dh(t.d):t.hd!==void 0?e=dh(t.hd):t.r!==void 0?e=dh(t.r)*2:t.hr!==void 0?e=dh(t.hr)*2:e=dh("1mm");let n;return t.pd!==void 0?n=dh(t.pd):t.pr!==void 0?n=dh(t.pr)*2:n=e*(1.5/1),{fn:t.fn,d:e,pd:n,squarepad:t.squarepad??!1}}),Mdn=t=>{const e=Tdn.parse(t),{d:n,pd:i,squarepad:r}=e;return{circuitJson:[r?nj(1,0,0,n,i,i):Aa(1,0,0,n,i),zo(0,i/2+.5,.2)],parameters:e}},Adn=Ne({fn:B(),num_pins:Ce(6).default(6),h:B().default("1.6mm"),pl:B().default("1mm"),pw:B().default("0.7mm"),p:B().default("0.95mm")}),Cdn=t=>{const e=Adn.parse(t);return{circuitJson:Rdn(e),parameters:e}},Iqe=t=>{const{p:e,h:n,pn:i}=t;if(i===1)return{x:-n/2-.5,y:e};if(i===2)return{x:-n/2-.5,y:0};if(i===3)return{x:-n/2-.5,y:-e};if(i===4)return{x:n/2+.5,y:-e};if(i===5)return{x:n/2+.5,y:0};if(i===6)return{x:n/2+.5,y:e};throw new Error("Invalid pin number")},Rdn=t=>{const e=[];for(let d=1;d<=t.num_pins;d++){const{x:h,y:f}=Iqe({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:d});e.push(Dr(d,h,f,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=t.num_pins/2*Number.parseFloat(t.p),i=Number.parseFloat(t.h),r={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-n/3,y:i/2+Number.parseFloat(t.p)/1.3},{x:n/3,y:i/2+Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-n/3,y:-i/2-Number.parseFloat(t.p)/1.3},{x:n/3,y:-i/2-Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},s=zo(0,i+.3,.3),a=Iqe({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:1});a.x=a.x-Number.parseFloat(t.pw)*1.5;const c=.7,l=.3,u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:a.x+c/2,y:a.y},{x:a.x-c/2,y:a.y+l/2},{x:a.x-c/2,y:a.y-l/2},{x:a.x+c/2,y:a.y}],stroke_width:.05};return[...e,s,r,o,u]},Pdn=Ne({fn:B()}),Idn=t=>{const e=Pdn.parse(t),n=[],i=.5-.15,r=1.5,s=.5/2,a=75,c=-37/2;for(let P=0;P<a;P++){const M=P+1;if(M>=24&&M<=31)continue;const I=c-P*s,A=M%2===0,$=r+(A?.25:0),V=.5-$/2,X=Dr(M,V,I,$,i);X.layer=A?"bottom":"top",n.push(X)}const l=46*.0254,u=137*.0254,d=261*.0254,h={type:"pcb_cutout",pcb_cutout_id:"",shape:"rect",center:{x:-u/2+r/2,y:c-d},width:u,height:l},f={x:-.5,y:c},m={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:f.x-.4,y:f.y},{x:f.x-.7,y:f.y+.3},{x:f.x-.7,y:f.y-.3},{x:f.x-.4,y:f.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"};let y=1/0,g=-1/0,b=1/0,v=-1/0;const w=(P,M,I=0,A=0)=>{y=Math.min(y,P-I/2),g=Math.max(g,P+I/2),b=Math.min(b,M-A/2),v=Math.max(v,M+A/2)};for(const P of n)w(P.x,P.y,P.width,P.height);w(h.center.x,h.center.y,h.width,h.height);for(const P of m.route)w(P.x,P.y);const T=(y+g)/2,N=(b+v)/2,R=P=>{typeof P.x=="number"&&(P.x-=T),typeof P.y=="number"&&(P.y-=N),P.center&&(P.center.x-=T,P.center.y-=N),Array.isArray(P.route)&&(P.route=P.route.map(M=>({x:M.x-T,y:M.y-N})))};for(const P of n)R(P);return R(h),R(m),{circuitJson:[...n,h,m],parameters:e}};function Ndn(t){return t!=null}var kdn=(t,e)=>{if(!e)return t;const n=t.filter(u=>u.type==="pcb_smtpad"||u.type==="pcb_plated_hole"||u.type==="pcb_thtpad");if(n.length===0)return t;let i=1/0,r=-1/0,o=1/0,s=-1/0;const a=(u,d,h=0,f=0)=>{const m=u-h/2,y=u+h/2,g=d-f/2,b=d+f/2;i=Math.min(i,m),r=Math.max(r,y),o=Math.min(o,g),s=Math.max(s,b)};for(const u of n)if(u.type==="pcb_smtpad"){const d=u.shape==="circle"?u.radius*2:u.width,h=u.shape==="circle"?u.radius*2:u.height;a(u.x,u.y,d,h)}else if(u.type==="pcb_plated_hole"){const d=u.outer_diameter??u.hole_diameter;a(u.x,u.y,d,d)}else if(u.type==="pcb_thtpad"){const d=u.diameter;a(u.x,u.y,d,d)}let c=0,l=0;switch(e){case"center":c=(i+r)/2,l=(o+s)/2;break;case"bottomleft":c=i,l=o;break;case"bottomcenter":case"centerbottom":c=(i+r)/2,l=o;break;case"topcenter":case"centertop":c=(i+r)/2,l=s;break;case"leftcenter":case"centerleft":c=i,l=(o+s)/2;break;case"rightcenter":case"centerright":c=r,l=(o+s)/2;break;case"pin1":const u=n.find(d=>d.port_hints?.[0]==="1")||n[0];c=u.x,l=u.y;break}if(c===0&&l===0)return t;for(const u of t){if(typeof u.x=="number"&&(u.x-=c),typeof u.y=="number"&&(u.y-=l),u.center&&typeof u.center.x=="number"&&(u.center.x-=c,u.center.y-=l),u.type==="pcb_silkscreen_path")for(const d of u.route)d.x-=c,d.y-=l;u.type==="pcb_silkscreen_text"&&u.anchor_position&&(u.anchor_position.x-=c,u.anchor_position.y-=l)}return t},Odn=t=>{let e=sj();const i=t.replace(/^((?:\d{4}|\d{5}))(?=$|_)/,"res$1").split(/_(?!metric)/).map(r=>{const o=r.match(/([a-z]+)([\(\d\.\+\?].*)?/);if(!o)return null;const[,s,a]=o;return!s||a?.includes("?")?null:{fn:s,v:a}}).filter(Ndn);for(const{fn:r,v:o}of i)e=e[r](o);return e.setString(t),e},Ldn=()=>Object.keys(i3),sj=()=>{const t=new Proxy({},{get:(e,n)=>{if(n==="soup"||n==="circuitJson"){if("fn"in e&&i3[e.fn])return()=>{const{circuitJson:i}=i3[e.fn](e);return kdn(i,e.origin)};if(!i3[e.fn])throw new Error(`Invalid footprint function, got "${e.fn}"${e.string?`, from string "${e.string}"`:""}`);return()=>{throw new Error(`No function found for footprinter, make sure to specify .dip, .lr, .p, etc. Got "${n}"`)}}if(n==="json"){if(!i3[e.fn])throw new Error(`Invalid footprint function, got "${e.fn}"${e.string?`, from string "${e.string}"`:""}`);return()=>i3[e.fn](e).parameters}return n==="getFootprintNames"?()=>Object.keys(i3):n==="params"?()=>e:n==="setString"?i=>(e.string=i,t):i=>(Object.keys(e).length===0?`${n}${i}`in i3?(e[`${n}${i}`]=!0,e.fn=`${n}${i}`):(e[n]=!0,e.fn=n,n==="res"||n==="cap"?i&&(typeof i=="string"&&i.includes("_metric")?e.metric=i.split("_metric")[0]:e.imperial=i):e.num_pins=Number.isNaN(Number.parseFloat(i))?void 0:Number.parseFloat(i)):!i&&["w","h","p"].includes(n)||(e[n]=i??!0),t)}});return t};sj.string=Odn,sj.getFootprintNames=Ldn;var Ddn=sj,dv=jp(d0e()),Nqe=Symbol("Fragment");function E0e(t,e,...n){const i=n.length?n:e?.children!==void 0?[e.children]:[],r=[],o=(Array.isArray(i)?i:[i]).flat(1/0);for(const s of o)s==null||s===!1||(Array.isArray(s)?r.push(...s):r.push(s));return{type:t,props:(e&&e.children!==void 0?{...e,children:void 0}:e)||{},children:r}}var Oc=Symbol("Cuboid"),kqe=Symbol("Cube"),q4=Symbol("Cylinder"),Oqe=Symbol("Sphere"),aj=Symbol("RoundedCuboid"),X4=Symbol("Translate"),NI=Symbol("Rotate"),Lqe=Symbol("Union"),T0e=Symbol("Subtract"),cj=Symbol("Hull"),s3=Symbol("Colorize"),kI=Symbol("Polygon"),OI=Symbol("ExtrudeLinear"),Wy=Nqe,ui=(t,e,n)=>E0e(t,e),z0=(t,e,n)=>E0e(t,e),BA=({center:t,width:e,length:n,height:i,heightAboveSurface:r=.15})=>ui(s3,{color:"#555",children:ui(X4,{offset:t,children:ui(X4,{offset:{x:0,y:0,z:i/2+r},children:ui(aj,{roundRadius:.2,size:[e,n,i]})})})}),zdn=t=>Array.from({length:t},(e,n)=>n);function M0e(t,e){if(t.length<2)throw new Error("Stroke must have at least two points");const n=Array.isArray(t[0])?t.map(([u,d])=>({x:u,y:d})):t,i=e/2,r=[],o=[];function s(u,d){const h=d.x-u.x,f=d.y-u.y,m=Math.sqrt(h*h+f*f);return{x:-f/m,y:h/m}}function a(u,d,h){const f={x:u.x+d.x*i*h,y:u.y+d.y*i*h};h>0?r.push(f):o.unshift(f)}const c=s(n[0],n[1]);a(n[0],c,1),a(n[0],c,-1);for(let u=1;u<n.length-1;u++){const d=n[u-1],h=n[u],f=n[u+1],m=s(d,h),y=s(h,f),g=m.x+y.x,b=m.y+y.y,v=Math.sqrt(g*g+b*b);if(v/2>2*i)a(h,m,1),a(h,y,1),a(h,m,-1),a(h,y,-1);else{const T=1/v;a(h,{x:g*T,y:b*T},1),a(h,{x:g*T,y:b*T},-1)}}const l=s(n[n.length-2],n[n.length-1]);return a(n[n.length-1],l,1),a(n[n.length-1],l,-1),[...r,...o]}var Fdn=t=>{const e=Math.min(...t.map(a=>a.x)),n=Math.max(...t.map(a=>a.x)),i=Math.min(...t.map(a=>a.y)),s=5.47/(Math.max(...t.map(a=>a.y))-i);return t.map(a=>({x:(a.x-e-(n-e)/2)*s,y:(a.y-i)*s}))},Bdn=Fdn([{x:20,y:105},{x:20,y:109},{x:20,y:102},{x:26,y:102},{x:26,y:109},{x:24,y:111},{x:24,y:118},{x:22,y:118},{x:22,y:111},{x:20,y:109}]),Dqe=5.47,lj=.5,Udn=({x:t,y:e,z:n})=>{const i=t>0;return z0(Wy,{children:[ui(X4,{offset:{x:t+.25/2,y:e,z:n},children:ui(NI,{rotation:["-90deg",0,"90deg"],children:ui(OI,{height:.25,children:ui(kI,{points:Bdn.map(r=>[r.x,r.y])})})})}),ui(X4,{offset:{x:t,y:e+(i?1:-1),z:n},children:ui(NI,{rotation:["-90deg","90deg",i?"180deg":"0deg"],children:ui(OI,{height:2,children:ui(kI,{points:M0e([[0,0],[-1,0],[-1,-1]],.25).map(r=>[r.x,r.y])})})})})]})},$dn=({numPins:t=8,pitch:e=2.54,bodyWidth:n=6.4})=>{const i=Math.floor(t/2),r=n+1;return z0(Wy,{children:[zdn(t).map(o=>{const s=o%i,a=(Math.floor(o/i)-.5)*2;return ui(Udn,{x:a*r/2,y:s*e-(i-1)/2*e,z:Dqe/2+lj})}),ui(BA,{width:n,length:i*e+.5,height:Dqe-lj,heightAboveSurface:lj,center:{x:0,y:0,z:lj}})]})};function jdn(t,{height:e,padContactLength:n,curveLength:i,bodyDistance:r,steepness:o=10}){i||(i=r*.3);let s=r-n-i;s<0&&(i+=s,s=0);const a=n*.75,c=n+i+(r-n-i)*.25;if(t<=a)return 0;if(t>=c)return e;const l=(t-a)/(c-a);return e/(1+Math.exp(-o*(l-.5)))}var hv=t=>{const{thickness:e,width:n,padContactLength:i,bodyDistance:r,height:o,rotation:s}=t,a=15,c=Array.from({length:a}).map((u,d)=>d/(a-1)*r).map(u=>[u,jdn(u,t)]),l=M0e(c,e);return ui(s3,{color:"#fff",children:ui(X4,{offset:{z:0,y:0,x:0,...t.position},children:ui(NI,{rotation:["90deg",0,s??0],children:ui(X4,{offset:{x:0,y:0,z:-n/2},children:ui(OI,{height:n,children:ui(kI,{points:l.map(u=>[u.x,u.y])})})})})})})},Hdn=({pinCount:t,leadLength:e,leadWidth:n,pitch:i,bodyWidth:r})=>{const o=Math.ceil(t/2),s=i*t/2+n/2,a=(o-1)*i/2,c=.25;return z0(Wy,{children:[Array.from({length:o}).map((l,u)=>ui(hv,{position:{x:-r/2-e,y:u*i-a,z:c/2},width:n,thickness:c,padContactLength:e,bodyDistance:e+1,height:.8})),Array.from({length:o}).map((l,u)=>ui(hv,{rotation:Math.PI,position:{x:r/2+e,y:u*i-a,z:c/2},width:n,thickness:c,padContactLength:e,bodyDistance:e+1,height:.8})),ui(BA,{center:{x:0,y:0,z:c/2},width:r-n-1,length:s,height:1.5})]})},A0e=1,C0e=.5,UA=.5,LI=.2,Vdn=A0e-LI*2,zqe=({color:t="#333"})=>z0(Wy,{children:[ui(Oc,{size:[Vdn,C0e,UA],offset:[0,0,UA/2],color:t}),ui(Oc,{size:[LI,UA,C0e],offset:[A0e/2-LI/2,0,UA/2],color:"#ccc"}),ui(Oc,{size:[LI,UA,C0e],offset:[-A0e/2+LI/2,0,UA/2],color:"#ccc"})]}),R0e=1.6,Gdn=R0e-.3*2,uj=.3,P0e=.85,$A=.6,Fqe=({color:t="#333"})=>z0(Wy,{children:[ui(Oc,{size:[Gdn,P0e,$A],offset:[0,0,$A/2],color:t}),ui(Oc,{size:[uj,P0e,$A],offset:[R0e/2-uj/2,0,$A/2],color:"#ccc"}),ui(Oc,{size:[uj,P0e,$A],offset:[-R0e/2+uj/2,0,$A/2],color:"#ccc"})]}),I0e=2,N0e=1.25,jA=.55,DI=.5,Ydn=I0e-DI*2,Bqe=({color:t="#333"})=>z0(Wy,{children:[ui(Oc,{size:[Ydn,N0e,jA],offset:[0,0,jA/2],color:t}),ui(Oc,{size:[DI,N0e,jA],offset:[I0e/2-DI/2,0,jA/2],color:"#ccc"}),ui(Oc,{size:[DI,N0e,jA],offset:[-I0e/2+DI/2,0,jA/2],color:"#ccc"})]}),qdn=({pinCount:t,pitch:e,leadWidth:n,padContactLength:i,bodyWidth:r})=>{const o=t/4;e||(e=Xdn(t,r)),i||(i=Wdn(t)),n||(n=Zdn(t,r)),r||(r=e*(o+4));const s=r,a=(o-1)*e/2,c=s+2*i,l=c,u=.8,d=.15,h=(l-r)/2;return z0(Wy,{children:[Array.from({length:o}).map((f,m)=>ui(hv,{position:{x:-l/2,y:m*e-a,z:d/2},width:n,thickness:d,padContactLength:i,bodyDistance:h,height:u})),Array.from({length:o}).map((f,m)=>ui(hv,{rotation:Math.PI,position:{x:l/2,y:m*e-a,z:d/2},width:n,thickness:d,padContactLength:i,bodyDistance:h,height:u})),Array.from({length:o}).map((f,m)=>ui(hv,{rotation:Math.PI/2,position:{x:m*e-a,y:-c/2,z:d/2},width:n,thickness:d,padContactLength:i,bodyDistance:h,height:u})),Array.from({length:o}).map((f,m)=>ui(hv,{rotation:-Math.PI/2,position:{x:m*e-a,y:c/2,z:d/2},width:n,thickness:d,padContactLength:i,bodyDistance:h,height:u})),ui(BA,{center:{x:0,y:0,z:d/2},width:r,length:s,height:1.5})]})},Xdn=(t,e)=>{switch(t){case 44:case 64:return .8;case 52:return e===14?1:.65;case 208:return .5;default:return .5}},Wdn=t=>{switch(t){case 44:case 52:case 64:return 2.25;case 208:return 1.65;default:return 1}},Zdn=(t,e)=>{switch(t){case 44:case 64:return .5;case 52:return e===14?.45:.55;case 208:return .3;default:return .25}},Kdn=({numberOfPins:t,pitch:e=2.54,longSidePinLength:n=6})=>{const o=t*e,s=3,a=-((t-1)/2)*e;return z0(Wy,{children:[ui(Oc,{color:"#222",size:[o,.63*3,2],center:[0,0,2/2]}),Array.from({length:t},(c,l)=>z0(Wy,{children:[ui(s3,{color:"gold",children:z0(cj,{children:[ui(Oc,{color:"gold",size:[.63,.63,s*.9],center:[a+l*e,0,2*.9+2/2]}),ui(Oc,{color:"gold",size:[.63/1.8,.63/1.8,s],center:[a+l*e,0,2+2/2]})]})}),ui(s3,{color:"gold",children:z0(cj,{children:[ui(Oc,{color:"gold",size:[.63,.63,n*.9],center:[a+l*e,0,-n/2*.9]}),ui(Oc,{color:"gold",size:[.63/1.8,.63/1.8,n],center:[a+l*e,0,-n/2]})]})})]}))]})},Qdn=t=>{const e=["left","bottom","right","top"],{pin_count:n,pn:i,w:r,h:o,p:s,pl:a}=t,c=n/4,l=e[Math.floor((i-1)/c)],u=(i-1)%c,d=s*(c-1),h=s*(c-1),f=-a/2;switch(l){case"left":return{x:-r/2-f,y:h/2-u*s,o:"vert"};case"bottom":return{x:-d/2+u*s,y:-o/2-f,o:"horz"};case"right":return{x:r/2+f,y:-h/2+u*s,o:"vert"};case"top":return{x:d/2-u*s,y:o/2+f,o:"horz"};default:throw new Error("Invalid pin number")}},Jdn=({num_pins:t,cw:e,ccw:n,startingpin:i})=>{const r=[],o=t/4;let s=1;const a={};for(const c of i??[])a[c]=!0;!a.leftside&&!a.topside&&!a.rightside&&!a.bottomside&&(a.leftside=!0),!a.bottompin&&!a.leftpin&&!a.rightpin&&!a.toppin&&(a.leftside?a.toppin=!0:a.topside?a.rightpin=!0:a.rightside?a.bottompin=!0:a.bottomside&&(a.leftpin=!0)),a.leftside&&a.toppin?s=1:a.leftside&&a.bottompin?s=o:a.bottomside&&a.leftpin?s=o+1:a.bottomside&&a.rightpin?s=o*2:a.rightside&&a.bottompin?s=o*2+1:a.rightside&&a.toppin?s=o*3:a.topside&&a.rightpin?s=o*3+1:a.topside&&a.leftpin&&(s=o*4),r.push(-1);for(let c=0;c<t;c++)r[s]=c+1,s++,s>t&&(s=1);return r},ehn=({num_pins:t=16,bodyWidth:e=9,bodyLength:n=9,bodyThickness:i=.8,thermalPadSize:r,padWidth:o=.25,padLength:s=.25,pitch:a=.5,thermalPadThickness:c=.05})=>{const l=Jdn({num_pins:t,cw:!0,ccw:!0}),u=[];for(let d=0;d<t;d++){const{x:h,y:f,o:m}=Qdn({pin_count:t,pn:d+1,w:e,h:n,p:a,pl:s});let y=o,g=s;m==="vert"&&([y,g]=[g,y]);const b=l[d+1];u.push({pn:b,x:h,y:f,pw:y,pl:g})}return z0(Wy,{children:[ui(s3,{color:"grey",children:ui(Oc,{center:{x:0,y:0,z:i/2},size:[e,n,i]})}),u.map((d,h)=>ui(Oc,{center:{x:d.x,y:d.y,z:c/2},size:[d.pw,d.pl,c]})),r?.length!==void 0&&r?.width!==void 0&&ui(Oc,{center:{x:0,y:0,z:c/2},size:[r.width,r.length,c]})]})},thn=ehn,nhn=()=>{const c=1.1999999999999997;return z0(Wy,{children:[ui(hv,{rotation:Math.PI,position:{x:2.8/2+c/4,y:-1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),ui(hv,{rotation:Math.PI,position:{x:2.8/2+c/4,y:1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),ui(hv,{position:{x:-2.8/2-c/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),ui(hv,{position:{x:-2.8/2-c/4,y:-1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),ui(hv,{position:{x:-2.8/2-c/4,y:1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),ui(BA,{center:{x:0,y:0,z:0},width:1.6,length:2.9,height:1.2})]})},ihn=nhn,k0e=.6,O0e=.3,HA=.33,zI=.1,rhn=k0e-zI*2,Uqe=({color:t="#333"})=>z0(Wy,{children:[ui(Oc,{size:[rhn,O0e,HA],offset:[0,0,HA/2],color:t}),ui(Oc,{size:[zI,O0e,HA],offset:[k0e/2-zI/2,0,HA/2],color:"#ccc"}),ui(Oc,{size:[zI,O0e,HA],offset:[-k0e/2+zI/2,0,HA/2],color:"#ccc"})]}),L0e=.4,D0e=.2,VA=.13,FI=.07,ohn=L0e-FI*2,$qe=({color:t="#333"})=>z0(Wy,{children:[ui(Oc,{size:[ohn,D0e,VA],offset:[0,0,VA/2],color:t}),ui(Oc,{size:[FI,D0e,VA],offset:[L0e/2-FI/2,0,VA/2],color:"#ccc"}),ui(Oc,{size:[FI,D0e,VA],offset:[-L0e/2+FI/2,0,VA/2],color:"#ccc"})]}),z0e=3.2,F0e=1.6,GA=.9,BI=.5,shn=z0e-BI*2,jqe=({color:t="#333"})=>z0(Wy,{children:[ui(Oc,{size:[shn,F0e,GA],offset:[0,0,GA/2],color:t}),ui(Oc,{size:[BI,F0e,GA],offset:[z0e/2-BI/2,0,GA/2],color:"#ccc"}),ui(Oc,{size:[BI,F0e,GA],offset:[-z0e/2+BI/2,0,GA/2],color:"#ccc"})]}),B0e=3.2,U0e=2.5,YA=1,UI=.6,ahn=B0e-UI*2,Hqe=({color:t="#333"})=>z0(Wy,{children:[ui(Oc,{size:[ahn,U0e,YA],offset:[0,0,YA/2],color:t}),ui(Oc,{size:[UI,U0e,YA],offset:[B0e/2-UI/2,0,YA/2],color:"#ccc"}),ui(Oc,{size:[UI,U0e,YA],offset:[-B0e/2+UI/2,0,YA/2],color:"#ccc"})]}),$0e=5,j0e=2.5,qA=1.4,$I=.6,chn=$0e-$I*2,Vqe=({color:t="#333"})=>z0(Wy,{children:[ui(Oc,{size:[chn,j0e,qA],offset:[0,0,qA/2],color:t}),ui(Oc,{size:[$I,j0e,qA],offset:[$0e/2-$I/2,0,qA/2],color:"#ccc"}),ui(Oc,{size:[$I,j0e,qA],offset:[-$0e/2+$I/2,0,qA/2],color:"#ccc"})]}),H0e=6.3,V0e=3.2,XA=1.8,jI=.8,lhn=H0e-jI*2,Gqe=({color:t="#333"})=>z0(Wy,{children:[ui(Oc,{size:[lhn,V0e,XA],offset:[0,0,XA/2],color:t}),ui(Oc,{size:[jI,V0e,XA],offset:[H0e/2-jI/2,0,XA/2],color:"#ccc"}),ui(Oc,{size:[jI,V0e,XA],offset:[-H0e/2+jI/2,0,XA/2],color:"#ccc"})]}),uhn=({numberOfPins:t,pitch:e=2.54,legsLength:n=3,outerDiameter:i=.945,innerDiameter:r=.945})=>{const o=r/1.5,s=o*2+i,a=5,c=(t-1)*e+i+e/2,l=o*1.6,u=-((t-1)/2)*e,d=ui(s3,{color:"#1a1a1a",children:z0(T0e,{children:[ui(Oc,{color:"#000",size:[c,s,a],center:[0,0,a/2]}),Array.from({length:t},(h,f)=>r?ui(q4,{height:a+.1,radius:r/2,center:[u+f*e,0,a/2],color:"#222"},f):ui(Oc,{size:[l,l,a],center:[u+f*e,0,a/2]},f))]})});return z0(Wy,{children:[d,Array.from({length:t},(h,f)=>z0(s3,{color:"silver",children:[z0(cj,{children:[ui(Oc,{color:"silver",size:[o,o,n*.9],center:[u+f*e,0,-n/2*.9]}),ui(Oc,{color:"silver",size:[o/1.8,o/1.8,n],center:[u+f*e,0,-n/2]})]}),ui(Oc,{color:"silver",size:[l,l,l*.5],center:[u+f*e,0,l/2*.5]})]},f))]})},dhn=({width:t,length:e,innerDiameter:n=1})=>{const i=t,r=e,o=t*.7,s=n/2.5;return z0(Wy,{children:[ui(aj,{color:"#1a1a1f",center:[0,0,o/2],size:[r,r,o],roundRadius:.3}),ui(aj,{color:"#f2f2f2",center:[0,0,o+o*.1/2.5],size:[r,r,o*.1],roundRadius:.14}),ui(q4,{color:"#1a1a1f",height:o*.8,radius:i/3,center:[0,0,o+o*.8/2]}),ui(q4,{color:"#1a1a1f",height:o*.2,radius:n/2,center:[r/3,r/3,o+o*.1/2]}),ui(q4,{color:"#1a1a1f",height:o*.2,radius:n/2,center:[-r/3,-r/3,o+o*.1/2]}),ui(q4,{color:"#1a1a1f",height:o*.2,radius:n/2,center:[-r/3,r/3,o+o*.1/2]}),ui(q4,{color:"#1a1a1f",height:o*.2,radius:n/2,center:[r/3,-r/3,o+o*.1/2]}),ui(dj,{thickness:n/3,width:s,horizontalLength:r*.8,verticalLength:o/2,position:{x:-i/2,y:-r/2,z:-o*1.2}}),ui(dj,{thickness:n/3,width:s,horizontalLength:r*.8,verticalLength:o/2,position:{x:-i/2,y:r/2,z:-o*1.2},rotation:Math.PI}),ui(dj,{thickness:n/3,width:s,horizontalLength:r*.8,verticalLength:o/2,position:{x:i/2,y:r/2,z:-o*1.2},rotation:Math.PI}),ui(dj,{thickness:n/3,width:s,horizontalLength:r*.8,verticalLength:o/2,position:{x:i/2+n/3.6,y:-r/2,z:-o*1.2}})]})},dj=t=>{const{thickness:e,width:n,horizontalLength:i,verticalLength:r,rotation:o=0,position:s}=t,a=[[0,i],[-r/3,i/3],[-r/5,i/4],[0,0]],c=M0e(a,e);return ui(s3,{color:"#f2f2f2",children:ui(X4,{offset:{x:s?.x||0,y:s?.y||0,z:s?.z||0},children:ui(NI,{rotation:[0,55,o],children:ui(OI,{height:n,children:ui(kI,{points:c.map(l=>[l.y,l.x])})})})})})},hhn=({pinCount:t,leadLength:e,leadWidth:n,pitch:i,bodyWidth:r})=>{const o=Math.ceil(t/2),s=(o-1)*i/2,a=.25,c=1,l=.8,u=e*0,d=i*(o-1)+n+.2,h=r*.55;return z0(Wy,{children:[Array.from({length:o}).map((f,m)=>ui(hv,{position:{x:-r/2-u,y:m*i-s,z:a/2},width:n,thickness:a,padContactLength:e/2,bodyDistance:e+.2,height:l})),Array.from({length:o}).map((f,m)=>ui(hv,{rotation:Math.PI,position:{x:r/2+u,y:m*i-s,z:a/2},width:n,thickness:a,padContactLength:e/2,bodyDistance:e+.2,height:l})),ui(BA,{center:{x:0,y:0,z:a/2},width:h,length:d,height:c})]})},phn=({pinCount:t,pitch:e,leadWidth:n,leadLength:i,bodyWidth:r,bodyLength:o})=>{const s=t===8?{pitch:.65,leadWidth:.3}:{pitch:.5,leadWidth:.225},a=isNaN(parseFloat(e))?s.pitch:parseFloat(e),c=isNaN(parseFloat(n))?s.leadWidth:parseFloat(n)*.8,l=isNaN(parseFloat(r))?2.6:parseFloat(r)*.8,u=isNaN(parseFloat(o))?2+Number(a)*1.4:parseFloat(o),d=t/2,h=(d-1)*a/2,f=.15,m=.8,y=4.5,g=(y-l)/2,b=g*.5;return z0(Wy,{children:[Array.from({length:d}).map((v,w)=>ui(hv,{position:{x:-y/2,y:h-w*a,z:f/2},width:c,thickness:f,padContactLength:b+.05,bodyDistance:g+.05,height:m})),Array.from({length:d}).map((v,w)=>ui(hv,{rotation:Math.PI,position:{x:y/2,y:h-w*a,z:f/2},width:c,thickness:f,padContactLength:b+.05,bodyDistance:g+.05,height:m})),ui(BA,{center:{x:0,y:0,z:f/2},width:l,length:u,height:1})]})},fhn=({footprint:t})=>{const e=Ddn.string(t).json();switch(e.fn){case"dip":return ui($dn,{numPins:e.num_pins,pitch:e.p,bodyWidth:e.w});case"tssop":return ui(Hdn,{pinCount:e.num_pins,leadLength:e.pl,leadWidth:e.pw,pitch:e.p,bodyWidth:e.w});case"vssop":return ui(phn,{pinCount:e.num_pins,leadLength:e.pl,leadWidth:e.pw,pitch:e.p,bodyWidth:e.w,bodyLength:e.h});case"qfp":return ui(qdn,{pinCount:e.num_pins,pitch:e.p,leadWidth:e.pw,padContactLength:e.pl,bodyWidth:e.w});case"qfn":return ui(thn,{num_pins:e.num_pins,bodyWidth:e.w,bodyLength:e.h,pitch:e.p,padLength:e.pl,padWidth:e.pw,thermalPadSize:{width:e.thermalpad.x,length:e.thermalpad.y}});case"pinrow":if(e.male)return ui(Kdn,{numberOfPins:e.num_pins,pitch:e.p});if(e.female)return ui(uhn,{numberOfPins:e.num_pins,pitch:e.p});case"cap":switch(e.imperial){case"0402":return ui(zqe,{color:"#856c4d"});case"0603":return ui(Fqe,{color:"#856c4d"});case"0805":return ui(Bqe,{color:"#856c4d"});case"0201":return ui(Uqe,{color:"#856c4d"});case"01005":return ui($qe,{color:"#856c4d"});case"1206":return ui(jqe,{color:"#856c4d"});case"1210":return ui(Hqe,{color:"#856c4d"});case"2010":return ui(Vqe,{color:"#856c4d"});case"2512":return ui(Gqe,{color:"#856c4d"})}case"sot235":return ui(ihn,{});case"pushbutton":return ui(dhn,{width:e.w,length:e.h,innerDiameter:e.id});case"soic":return ui(hhn,{pinCount:e.num_pins,leadLength:e.pl,leadWidth:e.pw,pitch:e.p,bodyWidth:e.w})}switch(e.imperial){case"0402":return ui(zqe,{});case"0603":return ui(Fqe,{});case"0805":return ui(Bqe,{});case"0201":return ui(Uqe,{});case"01005":return ui($qe,{});case"1206":return ui(jqe,{});case"1210":return ui(Hqe,{});case"2010":return ui(Vqe,{});case"2512":return ui(Gqe,{})}return null},mhn=t=>t&&typeof t=="object"&&"type"in t,WA=t=>{if(typeof t=="number")return t;if(typeof t=="string"){const e=/^(-?\d+(?:\.\d+)?)\s*deg$/i.exec(t);if(e)return parseFloat(e[1])*Math.PI/180;const n=Number(t);if(!Number.isNaN(n))return n}return 0},_hn=t=>Array.isArray(t)?[Number(t[0])||0,Number(t[1])||0,Number(t[2])||0]:typeof t=="object"&&t?[Number(t.x)||0,Number(t.y)||0,Number(t.z)||0]:[0,0,0];function Pw(t,e){if(t==null||t===!1)return[];if(Array.isArray(t))return t.flatMap(o=>Pw(o,e));if(!mhn(t))return[];const{type:n,props:i,children:r}=t;if(n===Nqe)return(r??[]).flatMap(o=>Pw(o,e));if(n===s3){const o=i?.color;return(r??[]).flatMap(s=>Pw(s,o??e))}if(n===X4){const o=_hn(i?.offset??{x:i?.x,y:i?.y,z:i?.z});return(r??[]).flatMap(a=>Pw(a,e)).map(({geom:a,color:c})=>({geom:dv.transforms.translate(o,a),color:c??e}))}if(n===NI){const o=Array.isArray(i?.rotation)?[WA(i.rotation[0]),WA(i.rotation[1]),WA(i.rotation[2])]:[WA(i?.x??0),WA(i?.y??0),WA(i?.z??0)];return(r??[]).flatMap(a=>Pw(a,e)).map(({geom:a,color:c})=>({geom:dv.transforms.rotateZ(o[2],dv.transforms.rotateY(o[1],dv.transforms.rotateX(o[0],a))),color:c}))}if(n===Lqe||n===T0e||n===cj){const o=(r??[]).flatMap(a=>Pw(a,e)).map(a=>a.geom);if(o.length===0)return[];let s;return n===Lqe?s=dv.booleans.union(o):n===T0e?s=dv.booleans.subtract(o[0],o.slice(1)):s=dv.hulls.hull(o),[{geom:s}]}if(n===kI){const o=i?.points??[];return[{geom:dv.geometries.geom2.fromPoints(o),color:e??i?.color}]}if(n===OI){const o=(r??[]).flatMap(l=>Pw(l,e)).map(l=>l.geom);if(o.length===0)return[];const s=o.length>1?dv.booleans.union(o):o[0],a=i?.height??i?.h??1;return[{geom:dv.extrusions.extrudeLinear({height:a},s),color:e??i?.color}]}if(n===Oc||n===kqe||n===q4||n===Oqe||n===aj){let o;if(n===Oc){const s=i?.size??[1,1,1],a=i?.offset,c=i?.center??(a?[a[0],a[1],a[2]]:[0,0,0]);o=dv.primitives.cuboid({size:s,center:c})}else if(n===kqe){const s=i?.size??1,a=i?.offset,c=i?.center??(a?[a[0],a[1],a[2]]:[0,0,0]);o=dv.primitives.cube({size:s,center:c})}else if(n===q4){const s=i?.height??1,a=i?.radius??1,c=i?.center??[0,0,0];o=dv.primitives.cylinder({height:s,radius:a,center:c})}else if(n===Oqe){const s=i?.radius??1,a=i?.center??[0,0,0];o=dv.primitives.sphere({radius:s,center:a})}else{const s=i?.size??[1,1,1],a=i?.roundRadius??.1,c=i?.center??[0,0,0];o=dv.primitives.roundedCuboid({size:s,roundRadius:a,center:c})}return[{geom:o,color:e??i?.color}]}if(typeof n=="function"){const o=n(i??{});return Pw(o,e)}return(r??[]).flatMap(o=>Pw(o,e))}function yhn(t){return{geometries:Pw(t)}}function Yqe(t){if(t.polygons){const e=[],n=[],i=[];let r=0;for(const s of t.polygons){for(const c of s.vertices)c.index=r,e.push(c[0],c[1],c[2]),t.color&&t.color.length>=3?i.push(t.color[0],t.color[1],t.color[2]):i.push(1,1,1),r++;const a=s.vertices[0].index;for(let c=2;c<s.vertices.length;c++){const l=s.vertices[c-1].index,u=s.vertices[c].index;n.push(a,l,u)}}const o=new Sf;if(o.setAttribute("position",new f0(new Float32Array(e),3)),o.setIndex(n),i.length>0&&o.setAttribute("color",new f0(new Float32Array(i),3)),t.transforms){const s=new Xa;s.fromArray(t.transforms),o.applyMatrix4(s)}return o.computeVertexNormals(),o}if(t.sides){const e=[],n=[];for(const r of t.sides)e.push(r[0][0],r[0][1],0),t.color&&t.color.length>=3?n.push(t.color[0],t.color[1],t.color[2]):n.push(1,1,1);const i=new Sf;if(i.setAttribute("position",new f0(new Float32Array(e),3)),n.length>0&&i.setAttribute("color",new f0(new Float32Array(n),3)),t.transforms){const r=new Xa;r.fromArray(t.transforms),i.applyMatrix4(r)}return i}return console.error("Invalid CSG object: neither polygons nor sides found"),new Sf}function ghn(t){const e=E0e(fhn,{footprint:t});return yhn(e)}var bhn=({jscadPlan:t,positionOffset:e,rotationOffset:n,onHover:i,onUnhover:r,isHovered:o,scale:s})=>{const{rootObject:a}=Nx(),{threeGeom:c,material:l}=Ee.useMemo(()=>{const d=(0,don.executeJscadOperations)(hon.default,t);if(!d||!d.polygons&&!d.sides)return{threeGeom:null,material:null};const h=Yqe(d),f=new N9({vertexColors:!0,side:x1});return{threeGeom:h,material:f}},[t]),u=Ee.useMemo(()=>c?new pd(c,l):null,[c,l]);return Ee.useEffect(()=>{if(!(!u||!a))return a.add(u),()=>{a.remove(u)}},[a,u]),Ee.useEffect(()=>{u&&(e&&u.position.fromArray(e),n&&u.rotation.fromArray(n),s!==void 0&&u.scale.setScalar(s))},[u,e?.[0],e?.[1],e?.[2],n?.[0],n?.[1],n?.[2],s]),Ee.useMemo(()=>{if(l)if(o){const d=new eo(l.color.getHex());l.emissive.copy(d),l.emissive.setRGB(0,0,1),l.emissiveIntensity=.2}else l.emissiveIntensity=0},[o,l]),c?ye.jsx(CI,{isHovered:o,onHover:i,onUnhover:r,object:u}):null},xhn=({positionOffset:t,footprint:e,rotationOffset:n,onHover:i,onUnhover:r,isHovered:o,scale:s})=>{const{rootObject:a}=Nx(),c=Ee.useMemo(()=>{if(!e)return null;const{geometries:l}=ghn(e),u=new I9;for(const d of l.flat(1/0)){const h=d.geom;if(!h||!h.polygons&&!h.sides)continue;const f=new eo(d.color);f.convertLinearToSRGB();const m={...h,color:[f.r,f.g,f.b]},y=Yqe(m),g=new N9({vertexColors:!0,side:x1}),b=new pd(y,g);u.add(b)}return u},[e]);return Ee.useEffect(()=>{if(!(!c||!a))return a.add(c),()=>{a.remove(c)}},[a,c]),Ee.useEffect(()=>{c&&(t&&c.position.fromArray(t),n&&c.rotation.fromArray(n),s!==void 0&&c.scale.setScalar(s))},[c,t?.[0],t?.[1],t?.[2],n?.[0],n?.[1],n?.[2],s]),Ee.useEffect(()=>{c&&c.traverse(l=>{l instanceof pd&&l.material instanceof N9&&(o?(l.material.emissive.setHex(255),l.material.emissiveIntensity=.2):l.material.emissiveIntensity=0)})},[o,c]),c?ye.jsx(CI,{isHovered:o,onHover:i,onUnhover:r,object:c}):null},vhn=(...t)=>t,qqe=({children:t,position:e,style:n})=>{const{camera:i,renderer:r}=Nx(),o=Ee.useRef(document.createElement("div")),[s,a]=Ee.useState(null);return Ee.useEffect(()=>{const c=r?.domElement.parentNode;if(c)return c.style.position!=="relative"&&c.style.position!=="absolute"&&(c.style.position="relative"),c.appendChild(o.current),a(HW.createPortal(t,o.current)),()=>{c.contains(o.current)&&c.removeChild(o.current)}},[r,t]),AI(()=>{if(!i||!o.current||!r)return;const c=new tn(...e);c.project(i);const l=r.domElement.getBoundingClientRect(),u=Math.round((c.x+1)/2*l.width),d=Math.round((-c.y+1)/2*l.height);o.current.style.position="absolute",o.current.style.left=`${u}px`,o.current.style.top=`${d}px`,o.current.style.pointerEvents="none",o.current.style.zIndex="1000",n&&Object.assign(o.current.style,n)},[i,r,e,n]),s},Xqe=({cad_component:t,circuitJson:e})=>{const[n,i]=Ee.useState(!1),[r,o]=Ee.useState(null),s=Ee.useCallback(f=>{f?.mousePosition?(i(!0),o(f.mousePosition)):(i(!1),o(null))},[]),a=Ee.useCallback(()=>{i(!1),o(null)},[]),c=Ee.useMemo(()=>ea(e).source_component.getUsing({source_component_id:t.source_component_id})?.name,[e,t.source_component_id]),l=t.model_obj_url??t.model_wrl_url??t.model_stl_url,u=t.model_glb_url??t.model_gltf_url,d=t.rotation?vhn(t.rotation.x*Math.PI/180,t.rotation.y*Math.PI/180,t.rotation.z*Math.PI/180):void 0;let h=null;return l?h=ye.jsx(lon,{url:l,position:t.position?[t.position.x,t.position.y,t.position.z]:void 0,rotation:d,scale:t.model_unit_to_mm_scale_factor,onHover:s,onUnhover:a,isHovered:n},t.cad_component_id):u?h=ye.jsx(uon,{gltfUrl:u,position:t.position?[t.position.x,t.position.y,t.position.z]:void 0,rotation:d,scale:t.model_unit_to_mm_scale_factor,onHover:s,onUnhover:a,isHovered:n},t.cad_component_id):t.model_jscad?h=ye.jsx(bhn,{jscadPlan:t.model_jscad,rotationOffset:d,scale:t.model_unit_to_mm_scale_factor,onHover:s,onUnhover:a,isHovered:n},t.cad_component_id):t.footprinter_string&&(h=ye.jsx(xhn,{positionOffset:t.position?[t.position.x,t.position.y,t.position.z]:void 0,rotationOffset:d,footprint:t.footprinter_string,scale:t.model_unit_to_mm_scale_factor,onHover:s,onUnhover:a,isHovered:n})),ye.jsxs(ye.Fragment,{children:[h,n&&r?ye.jsx(qqe,{position:r,style:{fontFamily:"sans-serif",transform:"translate3d(1rem, 1rem, 0)",backgroundColor:"white",padding:"5px",borderRadius:"3px",pointerEvents:"none",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},children:c??"<unknown>"}):null]})},Wqe={version:"0.0.401"},aM=({children:t,parent:e,position:n,rotation:i,scale:r,color:o,fontSize:s,anchorX:a,anchorY:c,depthOffset:l})=>{const{rootObject:u}=Nx(),d=Ee.useMemo(()=>{const h=new hAe;return h.text=t,n&&h.position.fromArray(n),i&&h.rotation.fromArray(i),r&&h.scale.fromArray(r),h.color=o||"white",h.fontSize=s||1,h.anchorX=a||"center",h.anchorY=c||"middle",h.depthOffset=l||0,h.font=null,h.sync(),h},[t,n,i,r,o,s,a,c,l]);return Ee.useEffect(()=>{const h=e||u;if(!(!h||!d))return h.add(d),()=>{h.remove(d),d.dispose()}},[u,e,d]),null};typeof window<"u"&&(window.TSCI_MAIN_CAMERA_ROTATION=new A9(0,0,0));function whn(t,e){const n=new y2().setFromEuler(new A9(t.x,t.y,t.z)),i=new tn(0,0,1);return i.applyQuaternion(n),i.multiplyScalar(e)}var Shn=({})=>{const{camera:t,scene:e}=Nx();Ee.useEffect(()=>{if(!e)return;const i=new m6e(16777215,Math.PI/2);return e.add(i),()=>{e.remove(i)}},[e]),AI(()=>{if(!t)return;const i=window.TSCI_MAIN_CAMERA_ROTATION,r=whn(i,2);t.position.copy(r),t.lookAt(0,0,0)});const n=Ee.useMemo(()=>{const i=new I9;i.rotation.fromArray([Math.PI/2,0,0]);const r=new pd(new uw(1,1,1),new N9({color:"white"}));i.add(r);const o=new eP(new Wwt(new uw(1,1,1)),new RT({color:0,linewidth:2}));return i.add(o),i},[]);return Ee.useEffect(()=>{if(e)return e.add(n),()=>{e.remove(n)}},[e,n]),ye.jsxs(ye.Fragment,{children:[ye.jsx(aM,{parent:n,position:[0,0,.51],fontSize:.25,color:"black",children:"Front"}),ye.jsx(aM,{parent:n,position:[0,0,-.51],fontSize:.25,color:"black",rotation:[0,Math.PI,0],children:"Back"}),ye.jsx(aM,{parent:n,position:[.51,0,0],fontSize:.25,color:"black",rotation:[0,Math.PI/2,0],children:"Right"}),ye.jsx(aM,{parent:n,position:[-.51,0,0],fontSize:.25,color:"black",rotation:[0,-Math.PI/2,0],children:"Left"}),ye.jsx(aM,{parent:n,position:[0,.51,0],fontSize:.25,color:"black",rotation:[-Math.PI/2,0,0],children:"Top"}),ye.jsx(aM,{parent:n,position:[0,-.51,0],fontSize:.25,color:"black",rotation:[Math.PI/2,0,0],children:"Bottom"})]})};function Ehn(t){t.querySelectorAll("canvas").forEach(e=>e.remove())}var Zqe=Ee.forwardRef(({children:t,scene:e,camera:n,style:i},r)=>{const o=Ee.useRef(null),[s,a]=Ee.useState(null),c=Ee.useRef([]),l=Ee.useCallback(f=>{c.current.push(f)},[]),u=Ee.useCallback(f=>{c.current=c.current.filter(m=>m!==f)},[]),d=Ee.useMemo(()=>new ZR,[]);e?.up&&d.up.set(e.up.x,e.up.y,e.up.z);const h=Ee.useRef(new p0);return Ee.useImperativeHandle(r,()=>h.current),Ee.useEffect(()=>{if(!o.current)return;Ehn(o.current);const f=new F8e({antialias:!0,alpha:!0});f.setSize(o.current.clientWidth,o.current.clientHeight),f.setPixelRatio(window.devicePixelRatio),o.current.appendChild(f.domElement);const m=new Ax(75,o.current.clientWidth/o.current.clientHeight,.1,1e3);n?.up&&m.up.set(n.up[0],n.up[1],n.up[2]),n?.position&&m.position.set(n.position[0],n.position[1],n.position[2]),m.lookAt(0,0,0),d.add(h.current),window.__TSCIRCUIT_THREE_OBJECT=h.current,a({scene:d,camera:m,renderer:f,rootObject:h.current,addFrameListener:l,removeFrameListener:u});let y;const g=new NSt,b=()=>{const w=g.getElapsedTime(),T=g.getDelta();c.current.forEach(N=>N(w,T)),f.render(d,m),y=requestAnimationFrame(b)};b();const v=()=>{o.current&&(m.aspect=o.current.clientWidth/o.current.clientHeight,m.updateProjectionMatrix(),f.setSize(o.current.clientWidth,o.current.clientHeight))};return window.addEventListener("resize",v),()=>{window.removeEventListener("resize",v),cancelAnimationFrame(y),o.current&&f.domElement&&o.current.removeChild(f.domElement),f.dispose(),d.remove(h.current),window.__TSCIRCUIT_THREE_OBJECT===h.current&&(window.__TSCIRCUIT_THREE_OBJECT=void 0)}},[d,l,u]),ye.jsx("div",{ref:o,style:{width:"100%",height:"100%",...i},children:s&&ye.jsx(kYe.Provider,{value:s,children:ye.jsx(ron,{children:t})})})}),Thn=({autoRotate:t,autoRotateSpeed:e,onStart:n,panSpeed:i,rotateSpeed:r,zoomSpeed:o,enableDamping:s,dampingFactor:a,target:c})=>{const{camera:l,renderer:u}=Nx(),d=Ee.useMemo(()=>!l||!u?null:new iEt(l,u.domElement),[l,u]);return Ee.useEffect(()=>{d&&(d.autoRotate=t||!1,d.autoRotateSpeed=e||1,i!==void 0&&(d.panSpeed=i),r!==void 0&&(d.rotateSpeed=r),o!==void 0&&(d.zoomSpeed=o),s!==void 0&&(d.enableDamping=s),a!==void 0&&(d.dampingFactor=a),d.zoomToCursor=!0,c&&(d.target.set(c[0],c[1],c[2]),d.update()))},[d,t,e,i,r,o,s,a,c]),Ee.useEffect(()=>{if(!(!d||!n))return d.addEventListener("start",n),()=>{d.removeEventListener("start",n)}},[d,n]),Ee.useEffect(()=>{if(d)return()=>{d.dispose()}},[d]),AI(()=>{d?.update()},[d]),null},Mhn=`
5083
+ `).replace(/d 0\./g,"d 1."),f=l.replace(/newmtl[\s\S]*?endmtl/g,"").replace(/^mtllib.*/gm,""),m=new W3t;m.setMaterialOptions({invertTrProperty:!0});const y=m.parse(h.replace(/Kd\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/g,"Kd $2 $2 $2"),"embedded.mtl");return d.setMaterials(y),d.parse(f)}return d.parse(l.replace(/^mtllib.*/gm,""))}catch(c){return c}}function a(){if(r.has(i)){const l=r.get(i);return l.result?Promise.resolve(l.result.clone()):l.promise.then(u=>u instanceof Error?u:u.clone())}const c=s().then(l=>(l instanceof Error||r.set(i,{...r.get(i),result:l}),l));return r.set(i,{promise:c,result:null}),c}return a().then(c=>{o||n(c)}).catch(c=>{console.error(c)}),()=>{o=!0}},[t]),e}function lon({url:t,position:e,rotation:n,onHover:i,onUnhover:r,isHovered:o,scale:s}){const a=con(t),{rootObject:c}=Nx(),l=Ee.useMemo(()=>a&&!(a instanceof Error)?a:new pd(new uw(.5,.5,.5),new N9({transparent:!0,color:"red",opacity:.25})),[a]);if(Ee.useEffect(()=>{if(!(!c||!l))return c.add(l),()=>{c.remove(l)}},[c,l]),Ee.useEffect(()=>{l&&(e&&(Array.isArray(e)?l.position.fromArray(e):l.position.copy(e)),n&&(Array.isArray(n)?l.rotation.fromArray(n):l.rotation.copy(n)),s!==void 0&&l.scale.setScalar(s))},[l,Array.isArray(e)?e[0]:e?.x,Array.isArray(e)?e[1]:e?.y,Array.isArray(e)?e[2]:e?.z,Array.isArray(n)?n[0]:n?.x,Array.isArray(n)?n[1]:n?.y,Array.isArray(n)?n[2]:n?.z,s]),a instanceof Error)throw a;return ye.jsx(CI,{isHovered:o,onHover:i,onUnhover:r,object:l})}function uon({gltfUrl:t,position:e,rotation:n,onHover:i,onUnhover:r,isHovered:o,scale:s}){const{rootObject:a}=Nx(),[c,l]=Ee.useState(null);return Ee.useEffect(()=>{if(!t)return;const u=new p3t;let d=!0;return u.load(t,h=>{d&&l(h.scene)},void 0,h=>{d&&console.error(`An error happened loading ${t}`,h)}),()=>{d=!1}},[t]),Ee.useEffect(()=>{c&&(e&&c.position.fromArray(e),n&&c.rotation.fromArray(n),s!==void 0&&c.scale.setScalar(s))},[c,e?.[0],e?.[1],e?.[2],n?.[0],n?.[1],n?.[2],s]),Ee.useEffect(()=>{if(!(!a||!c))return a.add(c),()=>{a.remove(c)}},[a,c]),Ee.useEffect(()=>{c&&c.traverse(u=>{u instanceof pd&&u.material instanceof N9&&(o?(u.material.emissive.setHex(255),u.material.emissiveIntensity=.2):u.material.emissiveIntensity=0)})},[o,c]),c?ye.jsx(CI,{isHovered:o,onHover:i,onUnhover:r,object:c}):null}var don=jp(uGe()),hon=jp(d0e()),LYe={in:25.4,inch:25.4,mil:.0254,mm:1,m:1e3,cm:10,ft:304.8,feet:304.8},dh=t=>{let e=typeof t=="number"?"mm":t.replace(/^[^a-zA-Z]+/g,"").toLowerCase();e||(e="mm");const n=typeof t=="number"?t:Number.parseFloat(t.split(e)[0]);if(e in LYe)return n*LYe[e];throw new Error(`Unsupported unit: ${e}`)},RI=dh,DYe={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,kohm: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}}},h0e=new Set;for(const[t,e]of Object.entries(DYe)){h0e.add(t);for(const n of Object.keys(e.variants))h0e.add(n)}function pon(t){for(const[e,n]of Object.entries(DYe))if(t in n.variants)return{baseUnit:n.baseUnit,conversionFactor:n.variants[t]};return{baseUnit:t,conversionFactor:1}}var zYe={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},m5=t=>{if(typeof t>"u")return{parsedUnit:null,unitOfValue:null,value:null};if(typeof t=="string"&&t.match(/^-?[\d\.]+$/))return{value:Number.parseFloat(t),parsedUnit:null,unitOfValue:null};if(typeof t=="number")return{value:t,parsedUnit:null,unitOfValue:null};if(typeof t=="object"&&"x"in t&&"y"in t){const{parsedUnit:a,unitOfValue:c}=m5(t.x);return{parsedUnit:a,unitOfValue:c,value:{x:m5(t.x).value,y:m5(t.y).value}}}const n=t.toString().split("").reverse().join("").match(/[^\d\s]+/)?.[0];if(!n)throw new Error(`Could not determine unit: "${t}"`);const i=n.split("").reverse().join(""),r=t.slice(0,-i.length);if(i in zYe&&!h0e.has(i)){const a=zYe[i];return{parsedUnit:null,unitOfValue:null,value:Number.parseFloat(r)*a}}const{baseUnit:o,conversionFactor:s}=pon(i);return{parsedUnit:i,unitOfValue:o,value:s*Number.parseFloat(r)}},p0e=B().or(Ue()).transform(t=>m5(t).value),FYe=B().or(Ue()).transform(t=>m5(t).value).transform(t=>Number.parseFloat(t.toPrecision(12))),fon=B().or(Ue()).transform(t=>m5(t).value),FA=B().or(Ue()).transform(t=>m5(t).value),_t=B().or(Ue()).transform(t=>m5(t).value),BYe=B().or(Ue()).transform(t=>m5(t).value),Di=_t;B().or(Ue()).transform(t=>m5(t).value),B().or(Ue()).transform(t=>m5(t).value);var n3=B().or(Ue()).transform(t=>typeof t=="number"?t:t.endsWith("deg")?Number.parseFloat(t.split("deg")[0]):t.endsWith("rad")?Number.parseFloat(t.split("rad")[0])*180/Math.PI:Number.parseFloat(t)),mon=Ue().or(B().endsWith("mAh")).transform(t=>{if(typeof t=="string"){const e=t.replace("mAh",""),n=Number.parseFloat(e);if(Number.isNaN(n))throw new Error("Invalid capacity");return n}return t}).describe("Battery capacity in mAh"),au=Ne({x:Di,y:Di}),f0e=Ne({x:Di,y:Di,z:Di}),UYe=Ne({width:Ue(),height:Ue()}),_on=t=>{const e="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";return Array.from({length:t},()=>e[Math.floor(Math.random()*e.length)]).join("")},Io=t=>B().optional().default(()=>`${t}_${_on(10)}`),m0e=dn(["top_left","top_center","top_right","center_left","center","center_right","bottom_left","bottom_center","bottom_right"]),yon=dn(["jlcpcb","macrofab","pcbway","digikey","mouser","lcsc"]),C1=Ne({type:Ce("source_component"),ftype:B().optional(),source_component_id:B(),name:B(),manufacturer_part_number:B().optional(),supplier_part_numbers:Us(yon,Ct(B())).optional(),display_value:B().optional(),are_pins_interchangeable:bt().optional(),internally_connected_source_port_ids:Ct(Ct(B())).optional(),source_group_id:B().optional(),subcircuit_id:B().optional()}),$Ye=C1.extend({ftype:Ce("simple_capacitor"),capacitance:FYe,max_voltage_rating:FA.optional(),display_capacitance:B().optional(),max_decoupling_trace_length:Di.optional()}),jYe=C1.extend({ftype:Ce("simple_resistor"),resistance:p0e,display_resistance:B().optional()}),_0e=C1.extend({ftype:Ce("simple_diode")}),HYe=_0e.extend({ftype:Ce("simple_led"),color:B().optional(),wavelength:B().optional()}),gon=C1.extend({ftype:Ce("simple_ground")}),VYe=C1.extend({ftype:Ce("simple_chip")}),GYe=C1.extend({ftype:Ce("simple_power_source"),voltage:FA}),bon=C1.extend({ftype:Ce("simple_fuse"),current_rating_amps:Ue().describe("Nominal current in amps the fuse is rated for"),voltage_rating_volts:Ue().describe("Voltage rating in volts, e.g. ±5V would be 5")}),YYe=C1.extend({ftype:Ce("simple_battery"),capacity:mon}),qYe=C1.extend({ftype:Ce("simple_inductor"),inductance:fon,max_current_rating:Ue().optional()}),XYe=C1.extend({ftype:Ce("simple_push_button")}),WYe=C1.extend({ftype:Ce("simple_potentiometer"),max_resistance:p0e}),xon=C1.extend({ftype:Ce("simple_crystal"),frequency:Ue().describe("Frequency in Hz"),load_capacitance:Ue().optional().describe("Load capacitance in pF")}),ZYe=C1.extend({ftype:Ce("simple_pin_header"),pin_count:Ue(),gender:dn(["male","female"]).optional().default("male")}),KYe=C1.extend({ftype:Ce("simple_pinout")}),QYe=C1.extend({ftype:Ce("simple_resonator"),load_capacitance:FYe,equivalent_series_resistance:p0e.optional(),frequency:BYe}),JYe=C1.extend({ftype:Ce("simple_transistor"),transistor_type:dn(["npn","pnp"])}),eqe=C1.extend({ftype:Ce("simple_test_point"),footprint_variant:dn(["pad","through_hole"]).optional(),pad_shape:dn(["rect","circle"]).optional(),pad_diameter:oi([Ue(),B()]).optional(),hole_diameter:oi([Ue(),B()]).optional(),width:oi([Ue(),B()]).optional(),height:oi([Ue(),B()]).optional()}),tqe=C1.extend({ftype:Ce("simple_mosfet"),channel_type:dn(["n","p"]),mosfet_mode:dn(["enhancement","depletion"])}),nqe=C1.extend({ftype:Ce("simple_switch")}),iqe=Ne({type:Ce("source_project_metadata"),name:B().optional(),software_used_string:B().optional(),project_url:B().optional(),created_at:B().datetime().optional()}),von=Ne({type:Ce("source_missing_property_error"),source_missing_property_error_id:Io("source_missing_property_error"),source_component_id:B(),property_name:B(),subcircuit_id:B().optional(),error_type:Ce("source_missing_property_error").default("source_missing_property_error"),message:B()}).describe("The source code is missing a property"),won=Ne({type:Ce("source_failed_to_create_component_error"),source_failed_to_create_component_error_id:Io("source_failed_to_create_component_error"),error_type:Ce("source_failed_to_create_component_error").default("source_failed_to_create_component_error"),component_name:B().optional(),subcircuit_id:B().optional(),parent_source_component_id:B().optional(),message:B(),pcb_center:Ne({x:Ue().optional(),y:Ue().optional()}).optional(),schematic_center:Ne({x:Ue().optional(),y:Ue().optional()}).optional()}).describe("Error emitted when a component fails to be constructed"),rqe=Ne({type:Ce("source_trace_not_connected_error"),source_trace_not_connected_error_id:Io("source_trace_not_connected_error"),error_type:Ce("source_trace_not_connected_error").default("source_trace_not_connected_error"),message:B(),subcircuit_id:B().optional(),source_group_id:B().optional(),source_trace_id:B().optional(),connected_source_port_ids:Ct(B()).optional(),selectors_not_found:Ct(B()).optional()}).describe("Occurs when a source trace selector does not match any ports"),Son=Ne({type:Ce("source_property_ignored_warning"),source_property_ignored_warning_id:Io("source_property_ignored_warning"),source_component_id:B(),property_name:B(),subcircuit_id:B().optional(),error_type:Ce("source_property_ignored_warning").default("source_property_ignored_warning"),message:B()}).describe("The source property was ignored"),oqe=Ne({type:Ce("source_pin_missing_trace_warning"),source_pin_missing_trace_warning_id:Io("source_pin_missing_trace_warning"),warning_type:Ce("source_pin_missing_trace_warning").default("source_pin_missing_trace_warning"),message:B(),source_component_id:B(),source_port_id:B(),subcircuit_id:B().optional()}).describe("Warning emitted when a source component pin is missing a trace connection"),Eon=oi([jYe,$Ye,_0e,HYe,gon,VYe,GYe,YYe,qYe,XYe,WYe,xon,ZYe,KYe,QYe,nqe,JYe,eqe,tqe,bon,iqe,von,won,rqe,Son,oqe]),Ton=Ne({type:Ce("source_port"),pin_number:Ue().optional(),port_hints:Ct(B()).optional(),name:B(),source_port_id:B(),source_component_id:B(),subcircuit_id:B().optional(),subcircuit_connectivity_map_key:B().optional()}),Mon=Ne({type:Ce("source_trace"),source_trace_id:B(),connected_source_port_ids:Ct(B()),connected_source_net_ids:Ct(B()),subcircuit_id:B().optional(),subcircuit_connectivity_map_key:B().optional(),max_length:Ue().optional(),min_trace_thickness:Ue().optional(),display_name:B().optional()}),Aon=Ne({type:Ce("source_group"),source_group_id:B(),subcircuit_id:B().optional(),parent_subcircuit_id:B().optional(),parent_source_group_id:B().optional(),is_subcircuit:bt().optional(),show_as_schematic_box:bt().optional(),name:B().optional()}),Con=Ne({type:Ce("source_net"),source_net_id:B(),name:B(),member_source_group_ids:Ct(B()),is_power:bt().optional(),is_ground:bt().optional(),is_digital_signal:bt().optional(),is_analog_signal:bt().optional(),is_positive_voltage_source:bt().optional(),trace_width:Ue().optional(),subcircuit_id:B().optional(),subcircuit_connectivity_map_key:B().optional()}),Ron=Ne({type:Ce("source_pcb_ground_plane"),source_pcb_ground_plane_id:B(),source_group_id:B(),source_net_id:B(),subcircuit_id:B().optional()}).describe("Defines a ground plane in the source domain"),Pon=["top","bottom","inner1","inner2","inner3","inner4","inner5","inner6"],sqe=dn(Pon),Dh=sqe.or(Ne({name:sqe})).transform(t=>typeof t=="string"?t:t.name),PI=dn(["top","bottom"]),Ion=Ne({type:Ce("source_manually_placed_via"),source_manually_placed_via_id:B(),source_group_id:B(),source_net_id:B(),subcircuit_id:B().optional(),source_trace_id:B().optional()}).describe("Defines a via that is manually placed in the source domain"),Non=Ne({type:Ce("schematic_box"),schematic_component_id:B().optional(),width:Di,height:Di,is_dashed:bt().default(!1),x:Di,y:Di,subcircuit_id:B().optional()}).describe("Draws a box on the schematic"),kon=Ne({type:Ce("schematic_path"),schematic_component_id:B(),fill_color:dn(["red","blue"]).optional(),is_filled:bt().optional(),points:Ct(au),subcircuit_id:B().optional()}),Oon=Us(Ne({left_margin:_t.optional(),right_margin:_t.optional(),top_margin:_t.optional(),bottom_margin:_t.optional()})),Lon=Ne({left_size:Ue(),right_size:Ue(),top_size:Ue().optional(),bottom_size:Ue().optional()}),Don=Ne({left_side:Ne({pins:Ct(Ue()),direction:dn(["top-to-bottom","bottom-to-top"]).optional()}).optional(),right_side:Ne({pins:Ct(Ue()),direction:dn(["top-to-bottom","bottom-to-top"]).optional()}).optional(),top_side:Ne({pins:Ct(Ue()),direction:dn(["left-to-right","right-to-left"]).optional()}).optional(),bottom_side:Ne({pins:Ct(Ue()),direction:dn(["left-to-right","right-to-left"]).optional()}).optional()}),zon=oi([Lon,Don]),Fon=Ne({type:Ce("schematic_component"),size:UYe,center:au,source_component_id:B().optional(),schematic_component_id:B(),pin_spacing:_t.optional(),pin_styles:Oon.optional(),box_width:_t.optional(),symbol_name:B().optional(),port_arrangement:zon.optional(),port_labels:Us(B()).optional(),symbol_display_value:B().optional(),subcircuit_id:B().optional(),schematic_group_id:B().optional(),is_schematic_group:bt().optional(),source_group_id:B().optional()}),Bon=Ne({type:Ce("schematic_line"),schematic_component_id:B(),x1:Di,x2:Di,y1:Di,y2:Di,subcircuit_id:B().optional()}),Uon=Ne({type:Ce("schematic_trace"),schematic_trace_id:B(),source_trace_id:B().optional(),junctions:Ct(Ne({x:Ue(),y:Ue()})),edges:Ct(Ne({from:Ne({x:Ue(),y:Ue()}),to:Ne({x:Ue(),y:Ue()}),is_crossing:bt().optional(),from_schematic_port_id:B().optional(),to_schematic_port_id:B().optional()})),subcircuit_id:B().optional(),subcircuit_connectivity_map_key:B().optional()}),$on=dn(["center","left","right","top","bottom"]),jon=Ne({type:Ce("schematic_text"),schematic_component_id:B().optional(),schematic_text_id:B(),text:B(),font_size:Ue().default(.18),position:Ne({x:Di,y:Di}),rotation:Ue().default(0),anchor:oi([$on.describe("legacy"),m0e]).default("center"),color:B().default("#000000"),subcircuit_id:B().optional()}),Hon=Ne({type:Ce("schematic_port"),schematic_port_id:B(),source_port_id:B(),schematic_component_id:B().optional(),center:au,facing_direction:dn(["up","down","left","right"]).optional(),distance_from_component_edge:Ue().optional(),side_of_component:dn(["top","bottom","left","right"]).optional(),true_ccw_index:Ue().optional(),pin_number:Ue().optional(),display_pin_label:B().optional(),subcircuit_id:B().optional(),is_connected:bt().optional(),has_input_arrow:bt().optional(),has_output_arrow:bt().optional()}).describe("Defines a port on a schematic component"),Von=Ne({type:Ce("schematic_net_label"),schematic_net_label_id:Io("schematic_net_label"),schematic_trace_id:B().optional(),source_trace_id:B().optional(),source_net_id:B(),center:au,anchor_position:au.optional(),anchor_side:dn(["top","bottom","left","right"]),text:B(),symbol_name:B().optional(),is_movable:bt().optional(),subcircuit_id:B().optional()}),Gon=Ne({type:Ce("schematic_error"),schematic_error_id:B(),error_type:Ce("schematic_port_not_found").default("schematic_port_not_found"),message:B(),subcircuit_id:B().optional()}).describe("Defines a schematic error on the schematic"),Yon=Ne({type:Ce("schematic_layout_error"),schematic_layout_error_id:Io("schematic_layout_error"),error_type:Ce("schematic_layout_error").default("schematic_layout_error"),message:B(),source_group_id:B(),schematic_group_id:B(),subcircuit_id:B().optional()}).describe("Error emitted when schematic layout fails for a group"),y0e=Ne({type:Ce("schematic_debug_object"),label:B().optional(),subcircuit_id:B().optional()}),qon=y0e.extend({shape:Ce("rect"),center:au,size:UYe}),Xon=y0e.extend({shape:Ce("line"),start:au,end:au}),Won=y0e.extend({shape:Ce("point"),center:au}),Zon=uy("shape",[qon,Xon,Won]),Kon=Ne({type:Ce("schematic_voltage_probe"),schematic_voltage_probe_id:B(),position:au,schematic_trace_id:B(),voltage:FA.optional(),subcircuit_id:B().optional()}).describe("Defines a voltage probe measurement point on a schematic trace"),Qon=Ne({type:Ce("schematic_manual_edit_conflict_warning"),schematic_manual_edit_conflict_warning_id:Io("schematic_manual_edit_conflict_warning"),warning_type:Ce("schematic_manual_edit_conflict_warning").default("schematic_manual_edit_conflict_warning"),message:B(),schematic_component_id:B(),schematic_group_id:B().optional(),subcircuit_id:B().optional(),source_component_id:B()}).describe("Warning emitted when a component has both manual placement and explicit schX/schY coordinates"),Jon=Ne({type:Ce("schematic_group"),schematic_group_id:Io("schematic_group"),source_group_id:B(),is_subcircuit:bt().optional(),subcircuit_id:B().optional(),width:_t,height:_t,center:au,schematic_component_ids:Ct(B()),show_as_schematic_box:bt().optional(),name:B().optional(),description:B().optional()}).describe("Defines a group of components on the schematic"),esn=Ne({type:Ce("schematic_table"),schematic_table_id:Io("schematic_table"),anchor_position:au,column_widths:Ct(Di),row_heights:Ct(Di),cell_padding:Di.optional(),border_width:Di.optional(),subcircuit_id:B().optional(),schematic_component_id:B().optional(),anchor:m0e.optional()}).describe("Defines a table on the schematic"),tsn=Ne({type:Ce("schematic_table_cell"),schematic_table_cell_id:Io("schematic_table_cell"),schematic_table_id:B(),start_row_index:Ue(),end_row_index:Ue(),start_column_index:Ue(),end_column_index:Ue(),text:B().optional(),center:au,width:Di,height:Di,horizontal_align:dn(["left","center","right"]).optional(),vertical_align:dn(["top","middle","bottom"]).optional(),font_size:Di.optional(),subcircuit_id:B().optional()}).describe("Defines a cell within a schematic_table"),nsn=Ne({x:Di,y:Di,bulge:Ue().optional()}),aqe=Ne({vertices:Ct(nsn)}),isn=Ne({outer_ring:aqe,inner_rings:Ct(aqe).default([])}),rsn=Ne({x:Di,y:Di,via:bt().optional(),via_to_layer:Dh.optional()});Ct(rsn);var osn=Ne({x:Di,y:Di,via:bt().optional(),to_layer:Dh.optional(),trace_width:Di.optional()}),ssn=Ne({type:Ce("pcb_component"),pcb_component_id:Io("pcb_component"),source_component_id:B(),center:au,layer:Dh,rotation:n3,width:_t,height:_t,subcircuit_id:B().optional(),pcb_group_id:B().optional()}).describe("Defines a component on the PCB"),cqe=Ne({type:Ce("pcb_hole"),pcb_hole_id:Io("pcb_hole"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),hole_shape:dn(["circle","square"]),hole_diameter:Ue(),x:Di,y:Di});cqe.describe("Defines a circular or square hole on the PCB");var lqe=Ne({type:Ce("pcb_hole"),pcb_hole_id:Io("pcb_hole"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),hole_shape:Ce("oval"),hole_width:Ue(),hole_height:Ue(),x:Di,y:Di});lqe.describe("Defines an oval hole on the PCB");var asn=cqe.or(lqe),csn=Ne({type:Ce("pcb_plated_hole"),shape:Ce("circle"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),outer_diameter:Ue(),hole_diameter:Ue(),x:Di,y:Di,layers:Ct(Dh),port_hints:Ct(B()).optional(),pcb_component_id:B().optional(),pcb_port_id:B().optional(),pcb_plated_hole_id:Io("pcb_plated_hole")}),lsn=Ne({type:Ce("pcb_plated_hole"),shape:dn(["oval","pill"]),pcb_group_id:B().optional(),subcircuit_id:B().optional(),outer_width:Ue(),outer_height:Ue(),hole_width:Ue(),hole_height:Ue(),x:Di,y:Di,ccw_rotation:n3,layers:Ct(Dh),port_hints:Ct(B()).optional(),pcb_component_id:B().optional(),pcb_port_id:B().optional(),pcb_plated_hole_id:Io("pcb_plated_hole")}),usn=Ne({type:Ce("pcb_plated_hole"),shape:Ce("circular_hole_with_rect_pad"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),hole_shape:Ce("circle"),pad_shape:Ce("rect"),hole_diameter:Ue(),rect_pad_width:Ue(),rect_pad_height:Ue(),rect_border_radius:Ue().optional(),hole_offset_x:Di.default(0),hole_offset_y:Di.default(0),x:Di,y:Di,layers:Ct(Dh),port_hints:Ct(B()).optional(),pcb_component_id:B().optional(),pcb_port_id:B().optional(),pcb_plated_hole_id:Io("pcb_plated_hole")}),dsn=Ne({type:Ce("pcb_plated_hole"),shape:Ce("pill_hole_with_rect_pad"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),hole_shape:Ce("pill"),pad_shape:Ce("rect"),hole_width:Ue(),hole_height:Ue(),rect_pad_width:Ue(),rect_pad_height:Ue(),rect_border_radius:Ue().optional(),x:Di,y:Di,layers:Ct(Dh),port_hints:Ct(B()).optional(),pcb_component_id:B().optional(),pcb_port_id:B().optional(),pcb_plated_hole_id:Io("pcb_plated_hole")}),hsn=Ne({type:Ce("pcb_plated_hole"),shape:Ce("rotated_pill_hole_with_rect_pad"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),hole_shape:Ce("rotated_pill"),pad_shape:Ce("rect"),hole_width:Ue(),hole_height:Ue(),hole_ccw_rotation:n3,rect_pad_width:Ue(),rect_pad_height:Ue(),rect_border_radius:Ue().optional(),rect_ccw_rotation:n3,x:Di,y:Di,layers:Ct(Dh),port_hints:Ct(B()).optional(),pcb_component_id:B().optional(),pcb_port_id:B().optional(),pcb_plated_hole_id:Io("pcb_plated_hole")}),psn=oi([csn,lsn,usn,dsn,hsn]),fsn=Ne({type:Ce("pcb_port"),pcb_port_id:Io("pcb_port"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),source_port_id:B(),pcb_component_id:B(),x:Di,y:Di,layers:Ct(Dh),is_board_pinout:bt().optional()}).describe("Defines a port on the PCB"),msn=Ne({type:Ce("pcb_smtpad"),shape:Ce("circle"),pcb_smtpad_id:Io("pcb_smtpad"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),x:Di,y:Di,radius:Ue(),layer:Dh,port_hints:Ct(B()).optional(),pcb_component_id:B().optional(),pcb_port_id:B().optional(),is_covered_with_solder_mask:bt().optional()}),_sn=Ne({type:Ce("pcb_smtpad"),shape:Ce("rect"),pcb_smtpad_id:Io("pcb_smtpad"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),x:Di,y:Di,width:Ue(),height:Ue(),rect_border_radius:Ue().optional(),layer:Dh,port_hints:Ct(B()).optional(),pcb_component_id:B().optional(),pcb_port_id:B().optional(),is_covered_with_solder_mask:bt().optional()}),ysn=Ne({type:Ce("pcb_smtpad"),shape:Ce("rotated_rect"),pcb_smtpad_id:Io("pcb_smtpad"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),x:Di,y:Di,width:Ue(),height:Ue(),rect_border_radius:Ue().optional(),ccw_rotation:n3,layer:Dh,port_hints:Ct(B()).optional(),pcb_component_id:B().optional(),pcb_port_id:B().optional(),is_covered_with_solder_mask:bt().optional()}),gsn=Ne({type:Ce("pcb_smtpad"),shape:Ce("pill"),pcb_smtpad_id:Io("pcb_smtpad"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),x:Di,y:Di,width:Ue(),height:Ue(),radius:Ue(),layer:Dh,port_hints:Ct(B()).optional(),pcb_component_id:B().optional(),pcb_port_id:B().optional(),is_covered_with_solder_mask:bt().optional()}),bsn=Ne({type:Ce("pcb_smtpad"),shape:Ce("rotated_pill"),pcb_smtpad_id:Io("pcb_smtpad"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),x:Di,y:Di,width:Ue(),height:Ue(),radius:Ue(),ccw_rotation:n3,layer:Dh,port_hints:Ct(B()).optional(),pcb_component_id:B().optional(),pcb_port_id:B().optional(),is_covered_with_solder_mask:bt().optional()}),xsn=Ne({type:Ce("pcb_smtpad"),shape:Ce("polygon"),pcb_smtpad_id:Io("pcb_smtpad"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),points:Ct(au),layer:Dh,port_hints:Ct(B()).optional(),pcb_component_id:B().optional(),pcb_port_id:B().optional(),is_covered_with_solder_mask:bt().optional()}),vsn=uy("shape",[msn,_sn,ysn,bsn,gsn,xsn]).describe("Defines an SMT pad on the PCB"),wsn=Ne({type:Ce("pcb_solder_paste"),shape:Ce("circle"),pcb_solder_paste_id:Io("pcb_solder_paste"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),x:Di,y:Di,radius:Ue(),layer:Dh,pcb_component_id:B().optional(),pcb_smtpad_id:B().optional()}),Ssn=Ne({type:Ce("pcb_solder_paste"),shape:Ce("rect"),pcb_solder_paste_id:Io("pcb_solder_paste"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),x:Di,y:Di,width:Ue(),height:Ue(),layer:Dh,pcb_component_id:B().optional(),pcb_smtpad_id:B().optional()}),Esn=Ne({type:Ce("pcb_solder_paste"),shape:Ce("pill"),pcb_solder_paste_id:Io("pcb_solder_paste"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),x:Di,y:Di,width:Ue(),height:Ue(),radius:Ue(),layer:Dh,pcb_component_id:B().optional(),pcb_smtpad_id:B().optional()}),Tsn=Ne({type:Ce("pcb_solder_paste"),shape:Ce("rotated_rect"),pcb_solder_paste_id:Io("pcb_solder_paste"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),x:Di,y:Di,width:Ue(),height:Ue(),ccw_rotation:Di,layer:Dh,pcb_component_id:B().optional(),pcb_smtpad_id:B().optional()}),Msn=Ne({type:Ce("pcb_solder_paste"),shape:Ce("oval"),pcb_solder_paste_id:Io("pcb_solder_paste"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),x:Di,y:Di,width:Ue(),height:Ue(),layer:Dh,pcb_component_id:B().optional(),pcb_smtpad_id:B().optional()}),Asn=oi([wsn,Ssn,Esn,Tsn,Msn]).describe("Defines solderpaste on the PCB"),Csn=Ne({type:Ce("pcb_text"),pcb_text_id:Io("pcb_text"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),text:B(),center:au,layer:Dh,width:_t,height:_t,lines:Ue(),align:dn(["bottom-left"])}).describe("Defines text on the PCB"),Rsn=Ne({route_type:Ce("wire"),x:Di,y:Di,width:Di,start_pcb_port_id:B().optional(),end_pcb_port_id:B().optional(),layer:Dh}),Psn=Ne({route_type:Ce("via"),x:Di,y:Di,hole_diameter:Di.optional(),outer_diameter:Di.optional(),from_layer:B(),to_layer:B()}),Isn=oi([Rsn,Psn]),Nsn=Ne({type:Ce("pcb_trace"),source_trace_id:B().optional(),pcb_component_id:B().optional(),pcb_trace_id:Io("pcb_trace"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),route_thickness_mode:dn(["constant","interpolated"]).default("constant").optional(),route_order_index:Ue().optional(),should_round_corners:bt().optional(),trace_length:Ue().optional(),route:Ct(Isn)}).describe("Defines a trace on the PCB"),ksn=Ne({type:Ce("pcb_trace_error"),pcb_trace_error_id:Io("pcb_trace_error"),error_type:Ce("pcb_trace_error").default("pcb_trace_error"),message:B(),center:au.optional(),pcb_trace_id:B(),source_trace_id:B(),pcb_component_ids:Ct(B()),pcb_port_ids:Ct(B()),subcircuit_id:B().optional()}).describe("Defines a trace error on the PCB"),Osn=Ne({type:Ce("pcb_trace_missing_error"),pcb_trace_missing_error_id:Io("pcb_trace_missing_error"),error_type:Ce("pcb_trace_missing_error").default("pcb_trace_missing_error"),message:B(),center:au.optional(),source_trace_id:B(),pcb_component_ids:Ct(B()),pcb_port_ids:Ct(B()),subcircuit_id:B().optional()}).describe("Defines an error when a source trace has no corresponding PCB trace"),Lsn=Ne({type:Ce("pcb_port_not_matched_error"),pcb_error_id:Io("pcb_error"),error_type:Ce("pcb_port_not_matched_error").default("pcb_port_not_matched_error"),message:B(),pcb_component_ids:Ct(B()),subcircuit_id:B().optional()}).describe("Defines a trace error on the PCB where a port is not matched"),Dsn=Ne({type:Ce("pcb_port_not_connected_error"),pcb_port_not_connected_error_id:Io("pcb_port_not_connected_error"),error_type:Ce("pcb_port_not_connected_error").default("pcb_port_not_connected_error"),message:B(),pcb_port_ids:Ct(B()),pcb_component_ids:Ct(B()),subcircuit_id:B().optional()}).describe("Defines an error when a pcb port is not connected to any trace"),zsn=Ne({type:Ce("pcb_via"),pcb_via_id:Io("pcb_via"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),x:Di,y:Di,outer_diameter:Di.default("0.6mm"),hole_diameter:Di.default("0.25mm"),from_layer:Dh.optional(),to_layer:Dh.optional(),layers:Ct(Dh),pcb_trace_id:B().optional()}).describe("Defines a via on the PCB"),Fsn=Ne({type:Ce("pcb_board"),pcb_board_id:Io("pcb_board"),is_subcircuit:bt().optional(),subcircuit_id:B().optional(),width:_t,height:_t,center:au,thickness:_t.optional().default(1.4),num_layers:Ue().optional().default(4),outline:Ct(au).optional(),material:dn(["fr4","fr1"]).default("fr4")}).describe("Defines the board outline of the PCB"),Bsn=Ne({type:Ce("pcb_placement_error"),pcb_placement_error_id:Io("pcb_placement_error"),error_type:Ce("pcb_placement_error").default("pcb_placement_error"),message:B(),subcircuit_id:B().optional()}).describe("Defines a placement error on the PCB"),Usn=Ne({type:Ce("pcb_trace_hint"),pcb_trace_hint_id:Io("pcb_trace_hint"),pcb_port_id:B(),pcb_component_id:B(),route:Ct(osn),subcircuit_id:B().optional()}).describe("A hint that can be used during generation of a PCB trace"),$sn=Ne({type:Ce("pcb_silkscreen_line"),pcb_silkscreen_line_id:Io("pcb_silkscreen_line"),pcb_component_id:B(),pcb_group_id:B().optional(),subcircuit_id:B().optional(),stroke_width:Di.default("0.1mm"),x1:Di,y1:Di,x2:Di,y2:Di,layer:PI}).describe("Defines a silkscreen line on the PCB"),jsn=Ne({type:Ce("pcb_silkscreen_path"),pcb_silkscreen_path_id:Io("pcb_silkscreen_path"),pcb_component_id:B(),pcb_group_id:B().optional(),subcircuit_id:B().optional(),layer:PI,route:Ct(au),stroke_width:_t}).describe("Defines a silkscreen path on the PCB"),Hsn=Ne({type:Ce("pcb_silkscreen_text"),pcb_silkscreen_text_id:Io("pcb_silkscreen_text"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),font:Ce("tscircuit2024").default("tscircuit2024"),font_size:Di.default("0.2mm"),pcb_component_id:B(),text:B(),is_knockout:bt().default(!1).optional(),knockout_padding:Ne({left:_t,top:_t,bottom:_t,right:_t}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:Ue().optional(),layer:Dh,is_mirrored:bt().default(!1).optional(),anchor_position:au.default({x:0,y:0}),anchor_alignment:m0e.default("center")}).describe("Defines silkscreen text on the PCB"),Vsn=Ne({type:Ce("pcb_silkscreen_rect"),pcb_silkscreen_rect_id:Io("pcb_silkscreen_rect"),pcb_component_id:B(),pcb_group_id:B().optional(),subcircuit_id:B().optional(),center:au,width:_t,height:_t,layer:Dh,stroke_width:_t.default("1mm"),is_filled:bt().default(!0).optional(),has_stroke:bt().optional(),is_stroke_dashed:bt().optional()}).describe("Defines a silkscreen rect on the PCB"),Gsn=Ne({type:Ce("pcb_silkscreen_circle"),pcb_silkscreen_circle_id:Io("pcb_silkscreen_circle"),pcb_component_id:B(),pcb_group_id:B().optional(),subcircuit_id:B().optional(),center:au,radius:_t,layer:PI,stroke_width:_t.default("1mm")}).describe("Defines a silkscreen circle on the PCB"),Ysn=Ne({type:Ce("pcb_silkscreen_oval"),pcb_silkscreen_oval_id:Io("pcb_silkscreen_oval"),pcb_component_id:B(),pcb_group_id:B().optional(),subcircuit_id:B().optional(),center:au,radius_x:Di,radius_y:Di,layer:PI}).describe("Defines a silkscreen oval on the PCB"),qsn=Ne({type:Ce("pcb_fabrication_note_text"),pcb_fabrication_note_text_id:Io("pcb_fabrication_note_text"),subcircuit_id:B().optional(),pcb_group_id:B().optional(),font:Ce("tscircuit2024").default("tscircuit2024"),font_size:Di.default("1mm"),pcb_component_id:B(),text:B(),layer:PI,anchor_position:au.default({x:0,y:0}),anchor_alignment:dn(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:B().optional()}).describe("Defines a fabrication note in text on the PCB, useful for leaving notes for assemblers or fabricators"),Xsn=Ne({type:Ce("pcb_fabrication_note_path"),pcb_fabrication_note_path_id:Io("pcb_fabrication_note_path"),pcb_component_id:B(),subcircuit_id:B().optional(),layer:Dh,route:Ct(au),stroke_width:_t,color:B().optional()}).describe("Defines a fabrication path on the PCB for fabricators or assemblers"),Wsn=Ne({type:Ce("pcb_footprint_overlap_error"),pcb_error_id:Io("pcb_error"),error_type:Ce("pcb_footprint_overlap_error").default("pcb_footprint_overlap_error"),message:B(),pcb_smtpad_ids:Ct(B()).optional(),pcb_plated_hole_ids:Ct(B()).optional(),pcb_hole_ids:Ct(B()).optional(),pcb_keepout_ids:Ct(B()).optional()}).describe("Error emitted when a pcb footprint overlaps with another element"),Zsn=Ne({type:Ce("pcb_keepout"),shape:Ce("rect"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),center:au,width:Di,height:Di,pcb_keepout_id:B(),layers:Ct(B()),description:B().optional()}).or(Ne({type:Ce("pcb_keepout"),shape:Ce("circle"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),center:au,radius:Di,pcb_keepout_id:B(),layers:Ct(B()),description:B().optional()})),g0e=Ne({type:Ce("pcb_cutout"),pcb_cutout_id:Io("pcb_cutout"),pcb_group_id:B().optional(),subcircuit_id:B().optional()}),Ksn=g0e.extend({shape:Ce("rect"),center:au,width:_t,height:_t,rotation:n3.optional()}),Qsn=g0e.extend({shape:Ce("circle"),center:au,radius:_t}),Jsn=g0e.extend({shape:Ce("polygon"),points:Ct(au)}),ean=uy("shape",[Ksn,Qsn,Jsn]).describe("Defines a cutout on the PCB, removing board material."),tan=Ne({type:Ce("pcb_missing_footprint_error"),pcb_missing_footprint_error_id:Io("pcb_missing_footprint_error"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),error_type:Ce("pcb_missing_footprint_error").default("pcb_missing_footprint_error"),source_component_id:B(),message:B()}).describe("Defines a missing footprint error on the PCB"),nan=Ne({type:Ce("external_footprint_load_error"),external_footprint_load_error_id:Io("external_footprint_load_error"),pcb_component_id:B(),source_component_id:B(),pcb_group_id:B().optional(),subcircuit_id:B().optional(),footprinter_string:B().optional(),error_type:Ce("external_footprint_load_error").default("external_footprint_load_error"),message:B()}).describe("Defines an error when an external footprint fails to load"),ian=Ne({type:Ce("pcb_group"),pcb_group_id:Io("pcb_group"),source_group_id:B(),is_subcircuit:bt().optional(),subcircuit_id:B().optional(),width:_t,height:_t,center:au,pcb_component_ids:Ct(B()),name:B().optional(),description:B().optional(),layout_mode:B().optional(),autorouter_configuration:Ne({trace_clearance:_t}).optional(),autorouter_used_string:B().optional()}).describe("Defines a group of components on the PCB"),ran=Ne({type:Ce("pcb_autorouting_error"),pcb_error_id:Io("pcb_autorouting_error"),error_type:Ce("pcb_autorouting_error").default("pcb_autorouting_error"),message:B(),subcircuit_id:B().optional()}).describe("The autorouting has failed to route a portion of the board"),oan=Ne({type:Ce("pcb_manual_edit_conflict_warning"),pcb_manual_edit_conflict_warning_id:Io("pcb_manual_edit_conflict_warning"),warning_type:Ce("pcb_manual_edit_conflict_warning").default("pcb_manual_edit_conflict_warning"),message:B(),pcb_component_id:B(),pcb_group_id:B().optional(),subcircuit_id:B().optional(),source_component_id:B()}).describe("Warning emitted when a component has both manual placement and explicit pcbX/pcbY coordinates"),san=Ne({type:Ce("pcb_breakout_point"),pcb_breakout_point_id:Io("pcb_breakout_point"),pcb_group_id:B(),subcircuit_id:B().optional(),source_trace_id:B().optional(),source_port_id:B().optional(),source_net_id:B().optional(),x:Di,y:Di}).describe("Defines a routing target within a pcb_group for a source_trace or source_net"),aan=Ne({type:Ce("pcb_ground_plane"),pcb_ground_plane_id:Io("pcb_ground_plane"),source_pcb_ground_plane_id:B(),source_net_id:B(),pcb_group_id:B().optional(),subcircuit_id:B().optional()}).describe("Defines a ground plane on the PCB"),can=Ne({type:Ce("pcb_ground_plane_region"),pcb_ground_plane_region_id:Io("pcb_ground_plane_region"),pcb_ground_plane_id:B(),pcb_group_id:B().optional(),subcircuit_id:B().optional(),layer:Dh,points:Ct(au)}).describe("Defines a polygon region of a ground plane"),lan=Ne({type:Ce("pcb_thermal_spoke"),pcb_thermal_spoke_id:Io("pcb_thermal_spoke"),pcb_ground_plane_id:B(),shape:B(),spoke_count:Ue(),spoke_thickness:Di,spoke_inner_diameter:Di,spoke_outer_diameter:Di,pcb_plated_hole_id:B().optional(),subcircuit_id:B().optional()}).describe("Pattern for connecting a ground plane to a plated hole"),b0e=Ne({type:Ce("pcb_copper_pour"),pcb_copper_pour_id:Io("pcb_copper_pour"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),layer:Dh,source_net_id:B().optional()}),uan=b0e.extend({shape:Ce("rect"),center:au,width:_t,height:_t,rotation:n3.optional()}),dan=b0e.extend({shape:Ce("brep"),brep_shape:isn}),han=b0e.extend({shape:Ce("polygon"),points:Ct(au)}),pan=uy("shape",[uan,dan,han]).describe("Defines a copper pour on the PCB."),fan=Ne({type:Ce("pcb_component_outside_board_error"),pcb_component_outside_board_error_id:Io("pcb_component_outside_board_error"),error_type:Ce("pcb_component_outside_board_error").default("pcb_component_outside_board_error"),message:B(),pcb_component_id:B(),pcb_board_id:B(),component_center:au,component_bounds:Ne({min_x:Ue(),max_x:Ue(),min_y:Ue(),max_y:Ue()}),subcircuit_id:B().optional(),source_component_id:B().optional()}).describe("Error emitted when a PCB component is placed outside the board boundaries"),man=Ne({type:Ce("cad_component"),cad_component_id:B(),pcb_component_id:B(),source_component_id:B(),position:f0e,rotation:f0e.optional(),size:f0e.optional(),layer:Dh.optional(),subcircuit_id:B().optional(),footprinter_string:B().optional(),model_obj_url:B().optional(),model_stl_url:B().optional(),model_3mf_url:B().optional(),model_gltf_url:B().optional(),model_glb_url:B().optional(),model_step_url:B().optional(),model_wrl_url:B().optional(),model_unit_to_mm_scale_factor:Ue().optional(),model_jscad:jd().optional()}).describe("Defines a component on the PCB"),_an=dn(["sinewave","square","triangle","sawtooth"]),yan=oi([B(),Ue()]).transform(t=>typeof t=="string"?t.endsWith("%")?parseFloat(t.slice(0,-1))/100:parseFloat(t):t).pipe(Ue().min(0,"Duty cycle must be non-negative").max(1,"Duty cycle cannot be greater than 100%")),gan=Ne({type:Ce("simulation_voltage_source"),simulation_voltage_source_id:Io("simulation_voltage_source"),is_dc_source:Ce(!0).optional().default(!0),positive_source_port_id:B().optional(),negative_source_port_id:B().optional(),positive_source_net_id:B().optional(),negative_source_net_id:B().optional(),voltage:FA}).describe("Defines a DC voltage source for simulation"),ban=Ne({type:Ce("simulation_voltage_source"),simulation_voltage_source_id:Io("simulation_voltage_source"),is_dc_source:Ce(!1),terminal1_source_port_id:B().optional(),terminal2_source_port_id:B().optional(),terminal1_source_net_id:B().optional(),terminal2_source_net_id:B().optional(),voltage:FA.optional(),frequency:BYe.optional(),peak_to_peak_voltage:FA.optional(),wave_shape:_an.optional(),phase:n3.optional(),duty_cycle:yan.optional()}).describe("Defines an AC voltage source for simulation"),xan=oi([gan,ban]).describe("Defines a voltage source for simulation");oi([Mon,Ton,Eon,Con,Aon,VYe,$Ye,_0e,HYe,jYe,GYe,YYe,qYe,ZYe,KYe,QYe,nqe,JYe,eqe,tqe,WYe,XYe,Ron,Ion,iqe,rqe,oqe,ssn,asn,tan,nan,oan,psn,Zsn,fsn,Csn,Nsn,zsn,vsn,Asn,Fsn,ian,Usn,$sn,jsn,Hsn,Vsn,Gsn,Ysn,ksn,Osn,Bsn,Lsn,Dsn,Xsn,qsn,ran,Wsn,san,ean,aan,can,lan,pan,fan,Non,jon,Bon,Fon,Hon,Uon,kon,Gon,Yon,Von,Zon,Kon,Qon,Jon,esn,tsn,man,xan]);var van=Object.defineProperty,wan=(t,e)=>{for(var n in e)van(t,n,{get:e[n],enumerable:!0})},i3={};wan(i3,{axial:()=>wcn,bga:()=>Oan,breakoutheaders:()=>Ncn,cap:()=>Ran,dfn:()=>icn,diode:()=>Can,dip:()=>Tan,electrolytic:()=>fdn,hc49:()=>Ocn,jst:()=>Fun,led:()=>Pan,lqfp:()=>Pcn,m2host:()=>Idn,melf:()=>qln,micromelf:()=>Kln,minimelf:()=>Bln,mlp:()=>jan,ms012:()=>ucn,ms013:()=>hcn,msop:()=>Xun,pad:()=>Lcn,pinrow:()=>scn,platedhole:()=>Mdn,potentiometer:()=>ddn,pushbutton:()=>Ecn,qfn:()=>Uan,qfp:()=>$an,quad:()=>II,res:()=>Ian,sma:()=>tun,smb:()=>lun,smbf:()=>_dn,smc:()=>pun,smf:()=>oun,smtpad:()=>Edn,sod110:()=>Uun,sod123:()=>gcn,sod123f:()=>yln,sod123fl:()=>vln,sod123w:()=>Kcn,sod128:()=>Rln,sod323:()=>tln,sod323f:()=>pln,sod323fl:()=>edn,sod323w:()=>Zun,sod523:()=>$cn,sod723:()=>Tln,sod80:()=>qcn,sod882:()=>lln,sod882d:()=>Hln,sod923:()=>oln,soic:()=>Dan,solderjumper:()=>odn,son:()=>rdn,sop8:()=>Gcn,sot:()=>Cdn,sot223:()=>yun,sot23:()=>Zan,sot23w:()=>Mun,sot25:()=>ecn,sot323:()=>xdn,sot363:()=>Xan,sot457:()=>cdn,sot563:()=>ccn,sot723:()=>fcn,sot89:()=>Lln,ssop:()=>Van,stampboard:()=>Mcn,stampreceiver:()=>Rcn,to220:()=>zln,to92:()=>Bcn,to92s:()=>Nun,tssop:()=>Yan,vssop:()=>Gun});var zo=(t,e,n)=>({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:"silkscreen_text_1",font:"tscircuit2024",font_size:n,pcb_component_id:"pcb_component_1",text:"{REF}",layer:"top",anchor_position:{x:t,y:e},anchor_alignment:"center"}),Aa=(t,e,n,i,r)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circle",x:e,y:n,hole_diameter:dh(i),outer_diameter:dh(r),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()]}),uqe=Array.from({length:9},(t,e)=>Math.cos(e/8*Math.PI-Math.PI)).map(t=>({x:t,y:-Math.sqrt(1-t**2)}));function Y4(t){return typeof t=="string"?t.trim().toLowerCase().endsWith("mil")?parseFloat(t)*.0254:parseFloat(t):Number(t)}var J$=oi([B(),Ue()]).transform(t=>Y4(t)),San=t=>Ne({fn:B(),num_pins:Ue().optional().default(6),wide:bt().optional(),narrow:bt().optional(),w:J$.optional(),p:J$.default(t.p??"2.54mm"),id:J$.optional(),od:J$.optional()}).transform(e=>(!e.id&&!e.od?Math.abs(e.p-1.27)<.01?(e.id=Y4("0.55mm"),e.od=Y4("0.95mm")):(e.id=Y4("1.0mm"),e.od=Y4("1.5mm")):e.id?e.od||(e.od=e.id*(1.5/1)):e.id=e.od*(1/1.5),e.w||(e.wide?e.w=Y4("600mil"):e.narrow?e.w=Y4("300mil"):e.w=Y4(t.w??"300mil")),e)),Ean=San({}),dqe=(t,e,n,i)=>{const r=t/2,o=e<=r,s=r-1,a=i,c=a*s;return o?{x:-n/2,y:c/2-(e-1)*a}:{x:n/2,y:-c/2+(e-r-1)*a}},Tan=t=>{const e=Ean.parse(t),n=[];for(let l=0;l<e.num_pins;l++){const{x:u,y:d}=dqe(e.num_pins,l+1,e.w,e.p??2.54);n.push(Aa(l+1,u,d,e.id??"0.8mm",e.od??"1mm"))}(e.num_pins/2-1)*e.p+e.od;const r=e.w-e.od-1,o=(e.num_pins/2-1)*e.p+e.od+.4,s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-r/2,y:-o/2},{x:-r/2,y:o/2},...uqe.map(({x:l,y:u})=>({x:l*r/6,y:u*r/6+o/2})),{x:r/2,y:o/2},{x:r/2,y:-o/2},{x:-r/2,y:-o/2}],type:"pcb_silkscreen_path",stroke_width:.1},a=[];for(let l=0;l<e.num_pins;l++){const u=l<e.num_pins/2,d=.6,{y:h}=dqe(e.num_pins,l+1,e.w,e.p??2.54),f=u?-e.w/2-e.od/2-d:e.w/2+e.od/2+d,m=h;a.push({type:"pcb_fabrication_note_text",pcb_fabrication_note_text_id:`pin_${l+1}`,layer:"top",pcb_component_id:`pin_${l+1}`,text:`{pin${l+1}}`,anchor_position:{x:f,y:m},font_size:.3,font:"tscircuit2024",anchor_alignment:"top_left"})}const c=zo(0,o/2+.5,.4);return{circuitJson:[...n,s,c,...a],parameters:e}},Dr=(t,e,n,i,r)=>({type:"pcb_smtpad",x:e,y:n,width:i,height:r,layer:"top",shape:"rect",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(o=>o.toString()):[t.toString()]}),hqe=[{imperial:"01005",metric:"0402",p_mm_min:.5,pw_mm_min:.4,ph_mm_min:.3,w_mm_min:.58,h_mm_min:.21},{imperial:"0504",metric:"1310",p_mm_min:1.1,pw_mm_min:.65,ph_mm_min:1.3,w_mm_min:.58,h_mm_min:.21},{imperial:"1812",metric:"4532",p_mm_min:4.275,pw_mm_min:1.125,ph_mm_min:3.4,w_mm_min:5.4,h_mm_min:3.4},{imperial:"0201",metric:"0603",p_mm_min:.66,pw_mm_min:.46,ph_mm_min:.4,w_mm_min:.9,h_mm_min:.3},{imperial:"0402",metric:"1005",p_mm_min:1.02,pw_mm_min:.54,ph_mm_min:.64,w_mm_min:1.56,h_mm_min:.64},{imperial:"0603",metric:"1608",p_mm_min:1.65,pw_mm_min:.8,ph_mm_min:.95,w_mm_min:2.45,h_mm_min:.95},{imperial:"0805",metric:"2012",p_mm_min:1.825,pw_mm_min:1.025,ph_mm_min:1.4,w_mm_min:2.8499999999999996,h_mm_min:1.4},{imperial:"1206",metric:"3216",p_mm_min:2.925,pw_mm_min:1.125,ph_mm_min:1.75,w_mm_min:4.05,h_mm_min:1.75},{imperial:"1210",metric:"3225",p_mm_min:2.925,pw_mm_min:1.125,ph_mm_min:2.65,w_mm_min:4.05,h_mm_min:2.65},{imperial:"2010",metric:"5025",p_mm_min:4.625,pw_mm_min:1.225,ph_mm_min:2.65,w_mm_min:5.85,h_mm_min:2.65},{imperial:"2512",metric:"6332",p_mm_min:5.925,pw_mm_min:1.225,ph_mm_min:3.35,w_mm_min:7.15,h_mm_min:3.35}],Man=Object.fromEntries(hqe.map(t=>[t.metric,t])),Aan=Object.fromEntries(hqe.map(t=>[t.imperial,t]));Ne({tht:bt(),p:_t.optional(),pw:_t.optional(),ph:_t.optional(),metric:Di.optional(),imperial:Di.optional(),w:_t.optional(),h:_t.optional(),textbottom:bt().optional()});var ej=t=>{let{tht:e,p:n,pw:i,ph:r,metric:o,imperial:s,w:a,h:c,textbottom:l}=t;if(typeof a=="string"&&(a=RI(a)),typeof c=="string"&&(c=RI(c)),typeof n=="string"&&(n=RI(n)),typeof i=="string"&&(i=RI(i)),typeof r=="string"&&(r=RI(r)),c!==void 0&&a!==void 0&&c>a)throw new Error("height cannot be greater than width (rotated footprint not yet implemented)");let u;if(o&&(u=Man[o]),s&&(u=Aan[s]),u&&(a=u.w_mm_min,c=u.h_mm_min,n=u.p_mm_min,i=u.pw_mm_min,r=u.ph_mm_min),n===void 0||i===void 0||r===void 0)throw new Error("Could not determine required pad dimensions (p, pw, ph)");const d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:n/2,y:r/2+.4},{x:-n/2-i/2-.2,y:r/2+.4},{x:-n/2-i/2-.2,y:-r/2-.4},{x:n/2,y:-r/2-.4}],stroke_width:.1,pcb_silkscreen_path_id:""},h=l?-r/2-.9:r/2+.9,f=zo(0,h,.2);return e?[Aa(1,-n/2,0,i,i*1/.8),Aa(2,n/2,0,i,i*1/.8),d,f]:[Dr(["1","left"],-n/2,0,i,r),Dr(["2","right"],n/2,0,i,r),d,f]},Can=t=>({circuitJson:ej(t),parameters:t}),Ran=t=>({circuitJson:ej(t),parameters:t}),Pan=t=>({circuitJson:ej(t),parameters:t}),Ian=t=>({circuitJson:ej(t),parameters:t}),pqe=(t,{x:e,y:n,radius:i})=>({type:"pcb_smtpad",x:e,y:n,radius:i,layer:"top",shape:"circle",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(r=>r.toString()):[t.toString()]}),fqe="ABCDEFGHIJKLMNOPQRSTUVWXYZ",mqe=B().transform(t=>{const[e,n]=t.split(/[x ]/);return{x:parseFloat(e),y:parseFloat(n)}}).pipe(Ne({x:Ue(),y:Ue()})),Nan=B().or(Ct(jd())).transform(t=>Array.isArray(t)?t:(t.startsWith("(")&&t.endsWith(")")&&(t=t.slice(1,-1)),t.split(",").map(e=>{const n=Number(e);return isNaN(n)?e:n}))).pipe(Ct(B().or(Ue()))),kan=Ne({fn:B(),num_pins:Ue().optional().default(64),grid:mqe.optional(),p:Di.default("0.8mm"),w:_t.optional(),h:_t.optional(),ball:_t.optional().describe("ball diameter"),pad:_t.optional().describe("pad width/height"),circularpads:bt().optional().describe("use circular pads"),tlorigin:bt().optional(),blorigin:bt().optional(),trorigin:bt().optional(),brorigin:bt().optional(),missing:Nan.default([])}).transform(t=>{let e="tl";if(t.blorigin&&(e="bl"),t.trorigin&&(e="tr"),t.brorigin&&(e="br"),!t.grid){const i=Math.ceil(Math.sqrt(t.num_pins));t.grid={x:i,y:i}}return t.missing&&(t.missing=t.missing.map(i=>{if(typeof i=="number")return i;if(i==="center")return"center";if(i==="topleft")return"topleft";const r=i.match(/([A-Z]+)(\d+)/);if(!r)return i;const o=fqe.indexOf(r[1]),s=Number.parseInt(r[2])-1;return o*t.grid.x+s+1})),{...t,origin:e}}),Oan=t=>{const e=kan.parse(t);let{num_pins:n,grid:i,p:r,w:o,h:s,ball:a,pad:c,missing:l}=e;a??=.75/1.27*r,c??=a*.8;const u=[],d=(l??[]).filter(N=>typeof N=="number"),h=i.x*i.y-n;if(l.length===0&&h>0&&(Math.sqrt(h)%1===0?l.push("center"):h===1&&l.push("topleft")),l?.includes("center")){const N=Math.floor(Math.sqrt(h)),R=Math.floor((i.x-N)/2),P=Math.floor((i.y-N)/2);for(let M=P;M<P+N;M++)for(let I=R;I<R+N;I++)d.push(M*i.x+I+1)}l?.includes("topleft")&&d.push(1);const f=new Set(d);let m=0;for(let N=0;N<i.y;N++)for(let R=0;R<i.x;R++){const P=(R-(i.x-1)/2)*r,M=(N-(i.y-1)/2)*r;let I=R,A=N;switch(e.origin){case"bl":I=R,A=i.y-1-N;break;case"br":I=i.x-1-R,A=i.y-1-N;break;case"tr":I=i.x-1-R,A=N;break}let $=A*i.x+I+1;if(f.has($)){m++;continue}$-=m;const k=[$,`${fqe[A]}${I+1}`];u.push(e.circularpads?pqe(k,{x:P,y:M,radius:c/2}):Dr(k,P,M,c,c))}const y=zo(0,i.y*r/2,.2),g=r/6;let b;const v=i.x*r/2,w=i.y*r/2;switch(e.origin){case"bl":b=[{x:-v,y:-w},{x:-v,y:-w-g},{x:-v-g,y:-w},{x:-v,y:-w}];break;case"br":b=[{x:v,y:-w},{x:v,y:-w-g},{x:v+g,y:-w},{x:v,y:-w}];break;case"tr":b=[{x:v,y:w},{x:v,y:w+g},{x:v+g,y:w},{x:v,y:w}];break;case"tl":default:b=[{x:-v,y:w},{x:-v,y:w+g},{x:-v-g,y:w},{x:-v,y:w}];break}const T={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_marker",route:b,stroke_width:.05};return{circuitJson:[...u,y,T],parameters:e}},tj=(t,e,n,i,r)=>({type:"pcb_smtpad",x:e,y:n,width:i,height:r,radius:r/2,layer:"top",shape:"pill",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(o=>o.toString()):[t.toString()]}),_5=t=>Ne({fn:B(),num_pins:Ue().optional().default(8),w:_t.default(_t.parse(t.w??"5.3mm")),p:_t.default(_t.parse(t.p??"1.27mm")),pw:_t.default(_t.parse(t.pw??"0.6mm")),pl:_t.default(_t.parse(t.pl??"1.0mm")),legsoutside:bt().optional().default(t.legsoutside??!1),pillpads:bt().optional().default(t.pillpads??!1)}).transform(e=>(!e.pw&&!e.pl?(e.pw=_t.parse("0.6mm"),e.pl=_t.parse("1.0mm")):e.pw?e.pl||(e.pl=e.pw*(1/.6)):e.pw=e.pl*(.6/1),e)),Lan=_5({}),x0e=t=>{t.widthincludeslegs!==void 0&&(t.legsoutside=!t.widthincludeslegs);const{num_pins:e,pn:n,w:i,p:r,pl:o,legsoutside:s}=t,a=e/2,c=n<=a,l=a-1,u=r,d=u*l,h=s?o/2:-o/2;return c?{x:-i/2-h,y:d/2-(n-1)*u}:{x:i/2+h,y:-d/2+(n-a-1)*u}},Dan=t=>{const e=Lan.parse(t);return{circuitJson:r3(e),parameters:e}},r3=t=>{const e=[];for(let a=0;a<t.num_pins;a++){const{x:c,y:l}=x0e({num_pins:t.num_pins,pn:a+1,w:t.w,p:t.p,pl:t.pl,legsoutside:t.legsoutside});t.pillpads?e.push(tj(a+1,c,l,t.pl,t.pw)):e.push(Dr(a+1,c,l,t.pl,t.pw))}const n=Math.min(1,t.p/2),i=t.w-(t.legsoutside?0:t.pl*2)-.2,r=(t.num_pins/2-1)*t.p+t.pw+n,o=zo(0,r/2+.4,r/12),s={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",stroke_width:.1,route:[{x:-i/2,y:-r/2},{x:-i/2,y:r/2},...uqe.map(({x:a,y:c})=>({x:a*i/6,y:c*i/6+r/2})),{x:i/2,y:r/2},{x:i/2,y:-r/2},{x:-i/2,y:-r/2}]};return[...e,s,o]},_qe=dn(["leftside","topside","rightside","bottomside","toppin","bottompin","leftpin","rightpin"]),zan=({num_pins:t,cw:e,ccw:n,startingpin:i})=>{const r=[],o=t/4;let s=1;const a={};for(const c of i??[])a[c]=!0;!a.leftside&&!a.topside&&!a.rightside&&!a.bottomside&&(a.leftside=!0),!a.bottompin&&!a.leftpin&&!a.rightpin&&!a.toppin&&(a.leftside?a.toppin=!0:a.topside?a.rightpin=!0:a.rightside?a.bottompin=!0:a.bottomside&&(a.leftpin=!0)),a.leftside&&a.toppin?s=1:a.leftside&&a.bottompin?s=o:a.bottomside&&a.leftpin?s=o+1:a.bottomside&&a.rightpin?s=o*2:a.rightside&&a.bottompin?s=o*2+1:a.rightside&&a.toppin?s=o*3:a.topside&&a.rightpin?s=o*3+1:a.topside&&a.leftpin&&(s=o*4),r.push(-1);for(let c=0;c<t;c++)r[s]=c+1,n||!e?(s++,s>t&&(s=1)):(s--,s<1&&(s=t));return r},v0e=Ne({fn:B(),cc:bt().default(!0).optional(),ccw:bt().default(!0).optional(),startingpin:B().or(Ct(_qe)).transform(t=>typeof t=="string"?t.slice(1,-1).split(","):t).pipe(Ct(_qe)).optional(),num_pins:Ue().optional().default(64),w:_t.optional(),h:_t.optional(),p:_t.default(_t.parse("0.5mm")),pw:_t.optional(),pl:_t.optional(),thermalpad:oi([Ce(!0),mqe]).optional(),legsoutside:bt().default(!1)}),w0e=t=>{t.w&&!t.h?t.h=t.w:!t.w&&t.h&&(t.w=t.h);const e=t.num_pins/4;if(!t.p&&!t.pw&&!t.pl&&t.w){const n=e+4;t.p=t.w/n}return!t.p&&t.w&&t.h&&t.pw&&t.pl&&(t.p=(t.w-t.pl*2)/(e-1)),!t.w&&!t.h&&t.p&&(t.w=t.p*(e+4),t.h=t.w),t.p&&!t.pw&&!t.pl?(t.pw=t.p/2,t.pl=t.p/2):t.pw?t.pl||(t.pl=t.pw*(1/.6)):t.pw=t.pl*(.6/1),t},yqe=v0e.transform(w0e),Fan=["left","bottom","right","top"],Ban=t=>{const{pin_count:e,pn:n,w:i,h:r,p:o,pl:s,legsoutside:a}=t,c=e/4,l=Fan[Math.floor((n-1)/c)],u=(n-1)%c,d=o*(c-1),h=o*(c-1),f=a?s/2:-s/2;switch(l){case"left":return{x:-i/2-f,y:h/2-u*o,o:"vert"};case"bottom":return{x:-d/2+u*o,y:-r/2-f,o:"horz"};case"right":return{x:i/2+f,y:-h/2+u*o,o:"vert"};case"top":return{x:d/2-u*o,y:r/2+f,o:"horz"};default:throw new Error("Invalid pin number")}},II=t=>{const e=yqe.parse(t),n=[],i=zan(e),r=e.num_pins/4;for(let a=0;a<e.num_pins;a++){const{x:c,y:l,o:u}=Ban({pin_count:e.num_pins,pn:a+1,w:e.w,h:e.h,p:e.p??.5,pl:e.pl,legsoutside:e.legsoutside});let d=e.pw,h=e.pl;u==="vert"&&([d,h]=[h,d]);const f=i[a+1];n.push(Dr(f,c,l,d,h))}if(e.thermalpad)if(typeof e.thermalpad=="boolean"){const a=e.p*(r-1)+e.pw,c=e.p*(r-1)+e.pw;n.push(Dr(["thermalpad"],0,0,a,c))}else n.push(Dr(["thermalpad"],0,0,e.thermalpad.x,e.thermalpad.y));const o=[];for(const[a,c,l]of[["top-left",-1,1],["bottom-left",-1,-1],["bottom-right",1,-1],["top-right",1,1]]){const u=e.w/2*c,d=e.h/2*l;let h="none",f=u,m=d;const y=e.pw*2;i[1]===1&&a==="top-left"?h="in1":i[r*4]===1&&a==="top-left"||i[r*3+1]===1&&a==="top-right"?h="in2":i[r*3]===1&&a==="top-right"||i[r]===1&&a==="bottom-left"?h="in1":i[r+1]===1&&a==="bottom-left"?h="in2":i[r*2]===1&&a==="bottom-right"?h="in1":i[r*2+1]===1&&a==="bottom-right"&&(h="in2");const g=h==="in1"?1:-1;if(e.legsoutside){const b=h==="in1"?e.pl/2:e.pw/2,v=h==="in1"?e.pw/2:e.pl/2;f+=b*c*g,m-=v*l*g}(h==="none"||e.legsoutside)&&o.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${a}`,route:[{x:u-y*c,y:d},{x:u,y:d},{x:u,y:d-y*l}],type:"pcb_silkscreen_path",stroke_width:.1}),(h==="in1"||h==="in2")&&!e.legsoutside&&o.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${a}_1`,route:[{x:u-y*c,y:d},{x:u-y*c/2,y:d}],type:"pcb_silkscreen_path",stroke_width:0},{layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${a}_2`,route:[{x:u,y:d-y*l/2},{x:u,y:d-y*l}],type:"pcb_silkscreen_path",stroke_width:.1}),(h==="in1"||h==="in2")&&o.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${a}_3`,route:[{x:f-.2*-c,y:m+.2*g},{x:f,y:m},{x:f+.2*g*-c,y:m+.2},{x:f-.2*-c,y:m+.2*g}],type:"pcb_silkscreen_path",stroke_width:.1})}const s=zo(0,e.h/2+(e.legsoutside?e.pl*1.2:.5),.3);return{circuitJson:[...n,...o,s],parameters:e}};v0e.extend({}).transform(w0e);var Uan=t=>(t.legsoutside=!1,II(t)),$an=t=>{t.legsoutside=!0;const e=yqe.parse(t);if(!t.p)switch(t.num_pins){case 44:case 64:t.p=.8;break;case 52:t.w===14?t.p=1:t.p=.65;break;case 208:t.p=.5;break}if(!t.pl)switch(t.num_pins){case 44:case 52:case 64:t.pl=2.25;break;case 208:t.pl=1.65;break;default:t.pl=e.pl*4;break}if(!t.pw)switch(t.num_pins){case 44:case 64:t.pw=.5;break;case 52:t.w===14?t.pw=.45:t.pw=.55;break;case 208:t.pw=.3;break;default:t.pw=e.pw;break}return II(t)};v0e.extend({}).transform(w0e);var jan=t=>(t.legsoutside=!1,t.thermalpad===void 0&&(t.thermalpad=!0),II(t)),Han=_5({w:"3.9mm",p:"1.27mm"}),Van=t=>{const e=Han.parse(t);return{circuitJson:r3(e),parameters:e}},Gan=_5({w:"7.1mm",p:"0.65mm",pl:"1.35mm",pw:"0.40mm",legsoutside:!0}),Yan=t=>{const e=Gan.parse(t);return{circuitJson:r3(e),parameters:e}},qan=_5({}),Xan=t=>{const e=qan.parse({fn:"sot363",num_pins:6,w:1.94,p:.65,pw:.3,pl:.7,legoutside:!0});return{circuitJson:r3(e),parameters:e}},gqe=Ne({fn:B(),num_pins:Ue().default(3),w:B().default("1.92mm"),h:B().default("2.74mm"),pl:B().default("0.8mm"),pw:B().default("0.764mm"),p:B().default("0.95mm"),string:B().optional()}),Wan=_5({p:"0.95mm",w:"1.6mm",legsoutside:!0}),Zan=t=>{const e=t.string?.match(/^sot23_(\d+)/),n=e?Number.parseInt(e[1],10):3;if(n===6||n===8){const r=Wan.parse({...t,num_pins:n});return{circuitJson:r3(r),parameters:r}}const i=gqe.parse({...t,num_pins:n});if(i.num_pins===3)return{circuitJson:Qan(i),parameters:i};if(i.num_pins===5)return{circuitJson:xqe(i),parameters:i};throw new Error("Invalid number of pins")},Kan=t=>{const{pn:e}=t;return e===1?{x:-1.7,y:0}:e===2?{x:1.7,y:-.95}:{x:1.7,y:.95}},Qan=t=>{const e=[];for(let i=0;i<t.num_pins;i++){const{x:r,y:o}=Kan({num_pins:t.num_pins,pn:i+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl)});e.push(Dr(i+1,r,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=zo(0,Number.parseInt(t.h),.3);return[...e,n]},bqe=t=>{const{p:e,h:n,pn:i}=t;if(i===1)return{x:-n/2-.5,y:e};if(i===2)return{x:-n/2-.5,y:0};if(i===3)return{x:-n/2-.5,y:-e};if(i===4)return{x:n/2+.5,y:-e};if(i===5)return{x:n/2+.5,y:e};throw new Error("Invalid pin number")},xqe=t=>{const e=[];for(let d=1;d<=t.num_pins;d++){const{x:h,y:f}=bqe({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:d});e.push(Dr(d,h,f,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=(t.num_pins+1)/2*Number.parseFloat(t.p),i=Number.parseFloat(t.h),r={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-n/3,y:i/2+Number.parseFloat(t.p)/1.3},{x:n/3,y:i/2+Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-n/3,y:-i/2-Number.parseFloat(t.p)/1.3},{x:n/3,y:-i/2-Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},s=zo(0,i+.3,.3),a=bqe({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:1});a.x=a.x-Number.parseFloat(t.pw)*1.5;const c=.7,l=.3,u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:a.x+c/2,y:a.y},{x:a.x-c/2,y:a.y+l/2},{x:a.x-c/2,y:a.y-l/2},{x:a.x+c/2,y:a.y}],stroke_width:.05};return[...e,s,r,o,u]},Jan=gqe.extend({}),ecn=t=>{const e=Jan.parse({...t,num_pins:5});return{circuitJson:xqe(e),parameters:e}},tcn=[{name:"top-left",dx:-1,dy:1},{name:"top-right",dx:1,dy:1},{name:"bottom-left",dx:-1,dy:-1},{name:"bottom-right",dx:1,dy:-1}],ncn=_5({}),icn=t=>{const e=ncn.parse(t),n=[];for(let d=0;d<e.num_pins;d++){const{x:h,y:f}=x0e({num_pins:e.num_pins,pn:d+1,w:e.w,p:e.p??1.27,pl:e.pl,widthincludeslegs:!0});n.push(Dr(d+1,h,f,e.pl??"1mm",e.pw??"0.6mm"))}const i=Math.min(1,e.p/2),r=e.w+i,o=(e.num_pins/2-1)*e.p+e.pw+i,s=[];for(const d of tcn){const{dx:h,dy:f}=d;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",route:[{x:h*r/2-h*e.p,y:f*o/2},{x:h*r/2,y:f*o/2},{x:h*r/2,y:f*o/2-f*e.p}],type:"pcb_silkscreen_path",stroke_width:.1})}const a=e.p/4,c=-r/2-a/2,l=o/2-e.p/2;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:c,y:l},{x:c-a,y:l+a},{x:c-a,y:l-a},{x:c,y:l}],stroke_width:.1});const u=zo(0,o/2+.4,o/12);return{circuitJson:[...n,u,...s],parameters:e}},nj=(t,e,n,i,r,o)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circular_hole_with_rect_pad",x:e,y:n,hole_diameter:dh(i),hole_shape:"circle",pad_shape:"rect",rect_pad_width:dh(r),rect_pad_height:dh(o),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()]}),S0e=({fs:t,pn:e,anchor_x:n,anchor_y:i,textalign:r="center",orthogonal:o=!1,verticallyinverted:s=!1,layer:a="top"})=>{let c=0;o&&s?c=270:s?c=180:o?c=90:c=0;let l="center";return r==="left"&&(s?l="center_right":l="center_left"),r==="right"&&(s?l="center_left":l="center_right"),a==="bottom"&&(l==="center_left"?l="center_right":l==="center_right"&&(l="center_left")),{type:"pcb_silkscreen_text",pcb_silkscreen_text_id:"silkscreen_text_1",font:"tscircuit2024",font_size:t,pcb_component_id:"pcb_component_1",text:`{PIN${e}}`,layer:a,anchor_position:{x:n,y:i},anchor_alignment:l,ccw_rotation:c}};function rcn({pinlabeltextalignleft:t,pinlabeltextalignright:e,pinlabelorthogonal:n}){let i="top";return n?i="left":i="top",t&&(n?i="bottom":i="right"),e&&(n?i="top":i="left"),i}var ocn=Ne({fn:B(),num_pins:Ue().optional().default(6),rows:oi([B(),Ue()]).transform(t=>Number(t)).optional().default(1).describe("number of rows"),p:_t.default("0.1in").describe("pitch"),id:_t.default("1.0mm").describe("inner diameter"),od:_t.default("1.5mm").describe("outer diameter"),male:bt().optional().describe("for male pin headers"),female:bt().optional().describe("for female pin headers"),pinlabeltextalignleft:bt().optional().default(!1),pinlabeltextaligncenter:bt().optional().default(!1),pinlabeltextalignright:bt().optional().default(!1),pinlabelverticallyinverted:bt().optional().default(!1),pinlabelorthogonal:bt().optional().default(!1),nosquareplating:bt().optional().default(!1).describe("do not use rectangular pad for pin 1"),nopinlabels:bt().optional().default(!1).describe("omit silkscreen pin labels"),doublesidedpinlabel:bt().optional().default(!1).describe("add silkscreen pins in top and bottom layers"),bottomsidepinlabel:bt().optional().default(!1).describe("place the silkscreen reference text on the bottom layer instead of top")}).transform(t=>{const e=rcn(t);return{...t,pinlabelAnchorSide:e,male:t.male??!t.female,female:t.female??!1}}).superRefine((t,e)=>{t.male&&t.female&&e.addIssue({code:zi.custom,message:"'male' and 'female' cannot both be true; it should be male or female.",path:["male","female"]})}),scn=t=>{const e=ocn.parse(t),{p:n,id:i,od:r,rows:o,num_pins:s,pinlabelAnchorSide:a,pinlabelverticallyinverted:c,pinlabelorthogonal:l,pinlabeltextalignleft:u,pinlabeltextalignright:d,nopinlabels:h,doublesidedpinlabel:f,bottomsidepinlabel:m}=e;let y="center";u?y="left":d&&(y="right");const g=[],b=Math.ceil(s/o),v=-n,w=({xoff:M,yoff:I,od:A,anchorSide:$})=>{let k=0,V=0;const X=A*.75;switch($){case"right":k=X;break;case"top":V=X;break;case"bottom":V=-X;break;case"left":k=-X;break}return{anchor_x:M+k,anchor_y:I+V}},T=(M,I,A)=>{M===1&&!e.nosquareplating?g.push(nj(M,I,A,i,r,r)):g.push(Aa(M,I,A,i,r));const{anchor_x:$,anchor_y:k}=w({xoff:I,yoff:A,od:r,anchorSide:a});h||(m?g.push(S0e({fs:r/5,pn:M,anchor_x:$,anchor_y:k,textalign:y,orthogonal:l,verticallyinverted:c,layer:"bottom"})):g.push(S0e({fs:r/5,pn:M,anchor_x:$,anchor_y:k,textalign:y,orthogonal:l,verticallyinverted:c,layer:"top"})),f&&g.push(S0e({fs:r/5,pn:M,anchor_x:$,anchor_y:k,textalign:y,orthogonal:l,verticallyinverted:c,layer:"bottom"})))},N=new Set,R=o>2&&b>2;if(o===1){const M=-((s-1)/2)*n;for(let I=0;I<s;I++){const A=I+1,$=M+I*n,k=`${$},0`;if(N.has(k))throw new Error(`Overlap at ${k}`);N.add(k),T(A,$,0)}}else if(R){const M=-((b-1)/2)*n;let I=1;for(let A=0;A<o&&I<=s;A++)for(let $=0;$<b&&I<=s;$++){const k=M+$*n,V=A*v,X=`${k},${V}`;if(N.has(X))throw new Error(`Overlap at ${X}`);N.add(X),T(I++,k,V)}}else{const M=-((b-1)/2)*n;let I=1,A=0,$=o-1,k=0,V=b-1;for(;I<=s&&A<=$&&k<=V;){for(let X=A;X<=$&&I<=s;X++){const W=M+k*n,K=X*v,te=`${W},${K}`;if(N.has(te))throw new Error(`Overlap at ${te}`);N.add(te),T(I++,W,K)}k++;for(let X=k;X<=V&&I<=s;X++){const W=M+X*n,K=$*v,te=`${W},${K}`;if(N.has(te))throw new Error(`Overlap at ${te}`);N.add(te),T(I++,W,K)}if($--,k<=V){for(let X=$;X>=A&&I<=s;X--){const W=M+V*n,K=X*v,te=`${W},${K}`;if(N.has(te))throw new Error(`Overlap at ${te}`);N.add(te),T(I++,W,K)}V--}if(A<=$){for(let X=V;X>=k&&I<=s;X--){const W=M+X*n,K=A*v,te=`${W},${K}`;if(N.has(te))throw new Error(`Overlap at ${te}`);N.add(te),T(I++,W,K)}A++}}if(I-1<s)throw new Error(`Missing pins: assigned ${I-1}, expected ${s}`)}const P=zo(0,n,.5);return{circuitJson:[...g,P],parameters:e}},acn=_5({}),ccn=t=>{const e=acn.parse({fn:"sot563",num_pins:6,w:1.94,p:.5,pw:.3,pl:.67,legoutside:!0});return{circuitJson:r3(e),parameters:e}},lcn=_5({p:"1.27mm",w:"3.9mm",legsoutside:!0}),ucn=t=>{const e=lcn.parse({...t,num_pins:8});return{circuitJson:r3(e),parameters:e}},dcn=_5({p:"1.27mm",w:"7.5mm",legsoutside:!0}),hcn=t=>{const e=dcn.parse({...t,num_pins:16});return{circuitJson:r3(e),parameters:e}},pcn=Ne({fn:B(),num_pins:Ce(3).default(3),w:B().default("1.2mm"),h:B().default("1.2mm"),pl:B().default("0.3mm"),pw:B().default("0.32mm")}),fcn=t=>{const e=pcn.parse(t),n=_cn(e),i=zo(.4,_t.parse(e.h),.2);return{circuitJson:[...n,i],parameters:e}},mcn=t=>{const{pn:e}=t;return e===1?{x:0,y:0}:e===2?{x:1,y:-.4}:{x:1,y:.4}},_cn=t=>{const e=[];for(let n=0;n<3;n++){const{x:i,y:r}=mcn({num_pins:t.num_pins,pn:n+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl)});e.push(Dr(n+1,i,r,Number.parseFloat(t.pl),n!==0?Number.parseFloat(t.pw):.42))}return e},ycn=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("2.36mm"),h:B().default("1.22mm"),pl:B().default("0.9mm"),pw:B().default("0.9mm"),p:B().default("4.19mm")}),gcn=t=>{const e=ycn.parse(t),n=zo(0,_t.parse(e.h)/4+.4,.3);return{circuitJson:xcn(e).concat(n),parameters:e}},bcn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},xcn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=bcn({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},vcn=Ne({fn:B(),p:_t.optional().default("2.54mm"),id:_t.optional().default("0.7mm"),od:_t.optional().default("1mm")}),wcn=t=>{const e=vcn.parse(t),{p:n,id:i,od:r}=e,o=[Aa(1,-n/2,0,i,r),Aa(2,n/2,0,i,r)],s={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/2+r+i/2,y:0},{x:n/2-r-i/2,y:0}],stroke_width:.1,pcb_silkscreen_path_id:""},a=zo(0,n/4,.5);return{circuitJson:[...o,s,a],parameters:e}},ij=(t,e={})=>({type:"pcb_silkscreen_path",layer:e.layer||"top",pcb_component_id:e.pcb_component_id||"",pcb_silkscreen_path_id:e.pcb_silkscreen_path_id||"",route:t,stroke_width:e.stroke_width||.1}),Scn=Ne({fn:Ce("pushbutton"),w:_t.default(4.5),h:_t.default(6.5),id:_t.default(1),od:_t.default(1.2)}),Ecn=t=>{const e=Scn.parse(t),n=e.w,i=e.h,r=e.id,o=[Aa(1,-n/2,i/2,r,r*1.5),Aa(2,-n/2,-i/2,r,r*1.5),Aa(3,n/2,-i/2,r,r*1.5),Aa(4,n/2,i/2,r,r*1.5)],s=[ij([{x:-n/2,y:-i/2},{x:-n/2,y:i/2}]),ij([{x:n/2,y:-i/2},{x:n/2,y:i/2}]),ij([{x:-n/2,y:0},{x:-n/5,y:0},{x:n/5*1/Math.sqrt(2),y:i/8}]),ij([{x:n/2,y:0},{x:n/5,y:0}])],a=zo(0,i/2+.4,.5);return{circuitJson:[...o,...s,a],parameters:e}},vqe=Ne({fn:B(),w:_t.default("22.58mm"),h:_t.optional(),left:_t.optional().default(20),right:_t.optional().default(20),top:_t.optional().default(2),bottom:_t.optional().default(2),p:_t.default(_t.parse("2.54mm")),pw:_t.default(_t.parse("1.6mm")),pl:_t.default(_t.parse("2.4mm")),innerhole:bt().default(!1),innerholeedgedistance:_t.default(_t.parse("1.61mm")),silkscreenlabels:bt().default(!1),silkscreenlabelmargin:_t.default(_t.parse("0.1mm"))}),Tcn=t=>{const e=vqe.parse(t);return e.left&&e.right?Math.max(e.left,e.right)*e.p:e.left?e.left*e.p:e.right?e.right*e.p:51},rj=(t,e,n)=>{let i=[];return n==="right"&&(i=[{x:t+1/2,y:e},{x:t-1/2,y:e+.6/2},{x:t-1/2,y:e-.6/2},{x:t+1/2,y:e}]),n==="left"&&(i=[{x:t-1/2,y:e},{x:t+1/2,y:e+.6/2},{x:t+1/2,y:e-.6/2},{x:t-1/2,y:e}]),n==="top"&&(i=[{x:t,y:e+1/2},{x:t-.6/2,y:e-1/2},{x:t+.6/2,y:e-1/2},{x:t,y:e+1/2}]),n==="bottom"&&(i=[{x:t,y:e-1/2},{x:t-.6/2,y:e+1/2},{x:t+.6/2,y:e+1/2},{x:t,y:e-1/2}]),i},Mcn=t=>{const e=vqe.parse(t),n=e.h??Tcn(e),i=[],r=[],o=[];let s=[];const a=1,c=a,l=e.left+e.right+(e.bottom??0)+(e.top??0),d=`pin${l}`.length*.7/2;if(e.right){const y=-((e.right-1)/2)*e.p;for(let g=0;g<e.right;g++){if(g===0&&!e.left&&!e.bottom&&!e.silkscreenlabels&&(s=rj(e.w/2-e.pl*1.4,y+g*e.p,"right")),i.push(Dr(g+1+e.left+(e.bottom??0),e.w/2-e.pl/2,y+g*e.p,e.pl,e.pw)),e.silkscreenlabels){const b=g+1+e.left+(e.bottom??0),v=`pin${b}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${b}`,pcb_component_id:"1",layer:"top",anchor_position:{x:e.w/2-e.pl-(d+e.silkscreenlabelmargin),y:y+g*e.p},text:v,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}e.innerhole&&(r.push(Aa(g+1+e.left+(e.bottom??0)+l,e.w/2,y+g*e.p,a,c)),r.push(Aa(g+1+e.left+(e.bottom??0)+l*2,e.w/2-e.innerholeedgedistance,y+g*e.p,a,c)))}}if(e.left){const y=(e.left-1)/2*e.p;for(let g=0;g<e.left;g++){if(g===0&&!e.silkscreenlabels&&(s=rj(-e.w/2+e.pl*1.4,y-g*e.p,"left")),i.push(Dr(g+1,-e.w/2+e.pl/2,y-g*e.p,e.pl,e.pw)),e.silkscreenlabels){const b=g+1,v=`pin${b}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${b}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-e.w/2+e.pl+(d+e.silkscreenlabelmargin),y:y-g*e.p},text:v,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}e.innerhole&&(r.push(Aa(g+1+l,-e.w/2,y-g*e.p,a,c)),r.push(Aa(g+1+l*2,-e.w/2+e.innerholeedgedistance,y-g*e.p,a,c)))}}if(e.top){const y=(e.top-1)/2*e.p;for(let g=0;g<e.top;g++){if(g===0&&!e.left&&!e.bottom&&!e.right&&!e.silkscreenlabels&&(s=rj(y-g*e.p,n/2-e.pl*1.4,"top")),i.push(Dr(g+1+e.left+e.right+(e.bottom??0),y-g*e.p,n/2-e.pl/2,e.pw,e.pl)),e.silkscreenlabels){const b=g+1+e.left+e.right+(e.bottom??0),v=`pin${b}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${b}`,pcb_component_id:"1",layer:"top",anchor_position:{x:y-g*e.p,y:n/2-e.pl-(d+e.silkscreenlabelmargin)},text:v,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:270})}e.innerhole&&(r.push(Aa(g+1+e.left+e.right+(e.bottom??0)+l,y-g*e.p,n/2,a,c)),r.push(Aa(g+1+e.left+e.right+(e.bottom??0)+l*2,y-g*e.p,n/2-e.innerholeedgedistance,a,c)))}}if(e.bottom){const y=-((e.bottom-1)/2)*e.p;for(let g=0;g<e.bottom;g++){if(g===0&&!e.left&&!e.silkscreenlabels&&(s=rj(y+g*e.p,-n/2+e.pl*1.4,"bottom")),i.push(Dr(g+1+e.left,y+g*e.p,-n/2+e.pl/2,e.pw,e.pl)),e.silkscreenlabels){const b=g+1+e.left,v=`pin${b}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${b}`,pcb_component_id:"1",layer:"top",anchor_position:{x:y+g*e.p,y:-n/2+e.pl+(d+e.silkscreenlabelmargin)},text:v,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:90})}e.innerhole&&(r.push(Aa(g+1+e.left+l,y+g*e.p,-n/2,a,c)),r.push(Aa(g+1+e.left+l*2,y+g*e.p,-n/2+e.innerholeedgedistance,a,c)))}}const h={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_triangle_1",pcb_component_id:"2",route:s,stroke_width:.1,layer:"top"},f={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-e.w/2,y:n/2},{x:e.w/2,y:n/2},{x:e.w/2,y:-n/2},{x:-e.w/2,y:-n/2},{x:-e.w/2,y:n/2}],stroke_width:.1,layer:"top"},m=zo(0,n/1.8,n/25);return{circuitJson:[...i,...r,...o,f,...e.silkscreenlabels?[]:[h],m],parameters:e}},wqe=Ne({fn:B(),w:_t.default("22.58mm"),h:_t.optional(),left:_t.optional().default(20),right:_t.optional().default(20),top:_t.optional().default(2),bottom:_t.optional().default(2),p:_t.default(_t.parse("2.54mm")),pw:_t.default(_t.parse("1.6mm")),pl:_t.default(_t.parse("3.2mm")),innerhole:bt().default(!1),innerholeedgedistance:_t.default(_t.parse("1.61mm"))}),Acn=t=>{const e=wqe.parse(t);return e.left&&e.right?Math.max(e.left,e.right)*e.p:e.left?e.left*e.p:e.right?e.right*e.p:51},Ccn=(t,e,n,i=1,r=.6)=>{const o=i/2,s=r/2;return{left:[{x:t+o,y:e},{x:t-o,y:e+s},{x:t-o,y:e-s},{x:t+o,y:e}],right:[{x:t-o,y:e},{x:t+o,y:e+s},{x:t+o,y:e-s},{x:t-o,y:e}],top:[{x:t,y:e-o},{x:t-s,y:e+o},{x:t+s,y:e+o},{x:t,y:e-o}],bottom:[{x:t,y:e+o},{x:t-s,y:e-o},{x:t+s,y:e-o},{x:t,y:e+o}]}[n]},Rcn=t=>{const e=wqe.parse(t),n=e.h??Acn(e),i=[],r=[],o=[],s=1,a=1.2,c=e.left+e.right+(e.bottom??0)+(e.top??0);let l=[],u=1;if(e.left){const m=(e.left-1)/2*e.p;for(let y=0;y<e.left;y++)y===0&&(l=Ccn(-e.w/2-e.pl/2,m-y*e.p,"left")),i.push(Dr(u,-e.w/2+e.pl/2,m-y*e.p,e.pl,e.pw)),r.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${u}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-e.w/2+e.pl/2-4.5,y:m-y*e.p},text:`pin${u}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),u++,e.innerhole&&o.push(Aa(u+c,-e.w/2+e.innerholeedgedistance,m-y*e.p,s,a))}if(e.bottom){const m=(e.bottom-1)/2*e.p;for(let y=e.bottom-1;y>=0;y--)i.push(Dr(u,m-y*e.p,-n/2+e.pl/2,e.pw,e.pl)),r.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${u}`,pcb_component_id:"1",layer:"top",anchor_position:{x:m-y*e.p,y:-n/2+e.pl/2-3.2},text:`pin${u}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),u++,e.innerhole&&o.push(Aa(u+c,m-y*e.p,-n/2+e.innerholeedgedistance,s,a))}if(e.right){const m=-((e.right-1)/2)*e.p;for(let y=0;y<e.right;y++)i.push(Dr(u,e.w/2-e.pl/2,m+y*e.p,e.pl,e.pw)),r.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${u}`,pcb_component_id:"1",layer:"top",anchor_position:{x:e.w/2-e.pl/2+3.7,y:m+y*e.p},text:`pin${u}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),u++,e.innerhole&&o.push(Aa(u+c,e.w/2-e.innerholeedgedistance,m+y*e.p,s,a))}if(e.top){const m=-((e.top-1)/2)*e.p;for(let y=e.top-1;y>=0;y--)i.push(Dr(u,m+y*e.p,n/2-e.pl/2,e.pw,e.pl)),r.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${u}`,pcb_component_id:"1",layer:"top",anchor_position:{x:m+y*e.p,y:n/2-e.pl/2+3.2},text:`pin${u}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),u++,e.innerhole&&o.push(Aa(u+c,m+y*e.p,n/2-e.innerholeedgedistance,s,a))}const d={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"1",pcb_component_id:"1",layer:"top",route:l,stroke_width:.1},h={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-e.w/2-e.pl/3,y:n/2+e.pl/3},{x:e.w/2+e.pl/3,y:n/2+e.pl/3},{x:e.w/2+e.pl/3,y:-n/2-e.pl/3},{x:-e.w/2-e.pl/3,y:-n/2-e.pl/3},{x:-e.w/2-e.pl/3,y:n/2+e.pl/3}],stroke_width:.1,layer:"top"},f=zo(0,n/1.8,n/25);return{circuitJson:[...o,...i,...r,h,d,f],parameters:e}},Pcn=t=>(t.legsoutside=!0,II(t)),Sqe=Ne({fn:B(),w:_t.default("10mm"),h:_t.optional(),left:_t.optional().default(20),right:_t.optional().default(20),top:_t.optional().default(0),bottom:_t.optional().default(0),p:_t.default(_t.parse("2.54mm")),id:_t.optional().default(_t.parse("1mm")),od:_t.optional().default(_t.parse("1.5mm"))}),Icn=t=>{const e=Sqe.parse(t);return e.left&&e.right?Math.max(e.left,e.right)*e.p:e.left?e.left*e.p:e.right?e.right*e.p:51},oj=(t,e,n,i=1,r=.6)=>{const o=i/2,s=r/2;return{left:[{x:t+o,y:e},{x:t-o,y:e+s},{x:t-o,y:e-s},{x:t+o,y:e}],right:[{x:t-o,y:e},{x:t+o,y:e+s},{x:t+o,y:e-s},{x:t-o,y:e}],top:[{x:t,y:e-o},{x:t-s,y:e+o},{x:t+s,y:e+o},{x:t,y:e-o}],bottom:[{x:t,y:e+o},{x:t-s,y:e-o},{x:t+s,y:e-o},{x:t,y:e+o}]}[n]},Ncn=t=>{const e=Sqe.parse(t),n=e.h??Icn(e),i=[],r=e.id,o=e.od;let s=[];if(e.right){const u=-((e.right-1)/2)*e.p;for(let d=0;d<e.right;d++)d===0&&!e.left&&!e.bottom&&(s=oj(e.w/2+o*1.4,u+d*e.p,"right")),i.push(Aa(d+1+e.left+(e.bottom??0),e.w/2,u+d*e.p,r,o))}if(e.left){const u=-((e.left-1)/2)*e.p;for(let d=0;d<e.left;d++)d===e.left-1&&(s=oj(-e.w/2-o*1.4,u+d*e.p,"left")),i.push(Aa(d+1,-e.w/2,u+d*e.p,r,o))}if(e.top){const u=-((e.top-1)/2)*e.p;for(let d=0;d<e.top;d++)d===e.top-1&&!e.left&&!e.bottom&&!e.right&&(s=oj(u+d*e.p,n/2+o*1.4,"top")),i.push(Aa(d+1+e.right+(e.bottom??0)+e.left,u+d*e.p,n/2,r,o))}if(e.bottom){const u=-((e.bottom-1)/2)*e.p;for(let d=0;d<e.bottom;d++)d===0&&!e.left&&(s=oj(u+d*e.p,-n/2-o*1.4,"bottom")),i.push(Aa(d+1+e.left,u+d*e.p,-n/2,r,o))}const a={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"1",pcb_component_id:"1",layer:"top",route:s,stroke_width:.1},c={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-e.w/2-o,y:n/2+o},{x:e.w/2+o,y:n/2+o},{x:e.w/2+o,y:-n/2-o},{x:-e.w/2-o,y:-n/2-o},{x:-e.w/2-o,y:n/2+o}],stroke_width:.1,layer:"top"},l=zo(0,n/1.7,n/25);return{circuitJson:[...i,c,l,a],parameters:e}},Eqe=(t,e,n,i)=>Array.from({length:25},(r,o)=>{const s=o/24*Math.PI-Math.PI/2;return{x:t+(i==="right"?1:-1)*Math.cos(s)*n,y:e+Math.sin(s)*n}}),kcn=Ne({fn:B(),p:_t.optional().default("4.88mm"),id:_t.optional().default("0.6mm"),od:_t.optional().default("1.2mm"),w:_t.optional().default("5.6mm"),h:_t.optional().default("3.5mm")}),Ocn=t=>{const e=kcn.parse(t),{p:n,id:i,od:r,w:o,h:s}=e,a=s/2,c=[Aa(1,-n/2,0,i,r),Aa(2,n/2,0,i,r)],l=Eqe(-o/2,0,a,"left"),u=Eqe(o/2,0,a,"right"),d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[...l,...l.slice(1).reverse(),{x:-o/2,y:-s/2},{x:o/2,y:-s/2},...u,{x:o/2,y:s/2},{x:-o/2,y:s/2}],stroke_width:.1,pcb_silkscreen_path_id:""},h=zo(0,n/4,.5);return{circuitJson:[...c,d,h],parameters:e}};Ne({w:_t,h:_t});var Lcn=t=>{const{w:e,h:n}=t,i=dh(e),r=dh(n);return{circuitJson:[Dr(1,0,0,i,r),zo(0,r/2+.5,.2)],parameters:t}},Dcn=Ne({fn:B(),num_pins:oi([Ce(3),Ce(2)]).default(3),p:B().default("1.27mm"),id:B().default("0.72mm"),od:B().default("0.95mm"),w:B().default("4.5mm"),h:B().default("4.5mm"),inline:bt().default(!1),string:B().optional()}),zcn=(t,e,n)=>Array.from({length:25},(i,r)=>{const o=r/24*Math.PI;return{x:t+Math.cos(o)*n,y:e+Math.sin(o)*n}}),Fcn=t=>{const{p:e,id:n,od:i,h:r}=t,o=Number.parseFloat(r)/2,s=Number.parseFloat(e);return[Aa(1,-s,o-s,n,i),Aa(2,s,o-s,n,i)]},Bcn=t=>{const e=t.string?.match(/^to92_(\d+)/),n=e?Number.parseInt(e[1],10):3,i=Dcn.parse({...t,num_pins:n}),{p:r,id:o,od:s,w:a,h:c,inline:l}=i,u=Number.parseFloat(c)/2,d=Number.parseFloat(r);let h=[];if(i.num_pins===3)h=l?[Aa(1,-d,u-d,o,s),Aa(2,0,u-d,o,s),Aa(3,d,u-d,o,s)]:[Aa(1,0,u,o,s),Aa(2,-d,u-d,o,s),Aa(3,d,u-d,o,s)];else if(i.num_pins===2)h=Fcn(i);else throw new Error("Invalid number of pins for TO-92");const f=Number.parseFloat(a)/2,m=zcn(0,u,f),y={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[...m,{x:-f,y:0},{x:f,y:0},m[0]],stroke_width:.1,pcb_silkscreen_path_id:""},g=zo(0,u+1,.5);return{circuitJson:[...h,y,g],parameters:i}},Ucn=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("2.15mm"),h:B().default("1.20mm"),pl:B().default("0.5mm"),pw:B().default("0.6mm"),p:B().default("1.4mm")}),$cn=t=>{const e=Ucn.parse(t),n=zo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Hcn(e).concat(i,n),parameters:e}},jcn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Hcn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=jcn({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Vcn=_5({}),Gcn=t=>{const e=Vcn.parse(t),n=[];for(let s=0;s<e.num_pins;s++){const{x:a,y:c}=x0e({num_pins:e.num_pins,pn:s+1,w:e.w,p:e.p??1.27,pl:e.pl,widthincludeslegs:!0});n.push(Dr(s+1,a,c,e.pl??"1.5mm",e.pw??"0.6mm"))}const i=(e.num_pins/2-1)*e.p+e.pw,r=zo(0,i/2-.5,i/12),o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:-e.w/3,y:i/2+.2},{x:e.w/3,y:i/2+.2}],stroke_width:.1};return{circuitJson:[...n,r,o],parameters:e}},Ycn=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("5.0mm"),h:B().default("2.30mm"),pl:B().default("1.25mm"),pw:B().default("2mm"),p:B().default("3.75mm")}),qcn=t=>{const e=Ycn.parse(t),n=zo(0,_t.parse(e.h)/2+1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2+.5,y:_t.parse(e.h)/2+.5},{x:-_t.parse(e.w)/2-.5,y:_t.parse(e.h)/2+.5},{x:-_t.parse(e.w)/2-.5,y:-_t.parse(e.h)/2-.5},{x:_t.parse(e.p)/2+.5,y:-_t.parse(e.h)/2-.5}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Wcn(e).concat(i,n),parameters:e}},Xcn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Wcn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=Xcn({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Zcn=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("4.4mm"),h:B().default("2.1mm"),pl:B().default("1.2mm"),pw:B().default("1.2mm"),p:B().default("2.9mm")}),Kcn=t=>{const e=Zcn.parse(t),n=zo(0,_t.parse(e.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Jcn(e).concat(i,n),parameters:e}},Qcn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Jcn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=Qcn({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},eln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("3.30mm"),h:B().default("1.80mm"),pl:B().default("0.60mm"),pw:B().default("0.45mm"),p:B().default("2.1mm")}),tln=t=>{const e=eln.parse(t),n=zo(0,_t.parse(e.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:iln(e).concat(i,n),parameters:e}},nln=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},iln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=nln({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},rln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("1.4mm"),h:B().default("0.9mm"),pl:B().default("0.35mm"),pw:B().default("0.25mm"),p:B().default("1.2mm")}),oln=t=>{const e=rln.parse(t),n=zo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2+.15,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.4,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.4,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2+.15,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:aln(e).concat(i,n),parameters:e}},sln=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},aln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=sln({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},cln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("1.3mm"),h:B().default("0.9mm"),pl:B().default("0.4mm"),pw:B().default("0.7mm"),p:B().default("0.7mm")}),lln=t=>{const e=cln.parse(t),n=zo(0,_t.parse(e.h)+.1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2+.2,y:_t.parse(e.h)/2+.2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2+.2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2-.2},{x:_t.parse(e.p)/2+.2,y:-_t.parse(e.h)/2-.2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:dln(e).concat(i,n),parameters:e}},uln=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},dln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=uln({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},hln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("3,05mm"),h:B().default("1.65mm"),pl:B().default("0.6mm"),pw:B().default("0.6mm"),pad_spacing:B().default("2.2mm")}),pln=t=>{const e=hln.parse(t),n=zo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.pad_spacing)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.pad_spacing)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:mln(e).concat(i,n),parameters:e}},fln=t=>{const{pn:e,pad_spacing:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},mln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=fln({pn:n,pad_spacing:Number.parseFloat(t.pad_spacing)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},_ln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("4.4mm"),h:B().default("2.1mm"),pl:B().default("1.2mm"),pw:B().default("1.2mm"),p:B().default("2.9mm")}),yln=t=>{const e=_ln.parse(t),n=zo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:bln(e).concat(i,n),parameters:e}},gln=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},bln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=gln({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},xln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("4.4mm"),h:B().default("2.1mm"),pl:B().default("0.91mm"),pw:B().default("1.22mm"),p:B().default("3.146mm")}),vln=t=>{const e=xln.parse(t),n=zo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Sln(e).concat(i,n),parameters:e}},wln=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Sln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=wln({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Eln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("1.80mm"),h:B().default("1.00mm"),pl:B().default("0.66mm"),pw:B().default("0.5mm"),p:B().default("0.8mm")}),Tln=t=>{const e=Eln.parse(t),n=zo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.1,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.1,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Aln(e).concat(i,n),parameters:e}},Mln=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Aln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=Mln({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Cln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("6.2mm"),h:B().default("3.4mm"),pl:B().default("1.4mm"),pw:B().default("2.1mm"),p:B().default("4.4mm")}),Rln=t=>{const e=Cln.parse(t),n=zo(0,_t.parse(e.h)/2+.4,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Iln(e).concat(i,n),parameters:e}},Pln=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Iln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=Pln({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Nln=Ne({fn:B(),num_pins:oi([Ce(3),Ce(5)]).default(3),w:B().default("4.80mm"),h:B().default("4.80mm"),pl:B().default("1.3mm"),pw:B().default("0.9mm"),p:B().default("1.5mm"),string:B().optional()}),kln=t=>{const e=[],n=Number.parseFloat(t.p),i=Number.parseFloat(t.pw),r=Number.parseFloat(t.w),o=Number.parseFloat(t.pl);e.push(Dr(1,-r/2,n,o,i),Dr(2,-r/2+(1.5-1.3)/2,0,1.5,i),Dr(3,-r/2,-n,o,i));const s=zo(0,0,.3),a=Number.parseFloat(t.w)/2-1,c=Number.parseFloat(t.h)/2,l={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-a,y:c},{x:a,y:c},{x:a,y:c/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},u={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-a,y:-c},{x:a,y:-c},{x:a,y:-c/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1};return[...e,l,u,s]},Oln=t=>{const e=[];Number.parseFloat(t.p),Number.parseFloat(t.pw),Number.parseFloat(t.w),e.push(Dr(1,-1.85,-1.5,1.5,.7),Dr(2,-1.85,1.5,1.5,.7),Dr(3,0,0,.8,2),Dr(4,1.85,-1.5,1.5,.7),Dr(5,1.85,1.5,1.5,.7));const n=zo(0,Number.parseFloat(t.h)/2+.5,.3),i=Number.parseFloat(t.w)/2-1,r=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:r},{x:i,y:r}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-r},{x:i,y:-r}],type:"pcb_silkscreen_path",stroke_width:.1};return[...e,o,s,n]},Lln=t=>{const e=t.string?.match(/^sot89_(\d+)/),n=e?Number.parseInt(e[1],10):3,i=Nln.parse({...t,num_pins:n});if(i.num_pins===3)return{circuitJson:kln(i),parameters:i};if(i.num_pins===5)return{circuitJson:Oln(i),parameters:i};throw new Error("Invalid number of pins for SOT89")},Dln=Ne({fn:B(),p:_t.optional().default("5.0mm"),id:_t.optional().default("1.0mm"),od:_t.optional().default("1.9mm"),w:_t.optional().default("13mm"),h:_t.optional().default("7mm"),num_pins:Ue().optional(),string:B().optional()}),zln=t=>{const e=Dln.parse(t),{fn:n,id:i,od:r,w:o,h:s,string:a}=e,c=Number.parseInt(a?.split("_")[1]??"3"),l=-1,u=o/2,d=s/2,h=2.5,f=o*.4,m=Math.max(h,f/(c-1)),y=Array.from({length:c},(N,R)=>{const P=c%2===0?(R-c/2+.5)*m:(R-Math.floor(c/2))*m;return Aa(R+1,P,l,i,r)}),g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-u,y:-d},{x:u,y:-d},{x:u,y:d},{x:-u,y:d},{x:-u,y:-d}],stroke_width:.1,pcb_silkscreen_path_id:""},b=-d+2*s/3,v={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-u,y:b},{x:u,y:b}],stroke_width:.1,pcb_silkscreen_path_id:""},w=[{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-o/6,y:b},{x:-o/6,y:d}],stroke_width:.1,pcb_silkscreen_path_id:""},{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:o/6,y:b},{x:o/6,y:d}],stroke_width:.1,pcb_silkscreen_path_id:""}],T=zo(0,s/2+.6,.5);return{circuitJson:[...y,g,v,...w,T],parameters:{...e,p:m}}},Fln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("5.40mm"),h:B().default("2.30mm"),pl:B().default("1.30mm"),pw:B().default("1.70mm"),p:B().default("3.5mm")}),Bln=t=>{const e=Fln.parse(t),n=zo(0,_t.parse(e.h)/2+.4,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:$ln(e).concat(i,n),parameters:e}},Uln=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},$ln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=Uln({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},jln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("1.90mm"),h:B().default("1.33mm"),pl:B().default("0.5mm"),pw:B().default("0.7mm"),p:B().default("0.8mm")}),Hln=t=>{const e=jln.parse(t),n=zo(0,_t.parse(e.h)+.1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2+.1,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2+.1,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Gln(e).concat(i,n),parameters:e}},Vln=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Gln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=Vln({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Yln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("7.0mm"),h:B().default("3.35mm"),pl:B().default("1.50mm"),pw:B().default("2.70mm"),p:B().default("4.8mm")}),qln=t=>{const e=Yln.parse(t),n=zo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Wln(e).concat(i,n),parameters:e}},Xln=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Wln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=Xln({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Zln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("3.0mm"),h:B().default("1.80mm"),pl:B().default("0.80mm"),pw:B().default("1.20mm"),p:B().default("1.6mm")}),Kln=t=>{const e=Zln.parse(t),n=zo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.1,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.1,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Jln(e).concat(i,n),parameters:e}},Qln=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Jln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=Qln({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},eun=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("7.10mm"),h:B().default("3.40mm"),pl:B().default("2.45mm"),pw:B().default("1.80mm"),p:B().default("4.05mm")}),tun=t=>{const e=eun.parse(t),n=zo(0,_t.parse(e.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.5,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.5,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:iun(e).concat(i,n),parameters:e}},nun=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},iun=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=nun({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},run=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("4.80mm"),h:B().default("2.10mm"),pl:B().default("1.30mm"),pw:B().default("1.40mm"),p:B().default("2.9mm")}),oun=t=>{const e=run.parse(t),n=zo(0,_t.parse(e.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:aun(e).concat(i,n),parameters:e}},sun=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},aun=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=sun({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},cun=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("7.30mm"),h:B().default("4.40mm"),pl:B().default("2.50mm"),pw:B().default("2.30mm"),p:B().default("4.30mm")}),lun=t=>{const e=cun.parse(t),n=zo(0,_t.parse(e.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.1,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.1,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:dun(e).concat(i,n),parameters:e}},uun=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},dun=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=uun({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},hun=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("10.70mm"),h:B().default("6.60mm"),pl:B().default("3.30mm"),pw:B().default("2.50mm"),p:B().default("6.80mm")}),pun=t=>{const e=hun.parse(t),n=zo(0,3,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2-.8},{x:-_t.parse(e.w)/2-.8,y:_t.parse(e.h)/2-.8},{x:-_t.parse(e.w)/2-.8,y:-_t.parse(e.h)/2+.8},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2+.8}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:mun(e).concat(i,n),parameters:e}},fun=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},mun=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=fun({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},_un=Ne({fn:B(),num_pins:Ue().default(4),w:B().default("8.50mm"),h:B().default("6.90mm"),pl:B().default("2mm"),pw:B().default("1.5mm"),p:B().default("2.30mm"),string:B().optional()}),yun=t=>{const e=t.string?.match(/^sot223_(\d+)/),n=e?Number.parseInt(e[1],10):4;if(n===8){const r=xun.parse({...t,num_pins:n});return{circuitJson:r3(r),parameters:r}}const i=_un.parse({...t,num_pins:n});if(i.num_pins===4)return{circuitJson:bun(i),parameters:i};if(i.num_pins===5)return{circuitJson:wun(i),parameters:i};if(i.num_pins===6)return{circuitJson:Eun(i),parameters:i};throw new Error("Invalid number of pins")},gun=t=>{const{pn:e,w:n,p:i}=t;return e===1?{x:-n/2+1.1,y:i}:e===2?{x:-n/2+1.1,y:0}:e===3?{x:-n/2+1.1,y:-i}:{x:n/2-1.1,y:0}},bun=t=>{const e=[];for(let a=0;a<t.num_pins;a++){const{x:c,y:l}=gun({num_pins:t.num_pins,pn:a+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)}),u=a===3?3.8:Number.parseFloat(t.pw);e.push(Dr(a+1,c,l,Number.parseFloat(t.pl),u))}const n=zo(0,0,.3),i=Number.parseFloat(t.w)/2-2.4,r=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:r},{x:i,y:r},{x:i,y:r/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-r},{x:i,y:-r},{x:i,y:-r/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1};return[...e,o,s,n]},xun=_5({p:"0.90mm",w:"2.8mm",legsoutside:!0}),vun=t=>{const{p:e,pn:n,w:i}=t;if(n===1)return{x:-i/2+1.2,y:e/2+e};if(n===2)return{x:-i/2+1.2,y:e/2};if(n===3)return{x:-i/2+1.2,y:-e/2};if(n===4)return{x:-i/2+1.2,y:-e/2-e};if(n===5)return{x:i/2-1,y:0};throw new Error("Invalid pin number")},wun=t=>{const e=[];for(let a=1;a<=t.num_pins;a++){const{x:c,y:l}=vun({h:Number.parseFloat(t.h),p:1.5,pn:a,w:Number.parseFloat(t.w)});let u=Number.parseFloat(t.pw),d=Number.parseFloat(t.pl);a===5?(u=3.4,d=1.8):(u=1,d=2.2),e.push(Dr(a,c,l,d,u))}const n=Number.parseFloat(t.w)/2-2.4,i=Number.parseFloat(t.h)/2,r={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-n,y:i},{x:n,y:i},{x:n,y:i/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-n,y:-i},{x:n,y:-i},{x:n,y:-i/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},s=zo(0,0,.3);return[...e,r,o,s]},Sun=t=>{const{p:e,pn:n,w:i}=t;if(n===1)return{x:-i/2+1.2,y:2*e};if(n===2)return{x:-i/2+1.2,y:e};if(n===3)return{x:-i/2+1.2,y:0};if(n===4)return{x:-i/2+1.2,y:-e};if(n===5)return{x:-i/2+1.2,y:-2*e};if(n===6)return{x:i/2-1.175,y:0};throw new Error("Invalid pin number")},Eun=t=>{const e=[];for(let a=1;a<=t.num_pins;a++){const{x:c,y:l}=Sun({h:Number.parseFloat(t.h),p:1.3,pn:a,w:8.7});let u=Number.parseFloat(t.pw),d=Number.parseFloat(t.pl);a===6?(u=3.4,d=2.15):(u=.6,d=2.2),e.push(Dr(a,c,l,d,u))}const n=Number.parseFloat(t.w)/2-2.4,i=Number.parseFloat(t.h)/2,r={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-n,y:i},{x:n,y:i},{x:n,y:i/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-n,y:-i},{x:n,y:-i},{x:n,y:-i/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},s=zo(0,0,.3);return[...e,r,o,s]},Tun=Ne({fn:B(),num_pins:Ue().default(3),w:B().default("3.40mm"),h:B().default("3.30mm"),pl:B().default("1mm"),pw:B().default("0.7mm"),p:B().default("1.2mm"),string:B().optional()}),Mun=t=>{const e=t.string?.match(/^sot23w_(\d+)/),n=e?Number.parseInt(e[1],3):3,i=Tun.parse({...t,num_pins:n});if(i.num_pins===3)return{circuitJson:Cun(i),parameters:i};throw new Error("Invalid number of pins")},Aun=t=>{const{pn:e,p:n}=t;return e===1?{x:-n,y:.95}:e===2?{x:-n,y:-.95}:{x:n,y:0}},Cun=t=>{const e=[];for(let a=0;a<t.num_pins;a++){const{x:c,y:l}=Aun({num_pins:t.num_pins,pn:a+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)});e.push(Dr(a+1,c,l,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=zo(0,Number.parseInt(t.h)/2+1,.3),i=Number.parseFloat(t.w)/2-1,r=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:r},{x:i+.3,y:r},{x:i+.3,y:r/2}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-r},{x:i+.3,y:-r},{x:i+.3,y:-r/2}],type:"pcb_silkscreen_path",stroke_width:.1};return[...e,o,s,n]},Run=Ne({fn:B(),num_pins:oi([Ce(3),Ce(2)]).default(3),p:B().default("1.27mm"),id:B().default("0.72mm"),od:B().default("0.95mm"),w:B().default("2.5mm"),h:B().default("4.2mm"),string:B().optional()}),Pun=t=>{const{p:e,id:n,od:i,w:r,h:o}=t,s=Number.parseFloat(o)/2,a=Number.parseFloat(e);return[Aa(1,-a,s-a,n,i),Aa(2,0,s-a,n,i),Aa(3,a,s-a,n,i)]},Iun=t=>{const{p:e,id:n,od:i,h:r}=t,o=Number.parseFloat(r)/2,s=Number.parseFloat(e);return[Aa(1,-s,o-s,n,i),Aa(2,s,o-s,n,i)]},Nun=t=>{const e=t.string?.match(/^to92s_(\d+)/),n=e?Number.parseInt(e[1],10):3,i=Run.parse({...t,num_pins:n});let r=[];if(i.num_pins===3)r=Pun(i);else if(i.num_pins===2)r=Iun(i);else throw new Error("Invalid number of pins for TO-92");const o=Number.parseFloat(i.h)/2,s=Number.parseFloat(i.p),a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-o,y:o-s},{x:-1.9,y:0},{x:1.9,y:0},{x:o,y:o-s},{x:1.5,y:Number.parseFloat(i.h)/2+.5},{x:-1.5,y:Number.parseFloat(i.h)/2+.5},{x:-o,y:o-s}],stroke_width:.1,pcb_silkscreen_path_id:""},c=zo(0,o+1,.5);return{circuitJson:[...r,a,c],parameters:i}},kun=Ne({fn:B(),p:_t.optional(),id:_t.optional(),pw:_t.optional(),pl:_t.optional(),w:_t.optional(),h:_t.optional(),sh:oi([bt(),B(),Ue()]).optional().transform(t=>{if(typeof t=="string"){const e=Number(t);return Number.isNaN(e)?!0:e}return t}).describe('JST SH (Surface-mount) connector family. SH stands for "Super High-density".'),ph:bt().optional().describe('JST PH (Through-hole) connector family. PH stands for "Pin Header".'),string:B().optional()}),Oun={ph:{p:_t.parse("2.2mm"),id:_t.parse("0.70mm"),pw:_t.parse("1.20mm"),pl:_t.parse("1.20mm"),w:_t.parse("6mm"),h:_t.parse("5mm")},sh:{p:_t.parse("1mm"),pw:_t.parse("0.6mm"),pl:_t.parse("1.55mm"),w:_t.parse("5.8mm"),h:_t.parse("7.8mm")}};function Lun(t){return t.sh?"sh":(t.ph,"ph")}function Dun(t,e,n,i,r,o){const s=[];if(t==="ph"){const a=n/2;s.push(nj(1,-a,2,i,r,o)),s.push(nj(2,a,2,i,r,o))}else{const a=-((e-1)/2)*n;for(let l=0;l<e;l++){const u=a+l*n;console.log("x si",u),s.push(Dr(l+1,u,-1.325,r,o))}const c=(e-1)/2*n+1.3;console.log("offset",c),s.push(Dr(e+1,-c,1.22,1.2,1.8)),s.push(Dr(e+2,c,1.22,1.2,1.8))}return s}function zun(t,e,n){return t==="ph"?{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-3,y:3},{x:3,y:3},{x:3,y:-2},{x:-3,y:-2},{x:-3,y:3}],stroke_width:.1,pcb_silkscreen_path_id:""}:{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[],stroke_width:.1,pcb_silkscreen_path_id:""}}var Fun=t=>{const e=kun.parse(t),n=Lun(e),i=Oun[n],r=e.p??i.p,o=e.id??i.id,s=e.pw??i.pw,a=e.pl??i.pl,c=e.w??i.w,l=e.h??i.h;let u=n==="sh"?4:2;if(n==="sh"){const y=(typeof t.string=="string"?t.string:"").match(/sh(\d+)/);if(y&&y[1]){const g=parseInt(y[1],10);Number.isNaN(g)||(u=g)}else typeof e.sh=="number"&&(u=e.sh)}const d=Dun(n,u,r,o,s,a),h=zun(n),f=zo(0,l/2+1,.5);return{circuitJson:[...d,h,f],parameters:{...e,p:r,id:o,pw:s,pl:a,w:c,h:l,num_pins:u,sh:n==="sh",ph:n==="ph"}}},Bun=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("3.30mm"),h:B().default("1.70mm"),pl:B().default("0.80mm"),pw:B().default("1mm"),p:B().default("1.90mm")}),Uun=t=>{const e=Bun.parse(t),n=zo(0,_t.parse(e.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:jun(e).concat(i,n),parameters:e}},$un=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},jun=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=$un({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Hun=t=>{switch(t){case 8:return{w:"3.06mm",h:"3.14mm",p:"0.65mm",pl:"1.6mm",pw:"0.5mm"};case 10:return{w:"3.10mm",h:"3.33mm",p:"0.5mm",pl:"1.45mm",pw:"0.3mm"};default:return{w:"3.06mm",h:"3.14mm",p:"0.65mm",pl:"1.6mm",pw:"0.5mm"}}},Vun=Ne({fn:B(),num_pins:oi([Ce(8),Ce(10)]).default(8),w:B().optional(),h:B().optional(),p:B().optional(),pl:B().optional(),pw:B().optional(),string:B().optional()}),Gun=t=>{const e=Vun.parse(t),n=Hun(e.num_pins),i=_t.parse(e.w||n.w),r=_t.parse(e.h||n.h),o=_t.parse(e.p||n.p),s=_t.parse(e.pl||n.pl),a=_t.parse(e.pw||n.pw),c=[],l=e.num_pins/2;for(let v=0;v<e.num_pins;v++){const{x:w,y:T}=Tqe(e.num_pins,v+1,i,o),N=v<l?v+1:e.num_pins-(v-l);c.push(Dr(N,w,T,s,a))}const u=i,d=r,h={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-u/2,y:d/2},{x:u/2,y:d/2}],stroke_width:.05,pcb_silkscreen_path_id:""},f={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-u/2,y:-d/2},{x:u/2,y:-d/2}],stroke_width:.05,pcb_silkscreen_path_id:""},m=Tqe(e.num_pins,1,u,o),y={x:m.x-.8,y:m.y},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:y.x-.4,y:y.y},{x:y.x-.7,y:y.y+.3},{x:y.x-.7,y:y.y-.3},{x:y.x-.4,y:y.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},b=zo(0,d/2+.5,.3);return{circuitJson:[...c,h,f,b,g],parameters:e}},Tqe=(t,e,n,i)=>{const r=t/2,o=(e-1)%r,s=e<=r?-1:1,a=(r-1)/2-o;return{x:s*_t.parse(t===8?"1.8mm":"2.2mm"),y:a*i}},Yun=t=>{switch(t){case 10:return{w:"3.10mm",h:"3.32mm",p:"0.5mm",pl:"1.63mm",pw:"0.33mm"};case 12:return{w:"3mm",h:"4mm",p:"0.65mm",pl:"0.88mm",pw:"0.4mm"};case 16:return{w:"3.10mm",h:"4mm",p:"0.5mm",pl:"0.88mm",pw:"0.3mm"};default:return{w:"3.10mm",h:"3.32mm",p:"0.65mm",pl:"1.63mm",pw:"0.4mm"}}},qun=Ne({fn:B(),num_pins:oi([Ce(8),Ce(10),Ce(12),Ce(16)]).default(8),w:B().optional(),h:B().optional(),p:B().optional(),pl:B().optional(),pw:B().optional(),string:B().optional()}),Mqe=(t,e,n,i)=>{const r=t/2,o=(e-1)%r,s=e<=r?-1:1,a=(r-1)/2-o;return{x:s*_t.parse("2mm"),y:a*i}},Xun=t=>{const e=qun.parse(t),n=Yun(e.num_pins),i=_t.parse(e.w||n.w),r=_t.parse(e.h||n.h),o=_t.parse(e.p||n.p),s=_t.parse(e.pl||n.pl),a=_t.parse(e.pw||n.pw),c=[];for(let b=0;b<e.num_pins;b++){const{x:v,y:w}=Mqe(e.num_pins,b+1,i,o);c.push(Dr(b+1,v,w,s,a))}const l=i,u=r,d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-l/2,y:u/2},{x:l/2,y:u/2}],stroke_width:.05,pcb_silkscreen_path_id:""},h={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-l/2,y:-u/2},{x:l/2,y:-u/2}],stroke_width:.05,pcb_silkscreen_path_id:""},f=Mqe(e.num_pins,1,l,o),m={x:f.x-.8,y:f.y},y={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:m.x-.4,y:m.y},{x:m.x-.7,y:m.y+.3},{x:m.x-.7,y:m.y-.3},{x:m.x-.4,y:m.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},g=zo(0,u/2+.5,.3);return{circuitJson:[...c,d,h,g,y],parameters:e}},Wun=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("3.8mm"),h:B().default("1.65mm"),pl:B().default("1.2mm"),pw:B().default("1.2mm"),pad_spacing:B().default("2.6mm")}),Zun=t=>{const e=Wun.parse(t),n=zo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.pad_spacing)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.pad_spacing)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Qun(e).concat(i,n),parameters:e}},Kun=t=>{const{pn:e,pad_spacing:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Qun=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=Kun({pn:n,pad_spacing:Number.parseFloat(t.pad_spacing)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Jun=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("3.20mm"),h:B().default("1.65mm"),pl:B().default("0.8mm"),pw:B().default("0.9mm"),pad_spacing:B().default("2.1mm")}),edn=t=>{const e=Jun.parse(t),n=zo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.pad_spacing)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.pad_spacing)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:ndn(e).concat(i,n),parameters:e}},tdn=t=>{const{pn:e,pad_spacing:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},ndn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=tdn({pn:n,pad_spacing:Number.parseFloat(t.pad_spacing)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},idn=Ne({fn:B(),num_pins:oi([Ce(6),Ce(8)]).default(8),w:B().default("3mm"),h:B().default("3mm"),p:B().default("0.5mm"),pl:B().default("0.52mm"),pw:B().default("0.35mm"),epw:B().default("1.40mm"),eph:B().default("1.60mm"),string:B().optional(),ep:bt().default(!1)}),rdn=t=>{t.string&&t.string.includes("_ep")&&(t.ep=!0);const e=t.string?.match(/^son_(\d+)/),n=e?Number.parseInt(e[1],10):t.num_pins||8,i=idn.parse({...t,num_pins:n}),r=_t.parse(i.w),o=_t.parse(i.h),s=_t.parse(i.p),a=_t.parse(i.pl),c=_t.parse(i.pw),l=_t.parse(i.epw),u=_t.parse(i.eph),d=[];for(let T=0;T<i.num_pins;T++){const{x:N,y:R}=Aqe(i.num_pins,T+1,r,s);d.push(Dr(T+1,N,R,a,c))}i.ep&&d.push(Dr(i.num_pins+1,0,0,l,u));const h=r,f=o,m={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-h/2,y:f/2},{x:h/2,y:f/2}],stroke_width:.05,pcb_silkscreen_path_id:""},y={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-h/2,y:-f/2},{x:h/2,y:-f/2}],stroke_width:.05,pcb_silkscreen_path_id:""},g=Aqe(i.num_pins,1,h,s),b={x:g.x-.4,y:g.y},v={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:b.x-.4,y:b.y},{x:b.x-.7,y:b.y+.3},{x:b.x-.7,y:b.y-.3},{x:b.x-.4,y:b.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},w=zo(0,f/2+.5,.3);return{circuitJson:[...d,m,y,w,v],parameters:i}},Aqe=(t,e,n,i)=>{const r=t/2,o=(e-1)%r,s=e<=r?-1:1,a=(r-1)/2-o;return{x:s*_t.parse("1.4mm"),y:a*i}},odn=t=>{const{num_pins:e,bridged:n,p:i=2.54,pw:r=1.5,ph:o=1.5}=t,s=_t.parse(i),a=_t.parse(r),c=_t.parse(o),l=Math.min(c/4,.5),u=[];for(let T=0;T<e;T++)u.push(Dr(T+1,T*s,0,a,c));let d=[];if(n){const T=n.split("").map(Number);if(T.length>1)for(let N=0;N<T.length-1;N++){const R=T[N],P=T[N+1];if(typeof R=="number"&&typeof P=="number"&&!isNaN(R)&&!isNaN(P)){const M=(R-1)*s,I=(P-1)*s,A=Math.sign(I-M),$=M+A*(a/2),k=I-A*(a/2);d.push({type:"pcb_trace",pcb_trace_id:"",route:[{start_pcb_port_id:`{PIN${R}}`,x:$,y:0,width:l,layer:"top",route_type:"wire"},{end_pcb_port_id:`{PIN${P}}`,x:k,y:0,width:l,layer:"top",route_type:"wire"}]})}}}const h=(e-1)*s+a+.7,f=c+1,m=(e-1)*s/2,y=0,g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"outline",route:[{x:m-h/2,y:y-f/2},{x:m+h/2,y:y-f/2},{x:m+h/2,y:y+f/2},{x:m-h/2,y:y+f/2},{x:m-h/2,y:y-f/2}],stroke_width:.15},v=y+f/2+.6,w=zo(m,v,.4);return{circuitJson:[...u,...d,g,w],parameters:t}},Cqe={fn:Ce("sot457"),num_pins:Ce(6).default(6),pillh:B().default("0.45mm"),pillw:B().default("1.45mm"),pl:B(),pw:B(),p:B(),wave:bt().optional(),reflow:bt().optional()},sdn=Ne({...Cqe,h:B().default("2.5mm"),w:B().default("2.7mm"),pl:B().default("0.8mm"),pw:B().default("0.55mm"),p:B().default("0.95mm")}),adn=Ne({...Cqe,h:B().default("3mm"),w:B().default("4mm"),pillr:B().default("0.225mm"),pl:B().default("1.45mm"),pw:B().default("1.5mm"),p:B().default("1.475mm")}).transform(t=>({...t,wave:t.wave??(t.reflow===void 0?!0:!t.reflow),reflow:t.reflow??(t.wave===void 0?!1:!t.wave)})),o3=t=>Number.parseFloat(t.replace("mm","")),Rqe=({pitch:t,width:e,pinNumber:n})=>{const o={1:{x:-e/2-.1,y:t},2:{x:-e/2-.1,y:0},3:{x:-e/2-.1,y:-t},4:{x:e/2+.1,y:-t},5:{x:e/2+.1,y:0},6:{x:e/2+.1,y:t}}[n];if(!o)throw new Error(`Invalid pin number: ${n}`);return o},Pqe=t=>{const e=[],n=o3(t.p),i=o3(t.pl),r=o3(t.pw),o=o3(t.w),s=o3(t.h);if(t.wave){const m={1:({padWidth:y,padHeight:g})=>Dr(1,-n,n,g,y),2:({padWidth:y,padHeight:g})=>Dr(2,-n,-n,g,y),3:({padWidth:y,padHeight:g})=>tj(3,-n,0,o3(t.pillw),o3(t.pillh)),4:({padWidth:y,padHeight:g})=>tj(4,n,0,o3(t.pillw),o3(t.pillh)),5:({padWidth:y,padHeight:g})=>Dr(5,n,n,g,y),6:({padWidth:y,padHeight:g})=>Dr(6,n,-n,g,y)};for(let y=1;y<=t.num_pins;y++){const g=m[y];g&&e.push(g({padWidth:i,padHeight:r}))}}else for(let m=1;m<=t.num_pins;m++){const{x:y,y:g}=Rqe({pitch:n,width:o,pinNumber:m});e.push(Dr(m,y,g,i,r))}const a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-o/3,y:s/2+n/1.3},{x:o/3,y:s/2+n/1.3}],stroke_width:.05},c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-o/3,y:-s/2-n/1.3},{x:o/3,y:-s/2-n/1.3}],stroke_width:.05},l=zo(0,s+.5,.3),u=Rqe({pitch:n,width:o,pinNumber:1}),d=t.wave?1:.5,h=t.wave?.7:.3;u.x-=t.wave?r:r*1.7;const f={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:u.x+d/2,y:u.y},{x:u.x-d/2,y:u.y+h/2},{x:u.x-d/2,y:u.y-h/2},{x:u.x+d/2,y:u.y}],stroke_width:.05};return[l,a,c,f,...e]},cdn=t=>{if(t.wave){const n=adn.parse({...t,fn:"sot457"});return{circuitJson:Pqe(n),parameters:n}}const e=sdn.parse(t);return{circuitJson:Pqe(e),parameters:e}},ldn=Ne({fn:B(),num_pins:oi([Ce(3),Ce(2)]).default(3),p:B().default("3.8mm"),id:B().default("1.25mm"),od:B().default("2.35mm"),ca:B().default("14mm").describe("Caliper axis (width or diameter of the potentiometer body or adjustment knob)"),w:B().default("5.35mm"),h:B().default("4mm"),string:B().optional()}),udn=t=>{const{p:e,id:n,od:i,h:r,ca:o}=t,s=Number.parseFloat(r),a=Number.parseFloat(o);return[Aa(1,0,a/4+.3,n,i),Aa(2,s,0,n,i),Aa(3,0,-a/4-.3,n,i)]},ddn=t=>{const e=t.string?.match(/^potentiometer_(\d+)/),n=e?Number.parseInt(e[1],10):3,i=ldn.parse({...t,num_pins:n});let r=[];i.num_pins===3&&(r=udn(i));const o=Number.parseFloat(i.ca)/2+.15,s=Number.parseFloat(i.w),a=Number.parseFloat(i.od)/2+.35,c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:o-1.75},{x:0,y:o},{x:s,y:o},{x:s,y:a}],stroke_width:.1,pcb_silkscreen_path_id:""},l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:s,y:-a},{x:s,y:-o},{x:0,y:-o},{x:0,y:-o+1.75}],stroke_width:.1,pcb_silkscreen_path_id:""},u=Number.parseFloat(i.w)/2,d=zo(u,o+1,.5);return{circuitJson:[...r,c,l,d],parameters:i}},hdn=Ne({fn:B(),p:_t.optional().default("7.5mm"),id:_t.optional().default("1mm"),od:_t.optional().default("2mm"),d:_t.optional().default("10.5mm")}),pdn=(t,e,n,i,r)=>{const o=[],s=[];for(let a=0;a<=50;a++){const c=a/50*Math.PI,l=t+Math.cos(c)*n,u=e+Math.sin(c)*n;l<t-i&&u>=e-r/2&&u<=e+r/2||o.push({x:l,y:u})}for(let a=0;a<=50;a++){const c=Math.PI+a/50*Math.PI,l=t+Math.cos(c)*n,u=e+Math.sin(c)*n;l<t-i&&u>=e-r/2&&u<=e+r/2||s.push({x:l,y:u})}return{topArc:o,bottomArc:s}},fdn=t=>{const e=hdn.parse(t),{p:n,id:i,od:r,d:o}=e,s=[Aa(1,-n/2,0,i,r),Aa(2,n/2,0,i,r)],{topArc:a,bottomArc:c}=pdn(0,0,o/2+.1,r/2,r),l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:a,stroke_width:.1,pcb_silkscreen_path_id:""},u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:c,stroke_width:.1,pcb_silkscreen_path_id:""},d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:o/2+.1},{x:0,y:-(o/2+.1)}],stroke_width:.1,pcb_silkscreen_path_id:""},h=-(o/2+.5),f=r/2+1.5,m=.5,y={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:h-m,y:f},{x:h+m,y:f}],stroke_width:.1,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:h,y:f-m},{x:h,y:f+m}],stroke_width:.1,pcb_silkscreen_path_id:""},b=zo(0,o/2+1,.5);return{circuitJson:[...s,l,u,d,y,g,b],parameters:e}},mdn=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("6.5mm"),h:B().default("3mm"),pl:B().default("1.75mm"),pw:B().default("2.40mm"),p:B().default("4.75mm")}),_dn=t=>{const e=mdn.parse(t),n=zo(0,_t.parse(e.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.3,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.3,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:gdn(e).concat(i,n),parameters:e}},ydn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},gdn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=ydn({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},bdn=Ne({fn:B(),num_pins:Ue().default(3),w:B().default("2.45mm"),h:B().default("2.40mm"),pl:B().default("0.45mm"),pw:B().default("0.70mm"),p:B().default("1mm"),string:B().optional()}),xdn=t=>{const e=t.string?.match(/^sot323_(\d+)/),n=e?Number.parseInt(e[1],3):3,i=bdn.parse({...t,num_pins:n});if(i.num_pins===3)return{circuitJson:wdn(i),parameters:i};throw new Error("Invalid number of pins")},vdn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n,y:.65}:e===2?{x:-n,y:-.65}:{x:n,y:0}},wdn=t=>{const e=[];for(let a=0;a<t.num_pins;a++){const{x:c,y:l}=vdn({num_pins:t.num_pins,pn:a+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)});e.push(Dr(a+1,c,l,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=zo(0,Number.parseInt(t.h)/2+1,.3),i=Number.parseFloat(t.w)/2-Number.parseFloat(t.pl),r=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:r+.3},{x:i,y:r+.3},{x:i,y:r/2}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-r-.3},{x:i,y:-r-.3},{x:i,y:-r/2}],type:"pcb_silkscreen_path",stroke_width:.1};return[...e,o,s,n]},Sdn=Ne({fn:B(),circle:bt().optional(),rect:bt().optional(),square:bt().optional(),pill:bt().optional(),d:_t.optional(),pd:_t.optional(),diameter:_t.optional(),r:_t.optional(),pr:_t.optional(),radius:_t.optional(),w:_t.optional(),pw:_t.optional(),width:_t.optional(),h:_t.optional(),ph:_t.optional(),height:_t.optional(),s:_t.optional(),size:_t.optional(),string:B().optional()}).transform(t=>{let e="rect";t.circle&&(e="circle"),t.square&&(e="square"),t.rect&&(e="rect"),t.pill&&(e="pill");let n,i,r;return e==="circle"?t.r!==void 0?n=dh(t.r):t.pr!==void 0?n=dh(t.pr):t.radius!==void 0?n=dh(t.radius):t.d!==void 0?n=dh(t.d)/2:t.pd!==void 0?n=dh(t.pd)/2:t.diameter!==void 0?n=dh(t.diameter)/2:n=dh("1mm")/2:(t.w!==void 0?i=dh(t.w):t.pw!==void 0?i=dh(t.pw):t.width!==void 0?i=dh(t.width):t.s!==void 0?i=dh(t.s):t.size!==void 0?i=dh(t.size):i=dh("1mm"),t.h!==void 0?r=dh(t.h):t.ph!==void 0?r=dh(t.ph):t.height!==void 0?r=dh(t.height):e==="square"||e==="rect"?r=i:r=dh("1mm")),{fn:t.fn,shape:e,radius:n,width:i,height:r}}),Edn=t=>{const e=Sdn.parse(t),{shape:n,radius:i,width:r,height:o}=e;let s,a;return n==="circle"?(s=pqe(1,{x:0,y:0,radius:i}),a=i+.5):n==="pill"?(s=tj(1,0,0,r,o),a=Math.max(r,o)/2+.5):(s=Dr(1,0,0,r,o),a=o/2+.5),{circuitJson:[s,zo(0,a,.2)],parameters:e}},Tdn=Ne({fn:B(),d:_t.optional(),hd:_t.optional(),r:_t.optional(),hr:_t.optional(),pd:_t.optional(),pr:_t.optional(),squarepad:bt().optional().default(!1)}).transform(t=>{let e;t.d!==void 0?e=dh(t.d):t.hd!==void 0?e=dh(t.hd):t.r!==void 0?e=dh(t.r)*2:t.hr!==void 0?e=dh(t.hr)*2:e=dh("1mm");let n;return t.pd!==void 0?n=dh(t.pd):t.pr!==void 0?n=dh(t.pr)*2:n=e*(1.5/1),{fn:t.fn,d:e,pd:n,squarepad:t.squarepad??!1}}),Mdn=t=>{const e=Tdn.parse(t),{d:n,pd:i,squarepad:r}=e;return{circuitJson:[r?nj(1,0,0,n,i,i):Aa(1,0,0,n,i),zo(0,i/2+.5,.2)],parameters:e}},Adn=Ne({fn:B(),num_pins:Ce(6).default(6),h:B().default("1.6mm"),pl:B().default("1mm"),pw:B().default("0.7mm"),p:B().default("0.95mm")}),Cdn=t=>{const e=Adn.parse(t);return{circuitJson:Rdn(e),parameters:e}},Iqe=t=>{const{p:e,h:n,pn:i}=t;if(i===1)return{x:-n/2-.5,y:e};if(i===2)return{x:-n/2-.5,y:0};if(i===3)return{x:-n/2-.5,y:-e};if(i===4)return{x:n/2+.5,y:-e};if(i===5)return{x:n/2+.5,y:0};if(i===6)return{x:n/2+.5,y:e};throw new Error("Invalid pin number")},Rdn=t=>{const e=[];for(let d=1;d<=t.num_pins;d++){const{x:h,y:f}=Iqe({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:d});e.push(Dr(d,h,f,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=t.num_pins/2*Number.parseFloat(t.p),i=Number.parseFloat(t.h),r={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-n/3,y:i/2+Number.parseFloat(t.p)/1.3},{x:n/3,y:i/2+Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-n/3,y:-i/2-Number.parseFloat(t.p)/1.3},{x:n/3,y:-i/2-Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},s=zo(0,i+.3,.3),a=Iqe({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:1});a.x=a.x-Number.parseFloat(t.pw)*1.5;const c=.7,l=.3,u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:a.x+c/2,y:a.y},{x:a.x-c/2,y:a.y+l/2},{x:a.x-c/2,y:a.y-l/2},{x:a.x+c/2,y:a.y}],stroke_width:.05};return[...e,s,r,o,u]},Pdn=Ne({fn:B()}),Idn=t=>{const e=Pdn.parse(t),n=[],i=.5-.15,r=1.5,s=.5/2,a=75,c=-37/2;for(let P=0;P<a;P++){const M=P+1;if(M>=24&&M<=31)continue;const I=c-P*s,A=M%2===0,$=r+(A?.25:0),V=.5-$/2,X=Dr(M,V,I,$,i);X.layer=A?"bottom":"top",n.push(X)}const l=46*.0254,u=137*.0254,d=261*.0254,h={type:"pcb_cutout",pcb_cutout_id:"",shape:"rect",center:{x:-u/2+r/2,y:c-d},width:u,height:l},f={x:-.5,y:c},m={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:f.x-.4,y:f.y},{x:f.x-.7,y:f.y+.3},{x:f.x-.7,y:f.y-.3},{x:f.x-.4,y:f.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"};let y=1/0,g=-1/0,b=1/0,v=-1/0;const w=(P,M,I=0,A=0)=>{y=Math.min(y,P-I/2),g=Math.max(g,P+I/2),b=Math.min(b,M-A/2),v=Math.max(v,M+A/2)};for(const P of n)w(P.x,P.y,P.width,P.height);w(h.center.x,h.center.y,h.width,h.height);for(const P of m.route)w(P.x,P.y);const T=(y+g)/2,N=(b+v)/2,R=P=>{typeof P.x=="number"&&(P.x-=T),typeof P.y=="number"&&(P.y-=N),P.center&&(P.center.x-=T,P.center.y-=N),Array.isArray(P.route)&&(P.route=P.route.map(M=>({x:M.x-T,y:M.y-N})))};for(const P of n)R(P);return R(h),R(m),{circuitJson:[...n,h,m],parameters:e}};function Ndn(t){return t!=null}var kdn=(t,e)=>{if(!e)return t;const n=t.filter(u=>u.type==="pcb_smtpad"||u.type==="pcb_plated_hole"||u.type==="pcb_thtpad");if(n.length===0)return t;let i=1/0,r=-1/0,o=1/0,s=-1/0;const a=(u,d,h=0,f=0)=>{const m=u-h/2,y=u+h/2,g=d-f/2,b=d+f/2;i=Math.min(i,m),r=Math.max(r,y),o=Math.min(o,g),s=Math.max(s,b)};for(const u of n)if(u.type==="pcb_smtpad"){const d=u.shape==="circle"?u.radius*2:u.width,h=u.shape==="circle"?u.radius*2:u.height;a(u.x,u.y,d,h)}else if(u.type==="pcb_plated_hole"){const d=u.outer_diameter??u.hole_diameter;a(u.x,u.y,d,d)}else if(u.type==="pcb_thtpad"){const d=u.diameter;a(u.x,u.y,d,d)}let c=0,l=0;switch(e){case"center":c=(i+r)/2,l=(o+s)/2;break;case"bottomleft":c=i,l=o;break;case"bottomcenter":case"centerbottom":c=(i+r)/2,l=o;break;case"topcenter":case"centertop":c=(i+r)/2,l=s;break;case"leftcenter":case"centerleft":c=i,l=(o+s)/2;break;case"rightcenter":case"centerright":c=r,l=(o+s)/2;break;case"pin1":const u=n.find(d=>d.port_hints?.[0]==="1")||n[0];c=u.x,l=u.y;break}if(c===0&&l===0)return t;for(const u of t){if(typeof u.x=="number"&&(u.x-=c),typeof u.y=="number"&&(u.y-=l),u.center&&typeof u.center.x=="number"&&(u.center.x-=c,u.center.y-=l),u.type==="pcb_silkscreen_path")for(const d of u.route)d.x-=c,d.y-=l;u.type==="pcb_silkscreen_text"&&u.anchor_position&&(u.anchor_position.x-=c,u.anchor_position.y-=l)}return t},Odn=t=>{let e=sj();const i=t.replace(/^((?:\d{4}|\d{5}))(?=$|_)/,"res$1").split(/_(?!metric)/).map(r=>{const o=r.match(/([a-z]+)([\(\d\.\+\?].*)?/);if(!o)return null;const[,s,a]=o;return!s||a?.includes("?")?null:{fn:s,v:a}}).filter(Ndn);for(const{fn:r,v:o}of i)e=e[r](o);return e.setString(t),e},Ldn=()=>Object.keys(i3),sj=()=>{const t=new Proxy({},{get:(e,n)=>{if(n==="soup"||n==="circuitJson"){if("fn"in e&&i3[e.fn])return()=>{const{circuitJson:i}=i3[e.fn](e);return kdn(i,e.origin)};if(!i3[e.fn])throw new Error(`Invalid footprint function, got "${e.fn}"${e.string?`, from string "${e.string}"`:""}`);return()=>{throw new Error(`No function found for footprinter, make sure to specify .dip, .lr, .p, etc. Got "${n}"`)}}if(n==="json"){if(!i3[e.fn])throw new Error(`Invalid footprint function, got "${e.fn}"${e.string?`, from string "${e.string}"`:""}`);return()=>i3[e.fn](e).parameters}return n==="getFootprintNames"?()=>Object.keys(i3):n==="params"?()=>e:n==="setString"?i=>(e.string=i,t):i=>(Object.keys(e).length===0?`${n}${i}`in i3?(e[`${n}${i}`]=!0,e.fn=`${n}${i}`):(e[n]=!0,e.fn=n,n==="res"||n==="cap"?i&&(typeof i=="string"&&i.includes("_metric")?e.metric=i.split("_metric")[0]:e.imperial=i):e.num_pins=Number.isNaN(Number.parseFloat(i))?void 0:Number.parseFloat(i)):!i&&["w","h","p"].includes(n)||(e[n]=i??!0),t)}});return t};sj.string=Odn,sj.getFootprintNames=Ldn;var Ddn=sj,dv=jp(d0e()),Nqe=Symbol("Fragment");function E0e(t,e,...n){const i=n.length?n:e?.children!==void 0?[e.children]:[],r=[],o=(Array.isArray(i)?i:[i]).flat(1/0);for(const s of o)s==null||s===!1||(Array.isArray(s)?r.push(...s):r.push(s));return{type:t,props:(e&&e.children!==void 0?{...e,children:void 0}:e)||{},children:r}}var Oc=Symbol("Cuboid"),kqe=Symbol("Cube"),q4=Symbol("Cylinder"),Oqe=Symbol("Sphere"),aj=Symbol("RoundedCuboid"),X4=Symbol("Translate"),NI=Symbol("Rotate"),Lqe=Symbol("Union"),T0e=Symbol("Subtract"),cj=Symbol("Hull"),s3=Symbol("Colorize"),kI=Symbol("Polygon"),OI=Symbol("ExtrudeLinear"),Wy=Nqe,ui=(t,e,n)=>E0e(t,e),z0=(t,e,n)=>E0e(t,e),BA=({center:t,width:e,length:n,height:i,heightAboveSurface:r=.15})=>ui(s3,{color:"#555",children:ui(X4,{offset:t,children:ui(X4,{offset:{x:0,y:0,z:i/2+r},children:ui(aj,{roundRadius:.2,size:[e,n,i]})})})}),zdn=t=>Array.from({length:t},(e,n)=>n);function M0e(t,e){if(t.length<2)throw new Error("Stroke must have at least two points");const n=Array.isArray(t[0])?t.map(([u,d])=>({x:u,y:d})):t,i=e/2,r=[],o=[];function s(u,d){const h=d.x-u.x,f=d.y-u.y,m=Math.sqrt(h*h+f*f);return{x:-f/m,y:h/m}}function a(u,d,h){const f={x:u.x+d.x*i*h,y:u.y+d.y*i*h};h>0?r.push(f):o.unshift(f)}const c=s(n[0],n[1]);a(n[0],c,1),a(n[0],c,-1);for(let u=1;u<n.length-1;u++){const d=n[u-1],h=n[u],f=n[u+1],m=s(d,h),y=s(h,f),g=m.x+y.x,b=m.y+y.y,v=Math.sqrt(g*g+b*b);if(v/2>2*i)a(h,m,1),a(h,y,1),a(h,m,-1),a(h,y,-1);else{const T=1/v;a(h,{x:g*T,y:b*T},1),a(h,{x:g*T,y:b*T},-1)}}const l=s(n[n.length-2],n[n.length-1]);return a(n[n.length-1],l,1),a(n[n.length-1],l,-1),[...r,...o]}var Fdn=t=>{const e=Math.min(...t.map(a=>a.x)),n=Math.max(...t.map(a=>a.x)),i=Math.min(...t.map(a=>a.y)),s=5.47/(Math.max(...t.map(a=>a.y))-i);return t.map(a=>({x:(a.x-e-(n-e)/2)*s,y:(a.y-i)*s}))},Bdn=Fdn([{x:20,y:105},{x:20,y:109},{x:20,y:102},{x:26,y:102},{x:26,y:109},{x:24,y:111},{x:24,y:118},{x:22,y:118},{x:22,y:111},{x:20,y:109}]),Dqe=5.47,lj=.5,Udn=({x:t,y:e,z:n})=>{const i=t>0;return z0(Wy,{children:[ui(X4,{offset:{x:t+.25/2,y:e,z:n},children:ui(NI,{rotation:["-90deg",0,"90deg"],children:ui(OI,{height:.25,children:ui(kI,{points:Bdn.map(r=>[r.x,r.y])})})})}),ui(X4,{offset:{x:t,y:e+(i?1:-1),z:n},children:ui(NI,{rotation:["-90deg","90deg",i?"180deg":"0deg"],children:ui(OI,{height:2,children:ui(kI,{points:M0e([[0,0],[-1,0],[-1,-1]],.25).map(r=>[r.x,r.y])})})})})]})},$dn=({numPins:t=8,pitch:e=2.54,bodyWidth:n=6.4})=>{const i=Math.floor(t/2),r=n+1;return z0(Wy,{children:[zdn(t).map(o=>{const s=o%i,a=(Math.floor(o/i)-.5)*2;return ui(Udn,{x:a*r/2,y:s*e-(i-1)/2*e,z:Dqe/2+lj})}),ui(BA,{width:n,length:i*e+.5,height:Dqe-lj,heightAboveSurface:lj,center:{x:0,y:0,z:lj}})]})};function jdn(t,{height:e,padContactLength:n,curveLength:i,bodyDistance:r,steepness:o=10}){i||(i=r*.3);let s=r-n-i;s<0&&(i+=s,s=0);const a=n*.75,c=n+i+(r-n-i)*.25;if(t<=a)return 0;if(t>=c)return e;const l=(t-a)/(c-a);return e/(1+Math.exp(-o*(l-.5)))}var hv=t=>{const{thickness:e,width:n,padContactLength:i,bodyDistance:r,height:o,rotation:s}=t,a=15,c=Array.from({length:a}).map((u,d)=>d/(a-1)*r).map(u=>[u,jdn(u,t)]),l=M0e(c,e);return ui(s3,{color:"#fff",children:ui(X4,{offset:{z:0,y:0,x:0,...t.position},children:ui(NI,{rotation:["90deg",0,s??0],children:ui(X4,{offset:{x:0,y:0,z:-n/2},children:ui(OI,{height:n,children:ui(kI,{points:l.map(u=>[u.x,u.y])})})})})})})},Hdn=({pinCount:t,leadLength:e,leadWidth:n,pitch:i,bodyWidth:r})=>{const o=Math.ceil(t/2),s=i*t/2+n/2,a=(o-1)*i/2,c=.25;return z0(Wy,{children:[Array.from({length:o}).map((l,u)=>ui(hv,{position:{x:-r/2-e,y:u*i-a,z:c/2},width:n,thickness:c,padContactLength:e,bodyDistance:e+1,height:.8})),Array.from({length:o}).map((l,u)=>ui(hv,{rotation:Math.PI,position:{x:r/2+e,y:u*i-a,z:c/2},width:n,thickness:c,padContactLength:e,bodyDistance:e+1,height:.8})),ui(BA,{center:{x:0,y:0,z:c/2},width:r-n-1,length:s,height:1.5})]})},A0e=1,C0e=.5,UA=.5,LI=.2,Vdn=A0e-LI*2,zqe=({color:t="#333"})=>z0(Wy,{children:[ui(Oc,{size:[Vdn,C0e,UA],offset:[0,0,UA/2],color:t}),ui(Oc,{size:[LI,UA,C0e],offset:[A0e/2-LI/2,0,UA/2],color:"#ccc"}),ui(Oc,{size:[LI,UA,C0e],offset:[-A0e/2+LI/2,0,UA/2],color:"#ccc"})]}),R0e=1.6,Gdn=R0e-.3*2,uj=.3,P0e=.85,$A=.6,Fqe=({color:t="#333"})=>z0(Wy,{children:[ui(Oc,{size:[Gdn,P0e,$A],offset:[0,0,$A/2],color:t}),ui(Oc,{size:[uj,P0e,$A],offset:[R0e/2-uj/2,0,$A/2],color:"#ccc"}),ui(Oc,{size:[uj,P0e,$A],offset:[-R0e/2+uj/2,0,$A/2],color:"#ccc"})]}),I0e=2,N0e=1.25,jA=.55,DI=.5,Ydn=I0e-DI*2,Bqe=({color:t="#333"})=>z0(Wy,{children:[ui(Oc,{size:[Ydn,N0e,jA],offset:[0,0,jA/2],color:t}),ui(Oc,{size:[DI,N0e,jA],offset:[I0e/2-DI/2,0,jA/2],color:"#ccc"}),ui(Oc,{size:[DI,N0e,jA],offset:[-I0e/2+DI/2,0,jA/2],color:"#ccc"})]}),qdn=({pinCount:t,pitch:e,leadWidth:n,padContactLength:i,bodyWidth:r})=>{const o=t/4;e||(e=Xdn(t,r)),i||(i=Wdn(t)),n||(n=Zdn(t,r)),r||(r=e*(o+4));const s=r,a=(o-1)*e/2,c=s+2*i,l=c,u=.8,d=.15,h=(l-r)/2;return z0(Wy,{children:[Array.from({length:o}).map((f,m)=>ui(hv,{position:{x:-l/2,y:m*e-a,z:d/2},width:n,thickness:d,padContactLength:i,bodyDistance:h,height:u})),Array.from({length:o}).map((f,m)=>ui(hv,{rotation:Math.PI,position:{x:l/2,y:m*e-a,z:d/2},width:n,thickness:d,padContactLength:i,bodyDistance:h,height:u})),Array.from({length:o}).map((f,m)=>ui(hv,{rotation:Math.PI/2,position:{x:m*e-a,y:-c/2,z:d/2},width:n,thickness:d,padContactLength:i,bodyDistance:h,height:u})),Array.from({length:o}).map((f,m)=>ui(hv,{rotation:-Math.PI/2,position:{x:m*e-a,y:c/2,z:d/2},width:n,thickness:d,padContactLength:i,bodyDistance:h,height:u})),ui(BA,{center:{x:0,y:0,z:d/2},width:r,length:s,height:1.5})]})},Xdn=(t,e)=>{switch(t){case 44:case 64:return .8;case 52:return e===14?1:.65;case 208:return .5;default:return .5}},Wdn=t=>{switch(t){case 44:case 52:case 64:return 2.25;case 208:return 1.65;default:return 1}},Zdn=(t,e)=>{switch(t){case 44:case 64:return .5;case 52:return e===14?.45:.55;case 208:return .3;default:return .25}},Kdn=({numberOfPins:t,pitch:e=2.54,longSidePinLength:n=6})=>{const o=t*e,s=3,a=-((t-1)/2)*e;return z0(Wy,{children:[ui(Oc,{color:"#222",size:[o,.63*3,2],center:[0,0,2/2]}),Array.from({length:t},(c,l)=>z0(Wy,{children:[ui(s3,{color:"gold",children:z0(cj,{children:[ui(Oc,{color:"gold",size:[.63,.63,s*.9],center:[a+l*e,0,2*.9+2/2]}),ui(Oc,{color:"gold",size:[.63/1.8,.63/1.8,s],center:[a+l*e,0,2+2/2]})]})}),ui(s3,{color:"gold",children:z0(cj,{children:[ui(Oc,{color:"gold",size:[.63,.63,n*.9],center:[a+l*e,0,-n/2*.9]}),ui(Oc,{color:"gold",size:[.63/1.8,.63/1.8,n],center:[a+l*e,0,-n/2]})]})})]}))]})},Qdn=t=>{const e=["left","bottom","right","top"],{pin_count:n,pn:i,w:r,h:o,p:s,pl:a}=t,c=n/4,l=e[Math.floor((i-1)/c)],u=(i-1)%c,d=s*(c-1),h=s*(c-1),f=-a/2;switch(l){case"left":return{x:-r/2-f,y:h/2-u*s,o:"vert"};case"bottom":return{x:-d/2+u*s,y:-o/2-f,o:"horz"};case"right":return{x:r/2+f,y:-h/2+u*s,o:"vert"};case"top":return{x:d/2-u*s,y:o/2+f,o:"horz"};default:throw new Error("Invalid pin number")}},Jdn=({num_pins:t,cw:e,ccw:n,startingpin:i})=>{const r=[],o=t/4;let s=1;const a={};for(const c of i??[])a[c]=!0;!a.leftside&&!a.topside&&!a.rightside&&!a.bottomside&&(a.leftside=!0),!a.bottompin&&!a.leftpin&&!a.rightpin&&!a.toppin&&(a.leftside?a.toppin=!0:a.topside?a.rightpin=!0:a.rightside?a.bottompin=!0:a.bottomside&&(a.leftpin=!0)),a.leftside&&a.toppin?s=1:a.leftside&&a.bottompin?s=o:a.bottomside&&a.leftpin?s=o+1:a.bottomside&&a.rightpin?s=o*2:a.rightside&&a.bottompin?s=o*2+1:a.rightside&&a.toppin?s=o*3:a.topside&&a.rightpin?s=o*3+1:a.topside&&a.leftpin&&(s=o*4),r.push(-1);for(let c=0;c<t;c++)r[s]=c+1,s++,s>t&&(s=1);return r},ehn=({num_pins:t=16,bodyWidth:e=9,bodyLength:n=9,bodyThickness:i=.8,thermalPadSize:r,padWidth:o=.25,padLength:s=.25,pitch:a=.5,thermalPadThickness:c=.05})=>{const l=Jdn({num_pins:t,cw:!0,ccw:!0}),u=[];for(let d=0;d<t;d++){const{x:h,y:f,o:m}=Qdn({pin_count:t,pn:d+1,w:e,h:n,p:a,pl:s});let y=o,g=s;m==="vert"&&([y,g]=[g,y]);const b=l[d+1];u.push({pn:b,x:h,y:f,pw:y,pl:g})}return z0(Wy,{children:[ui(s3,{color:"grey",children:ui(Oc,{center:{x:0,y:0,z:i/2},size:[e,n,i]})}),u.map((d,h)=>ui(Oc,{center:{x:d.x,y:d.y,z:c/2},size:[d.pw,d.pl,c]})),r?.length!==void 0&&r?.width!==void 0&&ui(Oc,{center:{x:0,y:0,z:c/2},size:[r.width,r.length,c]})]})},thn=ehn,nhn=()=>{const c=1.1999999999999997;return z0(Wy,{children:[ui(hv,{rotation:Math.PI,position:{x:2.8/2+c/4,y:-1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),ui(hv,{rotation:Math.PI,position:{x:2.8/2+c/4,y:1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),ui(hv,{position:{x:-2.8/2-c/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),ui(hv,{position:{x:-2.8/2-c/4,y:-1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),ui(hv,{position:{x:-2.8/2-c/4,y:1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),ui(BA,{center:{x:0,y:0,z:0},width:1.6,length:2.9,height:1.2})]})},ihn=nhn,k0e=.6,O0e=.3,HA=.33,zI=.1,rhn=k0e-zI*2,Uqe=({color:t="#333"})=>z0(Wy,{children:[ui(Oc,{size:[rhn,O0e,HA],offset:[0,0,HA/2],color:t}),ui(Oc,{size:[zI,O0e,HA],offset:[k0e/2-zI/2,0,HA/2],color:"#ccc"}),ui(Oc,{size:[zI,O0e,HA],offset:[-k0e/2+zI/2,0,HA/2],color:"#ccc"})]}),L0e=.4,D0e=.2,VA=.13,FI=.07,ohn=L0e-FI*2,$qe=({color:t="#333"})=>z0(Wy,{children:[ui(Oc,{size:[ohn,D0e,VA],offset:[0,0,VA/2],color:t}),ui(Oc,{size:[FI,D0e,VA],offset:[L0e/2-FI/2,0,VA/2],color:"#ccc"}),ui(Oc,{size:[FI,D0e,VA],offset:[-L0e/2+FI/2,0,VA/2],color:"#ccc"})]}),z0e=3.2,F0e=1.6,GA=.9,BI=.5,shn=z0e-BI*2,jqe=({color:t="#333"})=>z0(Wy,{children:[ui(Oc,{size:[shn,F0e,GA],offset:[0,0,GA/2],color:t}),ui(Oc,{size:[BI,F0e,GA],offset:[z0e/2-BI/2,0,GA/2],color:"#ccc"}),ui(Oc,{size:[BI,F0e,GA],offset:[-z0e/2+BI/2,0,GA/2],color:"#ccc"})]}),B0e=3.2,U0e=2.5,YA=1,UI=.6,ahn=B0e-UI*2,Hqe=({color:t="#333"})=>z0(Wy,{children:[ui(Oc,{size:[ahn,U0e,YA],offset:[0,0,YA/2],color:t}),ui(Oc,{size:[UI,U0e,YA],offset:[B0e/2-UI/2,0,YA/2],color:"#ccc"}),ui(Oc,{size:[UI,U0e,YA],offset:[-B0e/2+UI/2,0,YA/2],color:"#ccc"})]}),$0e=5,j0e=2.5,qA=1.4,$I=.6,chn=$0e-$I*2,Vqe=({color:t="#333"})=>z0(Wy,{children:[ui(Oc,{size:[chn,j0e,qA],offset:[0,0,qA/2],color:t}),ui(Oc,{size:[$I,j0e,qA],offset:[$0e/2-$I/2,0,qA/2],color:"#ccc"}),ui(Oc,{size:[$I,j0e,qA],offset:[-$0e/2+$I/2,0,qA/2],color:"#ccc"})]}),H0e=6.3,V0e=3.2,XA=1.8,jI=.8,lhn=H0e-jI*2,Gqe=({color:t="#333"})=>z0(Wy,{children:[ui(Oc,{size:[lhn,V0e,XA],offset:[0,0,XA/2],color:t}),ui(Oc,{size:[jI,V0e,XA],offset:[H0e/2-jI/2,0,XA/2],color:"#ccc"}),ui(Oc,{size:[jI,V0e,XA],offset:[-H0e/2+jI/2,0,XA/2],color:"#ccc"})]}),uhn=({numberOfPins:t,pitch:e=2.54,legsLength:n=3,outerDiameter:i=.945,innerDiameter:r=.945})=>{const o=r/1.5,s=o*2+i,a=5,c=(t-1)*e+i+e/2,l=o*1.6,u=-((t-1)/2)*e,d=ui(s3,{color:"#1a1a1a",children:z0(T0e,{children:[ui(Oc,{color:"#000",size:[c,s,a],center:[0,0,a/2]}),Array.from({length:t},(h,f)=>r?ui(q4,{height:a+.1,radius:r/2,center:[u+f*e,0,a/2],color:"#222"},f):ui(Oc,{size:[l,l,a],center:[u+f*e,0,a/2]},f))]})});return z0(Wy,{children:[d,Array.from({length:t},(h,f)=>z0(s3,{color:"silver",children:[z0(cj,{children:[ui(Oc,{color:"silver",size:[o,o,n*.9],center:[u+f*e,0,-n/2*.9]}),ui(Oc,{color:"silver",size:[o/1.8,o/1.8,n],center:[u+f*e,0,-n/2]})]}),ui(Oc,{color:"silver",size:[l,l,l*.5],center:[u+f*e,0,l/2*.5]})]},f))]})},dhn=({width:t,length:e,innerDiameter:n=1})=>{const i=t,r=e,o=t*.7,s=n/2.5;return z0(Wy,{children:[ui(aj,{color:"#1a1a1f",center:[0,0,o/2],size:[r,r,o],roundRadius:.3}),ui(aj,{color:"#f2f2f2",center:[0,0,o+o*.1/2.5],size:[r,r,o*.1],roundRadius:.14}),ui(q4,{color:"#1a1a1f",height:o*.8,radius:i/3,center:[0,0,o+o*.8/2]}),ui(q4,{color:"#1a1a1f",height:o*.2,radius:n/2,center:[r/3,r/3,o+o*.1/2]}),ui(q4,{color:"#1a1a1f",height:o*.2,radius:n/2,center:[-r/3,-r/3,o+o*.1/2]}),ui(q4,{color:"#1a1a1f",height:o*.2,radius:n/2,center:[-r/3,r/3,o+o*.1/2]}),ui(q4,{color:"#1a1a1f",height:o*.2,radius:n/2,center:[r/3,-r/3,o+o*.1/2]}),ui(dj,{thickness:n/3,width:s,horizontalLength:r*.8,verticalLength:o/2,position:{x:-i/2,y:-r/2,z:-o*1.2}}),ui(dj,{thickness:n/3,width:s,horizontalLength:r*.8,verticalLength:o/2,position:{x:-i/2,y:r/2,z:-o*1.2},rotation:Math.PI}),ui(dj,{thickness:n/3,width:s,horizontalLength:r*.8,verticalLength:o/2,position:{x:i/2,y:r/2,z:-o*1.2},rotation:Math.PI}),ui(dj,{thickness:n/3,width:s,horizontalLength:r*.8,verticalLength:o/2,position:{x:i/2+n/3.6,y:-r/2,z:-o*1.2}})]})},dj=t=>{const{thickness:e,width:n,horizontalLength:i,verticalLength:r,rotation:o=0,position:s}=t,a=[[0,i],[-r/3,i/3],[-r/5,i/4],[0,0]],c=M0e(a,e);return ui(s3,{color:"#f2f2f2",children:ui(X4,{offset:{x:s?.x||0,y:s?.y||0,z:s?.z||0},children:ui(NI,{rotation:[0,55,o],children:ui(OI,{height:n,children:ui(kI,{points:c.map(l=>[l.y,l.x])})})})})})},hhn=({pinCount:t,leadLength:e,leadWidth:n,pitch:i,bodyWidth:r})=>{const o=Math.ceil(t/2),s=(o-1)*i/2,a=.25,c=1,l=.8,u=e*0,d=i*(o-1)+n+.2,h=r*.55;return z0(Wy,{children:[Array.from({length:o}).map((f,m)=>ui(hv,{position:{x:-r/2-u,y:m*i-s,z:a/2},width:n,thickness:a,padContactLength:e/2,bodyDistance:e+.2,height:l})),Array.from({length:o}).map((f,m)=>ui(hv,{rotation:Math.PI,position:{x:r/2+u,y:m*i-s,z:a/2},width:n,thickness:a,padContactLength:e/2,bodyDistance:e+.2,height:l})),ui(BA,{center:{x:0,y:0,z:a/2},width:h,length:d,height:c})]})},phn=({pinCount:t,pitch:e,leadWidth:n,leadLength:i,bodyWidth:r,bodyLength:o})=>{const s=t===8?{pitch:.65,leadWidth:.3}:{pitch:.5,leadWidth:.225},a=isNaN(parseFloat(e))?s.pitch:parseFloat(e),c=isNaN(parseFloat(n))?s.leadWidth:parseFloat(n)*.8,l=isNaN(parseFloat(r))?2.6:parseFloat(r)*.8,u=isNaN(parseFloat(o))?2+Number(a)*1.4:parseFloat(o),d=t/2,h=(d-1)*a/2,f=.15,m=.8,y=4.5,g=(y-l)/2,b=g*.5;return z0(Wy,{children:[Array.from({length:d}).map((v,w)=>ui(hv,{position:{x:-y/2,y:h-w*a,z:f/2},width:c,thickness:f,padContactLength:b+.05,bodyDistance:g+.05,height:m})),Array.from({length:d}).map((v,w)=>ui(hv,{rotation:Math.PI,position:{x:y/2,y:h-w*a,z:f/2},width:c,thickness:f,padContactLength:b+.05,bodyDistance:g+.05,height:m})),ui(BA,{center:{x:0,y:0,z:f/2},width:l,length:u,height:1})]})},fhn=({footprint:t})=>{const e=Ddn.string(t).json();switch(e.fn){case"dip":return ui($dn,{numPins:e.num_pins,pitch:e.p,bodyWidth:e.w});case"tssop":return ui(Hdn,{pinCount:e.num_pins,leadLength:e.pl,leadWidth:e.pw,pitch:e.p,bodyWidth:e.w});case"vssop":return ui(phn,{pinCount:e.num_pins,leadLength:e.pl,leadWidth:e.pw,pitch:e.p,bodyWidth:e.w,bodyLength:e.h});case"qfp":return ui(qdn,{pinCount:e.num_pins,pitch:e.p,leadWidth:e.pw,padContactLength:e.pl,bodyWidth:e.w});case"qfn":return ui(thn,{num_pins:e.num_pins,bodyWidth:e.w,bodyLength:e.h,pitch:e.p,padLength:e.pl,padWidth:e.pw,thermalPadSize:{width:e.thermalpad.x,length:e.thermalpad.y}});case"pinrow":if(e.male)return ui(Kdn,{numberOfPins:e.num_pins,pitch:e.p});if(e.female)return ui(uhn,{numberOfPins:e.num_pins,pitch:e.p});case"cap":switch(e.imperial){case"0402":return ui(zqe,{color:"#856c4d"});case"0603":return ui(Fqe,{color:"#856c4d"});case"0805":return ui(Bqe,{color:"#856c4d"});case"0201":return ui(Uqe,{color:"#856c4d"});case"01005":return ui($qe,{color:"#856c4d"});case"1206":return ui(jqe,{color:"#856c4d"});case"1210":return ui(Hqe,{color:"#856c4d"});case"2010":return ui(Vqe,{color:"#856c4d"});case"2512":return ui(Gqe,{color:"#856c4d"})}case"sot235":return ui(ihn,{});case"pushbutton":return ui(dhn,{width:e.w,length:e.h,innerDiameter:e.id});case"soic":return ui(hhn,{pinCount:e.num_pins,leadLength:e.pl,leadWidth:e.pw,pitch:e.p,bodyWidth:e.w})}switch(e.imperial){case"0402":return ui(zqe,{});case"0603":return ui(Fqe,{});case"0805":return ui(Bqe,{});case"0201":return ui(Uqe,{});case"01005":return ui($qe,{});case"1206":return ui(jqe,{});case"1210":return ui(Hqe,{});case"2010":return ui(Vqe,{});case"2512":return ui(Gqe,{})}return null},mhn=t=>t&&typeof t=="object"&&"type"in t,WA=t=>{if(typeof t=="number")return t;if(typeof t=="string"){const e=/^(-?\d+(?:\.\d+)?)\s*deg$/i.exec(t);if(e)return parseFloat(e[1])*Math.PI/180;const n=Number(t);if(!Number.isNaN(n))return n}return 0},_hn=t=>Array.isArray(t)?[Number(t[0])||0,Number(t[1])||0,Number(t[2])||0]:typeof t=="object"&&t?[Number(t.x)||0,Number(t.y)||0,Number(t.z)||0]:[0,0,0];function Pw(t,e){if(t==null||t===!1)return[];if(Array.isArray(t))return t.flatMap(o=>Pw(o,e));if(!mhn(t))return[];const{type:n,props:i,children:r}=t;if(n===Nqe)return(r??[]).flatMap(o=>Pw(o,e));if(n===s3){const o=i?.color;return(r??[]).flatMap(s=>Pw(s,o??e))}if(n===X4){const o=_hn(i?.offset??{x:i?.x,y:i?.y,z:i?.z});return(r??[]).flatMap(a=>Pw(a,e)).map(({geom:a,color:c})=>({geom:dv.transforms.translate(o,a),color:c??e}))}if(n===NI){const o=Array.isArray(i?.rotation)?[WA(i.rotation[0]),WA(i.rotation[1]),WA(i.rotation[2])]:[WA(i?.x??0),WA(i?.y??0),WA(i?.z??0)];return(r??[]).flatMap(a=>Pw(a,e)).map(({geom:a,color:c})=>({geom:dv.transforms.rotateZ(o[2],dv.transforms.rotateY(o[1],dv.transforms.rotateX(o[0],a))),color:c}))}if(n===Lqe||n===T0e||n===cj){const o=(r??[]).flatMap(a=>Pw(a,e)).map(a=>a.geom);if(o.length===0)return[];let s;return n===Lqe?s=dv.booleans.union(o):n===T0e?s=dv.booleans.subtract(o[0],o.slice(1)):s=dv.hulls.hull(o),[{geom:s}]}if(n===kI){const o=i?.points??[];return[{geom:dv.geometries.geom2.fromPoints(o),color:e??i?.color}]}if(n===OI){const o=(r??[]).flatMap(l=>Pw(l,e)).map(l=>l.geom);if(o.length===0)return[];const s=o.length>1?dv.booleans.union(o):o[0],a=i?.height??i?.h??1;return[{geom:dv.extrusions.extrudeLinear({height:a},s),color:e??i?.color}]}if(n===Oc||n===kqe||n===q4||n===Oqe||n===aj){let o;if(n===Oc){const s=i?.size??[1,1,1],a=i?.offset,c=i?.center??(a?[a[0],a[1],a[2]]:[0,0,0]);o=dv.primitives.cuboid({size:s,center:c})}else if(n===kqe){const s=i?.size??1,a=i?.offset,c=i?.center??(a?[a[0],a[1],a[2]]:[0,0,0]);o=dv.primitives.cube({size:s,center:c})}else if(n===q4){const s=i?.height??1,a=i?.radius??1,c=i?.center??[0,0,0];o=dv.primitives.cylinder({height:s,radius:a,center:c})}else if(n===Oqe){const s=i?.radius??1,a=i?.center??[0,0,0];o=dv.primitives.sphere({radius:s,center:a})}else{const s=i?.size??[1,1,1],a=i?.roundRadius??.1,c=i?.center??[0,0,0];o=dv.primitives.roundedCuboid({size:s,roundRadius:a,center:c})}return[{geom:o,color:e??i?.color}]}if(typeof n=="function"){const o=n(i??{});return Pw(o,e)}return(r??[]).flatMap(o=>Pw(o,e))}function yhn(t){return{geometries:Pw(t)}}function Yqe(t){if(t.polygons){const e=[],n=[],i=[];let r=0;for(const s of t.polygons){for(const c of s.vertices)c.index=r,e.push(c[0],c[1],c[2]),t.color&&t.color.length>=3?i.push(t.color[0],t.color[1],t.color[2]):i.push(1,1,1),r++;const a=s.vertices[0].index;for(let c=2;c<s.vertices.length;c++){const l=s.vertices[c-1].index,u=s.vertices[c].index;n.push(a,l,u)}}const o=new Sf;if(o.setAttribute("position",new f0(new Float32Array(e),3)),o.setIndex(n),i.length>0&&o.setAttribute("color",new f0(new Float32Array(i),3)),t.transforms){const s=new Xa;s.fromArray(t.transforms),o.applyMatrix4(s)}return o.computeVertexNormals(),o}if(t.sides){const e=[],n=[];for(const r of t.sides)e.push(r[0][0],r[0][1],0),t.color&&t.color.length>=3?n.push(t.color[0],t.color[1],t.color[2]):n.push(1,1,1);const i=new Sf;if(i.setAttribute("position",new f0(new Float32Array(e),3)),n.length>0&&i.setAttribute("color",new f0(new Float32Array(n),3)),t.transforms){const r=new Xa;r.fromArray(t.transforms),i.applyMatrix4(r)}return i}return console.error("Invalid CSG object: neither polygons nor sides found"),new Sf}function ghn(t){const e=E0e(fhn,{footprint:t});return yhn(e)}var bhn=({jscadPlan:t,positionOffset:e,rotationOffset:n,onHover:i,onUnhover:r,isHovered:o,scale:s})=>{const{rootObject:a}=Nx(),{threeGeom:c,material:l}=Ee.useMemo(()=>{const d=(0,don.executeJscadOperations)(hon.default,t);if(!d||!d.polygons&&!d.sides)return{threeGeom:null,material:null};const h=Yqe(d),f=new N9({vertexColors:!0,side:x1});return{threeGeom:h,material:f}},[t]),u=Ee.useMemo(()=>c?new pd(c,l):null,[c,l]);return Ee.useEffect(()=>{if(!(!u||!a))return a.add(u),()=>{a.remove(u)}},[a,u]),Ee.useEffect(()=>{u&&(e&&u.position.fromArray(e),n&&u.rotation.fromArray(n),s!==void 0&&u.scale.setScalar(s))},[u,e?.[0],e?.[1],e?.[2],n?.[0],n?.[1],n?.[2],s]),Ee.useMemo(()=>{if(l)if(o){const d=new eo(l.color.getHex());l.emissive.copy(d),l.emissive.setRGB(0,0,1),l.emissiveIntensity=.2}else l.emissiveIntensity=0},[o,l]),c?ye.jsx(CI,{isHovered:o,onHover:i,onUnhover:r,object:u}):null},xhn=({positionOffset:t,footprint:e,rotationOffset:n,onHover:i,onUnhover:r,isHovered:o,scale:s})=>{const{rootObject:a}=Nx(),c=Ee.useMemo(()=>{if(!e)return null;const{geometries:l}=ghn(e),u=new I9;for(const d of l.flat(1/0)){const h=d.geom;if(!h||!h.polygons&&!h.sides)continue;const f=new eo(d.color);f.convertLinearToSRGB();const m={...h,color:[f.r,f.g,f.b]},y=Yqe(m),g=new N9({vertexColors:!0,side:x1}),b=new pd(y,g);u.add(b)}return u},[e]);return Ee.useEffect(()=>{if(!(!c||!a))return a.add(c),()=>{a.remove(c)}},[a,c]),Ee.useEffect(()=>{c&&(t&&c.position.fromArray(t),n&&c.rotation.fromArray(n),s!==void 0&&c.scale.setScalar(s))},[c,t?.[0],t?.[1],t?.[2],n?.[0],n?.[1],n?.[2],s]),Ee.useEffect(()=>{c&&c.traverse(l=>{l instanceof pd&&l.material instanceof N9&&(o?(l.material.emissive.setHex(255),l.material.emissiveIntensity=.2):l.material.emissiveIntensity=0)})},[o,c]),c?ye.jsx(CI,{isHovered:o,onHover:i,onUnhover:r,object:c}):null},vhn=(...t)=>t,qqe=({children:t,position:e,style:n})=>{const{camera:i,renderer:r}=Nx(),o=Ee.useRef(document.createElement("div")),[s,a]=Ee.useState(null);return Ee.useEffect(()=>{const c=r?.domElement.parentNode;if(c)return c.style.position!=="relative"&&c.style.position!=="absolute"&&(c.style.position="relative"),c.appendChild(o.current),a(HW.createPortal(t,o.current)),()=>{c.contains(o.current)&&c.removeChild(o.current)}},[r,t]),AI(()=>{if(!i||!o.current||!r)return;const c=new tn(...e);c.project(i);const l=r.domElement.getBoundingClientRect(),u=Math.round((c.x+1)/2*l.width),d=Math.round((-c.y+1)/2*l.height);o.current.style.position="absolute",o.current.style.left=`${u}px`,o.current.style.top=`${d}px`,o.current.style.pointerEvents="none",o.current.style.zIndex="1000",n&&Object.assign(o.current.style,n)},[i,r,e,n]),s},Xqe=({cad_component:t,circuitJson:e})=>{const[n,i]=Ee.useState(!1),[r,o]=Ee.useState(null),s=Ee.useCallback(f=>{f?.mousePosition?(i(!0),o(f.mousePosition)):(i(!1),o(null))},[]),a=Ee.useCallback(()=>{i(!1),o(null)},[]),c=Ee.useMemo(()=>ea(e).source_component.getUsing({source_component_id:t.source_component_id})?.name,[e,t.source_component_id]),l=t.model_obj_url??t.model_wrl_url??t.model_stl_url,u=t.model_glb_url??t.model_gltf_url,d=t.rotation?vhn(t.rotation.x*Math.PI/180,t.rotation.y*Math.PI/180,t.rotation.z*Math.PI/180):void 0;let h=null;return l?h=ye.jsx(lon,{url:l,position:t.position?[t.position.x,t.position.y,t.position.z]:void 0,rotation:d,scale:t.model_unit_to_mm_scale_factor,onHover:s,onUnhover:a,isHovered:n},t.cad_component_id):u?h=ye.jsx(uon,{gltfUrl:u,position:t.position?[t.position.x,t.position.y,t.position.z]:void 0,rotation:d,scale:t.model_unit_to_mm_scale_factor,onHover:s,onUnhover:a,isHovered:n},t.cad_component_id):t.model_jscad?h=ye.jsx(bhn,{jscadPlan:t.model_jscad,rotationOffset:d,scale:t.model_unit_to_mm_scale_factor,onHover:s,onUnhover:a,isHovered:n},t.cad_component_id):t.footprinter_string&&(h=ye.jsx(xhn,{positionOffset:t.position?[t.position.x,t.position.y,t.position.z]:void 0,rotationOffset:d,footprint:t.footprinter_string,scale:t.model_unit_to_mm_scale_factor,onHover:s,onUnhover:a,isHovered:n})),ye.jsxs(ye.Fragment,{children:[h,n&&r?ye.jsx(qqe,{position:r,style:{fontFamily:"sans-serif",transform:"translate3d(1rem, 1rem, 0)",backgroundColor:"white",padding:"5px",borderRadius:"3px",pointerEvents:"none",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},children:c??"<unknown>"}):null]})},Wqe={version:"0.0.402"},aM=({children:t,parent:e,position:n,rotation:i,scale:r,color:o,fontSize:s,anchorX:a,anchorY:c,depthOffset:l})=>{const{rootObject:u}=Nx(),d=Ee.useMemo(()=>{const h=new hAe;return h.text=t,n&&h.position.fromArray(n),i&&h.rotation.fromArray(i),r&&h.scale.fromArray(r),h.color=o||"white",h.fontSize=s||1,h.anchorX=a||"center",h.anchorY=c||"middle",h.depthOffset=l||0,h.font=null,h.sync(),h},[t,n,i,r,o,s,a,c,l]);return Ee.useEffect(()=>{const h=e||u;if(!(!h||!d))return h.add(d),()=>{h.remove(d),d.dispose()}},[u,e,d]),null};typeof window<"u"&&(window.TSCI_MAIN_CAMERA_ROTATION=new A9(0,0,0));function whn(t,e){const n=new y2().setFromEuler(new A9(t.x,t.y,t.z)),i=new tn(0,0,1);return i.applyQuaternion(n),i.multiplyScalar(e)}var Shn=({})=>{const{camera:t,scene:e}=Nx();Ee.useEffect(()=>{if(!e)return;const i=new m6e(16777215,Math.PI/2);return e.add(i),()=>{e.remove(i)}},[e]),AI(()=>{if(!t)return;const i=window.TSCI_MAIN_CAMERA_ROTATION,r=whn(i,2);t.position.copy(r),t.lookAt(0,0,0)});const n=Ee.useMemo(()=>{const i=new I9;i.rotation.fromArray([Math.PI/2,0,0]);const r=new pd(new uw(1,1,1),new N9({color:"white"}));i.add(r);const o=new eP(new Wwt(new uw(1,1,1)),new RT({color:0,linewidth:2}));return i.add(o),i},[]);return Ee.useEffect(()=>{if(e)return e.add(n),()=>{e.remove(n)}},[e,n]),ye.jsxs(ye.Fragment,{children:[ye.jsx(aM,{parent:n,position:[0,0,.51],fontSize:.25,color:"black",children:"Front"}),ye.jsx(aM,{parent:n,position:[0,0,-.51],fontSize:.25,color:"black",rotation:[0,Math.PI,0],children:"Back"}),ye.jsx(aM,{parent:n,position:[.51,0,0],fontSize:.25,color:"black",rotation:[0,Math.PI/2,0],children:"Right"}),ye.jsx(aM,{parent:n,position:[-.51,0,0],fontSize:.25,color:"black",rotation:[0,-Math.PI/2,0],children:"Left"}),ye.jsx(aM,{parent:n,position:[0,.51,0],fontSize:.25,color:"black",rotation:[-Math.PI/2,0,0],children:"Top"}),ye.jsx(aM,{parent:n,position:[0,-.51,0],fontSize:.25,color:"black",rotation:[Math.PI/2,0,0],children:"Bottom"})]})};function Ehn(t){t.querySelectorAll("canvas").forEach(e=>e.remove())}var Zqe=Ee.forwardRef(({children:t,scene:e,camera:n,style:i},r)=>{const o=Ee.useRef(null),[s,a]=Ee.useState(null),c=Ee.useRef([]),l=Ee.useCallback(f=>{c.current.push(f)},[]),u=Ee.useCallback(f=>{c.current=c.current.filter(m=>m!==f)},[]),d=Ee.useMemo(()=>new ZR,[]);e?.up&&d.up.set(e.up.x,e.up.y,e.up.z);const h=Ee.useRef(new p0);return Ee.useImperativeHandle(r,()=>h.current),Ee.useEffect(()=>{if(!o.current)return;Ehn(o.current);const f=new F8e({antialias:!0,alpha:!0});f.setSize(o.current.clientWidth,o.current.clientHeight),f.setPixelRatio(window.devicePixelRatio),o.current.appendChild(f.domElement);const m=new Ax(75,o.current.clientWidth/o.current.clientHeight,.1,1e3);n?.up&&m.up.set(n.up[0],n.up[1],n.up[2]),n?.position&&m.position.set(n.position[0],n.position[1],n.position[2]),m.lookAt(0,0,0),d.add(h.current),window.__TSCIRCUIT_THREE_OBJECT=h.current,a({scene:d,camera:m,renderer:f,rootObject:h.current,addFrameListener:l,removeFrameListener:u});let y;const g=new NSt,b=()=>{const w=g.getElapsedTime(),T=g.getDelta();c.current.forEach(N=>N(w,T)),f.render(d,m),y=requestAnimationFrame(b)};b();const v=()=>{o.current&&(m.aspect=o.current.clientWidth/o.current.clientHeight,m.updateProjectionMatrix(),f.setSize(o.current.clientWidth,o.current.clientHeight))};return window.addEventListener("resize",v),()=>{window.removeEventListener("resize",v),cancelAnimationFrame(y),o.current&&f.domElement&&o.current.removeChild(f.domElement),f.dispose(),d.remove(h.current),window.__TSCIRCUIT_THREE_OBJECT===h.current&&(window.__TSCIRCUIT_THREE_OBJECT=void 0)}},[d,l,u]),ye.jsx("div",{ref:o,style:{width:"100%",height:"100%",...i},children:s&&ye.jsx(kYe.Provider,{value:s,children:ye.jsx(ron,{children:t})})})}),Thn=({autoRotate:t,autoRotateSpeed:e,onStart:n,panSpeed:i,rotateSpeed:r,zoomSpeed:o,enableDamping:s,dampingFactor:a,target:c})=>{const{camera:l,renderer:u}=Nx(),d=Ee.useMemo(()=>!l||!u?null:new iEt(l,u.domElement),[l,u]);return Ee.useEffect(()=>{d&&(d.autoRotate=t||!1,d.autoRotateSpeed=e||1,i!==void 0&&(d.panSpeed=i),r!==void 0&&(d.rotateSpeed=r),o!==void 0&&(d.zoomSpeed=o),s!==void 0&&(d.enableDamping=s),a!==void 0&&(d.dampingFactor=a),d.zoomToCursor=!0,c&&(d.target.set(c[0],c[1],c[2]),d.update()))},[d,t,e,i,r,o,s,a,c]),Ee.useEffect(()=>{if(!(!d||!n))return d.addEventListener("start",n),()=>{d.removeEventListener("start",n)}},[d,n]),Ee.useEffect(()=>{if(d)return()=>{d.dispose()}},[d]),AI(()=>{d?.update()},[d]),null},Mhn=`
5084
5084
  varying vec3 worldPosition;
5085
5085
  void main() {
5086
5086
  worldPosition = (modelMatrix * vec4(position, 1.0)).xyz;
@@ -5502,7 +5502,7 @@ $1`).replace(/>(\s*)(?=<!--\s*\/)/g,"> ")}}}),sye={};t5n(sye,{all_layers:()=>zye
5502
5502
  transition: opacity 0.2s;
5503
5503
  margin-bottom: 10px;
5504
5504
  color: red;
5505
- `,r3n=({children:t,transform:e=h0(),elements:n})=>{const i=Ee.useRef(null),{isShowingDRCErrors:r,hoveredErrorId:o}=yv(l=>({isShowingDRCErrors:l.is_showing_drc_errors,hoveredErrorId:l.hovered_error_id}));if(!n)return ye.jsx("div",{style:{position:"relative"},ref:i,children:t});const s=n.filter(l=>l.type==="pcb_trace_error"),a=n.filter(l=>l.type==="pcb_trace_error"&&l.message?.includes("Multiple components found with name")),c=new Map;return n.forEach(l=>{l.type==="pcb_port"&&c.set(l.pcb_port_id,l)}),ye.jsxs("div",{style:{position:"relative"},ref:i,children:[t,s.map((l,u)=>{const{pcb_port_ids:d,pcb_trace_id:h}=l,f=d?.[0]?c.get(d[0]):void 0,m=d?.[1]?c.get(d[1]):void 0,y=n?dE(n).pcb_trace.get(h):void 0,g=l.pcb_trace_error_id||`error_${u}_${l.error_type}_${l.message?.slice(0,20)}`,b=o===g;if(f&&m){const v=Yt(e,{x:f.x,y:f.y}),w=Yt(e,{x:m.x,y:m.y}),T=!(isNaN(v.x)||isNaN(v.y)||isNaN(w.x)||isNaN(w.y)),N={x:(v.x+w.x)/2,y:(v.y+w.y)/2};if(isNaN(N.x)||isNaN(N.y))return null;const R=Gye(N,i);return ye.jsxs(Ee.Fragment,{children:[ye.jsx(n3n,{screenPort1:v,screenPort2:w,errorCenter:N,canLineBeDrawn:T,isHighlighted:b}),ye.jsx("div",{style:{position:"absolute",left:N.x-15,top:N.y-15,width:30,height:30,zIndex:Wm.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:P=>{const M=P.currentTarget.nextElementSibling;if(M){const I=M.querySelector(".error-message");I&&(I.style.opacity="1")}},onMouseLeave:P=>{if(!b){const M=P.currentTarget.nextElementSibling;if(M){const I=M.querySelector(".error-message");I&&(I.style.opacity="0")}}}}),ye.jsx("div",{style:{position:"absolute",zIndex:b?200:100,left:R.left,top:R.top,color:b?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:r||b?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:R.transform},children:ye.jsx("div",{className:`error-message ${Yye}`,style:{opacity:b?1:0,border:`1px solid ${b?"#ff4444":"red"}`},children:l.message})})]},g)}if(y?.route&&(r||b)){const v=y.route.map(R=>Yt(e,{x:R.x,y:R.y}));if(v.some(R=>isNaN(R.x)||isNaN(R.y)))return null;const w=Math.floor(v.length/2),T=v[w],N=Gye(T,i);return ye.jsxs(Ee.Fragment,{children:[ye.jsx(i3n,{points:v,errorCenter:T,isHighlighted:b}),ye.jsx("div",{style:{position:"absolute",left:T.x-15,top:T.y-15,width:30,height:30,zIndex:Wm.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:R=>{const P=R.currentTarget.nextElementSibling;if(P){const M=P.querySelector(".error-message");M&&(M.style.opacity="1")}},onMouseLeave:R=>{if(!b){const P=R.currentTarget.nextElementSibling;if(P){const M=P.querySelector(".error-message");M&&(M.style.opacity="0")}}}}),ye.jsx("div",{style:{position:"absolute",zIndex:b?Wm.errorOverlay+10:Wm.errorOverlay+1,left:N.left,top:N.top,color:b?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:"flex",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:N.transform},children:ye.jsx("div",{className:`error-message ${Yye}`,style:{opacity:b?1:0,border:`1px solid ${b?"#ff4444":"red"}`},children:l.message})})]},g)}return null}),a.map((l,u)=>{const d=l.component_name||l.message?.match(/name "([^"]+)"/)?.[1];if(!d)return null;const h=n?.filter(y=>y.type==="source_component"&&y.name===d||y.type==="pcb_component"&&n?.find(g=>g.type==="source_component"&&g.source_component_id===y.source_component_id&&g.name===d))||[],f=l.pcb_trace_error_id||`error_${u}_${l.error_type}_${l.message?.slice(0,20)}`,m=o===f;return!m&&!r?null:h.map((y,g)=>{let b={x:0,y:0};if(y.type==="pcb_component")b=y.center||{x:0,y:0};else if(y.type==="source_component"){const I=n?.find(A=>A.type==="pcb_component"&&A.source_component_id===y.source_component_id);I&&I.type==="pcb_component"&&(b=I.center||{x:0,y:0})}const v=Yt(e,b);if(isNaN(v.x)||isNaN(v.y))return null;const w=Math.abs(e.a),P=Math.max(8,Math.min(30,.5*w)),M=Gye(v,i);return ye.jsxs(Ee.Fragment,{children:[ye.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:Wm.errorOverlay},width:"100%",height:"100%",children:m?ye.jsx("polygon",{points:`${v.x},${v.y-P*1.25} ${v.x+P},${v.y} ${v.x},${v.y+P*1.25} ${v.x-P},${v.y}`,fill:"#ff4444"}):ye.jsx("circle",{cx:v.x,cy:v.y,r:P,fill:"none",stroke:m?"#ff4444":"red",strokeWidth:m?Math.max(2,P*.15):Math.max(1,P*.1),opacity:1})}),ye.jsx("div",{style:{position:"absolute",left:v.x-(P+10),top:v.y-(P+10),width:(P+10)*2,height:(P+10)*2,zIndex:Wm.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:I=>{const A=I.currentTarget.nextElementSibling;if(A){const $=A.querySelector(".error-message");$&&($.style.opacity="1")}},onMouseLeave:I=>{if(!m){const A=I.currentTarget.nextElementSibling;if(A){const $=A.querySelector(".error-message");$&&($.style.opacity="0")}}}}),ye.jsx("div",{style:{position:"absolute",zIndex:m?Wm.errorOverlay+20:Wm.errorOverlay+10,left:M.left,top:M.top,color:m?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:r||m?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:M.transform},children:ye.jsx("div",{className:`error-message ${Yye}`,style:{opacity:m?1:0,border:`1px solid ${m?"#ff4444":"red"}`},children:l.message})})]},`${f}_${g}`)})})]})};function o3n({primitiveElement:t,elements:e}){let n=t.trace_length?`${t.trace_length.toFixed(3)}`:"";const i=dE(e).source_trace.get(t?.source_trace_id);if(i?.display_name&&(i?.max_length?n+=` / ${i.max_length}mm `:n+=" mm ",n+=`(${i.display_name})`),!n)return null;const r=t.trace_length&&i?.max_length&&t.trace_length>i.max_length;return{text:n,isOverLength:r}}function s3n(t){const{primitives:e,is_showing_multiple_traces_length:n,elements:i}=t,r=e.filter(c=>c._element.type==="pcb_trace"),o=i.filter(c=>c.type==="source_trace"),s=e.filter(c=>c._element.type!=="pcb_trace"),a=r.filter(c=>o.some(l=>c._element.type==="pcb_trace"&&c._element.source_trace_id===l.source_trace_id&&l.max_length!==void 0));if(!n)return[...s,...a];if(r.length>1){const c=r.reduce((l,u)=>{const d=l._element.trace_length;return u._element.trace_length<d?u:l},r[0]);return[...s,c]}return e}var a3n={position:"absolute",left:0,top:0,pointerEvents:"none",color:"red",fontFamily:"sans-serif",fontSize:12,textShadow:"0 0 2px black"},c3n=t=>{const{_element:e,_parent_pcb_component:n,_parent_source_component:i,_source_port:r}=t;switch(e.type){case"pcb_trace":return e.trace_length?`${e.trace_length.toFixed(3)}`:"";case"pcb_smtpad":case"pcb_plated_hole":{let o="";const s=Array.from(new Set((e.port_hints??[]).concat(r?.port_hints??[]))).filter(a=>!/^[0-9]+$/.test(a)).sort((a,c)=>c.localeCompare(a));return i&&"name"in i&&i.name&&(o+=`.${i.name}`,s.length>0&&(o+=" > ")),s.length>0&&(o+=s.map(a=>`.${a}`).join(", ")),o}default:return""}},l3n={top:"red",bottom:"aqua"},u3n=({primitive:t,mousePos:e,elements:n})=>{const[i,r]=Ee.useState(!1),o=t._element;Ee.useEffect(()=>{setTimeout(()=>{r(!0)},100)},[]);const[s,a,c,l]=[t.screen_x,t.screen_y,t.screen_w,t.screen_h],u=t.same_space_index??0,d=26,h=l3n[t?._element?.layer]??"red";let f=0;if(o.type==="pcb_smtpad"&&o?.shape==="rotated_rect"?f=o?.ccw_rotation??0:(o.type==="pcb_smtpad"&&(o?.shape==="pill"||o?.shape==="rotated_pill")&&"ccw_rotation"in t||o.type==="pcb_plated_hole"&&(o?.shape==="pill"||o?.shape==="oval")&&"ccw_rotation"in t)&&(f=o.ccw_rotation??0),o.type==="pcb_trace"){const y=o3n({primitiveElement:o,elements:n});if(!y)return null;const g=e.y-35;return ye.jsx("div",{style:{zIndex:Wm.elementOverlay,position:"absolute",left:e.x,top:g,color:h,pointerEvents:"none",transform:"translateX(-50%)"},children:ye.jsx("div",{style:{backgroundColor:"#f2efcc",color:y.isOverLength?"red":"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",minWidth:"45px",textAlign:"center",whiteSpace:"nowrap"},children:y.text})})}return ye.jsx("div",{style:{zIndex:Wm.elementOverlay,position:"absolute",left:s-c/2-8,top:a-l/2-8,width:c+16,height:l+16,color:h,transform:`rotate(${-f}deg)`,transformOrigin:"center center"},children:ye.jsx("div",{style:{width:i?`calc(100% + ${d*2*u}px)`:"100%",height:i?`calc(100% + ${d*2*u}px)`:"100%",marginLeft:i?`${-d*u}px`:0,marginTop:i?`${-d*u}px`:0,border:`1px solid ${h}`,opacity:i||u===0?1:0,transition:"width 0.2s, height 0.2s, margin-left 0.2s, margin-top 0.2s, opacity 0.2s"},children:ye.jsx("div",{style:{position:"absolute",bottom:l+20+d*u,marginRight:i?`${-d*u}px`:0,marginBottom:i?0:-d*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(${f}deg)`,minWidth:"45px",textAlign:"center"},children:c3n(t)})})})},d3n=({highlightedPrimitives:t,mousePos:e,elements:n})=>{const[i,r]=yv(a=>[a.is_moving_component,a.is_showing_multiple_traces_length]),o=t.some(a=>a._element.type==="pcb_smtpad")&&t.some(a=>a._element.type==="pcb_trace");let s=t;return o&&(s=s.filter(a=>a._element.type==="pcb_smtpad")),s=s3n({primitives:s,is_showing_multiple_traces_length:r,elements:n}),ye.jsx("div",{style:a3n,children:!i&&s.map((a,c)=>ye.jsx(u3n,{primitive:a,mousePos:e,elements:n},c))})};function h3n(t,e){return t.size!==e.size?!1:Array.from(t).every(n=>e.has(n))}function p3n(t,e,n){const i=(n.x-e.x)**2+(n.y-e.y)**2;if(i===0)return Lnt(t,e);let r=((t.x-e.x)*(n.x-e.x)+(t.y-e.y)*(n.y-e.y))/i;r=Math.max(0,Math.min(1,r));const o={x:e.x+r*(n.x-e.x),y:e.y+r*(n.y-e.y)};return Lnt(t,o)}function Lnt(t,e){const n=t.x-e.x,i=t.y-e.y;return Math.sqrt(n*n+i*i)}var f3n=(t,e,n)=>{const i=[];for(const r of t){if(!r._element)continue;if("x1"in r&&r._element?.type==="pcb_trace"){const a=p3n({x:e.x,y:e.y},{x:r.x1,y:r.y1},{x:r.x2,y:r.y2}),c=r.width||.5,l=Math.max(c*25,2)/n.a;a<l&&i.push(r);continue}if(!("x"in r&&"y"in r))continue;let o=0,s=0;if("w"in r&&"h"in r)o=r.w,s=r.h;else if("r"in r)o=r.r*2,s=r.r*2;else continue;Math.abs(r.x-e.x)<o/2&&Math.abs(r.y-e.y)<s/2&&i.push(r)}return i},m3n=({elements:t,children:e,transform:n,primitives:i,onMouseHoverOverPrimitives:r})=>{const[o,s]=Ee.useState([]),[a,c]=Ee.useState({x:0,y:0}),l=Ee.useMemo(()=>{const d=[];for(const h of o){if(h._element?.type==="pcb_via"||h._element?.type==="pcb_component"||h?.layer==="drill")continue;const f=Yt(n,h),m="w"in h?h.w:"r"in h?h.r*2:0,y="h"in h?h.h:"r"in h?h.r*2:0,g={w:m*n.a,h:y*n.a},b=d.filter(v=>f.x===v.screen_x&&f.y===v.screen_y&&g.w===v.screen_w&&g.h===v.screen_h).length;d.push({...h,screen_x:f.x,screen_y:f.y,screen_w:g.w,screen_h:g.h,same_space_index:b})}return d},[o,n]),u=(d,h,f,m)=>{c({x:d,y:h});const y=Yt(n5(f),{x:d,y:h}),g=f3n(m,y,f);h3n(new Set(g.map(b=>b._pcb_drawing_object_id)),new Set(o.map(b=>b._pcb_drawing_object_id)))||(s(g),r(g))};return ye.jsxs("div",{style:{position:"relative"},onMouseMove:d=>{if(n){const h=d.currentTarget.getBoundingClientRect(),f=d.clientX-h.left,m=d.clientY-h.top;u(f,m,n,i)}},onTouchStart:d=>{if(n){const h=d.touches[0],f=d.currentTarget.getBoundingClientRect(),m=h.clientX-f.left,y=h.clientY-f.top;u(m,y,n,i)}},children:[e,ye.jsx(d3n,{elements:t,mousePos:a,highlightedPrimitives:l})]})},Dnt=["rgb(255, 100, 100)","rgb(100, 255, 100)","rgb(100, 100, 255)","rgb(255, 255, 100)","rgb(255, 100, 255)","rgb(100, 255, 255)","rgb(255, 150, 100)","rgb(150, 100, 255)","rgb(100, 255, 150)","rgb(255, 100, 150)"],_3n=({children:t,transform:e=h0(),elements:n=[]})=>{const[i,{width:r,height:o}]=eV(),s=Ee.useRef(null),a=yv(c=>c.is_showing_pcb_groups);return Ee.useEffect(()=>{const c=s.current;if(!c||!r||!o)return;c.width=r,c.height=o;const l=c.getContext("2d");if(!l||(l.clearRect(0,0,r,o),!a))return;const u=n.filter(g=>g.type==="pcb_group"),d=n.filter(g=>g.type==="pcb_component"),h=n.filter(g=>g.type==="source_group"),f=new Map;h.forEach(g=>{const b=g;if(b.parent_source_group_id){const v=f.get(b.parent_source_group_id)||[];v.push(g.source_group_id),f.set(b.parent_source_group_id,v)}});const m=g=>{const b=[],v=f.get(g)||[];for(const w of v)b.push(w),b.push(...m(w));return b},y=g=>{const b=h.find(v=>v.source_group_id===g);return b?.parent_source_group_id?1+y(b.parent_source_group_id):0};u.forEach((g,b)=>{let v=d.filter(Je=>Je.pcb_group_id===g.pcb_group_id);if(g.source_group_id){const Je=m(g.source_group_id),st=u.filter(Se=>Se.source_group_id&&Je.includes(Se.source_group_id));for(const Se of st){const ut=d.filter(Ke=>Ke.pcb_group_id===Se.pcb_group_id);v=[...v,...ut]}}if(v.length===0)return;let w=1/0,T=1/0,N=-1/0,R=-1/0;if(v.forEach(Je=>{if(Je.center&&typeof Je.width=="number"&&typeof Je.height=="number"){const st=Je.center.x-Je.width/2,Se=Je.center.x+Je.width/2,ut=Je.center.y+Je.height/2,Ke=Je.center.y-Je.height/2;w=Math.min(w,st),N=Math.max(N,Se),T=Math.min(T,Ke),R=Math.max(R,ut)}}),w===1/0||N===-1/0)return;const P=g.source_group_id?y(g.source_group_id):0,M=g.source_group_id?m(g.source_group_id).length>0:!1,$=1+(M?.5:0);w-=$,N+=$,T-=$,R+=$;const k=Yt(e,{x:w,y:R}),V=Yt(e,{x:N,y:R}),X=Yt(e,{x:w,y:T}),W=Yt(e,{x:N,y:T}),K=Dnt[b%Dnt.length];l.strokeStyle=K,l.lineWidth=2;const te=Math.max(4,Math.min(12,8*Math.abs(e.a))),se=Math.max(2,Math.min(6,4*Math.abs(e.a))),be=te*(M?1.3:1),re=se;l.setLineDash([be,re]),l.beginPath(),l.moveTo(k.x,k.y),l.lineTo(V.x,V.y),l.lineTo(W.x,W.y),l.lineTo(X.x,X.y),l.closePath(),l.stroke();const ue=Math.max(8,Math.min(12,10*Math.abs(e.a))),he=P==0||P==1?0:P*.11,Me=ue*(1-he),Ie=4,De=g.name||`Group ${b+1}`;l.font=`${Me}px sans-serif`,l.setLineDash([]);const ke=l.measureText(De).width+Ie*2,ce=Me+Ie*2,we=k.x-5,xe=k.y-5,Ye=3;l.fillStyle="rgba(0, 0, 0, 0.8)",l.beginPath(),l.roundRect(we,xe-ce,ke,ce,Ye),l.fill(),l.fillStyle=K,l.textAlign="left",l.textBaseline="middle",l.fillText(De,we+Ie,xe-ce/2)})},[n,e,r,o,a]),ye.jsxs("div",{ref:i,style:{position:"relative",width:"100%",height:"100%"},children:[t,ye.jsx("canvas",{ref:s,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:Wm.pcbGroupOverlay,display:a?"block":"none"}})]})},y3n=({transform:t,soup:e,children:n})=>{const i=yv(a=>a.is_showing_rats_nest),{netMap:r,idToNetMap:o}=Ee.useMemo(()=>Rnt(e||[]),[e]),s=Ee.useMemo(()=>{if(!e||!i)return[];const a=h=>{const f=dE(e)[h.replace(/_\d+$/,"")].get(h);return f&&"x"in f&&"y"in f?{x:f.x,y:f.y}:null},c=(h,f)=>{const m=r[f]||[];let y=null,g=1/0;return m.forEach(b=>{const v=a(b);if(v){const w=Math.sqrt((h.x-v.x)**2+(h.y-v.y)**2);w<g&&w>0&&(g=w,y=v)}}),y},l=dE(e).pcb_port.list(),u=dE(e).source_trace.list(),d=[];return l.forEach((h,f)=>{const m=o[h.pcb_port_id];let y=!1;for(const v of u)v.connected_source_port_ids.includes(h.source_port_id)&&v.connected_source_net_ids.length>0&&(y=!0);if(!m)return;const g={x:h.x,y:h.y},b=c(g,m);b&&d.push({key:`${h.pcb_port_id}-${f}`,startPoint:g,endPoint:b,isInNet:y})}),d},[e,r,o,i]);return!e||!i?n:(t||(t=h0()),ye.jsxs("div",{style:{position:"relative"},children:[n,ye.jsx("svg",{style:{position:"absolute",left:0,top:0,width:"100%",height:"100%",pointerEvents:"none",opacity:.5,zIndex:Wm.ratsNestOverlay},children:s.map(({key:a,startPoint:c,endPoint:l,isInNet:u})=>{const d=Yt(t,c),h=Yt(t,l);return ye.jsx("line",{x1:d.x,y1:d.y,x2:h.x,y2:h.y,stroke:"white",strokeWidth:"1",strokeDasharray:u?"6,6":void 0},a)})})]}))},g3n={version:"1.11.223"},pE=(t,e)=>{const n=yv(i=>i.is_mouse_over_container);Ee.useEffect(()=>{if(!t||typeof e!="function")return;const i=r=>{const o=t.split("+"),s=o.includes("ctrl"),a=o.includes("shift"),c=o.includes("alt"),l=o.includes("meta"),u=o[o.length-1];n&&(!s||r.ctrlKey)&&(!a||r.shiftKey)&&(!c||r.altKey)&&(!l||r.metaKey)&&r.key.toLowerCase()===u.toLowerCase()&&(r.preventDefault(),e())};return window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[t,e])},b3n=()=>{const[t,e]=Ee.useState(!1);return Ee.useEffect(()=>{const n=()=>{e(window.innerWidth<=768)};return n(),window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[]),t},x3n=({name:t,selected:e,onClick:n})=>ye.jsxs("div",{className:kN`
5505
+ `,r3n=({children:t,transform:e=h0(),elements:n})=>{const i=Ee.useRef(null),{isShowingDRCErrors:r,hoveredErrorId:o}=yv(l=>({isShowingDRCErrors:l.is_showing_drc_errors,hoveredErrorId:l.hovered_error_id}));if(!n)return ye.jsx("div",{style:{position:"relative"},ref:i,children:t});const s=n.filter(l=>l.type==="pcb_trace_error"),a=n.filter(l=>l.type==="pcb_trace_error"&&l.message?.includes("Multiple components found with name")),c=new Map;return n.forEach(l=>{l.type==="pcb_port"&&c.set(l.pcb_port_id,l)}),ye.jsxs("div",{style:{position:"relative"},ref:i,children:[t,s.map((l,u)=>{const{pcb_port_ids:d,pcb_trace_id:h}=l,f=d?.[0]?c.get(d[0]):void 0,m=d?.[1]?c.get(d[1]):void 0,y=n?dE(n).pcb_trace.get(h):void 0,g=l.pcb_trace_error_id||`error_${u}_${l.error_type}_${l.message?.slice(0,20)}`,b=o===g;if(f&&m){const v=Yt(e,{x:f.x,y:f.y}),w=Yt(e,{x:m.x,y:m.y}),T=!(isNaN(v.x)||isNaN(v.y)||isNaN(w.x)||isNaN(w.y)),N={x:(v.x+w.x)/2,y:(v.y+w.y)/2};if(isNaN(N.x)||isNaN(N.y))return null;const R=Gye(N,i);return ye.jsxs(Ee.Fragment,{children:[ye.jsx(n3n,{screenPort1:v,screenPort2:w,errorCenter:N,canLineBeDrawn:T,isHighlighted:b}),ye.jsx("div",{style:{position:"absolute",left:N.x-15,top:N.y-15,width:30,height:30,zIndex:Wm.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:P=>{const M=P.currentTarget.nextElementSibling;if(M){const I=M.querySelector(".error-message");I&&(I.style.opacity="1")}},onMouseLeave:P=>{if(!b){const M=P.currentTarget.nextElementSibling;if(M){const I=M.querySelector(".error-message");I&&(I.style.opacity="0")}}}}),ye.jsx("div",{style:{position:"absolute",zIndex:b?200:100,left:R.left,top:R.top,color:b?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:r||b?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:R.transform},children:ye.jsx("div",{className:`error-message ${Yye}`,style:{opacity:b?1:0,border:`1px solid ${b?"#ff4444":"red"}`},children:l.message})})]},g)}if(y?.route&&(r||b)){const v=y.route.map(R=>Yt(e,{x:R.x,y:R.y}));if(v.some(R=>isNaN(R.x)||isNaN(R.y)))return null;const w=Math.floor(v.length/2),T=v[w],N=Gye(T,i);return ye.jsxs(Ee.Fragment,{children:[ye.jsx(i3n,{points:v,errorCenter:T,isHighlighted:b}),ye.jsx("div",{style:{position:"absolute",left:T.x-15,top:T.y-15,width:30,height:30,zIndex:Wm.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:R=>{const P=R.currentTarget.nextElementSibling;if(P){const M=P.querySelector(".error-message");M&&(M.style.opacity="1")}},onMouseLeave:R=>{if(!b){const P=R.currentTarget.nextElementSibling;if(P){const M=P.querySelector(".error-message");M&&(M.style.opacity="0")}}}}),ye.jsx("div",{style:{position:"absolute",zIndex:b?Wm.errorOverlay+10:Wm.errorOverlay+1,left:N.left,top:N.top,color:b?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:"flex",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:N.transform},children:ye.jsx("div",{className:`error-message ${Yye}`,style:{opacity:b?1:0,border:`1px solid ${b?"#ff4444":"red"}`},children:l.message})})]},g)}return null}),a.map((l,u)=>{const d=l.component_name||l.message?.match(/name "([^"]+)"/)?.[1];if(!d)return null;const h=n?.filter(y=>y.type==="source_component"&&y.name===d||y.type==="pcb_component"&&n?.find(g=>g.type==="source_component"&&g.source_component_id===y.source_component_id&&g.name===d))||[],f=l.pcb_trace_error_id||`error_${u}_${l.error_type}_${l.message?.slice(0,20)}`,m=o===f;return!m&&!r?null:h.map((y,g)=>{let b={x:0,y:0};if(y.type==="pcb_component")b=y.center||{x:0,y:0};else if(y.type==="source_component"){const I=n?.find(A=>A.type==="pcb_component"&&A.source_component_id===y.source_component_id);I&&I.type==="pcb_component"&&(b=I.center||{x:0,y:0})}const v=Yt(e,b);if(isNaN(v.x)||isNaN(v.y))return null;const w=Math.abs(e.a),P=Math.max(8,Math.min(30,.5*w)),M=Gye(v,i);return ye.jsxs(Ee.Fragment,{children:[ye.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:Wm.errorOverlay},width:"100%",height:"100%",children:m?ye.jsx("polygon",{points:`${v.x},${v.y-P*1.25} ${v.x+P},${v.y} ${v.x},${v.y+P*1.25} ${v.x-P},${v.y}`,fill:"#ff4444"}):ye.jsx("circle",{cx:v.x,cy:v.y,r:P,fill:"none",stroke:m?"#ff4444":"red",strokeWidth:m?Math.max(2,P*.15):Math.max(1,P*.1),opacity:1})}),ye.jsx("div",{style:{position:"absolute",left:v.x-(P+10),top:v.y-(P+10),width:(P+10)*2,height:(P+10)*2,zIndex:Wm.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:I=>{const A=I.currentTarget.nextElementSibling;if(A){const $=A.querySelector(".error-message");$&&($.style.opacity="1")}},onMouseLeave:I=>{if(!m){const A=I.currentTarget.nextElementSibling;if(A){const $=A.querySelector(".error-message");$&&($.style.opacity="0")}}}}),ye.jsx("div",{style:{position:"absolute",zIndex:m?Wm.errorOverlay+20:Wm.errorOverlay+10,left:M.left,top:M.top,color:m?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:r||m?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:M.transform},children:ye.jsx("div",{className:`error-message ${Yye}`,style:{opacity:m?1:0,border:`1px solid ${m?"#ff4444":"red"}`},children:l.message})})]},`${f}_${g}`)})})]})};function o3n({primitiveElement:t,elements:e}){let n=t.trace_length?`${t.trace_length.toFixed(3)}`:"";const i=dE(e).source_trace.get(t?.source_trace_id);if(i?.display_name&&(i?.max_length?n+=` / ${i.max_length}mm `:n+=" mm ",n+=`(${i.display_name})`),!n)return null;const r=t.trace_length&&i?.max_length&&t.trace_length>i.max_length;return{text:n,isOverLength:r}}function s3n(t){const{primitives:e,is_showing_multiple_traces_length:n,elements:i}=t,r=e.filter(c=>c._element.type==="pcb_trace"),o=i.filter(c=>c.type==="source_trace"),s=e.filter(c=>c._element.type!=="pcb_trace"),a=r.filter(c=>o.some(l=>c._element.type==="pcb_trace"&&c._element.source_trace_id===l.source_trace_id&&l.max_length!==void 0));if(!n)return[...s,...a];if(r.length>1){const c=r.reduce((l,u)=>{const d=l._element.trace_length;return u._element.trace_length<d?u:l},r[0]);return[...s,c]}return e}var a3n={position:"absolute",left:0,top:0,pointerEvents:"none",color:"red",fontFamily:"sans-serif",fontSize:12,textShadow:"0 0 2px black"},c3n=t=>{const{_element:e,_parent_pcb_component:n,_parent_source_component:i,_source_port:r}=t;switch(e.type){case"pcb_trace":return e.trace_length?`${e.trace_length.toFixed(3)}`:"";case"pcb_smtpad":case"pcb_plated_hole":{let o="";const s=Array.from(new Set((e.port_hints??[]).concat(r?.port_hints??[]))).filter(a=>!/^[0-9]+$/.test(a)).sort((a,c)=>c.localeCompare(a));return i&&"name"in i&&i.name&&(o+=`.${i.name}`,s.length>0&&(o+=" > ")),s.length>0&&(o+=s.map(a=>`.${a}`).join(", ")),o}default:return""}},l3n={top:"red",bottom:"aqua"},u3n=({primitive:t,mousePos:e,elements:n})=>{const[i,r]=Ee.useState(!1),o=t._element;Ee.useEffect(()=>{setTimeout(()=>{r(!0)},100)},[]);const[s,a,c,l]=[t.screen_x,t.screen_y,t.screen_w,t.screen_h],u=t.same_space_index??0,d=26,h=l3n[t?._element?.layer]??"red";let f=0;if(o.type==="pcb_smtpad"&&o?.shape==="rotated_rect"?f=o?.ccw_rotation??0:(o.type==="pcb_smtpad"&&(o?.shape==="pill"||o?.shape==="rotated_pill")&&"ccw_rotation"in t||o.type==="pcb_plated_hole"&&(o?.shape==="pill"||o?.shape==="oval")&&"ccw_rotation"in t)&&(f=o.ccw_rotation??0),o.type==="pcb_trace"){const y=o3n({primitiveElement:o,elements:n});if(!y)return null;const g=e.y-35;return ye.jsx("div",{style:{zIndex:Wm.elementOverlay,position:"absolute",left:e.x,top:g,color:h,pointerEvents:"none",transform:"translateX(-50%)"},children:ye.jsx("div",{style:{backgroundColor:"#f2efcc",color:y.isOverLength?"red":"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",minWidth:"45px",textAlign:"center",whiteSpace:"nowrap"},children:y.text})})}return ye.jsx("div",{style:{zIndex:Wm.elementOverlay,position:"absolute",left:s-c/2-8,top:a-l/2-8,width:c+16,height:l+16,color:h,transform:`rotate(${-f}deg)`,transformOrigin:"center center"},children:ye.jsx("div",{style:{width:i?`calc(100% + ${d*2*u}px)`:"100%",height:i?`calc(100% + ${d*2*u}px)`:"100%",marginLeft:i?`${-d*u}px`:0,marginTop:i?`${-d*u}px`:0,border:`1px solid ${h}`,opacity:i||u===0?1:0,transition:"width 0.2s, height 0.2s, margin-left 0.2s, margin-top 0.2s, opacity 0.2s"},children:ye.jsx("div",{style:{position:"absolute",bottom:l+20+d*u,marginRight:i?`${-d*u}px`:0,marginBottom:i?0:-d*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(${f}deg)`,minWidth:"45px",textAlign:"center"},children:c3n(t)})})})},d3n=({highlightedPrimitives:t,mousePos:e,elements:n})=>{const[i,r]=yv(a=>[a.is_moving_component,a.is_showing_multiple_traces_length]),o=t.some(a=>a._element.type==="pcb_smtpad")&&t.some(a=>a._element.type==="pcb_trace");let s=t;return o&&(s=s.filter(a=>a._element.type==="pcb_smtpad")),s=s3n({primitives:s,is_showing_multiple_traces_length:r,elements:n}),ye.jsx("div",{style:a3n,children:!i&&s.map((a,c)=>ye.jsx(u3n,{primitive:a,mousePos:e,elements:n},c))})};function h3n(t,e){return t.size!==e.size?!1:Array.from(t).every(n=>e.has(n))}function p3n(t,e,n){const i=(n.x-e.x)**2+(n.y-e.y)**2;if(i===0)return Lnt(t,e);let r=((t.x-e.x)*(n.x-e.x)+(t.y-e.y)*(n.y-e.y))/i;r=Math.max(0,Math.min(1,r));const o={x:e.x+r*(n.x-e.x),y:e.y+r*(n.y-e.y)};return Lnt(t,o)}function Lnt(t,e){const n=t.x-e.x,i=t.y-e.y;return Math.sqrt(n*n+i*i)}var f3n=(t,e,n)=>{const i=[];for(const r of t){if(!r._element)continue;if("x1"in r&&r._element?.type==="pcb_trace"){const a=p3n({x:e.x,y:e.y},{x:r.x1,y:r.y1},{x:r.x2,y:r.y2}),c=r.width||.5,l=Math.max(c*25,2)/n.a;a<l&&i.push(r);continue}if(!("x"in r&&"y"in r))continue;let o=0,s=0;if("w"in r&&"h"in r)o=r.w,s=r.h;else if("r"in r)o=r.r*2,s=r.r*2;else continue;Math.abs(r.x-e.x)<o/2&&Math.abs(r.y-e.y)<s/2&&i.push(r)}return i},m3n=({elements:t,children:e,transform:n,primitives:i,onMouseHoverOverPrimitives:r})=>{const[o,s]=Ee.useState([]),[a,c]=Ee.useState({x:0,y:0}),l=Ee.useMemo(()=>{const d=[];for(const h of o){if(h._element?.type==="pcb_via"||h._element?.type==="pcb_component"||h?.layer==="drill")continue;const f=Yt(n,h),m="w"in h?h.w:"r"in h?h.r*2:0,y="h"in h?h.h:"r"in h?h.r*2:0,g={w:m*n.a,h:y*n.a},b=d.filter(v=>f.x===v.screen_x&&f.y===v.screen_y&&g.w===v.screen_w&&g.h===v.screen_h).length;d.push({...h,screen_x:f.x,screen_y:f.y,screen_w:g.w,screen_h:g.h,same_space_index:b})}return d},[o,n]),u=(d,h,f,m)=>{c({x:d,y:h});const y=Yt(n5(f),{x:d,y:h}),g=f3n(m,y,f);h3n(new Set(g.map(b=>b._pcb_drawing_object_id)),new Set(o.map(b=>b._pcb_drawing_object_id)))||(s(g),r(g))};return ye.jsxs("div",{style:{position:"relative"},onMouseMove:d=>{if(n){const h=d.currentTarget.getBoundingClientRect(),f=d.clientX-h.left,m=d.clientY-h.top;u(f,m,n,i)}},onTouchStart:d=>{if(n){const h=d.touches[0],f=d.currentTarget.getBoundingClientRect(),m=h.clientX-f.left,y=h.clientY-f.top;u(m,y,n,i)}},children:[e,ye.jsx(d3n,{elements:t,mousePos:a,highlightedPrimitives:l})]})},Dnt=["rgb(255, 100, 100)","rgb(100, 255, 100)","rgb(100, 100, 255)","rgb(255, 255, 100)","rgb(255, 100, 255)","rgb(100, 255, 255)","rgb(255, 150, 100)","rgb(150, 100, 255)","rgb(100, 255, 150)","rgb(255, 100, 150)"],_3n=({children:t,transform:e=h0(),elements:n=[]})=>{const[i,{width:r,height:o}]=eV(),s=Ee.useRef(null),a=yv(c=>c.is_showing_pcb_groups);return Ee.useEffect(()=>{const c=s.current;if(!c||!r||!o)return;c.width=r,c.height=o;const l=c.getContext("2d");if(!l||(l.clearRect(0,0,r,o),!a))return;const u=n.filter(g=>g.type==="pcb_group"),d=n.filter(g=>g.type==="pcb_component"),h=n.filter(g=>g.type==="source_group"),f=new Map;h.forEach(g=>{const b=g;if(b.parent_source_group_id){const v=f.get(b.parent_source_group_id)||[];v.push(g.source_group_id),f.set(b.parent_source_group_id,v)}});const m=g=>{const b=[],v=f.get(g)||[];for(const w of v)b.push(w),b.push(...m(w));return b},y=g=>{const b=h.find(v=>v.source_group_id===g);return b?.parent_source_group_id?1+y(b.parent_source_group_id):0};u.forEach((g,b)=>{let v=d.filter(Je=>Je.pcb_group_id===g.pcb_group_id);if(g.source_group_id){const Je=m(g.source_group_id),st=u.filter(Se=>Se.source_group_id&&Je.includes(Se.source_group_id));for(const Se of st){const ut=d.filter(Ke=>Ke.pcb_group_id===Se.pcb_group_id);v=[...v,...ut]}}if(v.length===0)return;let w=1/0,T=1/0,N=-1/0,R=-1/0;if(v.forEach(Je=>{if(Je.center&&typeof Je.width=="number"&&typeof Je.height=="number"){const st=Je.center.x-Je.width/2,Se=Je.center.x+Je.width/2,ut=Je.center.y+Je.height/2,Ke=Je.center.y-Je.height/2;w=Math.min(w,st),N=Math.max(N,Se),T=Math.min(T,Ke),R=Math.max(R,ut)}}),w===1/0||N===-1/0)return;const P=g.source_group_id?y(g.source_group_id):0,M=g.source_group_id?m(g.source_group_id).length>0:!1,$=1+(M?.5:0);w-=$,N+=$,T-=$,R+=$;const k=Yt(e,{x:w,y:R}),V=Yt(e,{x:N,y:R}),X=Yt(e,{x:w,y:T}),W=Yt(e,{x:N,y:T}),K=Dnt[b%Dnt.length];l.strokeStyle=K,l.lineWidth=2;const te=Math.max(4,Math.min(12,8*Math.abs(e.a))),se=Math.max(2,Math.min(6,4*Math.abs(e.a))),be=te*(M?1.3:1),re=se;l.setLineDash([be,re]),l.beginPath(),l.moveTo(k.x,k.y),l.lineTo(V.x,V.y),l.lineTo(W.x,W.y),l.lineTo(X.x,X.y),l.closePath(),l.stroke();const ue=Math.max(8,Math.min(12,10*Math.abs(e.a))),he=P==0||P==1?0:P*.11,Me=ue*(1-he),Ie=4,De=g.name||`Group ${b+1}`;l.font=`${Me}px sans-serif`,l.setLineDash([]);const ke=l.measureText(De).width+Ie*2,ce=Me+Ie*2,we=k.x-5,xe=k.y-5,Ye=3;l.fillStyle="rgba(0, 0, 0, 0.8)",l.beginPath(),l.roundRect(we,xe-ce,ke,ce,Ye),l.fill(),l.fillStyle=K,l.textAlign="left",l.textBaseline="middle",l.fillText(De,we+Ie,xe-ce/2)})},[n,e,r,o,a]),ye.jsxs("div",{ref:i,style:{position:"relative",width:"100%",height:"100%"},children:[t,ye.jsx("canvas",{ref:s,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:Wm.pcbGroupOverlay,display:a?"block":"none"}})]})},y3n=({transform:t,soup:e,children:n})=>{const i=yv(a=>a.is_showing_rats_nest),{netMap:r,idToNetMap:o}=Ee.useMemo(()=>Rnt(e||[]),[e]),s=Ee.useMemo(()=>{if(!e||!i)return[];const a=h=>{const f=dE(e)[h.replace(/_\d+$/,"")].get(h);return f&&"x"in f&&"y"in f?{x:f.x,y:f.y}:null},c=(h,f)=>{const m=r[f]||[];let y=null,g=1/0;return m.forEach(b=>{const v=a(b);if(v){const w=Math.sqrt((h.x-v.x)**2+(h.y-v.y)**2);w<g&&w>0&&(g=w,y=v)}}),y},l=dE(e).pcb_port.list(),u=dE(e).source_trace.list(),d=[];return l.forEach((h,f)=>{const m=o[h.pcb_port_id];let y=!1;for(const v of u)v.connected_source_port_ids.includes(h.source_port_id)&&v.connected_source_net_ids.length>0&&(y=!0);if(!m)return;const g={x:h.x,y:h.y},b=c(g,m);b&&d.push({key:`${h.pcb_port_id}-${f}`,startPoint:g,endPoint:b,isInNet:y})}),d},[e,r,o,i]);return!e||!i?n:(t||(t=h0()),ye.jsxs("div",{style:{position:"relative"},children:[n,ye.jsx("svg",{style:{position:"absolute",left:0,top:0,width:"100%",height:"100%",pointerEvents:"none",opacity:.5,zIndex:Wm.ratsNestOverlay},children:s.map(({key:a,startPoint:c,endPoint:l,isInNet:u})=>{const d=Yt(t,c),h=Yt(t,l);return ye.jsx("line",{x1:d.x,y1:d.y,x2:h.x,y2:h.y,stroke:"white",strokeWidth:"1",strokeDasharray:u?"6,6":void 0},a)})})]}))},g3n={version:"1.11.224"},pE=(t,e)=>{const n=yv(i=>i.is_mouse_over_container);Ee.useEffect(()=>{if(!t||typeof e!="function")return;const i=r=>{const o=t.split("+"),s=o.includes("ctrl"),a=o.includes("shift"),c=o.includes("alt"),l=o.includes("meta"),u=o[o.length-1];n&&(!s||r.ctrlKey)&&(!a||r.shiftKey)&&(!c||r.altKey)&&(!l||r.metaKey)&&r.key.toLowerCase()===u.toLowerCase()&&(r.preventDefault(),e())};return window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[t,e])},b3n=()=>{const[t,e]=Ee.useState(!1);return Ee.useEffect(()=>{const n=()=>{e(window.innerWidth<=768)};return n(),window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[]),t},x3n=({name:t,selected:e,onClick:n})=>ye.jsxs("div",{className:kN`
5506
5506
  margin-top: 2px;
5507
5507
  padding: 4px;
5508
5508
  padding-left: 8px;