@tscircuit/runframe 0.0.1830 → 0.0.1832

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.
@@ -5150,7 +5150,7 @@ ${c.join(`
5150
5150
  ${p}polygon: ${h.polygon.vertices}
5151
5151
  `:c+=`
5152
5152
  `,h.children.length>0&&u.push(h.children)}return c}};e.exports=s}}),o4n=it({"node_modules/@jscad/modeling/src/operations/booleans/trees/Tree.js"(t,e){var n=Z5n(),o=n4n(),r=class{constructor(i){this.polygonTree=new o,this.rootnode=new n(null),i&&this.addPolygons(i)}invert(){this.polygonTree.invert(),this.rootnode.invert()}clipTo(i,s=!1){this.rootnode.clipTo(i,s)}allPolygons(){const i=[];return this.polygonTree.getPolygons(i),i}addPolygons(i){const s=new Array(i.length);for(let a=0;a<i.length;a++)s[a]=this.polygonTree.addChild(i[a]);this.rootnode.addPolygonTreeNodes(s)}clear(){this.polygonTree.clear()}toString(){return"Tree: "+this.polygonTree.toString("")}};e.exports=r}}),Yfe=it({"node_modules/@jscad/modeling/src/operations/booleans/trees/index.js"(t,e){e.exports={Tree:o4n()}}}),r4n=it({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3Sub.js"(t,e){var n=Wi(),o=Gfe(),{Tree:r}=Yfe(),i=(s,a)=>{if(!o(s,a))return n.create();const c=new r(n.toPolygons(s)),l=new r(n.toPolygons(a));c.invert(),l.clipTo(c),l.invert(),c.clipTo(l),l.clipTo(c),c.addPolygons(l.allPolygons()),c.invert();const u=c.allPolygons();return n.create(u)};e.exports=i}}),mZe=it({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3.js"(t,e){var n=vi(),o=hN(),r=r4n(),i=(...s)=>{s=n(s);let a=s.shift();return s.forEach(c=>{a=r(a,c)}),a=o(a),a};e.exports=i}}),i4n=it({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom2.js"(t,e){var n=vi(),o=Wi(),r=av(),i=Xfe(),s=jfe(),a=mZe(),c=(...l)=>{l=n(l);const u=l.map(m=>s({z0:-1,z1:1},m)),_=a(u),d=r(_);return i(d,o.toPolygons(_))};e.exports=c}}),s4n=it({"node_modules/@jscad/modeling/src/operations/booleans/intersect.js"(t,e){var n=vi(),o=dN(),r=Gi(),i=Wi(),s=i4n(),a=mZe(),c=(...l)=>{if(l=n(l),l.length===0)throw new Error("wrong number of arguments");if(!o(l))throw new Error("only intersect of the types are supported");const u=l[0];return r.isA(u)?s(l):i.isA(u)?a(l):u};e.exports=c}}),qfe=it({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints3.js"(t,e){var n=Is(),o=yQe(),r=i=>o(i,{skipTriangulation:!0}).map(c=>{const l=c.map(u=>i[u]);return n.create(l)});e.exports=r}}),pZe=it({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3Sub.js"(t,e){var n=Wi(),o=Gfe(),{Tree:r}=Yfe(),i=(a,c)=>{if(!o(a,c))return s(a,c);const l=new r(n.toPolygons(a)),u=new r(n.toPolygons(c));l.clipTo(u,!1),u.clipTo(l),u.invert(),u.clipTo(l),u.invert();const _=l.allPolygons().concat(u.allPolygons());return n.create(_)},s=(a,c)=>{let l=n.toPolygons(a);return l=l.concat(n.toPolygons(c)),n.create(l)};e.exports=i}}),Jfe=it({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3.js"(t,e){var n=vi(),o=hN(),r=pZe(),i=(...s)=>{s=n(s);let a;for(a=1;a<s.length;a+=2)s.push(r(s[a-1],s[a]));let c=s[a-1];return c=o(c),c};e.exports=i}}),fZe=it({"node_modules/@jscad/modeling/src/operations/minkowski/minkowskiSum.js"(t,e){var n=vi(),o=Wi(),r=Is(),i=qfe(),s=Jfe(),a=(...m)=>{if(m=n(m),m.length!==2)throw new Error("minkowskiSum requires exactly two geometries");const[h,p]=m;if(!o.isA(h)||!o.isA(p))throw new Error("minkowskiSum requires geom3 geometries");const x=o.isConvex(h),f=o.isConvex(p);if(x&&f)return _(h,p);if(!x&&f)return c(h,p);if(x&&!f)return c(p,h);throw new Error("minkowskiSum of two non-convex geometries is not yet supported")},c=(m,h)=>{const p=l(m);if(p.length===0)return o.create();const x=p.map(f=>_(f,h));return x.length===1?x[0]:s(x)},l=m=>{const h=o.toPolygons(m);if(h.length===0)return[];const p=[];for(let x=0;x<h.length;x++){const f=h[x],g=f.vertices;let y=0,b=0,v=0;for(let H=0;H<g.length;H++)y+=g[H][0],b+=g[H][1],v+=g[H][2];y/=g.length,b/=g.length,v/=g.length;const S=r.plane(f),M=S[0],w=S[1],D=S[2],A=.1,I=[y-M*A,b-w*A,v-D*A];for(let H=1;H<g.length-1;H++){const O=g[0],z=g[H],V=g[H+1],G=u(I,O,z,V);p.push(o.create(G))}}return p},u=(m,h,p,x)=>[r.create([m,p,h]),r.create([m,h,x]),r.create([h,p,x]),r.create([p,m,x])],_=(m,h)=>{const p=d(m),x=d(h);if(p.length===0||x.length===0)return o.create();const f=[];for(let y=0;y<p.length;y++){const b=p[y];for(let v=0;v<x.length;v++){const S=x[v];f.push([b[0]+S[0],b[1]+S[1],b[2]+S[2]])}}const g=i(f);return o.create(g)},d=m=>{const h=new Set,p=[],x=o.toPolygons(m);for(let f=0;f<x.length;f++){const g=x[f].vertices;for(let y=0;y<g.length;y++){const b=g[y],v=`${b[0]},${b[1]},${b[2]}`;h.has(v)||(h.add(v),p.push(b))}}return p};e.exports=a}}),a4n=it({"node_modules/@jscad/modeling/src/operations/booleans/scissionGeom3.js"(t,e){var n=Pr(),o=av(),r=Wi(),i=l=>l.sort((u,_)=>u-_).filter((u,_,d)=>!_||u!==d[_-1]),s=(l,u,_)=>{const d=`${u}`,m=l.get(d);m===void 0?l.set(d,[_]):m.push(_)},a=(l,u)=>{const _=`${u}`;return l.get(_)},c=l=>{const u=o(l),_=r.toPolygons(l),d=_.length,m=new Map,h=n.create();_.forEach((y,b)=>{y.vertices.forEach(v=>{s(m,n.snap(h,v,u),b)})});const p=_.map(y=>{let b=[];return y.vertices.forEach(v=>{b=b.concat(a(m,n.snap(h,v,u)))}),{e:1,d:i(b)}});m.clear();let x=0;const f=p.length;for(let y=0;y<f;y++){const b=p[y];if(b.e>0){const v=new Array(d);v[y]=!0;do x=0,v.forEach((S,M)=>{const w=p[M];if(w.e>0){w.e=-1;for(let D=0;D<w.d.length;D++)v[w.d[D]]=!0;x++}});while(x>0);b.indexes=v}}const g=[];for(let y=0;y<f;y++)if(p[y].indexes){const b=[];p[y].indexes.forEach((v,S)=>b.push(_[S])),g.push(r.create(b))}return g};e.exports=c}}),c4n=it({"node_modules/@jscad/modeling/src/operations/booleans/scission.js"(t,e){var n=vi(),o=Wi(),r=a4n(),i=(...s)=>{if(s=n(s),s.length===0)throw new Error("wrong number of arguments");const a=s.map(c=>o.isA(c)?r(c):c);return a.length===1?a[0]:a};e.exports=i}}),l4n=it({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3Sub.js"(t,e){var n=Wi(),o=Gfe(),{Tree:r}=Yfe(),i=(s,a)=>{if(!o(s,a))return n.clone(s);const c=new r(n.toPolygons(s)),l=new r(n.toPolygons(a));c.invert(),c.clipTo(l),l.clipTo(c,!0),c.addPolygons(l.allPolygons()),c.invert();const u=c.allPolygons();return n.create(u)};e.exports=i}}),xZe=it({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3.js"(t,e){var n=vi(),o=hN(),r=l4n(),i=(...s)=>{s=n(s);let a=s.shift();return s.forEach(c=>{a=r(a,c)}),a=o(a),a};e.exports=i}}),u4n=it({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom2.js"(t,e){var n=vi(),o=Wi(),r=av(),i=Xfe(),s=jfe(),a=xZe(),c=(...l)=>{l=n(l);const u=l.map(m=>s({z0:-1,z1:1},m)),_=a(u),d=r(_);return i(d,o.toPolygons(_))};e.exports=c}}),_4n=it({"node_modules/@jscad/modeling/src/operations/booleans/subtract.js"(t,e){var n=vi(),o=dN(),r=Gi(),i=Wi(),s=u4n(),a=xZe(),c=(...l)=>{if(l=n(l),l.length===0)throw new Error("wrong number of arguments");if(!o(l))throw new Error("only subtract of the types are supported");const u=l[0];return r.isA(u)?s(l):i.isA(u)?a(l):u};e.exports=c}}),gZe=it({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom2.js"(t,e){var n=vi(),o=Wi(),r=av(),i=Xfe(),s=jfe(),a=Jfe(),c=(...l)=>{l=n(l);const u=l.map(m=>s({z0:-1,z1:1},m)),_=a(u),d=r(_);return i(d,o.toPolygons(_))};e.exports=c}}),Kfe=it({"node_modules/@jscad/modeling/src/operations/booleans/union.js"(t,e){var n=vi(),o=dN(),r=Gi(),i=Wi(),s=gZe(),a=Jfe(),c=(...l)=>{if(l=n(l),l.length===0)throw new Error("wrong number of arguments");if(!o(l))throw new Error("only unions of the same type are supported");const u=l[0];return r.isA(u)?s(l):i.isA(u)?a(l):u};e.exports=c}}),mN=it({"node_modules/@jscad/modeling/src/operations/booleans/index.js"(t,e){e.exports={intersect:s4n(),minkowski:fZe(),scission:c4n(),subtract:_4n(),union:Kfe()}}}),PX=it({"node_modules/@jscad/modeling/src/operations/expansions/offsetFromPoints.js"(t,e){var{EPS:n,TAU:o}=Js(),r=GQe(),i=zfe(),s=hs(),a=gX(),c=(l,u)=>{const _={delta:1,corners:"edge",closed:!1,segments:16};let{delta:d,corners:m,closed:h,segments:p}=Object.assign({},_,l);if(Math.abs(d)<n)return u;let x=l.closed?a(u):1;x===0&&(x=1);const f=x>0&&d>=0||x<0&&d<0;d=Math.abs(d);let g=null,y=[];const b=[],v=s.create(),S=u.length;for(let M=0;M<S;M++){const w=(M+1)%S,D=u[M],A=u[w];f?s.subtract(v,D,A):s.subtract(v,A,D),s.normal(v,v),s.normalize(v,v),s.scale(v,v,d);const I=s.add(s.create(),D,v),H=s.add(s.create(),A,v),O=[I,H];if(g!=null&&(h||!h&&w!==0)){const z=r(g[0],g[1],O[0],O[1]);z?(y.pop(),O[0]=z):b.push({c:D,s0:g,s1:O})}g=[I,H],!(w===0&&!h)&&(y.push(O[0]),y.push(O[1]))}if(h&&g!=null){const M=y[0],w=y[1],D=r(g[0],g[1],M,w);if(D)y[0]=D,y.pop();else{const A=u[0],I=[M,w];b.push({c:A,s0:g,s1:I})}}if(m==="edge"){const M=new Map;y.forEach((A,I)=>M.set(A,I));const w=i.create(),D=i.create();b.forEach(A=>{i.fromPoints(w,A.s0[0],A.s0[1]),i.fromPoints(D,A.s1[0],A.s1[1]);const I=i.intersectPointOfLines(w,D);if(Number.isFinite(I[0])&&Number.isFinite(I[1])){const H=A.s0[1],O=M.get(H);y[O]=I,y[(O+1)%y.length]=void 0}else{const H=A.s1[0],O=M.get(H);y[O]=void 0}}),y=y.filter(A=>A!==void 0)}if(m==="round"){let M=Math.floor(p/4);const w=s.create();b.forEach(D=>{let A=s.angle(s.subtract(w,D.s1[0],D.c));if(A-=s.angle(s.subtract(w,D.s0[1],D.c)),f&&A<0&&(A=A+Math.PI,A<0&&(A=A+Math.PI)),!f&&A>0&&(A=A-Math.PI,A>0&&(A=A-Math.PI)),A!==0){M=Math.floor(p*(Math.abs(A)/o));const I=A/M,H=s.angle(s.subtract(w,D.s0[1],D.c)),O=[];for(let z=1;z<M;z++){const V=H+I*z,G=s.fromAngleRadians(s.create(),V);s.scale(G,G,d),s.add(G,G,D.c),O.push(G)}if(O.length>0){const z=D.s0[1];let V=y.findIndex(G=>s.equals(z,G));V=(V+1)%y.length,y.splice(V,0,...O)}}else{const I=D.s1[0],H=y.findIndex(O=>s.equals(I,O));y.splice(H,1)}})}return y};e.exports=c}}),d4n=it({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom2.js"(t,e){var n=Gi(),o=PX(),r=(i,s)=>{const a={delta:1,corners:"edge",segments:16},{delta:c,corners:l,segments:u}=Object.assign({},a,i);if(!(l==="edge"||l==="chamfer"||l==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const m=n.toOutlines(s).map(h=>(i={delta:c,corners:l,closed:!0,segments:u},o(i,h))).reduce((h,p)=>h.concat(n.toSides(n.fromPoints(p))),[]);return n.create(m)};e.exports=r}}),h4n=it({"node_modules/@jscad/modeling/src/operations/expansions/extrudePolygon.js"(t,e){var n=El(),o=Pr(),r=Wi(),i=Is(),s=(a,c)=>{o.dot(i.plane(c),a)>0&&(c=i.invert(c));const u=[c],_=i.transform(n.fromTranslation(n.create(),a),c),d=c.vertices.length;for(let m=0;m<d;m++){const h=m<d-1?m+1:0,p=i.create([c.vertices[m],_.vertices[m],_.vertices[h],c.vertices[h]]);u.push(p)}return u.push(i.invert(_)),r.create(u)};e.exports=s}}),m4n=it({"node_modules/@jscad/modeling/src/operations/expansions/expandShell.js"(t,e){var{EPS:n,TAU:o}=Js(),r=El(),i=Pr(),s=dZe(),a=Wi(),c=Is(),l=iZe(),u=hN(),_=pZe(),d=h4n(),m=(f,g,y)=>{const b=g.toString();if(f.has(b))f.get(b)[1].push(y);else{const v=[g,[y]];f.set(b,v)}},h=(f,g,y)=>{const b=g[0].toString(),v=g[1].toString(),S=b<v?`${b},${v}`:`${v},${b}`;if(f.has(S))f.get(S)[1].push(y);else{const M=[g,[y]];f.set(S,M)}},p=(f,g)=>{f.findIndex(b=>b===g)<0&&f.push(g)},x=(f,g)=>{const y={delta:1,segments:12},{delta:b,segments:v}=Object.assign({},y,f);let S=a.create();const M=new Map,w=new Map,D=i.create(),A=i.create();return a.toPolygons(g).forEach((H,O)=>{const z=i.scale(i.create(),c.plane(H),2*b),V=c.transform(r.fromTranslation(r.create(),i.scale(i.create(),z,-.5)),H),G=d(z,V);S=_(S,G);const q=H.vertices;for(let K=0;K<q.length;K++){m(M,q[K],c.plane(H));const ne=(K+1)%q.length,ce=[q[K],q[ne]];h(w,ce,c.plane(H))}}),w.forEach(H=>{const O=H[0],z=H[1],V=O[0],G=O[1],q=i.subtract(i.create(),G,V);i.normalize(q,q);const K=z[0],ne=i.cross(i.create(),K,q);let ce=[];for(let De=0;De<v;De++)p(ce,De*o/v);for(let De=0,pe=z.length;De<pe;De++){const Me=z[De],xe=i.dot(ne,Me),We=i.dot(K,Me);let Xe=Math.atan2(xe,We);Xe<0&&(Xe+=o),p(ce,Xe),Xe=Math.atan2(-xe,-We),Xe<0&&(Xe+=o),p(ce,Xe)}ce=ce.sort(s);const ee=ce.length;let oe,ie;const ae=[],de=[],be=[];for(let De=-1;De<ee;De++){const pe=ce[De<0?De+ee:De],Me=Math.sin(pe),xe=Math.cos(pe);i.scale(D,K,xe*b),i.scale(A,ne,Me*b),i.add(D,D,A);const We=i.add(i.create(),V,D),Xe=i.add(i.create(),G,D);let Je=!1;if(De>=0&&i.distance(We,oe)<n&&(Je=!0),!Je){if(De>=0){ae.push(We),de.push(Xe);const fe=[ie,Xe,We,oe],Ye=c.create(fe);be.push(Ye)}oe=We,ie=Xe}}de.reverse(),be.push(c.create(ae)),be.push(c.create(de));const Ce=a.create(be);S=_(S,Ce)}),M.forEach(H=>{const O=H[0],z=H[1],V=z[0];let G=null,q=0;for(let ee=1;ee<z.length;ee++){const oe=z[ee],ie=i.cross(D,V,oe),ae=i.length(ie);ae>.05&&ae>q&&(q=ae,G=oe)}G||(G=i.orthogonal(D,V));const K=i.cross(D,V,G);i.normalize(K,K);const ne=i.cross(A,K,V),ce=l({center:[O[0],O[1],O[2]],radius:b,segments:v,axes:[V,K,ne]});S=_(S,ce)}),u(S)};e.exports=x}}),p4n=it({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom3.js"(t,e){var n=Wi(),o=Kfe(),r=m4n(),i=(s,a)=>{const c={delta:1,corners:"round",segments:12},{delta:l,corners:u,segments:_}=Object.assign({},c,s);if(u!=="round")throw new Error('corners must be "round" for 3D geometries');if(n.toPolygons(a).length===0)throw new Error("the given geometry cannot be empty");s={delta:l,corners:u,segments:_};const m=r(s,a);return o(a,m)};e.exports=i}}),f4n=it({"node_modules/@jscad/modeling/src/operations/expansions/expandPath2.js"(t,e){var n=gX(),o=hs(),r=Gi(),i=ll(),s=PX(),a=u=>{let{external:_,internal:d}=u;n(_)<0?_=_.reverse():d=d.reverse();const m=i.fromPoints({closed:!0},_),h=i.fromPoints({closed:!0},d),p=r.toSides(r.fromPoints(i.toPoints(m))),x=r.toSides(r.fromPoints(i.toPoints(h)));return p.push(...x),r.create(p)},c=(u,_,d,m)=>{const{points:h,external:p,internal:x}=u,f=Math.floor(_/2),g=[],y=[];if(d==="round"&&f>0){const v=Math.PI/f,S=h[h.length-1],M=o.angle(o.subtract(o.create(),p[p.length-1],S)),w=h[0],D=o.angle(o.subtract(o.create(),x[0],w));for(let A=1;A<f;A++){let I=M+v*A,H=o.fromAngleRadians(o.create(),I);o.scale(H,H,m),o.add(H,H,S),g.push(H),I=D+v*A,H=o.fromAngleRadians(o.create(),I),o.scale(H,H,m),o.add(H,H,w),y.push(H)}}const b=[];return b.push(...p,...g,...x.reverse(),...y),r.fromPoints(b)},l=(u,_)=>{u=Object.assign({},{delta:1,corners:"edge",segments:16},u);const{delta:m,corners:h,segments:p}=u;if(m<=0)throw new Error("the given delta must be positive for paths");if(!(h==="edge"||h==="chamfer"||h==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const x=_.isClosed,f=i.toPoints(_);if(f.length===0)throw new Error("the given geometry cannot be empty");const g={points:f,external:s({delta:m,corners:h,segments:p,closed:x},f),internal:s({delta:-m,corners:h,segments:p,closed:x},f)};return _.isClosed?a(g):c(g,p,h,m)};e.exports=l}}),Qfe=it({"node_modules/@jscad/modeling/src/operations/expansions/expand.js"(t,e){var n=vi(),o=Gi(),r=Wi(),i=ll(),s=d4n(),a=p4n(),c=f4n(),l=(u,..._)=>{if(_=n(_),_.length===0)throw new Error("wrong number of arguments");const d=_.map(m=>i.isA(m)?c(u,m):o.isA(m)?s(u,m):r.isA(m)?a(u,m):m);return d.length===1?d[0]:d};e.exports=l}}),x4n=it({"node_modules/@jscad/modeling/src/operations/expansions/offsetGeom2.js"(t,e){var n=Gi(),o=Ife(),r=PX(),i=(s,a)=>{const c={delta:1,corners:"edge",segments:0},{delta:l,corners:u,segments:_}=Object.assign({},c,s);if(!(u==="edge"||u==="chamfer"||u==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const d=n.toOutlines(a),h=d.map(p=>(s={delta:d.reduce((g,y)=>g+o.arePointsInside(p,o.create(y)),0)%2===0?l:-l,corners:u,closed:!0,segments:_},r(s,p))).reduce((p,x)=>p.concat(n.toSides(n.fromPoints(x))),[]);return n.create(h)};e.exports=i}}),g4n=it({"node_modules/@jscad/modeling/src/operations/expansions/offsetPath2.js"(t,e){var n=ll(),o=PX(),r=(i,s)=>{const a={delta:1,corners:"edge",closed:s.isClosed,segments:16},{delta:c,corners:l,closed:u,segments:_}=Object.assign({},a,i);if(!(l==="edge"||l==="chamfer"||l==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');i={delta:c,corners:l,closed:u,segments:_};const d=o(i,n.toPoints(s));return n.fromPoints({closed:u},d)};e.exports=r}}),y4n=it({"node_modules/@jscad/modeling/src/operations/expansions/offset.js"(t,e){var n=vi(),o=Gi(),r=ll(),i=x4n(),s=g4n(),a=(c,...l)=>{if(l=n(l),l.length===0)throw new Error("wrong number of arguments");const u=l.map(_=>r.isA(_)?s(c,_):o.isA(_)?i(c,_):_);return u.length===1?u[0]:u};e.exports=a}}),yZe=it({"node_modules/@jscad/modeling/src/operations/expansions/index.js"(t,e){e.exports={expand:Qfe(),offset:y4n()}}}),vX=it({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearGeom2.js"(t,e){var n=El(),o=Pr(),r=Gi(),i=Yw(),s=bX(),a=(c,l)=>{const u={offset:[0,0,1],twistAngle:0,twistSteps:12,repair:!0};let{offset:_,twistAngle:d,twistSteps:m,repair:h}=Object.assign({},u,c);if(m<1)throw new Error("twistSteps must be 1 or more");d===0&&(m=1);const p=o.clone(_),x=r.toSides(l);if(x.length===0)throw new Error("the given geometry cannot be empty");const f=i.fromSides(x);p[2]<0&&i.reverse(f,f);const g=n.create(),y=(b,v,S)=>{const M=v/m*d,w=o.scale(o.create(),p,v/m);return n.multiply(g,n.fromZRotation(g,M),n.fromTranslation(n.create(),w)),i.transform(g,S)};return c={numberOfSlices:m+1,capStart:!0,capEnd:!0,repair:h,callback:y},s(c,f)};e.exports=a}}),b4n=it({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearPath2.js"(t,e){var n=Gi(),o=ll(),r=vX(),i=(s,a)=>{if(!a.isClosed)throw new Error("extruded path must be closed");const c=o.toPoints(a),l=n.fromPoints(c);return r(s,l)};e.exports=i}}),P4n=it({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinear.js"(t,e){var n=vi(),o=Gi(),r=ll(),i=vX(),s=b4n(),a=(c,...l)=>{const u={height:1,twistAngle:0,twistSteps:1,repair:!0},{height:_,twistAngle:d,twistSteps:m,repair:h}=Object.assign({},u,c);if(l=n(l),l.length===0)throw new Error("wrong number of arguments");c={offset:[0,0,_],twistAngle:d,twistSteps:m,repair:h};const p=l.map(x=>r.isA(x)?s(c,x):o.isA(x)?i(c,x):x);return p.length===1?p[0]:p};e.exports=a}}),v4n=it({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularPath2.js"(t,e){var n=ll(),o=Qfe(),r=vX(),i=(s,a)=>{const c={size:1,height:1},{size:l,height:u}=Object.assign({},c,s);if(s.delta=l,s.offset=[0,0,u],n.toPoints(a).length===0)throw new Error("the given geometry cannot be empty");const d=o(s,a);return r(s,d)};e.exports=i}}),S4n=it({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularGeom2.js"(t,e){var{area:n}=cN(),o=Gi(),r=ll(),i=Qfe(),s=vX(),a=(c,l)=>{const u={size:1,height:1},{size:_,height:d}=Object.assign({},u,c);c.delta=_,c.offset=[0,0,d];const m=o.toOutlines(l);if(m.length===0)throw new Error("the given geometry cannot be empty");const p=m.map(f=>(n(f)<0&&f.reverse(),i(c,r.fromPoints({closed:!0},f)))).reduce((f,g)=>f.concat(o.toSides(g)),[]),x=o.create(p);return s(c,x)};e.exports=a}}),C4n=it({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangular.js"(t,e){var n=vi(),o=Gi(),r=ll(),i=v4n(),s=S4n(),a=(c,...l)=>{const u={size:1,height:1},{size:_,height:d}=Object.assign({},u,c);if(l=n(l),l.length===0)throw new Error("wrong number of arguments");if(_<=0)throw new Error("size must be positive");if(d<=0)throw new Error("height must be positive");const m=l.map(h=>r.isA(h)?i(c,h):o.isA(h)?s(c,h):h);return m.length===1?m[0]:m};e.exports=a}}),M4n=it({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeHelical.js"(t,e){var{TAU:n}=Js(),o=El(),r=Gi(),i=bX(),s=Yw(),a=(c,l)=>{const u={angle:n,startAngle:0,pitch:10,height:0,endOffset:0,segmentsPerRotation:32};let{angle:_,startAngle:d,pitch:m,height:h,endOffset:p,segmentsPerRotation:x}=Object.assign({},u,c);if(h!=0&&(m=h/(_/n)),x<3)throw new Error("The number of segments per rotation needs to be at least 3.");const g=r.toSides(l);if(g.length===0)throw new Error("The given geometry cannot be empty");const y=g.filter(A=>A[0][0]>=0);let b=s.fromSides(g);y.length===0&&(b=s.reverse(b));const v=Math.round(x/n*Math.abs(_)),S=v>=2?v:2,M=o.create(),w=o.create(),D=(A,I,H)=>{const O=d+_/S*I,z=p/S*I,V=(O-d)/n*m;return o.multiply(M,o.fromTranslation(o.create(),[z,0,V*Math.sign(_)]),o.fromXRotation(o.create(),-n/4*Math.sign(_))),o.multiply(w,o.fromZRotation(o.create(),O),M),s.transform(w,H)};return i({numberOfSlices:S+1,callback:D},b)};e.exports=a}}),T4n=it({"node_modules/@jscad/modeling/src/operations/extrusions/project.js"(t,e){var n=vi(),o=Bfe(),r=J6(),i=El(),s=Gi(),a=Wi(),c=Is(),l=av(),u=gZe(),_=(m,h)=>{const p=r.fromNormalAndPoint(r.create(),m.axis,m.origin);if(Number.isNaN(p[0])||Number.isNaN(p[1])||Number.isNaN(p[2])||Number.isNaN(p[3]))throw new Error("project: invalid axis or origin");const x=l(h),f=x*x*Math.sqrt(3)/4;if(x===0)return s.create();const g=a.toPolygons(h);let y=[];for(let v=0;v<g.length;v++){const S=g[v].vertices.map(D=>r.projectionOfPoint(p,D)),M=c.create(S),w=c.plane(M);o(p,w)&&(c.measureArea(M)<f||y.push(M))}if(!o(p,[0,0,1])){const v=i.fromVectorRotation(i.create(),p,[0,0,1]);y=y.map(S=>c.transform(v,S))}y=y.sort((v,S)=>c.measureArea(S)-c.measureArea(v));const b=y.map(v=>s.fromPoints(v.vertices));return u(b)},d=(m,...h)=>{const p={axis:[0,0,1],origin:[0,0,0]},{axis:x,origin:f}=Object.assign({},p,m);if(h=n(h),h.length===0)throw new Error("wrong number of arguments");m={axis:x,origin:f};const g=h.map(y=>a.isA(y)?_(m,y):y);return g.length===1?g[0]:g};e.exports=d}}),pN=it({"node_modules/@jscad/modeling/src/operations/extrusions/index.js"(t,e){e.exports={extrudeFromSlices:bX(),extrudeLinear:P4n(),extrudeRectangular:C4n(),extrudeRotate:lZe(),extrudeHelical:M4n(),project:T4n(),slice:Yw()}}}),Zfe=it({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints2.js"(t,e){var n=hs(),o=s=>{let a=n.fromValues(1/0,1/0);s.forEach(u=>{(u[1]<a[1]||u[1]===a[1]&&u[0]<a[0])&&(a=u)});const c=[];s.forEach(u=>{const _=i(u[1]-a[1],u[0]-a[0]),d=n.squaredDistance(u,a);c.push({point:u,angle:_,distSq:d})}),c.sort((u,_)=>u.angle!==_.angle?u.angle-_.angle:u.distSq-_.distSq);const l=[];return c.forEach(u=>{let _=l.length;for(;_>1&&r(l[_-2],l[_-1],u.point)<=Number.EPSILON;)l.pop(),_=l.length;l.push(u.point)}),l},r=(s,a,c)=>(a[0]-s[0])*(c[1]-s[1])-(a[1]-s[1])*(c[0]-s[0]),i=(s,a)=>s===0&&a===0?-1/0:-a/s;e.exports=o}}),e1e=it({"node_modules/@jscad/modeling/src/operations/hulls/toUniquePoints.js"(t,e){var n=Gi(),o=Wi(),r=ll(),i=s=>{const a=new Set,c=[],l=u=>{const _=u.toString();a.has(_)||(c.push(u),a.add(_))};return s.forEach(u=>{n.isA(u)?n.toPoints(u).forEach(l):o.isA(u)?o.toPoints(u).forEach(_=>_.forEach(l)):r.isA(u)&&r.toPoints(u).forEach(l)}),c};e.exports=i}}),w4n=it({"node_modules/@jscad/modeling/src/operations/hulls/hullPath2.js"(t,e){var n=vi(),o=ll(),r=Zfe(),i=e1e(),s=(...a)=>{a=n(a);const c=i(a),l=r(c);return o.fromPoints({closed:!0},l)};e.exports=s}}),E4n=it({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom2.js"(t,e){var n=vi(),o=Gi(),r=Zfe(),i=e1e(),s=(...a)=>{a=n(a);const c=i(a),l=r(c);return l.length<3?o.create():o.fromPoints(l)};e.exports=s}}),D4n=it({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom3.js"(t,e){var n=vi(),o=Wi(),r=e1e(),i=qfe(),s=(...a)=>{a=n(a);const c=r(a);return c.length===0?o.create():o.create(i(c))};e.exports=s}}),bZe=it({"node_modules/@jscad/modeling/src/operations/hulls/hull.js"(t,e){var n=vi(),o=dN(),r=Gi(),i=Wi(),s=ll(),a=w4n(),c=E4n(),l=D4n(),u=(..._)=>{if(_=n(_),_.length===0)throw new Error("wrong number of arguments");if(!o(_))throw new Error("only hulls of the same type are supported");const d=_[0];return s.isA(d)?a(_):r.isA(d)?c(_):i.isA(d)?l(_):d};e.exports=u}}),A4n=it({"node_modules/@jscad/modeling/src/operations/hulls/hullChain.js"(t,e){var n=vi(),o=Kfe(),r=bZe(),i=(...s)=>{if(s=n(s),s.length<2)throw new Error("wrong number of arguments");const a=[];for(let c=1;c<s.length;c++)a.push(r(s[c-1],s[c]));return o(a)};e.exports=i}}),R4n=it({"node_modules/@jscad/modeling/src/operations/hulls/index.js"(t,e){e.exports={hull:bZe(),hullChain:A4n(),hullPoints2:Zfe(),hullPoints3:qfe()}}}),k4n=it({"node_modules/@jscad/modeling/src/operations/minkowski/index.js"(t,e){e.exports={minkowskiSum:fZe()}}}),PZe=it({"node_modules/@jscad/modeling/src/operations/modifiers/snapPolygons.js"(t,e){var n=Pr(),o=Is(),r=(s,a)=>{const c=Math.abs(o.measureArea(a));return Number.isFinite(c)&&c>s},i=(s,a)=>{let c=a.map(u=>{const _=u.vertices.map(h=>n.snap(n.create(),h,s)),d=[];for(let h=0;h<_.length;h++){const p=(h+1)%_.length;n.equals(_[h],_[p])||d.push(_[h])}const m=o.create(d);return u.color&&(m.color=u.color),m});const l=s*s*Math.sqrt(3)/4;return c=c.filter(u=>r(l,u)),c};e.exports=i}}),N4n=it({"node_modules/@jscad/modeling/src/operations/modifiers/mergePolygons.js"(t,e){var n=Bfe(),o=Pr(),r=Is(),i=f=>{const g=r.toPoints(f),y=[];for(let b=0;b<g.length;b++){const v=(b+1)%g.length,S={v1:g[b],v2:g[v]};y.push(S)}for(let b=0;b<y.length;b++){const v=(b+1)%g.length;y[b].next=y[v],y[v].prev=y[b]}return y},s=(f,g)=>{const y=`${g.v1}:${g.v2}`;f.set(y,g)},a=(f,g)=>{const y=`${g.v1}:${g.v2}`;f.delete(y)},c=(f,g)=>{const y=`${g.v2}:${g.v1}`;return f.get(y)},l=(f,g,y)=>{let b=f.prev.v1,v=f.prev.v2,S=g.next.v2;const M=d(b,v,S,y);b=g.prev.v1,v=g.prev.v2,S=f.next.v2;const w=d(b,v,S,y);return[M,w]},u=o.create(),_=o.create(),d=(f,g,y,b)=>{const v=o.subtract(u,g,f),S=o.subtract(_,y,g);return o.cross(v,v,S),o.dot(v,b)},m=f=>{let g;const y=[];for(;f.next;){const b=f.next;y.push(f.v1),f.v1=null,f.v2=null,f.next=null,f.prev=null,f=b}return y.length>0&&(g=r.create(y)),g},h=f=>{if(f.length<2)return f;const g=f[0].plane,y=f.slice(),b=new Map;for(;y.length>0;){const S=y.shift(),M=i(S);for(let w=0;w<M.length;w++){const D=M[w],A=c(b,D);if(A){const I=l(D,A,g);if(I[0]>=0&&I[1]>=0){const H=A.next,O=D.next;D.prev.next=A.next,D.next.prev=A.prev,A.prev.next=D.next,A.next.prev=D.prev,D.v1=null,D.v2=null,D.next=null,D.prev=null,a(b,A),A.v1=null,A.v2=null,A.next=null,A.prev=null;const z=(V,G,q)=>{const K={v1:q.v1,v2:G.v2,next:G.next,prev:q.prev};q.prev.next=K,G.next.prev=K,a(V,G),G.v1=null,G.v2=null,G.next=null,G.prev=null,a(V,q),q.v1=null,q.v2=null,q.next=null,q.prev=null};I[0]===0&&z(b,H,H.prev),I[1]===0&&z(b,O,O.prev)}}else D.next&&s(b,D)}}const v=[];return b.forEach(S=>{const M=m(S);M&&v.push(M)}),b.clear(),v},p=(f,g)=>Math.abs(f[3]-g[3])<15e-8?n(f,g):!1,x=(f,g)=>{const y=[];g.forEach(v=>{const S=y.find(M=>p(M[0],r.plane(v)));S?S[1].push(v):y.push([r.plane(v),[v]])});let b=[];return y.forEach(v=>{const S=v[1],M=h(S);b=b.concat(M)}),b};e.exports=x}}),H4n=it({"node_modules/@jscad/modeling/src/operations/modifiers/insertTjunctions.js"(t,e){var n=Js(),o=Pr(),r=Is(),i=l=>`${l}`,s=(l,u,_,d,m,h)=>{const p=i(d),x=i(m),f=`${p}/${x}`,g=`${x}/${p}`;if(l.has(g))return a(l,u,_,m,d,null),null;const y={vertex0:d,vertex1:m,polygonindex:h};return l.has(f)?l.get(f).push(y):l.set(f,[y]),u.has(p)?u.get(p).push(f):u.set(p,[f]),_.has(x)?_.get(x).push(f):_.set(x,[f]),f},a=(l,u,_,d,m,h)=>{const p=i(d),x=i(m),f=`${p}/${x}`;let g=-1;const y=l.get(f);for(let b=0;b<y.length;b++){const v=y[b];let S=i(v.vertex0);if(S===p&&(S=i(v.vertex1),S===x&&!(h!==null&&v.polygonindex!==h))){g=b;break}}y.splice(g,1),y.length===0&&l.delete(f),g=u.get(p).indexOf(f),u.get(p).splice(g,1),u.get(p).length===0&&u.delete(p),g=_.get(x).indexOf(f),_.get(x).splice(g,1),_.get(x).length===0&&_.delete(x)},c=l=>{const u=new Map;for(let _=0;_<l.length;_++){const d=l[_],m=d.vertices.length;if(m>=3){let h=d.vertices[0],p=i(h);for(let x=0;x<m;x++){let f=x+1;f===m&&(f=0);const g=d.vertices[f],y=i(g),b=`${p}/${y}`,v=`${y}/${p}`;if(u.has(v)){const S=u.get(v);S.splice(-1,1),S.length===0&&u.delete(v)}else{const S={vertex0:h,vertex1:g,polygonindex:_};u.has(b)?u.get(b).push(S):u.set(b,[S])}h=g,p=y}}else console.warn("warning: invalid polygon found during insertTjunctions")}if(u.size>0){const _=new Map,d=new Map,m=new Map;for(const[p,x]of u)m.set(p,!0),x.forEach(f=>{const g=i(f.vertex0),y=i(f.vertex1);_.has(g)?_.get(g).push(p):_.set(g,[p]),d.has(y)?d.get(y).push(p):d.set(y,[p])});const h=l.slice(0);for(;u.size!==0;){for(const x of u.keys())m.set(x,!0);let p=!1;for(;;){const x=Array.from(m.keys());if(x.length===0)break;const f=x[0];let g=!0;if(u.has(f)){const b=u.get(f)[0];for(let v=0;v<2;v++){const S=v===0?b.vertex0:b.vertex1,M=v===0?b.vertex1:b.vertex0,w=i(S),D=i(M);let A=[];v===0?d.has(w)&&(A=d.get(w)):_.has(w)&&(A=_.get(w));for(let I=0;I<A.length;I++){const H=A[I],O=u.get(H)[0],z=v===0?O.vertex0:O.vertex1;if(v===0?O.vertex1:O.vertex0,i(z)===D){a(u,_,d,S,M,null),a(u,_,d,M,S,null),g=!1,v=2,p=!0;break}else{const G=S,q=M,K=z,ne=o.subtract(o.create(),K,G),ce=o.dot(o.subtract(o.create(),q,G),ne)/o.dot(ne,ne);if(ce>0&&ce<1){const ee=o.scale(o.create(),ne,ce);if(o.add(ee,ee,G),o.squaredDistance(ee,q)<n.EPS*n.EPS){const ie=O.polygonindex,ae=h[ie],de=i(O.vertex1);let be=-1;for(let xe=0;xe<ae.vertices.length;xe++)if(i(ae.vertices[xe])===de){be=xe;break}const Ce=ae.vertices.slice(0);Ce.splice(be,0,M);const De=r.create(Ce);h[ie]=De,a(u,_,d,O.vertex0,O.vertex1,ie);const pe=s(u,_,d,O.vertex0,M,ie),Me=s(u,_,d,M,O.vertex1,ie);pe!==null&&m.set(pe,!0),Me!==null&&m.set(Me,!0),g=!1,v=2,p=!0;break}}}}}}g&&m.delete(f)}if(!p)break}l=h}return u.clear(),l};e.exports=c}}),I4n=it({"node_modules/@jscad/modeling/src/operations/modifiers/triangulatePolygons.js"(t,e){var n=Pr(),o=Is(),r=(s,a,c)=>{const l=a.vertices.length;if(l>3){if(l>4){const d=[0,0,0];a.vertices.forEach(m=>n.add(d,d,m)),n.snap(d,n.divide(d,d,[l,l,l]),s);for(let m=0;m<l;m++){const h=o.create([d,a.vertices[m],a.vertices[(m+1)%l]]);a.color&&(h.color=a.color),c.push(h)}return}const u=o.create([a.vertices[0],a.vertices[1],a.vertices[2]]),_=o.create([a.vertices[0],a.vertices[2],a.vertices[3]]);a.color&&(u.color=a.color,_.color=a.color),c.push(u,_);return}c.push(a)},i=(s,a)=>{const c=[];return a.forEach(l=>{r(s,l,c)}),c};e.exports=i}}),L4n=it({"node_modules/@jscad/modeling/src/operations/modifiers/generalize.js"(t,e){var n=vi(),o=av(),r=Gi(),i=Wi(),s=ll(),a=PZe(),c=N4n(),l=H4n(),u=I4n(),_=(p,x)=>x,d=(p,x)=>x,m=(p,x)=>{const f={snap:!1,simplify:!1,triangulate:!1},{snap:g,simplify:y,triangulate:b}=Object.assign({},f,p),v=o(x);let S=i.toPolygons(x);g&&(S=a(v,S)),y&&(S=c(v,S)),b&&(S=l(S),S=u(v,S));const M=Object.assign({},x);return M.polygons=S,M},h=(p,...x)=>{if(x=n(x),x.length===0)throw new Error("wrong number of arguments");const f=x.map(g=>{if(s.isA(g))return _(p,g);if(r.isA(g))return d(p,g);if(i.isA(g))return m(p,g);throw new Error("invalid geometry")});return f.length===1?f[0]:f};e.exports=h}}),O4n=it({"node_modules/@jscad/modeling/src/operations/modifiers/snap.js"(t,e){var n=vi(),o=hs(),r=Gi(),i=Wi(),s=ll(),a=av(),c=PZe(),l=m=>{const h=a(m),x=s.toPoints(m).map(f=>o.snap(o.create(),f,h));return s.create(x)},u=m=>{const h=a(m);let x=r.toSides(m).map(f=>[o.snap(o.create(),f[0],h),o.snap(o.create(),f[1],h)]);return x=x.filter(f=>!o.equals(f[0],f[1])),r.create(x)},_=m=>{const h=a(m),p=i.toPolygons(m),x=c(h,p);return i.create(x)},d=(...m)=>{if(m=n(m),m.length===0)throw new Error("wrong number of arguments");const h=m.map(p=>s.isA(p)?l(p):r.isA(p)?u(p):i.isA(p)?_(p):p);return h.length===1?h[0]:h};e.exports=d}}),F4n=it({"node_modules/@jscad/modeling/src/operations/modifiers/index.js"(t,e){e.exports={generalize:L4n(),snap:O4n(),retessellate:hN()}}}),B4n=it({"node_modules/@jscad/modeling/src/utils/padArrayToLength.js"(t,e){var n=(o,r,i)=>{for(o=o.slice();o.length<i;)o.push(r);return o};e.exports=n}}),z4n=it({"node_modules/@jscad/modeling/src/operations/transforms/align.js"(t,e){var n=vi(),o=B4n(),r=Vfe(),{translate:i}=_8(),s=u=>{if(!Array.isArray(u.modes)||u.modes.length>3)throw new Error("align(): modes must be an array of length <= 3");if(u.modes=o(u.modes,"none",3),u.modes.filter(_=>["center","max","min","none"].includes(_)).length!==3)throw new Error('align(): all modes must be one of "center", "max" or "min"');if(!Array.isArray(u.relativeTo)||u.relativeTo.length>3)throw new Error("align(): relativeTo must be an array of length <= 3");if(u.relativeTo=o(u.relativeTo,0,3),u.relativeTo.filter(_=>Number.isFinite(_)||_==null).length!==3)throw new Error("align(): all relativeTo values must be a number, or null.");if(typeof u.grouped!="boolean")throw new Error("align(): grouped must be a boolean value.");return u},a=(u,_,d)=>{for(let m=0;m<3;m++)u[m]==null&&(_[m]==="center"?u[m]=(d[0][m]+d[1][m])/2:_[m]==="max"?u[m]=d[1][m]:_[m]==="min"&&(u[m]=d[0][m]));return u},c=(u,_,d)=>{const m=r(u),h=[0,0,0];for(let p=0;p<3;p++)_[p]==="center"?h[p]=d[p]-(m[0][p]+m[1][p])/2:_[p]==="max"?h[p]=d[p]-m[1][p]:_[p]==="min"&&(h[p]=d[p]-m[0][p]);return i(h,u)},l=(u,..._)=>{u=Object.assign({},{modes:["center","center","min"],relativeTo:[0,0,0],grouped:!1},u),u=s(u);let{modes:m,relativeTo:h,grouped:p}=u;if(_=n(_),_.length===0)throw new Error("align(): No geometries were provided to act upon");if(h.filter(x=>x==null).length){const x=r(_);h=a(h,m,x)}return p?_=c(_,m,h):_=_.map(x=>c(x,m,h)),_.length===1?_[0]:_};e.exports=l}}),SX=it({"node_modules/@jscad/modeling/src/operations/transforms/center.js"(t,e){var n=vi(),o=Gi(),r=Wi(),i=ll(),s=l8(),{translate:a}=_8(),c=(m,h)=>{const p={axes:[!0,!0,!0],relativeTo:[0,0,0]},{axes:x,relativeTo:f}=Object.assign({},p,m),g=s(h),y=[0,0,0];return x[0]&&(y[0]=f[0]-(g[0][0]+(g[1][0]-g[0][0])/2)),x[1]&&(y[1]=f[1]-(g[0][1]+(g[1][1]-g[0][1])/2)),x[2]&&(y[2]=f[2]-(g[0][2]+(g[1][2]-g[0][2])/2)),a(y,h)},l=(m,...h)=>{const p={axes:[!0,!0,!0],relativeTo:[0,0,0]},{axes:x,relativeTo:f}=Object.assign({},p,m);if(h=n(h),h.length===0)throw new Error("wrong number of arguments");if(f.length!==3)throw new Error("relativeTo must be an array of length 3");m={axes:x,relativeTo:f};const g=h.map(y=>i.isA(y)||o.isA(y)||r.isA(y)?c(m,y):y);return g.length===1?g[0]:g},u=(...m)=>l({axes:[!0,!1,!1]},m),_=(...m)=>l({axes:[!1,!0,!1]},m),d=(...m)=>l({axes:[!1,!1,!0]},m);e.exports={center:l,centerX:u,centerY:_,centerZ:d}}}),CX=it({"node_modules/@jscad/modeling/src/operations/transforms/scale.js"(t,e){var n=vi(),o=El(),r=Gi(),i=Wi(),s=ll(),a=(_,...d)=>{if(!Array.isArray(_))throw new Error("factors must be an array");if(d=n(d),d.length===0)throw new Error("wrong number of arguments");for(_=_.slice();_.length<3;)_.push(1);if(_[0]<=0||_[1]<=0||_[2]<=0)throw new Error("factors must be positive");const m=o.fromScaling(o.create(),_),h=d.map(p=>s.isA(p)?s.transform(m,p):r.isA(p)?r.transform(m,p):i.isA(p)?i.transform(m,p):p);return h.length===1?h[0]:h},c=(_,...d)=>a([_,1,1],d),l=(_,...d)=>a([1,_,1],d),u=(_,...d)=>a([1,1,_],d);e.exports={scale:a,scaleX:c,scaleY:l,scaleZ:u}}}),V4n=it({"node_modules/@jscad/modeling/src/operations/transforms/transform.js"(t,e){var n=vi(),o=Gi(),r=Wi(),i=ll(),s=(a,...c)=>{if(c=n(c),c.length===0)throw new Error("wrong number of arguments");const l=c.map(u=>i.isA(u)?i.transform(a,u):o.isA(u)?o.transform(a,u):r.isA(u)?r.transform(a,u):u);return l.length===1?l[0]:l};e.exports=s}}),h8=it({"node_modules/@jscad/modeling/src/operations/transforms/index.js"(t,e){e.exports={align:z4n(),center:SX().center,centerX:SX().centerX,centerY:SX().centerY,centerZ:SX().centerZ,mirror:uN().mirror,mirrorX:uN().mirrorX,mirrorY:uN().mirrorY,mirrorZ:uN().mirrorZ,rotate:_N().rotate,rotateX:_N().rotateX,rotateY:_N().rotateY,rotateZ:_N().rotateZ,scale:CX().scale,scaleX:CX().scaleX,scaleY:CX().scaleY,scaleZ:CX().scaleZ,transform:V4n(),translate:_8().translate,translateX:_8().translateX,translateY:_8().translateY,translateZ:_8().translateZ}}}),MX=it({"node_modules/@jscad/modeling/src/index.js"(t,e){e.exports={colors:xX(),curves:Iyn(),geometries:Lfe(),maths:s5n(),measurements:m5n(),primitives:d8(),text:j5n(),utils:hZe(),booleans:mN(),expansions:yZe(),extrusions:pN(),hulls:R4n(),minkowski:k4n(),modifiers:F4n(),transforms:h8()}}}),vZe=it({"node_modules/jscad-planner/dist/index.cjs"(t,e){var n=Object.defineProperty,o=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,s=(d,m)=>{for(var h in m)n(d,h,{get:m[h],enumerable:!0})},a=(d,m,h,p)=>{if(m&&typeof m=="object"||typeof m=="function")for(let x of r(m))!i.call(d,x)&&x!==h&&n(d,x,{get:()=>m[x],enumerable:!(p=o(m,x))||p.enumerable});return d},c=d=>a(n({},"__esModule",{value:!0}),d),l={};s(l,{executeJscadOperations:()=>_,jscadPlanner:()=>u}),e.exports=c(l);var u={booleans:{intersect:(...d)=>({type:"intersect",shapes:d}),subtract:(...d)=>({type:"subtract",shapes:d}),union:(...d)=>({type:"union",shapes:d})},hulls:{hull:(...d)=>({type:"hull",shapes:d.flat()}),hullChain:(...d)=>({type:"hullChain",shapes:d.flat()})},colors:{colorize:(d,m)=>({type:"colorize",color:d,shape:m})},primitives:{cube:d=>({type:"cube",...d}),sphere:d=>({type:"sphere",...d}),cylinder:d=>({type:"cylinder",...d}),polygon:d=>({type:"polygon",...d}),cuboid:d=>({type:"cuboid",...d}),roundedCuboid:d=>({type:"roundedCuboid",...d})},transforms:{rotate:(d,m)=>({type:"rotate",angles:d,shape:m}),scale:(d,m)=>({type:"scale",factors:d,shape:m}),translate:(d,m)=>({type:"translate",vector:d,shape:m})},extrusions:{extrudeLinear:(d,m)=>({type:"extrudeLinear",options:d,shape:m}),extrudeRotate:(d,m)=>({type:"extrudeRotate",options:d,shape:m})},maths:{vec2:{create:(d,m)=>[d,m],fromValues:(d,m)=>[d,m]},vec3:{create:(d,m,h)=>[d,m,h],fromValues:(d,m,h)=>[d,m,h]}},geometries:{geom2:{create:d=>({type:"createGeom2",points:d})},geom3:{create:d=>({type:"createGeom3",polygons:d})},path2:{create:d=>({type:"createPath2",points:d})}},measurements:{measureBoundingBox:d=>({type:"measureBoundingBox",shape:d}),measureArea:d=>({type:"measureArea",shape:d}),measureVolume:d=>({type:"measureVolume",shape:d})},utils:{degToRad:d=>d*Math.PI/180,radToDeg:d=>d*180/Math.PI}},_=(d,m)=>{if(Array.isArray(m)&&m.length===1)return _(d,m[0]);if(Array.isArray(m))throw new Error("executeJscadOperations currently doesn't support Array<JscadOperation>, try adding a root union or or executing each element individually");const h=f=>_(d,f),{type:p,...x}=m;switch(p){case"intersect":return d.booleans.intersect(...m.shapes.map(h));case"subtract":return d.booleans.subtract(...m.shapes.map(h));case"union":return d.booleans.union(...m.shapes.map(h));case"hull":return d.hulls.hull(...m.shapes.map(h));case"hullChain":return d.hulls.hullChain(...m.shapes.map(h));case"colorize":return d.colors.colorize(m.color,h(m.shape));case"cube":return d.primitives.cube(x);case"sphere":return d.primitives.sphere(x);case"cylinder":return d.primitives.cylinder(x);case"polygon":return d.primitives.polygon(x);case"cuboid":return d.primitives.cuboid(x);case"roundedCuboid":return d.primitives.roundedCuboid(x);case"rotate":return d.transforms.rotate(m.angles,h(m.shape));case"scale":return d.transforms.scale(m.factors,h(m.shape));case"translate":return d.transforms.translate(m.vector,h(m.shape));case"extrudeLinear":return d.extrusions.extrudeLinear(m.options,h(m.shape));case"extrudeRotate":return d.extrusions.extrudeRotate(m.options,h(m.shape));case"createGeom2":return d.geometries.geom2.create(m.points);case"createGeom3":return d.geometries.geom3.create(m.polygons);case"createPath2":return d.geometries.path2.create(m.points);case"measureBoundingBox":return d.measurements.measureBoundingBox(h(m.shape));case"measureArea":return d.measurements.measureArea(h(m.shape));case"measureVolume":return d.measurements.measureVolume(h(m.shape));case"degToRad":return d.utils.degToRad(m.degrees);case"radToDeg":return d.utils.radToDeg(m.radians);default:throw m.type===void 0?new Error(`Operation type is undefined. This usually means the operation object is malformed or not properly initialized. Operation: ${JSON.stringify(m,null,2).slice(0,200)}...`):new Error(`Unsupported operation type: ${m.type}. Operation: ${JSON.stringify(m,null,2)}`)}}}}),$4n=it({"node_modules/ms/index.js"(t,e){var n=1e3,o=n*60,r=o*60,i=r*24,s=i*7,a=i*365.25;e.exports=function(d,m){m=m||{};var h=typeof d;if(h==="string"&&d.length>0)return c(d);if(h==="number"&&isFinite(d))return m.long?u(d):l(d);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(d))};function c(d){if(d=String(d),!(d.length>100)){var m=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(d);if(m){var h=parseFloat(m[1]),p=(m[2]||"ms").toLowerCase();switch(p){case"years":case"year":case"yrs":case"yr":case"y":return h*a;case"weeks":case"week":case"w":return h*s;case"days":case"day":case"d":return h*i;case"hours":case"hour":case"hrs":case"hr":case"h":return h*r;case"minutes":case"minute":case"mins":case"min":case"m":return h*o;case"seconds":case"second":case"secs":case"sec":case"s":return h*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return h;default:return}}}}function l(d){var m=Math.abs(d);return m>=i?Math.round(d/i)+"d":m>=r?Math.round(d/r)+"h":m>=o?Math.round(d/o)+"m":m>=n?Math.round(d/n)+"s":d+"ms"}function u(d){var m=Math.abs(d);return m>=i?_(d,m,i,"day"):m>=r?_(d,m,r,"hour"):m>=o?_(d,m,o,"minute"):m>=n?_(d,m,n,"second"):d+" ms"}function _(d,m,h,p){var x=m>=h*1.5;return Math.round(d/h)+" "+p+(x?"s":"")}}}),W4n=it({"node_modules/debug/src/common.js"(t,e){function n(o){i.debug=i,i.default=i,i.coerce=_,i.disable=l,i.enable=a,i.enabled=u,i.humanize=$4n(),i.destroy=d,Object.keys(o).forEach(m=>{i[m]=o[m]}),i.names=[],i.skips=[],i.formatters={};function r(m){let h=0;for(let p=0;p<m.length;p++)h=(h<<5)-h+m.charCodeAt(p),h|=0;return i.colors[Math.abs(h)%i.colors.length]}i.selectColor=r;function i(m){let h,p=null,x,f;function g(...y){if(!g.enabled)return;const b=g,v=Number(new Date),S=v-(h||v);b.diff=S,b.prev=h,b.curr=v,h=v,y[0]=i.coerce(y[0]),typeof y[0]!="string"&&y.unshift("%O");let M=0;y[0]=y[0].replace(/%([a-zA-Z%])/g,(D,A)=>{if(D==="%%")return"%";M++;const I=i.formatters[A];if(typeof I=="function"){const H=y[M];D=I.call(b,H),y.splice(M,1),M--}return D}),i.formatArgs.call(b,y),(b.log||i.log).apply(b,y)}return g.namespace=m,g.useColors=i.useColors(),g.color=i.selectColor(m),g.extend=s,g.destroy=i.destroy,Object.defineProperty(g,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(x!==i.namespaces&&(x=i.namespaces,f=i.enabled(m)),f),set:y=>{p=y}}),typeof i.init=="function"&&i.init(g),g}function s(m,h){const p=i(this.namespace+(typeof h>"u"?":":h)+m);return p.log=this.log,p}function a(m){i.save(m),i.namespaces=m,i.names=[],i.skips=[];const h=(typeof m=="string"?m:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const p of h)p[0]==="-"?i.skips.push(p.slice(1)):i.names.push(p)}function c(m,h){let p=0,x=0,f=-1,g=0;for(;p<m.length;)if(x<h.length&&(h[x]===m[p]||h[x]==="*"))h[x]==="*"?(f=x,g=p,x++):(p++,x++);else if(f!==-1)x=f+1,g++,p=g;else return!1;for(;x<h.length&&h[x]==="*";)x++;return x===h.length}function l(){const m=[...i.names,...i.skips.map(h=>"-"+h)].join(",");return i.enable(""),m}function u(m){for(const h of i.skips)if(c(m,h))return!1;for(const h of i.names)if(c(m,h))return!0;return!1}function _(m){return m instanceof Error?m.stack||m.message:m}function d(){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 i.enable(i.load()),i}e.exports=n}}),U4n=it({"node_modules/debug/src/browser.js"(t,e){t.formatArgs=o,t.save=r,t.load=i,t.useColors=n,t.storage=s(),t.destroy=(()=>{let c=!1;return()=>{c||(c=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function n(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let c;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(c=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(c[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function o(c){if(c[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+c[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const l="color: "+this.color;c.splice(1,0,l,"color: inherit");let u=0,_=0;c[0].replace(/%[a-zA-Z%]/g,d=>{d!=="%%"&&(u++,d==="%c"&&(_=u))}),c.splice(_,0,l)}t.log=console.debug||console.log||(()=>{});function r(c){try{c?t.storage.setItem("debug",c):t.storage.removeItem("debug")}catch{}}function i(){let c;try{c=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch{}return!c&&typeof Tfe<"u"&&"env"in Tfe&&(c=Tfe.env.DEBUG),c}function s(){try{return localStorage}catch{}}e.exports=W4n()(t);var{formatters:a}=e.exports;a.j=function(c){try{return JSON.stringify(c)}catch(l){return"[UnexpectedJSONParseError]: "+l.message}}}}),SZe={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,pcbNotes:!1,backgroundStart:!0,backgroundEnd:!0},CZe=Y.createContext(void 0),X4n=({children:t})=>{const[e,n]=Y.useState(SZe),o=Y.useCallback((s,a)=>{n(c=>({...c,[s]:a}))},[]),r=Y.useCallback(()=>{n(SZe)},[]),i=Y.useMemo(()=>({visibility:e,setLayerVisibility:o,resetToDefaults:r}),[e,o,r]);return j.jsx(CZe.Provider,{value:i,children:t})},m8=()=>{const t=Y.useContext(CZe);if(!t)throw new Error("useLayerVisibility must be used within a LayerVisibilityProvider");return t},t1e=1.2;function MZe(t){return Y.useMemo(()=>{if(!t)return t1e;try{return br(t).pcb_board.list()[0]?.thickness??t1e}catch{return t1e}},[t])}var TZe=Y.createContext(null),_2=()=>{const t=Y.useContext(TZe);if(!t)throw new Error("useThree must be used within a ThreeProvider");return t},fN=(t,e=[])=>{const{addFrameListener:n,removeFrameListener:o}=_2();cr.useEffect(()=>(n(t),()=>o(t)),[n,o,...e])},xN={clickToInteractOverlay:100,htmlElements:95,orientationCube:95,contextMenu:90,appearanceMenu:91},wZe=({children:t,position:e,style:n})=>{const{camera:o,renderer:r}=_2(),i=Y.useRef(document.createElement("div")),[s,a]=Y.useState(null);return Y.useEffect(()=>{const c=r?.domElement.parentNode;if(c)return c.style.position!=="relative"&&c.style.position!=="absolute"&&(c.style.position="relative"),c.appendChild(i.current),a(Q$.createPortal(t,i.current)),()=>{c.contains(i.current)&&c.removeChild(i.current)}},[r,t]),fN(()=>{if(!o||!i.current||!r)return;const c=new wt(...e);c.project(o);const l=r.domElement.getBoundingClientRect(),u=Math.round((c.x+1)/2*l.width),_=Math.round((-c.y+1)/2*l.height);i.current.style.position="absolute",i.current.style.left=`${u}px`,i.current.style.top=`${_}px`,i.current.style.pointerEvents="none",i.current.style.zIndex=xN.htmlElements.toString(),n&&Object.assign(i.current.style,n)},[o,r,e,n]),s},EZe={in:25.4,inch:25.4,mil:.0254,mm:1,m:1e3,cm:10,ft:304.8,feet:304.8},Xs=t=>{let e=typeof t=="number"?"mm":t.replace(/^[^a-zA-Z]+/g,"").toLowerCase();e||(e="mm");const n=typeof t=="number"?t:Number.parseFloat(t.split(e)[0]);if(e in EZe)return n*EZe[e];throw new Error(`Unsupported unit: ${e}`)},u_=Xs,j4n=Object.defineProperty,G4n=(t,e)=>{for(var n in e)j4n(t,n,{get:e[n],enumerable:!0})},O9={};G4n(O9,{axial:()=>S3n,bga:()=>T6n,breakoutheaders:()=>L3n,cap:()=>t6n,dfn:()=>r3n,diode:()=>e6n,dip:()=>J4n,electrolytic:()=>APn,hc49:()=>B3n,jst:()=>Gbn,led:()=>n6n,lqfp:()=>H3n,m2host:()=>ZPn,melf:()=>tbn,micromelf:()=>ibn,minimelf:()=>G9n,mlp:()=>I6n,mountedpcbmodule:()=>tvn,ms012:()=>_3n,ms013:()=>h3n,msop:()=>oPn,pad:()=>z3n,pinrow:()=>s3n,platedhole:()=>WPn,potentiometer:()=>wPn,pushbutton:()=>E3n,qfn:()=>k6n,qfp:()=>H6n,quad:()=>Jw,radial:()=>T3n,res:()=>S6n,sma:()=>lbn,smb:()=>xbn,smbf:()=>kPn,smc:()=>Pbn,smf:()=>hbn,smtpad:()=>VPn,sod110:()=>qbn,sod123:()=>y3n,sod123f:()=>v9n,sod123fl:()=>T9n,sod123w:()=>n9n,sod128:()=>H9n,sod323:()=>s9n,sod323f:()=>g9n,sod323fl:()=>lPn,sod323w:()=>iPn,sod523:()=>j3n,sod723:()=>A9n,sod80:()=>Q3n,sod882:()=>m9n,sod882d:()=>K9n,sod923:()=>u9n,soic:()=>E6n,solderjumper:()=>gPn,son:()=>hPn,sop8:()=>J3n,sot:()=>XPn,sot223:()=>Mbn,sot23:()=>K6n,sot23w:()=>Hbn,sot25:()=>t3n,sot323:()=>OPn,sot343:()=>qPn,sot363:()=>U6n,sot457:()=>PPn,sot563:()=>l3n,sot723:()=>p3n,sot886:()=>G6n,sot89:()=>$9n,sot963:()=>CPn,ssop:()=>F6n,stampboard:()=>A3n,stampreceiver:()=>N3n,to220:()=>jZe,to220f:()=>X9n,to92:()=>U3n,to92l:()=>ivn,to92s:()=>zbn,tqfp:()=>N6n,tssop:()=>V6n,vson:()=>pPn,vssop:()=>ePn});var Ho=(t,e,n)=>({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:"silkscreen_text_1",font:"tscircuit2024",font_size:n,pcb_component_id:"pcb_component_1",text:"{REF}",layer:"top",anchor_position:{x:t,y:e},anchor_alignment:"center"}),Ro=rt({norefdes:Be().optional().describe("disable reference designator label"),invert:Be().optional().describe("hint to invert the orientation of the 3D model"),faceup:Be().optional().describe("The male pin header should face upwards, out of the top layer"),nosilkscreen:Be().optional().describe("omit all silkscreen elements from the footprint")}),Si=(t,e,n,o,r)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circle",x:e,y:n,hole_diameter:Xs(o),outer_diameter:Xs(r),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()]}),P5=t=>{const{pn:e,x:n,y:o,holeDiameter:r,rectPadWidth:i,rectPadHeight:s,holeOffsetX:a=0,holeOffsetY:c=0,rectBorderRadius:l}=t;return{pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circular_hole_with_rect_pad",x:n,y:o,hole_diameter:Xs(r),hole_shape:"circle",pad_shape:"rect",rect_pad_width:Xs(i),rect_pad_height:Xs(s),...l!==void 0&&{rect_border_radius:l},pcb_port_id:"",layers:["top","bottom"],port_hints:[e.toString()],hole_offset_x:a,hole_offset_y:c}},TX=Array.from({length:9},(t,e)=>Math.cos(e/8*Math.PI-Math.PI)).map(t=>({x:t,y:-Math.sqrt(1-t**2)})),d2=t=>{if(t.length<2)throw new Error("Rect union outline requires at least two bounds");for(const l of t)if(l.minX>=l.maxX||l.minY>=l.maxY)throw new Error("Each rectangle bound must have min < max on both axes");for(let l=1;l<t.length;l++){const u=t[l-1],_=t[l];if(_.minX<u.minX||_.maxX>u.maxX||_.minY>u.minY||_.maxY<u.maxY)throw new Error("Bounds must be ordered outer-to-inner with tighter X and larger Y span")}const e=()=>{const l=[];let u=t.length-1;for(l.push({x:t[u].minX,y:t[u].maxY});u>0;){const _=t[u],d=t[u-1];l.push({x:_.minX,y:d.maxY}),l.push({x:d.minX,y:d.maxY}),u-=1}return l},n=()=>{const l=[];let u=t.length-1;for(l.push({x:t[u].maxX,y:t[u].maxY});u>0;){const _=t[u],d=t[u-1];l.push({x:_.maxX,y:d.maxY}),l.push({x:d.maxX,y:d.maxY}),u-=1}return l},o=()=>{const l=[];let u=t.length-1;for(l.push({x:t[u].maxX,y:t[u].minY});u>0;){const _=t[u],d=t[u-1];l.push({x:_.maxX,y:d.minY}),l.push({x:d.maxX,y:d.minY}),u-=1}return l},r=()=>{const l=[];let u=t.length-1;for(l.push({x:t[u].minX,y:t[u].minY});u>0;){const _=t[u],d=t[u-1];l.push({x:_.minX,y:d.minY}),l.push({x:d.minX,y:d.minY}),u-=1}return l},i=e(),s=n(),a=o(),c=r();return[...i.reverse(),...s,...a.reverse(),...c]};function cv(t){return typeof t=="string"?t.trim().toLowerCase().endsWith("mil")?parseFloat(t)*.0254:parseFloat(t):Number(t)}var wX=Nn([F(),je()]).transform(t=>cv(t)),Y4n=t=>Ro.extend({fn:F(),num_pins:je().optional().default(6),wide:Be().optional(),narrow:Be().optional(),w:wX.optional(),p:wX.default(t.p??"2.54mm"),id:wX.optional(),od:wX.optional(),nosquareplating:Be().optional().default(!1).describe("do not use rectangular pad for pin 1")}).transform(e=>(!e.id&&!e.od?Math.abs(e.p-1.27)<.01?(e.id=cv("0.55mm"),e.od=cv("0.95mm")):(e.id=cv("0.8mm"),e.od=cv("1.6mm")):e.id?e.od||(e.od=e.id*(1.5/1)):e.id=e.od*(1/1.5),e.w||(e.wide?e.w=cv("600mil"):e.narrow?e.w=cv("300mil"):e.w=cv(t.w??"300mil")),e)),q4n=Y4n({}),DZe=(t,e,n,o,r)=>{const i=t/2,s=e<=i,a=i-1,c=o,l=c*a;return s?{x:-n/2,y:l/2-(e-1)*c}:{x:n/2,y:-l/2+(e-i-1)*c}},J4n=t=>{const e=q4n.parse(t),n=[];for(let f=0;f<e.num_pins;f++){const{x:g,y}=DZe(e.num_pins,f+1,e.w,e.p??2.54,e.nosquareplating);if(f===0&&!e.nosquareplating){n.push(P5({pn:f+1,x:g,y,holeDiameter:e.id??"0.8mm",rectPadWidth:e.od??"1mm",rectPadHeight:e.od??"1mm"}));continue}n.push(Si(f+1,g,y,e.id??"0.8mm",e.od??"1mm"))}const o=(e.num_pins/2-1)*e.p+e.od,i=e.w-e.od-1,s=(e.num_pins/2-1)*e.p+e.od+.4,a={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i/2,y:-s/2},{x:-i/2,y:s/2},...TX.map(({x:f,y:g})=>({x:f*i/6,y:g*i/6+s/2})),{x:i/2,y:s/2},{x:i/2,y:-s/2},{x:-i/2,y:-s/2}],type:"pcb_silkscreen_path",stroke_width:.1},c=[];for(let f=0;f<e.num_pins;f++){const g=f<e.num_pins/2,y=.6,{y:b}=DZe(e.num_pins,f+1,e.w,e.p??2.54,e.nosquareplating),v=g?-e.w/2-e.od/2-y:e.w/2+e.od/2+y,S=b;c.push({type:"pcb_fabrication_note_text",pcb_fabrication_note_text_id:`pin_${f+1}`,layer:"top",pcb_component_id:`pin_${f+1}`,text:`{pin${f+1}}`,anchor_position:{x:v,y:S},font_size:.3,font:"tscircuit2024",anchor_alignment:"top_left"})}const l=Ho(0,s/2+.5,.4),u=e.w+e.od,_=o,d=u/2+.25,m=d,h=_/2+.72,p=h,x={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:d2([{minX:-d,maxX:d,minY:-p,maxY:p},{minX:-m,maxX:m,minY:-h,maxY:h}]),layer:"top"};return{circuitJson:[...n,a,l,...c,x],parameters:e}},lo=(t,e,n,o,r)=>({type:"pcb_smtpad",x:e,y:n,width:o,height:r,layer:"top",shape:"rect",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(i=>i.toString()):[t.toString()]}),AZe=[{imperial:"01005",metric:"0402",p_mm_min:.5,pw_mm_min:.4,ph_mm_min:.3,w_mm_min:.58,h_mm_min:.21,courtyard_width_mm:1.2,courtyard_height_mm:.6},{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,courtyard_width_mm:5.9,courtyard_height_mm:3.9},{imperial:"0201",metric:"0603",p_mm_min:.66,pw_mm_min:.46,ph_mm_min:.4,w_mm_min:.9,h_mm_min:.3,courtyard_width_mm:1.4,courtyard_height_mm:.7},{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,courtyard_width_mm:1.86,courtyard_height_mm:.94},{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,courtyard_width_mm:2.96,courtyard_height_mm:1.46},{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,courtyard_width_mm:3.36,courtyard_height_mm:1.9},{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,courtyard_width_mm:4.56,courtyard_height_mm:2.26},{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,courtyard_width_mm:4.56,courtyard_height_mm:3.16},{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,courtyard_width_mm:6.36,courtyard_height_mm:3.16},{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,courtyard_width_mm:7.66,courtyard_height_mm:3.86}],K4n=Object.fromEntries(AZe.map(t=>[t.metric,t])),Q4n=Object.fromEntries(AZe.map(t=>[t.imperial,t])),Z4n=(t,e)=>({type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:t,height:e,layer:"top"});Ro.extend({tht:Be(),p:_e.optional(),pw:_e.optional(),ph:_e.optional(),metric:nt.optional(),imperial:nt.optional(),w:_e.optional(),h:_e.optional(),textbottom:Be().optional()});var EX=t=>{let{tht:e,p:n,pw:o,ph:r,metric:i,imperial:s,w:a,h:c,textbottom:l}=t;if(typeof a=="string"&&(a=u_(a)),typeof c=="string"&&(c=u_(c)),typeof n=="string"&&(n=u_(n)),typeof o=="string"&&(o=u_(o)),typeof r=="string"&&(r=u_(r)),c!==void 0&&a!==void 0&&c>a)throw new Error("height cannot be greater than width (rotated footprint not yet implemented)");let u;if(i&&(u=K4n[i]),s&&(u=Q4n[s]),u&&(a=u.w_mm_min,c=u.h_mm_min,n=u.p_mm_min,o=u.pw_mm_min,r=u.ph_mm_min),n===void 0||o===void 0||r===void 0)throw new Error("Could not determine required pad dimensions (p, pw, ph)");const _={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:n/2,y:r/2+.4},{x:-n/2-o/2-.2,y:r/2+.4},{x:-n/2-o/2-.2,y:-r/2-.4},{x:n/2,y:-r/2-.4}],stroke_width:.1,pcb_silkscreen_path_id:""},d=l?-r/2-.9:r/2+.9,m=Ho(0,d,.2),h=u?.courtyard_width_mm&&u.courtyard_height_mm?Z4n(u.courtyard_width_mm,u.courtyard_height_mm):null;return e?[Si(1,-n/2,0,o,o*1/.8),Si(2,n/2,0,o,o*1/.8),_,m,...h?[h]:[]]:[lo(["1","left"],-n/2,0,o,r),lo(["2","right"],n/2,0,o,r),_,m,...h?[h]:[]]},e6n=t=>({circuitJson:EX(t),parameters:t}),t6n=t=>({circuitJson:EX(t),parameters:t}),n6n=t=>({circuitJson:EX(t),parameters:t}),qw=t=>{const{padSpacing:e,padWidth:n,padHeight:o,padPitch:r,numRows:i,textbottom:s,courtyardOutline:a}=t,c=[],l=(i-1)*(r/2);for(let A=0;A<i;A++)c.push(l-A*r);const u=[];c.forEach((A,I)=>{u.push(lo(I+1,-e/2,A,n,o))}),c.slice().reverse().forEach((A,I)=>{u.push(lo(I+i+1,e/2,A,n,o))});const _=Math.max(...c)+o/2+.4,d=Math.min(...c)-o/2-.4,m=-e/2-n/2-.4,h=e/2+n/2+.4,p={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:h*.5,y:_},{x:m*.5,y:_}],stroke_width:.12,pcb_silkscreen_path_id:"silkscreen_top"},x={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:h*.5,y:d},{x:m*.5,y:d}],stroke_width:.12,pcb_silkscreen_path_id:"silkscreen_bottom"},f=-e/2,g=Math.max(...c),y=.2,b=f-n/2-.1,v=g+o/2+.1,S={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_marker",route:[{x:b,y:v},{x:b-y,y:v},{x:b,y:v+y},{x:b,y:v}],stroke_width:.1},M=s?d-.9:_+.9,w=Ho(0,M,.2),D=a?{type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:a}:null;return[...u,p,x,S,w,...D?[D]:[]]},o6n=Ro.extend({pw:_e.default("0.5mm"),ph:_e.default("0.4mm"),p:_e.default("0.7mm"),textbottom:Be().optional(),convex:Be().optional(),concave:Be().optional()}),r6n=1,i6n=t=>{const e=o6n.parse(t);if(e.concave===!0)return[];const n=u_(e.pw),o=u_(e.ph),r=u_(e.p);return qw({padSpacing:r6n,padWidth:n,padHeight:o,padPitch:r,numRows:2,textbottom:e.textbottom,convex:e.convex,concave:e.concave,courtyardOutline:[{x:-1,y:.95},{x:-1,y:-.95},{x:1,y:-.95},{x:1,y:.95}]})},s6n=Ro.extend({pw:_e.default("0.5mm"),ph:_e.default("0.32mm"),p:_e.default("0.5mm"),textbottom:Be().optional(),convex:Be().optional(),concave:Be().optional()}),a6n=1,c6n=t=>{const e=s6n.parse(t),n=u_(e.pw),o=u_(e.ph),r=u_(e.p);return qw({padSpacing:a6n,padWidth:n,padHeight:o,padPitch:r,numRows:4,textbottom:e.textbottom,convex:e.convex,concave:e.concave,courtyardOutline:[{x:-1,y:1.25},{x:-1,y:-1.25},{x:1,y:-1.25},{x:1,y:1.25}]})},l6n=Ro.extend({pw:_e.default("0.9mm"),ph:_e.default("0.4mm"),p:_e.default("0.8mm"),textbottom:Be().optional(),convex:Be().optional(),concave:Be().optional()}),u6n=1.7,_6n=t=>{const e=l6n.parse(t),n=u_(e.pw),o=u_(e.ph),r=u_(e.p);return qw({padSpacing:u6n,padWidth:n,padHeight:o,padPitch:r,numRows:2,textbottom:e.textbottom,convex:e.convex,concave:e.concave,courtyardOutline:[{x:-1.55,y:1.05},{x:-1.55,y:-1.05},{x:1.55,y:-1.05},{x:1.55,y:1.05}]})},d6n=Ro.extend({pw:_e.default("0.9mm"),ph:_e.default("0.4mm"),p:_e.default("0.8mm"),textbottom:Be().optional(),convex:Be().optional(),concave:Be().optional()}),h6n=1.7,m6n=t=>{const e=d6n.parse(t),n=u_(e.pw),o=u_(e.ph),r=u_(e.p);return qw({padSpacing:h6n,padWidth:n,padHeight:o,padPitch:r,numRows:4,textbottom:e.textbottom,convex:e.convex,concave:e.concave,courtyardOutline:[{x:-1.55,y:1.88},{x:-1.55,y:-1.87},{x:1.55,y:-1.87},{x:1.55,y:1.88}]})},p6n=Ro.extend({pw:_e.default("0.7mm"),ph:_e.default("0.64mm"),p:_e.default("0.94mm"),textbottom:Be().optional(),convex:Be().optional(),concave:Be().optional()}),f6n=1.4,x6n=t=>{const e=p6n.parse(t),n=u_(e.pw),o=u_(e.ph),r=u_(e.p);return qw({padSpacing:f6n,padWidth:n,padHeight:o,padPitch:r,numRows:2,textbottom:e.textbottom,convex:e.convex,concave:e.concave,courtyardOutline:[{x:-1.3,y:1.05},{x:-1.3,y:-1.05},{x:1.3,y:-1.05},{x:1.3,y:1.05}]})},g6n=Ro.extend({pw:_e.default("0.9mm"),ph:_e.default("0.9mm"),p:_e.default("1.34mm"),textbottom:Be().optional(),convex:Be().optional(),concave:Be().optional()}),y6n=3,b6n=t=>{const e=g6n.parse(t),n=u_(e.pw),o=u_(e.ph),r=u_(e.p);return qw({padSpacing:y6n,padWidth:n,padHeight:o,padPitch:r,numRows:4,textbottom:e.textbottom,convex:e.convex,concave:e.concave,courtyardOutline:[{x:-2.21,y:2.85},{x:-2.21,y:-2.85},{x:2.2,y:-2.85},{x:2.2,y:2.85}]})},P6n=t=>{const e=t.array??t.x;if(typeof e=="number")return Number.isNaN(e)?void 0:e;if(typeof e=="string"){const n=Number.parseInt(e,10);return Number.isNaN(n)?void 0:n}if(typeof t.imperial=="string"){const o=t.imperial.match(/x(2|4)$/)?.[1];if(o)return Number.parseInt(o,10)}},v6n=t=>t?(typeof t=="number"?`${t}`:t).split(/[_x]/)[0]:void 0,S6n=t=>{const e=P6n(t),n=v6n(t.imperial);return e===2&&n==="0402"?{circuitJson:i6n(t),parameters:t}:e===4&&n==="0402"?{circuitJson:c6n(t),parameters:t}:e===2&&n==="0603"?{circuitJson:_6n(t),parameters:t}:e===4&&n==="0603"?{circuitJson:m6n(t),parameters:t}:e===2&&n==="0606"?{circuitJson:x6n(t),parameters:t}:e===4&&n==="1206"?{circuitJson:b6n(t),parameters:t}:{circuitJson:EX(t),parameters:t}},RZe=(t,{x:e,y:n,radius:o})=>({type:"pcb_smtpad",x:e,y:n,radius:o,layer:"top",shape:"circle",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(r=>r.toString()):[t.toString()]}),kZe="ABCDEFGHIJKLMNOPQRSTUVWXYZ",DX=F().transform(t=>{const[e,n]=t.split(/[x ]/);return{x:parseFloat(e??""),y:parseFloat(n??"")}}).pipe(rt({x:je(),y:je()})),C6n=F().or(Pt(b0())).transform(t=>Array.isArray(t)?t:(t.startsWith("(")&&t.endsWith(")")&&(t=t.slice(1,-1)),t.split(",").map(e=>{const n=Number(e);return isNaN(n)?e:n}))).pipe(Pt(F().or(je()))),M6n=Ro.extend({fn:F(),num_pins:je().optional().default(64),grid:DX.optional(),p:nt.default("0.8mm"),w:_e.optional(),h:_e.optional(),ball:_e.optional().describe("ball diameter"),pad:_e.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:C6n.default([])}).transform(t=>{let e="tl";if(t.blorigin&&(e="bl"),t.trorigin&&(e="tr"),t.brorigin&&(e="br"),!t.grid){const o=Math.ceil(Math.sqrt(t.num_pins));t.grid={x:o,y:o}}return t.missing&&(t.missing=t.missing.map(o=>{if(typeof o=="number")return o;if(o==="center")return"center";if(o==="topleft")return"topleft";const r=o.match(/([A-Z]+)(\d+)/);if(!r)return o;const i=kZe.indexOf(r[1]),s=Number.parseInt(r[2])-1;return i*t.grid.x+s+1})),{...t,origin:e}}),T6n=t=>{const e=M6n.parse(t);let{num_pins:n,grid:o,p:r,w:i,h:s,ball:a,pad:c,missing:l}=e;a??=.75/1.27*r,c??=a*.8;const u=[],_=(l??[]).filter(K=>typeof K=="number"),d=o.x*o.y-n;if(l.length===0&&d>0&&(Math.sqrt(d)%1===0?l.push("center"):d===1&&l.push("topleft")),l?.includes("center")){const K=Math.floor(Math.sqrt(d)),ne=Math.floor((o.x-K)/2),ce=Math.floor((o.y-K)/2);for(let ee=ce;ee<ce+K;ee++)for(let oe=ne;oe<ne+K;oe++)_.push(ee*o.x+oe+1)}l?.includes("topleft")&&_.push(1);const m=new Set(_);let h=0;for(let K=0;K<o.y;K++)for(let ne=0;ne<o.x;ne++){const ce=(ne-(o.x-1)/2)*r,ee=(K-(o.y-1)/2)*r;let oe=ne,ie=K;switch(e.origin){case"bl":oe=ne,ie=o.y-1-K;break;case"br":oe=o.x-1-ne,ie=o.y-1-K;break;case"tr":oe=o.x-1-ne,ie=K;break}let ae=ie*o.x+oe+1;if(m.has(ae)){h++;continue}ae-=h;const de=[ae,`${kZe[ie]}${oe+1}`];u.push(e.circularpads?RZe(de,{x:ce,y:ee,radius:c/2}):lo(de,ce,ee,c,c))}const p=Ho(0,o.y*r/2,.2),x=r/6;let f;const g=o.x*r/2,y=o.y*r/2;switch(e.origin){case"bl":f=[{x:-g,y:-y},{x:-g,y:-y-x},{x:-g-x,y:-y},{x:-g,y:-y}];break;case"br":f=[{x:g,y:-y},{x:g,y:-y-x},{x:g+x,y:-y},{x:g,y:-y}];break;case"tr":f=[{x:g,y},{x:g,y:y+x},{x:g+x,y},{x:g,y}];break;default:f=[{x:-g,y},{x:-g,y:y+x},{x:-g-x,y},{x:-g,y}];break}const b={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_marker",route:f,stroke_width:.05},v=(o.x-1)*r+c,S=(o.y-1)*r+c,M=i??v,w=s??S,D=Math.max(v/2,M/2),A=Math.max(S/2,w/2),I=1.715,H=1.765,O=D+I,z=O,V=A+H,G=V,q={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:d2([{minX:-O,maxX:O,minY:-G,maxY:G},{minX:-z,maxX:z,minY:-V,maxY:V}]),layer:"top"};return{circuitJson:[...u,p,b,q],parameters:e}},AX=(t,e,n,o,r)=>({type:"pcb_smtpad",x:e,y:n,width:o,height:r,radius:r/2,layer:"top",shape:"pill",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(i=>i.toString()):[t.toString()]}),p8=t=>Ro.extend({fn:F(),num_pins:je().optional().default(8),w:_e.default(_e.parse(t.w??"5.3mm")),p:_e.default(_e.parse(t.p??"1.27mm")),pw:_e.default(_e.parse(t.pw??"0.6mm")),pl:_e.default(_e.parse(t.pl??"1.0mm")),legsoutside:Be().optional().default(t.legsoutside??!1),pillpads:Be().optional().default(t.pillpads??!1),silkscreen_stroke_width:je().optional().default(.1)}).transform(e=>(!e.pw&&!e.pl?(e.pw=_e.parse("0.6mm"),e.pl=_e.parse("1.0mm")):e.pw?e.pl||(e.pl=e.pw*(1/.6)):e.pw=e.pl*(.6/1),e)),w6n=p8({}),n1e=t=>{t.widthincludeslegs!==void 0&&(t.legsoutside=!t.widthincludeslegs);const{num_pins:e,pn:n,w:o,p:r,pl:i,legsoutside:s}=t,a=e/2,c=n<=a,l=a-1,u=r,_=u*l,d=s?i/2:-i/2;return c?{x:-o/2-d,y:_/2-(n-1)*u}:{x:o/2+d,y:-_/2+(n-a-1)*u}},E6n=t=>{const e=w6n.parse(t);return{circuitJson:gN(e),parameters:e}},gN=t=>{const e=[];for(let m=0;m<t.num_pins;m++){const{x:h,y:p}=n1e({num_pins:t.num_pins,pn:m+1,w:t.w,p:t.p,pl:t.pl,legsoutside:t.legsoutside});t.pillpads?e.push(AX(m+1,h,p,t.pl,t.pw)):e.push(lo(m+1,h,p,t.pl,t.pw))}const n=Math.min(1,t.p/2),o=t.w-(t.legsoutside?0:t.pl*2)-.2,r=(t.num_pins/2-1)*t.p+t.pw+n,i=Ho(0,r/2+.4,r/12),s={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",stroke_width:t.silkscreen_stroke_width??.1,route:[{x:-o/2,y:-r/2},{x:-o/2,y:r/2},...TX.map(({x:m,y:h})=>({x:m*o/6,y:h*o/6+r/2})),{x:o/2,y:r/2},{x:o/2,y:-r/2},{x:-o/2,y:-r/2}]},a=(t.num_pins/2-1)*t.p+t.pw,c=t.w/2+.25,l=c+1.93,u=a/2+.275,_=a/2+.635,d={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:d2([{minX:-l,maxX:l,minY:-u,maxY:u},{minX:-c,maxX:c,minY:-_,maxY:_}])};return[...e,s,i,d]},NZe=Kt(["leftside","topside","rightside","bottomside","toppin","bottompin","leftpin","rightpin"]),D6n=({num_pins:t,cw:e,ccw:n,startingpin:o})=>{const r=[],i=t/4;let s=1;const a={};for(const c of o??[])a[c]=!0;!a.leftside&&!a.topside&&!a.rightside&&!a.bottomside&&(a.leftside=!0),!a.bottompin&&!a.leftpin&&!a.rightpin&&!a.toppin&&(a.leftside?a.toppin=!0:a.topside?a.rightpin=!0:a.rightside?a.bottompin=!0:a.bottomside&&(a.leftpin=!0)),a.leftside&&a.toppin?s=1:a.leftside&&a.bottompin?s=i:a.bottomside&&a.leftpin?s=i+1:a.bottomside&&a.rightpin?s=i*2:a.rightside&&a.bottompin?s=i*2+1:a.rightside&&a.toppin?s=i*3:a.topside&&a.rightpin?s=i*3+1:a.topside&&a.leftpin&&(s=i*4),r.push(-1);for(let c=0;c<t;c++)r[s]=c+1,n||!e?(s++,s>t&&(s=1)):(s--,s<1&&(s=t));return r},o1e=Ro.extend({fn:F(),cc:Be().default(!0).optional(),ccw:Be().default(!0).optional(),startingpin:F().or(Pt(NZe)).transform(t=>typeof t=="string"?t.slice(1,-1).split(","):t).pipe(Pt(NZe)).optional(),num_pins:je().optional().default(64),w:_e.optional(),h:_e.optional(),p:_e.default(_e.parse("0.5mm")),pw:_e.optional(),pl:_e.optional(),thermalpad:Nn([ke(!0),DX]).optional(),legsoutside:Be().default(!1)}),r1e=t=>{t.w&&!t.h?t.h=t.w:!t.w&&t.h&&(t.w=t.h);const e=t.num_pins/4;if(!t.p&&!t.pw&&!t.pl&&t.w){const n=e+4;t.p=t.w/n}return!t.p&&t.w&&t.h&&t.pw&&t.pl&&(t.p=(t.w-t.pl*2)/(e-1)),!t.w&&!t.h&&t.p&&(t.w=t.p*(e+4),t.h=t.w),t.p&&!t.pw&&!t.pl?(t.pw=t.p/2,t.pl=t.p/2):t.pw?t.pl||(t.pl=t.pw*(1/.6)):t.pw=t.pl*(.6/1),t},HZe=o1e.transform(r1e),A6n=["left","bottom","right","top"],R6n=t=>{const{pin_count:e,pn:n,w:o,h:r,p:i,pl:s,legsoutside:a}=t,c=e/4,l=A6n[Math.floor((n-1)/c)],u=(n-1)%c,_=i*(c-1),d=i*(c-1),m=a?s/2:-s/2;switch(l){case"left":return{x:-o/2-m+.1,y:d/2-u*i,o:"vert"};case"bottom":return{x:-_/2+u*i,y:-r/2-m+.1,o:"horz"};case"right":return{x:o/2+m-.1,y:-d/2+u*i,o:"vert"};case"top":return{x:_/2-u*i,y:r/2+m-.1,o:"horz"};default:throw new Error("Invalid pin number")}},Jw=t=>{const e=HZe.parse(t),n=[];let o=0,r=0;const i=D6n(e),s=e.num_pins/4;for(let y=0;y<e.num_pins;y++){const{x:b,y:v,o:S}=R6n({pin_count:e.num_pins,pn:y+1,w:e.w,h:e.h,p:e.p??.5,pl:e.pl,legsoutside:e.legsoutside});let M=e.pw,w=e.pl;S==="vert"&&([M,w]=[w,M]);const D=i[y+1];o=Math.max(o,Math.abs(b)+M/2),r=Math.max(r,Math.abs(v)+w/2),n.push(lo(D,b,v,M,w))}if(e.thermalpad)if(typeof e.thermalpad=="boolean"){const y=e.p*(s-1)+e.pw,b=e.p*(s-1)+e.pw;o=Math.max(o,y/2),r=Math.max(r,b/2),n.push(lo(["thermalpad"],0,0,y,b))}else o=Math.max(o,e.thermalpad.x/2),r=Math.max(r,e.thermalpad.y/2),n.push(lo(["thermalpad"],0,0,e.thermalpad.x,e.thermalpad.y));const a=[];for(const[y,b,v]of[["top-left",-1,1],["bottom-left",-1,-1],["bottom-right",1,-1],["top-right",1,1]]){const S=e.w/2*b,M=e.h/2*v;let w="none",D=S,A=M;const I=e.pw*2;i[1]===1&&y==="top-left"?w="in1":i[s*4]===1&&y==="top-left"||i[s*3+1]===1&&y==="top-right"?w="in2":i[s*3]===1&&y==="top-right"||i[s]===1&&y==="bottom-left"?w="in1":i[s+1]===1&&y==="bottom-left"?w="in2":i[s*2]===1&&y==="bottom-right"?w="in1":i[s*2+1]===1&&y==="bottom-right"&&(w="in2");const H=w==="in1"?1:-1;if(e.legsoutside){const O=w==="in1"?e.pl/2:e.pw/2,z=w==="in1"?e.pw/2:e.pl/2;D+=O*b*H,A-=z*v*H}(w==="none"||e.legsoutside)&&a.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${y}`,route:[{x:S-I*b,y:M},{x:S,y:M},{x:S,y:M-I*v}],type:"pcb_silkscreen_path",stroke_width:.1}),(w==="in1"||w==="in2")&&!e.legsoutside&&a.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${y}_1`,route:[{x:S-I*b,y:M},{x:S-I*b/2,y:M}],type:"pcb_silkscreen_path",stroke_width:0},{layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${y}_2`,route:[{x:S,y:M-I*v/2},{x:S,y:M-I*v}],type:"pcb_silkscreen_path",stroke_width:.1}),(w==="in1"||w==="in2")&&a.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${y}_3`,route:[{x:D-.2*-b,y:A+.2*H},{x:D,y:A},{x:D+.2*H*-b,y:A+.2},{x:D-.2*-b,y:A+.2*H}],type:"pcb_silkscreen_path",stroke_width:.1})}const c=Ho(0,e.h/2+(e.legsoutside?e.pl*1.2:.5),.3),l=y=>Math.ceil(y/.05)*.05,u=(s-1)*e.p+e.pw,_=(s-1)*e.p+e.pw,d=u/2+.25,m=_/2+.25,h=e.w/2+.25,p=e.h/2+.25,x=Math.max(h,l(o+.25)),f=Math.max(p,l(r+.25)),g={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:d2([{minX:-x,maxX:x,minY:-m,maxY:m},{minX:-h,maxX:h,minY:-p,maxY:p},{minX:-d,maxX:d,minY:-f,maxY:f}])};return{circuitJson:[...n,...a,c,g],parameters:e}};o1e.extend({}).transform(r1e);var k6n=t=>(t.legsoutside=!1,t.pl||(t.pl=.875),t.pw||(t.pw=.25),Jw(t)),N6n=t=>{if(t.legsoutside=!0,!t.p)switch(t.num_pins){case 32:t.p=.8;break;case 44:case 48:t.p=.5;break;case 64:case 80:case 100:t.p=.5;break;case 144:t.p=.5;break}if(!t.pl)switch(t.num_pins){case 32:case 44:case 48:case 64:case 80:case 100:t.pl=1.475;break;case 144:t.pl=1.6;break}if(!t.pw)switch(t.num_pins){case 32:t.pw=.55;break;case 44:case 48:case 64:case 80:case 100:t.pw=.3;break;case 144:t.pw=.25;break}return Jw(t)},H6n=t=>{t.legsoutside=!0;const e=HZe.parse(t);if(!t.p)switch(t.num_pins){case 44:case 64:t.p=.8;break;case 52:t.w===14?t.p=1:t.p=.65;break;case 208:t.p=.5;break}if(!t.pl)switch(t.num_pins){case 44:case 52:case 64:t.pl=2.25;break;case 208:t.pl=1.65;break;default:t.pl=e.pl*4;break}if(!t.pw)switch(t.num_pins){case 44:case 64:t.pw=.5;break;case 52:t.w===14?t.pw=.45:t.pw=.55;break;case 208:t.pw=.3;break;default:t.pw=e.pw;break}return Jw(t)};o1e.extend({}).transform(r1e);var I6n=t=>(t.legsoutside=!1,t.thermalpad===void 0&&(t.thermalpad=!0),Jw(t)),L6n=Ro.extend({fn:F(),num_pins:je().optional().default(8),w:_e.default(_e.parse("3.9mm")),p:_e.default(_e.parse("1.27mm")),pw:_e.optional(),pl:_e.optional(),legsoutside:Be().optional().default(!1),silkscreen_stroke_width:je().optional().default(.1)}).transform(t=>(t.pw==null&&t.pl==null?(t.pw=_e.parse("0.51mm"),t.pl=_e.parse("1.1mm")):t.pw==null?t.pw=t.pl*(.51/1.1):t.pl==null&&(t.pl=t.pw*(1.1/.51)),t)),O6n=t=>{const{num_pins:e,pn:n,w:o,p:r}=t,i=e/2,s=n<=i,a=i-1,c=r,l=c*a,u=o+_e.parse("0.2mm"),_=(s?-1:1)*(u/2);return s?{x:_,y:l/2-(n-1)*c}:{x:_,y:-l/2+(n-i-1)*c}},F6n=t=>{const e=L6n.parse(t),n=[];for(let x=0;x<e.num_pins;x++){const{x:f,y:g}=O6n({num_pins:e.num_pins,pn:x+1,w:e.w,p:e.p,pl:e.pl,legsoutside:e.legsoutside});n.push(lo(x+1,f,g,e.pl,e.pw))}const o=Math.min(1,e.p/2),r=e.w-(e.legsoutside?0:e.pl)-.2,i=(e.num_pins/2-1)*e.p+e.pw+o,s=Ho(0,i/2+.4,i/12),a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",stroke_width:e.silkscreen_stroke_width??.1,route:[{x:-r/2,y:-i/2},{x:-r/2,y:i/2},...TX.map(({x,y:f})=>({x:x*r/6,y:f*r/6+i/2})),{x:r/2,y:i/2},{x:r/2,y:-i/2},{x:-r/2,y:-i/2}]},c=(e.num_pins/2-1)*e.p+e.pw,l=e.legsoutside?e.w/2+e.pl:(e.w+.2)/2+e.pl/2,u=c/2,_=l+.25,d=_,m=u+.445,h=m,p={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:d2([{minX:-_,maxX:_,minY:-h,maxY:h},{minX:-d,maxX:d,minY:-m,maxY:m}]),layer:"top"};return{circuitJson:[...n,a,s,p],parameters:e}},B6n=Ro.extend({fn:F(),num_pins:je().optional().default(8),w:_e.default(_e.parse("3.0mm")),p:_e.default(_e.parse("0.5mm")),pw:_e.default(_e.parse("0.30mm")),pl:_e.default(_e.parse("1.45mm")),legsoutside:Be().optional().default(!0),silkscreen_stroke_width:je().optional().default(.1)}),z6n=t=>{const{num_pins:e,pn:n,w:o,p:r,pl:i,legsoutside:s}=t,a=e/2,c=n<=a,l=a-1,u=r*l,_=s?i/2:-i/2;return c?{x:-o/2-_,y:u/2-(n-1)*r}:{x:o/2+_,y:-u/2+(n-a-1)*r}},V6n=t=>{const e={...t},n=e.p,o=typeof n=="string"||typeof n=="number"?_e.parse(n):void 0,r=o!=null&&o<=_e.parse("0.5mm"),i=B6n.parse(e),s=[],a=r?i.w-_e.parse("0.15mm"):i.w;for(let b=0;b<i.num_pins;b++){const{x:v,y:S}=z6n({num_pins:i.num_pins,pn:b+1,w:a,p:i.p,pl:i.pl,legsoutside:i.legsoutside});s.push(lo(b+1,v,S,i.pl,i.pw))}const c=Math.min(1,i.p/2),l=i.w-(i.legsoutside?0:i.pl*2)-.2,u=(i.num_pins/2-1)*i.p+i.pw+c,_=Ho(0,u/2+.4,u/12),d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",stroke_width:i.silkscreen_stroke_width??.1,route:[{x:-l/2,y:-u/2},{x:-l/2,y:u/2},...TX.map(({x:b,y:v})=>({x:b*l/6,y:v*l/6+u/2})),{x:l/2,y:u/2},{x:l/2,y:-u/2},{x:-l/2,y:-u/2}]},m=(i.num_pins/2-1)*i.p+i.pw,h=i.w/2+(i.legsoutside?i.pl:0),p=i.w/2+.25,x=h+.18,f=m/2+.25,g=f+.35,y={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:d2([{minX:-x,maxX:x,minY:-f,maxY:f},{minX:-p,maxX:p,minY:-g,maxY:g}])};return{circuitJson:[...s,d,_,y],parameters:i}},$6n=[{x:-1.45,y:.93},{x:-.73,y:.93},{x:-.73,y:1.1},{x:.73,y:1.1},{x:.73,y:.93},{x:1.45,y:.93},{x:1.45,y:-.93},{x:.73,y:-.93},{x:.73,y:-1.1},{x:-.73,y:-1.1},{x:-.73,y:-.93},{x:-1.45,y:-.93}],W6n=Ro.extend({fn:F(),num_pins:ke(6).default(6),w:F().default("3.1mm"),h:F().default("2.0mm"),p:F().default("0.65mm"),pl:F().default("1.03mm"),pw:F().default("0.35mm"),string:F().optional()}),U6n=t=>{const e=W6n.parse({...t,fn:"sot363"}),n=_e.parse(e.w),o=_e.parse(e.h),r=_e.parse(e.p),i=_e.parse(e.pl),s=_e.parse(e.pw),a=[];for(let h=0;h<6;h++){const{x:p,y:x}=IZe(h+1,n,r);a.push(lo(h+1,p,x,i,s))}const c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/4,y:o/2+.1},{x:n/4,y:o/2+.1}],stroke_width:.05,pcb_silkscreen_path_id:""},l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/4,y:-o/2-.1},{x:n/4,y:-o/2-.1}],stroke_width:.05,pcb_silkscreen_path_id:""},u=IZe(1,n,r),_={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:u.x-i/2-.3,y:u.y},{x:u.x-i/2-.45,y:u.y+.15},{x:u.x-i/2-.45,y:u.y-.15},{x:u.x-i/2-.3,y:u.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},d=Ho(0,o/2+.4,.25),m={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:$6n,layer:"top"};return{circuitJson:[...a,c,l,d,_,m],parameters:e}},IZe=(t,e,n,o)=>t<=3?{x:-.84,y:n-(t-1)*n}:{x:.84,y:-n+(t-4)*n},X6n=[{x:-.75,y:1},{x:-.75,y:-1},{x:.75,y:-1},{x:.75,y:1}],j6n=Ro.extend({fn:F(),num_pins:ke(6).default(6),w:F().default("1.01mm"),h:F().default("1.45mm"),p:F().default("0.5mm"),pl:F().default("0.33mm"),pw:F().default("0.27mm"),string:F().optional()}),G6n=t=>{const e=j6n.parse({...t,fn:"sot886"}),n=_e.parse(e.w),o=_e.parse(e.h),r=_e.parse(e.p),i=_e.parse(e.pl),s=_e.parse(e.pw),a=[];for(let h=0;h<6;h++){const{x:p,y:x}=LZe(h+1,n,r,i);a.push(lo(h+1,p,x,i,s))}const c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/2,y:o/2},{x:n/2,y:o/2}],stroke_width:.05,pcb_silkscreen_path_id:""},l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/2,y:-o/2},{x:n/2,y:-o/2}],stroke_width:.05,pcb_silkscreen_path_id:""},u=LZe(1,n,r,i),_={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:u.x-i/2-.3,y:u.y},{x:u.x-i/2-.45,y:u.y+.15},{x:u.x-i/2-.45,y:u.y-.15},{x:u.x-i/2-.3,y:u.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},d=Ho(0,o/2+.4,.25),m={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:X6n,layer:"top"};return{circuitJson:[...a,c,l,d,_,m],parameters:e}},LZe=(t,e,n,o)=>{const r=e/2-o/2;return t<=3?{x:-r,y:n-(t-1)*n}:{x:r,y:-n+(t-4)*n}},Y6n=[{x:-2.05,y:1.5},{x:-1.05,y:1.5},{x:-1.05,y:1.7},{x:1.05,y:1.7},{x:1.05,y:.55},{x:2.05,y:.55},{x:2.05,y:-.55},{x:1.05,y:-.55},{x:1.05,y:-1.7},{x:-1.05,y:-1.7},{x:-1.05,y:-1.5},{x:-2.05,y:-1.5},{x:-2.05,y:-.39},{x:-1.05,y:-.39},{x:-1.05,y:.39},{x:-2.05,y:.39}],q6n=[{x:-2.05,y:1.5},{x:-1.05,y:1.5},{x:-1.05,y:1.7},{x:1.05,y:1.7},{x:1.05,y:1.5},{x:2.05,y:1.5},{x:2.05,y:.39},{x:1.05,y:.39},{x:1.05,y:-.39},{x:2.05,y:-.39},{x:2.05,y:-1.5},{x:1.05,y:-1.5},{x:1.05,y:-1.7},{x:-1.05,y:-1.7},{x:-1.05,y:-1.5},{x:-2.05,y:-1.5}],OZe=Ro.extend({fn:F(),num_pins:je().default(3),w:F().default("1.92mm"),h:F().default("2.74mm"),pl:F().default("1.325mm"),pw:F().default("0.6mm"),p:F().default("0.95mm"),string:F().optional()}),J6n=p8({p:"0.95mm",w:"1.6mm",legsoutside:!0}),K6n=t=>{const e=t.string?.match(/^sot23_(\d+)/),n=e?Number.parseInt(e[1],10):3;if(n===6||n===8){const r=J6n.parse({...t,num_pins:n});return{circuitJson:gN(r),parameters:r}}const o=OZe.parse({...t,num_pins:n});if(o.num_pins===3)return{circuitJson:Z6n(o),parameters:o};if(o.num_pins===5)return{circuitJson:BZe(o),parameters:o};throw new Error("Invalid number of pins")},Q6n=t=>{const{pn:e,p:n}=t;return e===1?{x:-1.1375,y:n}:e===2?{x:-1.1375,y:-n}:{x:1.1375,y:0}},Z6n=t=>{const e=[];for(let r=0;r<t.num_pins;r++){const{x:i,y:s}=Q6n({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)});e.push(lo(r+1,i,s,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=Ho(0,Number.parseInt(t.h),.3),o={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:Y6n,layer:"top"};return[...e,n,o]},FZe=t=>{const{p:e,h:n,pn:o}=t;if(o===1)return{x:-1.1375,y:e};if(o===2)return{x:-1.1375,y:0};if(o===3)return{x:-1.1375,y:-e};if(o===4)return{x:1.1375,y:-e};if(o===5)return{x:1.1375,y:e};throw new Error("Invalid pin number")},BZe=t=>{const e=[];for(let d=1;d<=t.num_pins;d++){const{x:m,y:h}=FZe({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:d});e.push(lo(d,m,h,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=(t.num_pins+1)/2*Number.parseFloat(t.p),o=Number.parseFloat(t.h),r={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-n/3,y:o/2+Number.parseFloat(t.p)/1.3},{x:n/3,y:o/2+Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},i={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-n/3,y:-o/2-Number.parseFloat(t.p)/1.3},{x:n/3,y:-o/2-Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},s=Ho(0,o+.3,.3),a=FZe({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:1});a.x=a.x-Number.parseFloat(t.pw)*1.5;const c=.3,l=.4,u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:a.x+c/2,y:a.y},{x:a.x-c/2,y:a.y+l/2},{x:a.x-c/2,y:a.y-l/2},{x:a.x+c/2,y:a.y}],stroke_width:.05},_={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:q6n,layer:"top"};return[...e,s,r,i,u,_]},e3n=OZe.extend({}),t3n=t=>{const e=e3n.parse({...t,num_pins:5});return{circuitJson:BZe(e),parameters:e}},n3n=[{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}],o3n=p8({}),r3n=t=>{const e=o3n.parse(t),n=[];for(let x=0;x<e.num_pins;x++){const{x:f,y:g}=n1e({num_pins:e.num_pins,pn:x+1,w:e.w,p:e.p??1.27,pl:e.pl,widthincludeslegs:!0});n.push(lo(x+1,f,g,e.pl??"1mm",e.pw??"0.6mm"))}const o=Math.min(1,e.p/2),r=e.w+o,i=(e.num_pins/2-1)*e.p+e.pw+o,s=[];for(const x of n3n){const{dx:f,dy:g}=x;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",route:[{x:f*r/2-f*e.p,y:g*i/2},{x:f*r/2,y:g*i/2},{x:f*r/2,y:g*i/2-g*e.p}],type:"pcb_silkscreen_path",stroke_width:.1})}const a=e.p/4,c=-r/2-a/2,l=i/2-e.p/2;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:c,y:l},{x:c-a,y:l+a},{x:c-a,y:l-a},{x:c,y:l}],stroke_width:.1});const u=Ho(0,i/2+.4,i/12),_=x=>Math.ceil(x/.05)*.05,d=(e.num_pins/2-1)*e.p+e.pw,m=_(e.w/2+.25),h=_(d/2+.45),p={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:m*2,height:h*2,layer:"top"};return{circuitJson:[...n,u,...s,p],parameters:e}},f8=({fs:t,pn:e,anchor_x:n,anchor_y:o,textalign:r="center",orthogonal:i=!1,verticallyinverted:s=!1,layer:a="top"})=>{let c=0;i&&s?c=270:s?c=180:i?c=90:c=0;let l="center";return r==="left"&&(s?l="center_right":l="center_left"),r==="right"&&(s?l="center_left":l="center_right"),a==="bottom"&&(l==="center_left"?l="center_right":l==="center_right"&&(l="center_left")),{type:"pcb_silkscreen_text",pcb_silkscreen_text_id:"silkscreen_text_1",font:"tscircuit2024",font_size:t,pcb_component_id:"pcb_component_1",text:`{PIN${e}}`,layer:a,anchor_position:{x:n,y:o},anchor_alignment:l,ccw_rotation:c}};function zZe({pinlabeltextalignleft:t,pinlabeltextalignright:e,pinlabelorthogonal:n}){let o="top";return n?o="left":o="top",t&&(n?o="bottom":o="right"),e&&(n?o="top":o="left"),o}var i3n=Ro.extend({fn:F(),num_pins:je().optional().default(6),rows:Nn([F(),je()]).transform(t=>Number(t)).optional().default(1).describe("number of rows"),p:_e.default("0.1in").describe("pitch"),id:_e.default("1.0mm").describe("inner diameter"),od:_e.default("1.5mm").describe("outer diameter"),male:Be().optional().describe("for male pin headers"),female:Be().optional().describe("for female pin headers"),smd:Be().optional().describe("surface mount device"),surfacemount:Be().optional().describe("surface mount device (verbose)"),rightangle:Be().optional().describe("right angle"),pw:_e.optional().default("1.0mm").describe("pad width for SMD"),pl:_e.optional().default("2.0mm").describe("pad length for SMD"),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 e=zZe(t);return{...t,pinlabelAnchorSide:e,male:t.male??!t.female,female:t.female??!1,smd:t.smd??t.surfacemount??!1,rightangle:t.rightangle??!1}}).superRefine((t,e)=>{t.male&&t.female&&e.addIssue({code:Jn.custom,message:"'male' and 'female' cannot both be true; it should be male or female.",path:["male","female"]})}),s3n=t=>{const e=i3n.parse(t),{p:n,id:o,od:r,rows:i,num_pins:s,pinlabelAnchorSide:a,pinlabelverticallyinverted:c,pinlabelorthogonal:l,pinlabeltextalignleft:u,pinlabeltextalignright:_,nopinlabels:d,doublesidedpinlabel:m,bottomsidepinlabel:h}=e;let p="center";u?p="left":_&&(p="right");const x=[],f=Math.ceil(s/i),g=-n,y=({xoff:ne,yoff:ce,od:ee,anchorSide:oe,smd:ie,pw:ae,pl:de})=>{let be=0,Ce=0;if(ie){const De=ee/5;switch(oe){case"right":be=ae/2+De;break;case"top":Ce=de/2+De;break;case"bottom":Ce=-(de/2+De);break;case"left":be=-(ae/2+De);break}}else{const De=ee*.75;switch(oe){case"right":be=De;break;case"top":Ce=De;break;case"bottom":Ce=-De;break;case"left":be=-De;break}}return{anchor_x:ne+be,anchor_y:ce+Ce}},b=(ne,ce,ee)=>{e.smd?x.push(lo(ne,ce,ee,e.pw,e.pl)):ne===1&&!e.nosquareplating?x.push(P5({pn:ne,x:ce,y:ee,holeDiameter:o,rectPadWidth:r,rectPadHeight:r})):x.push(Si(ne,ce,ee,o,r));const{anchor_x:oe,anchor_y:ie}=y({xoff:ce,yoff:ee,od:r,anchorSide:a,smd:e.smd,pw:e.pw,pl:e.pl});d||(h?x.push(f8({fs:r/5,pn:ne,anchor_x:oe,anchor_y:ie,textalign:p,orthogonal:l,verticallyinverted:c,layer:"bottom"})):x.push(f8({fs:r/5,pn:ne,anchor_x:oe,anchor_y:ie,textalign:p,orthogonal:l,verticallyinverted:c,layer:"top"})),m&&x.push(f8({fs:r/5,pn:ne,anchor_x:oe,anchor_y:ie,textalign:p,orthogonal:l,verticallyinverted:c,layer:"bottom"})))},v=new Set,S=i>2&&f>2;if(i===1){const ne=-((s-1)/2)*n;for(let ce=0;ce<s;ce++){const ee=ce+1,oe=ne+ce*n,ie=`${oe},0`;if(v.has(ie))throw new Error(`Overlap at ${ie}`);v.add(ie),b(ee,oe,0)}}else if(S){const ne=-((f-1)/2)*n;let ce=1;for(let ee=0;ee<i&&ce<=s;ee++)for(let oe=0;oe<f&&ce<=s;oe++){const ie=ne+oe*n,ae=ee*g,de=`${ie},${ae}`;if(v.has(de))throw new Error(`Overlap at ${de}`);v.add(de),b(ce++,ie,ae)}}else{const ne=-((f-1)/2)*n;let ce=1,ee=0,oe=i-1,ie=0,ae=f-1;for(;ce<=s&&ee<=oe&&ie<=ae;){for(let de=ee;de<=oe&&ce<=s;de++){const be=ne+ie*n,Ce=de*g,De=`${be},${Ce}`;if(v.has(De))throw new Error(`Overlap at ${De}`);v.add(De),b(ce++,be,Ce)}ie++;for(let de=ie;de<=ae&&ce<=s;de++){const be=ne+de*n,Ce=oe*g,De=`${be},${Ce}`;if(v.has(De))throw new Error(`Overlap at ${De}`);v.add(De),b(ce++,be,Ce)}if(oe--,ie<=ae){for(let de=oe;de>=ee&&ce<=s;de--){const be=ne+ae*n,Ce=de*g,De=`${be},${Ce}`;if(v.has(De))throw new Error(`Overlap at ${De}`);v.add(De),b(ce++,be,Ce)}ae--}if(ee<=oe){for(let de=ae;de>=ie&&ce<=s;de--){const be=ne+de*n,Ce=ee*g,De=`${be},${Ce}`;if(v.has(De))throw new Error(`Overlap at ${De}`);v.add(De),b(ce++,be,Ce)}ee++}}if(ce-1<s)throw new Error(`Missing pins: assigned ${ce-1}, expected ${s}`)}const M=Ho(0,n,.5),w=e.smd?e.pw/2:r/2,D=e.smd?e.pl/2:r/2,A=(f-1)*n,I=(i-1)*n,H=A/2+w,O=I/2+D,z=A/2+n/2,V=I/2+n/2,G=Math.max(H+.25,z+.5),q=Math.max(O+.25,V+.5),K={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:-((i-1)*n)/2},width:2*G,height:2*q,layer:"top"};return{circuitJson:[...x,M,K],parameters:e}},a3n=[{x:-1.2,y:.83},{x:-.75,y:.83},{x:-.75,y:.95},{x:.75,y:.95},{x:.75,y:.83},{x:1.2,y:.83},{x:1.2,y:-.83},{x:.75,y:-.83},{x:.75,y:-.95},{x:-.75,y:-.95},{x:-.75,y:-.83},{x:-1.2,y:-.83}],c3n=Ro.extend({fn:F(),num_pins:ke(6).default(6),w:F().default("2.1mm"),h:F().default("2.45mm"),p:F().default("0.5mm"),pl:F().default("0.675mm"),pw:F().default("0.35mm"),string:F().optional()}),l3n=t=>{const e=c3n.parse({...t,fn:"sot563"}),n=_e.parse(e.w),o=_e.parse(e.h),r=_e.parse(e.p),i=_e.parse(e.pl),s=_e.parse(e.pw),a=[];for(let h=0;h<6;h++){const{x:p,y:x}=VZe(h+1,n,r,i);a.push(lo(h+1,p,x,i,s))}const c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/2,y:o/2},{x:n/2,y:o/2}],stroke_width:.05,pcb_silkscreen_path_id:""},l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/2,y:-o/2},{x:n/2,y:-o/2}],stroke_width:.05,pcb_silkscreen_path_id:""},u=VZe(1,n,r,i),_={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:u.x-i/2-.3,y:u.y},{x:u.x-i/2-.45,y:u.y+.15},{x:u.x-i/2-.45,y:u.y-.15},{x:u.x-i/2-.3,y:u.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},d=Ho(0,o/2+.4,.25),m={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:a3n,layer:"top"};return{circuitJson:[...a,c,l,d,_,m],parameters:e}},VZe=(t,e,n,o)=>{const r=e/2-o/2;return t<=3?{x:-r,y:n-(t-1)*n}:{x:r,y:-n+(t-4)*n}},u3n=p8({p:"1.27mm",w:"3.9mm",legsoutside:!0}),_3n=t=>{const e=u3n.parse({...t,num_pins:8});return{circuitJson:gN(e),parameters:e}},d3n=p8({p:"1.27mm",w:"7.5mm",legsoutside:!0}),h3n=t=>{const e=d3n.parse({...t,num_pins:16});return{circuitJson:gN(e),parameters:e}},m3n=Ro.extend({fn:F(),num_pins:ke(3).default(3),w:F().default("1.2mm"),h:F().default("1.2mm"),pw:F().default("0.40mm"),pl:F().default("0.45mm"),p:F().default("0.575mm")}),p3n=t=>{const e=m3n.parse(t),n=x3n(e),o=Ho(0,_e.parse(e.h),.2),r=1.8,i=1.8,s={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:[{x:-r/2,y:i/2},{x:r/2,y:i/2},{x:r/2,y:-i/2},{x:-r/2,y:-i/2}],layer:"top"};return{circuitJson:[...n,o,s],parameters:e}},f3n=t=>{const{pn:e,p:n}=t;return e===1?{x:n,y:0}:e===2?{x:-n,y:-.4}:{x:-n,y:.4}},x3n=t=>{const e=[];for(let n=0;n<3;n++){const{x:o,y:r}=f3n({num_pins:t.num_pins,pn:n+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)});e.push(lo(n+1,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},g3n=Ro.extend({fn:F(),num_pins:ke(2).default(2),w:F().default("2.36mm"),h:F().default("1.22mm"),pl:F().default("0.9mm"),pw:F().default("1.2mm"),p:F().default("3.30mm")}),y3n=t=>{const e=g3n.parse(t),n=Ho(0,_e.parse(e.h)/4+.4,.3),i={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:4.7,height:2.3,layer:"top"};return{circuitJson:P3n(e).concat(n,i),parameters:e}},b3n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},P3n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=b3n({pn:n,p:Number.parseFloat(t.p)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},v3n=Ro.extend({fn:F(),p:_e.optional().default("2.54mm"),id:_e.optional().default("0.7mm"),od:_e.optional().default("1.4mm")}),S3n=t=>{const e=v3n.parse(t),{p:n,id:o,od:r}=e,i=[Si(1,-n/2,0,o,r),Si(2,n/2,0,o,r)],s={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/2+r+o/2,y:0},{x:n/2-r-o/2,y:0}],stroke_width:.1,pcb_silkscreen_path_id:""},a=Ho(0,1.5,.5),c=-n/2,l=n/2,u=r/2,_=r/2,d=c-u-.35,m=l+u+.26,h=_+.35,p=d,x=m,f=h,g={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:d2([{minX:d,maxX:m,minY:-f,maxY:f},{minX:p,maxX:x,minY:-h,maxY:h}]),layer:"top"};return{circuitJson:[...i,s,a,g],parameters:e}},C3n=(t,e,n,o,r,i=.1)=>{const s=[],a=[],c=Math.max(1,Math.ceil(Math.PI*n/i)),l=Math.PI/c;for(let u=0;u<=c;u++){const _=u*l,d=t+Math.cos(_)*n,m=e+Math.sin(_)*n;d<t-o&&m>=e-r/2&&m<=e+r/2||s.push({x:d,y:m})}for(let u=0;u<=c;u++){const _=Math.PI+u*l,d=t+Math.cos(_)*n,m=e+Math.sin(_)*n;d<t-o&&m>=e-r/2&&m<=e+r/2||a.push({x:d,y:m})}return{topArc:s,bottomArc:a}},M3n=Ro.extend({fn:F(),p:_e.optional().default("5mm"),id:_e.optional().default("0.8mm"),od:_e.optional().default("1.6mm"),ceramic:Be().optional(),electrolytic:Be().optional(),polarized:Be().optional()}),T3n=t=>{const e=M3n.parse(t),{p:n,id:o,od:r}=e;o===.8&&r===1.6&&(e.id=n===5?.8:n*.25,e.od=n===5?1.6:n*.5);const i=[Si(1,-n/2,0,e.id,e.od),Si(2,n/2,0,e.id,e.od)],s=n+.1,{topArc:a,bottomArc:c}=C3n(0,0,s,e.od/2,e.od),l=.02*n,u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:a,stroke_width:l,pcb_silkscreen_path_id:""},_={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:c,stroke_width:l,pcb_silkscreen_path_id:""},d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:s},{x:0,y:-s}],stroke_width:l,pcb_silkscreen_path_id:""},m=.1*n,h=-(n+m+.04*n),p=s-m-.08*n,x={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:h-m,y:p},{x:h+m,y:p}],stroke_width:l,pcb_silkscreen_path_id:""},f={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:h,y:p-m},{x:h,y:p+m}],stroke_width:l,pcb_silkscreen_path_id:""},g=Ho(0,s+.12*n,.1*n),y=[...i,u,_,d,g];(e.electrolytic===!0||e.polarized===!0)&&y.push(x,f);const v=n+.25,S={type:"pcb_courtyard_circle",pcb_courtyard_circle_id:"",pcb_component_id:"",center:{x:0,y:0},radius:v,layer:"top"};return y.push(S),{circuitJson:y,parameters:e}},x8=(t,e={})=>({type:"pcb_silkscreen_path",layer:e.layer||"top",pcb_component_id:e.pcb_component_id||"",pcb_silkscreen_path_id:e.pcb_silkscreen_path_id||"",route:t,stroke_width:e.stroke_width||.1}),w3n=Ro.extend({fn:ke("pushbutton"),w:_e.default(4.5),h:_e.default(6.5),id:_e.default(1),od:_e.default(1.2)}),E3n=t=>{const e=w3n.parse(t),n=e.w,o=e.h,r=e.id,i=[Si(1,-n/2,o/2,r,r*1.5),Si(2,-n/2,-o/2,r,r*1.5),Si(3,n/2,-o/2,r,r*1.5),Si(4,n/2,o/2,r,r*1.5)],s=[x8([{x:-n/2,y:-o/2},{x:-n/2,y:o/2}]),x8([{x:n/2,y:-o/2},{x:n/2,y:o/2}]),x8([{x:-n/2,y:0},{x:-n/5,y:0},{x:n/5*1/Math.sqrt(2),y:o/8}]),x8([{x:n/2,y:0},{x:n/5,y:0}])],a=Ho(0,o/2+.4,.5),c=r*1.5/2,l=n,u=o,_=l/2+c,d=u/2+c,m=_+.5,h=d+.5,p={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:2*m,height:2*h,layer:"top"};return{circuitJson:[...i,...s,a,p],parameters:e}},$Ze=Ro.extend({fn:F(),w:_e.default("22.58mm"),h:_e.optional(),left:_e.optional().default(20),right:_e.optional().default(20),top:_e.optional().default(2),bottom:_e.optional().default(2),p:_e.default(_e.parse("2.54mm")),pw:_e.default(_e.parse("1.6mm")),pl:_e.default(_e.parse("2.4mm")),innerhole:Be().default(!1),innerholeedgedistance:_e.default(_e.parse("1.61mm")),silkscreenlabels:Be().default(!1),silkscreenlabelmargin:_e.default(_e.parse("0.1mm"))}),D3n=t=>{const e=$Ze.parse(t);return e.left&&e.right?Math.max(e.left,e.right)*e.p:e.left?e.left*e.p:e.right?e.right*e.p:51},RX=(t,e,n)=>{let o=[];return n==="right"&&(o=[{x:t+1/2,y:e},{x:t-1/2,y:e+.6/2},{x:t-1/2,y:e-.6/2},{x:t+1/2,y:e}]),n==="left"&&(o=[{x:t-1/2,y:e},{x:t+1/2,y:e+.6/2},{x:t+1/2,y:e-.6/2},{x:t-1/2,y:e}]),n==="top"&&(o=[{x:t,y:e+1/2},{x:t-.6/2,y:e-1/2},{x:t+.6/2,y:e-1/2},{x:t,y:e+1/2}]),n==="bottom"&&(o=[{x:t,y:e-1/2},{x:t-.6/2,y:e+1/2},{x:t+.6/2,y:e+1/2},{x:t,y:e-1/2}]),o},A3n=t=>{const e=$Ze.parse(t),n=e.h??D3n(e),o=[],r=[],i=[];let s=[];const a=1,c=a,l=e.left+e.right+(e.bottom??0)+(e.top??0),_=`pin${l}`.length*.7/2;if(e.right){const p=-((e.right-1)/2)*e.p;for(let x=0;x<e.right;x++){if(x===0&&!e.left&&!e.bottom&&!e.silkscreenlabels&&(s=RX(e.w/2-e.pl*1.4,p+x*e.p,"right")),o.push(lo(x+1+e.left+(e.bottom??0),e.w/2-e.pl/2,p+x*e.p,e.pl,e.pw)),e.silkscreenlabels){const f=x+1+e.left+(e.bottom??0),g=`pin${f}`;i.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${f}`,pcb_component_id:"1",layer:"top",anchor_position:{x:e.w/2-e.pl-(_+e.silkscreenlabelmargin),y:p+x*e.p},text:g,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}e.innerhole&&(r.push(Si(x+1+e.left+(e.bottom??0)+l,e.w/2,p+x*e.p,a,c)),r.push(Si(x+1+e.left+(e.bottom??0)+l*2,e.w/2-e.innerholeedgedistance,p+x*e.p,a,c)))}}if(e.left){const p=(e.left-1)/2*e.p;for(let x=0;x<e.left;x++){if(x===0&&!e.silkscreenlabels&&(s=RX(-e.w/2+e.pl*1.4,p-x*e.p,"left")),o.push(lo(x+1,-e.w/2+e.pl/2,p-x*e.p,e.pl,e.pw)),e.silkscreenlabels){const f=x+1,g=`pin${f}`;i.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${f}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-e.w/2+e.pl+(_+e.silkscreenlabelmargin),y:p-x*e.p},text:g,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}e.innerhole&&(r.push(Si(x+1+l,-e.w/2,p-x*e.p,a,c)),r.push(Si(x+1+l*2,-e.w/2+e.innerholeedgedistance,p-x*e.p,a,c)))}}if(e.top){const p=(e.top-1)/2*e.p;for(let x=0;x<e.top;x++){if(x===0&&!e.left&&!e.bottom&&!e.right&&!e.silkscreenlabels&&(s=RX(p-x*e.p,n/2-e.pl*1.4,"top")),o.push(lo(x+1+e.left+e.right+(e.bottom??0),p-x*e.p,n/2-e.pl/2,e.pw,e.pl)),e.silkscreenlabels){const f=x+1+e.left+e.right+(e.bottom??0),g=`pin${f}`;i.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${f}`,pcb_component_id:"1",layer:"top",anchor_position:{x:p-x*e.p,y:n/2-e.pl-(_+e.silkscreenlabelmargin)},text:g,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:270})}e.innerhole&&(r.push(Si(x+1+e.left+e.right+(e.bottom??0)+l,p-x*e.p,n/2,a,c)),r.push(Si(x+1+e.left+e.right+(e.bottom??0)+l*2,p-x*e.p,n/2-e.innerholeedgedistance,a,c)))}}if(e.bottom){const p=-((e.bottom-1)/2)*e.p;for(let x=0;x<e.bottom;x++){if(x===0&&!e.left&&!e.silkscreenlabels&&(s=RX(p+x*e.p,-n/2+e.pl*1.4,"bottom")),o.push(lo(x+1+e.left,p+x*e.p,-n/2+e.pl/2,e.pw,e.pl)),e.silkscreenlabels){const f=x+1+e.left,g=`pin${f}`;i.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${f}`,pcb_component_id:"1",layer:"top",anchor_position:{x:p+x*e.p,y:-n/2+e.pl+(_+e.silkscreenlabelmargin)},text:g,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:90})}e.innerhole&&(r.push(Si(x+1+e.left+l,p+x*e.p,-n/2,a,c)),r.push(Si(x+1+e.left+l*2,p+x*e.p,-n/2+e.innerholeedgedistance,a,c)))}}const d={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_triangle_1",pcb_component_id:"2",route:s,stroke_width:.1,layer:"top"},m={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-e.w/2,y:n/2},{x:e.w/2,y:n/2},{x:e.w/2,y:-n/2},{x:-e.w/2,y:-n/2},{x:-e.w/2,y:n/2}],stroke_width:.1,layer:"top"},h=Ho(0,n/1.8,n/25);return{circuitJson:[...o,...r,...i,m,...e.silkscreenlabels?[]:[d],h],parameters:e}},WZe=Ro.extend({fn:F(),w:_e.default("22.58mm"),h:_e.optional(),left:_e.optional().default(20),right:_e.optional().default(20),top:_e.optional().default(2),bottom:_e.optional().default(2),p:_e.default(_e.parse("2.54mm")),pw:_e.default(_e.parse("1.6mm")),pl:_e.default(_e.parse("3.2mm")),innerhole:Be().default(!1),innerholeedgedistance:_e.default(_e.parse("1.61mm"))}),R3n=t=>{const e=WZe.parse(t);return e.left&&e.right?Math.max(e.left,e.right)*e.p:e.left?e.left*e.p:e.right?e.right*e.p:51},k3n=(t,e,n,o=1,r=.6)=>{const i=o/2,s=r/2;return{left:[{x:t+i,y:e},{x:t-i,y:e+s},{x:t-i,y:e-s},{x:t+i,y:e}],right:[{x:t-i,y:e},{x:t+i,y:e+s},{x:t+i,y:e-s},{x:t-i,y:e}],top:[{x:t,y:e-i},{x:t-s,y:e+i},{x:t+s,y:e+i},{x:t,y:e-i}],bottom:[{x:t,y:e+i},{x:t-s,y:e-i},{x:t+s,y:e-i},{x:t,y:e+i}]}[n]},N3n=t=>{const e=WZe.parse(t),n=e.h??R3n(e),o=[],r=[],i=[],s=1,a=1.2,c=e.left+e.right+(e.bottom??0)+(e.top??0);let l=[],u=1;if(e.left){const h=(e.left-1)/2*e.p;for(let p=0;p<e.left;p++)p===0&&(l=k3n(-e.w/2-e.pl/2,h-p*e.p,"left")),o.push(lo(u,-e.w/2+e.pl/2,h-p*e.p,e.pl,e.pw)),r.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${u}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-e.w/2+e.pl/2-4.5,y:h-p*e.p},text:`pin${u}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),u++,e.innerhole&&i.push(Si(u+c,-e.w/2+e.innerholeedgedistance,h-p*e.p,s,a))}if(e.bottom){const h=(e.bottom-1)/2*e.p;for(let p=e.bottom-1;p>=0;p--)o.push(lo(u,h-p*e.p,-n/2+e.pl/2,e.pw,e.pl)),r.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${u}`,pcb_component_id:"1",layer:"top",anchor_position:{x:h-p*e.p,y:-n/2+e.pl/2-3.2},text:`pin${u}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),u++,e.innerhole&&i.push(Si(u+c,h-p*e.p,-n/2+e.innerholeedgedistance,s,a))}if(e.right){const h=-((e.right-1)/2)*e.p;for(let p=0;p<e.right;p++)o.push(lo(u,e.w/2-e.pl/2,h+p*e.p,e.pl,e.pw)),r.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${u}`,pcb_component_id:"1",layer:"top",anchor_position:{x:e.w/2-e.pl/2+3.7,y:h+p*e.p},text:`pin${u}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),u++,e.innerhole&&i.push(Si(u+c,e.w/2-e.innerholeedgedistance,h+p*e.p,s,a))}if(e.top){const h=-((e.top-1)/2)*e.p;for(let p=e.top-1;p>=0;p--)o.push(lo(u,h+p*e.p,n/2-e.pl/2,e.pw,e.pl)),r.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${u}`,pcb_component_id:"1",layer:"top",anchor_position:{x:h+p*e.p,y:n/2-e.pl/2+3.2},text:`pin${u}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),u++,e.innerhole&&i.push(Si(u+c,h+p*e.p,n/2-e.innerholeedgedistance,s,a))}const _={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"1",pcb_component_id:"1",layer:"top",route:l,stroke_width:.1},d={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-e.w/2-e.pl/3,y:n/2+e.pl/3},{x:e.w/2+e.pl/3,y:n/2+e.pl/3},{x:e.w/2+e.pl/3,y:-n/2-e.pl/3},{x:-e.w/2-e.pl/3,y:-n/2-e.pl/3},{x:-e.w/2-e.pl/3,y:n/2+e.pl/3}],stroke_width:.1,layer:"top"},m=Ho(0,n/1.8,n/25);return{circuitJson:[...i,...o,...r,d,_,m],parameters:e}},H3n=t=>(t.legsoutside=!0,t.pl||(t.pl=1.5),t.pw||(t.pw=.3),Jw(t)),UZe=Ro.extend({fn:F(),w:_e.default("10mm"),h:_e.optional(),left:_e.optional().default(20),right:_e.optional().default(20),top:_e.optional().default(0),bottom:_e.optional().default(0),p:_e.default(_e.parse("2.54mm")),id:_e.optional().default(_e.parse("1mm")),od:_e.optional().default(_e.parse("1.5mm"))}),I3n=t=>{const e=UZe.parse(t);return e.left&&e.right?Math.max(e.left,e.right)*e.p:e.left?e.left*e.p:e.right?e.right*e.p:51},kX=(t,e,n,o=1,r=.6)=>{const i=o/2,s=r/2;return{left:[{x:t+i,y:e},{x:t-i,y:e+s},{x:t-i,y:e-s},{x:t+i,y:e}],right:[{x:t-i,y:e},{x:t+i,y:e+s},{x:t+i,y:e-s},{x:t-i,y:e}],top:[{x:t,y:e-i},{x:t-s,y:e+i},{x:t+s,y:e+i},{x:t,y:e-i}],bottom:[{x:t,y:e+i},{x:t-s,y:e-i},{x:t+s,y:e-i},{x:t,y:e+i}]}[n]},L3n=t=>{const e=UZe.parse(t),n=e.h??I3n(e),o=[],r=e.id,i=e.od;let s=[];if(e.right){const u=-((e.right-1)/2)*e.p;for(let _=0;_<e.right;_++)_===0&&!e.left&&!e.bottom&&(s=kX(e.w/2+i*1.4,u+_*e.p,"right")),o.push(Si(_+1+e.left+(e.bottom??0),e.w/2,u+_*e.p,r,i))}if(e.left){const u=-((e.left-1)/2)*e.p;for(let _=0;_<e.left;_++)_===e.left-1&&(s=kX(-e.w/2-i*1.4,u+_*e.p,"left")),o.push(Si(_+1,-e.w/2,u+_*e.p,r,i))}if(e.top){const u=-((e.top-1)/2)*e.p;for(let _=0;_<e.top;_++)_===e.top-1&&!e.left&&!e.bottom&&!e.right&&(s=kX(u+_*e.p,n/2+i*1.4,"top")),o.push(Si(_+1+e.right+(e.bottom??0)+e.left,u+_*e.p,n/2,r,i))}if(e.bottom){const u=-((e.bottom-1)/2)*e.p;for(let _=0;_<e.bottom;_++)_===0&&!e.left&&(s=kX(u+_*e.p,-n/2-i*1.4,"bottom")),o.push(Si(_+1+e.left,u+_*e.p,-n/2,r,i))}const a={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"1",pcb_component_id:"1",layer:"top",route:s,stroke_width:.1},c={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-e.w/2-i,y:n/2+i},{x:e.w/2+i,y:n/2+i},{x:e.w/2+i,y:-n/2-i},{x:-e.w/2-i,y:-n/2-i},{x:-e.w/2-i,y:n/2+i}],stroke_width:.1,layer:"top"},l=Ho(0,n/1.7,n/25);return{circuitJson:[...o,c,l,a],parameters:e}},O3n=t=>{const{centerX:e,centerY:n,straightHalfLength:o,radius:r,arcSegmentCount:i=9,orientation:s="horizontal"}=t;if(o<0)throw new Error("Capsule straightHalfLength must be non-negative");if(r<=0)throw new Error("Capsule radius must be positive");if(i<2)throw new Error("Capsule arcSegmentCount must be at least 2");if(s==="horizontal"){const _=e-o,d=e+o,m=Array.from({length:i+1},(p,x)=>{const f=Math.PI/2-x*Math.PI/i;return{x:d+Math.cos(f)*r,y:n+Math.sin(f)*r}}),h=Array.from({length:i+1},(p,x)=>{const f=-Math.PI/2+x*Math.PI/i;return{x:_-Math.cos(f)*r,y:n+Math.sin(f)*r}});return[{x:_,y:n+r},{x:d,y:n+r},...m.slice(1,-1),{x:d,y:n-r},{x:_,y:n-r},...h.slice(1,-1)]}const a=n-o,c=n+o,l=Array.from({length:i+1},(_,d)=>{const m=Math.PI-d*Math.PI/i;return{x:e+Math.cos(m)*r,y:c+Math.sin(m)*r}}),u=Array.from({length:i+1},(_,d)=>{const m=d*Math.PI/i;return{x:e+Math.cos(m)*r,y:a-Math.sin(m)*r}});return[{x:e-r,y:a},{x:e-r,y:c},...l.slice(1,-1),{x:e+r,y:c},{x:e+r,y:a},...u.slice(1,-1)]},XZe=(t,e,n,o)=>Array.from({length:25},(r,i)=>{const s=i/24*Math.PI-Math.PI/2;return{x:t+(o==="right"?1:-1)*Math.cos(s)*n,y:e+Math.sin(s)*n}}),F3n=Ro.extend({fn:F(),p:_e.optional().default("4.88mm"),id:_e.optional().default("0.8mm"),od:_e.optional().default("1.5mm"),w:_e.optional().default("5.6mm"),h:_e.optional().default("3.5mm")}),B3n=t=>{const e=F3n.parse(t),{p:n,id:o,od:r,w:i,h:s}=e,a=s/2,c=[Si(1,-n/2,0,o,r),Si(2,n/2,0,o,r)],l=XZe(-i/2,0,a,"left"),u=XZe(i/2,0,a,"right"),_={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[...l,...l.slice(1).reverse(),{x:-i/2,y:-s/2},{x:i/2,y:-s/2},...u,{x:i/2,y:s/2},{x:-i/2,y:s/2}],stroke_width:.1,pcb_silkscreen_path_id:""},d=Ho(0,n/4,.5),h=n/2+r/2,p=Math.max(s/2+.25,i/2+.03),x={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:O3n({centerX:0,centerY:0,straightHalfLength:h,radius:p,arcSegmentCount:9}),layer:"top"};return{circuitJson:[...c,_,d,x],parameters:e}};Ro.extend({w:_e,h:_e});var z3n=t=>{const{w:e,h:n}=t,o=Xs(e),r=Xs(n);return{circuitJson:[lo(1,0,0,o,r),Ho(0,r/2+.5,.2)],parameters:t}},g8=(t,e,n,o,r,i)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"pill",x:e,y:n,outer_width:Xs(r),outer_height:Xs(i),hole_width:Xs(o),hole_height:Xs(o),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()],ccw_rotation:0}),V3n=[{x:-2.73,y:3.71},{x:-2.73,y:-1.03},{x:2.73,y:-1.03},{x:2.73,y:3.71}],$3n=Ro.extend({fn:F(),num_pins:Nn([ke(3),ke(2)]).default(3),p:F().default("1.27mm"),id:F().default("0.72mm"),od:F().default("0.95mm"),w:F().default("4.5mm"),h:F().default("4.5mm"),inline:Be().default(!1),string:F().optional()}),W3n=(t,e,n)=>Array.from({length:25},(o,r)=>{const i=r/24*Math.PI;return{x:t+Math.cos(i)*n,y:e+Math.sin(i)*n}}),U3n=t=>{const e=t.string?.match(/^to92_(\d+)/),n=e?Number.parseInt(e[1],10):3,o=$3n.parse({...t,num_pins:n}),{p:r,id:i,od:s,w:a,h:c,inline:l}=o,u=Number.parseFloat(c)/2,_=Number.parseFloat(r),d=Number.parseFloat(i),m=Number.parseFloat(s),h=m,p=m*(1.5/1.05);let x=[];if(o.num_pins===3)l?x=[P5({pn:1,x:-_,y:u-_,holeDiameter:d,rectPadWidth:m,rectPadHeight:p}),g8(2,0,u-_,d,h,p),g8(3,_,u-_,d,h,p)]:x=[P5({pn:1,x:-_,y:u-_,holeDiameter:d,rectPadWidth:m,rectPadHeight:m}),Si(2,0,u,d,m),Si(3,_,u-_,d,m)];else if(o.num_pins===2)x=[P5({pn:1,x:-_,y:u-_,holeDiameter:d,rectPadWidth:h,rectPadHeight:p}),g8(2,_,u-_,d,h,p)];else throw new Error("Invalid number of pins for TO-92");const f=Number.parseFloat(a)/2,g=W3n(0,u,f),y={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[...g,{x:-f,y:0},{x:f,y:0},g[0]],stroke_width:.1,pcb_silkscreen_path_id:""},b=Ho(0,u+1,.5),v={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:V3n,layer:"top"};return{circuitJson:[...x,y,b,v],parameters:o}},X3n=Ro.extend({fn:F(),num_pins:ke(2).default(2),w:F().default("2.15mm"),h:F().default("1.20mm"),pl:F().default("0.5mm"),pw:F().default("0.6mm"),p:F().default("1.4mm")}),j3n=t=>{const e=X3n.parse(t),n=Ho(0,_e.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_e.parse(e.p)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.2,y:-_e.parse(e.h)/2},{x:_e.parse(e.p)/2,y:-_e.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:2.5,height:1.4,layer:"top"};return{circuitJson:Y3n(e).concat(o,n,s),parameters:e}},G3n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Y3n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=G3n({pn:n,p:Number.parseFloat(t.p)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},q3n=p8({w:"7.05mm",p:"1.27mm",pw:"0.65mm",pl:"1.975mm"}),J3n=t=>{const e=q3n.parse(t),n=[];for(let d=0;d<e.num_pins;d++){const{x:m,y:h}=n1e({num_pins:e.num_pins,pn:d+1,w:e.w,p:e.p??1.27,pl:e.pl,widthincludeslegs:!0});n.push(lo(d+1,m,h,e.pl??"1.5mm",e.pw??"0.6mm"))}const o=(e.num_pins/2-1)*e.p+e.pw,r=Ho(0,o/2+1,o/12),i={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:-e.w/3,y:o/2+.4},{x:e.w/3,y:o/2+.4}],stroke_width:.1},s=(e.num_pins/2-1)*e.p+e.pw,a=e.w/2-1.395,c=e.w/2+.255,l=s/2+.25,u=s/2+.5,_={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:d2([{minX:-c,maxX:c,minY:-l,maxY:l},{minX:-a,maxX:a,minY:-u,maxY:u}])};return{circuitJson:[...n,r,i,_],parameters:e}},K3n=Ro.extend({fn:F(),num_pins:ke(2).default(2),w:F().default("5.0mm"),h:F().default("2.30mm"),pl:F().default("1.25mm"),pw:F().default("2mm"),p:F().default("3.75mm")}),Q3n=t=>{const e=K3n.parse(t),n=Ho(0,_e.parse(e.h)/2+1,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_e.parse(e.p)/2+.5,y:_e.parse(e.h)/2+.5},{x:-_e.parse(e.w)/2-.5,y:_e.parse(e.h)/2+.5},{x:-_e.parse(e.w)/2-.5,y:-_e.parse(e.h)/2-.5},{x:_e.parse(e.p)/2+.5,y:-_e.parse(e.h)/2-.5}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:5.1,height:2.8,layer:"top"};return{circuitJson:e9n(e).concat(o,n,s),parameters:e}},Z3n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},e9n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=Z3n({pn:n,p:Number.parseFloat(t.p)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},t9n=Ro.extend({fn:F(),num_pins:ke(2).default(2),w:F().default("4.4mm"),h:F().default("2.1mm"),pl:F().default("1.2mm"),pw:F().default("1.2mm"),p:F().default("2.9mm")}),n9n=t=>{const e=t9n.parse(t),n=Ho(0,_e.parse(e.h)-.5,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_e.parse(e.p)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.2,y:-_e.parse(e.h)/2},{x:_e.parse(e.p)/2,y:-_e.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:4.5,height:2.2,layer:"top"};return{circuitJson:r9n(e).concat(o,n,s),parameters:e}},o9n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},r9n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=o9n({pn:n,p:Number.parseFloat(t.p)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},i9n=Ro.extend({fn:F(),num_pins:ke(2).default(2),w:F().default("3.30mm"),h:F().default("1.80mm"),pl:F().default("0.60mm"),pw:F().default("0.45mm"),p:F().default("2.1mm")}),s9n=t=>{const e=i9n.parse(t),n=Ho(0,_e.parse(e.h)-.5,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_e.parse(e.p)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2,y:-_e.parse(e.h)/2},{x:_e.parse(e.p)/2,y:-_e.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:3.2,height:1.9,layer:"top"};return{circuitJson:c9n(e).concat(o,n,s),parameters:e}},a9n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},c9n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=a9n({pn:n,p:Number.parseFloat(t.p)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},l9n=Ro.extend({fn:F(),num_pins:ke(2).default(2),w:F().default("1.4mm"),h:F().default("0.9mm"),pl:F().default("0.36mm"),pw:F().default("0.25mm"),p:F().default("0.85mm")}),u9n=t=>{const e=l9n.parse(t),n=_e.parse(e.w),o=_e.parse(e.h),r=_e.parse(e.pl),i=_e.parse(e.pw),s=_e.parse(e.p),a=Ho(0,o,.3),c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:s/2+.15,y:o/2},{x:-n/2-.15,y:o/2},{x:-n/2-.15,y:-o/2},{x:s/2+.15,y:-o/2}],stroke_width:.1,pcb_silkscreen_path_id:""},l=s+r,u=i,_=n/2,d=o/2,m=l/2,h=u/2,p=Math.max(_,m),x=Math.max(d,h),f=Math.min(_,m),g=Math.min(d,h),y=p+.05,b=f-.055,v=x,S=g+.155,M={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:d2([{minX:-y,maxX:y,minY:-S,maxY:S},{minX:-b,maxX:b,minY:-v,maxY:v}]),layer:"top"};return{circuitJson:d9n(e).concat(c,a,M),parameters:e}},_9n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},d9n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=_9n({pn:n,p:Number.parseFloat(t.p)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},h9n=Ro.extend({fn:F(),num_pins:ke(2).default(2),w:F().default("1.3mm"),h:F().default("0.9mm"),pl:F().default("0.4mm"),pw:F().default("0.7mm"),p:F().default("0.7mm")}),m9n=t=>{const e=h9n.parse(t),n=Ho(0,_e.parse(e.h)+.1,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_e.parse(e.p)/2+.2,y:_e.parse(e.h)/2+.2},{x:-_e.parse(e.w)/2-.2,y:_e.parse(e.h)/2+.2},{x:-_e.parse(e.w)/2-.2,y:-_e.parse(e.h)/2-.2},{x:_e.parse(e.p)/2+.2,y:-_e.parse(e.h)/2-.2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:1.6,height:1.2,layer:"top"};return{circuitJson:f9n(e).concat(o,n,s),parameters:e}},p9n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},f9n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=p9n({pn:n,p:Number.parseFloat(t.p)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},x9n=Ro.extend({fn:F(),num_pins:ke(2).default(2),w:F().default("3.05mm"),h:F().default("1.65mm"),pl:F().default("0.6mm"),pw:F().default("0.6mm"),pad_spacing:F().default("2.2mm")}),g9n=t=>{const e=x9n.parse(t),n=Ho(0,_e.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_e.parse(e.pad_spacing)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.2,y:-_e.parse(e.h)/2},{x:_e.parse(e.pad_spacing)/2,y:-_e.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:3.2,height:1.9,layer:"top"};return{circuitJson:b9n(e).concat(o,n,s),parameters:e}},y9n=t=>{const{pn:e,pad_spacing:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},b9n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=y9n({pn:n,pad_spacing:Number.parseFloat(t.pad_spacing)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},P9n=Ro.extend({fn:F(),num_pins:ke(2).default(2),w:F().default("4.4mm"),h:F().default("2.1mm"),pl:F().default("1.10mm"),pw:F().default("1.10mm"),p:F().default("2.8mm")}),v9n=t=>{const e=P9n.parse(t),n=Ho(0,_e.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_e.parse(e.p)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.2,y:-_e.parse(e.h)/2},{x:_e.parse(e.p)/2,y:-_e.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:4.4,height:2.3,layer:"top"};return{circuitJson:C9n(e).concat(o,n,s),parameters:e}},S9n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},C9n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=S9n({pn:n,p:Number.parseFloat(t.p)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},M9n=Ro.extend({fn:F(),num_pins:ke(2).default(2),w:F().default("4.4mm"),h:F().default("2.1mm"),pl:F().default("0.91mm"),pw:F().default("1.22mm"),p:F().default("3.146mm")}),T9n=t=>{const e=M9n.parse(t),n=Ho(0,_e.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_e.parse(e.p)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.2,y:-_e.parse(e.h)/2},{x:_e.parse(e.p)/2,y:-_e.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:4.9,height:2.7,layer:"top"};return{circuitJson:E9n(e).concat(o,n,s),parameters:e}},w9n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},E9n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=w9n({pn:n,p:Number.parseFloat(t.p)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},D9n=Ro.extend({fn:F(),num_pins:ke(2).default(2),w:F().default("1.80mm"),h:F().default("1.00mm"),pl:F().default("0.66mm"),pw:F().default("0.5mm"),p:F().default("0.8mm")}),A9n=t=>{const e=D9n.parse(t),n=Ho(0,_e.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_e.parse(e.p)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.1,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.1,y:-_e.parse(e.h)/2},{x:_e.parse(e.p)/2,y:-_e.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:2.3,height:1.5,layer:"top"};return{circuitJson:k9n(e).concat(o,n,s),parameters:e}},R9n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},k9n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=R9n({pn:n,p:Number.parseFloat(t.p)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},N9n=Ro.extend({fn:F(),num_pins:ke(2).default(2),w:F().default("6.2mm"),h:F().default("3.4mm"),pl:F().default("1.4mm"),pw:F().default("2.1mm"),p:F().default("4.4mm")}),H9n=t=>{const e=N9n.parse(t),n=Ho(0,_e.parse(e.h)/2+.4,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_e.parse(e.p)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.2,y:-_e.parse(e.h)/2},{x:_e.parse(e.p)/2,y:-_e.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:6.3,height:3,layer:"top"};return{circuitJson:L9n(e).concat(o,n,s),parameters:e}},I9n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},L9n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=I9n({pn:n,p:Number.parseFloat(t.p)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},O9n=[{x:-3.0875,y:-2.5},{x:-3.0875,y:2.5},{x:2.0125,y:2.5},{x:2.0125,y:-2.5}],F9n=[{x:-2.85,y:-2.5},{x:-2.85,y:2.5},{x:2.85,y:2.5},{x:2.85,y:-2.5}],B9n=Ro.extend({fn:F(),num_pins:Nn([ke(3),ke(5)]).default(3),w:F().default("4.20mm"),h:F().default("4.80mm"),pl:F().default("1.3mm"),pw:F().default("0.9mm"),p:F().default("1.5mm"),string:F().optional()}),z9n=t=>{const e=[],n=Number.parseFloat(t.p),o=Number.parseFloat(t.pw),r=Number.parseFloat(t.w),i=Number.parseFloat(t.pl),s=.175,a=(i-(i+s))/2;e.push(lo(1,-r/2+a,n,i,o),lo(2,-r/2,0,i+s,o),lo(3,-r/2+a,-n,i,o));const c=Ho(0,0,.3),l=Number.parseFloat(t.w)/2-1,u=Number.parseFloat(t.h)/2,_={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-l,y:u},{x:l,y:u},{x:l,y:u/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},d={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-l,y:-u},{x:l,y:-u},{x:l,y:-u/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},m={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:O9n,layer:"top"};return[...e,_,d,c,m]},V9n=t=>{const e=[];Number.parseFloat(t.p),Number.parseFloat(t.pw),Number.parseFloat(t.w),e.push(lo(1,-1.85,-1.5,1.5,.7),lo(2,-1.85,1.5,1.5,.7),lo(3,0,0,.8,2),lo(4,1.85,-1.5,1.5,.7),lo(5,1.85,1.5,1.5,.7));const n=Ho(0,Number.parseFloat(t.h)/2+.5,.3),o=Number.parseFloat(t.w)/2-1,r=Number.parseFloat(t.h)/2,i={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-o,y:r},{x:o,y:r}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-o,y:-r},{x:o,y:-r}],type:"pcb_silkscreen_path",stroke_width:.1},a={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:F9n,layer:"top"};return[...e,i,s,n,a]},$9n=t=>{const e=t.string?.match(/^sot89_(\d+)/),n=e?Number.parseInt(e[1],10):3,o=B9n.parse({...t,num_pins:n});if(o.num_pins===3)return{circuitJson:z9n(o),parameters:o};if(o.num_pins===5)return{circuitJson:V9n(o),parameters:o};throw new Error("Invalid number of pins for SOT89")},W9n=Ro.extend({fn:F(),p:_e.optional().default("5.0mm"),id:_e.optional().default("1.0mm"),od:_e.optional().default("1.9mm"),w:_e.optional().default("13mm"),h:_e.optional().default("7mm"),num_pins:je().optional(),string:F().optional()}),jZe=t=>{const e=W9n.parse(t),{id:n,od:o,w:r,h:i,string:s}=e,a=e.num_pins??Number.parseInt(s?.match(/^to220(?:_|-)(\d+)/i)?.[1]??"3"),c=-1,l=r/2,u=i/2,_=2.5,d=r*.4,m=Math.max(_,d/(a-1)),h=Array.from({length:a},(V,G)=>{const q=a%2===0?(G-a/2+.5)*m:(G-Math.floor(a/2))*m;return Si(G+1,q,c,n,o)}),p={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-l,y:-u},{x:l,y:-u},{x:l,y:u},{x:-l,y:u},{x:-l,y:-u}],stroke_width:.1,pcb_silkscreen_path_id:""},x=-u+2*i/3,f={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-l,y:x},{x:l,y:x}],stroke_width:.1,pcb_silkscreen_path_id:""},g=[{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-r/6,y:x},{x:-r/6,y:u}],stroke_width:.1,pcb_silkscreen_path_id:""},{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:r/6,y:x},{x:r/6,y:u}],stroke_width:.1,pcb_silkscreen_path_id:""}],y=Ho(0,i/2+.6,.5),b=Math.max(...h.map(V=>Math.abs(V.x)))+o/2,v=c+o/2,S=c-o/2,M=Math.max(b+.25,l-o*.59),w=u-o*.63,D=S-(o/2+.01),A=-M,I=M,H=Math.min(D,S-.25),O=Math.max(w,v+.25),z={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:(A+I)/2,y:(H+O)/2},width:I-A,height:O-H,layer:"top"};return{circuitJson:[...h,p,f,...g,y,z],parameters:{...e,p:m}}},i1e=2.54,U9n=Ro.extend({fn:F(),id:_e.optional().default("1.2mm"),od:_e.optional().default("1.905mm"),ph:_e.optional().default("2mm"),w:_e.optional().default("13mm"),h:_e.optional().default("7mm"),num_pins:je().optional(),string:F().optional()}),X9n=t=>{const e=U9n.parse(t),n=e.num_pins??Number.parseInt(e.string?.match(/^to220f(?:_|-)(\d+)/i)?.[1]??"3"),o=jZe({...e,fn:"to220",string:e.string?.replace(/^to220f/i,"to220"),num_pins:n}),r=-1,i=Array.from({length:n},(a,c)=>{const l=n%2===0?(c-n/2+.5)*i1e:(c-Math.floor(n/2))*i1e;return c===0?P5({pn:1,x:l,y:r,holeDiameter:e.id,rectPadWidth:e.od,rectPadHeight:e.ph}):g8(c+1,l,r,Xs(e.id),Xs(e.od),Xs(e.ph))}),s=o.circuitJson.filter(a=>a.type!=="pcb_plated_hole");return{circuitJson:[...i,...s],parameters:{...e,p:i1e,num_pins:n}}},j9n=Ro.extend({fn:F(),num_pins:ke(2).default(2),w:F().default("5.40mm"),h:F().default("2.30mm"),pl:F().default("1.30mm"),pw:F().default("1.70mm"),p:F().default("3.5mm")}),G9n=t=>{const e=j9n.parse(t),n=Ho(0,_e.parse(e.h)/2+.4,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_e.parse(e.p)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2,y:-_e.parse(e.h)/2},{x:_e.parse(e.p)/2,y:-_e.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:5.3,height:2.2,layer:"top"};return{circuitJson:q9n(e).concat(o,n,s),parameters:e}},Y9n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},q9n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=Y9n({pn:n,p:Number.parseFloat(t.p)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},J9n=Ro.extend({fn:F(),num_pins:ke(2).default(2),w:F().default("1.90mm"),h:F().default("1.33mm"),pl:F().default("0.5mm"),pw:F().default("0.7mm"),p:F().default("0.8mm")}),K9n=t=>{const e=J9n.parse(t),n=Ho(0,_e.parse(e.h)+.1,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_e.parse(e.p)/2+.1,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2,y:-_e.parse(e.h)/2},{x:_e.parse(e.p)/2+.1,y:-_e.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:1.8,height:1.2,layer:"top"};return{circuitJson:Z9n(e).concat(o,n,s),parameters:e}},Q9n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Z9n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=Q9n({pn:n,p:Number.parseFloat(t.p)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},ebn=Ro.extend({fn:F(),num_pins:ke(2).default(2),w:F().default("7.0mm"),h:F().default("3.35mm"),pl:F().default("1.50mm"),pw:F().default("2.70mm"),p:F().default("4.8mm")}),tbn=t=>{const e=ebn.parse(t),n=Ho(0,_e.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_e.parse(e.p)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2,y:-_e.parse(e.h)/2},{x:_e.parse(e.p)/2,y:-_e.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:6.8,height:3.2,layer:"top"};return{circuitJson:obn(e).concat(o,n,s),parameters:e}},nbn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},obn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=nbn({pn:n,p:Number.parseFloat(t.p)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},rbn=Ro.extend({fn:F(),num_pins:ke(2).default(2),w:F().default("3.0mm"),h:F().default("1.80mm"),pl:F().default("0.80mm"),pw:F().default("1.20mm"),p:F().default("1.6mm")}),ibn=t=>{const e=rbn.parse(t),n=Ho(0,_e.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_e.parse(e.p)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.1,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.1,y:-_e.parse(e.h)/2},{x:_e.parse(e.p)/2,y:-_e.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:2.9,height:1.7,layer:"top"};return{circuitJson:abn(e).concat(o,n,s),parameters:e}},sbn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},abn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=sbn({pn:n,p:Number.parseFloat(t.p)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},cbn=Ro.extend({fn:F(),num_pins:ke(2).default(2),w:F().default("7.10mm"),h:F().default("3.40mm"),pl:F().default("2.50mm"),pw:F().default("1.80mm"),p:F().default("4.00mm")}),lbn=t=>{const e=cbn.parse(t),n=Ho(0,_e.parse(e.h)/2+.5,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_e.parse(e.p)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.5,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.5,y:-_e.parse(e.h)/2},{x:_e.parse(e.p)/2,y:-_e.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:7,height:3.5,layer:"top"};return{circuitJson:_bn(e).concat(o,n,s),parameters:e}},ubn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},_bn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=ubn({pn:n,p:Number.parseFloat(t.p)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},dbn=Ro.extend({fn:F(),num_pins:ke(2).default(2),w:F().default("4.80mm"),h:F().default("2.10mm"),pl:F().default("1.30mm"),pw:F().default("1.40mm"),p:F().default("2.9mm")}),hbn=t=>{const e=dbn.parse(t),n=Ho(0,_e.parse(e.h)-.5,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_e.parse(e.p)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2,y:-_e.parse(e.h)/2},{x:_e.parse(e.p)/2,y:-_e.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:4.7,height:2.3,layer:"top"};return{circuitJson:pbn(e).concat(o,n,s),parameters:e}},mbn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},pbn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=mbn({pn:n,p:Number.parseFloat(t.p)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},fbn=Ro.extend({fn:F(),num_pins:ke(2).default(2),w:F().default("7.30mm"),h:F().default("4.40mm"),pl:F().default("2.50mm"),pw:F().default("2.30mm"),p:F().default("4.30mm")}),xbn=t=>{const e=fbn.parse(t),n=Ho(0,_e.parse(e.h)/2+.5,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_e.parse(e.p)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.1,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.1,y:-_e.parse(e.h)/2},{x:_e.parse(e.p)/2,y:-_e.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:7.3,height:4.5,layer:"top"};return{circuitJson:ybn(e).concat(o,n,s),parameters:e}},gbn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},ybn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=gbn({pn:n,p:Number.parseFloat(t.p)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},bbn=Ro.extend({fn:F(),num_pins:ke(2).default(2),w:F().default("10.70mm"),h:F().default("6.60mm"),pl:F().default("2.50mm"),pw:F().default("3.30mm"),p:F().default("6.80mm")}),Pbn=t=>{const e=bbn.parse(t),n=Ho(0,3,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_e.parse(e.p)/2,y:_e.parse(e.h)/2-.8},{x:-_e.parse(e.w)/2-.8,y:_e.parse(e.h)/2-.8},{x:-_e.parse(e.w)/2-.8,y:-_e.parse(e.h)/2+.8},{x:_e.parse(e.p)/2,y:-_e.parse(e.h)/2+.8}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:9.8,height:6.7,layer:"top"};return{circuitJson:Sbn(e).concat(o,n,s),parameters:e}},vbn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Sbn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=vbn({pn:n,p:Number.parseFloat(t.p)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Cbn=Ro.extend({fn:F(),num_pins:je().default(4),w:F().default("8.50mm"),h:F().default("6.90mm"),pl:F().default("2mm"),pw:F().default("1.5mm"),p:F().default("2.30mm"),string:F().optional()}),Mbn=t=>{const e=t.string?.match(/^sot223_(\d+)/),n=e?Number.parseInt(e[1],10):4;if(n===8){const r=Ebn.parse({...t,num_pins:n});return{circuitJson:gN(r),parameters:r}}const o=Cbn.parse({...t,num_pins:n});if(o.num_pins===4)return{circuitJson:wbn(o),parameters:o};if(o.num_pins===5)return{circuitJson:Abn(o),parameters:o};if(o.num_pins===6)return{circuitJson:kbn(o),parameters:o};throw new Error("Invalid number of pins")},Tbn=t=>{const{pn:e,w:n,p:o}=t;return e===1?{x:-n/2+1.1,y:o}:e===2?{x:-n/2+1.1,y:0}:e===3?{x:-n/2+1.1,y:-o}:{x:n/2-1.1,y:0}},wbn=t=>{const e=[];let n=0,o=0;for(let h=0;h<t.num_pins;h++){const{x:p,y:x}=Tbn({num_pins:t.num_pins,pn:h+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)}),f=h===3?3.8:Number.parseFloat(t.pw),g=Number.parseFloat(t.pl);n=Math.max(n,Math.abs(p)+g/2),o=Math.max(o,Math.abs(x)+f/2),e.push(lo(h+1,p,x,g,f))}const r=Ho(0,0,.3),i=Number.parseFloat(t.w)/2-2.4,s=Number.parseFloat(t.h)/2,a={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:s},{x:i,y:s},{x:i,y:s/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},c={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-s},{x:i,y:-s},{x:i,y:-s/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},l=Number.parseFloat(t.w)/2,u=Number.parseFloat(t.h)/2,_=Math.max(n+.25,l+.15),d=Math.max(o+.25,u+.15),m={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:2*_,height:2*d,layer:"top"};return[...e,a,c,r,m]},Ebn=p8({p:"0.90mm",w:"2.8mm",legsoutside:!0}),Dbn=t=>{const{p:e,pn:n,w:o}=t;if(n===1)return{x:-o/2+1.2,y:e/2+e};if(n===2)return{x:-o/2+1.2,y:e/2};if(n===3)return{x:-o/2+1.2,y:-e/2};if(n===4)return{x:-o/2+1.2,y:-e/2-e};if(n===5)return{x:o/2-1,y:0};throw new Error("Invalid pin number")},Abn=t=>{const e=[];let n=0,o=0;for(let h=1;h<=t.num_pins;h++){const{x:p,y:x}=Dbn({h:Number.parseFloat(t.h),p:1.5,pn:h,w:Number.parseFloat(t.w)});let f=Number.parseFloat(t.pw),g=Number.parseFloat(t.pl);h===5?(f=3.4,g=1.8):(f=1,g=2.2),n=Math.max(n,Math.abs(p)+g/2),o=Math.max(o,Math.abs(x)+f/2),e.push(lo(h,p,x,g,f))}const r=Number.parseFloat(t.w)/2-2.4,i=Number.parseFloat(t.h)/2,s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-r,y:i},{x:r,y:i},{x:r,y:i/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},a={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-r,y:-i},{x:r,y:-i},{x:r,y:-i/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},c=Ho(0,0,.3),l=Number.parseFloat(t.w)/2,u=Number.parseFloat(t.h)/2,_=Math.max(n+.25,l+.15),d=Math.max(o+.25,u+.15),m={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:2*_,height:2*d,layer:"top"};return[...e,s,a,c,m]},Rbn=t=>{const{p:e,pn:n,w:o}=t;if(n===1)return{x:-o/2+1.2,y:2*e};if(n===2)return{x:-o/2+1.2,y:e};if(n===3)return{x:-o/2+1.2,y:0};if(n===4)return{x:-o/2+1.2,y:-e};if(n===5)return{x:-o/2+1.2,y:-2*e};if(n===6)return{x:o/2-1.175,y:0};throw new Error("Invalid pin number")},kbn=t=>{const e=[];let n=0,o=0;for(let h=1;h<=t.num_pins;h++){const{x:p,y:x}=Rbn({h:Number.parseFloat(t.h),p:1.3,pn:h,w:8.7});let f=Number.parseFloat(t.pw),g=Number.parseFloat(t.pl);h===6?(f=3.4,g=2.15):(f=.6,g=2.2),n=Math.max(n,Math.abs(p)+g/2),o=Math.max(o,Math.abs(x)+f/2),e.push(lo(h,p,x,g,f))}const r=Number.parseFloat(t.w)/2-2.4,i=Number.parseFloat(t.h)/2,s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-r,y:i},{x:r,y:i},{x:r,y:i/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},a={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-r,y:-i},{x:r,y:-i},{x:r,y:-i/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},c=Ho(0,0,.3),l=Number.parseFloat(t.w)/2,u=Number.parseFloat(t.h)/2,_=Math.max(n+.25,l+.15),d=Math.max(o+.25,u+.15),m={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:2*_,height:2*d,layer:"top"};return[...e,s,a,c,m]},Nbn=Ro.extend({fn:F(),num_pins:je().default(3),w:F().default("3.40mm"),h:F().default("3.30mm"),pl:F().default("1mm"),pw:F().default("0.7mm"),p:F().default("1.2mm"),string:F().optional()}),Hbn=t=>{const e=t.string?.match(/^sot23w_(\d+)/),n=e?Number.parseInt(e[1],3):3,o=Nbn.parse({...t,num_pins:n});if(o.num_pins===3)return{circuitJson:Lbn(o),parameters:o};throw new Error("Invalid number of pins")},Ibn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n,y:.95}:e===2?{x:-n,y:-.95}:{x:n,y:0}},Lbn=t=>{const e=[];for(let f=0;f<t.num_pins;f++){const{x:g,y}=Ibn({num_pins:t.num_pins,pn:f+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)});e.push(lo(f+1,g,y,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=Ho(0,Number.parseInt(t.h)/2+1,.3),o=Number.parseFloat(t.w)/2-1,r=Number.parseFloat(t.h)/2,i={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-o,y:r},{x:o+.3,y:r},{x:o+.3,y:r/2}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-o,y:-r},{x:o+.3,y:-r},{x:o+.3,y:-r/2}],type:"pcb_silkscreen_path",stroke_width:.1},a=Number.parseFloat(t.p),c=Number.parseFloat(t.pl),l=Number.parseFloat(t.pw),u=Number.parseFloat(t.h),_=a+c/2,d=.95+l/2,m=u/2,h=_+.25,p=Math.max(d+.25,m+.09),x={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:2*h,height:2*p,layer:"top"};return[...e,i,s,n,x]},Obn=Ro.extend({fn:F(),num_pins:Nn([ke(3),ke(2)]).default(3),p:F().default("1.27mm"),id:F().default("0.72mm"),od:F().default("0.95mm"),w:F().default("2.5mm"),h:F().default("4.2mm"),string:F().optional()}),Fbn=t=>{const{p:e,id:n,od:o,w:r,h:i}=t,s=Number.parseFloat(i)/2,a=Number.parseFloat(e);return[Si(1,-a,s-a,n,o),Si(2,0,s-a,n,o),Si(3,a,s-a,n,o)]},Bbn=t=>{const{p:e,id:n,od:o,h:r}=t,i=Number.parseFloat(r)/2,s=Number.parseFloat(e);return[Si(1,-s,i-s,n,o),Si(2,s,i-s,n,o)]},zbn=t=>{const e=t.string?.match(/^to92s_(\d+)/),n=e?Number.parseInt(e[1],10):3,o=Obn.parse({...t,num_pins:n});let r=[];if(o.num_pins===3)r=Fbn(o);else if(o.num_pins===2)r=Bbn(o);else throw new Error("Invalid number of pins for TO-92");const i=Number.parseFloat(o.h)/2,s=Number.parseFloat(o.p),a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-i,y:i-s},{x:-1.9,y:0},{x:1.9,y:0},{x:i,y:i-s},{x:1.5,y:Number.parseFloat(o.h)/2+.5},{x:-1.5,y:Number.parseFloat(o.h)/2+.5},{x:-i,y:i-s}],stroke_width:.1,pcb_silkscreen_path_id:""},c=Ho(0,i+1,.5),l=Number.parseFloat(o.od),u=i-s,_=-s-l/2,d=s+l/2,m=u-l/2,h=u+l/2,p=-i,x=i,f=0,g=i+.5,y=Math.min(_,p)-.27,b=Math.max(d,x)+.13,v=Math.min(m,f)-.42,S=Math.max(h,g)+.08,M={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:(y+b)/2,y:(v+S)/2},width:b-y,height:S-v,layer:"top"};return{circuitJson:[...r,a,c,M],parameters:o}},Vbn=Ro.extend({fn:F(),p:_e.optional(),id:_e.optional(),pw:_e.optional(),pl:_e.optional(),w:_e.optional(),h:_e.optional(),sh:Be().optional().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".'),zh:Be().optional().describe("JST ZH (Through-hole) connector family. 1.5mm pitch wire-to-board."),string:F().optional()}),$bn=()=>({minX:Number.POSITIVE_INFINITY,maxX:Number.NEGATIVE_INFINITY,minY:Number.POSITIVE_INFINITY,maxY:Number.NEGATIVE_INFINITY}),yN=({bounds:t,centerX:e,centerY:n,width:o,height:r})=>{const i=o/2,s=r/2;t.minX=Math.min(t.minX,e-i),t.maxX=Math.max(t.maxX,e+i),t.minY=Math.min(t.minY,n-s),t.maxY=Math.max(t.maxY,n+s)},Wbn={ph:{p:_e.parse("2.2mm"),id:_e.parse("0.70mm"),pw:_e.parse("1.20mm"),pl:_e.parse("1.20mm"),w:_e.parse("6mm"),h:_e.parse("5mm")},sh:{p:_e.parse("1mm"),pw:_e.parse("0.6mm"),pl:_e.parse("1.55mm"),w:_e.parse("5.8mm"),h:_e.parse("7.8mm")},zh:{p:_e.parse("1.5mm"),id:_e.parse("0.73mm"),pw:_e.parse("1.03mm"),pl:_e.parse("1.73mm"),w:_e.parse("3mm"),h:_e.parse("3.5mm")}};function Ubn(t){return t.sh?"sh":t.ph?"ph":t.zh?"zh":"ph"}function Xbn({variant:t,numPins:e,p:n,id:o,pw:r,pl:i}){const s=[],a=$bn();let c=0;if(t==="ph"){const l=-((e-1)/2)*n;for(let u=0;u<e;u++){const _=l+u*n;s.push(P5({pn:u+1,x:_,y:2,holeDiameter:o,rectPadWidth:r,rectPadHeight:i})),yN({bounds:a,centerX:_,centerY:2,width:r,height:i}),c=Math.max(c,i/2)}}else if(t==="zh"){const l=-((e-1)/2)*n;for(let u=0;u<e;u++){const _=l+u*n;u===0?s.push(P5({pn:u+1,x:_,y:0,holeDiameter:o,rectPadWidth:r,rectPadHeight:i,rectBorderRadius:.12499977})):s.push(g8(u+1,_,0,o,r,i)),yN({bounds:a,centerX:_,centerY:0,width:r,height:i}),c=Math.max(c,i/2)}}else{const l=-((e-1)/2)*n;for(let _=0;_<e;_++){const d=l+_*n;s.push(lo(_+1,d,-1.325,r,i)),yN({bounds:a,centerX:d,centerY:-1.325,width:r,height:i}),c=Math.max(c,i/2)}const u=(e-1)/2*n+1.3;s.push(lo(e+1,-u,1.22,1.2,1.8)),s.push(lo(e+2,u,1.22,1.2,1.8)),yN({bounds:a,centerX:-u,centerY:1.22,width:1.2,height:1.8}),yN({bounds:a,centerX:u,centerY:1.22,width:1.2,height:1.8}),c=Math.max(c,.9)}return{pads:s,padBounds:a,maxPadHalfY:c}}function jbn({variant:t,w:e,h:n,numPins:o,p:r}){if(t==="ph")return{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:""};if(t==="zh"&&o&&r){const i=(o-1)*r,s=-i/2-1.5,a=i/2+1.5,c=-n/2,l=n/2;return{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:s,y:c},{x:a,y:c},{x:a,y:l},{x:s,y:l},{x:s,y:c}],stroke_width:.1,pcb_silkscreen_path_id:""}}else return{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[],stroke_width:.1,pcb_silkscreen_path_id:""}}var Gbn=t=>{const e=Vbn.parse(t),n=Ubn(e),o=Wbn[n],r=e.p??o.p,i=e.id??o.id,s=e.pw??o.pw,a=e.pl??o.pl,c=e.w??o.w,l=e.h??o.h;let u;const _=t.num_pins;typeof _=="number"&&(u=_);const d=typeof t.string=="string"?t.string:"",m=d.match(/(?:^|_)jst(\d+)(?:_|$)/),h=d.match(/(?:^|_)zh(\d+)(?:_|$)/);if(m&&m[1]){const ce=Number.parseInt(m[1],10);Number.isNaN(ce)||(u=ce)}if(h&&h[1]){const ce=Number.parseInt(h[1],10);Number.isNaN(ce)||(u=ce)}if(typeof u!="number")throw new Error(`JST requires an explicit pin count (e.g. jst6_sh or .jst(6))${e.string?`, from string "${e.string}"`:""}`);const p=Xbn({variant:n,numPins:u,p:r,id:i,pw:s,pl:a}),{pads:x,padBounds:f,maxPadHalfY:g}=p,y=jbn({variant:n,w:c,h:l,numPins:u,p:r}),b=Ho(0,l/2+1,.5),v=y.route.map(ce=>ce.x),S=y.route.map(ce=>ce.y),M=v.length>0&&S.length>0,w=M?Math.min(f.minX,Math.min(...v)):f.minX,D=M?Math.max(f.maxX,Math.max(...v)):f.maxX,A=M?Math.min(f.minY,Math.min(...S)):f.minY,I=M?Math.max(f.maxY,Math.max(...S)):f.maxY,H=.5,O=.05,z=g+.085,V=w-H,G=D+H,q=A-z,K=I+O,ne={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:(V+G)/2,y:(q+K)/2},width:G-V,height:K-q,layer:"top"};return{circuitJson:[...x,y,b,ne],parameters:{...e,p:r,id:i,pw:s,pl:a,w:c,h:l,num_pins:u,sh:n==="sh",ph:n==="ph",zh:n==="zh"}}},Ybn=Ro.extend({fn:F(),num_pins:ke(2).default(2),w:F().default("3.30mm"),h:F().default("1.70mm"),pl:F().default("0.80mm"),pw:F().default("1mm"),p:F().default("1.90mm")}),qbn=t=>{const e=Ybn.parse(t),n=Ho(0,_e.parse(e.h)/2+.5,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_e.parse(e.p)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2,y:-_e.parse(e.h)/2},{x:_e.parse(e.p)/2,y:-_e.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:3.2,height:2,layer:"top"};return{circuitJson:Kbn(e).concat(o,n,s),parameters:e}},Jbn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Kbn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=Jbn({pn:n,p:Number.parseFloat(t.p)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Qbn=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"}}},Zbn=Ro.extend({fn:F(),num_pins:Nn([ke(8),ke(10)]).default(8),w:F().optional(),h:F().optional(),p:F().optional(),pl:F().optional(),pw:F().optional(),string:F().optional()}),ePn=t=>{const e=Zbn.parse(t),n=Qbn(e.num_pins),o=_e.parse(e.w||n.w),r=_e.parse(e.h||n.h),i=_e.parse(e.p||n.p),s=_e.parse(e.pl||n.pl),a=_e.parse(e.pw||n.pw),c=[],l=e.num_pins/2;for(let w=0;w<e.num_pins;w++){const{x:D,y:A}=GZe(e.num_pins,w+1,o,i),I=w<l?w+1:e.num_pins-(w-l);c.push(lo(I,D,A,s,a))}const u=o,_=r,d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-u/2,y:_/2},{x:u/2,y:_/2}],stroke_width:.05,pcb_silkscreen_path_id:""},m={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-u/2,y:-_/2},{x:u/2,y:-_/2}],stroke_width:.05,pcb_silkscreen_path_id:""},h=GZe(e.num_pins,1,u,i),p={x:h.x-.8,y:h.y},x={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:p.x-.4,y:p.y},{x:p.x-.7,y:p.y+.3},{x:p.x-.7,y:p.y-.3},{x:p.x-.4,y:p.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},f=Ho(0,_/2+.5,.3),g=(e.num_pins/2-1)*i+a,y=o/2+.25,b=y+1.43,v=g/2+.255,S=r/2+.25,M={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:d2([{minX:-b,maxX:b,minY:-v,maxY:v},{minX:-y,maxX:y,minY:-S,maxY:S}])};return{circuitJson:[...c,d,m,f,x,M],parameters:e}},GZe=(t,e,n,o)=>{const r=t/2,i=(e-1)%r,s=e<=r?-1:1,a=(r-1)/2-i;return{x:s*2.11,y:a*o}},tPn=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"}}},nPn=Ro.extend({fn:F(),num_pins:Nn([ke(8),ke(10),ke(12),ke(16)]).default(8),w:F().optional(),h:F().optional(),p:F().optional(),pl:F().optional(),pw:F().optional(),string:F().optional()}),YZe=(t,e,n,o)=>{const r=t/2,i=(e-1)%r,s=e<=r?-1:1,a=(r-1)/2-i;return{x:s*_e.parse("2mm"),y:a*o}},oPn=t=>{const e=nPn.parse(t),n=tPn(e.num_pins),o=_e.parse(e.w||n.w),r=_e.parse(e.h||n.h),i=_e.parse(e.p||n.p),s=_e.parse(e.pl||n.pl),a=_e.parse(e.pw||n.pw),c=[];for(let M=0;M<e.num_pins;M++){const{x:w,y:D}=YZe(e.num_pins,M+1,o,i);c.push(lo(M+1,w,D,s,a))}const l=o,u=r,_={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-l/2,y:u/2},{x:l/2,y:u/2}],stroke_width:.05,pcb_silkscreen_path_id:""},d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-l/2,y:-u/2},{x:l/2,y:-u/2}],stroke_width:.05,pcb_silkscreen_path_id:""},m=YZe(e.num_pins,1,l,i),h={x:m.x-.8,y:m.y},p={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"},x=Ho(0,u/2+.5,.3),f=(e.num_pins/2-1)*i+a,g=o/2+.25,y=g+1.43,b=f/2+.255,v=r/2+.25,S={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:d2([{minX:-y,maxX:y,minY:-b,maxY:b},{minX:-g,maxX:g,minY:-v,maxY:v}])};return{circuitJson:[...c,_,d,x,p,S],parameters:e}},rPn=Ro.extend({fn:F(),num_pins:ke(2).default(2),w:F().default("3.8mm"),h:F().default("1.65mm"),pl:F().default("1.2mm"),pw:F().default("1.2mm"),pad_spacing:F().default("2.6mm")}),iPn=t=>{const e=rPn.parse(t),n=Ho(0,_e.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_e.parse(e.pad_spacing)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.2,y:-_e.parse(e.h)/2},{x:_e.parse(e.pad_spacing)/2,y:-_e.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:4.3,height:2.15,layer:"top"};return{circuitJson:aPn(e).concat(o,n,s),parameters:e}},sPn=t=>{const{pn:e,pad_spacing:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},aPn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=sPn({pn:n,pad_spacing:Number.parseFloat(t.pad_spacing)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},cPn=Ro.extend({fn:F(),num_pins:ke(2).default(2),w:F().default("3.20mm"),h:F().default("1.65mm"),pl:F().default("0.8mm"),pw:F().default("0.9mm"),pad_spacing:F().default("2.1mm")}),lPn=t=>{const e=cPn.parse(t),n=Ho(0,_e.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_e.parse(e.pad_spacing)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.2,y:-_e.parse(e.h)/2},{x:_e.parse(e.pad_spacing)/2,y:-_e.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:3.7,height:2.15,layer:"top"};return{circuitJson:_Pn(e).concat(o,n,s),parameters:e}},uPn=t=>{const{pn:e,pad_spacing:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},_Pn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=uPn({pn:n,pad_spacing:Number.parseFloat(t.pad_spacing)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},dPn=Ro.extend({fn:F(),num_pins:Nn([ke(6),ke(8)]).default(8),w:F().default("3mm"),h:F().default("3mm"),p:F().default("0.5mm"),pl:F().default("0.52mm"),pw:F().default("0.35mm"),epw:F().default("1.40mm"),eph:F().default("1.60mm"),string:F().optional(),ep:Be().default(!1)}),hPn=t=>{t.string&&t.string.includes("_ep")&&(t.ep=!0);const e=t.string?.match(/^son_(\d+)/),n=e?Number.parseInt(e[1],10):t.num_pins||8,o=dPn.parse({...t,num_pins:n}),r=_e.parse(o.w),i=_e.parse(o.h),s=_e.parse(o.p),a=_e.parse(o.pl),c=_e.parse(o.pw),l=_e.parse(o.epw),u=_e.parse(o.eph),_=[];for(let H=0;H<o.num_pins;H++){const{x:O,y:z}=s1e(o.num_pins,H+1,r,s);_.push(lo(H+1,O,z,a,c))}o.ep&&_.push(lo(o.num_pins+1,0,0,l,u));const d=r,m=i,h={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-d/2,y:m/2},{x:d/2,y:m/2}],stroke_width:.05,pcb_silkscreen_path_id:""},p={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-d/2,y:-m/2},{x:d/2,y:-m/2}],stroke_width:.05,pcb_silkscreen_path_id:""},x=s1e(o.num_pins,1,d,s),f={x:x.x-.4,y:x.y},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:f.x-.4,y:f.y},{x:f.x-.7,y:f.y+.3},{x:f.x-.7,y:f.y-.3},{x:f.x-.4,y:f.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},y=Ho(0,m/2+.5,.3),b=Math.abs(s1e(o.num_pins,1,r,s).x),v=(o.num_pins/2-1)*s+c,S=b*2+a,M=r/2+.25,w=S/2+.25,D=v/2+.25,A=i/2+.25,I={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:d2([{minX:-w,maxX:w,minY:-D,maxY:D},{minX:-M,maxX:M,minY:-A,maxY:A}])};return{circuitJson:[..._,h,p,y,g,I],parameters:o}},s1e=(t,e,n,o)=>{const r=t/2,i=(e-1)%r,s=e<=r?-1:1,a=(r-1)/2-i;return{x:s*_e.parse("1.4mm"),y:a*o}},mPn=Ro.extend({fn:F(),num_pins:je().optional().default(8),p:nt.describe("pitch (distance between center of each pin)"),w:_e.describe("width between vertical rows of pins"),grid:DX.describe("width and height of the border of the footprint"),ep:DX.default("0x0mm").describe("width and height of the central exposed thermal pad"),epx:_e.default("0mm").describe("x offset of the center of the central exposed thermal pad"),pinw:_e.describe("width of the pin pads"),pinh:_e.describe("height of the pin pads")}),pPn=t=>{const e=mPn.parse(t),{num_pins:n,p:o,w:r,grid:i,ep:s,epx:a,pinw:c,pinh:l}=e;if(n%2!==0)throw new Error("invalid number of pins");const u=[];for(let M=0;M<n;M++){const{pinX:w,pinY:D}=fPn({pinCount:n,pinIndex:M,width:r,pitch:o});u.push(lo(M+1,w,D,c,l))}s.x>0&&s.y>0&&u.push(lo(e.num_pins+1,a,0,s.x,s.y));const _=xPn(i),d=Ho(0,i.y/2+o,i.y/6),m=(n/2-1)*o+l,h=r+c,p=i.x/2+.25,x=h/2+.25,f=m/2+.25,g=m/2+.45+Math.max(0,.8-o),y=Math.min(i.y/2+.25,g),b=Math.max(0,.37-Math.max(0,x-p-.38)*1.4),v=Math.max(f,y-b),S={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:d2([{minX:-x,maxX:x,minY:-v,maxY:v},{minX:-p,maxX:p,minY:-y,maxY:y}])};return{circuitJson:[...u,..._,d,S],parameters:e}},fPn=t=>{let e=0,n=0;const o=(t.pinCount/2-1)*t.pitch/2,r=t.pinCount/2;return t.pinIndex+1<=r?(e=t.pitch*t.pinIndex-o,n=0-t.width/2):(e=t.pitch*(t.pinCount-t.pinIndex-1)-o,n=t.width/2),{pinX:n,pinY:e}},xPn=t=>{const n=t.y/30;return[{layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:-t.x/2-.1,y:t.y/2+.1-n},{x:-t.x/2-.1,y:t.y/2+.1},{x:t.x/2+.1,y:t.y/2+.1},{x:t.x/2+.1,y:t.y/2+.1-n}],stroke_width:t.y/30},{layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:-t.x/2-.1,y:-t.y/2-.1+n},{x:-t.x/2-.1,y:-t.y/2-.1},{x:t.x/2+.1,y:-t.y/2-.1},{x:t.x/2+.1,y:-t.y/2-.1+n}],stroke_width:t.y/30}]},gPn=t=>{const{num_pins:e,bridged:n,p:o=2.54,pw:r=1.5,ph:i=1.5}=t,s=_e.parse(o),a=_e.parse(r),c=_e.parse(i),l=Math.min(c/4,.5),u=[];for(let A=0;A<e;A++)u.push(lo(A+1,A*s,0,a,c));let _=[];if(n){const A=n.split("").map(Number);if(A.length>1)for(let I=0;I<A.length-1;I++){const H=A[I],O=A[I+1];if(typeof H=="number"&&typeof O=="number"&&!isNaN(H)&&!isNaN(O)){const z=(H-1)*s,V=(O-1)*s,G=Math.sign(V-z),q=z+G*(a/2),K=V-G*(a/2);_.push({type:"pcb_trace",pcb_trace_id:"",route:[{start_pcb_port_id:`{PIN${H}}`,x:q,y:0,width:l,layer:"top",route_type:"wire"},{end_pcb_port_id:`{PIN${O}}`,x:K,y:0,width:l,layer:"top",route_type:"wire"}]})}}}const d=(e-1)*s+a+.7,m=c+1,h=(e-1)*s/2,p=0,x={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"outline",route:[{x:h-d/2,y:p-m/2},{x:h+d/2,y:p-m/2},{x:h+d/2,y:p+m/2},{x:h-d/2,y:p+m/2},{x:h-d/2,y:p-m/2}],stroke_width:.15},g=p+m/2+.6,y=Ho(h,g,.4),b=(e-1)*s,v=b/2+a/2,S=c/2,M=v+.5,w=S+.5,D={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:b/2,y:0},width:2*M,height:2*w,layer:"top"};return{circuitJson:[...u,..._,x,y,D],parameters:t}},qZe={fn:ke("sot457"),num_pins:ke(6).default(6),pillh:F().default("0.45mm"),pillw:F().default("1.45mm"),pl:F(),pw:F(),p:F(),wave:Be().optional(),reflow:Be().optional()},yPn=Ro.extend({...qZe,h:F().default("2.5mm"),w:F().default("2.7mm"),pl:F().default("0.8mm"),pw:F().default("0.55mm"),p:F().default("0.95mm")}),bPn=Ro.extend({...qZe,h:F().default("3mm"),w:F().default("4mm"),pillr:F().default("0.225mm"),pl:F().default("1.45mm"),pw:F().default("1.5mm"),p:F().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)})),F9=t=>Number.parseFloat(t.replace("mm","")),JZe=({pitch:t,width:e,pinNumber:n})=>{const i={1:{x:-e/2-.1,y:t},2:{x:-e/2-.1,y:0},3:{x:-e/2-.1,y:-t},4:{x:e/2+.1,y:-t},5:{x:e/2+.1,y:0},6:{x:e/2+.1,y:t}}[n];if(!i)throw new Error(`Invalid pin number: ${n}`);return i},KZe=t=>{const e=[],n=F9(t.p),o=F9(t.pl),r=F9(t.pw),i=F9(t.w),s=F9(t.h);if(t.wave){const p={1:({padWidth:x,padHeight:f})=>lo(1,-n,n,f,x),2:({padWidth:x,padHeight:f})=>lo(2,-n,-n,f,x),3:({padWidth:x,padHeight:f})=>AX(3,-n,0,F9(t.pillw),F9(t.pillh)),4:({padWidth:x,padHeight:f})=>AX(4,n,0,F9(t.pillw),F9(t.pillh)),5:({padWidth:x,padHeight:f})=>lo(5,n,n,f,x),6:({padWidth:x,padHeight:f})=>lo(6,n,-n,f,x)};for(let x=1;x<=t.num_pins;x++){const f=p[x];f&&e.push(f({padWidth:o,padHeight:r}))}}else for(let p=1;p<=t.num_pins;p++){const{x,y:f}=JZe({pitch:n,width:i,pinNumber:p});e.push(lo(p,x,f,o,r))}const a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i/3,y:s/2+n/1.3},{x:i/3,y:s/2+n/1.3}],stroke_width:.05},c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i/3,y:-s/2-n/1.3},{x:i/3,y:-s/2-n/1.3}],stroke_width:.05},l=Ho(0,s+.5,.3),u=JZe({pitch:n,width:i,pinNumber:1}),_=t.wave?1:.5,d=t.wave?.7:.3;u.x-=t.wave?r:r*1.7;const m={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:u.x+_/2,y:u.y},{x:u.x-_/2,y:u.y+d/2},{x:u.x-_/2,y:u.y-d/2},{x:u.x+_/2,y:u.y}],stroke_width:.05};let h;if(t.wave){const p=2*n,x=2*n,f=p/2+r/2,g=x/2+o/2,y=f+.25,b=g+.25;h={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:2*y,height:2*b,layer:"top"}}else{const x=i/2+.1+o/2,f=n+r/2,g=i/2,y=s/2,b=x+.25,v=g+.08,S=f+.25,M=Math.max(y+.45,S);h={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:d2([{minX:-b,maxX:b,minY:-S,maxY:S},{minX:-v,maxX:v,minY:-M,maxY:M}]),layer:"top"}}return[l,a,c,m,...e,h]},PPn=t=>{if(t.wave){const n=bPn.parse({...t,fn:"sot457"});return{circuitJson:KZe(n),parameters:n}}const e=yPn.parse(t);return{circuitJson:KZe(e),parameters:e}},vPn=[{x:-.8,y:.75},{x:.8,y:.75},{x:.8,y:-.75},{x:-.8,y:-.75}],SPn=Ro.extend({fn:F(),num_pins:ke(6).default(6),w:F().default("1.1mm"),h:F().default("1.45mm"),p:F().default("0.35mm"),pl:F().default("0.2mm"),pw:F().default("0.2mm"),string:F().optional()}),CPn=t=>{const e=SPn.parse({...t,fn:"sot963"}),n=_e.parse(e.w),o=_e.parse(e.h),r=_e.parse(e.p),i=_e.parse(e.pl),s=_e.parse(e.pw),a=[];for(let h=0;h<6;h++){const{x:p,y:x}=QZe(h+1,n,r,i);a.push(lo(h+1,p,x,i,s))}const c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/2,y:o/2},{x:n/2,y:o/2}],stroke_width:.05,pcb_silkscreen_path_id:""},l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/2,y:-o/2},{x:n/2,y:-o/2}],stroke_width:.05,pcb_silkscreen_path_id:""},u=QZe(1,n,r,i),_={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:u.x-i/2-.3,y:u.y},{x:u.x-i/2-.45,y:u.y+.15},{x:u.x-i/2-.45,y:u.y-.15},{x:u.x-i/2-.3,y:u.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},d=Ho(0,o/2+.4,.25),m={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:vPn,layer:"top"};return{circuitJson:[...a,c,l,d,_,m],parameters:e}},QZe=(t,e,n,o)=>{const r=e/2-o/2;return t<=3?{x:-r,y:n-(t-1)*n}:{x:r,y:-n+(t-4)*n}},MPn=Ro.extend({fn:F(),num_pins:Nn([ke(3),ke(2)]).default(3),p:F().default("3.8mm"),id:F().default("1.25mm"),od:F().default("2.35mm"),ca:F().default("14mm").describe("Caliper axis (width or diameter of the potentiometer body or adjustment knob)"),w:F().default("5.35mm"),h:F().default("4mm"),string:F().optional()}),TPn=t=>{const{p:e,id:n,od:o,h:r,ca:i}=t,s=Number.parseFloat(r),a=Number.parseFloat(i);return[Si(1,0,a/4+.3,n,o),Si(2,s,0,n,o),Si(3,0,-a/4-.3,n,o)]},wPn=t=>{const e=t.string?.match(/^potentiometer_(\d+)/),n=e?Number.parseInt(e[1],10):3,o=MPn.parse({...t,num_pins:n});let r=[];o.num_pins===3&&(r=TPn(o));const i=Number.parseFloat(o.ca)/2+.15,s=Number.parseFloat(o.w),a=Number.parseFloat(o.od)/2+.35,c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:i-1.75},{x:0,y:i},{x:s,y:i},{x:s,y:a}],stroke_width:.1,pcb_silkscreen_path_id:""},l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:s,y:-a},{x:s,y:-i},{x:0,y:-i},{x:0,y:-i+1.75}],stroke_width:.1,pcb_silkscreen_path_id:""},u=Number.parseFloat(o.w)/2,_=Ho(u,i+1,.5),d=Number.parseFloat(o.od)/2,m=Number.parseFloat(o.h),h=Number.parseFloat(o.ca)/2,p=-(d+.25),x=m+d+.25,f=h+.25,g={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:(p+x)/2,y:0},width:x-p,height:2*f,layer:"top"};return{circuitJson:[...r,c,l,_,g],parameters:o}},EPn=Ro.extend({fn:F(),p:_e.optional().default("7.5mm"),id:_e.optional().default("1mm"),od:_e.optional().default("2mm"),d:_e.optional().default("10.5mm")}),DPn=(t,e,n,o,r)=>{const i=[],s=[];for(let a=0;a<=50;a++){const c=a/50*Math.PI,l=t+Math.cos(c)*n,u=e+Math.sin(c)*n;l<t-o&&u>=e-r/2&&u<=e+r/2||i.push({x:l,y:u})}for(let a=0;a<=50;a++){const c=Math.PI+a/50*Math.PI,l=t+Math.cos(c)*n,u=e+Math.sin(c)*n;l<t-o&&u>=e-r/2&&u<=e+r/2||s.push({x:l,y:u})}return{topArc:i,bottomArc:s}},APn=t=>{const e=EPn.parse(t),{p:n,id:o,od:r,d:i}=e,s=[Si(1,-n/2,0,o,r),Si(2,n/2,0,o,r)],{topArc:a,bottomArc:c}=DPn(0,0,i/2+.1,r/2,r),l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:a,stroke_width:.1,pcb_silkscreen_path_id:""},u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:c,stroke_width:.1,pcb_silkscreen_path_id:""},_={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:i/2+.1},{x:0,y:-(i/2+.1)}],stroke_width:.1,pcb_silkscreen_path_id:""},d=-(i/2+.5),m=r/2+1.5,h=.5,p={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:d-h,y:m},{x:d+h,y:m}],stroke_width:.1,pcb_silkscreen_path_id:""},x={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:d,y:m-h},{x:d,y:m+h}],stroke_width:.1,pcb_silkscreen_path_id:""},f=Ho(0,i/2+1,.5),g=i/2,y=n/2+r/2,v=Math.max(g,y)+.25,S={type:"pcb_courtyard_circle",pcb_courtyard_circle_id:"",pcb_component_id:"",center:{x:0,y:0},radius:v,layer:"top"};return{circuitJson:[...s,l,u,_,p,x,f,S],parameters:e}},RPn=Ro.extend({fn:F(),num_pins:ke(2).default(2),w:F().default("6.5mm"),h:F().default("3mm"),pl:F().default("1.75mm"),pw:F().default("2.40mm"),p:F().default("4.75mm")}),kPn=t=>{const e=RPn.parse(t),n=Ho(0,_e.parse(e.h)-.5,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_e.parse(e.p)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.3,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.3,y:-_e.parse(e.h)/2},{x:_e.parse(e.p)/2,y:-_e.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:7,height:3.5,layer:"top"};return{circuitJson:HPn(e).concat(o,n,s),parameters:e}},NPn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},HPn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=NPn({pn:n,p:Number.parseFloat(t.p)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},IPn=[{x:-1.45,y:.98},{x:-.73,y:.98},{x:-.73,y:1.1},{x:.73,y:1.1},{x:.73,y:.33},{x:1.45,y:.33},{x:1.45,y:-.33},{x:.73,y:-.33},{x:.73,y:-1.1},{x:-.73,y:-1.1},{x:-.73,y:-.98},{x:-1.45,y:-.98},{x:-1.45,y:-.32},{x:-.73,y:-.32},{x:-.73,y:.32},{x:-1.45,y:.32}],LPn=Ro.extend({fn:F(),num_pins:je().default(3),w:F().default("2.45mm"),h:F().default("2.40mm"),pl:F().default("0.92mm"),pw:F().default("0.45mm"),p:F().default("0.891mm"),string:F().optional()}),OPn=t=>{const e=t.string?.match(/^sot323_(\d+)/),n=e?Number.parseInt(e[1],3):3,o=LPn.parse({...t,num_pins:n});if(o.num_pins===3)return{circuitJson:BPn(o),parameters:o};throw new Error("Invalid number of pins")},FPn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n,y:.65}:e===2?{x:-n,y:-.65}:{x:n,y:0}},BPn=t=>{const e=[];for(let c=0;c<t.num_pins;c++){const{x:l,y:u}=FPn({num_pins:t.num_pins,pn:c+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)});e.push(lo(c+1,l,u,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=Ho(0,Number.parseInt(t.h)/2+1,.3),o=Number.parseFloat(t.w)/2-Number.parseFloat(t.pl),r=Number.parseFloat(t.h)/2,i={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-o,y:r+.3},{x:o,y:r+.3},{x:o,y:r/2}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-o,y:-r-.3},{x:o,y:-r-.3},{x:o,y:-r/2}],type:"pcb_silkscreen_path",stroke_width:.1},a={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:IPn,layer:"top"};return[...e,i,s,n,a]},zPn=Ro.extend({fn:F(),circle:Be().optional(),rect:Be().optional(),square:Be().optional(),pill:Be().optional(),d:_e.optional(),pd:_e.optional(),diameter:_e.optional(),r:_e.optional(),pr:_e.optional(),radius:_e.optional(),w:_e.optional(),pw:_e.optional(),width:_e.optional(),h:_e.optional(),ph:_e.optional(),height:_e.optional(),s:_e.optional(),size:_e.optional(),string:F().optional()}).transform(t=>{let e="rect";t.circle&&(e="circle"),t.square&&(e="square"),t.rect&&(e="rect"),t.pill&&(e="pill");let n,o,r;return e==="circle"?t.r!==void 0?n=Xs(t.r):t.pr!==void 0?n=Xs(t.pr):t.radius!==void 0?n=Xs(t.radius):t.d!==void 0?n=Xs(t.d)/2:t.pd!==void 0?n=Xs(t.pd)/2:t.diameter!==void 0?n=Xs(t.diameter)/2:n=Xs("1mm")/2:(t.w!==void 0?o=Xs(t.w):t.pw!==void 0?o=Xs(t.pw):t.width!==void 0?o=Xs(t.width):t.s!==void 0?o=Xs(t.s):t.size!==void 0?o=Xs(t.size):o=Xs("1mm"),t.h!==void 0?r=Xs(t.h):t.ph!==void 0?r=Xs(t.ph):t.height!==void 0?r=Xs(t.height):e==="square"||e==="rect"?r=o:r=Xs("1mm")),{fn:t.fn,shape:e,radius:n,width:o,height:r}}),VPn=t=>{const e=zPn.parse(t),{shape:n,radius:o,width:r,height:i}=e;let s,a;return n==="circle"?(s=RZe(1,{x:0,y:0,radius:o}),a=o+.5):n==="pill"?(s=AX(1,0,0,r,i),a=Math.max(r,i)/2+.5):(s=lo(1,0,0,r,i),a=i/2+.5),{circuitJson:[s,Ho(0,a,.2)],parameters:e}},$Pn=Ro.extend({fn:F(),d:_e.optional(),hd:_e.optional(),r:_e.optional(),hr:_e.optional(),pd:_e.optional(),pr:_e.optional(),squarepad:Be().optional().default(!1)}).transform(t=>{let e;t.d!==void 0?e=Xs(t.d):t.hd!==void 0?e=Xs(t.hd):t.r!==void 0?e=Xs(t.r)*2:t.hr!==void 0?e=Xs(t.hr)*2:e=Xs("1mm");let n;return t.pd!==void 0?n=Xs(t.pd):t.pr!==void 0?n=Xs(t.pr)*2:n=e*(1.5/1),{fn:t.fn,d:e,pd:n,squarepad:t.squarepad??!1}}),WPn=t=>{const e=$Pn.parse(t),{d:n,pd:o,squarepad:r}=e;return{circuitJson:[r?P5({pn:1,x:0,y:0,holeDiameter:n,rectPadWidth:o,rectPadHeight:o}):Si(1,0,0,n,o),Ho(0,o/2+.5,.2)],parameters:e}},UPn=Ro.extend({fn:F(),num_pins:ke(6).default(6),h:F().default("1.6mm"),pl:F().default("1mm"),pw:F().default("0.7mm"),p:F().default("0.95mm")}),XPn=t=>{const e=UPn.parse(t);return{circuitJson:jPn(e),parameters:e}},ZZe=t=>{const{p:e,h:n,pn:o}=t;if(o===1)return{x:-n/2-.5,y:e};if(o===2)return{x:-n/2-.5,y:0};if(o===3)return{x:-n/2-.5,y:-e};if(o===4)return{x:n/2+.5,y:-e};if(o===5)return{x:n/2+.5,y:0};if(o===6)return{x:n/2+.5,y:e};throw new Error("Invalid pin number")},jPn=t=>{const e=[];for(let M=1;M<=t.num_pins;M++){const{x:w,y:D}=ZZe({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:M});e.push(lo(M,w,D,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=t.num_pins/2*Number.parseFloat(t.p),o=Number.parseFloat(t.h),r={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-n/3,y:o/2+Number.parseFloat(t.p)/1.3},{x:n/3,y:o/2+Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},i={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-n/3,y:-o/2-Number.parseFloat(t.p)/1.3},{x:n/3,y:-o/2-Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},s=Ho(0,o+.3,.3),a=ZZe({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:1});a.x=a.x-Number.parseFloat(t.pw)*1.5;const c=.7,l=.3,u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:a.x+c/2,y:a.y},{x:a.x-c/2,y:a.y+l/2},{x:a.x-c/2,y:a.y-l/2},{x:a.x+c/2,y:a.y}],stroke_width:.05},_=Number.parseFloat(t.h),d=Number.parseFloat(t.p),m=Number.parseFloat(t.pl),h=Number.parseFloat(t.pw),p=_/2+.5,x=d*2+h,f=p+m/2,g=_/2+.25,y=f+.25,b=x/2+.2,v=b+.2,S={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:d2([{minX:-y,maxX:y,minY:-b,maxY:b},{minX:-g,maxX:g,minY:-v,maxY:v}])};return[...e,s,r,i,u,S]},GPn=[{x:-1.703,y:.98},{x:-.983,y:.98},{x:-.983,y:1.1},{x:.477,y:1.1},{x:.477,y:.98},{x:1.197,y:.98},{x:1.197,y:-.98},{x:.477,y:-.98},{x:.477,y:-1.1},{x:-.983,y:-1.1},{x:-.983,y:-.98},{x:-1.703,y:-.98}],YPn=Ro.extend({fn:F(),num_pins:je().default(4),w:F().default("3.2mm"),h:F().default("2.6mm"),pl:F().default("1.05mm"),pw:F().default("0.45mm"),p:F().default("0.55mm"),string:F().optional()}),qPn=t=>{const e=t.string?.match(/^sot343_(\d+)/),n=e?Number.parseInt(e[1],4):4,o=YPn.parse({...t,num_pins:n});if(o.num_pins===4)return{circuitJson:KPn(o),parameters:o};throw new Error("Invalid number of pins")},JPn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n*1.92,y:-.65}:e===2?{x:-n*1.92,y:.65}:e===3?{x:n,y:.65}:e===4?{x:n,y:-.65}:{x:0,y:0}},KPn=t=>{const e=[],n=Number.parseFloat(t.w),o=Number.parseFloat(t.h),r=Number.parseFloat(t.pl),i=Number.parseFloat(t.pw),s=Number.parseFloat(t.p);let a=1/0,c=-1/0,l=1/0,u=-1/0;for(let b=0;b<t.num_pins;b++){const{x:v,y:S}=JPn({num_pins:t.num_pins,pn:b+1,p:s});e.push(lo(b+1,v,S,r,i)),v<a&&(a=v),v>c&&(c=v),S<l&&(l=S),S>u&&(u=S)}const _=(a+c)/2,d=u-l,m=o*.3,h=d/2+m;let p=n*.8;o<=2.6&&(p/=2);const x=Ho(_,h+.5,.3),f={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_top",route:[{x:_-p/2,y:h},{x:_+p/2,y:h}],type:"pcb_silkscreen_path",stroke_width:.1},g={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_bottom",route:[{x:_-p/2,y:-h},{x:_+p/2,y:-h}],type:"pcb_silkscreen_path",stroke_width:.1},y={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:GPn,layer:"top"};return[...e,f,g,x,y]},QPn=Ro.extend({fn:F()}),ZPn=t=>{const e=QPn.parse(t),n=[],o=.5-.15,r=1.5,s=.5/2,a=75,c=-37/2;for(let M=0;M<a;M++){const w=M+1;if(w>=24&&w<=31)continue;const D=c-M*s,A=w%2===0,I=r+(A?.25:0),O=.5-I/2,z=lo(w,O,D,I,o);z.layer=A?"bottom":"top",n.push(z)}const l=46*.0254,u=137*.0254,_=261*.0254,d={type:"pcb_cutout",pcb_cutout_id:"",shape:"rect",center:{x:-u/2+r/2,y:c-_},width:u,height:l},m={x:-.5,y:c},h={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:m.x-.4,y:m.y},{x:m.x-.7,y:m.y+.3},{x:m.x-.7,y:m.y-.3},{x:m.x-.4,y:m.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"};let p=1/0,x=-1/0,f=1/0,g=-1/0;const y=(M,w,D=0,A=0)=>{p=Math.min(p,M-D/2),x=Math.max(x,M+D/2),f=Math.min(f,w-A/2),g=Math.max(g,w+A/2)};for(const M of n){const w=M;y(w.x,w.y,w.width,w.height)}y(d.center.x,d.center.y,d.width,d.height);for(const M of h.route)y(M.x,M.y);const b=(p+x)/2,v=(f+g)/2,S=M=>{typeof M.x=="number"&&(M.x-=b),typeof M.y=="number"&&(M.y-=v),M.center&&(M.center.x-=b,M.center.y-=v),Array.isArray(M.route)&&(M.route=M.route.map(w=>({x:w.x-b,y:w.y-v})))};for(const M of n)S(M);return S(d),S(h),{circuitJson:[...n,d,h],parameters:e}},evn=Ro.extend({fn:F(),numPins:je().optional().default(0),rows:Nn([F(),je()]).transform(t=>Number(t)).optional().default(1).describe("number of rows"),p:_e.default("2.54mm").describe("pitch"),id:_e.default("1.0mm").describe("inner diameter"),od:_e.default("1.5mm").describe("outer diameter"),male:Be().optional().describe("the module uses male headers"),nopin:Be().optional().default(!1).describe("omit pins rendering"),female:Be().optional().describe("the module uses female headers"),smd:Be().optional().describe("surface mount device"),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),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"),pinRowSide:Kt(["left","right","top","bottom"]).optional().default("left"),pinrowleft:Be().optional().default(!1),pinrowright:Be().optional().default(!1),pinrowtop:Be().optional().default(!1),pinrowbottom:Be().optional().default(!1),pinrowleftpins:Nn([F(),je()]).transform(t=>Number(t)).optional(),pinrowrightpins:Nn([F(),je()]).transform(t=>Number(t)).optional(),pinrowtoppins:Nn([F(),je()]).transform(t=>Number(t)).optional(),pinrowbottompins:Nn([F(),je()]).transform(t=>Number(t)).optional(),width:_e.optional(),height:_e.optional(),pinRowHoleEdgeToEdgeDist:_e.default("2mm"),holes:Nn([F(),Pt(F())]).optional().transform(t=>!t||Array.isArray(t)?t:t.startsWith("(")&&t.endsWith(")")?t.slice(1,-1).split(",").map(e=>e.trim()):[t]),holeXDist:_e.optional(),holeYDist:_e.optional(),holeInset:_e.default("1mm"),pinrow:Nn([F(),je()]).optional(),usbposition:Kt(["left","right","top","bottom"]).optional().default("left"),usbleft:Be().optional().default(!1),usbtop:Be().optional().default(!1),usbright:Be().optional().default(!1),usbbottom:Be().optional().default(!1),usbtype:Kt(["micro","c"]).optional(),usbmicro:Be().optional().default(!1),usbc:Be().optional().default(!1),screen:Be().optional().default(!1).describe("add silkscreen outline for screen/display area"),screenwidth:_e.optional(),screenheight:_e.optional(),screencenteroffsetx:_e.optional(),screencenteroffsety:_e.optional()}).transform(t=>{const e=zZe(t);let n=t.pinRowSide;t.pinrowleft&&(n="left"),t.pinrowright&&(n="right"),t.pinrowtop&&(n="top"),t.pinrowbottom&&(n="bottom");let o=t.usbposition;t.usbleft&&(o="left"),t.usbtop&&(o="top"),t.usbright&&(o="right"),t.usbbottom&&(o="bottom");let r=t.usbtype;t.usbmicro&&(r="micro"),t.usbc&&(r="c"),t.pinrow!==void 0&&(t.numPins=Number(t.pinrow));const i={left:t.pinrowleftpins,right:t.pinrowrightpins,top:t.pinrowtoppins,bottom:t.pinrowbottompins},s=Object.values(i).some(b=>b!==void 0&&b>0),a=(i.left??0)>0&&(i.right??0)>0,c=(i.top??0)>0&&(i.bottom??0)>0;s&&((i.left??0)>0?n="left":(i.right??0)>0?n="right":(i.top??0)>0?n="top":(i.bottom??0)>0&&(n="bottom"),t.numPins=(i.left??0)+(i.right??0)+(i.top??0)+(i.bottom??0));const l=Math.ceil(t.numPins/t.rows),u=Math.max(i.left??0,i.right??0),_=Math.max(i.top??0,i.bottom??0);let d,m;if(s){const b=a?t.p:0,v=c?t.p:0;d=(_>0?(_-1)*t.p:0)+2*t.pinRowHoleEdgeToEdgeDist+b,m=(u>0?(u-1)*t.p:0)+2*t.pinRowHoleEdgeToEdgeDist+v}else n==="left"||n==="right"?(d=(t.rows-1)*t.p+2*t.pinRowHoleEdgeToEdgeDist,m=(l-1)*t.p+2*t.pinRowHoleEdgeToEdgeDist):(m=(t.rows-1)*t.p+2*t.pinRowHoleEdgeToEdgeDist,d=(l-1)*t.p+2*t.pinRowHoleEdgeToEdgeDist);t.numPins===0&&(d=10,m=10);const h=t.width??d,p=t.height??m,x=t.screenwidth??h*.95,f=t.screenheight??p*.95,g=t.screencenteroffsetx??0,y=t.screencenteroffsety??0;return{...t,pinlabelAnchorSide:e,pinRowSide:n,usbposition:o,usbtype:r,male:t.male??!t.female,female:t.female??!1,width:h,height:p,screenwidth:x,screenheight:f,screencenteroffsetx:g,screencenteroffsety:y,pinrowleftpins:i.left,pinrowrightpins:i.right,pinrowtoppins:i.top,pinrowbottompins:i.bottom}}).superRefine((t,e)=>{t.male&&t.female&&e.addIssue({code:Jn.custom,message:"'male' and 'female' cannot both be true; it should be male or female.",path:["male","female"]})}),tvn=t=>{const e=evn.parse(t),{p:n,id:o,od:r,rows:i,numPins:s,pinlabelAnchorSide:a,pinlabelverticallyinverted:c,pinlabelorthogonal:l,pinlabeltextalignleft:u,pinlabeltextalignright:_,nopinlabels:d,doublesidedpinlabel:m,bottomsidepinlabel:h,pinRowSide:p,width:x,height:f,pinRowHoleEdgeToEdgeDist:g,holes:y,holeXDist:b,holeYDist:v,holeInset:S,pinrowleftpins:M,pinrowrightpins:w,pinrowtoppins:D,pinrowbottompins:A,usbposition:I,usbtype:H,screen:O,screenwidth:z,screenheight:V,screencenteroffsetx:G,screencenteroffsety:q}=e;let K="center";u?K="left":_&&(K="right");const ne=[],ce={left:M,right:w,top:D,bottom:A},ee=Object.values(ce).some(ae=>ae!==void 0&&ae>0),oe=(ae,de,be,Ce)=>{if(e.smd?ne.push(lo(ae,de,be,e.od,e.od)):ae===1?ne.push(P5({pn:ae,x:de,y:be,holeDiameter:o,rectPadWidth:r,rectPadHeight:r})):ne.push(Si(ae,de,be,o,r)),!d){const De=de+(Ce==="left"?-r:Ce==="right"?r:0),pe=be+(Ce==="top"?r:Ce==="bottom"?-r:0);h||ne.push(f8({fs:r/5,pn:ae,anchor_x:De,anchor_y:pe,textalign:K,orthogonal:l,verticallyinverted:c,layer:"top"})),(m||h)&&ne.push(f8({fs:r/5,pn:ae,anchor_x:De,anchor_y:pe,textalign:K,orthogonal:l,verticallyinverted:c,layer:"bottom"}))}};if(ee){const ae=n;let de=1;const be=ce.left??0,Ce=ce.right??0,De=ce.top??0,pe=ce.bottom??0,Me=(xe,We)=>{if(!(We<=0))if(xe==="left"||xe==="right"){const Xe=xe==="left"?-x/2+g:x/2-g,Je=(We-1)/2*ae;for(let fe=0;fe<We;fe++)oe(de,Xe,Je-fe*ae,xe),de++}else{const Xe=xe==="top"?f/2-g:-f/2+g,Je=-((We-1)/2)*ae;for(let fe=0;fe<We;fe++)oe(de,Je+fe*ae,Xe,xe),de++}};Me("left",be),Me("right",Ce),Me("top",De),Me("bottom",pe)}else{const ae=n;let de=0,be=0,Ce=0,De=0,pe=0,Me=0;const xe=Math.ceil(s/i);p==="left"||p==="right"?(de=p==="left"?-x/2+g:x/2-g,be=(xe-1)/2*ae,Ce=0,De=-ae,pe=p==="left"?ae:-ae,Me=0):(de=-(xe-1)/2*ae,be=p==="top"?f/2-g:-f/2+g,Ce=ae,De=0,pe=0,Me=p==="top"?-ae:ae);let We=1;for(let Xe=0;Xe<i&&We<=s;Xe++)for(let Je=0;Je<xe&&We<=s;Je++){const fe=de+Je*Ce+Xe*pe,Ye=be+Je*De+Xe*Me;if(e.smd?ne.push(lo(We,fe,Ye,e.od,e.od)):We===1?ne.push(P5({pn:We,x:fe,y:Ye,holeDiameter:o,rectPadWidth:r,rectPadHeight:r})):ne.push(Si(We,fe,Ye,o,r)),!d){const Oe=fe+(p==="left"?-r:p==="right"?r:0),Ne=Ye+(p==="top"?r:p==="bottom"?-r:0);h||ne.push(f8({fs:r/5,pn:We,anchor_x:Oe,anchor_y:Ne,textalign:K,orthogonal:l,verticallyinverted:c,layer:"top"})),(m||h)&&ne.push(f8({fs:r/5,pn:We,anchor_x:Oe,anchor_y:Ne,textalign:K,orthogonal:l,verticallyinverted:c,layer:"bottom"}))}We++}}if(y)for(const ae of y){let de=0,be=0;ae==="topleft"?(de=-x/2+S,be=f/2-S):ae==="topright"?(de=x/2-S,be=f/2-S):ae==="bottomleft"?(de=-x/2+S,be=-f/2+S):ae==="bottomright"?(de=x/2-S,be=-f/2+S):ae==="center"&&(de=0,be=0),b!==void 0&&(de+=b),v!==void 0&&(be+=v),ne.push(Si(s+y.indexOf(ae)+1,de,be,o,r))}if(!e.nosilkscreen){const ae=[{x:-x/2,y:-f/2},{x:x/2,y:-f/2},{x:x/2,y:f/2},{x:-x/2,y:f/2},{x:-x/2,y:-f/2}];ne.push(x8(ae,{stroke_width:.1,layer:"top"}))}const ie=Ho(0,f/2+1,.5);if(ne.push(ie),I&&H){let ae,de;if(H==="c")ae=8,de=3;else if(H==="micro")ae=6,de=2;else return{circuitJson:ne,parameters:e};let be;if(I==="left")be=[{x:-x/2,y:-ae/2},{x:-x/2+de,y:-ae/2},{x:-x/2+de,y:ae/2},{x:-x/2,y:ae/2},{x:-x/2,y:-ae/2}];else if(I==="right")be=[{x:x/2-de,y:-ae/2},{x:x/2,y:-ae/2},{x:x/2,y:ae/2},{x:x/2-de,y:ae/2},{x:x/2-de,y:-ae/2}];else if(I==="top")be=[{x:-ae/2,y:f/2-de},{x:ae/2,y:f/2-de},{x:ae/2,y:f/2},{x:-ae/2,y:f/2},{x:-ae/2,y:f/2-de}];else if(I==="bottom")be=[{x:-ae/2,y:-f/2},{x:ae/2,y:-f/2},{x:ae/2,y:-f/2+de},{x:-ae/2,y:-f/2+de},{x:-ae/2,y:-f/2}];else return{circuitJson:ne,parameters:e};ne.push(x8(be,{stroke_width:.1,layer:"top"}))}if(O){const ae=z/2,de=V/2,be=G,Ce=q,De=[{x:-ae+be,y:-de+Ce},{x:ae+be,y:-de+Ce},{x:ae+be,y:de+Ce},{x:-ae+be,y:de+Ce},{x:-ae+be,y:-de+Ce}];ne.push(x8(De,{stroke_width:.05,layer:"top"}))}return{circuitJson:ne,parameters:e}},nvn=[{x:-1.45,y:2.75},{x:-1.45,y:-1.85},{x:4.05,y:-1.85},{x:4.05,y:2.75}],ovn=[{x:-1.55,y:2.75},{x:-1.55,y:-1.85},{x:3.95,y:-1.85},{x:3.95,y:2.75}],rvn=Ro.extend({fn:F(),num_pins:je().default(3),inline:Be().default(!1),p:F().default("1.27mm"),id:F().default("0.75mm"),od:F().default("1.3mm"),w:F().default("4.8mm"),h:F().default("4.0mm")}),ivn=t=>{const e=rvn.parse(t),n=Number.parseFloat(e.p),o=Number.parseFloat(e.w),r=Number.parseFloat(e.h),i=e.inline?1.05:Number.parseFloat(e.od),s=e.inline?1.5:i,a=[P5({pn:1,x:0,y:0,holeDiameter:e.id,rectPadWidth:i,rectPadHeight:s}),e.inline?g8(2,n,0,Number.parseFloat(e.id),i,s):Si(2,n,n,e.id,i),e.inline?g8(3,n*2,0,Number.parseFloat(e.id),i,s):Si(3,n*2,0,e.id,i)],c=o/2,l=e.inline?n-.09:n,u=.2,_=u+c-r,d=Array.from({length:32},(x,f)=>{const g=Math.PI*f/31;return{x:l+c*Math.cos(g),y:u+c*Math.sin(g)}}),m={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",stroke_width:.12,route:[...d,{x:l-c,y:_},{x:l+c,y:_},d[0]]},h=Ho(l,u+c+1,.5),p={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:e.inline?ovn:nvn,layer:"top"};return{circuitJson:[...a,m,h,p],parameters:e}},svn=(t,e)=>{const n=t.filter(o=>o.type==="pcb_silkscreen_text");if(n.length===0)return t;for(const o of n)e.norefdes&&(o.text="");return t},avn=(t,e)=>e.nosilkscreen?t.filter(n=>n.type!=="pcb_silkscreen_path"&&n.type!=="pcb_silkscreen_text"):t,cvn=(t,e)=>{if(!e)return t;const n=t.filter(u=>u.type==="pcb_smtpad"||u.type==="pcb_plated_hole");if(n.length===0)return t;let o=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY;const a=(u,_,d=0,m=0)=>{const h=u-d/2,p=u+d/2,x=_-m/2,f=_+m/2;o=Math.min(o,h),r=Math.max(r,p),i=Math.min(i,x),s=Math.max(s,f)};for(const u of n)if(u.type==="pcb_smtpad"){const _=u.shape==="circle"?u.radius*2:u.width,d=u.shape==="circle"?u.radius*2:u.height;a(u.x,u.y,_,d)}else if(u.type==="pcb_plated_hole"){const _=u.outer_diameter??u.hole_diameter;a(u.x,u.y,_,_)}let c=0,l=0;switch(e){case"center":c=(o+r)/2,l=(i+s)/2;break;case"bottomleft":c=o,l=i;break;case"bottomcenter":case"centerbottom":c=(o+r)/2,l=i;break;case"topcenter":case"centertop":c=(o+r)/2,l=s;break;case"leftcenter":case"centerleft":c=o,l=(i+s)/2;break;case"rightcenter":case"centerright":c=r,l=(i+s)/2;break;case"pin1":{const u=n.find(_=>_.port_hints?.[0]==="1")||n[0];c=u.x,l=u.y;break}}if(c===0&&l===0)return t;for(const u of t){if(typeof u.x=="number"&&(u.x-=c),typeof u.y=="number"&&(u.y-=l),u.center&&typeof u.center.x=="number"&&(u.center.x-=c,u.center.y-=l),u.type==="pcb_silkscreen_path")for(const _ of u.route)_.x-=c,_.y-=l;u.type==="pcb_silkscreen_text"&&u.anchor_position&&(u.anchor_position.x-=c,u.anchor_position.y-=l)}return t};function lvn(t){return t!=null}var uvn=t=>t.trim().replace(/^sot23-(\d+)(?=_|$)/i,"sot23_$1").replace(/^sot-223-(\d+)(?=_|$)/i,"sot223_$1").replace(/^to-220f-(\d+)(?=_|$)/i,"to220f_$1").replace(/^jst_(ph|sh|zh)_(\d+)(?=_|$)/i,"jst$2_$1"),_vn=t=>{let e=NX();const n=uvn(t),r=n.replace(/^((?:\d{4}|\d{5}))(?=$|_|x)/,"res$1").replace(/^zh(\d+)(?:$|_)/,"jst$1_zh").split(/_(?!metric)/).map(i=>{const s=i.match(/([a-zA-Z]+)([\(\d\.\+\?].*)?/);if(!s)return null;const[,a,c]=s;if(!a)return null;const l=a.toLowerCase();return c?.includes("?")?null:{fn:l,v:c}}).filter(lvn);for(const{fn:i,v:s}of r)e=e[i](s);return e.setString(n),e},dvn=()=>Object.keys(O9),NX=()=>{const t=new Proxy({},{get:(e,n)=>{if(n==="soup"||n==="circuitJson"){if("fn"in e&&O9[e.fn])return()=>{const{circuitJson:o}=O9[e.fn](e),r=avn(o,e),i=svn(r,e);return cvn(i,e.origin)};if(!O9[e.fn])throw new Error(`Invalid footprint function, got "${e.fn}"${e.string?`, from string "${e.string}"`:""}`);return()=>{throw new Error(`No function found for footprinter, make sure to specify .dip, .lr, .p, etc. Got "${n}"`)}}if(n==="json"){if(!O9[e.fn])throw new Error(`Invalid footprint function, got "${e.fn}"${e.string?`, from string "${e.string}"`:""}`);return()=>O9[e.fn](e).parameters}return n==="getFootprintNames"?()=>Object.keys(O9):n==="params"?()=>e:n==="setString"?o=>(e.string=o,t):o=>(Object.keys(e).length===0?`${n}${o}`in O9?(e[`${n}${o}`]=!0,e.fn=`${n}${o}`):(e[n]=!0,e.fn=n,n==="res"||n==="cap"?o&&(typeof o=="string"&&o.includes("_metric")?e.metric=o.split("_metric")[0]:e.imperial=o):e.num_pins=Number.isNaN(Number.parseFloat(o))?void 0:Number.parseFloat(o)):!o&&["w","h","p"].includes(n)||(e[n]=o??!0),t)}});return t};NX.string=_vn,NX.getFootprintNames=dvn;var hvn=NX,eet=Symbol("Fragment");function a1e(t,e,...n){const o=n.length?n:e?.children!==void 0?[e.children]:[],r=[],i=(Array.isArray(o)?o:[o]).flat(1/0);for(const s of i)s==null||s===!1||(Array.isArray(s)?r.push(...s):r.push(s));return{type:t,props:(e&&e.children!==void 0?{...e,children:void 0}:e)||{},children:r}}var hn=Symbol("Cuboid"),tet=Symbol("Cube"),__=Symbol("Cylinder"),HX=Symbol("Sphere"),bN=Symbol("RoundedCuboid"),Uo=Symbol("Translate"),Cd=Symbol("Rotate"),lm=Symbol("Union"),v5=Symbol("Subtract"),Kl=Symbol("Hull"),fi=Symbol("Colorize"),PN=Symbol("Polygon"),vN=Symbol("ExtrudeLinear"),Lx=Symbol("RoundedCylinder"),Hr=eet,Ge=(t,e,n)=>a1e(t,e),Un=(t,e,n)=>a1e(t,e),z_=({center:t,width:e,length:n,height:o,heightAboveSurface:r=.15,color:i="#555",taperRatio:s=.12,faceRatio:a=.75,straightHeightRatio:c=.5,includeNotch:l=!0,notchRadius:u,notchPosition:_,notchRotation:d=[0,0,0],notchLength:m=.5,notchWidth:h=.25,chamferSize:p=0})=>{const x=o*c,f=o-x,g=Math.min(e,n)*s,y=Math.max(e-g,e*a),b=Math.max(n-g,n*a),v=Math.min(e,n)*.12,S=u??v,M={x:0,y:n/2-S*.25,z:o},w=_??M,D=Un(lm,{children:[Un(Kl,{children:[Ge(Uo,{z:.005,children:Ge(hn,{size:[y,b,.01]})}),Ge(Uo,{z:x,children:Ge(hn,{size:[e,n,.01]})})]}),Un(Kl,{children:[Ge(Uo,{z:x,children:Ge(hn,{size:[e,n,.01]})}),Ge(Uo,{z:x+f,children:Ge(hn,{size:[y,b,.01]})})]})]}),A=(H,O)=>Ge(Uo,{offset:{x:H,y:O,z:0},children:Ge(Cd,{rotation:[0,0,Math.PI/4],children:Ge(hn,{size:[p*Math.SQRT2,p*Math.SQRT2,o*3]})})});let I=D;if(p>0){const H=e/2,O=n/2;I=Un(v5,{children:[D,A(H,O),A(-H,O),A(H,-O),A(-H,-O)]})}return Ge(fi,{color:i,children:Ge(Uo,{offset:t,children:Ge(Uo,{offset:{x:0,y:0,z:r},children:l?Un(v5,{children:[I,Ge(Uo,{offset:w,children:Ge(Cd,{rotation:d,children:Ge(__,{radius:S,height:h})})})]}):I})})})},mvn=t=>Array.from({length:t},(e,n)=>n);function c1e(t,e){if(t.length<2)throw new Error("Stroke must have at least two points");const n=Array.isArray(t[0])?t.map(([u,_])=>({x:u,y:_})):t,o=e/2,r=[],i=[];function s(u,_){const d=_.x-u.x,m=_.y-u.y,h=Math.sqrt(d*d+m*m);return{x:-m/h,y:d/h}}function a(u,_,d){const m={x:u.x+_.x*o*d,y:u.y+_.y*o*d};d>0?r.push(m):i.unshift(m)}const c=s(n[0],n[1]);a(n[0],c,1),a(n[0],c,-1);for(let u=1;u<n.length-1;u++){const _=n[u-1],d=n[u],m=n[u+1],h=s(_,d),p=s(d,m),x=h.x+p.x,f=h.y+p.y,g=Math.sqrt(x*x+f*f);if(g/2>2*o)a(d,h,1),a(d,p,1),a(d,h,-1),a(d,p,-1);else{const b=1/g;a(d,{x:x*b,y:f*b},1),a(d,{x:x*b,y:f*b},-1)}}const l=s(n[n.length-2],n[n.length-1]);return a(n[n.length-1],l,1),a(n[n.length-1],l,-1),[...r,...i]}var pvn=t=>{const e=Math.min(...t.map(a=>a.x)),n=Math.max(...t.map(a=>a.x)),o=Math.min(...t.map(a=>a.y)),s=5.47/(Math.max(...t.map(a=>a.y))-o);return t.map(a=>({x:(a.x-e-(n-e)/2)*s,y:(a.y-o)*s}))},fvn=pvn([{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}]),net=5.47,IX=.5,xvn=({x:t,y:e,z:n})=>{const o=t>0;return Un(Hr,{children:[Ge(Uo,{offset:{x:t+.25/2,y:e,z:n},children:Ge(Cd,{rotation:["-90deg",0,"90deg"],children:Ge(vN,{height:.25,children:Ge(PN,{points:fvn.slice().reverse().map(r=>[r.x,r.y])})})})}),Ge(Uo,{offset:{x:t,y:e+(o?1:-1),z:n},children:Ge(Cd,{rotation:["-90deg","90deg",o?"180deg":"0deg"],children:Ge(vN,{height:2,children:Ge(PN,{points:c1e([[0,0],[-1,0],[-1,-1]],.25).map(r=>[r.x,r.y])})})})})]})},gvn=({numPins:t=8,pitch:e=2.54,bodyWidth:n=6.4,rowSpacing:o})=>{const r=Math.floor(t/2),i=o??(n>=7?n:n+1.22),s=n>=7?i-1.22:n;return Un(Hr,{children:[mvn(t).map(a=>{const c=a%r,l=(Math.floor(a/r)-.5)*2;return Ge(xvn,{x:l*i/2,y:c*e-(r-1)/2*e,z:net/2+IX})}),Ge(z_,{width:s,length:r*e+.5,height:net-IX,heightAboveSurface:IX,center:{x:0,y:0,z:IX}})]})};function yvn(t,{height:e,padContactLength:n,curveLength:o,bodyDistance:r,steepness:i=10}){o||(o=r*.3);let s=r-n-o;s<0&&(o+=s,s=0);const a=n*.75,c=n+o+(r-n-o)*.25;if(t<=a)return 0;if(t>=c)return e;const l=(t-a)/(c-a);return e/(1+Math.exp(-i*(l-.5)))}var Kr=t=>{const{thickness:e,width:n,padContactLength:o,bodyDistance:r,height:i,rotation:s}=t,a=15,c=Array.from({length:a}).map((u,_)=>_/(a-1)*r).map(u=>[u,yvn(u,t)]),l=c1e(c,e);return Ge(fi,{color:"#fff",children:Ge(Uo,{offset:{z:0,y:0,x:0,...t.position},children:Ge(Cd,{rotation:["90deg",0,s??0],children:Ge(Uo,{offset:{x:0,y:0,z:-n/2},children:Ge(vN,{height:n,children:Ge(PN,{points:l.map(u=>[u.x,u.y])})})})})})})},bvn=({pinCount:t,leadLength:e,leadWidth:n,pitch:o,bodyWidth:r})=>{const i=Math.ceil(t/2),s=o*t/2+n/2,a=(i-1)*o/2,c=.25;return Un(Hr,{children:[Array.from({length:i}).map((l,u)=>Ge(Kr,{position:{x:-r/2-e,y:u*o-a,z:c/2},width:n,thickness:c,padContactLength:e,bodyDistance:e+1,height:.8})),Array.from({length:i}).map((l,u)=>Ge(Kr,{rotation:Math.PI,position:{x:r/2+e,y:u*o-a,z:c/2},width:n,thickness:c,padContactLength:e,bodyDistance:e+1,height:.8})),Ge(z_,{center:{x:0,y:0,z:c/2},width:r-n-1,length:s,height:1.5})]})},Pvn=({pinCount:t,padContactLength:e=.4,leadWidth:n=.2,pitch:o=.65,bodyWidth:r=3})=>{const i=Math.ceil(t/2),s=(i-1)*o/2,a=.2;return Un(Hr,{children:[Array.from({length:i}).map((c,l)=>Ge(Kr,{position:{x:-r/2-e-.3,y:l*o-s,z:a/2},width:n,thickness:a,padContactLength:e,bodyDistance:e+.4,height:.6})),Array.from({length:i}).map((c,l)=>Ge(Kr,{rotation:Math.PI,position:{x:r/2+e+.3,y:l*o-s,z:a/2},width:n,thickness:a,padContactLength:e,bodyDistance:e+.4,height:.6})),Ge(z_,{center:{x:0,y:0,z:a/2},width:r,length:r,height:1.1,notchRadius:.35,heightAboveSurface:.1,taperRatio:.09})]})},l1e=1,u1e=.5,Kw=.5,SN=.2,vvn=l1e-SN*2,oet=({color:t="#333"})=>Un(Hr,{children:[Ge(hn,{size:[vvn,u1e,Kw],offset:[0,0,Kw/2],color:t}),Ge(hn,{size:[SN,Kw,u1e],offset:[l1e/2-SN/2,0,Kw/2],color:"#ccc"}),Ge(hn,{size:[SN,Kw,u1e],offset:[-l1e/2+SN/2,0,Kw/2],color:"#ccc"})]}),_1e=1.6,Svn=_1e-.3*2,LX=.3,d1e=.85,Qw=.6,ret=({color:t="#333"})=>Un(Hr,{children:[Ge(hn,{size:[Svn,d1e,Qw],offset:[0,0,Qw/2],color:t}),Ge(hn,{size:[LX,d1e,Qw],offset:[_1e/2-LX/2,0,Qw/2],color:"#ccc"}),Ge(hn,{size:[LX,d1e,Qw],offset:[-_1e/2+LX/2,0,Qw/2],color:"#ccc"})]}),h1e=2,m1e=1.25,Zw=.55,CN=.5,Cvn=h1e-CN*2,iet=({color:t="#333"})=>Un(Hr,{children:[Ge(hn,{size:[Cvn,m1e,Zw],offset:[0,0,Zw/2],color:t}),Ge(hn,{size:[CN,m1e,Zw],offset:[h1e/2-CN/2,0,Zw/2],color:"#ccc"}),Ge(hn,{size:[CN,m1e,Zw],offset:[-h1e/2+CN/2,0,Zw/2],color:"#ccc"})]}),Mvn=({pinCount:t,pitch:e,leadWidth:n,padContactLength:o,bodyWidth:r})=>{const i=t/4;e||(e=Tvn(t,r)),o||(o=wvn(t)),n||(n=Evn(t,r)),r||(r=e*(i+4));const s=r,a=(i-1)*e/2,c=s+2*o,l=c,u=.8,_=.15,d=(l-r)/2+.5;return Un(Hr,{children:[Array.from({length:i}).map((m,h)=>Ge(Kr,{position:{x:-l/2-.4,y:h*e-a,z:_/2},width:n,thickness:_,padContactLength:o,bodyDistance:d,height:u})),Array.from({length:i}).map((m,h)=>Ge(Kr,{rotation:Math.PI,position:{x:l/2+.4,y:h*e-a,z:_/2},width:n,thickness:_,padContactLength:o,bodyDistance:d,height:u})),Array.from({length:i}).map((m,h)=>Ge(Kr,{rotation:Math.PI/2,position:{x:h*e-a,y:-c/2-.4,z:_/2},width:n,thickness:_,padContactLength:o,bodyDistance:d,height:u})),Array.from({length:i}).map((m,h)=>Ge(Kr,{rotation:-Math.PI/2,position:{x:h*e-a,y:c/2+.4,z:_/2},width:n,thickness:_,padContactLength:o,bodyDistance:d,height:u})),Ge(z_,{center:{x:0,y:0,z:0},width:r,length:s,height:1.5,taperRatio:.03,chamferSize:.7,notchPosition:{x:-(s/2-1.5),y:r/2-1.5,z:1.5},notchRadius:1.5/2})]})},Tvn=(t,e)=>{switch(t){case 44:case 64:return .8;case 52:return e===14?1:.65;case 208:return .5;default:return .5}},wvn=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}},Evn=(t,e)=>{switch(t){case 44:case 64:return .5;case 52:return e===14?.45:.55;case 208:return .3;default:return .25}},set=({x:t,y:e,pinThickness:n,shortSidePinLength:o,longSidePinLength:r,bodyHeight:i,bodyLength:s=2.54,bodyWidth:a=2.54,flipZ:c,faceup:l,smd:u,rightangle:_})=>Un(Hr,{children:[Ge(Uo,{y:_?-3:0,children:Ge(hn,{color:"#222",size:[s,a,i],center:[t,e,c(i/2)]})}),!l&&Ge(fi,{color:"gold",children:u?Ge(Kr,{rotation:-Math.PI/2,position:{x:t,y:e+1,z:n/2},thickness:n,width:n,height:n,padContactLength:2,bodyDistance:3}):Un(Kl,{children:[Ge(hn,{color:"gold",size:[n,n,o*.9],center:[t,e,c(i*.9+i/2)]}),Ge(hn,{color:"gold",size:[n/1.8,n/1.8,o],center:[t,e,c(i+i/2)]})]})}),Ge(fi,{color:"gold",children:Ge(Uo,{y:_?-3.9:0,z:_?1:0,children:Ge(Cd,{rotation:_?[-Math.PI/2,0,0]:[0,0,0],children:Un(Kl,{children:[Ge(hn,{color:"gold",size:[n,n,r*.9],center:[t,e,c(-r/2*.9)]}),Ge(hn,{color:"gold",size:[n/1.8,n/1.8,r],center:[t,e,c(-r/2)]})]})})})})]}),Dvn=({numberOfPins:t,pitch:e=2.54,longSidePinLength:n=6,invert:o,faceup:r,rows:i=1,smd:s,rightangle:a})=>{const u=Math.ceil(t/i),_=2.54,d=3,m=-((u-1)/2)*e,h=!s&&!a?-2-1.6:0,p=x=>(o||r?-x+2:x)+h;return Ge(Hr,{children:Array.from({length:t},(x,f)=>{const g=Math.floor(f/u),y=f%u,b=m+y*e,v=-g*_;return Ge(set,{x:b,y:v,pinThickness:.63,shortSidePinLength:d,longSidePinLength:n,bodyHeight:2,flipZ:p,faceup:r,smd:s,rightangle:a},f)})})},Avn=t=>{const e=["left","bottom","right","top"],{pin_count:n,pn:o,w:r,h:i,p:s,pl:a}=t,c=n/4,l=e[Math.floor((o-1)/c)],u=(o-1)%c,_=s*(c-1),d=s*(c-1),m=-a/2;switch(l){case"left":return{x:-r/2-m,y:d/2-u*s,o:"vert"};case"bottom":return{x:-_/2+u*s,y:-i/2-m,o:"horz"};case"right":return{x:r/2+m,y:-d/2+u*s,o:"vert"};case"top":return{x:_/2-u*s,y:i/2+m,o:"horz"};default:throw new Error("Invalid pin number")}},Rvn=({num_pins:t,cw:e,ccw:n,startingpin:o})=>{const r=[],i=t/4;let s=1;const a={};for(const c of o??[])a[c]=!0;!a.leftside&&!a.topside&&!a.rightside&&!a.bottomside&&(a.leftside=!0),!a.bottompin&&!a.leftpin&&!a.rightpin&&!a.toppin&&(a.leftside?a.toppin=!0:a.topside?a.rightpin=!0:a.rightside?a.bottompin=!0:a.bottomside&&(a.leftpin=!0)),a.leftside&&a.toppin?s=1:a.leftside&&a.bottompin?s=i:a.bottomside&&a.leftpin?s=i+1:a.bottomside&&a.rightpin?s=i*2:a.rightside&&a.bottompin?s=i*2+1:a.rightside&&a.toppin?s=i*3:a.topside&&a.rightpin?s=i*3+1:a.topside&&a.leftpin&&(s=i*4),r.push(-1);for(let c=0;c<t;c++)r[s]=c+1,s++,s>t&&(s=1);return r},kvn=({num_pins:t=16,bodyWidth:e=9,bodyLength:n=9,bodyThickness:o=.8,thermalPadSize:r,padWidth:i=.25,padLength:s=.25,pitch:a=.5,thermalPadThickness:c=.05})=>{const l=Rvn({num_pins:t,cw:!0,ccw:!0}),u=[];for(let _=0;_<t;_++){const{x:d,y:m,o:h}=Avn({pin_count:t,pn:_+1,w:e,h:n,p:a,pl:s});let p=i,x=s;h==="vert"&&([p,x]=[x,p]);const f=l[_+1];u.push({pn:f,x:d,y:m,pw:p,pl:x})}return Un(Hr,{children:[Ge(fi,{color:"grey",children:Ge(hn,{center:{x:0,y:0,z:o/2},size:[e,n,o]})}),u.map((_,d)=>Ge(hn,{center:{x:_.x,y:_.y,z:c/2},size:[_.pw,_.pl,c]})),r?.length!==void 0&&r?.width!==void 0&&Ge(hn,{center:{x:0,y:0,z:c/2},size:[r.width,r.length,c]})]})},Nvn=kvn,Hvn=()=>{const c=1.1999999999999997;return Un(Hr,{children:[Ge(Kr,{rotation:Math.PI,position:{x:2.8/2+c/4,y:-1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),Ge(Kr,{rotation:Math.PI,position:{x:2.8/2+c/4,y:1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),Ge(Kr,{position:{x:-2.8/2-c/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),Ge(Kr,{position:{x:-2.8/2-c/4,y:-1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),Ge(Kr,{position:{x:-2.8/2-c/4,y:1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),Ge(z_,{center:{x:0,y:0,z:0},width:1.6,length:2.9,height:1.2})]})},Ivn=Hvn,Lvn=({fullWidth:t=2.9,fullLength:e=2.8})=>{const u=(t-1.92)/2+.3;return Un(Hr,{children:[Ge(Kr,{rotation:Math.PI,position:{x:t/2,y:0,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:u,height:.45}),Ge(Kr,{position:{x:-t/2,y:-.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:u,height:.45}),Ge(Kr,{position:{x:-t/2,y:.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:u,height:.45}),Ge(z_,{center:{x:0,y:0,z:0},width:1.92,length:2.9,height:1.1,straightHeightRatio:.45,heightAboveSurface:.05})]})},p1e=.6,f1e=.3,eE=.33,MN=.1,Ovn=p1e-MN*2,aet=({color:t="#333"})=>Un(Hr,{children:[Ge(hn,{size:[Ovn,f1e,eE],offset:[0,0,eE/2],color:t}),Ge(hn,{size:[MN,f1e,eE],offset:[p1e/2-MN/2,0,eE/2],color:"#ccc"}),Ge(hn,{size:[MN,f1e,eE],offset:[-p1e/2+MN/2,0,eE/2],color:"#ccc"})]}),x1e=.4,g1e=.2,tE=.13,TN=.07,Fvn=x1e-TN*2,cet=({color:t="#333"})=>Un(Hr,{children:[Ge(hn,{size:[Fvn,g1e,tE],offset:[0,0,tE/2],color:t}),Ge(hn,{size:[TN,g1e,tE],offset:[x1e/2-TN/2,0,tE/2],color:"#ccc"}),Ge(hn,{size:[TN,g1e,tE],offset:[-x1e/2+TN/2,0,tE/2],color:"#ccc"})]}),y1e=3.2,b1e=1.6,nE=.9,wN=.5,Bvn=y1e-wN*2,uet=({color:t="#333"})=>Un(Hr,{children:[Ge(hn,{size:[Bvn,b1e,nE],offset:[0,0,nE/2],color:t}),Ge(hn,{size:[wN,b1e,nE],offset:[y1e/2-wN/2,0,nE/2],color:"#ccc"}),Ge(hn,{size:[wN,b1e,nE],offset:[-y1e/2+wN/2,0,nE/2],color:"#ccc"})]}),P1e=3.2,v1e=2.5,oE=1,EN=.6,zvn=P1e-EN*2,_et=({color:t="#333"})=>Un(Hr,{children:[Ge(hn,{size:[zvn,v1e,oE],offset:[0,0,oE/2],color:t}),Ge(hn,{size:[EN,v1e,oE],offset:[P1e/2-EN/2,0,oE/2],color:"#ccc"}),Ge(hn,{size:[EN,v1e,oE],offset:[-P1e/2+EN/2,0,oE/2],color:"#ccc"})]}),S1e=5,C1e=2.5,rE=1.4,DN=.6,Vvn=S1e-DN*2,det=({color:t="#333"})=>Un(Hr,{children:[Ge(hn,{size:[Vvn,C1e,rE],offset:[0,0,rE/2],color:t}),Ge(hn,{size:[DN,C1e,rE],offset:[S1e/2-DN/2,0,rE/2],color:"#ccc"}),Ge(hn,{size:[DN,C1e,rE],offset:[-S1e/2+DN/2,0,rE/2],color:"#ccc"})]}),M1e=6.3,T1e=3.2,iE=1.8,AN=.8,$vn=M1e-AN*2,het=({color:t="#333"})=>Un(Hr,{children:[Ge(hn,{size:[$vn,T1e,iE],offset:[0,0,iE/2],color:t}),Ge(hn,{size:[AN,T1e,iE],offset:[M1e/2-AN/2,0,iE/2],color:"#ccc"}),Ge(hn,{size:[AN,T1e,iE],offset:[-M1e/2+AN/2,0,iE/2],color:"#ccc"})]}),met=({x:t,y:e,z:n=0,pitch:o=2.54,legsLength:r=3,innerDiameter:i=.945,bodyHeight:s=5,bodyLength:a=o,bodyWidth:c=o,flipZ:l})=>{const u=i/1.5,_=u*1.6;return Un(Hr,{children:[Ge(fi,{color:"#1a1a1a",children:Un(v5,{children:[Ge(hn,{color:"#000",size:[a,c,s],center:[t,e,l(n+s/2)]}),i?Ge(__,{height:s+.1,radius:i/2,center:[t,e,l(n+s/2)],color:"#222"}):Ge(hn,{size:[_,_,s],center:[t,e,l(n+s/2)]})]})}),Un(fi,{color:"silver",children:[Un(Kl,{children:[Ge(hn,{color:"silver",size:[u,u,r*.9],center:[t,e,l(n+-r/2*.9)]}),Ge(hn,{color:"silver",size:[u/1.8,u/1.8,r],center:[t,e,l(n+-r/2)]})]}),Ge(hn,{color:"silver",size:[_,_,_*.5],center:[t,e,l(n+_/2*.5)]})]})]})},Wvn=({numberOfPins:t,pitch:e=2.54,legsLength:n=3,innerDiameter:o=.945,rows:r=1,invert:i})=>{const a=Math.ceil(t/r),c=2.54,l=-((a-1)/2)*e,u=_=>i?-_+5:_;return Ge(Hr,{children:Array.from({length:t},(_,d)=>{const m=Math.floor(d/a),h=d%a,p=l+h*e,x=-m*c;return Ge(met,{x:p,y:x,pitch:e,legsLength:n,innerDiameter:o,flipZ:u},d)})})},Uvn=({width:t,length:e,innerDiameter:n=1})=>{const o=t,r=e,i=t*.7,s=n/2.5;return Un(Hr,{children:[Ge(bN,{color:"#1a1a1f",center:[0,0,i/2],size:[r,r,i],roundRadius:.3}),Ge(bN,{color:"#f2f2f2",center:[0,0,i+i*.1/2.5],size:[r,r,i*.1],roundRadius:.14}),Ge(__,{color:"#1a1a1f",height:i*.8,radius:o/3,center:[0,0,i+i*.8/2]}),Ge(__,{color:"#1a1a1f",height:i*.2,radius:n/2,center:[r/3,r/3,i+i*.1/2]}),Ge(__,{color:"#1a1a1f",height:i*.2,radius:n/2,center:[-r/3,-r/3,i+i*.1/2]}),Ge(__,{color:"#1a1a1f",height:i*.2,radius:n/2,center:[-r/3,r/3,i+i*.1/2]}),Ge(__,{color:"#1a1a1f",height:i*.2,radius:n/2,center:[r/3,-r/3,i+i*.1/2]}),Ge(OX,{thickness:n/3,width:s,horizontalLength:r*.8,verticalLength:i/2,position:{x:-o/2,y:-r/2,z:-i*1.2}}),Ge(OX,{thickness:n/3,width:s,horizontalLength:r*.8,verticalLength:i/2,position:{x:-o/2,y:r/2,z:-i*1.2},rotation:Math.PI}),Ge(OX,{thickness:n/3,width:s,horizontalLength:r*.8,verticalLength:i/2,position:{x:o/2,y:r/2,z:-i*1.2},rotation:Math.PI}),Ge(OX,{thickness:n/3,width:s,horizontalLength:r*.8,verticalLength:i/2,position:{x:o/2+n/3.6,y:-r/2,z:-i*1.2}})]})},OX=t=>{const{thickness:e,width:n,horizontalLength:o,verticalLength:r,rotation:i=0,position:s}=t,a=[[0,o],[-r/3,o/3],[-r/5,o/4],[0,0]],c=c1e(a,e);return Ge(fi,{color:"#f2f2f2",children:Ge(Uo,{offset:{x:s?.x||0,y:s?.y||0,z:s?.z||0},children:Ge(Cd,{rotation:[0,55,i],children:Ge(vN,{height:n,children:Ge(PN,{points:c.map(l=>[l.y,l.x])})})})})})},Xvn=({pinCount:t,leadLength:e,leadWidth:n,pitch:o,bodyWidth:r})=>{const i=Math.ceil(t/2),s=(i-1)*o/2,a=.25,c=1,l=.8,u=e*0,_=o*(i-1)+n+.2,d=r*.55;return Un(Hr,{children:[Array.from({length:i}).map((m,h)=>Ge(Kr,{position:{x:-r/2-u,y:h*o-s,z:a/2},width:n,thickness:a,padContactLength:e/2,bodyDistance:e+.3,height:l})),Array.from({length:i}).map((m,h)=>Ge(Kr,{rotation:Math.PI,position:{x:r/2+u,y:h*o-s,z:a/2},width:n,thickness:a,padContactLength:e/2,bodyDistance:e+.3,height:l})),Ge(z_,{center:{x:0,y:0,z:a/2},width:d,length:_,height:c})]})},jvn=({pinCount:t,pitch:e,leadWidth:n,leadLength:o,bodyWidth:r,bodyLength:i})=>{const s=t===8?{pitch:.65,leadWidth:.3}:{pitch:.5,leadWidth:.225},a=isNaN(parseFloat(e))?s.pitch:parseFloat(e),c=isNaN(parseFloat(n))?s.leadWidth:parseFloat(n)*.8,l=isNaN(parseFloat(r))?2.6:parseFloat(r)*.8,u=isNaN(parseFloat(i))?2+Number(a)*1.4:parseFloat(i),_=t/2,d=(_-1)*a/2,m=.15,h=.8,p=4.5,x=(p-l)/2,f=x*.5;return Un(Hr,{children:[Array.from({length:_}).map((g,y)=>Ge(Kr,{position:{x:-p/2,y:d-y*a,z:m/2},width:c,thickness:m,padContactLength:f+.05,bodyDistance:x+.1,height:h})),Array.from({length:_}).map((g,y)=>Ge(Kr,{rotation:Math.PI,position:{x:p/2,y:d-y*a,z:m/2},width:c,thickness:m,padContactLength:f+.05,bodyDistance:x+.1,height:h})),Ge(z_,{center:{x:0,y:0,z:m/2},width:l,length:u,height:1})]})},Gvn=()=>Un(Hr,{children:[Ge(hn,{color:"#ccc",size:[.5,.6,.12],center:[-.725,0,.12/2]}),Ge(hn,{color:"#ccc",size:[.5,.6,.12],center:[.725,0,.12/2]}),Ge(fi,{color:"#222",children:Un(lm,{children:[Ge(Uo,{z:.3/2,children:Ge(hn,{size:[1.65,.8,.3]})}),Un(Kl,{children:[Ge(Uo,{z:.3,children:Ge(hn,{size:[1.65,.8,.01]})}),Ge(Uo,{z:.6,children:Ge(hn,{size:[1.65-.2,.8-.2,.01]})})]})]})})]}),Yvn=()=>Un(Hr,{children:[Ge(hn,{color:"#ccc",size:[.26,.51,.12],center:[-.325,0,.12/2]}),Ge(hn,{color:"#ccc",size:[.26,.51,.12],center:[.325,0,.12/2]}),Ge(fi,{color:"#222",children:Ge(Uo,{z:.47/2+.02,children:Ge(hn,{size:[.98,.58,.47]})})}),Ge(hn,{color:"#ccc",size:[.98+.001,.26/2,.26/4],center:[0,.26/2,.47/4]}),Ge(hn,{color:"#ccc",size:[.98+.001,.26/2,.26/4],center:[0,-.26/2,.47/4]}),Ge(hn,{color:"#ccc",size:[.26/1.5,.58+.001,.26/4],center:[.65/2,0,.47/4]}),Ge(hn,{color:"#ccc",size:[.26/1.5,.58+.001,.26/4],center:[-.65/2,0,.47/4]})]}),qvn=()=>{const l=Ge(fi,{color:"#1a1a1a",children:Un(lm,{children:[Un(Kl,{children:[Ge(Uo,{z:.13,children:Ge(hn,{size:[4,3,.03]})}),Ge(Uo,{z:1.15,children:Ge(hn,{size:[4.4,3.4,.01]})})]}),Un(Kl,{children:[Ge(Uo,{z:1.15,children:Ge(hn,{size:[4.4,3.4,.01]})}),Ge(Uo,{z:2.3,children:Ge(hn,{size:[4,3,.01]})})]})]})}),u=({xDir:_})=>{const h=_*1.78,p=_*(3.4/2-.2/2+1),x=_*(3.4/2-.2/2),f=Math.abs(x-p),g=(p+x)/2;return Ge(fi,{color:"#c0c0c0",children:Un(lm,{children:[Ge(hn,{size:[2.3*.8,1.45,.2],center:[h,0,.2/2]}),Ge(hn,{size:[.2,1.45,1.14],center:[p,0,1.14/2+.2]}),Ge(hn,{size:[f,1.45,.2],center:[g,0,.2/2+1.14]})]})})};return Un(Hr,{children:[Ge(u,{xDir:1}),Ge(u,{xDir:-1}),l]})},Jvn=()=>{const l=Ge(fi,{color:"#1a1a1a",children:Un(lm,{children:[Un(Kl,{children:[Ge(Uo,{z:.13,children:Ge(hn,{size:[4,3,.03]})}),Ge(Uo,{z:1.15,children:Ge(hn,{size:[4.4,3.4,.01]})})]}),Un(Kl,{children:[Ge(Uo,{z:1.15,children:Ge(hn,{size:[4.4,3.4,.01]})}),Ge(Uo,{z:2.3,children:Ge(hn,{size:[4,3,.01]})})]})]})}),u=({xDir:_})=>{const h=_*1.78,p=_*(3.4/2-.2/2+1),x=_*(3.4/2-.2/2),f=Math.abs(x-p),g=(p+x)/2;return Ge(fi,{color:"#c0c0c0",children:Un(lm,{children:[Ge(hn,{size:[2.3*.8,1.45,.2],center:[h,0,.2/2]}),Ge(hn,{size:[.2,1.45,1.14],center:[p,0,1.14/2+.2]}),Ge(hn,{size:[f,1.45,.2],center:[g,0,.2/2+1.14]})]})})};return Un(Hr,{children:[Ge(u,{xDir:1}),Ge(u,{xDir:-1}),l]})},Kvn=()=>{const l=Ge(fi,{color:"#1a1a1a",children:Un(lm,{children:[Un(Kl,{children:[Ge(Uo,{z:.21000000000000002,children:Ge(hn,{size:[6.3999999999999995,5.6,.03]})}),Ge(Uo,{z:1.15,children:Ge(hn,{size:[6.8,6,.01]})})]}),Un(Kl,{children:[Ge(Uo,{z:1.15,children:Ge(hn,{size:[6.8,6,.01]})}),Ge(Uo,{z:2.3,children:Ge(hn,{size:[6.3999999999999995,5.6,.01]})})]})]})}),u=({xDir:_})=>{const h=_*3.08,p=_*(6/2-.2/2+1),x=_*(6/2-.2/2),f=Math.abs(x-p),g=(p+x)/2;return Ge(fi,{color:"#c0c0c0",children:Un(lm,{children:[Ge(hn,{size:[2.3*.8,2.95,.2],center:[h,0,.2/2]}),Ge(hn,{size:[.2,2.95,1.14],center:[p,0,1.14/2+.2]}),Ge(hn,{size:[f,2.95,.2],center:[g,0,.2/2+1.14]})]})})};return Un(Hr,{children:[Ge(u,{xDir:1}),Ge(u,{xDir:-1}),l]})},Qvn=()=>{const _=Ge(fi,{color:"#222",children:Un(lm,{children:[Ge(Uo,{z:.27,children:Ge(hn,{size:[2.9,1.9,.54]})}),Un(Kl,{children:[Ge(Uo,{z:.54,children:Ge(hn,{size:[2.9,1.9,.01]})}),Ge(Uo,{z:1.08,children:Ge(hn,{size:[2.6999999999999997,1.7,.01]})})]})]})});return Un(Hr,{children:[Ge(hn,{color:"#ccc",size:[1,1.2,.25],center:[-1.3,0,.25/2]}),Ge(hn,{color:"#ccc",size:[1,1.2,.25],center:[1.3,0,.25/2]}),_]})},Zvn=()=>Un(Hr,{children:[Ge(hn,{color:"#ccc",size:[1,.6,.12],center:[-1.3,0,.12/2]}),Ge(hn,{color:"#ccc",size:[1,.6,.12],center:[1.3,0,.12/2]}),Ge(fi,{color:"#222",children:Un(lm,{children:[Ge(Uo,{z:.55/2,children:Ge(hn,{size:[2.7,1.6,.55]})}),Un(Kl,{children:[Ge(Uo,{z:.55,children:Ge(hn,{size:[2.7,1.6,.01]})}),Ge(Uo,{z:1.1,children:Ge(hn,{size:[2.7-.2,1.6-.2,.01]})})]})]})})]}),e7n=()=>Un(Hr,{children:[Ge(hn,{color:"#ccc",size:[1,.9,.2],center:[-1.3,0,.2/2]}),Ge(hn,{color:"#ccc",size:[1,.9,.2],center:[1.3,0,.2/2]}),Ge(fi,{color:"#222",children:Un(lm,{children:[Ge(Uo,{z:.2/2,children:Ge(hn,{size:[2.75,1.8,.2]})}),Un(Kl,{children:[Ge(Uo,{z:.2,children:Ge(hn,{size:[2.75,1.8,.01]})}),Ge(Uo,{z:1,children:Ge(hn,{size:[2.75-.4,1.8-.4,.01]})})]})]})}),Ge(hn,{color:"#777",size:[.2,1.8-.4,.01],center:[-1.3+.4,0,1]})]}),t7n=()=>Un(Hr,{children:[Ge(hn,{color:"#ccc",size:[.9,.9,.2],center:[-1.225,0,.2/2]}),Ge(hn,{color:"#ccc",size:[.9,.9,.2],center:[1.225,0,.2/2]}),Ge(fi,{color:"#222",children:Un(lm,{children:[Un(Kl,{children:[Ge(Uo,{z:.2,children:Ge(hn,{size:[2.6-.1/2,1.7-.1/2,.01]})}),Ge(Uo,{z:.01,children:Ge(hn,{size:[2.6-.1,1.7-.1,.01]})})]}),Un(Kl,{children:[Ge(Uo,{z:.2,children:Ge(hn,{size:[2.6,1.7,.01]})}),Ge(Uo,{z:1,children:Ge(hn,{size:[2.6-.4,1.7-.4,.01]})})]})]})}),Ge(hn,{color:"#777",size:[.2*2.7,1.7-.4,.02],center:[-1.225+.4,0,1]})]}),n7n=()=>Un(Hr,{children:[Ge(hn,{color:"#ccc",size:[.9,1.75,.2],center:[-1.825,0,.2/2]}),Ge(hn,{color:"#ccc",size:[.9,1.75,.2],center:[1.825,0,.2/2]}),Ge(fi,{color:"#222",children:Un(lm,{children:[Un(Kl,{children:[Ge(Uo,{z:.2,children:Ge(hn,{size:[3.8-.05/2,2.5-.05/2,.01]})}),Ge(Uo,{z:.01,children:Ge(hn,{size:[3.8-.05,2.5-.05,.01]})})]}),Un(Kl,{children:[Ge(Uo,{z:.2,children:Ge(hn,{size:[3.8,2.5,.01]})}),Ge(Uo,{z:1,children:Ge(hn,{size:[3.8-.4,2.5-.4,.01]})})]})]})}),Ge(hn,{color:"#777",size:[.2*2.7,2.5-.4,.02],center:[-1.825+.4,0,1]})]}),o7n=()=>Un(Hr,{children:[Ge(hn,{color:"#ccc",size:[.4,.25,.14],center:[-.4,0,.14/2]}),Ge(hn,{color:"#ccc",size:[.4,.25,.14],center:[.4,0,.14/2]}),Ge(fi,{color:"#222",children:Un(lm,{children:[Ge(Uo,{z:.14/2,children:Ge(hn,{size:[.8,.6,.14]})}),Un(Kl,{children:[Ge(Uo,{z:.14,children:Ge(hn,{size:[.8,.6,.01]})}),Ge(Uo,{z:.37,children:Ge(hn,{size:[.8-.1,.6-.1,.01]})})]})]})})]}),r7n=()=>{const u=3.0999999999999996;return Un(Hr,{children:[Ge(Kr,{rotation:Math.PI,position:{x:6.6/2+u/4,y:0,z:.25/2},width:3,thickness:.25,padContactLength:.5,bodyDistance:u,height:.75}),Ge(Kr,{position:{x:-6.6/2-u/4,y:0,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:u,height:.75}),Ge(Kr,{position:{x:-6.6/2-u/4,y:-2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:u,height:.75}),Ge(Kr,{position:{x:-6.6/2-u/4,y:2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:u,height:.75}),Ge(z_,{center:{x:0,y:0,z:0},width:3.5,length:6.5,height:1.7,includeNotch:!1,taperRatio:.06,straightHeightRatio:.45})]})},i7n=()=>Un(Hr,{children:[Array.from({length:16}).map((m,h)=>Ge(Kr,{position:{x:-10.5/2,y:h*.5-3.75,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Array.from({length:16}).map((m,h)=>Ge(Kr,{rotation:Math.PI,position:{x:10.5/2,y:h*.5-3.75,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Array.from({length:16}).map((m,h)=>Ge(Kr,{rotation:Math.PI/2,position:{x:h*.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((m,h)=>Ge(Kr,{rotation:-Math.PI/2,position:{x:h*.5-3.75,y:10.5/2,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Ge(z_,{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})]}),s7n=i7n,a7n=()=>{const l=.7999999999999998;return Un(Hr,{children:[Ge(Kr,{rotation:Math.PI,position:{x:2.05/2+l/4,y:0,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:l,height:.65}),Ge(Kr,{position:{x:-2.05/2-l/4,y:-.65,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:l,height:.65}),Ge(Kr,{position:{x:-2.05/2-l/4,y:.65,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:l,height:.65}),Ge(z_,{center:{x:0,y:0,z:0},width:1.25,length:2,height:.9,includeNotch:!1,taperRatio:.06,straightHeightRatio:.7,heightAboveSurface:.05})]})},c7n=({pinCount:t,pitch:e,leadWidth:n,padContactLength:o,bodyWidth:r})=>{const i=t/4;if(i!==Math.floor(i))throw new Error(`LQFP pinCount must be divisible by 4, got ${t}`);e||(e=.5),o||(o=.6),n||(n=.22),r||(r=e*(i+4));const s=r,a=(i-1)*e/2,c=s+3.3*o,l=c,u=.8,_=.2,d=(l-r)/2+.4;return Un(Hr,{children:[Array.from({length:i}).map((m,h)=>Ge(Kr,{position:{x:-l/2-.36,y:h*e-a,z:_/2},width:n,thickness:_,padContactLength:o,bodyDistance:d,height:u})),Array.from({length:i}).map((m,h)=>Ge(Kr,{rotation:Math.PI,position:{x:l/2+.36,y:h*e-a,z:_/2},width:n,thickness:_,padContactLength:o,bodyDistance:d,height:u})),Array.from({length:i}).map((m,h)=>Ge(Kr,{rotation:Math.PI/2,position:{x:h*e-a,y:-c/2-.36,z:_/2},width:n,thickness:_,padContactLength:o,bodyDistance:d,height:u})),Array.from({length:i}).map((m,h)=>Ge(Kr,{rotation:-Math.PI/2,position:{x:h*e-a,y:c/2+.36,z:_/2},width:n,thickness:_,padContactLength:o,bodyDistance:d,height:u})),Ge(z_,{center:{x:0,y:0,z:0},width:r,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})]})},l7n=()=>{const o=.20900000000000002,r=.1,i=.3,s=.1,a=.2;return Un(Hr,{children:[Ge(fi,{color:"#222",children:Un(lm,{children:[Ge(hn,{size:[.85,1.2,o],center:[0,0,o/2]}),Un(Kl,{children:[Ge(Uo,{z:o,children:Ge(hn,{size:[.85,1.2,.01]})}),Ge(Uo,{z:.38,children:Ge(hn,{size:[.85-r,1.2-r,.01]})})]})]})}),Ge(hn,{color:"#ccc",size:[i,.25,s],center:[.55,0,s/2]}),Ge(hn,{color:"#ccc",size:[i,a,s],center:[-.55,.4,s/2]}),Ge(hn,{color:"#ccc",size:[i,a,s],center:[-.55,-.4,s/2]})]})},u7n=({num_pins:t,bodyWidth:e=5.3,bodyLength:n=5.3,bodyThickness:o=1,thermalPadSize:r,padWidth:i=n/5.3*.6,padLength:s=n/5.3*1,pitch:a=.5,thermalPadThickness:c=.2})=>{const l=[],u=Math.floor(t/2),_=a*(u-1);for(let d=0;d<t;d++){const m=d<u?"left":"right",h=d%u,p=_/2-h*a,x=s,f=i,g=m==="left"?-e/2+x/2:e/2-x/2,y=d+1;l.push({pinNumber:y,x:g,y:p,padSizeX:x,padSizeY:f})}return Un(Hr,{children:[Ge(z_,{center:{x:0,y:0,z:0},width:e,length:n,height:o,heightAboveSurface:0,color:"grey",chamferSize:.2,taperRatio:0,notchPosition:{x:-(e/2-s),y:n/2-s,z:o}}),l.map((d,m)=>Ge(hn,{center:[d.x,d.y,c/2],size:[d.padSizeX,d.padSizeY,c]})),r?.length!==void 0&&r?.width!==void 0&&Ge(hn,{center:[0,0,c/2],size:[r.width,r.length,c]})]})},_7n=({bodyLength:t=10.2,bodyWidth:e=4.65,bodyHeight:n=13.46,leadSpacing:o=5,leadDiameter:r=.8,leadLength:i=12.7,color:s="#ddd",leadColor:a="#b87333"})=>{const c=t/2,l=e/2,u=c-l,_=o/2,d=.85;return Un(Hr,{children:[Un(fi,{color:s,children:[Un(Kl,{children:[Ge(Lx,{height:n,roundRadius:.5,radius:l,center:[-u,0,n]}),Ge(Lx,{height:n,roundRadius:.5,radius:l,center:[u,0,n]})]}),Un(Kl,{children:[Ge(Lx,{height:d,roundRadius:.1,radius:l+.85,center:[-u,0,n/2+d/2]}),Ge(Lx,{height:d,roundRadius:.1,radius:l+.85,center:[u,0,n/2+d/2]})]})]}),Un(fi,{color:a,children:[Ge(__,{height:i+n/2,radius:r/2,center:[-_+.06,0,-(i/2)+n/2]}),Ge(__,{height:i+n/2,radius:r/2,center:[_-.06,0,-(i/2)+n/2]})]})]})},d7n=({bodyLength:t=1.4,bodyDiameter:e=1.1,color:n="#3a3a3aff",contactColor:o="#c6c6c6",cathodeIdentification:r="#111"})=>Un(Hr,{children:[Ge(fi,{color:n,children:Un(Cd,{rotation:[0,"90deg",0],children:[Ge(bN,{size:[e,e,t-.2],roundRadius:.2,center:[-e/2,0,.05]}),Ge(__,{height:.2/2,radius:e/2-.2,center:[-e/2,0,-t/2+.2/2]})]})}),Ge(fi,{color:r,children:Ge(Cd,{rotation:[0,"90deg",0],children:Ge(bN,{size:[e*1.01,e*1.01,t/3],roundRadius:.2,center:[-e/2,0,-t/4+.1]})})}),Ge(fi,{color:o,children:Ge(Cd,{rotation:[0,"90deg",0],children:Ge(Lx,{height:.2,radius:e/2,roundRadius:.2/3,center:[-e/2,0,-t/2]})})}),Ge(fi,{color:o,children:Ge(Cd,{rotation:[0,"90deg",0],children:Ge(Lx,{height:.2,radius:e/2,roundRadius:.2/3,center:[-e/2,0,t/2]})})})]}),h7n=({bodyLength:t=3.5,bodyDiameter:e=1.5,color:n="#3a3a3aff",contactColor:o="#c6c6c6"})=>Un(Hr,{children:[Ge(fi,{color:n,children:Ge(Cd,{rotation:[0,"90deg",0],children:Ge(Lx,{height:t,radius:e/2,roundRadius:.3,center:[-e/2,0,0]})})}),Ge(fi,{color:o,children:Ge(Cd,{rotation:[0,"90deg",0],children:Ge(Lx,{height:.5,radius:e/2,roundRadius:.2,center:[-e/2,0,-t/2]})})}),Ge(fi,{color:o,children:Ge(Cd,{rotation:[0,"90deg",0],children:Ge(Lx,{height:.5,radius:e/2,roundRadius:.2,center:[-e/2,0,t/2]})})})]}),m7n=({bodyLength:t=3.9,bodyDiameter:e=2.5,color:n="#3a3a3aff",contactColor:o="#c6c6c6"})=>Un(Hr,{children:[Ge(fi,{color:n,children:Ge(Cd,{rotation:[0,"90deg",0],children:Ge(Lx,{height:t,radius:e/2,roundRadius:.3,center:[-e/2,0,0]})})}),Ge(fi,{color:o,children:Ge(Cd,{rotation:[0,"90deg",0],children:Ge(Lx,{height:.55,radius:e/2,roundRadius:.2,center:[-e/2,0,-t/2]})})}),Ge(fi,{color:o,children:Ge(Cd,{rotation:[0,"90deg",0],children:Ge(Lx,{height:.55,radius:e/2,roundRadius:.2,center:[-e/2,0,t/2]})})})]}),p7n=({pinCount:t,padContactLength:e=.6,leadWidth:n=.41,pitch:o=1.27})=>{if(t%2!==0)throw new Error("MS012 pinCount must be even");const r=t/2,i=4.9,s=3.9,a=(r-1)*o/2,c=.2;return Un(Hr,{children:[Array.from({length:r}).map((l,u)=>Ge(Kr,{position:{x:-s/2-e-.3,y:u*o-a,z:c/2},width:n,thickness:c,padContactLength:e,bodyDistance:e+.4,height:.85})),Array.from({length:r}).map((l,u)=>Ge(Kr,{rotation:Math.PI,position:{x:s/2+e+.3,y:u*o-a,z:c/2},width:n,thickness:c,padContactLength:e,bodyDistance:e+.4,height:.85})),Ge(z_,{center:{x:0,y:0,z:c/2},width:s,length:i,height:1.55,notchPosition:{x:-.95,y:i/2-1,z:1.55},heightAboveSurface:.17,taperRatio:.09})]})},f7n=({pinCount:t=16,padContactLength:e=.6,leadWidth:n=.41,pitch:o=1.27})=>{if(t!==16)throw new Error("MS013 only supports 16 pins");const r=t/2,i=7.5,s=10.3,a=(r-1)*o/2,c=.2;return Un(Hr,{children:[Array.from({length:r}).map((l,u)=>Ge(Kr,{position:{x:-i/2-e-.3,y:u*o-a,z:c/2},width:n,thickness:c,padContactLength:e,bodyDistance:e+.4,height:.85})),Array.from({length:r}).map((l,u)=>Ge(Kr,{rotation:Math.PI,position:{x:i/2+e+.3,y:u*o-a,z:c/2},width:n,thickness:c,padContactLength:e,bodyDistance:e+.4,height:.85})),Ge(z_,{center:{x:0,y:0,z:c/2},width:i,length:s,height:1.1,notchPosition:{x:-2.25,y:s/2-1.5,z:1.1},heightAboveSurface:.17,taperRatio:.05})]})},x7n=()=>{const p=7.050000000000001,x=24.95+6.5/2;return Ge(Uo,{center:[0,0,1],children:Un(Hr,{children:[Un(Cd,{rotation:[0,55,-55],children:[Un(v5,{children:[Ge(hn,{color:"#ccc",size:[6.5+.1,9.9,1.3],center:[x,0,1.3-2]}),Ge(__,{color:"black",center:[x,0,1.3-2],radius:3/2,height:1.3*1.2})]}),Ge(fi,{color:"#222",children:Ge(z_,{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})})]}),Ge(Cd,{rotation:[0,55,55],children:Array.from({length:3}).map((f,g)=>{const y=p,b=(g-1)*2.7,v=-.5-.6;return Un(fi,{color:"gold",children:[Un(Kl,{children:[Ge(Uo,{center:[15.05-4.5/2+.1,b,v],children:Ge(hn,{size:[4.5,.81+1,.5]})}),Ge(Uo,{center:[15.05-4.5/2-1+.1,b,v],children:Ge(hn,{size:[4.5,.81,.5]})})]}),Ge(Uo,{center:[y,b,v],children:Ge(hn,{size:[16+.1,.81,.5]})})]},`prong-${g}`)})})]})})},g7n=()=>{const l=1.1999999999999997;return Un(Hr,{children:[Ge(Kr,{rotation:Math.PI,position:{x:2.8/2+l/4,y:-.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:l,height:.95}),Ge(Kr,{rotation:Math.PI,position:{x:2.8/2+l/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:l,height:.95}),Ge(Kr,{rotation:Math.PI,position:{x:2.8/2+l/4,y:.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:l,height:.95}),Ge(Kr,{position:{x:-2.8/2-l/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:l,height:.95}),Ge(Kr,{position:{x:-2.8/2-l/4,y:-.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:l,height:.95}),Ge(Kr,{position:{x:-2.8/2-l/4,y:.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:l,height:.95}),Ge(z_,{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})]})},y7n=()=>Un(Hr,{children:[Ge(z_,{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(l=>{const u=-.35+l*.35;return Ge(hn,{center:[-.8/2+.19/2-.1,u,.12/2],size:[.19,.15,.12]})}),[0,1,2].map(l=>{const u=-.35+l*.35;return Ge(hn,{center:[.8/2-.19/2+.1,u,.12/2],size:[.19,.15,.12]})})]}),b7n=()=>{const s="#222",c=[.43,.4,1.32],l=[.43,.4,.25],u=[0,0,-.66],_=[0,0,-1.32],d=[0,1.28,-2.72],m=[0,1.28,-8.9],h=-7.5;return Un(Uo,{center:[0,1,10.5],children:[Ge(fi,{color:s,children:Un(v5,{children:[Ge(Uo,{center:[0,0,2.25],children:Ge(__,{radius:2.4,height:4.5})}),Ge(Uo,{center:[0,-1.8499999999999999,2.25],children:Ge(hn,{size:[2.4*2,1.1,4.5+.2]})})]})}),Ge(Uo,{center:u,children:Ge(hn,{size:c})}),Un(Kl,{children:[Ge(Uo,{center:_,children:Ge(hn,{size:l})}),Ge(Uo,{center:d,children:Ge(hn,{size:l})})]}),Ge(Uo,{center:m,children:Ge(hn,{size:[.43,.4,12.2]})}),Ge(Uo,{center:[1.3,0,h],children:Ge(hn,{size:[.43,.4,15]})}),Ge(Uo,{center:[-1.3,0,h],children:Ge(hn,{size:[.43,.4,15]})})]})},P7n=()=>Un(Hr,{children:[Ge(Kr,{rotation:Math.PI,position:{x:2/2+.75/4,y:-.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Ge(Kr,{rotation:Math.PI,position:{x:2/2+.75/4,y:0,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Ge(Kr,{rotation:Math.PI,position:{x:2/2+.75/4,y:.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Ge(Kr,{position:{x:-2/2-.75/4,y:0,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Ge(Kr,{position:{x:-2/2-.75/4,y:-.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Ge(Kr,{position:{x:-2/2-.75/4,y:.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Ge(z_,{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})]}),v7n=P7n,S7n=()=>Un(Hr,{children:[Ge(z_,{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(a=>{const c=-.5+a*.5;return Ge(hn,{center:[-1/2+.3/2,c,.05/2],size:[.3,.2,.05]})}),[0,1,2].map(a=>{const c=-.5+a*.5;return Ge(hn,{center:[1/2-.3/2,c,.05/2],size:[.3,.2,.05]})})]}),C7n=()=>Un(Hr,{children:[Ge(Kr,{position:{x:-2.5/2,y:0,z:.175/2},width:.3,thickness:.175,padContactLength:.3,bodyDistance:.45,height:.7}),Ge(Kr,{rotation:Math.PI,position:{x:2.5/2,y:0,z:.175/2},width:.3,thickness:.175,padContactLength:.3,bodyDistance:.45,height:.7}),Ge(fi,{color:"#222",children:Ge(z_,{center:{x:0,y:0,z:0},width:1.7,length:1.25,height:.95,includeNotch:!1,taperRatio:.06,straightHeightRatio:.7,heightAboveSurface:.05})}),Ge(hn,{color:"#777",size:[1.7/3,1.25-.075,.02],center:[-.85*2/3+.035,0,.95+.05]})]}),M7n=()=>Un(Hr,{children:[Ge(hn,{color:"#ccc",size:[.4,.325,.175],center:[-1.05,0,.175/2]}),Ge(hn,{color:"#ccc",size:[.4,.325,.175],center:[1.05,0,.175/2]}),Ge(fi,{color:"#222",children:Un(lm,{children:[Ge(Uo,{z:.175/2,children:Ge(hn,{size:[1.7,1.25,.175]})}),Un(Kl,{children:[Ge(Uo,{z:.175,children:Ge(hn,{size:[1.7,1.25,.01]})}),Ge(Uo,{z:.725,children:Ge(hn,{size:[1.7-.2,1.25-.2,.01]})})]})]})}),Ge(hn,{color:"#777",size:[1.7/3,1.25-.2,.02],center:[-1.05+1.7/4.4+.2,0,.725]})]}),T7n=()=>{const s=-1.0474999999999999,a=1.775/2+.4/2-.04;return Un(Hr,{children:[Ge(hn,{color:"#ccc",size:[.4,.325,.13],center:[s,0,.13/2]}),Ge(hn,{color:"#ccc",size:[.4,.325,.13],center:[a,0,.13/2]}),Ge(fi,{color:"#222",children:Ge(z_,{width:1.775,length:1.25,height:.725,center:{x:0,y:0,z:0},heightAboveSurface:0,straightHeightRatio:.7,taperRatio:.06,includeNotch:!1})}),Ge(hn,{color:"#777",size:[1.775/3,1.25-.05,.02],center:[s+1.775/4.4+.2,0,.725]})]})},w7n=({pitch:t=10})=>Un(Hr,{children:[Ge(__,{height:4,radius:.5,center:[-t/2,0,.5]}),Ge(HX,{radius:.5,center:[-t/2,0,2.5]}),Ge(Uo,{x:-2.5,y:0,z:2.5,children:Un(Cd,{rotation:[0,Math.PI/2,0],children:[Ge(__,{height:t,radius:.5,center:[0,0,2.5]}),Ge(fi,{color:"#d2b48c",children:Ge(__,{height:5,radius:1.3,center:[0,0,2.5]})})]})}),Ge(__,{height:4,radius:.5,center:[t/2,0,.5]}),Ge(HX,{radius:.5,center:[t/2,0,2.5]})]}),E7n=({bodyWidth:t=21,boardThickness:e=.5,leadWidth:n=1.6,leadLength:o=2.4,leadsPitch:r=2.54,leadsLeft:i,leadsRight:s,leadsTop:a,leadsBottom:c,innerHoles:l=!0,innerHoleEdgeDistance:u=1.61,innerHoleDiameter:_=1})=>{const d=t/2,m=e/2,h=e*1.05,p=_/2,x=Math.max(i||0,s||0,a||0,c||0)*r||51,f=[],g=[];if(s){const S=-((s-1)/2)*r;for(let M=0;M<s;M++){const w=S+M*r;f.push({x:d-o/2,y:-w,pl:o,pw:n}),l&&g.push({x:d,y:-w},{x:d-u,y:-w})}}if(i){const S=-((i-1)/2)*r;for(let M=0;M<i;M++){const w=S+M*r;f.push({x:-d+o/2,y:-w,pl:o,pw:n}),l&&g.push({x:-d,y:-w},{x:-d+u,y:-w})}}if(a){const S=-((a-1)/2)*r;for(let M=0;M<a;M++){const w=S+M*r;f.push({x:-w,y:x/2-o/2,pl:n,pw:o}),l&&g.push({x:-w,y:x/2},{x:-w,y:x/2-u})}}if(c){const S=-((c-1)/2)*r;for(let M=0;M<c;M++){const w=S+M*r;f.push({x:-w,y:-x/2+o/2,pl:n,pw:o}),l&&g.push({x:-w,y:-x/2},{x:-w,y:-x/2+u})}}const y=Ge(fi,{color:"#008080",children:Un(v5,{children:[Ge(hn,{center:[0,0,m],size:[t,x,e]}),f.map((S,M)=>Ge(hn,{center:[S.x,S.y,m],size:[S.pl+.01,S.pw+.01,h]},M))]})}),b=l&&g.map((S,M)=>Ge(__,{color:"black",center:[S.x,S.y,m],radius:p,height:e*1.07})),v=f.map((S,M)=>Ge(hn,{center:[S.x,S.y,m],size:[S.pl+.01,S.pw+.01,h]}));return Un(Hr,{children:[y,Ge(fi,{color:"#FFD700",children:l?Un(v5,{children:[Ge(lm,{children:f.map((S,M)=>Ge(hn,{center:[S.x,S.y,m],size:[S.pl+.01,S.pw+.01,h]},M))}),b]}):v})]})},D7n=({width:t=30,height:e=22,thickness:n=1,bezelInset:o=2,bezelDepth:r=1,screenColor:i="#001414",bezelColor:s="#0f1116",screenWidth:a,screenHeight:c,offset:l})=>{const u=t,_=e,d=Math.max(n,.4),m=Math.max(Math.min(r,d),.2),h=Math.max(d-m,0),p=Math.max(o,0),x=Math.max(a??u-p*2,2),f=Math.max(c??_-p*2,2),g=Math.min(Math.max(m*.6,.2),m),y=l?.x??0,b=l?.y??0,v=l?.z??0;return Un(Uo,{offset:{x:y,y:b,z:v},children:[h>0&&Ge(fi,{color:s,children:Ge(hn,{size:[u,_,h],offset:[0,0,h/2]})}),Ge(fi,{color:s,children:Un(v5,{children:[Ge(hn,{size:[u,_,m],offset:[0,0,h+m/2]}),Ge(hn,{size:[x,f,m+.02],offset:[0,0,h+m/2]})]})}),Ge(fi,{color:i,children:Ge(hn,{size:[x,f,g],offset:[0,0,h+g/2]})})]})},A7n=({numPins:t=5,rows:e=1,p:n=2.54,id:o=1,od:r=1.5,boardThickness:i=1.6,width:s,height:a,pinRowSide:c="left",holes:l=[],holeInset:u=1,pinRowHoleEdgeToEdgeDist:_=2,female:d,nopin:m,screen:h,screenWidth:p,screenHeight:x,screenCenterOffsetX:f,screenCenterOffsetY:g})=>{const y=h??!1,b=i/2,v=Math.ceil(t/e);let S,M;c==="left"||c==="right"?(S=(e-1)*n+2*_,M=(v-1)*n+2*_):(M=(e-1)*n+2*_,S=(v-1)*n+2*_),t===0&&(S=10,M=10);const w=Number(s??S),D=Number(a??M),A=[];let I=0,H=0,O=0,z=0,V=0,G=0;c==="left"||c==="right"?(I=c==="left"?-w/2+_:w/2-_,H=-((v-1)/2)*n,O=0,z=n,V=c==="left"?n:-n,G=0):(I=-((v-1)/2)*n,H=c==="top"?D/2-_:-D/2+_,O=n,z=0,V=0,G=c==="top"?-n:n);let q=0;for(let pe=0;pe<e&&q<t;pe++)for(let Me=0;Me<v&&q<t;Me++){const xe=I+Me*O+pe*V,We=H+Me*z+pe*G;A.push({x:xe,y:We}),q++}const K=[];if(l)for(const pe of l){let Me=0,xe=0;pe==="topleft"?(Me=-w/2+u,xe=D/2-u):pe==="topright"?(Me=w/2-u,xe=D/2-u):pe==="bottomleft"?(Me=-w/2+u,xe=-D/2+u):pe==="bottomright"?(Me=w/2-u,xe=-D/2+u):pe==="center"&&(Me=0,xe=0),K.push({x:Me,y:xe})}const ne=.63,ce=2,ee=6,oe=3,ie=m||d?0:ce,ae=ie+i,de=Ge(fi,{color:"#008080",children:Un(v5,{children:[Ge(hn,{center:[0,0,b+ie],size:[w,D,i]}),K.map((pe,Me)=>Ge(__,{center:[pe.x,pe.y,b+ie],radius:r/2,height:i},`hole-${Me}`)),A.map((pe,Me)=>Ge(__,{center:[pe.x,pe.y,b+ie],radius:r/2,height:i},`pin-hole-${Me}`))]})}),be=A.map((pe,Me)=>Ge(fi,{color:"#FFD700",children:Un(v5,{children:[Ge(__,{center:[pe.x,pe.y,i/2+ie],radius:r/2,height:i}),Ge(__,{center:[pe.x,pe.y,i/2+ie],radius:o/2,height:i})]})})),Ce=A.map((pe,Me)=>Ge(set,{x:pe.x,y:pe.y,pinThickness:ne,shortSidePinLength:oe,longSidePinLength:ee,bodyHeight:ce,flipZ:xe=>xe})),De=A.map((pe,Me)=>Ge(met,{x:pe.x,y:pe.y,flipZ:xe=>-xe}));return Un(Hr,{children:[de,be,!d&&!m&&Ce,d&&De,y&&Ge(D7n,{width:p??w*.8,height:x??D*.6,offset:{x:f??0,y:g??0,z:ae}})]})},R7n=({footprint:t})=>{const e=hvn.string(t).json();switch(e.fn){case"dip":return Ge(gvn,{numPins:e.num_pins,pitch:e.p,bodyWidth:e.w});case"axial":return Ge(w7n,{pitch:e.p});case"tssop":return Ge(bvn,{pinCount:e.num_pins,leadLength:e.pl,leadWidth:e.pw,pitch:e.p,bodyWidth:e.w});case"msop":return Ge(Pvn,{pinCount:e.num_pins,padContactLength:e.pl,leadWidth:e.pw,pitch:e.p,bodyWidth:e.w});case"vssop":return Ge(jvn,{pinCount:e.num_pins,leadLength:e.pl,leadWidth:e.pw,pitch:e.p,bodyWidth:e.w,bodyLength:e.h});case"qfp":return Ge(Mvn,{pinCount:e.num_pins,pitch:e.p,leadWidth:e.pw,padContactLength:e.pl,bodyWidth:e.w});case"tqfp":return Ge(s7n,{});case"lqfp":return Ge(c7n,{pinCount:e.num_pins});case"qfn":{const r=typeof e.thermalpad?.x=="number"&&typeof e.thermalpad?.y=="number";return Ge(Nvn,{num_pins:e.num_pins,bodyWidth:e.w,bodyLength:e.h,pitch:e.p,padLength:e.pl,padWidth:e.pw,thermalPadSize:r?{width:e.thermalpad.x,length:e.thermalpad.y}:void 0})}case"dfn":{const r=typeof e.thermalpad?.x=="number"&&typeof e.thermalpad?.y=="number";return Ge(u7n,{num_pins:e.num_pins,bodyWidth:e.w,bodyLength:e.h,pitch:e.p,padLength:e.pl,padWidth:e.pw,thermalPadSize:r?{width:e.thermalpad.x,length:e.thermalpad.y}:void 0})}case"pinrow":{const r=t.match(/_rows(\d+)/),i=r&&r[1]?parseInt(r[1],10):1;if(e.male)return Ge(Dvn,{numberOfPins:e.num_pins,pitch:e.p,invert:e.invert,faceup:e.faceup,rows:i,smd:e.smd||e.surface_mount,rightangle:e.rightangle});if(e.female)return Ge(Wvn,{numberOfPins:e.num_pins,pitch:e.p,rows:i})}case"cap":switch(e.imperial){case"0402":return Ge(oet,{color:"#856c4d"});case"0603":return Ge(ret,{color:"#856c4d"});case"0805":return Ge(iet,{color:"#856c4d"});case"0201":return Ge(aet,{color:"#856c4d"});case"01005":return Ge(cet,{color:"#856c4d"});case"1206":return Ge(uet,{color:"#856c4d"});case"1210":return Ge(_et,{color:"#856c4d"});case"2010":return Ge(det,{color:"#856c4d"});case"2512":return Ge(het,{color:"#856c4d"})}case"sot235":return Ge(Ivn,{});case"sot457":return Ge(g7n,{});case"sot223":return Ge(r7n,{});case"sot23w":return Ge(Lvn,{});case"sot323":return Ge(a7n,{});case"sod323f":return Ge(M7n,{});case"sod323fl":return Ge(T7n,{});case"sot363":return Ge(v7n,{});case"sot886":return Ge(S7n,{});case"sot963":return Ge(y7n,{});case"pushbutton":return Ge(Uvn,{width:e.w,length:e.h,innerDiameter:e.id});case"soic":return Ge(Xvn,{pinCount:e.num_pins,leadLength:e.pl,leadWidth:e.pw,pitch:e.p,bodyWidth:e.w});case"sod523":return Ge(Gvn,{});case"sod882":return Ge(Yvn,{});case"sma":return Ge(qvn,{});case"smb":return Ge(Jvn,{});case"smc":return Ge(Kvn,{});case"smf":return Ge(Qvn,{});case"sod123f":return Ge(Zvn,{});case"sod123fl":return Ge(e7n,{});case"sod123w":return Ge(t7n,{});case"sod128":return Ge(n7n,{});case"sod323":return Ge(C7n,{});case"sod923":return Ge(o7n,{});case"hc49":return Ge(_7n,{});case"micromelf":return Ge(d7n,{});case"minimelf":return Ge(h7n,{});case"melf":return Ge(m7n,{});case"ms012":return Ge(p7n,{pinCount:e.num_pins,padContactLength:e.pl,leadWidth:e.pw,pitch:e.p});case"ms013":return Ge(f7n,{pinCount:e.num_pins,padContactLength:e.pl,leadWidth:e.pw,pitch:e.p});case"sot723":return Ge(l7n,{});case"to220":return Ge(x7n,{});case"to92":return Ge(b7n,{});case"stampboard":case"stampreceiver":return Ge(E7n,{bodyWidth:e.w,leadsLeft:e.left,leadsRight:e.right,leadsTop:e.top,leadsBottom:e.bottom,leadsPitch:e.p,leadWidth:e.pw,leadLength:e.pl,innerHoles:e.innerhole,innerHoleEdgeDistance:e.innerholeedgedistance});case"mountedpcbmodule":{const r=e.rows??1,i=e.pinRowSide??"left",s=e.holeInset,a=e.width,c=e.height,l=e.pinrow,u=e.pinRowHoleEdgeToEdgeDist,_=Array.isArray(e.holes)?e.holes:[];return Ge(A7n,{numPins:l,rows:r,p:e.p,id:e.id,od:e.od,width:a,height:c,pinRowSide:i,holes:_,holeInset:s,pinRowHoleEdgeToEdgeDist:u,nopin:e.nopin,female:e.female,screen:e.screen,screenWidth:e.screenwidth,screenHeight:e.screenheight,screenCenterOffsetX:e.screencenteroffsetx,screenCenterOffsetY:e.screencenteroffsety})}}const n=t.match(/_color\(([^)]+)\)/),o=n?n[1]:void 0;switch(e.imperial){case"0402":return Ge(oet,{color:o});case"0603":return Ge(ret,{color:o});case"0805":return Ge(iet,{color:o});case"0201":return Ge(aet,{color:o});case"01005":return Ge(cet,{color:o});case"1206":return Ge(uet,{color:o});case"1210":return Ge(_et,{color:o});case"2010":return Ge(det,{color:o});case"2512":return Ge(het,{color:o})}return null},k7n=t=>t&&typeof t=="object"&&"type"in t,sE=t=>{if(typeof t=="number")return t;if(typeof t=="string"){const e=/^(-?\d+(?:\.\d+)?)\s*deg$/i.exec(t);if(e)return parseFloat(e[1])*Math.PI/180;const n=Number(t);if(!Number.isNaN(n))return n}return 0},N7n=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 K6(t,e,n){const{jscad:{primitives:o,booleans:r,hulls:i,geometries:s,extrusions:a,transforms:c}}=n;if(t==null||t===!1)return[];if(Array.isArray(t))return t.flatMap(d=>K6(d,e,n));if(!k7n(t))return[];const{type:l,props:u,children:_}=t;if(l===eet)return(_??[]).flatMap(d=>K6(d,e,n));if(l===fi){const d=u?.color;return(_??[]).flatMap(m=>K6(m,d??e,n))}if(l===Uo){const d=N7n(u?.offset??u?.center??{x:u?.x,y:u?.y,z:u?.z});return(_??[]).flatMap(h=>K6(h,e,n)).map(({geom:h,color:p})=>({geom:c.translate(d,h),color:p??e}))}if(l===Cd){const d=Array.isArray(u?.rotation)?[sE(u.rotation[0]),sE(u.rotation[1]),sE(u.rotation[2])]:[sE(u?.x??0),sE(u?.y??0),sE(u?.z??0)];return(_??[]).flatMap(h=>K6(h,e,n)).map(({geom:h,color:p})=>({geom:c.rotateZ(d[2],c.rotateY(d[1],c.rotateX(d[0],h))),color:p}))}if(l===lm||l===v5||l===Kl){const d=(_??[]).flatMap(h=>K6(h,e,n)).map(h=>h.geom);if(d.length===0)return[];let m;return l===lm?m=r.union(d):l===v5?m=r.subtract(d[0],d.slice(1)):m=i.hull(d),[{geom:m,color:e}]}if(l===PN){const d=u?.points??[];return[{geom:s.geom2.fromPoints(d),color:e??u?.color}]}if(l===vN){const d=(_??[]).flatMap(x=>K6(x,e,n)).map(x=>x.geom);if(d.length===0)return[];const m=d.length>1?r.union(d):d[0],h=u?.height??u?.h??1;let p=a.extrudeLinear({height:h},m);if(p.polygons)for(const x of p.polygons)!x.plane||!x.vertices||x.vertices.length<3||x.vertices.reverse();return[{geom:p,color:e??u?.color}]}if(l===hn||l===tet||l===__||l===HX||l===bN||l===Lx){let d;if(l===hn){const m=u?.size??[1,1,1],h=u?.offset,p=u?.center??(h?[h[0],h[1],h[2]]:[0,0,0]);d=o.cuboid({size:m,center:p})}else if(l===tet){const m=u?.size??1,h=u?.offset,p=u?.center??(h?[h[0],h[1],h[2]]:[0,0,0]);d=o.cube({size:m,center:p})}else if(l===__){const m=u?.height??1,h=u?.radius??1,p=u?.center??[0,0,0];d=o.cylinder({height:m,radius:h,center:p})}else if(l===HX){const m=u?.radius??1,h=u?.center??[0,0,0];d=o.sphere({radius:m,center:h})}else if(l===Lx){const m=u?.height??1,h=u?.radius??1,p=u?.roundRadius??.1,x=u?.center??[0,0,0];d=o.roundedCylinder({height:m,radius:h,roundRadius:p,center:x})}else{const m=u?.size??[1,1,1],h=u?.roundRadius??.1,p=u?.center??[0,0,0];d=o.roundedCuboid({size:m,roundRadius:h,center:p})}return[{geom:d,color:e??u?.color}]}if(typeof l=="function"){const d=l(u??{});return K6(d,e,n)}return(_??[]).flatMap(d=>K6(d,e,n))}function H7n(t,e){return{geometries:K6(t,void 0,{jscad:e})}}function pet(t){if(t.polygons){const e=[],n=[],o=[];let r=0;for(const s of t.polygons){for(const c of s.vertices)c.index=r,e.push(c[0],c[1],c[2]),t.color&&t.color.length>=3?o.push(t.color[0],t.color[1],t.color[2]):o.push(1,1,1),r++;const a=s.vertices[0].index;for(let c=2;c<s.vertices.length;c++){const l=s.vertices[c-1].index,u=s.vertices[c].index;n.push(a,l,u)}}const i=new al;if(i.setAttribute("position",new Jl(new Float32Array(e),3)),i.setIndex(n),o.length>0&&i.setAttribute("color",new Jl(new Float32Array(o),3)),t.transforms){const s=new Vi;s.fromArray(t.transforms),i.applyMatrix4(s)}return i.computeVertexNormals(),i}if(t.sides){const e=[],n=[];for(const r of t.sides)e.push(r[0][0],r[0][1],0),t.color&&t.color.length>=3?n.push(t.color[0],t.color[1],t.color[2]):n.push(1,1,1);const o=new al;if(o.setAttribute("position",new Jl(new Float32Array(e),3)),n.length>0&&o.setAttribute("color",new Jl(new Float32Array(n),3)),t.transforms){const r=new Vi;r.fromArray(t.transforms),o.applyMatrix4(r)}return o}return console.error("Invalid CSG object: neither polygons nor sides found"),new al}function I7n(t,e){const n=a1e(R7n,{footprint:t});return H7n(n,e)}var L7n=Tc(MX()),fet=Y.createContext(null),O7n=()=>{const t=Y.useContext(fet);if(!t)throw new Error("useHover must be used within a HoverProvider");return t},F7n=({children:t})=>{const{camera:e,renderer:n}=_2(),[o,r]=Y.useState([]),i=Y.useMemo(()=>new a0n,[]),s=Y.useMemo(()=>new pr,[]),a=Y.useRef(o);a.current=o;const c=Y.useRef(null),l=Y.useCallback(h=>{r(p=>[...p,h])},[]),u=Y.useCallback(h=>{if(c.current){let p=!1,x=c.current.object;for(;x;){if(x===h){p=!0;break}x=x.parent}p&&(c.current.onUnhover(),c.current=null)}r(p=>p.filter(x=>x.object!==h))},[]),_=Y.useCallback(h=>{let p=h;for(;p;){const x=a.current.find(f=>f.object===p);if(x)return x;p=p.parent}},[]),d=Y.useCallback(h=>{if(!n.domElement)return;const p=n.domElement.getBoundingClientRect();s.x=(h.clientX-p.left)/p.width*2-1,s.y=-((h.clientY-p.top)/p.height)*2+1,i.setFromCamera(s,e);const x=a.current.map(g=>g.object);if(x.length===0){c.current&&(c.current.onUnhover(),c.current=null);return}const f=i.intersectObjects(x,!0);if(f.length>0){const g=f[0],y=_(g.object);if(y){const b={mousePosition:[g.point.x,g.point.y,g.point.z]};c.current!==y?(c.current?.onUnhover(),y.onHover(b),c.current=y):y.onHover(b)}else c.current&&(c.current.onUnhover(),c.current=null)}else c.current&&(c.current.onUnhover(),c.current=null)},[e,n,i,s,_]);Y.useEffect(()=>{const h=n.domElement;return h.addEventListener("mousemove",d),()=>{h.removeEventListener("mousemove",d)}},[n,d]);const m=Y.useMemo(()=>({addHoverable:l,removeHoverable:u}),[l,u]);return j.jsx(fet.Provider,{value:m,children:t})},B7n=({children:t,object:e,onHover:n,onUnhover:o,isHovered:r})=>{const{addHoverable:i,removeHoverable:s}=O7n();return Y.useEffect(()=>e?(i({object:e,onHover:n,onUnhover:o}),()=>{s(e)}):void 0,[e,n,o,i,s]),j.jsx(j.Fragment,{children:t})},RN=B7n,z7n=({positionOffset:t,footprint:e,rotationOffset:n,onHover:o,onUnhover:r,isHovered:i,scale:s,isTranslucent:a=!1})=>{const{rootObject:c}=_2(),l=Y.useMemo(()=>{if(!e)return null;const{geometries:u}=I7n(e,L7n),_=new op;for(const d of u.flat(1/0)){const m=d.geom;if(!m||!m.polygons&&!m.sides)continue;const h=new Yo(d.color);h.convertLinearToSRGB();const p={...m,color:[h.r,h.g,h.b]},x=pet(p),f=new tf({vertexColors:!0,side:om,transparent:a,opacity:a?.5:1,depthWrite:!a}),g=new ei(x,f);g.renderOrder=a?2:1,_.add(g)}return _},[e,a]);return Y.useEffect(()=>{if(!(!l||!c))return c.add(l),()=>{c.remove(l)}},[c,l]),Y.useEffect(()=>{l&&(t&&l.position.fromArray(t),n&&l.rotation.fromArray(n),s!==void 0&&l.scale.setScalar(s))},[l,t?.[0],t?.[1],t?.[2],n?.[0],n?.[1],n?.[2],s]),Y.useEffect(()=>{l&&l.traverse(u=>{u instanceof ei&&u.material instanceof tf&&(i?(u.material.emissive.setHex(255),u.material.emissiveIntensity=.2):u.material.emissiveIntensity=0)})},[i,l]),l?j.jsx(RN,{isHovered:i,onHover:o,onUnhover:r,object:l}):null},xet=new WeakMap,V7n=()=>{const t=new T0;return t.name="fallback-environment-map",t.mapping=NW,t},$7n=t=>{if(!t)return null;const e=t,n=xet.get(e);if(n)return n;let o;if(t instanceof _U){const r=new uce(t);o=r.fromScene(R0n(),.04).texture,r.dispose()}else o=V7n();return xet.set(e,o),o};function W7n(t){const e=new f5;let n=!1;t.updateWorldMatrix(!0,!1);const o=t.parent?t.parent.matrixWorld.clone().invert():new Vi;return t.traverse(r=>{if(r.updateWorldMatrix(!0,!1),r instanceof ei&&r.geometry&&(r.geometry.boundingBox||r.geometry.computeBoundingBox(),r.geometry.boundingBox)){const i=r.geometry.boundingBox.clone();i.applyMatrix4(r.matrixWorld),i.applyMatrix4(o),n?e.union(i):(e.copy(i),n=!0)}}),n?e:null}function U7n(t){const e=W7n(t);return e?e.getSize(new wt):new wt}function X7n(t,e,n="contain_within_bounds"){if(!e)return[1,1,1];const o=U7n(t),r=[o.x>0?e[0]/o.x:1,o.y>0?e[1]/o.y:1,o.z>0?e[2]/o.z:1];if(n==="fill_bounds")return r;const i=Math.min(...r);return[i,i,i]}var w1e=({model:t,position:e,rotation:n,modelOffset:o=[0,0,0],modelRotation:r=[0,0,0],sourceCoordinateTransform:i,modelSize:s,modelFitMode:a="contain_within_bounds",scale:c})=>{const{rootObject:l}=_2(),u=Y.useMemo(()=>new op,[]),_=Y.useMemo(()=>new op,[]),d=Y.useMemo(()=>new op,[]),m=Y.useMemo(()=>new op,[]);return Y.useEffect(()=>(u.add(_),()=>{u.remove(_)}),[u,_]),Y.useEffect(()=>(_.add(d),()=>{_.remove(d)}),[_,d]),Y.useEffect(()=>(d.add(m),()=>{d.remove(m)}),[d,m]),Y.useEffect(()=>{for(;m.children.length>0;){const h=m.children[0];if(!h)break;m.remove(h)}t&&m.add(t)},[m,t]),Y.useEffect(()=>{if(!i){m.matrixAutoUpdate=!0,m.position.set(0,0,0),m.rotation.set(0,0,0),m.scale.set(1,1,1),m.updateMatrix();return}m.matrixAutoUpdate=!1,m.matrix.copy(i),m.matrixWorldNeedsUpdate=!0},[m,i]),Y.useEffect(()=>{if(l)return l.add(u),()=>{l.remove(u)}},[l,u]),Y.useEffect(()=>{if(e?u.position.fromArray(e):u.position.set(0,0,0),n?u.rotation.fromArray(n):u.rotation.set(0,0,0),d.position.fromArray(o),d.rotation.fromArray(r),d.scale.setScalar(c??1),!t){_.scale.set(1,1,1);return}_.scale.set(1,1,1),_.updateWorldMatrix(!0,!0);const h=X7n(d,s,a);_.scale.set(h[0],h[1],h[2])},[u,_,t,a,o,m,d,r,s,e,n,c]),{boardTransformGroup:u}},get=1.25;function yet({gltfUrl:t,position:e,rotation:n,modelOffset:o=[0,0,0],modelRotation:r=[0,0,0],sourceCoordinateTransform:i,modelSize:s,modelFitMode:a="contain_within_bounds",onHover:c,onUnhover:l,isHovered:u,scale:_,isTranslucent:d=!1}){const{renderer:m}=_2(),[h,p]=Y.useState(null),[x,f]=Y.useState(null),{boardTransformGroup:g}=w1e({model:h,position:e,rotation:n,modelOffset:o,modelRotation:r,sourceCoordinateTransform:i,modelSize:s,modelFitMode:a,scale:_});if(Y.useEffect(()=>{if(!t)return;const y=new N0n;let b=!0;return y.load(t,v=>{if(!b)return;const S=v.scene;S.traverse(M=>{if(M instanceof ei&&M.material){const w=D=>{D.transparent=d,D.opacity=d?.5:1,D.depthWrite=!d,D.needsUpdate=!0};Array.isArray(M.material)?M.material.forEach(w):w(M.material),M.renderOrder=d?2:1}}),p(S)},void 0,v=>{if(!b)return;console.error(`An error happened loading ${t}`,v);const S=v instanceof Error?v:new Error(`Failed to load glTF model from ${t}`);f(S)}),()=>{b=!1}},[t,d]),Y.useEffect(()=>{if(!h||!m)return;const y=$7n(m);if(!y)return;const b=[],v=S=>{S instanceof tf&&(b.push({material:S,envMap:S.envMap??null,envMapIntensity:S.envMapIntensity??1}),S.envMap=y,(typeof S.envMapIntensity!="number"||S.envMapIntensity<get)&&(S.envMapIntensity=get),S.needsUpdate=!0)};return h.traverse(S=>{if(!(S instanceof ei))return;const M=S.material;Array.isArray(M)?M.forEach(v):M&&v(M)}),()=>{b.forEach(({material:S,envMap:M,envMapIntensity:w})=>{S.envMap=M,S.envMapIntensity=w,S.needsUpdate=!0})}},[h,m]),Y.useEffect(()=>{h&&h.traverse(y=>{y instanceof ei&&y.material instanceof tf&&(u?(y.material.emissive.setHex(255),y.material.emissiveIntensity=.2):y.material.emissiveIntensity=0)})},[u,h]),x)throw x;return h?j.jsx(RN,{isHovered:u,onHover:c,onUnhover:l,object:g}):null}var j7n=Tc(vZe()),G7n=Tc(MX()),Y7n=({jscadPlan:t,positionOffset:e,rotationOffset:n,modelOffset:o=[0,0,0],modelRotation:r=[0,0,0],sourceCoordinateTransform:i,modelSize:s,modelFitMode:a="contain_within_bounds",onHover:c,onUnhover:l,isHovered:u,scale:_,isTranslucent:d=!1})=>{const{threeGeom:m,material:h}=Y.useMemo(()=>{const f=(0,j7n.executeJscadOperations)(G7n.default,t);if(!f||!f.polygons&&!f.sides)return{threeGeom:null,material:null};const g=pet(f),y=new tf({vertexColors:!0,side:om,transparent:d,opacity:d?.5:1,depthWrite:!d});return{threeGeom:g,material:y}},[t,d]),p=Y.useMemo(()=>{if(!m)return null;const f=new ei(m,h);return f.renderOrder=d?2:1,f},[m,h,d]),{boardTransformGroup:x}=w1e({model:p,position:e,rotation:n,modelOffset:o,modelRotation:r,sourceCoordinateTransform:i,modelSize:s,modelFitMode:a,scale:_});return Y.useEffect(()=>{if(h)if(u){const f=new Yo(h.color.getHex());h.emissive.copy(f),h.emissive.setRGB(0,0,1),h.emissiveIntensity=.2}else h.emissiveIntensity=0},[u,h]),m?j.jsx(RN,{isHovered:u,onHover:c,onUnhover:l,object:x}):null};function q7n(t){return t.replace(/(DEF|USE)\s+([^\s]+)/g,(e,n,o)=>`${n} ${o.replace(/-/g,"_")}`)}async function J7n(t){const e=await fetch(t);if(!e.ok)throw new Error(`Failed to fetch "${t}": ${e.status} ${e.statusText}`);const n=await e.text();return new gun().parse(q7n(n),t)}typeof window<"u"&&!window.TSCIRCUIT_OBJ_LOADER_CACHE&&(window.TSCIRCUIT_OBJ_LOADER_CACHE=new Map);function K7n(t){const[e,n]=Y.useState(null);return Y.useEffect(()=>{if(!t)return;const o=t.replace(/&cachebust_origin=$/,""),r=window.TSCIRCUIT_OBJ_LOADER_CACHE;let i=!1;async function s(){try{if(o.endsWith(".wrl"))return await J7n(o);const c=await fetch(o);if(!c.ok)throw new Error(`Failed to fetch "${o}": ${c.status} ${c.statusText}`);const l=await c.text(),u=l.match(/newmtl[\s\S]*?endmtl/g),_=new wun;if(u?.length){const d=u.join(`
5153
- `).replace(/d 0\./g,"d 1."),m=l.replace(/newmtl[\s\S]*?endmtl/g,"").replace(/^mtllib.*/gm,""),h=new pun;h.setMaterialOptions({invertTrProperty:!0});const p=h.parse(d.replace(/Kd\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/g,"Kd $2 $2 $2"),"embedded.mtl");return _.setMaterials(p),_.parse(m)}return _.parse(l.replace(/^mtllib.*/gm,""))}catch(c){return c}}function a(){if(r.has(o)){const l=r.get(o);return l.result?Promise.resolve(l.result.clone()):l.promise.then(u=>u instanceof Error?u:u.clone())}const c=s().then(l=>(l instanceof Error||r.set(o,{...r.get(o),result:l}),l));return r.set(o,{promise:c,result:null}),c}return a().then(c=>{i||n(c)}).catch(c=>{console.error(c)}),()=>{i=!0}},[t]),e}function Q7n({url:t,position:e,rotation:n,modelOffset:o=[0,0,0],modelRotation:r=[0,0,0],sourceCoordinateTransform:i,modelSize:s,modelFitMode:a="contain_within_bounds",onHover:c,onUnhover:l,isHovered:u,scale:_,isTranslucent:d=!1}){const m=K7n(t),h=Y.useMemo(()=>m&&!(m instanceof Error)?(m.traverse(x=>{if(x instanceof ei&&x.material){const f=g=>{g.transparent=d,g.opacity=d?.5:1,g.depthWrite=!d,g.needsUpdate=!0};Array.isArray(x.material)?x.material.forEach(f):f(x.material),x.renderOrder=d?2:1}}),m):new ei(new S4(.5,.5,.5),new tf({transparent:!0,color:"red",opacity:.25})),[m,d]),{boardTransformGroup:p}=w1e({model:h,position:Array.isArray(e)?e:e?[e.x,e.y,e.z]:void 0,rotation:Array.isArray(n)?n:n?[n.x,n.y,n.z]:void 0,modelOffset:o,modelRotation:r,sourceCoordinateTransform:i,modelSize:s,modelFitMode:a,scale:_});if(m instanceof Error)throw m;return j.jsx(RN,{isHovered:u,onHover:c,onUnhover:l,object:p})}var E1e,Z7n="https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/dist";function eSn(t){if(typeof t=="function")return t;if(t&&typeof t=="object"&&"default"in t&&typeof t.default=="function")return t.default;throw new Error("Unable to resolve occt-import-js factory export")}async function tSn(){if(!E1e){const t=await import("https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/+esm");E1e=eSn(t)({locateFile:n=>`${Z7n}/${n}`})}return E1e}function nSn(t){const e=new op;for(const n of t){const o=n.attributes.position?.array??[],r=n.index?.array??[];if(!o.length||!r.length)continue;const i=new al;i.setAttribute("position",new $i(o,3));const s=n.attributes.normal?.array??[];s.length?i.setAttribute("normal",new $i(s,3)):i.computeVertexNormals(),i.setIndex(r);const a=new tf({color:n.color?new Yo(n.color[0],n.color[1],n.color[2]):new Yo(.82,.82,.82)}),c=new ei(i,a);c.name=n.name,e.add(c)}return e}async function oSn(t){const e=await fetch(t);if(!e.ok)throw new Error(`Failed to fetch STEP file: ${e.statusText}`);const n=await e.arrayBuffer(),r=(await tSn()).ReadStepFile(new Uint8Array(n),null);if(!r.success||!r.meshes.length)throw new Error("occt-import-js failed to convert STEP file");const i=nSn(r.meshes),s=new Vce;return await new Promise((c,l)=>{s.parse(i,u=>{u instanceof ArrayBuffer?c(u):l(new Error("GLTFExporter did not return binary output"))},u=>{l(u)},{binary:!0})})}var bet="step-glb-cache:";function rSn(t){const e=new Uint8Array(t),n=32768;let o="";for(let r=0;r<e.length;r+=n){const i=e.subarray(r,r+n);o+=String.fromCharCode(...i)}return btoa(o)}function iSn(t){const e=atob(t),n=new Uint8Array(e.length);for(let o=0;o<e.length;o+=1)n[o]=e.charCodeAt(o);return n.buffer}function sSn(t){try{const e=localStorage.getItem(`${bet}${t}`);return e?iSn(e):null}catch(e){return console.warn("Failed to read STEP GLB cache",e),null}}function Pet(t,e){try{const n=rSn(e);localStorage.setItem(`${bet}${t}`,n)}catch(n){console.warn("Failed to write STEP GLB cache",n)}}function aSn(){const t=globalThis;return t.stepUrlToGltfModelConversions||(t.stepUrlToGltfModelConversions={inProgress:new Map,completed:new Map}),t.stepUrlToGltfModelConversions}var cSn=({stepUrl:t,position:e,rotation:n,modelOffset:o,modelRotation:r,sourceCoordinateTransform:i,modelSize:s,modelFitMode:a,scale:c,onHover:l,onUnhover:u,isHovered:_,isTranslucent:d})=>{const[m,h]=Y.useState(null);return Y.useEffect(()=>{let p=!0,x=null,f=!0;const g=aSn(),y=sSn(t);if(y){const S={arrayBuffer:y,blobUrl:URL.createObjectURL(new Blob([y],{type:"model/gltf-binary"}))};return g.completed.set(t,S),x=S.blobUrl,f=!1,h(S.blobUrl),()=>{p=!1,x&&f&&URL.revokeObjectURL(x)}}const b=g.completed.get(t);if(b)return x=b.blobUrl,f=!1,h(b.blobUrl),Pet(t,b.arrayBuffer),()=>{p=!1,x&&f&&URL.revokeObjectURL(x)};let v=g.inProgress.get(t);return v||(v=oSn(t).then(S=>{const M={arrayBuffer:S,blobUrl:URL.createObjectURL(new Blob([S],{type:"model/gltf-binary"}))};return g.completed.set(t,M),g.inProgress.delete(t),M}).catch(S=>{throw g.inProgress.delete(t),S}),g.inProgress.set(t,v)),v.then(S=>{p&&(x=S.blobUrl,f=!1,h(S.blobUrl),Pet(t,S.arrayBuffer))}).catch(S=>{console.error("Failed to convert STEP file to GLB",S),p&&h(null)}),()=>{p=!1,x&&f&&URL.revokeObjectURL(x)}},[t]),m?j.jsx(yet,{gltfUrl:m,position:e,rotation:n,modelOffset:o,modelRotation:r,sourceCoordinateTransform:i,modelSize:s,modelFitMode:a,scale:c,onHover:l,onUnhover:u,isHovered:_,isTranslucent:d}):null};function FX(t,e){let{x:n,y:o,z:r}=t;if(e.axisMapping){const i={x:n,y:o,z:r};e.axisMapping.x&&(n=D1e(i,e.axisMapping.x)),e.axisMapping.y&&(o=D1e(i,e.axisMapping.y)),e.axisMapping.z&&(r=D1e(i,e.axisMapping.z))}if(n*=e.flipX??1,o*=e.flipY??1,r*=e.flipZ??1,e.rotation){if(e.rotation.x){const i=e.rotation.x*Math.PI/180,s=Math.cos(i),a=Math.sin(i),c=o*s-r*a,l=o*a+r*s;o=c,r=l}if(e.rotation.y){const i=e.rotation.y*Math.PI/180,s=Math.cos(i),a=Math.sin(i),c=n*s+r*a,l=-n*a+r*s;n=c,r=l}if(e.rotation.z){const i=e.rotation.z*Math.PI/180,s=Math.cos(i),a=Math.sin(i),c=n*s-o*a,l=n*a+o*s;n=c,o=l}}return{x:n,y:o,z:r}}function D1e(t,e){switch(e){case"x":return t.x;case"y":return t.y;case"z":return t.z;case"-x":return-t.x;case"-y":return-t.y;case"-z":return-t.z;default:return 0}}var A1e={STEP_INVERTED:{axisMapping:{x:"-x",y:"z",z:"-y"}},Z_UP_TO_Y_UP_USB_FIX:{axisMapping:{x:"x",y:"-z",z:"y"},flipZ:-1},FOOTPRINTER_MODEL_TRANSFORM:{axisMapping:{x:"x",y:"-z",z:"y"},flipX:-1,rotation:{x:180,y:180}}};function lSn(t,e){if(e.coordinateTransform)return e.coordinateTransform;if(!e.usingGlbCoordinates){if(e.hasFootprinterModel)return A1e.FOOTPRINTER_MODEL_TRANSFORM;if(!e.usingObjFormat)return e.usingStepFormat?A1e.STEP_INVERTED:A1e.Z_UP_TO_Y_UP_USB_FIX}}function kN(t,e){return lSn(t,{usingGlbCoordinates:e==="gltf"||e==="glb"||e==="jscad",usingObjFormat:e==="obj"||e==="wrl",usingStepFormat:e==="step",hasFootprinterModel:e==="footprinter"})}function BX(t){if(!t)return;const e=FX({x:1,y:0,z:0},t),n=FX({x:0,y:1,z:0},t),o=FX({x:0,y:0,z:1},t);return new Vi().makeBasis(new wt(e.x,e.y,e.z),new wt(n.x,n.y,n.z),new wt(o.x,o.y,o.z))}function lv(t){return t*Math.PI/180}function uSn(t){if(t==="z+")return[0,0,0];switch(t){case"x+":return[0,lv(-90),0];case"x-":return[0,lv(90),0];case"y+":return[lv(90),0,0];case"y-":return[lv(-90),0,0];case"z-":return[lv(180),0,0];default:return[0,0,0]}}function _Sn(t,e,n){if(!t.position)return;let o=t.position.z;return e==="bottom"&&t.position.z>=0&&(o=-(t.position.z+n)),[t.position.x,t.position.y,o]}function dSn(t,e){return t.rotation?[lv(t.rotation.x),lv(t.rotation.y),lv(t.rotation.z)]:e==="bottom"?[Math.PI,0,0]:[0,0,0]}function hSn(t,e){const n=new wt(t.x,t.y,t.z),o=new a2(e[0],e[1],e[2],"XYZ");return n.applyEuler(o),[n.x,n.y,n.z]}function mSn(t,e,n){if(!t.model_origin_position)return[0,0,0];const o=e?FX(t.model_origin_position,e):t.model_origin_position;return hSn(o,n)}function pSn(t,e){const n=_Sn(t,e.layer,e.pcbThickness),o=dSn(t,e.layer),r=kN(t,e.modelType),i=uSn(t.model_board_normal_direction??"z+"),s=mSn(t,r,i);return{position:n,rotation:o,modelPosition:[-s[0],-s[1],-s[2]],modelRotation:i,scale:t.model_unit_to_mm_scale_factor??void 0,fitMode:t.model_object_fit??"contain_within_bounds",size:t.size?[t.size.x,t.size.y,t.size.z]:void 0}}var fSn=t=>t.model_glb_url||t.model_gltf_url?t.model_glb_url?"glb":"gltf":t.model_obj_url||t.model_wrl_url||t.model_stl_url?t.model_wrl_url?"wrl":t.model_stl_url?"stl":"obj":t.model_jscad?"jscad":t.footprinter_string?"footprinter":t.model_step_url?"step":"unknown",xSn=t=>t==="step"?"glb":t,gSn=(t,e)=>{if(t)return e?e(t):t},ySn=(...t)=>t,R1e=class extends cr.Component{constructor(t){super(t),this.state={hasError:!1,error:null}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}render(){return this.state.hasError&&this.state.error?this.props.fallback({error:this.state.error}):this.props.children}},bSn=({error:t,onError:e})=>(Y.useEffect(()=>{e(t)},[t,e]),null),vet=({cad_component:t,circuitJson:e,resolveStaticAsset:n})=>{const o=MZe(e),[r,i]=Y.useState(!1),{visibility:s}=m8(),[a,c]=Y.useState(null),l=Y.useCallback(G=>{G?.mousePosition?(i(!0),c(G.mousePosition)):(i(!1),c(null))},[]),u=Y.useCallback(()=>{i(!1),c(null)},[]),_=Y.useMemo(()=>br(e).source_component.getUsing({source_component_id:t.source_component_id})?.name,[e,t.source_component_id]),d=Y.useMemo(()=>e.filter(q=>q.type==="pcb_plated_hole"&&q.pcb_component_id===t.pcb_component_id).length>0,[e,t.pcb_component_id]),m=Y.useCallback(G=>gSn(G,n),[n]),h=m(t.model_wrl_url??t.model_stl_url??t.model_obj_url),p=m(t.model_glb_url??t.model_gltf_url),x=m(t.model_step_url),[f,g]=Y.useState(0),[y,b]=Y.useState(null);Y.useEffect(()=>{g(0),b(null)},[t.cad_component_id,h,p,x]);const S=e.find(G=>G.type==="pcb_component"&&G.source_component_id===t.source_component_id)?.layer??"top",M=fSn(t),w=xSn(M),D=t.model_glb_url?"glb":"gltf",A=t.model_wrl_url?"wrl":t.model_stl_url?"stl":"obj",I=Y.useMemo(()=>pSn(t,{layer:S,pcbThickness:o,modelType:w}),[t,S,o,w]),H=ySn(...I.rotation),O=I.position,z=Y.useMemo(()=>{const G=[];return p&&G.push(j.jsx(yet,{gltfUrl:p,position:O,rotation:H,modelOffset:I.modelPosition,modelRotation:I.modelRotation,sourceCoordinateTransform:BX(kN(t,D)),scale:I.scale,modelSize:I.size,modelFitMode:I.fitMode,onHover:l,onUnhover:u,isHovered:r,isTranslucent:t.show_as_translucent_model},`${t.cad_component_id}-gltf-${p}`)),h&&G.push(j.jsx(Q7n,{url:h,position:O,rotation:H,modelOffset:I.modelPosition,modelRotation:I.modelRotation,sourceCoordinateTransform:BX(kN(t,A)),scale:I.scale,modelSize:I.size,modelFitMode:I.fitMode,onHover:l,onUnhover:u,isHovered:r,isTranslucent:t.show_as_translucent_model},`${t.cad_component_id}-mixed-${h}`)),x&&!t.model_jscad&&!t.footprinter_string&&G.push(j.jsx(cSn,{stepUrl:x,position:O,rotation:H,modelOffset:I.modelPosition,modelRotation:I.modelRotation,sourceCoordinateTransform:BX(kN(t,w)),scale:I.scale,modelSize:I.size,modelFitMode:I.fitMode,onHover:l,onUnhover:u,isHovered:r,isTranslucent:t.show_as_translucent_model},`${t.cad_component_id}-step-${x}`)),G},[O,t.cad_component_id,t.footprinter_string,t.model_jscad,t.show_as_translucent_model,p,D,l,u,r,A,I.modelPosition,I.modelRotation,I.scale,I.fitMode,I.size,w,H,x,h]);let V=null;if(z.length>0){if(f>=z.length){if(y)throw y;return null}V=j.jsx(R1e,{fallback:({error:G})=>j.jsx(bSn,{error:G,onError:q=>{b(q),g(K=>Math.max(K,f+1))}}),children:z[f]},`${t.cad_component_id}-fallback-${f}`)}else t.model_jscad?V=j.jsx(Y7n,{jscadPlan:t.model_jscad,positionOffset:O,rotationOffset:H,modelOffset:I.modelPosition,modelRotation:I.modelRotation,sourceCoordinateTransform:BX(kN(t,"jscad")),scale:I.scale,modelSize:I.size,modelFitMode:I.fitMode,onHover:l,onUnhover:u,isHovered:r,isTranslucent:t.show_as_translucent_model},t.cad_component_id):t.footprinter_string&&(V=j.jsx(z7n,{positionOffset:O,rotationOffset:H,footprint:t.footprinter_string,scale:I.scale,onHover:l,onUnhover:u,isHovered:r,isTranslucent:t.show_as_translucent_model}));if(t.show_as_translucent_model){if(!s.translucentModels)return null}else if(d&&!s.throughHoleModels||!d&&!s.smtModels)return null;return j.jsxs(j.Fragment,{children:[V,r&&a?j.jsx(wZe,{position:a,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:_??"<unknown>"}):null]})},Cet={version:"0.0.552"};function PSn(t){t.querySelectorAll("canvas").forEach(e=>e.remove())}var vSn=t=>{t.outputColorSpace=p4,t.toneMapping=GFe,t.toneMappingExposure=1},Met="cadViewerCameraStateSession",Tet=(t,e)=>{try{const n={position:t.position.toArray(),quaternion:t.quaternion.toArray(),up:t.up.toArray(),fov:t.fov??50,target:e.target.toArray()};sessionStorage.setItem(Met,JSON.stringify(n))}catch(n){console.warn("Failed to save camera:",n)}},k1e=(t,e)=>{try{const n=sessionStorage.getItem(Met);if(!n)return!1;const o=JSON.parse(n);if(t.position.fromArray(o.position),t.quaternion.fromArray(o.quaternion),t.up.fromArray(o.up),"fov"in t){const r=t;r.fov=o.fov,r.updateProjectionMatrix?.()}return e.target.fromArray(o.target),e.update(),t.updateMatrixWorld(),!0}catch(n){return console.warn("Failed to restore camera:",n),!1}},wet=Y.createContext(void 0),SSn=({children:t,defaultTarget:e,initialCameraPosition:n})=>{const o=Y.useRef(null),r=Y.useRef(null),[i,s]=Y.useState(null),[a,c]=Y.useState("perspective"),[l,u]=Y.useState(n??null),[_,d]=Y.useState(new a2(0,0,0)),m=Y.useMemo(()=>{const[f,g,y]=n??[5,-5,5],b=Math.hypot(f-e.x,g-e.y,y-e.z);return b>0?b:5},[n,e]),h=Y.useCallback(f=>{const g=[e.x,e.y,e.z],y=r.current,b=o.current;let v=m;switch(y&&b&&(v=y.position.distanceTo(b.target)),f){case"Top Center Angled":{const S=v/Math.sqrt(2);return{position:[e.x,e.y-S,e.z+S],target:g,up:[0,0,1]}}case"Top Down":return{position:[e.x,e.y,e.z+v],target:g,up:[0,0,1]};case"Top Left Corner":return{position:[e.x-v*.6,e.y-v*.6,e.z+v*.6],target:g,up:[0,0,1]};case"Top Right Corner":return{position:[e.x+v*.6,e.y-v*.6,e.z+v*.6],target:g,up:[0,0,1]};case"Left Sideview":return{position:[e.x-v,e.y,e.z],target:g,up:[0,0,1]};case"Right Sideview":return{position:[e.x+v,e.y,e.z],target:g,up:[0,0,1]};case"Front":return{position:[e.x,e.y-v,e.z],target:g,up:[0,0,1]};default:return null}},[m,e,r,o]),p=Y.useCallback(f=>{o.current=f},[]),x=Y.useMemo(()=>({controlsRef:o,mainCameraRef:r,defaultTarget:e,baseDistance:m,controller:i,setController:s,getPresetConfig:h,handleControlsChange:p,cameraType:a,setCameraType:c,cameraPosition:l,setCameraPosition:u,cameraRotation:_,setCameraRotation:d,saveCameraToSession:Tet,loadCameraFromSession:k1e}),[e,m,i,h,p,a,l,_]);return j.jsx(wet.Provider,{value:x,children:t})},uv=()=>{const t=Y.useContext(wet);if(!t)throw new Error("useCameraController must be used within a CameraControllerProvider");return t},CSn=Y.forwardRef(({children:t,scene:e,camera:n,style:o,onCreated:r},i)=>{const{cameraType:s}=uv(),a=Y.useRef(null),[c,l]=Y.useState(null),u=Y.useRef([]),_=Y.useRef(void 0);_.current=r;const d=Y.useRef(null),m=Y.useCallback(f=>{u.current.push(f)},[]),h=Y.useCallback(f=>{u.current=u.current.filter(g=>g!==f)},[]),p=Y.useMemo(()=>new JS,[]);e?.up&&p.up.set(e.up.x,e.up.y,e.up.z);const x=Y.useRef(new sl);return Y.useImperativeHandle(i,()=>x.current),Y.useEffect(()=>{if(!a.current)return;PSn(a.current);const f=new _U({antialias:!0,alpha:!0});vSn(f),f.setSize(a.current.clientWidth,a.current.clientHeight),f.setPixelRatio(window.devicePixelRatio),a.current.appendChild(f.domElement);const g=a.current.clientWidth/a.current.clientHeight,y=s==="perspective"?new np(75,g,.1,1e3):new Mk(-10*g,10*g,10,-10,-1e3,1e3);d.current?(y.position.copy(d.current.position),y.quaternion.copy(d.current.quaternion),y.up.copy(d.current.up)):(n?.up&&y.up.set(n.up[0],n.up[1],n.up[2]),n?.position&&y.position.set(n.position[0],n.position[1],n.position[2]),y.lookAt(0,0,0)),p.add(x.current),window.__TSCIRCUIT_THREE_OBJECT=x.current,l({scene:p,camera:y,renderer:f,rootObject:x.current,addFrameListener:m,removeFrameListener:h}),_.current?.({camera:y,renderer:f});let b;const v=new Kln,S=()=>{const w=v.getElapsedTime(),D=v.getDelta();u.current.forEach(A=>A(w,D)),f.render(p,y),b=requestAnimationFrame(S)};S();const M=()=>{if(a.current){const w=a.current.clientWidth/a.current.clientHeight;y instanceof np?y.aspect=w:y instanceof Mk&&(y.left=-10*w,y.right=10*w,y.top=10,y.bottom=-10),y.updateProjectionMatrix(),f.setSize(a.current.clientWidth,a.current.clientHeight)}};return window.addEventListener("resize",M),()=>{d.current={position:y.position.clone(),quaternion:y.quaternion.clone(),up:y.up.clone()},window.removeEventListener("resize",M),cancelAnimationFrame(b),a.current&&f.domElement&&a.current.removeChild(f.domElement),f.dispose(),p.remove(x.current),window.__TSCIRCUIT_THREE_OBJECT===x.current&&(window.__TSCIRCUIT_THREE_OBJECT=void 0)}},[p,m,h,s]),j.jsx("div",{ref:a,style:{width:"100%",height:"100%",...o},children:c&&j.jsx(TZe.Provider,{value:c,children:j.jsx(F7n,{children:t})})})}),MSn=({autoRotate:t,autoRotateSpeed:e,onStart:n,panSpeed:o,rotateSpeed:r,zoomSpeed:i,enableDamping:s,dampingFactor:a,target:c,onControlsChange:l})=>{const{camera:u,renderer:_}=_2(),d=Y.useMemo(()=>!u||!_?null:new Dun(u,_.domElement),[u,_]);return Y.useEffect(()=>(l?.(d??null),()=>l?.(null)),[d,l]),Y.useEffect(()=>{if(!d)return;const m=()=>{l?.(d)};return d.addEventListener("change",m),()=>{d.removeEventListener("change",m)}},[d,l]),Y.useEffect(()=>{d&&(d.autoRotate=t||!1,d.autoRotateSpeed=e||1,o!==void 0&&(d.panSpeed=o),r!==void 0&&(d.rotateSpeed=r),i!==void 0&&(d.zoomSpeed=i),s!==void 0&&(d.enableDamping=s),a!==void 0&&(d.dampingFactor=a),d.zoomToCursor=!0,d.mouseButtons={LEFT:zP.ROTATE,MIDDLE:zP.PAN,RIGHT:null},c&&(d.target.set(c[0],c[1],c[2]),d.update()))},[d,t,e,o,r,i,s,a,c]),Y.useEffect(()=>{if(!(!d||!n))return d.addEventListener("start",n),()=>{d.removeEventListener("start",n)}},[d,n]),Y.useEffect(()=>{if(d)return()=>{d.dispose()}},[d]),fN(()=>{d?.update()},[d]),null},TSn=`
5153
+ `).replace(/d 0\./g,"d 1."),m=l.replace(/newmtl[\s\S]*?endmtl/g,"").replace(/^mtllib.*/gm,""),h=new pun;h.setMaterialOptions({invertTrProperty:!0});const p=h.parse(d.replace(/Kd\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/g,"Kd $2 $2 $2"),"embedded.mtl");return _.setMaterials(p),_.parse(m)}return _.parse(l.replace(/^mtllib.*/gm,""))}catch(c){return c}}function a(){if(r.has(o)){const l=r.get(o);return l.result?Promise.resolve(l.result.clone()):l.promise.then(u=>u instanceof Error?u:u.clone())}const c=s().then(l=>(l instanceof Error||r.set(o,{...r.get(o),result:l}),l));return r.set(o,{promise:c,result:null}),c}return a().then(c=>{i||n(c)}).catch(c=>{console.error(c)}),()=>{i=!0}},[t]),e}function Q7n({url:t,position:e,rotation:n,modelOffset:o=[0,0,0],modelRotation:r=[0,0,0],sourceCoordinateTransform:i,modelSize:s,modelFitMode:a="contain_within_bounds",onHover:c,onUnhover:l,isHovered:u,scale:_,isTranslucent:d=!1}){const m=K7n(t),h=Y.useMemo(()=>m&&!(m instanceof Error)?(m.traverse(x=>{if(x instanceof ei&&x.material){const f=g=>{g.transparent=d,g.opacity=d?.5:1,g.depthWrite=!d,g.needsUpdate=!0};Array.isArray(x.material)?x.material.forEach(f):f(x.material),x.renderOrder=d?2:1}}),m):new ei(new S4(.5,.5,.5),new tf({transparent:!0,color:"red",opacity:.25})),[m,d]),{boardTransformGroup:p}=w1e({model:h,position:Array.isArray(e)?e:e?[e.x,e.y,e.z]:void 0,rotation:Array.isArray(n)?n:n?[n.x,n.y,n.z]:void 0,modelOffset:o,modelRotation:r,sourceCoordinateTransform:i,modelSize:s,modelFitMode:a,scale:_});if(m instanceof Error)throw m;return j.jsx(RN,{isHovered:u,onHover:c,onUnhover:l,object:p})}var E1e,Z7n="https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/dist";function eSn(t){if(typeof t=="function")return t;if(t&&typeof t=="object"&&"default"in t&&typeof t.default=="function")return t.default;throw new Error("Unable to resolve occt-import-js factory export")}async function tSn(){if(!E1e){const t=await import("https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/+esm");E1e=eSn(t)({locateFile:n=>`${Z7n}/${n}`})}return E1e}function nSn(t){const e=new op;for(const n of t){const o=n.attributes.position?.array??[],r=n.index?.array??[];if(!o.length||!r.length)continue;const i=new al;i.setAttribute("position",new $i(o,3));const s=n.attributes.normal?.array??[];s.length?i.setAttribute("normal",new $i(s,3)):i.computeVertexNormals(),i.setIndex(r);const a=new tf({color:n.color?new Yo(n.color[0],n.color[1],n.color[2]):new Yo(.82,.82,.82)}),c=new ei(i,a);c.name=n.name,e.add(c)}return e}async function oSn(t){const e=await fetch(t);if(!e.ok)throw new Error(`Failed to fetch STEP file: ${e.statusText}`);const n=await e.arrayBuffer(),r=(await tSn()).ReadStepFile(new Uint8Array(n),null);if(!r.success||!r.meshes.length)throw new Error("occt-import-js failed to convert STEP file");const i=nSn(r.meshes),s=new Vce;return await new Promise((c,l)=>{s.parse(i,u=>{u instanceof ArrayBuffer?c(u):l(new Error("GLTFExporter did not return binary output"))},u=>{l(u)},{binary:!0})})}var bet="step-glb-cache:";function rSn(t){const e=new Uint8Array(t),n=32768;let o="";for(let r=0;r<e.length;r+=n){const i=e.subarray(r,r+n);o+=String.fromCharCode(...i)}return btoa(o)}function iSn(t){const e=atob(t),n=new Uint8Array(e.length);for(let o=0;o<e.length;o+=1)n[o]=e.charCodeAt(o);return n.buffer}function sSn(t){try{const e=localStorage.getItem(`${bet}${t}`);return e?iSn(e):null}catch(e){return console.warn("Failed to read STEP GLB cache",e),null}}function Pet(t,e){try{const n=rSn(e);localStorage.setItem(`${bet}${t}`,n)}catch(n){console.warn("Failed to write STEP GLB cache",n)}}function aSn(){const t=globalThis;return t.stepUrlToGltfModelConversions||(t.stepUrlToGltfModelConversions={inProgress:new Map,completed:new Map}),t.stepUrlToGltfModelConversions}var cSn=({stepUrl:t,position:e,rotation:n,modelOffset:o,modelRotation:r,sourceCoordinateTransform:i,modelSize:s,modelFitMode:a,scale:c,onHover:l,onUnhover:u,isHovered:_,isTranslucent:d})=>{const[m,h]=Y.useState(null);return Y.useEffect(()=>{let p=!0,x=null,f=!0;const g=aSn(),y=sSn(t);if(y){const S={arrayBuffer:y,blobUrl:URL.createObjectURL(new Blob([y],{type:"model/gltf-binary"}))};return g.completed.set(t,S),x=S.blobUrl,f=!1,h(S.blobUrl),()=>{p=!1,x&&f&&URL.revokeObjectURL(x)}}const b=g.completed.get(t);if(b)return x=b.blobUrl,f=!1,h(b.blobUrl),Pet(t,b.arrayBuffer),()=>{p=!1,x&&f&&URL.revokeObjectURL(x)};let v=g.inProgress.get(t);return v||(v=oSn(t).then(S=>{const M={arrayBuffer:S,blobUrl:URL.createObjectURL(new Blob([S],{type:"model/gltf-binary"}))};return g.completed.set(t,M),g.inProgress.delete(t),M}).catch(S=>{throw g.inProgress.delete(t),S}),g.inProgress.set(t,v)),v.then(S=>{p&&(x=S.blobUrl,f=!1,h(S.blobUrl),Pet(t,S.arrayBuffer))}).catch(S=>{console.error("Failed to convert STEP file to GLB",S),p&&h(null)}),()=>{p=!1,x&&f&&URL.revokeObjectURL(x)}},[t]),m?j.jsx(yet,{gltfUrl:m,position:e,rotation:n,modelOffset:o,modelRotation:r,sourceCoordinateTransform:i,modelSize:s,modelFitMode:a,scale:c,onHover:l,onUnhover:u,isHovered:_,isTranslucent:d}):null};function FX(t,e){let{x:n,y:o,z:r}=t;if(e.axisMapping){const i={x:n,y:o,z:r};e.axisMapping.x&&(n=D1e(i,e.axisMapping.x)),e.axisMapping.y&&(o=D1e(i,e.axisMapping.y)),e.axisMapping.z&&(r=D1e(i,e.axisMapping.z))}if(n*=e.flipX??1,o*=e.flipY??1,r*=e.flipZ??1,e.rotation){if(e.rotation.x){const i=e.rotation.x*Math.PI/180,s=Math.cos(i),a=Math.sin(i),c=o*s-r*a,l=o*a+r*s;o=c,r=l}if(e.rotation.y){const i=e.rotation.y*Math.PI/180,s=Math.cos(i),a=Math.sin(i),c=n*s+r*a,l=-n*a+r*s;n=c,r=l}if(e.rotation.z){const i=e.rotation.z*Math.PI/180,s=Math.cos(i),a=Math.sin(i),c=n*s-o*a,l=n*a+o*s;n=c,o=l}}return{x:n,y:o,z:r}}function D1e(t,e){switch(e){case"x":return t.x;case"y":return t.y;case"z":return t.z;case"-x":return-t.x;case"-y":return-t.y;case"-z":return-t.z;default:return 0}}var A1e={STEP_INVERTED:{axisMapping:{x:"-x",y:"z",z:"-y"}},Z_UP_TO_Y_UP_USB_FIX:{axisMapping:{x:"x",y:"-z",z:"y"},flipZ:-1},FOOTPRINTER_MODEL_TRANSFORM:{axisMapping:{x:"x",y:"-z",z:"y"},flipX:-1,rotation:{x:180,y:180}}};function lSn(t,e){if(e.coordinateTransform)return e.coordinateTransform;if(!e.usingGlbCoordinates){if(e.hasFootprinterModel)return A1e.FOOTPRINTER_MODEL_TRANSFORM;if(!e.usingObjFormat)return e.usingStepFormat?A1e.STEP_INVERTED:A1e.Z_UP_TO_Y_UP_USB_FIX}}function kN(t,e){return lSn(t,{usingGlbCoordinates:e==="gltf"||e==="glb"||e==="jscad",usingObjFormat:e==="obj"||e==="wrl",usingStepFormat:e==="step",hasFootprinterModel:e==="footprinter"})}function BX(t){if(!t)return;const e=FX({x:1,y:0,z:0},t),n=FX({x:0,y:1,z:0},t),o=FX({x:0,y:0,z:1},t);return new Vi().makeBasis(new wt(e.x,e.y,e.z),new wt(n.x,n.y,n.z),new wt(o.x,o.y,o.z))}function lv(t){return t*Math.PI/180}function uSn(t){if(t==="z+")return[0,0,0];switch(t){case"x+":return[0,lv(-90),0];case"x-":return[0,lv(90),0];case"y+":return[lv(90),0,0];case"y-":return[lv(-90),0,0];case"z-":return[lv(180),0,0];default:return[0,0,0]}}function _Sn(t,e,n){if(!t.position)return;let o=t.position.z;return e==="bottom"&&t.position.z>=0&&(o=-(t.position.z+n)),[t.position.x,t.position.y,o]}function dSn(t,e){return t.rotation?[lv(t.rotation.x),lv(t.rotation.y),lv(t.rotation.z)]:e==="bottom"?[Math.PI,0,0]:[0,0,0]}function hSn(t,e){const n=new wt(t.x,t.y,t.z),o=new a2(e[0],e[1],e[2],"XYZ");return n.applyEuler(o),[n.x,n.y,n.z]}function mSn(t,e,n){if(!t.model_origin_position)return[0,0,0];const o=e?FX(t.model_origin_position,e):t.model_origin_position;return hSn(o,n)}function pSn(t,e){const n=_Sn(t,e.layer,e.pcbThickness),o=dSn(t,e.layer),r=kN(t,e.modelType),i=uSn(t.model_board_normal_direction??"z+"),s=mSn(t,r,i);return{position:n,rotation:o,modelPosition:[-s[0],-s[1],-s[2]],modelRotation:i,scale:t.model_unit_to_mm_scale_factor??void 0,fitMode:t.model_object_fit??"contain_within_bounds",size:t.size?[t.size.x,t.size.y,t.size.z]:void 0}}var fSn=t=>t.model_glb_url||t.model_gltf_url?t.model_glb_url?"glb":"gltf":t.model_obj_url||t.model_wrl_url||t.model_stl_url?t.model_wrl_url?"wrl":t.model_stl_url?"stl":"obj":t.model_jscad?"jscad":t.footprinter_string?"footprinter":t.model_step_url?"step":"unknown",xSn=t=>t==="step"?"glb":t,gSn=(t,e)=>{if(t)return e?e(t):t},ySn=(...t)=>t,R1e=class extends cr.Component{constructor(t){super(t),this.state={hasError:!1,error:null}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}render(){return this.state.hasError&&this.state.error?this.props.fallback({error:this.state.error}):this.props.children}},bSn=({error:t,onError:e})=>(Y.useEffect(()=>{e(t)},[t,e]),null),vet=({cad_component:t,circuitJson:e,resolveStaticAsset:n})=>{const o=MZe(e),[r,i]=Y.useState(!1),{visibility:s}=m8(),[a,c]=Y.useState(null),l=Y.useCallback(G=>{G?.mousePosition?(i(!0),c(G.mousePosition)):(i(!1),c(null))},[]),u=Y.useCallback(()=>{i(!1),c(null)},[]),_=Y.useMemo(()=>br(e).source_component.getUsing({source_component_id:t.source_component_id})?.name,[e,t.source_component_id]),d=Y.useMemo(()=>e.filter(q=>q.type==="pcb_plated_hole"&&q.pcb_component_id===t.pcb_component_id).length>0,[e,t.pcb_component_id]),m=Y.useCallback(G=>gSn(G,n),[n]),h=m(t.model_wrl_url??t.model_stl_url??t.model_obj_url),p=m(t.model_glb_url??t.model_gltf_url),x=m(t.model_step_url),[f,g]=Y.useState(0),[y,b]=Y.useState(null);Y.useEffect(()=>{g(0),b(null)},[t.cad_component_id,h,p,x]);const S=e.find(G=>G.type==="pcb_component"&&G.source_component_id===t.source_component_id)?.layer??"top",M=fSn(t),w=xSn(M),D=t.model_glb_url?"glb":"gltf",A=t.model_wrl_url?"wrl":t.model_stl_url?"stl":"obj",I=Y.useMemo(()=>pSn(t,{layer:S,pcbThickness:o,modelType:w}),[t,S,o,w]),H=ySn(...I.rotation),O=I.position,z=Y.useMemo(()=>{const G=[];return p&&G.push(j.jsx(yet,{gltfUrl:p,position:O,rotation:H,modelOffset:I.modelPosition,modelRotation:I.modelRotation,sourceCoordinateTransform:BX(kN(t,D)),scale:I.scale,modelSize:I.size,modelFitMode:I.fitMode,onHover:l,onUnhover:u,isHovered:r,isTranslucent:t.show_as_translucent_model},`${t.cad_component_id}-gltf-${p}`)),h&&G.push(j.jsx(Q7n,{url:h,position:O,rotation:H,modelOffset:I.modelPosition,modelRotation:I.modelRotation,sourceCoordinateTransform:BX(kN(t,A)),scale:I.scale,modelSize:I.size,modelFitMode:I.fitMode,onHover:l,onUnhover:u,isHovered:r,isTranslucent:t.show_as_translucent_model},`${t.cad_component_id}-mixed-${h}`)),x&&!t.model_jscad&&!t.footprinter_string&&G.push(j.jsx(cSn,{stepUrl:x,position:O,rotation:H,modelOffset:I.modelPosition,modelRotation:I.modelRotation,sourceCoordinateTransform:BX(kN(t,w)),scale:I.scale,modelSize:I.size,modelFitMode:I.fitMode,onHover:l,onUnhover:u,isHovered:r,isTranslucent:t.show_as_translucent_model},`${t.cad_component_id}-step-${x}`)),G},[O,t.cad_component_id,t.footprinter_string,t.model_jscad,t.show_as_translucent_model,p,D,l,u,r,A,I.modelPosition,I.modelRotation,I.scale,I.fitMode,I.size,w,H,x,h]);let V=null;if(z.length>0){if(f>=z.length){if(y)throw y;return null}V=j.jsx(R1e,{fallback:({error:G})=>j.jsx(bSn,{error:G,onError:q=>{b(q),g(K=>Math.max(K,f+1))}}),children:z[f]},`${t.cad_component_id}-fallback-${f}`)}else t.model_jscad?V=j.jsx(Y7n,{jscadPlan:t.model_jscad,positionOffset:O,rotationOffset:H,modelOffset:I.modelPosition,modelRotation:I.modelRotation,sourceCoordinateTransform:BX(kN(t,"jscad")),scale:I.scale,modelSize:I.size,modelFitMode:I.fitMode,onHover:l,onUnhover:u,isHovered:r,isTranslucent:t.show_as_translucent_model},t.cad_component_id):t.footprinter_string&&(V=j.jsx(z7n,{positionOffset:O,rotationOffset:H,footprint:t.footprinter_string,scale:I.scale,onHover:l,onUnhover:u,isHovered:r,isTranslucent:t.show_as_translucent_model}));if(t.show_as_translucent_model){if(!s.translucentModels)return null}else if(d&&!s.throughHoleModels||!d&&!s.smtModels)return null;return j.jsxs(j.Fragment,{children:[V,r&&a?j.jsx(wZe,{position:a,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:_??"<unknown>"}):null]})},Cet={version:"0.0.553"};function PSn(t){t.querySelectorAll("canvas").forEach(e=>e.remove())}var vSn=t=>{t.outputColorSpace=p4,t.toneMapping=GFe,t.toneMappingExposure=1},Met="cadViewerCameraStateSession",Tet=(t,e)=>{try{const n={position:t.position.toArray(),quaternion:t.quaternion.toArray(),up:t.up.toArray(),fov:t.fov??50,target:e.target.toArray()};sessionStorage.setItem(Met,JSON.stringify(n))}catch(n){console.warn("Failed to save camera:",n)}},k1e=(t,e)=>{try{const n=sessionStorage.getItem(Met);if(!n)return!1;const o=JSON.parse(n);if(t.position.fromArray(o.position),t.quaternion.fromArray(o.quaternion),t.up.fromArray(o.up),"fov"in t){const r=t;r.fov=o.fov,r.updateProjectionMatrix?.()}return e.target.fromArray(o.target),e.update(),t.updateMatrixWorld(),!0}catch(n){return console.warn("Failed to restore camera:",n),!1}},wet=Y.createContext(void 0),SSn=({children:t,defaultTarget:e,initialCameraPosition:n})=>{const o=Y.useRef(null),r=Y.useRef(null),[i,s]=Y.useState(null),[a,c]=Y.useState("perspective"),[l,u]=Y.useState(n??null),[_,d]=Y.useState(new a2(0,0,0)),m=Y.useMemo(()=>{const[f,g,y]=n??[5,-5,5],b=Math.hypot(f-e.x,g-e.y,y-e.z);return b>0?b:5},[n,e]),h=Y.useCallback(f=>{const g=[e.x,e.y,e.z],y=r.current,b=o.current;let v=m;switch(y&&b&&(v=y.position.distanceTo(b.target)),f){case"Top Center Angled":{const S=v/Math.sqrt(2);return{position:[e.x,e.y-S,e.z+S],target:g,up:[0,0,1]}}case"Top Down":return{position:[e.x,e.y,e.z+v],target:g,up:[0,0,1]};case"Top Left Corner":return{position:[e.x-v*.6,e.y-v*.6,e.z+v*.6],target:g,up:[0,0,1]};case"Top Right Corner":return{position:[e.x+v*.6,e.y-v*.6,e.z+v*.6],target:g,up:[0,0,1]};case"Left Sideview":return{position:[e.x-v,e.y,e.z],target:g,up:[0,0,1]};case"Right Sideview":return{position:[e.x+v,e.y,e.z],target:g,up:[0,0,1]};case"Front":return{position:[e.x,e.y-v,e.z],target:g,up:[0,0,1]};default:return null}},[m,e,r,o]),p=Y.useCallback(f=>{o.current=f},[]),x=Y.useMemo(()=>({controlsRef:o,mainCameraRef:r,defaultTarget:e,baseDistance:m,controller:i,setController:s,getPresetConfig:h,handleControlsChange:p,cameraType:a,setCameraType:c,cameraPosition:l,setCameraPosition:u,cameraRotation:_,setCameraRotation:d,saveCameraToSession:Tet,loadCameraFromSession:k1e}),[e,m,i,h,p,a,l,_]);return j.jsx(wet.Provider,{value:x,children:t})},uv=()=>{const t=Y.useContext(wet);if(!t)throw new Error("useCameraController must be used within a CameraControllerProvider");return t},CSn=Y.forwardRef(({children:t,scene:e,camera:n,style:o,onCreated:r},i)=>{const{cameraType:s}=uv(),a=Y.useRef(null),[c,l]=Y.useState(null),u=Y.useRef([]),_=Y.useRef(void 0);_.current=r;const d=Y.useRef(null),m=Y.useCallback(f=>{u.current.push(f)},[]),h=Y.useCallback(f=>{u.current=u.current.filter(g=>g!==f)},[]),p=Y.useMemo(()=>new JS,[]);e?.up&&p.up.set(e.up.x,e.up.y,e.up.z);const x=Y.useRef(new sl);return Y.useImperativeHandle(i,()=>x.current),Y.useEffect(()=>{if(!a.current)return;PSn(a.current);const f=new _U({antialias:!0,alpha:!0});vSn(f),f.setSize(a.current.clientWidth,a.current.clientHeight),f.setPixelRatio(window.devicePixelRatio),a.current.appendChild(f.domElement);const g=a.current.clientWidth/a.current.clientHeight,y=s==="perspective"?new np(75,g,.1,1e3):new Mk(-10*g,10*g,10,-10,-1e3,1e3);d.current?(y.position.copy(d.current.position),y.quaternion.copy(d.current.quaternion),y.up.copy(d.current.up)):(n?.up&&y.up.set(n.up[0],n.up[1],n.up[2]),n?.position&&y.position.set(n.position[0],n.position[1],n.position[2]),y.lookAt(0,0,0)),p.add(x.current),window.__TSCIRCUIT_THREE_OBJECT=x.current,l({scene:p,camera:y,renderer:f,rootObject:x.current,addFrameListener:m,removeFrameListener:h}),_.current?.({camera:y,renderer:f});let b;const v=new Kln,S=()=>{const w=v.getElapsedTime(),D=v.getDelta();u.current.forEach(A=>A(w,D)),f.render(p,y),b=requestAnimationFrame(S)};S();const M=()=>{if(a.current){const w=a.current.clientWidth/a.current.clientHeight;y instanceof np?y.aspect=w:y instanceof Mk&&(y.left=-10*w,y.right=10*w,y.top=10,y.bottom=-10),y.updateProjectionMatrix(),f.setSize(a.current.clientWidth,a.current.clientHeight)}};return window.addEventListener("resize",M),()=>{d.current={position:y.position.clone(),quaternion:y.quaternion.clone(),up:y.up.clone()},window.removeEventListener("resize",M),cancelAnimationFrame(b),a.current&&f.domElement&&a.current.removeChild(f.domElement),f.dispose(),p.remove(x.current),window.__TSCIRCUIT_THREE_OBJECT===x.current&&(window.__TSCIRCUIT_THREE_OBJECT=void 0)}},[p,m,h,s]),j.jsx("div",{ref:a,style:{width:"100%",height:"100%",...o},children:c&&j.jsx(TZe.Provider,{value:c,children:j.jsx(F7n,{children:t})})})}),MSn=({autoRotate:t,autoRotateSpeed:e,onStart:n,panSpeed:o,rotateSpeed:r,zoomSpeed:i,enableDamping:s,dampingFactor:a,target:c,onControlsChange:l})=>{const{camera:u,renderer:_}=_2(),d=Y.useMemo(()=>!u||!_?null:new Dun(u,_.domElement),[u,_]);return Y.useEffect(()=>(l?.(d??null),()=>l?.(null)),[d,l]),Y.useEffect(()=>{if(!d)return;const m=()=>{l?.(d)};return d.addEventListener("change",m),()=>{d.removeEventListener("change",m)}},[d,l]),Y.useEffect(()=>{d&&(d.autoRotate=t||!1,d.autoRotateSpeed=e||1,o!==void 0&&(d.panSpeed=o),r!==void 0&&(d.rotateSpeed=r),i!==void 0&&(d.zoomSpeed=i),s!==void 0&&(d.enableDamping=s),a!==void 0&&(d.dampingFactor=a),d.zoomToCursor=!0,d.mouseButtons={LEFT:zP.ROTATE,MIDDLE:zP.PAN,RIGHT:null},c&&(d.target.set(c[0],c[1],c[2]),d.update()))},[d,t,e,o,r,i,s,a,c]),Y.useEffect(()=>{if(!(!d||!n))return d.addEventListener("start",n),()=>{d.removeEventListener("start",n)}},[d,n]),Y.useEffect(()=>{if(d)return()=>{d.dispose()}},[d]),fN(()=>{d?.update()},[d]),null},TSn=`
5154
5154
  varying vec3 worldPosition;
5155
5155
  void main() {
5156
5156
  worldPosition = (modelMatrix * vec4(position, 1.0)).xyz;
@@ -5686,7 +5686,7 @@ test("${l} should solve problem correctly", () => {
5686
5686
  // Add more specific assertions based on expected output
5687
5687
  // expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
5688
5688
  })
5689
- `,_=new Blob([u],{type:"text/plain"}),d=URL.createObjectURL(_),m=document.createElement("a");m.href=d,m.download=`${l}.test.ts`,m.click(),URL.revokeObjectURL(d)}catch(c){alert(`Error generating test.ts for ${t.constructor.name}: ${c instanceof Error?c.message:String(c)}`)}o(!1)};return j.jsxs("div",{className:`relative ${e}`,ref:r,children:[j.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>o(!n),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),n&&j.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:[j.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:i,children:"Download JSON"}),j.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),j.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},Ddt=t=>t.activeSubSolver?[t,...Ddt(t.activeSubSolver)]:[t],_Jn=({solver:t})=>{const e=Ddt(t);return j.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>j.jsxs("div",{className:"flex items-center",children:[o>0&&j.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),j.jsx(uJn,{solver:n})]},n.constructor.name))})},dJn=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:r})=>{const[i,s]=Y.useReducer(p=>!p,!1),a=Y.useRef(void 0),c=()=>{!t.solved&&!t.failed&&(t.step(),e())},l=()=>{!t.solved&&!t.failed&&(o&&o(t),t.solve(),e(),r&&r(t))},u=()=>{i?(a.current&&(clearInterval(a.current),a.current=void 0),s()):(s(),a.current=setInterval(()=>{if(t.solved||t.failed){a.current&&(clearInterval(a.current),a.current=void 0),s(),e(),r&&t.solved&&r(t);return}t.step(),e()},n))},_=()=>{const p=t;if(p.getCurrentPhase&&!t.solved&&!t.failed){const x=p.getCurrentPhase();for(;p.getCurrentPhase()===x&&!t.solved&&!t.failed;)t.step();e()}},d=()=>{if(t.solved||t.failed||i)return;const p=window.prompt("Step until which iteration?",`${t.iterations}`);if(p===null)return;const x=Number(p);if(!Number.isFinite(x)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<x&&!t.solved&&!t.failed;)t.step();e(),t.solved&&r&&r(t)};Y.useEffect(()=>()=>{a.current&&clearInterval(a.current)},[]),Y.useEffect(()=>{(t.solved||t.failed)&&i&&(a.current&&(clearInterval(a.current),a.current=void 0),s())},[t.solved,t.failed,i]);const m=t.getCurrentPhase!==void 0,h=m?t.getCurrentPhase():null;return j.jsxs("div",{className:"space-y-2 p-2 border-b",children:[j.jsx("div",{className:"flex items-center",children:j.jsx(_Jn,{solver:t})}),j.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[j.jsx("button",{onClick:c,disabled:t.solved||t.failed||i,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),j.jsx("button",{onClick:l,disabled:t.solved||t.failed||i,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),j.jsx("button",{onClick:u,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${i?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:i?"Stop":"Animate"}),j.jsx("button",{onClick:d,disabled:t.solved||t.failed||i,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"}),m&&j.jsx("button",{onClick:_,disabled:t.solved||t.failed||i,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),j.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&j.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),h&&j.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",j.jsx("span",{className:"font-medium",children:h})]}),t.solved&&j.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&j.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&j.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},hJn=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},mJn=(t,e)=>{const o=t.pipelineDef[e].solverName,r=hJn(t,e),i=t[o],s=t.firstIterationOfPhase?.[o]??null,a=t.iterations;let c=0;if(r==="Completed"){const d=t.pipelineDef[e+1],m=d?t.firstIterationOfPhase?.[d.solverName]:void 0;m!==void 0&&s!==null?c=m-s:s!==null&&(c=a-s)}else r==="In Progress"&&s!==null&&(c=a-s);const l=t.timeSpentOnPhase?.[o]??0;let u=0;r==="Completed"?u=1:r==="In Progress"&&i&&(u=i.progress??0);const _=i?.stats??null;return{index:e,name:o,status:r,firstIteration:s,iterations:c,progress:u,timeSpent:l,stats:_&&Object.keys(_).length>0?_:null,solverInstance:i??null}},pJn=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return j.jsx("span",{className:`font-medium ${e[t]}`,children:t})},fJn=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return j.jsxs("div",{className:"flex items-center gap-2",children:[j.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:j.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),j.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},xJn=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),gJn=({stats:t})=>{if(!t||Object.keys(t).length===0)return j.jsx("span",{children:"-"});const e=Object.entries(t),n=xJn(t);return j.jsxs("details",{className:"cursor-pointer",children:[j.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),j.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,r])=>j.jsxs("div",{children:[o,": ",String(r)]},o))})]})},Dye=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(Dye);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=Dye(o));return e},yJn=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=Dye(t.getConstructorParams()),o=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),r=URL.createObjectURL(o),i=document.createElement("a");i.href=r,i.download=`${e}_input.json`,i.click(),URL.revokeObjectURL(r)}catch(n){alert(`Error downloading input for ${e}: ${n instanceof Error?n.message:String(n)}`)}},bJn=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((a,c)=>mJn(t,c)),r=a=>{e?.(a)},i=a=>{a.solverInstance&&(n?n(a.solverInstance,a.name):yJn(a.solverInstance,a.name))},s=a=>`${(a/1e3).toFixed(2)}s`;return j.jsxs("div",{className:"border-t border-gray-200",children:[j.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:j.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),j.jsx("div",{className:"overflow-x-auto",children:j.jsxs("table",{className:"w-full text-sm",children:[j.jsx("thead",{children:j.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),j.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",j.jsx("sub",{children:"0"})]}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),j.jsx("tbody",{children:o.map(a=>j.jsxs("tr",{className:`border-b border-gray-100 ${a.status==="In Progress"?"bg-yellow-50":""}`,children:[j.jsx("td",{className:"px-4 py-2",children:j.jsxs("div",{className:"flex items-center gap-2",children:[j.jsx("span",{className:"text-gray-400 w-6",children:String(a.index+1).padStart(2,"0")}),j.jsx("button",{onClick:()=>r(a.name),disabled:a.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 ${a.name} completes`,children:j.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:j.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"})})}),j.jsx("span",{className:"font-medium text-gray-900",children:a.name})]})}),j.jsx("td",{className:"px-4 py-2",children:j.jsx(pJn,{status:a.status})}),j.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:a.firstIteration!==null?a.firstIteration:""}),j.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.iterations}),j.jsx("td",{className:"px-4 py-2",children:j.jsx(fJn,{progress:a.progress})}),j.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(a.timeSpent)}),j.jsx("td",{className:"px-4 py-2 text-gray-500",children:j.jsx(gJn,{stats:a.stats})}),j.jsx("td",{className:"px-4 py-2",children:a.solverInstance?j.jsxs("button",{onClick:()=>i(a),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${a.name}`,children:[j.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:j.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"})}),j.jsx("span",{children:"Input"})]}):null})]},a.name))})]})})]})},PJn=class extends cr.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 vJn({graphics:t}){const e=t.points??[],n=t.lines??[],o=t.rects??[],r=t.circles??[],i=t.texts??[];let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY;const u=(x,f)=>{typeof x=="number"&&(x<s&&(s=x),x>c&&(c=x)),typeof f=="number"&&(f<a&&(a=f),f>l&&(l=f))};for(const x of e)u(x.x,x.y);for(const x of n){const f=x.points??[];for(const g of f)u(g.x,g.y)}for(const x of o){const f=x.x??0,g=x.y??0,y=x.width??0,b=x.height??0;u(f,g),u(f+y,g+b)}for(const x of r){const f=x.x??0,g=x.y??0,y=x.radius??1;u(f-y,g-y),u(f+y,g+y)}for(const x of i)u(x.x,x.y);(!isFinite(s)||!isFinite(a)||!isFinite(c)||!isFinite(l))&&(s=-20,a=-20,c=20,l=20);const _=10,d=s-_,m=a-_,h=Math.max(1,c-s+2*_),p=Math.max(1,l-a+2*_);return j.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${d} ${m} ${h} ${p}`,role:"img","aria-label":"Graphics fallback",children:[o.map((x,f)=>j.jsx("rect",{x:x.x??0,y:x.y??0,width:x.width??0,height:x.height??0,fill:"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1},`rect-${f}`)),n.map((x,f)=>j.jsx("polyline",{fill:"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1,points:(x.points??[]).map(g=>`${g.x??0},${g.y??0}`).join(" ")},`line-${f}`)),r.map((x,f)=>j.jsx("circle",{cx:x.x??0,cy:x.y??0,r:x.radius??1.5,fill:x.fillColor??"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1},`circle-${f}`)),e.map((x,f)=>j.jsx("circle",{cx:x.x??0,cy:x.y??0,r:x.radius??1.5,fill:x.color??"black"},`point-${f}`)),i.map((x,f)=>j.jsx("text",{x:x.x??0,y:x.y??0,fontSize:x.fontSize??10,fill:x.color??"black",children:x.text??""},`text-${f}`))]})}var SJn=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[r,i]=Y.useReducer(u=>u+1,0),s=Y.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(u){return console.error("Visualization error:",u),{points:[],lines:[],rects:[],circles:[]}}},[t,r]),a=Y.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);Y.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const u=document.createElement("script");u.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(u)}},[]);const c=t.pipelineDef!==void 0,l=u=>{const _=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&_.currentPipelineStepIndex<=_.pipelineDef.findIndex(d=>d.solverName===u);)t.step();i()}};return j.jsxs("div",{children:[j.jsx(dJn,{solver:t,triggerRender:i,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),a?j.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):j.jsx(PJn,{fallback:j.jsx(vJn,{graphics:s}),children:j.jsx(lJn,{graphics:s})}),c&&j.jsx(bJn,{solver:t,onStepUntilPhase:l})]})};const CJn=()=>{Y.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const e=document.createElement("div");e.className="hidden",document.body.appendChild(e);const n=window.getComputedStyle(e).display==="none";if(document.body.removeChild(e),n)return;const o=document.createElement("script");o.id=t,o.src="https://cdn.tailwindcss.com",document.head.appendChild(o)},[])},MJn=t=>t.toLowerCase().includes("pack")?zDn:t.toLowerCase().includes("rout")?XDn:MDn,TJn=({solverEvents:t=[]})=>{const[e,n]=Y.useState(null);CJn();const o=Y.useMemo(()=>{const a=new Map;for(const c of t){const l=`${c.componentName}-${c.solverName}`;a.set(l,c)}return a},[t]),r=Y.useMemo(()=>Array.from(o.keys()),[o]),i=e?o.get(e):null,s=Y.useMemo(()=>{if(!i)return{instance:null,error:null,classFound:!1};const a=$ie[i.solverName];if(!a)return{instance:null,error:`Solver class "${i.solverName}" not found in SOLVERS registry. Available: ${Object.keys($ie).join(", ")}`,classFound:!1};try{const c=i.solverParams,l=c?.input!==void 0?c.input:c;return{instance:new a(l),error:null,classFound:!0}}catch(c){const l=c instanceof Error?c.message:String(c);return console.error("Failed to reconstruct solver:",c),{instance:null,error:`Failed to instantiate solver: ${l}`,classFound:!0}}},[i]);return t.length===0?j.jsx("div",{className:"rf-p-4",children:j.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:j.jsxs("div",{className:"rf-p-4",children:[j.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),j.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."})]})})}):j.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[j.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[j.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:[r.length," ",r.length===1?"Solver":"Solvers"]}),r.map(a=>{const c=o.get(a),l=e===a;return j.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${l?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>n(a),children:(()=>{const u=MJn(c.solverName);return j.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[j.jsx(u,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),j.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[j.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:c.componentName}),j.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:c.solverName})]})]})})()},a)})]}),j.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:i?s.instance?j.jsx(M5,{fallback:j.jsx("div",{className:"rf-p-4",children:j.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[j.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),j.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",i.solverName]})]})}),children:j.jsx(SJn,{solver:s.instance})}):j.jsxs("div",{className:"rf-p-4",children:[j.jsxs("div",{className:"rf-mb-4",children:[j.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:i.solverName}),j.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",i.componentName]})]}),s.error&&j.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:j.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),j.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[j.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:j.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),j.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:j.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(i.solverParams,null,2)})})]})]}):j.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:j.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},Adt=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{Y.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{EW.captureException(o)}catch{}}},[t,e]),Y.useEffect(()=>{if(n&&n.length>0)for(const o of n){const r=new Error(o.message||"Circuit JSON Error");o.stack&&(r.stack=o.stack);try{EW.captureException(r,{error_type:o.type})}catch{}}},[n])},Rdt="0.0.1829",wJn={version:Rdt},PY=OIe()(FIe(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:e=>{t({lastRunEvalVersion:e})}}),{name:"runframe-runner-store"})),EJn=t=>{const[e,n]=Y.useState([]),[o,r]=Y.useState(null),[i,s]=Y.useState(""),[a,c]=RT("eval-version-selection",null),l=PY(m=>m.setLastRunEvalVersion),u=PY(m=>m.lastRunEvalVersion);return Y.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(m=>m.json()).then(m=>{if(Array.isArray(m?.versions)){let h=[...m.versions];m.tags?.latest&&(r(m.tags.latest),h=h.filter(p=>p!==m.tags.latest)),n(h)}}).catch(()=>{})},[t]),Y.useEffect(()=>{t&&(a?(window.TSCIRCUIT_LATEST_EVAL_VERSION=a,l(a)):o&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=o,l(o)))},[t,a,o]),{versions:Y.useMemo(()=>e.filter(m=>m.includes(i)).slice(0,50),[e,i]),latestVersion:o,lastRunEvalVersion:u,search:i,setSearch:s,selectVersion:m=>{c(m),s("")}}},DJn=({snippetNames:t,onSelect:e,onCancel:n,isOpen:o})=>{const[r,i]=Y.useState(""),[s,a]=Y.useState("");if(!o)return null;const c=t.filter(_=>_.toLowerCase().includes(s.toLowerCase())),l=s&&!t.includes(s),u=_=>{_.key==="Enter"&&(c.length===1?i(c[0]):l&&i(s))};return j.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:j.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[j.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),j.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:s,onChange:_=>a(_.target.value),onKeyDown:u}),j.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[c.map(_=>j.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${r===_?"bg-blue-50":""}`,onClick:()=>i(_),children:_},_)),l&&j.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${r===s?"bg-blue-50":""}`,onClick:()=>i(s),children:['Create new "',s,'"']})]}),j.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[j.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:n,children:"Cancel"}),j.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>r&&e(r),disabled:!r,children:r===s?`Create "${r}"`:`Save to ${r}`})]})]})})},AJn=t=>{const e=Y.useRef(null),n=eu(o=>o.recentEvents);Y.useEffect(()=>{if(n.length===0)return;const o=n[0];o.event_id!==e.current&&(t(o),e.current=o.event_id)},[n,t])};function RJn(t){const e=kJn(t),n=Y.forwardRef((o,r)=>{const{children:i,...s}=o,a=Y.Children.toArray(i),c=a.find(HJn);if(c){const l=c.props.children,u=a.map(_=>_===c?Y.Children.count(l)>1?Y.Children.only(null):Y.isValidElement(l)?l.props.children:null:_);return j.jsx(e,{...s,ref:r,children:Y.isValidElement(l)?Y.cloneElement(l,void 0,u):null})}return j.jsx(e,{...s,ref:r,children:i})});return n.displayName=`${t}.Slot`,n}function kJn(t){const e=Y.forwardRef((n,o)=>{const{children:r,...i}=n;if(Y.isValidElement(r)){const s=LJn(r),a=IJn(i,r.props);return r.type!==Y.Fragment&&(a.ref=o?Rx(o,s):s),Y.cloneElement(r,a)}return Y.Children.count(r)>1?Y.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var NJn=Symbol("radix.slottable");function HJn(t){return Y.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===NJn}function IJn(t,e){const n={...e};for(const o in e){const r=t[o],i=e[o];/^on[A-Z]/.test(o)?r&&i?n[o]=(...a)=>{const c=i(...a);return r(...a),c}:r&&(n[o]=r):o==="style"?n[o]={...r,...i}:o==="className"&&(n[o]=[r,i].filter(Boolean).join(" "))}return{...t,...n}}function LJn(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var vY="Dialog",[kdt,Ndt]=d4(vY),[OJn,B4]=kdt(vY),Hdt=t=>{const{__scopeDialog:e,children:n,open:o,defaultOpen:r,onOpenChange:i,modal:s=!0}=t,a=Y.useRef(null),c=Y.useRef(null),[l,u]=DP({prop:o,defaultProp:r??!1,onChange:i,caller:vY});return j.jsx(OJn,{scope:e,triggerRef:a,contentRef:c,contentId:Jp(),titleId:Jp(),descriptionId:Jp(),open:l,onOpenChange:u,onOpenToggle:Y.useCallback(()=>u(_=>!_),[u]),modal:s,children:n})};Hdt.displayName=vY;var Idt="DialogTrigger",Ldt=Y.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,r=B4(Idt,n),i=tu(e,r.triggerRef);return j.jsx(Cc.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.contentId,"data-state":kye(r.open),...o,ref:i,onClick:Vr(t.onClick,r.onOpenToggle)})});Ldt.displayName=Idt;var Aye="DialogPortal",[FJn,Odt]=kdt(Aye,{forceMount:void 0}),Fdt=t=>{const{__scopeDialog:e,forceMount:n,children:o,container:r}=t,i=B4(Aye,e);return j.jsx(FJn,{scope:e,forceMount:n,children:Y.Children.map(o,s=>j.jsx(Fg,{present:n||i.open,children:j.jsx(Lj,{asChild:!0,container:r,children:s})}))})};Fdt.displayName=Aye;var SY="DialogOverlay",Bdt=Y.forwardRef((t,e)=>{const n=Odt(SY,t.__scopeDialog),{forceMount:o=n.forceMount,...r}=t,i=B4(SY,t.__scopeDialog);return i.modal?j.jsx(Fg,{present:o||i.open,children:j.jsx(zJn,{...r,ref:e})}):null});Bdt.displayName=SY;var BJn=RJn("DialogOverlay.RemoveScroll"),zJn=Y.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,r=B4(SY,n);return j.jsx(Uj,{as:BJn,allowPinchZoom:!0,shards:[r.contentRef],children:j.jsx(Cc.div,{"data-state":kye(r.open),...o,ref:e,style:{pointerEvents:"auto",...o.style}})})}),Z8="DialogContent",zdt=Y.forwardRef((t,e)=>{const n=Odt(Z8,t.__scopeDialog),{forceMount:o=n.forceMount,...r}=t,i=B4(Z8,t.__scopeDialog);return j.jsx(Fg,{present:o||i.open,children:i.modal?j.jsx(VJn,{...r,ref:e}):j.jsx($Jn,{...r,ref:e})})});zdt.displayName=Z8;var VJn=Y.forwardRef((t,e)=>{const n=B4(Z8,t.__scopeDialog),o=Y.useRef(null),r=tu(e,n.contentRef,o);return Y.useEffect(()=>{const i=o.current;if(i)return J2e(i)},[]),j.jsx(Vdt,{...t,ref:r,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Vr(t.onCloseAutoFocus,i=>{i.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Vr(t.onPointerDownOutside,i=>{const s=i.detail.originalEvent,a=s.button===0&&s.ctrlKey===!0;(s.button===2||a)&&i.preventDefault()}),onFocusOutside:Vr(t.onFocusOutside,i=>i.preventDefault())})}),$Jn=Y.forwardRef((t,e)=>{const n=B4(Z8,t.__scopeDialog),o=Y.useRef(!1),r=Y.useRef(!1);return j.jsx(Vdt,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{t.onCloseAutoFocus?.(i),i.defaultPrevented||(o.current||n.triggerRef.current?.focus(),i.preventDefault()),o.current=!1,r.current=!1},onInteractOutside:i=>{t.onInteractOutside?.(i),i.defaultPrevented||(o.current=!0,i.detail.originalEvent.type==="pointerdown"&&(r.current=!0));const s=i.target;n.triggerRef.current?.contains(s)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&r.current&&i.preventDefault()}})}),Vdt=Y.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:o,onOpenAutoFocus:r,onCloseAutoFocus:i,...s}=t,a=B4(Z8,n),c=Y.useRef(null),l=tu(e,c);return R2e(),j.jsxs(j.Fragment,{children:[j.jsx(Sj,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:r,onUnmountAutoFocus:i,children:j.jsx(ZN,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":kye(a.open),...s,ref:l,onDismiss:()=>a.onOpenChange(!1)})}),j.jsxs(j.Fragment,{children:[j.jsx(UJn,{titleId:a.titleId}),j.jsx(jJn,{contentRef:c,descriptionId:a.descriptionId})]})]})}),Rye="DialogTitle",$dt=Y.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,r=B4(Rye,n);return j.jsx(Cc.h2,{id:r.titleId,...o,ref:e})});$dt.displayName=Rye;var Wdt="DialogDescription",Udt=Y.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,r=B4(Wdt,n);return j.jsx(Cc.p,{id:r.descriptionId,...o,ref:e})});Udt.displayName=Wdt;var Xdt="DialogClose",jdt=Y.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,r=B4(Xdt,n);return j.jsx(Cc.button,{type:"button",...o,ref:e,onClick:Vr(t.onClick,()=>r.onOpenChange(!1))})});jdt.displayName=Xdt;function kye(t){return t?"open":"closed"}var Gdt="DialogTitleWarning",[WJn,Ydt]=EZt(Gdt,{contentName:Z8,titleName:Rye,docsSlug:"dialog"}),UJn=({titleId:t})=>{const e=Ydt(Gdt),n=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
5689
+ `,_=new Blob([u],{type:"text/plain"}),d=URL.createObjectURL(_),m=document.createElement("a");m.href=d,m.download=`${l}.test.ts`,m.click(),URL.revokeObjectURL(d)}catch(c){alert(`Error generating test.ts for ${t.constructor.name}: ${c instanceof Error?c.message:String(c)}`)}o(!1)};return j.jsxs("div",{className:`relative ${e}`,ref:r,children:[j.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>o(!n),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),n&&j.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:[j.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:i,children:"Download JSON"}),j.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),j.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},Ddt=t=>t.activeSubSolver?[t,...Ddt(t.activeSubSolver)]:[t],_Jn=({solver:t})=>{const e=Ddt(t);return j.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>j.jsxs("div",{className:"flex items-center",children:[o>0&&j.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),j.jsx(uJn,{solver:n})]},n.constructor.name))})},dJn=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:r})=>{const[i,s]=Y.useReducer(p=>!p,!1),a=Y.useRef(void 0),c=()=>{!t.solved&&!t.failed&&(t.step(),e())},l=()=>{!t.solved&&!t.failed&&(o&&o(t),t.solve(),e(),r&&r(t))},u=()=>{i?(a.current&&(clearInterval(a.current),a.current=void 0),s()):(s(),a.current=setInterval(()=>{if(t.solved||t.failed){a.current&&(clearInterval(a.current),a.current=void 0),s(),e(),r&&t.solved&&r(t);return}t.step(),e()},n))},_=()=>{const p=t;if(p.getCurrentPhase&&!t.solved&&!t.failed){const x=p.getCurrentPhase();for(;p.getCurrentPhase()===x&&!t.solved&&!t.failed;)t.step();e()}},d=()=>{if(t.solved||t.failed||i)return;const p=window.prompt("Step until which iteration?",`${t.iterations}`);if(p===null)return;const x=Number(p);if(!Number.isFinite(x)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<x&&!t.solved&&!t.failed;)t.step();e(),t.solved&&r&&r(t)};Y.useEffect(()=>()=>{a.current&&clearInterval(a.current)},[]),Y.useEffect(()=>{(t.solved||t.failed)&&i&&(a.current&&(clearInterval(a.current),a.current=void 0),s())},[t.solved,t.failed,i]);const m=t.getCurrentPhase!==void 0,h=m?t.getCurrentPhase():null;return j.jsxs("div",{className:"space-y-2 p-2 border-b",children:[j.jsx("div",{className:"flex items-center",children:j.jsx(_Jn,{solver:t})}),j.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[j.jsx("button",{onClick:c,disabled:t.solved||t.failed||i,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),j.jsx("button",{onClick:l,disabled:t.solved||t.failed||i,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),j.jsx("button",{onClick:u,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${i?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:i?"Stop":"Animate"}),j.jsx("button",{onClick:d,disabled:t.solved||t.failed||i,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"}),m&&j.jsx("button",{onClick:_,disabled:t.solved||t.failed||i,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),j.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&j.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),h&&j.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",j.jsx("span",{className:"font-medium",children:h})]}),t.solved&&j.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&j.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&j.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},hJn=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},mJn=(t,e)=>{const o=t.pipelineDef[e].solverName,r=hJn(t,e),i=t[o],s=t.firstIterationOfPhase?.[o]??null,a=t.iterations;let c=0;if(r==="Completed"){const d=t.pipelineDef[e+1],m=d?t.firstIterationOfPhase?.[d.solverName]:void 0;m!==void 0&&s!==null?c=m-s:s!==null&&(c=a-s)}else r==="In Progress"&&s!==null&&(c=a-s);const l=t.timeSpentOnPhase?.[o]??0;let u=0;r==="Completed"?u=1:r==="In Progress"&&i&&(u=i.progress??0);const _=i?.stats??null;return{index:e,name:o,status:r,firstIteration:s,iterations:c,progress:u,timeSpent:l,stats:_&&Object.keys(_).length>0?_:null,solverInstance:i??null}},pJn=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return j.jsx("span",{className:`font-medium ${e[t]}`,children:t})},fJn=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return j.jsxs("div",{className:"flex items-center gap-2",children:[j.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:j.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),j.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},xJn=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),gJn=({stats:t})=>{if(!t||Object.keys(t).length===0)return j.jsx("span",{children:"-"});const e=Object.entries(t),n=xJn(t);return j.jsxs("details",{className:"cursor-pointer",children:[j.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),j.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,r])=>j.jsxs("div",{children:[o,": ",String(r)]},o))})]})},Dye=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(Dye);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=Dye(o));return e},yJn=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=Dye(t.getConstructorParams()),o=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),r=URL.createObjectURL(o),i=document.createElement("a");i.href=r,i.download=`${e}_input.json`,i.click(),URL.revokeObjectURL(r)}catch(n){alert(`Error downloading input for ${e}: ${n instanceof Error?n.message:String(n)}`)}},bJn=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((a,c)=>mJn(t,c)),r=a=>{e?.(a)},i=a=>{a.solverInstance&&(n?n(a.solverInstance,a.name):yJn(a.solverInstance,a.name))},s=a=>`${(a/1e3).toFixed(2)}s`;return j.jsxs("div",{className:"border-t border-gray-200",children:[j.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:j.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),j.jsx("div",{className:"overflow-x-auto",children:j.jsxs("table",{className:"w-full text-sm",children:[j.jsx("thead",{children:j.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),j.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",j.jsx("sub",{children:"0"})]}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),j.jsx("tbody",{children:o.map(a=>j.jsxs("tr",{className:`border-b border-gray-100 ${a.status==="In Progress"?"bg-yellow-50":""}`,children:[j.jsx("td",{className:"px-4 py-2",children:j.jsxs("div",{className:"flex items-center gap-2",children:[j.jsx("span",{className:"text-gray-400 w-6",children:String(a.index+1).padStart(2,"0")}),j.jsx("button",{onClick:()=>r(a.name),disabled:a.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 ${a.name} completes`,children:j.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:j.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"})})}),j.jsx("span",{className:"font-medium text-gray-900",children:a.name})]})}),j.jsx("td",{className:"px-4 py-2",children:j.jsx(pJn,{status:a.status})}),j.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:a.firstIteration!==null?a.firstIteration:""}),j.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.iterations}),j.jsx("td",{className:"px-4 py-2",children:j.jsx(fJn,{progress:a.progress})}),j.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(a.timeSpent)}),j.jsx("td",{className:"px-4 py-2 text-gray-500",children:j.jsx(gJn,{stats:a.stats})}),j.jsx("td",{className:"px-4 py-2",children:a.solverInstance?j.jsxs("button",{onClick:()=>i(a),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${a.name}`,children:[j.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:j.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"})}),j.jsx("span",{children:"Input"})]}):null})]},a.name))})]})})]})},PJn=class extends cr.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 vJn({graphics:t}){const e=t.points??[],n=t.lines??[],o=t.rects??[],r=t.circles??[],i=t.texts??[];let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY;const u=(x,f)=>{typeof x=="number"&&(x<s&&(s=x),x>c&&(c=x)),typeof f=="number"&&(f<a&&(a=f),f>l&&(l=f))};for(const x of e)u(x.x,x.y);for(const x of n){const f=x.points??[];for(const g of f)u(g.x,g.y)}for(const x of o){const f=x.x??0,g=x.y??0,y=x.width??0,b=x.height??0;u(f,g),u(f+y,g+b)}for(const x of r){const f=x.x??0,g=x.y??0,y=x.radius??1;u(f-y,g-y),u(f+y,g+y)}for(const x of i)u(x.x,x.y);(!isFinite(s)||!isFinite(a)||!isFinite(c)||!isFinite(l))&&(s=-20,a=-20,c=20,l=20);const _=10,d=s-_,m=a-_,h=Math.max(1,c-s+2*_),p=Math.max(1,l-a+2*_);return j.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${d} ${m} ${h} ${p}`,role:"img","aria-label":"Graphics fallback",children:[o.map((x,f)=>j.jsx("rect",{x:x.x??0,y:x.y??0,width:x.width??0,height:x.height??0,fill:"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1},`rect-${f}`)),n.map((x,f)=>j.jsx("polyline",{fill:"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1,points:(x.points??[]).map(g=>`${g.x??0},${g.y??0}`).join(" ")},`line-${f}`)),r.map((x,f)=>j.jsx("circle",{cx:x.x??0,cy:x.y??0,r:x.radius??1.5,fill:x.fillColor??"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1},`circle-${f}`)),e.map((x,f)=>j.jsx("circle",{cx:x.x??0,cy:x.y??0,r:x.radius??1.5,fill:x.color??"black"},`point-${f}`)),i.map((x,f)=>j.jsx("text",{x:x.x??0,y:x.y??0,fontSize:x.fontSize??10,fill:x.color??"black",children:x.text??""},`text-${f}`))]})}var SJn=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[r,i]=Y.useReducer(u=>u+1,0),s=Y.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(u){return console.error("Visualization error:",u),{points:[],lines:[],rects:[],circles:[]}}},[t,r]),a=Y.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);Y.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const u=document.createElement("script");u.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(u)}},[]);const c=t.pipelineDef!==void 0,l=u=>{const _=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&_.currentPipelineStepIndex<=_.pipelineDef.findIndex(d=>d.solverName===u);)t.step();i()}};return j.jsxs("div",{children:[j.jsx(dJn,{solver:t,triggerRender:i,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),a?j.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):j.jsx(PJn,{fallback:j.jsx(vJn,{graphics:s}),children:j.jsx(lJn,{graphics:s})}),c&&j.jsx(bJn,{solver:t,onStepUntilPhase:l})]})};const CJn=()=>{Y.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const e=document.createElement("div");e.className="hidden",document.body.appendChild(e);const n=window.getComputedStyle(e).display==="none";if(document.body.removeChild(e),n)return;const o=document.createElement("script");o.id=t,o.src="https://cdn.tailwindcss.com",document.head.appendChild(o)},[])},MJn=t=>t.toLowerCase().includes("pack")?zDn:t.toLowerCase().includes("rout")?XDn:MDn,TJn=({solverEvents:t=[]})=>{const[e,n]=Y.useState(null);CJn();const o=Y.useMemo(()=>{const a=new Map;for(const c of t){const l=`${c.componentName}-${c.solverName}`;a.set(l,c)}return a},[t]),r=Y.useMemo(()=>Array.from(o.keys()),[o]),i=e?o.get(e):null,s=Y.useMemo(()=>{if(!i)return{instance:null,error:null,classFound:!1};const a=$ie[i.solverName];if(!a)return{instance:null,error:`Solver class "${i.solverName}" not found in SOLVERS registry. Available: ${Object.keys($ie).join(", ")}`,classFound:!1};try{const c=i.solverParams,l=c?.input!==void 0?c.input:c;return{instance:new a(l),error:null,classFound:!0}}catch(c){const l=c instanceof Error?c.message:String(c);return console.error("Failed to reconstruct solver:",c),{instance:null,error:`Failed to instantiate solver: ${l}`,classFound:!0}}},[i]);return t.length===0?j.jsx("div",{className:"rf-p-4",children:j.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:j.jsxs("div",{className:"rf-p-4",children:[j.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),j.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."})]})})}):j.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[j.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[j.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:[r.length," ",r.length===1?"Solver":"Solvers"]}),r.map(a=>{const c=o.get(a),l=e===a;return j.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${l?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>n(a),children:(()=>{const u=MJn(c.solverName);return j.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[j.jsx(u,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),j.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[j.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:c.componentName}),j.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:c.solverName})]})]})})()},a)})]}),j.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:i?s.instance?j.jsx(M5,{fallback:j.jsx("div",{className:"rf-p-4",children:j.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[j.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),j.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",i.solverName]})]})}),children:j.jsx(SJn,{solver:s.instance})}):j.jsxs("div",{className:"rf-p-4",children:[j.jsxs("div",{className:"rf-mb-4",children:[j.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:i.solverName}),j.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",i.componentName]})]}),s.error&&j.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:j.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),j.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[j.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:j.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),j.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:j.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(i.solverParams,null,2)})})]})]}):j.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:j.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},Adt=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{Y.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{EW.captureException(o)}catch{}}},[t,e]),Y.useEffect(()=>{if(n&&n.length>0)for(const o of n){const r=new Error(o.message||"Circuit JSON Error");o.stack&&(r.stack=o.stack);try{EW.captureException(r,{error_type:o.type})}catch{}}},[n])},Rdt="0.0.1831",wJn={version:Rdt},PY=OIe()(FIe(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:e=>{t({lastRunEvalVersion:e})}}),{name:"runframe-runner-store"})),EJn=t=>{const[e,n]=Y.useState([]),[o,r]=Y.useState(null),[i,s]=Y.useState(""),[a,c]=RT("eval-version-selection",null),l=PY(m=>m.setLastRunEvalVersion),u=PY(m=>m.lastRunEvalVersion);return Y.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(m=>m.json()).then(m=>{if(Array.isArray(m?.versions)){let h=[...m.versions];m.tags?.latest&&(r(m.tags.latest),h=h.filter(p=>p!==m.tags.latest)),n(h)}}).catch(()=>{})},[t]),Y.useEffect(()=>{t&&(a?(window.TSCIRCUIT_LATEST_EVAL_VERSION=a,l(a)):o&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=o,l(o)))},[t,a,o]),{versions:Y.useMemo(()=>e.filter(m=>m.includes(i)).slice(0,50),[e,i]),latestVersion:o,lastRunEvalVersion:u,search:i,setSearch:s,selectVersion:m=>{c(m),s("")}}},DJn=({snippetNames:t,onSelect:e,onCancel:n,isOpen:o})=>{const[r,i]=Y.useState(""),[s,a]=Y.useState("");if(!o)return null;const c=t.filter(_=>_.toLowerCase().includes(s.toLowerCase())),l=s&&!t.includes(s),u=_=>{_.key==="Enter"&&(c.length===1?i(c[0]):l&&i(s))};return j.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:j.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[j.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),j.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:s,onChange:_=>a(_.target.value),onKeyDown:u}),j.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[c.map(_=>j.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${r===_?"bg-blue-50":""}`,onClick:()=>i(_),children:_},_)),l&&j.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${r===s?"bg-blue-50":""}`,onClick:()=>i(s),children:['Create new "',s,'"']})]}),j.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[j.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:n,children:"Cancel"}),j.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>r&&e(r),disabled:!r,children:r===s?`Create "${r}"`:`Save to ${r}`})]})]})})},AJn=t=>{const e=Y.useRef(null),n=eu(o=>o.recentEvents);Y.useEffect(()=>{if(n.length===0)return;const o=n[0];o.event_id!==e.current&&(t(o),e.current=o.event_id)},[n,t])};function RJn(t){const e=kJn(t),n=Y.forwardRef((o,r)=>{const{children:i,...s}=o,a=Y.Children.toArray(i),c=a.find(HJn);if(c){const l=c.props.children,u=a.map(_=>_===c?Y.Children.count(l)>1?Y.Children.only(null):Y.isValidElement(l)?l.props.children:null:_);return j.jsx(e,{...s,ref:r,children:Y.isValidElement(l)?Y.cloneElement(l,void 0,u):null})}return j.jsx(e,{...s,ref:r,children:i})});return n.displayName=`${t}.Slot`,n}function kJn(t){const e=Y.forwardRef((n,o)=>{const{children:r,...i}=n;if(Y.isValidElement(r)){const s=LJn(r),a=IJn(i,r.props);return r.type!==Y.Fragment&&(a.ref=o?Rx(o,s):s),Y.cloneElement(r,a)}return Y.Children.count(r)>1?Y.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var NJn=Symbol("radix.slottable");function HJn(t){return Y.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===NJn}function IJn(t,e){const n={...e};for(const o in e){const r=t[o],i=e[o];/^on[A-Z]/.test(o)?r&&i?n[o]=(...a)=>{const c=i(...a);return r(...a),c}:r&&(n[o]=r):o==="style"?n[o]={...r,...i}:o==="className"&&(n[o]=[r,i].filter(Boolean).join(" "))}return{...t,...n}}function LJn(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var vY="Dialog",[kdt,Ndt]=d4(vY),[OJn,B4]=kdt(vY),Hdt=t=>{const{__scopeDialog:e,children:n,open:o,defaultOpen:r,onOpenChange:i,modal:s=!0}=t,a=Y.useRef(null),c=Y.useRef(null),[l,u]=DP({prop:o,defaultProp:r??!1,onChange:i,caller:vY});return j.jsx(OJn,{scope:e,triggerRef:a,contentRef:c,contentId:Jp(),titleId:Jp(),descriptionId:Jp(),open:l,onOpenChange:u,onOpenToggle:Y.useCallback(()=>u(_=>!_),[u]),modal:s,children:n})};Hdt.displayName=vY;var Idt="DialogTrigger",Ldt=Y.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,r=B4(Idt,n),i=tu(e,r.triggerRef);return j.jsx(Cc.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.contentId,"data-state":kye(r.open),...o,ref:i,onClick:Vr(t.onClick,r.onOpenToggle)})});Ldt.displayName=Idt;var Aye="DialogPortal",[FJn,Odt]=kdt(Aye,{forceMount:void 0}),Fdt=t=>{const{__scopeDialog:e,forceMount:n,children:o,container:r}=t,i=B4(Aye,e);return j.jsx(FJn,{scope:e,forceMount:n,children:Y.Children.map(o,s=>j.jsx(Fg,{present:n||i.open,children:j.jsx(Lj,{asChild:!0,container:r,children:s})}))})};Fdt.displayName=Aye;var SY="DialogOverlay",Bdt=Y.forwardRef((t,e)=>{const n=Odt(SY,t.__scopeDialog),{forceMount:o=n.forceMount,...r}=t,i=B4(SY,t.__scopeDialog);return i.modal?j.jsx(Fg,{present:o||i.open,children:j.jsx(zJn,{...r,ref:e})}):null});Bdt.displayName=SY;var BJn=RJn("DialogOverlay.RemoveScroll"),zJn=Y.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,r=B4(SY,n);return j.jsx(Uj,{as:BJn,allowPinchZoom:!0,shards:[r.contentRef],children:j.jsx(Cc.div,{"data-state":kye(r.open),...o,ref:e,style:{pointerEvents:"auto",...o.style}})})}),Z8="DialogContent",zdt=Y.forwardRef((t,e)=>{const n=Odt(Z8,t.__scopeDialog),{forceMount:o=n.forceMount,...r}=t,i=B4(Z8,t.__scopeDialog);return j.jsx(Fg,{present:o||i.open,children:i.modal?j.jsx(VJn,{...r,ref:e}):j.jsx($Jn,{...r,ref:e})})});zdt.displayName=Z8;var VJn=Y.forwardRef((t,e)=>{const n=B4(Z8,t.__scopeDialog),o=Y.useRef(null),r=tu(e,n.contentRef,o);return Y.useEffect(()=>{const i=o.current;if(i)return J2e(i)},[]),j.jsx(Vdt,{...t,ref:r,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Vr(t.onCloseAutoFocus,i=>{i.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Vr(t.onPointerDownOutside,i=>{const s=i.detail.originalEvent,a=s.button===0&&s.ctrlKey===!0;(s.button===2||a)&&i.preventDefault()}),onFocusOutside:Vr(t.onFocusOutside,i=>i.preventDefault())})}),$Jn=Y.forwardRef((t,e)=>{const n=B4(Z8,t.__scopeDialog),o=Y.useRef(!1),r=Y.useRef(!1);return j.jsx(Vdt,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{t.onCloseAutoFocus?.(i),i.defaultPrevented||(o.current||n.triggerRef.current?.focus(),i.preventDefault()),o.current=!1,r.current=!1},onInteractOutside:i=>{t.onInteractOutside?.(i),i.defaultPrevented||(o.current=!0,i.detail.originalEvent.type==="pointerdown"&&(r.current=!0));const s=i.target;n.triggerRef.current?.contains(s)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&r.current&&i.preventDefault()}})}),Vdt=Y.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:o,onOpenAutoFocus:r,onCloseAutoFocus:i,...s}=t,a=B4(Z8,n),c=Y.useRef(null),l=tu(e,c);return R2e(),j.jsxs(j.Fragment,{children:[j.jsx(Sj,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:r,onUnmountAutoFocus:i,children:j.jsx(ZN,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":kye(a.open),...s,ref:l,onDismiss:()=>a.onOpenChange(!1)})}),j.jsxs(j.Fragment,{children:[j.jsx(UJn,{titleId:a.titleId}),j.jsx(jJn,{contentRef:c,descriptionId:a.descriptionId})]})]})}),Rye="DialogTitle",$dt=Y.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,r=B4(Rye,n);return j.jsx(Cc.h2,{id:r.titleId,...o,ref:e})});$dt.displayName=Rye;var Wdt="DialogDescription",Udt=Y.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,r=B4(Wdt,n);return j.jsx(Cc.p,{id:r.descriptionId,...o,ref:e})});Udt.displayName=Wdt;var Xdt="DialogClose",jdt=Y.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,r=B4(Xdt,n);return j.jsx(Cc.button,{type:"button",...o,ref:e,onClick:Vr(t.onClick,()=>r.onOpenChange(!1))})});jdt.displayName=Xdt;function kye(t){return t?"open":"closed"}var Gdt="DialogTitleWarning",[WJn,Ydt]=EZt(Gdt,{contentName:Z8,titleName:Rye,docsSlug:"dialog"}),UJn=({titleId:t})=>{const e=Ydt(Gdt),n=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
5690
5690
 
5691
5691
  If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component.
5692
5692