@tscircuit/runframe 0.0.1459 → 0.0.1460
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.
|
@@ -5059,7 +5059,7 @@ ${a.join(`
|
|
|
5059
5059
|
${Q}polygon: ${l.polygon.vertices}
|
|
5060
5060
|
`:a+=`
|
|
5061
5061
|
`,l.children.length>0&&I.push(l.children)}return a}};A.exports=s}}),yst=oe({"node_modules/@jscad/modeling/src/operations/booleans/trees/Tree.js"(t,A){var e=ust(),i=fst(),o=class{constructor(n){this.polygonTree=new i,this.rootnode=new e(null),n&&this.addPolygons(n)}invert(){this.polygonTree.invert(),this.rootnode.invert()}clipTo(n,s=!1){this.rootnode.clipTo(n,s)}allPolygons(){const n=[];return this.polygonTree.getPolygons(n),n}addPolygons(n){const s=new Array(n.length);for(let r=0;r<n.length;r++)s[r]=this.polygonTree.addChild(n[r]);this.rootnode.addPolygonTreeNodes(s)}clear(){this.polygonTree.clear()}toString(){return"Tree: "+this.polygonTree.toString("")}};A.exports=o}}),XcA=oe({"node_modules/@jscad/modeling/src/operations/booleans/trees/index.js"(t,A){A.exports={Tree:yst()}}}),wst=oe({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3Sub.js"(t,A){var e=Tn(),i=zcA(),{Tree:o}=XcA(),n=(s,r)=>{if(!i(s,r))return e.create();const a=new o(e.toPolygons(s)),g=new o(e.toPolygons(r));a.invert(),g.clipTo(a),g.invert(),a.clipTo(g),g.clipTo(a),a.addPolygons(g.allPolygons()),a.invert();const I=a.allPolygons();return e.create(I)};A.exports=n}}),Q8A=oe({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3.js"(t,A){var e=Gn(),i=yU(),o=wst(),n=(...s)=>{s=e(s);let r=s.shift();return s.forEach(a=>{r=o(r,a)}),r=i(r),r};A.exports=n}}),mst=oe({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom2.js"(t,A){var e=Gn(),i=Tn(),o=Cx(),n=VcA(),s=jcA(),r=Q8A(),a=(...g)=>{g=e(g);const I=g.map(C=>s({z0:-1,z1:1},C)),c=r(I),B=o(c);return n(B,i.toPolygons(c))};A.exports=a}}),Dst=oe({"node_modules/@jscad/modeling/src/operations/booleans/intersect.js"(t,A){var e=Gn(),i=fU(),o=Kn(),n=Tn(),s=mst(),r=Q8A(),a=(...g)=>{if(g=e(g),g.length===0)throw new Error("wrong number of arguments");if(!i(g))throw new Error("only intersect of the types are supported");const I=g[0];return o.isA(I)?s(g):n.isA(I)?r(g):I};A.exports=a}}),Sst=oe({"node_modules/@jscad/modeling/src/operations/booleans/scissionGeom3.js"(t,A){var e=ho(),i=Cx(),o=Tn(),n=g=>g.sort((I,c)=>I-c).filter((I,c,B)=>!c||I!==B[c-1]),s=(g,I,c)=>{const B=`${I}`,C=g.get(B);C===void 0?g.set(B,[c]):C.push(c)},r=(g,I)=>{const c=`${I}`;return g.get(c)},a=g=>{const I=i(g),c=o.toPolygons(g),B=c.length,C=new Map,l=e.create();c.forEach((d,f)=>{d.vertices.forEach(D=>{s(C,e.snap(l,D,I),f)})});const Q=c.map(d=>{let f=[];return d.vertices.forEach(D=>{f=f.concat(r(C,e.snap(l,D,I)))}),{e:1,d:n(f)}});C.clear();let E=0;const h=Q.length;for(let d=0;d<h;d++){const f=Q[d];if(f.e>0){const D=new Array(B);D[d]=!0;do E=0,D.forEach((b,m)=>{const x=Q[m];if(x.e>0){x.e=-1;for(let F=0;F<x.d.length;F++)D[x.d[F]]=!0;E++}});while(E>0);f.indexes=D}}const u=[];for(let d=0;d<h;d++)if(Q[d].indexes){const f=[];Q[d].indexes.forEach((D,b)=>f.push(c[b])),u.push(o.create(f))}return u};A.exports=a}}),bst=oe({"node_modules/@jscad/modeling/src/operations/booleans/scission.js"(t,A){var e=Gn(),i=Tn(),o=Sst(),n=(...s)=>{if(s=e(s),s.length===0)throw new Error("wrong number of arguments");const r=s.map(a=>i.isA(a)?o(a):a);return r.length===1?r[0]:r};A.exports=n}}),xst=oe({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3Sub.js"(t,A){var e=Tn(),i=zcA(),{Tree:o}=XcA(),n=(s,r)=>{if(!i(s,r))return e.clone(s);const a=new o(e.toPolygons(s)),g=new o(e.toPolygons(r));a.invert(),a.clipTo(g),g.clipTo(a,!0),a.addPolygons(g.allPolygons()),a.invert();const I=a.allPolygons();return e.create(I)};A.exports=n}}),E8A=oe({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3.js"(t,A){var e=Gn(),i=yU(),o=xst(),n=(...s)=>{s=e(s);let r=s.shift();return s.forEach(a=>{r=o(r,a)}),r=i(r),r};A.exports=n}}),kst=oe({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom2.js"(t,A){var e=Gn(),i=Tn(),o=Cx(),n=VcA(),s=jcA(),r=E8A(),a=(...g)=>{g=e(g);const I=g.map(C=>s({z0:-1,z1:1},C)),c=r(I),B=o(c);return n(B,i.toPolygons(c))};A.exports=a}}),Gst=oe({"node_modules/@jscad/modeling/src/operations/booleans/subtract.js"(t,A){var e=Gn(),i=fU(),o=Kn(),n=Tn(),s=kst(),r=E8A(),a=(...g)=>{if(g=e(g),g.length===0)throw new Error("wrong number of arguments");if(!i(g))throw new Error("only subtract of the types are supported");const I=g[0];return o.isA(I)?s(g):n.isA(I)?r(g):I};A.exports=a}}),h8A=oe({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3Sub.js"(t,A){var e=Tn(),i=zcA(),{Tree:o}=XcA(),n=(r,a)=>{if(!i(r,a))return s(r,a);const g=new o(e.toPolygons(r)),I=new o(e.toPolygons(a));g.clipTo(I,!1),I.clipTo(g),I.invert(),I.clipTo(g),I.invert();const c=g.allPolygons().concat(I.allPolygons());return e.create(c)},s=(r,a)=>{let g=e.toPolygons(r);return g=g.concat(e.toPolygons(a)),e.create(g)};A.exports=n}}),u8A=oe({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3.js"(t,A){var e=Gn(),i=yU(),o=h8A(),n=(...s)=>{s=e(s);let r;for(r=1;r<s.length;r+=2)s.push(o(s[r-1],s[r]));let a=s[r-1];return a=i(a),a};A.exports=n}}),d8A=oe({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom2.js"(t,A){var e=Gn(),i=Tn(),o=Cx(),n=VcA(),s=jcA(),r=u8A(),a=(...g)=>{g=e(g);const I=g.map(C=>s({z0:-1,z1:1},C)),c=r(I),B=o(c);return n(B,i.toPolygons(c))};A.exports=a}}),$cA=oe({"node_modules/@jscad/modeling/src/operations/booleans/union.js"(t,A){var e=Gn(),i=fU(),o=Kn(),n=Tn(),s=d8A(),r=u8A(),a=(...g)=>{if(g=e(g),g.length===0)throw new Error("wrong number of arguments");if(!i(g))throw new Error("only unions of the same type are supported");const I=g[0];return o.isA(I)?s(g):n.isA(I)?r(g):I};A.exports=a}}),mM=oe({"node_modules/@jscad/modeling/src/operations/booleans/index.js"(t,A){A.exports={intersect:Dst(),scission:bst(),subtract:Gst(),union:$cA()}}}),uO=oe({"node_modules/@jscad/modeling/src/operations/expansions/offsetFromPoints.js"(t,A){var{EPS:e,TAU:i}=Br(),o=Z5A(),n=TcA(),s=Bs(),r=QO(),a=(g,I)=>{const c={delta:1,corners:"edge",closed:!1,segments:16};let{delta:B,corners:C,closed:l,segments:Q}=Object.assign({},c,g);if(Math.abs(B)<e)return I;let E=g.closed?r(I):1;E===0&&(E=1);const h=E>0&&B>=0||E<0&&B<0;B=Math.abs(B);let u=null,d=[];const f=[],D=s.create(),b=I.length;for(let m=0;m<b;m++){const x=(m+1)%b,F=I[m],k=I[x];h?s.subtract(D,F,k):s.subtract(D,k,F),s.normal(D,D),s.normalize(D,D),s.scale(D,D,B);const v=s.add(s.create(),F,D),M=s.add(s.create(),k,D),H=[v,M];if(u!=null&&(l||!l&&x!==0)){const P=o(u[0],u[1],H[0],H[1]);P?(d.pop(),H[0]=P):f.push({c:F,s0:u,s1:H})}u=[v,M],!(x===0&&!l)&&(d.push(H[0]),d.push(H[1]))}if(l&&u!=null){const m=d[0],x=d[1],F=o(u[0],u[1],m,x);if(F)d[0]=F,d.pop();else{const k=I[0],v=[m,x];f.push({c:k,s0:u,s1:v})}}if(C==="edge"){const m=new Map;d.forEach((k,v)=>m.set(k,v));const x=n.create(),F=n.create();f.forEach(k=>{n.fromPoints(x,k.s0[0],k.s0[1]),n.fromPoints(F,k.s1[0],k.s1[1]);const v=n.intersectPointOfLines(x,F);if(Number.isFinite(v[0])&&Number.isFinite(v[1])){const M=k.s0[1],H=m.get(M);d[H]=v,d[(H+1)%d.length]=void 0}else{const M=k.s1[0],H=m.get(M);d[H]=void 0}}),d=d.filter(k=>k!==void 0)}if(C==="round"){let m=Math.floor(Q/4);const x=s.create();f.forEach(F=>{let k=s.angle(s.subtract(x,F.s1[0],F.c));if(k-=s.angle(s.subtract(x,F.s0[1],F.c)),h&&k<0&&(k=k+Math.PI,k<0&&(k=k+Math.PI)),!h&&k>0&&(k=k-Math.PI,k>0&&(k=k-Math.PI)),k!==0){m=Math.floor(Q*(Math.abs(k)/i));const v=k/m,M=s.angle(s.subtract(x,F.s0[1],F.c)),H=[];for(let P=1;P<m;P++){const K=M+v*P,O=s.fromAngleRadians(s.create(),K);s.scale(O,O,B),s.add(O,O,F.c),H.push(O)}if(H.length>0){const P=F.s0[1];let K=d.findIndex(O=>s.equals(P,O));K=(K+1)%d.length,d.splice(K,0,...H)}}else{const v=F.s1[0],M=d.findIndex(H=>s.equals(v,H));d.splice(M,1)}})}return d};A.exports=a}}),Fst=oe({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom2.js"(t,A){var e=Kn(),i=uO(),o=(n,s)=>{const r={delta:1,corners:"edge",segments:16},{delta:a,corners:g,segments:I}=Object.assign({},r,n);if(!(g==="edge"||g==="chamfer"||g==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const C=e.toOutlines(s).map(l=>(n={delta:a,corners:g,closed:!0,segments:I},i(n,l))).reduce((l,Q)=>l.concat(e.toSides(e.fromPoints(Q))),[]);return e.create(C)};A.exports=o}}),Rst=oe({"node_modules/@jscad/modeling/src/operations/expansions/extrudePolygon.js"(t,A){var e=_g(),i=ho(),o=Tn(),n=Xs(),s=(r,a)=>{i.dot(n.plane(a),r)>0&&(a=n.invert(a));const I=[a],c=n.transform(e.fromTranslation(e.create(),r),a),B=a.vertices.length;for(let C=0;C<B;C++){const l=C<B-1?C+1:0,Q=n.create([a.vertices[C],c.vertices[C],c.vertices[l],a.vertices[l]]);I.push(Q)}return I.push(n.invert(c)),o.create(I)};A.exports=s}}),Nst=oe({"node_modules/@jscad/modeling/src/operations/expansions/expandShell.js"(t,A){var{EPS:e,TAU:i}=Br(),o=_g(),n=ho(),s=C8A(),r=Tn(),a=Xs(),g=s8A(),I=yU(),c=h8A(),B=Rst(),C=(h,u,d)=>{const f=u.toString();if(h.has(f))h.get(f)[1].push(d);else{const D=[u,[d]];h.set(f,D)}},l=(h,u,d)=>{const f=u[0].toString(),D=u[1].toString(),b=f<D?`${f},${D}`:`${D},${f}`;if(h.has(b))h.get(b)[1].push(d);else{const m=[u,[d]];h.set(b,m)}},Q=(h,u)=>{h.findIndex(f=>f===u)<0&&h.push(u)},E=(h,u)=>{const d={delta:1,segments:12},{delta:f,segments:D}=Object.assign({},d,h);let b=r.create();const m=new Map,x=new Map,F=n.create(),k=n.create();return r.toPolygons(u).forEach((M,H)=>{const P=n.scale(n.create(),a.plane(M),2*f),K=a.transform(o.fromTranslation(o.create(),n.scale(n.create(),P,-.5)),M),O=B(P,K);b=c(b,O);const W=M.vertices;for(let $=0;$<W.length;$++){C(m,W[$],a.plane(M));const oA=($+1)%W.length,IA=[W[$],W[oA]];l(x,IA,a.plane(M))}}),x.forEach(M=>{const H=M[0],P=M[1],K=H[0],O=H[1],W=n.subtract(n.create(),O,K);n.normalize(W,W);const $=P[0],oA=n.cross(n.create(),$,W);let IA=[];for(let qA=0;qA<D;qA++)Q(IA,qA*i/D);for(let qA=0,BA=P.length;qA<BA;qA++){const fA=P[qA],hA=n.dot(oA,fA),TA=n.dot($,fA);let ee=Math.atan2(hA,TA);ee<0&&(ee+=i),Q(IA,ee),ee=Math.atan2(-hA,-TA),ee<0&&(ee+=i),Q(IA,ee)}IA=IA.sort(s);const tA=IA.length;let sA,gA;const dA=[],SA=[],RA=[];for(let qA=-1;qA<tA;qA++){const BA=IA[qA<0?qA+tA:qA],fA=Math.sin(BA),hA=Math.cos(BA);n.scale(F,$,hA*f),n.scale(k,oA,fA*f),n.add(F,F,k);const TA=n.add(n.create(),K,F),ee=n.add(n.create(),O,F);let ce=!1;if(qA>=0&&n.distance(TA,sA)<e&&(ce=!0),!ce){if(qA>=0){dA.push(TA),SA.push(ee);const yA=[gA,ee,TA,sA],OA=a.create(yA);RA.push(OA)}sA=TA,gA=ee}}SA.reverse(),RA.push(a.create(dA)),RA.push(a.create(SA));const NA=r.create(RA);b=c(b,NA)}),m.forEach(M=>{const H=M[0],P=M[1],K=P[0];let O=null,W=0;for(let tA=1;tA<P.length;tA++){const sA=P[tA],gA=n.cross(F,K,sA),dA=n.length(gA);dA>.05&&dA>W&&(W=dA,O=sA)}O||(O=n.orthogonal(F,K));const $=n.cross(F,K,O);n.normalize($,$);const oA=n.cross(k,$,K),IA=g({center:[H[0],H[1],H[2]],radius:f,segments:D,axes:[K,$,oA]});b=c(b,IA)}),I(b)};A.exports=E}}),Mst=oe({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom3.js"(t,A){var e=Tn(),i=$cA(),o=Nst(),n=(s,r)=>{const a={delta:1,corners:"round",segments:12},{delta:g,corners:I,segments:c}=Object.assign({},a,s);if(I!=="round")throw new Error('corners must be "round" for 3D geometries');if(e.toPolygons(r).length===0)throw new Error("the given geometry cannot be empty");s={delta:g,corners:I,segments:c};const C=o(s,r);return i(r,C)};A.exports=n}}),_st=oe({"node_modules/@jscad/modeling/src/operations/expansions/expandPath2.js"(t,A){var e=QO(),i=Bs(),o=Kn(),n=Qg(),s=uO(),r=I=>{let{external:c,internal:B}=I;e(c)<0?c=c.reverse():B=B.reverse();const C=n.fromPoints({closed:!0},c),l=n.fromPoints({closed:!0},B),Q=o.toSides(o.fromPoints(n.toPoints(C))),E=o.toSides(o.fromPoints(n.toPoints(l)));return Q.push(...E),o.create(Q)},a=(I,c,B,C)=>{const{points:l,external:Q,internal:E}=I,h=Math.floor(c/2),u=[],d=[];if(B==="round"&&h>0){const D=Math.PI/h,b=l[l.length-1],m=i.angle(i.subtract(i.create(),Q[Q.length-1],b)),x=l[0],F=i.angle(i.subtract(i.create(),E[0],x));for(let k=1;k<h;k++){let v=m+D*k,M=i.fromAngleRadians(i.create(),v);i.scale(M,M,C),i.add(M,M,b),u.push(M),v=F+D*k,M=i.fromAngleRadians(i.create(),v),i.scale(M,M,C),i.add(M,M,x),d.push(M)}}const f=[];return f.push(...Q,...u,...E.reverse(),...d),o.fromPoints(f)},g=(I,c)=>{I=Object.assign({},{delta:1,corners:"edge",segments:16},I);const{delta:C,corners:l,segments:Q}=I;if(C<=0)throw new Error("the given delta must be positive for paths");if(!(l==="edge"||l==="chamfer"||l==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const E=c.isClosed,h=n.toPoints(c);if(h.length===0)throw new Error("the given geometry cannot be empty");const u={points:h,external:s({delta:C,corners:l,segments:Q,closed:E},h),internal:s({delta:-C,corners:l,segments:Q,closed:E},h)};return c.isClosed?r(u):a(u,Q,l,C)};A.exports=g}}),ABA=oe({"node_modules/@jscad/modeling/src/operations/expansions/expand.js"(t,A){var e=Gn(),i=Kn(),o=Tn(),n=Qg(),s=Fst(),r=Mst(),a=_st(),g=(I,...c)=>{if(c=e(c),c.length===0)throw new Error("wrong number of arguments");const B=c.map(C=>n.isA(C)?a(I,C):i.isA(C)?s(I,C):o.isA(C)?r(I,C):C);return B.length===1?B[0]:B};A.exports=g}}),vst=oe({"node_modules/@jscad/modeling/src/operations/expansions/offsetGeom2.js"(t,A){var e=Kn(),i=LcA(),o=uO(),n=(s,r)=>{const a={delta:1,corners:"edge",segments:0},{delta:g,corners:I,segments:c}=Object.assign({},a,s);if(!(I==="edge"||I==="chamfer"||I==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const B=e.toOutlines(r),l=B.map(Q=>(s={delta:B.reduce((u,d)=>u+i.arePointsInside(Q,i.create(d)),0)%2===0?g:-g,corners:I,closed:!0,segments:c},o(s,Q))).reduce((Q,E)=>Q.concat(e.toSides(e.fromPoints(E))),[]);return e.create(l)};A.exports=n}}),Ust=oe({"node_modules/@jscad/modeling/src/operations/expansions/offsetPath2.js"(t,A){var e=Qg(),i=uO(),o=(n,s)=>{const r={delta:1,corners:"edge",closed:s.isClosed,segments:16},{delta:a,corners:g,closed:I,segments:c}=Object.assign({},r,n);if(!(g==="edge"||g==="chamfer"||g==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');n={delta:a,corners:g,closed:I,segments:c};const B=i(n,e.toPoints(s));return e.fromPoints({closed:I},B)};A.exports=o}}),Lst=oe({"node_modules/@jscad/modeling/src/operations/expansions/offset.js"(t,A){var e=Gn(),i=Kn(),o=Qg(),n=vst(),s=Ust(),r=(a,...g)=>{if(g=e(g),g.length===0)throw new Error("wrong number of arguments");const I=g.map(c=>o.isA(c)?s(a,c):i.isA(c)?n(a,c):c);return I.length===1?I[0]:I};A.exports=r}}),eBA=oe({"node_modules/@jscad/modeling/src/operations/expansions/index.js"(t,A){A.exports={expand:ABA(),offset:Lst()}}}),dO=oe({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearGeom2.js"(t,A){var e=_g(),i=ho(),o=Kn(),n=wM(),s=hO(),r=(a,g)=>{const I={offset:[0,0,1],twistAngle:0,twistSteps:12,repair:!0};let{offset:c,twistAngle:B,twistSteps:C,repair:l}=Object.assign({},I,a);if(C<1)throw new Error("twistSteps must be 1 or more");B===0&&(C=1);const Q=i.clone(c),E=o.toSides(g);if(E.length===0)throw new Error("the given geometry cannot be empty");const h=n.fromSides(E);Q[2]<0&&n.reverse(h,h);const u=e.create(),d=(f,D,b)=>{const m=D/C*B,x=i.scale(i.create(),Q,D/C);return e.multiply(u,e.fromZRotation(u,m),e.fromTranslation(e.create(),x)),n.transform(u,b)};return a={numberOfSlices:C+1,capStart:!0,capEnd:!0,repair:l,callback:d},s(a,h)};A.exports=r}}),Hst=oe({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearPath2.js"(t,A){var e=Kn(),i=Qg(),o=dO(),n=(s,r)=>{if(!r.isClosed)throw new Error("extruded path must be closed");const a=i.toPoints(r),g=e.fromPoints(a);return o(s,g)};A.exports=n}}),Yst=oe({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinear.js"(t,A){var e=Gn(),i=Kn(),o=Qg(),n=dO(),s=Hst(),r=(a,...g)=>{const I={height:1,twistAngle:0,twistSteps:1,repair:!0},{height:c,twistAngle:B,twistSteps:C,repair:l}=Object.assign({},I,a);if(g=e(g),g.length===0)throw new Error("wrong number of arguments");a={offset:[0,0,c],twistAngle:B,twistSteps:C,repair:l};const Q=g.map(E=>o.isA(E)?s(a,E):i.isA(E)?n(a,E):E);return Q.length===1?Q[0]:Q};A.exports=r}}),Jst=oe({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularPath2.js"(t,A){var e=Qg(),i=ABA(),o=dO(),n=(s,r)=>{const a={size:1,height:1},{size:g,height:I}=Object.assign({},a,s);if(s.delta=g,s.offset=[0,0,I],e.toPoints(r).length===0)throw new Error("the given geometry cannot be empty");const B=i(s,r);return o(s,B)};A.exports=n}}),Kst=oe({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularGeom2.js"(t,A){var{area:e}=hU(),i=Kn(),o=Qg(),n=ABA(),s=dO(),r=(a,g)=>{const I={size:1,height:1},{size:c,height:B}=Object.assign({},I,a);a.delta=c,a.offset=[0,0,B];const C=i.toOutlines(g);if(C.length===0)throw new Error("the given geometry cannot be empty");const Q=C.map(h=>(e(h)<0&&h.reverse(),n(a,o.fromPoints({closed:!0},h)))).reduce((h,u)=>h.concat(i.toSides(u)),[]),E=i.create(Q);return s(a,E)};A.exports=r}}),Tst=oe({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangular.js"(t,A){var e=Gn(),i=Kn(),o=Qg(),n=Jst(),s=Kst(),r=(a,...g)=>{const I={size:1,height:1},{size:c,height:B}=Object.assign({},I,a);if(g=e(g),g.length===0)throw new Error("wrong number of arguments");if(c<=0)throw new Error("size must be positive");if(B<=0)throw new Error("height must be positive");const C=g.map(l=>o.isA(l)?n(a,l):i.isA(l)?s(a,l):l);return C.length===1?C[0]:C};A.exports=r}}),qst=oe({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeHelical.js"(t,A){var{TAU:e}=Br(),i=_g(),o=Kn(),n=hO(),s=wM(),r=(a,g)=>{const I={angle:e,startAngle:0,pitch:10,height:0,endOffset:0,segmentsPerRotation:32};let{angle:c,startAngle:B,pitch:C,height:l,endOffset:Q,segmentsPerRotation:E}=Object.assign({},I,a);if(l!=0&&(C=l/(c/e)),E<3)throw new Error("The number of segments per rotation needs to be at least 3.");const u=o.toSides(g);if(u.length===0)throw new Error("The given geometry cannot be empty");const d=u.filter(k=>k[0][0]>=0);let f=s.fromSides(u);d.length===0&&(f=s.reverse(f));const D=Math.round(E/e*Math.abs(c)),b=D>=2?D:2,m=i.create(),x=i.create(),F=(k,v,M)=>{const H=B+c/b*v,P=Q/b*v,K=(H-B)/e*C;return i.multiply(m,i.fromTranslation(i.create(),[P,0,K*Math.sign(c)]),i.fromXRotation(i.create(),-e/4*Math.sign(c))),i.multiply(x,i.fromZRotation(i.create(),H),m),s.transform(x,M)};return n({numberOfSlices:b+1,callback:F},f)};A.exports=r}}),Pst=oe({"node_modules/@jscad/modeling/src/operations/extrusions/project.js"(t,A){var e=Gn(),i=KcA(),o=Em(),n=_g(),s=Kn(),r=Tn(),a=Xs(),g=Cx(),I=d8A(),c=(C,l)=>{const Q=o.fromNormalAndPoint(o.create(),C.axis,C.origin);if(Number.isNaN(Q[0])||Number.isNaN(Q[1])||Number.isNaN(Q[2])||Number.isNaN(Q[3]))throw new Error("project: invalid axis or origin");const E=g(l),h=E*E*Math.sqrt(3)/4;if(E===0)return s.create();const u=r.toPolygons(l);let d=[];for(let D=0;D<u.length;D++){const b=u[D].vertices.map(F=>o.projectionOfPoint(Q,F)),m=a.create(b),x=a.plane(m);i(Q,x)&&(a.measureArea(m)<h||d.push(m))}if(!i(Q,[0,0,1])){const D=n.fromVectorRotation(n.create(),Q,[0,0,1]);d=d.map(b=>a.transform(D,b))}d=d.sort((D,b)=>a.measureArea(b)-a.measureArea(D));const f=d.map(D=>s.fromPoints(D.vertices));return I(f)},B=(C,...l)=>{const Q={axis:[0,0,1],origin:[0,0,0]},{axis:E,origin:h}=Object.assign({},Q,C);if(l=e(l),l.length===0)throw new Error("wrong number of arguments");C={axis:E,origin:h};const u=l.map(d=>r.isA(d)?c(C,d):d);return u.length===1?u[0]:u};A.exports=B}}),wU=oe({"node_modules/@jscad/modeling/src/operations/extrusions/index.js"(t,A){A.exports={extrudeFromSlices:hO(),extrudeLinear:Yst(),extrudeRectangular:Tst(),extrudeRotate:I8A(),extrudeHelical:qst(),project:Pst(),slice:wM()}}}),tBA=oe({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints2.js"(t,A){var e=Bs(),i=s=>{let r=e.fromValues(1/0,1/0);s.forEach(I=>{(I[1]<r[1]||I[1]===r[1]&&I[0]<r[0])&&(r=I)});const a=[];s.forEach(I=>{const c=n(I[1]-r[1],I[0]-r[0]),B=e.squaredDistance(I,r);a.push({point:I,angle:c,distSq:B})}),a.sort((I,c)=>I.angle!==c.angle?I.angle-c.angle:I.distSq-c.distSq);const g=[];return a.forEach(I=>{let c=g.length;for(;c>1&&o(g[c-2],g[c-1],I.point)<=Number.EPSILON;)g.pop(),c=g.length;g.push(I.point)}),g},o=(s,r,a)=>(r[0]-s[0])*(a[1]-s[1])-(r[1]-s[1])*(a[0]-s[0]),n=(s,r)=>s===0&&r===0?-1/0:-r/s;A.exports=i}}),iBA=oe({"node_modules/@jscad/modeling/src/operations/hulls/toUniquePoints.js"(t,A){var e=Kn(),i=Tn(),o=Qg(),n=s=>{const r=new Set,a=[],g=I=>{const c=I.toString();r.has(c)||(a.push(I),r.add(c))};return s.forEach(I=>{e.isA(I)?e.toPoints(I).forEach(g):i.isA(I)?i.toPoints(I).forEach(c=>c.forEach(g)):o.isA(I)&&o.toPoints(I).forEach(g)}),a};A.exports=n}}),Ost=oe({"node_modules/@jscad/modeling/src/operations/hulls/hullPath2.js"(t,A){var e=Gn(),i=Qg(),o=tBA(),n=iBA(),s=(...r)=>{r=e(r);const a=n(r),g=o(a);return i.fromPoints({closed:!0},g)};A.exports=s}}),Wst=oe({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom2.js"(t,A){var e=Gn(),i=Kn(),o=tBA(),n=iBA(),s=(...r)=>{r=e(r);const a=n(r),g=o(a);return g.length<3?i.create():i.fromPoints(g)};A.exports=s}}),p8A=oe({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints3.js"(t,A){var e=Xs(),i=d5A(),o=n=>i(n,{skipTriangulation:!0}).map(a=>{const g=a.map(I=>n[I]);return e.create(g)});A.exports=o}}),Zst=oe({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom3.js"(t,A){var e=Gn(),i=Tn(),o=iBA(),n=p8A(),s=(...r)=>{r=e(r);const a=o(r);return a.length===0?i.create():i.create(n(a))};A.exports=s}}),f8A=oe({"node_modules/@jscad/modeling/src/operations/hulls/hull.js"(t,A){var e=Gn(),i=fU(),o=Kn(),n=Tn(),s=Qg(),r=Ost(),a=Wst(),g=Zst(),I=(...c)=>{if(c=e(c),c.length===0)throw new Error("wrong number of arguments");if(!i(c))throw new Error("only hulls of the same type are supported");const B=c[0];return s.isA(B)?r(c):o.isA(B)?a(c):n.isA(B)?g(c):B};A.exports=I}}),Vst=oe({"node_modules/@jscad/modeling/src/operations/hulls/hullChain.js"(t,A){var e=Gn(),i=$cA(),o=f8A(),n=(...s)=>{if(s=e(s),s.length<2)throw new Error("wrong number of arguments");const r=[];for(let a=1;a<s.length;a++)r.push(o(s[a-1],s[a]));return i(r)};A.exports=n}}),jst=oe({"node_modules/@jscad/modeling/src/operations/hulls/index.js"(t,A){A.exports={hull:f8A(),hullChain:Vst(),hullPoints2:tBA(),hullPoints3:p8A()}}}),y8A=oe({"node_modules/@jscad/modeling/src/operations/modifiers/snapPolygons.js"(t,A){var e=ho(),i=Xs(),o=(s,r)=>{const a=Math.abs(i.measureArea(r));return Number.isFinite(a)&&a>s},n=(s,r)=>{let a=r.map(I=>{const c=I.vertices.map(l=>e.snap(e.create(),l,s)),B=[];for(let l=0;l<c.length;l++){const Q=(l+1)%c.length;e.equals(c[l],c[Q])||B.push(c[l])}const C=i.create(B);return I.color&&(C.color=I.color),C});const g=s*s*Math.sqrt(3)/4;return a=a.filter(I=>o(g,I)),a};A.exports=n}}),zst=oe({"node_modules/@jscad/modeling/src/operations/modifiers/mergePolygons.js"(t,A){var e=KcA(),i=ho(),o=Xs(),n=h=>{const u=o.toPoints(h),d=[];for(let f=0;f<u.length;f++){const D=(f+1)%u.length,b={v1:u[f],v2:u[D]};d.push(b)}for(let f=0;f<d.length;f++){const D=(f+1)%u.length;d[f].next=d[D],d[D].prev=d[f]}return d},s=(h,u)=>{const d=`${u.v1}:${u.v2}`;h.set(d,u)},r=(h,u)=>{const d=`${u.v1}:${u.v2}`;h.delete(d)},a=(h,u)=>{const d=`${u.v2}:${u.v1}`;return h.get(d)},g=(h,u,d)=>{let f=h.prev.v1,D=h.prev.v2,b=u.next.v2;const m=B(f,D,b,d);f=u.prev.v1,D=u.prev.v2,b=h.next.v2;const x=B(f,D,b,d);return[m,x]},I=i.create(),c=i.create(),B=(h,u,d,f)=>{const D=i.subtract(I,u,h),b=i.subtract(c,d,u);return i.cross(D,D,b),i.dot(D,f)},C=h=>{let u;const d=[];for(;h.next;){const f=h.next;d.push(h.v1),h.v1=null,h.v2=null,h.next=null,h.prev=null,h=f}return d.length>0&&(u=o.create(d)),u},l=h=>{if(h.length<2)return h;const u=h[0].plane,d=h.slice(),f=new Map;for(;d.length>0;){const b=d.shift(),m=n(b);for(let x=0;x<m.length;x++){const F=m[x],k=a(f,F);if(k){const v=g(F,k,u);if(v[0]>=0&&v[1]>=0){const M=k.next,H=F.next;F.prev.next=k.next,F.next.prev=k.prev,k.prev.next=F.next,k.next.prev=F.prev,F.v1=null,F.v2=null,F.next=null,F.prev=null,r(f,k),k.v1=null,k.v2=null,k.next=null,k.prev=null;const P=(K,O,W)=>{const $={v1:W.v1,v2:O.v2,next:O.next,prev:W.prev};W.prev.next=$,O.next.prev=$,r(K,O),O.v1=null,O.v2=null,O.next=null,O.prev=null,r(K,W),W.v1=null,W.v2=null,W.next=null,W.prev=null};v[0]===0&&P(f,M,M.prev),v[1]===0&&P(f,H,H.prev)}}else F.next&&s(f,F)}}const D=[];return f.forEach(b=>{const m=C(b);m&&D.push(m)}),f.clear(),D},Q=(h,u)=>Math.abs(h[3]-u[3])<15e-8?e(h,u):!1,E=(h,u)=>{const d=[];u.forEach(D=>{const b=d.find(m=>Q(m[0],o.plane(D)));b?b[1].push(D):d.push([o.plane(D),[D]])});let f=[];return d.forEach(D=>{const b=D[1],m=l(b);f=f.concat(m)}),f};A.exports=E}}),Xst=oe({"node_modules/@jscad/modeling/src/operations/modifiers/insertTjunctions.js"(t,A){var e=Br(),i=ho(),o=Xs(),n=g=>`${g}`,s=(g,I,c,B,C,l)=>{const Q=n(B),E=n(C),h=`${Q}/${E}`,u=`${E}/${Q}`;if(g.has(u))return r(g,I,c,C,B,null),null;const d={vertex0:B,vertex1:C,polygonindex:l};return g.has(h)?g.get(h).push(d):g.set(h,[d]),I.has(Q)?I.get(Q).push(h):I.set(Q,[h]),c.has(E)?c.get(E).push(h):c.set(E,[h]),h},r=(g,I,c,B,C,l)=>{const Q=n(B),E=n(C),h=`${Q}/${E}`;let u=-1;const d=g.get(h);for(let f=0;f<d.length;f++){const D=d[f];let b=n(D.vertex0);if(b===Q&&(b=n(D.vertex1),b===E&&!(l!==null&&D.polygonindex!==l))){u=f;break}}d.splice(u,1),d.length===0&&g.delete(h),u=I.get(Q).indexOf(h),I.get(Q).splice(u,1),I.get(Q).length===0&&I.delete(Q),u=c.get(E).indexOf(h),c.get(E).splice(u,1),c.get(E).length===0&&c.delete(E)},a=g=>{const I=new Map;for(let c=0;c<g.length;c++){const B=g[c],C=B.vertices.length;if(C>=3){let l=B.vertices[0],Q=n(l);for(let E=0;E<C;E++){let h=E+1;h===C&&(h=0);const u=B.vertices[h],d=n(u),f=`${Q}/${d}`,D=`${d}/${Q}`;if(I.has(D)){const b=I.get(D);b.splice(-1,1),b.length===0&&I.delete(D)}else{const b={vertex0:l,vertex1:u,polygonindex:c};I.has(f)?I.get(f).push(b):I.set(f,[b])}l=u,Q=d}}else console.warn("warning: invalid polygon found during insertTjunctions")}if(I.size>0){const c=new Map,B=new Map,C=new Map;for(const[Q,E]of I)C.set(Q,!0),E.forEach(h=>{const u=n(h.vertex0),d=n(h.vertex1);c.has(u)?c.get(u).push(Q):c.set(u,[Q]),B.has(d)?B.get(d).push(Q):B.set(d,[Q])});const l=g.slice(0);for(;I.size!==0;){for(const E of I.keys())C.set(E,!0);let Q=!1;for(;;){const E=Array.from(C.keys());if(E.length===0)break;const h=E[0];let u=!0;if(I.has(h)){const f=I.get(h)[0];for(let D=0;D<2;D++){const b=D===0?f.vertex0:f.vertex1,m=D===0?f.vertex1:f.vertex0,x=n(b),F=n(m);let k=[];D===0?B.has(x)&&(k=B.get(x)):c.has(x)&&(k=c.get(x));for(let v=0;v<k.length;v++){const M=k[v],H=I.get(M)[0],P=D===0?H.vertex0:H.vertex1;if(D===0?H.vertex1:H.vertex0,n(P)===F){r(I,c,B,b,m,null),r(I,c,B,m,b,null),u=!1,D=2,Q=!0;break}else{const O=b,W=m,$=P,oA=i.subtract(i.create(),$,O),IA=i.dot(i.subtract(i.create(),W,O),oA)/i.dot(oA,oA);if(IA>0&&IA<1){const tA=i.scale(i.create(),oA,IA);if(i.add(tA,tA,O),i.squaredDistance(tA,W)<e.EPS*e.EPS){const gA=H.polygonindex,dA=l[gA],SA=n(H.vertex1);let RA=-1;for(let hA=0;hA<dA.vertices.length;hA++)if(n(dA.vertices[hA])===SA){RA=hA;break}const NA=dA.vertices.slice(0);NA.splice(RA,0,m);const qA=o.create(NA);l[gA]=qA,r(I,c,B,H.vertex0,H.vertex1,gA);const BA=s(I,c,B,H.vertex0,m,gA),fA=s(I,c,B,m,H.vertex1,gA);BA!==null&&C.set(BA,!0),fA!==null&&C.set(fA,!0),u=!1,D=2,Q=!0;break}}}}}}u&&C.delete(h)}if(!Q)break}g=l}return I.clear(),g};A.exports=a}}),$st=oe({"node_modules/@jscad/modeling/src/operations/modifiers/triangulatePolygons.js"(t,A){var e=ho(),i=Xs(),o=(s,r,a)=>{const g=r.vertices.length;if(g>3){if(g>4){const B=[0,0,0];r.vertices.forEach(C=>e.add(B,B,C)),e.snap(B,e.divide(B,B,[g,g,g]),s);for(let C=0;C<g;C++){const l=i.create([B,r.vertices[C],r.vertices[(C+1)%g]]);r.color&&(l.color=r.color),a.push(l)}return}const I=i.create([r.vertices[0],r.vertices[1],r.vertices[2]]),c=i.create([r.vertices[0],r.vertices[2],r.vertices[3]]);r.color&&(I.color=r.color,c.color=r.color),a.push(I,c);return}a.push(r)},n=(s,r)=>{const a=[];return r.forEach(g=>{o(s,g,a)}),a};A.exports=n}}),Art=oe({"node_modules/@jscad/modeling/src/operations/modifiers/generalize.js"(t,A){var e=Gn(),i=Cx(),o=Kn(),n=Tn(),s=Qg(),r=y8A(),a=zst(),g=Xst(),I=$st(),c=(Q,E)=>E,B=(Q,E)=>E,C=(Q,E)=>{const h={snap:!1,simplify:!1,triangulate:!1},{snap:u,simplify:d,triangulate:f}=Object.assign({},h,Q),D=i(E);let b=n.toPolygons(E);u&&(b=r(D,b)),d&&(b=a(D,b)),f&&(b=g(b),b=I(D,b));const m=Object.assign({},E);return m.polygons=b,m},l=(Q,...E)=>{if(E=e(E),E.length===0)throw new Error("wrong number of arguments");const h=E.map(u=>{if(s.isA(u))return c(Q,u);if(o.isA(u))return B(Q,u);if(n.isA(u))return C(Q,u);throw new Error("invalid geometry")});return h.length===1?h[0]:h};A.exports=l}}),ert=oe({"node_modules/@jscad/modeling/src/operations/modifiers/snap.js"(t,A){var e=Gn(),i=Bs(),o=Kn(),n=Tn(),s=Qg(),r=Cx(),a=y8A(),g=C=>{const l=r(C),E=s.toPoints(C).map(h=>i.snap(i.create(),h,l));return s.create(E)},I=C=>{const l=r(C);let E=o.toSides(C).map(h=>[i.snap(i.create(),h[0],l),i.snap(i.create(),h[1],l)]);return E=E.filter(h=>!i.equals(h[0],h[1])),o.create(E)},c=C=>{const l=r(C),Q=n.toPolygons(C),E=a(l,Q);return n.create(E)},B=(...C)=>{if(C=e(C),C.length===0)throw new Error("wrong number of arguments");const l=C.map(Q=>s.isA(Q)?g(Q):o.isA(Q)?I(Q):n.isA(Q)?c(Q):Q);return l.length===1?l[0]:l};A.exports=B}}),trt=oe({"node_modules/@jscad/modeling/src/operations/modifiers/index.js"(t,A){A.exports={generalize:Art(),snap:ert(),retessellate:yU()}}}),irt=oe({"node_modules/@jscad/modeling/src/utils/padArrayToLength.js"(t,A){var e=(i,o,n)=>{for(i=i.slice();i.length<n;)i.push(o);return i};A.exports=e}}),ort=oe({"node_modules/@jscad/modeling/src/operations/transforms/align.js"(t,A){var e=Gn(),i=irt(),o=qcA(),{translate:n}=_G(),s=I=>{if(!Array.isArray(I.modes)||I.modes.length>3)throw new Error("align(): modes must be an array of length <= 3");if(I.modes=i(I.modes,"none",3),I.modes.filter(c=>["center","max","min","none"].includes(c)).length!==3)throw new Error('align(): all modes must be one of "center", "max" or "min"');if(!Array.isArray(I.relativeTo)||I.relativeTo.length>3)throw new Error("align(): relativeTo must be an array of length <= 3");if(I.relativeTo=i(I.relativeTo,0,3),I.relativeTo.filter(c=>Number.isFinite(c)||c==null).length!==3)throw new Error("align(): all relativeTo values must be a number, or null.");if(typeof I.grouped!="boolean")throw new Error("align(): grouped must be a boolean value.");return I},r=(I,c,B)=>{for(let C=0;C<3;C++)I[C]==null&&(c[C]==="center"?I[C]=(B[0][C]+B[1][C])/2:c[C]==="max"?I[C]=B[1][C]:c[C]==="min"&&(I[C]=B[0][C]));return I},a=(I,c,B)=>{const C=o(I),l=[0,0,0];for(let Q=0;Q<3;Q++)c[Q]==="center"?l[Q]=B[Q]-(C[0][Q]+C[1][Q])/2:c[Q]==="max"?l[Q]=B[Q]-C[1][Q]:c[Q]==="min"&&(l[Q]=B[Q]-C[0][Q]);return n(l,I)},g=(I,...c)=>{I=Object.assign({},{modes:["center","center","min"],relativeTo:[0,0,0],grouped:!1},I),I=s(I);let{modes:C,relativeTo:l,grouped:Q}=I;if(c=e(c),c.length===0)throw new Error("align(): No geometries were provided to act upon");if(l.filter(E=>E==null).length){const E=o(c);l=r(l,C,E)}return Q?c=a(c,C,l):c=c.map(E=>a(E,C,l)),c.length===1?c[0]:c};A.exports=g}}),pO=oe({"node_modules/@jscad/modeling/src/operations/transforms/center.js"(t,A){var e=Gn(),i=Kn(),o=Tn(),n=Qg(),s=NG(),{translate:r}=_G(),a=(C,l)=>{const Q={axes:[!0,!0,!0],relativeTo:[0,0,0]},{axes:E,relativeTo:h}=Object.assign({},Q,C),u=s(l),d=[0,0,0];return E[0]&&(d[0]=h[0]-(u[0][0]+(u[1][0]-u[0][0])/2)),E[1]&&(d[1]=h[1]-(u[0][1]+(u[1][1]-u[0][1])/2)),E[2]&&(d[2]=h[2]-(u[0][2]+(u[1][2]-u[0][2])/2)),r(d,l)},g=(C,...l)=>{const Q={axes:[!0,!0,!0],relativeTo:[0,0,0]},{axes:E,relativeTo:h}=Object.assign({},Q,C);if(l=e(l),l.length===0)throw new Error("wrong number of arguments");if(h.length!==3)throw new Error("relativeTo must be an array of length 3");C={axes:E,relativeTo:h};const u=l.map(d=>n.isA(d)||i.isA(d)||o.isA(d)?a(C,d):d);return u.length===1?u[0]:u},I=(...C)=>g({axes:[!0,!1,!1]},C),c=(...C)=>g({axes:[!1,!0,!1]},C),B=(...C)=>g({axes:[!1,!1,!0]},C);A.exports={center:g,centerX:I,centerY:c,centerZ:B}}}),fO=oe({"node_modules/@jscad/modeling/src/operations/transforms/scale.js"(t,A){var e=Gn(),i=_g(),o=Kn(),n=Tn(),s=Qg(),r=(c,...B)=>{if(!Array.isArray(c))throw new Error("factors must be an array");if(B=e(B),B.length===0)throw new Error("wrong number of arguments");for(c=c.slice();c.length<3;)c.push(1);if(c[0]<=0||c[1]<=0||c[2]<=0)throw new Error("factors must be positive");const C=i.fromScaling(i.create(),c),l=B.map(Q=>s.isA(Q)?s.transform(C,Q):o.isA(Q)?o.transform(C,Q):n.isA(Q)?n.transform(C,Q):Q);return l.length===1?l[0]:l},a=(c,...B)=>r([c,1,1],B),g=(c,...B)=>r([1,c,1],B),I=(c,...B)=>r([1,1,c],B);A.exports={scale:r,scaleX:a,scaleY:g,scaleZ:I}}}),nrt=oe({"node_modules/@jscad/modeling/src/operations/transforms/transform.js"(t,A){var e=Gn(),i=Kn(),o=Tn(),n=Qg(),s=(r,...a)=>{if(a=e(a),a.length===0)throw new Error("wrong number of arguments");const g=a.map(I=>n.isA(I)?n.transform(r,I):i.isA(I)?i.transform(r,I):o.isA(I)?o.transform(r,I):I);return g.length===1?g[0]:g};A.exports=s}}),vG=oe({"node_modules/@jscad/modeling/src/operations/transforms/index.js"(t,A){A.exports={align:ort(),center:pO().center,centerX:pO().centerX,centerY:pO().centerY,centerZ:pO().centerZ,mirror:dU().mirror,mirrorX:dU().mirrorX,mirrorY:dU().mirrorY,mirrorZ:dU().mirrorZ,rotate:pU().rotate,rotateX:pU().rotateX,rotateY:pU().rotateY,rotateZ:pU().rotateZ,scale:fO().scale,scaleX:fO().scaleX,scaleY:fO().scaleY,scaleZ:fO().scaleZ,transform:nrt(),translate:_G().translate,translateX:_G().translateX,translateY:_G().translateY,translateZ:_G().translateZ}}}),yO=oe({"node_modules/@jscad/modeling/src/index.js"(t,A){A.exports={colors:lO(),curves:ent(),geometries:HcA(),maths:Snt(),measurements:Mnt(),primitives:lx(),text:ZcA(),utils:l8A(),booleans:mM(),expansions:eBA(),extrusions:wU(),hulls:jst(),modifiers:trt(),transforms:vG()}}}),srt=oe({"node_modules/ms/index.js"(t,A){var e=1e3,i=e*60,o=i*60,n=o*24,s=n*7,r=n*365.25;A.exports=function(B,C){C=C||{};var l=typeof B;if(l==="string"&&B.length>0)return a(B);if(l==="number"&&isFinite(B))return C.long?I(B):g(B);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(B))};function a(B){if(B=String(B),!(B.length>100)){var C=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(B);if(C){var l=parseFloat(C[1]),Q=(C[2]||"ms").toLowerCase();switch(Q){case"years":case"year":case"yrs":case"yr":case"y":return l*r;case"weeks":case"week":case"w":return l*s;case"days":case"day":case"d":return l*n;case"hours":case"hour":case"hrs":case"hr":case"h":return l*o;case"minutes":case"minute":case"mins":case"min":case"m":return l*i;case"seconds":case"second":case"secs":case"sec":case"s":return l*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return l;default:return}}}}function g(B){var C=Math.abs(B);return C>=n?Math.round(B/n)+"d":C>=o?Math.round(B/o)+"h":C>=i?Math.round(B/i)+"m":C>=e?Math.round(B/e)+"s":B+"ms"}function I(B){var C=Math.abs(B);return C>=n?c(B,C,n,"day"):C>=o?c(B,C,o,"hour"):C>=i?c(B,C,i,"minute"):C>=e?c(B,C,e,"second"):B+" ms"}function c(B,C,l,Q){var E=C>=l*1.5;return Math.round(B/l)+" "+Q+(E?"s":"")}}}),rrt=oe({"node_modules/debug/src/common.js"(t,A){function e(i){n.debug=n,n.default=n,n.coerce=c,n.disable=g,n.enable=r,n.enabled=I,n.humanize=srt(),n.destroy=B,Object.keys(i).forEach(C=>{n[C]=i[C]}),n.names=[],n.skips=[],n.formatters={};function o(C){let l=0;for(let Q=0;Q<C.length;Q++)l=(l<<5)-l+C.charCodeAt(Q),l|=0;return n.colors[Math.abs(l)%n.colors.length]}n.selectColor=o;function n(C){let l,Q=null,E,h;function u(...d){if(!u.enabled)return;const f=u,D=Number(new Date),b=D-(l||D);f.diff=b,f.prev=l,f.curr=D,l=D,d[0]=n.coerce(d[0]),typeof d[0]!="string"&&d.unshift("%O");let m=0;d[0]=d[0].replace(/%([a-zA-Z%])/g,(F,k)=>{if(F==="%%")return"%";m++;const v=n.formatters[k];if(typeof v=="function"){const M=d[m];F=v.call(f,M),d.splice(m,1),m--}return F}),n.formatArgs.call(f,d),(f.log||n.log).apply(f,d)}return u.namespace=C,u.useColors=n.useColors(),u.color=n.selectColor(C),u.extend=s,u.destroy=n.destroy,Object.defineProperty(u,"enabled",{enumerable:!0,configurable:!1,get:()=>Q!==null?Q:(E!==n.namespaces&&(E=n.namespaces,h=n.enabled(C)),h),set:d=>{Q=d}}),typeof n.init=="function"&&n.init(u),u}function s(C,l){const Q=n(this.namespace+(typeof l>"u"?":":l)+C);return Q.log=this.log,Q}function r(C){n.save(C),n.namespaces=C,n.names=[],n.skips=[];const l=(typeof C=="string"?C:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const Q of l)Q[0]==="-"?n.skips.push(Q.slice(1)):n.names.push(Q)}function a(C,l){let Q=0,E=0,h=-1,u=0;for(;Q<C.length;)if(E<l.length&&(l[E]===C[Q]||l[E]==="*"))l[E]==="*"?(h=E,u=Q,E++):(Q++,E++);else if(h!==-1)E=h+1,u++,Q=u;else return!1;for(;E<l.length&&l[E]==="*";)E++;return E===l.length}function g(){const C=[...n.names,...n.skips.map(l=>"-"+l)].join(",");return n.enable(""),C}function I(C){for(const l of n.skips)if(a(C,l))return!1;for(const l of n.names)if(a(C,l))return!0;return!1}function c(C){return C instanceof Error?C.stack||C.message:C}function B(){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 n.enable(n.load()),n}A.exports=e}}),art=oe({"node_modules/debug/src/browser.js"(t,A){t.formatArgs=i,t.save=o,t.load=n,t.useColors=e,t.storage=s(),t.destroy=(()=>{let a=!1;return()=>{a||(a=!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 e(){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 a;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&&(a=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(a[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function i(a){if(a[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+a[0]+(this.useColors?"%c ":" ")+"+"+A.exports.humanize(this.diff),!this.useColors)return;const g="color: "+this.color;a.splice(1,0,g,"color: inherit");let I=0,c=0;a[0].replace(/%[a-zA-Z%]/g,B=>{B!=="%%"&&(I++,B==="%c"&&(c=I))}),a.splice(c,0,g)}t.log=console.debug||console.log||(()=>{});function o(a){try{a?t.storage.setItem("debug",a):t.storage.removeItem("debug")}catch{}}function n(){let a;try{a=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch{}return!a&&typeof GcA<"u"&&"env"in GcA&&(a=GcA.env.DEBUG),a}function s(){try{return localStorage}catch{}}A.exports=rrt()(t);var{formatters:r}=A.exports;r.j=function(a){try{return JSON.stringify(a)}catch(g){return"[UnexpectedJSONParseError]: "+g.message}}}}),w8A=AA.createContext(null),du=()=>{const t=AA.useContext(w8A);if(!t)throw new Error("useThree must be used within a ThreeProvider");return t},mU=(t,A=[])=>{const{addFrameListener:e,removeFrameListener:i}=du();zi.useEffect(()=>(e(t),()=>i(t)),[e,i,...A])},m8A=AA.createContext(null),grt=()=>{const t=AA.useContext(m8A);if(!t)throw new Error("useHover must be used within a HoverProvider");return t},Irt=({children:t})=>{const{camera:A,renderer:e}=du(),[i,o]=AA.useState([]),n=AA.useMemo(()=>new eme,[]),s=AA.useMemo(()=>new go,[]),r=AA.useRef(i);r.current=i;const a=AA.useRef(null),g=AA.useCallback(l=>{o(Q=>[...Q,l])},[]),I=AA.useCallback(l=>{if(a.current){let Q=!1,E=a.current.object;for(;E;){if(E===l){Q=!0;break}E=E.parent}Q&&(a.current.onUnhover(),a.current=null)}o(Q=>Q.filter(E=>E.object!==l))},[]),c=AA.useCallback(l=>{let Q=l;for(;Q;){const E=r.current.find(h=>h.object===Q);if(E)return E;Q=Q.parent}},[]),B=AA.useCallback(l=>{if(!e.domElement)return;const Q=e.domElement.getBoundingClientRect();s.x=(l.clientX-Q.left)/Q.width*2-1,s.y=-((l.clientY-Q.top)/Q.height)*2+1,n.setFromCamera(s,A);const E=r.current.map(u=>u.object);if(E.length===0){a.current&&(a.current.onUnhover(),a.current=null);return}const h=n.intersectObjects(E,!0);if(h.length>0){const u=h[0],d=c(u.object);if(d){const f={mousePosition:[u.point.x,u.point.y,u.point.z]};a.current!==d?(a.current?.onUnhover(),d.onHover(f),a.current=d):d.onHover(f)}else a.current&&(a.current.onUnhover(),a.current=null)}else a.current&&(a.current.onUnhover(),a.current=null)},[A,e,n,s,c]);AA.useEffect(()=>{const l=e.domElement;return l.addEventListener("mousemove",B),()=>{l.removeEventListener("mousemove",B)}},[e,B]);const C=AA.useMemo(()=>({addHoverable:g,removeHoverable:I}),[g,I]);return V.jsx(m8A.Provider,{value:C,children:t})},crt=({children:t,object:A,onHover:e,onUnhover:i,isHovered:o})=>{const{addHoverable:n,removeHoverable:s}=grt();return AA.useEffect(()=>A?(n({object:A,onHover:e,onUnhover:i}),()=>{s(A)}):void 0,[A,e,i,n,s]),V.jsx(V.Fragment,{children:t})},DU=crt;function Brt(t){return t.replace(/(DEF|USE)\s+([^\s]+)/g,(A,e,i)=>`${e} ${i.replace(/-/g,"_")}`)}async function Crt(t){const A=await fetch(t);if(!A.ok)throw new Error(`Failed to fetch "${t}": ${A.status} ${A.statusText}`);const e=await A.text();return new TSe().parse(Brt(e),t)}typeof window<"u"&&!window.TSCIRCUIT_OBJ_LOADER_CACHE&&(window.TSCIRCUIT_OBJ_LOADER_CACHE=new Map);function lrt(t){const[A,e]=AA.useState(null);return AA.useEffect(()=>{if(!t)return;const i=t.replace(/&cachebust_origin=$/,""),o=window.TSCIRCUIT_OBJ_LOADER_CACHE;let n=!1;async function s(){try{if(i.endsWith(".wrl"))return await Crt(i);const a=await fetch(i);if(!a.ok)throw new Error(`Failed to fetch "${i}": ${a.status} ${a.statusText}`);const g=await a.text(),I=g.match(/newmtl[\s\S]*?endmtl/g),c=new XSe;if(I?.length){const B=I.join(`
|
|
5062
|
-
`).replace(/d 0\./g,"d 1."),C=g.replace(/newmtl[\s\S]*?endmtl/g,"").replace(/^mtllib.*/gm,""),l=new YSe;l.setMaterialOptions({invertTrProperty:!0});const Q=l.parse(B.replace(/Kd\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/g,"Kd $2 $2 $2"),"embedded.mtl");return c.setMaterials(Q),c.parse(C)}return c.parse(g.replace(/^mtllib.*/gm,""))}catch(a){return a}}function r(){if(o.has(i)){const g=o.get(i);return g.result?Promise.resolve(g.result.clone()):g.promise.then(I=>I instanceof Error?I:I.clone())}const a=s().then(g=>(g instanceof Error||o.set(i,{...o.get(i),result:g}),g));return o.set(i,{promise:a,result:null}),a}return r().then(a=>{n||e(a)}).catch(a=>{console.error(a)}),()=>{n=!0}},[t]),A}function Qrt({url:t,position:A,rotation:e,onHover:i,onUnhover:o,isHovered:n,scale:s,isTranslucent:r=!1}){const a=lrt(t),{rootObject:g}=du(),I=AA.useMemo(()=>a&&!(a instanceof Error)?(a.traverse(c=>{if(c instanceof $o&&c.material){const B=C=>{C.transparent=r,C.opacity=r?.5:1,C.depthWrite=!r,C.needsUpdate=!0};Array.isArray(c.material)?c.material.forEach(B):B(c.material)}}),a):new $o(new Aw(.5,.5,.5),new Qu({transparent:!0,color:"red",opacity:.25})),[a,r]);if(AA.useEffect(()=>{if(!(!g||!I))return g.add(I),()=>{g.remove(I)}},[g,I]),AA.useEffect(()=>{I&&(A&&(Array.isArray(A)?I.position.fromArray(A):I.position.copy(A)),e&&(Array.isArray(e)?I.rotation.fromArray(e):I.rotation.copy(e)),s!==void 0&&I.scale.setScalar(s))},[I,Array.isArray(A)?A[0]:A?.x,Array.isArray(A)?A[1]:A?.y,Array.isArray(A)?A[2]:A?.z,Array.isArray(e)?e[0]:e?.x,Array.isArray(e)?e[1]:e?.y,Array.isArray(e)?e[2]:e?.z,s]),a instanceof Error)throw a;return V.jsx(DU,{isHovered:n,onHover:i,onUnhover:o,object:I})}var D8A=new WeakMap,Ert=()=>{const t=new vc;return t.name="fallback-environment-map",t.mapping=qJ,t},hrt=t=>{if(!t)return null;const A=t,e=D8A.get(A);if(e)return e;let i;if(t instanceof yK){const o=new Oj(t);i=o.fromScene(tSe(),.04).texture,o.dispose()}else i=Ert();return D8A.set(A,i),i},S8A=1.25;function urt({gltfUrl:t,position:A,rotation:e,onHover:i,onUnhover:o,isHovered:n,scale:s,isTranslucent:r=!1}){const{renderer:a,rootObject:g}=du(),[I,c]=AA.useState(null),[B,C]=AA.useState(null);if(AA.useEffect(()=>{if(!t)return;const l=new oSe;let Q=!0;return l.load(t,E=>{if(!Q)return;const h=E.scene;h.traverse(u=>{if(u instanceof $o&&u.material){const d=f=>{f.transparent=r,f.opacity=r?.5:1,f.depthWrite=!r,f.needsUpdate=!0};Array.isArray(u.material)?u.material.forEach(d):d(u.material)}}),c(h)},void 0,E=>{if(!Q)return;console.error(`An error happened loading ${t}`,E);const h=E instanceof Error?E:new Error(`Failed to load glTF model from ${t}`);C(h)}),()=>{Q=!1}},[t,r]),AA.useEffect(()=>{I&&(A&&I.position.fromArray(A),e&&I.rotation.fromArray(e),s!==void 0&&I.scale.setScalar(s))},[I,A?.[0],A?.[1],A?.[2],e?.[0],e?.[1],e?.[2],s]),AA.useEffect(()=>{if(!(!g||!I))return g.add(I),()=>{g.remove(I)}},[g,I]),AA.useEffect(()=>{if(!I||!a)return;const l=hrt(a);if(!l)return;const Q=[],E=h=>{h instanceof Qu&&(Q.push({material:h,envMap:h.envMap??null,envMapIntensity:h.envMapIntensity??1}),h.envMap||(h.envMap=l),(typeof h.envMapIntensity!="number"||h.envMapIntensity<S8A)&&(h.envMapIntensity=S8A),h.needsUpdate=!0)};return I.traverse(h=>{if(!(h instanceof $o))return;const u=h.material;Array.isArray(u)?u.forEach(E):u&&E(u)}),()=>{Q.forEach(({material:h,envMap:u,envMapIntensity:d})=>{h.envMap=u,h.envMapIntensity=d,h.needsUpdate=!0})}},[I,a]),AA.useEffect(()=>{I&&I.traverse(l=>{l instanceof $o&&l.material instanceof Qu&&(n?(l.material.emissive.setHex(255),l.material.emissiveIntensity=.2):l.material.emissiveIntensity=0)})},[n,I]),B)throw B;return I?V.jsx(DU,{isHovered:n,onHover:i,onUnhover:o,object:I}):null}var drt=fr(A5A()),prt=fr(yO()),b8A={in:25.4,inch:25.4,mil:.0254,mm:1,m:1e3,cm:10,ft:304.8,feet:304.8},pa=t=>{let A=typeof t=="number"?"mm":t.replace(/^[^a-zA-Z]+/g,"").toLowerCase();A||(A="mm");const e=typeof t=="number"?t:Number.parseFloat(t.split(A)[0]);if(A in b8A)return e*b8A[A];throw new Error(`Unsupported unit: ${A}`)},SU=pa,x8A={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:{fs:1e-12,ps:1e-9,ns:1e-6,us:.001,µs:.001,ms:1,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}}},oBA=new Set;for(const[t,A]of Object.entries(x8A)){oBA.add(t);for(const e of Object.keys(A.variants))oBA.add(e)}function frt(t){for(const[A,e]of Object.entries(x8A))if(t in e.variants)return{baseUnit:e.baseUnit,conversionFactor:e.variants[t]};return{baseUnit:t,conversionFactor:1}}var k8A={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};function Iw(t){if(t==null)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:r,unitOfValue:a}=Iw(t.x),g=Iw(t.x),I=Iw(t.y);return g.value===null||I.value===null?{parsedUnit:null,unitOfValue:null,value:null}:{parsedUnit:r,unitOfValue:a,value:{x:g.value,y:I.value}}}const e=t.toString().split("").reverse().join("").match(/[^\d\s]+/)?.[0];if(!e)throw new Error(`Could not determine unit: "${t}"`);const i=e.split("").reverse().join(""),o=t.slice(0,-i.length);if(i in k8A&&!oBA.has(i)){const r=k8A[i];return{parsedUnit:null,unitOfValue:null,value:Number.parseFloat(o)*r}}const{baseUnit:n,conversionFactor:s}=frt(i);return{parsedUnit:i,unitOfValue:n,value:s*Number.parseFloat(o)}}var nBA=Y().or(jA()).transform(t=>Iw(t).value),G8A=Y().or(jA()).transform(t=>Iw(t).value).transform(t=>Number.parseFloat(t.toPrecision(12))),yrt=Y().or(jA()).transform(t=>Iw(t).value),DM=Y().or(jA()).transform(t=>Iw(t).value),ie=Y().or(jA()).transform(t=>Iw(t).value),sBA=Y().or(jA()).transform(t=>Iw(t).value),mt=ie;Y().or(jA()).transform(t=>Iw(t).value);var rBA=Y().or(jA()).transform(t=>Iw(t).value),SM=rBA,wrt=Y().datetime(),qf=Y().or(jA()).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)),mrt=jA().or(Y().endsWith("mAh")).transform(t=>{if(typeof t=="string"){const A=t.replace("mAh",""),e=Number.parseFloat(A);if(Number.isNaN(e))throw new Error("Invalid capacity");return e}return t}).describe("Battery capacity in mAh"),Fo=YA({x:mt,y:mt}),aBA=YA({x:mt,y:mt,z:mt}),F8A=YA({width:jA(),height:jA()}),Drt=t=>{const A="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";return Array.from({length:t},()=>A[Math.floor(Math.random()*A.length)]).join("")},Ai=t=>Y().optional().default(()=>`${t}_${Drt(10)}`),bM=Ct(["top_left","top_center","top_right","center_left","center","center_right","bottom_left","bottom_center","bottom_right"]),Srt=Ct(["jlcpcb","macrofab","pcbway","digikey","mouser","lcsc"]),OB=YA({type:kA("source_component"),ftype:Y().optional(),source_component_id:Y(),name:Y(),manufacturer_part_number:Y().optional(),supplier_part_numbers:Ra(Srt,be(Y())).optional(),display_value:Y().optional(),are_pins_interchangeable:Be().optional(),internally_connected_source_port_ids:be(be(Y())).optional(),source_group_id:Y().optional(),subcircuit_id:Y().optional()}),R8A=OB.extend({ftype:kA("simple_capacitor"),capacitance:G8A,max_voltage_rating:DM.optional(),display_capacitance:Y().optional(),max_decoupling_trace_length:mt.optional()}),N8A=OB.extend({ftype:kA("simple_resistor"),resistance:nBA,display_resistance:Y().optional()}),gBA=OB.extend({ftype:kA("simple_diode")}),brt=OB.extend({ftype:kA("simple_fiducial")}),M8A=gBA.extend({ftype:kA("simple_led"),color:Y().optional(),wavelength:Y().optional()}),xrt=OB.extend({ftype:kA("simple_ground")}),_8A=OB.extend({ftype:kA("simple_chip")}),v8A=OB.extend({ftype:kA("simple_power_source"),voltage:DM}),krt=OB.extend({ftype:kA("simple_fuse"),current_rating_amps:jA().describe("Nominal current in amps the fuse is rated for"),voltage_rating_volts:jA().describe("Voltage rating in volts, e.g. ±5V would be 5")}),U8A=OB.extend({ftype:kA("simple_battery"),capacity:mrt}),L8A=OB.extend({ftype:kA("simple_inductor"),inductance:yrt,max_current_rating:jA().optional()}),H8A=OB.extend({ftype:kA("simple_push_button")}),Y8A=OB.extend({ftype:kA("simple_potentiometer"),max_resistance:nBA}),Grt=OB.extend({ftype:kA("simple_crystal"),frequency:jA().describe("Frequency in Hz"),load_capacitance:jA().optional().describe("Load capacitance in pF")}),J8A=OB.extend({ftype:kA("simple_pin_header"),pin_count:jA(),gender:Ct(["male","female"]).optional().default("male")}),K8A=OB.extend({ftype:kA("simple_pinout")}),T8A=OB.extend({ftype:kA("simple_resonator"),load_capacitance:G8A,equivalent_series_resistance:nBA.optional(),frequency:sBA}),q8A=OB.extend({ftype:kA("simple_transistor"),transistor_type:Ct(["npn","pnp"])}),P8A=OB.extend({ftype:kA("simple_test_point"),footprint_variant:Ct(["pad","through_hole"]).optional(),pad_shape:Ct(["rect","circle"]).optional(),pad_diameter:ei([jA(),Y()]).optional(),hole_diameter:ei([jA(),Y()]).optional(),width:ei([jA(),Y()]).optional(),height:ei([jA(),Y()]).optional()}),O8A=OB.extend({ftype:kA("simple_mosfet"),channel_type:Ct(["n","p"]),mosfet_mode:Ct(["enhancement","depletion"])}),W8A=OB.extend({ftype:kA("simple_switch")}),Z8A=YA({type:kA("source_project_metadata"),name:Y().optional(),software_used_string:Y().optional(),project_url:Y().optional(),created_at:wrt.optional()}),Frt=YA({type:kA("source_missing_property_error"),source_missing_property_error_id:Ai("source_missing_property_error"),source_component_id:Y(),property_name:Y(),subcircuit_id:Y().optional(),error_type:kA("source_missing_property_error").default("source_missing_property_error"),message:Y()}).describe("The source code is missing a property"),Rrt=YA({type:kA("source_failed_to_create_component_error"),source_failed_to_create_component_error_id:Ai("source_failed_to_create_component_error"),error_type:kA("source_failed_to_create_component_error").default("source_failed_to_create_component_error"),component_name:Y().optional(),subcircuit_id:Y().optional(),parent_source_component_id:Y().optional(),message:Y(),pcb_center:YA({x:jA().optional(),y:jA().optional()}).optional(),schematic_center:YA({x:jA().optional(),y:jA().optional()}).optional()}).describe("Error emitted when a component fails to be constructed"),V8A=YA({type:kA("source_trace_not_connected_error"),source_trace_not_connected_error_id:Ai("source_trace_not_connected_error"),error_type:kA("source_trace_not_connected_error").default("source_trace_not_connected_error"),message:Y(),subcircuit_id:Y().optional(),source_group_id:Y().optional(),source_trace_id:Y().optional(),connected_source_port_ids:be(Y()).optional(),selectors_not_found:be(Y()).optional()}).describe("Occurs when a source trace selector does not match any ports"),Nrt=YA({type:kA("source_property_ignored_warning"),source_property_ignored_warning_id:Ai("source_property_ignored_warning"),source_component_id:Y(),property_name:Y(),subcircuit_id:Y().optional(),error_type:kA("source_property_ignored_warning").default("source_property_ignored_warning"),message:Y()}).describe("The source property was ignored"),j8A=YA({type:kA("source_pin_missing_trace_warning"),source_pin_missing_trace_warning_id:Ai("source_pin_missing_trace_warning"),warning_type:kA("source_pin_missing_trace_warning").default("source_pin_missing_trace_warning"),message:Y(),source_component_id:Y(),source_port_id:Y(),subcircuit_id:Y().optional()}).describe("Warning emitted when a source component pin is missing a trace connection"),Mrt=OB.extend({ftype:kA("simple_voltage_probe")}),_rt=OB.extend({ftype:kA("interconnect")}),vrt=ei([N8A,R8A,gBA,brt,M8A,xrt,_8A,v8A,U8A,L8A,H8A,Y8A,Grt,J8A,K8A,T8A,W8A,q8A,P8A,O8A,krt,Mrt,_rt,Z8A,Frt,Rrt,V8A,Nrt,j8A]),Urt=YA({type:kA("source_port"),pin_number:jA().optional(),port_hints:be(Y()).optional(),name:Y(),source_port_id:Y(),source_component_id:Y().optional(),source_group_id:Y().optional(),subcircuit_id:Y().optional(),subcircuit_connectivity_map_key:Y().optional(),must_be_connected:Be().optional()}),Lrt=YA({type:kA("source_component_internal_connection"),source_component_internal_connection_id:Y(),source_component_id:Y(),source_port_ids:be(Y()),subcircuit_id:Y().optional()}),Hrt=YA({type:kA("source_trace"),source_trace_id:Y(),connected_source_port_ids:be(Y()),connected_source_net_ids:be(Y()),subcircuit_id:Y().optional(),subcircuit_connectivity_map_key:Y().optional(),max_length:jA().optional(),min_trace_thickness:jA().optional(),display_name:Y().optional()}),Yrt=YA({type:kA("source_group"),source_group_id:Y(),subcircuit_id:Y().optional(),parent_subcircuit_id:Y().optional(),parent_source_group_id:Y().optional(),is_subcircuit:Be().optional(),show_as_schematic_box:Be().optional(),name:Y().optional(),was_automatically_named:Be().optional()}),Jrt=YA({type:kA("source_net"),source_net_id:Y(),name:Y(),member_source_group_ids:be(Y()),is_power:Be().optional(),is_ground:Be().optional(),is_digital_signal:Be().optional(),is_analog_signal:Be().optional(),is_positive_voltage_source:Be().optional(),trace_width:jA().optional(),subcircuit_id:Y().optional(),subcircuit_connectivity_map_key:Y().optional()}),Krt=YA({type:kA("source_board"),source_board_id:Y(),source_group_id:Y(),title:Y().optional()}).describe("Defines a board in the source domain"),Trt=YA({type:kA("source_pcb_ground_plane"),source_pcb_ground_plane_id:Y(),source_group_id:Y(),source_net_id:Y(),subcircuit_id:Y().optional()}).describe("Defines a ground plane in the source domain"),qrt=["top","bottom","inner1","inner2","inner3","inner4","inner5","inner6"],z8A=Ct(qrt),Zr=z8A.or(YA({name:z8A})).transform(t=>typeof t=="string"?t:t.name),hm=Ct(["top","bottom"]),Prt=YA({type:kA("source_manually_placed_via"),source_manually_placed_via_id:Y(),source_group_id:Y(),source_net_id:Y(),subcircuit_id:Y().optional(),source_trace_id:Y().optional()}).describe("Defines a via that is manually placed in the source domain"),Ort=YA({type:kA("source_pin_must_be_connected_error"),source_pin_must_be_connected_error_id:Ai("source_pin_must_be_connected_error"),error_type:kA("source_pin_must_be_connected_error").default("source_pin_must_be_connected_error"),message:Y(),source_component_id:Y(),source_port_id:Y(),subcircuit_id:Y().optional()}).describe("Error emitted when a pin with mustBeConnected attribute is not connected to any trace"),Wrt=YA({type:kA("unknown_error_finding_part"),unknown_error_finding_part_id:Ai("unknown_error_finding_part"),error_type:kA("unknown_error_finding_part").default("unknown_error_finding_part"),message:Y(),source_component_id:Y().optional(),subcircuit_id:Y().optional()}).describe("Error emitted when an unexpected error occurs while finding a part"),Zrt=YA({type:kA("schematic_box"),schematic_component_id:Y().optional(),width:mt,height:mt,is_dashed:Be().default(!1),x:mt,y:mt,subcircuit_id:Y().optional()}).describe("Draws a box on the schematic"),Vrt=YA({type:kA("schematic_path"),schematic_component_id:Y(),fill_color:Ct(["red","blue"]).optional(),is_filled:Be().optional(),points:be(Fo),subcircuit_id:Y().optional()}),jrt=Ra(YA({left_margin:ie.optional(),right_margin:ie.optional(),top_margin:ie.optional(),bottom_margin:ie.optional()})),zrt=YA({left_size:jA(),right_size:jA(),top_size:jA().optional(),bottom_size:jA().optional()}),Xrt=YA({left_side:YA({pins:be(jA()),direction:Ct(["top-to-bottom","bottom-to-top"]).optional()}).optional(),right_side:YA({pins:be(jA()),direction:Ct(["top-to-bottom","bottom-to-top"]).optional()}).optional(),top_side:YA({pins:be(jA()),direction:Ct(["left-to-right","right-to-left"]).optional()}).optional(),bottom_side:YA({pins:be(jA()),direction:Ct(["left-to-right","right-to-left"]).optional()}).optional()}),$rt=ei([zrt,Xrt]),Aat=YA({type:kA("schematic_component"),size:F8A,center:Fo,source_component_id:Y().optional(),schematic_component_id:Y(),pin_spacing:ie.optional(),pin_styles:jrt.optional(),box_width:ie.optional(),symbol_name:Y().optional(),port_arrangement:$rt.optional(),port_labels:Ra(Y()).optional(),symbol_display_value:Y().optional(),subcircuit_id:Y().optional(),schematic_group_id:Y().optional(),is_schematic_group:Be().optional(),source_group_id:Y().optional(),is_box_with_pins:Be().optional().default(!0)}),eat=YA({type:kA("schematic_line"),schematic_line_id:Ai("schematic_line"),schematic_component_id:Y(),x1:mt,y1:mt,x2:mt,y2:mt,stroke_width:mt.nullable().optional(),color:Y().default("#000000"),is_dashed:Be().default(!1),subcircuit_id:Y().optional()}).describe("Draws a styled line on the schematic"),tat=YA({type:kA("schematic_rect"),schematic_rect_id:Ai("schematic_rect"),schematic_component_id:Y(),center:Fo,width:mt,height:mt,rotation:qf.default(0),stroke_width:mt.nullable().optional(),color:Y().default("#000000"),is_filled:Be().default(!1),fill_color:Y().optional(),is_dashed:Be().default(!1),subcircuit_id:Y().optional()}).describe("Draws a styled rectangle on the schematic"),iat=YA({type:kA("schematic_circle"),schematic_circle_id:Ai("schematic_circle"),schematic_component_id:Y(),center:Fo,radius:mt,stroke_width:mt.nullable().optional(),color:Y().default("#000000"),is_filled:Be().default(!1),fill_color:Y().optional(),is_dashed:Be().default(!1),subcircuit_id:Y().optional()}).describe("Draws a styled circle on the schematic"),oat=YA({type:kA("schematic_arc"),schematic_arc_id:Ai("schematic_arc"),schematic_component_id:Y(),center:Fo,radius:mt,start_angle_degrees:qf,end_angle_degrees:qf,direction:Ct(["clockwise","counterclockwise"]).default("counterclockwise"),stroke_width:mt.nullable().optional(),color:Y().default("#000000"),is_dashed:Be().default(!1),subcircuit_id:Y().optional()}).describe("Draws a styled arc on the schematic"),nat=YA({type:kA("schematic_trace"),schematic_trace_id:Y(),source_trace_id:Y().optional(),junctions:be(YA({x:jA(),y:jA()})),edges:be(YA({from:YA({x:jA(),y:jA()}),to:YA({x:jA(),y:jA()}),is_crossing:Be().optional(),from_schematic_port_id:Y().optional(),to_schematic_port_id:Y().optional()})),subcircuit_id:Y().optional(),subcircuit_connectivity_map_key:Y().optional()}),sat=Ct(["center","left","right","top","bottom"]),rat=YA({type:kA("schematic_text"),schematic_component_id:Y().optional(),schematic_text_id:Y(),text:Y(),font_size:jA().default(.18),position:YA({x:mt,y:mt}),rotation:jA().default(0),anchor:ei([sat.describe("legacy"),bM]).default("center"),color:Y().default("#000000"),subcircuit_id:Y().optional()}),aat=YA({type:kA("schematic_port"),schematic_port_id:Y(),source_port_id:Y(),schematic_component_id:Y().optional(),center:Fo,facing_direction:Ct(["up","down","left","right"]).optional(),distance_from_component_edge:jA().optional(),side_of_component:Ct(["top","bottom","left","right"]).optional(),true_ccw_index:jA().optional(),pin_number:jA().optional(),display_pin_label:Y().optional(),subcircuit_id:Y().optional(),is_connected:Be().optional(),has_input_arrow:Be().optional(),has_output_arrow:Be().optional()}).describe("Defines a port on a schematic component"),gat=YA({type:kA("schematic_net_label"),schematic_net_label_id:Ai("schematic_net_label"),schematic_trace_id:Y().optional(),source_trace_id:Y().optional(),source_net_id:Y(),center:Fo,anchor_position:Fo.optional(),anchor_side:Ct(["top","bottom","left","right"]),text:Y(),symbol_name:Y().optional(),is_movable:Be().optional(),subcircuit_id:Y().optional()}),Iat=YA({type:kA("schematic_error"),schematic_error_id:Y(),error_type:kA("schematic_port_not_found").default("schematic_port_not_found"),message:Y(),subcircuit_id:Y().optional()}).describe("Defines a schematic error on the schematic"),cat=YA({type:kA("schematic_layout_error"),schematic_layout_error_id:Ai("schematic_layout_error"),error_type:kA("schematic_layout_error").default("schematic_layout_error"),message:Y(),source_group_id:Y(),schematic_group_id:Y(),subcircuit_id:Y().optional()}).describe("Error emitted when schematic layout fails for a group"),IBA=YA({type:kA("schematic_debug_object"),label:Y().optional(),subcircuit_id:Y().optional()}),Bat=IBA.extend({shape:kA("rect"),center:Fo,size:F8A}),Cat=IBA.extend({shape:kA("line"),start:Fo,end:Fo}),lat=IBA.extend({shape:kA("point"),center:Fo}),Qat=Fp("shape",[Bat,Cat,lat]),Eat=YA({type:kA("schematic_voltage_probe"),schematic_voltage_probe_id:Y(),source_component_id:Y().optional(),name:Y().optional(),position:Fo,schematic_trace_id:Y(),voltage:DM.optional(),subcircuit_id:Y().optional(),color:Y().optional(),label_alignment:bM.optional()}).describe("Defines a voltage probe measurement point on a schematic trace"),hat=YA({type:kA("schematic_manual_edit_conflict_warning"),schematic_manual_edit_conflict_warning_id:Ai("schematic_manual_edit_conflict_warning"),warning_type:kA("schematic_manual_edit_conflict_warning").default("schematic_manual_edit_conflict_warning"),message:Y(),schematic_component_id:Y(),schematic_group_id:Y().optional(),subcircuit_id:Y().optional(),source_component_id:Y()}).describe("Warning emitted when a component has both manual placement and explicit schX/schY coordinates"),uat=YA({type:kA("schematic_group"),schematic_group_id:Ai("schematic_group"),source_group_id:Y(),is_subcircuit:Be().optional(),subcircuit_id:Y().optional(),width:ie,height:ie,center:Fo,schematic_component_ids:be(Y()),show_as_schematic_box:Be().optional(),name:Y().optional(),description:Y().optional()}).describe("Defines a group of components on the schematic"),dat=YA({type:kA("schematic_table"),schematic_table_id:Ai("schematic_table"),anchor_position:Fo,column_widths:be(mt),row_heights:be(mt),cell_padding:mt.optional(),border_width:mt.optional(),subcircuit_id:Y().optional(),schematic_component_id:Y().optional(),anchor:bM.optional()}).describe("Defines a table on the schematic"),pat=YA({type:kA("schematic_table_cell"),schematic_table_cell_id:Ai("schematic_table_cell"),schematic_table_id:Y(),start_row_index:jA(),end_row_index:jA(),start_column_index:jA(),end_column_index:jA(),text:Y().optional(),center:Fo,width:mt,height:mt,horizontal_align:Ct(["left","center","right"]).optional(),vertical_align:Ct(["top","middle","bottom"]).optional(),font_size:mt.optional(),subcircuit_id:Y().optional()}).describe("Defines a cell within a schematic_table"),fat=YA({type:kA("schematic_sheet"),schematic_sheet_id:Ai("schematic_sheet"),name:Y().optional(),subcircuit_id:Y().optional()}).describe("Defines a schematic sheet or page that components can be placed on"),yat=YA({x:mt,y:mt,bulge:jA().optional()}),X8A=YA({vertices:be(yat)}),wat=YA({outer_ring:X8A,inner_rings:be(X8A).default([])}),mat=YA({x:mt,y:mt,via:Be().optional(),via_to_layer:Zr.optional()});be(mat);var Dat=YA({x:mt,y:mt,via:Be().optional(),to_layer:Zr.optional(),trace_width:mt.optional()}),Sat=YA({type:kA("pcb_component"),pcb_component_id:Ai("pcb_component"),source_component_id:Y(),center:Fo,layer:Zr,rotation:qf,display_offset_x:Y().optional().describe("How to display the x offset for this part, usually corresponding with how the user specified it"),display_offset_y:Y().optional().describe("How to display the y offset for this part, usually corresponding with how the user specified it"),width:ie,height:ie,do_not_place:Be().optional(),subcircuit_id:Y().optional(),pcb_group_id:Y().optional(),position_mode:Ct(["packed","relative_to_group_anchor","none"]).optional(),positioned_relative_to_pcb_group_id:Y().optional(),positioned_relative_to_pcb_board_id:Y().optional(),obstructs_within_bounds:Be().default(!0).describe("Does this component take up all the space within its bounds on a layer. This is generally true except for when separated pin headers are being represented by a single component (in which case, chips can be placed between the pin headers) or for tall modules where chips fit underneath")}).describe("Defines a component on the PCB"),$8A=YA({type:kA("pcb_hole"),pcb_hole_id:Ai("pcb_hole"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),hole_shape:kA("circle"),hole_diameter:jA(),x:mt,y:mt,is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()});$8A.describe("Defines a circular hole on the PCB");var AWA=YA({type:kA("pcb_hole"),pcb_hole_id:Ai("pcb_hole"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),hole_shape:kA("rect"),hole_width:jA(),hole_height:jA(),x:mt,y:mt,is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()});AWA.describe("Defines a rectangular (square-capable) hole on the PCB. Use equal width/height for square.");var eWA=YA({type:kA("pcb_hole"),pcb_hole_id:Ai("pcb_hole"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),hole_shape:Ct(["circle","square"]),hole_diameter:jA(),x:mt,y:mt,is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()});eWA.describe("Defines a circular or square hole on the PCB");var tWA=YA({type:kA("pcb_hole"),pcb_hole_id:Ai("pcb_hole"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),hole_shape:kA("oval"),hole_width:jA(),hole_height:jA(),x:mt,y:mt,is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()});tWA.describe("Defines an oval hole on the PCB");var iWA=YA({type:kA("pcb_hole"),pcb_hole_id:Ai("pcb_hole"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),hole_shape:kA("pill"),hole_width:jA(),hole_height:jA(),x:mt,y:mt,is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()});iWA.describe("Defines a pill-shaped hole on the PCB");var oWA=YA({type:kA("pcb_hole"),pcb_hole_id:Ai("pcb_hole"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),hole_shape:kA("rotated_pill"),hole_width:jA(),hole_height:jA(),x:mt,y:mt,ccw_rotation:qf,is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()});oWA.describe("Defines a rotated pill-shaped hole on the PCB");var bat=eWA.or(tWA).or(iWA).or(oWA).or($8A).or(AWA),xat=YA({type:kA("pcb_plated_hole"),shape:kA("circle"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),outer_diameter:jA(),hole_diameter:jA(),is_covered_with_solder_mask:Be().optional(),x:mt,y:mt,layers:be(Zr),port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),pcb_plated_hole_id:Ai("pcb_plated_hole"),soldermask_margin:jA().optional()}),kat=YA({type:kA("pcb_plated_hole"),shape:Ct(["oval","pill"]),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),outer_width:jA(),outer_height:jA(),hole_width:jA(),hole_height:jA(),is_covered_with_solder_mask:Be().optional(),x:mt,y:mt,ccw_rotation:qf,layers:be(Zr),port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),pcb_plated_hole_id:Ai("pcb_plated_hole"),soldermask_margin:jA().optional()}),Gat=YA({type:kA("pcb_plated_hole"),shape:kA("circular_hole_with_rect_pad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),hole_shape:kA("circle"),pad_shape:kA("rect"),hole_diameter:jA(),rect_pad_width:jA(),rect_pad_height:jA(),rect_border_radius:jA().optional(),hole_offset_x:mt.default(0),hole_offset_y:mt.default(0),is_covered_with_solder_mask:Be().optional(),x:mt,y:mt,layers:be(Zr),port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),pcb_plated_hole_id:Ai("pcb_plated_hole"),soldermask_margin:jA().optional()}),Fat=YA({type:kA("pcb_plated_hole"),shape:kA("pill_hole_with_rect_pad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),hole_shape:kA("pill"),pad_shape:kA("rect"),hole_width:jA(),hole_height:jA(),rect_pad_width:jA(),rect_pad_height:jA(),rect_border_radius:jA().optional(),hole_offset_x:mt.default(0),hole_offset_y:mt.default(0),is_covered_with_solder_mask:Be().optional(),x:mt,y:mt,layers:be(Zr),port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),pcb_plated_hole_id:Ai("pcb_plated_hole"),soldermask_margin:jA().optional()}),Rat=YA({type:kA("pcb_plated_hole"),shape:kA("rotated_pill_hole_with_rect_pad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),hole_shape:kA("rotated_pill"),pad_shape:kA("rect"),hole_width:jA(),hole_height:jA(),hole_ccw_rotation:qf,rect_pad_width:jA(),rect_pad_height:jA(),rect_border_radius:jA().optional(),rect_ccw_rotation:qf,hole_offset_x:mt.default(0),hole_offset_y:mt.default(0),is_covered_with_solder_mask:Be().optional(),x:mt,y:mt,layers:be(Zr),port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),pcb_plated_hole_id:Ai("pcb_plated_hole"),soldermask_margin:jA().optional()}),Nat=YA({type:kA("pcb_plated_hole"),shape:kA("hole_with_polygon_pad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),hole_shape:Ct(["circle","oval","pill","rotated_pill"]),hole_diameter:jA().optional(),hole_width:jA().optional(),hole_height:jA().optional(),pad_outline:be(YA({x:mt,y:mt})).min(3),hole_offset_x:mt.default(0),hole_offset_y:mt.default(0),is_covered_with_solder_mask:Be().optional(),x:mt,y:mt,layers:be(Zr),port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),pcb_plated_hole_id:Ai("pcb_plated_hole"),soldermask_margin:jA().optional()}),Mat=ei([xat,kat,Gat,Fat,Rat,Nat]),_at=YA({type:kA("pcb_port"),pcb_port_id:Ai("pcb_port"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),source_port_id:Y(),pcb_component_id:Y().optional(),x:mt,y:mt,layers:be(Zr),is_board_pinout:Be().optional()}).describe("Defines a port on the PCB"),vat=YA({type:kA("pcb_smtpad"),shape:kA("circle"),pcb_smtpad_id:Ai("pcb_smtpad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:mt,y:mt,radius:jA(),layer:Zr,port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()}),Uat=YA({type:kA("pcb_smtpad"),shape:kA("rect"),pcb_smtpad_id:Ai("pcb_smtpad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:mt,y:mt,width:jA(),height:jA(),rect_border_radius:jA().optional(),corner_radius:jA().optional(),layer:Zr,port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()}),Lat=YA({type:kA("pcb_smtpad"),shape:kA("rotated_rect"),pcb_smtpad_id:Ai("pcb_smtpad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:mt,y:mt,width:jA(),height:jA(),rect_border_radius:jA().optional(),corner_radius:jA().optional(),ccw_rotation:qf,layer:Zr,port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()}),Hat=YA({type:kA("pcb_smtpad"),shape:kA("pill"),pcb_smtpad_id:Ai("pcb_smtpad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:mt,y:mt,width:jA(),height:jA(),radius:jA(),layer:Zr,port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()}),Yat=YA({type:kA("pcb_smtpad"),shape:kA("rotated_pill"),pcb_smtpad_id:Ai("pcb_smtpad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:mt,y:mt,width:jA(),height:jA(),radius:jA(),ccw_rotation:qf,layer:Zr,port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()}),Jat=YA({type:kA("pcb_smtpad"),shape:kA("polygon"),pcb_smtpad_id:Ai("pcb_smtpad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),points:be(Fo),layer:Zr,port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()}),Kat=Fp("shape",[vat,Uat,Lat,Yat,Hat,Jat]).describe("Defines an SMT pad on the PCB"),Tat=YA({type:kA("pcb_solder_paste"),shape:kA("circle"),pcb_solder_paste_id:Ai("pcb_solder_paste"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:mt,y:mt,radius:jA(),layer:Zr,pcb_component_id:Y().optional(),pcb_smtpad_id:Y().optional()}),qat=YA({type:kA("pcb_solder_paste"),shape:kA("rect"),pcb_solder_paste_id:Ai("pcb_solder_paste"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:mt,y:mt,width:jA(),height:jA(),layer:Zr,pcb_component_id:Y().optional(),pcb_smtpad_id:Y().optional()}),Pat=YA({type:kA("pcb_solder_paste"),shape:kA("pill"),pcb_solder_paste_id:Ai("pcb_solder_paste"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:mt,y:mt,width:jA(),height:jA(),radius:jA(),layer:Zr,pcb_component_id:Y().optional(),pcb_smtpad_id:Y().optional()}),Oat=YA({type:kA("pcb_solder_paste"),shape:kA("rotated_rect"),pcb_solder_paste_id:Ai("pcb_solder_paste"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:mt,y:mt,width:jA(),height:jA(),ccw_rotation:mt,layer:Zr,pcb_component_id:Y().optional(),pcb_smtpad_id:Y().optional()}),Wat=YA({type:kA("pcb_solder_paste"),shape:kA("oval"),pcb_solder_paste_id:Ai("pcb_solder_paste"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:mt,y:mt,width:jA(),height:jA(),layer:Zr,pcb_component_id:Y().optional(),pcb_smtpad_id:Y().optional()}),Zat=ei([Tat,qat,Pat,Oat,Wat]).describe("Defines solderpaste on the PCB"),Vat=YA({type:kA("pcb_text"),pcb_text_id:Ai("pcb_text"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),text:Y(),center:Fo,layer:Zr,width:ie,height:ie,lines:jA(),align:Ct(["bottom-left"])}).describe("Defines text on the PCB"),jat=YA({route_type:kA("wire"),x:mt,y:mt,width:mt,start_pcb_port_id:Y().optional(),end_pcb_port_id:Y().optional(),layer:Zr}),zat=YA({route_type:kA("via"),x:mt,y:mt,hole_diameter:mt.optional(),outer_diameter:mt.optional(),from_layer:Y(),to_layer:Y()}),Xat=ei([jat,zat]),$at=YA({type:kA("pcb_trace"),source_trace_id:Y().optional(),pcb_component_id:Y().optional(),pcb_trace_id:Ai("pcb_trace"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),route_thickness_mode:Ct(["constant","interpolated"]).default("constant").optional(),route_order_index:jA().optional(),should_round_corners:Be().optional(),trace_length:jA().optional(),highlight_color:Y().optional(),route:be(Xat)}).describe("Defines a trace on the PCB"),Agt=YA({type:kA("pcb_trace_error"),pcb_trace_error_id:Ai("pcb_trace_error"),error_type:kA("pcb_trace_error").default("pcb_trace_error"),message:Y(),center:Fo.optional(),pcb_trace_id:Y(),source_trace_id:Y(),pcb_component_ids:be(Y()),pcb_port_ids:be(Y()),subcircuit_id:Y().optional()}).describe("Defines a trace error on the PCB"),egt=YA({type:kA("pcb_trace_missing_error"),pcb_trace_missing_error_id:Ai("pcb_trace_missing_error"),error_type:kA("pcb_trace_missing_error").default("pcb_trace_missing_error"),message:Y(),center:Fo.optional(),source_trace_id:Y(),pcb_component_ids:be(Y()),pcb_port_ids:be(Y()),subcircuit_id:Y().optional()}).describe("Defines an error when a source trace has no corresponding PCB trace"),tgt=YA({type:kA("pcb_port_not_matched_error"),pcb_error_id:Ai("pcb_error"),error_type:kA("pcb_port_not_matched_error").default("pcb_port_not_matched_error"),message:Y(),pcb_component_ids:be(Y()),subcircuit_id:Y().optional()}).describe("Defines a trace error on the PCB where a port is not matched"),igt=YA({type:kA("pcb_port_not_connected_error"),pcb_port_not_connected_error_id:Ai("pcb_port_not_connected_error"),error_type:kA("pcb_port_not_connected_error").default("pcb_port_not_connected_error"),message:Y(),pcb_port_ids:be(Y()),pcb_component_ids:be(Y()),subcircuit_id:Y().optional()}).describe("Defines an error when a pcb port is not connected to any trace"),ogt=YA({type:kA("pcb_net"),pcb_net_id:Ai("pcb_net"),source_net_id:Y().optional(),highlight_color:Y().optional()}).describe("Defines a net on the PCB"),ngt=YA({type:kA("pcb_via"),pcb_via_id:Ai("pcb_via"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),subcircuit_connectivity_map_key:Y().optional(),x:mt,y:mt,outer_diameter:mt.default("0.6mm"),hole_diameter:mt.default("0.25mm"),from_layer:Zr.optional(),to_layer:Zr.optional(),layers:be(Zr),pcb_trace_id:Y().optional(),net_is_assignable:Be().optional(),net_assigned:Be().optional(),is_tented:Be().optional()}).describe("Defines a via on the PCB"),sgt=YA({type:kA("pcb_board"),pcb_board_id:Ai("pcb_board"),pcb_panel_id:Y().optional(),is_subcircuit:Be().optional(),subcircuit_id:Y().optional(),width:ie.optional(),height:ie.optional(),center:Fo,thickness:ie.optional().default(1.4),num_layers:jA().optional().default(4),outline:be(Fo).optional(),shape:Ct(["rect","polygon"]).optional(),material:Ct(["fr4","fr1"]).default("fr4")}).describe("Defines the board outline of the PCB"),rgt=YA({type:kA("pcb_panel"),pcb_panel_id:Ai("pcb_panel"),width:ie,height:ie,center:Fo,covered_with_solder_mask:Be().optional().default(!0)}).describe("Defines a PCB panel that can contain multiple boards"),agt=YA({type:kA("pcb_placement_error"),pcb_placement_error_id:Ai("pcb_placement_error"),error_type:kA("pcb_placement_error").default("pcb_placement_error"),message:Y(),subcircuit_id:Y().optional()}).describe("Defines a placement error on the PCB"),ggt=YA({type:kA("pcb_trace_hint"),pcb_trace_hint_id:Ai("pcb_trace_hint"),pcb_port_id:Y(),pcb_component_id:Y(),route:be(Dat),subcircuit_id:Y().optional()}).describe("A hint that can be used during generation of a PCB trace"),Igt=YA({type:kA("pcb_silkscreen_line"),pcb_silkscreen_line_id:Ai("pcb_silkscreen_line"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),stroke_width:mt.default("0.1mm"),x1:mt,y1:mt,x2:mt,y2:mt,layer:hm}).describe("Defines a silkscreen line on the PCB"),cgt=YA({type:kA("pcb_silkscreen_path"),pcb_silkscreen_path_id:Ai("pcb_silkscreen_path"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),layer:hm,route:be(Fo),stroke_width:ie}).describe("Defines a silkscreen path on the PCB"),Bgt=YA({type:kA("pcb_silkscreen_text"),pcb_silkscreen_text_id:Ai("pcb_silkscreen_text"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),font:kA("tscircuit2024").default("tscircuit2024"),font_size:mt.default("0.2mm"),pcb_component_id:Y(),text:Y(),is_knockout:Be().default(!1).optional(),knockout_padding:YA({left:ie,top:ie,bottom:ie,right:ie}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:jA().optional(),layer:Zr,is_mirrored:Be().default(!1).optional(),anchor_position:Fo.default({x:0,y:0}),anchor_alignment:bM.default("center")}).describe("Defines silkscreen text on the PCB"),Cgt=YA({type:kA("pcb_copper_text"),pcb_copper_text_id:Ai("pcb_copper_text"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),font:kA("tscircuit2024").default("tscircuit2024"),font_size:mt.default("0.2mm"),pcb_component_id:Y(),text:Y(),is_knockout:Be().default(!1).optional(),knockout_padding:YA({left:ie,top:ie,bottom:ie,right:ie}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:jA().optional(),layer:Zr,is_mirrored:Be().default(!1).optional(),anchor_position:Fo.default({x:0,y:0}),anchor_alignment:bM.default("center")}).describe("Defines copper text on the PCB"),lgt=YA({type:kA("pcb_silkscreen_rect"),pcb_silkscreen_rect_id:Ai("pcb_silkscreen_rect"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:Fo,width:ie,height:ie,layer:Zr,stroke_width:ie.default("1mm"),corner_radius:ie.optional(),is_filled:Be().default(!0).optional(),has_stroke:Be().optional(),is_stroke_dashed:Be().optional()}).describe("Defines a silkscreen rect on the PCB"),Qgt=YA({type:kA("pcb_silkscreen_circle"),pcb_silkscreen_circle_id:Ai("pcb_silkscreen_circle"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:Fo,radius:ie,layer:hm,stroke_width:ie.default("1mm")}).describe("Defines a silkscreen circle on the PCB"),Egt=YA({type:kA("pcb_silkscreen_oval"),pcb_silkscreen_oval_id:Ai("pcb_silkscreen_oval"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:Fo,radius_x:mt,radius_y:mt,layer:hm}).describe("Defines a silkscreen oval on the PCB"),hgt=YA({type:kA("pcb_fabrication_note_text"),pcb_fabrication_note_text_id:Ai("pcb_fabrication_note_text"),subcircuit_id:Y().optional(),pcb_group_id:Y().optional(),font:kA("tscircuit2024").default("tscircuit2024"),font_size:mt.default("1mm"),pcb_component_id:Y(),text:Y(),layer:hm,anchor_position:Fo.default({x:0,y:0}),anchor_alignment:Ct(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:Y().optional()}).describe("Defines a fabrication note in text on the PCB, useful for leaving notes for assemblers or fabricators"),ugt=YA({type:kA("pcb_fabrication_note_path"),pcb_fabrication_note_path_id:Ai("pcb_fabrication_note_path"),pcb_component_id:Y(),subcircuit_id:Y().optional(),layer:Zr,route:be(Fo),stroke_width:ie,color:Y().optional()}).describe("Defines a fabrication path on the PCB for fabricators or assemblers"),dgt=YA({type:kA("pcb_fabrication_note_rect"),pcb_fabrication_note_rect_id:Ai("pcb_fabrication_note_rect"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:Fo,width:ie,height:ie,layer:hm,stroke_width:ie.default("0.1mm"),corner_radius:ie.optional(),is_filled:Be().optional(),has_stroke:Be().optional(),is_stroke_dashed:Be().optional(),color:Y().optional()}).describe("Defines a fabrication note rectangle on the PCB"),pgt=YA({type:kA("pcb_fabrication_note_dimension"),pcb_fabrication_note_dimension_id:Ai("pcb_fabrication_note_dimension"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),layer:hm,from:Fo,to:Fo,text:Y().optional(),text_ccw_rotation:jA().optional(),offset:ie.optional(),offset_distance:ie.optional(),offset_direction:YA({x:jA(),y:jA()}).optional(),font:kA("tscircuit2024").default("tscircuit2024"),font_size:ie.default("1mm"),color:Y().optional(),arrow_size:ie.default("1mm")}).describe("Defines a measurement annotation within PCB fabrication notes"),fgt=YA({type:kA("pcb_note_text"),pcb_note_text_id:Ai("pcb_note_text"),pcb_component_id:Y().optional(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),name:Y().optional(),font:kA("tscircuit2024").default("tscircuit2024"),font_size:mt.default("1mm"),text:Y().optional(),anchor_position:Fo.default({x:0,y:0}),anchor_alignment:Ct(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:Y().optional()}).describe("Defines a documentation note in text on the PCB"),ygt=YA({type:kA("pcb_note_rect"),pcb_note_rect_id:Ai("pcb_note_rect"),pcb_component_id:Y().optional(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),name:Y().optional(),text:Y().optional(),center:Fo,width:ie,height:ie,stroke_width:ie.default("0.1mm"),corner_radius:ie.optional(),is_filled:Be().optional(),has_stroke:Be().optional(),is_stroke_dashed:Be().optional(),color:Y().optional()}).describe("Defines a rectangular documentation note on the PCB"),wgt=YA({type:kA("pcb_note_path"),pcb_note_path_id:Ai("pcb_note_path"),pcb_component_id:Y().optional(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),name:Y().optional(),text:Y().optional(),route:be(Fo),stroke_width:ie.default("0.1mm"),color:Y().optional()}).describe("Defines a polyline documentation note on the PCB"),mgt=YA({type:kA("pcb_note_line"),pcb_note_line_id:Ai("pcb_note_line"),pcb_component_id:Y().optional(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),name:Y().optional(),text:Y().optional(),x1:mt,y1:mt,x2:mt,y2:mt,stroke_width:mt.default("0.1mm"),color:Y().optional(),is_dashed:Be().optional()}).describe("Defines a straight documentation note line on the PCB"),Dgt=YA({type:kA("pcb_note_dimension"),pcb_note_dimension_id:Ai("pcb_note_dimension"),pcb_component_id:Y().optional(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),name:Y().optional(),from:Fo,to:Fo,text:Y().optional(),text_ccw_rotation:jA().optional(),offset_distance:ie.optional(),offset_direction:YA({x:jA(),y:jA()}).optional(),font:kA("tscircuit2024").default("tscircuit2024"),font_size:ie.default("1mm"),color:Y().optional(),arrow_size:ie.default("1mm")}).describe("Defines a measurement annotation within PCB documentation notes"),Sgt=YA({type:kA("pcb_footprint_overlap_error"),pcb_error_id:Ai("pcb_error"),error_type:kA("pcb_footprint_overlap_error").default("pcb_footprint_overlap_error"),message:Y(),pcb_smtpad_ids:be(Y()).optional(),pcb_plated_hole_ids:be(Y()).optional(),pcb_hole_ids:be(Y()).optional(),pcb_keepout_ids:be(Y()).optional()}).describe("Error emitted when a pcb footprint overlaps with another element"),bgt=YA({type:kA("pcb_keepout"),shape:kA("rect"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:Fo,width:mt,height:mt,pcb_keepout_id:Y(),layers:be(Y()),description:Y().optional()}).or(YA({type:kA("pcb_keepout"),shape:kA("circle"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:Fo,radius:mt,pcb_keepout_id:Y(),layers:be(Y()),description:Y().optional()})),wO=YA({type:kA("pcb_cutout"),pcb_cutout_id:Ai("pcb_cutout"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),pcb_board_id:Y().optional(),pcb_panel_id:Y().optional()}),xgt=wO.extend({shape:kA("rect"),center:Fo,width:ie,height:ie,rotation:qf.optional(),corner_radius:ie.optional()}),kgt=wO.extend({shape:kA("circle"),center:Fo,radius:ie}),Ggt=wO.extend({shape:kA("polygon"),points:be(Fo)}),Fgt=wO.extend({shape:kA("path"),route:be(Fo),slot_width:ie,slot_length:ie.optional(),space_between_slots:ie.optional(),slot_corner_radius:ie.optional()}),Rgt=Fp("shape",[xgt,kgt,Ggt,Fgt]).describe("Defines a cutout on the PCB, removing board material."),Ngt=YA({type:kA("pcb_missing_footprint_error"),pcb_missing_footprint_error_id:Ai("pcb_missing_footprint_error"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),error_type:kA("pcb_missing_footprint_error").default("pcb_missing_footprint_error"),source_component_id:Y(),message:Y()}).describe("Defines a missing footprint error on the PCB"),Mgt=YA({type:kA("external_footprint_load_error"),external_footprint_load_error_id:Ai("external_footprint_load_error"),pcb_component_id:Y(),source_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),footprinter_string:Y().optional(),error_type:kA("external_footprint_load_error").default("external_footprint_load_error"),message:Y()}).describe("Defines an error when an external footprint fails to load"),_gt=YA({type:kA("circuit_json_footprint_load_error"),circuit_json_footprint_load_error_id:Ai("circuit_json_footprint_load_error"),pcb_component_id:Y(),source_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),error_type:kA("circuit_json_footprint_load_error").default("circuit_json_footprint_load_error"),message:Y(),circuit_json:be(_I()).optional()}).describe("Defines an error when a circuit JSON footprint fails to load"),vgt=YA({type:kA("pcb_group"),pcb_group_id:Ai("pcb_group"),source_group_id:Y(),is_subcircuit:Be().optional(),subcircuit_id:Y().optional(),width:ie.optional(),height:ie.optional(),center:Fo,display_offset_x:Y().optional().describe("How to display the x offset for this group, usually corresponding with how the user specified it"),display_offset_y:Y().optional().describe("How to display the y offset for this group, usually corresponding with how the user specified it"),outline:be(Fo).optional(),anchor_position:Fo.optional(),anchor_alignment:bM.default("center"),position_mode:Ct(["packed","relative_to_group_anchor","none"]).optional(),positioned_relative_to_pcb_group_id:Y().optional(),positioned_relative_to_pcb_board_id:Y().optional(),pcb_component_ids:be(Y()),child_layout_mode:Ct(["packed","none"]).optional(),name:Y().optional(),description:Y().optional(),layout_mode:Y().optional(),autorouter_configuration:YA({trace_clearance:ie}).optional(),autorouter_used_string:Y().optional()}).describe("Defines a group of components on the PCB"),Ugt=YA({type:kA("pcb_autorouting_error"),pcb_error_id:Ai("pcb_autorouting_error"),error_type:kA("pcb_autorouting_error").default("pcb_autorouting_error"),message:Y(),subcircuit_id:Y().optional()}).describe("The autorouting has failed to route a portion of the board"),Lgt=YA({type:kA("pcb_manual_edit_conflict_warning"),pcb_manual_edit_conflict_warning_id:Ai("pcb_manual_edit_conflict_warning"),warning_type:kA("pcb_manual_edit_conflict_warning").default("pcb_manual_edit_conflict_warning"),message:Y(),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),source_component_id:Y()}).describe("Warning emitted when a component has both manual placement and explicit pcbX/pcbY coordinates"),Hgt=YA({type:kA("pcb_breakout_point"),pcb_breakout_point_id:Ai("pcb_breakout_point"),pcb_group_id:Y(),subcircuit_id:Y().optional(),source_trace_id:Y().optional(),source_port_id:Y().optional(),source_net_id:Y().optional(),x:mt,y:mt}).describe("Defines a routing target within a pcb_group for a source_trace or source_net"),Ygt=YA({type:kA("pcb_ground_plane"),pcb_ground_plane_id:Ai("pcb_ground_plane"),source_pcb_ground_plane_id:Y(),source_net_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional()}).describe("Defines a ground plane on the PCB"),Jgt=YA({type:kA("pcb_ground_plane_region"),pcb_ground_plane_region_id:Ai("pcb_ground_plane_region"),pcb_ground_plane_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),layer:Zr,points:be(Fo)}).describe("Defines a polygon region of a ground plane"),Kgt=YA({type:kA("pcb_thermal_spoke"),pcb_thermal_spoke_id:Ai("pcb_thermal_spoke"),pcb_ground_plane_id:Y(),shape:Y(),spoke_count:jA(),spoke_thickness:mt,spoke_inner_diameter:mt,spoke_outer_diameter:mt,pcb_plated_hole_id:Y().optional(),subcircuit_id:Y().optional()}).describe("Pattern for connecting a ground plane to a plated hole"),cBA=YA({type:kA("pcb_copper_pour"),pcb_copper_pour_id:Ai("pcb_copper_pour"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),layer:Zr,source_net_id:Y().optional(),covered_with_solder_mask:Be().optional().default(!0)}),Tgt=cBA.extend({shape:kA("rect"),center:Fo,width:ie,height:ie,rotation:qf.optional()}),qgt=cBA.extend({shape:kA("brep"),brep_shape:wat}),Pgt=cBA.extend({shape:kA("polygon"),points:be(Fo)}),Ogt=Fp("shape",[Tgt,qgt,Pgt]).describe("Defines a copper pour on the PCB."),Wgt=YA({type:kA("pcb_component_outside_board_error"),pcb_component_outside_board_error_id:Ai("pcb_component_outside_board_error"),error_type:kA("pcb_component_outside_board_error").default("pcb_component_outside_board_error"),message:Y(),pcb_component_id:Y(),pcb_board_id:Y(),component_center:Fo,component_bounds:YA({min_x:jA(),max_x:jA(),min_y:jA(),max_y:jA()}),subcircuit_id:Y().optional(),source_component_id:Y().optional()}).describe("Error emitted when a PCB component is placed outside the board boundaries"),Zgt=YA({type:kA("pcb_component_invalid_layer_error"),pcb_component_invalid_layer_error_id:Ai("pcb_component_invalid_layer_error"),error_type:kA("pcb_component_invalid_layer_error").default("pcb_component_invalid_layer_error"),message:Y(),pcb_component_id:Y().optional(),source_component_id:Y(),layer:Zr,subcircuit_id:Y().optional()}).describe("Error emitted when a component is placed on an invalid layer (components can only be on 'top' or 'bottom' layers)"),Vgt=YA({type:kA("pcb_via_clearance_error"),pcb_error_id:Ai("pcb_error"),error_type:kA("pcb_via_clearance_error").default("pcb_via_clearance_error"),message:Y(),pcb_via_ids:be(Y()).min(2),minimum_clearance:mt.optional(),actual_clearance:mt.optional(),pcb_center:YA({x:jA().optional(),y:jA().optional()}).optional(),subcircuit_id:Y().optional()}).describe("Error emitted when vias are closer than the allowed clearance"),jgt=YA({type:kA("pcb_courtyard_rect"),pcb_courtyard_rect_id:Ai("pcb_courtyard_rect"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:Fo,width:ie,height:ie,layer:hm,color:Y().optional()}).describe("Defines a courtyard rectangle on the PCB"),zgt=YA({type:kA("pcb_courtyard_outline"),pcb_courtyard_outline_id:Ai("pcb_courtyard_outline"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),layer:hm,outline:be(Fo).min(2),stroke_width:ie.default("0.1mm"),is_closed:Be().optional(),is_stroke_dashed:Be().optional(),color:Y().optional()}).describe("Defines a courtyard outline on the PCB"),Xgt=YA({type:kA("pcb_courtyard_polygon"),pcb_courtyard_polygon_id:Ai("pcb_courtyard_polygon"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),layer:hm,points:be(Fo).min(3),color:Y().optional()}).describe("Defines a courtyard polygon on the PCB"),$gt=YA({type:kA("cad_component"),cad_component_id:Y(),pcb_component_id:Y(),source_component_id:Y(),position:aBA,rotation:aBA.optional(),size:aBA.optional(),layer:Zr.optional(),subcircuit_id:Y().optional(),footprinter_string:Y().optional(),model_obj_url:Y().optional(),model_stl_url:Y().optional(),model_3mf_url:Y().optional(),model_gltf_url:Y().optional(),model_glb_url:Y().optional(),model_step_url:Y().optional(),model_wrl_url:Y().optional(),model_unit_to_mm_scale_factor:jA().optional(),model_jscad:_I().optional(),show_as_translucent_model:Be().optional()}).describe("Defines a component on the PCB"),AIt=Ct(["sinewave","square","triangle","sawtooth"]),eIt=ei([Y(),jA()]).transform(t=>typeof t=="string"?t.endsWith("%")?parseFloat(t.slice(0,-1))/100:parseFloat(t):t).pipe(jA().min(0,"Duty cycle must be non-negative").max(1,"Duty cycle cannot be greater than 100%")),tIt=YA({type:kA("simulation_voltage_source"),simulation_voltage_source_id:Ai("simulation_voltage_source"),is_dc_source:kA(!0).optional().default(!0),positive_source_port_id:Y().optional(),negative_source_port_id:Y().optional(),positive_source_net_id:Y().optional(),negative_source_net_id:Y().optional(),voltage:DM}).describe("Defines a DC voltage source for simulation"),iIt=YA({type:kA("simulation_voltage_source"),simulation_voltage_source_id:Ai("simulation_voltage_source"),is_dc_source:kA(!1),terminal1_source_port_id:Y().optional(),terminal2_source_port_id:Y().optional(),terminal1_source_net_id:Y().optional(),terminal2_source_net_id:Y().optional(),voltage:DM.optional(),frequency:sBA.optional(),peak_to_peak_voltage:DM.optional(),wave_shape:AIt.optional(),phase:qf.optional(),duty_cycle:eIt.optional()}).describe("Defines an AC voltage source for simulation"),oIt=ei([tIt,iIt]).describe("Defines a voltage source for simulation"),nIt=ei([kA("spice_dc_sweep"),kA("spice_dc_operating_point"),kA("spice_transient_analysis"),kA("spice_ac_analysis")]),sIt=YA({type:kA("simulation_experiment"),simulation_experiment_id:Ai("simulation_experiment"),name:Y(),experiment_type:nIt,time_per_step:rBA.optional(),start_time_ms:SM.optional(),end_time_ms:SM.optional()}).describe("Defines a simulation experiment configuration"),rIt=YA({type:kA("simulation_transient_voltage_graph"),simulation_transient_voltage_graph_id:Ai("simulation_transient_voltage_graph"),simulation_experiment_id:Y(),timestamps_ms:be(jA()).optional(),voltage_levels:be(jA()),source_component_id:Y().optional(),subcircuit_connectivity_map_key:Y().optional(),time_per_step:rBA,start_time_ms:SM,end_time_ms:SM,name:Y().optional(),color:Y().optional()}).describe("Stores voltage measurements over time for a simulation"),aIt=YA({type:kA("simulation_switch"),simulation_switch_id:Ai("simulation_switch"),source_component_id:Y().optional(),closes_at:SM.optional(),opens_at:SM.optional(),starts_closed:Be().optional(),switching_frequency:sBA.optional()}).describe("Defines a switch for simulation timing control"),gIt=YA({type:kA("simulation_voltage_probe"),simulation_voltage_probe_id:Ai("simulation_voltage_probe"),source_component_id:Y().optional(),name:Y().optional(),signal_input_source_port_id:Y().optional(),signal_input_source_net_id:Y().optional(),reference_input_source_port_id:Y().optional(),reference_input_source_net_id:Y().optional(),subcircuit_id:Y().optional(),color:Y().optional()}).describe("Defines a voltage probe for simulation. If a reference input is not provided, it measures against ground. If a reference input is provided, it measures the differential voltage between two points.").superRefine((t,A)=>{if(t.reference_input_source_port_id||t.reference_input_source_net_id){const i=!!t.signal_input_source_port_id||!!t.reference_input_source_port_id,o=!!t.signal_input_source_net_id||!!t.reference_input_source_net_id;i&&o?A.addIssue({code:Wt.custom,message:"Cannot mix port and net connections in a differential probe."}):i?(!t.signal_input_source_port_id||!t.reference_input_source_port_id)&&A.addIssue({code:Wt.custom,message:"Differential port probe requires both signal_input_source_port_id and reference_input_source_port_id."}):o&&(!t.signal_input_source_net_id||!t.reference_input_source_net_id)&&A.addIssue({code:Wt.custom,message:"Differential net probe requires both signal_input_source_net_id and reference_input_source_net_id."})}else!!t.signal_input_source_port_id==!!t.signal_input_source_net_id&&A.addIssue({code:Wt.custom,message:"A voltage probe must have exactly one of signal_input_source_port_id or signal_input_source_net_id."})}),IIt=YA({type:kA("simulation_unknown_experiment_error"),simulation_unknown_experiment_error_id:Ai("simulation_unknown_experiment_error"),error_type:kA("simulation_unknown_experiment_error").default("simulation_unknown_experiment_error"),message:Y(),simulation_experiment_id:Y().optional(),subcircuit_id:Y().optional()}).describe("An unknown error occurred during the simulation experiment.");ei([Hrt,Urt,Lrt,vrt,Jrt,Yrt,_8A,R8A,gBA,M8A,N8A,v8A,U8A,L8A,J8A,K8A,T8A,W8A,q8A,P8A,O8A,Y8A,H8A,Trt,Prt,Krt,Z8A,V8A,j8A,Ort,Wrt,Sat,bat,Ngt,Mgt,_gt,Lgt,Mat,bgt,_at,ogt,Vat,$at,ngt,Kat,Zat,sgt,rgt,vgt,ggt,Igt,cgt,Bgt,Cgt,lgt,Qgt,Egt,Agt,egt,agt,tgt,igt,Vgt,ugt,hgt,dgt,pgt,fgt,ygt,wgt,mgt,Dgt,Ugt,Sgt,Hgt,Rgt,Ygt,Jgt,Kgt,Ogt,Wgt,Zgt,jgt,zgt,Xgt,Zrt,rat,eat,tat,iat,oat,Aat,aat,nat,Vrt,Iat,cat,gat,Qat,Eat,hat,uat,fat,dat,pat,$gt,oIt,sIt,rIt,aIt,gIt,IIt]);var cIt=Object.defineProperty,BIt=(t,A)=>{for(var e in A)cIt(t,e,{get:A[e],enumerable:!0})},eS={};BIt(eS,{axial:()=>Bct,bga:()=>mIt,breakoutheaders:()=>yct,cap:()=>dIt,dfn:()=>WIt,diode:()=>uIt,dip:()=>QIt,electrolytic:()=>olt,hc49:()=>mct,jst:()=>xCt,led:()=>pIt,lqfp:()=>pct,m2host:()=>flt,melf:()=>UBt,micromelf:()=>JBt,minimelf:()=>kBt,mlp:()=>RIt,ms012:()=>Act,ms013:()=>tct,msop:()=>LCt,pad:()=>Dct,pinrow:()=>jIt,platedhole:()=>Elt,potentiometer:()=>elt,pushbutton:()=>lct,qfn:()=>GIt,qfp:()=>FIt,quad:()=>bU,res:()=>fIt,sma:()=>PBt,smb:()=>$Bt,smbf:()=>slt,smc:()=>iCt,smf:()=>VBt,smtpad:()=>llt,sod110:()=>GCt,sod123:()=>act,sod123f:()=>rBt,sod123fl:()=>cBt,sod123w:()=>Jct,sod128:()=>dBt,sod323:()=>Pct,sod323f:()=>iBt,sod323fl:()=>qCt,sod323w:()=>YCt,sod523:()=>Fct,sod723:()=>QBt,sod80:()=>Uct,sod882:()=>$ct,sod882d:()=>NBt,sod923:()=>Vct,soic:()=>SIt,solderjumper:()=>VCt,son:()=>ZCt,sop8:()=>_ct,sot:()=>ult,sot223:()=>rCt,sot23:()=>YIt,sot23w:()=>ECt,sot25:()=>qIt,sot323:()=>Ilt,sot363:()=>LIt,sot457:()=>XCt,sot563:()=>XIt,sot723:()=>oct,sot89:()=>DBt,ssop:()=>MIt,stampboard:()=>Ect,stampreceiver:()=>dct,to220:()=>bBt,to92:()=>kct,to92s:()=>yCt,tssop:()=>vIt,vssop:()=>_Ct});var Bo=(t,A,e)=>({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:"silkscreen_text_1",font:"tscircuit2024",font_size:e,pcb_component_id:"pcb_component_1",text:"{REF}",layer:"top",anchor_position:{x:t,y:A},anchor_alignment:"center"}),Fn=(t,A,e,i,o)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circle",x:A,y:e,hole_diameter:pa(i),outer_diameter:pa(o),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()]}),nWA=Array.from({length:9},(t,A)=>Math.cos(A/8*Math.PI-Math.PI)).map(t=>({x:t,y:-Math.sqrt(1-t**2)}));function Qx(t){return typeof t=="string"?t.trim().toLowerCase().endsWith("mil")?parseFloat(t)*.0254:parseFloat(t):Number(t)}var mO=ei([Y(),jA()]).transform(t=>Qx(t)),CIt=t=>YA({fn:Y(),num_pins:jA().optional().default(6),wide:Be().optional(),narrow:Be().optional(),w:mO.optional(),p:mO.default(t.p??"2.54mm"),id:mO.optional(),od:mO.optional()}).transform(A=>(!A.id&&!A.od?Math.abs(A.p-1.27)<.01?(A.id=Qx("0.55mm"),A.od=Qx("0.95mm")):(A.id=Qx("1.0mm"),A.od=Qx("1.5mm")):A.id?A.od||(A.od=A.id*(1.5/1)):A.id=A.od*(1/1.5),A.w||(A.wide?A.w=Qx("600mil"):A.narrow?A.w=Qx("300mil"):A.w=Qx(t.w??"300mil")),A)),lIt=CIt({}),sWA=(t,A,e,i)=>{const o=t/2,n=A<=o,s=o-1,r=i,a=r*s;return n?{x:-e/2,y:a/2-(A-1)*r}:{x:e/2,y:-a/2+(A-o-1)*r}},QIt=t=>{const A=lIt.parse(t),e=[];for(let g=0;g<A.num_pins;g++){const{x:I,y:c}=sWA(A.num_pins,g+1,A.w,A.p??2.54);e.push(Fn(g+1,I,c,A.id??"0.8mm",A.od??"1mm"))}(A.num_pins/2-1)*A.p+A.od;const o=A.w-A.od-1,n=(A.num_pins/2-1)*A.p+A.od+.4,s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-o/2,y:-n/2},{x:-o/2,y:n/2},...nWA.map(({x:g,y:I})=>({x:g*o/6,y:I*o/6+n/2})),{x:o/2,y:n/2},{x:o/2,y:-n/2},{x:-o/2,y:-n/2}],type:"pcb_silkscreen_path",stroke_width:.1},r=[];for(let g=0;g<A.num_pins;g++){const I=g<A.num_pins/2,c=.6,{y:B}=sWA(A.num_pins,g+1,A.w,A.p??2.54),C=I?-A.w/2-A.od/2-c:A.w/2+A.od/2+c,l=B;r.push({type:"pcb_fabrication_note_text",pcb_fabrication_note_text_id:`pin_${g+1}`,layer:"top",pcb_component_id:`pin_${g+1}`,text:`{pin${g+1}}`,anchor_position:{x:C,y:l},font_size:.3,font:"tscircuit2024",anchor_alignment:"top_left"})}const a=Bo(0,n/2+.5,.4);return{circuitJson:[...e,s,a,...r],parameters:A}},xi=(t,A,e,i,o)=>({type:"pcb_smtpad",x:A,y:e,width:i,height:o,layer:"top",shape:"rect",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(n=>n.toString()):[t.toString()]}),rWA=[{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}],EIt=Object.fromEntries(rWA.map(t=>[t.metric,t])),hIt=Object.fromEntries(rWA.map(t=>[t.imperial,t]));YA({tht:Be(),p:ie.optional(),pw:ie.optional(),ph:ie.optional(),metric:mt.optional(),imperial:mt.optional(),w:ie.optional(),h:ie.optional(),textbottom:Be().optional()});var DO=t=>{let{tht:A,p:e,pw:i,ph:o,metric:n,imperial:s,w:r,h:a,textbottom:g}=t;if(typeof r=="string"&&(r=SU(r)),typeof a=="string"&&(a=SU(a)),typeof e=="string"&&(e=SU(e)),typeof i=="string"&&(i=SU(i)),typeof o=="string"&&(o=SU(o)),a!==void 0&&r!==void 0&&a>r)throw new Error("height cannot be greater than width (rotated footprint not yet implemented)");let I;if(n&&(I=EIt[n]),s&&(I=hIt[s]),I&&(r=I.w_mm_min,a=I.h_mm_min,e=I.p_mm_min,i=I.pw_mm_min,o=I.ph_mm_min),e===void 0||i===void 0||o===void 0)throw new Error("Could not determine required pad dimensions (p, pw, ph)");const c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:e/2,y:o/2+.4},{x:-e/2-i/2-.2,y:o/2+.4},{x:-e/2-i/2-.2,y:-o/2-.4},{x:e/2,y:-o/2-.4}],stroke_width:.1,pcb_silkscreen_path_id:""},B=g?-o/2-.9:o/2+.9,C=Bo(0,B,.2);return A?[Fn(1,-e/2,0,i,i*1/.8),Fn(2,e/2,0,i,i*1/.8),c,C]:[xi(["1","left"],-e/2,0,i,o),xi(["2","right"],e/2,0,i,o),c,C]},uIt=t=>({circuitJson:DO(t),parameters:t}),dIt=t=>({circuitJson:DO(t),parameters:t}),pIt=t=>({circuitJson:DO(t),parameters:t}),fIt=t=>({circuitJson:DO(t),parameters:t}),aWA=(t,{x:A,y:e,radius:i})=>({type:"pcb_smtpad",x:A,y:e,radius:i,layer:"top",shape:"circle",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(o=>o.toString()):[t.toString()]}),gWA="ABCDEFGHIJKLMNOPQRSTUVWXYZ",IWA=Y().transform(t=>{const[A,e]=t.split(/[x ]/);return{x:parseFloat(A),y:parseFloat(e)}}).pipe(YA({x:jA(),y:jA()})),yIt=Y().or(be(_I())).transform(t=>Array.isArray(t)?t:(t.startsWith("(")&&t.endsWith(")")&&(t=t.slice(1,-1)),t.split(",").map(A=>{const e=Number(A);return isNaN(e)?A:e}))).pipe(be(Y().or(jA()))),wIt=YA({fn:Y(),num_pins:jA().optional().default(64),grid:IWA.optional(),p:mt.default("0.8mm"),w:ie.optional(),h:ie.optional(),ball:ie.optional().describe("ball diameter"),pad:ie.optional().describe("pad width/height"),circularpads:Be().optional().describe("use circular pads"),tlorigin:Be().optional(),blorigin:Be().optional(),trorigin:Be().optional(),brorigin:Be().optional(),missing:yIt.default([])}).transform(t=>{let A="tl";if(t.blorigin&&(A="bl"),t.trorigin&&(A="tr"),t.brorigin&&(A="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 o=i.match(/([A-Z]+)(\d+)/);if(!o)return i;const n=gWA.indexOf(o[1]),s=Number.parseInt(o[2])-1;return n*t.grid.x+s+1})),{...t,origin:A}}),mIt=t=>{const A=wIt.parse(t);let{num_pins:e,grid:i,p:o,w:n,h:s,ball:r,pad:a,missing:g}=A;r??=.75/1.27*o,a??=r*.8;const I=[],c=(g??[]).filter(D=>typeof D=="number"),B=i.x*i.y-e;if(g.length===0&&B>0&&(Math.sqrt(B)%1===0?g.push("center"):B===1&&g.push("topleft")),g?.includes("center")){const D=Math.floor(Math.sqrt(B)),b=Math.floor((i.x-D)/2),m=Math.floor((i.y-D)/2);for(let x=m;x<m+D;x++)for(let F=b;F<b+D;F++)c.push(x*i.x+F+1)}g?.includes("topleft")&&c.push(1);const C=new Set(c);let l=0;for(let D=0;D<i.y;D++)for(let b=0;b<i.x;b++){const m=(b-(i.x-1)/2)*o,x=(D-(i.y-1)/2)*o;let F=b,k=D;switch(A.origin){case"bl":F=b,k=i.y-1-D;break;case"br":F=i.x-1-b,k=i.y-1-D;break;case"tr":F=i.x-1-b,k=D;break}let v=k*i.x+F+1;if(C.has(v)){l++;continue}v-=l;const M=[v,`${gWA[k]}${F+1}`];I.push(A.circularpads?aWA(M,{x:m,y:x,radius:a/2}):xi(M,m,x,a,a))}const Q=Bo(0,i.y*o/2,.2),E=o/6;let h;const u=i.x*o/2,d=i.y*o/2;switch(A.origin){case"bl":h=[{x:-u,y:-d},{x:-u,y:-d-E},{x:-u-E,y:-d},{x:-u,y:-d}];break;case"br":h=[{x:u,y:-d},{x:u,y:-d-E},{x:u+E,y:-d},{x:u,y:-d}];break;case"tr":h=[{x:u,y:d},{x:u,y:d+E},{x:u+E,y:d},{x:u,y:d}];break;default:h=[{x:-u,y:d},{x:-u,y:d+E},{x:-u-E,y:d},{x:-u,y:d}];break}const f={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_marker",route:h,stroke_width:.05};return{circuitJson:[...I,Q,f],parameters:A}},SO=(t,A,e,i,o)=>({type:"pcb_smtpad",x:A,y:e,width:i,height:o,radius:o/2,layer:"top",shape:"pill",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(n=>n.toString()):[t.toString()]}),cw=t=>YA({fn:Y(),num_pins:jA().optional().default(8),w:ie.default(ie.parse(t.w??"5.3mm")),p:ie.default(ie.parse(t.p??"1.27mm")),pw:ie.default(ie.parse(t.pw??"0.6mm")),pl:ie.default(ie.parse(t.pl??"1.0mm")),legsoutside:Be().optional().default(t.legsoutside??!1),pillpads:Be().optional().default(t.pillpads??!1)}).transform(A=>(!A.pw&&!A.pl?(A.pw=ie.parse("0.6mm"),A.pl=ie.parse("1.0mm")):A.pw?A.pl||(A.pl=A.pw*(1/.6)):A.pw=A.pl*(.6/1),A)),DIt=cw({}),BBA=t=>{t.widthincludeslegs!==void 0&&(t.legsoutside=!t.widthincludeslegs);const{num_pins:A,pn:e,w:i,p:o,pl:n,legsoutside:s}=t,r=A/2,a=e<=r,g=r-1,I=o,c=I*g,B=s?n/2:-n/2;return a?{x:-i/2-B,y:c/2-(e-1)*I}:{x:i/2+B,y:-c/2+(e-r-1)*I}},SIt=t=>{const A=DIt.parse(t);return{circuitJson:tS(A),parameters:A}},tS=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=BBA({num_pins:t.num_pins,pn:r+1,w:t.w,p:t.p,pl:t.pl,legsoutside:t.legsoutside});t.pillpads?A.push(SO(r+1,a,g,t.pl,t.pw)):A.push(xi(r+1,a,g,t.pl,t.pw))}const e=Math.min(1,t.p/2),i=t.w-(t.legsoutside?0:t.pl*2)-.2,o=(t.num_pins/2-1)*t.p+t.pw+e,n=Bo(0,o/2+.4,o/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:-o/2},{x:-i/2,y:o/2},...nWA.map(({x:r,y:a})=>({x:r*i/6,y:a*i/6+o/2})),{x:i/2,y:o/2},{x:i/2,y:-o/2},{x:-i/2,y:-o/2}]};return[...A,s,n]},cWA=Ct(["leftside","topside","rightside","bottomside","toppin","bottompin","leftpin","rightpin"]),bIt=({num_pins:t,cw:A,ccw:e,startingpin:i})=>{const o=[],n=t/4;let s=1;const r={};for(const a of i??[])r[a]=!0;!r.leftside&&!r.topside&&!r.rightside&&!r.bottomside&&(r.leftside=!0),!r.bottompin&&!r.leftpin&&!r.rightpin&&!r.toppin&&(r.leftside?r.toppin=!0:r.topside?r.rightpin=!0:r.rightside?r.bottompin=!0:r.bottomside&&(r.leftpin=!0)),r.leftside&&r.toppin?s=1:r.leftside&&r.bottompin?s=n:r.bottomside&&r.leftpin?s=n+1:r.bottomside&&r.rightpin?s=n*2:r.rightside&&r.bottompin?s=n*2+1:r.rightside&&r.toppin?s=n*3:r.topside&&r.rightpin?s=n*3+1:r.topside&&r.leftpin&&(s=n*4),o.push(-1);for(let a=0;a<t;a++)o[s]=a+1,e||!A?(s++,s>t&&(s=1)):(s--,s<1&&(s=t));return o},CBA=YA({fn:Y(),cc:Be().default(!0).optional(),ccw:Be().default(!0).optional(),startingpin:Y().or(be(cWA)).transform(t=>typeof t=="string"?t.slice(1,-1).split(","):t).pipe(be(cWA)).optional(),num_pins:jA().optional().default(64),w:ie.optional(),h:ie.optional(),p:ie.default(ie.parse("0.5mm")),pw:ie.optional(),pl:ie.optional(),thermalpad:ei([kA(!0),IWA]).optional(),legsoutside:Be().default(!1)}),lBA=t=>{t.w&&!t.h?t.h=t.w:!t.w&&t.h&&(t.w=t.h);const A=t.num_pins/4;if(!t.p&&!t.pw&&!t.pl&&t.w){const e=A+4;t.p=t.w/e}return!t.p&&t.w&&t.h&&t.pw&&t.pl&&(t.p=(t.w-t.pl*2)/(A-1)),!t.w&&!t.h&&t.p&&(t.w=t.p*(A+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},BWA=CBA.transform(lBA),xIt=["left","bottom","right","top"],kIt=t=>{const{pin_count:A,pn:e,w:i,h:o,p:n,pl:s,legsoutside:r}=t,a=A/4,g=xIt[Math.floor((e-1)/a)],I=(e-1)%a,c=n*(a-1),B=n*(a-1),C=r?s/2:-s/2;switch(g){case"left":return{x:-i/2-C,y:B/2-I*n,o:"vert"};case"bottom":return{x:-c/2+I*n,y:-o/2-C,o:"horz"};case"right":return{x:i/2+C,y:-B/2+I*n,o:"vert"};case"top":return{x:c/2-I*n,y:o/2+C,o:"horz"};default:throw new Error("Invalid pin number")}},bU=t=>{const A=BWA.parse(t),e=[],i=bIt(A),o=A.num_pins/4;for(let r=0;r<A.num_pins;r++){const{x:a,y:g,o:I}=kIt({pin_count:A.num_pins,pn:r+1,w:A.w,h:A.h,p:A.p??.5,pl:A.pl,legsoutside:A.legsoutside});let c=A.pw,B=A.pl;I==="vert"&&([c,B]=[B,c]);const C=i[r+1];e.push(xi(C,a,g,c,B))}if(A.thermalpad)if(typeof A.thermalpad=="boolean"){const r=A.p*(o-1)+A.pw,a=A.p*(o-1)+A.pw;e.push(xi(["thermalpad"],0,0,r,a))}else e.push(xi(["thermalpad"],0,0,A.thermalpad.x,A.thermalpad.y));const n=[];for(const[r,a,g]of[["top-left",-1,1],["bottom-left",-1,-1],["bottom-right",1,-1],["top-right",1,1]]){const I=A.w/2*a,c=A.h/2*g;let B="none",C=I,l=c;const Q=A.pw*2;i[1]===1&&r==="top-left"?B="in1":i[o*4]===1&&r==="top-left"||i[o*3+1]===1&&r==="top-right"?B="in2":i[o*3]===1&&r==="top-right"||i[o]===1&&r==="bottom-left"?B="in1":i[o+1]===1&&r==="bottom-left"?B="in2":i[o*2]===1&&r==="bottom-right"?B="in1":i[o*2+1]===1&&r==="bottom-right"&&(B="in2");const E=B==="in1"?1:-1;if(A.legsoutside){const h=B==="in1"?A.pl/2:A.pw/2,u=B==="in1"?A.pw/2:A.pl/2;C+=h*a*E,l-=u*g*E}(B==="none"||A.legsoutside)&&n.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}`,route:[{x:I-Q*a,y:c},{x:I,y:c},{x:I,y:c-Q*g}],type:"pcb_silkscreen_path",stroke_width:.1}),(B==="in1"||B==="in2")&&!A.legsoutside&&n.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}_1`,route:[{x:I-Q*a,y:c},{x:I-Q*a/2,y:c}],type:"pcb_silkscreen_path",stroke_width:0},{layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}_2`,route:[{x:I,y:c-Q*g/2},{x:I,y:c-Q*g}],type:"pcb_silkscreen_path",stroke_width:.1}),(B==="in1"||B==="in2")&&n.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}_3`,route:[{x:C-.2*-a,y:l+.2*E},{x:C,y:l},{x:C+.2*E*-a,y:l+.2},{x:C-.2*-a,y:l+.2*E}],type:"pcb_silkscreen_path",stroke_width:.1})}const s=Bo(0,A.h/2+(A.legsoutside?A.pl*1.2:.5),.3);return{circuitJson:[...e,...n,s],parameters:A}};CBA.extend({}).transform(lBA);var GIt=t=>(t.legsoutside=!1,bU(t)),FIt=t=>{t.legsoutside=!0;const A=BWA.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=A.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=A.pw;break}return bU(t)};CBA.extend({}).transform(lBA);var RIt=t=>(t.legsoutside=!1,t.thermalpad===void 0&&(t.thermalpad=!0),bU(t)),NIt=cw({w:"3.9mm",p:"1.27mm"}),MIt=t=>{const A=NIt.parse(t);return{circuitJson:tS(A),parameters:A}},_It=cw({w:"7.1mm",p:"0.65mm",pl:"1.35mm",pw:"0.40mm",legsoutside:!0}),vIt=t=>{const A=_It.parse(t);return{circuitJson:tS(A),parameters:A}},UIt=cw({}),LIt=t=>{const A=UIt.parse({fn:"sot363",num_pins:6,w:1.94,p:.65,pw:.3,pl:.7,legoutside:!0});return{circuitJson:tS(A),parameters:A}},CWA=YA({fn:Y(),num_pins:jA().default(3),w:Y().default("1.92mm"),h:Y().default("2.74mm"),pl:Y().default("0.8mm"),pw:Y().default("0.764mm"),p:Y().default("0.95mm"),string:Y().optional()}),HIt=cw({p:"0.95mm",w:"1.6mm",legsoutside:!0}),YIt=t=>{const A=t.string?.match(/^sot23_(\d+)/),e=A?Number.parseInt(A[1],10):3;if(e===6||e===8){const o=HIt.parse({...t,num_pins:e});return{circuitJson:tS(o),parameters:o}}const i=CWA.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:KIt(i),parameters:i};if(i.num_pins===5)return{circuitJson:QWA(i),parameters:i};throw new Error("Invalid number of pins")},JIt=t=>{const{pn:A}=t;return A===1?{x:-1.7,y:0}:A===2?{x:1.7,y:-.95}:{x:1.7,y:.95}},KIt=t=>{const A=[];for(let i=0;i<t.num_pins;i++){const{x:o,y:n}=JIt({num_pins:t.num_pins,pn:i+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl)});A.push(xi(i+1,o,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=Bo(0,Number.parseInt(t.h),.3);return[...A,e]},lWA=t=>{const{p:A,h:e,pn:i}=t;if(i===1)return{x:-e/2-.5,y:A};if(i===2)return{x:-e/2-.5,y:0};if(i===3)return{x:-e/2-.5,y:-A};if(i===4)return{x:e/2+.5,y:-A};if(i===5)return{x:e/2+.5,y:A};throw new Error("Invalid pin number")},QWA=t=>{const A=[];for(let c=1;c<=t.num_pins;c++){const{x:B,y:C}=lWA({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:c});A.push(xi(c,B,C,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=(t.num_pins+1)/2*Number.parseFloat(t.p),i=Number.parseFloat(t.h),o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-e/3,y:i/2+Number.parseFloat(t.p)/1.3},{x:e/3,y:i/2+Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-e/3,y:-i/2-Number.parseFloat(t.p)/1.3},{x:e/3,y:-i/2-Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},s=Bo(0,i+.3,.3),r=lWA({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:1});r.x=r.x-Number.parseFloat(t.pw)*1.5;const a=.7,g=.3,I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:r.x+a/2,y:r.y},{x:r.x-a/2,y:r.y+g/2},{x:r.x-a/2,y:r.y-g/2},{x:r.x+a/2,y:r.y}],stroke_width:.05};return[...A,s,o,n,I]},TIt=CWA.extend({}),qIt=t=>{const A=TIt.parse({...t,num_pins:5});return{circuitJson:QWA(A),parameters:A}},PIt=[{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}],OIt=cw({}),WIt=t=>{const A=OIt.parse(t),e=[];for(let c=0;c<A.num_pins;c++){const{x:B,y:C}=BBA({num_pins:A.num_pins,pn:c+1,w:A.w,p:A.p??1.27,pl:A.pl,widthincludeslegs:!0});e.push(xi(c+1,B,C,A.pl??"1mm",A.pw??"0.6mm"))}const i=Math.min(1,A.p/2),o=A.w+i,n=(A.num_pins/2-1)*A.p+A.pw+i,s=[];for(const c of PIt){const{dx:B,dy:C}=c;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",route:[{x:B*o/2-B*A.p,y:C*n/2},{x:B*o/2,y:C*n/2},{x:B*o/2,y:C*n/2-C*A.p}],type:"pcb_silkscreen_path",stroke_width:.1})}const r=A.p/4,a=-o/2-r/2,g=n/2-A.p/2;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:a,y:g},{x:a-r,y:g+r},{x:a-r,y:g-r},{x:a,y:g}],stroke_width:.1});const I=Bo(0,n/2+.4,n/12);return{circuitJson:[...e,I,...s],parameters:A}},bO=(t,A,e,i,o,n)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circular_hole_with_rect_pad",x:A,y:e,hole_diameter:pa(i),hole_shape:"circle",pad_shape:"rect",rect_pad_width:pa(o),rect_pad_height:pa(n),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()]}),QBA=({fs:t,pn:A,anchor_x:e,anchor_y:i,textalign:o="center",orthogonal:n=!1,verticallyinverted:s=!1,layer:r="top"})=>{let a=0;n&&s?a=270:s?a=180:n?a=90:a=0;let g="center";return o==="left"&&(s?g="center_right":g="center_left"),o==="right"&&(s?g="center_left":g="center_right"),r==="bottom"&&(g==="center_left"?g="center_right":g==="center_right"&&(g="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${A}}`,layer:r,anchor_position:{x:e,y:i},anchor_alignment:g,ccw_rotation:a}};function ZIt({pinlabeltextalignleft:t,pinlabeltextalignright:A,pinlabelorthogonal:e}){let i="top";return e?i="left":i="top",t&&(e?i="bottom":i="right"),A&&(e?i="top":i="left"),i}var VIt=YA({fn:Y(),num_pins:jA().optional().default(6),rows:ei([Y(),jA()]).transform(t=>Number(t)).optional().default(1).describe("number of rows"),p:ie.default("0.1in").describe("pitch"),id:ie.default("1.0mm").describe("inner diameter"),od:ie.default("1.5mm").describe("outer diameter"),male:Be().optional().describe("for male pin headers"),female:Be().optional().describe("for female pin headers"),pinlabeltextalignleft:Be().optional().default(!1),pinlabeltextaligncenter:Be().optional().default(!1),pinlabeltextalignright:Be().optional().default(!1),pinlabelverticallyinverted:Be().optional().default(!1),pinlabelorthogonal:Be().optional().default(!1),nosquareplating:Be().optional().default(!1).describe("do not use rectangular pad for pin 1"),nopinlabels:Be().optional().default(!1).describe("omit silkscreen pin labels"),doublesidedpinlabel:Be().optional().default(!1).describe("add silkscreen pins in top and bottom layers"),bottomsidepinlabel:Be().optional().default(!1).describe("place the silkscreen reference text on the bottom layer instead of top")}).transform(t=>{const A=ZIt(t);return{...t,pinlabelAnchorSide:A,male:t.male??!t.female,female:t.female??!1}}).superRefine((t,A)=>{t.male&&t.female&&A.addIssue({code:Wt.custom,message:"'male' and 'female' cannot both be true; it should be male or female.",path:["male","female"]})}),jIt=t=>{const A=VIt.parse(t),{p:e,id:i,od:o,rows:n,num_pins:s,pinlabelAnchorSide:r,pinlabelverticallyinverted:a,pinlabelorthogonal:g,pinlabeltextalignleft:I,pinlabeltextalignright:c,nopinlabels:B,doublesidedpinlabel:C,bottomsidepinlabel:l}=A;let Q="center";I?Q="left":c&&(Q="right");const E=[],h=Math.ceil(s/n),u=-e,d=({xoff:x,yoff:F,od:k,anchorSide:v})=>{let M=0,H=0;const P=k*.75;switch(v){case"right":M=P;break;case"top":H=P;break;case"bottom":H=-P;break;case"left":M=-P;break}return{anchor_x:x+M,anchor_y:F+H}},f=(x,F,k)=>{x===1&&!A.nosquareplating?E.push(bO(x,F,k,i,o,o)):E.push(Fn(x,F,k,i,o));const{anchor_x:v,anchor_y:M}=d({xoff:F,yoff:k,od:o,anchorSide:r});B||(l?E.push(QBA({fs:o/5,pn:x,anchor_x:v,anchor_y:M,textalign:Q,orthogonal:g,verticallyinverted:a,layer:"bottom"})):E.push(QBA({fs:o/5,pn:x,anchor_x:v,anchor_y:M,textalign:Q,orthogonal:g,verticallyinverted:a,layer:"top"})),C&&E.push(QBA({fs:o/5,pn:x,anchor_x:v,anchor_y:M,textalign:Q,orthogonal:g,verticallyinverted:a,layer:"bottom"})))},D=new Set,b=n>2&&h>2;if(n===1){const x=-((s-1)/2)*e;for(let F=0;F<s;F++){const k=F+1,v=x+F*e,M=`${v},0`;if(D.has(M))throw new Error(`Overlap at ${M}`);D.add(M),f(k,v,0)}}else if(b){const x=-((h-1)/2)*e;let F=1;for(let k=0;k<n&&F<=s;k++)for(let v=0;v<h&&F<=s;v++){const M=x+v*e,H=k*u,P=`${M},${H}`;if(D.has(P))throw new Error(`Overlap at ${P}`);D.add(P),f(F++,M,H)}}else{const x=-((h-1)/2)*e;let F=1,k=0,v=n-1,M=0,H=h-1;for(;F<=s&&k<=v&&M<=H;){for(let P=k;P<=v&&F<=s;P++){const K=x+M*e,O=P*u,W=`${K},${O}`;if(D.has(W))throw new Error(`Overlap at ${W}`);D.add(W),f(F++,K,O)}M++;for(let P=M;P<=H&&F<=s;P++){const K=x+P*e,O=v*u,W=`${K},${O}`;if(D.has(W))throw new Error(`Overlap at ${W}`);D.add(W),f(F++,K,O)}if(v--,M<=H){for(let P=v;P>=k&&F<=s;P--){const K=x+H*e,O=P*u,W=`${K},${O}`;if(D.has(W))throw new Error(`Overlap at ${W}`);D.add(W),f(F++,K,O)}H--}if(k<=v){for(let P=H;P>=M&&F<=s;P--){const K=x+P*e,O=k*u,W=`${K},${O}`;if(D.has(W))throw new Error(`Overlap at ${W}`);D.add(W),f(F++,K,O)}k++}}if(F-1<s)throw new Error(`Missing pins: assigned ${F-1}, expected ${s}`)}const m=Bo(0,e,.5);return{circuitJson:[...E,m],parameters:A}},zIt=cw({}),XIt=t=>{const A=zIt.parse({fn:"sot563",num_pins:6,w:1.94,p:.5,pw:.3,pl:.67,legoutside:!0});return{circuitJson:tS(A),parameters:A}},$It=cw({p:"1.27mm",w:"3.9mm",legsoutside:!0}),Act=t=>{const A=$It.parse({...t,num_pins:8});return{circuitJson:tS(A),parameters:A}},ect=cw({p:"1.27mm",w:"7.5mm",legsoutside:!0}),tct=t=>{const A=ect.parse({...t,num_pins:16});return{circuitJson:tS(A),parameters:A}},ict=YA({fn:Y(),num_pins:kA(3).default(3),w:Y().default("1.2mm"),h:Y().default("1.2mm"),pl:Y().default("0.3mm"),pw:Y().default("0.32mm")}),oct=t=>{const A=ict.parse(t),e=sct(A),i=Bo(.4,ie.parse(A.h),.2);return{circuitJson:[...e,i],parameters:A}},nct=t=>{const{pn:A}=t;return A===1?{x:0,y:0}:A===2?{x:1,y:-.4}:{x:1,y:.4}},sct=t=>{const A=[];for(let e=0;e<3;e++){const{x:i,y:o}=nct({num_pins:t.num_pins,pn:e+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl)});A.push(xi(e+1,i,o,Number.parseFloat(t.pl),e!==0?Number.parseFloat(t.pw):.42))}return A},rct=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("2.36mm"),h:Y().default("1.22mm"),pl:Y().default("0.9mm"),pw:Y().default("0.9mm"),p:Y().default("4.19mm")}),act=t=>{const A=rct.parse(t),e=Bo(0,ie.parse(A.h)/4+.4,.3);return{circuitJson:Ict(A).concat(e),parameters:A}},gct=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},Ict=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=gct({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},cct=YA({fn:Y(),p:ie.optional().default("2.54mm"),id:ie.optional().default("0.7mm"),od:ie.optional().default("1mm")}),Bct=t=>{const A=cct.parse(t),{p:e,id:i,od:o}=A,n=[Fn(1,-e/2,0,i,o),Fn(2,e/2,0,i,o)],s={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2+o+i/2,y:0},{x:e/2-o-i/2,y:0}],stroke_width:.1,pcb_silkscreen_path_id:""},r=Bo(0,e/4,.5);return{circuitJson:[...n,s,r],parameters:A}},xO=(t,A={})=>({type:"pcb_silkscreen_path",layer:A.layer||"top",pcb_component_id:A.pcb_component_id||"",pcb_silkscreen_path_id:A.pcb_silkscreen_path_id||"",route:t,stroke_width:A.stroke_width||.1}),Cct=YA({fn:kA("pushbutton"),w:ie.default(4.5),h:ie.default(6.5),id:ie.default(1),od:ie.default(1.2)}),lct=t=>{const A=Cct.parse(t),e=A.w,i=A.h,o=A.id,n=[Fn(1,-e/2,i/2,o,o*1.5),Fn(2,-e/2,-i/2,o,o*1.5),Fn(3,e/2,-i/2,o,o*1.5),Fn(4,e/2,i/2,o,o*1.5)],s=[xO([{x:-e/2,y:-i/2},{x:-e/2,y:i/2}]),xO([{x:e/2,y:-i/2},{x:e/2,y:i/2}]),xO([{x:-e/2,y:0},{x:-e/5,y:0},{x:e/5*1/Math.sqrt(2),y:i/8}]),xO([{x:e/2,y:0},{x:e/5,y:0}])],r=Bo(0,i/2+.4,.5);return{circuitJson:[...n,...s,r],parameters:A}},EWA=YA({fn:Y(),w:ie.default("22.58mm"),h:ie.optional(),left:ie.optional().default(20),right:ie.optional().default(20),top:ie.optional().default(2),bottom:ie.optional().default(2),p:ie.default(ie.parse("2.54mm")),pw:ie.default(ie.parse("1.6mm")),pl:ie.default(ie.parse("2.4mm")),innerhole:Be().default(!1),innerholeedgedistance:ie.default(ie.parse("1.61mm")),silkscreenlabels:Be().default(!1),silkscreenlabelmargin:ie.default(ie.parse("0.1mm"))}),Qct=t=>{const A=EWA.parse(t);return A.left&&A.right?Math.max(A.left,A.right)*A.p:A.left?A.left*A.p:A.right?A.right*A.p:51},kO=(t,A,e)=>{let i=[];return e==="right"&&(i=[{x:t+1/2,y:A},{x:t-1/2,y:A+.6/2},{x:t-1/2,y:A-.6/2},{x:t+1/2,y:A}]),e==="left"&&(i=[{x:t-1/2,y:A},{x:t+1/2,y:A+.6/2},{x:t+1/2,y:A-.6/2},{x:t-1/2,y:A}]),e==="top"&&(i=[{x:t,y:A+1/2},{x:t-.6/2,y:A-1/2},{x:t+.6/2,y:A-1/2},{x:t,y:A+1/2}]),e==="bottom"&&(i=[{x:t,y:A-1/2},{x:t-.6/2,y:A+1/2},{x:t+.6/2,y:A+1/2},{x:t,y:A-1/2}]),i},Ect=t=>{const A=EWA.parse(t),e=A.h??Qct(A),i=[],o=[],n=[];let s=[];const r=1,a=r,g=A.left+A.right+(A.bottom??0)+(A.top??0),c=`pin${g}`.length*.7/2;if(A.right){const Q=-((A.right-1)/2)*A.p;for(let E=0;E<A.right;E++){if(E===0&&!A.left&&!A.bottom&&!A.silkscreenlabels&&(s=kO(A.w/2-A.pl*1.4,Q+E*A.p,"right")),i.push(xi(E+1+A.left+(A.bottom??0),A.w/2-A.pl/2,Q+E*A.p,A.pl,A.pw)),A.silkscreenlabels){const h=E+1+A.left+(A.bottom??0),u=`pin${h}`;n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${h}`,pcb_component_id:"1",layer:"top",anchor_position:{x:A.w/2-A.pl-(c+A.silkscreenlabelmargin),y:Q+E*A.p},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}A.innerhole&&(o.push(Fn(E+1+A.left+(A.bottom??0)+g,A.w/2,Q+E*A.p,r,a)),o.push(Fn(E+1+A.left+(A.bottom??0)+g*2,A.w/2-A.innerholeedgedistance,Q+E*A.p,r,a)))}}if(A.left){const Q=(A.left-1)/2*A.p;for(let E=0;E<A.left;E++){if(E===0&&!A.silkscreenlabels&&(s=kO(-A.w/2+A.pl*1.4,Q-E*A.p,"left")),i.push(xi(E+1,-A.w/2+A.pl/2,Q-E*A.p,A.pl,A.pw)),A.silkscreenlabels){const h=E+1,u=`pin${h}`;n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${h}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-A.w/2+A.pl+(c+A.silkscreenlabelmargin),y:Q-E*A.p},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}A.innerhole&&(o.push(Fn(E+1+g,-A.w/2,Q-E*A.p,r,a)),o.push(Fn(E+1+g*2,-A.w/2+A.innerholeedgedistance,Q-E*A.p,r,a)))}}if(A.top){const Q=(A.top-1)/2*A.p;for(let E=0;E<A.top;E++){if(E===0&&!A.left&&!A.bottom&&!A.right&&!A.silkscreenlabels&&(s=kO(Q-E*A.p,e/2-A.pl*1.4,"top")),i.push(xi(E+1+A.left+A.right+(A.bottom??0),Q-E*A.p,e/2-A.pl/2,A.pw,A.pl)),A.silkscreenlabels){const h=E+1+A.left+A.right+(A.bottom??0),u=`pin${h}`;n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${h}`,pcb_component_id:"1",layer:"top",anchor_position:{x:Q-E*A.p,y:e/2-A.pl-(c+A.silkscreenlabelmargin)},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:270})}A.innerhole&&(o.push(Fn(E+1+A.left+A.right+(A.bottom??0)+g,Q-E*A.p,e/2,r,a)),o.push(Fn(E+1+A.left+A.right+(A.bottom??0)+g*2,Q-E*A.p,e/2-A.innerholeedgedistance,r,a)))}}if(A.bottom){const Q=-((A.bottom-1)/2)*A.p;for(let E=0;E<A.bottom;E++){if(E===0&&!A.left&&!A.silkscreenlabels&&(s=kO(Q+E*A.p,-e/2+A.pl*1.4,"bottom")),i.push(xi(E+1+A.left,Q+E*A.p,-e/2+A.pl/2,A.pw,A.pl)),A.silkscreenlabels){const h=E+1+A.left,u=`pin${h}`;n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${h}`,pcb_component_id:"1",layer:"top",anchor_position:{x:Q+E*A.p,y:-e/2+A.pl+(c+A.silkscreenlabelmargin)},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:90})}A.innerhole&&(o.push(Fn(E+1+A.left+g,Q+E*A.p,-e/2,r,a)),o.push(Fn(E+1+A.left+g*2,Q+E*A.p,-e/2+A.innerholeedgedistance,r,a)))}}const B={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_triangle_1",pcb_component_id:"2",route:s,stroke_width:.1,layer:"top"},C={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-A.w/2,y:e/2},{x:A.w/2,y:e/2},{x:A.w/2,y:-e/2},{x:-A.w/2,y:-e/2},{x:-A.w/2,y:e/2}],stroke_width:.1,layer:"top"},l=Bo(0,e/1.8,e/25);return{circuitJson:[...i,...o,...n,C,...A.silkscreenlabels?[]:[B],l],parameters:A}},hWA=YA({fn:Y(),w:ie.default("22.58mm"),h:ie.optional(),left:ie.optional().default(20),right:ie.optional().default(20),top:ie.optional().default(2),bottom:ie.optional().default(2),p:ie.default(ie.parse("2.54mm")),pw:ie.default(ie.parse("1.6mm")),pl:ie.default(ie.parse("3.2mm")),innerhole:Be().default(!1),innerholeedgedistance:ie.default(ie.parse("1.61mm"))}),hct=t=>{const A=hWA.parse(t);return A.left&&A.right?Math.max(A.left,A.right)*A.p:A.left?A.left*A.p:A.right?A.right*A.p:51},uct=(t,A,e,i=1,o=.6)=>{const n=i/2,s=o/2;return{left:[{x:t+n,y:A},{x:t-n,y:A+s},{x:t-n,y:A-s},{x:t+n,y:A}],right:[{x:t-n,y:A},{x:t+n,y:A+s},{x:t+n,y:A-s},{x:t-n,y:A}],top:[{x:t,y:A-n},{x:t-s,y:A+n},{x:t+s,y:A+n},{x:t,y:A-n}],bottom:[{x:t,y:A+n},{x:t-s,y:A-n},{x:t+s,y:A-n},{x:t,y:A+n}]}[e]},dct=t=>{const A=hWA.parse(t),e=A.h??hct(A),i=[],o=[],n=[],s=1,r=1.2,a=A.left+A.right+(A.bottom??0)+(A.top??0);let g=[],I=1;if(A.left){const l=(A.left-1)/2*A.p;for(let Q=0;Q<A.left;Q++)Q===0&&(g=uct(-A.w/2-A.pl/2,l-Q*A.p,"left")),i.push(xi(I,-A.w/2+A.pl/2,l-Q*A.p,A.pl,A.pw)),o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${I}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-A.w/2+A.pl/2-4.5,y:l-Q*A.p},text:`pin${I}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),I++,A.innerhole&&n.push(Fn(I+a,-A.w/2+A.innerholeedgedistance,l-Q*A.p,s,r))}if(A.bottom){const l=(A.bottom-1)/2*A.p;for(let Q=A.bottom-1;Q>=0;Q--)i.push(xi(I,l-Q*A.p,-e/2+A.pl/2,A.pw,A.pl)),o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${I}`,pcb_component_id:"1",layer:"top",anchor_position:{x:l-Q*A.p,y:-e/2+A.pl/2-3.2},text:`pin${I}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),I++,A.innerhole&&n.push(Fn(I+a,l-Q*A.p,-e/2+A.innerholeedgedistance,s,r))}if(A.right){const l=-((A.right-1)/2)*A.p;for(let Q=0;Q<A.right;Q++)i.push(xi(I,A.w/2-A.pl/2,l+Q*A.p,A.pl,A.pw)),o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${I}`,pcb_component_id:"1",layer:"top",anchor_position:{x:A.w/2-A.pl/2+3.7,y:l+Q*A.p},text:`pin${I}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),I++,A.innerhole&&n.push(Fn(I+a,A.w/2-A.innerholeedgedistance,l+Q*A.p,s,r))}if(A.top){const l=-((A.top-1)/2)*A.p;for(let Q=A.top-1;Q>=0;Q--)i.push(xi(I,l+Q*A.p,e/2-A.pl/2,A.pw,A.pl)),o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${I}`,pcb_component_id:"1",layer:"top",anchor_position:{x:l+Q*A.p,y:e/2-A.pl/2+3.2},text:`pin${I}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),I++,A.innerhole&&n.push(Fn(I+a,l+Q*A.p,e/2-A.innerholeedgedistance,s,r))}const c={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"1",pcb_component_id:"1",layer:"top",route:g,stroke_width:.1},B={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-A.w/2-A.pl/3,y:e/2+A.pl/3},{x:A.w/2+A.pl/3,y:e/2+A.pl/3},{x:A.w/2+A.pl/3,y:-e/2-A.pl/3},{x:-A.w/2-A.pl/3,y:-e/2-A.pl/3},{x:-A.w/2-A.pl/3,y:e/2+A.pl/3}],stroke_width:.1,layer:"top"},C=Bo(0,e/1.8,e/25);return{circuitJson:[...n,...i,...o,B,c,C],parameters:A}},pct=t=>(t.legsoutside=!0,bU(t)),uWA=YA({fn:Y(),w:ie.default("10mm"),h:ie.optional(),left:ie.optional().default(20),right:ie.optional().default(20),top:ie.optional().default(0),bottom:ie.optional().default(0),p:ie.default(ie.parse("2.54mm")),id:ie.optional().default(ie.parse("1mm")),od:ie.optional().default(ie.parse("1.5mm"))}),fct=t=>{const A=uWA.parse(t);return A.left&&A.right?Math.max(A.left,A.right)*A.p:A.left?A.left*A.p:A.right?A.right*A.p:51},GO=(t,A,e,i=1,o=.6)=>{const n=i/2,s=o/2;return{left:[{x:t+n,y:A},{x:t-n,y:A+s},{x:t-n,y:A-s},{x:t+n,y:A}],right:[{x:t-n,y:A},{x:t+n,y:A+s},{x:t+n,y:A-s},{x:t-n,y:A}],top:[{x:t,y:A-n},{x:t-s,y:A+n},{x:t+s,y:A+n},{x:t,y:A-n}],bottom:[{x:t,y:A+n},{x:t-s,y:A-n},{x:t+s,y:A-n},{x:t,y:A+n}]}[e]},yct=t=>{const A=uWA.parse(t),e=A.h??fct(A),i=[],o=A.id,n=A.od;let s=[];if(A.right){const I=-((A.right-1)/2)*A.p;for(let c=0;c<A.right;c++)c===0&&!A.left&&!A.bottom&&(s=GO(A.w/2+n*1.4,I+c*A.p,"right")),i.push(Fn(c+1+A.left+(A.bottom??0),A.w/2,I+c*A.p,o,n))}if(A.left){const I=-((A.left-1)/2)*A.p;for(let c=0;c<A.left;c++)c===A.left-1&&(s=GO(-A.w/2-n*1.4,I+c*A.p,"left")),i.push(Fn(c+1,-A.w/2,I+c*A.p,o,n))}if(A.top){const I=-((A.top-1)/2)*A.p;for(let c=0;c<A.top;c++)c===A.top-1&&!A.left&&!A.bottom&&!A.right&&(s=GO(I+c*A.p,e/2+n*1.4,"top")),i.push(Fn(c+1+A.right+(A.bottom??0)+A.left,I+c*A.p,e/2,o,n))}if(A.bottom){const I=-((A.bottom-1)/2)*A.p;for(let c=0;c<A.bottom;c++)c===0&&!A.left&&(s=GO(I+c*A.p,-e/2-n*1.4,"bottom")),i.push(Fn(c+1+A.left,I+c*A.p,-e/2,o,n))}const r={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"1",pcb_component_id:"1",layer:"top",route:s,stroke_width:.1},a={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-A.w/2-n,y:e/2+n},{x:A.w/2+n,y:e/2+n},{x:A.w/2+n,y:-e/2-n},{x:-A.w/2-n,y:-e/2-n},{x:-A.w/2-n,y:e/2+n}],stroke_width:.1,layer:"top"},g=Bo(0,e/1.7,e/25);return{circuitJson:[...i,a,g,r],parameters:A}},dWA=(t,A,e,i)=>Array.from({length:25},(o,n)=>{const s=n/24*Math.PI-Math.PI/2;return{x:t+(i==="right"?1:-1)*Math.cos(s)*e,y:A+Math.sin(s)*e}}),wct=YA({fn:Y(),p:ie.optional().default("4.88mm"),id:ie.optional().default("0.6mm"),od:ie.optional().default("1.2mm"),w:ie.optional().default("5.6mm"),h:ie.optional().default("3.5mm")}),mct=t=>{const A=wct.parse(t),{p:e,id:i,od:o,w:n,h:s}=A,r=s/2,a=[Fn(1,-e/2,0,i,o),Fn(2,e/2,0,i,o)],g=dWA(-n/2,0,r,"left"),I=dWA(n/2,0,r,"right"),c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[...g,...g.slice(1).reverse(),{x:-n/2,y:-s/2},{x:n/2,y:-s/2},...I,{x:n/2,y:s/2},{x:-n/2,y:s/2}],stroke_width:.1,pcb_silkscreen_path_id:""},B=Bo(0,e/4,.5);return{circuitJson:[...a,c,B],parameters:A}};YA({w:ie,h:ie});var Dct=t=>{const{w:A,h:e}=t,i=pa(A),o=pa(e);return{circuitJson:[xi(1,0,0,i,o),Bo(0,o/2+.5,.2)],parameters:t}},Sct=YA({fn:Y(),num_pins:ei([kA(3),kA(2)]).default(3),p:Y().default("1.27mm"),id:Y().default("0.72mm"),od:Y().default("0.95mm"),w:Y().default("4.5mm"),h:Y().default("4.5mm"),inline:Be().default(!1),string:Y().optional()}),bct=(t,A,e)=>Array.from({length:25},(i,o)=>{const n=o/24*Math.PI;return{x:t+Math.cos(n)*e,y:A+Math.sin(n)*e}}),xct=t=>{const{p:A,id:e,od:i,h:o}=t,n=Number.parseFloat(o)/2,s=Number.parseFloat(A);return[Fn(1,-s,n-s,e,i),Fn(2,s,n-s,e,i)]},kct=t=>{const A=t.string?.match(/^to92_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=Sct.parse({...t,num_pins:e}),{p:o,id:n,od:s,w:r,h:a,inline:g}=i,I=Number.parseFloat(a)/2,c=Number.parseFloat(o);let B=[];if(i.num_pins===3)B=g?[Fn(1,-c,I-c,n,s),Fn(2,0,I-c,n,s),Fn(3,c,I-c,n,s)]:[Fn(1,0,I,n,s),Fn(2,-c,I-c,n,s),Fn(3,c,I-c,n,s)];else if(i.num_pins===2)B=xct(i);else throw new Error("Invalid number of pins for TO-92");const C=Number.parseFloat(r)/2,l=bct(0,I,C),Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[...l,{x:-C,y:0},{x:C,y:0},l[0]],stroke_width:.1,pcb_silkscreen_path_id:""},E=Bo(0,I+1,.5);return{circuitJson:[...B,Q,E],parameters:i}},Gct=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("2.15mm"),h:Y().default("1.20mm"),pl:Y().default("0.5mm"),pw:Y().default("0.6mm"),p:Y().default("1.4mm")}),Fct=t=>{const A=Gct.parse(t),e=Bo(0,ie.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Nct(A).concat(i,e),parameters:A}},Rct=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},Nct=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=Rct({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},Mct=cw({}),_ct=t=>{const A=Mct.parse(t),e=[];for(let s=0;s<A.num_pins;s++){const{x:r,y:a}=BBA({num_pins:A.num_pins,pn:s+1,w:A.w,p:A.p??1.27,pl:A.pl,widthincludeslegs:!0});e.push(xi(s+1,r,a,A.pl??"1.5mm",A.pw??"0.6mm"))}const i=(A.num_pins/2-1)*A.p+A.pw,o=Bo(0,i/2-.5,i/12),n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:-A.w/3,y:i/2+.2},{x:A.w/3,y:i/2+.2}],stroke_width:.1};return{circuitJson:[...e,o,n],parameters:A}},vct=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("5.0mm"),h:Y().default("2.30mm"),pl:Y().default("1.25mm"),pw:Y().default("2mm"),p:Y().default("3.75mm")}),Uct=t=>{const A=vct.parse(t),e=Bo(0,ie.parse(A.h)/2+1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2+.5,y:ie.parse(A.h)/2+.5},{x:-ie.parse(A.w)/2-.5,y:ie.parse(A.h)/2+.5},{x:-ie.parse(A.w)/2-.5,y:-ie.parse(A.h)/2-.5},{x:ie.parse(A.p)/2+.5,y:-ie.parse(A.h)/2-.5}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Hct(A).concat(i,e),parameters:A}},Lct=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},Hct=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=Lct({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},Yct=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("4.4mm"),h:Y().default("2.1mm"),pl:Y().default("1.2mm"),pw:Y().default("1.2mm"),p:Y().default("2.9mm")}),Jct=t=>{const A=Yct.parse(t),e=Bo(0,ie.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Tct(A).concat(i,e),parameters:A}},Kct=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},Tct=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=Kct({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},qct=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("3.30mm"),h:Y().default("1.80mm"),pl:Y().default("0.60mm"),pw:Y().default("0.45mm"),p:Y().default("2.1mm")}),Pct=t=>{const A=qct.parse(t),e=Bo(0,ie.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Wct(A).concat(i,e),parameters:A}},Oct=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},Wct=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=Oct({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},Zct=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("1.4mm"),h:Y().default("0.9mm"),pl:Y().default("0.35mm"),pw:Y().default("0.25mm"),p:Y().default("1.2mm")}),Vct=t=>{const A=Zct.parse(t),e=Bo(0,ie.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2+.15,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.4,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.4,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2+.15,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:zct(A).concat(i,e),parameters:A}},jct=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},zct=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=jct({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},Xct=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("1.3mm"),h:Y().default("0.9mm"),pl:Y().default("0.4mm"),pw:Y().default("0.7mm"),p:Y().default("0.7mm")}),$ct=t=>{const A=Xct.parse(t),e=Bo(0,ie.parse(A.h)+.1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2+.2,y:ie.parse(A.h)/2+.2},{x:-ie.parse(A.w)/2-.2,y:ie.parse(A.h)/2+.2},{x:-ie.parse(A.w)/2-.2,y:-ie.parse(A.h)/2-.2},{x:ie.parse(A.p)/2+.2,y:-ie.parse(A.h)/2-.2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:eBt(A).concat(i,e),parameters:A}},ABt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},eBt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=ABt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},tBt=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("3,05mm"),h:Y().default("1.65mm"),pl:Y().default("0.6mm"),pw:Y().default("0.6mm"),pad_spacing:Y().default("2.2mm")}),iBt=t=>{const A=tBt.parse(t),e=Bo(0,ie.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.pad_spacing)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:-ie.parse(A.h)/2},{x:ie.parse(A.pad_spacing)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:nBt(A).concat(i,e),parameters:A}},oBt=t=>{const{pn:A,pad_spacing:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},nBt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=oBt({pn:e,pad_spacing:Number.parseFloat(t.pad_spacing)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},sBt=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("4.4mm"),h:Y().default("2.1mm"),pl:Y().default("1.2mm"),pw:Y().default("1.2mm"),p:Y().default("2.9mm")}),rBt=t=>{const A=sBt.parse(t),e=Bo(0,ie.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:gBt(A).concat(i,e),parameters:A}},aBt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},gBt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=aBt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},IBt=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("4.4mm"),h:Y().default("2.1mm"),pl:Y().default("0.91mm"),pw:Y().default("1.22mm"),p:Y().default("3.146mm")}),cBt=t=>{const A=IBt.parse(t),e=Bo(0,ie.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:CBt(A).concat(i,e),parameters:A}},BBt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},CBt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=BBt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},lBt=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("1.80mm"),h:Y().default("1.00mm"),pl:Y().default("0.66mm"),pw:Y().default("0.5mm"),p:Y().default("0.8mm")}),QBt=t=>{const A=lBt.parse(t),e=Bo(0,ie.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.1,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.1,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:hBt(A).concat(i,e),parameters:A}},EBt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},hBt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=EBt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},uBt=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("6.2mm"),h:Y().default("3.4mm"),pl:Y().default("1.4mm"),pw:Y().default("2.1mm"),p:Y().default("4.4mm")}),dBt=t=>{const A=uBt.parse(t),e=Bo(0,ie.parse(A.h)/2+.4,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:fBt(A).concat(i,e),parameters:A}},pBt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},fBt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=pBt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},yBt=YA({fn:Y(),num_pins:ei([kA(3),kA(5)]).default(3),w:Y().default("4.80mm"),h:Y().default("4.80mm"),pl:Y().default("1.3mm"),pw:Y().default("0.9mm"),p:Y().default("1.5mm"),string:Y().optional()}),wBt=t=>{const A=[],e=Number.parseFloat(t.p),i=Number.parseFloat(t.pw),o=Number.parseFloat(t.w),n=Number.parseFloat(t.pl);A.push(xi(1,-o/2,e,n,i),xi(2,-o/2+(1.5-1.3)/2,0,1.5,i),xi(3,-o/2,-e,n,i));const s=Bo(0,0,.3),r=Number.parseFloat(t.w)/2-1,a=Number.parseFloat(t.h)/2,g={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-r,y:a},{x:r,y:a},{x:r,y:a/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},I={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-r,y:-a},{x:r,y:-a},{x:r,y:-a/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,g,I,s]},mBt=t=>{const A=[];Number.parseFloat(t.p),Number.parseFloat(t.pw),Number.parseFloat(t.w),A.push(xi(1,-1.85,-1.5,1.5,.7),xi(2,-1.85,1.5,1.5,.7),xi(3,0,0,.8,2),xi(4,1.85,-1.5,1.5,.7),xi(5,1.85,1.5,1.5,.7));const e=Bo(0,Number.parseFloat(t.h)/2+.5,.3),i=Number.parseFloat(t.w)/2-1,o=Number.parseFloat(t.h)/2,n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:o},{x:i,y:o}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-o},{x:i,y:-o}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,n,s,e]},DBt=t=>{const A=t.string?.match(/^sot89_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=yBt.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:wBt(i),parameters:i};if(i.num_pins===5)return{circuitJson:mBt(i),parameters:i};throw new Error("Invalid number of pins for SOT89")},SBt=YA({fn:Y(),p:ie.optional().default("5.0mm"),id:ie.optional().default("1.0mm"),od:ie.optional().default("1.9mm"),w:ie.optional().default("13mm"),h:ie.optional().default("7mm"),num_pins:jA().optional(),string:Y().optional()}),bBt=t=>{const A=SBt.parse(t),{fn:e,id:i,od:o,w:n,h:s,string:r}=A,a=Number.parseInt(r?.split("_")[1]??"3"),g=-1,I=n/2,c=s/2,B=2.5,C=n*.4,l=Math.max(B,C/(a-1)),Q=Array.from({length:a},(D,b)=>{const m=a%2===0?(b-a/2+.5)*l:(b-Math.floor(a/2))*l;return Fn(b+1,m,g,i,o)}),E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-I,y:-c},{x:I,y:-c},{x:I,y:c},{x:-I,y:c},{x:-I,y:-c}],stroke_width:.1,pcb_silkscreen_path_id:""},h=-c+2*s/3,u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-I,y:h},{x:I,y:h}],stroke_width:.1,pcb_silkscreen_path_id:""},d=[{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/6,y:h},{x:-n/6,y:c}],stroke_width:.1,pcb_silkscreen_path_id:""},{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:n/6,y:h},{x:n/6,y:c}],stroke_width:.1,pcb_silkscreen_path_id:""}],f=Bo(0,s/2+.6,.5);return{circuitJson:[...Q,E,u,...d,f],parameters:{...A,p:l}}},xBt=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("5.40mm"),h:Y().default("2.30mm"),pl:Y().default("1.30mm"),pw:Y().default("1.70mm"),p:Y().default("3.5mm")}),kBt=t=>{const A=xBt.parse(t),e=Bo(0,ie.parse(A.h)/2+.4,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:FBt(A).concat(i,e),parameters:A}},GBt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},FBt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=GBt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},RBt=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("1.90mm"),h:Y().default("1.33mm"),pl:Y().default("0.5mm"),pw:Y().default("0.7mm"),p:Y().default("0.8mm")}),NBt=t=>{const A=RBt.parse(t),e=Bo(0,ie.parse(A.h)+.1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2+.1,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2+.1,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:_Bt(A).concat(i,e),parameters:A}},MBt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},_Bt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=MBt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},vBt=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("7.0mm"),h:Y().default("3.35mm"),pl:Y().default("1.50mm"),pw:Y().default("2.70mm"),p:Y().default("4.8mm")}),UBt=t=>{const A=vBt.parse(t),e=Bo(0,ie.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:HBt(A).concat(i,e),parameters:A}},LBt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},HBt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=LBt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},YBt=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("3.0mm"),h:Y().default("1.80mm"),pl:Y().default("0.80mm"),pw:Y().default("1.20mm"),p:Y().default("1.6mm")}),JBt=t=>{const A=YBt.parse(t),e=Bo(0,ie.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.1,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.1,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:TBt(A).concat(i,e),parameters:A}},KBt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},TBt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=KBt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},qBt=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("7.10mm"),h:Y().default("3.40mm"),pl:Y().default("2.45mm"),pw:Y().default("1.80mm"),p:Y().default("4.05mm")}),PBt=t=>{const A=qBt.parse(t),e=Bo(0,ie.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.5,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.5,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:WBt(A).concat(i,e),parameters:A}},OBt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},WBt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=OBt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},ZBt=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("4.80mm"),h:Y().default("2.10mm"),pl:Y().default("1.30mm"),pw:Y().default("1.40mm"),p:Y().default("2.9mm")}),VBt=t=>{const A=ZBt.parse(t),e=Bo(0,ie.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:zBt(A).concat(i,e),parameters:A}},jBt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},zBt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=jBt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},XBt=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("7.30mm"),h:Y().default("4.40mm"),pl:Y().default("2.50mm"),pw:Y().default("2.30mm"),p:Y().default("4.30mm")}),$Bt=t=>{const A=XBt.parse(t),e=Bo(0,ie.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.1,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.1,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:eCt(A).concat(i,e),parameters:A}},ACt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},eCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=ACt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},tCt=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("10.70mm"),h:Y().default("6.60mm"),pl:Y().default("3.30mm"),pw:Y().default("2.50mm"),p:Y().default("6.80mm")}),iCt=t=>{const A=tCt.parse(t),e=Bo(0,3,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2-.8},{x:-ie.parse(A.w)/2-.8,y:ie.parse(A.h)/2-.8},{x:-ie.parse(A.w)/2-.8,y:-ie.parse(A.h)/2+.8},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2+.8}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:nCt(A).concat(i,e),parameters:A}},oCt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},nCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=oCt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},sCt=YA({fn:Y(),num_pins:jA().default(4),w:Y().default("8.50mm"),h:Y().default("6.90mm"),pl:Y().default("2mm"),pw:Y().default("1.5mm"),p:Y().default("2.30mm"),string:Y().optional()}),rCt=t=>{const A=t.string?.match(/^sot223_(\d+)/),e=A?Number.parseInt(A[1],10):4;if(e===8){const o=ICt.parse({...t,num_pins:e});return{circuitJson:tS(o),parameters:o}}const i=sCt.parse({...t,num_pins:e});if(i.num_pins===4)return{circuitJson:gCt(i),parameters:i};if(i.num_pins===5)return{circuitJson:BCt(i),parameters:i};if(i.num_pins===6)return{circuitJson:lCt(i),parameters:i};throw new Error("Invalid number of pins")},aCt=t=>{const{pn:A,w:e,p:i}=t;return A===1?{x:-e/2+1.1,y:i}:A===2?{x:-e/2+1.1,y:0}:A===3?{x:-e/2+1.1,y:-i}:{x:e/2-1.1,y:0}},gCt=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=aCt({num_pins:t.num_pins,pn:r+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)}),I=r===3?3.8:Number.parseFloat(t.pw);A.push(xi(r+1,a,g,Number.parseFloat(t.pl),I))}const e=Bo(0,0,.3),i=Number.parseFloat(t.w)/2-2.4,o=Number.parseFloat(t.h)/2,n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:o},{x:i,y:o},{x:i,y:o/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:-o},{x:i,y:-o},{x:i,y:-o/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,n,s,e]},ICt=cw({p:"0.90mm",w:"2.8mm",legsoutside:!0}),cCt=t=>{const{p:A,pn:e,w:i}=t;if(e===1)return{x:-i/2+1.2,y:A/2+A};if(e===2)return{x:-i/2+1.2,y:A/2};if(e===3)return{x:-i/2+1.2,y:-A/2};if(e===4)return{x:-i/2+1.2,y:-A/2-A};if(e===5)return{x:i/2-1,y:0};throw new Error("Invalid pin number")},BCt=t=>{const A=[];for(let r=1;r<=t.num_pins;r++){const{x:a,y:g}=cCt({h:Number.parseFloat(t.h),p:1.5,pn:r,w:Number.parseFloat(t.w)});let I=Number.parseFloat(t.pw),c=Number.parseFloat(t.pl);r===5?(I=3.4,c=1.8):(I=1,c=2.2),A.push(xi(r,a,g,c,I))}const e=Number.parseFloat(t.w)/2-2.4,i=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-e,y:i},{x:e,y:i},{x:e,y:i/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-e,y:-i},{x:e,y:-i},{x:e,y:-i/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},s=Bo(0,0,.3);return[...A,o,n,s]},CCt=t=>{const{p:A,pn:e,w:i}=t;if(e===1)return{x:-i/2+1.2,y:2*A};if(e===2)return{x:-i/2+1.2,y:A};if(e===3)return{x:-i/2+1.2,y:0};if(e===4)return{x:-i/2+1.2,y:-A};if(e===5)return{x:-i/2+1.2,y:-2*A};if(e===6)return{x:i/2-1.175,y:0};throw new Error("Invalid pin number")},lCt=t=>{const A=[];for(let r=1;r<=t.num_pins;r++){const{x:a,y:g}=CCt({h:Number.parseFloat(t.h),p:1.3,pn:r,w:8.7});let I=Number.parseFloat(t.pw),c=Number.parseFloat(t.pl);r===6?(I=3.4,c=2.15):(I=.6,c=2.2),A.push(xi(r,a,g,c,I))}const e=Number.parseFloat(t.w)/2-2.4,i=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-e,y:i},{x:e,y:i},{x:e,y:i/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-e,y:-i},{x:e,y:-i},{x:e,y:-i/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},s=Bo(0,0,.3);return[...A,o,n,s]},QCt=YA({fn:Y(),num_pins:jA().default(3),w:Y().default("3.40mm"),h:Y().default("3.30mm"),pl:Y().default("1mm"),pw:Y().default("0.7mm"),p:Y().default("1.2mm"),string:Y().optional()}),ECt=t=>{const A=t.string?.match(/^sot23w_(\d+)/),e=A?Number.parseInt(A[1],3):3,i=QCt.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:uCt(i),parameters:i};throw new Error("Invalid number of pins")},hCt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e,y:.95}:A===2?{x:-e,y:-.95}:{x:e,y:0}},uCt=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=hCt({num_pins:t.num_pins,pn:r+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)});A.push(xi(r+1,a,g,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=Bo(0,Number.parseInt(t.h)/2+1,.3),i=Number.parseFloat(t.w)/2-1,o=Number.parseFloat(t.h)/2,n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:o},{x:i+.3,y:o},{x:i+.3,y:o/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:-o},{x:i+.3,y:-o},{x:i+.3,y:-o/2}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,n,s,e]},dCt=YA({fn:Y(),num_pins:ei([kA(3),kA(2)]).default(3),p:Y().default("1.27mm"),id:Y().default("0.72mm"),od:Y().default("0.95mm"),w:Y().default("2.5mm"),h:Y().default("4.2mm"),string:Y().optional()}),pCt=t=>{const{p:A,id:e,od:i,w:o,h:n}=t,s=Number.parseFloat(n)/2,r=Number.parseFloat(A);return[Fn(1,-r,s-r,e,i),Fn(2,0,s-r,e,i),Fn(3,r,s-r,e,i)]},fCt=t=>{const{p:A,id:e,od:i,h:o}=t,n=Number.parseFloat(o)/2,s=Number.parseFloat(A);return[Fn(1,-s,n-s,e,i),Fn(2,s,n-s,e,i)]},yCt=t=>{const A=t.string?.match(/^to92s_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=dCt.parse({...t,num_pins:e});let o=[];if(i.num_pins===3)o=pCt(i);else if(i.num_pins===2)o=fCt(i);else throw new Error("Invalid number of pins for TO-92");const n=Number.parseFloat(i.h)/2,s=Number.parseFloat(i.p),r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n,y:n-s},{x:-1.9,y:0},{x:1.9,y:0},{x:n,y:n-s},{x:1.5,y:Number.parseFloat(i.h)/2+.5},{x:-1.5,y:Number.parseFloat(i.h)/2+.5},{x:-n,y:n-s}],stroke_width:.1,pcb_silkscreen_path_id:""},a=Bo(0,n+1,.5);return{circuitJson:[...o,r,a],parameters:i}},wCt=YA({fn:Y(),p:ie.optional(),id:ie.optional(),pw:ie.optional(),pl:ie.optional(),w:ie.optional(),h:ie.optional(),sh:ei([Be(),Y(),jA()]).optional().transform(t=>{if(typeof t=="string"){const A=Number(t);return Number.isNaN(A)?!0:A}return t}).describe('JST SH (Surface-mount) connector family. SH stands for "Super High-density".'),ph:Be().optional().describe('JST PH (Through-hole) connector family. PH stands for "Pin Header".'),string:Y().optional()}),mCt={ph:{p:ie.parse("2.2mm"),id:ie.parse("0.70mm"),pw:ie.parse("1.20mm"),pl:ie.parse("1.20mm"),w:ie.parse("6mm"),h:ie.parse("5mm")},sh:{p:ie.parse("1mm"),pw:ie.parse("0.6mm"),pl:ie.parse("1.55mm"),w:ie.parse("5.8mm"),h:ie.parse("7.8mm")}};function DCt(t){return t.sh?"sh":(t.ph,"ph")}function SCt(t,A,e,i,o,n){const s=[];if(t==="ph"){const r=e/2;s.push(bO(1,-r,2,i,o,n)),s.push(bO(2,r,2,i,o,n))}else{const r=-((A-1)/2)*e;for(let g=0;g<A;g++){const I=r+g*e;console.log("x si",I),s.push(xi(g+1,I,-1.325,o,n))}const a=(A-1)/2*e+1.3;console.log("offset",a),s.push(xi(A+1,-a,1.22,1.2,1.8)),s.push(xi(A+2,a,1.22,1.2,1.8))}return s}function bCt(t,A,e){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 xCt=t=>{const A=wCt.parse(t),e=DCt(A),i=mCt[e],o=A.p??i.p,n=A.id??i.id,s=A.pw??i.pw,r=A.pl??i.pl,a=A.w??i.w,g=A.h??i.h;let I=e==="sh"?4:2;if(e==="sh"){const Q=(typeof t.string=="string"?t.string:"").match(/sh(\d+)/);if(Q&&Q[1]){const E=parseInt(Q[1],10);Number.isNaN(E)||(I=E)}else typeof A.sh=="number"&&(I=A.sh)}const c=SCt(e,I,o,n,s,r),B=bCt(e),C=Bo(0,g/2+1,.5);return{circuitJson:[...c,B,C],parameters:{...A,p:o,id:n,pw:s,pl:r,w:a,h:g,num_pins:I,sh:e==="sh",ph:e==="ph"}}},kCt=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("3.30mm"),h:Y().default("1.70mm"),pl:Y().default("0.80mm"),pw:Y().default("1mm"),p:Y().default("1.90mm")}),GCt=t=>{const A=kCt.parse(t),e=Bo(0,ie.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:RCt(A).concat(i,e),parameters:A}},FCt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},RCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=FCt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},NCt=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"}}},MCt=YA({fn:Y(),num_pins:ei([kA(8),kA(10)]).default(8),w:Y().optional(),h:Y().optional(),p:Y().optional(),pl:Y().optional(),pw:Y().optional(),string:Y().optional()}),_Ct=t=>{const A=MCt.parse(t),e=NCt(A.num_pins),i=ie.parse(A.w||e.w),o=ie.parse(A.h||e.h),n=ie.parse(A.p||e.p),s=ie.parse(A.pl||e.pl),r=ie.parse(A.pw||e.pw),a=[],g=A.num_pins/2;for(let u=0;u<A.num_pins;u++){const{x:d,y:f}=pWA(A.num_pins,u+1,i,n),D=u<g?u+1:A.num_pins-(u-g);a.push(xi(D,d,f,s,r))}const I=i,c=o,B={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-I/2,y:c/2},{x:I/2,y:c/2}],stroke_width:.05,pcb_silkscreen_path_id:""},C={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-I/2,y:-c/2},{x:I/2,y:-c/2}],stroke_width:.05,pcb_silkscreen_path_id:""},l=pWA(A.num_pins,1,I,n),Q={x:l.x-.8,y:l.y},E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:Q.x-.4,y:Q.y},{x:Q.x-.7,y:Q.y+.3},{x:Q.x-.7,y:Q.y-.3},{x:Q.x-.4,y:Q.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},h=Bo(0,c/2+.5,.3);return{circuitJson:[...a,B,C,h,E],parameters:A}},pWA=(t,A,e,i)=>{const o=t/2,n=(A-1)%o,s=A<=o?-1:1,r=(o-1)/2-n;return{x:s*ie.parse(t===8?"1.8mm":"2.2mm"),y:r*i}},vCt=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"}}},UCt=YA({fn:Y(),num_pins:ei([kA(8),kA(10),kA(12),kA(16)]).default(8),w:Y().optional(),h:Y().optional(),p:Y().optional(),pl:Y().optional(),pw:Y().optional(),string:Y().optional()}),fWA=(t,A,e,i)=>{const o=t/2,n=(A-1)%o,s=A<=o?-1:1,r=(o-1)/2-n;return{x:s*ie.parse("2mm"),y:r*i}},LCt=t=>{const A=UCt.parse(t),e=vCt(A.num_pins),i=ie.parse(A.w||e.w),o=ie.parse(A.h||e.h),n=ie.parse(A.p||e.p),s=ie.parse(A.pl||e.pl),r=ie.parse(A.pw||e.pw),a=[];for(let h=0;h<A.num_pins;h++){const{x:u,y:d}=fWA(A.num_pins,h+1,i,n);a.push(xi(h+1,u,d,s,r))}const g=i,I=o,c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-g/2,y:I/2},{x:g/2,y:I/2}],stroke_width:.05,pcb_silkscreen_path_id:""},B={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-g/2,y:-I/2},{x:g/2,y:-I/2}],stroke_width:.05,pcb_silkscreen_path_id:""},C=fWA(A.num_pins,1,g,n),l={x:C.x-.8,y:C.y},Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:l.x-.4,y:l.y},{x:l.x-.7,y:l.y+.3},{x:l.x-.7,y:l.y-.3},{x:l.x-.4,y:l.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},E=Bo(0,I/2+.5,.3);return{circuitJson:[...a,c,B,E,Q],parameters:A}},HCt=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("3.8mm"),h:Y().default("1.65mm"),pl:Y().default("1.2mm"),pw:Y().default("1.2mm"),pad_spacing:Y().default("2.6mm")}),YCt=t=>{const A=HCt.parse(t),e=Bo(0,ie.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.pad_spacing)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:-ie.parse(A.h)/2},{x:ie.parse(A.pad_spacing)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:KCt(A).concat(i,e),parameters:A}},JCt=t=>{const{pn:A,pad_spacing:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},KCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=JCt({pn:e,pad_spacing:Number.parseFloat(t.pad_spacing)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},TCt=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("3.20mm"),h:Y().default("1.65mm"),pl:Y().default("0.8mm"),pw:Y().default("0.9mm"),pad_spacing:Y().default("2.1mm")}),qCt=t=>{const A=TCt.parse(t),e=Bo(0,ie.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.pad_spacing)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:-ie.parse(A.h)/2},{x:ie.parse(A.pad_spacing)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:OCt(A).concat(i,e),parameters:A}},PCt=t=>{const{pn:A,pad_spacing:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},OCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=PCt({pn:e,pad_spacing:Number.parseFloat(t.pad_spacing)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},WCt=YA({fn:Y(),num_pins:ei([kA(6),kA(8)]).default(8),w:Y().default("3mm"),h:Y().default("3mm"),p:Y().default("0.5mm"),pl:Y().default("0.52mm"),pw:Y().default("0.35mm"),epw:Y().default("1.40mm"),eph:Y().default("1.60mm"),string:Y().optional(),ep:Be().default(!1)}),ZCt=t=>{t.string&&t.string.includes("_ep")&&(t.ep=!0);const A=t.string?.match(/^son_(\d+)/),e=A?Number.parseInt(A[1],10):t.num_pins||8,i=WCt.parse({...t,num_pins:e}),o=ie.parse(i.w),n=ie.parse(i.h),s=ie.parse(i.p),r=ie.parse(i.pl),a=ie.parse(i.pw),g=ie.parse(i.epw),I=ie.parse(i.eph),c=[];for(let f=0;f<i.num_pins;f++){const{x:D,y:b}=yWA(i.num_pins,f+1,o,s);c.push(xi(f+1,D,b,r,a))}i.ep&&c.push(xi(i.num_pins+1,0,0,g,I));const B=o,C=n,l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-B/2,y:C/2},{x:B/2,y:C/2}],stroke_width:.05,pcb_silkscreen_path_id:""},Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-B/2,y:-C/2},{x:B/2,y:-C/2}],stroke_width:.05,pcb_silkscreen_path_id:""},E=yWA(i.num_pins,1,B,s),h={x:E.x-.4,y:E.y},u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:h.x-.4,y:h.y},{x:h.x-.7,y:h.y+.3},{x:h.x-.7,y:h.y-.3},{x:h.x-.4,y:h.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},d=Bo(0,C/2+.5,.3);return{circuitJson:[...c,l,Q,d,u],parameters:i}},yWA=(t,A,e,i)=>{const o=t/2,n=(A-1)%o,s=A<=o?-1:1,r=(o-1)/2-n;return{x:s*ie.parse("1.4mm"),y:r*i}},VCt=t=>{const{num_pins:A,bridged:e,p:i=2.54,pw:o=1.5,ph:n=1.5}=t,s=ie.parse(i),r=ie.parse(o),a=ie.parse(n),g=Math.min(a/4,.5),I=[];for(let f=0;f<A;f++)I.push(xi(f+1,f*s,0,r,a));let c=[];if(e){const f=e.split("").map(Number);if(f.length>1)for(let D=0;D<f.length-1;D++){const b=f[D],m=f[D+1];if(typeof b=="number"&&typeof m=="number"&&!isNaN(b)&&!isNaN(m)){const x=(b-1)*s,F=(m-1)*s,k=Math.sign(F-x),v=x+k*(r/2),M=F-k*(r/2);c.push({type:"pcb_trace",pcb_trace_id:"",route:[{start_pcb_port_id:`{PIN${b}}`,x:v,y:0,width:g,layer:"top",route_type:"wire"},{end_pcb_port_id:`{PIN${m}}`,x:M,y:0,width:g,layer:"top",route_type:"wire"}]})}}}const B=(A-1)*s+r+.7,C=a+1,l=(A-1)*s/2,Q=0,E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"outline",route:[{x:l-B/2,y:Q-C/2},{x:l+B/2,y:Q-C/2},{x:l+B/2,y:Q+C/2},{x:l-B/2,y:Q+C/2},{x:l-B/2,y:Q-C/2}],stroke_width:.15},u=Q+C/2+.6,d=Bo(l,u,.4);return{circuitJson:[...I,...c,E,d],parameters:t}},wWA={fn:kA("sot457"),num_pins:kA(6).default(6),pillh:Y().default("0.45mm"),pillw:Y().default("1.45mm"),pl:Y(),pw:Y(),p:Y(),wave:Be().optional(),reflow:Be().optional()},jCt=YA({...wWA,h:Y().default("2.5mm"),w:Y().default("2.7mm"),pl:Y().default("0.8mm"),pw:Y().default("0.55mm"),p:Y().default("0.95mm")}),zCt=YA({...wWA,h:Y().default("3mm"),w:Y().default("4mm"),pillr:Y().default("0.225mm"),pl:Y().default("1.45mm"),pw:Y().default("1.5mm"),p:Y().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)})),iS=t=>Number.parseFloat(t.replace("mm","")),mWA=({pitch:t,width:A,pinNumber:e})=>{const n={1:{x:-A/2-.1,y:t},2:{x:-A/2-.1,y:0},3:{x:-A/2-.1,y:-t},4:{x:A/2+.1,y:-t},5:{x:A/2+.1,y:0},6:{x:A/2+.1,y:t}}[e];if(!n)throw new Error(`Invalid pin number: ${e}`);return n},DWA=t=>{const A=[],e=iS(t.p),i=iS(t.pl),o=iS(t.pw),n=iS(t.w),s=iS(t.h);if(t.wave){const l={1:({padWidth:Q,padHeight:E})=>xi(1,-e,e,E,Q),2:({padWidth:Q,padHeight:E})=>xi(2,-e,-e,E,Q),3:({padWidth:Q,padHeight:E})=>SO(3,-e,0,iS(t.pillw),iS(t.pillh)),4:({padWidth:Q,padHeight:E})=>SO(4,e,0,iS(t.pillw),iS(t.pillh)),5:({padWidth:Q,padHeight:E})=>xi(5,e,e,E,Q),6:({padWidth:Q,padHeight:E})=>xi(6,e,-e,E,Q)};for(let Q=1;Q<=t.num_pins;Q++){const E=l[Q];E&&A.push(E({padWidth:i,padHeight:o}))}}else for(let l=1;l<=t.num_pins;l++){const{x:Q,y:E}=mWA({pitch:e,width:n,pinNumber:l});A.push(xi(l,Q,E,i,o))}const r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-n/3,y:s/2+e/1.3},{x:n/3,y:s/2+e/1.3}],stroke_width:.05},a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-n/3,y:-s/2-e/1.3},{x:n/3,y:-s/2-e/1.3}],stroke_width:.05},g=Bo(0,s+.5,.3),I=mWA({pitch:e,width:n,pinNumber:1}),c=t.wave?1:.5,B=t.wave?.7:.3;I.x-=t.wave?o:o*1.7;const C={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:I.x+c/2,y:I.y},{x:I.x-c/2,y:I.y+B/2},{x:I.x-c/2,y:I.y-B/2},{x:I.x+c/2,y:I.y}],stroke_width:.05};return[g,r,a,C,...A]},XCt=t=>{if(t.wave){const e=zCt.parse({...t,fn:"sot457"});return{circuitJson:DWA(e),parameters:e}}const A=jCt.parse(t);return{circuitJson:DWA(A),parameters:A}},$Ct=YA({fn:Y(),num_pins:ei([kA(3),kA(2)]).default(3),p:Y().default("3.8mm"),id:Y().default("1.25mm"),od:Y().default("2.35mm"),ca:Y().default("14mm").describe("Caliper axis (width or diameter of the potentiometer body or adjustment knob)"),w:Y().default("5.35mm"),h:Y().default("4mm"),string:Y().optional()}),Alt=t=>{const{p:A,id:e,od:i,h:o,ca:n}=t,s=Number.parseFloat(o),r=Number.parseFloat(n);return[Fn(1,0,r/4+.3,e,i),Fn(2,s,0,e,i),Fn(3,0,-r/4-.3,e,i)]},elt=t=>{const A=t.string?.match(/^potentiometer_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=$Ct.parse({...t,num_pins:e});let o=[];i.num_pins===3&&(o=Alt(i));const n=Number.parseFloat(i.ca)/2+.15,s=Number.parseFloat(i.w),r=Number.parseFloat(i.od)/2+.35,a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:n-1.75},{x:0,y:n},{x:s,y:n},{x:s,y:r}],stroke_width:.1,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:s,y:-r},{x:s,y:-n},{x:0,y:-n},{x:0,y:-n+1.75}],stroke_width:.1,pcb_silkscreen_path_id:""},I=Number.parseFloat(i.w)/2,c=Bo(I,n+1,.5);return{circuitJson:[...o,a,g,c],parameters:i}},tlt=YA({fn:Y(),p:ie.optional().default("7.5mm"),id:ie.optional().default("1mm"),od:ie.optional().default("2mm"),d:ie.optional().default("10.5mm")}),ilt=(t,A,e,i,o)=>{const n=[],s=[];for(let r=0;r<=50;r++){const a=r/50*Math.PI,g=t+Math.cos(a)*e,I=A+Math.sin(a)*e;g<t-i&&I>=A-o/2&&I<=A+o/2||n.push({x:g,y:I})}for(let r=0;r<=50;r++){const a=Math.PI+r/50*Math.PI,g=t+Math.cos(a)*e,I=A+Math.sin(a)*e;g<t-i&&I>=A-o/2&&I<=A+o/2||s.push({x:g,y:I})}return{topArc:n,bottomArc:s}},olt=t=>{const A=tlt.parse(t),{p:e,id:i,od:o,d:n}=A,s=[Fn(1,-e/2,0,i,o),Fn(2,e/2,0,i,o)],{topArc:r,bottomArc:a}=ilt(0,0,n/2+.1,o/2,o),g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:r,stroke_width:.1,pcb_silkscreen_path_id:""},I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:a,stroke_width:.1,pcb_silkscreen_path_id:""},c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:n/2+.1},{x:0,y:-(n/2+.1)}],stroke_width:.1,pcb_silkscreen_path_id:""},B=-(n/2+.5),C=o/2+1.5,l=.5,Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:B-l,y:C},{x:B+l,y:C}],stroke_width:.1,pcb_silkscreen_path_id:""},E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:B,y:C-l},{x:B,y:C+l}],stroke_width:.1,pcb_silkscreen_path_id:""},h=Bo(0,n/2+1,.5);return{circuitJson:[...s,g,I,c,Q,E,h],parameters:A}},nlt=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("6.5mm"),h:Y().default("3mm"),pl:Y().default("1.75mm"),pw:Y().default("2.40mm"),p:Y().default("4.75mm")}),slt=t=>{const A=nlt.parse(t),e=Bo(0,ie.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.3,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.3,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:alt(A).concat(i,e),parameters:A}},rlt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},alt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=rlt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},glt=YA({fn:Y(),num_pins:jA().default(3),w:Y().default("2.45mm"),h:Y().default("2.40mm"),pl:Y().default("0.45mm"),pw:Y().default("0.70mm"),p:Y().default("1mm"),string:Y().optional()}),Ilt=t=>{const A=t.string?.match(/^sot323_(\d+)/),e=A?Number.parseInt(A[1],3):3,i=glt.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:Blt(i),parameters:i};throw new Error("Invalid number of pins")},clt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e,y:.65}:A===2?{x:-e,y:-.65}:{x:e,y:0}},Blt=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=clt({num_pins:t.num_pins,pn:r+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)});A.push(xi(r+1,a,g,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=Bo(0,Number.parseInt(t.h)/2+1,.3),i=Number.parseFloat(t.w)/2-Number.parseFloat(t.pl),o=Number.parseFloat(t.h)/2,n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:o+.3},{x:i,y:o+.3},{x:i,y:o/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:-o-.3},{x:i,y:-o-.3},{x:i,y:-o/2}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,n,s,e]},Clt=YA({fn:Y(),circle:Be().optional(),rect:Be().optional(),square:Be().optional(),pill:Be().optional(),d:ie.optional(),pd:ie.optional(),diameter:ie.optional(),r:ie.optional(),pr:ie.optional(),radius:ie.optional(),w:ie.optional(),pw:ie.optional(),width:ie.optional(),h:ie.optional(),ph:ie.optional(),height:ie.optional(),s:ie.optional(),size:ie.optional(),string:Y().optional()}).transform(t=>{let A="rect";t.circle&&(A="circle"),t.square&&(A="square"),t.rect&&(A="rect"),t.pill&&(A="pill");let e,i,o;return A==="circle"?t.r!==void 0?e=pa(t.r):t.pr!==void 0?e=pa(t.pr):t.radius!==void 0?e=pa(t.radius):t.d!==void 0?e=pa(t.d)/2:t.pd!==void 0?e=pa(t.pd)/2:t.diameter!==void 0?e=pa(t.diameter)/2:e=pa("1mm")/2:(t.w!==void 0?i=pa(t.w):t.pw!==void 0?i=pa(t.pw):t.width!==void 0?i=pa(t.width):t.s!==void 0?i=pa(t.s):t.size!==void 0?i=pa(t.size):i=pa("1mm"),t.h!==void 0?o=pa(t.h):t.ph!==void 0?o=pa(t.ph):t.height!==void 0?o=pa(t.height):A==="square"||A==="rect"?o=i:o=pa("1mm")),{fn:t.fn,shape:A,radius:e,width:i,height:o}}),llt=t=>{const A=Clt.parse(t),{shape:e,radius:i,width:o,height:n}=A;let s,r;return e==="circle"?(s=aWA(1,{x:0,y:0,radius:i}),r=i+.5):e==="pill"?(s=SO(1,0,0,o,n),r=Math.max(o,n)/2+.5):(s=xi(1,0,0,o,n),r=n/2+.5),{circuitJson:[s,Bo(0,r,.2)],parameters:A}},Qlt=YA({fn:Y(),d:ie.optional(),hd:ie.optional(),r:ie.optional(),hr:ie.optional(),pd:ie.optional(),pr:ie.optional(),squarepad:Be().optional().default(!1)}).transform(t=>{let A;t.d!==void 0?A=pa(t.d):t.hd!==void 0?A=pa(t.hd):t.r!==void 0?A=pa(t.r)*2:t.hr!==void 0?A=pa(t.hr)*2:A=pa("1mm");let e;return t.pd!==void 0?e=pa(t.pd):t.pr!==void 0?e=pa(t.pr)*2:e=A*(1.5/1),{fn:t.fn,d:A,pd:e,squarepad:t.squarepad??!1}}),Elt=t=>{const A=Qlt.parse(t),{d:e,pd:i,squarepad:o}=A;return{circuitJson:[o?bO(1,0,0,e,i,i):Fn(1,0,0,e,i),Bo(0,i/2+.5,.2)],parameters:A}},hlt=YA({fn:Y(),num_pins:kA(6).default(6),h:Y().default("1.6mm"),pl:Y().default("1mm"),pw:Y().default("0.7mm"),p:Y().default("0.95mm")}),ult=t=>{const A=hlt.parse(t);return{circuitJson:dlt(A),parameters:A}},SWA=t=>{const{p:A,h:e,pn:i}=t;if(i===1)return{x:-e/2-.5,y:A};if(i===2)return{x:-e/2-.5,y:0};if(i===3)return{x:-e/2-.5,y:-A};if(i===4)return{x:e/2+.5,y:-A};if(i===5)return{x:e/2+.5,y:0};if(i===6)return{x:e/2+.5,y:A};throw new Error("Invalid pin number")},dlt=t=>{const A=[];for(let c=1;c<=t.num_pins;c++){const{x:B,y:C}=SWA({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:c});A.push(xi(c,B,C,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=t.num_pins/2*Number.parseFloat(t.p),i=Number.parseFloat(t.h),o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-e/3,y:i/2+Number.parseFloat(t.p)/1.3},{x:e/3,y:i/2+Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-e/3,y:-i/2-Number.parseFloat(t.p)/1.3},{x:e/3,y:-i/2-Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},s=Bo(0,i+.3,.3),r=SWA({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:1});r.x=r.x-Number.parseFloat(t.pw)*1.5;const a=.7,g=.3,I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:r.x+a/2,y:r.y},{x:r.x-a/2,y:r.y+g/2},{x:r.x-a/2,y:r.y-g/2},{x:r.x+a/2,y:r.y}],stroke_width:.05};return[...A,s,o,n,I]},plt=YA({fn:Y()}),flt=t=>{const A=plt.parse(t),e=[],i=.5-.15,o=1.5,s=.5/2,r=75,a=-37/2;for(let m=0;m<r;m++){const x=m+1;if(x>=24&&x<=31)continue;const F=a-m*s,k=x%2===0,v=o+(k?.25:0),H=.5-v/2,P=xi(x,H,F,v,i);P.layer=k?"bottom":"top",e.push(P)}const g=46*.0254,I=137*.0254,c=261*.0254,B={type:"pcb_cutout",pcb_cutout_id:"",shape:"rect",center:{x:-I/2+o/2,y:a-c},width:I,height:g},C={x:-.5,y:a},l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:C.x-.4,y:C.y},{x:C.x-.7,y:C.y+.3},{x:C.x-.7,y:C.y-.3},{x:C.x-.4,y:C.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"};let Q=1/0,E=-1/0,h=1/0,u=-1/0;const d=(m,x,F=0,k=0)=>{Q=Math.min(Q,m-F/2),E=Math.max(E,m+F/2),h=Math.min(h,x-k/2),u=Math.max(u,x+k/2)};for(const m of e)d(m.x,m.y,m.width,m.height);d(B.center.x,B.center.y,B.width,B.height);for(const m of l.route)d(m.x,m.y);const f=(Q+E)/2,D=(h+u)/2,b=m=>{typeof m.x=="number"&&(m.x-=f),typeof m.y=="number"&&(m.y-=D),m.center&&(m.center.x-=f,m.center.y-=D),Array.isArray(m.route)&&(m.route=m.route.map(x=>({x:x.x-f,y:x.y-D})))};for(const m of e)b(m);return b(B),b(l),{circuitJson:[...e,B,l],parameters:A}};function ylt(t){return t!=null}var wlt=(t,A)=>{if(!A)return t;const e=t.filter(I=>I.type==="pcb_smtpad"||I.type==="pcb_plated_hole"||I.type==="pcb_thtpad");if(e.length===0)return t;let i=1/0,o=-1/0,n=1/0,s=-1/0;const r=(I,c,B=0,C=0)=>{const l=I-B/2,Q=I+B/2,E=c-C/2,h=c+C/2;i=Math.min(i,l),o=Math.max(o,Q),n=Math.min(n,E),s=Math.max(s,h)};for(const I of e)if(I.type==="pcb_smtpad"){const c=I.shape==="circle"?I.radius*2:I.width,B=I.shape==="circle"?I.radius*2:I.height;r(I.x,I.y,c,B)}else if(I.type==="pcb_plated_hole"){const c=I.outer_diameter??I.hole_diameter;r(I.x,I.y,c,c)}else if(I.type==="pcb_thtpad"){const c=I.diameter;r(I.x,I.y,c,c)}let a=0,g=0;switch(A){case"center":a=(i+o)/2,g=(n+s)/2;break;case"bottomleft":a=i,g=n;break;case"bottomcenter":case"centerbottom":a=(i+o)/2,g=n;break;case"topcenter":case"centertop":a=(i+o)/2,g=s;break;case"leftcenter":case"centerleft":a=i,g=(n+s)/2;break;case"rightcenter":case"centerright":a=o,g=(n+s)/2;break;case"pin1":const I=e.find(c=>c.port_hints?.[0]==="1")||e[0];a=I.x,g=I.y;break}if(a===0&&g===0)return t;for(const I of t){if(typeof I.x=="number"&&(I.x-=a),typeof I.y=="number"&&(I.y-=g),I.center&&typeof I.center.x=="number"&&(I.center.x-=a,I.center.y-=g),I.type==="pcb_silkscreen_path")for(const c of I.route)c.x-=a,c.y-=g;I.type==="pcb_silkscreen_text"&&I.anchor_position&&(I.anchor_position.x-=a,I.anchor_position.y-=g)}return t},mlt=t=>{let A=FO();const i=t.replace(/^((?:\d{4}|\d{5}))(?=$|_)/,"res$1").split(/_(?!metric)/).map(o=>{const n=o.match(/([a-z]+)([\(\d\.\+\?].*)?/);if(!n)return null;const[,s,r]=n;return!s||r?.includes("?")?null:{fn:s,v:r}}).filter(ylt);for(const{fn:o,v:n}of i)A=A[o](n);return A.setString(t),A},Dlt=()=>Object.keys(eS),FO=()=>{const t=new Proxy({},{get:(A,e)=>{if(e==="soup"||e==="circuitJson"){if("fn"in A&&eS[A.fn])return()=>{const{circuitJson:i}=eS[A.fn](A);return wlt(i,A.origin)};if(!eS[A.fn])throw new Error(`Invalid footprint function, got "${A.fn}"${A.string?`, from string "${A.string}"`:""}`);return()=>{throw new Error(`No function found for footprinter, make sure to specify .dip, .lr, .p, etc. Got "${e}"`)}}if(e==="json"){if(!eS[A.fn])throw new Error(`Invalid footprint function, got "${A.fn}"${A.string?`, from string "${A.string}"`:""}`);return()=>eS[A.fn](A).parameters}return e==="getFootprintNames"?()=>Object.keys(eS):e==="params"?()=>A:e==="setString"?i=>(A.string=i,t):i=>(Object.keys(A).length===0?`${e}${i}`in eS?(A[`${e}${i}`]=!0,A.fn=`${e}${i}`):(A[e]=!0,A.fn=e,e==="res"||e==="cap"?i&&(typeof i=="string"&&i.includes("_metric")?A.metric=i.split("_metric")[0]:A.imperial=i):A.num_pins=Number.isNaN(Number.parseFloat(i))?void 0:Number.parseFloat(i)):!i&&["w","h","p"].includes(e)||(A[e]=i??!0),t)}});return t};FO.string=mlt,FO.getFootprintNames=Dlt;var Slt=FO,bWA=Symbol("Fragment");function EBA(t,A,...e){const i=e.length?e:A?.children!==void 0?[A.children]:[],o=[],n=(Array.isArray(i)?i:[i]).flat(1/0);for(const s of n)s==null||s===!1||(Array.isArray(s)?o.push(...s):o.push(s));return{type:t,props:(A&&A.children!==void 0?{...A,children:void 0}:A)||{},children:o}}var ht=Symbol("Cuboid"),xWA=Symbol("Cube"),Up=Symbol("Cylinder"),kWA=Symbol("Sphere"),xU=Symbol("RoundedCuboid"),Wi=Symbol("Translate"),BQ=Symbol("Rotate"),sE=Symbol("Union"),UG=Symbol("Subtract"),nI=Symbol("Hull"),fs=Symbol("Colorize"),kU=Symbol("Polygon"),GU=Symbol("ExtrudeLinear"),Lp=Symbol("RoundedCylinder"),Ho=bWA,$A=(t,A,e)=>EBA(t,A),Ot=(t,A,e)=>EBA(t,A),WB=({center:t,width:A,length:e,height:i,heightAboveSurface:o=.15,color:n="#555",taperRatio:s=.12,faceRatio:r=.75,straightHeightRatio:a=.5,includeNotch:g=!0,notchRadius:I,notchPosition:c,notchRotation:B=[0,0,0],notchLength:C=.5,notchWidth:l=.25,chamferSize:Q=0})=>{const E=i*a,h=i-E,u=Math.min(A,e)*s,d=Math.max(A-u,A*r),f=Math.max(e-u,e*r),D=Math.min(A,e)*.12,b=I??D,m={x:0,y:e/2-b*.25,z:i},x=c??m,F=Ot(sE,{children:[Ot(nI,{children:[$A(Wi,{z:.005,children:$A(ht,{size:[d,f,.01]})}),$A(Wi,{z:E,children:$A(ht,{size:[A,e,.01]})})]}),Ot(nI,{children:[$A(Wi,{z:E,children:$A(ht,{size:[A,e,.01]})}),$A(Wi,{z:E+h,children:$A(ht,{size:[d,f,.01]})})]})]}),k=(M,H)=>$A(Wi,{offset:{x:M,y:H,z:0},children:$A(BQ,{rotation:[0,0,Math.PI/4],children:$A(ht,{size:[Q*Math.SQRT2,Q*Math.SQRT2,i*3]})})});let v=F;if(Q>0){const M=A/2,H=e/2;v=Ot(UG,{children:[F,k(M,H),k(-M,H),k(M,-H),k(-M,-H)]})}return $A(fs,{color:n,children:$A(Wi,{offset:t,children:$A(Wi,{offset:{x:0,y:0,z:o},children:g?Ot(UG,{children:[v,$A(Wi,{offset:x,children:$A(BQ,{rotation:B,children:$A(Up,{radius:b,height:l})})})]}):v})})})},blt=t=>Array.from({length:t},(A,e)=>e);function hBA(t,A){if(t.length<2)throw new Error("Stroke must have at least two points");const e=Array.isArray(t[0])?t.map(([I,c])=>({x:I,y:c})):t,i=A/2,o=[],n=[];function s(I,c){const B=c.x-I.x,C=c.y-I.y,l=Math.sqrt(B*B+C*C);return{x:-C/l,y:B/l}}function r(I,c,B){const C={x:I.x+c.x*i*B,y:I.y+c.y*i*B};B>0?o.push(C):n.unshift(C)}const a=s(e[0],e[1]);r(e[0],a,1),r(e[0],a,-1);for(let I=1;I<e.length-1;I++){const c=e[I-1],B=e[I],C=e[I+1],l=s(c,B),Q=s(B,C),E=l.x+Q.x,h=l.y+Q.y,u=Math.sqrt(E*E+h*h);if(u/2>2*i)r(B,l,1),r(B,Q,1),r(B,l,-1),r(B,Q,-1);else{const f=1/u;r(B,{x:E*f,y:h*f},1),r(B,{x:E*f,y:h*f},-1)}}const g=s(e[e.length-2],e[e.length-1]);return r(e[e.length-1],g,1),r(e[e.length-1],g,-1),[...o,...n]}var xlt=t=>{const A=Math.min(...t.map(r=>r.x)),e=Math.max(...t.map(r=>r.x)),i=Math.min(...t.map(r=>r.y)),s=5.47/(Math.max(...t.map(r=>r.y))-i);return t.map(r=>({x:(r.x-A-(e-A)/2)*s,y:(r.y-i)*s}))},klt=xlt([{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}]),GWA=5.47,RO=.5,Glt=({x:t,y:A,z:e})=>{const i=t>0;return Ot(Ho,{children:[$A(Wi,{offset:{x:t+.25/2,y:A,z:e},children:$A(BQ,{rotation:["-90deg",0,"90deg"],children:$A(GU,{height:.25,children:$A(kU,{points:klt.slice().reverse().map(o=>[o.x,o.y])})})})}),$A(Wi,{offset:{x:t,y:A+(i?1:-1),z:e},children:$A(BQ,{rotation:["-90deg","90deg",i?"180deg":"0deg"],children:$A(GU,{height:2,children:$A(kU,{points:hBA([[0,0],[-1,0],[-1,-1]],.25).map(o=>[o.x,o.y])})})})})]})},Flt=({numPins:t=8,pitch:A=2.54,bodyWidth:e=6.4,rowSpacing:i})=>{const o=Math.floor(t/2),n=i??(e>=7?e:e+1.22),s=e>=7?n-1.22:e;return Ot(Ho,{children:[blt(t).map(r=>{const a=r%o,g=(Math.floor(r/o)-.5)*2;return $A(Glt,{x:g*n/2,y:a*A-(o-1)/2*A,z:GWA/2+RO})}),$A(WB,{width:s,length:o*A+.5,height:GWA-RO,heightAboveSurface:RO,center:{x:0,y:0,z:RO}})]})};function Rlt(t,{height:A,padContactLength:e,curveLength:i,bodyDistance:o,steepness:n=10}){i||(i=o*.3);let s=o-e-i;s<0&&(i+=s,s=0);const r=e*.75,a=e+i+(o-e-i)*.25;if(t<=r)return 0;if(t>=a)return A;const g=(t-r)/(a-r);return A/(1+Math.exp(-n*(g-.5)))}var Ko=t=>{const{thickness:A,width:e,padContactLength:i,bodyDistance:o,height:n,rotation:s}=t,r=15,a=Array.from({length:r}).map((I,c)=>c/(r-1)*o).map(I=>[I,Rlt(I,t)]),g=hBA(a,A);return $A(fs,{color:"#fff",children:$A(Wi,{offset:{z:0,y:0,x:0,...t.position},children:$A(BQ,{rotation:["90deg",0,s??0],children:$A(Wi,{offset:{x:0,y:0,z:-e/2},children:$A(GU,{height:e,children:$A(kU,{points:g.map(I=>[I.x,I.y])})})})})})})},Nlt=({pinCount:t,leadLength:A,leadWidth:e,pitch:i,bodyWidth:o})=>{const n=Math.ceil(t/2),s=i*t/2+e/2,r=(n-1)*i/2,a=.25;return Ot(Ho,{children:[Array.from({length:n}).map((g,I)=>$A(Ko,{position:{x:-o/2-A,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+1,height:.8})),Array.from({length:n}).map((g,I)=>$A(Ko,{rotation:Math.PI,position:{x:o/2+A,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+1,height:.8})),$A(WB,{center:{x:0,y:0,z:a/2},width:o-e-1,length:s,height:1.5})]})},Mlt=({pinCount:t,padContactLength:A=.4,leadWidth:e=.2,pitch:i=.65,bodyWidth:o=3})=>{const n=Math.ceil(t/2),s=(n-1)*i/2,r=.2;return Ot(Ho,{children:[Array.from({length:n}).map((a,g)=>$A(Ko,{position:{x:-o/2-A-.3,y:g*i-s,z:r/2},width:e,thickness:r,padContactLength:A,bodyDistance:A+.4,height:.6})),Array.from({length:n}).map((a,g)=>$A(Ko,{rotation:Math.PI,position:{x:o/2+A+.3,y:g*i-s,z:r/2},width:e,thickness:r,padContactLength:A,bodyDistance:A+.4,height:.6})),$A(WB,{center:{x:0,y:0,z:r/2},width:o,length:o,height:1.1,notchRadius:.35,heightAboveSurface:.1,taperRatio:.09})]})},uBA=1,dBA=.5,xM=.5,FU=.2,_lt=uBA-FU*2,FWA=({color:t="#333"})=>Ot(Ho,{children:[$A(ht,{size:[_lt,dBA,xM],offset:[0,0,xM/2],color:t}),$A(ht,{size:[FU,xM,dBA],offset:[uBA/2-FU/2,0,xM/2],color:"#ccc"}),$A(ht,{size:[FU,xM,dBA],offset:[-uBA/2+FU/2,0,xM/2],color:"#ccc"})]}),pBA=1.6,vlt=pBA-.3*2,NO=.3,fBA=.85,kM=.6,RWA=({color:t="#333"})=>Ot(Ho,{children:[$A(ht,{size:[vlt,fBA,kM],offset:[0,0,kM/2],color:t}),$A(ht,{size:[NO,fBA,kM],offset:[pBA/2-NO/2,0,kM/2],color:"#ccc"}),$A(ht,{size:[NO,fBA,kM],offset:[-pBA/2+NO/2,0,kM/2],color:"#ccc"})]}),yBA=2,wBA=1.25,GM=.55,RU=.5,Ult=yBA-RU*2,NWA=({color:t="#333"})=>Ot(Ho,{children:[$A(ht,{size:[Ult,wBA,GM],offset:[0,0,GM/2],color:t}),$A(ht,{size:[RU,wBA,GM],offset:[yBA/2-RU/2,0,GM/2],color:"#ccc"}),$A(ht,{size:[RU,wBA,GM],offset:[-yBA/2+RU/2,0,GM/2],color:"#ccc"})]}),Llt=({pinCount:t,pitch:A,leadWidth:e,padContactLength:i,bodyWidth:o})=>{const n=t/4;A||(A=Hlt(t,o)),i||(i=Ylt(t)),e||(e=Jlt(t,o)),o||(o=A*(n+4));const s=o,r=(n-1)*A/2,a=s+2*i,g=a,I=.8,c=.15,B=(g-o)/2+.5;return Ot(Ho,{children:[Array.from({length:n}).map((C,l)=>$A(Ko,{position:{x:-g/2-.4,y:l*A-r,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:n}).map((C,l)=>$A(Ko,{rotation:Math.PI,position:{x:g/2+.4,y:l*A-r,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:n}).map((C,l)=>$A(Ko,{rotation:Math.PI/2,position:{x:l*A-r,y:-a/2-.4,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:n}).map((C,l)=>$A(Ko,{rotation:-Math.PI/2,position:{x:l*A-r,y:a/2+.4,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),$A(WB,{center:{x:0,y:0,z:0},width:o,length:s,height:1.5,taperRatio:.03,chamferSize:.7,notchPosition:{x:-(s/2-1.5),y:o/2-1.5,z:1.5},notchRadius:1.5/2})]})},Hlt=(t,A)=>{switch(t){case 44:case 64:return .8;case 52:return A===14?1:.65;case 208:return .5;default:return .5}},Ylt=t=>{switch(t){case 32:return .6;case 40:return .6;case 52:case 64:return .65;case 208:return 1.65;default:return .6}},Jlt=(t,A)=>{switch(t){case 44:case 64:return .5;case 52:return A===14?.45:.55;case 208:return .3;default:return .25}},Klt=({numberOfPins:t,pitch:A=2.54,longSidePinLength:e=6,invert:i,faceup:o,rows:n=1})=>{const a=Math.ceil(t/n),g=2.54,I=a*A,c=n>1?(n-1)*g+.63*3:.63*3,B=3,C=-((a-1)/2)*A,l=n>1?-((n-1)*g)/2:0,Q=E=>i||o?-E+2:E;return Ot(Ho,{children:[$A(ht,{color:"#222",size:[I,c,2],center:[0,l,Q(2/2)]}),Array.from({length:t},(E,h)=>{const u=Math.floor(h/a),d=h%a,f=C+d*A,D=-u*g;return Ot(Ho,{children:[!o&&$A(fs,{color:"gold",children:Ot(nI,{children:[$A(ht,{color:"gold",size:[.63,.63,B*.9],center:[f,D,Q(2*.9+2/2)]}),$A(ht,{color:"gold",size:[.63/1.8,.63/1.8,B],center:[f,D,Q(2+2/2)]})]})}),$A(fs,{color:"gold",children:Ot(nI,{children:[$A(ht,{color:"gold",size:[.63,.63,e*.9],center:[f,D,Q(-e/2*.9)]}),$A(ht,{color:"gold",size:[.63/1.8,.63/1.8,e],center:[f,D,Q(-e/2)]})]})})]})})]})},Tlt=t=>{const A=["left","bottom","right","top"],{pin_count:e,pn:i,w:o,h:n,p:s,pl:r}=t,a=e/4,g=A[Math.floor((i-1)/a)],I=(i-1)%a,c=s*(a-1),B=s*(a-1),C=-r/2;switch(g){case"left":return{x:-o/2-C,y:B/2-I*s,o:"vert"};case"bottom":return{x:-c/2+I*s,y:-n/2-C,o:"horz"};case"right":return{x:o/2+C,y:-B/2+I*s,o:"vert"};case"top":return{x:c/2-I*s,y:n/2+C,o:"horz"};default:throw new Error("Invalid pin number")}},qlt=({num_pins:t,cw:A,ccw:e,startingpin:i})=>{const o=[],n=t/4;let s=1;const r={};for(const a of i??[])r[a]=!0;!r.leftside&&!r.topside&&!r.rightside&&!r.bottomside&&(r.leftside=!0),!r.bottompin&&!r.leftpin&&!r.rightpin&&!r.toppin&&(r.leftside?r.toppin=!0:r.topside?r.rightpin=!0:r.rightside?r.bottompin=!0:r.bottomside&&(r.leftpin=!0)),r.leftside&&r.toppin?s=1:r.leftside&&r.bottompin?s=n:r.bottomside&&r.leftpin?s=n+1:r.bottomside&&r.rightpin?s=n*2:r.rightside&&r.bottompin?s=n*2+1:r.rightside&&r.toppin?s=n*3:r.topside&&r.rightpin?s=n*3+1:r.topside&&r.leftpin&&(s=n*4),o.push(-1);for(let a=0;a<t;a++)o[s]=a+1,s++,s>t&&(s=1);return o},Plt=({num_pins:t=16,bodyWidth:A=9,bodyLength:e=9,bodyThickness:i=.8,thermalPadSize:o,padWidth:n=.25,padLength:s=.25,pitch:r=.5,thermalPadThickness:a=.05})=>{const g=qlt({num_pins:t,cw:!0,ccw:!0}),I=[];for(let c=0;c<t;c++){const{x:B,y:C,o:l}=Tlt({pin_count:t,pn:c+1,w:A,h:e,p:r,pl:s});let Q=n,E=s;l==="vert"&&([Q,E]=[E,Q]);const h=g[c+1];I.push({pn:h,x:B,y:C,pw:Q,pl:E})}return Ot(Ho,{children:[$A(fs,{color:"grey",children:$A(ht,{center:{x:0,y:0,z:i/2},size:[A,e,i]})}),I.map((c,B)=>$A(ht,{center:{x:c.x,y:c.y,z:a/2},size:[c.pw,c.pl,a]})),o?.length!==void 0&&o?.width!==void 0&&$A(ht,{center:{x:0,y:0,z:a/2},size:[o.width,o.length,a]})]})},Olt=Plt,Wlt=()=>{const a=1.1999999999999997;return Ot(Ho,{children:[$A(Ko,{rotation:Math.PI,position:{x:2.8/2+a/4,y:-1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),$A(Ko,{rotation:Math.PI,position:{x:2.8/2+a/4,y:1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),$A(Ko,{position:{x:-2.8/2-a/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),$A(Ko,{position:{x:-2.8/2-a/4,y:-1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),$A(Ko,{position:{x:-2.8/2-a/4,y:1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),$A(WB,{center:{x:0,y:0,z:0},width:1.6,length:2.9,height:1.2})]})},Zlt=Wlt,Vlt=({fullWidth:t=2.9,fullLength:A=2.8})=>{const I=(t-1.92)/2+.3;return Ot(Ho,{children:[$A(Ko,{rotation:Math.PI,position:{x:t/2,y:0,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:I,height:.45}),$A(Ko,{position:{x:-t/2,y:-.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:I,height:.45}),$A(Ko,{position:{x:-t/2,y:.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:I,height:.45}),$A(WB,{center:{x:0,y:0,z:0},width:1.92,length:2.9,height:1.1,straightHeightRatio:.45,heightAboveSurface:.05})]})},mBA=.6,DBA=.3,FM=.33,NU=.1,jlt=mBA-NU*2,MWA=({color:t="#333"})=>Ot(Ho,{children:[$A(ht,{size:[jlt,DBA,FM],offset:[0,0,FM/2],color:t}),$A(ht,{size:[NU,DBA,FM],offset:[mBA/2-NU/2,0,FM/2],color:"#ccc"}),$A(ht,{size:[NU,DBA,FM],offset:[-mBA/2+NU/2,0,FM/2],color:"#ccc"})]}),SBA=.4,bBA=.2,RM=.13,MU=.07,zlt=SBA-MU*2,_WA=({color:t="#333"})=>Ot(Ho,{children:[$A(ht,{size:[zlt,bBA,RM],offset:[0,0,RM/2],color:t}),$A(ht,{size:[MU,bBA,RM],offset:[SBA/2-MU/2,0,RM/2],color:"#ccc"}),$A(ht,{size:[MU,bBA,RM],offset:[-SBA/2+MU/2,0,RM/2],color:"#ccc"})]}),xBA=3.2,kBA=1.6,NM=.9,_U=.5,Xlt=xBA-_U*2,vWA=({color:t="#333"})=>Ot(Ho,{children:[$A(ht,{size:[Xlt,kBA,NM],offset:[0,0,NM/2],color:t}),$A(ht,{size:[_U,kBA,NM],offset:[xBA/2-_U/2,0,NM/2],color:"#ccc"}),$A(ht,{size:[_U,kBA,NM],offset:[-xBA/2+_U/2,0,NM/2],color:"#ccc"})]}),GBA=3.2,FBA=2.5,MM=1,vU=.6,$lt=GBA-vU*2,UWA=({color:t="#333"})=>Ot(Ho,{children:[$A(ht,{size:[$lt,FBA,MM],offset:[0,0,MM/2],color:t}),$A(ht,{size:[vU,FBA,MM],offset:[GBA/2-vU/2,0,MM/2],color:"#ccc"}),$A(ht,{size:[vU,FBA,MM],offset:[-GBA/2+vU/2,0,MM/2],color:"#ccc"})]}),RBA=5,NBA=2.5,_M=1.4,UU=.6,AQt=RBA-UU*2,LWA=({color:t="#333"})=>Ot(Ho,{children:[$A(ht,{size:[AQt,NBA,_M],offset:[0,0,_M/2],color:t}),$A(ht,{size:[UU,NBA,_M],offset:[RBA/2-UU/2,0,_M/2],color:"#ccc"}),$A(ht,{size:[UU,NBA,_M],offset:[-RBA/2+UU/2,0,_M/2],color:"#ccc"})]}),MBA=6.3,_BA=3.2,vM=1.8,LU=.8,eQt=MBA-LU*2,HWA=({color:t="#333"})=>Ot(Ho,{children:[$A(ht,{size:[eQt,_BA,vM],offset:[0,0,vM/2],color:t}),$A(ht,{size:[LU,_BA,vM],offset:[MBA/2-LU/2,0,vM/2],color:"#ccc"}),$A(ht,{size:[LU,_BA,vM],offset:[-MBA/2+LU/2,0,vM/2],color:"#ccc"})]}),tQt=({numberOfPins:t,pitch:A=2.54,legsLength:e=3,outerDiameter:i=.945,innerDiameter:o=.945,rows:n=1})=>{const s=o/1.5,r=s*2+i,a=5,g=Math.ceil(t/n),I=2.54,c=(g-1)*A+i+A/2,B=n>1?(n-1)*I+r:r,C=s*1.6,l=-((g-1)/2)*A,Q=n>1?-((n-1)*I)/2:0,E=$A(fs,{color:"#1a1a1a",children:Ot(UG,{children:[$A(ht,{color:"#000",size:[c,B,a],center:[0,Q,a/2]}),Array.from({length:t},(h,u)=>{const d=Math.floor(u/g),f=u%g,D=l+f*A,b=-d*I;return o?$A(Up,{height:a+.1,radius:o/2,center:[D,b,a/2],color:"#222"},u):$A(ht,{size:[C,C,a],center:[D,b,a/2]},u)})]})});return Ot(Ho,{children:[E,Array.from({length:t},(h,u)=>{const d=Math.floor(u/g),f=u%g,D=l+f*A,b=-d*I;return Ot(fs,{color:"silver",children:[Ot(nI,{children:[$A(ht,{color:"silver",size:[s,s,e*.9],center:[D,b,-e/2*.9]}),$A(ht,{color:"silver",size:[s/1.8,s/1.8,e],center:[D,b,-e/2]})]}),$A(ht,{color:"silver",size:[C,C,C*.5],center:[D,b,C/2*.5]})]},u)})]})},iQt=({width:t,length:A,innerDiameter:e=1})=>{const i=t,o=A,n=t*.7,s=e/2.5;return Ot(Ho,{children:[$A(xU,{color:"#1a1a1f",center:[0,0,n/2],size:[o,o,n],roundRadius:.3}),$A(xU,{color:"#f2f2f2",center:[0,0,n+n*.1/2.5],size:[o,o,n*.1],roundRadius:.14}),$A(Up,{color:"#1a1a1f",height:n*.8,radius:i/3,center:[0,0,n+n*.8/2]}),$A(Up,{color:"#1a1a1f",height:n*.2,radius:e/2,center:[o/3,o/3,n+n*.1/2]}),$A(Up,{color:"#1a1a1f",height:n*.2,radius:e/2,center:[-o/3,-o/3,n+n*.1/2]}),$A(Up,{color:"#1a1a1f",height:n*.2,radius:e/2,center:[-o/3,o/3,n+n*.1/2]}),$A(Up,{color:"#1a1a1f",height:n*.2,radius:e/2,center:[o/3,-o/3,n+n*.1/2]}),$A(MO,{thickness:e/3,width:s,horizontalLength:o*.8,verticalLength:n/2,position:{x:-i/2,y:-o/2,z:-n*1.2}}),$A(MO,{thickness:e/3,width:s,horizontalLength:o*.8,verticalLength:n/2,position:{x:-i/2,y:o/2,z:-n*1.2},rotation:Math.PI}),$A(MO,{thickness:e/3,width:s,horizontalLength:o*.8,verticalLength:n/2,position:{x:i/2,y:o/2,z:-n*1.2},rotation:Math.PI}),$A(MO,{thickness:e/3,width:s,horizontalLength:o*.8,verticalLength:n/2,position:{x:i/2+e/3.6,y:-o/2,z:-n*1.2}})]})},MO=t=>{const{thickness:A,width:e,horizontalLength:i,verticalLength:o,rotation:n=0,position:s}=t,r=[[0,i],[-o/3,i/3],[-o/5,i/4],[0,0]],a=hBA(r,A);return $A(fs,{color:"#f2f2f2",children:$A(Wi,{offset:{x:s?.x||0,y:s?.y||0,z:s?.z||0},children:$A(BQ,{rotation:[0,55,n],children:$A(GU,{height:e,children:$A(kU,{points:a.map(g=>[g.y,g.x])})})})})})},oQt=({pinCount:t,leadLength:A,leadWidth:e,pitch:i,bodyWidth:o})=>{const n=Math.ceil(t/2),s=(n-1)*i/2,r=.25,a=1,g=.8,I=A*0,c=i*(n-1)+e+.2,B=o*.55;return Ot(Ho,{children:[Array.from({length:n}).map((C,l)=>$A(Ko,{position:{x:-o/2-I,y:l*i-s,z:r/2},width:e,thickness:r,padContactLength:A/2,bodyDistance:A+.3,height:g})),Array.from({length:n}).map((C,l)=>$A(Ko,{rotation:Math.PI,position:{x:o/2+I,y:l*i-s,z:r/2},width:e,thickness:r,padContactLength:A/2,bodyDistance:A+.3,height:g})),$A(WB,{center:{x:0,y:0,z:r/2},width:B,length:c,height:a})]})},nQt=({pinCount:t,pitch:A,leadWidth:e,leadLength:i,bodyWidth:o,bodyLength:n})=>{const s=t===8?{pitch:.65,leadWidth:.3}:{pitch:.5,leadWidth:.225},r=isNaN(parseFloat(A))?s.pitch:parseFloat(A),a=isNaN(parseFloat(e))?s.leadWidth:parseFloat(e)*.8,g=isNaN(parseFloat(o))?2.6:parseFloat(o)*.8,I=isNaN(parseFloat(n))?2+Number(r)*1.4:parseFloat(n),c=t/2,B=(c-1)*r/2,C=.15,l=.8,Q=4.5,E=(Q-g)/2,h=E*.5;return Ot(Ho,{children:[Array.from({length:c}).map((u,d)=>$A(Ko,{position:{x:-Q/2,y:B-d*r,z:C/2},width:a,thickness:C,padContactLength:h+.05,bodyDistance:E+.1,height:l})),Array.from({length:c}).map((u,d)=>$A(Ko,{rotation:Math.PI,position:{x:Q/2,y:B-d*r,z:C/2},width:a,thickness:C,padContactLength:h+.05,bodyDistance:E+.1,height:l})),$A(WB,{center:{x:0,y:0,z:C/2},width:g,length:I,height:1})]})},sQt=()=>Ot(Ho,{children:[$A(ht,{color:"#ccc",size:[.5,.6,.12],center:[-.725,0,.12/2]}),$A(ht,{color:"#ccc",size:[.5,.6,.12],center:[.725,0,.12/2]}),$A(fs,{color:"#222",children:Ot(sE,{children:[$A(Wi,{z:.3/2,children:$A(ht,{size:[1.65,.8,.3]})}),Ot(nI,{children:[$A(Wi,{z:.3,children:$A(ht,{size:[1.65,.8,.01]})}),$A(Wi,{z:.6,children:$A(ht,{size:[1.65-.2,.8-.2,.01]})})]})]})})]}),rQt=()=>Ot(Ho,{children:[$A(ht,{color:"#ccc",size:[.26,.51,.12],center:[-.325,0,.12/2]}),$A(ht,{color:"#ccc",size:[.26,.51,.12],center:[.325,0,.12/2]}),$A(fs,{color:"#222",children:$A(Wi,{z:.47/2+.02,children:$A(ht,{size:[.98,.58,.47]})})}),$A(ht,{color:"#ccc",size:[.98+.001,.26/2,.26/4],center:[0,.26/2,.47/4]}),$A(ht,{color:"#ccc",size:[.98+.001,.26/2,.26/4],center:[0,-.26/2,.47/4]}),$A(ht,{color:"#ccc",size:[.26/1.5,.58+.001,.26/4],center:[.65/2,0,.47/4]}),$A(ht,{color:"#ccc",size:[.26/1.5,.58+.001,.26/4],center:[-.65/2,0,.47/4]})]}),aQt=()=>{const g=$A(fs,{color:"#1a1a1a",children:Ot(sE,{children:[Ot(nI,{children:[$A(Wi,{z:.13,children:$A(ht,{size:[4,3,.03]})}),$A(Wi,{z:1.15,children:$A(ht,{size:[4.4,3.4,.01]})})]}),Ot(nI,{children:[$A(Wi,{z:1.15,children:$A(ht,{size:[4.4,3.4,.01]})}),$A(Wi,{z:2.3,children:$A(ht,{size:[4,3,.01]})})]})]})}),I=({xDir:c})=>{const l=c*1.78,Q=c*(3.4/2-.2/2+1),E=c*(3.4/2-.2/2),h=Math.abs(E-Q),u=(Q+E)/2;return $A(fs,{color:"#c0c0c0",children:Ot(sE,{children:[$A(ht,{size:[2.3*.8,1.45,.2],center:[l,0,.2/2]}),$A(ht,{size:[.2,1.45,1.14],center:[Q,0,1.14/2+.2]}),$A(ht,{size:[h,1.45,.2],center:[u,0,.2/2+1.14]})]})})};return Ot(Ho,{children:[$A(I,{xDir:1}),$A(I,{xDir:-1}),g]})},gQt=()=>{const g=$A(fs,{color:"#1a1a1a",children:Ot(sE,{children:[Ot(nI,{children:[$A(Wi,{z:.13,children:$A(ht,{size:[4,3,.03]})}),$A(Wi,{z:1.15,children:$A(ht,{size:[4.4,3.4,.01]})})]}),Ot(nI,{children:[$A(Wi,{z:1.15,children:$A(ht,{size:[4.4,3.4,.01]})}),$A(Wi,{z:2.3,children:$A(ht,{size:[4,3,.01]})})]})]})}),I=({xDir:c})=>{const l=c*1.78,Q=c*(3.4/2-.2/2+1),E=c*(3.4/2-.2/2),h=Math.abs(E-Q),u=(Q+E)/2;return $A(fs,{color:"#c0c0c0",children:Ot(sE,{children:[$A(ht,{size:[2.3*.8,1.45,.2],center:[l,0,.2/2]}),$A(ht,{size:[.2,1.45,1.14],center:[Q,0,1.14/2+.2]}),$A(ht,{size:[h,1.45,.2],center:[u,0,.2/2+1.14]})]})})};return Ot(Ho,{children:[$A(I,{xDir:1}),$A(I,{xDir:-1}),g]})},IQt=()=>{const g=$A(fs,{color:"#1a1a1a",children:Ot(sE,{children:[Ot(nI,{children:[$A(Wi,{z:.21000000000000002,children:$A(ht,{size:[6.3999999999999995,5.6,.03]})}),$A(Wi,{z:1.15,children:$A(ht,{size:[6.8,6,.01]})})]}),Ot(nI,{children:[$A(Wi,{z:1.15,children:$A(ht,{size:[6.8,6,.01]})}),$A(Wi,{z:2.3,children:$A(ht,{size:[6.3999999999999995,5.6,.01]})})]})]})}),I=({xDir:c})=>{const l=c*3.08,Q=c*(6/2-.2/2+1),E=c*(6/2-.2/2),h=Math.abs(E-Q),u=(Q+E)/2;return $A(fs,{color:"#c0c0c0",children:Ot(sE,{children:[$A(ht,{size:[2.3*.8,2.95,.2],center:[l,0,.2/2]}),$A(ht,{size:[.2,2.95,1.14],center:[Q,0,1.14/2+.2]}),$A(ht,{size:[h,2.95,.2],center:[u,0,.2/2+1.14]})]})})};return Ot(Ho,{children:[$A(I,{xDir:1}),$A(I,{xDir:-1}),g]})},cQt=()=>{const c=$A(fs,{color:"#222",children:Ot(sE,{children:[$A(Wi,{z:.27,children:$A(ht,{size:[2.9,1.9,.54]})}),Ot(nI,{children:[$A(Wi,{z:.54,children:$A(ht,{size:[2.9,1.9,.01]})}),$A(Wi,{z:1.08,children:$A(ht,{size:[2.6999999999999997,1.7,.01]})})]})]})});return Ot(Ho,{children:[$A(ht,{color:"#ccc",size:[1,1.2,.25],center:[-1.3,0,.25/2]}),$A(ht,{color:"#ccc",size:[1,1.2,.25],center:[1.3,0,.25/2]}),c]})},BQt=()=>Ot(Ho,{children:[$A(ht,{color:"#ccc",size:[1,.6,.12],center:[-1.3,0,.12/2]}),$A(ht,{color:"#ccc",size:[1,.6,.12],center:[1.3,0,.12/2]}),$A(fs,{color:"#222",children:Ot(sE,{children:[$A(Wi,{z:.55/2,children:$A(ht,{size:[2.7,1.6,.55]})}),Ot(nI,{children:[$A(Wi,{z:.55,children:$A(ht,{size:[2.7,1.6,.01]})}),$A(Wi,{z:1.1,children:$A(ht,{size:[2.7-.2,1.6-.2,.01]})})]})]})})]}),CQt=()=>Ot(Ho,{children:[$A(ht,{color:"#ccc",size:[1,.9,.2],center:[-1.3,0,.2/2]}),$A(ht,{color:"#ccc",size:[1,.9,.2],center:[1.3,0,.2/2]}),$A(fs,{color:"#222",children:Ot(sE,{children:[$A(Wi,{z:.2/2,children:$A(ht,{size:[2.75,1.8,.2]})}),Ot(nI,{children:[$A(Wi,{z:.2,children:$A(ht,{size:[2.75,1.8,.01]})}),$A(Wi,{z:1,children:$A(ht,{size:[2.75-.4,1.8-.4,.01]})})]})]})}),$A(ht,{color:"#777",size:[.2,1.8-.4,.01],center:[-1.3+.4,0,1]})]}),lQt=()=>Ot(Ho,{children:[$A(ht,{color:"#ccc",size:[.9,.9,.2],center:[-1.225,0,.2/2]}),$A(ht,{color:"#ccc",size:[.9,.9,.2],center:[1.225,0,.2/2]}),$A(fs,{color:"#222",children:Ot(sE,{children:[Ot(nI,{children:[$A(Wi,{z:.2,children:$A(ht,{size:[2.6-.1/2,1.7-.1/2,.01]})}),$A(Wi,{z:.01,children:$A(ht,{size:[2.6-.1,1.7-.1,.01]})})]}),Ot(nI,{children:[$A(Wi,{z:.2,children:$A(ht,{size:[2.6,1.7,.01]})}),$A(Wi,{z:1,children:$A(ht,{size:[2.6-.4,1.7-.4,.01]})})]})]})}),$A(ht,{color:"#777",size:[.2*2.7,1.7-.4,.02],center:[-1.225+.4,0,1]})]}),QQt=()=>Ot(Ho,{children:[$A(ht,{color:"#ccc",size:[.9,1.75,.2],center:[-1.825,0,.2/2]}),$A(ht,{color:"#ccc",size:[.9,1.75,.2],center:[1.825,0,.2/2]}),$A(fs,{color:"#222",children:Ot(sE,{children:[Ot(nI,{children:[$A(Wi,{z:.2,children:$A(ht,{size:[3.8-.05/2,2.5-.05/2,.01]})}),$A(Wi,{z:.01,children:$A(ht,{size:[3.8-.05,2.5-.05,.01]})})]}),Ot(nI,{children:[$A(Wi,{z:.2,children:$A(ht,{size:[3.8,2.5,.01]})}),$A(Wi,{z:1,children:$A(ht,{size:[3.8-.4,2.5-.4,.01]})})]})]})}),$A(ht,{color:"#777",size:[.2*2.7,2.5-.4,.02],center:[-1.825+.4,0,1]})]}),EQt=()=>Ot(Ho,{children:[$A(ht,{color:"#ccc",size:[.4,.25,.14],center:[-.4,0,.14/2]}),$A(ht,{color:"#ccc",size:[.4,.25,.14],center:[.4,0,.14/2]}),$A(fs,{color:"#222",children:Ot(sE,{children:[$A(Wi,{z:.14/2,children:$A(ht,{size:[.8,.6,.14]})}),Ot(nI,{children:[$A(Wi,{z:.14,children:$A(ht,{size:[.8,.6,.01]})}),$A(Wi,{z:.37,children:$A(ht,{size:[.8-.1,.6-.1,.01]})})]})]})})]}),hQt=()=>{const I=3.0999999999999996;return Ot(Ho,{children:[$A(Ko,{rotation:Math.PI,position:{x:6.6/2+I/4,y:0,z:.25/2},width:3,thickness:.25,padContactLength:.5,bodyDistance:I,height:.75}),$A(Ko,{position:{x:-6.6/2-I/4,y:0,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:I,height:.75}),$A(Ko,{position:{x:-6.6/2-I/4,y:-2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:I,height:.75}),$A(Ko,{position:{x:-6.6/2-I/4,y:2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:I,height:.75}),$A(WB,{center:{x:0,y:0,z:0},width:3.5,length:6.5,height:1.7,includeNotch:!1,taperRatio:.06,straightHeightRatio:.45})]})},uQt=()=>Ot(Ho,{children:[Array.from({length:16}).map((C,l)=>$A(Ko,{position:{x:-10.5/2,y:l*.5-3.75,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Array.from({length:16}).map((C,l)=>$A(Ko,{rotation:Math.PI,position:{x:10.5/2,y:l*.5-3.75,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Array.from({length:16}).map((C,l)=>$A(Ko,{rotation:Math.PI/2,position:{x:l*.5-3.75,y:-10.5/2,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Array.from({length:16}).map((C,l)=>$A(Ko,{rotation:-Math.PI/2,position:{x:l*.5-3.75,y:10.5/2,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),$A(WB,{center:{x:0,y:0,z:0},width:9,length:9,height:1.2,chamferSize:.7,taperRatio:.05,notchPosition:{x:-3.5,y:3.5,z:1.2},notchRadius:1.2/2})]}),dQt=uQt,pQt=()=>{const g=.7999999999999998;return Ot(Ho,{children:[$A(Ko,{rotation:Math.PI,position:{x:2.05/2+g/4,y:0,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:g,height:.65}),$A(Ko,{position:{x:-2.05/2-g/4,y:-.65,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:g,height:.65}),$A(Ko,{position:{x:-2.05/2-g/4,y:.65,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:g,height:.65}),$A(WB,{center:{x:0,y:0,z:0},width:1.25,length:2,height:.9,includeNotch:!1,taperRatio:.06,straightHeightRatio:.7,heightAboveSurface:.05})]})},fQt=({pinCount:t,pitch:A,leadWidth:e,padContactLength:i,bodyWidth:o})=>{const n=t/4;if(n!==Math.floor(n))throw new Error(`LQFP pinCount must be divisible by 4, got ${t}`);A||(A=.5),i||(i=.6),e||(e=.22),o||(o=A*(n+4));const s=o,r=(n-1)*A/2,a=s+3.3*i,g=a,I=.8,c=.2,B=(g-o)/2+.4;return Ot(Ho,{children:[Array.from({length:n}).map((C,l)=>$A(Ko,{position:{x:-g/2-.36,y:l*A-r,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:n}).map((C,l)=>$A(Ko,{rotation:Math.PI,position:{x:g/2+.36,y:l*A-r,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:n}).map((C,l)=>$A(Ko,{rotation:Math.PI/2,position:{x:l*A-r,y:-a/2-.36,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:n}).map((C,l)=>$A(Ko,{rotation:-Math.PI/2,position:{x:l*A-r,y:a/2+.36,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),$A(WB,{center:{x:0,y:0,z:0},width:o,length:s,height:1.5,heightAboveSurface:.1,taperRatio:.04,chamferSize:.7,notchPosition:{x:-(s/2-1.5),y:s/2-1.5,z:1.5},notchRadius:1.5/2})]})},yQt=()=>{const i=.20900000000000002,o=.1,n=.3,s=.1,r=.2;return Ot(Ho,{children:[$A(fs,{color:"#222",children:Ot(sE,{children:[$A(ht,{size:[.85,1.2,i],center:[0,0,i/2]}),Ot(nI,{children:[$A(Wi,{z:i,children:$A(ht,{size:[.85,1.2,.01]})}),$A(Wi,{z:.38,children:$A(ht,{size:[.85-o,1.2-o,.01]})})]})]})}),$A(ht,{color:"#ccc",size:[n,.25,s],center:[.55,0,s/2]}),$A(ht,{color:"#ccc",size:[n,r,s],center:[-.55,.4,s/2]}),$A(ht,{color:"#ccc",size:[n,r,s],center:[-.55,-.4,s/2]})]})},wQt=({num_pins:t,bodyWidth:A=5.3,bodyLength:e=5.3,bodyThickness:i=1,thermalPadSize:o,padWidth:n=e/5.3*.6,padLength:s=e/5.3*1,pitch:r=.5,thermalPadThickness:a=.2})=>{const g=[],I=Math.floor(t/2),c=r*(I-1);for(let B=0;B<t;B++){const C=B<I?"left":"right",l=B%I,Q=c/2-l*r,E=s,h=n,u=C==="left"?-A/2+E/2:A/2-E/2,d=B+1;g.push({pinNumber:d,x:u,y:Q,padSizeX:E,padSizeY:h})}return Ot(Ho,{children:[$A(WB,{center:{x:0,y:0,z:0},width:A,length:e,height:i,heightAboveSurface:0,color:"grey",chamferSize:.2,taperRatio:0,notchPosition:{x:-(A/2-s),y:e/2-s,z:i}}),g.map((B,C)=>$A(ht,{center:[B.x,B.y,a/2],size:[B.padSizeX,B.padSizeY,a]})),o?.length!==void 0&&o?.width!==void 0&&$A(ht,{center:[0,0,a/2],size:[o.width,o.length,a]})]})},mQt=({bodyLength:t=10.2,bodyWidth:A=4.65,bodyHeight:e=13.46,leadSpacing:i=5,leadDiameter:o=.8,leadLength:n=12.7,color:s="#ddd",leadColor:r="#b87333"})=>{const a=t/2,g=A/2,I=a-g,c=i/2,B=.85;return Ot(Ho,{children:[Ot(fs,{color:s,children:[Ot(nI,{children:[$A(Lp,{height:e,roundRadius:.5,radius:g,center:[-I,0,e]}),$A(Lp,{height:e,roundRadius:.5,radius:g,center:[I,0,e]})]}),Ot(nI,{children:[$A(Lp,{height:B,roundRadius:.1,radius:g+.85,center:[-I,0,e/2+B/2]}),$A(Lp,{height:B,roundRadius:.1,radius:g+.85,center:[I,0,e/2+B/2]})]})]}),Ot(fs,{color:r,children:[$A(Up,{height:n+e/2,radius:o/2,center:[-c+.06,0,-(n/2)+e/2]}),$A(Up,{height:n+e/2,radius:o/2,center:[c-.06,0,-(n/2)+e/2]})]})]})},DQt=({bodyLength:t=1.4,bodyDiameter:A=1.1,color:e="#3a3a3aff",contactColor:i="#c6c6c6",cathodeIdentification:o="#111"})=>Ot(Ho,{children:[$A(fs,{color:e,children:Ot(BQ,{rotation:[0,"90deg",0],children:[$A(xU,{size:[A,A,t-.2],roundRadius:.2,center:[-A/2,0,.05]}),$A(Up,{height:.2/2,radius:A/2-.2,center:[-A/2,0,-t/2+.2/2]})]})}),$A(fs,{color:o,children:$A(BQ,{rotation:[0,"90deg",0],children:$A(xU,{size:[A*1.01,A*1.01,t/3],roundRadius:.2,center:[-A/2,0,-t/4+.1]})})}),$A(fs,{color:i,children:$A(BQ,{rotation:[0,"90deg",0],children:$A(Lp,{height:.2,radius:A/2,roundRadius:.2/3,center:[-A/2,0,-t/2]})})}),$A(fs,{color:i,children:$A(BQ,{rotation:[0,"90deg",0],children:$A(Lp,{height:.2,radius:A/2,roundRadius:.2/3,center:[-A/2,0,t/2]})})})]}),SQt=({bodyLength:t=3.5,bodyDiameter:A=1.5,color:e="#3a3a3aff",contactColor:i="#c6c6c6"})=>Ot(Ho,{children:[$A(fs,{color:e,children:$A(BQ,{rotation:[0,"90deg",0],children:$A(Lp,{height:t,radius:A/2,roundRadius:.3,center:[-A/2,0,0]})})}),$A(fs,{color:i,children:$A(BQ,{rotation:[0,"90deg",0],children:$A(Lp,{height:.5,radius:A/2,roundRadius:.2,center:[-A/2,0,-t/2]})})}),$A(fs,{color:i,children:$A(BQ,{rotation:[0,"90deg",0],children:$A(Lp,{height:.5,radius:A/2,roundRadius:.2,center:[-A/2,0,t/2]})})})]}),bQt=({bodyLength:t=3.9,bodyDiameter:A=2.5,color:e="#3a3a3aff",contactColor:i="#c6c6c6"})=>Ot(Ho,{children:[$A(fs,{color:e,children:$A(BQ,{rotation:[0,"90deg",0],children:$A(Lp,{height:t,radius:A/2,roundRadius:.3,center:[-A/2,0,0]})})}),$A(fs,{color:i,children:$A(BQ,{rotation:[0,"90deg",0],children:$A(Lp,{height:.55,radius:A/2,roundRadius:.2,center:[-A/2,0,-t/2]})})}),$A(fs,{color:i,children:$A(BQ,{rotation:[0,"90deg",0],children:$A(Lp,{height:.55,radius:A/2,roundRadius:.2,center:[-A/2,0,t/2]})})})]}),xQt=({pinCount:t,padContactLength:A=.6,leadWidth:e=.41,pitch:i=1.27})=>{if(t%2!==0)throw new Error("MS012 pinCount must be even");const o=t/2,n=4.9,s=3.9,r=(o-1)*i/2,a=.2;return Ot(Ho,{children:[Array.from({length:o}).map((g,I)=>$A(Ko,{position:{x:-s/2-A-.3,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),Array.from({length:o}).map((g,I)=>$A(Ko,{rotation:Math.PI,position:{x:s/2+A+.3,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),$A(WB,{center:{x:0,y:0,z:a/2},width:s,length:n,height:1.55,notchPosition:{x:-.95,y:n/2-1,z:1.55},heightAboveSurface:.17,taperRatio:.09})]})},kQt=({pinCount:t=16,padContactLength:A=.6,leadWidth:e=.41,pitch:i=1.27})=>{if(t!==16)throw new Error("MS013 only supports 16 pins");const o=t/2,n=7.5,s=10.3,r=(o-1)*i/2,a=.2;return Ot(Ho,{children:[Array.from({length:o}).map((g,I)=>$A(Ko,{position:{x:-n/2-A-.3,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),Array.from({length:o}).map((g,I)=>$A(Ko,{rotation:Math.PI,position:{x:n/2+A+.3,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),$A(WB,{center:{x:0,y:0,z:a/2},width:n,length:s,height:1.1,notchPosition:{x:-2.25,y:s/2-1.5,z:1.1},heightAboveSurface:.17,taperRatio:.05})]})},GQt=()=>{const Q=7.050000000000001,E=24.95+6.5/2;return $A(Wi,{center:[0,0,1],children:Ot(Ho,{children:[Ot(BQ,{rotation:[0,55,-55],children:[Ot(UG,{children:[$A(ht,{color:"#ccc",size:[6.5+.1,9.9,1.3],center:[E,0,1.3-2]}),$A(Up,{color:"black",center:[E,0,1.3-2],radius:3/2,height:1.3*1.2})]}),$A(fs,{color:"#222",children:$A(WB,{width:9.9,length:9.9,height:4.5,center:{x:20,y:0,z:-2.4},includeNotch:!1,straightHeightRatio:.3,taperRatio:.04,heightAboveSurface:1})})]}),$A(BQ,{rotation:[0,55,55],children:Array.from({length:3}).map((h,u)=>{const d=Q,f=(u-1)*2.7,D=-.5-.6;return Ot(fs,{color:"gold",children:[Ot(nI,{children:[$A(Wi,{center:[15.05-4.5/2+.1,f,D],children:$A(ht,{size:[4.5,.81+1,.5]})}),$A(Wi,{center:[15.05-4.5/2-1+.1,f,D],children:$A(ht,{size:[4.5,.81,.5]})})]}),$A(Wi,{center:[d,f,D],children:$A(ht,{size:[16+.1,.81,.5]})})]},`prong-${u}`)})})]})})},FQt=()=>{const g=1.1999999999999997;return Ot(Ho,{children:[$A(Ko,{rotation:Math.PI,position:{x:2.8/2+g/4,y:-.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),$A(Ko,{rotation:Math.PI,position:{x:2.8/2+g/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),$A(Ko,{rotation:Math.PI,position:{x:2.8/2+g/4,y:.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),$A(Ko,{position:{x:-2.8/2-g/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),$A(Ko,{position:{x:-2.8/2-g/4,y:-.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),$A(Ko,{position:{x:-2.8/2-g/4,y:.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),$A(WB,{center:{x:0,y:0,z:0},width:1.6,length:2.9,height:1.2,straightHeightRatio:.6,notchPosition:{x:-.4,y:1.2/2+.4,z:1.2+.05},notchRadius:.1})]})},RQt=()=>Ot(Ho,{children:[$A(WB,{center:{x:0,y:0,z:0},width:.8,length:1,height:.37,heightAboveSurface:0,color:"#1a1a1a",taperRatio:.15,straightHeightRatio:0,notchPosition:{x:-.8/4,y:.7/2.2,z:.37+.1}}),[0,1,2].map(g=>{const I=-.35+g*.35;return $A(ht,{center:[-.8/2+.19/2-.1,I,.12/2],size:[.19,.15,.12]})}),[0,1,2].map(g=>{const I=-.35+g*.35;return $A(ht,{center:[.8/2-.19/2+.1,I,.12/2],size:[.19,.15,.12]})})]}),NQt=()=>{const s="#222",a=[.43,.4,1.32],g=[.43,.4,.25],I=[0,0,-.66],c=[0,0,-1.32],B=[0,1.28,-2.72],C=[0,1.28,-8.9],l=-7.5;return Ot(Wi,{center:[0,1,10.5],children:[$A(fs,{color:s,children:Ot(UG,{children:[$A(Wi,{center:[0,0,2.25],children:$A(Up,{radius:2.4,height:4.5})}),$A(Wi,{center:[0,-1.8499999999999999,2.25],children:$A(ht,{size:[2.4*2,1.1,4.5+.2]})})]})}),$A(Wi,{center:I,children:$A(ht,{size:a})}),Ot(nI,{children:[$A(Wi,{center:c,children:$A(ht,{size:g})}),$A(Wi,{center:B,children:$A(ht,{size:g})})]}),$A(Wi,{center:C,children:$A(ht,{size:[.43,.4,12.2]})}),$A(Wi,{center:[1.3,0,l],children:$A(ht,{size:[.43,.4,15]})}),$A(Wi,{center:[-1.3,0,l],children:$A(ht,{size:[.43,.4,15]})})]})},MQt=()=>Ot(Ho,{children:[$A(Ko,{rotation:Math.PI,position:{x:2/2+.75/4,y:-.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),$A(Ko,{rotation:Math.PI,position:{x:2/2+.75/4,y:0,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),$A(Ko,{rotation:Math.PI,position:{x:2/2+.75/4,y:.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),$A(Ko,{position:{x:-2/2-.75/4,y:0,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),$A(Ko,{position:{x:-2/2-.75/4,y:-.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),$A(Ko,{position:{x:-2/2-.75/4,y:.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),$A(WB,{center:{x:0,y:0,z:0},width:1.25,length:2,height:1.1,straightHeightRatio:.6,notchPosition:{x:-.375,y:1.1/2+.2,z:1.1},heightAboveSurface:.1})]}),_Qt=MQt,vQt=()=>Ot(Ho,{children:[$A(WB,{center:{x:0,y:0,z:.05},width:1,length:1.45,height:.5,heightAboveSurface:0,color:"#1a1a1a",taperRatio:0,includeNotch:!1}),[0,1,2].map(r=>{const a=-.5+r*.5;return $A(ht,{center:[-1/2+.3/2,a,.05/2],size:[.3,.2,.05]})}),[0,1,2].map(r=>{const a=-.5+r*.5;return $A(ht,{center:[1/2-.3/2,a,.05/2],size:[.3,.2,.05]})})]}),UQt=()=>Ot(Ho,{children:[$A(Ko,{position:{x:-2.5/2,y:0,z:.175/2},width:.3,thickness:.175,padContactLength:.3,bodyDistance:.45,height:.7}),$A(Ko,{rotation:Math.PI,position:{x:2.5/2,y:0,z:.175/2},width:.3,thickness:.175,padContactLength:.3,bodyDistance:.45,height:.7}),$A(fs,{color:"#222",children:$A(WB,{center:{x:0,y:0,z:0},width:1.7,length:1.25,height:.95,includeNotch:!1,taperRatio:.06,straightHeightRatio:.7,heightAboveSurface:.05})}),$A(ht,{color:"#777",size:[1.7/3,1.25-.075,.02],center:[-.85*2/3+.035,0,.95+.05]})]}),LQt=()=>Ot(Ho,{children:[$A(ht,{color:"#ccc",size:[.4,.325,.175],center:[-1.05,0,.175/2]}),$A(ht,{color:"#ccc",size:[.4,.325,.175],center:[1.05,0,.175/2]}),$A(fs,{color:"#222",children:Ot(sE,{children:[$A(Wi,{z:.175/2,children:$A(ht,{size:[1.7,1.25,.175]})}),Ot(nI,{children:[$A(Wi,{z:.175,children:$A(ht,{size:[1.7,1.25,.01]})}),$A(Wi,{z:.725,children:$A(ht,{size:[1.7-.2,1.25-.2,.01]})})]})]})}),$A(ht,{color:"#777",size:[1.7/3,1.25-.2,.02],center:[-1.05+1.7/4.4+.2,0,.725]})]}),HQt=()=>{const s=-1.0474999999999999,r=1.775/2+.4/2-.04;return Ot(Ho,{children:[$A(ht,{color:"#ccc",size:[.4,.325,.13],center:[s,0,.13/2]}),$A(ht,{color:"#ccc",size:[.4,.325,.13],center:[r,0,.13/2]}),$A(fs,{color:"#222",children:$A(WB,{width:1.775,length:1.25,height:.725,center:{x:0,y:0,z:0},heightAboveSurface:0,straightHeightRatio:.7,taperRatio:.06,includeNotch:!1})}),$A(ht,{color:"#777",size:[1.775/3,1.25-.05,.02],center:[s+1.775/4.4+.2,0,.725]})]})},YQt=({footprint:t})=>{const A=Slt.string(t).json();switch(A.fn){case"dip":return $A(Flt,{numPins:A.num_pins,pitch:A.p,bodyWidth:A.w});case"tssop":return $A(Nlt,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"msop":return $A(Mlt,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"vssop":return $A(nQt,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w,bodyLength:A.h});case"qfp":return $A(Llt,{pinCount:A.num_pins,pitch:A.p,leadWidth:A.pw,padContactLength:A.pl,bodyWidth:A.w});case"tqfp":return $A(dQt,{});case"lqfp":return $A(fQt,{pinCount:A.num_pins});case"qfn":{const o=typeof A.thermalpad?.x=="number"&&typeof A.thermalpad?.y=="number";return $A(Olt,{num_pins:A.num_pins,bodyWidth:A.w,bodyLength:A.h,pitch:A.p,padLength:A.pl,padWidth:A.pw,thermalPadSize:o?{width:A.thermalpad.x,length:A.thermalpad.y}:void 0})}case"dfn":{const o=typeof A.thermalpad?.x=="number"&&typeof A.thermalpad?.y=="number";return $A(wQt,{num_pins:A.num_pins,bodyWidth:A.w,bodyLength:A.h,pitch:A.p,padLength:A.pl,padWidth:A.pw,thermalPadSize:o?{width:A.thermalpad.x,length:A.thermalpad.y}:void 0})}case"pinrow":{const o=t.match(/_rows(\d+)/),n=o&&o[1]?parseInt(o[1],10):1;if(A.male)return $A(Klt,{numberOfPins:A.num_pins,pitch:A.p,invert:A.invert,faceup:A.faceup,rows:n});if(A.female)return $A(tQt,{numberOfPins:A.num_pins,pitch:A.p,rows:n})}case"cap":switch(A.imperial){case"0402":return $A(FWA,{color:"#856c4d"});case"0603":return $A(RWA,{color:"#856c4d"});case"0805":return $A(NWA,{color:"#856c4d"});case"0201":return $A(MWA,{color:"#856c4d"});case"01005":return $A(_WA,{color:"#856c4d"});case"1206":return $A(vWA,{color:"#856c4d"});case"1210":return $A(UWA,{color:"#856c4d"});case"2010":return $A(LWA,{color:"#856c4d"});case"2512":return $A(HWA,{color:"#856c4d"})}case"sot235":return $A(Zlt,{});case"sot457":return $A(FQt,{});case"sot223":return $A(hQt,{});case"sot23w":return $A(Vlt,{});case"sot323":return $A(pQt,{});case"sod323f":return $A(LQt,{});case"sod323fl":return $A(HQt,{});case"sot363":return $A(_Qt,{});case"sot886":return $A(vQt,{});case"sot963":return $A(RQt,{});case"pushbutton":return $A(iQt,{width:A.w,length:A.h,innerDiameter:A.id});case"soic":return $A(oQt,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"sod523":return $A(sQt,{});case"sod882":return $A(rQt,{});case"sma":return $A(aQt,{});case"smb":return $A(gQt,{});case"smc":return $A(IQt,{});case"smf":return $A(cQt,{});case"sod123f":return $A(BQt,{});case"sod123fl":return $A(CQt,{});case"sod123w":return $A(lQt,{});case"sod128":return $A(QQt,{});case"sod323":return $A(UQt,{});case"sod923":return $A(EQt,{});case"hc49":return $A(mQt,{});case"micromelf":return $A(DQt,{});case"minimelf":return $A(SQt,{});case"melf":return $A(bQt,{});case"ms012":return $A(xQt,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p});case"ms013":return $A(kQt,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p});case"sot723":return $A(yQt,{});case"to220":return $A(GQt,{});case"to92":return $A(NQt,{})}const e=t.match(/_color\(([^)]+)\)/),i=e?e[1]:void 0;switch(A.imperial){case"0402":return $A(FWA,{color:i});case"0603":return $A(RWA,{color:i});case"0805":return $A(NWA,{color:i});case"0201":return $A(MWA,{color:i});case"01005":return $A(_WA,{color:i});case"1206":return $A(vWA,{color:i});case"1210":return $A(UWA,{color:i});case"2010":return $A(LWA,{color:i});case"2512":return $A(HWA,{color:i})}return null},JQt=t=>t&&typeof t=="object"&&"type"in t,UM=t=>{if(typeof t=="number")return t;if(typeof t=="string"){const A=/^(-?\d+(?:\.\d+)?)\s*deg$/i.exec(t);if(A)return parseFloat(A[1])*Math.PI/180;const e=Number(t);if(!Number.isNaN(e))return e}return 0},KQt=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 um(t,A,e){const{jscad:{primitives:i,booleans:o,hulls:n,geometries:s,extrusions:r,transforms:a}}=e;if(t==null||t===!1)return[];if(Array.isArray(t))return t.flatMap(B=>um(B,A,e));if(!JQt(t))return[];const{type:g,props:I,children:c}=t;if(g===bWA)return(c??[]).flatMap(B=>um(B,A,e));if(g===fs){const B=I?.color;return(c??[]).flatMap(C=>um(C,B??A,e))}if(g===Wi){const B=KQt(I?.offset??I?.center??{x:I?.x,y:I?.y,z:I?.z});return(c??[]).flatMap(l=>um(l,A,e)).map(({geom:l,color:Q})=>({geom:a.translate(B,l),color:Q??A}))}if(g===BQ){const B=Array.isArray(I?.rotation)?[UM(I.rotation[0]),UM(I.rotation[1]),UM(I.rotation[2])]:[UM(I?.x??0),UM(I?.y??0),UM(I?.z??0)];return(c??[]).flatMap(l=>um(l,A,e)).map(({geom:l,color:Q})=>({geom:a.rotateZ(B[2],a.rotateY(B[1],a.rotateX(B[0],l))),color:Q}))}if(g===sE||g===UG||g===nI){const B=(c??[]).flatMap(l=>um(l,A,e)).map(l=>l.geom);if(B.length===0)return[];let C;return g===sE?C=o.union(B):g===UG?C=o.subtract(B[0],B.slice(1)):C=n.hull(B),[{geom:C,color:A}]}if(g===kU){const B=I?.points??[];return[{geom:s.geom2.fromPoints(B),color:A??I?.color}]}if(g===GU){const B=(c??[]).flatMap(E=>um(E,A,e)).map(E=>E.geom);if(B.length===0)return[];const C=B.length>1?o.union(B):B[0],l=I?.height??I?.h??1;let Q=r.extrudeLinear({height:l},C);if(Q.polygons)for(const E of Q.polygons)!E.plane||!E.vertices||E.vertices.length<3||E.vertices.reverse();return[{geom:Q,color:A??I?.color}]}if(g===ht||g===xWA||g===Up||g===kWA||g===xU||g===Lp){let B;if(g===ht){const C=I?.size??[1,1,1],l=I?.offset,Q=I?.center??(l?[l[0],l[1],l[2]]:[0,0,0]);B=i.cuboid({size:C,center:Q})}else if(g===xWA){const C=I?.size??1,l=I?.offset,Q=I?.center??(l?[l[0],l[1],l[2]]:[0,0,0]);B=i.cube({size:C,center:Q})}else if(g===Up){const C=I?.height??1,l=I?.radius??1,Q=I?.center??[0,0,0];B=i.cylinder({height:C,radius:l,center:Q})}else if(g===kWA){const C=I?.radius??1,l=I?.center??[0,0,0];B=i.sphere({radius:C,center:l})}else if(g===Lp){const C=I?.height??1,l=I?.radius??1,Q=I?.roundRadius??.1,E=I?.center??[0,0,0];B=i.roundedCylinder({height:C,radius:l,roundRadius:Q,center:E})}else{const C=I?.size??[1,1,1],l=I?.roundRadius??.1,Q=I?.center??[0,0,0];B=i.roundedCuboid({size:C,roundRadius:l,center:Q})}return[{geom:B,color:A??I?.color}]}if(typeof g=="function"){const B=g(I??{});return um(B,A,e)}return(c??[]).flatMap(B=>um(B,A,e))}function TQt(t,A){return{geometries:um(t,void 0,{jscad:A})}}function YWA(t){if(t.polygons){const A=[],e=[],i=[];let o=0;for(const s of t.polygons){for(const a of s.vertices)a.index=o,A.push(a[0],a[1],a[2]),t.color&&t.color.length>=3?i.push(t.color[0],t.color[1],t.color[2]):i.push(1,1,1),o++;const r=s.vertices[0].index;for(let a=2;a<s.vertices.length;a++){const g=s.vertices[a-1].index,I=s.vertices[a].index;e.push(r,g,I)}}const n=new Fg;if(n.setAttribute("position",new iI(new Float32Array(A),3)),n.setIndex(e),i.length>0&&n.setAttribute("color",new iI(new Float32Array(i),3)),t.transforms){const s=new As;s.fromArray(t.transforms),n.applyMatrix4(s)}return n.computeVertexNormals(),n}if(t.sides){const A=[],e=[];for(const o of t.sides)A.push(o[0][0],o[0][1],0),t.color&&t.color.length>=3?e.push(t.color[0],t.color[1],t.color[2]):e.push(1,1,1);const i=new Fg;if(i.setAttribute("position",new iI(new Float32Array(A),3)),e.length>0&&i.setAttribute("color",new iI(new Float32Array(e),3)),t.transforms){const o=new As;o.fromArray(t.transforms),i.applyMatrix4(o)}return i}return console.error("Invalid CSG object: neither polygons nor sides found"),new Fg}function qQt(t,A){const e=EBA(YQt,{footprint:t});return TQt(e,A)}var PQt=({jscadPlan:t,positionOffset:A,rotationOffset:e,onHover:i,onUnhover:o,isHovered:n,scale:s,isTranslucent:r=!1})=>{const{rootObject:a}=du(),{threeGeom:g,material:I}=AA.useMemo(()=>{const B=(0,drt.executeJscadOperations)(prt.default,t);if(!B||!B.polygons&&!B.sides)return{threeGeom:null,material:null};const C=YWA(B),l=new Qu({vertexColors:!0,side:_C,transparent:r,opacity:r?.5:1,depthWrite:!r});return{threeGeom:C,material:l}},[t,r]),c=AA.useMemo(()=>g?new $o(g,I):null,[g,I]);return AA.useEffect(()=>{if(!(!c||!a))return a.add(c),()=>{a.remove(c)}},[a,c]),AA.useEffect(()=>{c&&(A&&c.position.fromArray(A),e&&c.rotation.fromArray(e),s!==void 0&&c.scale.setScalar(s))},[c,A?.[0],A?.[1],A?.[2],e?.[0],e?.[1],e?.[2],s]),AA.useMemo(()=>{if(I)if(n){const B=new Li(I.color.getHex());I.emissive.copy(B),I.emissive.setRGB(0,0,1),I.emissiveIntensity=.2}else I.emissiveIntensity=0},[n,I]),g?V.jsx(DU,{isHovered:n,onHover:i,onUnhover:o,object:c}):null},OQt=fr(yO()),WQt=({positionOffset:t,footprint:A,rotationOffset:e,onHover:i,onUnhover:o,isHovered:n,scale:s,isTranslucent:r=!1})=>{const{rootObject:a}=du(),g=AA.useMemo(()=>{if(!A)return null;const{geometries:I}=qQt(A,OQt),c=new Lf;for(const B of I.flat(1/0)){const C=B.geom;if(!C||!C.polygons&&!C.sides)continue;const l=new Li(B.color);l.convertLinearToSRGB();const Q={...C,color:[l.r,l.g,l.b]},E=YWA(Q),h=new Qu({vertexColors:!0,side:_C,transparent:r,opacity:r?.5:1,depthWrite:!r}),u=new $o(E,h);c.add(u)}return c},[A,r]);return AA.useEffect(()=>{if(!(!g||!a))return a.add(g),()=>{a.remove(g)}},[a,g]),AA.useEffect(()=>{g&&(t&&g.position.fromArray(t),e&&g.rotation.fromArray(e),s!==void 0&&g.scale.setScalar(s))},[g,t?.[0],t?.[1],t?.[2],e?.[0],e?.[1],e?.[2],s]),AA.useEffect(()=>{g&&g.traverse(I=>{I instanceof $o&&I.material instanceof Qu&&(n?(I.material.emissive.setHex(255),I.material.emissiveIntensity=.2):I.material.emissiveIntensity=0)})},[n,g]),g?V.jsx(DU,{isHovered:n,onHover:i,onUnhover:o,object:g}):null},ZQt=(...t)=>t,HU={clickToInteractOverlay:100,htmlElements:95,orientationCube:95,contextMenu:90,appearanceMenu:91},JWA=({children:t,position:A,style:e})=>{const{camera:i,renderer:o}=du(),n=AA.useRef(document.createElement("div")),[s,r]=AA.useState(null);return AA.useEffect(()=>{const a=o?.domElement.parentNode;if(a)return a.style.position!=="relative"&&a.style.position!=="absolute"&&(a.style.position="relative"),a.appendChild(n.current),r(aJ.createPortal(t,n.current)),()=>{a.contains(n.current)&&a.removeChild(n.current)}},[o,t]),mU(()=>{if(!i||!n.current||!o)return;const a=new Re(...A);a.project(i);const g=o.domElement.getBoundingClientRect(),I=Math.round((a.x+1)/2*g.width),c=Math.round((-a.y+1)/2*g.height);n.current.style.position="absolute",n.current.style.left=`${I}px`,n.current.style.top=`${c}px`,n.current.style.pointerEvents="none",n.current.style.zIndex=HU.htmlElements.toString(),e&&Object.assign(n.current.style,e)},[i,o,A,e]),s},KWA={boardBody:!0,topCopper:!0,bottomCopper:!0,adhesive:!1,solderPaste:!1,topSilkscreen:!0,bottomSilkscreen:!0,topMask:!0,bottomMask:!0,throughHoleModels:!0,smtModels:!0,translucentModels:!0,modelsNotInPosFile:!1,modelsMarkedDNP:!1,modelBoundingBoxes:!1,threedAxis:!1,backgroundStart:!0,backgroundEnd:!0},TWA=AA.createContext(void 0),VQt=({children:t})=>{const[A,e]=AA.useState(KWA),i=AA.useCallback((s,r)=>{e(a=>({...a,[s]:r}))},[]),o=AA.useCallback(()=>{e(KWA)},[]),n=AA.useMemo(()=>({visibility:A,setLayerVisibility:i,resetToDefaults:o}),[A,i,o]);return V.jsx(TWA.Provider,{value:n,children:t})},LM=()=>{const t=AA.useContext(TWA);if(!t)throw new Error("useLayerVisibility must be used within a LayerVisibilityProvider");return t},qWA=({cad_component:t,circuitJson:A})=>{const[e,i]=AA.useState(!1),{visibility:o}=LM(),[n,s]=AA.useState(null),r=AA.useCallback(Q=>{Q?.mousePosition?(i(!0),s(Q.mousePosition)):(i(!1),s(null))},[]),a=AA.useCallback(()=>{i(!1),s(null)},[]),g=AA.useMemo(()=>yi(A).source_component.getUsing({source_component_id:t.source_component_id})?.name,[A,t.source_component_id]),I=AA.useMemo(()=>A.filter(E=>E.type==="pcb_plated_hole"&&E.pcb_component_id===t.pcb_component_id).length>0,[A,t.pcb_component_id]),c=t.model_obj_url??t.model_wrl_url??t.model_stl_url,B=t.model_glb_url??t.model_gltf_url,C=t.rotation?ZQt(t.rotation.x*Math.PI/180,t.rotation.y*Math.PI/180,t.rotation.z*Math.PI/180):void 0;let l=null;if(c?l=V.jsx(Qrt,{url:c,position:t.position?[t.position.x,t.position.y,t.position.z]:void 0,rotation:C,scale:t.model_unit_to_mm_scale_factor,onHover:r,onUnhover:a,isHovered:e,isTranslucent:t.show_as_translucent_model},t.cad_component_id):B?l=V.jsx(urt,{gltfUrl:B,position:t.position?[t.position.x,t.position.y,t.position.z]:void 0,rotation:C,scale:t.model_unit_to_mm_scale_factor,onHover:r,onUnhover:a,isHovered:e,isTranslucent:t.show_as_translucent_model},t.cad_component_id):t.model_jscad?l=V.jsx(PQt,{jscadPlan:t.model_jscad,rotationOffset:C,scale:t.model_unit_to_mm_scale_factor,onHover:r,onUnhover:a,isHovered:e,isTranslucent:t.show_as_translucent_model},t.cad_component_id):t.footprinter_string&&(l=V.jsx(WQt,{positionOffset:t.position?[t.position.x,t.position.y,t.position.z]:void 0,rotationOffset:C,footprint:t.footprinter_string,scale:t.model_unit_to_mm_scale_factor,onHover:r,onUnhover:a,isHovered:e,isTranslucent:t.show_as_translucent_model})),t.show_as_translucent_model){if(!o.translucentModels)return null}else if(I&&!o.throughHoleModels||!I&&!o.smtModels)return null;return V.jsxs(V.Fragment,{children:[l,e&&n?V.jsx(JWA,{position:n,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:g??"<unknown>"}):null]})},PWA={version:"0.0.480"};function jQt(t){t.querySelectorAll("canvas").forEach(A=>A.remove())}var zQt=t=>{t.outputColorSpace=Py,t.toneMapping=iDA,t.toneMappingExposure=1},OWA="cadViewerCameraStateSession",WWA=(t,A)=>{try{const e={position:t.position.toArray(),quaternion:t.quaternion.toArray(),up:t.up.toArray(),fov:t.fov??50,target:A.target.toArray()};sessionStorage.setItem(OWA,JSON.stringify(e))}catch(e){console.warn("Failed to save camera:",e)}},vBA=(t,A)=>{try{const e=sessionStorage.getItem(OWA);if(!e)return!1;const i=JSON.parse(e);if(t.position.fromArray(i.position),t.quaternion.fromArray(i.quaternion),t.up.fromArray(i.up),"fov"in t){const o=t;o.fov=i.fov,o.updateProjectionMatrix?.()}return A.target.fromArray(i.target),A.update(),t.updateMatrixWorld(),!0}catch(e){return console.warn("Failed to restore camera:",e),!1}},ZWA=AA.createContext(void 0),XQt=({children:t,defaultTarget:A,initialCameraPosition:e})=>{const i=AA.useRef(null),o=AA.useRef(null),[n,s]=AA.useState(null),[r,a]=AA.useState("perspective"),[g,I]=AA.useState(e??null),[c,B]=AA.useState(new xp(0,0,0)),C=AA.useMemo(()=>{const[h,u,d]=e??[5,-5,5],f=Math.hypot(h-A.x,u-A.y,d-A.z);return f>0?f:5},[e,A]),l=AA.useCallback(h=>{const u=[A.x,A.y,A.z],d=o.current,f=i.current;let D=C;switch(d&&f&&(D=d.position.distanceTo(f.target)),h){case"Top Center Angled":{const b=D/Math.sqrt(2);return{position:[A.x,A.y-b,A.z+b],target:u,up:[0,0,1]}}case"Top Down":return{position:[A.x,A.y,A.z+D],target:u,up:[0,0,1]};case"Top Left Corner":return{position:[A.x-D*.6,A.y-D*.6,A.z+D*.6],target:u,up:[0,0,1]};case"Top Right Corner":return{position:[A.x+D*.6,A.y-D*.6,A.z+D*.6],target:u,up:[0,0,1]};case"Left Sideview":return{position:[A.x-D,A.y,A.z],target:u,up:[0,0,1]};case"Right Sideview":return{position:[A.x+D,A.y,A.z],target:u,up:[0,0,1]};case"Front":return{position:[A.x,A.y-D,A.z],target:u,up:[0,0,1]};default:return null}},[C,A,o,i]),Q=AA.useCallback(h=>{i.current=h},[]),E=AA.useMemo(()=>({controlsRef:i,mainCameraRef:o,defaultTarget:A,baseDistance:C,controller:n,setController:s,getPresetConfig:l,handleControlsChange:Q,cameraType:r,setCameraType:a,cameraPosition:g,setCameraPosition:I,cameraRotation:c,setCameraRotation:B,saveCameraToSession:WWA,loadCameraFromSession:vBA}),[A,C,n,l,Q,r,g,c]);return V.jsx(ZWA.Provider,{value:E,children:t})},Ex=()=>{const t=AA.useContext(ZWA);if(!t)throw new Error("useCameraController must be used within a CameraControllerProvider");return t},$Qt=AA.forwardRef(({children:t,scene:A,camera:e,style:i,onCreated:o},n)=>{const{cameraType:s}=Ex(),r=AA.useRef(null),[a,g]=AA.useState(null),I=AA.useRef([]),c=AA.useRef(void 0);c.current=o;const B=AA.useRef(null),C=AA.useCallback(h=>{I.current.push(h)},[]),l=AA.useCallback(h=>{I.current=I.current.filter(u=>u!==h)},[]),Q=AA.useMemo(()=>new jk,[]);A?.up&&Q.up.set(A.up.x,A.up.y,A.up.z);const E=AA.useRef(new cg);return AA.useImperativeHandle(n,()=>E.current),AA.useEffect(()=>{if(!r.current)return;jQt(r.current);const h=new yK({antialias:!0,alpha:!0});zQt(h),h.setSize(r.current.clientWidth,r.current.clientHeight),h.setPixelRatio(window.devicePixelRatio),r.current.appendChild(h.domElement);const u=r.current.clientWidth/r.current.clientHeight,d=s==="perspective"?new $Q(75,u,.1,1e3):new D1(-10*u,10*u,10,-10,-1e3,1e3);B.current?(d.position.copy(B.current.position),d.quaternion.copy(B.current.quaternion),d.up.copy(B.current.up)):(e?.up&&d.up.set(e.up[0],e.up[1],e.up[2]),e?.position&&d.position.set(e.position[0],e.position[1],e.position[2]),d.lookAt(0,0,0)),Q.add(E.current),window.__TSCIRCUIT_THREE_OBJECT=E.current,g({scene:Q,camera:d,renderer:h,rootObject:E.current,addFrameListener:C,removeFrameListener:l}),c.current?.({camera:d,renderer:h});let f;const D=new Pwe,b=()=>{const x=D.getElapsedTime(),F=D.getDelta();I.current.forEach(k=>k(x,F)),h.render(Q,d),f=requestAnimationFrame(b)};b();const m=()=>{if(r.current){const x=r.current.clientWidth/r.current.clientHeight;d instanceof $Q?d.aspect=x:d instanceof D1&&(d.left=-10*x,d.right=10*x,d.top=10,d.bottom=-10),d.updateProjectionMatrix(),h.setSize(r.current.clientWidth,r.current.clientHeight)}};return window.addEventListener("resize",m),()=>{B.current={position:d.position.clone(),quaternion:d.quaternion.clone(),up:d.up.clone()},window.removeEventListener("resize",m),cancelAnimationFrame(f),r.current&&h.domElement&&r.current.removeChild(h.domElement),h.dispose(),Q.remove(E.current),window.__TSCIRCUIT_THREE_OBJECT===E.current&&(window.__TSCIRCUIT_THREE_OBJECT=void 0)}},[Q,C,l,s]),V.jsx("div",{ref:r,style:{width:"100%",height:"100%",...i},children:a&&V.jsx(w8A.Provider,{value:a,children:V.jsx(Irt,{children:t})})})}),AEt=({autoRotate:t,autoRotateSpeed:A,onStart:e,panSpeed:i,rotateSpeed:o,zoomSpeed:n,enableDamping:s,dampingFactor:r,target:a,onControlsChange:g})=>{const{camera:I,renderer:c}=du(),B=AA.useMemo(()=>!I||!c?null:new Abe(I,c.domElement),[I,c]);return AA.useEffect(()=>(g?.(B??null),()=>g?.(null)),[B,g]),AA.useEffect(()=>{if(!B)return;const C=()=>{g?.(B)};return B.addEventListener("change",C),()=>{B.removeEventListener("change",C)}},[B,g]),AA.useEffect(()=>{B&&(B.autoRotate=t||!1,B.autoRotateSpeed=A||1,i!==void 0&&(B.panSpeed=i),o!==void 0&&(B.rotateSpeed=o),n!==void 0&&(B.zoomSpeed=n),s!==void 0&&(B.enableDamping=s),r!==void 0&&(B.dampingFactor=r),B.zoomToCursor=!0,B.mouseButtons={LEFT:Bb.ROTATE,MIDDLE:Bb.PAN,RIGHT:null},a&&(B.target.set(a[0],a[1],a[2]),B.update()))},[B,t,A,i,o,n,s,r,a]),AA.useEffect(()=>{if(!(!B||!e))return B.addEventListener("start",e),()=>{B.removeEventListener("start",e)}},[B,e]),AA.useEffect(()=>{if(B)return()=>{B.dispose()}},[B]),mU(()=>{B?.update()},[B]),null},eEt=`
|
|
5062
|
+
`).replace(/d 0\./g,"d 1."),C=g.replace(/newmtl[\s\S]*?endmtl/g,"").replace(/^mtllib.*/gm,""),l=new YSe;l.setMaterialOptions({invertTrProperty:!0});const Q=l.parse(B.replace(/Kd\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/g,"Kd $2 $2 $2"),"embedded.mtl");return c.setMaterials(Q),c.parse(C)}return c.parse(g.replace(/^mtllib.*/gm,""))}catch(a){return a}}function r(){if(o.has(i)){const g=o.get(i);return g.result?Promise.resolve(g.result.clone()):g.promise.then(I=>I instanceof Error?I:I.clone())}const a=s().then(g=>(g instanceof Error||o.set(i,{...o.get(i),result:g}),g));return o.set(i,{promise:a,result:null}),a}return r().then(a=>{n||e(a)}).catch(a=>{console.error(a)}),()=>{n=!0}},[t]),A}function Qrt({url:t,position:A,rotation:e,onHover:i,onUnhover:o,isHovered:n,scale:s,isTranslucent:r=!1}){const a=lrt(t),{rootObject:g}=du(),I=AA.useMemo(()=>a&&!(a instanceof Error)?(a.traverse(c=>{if(c instanceof $o&&c.material){const B=C=>{C.transparent=r,C.opacity=r?.5:1,C.depthWrite=!r,C.needsUpdate=!0};Array.isArray(c.material)?c.material.forEach(B):B(c.material)}}),a):new $o(new Aw(.5,.5,.5),new Qu({transparent:!0,color:"red",opacity:.25})),[a,r]);if(AA.useEffect(()=>{if(!(!g||!I))return g.add(I),()=>{g.remove(I)}},[g,I]),AA.useEffect(()=>{I&&(A&&(Array.isArray(A)?I.position.fromArray(A):I.position.copy(A)),e&&(Array.isArray(e)?I.rotation.fromArray(e):I.rotation.copy(e)),s!==void 0&&I.scale.setScalar(s))},[I,Array.isArray(A)?A[0]:A?.x,Array.isArray(A)?A[1]:A?.y,Array.isArray(A)?A[2]:A?.z,Array.isArray(e)?e[0]:e?.x,Array.isArray(e)?e[1]:e?.y,Array.isArray(e)?e[2]:e?.z,s]),a instanceof Error)throw a;return V.jsx(DU,{isHovered:n,onHover:i,onUnhover:o,object:I})}var D8A=new WeakMap,Ert=()=>{const t=new vc;return t.name="fallback-environment-map",t.mapping=qJ,t},hrt=t=>{if(!t)return null;const A=t,e=D8A.get(A);if(e)return e;let i;if(t instanceof yK){const o=new Oj(t);i=o.fromScene(tSe(),.04).texture,o.dispose()}else i=Ert();return D8A.set(A,i),i},S8A=1.25;function urt({gltfUrl:t,position:A,rotation:e,onHover:i,onUnhover:o,isHovered:n,scale:s,isTranslucent:r=!1}){const{renderer:a,rootObject:g}=du(),[I,c]=AA.useState(null),[B,C]=AA.useState(null);if(AA.useEffect(()=>{if(!t)return;const l=new oSe;let Q=!0;return l.load(t,E=>{if(!Q)return;const h=E.scene;h.traverse(u=>{if(u instanceof $o&&u.material){const d=f=>{f.transparent=r,f.opacity=r?.5:1,f.depthWrite=!r,f.needsUpdate=!0};Array.isArray(u.material)?u.material.forEach(d):d(u.material)}}),c(h)},void 0,E=>{if(!Q)return;console.error(`An error happened loading ${t}`,E);const h=E instanceof Error?E:new Error(`Failed to load glTF model from ${t}`);C(h)}),()=>{Q=!1}},[t,r]),AA.useEffect(()=>{I&&(A&&I.position.fromArray(A),e&&I.rotation.fromArray(e),s!==void 0&&I.scale.setScalar(s))},[I,A?.[0],A?.[1],A?.[2],e?.[0],e?.[1],e?.[2],s]),AA.useEffect(()=>{if(!(!g||!I))return g.add(I),()=>{g.remove(I)}},[g,I]),AA.useEffect(()=>{if(!I||!a)return;const l=hrt(a);if(!l)return;const Q=[],E=h=>{h instanceof Qu&&(Q.push({material:h,envMap:h.envMap??null,envMapIntensity:h.envMapIntensity??1}),h.envMap=l,(typeof h.envMapIntensity!="number"||h.envMapIntensity<S8A)&&(h.envMapIntensity=S8A),h.needsUpdate=!0)};return I.traverse(h=>{if(!(h instanceof $o))return;const u=h.material;Array.isArray(u)?u.forEach(E):u&&E(u)}),()=>{Q.forEach(({material:h,envMap:u,envMapIntensity:d})=>{h.envMap=u,h.envMapIntensity=d,h.needsUpdate=!0})}},[I,a]),AA.useEffect(()=>{I&&I.traverse(l=>{l instanceof $o&&l.material instanceof Qu&&(n?(l.material.emissive.setHex(255),l.material.emissiveIntensity=.2):l.material.emissiveIntensity=0)})},[n,I]),B)throw B;return I?V.jsx(DU,{isHovered:n,onHover:i,onUnhover:o,object:I}):null}var drt=fr(A5A()),prt=fr(yO()),b8A={in:25.4,inch:25.4,mil:.0254,mm:1,m:1e3,cm:10,ft:304.8,feet:304.8},pa=t=>{let A=typeof t=="number"?"mm":t.replace(/^[^a-zA-Z]+/g,"").toLowerCase();A||(A="mm");const e=typeof t=="number"?t:Number.parseFloat(t.split(A)[0]);if(A in b8A)return e*b8A[A];throw new Error(`Unsupported unit: ${A}`)},SU=pa,x8A={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:{fs:1e-12,ps:1e-9,ns:1e-6,us:.001,µs:.001,ms:1,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}}},oBA=new Set;for(const[t,A]of Object.entries(x8A)){oBA.add(t);for(const e of Object.keys(A.variants))oBA.add(e)}function frt(t){for(const[A,e]of Object.entries(x8A))if(t in e.variants)return{baseUnit:e.baseUnit,conversionFactor:e.variants[t]};return{baseUnit:t,conversionFactor:1}}var k8A={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};function Iw(t){if(t==null)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:r,unitOfValue:a}=Iw(t.x),g=Iw(t.x),I=Iw(t.y);return g.value===null||I.value===null?{parsedUnit:null,unitOfValue:null,value:null}:{parsedUnit:r,unitOfValue:a,value:{x:g.value,y:I.value}}}const e=t.toString().split("").reverse().join("").match(/[^\d\s]+/)?.[0];if(!e)throw new Error(`Could not determine unit: "${t}"`);const i=e.split("").reverse().join(""),o=t.slice(0,-i.length);if(i in k8A&&!oBA.has(i)){const r=k8A[i];return{parsedUnit:null,unitOfValue:null,value:Number.parseFloat(o)*r}}const{baseUnit:n,conversionFactor:s}=frt(i);return{parsedUnit:i,unitOfValue:n,value:s*Number.parseFloat(o)}}var nBA=Y().or(jA()).transform(t=>Iw(t).value),G8A=Y().or(jA()).transform(t=>Iw(t).value).transform(t=>Number.parseFloat(t.toPrecision(12))),yrt=Y().or(jA()).transform(t=>Iw(t).value),DM=Y().or(jA()).transform(t=>Iw(t).value),ie=Y().or(jA()).transform(t=>Iw(t).value),sBA=Y().or(jA()).transform(t=>Iw(t).value),mt=ie;Y().or(jA()).transform(t=>Iw(t).value);var rBA=Y().or(jA()).transform(t=>Iw(t).value),SM=rBA,wrt=Y().datetime(),qf=Y().or(jA()).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)),mrt=jA().or(Y().endsWith("mAh")).transform(t=>{if(typeof t=="string"){const A=t.replace("mAh",""),e=Number.parseFloat(A);if(Number.isNaN(e))throw new Error("Invalid capacity");return e}return t}).describe("Battery capacity in mAh"),Fo=YA({x:mt,y:mt}),aBA=YA({x:mt,y:mt,z:mt}),F8A=YA({width:jA(),height:jA()}),Drt=t=>{const A="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";return Array.from({length:t},()=>A[Math.floor(Math.random()*A.length)]).join("")},Ai=t=>Y().optional().default(()=>`${t}_${Drt(10)}`),bM=Ct(["top_left","top_center","top_right","center_left","center","center_right","bottom_left","bottom_center","bottom_right"]),Srt=Ct(["jlcpcb","macrofab","pcbway","digikey","mouser","lcsc"]),OB=YA({type:kA("source_component"),ftype:Y().optional(),source_component_id:Y(),name:Y(),manufacturer_part_number:Y().optional(),supplier_part_numbers:Ra(Srt,be(Y())).optional(),display_value:Y().optional(),are_pins_interchangeable:Be().optional(),internally_connected_source_port_ids:be(be(Y())).optional(),source_group_id:Y().optional(),subcircuit_id:Y().optional()}),R8A=OB.extend({ftype:kA("simple_capacitor"),capacitance:G8A,max_voltage_rating:DM.optional(),display_capacitance:Y().optional(),max_decoupling_trace_length:mt.optional()}),N8A=OB.extend({ftype:kA("simple_resistor"),resistance:nBA,display_resistance:Y().optional()}),gBA=OB.extend({ftype:kA("simple_diode")}),brt=OB.extend({ftype:kA("simple_fiducial")}),M8A=gBA.extend({ftype:kA("simple_led"),color:Y().optional(),wavelength:Y().optional()}),xrt=OB.extend({ftype:kA("simple_ground")}),_8A=OB.extend({ftype:kA("simple_chip")}),v8A=OB.extend({ftype:kA("simple_power_source"),voltage:DM}),krt=OB.extend({ftype:kA("simple_fuse"),current_rating_amps:jA().describe("Nominal current in amps the fuse is rated for"),voltage_rating_volts:jA().describe("Voltage rating in volts, e.g. ±5V would be 5")}),U8A=OB.extend({ftype:kA("simple_battery"),capacity:mrt}),L8A=OB.extend({ftype:kA("simple_inductor"),inductance:yrt,max_current_rating:jA().optional()}),H8A=OB.extend({ftype:kA("simple_push_button")}),Y8A=OB.extend({ftype:kA("simple_potentiometer"),max_resistance:nBA}),Grt=OB.extend({ftype:kA("simple_crystal"),frequency:jA().describe("Frequency in Hz"),load_capacitance:jA().optional().describe("Load capacitance in pF")}),J8A=OB.extend({ftype:kA("simple_pin_header"),pin_count:jA(),gender:Ct(["male","female"]).optional().default("male")}),K8A=OB.extend({ftype:kA("simple_pinout")}),T8A=OB.extend({ftype:kA("simple_resonator"),load_capacitance:G8A,equivalent_series_resistance:nBA.optional(),frequency:sBA}),q8A=OB.extend({ftype:kA("simple_transistor"),transistor_type:Ct(["npn","pnp"])}),P8A=OB.extend({ftype:kA("simple_test_point"),footprint_variant:Ct(["pad","through_hole"]).optional(),pad_shape:Ct(["rect","circle"]).optional(),pad_diameter:ei([jA(),Y()]).optional(),hole_diameter:ei([jA(),Y()]).optional(),width:ei([jA(),Y()]).optional(),height:ei([jA(),Y()]).optional()}),O8A=OB.extend({ftype:kA("simple_mosfet"),channel_type:Ct(["n","p"]),mosfet_mode:Ct(["enhancement","depletion"])}),W8A=OB.extend({ftype:kA("simple_switch")}),Z8A=YA({type:kA("source_project_metadata"),name:Y().optional(),software_used_string:Y().optional(),project_url:Y().optional(),created_at:wrt.optional()}),Frt=YA({type:kA("source_missing_property_error"),source_missing_property_error_id:Ai("source_missing_property_error"),source_component_id:Y(),property_name:Y(),subcircuit_id:Y().optional(),error_type:kA("source_missing_property_error").default("source_missing_property_error"),message:Y()}).describe("The source code is missing a property"),Rrt=YA({type:kA("source_failed_to_create_component_error"),source_failed_to_create_component_error_id:Ai("source_failed_to_create_component_error"),error_type:kA("source_failed_to_create_component_error").default("source_failed_to_create_component_error"),component_name:Y().optional(),subcircuit_id:Y().optional(),parent_source_component_id:Y().optional(),message:Y(),pcb_center:YA({x:jA().optional(),y:jA().optional()}).optional(),schematic_center:YA({x:jA().optional(),y:jA().optional()}).optional()}).describe("Error emitted when a component fails to be constructed"),V8A=YA({type:kA("source_trace_not_connected_error"),source_trace_not_connected_error_id:Ai("source_trace_not_connected_error"),error_type:kA("source_trace_not_connected_error").default("source_trace_not_connected_error"),message:Y(),subcircuit_id:Y().optional(),source_group_id:Y().optional(),source_trace_id:Y().optional(),connected_source_port_ids:be(Y()).optional(),selectors_not_found:be(Y()).optional()}).describe("Occurs when a source trace selector does not match any ports"),Nrt=YA({type:kA("source_property_ignored_warning"),source_property_ignored_warning_id:Ai("source_property_ignored_warning"),source_component_id:Y(),property_name:Y(),subcircuit_id:Y().optional(),error_type:kA("source_property_ignored_warning").default("source_property_ignored_warning"),message:Y()}).describe("The source property was ignored"),j8A=YA({type:kA("source_pin_missing_trace_warning"),source_pin_missing_trace_warning_id:Ai("source_pin_missing_trace_warning"),warning_type:kA("source_pin_missing_trace_warning").default("source_pin_missing_trace_warning"),message:Y(),source_component_id:Y(),source_port_id:Y(),subcircuit_id:Y().optional()}).describe("Warning emitted when a source component pin is missing a trace connection"),Mrt=OB.extend({ftype:kA("simple_voltage_probe")}),_rt=OB.extend({ftype:kA("interconnect")}),vrt=ei([N8A,R8A,gBA,brt,M8A,xrt,_8A,v8A,U8A,L8A,H8A,Y8A,Grt,J8A,K8A,T8A,W8A,q8A,P8A,O8A,krt,Mrt,_rt,Z8A,Frt,Rrt,V8A,Nrt,j8A]),Urt=YA({type:kA("source_port"),pin_number:jA().optional(),port_hints:be(Y()).optional(),name:Y(),source_port_id:Y(),source_component_id:Y().optional(),source_group_id:Y().optional(),subcircuit_id:Y().optional(),subcircuit_connectivity_map_key:Y().optional(),must_be_connected:Be().optional()}),Lrt=YA({type:kA("source_component_internal_connection"),source_component_internal_connection_id:Y(),source_component_id:Y(),source_port_ids:be(Y()),subcircuit_id:Y().optional()}),Hrt=YA({type:kA("source_trace"),source_trace_id:Y(),connected_source_port_ids:be(Y()),connected_source_net_ids:be(Y()),subcircuit_id:Y().optional(),subcircuit_connectivity_map_key:Y().optional(),max_length:jA().optional(),min_trace_thickness:jA().optional(),display_name:Y().optional()}),Yrt=YA({type:kA("source_group"),source_group_id:Y(),subcircuit_id:Y().optional(),parent_subcircuit_id:Y().optional(),parent_source_group_id:Y().optional(),is_subcircuit:Be().optional(),show_as_schematic_box:Be().optional(),name:Y().optional(),was_automatically_named:Be().optional()}),Jrt=YA({type:kA("source_net"),source_net_id:Y(),name:Y(),member_source_group_ids:be(Y()),is_power:Be().optional(),is_ground:Be().optional(),is_digital_signal:Be().optional(),is_analog_signal:Be().optional(),is_positive_voltage_source:Be().optional(),trace_width:jA().optional(),subcircuit_id:Y().optional(),subcircuit_connectivity_map_key:Y().optional()}),Krt=YA({type:kA("source_board"),source_board_id:Y(),source_group_id:Y(),title:Y().optional()}).describe("Defines a board in the source domain"),Trt=YA({type:kA("source_pcb_ground_plane"),source_pcb_ground_plane_id:Y(),source_group_id:Y(),source_net_id:Y(),subcircuit_id:Y().optional()}).describe("Defines a ground plane in the source domain"),qrt=["top","bottom","inner1","inner2","inner3","inner4","inner5","inner6"],z8A=Ct(qrt),Zr=z8A.or(YA({name:z8A})).transform(t=>typeof t=="string"?t:t.name),hm=Ct(["top","bottom"]),Prt=YA({type:kA("source_manually_placed_via"),source_manually_placed_via_id:Y(),source_group_id:Y(),source_net_id:Y(),subcircuit_id:Y().optional(),source_trace_id:Y().optional()}).describe("Defines a via that is manually placed in the source domain"),Ort=YA({type:kA("source_pin_must_be_connected_error"),source_pin_must_be_connected_error_id:Ai("source_pin_must_be_connected_error"),error_type:kA("source_pin_must_be_connected_error").default("source_pin_must_be_connected_error"),message:Y(),source_component_id:Y(),source_port_id:Y(),subcircuit_id:Y().optional()}).describe("Error emitted when a pin with mustBeConnected attribute is not connected to any trace"),Wrt=YA({type:kA("unknown_error_finding_part"),unknown_error_finding_part_id:Ai("unknown_error_finding_part"),error_type:kA("unknown_error_finding_part").default("unknown_error_finding_part"),message:Y(),source_component_id:Y().optional(),subcircuit_id:Y().optional()}).describe("Error emitted when an unexpected error occurs while finding a part"),Zrt=YA({type:kA("schematic_box"),schematic_component_id:Y().optional(),width:mt,height:mt,is_dashed:Be().default(!1),x:mt,y:mt,subcircuit_id:Y().optional()}).describe("Draws a box on the schematic"),Vrt=YA({type:kA("schematic_path"),schematic_component_id:Y(),fill_color:Ct(["red","blue"]).optional(),is_filled:Be().optional(),points:be(Fo),subcircuit_id:Y().optional()}),jrt=Ra(YA({left_margin:ie.optional(),right_margin:ie.optional(),top_margin:ie.optional(),bottom_margin:ie.optional()})),zrt=YA({left_size:jA(),right_size:jA(),top_size:jA().optional(),bottom_size:jA().optional()}),Xrt=YA({left_side:YA({pins:be(jA()),direction:Ct(["top-to-bottom","bottom-to-top"]).optional()}).optional(),right_side:YA({pins:be(jA()),direction:Ct(["top-to-bottom","bottom-to-top"]).optional()}).optional(),top_side:YA({pins:be(jA()),direction:Ct(["left-to-right","right-to-left"]).optional()}).optional(),bottom_side:YA({pins:be(jA()),direction:Ct(["left-to-right","right-to-left"]).optional()}).optional()}),$rt=ei([zrt,Xrt]),Aat=YA({type:kA("schematic_component"),size:F8A,center:Fo,source_component_id:Y().optional(),schematic_component_id:Y(),pin_spacing:ie.optional(),pin_styles:jrt.optional(),box_width:ie.optional(),symbol_name:Y().optional(),port_arrangement:$rt.optional(),port_labels:Ra(Y()).optional(),symbol_display_value:Y().optional(),subcircuit_id:Y().optional(),schematic_group_id:Y().optional(),is_schematic_group:Be().optional(),source_group_id:Y().optional(),is_box_with_pins:Be().optional().default(!0)}),eat=YA({type:kA("schematic_line"),schematic_line_id:Ai("schematic_line"),schematic_component_id:Y(),x1:mt,y1:mt,x2:mt,y2:mt,stroke_width:mt.nullable().optional(),color:Y().default("#000000"),is_dashed:Be().default(!1),subcircuit_id:Y().optional()}).describe("Draws a styled line on the schematic"),tat=YA({type:kA("schematic_rect"),schematic_rect_id:Ai("schematic_rect"),schematic_component_id:Y(),center:Fo,width:mt,height:mt,rotation:qf.default(0),stroke_width:mt.nullable().optional(),color:Y().default("#000000"),is_filled:Be().default(!1),fill_color:Y().optional(),is_dashed:Be().default(!1),subcircuit_id:Y().optional()}).describe("Draws a styled rectangle on the schematic"),iat=YA({type:kA("schematic_circle"),schematic_circle_id:Ai("schematic_circle"),schematic_component_id:Y(),center:Fo,radius:mt,stroke_width:mt.nullable().optional(),color:Y().default("#000000"),is_filled:Be().default(!1),fill_color:Y().optional(),is_dashed:Be().default(!1),subcircuit_id:Y().optional()}).describe("Draws a styled circle on the schematic"),oat=YA({type:kA("schematic_arc"),schematic_arc_id:Ai("schematic_arc"),schematic_component_id:Y(),center:Fo,radius:mt,start_angle_degrees:qf,end_angle_degrees:qf,direction:Ct(["clockwise","counterclockwise"]).default("counterclockwise"),stroke_width:mt.nullable().optional(),color:Y().default("#000000"),is_dashed:Be().default(!1),subcircuit_id:Y().optional()}).describe("Draws a styled arc on the schematic"),nat=YA({type:kA("schematic_trace"),schematic_trace_id:Y(),source_trace_id:Y().optional(),junctions:be(YA({x:jA(),y:jA()})),edges:be(YA({from:YA({x:jA(),y:jA()}),to:YA({x:jA(),y:jA()}),is_crossing:Be().optional(),from_schematic_port_id:Y().optional(),to_schematic_port_id:Y().optional()})),subcircuit_id:Y().optional(),subcircuit_connectivity_map_key:Y().optional()}),sat=Ct(["center","left","right","top","bottom"]),rat=YA({type:kA("schematic_text"),schematic_component_id:Y().optional(),schematic_text_id:Y(),text:Y(),font_size:jA().default(.18),position:YA({x:mt,y:mt}),rotation:jA().default(0),anchor:ei([sat.describe("legacy"),bM]).default("center"),color:Y().default("#000000"),subcircuit_id:Y().optional()}),aat=YA({type:kA("schematic_port"),schematic_port_id:Y(),source_port_id:Y(),schematic_component_id:Y().optional(),center:Fo,facing_direction:Ct(["up","down","left","right"]).optional(),distance_from_component_edge:jA().optional(),side_of_component:Ct(["top","bottom","left","right"]).optional(),true_ccw_index:jA().optional(),pin_number:jA().optional(),display_pin_label:Y().optional(),subcircuit_id:Y().optional(),is_connected:Be().optional(),has_input_arrow:Be().optional(),has_output_arrow:Be().optional()}).describe("Defines a port on a schematic component"),gat=YA({type:kA("schematic_net_label"),schematic_net_label_id:Ai("schematic_net_label"),schematic_trace_id:Y().optional(),source_trace_id:Y().optional(),source_net_id:Y(),center:Fo,anchor_position:Fo.optional(),anchor_side:Ct(["top","bottom","left","right"]),text:Y(),symbol_name:Y().optional(),is_movable:Be().optional(),subcircuit_id:Y().optional()}),Iat=YA({type:kA("schematic_error"),schematic_error_id:Y(),error_type:kA("schematic_port_not_found").default("schematic_port_not_found"),message:Y(),subcircuit_id:Y().optional()}).describe("Defines a schematic error on the schematic"),cat=YA({type:kA("schematic_layout_error"),schematic_layout_error_id:Ai("schematic_layout_error"),error_type:kA("schematic_layout_error").default("schematic_layout_error"),message:Y(),source_group_id:Y(),schematic_group_id:Y(),subcircuit_id:Y().optional()}).describe("Error emitted when schematic layout fails for a group"),IBA=YA({type:kA("schematic_debug_object"),label:Y().optional(),subcircuit_id:Y().optional()}),Bat=IBA.extend({shape:kA("rect"),center:Fo,size:F8A}),Cat=IBA.extend({shape:kA("line"),start:Fo,end:Fo}),lat=IBA.extend({shape:kA("point"),center:Fo}),Qat=Fp("shape",[Bat,Cat,lat]),Eat=YA({type:kA("schematic_voltage_probe"),schematic_voltage_probe_id:Y(),source_component_id:Y().optional(),name:Y().optional(),position:Fo,schematic_trace_id:Y(),voltage:DM.optional(),subcircuit_id:Y().optional(),color:Y().optional(),label_alignment:bM.optional()}).describe("Defines a voltage probe measurement point on a schematic trace"),hat=YA({type:kA("schematic_manual_edit_conflict_warning"),schematic_manual_edit_conflict_warning_id:Ai("schematic_manual_edit_conflict_warning"),warning_type:kA("schematic_manual_edit_conflict_warning").default("schematic_manual_edit_conflict_warning"),message:Y(),schematic_component_id:Y(),schematic_group_id:Y().optional(),subcircuit_id:Y().optional(),source_component_id:Y()}).describe("Warning emitted when a component has both manual placement and explicit schX/schY coordinates"),uat=YA({type:kA("schematic_group"),schematic_group_id:Ai("schematic_group"),source_group_id:Y(),is_subcircuit:Be().optional(),subcircuit_id:Y().optional(),width:ie,height:ie,center:Fo,schematic_component_ids:be(Y()),show_as_schematic_box:Be().optional(),name:Y().optional(),description:Y().optional()}).describe("Defines a group of components on the schematic"),dat=YA({type:kA("schematic_table"),schematic_table_id:Ai("schematic_table"),anchor_position:Fo,column_widths:be(mt),row_heights:be(mt),cell_padding:mt.optional(),border_width:mt.optional(),subcircuit_id:Y().optional(),schematic_component_id:Y().optional(),anchor:bM.optional()}).describe("Defines a table on the schematic"),pat=YA({type:kA("schematic_table_cell"),schematic_table_cell_id:Ai("schematic_table_cell"),schematic_table_id:Y(),start_row_index:jA(),end_row_index:jA(),start_column_index:jA(),end_column_index:jA(),text:Y().optional(),center:Fo,width:mt,height:mt,horizontal_align:Ct(["left","center","right"]).optional(),vertical_align:Ct(["top","middle","bottom"]).optional(),font_size:mt.optional(),subcircuit_id:Y().optional()}).describe("Defines a cell within a schematic_table"),fat=YA({type:kA("schematic_sheet"),schematic_sheet_id:Ai("schematic_sheet"),name:Y().optional(),subcircuit_id:Y().optional()}).describe("Defines a schematic sheet or page that components can be placed on"),yat=YA({x:mt,y:mt,bulge:jA().optional()}),X8A=YA({vertices:be(yat)}),wat=YA({outer_ring:X8A,inner_rings:be(X8A).default([])}),mat=YA({x:mt,y:mt,via:Be().optional(),via_to_layer:Zr.optional()});be(mat);var Dat=YA({x:mt,y:mt,via:Be().optional(),to_layer:Zr.optional(),trace_width:mt.optional()}),Sat=YA({type:kA("pcb_component"),pcb_component_id:Ai("pcb_component"),source_component_id:Y(),center:Fo,layer:Zr,rotation:qf,display_offset_x:Y().optional().describe("How to display the x offset for this part, usually corresponding with how the user specified it"),display_offset_y:Y().optional().describe("How to display the y offset for this part, usually corresponding with how the user specified it"),width:ie,height:ie,do_not_place:Be().optional(),subcircuit_id:Y().optional(),pcb_group_id:Y().optional(),position_mode:Ct(["packed","relative_to_group_anchor","none"]).optional(),positioned_relative_to_pcb_group_id:Y().optional(),positioned_relative_to_pcb_board_id:Y().optional(),obstructs_within_bounds:Be().default(!0).describe("Does this component take up all the space within its bounds on a layer. This is generally true except for when separated pin headers are being represented by a single component (in which case, chips can be placed between the pin headers) or for tall modules where chips fit underneath")}).describe("Defines a component on the PCB"),$8A=YA({type:kA("pcb_hole"),pcb_hole_id:Ai("pcb_hole"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),hole_shape:kA("circle"),hole_diameter:jA(),x:mt,y:mt,is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()});$8A.describe("Defines a circular hole on the PCB");var AWA=YA({type:kA("pcb_hole"),pcb_hole_id:Ai("pcb_hole"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),hole_shape:kA("rect"),hole_width:jA(),hole_height:jA(),x:mt,y:mt,is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()});AWA.describe("Defines a rectangular (square-capable) hole on the PCB. Use equal width/height for square.");var eWA=YA({type:kA("pcb_hole"),pcb_hole_id:Ai("pcb_hole"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),hole_shape:Ct(["circle","square"]),hole_diameter:jA(),x:mt,y:mt,is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()});eWA.describe("Defines a circular or square hole on the PCB");var tWA=YA({type:kA("pcb_hole"),pcb_hole_id:Ai("pcb_hole"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),hole_shape:kA("oval"),hole_width:jA(),hole_height:jA(),x:mt,y:mt,is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()});tWA.describe("Defines an oval hole on the PCB");var iWA=YA({type:kA("pcb_hole"),pcb_hole_id:Ai("pcb_hole"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),hole_shape:kA("pill"),hole_width:jA(),hole_height:jA(),x:mt,y:mt,is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()});iWA.describe("Defines a pill-shaped hole on the PCB");var oWA=YA({type:kA("pcb_hole"),pcb_hole_id:Ai("pcb_hole"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),hole_shape:kA("rotated_pill"),hole_width:jA(),hole_height:jA(),x:mt,y:mt,ccw_rotation:qf,is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()});oWA.describe("Defines a rotated pill-shaped hole on the PCB");var bat=eWA.or(tWA).or(iWA).or(oWA).or($8A).or(AWA),xat=YA({type:kA("pcb_plated_hole"),shape:kA("circle"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),outer_diameter:jA(),hole_diameter:jA(),is_covered_with_solder_mask:Be().optional(),x:mt,y:mt,layers:be(Zr),port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),pcb_plated_hole_id:Ai("pcb_plated_hole"),soldermask_margin:jA().optional()}),kat=YA({type:kA("pcb_plated_hole"),shape:Ct(["oval","pill"]),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),outer_width:jA(),outer_height:jA(),hole_width:jA(),hole_height:jA(),is_covered_with_solder_mask:Be().optional(),x:mt,y:mt,ccw_rotation:qf,layers:be(Zr),port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),pcb_plated_hole_id:Ai("pcb_plated_hole"),soldermask_margin:jA().optional()}),Gat=YA({type:kA("pcb_plated_hole"),shape:kA("circular_hole_with_rect_pad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),hole_shape:kA("circle"),pad_shape:kA("rect"),hole_diameter:jA(),rect_pad_width:jA(),rect_pad_height:jA(),rect_border_radius:jA().optional(),hole_offset_x:mt.default(0),hole_offset_y:mt.default(0),is_covered_with_solder_mask:Be().optional(),x:mt,y:mt,layers:be(Zr),port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),pcb_plated_hole_id:Ai("pcb_plated_hole"),soldermask_margin:jA().optional()}),Fat=YA({type:kA("pcb_plated_hole"),shape:kA("pill_hole_with_rect_pad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),hole_shape:kA("pill"),pad_shape:kA("rect"),hole_width:jA(),hole_height:jA(),rect_pad_width:jA(),rect_pad_height:jA(),rect_border_radius:jA().optional(),hole_offset_x:mt.default(0),hole_offset_y:mt.default(0),is_covered_with_solder_mask:Be().optional(),x:mt,y:mt,layers:be(Zr),port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),pcb_plated_hole_id:Ai("pcb_plated_hole"),soldermask_margin:jA().optional()}),Rat=YA({type:kA("pcb_plated_hole"),shape:kA("rotated_pill_hole_with_rect_pad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),hole_shape:kA("rotated_pill"),pad_shape:kA("rect"),hole_width:jA(),hole_height:jA(),hole_ccw_rotation:qf,rect_pad_width:jA(),rect_pad_height:jA(),rect_border_radius:jA().optional(),rect_ccw_rotation:qf,hole_offset_x:mt.default(0),hole_offset_y:mt.default(0),is_covered_with_solder_mask:Be().optional(),x:mt,y:mt,layers:be(Zr),port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),pcb_plated_hole_id:Ai("pcb_plated_hole"),soldermask_margin:jA().optional()}),Nat=YA({type:kA("pcb_plated_hole"),shape:kA("hole_with_polygon_pad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),hole_shape:Ct(["circle","oval","pill","rotated_pill"]),hole_diameter:jA().optional(),hole_width:jA().optional(),hole_height:jA().optional(),pad_outline:be(YA({x:mt,y:mt})).min(3),hole_offset_x:mt.default(0),hole_offset_y:mt.default(0),is_covered_with_solder_mask:Be().optional(),x:mt,y:mt,layers:be(Zr),port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),pcb_plated_hole_id:Ai("pcb_plated_hole"),soldermask_margin:jA().optional()}),Mat=ei([xat,kat,Gat,Fat,Rat,Nat]),_at=YA({type:kA("pcb_port"),pcb_port_id:Ai("pcb_port"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),source_port_id:Y(),pcb_component_id:Y().optional(),x:mt,y:mt,layers:be(Zr),is_board_pinout:Be().optional()}).describe("Defines a port on the PCB"),vat=YA({type:kA("pcb_smtpad"),shape:kA("circle"),pcb_smtpad_id:Ai("pcb_smtpad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:mt,y:mt,radius:jA(),layer:Zr,port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()}),Uat=YA({type:kA("pcb_smtpad"),shape:kA("rect"),pcb_smtpad_id:Ai("pcb_smtpad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:mt,y:mt,width:jA(),height:jA(),rect_border_radius:jA().optional(),corner_radius:jA().optional(),layer:Zr,port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()}),Lat=YA({type:kA("pcb_smtpad"),shape:kA("rotated_rect"),pcb_smtpad_id:Ai("pcb_smtpad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:mt,y:mt,width:jA(),height:jA(),rect_border_radius:jA().optional(),corner_radius:jA().optional(),ccw_rotation:qf,layer:Zr,port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()}),Hat=YA({type:kA("pcb_smtpad"),shape:kA("pill"),pcb_smtpad_id:Ai("pcb_smtpad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:mt,y:mt,width:jA(),height:jA(),radius:jA(),layer:Zr,port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()}),Yat=YA({type:kA("pcb_smtpad"),shape:kA("rotated_pill"),pcb_smtpad_id:Ai("pcb_smtpad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:mt,y:mt,width:jA(),height:jA(),radius:jA(),ccw_rotation:qf,layer:Zr,port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()}),Jat=YA({type:kA("pcb_smtpad"),shape:kA("polygon"),pcb_smtpad_id:Ai("pcb_smtpad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),points:be(Fo),layer:Zr,port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()}),Kat=Fp("shape",[vat,Uat,Lat,Yat,Hat,Jat]).describe("Defines an SMT pad on the PCB"),Tat=YA({type:kA("pcb_solder_paste"),shape:kA("circle"),pcb_solder_paste_id:Ai("pcb_solder_paste"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:mt,y:mt,radius:jA(),layer:Zr,pcb_component_id:Y().optional(),pcb_smtpad_id:Y().optional()}),qat=YA({type:kA("pcb_solder_paste"),shape:kA("rect"),pcb_solder_paste_id:Ai("pcb_solder_paste"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:mt,y:mt,width:jA(),height:jA(),layer:Zr,pcb_component_id:Y().optional(),pcb_smtpad_id:Y().optional()}),Pat=YA({type:kA("pcb_solder_paste"),shape:kA("pill"),pcb_solder_paste_id:Ai("pcb_solder_paste"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:mt,y:mt,width:jA(),height:jA(),radius:jA(),layer:Zr,pcb_component_id:Y().optional(),pcb_smtpad_id:Y().optional()}),Oat=YA({type:kA("pcb_solder_paste"),shape:kA("rotated_rect"),pcb_solder_paste_id:Ai("pcb_solder_paste"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:mt,y:mt,width:jA(),height:jA(),ccw_rotation:mt,layer:Zr,pcb_component_id:Y().optional(),pcb_smtpad_id:Y().optional()}),Wat=YA({type:kA("pcb_solder_paste"),shape:kA("oval"),pcb_solder_paste_id:Ai("pcb_solder_paste"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:mt,y:mt,width:jA(),height:jA(),layer:Zr,pcb_component_id:Y().optional(),pcb_smtpad_id:Y().optional()}),Zat=ei([Tat,qat,Pat,Oat,Wat]).describe("Defines solderpaste on the PCB"),Vat=YA({type:kA("pcb_text"),pcb_text_id:Ai("pcb_text"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),text:Y(),center:Fo,layer:Zr,width:ie,height:ie,lines:jA(),align:Ct(["bottom-left"])}).describe("Defines text on the PCB"),jat=YA({route_type:kA("wire"),x:mt,y:mt,width:mt,start_pcb_port_id:Y().optional(),end_pcb_port_id:Y().optional(),layer:Zr}),zat=YA({route_type:kA("via"),x:mt,y:mt,hole_diameter:mt.optional(),outer_diameter:mt.optional(),from_layer:Y(),to_layer:Y()}),Xat=ei([jat,zat]),$at=YA({type:kA("pcb_trace"),source_trace_id:Y().optional(),pcb_component_id:Y().optional(),pcb_trace_id:Ai("pcb_trace"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),route_thickness_mode:Ct(["constant","interpolated"]).default("constant").optional(),route_order_index:jA().optional(),should_round_corners:Be().optional(),trace_length:jA().optional(),highlight_color:Y().optional(),route:be(Xat)}).describe("Defines a trace on the PCB"),Agt=YA({type:kA("pcb_trace_error"),pcb_trace_error_id:Ai("pcb_trace_error"),error_type:kA("pcb_trace_error").default("pcb_trace_error"),message:Y(),center:Fo.optional(),pcb_trace_id:Y(),source_trace_id:Y(),pcb_component_ids:be(Y()),pcb_port_ids:be(Y()),subcircuit_id:Y().optional()}).describe("Defines a trace error on the PCB"),egt=YA({type:kA("pcb_trace_missing_error"),pcb_trace_missing_error_id:Ai("pcb_trace_missing_error"),error_type:kA("pcb_trace_missing_error").default("pcb_trace_missing_error"),message:Y(),center:Fo.optional(),source_trace_id:Y(),pcb_component_ids:be(Y()),pcb_port_ids:be(Y()),subcircuit_id:Y().optional()}).describe("Defines an error when a source trace has no corresponding PCB trace"),tgt=YA({type:kA("pcb_port_not_matched_error"),pcb_error_id:Ai("pcb_error"),error_type:kA("pcb_port_not_matched_error").default("pcb_port_not_matched_error"),message:Y(),pcb_component_ids:be(Y()),subcircuit_id:Y().optional()}).describe("Defines a trace error on the PCB where a port is not matched"),igt=YA({type:kA("pcb_port_not_connected_error"),pcb_port_not_connected_error_id:Ai("pcb_port_not_connected_error"),error_type:kA("pcb_port_not_connected_error").default("pcb_port_not_connected_error"),message:Y(),pcb_port_ids:be(Y()),pcb_component_ids:be(Y()),subcircuit_id:Y().optional()}).describe("Defines an error when a pcb port is not connected to any trace"),ogt=YA({type:kA("pcb_net"),pcb_net_id:Ai("pcb_net"),source_net_id:Y().optional(),highlight_color:Y().optional()}).describe("Defines a net on the PCB"),ngt=YA({type:kA("pcb_via"),pcb_via_id:Ai("pcb_via"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),subcircuit_connectivity_map_key:Y().optional(),x:mt,y:mt,outer_diameter:mt.default("0.6mm"),hole_diameter:mt.default("0.25mm"),from_layer:Zr.optional(),to_layer:Zr.optional(),layers:be(Zr),pcb_trace_id:Y().optional(),net_is_assignable:Be().optional(),net_assigned:Be().optional(),is_tented:Be().optional()}).describe("Defines a via on the PCB"),sgt=YA({type:kA("pcb_board"),pcb_board_id:Ai("pcb_board"),pcb_panel_id:Y().optional(),is_subcircuit:Be().optional(),subcircuit_id:Y().optional(),width:ie.optional(),height:ie.optional(),center:Fo,thickness:ie.optional().default(1.4),num_layers:jA().optional().default(4),outline:be(Fo).optional(),shape:Ct(["rect","polygon"]).optional(),material:Ct(["fr4","fr1"]).default("fr4")}).describe("Defines the board outline of the PCB"),rgt=YA({type:kA("pcb_panel"),pcb_panel_id:Ai("pcb_panel"),width:ie,height:ie,center:Fo,covered_with_solder_mask:Be().optional().default(!0)}).describe("Defines a PCB panel that can contain multiple boards"),agt=YA({type:kA("pcb_placement_error"),pcb_placement_error_id:Ai("pcb_placement_error"),error_type:kA("pcb_placement_error").default("pcb_placement_error"),message:Y(),subcircuit_id:Y().optional()}).describe("Defines a placement error on the PCB"),ggt=YA({type:kA("pcb_trace_hint"),pcb_trace_hint_id:Ai("pcb_trace_hint"),pcb_port_id:Y(),pcb_component_id:Y(),route:be(Dat),subcircuit_id:Y().optional()}).describe("A hint that can be used during generation of a PCB trace"),Igt=YA({type:kA("pcb_silkscreen_line"),pcb_silkscreen_line_id:Ai("pcb_silkscreen_line"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),stroke_width:mt.default("0.1mm"),x1:mt,y1:mt,x2:mt,y2:mt,layer:hm}).describe("Defines a silkscreen line on the PCB"),cgt=YA({type:kA("pcb_silkscreen_path"),pcb_silkscreen_path_id:Ai("pcb_silkscreen_path"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),layer:hm,route:be(Fo),stroke_width:ie}).describe("Defines a silkscreen path on the PCB"),Bgt=YA({type:kA("pcb_silkscreen_text"),pcb_silkscreen_text_id:Ai("pcb_silkscreen_text"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),font:kA("tscircuit2024").default("tscircuit2024"),font_size:mt.default("0.2mm"),pcb_component_id:Y(),text:Y(),is_knockout:Be().default(!1).optional(),knockout_padding:YA({left:ie,top:ie,bottom:ie,right:ie}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:jA().optional(),layer:Zr,is_mirrored:Be().default(!1).optional(),anchor_position:Fo.default({x:0,y:0}),anchor_alignment:bM.default("center")}).describe("Defines silkscreen text on the PCB"),Cgt=YA({type:kA("pcb_copper_text"),pcb_copper_text_id:Ai("pcb_copper_text"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),font:kA("tscircuit2024").default("tscircuit2024"),font_size:mt.default("0.2mm"),pcb_component_id:Y(),text:Y(),is_knockout:Be().default(!1).optional(),knockout_padding:YA({left:ie,top:ie,bottom:ie,right:ie}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:jA().optional(),layer:Zr,is_mirrored:Be().default(!1).optional(),anchor_position:Fo.default({x:0,y:0}),anchor_alignment:bM.default("center")}).describe("Defines copper text on the PCB"),lgt=YA({type:kA("pcb_silkscreen_rect"),pcb_silkscreen_rect_id:Ai("pcb_silkscreen_rect"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:Fo,width:ie,height:ie,layer:Zr,stroke_width:ie.default("1mm"),corner_radius:ie.optional(),is_filled:Be().default(!0).optional(),has_stroke:Be().optional(),is_stroke_dashed:Be().optional()}).describe("Defines a silkscreen rect on the PCB"),Qgt=YA({type:kA("pcb_silkscreen_circle"),pcb_silkscreen_circle_id:Ai("pcb_silkscreen_circle"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:Fo,radius:ie,layer:hm,stroke_width:ie.default("1mm")}).describe("Defines a silkscreen circle on the PCB"),Egt=YA({type:kA("pcb_silkscreen_oval"),pcb_silkscreen_oval_id:Ai("pcb_silkscreen_oval"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:Fo,radius_x:mt,radius_y:mt,layer:hm}).describe("Defines a silkscreen oval on the PCB"),hgt=YA({type:kA("pcb_fabrication_note_text"),pcb_fabrication_note_text_id:Ai("pcb_fabrication_note_text"),subcircuit_id:Y().optional(),pcb_group_id:Y().optional(),font:kA("tscircuit2024").default("tscircuit2024"),font_size:mt.default("1mm"),pcb_component_id:Y(),text:Y(),layer:hm,anchor_position:Fo.default({x:0,y:0}),anchor_alignment:Ct(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:Y().optional()}).describe("Defines a fabrication note in text on the PCB, useful for leaving notes for assemblers or fabricators"),ugt=YA({type:kA("pcb_fabrication_note_path"),pcb_fabrication_note_path_id:Ai("pcb_fabrication_note_path"),pcb_component_id:Y(),subcircuit_id:Y().optional(),layer:Zr,route:be(Fo),stroke_width:ie,color:Y().optional()}).describe("Defines a fabrication path on the PCB for fabricators or assemblers"),dgt=YA({type:kA("pcb_fabrication_note_rect"),pcb_fabrication_note_rect_id:Ai("pcb_fabrication_note_rect"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:Fo,width:ie,height:ie,layer:hm,stroke_width:ie.default("0.1mm"),corner_radius:ie.optional(),is_filled:Be().optional(),has_stroke:Be().optional(),is_stroke_dashed:Be().optional(),color:Y().optional()}).describe("Defines a fabrication note rectangle on the PCB"),pgt=YA({type:kA("pcb_fabrication_note_dimension"),pcb_fabrication_note_dimension_id:Ai("pcb_fabrication_note_dimension"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),layer:hm,from:Fo,to:Fo,text:Y().optional(),text_ccw_rotation:jA().optional(),offset:ie.optional(),offset_distance:ie.optional(),offset_direction:YA({x:jA(),y:jA()}).optional(),font:kA("tscircuit2024").default("tscircuit2024"),font_size:ie.default("1mm"),color:Y().optional(),arrow_size:ie.default("1mm")}).describe("Defines a measurement annotation within PCB fabrication notes"),fgt=YA({type:kA("pcb_note_text"),pcb_note_text_id:Ai("pcb_note_text"),pcb_component_id:Y().optional(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),name:Y().optional(),font:kA("tscircuit2024").default("tscircuit2024"),font_size:mt.default("1mm"),text:Y().optional(),anchor_position:Fo.default({x:0,y:0}),anchor_alignment:Ct(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:Y().optional()}).describe("Defines a documentation note in text on the PCB"),ygt=YA({type:kA("pcb_note_rect"),pcb_note_rect_id:Ai("pcb_note_rect"),pcb_component_id:Y().optional(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),name:Y().optional(),text:Y().optional(),center:Fo,width:ie,height:ie,stroke_width:ie.default("0.1mm"),corner_radius:ie.optional(),is_filled:Be().optional(),has_stroke:Be().optional(),is_stroke_dashed:Be().optional(),color:Y().optional()}).describe("Defines a rectangular documentation note on the PCB"),wgt=YA({type:kA("pcb_note_path"),pcb_note_path_id:Ai("pcb_note_path"),pcb_component_id:Y().optional(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),name:Y().optional(),text:Y().optional(),route:be(Fo),stroke_width:ie.default("0.1mm"),color:Y().optional()}).describe("Defines a polyline documentation note on the PCB"),mgt=YA({type:kA("pcb_note_line"),pcb_note_line_id:Ai("pcb_note_line"),pcb_component_id:Y().optional(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),name:Y().optional(),text:Y().optional(),x1:mt,y1:mt,x2:mt,y2:mt,stroke_width:mt.default("0.1mm"),color:Y().optional(),is_dashed:Be().optional()}).describe("Defines a straight documentation note line on the PCB"),Dgt=YA({type:kA("pcb_note_dimension"),pcb_note_dimension_id:Ai("pcb_note_dimension"),pcb_component_id:Y().optional(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),name:Y().optional(),from:Fo,to:Fo,text:Y().optional(),text_ccw_rotation:jA().optional(),offset_distance:ie.optional(),offset_direction:YA({x:jA(),y:jA()}).optional(),font:kA("tscircuit2024").default("tscircuit2024"),font_size:ie.default("1mm"),color:Y().optional(),arrow_size:ie.default("1mm")}).describe("Defines a measurement annotation within PCB documentation notes"),Sgt=YA({type:kA("pcb_footprint_overlap_error"),pcb_error_id:Ai("pcb_error"),error_type:kA("pcb_footprint_overlap_error").default("pcb_footprint_overlap_error"),message:Y(),pcb_smtpad_ids:be(Y()).optional(),pcb_plated_hole_ids:be(Y()).optional(),pcb_hole_ids:be(Y()).optional(),pcb_keepout_ids:be(Y()).optional()}).describe("Error emitted when a pcb footprint overlaps with another element"),bgt=YA({type:kA("pcb_keepout"),shape:kA("rect"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:Fo,width:mt,height:mt,pcb_keepout_id:Y(),layers:be(Y()),description:Y().optional()}).or(YA({type:kA("pcb_keepout"),shape:kA("circle"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:Fo,radius:mt,pcb_keepout_id:Y(),layers:be(Y()),description:Y().optional()})),wO=YA({type:kA("pcb_cutout"),pcb_cutout_id:Ai("pcb_cutout"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),pcb_board_id:Y().optional(),pcb_panel_id:Y().optional()}),xgt=wO.extend({shape:kA("rect"),center:Fo,width:ie,height:ie,rotation:qf.optional(),corner_radius:ie.optional()}),kgt=wO.extend({shape:kA("circle"),center:Fo,radius:ie}),Ggt=wO.extend({shape:kA("polygon"),points:be(Fo)}),Fgt=wO.extend({shape:kA("path"),route:be(Fo),slot_width:ie,slot_length:ie.optional(),space_between_slots:ie.optional(),slot_corner_radius:ie.optional()}),Rgt=Fp("shape",[xgt,kgt,Ggt,Fgt]).describe("Defines a cutout on the PCB, removing board material."),Ngt=YA({type:kA("pcb_missing_footprint_error"),pcb_missing_footprint_error_id:Ai("pcb_missing_footprint_error"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),error_type:kA("pcb_missing_footprint_error").default("pcb_missing_footprint_error"),source_component_id:Y(),message:Y()}).describe("Defines a missing footprint error on the PCB"),Mgt=YA({type:kA("external_footprint_load_error"),external_footprint_load_error_id:Ai("external_footprint_load_error"),pcb_component_id:Y(),source_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),footprinter_string:Y().optional(),error_type:kA("external_footprint_load_error").default("external_footprint_load_error"),message:Y()}).describe("Defines an error when an external footprint fails to load"),_gt=YA({type:kA("circuit_json_footprint_load_error"),circuit_json_footprint_load_error_id:Ai("circuit_json_footprint_load_error"),pcb_component_id:Y(),source_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),error_type:kA("circuit_json_footprint_load_error").default("circuit_json_footprint_load_error"),message:Y(),circuit_json:be(_I()).optional()}).describe("Defines an error when a circuit JSON footprint fails to load"),vgt=YA({type:kA("pcb_group"),pcb_group_id:Ai("pcb_group"),source_group_id:Y(),is_subcircuit:Be().optional(),subcircuit_id:Y().optional(),width:ie.optional(),height:ie.optional(),center:Fo,display_offset_x:Y().optional().describe("How to display the x offset for this group, usually corresponding with how the user specified it"),display_offset_y:Y().optional().describe("How to display the y offset for this group, usually corresponding with how the user specified it"),outline:be(Fo).optional(),anchor_position:Fo.optional(),anchor_alignment:bM.default("center"),position_mode:Ct(["packed","relative_to_group_anchor","none"]).optional(),positioned_relative_to_pcb_group_id:Y().optional(),positioned_relative_to_pcb_board_id:Y().optional(),pcb_component_ids:be(Y()),child_layout_mode:Ct(["packed","none"]).optional(),name:Y().optional(),description:Y().optional(),layout_mode:Y().optional(),autorouter_configuration:YA({trace_clearance:ie}).optional(),autorouter_used_string:Y().optional()}).describe("Defines a group of components on the PCB"),Ugt=YA({type:kA("pcb_autorouting_error"),pcb_error_id:Ai("pcb_autorouting_error"),error_type:kA("pcb_autorouting_error").default("pcb_autorouting_error"),message:Y(),subcircuit_id:Y().optional()}).describe("The autorouting has failed to route a portion of the board"),Lgt=YA({type:kA("pcb_manual_edit_conflict_warning"),pcb_manual_edit_conflict_warning_id:Ai("pcb_manual_edit_conflict_warning"),warning_type:kA("pcb_manual_edit_conflict_warning").default("pcb_manual_edit_conflict_warning"),message:Y(),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),source_component_id:Y()}).describe("Warning emitted when a component has both manual placement and explicit pcbX/pcbY coordinates"),Hgt=YA({type:kA("pcb_breakout_point"),pcb_breakout_point_id:Ai("pcb_breakout_point"),pcb_group_id:Y(),subcircuit_id:Y().optional(),source_trace_id:Y().optional(),source_port_id:Y().optional(),source_net_id:Y().optional(),x:mt,y:mt}).describe("Defines a routing target within a pcb_group for a source_trace or source_net"),Ygt=YA({type:kA("pcb_ground_plane"),pcb_ground_plane_id:Ai("pcb_ground_plane"),source_pcb_ground_plane_id:Y(),source_net_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional()}).describe("Defines a ground plane on the PCB"),Jgt=YA({type:kA("pcb_ground_plane_region"),pcb_ground_plane_region_id:Ai("pcb_ground_plane_region"),pcb_ground_plane_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),layer:Zr,points:be(Fo)}).describe("Defines a polygon region of a ground plane"),Kgt=YA({type:kA("pcb_thermal_spoke"),pcb_thermal_spoke_id:Ai("pcb_thermal_spoke"),pcb_ground_plane_id:Y(),shape:Y(),spoke_count:jA(),spoke_thickness:mt,spoke_inner_diameter:mt,spoke_outer_diameter:mt,pcb_plated_hole_id:Y().optional(),subcircuit_id:Y().optional()}).describe("Pattern for connecting a ground plane to a plated hole"),cBA=YA({type:kA("pcb_copper_pour"),pcb_copper_pour_id:Ai("pcb_copper_pour"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),layer:Zr,source_net_id:Y().optional(),covered_with_solder_mask:Be().optional().default(!0)}),Tgt=cBA.extend({shape:kA("rect"),center:Fo,width:ie,height:ie,rotation:qf.optional()}),qgt=cBA.extend({shape:kA("brep"),brep_shape:wat}),Pgt=cBA.extend({shape:kA("polygon"),points:be(Fo)}),Ogt=Fp("shape",[Tgt,qgt,Pgt]).describe("Defines a copper pour on the PCB."),Wgt=YA({type:kA("pcb_component_outside_board_error"),pcb_component_outside_board_error_id:Ai("pcb_component_outside_board_error"),error_type:kA("pcb_component_outside_board_error").default("pcb_component_outside_board_error"),message:Y(),pcb_component_id:Y(),pcb_board_id:Y(),component_center:Fo,component_bounds:YA({min_x:jA(),max_x:jA(),min_y:jA(),max_y:jA()}),subcircuit_id:Y().optional(),source_component_id:Y().optional()}).describe("Error emitted when a PCB component is placed outside the board boundaries"),Zgt=YA({type:kA("pcb_component_invalid_layer_error"),pcb_component_invalid_layer_error_id:Ai("pcb_component_invalid_layer_error"),error_type:kA("pcb_component_invalid_layer_error").default("pcb_component_invalid_layer_error"),message:Y(),pcb_component_id:Y().optional(),source_component_id:Y(),layer:Zr,subcircuit_id:Y().optional()}).describe("Error emitted when a component is placed on an invalid layer (components can only be on 'top' or 'bottom' layers)"),Vgt=YA({type:kA("pcb_via_clearance_error"),pcb_error_id:Ai("pcb_error"),error_type:kA("pcb_via_clearance_error").default("pcb_via_clearance_error"),message:Y(),pcb_via_ids:be(Y()).min(2),minimum_clearance:mt.optional(),actual_clearance:mt.optional(),pcb_center:YA({x:jA().optional(),y:jA().optional()}).optional(),subcircuit_id:Y().optional()}).describe("Error emitted when vias are closer than the allowed clearance"),jgt=YA({type:kA("pcb_courtyard_rect"),pcb_courtyard_rect_id:Ai("pcb_courtyard_rect"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:Fo,width:ie,height:ie,layer:hm,color:Y().optional()}).describe("Defines a courtyard rectangle on the PCB"),zgt=YA({type:kA("pcb_courtyard_outline"),pcb_courtyard_outline_id:Ai("pcb_courtyard_outline"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),layer:hm,outline:be(Fo).min(2),stroke_width:ie.default("0.1mm"),is_closed:Be().optional(),is_stroke_dashed:Be().optional(),color:Y().optional()}).describe("Defines a courtyard outline on the PCB"),Xgt=YA({type:kA("pcb_courtyard_polygon"),pcb_courtyard_polygon_id:Ai("pcb_courtyard_polygon"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),layer:hm,points:be(Fo).min(3),color:Y().optional()}).describe("Defines a courtyard polygon on the PCB"),$gt=YA({type:kA("cad_component"),cad_component_id:Y(),pcb_component_id:Y(),source_component_id:Y(),position:aBA,rotation:aBA.optional(),size:aBA.optional(),layer:Zr.optional(),subcircuit_id:Y().optional(),footprinter_string:Y().optional(),model_obj_url:Y().optional(),model_stl_url:Y().optional(),model_3mf_url:Y().optional(),model_gltf_url:Y().optional(),model_glb_url:Y().optional(),model_step_url:Y().optional(),model_wrl_url:Y().optional(),model_unit_to_mm_scale_factor:jA().optional(),model_jscad:_I().optional(),show_as_translucent_model:Be().optional()}).describe("Defines a component on the PCB"),AIt=Ct(["sinewave","square","triangle","sawtooth"]),eIt=ei([Y(),jA()]).transform(t=>typeof t=="string"?t.endsWith("%")?parseFloat(t.slice(0,-1))/100:parseFloat(t):t).pipe(jA().min(0,"Duty cycle must be non-negative").max(1,"Duty cycle cannot be greater than 100%")),tIt=YA({type:kA("simulation_voltage_source"),simulation_voltage_source_id:Ai("simulation_voltage_source"),is_dc_source:kA(!0).optional().default(!0),positive_source_port_id:Y().optional(),negative_source_port_id:Y().optional(),positive_source_net_id:Y().optional(),negative_source_net_id:Y().optional(),voltage:DM}).describe("Defines a DC voltage source for simulation"),iIt=YA({type:kA("simulation_voltage_source"),simulation_voltage_source_id:Ai("simulation_voltage_source"),is_dc_source:kA(!1),terminal1_source_port_id:Y().optional(),terminal2_source_port_id:Y().optional(),terminal1_source_net_id:Y().optional(),terminal2_source_net_id:Y().optional(),voltage:DM.optional(),frequency:sBA.optional(),peak_to_peak_voltage:DM.optional(),wave_shape:AIt.optional(),phase:qf.optional(),duty_cycle:eIt.optional()}).describe("Defines an AC voltage source for simulation"),oIt=ei([tIt,iIt]).describe("Defines a voltage source for simulation"),nIt=ei([kA("spice_dc_sweep"),kA("spice_dc_operating_point"),kA("spice_transient_analysis"),kA("spice_ac_analysis")]),sIt=YA({type:kA("simulation_experiment"),simulation_experiment_id:Ai("simulation_experiment"),name:Y(),experiment_type:nIt,time_per_step:rBA.optional(),start_time_ms:SM.optional(),end_time_ms:SM.optional()}).describe("Defines a simulation experiment configuration"),rIt=YA({type:kA("simulation_transient_voltage_graph"),simulation_transient_voltage_graph_id:Ai("simulation_transient_voltage_graph"),simulation_experiment_id:Y(),timestamps_ms:be(jA()).optional(),voltage_levels:be(jA()),source_component_id:Y().optional(),subcircuit_connectivity_map_key:Y().optional(),time_per_step:rBA,start_time_ms:SM,end_time_ms:SM,name:Y().optional(),color:Y().optional()}).describe("Stores voltage measurements over time for a simulation"),aIt=YA({type:kA("simulation_switch"),simulation_switch_id:Ai("simulation_switch"),source_component_id:Y().optional(),closes_at:SM.optional(),opens_at:SM.optional(),starts_closed:Be().optional(),switching_frequency:sBA.optional()}).describe("Defines a switch for simulation timing control"),gIt=YA({type:kA("simulation_voltage_probe"),simulation_voltage_probe_id:Ai("simulation_voltage_probe"),source_component_id:Y().optional(),name:Y().optional(),signal_input_source_port_id:Y().optional(),signal_input_source_net_id:Y().optional(),reference_input_source_port_id:Y().optional(),reference_input_source_net_id:Y().optional(),subcircuit_id:Y().optional(),color:Y().optional()}).describe("Defines a voltage probe for simulation. If a reference input is not provided, it measures against ground. If a reference input is provided, it measures the differential voltage between two points.").superRefine((t,A)=>{if(t.reference_input_source_port_id||t.reference_input_source_net_id){const i=!!t.signal_input_source_port_id||!!t.reference_input_source_port_id,o=!!t.signal_input_source_net_id||!!t.reference_input_source_net_id;i&&o?A.addIssue({code:Wt.custom,message:"Cannot mix port and net connections in a differential probe."}):i?(!t.signal_input_source_port_id||!t.reference_input_source_port_id)&&A.addIssue({code:Wt.custom,message:"Differential port probe requires both signal_input_source_port_id and reference_input_source_port_id."}):o&&(!t.signal_input_source_net_id||!t.reference_input_source_net_id)&&A.addIssue({code:Wt.custom,message:"Differential net probe requires both signal_input_source_net_id and reference_input_source_net_id."})}else!!t.signal_input_source_port_id==!!t.signal_input_source_net_id&&A.addIssue({code:Wt.custom,message:"A voltage probe must have exactly one of signal_input_source_port_id or signal_input_source_net_id."})}),IIt=YA({type:kA("simulation_unknown_experiment_error"),simulation_unknown_experiment_error_id:Ai("simulation_unknown_experiment_error"),error_type:kA("simulation_unknown_experiment_error").default("simulation_unknown_experiment_error"),message:Y(),simulation_experiment_id:Y().optional(),subcircuit_id:Y().optional()}).describe("An unknown error occurred during the simulation experiment.");ei([Hrt,Urt,Lrt,vrt,Jrt,Yrt,_8A,R8A,gBA,M8A,N8A,v8A,U8A,L8A,J8A,K8A,T8A,W8A,q8A,P8A,O8A,Y8A,H8A,Trt,Prt,Krt,Z8A,V8A,j8A,Ort,Wrt,Sat,bat,Ngt,Mgt,_gt,Lgt,Mat,bgt,_at,ogt,Vat,$at,ngt,Kat,Zat,sgt,rgt,vgt,ggt,Igt,cgt,Bgt,Cgt,lgt,Qgt,Egt,Agt,egt,agt,tgt,igt,Vgt,ugt,hgt,dgt,pgt,fgt,ygt,wgt,mgt,Dgt,Ugt,Sgt,Hgt,Rgt,Ygt,Jgt,Kgt,Ogt,Wgt,Zgt,jgt,zgt,Xgt,Zrt,rat,eat,tat,iat,oat,Aat,aat,nat,Vrt,Iat,cat,gat,Qat,Eat,hat,uat,fat,dat,pat,$gt,oIt,sIt,rIt,aIt,gIt,IIt]);var cIt=Object.defineProperty,BIt=(t,A)=>{for(var e in A)cIt(t,e,{get:A[e],enumerable:!0})},eS={};BIt(eS,{axial:()=>Bct,bga:()=>mIt,breakoutheaders:()=>yct,cap:()=>dIt,dfn:()=>WIt,diode:()=>uIt,dip:()=>QIt,electrolytic:()=>olt,hc49:()=>mct,jst:()=>xCt,led:()=>pIt,lqfp:()=>pct,m2host:()=>flt,melf:()=>UBt,micromelf:()=>JBt,minimelf:()=>kBt,mlp:()=>RIt,ms012:()=>Act,ms013:()=>tct,msop:()=>LCt,pad:()=>Dct,pinrow:()=>jIt,platedhole:()=>Elt,potentiometer:()=>elt,pushbutton:()=>lct,qfn:()=>GIt,qfp:()=>FIt,quad:()=>bU,res:()=>fIt,sma:()=>PBt,smb:()=>$Bt,smbf:()=>slt,smc:()=>iCt,smf:()=>VBt,smtpad:()=>llt,sod110:()=>GCt,sod123:()=>act,sod123f:()=>rBt,sod123fl:()=>cBt,sod123w:()=>Jct,sod128:()=>dBt,sod323:()=>Pct,sod323f:()=>iBt,sod323fl:()=>qCt,sod323w:()=>YCt,sod523:()=>Fct,sod723:()=>QBt,sod80:()=>Uct,sod882:()=>$ct,sod882d:()=>NBt,sod923:()=>Vct,soic:()=>SIt,solderjumper:()=>VCt,son:()=>ZCt,sop8:()=>_ct,sot:()=>ult,sot223:()=>rCt,sot23:()=>YIt,sot23w:()=>ECt,sot25:()=>qIt,sot323:()=>Ilt,sot363:()=>LIt,sot457:()=>XCt,sot563:()=>XIt,sot723:()=>oct,sot89:()=>DBt,ssop:()=>MIt,stampboard:()=>Ect,stampreceiver:()=>dct,to220:()=>bBt,to92:()=>kct,to92s:()=>yCt,tssop:()=>vIt,vssop:()=>_Ct});var Bo=(t,A,e)=>({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:"silkscreen_text_1",font:"tscircuit2024",font_size:e,pcb_component_id:"pcb_component_1",text:"{REF}",layer:"top",anchor_position:{x:t,y:A},anchor_alignment:"center"}),Fn=(t,A,e,i,o)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circle",x:A,y:e,hole_diameter:pa(i),outer_diameter:pa(o),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()]}),nWA=Array.from({length:9},(t,A)=>Math.cos(A/8*Math.PI-Math.PI)).map(t=>({x:t,y:-Math.sqrt(1-t**2)}));function Qx(t){return typeof t=="string"?t.trim().toLowerCase().endsWith("mil")?parseFloat(t)*.0254:parseFloat(t):Number(t)}var mO=ei([Y(),jA()]).transform(t=>Qx(t)),CIt=t=>YA({fn:Y(),num_pins:jA().optional().default(6),wide:Be().optional(),narrow:Be().optional(),w:mO.optional(),p:mO.default(t.p??"2.54mm"),id:mO.optional(),od:mO.optional()}).transform(A=>(!A.id&&!A.od?Math.abs(A.p-1.27)<.01?(A.id=Qx("0.55mm"),A.od=Qx("0.95mm")):(A.id=Qx("1.0mm"),A.od=Qx("1.5mm")):A.id?A.od||(A.od=A.id*(1.5/1)):A.id=A.od*(1/1.5),A.w||(A.wide?A.w=Qx("600mil"):A.narrow?A.w=Qx("300mil"):A.w=Qx(t.w??"300mil")),A)),lIt=CIt({}),sWA=(t,A,e,i)=>{const o=t/2,n=A<=o,s=o-1,r=i,a=r*s;return n?{x:-e/2,y:a/2-(A-1)*r}:{x:e/2,y:-a/2+(A-o-1)*r}},QIt=t=>{const A=lIt.parse(t),e=[];for(let g=0;g<A.num_pins;g++){const{x:I,y:c}=sWA(A.num_pins,g+1,A.w,A.p??2.54);e.push(Fn(g+1,I,c,A.id??"0.8mm",A.od??"1mm"))}(A.num_pins/2-1)*A.p+A.od;const o=A.w-A.od-1,n=(A.num_pins/2-1)*A.p+A.od+.4,s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-o/2,y:-n/2},{x:-o/2,y:n/2},...nWA.map(({x:g,y:I})=>({x:g*o/6,y:I*o/6+n/2})),{x:o/2,y:n/2},{x:o/2,y:-n/2},{x:-o/2,y:-n/2}],type:"pcb_silkscreen_path",stroke_width:.1},r=[];for(let g=0;g<A.num_pins;g++){const I=g<A.num_pins/2,c=.6,{y:B}=sWA(A.num_pins,g+1,A.w,A.p??2.54),C=I?-A.w/2-A.od/2-c:A.w/2+A.od/2+c,l=B;r.push({type:"pcb_fabrication_note_text",pcb_fabrication_note_text_id:`pin_${g+1}`,layer:"top",pcb_component_id:`pin_${g+1}`,text:`{pin${g+1}}`,anchor_position:{x:C,y:l},font_size:.3,font:"tscircuit2024",anchor_alignment:"top_left"})}const a=Bo(0,n/2+.5,.4);return{circuitJson:[...e,s,a,...r],parameters:A}},xi=(t,A,e,i,o)=>({type:"pcb_smtpad",x:A,y:e,width:i,height:o,layer:"top",shape:"rect",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(n=>n.toString()):[t.toString()]}),rWA=[{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}],EIt=Object.fromEntries(rWA.map(t=>[t.metric,t])),hIt=Object.fromEntries(rWA.map(t=>[t.imperial,t]));YA({tht:Be(),p:ie.optional(),pw:ie.optional(),ph:ie.optional(),metric:mt.optional(),imperial:mt.optional(),w:ie.optional(),h:ie.optional(),textbottom:Be().optional()});var DO=t=>{let{tht:A,p:e,pw:i,ph:o,metric:n,imperial:s,w:r,h:a,textbottom:g}=t;if(typeof r=="string"&&(r=SU(r)),typeof a=="string"&&(a=SU(a)),typeof e=="string"&&(e=SU(e)),typeof i=="string"&&(i=SU(i)),typeof o=="string"&&(o=SU(o)),a!==void 0&&r!==void 0&&a>r)throw new Error("height cannot be greater than width (rotated footprint not yet implemented)");let I;if(n&&(I=EIt[n]),s&&(I=hIt[s]),I&&(r=I.w_mm_min,a=I.h_mm_min,e=I.p_mm_min,i=I.pw_mm_min,o=I.ph_mm_min),e===void 0||i===void 0||o===void 0)throw new Error("Could not determine required pad dimensions (p, pw, ph)");const c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:e/2,y:o/2+.4},{x:-e/2-i/2-.2,y:o/2+.4},{x:-e/2-i/2-.2,y:-o/2-.4},{x:e/2,y:-o/2-.4}],stroke_width:.1,pcb_silkscreen_path_id:""},B=g?-o/2-.9:o/2+.9,C=Bo(0,B,.2);return A?[Fn(1,-e/2,0,i,i*1/.8),Fn(2,e/2,0,i,i*1/.8),c,C]:[xi(["1","left"],-e/2,0,i,o),xi(["2","right"],e/2,0,i,o),c,C]},uIt=t=>({circuitJson:DO(t),parameters:t}),dIt=t=>({circuitJson:DO(t),parameters:t}),pIt=t=>({circuitJson:DO(t),parameters:t}),fIt=t=>({circuitJson:DO(t),parameters:t}),aWA=(t,{x:A,y:e,radius:i})=>({type:"pcb_smtpad",x:A,y:e,radius:i,layer:"top",shape:"circle",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(o=>o.toString()):[t.toString()]}),gWA="ABCDEFGHIJKLMNOPQRSTUVWXYZ",IWA=Y().transform(t=>{const[A,e]=t.split(/[x ]/);return{x:parseFloat(A),y:parseFloat(e)}}).pipe(YA({x:jA(),y:jA()})),yIt=Y().or(be(_I())).transform(t=>Array.isArray(t)?t:(t.startsWith("(")&&t.endsWith(")")&&(t=t.slice(1,-1)),t.split(",").map(A=>{const e=Number(A);return isNaN(e)?A:e}))).pipe(be(Y().or(jA()))),wIt=YA({fn:Y(),num_pins:jA().optional().default(64),grid:IWA.optional(),p:mt.default("0.8mm"),w:ie.optional(),h:ie.optional(),ball:ie.optional().describe("ball diameter"),pad:ie.optional().describe("pad width/height"),circularpads:Be().optional().describe("use circular pads"),tlorigin:Be().optional(),blorigin:Be().optional(),trorigin:Be().optional(),brorigin:Be().optional(),missing:yIt.default([])}).transform(t=>{let A="tl";if(t.blorigin&&(A="bl"),t.trorigin&&(A="tr"),t.brorigin&&(A="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 o=i.match(/([A-Z]+)(\d+)/);if(!o)return i;const n=gWA.indexOf(o[1]),s=Number.parseInt(o[2])-1;return n*t.grid.x+s+1})),{...t,origin:A}}),mIt=t=>{const A=wIt.parse(t);let{num_pins:e,grid:i,p:o,w:n,h:s,ball:r,pad:a,missing:g}=A;r??=.75/1.27*o,a??=r*.8;const I=[],c=(g??[]).filter(D=>typeof D=="number"),B=i.x*i.y-e;if(g.length===0&&B>0&&(Math.sqrt(B)%1===0?g.push("center"):B===1&&g.push("topleft")),g?.includes("center")){const D=Math.floor(Math.sqrt(B)),b=Math.floor((i.x-D)/2),m=Math.floor((i.y-D)/2);for(let x=m;x<m+D;x++)for(let F=b;F<b+D;F++)c.push(x*i.x+F+1)}g?.includes("topleft")&&c.push(1);const C=new Set(c);let l=0;for(let D=0;D<i.y;D++)for(let b=0;b<i.x;b++){const m=(b-(i.x-1)/2)*o,x=(D-(i.y-1)/2)*o;let F=b,k=D;switch(A.origin){case"bl":F=b,k=i.y-1-D;break;case"br":F=i.x-1-b,k=i.y-1-D;break;case"tr":F=i.x-1-b,k=D;break}let v=k*i.x+F+1;if(C.has(v)){l++;continue}v-=l;const M=[v,`${gWA[k]}${F+1}`];I.push(A.circularpads?aWA(M,{x:m,y:x,radius:a/2}):xi(M,m,x,a,a))}const Q=Bo(0,i.y*o/2,.2),E=o/6;let h;const u=i.x*o/2,d=i.y*o/2;switch(A.origin){case"bl":h=[{x:-u,y:-d},{x:-u,y:-d-E},{x:-u-E,y:-d},{x:-u,y:-d}];break;case"br":h=[{x:u,y:-d},{x:u,y:-d-E},{x:u+E,y:-d},{x:u,y:-d}];break;case"tr":h=[{x:u,y:d},{x:u,y:d+E},{x:u+E,y:d},{x:u,y:d}];break;default:h=[{x:-u,y:d},{x:-u,y:d+E},{x:-u-E,y:d},{x:-u,y:d}];break}const f={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_marker",route:h,stroke_width:.05};return{circuitJson:[...I,Q,f],parameters:A}},SO=(t,A,e,i,o)=>({type:"pcb_smtpad",x:A,y:e,width:i,height:o,radius:o/2,layer:"top",shape:"pill",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(n=>n.toString()):[t.toString()]}),cw=t=>YA({fn:Y(),num_pins:jA().optional().default(8),w:ie.default(ie.parse(t.w??"5.3mm")),p:ie.default(ie.parse(t.p??"1.27mm")),pw:ie.default(ie.parse(t.pw??"0.6mm")),pl:ie.default(ie.parse(t.pl??"1.0mm")),legsoutside:Be().optional().default(t.legsoutside??!1),pillpads:Be().optional().default(t.pillpads??!1)}).transform(A=>(!A.pw&&!A.pl?(A.pw=ie.parse("0.6mm"),A.pl=ie.parse("1.0mm")):A.pw?A.pl||(A.pl=A.pw*(1/.6)):A.pw=A.pl*(.6/1),A)),DIt=cw({}),BBA=t=>{t.widthincludeslegs!==void 0&&(t.legsoutside=!t.widthincludeslegs);const{num_pins:A,pn:e,w:i,p:o,pl:n,legsoutside:s}=t,r=A/2,a=e<=r,g=r-1,I=o,c=I*g,B=s?n/2:-n/2;return a?{x:-i/2-B,y:c/2-(e-1)*I}:{x:i/2+B,y:-c/2+(e-r-1)*I}},SIt=t=>{const A=DIt.parse(t);return{circuitJson:tS(A),parameters:A}},tS=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=BBA({num_pins:t.num_pins,pn:r+1,w:t.w,p:t.p,pl:t.pl,legsoutside:t.legsoutside});t.pillpads?A.push(SO(r+1,a,g,t.pl,t.pw)):A.push(xi(r+1,a,g,t.pl,t.pw))}const e=Math.min(1,t.p/2),i=t.w-(t.legsoutside?0:t.pl*2)-.2,o=(t.num_pins/2-1)*t.p+t.pw+e,n=Bo(0,o/2+.4,o/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:-o/2},{x:-i/2,y:o/2},...nWA.map(({x:r,y:a})=>({x:r*i/6,y:a*i/6+o/2})),{x:i/2,y:o/2},{x:i/2,y:-o/2},{x:-i/2,y:-o/2}]};return[...A,s,n]},cWA=Ct(["leftside","topside","rightside","bottomside","toppin","bottompin","leftpin","rightpin"]),bIt=({num_pins:t,cw:A,ccw:e,startingpin:i})=>{const o=[],n=t/4;let s=1;const r={};for(const a of i??[])r[a]=!0;!r.leftside&&!r.topside&&!r.rightside&&!r.bottomside&&(r.leftside=!0),!r.bottompin&&!r.leftpin&&!r.rightpin&&!r.toppin&&(r.leftside?r.toppin=!0:r.topside?r.rightpin=!0:r.rightside?r.bottompin=!0:r.bottomside&&(r.leftpin=!0)),r.leftside&&r.toppin?s=1:r.leftside&&r.bottompin?s=n:r.bottomside&&r.leftpin?s=n+1:r.bottomside&&r.rightpin?s=n*2:r.rightside&&r.bottompin?s=n*2+1:r.rightside&&r.toppin?s=n*3:r.topside&&r.rightpin?s=n*3+1:r.topside&&r.leftpin&&(s=n*4),o.push(-1);for(let a=0;a<t;a++)o[s]=a+1,e||!A?(s++,s>t&&(s=1)):(s--,s<1&&(s=t));return o},CBA=YA({fn:Y(),cc:Be().default(!0).optional(),ccw:Be().default(!0).optional(),startingpin:Y().or(be(cWA)).transform(t=>typeof t=="string"?t.slice(1,-1).split(","):t).pipe(be(cWA)).optional(),num_pins:jA().optional().default(64),w:ie.optional(),h:ie.optional(),p:ie.default(ie.parse("0.5mm")),pw:ie.optional(),pl:ie.optional(),thermalpad:ei([kA(!0),IWA]).optional(),legsoutside:Be().default(!1)}),lBA=t=>{t.w&&!t.h?t.h=t.w:!t.w&&t.h&&(t.w=t.h);const A=t.num_pins/4;if(!t.p&&!t.pw&&!t.pl&&t.w){const e=A+4;t.p=t.w/e}return!t.p&&t.w&&t.h&&t.pw&&t.pl&&(t.p=(t.w-t.pl*2)/(A-1)),!t.w&&!t.h&&t.p&&(t.w=t.p*(A+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},BWA=CBA.transform(lBA),xIt=["left","bottom","right","top"],kIt=t=>{const{pin_count:A,pn:e,w:i,h:o,p:n,pl:s,legsoutside:r}=t,a=A/4,g=xIt[Math.floor((e-1)/a)],I=(e-1)%a,c=n*(a-1),B=n*(a-1),C=r?s/2:-s/2;switch(g){case"left":return{x:-i/2-C,y:B/2-I*n,o:"vert"};case"bottom":return{x:-c/2+I*n,y:-o/2-C,o:"horz"};case"right":return{x:i/2+C,y:-B/2+I*n,o:"vert"};case"top":return{x:c/2-I*n,y:o/2+C,o:"horz"};default:throw new Error("Invalid pin number")}},bU=t=>{const A=BWA.parse(t),e=[],i=bIt(A),o=A.num_pins/4;for(let r=0;r<A.num_pins;r++){const{x:a,y:g,o:I}=kIt({pin_count:A.num_pins,pn:r+1,w:A.w,h:A.h,p:A.p??.5,pl:A.pl,legsoutside:A.legsoutside});let c=A.pw,B=A.pl;I==="vert"&&([c,B]=[B,c]);const C=i[r+1];e.push(xi(C,a,g,c,B))}if(A.thermalpad)if(typeof A.thermalpad=="boolean"){const r=A.p*(o-1)+A.pw,a=A.p*(o-1)+A.pw;e.push(xi(["thermalpad"],0,0,r,a))}else e.push(xi(["thermalpad"],0,0,A.thermalpad.x,A.thermalpad.y));const n=[];for(const[r,a,g]of[["top-left",-1,1],["bottom-left",-1,-1],["bottom-right",1,-1],["top-right",1,1]]){const I=A.w/2*a,c=A.h/2*g;let B="none",C=I,l=c;const Q=A.pw*2;i[1]===1&&r==="top-left"?B="in1":i[o*4]===1&&r==="top-left"||i[o*3+1]===1&&r==="top-right"?B="in2":i[o*3]===1&&r==="top-right"||i[o]===1&&r==="bottom-left"?B="in1":i[o+1]===1&&r==="bottom-left"?B="in2":i[o*2]===1&&r==="bottom-right"?B="in1":i[o*2+1]===1&&r==="bottom-right"&&(B="in2");const E=B==="in1"?1:-1;if(A.legsoutside){const h=B==="in1"?A.pl/2:A.pw/2,u=B==="in1"?A.pw/2:A.pl/2;C+=h*a*E,l-=u*g*E}(B==="none"||A.legsoutside)&&n.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}`,route:[{x:I-Q*a,y:c},{x:I,y:c},{x:I,y:c-Q*g}],type:"pcb_silkscreen_path",stroke_width:.1}),(B==="in1"||B==="in2")&&!A.legsoutside&&n.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}_1`,route:[{x:I-Q*a,y:c},{x:I-Q*a/2,y:c}],type:"pcb_silkscreen_path",stroke_width:0},{layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}_2`,route:[{x:I,y:c-Q*g/2},{x:I,y:c-Q*g}],type:"pcb_silkscreen_path",stroke_width:.1}),(B==="in1"||B==="in2")&&n.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}_3`,route:[{x:C-.2*-a,y:l+.2*E},{x:C,y:l},{x:C+.2*E*-a,y:l+.2},{x:C-.2*-a,y:l+.2*E}],type:"pcb_silkscreen_path",stroke_width:.1})}const s=Bo(0,A.h/2+(A.legsoutside?A.pl*1.2:.5),.3);return{circuitJson:[...e,...n,s],parameters:A}};CBA.extend({}).transform(lBA);var GIt=t=>(t.legsoutside=!1,bU(t)),FIt=t=>{t.legsoutside=!0;const A=BWA.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=A.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=A.pw;break}return bU(t)};CBA.extend({}).transform(lBA);var RIt=t=>(t.legsoutside=!1,t.thermalpad===void 0&&(t.thermalpad=!0),bU(t)),NIt=cw({w:"3.9mm",p:"1.27mm"}),MIt=t=>{const A=NIt.parse(t);return{circuitJson:tS(A),parameters:A}},_It=cw({w:"7.1mm",p:"0.65mm",pl:"1.35mm",pw:"0.40mm",legsoutside:!0}),vIt=t=>{const A=_It.parse(t);return{circuitJson:tS(A),parameters:A}},UIt=cw({}),LIt=t=>{const A=UIt.parse({fn:"sot363",num_pins:6,w:1.94,p:.65,pw:.3,pl:.7,legoutside:!0});return{circuitJson:tS(A),parameters:A}},CWA=YA({fn:Y(),num_pins:jA().default(3),w:Y().default("1.92mm"),h:Y().default("2.74mm"),pl:Y().default("0.8mm"),pw:Y().default("0.764mm"),p:Y().default("0.95mm"),string:Y().optional()}),HIt=cw({p:"0.95mm",w:"1.6mm",legsoutside:!0}),YIt=t=>{const A=t.string?.match(/^sot23_(\d+)/),e=A?Number.parseInt(A[1],10):3;if(e===6||e===8){const o=HIt.parse({...t,num_pins:e});return{circuitJson:tS(o),parameters:o}}const i=CWA.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:KIt(i),parameters:i};if(i.num_pins===5)return{circuitJson:QWA(i),parameters:i};throw new Error("Invalid number of pins")},JIt=t=>{const{pn:A}=t;return A===1?{x:-1.7,y:0}:A===2?{x:1.7,y:-.95}:{x:1.7,y:.95}},KIt=t=>{const A=[];for(let i=0;i<t.num_pins;i++){const{x:o,y:n}=JIt({num_pins:t.num_pins,pn:i+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl)});A.push(xi(i+1,o,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=Bo(0,Number.parseInt(t.h),.3);return[...A,e]},lWA=t=>{const{p:A,h:e,pn:i}=t;if(i===1)return{x:-e/2-.5,y:A};if(i===2)return{x:-e/2-.5,y:0};if(i===3)return{x:-e/2-.5,y:-A};if(i===4)return{x:e/2+.5,y:-A};if(i===5)return{x:e/2+.5,y:A};throw new Error("Invalid pin number")},QWA=t=>{const A=[];for(let c=1;c<=t.num_pins;c++){const{x:B,y:C}=lWA({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:c});A.push(xi(c,B,C,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=(t.num_pins+1)/2*Number.parseFloat(t.p),i=Number.parseFloat(t.h),o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-e/3,y:i/2+Number.parseFloat(t.p)/1.3},{x:e/3,y:i/2+Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-e/3,y:-i/2-Number.parseFloat(t.p)/1.3},{x:e/3,y:-i/2-Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},s=Bo(0,i+.3,.3),r=lWA({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:1});r.x=r.x-Number.parseFloat(t.pw)*1.5;const a=.7,g=.3,I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:r.x+a/2,y:r.y},{x:r.x-a/2,y:r.y+g/2},{x:r.x-a/2,y:r.y-g/2},{x:r.x+a/2,y:r.y}],stroke_width:.05};return[...A,s,o,n,I]},TIt=CWA.extend({}),qIt=t=>{const A=TIt.parse({...t,num_pins:5});return{circuitJson:QWA(A),parameters:A}},PIt=[{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}],OIt=cw({}),WIt=t=>{const A=OIt.parse(t),e=[];for(let c=0;c<A.num_pins;c++){const{x:B,y:C}=BBA({num_pins:A.num_pins,pn:c+1,w:A.w,p:A.p??1.27,pl:A.pl,widthincludeslegs:!0});e.push(xi(c+1,B,C,A.pl??"1mm",A.pw??"0.6mm"))}const i=Math.min(1,A.p/2),o=A.w+i,n=(A.num_pins/2-1)*A.p+A.pw+i,s=[];for(const c of PIt){const{dx:B,dy:C}=c;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",route:[{x:B*o/2-B*A.p,y:C*n/2},{x:B*o/2,y:C*n/2},{x:B*o/2,y:C*n/2-C*A.p}],type:"pcb_silkscreen_path",stroke_width:.1})}const r=A.p/4,a=-o/2-r/2,g=n/2-A.p/2;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:a,y:g},{x:a-r,y:g+r},{x:a-r,y:g-r},{x:a,y:g}],stroke_width:.1});const I=Bo(0,n/2+.4,n/12);return{circuitJson:[...e,I,...s],parameters:A}},bO=(t,A,e,i,o,n)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circular_hole_with_rect_pad",x:A,y:e,hole_diameter:pa(i),hole_shape:"circle",pad_shape:"rect",rect_pad_width:pa(o),rect_pad_height:pa(n),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()]}),QBA=({fs:t,pn:A,anchor_x:e,anchor_y:i,textalign:o="center",orthogonal:n=!1,verticallyinverted:s=!1,layer:r="top"})=>{let a=0;n&&s?a=270:s?a=180:n?a=90:a=0;let g="center";return o==="left"&&(s?g="center_right":g="center_left"),o==="right"&&(s?g="center_left":g="center_right"),r==="bottom"&&(g==="center_left"?g="center_right":g==="center_right"&&(g="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${A}}`,layer:r,anchor_position:{x:e,y:i},anchor_alignment:g,ccw_rotation:a}};function ZIt({pinlabeltextalignleft:t,pinlabeltextalignright:A,pinlabelorthogonal:e}){let i="top";return e?i="left":i="top",t&&(e?i="bottom":i="right"),A&&(e?i="top":i="left"),i}var VIt=YA({fn:Y(),num_pins:jA().optional().default(6),rows:ei([Y(),jA()]).transform(t=>Number(t)).optional().default(1).describe("number of rows"),p:ie.default("0.1in").describe("pitch"),id:ie.default("1.0mm").describe("inner diameter"),od:ie.default("1.5mm").describe("outer diameter"),male:Be().optional().describe("for male pin headers"),female:Be().optional().describe("for female pin headers"),pinlabeltextalignleft:Be().optional().default(!1),pinlabeltextaligncenter:Be().optional().default(!1),pinlabeltextalignright:Be().optional().default(!1),pinlabelverticallyinverted:Be().optional().default(!1),pinlabelorthogonal:Be().optional().default(!1),nosquareplating:Be().optional().default(!1).describe("do not use rectangular pad for pin 1"),nopinlabels:Be().optional().default(!1).describe("omit silkscreen pin labels"),doublesidedpinlabel:Be().optional().default(!1).describe("add silkscreen pins in top and bottom layers"),bottomsidepinlabel:Be().optional().default(!1).describe("place the silkscreen reference text on the bottom layer instead of top")}).transform(t=>{const A=ZIt(t);return{...t,pinlabelAnchorSide:A,male:t.male??!t.female,female:t.female??!1}}).superRefine((t,A)=>{t.male&&t.female&&A.addIssue({code:Wt.custom,message:"'male' and 'female' cannot both be true; it should be male or female.",path:["male","female"]})}),jIt=t=>{const A=VIt.parse(t),{p:e,id:i,od:o,rows:n,num_pins:s,pinlabelAnchorSide:r,pinlabelverticallyinverted:a,pinlabelorthogonal:g,pinlabeltextalignleft:I,pinlabeltextalignright:c,nopinlabels:B,doublesidedpinlabel:C,bottomsidepinlabel:l}=A;let Q="center";I?Q="left":c&&(Q="right");const E=[],h=Math.ceil(s/n),u=-e,d=({xoff:x,yoff:F,od:k,anchorSide:v})=>{let M=0,H=0;const P=k*.75;switch(v){case"right":M=P;break;case"top":H=P;break;case"bottom":H=-P;break;case"left":M=-P;break}return{anchor_x:x+M,anchor_y:F+H}},f=(x,F,k)=>{x===1&&!A.nosquareplating?E.push(bO(x,F,k,i,o,o)):E.push(Fn(x,F,k,i,o));const{anchor_x:v,anchor_y:M}=d({xoff:F,yoff:k,od:o,anchorSide:r});B||(l?E.push(QBA({fs:o/5,pn:x,anchor_x:v,anchor_y:M,textalign:Q,orthogonal:g,verticallyinverted:a,layer:"bottom"})):E.push(QBA({fs:o/5,pn:x,anchor_x:v,anchor_y:M,textalign:Q,orthogonal:g,verticallyinverted:a,layer:"top"})),C&&E.push(QBA({fs:o/5,pn:x,anchor_x:v,anchor_y:M,textalign:Q,orthogonal:g,verticallyinverted:a,layer:"bottom"})))},D=new Set,b=n>2&&h>2;if(n===1){const x=-((s-1)/2)*e;for(let F=0;F<s;F++){const k=F+1,v=x+F*e,M=`${v},0`;if(D.has(M))throw new Error(`Overlap at ${M}`);D.add(M),f(k,v,0)}}else if(b){const x=-((h-1)/2)*e;let F=1;for(let k=0;k<n&&F<=s;k++)for(let v=0;v<h&&F<=s;v++){const M=x+v*e,H=k*u,P=`${M},${H}`;if(D.has(P))throw new Error(`Overlap at ${P}`);D.add(P),f(F++,M,H)}}else{const x=-((h-1)/2)*e;let F=1,k=0,v=n-1,M=0,H=h-1;for(;F<=s&&k<=v&&M<=H;){for(let P=k;P<=v&&F<=s;P++){const K=x+M*e,O=P*u,W=`${K},${O}`;if(D.has(W))throw new Error(`Overlap at ${W}`);D.add(W),f(F++,K,O)}M++;for(let P=M;P<=H&&F<=s;P++){const K=x+P*e,O=v*u,W=`${K},${O}`;if(D.has(W))throw new Error(`Overlap at ${W}`);D.add(W),f(F++,K,O)}if(v--,M<=H){for(let P=v;P>=k&&F<=s;P--){const K=x+H*e,O=P*u,W=`${K},${O}`;if(D.has(W))throw new Error(`Overlap at ${W}`);D.add(W),f(F++,K,O)}H--}if(k<=v){for(let P=H;P>=M&&F<=s;P--){const K=x+P*e,O=k*u,W=`${K},${O}`;if(D.has(W))throw new Error(`Overlap at ${W}`);D.add(W),f(F++,K,O)}k++}}if(F-1<s)throw new Error(`Missing pins: assigned ${F-1}, expected ${s}`)}const m=Bo(0,e,.5);return{circuitJson:[...E,m],parameters:A}},zIt=cw({}),XIt=t=>{const A=zIt.parse({fn:"sot563",num_pins:6,w:1.94,p:.5,pw:.3,pl:.67,legoutside:!0});return{circuitJson:tS(A),parameters:A}},$It=cw({p:"1.27mm",w:"3.9mm",legsoutside:!0}),Act=t=>{const A=$It.parse({...t,num_pins:8});return{circuitJson:tS(A),parameters:A}},ect=cw({p:"1.27mm",w:"7.5mm",legsoutside:!0}),tct=t=>{const A=ect.parse({...t,num_pins:16});return{circuitJson:tS(A),parameters:A}},ict=YA({fn:Y(),num_pins:kA(3).default(3),w:Y().default("1.2mm"),h:Y().default("1.2mm"),pl:Y().default("0.3mm"),pw:Y().default("0.32mm")}),oct=t=>{const A=ict.parse(t),e=sct(A),i=Bo(.4,ie.parse(A.h),.2);return{circuitJson:[...e,i],parameters:A}},nct=t=>{const{pn:A}=t;return A===1?{x:0,y:0}:A===2?{x:1,y:-.4}:{x:1,y:.4}},sct=t=>{const A=[];for(let e=0;e<3;e++){const{x:i,y:o}=nct({num_pins:t.num_pins,pn:e+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl)});A.push(xi(e+1,i,o,Number.parseFloat(t.pl),e!==0?Number.parseFloat(t.pw):.42))}return A},rct=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("2.36mm"),h:Y().default("1.22mm"),pl:Y().default("0.9mm"),pw:Y().default("0.9mm"),p:Y().default("4.19mm")}),act=t=>{const A=rct.parse(t),e=Bo(0,ie.parse(A.h)/4+.4,.3);return{circuitJson:Ict(A).concat(e),parameters:A}},gct=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},Ict=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=gct({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},cct=YA({fn:Y(),p:ie.optional().default("2.54mm"),id:ie.optional().default("0.7mm"),od:ie.optional().default("1mm")}),Bct=t=>{const A=cct.parse(t),{p:e,id:i,od:o}=A,n=[Fn(1,-e/2,0,i,o),Fn(2,e/2,0,i,o)],s={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2+o+i/2,y:0},{x:e/2-o-i/2,y:0}],stroke_width:.1,pcb_silkscreen_path_id:""},r=Bo(0,e/4,.5);return{circuitJson:[...n,s,r],parameters:A}},xO=(t,A={})=>({type:"pcb_silkscreen_path",layer:A.layer||"top",pcb_component_id:A.pcb_component_id||"",pcb_silkscreen_path_id:A.pcb_silkscreen_path_id||"",route:t,stroke_width:A.stroke_width||.1}),Cct=YA({fn:kA("pushbutton"),w:ie.default(4.5),h:ie.default(6.5),id:ie.default(1),od:ie.default(1.2)}),lct=t=>{const A=Cct.parse(t),e=A.w,i=A.h,o=A.id,n=[Fn(1,-e/2,i/2,o,o*1.5),Fn(2,-e/2,-i/2,o,o*1.5),Fn(3,e/2,-i/2,o,o*1.5),Fn(4,e/2,i/2,o,o*1.5)],s=[xO([{x:-e/2,y:-i/2},{x:-e/2,y:i/2}]),xO([{x:e/2,y:-i/2},{x:e/2,y:i/2}]),xO([{x:-e/2,y:0},{x:-e/5,y:0},{x:e/5*1/Math.sqrt(2),y:i/8}]),xO([{x:e/2,y:0},{x:e/5,y:0}])],r=Bo(0,i/2+.4,.5);return{circuitJson:[...n,...s,r],parameters:A}},EWA=YA({fn:Y(),w:ie.default("22.58mm"),h:ie.optional(),left:ie.optional().default(20),right:ie.optional().default(20),top:ie.optional().default(2),bottom:ie.optional().default(2),p:ie.default(ie.parse("2.54mm")),pw:ie.default(ie.parse("1.6mm")),pl:ie.default(ie.parse("2.4mm")),innerhole:Be().default(!1),innerholeedgedistance:ie.default(ie.parse("1.61mm")),silkscreenlabels:Be().default(!1),silkscreenlabelmargin:ie.default(ie.parse("0.1mm"))}),Qct=t=>{const A=EWA.parse(t);return A.left&&A.right?Math.max(A.left,A.right)*A.p:A.left?A.left*A.p:A.right?A.right*A.p:51},kO=(t,A,e)=>{let i=[];return e==="right"&&(i=[{x:t+1/2,y:A},{x:t-1/2,y:A+.6/2},{x:t-1/2,y:A-.6/2},{x:t+1/2,y:A}]),e==="left"&&(i=[{x:t-1/2,y:A},{x:t+1/2,y:A+.6/2},{x:t+1/2,y:A-.6/2},{x:t-1/2,y:A}]),e==="top"&&(i=[{x:t,y:A+1/2},{x:t-.6/2,y:A-1/2},{x:t+.6/2,y:A-1/2},{x:t,y:A+1/2}]),e==="bottom"&&(i=[{x:t,y:A-1/2},{x:t-.6/2,y:A+1/2},{x:t+.6/2,y:A+1/2},{x:t,y:A-1/2}]),i},Ect=t=>{const A=EWA.parse(t),e=A.h??Qct(A),i=[],o=[],n=[];let s=[];const r=1,a=r,g=A.left+A.right+(A.bottom??0)+(A.top??0),c=`pin${g}`.length*.7/2;if(A.right){const Q=-((A.right-1)/2)*A.p;for(let E=0;E<A.right;E++){if(E===0&&!A.left&&!A.bottom&&!A.silkscreenlabels&&(s=kO(A.w/2-A.pl*1.4,Q+E*A.p,"right")),i.push(xi(E+1+A.left+(A.bottom??0),A.w/2-A.pl/2,Q+E*A.p,A.pl,A.pw)),A.silkscreenlabels){const h=E+1+A.left+(A.bottom??0),u=`pin${h}`;n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${h}`,pcb_component_id:"1",layer:"top",anchor_position:{x:A.w/2-A.pl-(c+A.silkscreenlabelmargin),y:Q+E*A.p},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}A.innerhole&&(o.push(Fn(E+1+A.left+(A.bottom??0)+g,A.w/2,Q+E*A.p,r,a)),o.push(Fn(E+1+A.left+(A.bottom??0)+g*2,A.w/2-A.innerholeedgedistance,Q+E*A.p,r,a)))}}if(A.left){const Q=(A.left-1)/2*A.p;for(let E=0;E<A.left;E++){if(E===0&&!A.silkscreenlabels&&(s=kO(-A.w/2+A.pl*1.4,Q-E*A.p,"left")),i.push(xi(E+1,-A.w/2+A.pl/2,Q-E*A.p,A.pl,A.pw)),A.silkscreenlabels){const h=E+1,u=`pin${h}`;n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${h}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-A.w/2+A.pl+(c+A.silkscreenlabelmargin),y:Q-E*A.p},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}A.innerhole&&(o.push(Fn(E+1+g,-A.w/2,Q-E*A.p,r,a)),o.push(Fn(E+1+g*2,-A.w/2+A.innerholeedgedistance,Q-E*A.p,r,a)))}}if(A.top){const Q=(A.top-1)/2*A.p;for(let E=0;E<A.top;E++){if(E===0&&!A.left&&!A.bottom&&!A.right&&!A.silkscreenlabels&&(s=kO(Q-E*A.p,e/2-A.pl*1.4,"top")),i.push(xi(E+1+A.left+A.right+(A.bottom??0),Q-E*A.p,e/2-A.pl/2,A.pw,A.pl)),A.silkscreenlabels){const h=E+1+A.left+A.right+(A.bottom??0),u=`pin${h}`;n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${h}`,pcb_component_id:"1",layer:"top",anchor_position:{x:Q-E*A.p,y:e/2-A.pl-(c+A.silkscreenlabelmargin)},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:270})}A.innerhole&&(o.push(Fn(E+1+A.left+A.right+(A.bottom??0)+g,Q-E*A.p,e/2,r,a)),o.push(Fn(E+1+A.left+A.right+(A.bottom??0)+g*2,Q-E*A.p,e/2-A.innerholeedgedistance,r,a)))}}if(A.bottom){const Q=-((A.bottom-1)/2)*A.p;for(let E=0;E<A.bottom;E++){if(E===0&&!A.left&&!A.silkscreenlabels&&(s=kO(Q+E*A.p,-e/2+A.pl*1.4,"bottom")),i.push(xi(E+1+A.left,Q+E*A.p,-e/2+A.pl/2,A.pw,A.pl)),A.silkscreenlabels){const h=E+1+A.left,u=`pin${h}`;n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${h}`,pcb_component_id:"1",layer:"top",anchor_position:{x:Q+E*A.p,y:-e/2+A.pl+(c+A.silkscreenlabelmargin)},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:90})}A.innerhole&&(o.push(Fn(E+1+A.left+g,Q+E*A.p,-e/2,r,a)),o.push(Fn(E+1+A.left+g*2,Q+E*A.p,-e/2+A.innerholeedgedistance,r,a)))}}const B={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_triangle_1",pcb_component_id:"2",route:s,stroke_width:.1,layer:"top"},C={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-A.w/2,y:e/2},{x:A.w/2,y:e/2},{x:A.w/2,y:-e/2},{x:-A.w/2,y:-e/2},{x:-A.w/2,y:e/2}],stroke_width:.1,layer:"top"},l=Bo(0,e/1.8,e/25);return{circuitJson:[...i,...o,...n,C,...A.silkscreenlabels?[]:[B],l],parameters:A}},hWA=YA({fn:Y(),w:ie.default("22.58mm"),h:ie.optional(),left:ie.optional().default(20),right:ie.optional().default(20),top:ie.optional().default(2),bottom:ie.optional().default(2),p:ie.default(ie.parse("2.54mm")),pw:ie.default(ie.parse("1.6mm")),pl:ie.default(ie.parse("3.2mm")),innerhole:Be().default(!1),innerholeedgedistance:ie.default(ie.parse("1.61mm"))}),hct=t=>{const A=hWA.parse(t);return A.left&&A.right?Math.max(A.left,A.right)*A.p:A.left?A.left*A.p:A.right?A.right*A.p:51},uct=(t,A,e,i=1,o=.6)=>{const n=i/2,s=o/2;return{left:[{x:t+n,y:A},{x:t-n,y:A+s},{x:t-n,y:A-s},{x:t+n,y:A}],right:[{x:t-n,y:A},{x:t+n,y:A+s},{x:t+n,y:A-s},{x:t-n,y:A}],top:[{x:t,y:A-n},{x:t-s,y:A+n},{x:t+s,y:A+n},{x:t,y:A-n}],bottom:[{x:t,y:A+n},{x:t-s,y:A-n},{x:t+s,y:A-n},{x:t,y:A+n}]}[e]},dct=t=>{const A=hWA.parse(t),e=A.h??hct(A),i=[],o=[],n=[],s=1,r=1.2,a=A.left+A.right+(A.bottom??0)+(A.top??0);let g=[],I=1;if(A.left){const l=(A.left-1)/2*A.p;for(let Q=0;Q<A.left;Q++)Q===0&&(g=uct(-A.w/2-A.pl/2,l-Q*A.p,"left")),i.push(xi(I,-A.w/2+A.pl/2,l-Q*A.p,A.pl,A.pw)),o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${I}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-A.w/2+A.pl/2-4.5,y:l-Q*A.p},text:`pin${I}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),I++,A.innerhole&&n.push(Fn(I+a,-A.w/2+A.innerholeedgedistance,l-Q*A.p,s,r))}if(A.bottom){const l=(A.bottom-1)/2*A.p;for(let Q=A.bottom-1;Q>=0;Q--)i.push(xi(I,l-Q*A.p,-e/2+A.pl/2,A.pw,A.pl)),o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${I}`,pcb_component_id:"1",layer:"top",anchor_position:{x:l-Q*A.p,y:-e/2+A.pl/2-3.2},text:`pin${I}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),I++,A.innerhole&&n.push(Fn(I+a,l-Q*A.p,-e/2+A.innerholeedgedistance,s,r))}if(A.right){const l=-((A.right-1)/2)*A.p;for(let Q=0;Q<A.right;Q++)i.push(xi(I,A.w/2-A.pl/2,l+Q*A.p,A.pl,A.pw)),o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${I}`,pcb_component_id:"1",layer:"top",anchor_position:{x:A.w/2-A.pl/2+3.7,y:l+Q*A.p},text:`pin${I}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),I++,A.innerhole&&n.push(Fn(I+a,A.w/2-A.innerholeedgedistance,l+Q*A.p,s,r))}if(A.top){const l=-((A.top-1)/2)*A.p;for(let Q=A.top-1;Q>=0;Q--)i.push(xi(I,l+Q*A.p,e/2-A.pl/2,A.pw,A.pl)),o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${I}`,pcb_component_id:"1",layer:"top",anchor_position:{x:l+Q*A.p,y:e/2-A.pl/2+3.2},text:`pin${I}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),I++,A.innerhole&&n.push(Fn(I+a,l+Q*A.p,e/2-A.innerholeedgedistance,s,r))}const c={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"1",pcb_component_id:"1",layer:"top",route:g,stroke_width:.1},B={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-A.w/2-A.pl/3,y:e/2+A.pl/3},{x:A.w/2+A.pl/3,y:e/2+A.pl/3},{x:A.w/2+A.pl/3,y:-e/2-A.pl/3},{x:-A.w/2-A.pl/3,y:-e/2-A.pl/3},{x:-A.w/2-A.pl/3,y:e/2+A.pl/3}],stroke_width:.1,layer:"top"},C=Bo(0,e/1.8,e/25);return{circuitJson:[...n,...i,...o,B,c,C],parameters:A}},pct=t=>(t.legsoutside=!0,bU(t)),uWA=YA({fn:Y(),w:ie.default("10mm"),h:ie.optional(),left:ie.optional().default(20),right:ie.optional().default(20),top:ie.optional().default(0),bottom:ie.optional().default(0),p:ie.default(ie.parse("2.54mm")),id:ie.optional().default(ie.parse("1mm")),od:ie.optional().default(ie.parse("1.5mm"))}),fct=t=>{const A=uWA.parse(t);return A.left&&A.right?Math.max(A.left,A.right)*A.p:A.left?A.left*A.p:A.right?A.right*A.p:51},GO=(t,A,e,i=1,o=.6)=>{const n=i/2,s=o/2;return{left:[{x:t+n,y:A},{x:t-n,y:A+s},{x:t-n,y:A-s},{x:t+n,y:A}],right:[{x:t-n,y:A},{x:t+n,y:A+s},{x:t+n,y:A-s},{x:t-n,y:A}],top:[{x:t,y:A-n},{x:t-s,y:A+n},{x:t+s,y:A+n},{x:t,y:A-n}],bottom:[{x:t,y:A+n},{x:t-s,y:A-n},{x:t+s,y:A-n},{x:t,y:A+n}]}[e]},yct=t=>{const A=uWA.parse(t),e=A.h??fct(A),i=[],o=A.id,n=A.od;let s=[];if(A.right){const I=-((A.right-1)/2)*A.p;for(let c=0;c<A.right;c++)c===0&&!A.left&&!A.bottom&&(s=GO(A.w/2+n*1.4,I+c*A.p,"right")),i.push(Fn(c+1+A.left+(A.bottom??0),A.w/2,I+c*A.p,o,n))}if(A.left){const I=-((A.left-1)/2)*A.p;for(let c=0;c<A.left;c++)c===A.left-1&&(s=GO(-A.w/2-n*1.4,I+c*A.p,"left")),i.push(Fn(c+1,-A.w/2,I+c*A.p,o,n))}if(A.top){const I=-((A.top-1)/2)*A.p;for(let c=0;c<A.top;c++)c===A.top-1&&!A.left&&!A.bottom&&!A.right&&(s=GO(I+c*A.p,e/2+n*1.4,"top")),i.push(Fn(c+1+A.right+(A.bottom??0)+A.left,I+c*A.p,e/2,o,n))}if(A.bottom){const I=-((A.bottom-1)/2)*A.p;for(let c=0;c<A.bottom;c++)c===0&&!A.left&&(s=GO(I+c*A.p,-e/2-n*1.4,"bottom")),i.push(Fn(c+1+A.left,I+c*A.p,-e/2,o,n))}const r={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"1",pcb_component_id:"1",layer:"top",route:s,stroke_width:.1},a={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-A.w/2-n,y:e/2+n},{x:A.w/2+n,y:e/2+n},{x:A.w/2+n,y:-e/2-n},{x:-A.w/2-n,y:-e/2-n},{x:-A.w/2-n,y:e/2+n}],stroke_width:.1,layer:"top"},g=Bo(0,e/1.7,e/25);return{circuitJson:[...i,a,g,r],parameters:A}},dWA=(t,A,e,i)=>Array.from({length:25},(o,n)=>{const s=n/24*Math.PI-Math.PI/2;return{x:t+(i==="right"?1:-1)*Math.cos(s)*e,y:A+Math.sin(s)*e}}),wct=YA({fn:Y(),p:ie.optional().default("4.88mm"),id:ie.optional().default("0.6mm"),od:ie.optional().default("1.2mm"),w:ie.optional().default("5.6mm"),h:ie.optional().default("3.5mm")}),mct=t=>{const A=wct.parse(t),{p:e,id:i,od:o,w:n,h:s}=A,r=s/2,a=[Fn(1,-e/2,0,i,o),Fn(2,e/2,0,i,o)],g=dWA(-n/2,0,r,"left"),I=dWA(n/2,0,r,"right"),c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[...g,...g.slice(1).reverse(),{x:-n/2,y:-s/2},{x:n/2,y:-s/2},...I,{x:n/2,y:s/2},{x:-n/2,y:s/2}],stroke_width:.1,pcb_silkscreen_path_id:""},B=Bo(0,e/4,.5);return{circuitJson:[...a,c,B],parameters:A}};YA({w:ie,h:ie});var Dct=t=>{const{w:A,h:e}=t,i=pa(A),o=pa(e);return{circuitJson:[xi(1,0,0,i,o),Bo(0,o/2+.5,.2)],parameters:t}},Sct=YA({fn:Y(),num_pins:ei([kA(3),kA(2)]).default(3),p:Y().default("1.27mm"),id:Y().default("0.72mm"),od:Y().default("0.95mm"),w:Y().default("4.5mm"),h:Y().default("4.5mm"),inline:Be().default(!1),string:Y().optional()}),bct=(t,A,e)=>Array.from({length:25},(i,o)=>{const n=o/24*Math.PI;return{x:t+Math.cos(n)*e,y:A+Math.sin(n)*e}}),xct=t=>{const{p:A,id:e,od:i,h:o}=t,n=Number.parseFloat(o)/2,s=Number.parseFloat(A);return[Fn(1,-s,n-s,e,i),Fn(2,s,n-s,e,i)]},kct=t=>{const A=t.string?.match(/^to92_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=Sct.parse({...t,num_pins:e}),{p:o,id:n,od:s,w:r,h:a,inline:g}=i,I=Number.parseFloat(a)/2,c=Number.parseFloat(o);let B=[];if(i.num_pins===3)B=g?[Fn(1,-c,I-c,n,s),Fn(2,0,I-c,n,s),Fn(3,c,I-c,n,s)]:[Fn(1,0,I,n,s),Fn(2,-c,I-c,n,s),Fn(3,c,I-c,n,s)];else if(i.num_pins===2)B=xct(i);else throw new Error("Invalid number of pins for TO-92");const C=Number.parseFloat(r)/2,l=bct(0,I,C),Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[...l,{x:-C,y:0},{x:C,y:0},l[0]],stroke_width:.1,pcb_silkscreen_path_id:""},E=Bo(0,I+1,.5);return{circuitJson:[...B,Q,E],parameters:i}},Gct=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("2.15mm"),h:Y().default("1.20mm"),pl:Y().default("0.5mm"),pw:Y().default("0.6mm"),p:Y().default("1.4mm")}),Fct=t=>{const A=Gct.parse(t),e=Bo(0,ie.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Nct(A).concat(i,e),parameters:A}},Rct=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},Nct=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=Rct({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},Mct=cw({}),_ct=t=>{const A=Mct.parse(t),e=[];for(let s=0;s<A.num_pins;s++){const{x:r,y:a}=BBA({num_pins:A.num_pins,pn:s+1,w:A.w,p:A.p??1.27,pl:A.pl,widthincludeslegs:!0});e.push(xi(s+1,r,a,A.pl??"1.5mm",A.pw??"0.6mm"))}const i=(A.num_pins/2-1)*A.p+A.pw,o=Bo(0,i/2-.5,i/12),n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:-A.w/3,y:i/2+.2},{x:A.w/3,y:i/2+.2}],stroke_width:.1};return{circuitJson:[...e,o,n],parameters:A}},vct=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("5.0mm"),h:Y().default("2.30mm"),pl:Y().default("1.25mm"),pw:Y().default("2mm"),p:Y().default("3.75mm")}),Uct=t=>{const A=vct.parse(t),e=Bo(0,ie.parse(A.h)/2+1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2+.5,y:ie.parse(A.h)/2+.5},{x:-ie.parse(A.w)/2-.5,y:ie.parse(A.h)/2+.5},{x:-ie.parse(A.w)/2-.5,y:-ie.parse(A.h)/2-.5},{x:ie.parse(A.p)/2+.5,y:-ie.parse(A.h)/2-.5}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Hct(A).concat(i,e),parameters:A}},Lct=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},Hct=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=Lct({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},Yct=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("4.4mm"),h:Y().default("2.1mm"),pl:Y().default("1.2mm"),pw:Y().default("1.2mm"),p:Y().default("2.9mm")}),Jct=t=>{const A=Yct.parse(t),e=Bo(0,ie.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Tct(A).concat(i,e),parameters:A}},Kct=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},Tct=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=Kct({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},qct=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("3.30mm"),h:Y().default("1.80mm"),pl:Y().default("0.60mm"),pw:Y().default("0.45mm"),p:Y().default("2.1mm")}),Pct=t=>{const A=qct.parse(t),e=Bo(0,ie.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Wct(A).concat(i,e),parameters:A}},Oct=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},Wct=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=Oct({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},Zct=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("1.4mm"),h:Y().default("0.9mm"),pl:Y().default("0.35mm"),pw:Y().default("0.25mm"),p:Y().default("1.2mm")}),Vct=t=>{const A=Zct.parse(t),e=Bo(0,ie.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2+.15,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.4,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.4,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2+.15,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:zct(A).concat(i,e),parameters:A}},jct=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},zct=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=jct({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},Xct=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("1.3mm"),h:Y().default("0.9mm"),pl:Y().default("0.4mm"),pw:Y().default("0.7mm"),p:Y().default("0.7mm")}),$ct=t=>{const A=Xct.parse(t),e=Bo(0,ie.parse(A.h)+.1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2+.2,y:ie.parse(A.h)/2+.2},{x:-ie.parse(A.w)/2-.2,y:ie.parse(A.h)/2+.2},{x:-ie.parse(A.w)/2-.2,y:-ie.parse(A.h)/2-.2},{x:ie.parse(A.p)/2+.2,y:-ie.parse(A.h)/2-.2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:eBt(A).concat(i,e),parameters:A}},ABt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},eBt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=ABt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},tBt=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("3,05mm"),h:Y().default("1.65mm"),pl:Y().default("0.6mm"),pw:Y().default("0.6mm"),pad_spacing:Y().default("2.2mm")}),iBt=t=>{const A=tBt.parse(t),e=Bo(0,ie.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.pad_spacing)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:-ie.parse(A.h)/2},{x:ie.parse(A.pad_spacing)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:nBt(A).concat(i,e),parameters:A}},oBt=t=>{const{pn:A,pad_spacing:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},nBt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=oBt({pn:e,pad_spacing:Number.parseFloat(t.pad_spacing)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},sBt=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("4.4mm"),h:Y().default("2.1mm"),pl:Y().default("1.2mm"),pw:Y().default("1.2mm"),p:Y().default("2.9mm")}),rBt=t=>{const A=sBt.parse(t),e=Bo(0,ie.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:gBt(A).concat(i,e),parameters:A}},aBt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},gBt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=aBt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},IBt=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("4.4mm"),h:Y().default("2.1mm"),pl:Y().default("0.91mm"),pw:Y().default("1.22mm"),p:Y().default("3.146mm")}),cBt=t=>{const A=IBt.parse(t),e=Bo(0,ie.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:CBt(A).concat(i,e),parameters:A}},BBt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},CBt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=BBt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},lBt=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("1.80mm"),h:Y().default("1.00mm"),pl:Y().default("0.66mm"),pw:Y().default("0.5mm"),p:Y().default("0.8mm")}),QBt=t=>{const A=lBt.parse(t),e=Bo(0,ie.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.1,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.1,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:hBt(A).concat(i,e),parameters:A}},EBt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},hBt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=EBt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},uBt=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("6.2mm"),h:Y().default("3.4mm"),pl:Y().default("1.4mm"),pw:Y().default("2.1mm"),p:Y().default("4.4mm")}),dBt=t=>{const A=uBt.parse(t),e=Bo(0,ie.parse(A.h)/2+.4,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:fBt(A).concat(i,e),parameters:A}},pBt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},fBt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=pBt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},yBt=YA({fn:Y(),num_pins:ei([kA(3),kA(5)]).default(3),w:Y().default("4.80mm"),h:Y().default("4.80mm"),pl:Y().default("1.3mm"),pw:Y().default("0.9mm"),p:Y().default("1.5mm"),string:Y().optional()}),wBt=t=>{const A=[],e=Number.parseFloat(t.p),i=Number.parseFloat(t.pw),o=Number.parseFloat(t.w),n=Number.parseFloat(t.pl);A.push(xi(1,-o/2,e,n,i),xi(2,-o/2+(1.5-1.3)/2,0,1.5,i),xi(3,-o/2,-e,n,i));const s=Bo(0,0,.3),r=Number.parseFloat(t.w)/2-1,a=Number.parseFloat(t.h)/2,g={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-r,y:a},{x:r,y:a},{x:r,y:a/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},I={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-r,y:-a},{x:r,y:-a},{x:r,y:-a/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,g,I,s]},mBt=t=>{const A=[];Number.parseFloat(t.p),Number.parseFloat(t.pw),Number.parseFloat(t.w),A.push(xi(1,-1.85,-1.5,1.5,.7),xi(2,-1.85,1.5,1.5,.7),xi(3,0,0,.8,2),xi(4,1.85,-1.5,1.5,.7),xi(5,1.85,1.5,1.5,.7));const e=Bo(0,Number.parseFloat(t.h)/2+.5,.3),i=Number.parseFloat(t.w)/2-1,o=Number.parseFloat(t.h)/2,n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:o},{x:i,y:o}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-o},{x:i,y:-o}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,n,s,e]},DBt=t=>{const A=t.string?.match(/^sot89_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=yBt.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:wBt(i),parameters:i};if(i.num_pins===5)return{circuitJson:mBt(i),parameters:i};throw new Error("Invalid number of pins for SOT89")},SBt=YA({fn:Y(),p:ie.optional().default("5.0mm"),id:ie.optional().default("1.0mm"),od:ie.optional().default("1.9mm"),w:ie.optional().default("13mm"),h:ie.optional().default("7mm"),num_pins:jA().optional(),string:Y().optional()}),bBt=t=>{const A=SBt.parse(t),{fn:e,id:i,od:o,w:n,h:s,string:r}=A,a=Number.parseInt(r?.split("_")[1]??"3"),g=-1,I=n/2,c=s/2,B=2.5,C=n*.4,l=Math.max(B,C/(a-1)),Q=Array.from({length:a},(D,b)=>{const m=a%2===0?(b-a/2+.5)*l:(b-Math.floor(a/2))*l;return Fn(b+1,m,g,i,o)}),E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-I,y:-c},{x:I,y:-c},{x:I,y:c},{x:-I,y:c},{x:-I,y:-c}],stroke_width:.1,pcb_silkscreen_path_id:""},h=-c+2*s/3,u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-I,y:h},{x:I,y:h}],stroke_width:.1,pcb_silkscreen_path_id:""},d=[{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/6,y:h},{x:-n/6,y:c}],stroke_width:.1,pcb_silkscreen_path_id:""},{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:n/6,y:h},{x:n/6,y:c}],stroke_width:.1,pcb_silkscreen_path_id:""}],f=Bo(0,s/2+.6,.5);return{circuitJson:[...Q,E,u,...d,f],parameters:{...A,p:l}}},xBt=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("5.40mm"),h:Y().default("2.30mm"),pl:Y().default("1.30mm"),pw:Y().default("1.70mm"),p:Y().default("3.5mm")}),kBt=t=>{const A=xBt.parse(t),e=Bo(0,ie.parse(A.h)/2+.4,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:FBt(A).concat(i,e),parameters:A}},GBt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},FBt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=GBt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},RBt=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("1.90mm"),h:Y().default("1.33mm"),pl:Y().default("0.5mm"),pw:Y().default("0.7mm"),p:Y().default("0.8mm")}),NBt=t=>{const A=RBt.parse(t),e=Bo(0,ie.parse(A.h)+.1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2+.1,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2+.1,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:_Bt(A).concat(i,e),parameters:A}},MBt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},_Bt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=MBt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},vBt=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("7.0mm"),h:Y().default("3.35mm"),pl:Y().default("1.50mm"),pw:Y().default("2.70mm"),p:Y().default("4.8mm")}),UBt=t=>{const A=vBt.parse(t),e=Bo(0,ie.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:HBt(A).concat(i,e),parameters:A}},LBt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},HBt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=LBt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},YBt=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("3.0mm"),h:Y().default("1.80mm"),pl:Y().default("0.80mm"),pw:Y().default("1.20mm"),p:Y().default("1.6mm")}),JBt=t=>{const A=YBt.parse(t),e=Bo(0,ie.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.1,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.1,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:TBt(A).concat(i,e),parameters:A}},KBt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},TBt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=KBt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},qBt=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("7.10mm"),h:Y().default("3.40mm"),pl:Y().default("2.45mm"),pw:Y().default("1.80mm"),p:Y().default("4.05mm")}),PBt=t=>{const A=qBt.parse(t),e=Bo(0,ie.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.5,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.5,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:WBt(A).concat(i,e),parameters:A}},OBt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},WBt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=OBt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},ZBt=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("4.80mm"),h:Y().default("2.10mm"),pl:Y().default("1.30mm"),pw:Y().default("1.40mm"),p:Y().default("2.9mm")}),VBt=t=>{const A=ZBt.parse(t),e=Bo(0,ie.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:zBt(A).concat(i,e),parameters:A}},jBt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},zBt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=jBt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},XBt=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("7.30mm"),h:Y().default("4.40mm"),pl:Y().default("2.50mm"),pw:Y().default("2.30mm"),p:Y().default("4.30mm")}),$Bt=t=>{const A=XBt.parse(t),e=Bo(0,ie.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.1,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.1,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:eCt(A).concat(i,e),parameters:A}},ACt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},eCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=ACt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},tCt=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("10.70mm"),h:Y().default("6.60mm"),pl:Y().default("3.30mm"),pw:Y().default("2.50mm"),p:Y().default("6.80mm")}),iCt=t=>{const A=tCt.parse(t),e=Bo(0,3,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2-.8},{x:-ie.parse(A.w)/2-.8,y:ie.parse(A.h)/2-.8},{x:-ie.parse(A.w)/2-.8,y:-ie.parse(A.h)/2+.8},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2+.8}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:nCt(A).concat(i,e),parameters:A}},oCt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},nCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=oCt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},sCt=YA({fn:Y(),num_pins:jA().default(4),w:Y().default("8.50mm"),h:Y().default("6.90mm"),pl:Y().default("2mm"),pw:Y().default("1.5mm"),p:Y().default("2.30mm"),string:Y().optional()}),rCt=t=>{const A=t.string?.match(/^sot223_(\d+)/),e=A?Number.parseInt(A[1],10):4;if(e===8){const o=ICt.parse({...t,num_pins:e});return{circuitJson:tS(o),parameters:o}}const i=sCt.parse({...t,num_pins:e});if(i.num_pins===4)return{circuitJson:gCt(i),parameters:i};if(i.num_pins===5)return{circuitJson:BCt(i),parameters:i};if(i.num_pins===6)return{circuitJson:lCt(i),parameters:i};throw new Error("Invalid number of pins")},aCt=t=>{const{pn:A,w:e,p:i}=t;return A===1?{x:-e/2+1.1,y:i}:A===2?{x:-e/2+1.1,y:0}:A===3?{x:-e/2+1.1,y:-i}:{x:e/2-1.1,y:0}},gCt=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=aCt({num_pins:t.num_pins,pn:r+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)}),I=r===3?3.8:Number.parseFloat(t.pw);A.push(xi(r+1,a,g,Number.parseFloat(t.pl),I))}const e=Bo(0,0,.3),i=Number.parseFloat(t.w)/2-2.4,o=Number.parseFloat(t.h)/2,n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:o},{x:i,y:o},{x:i,y:o/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:-o},{x:i,y:-o},{x:i,y:-o/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,n,s,e]},ICt=cw({p:"0.90mm",w:"2.8mm",legsoutside:!0}),cCt=t=>{const{p:A,pn:e,w:i}=t;if(e===1)return{x:-i/2+1.2,y:A/2+A};if(e===2)return{x:-i/2+1.2,y:A/2};if(e===3)return{x:-i/2+1.2,y:-A/2};if(e===4)return{x:-i/2+1.2,y:-A/2-A};if(e===5)return{x:i/2-1,y:0};throw new Error("Invalid pin number")},BCt=t=>{const A=[];for(let r=1;r<=t.num_pins;r++){const{x:a,y:g}=cCt({h:Number.parseFloat(t.h),p:1.5,pn:r,w:Number.parseFloat(t.w)});let I=Number.parseFloat(t.pw),c=Number.parseFloat(t.pl);r===5?(I=3.4,c=1.8):(I=1,c=2.2),A.push(xi(r,a,g,c,I))}const e=Number.parseFloat(t.w)/2-2.4,i=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-e,y:i},{x:e,y:i},{x:e,y:i/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-e,y:-i},{x:e,y:-i},{x:e,y:-i/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},s=Bo(0,0,.3);return[...A,o,n,s]},CCt=t=>{const{p:A,pn:e,w:i}=t;if(e===1)return{x:-i/2+1.2,y:2*A};if(e===2)return{x:-i/2+1.2,y:A};if(e===3)return{x:-i/2+1.2,y:0};if(e===4)return{x:-i/2+1.2,y:-A};if(e===5)return{x:-i/2+1.2,y:-2*A};if(e===6)return{x:i/2-1.175,y:0};throw new Error("Invalid pin number")},lCt=t=>{const A=[];for(let r=1;r<=t.num_pins;r++){const{x:a,y:g}=CCt({h:Number.parseFloat(t.h),p:1.3,pn:r,w:8.7});let I=Number.parseFloat(t.pw),c=Number.parseFloat(t.pl);r===6?(I=3.4,c=2.15):(I=.6,c=2.2),A.push(xi(r,a,g,c,I))}const e=Number.parseFloat(t.w)/2-2.4,i=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-e,y:i},{x:e,y:i},{x:e,y:i/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-e,y:-i},{x:e,y:-i},{x:e,y:-i/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},s=Bo(0,0,.3);return[...A,o,n,s]},QCt=YA({fn:Y(),num_pins:jA().default(3),w:Y().default("3.40mm"),h:Y().default("3.30mm"),pl:Y().default("1mm"),pw:Y().default("0.7mm"),p:Y().default("1.2mm"),string:Y().optional()}),ECt=t=>{const A=t.string?.match(/^sot23w_(\d+)/),e=A?Number.parseInt(A[1],3):3,i=QCt.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:uCt(i),parameters:i};throw new Error("Invalid number of pins")},hCt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e,y:.95}:A===2?{x:-e,y:-.95}:{x:e,y:0}},uCt=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=hCt({num_pins:t.num_pins,pn:r+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)});A.push(xi(r+1,a,g,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=Bo(0,Number.parseInt(t.h)/2+1,.3),i=Number.parseFloat(t.w)/2-1,o=Number.parseFloat(t.h)/2,n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:o},{x:i+.3,y:o},{x:i+.3,y:o/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:-o},{x:i+.3,y:-o},{x:i+.3,y:-o/2}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,n,s,e]},dCt=YA({fn:Y(),num_pins:ei([kA(3),kA(2)]).default(3),p:Y().default("1.27mm"),id:Y().default("0.72mm"),od:Y().default("0.95mm"),w:Y().default("2.5mm"),h:Y().default("4.2mm"),string:Y().optional()}),pCt=t=>{const{p:A,id:e,od:i,w:o,h:n}=t,s=Number.parseFloat(n)/2,r=Number.parseFloat(A);return[Fn(1,-r,s-r,e,i),Fn(2,0,s-r,e,i),Fn(3,r,s-r,e,i)]},fCt=t=>{const{p:A,id:e,od:i,h:o}=t,n=Number.parseFloat(o)/2,s=Number.parseFloat(A);return[Fn(1,-s,n-s,e,i),Fn(2,s,n-s,e,i)]},yCt=t=>{const A=t.string?.match(/^to92s_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=dCt.parse({...t,num_pins:e});let o=[];if(i.num_pins===3)o=pCt(i);else if(i.num_pins===2)o=fCt(i);else throw new Error("Invalid number of pins for TO-92");const n=Number.parseFloat(i.h)/2,s=Number.parseFloat(i.p),r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n,y:n-s},{x:-1.9,y:0},{x:1.9,y:0},{x:n,y:n-s},{x:1.5,y:Number.parseFloat(i.h)/2+.5},{x:-1.5,y:Number.parseFloat(i.h)/2+.5},{x:-n,y:n-s}],stroke_width:.1,pcb_silkscreen_path_id:""},a=Bo(0,n+1,.5);return{circuitJson:[...o,r,a],parameters:i}},wCt=YA({fn:Y(),p:ie.optional(),id:ie.optional(),pw:ie.optional(),pl:ie.optional(),w:ie.optional(),h:ie.optional(),sh:ei([Be(),Y(),jA()]).optional().transform(t=>{if(typeof t=="string"){const A=Number(t);return Number.isNaN(A)?!0:A}return t}).describe('JST SH (Surface-mount) connector family. SH stands for "Super High-density".'),ph:Be().optional().describe('JST PH (Through-hole) connector family. PH stands for "Pin Header".'),string:Y().optional()}),mCt={ph:{p:ie.parse("2.2mm"),id:ie.parse("0.70mm"),pw:ie.parse("1.20mm"),pl:ie.parse("1.20mm"),w:ie.parse("6mm"),h:ie.parse("5mm")},sh:{p:ie.parse("1mm"),pw:ie.parse("0.6mm"),pl:ie.parse("1.55mm"),w:ie.parse("5.8mm"),h:ie.parse("7.8mm")}};function DCt(t){return t.sh?"sh":(t.ph,"ph")}function SCt(t,A,e,i,o,n){const s=[];if(t==="ph"){const r=e/2;s.push(bO(1,-r,2,i,o,n)),s.push(bO(2,r,2,i,o,n))}else{const r=-((A-1)/2)*e;for(let g=0;g<A;g++){const I=r+g*e;console.log("x si",I),s.push(xi(g+1,I,-1.325,o,n))}const a=(A-1)/2*e+1.3;console.log("offset",a),s.push(xi(A+1,-a,1.22,1.2,1.8)),s.push(xi(A+2,a,1.22,1.2,1.8))}return s}function bCt(t,A,e){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 xCt=t=>{const A=wCt.parse(t),e=DCt(A),i=mCt[e],o=A.p??i.p,n=A.id??i.id,s=A.pw??i.pw,r=A.pl??i.pl,a=A.w??i.w,g=A.h??i.h;let I=e==="sh"?4:2;if(e==="sh"){const Q=(typeof t.string=="string"?t.string:"").match(/sh(\d+)/);if(Q&&Q[1]){const E=parseInt(Q[1],10);Number.isNaN(E)||(I=E)}else typeof A.sh=="number"&&(I=A.sh)}const c=SCt(e,I,o,n,s,r),B=bCt(e),C=Bo(0,g/2+1,.5);return{circuitJson:[...c,B,C],parameters:{...A,p:o,id:n,pw:s,pl:r,w:a,h:g,num_pins:I,sh:e==="sh",ph:e==="ph"}}},kCt=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("3.30mm"),h:Y().default("1.70mm"),pl:Y().default("0.80mm"),pw:Y().default("1mm"),p:Y().default("1.90mm")}),GCt=t=>{const A=kCt.parse(t),e=Bo(0,ie.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:RCt(A).concat(i,e),parameters:A}},FCt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},RCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=FCt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},NCt=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"}}},MCt=YA({fn:Y(),num_pins:ei([kA(8),kA(10)]).default(8),w:Y().optional(),h:Y().optional(),p:Y().optional(),pl:Y().optional(),pw:Y().optional(),string:Y().optional()}),_Ct=t=>{const A=MCt.parse(t),e=NCt(A.num_pins),i=ie.parse(A.w||e.w),o=ie.parse(A.h||e.h),n=ie.parse(A.p||e.p),s=ie.parse(A.pl||e.pl),r=ie.parse(A.pw||e.pw),a=[],g=A.num_pins/2;for(let u=0;u<A.num_pins;u++){const{x:d,y:f}=pWA(A.num_pins,u+1,i,n),D=u<g?u+1:A.num_pins-(u-g);a.push(xi(D,d,f,s,r))}const I=i,c=o,B={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-I/2,y:c/2},{x:I/2,y:c/2}],stroke_width:.05,pcb_silkscreen_path_id:""},C={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-I/2,y:-c/2},{x:I/2,y:-c/2}],stroke_width:.05,pcb_silkscreen_path_id:""},l=pWA(A.num_pins,1,I,n),Q={x:l.x-.8,y:l.y},E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:Q.x-.4,y:Q.y},{x:Q.x-.7,y:Q.y+.3},{x:Q.x-.7,y:Q.y-.3},{x:Q.x-.4,y:Q.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},h=Bo(0,c/2+.5,.3);return{circuitJson:[...a,B,C,h,E],parameters:A}},pWA=(t,A,e,i)=>{const o=t/2,n=(A-1)%o,s=A<=o?-1:1,r=(o-1)/2-n;return{x:s*ie.parse(t===8?"1.8mm":"2.2mm"),y:r*i}},vCt=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"}}},UCt=YA({fn:Y(),num_pins:ei([kA(8),kA(10),kA(12),kA(16)]).default(8),w:Y().optional(),h:Y().optional(),p:Y().optional(),pl:Y().optional(),pw:Y().optional(),string:Y().optional()}),fWA=(t,A,e,i)=>{const o=t/2,n=(A-1)%o,s=A<=o?-1:1,r=(o-1)/2-n;return{x:s*ie.parse("2mm"),y:r*i}},LCt=t=>{const A=UCt.parse(t),e=vCt(A.num_pins),i=ie.parse(A.w||e.w),o=ie.parse(A.h||e.h),n=ie.parse(A.p||e.p),s=ie.parse(A.pl||e.pl),r=ie.parse(A.pw||e.pw),a=[];for(let h=0;h<A.num_pins;h++){const{x:u,y:d}=fWA(A.num_pins,h+1,i,n);a.push(xi(h+1,u,d,s,r))}const g=i,I=o,c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-g/2,y:I/2},{x:g/2,y:I/2}],stroke_width:.05,pcb_silkscreen_path_id:""},B={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-g/2,y:-I/2},{x:g/2,y:-I/2}],stroke_width:.05,pcb_silkscreen_path_id:""},C=fWA(A.num_pins,1,g,n),l={x:C.x-.8,y:C.y},Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:l.x-.4,y:l.y},{x:l.x-.7,y:l.y+.3},{x:l.x-.7,y:l.y-.3},{x:l.x-.4,y:l.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},E=Bo(0,I/2+.5,.3);return{circuitJson:[...a,c,B,E,Q],parameters:A}},HCt=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("3.8mm"),h:Y().default("1.65mm"),pl:Y().default("1.2mm"),pw:Y().default("1.2mm"),pad_spacing:Y().default("2.6mm")}),YCt=t=>{const A=HCt.parse(t),e=Bo(0,ie.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.pad_spacing)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:-ie.parse(A.h)/2},{x:ie.parse(A.pad_spacing)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:KCt(A).concat(i,e),parameters:A}},JCt=t=>{const{pn:A,pad_spacing:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},KCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=JCt({pn:e,pad_spacing:Number.parseFloat(t.pad_spacing)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},TCt=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("3.20mm"),h:Y().default("1.65mm"),pl:Y().default("0.8mm"),pw:Y().default("0.9mm"),pad_spacing:Y().default("2.1mm")}),qCt=t=>{const A=TCt.parse(t),e=Bo(0,ie.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.pad_spacing)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:-ie.parse(A.h)/2},{x:ie.parse(A.pad_spacing)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:OCt(A).concat(i,e),parameters:A}},PCt=t=>{const{pn:A,pad_spacing:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},OCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=PCt({pn:e,pad_spacing:Number.parseFloat(t.pad_spacing)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},WCt=YA({fn:Y(),num_pins:ei([kA(6),kA(8)]).default(8),w:Y().default("3mm"),h:Y().default("3mm"),p:Y().default("0.5mm"),pl:Y().default("0.52mm"),pw:Y().default("0.35mm"),epw:Y().default("1.40mm"),eph:Y().default("1.60mm"),string:Y().optional(),ep:Be().default(!1)}),ZCt=t=>{t.string&&t.string.includes("_ep")&&(t.ep=!0);const A=t.string?.match(/^son_(\d+)/),e=A?Number.parseInt(A[1],10):t.num_pins||8,i=WCt.parse({...t,num_pins:e}),o=ie.parse(i.w),n=ie.parse(i.h),s=ie.parse(i.p),r=ie.parse(i.pl),a=ie.parse(i.pw),g=ie.parse(i.epw),I=ie.parse(i.eph),c=[];for(let f=0;f<i.num_pins;f++){const{x:D,y:b}=yWA(i.num_pins,f+1,o,s);c.push(xi(f+1,D,b,r,a))}i.ep&&c.push(xi(i.num_pins+1,0,0,g,I));const B=o,C=n,l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-B/2,y:C/2},{x:B/2,y:C/2}],stroke_width:.05,pcb_silkscreen_path_id:""},Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-B/2,y:-C/2},{x:B/2,y:-C/2}],stroke_width:.05,pcb_silkscreen_path_id:""},E=yWA(i.num_pins,1,B,s),h={x:E.x-.4,y:E.y},u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:h.x-.4,y:h.y},{x:h.x-.7,y:h.y+.3},{x:h.x-.7,y:h.y-.3},{x:h.x-.4,y:h.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},d=Bo(0,C/2+.5,.3);return{circuitJson:[...c,l,Q,d,u],parameters:i}},yWA=(t,A,e,i)=>{const o=t/2,n=(A-1)%o,s=A<=o?-1:1,r=(o-1)/2-n;return{x:s*ie.parse("1.4mm"),y:r*i}},VCt=t=>{const{num_pins:A,bridged:e,p:i=2.54,pw:o=1.5,ph:n=1.5}=t,s=ie.parse(i),r=ie.parse(o),a=ie.parse(n),g=Math.min(a/4,.5),I=[];for(let f=0;f<A;f++)I.push(xi(f+1,f*s,0,r,a));let c=[];if(e){const f=e.split("").map(Number);if(f.length>1)for(let D=0;D<f.length-1;D++){const b=f[D],m=f[D+1];if(typeof b=="number"&&typeof m=="number"&&!isNaN(b)&&!isNaN(m)){const x=(b-1)*s,F=(m-1)*s,k=Math.sign(F-x),v=x+k*(r/2),M=F-k*(r/2);c.push({type:"pcb_trace",pcb_trace_id:"",route:[{start_pcb_port_id:`{PIN${b}}`,x:v,y:0,width:g,layer:"top",route_type:"wire"},{end_pcb_port_id:`{PIN${m}}`,x:M,y:0,width:g,layer:"top",route_type:"wire"}]})}}}const B=(A-1)*s+r+.7,C=a+1,l=(A-1)*s/2,Q=0,E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"outline",route:[{x:l-B/2,y:Q-C/2},{x:l+B/2,y:Q-C/2},{x:l+B/2,y:Q+C/2},{x:l-B/2,y:Q+C/2},{x:l-B/2,y:Q-C/2}],stroke_width:.15},u=Q+C/2+.6,d=Bo(l,u,.4);return{circuitJson:[...I,...c,E,d],parameters:t}},wWA={fn:kA("sot457"),num_pins:kA(6).default(6),pillh:Y().default("0.45mm"),pillw:Y().default("1.45mm"),pl:Y(),pw:Y(),p:Y(),wave:Be().optional(),reflow:Be().optional()},jCt=YA({...wWA,h:Y().default("2.5mm"),w:Y().default("2.7mm"),pl:Y().default("0.8mm"),pw:Y().default("0.55mm"),p:Y().default("0.95mm")}),zCt=YA({...wWA,h:Y().default("3mm"),w:Y().default("4mm"),pillr:Y().default("0.225mm"),pl:Y().default("1.45mm"),pw:Y().default("1.5mm"),p:Y().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)})),iS=t=>Number.parseFloat(t.replace("mm","")),mWA=({pitch:t,width:A,pinNumber:e})=>{const n={1:{x:-A/2-.1,y:t},2:{x:-A/2-.1,y:0},3:{x:-A/2-.1,y:-t},4:{x:A/2+.1,y:-t},5:{x:A/2+.1,y:0},6:{x:A/2+.1,y:t}}[e];if(!n)throw new Error(`Invalid pin number: ${e}`);return n},DWA=t=>{const A=[],e=iS(t.p),i=iS(t.pl),o=iS(t.pw),n=iS(t.w),s=iS(t.h);if(t.wave){const l={1:({padWidth:Q,padHeight:E})=>xi(1,-e,e,E,Q),2:({padWidth:Q,padHeight:E})=>xi(2,-e,-e,E,Q),3:({padWidth:Q,padHeight:E})=>SO(3,-e,0,iS(t.pillw),iS(t.pillh)),4:({padWidth:Q,padHeight:E})=>SO(4,e,0,iS(t.pillw),iS(t.pillh)),5:({padWidth:Q,padHeight:E})=>xi(5,e,e,E,Q),6:({padWidth:Q,padHeight:E})=>xi(6,e,-e,E,Q)};for(let Q=1;Q<=t.num_pins;Q++){const E=l[Q];E&&A.push(E({padWidth:i,padHeight:o}))}}else for(let l=1;l<=t.num_pins;l++){const{x:Q,y:E}=mWA({pitch:e,width:n,pinNumber:l});A.push(xi(l,Q,E,i,o))}const r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-n/3,y:s/2+e/1.3},{x:n/3,y:s/2+e/1.3}],stroke_width:.05},a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-n/3,y:-s/2-e/1.3},{x:n/3,y:-s/2-e/1.3}],stroke_width:.05},g=Bo(0,s+.5,.3),I=mWA({pitch:e,width:n,pinNumber:1}),c=t.wave?1:.5,B=t.wave?.7:.3;I.x-=t.wave?o:o*1.7;const C={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:I.x+c/2,y:I.y},{x:I.x-c/2,y:I.y+B/2},{x:I.x-c/2,y:I.y-B/2},{x:I.x+c/2,y:I.y}],stroke_width:.05};return[g,r,a,C,...A]},XCt=t=>{if(t.wave){const e=zCt.parse({...t,fn:"sot457"});return{circuitJson:DWA(e),parameters:e}}const A=jCt.parse(t);return{circuitJson:DWA(A),parameters:A}},$Ct=YA({fn:Y(),num_pins:ei([kA(3),kA(2)]).default(3),p:Y().default("3.8mm"),id:Y().default("1.25mm"),od:Y().default("2.35mm"),ca:Y().default("14mm").describe("Caliper axis (width or diameter of the potentiometer body or adjustment knob)"),w:Y().default("5.35mm"),h:Y().default("4mm"),string:Y().optional()}),Alt=t=>{const{p:A,id:e,od:i,h:o,ca:n}=t,s=Number.parseFloat(o),r=Number.parseFloat(n);return[Fn(1,0,r/4+.3,e,i),Fn(2,s,0,e,i),Fn(3,0,-r/4-.3,e,i)]},elt=t=>{const A=t.string?.match(/^potentiometer_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=$Ct.parse({...t,num_pins:e});let o=[];i.num_pins===3&&(o=Alt(i));const n=Number.parseFloat(i.ca)/2+.15,s=Number.parseFloat(i.w),r=Number.parseFloat(i.od)/2+.35,a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:n-1.75},{x:0,y:n},{x:s,y:n},{x:s,y:r}],stroke_width:.1,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:s,y:-r},{x:s,y:-n},{x:0,y:-n},{x:0,y:-n+1.75}],stroke_width:.1,pcb_silkscreen_path_id:""},I=Number.parseFloat(i.w)/2,c=Bo(I,n+1,.5);return{circuitJson:[...o,a,g,c],parameters:i}},tlt=YA({fn:Y(),p:ie.optional().default("7.5mm"),id:ie.optional().default("1mm"),od:ie.optional().default("2mm"),d:ie.optional().default("10.5mm")}),ilt=(t,A,e,i,o)=>{const n=[],s=[];for(let r=0;r<=50;r++){const a=r/50*Math.PI,g=t+Math.cos(a)*e,I=A+Math.sin(a)*e;g<t-i&&I>=A-o/2&&I<=A+o/2||n.push({x:g,y:I})}for(let r=0;r<=50;r++){const a=Math.PI+r/50*Math.PI,g=t+Math.cos(a)*e,I=A+Math.sin(a)*e;g<t-i&&I>=A-o/2&&I<=A+o/2||s.push({x:g,y:I})}return{topArc:n,bottomArc:s}},olt=t=>{const A=tlt.parse(t),{p:e,id:i,od:o,d:n}=A,s=[Fn(1,-e/2,0,i,o),Fn(2,e/2,0,i,o)],{topArc:r,bottomArc:a}=ilt(0,0,n/2+.1,o/2,o),g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:r,stroke_width:.1,pcb_silkscreen_path_id:""},I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:a,stroke_width:.1,pcb_silkscreen_path_id:""},c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:n/2+.1},{x:0,y:-(n/2+.1)}],stroke_width:.1,pcb_silkscreen_path_id:""},B=-(n/2+.5),C=o/2+1.5,l=.5,Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:B-l,y:C},{x:B+l,y:C}],stroke_width:.1,pcb_silkscreen_path_id:""},E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:B,y:C-l},{x:B,y:C+l}],stroke_width:.1,pcb_silkscreen_path_id:""},h=Bo(0,n/2+1,.5);return{circuitJson:[...s,g,I,c,Q,E,h],parameters:A}},nlt=YA({fn:Y(),num_pins:kA(2).default(2),w:Y().default("6.5mm"),h:Y().default("3mm"),pl:Y().default("1.75mm"),pw:Y().default("2.40mm"),p:Y().default("4.75mm")}),slt=t=>{const A=nlt.parse(t),e=Bo(0,ie.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.3,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.3,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:alt(A).concat(i,e),parameters:A}},rlt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},alt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=rlt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},glt=YA({fn:Y(),num_pins:jA().default(3),w:Y().default("2.45mm"),h:Y().default("2.40mm"),pl:Y().default("0.45mm"),pw:Y().default("0.70mm"),p:Y().default("1mm"),string:Y().optional()}),Ilt=t=>{const A=t.string?.match(/^sot323_(\d+)/),e=A?Number.parseInt(A[1],3):3,i=glt.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:Blt(i),parameters:i};throw new Error("Invalid number of pins")},clt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e,y:.65}:A===2?{x:-e,y:-.65}:{x:e,y:0}},Blt=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=clt({num_pins:t.num_pins,pn:r+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)});A.push(xi(r+1,a,g,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=Bo(0,Number.parseInt(t.h)/2+1,.3),i=Number.parseFloat(t.w)/2-Number.parseFloat(t.pl),o=Number.parseFloat(t.h)/2,n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:o+.3},{x:i,y:o+.3},{x:i,y:o/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:-o-.3},{x:i,y:-o-.3},{x:i,y:-o/2}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,n,s,e]},Clt=YA({fn:Y(),circle:Be().optional(),rect:Be().optional(),square:Be().optional(),pill:Be().optional(),d:ie.optional(),pd:ie.optional(),diameter:ie.optional(),r:ie.optional(),pr:ie.optional(),radius:ie.optional(),w:ie.optional(),pw:ie.optional(),width:ie.optional(),h:ie.optional(),ph:ie.optional(),height:ie.optional(),s:ie.optional(),size:ie.optional(),string:Y().optional()}).transform(t=>{let A="rect";t.circle&&(A="circle"),t.square&&(A="square"),t.rect&&(A="rect"),t.pill&&(A="pill");let e,i,o;return A==="circle"?t.r!==void 0?e=pa(t.r):t.pr!==void 0?e=pa(t.pr):t.radius!==void 0?e=pa(t.radius):t.d!==void 0?e=pa(t.d)/2:t.pd!==void 0?e=pa(t.pd)/2:t.diameter!==void 0?e=pa(t.diameter)/2:e=pa("1mm")/2:(t.w!==void 0?i=pa(t.w):t.pw!==void 0?i=pa(t.pw):t.width!==void 0?i=pa(t.width):t.s!==void 0?i=pa(t.s):t.size!==void 0?i=pa(t.size):i=pa("1mm"),t.h!==void 0?o=pa(t.h):t.ph!==void 0?o=pa(t.ph):t.height!==void 0?o=pa(t.height):A==="square"||A==="rect"?o=i:o=pa("1mm")),{fn:t.fn,shape:A,radius:e,width:i,height:o}}),llt=t=>{const A=Clt.parse(t),{shape:e,radius:i,width:o,height:n}=A;let s,r;return e==="circle"?(s=aWA(1,{x:0,y:0,radius:i}),r=i+.5):e==="pill"?(s=SO(1,0,0,o,n),r=Math.max(o,n)/2+.5):(s=xi(1,0,0,o,n),r=n/2+.5),{circuitJson:[s,Bo(0,r,.2)],parameters:A}},Qlt=YA({fn:Y(),d:ie.optional(),hd:ie.optional(),r:ie.optional(),hr:ie.optional(),pd:ie.optional(),pr:ie.optional(),squarepad:Be().optional().default(!1)}).transform(t=>{let A;t.d!==void 0?A=pa(t.d):t.hd!==void 0?A=pa(t.hd):t.r!==void 0?A=pa(t.r)*2:t.hr!==void 0?A=pa(t.hr)*2:A=pa("1mm");let e;return t.pd!==void 0?e=pa(t.pd):t.pr!==void 0?e=pa(t.pr)*2:e=A*(1.5/1),{fn:t.fn,d:A,pd:e,squarepad:t.squarepad??!1}}),Elt=t=>{const A=Qlt.parse(t),{d:e,pd:i,squarepad:o}=A;return{circuitJson:[o?bO(1,0,0,e,i,i):Fn(1,0,0,e,i),Bo(0,i/2+.5,.2)],parameters:A}},hlt=YA({fn:Y(),num_pins:kA(6).default(6),h:Y().default("1.6mm"),pl:Y().default("1mm"),pw:Y().default("0.7mm"),p:Y().default("0.95mm")}),ult=t=>{const A=hlt.parse(t);return{circuitJson:dlt(A),parameters:A}},SWA=t=>{const{p:A,h:e,pn:i}=t;if(i===1)return{x:-e/2-.5,y:A};if(i===2)return{x:-e/2-.5,y:0};if(i===3)return{x:-e/2-.5,y:-A};if(i===4)return{x:e/2+.5,y:-A};if(i===5)return{x:e/2+.5,y:0};if(i===6)return{x:e/2+.5,y:A};throw new Error("Invalid pin number")},dlt=t=>{const A=[];for(let c=1;c<=t.num_pins;c++){const{x:B,y:C}=SWA({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:c});A.push(xi(c,B,C,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=t.num_pins/2*Number.parseFloat(t.p),i=Number.parseFloat(t.h),o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-e/3,y:i/2+Number.parseFloat(t.p)/1.3},{x:e/3,y:i/2+Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-e/3,y:-i/2-Number.parseFloat(t.p)/1.3},{x:e/3,y:-i/2-Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},s=Bo(0,i+.3,.3),r=SWA({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:1});r.x=r.x-Number.parseFloat(t.pw)*1.5;const a=.7,g=.3,I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:r.x+a/2,y:r.y},{x:r.x-a/2,y:r.y+g/2},{x:r.x-a/2,y:r.y-g/2},{x:r.x+a/2,y:r.y}],stroke_width:.05};return[...A,s,o,n,I]},plt=YA({fn:Y()}),flt=t=>{const A=plt.parse(t),e=[],i=.5-.15,o=1.5,s=.5/2,r=75,a=-37/2;for(let m=0;m<r;m++){const x=m+1;if(x>=24&&x<=31)continue;const F=a-m*s,k=x%2===0,v=o+(k?.25:0),H=.5-v/2,P=xi(x,H,F,v,i);P.layer=k?"bottom":"top",e.push(P)}const g=46*.0254,I=137*.0254,c=261*.0254,B={type:"pcb_cutout",pcb_cutout_id:"",shape:"rect",center:{x:-I/2+o/2,y:a-c},width:I,height:g},C={x:-.5,y:a},l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:C.x-.4,y:C.y},{x:C.x-.7,y:C.y+.3},{x:C.x-.7,y:C.y-.3},{x:C.x-.4,y:C.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"};let Q=1/0,E=-1/0,h=1/0,u=-1/0;const d=(m,x,F=0,k=0)=>{Q=Math.min(Q,m-F/2),E=Math.max(E,m+F/2),h=Math.min(h,x-k/2),u=Math.max(u,x+k/2)};for(const m of e)d(m.x,m.y,m.width,m.height);d(B.center.x,B.center.y,B.width,B.height);for(const m of l.route)d(m.x,m.y);const f=(Q+E)/2,D=(h+u)/2,b=m=>{typeof m.x=="number"&&(m.x-=f),typeof m.y=="number"&&(m.y-=D),m.center&&(m.center.x-=f,m.center.y-=D),Array.isArray(m.route)&&(m.route=m.route.map(x=>({x:x.x-f,y:x.y-D})))};for(const m of e)b(m);return b(B),b(l),{circuitJson:[...e,B,l],parameters:A}};function ylt(t){return t!=null}var wlt=(t,A)=>{if(!A)return t;const e=t.filter(I=>I.type==="pcb_smtpad"||I.type==="pcb_plated_hole"||I.type==="pcb_thtpad");if(e.length===0)return t;let i=1/0,o=-1/0,n=1/0,s=-1/0;const r=(I,c,B=0,C=0)=>{const l=I-B/2,Q=I+B/2,E=c-C/2,h=c+C/2;i=Math.min(i,l),o=Math.max(o,Q),n=Math.min(n,E),s=Math.max(s,h)};for(const I of e)if(I.type==="pcb_smtpad"){const c=I.shape==="circle"?I.radius*2:I.width,B=I.shape==="circle"?I.radius*2:I.height;r(I.x,I.y,c,B)}else if(I.type==="pcb_plated_hole"){const c=I.outer_diameter??I.hole_diameter;r(I.x,I.y,c,c)}else if(I.type==="pcb_thtpad"){const c=I.diameter;r(I.x,I.y,c,c)}let a=0,g=0;switch(A){case"center":a=(i+o)/2,g=(n+s)/2;break;case"bottomleft":a=i,g=n;break;case"bottomcenter":case"centerbottom":a=(i+o)/2,g=n;break;case"topcenter":case"centertop":a=(i+o)/2,g=s;break;case"leftcenter":case"centerleft":a=i,g=(n+s)/2;break;case"rightcenter":case"centerright":a=o,g=(n+s)/2;break;case"pin1":const I=e.find(c=>c.port_hints?.[0]==="1")||e[0];a=I.x,g=I.y;break}if(a===0&&g===0)return t;for(const I of t){if(typeof I.x=="number"&&(I.x-=a),typeof I.y=="number"&&(I.y-=g),I.center&&typeof I.center.x=="number"&&(I.center.x-=a,I.center.y-=g),I.type==="pcb_silkscreen_path")for(const c of I.route)c.x-=a,c.y-=g;I.type==="pcb_silkscreen_text"&&I.anchor_position&&(I.anchor_position.x-=a,I.anchor_position.y-=g)}return t},mlt=t=>{let A=FO();const i=t.replace(/^((?:\d{4}|\d{5}))(?=$|_)/,"res$1").split(/_(?!metric)/).map(o=>{const n=o.match(/([a-z]+)([\(\d\.\+\?].*)?/);if(!n)return null;const[,s,r]=n;return!s||r?.includes("?")?null:{fn:s,v:r}}).filter(ylt);for(const{fn:o,v:n}of i)A=A[o](n);return A.setString(t),A},Dlt=()=>Object.keys(eS),FO=()=>{const t=new Proxy({},{get:(A,e)=>{if(e==="soup"||e==="circuitJson"){if("fn"in A&&eS[A.fn])return()=>{const{circuitJson:i}=eS[A.fn](A);return wlt(i,A.origin)};if(!eS[A.fn])throw new Error(`Invalid footprint function, got "${A.fn}"${A.string?`, from string "${A.string}"`:""}`);return()=>{throw new Error(`No function found for footprinter, make sure to specify .dip, .lr, .p, etc. Got "${e}"`)}}if(e==="json"){if(!eS[A.fn])throw new Error(`Invalid footprint function, got "${A.fn}"${A.string?`, from string "${A.string}"`:""}`);return()=>eS[A.fn](A).parameters}return e==="getFootprintNames"?()=>Object.keys(eS):e==="params"?()=>A:e==="setString"?i=>(A.string=i,t):i=>(Object.keys(A).length===0?`${e}${i}`in eS?(A[`${e}${i}`]=!0,A.fn=`${e}${i}`):(A[e]=!0,A.fn=e,e==="res"||e==="cap"?i&&(typeof i=="string"&&i.includes("_metric")?A.metric=i.split("_metric")[0]:A.imperial=i):A.num_pins=Number.isNaN(Number.parseFloat(i))?void 0:Number.parseFloat(i)):!i&&["w","h","p"].includes(e)||(A[e]=i??!0),t)}});return t};FO.string=mlt,FO.getFootprintNames=Dlt;var Slt=FO,bWA=Symbol("Fragment");function EBA(t,A,...e){const i=e.length?e:A?.children!==void 0?[A.children]:[],o=[],n=(Array.isArray(i)?i:[i]).flat(1/0);for(const s of n)s==null||s===!1||(Array.isArray(s)?o.push(...s):o.push(s));return{type:t,props:(A&&A.children!==void 0?{...A,children:void 0}:A)||{},children:o}}var ht=Symbol("Cuboid"),xWA=Symbol("Cube"),Up=Symbol("Cylinder"),kWA=Symbol("Sphere"),xU=Symbol("RoundedCuboid"),Wi=Symbol("Translate"),BQ=Symbol("Rotate"),sE=Symbol("Union"),UG=Symbol("Subtract"),nI=Symbol("Hull"),fs=Symbol("Colorize"),kU=Symbol("Polygon"),GU=Symbol("ExtrudeLinear"),Lp=Symbol("RoundedCylinder"),Ho=bWA,$A=(t,A,e)=>EBA(t,A),Ot=(t,A,e)=>EBA(t,A),WB=({center:t,width:A,length:e,height:i,heightAboveSurface:o=.15,color:n="#555",taperRatio:s=.12,faceRatio:r=.75,straightHeightRatio:a=.5,includeNotch:g=!0,notchRadius:I,notchPosition:c,notchRotation:B=[0,0,0],notchLength:C=.5,notchWidth:l=.25,chamferSize:Q=0})=>{const E=i*a,h=i-E,u=Math.min(A,e)*s,d=Math.max(A-u,A*r),f=Math.max(e-u,e*r),D=Math.min(A,e)*.12,b=I??D,m={x:0,y:e/2-b*.25,z:i},x=c??m,F=Ot(sE,{children:[Ot(nI,{children:[$A(Wi,{z:.005,children:$A(ht,{size:[d,f,.01]})}),$A(Wi,{z:E,children:$A(ht,{size:[A,e,.01]})})]}),Ot(nI,{children:[$A(Wi,{z:E,children:$A(ht,{size:[A,e,.01]})}),$A(Wi,{z:E+h,children:$A(ht,{size:[d,f,.01]})})]})]}),k=(M,H)=>$A(Wi,{offset:{x:M,y:H,z:0},children:$A(BQ,{rotation:[0,0,Math.PI/4],children:$A(ht,{size:[Q*Math.SQRT2,Q*Math.SQRT2,i*3]})})});let v=F;if(Q>0){const M=A/2,H=e/2;v=Ot(UG,{children:[F,k(M,H),k(-M,H),k(M,-H),k(-M,-H)]})}return $A(fs,{color:n,children:$A(Wi,{offset:t,children:$A(Wi,{offset:{x:0,y:0,z:o},children:g?Ot(UG,{children:[v,$A(Wi,{offset:x,children:$A(BQ,{rotation:B,children:$A(Up,{radius:b,height:l})})})]}):v})})})},blt=t=>Array.from({length:t},(A,e)=>e);function hBA(t,A){if(t.length<2)throw new Error("Stroke must have at least two points");const e=Array.isArray(t[0])?t.map(([I,c])=>({x:I,y:c})):t,i=A/2,o=[],n=[];function s(I,c){const B=c.x-I.x,C=c.y-I.y,l=Math.sqrt(B*B+C*C);return{x:-C/l,y:B/l}}function r(I,c,B){const C={x:I.x+c.x*i*B,y:I.y+c.y*i*B};B>0?o.push(C):n.unshift(C)}const a=s(e[0],e[1]);r(e[0],a,1),r(e[0],a,-1);for(let I=1;I<e.length-1;I++){const c=e[I-1],B=e[I],C=e[I+1],l=s(c,B),Q=s(B,C),E=l.x+Q.x,h=l.y+Q.y,u=Math.sqrt(E*E+h*h);if(u/2>2*i)r(B,l,1),r(B,Q,1),r(B,l,-1),r(B,Q,-1);else{const f=1/u;r(B,{x:E*f,y:h*f},1),r(B,{x:E*f,y:h*f},-1)}}const g=s(e[e.length-2],e[e.length-1]);return r(e[e.length-1],g,1),r(e[e.length-1],g,-1),[...o,...n]}var xlt=t=>{const A=Math.min(...t.map(r=>r.x)),e=Math.max(...t.map(r=>r.x)),i=Math.min(...t.map(r=>r.y)),s=5.47/(Math.max(...t.map(r=>r.y))-i);return t.map(r=>({x:(r.x-A-(e-A)/2)*s,y:(r.y-i)*s}))},klt=xlt([{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}]),GWA=5.47,RO=.5,Glt=({x:t,y:A,z:e})=>{const i=t>0;return Ot(Ho,{children:[$A(Wi,{offset:{x:t+.25/2,y:A,z:e},children:$A(BQ,{rotation:["-90deg",0,"90deg"],children:$A(GU,{height:.25,children:$A(kU,{points:klt.slice().reverse().map(o=>[o.x,o.y])})})})}),$A(Wi,{offset:{x:t,y:A+(i?1:-1),z:e},children:$A(BQ,{rotation:["-90deg","90deg",i?"180deg":"0deg"],children:$A(GU,{height:2,children:$A(kU,{points:hBA([[0,0],[-1,0],[-1,-1]],.25).map(o=>[o.x,o.y])})})})})]})},Flt=({numPins:t=8,pitch:A=2.54,bodyWidth:e=6.4,rowSpacing:i})=>{const o=Math.floor(t/2),n=i??(e>=7?e:e+1.22),s=e>=7?n-1.22:e;return Ot(Ho,{children:[blt(t).map(r=>{const a=r%o,g=(Math.floor(r/o)-.5)*2;return $A(Glt,{x:g*n/2,y:a*A-(o-1)/2*A,z:GWA/2+RO})}),$A(WB,{width:s,length:o*A+.5,height:GWA-RO,heightAboveSurface:RO,center:{x:0,y:0,z:RO}})]})};function Rlt(t,{height:A,padContactLength:e,curveLength:i,bodyDistance:o,steepness:n=10}){i||(i=o*.3);let s=o-e-i;s<0&&(i+=s,s=0);const r=e*.75,a=e+i+(o-e-i)*.25;if(t<=r)return 0;if(t>=a)return A;const g=(t-r)/(a-r);return A/(1+Math.exp(-n*(g-.5)))}var Ko=t=>{const{thickness:A,width:e,padContactLength:i,bodyDistance:o,height:n,rotation:s}=t,r=15,a=Array.from({length:r}).map((I,c)=>c/(r-1)*o).map(I=>[I,Rlt(I,t)]),g=hBA(a,A);return $A(fs,{color:"#fff",children:$A(Wi,{offset:{z:0,y:0,x:0,...t.position},children:$A(BQ,{rotation:["90deg",0,s??0],children:$A(Wi,{offset:{x:0,y:0,z:-e/2},children:$A(GU,{height:e,children:$A(kU,{points:g.map(I=>[I.x,I.y])})})})})})})},Nlt=({pinCount:t,leadLength:A,leadWidth:e,pitch:i,bodyWidth:o})=>{const n=Math.ceil(t/2),s=i*t/2+e/2,r=(n-1)*i/2,a=.25;return Ot(Ho,{children:[Array.from({length:n}).map((g,I)=>$A(Ko,{position:{x:-o/2-A,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+1,height:.8})),Array.from({length:n}).map((g,I)=>$A(Ko,{rotation:Math.PI,position:{x:o/2+A,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+1,height:.8})),$A(WB,{center:{x:0,y:0,z:a/2},width:o-e-1,length:s,height:1.5})]})},Mlt=({pinCount:t,padContactLength:A=.4,leadWidth:e=.2,pitch:i=.65,bodyWidth:o=3})=>{const n=Math.ceil(t/2),s=(n-1)*i/2,r=.2;return Ot(Ho,{children:[Array.from({length:n}).map((a,g)=>$A(Ko,{position:{x:-o/2-A-.3,y:g*i-s,z:r/2},width:e,thickness:r,padContactLength:A,bodyDistance:A+.4,height:.6})),Array.from({length:n}).map((a,g)=>$A(Ko,{rotation:Math.PI,position:{x:o/2+A+.3,y:g*i-s,z:r/2},width:e,thickness:r,padContactLength:A,bodyDistance:A+.4,height:.6})),$A(WB,{center:{x:0,y:0,z:r/2},width:o,length:o,height:1.1,notchRadius:.35,heightAboveSurface:.1,taperRatio:.09})]})},uBA=1,dBA=.5,xM=.5,FU=.2,_lt=uBA-FU*2,FWA=({color:t="#333"})=>Ot(Ho,{children:[$A(ht,{size:[_lt,dBA,xM],offset:[0,0,xM/2],color:t}),$A(ht,{size:[FU,xM,dBA],offset:[uBA/2-FU/2,0,xM/2],color:"#ccc"}),$A(ht,{size:[FU,xM,dBA],offset:[-uBA/2+FU/2,0,xM/2],color:"#ccc"})]}),pBA=1.6,vlt=pBA-.3*2,NO=.3,fBA=.85,kM=.6,RWA=({color:t="#333"})=>Ot(Ho,{children:[$A(ht,{size:[vlt,fBA,kM],offset:[0,0,kM/2],color:t}),$A(ht,{size:[NO,fBA,kM],offset:[pBA/2-NO/2,0,kM/2],color:"#ccc"}),$A(ht,{size:[NO,fBA,kM],offset:[-pBA/2+NO/2,0,kM/2],color:"#ccc"})]}),yBA=2,wBA=1.25,GM=.55,RU=.5,Ult=yBA-RU*2,NWA=({color:t="#333"})=>Ot(Ho,{children:[$A(ht,{size:[Ult,wBA,GM],offset:[0,0,GM/2],color:t}),$A(ht,{size:[RU,wBA,GM],offset:[yBA/2-RU/2,0,GM/2],color:"#ccc"}),$A(ht,{size:[RU,wBA,GM],offset:[-yBA/2+RU/2,0,GM/2],color:"#ccc"})]}),Llt=({pinCount:t,pitch:A,leadWidth:e,padContactLength:i,bodyWidth:o})=>{const n=t/4;A||(A=Hlt(t,o)),i||(i=Ylt(t)),e||(e=Jlt(t,o)),o||(o=A*(n+4));const s=o,r=(n-1)*A/2,a=s+2*i,g=a,I=.8,c=.15,B=(g-o)/2+.5;return Ot(Ho,{children:[Array.from({length:n}).map((C,l)=>$A(Ko,{position:{x:-g/2-.4,y:l*A-r,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:n}).map((C,l)=>$A(Ko,{rotation:Math.PI,position:{x:g/2+.4,y:l*A-r,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:n}).map((C,l)=>$A(Ko,{rotation:Math.PI/2,position:{x:l*A-r,y:-a/2-.4,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:n}).map((C,l)=>$A(Ko,{rotation:-Math.PI/2,position:{x:l*A-r,y:a/2+.4,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),$A(WB,{center:{x:0,y:0,z:0},width:o,length:s,height:1.5,taperRatio:.03,chamferSize:.7,notchPosition:{x:-(s/2-1.5),y:o/2-1.5,z:1.5},notchRadius:1.5/2})]})},Hlt=(t,A)=>{switch(t){case 44:case 64:return .8;case 52:return A===14?1:.65;case 208:return .5;default:return .5}},Ylt=t=>{switch(t){case 32:return .6;case 40:return .6;case 52:case 64:return .65;case 208:return 1.65;default:return .6}},Jlt=(t,A)=>{switch(t){case 44:case 64:return .5;case 52:return A===14?.45:.55;case 208:return .3;default:return .25}},Klt=({numberOfPins:t,pitch:A=2.54,longSidePinLength:e=6,invert:i,faceup:o,rows:n=1})=>{const a=Math.ceil(t/n),g=2.54,I=a*A,c=n>1?(n-1)*g+.63*3:.63*3,B=3,C=-((a-1)/2)*A,l=n>1?-((n-1)*g)/2:0,Q=E=>i||o?-E+2:E;return Ot(Ho,{children:[$A(ht,{color:"#222",size:[I,c,2],center:[0,l,Q(2/2)]}),Array.from({length:t},(E,h)=>{const u=Math.floor(h/a),d=h%a,f=C+d*A,D=-u*g;return Ot(Ho,{children:[!o&&$A(fs,{color:"gold",children:Ot(nI,{children:[$A(ht,{color:"gold",size:[.63,.63,B*.9],center:[f,D,Q(2*.9+2/2)]}),$A(ht,{color:"gold",size:[.63/1.8,.63/1.8,B],center:[f,D,Q(2+2/2)]})]})}),$A(fs,{color:"gold",children:Ot(nI,{children:[$A(ht,{color:"gold",size:[.63,.63,e*.9],center:[f,D,Q(-e/2*.9)]}),$A(ht,{color:"gold",size:[.63/1.8,.63/1.8,e],center:[f,D,Q(-e/2)]})]})})]})})]})},Tlt=t=>{const A=["left","bottom","right","top"],{pin_count:e,pn:i,w:o,h:n,p:s,pl:r}=t,a=e/4,g=A[Math.floor((i-1)/a)],I=(i-1)%a,c=s*(a-1),B=s*(a-1),C=-r/2;switch(g){case"left":return{x:-o/2-C,y:B/2-I*s,o:"vert"};case"bottom":return{x:-c/2+I*s,y:-n/2-C,o:"horz"};case"right":return{x:o/2+C,y:-B/2+I*s,o:"vert"};case"top":return{x:c/2-I*s,y:n/2+C,o:"horz"};default:throw new Error("Invalid pin number")}},qlt=({num_pins:t,cw:A,ccw:e,startingpin:i})=>{const o=[],n=t/4;let s=1;const r={};for(const a of i??[])r[a]=!0;!r.leftside&&!r.topside&&!r.rightside&&!r.bottomside&&(r.leftside=!0),!r.bottompin&&!r.leftpin&&!r.rightpin&&!r.toppin&&(r.leftside?r.toppin=!0:r.topside?r.rightpin=!0:r.rightside?r.bottompin=!0:r.bottomside&&(r.leftpin=!0)),r.leftside&&r.toppin?s=1:r.leftside&&r.bottompin?s=n:r.bottomside&&r.leftpin?s=n+1:r.bottomside&&r.rightpin?s=n*2:r.rightside&&r.bottompin?s=n*2+1:r.rightside&&r.toppin?s=n*3:r.topside&&r.rightpin?s=n*3+1:r.topside&&r.leftpin&&(s=n*4),o.push(-1);for(let a=0;a<t;a++)o[s]=a+1,s++,s>t&&(s=1);return o},Plt=({num_pins:t=16,bodyWidth:A=9,bodyLength:e=9,bodyThickness:i=.8,thermalPadSize:o,padWidth:n=.25,padLength:s=.25,pitch:r=.5,thermalPadThickness:a=.05})=>{const g=qlt({num_pins:t,cw:!0,ccw:!0}),I=[];for(let c=0;c<t;c++){const{x:B,y:C,o:l}=Tlt({pin_count:t,pn:c+1,w:A,h:e,p:r,pl:s});let Q=n,E=s;l==="vert"&&([Q,E]=[E,Q]);const h=g[c+1];I.push({pn:h,x:B,y:C,pw:Q,pl:E})}return Ot(Ho,{children:[$A(fs,{color:"grey",children:$A(ht,{center:{x:0,y:0,z:i/2},size:[A,e,i]})}),I.map((c,B)=>$A(ht,{center:{x:c.x,y:c.y,z:a/2},size:[c.pw,c.pl,a]})),o?.length!==void 0&&o?.width!==void 0&&$A(ht,{center:{x:0,y:0,z:a/2},size:[o.width,o.length,a]})]})},Olt=Plt,Wlt=()=>{const a=1.1999999999999997;return Ot(Ho,{children:[$A(Ko,{rotation:Math.PI,position:{x:2.8/2+a/4,y:-1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),$A(Ko,{rotation:Math.PI,position:{x:2.8/2+a/4,y:1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),$A(Ko,{position:{x:-2.8/2-a/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),$A(Ko,{position:{x:-2.8/2-a/4,y:-1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),$A(Ko,{position:{x:-2.8/2-a/4,y:1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),$A(WB,{center:{x:0,y:0,z:0},width:1.6,length:2.9,height:1.2})]})},Zlt=Wlt,Vlt=({fullWidth:t=2.9,fullLength:A=2.8})=>{const I=(t-1.92)/2+.3;return Ot(Ho,{children:[$A(Ko,{rotation:Math.PI,position:{x:t/2,y:0,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:I,height:.45}),$A(Ko,{position:{x:-t/2,y:-.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:I,height:.45}),$A(Ko,{position:{x:-t/2,y:.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:I,height:.45}),$A(WB,{center:{x:0,y:0,z:0},width:1.92,length:2.9,height:1.1,straightHeightRatio:.45,heightAboveSurface:.05})]})},mBA=.6,DBA=.3,FM=.33,NU=.1,jlt=mBA-NU*2,MWA=({color:t="#333"})=>Ot(Ho,{children:[$A(ht,{size:[jlt,DBA,FM],offset:[0,0,FM/2],color:t}),$A(ht,{size:[NU,DBA,FM],offset:[mBA/2-NU/2,0,FM/2],color:"#ccc"}),$A(ht,{size:[NU,DBA,FM],offset:[-mBA/2+NU/2,0,FM/2],color:"#ccc"})]}),SBA=.4,bBA=.2,RM=.13,MU=.07,zlt=SBA-MU*2,_WA=({color:t="#333"})=>Ot(Ho,{children:[$A(ht,{size:[zlt,bBA,RM],offset:[0,0,RM/2],color:t}),$A(ht,{size:[MU,bBA,RM],offset:[SBA/2-MU/2,0,RM/2],color:"#ccc"}),$A(ht,{size:[MU,bBA,RM],offset:[-SBA/2+MU/2,0,RM/2],color:"#ccc"})]}),xBA=3.2,kBA=1.6,NM=.9,_U=.5,Xlt=xBA-_U*2,vWA=({color:t="#333"})=>Ot(Ho,{children:[$A(ht,{size:[Xlt,kBA,NM],offset:[0,0,NM/2],color:t}),$A(ht,{size:[_U,kBA,NM],offset:[xBA/2-_U/2,0,NM/2],color:"#ccc"}),$A(ht,{size:[_U,kBA,NM],offset:[-xBA/2+_U/2,0,NM/2],color:"#ccc"})]}),GBA=3.2,FBA=2.5,MM=1,vU=.6,$lt=GBA-vU*2,UWA=({color:t="#333"})=>Ot(Ho,{children:[$A(ht,{size:[$lt,FBA,MM],offset:[0,0,MM/2],color:t}),$A(ht,{size:[vU,FBA,MM],offset:[GBA/2-vU/2,0,MM/2],color:"#ccc"}),$A(ht,{size:[vU,FBA,MM],offset:[-GBA/2+vU/2,0,MM/2],color:"#ccc"})]}),RBA=5,NBA=2.5,_M=1.4,UU=.6,AQt=RBA-UU*2,LWA=({color:t="#333"})=>Ot(Ho,{children:[$A(ht,{size:[AQt,NBA,_M],offset:[0,0,_M/2],color:t}),$A(ht,{size:[UU,NBA,_M],offset:[RBA/2-UU/2,0,_M/2],color:"#ccc"}),$A(ht,{size:[UU,NBA,_M],offset:[-RBA/2+UU/2,0,_M/2],color:"#ccc"})]}),MBA=6.3,_BA=3.2,vM=1.8,LU=.8,eQt=MBA-LU*2,HWA=({color:t="#333"})=>Ot(Ho,{children:[$A(ht,{size:[eQt,_BA,vM],offset:[0,0,vM/2],color:t}),$A(ht,{size:[LU,_BA,vM],offset:[MBA/2-LU/2,0,vM/2],color:"#ccc"}),$A(ht,{size:[LU,_BA,vM],offset:[-MBA/2+LU/2,0,vM/2],color:"#ccc"})]}),tQt=({numberOfPins:t,pitch:A=2.54,legsLength:e=3,outerDiameter:i=.945,innerDiameter:o=.945,rows:n=1})=>{const s=o/1.5,r=s*2+i,a=5,g=Math.ceil(t/n),I=2.54,c=(g-1)*A+i+A/2,B=n>1?(n-1)*I+r:r,C=s*1.6,l=-((g-1)/2)*A,Q=n>1?-((n-1)*I)/2:0,E=$A(fs,{color:"#1a1a1a",children:Ot(UG,{children:[$A(ht,{color:"#000",size:[c,B,a],center:[0,Q,a/2]}),Array.from({length:t},(h,u)=>{const d=Math.floor(u/g),f=u%g,D=l+f*A,b=-d*I;return o?$A(Up,{height:a+.1,radius:o/2,center:[D,b,a/2],color:"#222"},u):$A(ht,{size:[C,C,a],center:[D,b,a/2]},u)})]})});return Ot(Ho,{children:[E,Array.from({length:t},(h,u)=>{const d=Math.floor(u/g),f=u%g,D=l+f*A,b=-d*I;return Ot(fs,{color:"silver",children:[Ot(nI,{children:[$A(ht,{color:"silver",size:[s,s,e*.9],center:[D,b,-e/2*.9]}),$A(ht,{color:"silver",size:[s/1.8,s/1.8,e],center:[D,b,-e/2]})]}),$A(ht,{color:"silver",size:[C,C,C*.5],center:[D,b,C/2*.5]})]},u)})]})},iQt=({width:t,length:A,innerDiameter:e=1})=>{const i=t,o=A,n=t*.7,s=e/2.5;return Ot(Ho,{children:[$A(xU,{color:"#1a1a1f",center:[0,0,n/2],size:[o,o,n],roundRadius:.3}),$A(xU,{color:"#f2f2f2",center:[0,0,n+n*.1/2.5],size:[o,o,n*.1],roundRadius:.14}),$A(Up,{color:"#1a1a1f",height:n*.8,radius:i/3,center:[0,0,n+n*.8/2]}),$A(Up,{color:"#1a1a1f",height:n*.2,radius:e/2,center:[o/3,o/3,n+n*.1/2]}),$A(Up,{color:"#1a1a1f",height:n*.2,radius:e/2,center:[-o/3,-o/3,n+n*.1/2]}),$A(Up,{color:"#1a1a1f",height:n*.2,radius:e/2,center:[-o/3,o/3,n+n*.1/2]}),$A(Up,{color:"#1a1a1f",height:n*.2,radius:e/2,center:[o/3,-o/3,n+n*.1/2]}),$A(MO,{thickness:e/3,width:s,horizontalLength:o*.8,verticalLength:n/2,position:{x:-i/2,y:-o/2,z:-n*1.2}}),$A(MO,{thickness:e/3,width:s,horizontalLength:o*.8,verticalLength:n/2,position:{x:-i/2,y:o/2,z:-n*1.2},rotation:Math.PI}),$A(MO,{thickness:e/3,width:s,horizontalLength:o*.8,verticalLength:n/2,position:{x:i/2,y:o/2,z:-n*1.2},rotation:Math.PI}),$A(MO,{thickness:e/3,width:s,horizontalLength:o*.8,verticalLength:n/2,position:{x:i/2+e/3.6,y:-o/2,z:-n*1.2}})]})},MO=t=>{const{thickness:A,width:e,horizontalLength:i,verticalLength:o,rotation:n=0,position:s}=t,r=[[0,i],[-o/3,i/3],[-o/5,i/4],[0,0]],a=hBA(r,A);return $A(fs,{color:"#f2f2f2",children:$A(Wi,{offset:{x:s?.x||0,y:s?.y||0,z:s?.z||0},children:$A(BQ,{rotation:[0,55,n],children:$A(GU,{height:e,children:$A(kU,{points:a.map(g=>[g.y,g.x])})})})})})},oQt=({pinCount:t,leadLength:A,leadWidth:e,pitch:i,bodyWidth:o})=>{const n=Math.ceil(t/2),s=(n-1)*i/2,r=.25,a=1,g=.8,I=A*0,c=i*(n-1)+e+.2,B=o*.55;return Ot(Ho,{children:[Array.from({length:n}).map((C,l)=>$A(Ko,{position:{x:-o/2-I,y:l*i-s,z:r/2},width:e,thickness:r,padContactLength:A/2,bodyDistance:A+.3,height:g})),Array.from({length:n}).map((C,l)=>$A(Ko,{rotation:Math.PI,position:{x:o/2+I,y:l*i-s,z:r/2},width:e,thickness:r,padContactLength:A/2,bodyDistance:A+.3,height:g})),$A(WB,{center:{x:0,y:0,z:r/2},width:B,length:c,height:a})]})},nQt=({pinCount:t,pitch:A,leadWidth:e,leadLength:i,bodyWidth:o,bodyLength:n})=>{const s=t===8?{pitch:.65,leadWidth:.3}:{pitch:.5,leadWidth:.225},r=isNaN(parseFloat(A))?s.pitch:parseFloat(A),a=isNaN(parseFloat(e))?s.leadWidth:parseFloat(e)*.8,g=isNaN(parseFloat(o))?2.6:parseFloat(o)*.8,I=isNaN(parseFloat(n))?2+Number(r)*1.4:parseFloat(n),c=t/2,B=(c-1)*r/2,C=.15,l=.8,Q=4.5,E=(Q-g)/2,h=E*.5;return Ot(Ho,{children:[Array.from({length:c}).map((u,d)=>$A(Ko,{position:{x:-Q/2,y:B-d*r,z:C/2},width:a,thickness:C,padContactLength:h+.05,bodyDistance:E+.1,height:l})),Array.from({length:c}).map((u,d)=>$A(Ko,{rotation:Math.PI,position:{x:Q/2,y:B-d*r,z:C/2},width:a,thickness:C,padContactLength:h+.05,bodyDistance:E+.1,height:l})),$A(WB,{center:{x:0,y:0,z:C/2},width:g,length:I,height:1})]})},sQt=()=>Ot(Ho,{children:[$A(ht,{color:"#ccc",size:[.5,.6,.12],center:[-.725,0,.12/2]}),$A(ht,{color:"#ccc",size:[.5,.6,.12],center:[.725,0,.12/2]}),$A(fs,{color:"#222",children:Ot(sE,{children:[$A(Wi,{z:.3/2,children:$A(ht,{size:[1.65,.8,.3]})}),Ot(nI,{children:[$A(Wi,{z:.3,children:$A(ht,{size:[1.65,.8,.01]})}),$A(Wi,{z:.6,children:$A(ht,{size:[1.65-.2,.8-.2,.01]})})]})]})})]}),rQt=()=>Ot(Ho,{children:[$A(ht,{color:"#ccc",size:[.26,.51,.12],center:[-.325,0,.12/2]}),$A(ht,{color:"#ccc",size:[.26,.51,.12],center:[.325,0,.12/2]}),$A(fs,{color:"#222",children:$A(Wi,{z:.47/2+.02,children:$A(ht,{size:[.98,.58,.47]})})}),$A(ht,{color:"#ccc",size:[.98+.001,.26/2,.26/4],center:[0,.26/2,.47/4]}),$A(ht,{color:"#ccc",size:[.98+.001,.26/2,.26/4],center:[0,-.26/2,.47/4]}),$A(ht,{color:"#ccc",size:[.26/1.5,.58+.001,.26/4],center:[.65/2,0,.47/4]}),$A(ht,{color:"#ccc",size:[.26/1.5,.58+.001,.26/4],center:[-.65/2,0,.47/4]})]}),aQt=()=>{const g=$A(fs,{color:"#1a1a1a",children:Ot(sE,{children:[Ot(nI,{children:[$A(Wi,{z:.13,children:$A(ht,{size:[4,3,.03]})}),$A(Wi,{z:1.15,children:$A(ht,{size:[4.4,3.4,.01]})})]}),Ot(nI,{children:[$A(Wi,{z:1.15,children:$A(ht,{size:[4.4,3.4,.01]})}),$A(Wi,{z:2.3,children:$A(ht,{size:[4,3,.01]})})]})]})}),I=({xDir:c})=>{const l=c*1.78,Q=c*(3.4/2-.2/2+1),E=c*(3.4/2-.2/2),h=Math.abs(E-Q),u=(Q+E)/2;return $A(fs,{color:"#c0c0c0",children:Ot(sE,{children:[$A(ht,{size:[2.3*.8,1.45,.2],center:[l,0,.2/2]}),$A(ht,{size:[.2,1.45,1.14],center:[Q,0,1.14/2+.2]}),$A(ht,{size:[h,1.45,.2],center:[u,0,.2/2+1.14]})]})})};return Ot(Ho,{children:[$A(I,{xDir:1}),$A(I,{xDir:-1}),g]})},gQt=()=>{const g=$A(fs,{color:"#1a1a1a",children:Ot(sE,{children:[Ot(nI,{children:[$A(Wi,{z:.13,children:$A(ht,{size:[4,3,.03]})}),$A(Wi,{z:1.15,children:$A(ht,{size:[4.4,3.4,.01]})})]}),Ot(nI,{children:[$A(Wi,{z:1.15,children:$A(ht,{size:[4.4,3.4,.01]})}),$A(Wi,{z:2.3,children:$A(ht,{size:[4,3,.01]})})]})]})}),I=({xDir:c})=>{const l=c*1.78,Q=c*(3.4/2-.2/2+1),E=c*(3.4/2-.2/2),h=Math.abs(E-Q),u=(Q+E)/2;return $A(fs,{color:"#c0c0c0",children:Ot(sE,{children:[$A(ht,{size:[2.3*.8,1.45,.2],center:[l,0,.2/2]}),$A(ht,{size:[.2,1.45,1.14],center:[Q,0,1.14/2+.2]}),$A(ht,{size:[h,1.45,.2],center:[u,0,.2/2+1.14]})]})})};return Ot(Ho,{children:[$A(I,{xDir:1}),$A(I,{xDir:-1}),g]})},IQt=()=>{const g=$A(fs,{color:"#1a1a1a",children:Ot(sE,{children:[Ot(nI,{children:[$A(Wi,{z:.21000000000000002,children:$A(ht,{size:[6.3999999999999995,5.6,.03]})}),$A(Wi,{z:1.15,children:$A(ht,{size:[6.8,6,.01]})})]}),Ot(nI,{children:[$A(Wi,{z:1.15,children:$A(ht,{size:[6.8,6,.01]})}),$A(Wi,{z:2.3,children:$A(ht,{size:[6.3999999999999995,5.6,.01]})})]})]})}),I=({xDir:c})=>{const l=c*3.08,Q=c*(6/2-.2/2+1),E=c*(6/2-.2/2),h=Math.abs(E-Q),u=(Q+E)/2;return $A(fs,{color:"#c0c0c0",children:Ot(sE,{children:[$A(ht,{size:[2.3*.8,2.95,.2],center:[l,0,.2/2]}),$A(ht,{size:[.2,2.95,1.14],center:[Q,0,1.14/2+.2]}),$A(ht,{size:[h,2.95,.2],center:[u,0,.2/2+1.14]})]})})};return Ot(Ho,{children:[$A(I,{xDir:1}),$A(I,{xDir:-1}),g]})},cQt=()=>{const c=$A(fs,{color:"#222",children:Ot(sE,{children:[$A(Wi,{z:.27,children:$A(ht,{size:[2.9,1.9,.54]})}),Ot(nI,{children:[$A(Wi,{z:.54,children:$A(ht,{size:[2.9,1.9,.01]})}),$A(Wi,{z:1.08,children:$A(ht,{size:[2.6999999999999997,1.7,.01]})})]})]})});return Ot(Ho,{children:[$A(ht,{color:"#ccc",size:[1,1.2,.25],center:[-1.3,0,.25/2]}),$A(ht,{color:"#ccc",size:[1,1.2,.25],center:[1.3,0,.25/2]}),c]})},BQt=()=>Ot(Ho,{children:[$A(ht,{color:"#ccc",size:[1,.6,.12],center:[-1.3,0,.12/2]}),$A(ht,{color:"#ccc",size:[1,.6,.12],center:[1.3,0,.12/2]}),$A(fs,{color:"#222",children:Ot(sE,{children:[$A(Wi,{z:.55/2,children:$A(ht,{size:[2.7,1.6,.55]})}),Ot(nI,{children:[$A(Wi,{z:.55,children:$A(ht,{size:[2.7,1.6,.01]})}),$A(Wi,{z:1.1,children:$A(ht,{size:[2.7-.2,1.6-.2,.01]})})]})]})})]}),CQt=()=>Ot(Ho,{children:[$A(ht,{color:"#ccc",size:[1,.9,.2],center:[-1.3,0,.2/2]}),$A(ht,{color:"#ccc",size:[1,.9,.2],center:[1.3,0,.2/2]}),$A(fs,{color:"#222",children:Ot(sE,{children:[$A(Wi,{z:.2/2,children:$A(ht,{size:[2.75,1.8,.2]})}),Ot(nI,{children:[$A(Wi,{z:.2,children:$A(ht,{size:[2.75,1.8,.01]})}),$A(Wi,{z:1,children:$A(ht,{size:[2.75-.4,1.8-.4,.01]})})]})]})}),$A(ht,{color:"#777",size:[.2,1.8-.4,.01],center:[-1.3+.4,0,1]})]}),lQt=()=>Ot(Ho,{children:[$A(ht,{color:"#ccc",size:[.9,.9,.2],center:[-1.225,0,.2/2]}),$A(ht,{color:"#ccc",size:[.9,.9,.2],center:[1.225,0,.2/2]}),$A(fs,{color:"#222",children:Ot(sE,{children:[Ot(nI,{children:[$A(Wi,{z:.2,children:$A(ht,{size:[2.6-.1/2,1.7-.1/2,.01]})}),$A(Wi,{z:.01,children:$A(ht,{size:[2.6-.1,1.7-.1,.01]})})]}),Ot(nI,{children:[$A(Wi,{z:.2,children:$A(ht,{size:[2.6,1.7,.01]})}),$A(Wi,{z:1,children:$A(ht,{size:[2.6-.4,1.7-.4,.01]})})]})]})}),$A(ht,{color:"#777",size:[.2*2.7,1.7-.4,.02],center:[-1.225+.4,0,1]})]}),QQt=()=>Ot(Ho,{children:[$A(ht,{color:"#ccc",size:[.9,1.75,.2],center:[-1.825,0,.2/2]}),$A(ht,{color:"#ccc",size:[.9,1.75,.2],center:[1.825,0,.2/2]}),$A(fs,{color:"#222",children:Ot(sE,{children:[Ot(nI,{children:[$A(Wi,{z:.2,children:$A(ht,{size:[3.8-.05/2,2.5-.05/2,.01]})}),$A(Wi,{z:.01,children:$A(ht,{size:[3.8-.05,2.5-.05,.01]})})]}),Ot(nI,{children:[$A(Wi,{z:.2,children:$A(ht,{size:[3.8,2.5,.01]})}),$A(Wi,{z:1,children:$A(ht,{size:[3.8-.4,2.5-.4,.01]})})]})]})}),$A(ht,{color:"#777",size:[.2*2.7,2.5-.4,.02],center:[-1.825+.4,0,1]})]}),EQt=()=>Ot(Ho,{children:[$A(ht,{color:"#ccc",size:[.4,.25,.14],center:[-.4,0,.14/2]}),$A(ht,{color:"#ccc",size:[.4,.25,.14],center:[.4,0,.14/2]}),$A(fs,{color:"#222",children:Ot(sE,{children:[$A(Wi,{z:.14/2,children:$A(ht,{size:[.8,.6,.14]})}),Ot(nI,{children:[$A(Wi,{z:.14,children:$A(ht,{size:[.8,.6,.01]})}),$A(Wi,{z:.37,children:$A(ht,{size:[.8-.1,.6-.1,.01]})})]})]})})]}),hQt=()=>{const I=3.0999999999999996;return Ot(Ho,{children:[$A(Ko,{rotation:Math.PI,position:{x:6.6/2+I/4,y:0,z:.25/2},width:3,thickness:.25,padContactLength:.5,bodyDistance:I,height:.75}),$A(Ko,{position:{x:-6.6/2-I/4,y:0,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:I,height:.75}),$A(Ko,{position:{x:-6.6/2-I/4,y:-2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:I,height:.75}),$A(Ko,{position:{x:-6.6/2-I/4,y:2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:I,height:.75}),$A(WB,{center:{x:0,y:0,z:0},width:3.5,length:6.5,height:1.7,includeNotch:!1,taperRatio:.06,straightHeightRatio:.45})]})},uQt=()=>Ot(Ho,{children:[Array.from({length:16}).map((C,l)=>$A(Ko,{position:{x:-10.5/2,y:l*.5-3.75,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Array.from({length:16}).map((C,l)=>$A(Ko,{rotation:Math.PI,position:{x:10.5/2,y:l*.5-3.75,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Array.from({length:16}).map((C,l)=>$A(Ko,{rotation:Math.PI/2,position:{x:l*.5-3.75,y:-10.5/2,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Array.from({length:16}).map((C,l)=>$A(Ko,{rotation:-Math.PI/2,position:{x:l*.5-3.75,y:10.5/2,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),$A(WB,{center:{x:0,y:0,z:0},width:9,length:9,height:1.2,chamferSize:.7,taperRatio:.05,notchPosition:{x:-3.5,y:3.5,z:1.2},notchRadius:1.2/2})]}),dQt=uQt,pQt=()=>{const g=.7999999999999998;return Ot(Ho,{children:[$A(Ko,{rotation:Math.PI,position:{x:2.05/2+g/4,y:0,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:g,height:.65}),$A(Ko,{position:{x:-2.05/2-g/4,y:-.65,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:g,height:.65}),$A(Ko,{position:{x:-2.05/2-g/4,y:.65,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:g,height:.65}),$A(WB,{center:{x:0,y:0,z:0},width:1.25,length:2,height:.9,includeNotch:!1,taperRatio:.06,straightHeightRatio:.7,heightAboveSurface:.05})]})},fQt=({pinCount:t,pitch:A,leadWidth:e,padContactLength:i,bodyWidth:o})=>{const n=t/4;if(n!==Math.floor(n))throw new Error(`LQFP pinCount must be divisible by 4, got ${t}`);A||(A=.5),i||(i=.6),e||(e=.22),o||(o=A*(n+4));const s=o,r=(n-1)*A/2,a=s+3.3*i,g=a,I=.8,c=.2,B=(g-o)/2+.4;return Ot(Ho,{children:[Array.from({length:n}).map((C,l)=>$A(Ko,{position:{x:-g/2-.36,y:l*A-r,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:n}).map((C,l)=>$A(Ko,{rotation:Math.PI,position:{x:g/2+.36,y:l*A-r,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:n}).map((C,l)=>$A(Ko,{rotation:Math.PI/2,position:{x:l*A-r,y:-a/2-.36,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:n}).map((C,l)=>$A(Ko,{rotation:-Math.PI/2,position:{x:l*A-r,y:a/2+.36,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),$A(WB,{center:{x:0,y:0,z:0},width:o,length:s,height:1.5,heightAboveSurface:.1,taperRatio:.04,chamferSize:.7,notchPosition:{x:-(s/2-1.5),y:s/2-1.5,z:1.5},notchRadius:1.5/2})]})},yQt=()=>{const i=.20900000000000002,o=.1,n=.3,s=.1,r=.2;return Ot(Ho,{children:[$A(fs,{color:"#222",children:Ot(sE,{children:[$A(ht,{size:[.85,1.2,i],center:[0,0,i/2]}),Ot(nI,{children:[$A(Wi,{z:i,children:$A(ht,{size:[.85,1.2,.01]})}),$A(Wi,{z:.38,children:$A(ht,{size:[.85-o,1.2-o,.01]})})]})]})}),$A(ht,{color:"#ccc",size:[n,.25,s],center:[.55,0,s/2]}),$A(ht,{color:"#ccc",size:[n,r,s],center:[-.55,.4,s/2]}),$A(ht,{color:"#ccc",size:[n,r,s],center:[-.55,-.4,s/2]})]})},wQt=({num_pins:t,bodyWidth:A=5.3,bodyLength:e=5.3,bodyThickness:i=1,thermalPadSize:o,padWidth:n=e/5.3*.6,padLength:s=e/5.3*1,pitch:r=.5,thermalPadThickness:a=.2})=>{const g=[],I=Math.floor(t/2),c=r*(I-1);for(let B=0;B<t;B++){const C=B<I?"left":"right",l=B%I,Q=c/2-l*r,E=s,h=n,u=C==="left"?-A/2+E/2:A/2-E/2,d=B+1;g.push({pinNumber:d,x:u,y:Q,padSizeX:E,padSizeY:h})}return Ot(Ho,{children:[$A(WB,{center:{x:0,y:0,z:0},width:A,length:e,height:i,heightAboveSurface:0,color:"grey",chamferSize:.2,taperRatio:0,notchPosition:{x:-(A/2-s),y:e/2-s,z:i}}),g.map((B,C)=>$A(ht,{center:[B.x,B.y,a/2],size:[B.padSizeX,B.padSizeY,a]})),o?.length!==void 0&&o?.width!==void 0&&$A(ht,{center:[0,0,a/2],size:[o.width,o.length,a]})]})},mQt=({bodyLength:t=10.2,bodyWidth:A=4.65,bodyHeight:e=13.46,leadSpacing:i=5,leadDiameter:o=.8,leadLength:n=12.7,color:s="#ddd",leadColor:r="#b87333"})=>{const a=t/2,g=A/2,I=a-g,c=i/2,B=.85;return Ot(Ho,{children:[Ot(fs,{color:s,children:[Ot(nI,{children:[$A(Lp,{height:e,roundRadius:.5,radius:g,center:[-I,0,e]}),$A(Lp,{height:e,roundRadius:.5,radius:g,center:[I,0,e]})]}),Ot(nI,{children:[$A(Lp,{height:B,roundRadius:.1,radius:g+.85,center:[-I,0,e/2+B/2]}),$A(Lp,{height:B,roundRadius:.1,radius:g+.85,center:[I,0,e/2+B/2]})]})]}),Ot(fs,{color:r,children:[$A(Up,{height:n+e/2,radius:o/2,center:[-c+.06,0,-(n/2)+e/2]}),$A(Up,{height:n+e/2,radius:o/2,center:[c-.06,0,-(n/2)+e/2]})]})]})},DQt=({bodyLength:t=1.4,bodyDiameter:A=1.1,color:e="#3a3a3aff",contactColor:i="#c6c6c6",cathodeIdentification:o="#111"})=>Ot(Ho,{children:[$A(fs,{color:e,children:Ot(BQ,{rotation:[0,"90deg",0],children:[$A(xU,{size:[A,A,t-.2],roundRadius:.2,center:[-A/2,0,.05]}),$A(Up,{height:.2/2,radius:A/2-.2,center:[-A/2,0,-t/2+.2/2]})]})}),$A(fs,{color:o,children:$A(BQ,{rotation:[0,"90deg",0],children:$A(xU,{size:[A*1.01,A*1.01,t/3],roundRadius:.2,center:[-A/2,0,-t/4+.1]})})}),$A(fs,{color:i,children:$A(BQ,{rotation:[0,"90deg",0],children:$A(Lp,{height:.2,radius:A/2,roundRadius:.2/3,center:[-A/2,0,-t/2]})})}),$A(fs,{color:i,children:$A(BQ,{rotation:[0,"90deg",0],children:$A(Lp,{height:.2,radius:A/2,roundRadius:.2/3,center:[-A/2,0,t/2]})})})]}),SQt=({bodyLength:t=3.5,bodyDiameter:A=1.5,color:e="#3a3a3aff",contactColor:i="#c6c6c6"})=>Ot(Ho,{children:[$A(fs,{color:e,children:$A(BQ,{rotation:[0,"90deg",0],children:$A(Lp,{height:t,radius:A/2,roundRadius:.3,center:[-A/2,0,0]})})}),$A(fs,{color:i,children:$A(BQ,{rotation:[0,"90deg",0],children:$A(Lp,{height:.5,radius:A/2,roundRadius:.2,center:[-A/2,0,-t/2]})})}),$A(fs,{color:i,children:$A(BQ,{rotation:[0,"90deg",0],children:$A(Lp,{height:.5,radius:A/2,roundRadius:.2,center:[-A/2,0,t/2]})})})]}),bQt=({bodyLength:t=3.9,bodyDiameter:A=2.5,color:e="#3a3a3aff",contactColor:i="#c6c6c6"})=>Ot(Ho,{children:[$A(fs,{color:e,children:$A(BQ,{rotation:[0,"90deg",0],children:$A(Lp,{height:t,radius:A/2,roundRadius:.3,center:[-A/2,0,0]})})}),$A(fs,{color:i,children:$A(BQ,{rotation:[0,"90deg",0],children:$A(Lp,{height:.55,radius:A/2,roundRadius:.2,center:[-A/2,0,-t/2]})})}),$A(fs,{color:i,children:$A(BQ,{rotation:[0,"90deg",0],children:$A(Lp,{height:.55,radius:A/2,roundRadius:.2,center:[-A/2,0,t/2]})})})]}),xQt=({pinCount:t,padContactLength:A=.6,leadWidth:e=.41,pitch:i=1.27})=>{if(t%2!==0)throw new Error("MS012 pinCount must be even");const o=t/2,n=4.9,s=3.9,r=(o-1)*i/2,a=.2;return Ot(Ho,{children:[Array.from({length:o}).map((g,I)=>$A(Ko,{position:{x:-s/2-A-.3,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),Array.from({length:o}).map((g,I)=>$A(Ko,{rotation:Math.PI,position:{x:s/2+A+.3,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),$A(WB,{center:{x:0,y:0,z:a/2},width:s,length:n,height:1.55,notchPosition:{x:-.95,y:n/2-1,z:1.55},heightAboveSurface:.17,taperRatio:.09})]})},kQt=({pinCount:t=16,padContactLength:A=.6,leadWidth:e=.41,pitch:i=1.27})=>{if(t!==16)throw new Error("MS013 only supports 16 pins");const o=t/2,n=7.5,s=10.3,r=(o-1)*i/2,a=.2;return Ot(Ho,{children:[Array.from({length:o}).map((g,I)=>$A(Ko,{position:{x:-n/2-A-.3,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),Array.from({length:o}).map((g,I)=>$A(Ko,{rotation:Math.PI,position:{x:n/2+A+.3,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),$A(WB,{center:{x:0,y:0,z:a/2},width:n,length:s,height:1.1,notchPosition:{x:-2.25,y:s/2-1.5,z:1.1},heightAboveSurface:.17,taperRatio:.05})]})},GQt=()=>{const Q=7.050000000000001,E=24.95+6.5/2;return $A(Wi,{center:[0,0,1],children:Ot(Ho,{children:[Ot(BQ,{rotation:[0,55,-55],children:[Ot(UG,{children:[$A(ht,{color:"#ccc",size:[6.5+.1,9.9,1.3],center:[E,0,1.3-2]}),$A(Up,{color:"black",center:[E,0,1.3-2],radius:3/2,height:1.3*1.2})]}),$A(fs,{color:"#222",children:$A(WB,{width:9.9,length:9.9,height:4.5,center:{x:20,y:0,z:-2.4},includeNotch:!1,straightHeightRatio:.3,taperRatio:.04,heightAboveSurface:1})})]}),$A(BQ,{rotation:[0,55,55],children:Array.from({length:3}).map((h,u)=>{const d=Q,f=(u-1)*2.7,D=-.5-.6;return Ot(fs,{color:"gold",children:[Ot(nI,{children:[$A(Wi,{center:[15.05-4.5/2+.1,f,D],children:$A(ht,{size:[4.5,.81+1,.5]})}),$A(Wi,{center:[15.05-4.5/2-1+.1,f,D],children:$A(ht,{size:[4.5,.81,.5]})})]}),$A(Wi,{center:[d,f,D],children:$A(ht,{size:[16+.1,.81,.5]})})]},`prong-${u}`)})})]})})},FQt=()=>{const g=1.1999999999999997;return Ot(Ho,{children:[$A(Ko,{rotation:Math.PI,position:{x:2.8/2+g/4,y:-.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),$A(Ko,{rotation:Math.PI,position:{x:2.8/2+g/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),$A(Ko,{rotation:Math.PI,position:{x:2.8/2+g/4,y:.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),$A(Ko,{position:{x:-2.8/2-g/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),$A(Ko,{position:{x:-2.8/2-g/4,y:-.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),$A(Ko,{position:{x:-2.8/2-g/4,y:.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),$A(WB,{center:{x:0,y:0,z:0},width:1.6,length:2.9,height:1.2,straightHeightRatio:.6,notchPosition:{x:-.4,y:1.2/2+.4,z:1.2+.05},notchRadius:.1})]})},RQt=()=>Ot(Ho,{children:[$A(WB,{center:{x:0,y:0,z:0},width:.8,length:1,height:.37,heightAboveSurface:0,color:"#1a1a1a",taperRatio:.15,straightHeightRatio:0,notchPosition:{x:-.8/4,y:.7/2.2,z:.37+.1}}),[0,1,2].map(g=>{const I=-.35+g*.35;return $A(ht,{center:[-.8/2+.19/2-.1,I,.12/2],size:[.19,.15,.12]})}),[0,1,2].map(g=>{const I=-.35+g*.35;return $A(ht,{center:[.8/2-.19/2+.1,I,.12/2],size:[.19,.15,.12]})})]}),NQt=()=>{const s="#222",a=[.43,.4,1.32],g=[.43,.4,.25],I=[0,0,-.66],c=[0,0,-1.32],B=[0,1.28,-2.72],C=[0,1.28,-8.9],l=-7.5;return Ot(Wi,{center:[0,1,10.5],children:[$A(fs,{color:s,children:Ot(UG,{children:[$A(Wi,{center:[0,0,2.25],children:$A(Up,{radius:2.4,height:4.5})}),$A(Wi,{center:[0,-1.8499999999999999,2.25],children:$A(ht,{size:[2.4*2,1.1,4.5+.2]})})]})}),$A(Wi,{center:I,children:$A(ht,{size:a})}),Ot(nI,{children:[$A(Wi,{center:c,children:$A(ht,{size:g})}),$A(Wi,{center:B,children:$A(ht,{size:g})})]}),$A(Wi,{center:C,children:$A(ht,{size:[.43,.4,12.2]})}),$A(Wi,{center:[1.3,0,l],children:$A(ht,{size:[.43,.4,15]})}),$A(Wi,{center:[-1.3,0,l],children:$A(ht,{size:[.43,.4,15]})})]})},MQt=()=>Ot(Ho,{children:[$A(Ko,{rotation:Math.PI,position:{x:2/2+.75/4,y:-.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),$A(Ko,{rotation:Math.PI,position:{x:2/2+.75/4,y:0,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),$A(Ko,{rotation:Math.PI,position:{x:2/2+.75/4,y:.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),$A(Ko,{position:{x:-2/2-.75/4,y:0,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),$A(Ko,{position:{x:-2/2-.75/4,y:-.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),$A(Ko,{position:{x:-2/2-.75/4,y:.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),$A(WB,{center:{x:0,y:0,z:0},width:1.25,length:2,height:1.1,straightHeightRatio:.6,notchPosition:{x:-.375,y:1.1/2+.2,z:1.1},heightAboveSurface:.1})]}),_Qt=MQt,vQt=()=>Ot(Ho,{children:[$A(WB,{center:{x:0,y:0,z:.05},width:1,length:1.45,height:.5,heightAboveSurface:0,color:"#1a1a1a",taperRatio:0,includeNotch:!1}),[0,1,2].map(r=>{const a=-.5+r*.5;return $A(ht,{center:[-1/2+.3/2,a,.05/2],size:[.3,.2,.05]})}),[0,1,2].map(r=>{const a=-.5+r*.5;return $A(ht,{center:[1/2-.3/2,a,.05/2],size:[.3,.2,.05]})})]}),UQt=()=>Ot(Ho,{children:[$A(Ko,{position:{x:-2.5/2,y:0,z:.175/2},width:.3,thickness:.175,padContactLength:.3,bodyDistance:.45,height:.7}),$A(Ko,{rotation:Math.PI,position:{x:2.5/2,y:0,z:.175/2},width:.3,thickness:.175,padContactLength:.3,bodyDistance:.45,height:.7}),$A(fs,{color:"#222",children:$A(WB,{center:{x:0,y:0,z:0},width:1.7,length:1.25,height:.95,includeNotch:!1,taperRatio:.06,straightHeightRatio:.7,heightAboveSurface:.05})}),$A(ht,{color:"#777",size:[1.7/3,1.25-.075,.02],center:[-.85*2/3+.035,0,.95+.05]})]}),LQt=()=>Ot(Ho,{children:[$A(ht,{color:"#ccc",size:[.4,.325,.175],center:[-1.05,0,.175/2]}),$A(ht,{color:"#ccc",size:[.4,.325,.175],center:[1.05,0,.175/2]}),$A(fs,{color:"#222",children:Ot(sE,{children:[$A(Wi,{z:.175/2,children:$A(ht,{size:[1.7,1.25,.175]})}),Ot(nI,{children:[$A(Wi,{z:.175,children:$A(ht,{size:[1.7,1.25,.01]})}),$A(Wi,{z:.725,children:$A(ht,{size:[1.7-.2,1.25-.2,.01]})})]})]})}),$A(ht,{color:"#777",size:[1.7/3,1.25-.2,.02],center:[-1.05+1.7/4.4+.2,0,.725]})]}),HQt=()=>{const s=-1.0474999999999999,r=1.775/2+.4/2-.04;return Ot(Ho,{children:[$A(ht,{color:"#ccc",size:[.4,.325,.13],center:[s,0,.13/2]}),$A(ht,{color:"#ccc",size:[.4,.325,.13],center:[r,0,.13/2]}),$A(fs,{color:"#222",children:$A(WB,{width:1.775,length:1.25,height:.725,center:{x:0,y:0,z:0},heightAboveSurface:0,straightHeightRatio:.7,taperRatio:.06,includeNotch:!1})}),$A(ht,{color:"#777",size:[1.775/3,1.25-.05,.02],center:[s+1.775/4.4+.2,0,.725]})]})},YQt=({footprint:t})=>{const A=Slt.string(t).json();switch(A.fn){case"dip":return $A(Flt,{numPins:A.num_pins,pitch:A.p,bodyWidth:A.w});case"tssop":return $A(Nlt,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"msop":return $A(Mlt,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"vssop":return $A(nQt,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w,bodyLength:A.h});case"qfp":return $A(Llt,{pinCount:A.num_pins,pitch:A.p,leadWidth:A.pw,padContactLength:A.pl,bodyWidth:A.w});case"tqfp":return $A(dQt,{});case"lqfp":return $A(fQt,{pinCount:A.num_pins});case"qfn":{const o=typeof A.thermalpad?.x=="number"&&typeof A.thermalpad?.y=="number";return $A(Olt,{num_pins:A.num_pins,bodyWidth:A.w,bodyLength:A.h,pitch:A.p,padLength:A.pl,padWidth:A.pw,thermalPadSize:o?{width:A.thermalpad.x,length:A.thermalpad.y}:void 0})}case"dfn":{const o=typeof A.thermalpad?.x=="number"&&typeof A.thermalpad?.y=="number";return $A(wQt,{num_pins:A.num_pins,bodyWidth:A.w,bodyLength:A.h,pitch:A.p,padLength:A.pl,padWidth:A.pw,thermalPadSize:o?{width:A.thermalpad.x,length:A.thermalpad.y}:void 0})}case"pinrow":{const o=t.match(/_rows(\d+)/),n=o&&o[1]?parseInt(o[1],10):1;if(A.male)return $A(Klt,{numberOfPins:A.num_pins,pitch:A.p,invert:A.invert,faceup:A.faceup,rows:n});if(A.female)return $A(tQt,{numberOfPins:A.num_pins,pitch:A.p,rows:n})}case"cap":switch(A.imperial){case"0402":return $A(FWA,{color:"#856c4d"});case"0603":return $A(RWA,{color:"#856c4d"});case"0805":return $A(NWA,{color:"#856c4d"});case"0201":return $A(MWA,{color:"#856c4d"});case"01005":return $A(_WA,{color:"#856c4d"});case"1206":return $A(vWA,{color:"#856c4d"});case"1210":return $A(UWA,{color:"#856c4d"});case"2010":return $A(LWA,{color:"#856c4d"});case"2512":return $A(HWA,{color:"#856c4d"})}case"sot235":return $A(Zlt,{});case"sot457":return $A(FQt,{});case"sot223":return $A(hQt,{});case"sot23w":return $A(Vlt,{});case"sot323":return $A(pQt,{});case"sod323f":return $A(LQt,{});case"sod323fl":return $A(HQt,{});case"sot363":return $A(_Qt,{});case"sot886":return $A(vQt,{});case"sot963":return $A(RQt,{});case"pushbutton":return $A(iQt,{width:A.w,length:A.h,innerDiameter:A.id});case"soic":return $A(oQt,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"sod523":return $A(sQt,{});case"sod882":return $A(rQt,{});case"sma":return $A(aQt,{});case"smb":return $A(gQt,{});case"smc":return $A(IQt,{});case"smf":return $A(cQt,{});case"sod123f":return $A(BQt,{});case"sod123fl":return $A(CQt,{});case"sod123w":return $A(lQt,{});case"sod128":return $A(QQt,{});case"sod323":return $A(UQt,{});case"sod923":return $A(EQt,{});case"hc49":return $A(mQt,{});case"micromelf":return $A(DQt,{});case"minimelf":return $A(SQt,{});case"melf":return $A(bQt,{});case"ms012":return $A(xQt,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p});case"ms013":return $A(kQt,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p});case"sot723":return $A(yQt,{});case"to220":return $A(GQt,{});case"to92":return $A(NQt,{})}const e=t.match(/_color\(([^)]+)\)/),i=e?e[1]:void 0;switch(A.imperial){case"0402":return $A(FWA,{color:i});case"0603":return $A(RWA,{color:i});case"0805":return $A(NWA,{color:i});case"0201":return $A(MWA,{color:i});case"01005":return $A(_WA,{color:i});case"1206":return $A(vWA,{color:i});case"1210":return $A(UWA,{color:i});case"2010":return $A(LWA,{color:i});case"2512":return $A(HWA,{color:i})}return null},JQt=t=>t&&typeof t=="object"&&"type"in t,UM=t=>{if(typeof t=="number")return t;if(typeof t=="string"){const A=/^(-?\d+(?:\.\d+)?)\s*deg$/i.exec(t);if(A)return parseFloat(A[1])*Math.PI/180;const e=Number(t);if(!Number.isNaN(e))return e}return 0},KQt=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 um(t,A,e){const{jscad:{primitives:i,booleans:o,hulls:n,geometries:s,extrusions:r,transforms:a}}=e;if(t==null||t===!1)return[];if(Array.isArray(t))return t.flatMap(B=>um(B,A,e));if(!JQt(t))return[];const{type:g,props:I,children:c}=t;if(g===bWA)return(c??[]).flatMap(B=>um(B,A,e));if(g===fs){const B=I?.color;return(c??[]).flatMap(C=>um(C,B??A,e))}if(g===Wi){const B=KQt(I?.offset??I?.center??{x:I?.x,y:I?.y,z:I?.z});return(c??[]).flatMap(l=>um(l,A,e)).map(({geom:l,color:Q})=>({geom:a.translate(B,l),color:Q??A}))}if(g===BQ){const B=Array.isArray(I?.rotation)?[UM(I.rotation[0]),UM(I.rotation[1]),UM(I.rotation[2])]:[UM(I?.x??0),UM(I?.y??0),UM(I?.z??0)];return(c??[]).flatMap(l=>um(l,A,e)).map(({geom:l,color:Q})=>({geom:a.rotateZ(B[2],a.rotateY(B[1],a.rotateX(B[0],l))),color:Q}))}if(g===sE||g===UG||g===nI){const B=(c??[]).flatMap(l=>um(l,A,e)).map(l=>l.geom);if(B.length===0)return[];let C;return g===sE?C=o.union(B):g===UG?C=o.subtract(B[0],B.slice(1)):C=n.hull(B),[{geom:C,color:A}]}if(g===kU){const B=I?.points??[];return[{geom:s.geom2.fromPoints(B),color:A??I?.color}]}if(g===GU){const B=(c??[]).flatMap(E=>um(E,A,e)).map(E=>E.geom);if(B.length===0)return[];const C=B.length>1?o.union(B):B[0],l=I?.height??I?.h??1;let Q=r.extrudeLinear({height:l},C);if(Q.polygons)for(const E of Q.polygons)!E.plane||!E.vertices||E.vertices.length<3||E.vertices.reverse();return[{geom:Q,color:A??I?.color}]}if(g===ht||g===xWA||g===Up||g===kWA||g===xU||g===Lp){let B;if(g===ht){const C=I?.size??[1,1,1],l=I?.offset,Q=I?.center??(l?[l[0],l[1],l[2]]:[0,0,0]);B=i.cuboid({size:C,center:Q})}else if(g===xWA){const C=I?.size??1,l=I?.offset,Q=I?.center??(l?[l[0],l[1],l[2]]:[0,0,0]);B=i.cube({size:C,center:Q})}else if(g===Up){const C=I?.height??1,l=I?.radius??1,Q=I?.center??[0,0,0];B=i.cylinder({height:C,radius:l,center:Q})}else if(g===kWA){const C=I?.radius??1,l=I?.center??[0,0,0];B=i.sphere({radius:C,center:l})}else if(g===Lp){const C=I?.height??1,l=I?.radius??1,Q=I?.roundRadius??.1,E=I?.center??[0,0,0];B=i.roundedCylinder({height:C,radius:l,roundRadius:Q,center:E})}else{const C=I?.size??[1,1,1],l=I?.roundRadius??.1,Q=I?.center??[0,0,0];B=i.roundedCuboid({size:C,roundRadius:l,center:Q})}return[{geom:B,color:A??I?.color}]}if(typeof g=="function"){const B=g(I??{});return um(B,A,e)}return(c??[]).flatMap(B=>um(B,A,e))}function TQt(t,A){return{geometries:um(t,void 0,{jscad:A})}}function YWA(t){if(t.polygons){const A=[],e=[],i=[];let o=0;for(const s of t.polygons){for(const a of s.vertices)a.index=o,A.push(a[0],a[1],a[2]),t.color&&t.color.length>=3?i.push(t.color[0],t.color[1],t.color[2]):i.push(1,1,1),o++;const r=s.vertices[0].index;for(let a=2;a<s.vertices.length;a++){const g=s.vertices[a-1].index,I=s.vertices[a].index;e.push(r,g,I)}}const n=new Fg;if(n.setAttribute("position",new iI(new Float32Array(A),3)),n.setIndex(e),i.length>0&&n.setAttribute("color",new iI(new Float32Array(i),3)),t.transforms){const s=new As;s.fromArray(t.transforms),n.applyMatrix4(s)}return n.computeVertexNormals(),n}if(t.sides){const A=[],e=[];for(const o of t.sides)A.push(o[0][0],o[0][1],0),t.color&&t.color.length>=3?e.push(t.color[0],t.color[1],t.color[2]):e.push(1,1,1);const i=new Fg;if(i.setAttribute("position",new iI(new Float32Array(A),3)),e.length>0&&i.setAttribute("color",new iI(new Float32Array(e),3)),t.transforms){const o=new As;o.fromArray(t.transforms),i.applyMatrix4(o)}return i}return console.error("Invalid CSG object: neither polygons nor sides found"),new Fg}function qQt(t,A){const e=EBA(YQt,{footprint:t});return TQt(e,A)}var PQt=({jscadPlan:t,positionOffset:A,rotationOffset:e,onHover:i,onUnhover:o,isHovered:n,scale:s,isTranslucent:r=!1})=>{const{rootObject:a}=du(),{threeGeom:g,material:I}=AA.useMemo(()=>{const B=(0,drt.executeJscadOperations)(prt.default,t);if(!B||!B.polygons&&!B.sides)return{threeGeom:null,material:null};const C=YWA(B),l=new Qu({vertexColors:!0,side:_C,transparent:r,opacity:r?.5:1,depthWrite:!r});return{threeGeom:C,material:l}},[t,r]),c=AA.useMemo(()=>g?new $o(g,I):null,[g,I]);return AA.useEffect(()=>{if(!(!c||!a))return a.add(c),()=>{a.remove(c)}},[a,c]),AA.useEffect(()=>{c&&(A&&c.position.fromArray(A),e&&c.rotation.fromArray(e),s!==void 0&&c.scale.setScalar(s))},[c,A?.[0],A?.[1],A?.[2],e?.[0],e?.[1],e?.[2],s]),AA.useMemo(()=>{if(I)if(n){const B=new Li(I.color.getHex());I.emissive.copy(B),I.emissive.setRGB(0,0,1),I.emissiveIntensity=.2}else I.emissiveIntensity=0},[n,I]),g?V.jsx(DU,{isHovered:n,onHover:i,onUnhover:o,object:c}):null},OQt=fr(yO()),WQt=({positionOffset:t,footprint:A,rotationOffset:e,onHover:i,onUnhover:o,isHovered:n,scale:s,isTranslucent:r=!1})=>{const{rootObject:a}=du(),g=AA.useMemo(()=>{if(!A)return null;const{geometries:I}=qQt(A,OQt),c=new Lf;for(const B of I.flat(1/0)){const C=B.geom;if(!C||!C.polygons&&!C.sides)continue;const l=new Li(B.color);l.convertLinearToSRGB();const Q={...C,color:[l.r,l.g,l.b]},E=YWA(Q),h=new Qu({vertexColors:!0,side:_C,transparent:r,opacity:r?.5:1,depthWrite:!r}),u=new $o(E,h);c.add(u)}return c},[A,r]);return AA.useEffect(()=>{if(!(!g||!a))return a.add(g),()=>{a.remove(g)}},[a,g]),AA.useEffect(()=>{g&&(t&&g.position.fromArray(t),e&&g.rotation.fromArray(e),s!==void 0&&g.scale.setScalar(s))},[g,t?.[0],t?.[1],t?.[2],e?.[0],e?.[1],e?.[2],s]),AA.useEffect(()=>{g&&g.traverse(I=>{I instanceof $o&&I.material instanceof Qu&&(n?(I.material.emissive.setHex(255),I.material.emissiveIntensity=.2):I.material.emissiveIntensity=0)})},[n,g]),g?V.jsx(DU,{isHovered:n,onHover:i,onUnhover:o,object:g}):null},ZQt=(...t)=>t,HU={clickToInteractOverlay:100,htmlElements:95,orientationCube:95,contextMenu:90,appearanceMenu:91},JWA=({children:t,position:A,style:e})=>{const{camera:i,renderer:o}=du(),n=AA.useRef(document.createElement("div")),[s,r]=AA.useState(null);return AA.useEffect(()=>{const a=o?.domElement.parentNode;if(a)return a.style.position!=="relative"&&a.style.position!=="absolute"&&(a.style.position="relative"),a.appendChild(n.current),r(aJ.createPortal(t,n.current)),()=>{a.contains(n.current)&&a.removeChild(n.current)}},[o,t]),mU(()=>{if(!i||!n.current||!o)return;const a=new Re(...A);a.project(i);const g=o.domElement.getBoundingClientRect(),I=Math.round((a.x+1)/2*g.width),c=Math.round((-a.y+1)/2*g.height);n.current.style.position="absolute",n.current.style.left=`${I}px`,n.current.style.top=`${c}px`,n.current.style.pointerEvents="none",n.current.style.zIndex=HU.htmlElements.toString(),e&&Object.assign(n.current.style,e)},[i,o,A,e]),s},KWA={boardBody:!0,topCopper:!0,bottomCopper:!0,adhesive:!1,solderPaste:!1,topSilkscreen:!0,bottomSilkscreen:!0,topMask:!0,bottomMask:!0,throughHoleModels:!0,smtModels:!0,translucentModels:!0,modelsNotInPosFile:!1,modelsMarkedDNP:!1,modelBoundingBoxes:!1,threedAxis:!1,backgroundStart:!0,backgroundEnd:!0},TWA=AA.createContext(void 0),VQt=({children:t})=>{const[A,e]=AA.useState(KWA),i=AA.useCallback((s,r)=>{e(a=>({...a,[s]:r}))},[]),o=AA.useCallback(()=>{e(KWA)},[]),n=AA.useMemo(()=>({visibility:A,setLayerVisibility:i,resetToDefaults:o}),[A,i,o]);return V.jsx(TWA.Provider,{value:n,children:t})},LM=()=>{const t=AA.useContext(TWA);if(!t)throw new Error("useLayerVisibility must be used within a LayerVisibilityProvider");return t},qWA=({cad_component:t,circuitJson:A})=>{const[e,i]=AA.useState(!1),{visibility:o}=LM(),[n,s]=AA.useState(null),r=AA.useCallback(Q=>{Q?.mousePosition?(i(!0),s(Q.mousePosition)):(i(!1),s(null))},[]),a=AA.useCallback(()=>{i(!1),s(null)},[]),g=AA.useMemo(()=>yi(A).source_component.getUsing({source_component_id:t.source_component_id})?.name,[A,t.source_component_id]),I=AA.useMemo(()=>A.filter(E=>E.type==="pcb_plated_hole"&&E.pcb_component_id===t.pcb_component_id).length>0,[A,t.pcb_component_id]),c=t.model_obj_url??t.model_wrl_url??t.model_stl_url,B=t.model_glb_url??t.model_gltf_url,C=t.rotation?ZQt(t.rotation.x*Math.PI/180,t.rotation.y*Math.PI/180,t.rotation.z*Math.PI/180):void 0;let l=null;if(c?l=V.jsx(Qrt,{url:c,position:t.position?[t.position.x,t.position.y,t.position.z]:void 0,rotation:C,scale:t.model_unit_to_mm_scale_factor,onHover:r,onUnhover:a,isHovered:e,isTranslucent:t.show_as_translucent_model},t.cad_component_id):B?l=V.jsx(urt,{gltfUrl:B,position:t.position?[t.position.x,t.position.y,t.position.z]:void 0,rotation:C,scale:t.model_unit_to_mm_scale_factor,onHover:r,onUnhover:a,isHovered:e,isTranslucent:t.show_as_translucent_model},t.cad_component_id):t.model_jscad?l=V.jsx(PQt,{jscadPlan:t.model_jscad,rotationOffset:C,scale:t.model_unit_to_mm_scale_factor,onHover:r,onUnhover:a,isHovered:e,isTranslucent:t.show_as_translucent_model},t.cad_component_id):t.footprinter_string&&(l=V.jsx(WQt,{positionOffset:t.position?[t.position.x,t.position.y,t.position.z]:void 0,rotationOffset:C,footprint:t.footprinter_string,scale:t.model_unit_to_mm_scale_factor,onHover:r,onUnhover:a,isHovered:e,isTranslucent:t.show_as_translucent_model})),t.show_as_translucent_model){if(!o.translucentModels)return null}else if(I&&!o.throughHoleModels||!I&&!o.smtModels)return null;return V.jsxs(V.Fragment,{children:[l,e&&n?V.jsx(JWA,{position:n,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:g??"<unknown>"}):null]})},PWA={version:"0.0.481"};function jQt(t){t.querySelectorAll("canvas").forEach(A=>A.remove())}var zQt=t=>{t.outputColorSpace=Py,t.toneMapping=iDA,t.toneMappingExposure=1},OWA="cadViewerCameraStateSession",WWA=(t,A)=>{try{const e={position:t.position.toArray(),quaternion:t.quaternion.toArray(),up:t.up.toArray(),fov:t.fov??50,target:A.target.toArray()};sessionStorage.setItem(OWA,JSON.stringify(e))}catch(e){console.warn("Failed to save camera:",e)}},vBA=(t,A)=>{try{const e=sessionStorage.getItem(OWA);if(!e)return!1;const i=JSON.parse(e);if(t.position.fromArray(i.position),t.quaternion.fromArray(i.quaternion),t.up.fromArray(i.up),"fov"in t){const o=t;o.fov=i.fov,o.updateProjectionMatrix?.()}return A.target.fromArray(i.target),A.update(),t.updateMatrixWorld(),!0}catch(e){return console.warn("Failed to restore camera:",e),!1}},ZWA=AA.createContext(void 0),XQt=({children:t,defaultTarget:A,initialCameraPosition:e})=>{const i=AA.useRef(null),o=AA.useRef(null),[n,s]=AA.useState(null),[r,a]=AA.useState("perspective"),[g,I]=AA.useState(e??null),[c,B]=AA.useState(new xp(0,0,0)),C=AA.useMemo(()=>{const[h,u,d]=e??[5,-5,5],f=Math.hypot(h-A.x,u-A.y,d-A.z);return f>0?f:5},[e,A]),l=AA.useCallback(h=>{const u=[A.x,A.y,A.z],d=o.current,f=i.current;let D=C;switch(d&&f&&(D=d.position.distanceTo(f.target)),h){case"Top Center Angled":{const b=D/Math.sqrt(2);return{position:[A.x,A.y-b,A.z+b],target:u,up:[0,0,1]}}case"Top Down":return{position:[A.x,A.y,A.z+D],target:u,up:[0,0,1]};case"Top Left Corner":return{position:[A.x-D*.6,A.y-D*.6,A.z+D*.6],target:u,up:[0,0,1]};case"Top Right Corner":return{position:[A.x+D*.6,A.y-D*.6,A.z+D*.6],target:u,up:[0,0,1]};case"Left Sideview":return{position:[A.x-D,A.y,A.z],target:u,up:[0,0,1]};case"Right Sideview":return{position:[A.x+D,A.y,A.z],target:u,up:[0,0,1]};case"Front":return{position:[A.x,A.y-D,A.z],target:u,up:[0,0,1]};default:return null}},[C,A,o,i]),Q=AA.useCallback(h=>{i.current=h},[]),E=AA.useMemo(()=>({controlsRef:i,mainCameraRef:o,defaultTarget:A,baseDistance:C,controller:n,setController:s,getPresetConfig:l,handleControlsChange:Q,cameraType:r,setCameraType:a,cameraPosition:g,setCameraPosition:I,cameraRotation:c,setCameraRotation:B,saveCameraToSession:WWA,loadCameraFromSession:vBA}),[A,C,n,l,Q,r,g,c]);return V.jsx(ZWA.Provider,{value:E,children:t})},Ex=()=>{const t=AA.useContext(ZWA);if(!t)throw new Error("useCameraController must be used within a CameraControllerProvider");return t},$Qt=AA.forwardRef(({children:t,scene:A,camera:e,style:i,onCreated:o},n)=>{const{cameraType:s}=Ex(),r=AA.useRef(null),[a,g]=AA.useState(null),I=AA.useRef([]),c=AA.useRef(void 0);c.current=o;const B=AA.useRef(null),C=AA.useCallback(h=>{I.current.push(h)},[]),l=AA.useCallback(h=>{I.current=I.current.filter(u=>u!==h)},[]),Q=AA.useMemo(()=>new jk,[]);A?.up&&Q.up.set(A.up.x,A.up.y,A.up.z);const E=AA.useRef(new cg);return AA.useImperativeHandle(n,()=>E.current),AA.useEffect(()=>{if(!r.current)return;jQt(r.current);const h=new yK({antialias:!0,alpha:!0});zQt(h),h.setSize(r.current.clientWidth,r.current.clientHeight),h.setPixelRatio(window.devicePixelRatio),r.current.appendChild(h.domElement);const u=r.current.clientWidth/r.current.clientHeight,d=s==="perspective"?new $Q(75,u,.1,1e3):new D1(-10*u,10*u,10,-10,-1e3,1e3);B.current?(d.position.copy(B.current.position),d.quaternion.copy(B.current.quaternion),d.up.copy(B.current.up)):(e?.up&&d.up.set(e.up[0],e.up[1],e.up[2]),e?.position&&d.position.set(e.position[0],e.position[1],e.position[2]),d.lookAt(0,0,0)),Q.add(E.current),window.__TSCIRCUIT_THREE_OBJECT=E.current,g({scene:Q,camera:d,renderer:h,rootObject:E.current,addFrameListener:C,removeFrameListener:l}),c.current?.({camera:d,renderer:h});let f;const D=new Pwe,b=()=>{const x=D.getElapsedTime(),F=D.getDelta();I.current.forEach(k=>k(x,F)),h.render(Q,d),f=requestAnimationFrame(b)};b();const m=()=>{if(r.current){const x=r.current.clientWidth/r.current.clientHeight;d instanceof $Q?d.aspect=x:d instanceof D1&&(d.left=-10*x,d.right=10*x,d.top=10,d.bottom=-10),d.updateProjectionMatrix(),h.setSize(r.current.clientWidth,r.current.clientHeight)}};return window.addEventListener("resize",m),()=>{B.current={position:d.position.clone(),quaternion:d.quaternion.clone(),up:d.up.clone()},window.removeEventListener("resize",m),cancelAnimationFrame(f),r.current&&h.domElement&&r.current.removeChild(h.domElement),h.dispose(),Q.remove(E.current),window.__TSCIRCUIT_THREE_OBJECT===E.current&&(window.__TSCIRCUIT_THREE_OBJECT=void 0)}},[Q,C,l,s]),V.jsx("div",{ref:r,style:{width:"100%",height:"100%",...i},children:a&&V.jsx(w8A.Provider,{value:a,children:V.jsx(Irt,{children:t})})})}),AEt=({autoRotate:t,autoRotateSpeed:A,onStart:e,panSpeed:i,rotateSpeed:o,zoomSpeed:n,enableDamping:s,dampingFactor:r,target:a,onControlsChange:g})=>{const{camera:I,renderer:c}=du(),B=AA.useMemo(()=>!I||!c?null:new Abe(I,c.domElement),[I,c]);return AA.useEffect(()=>(g?.(B??null),()=>g?.(null)),[B,g]),AA.useEffect(()=>{if(!B)return;const C=()=>{g?.(B)};return B.addEventListener("change",C),()=>{B.removeEventListener("change",C)}},[B,g]),AA.useEffect(()=>{B&&(B.autoRotate=t||!1,B.autoRotateSpeed=A||1,i!==void 0&&(B.panSpeed=i),o!==void 0&&(B.rotateSpeed=o),n!==void 0&&(B.zoomSpeed=n),s!==void 0&&(B.enableDamping=s),r!==void 0&&(B.dampingFactor=r),B.zoomToCursor=!0,B.mouseButtons={LEFT:Bb.ROTATE,MIDDLE:Bb.PAN,RIGHT:null},a&&(B.target.set(a[0],a[1],a[2]),B.update()))},[B,t,A,i,o,n,s,r,a]),AA.useEffect(()=>{if(!(!B||!e))return B.addEventListener("start",e),()=>{B.removeEventListener("start",e)}},[B,e]),AA.useEffect(()=>{if(B)return()=>{B.dispose()}},[B]),mU(()=>{B?.update()},[B]),null},eEt=`
|
|
5063
5063
|
varying vec3 worldPosition;
|
|
5064
5064
|
void main() {
|
|
5065
5065
|
worldPosition = (modelMatrix * vec4(position, 1.0)).xyz;
|
|
@@ -5598,7 +5598,7 @@ test("${g} should solve problem correctly", () => {
|
|
|
5598
5598
|
// Add more specific assertions based on expected output
|
|
5599
5599
|
// expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
|
|
5600
5600
|
})
|
|
5601
|
-
`,c=new Blob([I],{type:"text/plain"}),B=URL.createObjectURL(c),C=document.createElement("a");C.href=B,C.download=`${g}.test.ts`,C.click(),URL.revokeObjectURL(B)}catch(a){alert(`Error generating test.ts for ${t.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return V.jsxs("div",{className:`relative ${A}`,ref:o,children:[V.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!e),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),e&&V.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:n,children:"Download JSON"}),V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},kAe=t=>t.activeSubSolver?[t,...kAe(t.activeSubSolver)]:[t],W2t=({solver:t})=>{const A=kAe(t);return V.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((e,i)=>V.jsxs("div",{className:"flex items-center",children:[i>0&&V.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),V.jsx(O2t,{solver:e})]},e.constructor.name))})},Z2t=({solver:t,triggerRender:A,animationSpeed:e=25,onSolverStarted:i,onSolverCompleted:o})=>{const[n,s]=AA.useReducer(Q=>!Q,!1),r=AA.useRef(void 0),a=()=>{!t.solved&&!t.failed&&(t.step(),A())},g=()=>{!t.solved&&!t.failed&&(i&&i(t),t.solve(),A(),o&&o(t))},I=()=>{n?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(t.solved||t.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),o&&t.solved&&o(t);return}t.step(),A()},e))},c=()=>{const Q=t;if(Q.getCurrentPhase&&!t.solved&&!t.failed){const E=Q.getCurrentPhase();for(;Q.getCurrentPhase()===E&&!t.solved&&!t.failed;)t.step();A()}},B=()=>{if(t.solved||t.failed||n)return;const Q=window.prompt("Step until which iteration?",`${t.iterations}`);if(Q===null)return;const E=Number(Q);if(!Number.isFinite(E)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<E&&!t.solved&&!t.failed;)t.step();A(),t.solved&&o&&o(t)};AA.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),AA.useEffect(()=>{(t.solved||t.failed)&&n&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[t.solved,t.failed,n]);const C=t.getCurrentPhase!==void 0,l=C?t.getCurrentPhase():null;return V.jsxs("div",{className:"space-y-2 p-2 border-b",children:[V.jsx("div",{className:"flex items-center",children:V.jsx(W2t,{solver:t})}),V.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[V.jsx("button",{onClick:a,disabled:t.solved||t.failed||n,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),V.jsx("button",{onClick:g,disabled:t.solved||t.failed||n,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),V.jsx("button",{onClick:I,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${n?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:n?"Stop":"Animate"}),V.jsx("button",{onClick:B,disabled:t.solved||t.failed||n,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),C&&V.jsx("button",{onClick:c,disabled:t.solved||t.failed||n,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),V.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&V.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),l&&V.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",V.jsx("span",{className:"font-medium",children:l})]}),t.solved&&V.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&V.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&V.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},V2t=(t,A,e)=>{const i=t.currentPipelineStepIndex;return A<i?"Completed":A===i&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},j2t=(t,A)=>{const i=t.pipelineDef[A].solverName,o=V2t(t,A),n=t[i],s=t.firstIterationOfPhase?.[i]??null,r=t.iterations;let a=0;if(o==="Completed"){const B=t.pipelineDef[A+1],C=B?t.firstIterationOfPhase?.[B.solverName]:void 0;C!==void 0&&s!==null?a=C-s:s!==null&&(a=r-s)}else o==="In Progress"&&s!==null&&(a=r-s);const g=t.timeSpentOnPhase?.[i]??0;let I=0;o==="Completed"?I=1:o==="In Progress"&&n&&(I=n.progress??0);const c=n?.stats??null;return{index:A,name:i,status:o,firstIteration:s,iterations:a,progress:I,timeSpent:g,stats:c&&Object.keys(c).length>0?c:null,solverInstance:n??null}},z2t=({status:t})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return V.jsx("span",{className:`font-medium ${A[t]}`,children:t})},X2t=({progress:t})=>{if(t===0)return null;const A=Math.round(t*100);return V.jsxs("div",{className:"flex items-center gap-2",children:[V.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:V.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),V.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},$2t=t=>Object.entries(t).map(([A,e])=>`${A}: ${e}`).join(", "),AUt=({stats:t})=>{if(!t||Object.keys(t).length===0)return V.jsx("span",{children:"-"});const A=Object.entries(t),e=$2t(t);return V.jsxs("details",{className:"cursor-pointer",children:[V.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:e}),V.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,o])=>V.jsxs("div",{children:[i,": ",String(o)]},i))})]})},tEA=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(tEA);const A={};for(const[e,i]of Object.entries(t))e.startsWith("_")||(A[e]=tEA(i));return A},eUt=(t,A)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const e=tEA(t.getConstructorParams()),i=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),o=URL.createObjectURL(i),n=document.createElement("a");n.href=o,n.download=`${A}_input.json`,n.click(),URL.revokeObjectURL(o)}catch(e){alert(`Error downloading input for ${A}: ${e instanceof Error?e.message:String(e)}`)}},tUt=({solver:t,onStepUntilPhase:A,onDownloadInput:e})=>{const i=t.pipelineDef.map((r,a)=>j2t(t,a)),o=r=>{A?.(r)},n=r=>{r.solverInstance&&(e?e(r.solverInstance,r.name):eUt(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return V.jsxs("div",{className:"border-t border-gray-200",children:[V.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:V.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),V.jsx("div",{className:"overflow-x-auto",children:V.jsxs("table",{className:"w-full text-sm",children:[V.jsx("thead",{children:V.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),V.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",V.jsx("sub",{children:"0"})]}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),V.jsx("tbody",{children:i.map(r=>V.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[V.jsx("td",{className:"px-4 py-2",children:V.jsxs("div",{className:"flex items-center gap-2",children:[V.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),V.jsx("button",{onClick:()=>o(r.name),disabled:r.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${r.name} completes`,children:V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:V.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),V.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),V.jsx("td",{className:"px-4 py-2",children:V.jsx(z2t,{status:r.status})}),V.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),V.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),V.jsx("td",{className:"px-4 py-2",children:V.jsx(X2t,{progress:r.progress})}),V.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),V.jsx("td",{className:"px-4 py-2 text-gray-500",children:V.jsx(AUt,{stats:r.stats})}),V.jsx("td",{className:"px-4 py-2",children:r.solverInstance?V.jsxs("button",{onClick:()=>n(r),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${r.name}`,children:[V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:V.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),V.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},iUt=class extends zi.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.error("InteractiveGraphics render error:",t)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function oUt({graphics:t}){const A=t.points??[],e=t.lines??[],i=t.rects??[],o=t.circles??[],n=t.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const I=(E,h)=>{typeof E=="number"&&(E<s&&(s=E),E>a&&(a=E)),typeof h=="number"&&(h<r&&(r=h),h>g&&(g=h))};for(const E of A)I(E.x,E.y);for(const E of e){const h=E.points??[];for(const u of h)I(u.x,u.y)}for(const E of i){const h=E.x??0,u=E.y??0,d=E.width??0,f=E.height??0;I(h,u),I(h+d,u+f)}for(const E of o){const h=E.x??0,u=E.y??0,d=E.radius??1;I(h-d,u-d),I(h+d,u+d)}for(const E of n)I(E.x,E.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const c=10,B=s-c,C=r-c,l=Math.max(1,a-s+2*c),Q=Math.max(1,g-r+2*c);return V.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${B} ${C} ${l} ${Q}`,role:"img","aria-label":"Graphics fallback",children:[i.map((E,h)=>V.jsx("rect",{x:E.x??0,y:E.y??0,width:E.width??0,height:E.height??0,fill:"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1},`rect-${h}`)),e.map((E,h)=>V.jsx("polyline",{fill:"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1,points:(E.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${h}`)),o.map((E,h)=>V.jsx("circle",{cx:E.x??0,cy:E.y??0,r:E.radius??1.5,fill:E.fillColor??"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1},`circle-${h}`)),A.map((E,h)=>V.jsx("circle",{cx:E.x??0,cy:E.y??0,r:E.radius??1.5,fill:E.color??"black"},`point-${h}`)),n.map((E,h)=>V.jsx("text",{x:E.x??0,y:E.y??0,fontSize:E.fontSize??10,fill:E.color??"black",children:E.text??""},`text-${h}`))]})}var nUt=({solver:t,animationSpeed:A=25,onSolverStarted:e,onSolverCompleted:i})=>{const[o,n]=AA.useReducer(I=>I+1,0),s=AA.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(I){return console.error("Visualization error:",I),{points:[],lines:[],rects:[],circles:[]}}},[t,o]),r=AA.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);AA.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const I=document.createElement("script");I.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(I)}},[]);const a=t.pipelineDef!==void 0,g=I=>{const c=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&c.currentPipelineStepIndex<=c.pipelineDef.findIndex(B=>B.solverName===I);)t.step();n()}};return V.jsxs("div",{children:[V.jsx(Z2t,{solver:t,triggerRender:n,animationSpeed:A,onSolverStarted:e,onSolverCompleted:i}),r?V.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):V.jsx(iUt,{fallback:V.jsx(oUt,{graphics:s}),children:V.jsx(P2t,{graphics:s})}),a&&V.jsx(tUt,{solver:t,onStepUntilPhase:g})]})};const sUt=()=>{AA.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const e=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),e)return;const i=document.createElement("script");i.id=t,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},rUt=t=>t.toLowerCase().includes("pack")?J0t:t.toLowerCase().includes("rout")?W0t:R0t,aUt=({solverEvents:t=[]})=>{const[A,e]=AA.useState(null);sUt();const i=AA.useMemo(()=>{const r=new Map;for(const a of t){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[t]),o=AA.useMemo(()=>Array.from(i.keys()),[i]),n=A?i.get(A):null,s=AA.useMemo(()=>{if(!n)return{instance:null,error:null,classFound:!1};const r=siA[n.solverName];if(!r)return{instance:null,error:`Solver class "${n.solverName}" not found in SOLVERS registry. Available: ${Object.keys(siA).join(", ")}`,classFound:!1};try{const a=n.solverParams,g=a?.input!==void 0?a.input:a;return{instance:new r(g),error:null,classFound:!0}}catch(a){const g=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${g}`,classFound:!0}}},[n]);return t.length===0?V.jsx("div",{className:"rf-p-4",children:V.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:V.jsxs("div",{className:"rf-p-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),V.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):V.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[V.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[V.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[o.length," ",o.length===1?"Solver":"Solvers"]}),o.map(r=>{const a=i.get(r),g=A===r;return V.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${g?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>e(r),children:(()=>{const I=rUt(a.solverName);return V.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[V.jsx(I,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),V.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[V.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),V.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),V.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:n?s.instance?V.jsx(xm,{fallback:V.jsx("div",{className:"rf-p-4",children:V.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),V.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",n.solverName]})]})}),children:V.jsx(nUt,{solver:s.instance})}):V.jsxs("div",{className:"rf-p-4",children:[V.jsxs("div",{className:"rf-mb-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:n.solverName}),V.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",n.componentName]})]}),s.error&&V.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:V.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),V.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[V.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:V.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),V.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:V.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(n.solverParams,null,2)})})]})]}):V.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:V.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},GAe=({errorMessage:t,errorStack:A,circuitJsonErrors:e})=>{AA.useEffect(()=>{if(t){const i=new Error(t);A&&(i.stack=A);try{HJ.captureException(i)}catch{}}},[t,A]),AA.useEffect(()=>{if(e&&e.length>0)for(const i of e){const o=new Error(i.message||"Circuit JSON Error");i.stack&&(o.stack=i.stack);try{HJ.captureException(o,{error_type:i.type})}catch{}}},[e])},FAe="0.0.1458",gUt={version:FAe},iEA={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},oEA=new Map,rW=t=>{const A=oEA.get(t);return A?Object.fromEntries(Object.entries(A.stores).map(([e,i])=>[e,i.getState()])):{}},IUt=(t,A,e)=>{if(t===void 0)return{type:"untracked",connection:A.connect(e)};const i=oEA.get(e.name);if(i)return{type:"tracked",store:t,...i};const o={connection:A.connect(e),stores:{}};return oEA.set(e.name,o),{type:"tracked",store:t,...o}},RAe=(t,A={})=>(e,i,o)=>{const{enabled:n,anonymousActionType:s,store:r,...a}=A;let g;try{g=(n??(iEA?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!g)return(iEA?"production":void 0)!=="production"&&n&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(e,i,o);const{connection:I,...c}=IUt(r,g,a);let B=!0;o.setState=(Q,E,h)=>{const u=e(Q,E);if(!B)return u;const d=h===void 0?{type:s||"anonymous"}:typeof h=="string"?{type:h}:h;return r===void 0?(I?.send(d,i()),u):(I?.send({...d,type:`${r}/${d.type}`},{...rW(a.name),[r]:o.getState()}),u)};const C=(...Q)=>{const E=B;B=!1,e(...Q),B=E},l=t(o.setState,i,o);if(c.type==="untracked"?I?.init(l):(c.stores[c.store]=o,I?.init(Object.fromEntries(Object.entries(c.stores).map(([Q,E])=>[Q,Q===c.store?l:E.getState()])))),o.dispatchFromDevtools&&typeof o.dispatch=="function"){let Q=!1;const E=o.dispatch;o.dispatch=(...h)=>{(iEA?"production":void 0)!=="production"&&h[0].type==="__setState"&&!Q&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),Q=!0),E(...h)}}return I.subscribe(Q=>{var E;switch(Q.type){case"ACTION":if(typeof Q.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return nEA(Q.payload,h=>{if(h.type==="__setState"){if(r===void 0){C(h.state);return}Object.keys(h.state).length!==1&&console.error(`
|
|
5601
|
+
`,c=new Blob([I],{type:"text/plain"}),B=URL.createObjectURL(c),C=document.createElement("a");C.href=B,C.download=`${g}.test.ts`,C.click(),URL.revokeObjectURL(B)}catch(a){alert(`Error generating test.ts for ${t.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return V.jsxs("div",{className:`relative ${A}`,ref:o,children:[V.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!e),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),e&&V.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:n,children:"Download JSON"}),V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},kAe=t=>t.activeSubSolver?[t,...kAe(t.activeSubSolver)]:[t],W2t=({solver:t})=>{const A=kAe(t);return V.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((e,i)=>V.jsxs("div",{className:"flex items-center",children:[i>0&&V.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),V.jsx(O2t,{solver:e})]},e.constructor.name))})},Z2t=({solver:t,triggerRender:A,animationSpeed:e=25,onSolverStarted:i,onSolverCompleted:o})=>{const[n,s]=AA.useReducer(Q=>!Q,!1),r=AA.useRef(void 0),a=()=>{!t.solved&&!t.failed&&(t.step(),A())},g=()=>{!t.solved&&!t.failed&&(i&&i(t),t.solve(),A(),o&&o(t))},I=()=>{n?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(t.solved||t.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),o&&t.solved&&o(t);return}t.step(),A()},e))},c=()=>{const Q=t;if(Q.getCurrentPhase&&!t.solved&&!t.failed){const E=Q.getCurrentPhase();for(;Q.getCurrentPhase()===E&&!t.solved&&!t.failed;)t.step();A()}},B=()=>{if(t.solved||t.failed||n)return;const Q=window.prompt("Step until which iteration?",`${t.iterations}`);if(Q===null)return;const E=Number(Q);if(!Number.isFinite(E)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<E&&!t.solved&&!t.failed;)t.step();A(),t.solved&&o&&o(t)};AA.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),AA.useEffect(()=>{(t.solved||t.failed)&&n&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[t.solved,t.failed,n]);const C=t.getCurrentPhase!==void 0,l=C?t.getCurrentPhase():null;return V.jsxs("div",{className:"space-y-2 p-2 border-b",children:[V.jsx("div",{className:"flex items-center",children:V.jsx(W2t,{solver:t})}),V.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[V.jsx("button",{onClick:a,disabled:t.solved||t.failed||n,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),V.jsx("button",{onClick:g,disabled:t.solved||t.failed||n,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),V.jsx("button",{onClick:I,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${n?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:n?"Stop":"Animate"}),V.jsx("button",{onClick:B,disabled:t.solved||t.failed||n,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),C&&V.jsx("button",{onClick:c,disabled:t.solved||t.failed||n,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),V.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&V.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),l&&V.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",V.jsx("span",{className:"font-medium",children:l})]}),t.solved&&V.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&V.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&V.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},V2t=(t,A,e)=>{const i=t.currentPipelineStepIndex;return A<i?"Completed":A===i&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},j2t=(t,A)=>{const i=t.pipelineDef[A].solverName,o=V2t(t,A),n=t[i],s=t.firstIterationOfPhase?.[i]??null,r=t.iterations;let a=0;if(o==="Completed"){const B=t.pipelineDef[A+1],C=B?t.firstIterationOfPhase?.[B.solverName]:void 0;C!==void 0&&s!==null?a=C-s:s!==null&&(a=r-s)}else o==="In Progress"&&s!==null&&(a=r-s);const g=t.timeSpentOnPhase?.[i]??0;let I=0;o==="Completed"?I=1:o==="In Progress"&&n&&(I=n.progress??0);const c=n?.stats??null;return{index:A,name:i,status:o,firstIteration:s,iterations:a,progress:I,timeSpent:g,stats:c&&Object.keys(c).length>0?c:null,solverInstance:n??null}},z2t=({status:t})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return V.jsx("span",{className:`font-medium ${A[t]}`,children:t})},X2t=({progress:t})=>{if(t===0)return null;const A=Math.round(t*100);return V.jsxs("div",{className:"flex items-center gap-2",children:[V.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:V.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),V.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},$2t=t=>Object.entries(t).map(([A,e])=>`${A}: ${e}`).join(", "),AUt=({stats:t})=>{if(!t||Object.keys(t).length===0)return V.jsx("span",{children:"-"});const A=Object.entries(t),e=$2t(t);return V.jsxs("details",{className:"cursor-pointer",children:[V.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:e}),V.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,o])=>V.jsxs("div",{children:[i,": ",String(o)]},i))})]})},tEA=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(tEA);const A={};for(const[e,i]of Object.entries(t))e.startsWith("_")||(A[e]=tEA(i));return A},eUt=(t,A)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const e=tEA(t.getConstructorParams()),i=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),o=URL.createObjectURL(i),n=document.createElement("a");n.href=o,n.download=`${A}_input.json`,n.click(),URL.revokeObjectURL(o)}catch(e){alert(`Error downloading input for ${A}: ${e instanceof Error?e.message:String(e)}`)}},tUt=({solver:t,onStepUntilPhase:A,onDownloadInput:e})=>{const i=t.pipelineDef.map((r,a)=>j2t(t,a)),o=r=>{A?.(r)},n=r=>{r.solverInstance&&(e?e(r.solverInstance,r.name):eUt(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return V.jsxs("div",{className:"border-t border-gray-200",children:[V.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:V.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),V.jsx("div",{className:"overflow-x-auto",children:V.jsxs("table",{className:"w-full text-sm",children:[V.jsx("thead",{children:V.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),V.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",V.jsx("sub",{children:"0"})]}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),V.jsx("tbody",{children:i.map(r=>V.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[V.jsx("td",{className:"px-4 py-2",children:V.jsxs("div",{className:"flex items-center gap-2",children:[V.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),V.jsx("button",{onClick:()=>o(r.name),disabled:r.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${r.name} completes`,children:V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:V.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),V.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),V.jsx("td",{className:"px-4 py-2",children:V.jsx(z2t,{status:r.status})}),V.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),V.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),V.jsx("td",{className:"px-4 py-2",children:V.jsx(X2t,{progress:r.progress})}),V.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),V.jsx("td",{className:"px-4 py-2 text-gray-500",children:V.jsx(AUt,{stats:r.stats})}),V.jsx("td",{className:"px-4 py-2",children:r.solverInstance?V.jsxs("button",{onClick:()=>n(r),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${r.name}`,children:[V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:V.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),V.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},iUt=class extends zi.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.error("InteractiveGraphics render error:",t)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function oUt({graphics:t}){const A=t.points??[],e=t.lines??[],i=t.rects??[],o=t.circles??[],n=t.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const I=(E,h)=>{typeof E=="number"&&(E<s&&(s=E),E>a&&(a=E)),typeof h=="number"&&(h<r&&(r=h),h>g&&(g=h))};for(const E of A)I(E.x,E.y);for(const E of e){const h=E.points??[];for(const u of h)I(u.x,u.y)}for(const E of i){const h=E.x??0,u=E.y??0,d=E.width??0,f=E.height??0;I(h,u),I(h+d,u+f)}for(const E of o){const h=E.x??0,u=E.y??0,d=E.radius??1;I(h-d,u-d),I(h+d,u+d)}for(const E of n)I(E.x,E.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const c=10,B=s-c,C=r-c,l=Math.max(1,a-s+2*c),Q=Math.max(1,g-r+2*c);return V.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${B} ${C} ${l} ${Q}`,role:"img","aria-label":"Graphics fallback",children:[i.map((E,h)=>V.jsx("rect",{x:E.x??0,y:E.y??0,width:E.width??0,height:E.height??0,fill:"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1},`rect-${h}`)),e.map((E,h)=>V.jsx("polyline",{fill:"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1,points:(E.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${h}`)),o.map((E,h)=>V.jsx("circle",{cx:E.x??0,cy:E.y??0,r:E.radius??1.5,fill:E.fillColor??"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1},`circle-${h}`)),A.map((E,h)=>V.jsx("circle",{cx:E.x??0,cy:E.y??0,r:E.radius??1.5,fill:E.color??"black"},`point-${h}`)),n.map((E,h)=>V.jsx("text",{x:E.x??0,y:E.y??0,fontSize:E.fontSize??10,fill:E.color??"black",children:E.text??""},`text-${h}`))]})}var nUt=({solver:t,animationSpeed:A=25,onSolverStarted:e,onSolverCompleted:i})=>{const[o,n]=AA.useReducer(I=>I+1,0),s=AA.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(I){return console.error("Visualization error:",I),{points:[],lines:[],rects:[],circles:[]}}},[t,o]),r=AA.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);AA.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const I=document.createElement("script");I.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(I)}},[]);const a=t.pipelineDef!==void 0,g=I=>{const c=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&c.currentPipelineStepIndex<=c.pipelineDef.findIndex(B=>B.solverName===I);)t.step();n()}};return V.jsxs("div",{children:[V.jsx(Z2t,{solver:t,triggerRender:n,animationSpeed:A,onSolverStarted:e,onSolverCompleted:i}),r?V.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):V.jsx(iUt,{fallback:V.jsx(oUt,{graphics:s}),children:V.jsx(P2t,{graphics:s})}),a&&V.jsx(tUt,{solver:t,onStepUntilPhase:g})]})};const sUt=()=>{AA.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const e=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),e)return;const i=document.createElement("script");i.id=t,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},rUt=t=>t.toLowerCase().includes("pack")?J0t:t.toLowerCase().includes("rout")?W0t:R0t,aUt=({solverEvents:t=[]})=>{const[A,e]=AA.useState(null);sUt();const i=AA.useMemo(()=>{const r=new Map;for(const a of t){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[t]),o=AA.useMemo(()=>Array.from(i.keys()),[i]),n=A?i.get(A):null,s=AA.useMemo(()=>{if(!n)return{instance:null,error:null,classFound:!1};const r=siA[n.solverName];if(!r)return{instance:null,error:`Solver class "${n.solverName}" not found in SOLVERS registry. Available: ${Object.keys(siA).join(", ")}`,classFound:!1};try{const a=n.solverParams,g=a?.input!==void 0?a.input:a;return{instance:new r(g),error:null,classFound:!0}}catch(a){const g=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${g}`,classFound:!0}}},[n]);return t.length===0?V.jsx("div",{className:"rf-p-4",children:V.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:V.jsxs("div",{className:"rf-p-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),V.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):V.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[V.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[V.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[o.length," ",o.length===1?"Solver":"Solvers"]}),o.map(r=>{const a=i.get(r),g=A===r;return V.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${g?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>e(r),children:(()=>{const I=rUt(a.solverName);return V.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[V.jsx(I,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),V.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[V.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),V.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),V.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:n?s.instance?V.jsx(xm,{fallback:V.jsx("div",{className:"rf-p-4",children:V.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),V.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",n.solverName]})]})}),children:V.jsx(nUt,{solver:s.instance})}):V.jsxs("div",{className:"rf-p-4",children:[V.jsxs("div",{className:"rf-mb-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:n.solverName}),V.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",n.componentName]})]}),s.error&&V.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:V.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),V.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[V.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:V.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),V.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:V.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(n.solverParams,null,2)})})]})]}):V.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:V.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},GAe=({errorMessage:t,errorStack:A,circuitJsonErrors:e})=>{AA.useEffect(()=>{if(t){const i=new Error(t);A&&(i.stack=A);try{HJ.captureException(i)}catch{}}},[t,A]),AA.useEffect(()=>{if(e&&e.length>0)for(const i of e){const o=new Error(i.message||"Circuit JSON Error");i.stack&&(o.stack=i.stack);try{HJ.captureException(o,{error_type:i.type})}catch{}}},[e])},FAe="0.0.1459",gUt={version:FAe},iEA={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},oEA=new Map,rW=t=>{const A=oEA.get(t);return A?Object.fromEntries(Object.entries(A.stores).map(([e,i])=>[e,i.getState()])):{}},IUt=(t,A,e)=>{if(t===void 0)return{type:"untracked",connection:A.connect(e)};const i=oEA.get(e.name);if(i)return{type:"tracked",store:t,...i};const o={connection:A.connect(e),stores:{}};return oEA.set(e.name,o),{type:"tracked",store:t,...o}},RAe=(t,A={})=>(e,i,o)=>{const{enabled:n,anonymousActionType:s,store:r,...a}=A;let g;try{g=(n??(iEA?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!g)return(iEA?"production":void 0)!=="production"&&n&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(e,i,o);const{connection:I,...c}=IUt(r,g,a);let B=!0;o.setState=(Q,E,h)=>{const u=e(Q,E);if(!B)return u;const d=h===void 0?{type:s||"anonymous"}:typeof h=="string"?{type:h}:h;return r===void 0?(I?.send(d,i()),u):(I?.send({...d,type:`${r}/${d.type}`},{...rW(a.name),[r]:o.getState()}),u)};const C=(...Q)=>{const E=B;B=!1,e(...Q),B=E},l=t(o.setState,i,o);if(c.type==="untracked"?I?.init(l):(c.stores[c.store]=o,I?.init(Object.fromEntries(Object.entries(c.stores).map(([Q,E])=>[Q,Q===c.store?l:E.getState()])))),o.dispatchFromDevtools&&typeof o.dispatch=="function"){let Q=!1;const E=o.dispatch;o.dispatch=(...h)=>{(iEA?"production":void 0)!=="production"&&h[0].type==="__setState"&&!Q&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),Q=!0),E(...h)}}return I.subscribe(Q=>{var E;switch(Q.type){case"ACTION":if(typeof Q.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return nEA(Q.payload,h=>{if(h.type==="__setState"){if(r===void 0){C(h.state);return}Object.keys(h.state).length!==1&&console.error(`
|
|
5602
5602
|
[zustand devtools middleware] Unsupported __setState action format.
|
|
5603
5603
|
When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
|
|
5604
5604
|
and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }
|